randmarcomps 1.418.0 → 1.419.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.
@@ -95260,1996 +95260,906 @@ function ProductOverviewPage({
95260
95260
  ] }) })
95261
95261
  ] });
95262
95262
  }
95263
- function AssistantInsight({
95264
- prompt: t,
95265
- smartAndSlow: e = !1,
95266
- thinkingPlaceholderText: n = "Thinking...",
95267
- withCard: o = !0
95268
- }) {
95269
- const {
95270
- response: l,
95271
- isLoading: d,
95272
- error: f,
95273
- sendPrompt: g
95274
- } = useGemini({
95275
- useProModel: e,
95276
- outputFormat: "html"
95277
- });
95278
- return useEffect(() => {
95279
- t && g(t);
95280
- }, [t, g]), /* @__PURE__ */ jsxs("div", { className: `flex items-start gap-4 ${o ? "p-4 border rounded-lg bg-background" : ""}`, children: [
95281
- /* @__PURE__ */ jsx(
95282
- Bot,
95263
+ const colClasses = {
95264
+ base: { 1: "grid-cols-1", 2: "grid-cols-2", 3: "grid-cols-3", 4: "grid-cols-4", 5: "grid-cols-5", 6: "grid-cols-6" },
95265
+ sm: { 1: "sm:grid-cols-1", 2: "sm:grid-cols-2", 3: "sm:grid-cols-3", 4: "sm:grid-cols-4", 5: "sm:grid-cols-5", 6: "sm:grid-cols-6" },
95266
+ md: { 1: "md:grid-cols-1", 2: "md:grid-cols-2", 3: "md:grid-cols-3", 4: "md:grid-cols-4", 5: "md:grid-cols-5", 6: "md:grid-cols-6" },
95267
+ lg: { 1: "lg:grid-cols-1", 2: "lg:grid-cols-2", 3: "lg:grid-cols-3", 4: "lg:grid-cols-4", 5: "lg:grid-cols-5", 6: "lg:grid-cols-6" },
95268
+ xl: { 1: "xl:grid-cols-1", 2: "xl:grid-cols-2", 3: "xl:grid-cols-3", 4: "xl:grid-cols-4", 5: "xl:grid-cols-5", 6: "xl:grid-cols-6" }
95269
+ }, buildGridClassName = (t) => {
95270
+ const e = { base: 1, md: 2, ...t };
95271
+ return [
95272
+ "grid",
95273
+ "gap-4",
95274
+ e.base ? colClasses.base[e.base] : "",
95275
+ e.sm ? colClasses.sm[e.sm] : "",
95276
+ e.md ? colClasses.md[e.md] : "",
95277
+ e.lg ? colClasses.lg[e.lg] : "",
95278
+ e.xl ? colClasses.xl[e.xl] : ""
95279
+ ].filter(Boolean).join(" ");
95280
+ }, SearchPageGrid = ({
95281
+ results: t,
95282
+ groupBy: e,
95283
+ renderItem: n
95284
+ }) => {
95285
+ const o = e(t);
95286
+ return /* @__PURE__ */ jsx(Fragment$1, { children: Object.entries(o).map(([l, d]) => {
95287
+ const { items: f, gridCols: g } = d;
95288
+ if (f.length === 0)
95289
+ return null;
95290
+ const b = buildGridClassName(g);
95291
+ return /* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
95292
+ /* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold tracking-tight mb-4", children: l }),
95293
+ /* @__PURE__ */ jsx("div", { className: b, children: f.map((S, _) => n(S, _)) })
95294
+ ] }, l);
95295
+ }) });
95296
+ }, SearchPage = ({
95297
+ query: t,
95298
+ results: e,
95299
+ isLoading: n,
95300
+ children: o
95301
+ }) => n ? /* @__PURE__ */ jsx("div", { className: "flex w-full justify-center items-center py-24", children: /* @__PURE__ */ jsx(LoaderCircle, { className: "h-8 w-8 animate-spin text-muted-foreground" }) }) : t && e.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex w-full justify-center items-start pt-16", children: /* @__PURE__ */ jsx(Card, { className: "w-full max-w-lg", children: /* @__PURE__ */ jsxs(CardHeader, { className: "text-center items-center", children: [
95302
+ /* @__PURE__ */ jsx("div", { className: "rounded-full border bg-muted p-3 mb-4", children: /* @__PURE__ */ jsx(SearchX, { className: "h-8 w-8 text-muted-foreground" }) }),
95303
+ /* @__PURE__ */ jsx(CardTitle, { children: "No Results Found" }),
95304
+ /* @__PURE__ */ jsxs(CardDescription, { children: [
95305
+ 'Your search for "',
95306
+ t,
95307
+ '" did not return any results. Please try a different search term.'
95308
+ ] })
95309
+ ] }) }) }) : e.length > 0 ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-8", children: /* @__PURE__ */ jsx("div", { className: "col-span-3", children: o }) }) : null;
95310
+ var COLLAPSIBLE_NAME = "Collapsible", [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME), [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME), Collapsible = React.forwardRef(
95311
+ (t, e) => {
95312
+ const {
95313
+ __scopeCollapsible: n,
95314
+ open: o,
95315
+ defaultOpen: l,
95316
+ disabled: d,
95317
+ onOpenChange: f,
95318
+ ...g
95319
+ } = t, [b, S] = useControllableState({
95320
+ prop: o,
95321
+ defaultProp: l ?? !1,
95322
+ onChange: f,
95323
+ caller: COLLAPSIBLE_NAME
95324
+ });
95325
+ return /* @__PURE__ */ jsx(
95326
+ CollapsibleProvider,
95283
95327
  {
95284
- className: `mt-1 h-6 w-6 flex-shrink-0 ${d ? "animate-pulse text-primary" : "text-primary"}`
95328
+ scope: n,
95329
+ disabled: d,
95330
+ contentId: useId(),
95331
+ open: b,
95332
+ onOpenToggle: React.useCallback(() => S((_) => !_), [S]),
95333
+ children: /* @__PURE__ */ jsx(
95334
+ Primitive.div,
95335
+ {
95336
+ "data-state": getState$1(b),
95337
+ "data-disabled": d ? "" : void 0,
95338
+ ...g,
95339
+ ref: e
95340
+ }
95341
+ )
95285
95342
  }
95286
- ),
95287
- /* @__PURE__ */ jsxs("div", { className: "w-full min-h-[4rem]", children: [
95288
- d && /* @__PURE__ */ jsxs(Fragment$1, { children: [
95289
- /* @__PURE__ */ jsx("p", { className: "font-medium text-muted-foreground", children: n }),
95290
- /* @__PURE__ */ jsxs("div", { className: "space-y-2 mt-2", children: [
95291
- /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-5/6" }),
95292
- /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-3/4" })
95293
- ] })
95294
- ] }),
95295
- f && /* @__PURE__ */ jsx("p", { className: "text-sm text-red-600", children: f }),
95296
- !d && !f && l && // Renders the cleaned HTML response from the AI.
95297
- /* @__PURE__ */ jsx(
95298
- "div",
95299
- {
95300
- className: "chat-bubble-in-animation text-sm text-foreground space-y-4",
95301
- dangerouslySetInnerHTML: { __html: l }
95302
- }
95303
- )
95304
- ] })
95305
- ] });
95306
- }
95307
- function AssistantChat(t) {
95308
- return /* @__PURE__ */ jsx(Card, { className: "max-w-6xl", children: /* @__PURE__ */ jsx(AIChatLayout, { className: "h-[40em]", userId: t.userId, userName: t.userName, initialPrompt: t.initialPrompt }) });
95309
- }
95310
- function ExternalProductCard({
95311
- product: t,
95312
- viewProductLink: e
95313
- }) {
95314
- return t ? /* @__PURE__ */ jsx(Card, { className: "@container border-dashed border-2 hover:shadow-md transition-shadow h-full", children: /* @__PURE__ */ jsxs(CardContent, { className: "p-6 flex flex-col h-full", children: [
95315
- /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-start mb-4 @[36rem]:hidden", children: [
95316
- /* @__PURE__ */ jsx("h3", { className: "font-semibold text-lg pr-4 text-center w-full", children: t.Title || t.RandmarTitle }),
95317
- /* @__PURE__ */ jsx("div", { className: "w-24 h-10 flex-shrink-0", children: /* @__PURE__ */ jsx(
95318
- PartnerLogo,
95319
- {
95320
- id: t.ManufacturerId,
95321
- name: t.ManufacturerName,
95322
- width: 96,
95323
- height: 40
95324
- }
95325
- ) })
95326
- ] }),
95327
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-x-6 gap-y-4 flex-grow @[36rem]:flex-row", children: [
95328
- /* @__PURE__ */ jsx("div", { className: "mx-auto flex-shrink-0 @[36rem]:mx-0 @[36rem]:w-48", children: /* @__PURE__ */ jsx(
95329
- ProductImage,
95330
- {
95331
- randmarSKU: t.RandmarSKU || "",
95332
- alt: t.RandmarTitle || ""
95333
- }
95334
- ) }),
95335
- /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col text-center @[36rem]:text-left", children: [
95336
- /* @__PURE__ */ jsxs("div", { className: "hidden @[36rem]:flex justify-between items-start mb-4", children: [
95337
- /* @__PURE__ */ jsx("h3", { className: "font-semibold text-lg pr-4", children: t.Title || t.RandmarTitle }),
95338
- /* @__PURE__ */ jsx("div", { className: "w-24 h-10 flex-shrink-0", children: /* @__PURE__ */ jsx(
95339
- PartnerLogo,
95340
- {
95341
- id: t.ManufacturerId,
95342
- name: t.ManufacturerName,
95343
- width: 96,
95344
- height: 40
95345
- }
95346
- ) })
95347
- ] }),
95348
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2 justify-center @[36rem]:hidden", children: [
95349
- /* @__PURE__ */ jsxs(
95350
- Badge,
95351
- {
95352
- variant: "outline",
95353
- className: "border-orange-300 bg-orange-50 text-orange-800",
95354
- children: [
95355
- /* @__PURE__ */ jsx(Telescope, { className: "mr-2 h-3 w-3" }),
95356
- /* @__PURE__ */ jsx("span", { children: "External Product" })
95357
- ]
95358
- }
95359
- ),
95360
- /* @__PURE__ */ jsxs(
95361
- Badge,
95362
- {
95363
- variant: "outline",
95364
- className: "border-randmar-red bg-red-50 text-randmar-red",
95365
- children: [
95366
- /* @__PURE__ */ jsx(Warehouse, { className: "mr-2 h-3 w-3" }),
95367
- /* @__PURE__ */ jsxs("span", { children: [
95368
- "Held by ",
95369
- /* @__PURE__ */ jsx("b", { children: "Randmar" })
95370
- ] })
95371
- ]
95372
- }
95373
- )
95374
- ] }),
95375
- /* @__PURE__ */ jsxs("div", { className: "hidden @[36rem]:grid grid-cols-2 gap-2", children: [
95376
- /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md bg-orange-50 px-4 py-2 text-orange-800 border-1 border-orange-800 text-sm", children: [
95377
- /* @__PURE__ */ jsx(Telescope, { className: "mr-2 h-5 w-5 flex-shrink-0" }),
95378
- /* @__PURE__ */ jsx("span", { children: "External Product" })
95379
- ] }),
95380
- /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md bg-red-50 px-4 py-2 text-randmar-red border-1 border-randmar-red text-sm", children: [
95381
- /* @__PURE__ */ jsx(Warehouse, { className: "mr-2 h-5 w-5 flex-shrink-0" }),
95382
- /* @__PURE__ */ jsxs("span", { children: [
95383
- "Held by ",
95384
- /* @__PURE__ */ jsx("b", { children: "Randmar" })
95385
- ] })
95386
- ] })
95387
- ] }),
95388
- e && /* @__PURE__ */ jsx("div", { className: "mt-auto pt-4 flex justify-center @[36rem]:justify-end", children: /* @__PURE__ */ jsx(Link, { to: e, children: /* @__PURE__ */ jsxs(Button$1, { variant: "secondary", className: "w-full @[36rem]:w-auto", children: [
95389
- /* @__PURE__ */ jsx(Eye, { className: "mr-2 h-4 w-4" }),
95390
- "View Product"
95391
- ] }) }) })
95392
- ] })
95393
- ] })
95394
- ] }) }) : /* @__PURE__ */ jsx(Card, { className: "@container border-dashed border-2 h-full", children: /* @__PURE__ */ jsx(CardContent, { className: "p-6 flex flex-col h-full", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6 flex-grow @[36rem]:flex-row", children: [
95395
- /* @__PURE__ */ jsx("div", { className: "flex-shrink-0 @[36rem]:w-48", children: /* @__PURE__ */ jsx(Skeleton, { className: "aspect-square w-full h-auto" }) }),
95396
- /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col gap-4", children: [
95397
- /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-start", children: [
95398
- /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-1/2" }),
95399
- /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-24 rounded" })
95400
- ] }),
95401
- /* @__PURE__ */ jsxs("div", { children: [
95402
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2 justify-center @[36rem]:hidden", children: [
95403
- /* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-36 rounded-full" }),
95404
- /* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-36 rounded-full" })
95405
- ] }),
95406
- /* @__PURE__ */ jsxs("div", { className: "hidden @[36rem]:grid grid-cols-2 gap-2", children: [
95407
- /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full rounded-md" }),
95408
- /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full rounded-md" })
95409
- ] })
95410
- ] }),
95411
- /* @__PURE__ */ jsx("div", { className: "mt-auto pt-4 flex justify-center @[36rem]:justify-end", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full @[36rem]:w-40" }) })
95412
- ] })
95413
- ] }) }) });
95414
- }
95415
- function getEndDateStatus(t) {
95416
- if (!t) return { text: "No End Date", variant: "neutral", daysRemaining: null };
95417
- const e = new Date(t);
95418
- if (isNaN(e.getTime()))
95419
- return { text: "Invalid Date", variant: "neutral", daysRemaining: null };
95420
- const n = /* @__PURE__ */ 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));
95421
- 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 };
95422
- }
95423
- const formatDate = (t) => {
95424
- if (!t) return "N/A";
95425
- try {
95426
- const e = new Date(t);
95427
- return isNaN(e.getTime()) ? "Invalid Date" : e.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
95428
- } catch {
95429
- return "Invalid Date";
95343
+ );
95430
95344
  }
95431
- };
95432
- function OpportunitiesTable({
95433
- applicationId: t,
95434
- opportunities: e = null,
95435
- loading: n = !1
95436
- }) {
95437
- var te;
95438
- const { toast: o } = useToast(), [l, d] = useState({}), [f, g] = useState(!1), [b, S] = useState(""), [_, C] = useState(null), {
95439
- data: E
95440
- } = useGetV4PartnerByApplicationIdAccountQuery({
95441
- applicationId: t
95442
- }, {
95443
- skip: !t
95444
- }), R = useCallback((ne, ae, $e) => {
95445
- d((Ne) => ({
95446
- ...Ne,
95447
- [ne]: {
95448
- ...Ne[ne],
95449
- [ae]: $e
95345
+ );
95346
+ Collapsible.displayName = COLLAPSIBLE_NAME;
95347
+ var TRIGGER_NAME$1 = "CollapsibleTrigger", CollapsibleTrigger = React.forwardRef(
95348
+ (t, e) => {
95349
+ const { __scopeCollapsible: n, ...o } = t, l = useCollapsibleContext(TRIGGER_NAME$1, n);
95350
+ return /* @__PURE__ */ jsx(
95351
+ Primitive.button,
95352
+ {
95353
+ type: "button",
95354
+ "aria-controls": l.contentId,
95355
+ "aria-expanded": l.open || !1,
95356
+ "data-state": getState$1(l.open),
95357
+ "data-disabled": l.disabled ? "" : void 0,
95358
+ disabled: l.disabled,
95359
+ ...o,
95360
+ ref: e,
95361
+ onClick: composeEventHandlers(t.onClick, l.onOpenToggle)
95450
95362
  }
95451
- }));
95452
- }, []), [A] = usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(), I = useCallback(async (ne) => {
95453
- if (!(E != null && E.IsReseller)) return;
95454
- if (!ne.BidNumber) {
95455
- o({ title: "Error", description: "Bid Number is missing, cannot set default.", variant: "destructive" });
95456
- return;
95363
+ );
95364
+ }
95365
+ );
95366
+ CollapsibleTrigger.displayName = TRIGGER_NAME$1;
95367
+ var CONTENT_NAME$1 = "CollapsibleContent", CollapsibleContent = React.forwardRef(
95368
+ (t, e) => {
95369
+ const { forceMount: n, ...o } = t, l = useCollapsibleContext(CONTENT_NAME$1, t.__scopeCollapsible);
95370
+ return /* @__PURE__ */ jsx(Presence, { present: n || l.open, children: ({ present: d }) => /* @__PURE__ */ jsx(CollapsibleContentImpl, { ...o, ref: e, present: d }) });
95371
+ }
95372
+ );
95373
+ CollapsibleContent.displayName = CONTENT_NAME$1;
95374
+ var CollapsibleContentImpl = React.forwardRef((t, e) => {
95375
+ const { __scopeCollapsible: n, present: o, children: l, ...d } = t, f = useCollapsibleContext(CONTENT_NAME$1, n), [g, b] = React.useState(o), S = React.useRef(null), _ = useComposedRefs(e, S), C = React.useRef(0), E = C.current, R = React.useRef(0), A = R.current, I = f.open || g, M = React.useRef(I), V = React.useRef(void 0);
95376
+ return React.useEffect(() => {
95377
+ const j = requestAnimationFrame(() => M.current = !1);
95378
+ return () => cancelAnimationFrame(j);
95379
+ }, []), useLayoutEffect2(() => {
95380
+ const j = S.current;
95381
+ if (j) {
95382
+ V.current = V.current || {
95383
+ transitionDuration: j.style.transitionDuration,
95384
+ animationName: j.style.animationName
95385
+ }, j.style.transitionDuration = "0s", j.style.animationName = "none";
95386
+ const z = j.getBoundingClientRect();
95387
+ C.current = z.height, R.current = z.width, M.current || (j.style.transitionDuration = V.current.transitionDuration, j.style.animationName = V.current.animationName), b(o);
95457
95388
  }
95458
- const ae = ne.BidNumber;
95459
- R(ae, "isSettingDefault", !0), A({
95460
- routeResellerId: t,
95461
- manufacturerId: ne.ManufacturerId ?? "",
95462
- opportunityNumber: ae
95463
- }).unwrap().then(() => {
95464
- o({
95465
- title: "Success",
95466
- description: `Opportunity "${ne.OpportunityName || ne.Opportunity || ae}" was successfully set as default.`,
95467
- variant: "success"
95468
- });
95469
- }).catch(($e) => {
95470
- var Ne;
95471
- console.error("Set as default error:", $e), o({
95472
- title: "Error",
95473
- description: ((Ne = $e.data) == null ? void 0 : Ne.message) || $e.message || "An error occurred while setting this opportunity as default.",
95474
- variant: "destructive"
95475
- });
95476
- }).finally(() => {
95477
- R(ae, "isSettingDefault", !1);
95389
+ }, [f.open, o]), /* @__PURE__ */ jsx(
95390
+ Primitive.div,
95391
+ {
95392
+ "data-state": getState$1(f.open),
95393
+ "data-disabled": f.disabled ? "" : void 0,
95394
+ id: f.contentId,
95395
+ hidden: !I,
95396
+ ...d,
95397
+ ref: _,
95398
+ style: {
95399
+ "--radix-collapsible-content-height": E ? `${E}px` : void 0,
95400
+ "--radix-collapsible-content-width": A ? `${A}px` : void 0,
95401
+ ...t.style
95402
+ },
95403
+ children: I && l
95404
+ }
95405
+ );
95406
+ });
95407
+ function getState$1(t) {
95408
+ return t ? "open" : "closed";
95409
+ }
95410
+ var Root$1 = Collapsible, Trigger = CollapsibleTrigger, Content = CollapsibleContent, ACCORDION_NAME = "Accordion", ACCORDION_KEYS = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"], [Collection, useCollection, createCollectionScope] = createCollection(ACCORDION_NAME), [createAccordionContext] = createContextScope(ACCORDION_NAME, [
95411
+ createCollectionScope,
95412
+ createCollapsibleScope
95413
+ ]), useCollapsibleScope = createCollapsibleScope(), Accordion$1 = React__default.forwardRef(
95414
+ (t, e) => {
95415
+ const { type: n, ...o } = t, l = o, d = o;
95416
+ return /* @__PURE__ */ jsx(Collection.Provider, { scope: t.__scopeAccordion, children: n === "multiple" ? /* @__PURE__ */ jsx(AccordionImplMultiple, { ...d, ref: e }) : /* @__PURE__ */ jsx(AccordionImplSingle, { ...l, ref: e }) });
95417
+ }
95418
+ );
95419
+ Accordion$1.displayName = ACCORDION_NAME;
95420
+ var [AccordionValueProvider, useAccordionValueContext] = createAccordionContext(ACCORDION_NAME), [AccordionCollapsibleProvider, useAccordionCollapsibleContext] = createAccordionContext(
95421
+ ACCORDION_NAME,
95422
+ { collapsible: !1 }
95423
+ ), AccordionImplSingle = React__default.forwardRef(
95424
+ (t, e) => {
95425
+ const {
95426
+ value: n,
95427
+ defaultValue: o,
95428
+ onValueChange: l = () => {
95429
+ },
95430
+ collapsible: d = !1,
95431
+ ...f
95432
+ } = t, [g, b] = useControllableState({
95433
+ prop: n,
95434
+ defaultProp: o ?? "",
95435
+ onChange: l,
95436
+ caller: ACCORDION_NAME
95478
95437
  });
95479
- }, [t, A, o, R, E == null ? void 0 : E.IsReseller]), [M] = usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(), V = useCallback((ne) => {
95480
- if (E != null && E.IsReseller) {
95481
- if (!ne.BidNumber) {
95482
- o({ title: "Error", description: "Bid Number is missing, cannot prepare report.", variant: "destructive" });
95483
- return;
95438
+ return /* @__PURE__ */ jsx(
95439
+ AccordionValueProvider,
95440
+ {
95441
+ scope: t.__scopeAccordion,
95442
+ value: React__default.useMemo(() => g ? [g] : [], [g]),
95443
+ onItemOpen: b,
95444
+ onItemClose: React__default.useCallback(() => d && b(""), [d, b]),
95445
+ children: /* @__PURE__ */ jsx(AccordionCollapsibleProvider, { scope: t.__scopeAccordion, collapsible: d, children: /* @__PURE__ */ jsx(AccordionImpl, { ...f, ref: e }) })
95484
95446
  }
95485
- C(ne), S(""), g(!0);
95486
- }
95487
- }, [o, E == null ? void 0 : E.IsReseller]), j = useCallback(async () => {
95488
- if (!(E != null && E.IsReseller)) return;
95489
- if (!_ || !_.BidNumber) {
95490
- o({ title: "Error", description: "No opportunity selected or Bid Number is missing.", variant: "destructive" });
95491
- return;
95492
- }
95493
- if (!b.trim() || !/\S+@\S+\.\S+/.test(b)) {
95494
- o({ title: "Validation Error", description: "Please enter a valid email address.", variant: "destructive" });
95495
- return;
95447
+ );
95448
+ }
95449
+ ), AccordionImplMultiple = React__default.forwardRef((t, e) => {
95450
+ const {
95451
+ value: n,
95452
+ defaultValue: o,
95453
+ onValueChange: l = () => {
95454
+ },
95455
+ ...d
95456
+ } = t, [f, g] = useControllableState({
95457
+ prop: n,
95458
+ defaultProp: o ?? [],
95459
+ onChange: l,
95460
+ caller: ACCORDION_NAME
95461
+ }), b = React__default.useCallback(
95462
+ (_) => g((C = []) => [...C, _]),
95463
+ [g]
95464
+ ), S = React__default.useCallback(
95465
+ (_) => g((C = []) => C.filter((E) => E !== _)),
95466
+ [g]
95467
+ );
95468
+ return /* @__PURE__ */ jsx(
95469
+ AccordionValueProvider,
95470
+ {
95471
+ scope: t.__scopeAccordion,
95472
+ value: f,
95473
+ onItemOpen: b,
95474
+ onItemClose: S,
95475
+ children: /* @__PURE__ */ jsx(AccordionCollapsibleProvider, { scope: t.__scopeAccordion, collapsible: !0, children: /* @__PURE__ */ jsx(AccordionImpl, { ...d, ref: e }) })
95496
95476
  }
95497
- const ne = _.BidNumber;
95498
- R(ne, "isSendingReport", !0), M({
95499
- routeResellerId: t,
95500
- manufacturerId: _.ManufacturerId ?? "",
95501
- bidNumber: ne,
95502
- emailAddress: b
95503
- }).unwrap().then(() => {
95504
- o({
95505
- title: "Success",
95506
- description: `A report for "${_.OpportunityName || _.Opportunity || ne}" was successfully sent to ${b}.`,
95507
- variant: "success"
95508
- }), g(!1);
95509
- }).catch((ae) => {
95510
- var $e;
95511
- console.error("Send report by email error:", ae), o({
95512
- title: "Error",
95513
- description: (($e = ae.data) == null ? void 0 : $e.message) || ae.message || "An error occurred while sending the report by email.",
95514
- variant: "destructive"
95515
- });
95516
- }).finally(() => {
95517
- R(ne, "isSendingReport", !1), f || (C(null), S(""));
95477
+ );
95478
+ }), [AccordionImplProvider, useAccordionContext] = createAccordionContext(ACCORDION_NAME), AccordionImpl = React__default.forwardRef(
95479
+ (t, e) => {
95480
+ const { __scopeAccordion: n, disabled: o, dir: l, orientation: d = "vertical", ...f } = t, g = React__default.useRef(null), b = useComposedRefs(g, e), S = useCollection(n), C = useDirection(l) === "ltr", E = composeEventHandlers(t.onKeyDown, (R) => {
95481
+ var ne;
95482
+ if (!ACCORDION_KEYS.includes(R.key)) return;
95483
+ const A = R.target, I = S().filter((ae) => {
95484
+ var $e;
95485
+ return !(($e = ae.ref.current) != null && $e.disabled);
95486
+ }), M = I.findIndex((ae) => ae.ref.current === A), V = I.length;
95487
+ if (M === -1) return;
95488
+ R.preventDefault();
95489
+ let j = M;
95490
+ const z = 0, Q = V - 1, O = () => {
95491
+ j = M + 1, j > Q && (j = z);
95492
+ }, F = () => {
95493
+ j = M - 1, j < z && (j = Q);
95494
+ };
95495
+ switch (R.key) {
95496
+ case "Home":
95497
+ j = z;
95498
+ break;
95499
+ case "End":
95500
+ j = Q;
95501
+ break;
95502
+ case "ArrowRight":
95503
+ d === "horizontal" && (C ? O() : F());
95504
+ break;
95505
+ case "ArrowDown":
95506
+ d === "vertical" && O();
95507
+ break;
95508
+ case "ArrowLeft":
95509
+ d === "horizontal" && (C ? F() : O());
95510
+ break;
95511
+ case "ArrowUp":
95512
+ d === "vertical" && F();
95513
+ break;
95514
+ }
95515
+ const te = j % V;
95516
+ (ne = I[te].ref.current) == null || ne.focus();
95518
95517
  });
95519
- }, [_, b, t, M, o, R, g]), z = useMemo(
95520
- () => [
95518
+ return /* @__PURE__ */ jsx(
95519
+ AccordionImplProvider,
95521
95520
  {
95522
- accessorKey: "ManufacturerId",
95523
- header: "Manuf.",
95524
- cell: ({ row: ne }) => /* @__PURE__ */ jsx("div", { className: "w-20 h-8", children: /* @__PURE__ */ jsx(
95525
- PartnerLogo,
95521
+ scope: n,
95522
+ disabled: o,
95523
+ direction: l,
95524
+ orientation: d,
95525
+ children: /* @__PURE__ */ jsx(Collection.Slot, { scope: n, children: /* @__PURE__ */ jsx(
95526
+ Primitive.div,
95526
95527
  {
95527
- id: ne.original.ManufacturerId,
95528
- width: 80,
95529
- height: 32
95528
+ ...f,
95529
+ "data-orientation": d,
95530
+ ref: b,
95531
+ onKeyDown: o ? void 0 : E
95530
95532
  }
95531
- ) }),
95532
- enableSorting: !0,
95533
- enableFiltering: !0
95534
- },
95533
+ ) })
95534
+ }
95535
+ );
95536
+ }
95537
+ ), ITEM_NAME = "AccordionItem", [AccordionItemProvider, useAccordionItemContext] = createAccordionContext(ITEM_NAME), AccordionItem$1 = React__default.forwardRef(
95538
+ (t, e) => {
95539
+ const { __scopeAccordion: n, value: o, ...l } = t, d = useAccordionContext(ITEM_NAME, n), f = useAccordionValueContext(ITEM_NAME, n), g = useCollapsibleScope(n), b = useId(), S = o && f.value.includes(o) || !1, _ = d.disabled || t.disabled;
95540
+ return /* @__PURE__ */ jsx(
95541
+ AccordionItemProvider,
95535
95542
  {
95536
- id: "opportunityDisplay",
95537
- accessorFn: (ne) => ne.OpportunityName || ne.Opportunity,
95538
- header: "Opportunity",
95539
- cell: ({ getValue: ne }) => /* @__PURE__ */ jsx("div", { className: "min-w-[150px]", children: ne() ?? "N/A" }),
95540
- enableSorting: !0,
95541
- enableFiltering: !0
95542
- },
95543
+ scope: n,
95544
+ open: S,
95545
+ disabled: _,
95546
+ triggerId: b,
95547
+ children: /* @__PURE__ */ jsx(
95548
+ Root$1,
95549
+ {
95550
+ "data-orientation": d.orientation,
95551
+ "data-state": getState(S),
95552
+ ...g,
95553
+ ...l,
95554
+ ref: e,
95555
+ disabled: _,
95556
+ open: S,
95557
+ onOpenChange: (C) => {
95558
+ C ? f.onItemOpen(o) : f.onItemClose(o);
95559
+ }
95560
+ }
95561
+ )
95562
+ }
95563
+ );
95564
+ }
95565
+ );
95566
+ AccordionItem$1.displayName = ITEM_NAME;
95567
+ var HEADER_NAME = "AccordionHeader", AccordionHeader = React__default.forwardRef(
95568
+ (t, e) => {
95569
+ const { __scopeAccordion: n, ...o } = t, l = useAccordionContext(ACCORDION_NAME, n), d = useAccordionItemContext(HEADER_NAME, n);
95570
+ return /* @__PURE__ */ jsx(
95571
+ Primitive.h3,
95543
95572
  {
95544
- accessorKey: "BidNumber",
95545
- header: "Bid Number",
95546
- cell: ({ row: ne }) => ne.original.BidNumber ?? "N/A",
95547
- enableSorting: !0,
95548
- enableFiltering: !0
95549
- },
95573
+ "data-orientation": l.orientation,
95574
+ "data-state": getState(d.open),
95575
+ "data-disabled": d.disabled ? "" : void 0,
95576
+ ...o,
95577
+ ref: e
95578
+ }
95579
+ );
95580
+ }
95581
+ );
95582
+ AccordionHeader.displayName = HEADER_NAME;
95583
+ var TRIGGER_NAME = "AccordionTrigger", AccordionTrigger$1 = React__default.forwardRef(
95584
+ (t, e) => {
95585
+ const { __scopeAccordion: n, ...o } = t, l = useAccordionContext(ACCORDION_NAME, n), d = useAccordionItemContext(TRIGGER_NAME, n), f = useAccordionCollapsibleContext(TRIGGER_NAME, n), g = useCollapsibleScope(n);
95586
+ return /* @__PURE__ */ jsx(Collection.ItemSlot, { scope: n, children: /* @__PURE__ */ jsx(
95587
+ Trigger,
95550
95588
  {
95551
- id: "statusInfo",
95552
- header: "Status",
95553
- cell: ({ row: ne }) => {
95554
- const ae = ne.original, $e = ae.Active === !0, Ne = getEndDateStatus(ae.EndDate);
95555
- let oe = "border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";
95556
- return Ne.variant === "destructive" ? oe = "border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400" : Ne.variant === "warning" && (oe = "border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"), /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2 min-w-[200px]", children: [
95557
- /* @__PURE__ */ jsx(Badge, { variant: "outline", className: $e ? "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: $e ? "Active" : "Inactive" }),
95558
- ae.EndDate && /* @__PURE__ */ jsx(Badge, { variant: "outline", className: `${oe} font-medium`, children: Ne.text }),
95559
- /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 100, children: /* @__PURE__ */ jsxs(Tooltip$1, { children: [
95560
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button$1, { variant: "ghost", size: "icon", className: "h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent", children: /* @__PURE__ */ jsx(Info, { className: "h-4 w-4 text-muted-foreground" }) }) }),
95561
- /* @__PURE__ */ jsx(TooltipContent, { side: "top", align: "center", className: "bg-popover text-popover-foreground p-2 rounded shadow-lg", children: /* @__PURE__ */ jsxs("div", { className: "text-sm space-y-1", children: [
95562
- /* @__PURE__ */ jsxs("p", { children: [
95563
- /* @__PURE__ */ jsx("strong", { children: "Start:" }),
95564
- " ",
95565
- formatDate(ae.StartDate)
95566
- ] }),
95567
- /* @__PURE__ */ jsxs("p", { children: [
95568
- /* @__PURE__ */ jsx("strong", { children: "End:" }),
95569
- " ",
95570
- formatDate(ae.EndDate)
95571
- ] }),
95572
- /* @__PURE__ */ jsxs("p", { children: [
95573
- /* @__PURE__ */ jsx("strong", { children: "Updated:" }),
95574
- " ",
95575
- formatDate(ae.LastUpdate)
95576
- ] })
95577
- ] }) })
95578
- ] }) })
95579
- ] });
95580
- },
95581
- enableFiltering: !1
95582
- },
95589
+ "aria-disabled": d.open && !f.collapsible || void 0,
95590
+ "data-orientation": l.orientation,
95591
+ id: d.triggerId,
95592
+ ...g,
95593
+ ...o,
95594
+ ref: e
95595
+ }
95596
+ ) });
95597
+ }
95598
+ );
95599
+ AccordionTrigger$1.displayName = TRIGGER_NAME;
95600
+ var CONTENT_NAME = "AccordionContent", AccordionContent$1 = React__default.forwardRef(
95601
+ (t, e) => {
95602
+ const { __scopeAccordion: n, ...o } = t, l = useAccordionContext(ACCORDION_NAME, n), d = useAccordionItemContext(CONTENT_NAME, n), f = useCollapsibleScope(n);
95603
+ return /* @__PURE__ */ jsx(
95604
+ Content,
95583
95605
  {
95584
- id: "actions",
95585
- header: "Actions",
95586
- cell: ({ row: ne }) => {
95587
- var Oe, je;
95588
- const ae = ne.original;
95589
- if (!ae.BidNumber)
95590
- return /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Actions unavailable" });
95591
- const $e = ae.BidNumber, Ne = (Oe = l[$e]) == null ? void 0 : Oe.isSettingDefault, oe = (_ == null ? void 0 : _.BidNumber) === $e && ((je = l[$e]) == null ? void 0 : je.isSendingReport), Ae = Ne || oe, ge = ae.CanBeSetAsDefault === !0, Ve = E != null && E.IsManufacturer ? `/${t}/Opportunity/${ae.BidNumber}` : `/${t}/Opportunity/${ae.ManufacturerId}/${ae.BidNumber}`;
95592
- return /* @__PURE__ */ jsxs("div", { className: "flex space-x-2", children: [
95593
- /* @__PURE__ */ jsx(Link, { to: Ve, children: /* @__PURE__ */ jsxs(Button$1, { variant: "outline", size: "sm", className: "flex items-center", children: [
95594
- /* @__PURE__ */ jsx(Star, { className: "mr-2 h-4 w-4" }),
95595
- " View"
95596
- ] }) }),
95597
- (E == null ? void 0 : E.IsReseller) && /* @__PURE__ */ jsxs(Fragment$1, { children: [
95598
- /* @__PURE__ */ jsxs(Button$1, { variant: "outline", size: "sm", onClick: () => I(ae), disabled: Ae || !ge, title: ge ? "Set as default" : "This opportunity cannot be set as default", className: "flex items-center", children: [
95599
- Ne ? /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Star, { className: "mr-2 h-4 w-4" }),
95600
- " Set Default"
95601
- ] }),
95602
- /* @__PURE__ */ jsxs(Button$1, { variant: "outline", size: "sm", onClick: () => V(ae), disabled: Ae, title: "Send report by email", className: "flex items-center", children: [
95603
- oe ? /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Send, { className: "mr-2 h-4 w-4" }),
95604
- " Send Report"
95605
- ] })
95606
- ] })
95607
- ] });
95606
+ role: "region",
95607
+ "aria-labelledby": d.triggerId,
95608
+ "data-orientation": l.orientation,
95609
+ ...f,
95610
+ ...o,
95611
+ ref: e,
95612
+ style: {
95613
+ "--radix-accordion-content-height": "var(--radix-collapsible-content-height)",
95614
+ "--radix-accordion-content-width": "var(--radix-collapsible-content-width)",
95615
+ ...t.style
95608
95616
  }
95609
95617
  }
95610
- ],
95611
- [
95612
- l,
95613
- I,
95614
- V,
95615
- _,
95616
- E == null ? void 0 : E.IsReseller,
95618
+ );
95619
+ }
95620
+ );
95621
+ AccordionContent$1.displayName = CONTENT_NAME;
95622
+ function getState(t) {
95623
+ return t ? "open" : "closed";
95624
+ }
95625
+ var Root2 = Accordion$1, Item = AccordionItem$1, Header = AccordionHeader, Trigger2 = AccordionTrigger$1, Content2 = AccordionContent$1;
95626
+ const Accordion = Root2, AccordionItem = React.forwardRef(({ className: t, ...e }, n) => /* @__PURE__ */ jsx(
95627
+ Item,
95628
+ {
95629
+ ref: n,
95630
+ className: cn("border-b", t),
95631
+ ...e
95632
+ }
95633
+ ));
95634
+ AccordionItem.displayName = "AccordionItem";
95635
+ const AccordionTrigger = React.forwardRef(({ className: t, children: e, ...n }, o) => /* @__PURE__ */ jsx(Header, { className: "flex", children: /* @__PURE__ */ jsxs(
95636
+ Trigger2,
95637
+ {
95638
+ ref: o,
95639
+ className: cn(
95640
+ "flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",
95617
95641
  t
95642
+ ),
95643
+ ...n,
95644
+ children: [
95645
+ e,
95646
+ /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" })
95618
95647
  ]
95619
- ), Q = useMemo(() => {
95620
- const ne = {};
95621
- if (e) {
95622
- const ae = Array.from(
95623
- new Set(e.map((Ne) => Ne.ManufacturerId).filter((Ne) => Ne != null))
95624
- );
95625
- ne.ManufacturerId = ae;
95626
- const $e = Array.from(
95627
- new Set(e.map((Ne) => Ne.OpportunityName || Ne.Opportunity).filter((Ne) => Ne != null))
95628
- );
95629
- ne.opportunityDisplay = $e;
95630
- }
95631
- return ne;
95632
- }, [e]), O = e || [], F = _ != null && _.BidNumber ? (te = l[_.BidNumber]) == null ? void 0 : te.isSendingReport : !1;
95633
- return n ? /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
95634
- /* @__PURE__ */ jsxs(CardHeader, { children: [
95635
- " ",
95636
- /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-48" }),
95637
- " "
95638
- ] }),
95639
- /* @__PURE__ */ jsxs(CardContent, { className: "space-y-4", children: [
95640
- /* @__PURE__ */ jsx(Skeleton, { className: "h-12 w-full rounded-md border" }),
95641
- /* @__PURE__ */ jsx(Skeleton, { className: "h-48 w-full rounded-md border" }),
95642
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pt-4", children: [
95643
- /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-[130px]" }),
95644
- /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
95645
- /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-20" }),
95646
- " ",
95647
- /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-24" }),
95648
- " ",
95649
- /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9" }),
95650
- " ",
95651
- /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9" })
95652
- ] })
95653
- ] })
95654
- ] })
95655
- ] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
95656
- /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
95657
- /* @__PURE__ */ jsxs(CardHeader, { children: [
95658
- " ",
95659
- /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: "Opportunities" }),
95660
- " "
95661
- ] }),
95662
- /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(DataTable, { columns: z, data: O, uniqueValues: Q }) })
95663
- ] }),
95664
- /* @__PURE__ */ jsx(Dialog, { open: f, onOpenChange: (ne) => {
95665
- g(ne), ne || (C(null), S(""));
95666
- }, children: /* @__PURE__ */ jsxs(DialogContent, { className: "@sm:max-w-[425px]", children: [
95667
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
95668
- /* @__PURE__ */ jsx(DialogTitle, { children: "Send Opportunity Report" }),
95669
- /* @__PURE__ */ jsxs(DialogDescription, { children: [
95670
- "Enter the email address to send the report for opportunity: ",
95671
- /* @__PURE__ */ jsx("br", {}),
95672
- /* @__PURE__ */ jsx("span", { className: "font-semibold", children: (_ == null ? void 0 : _.OpportunityName) || (_ == null ? void 0 : _.Opportunity) || "N/A" }),
95673
- (_ == null ? void 0 : _.BidNumber) && /* @__PURE__ */ jsxs("span", { className: "block text-sm text-muted-foreground", children: [
95674
- "Bid Number: ",
95675
- _.BidNumber
95676
- ] })
95677
- ] })
95678
- ] }),
95679
- /* @__PURE__ */ jsx("div", { className: "grid gap-4 py-4", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-4 items-center gap-4", children: [
95680
- /* @__PURE__ */ jsx(Label$2, { htmlFor: "email", className: "text-right", children: "Email" }),
95681
- /* @__PURE__ */ jsx(Input, { id: "email", type: "email", value: b, onChange: (ne) => S(ne.target.value), placeholder: "recipient@example.com", className: "col-span-3", disabled: F })
95682
- ] }) }),
95683
- /* @__PURE__ */ jsxs(DialogFooter, { children: [
95684
- /* @__PURE__ */ jsx(Button$1, { variant: "outline", onClick: () => g(!1), disabled: F, children: "Cancel" }),
95685
- /* @__PURE__ */ jsxs(Button$1, { type: "submit", onClick: j, disabled: F, children: [
95686
- F && /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }),
95687
- " Send Report"
95648
+ }
95649
+ ) }));
95650
+ AccordionTrigger.displayName = Trigger2.displayName;
95651
+ const AccordionContent = React.forwardRef(({ className: t, children: e, ...n }, o) => /* @__PURE__ */ jsx(
95652
+ Content2,
95653
+ {
95654
+ ref: o,
95655
+ className: "overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",
95656
+ ...n,
95657
+ children: /* @__PURE__ */ jsx("div", { className: cn("pb-4 pt-0", t), children: e })
95658
+ }
95659
+ ));
95660
+ AccordionContent.displayName = Content2.displayName;
95661
+ function AssistantInsight({
95662
+ prompt: t,
95663
+ smartAndSlow: e = !1,
95664
+ thinkingPlaceholderText: n = "Thinking...",
95665
+ withCard: o = !0
95666
+ }) {
95667
+ const {
95668
+ response: l,
95669
+ isLoading: d,
95670
+ error: f,
95671
+ sendPrompt: g
95672
+ } = useGemini({
95673
+ useProModel: e,
95674
+ outputFormat: "html"
95675
+ });
95676
+ return useEffect(() => {
95677
+ t && g(t);
95678
+ }, [t, g]), /* @__PURE__ */ jsxs("div", { className: `flex items-start gap-4 ${o ? "p-4 border rounded-lg bg-background" : ""}`, children: [
95679
+ /* @__PURE__ */ jsx(
95680
+ Bot,
95681
+ {
95682
+ className: `mt-1 h-6 w-6 flex-shrink-0 ${d ? "animate-pulse text-primary" : "text-primary"}`
95683
+ }
95684
+ ),
95685
+ /* @__PURE__ */ jsxs("div", { className: "w-full min-h-[4rem]", children: [
95686
+ d && /* @__PURE__ */ jsxs(Fragment$1, { children: [
95687
+ /* @__PURE__ */ jsx("p", { className: "font-medium text-muted-foreground", children: n }),
95688
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2 mt-2", children: [
95689
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-5/6" }),
95690
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-3/4" })
95688
95691
  ] })
95689
- ] })
95690
- ] }) })
95692
+ ] }),
95693
+ f && /* @__PURE__ */ jsx("p", { className: "text-sm text-red-600", children: f }),
95694
+ !d && !f && l && // Renders the cleaned HTML response from the AI.
95695
+ /* @__PURE__ */ jsx(
95696
+ "div",
95697
+ {
95698
+ className: "chat-bubble-in-animation text-sm text-foreground space-y-4",
95699
+ dangerouslySetInnerHTML: { __html: l }
95700
+ }
95701
+ )
95702
+ ] })
95691
95703
  ] });
95692
95704
  }
95693
- function useLoadScript(t) {
95694
- const [e, n] = useState(!0), [o, l] = useState(null), [d, f] = useState(!1), g = () => {
95695
- n(!1), f(!0);
95696
- };
95697
- return useEffect(() => {
95698
- if (!document) {
95699
- const C = new Error(`[ScriptLoadingError] document not defined when attempting to load ${t}`);
95700
- l(C);
95701
- return;
95702
- }
95703
- const b = document.querySelector(`script[src="${t}"]`);
95704
- if (b != null && b.dataset.loaded) {
95705
- g();
95706
- return;
95707
- }
95708
- const S = b || document.createElement("script");
95709
- b || (S.src = t);
95710
- const _ = () => {
95711
- S.dataset.loaded = "1", g();
95712
- };
95713
- S.addEventListener("load", _), S.addEventListener("error", (C) => {
95714
- console.error("Failed to load script:", t, C);
95715
- const E = new Error(`[ScriptLoadingError] Failed to load script: ${t}`);
95716
- l(E);
95717
- }), b || document.head.append(S);
95718
- }, []), {
95719
- isLoading: e,
95720
- error: o,
95721
- isSuccess: d
95722
- };
95705
+ function tzName(t, e, n = "long") {
95706
+ return new Intl.DateTimeFormat("en-US", {
95707
+ // Enforces engine to render the time. Without the option JavaScriptCore omits it.
95708
+ hour: "numeric",
95709
+ timeZone: t,
95710
+ timeZoneName: n
95711
+ }).format(e).split(/\s/g).slice(2).join(" ");
95723
95712
  }
95724
- const isGoogleReady = (t) => t && t.charts, isGoogleChartsReady = (t, e) => {
95725
- const { controls: n, toolbarItems: o, getChartEditor: l } = t;
95726
- return e && e.charts && e.visualization && e.visualization.ChartWrapper && e.visualization.Dashboard && (!n || e.visualization.ChartWrapper) && (!l || e.visualization.ChartEditor) && (!o || e.visualization.drawToolbar);
95727
- }, getGoogleInstanceFromWindow = (t) => window.google;
95728
- function useLoadGoogleCharts(t) {
95729
- const { chartVersion: e = "current", chartPackages: n = [
95730
- "corechart",
95731
- "controls"
95732
- ], chartLanguage: o = "en", mapsApiKey: l } = t, [d, f] = useState(null), [g, b] = useState(null), [S, _] = useState(null), { isLoading: C, error: E, isSuccess: R } = useLoadScript(t.chartLoaderScriptUrl || "https://www.gstatic.com/charts/loader.js");
95733
- return useEffect(() => {
95734
- if (!R)
95735
- return;
95736
- const A = getGoogleInstanceFromWindow();
95737
- if (!isGoogleReady(A)) {
95738
- const I = new Error("[ScriptInitializationError] Script loaded but Google not attached to window.");
95739
- b(I);
95740
- return;
95741
- }
95742
- if (isGoogleChartsReady(t, A)) {
95743
- f(A);
95744
- return;
95745
- }
95746
- A.charts.load(e, {
95747
- packages: n,
95748
- language: o,
95749
- mapsApiKey: l
95750
- }), A.charts.setOnLoadCallback(() => {
95751
- if (!isGoogleChartsReady(t, A)) {
95752
- const I = new Error("[GoogleChartsInitializationError] Google Charts not ready after load callback.");
95753
- console.error(I), _(I);
95754
- return;
95755
- }
95756
- f(A);
95757
- });
95758
- }, [
95759
- R
95760
- ]), {
95761
- error: E || g || S,
95762
- isLoading: C,
95763
- google: d
95764
- };
95713
+ const offsetFormatCache = {}, offsetCache = {};
95714
+ function tzOffset(t, e) {
95715
+ try {
95716
+ const o = (offsetFormatCache[t] || (offsetFormatCache[t] = new Intl.DateTimeFormat("en-US", {
95717
+ timeZone: t,
95718
+ timeZoneName: "longOffset"
95719
+ }).format))(e).split("GMT")[1];
95720
+ return o in offsetCache ? offsetCache[o] : calcOffset(o, o.split(":"));
95721
+ } catch {
95722
+ if (t in offsetCache) return offsetCache[t];
95723
+ const n = t == null ? void 0 : t.match(offsetRe);
95724
+ return n ? calcOffset(t, n.slice(1)) : NaN;
95725
+ }
95765
95726
  }
95766
- const chartDefaultProps = {
95767
- // <DEPRECATED_PROPS>
95768
- legend_toggle: !1,
95769
- // </DEPRECATED_PROPS>
95770
- options: {},
95771
- legendToggle: !1,
95772
- getChartWrapper: () => {
95773
- },
95774
- spreadSheetQueryParameters: {
95775
- headers: 1,
95776
- gid: 1
95777
- },
95778
- rootProps: {},
95779
- chartWrapperParams: {},
95780
- chartLoaderScriptUrl: "https://www.gstatic.com/charts/loader.js"
95781
- }, GoogleChartControls = (t) => {
95782
- const { isReady: e, chartControls: n, filter: o } = t;
95783
- return !e || !n || !(n != null && n.length) ? null : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, n.filter((l) => {
95784
- let { controlProp: d, control: f } = l;
95785
- return o ? o({
95786
- control: f,
95787
- controlProp: d
95788
- }) : !0;
95789
- }).map((l) => {
95790
- let { control: d } = l;
95791
- return /* @__PURE__ */ React__default.createElement("div", {
95792
- key: d.getContainerId(),
95793
- id: d.getContainerId()
95794
- });
95727
+ const offsetRe = /([+-]\d\d):?(\d\d)?/;
95728
+ function calcOffset(t, e) {
95729
+ const n = +(e[0] || 0), o = +(e[1] || 0), l = +(e[2] || 0) / 60;
95730
+ return offsetCache[t] = n * 60 + o > 0 ? n * 60 + o + l : n * 60 - o - l;
95731
+ }
95732
+ class TZDateMini extends Date {
95733
+ //#region static
95734
+ constructor(...e) {
95735
+ super(), e.length > 1 && typeof e[e.length - 1] == "string" && (this.timeZone = e.pop()), this.internal = /* @__PURE__ */ new Date(), isNaN(tzOffset(this.timeZone, this)) ? this.setTime(NaN) : e.length ? typeof e[0] == "number" && (e.length === 1 || e.length === 2 && typeof e[1] != "number") ? this.setTime(e[0]) : typeof e[0] == "string" ? this.setTime(+new Date(e[0])) : e[0] instanceof Date ? this.setTime(+e[0]) : (this.setTime(+new Date(...e)), adjustToSystemTZ(this), syncToInternal(this)) : this.setTime(Date.now());
95736
+ }
95737
+ static tz(e, ...n) {
95738
+ return n.length ? new TZDateMini(...n, e) : new TZDateMini(Date.now(), e);
95739
+ }
95740
+ //#endregion
95741
+ //#region time zone
95742
+ withTimeZone(e) {
95743
+ return new TZDateMini(+this, e);
95744
+ }
95745
+ getTimezoneOffset() {
95746
+ const e = -tzOffset(this.timeZone, this);
95747
+ return e > 0 ? Math.floor(e) : Math.ceil(e);
95748
+ }
95749
+ //#endregion
95750
+ //#region time
95751
+ setTime(e) {
95752
+ return Date.prototype.setTime.apply(this, arguments), syncToInternal(this), +this;
95753
+ }
95754
+ //#endregion
95755
+ //#region date-fns integration
95756
+ [Symbol.for("constructDateFrom")](e) {
95757
+ return new TZDateMini(+new Date(e), this.timeZone);
95758
+ }
95759
+ //#endregion
95760
+ }
95761
+ const re = /^(get|set)(?!UTC)/;
95762
+ Object.getOwnPropertyNames(Date.prototype).forEach((t) => {
95763
+ if (!re.test(t)) return;
95764
+ const e = t.replace(re, "$1UTC");
95765
+ TZDateMini.prototype[e] && (t.startsWith("get") ? TZDateMini.prototype[t] = function() {
95766
+ return this.internal[e]();
95767
+ } : (TZDateMini.prototype[t] = function() {
95768
+ return Date.prototype[e].apply(this.internal, arguments), syncFromInternal(this), +this;
95769
+ }, TZDateMini.prototype[e] = function() {
95770
+ return Date.prototype[e].apply(this, arguments), syncToInternal(this), +this;
95795
95771
  }));
95796
- };
95797
- let uniqueID = 0;
95798
- const generateUniqueID = () => (uniqueID += 1, `reactgooglegraph-${uniqueID}`), Vr = class Vr {
95799
- };
95800
- /**
95801
- * Initialize the controls once chart is ready
95802
- */
95803
- er(Vr, "initializeControls", (e) => {
95804
- for (let n = 0; n < e.length; n += 1) {
95805
- const { controlType: o, options: l, controlWrapperParams: d } = e[n].controlProp;
95806
- d && "state" in d && e[n].control.setState(d.state), e[n].control.setOptions(l), e[n].control.setControlType(o);
95772
+ });
95773
+ function syncToInternal(t) {
95774
+ t.internal.setTime(+t), t.internal.setUTCSeconds(t.internal.getUTCSeconds() - Math.round(-tzOffset(t.timeZone, t) * 60));
95775
+ }
95776
+ function syncFromInternal(t) {
95777
+ Date.prototype.setFullYear.call(t, t.internal.getUTCFullYear(), t.internal.getUTCMonth(), t.internal.getUTCDate()), Date.prototype.setHours.call(t, t.internal.getUTCHours(), t.internal.getUTCMinutes(), t.internal.getUTCSeconds(), t.internal.getUTCMilliseconds()), adjustToSystemTZ(t);
95778
+ }
95779
+ function adjustToSystemTZ(t) {
95780
+ const e = tzOffset(t.timeZone, t), n = e > 0 ? Math.floor(e) : Math.ceil(e), o = /* @__PURE__ */ new Date(+t);
95781
+ o.setUTCHours(o.getUTCHours() - 1);
95782
+ const l = -(/* @__PURE__ */ new Date(+t)).getTimezoneOffset(), d = -(/* @__PURE__ */ new Date(+o)).getTimezoneOffset(), f = l - d, g = Date.prototype.getHours.apply(t) !== t.internal.getUTCHours();
95783
+ f && g && t.internal.setUTCMinutes(t.internal.getUTCMinutes() + f);
95784
+ const b = l - n;
95785
+ b && Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + b);
95786
+ const S = /* @__PURE__ */ new Date(+t);
95787
+ S.setUTCSeconds(0);
95788
+ const _ = l > 0 ? S.getSeconds() : (S.getSeconds() - 60) % 60, C = Math.round(-(tzOffset(t.timeZone, t) * 60)) % 60;
95789
+ (C || _) && (t.internal.setUTCSeconds(t.internal.getUTCSeconds() + C), Date.prototype.setUTCSeconds.call(t, Date.prototype.getUTCSeconds.call(t) + C + _));
95790
+ const E = tzOffset(t.timeZone, t), R = E > 0 ? Math.floor(E) : Math.ceil(E), I = -(/* @__PURE__ */ new Date(+t)).getTimezoneOffset() - R, M = R !== n, V = I - b;
95791
+ if (M && V) {
95792
+ Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + V);
95793
+ const j = tzOffset(t.timeZone, t), z = j > 0 ? Math.floor(j) : Math.ceil(j), Q = R - z;
95794
+ Q && (t.internal.setUTCMinutes(t.internal.getUTCMinutes() + Q), Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + Q));
95807
95795
  }
95808
- }), /**
95809
- * listen to the control events (ready, statechange, error) specified in the controlEvents prop
95810
- */
95811
- er(Vr, "listenToControlEvents", (e, n) => {
95812
- const { google: o } = n;
95813
- return e.flatMap((l) => {
95814
- const { control: d, controlProp: f } = l, { controlEvents: g = [] } = f;
95815
- return g.map((b) => {
95816
- const { callback: S, eventName: _ } = b;
95817
- return o.visualization.events.addListener(d, _, function() {
95818
- for (var C = arguments.length, E = new Array(C), R = 0; R < C; R++)
95819
- E[R] = arguments[R];
95820
- S({
95821
- chartWrapper: null,
95822
- controlWrapper: d,
95823
- props: n,
95824
- google: o,
95825
- eventArgs: E
95826
- });
95827
- });
95796
+ }
95797
+ class TZDate extends TZDateMini {
95798
+ //#region static
95799
+ static tz(e, ...n) {
95800
+ return n.length ? new TZDate(...n, e) : new TZDate(Date.now(), e);
95801
+ }
95802
+ //#endregion
95803
+ //#region representation
95804
+ toISOString() {
95805
+ const [e, n, o] = this.tzComponents(), l = `${e}${n}:${o}`;
95806
+ return this.internal.toISOString().slice(0, -1) + l;
95807
+ }
95808
+ toString() {
95809
+ return `${this.toDateString()} ${this.toTimeString()}`;
95810
+ }
95811
+ toDateString() {
95812
+ const [e, n, o, l] = this.internal.toUTCString().split(" ");
95813
+ return `${e == null ? void 0 : e.slice(0, -1)} ${o} ${n} ${l}`;
95814
+ }
95815
+ toTimeString() {
95816
+ const e = this.internal.toUTCString().split(" ")[4], [n, o, l] = this.tzComponents();
95817
+ return `${e} GMT${n}${o}${l} (${tzName(this.timeZone, this)})`;
95818
+ }
95819
+ toLocaleString(e, n) {
95820
+ return Date.prototype.toLocaleString.call(this, e, {
95821
+ ...n,
95822
+ timeZone: (n == null ? void 0 : n.timeZone) || this.timeZone
95828
95823
  });
95829
- });
95830
- }), /**
95831
- * If controlID is not provided, generate a unique controlID
95832
- */
95833
- er(Vr, "createControlId", (e) => {
95834
- let n;
95835
- return typeof e > "u" ? n = `googlechart-control-${generateUniqueID()}` : n = e, n;
95836
- }), /**
95837
- * Map the control props to Google Chart Controls
95838
- */
95839
- er(Vr, "createChartControls", (e) => {
95840
- const { controls: n, google: o } = e;
95841
- return n ? n.map((l, d) => {
95842
- const { controlID: f, controlType: g, options: b, controlWrapperParams: S } = l, _ = Vr.createControlId(f);
95843
- return {
95844
- controlProp: l,
95845
- control: new o.visualization.ControlWrapper({
95846
- containerId: _,
95847
- controlType: g,
95848
- options: b,
95849
- ...S
95850
- })
95851
- };
95852
- }) : null;
95853
- }), er(Vr, "addControls", (e) => {
95854
- const { chartWrapper: n, chartDashboard: o } = e, l = Vr.createChartControls(e);
95855
- return !l || !o || !n ? null : (o.bind(l.map((d) => {
95856
- let { control: f } = d;
95857
- return f;
95858
- }), n), Vr.initializeControls(l), l);
95859
- });
95860
- let GoogleChartControlsInternal = Vr;
95861
- const useCreateChartControls = (t) => {
95862
- const [e, n] = React.useState(null);
95863
- return [
95864
- React.useMemo(() => !e || !t ? null : t.map((l, d) => {
95865
- const f = e[d];
95866
- return f ? {
95867
- controlProp: l,
95868
- control: f
95869
- } : void 0;
95870
- }).flatMap((l) => l ? [
95871
- l
95872
- ] : []), [
95873
- e,
95874
- t
95875
- ]),
95876
- n
95877
- ];
95878
- }, useListenToControlEvents = (t, e) => {
95879
- React.useEffect(() => {
95880
- const n = GoogleChartControlsInternal.listenToControlEvents(t ?? [], e);
95881
- return () => {
95882
- n.forEach((o) => {
95883
- e.google.visualization.events.removeListener(o);
95884
- });
95885
- };
95886
- }, [
95887
- t,
95888
- e
95889
- ]);
95890
- }, useChartControls = (t) => {
95891
- const [e, n] = useCreateChartControls(t.controls);
95892
- return useListenToControlEvents(e ?? [], t), {
95893
- addControls: (l) => {
95894
- const d = GoogleChartControlsInternal.addControls(l);
95895
- n((d == null ? void 0 : d.map((f) => f.control)) ?? null);
95896
- },
95897
- renderControl: (l) => {
95898
- const { chartWrapper: d, chartDashboard: f } = t;
95899
- return /* @__PURE__ */ React.createElement(GoogleChartControls, {
95900
- ...t,
95901
- isReady: !!(d && f),
95902
- chartControls: e,
95903
- filter: l
95904
- });
95905
- }
95906
- };
95907
- }, useChartId = (t) => {
95908
- const e = React.useRef(null);
95909
- return {
95910
- chartId: (() => {
95911
- const { graphID: l, graph_id: d } = t, f = l || d;
95912
- let g;
95913
- return f ? g = f : g = e.current || generateUniqueID(), e.current = g, e.current;
95914
- })()
95915
- };
95916
- }, DEFAULT_CHART_COLORS = [
95917
- "#3366CC",
95918
- "#DC3912",
95919
- "#FF9900",
95920
- "#109618",
95921
- "#990099",
95922
- "#3B3EAC",
95923
- "#0099C6",
95924
- "#DD4477",
95925
- "#66AA00",
95926
- "#B82E2E",
95927
- "#316395",
95928
- "#994499",
95929
- "#22AA99",
95930
- "#AAAA11",
95931
- "#6633CC",
95932
- "#E67300",
95933
- "#8B0707",
95934
- "#329262",
95935
- "#5574A6",
95936
- "#3B3EAC"
95937
- ], loadDataTableFromSpreadSheet = async function(t, e) {
95938
- let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
95939
- return new Promise((o, l) => {
95940
- 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}` : ""}`, S = `${n.access_token ? `&access_token=${n.access_token}` : ""}`, _ = `${d}${g}${b}${f}${S}`, C = `${e}/gviz/tq?${_}`;
95941
- new t.visualization.Query(C).send((R) => {
95942
- R.isError() ? l(`Error in query: ${R.getMessage()} ${R.getDetailedMessage()}`) : o(R.getDataTable());
95824
+ }
95825
+ toLocaleDateString(e, n) {
95826
+ return Date.prototype.toLocaleDateString.call(this, e, {
95827
+ ...n,
95828
+ timeZone: (n == null ? void 0 : n.timeZone) || this.timeZone
95943
95829
  });
95944
- });
95945
- }, GRAY_COLOR = "#CCCCCC", Rr = class Rr {
95946
- };
95947
- er(Rr, "grayOutHiddenColumnsLabel", (e, n) => {
95948
- const { googleChartWrapper: o, options: l } = e;
95949
- if (!o) {
95950
- console.error("googleChartWrapper is not defined");
95951
- return;
95952
95830
  }
95953
- const d = o.getDataTable();
95954
- if (!d) return;
95955
- const f = d.getNumberOfColumns();
95956
- if (n.length > 0 === !1) return;
95957
- const b = Array.from({
95958
- length: f - 1
95959
- }).map((S, _) => {
95960
- const C = Rr.getColumnId(d, _ + 1);
95961
- return n.includes(C) ? GRAY_COLOR : l && l.colors ? l.colors[_] : DEFAULT_CHART_COLORS[_];
95962
- });
95963
- o.setOptions({
95964
- ...l,
95965
- colors: b
95966
- }), o.draw();
95967
- }), /**
95968
- * Listens to user clicking on the legend to toggle the visibility of a column.
95969
- * When a user clicks on a legend item, the column id is added to / removed from the hiddenColumns state.
95970
- */
95971
- er(Rr, "listenToLegendToggle", (e, n) => {
95972
- const [o, l] = n, { google: d, googleChartWrapper: f } = e;
95973
- if (!f) {
95974
- console.error("googleChartWrapper is not defined");
95975
- return;
95831
+ toLocaleTimeString(e, n) {
95832
+ return Date.prototype.toLocaleTimeString.call(this, e, {
95833
+ ...n,
95834
+ timeZone: (n == null ? void 0 : n.timeZone) || this.timeZone
95835
+ });
95976
95836
  }
95977
- return d.visualization.events.addListener(f, "select", () => {
95978
- const b = f.getChart().getSelection(), S = f.getDataTable();
95979
- if (b.length === 0 || // We want to listen to when a whole row is selected. This is the case only when row === null
95980
- b[0].row !== null || !S)
95981
- return;
95982
- const _ = b[0].column, C = Rr.getColumnId(S, _);
95983
- o != null && o.includes(C) ? l((E) => [
95984
- ...E.filter((R) => R !== C)
95985
- ]) : l((E) => [
95986
- ...E,
95987
- C
95988
- ]);
95989
- });
95990
- }), /**
95991
- * (Re-)Draw a Google Chart with the given data, options, and chart type.
95992
- */
95993
- er(Rr, "draw", async (e) => {
95994
- const { data: n, diffdata: o, rows: l, columns: d, options: f, chartType: g, formatters: b, spreadSheetUrl: S, spreadSheetQueryParameters: _, googleChartDashboard: C, googleChartWrapper: E, google: R, hiddenColumns: A, legendToggle: I, legend_toggle: M } = e;
95995
- if (!E) {
95996
- console.error("draw was called with googleChartWrapper = null");
95997
- return;
95837
+ //#endregion
95838
+ //#region private
95839
+ tzComponents() {
95840
+ const e = this.getTimezoneOffset(), n = e > 0 ? "-" : "+", o = String(Math.floor(Math.abs(e) / 60)).padStart(2, "0"), l = String(Math.abs(e) % 60).padStart(2, "0");
95841
+ return [n, o, l];
95998
95842
  }
95999
- let V, j = null;
96000
- if (o) {
96001
- const te = R.visualization.arrayToDataTable(o.old), ne = R.visualization.arrayToDataTable(o.new);
96002
- j = R.visualization[g].prototype.computeDiff(te, ne);
95843
+ //#endregion
95844
+ withTimeZone(e) {
95845
+ return new TZDate(+this, e);
96003
95846
  }
96004
- n ? n instanceof R.visualization.DataTable ? V = n : Array.isArray(n) ? V = R.visualization.arrayToDataTable(n) : V = new R.visualization.DataTable(n) : l && d ? V = R.visualization.arrayToDataTable([
96005
- d,
96006
- ...l
96007
- ]) : S ? V = await loadDataTableFromSpreadSheet(R, S, _) : V = R.visualization.arrayToDataTable([]);
96008
- const z = V.getNumberOfColumns(), Q = Array(z).fill(0).map((te, ne) => {
96009
- const ae = Rr.getColumnId(V, ne);
96010
- return A.includes(ae) ? {
96011
- label: V.getColumnLabel(ne),
96012
- type: V.getColumnType(ne),
96013
- calc: () => null
96014
- } : ne;
96015
- }), O = E.getChart();
96016
- E.getChartType() === "Timeline" && O && O.clearChart(), E.setChartType(g), E.setOptions(f || {});
96017
- const F = new R.visualization.DataView(V);
96018
- F.setColumns(Q), E.setDataTable(F), E.draw(), C && C.draw(V), j && (E.setDataTable(j), E.draw()), b && (Rr.applyFormatters({
96019
- dataTable: V,
96020
- formatters: b,
96021
- google: R
96022
- }), E.setDataTable(V), E.draw()), (I === !0 || M === !0) && Rr.grayOutHiddenColumnsLabel(e, A);
96023
- }), /**
96024
- * Get the column ID of a column in a GoogleDataTable.
96025
- * If the column has an ID, return the ID, otherwise return the label.
96026
- */
96027
- er(Rr, "getColumnId", (e, n) => e.getColumnId(n) || e.getColumnLabel(n)), /**
96028
- * Apply Chart Formatters passed under the formatters prop to the GoogleDataTable
96029
- */
96030
- er(Rr, "applyFormatters", (e) => {
96031
- let { dataTable: n, formatters: o, google: l } = e;
96032
- for (let d of o)
96033
- switch (d.type) {
96034
- case "ArrowFormat": {
96035
- new l.visualization.ArrowFormat(d.options).format(n, d.column);
96036
- return;
96037
- }
96038
- case "BarFormat": {
96039
- new l.visualization.BarFormat(d.options).format(n, d.column);
96040
- return;
96041
- }
96042
- case "ColorFormat": {
96043
- const f = new l.visualization.ColorFormat(d.options), { ranges: g } = d;
96044
- if (g)
96045
- for (let b of g)
96046
- f.addRange(...b);
96047
- f.format(n, d.column);
96048
- return;
96049
- }
96050
- case "DateFormat": {
96051
- new l.visualization.DateFormat(d.options).format(n, d.column);
96052
- return;
96053
- }
96054
- case "NumberFormat": {
96055
- new l.visualization.NumberFormat(d.options).format(n, d.column);
96056
- return;
96057
- }
96058
- case "PatternFormat": {
96059
- new l.visualization.PatternFormat(d.options).format(n, d.column);
96060
- return;
96061
- }
96062
- default: {
96063
- console.warn(`Unknown formatter type: ${d.type}`);
96064
- return;
96065
- }
96066
- }
96067
- });
96068
- let GoogleChartInternal = Rr;
96069
- const useGoogleChartDataTable = (t) => {
96070
- const { google: e, googleChartWrapper: n, googleChartDashboard: o } = t, [l, d] = React.useState([]);
96071
- React.useEffect(() => {
96072
- n && GoogleChartInternal.draw({
96073
- ...t,
96074
- hiddenColumns: l,
96075
- googleChartWrapper: n,
96076
- googleChartDashboard: o,
96077
- google: e
96078
- });
96079
- }, [
96080
- l,
96081
- t.data,
96082
- t.rows,
96083
- t.columns,
96084
- t.options,
96085
- t.chartLoaderScriptUrl,
96086
- t.chartType,
96087
- t.formatters,
96088
- t.spreadSheetUrl,
96089
- t.spreadSheetQueryParameters,
96090
- t.legendToggle,
96091
- t.legend_toggle
96092
- ]);
96093
- const f = () => {
96094
- const { googleChartWrapper: S } = t;
96095
- S && S.draw();
96096
- }, g = (S) => {
96097
- const _ = [], { legendToggle: C, legend_toggle: E } = t;
96098
- if (GoogleChartInternal.draw({
96099
- ...t,
96100
- hiddenColumns: l,
96101
- googleChartWrapper: S,
96102
- googleChartDashboard: o,
96103
- google: e
96104
- }), window.addEventListener("resize", f), E || C) {
96105
- const R = GoogleChartInternal.listenToLegendToggle(t, [
96106
- l,
96107
- d
96108
- ]);
96109
- R && _.push(R);
96110
- }
96111
- return _;
96112
- }, b = (S, _) => {
96113
- window.removeEventListener("resize", f), _.forEach((C) => {
96114
- e.visualization.events.removeListener(C);
96115
- }), S.getChartType() === "Timeline" && S.getChart() && S.getChart().clearChart();
96116
- };
96117
- React.useEffect(() => {
96118
- if (!n)
96119
- return;
96120
- const S = g(n);
96121
- return () => {
96122
- b(n, S);
96123
- };
96124
- }, [
96125
- n,
96126
- g,
96127
- b
96128
- ]);
96129
- }, listenToEvents = (t) => {
96130
- const { chartEvents: e, google: n, googleChartWrapper: o } = t;
96131
- if (e) {
96132
- if (!o) {
96133
- console.warn("listenToEvents was called before chart wrapper ready.");
96134
- return;
96135
- }
96136
- return e.map((l) => {
96137
- let { eventName: d, callback: f } = l;
96138
- return n.visualization.events.addListener(o, d, function() {
96139
- for (var g = arguments.length, b = new Array(g), S = 0; S < g; S++)
96140
- b[S] = arguments[S];
96141
- f({
96142
- chartWrapper: o,
96143
- props: t,
96144
- google: n,
96145
- eventArgs: b
96146
- });
96147
- });
96148
- });
95847
+ //#region date-fns integration
95848
+ [Symbol.for("constructDateFrom")](e) {
95849
+ return new TZDate(+new Date(e), this.timeZone);
96149
95850
  }
96150
- }, useGoogleChartEvents = (t) => {
96151
- useEffect(() => {
96152
- if (!t.googleChartWrapper) return;
96153
- const e = listenToEvents(t);
96154
- return () => {
96155
- e == null || e.forEach((n) => {
96156
- t.google.visualization.events.removeListener(n);
96157
- });
96158
- };
96159
- }, [
96160
- t
96161
- ]);
96162
- }, GoogleChart = (t) => {
96163
- const [e, n] = React.useState(null), [o, l] = React.useState(null), { addControls: d, renderControl: f } = useChartControls({
96164
- ...t,
96165
- chartDashboard: o,
96166
- chartWrapper: e
96167
- });
96168
- useGoogleChartEvents({
96169
- ...t,
96170
- googleChartWrapper: e
96171
- });
96172
- const { chartId: g } = useChartId(t), b = React.useRef(null), S = React.useRef(null);
96173
- React.useEffect(() => {
96174
- const { options: V, google: j, chartType: z, chartWrapperParams: Q, toolbarItems: O, getChartEditor: F, getChartWrapper: te, onLoad: ne } = t, ae = {
96175
- chartType: z,
96176
- options: V,
96177
- containerId: g,
96178
- ...Q
96179
- }, $e = new j.visualization.ChartWrapper(ae);
96180
- $e.setOptions(V || {}), te == null || te($e, j);
96181
- const Ne = new j.visualization.Dashboard(b.current);
96182
- O && j.visualization.drawToolbar(S.current, O);
96183
- let oe = null;
96184
- F && (oe = new j.visualization.ChartEditor(), F({
96185
- chartEditor: oe,
96186
- chartWrapper: $e,
96187
- google: j
96188
- })), d({
96189
- ...t,
96190
- chartDashboard: Ne,
96191
- chartWrapper: $e
96192
- }), n($e), l(Ne), ne == null || ne(j, {
96193
- google: j,
96194
- chartWrapper: $e,
96195
- chartEditor: oe,
96196
- chartDashboard: Ne
96197
- });
96198
- }, []), useGoogleChartDataTable({
96199
- ...t,
96200
- googleChartWrapper: e,
96201
- googleChartDashboard: o
96202
- });
96203
- const _ = () => {
96204
- const { width: V, height: j, options: z, style: Q, className: O, rootProps: F, google: te } = t, ne = {
96205
- height: j || z && z.height,
96206
- width: V || z && z.width,
96207
- ...Q
96208
- };
96209
- return /* @__PURE__ */ React.createElement("div", {
96210
- id: g,
96211
- style: ne,
96212
- className: O,
96213
- ...F
96214
- });
96215
- }, C = () => t.toolbarItems ? /* @__PURE__ */ React.createElement("div", {
96216
- ref: S
96217
- }) : null, { width: E, height: R, options: A, style: I } = t, M = {
96218
- height: R || A && A.height,
96219
- width: E || A && A.width,
96220
- ...I
96221
- };
96222
- return t.render ? /* @__PURE__ */ React.createElement("div", {
96223
- ref: b,
96224
- style: M
96225
- }, /* @__PURE__ */ React.createElement("div", {
96226
- ref: S,
96227
- id: "toolbar"
96228
- }), t.render({
96229
- renderChart: _,
96230
- renderControl: f,
96231
- renderToolbar: C
96232
- })) : /* @__PURE__ */ React.createElement("div", {
96233
- ref: b,
96234
- style: M
96235
- }, f((V) => {
96236
- let { controlProp: j } = V;
96237
- return j.controlPosition !== "bottom";
96238
- }), _(), f((V) => {
96239
- let { controlProp: j } = V;
96240
- return j.controlPosition === "bottom";
96241
- }), C());
96242
- }, ChartContext = /* @__PURE__ */ React.createContext(chartDefaultProps), ContextProvider = (t) => {
96243
- let { children: e, value: n } = t;
96244
- return /* @__PURE__ */ React.createElement(ChartContext.Provider, {
96245
- value: n
96246
- }, e);
96247
- }, ChartView = (t) => {
96248
- const { google: e, isLoading: n, error: o } = useLoadGoogleCharts(t);
96249
- return n ? t.loader ?? null : o ? t.errorElement ?? null : e ? /* @__PURE__ */ React__default.createElement(GoogleChart, {
96250
- google: e,
96251
- ...t
96252
- }) : null;
96253
- }, Chart = (t) => {
96254
- const e = {
96255
- ...chartDefaultProps,
96256
- ...t
96257
- };
96258
- return /* @__PURE__ */ React__default.createElement(ContextProvider, {
96259
- value: e
96260
- }, /* @__PURE__ */ React__default.createElement(ChartView, e));
96261
- };
96262
- var GoogleDataTableColumnRoleType;
96263
- (function(t) {
96264
- 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";
96265
- })(GoogleDataTableColumnRoleType || (GoogleDataTableColumnRoleType = {}));
96266
- function parseHsl(t) {
96267
- const e = t.match(/(\d+\.?\d*)\s*(\d+\.?\d*)%\s*(\d+\.?\d*)%/);
96268
- return e ? {
96269
- h: parseFloat(e[1]),
96270
- s: parseFloat(e[2]),
96271
- l: parseFloat(e[3])
96272
- } : null;
95851
+ //#endregion
96273
95852
  }
96274
- function hslToHex(t, e, n) {
96275
- n /= 100;
96276
- const o = e * Math.min(n, 1 - n) / 100, l = (d) => {
96277
- const f = (d + t / 30) % 12, g = n - o * Math.max(Math.min(f - 3, 9 - f, 1), -1);
96278
- return Math.round(255 * g).toString(16).padStart(2, "0");
96279
- };
96280
- return `#${l(0)}${l(8)}${l(4)}`;
95853
+ const FIVE_WEEKS = 5, FOUR_WEEKS = 4;
95854
+ function getBroadcastWeeksInMonth(t, e) {
95855
+ const n = e.startOfMonth(t), o = n.getDay() > 0 ? n.getDay() : 7, l = e.addDays(t, -o + 1), d = e.addDays(l, FIVE_WEEKS * 7 - 1);
95856
+ return e.getMonth(t) === e.getMonth(d) ? FIVE_WEEKS : FOUR_WEEKS;
96281
95857
  }
96282
- const Treemap = React.forwardRef(
96283
- ({ data: t, options: e, height: n = "500px", className: o, loading: l, disableClick: d = !0, ...f }, g) => {
96284
- const b = React.useRef(null), [S, _] = React.useState(null);
96285
- React.useEffect(() => {
96286
- if (!b.current) return;
96287
- const R = b.current, A = () => {
96288
- const j = getComputedStyle(R).getPropertyValue("--primary").trim();
96289
- if (j) {
96290
- const z = parseHsl(j);
96291
- if (z) {
96292
- const { h: Q, s: O, l: F } = z;
96293
- _({
96294
- minColor: hslToHex(Q, O, Math.min(100, F + 50)),
96295
- midColor: hslToHex(Q, O, Math.min(100, F + 35)),
96296
- maxColor: hslToHex(Q, O, Math.min(100, F + 20))
96297
- });
96298
- }
96299
- return !0;
96300
- }
96301
- return !1;
96302
- };
96303
- if (A())
96304
- return;
96305
- let I = 0;
96306
- const M = 20, V = setInterval(() => {
96307
- (A() || I >= M) && clearInterval(V), I++;
96308
- }, 100);
96309
- return () => {
96310
- V && clearInterval(V);
96311
- };
96312
- }, []);
96313
- const C = React.useMemo(() => {
96314
- const R = {
96315
- headerHeight: 0,
96316
- fontSize: 14,
96317
- showScale: !1,
96318
- isHtml: !0,
96319
- backgroundColor: "hsl(var(--background))",
96320
- generateTooltip: (A, I) => {
96321
- var j;
96322
- const M = (j = t[A + 1]) == null ? void 0 : j[0];
96323
- if (!M) return "";
96324
- const V = formatMoney(I);
96325
- return `<div class="p-2 bg-background text-foreground border rounded-md shadow-lg">
96326
- <strong>${M}</strong><br>Value: ${V}
96327
- </div>`;
96328
- }
96329
- };
96330
- return S && (!e || !e.colorAxis) && (R.minColor = S.minColor, R.midColor = S.midColor, R.maxColor = S.maxColor), { ...R, ...e };
96331
- }, [t, e, S]), E = React.useMemo(() => d ? [{
96332
- eventName: "select",
96333
- // react-google-charts is not officially maintained by Google and not up
96334
- // to date with the GoogleChartWrapper type, setSelection is missing
96335
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
96336
- callback: ({ chartWrapper: A }) => {
96337
- A.getChart().setSelection(null);
96338
- }
96339
- }] : void 0, [d]);
96340
- return React.useImperativeHandle(g, () => b.current, []), l ? /* @__PURE__ */ jsx("div", { ref: b, className: cn("w-full", o), style: { height: n }, ...f, children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full w-full" }) }) : !t || t.length <= 2 ? /* @__PURE__ */ jsx("div", { ref: b, className: cn("w-full flex items-center justify-center text-muted-foreground", o), style: { height: n }, ...f, children: "No data available" }) : /* @__PURE__ */ jsx("div", { ref: b, className: cn("w-full", o), style: { height: n }, ...f, children: /* @__PURE__ */ jsx(
96341
- Chart,
96342
- {
96343
- chartType: "TreeMap",
96344
- width: "100%",
96345
- height: "100%",
96346
- data: t,
96347
- options: C,
96348
- chartEvents: E,
96349
- loader: /* @__PURE__ */ jsx(Skeleton, { className: "h-full w-full" })
96350
- }
96351
- ) });
95858
+ function startOfBroadcastWeek(t, e) {
95859
+ const n = e.startOfMonth(t), o = n.getDay();
95860
+ return o === 1 ? n : o === 0 ? e.addDays(n, -6) : e.addDays(n, -1 * (o - 1));
95861
+ }
95862
+ function endOfBroadcastWeek(t, e) {
95863
+ const n = startOfBroadcastWeek(t, e), o = getBroadcastWeeksInMonth(t, e);
95864
+ return e.addDays(n, o * 7 - 1);
95865
+ }
95866
+ class DateLib {
95867
+ /**
95868
+ * Creates an instance of `DateLib`.
95869
+ *
95870
+ * @param options Configuration options for the date library.
95871
+ * @param overrides Custom overrides for the date library functions.
95872
+ */
95873
+ constructor(e, n) {
95874
+ this.Date = Date, this.today = () => {
95875
+ var o;
95876
+ return (o = this.overrides) != null && o.today ? this.overrides.today() : this.options.timeZone ? TZDate.tz(this.options.timeZone) : new this.Date();
95877
+ }, this.newDate = (o, l, d) => {
95878
+ var f;
95879
+ return (f = this.overrides) != null && f.newDate ? this.overrides.newDate(o, l, d) : this.options.timeZone ? new TZDate(o, l, d, this.options.timeZone) : new Date(o, l, d);
95880
+ }, this.addDays = (o, l) => {
95881
+ var d;
95882
+ return (d = this.overrides) != null && d.addDays ? this.overrides.addDays(o, l) : addDays(o, l);
95883
+ }, this.addMonths = (o, l) => {
95884
+ var d;
95885
+ return (d = this.overrides) != null && d.addMonths ? this.overrides.addMonths(o, l) : addMonths(o, l);
95886
+ }, this.addWeeks = (o, l) => {
95887
+ var d;
95888
+ return (d = this.overrides) != null && d.addWeeks ? this.overrides.addWeeks(o, l) : addWeeks(o, l);
95889
+ }, this.addYears = (o, l) => {
95890
+ var d;
95891
+ return (d = this.overrides) != null && d.addYears ? this.overrides.addYears(o, l) : addYears(o, l);
95892
+ }, this.differenceInCalendarDays = (o, l) => {
95893
+ var d;
95894
+ return (d = this.overrides) != null && d.differenceInCalendarDays ? this.overrides.differenceInCalendarDays(o, l) : differenceInCalendarDays(o, l);
95895
+ }, this.differenceInCalendarMonths = (o, l) => {
95896
+ var d;
95897
+ return (d = this.overrides) != null && d.differenceInCalendarMonths ? this.overrides.differenceInCalendarMonths(o, l) : differenceInCalendarMonths(o, l);
95898
+ }, this.eachMonthOfInterval = (o) => {
95899
+ var l;
95900
+ return (l = this.overrides) != null && l.eachMonthOfInterval ? this.overrides.eachMonthOfInterval(o) : eachMonthOfInterval(o);
95901
+ }, this.endOfBroadcastWeek = (o) => {
95902
+ var l;
95903
+ return (l = this.overrides) != null && l.endOfBroadcastWeek ? this.overrides.endOfBroadcastWeek(o) : endOfBroadcastWeek(o, this);
95904
+ }, this.endOfISOWeek = (o) => {
95905
+ var l;
95906
+ return (l = this.overrides) != null && l.endOfISOWeek ? this.overrides.endOfISOWeek(o) : endOfISOWeek(o);
95907
+ }, this.endOfMonth = (o) => {
95908
+ var l;
95909
+ return (l = this.overrides) != null && l.endOfMonth ? this.overrides.endOfMonth(o) : endOfMonth(o);
95910
+ }, this.endOfWeek = (o, l) => {
95911
+ var d;
95912
+ return (d = this.overrides) != null && d.endOfWeek ? this.overrides.endOfWeek(o, l) : endOfWeek(o, this.options);
95913
+ }, this.endOfYear = (o) => {
95914
+ var l;
95915
+ return (l = this.overrides) != null && l.endOfYear ? this.overrides.endOfYear(o) : endOfYear(o);
95916
+ }, this.format = (o, l, d) => {
95917
+ var g;
95918
+ const f = (g = this.overrides) != null && g.format ? this.overrides.format(o, l, this.options) : format(o, l, this.options);
95919
+ return this.options.numerals && this.options.numerals !== "latn" ? this.replaceDigits(f) : f;
95920
+ }, this.getISOWeek = (o) => {
95921
+ var l;
95922
+ return (l = this.overrides) != null && l.getISOWeek ? this.overrides.getISOWeek(o) : getISOWeek(o);
95923
+ }, this.getMonth = (o, l) => {
95924
+ var d;
95925
+ return (d = this.overrides) != null && d.getMonth ? this.overrides.getMonth(o, this.options) : getMonth(o, this.options);
95926
+ }, this.getYear = (o, l) => {
95927
+ var d;
95928
+ return (d = this.overrides) != null && d.getYear ? this.overrides.getYear(o, this.options) : getYear(o, this.options);
95929
+ }, this.getWeek = (o, l) => {
95930
+ var d;
95931
+ return (d = this.overrides) != null && d.getWeek ? this.overrides.getWeek(o, this.options) : getWeek(o, this.options);
95932
+ }, this.isAfter = (o, l) => {
95933
+ var d;
95934
+ return (d = this.overrides) != null && d.isAfter ? this.overrides.isAfter(o, l) : isAfter(o, l);
95935
+ }, this.isBefore = (o, l) => {
95936
+ var d;
95937
+ return (d = this.overrides) != null && d.isBefore ? this.overrides.isBefore(o, l) : isBefore(o, l);
95938
+ }, this.isDate = (o) => {
95939
+ var l;
95940
+ return (l = this.overrides) != null && l.isDate ? this.overrides.isDate(o) : isDate(o);
95941
+ }, this.isSameDay = (o, l) => {
95942
+ var d;
95943
+ return (d = this.overrides) != null && d.isSameDay ? this.overrides.isSameDay(o, l) : isSameDay(o, l);
95944
+ }, this.isSameMonth = (o, l) => {
95945
+ var d;
95946
+ return (d = this.overrides) != null && d.isSameMonth ? this.overrides.isSameMonth(o, l) : isSameMonth(o, l);
95947
+ }, this.isSameYear = (o, l) => {
95948
+ var d;
95949
+ return (d = this.overrides) != null && d.isSameYear ? this.overrides.isSameYear(o, l) : isSameYear(o, l);
95950
+ }, this.max = (o) => {
95951
+ var l;
95952
+ return (l = this.overrides) != null && l.max ? this.overrides.max(o) : max$1(o);
95953
+ }, this.min = (o) => {
95954
+ var l;
95955
+ return (l = this.overrides) != null && l.min ? this.overrides.min(o) : min$1(o);
95956
+ }, this.setMonth = (o, l) => {
95957
+ var d;
95958
+ return (d = this.overrides) != null && d.setMonth ? this.overrides.setMonth(o, l) : setMonth(o, l);
95959
+ }, this.setYear = (o, l) => {
95960
+ var d;
95961
+ return (d = this.overrides) != null && d.setYear ? this.overrides.setYear(o, l) : setYear(o, l);
95962
+ }, this.startOfBroadcastWeek = (o, l) => {
95963
+ var d;
95964
+ return (d = this.overrides) != null && d.startOfBroadcastWeek ? this.overrides.startOfBroadcastWeek(o, this) : startOfBroadcastWeek(o, this);
95965
+ }, this.startOfDay = (o) => {
95966
+ var l;
95967
+ return (l = this.overrides) != null && l.startOfDay ? this.overrides.startOfDay(o) : startOfDay(o);
95968
+ }, this.startOfISOWeek = (o) => {
95969
+ var l;
95970
+ return (l = this.overrides) != null && l.startOfISOWeek ? this.overrides.startOfISOWeek(o) : startOfISOWeek(o);
95971
+ }, this.startOfMonth = (o) => {
95972
+ var l;
95973
+ return (l = this.overrides) != null && l.startOfMonth ? this.overrides.startOfMonth(o) : startOfMonth(o);
95974
+ }, this.startOfWeek = (o, l) => {
95975
+ var d;
95976
+ return (d = this.overrides) != null && d.startOfWeek ? this.overrides.startOfWeek(o, this.options) : startOfWeek(o, this.options);
95977
+ }, this.startOfYear = (o) => {
95978
+ var l;
95979
+ return (l = this.overrides) != null && l.startOfYear ? this.overrides.startOfYear(o) : startOfYear(o);
95980
+ }, this.options = { locale: enUS, ...e }, this.overrides = n;
96352
95981
  }
96353
- );
96354
- Treemap.displayName = "Treemap";
96355
- const TopPercentTreemap = ({
96356
- data: t,
96357
- topPercent: e = 80,
96358
- title: n,
96359
- loading: o,
96360
- ...l
96361
- }) => {
96362
- const d = React.useMemo(() => {
96363
- if (!t || t.length === 0)
96364
- return [["ID", "Parent", "Value"], ["Root", null, 0]];
96365
- const g = [...t].sort((A, I) => I.value - A.value), S = g.reduce((A, I) => A + I.value, 0) * (e / 100), _ = [
96366
- ["ID", "Parent", "Value"],
96367
- ["Root", null, 0]
96368
- ], C = [], E = [];
96369
- let R = 0;
96370
- for (const A of g)
96371
- R < S ? (C.push(A), R += A.value) : E.push(A);
96372
- if (C.forEach((A) => {
96373
- _.push([A.name, "Root", A.value]);
96374
- }), E.length > 0) {
96375
- const A = `More... (${E.length} items)`;
96376
- _.push([A, "Root", 0]), E.forEach((I) => {
96377
- _.push([I.name, A, I.value]);
96378
- });
96379
- }
96380
- return _;
96381
- }, [t, e]), f = React.useMemo(() => ({
96382
- title: n,
96383
- maxDepth: 1,
96384
- backgroundColor: "hsl(var(--background))"
96385
- }), [n]);
96386
- return /* @__PURE__ */ jsx(
96387
- Treemap,
96388
- {
96389
- data: d,
96390
- options: f,
96391
- className: cn("h-full", l.className),
96392
- loading: o,
96393
- disableClick: !1,
96394
- ...l
96395
- }
96396
- );
96397
- }, SearchPage = ({
96398
- query: t,
96399
- results: e,
96400
- isLoading: n,
96401
- children: o
96402
- }) => n ? /* @__PURE__ */ jsx("div", { className: "flex w-full justify-center items-center py-24", children: /* @__PURE__ */ jsx(LoaderCircle, { className: "h-8 w-8 animate-spin text-muted-foreground" }) }) : t && e.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex w-full justify-center items-start pt-16", children: /* @__PURE__ */ jsx(Card, { className: "w-full max-w-lg", children: /* @__PURE__ */ jsxs(CardHeader, { className: "text-center items-center", children: [
96403
- /* @__PURE__ */ jsx("div", { className: "rounded-full border bg-muted p-3 mb-4", children: /* @__PURE__ */ jsx(SearchX, { className: "h-8 w-8 text-muted-foreground" }) }),
96404
- /* @__PURE__ */ jsx(CardTitle, { children: "No Results Found" }),
96405
- /* @__PURE__ */ jsxs(CardDescription, { children: [
96406
- 'Your search for "',
96407
- t,
96408
- '" did not return any results. Please try a different search term.'
96409
- ] })
96410
- ] }) }) }) : e.length > 0 ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-8", children: /* @__PURE__ */ jsx("div", { className: "col-span-3", children: o }) }) : null, colClasses = {
96411
- base: { 1: "grid-cols-1", 2: "grid-cols-2", 3: "grid-cols-3", 4: "grid-cols-4", 5: "grid-cols-5", 6: "grid-cols-6" },
96412
- sm: { 1: "sm:grid-cols-1", 2: "sm:grid-cols-2", 3: "sm:grid-cols-3", 4: "sm:grid-cols-4", 5: "sm:grid-cols-5", 6: "sm:grid-cols-6" },
96413
- md: { 1: "md:grid-cols-1", 2: "md:grid-cols-2", 3: "md:grid-cols-3", 4: "md:grid-cols-4", 5: "md:grid-cols-5", 6: "md:grid-cols-6" },
96414
- lg: { 1: "lg:grid-cols-1", 2: "lg:grid-cols-2", 3: "lg:grid-cols-3", 4: "lg:grid-cols-4", 5: "lg:grid-cols-5", 6: "lg:grid-cols-6" },
96415
- xl: { 1: "xl:grid-cols-1", 2: "xl:grid-cols-2", 3: "xl:grid-cols-3", 4: "xl:grid-cols-4", 5: "xl:grid-cols-5", 6: "xl:grid-cols-6" }
96416
- }, buildGridClassName = (t) => {
96417
- const e = { base: 1, md: 2, ...t };
96418
- return [
96419
- "grid",
96420
- "gap-4",
96421
- e.base ? colClasses.base[e.base] : "",
96422
- e.sm ? colClasses.sm[e.sm] : "",
96423
- e.md ? colClasses.md[e.md] : "",
96424
- e.lg ? colClasses.lg[e.lg] : "",
96425
- e.xl ? colClasses.xl[e.xl] : ""
96426
- ].filter(Boolean).join(" ");
96427
- }, SearchPageGrid = ({
96428
- results: t,
96429
- groupBy: e,
96430
- renderItem: n
96431
- }) => {
96432
- const o = e(t);
96433
- return /* @__PURE__ */ jsx(Fragment$1, { children: Object.entries(o).map(([l, d]) => {
96434
- const { items: f, gridCols: g } = d;
96435
- if (f.length === 0)
96436
- return null;
96437
- const b = buildGridClassName(g);
96438
- return /* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
96439
- /* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold tracking-tight mb-4", children: l }),
96440
- /* @__PURE__ */ jsx("div", { className: b, children: f.map((S, _) => n(S, _)) })
96441
- ] }, l);
96442
- }) });
96443
- };
96444
- var COLLAPSIBLE_NAME = "Collapsible", [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME), [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME), Collapsible = React.forwardRef(
96445
- (t, e) => {
96446
- const {
96447
- __scopeCollapsible: n,
96448
- open: o,
96449
- defaultOpen: l,
96450
- disabled: d,
96451
- onOpenChange: f,
96452
- ...g
96453
- } = t, [b, S] = useControllableState({
96454
- prop: o,
96455
- defaultProp: l ?? !1,
96456
- onChange: f,
96457
- caller: COLLAPSIBLE_NAME
96458
- });
96459
- return /* @__PURE__ */ jsx(
96460
- CollapsibleProvider,
96461
- {
96462
- scope: n,
96463
- disabled: d,
96464
- contentId: useId(),
96465
- open: b,
96466
- onOpenToggle: React.useCallback(() => S((_) => !_), [S]),
96467
- children: /* @__PURE__ */ jsx(
96468
- Primitive.div,
96469
- {
96470
- "data-state": getState$1(b),
96471
- "data-disabled": d ? "" : void 0,
96472
- ...g,
96473
- ref: e
96474
- }
96475
- )
96476
- }
96477
- );
95982
+ /**
95983
+ * Generates a mapping of Arabic digits (0-9) to the target numbering system
95984
+ * digits.
95985
+ *
95986
+ * @since 9.5.0
95987
+ * @returns A record mapping Arabic digits to the target numerals.
95988
+ */
95989
+ getDigitMap() {
95990
+ const { numerals: e = "latn" } = this.options, n = new Intl.NumberFormat("en-US", {
95991
+ numberingSystem: e
95992
+ }), o = {};
95993
+ for (let l = 0; l < 10; l++)
95994
+ o[l.toString()] = n.format(l);
95995
+ return o;
96478
95996
  }
96479
- );
96480
- Collapsible.displayName = COLLAPSIBLE_NAME;
96481
- var TRIGGER_NAME$1 = "CollapsibleTrigger", CollapsibleTrigger = React.forwardRef(
96482
- (t, e) => {
96483
- const { __scopeCollapsible: n, ...o } = t, l = useCollapsibleContext(TRIGGER_NAME$1, n);
96484
- return /* @__PURE__ */ jsx(
96485
- Primitive.button,
96486
- {
96487
- type: "button",
96488
- "aria-controls": l.contentId,
96489
- "aria-expanded": l.open || !1,
96490
- "data-state": getState$1(l.open),
96491
- "data-disabled": l.disabled ? "" : void 0,
96492
- disabled: l.disabled,
96493
- ...o,
96494
- ref: e,
96495
- onClick: composeEventHandlers(t.onClick, l.onOpenToggle)
96496
- }
96497
- );
95997
+ /**
95998
+ * Replaces Arabic digits in a string with the target numbering system digits.
95999
+ *
96000
+ * @since 9.5.0
96001
+ * @param input The string containing Arabic digits.
96002
+ * @returns The string with digits replaced.
96003
+ */
96004
+ replaceDigits(e) {
96005
+ const n = this.getDigitMap();
96006
+ return e.replace(/\d/g, (o) => n[o] || o);
96498
96007
  }
96499
- );
96500
- CollapsibleTrigger.displayName = TRIGGER_NAME$1;
96501
- var CONTENT_NAME$1 = "CollapsibleContent", CollapsibleContent = React.forwardRef(
96502
- (t, e) => {
96503
- const { forceMount: n, ...o } = t, l = useCollapsibleContext(CONTENT_NAME$1, t.__scopeCollapsible);
96504
- return /* @__PURE__ */ jsx(Presence, { present: n || l.open, children: ({ present: d }) => /* @__PURE__ */ jsx(CollapsibleContentImpl, { ...o, ref: e, present: d }) });
96008
+ /**
96009
+ * Formats a number using the configured numbering system.
96010
+ *
96011
+ * @since 9.5.0
96012
+ * @param value The number to format.
96013
+ * @returns The formatted number as a string.
96014
+ */
96015
+ formatNumber(e) {
96016
+ return this.replaceDigits(e.toString());
96505
96017
  }
96506
- );
96507
- CollapsibleContent.displayName = CONTENT_NAME$1;
96508
- var CollapsibleContentImpl = React.forwardRef((t, e) => {
96509
- const { __scopeCollapsible: n, present: o, children: l, ...d } = t, f = useCollapsibleContext(CONTENT_NAME$1, n), [g, b] = React.useState(o), S = React.useRef(null), _ = useComposedRefs(e, S), C = React.useRef(0), E = C.current, R = React.useRef(0), A = R.current, I = f.open || g, M = React.useRef(I), V = React.useRef(void 0);
96510
- return React.useEffect(() => {
96511
- const j = requestAnimationFrame(() => M.current = !1);
96512
- return () => cancelAnimationFrame(j);
96513
- }, []), useLayoutEffect2(() => {
96514
- const j = S.current;
96515
- if (j) {
96516
- V.current = V.current || {
96517
- transitionDuration: j.style.transitionDuration,
96518
- animationName: j.style.animationName
96519
- }, j.style.transitionDuration = "0s", j.style.animationName = "none";
96520
- const z = j.getBoundingClientRect();
96521
- C.current = z.height, R.current = z.width, M.current || (j.style.transitionDuration = V.current.transitionDuration, j.style.animationName = V.current.animationName), b(o);
96522
- }
96523
- }, [f.open, o]), /* @__PURE__ */ jsx(
96524
- Primitive.div,
96525
- {
96526
- "data-state": getState$1(f.open),
96527
- "data-disabled": f.disabled ? "" : void 0,
96528
- id: f.contentId,
96529
- hidden: !I,
96530
- ...d,
96531
- ref: _,
96532
- style: {
96533
- "--radix-collapsible-content-height": E ? `${E}px` : void 0,
96534
- "--radix-collapsible-content-width": A ? `${A}px` : void 0,
96535
- ...t.style
96536
- },
96537
- children: I && l
96538
- }
96539
- );
96540
- });
96541
- function getState$1(t) {
96542
- return t ? "open" : "closed";
96543
- }
96544
- var Root$1 = Collapsible, Trigger = CollapsibleTrigger, Content = CollapsibleContent, ACCORDION_NAME = "Accordion", ACCORDION_KEYS = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"], [Collection, useCollection, createCollectionScope] = createCollection(ACCORDION_NAME), [createAccordionContext] = createContextScope(ACCORDION_NAME, [
96545
- createCollectionScope,
96546
- createCollapsibleScope
96547
- ]), useCollapsibleScope = createCollapsibleScope(), Accordion$1 = React__default.forwardRef(
96548
- (t, e) => {
96549
- const { type: n, ...o } = t, l = o, d = o;
96550
- return /* @__PURE__ */ jsx(Collection.Provider, { scope: t.__scopeAccordion, children: n === "multiple" ? /* @__PURE__ */ jsx(AccordionImplMultiple, { ...d, ref: e }) : /* @__PURE__ */ jsx(AccordionImplSingle, { ...l, ref: e }) });
96018
+ /**
96019
+ * Returns the preferred ordering for month and year labels for the current
96020
+ * locale.
96021
+ */
96022
+ getMonthYearOrder() {
96023
+ var n;
96024
+ const e = (n = this.options.locale) == null ? void 0 : n.code;
96025
+ return e && DateLib.yearFirstLocales.has(e) ? "year-first" : "month-first";
96551
96026
  }
96552
- );
96553
- Accordion$1.displayName = ACCORDION_NAME;
96554
- var [AccordionValueProvider, useAccordionValueContext] = createAccordionContext(ACCORDION_NAME), [AccordionCollapsibleProvider, useAccordionCollapsibleContext] = createAccordionContext(
96555
- ACCORDION_NAME,
96556
- { collapsible: !1 }
96557
- ), AccordionImplSingle = React__default.forwardRef(
96558
- (t, e) => {
96559
- const {
96560
- value: n,
96561
- defaultValue: o,
96562
- onValueChange: l = () => {
96563
- },
96564
- collapsible: d = !1,
96565
- ...f
96566
- } = t, [g, b] = useControllableState({
96567
- prop: n,
96568
- defaultProp: o ?? "",
96569
- onChange: l,
96570
- caller: ACCORDION_NAME
96571
- });
96572
- return /* @__PURE__ */ jsx(
96573
- AccordionValueProvider,
96574
- {
96575
- scope: t.__scopeAccordion,
96576
- value: React__default.useMemo(() => g ? [g] : [], [g]),
96577
- onItemOpen: b,
96578
- onItemClose: React__default.useCallback(() => d && b(""), [d, b]),
96579
- children: /* @__PURE__ */ jsx(AccordionCollapsibleProvider, { scope: t.__scopeAccordion, collapsible: d, children: /* @__PURE__ */ jsx(AccordionImpl, { ...f, ref: e }) })
96027
+ /**
96028
+ * Formats the month/year pair respecting locale conventions.
96029
+ *
96030
+ * @since 9.11.0
96031
+ */
96032
+ formatMonthYear(e) {
96033
+ const { locale: n, timeZone: o, numerals: l } = this.options, d = n == null ? void 0 : n.code;
96034
+ if (d && DateLib.yearFirstLocales.has(d))
96035
+ try {
96036
+ return new Intl.DateTimeFormat(d, {
96037
+ month: "long",
96038
+ year: "numeric",
96039
+ timeZone: o,
96040
+ numberingSystem: l
96041
+ }).format(e);
96042
+ } catch {
96580
96043
  }
96581
- );
96044
+ const f = this.getMonthYearOrder() === "year-first" ? "y LLLL" : "LLLL y";
96045
+ return this.format(e, f);
96582
96046
  }
96583
- ), AccordionImplMultiple = React__default.forwardRef((t, e) => {
96584
- const {
96585
- value: n,
96586
- defaultValue: o,
96587
- onValueChange: l = () => {
96588
- },
96589
- ...d
96590
- } = t, [f, g] = useControllableState({
96591
- prop: n,
96592
- defaultProp: o ?? [],
96593
- onChange: l,
96594
- caller: ACCORDION_NAME
96595
- }), b = React__default.useCallback(
96596
- (_) => g((C = []) => [...C, _]),
96597
- [g]
96598
- ), S = React__default.useCallback(
96599
- (_) => g((C = []) => C.filter((E) => E !== _)),
96600
- [g]
96601
- );
96602
- return /* @__PURE__ */ jsx(
96603
- AccordionValueProvider,
96604
- {
96605
- scope: t.__scopeAccordion,
96606
- value: f,
96607
- onItemOpen: b,
96608
- onItemClose: S,
96609
- children: /* @__PURE__ */ jsx(AccordionCollapsibleProvider, { scope: t.__scopeAccordion, collapsible: !0, children: /* @__PURE__ */ jsx(AccordionImpl, { ...d, ref: e }) })
96610
- }
96611
- );
96612
- }), [AccordionImplProvider, useAccordionContext] = createAccordionContext(ACCORDION_NAME), AccordionImpl = React__default.forwardRef(
96613
- (t, e) => {
96614
- const { __scopeAccordion: n, disabled: o, dir: l, orientation: d = "vertical", ...f } = t, g = React__default.useRef(null), b = useComposedRefs(g, e), S = useCollection(n), C = useDirection(l) === "ltr", E = composeEventHandlers(t.onKeyDown, (R) => {
96615
- var ne;
96616
- if (!ACCORDION_KEYS.includes(R.key)) return;
96617
- const A = R.target, I = S().filter((ae) => {
96618
- var $e;
96619
- return !(($e = ae.ref.current) != null && $e.disabled);
96620
- }), M = I.findIndex((ae) => ae.ref.current === A), V = I.length;
96621
- if (M === -1) return;
96622
- R.preventDefault();
96623
- let j = M;
96624
- const z = 0, Q = V - 1, O = () => {
96625
- j = M + 1, j > Q && (j = z);
96626
- }, F = () => {
96627
- j = M - 1, j < z && (j = Q);
96628
- };
96629
- switch (R.key) {
96630
- case "Home":
96631
- j = z;
96632
- break;
96633
- case "End":
96634
- j = Q;
96635
- break;
96636
- case "ArrowRight":
96637
- d === "horizontal" && (C ? O() : F());
96638
- break;
96639
- case "ArrowDown":
96640
- d === "vertical" && O();
96641
- break;
96642
- case "ArrowLeft":
96643
- d === "horizontal" && (C ? F() : O());
96644
- break;
96645
- case "ArrowUp":
96646
- d === "vertical" && F();
96647
- break;
96648
- }
96649
- const te = j % V;
96650
- (ne = I[te].ref.current) == null || ne.focus();
96651
- });
96652
- return /* @__PURE__ */ jsx(
96653
- AccordionImplProvider,
96654
- {
96655
- scope: n,
96656
- disabled: o,
96657
- direction: l,
96658
- orientation: d,
96659
- children: /* @__PURE__ */ jsx(Collection.Slot, { scope: n, children: /* @__PURE__ */ jsx(
96660
- Primitive.div,
96661
- {
96662
- ...f,
96663
- "data-orientation": d,
96664
- ref: b,
96665
- onKeyDown: o ? void 0 : E
96666
- }
96667
- ) })
96668
- }
96669
- );
96670
- }
96671
- ), ITEM_NAME = "AccordionItem", [AccordionItemProvider, useAccordionItemContext] = createAccordionContext(ITEM_NAME), AccordionItem$1 = React__default.forwardRef(
96672
- (t, e) => {
96673
- const { __scopeAccordion: n, value: o, ...l } = t, d = useAccordionContext(ITEM_NAME, n), f = useAccordionValueContext(ITEM_NAME, n), g = useCollapsibleScope(n), b = useId(), S = o && f.value.includes(o) || !1, _ = d.disabled || t.disabled;
96674
- return /* @__PURE__ */ jsx(
96675
- AccordionItemProvider,
96676
- {
96677
- scope: n,
96678
- open: S,
96679
- disabled: _,
96680
- triggerId: b,
96681
- children: /* @__PURE__ */ jsx(
96682
- Root$1,
96683
- {
96684
- "data-orientation": d.orientation,
96685
- "data-state": getState(S),
96686
- ...g,
96687
- ...l,
96688
- ref: e,
96689
- disabled: _,
96690
- open: S,
96691
- onOpenChange: (C) => {
96692
- C ? f.onItemOpen(o) : f.onItemClose(o);
96693
- }
96694
- }
96695
- )
96696
- }
96697
- );
96698
- }
96699
- );
96700
- AccordionItem$1.displayName = ITEM_NAME;
96701
- var HEADER_NAME = "AccordionHeader", AccordionHeader = React__default.forwardRef(
96702
- (t, e) => {
96703
- const { __scopeAccordion: n, ...o } = t, l = useAccordionContext(ACCORDION_NAME, n), d = useAccordionItemContext(HEADER_NAME, n);
96704
- return /* @__PURE__ */ jsx(
96705
- Primitive.h3,
96706
- {
96707
- "data-orientation": l.orientation,
96708
- "data-state": getState(d.open),
96709
- "data-disabled": d.disabled ? "" : void 0,
96710
- ...o,
96711
- ref: e
96712
- }
96713
- );
96714
- }
96715
- );
96716
- AccordionHeader.displayName = HEADER_NAME;
96717
- var TRIGGER_NAME = "AccordionTrigger", AccordionTrigger$1 = React__default.forwardRef(
96718
- (t, e) => {
96719
- const { __scopeAccordion: n, ...o } = t, l = useAccordionContext(ACCORDION_NAME, n), d = useAccordionItemContext(TRIGGER_NAME, n), f = useAccordionCollapsibleContext(TRIGGER_NAME, n), g = useCollapsibleScope(n);
96720
- return /* @__PURE__ */ jsx(Collection.ItemSlot, { scope: n, children: /* @__PURE__ */ jsx(
96721
- Trigger,
96722
- {
96723
- "aria-disabled": d.open && !f.collapsible || void 0,
96724
- "data-orientation": l.orientation,
96725
- id: d.triggerId,
96726
- ...g,
96727
- ...o,
96728
- ref: e
96729
- }
96730
- ) });
96731
- }
96732
- );
96733
- AccordionTrigger$1.displayName = TRIGGER_NAME;
96734
- var CONTENT_NAME = "AccordionContent", AccordionContent$1 = React__default.forwardRef(
96735
- (t, e) => {
96736
- const { __scopeAccordion: n, ...o } = t, l = useAccordionContext(ACCORDION_NAME, n), d = useAccordionItemContext(CONTENT_NAME, n), f = useCollapsibleScope(n);
96737
- return /* @__PURE__ */ jsx(
96738
- Content,
96739
- {
96740
- role: "region",
96741
- "aria-labelledby": d.triggerId,
96742
- "data-orientation": l.orientation,
96743
- ...f,
96744
- ...o,
96745
- ref: e,
96746
- style: {
96747
- "--radix-accordion-content-height": "var(--radix-collapsible-content-height)",
96748
- "--radix-accordion-content-width": "var(--radix-collapsible-content-width)",
96749
- ...t.style
96750
- }
96751
- }
96752
- );
96753
- }
96754
- );
96755
- AccordionContent$1.displayName = CONTENT_NAME;
96756
- function getState(t) {
96757
- return t ? "open" : "closed";
96758
96047
  }
96759
- var Root2 = Accordion$1, Item = AccordionItem$1, Header = AccordionHeader, Trigger2 = AccordionTrigger$1, Content2 = AccordionContent$1;
96760
- const Accordion = Root2, AccordionItem = React.forwardRef(({ className: t, ...e }, n) => /* @__PURE__ */ jsx(
96761
- Item,
96762
- {
96763
- ref: n,
96764
- className: cn("border-b", t),
96765
- ...e
96048
+ DateLib.yearFirstLocales = /* @__PURE__ */ new Set([
96049
+ "eu",
96050
+ "hu",
96051
+ "ja",
96052
+ "ja-Hira",
96053
+ "ja-JP",
96054
+ "ko",
96055
+ "ko-KR",
96056
+ "lt",
96057
+ "lt-LT",
96058
+ "lv",
96059
+ "lv-LV",
96060
+ "mn",
96061
+ "mn-MN",
96062
+ "zh",
96063
+ "zh-CN",
96064
+ "zh-HK",
96065
+ "zh-TW"
96066
+ ]);
96067
+ const defaultDateLib = new DateLib();
96068
+ class CalendarDay {
96069
+ constructor(e, n, o = defaultDateLib) {
96070
+ this.date = e, this.displayMonth = n, this.outside = !!(n && !o.isSameMonth(e, n)), this.dateLib = o;
96766
96071
  }
96767
- ));
96768
- AccordionItem.displayName = "AccordionItem";
96769
- const AccordionTrigger = React.forwardRef(({ className: t, children: e, ...n }, o) => /* @__PURE__ */ jsx(Header, { className: "flex", children: /* @__PURE__ */ jsxs(
96770
- Trigger2,
96771
- {
96772
- ref: o,
96773
- className: cn(
96774
- "flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",
96775
- t
96776
- ),
96777
- ...n,
96778
- children: [
96779
- e,
96780
- /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" })
96781
- ]
96072
+ /**
96073
+ * Checks if this day is equal to another `CalendarDay`, considering both the
96074
+ * date and the displayed month.
96075
+ *
96076
+ * @param day The `CalendarDay` to compare with.
96077
+ * @returns `true` if the days are equal, otherwise `false`.
96078
+ */
96079
+ isEqualTo(e) {
96080
+ return this.dateLib.isSameDay(e.date, this.date) && this.dateLib.isSameMonth(e.displayMonth, this.displayMonth);
96782
96081
  }
96783
- ) }));
96784
- AccordionTrigger.displayName = Trigger2.displayName;
96785
- const AccordionContent = React.forwardRef(({ className: t, children: e, ...n }, o) => /* @__PURE__ */ jsx(
96786
- Content2,
96787
- {
96788
- ref: o,
96789
- className: "overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",
96790
- ...n,
96791
- children: /* @__PURE__ */ jsx("div", { className: cn("pb-4 pt-0", t), children: e })
96082
+ }
96083
+ class CalendarMonth {
96084
+ constructor(e, n) {
96085
+ this.date = e, this.weeks = n;
96792
96086
  }
96793
- ));
96794
- AccordionContent.displayName = Content2.displayName;
96795
- function tzName(t, e, n = "long") {
96796
- return new Intl.DateTimeFormat("en-US", {
96797
- // Enforces engine to render the time. Without the option JavaScriptCore omits it.
96798
- hour: "numeric",
96799
- timeZone: t,
96800
- timeZoneName: n
96801
- }).format(e).split(/\s/g).slice(2).join(" ");
96802
96087
  }
96803
- const offsetFormatCache = {}, offsetCache = {};
96804
- function tzOffset(t, e) {
96805
- try {
96806
- const o = (offsetFormatCache[t] || (offsetFormatCache[t] = new Intl.DateTimeFormat("en-US", {
96807
- timeZone: t,
96808
- timeZoneName: "longOffset"
96809
- }).format))(e).split("GMT")[1];
96810
- return o in offsetCache ? offsetCache[o] : calcOffset(o, o.split(":"));
96811
- } catch {
96812
- if (t in offsetCache) return offsetCache[t];
96813
- const n = t == null ? void 0 : t.match(offsetRe);
96814
- return n ? calcOffset(t, n.slice(1)) : NaN;
96088
+ class CalendarWeek {
96089
+ constructor(e, n) {
96090
+ this.days = n, this.weekNumber = e;
96815
96091
  }
96816
96092
  }
96817
- const offsetRe = /([+-]\d\d):?(\d\d)?/;
96818
- function calcOffset(t, e) {
96819
- const n = +(e[0] || 0), o = +(e[1] || 0), l = +(e[2] || 0) / 60;
96820
- return offsetCache[t] = n * 60 + o > 0 ? n * 60 + o + l : n * 60 - o - l;
96093
+ function Button(t) {
96094
+ return React__default.createElement("button", { ...t });
96821
96095
  }
96822
- class TZDateMini extends Date {
96823
- //#region static
96824
- constructor(...e) {
96825
- super(), e.length > 1 && typeof e[e.length - 1] == "string" && (this.timeZone = e.pop()), this.internal = /* @__PURE__ */ new Date(), isNaN(tzOffset(this.timeZone, this)) ? this.setTime(NaN) : e.length ? typeof e[0] == "number" && (e.length === 1 || e.length === 2 && typeof e[1] != "number") ? this.setTime(e[0]) : typeof e[0] == "string" ? this.setTime(+new Date(e[0])) : e[0] instanceof Date ? this.setTime(+e[0]) : (this.setTime(+new Date(...e)), adjustToSystemTZ(this), syncToInternal(this)) : this.setTime(Date.now());
96826
- }
96827
- static tz(e, ...n) {
96828
- return n.length ? new TZDateMini(...n, e) : new TZDateMini(Date.now(), e);
96829
- }
96830
- //#endregion
96831
- //#region time zone
96832
- withTimeZone(e) {
96833
- return new TZDateMini(+this, e);
96834
- }
96835
- getTimezoneOffset() {
96836
- const e = -tzOffset(this.timeZone, this);
96837
- return e > 0 ? Math.floor(e) : Math.ceil(e);
96838
- }
96839
- //#endregion
96840
- //#region time
96841
- setTime(e) {
96842
- return Date.prototype.setTime.apply(this, arguments), syncToInternal(this), +this;
96843
- }
96844
- //#endregion
96845
- //#region date-fns integration
96846
- [Symbol.for("constructDateFrom")](e) {
96847
- return new TZDateMini(+new Date(e), this.timeZone);
96848
- }
96849
- //#endregion
96096
+ function CaptionLabel(t) {
96097
+ return React__default.createElement("span", { ...t });
96850
96098
  }
96851
- const re = /^(get|set)(?!UTC)/;
96852
- Object.getOwnPropertyNames(Date.prototype).forEach((t) => {
96853
- if (!re.test(t)) return;
96854
- const e = t.replace(re, "$1UTC");
96855
- TZDateMini.prototype[e] && (t.startsWith("get") ? TZDateMini.prototype[t] = function() {
96856
- return this.internal[e]();
96857
- } : (TZDateMini.prototype[t] = function() {
96858
- return Date.prototype[e].apply(this.internal, arguments), syncFromInternal(this), +this;
96859
- }, TZDateMini.prototype[e] = function() {
96860
- return Date.prototype[e].apply(this, arguments), syncToInternal(this), +this;
96861
- }));
96862
- });
96863
- function syncToInternal(t) {
96864
- t.internal.setTime(+t), t.internal.setUTCSeconds(t.internal.getUTCSeconds() - Math.round(-tzOffset(t.timeZone, t) * 60));
96099
+ function Chevron(t) {
96100
+ const { size: e = 24, orientation: n = "left", className: o } = t;
96101
+ return (
96102
+ // biome-ignore lint/a11y/noSvgWithoutTitle: handled by the parent component
96103
+ React__default.createElement(
96104
+ "svg",
96105
+ { className: o, width: e, height: e, viewBox: "0 0 24 24" },
96106
+ n === "up" && React__default.createElement("polygon", { points: "6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28" }),
96107
+ n === "down" && React__default.createElement("polygon", { points: "6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72" }),
96108
+ n === "left" && React__default.createElement("polygon", { points: "16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20" }),
96109
+ n === "right" && React__default.createElement("polygon", { points: "8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20" })
96110
+ )
96111
+ );
96865
96112
  }
96866
- function syncFromInternal(t) {
96867
- Date.prototype.setFullYear.call(t, t.internal.getUTCFullYear(), t.internal.getUTCMonth(), t.internal.getUTCDate()), Date.prototype.setHours.call(t, t.internal.getUTCHours(), t.internal.getUTCMinutes(), t.internal.getUTCSeconds(), t.internal.getUTCMilliseconds()), adjustToSystemTZ(t);
96113
+ function Day(t) {
96114
+ const { day: e, modifiers: n, ...o } = t;
96115
+ return React__default.createElement("td", { ...o });
96868
96116
  }
96869
- function adjustToSystemTZ(t) {
96870
- const e = tzOffset(t.timeZone, t), n = e > 0 ? Math.floor(e) : Math.ceil(e), o = /* @__PURE__ */ new Date(+t);
96871
- o.setUTCHours(o.getUTCHours() - 1);
96872
- const l = -(/* @__PURE__ */ new Date(+t)).getTimezoneOffset(), d = -(/* @__PURE__ */ new Date(+o)).getTimezoneOffset(), f = l - d, g = Date.prototype.getHours.apply(t) !== t.internal.getUTCHours();
96873
- f && g && t.internal.setUTCMinutes(t.internal.getUTCMinutes() + f);
96874
- const b = l - n;
96875
- b && Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + b);
96876
- const S = /* @__PURE__ */ new Date(+t);
96877
- S.setUTCSeconds(0);
96878
- const _ = l > 0 ? S.getSeconds() : (S.getSeconds() - 60) % 60, C = Math.round(-(tzOffset(t.timeZone, t) * 60)) % 60;
96879
- (C || _) && (t.internal.setUTCSeconds(t.internal.getUTCSeconds() + C), Date.prototype.setUTCSeconds.call(t, Date.prototype.getUTCSeconds.call(t) + C + _));
96880
- const E = tzOffset(t.timeZone, t), R = E > 0 ? Math.floor(E) : Math.ceil(E), I = -(/* @__PURE__ */ new Date(+t)).getTimezoneOffset() - R, M = R !== n, V = I - b;
96881
- if (M && V) {
96882
- Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + V);
96883
- const j = tzOffset(t.timeZone, t), z = j > 0 ? Math.floor(j) : Math.ceil(j), Q = R - z;
96884
- Q && (t.internal.setUTCMinutes(t.internal.getUTCMinutes() + Q), Date.prototype.setUTCMinutes.call(t, Date.prototype.getUTCMinutes.call(t) + Q));
96885
- }
96117
+ function DayButton(t) {
96118
+ const { day: e, modifiers: n, ...o } = t, l = React__default.useRef(null);
96119
+ return React__default.useEffect(() => {
96120
+ var d;
96121
+ n.focused && ((d = l.current) == null || d.focus());
96122
+ }, [n.focused]), React__default.createElement("button", { ref: l, ...o });
96886
96123
  }
96887
- class TZDate extends TZDateMini {
96888
- //#region static
96889
- static tz(e, ...n) {
96890
- return n.length ? new TZDate(...n, e) : new TZDate(Date.now(), e);
96891
- }
96892
- //#endregion
96893
- //#region representation
96894
- toISOString() {
96895
- const [e, n, o] = this.tzComponents(), l = `${e}${n}:${o}`;
96896
- return this.internal.toISOString().slice(0, -1) + l;
96897
- }
96898
- toString() {
96899
- return `${this.toDateString()} ${this.toTimeString()}`;
96900
- }
96901
- toDateString() {
96902
- const [e, n, o, l] = this.internal.toUTCString().split(" ");
96903
- return `${e == null ? void 0 : e.slice(0, -1)} ${o} ${n} ${l}`;
96904
- }
96905
- toTimeString() {
96906
- const e = this.internal.toUTCString().split(" ")[4], [n, o, l] = this.tzComponents();
96907
- return `${e} GMT${n}${o}${l} (${tzName(this.timeZone, this)})`;
96908
- }
96909
- toLocaleString(e, n) {
96910
- return Date.prototype.toLocaleString.call(this, e, {
96911
- ...n,
96912
- timeZone: (n == null ? void 0 : n.timeZone) || this.timeZone
96913
- });
96914
- }
96915
- toLocaleDateString(e, n) {
96916
- return Date.prototype.toLocaleDateString.call(this, e, {
96917
- ...n,
96918
- timeZone: (n == null ? void 0 : n.timeZone) || this.timeZone
96919
- });
96920
- }
96921
- toLocaleTimeString(e, n) {
96922
- return Date.prototype.toLocaleTimeString.call(this, e, {
96923
- ...n,
96924
- timeZone: (n == null ? void 0 : n.timeZone) || this.timeZone
96925
- });
96926
- }
96927
- //#endregion
96928
- //#region private
96929
- tzComponents() {
96930
- const e = this.getTimezoneOffset(), n = e > 0 ? "-" : "+", o = String(Math.floor(Math.abs(e) / 60)).padStart(2, "0"), l = String(Math.abs(e) % 60).padStart(2, "0");
96931
- return [n, o, l];
96932
- }
96933
- //#endregion
96934
- withTimeZone(e) {
96935
- return new TZDate(+this, e);
96936
- }
96937
- //#region date-fns integration
96938
- [Symbol.for("constructDateFrom")](e) {
96939
- return new TZDate(+new Date(e), this.timeZone);
96940
- }
96941
- //#endregion
96124
+ var UI;
96125
+ (function(t) {
96126
+ t.Root = "root", t.Chevron = "chevron", t.Day = "day", t.DayButton = "day_button", t.CaptionLabel = "caption_label", t.Dropdowns = "dropdowns", t.Dropdown = "dropdown", t.DropdownRoot = "dropdown_root", t.Footer = "footer", t.MonthGrid = "month_grid", t.MonthCaption = "month_caption", t.MonthsDropdown = "months_dropdown", t.Month = "month", t.Months = "months", t.Nav = "nav", t.NextMonthButton = "button_next", t.PreviousMonthButton = "button_previous", t.Week = "week", t.Weeks = "weeks", t.Weekday = "weekday", t.Weekdays = "weekdays", t.WeekNumber = "week_number", t.WeekNumberHeader = "week_number_header", t.YearsDropdown = "years_dropdown";
96127
+ })(UI || (UI = {}));
96128
+ var DayFlag;
96129
+ (function(t) {
96130
+ t.disabled = "disabled", t.hidden = "hidden", t.outside = "outside", t.focused = "focused", t.today = "today";
96131
+ })(DayFlag || (DayFlag = {}));
96132
+ var SelectionState;
96133
+ (function(t) {
96134
+ t.range_end = "range_end", t.range_middle = "range_middle", t.range_start = "range_start", t.selected = "selected";
96135
+ })(SelectionState || (SelectionState = {}));
96136
+ var Animation;
96137
+ (function(t) {
96138
+ t.weeks_before_enter = "weeks_before_enter", t.weeks_before_exit = "weeks_before_exit", t.weeks_after_enter = "weeks_after_enter", t.weeks_after_exit = "weeks_after_exit", t.caption_after_enter = "caption_after_enter", t.caption_after_exit = "caption_after_exit", t.caption_before_enter = "caption_before_enter", t.caption_before_exit = "caption_before_exit";
96139
+ })(Animation || (Animation = {}));
96140
+ function Dropdown(t) {
96141
+ const { options: e, className: n, components: o, classNames: l, ...d } = t, f = [l[UI.Dropdown], n].join(" "), g = e == null ? void 0 : e.find(({ value: b }) => b === d.value);
96142
+ return React__default.createElement(
96143
+ "span",
96144
+ { "data-disabled": d.disabled, className: l[UI.DropdownRoot] },
96145
+ React__default.createElement(o.Select, { className: f, ...d }, e == null ? void 0 : e.map(({ value: b, label: S, disabled: _ }) => React__default.createElement(o.Option, { key: b, value: b, disabled: _ }, S))),
96146
+ React__default.createElement(
96147
+ "span",
96148
+ { className: l[UI.CaptionLabel], "aria-hidden": !0 },
96149
+ g == null ? void 0 : g.label,
96150
+ React__default.createElement(o.Chevron, { orientation: "down", size: 18, className: l[UI.Chevron] })
96151
+ )
96152
+ );
96942
96153
  }
96943
- const FIVE_WEEKS = 5, FOUR_WEEKS = 4;
96944
- function getBroadcastWeeksInMonth(t, e) {
96945
- const n = e.startOfMonth(t), o = n.getDay() > 0 ? n.getDay() : 7, l = e.addDays(t, -o + 1), d = e.addDays(l, FIVE_WEEKS * 7 - 1);
96946
- return e.getMonth(t) === e.getMonth(d) ? FIVE_WEEKS : FOUR_WEEKS;
96154
+ function DropdownNav(t) {
96155
+ return React__default.createElement("div", { ...t });
96947
96156
  }
96948
- function startOfBroadcastWeek(t, e) {
96949
- const n = e.startOfMonth(t), o = n.getDay();
96950
- return o === 1 ? n : o === 0 ? e.addDays(n, -6) : e.addDays(n, -1 * (o - 1));
96157
+ function Footer(t) {
96158
+ return React__default.createElement("div", { ...t });
96951
96159
  }
96952
- function endOfBroadcastWeek(t, e) {
96953
- const n = startOfBroadcastWeek(t, e), o = getBroadcastWeeksInMonth(t, e);
96954
- return e.addDays(n, o * 7 - 1);
96955
- }
96956
- class DateLib {
96957
- /**
96958
- * Creates an instance of `DateLib`.
96959
- *
96960
- * @param options Configuration options for the date library.
96961
- * @param overrides Custom overrides for the date library functions.
96962
- */
96963
- constructor(e, n) {
96964
- this.Date = Date, this.today = () => {
96965
- var o;
96966
- return (o = this.overrides) != null && o.today ? this.overrides.today() : this.options.timeZone ? TZDate.tz(this.options.timeZone) : new this.Date();
96967
- }, this.newDate = (o, l, d) => {
96968
- var f;
96969
- return (f = this.overrides) != null && f.newDate ? this.overrides.newDate(o, l, d) : this.options.timeZone ? new TZDate(o, l, d, this.options.timeZone) : new Date(o, l, d);
96970
- }, this.addDays = (o, l) => {
96971
- var d;
96972
- return (d = this.overrides) != null && d.addDays ? this.overrides.addDays(o, l) : addDays(o, l);
96973
- }, this.addMonths = (o, l) => {
96974
- var d;
96975
- return (d = this.overrides) != null && d.addMonths ? this.overrides.addMonths(o, l) : addMonths(o, l);
96976
- }, this.addWeeks = (o, l) => {
96977
- var d;
96978
- return (d = this.overrides) != null && d.addWeeks ? this.overrides.addWeeks(o, l) : addWeeks(o, l);
96979
- }, this.addYears = (o, l) => {
96980
- var d;
96981
- return (d = this.overrides) != null && d.addYears ? this.overrides.addYears(o, l) : addYears(o, l);
96982
- }, this.differenceInCalendarDays = (o, l) => {
96983
- var d;
96984
- return (d = this.overrides) != null && d.differenceInCalendarDays ? this.overrides.differenceInCalendarDays(o, l) : differenceInCalendarDays(o, l);
96985
- }, this.differenceInCalendarMonths = (o, l) => {
96986
- var d;
96987
- return (d = this.overrides) != null && d.differenceInCalendarMonths ? this.overrides.differenceInCalendarMonths(o, l) : differenceInCalendarMonths(o, l);
96988
- }, this.eachMonthOfInterval = (o) => {
96989
- var l;
96990
- return (l = this.overrides) != null && l.eachMonthOfInterval ? this.overrides.eachMonthOfInterval(o) : eachMonthOfInterval(o);
96991
- }, this.endOfBroadcastWeek = (o) => {
96992
- var l;
96993
- return (l = this.overrides) != null && l.endOfBroadcastWeek ? this.overrides.endOfBroadcastWeek(o) : endOfBroadcastWeek(o, this);
96994
- }, this.endOfISOWeek = (o) => {
96995
- var l;
96996
- return (l = this.overrides) != null && l.endOfISOWeek ? this.overrides.endOfISOWeek(o) : endOfISOWeek(o);
96997
- }, this.endOfMonth = (o) => {
96998
- var l;
96999
- return (l = this.overrides) != null && l.endOfMonth ? this.overrides.endOfMonth(o) : endOfMonth(o);
97000
- }, this.endOfWeek = (o, l) => {
97001
- var d;
97002
- return (d = this.overrides) != null && d.endOfWeek ? this.overrides.endOfWeek(o, l) : endOfWeek(o, this.options);
97003
- }, this.endOfYear = (o) => {
97004
- var l;
97005
- return (l = this.overrides) != null && l.endOfYear ? this.overrides.endOfYear(o) : endOfYear(o);
97006
- }, this.format = (o, l, d) => {
97007
- var g;
97008
- const f = (g = this.overrides) != null && g.format ? this.overrides.format(o, l, this.options) : format(o, l, this.options);
97009
- return this.options.numerals && this.options.numerals !== "latn" ? this.replaceDigits(f) : f;
97010
- }, this.getISOWeek = (o) => {
97011
- var l;
97012
- return (l = this.overrides) != null && l.getISOWeek ? this.overrides.getISOWeek(o) : getISOWeek(o);
97013
- }, this.getMonth = (o, l) => {
97014
- var d;
97015
- return (d = this.overrides) != null && d.getMonth ? this.overrides.getMonth(o, this.options) : getMonth(o, this.options);
97016
- }, this.getYear = (o, l) => {
97017
- var d;
97018
- return (d = this.overrides) != null && d.getYear ? this.overrides.getYear(o, this.options) : getYear(o, this.options);
97019
- }, this.getWeek = (o, l) => {
97020
- var d;
97021
- return (d = this.overrides) != null && d.getWeek ? this.overrides.getWeek(o, this.options) : getWeek(o, this.options);
97022
- }, this.isAfter = (o, l) => {
97023
- var d;
97024
- return (d = this.overrides) != null && d.isAfter ? this.overrides.isAfter(o, l) : isAfter(o, l);
97025
- }, this.isBefore = (o, l) => {
97026
- var d;
97027
- return (d = this.overrides) != null && d.isBefore ? this.overrides.isBefore(o, l) : isBefore(o, l);
97028
- }, this.isDate = (o) => {
97029
- var l;
97030
- return (l = this.overrides) != null && l.isDate ? this.overrides.isDate(o) : isDate(o);
97031
- }, this.isSameDay = (o, l) => {
97032
- var d;
97033
- return (d = this.overrides) != null && d.isSameDay ? this.overrides.isSameDay(o, l) : isSameDay(o, l);
97034
- }, this.isSameMonth = (o, l) => {
97035
- var d;
97036
- return (d = this.overrides) != null && d.isSameMonth ? this.overrides.isSameMonth(o, l) : isSameMonth(o, l);
97037
- }, this.isSameYear = (o, l) => {
97038
- var d;
97039
- return (d = this.overrides) != null && d.isSameYear ? this.overrides.isSameYear(o, l) : isSameYear(o, l);
97040
- }, this.max = (o) => {
97041
- var l;
97042
- return (l = this.overrides) != null && l.max ? this.overrides.max(o) : max$1(o);
97043
- }, this.min = (o) => {
97044
- var l;
97045
- return (l = this.overrides) != null && l.min ? this.overrides.min(o) : min$1(o);
97046
- }, this.setMonth = (o, l) => {
97047
- var d;
97048
- return (d = this.overrides) != null && d.setMonth ? this.overrides.setMonth(o, l) : setMonth(o, l);
97049
- }, this.setYear = (o, l) => {
97050
- var d;
97051
- return (d = this.overrides) != null && d.setYear ? this.overrides.setYear(o, l) : setYear(o, l);
97052
- }, this.startOfBroadcastWeek = (o, l) => {
97053
- var d;
97054
- return (d = this.overrides) != null && d.startOfBroadcastWeek ? this.overrides.startOfBroadcastWeek(o, this) : startOfBroadcastWeek(o, this);
97055
- }, this.startOfDay = (o) => {
97056
- var l;
97057
- return (l = this.overrides) != null && l.startOfDay ? this.overrides.startOfDay(o) : startOfDay(o);
97058
- }, this.startOfISOWeek = (o) => {
97059
- var l;
97060
- return (l = this.overrides) != null && l.startOfISOWeek ? this.overrides.startOfISOWeek(o) : startOfISOWeek(o);
97061
- }, this.startOfMonth = (o) => {
97062
- var l;
97063
- return (l = this.overrides) != null && l.startOfMonth ? this.overrides.startOfMonth(o) : startOfMonth(o);
97064
- }, this.startOfWeek = (o, l) => {
97065
- var d;
97066
- return (d = this.overrides) != null && d.startOfWeek ? this.overrides.startOfWeek(o, this.options) : startOfWeek(o, this.options);
97067
- }, this.startOfYear = (o) => {
97068
- var l;
97069
- return (l = this.overrides) != null && l.startOfYear ? this.overrides.startOfYear(o) : startOfYear(o);
97070
- }, this.options = { locale: enUS, ...e }, this.overrides = n;
97071
- }
97072
- /**
97073
- * Generates a mapping of Arabic digits (0-9) to the target numbering system
97074
- * digits.
97075
- *
97076
- * @since 9.5.0
97077
- * @returns A record mapping Arabic digits to the target numerals.
97078
- */
97079
- getDigitMap() {
97080
- const { numerals: e = "latn" } = this.options, n = new Intl.NumberFormat("en-US", {
97081
- numberingSystem: e
97082
- }), o = {};
97083
- for (let l = 0; l < 10; l++)
97084
- o[l.toString()] = n.format(l);
97085
- return o;
97086
- }
97087
- /**
97088
- * Replaces Arabic digits in a string with the target numbering system digits.
97089
- *
97090
- * @since 9.5.0
97091
- * @param input The string containing Arabic digits.
97092
- * @returns The string with digits replaced.
97093
- */
97094
- replaceDigits(e) {
97095
- const n = this.getDigitMap();
97096
- return e.replace(/\d/g, (o) => n[o] || o);
97097
- }
97098
- /**
97099
- * Formats a number using the configured numbering system.
97100
- *
97101
- * @since 9.5.0
97102
- * @param value The number to format.
97103
- * @returns The formatted number as a string.
97104
- */
97105
- formatNumber(e) {
97106
- return this.replaceDigits(e.toString());
97107
- }
97108
- /**
97109
- * Returns the preferred ordering for month and year labels for the current
97110
- * locale.
97111
- */
97112
- getMonthYearOrder() {
97113
- var n;
97114
- const e = (n = this.options.locale) == null ? void 0 : n.code;
97115
- return e && DateLib.yearFirstLocales.has(e) ? "year-first" : "month-first";
97116
- }
97117
- /**
97118
- * Formats the month/year pair respecting locale conventions.
97119
- *
97120
- * @since 9.11.0
97121
- */
97122
- formatMonthYear(e) {
97123
- const { locale: n, timeZone: o, numerals: l } = this.options, d = n == null ? void 0 : n.code;
97124
- if (d && DateLib.yearFirstLocales.has(d))
97125
- try {
97126
- return new Intl.DateTimeFormat(d, {
97127
- month: "long",
97128
- year: "numeric",
97129
- timeZone: o,
97130
- numberingSystem: l
97131
- }).format(e);
97132
- } catch {
97133
- }
97134
- const f = this.getMonthYearOrder() === "year-first" ? "y LLLL" : "LLLL y";
97135
- return this.format(e, f);
97136
- }
97137
- }
97138
- DateLib.yearFirstLocales = /* @__PURE__ */ new Set([
97139
- "eu",
97140
- "hu",
97141
- "ja",
97142
- "ja-Hira",
97143
- "ja-JP",
97144
- "ko",
97145
- "ko-KR",
97146
- "lt",
97147
- "lt-LT",
97148
- "lv",
97149
- "lv-LV",
97150
- "mn",
97151
- "mn-MN",
97152
- "zh",
97153
- "zh-CN",
97154
- "zh-HK",
97155
- "zh-TW"
97156
- ]);
97157
- const defaultDateLib = new DateLib();
97158
- class CalendarDay {
97159
- constructor(e, n, o = defaultDateLib) {
97160
- this.date = e, this.displayMonth = n, this.outside = !!(n && !o.isSameMonth(e, n)), this.dateLib = o;
97161
- }
97162
- /**
97163
- * Checks if this day is equal to another `CalendarDay`, considering both the
97164
- * date and the displayed month.
97165
- *
97166
- * @param day The `CalendarDay` to compare with.
97167
- * @returns `true` if the days are equal, otherwise `false`.
97168
- */
97169
- isEqualTo(e) {
97170
- return this.dateLib.isSameDay(e.date, this.date) && this.dateLib.isSameMonth(e.displayMonth, this.displayMonth);
97171
- }
97172
- }
97173
- class CalendarMonth {
97174
- constructor(e, n) {
97175
- this.date = e, this.weeks = n;
97176
- }
97177
- }
97178
- class CalendarWeek {
97179
- constructor(e, n) {
97180
- this.days = n, this.weekNumber = e;
97181
- }
97182
- }
97183
- function Button(t) {
97184
- return React__default.createElement("button", { ...t });
97185
- }
97186
- function CaptionLabel(t) {
97187
- return React__default.createElement("span", { ...t });
97188
- }
97189
- function Chevron(t) {
97190
- const { size: e = 24, orientation: n = "left", className: o } = t;
97191
- return (
97192
- // biome-ignore lint/a11y/noSvgWithoutTitle: handled by the parent component
97193
- React__default.createElement(
97194
- "svg",
97195
- { className: o, width: e, height: e, viewBox: "0 0 24 24" },
97196
- n === "up" && React__default.createElement("polygon", { points: "6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28" }),
97197
- n === "down" && React__default.createElement("polygon", { points: "6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72" }),
97198
- n === "left" && React__default.createElement("polygon", { points: "16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20" }),
97199
- n === "right" && React__default.createElement("polygon", { points: "8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20" })
97200
- )
97201
- );
97202
- }
97203
- function Day(t) {
97204
- const { day: e, modifiers: n, ...o } = t;
97205
- return React__default.createElement("td", { ...o });
97206
- }
97207
- function DayButton(t) {
97208
- const { day: e, modifiers: n, ...o } = t, l = React__default.useRef(null);
97209
- return React__default.useEffect(() => {
97210
- var d;
97211
- n.focused && ((d = l.current) == null || d.focus());
97212
- }, [n.focused]), React__default.createElement("button", { ref: l, ...o });
97213
- }
97214
- var UI;
97215
- (function(t) {
97216
- t.Root = "root", t.Chevron = "chevron", t.Day = "day", t.DayButton = "day_button", t.CaptionLabel = "caption_label", t.Dropdowns = "dropdowns", t.Dropdown = "dropdown", t.DropdownRoot = "dropdown_root", t.Footer = "footer", t.MonthGrid = "month_grid", t.MonthCaption = "month_caption", t.MonthsDropdown = "months_dropdown", t.Month = "month", t.Months = "months", t.Nav = "nav", t.NextMonthButton = "button_next", t.PreviousMonthButton = "button_previous", t.Week = "week", t.Weeks = "weeks", t.Weekday = "weekday", t.Weekdays = "weekdays", t.WeekNumber = "week_number", t.WeekNumberHeader = "week_number_header", t.YearsDropdown = "years_dropdown";
97217
- })(UI || (UI = {}));
97218
- var DayFlag;
97219
- (function(t) {
97220
- t.disabled = "disabled", t.hidden = "hidden", t.outside = "outside", t.focused = "focused", t.today = "today";
97221
- })(DayFlag || (DayFlag = {}));
97222
- var SelectionState;
97223
- (function(t) {
97224
- t.range_end = "range_end", t.range_middle = "range_middle", t.range_start = "range_start", t.selected = "selected";
97225
- })(SelectionState || (SelectionState = {}));
97226
- var Animation;
97227
- (function(t) {
97228
- t.weeks_before_enter = "weeks_before_enter", t.weeks_before_exit = "weeks_before_exit", t.weeks_after_enter = "weeks_after_enter", t.weeks_after_exit = "weeks_after_exit", t.caption_after_enter = "caption_after_enter", t.caption_after_exit = "caption_after_exit", t.caption_before_enter = "caption_before_enter", t.caption_before_exit = "caption_before_exit";
97229
- })(Animation || (Animation = {}));
97230
- function Dropdown(t) {
97231
- const { options: e, className: n, components: o, classNames: l, ...d } = t, f = [l[UI.Dropdown], n].join(" "), g = e == null ? void 0 : e.find(({ value: b }) => b === d.value);
97232
- return React__default.createElement(
97233
- "span",
97234
- { "data-disabled": d.disabled, className: l[UI.DropdownRoot] },
97235
- React__default.createElement(o.Select, { className: f, ...d }, e == null ? void 0 : e.map(({ value: b, label: S, disabled: _ }) => React__default.createElement(o.Option, { key: b, value: b, disabled: _ }, S))),
97236
- React__default.createElement(
97237
- "span",
97238
- { className: l[UI.CaptionLabel], "aria-hidden": !0 },
97239
- g == null ? void 0 : g.label,
97240
- React__default.createElement(o.Chevron, { orientation: "down", size: 18, className: l[UI.Chevron] })
97241
- )
97242
- );
97243
- }
97244
- function DropdownNav(t) {
97245
- return React__default.createElement("div", { ...t });
97246
- }
97247
- function Footer(t) {
97248
- return React__default.createElement("div", { ...t });
97249
- }
97250
- function Month(t) {
97251
- const { calendarMonth: e, displayIndex: n, ...o } = t;
97252
- return React__default.createElement("div", { ...o }, t.children);
96160
+ function Month(t) {
96161
+ const { calendarMonth: e, displayIndex: n, ...o } = t;
96162
+ return React__default.createElement("div", { ...o }, t.children);
97253
96163
  }
97254
96164
  function MonthCaption(t) {
97255
96165
  const { calendarMonth: e, displayIndex: n, ...o } = t;
@@ -98286,128 +97196,1220 @@ function Calendar({
98286
97196
  className: cn("size-4", S),
98287
97197
  ...C
98288
97198
  }
98289
- ) : /* @__PURE__ */ jsx(ChevronDown, { className: cn("size-4", S), ...C }),
98290
- DayButton: CalendarDayButton,
98291
- WeekNumber: ({ children: S, ..._ }) => /* @__PURE__ */ jsx("td", { ..._, children: /* @__PURE__ */ jsx("div", { className: "flex size-[--cell-size] items-center justify-center text-center", children: S }) }),
98292
- ...f
98293
- },
98294
- ...g
97199
+ ) : /* @__PURE__ */ jsx(ChevronDown, { className: cn("size-4", S), ...C }),
97200
+ DayButton: CalendarDayButton,
97201
+ WeekNumber: ({ children: S, ..._ }) => /* @__PURE__ */ jsx("td", { ..._, children: /* @__PURE__ */ jsx("div", { className: "flex size-[--cell-size] items-center justify-center text-center", children: S }) }),
97202
+ ...f
97203
+ },
97204
+ ...g
97205
+ }
97206
+ );
97207
+ }
97208
+ function CalendarDayButton({
97209
+ className: t,
97210
+ day: e,
97211
+ modifiers: n,
97212
+ ...o
97213
+ }) {
97214
+ const l = getDefaultClassNames(), d = React.useRef(null);
97215
+ return React.useEffect(() => {
97216
+ var f;
97217
+ n.focused && ((f = d.current) == null || f.focus());
97218
+ }, [n.focused]), /* @__PURE__ */ jsx(
97219
+ Button$1,
97220
+ {
97221
+ ref: d,
97222
+ variant: "ghost",
97223
+ size: "icon",
97224
+ "data-day": e.date.toLocaleDateString(),
97225
+ "data-selected-single": n.selected && !n.range_start && !n.range_end && !n.range_middle,
97226
+ "data-range-start": n.range_start,
97227
+ "data-range-end": n.range_end,
97228
+ "data-range-middle": n.range_middle,
97229
+ className: cn(
97230
+ "data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",
97231
+ l.day,
97232
+ t
97233
+ ),
97234
+ ...o
97235
+ }
97236
+ );
97237
+ }
97238
+ function AssistantChat(t) {
97239
+ return /* @__PURE__ */ jsx(Card, { className: "max-w-6xl", children: /* @__PURE__ */ jsx(AIChatLayout, { className: "h-[40em]", userId: t.userId, userName: t.userName, initialPrompt: t.initialPrompt }) });
97240
+ }
97241
+ function formatDateToISO(t) {
97242
+ if (!t || !isValidDate(t))
97243
+ return "";
97244
+ const e = t.getTimezoneOffset() * 6e4;
97245
+ return new Date(t.getTime() - e).toISOString().split("T")[0];
97246
+ }
97247
+ function isValidDate(t) {
97248
+ return t instanceof Date && !isNaN(t.getTime());
97249
+ }
97250
+ function DatePicker({
97251
+ date: t,
97252
+ onDateChange: e,
97253
+ label: n,
97254
+ id: o,
97255
+ className: l
97256
+ }) {
97257
+ const [d, f] = React.useState(!1), [g, b] = React.useState(t), [S, _] = React.useState(formatDateToISO(t));
97258
+ React.useEffect(() => {
97259
+ _(formatDateToISO(t)), isValidDate(t) && b(t);
97260
+ }, [t]);
97261
+ const C = (R) => {
97262
+ const I = R.target.value.replace(/\D/g, "").slice(0, 8);
97263
+ let M = I;
97264
+ if (I.length > 4 && (M = `${I.slice(0, 4)}-${I.slice(4)}`), I.length > 6 && (M = `${I.slice(0, 4)}-${I.slice(4, 6)}-${I.slice(6)}`), _(M), I.length === 8) {
97265
+ const V = new Date(M), j = new Date(V.getUTCFullYear(), V.getUTCMonth(), V.getUTCDate());
97266
+ isValidDate(j) ? (e(j), b(j)) : e(void 0);
97267
+ } else
97268
+ e(void 0);
97269
+ }, E = (R) => {
97270
+ R && (e(R), _(formatDateToISO(R))), f(!1);
97271
+ };
97272
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-2", l), children: [
97273
+ n && /* @__PURE__ */ jsx(Label$2, { htmlFor: o, children: n }),
97274
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
97275
+ /* @__PURE__ */ jsx(
97276
+ Input,
97277
+ {
97278
+ id: o,
97279
+ value: S,
97280
+ placeholder: "YYYY-MM-DD",
97281
+ className: "bg-background pr-10",
97282
+ onChange: C,
97283
+ onKeyDown: (R) => {
97284
+ R.key === "ArrowDown" && (R.preventDefault(), f(!0));
97285
+ }
97286
+ }
97287
+ ),
97288
+ /* @__PURE__ */ jsxs(Popover, { open: d, onOpenChange: f, children: [
97289
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
97290
+ Button$1,
97291
+ {
97292
+ variant: "ghost",
97293
+ size: "icon",
97294
+ className: "absolute right-1 top-1/2 h-7 w-7 -translate-y-1/2",
97295
+ "aria-label": "Select date",
97296
+ children: /* @__PURE__ */ jsx(Calendar$1, { className: "h-4 w-4" })
97297
+ }
97298
+ ) }),
97299
+ /* @__PURE__ */ jsx(
97300
+ PopoverContent,
97301
+ {
97302
+ className: "w-auto min-w-[280px] p-0",
97303
+ align: "end",
97304
+ sideOffset: 8,
97305
+ children: /* @__PURE__ */ jsx(
97306
+ Calendar,
97307
+ {
97308
+ mode: "single",
97309
+ selected: t,
97310
+ onSelect: E,
97311
+ month: g,
97312
+ onMonthChange: b,
97313
+ initialFocus: !0,
97314
+ className: "w-full"
97315
+ }
97316
+ )
97317
+ }
97318
+ )
97319
+ ] })
97320
+ ] })
97321
+ ] });
97322
+ }
97323
+ function ExternalProductCard({
97324
+ product: t,
97325
+ viewProductLink: e
97326
+ }) {
97327
+ return t ? /* @__PURE__ */ jsx(Card, { className: "@container border-dashed border-2 hover:shadow-md transition-shadow h-full", children: /* @__PURE__ */ jsxs(CardContent, { className: "p-6 flex flex-col h-full", children: [
97328
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-start mb-4 @[36rem]:hidden", children: [
97329
+ /* @__PURE__ */ jsx("h3", { className: "font-semibold text-lg pr-4 text-center w-full", children: t.Title || t.RandmarTitle }),
97330
+ /* @__PURE__ */ jsx("div", { className: "w-24 h-10 flex-shrink-0", children: /* @__PURE__ */ jsx(
97331
+ PartnerLogo,
97332
+ {
97333
+ id: t.ManufacturerId,
97334
+ name: t.ManufacturerName,
97335
+ width: 96,
97336
+ height: 40
97337
+ }
97338
+ ) })
97339
+ ] }),
97340
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-x-6 gap-y-4 flex-grow @[36rem]:flex-row", children: [
97341
+ /* @__PURE__ */ jsx("div", { className: "mx-auto flex-shrink-0 @[36rem]:mx-0 @[36rem]:w-48", children: /* @__PURE__ */ jsx(
97342
+ ProductImage,
97343
+ {
97344
+ randmarSKU: t.RandmarSKU || "",
97345
+ alt: t.RandmarTitle || ""
97346
+ }
97347
+ ) }),
97348
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col text-center @[36rem]:text-left", children: [
97349
+ /* @__PURE__ */ jsxs("div", { className: "hidden @[36rem]:flex justify-between items-start mb-4", children: [
97350
+ /* @__PURE__ */ jsx("h3", { className: "font-semibold text-lg pr-4", children: t.Title || t.RandmarTitle }),
97351
+ /* @__PURE__ */ jsx("div", { className: "w-24 h-10 flex-shrink-0", children: /* @__PURE__ */ jsx(
97352
+ PartnerLogo,
97353
+ {
97354
+ id: t.ManufacturerId,
97355
+ name: t.ManufacturerName,
97356
+ width: 96,
97357
+ height: 40
97358
+ }
97359
+ ) })
97360
+ ] }),
97361
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2 justify-center @[36rem]:hidden", children: [
97362
+ /* @__PURE__ */ jsxs(
97363
+ Badge,
97364
+ {
97365
+ variant: "outline",
97366
+ className: "border-orange-300 bg-orange-50 text-orange-800",
97367
+ children: [
97368
+ /* @__PURE__ */ jsx(Telescope, { className: "mr-2 h-3 w-3" }),
97369
+ /* @__PURE__ */ jsx("span", { children: "External Product" })
97370
+ ]
97371
+ }
97372
+ ),
97373
+ /* @__PURE__ */ jsxs(
97374
+ Badge,
97375
+ {
97376
+ variant: "outline",
97377
+ className: "border-randmar-red bg-red-50 text-randmar-red",
97378
+ children: [
97379
+ /* @__PURE__ */ jsx(Warehouse, { className: "mr-2 h-3 w-3" }),
97380
+ /* @__PURE__ */ jsxs("span", { children: [
97381
+ "Held by ",
97382
+ /* @__PURE__ */ jsx("b", { children: "Randmar" })
97383
+ ] })
97384
+ ]
97385
+ }
97386
+ )
97387
+ ] }),
97388
+ /* @__PURE__ */ jsxs("div", { className: "hidden @[36rem]:grid grid-cols-2 gap-2", children: [
97389
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md bg-orange-50 px-4 py-2 text-orange-800 border-1 border-orange-800 text-sm", children: [
97390
+ /* @__PURE__ */ jsx(Telescope, { className: "mr-2 h-5 w-5 flex-shrink-0" }),
97391
+ /* @__PURE__ */ jsx("span", { children: "External Product" })
97392
+ ] }),
97393
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md bg-red-50 px-4 py-2 text-randmar-red border-1 border-randmar-red text-sm", children: [
97394
+ /* @__PURE__ */ jsx(Warehouse, { className: "mr-2 h-5 w-5 flex-shrink-0" }),
97395
+ /* @__PURE__ */ jsxs("span", { children: [
97396
+ "Held by ",
97397
+ /* @__PURE__ */ jsx("b", { children: "Randmar" })
97398
+ ] })
97399
+ ] })
97400
+ ] }),
97401
+ e && /* @__PURE__ */ jsx("div", { className: "mt-auto pt-4 flex justify-center @[36rem]:justify-end", children: /* @__PURE__ */ jsx(Link, { to: e, children: /* @__PURE__ */ jsxs(Button$1, { variant: "secondary", className: "w-full @[36rem]:w-auto", children: [
97402
+ /* @__PURE__ */ jsx(Eye, { className: "mr-2 h-4 w-4" }),
97403
+ "View Product"
97404
+ ] }) }) })
97405
+ ] })
97406
+ ] })
97407
+ ] }) }) : /* @__PURE__ */ jsx(Card, { className: "@container border-dashed border-2 h-full", children: /* @__PURE__ */ jsx(CardContent, { className: "p-6 flex flex-col h-full", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6 flex-grow @[36rem]:flex-row", children: [
97408
+ /* @__PURE__ */ jsx("div", { className: "flex-shrink-0 @[36rem]:w-48", children: /* @__PURE__ */ jsx(Skeleton, { className: "aspect-square w-full h-auto" }) }),
97409
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col gap-4", children: [
97410
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-start", children: [
97411
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-1/2" }),
97412
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-24 rounded" })
97413
+ ] }),
97414
+ /* @__PURE__ */ jsxs("div", { children: [
97415
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2 justify-center @[36rem]:hidden", children: [
97416
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-36 rounded-full" }),
97417
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-36 rounded-full" })
97418
+ ] }),
97419
+ /* @__PURE__ */ jsxs("div", { className: "hidden @[36rem]:grid grid-cols-2 gap-2", children: [
97420
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full rounded-md" }),
97421
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full rounded-md" })
97422
+ ] })
97423
+ ] }),
97424
+ /* @__PURE__ */ jsx("div", { className: "mt-auto pt-4 flex justify-center @[36rem]:justify-end", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full @[36rem]:w-40" }) })
97425
+ ] })
97426
+ ] }) }) });
97427
+ }
97428
+ function getEndDateStatus(t) {
97429
+ if (!t) return { text: "No End Date", variant: "neutral", daysRemaining: null };
97430
+ const e = new Date(t);
97431
+ if (isNaN(e.getTime()))
97432
+ return { text: "Invalid Date", variant: "neutral", daysRemaining: null };
97433
+ const n = /* @__PURE__ */ 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));
97434
+ 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 };
97435
+ }
97436
+ const formatDate = (t) => {
97437
+ if (!t) return "N/A";
97438
+ try {
97439
+ const e = new Date(t);
97440
+ return isNaN(e.getTime()) ? "Invalid Date" : e.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
97441
+ } catch {
97442
+ return "Invalid Date";
97443
+ }
97444
+ };
97445
+ function OpportunitiesTable({
97446
+ applicationId: t,
97447
+ opportunities: e = null,
97448
+ loading: n = !1
97449
+ }) {
97450
+ var te;
97451
+ const { toast: o } = useToast(), [l, d] = useState({}), [f, g] = useState(!1), [b, S] = useState(""), [_, C] = useState(null), {
97452
+ data: E
97453
+ } = useGetV4PartnerByApplicationIdAccountQuery({
97454
+ applicationId: t
97455
+ }, {
97456
+ skip: !t
97457
+ }), R = useCallback((ne, ae, $e) => {
97458
+ d((Ne) => ({
97459
+ ...Ne,
97460
+ [ne]: {
97461
+ ...Ne[ne],
97462
+ [ae]: $e
97463
+ }
97464
+ }));
97465
+ }, []), [A] = usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(), I = useCallback(async (ne) => {
97466
+ if (!(E != null && E.IsReseller)) return;
97467
+ if (!ne.BidNumber) {
97468
+ o({ title: "Error", description: "Bid Number is missing, cannot set default.", variant: "destructive" });
97469
+ return;
97470
+ }
97471
+ const ae = ne.BidNumber;
97472
+ R(ae, "isSettingDefault", !0), A({
97473
+ routeResellerId: t,
97474
+ manufacturerId: ne.ManufacturerId ?? "",
97475
+ opportunityNumber: ae
97476
+ }).unwrap().then(() => {
97477
+ o({
97478
+ title: "Success",
97479
+ description: `Opportunity "${ne.OpportunityName || ne.Opportunity || ae}" was successfully set as default.`,
97480
+ variant: "success"
97481
+ });
97482
+ }).catch(($e) => {
97483
+ var Ne;
97484
+ console.error("Set as default error:", $e), o({
97485
+ title: "Error",
97486
+ description: ((Ne = $e.data) == null ? void 0 : Ne.message) || $e.message || "An error occurred while setting this opportunity as default.",
97487
+ variant: "destructive"
97488
+ });
97489
+ }).finally(() => {
97490
+ R(ae, "isSettingDefault", !1);
97491
+ });
97492
+ }, [t, A, o, R, E == null ? void 0 : E.IsReseller]), [M] = usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(), V = useCallback((ne) => {
97493
+ if (E != null && E.IsReseller) {
97494
+ if (!ne.BidNumber) {
97495
+ o({ title: "Error", description: "Bid Number is missing, cannot prepare report.", variant: "destructive" });
97496
+ return;
97497
+ }
97498
+ C(ne), S(""), g(!0);
97499
+ }
97500
+ }, [o, E == null ? void 0 : E.IsReseller]), j = useCallback(async () => {
97501
+ if (!(E != null && E.IsReseller)) return;
97502
+ if (!_ || !_.BidNumber) {
97503
+ o({ title: "Error", description: "No opportunity selected or Bid Number is missing.", variant: "destructive" });
97504
+ return;
97505
+ }
97506
+ if (!b.trim() || !/\S+@\S+\.\S+/.test(b)) {
97507
+ o({ title: "Validation Error", description: "Please enter a valid email address.", variant: "destructive" });
97508
+ return;
97509
+ }
97510
+ const ne = _.BidNumber;
97511
+ R(ne, "isSendingReport", !0), M({
97512
+ routeResellerId: t,
97513
+ manufacturerId: _.ManufacturerId ?? "",
97514
+ bidNumber: ne,
97515
+ emailAddress: b
97516
+ }).unwrap().then(() => {
97517
+ o({
97518
+ title: "Success",
97519
+ description: `A report for "${_.OpportunityName || _.Opportunity || ne}" was successfully sent to ${b}.`,
97520
+ variant: "success"
97521
+ }), g(!1);
97522
+ }).catch((ae) => {
97523
+ var $e;
97524
+ console.error("Send report by email error:", ae), o({
97525
+ title: "Error",
97526
+ description: (($e = ae.data) == null ? void 0 : $e.message) || ae.message || "An error occurred while sending the report by email.",
97527
+ variant: "destructive"
97528
+ });
97529
+ }).finally(() => {
97530
+ R(ne, "isSendingReport", !1), f || (C(null), S(""));
97531
+ });
97532
+ }, [_, b, t, M, o, R, g]), z = useMemo(
97533
+ () => [
97534
+ {
97535
+ accessorKey: "ManufacturerId",
97536
+ header: "Manuf.",
97537
+ cell: ({ row: ne }) => /* @__PURE__ */ jsx("div", { className: "w-20 h-8", children: /* @__PURE__ */ jsx(
97538
+ PartnerLogo,
97539
+ {
97540
+ id: ne.original.ManufacturerId,
97541
+ width: 80,
97542
+ height: 32
97543
+ }
97544
+ ) }),
97545
+ enableSorting: !0,
97546
+ enableFiltering: !0
97547
+ },
97548
+ {
97549
+ id: "opportunityDisplay",
97550
+ accessorFn: (ne) => ne.OpportunityName || ne.Opportunity,
97551
+ header: "Opportunity",
97552
+ cell: ({ getValue: ne }) => /* @__PURE__ */ jsx("div", { className: "min-w-[150px]", children: ne() ?? "N/A" }),
97553
+ enableSorting: !0,
97554
+ enableFiltering: !0
97555
+ },
97556
+ {
97557
+ accessorKey: "BidNumber",
97558
+ header: "Bid Number",
97559
+ cell: ({ row: ne }) => ne.original.BidNumber ?? "N/A",
97560
+ enableSorting: !0,
97561
+ enableFiltering: !0
97562
+ },
97563
+ {
97564
+ id: "statusInfo",
97565
+ header: "Status",
97566
+ cell: ({ row: ne }) => {
97567
+ const ae = ne.original, $e = ae.Active === !0, Ne = getEndDateStatus(ae.EndDate);
97568
+ let oe = "border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";
97569
+ return Ne.variant === "destructive" ? oe = "border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400" : Ne.variant === "warning" && (oe = "border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"), /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2 min-w-[200px]", children: [
97570
+ /* @__PURE__ */ jsx(Badge, { variant: "outline", className: $e ? "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: $e ? "Active" : "Inactive" }),
97571
+ ae.EndDate && /* @__PURE__ */ jsx(Badge, { variant: "outline", className: `${oe} font-medium`, children: Ne.text }),
97572
+ /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 100, children: /* @__PURE__ */ jsxs(Tooltip$1, { children: [
97573
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button$1, { variant: "ghost", size: "icon", className: "h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent", children: /* @__PURE__ */ jsx(Info, { className: "h-4 w-4 text-muted-foreground" }) }) }),
97574
+ /* @__PURE__ */ jsx(TooltipContent, { side: "top", align: "center", className: "bg-popover text-popover-foreground p-2 rounded shadow-lg", children: /* @__PURE__ */ jsxs("div", { className: "text-sm space-y-1", children: [
97575
+ /* @__PURE__ */ jsxs("p", { children: [
97576
+ /* @__PURE__ */ jsx("strong", { children: "Start:" }),
97577
+ " ",
97578
+ formatDate(ae.StartDate)
97579
+ ] }),
97580
+ /* @__PURE__ */ jsxs("p", { children: [
97581
+ /* @__PURE__ */ jsx("strong", { children: "End:" }),
97582
+ " ",
97583
+ formatDate(ae.EndDate)
97584
+ ] }),
97585
+ /* @__PURE__ */ jsxs("p", { children: [
97586
+ /* @__PURE__ */ jsx("strong", { children: "Updated:" }),
97587
+ " ",
97588
+ formatDate(ae.LastUpdate)
97589
+ ] })
97590
+ ] }) })
97591
+ ] }) })
97592
+ ] });
97593
+ },
97594
+ enableFiltering: !1
97595
+ },
97596
+ {
97597
+ id: "actions",
97598
+ header: "Actions",
97599
+ cell: ({ row: ne }) => {
97600
+ var Oe, je;
97601
+ const ae = ne.original;
97602
+ if (!ae.BidNumber)
97603
+ return /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Actions unavailable" });
97604
+ const $e = ae.BidNumber, Ne = (Oe = l[$e]) == null ? void 0 : Oe.isSettingDefault, oe = (_ == null ? void 0 : _.BidNumber) === $e && ((je = l[$e]) == null ? void 0 : je.isSendingReport), Ae = Ne || oe, ge = ae.CanBeSetAsDefault === !0, Ve = E != null && E.IsManufacturer ? `/${t}/Opportunity/${ae.BidNumber}` : `/${t}/Opportunity/${ae.ManufacturerId}/${ae.BidNumber}`;
97605
+ return /* @__PURE__ */ jsxs("div", { className: "flex space-x-2", children: [
97606
+ /* @__PURE__ */ jsx(Link, { to: Ve, children: /* @__PURE__ */ jsxs(Button$1, { variant: "outline", size: "sm", className: "flex items-center", children: [
97607
+ /* @__PURE__ */ jsx(Star, { className: "mr-2 h-4 w-4" }),
97608
+ " View"
97609
+ ] }) }),
97610
+ (E == null ? void 0 : E.IsReseller) && /* @__PURE__ */ jsxs(Fragment$1, { children: [
97611
+ /* @__PURE__ */ jsxs(Button$1, { variant: "outline", size: "sm", onClick: () => I(ae), disabled: Ae || !ge, title: ge ? "Set as default" : "This opportunity cannot be set as default", className: "flex items-center", children: [
97612
+ Ne ? /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Star, { className: "mr-2 h-4 w-4" }),
97613
+ " Set Default"
97614
+ ] }),
97615
+ /* @__PURE__ */ jsxs(Button$1, { variant: "outline", size: "sm", onClick: () => V(ae), disabled: Ae, title: "Send report by email", className: "flex items-center", children: [
97616
+ oe ? /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Send, { className: "mr-2 h-4 w-4" }),
97617
+ " Send Report"
97618
+ ] })
97619
+ ] })
97620
+ ] });
97621
+ }
97622
+ }
97623
+ ],
97624
+ [
97625
+ l,
97626
+ I,
97627
+ V,
97628
+ _,
97629
+ E == null ? void 0 : E.IsReseller,
97630
+ t
97631
+ ]
97632
+ ), Q = useMemo(() => {
97633
+ const ne = {};
97634
+ if (e) {
97635
+ const ae = Array.from(
97636
+ new Set(e.map((Ne) => Ne.ManufacturerId).filter((Ne) => Ne != null))
97637
+ );
97638
+ ne.ManufacturerId = ae;
97639
+ const $e = Array.from(
97640
+ new Set(e.map((Ne) => Ne.OpportunityName || Ne.Opportunity).filter((Ne) => Ne != null))
97641
+ );
97642
+ ne.opportunityDisplay = $e;
97643
+ }
97644
+ return ne;
97645
+ }, [e]), O = e || [], F = _ != null && _.BidNumber ? (te = l[_.BidNumber]) == null ? void 0 : te.isSendingReport : !1;
97646
+ return n ? /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
97647
+ /* @__PURE__ */ jsxs(CardHeader, { children: [
97648
+ " ",
97649
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-48" }),
97650
+ " "
97651
+ ] }),
97652
+ /* @__PURE__ */ jsxs(CardContent, { className: "space-y-4", children: [
97653
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-12 w-full rounded-md border" }),
97654
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-48 w-full rounded-md border" }),
97655
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pt-4", children: [
97656
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-[130px]" }),
97657
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
97658
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-20" }),
97659
+ " ",
97660
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-24" }),
97661
+ " ",
97662
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9" }),
97663
+ " ",
97664
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9" })
97665
+ ] })
97666
+ ] })
97667
+ ] })
97668
+ ] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
97669
+ /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
97670
+ /* @__PURE__ */ jsxs(CardHeader, { children: [
97671
+ " ",
97672
+ /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: "Opportunities" }),
97673
+ " "
97674
+ ] }),
97675
+ /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(DataTable, { columns: z, data: O, uniqueValues: Q }) })
97676
+ ] }),
97677
+ /* @__PURE__ */ jsx(Dialog, { open: f, onOpenChange: (ne) => {
97678
+ g(ne), ne || (C(null), S(""));
97679
+ }, children: /* @__PURE__ */ jsxs(DialogContent, { className: "@sm:max-w-[425px]", children: [
97680
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
97681
+ /* @__PURE__ */ jsx(DialogTitle, { children: "Send Opportunity Report" }),
97682
+ /* @__PURE__ */ jsxs(DialogDescription, { children: [
97683
+ "Enter the email address to send the report for opportunity: ",
97684
+ /* @__PURE__ */ jsx("br", {}),
97685
+ /* @__PURE__ */ jsx("span", { className: "font-semibold", children: (_ == null ? void 0 : _.OpportunityName) || (_ == null ? void 0 : _.Opportunity) || "N/A" }),
97686
+ (_ == null ? void 0 : _.BidNumber) && /* @__PURE__ */ jsxs("span", { className: "block text-sm text-muted-foreground", children: [
97687
+ "Bid Number: ",
97688
+ _.BidNumber
97689
+ ] })
97690
+ ] })
97691
+ ] }),
97692
+ /* @__PURE__ */ jsx("div", { className: "grid gap-4 py-4", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-4 items-center gap-4", children: [
97693
+ /* @__PURE__ */ jsx(Label$2, { htmlFor: "email", className: "text-right", children: "Email" }),
97694
+ /* @__PURE__ */ jsx(Input, { id: "email", type: "email", value: b, onChange: (ne) => S(ne.target.value), placeholder: "recipient@example.com", className: "col-span-3", disabled: F })
97695
+ ] }) }),
97696
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
97697
+ /* @__PURE__ */ jsx(Button$1, { variant: "outline", onClick: () => g(!1), disabled: F, children: "Cancel" }),
97698
+ /* @__PURE__ */ jsxs(Button$1, { type: "submit", onClick: j, disabled: F, children: [
97699
+ F && /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }),
97700
+ " Send Report"
97701
+ ] })
97702
+ ] })
97703
+ ] }) })
97704
+ ] });
97705
+ }
97706
+ function useLoadScript(t) {
97707
+ const [e, n] = useState(!0), [o, l] = useState(null), [d, f] = useState(!1), g = () => {
97708
+ n(!1), f(!0);
97709
+ };
97710
+ return useEffect(() => {
97711
+ if (!document) {
97712
+ const C = new Error(`[ScriptLoadingError] document not defined when attempting to load ${t}`);
97713
+ l(C);
97714
+ return;
97715
+ }
97716
+ const b = document.querySelector(`script[src="${t}"]`);
97717
+ if (b != null && b.dataset.loaded) {
97718
+ g();
97719
+ return;
97720
+ }
97721
+ const S = b || document.createElement("script");
97722
+ b || (S.src = t);
97723
+ const _ = () => {
97724
+ S.dataset.loaded = "1", g();
97725
+ };
97726
+ S.addEventListener("load", _), S.addEventListener("error", (C) => {
97727
+ console.error("Failed to load script:", t, C);
97728
+ const E = new Error(`[ScriptLoadingError] Failed to load script: ${t}`);
97729
+ l(E);
97730
+ }), b || document.head.append(S);
97731
+ }, []), {
97732
+ isLoading: e,
97733
+ error: o,
97734
+ isSuccess: d
97735
+ };
97736
+ }
97737
+ const isGoogleReady = (t) => t && t.charts, isGoogleChartsReady = (t, e) => {
97738
+ const { controls: n, toolbarItems: o, getChartEditor: l } = t;
97739
+ return e && e.charts && e.visualization && e.visualization.ChartWrapper && e.visualization.Dashboard && (!n || e.visualization.ChartWrapper) && (!l || e.visualization.ChartEditor) && (!o || e.visualization.drawToolbar);
97740
+ }, getGoogleInstanceFromWindow = (t) => window.google;
97741
+ function useLoadGoogleCharts(t) {
97742
+ const { chartVersion: e = "current", chartPackages: n = [
97743
+ "corechart",
97744
+ "controls"
97745
+ ], chartLanguage: o = "en", mapsApiKey: l } = t, [d, f] = useState(null), [g, b] = useState(null), [S, _] = useState(null), { isLoading: C, error: E, isSuccess: R } = useLoadScript(t.chartLoaderScriptUrl || "https://www.gstatic.com/charts/loader.js");
97746
+ return useEffect(() => {
97747
+ if (!R)
97748
+ return;
97749
+ const A = getGoogleInstanceFromWindow();
97750
+ if (!isGoogleReady(A)) {
97751
+ const I = new Error("[ScriptInitializationError] Script loaded but Google not attached to window.");
97752
+ b(I);
97753
+ return;
97754
+ }
97755
+ if (isGoogleChartsReady(t, A)) {
97756
+ f(A);
97757
+ return;
97758
+ }
97759
+ A.charts.load(e, {
97760
+ packages: n,
97761
+ language: o,
97762
+ mapsApiKey: l
97763
+ }), A.charts.setOnLoadCallback(() => {
97764
+ if (!isGoogleChartsReady(t, A)) {
97765
+ const I = new Error("[GoogleChartsInitializationError] Google Charts not ready after load callback.");
97766
+ console.error(I), _(I);
97767
+ return;
97768
+ }
97769
+ f(A);
97770
+ });
97771
+ }, [
97772
+ R
97773
+ ]), {
97774
+ error: E || g || S,
97775
+ isLoading: C,
97776
+ google: d
97777
+ };
97778
+ }
97779
+ const chartDefaultProps = {
97780
+ // <DEPRECATED_PROPS>
97781
+ legend_toggle: !1,
97782
+ // </DEPRECATED_PROPS>
97783
+ options: {},
97784
+ legendToggle: !1,
97785
+ getChartWrapper: () => {
97786
+ },
97787
+ spreadSheetQueryParameters: {
97788
+ headers: 1,
97789
+ gid: 1
97790
+ },
97791
+ rootProps: {},
97792
+ chartWrapperParams: {},
97793
+ chartLoaderScriptUrl: "https://www.gstatic.com/charts/loader.js"
97794
+ }, GoogleChartControls = (t) => {
97795
+ const { isReady: e, chartControls: n, filter: o } = t;
97796
+ return !e || !n || !(n != null && n.length) ? null : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, n.filter((l) => {
97797
+ let { controlProp: d, control: f } = l;
97798
+ return o ? o({
97799
+ control: f,
97800
+ controlProp: d
97801
+ }) : !0;
97802
+ }).map((l) => {
97803
+ let { control: d } = l;
97804
+ return /* @__PURE__ */ React__default.createElement("div", {
97805
+ key: d.getContainerId(),
97806
+ id: d.getContainerId()
97807
+ });
97808
+ }));
97809
+ };
97810
+ let uniqueID = 0;
97811
+ const generateUniqueID = () => (uniqueID += 1, `reactgooglegraph-${uniqueID}`), Vr = class Vr {
97812
+ };
97813
+ /**
97814
+ * Initialize the controls once chart is ready
97815
+ */
97816
+ er(Vr, "initializeControls", (e) => {
97817
+ for (let n = 0; n < e.length; n += 1) {
97818
+ const { controlType: o, options: l, controlWrapperParams: d } = e[n].controlProp;
97819
+ d && "state" in d && e[n].control.setState(d.state), e[n].control.setOptions(l), e[n].control.setControlType(o);
97820
+ }
97821
+ }), /**
97822
+ * listen to the control events (ready, statechange, error) specified in the controlEvents prop
97823
+ */
97824
+ er(Vr, "listenToControlEvents", (e, n) => {
97825
+ const { google: o } = n;
97826
+ return e.flatMap((l) => {
97827
+ const { control: d, controlProp: f } = l, { controlEvents: g = [] } = f;
97828
+ return g.map((b) => {
97829
+ const { callback: S, eventName: _ } = b;
97830
+ return o.visualization.events.addListener(d, _, function() {
97831
+ for (var C = arguments.length, E = new Array(C), R = 0; R < C; R++)
97832
+ E[R] = arguments[R];
97833
+ S({
97834
+ chartWrapper: null,
97835
+ controlWrapper: d,
97836
+ props: n,
97837
+ google: o,
97838
+ eventArgs: E
97839
+ });
97840
+ });
97841
+ });
97842
+ });
97843
+ }), /**
97844
+ * If controlID is not provided, generate a unique controlID
97845
+ */
97846
+ er(Vr, "createControlId", (e) => {
97847
+ let n;
97848
+ return typeof e > "u" ? n = `googlechart-control-${generateUniqueID()}` : n = e, n;
97849
+ }), /**
97850
+ * Map the control props to Google Chart Controls
97851
+ */
97852
+ er(Vr, "createChartControls", (e) => {
97853
+ const { controls: n, google: o } = e;
97854
+ return n ? n.map((l, d) => {
97855
+ const { controlID: f, controlType: g, options: b, controlWrapperParams: S } = l, _ = Vr.createControlId(f);
97856
+ return {
97857
+ controlProp: l,
97858
+ control: new o.visualization.ControlWrapper({
97859
+ containerId: _,
97860
+ controlType: g,
97861
+ options: b,
97862
+ ...S
97863
+ })
97864
+ };
97865
+ }) : null;
97866
+ }), er(Vr, "addControls", (e) => {
97867
+ const { chartWrapper: n, chartDashboard: o } = e, l = Vr.createChartControls(e);
97868
+ return !l || !o || !n ? null : (o.bind(l.map((d) => {
97869
+ let { control: f } = d;
97870
+ return f;
97871
+ }), n), Vr.initializeControls(l), l);
97872
+ });
97873
+ let GoogleChartControlsInternal = Vr;
97874
+ const useCreateChartControls = (t) => {
97875
+ const [e, n] = React.useState(null);
97876
+ return [
97877
+ React.useMemo(() => !e || !t ? null : t.map((l, d) => {
97878
+ const f = e[d];
97879
+ return f ? {
97880
+ controlProp: l,
97881
+ control: f
97882
+ } : void 0;
97883
+ }).flatMap((l) => l ? [
97884
+ l
97885
+ ] : []), [
97886
+ e,
97887
+ t
97888
+ ]),
97889
+ n
97890
+ ];
97891
+ }, useListenToControlEvents = (t, e) => {
97892
+ React.useEffect(() => {
97893
+ const n = GoogleChartControlsInternal.listenToControlEvents(t ?? [], e);
97894
+ return () => {
97895
+ n.forEach((o) => {
97896
+ e.google.visualization.events.removeListener(o);
97897
+ });
97898
+ };
97899
+ }, [
97900
+ t,
97901
+ e
97902
+ ]);
97903
+ }, useChartControls = (t) => {
97904
+ const [e, n] = useCreateChartControls(t.controls);
97905
+ return useListenToControlEvents(e ?? [], t), {
97906
+ addControls: (l) => {
97907
+ const d = GoogleChartControlsInternal.addControls(l);
97908
+ n((d == null ? void 0 : d.map((f) => f.control)) ?? null);
97909
+ },
97910
+ renderControl: (l) => {
97911
+ const { chartWrapper: d, chartDashboard: f } = t;
97912
+ return /* @__PURE__ */ React.createElement(GoogleChartControls, {
97913
+ ...t,
97914
+ isReady: !!(d && f),
97915
+ chartControls: e,
97916
+ filter: l
97917
+ });
97918
+ }
97919
+ };
97920
+ }, useChartId = (t) => {
97921
+ const e = React.useRef(null);
97922
+ return {
97923
+ chartId: (() => {
97924
+ const { graphID: l, graph_id: d } = t, f = l || d;
97925
+ let g;
97926
+ return f ? g = f : g = e.current || generateUniqueID(), e.current = g, e.current;
97927
+ })()
97928
+ };
97929
+ }, DEFAULT_CHART_COLORS = [
97930
+ "#3366CC",
97931
+ "#DC3912",
97932
+ "#FF9900",
97933
+ "#109618",
97934
+ "#990099",
97935
+ "#3B3EAC",
97936
+ "#0099C6",
97937
+ "#DD4477",
97938
+ "#66AA00",
97939
+ "#B82E2E",
97940
+ "#316395",
97941
+ "#994499",
97942
+ "#22AA99",
97943
+ "#AAAA11",
97944
+ "#6633CC",
97945
+ "#E67300",
97946
+ "#8B0707",
97947
+ "#329262",
97948
+ "#5574A6",
97949
+ "#3B3EAC"
97950
+ ], loadDataTableFromSpreadSheet = async function(t, e) {
97951
+ let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
97952
+ return new Promise((o, l) => {
97953
+ 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}` : ""}`, S = `${n.access_token ? `&access_token=${n.access_token}` : ""}`, _ = `${d}${g}${b}${f}${S}`, C = `${e}/gviz/tq?${_}`;
97954
+ new t.visualization.Query(C).send((R) => {
97955
+ R.isError() ? l(`Error in query: ${R.getMessage()} ${R.getDetailedMessage()}`) : o(R.getDataTable());
97956
+ });
97957
+ });
97958
+ }, GRAY_COLOR = "#CCCCCC", Rr = class Rr {
97959
+ };
97960
+ er(Rr, "grayOutHiddenColumnsLabel", (e, n) => {
97961
+ const { googleChartWrapper: o, options: l } = e;
97962
+ if (!o) {
97963
+ console.error("googleChartWrapper is not defined");
97964
+ return;
97965
+ }
97966
+ const d = o.getDataTable();
97967
+ if (!d) return;
97968
+ const f = d.getNumberOfColumns();
97969
+ if (n.length > 0 === !1) return;
97970
+ const b = Array.from({
97971
+ length: f - 1
97972
+ }).map((S, _) => {
97973
+ const C = Rr.getColumnId(d, _ + 1);
97974
+ return n.includes(C) ? GRAY_COLOR : l && l.colors ? l.colors[_] : DEFAULT_CHART_COLORS[_];
97975
+ });
97976
+ o.setOptions({
97977
+ ...l,
97978
+ colors: b
97979
+ }), o.draw();
97980
+ }), /**
97981
+ * Listens to user clicking on the legend to toggle the visibility of a column.
97982
+ * When a user clicks on a legend item, the column id is added to / removed from the hiddenColumns state.
97983
+ */
97984
+ er(Rr, "listenToLegendToggle", (e, n) => {
97985
+ const [o, l] = n, { google: d, googleChartWrapper: f } = e;
97986
+ if (!f) {
97987
+ console.error("googleChartWrapper is not defined");
97988
+ return;
97989
+ }
97990
+ return d.visualization.events.addListener(f, "select", () => {
97991
+ const b = f.getChart().getSelection(), S = f.getDataTable();
97992
+ if (b.length === 0 || // We want to listen to when a whole row is selected. This is the case only when row === null
97993
+ b[0].row !== null || !S)
97994
+ return;
97995
+ const _ = b[0].column, C = Rr.getColumnId(S, _);
97996
+ o != null && o.includes(C) ? l((E) => [
97997
+ ...E.filter((R) => R !== C)
97998
+ ]) : l((E) => [
97999
+ ...E,
98000
+ C
98001
+ ]);
98002
+ });
98003
+ }), /**
98004
+ * (Re-)Draw a Google Chart with the given data, options, and chart type.
98005
+ */
98006
+ er(Rr, "draw", async (e) => {
98007
+ const { data: n, diffdata: o, rows: l, columns: d, options: f, chartType: g, formatters: b, spreadSheetUrl: S, spreadSheetQueryParameters: _, googleChartDashboard: C, googleChartWrapper: E, google: R, hiddenColumns: A, legendToggle: I, legend_toggle: M } = e;
98008
+ if (!E) {
98009
+ console.error("draw was called with googleChartWrapper = null");
98010
+ return;
98011
+ }
98012
+ let V, j = null;
98013
+ if (o) {
98014
+ const te = R.visualization.arrayToDataTable(o.old), ne = R.visualization.arrayToDataTable(o.new);
98015
+ j = R.visualization[g].prototype.computeDiff(te, ne);
98016
+ }
98017
+ n ? n instanceof R.visualization.DataTable ? V = n : Array.isArray(n) ? V = R.visualization.arrayToDataTable(n) : V = new R.visualization.DataTable(n) : l && d ? V = R.visualization.arrayToDataTable([
98018
+ d,
98019
+ ...l
98020
+ ]) : S ? V = await loadDataTableFromSpreadSheet(R, S, _) : V = R.visualization.arrayToDataTable([]);
98021
+ const z = V.getNumberOfColumns(), Q = Array(z).fill(0).map((te, ne) => {
98022
+ const ae = Rr.getColumnId(V, ne);
98023
+ return A.includes(ae) ? {
98024
+ label: V.getColumnLabel(ne),
98025
+ type: V.getColumnType(ne),
98026
+ calc: () => null
98027
+ } : ne;
98028
+ }), O = E.getChart();
98029
+ E.getChartType() === "Timeline" && O && O.clearChart(), E.setChartType(g), E.setOptions(f || {});
98030
+ const F = new R.visualization.DataView(V);
98031
+ F.setColumns(Q), E.setDataTable(F), E.draw(), C && C.draw(V), j && (E.setDataTable(j), E.draw()), b && (Rr.applyFormatters({
98032
+ dataTable: V,
98033
+ formatters: b,
98034
+ google: R
98035
+ }), E.setDataTable(V), E.draw()), (I === !0 || M === !0) && Rr.grayOutHiddenColumnsLabel(e, A);
98036
+ }), /**
98037
+ * Get the column ID of a column in a GoogleDataTable.
98038
+ * If the column has an ID, return the ID, otherwise return the label.
98039
+ */
98040
+ er(Rr, "getColumnId", (e, n) => e.getColumnId(n) || e.getColumnLabel(n)), /**
98041
+ * Apply Chart Formatters passed under the formatters prop to the GoogleDataTable
98042
+ */
98043
+ er(Rr, "applyFormatters", (e) => {
98044
+ let { dataTable: n, formatters: o, google: l } = e;
98045
+ for (let d of o)
98046
+ switch (d.type) {
98047
+ case "ArrowFormat": {
98048
+ new l.visualization.ArrowFormat(d.options).format(n, d.column);
98049
+ return;
98050
+ }
98051
+ case "BarFormat": {
98052
+ new l.visualization.BarFormat(d.options).format(n, d.column);
98053
+ return;
98054
+ }
98055
+ case "ColorFormat": {
98056
+ const f = new l.visualization.ColorFormat(d.options), { ranges: g } = d;
98057
+ if (g)
98058
+ for (let b of g)
98059
+ f.addRange(...b);
98060
+ f.format(n, d.column);
98061
+ return;
98062
+ }
98063
+ case "DateFormat": {
98064
+ new l.visualization.DateFormat(d.options).format(n, d.column);
98065
+ return;
98066
+ }
98067
+ case "NumberFormat": {
98068
+ new l.visualization.NumberFormat(d.options).format(n, d.column);
98069
+ return;
98070
+ }
98071
+ case "PatternFormat": {
98072
+ new l.visualization.PatternFormat(d.options).format(n, d.column);
98073
+ return;
98074
+ }
98075
+ default: {
98076
+ console.warn(`Unknown formatter type: ${d.type}`);
98077
+ return;
98078
+ }
98079
+ }
98080
+ });
98081
+ let GoogleChartInternal = Rr;
98082
+ const useGoogleChartDataTable = (t) => {
98083
+ const { google: e, googleChartWrapper: n, googleChartDashboard: o } = t, [l, d] = React.useState([]);
98084
+ React.useEffect(() => {
98085
+ n && GoogleChartInternal.draw({
98086
+ ...t,
98087
+ hiddenColumns: l,
98088
+ googleChartWrapper: n,
98089
+ googleChartDashboard: o,
98090
+ google: e
98091
+ });
98092
+ }, [
98093
+ l,
98094
+ t.data,
98095
+ t.rows,
98096
+ t.columns,
98097
+ t.options,
98098
+ t.chartLoaderScriptUrl,
98099
+ t.chartType,
98100
+ t.formatters,
98101
+ t.spreadSheetUrl,
98102
+ t.spreadSheetQueryParameters,
98103
+ t.legendToggle,
98104
+ t.legend_toggle
98105
+ ]);
98106
+ const f = () => {
98107
+ const { googleChartWrapper: S } = t;
98108
+ S && S.draw();
98109
+ }, g = (S) => {
98110
+ const _ = [], { legendToggle: C, legend_toggle: E } = t;
98111
+ if (GoogleChartInternal.draw({
98112
+ ...t,
98113
+ hiddenColumns: l,
98114
+ googleChartWrapper: S,
98115
+ googleChartDashboard: o,
98116
+ google: e
98117
+ }), window.addEventListener("resize", f), E || C) {
98118
+ const R = GoogleChartInternal.listenToLegendToggle(t, [
98119
+ l,
98120
+ d
98121
+ ]);
98122
+ R && _.push(R);
98123
+ }
98124
+ return _;
98125
+ }, b = (S, _) => {
98126
+ window.removeEventListener("resize", f), _.forEach((C) => {
98127
+ e.visualization.events.removeListener(C);
98128
+ }), S.getChartType() === "Timeline" && S.getChart() && S.getChart().clearChart();
98129
+ };
98130
+ React.useEffect(() => {
98131
+ if (!n)
98132
+ return;
98133
+ const S = g(n);
98134
+ return () => {
98135
+ b(n, S);
98136
+ };
98137
+ }, [
98138
+ n,
98139
+ g,
98140
+ b
98141
+ ]);
98142
+ }, listenToEvents = (t) => {
98143
+ const { chartEvents: e, google: n, googleChartWrapper: o } = t;
98144
+ if (e) {
98145
+ if (!o) {
98146
+ console.warn("listenToEvents was called before chart wrapper ready.");
98147
+ return;
98148
+ }
98149
+ return e.map((l) => {
98150
+ let { eventName: d, callback: f } = l;
98151
+ return n.visualization.events.addListener(o, d, function() {
98152
+ for (var g = arguments.length, b = new Array(g), S = 0; S < g; S++)
98153
+ b[S] = arguments[S];
98154
+ f({
98155
+ chartWrapper: o,
98156
+ props: t,
98157
+ google: n,
98158
+ eventArgs: b
98159
+ });
98160
+ });
98161
+ });
98162
+ }
98163
+ }, useGoogleChartEvents = (t) => {
98164
+ useEffect(() => {
98165
+ if (!t.googleChartWrapper) return;
98166
+ const e = listenToEvents(t);
98167
+ return () => {
98168
+ e == null || e.forEach((n) => {
98169
+ t.google.visualization.events.removeListener(n);
98170
+ });
98171
+ };
98172
+ }, [
98173
+ t
98174
+ ]);
98175
+ }, GoogleChart = (t) => {
98176
+ const [e, n] = React.useState(null), [o, l] = React.useState(null), { addControls: d, renderControl: f } = useChartControls({
98177
+ ...t,
98178
+ chartDashboard: o,
98179
+ chartWrapper: e
98180
+ });
98181
+ useGoogleChartEvents({
98182
+ ...t,
98183
+ googleChartWrapper: e
98184
+ });
98185
+ const { chartId: g } = useChartId(t), b = React.useRef(null), S = React.useRef(null);
98186
+ React.useEffect(() => {
98187
+ const { options: V, google: j, chartType: z, chartWrapperParams: Q, toolbarItems: O, getChartEditor: F, getChartWrapper: te, onLoad: ne } = t, ae = {
98188
+ chartType: z,
98189
+ options: V,
98190
+ containerId: g,
98191
+ ...Q
98192
+ }, $e = new j.visualization.ChartWrapper(ae);
98193
+ $e.setOptions(V || {}), te == null || te($e, j);
98194
+ const Ne = new j.visualization.Dashboard(b.current);
98195
+ O && j.visualization.drawToolbar(S.current, O);
98196
+ let oe = null;
98197
+ F && (oe = new j.visualization.ChartEditor(), F({
98198
+ chartEditor: oe,
98199
+ chartWrapper: $e,
98200
+ google: j
98201
+ })), d({
98202
+ ...t,
98203
+ chartDashboard: Ne,
98204
+ chartWrapper: $e
98205
+ }), n($e), l(Ne), ne == null || ne(j, {
98206
+ google: j,
98207
+ chartWrapper: $e,
98208
+ chartEditor: oe,
98209
+ chartDashboard: Ne
98210
+ });
98211
+ }, []), useGoogleChartDataTable({
98212
+ ...t,
98213
+ googleChartWrapper: e,
98214
+ googleChartDashboard: o
98215
+ });
98216
+ const _ = () => {
98217
+ const { width: V, height: j, options: z, style: Q, className: O, rootProps: F, google: te } = t, ne = {
98218
+ height: j || z && z.height,
98219
+ width: V || z && z.width,
98220
+ ...Q
98221
+ };
98222
+ return /* @__PURE__ */ React.createElement("div", {
98223
+ id: g,
98224
+ style: ne,
98225
+ className: O,
98226
+ ...F
98227
+ });
98228
+ }, C = () => t.toolbarItems ? /* @__PURE__ */ React.createElement("div", {
98229
+ ref: S
98230
+ }) : null, { width: E, height: R, options: A, style: I } = t, M = {
98231
+ height: R || A && A.height,
98232
+ width: E || A && A.width,
98233
+ ...I
98234
+ };
98235
+ return t.render ? /* @__PURE__ */ React.createElement("div", {
98236
+ ref: b,
98237
+ style: M
98238
+ }, /* @__PURE__ */ React.createElement("div", {
98239
+ ref: S,
98240
+ id: "toolbar"
98241
+ }), t.render({
98242
+ renderChart: _,
98243
+ renderControl: f,
98244
+ renderToolbar: C
98245
+ })) : /* @__PURE__ */ React.createElement("div", {
98246
+ ref: b,
98247
+ style: M
98248
+ }, f((V) => {
98249
+ let { controlProp: j } = V;
98250
+ return j.controlPosition !== "bottom";
98251
+ }), _(), f((V) => {
98252
+ let { controlProp: j } = V;
98253
+ return j.controlPosition === "bottom";
98254
+ }), C());
98255
+ }, ChartContext = /* @__PURE__ */ React.createContext(chartDefaultProps), ContextProvider = (t) => {
98256
+ let { children: e, value: n } = t;
98257
+ return /* @__PURE__ */ React.createElement(ChartContext.Provider, {
98258
+ value: n
98259
+ }, e);
98260
+ }, ChartView = (t) => {
98261
+ const { google: e, isLoading: n, error: o } = useLoadGoogleCharts(t);
98262
+ return n ? t.loader ?? null : o ? t.errorElement ?? null : e ? /* @__PURE__ */ React__default.createElement(GoogleChart, {
98263
+ google: e,
98264
+ ...t
98265
+ }) : null;
98266
+ }, Chart = (t) => {
98267
+ const e = {
98268
+ ...chartDefaultProps,
98269
+ ...t
98270
+ };
98271
+ return /* @__PURE__ */ React__default.createElement(ContextProvider, {
98272
+ value: e
98273
+ }, /* @__PURE__ */ React__default.createElement(ChartView, e));
98274
+ };
98275
+ var GoogleDataTableColumnRoleType;
98276
+ (function(t) {
98277
+ 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";
98278
+ })(GoogleDataTableColumnRoleType || (GoogleDataTableColumnRoleType = {}));
98279
+ function parseHsl(t) {
98280
+ const e = t.match(/(\d+\.?\d*)\s*(\d+\.?\d*)%\s*(\d+\.?\d*)%/);
98281
+ return e ? {
98282
+ h: parseFloat(e[1]),
98283
+ s: parseFloat(e[2]),
98284
+ l: parseFloat(e[3])
98285
+ } : null;
98286
+ }
98287
+ function hslToHex(t, e, n) {
98288
+ n /= 100;
98289
+ const o = e * Math.min(n, 1 - n) / 100, l = (d) => {
98290
+ const f = (d + t / 30) % 12, g = n - o * Math.max(Math.min(f - 3, 9 - f, 1), -1);
98291
+ return Math.round(255 * g).toString(16).padStart(2, "0");
98292
+ };
98293
+ return `#${l(0)}${l(8)}${l(4)}`;
98294
+ }
98295
+ const Treemap = React.forwardRef(
98296
+ ({ data: t, options: e, height: n = "500px", className: o, loading: l, disableClick: d = !0, ...f }, g) => {
98297
+ const b = React.useRef(null), [S, _] = React.useState(null);
98298
+ React.useEffect(() => {
98299
+ if (!b.current) return;
98300
+ const R = b.current, A = () => {
98301
+ const j = getComputedStyle(R).getPropertyValue("--primary").trim();
98302
+ if (j) {
98303
+ const z = parseHsl(j);
98304
+ if (z) {
98305
+ const { h: Q, s: O, l: F } = z;
98306
+ _({
98307
+ minColor: hslToHex(Q, O, Math.min(100, F + 50)),
98308
+ midColor: hslToHex(Q, O, Math.min(100, F + 35)),
98309
+ maxColor: hslToHex(Q, O, Math.min(100, F + 20))
98310
+ });
98311
+ }
98312
+ return !0;
98313
+ }
98314
+ return !1;
98315
+ };
98316
+ if (A())
98317
+ return;
98318
+ let I = 0;
98319
+ const M = 20, V = setInterval(() => {
98320
+ (A() || I >= M) && clearInterval(V), I++;
98321
+ }, 100);
98322
+ return () => {
98323
+ V && clearInterval(V);
98324
+ };
98325
+ }, []);
98326
+ const C = React.useMemo(() => {
98327
+ const R = {
98328
+ headerHeight: 0,
98329
+ fontSize: 14,
98330
+ showScale: !1,
98331
+ isHtml: !0,
98332
+ backgroundColor: "hsl(var(--background))",
98333
+ generateTooltip: (A, I) => {
98334
+ var j;
98335
+ const M = (j = t[A + 1]) == null ? void 0 : j[0];
98336
+ if (!M) return "";
98337
+ const V = formatMoney(I);
98338
+ return `<div class="p-2 bg-background text-foreground border rounded-md shadow-lg">
98339
+ <strong>${M}</strong><br>Value: ${V}
98340
+ </div>`;
98341
+ }
98342
+ };
98343
+ return S && (!e || !e.colorAxis) && (R.minColor = S.minColor, R.midColor = S.midColor, R.maxColor = S.maxColor), { ...R, ...e };
98344
+ }, [t, e, S]), E = React.useMemo(() => d ? [{
98345
+ eventName: "select",
98346
+ // react-google-charts is not officially maintained by Google and not up
98347
+ // to date with the GoogleChartWrapper type, setSelection is missing
98348
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
98349
+ callback: ({ chartWrapper: A }) => {
98350
+ A.getChart().setSelection(null);
98351
+ }
98352
+ }] : void 0, [d]);
98353
+ return React.useImperativeHandle(g, () => b.current, []), l ? /* @__PURE__ */ jsx("div", { ref: b, className: cn("w-full", o), style: { height: n }, ...f, children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full w-full" }) }) : !t || t.length <= 2 ? /* @__PURE__ */ jsx("div", { ref: b, className: cn("w-full flex items-center justify-center text-muted-foreground", o), style: { height: n }, ...f, children: "No data available" }) : /* @__PURE__ */ jsx("div", { ref: b, className: cn("w-full", o), style: { height: n }, ...f, children: /* @__PURE__ */ jsx(
98354
+ Chart,
98355
+ {
98356
+ chartType: "TreeMap",
98357
+ width: "100%",
98358
+ height: "100%",
98359
+ data: t,
98360
+ options: C,
98361
+ chartEvents: E,
98362
+ loader: /* @__PURE__ */ jsx(Skeleton, { className: "h-full w-full" })
98363
+ }
98364
+ ) });
98365
+ }
98366
+ );
98367
+ Treemap.displayName = "Treemap";
98368
+ const TopPercentTreemap = ({
98369
+ data: t,
98370
+ topPercent: e = 80,
98371
+ title: n,
98372
+ loading: o,
98373
+ ...l
98374
+ }) => {
98375
+ const d = React.useMemo(() => {
98376
+ if (!t || t.length === 0)
98377
+ return [["ID", "Parent", "Value"], ["Root", null, 0]];
98378
+ const g = [...t].sort((A, I) => I.value - A.value), S = g.reduce((A, I) => A + I.value, 0) * (e / 100), _ = [
98379
+ ["ID", "Parent", "Value"],
98380
+ ["Root", null, 0]
98381
+ ], C = [], E = [];
98382
+ let R = 0;
98383
+ for (const A of g)
98384
+ R < S ? (C.push(A), R += A.value) : E.push(A);
98385
+ if (C.forEach((A) => {
98386
+ _.push([A.name, "Root", A.value]);
98387
+ }), E.length > 0) {
98388
+ const A = `More... (${E.length} items)`;
98389
+ _.push([A, "Root", 0]), E.forEach((I) => {
98390
+ _.push([I.name, A, I.value]);
98391
+ });
98295
98392
  }
98296
- );
98297
- }
98298
- function CalendarDayButton({
98299
- className: t,
98300
- day: e,
98301
- modifiers: n,
98302
- ...o
98303
- }) {
98304
- const l = getDefaultClassNames(), d = React.useRef(null);
98305
- return React.useEffect(() => {
98306
- var f;
98307
- n.focused && ((f = d.current) == null || f.focus());
98308
- }, [n.focused]), /* @__PURE__ */ jsx(
98309
- Button$1,
98393
+ return _;
98394
+ }, [t, e]), f = React.useMemo(() => ({
98395
+ title: n,
98396
+ maxDepth: 1,
98397
+ backgroundColor: "hsl(var(--background))"
98398
+ }), [n]);
98399
+ return /* @__PURE__ */ jsx(
98400
+ Treemap,
98310
98401
  {
98311
- ref: d,
98312
- variant: "ghost",
98313
- size: "icon",
98314
- "data-day": e.date.toLocaleDateString(),
98315
- "data-selected-single": n.selected && !n.range_start && !n.range_end && !n.range_middle,
98316
- "data-range-start": n.range_start,
98317
- "data-range-end": n.range_end,
98318
- "data-range-middle": n.range_middle,
98319
- className: cn(
98320
- "data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",
98321
- l.day,
98322
- t
98323
- ),
98324
- ...o
98402
+ data: d,
98403
+ options: f,
98404
+ className: cn("h-full", l.className),
98405
+ loading: o,
98406
+ disableClick: !1,
98407
+ ...l
98325
98408
  }
98326
98409
  );
98327
- }
98328
- function formatDateToISO(t) {
98329
- if (!t || !isValidDate(t))
98330
- return "";
98331
- const e = t.getTimezoneOffset() * 6e4;
98332
- return new Date(t.getTime() - e).toISOString().split("T")[0];
98333
- }
98334
- function isValidDate(t) {
98335
- return t instanceof Date && !isNaN(t.getTime());
98336
- }
98337
- function DatePicker({
98338
- date: t,
98339
- onDateChange: e,
98340
- label: n,
98341
- id: o,
98342
- className: l
98343
- }) {
98344
- const [d, f] = React.useState(!1), [g, b] = React.useState(t), [S, _] = React.useState(formatDateToISO(t));
98345
- React.useEffect(() => {
98346
- _(formatDateToISO(t)), isValidDate(t) && b(t);
98347
- }, [t]);
98348
- const C = (R) => {
98349
- const I = R.target.value.replace(/\D/g, "").slice(0, 8);
98350
- let M = I;
98351
- if (I.length > 4 && (M = `${I.slice(0, 4)}-${I.slice(4)}`), I.length > 6 && (M = `${I.slice(0, 4)}-${I.slice(4, 6)}-${I.slice(6)}`), _(M), I.length === 8) {
98352
- const V = new Date(M), j = new Date(V.getUTCFullYear(), V.getUTCMonth(), V.getUTCDate());
98353
- isValidDate(j) ? (e(j), b(j)) : e(void 0);
98354
- } else
98355
- e(void 0);
98356
- }, E = (R) => {
98357
- R && (e(R), _(formatDateToISO(R))), f(!1);
98358
- };
98359
- return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-2", l), children: [
98360
- n && /* @__PURE__ */ jsx(Label$2, { htmlFor: o, children: n }),
98361
- /* @__PURE__ */ jsxs("div", { className: "relative", children: [
98362
- /* @__PURE__ */ jsx(
98363
- Input,
98364
- {
98365
- id: o,
98366
- value: S,
98367
- placeholder: "YYYY-MM-DD",
98368
- className: "bg-background pr-10",
98369
- onChange: C,
98370
- onKeyDown: (R) => {
98371
- R.key === "ArrowDown" && (R.preventDefault(), f(!0));
98372
- }
98373
- }
98374
- ),
98375
- /* @__PURE__ */ jsxs(Popover, { open: d, onOpenChange: f, children: [
98376
- /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
98377
- Button$1,
98378
- {
98379
- variant: "ghost",
98380
- size: "icon",
98381
- className: "absolute right-1 top-1/2 h-7 w-7 -translate-y-1/2",
98382
- "aria-label": "Select date",
98383
- children: /* @__PURE__ */ jsx(Calendar$1, { className: "h-4 w-4" })
98384
- }
98385
- ) }),
98386
- /* @__PURE__ */ jsx(
98387
- PopoverContent,
98388
- {
98389
- className: "w-auto min-w-[280px] p-0",
98390
- align: "end",
98391
- sideOffset: 8,
98392
- children: /* @__PURE__ */ jsx(
98393
- Calendar,
98394
- {
98395
- mode: "single",
98396
- selected: t,
98397
- onSelect: E,
98398
- month: g,
98399
- onMonthChange: b,
98400
- initialFocus: !0,
98401
- className: "w-full"
98402
- }
98403
- )
98404
- }
98405
- )
98406
- ] })
98407
- ] })
98408
- ] });
98409
- }
98410
+ };
98410
98411
  export {
98412
+ AIChatLayout,
98411
98413
  Accordion,
98412
98414
  AccordionContent,
98413
98415
  AccordionItem,