@dropins/storefront-wishlist 0.1.0-alpha1 → 0.2.1-alpha

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 (71) hide show
  1. package/api/fragments.d.ts +0 -2
  2. package/api/removeProductsFromWishlist/graphql/removeProductsFromWishlistMutation.d.ts +1 -1
  3. package/api/removeProductsFromWishlist/removeProductsFromWishlist.d.ts +2 -7
  4. package/api.js +28 -3
  5. package/chunks/Heart.js +3 -0
  6. package/chunks/HeartFilled.js +1 -1
  7. package/chunks/Trash.js +3 -0
  8. package/chunks/WishlistAlert.js +3 -0
  9. package/chunks/WishlistItem.js +1 -1
  10. package/chunks/initializeWishlist.js +137 -10
  11. package/chunks/removeProductsFromWishlist.js +2 -150
  12. package/components/Login/Login.d.ts +4 -1
  13. package/components/ProductItem/ProductItem.d.ts +1 -0
  14. package/components/TaxDetails/TaxDetails.d.ts +9 -0
  15. package/{api/graphql/WishlistPaginationArguments.graphql.d.ts → components/TaxDetails/index.d.ts} +3 -2
  16. package/components/index.d.ts +1 -0
  17. package/containers/Wishlist/Wishlist.d.ts +1 -0
  18. package/containers/Wishlist.js +1 -1
  19. package/containers/WishlistAlert/WishlistAlert.d.ts +14 -0
  20. package/{api/graphql/WishlistPaginationVariables.graphql.d.ts → containers/WishlistAlert/index.d.ts} +3 -2
  21. package/containers/WishlistAlert.d.ts +3 -0
  22. package/containers/WishlistAlert.js +3 -0
  23. package/containers/WishlistItem/WishlistItem.d.ts +2 -2
  24. package/containers/WishlistItem.js +1 -1
  25. package/containers/WishlistToggle/WishlistToggle.d.ts +9 -0
  26. package/containers/WishlistToggle.js +1 -1
  27. package/containers/index.d.ts +1 -0
  28. package/data/models/wishlist.d.ts +0 -1
  29. package/lib/persisted-data.d.ts +1 -0
  30. package/package.json +1 -1
  31. package/render/index.d.ts +16 -0
  32. package/render.js +1 -2
  33. package/chunks/Add.js +0 -3
  34. package/chunks/AddressBook.js +0 -3
  35. package/chunks/Bulk.js +0 -3
  36. package/chunks/Burger.js +0 -3
  37. package/chunks/Card.js +0 -3
  38. package/chunks/Check.js +0 -3
  39. package/chunks/CheckWithCircle.js +0 -3
  40. package/chunks/ChevronRight.js +0 -3
  41. package/chunks/ChevronUp.js +0 -3
  42. package/chunks/Close.js +0 -3
  43. package/chunks/Coupon.js +0 -3
  44. package/chunks/Date.js +0 -3
  45. package/chunks/Delivery.js +0 -3
  46. package/chunks/EmptyBox.js +0 -3
  47. package/chunks/Eye.js +0 -3
  48. package/chunks/EyeClose.js +0 -3
  49. package/chunks/Gift.js +0 -3
  50. package/chunks/GiftCard.js +0 -3
  51. package/chunks/InfoFilled.js +0 -3
  52. package/chunks/Locker.js +0 -3
  53. package/chunks/Minus.js +0 -3
  54. package/chunks/Order.js +0 -3
  55. package/chunks/OrderError.js +0 -3
  56. package/chunks/OrderSuccess.js +0 -3
  57. package/chunks/PaymentError.js +0 -3
  58. package/chunks/Placeholder.js +0 -3
  59. package/chunks/PlaceholderFilled.js +0 -3
  60. package/chunks/Search.js +0 -3
  61. package/chunks/SearchFilled.js +0 -3
  62. package/chunks/Sort.js +0 -3
  63. package/chunks/Star.js +0 -3
  64. package/chunks/User.js +0 -3
  65. package/chunks/View.js +0 -3
  66. package/chunks/Wallet.js +0 -3
  67. package/chunks/Warning.js +0 -3
  68. package/chunks/WarningFilled.js +0 -3
  69. package/chunks/WarningWithCircle.js +0 -3
  70. package/chunks/getWishlistById.js +0 -31
  71. package/components/Wishlist/Wishlist.d.ts +0 -17
@@ -1,5 +1,3 @@
1
1
  export { WISHLIST_ITEM_FRAGMENT } from './graphql/WishlistItemFragment.graphql';
2
- export { WISHLIST_PAGINATION_ARGUMENTS } from './graphql/WishlistPaginationArguments.graphql';
3
- export { WISHLIST_PAGINATION_VARIABLES } from './graphql/WishlistPaginationVariables.graphql';
4
2
  export { WISHLIST_FRAGMENT } from './graphql/WishlistFragment.graphql';
5
3
  //# sourceMappingURL=fragments.d.ts.map
@@ -14,5 +14,5 @@
14
14
  * is strictly forbidden unless prior written permission is obtained
15
15
  * from Adobe.
16
16
  *******************************************************************/
17
- export declare const REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION: string;
17
+ export declare const REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION = "\n mutation REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION(\n $wishlistId: ID!, \n $wishlistItemsIds: [ID!]!,\n ) {\n removeProductsFromWishlist(\n wishlistId: $wishlistId\n wishlistItemsIds: $wishlistItemsIds\n ) {\n user_errors {\n code\n message\n }\n }\n }\n";
18
18
  //# sourceMappingURL=removeProductsFromWishlistMutation.d.ts.map
@@ -1,9 +1,4 @@
1
- import { Wishlist } from '../../data/models/wishlist';
1
+ import { Item, Wishlist } from '../../data/models/wishlist';
2
2
 
3
- export declare const removeProductsFromWishlist: (items: Array<{
4
- id: string;
5
- product: {
6
- sku: string;
7
- };
8
- }>) => Promise<Wishlist | null>;
3
+ export declare const removeProductsFromWishlist: (items: Array<Item>) => Promise<Wishlist | null>;
9
4
  //# sourceMappingURL=removeProductsFromWishlist.d.ts.map
package/api.js CHANGED
@@ -1,6 +1,31 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{a as P,c as _,f as w,h as S,b as D,g as E,d as F,i as G,e as H,r as U}from"./chunks/initializeWishlist.js";import{W as h,s as l,f as I,h as n,t as d}from"./chunks/removeProductsFromWishlist.js";import{e as N,g as O,c as $,r as x,a as C,b as L,d as M,i as Q}from"./chunks/removeProductsFromWishlist.js";import{g as b}from"./chunks/getWishlistById.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";const c=`
3
+ import{W as _,t as h,b as u}from"./chunks/initializeWishlist.js";import{a as G,c as H,h as F,j as v,d as U,g as A,e as L,i as M,f as N,r as R}from"./chunks/initializeWishlist.js";import{s as l,g as c,f as n,h as I}from"./chunks/removeProductsFromWishlist.js";import{e as y,j as O,c as Q,r as b,a as B,b as C,d as Y,i as x}from"./chunks/removeProductsFromWishlist.js";import{events as d}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";const m=`
4
+ query GET_WISHLIST_BY_ID_QUERY(
5
+ $wishlistId: ID!,
6
+ ) {
7
+ customer {
8
+ wishlist_v2(id: $wishlistId) {
9
+ id
10
+ updated_at
11
+ sharing_code
12
+ items_count
13
+ items_v2 {
14
+ items {
15
+ ...WISHLIST_ITEM_FRAGMENT
16
+ }
17
+ page_info {
18
+ page_size
19
+ current_page
20
+ total_pages
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }
26
+
27
+ ${_}
28
+ `,w=async(r,o,e)=>{if(!l.authenticated)return c();if(!r)throw Error("Wishlist ID is not set");return n(m,{variables:{wishlistId:r,currentPage:o,pageSize:e}}).then(({errors:s,data:t})=>{var a;if(s)return I(s);if(!((a=t==null?void 0:t.customer)!=null&&a.wishlist_v2))return null;const i=h(t.customer.wishlist_v2);return d.emit("wishlist/data",i),i})},p=`
4
29
  mutation UPDATE_PRODUCTS_IN_WISHLIST_MUTATION(
5
30
  $wishlistId: ID!,
6
31
  $wishlistItems: [WishlistItemUpdateInput!]!,
@@ -19,5 +44,5 @@ import{a as P,c as _,f as w,h as S,b as D,g as E,d as F,i as G,e as H,r as U}fro
19
44
  }
20
45
  }
21
46
 
22
- ${h}
23
- `,g=async a=>{const r=l.wishlistId;if(!r)throw Error("Wishlist ID is not set");return I(c,{variables:{wishlistId:r,wishlistItems:a.map(({wishlistItemId:e,quantity:s,description:t,selectedOptions:i,enteredOptions:o})=>({wishlistItemId:e,quantity:s,description:t,selected_options:i,entered_options:o}))}}).then(({errors:e,data:s})=>{var i;const t=[...((i=s==null?void 0:s.updateProductsInWishlist)==null?void 0:i.user_errors)??[],...e??[]];return t.length>0?n(t):d(s.updateProductsInWishlist.wishlist)})};export{P as addProductsToWishlist,_ as config,I as fetchGraphQl,N as getConfig,w as getDefaultWishlist,S as getGuestWishlist,O as getPersistedWishlistData,D as getProductBySku,E as getStoreConfig,b as getWishlistById,F as getWishlists,G as initialize,H as initializeWishlist,$ as removeFetchGraphQlHeader,x as removeProductsFromWishlist,U as resetWishlist,C as setEndpoint,L as setFetchGraphQlHeader,M as setFetchGraphQlHeaders,Q as setPersistedWishlistData,g as updateProductsInWishlist};
47
+ ${u}
48
+ `,E=async r=>{const o=l.wishlistId;if(!o)throw Error("Wishlist ID is not set");return n(p,{variables:{wishlistId:o,wishlistItems:r.map(({wishlistItemId:e,quantity:s,description:t,selectedOptions:i,enteredOptions:a})=>({wishlistItemId:e,quantity:s,description:t,selected_options:i,entered_options:a}))}}).then(({errors:e,data:s})=>{var i;const t=[...((i=s==null?void 0:s.updateProductsInWishlist)==null?void 0:i.user_errors)??[],...e??[]];return t.length>0?I(t):h(s.updateProductsInWishlist.wishlist)})};export{G as addProductsToWishlist,H as config,n as fetchGraphQl,y as getConfig,F as getDefaultWishlist,v as getGuestWishlist,c as getPersistedWishlistData,U as getProductBySku,A as getStoreConfig,w as getWishlistById,O as getWishlistItemFromStorage,L as getWishlists,M as initialize,N as initializeWishlist,Q as removeFetchGraphQlHeader,b as removeProductsFromWishlist,R as resetWishlist,B as setEndpoint,C as setFetchGraphQlHeader,Y as setFetchGraphQlHeaders,x as setPersistedWishlistData,E as updateProductsInWishlist};
@@ -0,0 +1,3 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import*as e from"@dropins/tools/preact-compat.js";const o=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.734 5.4175C17.8557 3.5275 14.7987 3.5275 12.9105 5.4175L11.9814 6.3475L11.0523 5.4175C9.15407 3.5475 6.09699 3.5775 4.22878 5.4875C2.39054 7.3675 2.39054 10.3675 4.22878 12.2475L5.15789 13.1775L11.9814 20.0075L18.8048 13.1775L19.734 12.2475C21.6221 10.3675 21.6221 7.3075 19.734 5.4175Z",stroke:"currentColor"}));export{o as S};
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import*as e from"@dropins/tools/preact-compat.js";const o=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.734 5.4175C17.8557 3.5275 14.7987 3.5275 12.9105 5.4175L11.9814 6.3475L11.0523 5.4175C9.15407 3.5475 6.09699 3.5775 4.22878 5.4875C2.39054 7.3675 2.39054 10.3675 4.22878 12.2475L5.15789 13.1775L11.9814 20.0075L18.8048 13.1775L19.734 12.2475C21.6221 10.3675 21.6221 7.3075 19.734 5.4175Z",stroke:"currentColor"})),l=Object.freeze(Object.defineProperty({__proto__:null,default:o},Symbol.toStringTag,{value:"Module"})),r=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12,20.75h0c-.2,0-.39-.08-.53-.22L3.71,12.77c-2.12-2.16-2.12-5.66,0-7.82,1.04-1.06,2.44-1.66,3.93-1.67h.06c1.47,0,2.85,.57,3.9,1.6l.4,.4,.4-.4c1.05-1.05,2.45-1.63,3.94-1.63h0c1.49,0,2.89,.58,3.94,1.63,.02,.02,.03,.03,.05,.05,1.02,1.05,1.59,2.43,1.59,3.9s-.58,2.89-1.63,3.94l-7.76,7.76c-.14,.14-.33,.22-.53,.22Z",stroke:"currentColor"})),c=Object.freeze(Object.defineProperty({__proto__:null,default:r},Symbol.toStringTag,{value:"Module"}));export{l as H,r as S,o as a,c as b};
3
+ import*as e from"@dropins/tools/preact-compat.js";const r=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12,20.75h0c-.2,0-.39-.08-.53-.22L3.71,12.77c-2.12-2.16-2.12-5.66,0-7.82,1.04-1.06,2.44-1.66,3.93-1.67h.06c1.47,0,2.85,.57,3.9,1.6l.4,.4,.4-.4c1.05-1.05,2.45-1.63,3.94-1.63h0c1.49,0,2.89,.58,3.94,1.63,.02,.02,.03,.03,.05,.05,1.02,1.05,1.59,2.43,1.59,3.9s-.58,2.89-1.63,3.94l-7.76,7.76c-.14,.14-.33,.22-.53,.22Z",stroke:"currentColor"}));export{r as S};
@@ -0,0 +1,3 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import*as e from"@dropins/tools/preact-compat.js";const r=t=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("g",{clipPath:"url(#clip0_102_196)"},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3601 18.16H6.5601L4.8801 3H2.3501M19.6701 19.59C19.6701 20.3687 19.0388 21 18.2601 21C17.4814 21 16.8501 20.3687 16.8501 19.59C16.8501 18.8113 17.4814 18.18 18.2601 18.18C19.0388 18.18 19.6701 18.8113 19.6701 19.59ZM7.42986 19.59C7.42986 20.3687 6.79858 21 6.01986 21C5.24114 21 4.60986 20.3687 4.60986 19.59C4.60986 18.8113 5.24114 18.18 6.01986 18.18C6.79858 18.18 7.42986 18.8113 7.42986 19.59Z",stroke:"currentColor",strokeLinejoin:"round"}),e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),e.createElement("defs",null,e.createElement("clipPath",{id:"clip0_102_196"},e.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),o=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",...t},e.createElement("path",{d:"M1 5H23",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}),e.createElement("path",{d:"M17.3674 22H6.63446C5.67952 22 4.88992 21.2688 4.8379 20.3338L4 5H20L19.1621 20.3338C19.1119 21.2688 18.3223 22 17.3655 22H17.3674Z",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}),e.createElement("path",{d:"M9.87189 2H14.1281C14.6085 2 15 2.39766 15 2.88889V5H9V2.88889C9 2.39912 9.39006 2 9.87189 2Z",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}),e.createElement("path",{d:"M8.87402 8.58057L9.39348 17.682",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}),e.createElement("path",{d:"M14.6673 8.58057L14.146 17.682",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}));export{r as S,o as a};
@@ -0,0 +1,3 @@
1
+ /*! Copyright 2025 Adobe
2
+ All Rights Reserved. */
3
+ import{jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{InLineAlert as n,Icon as c}from"@dropins/tools/components.js";import{S as m,a as g}from"./Trash.js";import{S as h}from"./HeartFilled.js";import{useText as v}from"@dropins/tools/i18n.js";const P=({action:e,item:t,routeToWishlist:s})=>{const i=v({addHeading:"Wishlist.Alert.addProduct.heading",addMessage:"Wishlist.Alert.addProduct.message",removeHeading:"Wishlist.Alert.removeProduct.heading",removeMessage:"Wishlist.Alert.removeProduct.message",moveHeading:"Wishlist.Alert.moveToCart.heading",moveMessage:"Wishlist.Alert.moveToCart.message",viewWishlist:"Wishlist.Alert.viewWishlist"});if(!e||!t)return null;const r=i[`${e}Heading`],a=i[`${e}Message`],d={add:h,remove:g,move:m},l=s?location.href.includes(s):!1;return o(n,{"data-testid":"wishlist-alert",heading:r,description:a.replace("{product}",t.product.name),type:"success",icon:o(c,{source:d[e],size:"16"}),actionButtonPosition:"top",additionalActions:!l&&s?[{label:i.viewWishlist,onClick:()=>{location.href=s}}]:void 0})};export{P as W};
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as t,jsxs as m,Fragment as A}from"@dropins/tools/preact-jsx-runtime.js";import{classes as c}from"@dropins/tools/lib.js";import{Button as T,Icon as M,Price as P,Image as H}from"@dropins/tools/components.js";import*as o from"@dropins/tools/preact-compat.js";import{useState as W}from"@dropins/tools/preact-compat.js";import{s as u,r as j}from"./removeProductsFromWishlist.js";import{events as S}from"@dropins/tools/event-bus.js";import{useText as F}from"@dropins/tools/i18n.js";const L=r=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},o.createElement("g",{clipPath:"url(#clip0_102_196)"},o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3601 18.16H6.5601L4.8801 3H2.3501M19.6701 19.59C19.6701 20.3687 19.0388 21 18.2601 21C17.4814 21 16.8501 20.3687 16.8501 19.59C16.8501 18.8113 17.4814 18.18 18.2601 18.18C19.0388 18.18 19.6701 18.8113 19.6701 19.59ZM7.42986 19.59C7.42986 20.3687 6.79858 21 6.01986 21C5.24114 21 4.60986 20.3687 4.60986 19.59C4.60986 18.8113 5.24114 18.18 6.01986 18.18C6.79858 18.18 7.42986 18.8113 7.42986 19.59Z",stroke:"currentColor",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),o.createElement("defs",null,o.createElement("clipPath",{id:"clip0_102_196"},o.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),q=Object.freeze(Object.defineProperty({__proto__:null,default:L},Symbol.toStringTag,{value:"Module"})),O=r=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",...r},o.createElement("path",{d:"M1 5H23",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}),o.createElement("path",{d:"M17.3674 22H6.63446C5.67952 22 4.88992 21.2688 4.8379 20.3338L4 5H20L19.1621 20.3338C19.1119 21.2688 18.3223 22 17.3655 22H17.3674Z",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}),o.createElement("path",{d:"M9.87189 2H14.1281C14.6085 2 15 2.39766 15 2.88889V5H9V2.88889C9 2.39912 9.39006 2 9.87189 2Z",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}),o.createElement("path",{d:"M8.87402 8.58057L9.39348 17.682",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10}),o.createElement("path",{d:"M14.6673 8.58057L14.146 17.682",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:10})),K=Object.freeze(Object.defineProperty({__proto__:null,default:O},Symbol.toStringTag,{value:"Module"})),R=({className:r,children:f,item:e,onCartActionButtonClick:a,onTrashButtonClick:l,fixedProductTaxesEnabled:n,fixedProductTaxesApply:d,fixedProductTaxesEnabledDisplayInProductLists:s,fixedProductTaxesEnabledDisplayInSalesModules:i,fixedProductTaxesEnabledDisplayInProductView:p,...h})=>{var g,C,I,_,y,E,k,b,N;const w=F({cartActionBtn:"ProductItem.CartActionButton",trashActionBtn:"ProductItem.TrashActionButton"}),x=((C=(g=e==null?void 0:e.prices)==null?void 0:g.discount)==null?void 0:C.amountOff)!=0||((_=(I=e==null?void 0:e.prices)==null?void 0:I.discount)==null?void 0:_.percentOff)!=0;return t("div",{...h,className:c(["wishlist-product-item",r]),children:m("div",{...h,className:c(["wishlist-product-item__content",r]),children:[t("div",{className:c(["wishlist-product-item-image"]),style:{backgroundColor:"var(--color-neutral-200)"},"data-testid":"wishlist-product-item-image",children:t(V,{images:e!=null&&e.image?[e.image]:[]})}),m("div",{className:c(["wishlist-product-item__title"]),"data-testid":"wishlist-product-item-header",children:[t("span",{className:"wishlist-product-item-name","data-testid":"wishlist-product-item-name",children:e==null?void 0:e.name}),t(T,{"data-testid":"wishlist-product-item-remove-button",className:c(["wishlist-product-item-button__remove"]),variant:"tertiary",onClick:()=>l==null?void 0:l(),icon:t(M,{source:O,size:"24",stroke:"2",viewBox:"0 0 24 24","aria-label":w.trashActionBtn})}),t(P,{className:c(["wishlist-product-item-price",x?"strikeout":""]),"data-testid":"wishlist-product-item-price",amount:(y=e==null?void 0:e.prices)==null?void 0:y.regularPrice.value,currency:(E=e==null?void 0:e.prices)==null?void 0:E.regularPrice.currency}),x&&t(P,{className:c(["wishlist-product-item-discounted-price"]),"data-testid":"wishlist-product-item-discounted-price",amount:(k=e==null?void 0:e.prices)==null?void 0:k.finalPrice.value,currency:(b=e==null?void 0:e.prices)==null?void 0:b.finalPrice.currency}),n&&(s==="INCLUDING_FPT_AND_DESCRIPTION"||s==="EXCLUDING_FPT_INCLUDING_DESCRIPTION_FINAL_PRICE")&&((N=e==null?void 0:e.prices)==null?void 0:N.fixedProductTaxes.map(v=>m("div",{"data-testid":"wishlist-product-item-tax",className:c(["wishlist-product-item-tax"]),children:[t("span",{children:v.label}),t(P,{amount:v.money.value,currency:v.money.currency}),s==="INCLUDING_FPT_AND_DESCRIPTION"?"incl.":"excl."]})))]}),t(T,{"data-testid":"wishlist-product-item-move-to-cart-button",size:"medium",type:"submit",icon:t(M,{source:L}),disabled:(e==null?void 0:e.stockStatus)!=="IN_STOCK","aria-label":w.moveItemToCart,onClick:()=>a==null?void 0:a(),children:w.cartActionBtn})]})})},V=({className:r,children:f,images:e,...a})=>{const[l,n]=W(0);return m(A,{children:[t("div",{...a,className:c(["image-carousel",r]),children:t("div",{className:c(["overflow-hidden relative max-w-[200px]",r]),children:e==null?void 0:e.map((d,s)=>s===l&&t(H,{className:"image-carousel-image",alt:d.alt,src:d.src}))})}),(e==null?void 0:e.length)>1&&t("div",{className:c(["absolute","image-switcher-area"]),children:e==null?void 0:e.map((d,s)=>t("span",{className:c(["image-switcher",l===s?"image-switcher-active":"image-switcher-inactive"]),onClick:i=>{n(s),i.stopPropagation()}},s))})]})},X=({initialData:r=null,moveProdToCart:f})=>{var l,n,d,s,i;if(!(r!=null&&r.product))return null;const e=async(p=!0)=>{try{return await j([r]),console.log(`Product ${r.product.sku} removed from wishlist!`),p&&S.emit("wishlist/update",{action:"remove",item:r}),!0}catch(h){return console.error(`Product ${r.product.sku} could not be removed from wishlist`,h),!1}},a=async()=>{try{return await f([{sku:r.product.sku,quantity:1}]),console.log(`Product ${r.product.sku} successfully moved to cart 🛒!`),S.emit("wishlist/update",{action:"move",item:r}),await e(!1)}catch(p){return console.error("Cart creation/update failed: ",p),!1}};return t(R,{item:r.product,onCartActionButtonClick:a,onTrashButtonClick:e,fixedProductTaxesEnabled:((l=u.config)==null?void 0:l.fixedProductTaxesEnabled)??!1,fixedProductTaxesApply:((n=u.config)==null?void 0:n.fixedProductTaxesApply)??!1,fixedProductTaxesEnabledDisplayInProductLists:(d=u.config)==null?void 0:d.fixedProductTaxesEnabledDisplayInProductLists,fixedProductTaxesEnabledDisplayInProductView:(s=u.config)==null?void 0:s.fixedProductTaxesEnabledDisplayInProductView,fixedProductTaxesEnabledDisplayInSalesModules:(i=u.config)==null?void 0:i.fixedProductTaxesEnabledDisplayInSalesModules})};export{q as C,L as S,K as T,X as W,O as a};
3
+ import{jsx as s,Fragment as g,jsxs as f}from"@dropins/tools/preact-jsx-runtime.js";import{classes as n}from"@dropins/tools/lib.js";import{Price as w,Button as T,Icon as _,Image as E}from"@dropins/tools/components.js";import{useState as S}from"@dropins/tools/preact-compat.js";import{s as p,r as A}from"./removeProductsFromWishlist.js";import{events as b}from"@dropins/tools/event-bus.js";import{a as C,S as F}from"./Trash.js";import{useText as O}from"@dropins/tools/i18n.js";const k=({taxes:c,displayMode:r})=>s(g,{children:c.map((e,o)=>f("div",{"data-testid":`wishlist-product-item-tax-${o}`,className:"wishlist-product-item-tax",children:[s("span",{className:"wishlist-product-item-tax-label",children:e.label}),s(w,{className:"wishlist-product-item-tax-price",amount:e.money.value,currency:e.money.currency}),s("span",{className:"wishlist-product-item-tax-display-mode",children:r==="INCLUDING_FPT_AND_DESCRIPTION"?"incl.":"excl."})]},o))}),L=({className:c,item:r,onCartActionButtonClick:e,onTrashButtonClick:o,fixedProductTaxesEnabled:l,fixedProductTaxesEnabledDisplayInProductLists:a,...d})=>{var i,h,P,m,x,v,N,I,y;const t=O({cartActionBtn:"ProductItem.CartActionButton",trashActionBtn:"ProductItem.TrashActionButton"}),u=((h=(i=r==null?void 0:r.prices)==null?void 0:i.discount)==null?void 0:h.amountOff)!==0||((m=(P=r==null?void 0:r.prices)==null?void 0:P.discount)==null?void 0:m.percentOff)!==0;return s("div",{...d,className:n(["wishlist-product-item",c]),children:f("div",{className:"wishlist-product-item__content",children:[s("a",{className:"wishlist-product-item-image","data-testid":"wishlist-product-item-image",href:r==null?void 0:r.urlKey,children:s(G,{images:r!=null&&r.image?[r.image]:[]})}),f("div",{className:"wishlist-product-item__title","data-testid":"wishlist-product-item-header",children:[s("a",{className:"wishlist-product-item-name","data-testid":"wishlist-product-item-name",href:r==null?void 0:r.urlKey,children:r==null?void 0:r.name}),s(T,{"data-testid":"wishlist-product-item-remove-button",className:"wishlist-product-item-button__remove",variant:"tertiary",onClick:()=>o==null?void 0:o(),icon:s(_,{source:C,size:"24",stroke:"2",viewBox:"0 0 24 24","aria-label":t.trashActionBtn})}),s(w,{className:n(["wishlist-product-item-price",u?"strikeout":""]),"data-testid":"wishlist-product-item-price",amount:(x=r==null?void 0:r.prices)==null?void 0:x.regularPrice.value,currency:(v=r==null?void 0:r.prices)==null?void 0:v.regularPrice.currency}),u&&s(w,{className:"wishlist-product-item-discounted-price","data-testid":"wishlist-product-item-discounted-price",amount:(N=r==null?void 0:r.prices)==null?void 0:N.finalPrice.value,currency:(I=r==null?void 0:r.prices)==null?void 0:I.finalPrice.currency}),l&&(a==="INCLUDING_FPT_AND_DESCRIPTION"||a==="EXCLUDING_FPT_INCLUDING_DESCRIPTION_FINAL_PRICE")&&((y=r==null?void 0:r.prices)==null?void 0:y.fixedProductTaxes)&&s(k,{taxes:r.prices.fixedProductTaxes,displayMode:a})]}),s(T,{"data-testid":"wishlist-product-item-move-to-cart-button",size:"medium",type:"submit",icon:s(_,{source:F}),disabled:(r==null?void 0:r.stockStatus)!=="IN_STOCK","aria-label":t.cartActionBtn,onClick:()=>e==null?void 0:e(),children:t.cartActionBtn})]})})},G=({className:c,children:r,images:e,...o})=>{const[l,a]=S(0);return f(g,{children:[s("div",{...o,className:n(["image-carousel",c]),children:s("div",{className:n(["overflow-hidden relative max-w-[200px]",c]),children:e==null?void 0:e.map((d,t)=>t===l&&s(E,{className:"image-carousel-image",alt:d.alt,src:d.src}))})}),(e==null?void 0:e.length)>1&&s("div",{className:n(["absolute","image-switcher-area"]),children:e==null?void 0:e.map((d,t)=>s("span",{className:n(["image-switcher",l===t?"image-switcher-active":"image-switcher-inactive"]),onClick:u=>{a(t),u.stopPropagation()}},t))})]})},z=({initialData:c=null,moveProdToCart:r})=>{var l,a,d,t,u;if(!(c!=null&&c.product))return null;const e=async(i=!0)=>{try{return await A([c]),console.log(`Product ${c.product.sku} removed from wishlist!`),i&&b.emit("wishlist/alert",{action:"remove",item:c}),!0}catch(h){return console.error(`Product ${c.product.sku} could not be removed from wishlist`,h),!1}},o=async()=>{try{return await r([{sku:c.product.sku,quantity:1}]),console.log(`Product ${c.product.sku} successfully moved to cart 🛒!`),b.emit("wishlist/alert",{action:"move",item:c}),await e(!1)}catch(i){return console.error("Cart creation/update failed: ",i),!1}};return s(L,{item:c.product,onCartActionButtonClick:o,onTrashButtonClick:e,fixedProductTaxesEnabled:((l=p.config)==null?void 0:l.fixedProductTaxesEnabled)??!1,fixedProductTaxesApply:((a=p.config)==null?void 0:a.fixedProductTaxesApply)??!1,fixedProductTaxesEnabledDisplayInProductLists:(d=p.config)==null?void 0:d.fixedProductTaxesEnabledDisplayInProductLists,fixedProductTaxesEnabledDisplayInProductView:(t=p.config)==null?void 0:t.fixedProductTaxesEnabledDisplayInProductView,fixedProductTaxesEnabledDisplayInSalesModules:(u=p.config)==null?void 0:u.fixedProductTaxesEnabledDisplayInSalesModules})};export{z as W};
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{Initializer as E}from"@dropins/tools/lib.js";import{events as r}from"@dropins/tools/event-bus.js";import{s as i,i as g,f as c,h as _,m as y,j as T,W as x,g as h,t as S}from"./removeProductsFromWishlist.js";const P=new E({init:async t=>{const s={isGuestWishlistEnabled:!1,...t};P.config.setConfig(s),w().catch(console.error)},listeners:()=>[r.on("authenticated",t=>{i.authenticated&&!t&&r.emit("wishlist/reset",void 0),t&&!i.authenticated&&(i.authenticated=t,w().catch(console.error))},{eager:!0}),r.on("wishlist/data",t=>{g(t)}),r.on("wishlist/reset",()=>{R().catch(console.error),r.emit("wishlist/data",null)})]}),$=P.config;function C(t){if(!t)return null;const s=e=>{switch(e){case 1:return"INCLUDING_FPT_AND_DESCRIPTION";case 2:return"EXCLUDING_FPT_INCLUDING_DESCRIPTION_FINAL_PRICE";case 3:return"EXCLUDING_FPT";default:return"INCLUDING_FPT_ONLY"}};return{wishlistIsEnabled:t.storeConfig.magento_wishlist_general_is_enabled,wishlistMultipleListIsEnabled:t.storeConfig.enable_multiple_wishlists,wishlistMaxNumber:t.storeConfig.maximum_number_of_wishlists,fixedProductTaxesEnabled:t.storeConfig.fixed_product_taxes_enable,fixedProductTaxesApply:t.storeConfig.fixed_product_taxes_apply_tax_to_fpt,fixedProductTaxesEnabledDisplayInProductLists:s(t.storeConfig.fixed_product_taxes_display_prices_in_product_lists),fixedProductTaxesEnabledDisplayInSalesModules:s(t.storeConfig.fixed_product_taxes_display_prices_in_sales_modules),fixedProductTaxesEnabledDisplayInProductView:s(t.storeConfig.fixed_product_taxes_display_prices_on_product_view_page)}}const b=`
3
+ import{Initializer as R}from"@dropins/tools/lib.js";import{events as u}from"@dropins/tools/event-bus.js";import{s as r,i as A,f as g,h as T,g as E}from"./removeProductsFromWishlist.js";const S=new R({init:async e=>{const t={isGuestWishlistEnabled:!1,...e};S.config.setConfig(t),P().catch(console.error)},listeners:()=>[u.on("authenticated",e=>{r.authenticated&&!e&&u.emit("wishlist/reset",void 0),e&&!r.authenticated&&(r.authenticated=e,P().catch(console.error))},{eager:!0}),u.on("wishlist/data",e=>{A(e)}),u.on("wishlist/reset",()=>{K().catch(console.error),u.emit("wishlist/data",null)})]}),ee=S.config;function G(e){if(!e)return null;const t=i=>{switch(i){case 1:return"INCLUDING_FPT_AND_DESCRIPTION";case 2:return"EXCLUDING_FPT_INCLUDING_DESCRIPTION_FINAL_PRICE";case 3:return"EXCLUDING_FPT";default:return"INCLUDING_FPT_ONLY"}};return{wishlistIsEnabled:e.storeConfig.magento_wishlist_general_is_enabled,wishlistMultipleListIsEnabled:e.storeConfig.enable_multiple_wishlists,wishlistMaxNumber:e.storeConfig.maximum_number_of_wishlists,fixedProductTaxesEnabled:e.storeConfig.fixed_product_taxes_enable,fixedProductTaxesApply:e.storeConfig.fixed_product_taxes_apply_tax_to_fpt,fixedProductTaxesEnabledDisplayInProductLists:t(e.storeConfig.fixed_product_taxes_display_prices_in_product_lists),fixedProductTaxesEnabledDisplayInSalesModules:t(e.storeConfig.fixed_product_taxes_display_prices_in_sales_modules),fixedProductTaxesEnabledDisplayInProductView:t(e.storeConfig.fixed_product_taxes_display_prices_on_product_view_page)}}function b(e){var t;return e?{name:e.name,sku:e.sku,uid:e.uid,image:v(e),stockStatus:e.stock_status,canonicalUrl:e.canonical_url,urlKey:e.url_key,categories:(t=e.categories)==null?void 0:t.map(i=>i.name),prices:O(e),productAttributes:W(e)}:null}function v(e){var t,i;return{src:(t=e.thumbnail)==null?void 0:t.url,alt:(i=e.thumbnail)==null?void 0:i.label}}function O(e){var t,i,s,n,c,a,_,o,l,d,m,f,p,h,I,y,x,w;return{regularPrice:{currency:(s=(i=(t=e.price_range)==null?void 0:t.minimum_price)==null?void 0:i.regular_price)==null?void 0:s.currency,value:(a=(c=(n=e.price_range)==null?void 0:n.minimum_price)==null?void 0:c.regular_price)==null?void 0:a.value},finalPrice:{currency:(l=(o=(_=e.price_range)==null?void 0:_.minimum_price)==null?void 0:o.final_price)==null?void 0:l.currency,value:(f=(m=(d=e.price_range)==null?void 0:d.minimum_price)==null?void 0:m.final_price)==null?void 0:f.value},discount:{amountOff:(I=(h=(p=e.price_range)==null?void 0:p.minimum_price)==null?void 0:h.discount)==null?void 0:I.amount_off,percentOff:(w=(x=(y=e.price_range)==null?void 0:y.minimum_price)==null?void 0:x.discount)==null?void 0:w.percent_off},fixedProductTaxes:D(e)}}function W(e){var t,i;return(i=(t=e.custom_attributesV2)==null?void 0:t.items)==null?void 0:i.map(s=>{const n=s.code.split("_").map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join(" ");return{...s,code:n}})}function D(e){var t,i,s;return(s=(i=(t=e.price_range)==null?void 0:t.minimum_price)==null?void 0:i.fixed_product_taxes)==null?void 0:s.map(n=>({money:{value:n.amount.value,currency:n.amount.currency},label:n.label}))}function C(e){return e?{id:e.id,updated_at:e.updated_at,sharing_code:e.sharing_code,items_count:e.items_count,items:M(e)}:null}function M(e){var t,i;return(i=(t=e==null?void 0:e.items_v2)==null?void 0:t.items)!=null&&i.length?e.items_v2.items.map(s=>({id:s.id,quantity:s.quantity,description:s.description,added_at:s.added_at,product:b(s.product)})):[]}const F=`
4
4
  query STORE_CONFIG_QUERY {
5
5
  storeConfig {
6
6
  magento_wishlist_general_is_enabled
@@ -13,7 +13,7 @@ query STORE_CONFIG_QUERY {
13
13
  fixed_product_taxes_display_prices_on_product_view_page
14
14
  }
15
15
  }
16
- `,D=async()=>c(b,{method:"GET",cache:"force-cache"}).then(({errors:t,data:s})=>t?_(t):C(s)),W=`
16
+ `,U=async()=>g(F,{method:"GET",cache:"force-cache"}).then(({errors:e,data:t})=>e?T(e):G(t)),k=`
17
17
  query GET_PRODUCT_BY_SKU($sku: String!) {
18
18
  products(filter: { sku: { eq: $sku } }) {
19
19
  items {
@@ -76,8 +76,137 @@ query STORE_CONFIG_QUERY {
76
76
  }
77
77
  }
78
78
  }
79
- `,N=async t=>{if(!t)throw Error("Product SKU is not set");return c(W,{variables:{sku:t}}).then(({errors:s,data:e})=>{var o;return s?_(s):(o=e==null?void 0:e.products)!=null&&o.items?y(e.products.items[0]):null})},G=`
80
- query GET_WISHLISTS_QUERY(${T}) {
79
+ `,L=async e=>{if(!e)throw Error("Product SKU is not set");return g(k,{variables:{sku:e}}).then(({errors:t,data:i})=>{var s;return t?T(t):(s=i==null?void 0:i.products)!=null&&s.items?b(i.products.items[0]):null})},$=`
80
+ fragment PRICE_RANGE_FRAGMENT on PriceRange {
81
+ minimum_price {
82
+ regular_price {
83
+ value
84
+ currency
85
+ }
86
+ final_price {
87
+ value
88
+ currency
89
+ }
90
+ discount {
91
+ percent_off
92
+ amount_off
93
+ }
94
+ fixed_product_taxes {
95
+ amount {
96
+ currency
97
+ value
98
+ }
99
+ label
100
+ }
101
+ }
102
+ maximum_price {
103
+ regular_price {
104
+ value
105
+ currency
106
+ }
107
+ final_price {
108
+ value
109
+ currency
110
+ }
111
+ discount {
112
+ percent_off
113
+ amount_off
114
+ }
115
+ fixed_product_taxes {
116
+ amount {
117
+ currency
118
+ value
119
+ }
120
+ label
121
+ }
122
+ }
123
+ }
124
+ `,H=`
125
+ fragment PRODUCT_FRAGMENT on ProductInterface {
126
+ name
127
+ sku
128
+ uid
129
+ thumbnail {
130
+ url
131
+ label
132
+ }
133
+ url_key
134
+ categories {
135
+ url_path
136
+ url_key
137
+ name
138
+ }
139
+ stock_status
140
+ canonical_url
141
+ custom_attributesV2(filters: {is_visible_on_front: true}){
142
+ items {
143
+ code
144
+ ...on AttributeValue {
145
+ value
146
+ }
147
+ ...on AttributeSelectedOptions {
148
+ selected_options {
149
+ value
150
+ label
151
+ }
152
+ }
153
+ }
154
+ }
155
+ price_range {
156
+ ...PRICE_RANGE_FRAGMENT
157
+ }
158
+ }
159
+
160
+ ${$}
161
+ `,z=`
162
+ fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {
163
+ type
164
+ customizable_option_uid
165
+ label
166
+ is_required
167
+ values {
168
+ label
169
+ value
170
+ price{
171
+ type
172
+ units
173
+ value
174
+ }
175
+ }
176
+ }
177
+ `,q=`
178
+ fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
179
+ __typename
180
+ id
181
+ quantity
182
+ description
183
+ added_at
184
+ product {
185
+ ...PRODUCT_FRAGMENT
186
+ }
187
+ customizable_options {
188
+ ...CUSTOMIZABLE_OPTIONS_FRAGMENT
189
+ }
190
+ }
191
+
192
+ ${H}
193
+ ${z}
194
+ `,N=`
195
+ fragment WISHLIST_FRAGMENT on Wishlist {
196
+ id
197
+ updated_at
198
+ sharing_code
199
+ items_count
200
+ items_v2 {
201
+ items {
202
+ ...WISHLIST_ITEM_FRAGMENT
203
+ }
204
+ }
205
+ }
206
+
207
+ ${q}
208
+ `,B=`
209
+ query GET_WISHLISTS_QUERY {
81
210
  customer {
82
211
  wishlists {
83
212
  ...WISHLIST_FRAGMENT
@@ -85,12 +214,11 @@ query STORE_CONFIG_QUERY {
85
214
  }
86
215
  }
87
216
 
88
- ${x}
89
- `,U=async()=>i.authenticated?c(G).then(({errors:t,data:s})=>{var e;return t?_(t):(e=s==null?void 0:s.customer)!=null&&e.wishlists?s.customer.wishlists.map(o=>S(o)):null}):h(),L=`
217
+ ${N}
218
+ `,Y=async()=>r.authenticated?g(B).then(({errors:e,data:t})=>{var i;return e?T(e):(i=t==null?void 0:t.customer)!=null&&i.wishlists?t.customer.wishlists.map(s=>C(s)):null}):E(),Q=`
90
219
  mutation ADD_PRODUCTS_TO_WISHLIST_MUTATION(
91
220
  $wishlistId: ID!,
92
221
  $wishlistItems: [WishlistItemInput!]!,
93
- ${T}
94
222
  ) {
95
223
  addProductsToWishlist(
96
224
  wishlistId: $wishlistId
@@ -105,6 +233,5 @@ query STORE_CONFIG_QUERY {
105
233
  }
106
234
  }
107
235
  }
108
-
109
- ${x}
110
- `,M=async t=>{var p,m;if(!i.authenticated){const l=h();for(const u of t){const d=await N(u.sku);if(!((p=l.items)==null?void 0:p.some(n=>n.product.sku===u.sku))){let n={id:l.id,items:l.items};n.items=[...n.items,{product:d}],g(n),r.emit("wishlist/data",n),r.emit("wishlist/update",{action:"add",item:n.items[n.items.length-1]})}}return null}if(!i.wishlistId)throw Error("Wishlist ID is not set");const s={wishlistId:i.wishlistId,wishlistItems:t.map(({sku:l,parentSku:u,quantity:d,optionsUIDs:I,enteredOptions:n})=>({sku:l,parent_sku:u,quantity:d,selected_options:I,entered_options:n}))},{errors:e,data:o}=await c(L,{variables:s}),f=[...((m=o==null?void 0:o.addProductsToWishlist)==null?void 0:m.user_errors)??[],...e??[]];if(f.length>0)return _(f);const a=S(o.addProductsToWishlist.wishlist);return i.currentPage=1,r.emit("wishlist/data",a),r.emit("wishlist/update",{action:"add",item:a.items[a.items.length-1]}),a},R=()=>(i.wishlistId=null,i.authenticated=!1,Promise.resolve(null)),w=async()=>{if(i.initializing)return null;i.initializing=!0,i.config||(i.config=await D());const t=i.authenticated?await O():await k();return r.emit("wishlist/initialized",t),r.emit("wishlist/data",t),i.initializing=!1,t};async function O(){const t=await U(),s=t?t[0]:null;return s?(i.wishlistId=s.id,s):null}async function k(){try{return await h()}catch(t){throw console.error(t),t}}export{M as a,N as b,$ as c,U as d,w as e,O as f,D as g,k as h,P as i,R as r};
236
+ ${N}
237
+ `,te=async e=>{var s,n,c;const t=E();let i={id:(t==null?void 0:t.id)??"",items:(t==null?void 0:t.items)??[],updated_at:"",sharing_code:"",items_count:0};if(!e)return null;for(const a of e){if((s=t.items)==null?void 0:s.some(l=>l.product.sku===a.sku))continue;const o=await L(a.sku);o&&(i.items=[...i.items,{product:o}])}if(i.items_count=(n=i.items)==null?void 0:n.length,u.emit("wishlist/data",i),r.authenticated){if(!r.wishlistId)throw u.emit("wishlist/data",t),Error("Wishlist ID is not set");const a={wishlistId:r.wishlistId,wishlistItems:e.map(({sku:m,parentSku:f,quantity:p,optionsUIDs:h,enteredOptions:I})=>({sku:m,parent_sku:f,quantity:p,selected_options:h,entered_options:I}))},{errors:_,data:o}=await g(Q,{variables:a}),l=[...((c=o==null?void 0:o.addProductsToWishlist)==null?void 0:c.user_errors)??[],..._??[]];if(l.length>0)return u.emit("wishlist/data",t),T(l);const d=C(o.addProductsToWishlist.wishlist);u.emit("wishlist/data",d)}return null},K=()=>(r.wishlistId=null,r.authenticated=!1,Promise.resolve(null)),P=async()=>{if(r.initializing)return null;r.initializing=!0,r.config||(r.config=await U());const e=r.authenticated?await V():await Z();return u.emit("wishlist/initialized",e),u.emit("wishlist/data",e),r.initializing=!1,e};async function V(){const e=await Y(),t=e?e[0]:null;return t?(r.wishlistId=t.id,t):null}async function Z(){try{return await E()}catch(e){throw console.error(e),e}}export{q as W,te as a,N as b,ee as c,L as d,Y as e,P as f,U as g,V as h,S as i,Z as j,K as r,C as t};
@@ -1,166 +1,18 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{events as E}from"@dropins/tools/event-bus.js";import{FetchGraphQL as P}from"@dropins/tools/fetch-graphql.js";function R(e){const t=document.cookie.split(";");for(const r of t)if(r.trim().startsWith(`${e}=`))return r.trim().substring(e.length+1);return null}const A={wishlistId:null,authenticated:!1,currentPage:1,pageSize:4},c=new Proxy(A,{set(e,t,r){if(e[t]=r,t==="wishlistId"){if(r===c.wishlistId)return!0;if(r===null)return document.cookie="DROPIN__WISHLIST__WISHLIST-ID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/",!0;const i=new Date;i.setDate(i.getDate()+30),document.cookie=`DROPIN__WISHLIST__WISHLIST-ID=${r}; expires=${i.toUTCString()}; path=/`}return Reflect.set(e,t,r)},get(e,t){return t==="wishlistId"?R("DROPIN__WISHLIST__WISHLIST-ID"):e[t]}}),I="DROPIN__WISHLIST__WISHLIST__DATA";function N(e){if(e)try{localStorage.setItem(I,JSON.stringify(e))}catch(t){O(t)?console.error("LocalStorage quota exceeded:",t):console.error("Error saving wishlist:",t)}else localStorage.removeItem(I)}const O=e=>e instanceof DOMException&&e.name==="QuotaExceededError";function W(){try{const e=localStorage.getItem(I);return e?JSON.parse(e):{id:"",items:[]}}catch(e){return console.error("Error retrieving wishlist:",e),{id:"",items:[]}}}const{setEndpoint:J,setFetchGraphQlHeader:Z,removeFetchGraphQlHeader:K,setFetchGraphQlHeaders:Y,fetchGraphQl:M,getConfig:X}=new P().getMethods();function v(e){var t;return e?{name:e.name,sku:e.sku,uid:e.uid,image:w(e),stockStatus:e.stock_status,canonicalUrl:e.canonical_url,urlKey:e.url_key,categories:(t=e.categories)==null?void 0:t.map(r=>r.name),prices:F(e),productAttributes:y(e)}:null}function w(e){var t,r;return{src:(t=e.thumbnail)==null?void 0:t.url,alt:(r=e.thumbnail)==null?void 0:r.label}}function F(e){var t,r,i,s,n,a,u,o,l,_,m,p,d,f,g,h,S,T;return{regularPrice:{currency:(i=(r=(t=e.price_range)==null?void 0:t.minimum_price)==null?void 0:r.regular_price)==null?void 0:i.currency,value:(a=(n=(s=e.price_range)==null?void 0:s.minimum_price)==null?void 0:n.regular_price)==null?void 0:a.value},finalPrice:{currency:(l=(o=(u=e.price_range)==null?void 0:u.minimum_price)==null?void 0:o.final_price)==null?void 0:l.currency,value:(p=(m=(_=e.price_range)==null?void 0:_.minimum_price)==null?void 0:m.final_price)==null?void 0:p.value},discount:{amountOff:(g=(f=(d=e.price_range)==null?void 0:d.minimum_price)==null?void 0:f.discount)==null?void 0:g.amount_off,percentOff:(T=(S=(h=e.price_range)==null?void 0:h.minimum_price)==null?void 0:S.discount)==null?void 0:T.percent_off},fixedProductTaxes:G(e)}}function y(e){var t,r;return(r=(t=e.custom_attributesV2)==null?void 0:t.items)==null?void 0:r.map(i=>{const s=i.code.split("_").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");return{...i,code:s}})}function G(e){var t,r,i;return(i=(r=(t=e.price_range)==null?void 0:t.minimum_price)==null?void 0:r.fixed_product_taxes)==null?void 0:i.map(s=>({money:{value:s.amount.value,currency:s.amount.currency},label:s.label}))}function L(e){return e?{id:e.id,updated_at:e.updated_at,sharing_code:e.sharing_code,items_count:e.items_count,total_pages:e.items_v2.page_info.total_pages,items:b(e)}:null}function b(e){var t,r;return(r=(t=e==null?void 0:e.items_v2)==null?void 0:t.items)!=null&&r.length?e.items_v2.items.map(i=>({id:i.id,quantity:i.quantity,description:i.description,added_at:i.added_at,product:v(i.product)})):[]}const D=e=>{const t=e.map(r=>r.message).join(" ");throw Error(t)},H=`
4
- fragment PRICE_RANGE_FRAGMENT on PriceRange {
5
- minimum_price {
6
- regular_price {
7
- value
8
- currency
9
- }
10
- final_price {
11
- value
12
- currency
13
- }
14
- discount {
15
- percent_off
16
- amount_off
17
- }
18
- fixed_product_taxes {
19
- amount {
20
- currency
21
- value
22
- }
23
- label
24
- }
25
- }
26
- maximum_price {
27
- regular_price {
28
- value
29
- currency
30
- }
31
- final_price {
32
- value
33
- currency
34
- }
35
- discount {
36
- percent_off
37
- amount_off
38
- }
39
- fixed_product_taxes {
40
- amount {
41
- currency
42
- value
43
- }
44
- label
45
- }
46
- }
47
- }
48
- `,x=`
49
- fragment PRODUCT_FRAGMENT on ProductInterface {
50
- name
51
- sku
52
- uid
53
- thumbnail {
54
- url
55
- label
56
- }
57
- url_key
58
- categories {
59
- url_path
60
- url_key
61
- name
62
- }
63
- stock_status
64
- canonical_url
65
- custom_attributesV2(filters: {is_visible_on_front: true}){
66
- items {
67
- code
68
- ...on AttributeValue {
69
- value
70
- }
71
- ...on AttributeSelectedOptions {
72
- selected_options {
73
- value
74
- label
75
- }
76
- }
77
- }
78
- }
79
- price_range {
80
- ...PRICE_RANGE_FRAGMENT
81
- }
82
- }
83
-
84
- ${H}
85
- `,$=`
86
- fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {
87
- type
88
- customizable_option_uid
89
- label
90
- is_required
91
- values {
92
- label
93
- value
94
- price{
95
- type
96
- units
97
- value
98
- }
99
- }
100
- }
101
- `,C=`
102
- fragment WISHLIST_ITEM_FRAGMENT on WishlistItemInterface {
103
- __typename
104
- id
105
- quantity
106
- description
107
- added_at
108
- product {
109
- ...PRODUCT_FRAGMENT
110
- }
111
- customizable_options {
112
- ...CUSTOMIZABLE_OPTIONS_FRAGMENT
113
- }
114
- }
115
-
116
- ${x}
117
- ${$}
118
- `,{pageSize:U,currentPage:k}=c,z=`
119
- $pageSize: Int! = ${U},
120
- $currentPage: Int! = ${k},
121
- `,Q=`
122
- pageSize: $pageSize,
123
- currentPage: $currentPage,
124
- `,V=`
125
- fragment WISHLIST_FRAGMENT on Wishlist {
126
- id
127
- updated_at
128
- sharing_code
129
- items_count
130
- items_v2(
131
- ${Q}
132
- ) {
133
- items {
134
- ...WISHLIST_ITEM_FRAGMENT
135
- }
136
- page_info {
137
- page_size
138
- current_page
139
- total_pages
140
- }
141
- }
142
- }
143
-
144
- ${C}
145
- `,q=`
3
+ import{events as d}from"@dropins/tools/event-bus.js";import{FetchGraphQL as m}from"@dropins/tools/fetch-graphql.js";function S(s){const t=document.cookie.split(";");for(const e of t)if(e.trim().startsWith(`${s}=`))return e.trim().substring(s.length+1);return null}const g={wishlistId:null,authenticated:!1},i=new Proxy(g,{set(s,t,e){if(s[t]=e,t==="wishlistId"){if(e===i.wishlistId)return!0;if(e===null)return document.cookie="DROPIN__WISHLIST__WISHLIST-ID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/",!0;const r=new Date;r.setDate(r.getDate()+30),document.cookie=`DROPIN__WISHLIST__WISHLIST-ID=${e}; expires=${r.toUTCString()}; path=/`}return Reflect.set(s,t,e)},get(s,t){return t==="wishlistId"?S("DROPIN__WISHLIST__WISHLIST-ID"):s[t]}}),n="DROPIN__WISHLIST__WISHLIST__DATA";function E(s){const t=i.authenticated?sessionStorage:localStorage;if(s)try{t.setItem(n,JSON.stringify(s))}catch(e){_(e)?console.error("Storage quota exceeded:",e):console.error("Error saving wishlist:",e)}else t.removeItem(n)}const _=s=>s instanceof DOMException&&s.name==="QuotaExceededError";function f(){const s=i.authenticated?sessionStorage:localStorage;try{const t=s.getItem(n);return t?JSON.parse(t):{id:"",items:[]}}catch(t){return console.error("Error retrieving wishlist:",t),{id:"",items:[]}}}function O(s){var r;const t=i.authenticated?sessionStorage:localStorage,e=t.getItem(n)?JSON.parse(t.getItem(n)):{items:[]};return(r=e==null?void 0:e.items)==null?void 0:r.find(a=>{var o;return((o=a.product)==null?void 0:o.sku)===s})}const{setEndpoint:H,setFetchGraphQlHeader:L,removeFetchGraphQlHeader:P,setFetchGraphQlHeaders:F,fetchGraphQl:p,getConfig:R}=new m().getMethods(),w=s=>{const t=s.map(e=>e.message).join(" ");throw Error(t)},T=`
146
4
  mutation REMOVE_PRODUCTS_FROM_WISHLIST_MUTATION(
147
5
  $wishlistId: ID!,
148
6
  $wishlistItemsIds: [ID!]!,
149
- ${z}
150
7
  ) {
151
8
  removeProductsFromWishlist(
152
9
  wishlistId: $wishlistId
153
10
  wishlistItemsIds: $wishlistItemsIds
154
11
  ) {
155
- wishlist {
156
- ...WISHLIST_FRAGMENT
157
- }
158
12
  user_errors {
159
13
  code
160
14
  message
161
15
  }
162
16
  }
163
17
  }
164
-
165
- ${V}
166
- `,ee=async e=>{var a,u;if(!c.authenticated){const o=W(),l={...o,items:(a=o.items)==null?void 0:a.filter(_=>!e.map(m=>m.product.sku).includes(_.product.sku))};return N(l),E.emit("wishlist/data",l),null}if(!c.wishlistId)throw Error("Wishlist ID is not set");const t=e.map(o=>o.id),{errors:r,data:i}=await M(q,{variables:{wishlistId:c.wishlistId,wishlistItemsIds:t}}),s=[...((u=i==null?void 0:i.removeProductsFromWishlist)==null?void 0:u.user_errors)??[],...r??[]];if(s.length>0)return D(s);const n=L(i.removeProductsFromWishlist.wishlist);return c.currentPage=1,E.emit("wishlist/data",n),n};export{V as W,J as a,Z as b,K as c,Y as d,X as e,M as f,W as g,D as h,N as i,z as j,Q as k,C as l,v as m,ee as r,c as s,L as t};
18
+ `,$=async s=>{var r,a,o;const t=f(),e={...t,items:(r=t.items)==null?void 0:r.filter(c=>!s.map(I=>I.product.sku).includes(c.product.sku))};if(e.items_count=(a=e.items)==null?void 0:a.length,d.emit("wishlist/data",e),i.authenticated){if(!i.wishlistId)throw Error("Wishlist ID is not set");const c=s.map(u=>u.id),{errors:I,data:l}=await p(T,{variables:{wishlistId:i.wishlistId,wishlistItemsIds:c}}),h=[...((o=l==null?void 0:l.removeProductsFromWishlist)==null?void 0:o.user_errors)??[],...I??[]];return h.length>0?(d.emit("wishlist/data",t),w(h)):null}return null};export{H as a,L as b,P as c,F as d,R as e,p as f,f as g,w as h,E as i,O as j,$ as r,i as s};
@@ -1,4 +1,7 @@
1
1
  import { FunctionComponent } from 'preact';
2
2
 
3
- export declare const Login: FunctionComponent;
3
+ export interface LoginProps {
4
+ onLoginClick?: () => void;
5
+ }
6
+ export declare const Login: FunctionComponent<LoginProps>;
4
7
  //# sourceMappingURL=Login.d.ts.map
@@ -3,6 +3,7 @@ import { HTMLAttributes } from 'preact/compat';
3
3
  import { Product } from '../../data/models';
4
4
 
5
5
  export interface ProductItemProps extends HTMLAttributes<HTMLDivElement> {
6
+ className?: string;
6
7
  item?: Product;
7
8
  onCartActionButtonClick?: () => boolean;
8
9
  onTrashButtonClick?: () => boolean;
@@ -0,0 +1,9 @@
1
+ import { FunctionComponent } from 'preact';
2
+ import { PriceDetails } from '../../data/models';
3
+
4
+ export interface TaxDetailsProps {
5
+ taxes: PriceDetails['fixedProductTaxes'];
6
+ displayMode: string;
7
+ }
8
+ export declare const TaxDetails: FunctionComponent<TaxDetailsProps>;
9
+ //# sourceMappingURL=TaxDetails.d.ts.map
@@ -14,5 +14,6 @@
14
14
  * is strictly forbidden unless prior written permission is obtained
15
15
  * from Adobe.
16
16
  *******************************************************************/
17
- export declare const WISHLIST_PAGINATION_ARGUMENTS: string;
18
- //# sourceMappingURL=WishlistPaginationArguments.graphql.d.ts.map
17
+ export * from '.';
18
+ export { TaxDetails } from './TaxDetails';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -19,4 +19,5 @@ export * from './Wishlist';
19
19
  export * from './ProductItem';
20
20
  export * from './ImageCarousel';
21
21
  export * from './Login';
22
+ export * from './TaxDetails';
22
23
  //# sourceMappingURL=index.d.ts.map
@@ -3,6 +3,7 @@ import { Container } from '../../../@adobe-commerce/elsie/src/lib';
3
3
 
4
4
  export interface WishlistProps extends HTMLAttributes<HTMLDivElement> {
5
5
  routeEmptyWishlistCTA?: () => string;
6
+ routeToWishlist?: string;
6
7
  moveProdToCart: (products: {
7
8
  sku: string;
8
9
  quantity: number;
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as n,jsxs as I,Fragment as B}from"@dropins/tools/preact-jsx-runtime.js";import*as W from"@dropins/tools/preact-compat.js";import{Suspense as H,lazy as t,useState as T,useCallback as x,useEffect as $,useMemo as O,Fragment as C}from"@dropins/tools/preact-compat.js";import{classes as L,isNumber as F,VComponent as M}from"@dropins/tools/lib.js";import{IllustratedMessage as z,Button as j,Icon as N,InLineAlert as U}from"@dropins/tools/components.js";import{S as q,a as G,W as J}from"../chunks/WishlistItem.js";import{s as w}from"../chunks/removeProductsFromWishlist.js";import{events as V}from"@dropins/tools/event-bus.js";import{g as K}from"../chunks/getWishlistById.js";import{useText as P,Text as k}from"@dropins/tools/i18n.js";import{a as Q,S as X}from"../chunks/HeartFilled.js";import{useCallback as R,useMemo as Y}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";const b=o=>W.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o},W.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),Z=Object.freeze(Object.defineProperty({__proto__:null,default:b},Symbol.toStringTag,{value:"Module"})),tt=({className:o,children:i,ctaLinkURL:s,...c})=>{const u=P({emptyWishlist:"Wishlist.EmptyWishlist.heading",message:"Wishlist.EmptyWishlist.message",cta:"Wishlist.EmptyWishlist.cta"});return n("div",{...c,className:L(["wishlist-empty-wishlist",o]),children:n(z,{className:L(["wishlist-empty-wishlist__wrapper",o]),"data-testid":"wishlist-empty-wishlist",heading:u.emptyWishlist,icon:n(N,{className:"wishlist-empty-wishlist__icon",source:Q}),message:n("p",{children:u.message}),action:s?n(j,{"data-testid":"wishlist-empty-wishlist-button",size:"medium",variant:"primary",type:"submit",href:s,children:u.cta},"routeHome"):void 0})})},et=function(){const i=typeof document<"u"&&document.createElement("link").relList;return i&&i.supports&&i.supports("modulepreload")?"modulepreload":"preload"}(),it=function(o){return"/"+o},D={},e=function(i,s,c){let u=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),l=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));u=Promise.allSettled(s.map(h=>{if(h=it(h),h in D)return;D[h]=!0;const v=h.endsWith(".css"),f=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${f}`))return;const r=document.createElement("link");if(r.rel=v?"stylesheet":et,v||(r.as="script"),r.crossOrigin="",r.href=h,l&&r.setAttribute("nonce",l),document.head.appendChild(r),v)return new Promise((a,p)=>{r.addEventListener("load",a),r.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${h}`)))})}))}function m(d){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=d,window.dispatchEvent(l),!l.defaultPrevented)throw d}return u.then(d=>{for(const l of d||[])l.status==="rejected"&&m(l.reason);return i().catch(m)})},rt=o=>o.reduce((s,c)=>{if(!c)return s;if(typeof c=="string"&&(s+=` ${c}`),Array.isArray(c)){const[u,m]=c;u&&m&&(s+=` ${u}`)}return s},"").trim(),st={Add:t(()=>e(()=>import("../chunks/Add.js"),[])),Bulk:t(()=>e(()=>import("../chunks/Bulk.js"),[])),Burger:t(()=>e(()=>import("../chunks/Burger.js"),[])),Cart:t(()=>e(()=>import("../chunks/WishlistItem.js").then(o=>o.C),[])),Check:t(()=>e(()=>import("../chunks/Check.js"),[])),ChevronDown:t(()=>e(()=>Promise.resolve().then(()=>Z),void 0)),ChevronUp:t(()=>e(()=>import("../chunks/ChevronUp.js"),[])),ChevronRight:t(()=>e(()=>import("../chunks/ChevronRight.js"),[])),Close:t(()=>e(()=>import("../chunks/Close.js"),[])),Heart:t(()=>e(()=>import("../chunks/HeartFilled.js").then(o=>o.H),[])),Minus:t(()=>e(()=>import("../chunks/Minus.js"),[])),Placeholder:t(()=>e(()=>import("../chunks/Placeholder.js"),[])),PlaceholderFilled:t(()=>e(()=>import("../chunks/PlaceholderFilled.js"),[])),Search:t(()=>e(()=>import("../chunks/Search.js"),[])),SearchFilled:t(()=>e(()=>import("../chunks/SearchFilled.js"),[])),Sort:t(()=>e(()=>import("../chunks/Sort.js"),[])),Star:t(()=>e(()=>import("../chunks/Star.js"),[])),View:t(()=>e(()=>import("../chunks/View.js"),[])),User:t(()=>e(()=>import("../chunks/User.js"),[])),Warning:t(()=>e(()=>import("../chunks/Warning.js"),[])),Locker:t(()=>e(()=>import("../chunks/Locker.js"),[])),Wallet:t(()=>e(()=>import("../chunks/Wallet.js"),[])),Card:t(()=>e(()=>import("../chunks/Card.js"),[])),Order:t(()=>e(()=>import("../chunks/Order.js"),[])),Delivery:t(()=>e(()=>import("../chunks/Delivery.js"),[])),OrderError:t(()=>e(()=>import("../chunks/OrderError.js"),[])),OrderSuccess:t(()=>e(()=>import("../chunks/OrderSuccess.js"),[])),PaymentError:t(()=>e(()=>import("../chunks/PaymentError.js"),[])),CheckWithCircle:t(()=>e(()=>import("../chunks/CheckWithCircle.js"),[])),WarningWithCircle:t(()=>e(()=>import("../chunks/WarningWithCircle.js"),[])),WarningFilled:t(()=>e(()=>import("../chunks/WarningFilled.js"),[])),InfoFilled:t(()=>e(()=>import("../chunks/InfoFilled.js"),[])),HeartFilled:t(()=>e(()=>import("../chunks/HeartFilled.js").then(o=>o.b),[])),Trash:t(()=>e(()=>import("../chunks/WishlistItem.js").then(o=>o.T),[])),Eye:t(()=>e(()=>import("../chunks/Eye.js"),[])),EyeClose:t(()=>e(()=>import("../chunks/EyeClose.js"),[])),Date:t(()=>e(()=>import("../chunks/Date.js"),[])),AddressBook:t(()=>e(()=>import("../chunks/AddressBook.js"),[])),EmptyBox:t(()=>e(()=>import("../chunks/EmptyBox.js"),[])),Coupon:t(()=>e(()=>import("../chunks/Coupon.js"),[])),Gift:t(()=>e(()=>import("../chunks/Gift.js"),[])),GiftCard:t(()=>e(()=>import("../chunks/GiftCard.js"),[]))};function S({source:o,size:i="24",stroke:s="2",viewBox:c="0 0 24 24",className:u,...m}){const d=typeof o=="string"?st[o]:null,l={className:rt(["dropin-icon",`dropin-icon--shape-stroke-${s}`,u]),width:i,height:i,viewBox:c};return n(H,{fallback:n("svg",{...m,...l}),children:d?n(d,{...m,...l}):n(o,{...m,...l})})}const ot=({totalPages:o=10,currentPage:i=1,onChange:s,className:c,...u})=>{const m=P({backwardButton:"Dropin.Pagination.backwardButton.ariaLabel",forwardButton:"Dropin.Pagination.forwardButton.ariaLabel"}),d=R(()=>{const r=Math.min(i+1,o);s==null||s(r)},[i,s,o]),l=R(()=>{const r=Math.max(i-1,1);s==null||s(r)},[i,s]),h=R(r=>{F(r)&&(s==null||s(r))},[s]),v=R((r,a)=>{let p=[];const _=(E,A)=>{for(let g=E;g<=A;g++)p.push({page:g,isActive:g===r,label:g})};return a<=5?_(1,a):r<=2?(_(1,2),p.push({page:"ellipsis",isActive:!1,label:"..."}),_(a-1,a)):r>=a-3?_(a-4,a):(_(r-1,r),p.push({page:"ellipsis",isActive:!1,label:"..."}),_(a-1,a)),p},[]),f=Y(()=>v(i,o),[v,i,o]);return I("div",{...u,className:L(["dropin-pagination",c]),children:[n("button",{type:"button","data-testid":"prev-button","aria-label":m.backwardButton,disabled:i===1,onClick:l,className:L(["dropin-pagination-arrow","dropin-pagination-arrow--backward"]),children:n(S,{size:"24",source:b})}),n("ul",{className:"dropin-pagination_list",children:f.map((r,a)=>n("li",{"data-testid":`dropin-pagination_list-item--${r.page}`,className:L(["dropin-pagination_list-item",`dropin-pagination_list-item--${r.page}`,["dropin-pagination_list-item--active",r.isActive]]),children:n("button",{type:"button","data-testid":`set-page-button-${r.page}`,onClick:()=>h(r.page),children:r.label})},`${r.page}_${a}`))}),n("button",{type:"button","data-testid":"next-button","aria-label":m.forwardButton,disabled:i===o,onClick:d,className:L(["dropin-pagination-arrow","dropin-pagination-arrow--forward"]),children:n(S,{size:"24",source:b})})]})},At=({routeEmptyWishlistCTA:o,moveProdToCart:i,...s})=>{const[c,u]=T(null),[m,d]=T(w.authenticated),l=P({addHeading:"Wishlist.Alert.addProduct.heading",addMessage:"Wishlist.Alert.addProduct.message",removeHeading:"Wishlist.Alert.removeProduct.heading",removeMessage:"Wishlist.Alert.removeProduct.message",moveHeading:"Wishlist.Alert.moveToCart.heading",moveMessage:"Wishlist.Alert.moveToCart.message",viewWishlist:"Wishlist.Alert.viewWishlist"}),h=a=>d(a),[v,f]=T(null),r=x(a=>{const{action:p,item:_}=a,E=l[`${p}Heading`],A=l[`${p}Message`],g={add:X,remove:G,move:q};f(n(U,{"data-testid":"wishlist-alert",heading:E,description:A.replace("{product}",_.product.name),type:"success",icon:n(N,{source:g[p],size:"16"}),actionButtonPosition:"top",additionalActions:[{label:l.viewWishlist,onClick:()=>{}}]}))},[l]);return $(()=>{const a=V.on("authenticated",h),p=V.on("wishlist/update",E=>r(E)),_=V.on("wishlist/data",E=>{u(E)});return()=>{a==null||a.off(),_==null||_.off(),p==null||p.off()}},[r]),n(nt,{...s,wishlistData:c,wishlistAlert:v,routeEmptyWishlistCTA:o,moveProdToCart:i,isLoggedIn:m})},nt=({className:o,wishlistData:i,wishlistAlert:s,isLoggedIn:c,moveProdToCart:u,routeEmptyWishlistCTA:m,...d})=>{const[l,h]=T(s),v=P({wishlistHeading:"Wishlist.Wishlist.heading"}),f=O(()=>{var _;return((_=i==null?void 0:i.items)==null?void 0:_.length)>0?i.items.map(E=>{var A;return n(J,{initialData:E,moveProdToCart:u},(A=E.product)==null?void 0:A.sku)}):null},[i,u]);$(()=>{if(s){h(s);const _=setTimeout(()=>{h(null)},5e3);return()=>clearTimeout(_)}},[s]);const r=O(()=>l?n(M,{node:l,className:"wishlist-wishlist__alert"}):null,[l]),a=O(()=>{var E;if(!f)return null;const _=c?i==null?void 0:i.items_count:i.items.length;return n("div",{className:"wishlist-wishlist__heading","data-testid":"wishlist-heading-wrapper",children:n("div",{className:"wishlist-wishlist__heading-text","data-testid":"default-wishlist-heading",children:(E=v.wishlistHeading)==null?void 0:E.split(" {count}").map((A,g)=>{var y;return I(C,{children:[A,g===0&&n("span",{className:"wishlist-wishlist__heading-count","data-testid":"wishlist-heading-count",children:`${_} products`})]},((y=i==null?void 0:i.id)==null?void 0:y.toString())+g)})})})},[v,f,i]),p=O(()=>!f||!c||i.total_pages===1?null:n(ot,{currentPage:w.currentPage||1,onChange:_=>{K(w.wishlistId,_,w.pageSize||10).then(()=>{w.currentPage=_}).catch(E=>{console.error("Failed to fetch wishlist data:",E)})},totalPages:i.total_pages}),[f,c,i]);return I("div",{...d,className:L(["wishlist-wishlist",o]),children:[r,f?I(B,{children:[a,p,n("div",{className:"wishlist-wishlist__content",children:f})]}):n("div",{className:L(["wishlist-wishlist__content","wishlist-wishlist__content--empty"]),children:I("div",{children:[n(tt,{"data-testid":"empty-wishlist",ctaLinkURL:m==null?void 0:m()}),!c&&n(lt,{})]})})]})},lt=()=>I("div",{className:"wishlist-login__sign-in",children:[n("a",{"data-testid":"log-in-link",className:"wishlist-login__link",href:"/#",target:"_blank",rel:"noreferrer",children:n(k,{id:"Wishlist.Login.logIn"})}),n(k,{id:"Wishlist.Login.sync"})]});export{At as Wishlist,At as default};
3
+ import{jsx as s,jsxs as u,Fragment as H}from"@dropins/tools/preact-jsx-runtime.js";import{useState as _,useCallback as L,useEffect as k,useMemo as N,Fragment as S}from"@dropins/tools/preact-compat.js";import{classes as w,VComponent as F}from"@dropins/tools/lib.js";import{IllustratedMessage as $,Button as j,Icon as M}from"@dropins/tools/components.js";import{W as z}from"../chunks/WishlistItem.js";import{events as v}from"@dropins/tools/event-bus.js";import{s as B}from"../chunks/removeProductsFromWishlist.js";import{useText as x,Text as b}from"@dropins/tools/i18n.js";import{W as V}from"../chunks/WishlistAlert.js";import{S as q}from"../chunks/Heart.js";import"../chunks/Trash.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/HeartFilled.js";const A=({className:l,children:i,ctaLinkURL:e,...d})=>{const r=x({emptyWishlist:"Wishlist.EmptyWishlist.heading",message:"Wishlist.EmptyWishlist.message",cta:"Wishlist.EmptyWishlist.cta"});return s("div",{...d,className:w(["wishlist-empty-wishlist",l]),children:s($,{className:w(["wishlist-empty-wishlist__wrapper",l]),"data-testid":"wishlist-empty-wishlist",heading:r.emptyWishlist,icon:s(M,{className:"wishlist-empty-wishlist__icon",source:q}),message:s("p",{children:r.message}),action:e?s(j,{"data-testid":"wishlist-empty-wishlist-button",size:"medium",variant:"primary",type:"submit",href:e,children:r.cta},"routeHome"):void 0})})},ss=({routeEmptyWishlistCTA:l,routeToWishlist:i,moveProdToCart:e,...d})=>{const[r,h]=_(null),[W,y]=_(B.authenticated),m=n=>y(n),[g,f]=_(null),c=L(n=>{const{action:a,item:t}=n;f(s(V,{action:a,item:t}))},[i]);return k(()=>{const n=v.on("authenticated",m),a=v.on("wishlist/alert",o=>c(o)),t=v.on("wishlist/data",o=>{h(o)});return()=>{n==null||n.off(),t==null||t.off(),a==null||a.off()}},[c]),s(G,{...d,wishlistData:r,wishlistAlert:g,routeEmptyWishlistCTA:l,moveProdToCart:e,isLoggedIn:W})},G=({className:l,wishlistData:i,wishlistAlert:e,isLoggedIn:d,moveProdToCart:r,routeEmptyWishlistCTA:h,onLoginClick:W,...y})=>{const[m,g]=_(e),f=x({wishlistHeading:"Wishlist.Wishlist.heading"}),c=N(()=>{var t;return((t=i==null?void 0:i.items)==null?void 0:t.length)>0?i.items.map(o=>{var p;return s(z,{initialData:o,moveProdToCart:r},(p=o.product)==null?void 0:p.sku)}):null},[i,r]);k(()=>{if(e){g(e);const t=setTimeout(()=>{g(null)},5e3);return()=>clearTimeout(t)}},[e]);const n=N(()=>m?s(F,{node:m,className:"wishlist-wishlist__alert"}):null,[m]),a=N(()=>{var t;return c?s("div",{className:"wishlist-wishlist__heading","data-testid":"wishlist-heading-wrapper",children:s("div",{className:"wishlist-wishlist__heading-text","data-testid":"default-wishlist-heading",children:(t=f.wishlistHeading)==null?void 0:t.split(" {count}").map((o,p)=>{var I;return u(S,{children:[o,p===0&&s("span",{className:"wishlist-wishlist__heading-count","data-testid":"wishlist-heading-count",children:`${i==null?void 0:i.items_count} products`})]},((I=i==null?void 0:i.id)==null?void 0:I.toString())+p)})})}):null},[f,c,i]);return u("div",{...y,className:w(["wishlist-wishlist",l]),children:[n,c?u(H,{children:[a,s("div",{className:"wishlist-wishlist__content",children:c})]}):s("div",{className:w(["wishlist-wishlist__content","wishlist-wishlist__content--empty"]),children:u("div",{children:[s(A,{"data-testid":"empty-wishlist",ctaLinkURL:h==null?void 0:h()}),!d&&s(J,{onLoginClick:W})]})})]})},J=({onLoginClick:l})=>u("div",{className:"wishlist-login__sign-in",children:[s("a",{"data-testid":"log-in-link",className:"wishlist-login__link",href:"",rel:"noreferrer",onClick:l,role:"button",children:s(b,{id:"Wishlist.Login.logIn"})}),s(b,{id:"Wishlist.Login.sync"})]});export{ss as Wishlist,ss as default};