@tapcart/mobile-components 0.2.12 → 0.3.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.
Files changed (54) hide show
  1. package/dist/components/hooks/use-infinite-scroll.d.ts +1 -0
  2. package/dist/components/hooks/use-infinite-scroll.d.ts.map +1 -1
  3. package/dist/components/hooks/use-infinite-scroll.js +3 -2
  4. package/dist/components/hooks/use-scroll-direction.d.ts +1 -1
  5. package/dist/components/hooks/use-scroll-direction.d.ts.map +1 -1
  6. package/dist/components/hooks/use-scroll-direction.js +17 -5
  7. package/dist/components/ui/accordion.js +1 -1
  8. package/dist/components/ui/badge.d.ts +1 -1
  9. package/dist/components/ui/button.d.ts.map +1 -1
  10. package/dist/components/ui/button.js +49 -14
  11. package/dist/components/ui/checkbox.js +2 -2
  12. package/dist/components/ui/chip.d.ts.map +1 -1
  13. package/dist/components/ui/chip.js +3 -3
  14. package/dist/components/ui/drawer.js +1 -1
  15. package/dist/components/ui/icon.d.ts.map +1 -1
  16. package/dist/components/ui/icon.js +5 -1
  17. package/dist/components/ui/image.d.ts +157 -0
  18. package/dist/components/ui/image.d.ts.map +1 -0
  19. package/dist/components/ui/image.js +318 -0
  20. package/dist/components/ui/line-item-text-icons.d.ts +14 -0
  21. package/dist/components/ui/line-item-text-icons.d.ts.map +1 -0
  22. package/dist/components/ui/line-item-text-icons.js +22 -0
  23. package/dist/components/ui/product-card.d.ts +5 -19
  24. package/dist/components/ui/product-card.d.ts.map +1 -1
  25. package/dist/components/ui/product-card.js +77 -24
  26. package/dist/components/ui/quantity-picker.d.ts +14 -0
  27. package/dist/components/ui/quantity-picker.d.ts.map +1 -0
  28. package/dist/components/ui/quantity-picker.js +23 -0
  29. package/dist/components/ui/radio-group.js +1 -1
  30. package/dist/components/ui/selectors.d.ts +1 -1
  31. package/dist/components/ui/selectors.d.ts.map +1 -1
  32. package/dist/components/ui/selectors.js +20 -4
  33. package/dist/components/ui/skeleton.js +1 -1
  34. package/dist/components/ui/slider.d.ts +14 -0
  35. package/dist/components/ui/slider.d.ts.map +1 -0
  36. package/dist/components/ui/slider.js +50 -0
  37. package/dist/components/ui/subscription.d.ts +15 -0
  38. package/dist/components/ui/subscription.d.ts.map +1 -0
  39. package/dist/components/ui/subscription.js +24 -0
  40. package/dist/components/ui/switch.d.ts.map +1 -1
  41. package/dist/components/ui/switch.js +2 -2
  42. package/dist/components/ui/tabs.js +1 -1
  43. package/dist/components/ui/toggle.js +1 -1
  44. package/dist/index.d.ts +5 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +5 -0
  47. package/dist/styles.css +108 -88
  48. package/package.json +9 -3
  49. package/dist/components/ThemeProvider.d.ts +0 -3
  50. package/dist/components/ThemeProvider.d.ts.map +0 -1
  51. package/dist/components/ThemeProvider.js +0 -18
  52. package/dist/components/ThemeToggle.d.ts +0 -2
  53. package/dist/components/ThemeToggle.d.ts.map +0 -1
  54. package/dist/components/ThemeToggle.js +0 -8
@@ -20,6 +20,7 @@ interface UseInfiniteScrollReturn {
20
20
  ref: (node?: Element | null | undefined) => void;
21
21
  products: Product[];
22
22
  isLoading: boolean;
23
+ isValidating: boolean;
23
24
  }
24
25
  declare const useInfiniteScroll: ({ initialData, loadMoreProducts, queryVariables, }: UseInfiniteScrollProps) => UseInfiniteScrollReturn;
25
26
  export { useInfiniteScroll };
@@ -1 +1 @@
1
- {"version":3,"file":"use-infinite-scroll.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-infinite-scroll.ts"],"names":[],"mappings":"AAOA,UAAU,OAAO;IACf,MAAM,EAAE,MAAM,CAAA;CAEf;AAED,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAOD,UAAU,sBAAsB;IAC9B,WAAW,EAAE,QAAQ,EAAE,CAAA;IACvB,gBAAgB,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ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CAAA;IAChB,aAAa,EAAE,OAAO,CAAA;IACtB,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAA;IAChD,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,QAAA,MAAM,iBAAiB,uDAIpB,sBAAsB,KAAG,uBAkE3B,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
@@ -5,7 +5,7 @@ import { useInView } from "react-intersection-observer";
5
5
  const PAGE_SIZE = 8;
6
6
  const useInfiniteScroll = ({ initialData, loadMoreProducts, queryVariables, }) => {
7
7
  var _a, _b, _c, _d;
8
- const { ref, inView } = useInView({ rootMargin: "300px" }); // controls how early the next page loads
8
+ const { ref, inView } = useInView({ rootMargin: "600px" }); // controls how early the next page loads
9
9
  const getKey = (pageIndex, previousPageData) => {
10
10
  var _a;
11
11
  if (pageIndex === 0)
@@ -14,7 +14,7 @@ const useInfiniteScroll = ({ initialData, loadMoreProducts, queryVariables, }) =
14
14
  return null;
15
15
  return Object.assign(Object.assign({}, queryVariables), { cursorBlob: previousPageData.pageData.cursorBlob });
16
16
  };
17
- const { data, error, size, setSize, isLoading } = useSWRInfinite(getKey, loadMoreProducts, {
17
+ const { data, error, size, setSize, isLoading, isValidating, } = useSWRInfinite(getKey, loadMoreProducts, {
18
18
  // @ts-expect-error
19
19
  fallbackData: [initialData],
20
20
  revalidateFirstPage: false,
@@ -48,6 +48,7 @@ const useInfiniteScroll = ({ initialData, loadMoreProducts, queryVariables, }) =
48
48
  ref,
49
49
  products: data ? data.flatMap((page) => page === null || page === void 0 ? void 0 : page.products) : [],
50
50
  isLoading,
51
+ isValidating,
51
52
  };
52
53
  };
53
54
  export { useInfiniteScroll };
@@ -3,6 +3,6 @@ interface ScrollData {
3
3
  direction: ScrollDirection;
4
4
  scrollY: number;
5
5
  }
6
- declare function useScrollDirection(threshold?: number): ScrollData;
6
+ declare function useScrollDirection(threshold?: number, throttleDelay?: number): ScrollData;
7
7
  export { useScrollDirection };
8
8
  //# sourceMappingURL=use-scroll-direction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-scroll-direction.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-scroll-direction.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;AAE3C,UAAU,UAAU;IAClB,SAAS,EAAE,eAAe,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,iBAAS,kBAAkB,CAAC,SAAS,GAAE,MAAU,GAAG,UAAU,CAmC7D;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
1
+ {"version":3,"file":"use-scroll-direction.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-scroll-direction.ts"],"names":[],"mappings":"AAGA,KAAK,eAAe,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;AAE3C,UAAU,UAAU;IAClB,SAAS,EAAE,eAAe,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,iBAAS,kBAAkB,CACzB,SAAS,GAAE,MAAU,EACrB,aAAa,GAAE,MAAW,GACzB,UAAU,CAmDZ;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
@@ -1,10 +1,21 @@
1
+ "use client";
1
2
  import { useState, useEffect, useRef } from "react";
2
- function useScrollDirection(threshold = 5) {
3
+ function useScrollDirection(threshold = 5, throttleDelay = 50) {
3
4
  const [scrollData, setScrollData] = useState({
4
5
  direction: null,
5
6
  scrollY: 0,
6
7
  });
7
8
  const lastScrollY = useRef(0);
9
+ const throttle = (func, limit) => {
10
+ let inThrottle;
11
+ return (...args) => {
12
+ if (!inThrottle) {
13
+ func(...args);
14
+ inThrottle = true;
15
+ setTimeout(() => (inThrottle = false), limit);
16
+ }
17
+ };
18
+ };
8
19
  useEffect(() => {
9
20
  if (typeof window === "undefined") {
10
21
  return;
@@ -14,17 +25,18 @@ function useScrollDirection(threshold = 5) {
14
25
  return;
15
26
  }
16
27
  const scrollY = window.scrollY;
17
- const direction = scrollY > lastScrollY.current ? "down" : "up";
28
+ const direction = scrollY > lastScrollY.current && scrollY !== 0 ? "down" : "up";
18
29
  if (Math.abs(scrollY - lastScrollY.current) > threshold) {
19
30
  setScrollData({ direction, scrollY });
20
31
  lastScrollY.current = scrollY > 0 ? scrollY : 0;
21
32
  }
22
33
  };
23
- window.addEventListener("scroll", updateScrollDirection);
34
+ const throttledUpdateScrollDirection = throttle(updateScrollDirection, throttleDelay);
35
+ window.addEventListener("scroll", throttledUpdateScrollDirection);
24
36
  return () => {
25
- window.removeEventListener("scroll", updateScrollDirection);
37
+ window.removeEventListener("scroll", throttledUpdateScrollDirection);
26
38
  };
27
- }, [threshold]);
39
+ }, [threshold, throttleDelay]);
28
40
  return scrollData;
29
41
  }
30
42
  export { useScrollDirection };
@@ -23,7 +23,7 @@ const AccordionItem = React.forwardRef((_a, ref) => {
23
23
  AccordionItem.displayName = "AccordionItem";
24
24
  const AccordionTrigger = React.forwardRef((_a, ref) => {
25
25
  var { className, children } = _a, props = __rest(_a, ["className", "children"]);
26
- return (_jsx(AccordionPrimitive.Header, Object.assign({ className: "flex" }, { children: _jsxs(AccordionPrimitive.Trigger, Object.assign({ ref: ref, className: cn("px-4 flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]_svg]:rotate-180", className) }, props, { children: [children, _jsx(Icon, { name: "chevron-down", size: "sm", className: "text-coreColors-secondaryIcon shrink-0 transition-transform duration-200 " })] })) })));
26
+ return (_jsx(AccordionPrimitive.Header, Object.assign({ className: "flex" }, { children: _jsxs(AccordionPrimitive.Trigger, Object.assign({ ref: ref, className: cn("px-4 flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]_svg]:rotate-180 active:opacity-70", className) }, props, { children: [children, _jsx(Icon, { name: "chevron-down", size: "sm", className: "text-coreColors-secondaryIcon shrink-0 transition-transform duration-200 " })] })) })));
27
27
  });
28
28
  AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
29
29
  const AccordionContent = React.forwardRef((_a, ref) => {
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { type VariantProps } from "class-variance-authority";
3
3
  declare const badgeVariants: (props?: ({
4
- alignment?: "center" | "end" | "start" | null | undefined;
4
+ alignment?: "end" | "center" | "start" | null | undefined;
5
5
  cornerRadius?: "circle" | "square" | "rounded" | null | undefined;
6
6
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
7
  export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {
@@ -1 +1 @@
1
- {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../components/ui/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAOjE,QAAA,MAAM,cAAc;;;mFAmCnB,CAAA;AAED,MAAM,WAAW,WACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,cAAc,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC;CAC9C;AAED,QAAA,MAAM,MAAM,uFAyCX,CAAA;AAGD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA"}
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../components/ui/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAKjE,QAAA,MAAM,cAAc;;;mFAgCnB,CAAA;AAwCD,MAAM,WAAW,WACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,cAAc,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAA;CAC7C;AAED,QAAA,MAAM,MAAM,uFAoEX,CAAA;AAGD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA"}
@@ -13,11 +13,10 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
13
13
  import * as React from "react";
14
14
  import { Slot } from "@radix-ui/react-slot";
15
15
  import { cva } from "class-variance-authority";
16
- import { IconLoader2 } from "@tabler/icons-react";
17
16
  import { cn } from "../../lib/utils";
18
17
  import { Icon } from "./icon";
19
18
  import { Text } from "./text";
20
- const buttonVariants = cva("w-full flex rounded items-center justify-center transition-colors disabled:bg-stateColors-disabled disabled:outline-stateColors-disabled disabled:pointer-events-none ring-offset-background overflow-elipse whitespace-nowrap truncate", {
19
+ const buttonVariants = cva("w-full flex rounded items-center justify-center transition-colors disabled:bg-stateColors-disabled disabled:border-stateColors-disabled disabled:pointer-events-none ring-offset-background overflow-elipse whitespace-nowrap truncate active:opacity-70 disabled:opacity-70", {
21
20
  variants: {
22
21
  size: {
23
22
  default: "py-3 px-4",
@@ -27,14 +26,14 @@ const buttonVariants = cva("w-full flex rounded items-center justify-center tran
27
26
  content: "py-3 px-4 w-auto",
28
27
  },
29
28
  variant: {
30
- default: "bg-buttonColors-primaryFill [&_svg]:text-buttonColors-primaryText [&>p]:text-buttonColors-primaryText outline outline-1 outline-buttonColors-primaryOutline active:opacity-70 shadow-buttonColors-primaryShadow",
31
- destructive: "bg-stateColors-error [&_svg]:text-coreColors-pageColor [&>p]:text-coreColors-pageColor active:opacity-70 disabled:bg-stateColors-disabled shadow-buttonColors-primaryShadow",
32
- outline: "outline outline-1 outline-input hover:bg-accent hover:[&>p]:text-accent-foreground hover:[&_svg]:text-accent-foreground",
33
- secondary: "bg-buttonColors-secondaryFill [&_svg]:text-buttonColors-secondaryText [&>p]:text-buttonColors-secondaryText outline outline-1 outline-buttonColors-secondaryOutline active:opacity-70 disabled:bg-buttonColors-secondaryFill disabled:text-stateColors-disabled disabled:border-stateColors-disabled shadow-buttonColors-secondaryShadow",
34
- ghost: "hover:bg-accent hover:[&>p]:text-accent-foreground hover:[&_svg]:text-accent-foreground",
35
- link: "underline-offset-4 hover:underline [&_svg]:text-textColors-primaryColor [&>p]:text-textColors-primaryColor disabled:text-stateColors-disabled disabled:bg-transparent",
36
- quickadd: "bg-buttonColors-primaryFill [&_svg]:text-buttonColors-primaryText [&>p]:text-buttonColors-primaryText outline outline-1 outline-buttonColors-primaryOutline active:opacity-70 w-full rounded-none rounded-b-lg h-8 text-xs",
37
- applePay: "bg-white [&_svg]:text-black [&>p]:text-black border border-black",
29
+ default: "bg-buttonColors-primaryFill border border-buttonColors-primaryOutlineColor shadow-buttonColors-primaryShadow",
30
+ destructive: "bg-stateColors-error disabled:bg-stateColors-disabled shadow-buttonColors-primaryShadow",
31
+ outline: "border border-input hover:bg-accent",
32
+ secondary: "bg-buttonColors-secondaryFill border border-buttonColors-secondaryOutlineColor disabled:bg-buttonColors-secondaryFill disabled:text-stateColors-disabled disabled:border-stateColors-disabled shadow-buttonColors-secondaryShadow",
33
+ ghost: "hover:bg-accent",
34
+ link: "underline-offset-4 hover:underline disabled:text-stateColors-disabled disabled:bg-transparent",
35
+ quickadd: "bg-buttonColors-primaryFill border border-buttonColors-primaryOutlineColor w-full rounded-none rounded-b-lg h-8 text-xs",
36
+ applePay: "bg-white border border-black",
38
37
  shopPay: "bg-[#612EFF]",
39
38
  },
40
39
  },
@@ -43,14 +42,50 @@ const buttonVariants = cva("w-full flex rounded items-center justify-center tran
43
42
  size: "default",
44
43
  },
45
44
  });
45
+ const iconVariants = cva("", {
46
+ variants: {
47
+ variant: {
48
+ default: "text-buttonColors-primaryText",
49
+ destructive: "text-coreColors-pageColor",
50
+ outline: "hover:text-accent-foreground",
51
+ secondary: "text-buttonColors-secondaryText",
52
+ ghost: "hover:text-accent-foreground",
53
+ link: "text-textColors-primaryColor",
54
+ quickadd: "text-buttonColors-primaryText",
55
+ applePay: "text-black",
56
+ shopPay: "",
57
+ },
58
+ },
59
+ defaultVariants: {
60
+ variant: "default",
61
+ },
62
+ });
63
+ const labelVariants = cva("truncate", {
64
+ variants: {
65
+ variant: {
66
+ default: "text-buttonColors-primaryText",
67
+ destructive: "text-coreColors-pageColor",
68
+ outline: "hover:text-accent-foreground",
69
+ secondary: "text-buttonColors-secondaryText",
70
+ ghost: "hover:text-accent-foreground",
71
+ link: "text-textColors-primaryColor",
72
+ quickadd: "text-buttonColors-primaryText",
73
+ applePay: "text-black border",
74
+ shopPay: "",
75
+ },
76
+ },
77
+ defaultVariants: {
78
+ variant: "default",
79
+ },
80
+ });
46
81
  const Button = React.forwardRef((_a, ref) => {
47
82
  var { className, labelClassName, labelStyle, variant, size, asChild = false, loading, icon } = _a, props = __rest(_a, ["className", "labelClassName", "labelStyle", "variant", "size", "asChild", "loading", "icon"]);
48
83
  const Comp = asChild ? Slot : "button";
49
- const IconButton = () => !loading && size === "icon" && icon ? (_jsx(Icon, { name: icon, size: "sm" })) : null;
50
- const BasicButton = () => (_jsxs(_Fragment, { children: [icon ? (_jsx(Icon, { name: icon, size: variant === "quickadd" ? "xs" : "sm", className: "mr-2" })) : null, !loading ? _jsx(Text, Object.assign({ type: "body-primary", className: cn("truncate", labelClassName), style: labelStyle }, { children: props.children })) : _jsx(_Fragment, {})] }));
51
- return (_jsx(Comp, Object.assign({ className: cn(buttonVariants({ variant, size, className }), {
84
+ const IconButton = () => (icon ? _jsx(Icon, { name: icon, size: "sm" }) : null);
85
+ const BasicButton = () => (_jsxs(_Fragment, { children: [icon ? (_jsx(Icon, { name: icon, size: variant === "quickadd" ? "xs" : "sm", className: cn(iconVariants({ variant }), "mr-2") })) : null, !loading ? (_jsx(Text, Object.assign({ type: "body-primary", className: cn(labelVariants({ variant }), labelClassName), style: labelStyle }, { children: props.children }))) : (_jsx(_Fragment, {}))] }));
86
+ return (_jsx(Comp, Object.assign({ className: cn(buttonVariants({ variant, size }), className, {
52
87
  "pointer-events-none": loading,
53
- }), ref: ref }, props, { children: loading ? (_jsx(IconLoader2, { className: "h-4 w-4 animate-spin" })) : size === "icon" ? (_jsx(IconButton, {})) : (_jsx(BasicButton, {})) })));
88
+ }), ref: ref }, props, { children: loading ? (_jsx("div", Object.assign({ className: cn("flex items-center justify-center", size === "icon" ? "h-5" : "h-6") }, { children: _jsx(Icon, { className: cn(iconVariants({ variant }), "h-5 w-5 animate-spin"), name: "loader" }) }))) : size === "icon" ? (_jsx(IconButton, {})) : (_jsx(BasicButton, {})) })));
54
89
  });
55
90
  Button.displayName = "Button";
56
91
  export { Button, buttonVariants };
@@ -23,7 +23,7 @@ const checkboxVariants = cva("flex flex-col group group-disabled", {
23
23
  variants: {
24
24
  deactivated: {
25
25
  true: "[&_p]:text-stateColors-disabled",
26
- false: "",
26
+ false: "active:opacity-70",
27
27
  },
28
28
  },
29
29
  defaultVariants: {
@@ -32,7 +32,7 @@ const checkboxVariants = cva("flex flex-col group group-disabled", {
32
32
  });
33
33
  const Checkbox = React.forwardRef((_a, ref) => {
34
34
  var { id, className, label, numberAmount, subtext, selected = false, onCheck, onSelect, deactivated = false } = _a, props = __rest(_a, ["id", "className", "label", "numberAmount", "subtext", "selected", "onCheck", "onSelect", "deactivated"]);
35
- return (_jsx("div", Object.assign({ className: cn(checkboxVariants({ deactivated })) }, { children: _jsx(CheckboxPrimitive.Root, Object.assign({ ref: ref, className: cn("peer h-6 shrink-0 self-start rounded ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 group ", className), id: id, checked: selected, onSelect: onSelect, onCheckedChange: onCheck, disabled: deactivated !== null && deactivated !== void 0 ? deactivated : false }, props, { children: _jsxs("div", Object.assign({ className: "grid grid-cols-[auto,auto,1fr] gap-2 items-start group" }, { children: [_jsxs("div", Object.assign({ className: "grid" }, { children: [_jsx(CheckboxPrimitive.Indicator, Object.assign({ className: "flex items-center justify-center text-current col-start-1 row-start-1" }, { children: !deactivated && (_jsx(Check, { className: "col-start-1 row-start-1 items-center z-50 text-coreColors-brandColorPrimary" })) })), _jsxs("div", Object.assign({ className: "flex items-center justify-center col-start-1 row-start-1" }, { children: [!deactivated && (_jsx(Unchecked, { className: "text-coreColors-secondaryIcon" })), deactivated && (_jsx(DisabledCheckbox, { className: "text-stateColors-disabled" }))] }))] })), _jsxs("div", Object.assign({ className: "flex flex-col gap-2 items-start" }, { children: [label && (_jsx("label", Object.assign({ htmlFor: id }, { children: _jsxs("span", Object.assign({ className: "flex gap-2" }, { children: [_jsx(Text, Object.assign({ type: "body-primary", className: "group-disabled:text-stateColors-disabled" }, { children: label })), numberAmount && (_jsxs(Text, Object.assign({ type: "body-primary", className: "text-textColors-secondaryColor group-disabled:text-stateColors-disabled inline" }, { children: ["(", numberAmount, ")"] })))] })) }))), subtext && (_jsx(Text, Object.assign({ type: "body-secondary", className: "group-disabled:text-stateColors-disabled" }, { children: subtext })))] }))] })) })) })));
35
+ return (_jsx("div", Object.assign({ className: cn(checkboxVariants({ deactivated })) }, { children: _jsx(CheckboxPrimitive.Root, Object.assign({ ref: ref, className: cn("peer h-6 shrink-0 self-start rounded ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 group ", className), id: id, checked: selected, onSelect: onSelect, onCheckedChange: onCheck, disabled: deactivated !== null && deactivated !== void 0 ? deactivated : false }, props, { children: _jsxs("div", Object.assign({ className: "grid grid-cols-[auto,auto,1fr] gap-2 items-start group" }, { children: [_jsxs("div", Object.assign({ className: "grid" }, { children: [_jsx(CheckboxPrimitive.Indicator, Object.assign({ className: "flex items-center justify-center text-current col-start-1 row-start-1" }, { children: !deactivated && (_jsx(Check, { className: "col-start-1 row-start-1 items-center z-50 text-coreColors-brandColorPrimary" })) })), _jsxs("div", Object.assign({ className: "flex items-center justify-center col-start-1 row-start-1" }, { children: [!deactivated && !selected && (_jsx(Unchecked, { className: "text-coreColors-secondaryIcon" })), deactivated && (_jsx(DisabledCheckbox, { className: "text-stateColors-disabled" }))] }))] })), _jsxs("div", Object.assign({ className: "flex flex-col gap-2 items-start" }, { children: [label && (_jsx("label", Object.assign({ htmlFor: id }, { children: _jsxs("span", Object.assign({ className: "flex gap-2" }, { children: [_jsx(Text, Object.assign({ type: "body-primary", className: "group-disabled:text-stateColors-disabled" }, { children: label })), numberAmount && (_jsxs(Text, Object.assign({ type: "body-primary", className: "text-textColors-secondaryColor group-disabled:text-stateColors-disabled inline" }, { children: ["(", numberAmount, ")"] })))] })) }))), subtext && (_jsx(Text, Object.assign({ type: "body-secondary", className: "group-disabled:text-stateColors-disabled" }, { children: subtext })))] }))] })) })) })));
36
36
  });
37
37
  Checkbox.displayName = CheckboxPrimitive.Root.displayName;
38
38
  export { Checkbox };
@@ -1 +1 @@
1
- {"version":3,"file":"chip.d.ts","sourceRoot":"","sources":["../../../components/ui/chip.tsx"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,KAAsC,MAAM,OAAO,CAAA;AAG1D,QAAA,MAAM,YAAY;;;mFAkBjB,CAAA;AAED,KAAK,SAAS,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,GACvD,YAAY,CAAC,OAAO,YAAY,CAAC,GAAG;IAClC,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,GAAG,O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C,CAAA;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAkD/C,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,CAAA"}
@@ -15,7 +15,7 @@ import { cva } from "class-variance-authority";
15
15
  import { cn } from "../../lib/utils";
16
16
  import React, { useState, useEffect } from "react";
17
17
  import { Icon } from "./icon";
18
- const chipVariants = cva("inline-flex items-center justify-center rounded border border-coreColors-dividingLines text-[12px] transition-colors p-2 h-8", {
18
+ const chipVariants = cva("inline-flex items-center justify-center rounded border border-coreColors-dividingLines text-[12px] transition-colors p-2 h-8 active:opacity-70", {
19
19
  variants: {
20
20
  variant: {
21
21
  primary: "bg-coreColors-pageColor text-textColors-primaryColor",
@@ -39,7 +39,7 @@ const Chip = React.forwardRef((_a, ref) => {
39
39
  const handleIconClick = () => {
40
40
  onIconClick === null || onIconClick === void 0 ? void 0 : onIconClick();
41
41
  };
42
- return (_jsxs("button", Object.assign({ onClick: handleOnClick, ref: ref, className: cn(chipVariants({ variant, direction }), className) }, props, { children: [iconPosition === "left" && (_jsx(Icon, { name: "square-x-filled", className: "mr-2 h-4 w-4 cursor-pointer", onClick: handleIconClick })), children, Icon && iconPosition === "right" && (_jsx(Icon, { name: "square-x-filled", className: "ml-2 h-4 w-4 cursor-pointer", onClick: handleIconClick }))] })));
42
+ return (_jsxs("button", Object.assign({ onClick: handleOnClick, ref: ref, className: cn(chipVariants({ variant, direction }), className) }, props, { children: [iconPosition === "left" && (_jsx(Icon, { name: "square-x-filled", className: "mr-2 h-4 w-4 cursor-pointer", color: "coreColors-secondaryIcon", onClick: handleIconClick })), children, Icon && iconPosition === "right" && (_jsx(Icon, { name: "square-x-filled", className: "ml-2 h-4 w-4 cursor-pointer", onClick: handleIconClick, color: "coreColors-secondaryIcon" }))] })));
43
43
  });
44
44
  Chip.displayName = "Chip";
45
45
  const MultipleChips = ({ children, containerRef, }) => {
@@ -59,7 +59,7 @@ const MultipleChips = ({ children, containerRef, }) => {
59
59
  useEffect(() => {
60
60
  checkOverflow();
61
61
  }, [children]);
62
- return (_jsxs("div", Object.assign({ className: "relative" }, { children: [_jsx("div", Object.assign({ ref: containerRef, className: "flex overflow-x-auto overflow-y-none overscroll-y-none no-scrollbar", onScroll: checkOverflow }, { children: children.map((chip, index) => (_jsx("div", Object.assign({ className: cn("shrink-0", {
62
+ return (_jsxs("div", Object.assign({ className: "relative" }, { children: [_jsx("div", Object.assign({ ref: containerRef, className: "flex overflow-x-auto overflow-y-hidden no-scrollbar", onScroll: checkOverflow }, { children: children.map((chip, index) => (_jsx("div", Object.assign({ className: cn("shrink-0", {
63
63
  "mr-2": index < children.length - 1,
64
64
  }) }, { children: chip }), index))) })), showFadeLeft && (_jsx("div", { className: "absolute top-0 left-0 w-8 h-full pointer-events-none bg-fade-left" })), showFadeRight && (_jsx("div", { className: "absolute top-0 right-0 w-8 h-full pointer-events-none bg-fade-right" }))] })));
65
65
  };
@@ -57,7 +57,7 @@ const DrawerDescription = React.forwardRef((_a, ref) => {
57
57
  });
58
58
  DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
59
59
  const DrawerHeader = ({ title, iconLeftName, iconRightName, onCloseClick, }) => {
60
- return (_jsxs(DrawerHeaderBase, Object.assign({ className: "p-4 text-center flex justify-between" }, { children: [iconLeftName ? (_jsx(DrawerClose, Object.assign({ className: "h-6 w-6 p-0", onClick: onCloseClick }, { children: _jsx(Icon, { name: iconLeftName, className: "h-6 w-6 p-0", size: "md" }) }))) : (_jsx("div", { className: "w-6" })), _jsx(DrawerTitle, { children: title }), iconRightName ? (_jsx(DrawerClose, Object.assign({ className: "h-6 w-6 p-0", onClick: onCloseClick }, { children: _jsx(Icon, { name: iconRightName, className: "h-6 w-6 p-0", size: "md" }) }))) : (_jsx("div", { className: "w-6" }))] })));
60
+ return (_jsxs(DrawerHeaderBase, Object.assign({ className: "p-4 text-center flex justify-between" }, { children: [iconLeftName ? (_jsx(DrawerClose, Object.assign({ className: "h-6 w-6 p-0", onClick: onCloseClick }, { children: _jsx(Icon, { name: iconLeftName, color: "coreColors-secondaryIcon", className: "h-6 w-6 p-0", size: "md" }) }))) : (_jsx("div", { className: "w-6" })), _jsx(DrawerTitle, { children: title }), iconRightName ? (_jsx(DrawerClose, Object.assign({ className: "h-6 w-6 p-0", onClick: onCloseClick }, { children: _jsx(Icon, { name: iconRightName, color: "coreColors-secondaryIcon", className: "h-6 w-6 p-0", size: "md" }) }))) : (_jsx("div", { className: "w-6" }))] })));
61
61
  };
62
62
  const DrawerContent = ({ children }) => {
63
63
  return _jsx("div", Object.assign({ className: "h-full overflow-scroll" }, { children: children }));
@@ -1 +1 @@
1
- {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../components/ui/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAEL,eAAe,EA0BhB,MAAM,qBAAqB,CAAA;AAI5B,QAAA,MAAM,YAAY;;;mFAgBjB,CAAA;AA6CD,MAAM,WAAW,SACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,EACzD,YAAY,CAAC,OAAO,YAAY,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,iBAAS,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,IAAW,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,2CAczE;AAED,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,eAAe,EAAE,CAAA"}
1
+ {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../components/ui/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAEL,eAAe,EA6BhB,MAAM,qBAAqB,CAAA;AAI5B,QAAA,MAAM,YAAY;;;mFAgBjB,CAAA;AAiDD,MAAM,WAAW,SACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,EACzD,YAAY,CAAC,OAAO,YAAY,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,iBAAS,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,IAAW,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,2CAczE;AAED,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,eAAe,EAAE,CAAA"}
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { cva } from "class-variance-authority";
14
- import { IconUpload, IconPencilMinus, IconPlus, IconMinus, IconAdjustmentsAlt, IconArrowsSort, IconAlertCircle, IconCircleX, IconInfoCircle, IconCheck, IconSquareOff, IconMapPin, IconRepeat, IconSquare, IconSquareCheck, IconChevronUp, IconEyeOff, IconSquareX, IconCircle, IconChevronDown, IconHeartFilled, IconCurrencyDollar, IconX, IconCircleOff, IconCircleDotFilled, IconMoodSad, IconSquareXFilled, } from "@tabler/icons-react";
14
+ import { IconUpload, IconPencilMinus, IconPlus, IconMinus, IconAdjustmentsAlt, IconArrowsSort, IconAlertCircle, IconCircleX, IconInfoCircle, IconCheck, IconSquareOff, IconMapPin, IconRepeat, IconSquare, IconSquareCheck, IconChevronUp, IconChevronRight, IconEyeOff, IconSquareX, IconCircle, IconChevronDown, IconHeartFilled, IconCurrencyDollar, IconX, IconCircleOff, IconCircleDotFilled, IconMoodSad, IconSquareXFilled, IconTrash, IconLoader2, } from "@tabler/icons-react";
15
15
  import { cn, iconColorVariantClasses } from "../../lib/utils";
16
16
  const iconVariants = cva("inline-flex items-center justify-center text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ring-offset-background", {
17
17
  variants: {
@@ -54,11 +54,13 @@ const icons = {
54
54
  square: IconSquare,
55
55
  "square-check": IconSquareCheck,
56
56
  "chevron-up": IconChevronUp,
57
+ "chevron-right": IconChevronRight,
57
58
  "eye-off": IconEyeOff,
58
59
  "square-x": IconSquareX,
59
60
  circle: IconCircle,
60
61
  "chevron-down": IconChevronDown,
61
62
  "heart-filled": IconHeartFilled,
63
+ "menu-icon-heart": IconHeartFilled,
62
64
  upload: IconUpload,
63
65
  "currency-dollar": IconCurrencyDollar,
64
66
  x: IconX,
@@ -66,6 +68,8 @@ const icons = {
66
68
  "circle-dot-filled": IconCircleDotFilled,
67
69
  "mood-sad": IconMoodSad,
68
70
  "square-x-filled": IconSquareXFilled,
71
+ trash: IconTrash,
72
+ loader: IconLoader2,
69
73
  };
70
74
  function Icon(_a) {
71
75
  var { className, name, size = "md", color } = _a, props = __rest(_a, ["className", "name", "size", "color"]);
@@ -0,0 +1,157 @@
1
+ import * as React from "react";
2
+ import type { PartialDeep } from "type-fest";
3
+ import type { Image as ImageType } from "app-studio-types";
4
+ type SrcSetOptions = {
5
+ intervals: number;
6
+ startingWidth: number;
7
+ incrementSize: number;
8
+ placeholderWidth: number;
9
+ };
10
+ export type LoaderParams = {
11
+ src?: ImageType["url"];
12
+ width?: number;
13
+ height?: number;
14
+ crop?: Crop;
15
+ isContained?: boolean;
16
+ };
17
+ export type Loader = (params: LoaderParams) => string;
18
+ type Crop = "center" | "top" | "bottom" | "left" | "right";
19
+ export type TapcartImageProps = React.ComponentPropsWithRef<"img"> & TapcartImageBaseProps;
20
+ type TapcartImageBaseProps = {
21
+ /** The aspect ratio of the image, in the format of `width/height`.
22
+ *
23
+ * @example
24
+ * ```
25
+ * <Image data={productImage} aspectRatio="4/5" />
26
+ * ```
27
+ */
28
+ aspectRatio?: string;
29
+ /** The crop position of the image.
30
+ *
31
+ * @remarks
32
+ * In the event that AspectRatio is set, without specifying a crop,
33
+ * the Shopify CDN won't return the expected image.
34
+ *
35
+ * @defaultValue `center`
36
+ */
37
+ crop?: Crop;
38
+ data?: PartialDeep<ImageType, {
39
+ recurseIntoArrays: true;
40
+ }>;
41
+ /** A function that returns a URL string for an image.
42
+ *
43
+ * @remarks
44
+ * By default, this uses Shopify’s CDN {@link https://cdn.shopify.com/} but you can provide
45
+ * your own function to use a another provider, as long as they support URL based image transformations.
46
+ */
47
+ loader?: Loader;
48
+ /** An optional prop you can use to change the default srcSet generation behaviour */
49
+ srcSetOptions?: SrcSetOptions;
50
+ /** An optional prop to set the fill behavior of the image. Defaults to "cover"
51
+ *
52
+ * @remarks
53
+ * "fit" maps to `object-fit: contain`
54
+ * "fill" maps to `object-fit: cover`
55
+ */
56
+ objectFit?: "fit" | "fill" | "cover" | "contain" | "none" | "scale-down";
57
+ };
58
+ /**
59
+ * Tapcart’s Image component is a wrapper around the HTML image element.
60
+ * It supports the same props as the HTML `img` element, but automatically
61
+ * generates the srcSet and sizes attributes for you. For most use cases,
62
+ * you’ll want to set the `aspectRatio` prop to ensure the image is sized
63
+ * correctly.
64
+ *
65
+ * @remarks
66
+ * - `decoding` is set to `async` by default.
67
+ * - `loading` is set to `lazy` by default.
68
+ * - `alt` will automatically be set to the `altText` from the Storefront API if passed in the `data` prop
69
+ * - `src` will automatically be set to the `url` from the Storefront API if passed in the `data` prop
70
+ *
71
+ * @example
72
+ * A responsive image with a 4:5 aspect ratio:
73
+ * ```
74
+ * <Image
75
+ * data={product.featuredImage}
76
+ * aspectRatio="4:5"
77
+ * sizes="(min-width: 45em) 40vw, 100vw"
78
+ * />
79
+ * ```
80
+ * @example
81
+ * A fixed size image:
82
+ * ```
83
+ * <Image
84
+ * data={product.featuredImage}
85
+ * width={100}
86
+ * height={100}
87
+ * />
88
+ * ```
89
+ *
90
+ * {@link https://shopify.dev/docs/api/hydrogen-react/components/image}
91
+ */
92
+ export declare const Image: React.ForwardRefExoticComponent<Omit<TapcartImageProps, "ref"> & React.RefAttributes<HTMLImageElement>>;
93
+ /**
94
+ * The shopifyLoader function is a simple utility function that takes a src, width,
95
+ * height, and crop and returns a string that can be used as the src for an image.
96
+ * It can be used with the Tapcart Image component or with the next/image component.
97
+ * (or any others that accept equivalent configuration)
98
+ * @param src - The source URL of the image, e.g. `https://cdn.shopify.com/static/sample-images/garnished.jpeg`
99
+ * @param width - The width of the image, e.g. `100`
100
+ * @param height - The height of the image, e.g. `100`
101
+ * @param crop - The crop of the image, e.g. `center`
102
+ * @returns A Shopify image URL with the correct query parameters, e.g. `https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=100&height=100&crop=center`
103
+ *
104
+ * @example
105
+ * ```
106
+ * shopifyLoader({
107
+ * src: 'https://cdn.shopify.com/static/sample-images/garnished.jpeg',
108
+ * width: 100,
109
+ * height: 100,
110
+ * crop: 'center',
111
+ * })
112
+ * ```
113
+ */
114
+ export declare function shopifyLoader({ src, width, height, crop, isContained, }: LoaderParams): string;
115
+ /**
116
+ * This function generates a srcSet for Shopify images.
117
+ * @param src - The source URL of the image, e.g. https://cdn.shopify.com/static/sample-images/garnished.jpeg
118
+ * @param sizesArray - An array of objects containing the `width`, `height`, and `crop` of the image, e.g. [\{width: 200, height: 200, crop: 'center'\}, \{width: 400, height: 400, crop: 'center'\}]
119
+ * @param loader - A function that takes a Shopify image URL and returns a Shopify image URL with the correct query parameters
120
+ * @returns A srcSet for Shopify images, e.g. 'https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=200&height=200&crop=center 200w, https://cdn.shopify.com/static/sample-images/garnished.jpeg?width=400&height=400&crop=center 400w'
121
+ */
122
+ export declare function generateSrcSet(src?: string, sizesArray?: Array<{
123
+ width?: number;
124
+ height?: number;
125
+ crop?: Crop;
126
+ }>, loader?: Loader, isContained?: boolean): string;
127
+ /**
128
+ * This function generates an array of sizes for Shopify images, for both fixed and responsive images.
129
+ * @param width - The CSS width of the image
130
+ * @param intervals - The number of intervals to generate
131
+ * @param startingWidth - The starting width of the image
132
+ * @param incrementSize - The size of each interval
133
+ * @returns An array of widths
134
+ */
135
+ export declare function generateImageWidths(width: string | number | undefined, intervals: number, startingWidth: number, incrementSize: number): number[];
136
+ /**
137
+ * Simple utility function to convert an aspect ratio CSS string to a decimal, currently only supports values like `1:1`, not `0.5`, or `auto`
138
+ * @param aspectRatio - The aspect ratio of the image, e.g. `1:1`
139
+ * @returns The aspect ratio as a number, e.g. `1`
140
+ *
141
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio}
142
+ */
143
+ export declare function parseAspectRatio(aspectRatio?: string): number | undefined;
144
+ /**
145
+ * Generate sizes for Imagery loader
146
+ * @param imageWidths
147
+ * @param aspectRatio
148
+ * @param crop
149
+ * @returns
150
+ */
151
+ export declare function generateSizes(imageWidths?: number[], aspectRatio?: string, crop?: Crop): {
152
+ width: number;
153
+ height: number | undefined;
154
+ crop: Crop;
155
+ }[] | undefined;
156
+ export {};
157
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../components/ui/image.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAM1D,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAUD,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,M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