randmarcomps 1.299.0 → 1.301.0

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.
@@ -928,6 +928,35 @@ export declare const Treemap: React_2.ForwardRefExoticComponent<TreemapProps & R
928
928
 
929
929
  declare interface TreemapProps {
930
930
  data: any[][];
931
+ /**
932
+ * A Google Charts options object for customizing the treemap's appearance and behavior.
933
+ * @see https://developers.google.com/chart/interactive/docs/gallery/treemap#configuration-options
934
+ *
935
+ * --- Popular Options ---
936
+ *
937
+ * ### Styling
938
+ * - `fontColor` (string): The color of the text inside nodes.
939
+ * - `fontFamily` (string): The font family for text.
940
+ * - `fontSize` (number): The font size for text.
941
+ * - `headerHeight` (number): The height of the header section for each node. Set to 0 to hide.
942
+ * - `useWeightedAverageForAggregation` (boolean): If true, a parent node's color is a weighted average of its children's colors, which often looks more intuitive. Defaults to false.
943
+ *
944
+ * ### Color & Scale
945
+ * - `minColor` (string): The color for nodes with the lowest value.
946
+ * - `midColor` (string): The color for nodes with the median value (requires 3-color mode).
947
+ * - `maxColor` (string): The color for nodes with the highest value.
948
+ * - `colorAxis` (object): A more advanced way to configure the color scale, e.g., `{ values: [min, mid, max], colors: ['#FF0000', '#FFFF00', '#00FF00'] }`.
949
+ * - `showScale` (boolean): If true, shows a gradient legend scale at the top of the chart.
950
+ *
951
+ * ### Tooltips
952
+ * - `showTooltips` (boolean): Set to false to disable tooltips entirely.
953
+ * - `generateTooltip` (function): A function that receives `(row, size, value)` and returns a custom HTML string for a tooltip.
954
+ *
955
+ * ### Interactivity
956
+ * - `maxDepth` (number): The maximum nesting depth to display. For example, a value of 1 shows only the top-level nodes.
957
+ * - `maxPostDepth` (number): The maximum depth to display after a user drills down into a node.
958
+ * - `goUpButton` (object): An object to configure the 'go up' button after drilling down, e.g., `{ text: '← Back', visible: true }`.
959
+ */
931
960
  options?: object;
932
961
  height?: string;
933
962
  className?: string;
@@ -64634,6 +64634,134 @@ function ManufacturerCard({
64634
64634
  ] })
64635
64635
  ] });
64636
64636
  }
64637
+ function formatYYYYMMDDIntToDateString$1(t) {
64638
+ if (t === null || typeof t > "u")
64639
+ return "N/A";
64640
+ const e = t.toString();
64641
+ return e.length === 8 ? `${e.substring(0, 4)}-${e.substring(4, 6)}-${e.substring(6, 8)}` : e;
64642
+ }
64643
+ function OrdersTable({
64644
+ orders: t = null,
64645
+ loading: e = !1,
64646
+ title: n = "Order Details"
64647
+ }) {
64648
+ const o = useMemo(
64649
+ () => [
64650
+ {
64651
+ accessorKey: "DocumentNumber",
64652
+ header: "Document Number",
64653
+ cell: ({ row: f }) => f.original.DocumentNumber ?? "N/A",
64654
+ enableSorting: !0,
64655
+ enableFiltering: !0
64656
+ },
64657
+ {
64658
+ accessorKey: "DocumentDate",
64659
+ header: "Document Date",
64660
+ cell: ({ row: f }) => formatYYYYMMDDIntToDateString$1(f.original.DocumentDate),
64661
+ enableSorting: !0,
64662
+ enableFiltering: !1
64663
+ },
64664
+ {
64665
+ accessorKey: "OrderNumber",
64666
+ header: "Order Number",
64667
+ cell: ({ row: f }) => f.original.OrderNumber ?? "N/A",
64668
+ enableSorting: !0,
64669
+ enableFiltering: !0
64670
+ },
64671
+ {
64672
+ accessorKey: "PONumber",
64673
+ header: "PO Number",
64674
+ cell: ({ row: f }) => f.original.PONumber ?? "N/A",
64675
+ enableSorting: !0,
64676
+ enableFiltering: !0
64677
+ },
64678
+ {
64679
+ accessorKey: "WarehouseCode",
64680
+ header: "Warehouse",
64681
+ cell: ({ row: f }) => f.original.WarehouseCode ?? "N/A",
64682
+ enableSorting: !0,
64683
+ enableFiltering: !0
64684
+ },
64685
+ {
64686
+ accessorKey: "Quantity",
64687
+ header: "Quantity",
64688
+ cell: ({ row: f }) => f.original.Quantity ?? "N/A",
64689
+ enableSorting: !0,
64690
+ enableFiltering: !1
64691
+ },
64692
+ {
64693
+ accessorKey: "ShipToName",
64694
+ header: "Name",
64695
+ cell: ({ row: f }) => /* @__PURE__ */ jsx("div", { className: "min-w-[150px]", children: f.original.ShipToName ?? "N/A" }),
64696
+ enableSorting: !0,
64697
+ enableFiltering: !0
64698
+ },
64699
+ {
64700
+ accessorKey: "UnitPrice",
64701
+ header: "Unit Price",
64702
+ cell: ({ row: f }) => f.original.UnitPrice ? formatMoney(f.original.UnitPrice) : "N/A",
64703
+ enableSorting: !0,
64704
+ enableFiltering: !1
64705
+ // Currency filtering usually needs range
64706
+ }
64707
+ ],
64708
+ []
64709
+ ), l = useMemo(() => {
64710
+ const f = {};
64711
+ if (t) {
64712
+ const g = Array.from(
64713
+ new Set(t.map((E) => E.WarehouseCode).filter((E) => E != null))
64714
+ );
64715
+ f.WarehouseCode = g;
64716
+ const b = Array.from(
64717
+ new Set(t.map((E) => E.ShipToName).filter((E) => E != null))
64718
+ );
64719
+ f.ShipToName = b;
64720
+ const S = Array.from(
64721
+ new Set(t.map((E) => E.DocumentNumber).filter((E) => E != null))
64722
+ );
64723
+ f.DocumentNumber = S;
64724
+ const _ = Array.from(
64725
+ new Set(t.map((E) => E.OrderNumber).filter((E) => E != null))
64726
+ );
64727
+ f.OrderNumber = _;
64728
+ const C = Array.from(
64729
+ new Set(t.map((E) => E.PONumber).filter((E) => E != null))
64730
+ );
64731
+ f.PONumber = C;
64732
+ }
64733
+ return f;
64734
+ }, [t]), d = t || [];
64735
+ return e ? /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
64736
+ /* @__PURE__ */ jsxs(CardHeader, { children: [
64737
+ " ",
64738
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-48" }),
64739
+ " "
64740
+ ] }),
64741
+ /* @__PURE__ */ jsxs(CardContent, { className: "space-y-4", children: [
64742
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-12 w-full rounded-md border" }),
64743
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full rounded-md border" }),
64744
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full rounded-md border" }),
64745
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full rounded-md border" }),
64746
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pt-4", children: [
64747
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-[130px]" }),
64748
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
64749
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-20" }),
64750
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-24" }),
64751
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9" }),
64752
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9" })
64753
+ ] })
64754
+ ] })
64755
+ ] })
64756
+ ] }) : /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
64757
+ /* @__PURE__ */ jsxs(CardHeader, { children: [
64758
+ " ",
64759
+ /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: n }),
64760
+ " "
64761
+ ] }),
64762
+ /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(DataTable, { columns: o, data: d, uniqueValues: l }) })
64763
+ ] });
64764
+ }
64637
64765
  function ResellerOverview({
64638
64766
  appID: t,
64639
64767
  reseller: e,
@@ -64738,6 +64866,28 @@ function ResellerOverview({
64738
64866
  loading: g
64739
64867
  }
64740
64868
  ),
64869
+ /* @__PURE__ */ jsx(
64870
+ OrdersTable,
64871
+ {
64872
+ title: "Active Orders",
64873
+ orders: A == null ? void 0 : A.ActiveOrderDetails,
64874
+ loading: g
64875
+ }
64876
+ ),
64877
+ /* @__PURE__ */ jsx(
64878
+ OrdersTable,
64879
+ {
64880
+ title: "Completed Orders",
64881
+ loading: g
64882
+ }
64883
+ ),
64884
+ /* @__PURE__ */ jsx(
64885
+ ReturnsTable,
64886
+ {
64887
+ applicationId: t,
64888
+ loading: g
64889
+ }
64890
+ ),
64741
64891
  !d && /* @__PURE__ */ jsx(
64742
64892
  ReportsSection,
64743
64893
  {
@@ -91309,134 +91459,6 @@ function RichTextEditor({ id: t, name: e, value: n, onChange: o, placeholder: l,
91309
91459
  }
91310
91460
  ) : null;
91311
91461
  }
91312
- function formatYYYYMMDDIntToDateString$1(t) {
91313
- if (t === null || typeof t > "u")
91314
- return "N/A";
91315
- const e = t.toString();
91316
- return e.length === 8 ? `${e.substring(0, 4)}-${e.substring(4, 6)}-${e.substring(6, 8)}` : e;
91317
- }
91318
- function OrdersTable({
91319
- orders: t = null,
91320
- loading: e = !1,
91321
- title: n = "Order Details"
91322
- }) {
91323
- const o = useMemo(
91324
- () => [
91325
- {
91326
- accessorKey: "DocumentNumber",
91327
- header: "Document Number",
91328
- cell: ({ row: f }) => f.original.DocumentNumber ?? "N/A",
91329
- enableSorting: !0,
91330
- enableFiltering: !0
91331
- },
91332
- {
91333
- accessorKey: "DocumentDate",
91334
- header: "Document Date",
91335
- cell: ({ row: f }) => formatYYYYMMDDIntToDateString$1(f.original.DocumentDate),
91336
- enableSorting: !0,
91337
- enableFiltering: !1
91338
- },
91339
- {
91340
- accessorKey: "OrderNumber",
91341
- header: "Order Number",
91342
- cell: ({ row: f }) => f.original.OrderNumber ?? "N/A",
91343
- enableSorting: !0,
91344
- enableFiltering: !0
91345
- },
91346
- {
91347
- accessorKey: "PONumber",
91348
- header: "PO Number",
91349
- cell: ({ row: f }) => f.original.PONumber ?? "N/A",
91350
- enableSorting: !0,
91351
- enableFiltering: !0
91352
- },
91353
- {
91354
- accessorKey: "WarehouseCode",
91355
- header: "Warehouse",
91356
- cell: ({ row: f }) => f.original.WarehouseCode ?? "N/A",
91357
- enableSorting: !0,
91358
- enableFiltering: !0
91359
- },
91360
- {
91361
- accessorKey: "Quantity",
91362
- header: "Quantity",
91363
- cell: ({ row: f }) => f.original.Quantity ?? "N/A",
91364
- enableSorting: !0,
91365
- enableFiltering: !1
91366
- },
91367
- {
91368
- accessorKey: "ShipToName",
91369
- header: "Name",
91370
- cell: ({ row: f }) => /* @__PURE__ */ jsx("div", { className: "min-w-[150px]", children: f.original.ShipToName ?? "N/A" }),
91371
- enableSorting: !0,
91372
- enableFiltering: !0
91373
- },
91374
- {
91375
- accessorKey: "UnitPrice",
91376
- header: "Unit Price",
91377
- cell: ({ row: f }) => f.original.UnitPrice ? formatMoney(f.original.UnitPrice) : "N/A",
91378
- enableSorting: !0,
91379
- enableFiltering: !1
91380
- // Currency filtering usually needs range
91381
- }
91382
- ],
91383
- []
91384
- ), l = useMemo(() => {
91385
- const f = {};
91386
- if (t) {
91387
- const g = Array.from(
91388
- new Set(t.map((E) => E.WarehouseCode).filter((E) => E != null))
91389
- );
91390
- f.WarehouseCode = g;
91391
- const b = Array.from(
91392
- new Set(t.map((E) => E.ShipToName).filter((E) => E != null))
91393
- );
91394
- f.ShipToName = b;
91395
- const S = Array.from(
91396
- new Set(t.map((E) => E.DocumentNumber).filter((E) => E != null))
91397
- );
91398
- f.DocumentNumber = S;
91399
- const _ = Array.from(
91400
- new Set(t.map((E) => E.OrderNumber).filter((E) => E != null))
91401
- );
91402
- f.OrderNumber = _;
91403
- const C = Array.from(
91404
- new Set(t.map((E) => E.PONumber).filter((E) => E != null))
91405
- );
91406
- f.PONumber = C;
91407
- }
91408
- return f;
91409
- }, [t]), d = t || [];
91410
- return e ? /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
91411
- /* @__PURE__ */ jsxs(CardHeader, { children: [
91412
- " ",
91413
- /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-48" }),
91414
- " "
91415
- ] }),
91416
- /* @__PURE__ */ jsxs(CardContent, { className: "space-y-4", children: [
91417
- /* @__PURE__ */ jsx(Skeleton, { className: "h-12 w-full rounded-md border" }),
91418
- /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full rounded-md border" }),
91419
- /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full rounded-md border" }),
91420
- /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full rounded-md border" }),
91421
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pt-4", children: [
91422
- /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-[130px]" }),
91423
- /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
91424
- /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-20" }),
91425
- /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-24" }),
91426
- /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9" }),
91427
- /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9" })
91428
- ] })
91429
- ] })
91430
- ] })
91431
- ] }) : /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
91432
- /* @__PURE__ */ jsxs(CardHeader, { children: [
91433
- " ",
91434
- /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: n }),
91435
- " "
91436
- ] }),
91437
- /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(DataTable, { columns: o, data: d, uniqueValues: l }) })
91438
- ] });
91439
- }
91440
91462
  function formatYYYYMMDDIntToDateString(t) {
91441
91463
  if (t === null || typeof t > "u")
91442
91464
  return "N/A";
@@ -91641,9 +91663,6 @@ function ReturnsTable({
91641
91663
  ] })
91642
91664
  ] })
91643
91665
  ] })
91644
- ] }) : !d || d.length === 0 ? /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
91645
- /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: "Returns" }) }),
91646
- /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", { className: "flex justify-center items-center h-24", children: /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "There are no returns to display." }) }) })
91647
91666
  ] }) : /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
91648
91667
  /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: "Returns" }) }),
91649
91668
  /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(DataTable, { columns: o, data: d, uniqueValues: l }) })
@@ -92817,9 +92836,9 @@ const Treemap = React.forwardRef(
92817
92836
  }, []);
92818
92837
  const _ = React.useMemo(() => {
92819
92838
  const C = {
92820
- headerHeight: 24,
92839
+ headerHeight: 0,
92821
92840
  fontSize: 14,
92822
- showScale: !0,
92841
+ showScale: !1,
92823
92842
  isHtml: !0,
92824
92843
  generateTooltip: (E, R) => {
92825
92844
  var M;
@@ -1071,7 +1071,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
1071
1071
 
1072
1072
  Defaulting to \`null\`.`}var Root=Progress$1,Indicator=ProgressIndicator;const Progress=React__namespace.forwardRef(({className:t,value:e,...n},o)=>jsxRuntime.jsx(Root,{ref:o,className:cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...n,children:jsxRuntime.jsx(Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(e||0)}%)`}})}));Progress.displayName=Root.displayName;function ManufacturerInventoryFinanceCard({manufacturer:t,isLoading:e}){const{data:n,isLoading:o,isFetching:l}=useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({routeManufacturerId:(t==null?void 0:t.ManufacturerId)??""},{skip:!(t!=null&&t.ManufacturerId)}),d=(t==null?void 0:t.DefaultMaxInventoryValue)??0,f=(n||[]).reduce((_,S)=>_+(S.InventoryValue||0),0),g=d-f,b=Math.round(f/d*100);return e||o||l?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-muted-foreground"}),"Inventory Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current inventory financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Max Allowance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(d)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current Funds"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(f)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Funds"}),jsxRuntime.jsx("span",{className:`font-bold ${g>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(g)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Budget Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[b,"%"]}),b>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:b,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:t,isLoading:e}){const n=(t==null?void 0:t.CreditLimit)??0,o=(t==null?void 0:t.OutstandingBalance)??0,l=n-o,d=Math.round(o/n*100);return e?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-muted-foreground"}),"Credit Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current credit financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Limit"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(n)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Outstanding Balance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(o)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Credit"}),jsxRuntime.jsx("span",{className:`font-bold ${l>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(l)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[d,"%"]}),d>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d>80?"High credit usage alert":"Credit usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:d,className:"h-2"})]})]})]})}function ManufacturerOverviewPage({applicationId:t,readonly:e,withReports:n,manufacturer:o,userEmail:l}){const{data:d,isLoading:f,isError:g}=useGetV4PartnerByApplicationIdAccountManufacturerQuery({applicationId:t,withSpecification:!0},{skip:!!o}),[b,_]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),S=React.useCallback(()=>e?!1:b.publicInfo.hasUnsavedChanges||b.qualifications.hasUnsavedChanges||b.billingInfo.hasUnsavedChanges,[e,b]),R=React.useCallback((A,I)=>{_(M=>{var j;return((j=M[A])==null?void 0:j.hasUnsavedChanges)!==I.hasUnsavedChanges?(console.log(`Updating form state for ${A}:`,I.hasUnsavedChanges),{...M,[A]:I}):M})},[]),{NavigationGuardDialog:C}=useRouterNavigationGuard(S),E=o??d;return jsxRuntime.jsxs("div",{className:"@container",children:[g?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your manufacturer information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:E==null?void 0:E.FiscalYearMonthStart,salesData:E==null?void 0:E.SalesData,isLoading:f}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChart,{salesData:(E==null?void 0:E.SalesStatistics)??[],isLoading:f}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",activeOrders:(E==null?void 0:E.ActiveOrderDetails)??void 0,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:E??{},onSave:()=>{},loading:f,readonly:!0}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("publicInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:E,readonly:e,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("billingInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("qualifications",{hasUnsavedChanges:A})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",userEmail:l,isLoading:f})]}),jsxRuntime.jsx(C,{})]})}function ManufacturerCategories({categories:t,activeCategory:e,onSelectCategory:n}){return jsxRuntime.jsx("div",{className:"grid",children:jsxRuntime.jsx("div",{className:"flex overflow-x-auto small-scrollbar pb-4",children:jsxRuntime.jsx("div",{className:"flex gap-2",children:t.map(o=>jsxRuntime.jsxs(Button,{onClick:()=>n(o.CategoryCode??""),variant:e===o.CategoryCode?"default":"outline",size:"sm",className:"px-3 py-1.5 text-xs whitespace-nowrap rounded-full",children:[o.CategoryName??"Undefined",o.QualificationRequired&&jsxRuntime.jsx(ShieldCheck,{className:`ml-1 w-5 h-5 ${e!==o.CategoryCode?"text-red-500":""}`})]},o.CategoryCode))})})})}function ManufacturerProducts({applicationId:t,manufacturer:e,shopifyHostName:n}){var M,j,q,z;const[o]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[l,d]=React.useState(((j=(M=e.Categories)==null?void 0:M[0])==null?void 0:j.CategoryCode)||""),[f,g]=React.useState(!1),[b,_]=React.useState(!1),{toast:S}=useToast(),{data:R,isLoading:C,isFetching:E}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:t,manufacturerId:e.ManufacturerId,categoryCode:l??""},{skip:!e.ManufacturerId||!l}),A=async()=>{try{g(!0),_(!1),await o({routeResellerId:t,manufacturerId:e.ManufacturerId??"",categoryCode:l,shopifyHostName:n}).unwrap()&&S({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(Q){console.error("Error syncing to Shopify:",Q),S({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{g(!1)}},I=()=>{var Q,F;return((F=(Q=e.Categories)==null?void 0:Q.find(V=>V.CategoryCode===l))==null?void 0:F.CategoryName)||l};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(ManufacturerCategories,{categories:e.Categories||[],activeCategory:l,onSelectCategory:d}),n&&((q=e.Categories)==null?void 0:q.findIndex(Q=>Q.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:b,onOpenChange:_,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700 mb-4",disabled:f,children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Category to Shopify"]})})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the category "',I(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",onClick:A,disabled:f,children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:C||E?Array.from({length:4}).map((Q,F)=>jsxRuntime.jsx(ProductCard,{},F)):R!=null&&R.Products&&(R==null?void 0:R.Products.length)>0?(z=[...R.Products].sort((Q,F)=>{const V=Q.OverallPercentileRank??0;return(F.OverallPercentileRank??0)-V}))==null?void 0:z.map(Q=>jsxRuntime.jsx(ProductCard,{applicationId:t,product:Q,viewProductLink:`/${t}/Product/${Q.RandmarSKU}`,shopifyHostname:n},Q.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",className:"col-span-1 @md:col-span-2",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Warning"}),jsxRuntime.jsx(AlertDescription,{children:"No products found for this manufacturer category."})]})})]})}function PartnerRelationshipPage({applicationId:t,partnerId:e,userEmail:n,shopifyHostName:o,isSuperAdmin:l}){var j,q,z;const{data:d,isLoading:f,isFetching:g}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:t,partnerId:e,withSpecification:!0}),b=f||g,{toast:_}=useToast(),[S]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[R,C]=React.useState(!1),[E,A]=React.useState(!1),I=async()=>{try{C(!0),A(!1),await S({routeResellerId:t??"",manufacturerId:e??"",shopifyHostName:o}).unwrap()&&_({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(Q){console.error("Error syncing to Shopify:",Q),_({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{C(!1)}},M=()=>d!=null&&d.Reseller?"reseller-overview":d!=null&&d.Manufacturer?"manufacturer-overview":"";return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:d,loading:b,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((d==null?void 0:d.Manufacturer)||b)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:d==null?void 0:d.Manufacturer,loading:b,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:t,manufacturer:d==null?void 0:d.Manufacturer}),o&&((q=(j=d==null?void 0:d.Manufacturer)==null?void 0:j.Categories)==null?void 0:q.findIndex(Q=>Q.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:E,onOpenChange:A,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Manufacturer to Shopify"]})})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the manufacturer "',(z=d==null?void 0:d.Manufacturer)==null?void 0:z.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",onClick:I,disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:d==null?void 0:d.Reseller,loading:b})]})]}),((d==null?void 0:d.Reseller)||(d==null?void 0:d.Manufacturer))&&!b&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:M(),className:"w-full",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Reseller Overview"}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Manufacturer Overview"}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"products",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Products"})]}),(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:d.ApplicationId||"",reseller:d==null?void 0:d.Reseller,userEmail:n,isSuperAdmin:l,withoutReports:!0})})}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:d==null?void 0:d.Manufacturer,applicationId:t,userEmail:n})})}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:t,manufacturer:d.Manufacturer,shopifyHostName:o})})})]})}),b&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}const PublicInfo=({reseller:t,appID:e,isLoading:n,readonly:o,onUnsavedChanges:l})=>{const{toast:d}=useToast(),[f]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[g,b]=React.useState({}),_=React.useMemo(()=>({publicEmail:t.PublicEmail??"",contactName:t.ContactName??"",phone:t.Phone??"",website:t.Website??""}),[t]),{register:S,handleSubmit:R,reset:C,watch:E,formState:{errors:A,isSubmitting:I}}=useForm({defaultValues:_}),M=E(),j=React.useCallback(()=>g?JSON.stringify(M)!==JSON.stringify(g):!1,[M,g]);React.useEffect(()=>{l&&l(j())},[j,l]),React.useEffect(()=>{t&&Object.keys(t).length>0&&(C(_),b(_))},[t,C,_]);const q=async Q=>{let F=!0,V=!1;const te=Object.keys(Q).map(ne=>({key:ne,keyApi:ne.charAt(0).toUpperCase()+ne.slice(1)}));for(const ne of te){const se=Q[ne.key],ge=t[ne.keyApi];if(se!==ge&&se!==void 0){V=!0;try{await f({applicationId:e,fieldName:ne.keyApi,newValue:String(se)}).unwrap()||(F=!1)}catch(oe){console.error(`Error updating ${ne.keyApi}:`,oe),F=!1}}}F&&V?(d({title:"Public info",description:"Information updated successfully",variant:"success"}),b({...Q}),l&&l(!1)):F||d({title:"Updation error",description:"Failed to update",variant:"destructive"})},z=Q=>!Q||Q.trim()==="";return n?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Public Information"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})})]})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{className:"text-1xl font-bold",children:["Public Information ",o?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(z(E("contactName"))||z(E("publicEmail"))||z(E("website"))||z(E("phone")))&&jsxRuntime.jsxs(Alert,{variant:"destructive",className:"mb-6",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Missing information"}),jsxRuntime.jsx(AlertDescription,{children:"All fields are required to get started at working with Manufacturers."})]}),jsxRuntime.jsxs("form",{onSubmit:R(q),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"contactName",children:"Main Representative *"}),jsxRuntime.jsx(Input,{id:"contactName",placeholder:"John Doe",readOnly:o,...S("contactName",{}),className:A.contactName||z(E("contactName"))?"input-error-indicator":""}),A.contactName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.contactName.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"publicEmail",children:"Public Email *"}),jsxRuntime.jsx(Input,{id:"publicEmail",placeholder:"contact@company.com",readOnly:o,...S("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:A.publicEmail||z(E("publicEmail"))?"input-error-indicator":""}),A.publicEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.publicEmail.message})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"website",children:"Website *"}),jsxRuntime.jsx(Input,{id:"website",placeholder:"https://company.com",readOnly:o,...S("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.website||z(E("website"))?"input-error-indicator":""}),A.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.website.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"phone",children:"Phone Number *"}),jsxRuntime.jsx(Input,{id:"phone",placeholder:"+1 (555) 123-4567",readOnly:o,...S("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.phone||z(E("phone"))?"input-error-indicator":""}),A.phone&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{type:"submit",disabled:I||o,className:o?"hidden":"",children:I?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:t,reseller:e,isLoading:n,withoutReports:o}){const{Statement:l,CreditLimit:d}=e,f=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(l==null?void 0:l.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(l==null?void 0:l.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(l==null?void 0:l.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(l==null?void 0:l.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsx(FormattedNumber,{value:d||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CreditCard}],g=()=>{const _=`https://dashboard.randmar.io/${t}/PayInvoice`;window.open(_,"_blank","noopener,noreferrer")};if(n)return jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-36"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:[1,2,3].map(_=>jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]},_))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:[1,2].map(_=>jsxRuntime.jsx("div",{className:_===2?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]})},_))})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-28 mt-6"})})]})]});const b=!o;return jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:f.slice(0,3).map((_,S)=>jsxRuntime.jsx(BillingItem,{icon:_.icon,label:_.label,value:_.value},S))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:f.slice(3).map((_,S)=>jsxRuntime.jsx("div",{className:S===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:_.icon,label:_.label,value:_.value})},S))})]}),b&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{className:"mt-6",onClick:g,children:"Pay Invoices"})})]})]})}function BillingItem({icon:t,label:e,value:n}){return jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(t,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:e})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:t,setOpen:e,tier:n,onTierChange:o,isLoading:l}){const d=()=>{e(!1)};return jsxRuntime.jsx(Dialog,{open:t,onOpenChange:e,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Change Pricing Tier"})}),jsxRuntime.jsxs("div",{className:"grid gap-1.5 py-2",children:[jsxRuntime.jsxs("p",{className:"text-lg text-muted-foreground",children:["Requested Pricing Tier: ",jsxRuntime.jsx("span",{className:"font-bold",children:n})]}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If your account qualifies, your pricing will update immediately."}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If not, we'll review your request and notify you of the decision."})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:d,disabled:l,children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:o,disabled:l,children:l?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=t=>t===1?"The Best":t===2?"Fixed 12.5% GP on all items":t===3?"Advantageous":t===4?"Buying Group":t===5?"Cost":t,getShippingText=t=>t==="A"?"Free or Custom":t==="B"?"Fixed $10 anywhere":t==="C"?`Free shipping on $150+ orders to your location,
1073
1073
  $15 for drop shipped orders under $1,500,
1074
- $10 with opportunities under $1,000`:t==="D"?"$15 under $1,500":t==="E"?"Full shipping charges":t,getTermsText=t=>t==="STRIPE"?"Credit card payment":t==="NET30"?"Net 30 days":t,AccountTier=({isSuperAdmin:t,readonly:e,reseller:n,appID:o,isLoading:l})=>{const{toast:d}=useToast(),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=Oe=>Oe&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Oe]||"",E=Oe=>Oe&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Oe]||"",A=Oe=>Oe&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Oe]||"",[I,M]=React.useState(C((n==null?void 0:n.Priority)??"")),[j,q]=React.useState(E((n==null?void 0:n.ShippingProfile)??"")),[z,Q]=React.useState(A(n==null?void 0:n.PriceProfile)),F=Oe=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Oe]||Oe,V=Oe=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Oe]||Oe,te=Oe=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Oe]||Oe;React.useEffect(()=>{M(C((n==null?void 0:n.Priority)??"")),q(E((n==null?void 0:n.ShippingProfile)??"")),Q(A(n==null?void 0:n.PriceProfile))},[n]);const ne=async(Oe,Fe,ze,$e)=>{try{(await S({applicationId:o,fieldName:Oe,newValue:Fe})).error?d({title:"Error",description:$e,variant:"destructive"}):d({title:"Success",description:ze,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},se=async Oe=>{M(Oe);const Fe=F(Oe);ne("Priority",Fe,`Priority updated to ${Fe}`,"Failed to update priority")},ge=async Oe=>{q(Oe);const Fe=V(Oe);ne("ShippingProfile",Fe,`Shipping profile updated to ${Fe}`,"Failed to update shipping profile")},oe=async Oe=>{Q(Oe);const Fe=te(Oe);ne("PriceProfile",Fe,`Pricing profile updated to ${Fe}`,"Failed to update pricing profile")},Ae=async()=>{try{const Oe=await S({applicationId:o,fieldName:"Tier",newValue:b});Oe.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Oe.data?d({title:"Success",description:`Pricing Tier changed to ${b}`,variant:"success"}):d({title:"Considered",description:"Request being considered",variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{g(!1),_("")}},je=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:t}],Ne=Oe=>{_(Oe),g(!0)};return l?jsxRuntime.jsxs(Card,{className:"md:col-span-2 xl:col-span-1 md:max-w-xl xl:max-w-[unset]",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},Oe))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"md:col-span-2 xl:col-span-1 md:max-w-xl xl:max-w-[unset]",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[(n==null?void 0:n.Priority)||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-green-600"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText((n==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!e&&jsxRuntime.jsx(Button,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs("a",{href:"https://www.randmar.io/docs/overview/pricingTiers",target:"_blank",rel:"noreferrer",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{disabled:e,className:e?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),je.map(Oe=>jsxRuntime.jsx(Button,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Oe.enabled,onClick:()=>Ne(Oe.name),children:Oe.name},Oe.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:Ae}),t&&!e&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:I,onValueChange:se,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`priority-${Oe.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:j,onValueChange:ge,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`shipping-${Oe.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:z,onValueChange:oe,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`pricing-${Oe.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.value))})]})]})})]})]})};function OrderCategories({openOrders:t=[],isLoading:e=!1}){const n=(t==null?void 0:t.filter(I=>I.DocumentType==="Order"))||[],o=(t==null?void 0:t.filter(I=>I.DocumentType==="Shipment"))||[],l=n.filter(I=>I.WarehouseCode!=="3PLE"),d=l.reduce((I,M)=>I+(M.Quantity??0),0),f=l.reduce((I,M)=>I+(M.ExtendedPrice??0),0),g=n.filter(I=>I.WarehouseCode==="3PLE"),b=g.reduce((I,M)=>I+(M.Quantity??0),0),_=g.reduce((I,M)=>I+(M.ExtendedPrice??0),0),S=o.reduce((I,M)=>I+(M.Quantity??0),0),R=o.reduce((I,M)=>I+(M.ExtendedPrice??0),0),C=d+b+S,E=f+_+R,A=[{name:"All",icon:Package,color:"bg-blue-500",orders:C,amount:E},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:d,amount:f},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:S,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:_}];return e?jsxRuntime.jsxs(Card,{className:"w-full @md:col-span-2 @xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(I=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:"bg-gray-200 h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},I))})})]}):jsxRuntime.jsxs(Card,{className:"w-full @md:col-span-2 @xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:A.map(I=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${I.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:I.name}),jsxRuntime.jsx("div",{className:`${I.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(I.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:I.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:I.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},I.name))})})]})}function ReportsSection({isLoading:t,userEmail:e,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[S,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:I}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[M,j]=React.useState(null),[q,z]=React.useState(e),[Q,F]=React.useState(!1),V=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],te=async ge=>{j(ge),F(!0)},ne=async()=>{if(!(!M||!n))try{switch(M.id){case"Products":await S({routeResellerId:n,emailAddress:q}).unwrap();break;case"AmazonTrackingFile":await f({routeResellerId:n,emailAddress:q}).unwrap();break;case"WalmartTrackingFile":await l({routeResellerId:n,emailAddress:q}).unwrap();break;case"OpenOrders":await b({routeResellerId:n,emailAddress:q}).unwrap();break;case"Invoices":await C({routeResellerId:n,emailAddress:q}).unwrap();break;case"Statement":await A({routeResellerId:n,emailAddress:q}).unwrap();break;default:throw new Error("invalid report id")}o({title:"Report requested",description:`The ${M.title} will be sent to ${q} shortly.`,variant:"success"}),F(!1)}catch(ge){console.error("Error requesting report:",ge),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},se=_||R||g||d||I||E;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:t?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(oe=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},oe))]},ge))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:V.map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:ge.name}),ge.reports.map(oe=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(oe.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:oe.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:oe.description})]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>te(oe),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},oe.id))]},ge.name))})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:F,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",M==null?void 0:M.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:q,onChange:ge=>z(ge.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:ne,disabled:!q||se,children:se?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:t,variant:e,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:e,size:n}),t),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function QualificationBadge({qualification:t}){return!t.QualificationId||t.QualificationId==="Suspended"?null:t.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$1,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:t.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),t.QualificationId,t.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:t.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function useIntersectionObserver({elementRef:t,threshold:e=0,rootMargin:n="0px",freezeOnceVisible:o=!1}){const[l,d]=React.useState(!1);return React.useEffect(()=>{const f=t.current;if(!f){d(!1);return}const g=new IntersectionObserver(([b])=>{const _=b.isIntersecting;o&&_?(d(!0),g.unobserve(f)):d(_)},{threshold:e,rootMargin:n});return g.observe(f),()=>{g.unobserve(f)}},[t,e,n,o]),l}const PartnerLogo=({id:t,name:e,width:n=64,height:o=64,align:l=""})=>{const d=React.useRef(null),[f,g]=React.useState(!1),[b,_]=React.useState(null),S=useIntersectionObserver({elementRef:d,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{data:R,isFetching:C}=useGetV4PartnerByApplicationIdAccountLogoExistsQuery({applicationId:t??""},{skip:!t||!S});React.useEffect(()=>{_(null),!(!t||C||!R||R==="false")&&(g(!0),fetch(`https://api.randmar.io/V4/Partner/${t}/Account/Logo?width=${n}&height=${o}&align=${l}`).then(M=>{M.ok||console.error("error fetching logo"),M.blob().then(j=>{const q=window.URL.createObjectURL(j);_(q)})}).catch(M=>{console.error("error loading logo",M)}).finally(()=>{g(!1)}))},[t,R,C]);const E="No Logo",A=e||(t?`Partner ID: ${t}`:"Logo not available (no ID)"),I=()=>!S||C||f?jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-sm"}):b?jsxRuntime.jsx("img",{src:b,alt:A,className:"h-full w-full object-contain rounded-sm"}):jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center border border-dashed border-border rounded-sm bg-muted/20 p-1",title:A,children:jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground font-mono text-center leading-none",children:E})});return jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("div",{className:"flex h-full w-full cursor-default",ref:d,children:I()})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",children:A})]})})};function ManufacturerCard({manufacturer:t,link:e,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1}){var C,E,A;if(d||!t)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const f=t.ManufacturerId||"N/A",g=[t.City,t.Province,t.Country].filter(Boolean),b=g.length>0?g.join(", "):"",_=((C=t.Tags)==null?void 0:C.split(",").map(I=>I.trim()).filter(Boolean))||[],R=(I=>!I||I.length===0?[]:[...I].sort((M,j)=>(M.Day||0)-(j.Day||0)).map(M=>({date:M.Day||0,amount:M.ExtendedPrice||0})))(t.SalesStatistics);return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(reactRouterDom.Link,{to:e??"#",target:e&&n?"_blank":"_self",children:jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,width:48,height:48})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Manufacturer"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:f})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:t.PublicName||"N/A"}),t.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t.Name}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:b})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:R.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(AreaChart,{data:R,height:60,size:"mini"})})})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!((E=t.Qualification)!=null&&E.QualificationId)&&((A=t.Qualification)==null?void 0:A.QualificationId)!=="Suspended"||!!t.OpenToWork||!!t.OnHold&&t.OnHold!==0||_.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:t.Qualification??{}}),!!t.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!t.OnHold&&t.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),_.map((I,M)=>jsxRuntime.jsx(Badge,{variant:"outline",children:I},M))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[t.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${t.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.Phone})]}),t.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${t.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.PublicEmail})]}),t.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:t.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.Website})]}),t.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.CurrencyCode})]})]})]}),t.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesYearToDay?formatMoney(t.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast3Months?formatMoney(t.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast30Days?formatMoney(t.SalesData.SalesLast30Days):"—"})]})]})}),(o||l)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:o&&o}),l&&jsxRuntime.jsx("div",{children:l})]})]})}function ResellerOverview({appID:t,reseller:e,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){const{data:f,isLoading:g,isError:b}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:t??"",withSpecification:!0},{skip:!!e}),[_,S]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>n?!1:_.publicInfo.hasUnsavedChanges,[n,_]),C=React.useCallback((q,z)=>{S(Q=>{var F;return((F=Q[q])==null?void 0:F.hasUnsavedChanges)!==z.hasUnsavedChanges?{...Q,[q]:z}:Q})},[]),{NavigationGuardDialog:E}=useRouterNavigationGuard(R),A=e??f,I=!n||!!(A!=null&&A.Statement)&&(A.Statement.Total??0)>0,M=(A==null?void 0:A.QualifiedManufacturers)??[],j=(A==null?void 0:A.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[b?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:(A==null?void 0:A.FiscalYearMonthStart)||1,salesData:A==null?void 0:A.SalesData,isLoading:g}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChart,{salesData:(A==null?void 0:A.SalesStatistics)??[],isLoading:g}),jsxRuntime.jsx(OrderCategories,{openOrders:(A==null?void 0:A.ActiveOrderDetails)??[],isLoading:g}),I&&jsxRuntime.jsx(BillingCard,{appID:t,reseller:A||{},withoutReports:d,isLoading:g}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:t??"",isLoading:g,readonly:n,onUnsavedChanges:q=>C("publicInfo",{hasUnsavedChanges:q})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:l,readonly:n,reseller:A||{},appID:t??"",isLoading:g})]}),g||M.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @2xl:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((q,z)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},z)):M.map(q=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:q,link:`https://dashboard.randmar.io/${t}/Partner/${q.ManufacturerId}`},q.ManufacturerId))})})]}):jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:A==null?void 0:A.Opportunities,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:t,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:t,variant:e,...n},o)=>jsxRuntime.jsx("div",{ref:o,role:"alert",className:cn(alertVariants({variant:e}),t),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",t),...e}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",t),...e}));AlertDescription.displayName="AlertDescription";/**
1074
+ $10 with opportunities under $1,000`:t==="D"?"$15 under $1,500":t==="E"?"Full shipping charges":t,getTermsText=t=>t==="STRIPE"?"Credit card payment":t==="NET30"?"Net 30 days":t,AccountTier=({isSuperAdmin:t,readonly:e,reseller:n,appID:o,isLoading:l})=>{const{toast:d}=useToast(),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=Oe=>Oe&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Oe]||"",E=Oe=>Oe&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Oe]||"",A=Oe=>Oe&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Oe]||"",[I,M]=React.useState(C((n==null?void 0:n.Priority)??"")),[j,q]=React.useState(E((n==null?void 0:n.ShippingProfile)??"")),[z,Q]=React.useState(A(n==null?void 0:n.PriceProfile)),F=Oe=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Oe]||Oe,V=Oe=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Oe]||Oe,te=Oe=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Oe]||Oe;React.useEffect(()=>{M(C((n==null?void 0:n.Priority)??"")),q(E((n==null?void 0:n.ShippingProfile)??"")),Q(A(n==null?void 0:n.PriceProfile))},[n]);const ne=async(Oe,Fe,ze,$e)=>{try{(await S({applicationId:o,fieldName:Oe,newValue:Fe})).error?d({title:"Error",description:$e,variant:"destructive"}):d({title:"Success",description:ze,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},se=async Oe=>{M(Oe);const Fe=F(Oe);ne("Priority",Fe,`Priority updated to ${Fe}`,"Failed to update priority")},ge=async Oe=>{q(Oe);const Fe=V(Oe);ne("ShippingProfile",Fe,`Shipping profile updated to ${Fe}`,"Failed to update shipping profile")},oe=async Oe=>{Q(Oe);const Fe=te(Oe);ne("PriceProfile",Fe,`Pricing profile updated to ${Fe}`,"Failed to update pricing profile")},Ae=async()=>{try{const Oe=await S({applicationId:o,fieldName:"Tier",newValue:b});Oe.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Oe.data?d({title:"Success",description:`Pricing Tier changed to ${b}`,variant:"success"}):d({title:"Considered",description:"Request being considered",variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{g(!1),_("")}},je=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:t}],Ne=Oe=>{_(Oe),g(!0)};return l?jsxRuntime.jsxs(Card,{className:"md:col-span-2 xl:col-span-1 md:max-w-xl xl:max-w-[unset]",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},Oe))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"md:col-span-2 xl:col-span-1 md:max-w-xl xl:max-w-[unset]",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[(n==null?void 0:n.Priority)||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-green-600"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText((n==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!e&&jsxRuntime.jsx(Button,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs("a",{href:"https://www.randmar.io/docs/overview/pricingTiers",target:"_blank",rel:"noreferrer",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{disabled:e,className:e?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),je.map(Oe=>jsxRuntime.jsx(Button,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Oe.enabled,onClick:()=>Ne(Oe.name),children:Oe.name},Oe.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:Ae}),t&&!e&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:I,onValueChange:se,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`priority-${Oe.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:j,onValueChange:ge,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`shipping-${Oe.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:z,onValueChange:oe,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`pricing-${Oe.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.value))})]})]})})]})]})};function OrderCategories({openOrders:t=[],isLoading:e=!1}){const n=(t==null?void 0:t.filter(I=>I.DocumentType==="Order"))||[],o=(t==null?void 0:t.filter(I=>I.DocumentType==="Shipment"))||[],l=n.filter(I=>I.WarehouseCode!=="3PLE"),d=l.reduce((I,M)=>I+(M.Quantity??0),0),f=l.reduce((I,M)=>I+(M.ExtendedPrice??0),0),g=n.filter(I=>I.WarehouseCode==="3PLE"),b=g.reduce((I,M)=>I+(M.Quantity??0),0),_=g.reduce((I,M)=>I+(M.ExtendedPrice??0),0),S=o.reduce((I,M)=>I+(M.Quantity??0),0),R=o.reduce((I,M)=>I+(M.ExtendedPrice??0),0),C=d+b+S,E=f+_+R,A=[{name:"All",icon:Package,color:"bg-blue-500",orders:C,amount:E},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:d,amount:f},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:S,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:_}];return e?jsxRuntime.jsxs(Card,{className:"w-full @md:col-span-2 @xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(I=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:"bg-gray-200 h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},I))})})]}):jsxRuntime.jsxs(Card,{className:"w-full @md:col-span-2 @xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:A.map(I=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${I.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:I.name}),jsxRuntime.jsx("div",{className:`${I.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(I.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:I.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:I.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},I.name))})})]})}function ReportsSection({isLoading:t,userEmail:e,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[S,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:I}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[M,j]=React.useState(null),[q,z]=React.useState(e),[Q,F]=React.useState(!1),V=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],te=async ge=>{j(ge),F(!0)},ne=async()=>{if(!(!M||!n))try{switch(M.id){case"Products":await S({routeResellerId:n,emailAddress:q}).unwrap();break;case"AmazonTrackingFile":await f({routeResellerId:n,emailAddress:q}).unwrap();break;case"WalmartTrackingFile":await l({routeResellerId:n,emailAddress:q}).unwrap();break;case"OpenOrders":await b({routeResellerId:n,emailAddress:q}).unwrap();break;case"Invoices":await C({routeResellerId:n,emailAddress:q}).unwrap();break;case"Statement":await A({routeResellerId:n,emailAddress:q}).unwrap();break;default:throw new Error("invalid report id")}o({title:"Report requested",description:`The ${M.title} will be sent to ${q} shortly.`,variant:"success"}),F(!1)}catch(ge){console.error("Error requesting report:",ge),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},se=_||R||g||d||I||E;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:t?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(oe=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},oe))]},ge))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:V.map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:ge.name}),ge.reports.map(oe=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(oe.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:oe.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:oe.description})]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>te(oe),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},oe.id))]},ge.name))})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:F,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",M==null?void 0:M.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:q,onChange:ge=>z(ge.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:ne,disabled:!q||se,children:se?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:t,variant:e,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:e,size:n}),t),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function QualificationBadge({qualification:t}){return!t.QualificationId||t.QualificationId==="Suspended"?null:t.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$1,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:t.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),t.QualificationId,t.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:t.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function useIntersectionObserver({elementRef:t,threshold:e=0,rootMargin:n="0px",freezeOnceVisible:o=!1}){const[l,d]=React.useState(!1);return React.useEffect(()=>{const f=t.current;if(!f){d(!1);return}const g=new IntersectionObserver(([b])=>{const _=b.isIntersecting;o&&_?(d(!0),g.unobserve(f)):d(_)},{threshold:e,rootMargin:n});return g.observe(f),()=>{g.unobserve(f)}},[t,e,n,o]),l}const PartnerLogo=({id:t,name:e,width:n=64,height:o=64,align:l=""})=>{const d=React.useRef(null),[f,g]=React.useState(!1),[b,_]=React.useState(null),S=useIntersectionObserver({elementRef:d,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{data:R,isFetching:C}=useGetV4PartnerByApplicationIdAccountLogoExistsQuery({applicationId:t??""},{skip:!t||!S});React.useEffect(()=>{_(null),!(!t||C||!R||R==="false")&&(g(!0),fetch(`https://api.randmar.io/V4/Partner/${t}/Account/Logo?width=${n}&height=${o}&align=${l}`).then(M=>{M.ok||console.error("error fetching logo"),M.blob().then(j=>{const q=window.URL.createObjectURL(j);_(q)})}).catch(M=>{console.error("error loading logo",M)}).finally(()=>{g(!1)}))},[t,R,C]);const E="No Logo",A=e||(t?`Partner ID: ${t}`:"Logo not available (no ID)"),I=()=>!S||C||f?jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-sm"}):b?jsxRuntime.jsx("img",{src:b,alt:A,className:"h-full w-full object-contain rounded-sm"}):jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center border border-dashed border-border rounded-sm bg-muted/20 p-1",title:A,children:jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground font-mono text-center leading-none",children:E})});return jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("div",{className:"flex h-full w-full cursor-default",ref:d,children:I()})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",children:A})]})})};function ManufacturerCard({manufacturer:t,link:e,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1}){var C,E,A;if(d||!t)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const f=t.ManufacturerId||"N/A",g=[t.City,t.Province,t.Country].filter(Boolean),b=g.length>0?g.join(", "):"",_=((C=t.Tags)==null?void 0:C.split(",").map(I=>I.trim()).filter(Boolean))||[],R=(I=>!I||I.length===0?[]:[...I].sort((M,j)=>(M.Day||0)-(j.Day||0)).map(M=>({date:M.Day||0,amount:M.ExtendedPrice||0})))(t.SalesStatistics);return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(reactRouterDom.Link,{to:e??"#",target:e&&n?"_blank":"_self",children:jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,width:48,height:48})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Manufacturer"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:f})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:t.PublicName||"N/A"}),t.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t.Name}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:b})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:R.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(AreaChart,{data:R,height:60,size:"mini"})})})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!((E=t.Qualification)!=null&&E.QualificationId)&&((A=t.Qualification)==null?void 0:A.QualificationId)!=="Suspended"||!!t.OpenToWork||!!t.OnHold&&t.OnHold!==0||_.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:t.Qualification??{}}),!!t.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!t.OnHold&&t.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),_.map((I,M)=>jsxRuntime.jsx(Badge,{variant:"outline",children:I},M))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[t.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${t.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.Phone})]}),t.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${t.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.PublicEmail})]}),t.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:t.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.Website})]}),t.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.CurrencyCode})]})]})]}),t.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesYearToDay?formatMoney(t.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast3Months?formatMoney(t.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast30Days?formatMoney(t.SalesData.SalesLast30Days):"—"})]})]})}),(o||l)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:o&&o}),l&&jsxRuntime.jsx("div",{children:l})]})]})}function formatYYYYMMDDIntToDateString$1(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function OrdersTable({orders:t=null,loading:e=!1,title:n="Order Details"}){const o=React.useMemo(()=>[{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:f})=>f.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:f})=>formatYYYYMMDDIntToDateString$1(f.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"OrderNumber",header:"Order Number",cell:({row:f})=>f.original.OrderNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"PONumber",header:"PO Number",cell:({row:f})=>f.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:f})=>f.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:f})=>f.original.UnitPrice?formatMoney(f.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(C=>C.WarehouseCode).filter(C=>C!=null)));f.WarehouseCode=g;const b=Array.from(new Set(t.map(C=>C.ShipToName).filter(C=>C!=null)));f.ShipToName=b;const _=Array.from(new Set(t.map(C=>C.DocumentNumber).filter(C=>C!=null)));f.DocumentNumber=_;const S=Array.from(new Set(t.map(C=>C.OrderNumber).filter(C=>C!=null)));f.OrderNumber=S;const R=Array.from(new Set(t.map(C=>C.PONumber).filter(C=>C!=null)));f.PONumber=R}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function ResellerOverview({appID:t,reseller:e,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){const{data:f,isLoading:g,isError:b}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:t??"",withSpecification:!0},{skip:!!e}),[_,S]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>n?!1:_.publicInfo.hasUnsavedChanges,[n,_]),C=React.useCallback((q,z)=>{S(Q=>{var F;return((F=Q[q])==null?void 0:F.hasUnsavedChanges)!==z.hasUnsavedChanges?{...Q,[q]:z}:Q})},[]),{NavigationGuardDialog:E}=useRouterNavigationGuard(R),A=e??f,I=!n||!!(A!=null&&A.Statement)&&(A.Statement.Total??0)>0,M=(A==null?void 0:A.QualifiedManufacturers)??[],j=(A==null?void 0:A.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[b?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:(A==null?void 0:A.FiscalYearMonthStart)||1,salesData:A==null?void 0:A.SalesData,isLoading:g}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChart,{salesData:(A==null?void 0:A.SalesStatistics)??[],isLoading:g}),jsxRuntime.jsx(OrderCategories,{openOrders:(A==null?void 0:A.ActiveOrderDetails)??[],isLoading:g}),I&&jsxRuntime.jsx(BillingCard,{appID:t,reseller:A||{},withoutReports:d,isLoading:g}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:t??"",isLoading:g,readonly:n,onUnsavedChanges:q=>C("publicInfo",{hasUnsavedChanges:q})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:l,readonly:n,reseller:A||{},appID:t??"",isLoading:g})]}),g||M.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @2xl:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((q,z)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},z)):M.map(q=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:q,link:`https://dashboard.randmar.io/${t}/Partner/${q.ManufacturerId}`},q.ManufacturerId))})})]}):jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:A==null?void 0:A.Opportunities,loading:g}),jsxRuntime.jsx(OrdersTable,{title:"Active Orders",orders:A==null?void 0:A.ActiveOrderDetails,loading:g}),jsxRuntime.jsx(OrdersTable,{title:"Completed Orders",loading:g}),jsxRuntime.jsx(ReturnsTable,{applicationId:t,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:t,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:t,variant:e,...n},o)=>jsxRuntime.jsx("div",{ref:o,role:"alert",className:cn(alertVariants({variant:e}),t),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",t),...e}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",t),...e}));AlertDescription.displayName="AlertDescription";/**
1075
1075
  * table-core
1076
1076
  *
1077
1077
  * Copyright (c) TanStack
@@ -1314,6 +1314,6 @@ img.ProseMirror-separator {
1314
1314
  .ProseMirror p {
1315
1315
  margin-bottom: 0.5em;
1316
1316
  }
1317
- `;function RichTextEditor({id:t,name:e,value:n,onChange:o,placeholder:l,className:d,...f}){const[g,b]=React.useState(!1),_=React.useRef(null),S=React.useRef(null),R=useEditor({extensions:[StarterKit,Underline],content:n,editorProps:{attributes:{class:"prose prose-sm sm:prose dark:prose-invert focus:outline-none",id:t??"",name:e??""}},onUpdate:({editor:j})=>{const q=j.getHTML();o({target:{id:t,name:e,value:q}})}});React.useEffect(()=>{R&&n!==R.getHTML()&&R.commands.setContent(n)},[n,R]);const C=React.useCallback(j=>{if(R)if(R.chain().focus(),j==="paragraph")R.chain().setParagraph().run();else{const q=Number.parseInt(j.slice(1));R.chain().setHeading({level:q}).run()}},[R]),E=React.useCallback(j=>{if(R)switch(R.chain().focus(),j){case"bold":R.chain().toggleBold().run();break;case"italic":R.chain().toggleItalic().run();break;case"underline":R.chain().toggleUnderline().run();break;case"strike":R.chain().toggleStrike().run();break;case"bulletList":R.chain().toggleBulletList().run();break;case"orderedList":R.chain().toggleOrderedList().run();break}},[R]),A=React.useCallback(()=>{b(j=>!j)},[]),I=React.useCallback(j=>{const q=j.target.value;R&&R.commands.setContent(q),o({target:{id:t,name:e,value:q}})},[o,R,t,e]),M=React.useCallback(()=>{!g&&R&&R.commands.focus()},[g,R]);return R?jsxRuntime.jsxs("div",{ref:S,className:cn("border border-input rounded-md overflow-hidden focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring",d),onClick:M,...f,children:[jsxRuntime.jsx("style",{children:editorStyles}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center p-2 border-b border-input gap-2 bg-background",children:[jsxRuntime.jsxs(Select,{onValueChange:C,disabled:g,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[160px]",children:jsxRuntime.jsx(SelectValue,{placeholder:"Format"})}),jsxRuntime.jsx(SelectContent,{children:formatOptions.map(j=>jsxRuntime.jsx(SelectItem,{value:j.value,children:j.label},j.value))})]}),["bold","italic","underline","strike","bulletList","orderedList"].map(j=>jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(j),className:R.isActive(j)?"bg-muted":"",disabled:g,children:[j==="bold"&&jsxRuntime.jsx(Bold$1,{className:"h-4 w-4"}),j==="italic"&&jsxRuntime.jsx(Italic$1,{className:"h-4 w-4"}),j==="underline"&&jsxRuntime.jsx(Underline$1,{className:"h-4 w-4"}),j==="strike"&&jsxRuntime.jsx(Strikethrough,{className:"h-4 w-4"}),j==="bulletList"&&jsxRuntime.jsx(List$1,{className:"h-4 w-4"}),j==="orderedList"&&jsxRuntime.jsx(ListOrdered,{className:"h-4 w-4"})]},j)),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"sm",onClick:A,className:g?"bg-muted":"",children:jsxRuntime.jsx(Code$1,{className:"h-4 w-4"})})]}),jsxRuntime.jsx("div",{className:"p-3",children:g?jsxRuntime.jsx(Textarea,{ref:_,id:t,name:e,value:R.getHTML(),onChange:I,className:cn("min-h-[150px] font-mono text-sm resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",d),placeholder:l}):jsxRuntime.jsx(EditorContent,{editor:R})})]}):null}function formatYYYYMMDDIntToDateString$1(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function OrdersTable({orders:t=null,loading:e=!1,title:n="Order Details"}){const o=React.useMemo(()=>[{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:f})=>f.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:f})=>formatYYYYMMDDIntToDateString$1(f.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"OrderNumber",header:"Order Number",cell:({row:f})=>f.original.OrderNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"PONumber",header:"PO Number",cell:({row:f})=>f.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:f})=>f.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:f})=>f.original.UnitPrice?formatMoney(f.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(C=>C.WarehouseCode).filter(C=>C!=null)));f.WarehouseCode=g;const b=Array.from(new Set(t.map(C=>C.ShipToName).filter(C=>C!=null)));f.ShipToName=b;const _=Array.from(new Set(t.map(C=>C.DocumentNumber).filter(C=>C!=null)));f.DocumentNumber=_;const S=Array.from(new Set(t.map(C=>C.OrderNumber).filter(C=>C!=null)));f.OrderNumber=S;const R=Array.from(new Set(t.map(C=>C.PONumber).filter(C=>C!=null)));f.PONumber=R}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function formatYYYYMMDDIntToDateString(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function ReceiptsTable({receipts:t=null,loading:e=!1,title:n="Latest Warehouse Receivings"}){const o=React.useMemo(()=>[{accessorKey:"Location",header:"Location",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.Location??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.ReceiptDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!0}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(_=>_.Location).filter(_=>_!=null)));f.Location=g;const b=Array.from(new Set(t.map(_=>formatYYYYMMDDIntToDateString(_.ReceiptDate)).filter(_=>_!=="N/A"&&_!=="Invalid Date"))).sort((_,S)=>new Date(S).getTime()-new Date(_).getTime());f.ReceiptDate=b}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-56"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}const formatDate$1=t=>{if(!t)return"N/A";try{const e=new Date(t);return isNaN(e.getTime())?"Invalid Date":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}},getStatusVariant=t=>{const e=(t==null?void 0:t.toLowerCase())||"";return e.includes("accepted")?"success":e.includes("error")||e.includes("rejected")?"destructive":"neutral"};function ReturnsTable({applicationId:t,returns:e=null,loading:n=!1}){const o=React.useMemo(()=>[{accessorKey:"ReturnNumber1",header:"RMA Number",cell:({row:f})=>{const g=f.original.ReturnNumber1||f.original.ReturnNumber;return g?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Return/${g}`,className:"font-medium text-blue-600 hover:underline dark:text-blue-400",children:g})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for return ",g]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"RequestDate",header:"Request Date",cell:({row:f})=>formatDate$1(f.original.RequestDate),enableSorting:!0},{accessorKey:"InvoiceNumber",header:"Invoice Number",cell:({row:f})=>{const g=f.original.InvoiceNumber;return g?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Document/${g}`,className:"text-blue-600 hover:underline dark:text-blue-400",children:g})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for invoice ",g]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"0",enableSorting:!0},{accessorKey:"ReasonForReturn",header:"Return Reason",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ReasonForReturn??"—"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"Status",header:"Status",cell:({row:f})=>{const g=f.original.Status,b=getStatusVariant(g);let _="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return b==="success"?_="border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400":b==="destructive"&&(_="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400"),g?jsxRuntime.jsx(Badge,{variant:"outline",className:`${_} font-medium`,children:g}):"—"},enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseLocation",header:"Warehouse",cell:({row:f})=>f.original.WarehouseLocation??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"LastUpdatedDate",header:"Last Update",cell:({row:f})=>formatDate$1(f.original.LastUpdatedDate)!=="N/A"?formatDate$1(f.original.LastUpdatedDate):"—",enableSorting:!0}],[t]),l=React.useMemo(()=>{const f={};if(e){const g=Array.from(new Set(e.map(S=>S.Status).filter(Boolean)));f.Status=g;const b=Array.from(new Set(e.map(S=>S.ReasonForReturn).filter(Boolean)));f.ReasonForReturn=b;const _=Array.from(new Set(e.map(S=>S.WarehouseLocation).filter(Boolean)));f.WarehouseLocation=_}return f},[e]),d=React.useMemo(()=>e?[...e].sort((g,b)=>(b.ReturnNumber1||b.ReturnNumber||"").localeCompare(g.ReturnNumber1||g.ReturnNumber||"")):[],[e]);return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-48 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):!d||d.length===0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Returns"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"flex justify-center items-center h-24",children:jsxRuntime.jsx("p",{className:"text-muted-foreground",children:"There are no returns to display."})})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Returns"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function ProductOverviewPage({applicationId:t,sku:e,productDefaultOpportunityNumber:n="",productOnAddToCart:o,productAddingToCart:l=!1,productShopifyHostname:d,productCustomAction:f=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){var C,E,A,I,M,j,q,z,Q;const{data:g,isLoading:b}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!t||!e}),{data:_,isLoading:S}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!0},{skip:!g}),R=(g==null?void 0:g.ManufacturerId)!==t;return console.log("readonly",R),jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 @sm:grid-cols-2 @md:grid-cols-3",children:[jsxRuntime.jsx("div",{className:"@md:col-span-2",children:jsxRuntime.jsx(ProductCard,{applicationId:t,product:_||g,defaultOpportunityNumber:n,onAddToCart:o,addingToCart:l,shopifyHostname:d,customAction:f})}),jsxRuntime.jsxs(Card,{className:"flex flex-col",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{children:[jsxRuntime.jsx(Info,{className:"h-5 w-5 inline mr-2"})," Additionnal information"]})}),jsxRuntime.jsx(CardContent,{className:"basis-0 grow overflow-y-auto",children:b?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-1 w-full my-6"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-1"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Cateory Name"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.ProductType)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Master Carton"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.MasterCarton)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Skid Quantity"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.SkidQuantity)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Automatic Reorder"}),jsxRuntime.jsx("span",{className:"font-medium",children:g!=null&&g.AutoUpdate?"Yes":"No"})]}),((g==null?void 0:g.VoiceoverCaption)||(g==null?void 0:g.BodyHTML))&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("hr",{className:"my-6"}),jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2",children:"Description"}),(g==null?void 0:g.VoiceoverCaption)&&jsxRuntime.jsx("div",{children:g==null?void 0:g.VoiceoverCaption}),(g==null?void 0:g.BodyHTML)&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:(g==null?void 0:g.BodyHTML)??""}})]})]})})]})]}),jsxRuntime.jsx("div",{className:"my-4",children:b?jsxRuntime.jsx("div",{className:"mx-auto flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})}):jsxRuntime.jsxs(Tabs,{defaultValue:"stats",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[jsxRuntime.jsx(TabsTrigger,{value:"stats",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:!S&&(((C=_==null?void 0:_.SalesStatistics)==null?void 0:C.length)??0)<=0,children:"Statistics"}),jsxRuntime.jsx(TabsTrigger,{value:"opportunities",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:!S&&(((E=_==null?void 0:_.Opportunities)==null?void 0:E.length)??0)<=0,children:"Opportunities"}),jsxRuntime.jsx(TabsTrigger,{value:"orders",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:!S&&(((A=_==null?void 0:_.ActiveOrderDetails)==null?void 0:A.length)??0)<=0&&(((I=_==null?void 0:_.CompletedOrderDetails)==null?void 0:I.length)??0)<=0&&(((M=_==null?void 0:_.Returns)==null?void 0:M.length)??0)<=0,children:"Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"warehouse",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:!S&&(((j=_==null?void 0:_.Receipts)==null?void 0:j.length)??0)<=0,children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChart,{salesData:(_==null?void 0:_.SalesStatistics)??[],isLoading:S,units:""})})}),jsxRuntime.jsx(TabsContent,{value:"opportunities",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:g==null?void 0:g.Opportunities,loading:b})})}),jsxRuntime.jsxs(TabsContent,{value:"orders",children:[(S||((q=_==null?void 0:_.ActiveOrderDetails)==null?void 0:q.length)!==0)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Open Orders",orders:_==null?void 0:_.ActiveOrderDetails,loading:S})}),(S||((z=_==null?void 0:_.CompletedOrderDetails)==null?void 0:z.length)!==0)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Completed Orders",orders:_==null?void 0:_.CompletedOrderDetails,loading:S})}),(S||((Q=_==null?void 0:_.CompletedOrderDetails)==null?void 0:Q.length)!==0)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReturnsTable,{applicationId:t,returns:_==null?void 0:_.Returns,loading:S})})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReceiptsTable,{receipts:_==null?void 0:_.Receipts,loading:S})})})]})})]})}function AssistantChat(t){return jsxRuntime.jsx(Card,{className:"max-w-6xl",children:jsxRuntime.jsx(ChatLayout,{className:"h-[40em]",userId:t.userId,userName:t.userName,assistantOnly:!0,initialPrompt:t.initialPrompt})})}function getEndDateStatus(t){if(!t)return{text:"No End Date",variant:"neutral",daysRemaining:null};const e=new Date(t);if(isNaN(e.getTime()))return{text:"Invalid Date",variant:"neutral",daysRemaining:null};const n=new Date,o=new Date(e.getFullYear(),e.getMonth(),e.getDate()),l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),d=o.getTime()-l.getTime(),f=Math.ceil(d/(1e3*60*60*24));return f<0?{text:`Ended ${Math.abs(f)}d ago`,variant:"destructive",daysRemaining:f}:f===0?{text:"Ends today",variant:"destructive",daysRemaining:f}:f<=7?{text:`Ends in ${f}d`,variant:"destructive",daysRemaining:f}:f<=30?{text:`Ends in ${f}d`,variant:"warning",daysRemaining:f}:{text:`Ends in ${f}d`,variant:"neutral",daysRemaining:f}}const formatDate=t=>{if(!t)return"N/A";try{const e=new Date(t);return isNaN(e.getTime())?"Invalid Date":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}};function OpportunitiesTable({applicationId:t,opportunities:e=null,loading:n=!1}){var te;const{toast:o}=useToast(),[l,d]=React.useState({}),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,R]=React.useState(null),{data:C}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t}),E=React.useCallback((ne,se,ge)=>{d(oe=>({...oe,[ne]:{...oe[ne],[se]:ge}}))},[]),[A]=usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(),I=React.useCallback(async ne=>{if(!(C!=null&&C.IsReseller))return;if(!ne.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot set default.",variant:"destructive"});return}const se=ne.BidNumber;E(se,"isSettingDefault",!0),A({routeResellerId:t,manufacturerId:ne.ManufacturerId??"",opportunityNumber:se}).unwrap().then(()=>{o({title:"Success",description:`Opportunity "${ne.OpportunityName||ne.Opportunity||se}" was successfully set as default.`,variant:"success"})}).catch(ge=>{var oe;console.error("Set as default error:",ge),o({title:"Error",description:((oe=ge.data)==null?void 0:oe.message)||ge.message||"An error occurred while setting this opportunity as default.",variant:"destructive"})}).finally(()=>{E(se,"isSettingDefault",!1)})},[t,A,o,E]),[M]=usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(),j=React.useCallback(ne=>{if(C!=null&&C.IsReseller){if(!ne.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot prepare report.",variant:"destructive"});return}R(ne),_(""),g(!0)}},[o]),q=React.useCallback(async()=>{if(!(C!=null&&C.IsReseller))return;if(!S||!S.BidNumber){o({title:"Error",description:"No opportunity selected or Bid Number is missing.",variant:"destructive"});return}if(!b.trim()||!/\S+@\S+\.\S+/.test(b)){o({title:"Validation Error",description:"Please enter a valid email address.",variant:"destructive"});return}const ne=S.BidNumber;E(ne,"isSendingReport",!0),M({routeResellerId:t,manufacturerId:S.ManufacturerId??"",bidNumber:ne,emailAddress:b}).unwrap().then(()=>{o({title:"Success",description:`A report for "${S.OpportunityName||S.Opportunity||ne}" was successfully sent to ${b}.`,variant:"success"}),g(!1)}).catch(se=>{var ge;console.error("Send report by email error:",se),o({title:"Error",description:((ge=se.data)==null?void 0:ge.message)||se.message||"An error occurred while sending the report by email.",variant:"destructive"})}).finally(()=>{E(ne,"isSendingReport",!1),f||(R(null),_(""))})},[S,b,t,M,o,E,g]),z=React.useMemo(()=>[{accessorKey:"ManufacturerId",header:"Manuf.",cell:({row:ne})=>jsxRuntime.jsx("div",{className:"w-20 h-8",children:jsxRuntime.jsx(PartnerLogo,{id:ne.original.ManufacturerId,width:80,height:32})}),enableSorting:!0,enableFiltering:!0},{id:"opportunityDisplay",accessorFn:ne=>ne.OpportunityName||ne.Opportunity,header:"Opportunity",cell:({getValue:ne})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:ne()??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"BidNumber",header:"Bid Number",cell:({row:ne})=>ne.original.BidNumber??"N/A",enableSorting:!0,enableFiltering:!0},{id:"statusInfo",header:"Status",cell:({row:ne})=>{const se=ne.original,ge=se.Active===!0,oe=getEndDateStatus(se.EndDate);let Ae="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return oe.variant==="destructive"?Ae="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400":oe.variant==="warning"&&(Ae="border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 min-w-[200px]",children:[jsxRuntime.jsx(Badge,{variant:"outline",className:ge?"border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400 font-medium":"border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400 font-medium",children:ge?"Active":"Inactive"}),se.EndDate&&jsxRuntime.jsx(Badge,{variant:"outline",className:`${Ae} font-medium`,children:oe.text}),jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent",children:jsxRuntime.jsx(Info,{className:"h-4 w-4 text-muted-foreground"})})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",className:"bg-popover text-popover-foreground p-2 rounded shadow-lg",children:jsxRuntime.jsxs("div",{className:"text-sm space-y-1",children:[jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Start:"})," ",formatDate(se.StartDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"End:"})," ",formatDate(se.EndDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Updated:"})," ",formatDate(se.LastUpdate)]})]})})]})})]})},enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:ne})=>{var Oe,Fe;const se=ne.original;if(!se.BidNumber)return jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Actions unavailable"});const ge=se.BidNumber,oe=(Oe=l[ge])==null?void 0:Oe.isSettingDefault,Ae=(S==null?void 0:S.BidNumber)===ge&&((Fe=l[ge])==null?void 0:Fe.isSendingReport),je=oe||Ae,Ne=se.CanBeSetAsDefault===!0;return jsxRuntime.jsxs("div",{className:"flex space-x-2",children:[jsxRuntime.jsx("a",{href:`/${t}/Opportunity/${se.ManufacturerId}/${se.BidNumber}`,children:jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center",children:[jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," View"]})}),(C==null?void 0:C.IsReseller)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>I(se),disabled:je||!Ne,title:Ne?"Set as default":"This opportunity cannot be set as default",className:"flex items-center",children:[oe?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," Set Default"]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>j(se),disabled:je,title:"Send report by email",className:"flex items-center",children:[Ae?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"})," Send Report"]})]})]})}}],[l,I,j,S]),Q=React.useMemo(()=>{const ne={};if(e){const se=Array.from(new Set(e.map(oe=>oe.ManufacturerId).filter(oe=>oe!=null)));ne.ManufacturerId=se;const ge=Array.from(new Set(e.map(oe=>oe.OpportunityName||oe.Opportunity).filter(oe=>oe!=null)));ne.opportunityDisplay=ge}return ne},[e]),F=e||[],V=S!=null&&S.BidNumber?(te=l[S.BidNumber])==null?void 0:te.isSendingReport:!1;return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-48 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Opportunities"})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:z,data:F,uniqueValues:Q})})]}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:ne=>{g(ne),ne||(R(null),_(""))},children:jsxRuntime.jsxs(DialogContent,{className:"@sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Opportunity Report"}),jsxRuntime.jsxs(DialogDescription,{children:["Enter the email address to send the report for opportunity: ",jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{className:"font-semibold",children:(S==null?void 0:S.OpportunityName)||(S==null?void 0:S.Opportunity)||"N/A"}),(S==null?void 0:S.BidNumber)&&jsxRuntime.jsxs("span",{className:"block text-sm text-muted-foreground",children:["Bid Number: ",S.BidNumber]})]})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:b,onChange:ne=>_(ne.target.value),placeholder:"recipient@example.com",className:"col-span-3",disabled:V})]})}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>g(!1),disabled:V,children:"Cancel"}),jsxRuntime.jsxs(Button,{type:"submit",onClick:q,disabled:V,children:[V&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"})," Send Report"]})]})]})})]})}function SalesChart({salesData:t,chartHeight:e=300,units:n="$",unitsPosition:o="left",className:l,isLoading:d=!1}){const[f,g]=React.useState([]),[b,_]=React.useState(!1),S=!d;return React.useEffect(()=>{if(d){g([]);return}const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),I=`${C}-${(E+1).toString().padStart(2,"0")}`,M=[];for(let Q=11;Q>=0;Q--){const F=new Date(C,E-Q,1),V=F.getFullYear(),te=(F.getMonth()+1).toString().padStart(2,"0");M.push(`${V}-${te}`)}const j={};M.forEach(Q=>{j[Q]=0}),t&&t.length>0&&t.forEach(Q=>{const F=Q.Day??0,V=Math.floor(F).toString();if(V.length!==8||isNaN(Number.parseInt(V))){console.warn(`Skipping invalid Day format: ${Q.Day}`);return}const te=V.substring(0,4),ne=V.substring(4,6),se=`${te}-${ne}`;M.includes(se)&&(j[se]=(j[se]||0)+(Q.ExtendedPrice??0))});const q={...j};if(b&&j[I]>0){const Q=q[I],F=new Date(C,E+1,0).getDate();if(A<F&&A>0){const te=Q/A*F;q[I]=te}}const z=M.map(Q=>{const F=q[Q],[V,te]=Q.split("-").map(Number);return{month:new Date(V,te-1).toLocaleString("default",{month:"short",year:"numeric"}),sales:F}});g(z)},[t,b,d]),d?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:e},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"})]}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4 mt-1"})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Sales"})}),jsxRuntime.jsx(CardContent,{children:f.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:f,units:n,unitsPosition:o,height:e,className:l}),S&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Switch,{checked:b,onCheckedChange:_,id:"extrapolate-switch","aria-label":"Toggle sales extrapolation"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate"})]}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"* Sales for the current month are projected, not actual."})]})]}):jsxRuntime.jsx("div",{style:{height:e},className:l||"p-4 text-center text-muted-foreground flex items-center justify-center",children:"No sales data available."})})]})}function useLoadScript(t){const[e,n]=React.useState(!0),[o,l]=React.useState(null),[d,f]=React.useState(!1),g=()=>{n(!1),f(!0)};return React.useEffect(()=>{if(!document){const R=new Error(`[ScriptLoadingError] document not defined when attempting to load ${t}`);l(R);return}const b=document.querySelector(`script[src="${t}"]`);if(b!=null&&b.dataset.loaded){g();return}const _=b||document.createElement("script");b||(_.src=t);const S=()=>{_.dataset.loaded="1",g()};_.addEventListener("load",S),_.addEventListener("error",R=>{console.error("Failed to load script:",t,R);const C=new Error(`[ScriptLoadingError] Failed to load script: ${t}`);l(C)}),b||document.head.append(_)},[]),{isLoading:e,error:o,isSuccess:d}}const isGoogleReady=t=>t&&t.charts,isGoogleChartsReady=(t,e)=>{const{controls:n,toolbarItems:o,getChartEditor:l}=t;return e&&e.charts&&e.visualization&&e.visualization.ChartWrapper&&e.visualization.Dashboard&&(!n||e.visualization.ChartWrapper)&&(!l||e.visualization.ChartEditor)&&(!o||e.visualization.drawToolbar)},getGoogleInstanceFromWindow=t=>window.google;function useLoadGoogleCharts(t){const{chartVersion:e="current",chartPackages:n=["corechart","controls"],chartLanguage:o="en",mapsApiKey:l}=t,[d,f]=React.useState(null),[g,b]=React.useState(null),[_,S]=React.useState(null),{isLoading:R,error:C,isSuccess:E}=useLoadScript(t.chartLoaderScriptUrl||"https://www.gstatic.com/charts/loader.js");return React.useEffect(()=>{if(!E)return;const A=getGoogleInstanceFromWindow();if(!isGoogleReady(A)){const I=new Error("[ScriptInitializationError] Script loaded but Google not attached to window.");b(I);return}if(isGoogleChartsReady(t,A)){f(A);return}A.charts.load(e,{packages:n,language:o,mapsApiKey:l}),A.charts.setOnLoadCallback(()=>{if(!isGoogleChartsReady(t,A)){const I=new Error("[GoogleChartsInitializationError] Google Charts not ready after load callback.");console.error(I),S(I);return}f(A)})},[E]),{error:C||g||_,isLoading:R,google:d}}const chartDefaultProps={legend_toggle:!1,options:{},legendToggle:!1,getChartWrapper:()=>{},spreadSheetQueryParameters:{headers:1,gid:1},rootProps:{},chartWrapperParams:{},chartLoaderScriptUrl:"https://www.gstatic.com/charts/loader.js"},GoogleChartControls=t=>{const{isReady:e,chartControls:n,filter:o}=t;return!e||!n||!(n!=null&&n.length)?null:React.createElement(React.Fragment,null,n.filter(l=>{let{controlProp:d,control:f}=l;return o?o({control:f,controlProp:d}):!0}).map(l=>{let{control:d}=l;return React.createElement("div",{key:d.getContainerId(),id:d.getContainerId()})}))};let uniqueID=0;const generateUniqueID=()=>(uniqueID+=1,`reactgooglegraph-${uniqueID}`),Nr=class Nr{};Qt(Nr,"initializeControls",e=>{for(let n=0;n<e.length;n+=1){const{controlType:o,options:l,controlWrapperParams:d}=e[n].controlProp;d&&"state"in d&&e[n].control.setState(d.state),e[n].control.setOptions(l),e[n].control.setControlType(o)}}),Qt(Nr,"listenToControlEvents",(e,n)=>{const{google:o}=n;return e.flatMap(l=>{const{control:d,controlProp:f}=l,{controlEvents:g=[]}=f;return g.map(b=>{const{callback:_,eventName:S}=b;return o.visualization.events.addListener(d,S,function(){for(var R=arguments.length,C=new Array(R),E=0;E<R;E++)C[E]=arguments[E];_({chartWrapper:null,controlWrapper:d,props:n,google:o,eventArgs:C})})})})}),Qt(Nr,"createControlId",e=>{let n;return typeof e>"u"?n=`googlechart-control-${generateUniqueID()}`:n=e,n}),Qt(Nr,"createChartControls",e=>{const{controls:n,google:o}=e;return n?n.map((l,d)=>{const{controlID:f,controlType:g,options:b,controlWrapperParams:_}=l,S=Nr.createControlId(f);return{controlProp:l,control:new o.visualization.ControlWrapper({containerId:S,controlType:g,options:b,..._})}}):null}),Qt(Nr,"addControls",e=>{const{chartWrapper:n,chartDashboard:o}=e,l=Nr.createChartControls(e);return!l||!o||!n?null:(o.bind(l.map(d=>{let{control:f}=d;return f}),n),Nr.initializeControls(l),l)});let GoogleChartControlsInternal=Nr;const useCreateChartControls=t=>{const[e,n]=React__namespace.useState(null);return[React__namespace.useMemo(()=>!e||!t?null:t.map((l,d)=>{const f=e[d];return f?{controlProp:l,control:f}:void 0}).flatMap(l=>l?[l]:[]),[e,t]),n]},useListenToControlEvents=(t,e)=>{React__namespace.useEffect(()=>{const n=GoogleChartControlsInternal.listenToControlEvents(t??[],e);return()=>{n.forEach(o=>{e.google.visualization.events.removeListener(o)})}},[t,e])},useChartControls=t=>{const[e,n]=useCreateChartControls(t.controls);return useListenToControlEvents(e??[],t),{addControls:l=>{const d=GoogleChartControlsInternal.addControls(l);n((d==null?void 0:d.map(f=>f.control))??null)},renderControl:l=>{const{chartWrapper:d,chartDashboard:f}=t;return React__namespace.createElement(GoogleChartControls,{...t,isReady:!!(d&&f),chartControls:e,filter:l})}}},useChartId=t=>{const e=React__namespace.useRef(null);return{chartId:(()=>{const{graphID:l,graph_id:d}=t,f=l||d;let g;return f?g=f:g=e.current||generateUniqueID(),e.current=g,e.current})()}},DEFAULT_CHART_COLORS=["#3366CC","#DC3912","#FF9900","#109618","#990099","#3B3EAC","#0099C6","#DD4477","#66AA00","#B82E2E","#316395","#994499","#22AA99","#AAAA11","#6633CC","#E67300","#8B0707","#329262","#5574A6","#3B3EAC"],loadDataTableFromSpreadSheet=async function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return new Promise((o,l)=>{const d=`${n.headers?`headers=${n.headers}`:"headers=0"}`,f=`${n.query?`&tq=${encodeURIComponent(n.query)}`:""}`,g=`${n.gid?`&gid=${n.gid}`:""}`,b=`${n.sheet?`&sheet=${n.sheet}`:""}`,_=`${n.access_token?`&access_token=${n.access_token}`:""}`,S=`${d}${g}${b}${f}${_}`,R=`${e}/gviz/tq?${S}`;new t.visualization.Query(R).send(E=>{E.isError()?l(`Error in query: ${E.getMessage()} ${E.getDetailedMessage()}`):o(E.getDataTable())})})},GRAY_COLOR="#CCCCCC",Tr=class Tr{};Qt(Tr,"grayOutHiddenColumnsLabel",(e,n)=>{const{googleChartWrapper:o,options:l}=e;if(!o){console.error("googleChartWrapper is not defined");return}const d=o.getDataTable();if(!d)return;const f=d.getNumberOfColumns();if(n.length>0===!1)return;const b=Array.from({length:f-1}).map((_,S)=>{const R=Tr.getColumnId(d,S+1);return n.includes(R)?GRAY_COLOR:l&&l.colors?l.colors[S]:DEFAULT_CHART_COLORS[S]});o.setOptions({...l,colors:b}),o.draw()}),Qt(Tr,"listenToLegendToggle",(e,n)=>{const[o,l]=n,{google:d,googleChartWrapper:f}=e;if(!f){console.error("googleChartWrapper is not defined");return}return d.visualization.events.addListener(f,"select",()=>{const b=f.getChart().getSelection(),_=f.getDataTable();if(b.length===0||b[0].row!==null||!_)return;const S=b[0].column,R=Tr.getColumnId(_,S);o!=null&&o.includes(R)?l(C=>[...C.filter(E=>E!==R)]):l(C=>[...C,R])})}),Qt(Tr,"draw",async e=>{const{data:n,diffdata:o,rows:l,columns:d,options:f,chartType:g,formatters:b,spreadSheetUrl:_,spreadSheetQueryParameters:S,googleChartDashboard:R,googleChartWrapper:C,google:E,hiddenColumns:A,legendToggle:I,legend_toggle:M}=e;if(!C){console.error("draw was called with googleChartWrapper = null");return}let j,q=null;if(o){const te=E.visualization.arrayToDataTable(o.old),ne=E.visualization.arrayToDataTable(o.new);q=E.visualization[g].prototype.computeDiff(te,ne)}n?n instanceof E.visualization.DataTable?j=n:Array.isArray(n)?j=E.visualization.arrayToDataTable(n):j=new E.visualization.DataTable(n):l&&d?j=E.visualization.arrayToDataTable([d,...l]):_?j=await loadDataTableFromSpreadSheet(E,_,S):j=E.visualization.arrayToDataTable([]);const z=j.getNumberOfColumns(),Q=Array(z).fill(0).map((te,ne)=>{const se=Tr.getColumnId(j,ne);return A.includes(se)?{label:j.getColumnLabel(ne),type:j.getColumnType(ne),calc:()=>null}:ne}),F=C.getChart();C.getChartType()==="Timeline"&&F&&F.clearChart(),C.setChartType(g),C.setOptions(f||{});const V=new E.visualization.DataView(j);V.setColumns(Q),C.setDataTable(V),C.draw(),R&&R.draw(j),q&&(C.setDataTable(q),C.draw()),b&&(Tr.applyFormatters({dataTable:j,formatters:b,google:E}),C.setDataTable(j),C.draw()),(I===!0||M===!0)&&Tr.grayOutHiddenColumnsLabel(e,A)}),Qt(Tr,"getColumnId",(e,n)=>e.getColumnId(n)||e.getColumnLabel(n)),Qt(Tr,"applyFormatters",e=>{let{dataTable:n,formatters:o,google:l}=e;for(let d of o)switch(d.type){case"ArrowFormat":{new l.visualization.ArrowFormat(d.options).format(n,d.column);return}case"BarFormat":{new l.visualization.BarFormat(d.options).format(n,d.column);return}case"ColorFormat":{const f=new l.visualization.ColorFormat(d.options),{ranges:g}=d;if(g)for(let b of g)f.addRange(...b);f.format(n,d.column);return}case"DateFormat":{new l.visualization.DateFormat(d.options).format(n,d.column);return}case"NumberFormat":{new l.visualization.NumberFormat(d.options).format(n,d.column);return}case"PatternFormat":{new l.visualization.PatternFormat(d.options).format(n,d.column);return}default:{console.warn(`Unknown formatter type: ${d.type}`);return}}});let GoogleChartInternal=Tr;const useGoogleChartDataTable=t=>{const{google:e,googleChartWrapper:n,googleChartDashboard:o}=t,[l,d]=React__namespace.useState([]);React__namespace.useEffect(()=>{n&&GoogleChartInternal.draw({...t,hiddenColumns:l,googleChartWrapper:n,googleChartDashboard:o,google:e})},[l,t.data,t.rows,t.columns,t.options,t.chartLoaderScriptUrl,t.chartType,t.formatters,t.spreadSheetUrl,t.spreadSheetQueryParameters,t.legendToggle,t.legend_toggle]);const f=()=>{const{googleChartWrapper:_}=t;_&&_.draw()},g=_=>{const S=[],{legendToggle:R,legend_toggle:C}=t;if(GoogleChartInternal.draw({...t,hiddenColumns:l,googleChartWrapper:_,googleChartDashboard:o,google:e}),window.addEventListener("resize",f),C||R){const E=GoogleChartInternal.listenToLegendToggle(t,[l,d]);E&&S.push(E)}return S},b=(_,S)=>{window.removeEventListener("resize",f),S.forEach(R=>{e.visualization.events.removeListener(R)}),_.getChartType()==="Timeline"&&_.getChart()&&_.getChart().clearChart()};React__namespace.useEffect(()=>{if(!n)return;const _=g(n);return()=>{b(n,_)}},[n,g,b])},listenToEvents=t=>{const{chartEvents:e,google:n,googleChartWrapper:o}=t;if(e){if(!o){console.warn("listenToEvents was called before chart wrapper ready.");return}return e.map(l=>{let{eventName:d,callback:f}=l;return n.visualization.events.addListener(o,d,function(){for(var g=arguments.length,b=new Array(g),_=0;_<g;_++)b[_]=arguments[_];f({chartWrapper:o,props:t,google:n,eventArgs:b})})})}},useGoogleChartEvents=t=>{React.useEffect(()=>{if(!t.googleChartWrapper)return;const e=listenToEvents(t);return()=>{e==null||e.forEach(n=>{t.google.visualization.events.removeListener(n)})}},[t])},GoogleChart=t=>{const[e,n]=React__namespace.useState(null),[o,l]=React__namespace.useState(null),{addControls:d,renderControl:f}=useChartControls({...t,chartDashboard:o,chartWrapper:e});useGoogleChartEvents({...t,googleChartWrapper:e});const{chartId:g}=useChartId(t),b=React__namespace.useRef(null),_=React__namespace.useRef(null);React__namespace.useEffect(()=>{const{options:j,google:q,chartType:z,chartWrapperParams:Q,toolbarItems:F,getChartEditor:V,getChartWrapper:te,onLoad:ne}=t,se={chartType:z,options:j,containerId:g,...Q},ge=new q.visualization.ChartWrapper(se);ge.setOptions(j||{}),te==null||te(ge,q);const oe=new q.visualization.Dashboard(b.current);F&&q.visualization.drawToolbar(_.current,F);let Ae=null;V&&(Ae=new q.visualization.ChartEditor,V({chartEditor:Ae,chartWrapper:ge,google:q})),d({...t,chartDashboard:oe,chartWrapper:ge}),n(ge),l(oe),ne==null||ne(q,{google:q,chartWrapper:ge,chartEditor:Ae,chartDashboard:oe})},[]),useGoogleChartDataTable({...t,googleChartWrapper:e,googleChartDashboard:o});const S=()=>{const{width:j,height:q,options:z,style:Q,className:F,rootProps:V,google:te}=t,ne={height:q||z&&z.height,width:j||z&&z.width,...Q};return React__namespace.createElement("div",{id:g,style:ne,className:F,...V})},R=()=>t.toolbarItems?React__namespace.createElement("div",{ref:_}):null,{width:C,height:E,options:A,style:I}=t,M={height:E||A&&A.height,width:C||A&&A.width,...I};return t.render?React__namespace.createElement("div",{ref:b,style:M},React__namespace.createElement("div",{ref:_,id:"toolbar"}),t.render({renderChart:S,renderControl:f,renderToolbar:R})):React__namespace.createElement("div",{ref:b,style:M},f(j=>{let{controlProp:q}=j;return q.controlPosition!=="bottom"}),S(),f(j=>{let{controlProp:q}=j;return q.controlPosition==="bottom"}),R())},ChartContext=React__namespace.createContext(chartDefaultProps),ContextProvider=t=>{let{children:e,value:n}=t;return React__namespace.createElement(ChartContext.Provider,{value:n},e)},ChartView=t=>{const{google:e,isLoading:n,error:o}=useLoadGoogleCharts(t);return n?t.loader??null:o?t.errorElement??null:e?React.createElement(GoogleChart,{google:e,...t}):null},Chart=t=>{const e={...chartDefaultProps,...t};return React.createElement(ContextProvider,{value:e},React.createElement(ChartView,e))};var GoogleDataTableColumnRoleType;(function(t){t.annotation="annotation",t.annotationText="annotationText",t.certainty="certainty",t.emphasis="emphasis",t.interval="interval",t.scope="scope",t.style="style",t.tooltip="tooltip",t.domain="domain"})(GoogleDataTableColumnRoleType||(GoogleDataTableColumnRoleType={}));function parseHsl(t){const e=t.match(/(\d+\.?\d*)\s*(\d+\.?\d*)%\s*(\d+\.?\d*)%/);return e?{h:parseFloat(e[1]),s:parseFloat(e[2]),l:parseFloat(e[3])}:null}function hslToHex(t,e,n){n/=100;const o=e*Math.min(n,1-n)/100,l=d=>{const f=(d+t/30)%12,g=n-o*Math.max(Math.min(f-3,9-f,1),-1);return Math.round(255*g).toString(16).padStart(2,"0")};return`#${l(0)}${l(8)}${l(4)}`}const Treemap=React__namespace.forwardRef(({data:t,options:e,height:n="500px",className:o,loading:l,...d},f)=>{const g=React__namespace.useRef(null),[b,_]=React__namespace.useState(null);React__namespace.useEffect(()=>{if(!g.current)return;const R=getComputedStyle(g.current).getPropertyValue("--primary"),C=parseHsl(R.trim());if(C){const{h:E,s:A,l:I}=C;_({minColor:hslToHex(E,A,Math.min(100,I+50)),midColor:hslToHex(E,A,Math.min(100,I+35)),maxColor:hslToHex(E,A,Math.min(100,I+20))})}},[]);const S=React__namespace.useMemo(()=>{const R={headerHeight:24,fontSize:14,showScale:!0,isHtml:!0,generateTooltip:(C,E)=>{var M;const A=(M=t[C+1])==null?void 0:M[0];if(!A)return"";const I=formatMoney(E);return`<div class="p-2 bg-background text-foreground border rounded-md shadow-lg">
1317
+ `;function RichTextEditor({id:t,name:e,value:n,onChange:o,placeholder:l,className:d,...f}){const[g,b]=React.useState(!1),_=React.useRef(null),S=React.useRef(null),R=useEditor({extensions:[StarterKit,Underline],content:n,editorProps:{attributes:{class:"prose prose-sm sm:prose dark:prose-invert focus:outline-none",id:t??"",name:e??""}},onUpdate:({editor:j})=>{const q=j.getHTML();o({target:{id:t,name:e,value:q}})}});React.useEffect(()=>{R&&n!==R.getHTML()&&R.commands.setContent(n)},[n,R]);const C=React.useCallback(j=>{if(R)if(R.chain().focus(),j==="paragraph")R.chain().setParagraph().run();else{const q=Number.parseInt(j.slice(1));R.chain().setHeading({level:q}).run()}},[R]),E=React.useCallback(j=>{if(R)switch(R.chain().focus(),j){case"bold":R.chain().toggleBold().run();break;case"italic":R.chain().toggleItalic().run();break;case"underline":R.chain().toggleUnderline().run();break;case"strike":R.chain().toggleStrike().run();break;case"bulletList":R.chain().toggleBulletList().run();break;case"orderedList":R.chain().toggleOrderedList().run();break}},[R]),A=React.useCallback(()=>{b(j=>!j)},[]),I=React.useCallback(j=>{const q=j.target.value;R&&R.commands.setContent(q),o({target:{id:t,name:e,value:q}})},[o,R,t,e]),M=React.useCallback(()=>{!g&&R&&R.commands.focus()},[g,R]);return R?jsxRuntime.jsxs("div",{ref:S,className:cn("border border-input rounded-md overflow-hidden focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring",d),onClick:M,...f,children:[jsxRuntime.jsx("style",{children:editorStyles}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center p-2 border-b border-input gap-2 bg-background",children:[jsxRuntime.jsxs(Select,{onValueChange:C,disabled:g,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[160px]",children:jsxRuntime.jsx(SelectValue,{placeholder:"Format"})}),jsxRuntime.jsx(SelectContent,{children:formatOptions.map(j=>jsxRuntime.jsx(SelectItem,{value:j.value,children:j.label},j.value))})]}),["bold","italic","underline","strike","bulletList","orderedList"].map(j=>jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(j),className:R.isActive(j)?"bg-muted":"",disabled:g,children:[j==="bold"&&jsxRuntime.jsx(Bold$1,{className:"h-4 w-4"}),j==="italic"&&jsxRuntime.jsx(Italic$1,{className:"h-4 w-4"}),j==="underline"&&jsxRuntime.jsx(Underline$1,{className:"h-4 w-4"}),j==="strike"&&jsxRuntime.jsx(Strikethrough,{className:"h-4 w-4"}),j==="bulletList"&&jsxRuntime.jsx(List$1,{className:"h-4 w-4"}),j==="orderedList"&&jsxRuntime.jsx(ListOrdered,{className:"h-4 w-4"})]},j)),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"sm",onClick:A,className:g?"bg-muted":"",children:jsxRuntime.jsx(Code$1,{className:"h-4 w-4"})})]}),jsxRuntime.jsx("div",{className:"p-3",children:g?jsxRuntime.jsx(Textarea,{ref:_,id:t,name:e,value:R.getHTML(),onChange:I,className:cn("min-h-[150px] font-mono text-sm resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",d),placeholder:l}):jsxRuntime.jsx(EditorContent,{editor:R})})]}):null}function formatYYYYMMDDIntToDateString(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function ReceiptsTable({receipts:t=null,loading:e=!1,title:n="Latest Warehouse Receivings"}){const o=React.useMemo(()=>[{accessorKey:"Location",header:"Location",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.Location??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.ReceiptDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!0}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(_=>_.Location).filter(_=>_!=null)));f.Location=g;const b=Array.from(new Set(t.map(_=>formatYYYYMMDDIntToDateString(_.ReceiptDate)).filter(_=>_!=="N/A"&&_!=="Invalid Date"))).sort((_,S)=>new Date(S).getTime()-new Date(_).getTime());f.ReceiptDate=b}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-56"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}const formatDate$1=t=>{if(!t)return"N/A";try{const e=new Date(t);return isNaN(e.getTime())?"Invalid Date":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}},getStatusVariant=t=>{const e=(t==null?void 0:t.toLowerCase())||"";return e.includes("accepted")?"success":e.includes("error")||e.includes("rejected")?"destructive":"neutral"};function ReturnsTable({applicationId:t,returns:e=null,loading:n=!1}){const o=React.useMemo(()=>[{accessorKey:"ReturnNumber1",header:"RMA Number",cell:({row:f})=>{const g=f.original.ReturnNumber1||f.original.ReturnNumber;return g?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Return/${g}`,className:"font-medium text-blue-600 hover:underline dark:text-blue-400",children:g})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for return ",g]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"RequestDate",header:"Request Date",cell:({row:f})=>formatDate$1(f.original.RequestDate),enableSorting:!0},{accessorKey:"InvoiceNumber",header:"Invoice Number",cell:({row:f})=>{const g=f.original.InvoiceNumber;return g?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Document/${g}`,className:"text-blue-600 hover:underline dark:text-blue-400",children:g})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for invoice ",g]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"0",enableSorting:!0},{accessorKey:"ReasonForReturn",header:"Return Reason",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ReasonForReturn??"—"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"Status",header:"Status",cell:({row:f})=>{const g=f.original.Status,b=getStatusVariant(g);let _="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return b==="success"?_="border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400":b==="destructive"&&(_="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400"),g?jsxRuntime.jsx(Badge,{variant:"outline",className:`${_} font-medium`,children:g}):"—"},enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseLocation",header:"Warehouse",cell:({row:f})=>f.original.WarehouseLocation??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"LastUpdatedDate",header:"Last Update",cell:({row:f})=>formatDate$1(f.original.LastUpdatedDate)!=="N/A"?formatDate$1(f.original.LastUpdatedDate):"—",enableSorting:!0}],[t]),l=React.useMemo(()=>{const f={};if(e){const g=Array.from(new Set(e.map(S=>S.Status).filter(Boolean)));f.Status=g;const b=Array.from(new Set(e.map(S=>S.ReasonForReturn).filter(Boolean)));f.ReasonForReturn=b;const _=Array.from(new Set(e.map(S=>S.WarehouseLocation).filter(Boolean)));f.WarehouseLocation=_}return f},[e]),d=React.useMemo(()=>e?[...e].sort((g,b)=>(b.ReturnNumber1||b.ReturnNumber||"").localeCompare(g.ReturnNumber1||g.ReturnNumber||"")):[],[e]);return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-48 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Returns"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function ProductOverviewPage({applicationId:t,sku:e,productDefaultOpportunityNumber:n="",productOnAddToCart:o,productAddingToCart:l=!1,productShopifyHostname:d,productCustomAction:f=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){var C,E,A,I,M,j,q,z,Q;const{data:g,isLoading:b}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!t||!e}),{data:_,isLoading:S}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!0},{skip:!g}),R=(g==null?void 0:g.ManufacturerId)!==t;return console.log("readonly",R),jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 @sm:grid-cols-2 @md:grid-cols-3",children:[jsxRuntime.jsx("div",{className:"@md:col-span-2",children:jsxRuntime.jsx(ProductCard,{applicationId:t,product:_||g,defaultOpportunityNumber:n,onAddToCart:o,addingToCart:l,shopifyHostname:d,customAction:f})}),jsxRuntime.jsxs(Card,{className:"flex flex-col",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{children:[jsxRuntime.jsx(Info,{className:"h-5 w-5 inline mr-2"})," Additionnal information"]})}),jsxRuntime.jsx(CardContent,{className:"basis-0 grow overflow-y-auto",children:b?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-1 w-full my-6"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-1"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Cateory Name"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.ProductType)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Master Carton"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.MasterCarton)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Skid Quantity"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.SkidQuantity)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Automatic Reorder"}),jsxRuntime.jsx("span",{className:"font-medium",children:g!=null&&g.AutoUpdate?"Yes":"No"})]}),((g==null?void 0:g.VoiceoverCaption)||(g==null?void 0:g.BodyHTML))&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("hr",{className:"my-6"}),jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2",children:"Description"}),(g==null?void 0:g.VoiceoverCaption)&&jsxRuntime.jsx("div",{children:g==null?void 0:g.VoiceoverCaption}),(g==null?void 0:g.BodyHTML)&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:(g==null?void 0:g.BodyHTML)??""}})]})]})})]})]}),jsxRuntime.jsx("div",{className:"my-4",children:b?jsxRuntime.jsx("div",{className:"mx-auto flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})}):jsxRuntime.jsxs(Tabs,{defaultValue:"stats",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[jsxRuntime.jsx(TabsTrigger,{value:"stats",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:!S&&(((C=_==null?void 0:_.SalesStatistics)==null?void 0:C.length)??0)<=0,children:"Statistics"}),jsxRuntime.jsx(TabsTrigger,{value:"opportunities",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:!S&&(((E=_==null?void 0:_.Opportunities)==null?void 0:E.length)??0)<=0,children:"Opportunities"}),jsxRuntime.jsx(TabsTrigger,{value:"orders",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:!S&&(((A=_==null?void 0:_.ActiveOrderDetails)==null?void 0:A.length)??0)<=0&&(((I=_==null?void 0:_.CompletedOrderDetails)==null?void 0:I.length)??0)<=0&&(((M=_==null?void 0:_.Returns)==null?void 0:M.length)??0)<=0,children:"Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"warehouse",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",disabled:!S&&(((j=_==null?void 0:_.Receipts)==null?void 0:j.length)??0)<=0,children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChart,{salesData:(_==null?void 0:_.SalesStatistics)??[],isLoading:S,units:""})})}),jsxRuntime.jsx(TabsContent,{value:"opportunities",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:g==null?void 0:g.Opportunities,loading:b})})}),jsxRuntime.jsxs(TabsContent,{value:"orders",children:[(S||((q=_==null?void 0:_.ActiveOrderDetails)==null?void 0:q.length)!==0)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Open Orders",orders:_==null?void 0:_.ActiveOrderDetails,loading:S})}),(S||((z=_==null?void 0:_.CompletedOrderDetails)==null?void 0:z.length)!==0)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Completed Orders",orders:_==null?void 0:_.CompletedOrderDetails,loading:S})}),(S||((Q=_==null?void 0:_.CompletedOrderDetails)==null?void 0:Q.length)!==0)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReturnsTable,{applicationId:t,returns:_==null?void 0:_.Returns,loading:S})})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReceiptsTable,{receipts:_==null?void 0:_.Receipts,loading:S})})})]})})]})}function AssistantChat(t){return jsxRuntime.jsx(Card,{className:"max-w-6xl",children:jsxRuntime.jsx(ChatLayout,{className:"h-[40em]",userId:t.userId,userName:t.userName,assistantOnly:!0,initialPrompt:t.initialPrompt})})}function getEndDateStatus(t){if(!t)return{text:"No End Date",variant:"neutral",daysRemaining:null};const e=new Date(t);if(isNaN(e.getTime()))return{text:"Invalid Date",variant:"neutral",daysRemaining:null};const n=new Date,o=new Date(e.getFullYear(),e.getMonth(),e.getDate()),l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),d=o.getTime()-l.getTime(),f=Math.ceil(d/(1e3*60*60*24));return f<0?{text:`Ended ${Math.abs(f)}d ago`,variant:"destructive",daysRemaining:f}:f===0?{text:"Ends today",variant:"destructive",daysRemaining:f}:f<=7?{text:`Ends in ${f}d`,variant:"destructive",daysRemaining:f}:f<=30?{text:`Ends in ${f}d`,variant:"warning",daysRemaining:f}:{text:`Ends in ${f}d`,variant:"neutral",daysRemaining:f}}const formatDate=t=>{if(!t)return"N/A";try{const e=new Date(t);return isNaN(e.getTime())?"Invalid Date":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}};function OpportunitiesTable({applicationId:t,opportunities:e=null,loading:n=!1}){var te;const{toast:o}=useToast(),[l,d]=React.useState({}),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,R]=React.useState(null),{data:C}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t}),E=React.useCallback((ne,se,ge)=>{d(oe=>({...oe,[ne]:{...oe[ne],[se]:ge}}))},[]),[A]=usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(),I=React.useCallback(async ne=>{if(!(C!=null&&C.IsReseller))return;if(!ne.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot set default.",variant:"destructive"});return}const se=ne.BidNumber;E(se,"isSettingDefault",!0),A({routeResellerId:t,manufacturerId:ne.ManufacturerId??"",opportunityNumber:se}).unwrap().then(()=>{o({title:"Success",description:`Opportunity "${ne.OpportunityName||ne.Opportunity||se}" was successfully set as default.`,variant:"success"})}).catch(ge=>{var oe;console.error("Set as default error:",ge),o({title:"Error",description:((oe=ge.data)==null?void 0:oe.message)||ge.message||"An error occurred while setting this opportunity as default.",variant:"destructive"})}).finally(()=>{E(se,"isSettingDefault",!1)})},[t,A,o,E]),[M]=usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(),j=React.useCallback(ne=>{if(C!=null&&C.IsReseller){if(!ne.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot prepare report.",variant:"destructive"});return}R(ne),_(""),g(!0)}},[o]),q=React.useCallback(async()=>{if(!(C!=null&&C.IsReseller))return;if(!S||!S.BidNumber){o({title:"Error",description:"No opportunity selected or Bid Number is missing.",variant:"destructive"});return}if(!b.trim()||!/\S+@\S+\.\S+/.test(b)){o({title:"Validation Error",description:"Please enter a valid email address.",variant:"destructive"});return}const ne=S.BidNumber;E(ne,"isSendingReport",!0),M({routeResellerId:t,manufacturerId:S.ManufacturerId??"",bidNumber:ne,emailAddress:b}).unwrap().then(()=>{o({title:"Success",description:`A report for "${S.OpportunityName||S.Opportunity||ne}" was successfully sent to ${b}.`,variant:"success"}),g(!1)}).catch(se=>{var ge;console.error("Send report by email error:",se),o({title:"Error",description:((ge=se.data)==null?void 0:ge.message)||se.message||"An error occurred while sending the report by email.",variant:"destructive"})}).finally(()=>{E(ne,"isSendingReport",!1),f||(R(null),_(""))})},[S,b,t,M,o,E,g]),z=React.useMemo(()=>[{accessorKey:"ManufacturerId",header:"Manuf.",cell:({row:ne})=>jsxRuntime.jsx("div",{className:"w-20 h-8",children:jsxRuntime.jsx(PartnerLogo,{id:ne.original.ManufacturerId,width:80,height:32})}),enableSorting:!0,enableFiltering:!0},{id:"opportunityDisplay",accessorFn:ne=>ne.OpportunityName||ne.Opportunity,header:"Opportunity",cell:({getValue:ne})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:ne()??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"BidNumber",header:"Bid Number",cell:({row:ne})=>ne.original.BidNumber??"N/A",enableSorting:!0,enableFiltering:!0},{id:"statusInfo",header:"Status",cell:({row:ne})=>{const se=ne.original,ge=se.Active===!0,oe=getEndDateStatus(se.EndDate);let Ae="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return oe.variant==="destructive"?Ae="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400":oe.variant==="warning"&&(Ae="border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 min-w-[200px]",children:[jsxRuntime.jsx(Badge,{variant:"outline",className:ge?"border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400 font-medium":"border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400 font-medium",children:ge?"Active":"Inactive"}),se.EndDate&&jsxRuntime.jsx(Badge,{variant:"outline",className:`${Ae} font-medium`,children:oe.text}),jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent",children:jsxRuntime.jsx(Info,{className:"h-4 w-4 text-muted-foreground"})})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",className:"bg-popover text-popover-foreground p-2 rounded shadow-lg",children:jsxRuntime.jsxs("div",{className:"text-sm space-y-1",children:[jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Start:"})," ",formatDate(se.StartDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"End:"})," ",formatDate(se.EndDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Updated:"})," ",formatDate(se.LastUpdate)]})]})})]})})]})},enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:ne})=>{var Oe,Fe;const se=ne.original;if(!se.BidNumber)return jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Actions unavailable"});const ge=se.BidNumber,oe=(Oe=l[ge])==null?void 0:Oe.isSettingDefault,Ae=(S==null?void 0:S.BidNumber)===ge&&((Fe=l[ge])==null?void 0:Fe.isSendingReport),je=oe||Ae,Ne=se.CanBeSetAsDefault===!0;return jsxRuntime.jsxs("div",{className:"flex space-x-2",children:[jsxRuntime.jsx("a",{href:`/${t}/Opportunity/${se.ManufacturerId}/${se.BidNumber}`,children:jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center",children:[jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," View"]})}),(C==null?void 0:C.IsReseller)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>I(se),disabled:je||!Ne,title:Ne?"Set as default":"This opportunity cannot be set as default",className:"flex items-center",children:[oe?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," Set Default"]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>j(se),disabled:je,title:"Send report by email",className:"flex items-center",children:[Ae?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"})," Send Report"]})]})]})}}],[l,I,j,S]),Q=React.useMemo(()=>{const ne={};if(e){const se=Array.from(new Set(e.map(oe=>oe.ManufacturerId).filter(oe=>oe!=null)));ne.ManufacturerId=se;const ge=Array.from(new Set(e.map(oe=>oe.OpportunityName||oe.Opportunity).filter(oe=>oe!=null)));ne.opportunityDisplay=ge}return ne},[e]),F=e||[],V=S!=null&&S.BidNumber?(te=l[S.BidNumber])==null?void 0:te.isSendingReport:!1;return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-48 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Opportunities"})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:z,data:F,uniqueValues:Q})})]}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:ne=>{g(ne),ne||(R(null),_(""))},children:jsxRuntime.jsxs(DialogContent,{className:"@sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Opportunity Report"}),jsxRuntime.jsxs(DialogDescription,{children:["Enter the email address to send the report for opportunity: ",jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{className:"font-semibold",children:(S==null?void 0:S.OpportunityName)||(S==null?void 0:S.Opportunity)||"N/A"}),(S==null?void 0:S.BidNumber)&&jsxRuntime.jsxs("span",{className:"block text-sm text-muted-foreground",children:["Bid Number: ",S.BidNumber]})]})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:b,onChange:ne=>_(ne.target.value),placeholder:"recipient@example.com",className:"col-span-3",disabled:V})]})}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>g(!1),disabled:V,children:"Cancel"}),jsxRuntime.jsxs(Button,{type:"submit",onClick:q,disabled:V,children:[V&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"})," Send Report"]})]})]})})]})}function SalesChart({salesData:t,chartHeight:e=300,units:n="$",unitsPosition:o="left",className:l,isLoading:d=!1}){const[f,g]=React.useState([]),[b,_]=React.useState(!1),S=!d;return React.useEffect(()=>{if(d){g([]);return}const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),I=`${C}-${(E+1).toString().padStart(2,"0")}`,M=[];for(let Q=11;Q>=0;Q--){const F=new Date(C,E-Q,1),V=F.getFullYear(),te=(F.getMonth()+1).toString().padStart(2,"0");M.push(`${V}-${te}`)}const j={};M.forEach(Q=>{j[Q]=0}),t&&t.length>0&&t.forEach(Q=>{const F=Q.Day??0,V=Math.floor(F).toString();if(V.length!==8||isNaN(Number.parseInt(V))){console.warn(`Skipping invalid Day format: ${Q.Day}`);return}const te=V.substring(0,4),ne=V.substring(4,6),se=`${te}-${ne}`;M.includes(se)&&(j[se]=(j[se]||0)+(Q.ExtendedPrice??0))});const q={...j};if(b&&j[I]>0){const Q=q[I],F=new Date(C,E+1,0).getDate();if(A<F&&A>0){const te=Q/A*F;q[I]=te}}const z=M.map(Q=>{const F=q[Q],[V,te]=Q.split("-").map(Number);return{month:new Date(V,te-1).toLocaleString("default",{month:"short",year:"numeric"}),sales:F}});g(z)},[t,b,d]),d?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:e},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"})]}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4 mt-1"})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Sales"})}),jsxRuntime.jsx(CardContent,{children:f.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:f,units:n,unitsPosition:o,height:e,className:l}),S&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Switch,{checked:b,onCheckedChange:_,id:"extrapolate-switch","aria-label":"Toggle sales extrapolation"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate"})]}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"* Sales for the current month are projected, not actual."})]})]}):jsxRuntime.jsx("div",{style:{height:e},className:l||"p-4 text-center text-muted-foreground flex items-center justify-center",children:"No sales data available."})})]})}function useLoadScript(t){const[e,n]=React.useState(!0),[o,l]=React.useState(null),[d,f]=React.useState(!1),g=()=>{n(!1),f(!0)};return React.useEffect(()=>{if(!document){const R=new Error(`[ScriptLoadingError] document not defined when attempting to load ${t}`);l(R);return}const b=document.querySelector(`script[src="${t}"]`);if(b!=null&&b.dataset.loaded){g();return}const _=b||document.createElement("script");b||(_.src=t);const S=()=>{_.dataset.loaded="1",g()};_.addEventListener("load",S),_.addEventListener("error",R=>{console.error("Failed to load script:",t,R);const C=new Error(`[ScriptLoadingError] Failed to load script: ${t}`);l(C)}),b||document.head.append(_)},[]),{isLoading:e,error:o,isSuccess:d}}const isGoogleReady=t=>t&&t.charts,isGoogleChartsReady=(t,e)=>{const{controls:n,toolbarItems:o,getChartEditor:l}=t;return e&&e.charts&&e.visualization&&e.visualization.ChartWrapper&&e.visualization.Dashboard&&(!n||e.visualization.ChartWrapper)&&(!l||e.visualization.ChartEditor)&&(!o||e.visualization.drawToolbar)},getGoogleInstanceFromWindow=t=>window.google;function useLoadGoogleCharts(t){const{chartVersion:e="current",chartPackages:n=["corechart","controls"],chartLanguage:o="en",mapsApiKey:l}=t,[d,f]=React.useState(null),[g,b]=React.useState(null),[_,S]=React.useState(null),{isLoading:R,error:C,isSuccess:E}=useLoadScript(t.chartLoaderScriptUrl||"https://www.gstatic.com/charts/loader.js");return React.useEffect(()=>{if(!E)return;const A=getGoogleInstanceFromWindow();if(!isGoogleReady(A)){const I=new Error("[ScriptInitializationError] Script loaded but Google not attached to window.");b(I);return}if(isGoogleChartsReady(t,A)){f(A);return}A.charts.load(e,{packages:n,language:o,mapsApiKey:l}),A.charts.setOnLoadCallback(()=>{if(!isGoogleChartsReady(t,A)){const I=new Error("[GoogleChartsInitializationError] Google Charts not ready after load callback.");console.error(I),S(I);return}f(A)})},[E]),{error:C||g||_,isLoading:R,google:d}}const chartDefaultProps={legend_toggle:!1,options:{},legendToggle:!1,getChartWrapper:()=>{},spreadSheetQueryParameters:{headers:1,gid:1},rootProps:{},chartWrapperParams:{},chartLoaderScriptUrl:"https://www.gstatic.com/charts/loader.js"},GoogleChartControls=t=>{const{isReady:e,chartControls:n,filter:o}=t;return!e||!n||!(n!=null&&n.length)?null:React.createElement(React.Fragment,null,n.filter(l=>{let{controlProp:d,control:f}=l;return o?o({control:f,controlProp:d}):!0}).map(l=>{let{control:d}=l;return React.createElement("div",{key:d.getContainerId(),id:d.getContainerId()})}))};let uniqueID=0;const generateUniqueID=()=>(uniqueID+=1,`reactgooglegraph-${uniqueID}`),Nr=class Nr{};Qt(Nr,"initializeControls",e=>{for(let n=0;n<e.length;n+=1){const{controlType:o,options:l,controlWrapperParams:d}=e[n].controlProp;d&&"state"in d&&e[n].control.setState(d.state),e[n].control.setOptions(l),e[n].control.setControlType(o)}}),Qt(Nr,"listenToControlEvents",(e,n)=>{const{google:o}=n;return e.flatMap(l=>{const{control:d,controlProp:f}=l,{controlEvents:g=[]}=f;return g.map(b=>{const{callback:_,eventName:S}=b;return o.visualization.events.addListener(d,S,function(){for(var R=arguments.length,C=new Array(R),E=0;E<R;E++)C[E]=arguments[E];_({chartWrapper:null,controlWrapper:d,props:n,google:o,eventArgs:C})})})})}),Qt(Nr,"createControlId",e=>{let n;return typeof e>"u"?n=`googlechart-control-${generateUniqueID()}`:n=e,n}),Qt(Nr,"createChartControls",e=>{const{controls:n,google:o}=e;return n?n.map((l,d)=>{const{controlID:f,controlType:g,options:b,controlWrapperParams:_}=l,S=Nr.createControlId(f);return{controlProp:l,control:new o.visualization.ControlWrapper({containerId:S,controlType:g,options:b,..._})}}):null}),Qt(Nr,"addControls",e=>{const{chartWrapper:n,chartDashboard:o}=e,l=Nr.createChartControls(e);return!l||!o||!n?null:(o.bind(l.map(d=>{let{control:f}=d;return f}),n),Nr.initializeControls(l),l)});let GoogleChartControlsInternal=Nr;const useCreateChartControls=t=>{const[e,n]=React__namespace.useState(null);return[React__namespace.useMemo(()=>!e||!t?null:t.map((l,d)=>{const f=e[d];return f?{controlProp:l,control:f}:void 0}).flatMap(l=>l?[l]:[]),[e,t]),n]},useListenToControlEvents=(t,e)=>{React__namespace.useEffect(()=>{const n=GoogleChartControlsInternal.listenToControlEvents(t??[],e);return()=>{n.forEach(o=>{e.google.visualization.events.removeListener(o)})}},[t,e])},useChartControls=t=>{const[e,n]=useCreateChartControls(t.controls);return useListenToControlEvents(e??[],t),{addControls:l=>{const d=GoogleChartControlsInternal.addControls(l);n((d==null?void 0:d.map(f=>f.control))??null)},renderControl:l=>{const{chartWrapper:d,chartDashboard:f}=t;return React__namespace.createElement(GoogleChartControls,{...t,isReady:!!(d&&f),chartControls:e,filter:l})}}},useChartId=t=>{const e=React__namespace.useRef(null);return{chartId:(()=>{const{graphID:l,graph_id:d}=t,f=l||d;let g;return f?g=f:g=e.current||generateUniqueID(),e.current=g,e.current})()}},DEFAULT_CHART_COLORS=["#3366CC","#DC3912","#FF9900","#109618","#990099","#3B3EAC","#0099C6","#DD4477","#66AA00","#B82E2E","#316395","#994499","#22AA99","#AAAA11","#6633CC","#E67300","#8B0707","#329262","#5574A6","#3B3EAC"],loadDataTableFromSpreadSheet=async function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return new Promise((o,l)=>{const d=`${n.headers?`headers=${n.headers}`:"headers=0"}`,f=`${n.query?`&tq=${encodeURIComponent(n.query)}`:""}`,g=`${n.gid?`&gid=${n.gid}`:""}`,b=`${n.sheet?`&sheet=${n.sheet}`:""}`,_=`${n.access_token?`&access_token=${n.access_token}`:""}`,S=`${d}${g}${b}${f}${_}`,R=`${e}/gviz/tq?${S}`;new t.visualization.Query(R).send(E=>{E.isError()?l(`Error in query: ${E.getMessage()} ${E.getDetailedMessage()}`):o(E.getDataTable())})})},GRAY_COLOR="#CCCCCC",Tr=class Tr{};Qt(Tr,"grayOutHiddenColumnsLabel",(e,n)=>{const{googleChartWrapper:o,options:l}=e;if(!o){console.error("googleChartWrapper is not defined");return}const d=o.getDataTable();if(!d)return;const f=d.getNumberOfColumns();if(n.length>0===!1)return;const b=Array.from({length:f-1}).map((_,S)=>{const R=Tr.getColumnId(d,S+1);return n.includes(R)?GRAY_COLOR:l&&l.colors?l.colors[S]:DEFAULT_CHART_COLORS[S]});o.setOptions({...l,colors:b}),o.draw()}),Qt(Tr,"listenToLegendToggle",(e,n)=>{const[o,l]=n,{google:d,googleChartWrapper:f}=e;if(!f){console.error("googleChartWrapper is not defined");return}return d.visualization.events.addListener(f,"select",()=>{const b=f.getChart().getSelection(),_=f.getDataTable();if(b.length===0||b[0].row!==null||!_)return;const S=b[0].column,R=Tr.getColumnId(_,S);o!=null&&o.includes(R)?l(C=>[...C.filter(E=>E!==R)]):l(C=>[...C,R])})}),Qt(Tr,"draw",async e=>{const{data:n,diffdata:o,rows:l,columns:d,options:f,chartType:g,formatters:b,spreadSheetUrl:_,spreadSheetQueryParameters:S,googleChartDashboard:R,googleChartWrapper:C,google:E,hiddenColumns:A,legendToggle:I,legend_toggle:M}=e;if(!C){console.error("draw was called with googleChartWrapper = null");return}let j,q=null;if(o){const te=E.visualization.arrayToDataTable(o.old),ne=E.visualization.arrayToDataTable(o.new);q=E.visualization[g].prototype.computeDiff(te,ne)}n?n instanceof E.visualization.DataTable?j=n:Array.isArray(n)?j=E.visualization.arrayToDataTable(n):j=new E.visualization.DataTable(n):l&&d?j=E.visualization.arrayToDataTable([d,...l]):_?j=await loadDataTableFromSpreadSheet(E,_,S):j=E.visualization.arrayToDataTable([]);const z=j.getNumberOfColumns(),Q=Array(z).fill(0).map((te,ne)=>{const se=Tr.getColumnId(j,ne);return A.includes(se)?{label:j.getColumnLabel(ne),type:j.getColumnType(ne),calc:()=>null}:ne}),F=C.getChart();C.getChartType()==="Timeline"&&F&&F.clearChart(),C.setChartType(g),C.setOptions(f||{});const V=new E.visualization.DataView(j);V.setColumns(Q),C.setDataTable(V),C.draw(),R&&R.draw(j),q&&(C.setDataTable(q),C.draw()),b&&(Tr.applyFormatters({dataTable:j,formatters:b,google:E}),C.setDataTable(j),C.draw()),(I===!0||M===!0)&&Tr.grayOutHiddenColumnsLabel(e,A)}),Qt(Tr,"getColumnId",(e,n)=>e.getColumnId(n)||e.getColumnLabel(n)),Qt(Tr,"applyFormatters",e=>{let{dataTable:n,formatters:o,google:l}=e;for(let d of o)switch(d.type){case"ArrowFormat":{new l.visualization.ArrowFormat(d.options).format(n,d.column);return}case"BarFormat":{new l.visualization.BarFormat(d.options).format(n,d.column);return}case"ColorFormat":{const f=new l.visualization.ColorFormat(d.options),{ranges:g}=d;if(g)for(let b of g)f.addRange(...b);f.format(n,d.column);return}case"DateFormat":{new l.visualization.DateFormat(d.options).format(n,d.column);return}case"NumberFormat":{new l.visualization.NumberFormat(d.options).format(n,d.column);return}case"PatternFormat":{new l.visualization.PatternFormat(d.options).format(n,d.column);return}default:{console.warn(`Unknown formatter type: ${d.type}`);return}}});let GoogleChartInternal=Tr;const useGoogleChartDataTable=t=>{const{google:e,googleChartWrapper:n,googleChartDashboard:o}=t,[l,d]=React__namespace.useState([]);React__namespace.useEffect(()=>{n&&GoogleChartInternal.draw({...t,hiddenColumns:l,googleChartWrapper:n,googleChartDashboard:o,google:e})},[l,t.data,t.rows,t.columns,t.options,t.chartLoaderScriptUrl,t.chartType,t.formatters,t.spreadSheetUrl,t.spreadSheetQueryParameters,t.legendToggle,t.legend_toggle]);const f=()=>{const{googleChartWrapper:_}=t;_&&_.draw()},g=_=>{const S=[],{legendToggle:R,legend_toggle:C}=t;if(GoogleChartInternal.draw({...t,hiddenColumns:l,googleChartWrapper:_,googleChartDashboard:o,google:e}),window.addEventListener("resize",f),C||R){const E=GoogleChartInternal.listenToLegendToggle(t,[l,d]);E&&S.push(E)}return S},b=(_,S)=>{window.removeEventListener("resize",f),S.forEach(R=>{e.visualization.events.removeListener(R)}),_.getChartType()==="Timeline"&&_.getChart()&&_.getChart().clearChart()};React__namespace.useEffect(()=>{if(!n)return;const _=g(n);return()=>{b(n,_)}},[n,g,b])},listenToEvents=t=>{const{chartEvents:e,google:n,googleChartWrapper:o}=t;if(e){if(!o){console.warn("listenToEvents was called before chart wrapper ready.");return}return e.map(l=>{let{eventName:d,callback:f}=l;return n.visualization.events.addListener(o,d,function(){for(var g=arguments.length,b=new Array(g),_=0;_<g;_++)b[_]=arguments[_];f({chartWrapper:o,props:t,google:n,eventArgs:b})})})}},useGoogleChartEvents=t=>{React.useEffect(()=>{if(!t.googleChartWrapper)return;const e=listenToEvents(t);return()=>{e==null||e.forEach(n=>{t.google.visualization.events.removeListener(n)})}},[t])},GoogleChart=t=>{const[e,n]=React__namespace.useState(null),[o,l]=React__namespace.useState(null),{addControls:d,renderControl:f}=useChartControls({...t,chartDashboard:o,chartWrapper:e});useGoogleChartEvents({...t,googleChartWrapper:e});const{chartId:g}=useChartId(t),b=React__namespace.useRef(null),_=React__namespace.useRef(null);React__namespace.useEffect(()=>{const{options:j,google:q,chartType:z,chartWrapperParams:Q,toolbarItems:F,getChartEditor:V,getChartWrapper:te,onLoad:ne}=t,se={chartType:z,options:j,containerId:g,...Q},ge=new q.visualization.ChartWrapper(se);ge.setOptions(j||{}),te==null||te(ge,q);const oe=new q.visualization.Dashboard(b.current);F&&q.visualization.drawToolbar(_.current,F);let Ae=null;V&&(Ae=new q.visualization.ChartEditor,V({chartEditor:Ae,chartWrapper:ge,google:q})),d({...t,chartDashboard:oe,chartWrapper:ge}),n(ge),l(oe),ne==null||ne(q,{google:q,chartWrapper:ge,chartEditor:Ae,chartDashboard:oe})},[]),useGoogleChartDataTable({...t,googleChartWrapper:e,googleChartDashboard:o});const S=()=>{const{width:j,height:q,options:z,style:Q,className:F,rootProps:V,google:te}=t,ne={height:q||z&&z.height,width:j||z&&z.width,...Q};return React__namespace.createElement("div",{id:g,style:ne,className:F,...V})},R=()=>t.toolbarItems?React__namespace.createElement("div",{ref:_}):null,{width:C,height:E,options:A,style:I}=t,M={height:E||A&&A.height,width:C||A&&A.width,...I};return t.render?React__namespace.createElement("div",{ref:b,style:M},React__namespace.createElement("div",{ref:_,id:"toolbar"}),t.render({renderChart:S,renderControl:f,renderToolbar:R})):React__namespace.createElement("div",{ref:b,style:M},f(j=>{let{controlProp:q}=j;return q.controlPosition!=="bottom"}),S(),f(j=>{let{controlProp:q}=j;return q.controlPosition==="bottom"}),R())},ChartContext=React__namespace.createContext(chartDefaultProps),ContextProvider=t=>{let{children:e,value:n}=t;return React__namespace.createElement(ChartContext.Provider,{value:n},e)},ChartView=t=>{const{google:e,isLoading:n,error:o}=useLoadGoogleCharts(t);return n?t.loader??null:o?t.errorElement??null:e?React.createElement(GoogleChart,{google:e,...t}):null},Chart=t=>{const e={...chartDefaultProps,...t};return React.createElement(ContextProvider,{value:e},React.createElement(ChartView,e))};var GoogleDataTableColumnRoleType;(function(t){t.annotation="annotation",t.annotationText="annotationText",t.certainty="certainty",t.emphasis="emphasis",t.interval="interval",t.scope="scope",t.style="style",t.tooltip="tooltip",t.domain="domain"})(GoogleDataTableColumnRoleType||(GoogleDataTableColumnRoleType={}));function parseHsl(t){const e=t.match(/(\d+\.?\d*)\s*(\d+\.?\d*)%\s*(\d+\.?\d*)%/);return e?{h:parseFloat(e[1]),s:parseFloat(e[2]),l:parseFloat(e[3])}:null}function hslToHex(t,e,n){n/=100;const o=e*Math.min(n,1-n)/100,l=d=>{const f=(d+t/30)%12,g=n-o*Math.max(Math.min(f-3,9-f,1),-1);return Math.round(255*g).toString(16).padStart(2,"0")};return`#${l(0)}${l(8)}${l(4)}`}const Treemap=React__namespace.forwardRef(({data:t,options:e,height:n="500px",className:o,loading:l,...d},f)=>{const g=React__namespace.useRef(null),[b,_]=React__namespace.useState(null);React__namespace.useEffect(()=>{if(!g.current)return;const R=getComputedStyle(g.current).getPropertyValue("--primary"),C=parseHsl(R.trim());if(C){const{h:E,s:A,l:I}=C;_({minColor:hslToHex(E,A,Math.min(100,I+50)),midColor:hslToHex(E,A,Math.min(100,I+35)),maxColor:hslToHex(E,A,Math.min(100,I+20))})}},[]);const S=React__namespace.useMemo(()=>{const R={headerHeight:0,fontSize:14,showScale:!1,isHtml:!0,generateTooltip:(C,E)=>{var M;const A=(M=t[C+1])==null?void 0:M[0];if(!A)return"";const I=formatMoney(E);return`<div class="p-2 bg-background text-foreground border rounded-md shadow-lg">
1318
1318
  <strong>${A}</strong><br>Value: ${I}
1319
1319
  </div>`}};return b&&(!e||!e.colorAxis)&&(R.minColor=b.minColor,R.midColor=b.midColor,R.maxColor=b.maxColor),{...R,...e}},[t,e,b]);return React__namespace.useImperativeHandle(f,()=>g.current,[]),l?jsxRuntime.jsx("div",{ref:g,className:cn("w-full",o),style:{height:n},...d,children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full"})}):!t||t.length<=2?jsxRuntime.jsx("div",{ref:g,className:cn("w-full flex items-center justify-center text-muted-foreground",o),style:{height:n},...d,children:"No data available"}):jsxRuntime.jsx("div",{ref:g,className:cn("w-full",o),style:{height:n},...d,children:jsxRuntime.jsx(Chart,{chartType:"TreeMap",width:"100%",height:"100%",data:t,options:S,loader:jsxRuntime.jsx(Skeleton,{className:"h-full w-full"})})})});Treemap.displayName="Treemap";const TopPercentTreemap=({data:t,topPercent:e=80,title:n,loading:o,...l})=>{const d=React__namespace.useMemo(()=>{if(!t||t.length===0)return[["ID","Parent","Value"],["Root",null,0]];const g=[...t].sort((A,I)=>I.value-A.value),_=g.reduce((A,I)=>A+I.value,0)*(e/100),S=[["ID","Parent","Value"],["Root",null,0]],R=[],C=[];let E=0;for(const A of g)E<_?(R.push(A),E+=A.value):C.push(A);if(R.forEach(A=>{S.push([A.name,"Root",A.value])}),C.length>0){const A=`More... (${C.length} items)`;S.push([A,"Root",0]),C.forEach(I=>{S.push([I.name,A,I.value])})}return S},[t,e]),f=React__namespace.useMemo(()=>({title:n,maxDepth:1}),[n]);return jsxRuntime.jsx(Treemap,{data:d,options:f,className:cn("h-full",l.className),loading:o,...l})};exports.ActiveOrdersCard=ActiveOrdersCard,exports.AiGeneratedContent=AiGeneratedContent,exports.Alert=Alert,exports.AlertDescription=AlertDescription,exports.AlertDialog=AlertDialog,exports.AlertDialogAction=AlertDialogAction,exports.AlertDialogCancel=AlertDialogCancel,exports.AlertDialogContent=AlertDialogContent,exports.AlertDialogDescription=AlertDialogDescription,exports.AlertDialogFooter=AlertDialogFooter,exports.AlertDialogHeader=AlertDialogHeader,exports.AlertDialogTitle=AlertDialogTitle,exports.AlertDialogTrigger=AlertDialogTrigger,exports.AlertTitle=AlertTitle,exports.AreaChart=AreaChart,exports.AssistantChat=AssistantChat,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.ChatProvider=ChatProvider,exports.Checkbox=Checkbox,exports.Command=Command,exports.CommandDialog=CommandDialog,exports.CommandEmpty=CommandEmpty,exports.CommandGroup=CommandGroup,exports.CommandInput=CommandInput,exports.CommandItem=CommandItem,exports.CommandList=CommandList,exports.CommandSeparator=CommandSeparator,exports.CommandShortcut=CommandShortcut,exports.CountryFlag=CountryFlag,exports.DataTable=DataTable,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.ExploreManufacturers=ExploreManufacturers,exports.GeminiApiKeyProvider=GeminiApiKeyProvider,exports.GeneralDocumentCard=GeneralDocumentCard,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$2,exports.Layout=Layout,exports.ManufacturerCard=ManufacturerCard,exports.ManufacturerGetStartedButton=ManufacturerGetStartedButton,exports.ManufacturerOverviewPage=ManufacturerOverviewPage,exports.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.MultiSelect=MultiSelect,exports.Navbar=Navbar,exports.OpportunitiesTable=OpportunitiesTable,exports.PageHeader=PageHeader,exports.PartnerCard=PartnerCard,exports.PartnerRelationshipPage=PartnerRelationshipPage,exports.Popover=Popover,exports.PopoverAnchor=PopoverAnchor,exports.PopoverContent=PopoverContent,exports.PopoverTrigger=PopoverTrigger,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ProductOverviewPage=ProductOverviewPage,exports.Progress=Progress,exports.RadioGroup=RadioGroup$1,exports.RadioGroupItem=RadioGroupItem,exports.ResellerBillingOverviewCard=ResellerBillingOverviewCard,exports.ResellerCard=ResellerCard,exports.ResellerOverview=ResellerOverview,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.ReturnsTable=ReturnsTable,exports.RichTextEditor=RichTextEditor,exports.SalesChart=SalesChart,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,exports.SelectContent=SelectContent,exports.SelectGroup=SelectGroup,exports.SelectItem=SelectItem,exports.SelectLabel=SelectLabel,exports.SelectScrollDownButton=SelectScrollDownButton,exports.SelectScrollUpButton=SelectScrollUpButton,exports.SelectTrigger=SelectTrigger,exports.SelectValue=SelectValue,exports.Separator=Separator$1,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Switch=Switch,exports.Table=Table,exports.TableBody=TableBody,exports.TableCaption=TableCaption,exports.TableCell=TableCell,exports.TableFooter=TableFooter,exports.TableHead=TableHead,exports.TableHeader=TableHeader,exports.TableRow=TableRow,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Textarea=Textarea,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.TopPercentTreemap=TopPercentTreemap,exports.Topbar=Topbar,exports.Treemap=Treemap,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.toast=toast,exports.useChat=useChat,exports.useGeminiApiKey=useGeminiApiKey,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.299.0",
4
+ "version": "1.301.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [