notify-me-wl 2.1.4 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  This JavaScript widget allows users to register their interest in a product that is either "coming soon" or "out of stock" (aka "notify me"). Depending on the `data-type` attribute provided, the widget will display appropriate messages and functionality.
4
4
 
5
+ ### Official docs
6
+
7
+ The full implementation guide lives in the TWC documentation site — start here:
8
+
9
+ - [Notify Me & Coming Soon — Overview](https://the-wishlist-documentation.gitbook.io/the-wishlist-documentation-docs/notify-me-and-coming-soon/overview)
10
+
11
+ This README covers installation and the widget's configuration attributes; the docs
12
+ site is the primary reference for integration, the Customer Interest API, and
13
+ related guides.
14
+
5
15
  #### Features:
6
16
  - Clean, centered modal that inherits the host store's font and stays out of the theme's way (all styles are namespaced under `#twc-nm-overlay`).
7
17
  - Dynamically display a labeled form to collect user information (email, mobile, first/last name, country, province).
@@ -10,7 +20,7 @@ This JavaScript widget allows users to register their interest in a product that
10
20
  - Closes on the × button, clicking the backdrop, or pressing `Esc`; locks background scroll while open and respects `prefers-reduced-motion`.
11
21
  - Optional email/SMS marketing opt-ins.
12
22
  - Two display modes: a centred modal (default) or a right-hand slide-in panel — see [Display modes](#display-modes).
13
- - Two auth modes: bundled server token (default) or Shopify App Proxy — see [Configuration](#configuration).
23
+ - Two auth modes: Shopify App Proxy (default) or a merchant-supplied token — see [Configuration](#configuration).
14
24
  - Optional "Shop similar styles" section under the form, showing personalised product recommendations for the customer.
15
25
 
16
26
  ### Installation
@@ -49,19 +59,58 @@ Add a button to your HTML where you want the widget to appear. The button should
49
59
  - `data-fields`: A JSON array specifying the optional fields to include in the form. Possible values are `"email"`, `"mobile"`, `"firstName"`, `"lastName"`, `"countryCode"`, and `"provinceCode"`. Defaults to `["email"]`. (A required Size selector is always shown and populated from the product's variants.)
50
60
  - `data-type`: Specifies the type of the widget. Possible values are `"notify-me"` and `"coming-soon"`.
51
61
  - `data-display`: How the widget presents itself. `"modal"` (default) is a centred dialog; `"panel"` slides in from the right edge at full height. Any other value falls back to `"modal"`. See [Display modes](#display-modes).
52
- - `data-auth`: Auth mode. `"token"` (default) uses the bundled server-issued access token. `"proxy"` uses the Shopify App Proxy at `/apps/<proxy-app>/auth/token` to obtain a tenant-scoped token (requires the customer to be logged in to the storefront).
62
+ - `data-auth`: Auth mode. `"proxy"` (default) uses the Shopify App Proxy at `/apps/<proxy-app>/auth/token` to obtain a tenant-scoped token (requires the customer to be logged in to the storefront). `"token"` sends a token you supply via `data-access-token` or `window.TWC_ACCESS_TOKEN`. **The widget bundles no credential of its own** — see [Auth modes](#auth-modes).
53
63
  - `data-tenant`: The TWC tenant sent as the `X-Twc-Tenant` header. Used in both auth modes. Falls back to the bundled `TENANT_ID` if omitted.
54
64
  - `data-proxy-app`: The Shopify App Proxy subpath, forming the `/apps/<proxy-app>/...` URL prefix used by the `"proxy"` auth mode. Falls back to the bundled `PROXY_APP_NAME` (`twc-sdk`) if omitted.
65
+ - `data-access-token`: Access token for the `"token"` auth mode, with or without the `Bearer ` prefix. Takes precedence over `window.TWC_ACCESS_TOKEN`. Ignored in `"proxy"` mode. Anything rendered here is visible to anyone viewing the page — use a short-lived, narrowly scoped token, never a staff or POS credential.
66
+ - `data-market-id`: The Shopify market the shopper is browsing in. Accepts either the numeric id or the full GID — `gid://shopify/Market/12345` and `12345` both send `12345`. Falls back to `window.Shopify.markets.currentMarket.id` when omitted. See [Shopify markets](#shopify-markets).
67
+ - `data-market-handle`: The market handle (e.g. `"au"`). Attribute only — there is no runtime fallback, so a theme that does not render it reports no handle.
68
+ - `data-country-code`: Two-letter ISO country code for the market the shopper is browsing in. Takes priority over the automatic detection chain, but a country the shopper picks in the form still wins over both.
55
69
  - `data-recommendations`: Set to `"false"` to disable the "Shop similar styles" section. Enabled by default.
56
70
  - `data-recommendations-count`: How many products to show. Defaults to `8`. Non-numeric or non-positive values fall back to `8`.
57
71
  - `data-currency`: Fallback ISO currency code (e.g. `"AUD"`) for formatting recommendation prices, used only when the storefront does not expose `window.Shopify.currency.active`. Without either, prices render as bare numbers rather than risking the wrong symbol.
58
72
  - `data-customer-email`: Overrides the customer email used to request recommendations. Intended for testing — in production the email comes from the Shopify customer context, or from the email the shopper submits.
59
73
 
60
- ### Proxy auth mode
74
+ ### Auth modes
75
+
76
+ Every TWC API call needs an `Authorization` header and an `X-Twc-Tenant` header.
77
+ `data-auth` chooses where the token comes from. **The distributed bundle contains no
78
+ access token** — a `"token"` install that supplies none will fail to submit.
79
+
80
+ #### `"proxy"` (default)
81
+
82
+ The widget lazily fetches a tenant-scoped token from the same-origin Shopify App Proxy
83
+ endpoint `/apps/<proxy-app>/auth/token` on form submit (where `<proxy-app>` comes from
84
+ `data-proxy-app`, defaulting to `twc-sdk`; Shopify signs and forwards the request). The
85
+ token is cached for the page session and reused across submissions.
86
+
87
+ Because the proxy only issues a token for a logged-in customer, if the token cannot be
88
+ obtained the popup stays open and shows an inline "Please log in to your account to
89
+ continue." message; submission is blocked until a token is available.
90
+
91
+ #### `"token"`
92
+
93
+ Sends a token you supply, from `data-access-token` on the open button or
94
+ `window.TWC_ACCESS_TOKEN`. The attribute wins if both are present, and the `Bearer `
95
+ prefix is added if you omit it.
96
+
97
+ ```html
98
+ <button id="popup-open" data-type="notify-me" data-auth="token"
99
+ data-access-token="{{ twc_widget_token }}">Notify Me</button>
100
+ ```
101
+
102
+ Anything you render here ships to the browser and is readable by anyone who views the
103
+ page or the bundle. Mint a short-lived token scoped to customer-interest writes for the
104
+ single tenant — never a staff, POS, or store-owner credential. If you cannot mint one
105
+ that narrow, use `"proxy"` instead.
61
106
 
62
- When `data-auth="proxy"` is set, the widget does not use the bundled access token. Instead, on form submit it lazily fetches a tenant-scoped access token from the same-origin Shopify App Proxy endpoint `/apps/<proxy-app>/auth/token` (where `<proxy-app>` comes from `data-proxy-app`, defaulting to `twc-sdk`; Shopify signs and forwards the request). The token is cached for the page session and reused across submissions.
107
+ When `"token"` mode has no token, the widget logs a setup error to the console and the
108
+ submission fails with the generic error message.
63
109
 
64
- Because the proxy only issues a token for a logged-in customer, if the token cannot be obtained the popup stays open and shows an inline "Please log in to your account to continue." message; submission is blocked until a token is available.
110
+ > **Breaking change in 3.0.0:** the default `data-auth` moved from `"token"` to
111
+ > `"proxy"`, and the previously bundled access token was removed. Installs that relied
112
+ > on the bundled token must either set up the App Proxy or supply their own token via
113
+ > `data-access-token`.
65
114
 
66
115
  ### Display modes
67
116
 
@@ -87,6 +136,36 @@ changes nothing about the widget's behaviour, so anything documented elsewhere i
87
136
  README applies to both modes. Under `prefers-reduced-motion` the panel appears without
88
137
  sliding.
89
138
 
139
+ ### Shopify markets
140
+
141
+ Market and country are captured on every submission so interest can be reported per
142
+ market. The values come from Liquid, which renders server-side, so the theme passes
143
+ them to the widget as attributes on the open button:
144
+
145
+ ```html
146
+ <button id="popup-open"
147
+ data-type="notify-me"
148
+ data-market-id="{{ localization.market.id }}"
149
+ data-market-handle="{{ localization.market.handle }}"
150
+ data-country-code="{{ localization.country.iso_code }}">
151
+ Notify Me
152
+ </button>
153
+ ```
154
+
155
+ **The market id is sent as the number only** — `12345`, never
156
+ `gid://shopify/Market/12345`. The widget strips the GID prefix itself, so it does not
157
+ matter which form the theme renders.
158
+
159
+ Any value that does not look right — an empty string from a storefront with no market
160
+ configured, or an unrendered Liquid tag — is dropped, and the field is left out of the
161
+ payload rather than sent as `null`. All three attributes are optional: without them,
162
+ `marketId` and `countryCode` still resolve from `window.Shopify` and the browser locale,
163
+ and `marketHandle` is simply not reported.
164
+
165
+ When `data-fields` includes `"countryCode"`, the country the shopper picks in the form
166
+ takes precedence over `data-country-code`. The dropdown is pre-selected to the market's
167
+ country, so leaving it untouched sends the market country either way.
168
+
90
169
  ### Shop similar styles
91
170
 
92
171
  When enabled, the widget shows a horizontally scrolling row of recommended products
@@ -203,5 +282,7 @@ simply not rendered. It never blocks or alters the notify-me submission.
203
282
  https://api.au-aws.thewishlist.io/services/wsservice/api/wishlist/items/customerInterest
204
283
  ```
205
284
 
206
- Replace `ACCESS_TOKEN` with your actual access token to authenticate API requests.
207
- Replace `TENANT_ID` with your actual tenant to authenticate API requests.
285
+ Authenticate with an `Authorization: Bearer <token>` header and an
286
+ `X-Twc-Tenant: <tenant>` header. The widget resolves the token per
287
+ [Auth modes](#auth-modes) and the tenant from `data-tenant`; there is no
288
+ `ACCESS_TOKEN` constant in the bundle to replace.
@@ -1 +1 @@
1
- !function(){"use strict";const e=[{code:"AF",name:"Afghanistan"},{code:"AX",name:"Åland Islands"},{code:"AL",name:"Albania"},{code:"DZ",name:"Algeria"},{code:"AS",name:"American Samoa"},{code:"AD",name:"Andorra"},{code:"AO",name:"Angola"},{code:"AI",name:"Anguilla"},{code:"AG",name:"Antigua and Barbuda"},{code:"AR",name:"Argentina"},{code:"AM",name:"Armenia"},{code:"AW",name:"Aruba"},{code:"AU",name:"Australia"},{code:"AT",name:"Austria"},{code:"AZ",name:"Azerbaijan"},{code:"BS",name:"Bahamas"},{code:"BH",name:"Bahrain"},{code:"BD",name:"Bangladesh"},{code:"BB",name:"Barbados"},{code:"BY",name:"Belarus"},{code:"BE",name:"Belgium"},{code:"BZ",name:"Belize"},{code:"BJ",name:"Benin"},{code:"BM",name:"Bermuda"},{code:"BT",name:"Bhutan"},{code:"BO",name:"Bolivia"},{code:"BA",name:"Bosnia and Herzegovina"},{code:"BW",name:"Botswana"},{code:"BR",name:"Brazil"},{code:"BN",name:"Brunei"},{code:"BG",name:"Bulgaria"},{code:"BF",name:"Burkina Faso"},{code:"BI",name:"Burundi"},{code:"CV",name:"Cabo Verde"},{code:"KH",name:"Cambodia"},{code:"CM",name:"Cameroon"},{code:"CA",name:"Canada"},{code:"KY",name:"Cayman Islands"},{code:"CF",name:"Central African Republic"},{code:"TD",name:"Chad"},{code:"CL",name:"Chile"},{code:"CN",name:"China"},{code:"CO",name:"Colombia"},{code:"KM",name:"Comoros"},{code:"CG",name:"Congo"},{code:"CD",name:"Congo, DR"},{code:"CK",name:"Cook Islands"},{code:"CR",name:"Costa Rica"},{code:"HR",name:"Croatia"},{code:"CU",name:"Cuba"},{code:"CW",name:"Curaçao"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czech Republic"},{code:"DK",name:"Denmark"},{code:"DJ",name:"Djibouti"},{code:"DM",name:"Dominica"},{code:"DO",name:"Dominican Republic"},{code:"EC",name:"Ecuador"},{code:"EG",name:"Egypt"},{code:"SV",name:"El Salvador"},{code:"GQ",name:"Equatorial Guinea"},{code:"ER",name:"Eritrea"},{code:"EE",name:"Estonia"},{code:"SZ",name:"Eswatini"},{code:"ET",name:"Ethiopia"},{code:"FO",name:"Faroe Islands"},{code:"FJ",name:"Fiji"},{code:"FI",name:"Finland"},{code:"FR",name:"France"},{code:"GF",name:"French Guiana"},{code:"PF",name:"French Polynesia"},{code:"GA",name:"Gabon"},{code:"GM",name:"Gambia"},{code:"GE",name:"Georgia"},{code:"DE",name:"Germany"},{code:"GH",name:"Ghana"},{code:"GI",name:"Gibraltar"},{code:"GR",name:"Greece"},{code:"GL",name:"Greenland"},{code:"GD",name:"Grenada"},{code:"GP",name:"Guadeloupe"},{code:"GU",name:"Guam"},{code:"GT",name:"Guatemala"},{code:"GN",name:"Guinea"},{code:"GW",name:"Guinea-Bissau"},{code:"GY",name:"Guyana"},{code:"HT",name:"Haiti"},{code:"HN",name:"Honduras"},{code:"HK",name:"Hong Kong"},{code:"HU",name:"Hungary"},{code:"IS",name:"Iceland"},{code:"IN",name:"India"},{code:"ID",name:"Indonesia"},{code:"IR",name:"Iran"},{code:"IQ",name:"Iraq"},{code:"IE",name:"Ireland"},{code:"IM",name:"Isle of Man"},{code:"IL",name:"Israel"},{code:"IT",name:"Italy"},{code:"JM",name:"Jamaica"},{code:"JP",name:"Japan"},{code:"JE",name:"Jersey"},{code:"JO",name:"Jordan"},{code:"KZ",name:"Kazakhstan"},{code:"KE",name:"Kenya"},{code:"KI",name:"Kiribati"},{code:"KR",name:"Korea, South"},{code:"XK",name:"Kosovo"},{code:"KW",name:"Kuwait"},{code:"KG",name:"Kyrgyzstan"},{code:"LA",name:"Laos"},{code:"LV",name:"Latvia"},{code:"LB",name:"Lebanon"},{code:"LS",name:"Lesotho"},{code:"LR",name:"Liberia"},{code:"LY",name:"Libya"},{code:"LI",name:"Liechtenstein"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"MO",name:"Macao"},{code:"MG",name:"Madagascar"},{code:"MW",name:"Malawi"},{code:"MY",name:"Malaysia"},{code:"MV",name:"Maldives"},{code:"ML",name:"Mali"},{code:"MT",name:"Malta"},{code:"MH",name:"Marshall Islands"},{code:"MQ",name:"Martinique"},{code:"MR",name:"Mauritania"},{code:"MU",name:"Mauritius"},{code:"MX",name:"Mexico"},{code:"FM",name:"Micronesia"},{code:"MD",name:"Moldova"},{code:"MC",name:"Monaco"},{code:"MN",name:"Mongolia"},{code:"ME",name:"Montenegro"},{code:"MS",name:"Montserrat"},{code:"MA",name:"Morocco"},{code:"MZ",name:"Mozambique"},{code:"MM",name:"Myanmar"},{code:"NA",name:"Namibia"},{code:"NR",name:"Nauru"},{code:"NP",name:"Nepal"},{code:"NL",name:"Netherlands"},{code:"NC",name:"New Caledonia"},{code:"NZ",name:"New Zealand"},{code:"NI",name:"Nicaragua"},{code:"NE",name:"Niger"},{code:"NG",name:"Nigeria"},{code:"NU",name:"Niue"},{code:"MK",name:"North Macedonia"},{code:"NO",name:"Norway"},{code:"OM",name:"Oman"},{code:"PK",name:"Pakistan"},{code:"PW",name:"Palau"},{code:"PS",name:"Palestine"},{code:"PA",name:"Panama"},{code:"PG",name:"Papua New Guinea"},{code:"PY",name:"Paraguay"},{code:"PE",name:"Peru"},{code:"PH",name:"Philippines"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"PR",name:"Puerto Rico"},{code:"QA",name:"Qatar"},{code:"RE",name:"Réunion"},{code:"RO",name:"Romania"},{code:"RW",name:"Rwanda"},{code:"KN",name:"Saint Kitts and Nevis"},{code:"LC",name:"Saint Lucia"},{code:"VC",name:"Saint Vincent and the Grenadines"},{code:"WS",name:"Samoa"},{code:"SM",name:"San Marino"},{code:"SA",name:"Saudi Arabia"},{code:"SN",name:"Senegal"},{code:"RS",name:"Serbia"},{code:"SC",name:"Seychelles"},{code:"SL",name:"Sierra Leone"},{code:"SG",name:"Singapore"},{code:"SK",name:"Slovakia"},{code:"SI",name:"Slovenia"},{code:"SB",name:"Solomon Islands"},{code:"SO",name:"Somalia"},{code:"ZA",name:"South Africa"},{code:"SS",name:"South Sudan"},{code:"ES",name:"Spain"},{code:"LK",name:"Sri Lanka"},{code:"SD",name:"Sudan"},{code:"SR",name:"Suriname"},{code:"SE",name:"Sweden"},{code:"CH",name:"Switzerland"},{code:"SY",name:"Syria"},{code:"TW",name:"Taiwan"},{code:"TJ",name:"Tajikistan"},{code:"TZ",name:"Tanzania"},{code:"TH",name:"Thailand"},{code:"TL",name:"Timor-Leste"},{code:"TG",name:"Togo"},{code:"TO",name:"Tonga"},{code:"TT",name:"Trinidad and Tobago"},{code:"TN",name:"Tunisia"},{code:"TR",name:"Turkey"},{code:"TM",name:"Turkmenistan"},{code:"TC",name:"Turks and Caicos Islands"},{code:"TV",name:"Tuvalu"},{code:"UG",name:"Uganda"},{code:"UA",name:"Ukraine"},{code:"AE",name:"United Arab Emirates"},{code:"GB",name:"United Kingdom"},{code:"US",name:"United States"},{code:"UY",name:"Uruguay"},{code:"UZ",name:"Uzbekistan"},{code:"VU",name:"Vanuatu"},{code:"VE",name:"Venezuela"},{code:"VN",name:"Vietnam"},{code:"VG",name:"Virgin Islands, British"},{code:"VI",name:"Virgin Islands, U.S."},{code:"YE",name:"Yemen"},{code:"ZM",name:"Zambia"},{code:"ZW",name:"Zimbabwe"}];let n=null;async function t(e,t){if("proxy"!==e)return"Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJRWlJkS3JabXJmMEk3WkhXRUtqNWRLTEhQanFubWJFeV9iNmpSbHdya1drIn0.eyJleHAiOjE3ODU5Mzc5NDMsImlhdCI6MTc4NTkzNDM0MywianRpIjoiOWExNWU1NmEtN2JmMi00ZTFhLTk4NmMtODBkZTIzYTUzNmI4IiwiaXNzIjoiaHR0cHM6Ly9hdXRoLmF1LWF3cy50aGV3aXNobGlzdC5pby9hdXRoL3JlYWxtcy90d2NNYWluIiwiYXVkIjoiYWNjb3VudCIsInN1YiI6IjY4OTlkMjU4LTcyNWQtNDcwMy04YzQ5LTI2OTRiZmUyZGExYSIsInR5cCI6IkJlYXJlciIsImF6cCI6InR3Yy1wb3MtY2xpZW50Iiwic2Vzc2lvbl9zdGF0ZSI6ImFkOGFkOTE0LWNhMmEtNGE4Yy05M2M1LTNmMzA3MjliMmRkOSIsImFsbG93ZWQtb3JpZ2lucyI6WyJodHRwczovL2xvY2FsaG9zdCJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsidHdjLXBvcy11c2VyIiwiZGVmYXVsdC1yb2xlcy10d2NtYWluIiwib2ZmbGluZV9hY2Nlc3MiLCJ1bWFfYXV0aG9yaXphdGlvbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoib3BlbmlkIHRlbmFudGlkIHN0b3JlIHByb2ZpbGUgc3RhZmZyZWYgZW1haWwiLCJzaWQiOiJhZDhhZDkxNC1jYTJhLTRhOGMtOTNjNS0zZjMwNzI5YjJkZDkiLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsInRlbmFudGlkIjoidHdjLWZhc2hpb24tZGVtbyIsIm5hbWUiOiJtYXR0IGZhc2hpb25kZW1vIiwicHJlZmVycmVkX3VzZXJuYW1lIjoibWF0dEBmYXNoaW9uZGVtby5jb20uYXUiLCJzdG9yZSI6InR3Yy1mYXNoaW9uLWRlbW8tdGVzdCIsImdpdmVuX25hbWUiOiJtYXR0IiwiZmFtaWx5X25hbWUiOiJmYXNoaW9uZGVtbyIsImVtYWlsIjoibWF0dEBmYXNoaW9uZGVtby5jb20uYXUifQ.rhW9joS8vQm13qHiXkgs-NHZM1Epva0cYGxIMXIyT6TEiDVAir8H536S8BlJKnFJWRVzsKn7VwaLoftgCPYvbsYDjC_wMnTY1oKygXs61DLaTWt90ou-4T5Ox0Ta_00dEFtmz22ouembFTrF_mumUPLGqsyc93nWIJZVQdmoqAnvxLiMs_F9PAVIq8X3ahjC9Qt_bzAa7QagQSWapQasfIQ9Wbwr9qa6JpIpYQnKf2j_Io0mNb7G2Xhvt0Pe8HqYNP50AJMvRdlQY_bHDAKtTRDGFU1jU_hVfbcWh44ZjjHHuSyM7TLvvI9M4gpLzXI25BCOf81tddVZAox4ms62TQ";const o=await async function(e){if(n)return n;try{const t=await fetch(`/apps/${e}/auth/token`,{method:"GET",headers:{Accept:"application/json"}}),o=await t.json().catch(()=>null);return t.ok&&o&&o.success&&o.data&&o.data.access_token?(n=o.data.access_token,n):null}catch(e){return console.error("Error fetching proxy access token:",e),null}}(t);return o?`Bearer ${o}`:null}const o=new Map;function a(e){return"string"==typeof e?e.trim():""}async function c(e,n,c){const i=o.get(e);if(void 0!==i)return i;const r=await t(n,c);if(!r)return null;try{const n=await fetch("https://api.au-aws.thewishlist.io/services/eventcollector/api/v1/custom/configs/public",{method:"GET",headers:{Accept:"application/json",Authorization:r,"X-Twc-Tenant":e}});if(!n.ok)return console.error("Tenant config request failed:",n.status),null;const t=function(e){if(!e||"object"!=typeof e)return null;const n=e.websiteRecommendations;if(!n||"object"!=typeof n)return null;const t=a(n.engine).toUpperCase();if("TWC"===t)return{engine:"TWC"};if("ATHOS"===t){const e=a(n.siteIdentifier);return e?{engine:"ATHOS",siteIdentifier:e,profileTag:a(n.profileTag)||a(n.tags)||"similar"}:null}return null}(await n.json().catch(()=>null));return o.set(e,t),t}catch(e){return console.error("Error fetching tenant config:",e),null}}function i(e){return"string"==typeof e?e.trim():""}function r(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){const n=parseFloat(e);if(Number.isFinite(n))return n}return null}function d(e){return Boolean(e.name&&e.imageUrl&&e.productUrl)}function m(e,n){const t=new Map;return e.forEach(e=>{const n=t.get(e.product.ref);n&&n.score>=e.score||t.set(e.product.ref,e)}),Array.from(t.values()).sort((e,n)=>n.score-e.score).slice(0,n).map(e=>e.product)}async function s(e){const{email:n,tenant:o,authMode:a,proxyApp:c,count:s}=e,l=await t(a,c);if(!l)return null;const u=Math.min(3*s,20),p=`https://api.au-aws.thewishlist.io/services/recommendations/api/v1/recommendations/${encodeURIComponent(o)}/${encodeURIComponent(n)}?n=${u}`;try{const e=await fetch(p,{method:"GET",headers:{Accept:"application/json",Authorization:l,"X-Twc-Tenant":o}});if(!e.ok)return console.error("Recommendations request failed:",e.status),null;return function(e,n){const t=e&&e.recommendations;if(!Array.isArray(t))return[];const o=[];return t.forEach(e=>{var n;const t=e&&e.product;if(!t)return;const a=i(t.name),c=i(t.image_url),m=i(t.product_url);if(!d({name:a,imageUrl:c,productUrl:m}))return;const s=i(t.product_ref)||i(t.product_id)||m;o.push({score:"number"==typeof e.score?e.score:0,product:{id:i(t.product_id)||s,ref:s,name:a,imageUrl:c,productUrl:m,price:null!==(n=r(t.price))&&void 0!==n?n:0,originalPrice:r(t.original_price)}})}),m(o,n)}(await e.json().catch(()=>null),s)}catch(e){return console.error("Error fetching recommendations:",e),null}}async function l(e){const{engine:n,email:t,count:o,productId:a}=e,c=encodeURIComponent(n.siteIdentifier),s=[`tags=${encodeURIComponent(n.profileTag)}`,`limits=${o}`];a&&s.push(`products=${encodeURIComponent(a)}`),t&&s.push(`shopper=${encodeURIComponent(t)}`);const l=`https://${c}.a.searchspring.io/boost/${c}/recommend?`+s.join("&");try{const e=await fetch(l,{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)return console.error("Athos recommendations request failed:",e.status),null;return function(e,n){const t=Array.isArray(e)?e[0]:e,o=t&&t.results;if(!Array.isArray(o))return[];const a=[];return o.forEach((e,n)=>{var t;const c=e&&e.mappings&&e.mappings.core;if(!c)return;const m=i(c.name),s=i(c.imageUrl)||i(c.thumbnailImageUrl),l=i(c.url);if(!d({name:m,imageUrl:s,productUrl:l}))return;const u=i(c.uid)||i(c.sku)||l,p=null!==(t=r(c.price))&&void 0!==t?t:0,w=r(c.msrp);a.push({score:o.length-n,product:{id:i(c.uid)||u,ref:u,name:m,imageUrl:s,productUrl:l,price:p,originalPrice:null!==w&&w>p?w:null}})}),m(a,n)}(await e.json().catch(()=>null),o)}catch(e){return console.error("Error fetching Athos recommendations:",e),null}}const u=new Map;const p="twc-nm-recs",w="twc-nm-recs-title";function f(e,n){if(n)try{return new Intl.NumberFormat(void 0,{style:"currency",currency:n}).format(e)}catch(e){}return new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}function y(){const e=document.createElement("div");e.className="twc-nm-rec twc-nm-rec--skeleton",e.setAttribute("aria-hidden","true");const n=document.createElement("div");n.className="twc-nm-rec-imgbox twc-nm-skel",e.appendChild(n);const t=document.createElement("span");t.className="twc-nm-skel twc-nm-skel-line",e.appendChild(t);const o=document.createElement("span");return o.className="twc-nm-skel twc-nm-skel-line twc-nm-skel-line--short",e.appendChild(o),e}function h(e){const{section:n,row:t}=function(){const e=document.createElement("section");e.id=p,e.className="twc-nm-recs",e.setAttribute("aria-labelledby",w);const n=document.createElement("h3");n.id=w,n.className="twc-nm-recs-title",n.textContent="Shop similar styles",e.appendChild(n);const t=document.createElement("div");return t.className="twc-nm-recs-row",e.appendChild(t),{section:e,row:t}}();n.classList.add("twc-nm-recs--loading"),n.setAttribute("aria-busy","true");for(let n=0;n<e;n++)t.appendChild(y());return n}function b(e,n,t){const o=e.querySelector(".twc-nm-recs-row");if(!o)return;const a=(c=t,window.Shopify&&window.Shopify.currency&&window.Shopify.currency.active||c||null);var c;const i=document.createDocumentFragment();n.forEach(e=>{i.appendChild(function(e,n){const t=document.createElement("a");t.className="twc-nm-rec",t.href=e.productUrl,t.target="_blank",t.rel="noopener noreferrer";const o=document.createElement("div");o.className="twc-nm-rec-imgbox";const a=document.createElement("img");a.className="twc-nm-rec-img",a.src=e.imageUrl,a.alt=e.name,a.loading="lazy",a.decoding="async",o.appendChild(a),t.appendChild(o);const c=document.createElement("span");c.className="twc-nm-rec-name",c.textContent=e.name,t.appendChild(c);const i=document.createElement("span");if(i.className="twc-nm-rec-price",null!==e.originalPrice&&e.originalPrice>e.price){const t=document.createElement("s");t.className="twc-nm-rec-was",t.textContent=f(e.originalPrice,n),i.appendChild(t),i.appendChild(document.createTextNode(" "))}return i.appendChild(document.createTextNode(f(e.price,n))),t.appendChild(i),t}(e,a))}),o.textContent="",o.appendChild(i),e.classList.remove("twc-nm-recs--loading"),e.removeAttribute("aria-busy")}function g(){const e=document.getElementById(p);e&&e.parentNode&&e.parentNode.removeChild(e)}const v={"notify-me":{text:"Register to receive a notification as soon as this item is back in stock",buttonText:"Notify Me"},"coming-soon":{text:"Register your interest to hear more about this item",buttonText:"Register Interest"}};function x(n){const{wrapper:o,openButton:a,config:i,productData:r,countryCtx:d}=n,{fields:m,type:w,display:f,authMode:y,tenant:x,proxyApp:C,marketId:I,recommendationsEnabled:k,recommendationsCount:N,currency:M,customerEmail:E}=i,S=document.createElement("div");S.innerHTML='\n <div id="twc-nm-overlay" role="dialog" aria-modal="true" aria-labelledby="popup-title">\n <div class="twc-nm-card">\n <button type="button" id="popup-close" class="twc-nm-close" aria-label="Close">&times;</button>\n <h2 id="popup-title" class="twc-nm-title"></h2>\n <p id="popup-text" class="twc-nm-text"></p>\n <form id="popup-form" class="twc-nm-form">\n <div class="twc-nm-field">\n <label class="twc-nm-label" for="twc-nm-size">Size</label>\n <select class="twc-nm-select" id="twc-nm-size" name="select-size" required>\n <option value="" disabled selected>Select a size</option>\n </select>\n </div>\n </form>\n </div>\n </div>\n ',o.appendChild(S);const A=document.getElementById("twc-nm-overlay"),T=document.getElementById("popup-close"),L=document.getElementById("popup-title"),G=document.getElementById("popup-text"),B=document.querySelector("select[name='select-size']"),W=document.getElementById("popup-form");if(!(A&&T&&L&&G&&B&&W))return;"panel"===f&&A.classList.add("twc-nm--panel"),G.innerText=v[w].text;const R=e.map(e=>`<option value="${e.code}"${e.code===d.countryCode?" selected":""}>${e.name}</option>`).join(""),Z=(e,n,t)=>`<div class="twc-nm-field"><label class="twc-nm-label" for="${e}">${n}</label>${t}</div>`,U={email:Z("twc-nm-email","Email",'<input class="twc-nm-input" id="twc-nm-email" name="email" type="email" placeholder="you@example.com" required />'),mobile:Z("twc-nm-mobile","Mobile",'<input class="twc-nm-input" id="twc-nm-mobile" name="mobile" type="tel" placeholder="Mobile number" required />'),firstName:Z("twc-nm-firstname","First name",'<input class="twc-nm-input" id="twc-nm-firstname" name="firstName" type="text" placeholder="First name" required />'),lastName:Z("twc-nm-lastname","Last name",'<input class="twc-nm-input" id="twc-nm-lastname" name="lastName" type="text" placeholder="Last name" required />'),countryCode:Z("twc-nm-country","Country",`<select class="twc-nm-select" id="twc-nm-country" name="countryCode"><option value="">Select country</option>${R}</select>`),provinceCode:Z("twc-nm-province","State / Province",`<input class="twc-nm-input" id="twc-nm-province" name="provinceCode" type="text" placeholder="State / province code" value="${d.provinceCode||""}" />`)};m.forEach(e=>{U[e]&&W.insertAdjacentHTML("beforeend",U[e])}),W.insertAdjacentHTML("beforeend",'<div class="twc-nm-checks">\n <label class="twc-nm-check"><input type="checkbox" name="mailList" /> Email me store updates</label>\n <label class="twc-nm-check"><input type="checkbox" name="mailListSms" /> Text me store updates</label>\n </div>'),W.insertAdjacentHTML("beforeend",'<div id="popup-status" class="twc-nm-status" role="status" aria-live="polite" hidden></div>'),W.insertAdjacentHTML("beforeend",`<button type="submit" class="twc-nm-submit">${v[w].buttonText}</button>`);const z=document.getElementById("popup-status"),Y=W.querySelector(".twc-nm-submit");if(!z||!Y)return;function j(e,n){z.textContent=n,z.className=`twc-nm-status twc-nm-status--${e}`,z.hidden=!1}function F(){z.hidden=!0,z.textContent=""}const J=e=>{const n=W.querySelector(e);return n?n.value:""},V=e=>{const n=W.querySelector(e);return!!n&&n.checked},P=A.querySelector(".twc-nm-card");let H=null;async function X(e){const n=await function(e,n,t){return c(e,n,t)}(x,y,C);if(!n)return!1;if(!A.classList.contains("is-open"))return!1;const t=h(N);P.appendChild(t);const o=await async function(e,n){const{email:t,tenant:o,authMode:a,proxyApp:c,count:i,productId:r}=n,d=`${e.engine}|${o}|${t}|${i}|${r||""}`,m=u.get(d);if(m)return m;let p=null;return p="ATHOS"===e.engine?await l({engine:e,email:t,count:i,productId:r}):await s({email:t,tenant:o,authMode:a,proxyApp:c,count:i}),null===p?[]:(u.set(d,p),p)}(n,{email:e,tenant:x,authMode:y,proxyApp:C,count:N,productId:r?String(r.id):null});return!!t.isConnected&&(o.length?(b(t,o,M),!0):(g(),!1))}function O(e){if(!k||!P)return Promise.resolve(!1);if(H)return H;if(document.getElementById(p))return Promise.resolve(!0);const n=X(e);return H=n,n.then(e=>(H===n&&(H=null),e),e=>(H===n&&(H=null),console.error("Error rendering recommendations:",e),!1))}let D=!1,K=null;function q(e){"Escape"===e.key&&$()}function $(){A.classList.remove("is-open"),document.body.style.overflow="",document.removeEventListener("keydown",q),F(),g(),H=null,K&&"function"==typeof K.focus&&K.focus()}a.addEventListener("click",function(){if(K=document.activeElement,A.classList.add("is-open"),document.body.style.overflow="hidden",document.addEventListener("keydown",q),!r)return W.hidden=!0,void j("error","Product information is unavailable. Please refresh the page.");L.textContent=r.title,D||((r.variants||[]).forEach(e=>{const n=document.createElement("option");n.value=e.title,n.textContent=e.title,B.appendChild(n)}),D=!0),E&&O(E);const e=W.querySelector("select, input");e&&e.focus()}),T.addEventListener("click",$),A.addEventListener("click",e=>{e.target===A&&$()}),W.addEventListener("submit",async e=>{e.preventDefault();const n=((null==r?void 0:r.variants)||[]).find(e=>e.title===B.value);if(!n)return void j("error","Please select a size.");const o={variantRef:n.id,email:J("input[name='email']"),subscribe:V("input[name='mailList']"),subscribeSms:V("input[name='mailListSms']")};if("coming-soon"===w?o.comingSoon=!0:o.notifyMe=!0,m.includes("firstName")&&(o.firstName=J("input[name='firstName']")),m.includes("lastName")&&(o.lastName=J("input[name='lastName']")),m.includes("mobile")&&(o.mobile=J("input[name='mobile']")),m.includes("countryCode")){const e=J("select[name='countryCode']");e&&(o.countryCode=e)}else d.countryCode&&(o.countryCode=d.countryCode);if(m.includes("provinceCode")){const e=J("input[name='provinceCode']");e&&(o.provinceCode=e)}else d.provinceCode&&(o.provinceCode=d.provinceCode);I&&(o.marketId=I),F();const a=Y.textContent||"";Y.disabled=!0,Y.textContent="Sending…";let c={ok:!1,reason:"error"};try{c=await async function(e,n,o,a){const c=await t(n,a);if(!c)return{ok:!1,reason:"auth"};try{return(await fetch("https://api.au-aws.thewishlist.io/services/wsservice/api/wishlist/items/customerInterest",{method:"POST",headers:{"Content-Type":"application/json",Authorization:c,"X-Twc-Tenant":o},body:JSON.stringify(e)})).ok?{ok:!0}:{ok:!1,reason:"error"}}catch(e){return console.error("Error submitting form:",e),{ok:!1,reason:"error"}}}(o,y,x,C)}finally{Y.disabled=!1,Y.textContent=a}if(c.ok){j("success","You're on the list. We'll be in touch.");const e=E||J("input[name='email']");!!e&&await O(e)||setTimeout($,1500)}else"auth"===c.reason?j("error","Please log in to your account to continue."):j("error","Something went wrong. Please try again.")})}function C(e){const n=e.getAttribute("data-customer-email");if(n&&n.trim())return n.trim();const t=window.customer&&window.customer.email;return t&&t.trim()?t.trim():null}document.addEventListener("DOMContentLoaded",()=>{const e=document.getElementById("notification-widget");if(!e)return;const n=document.getElementById("popup-open");if(!n)return;!function(){const e=document.createElement("style");e.type="text/css",e.innerText="\n .notification-btn {\n display: inline-block;\n width: 100%;\n padding: 12px 24px;\n background: #fff;\n border: 1px solid #111827;\n border-radius: 8px;\n color: #111827;\n font: inherit;\n text-align: center;\n text-transform: uppercase;\n cursor: pointer;\n }\n .notification-btn:hover {\n background: #111827;\n color: #fff;\n }\n #twc-nm-overlay {\n position: fixed;\n inset: 0;\n z-index: 99999;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 16px;\n background: rgba(17, 17, 17, 0.55);\n opacity: 0;\n visibility: hidden;\n transition: opacity 200ms ease;\n }\n #twc-nm-overlay.is-open {\n opacity: 1;\n visibility: visible;\n }\n #twc-nm-overlay * {\n box-sizing: border-box;\n }\n #twc-nm-overlay .twc-nm-card {\n position: relative;\n width: 100%;\n max-width: 400px;\n max-height: calc(100vh - 32px);\n overflow-y: auto;\n padding: 24px;\n background: #fff;\n color: #111827;\n border-radius: 12px;\n box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);\n font: inherit;\n transform: translateY(8px);\n transition: transform 200ms ease;\n }\n #twc-nm-overlay.is-open .twc-nm-card {\n transform: translateY(0);\n }\n /* Panel mode: same blocking backdrop, docked to the right edge and\n full height instead of centred. Declared after the modal rules so\n the shared properties are overridden. */\n #twc-nm-overlay.twc-nm--panel {\n align-items: stretch;\n justify-content: flex-end;\n padding: 0;\n }\n #twc-nm-overlay.twc-nm--panel .twc-nm-card {\n width: 420px;\n max-width: 100%;\n max-height: none;\n border-radius: 0;\n box-shadow: -10px 0 40px rgba(0, 0, 0, 0.18);\n transform: translateX(100%);\n }\n /* Needs the extra class to beat both the .is-open rule above and the\n panel's own resting transform. */\n #twc-nm-overlay.twc-nm--panel.is-open .twc-nm-card {\n transform: translateX(0);\n }\n @media (max-width: 480px) {\n #twc-nm-overlay.twc-nm--panel .twc-nm-card {\n width: 100%;\n }\n }\n #twc-nm-overlay .twc-nm-close {\n position: absolute;\n top: 12px;\n right: 12px;\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n border: none;\n background: transparent;\n border-radius: 6px;\n font-size: 24px;\n line-height: 1;\n color: #6b7280;\n cursor: pointer;\n }\n #twc-nm-overlay .twc-nm-close:hover {\n background: #f3f4f6;\n color: #111827;\n }\n #twc-nm-overlay .twc-nm-title {\n margin: 0 32px 4px 0;\n font-size: 18px;\n font-weight: 600;\n }\n #twc-nm-overlay .twc-nm-text {\n margin: 0 0 16px;\n font-size: 14px;\n line-height: 1.5;\n color: #6b7280;\n }\n #twc-nm-overlay .twc-nm-form {\n display: flex;\n flex-direction: column;\n gap: 14px;\n }\n #twc-nm-overlay .twc-nm-field {\n display: flex;\n flex-direction: column;\n gap: 6px;\n }\n #twc-nm-overlay .twc-nm-label {\n font-size: 13px;\n font-weight: 500;\n color: #374151;\n }\n #twc-nm-overlay .twc-nm-input,\n #twc-nm-overlay .twc-nm-select {\n width: 100%;\n padding: 10px 12px;\n font-size: 14px;\n font-family: inherit;\n color: #111827;\n background: #fff;\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n }\n #twc-nm-overlay .twc-nm-input:focus,\n #twc-nm-overlay .twc-nm-select:focus {\n outline: none;\n border-color: #111827;\n box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);\n }\n #twc-nm-overlay .twc-nm-select {\n appearance: none;\n -webkit-appearance: none;\n padding-right: 36px;\n cursor: pointer;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\");\n background-repeat: no-repeat;\n background-position: right 12px center;\n }\n #twc-nm-overlay .twc-nm-checks {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n #twc-nm-overlay .twc-nm-check {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 13px;\n color: #374151;\n cursor: pointer;\n }\n #twc-nm-overlay .twc-nm-check input {\n width: 16px;\n height: 16px;\n margin: 0;\n accent-color: #111827;\n }\n #twc-nm-overlay .twc-nm-status {\n font-size: 13px;\n line-height: 1.5;\n padding: 10px 12px;\n border-radius: 8px;\n }\n #twc-nm-overlay .twc-nm-status--error {\n color: #b91c1c;\n background: #fef2f2;\n }\n #twc-nm-overlay .twc-nm-status--success {\n color: #15803d;\n background: #f0fdf4;\n }\n #twc-nm-overlay .twc-nm-submit {\n width: 100%;\n padding: 12px 16px;\n font-size: 14px;\n font-weight: 600;\n font-family: inherit;\n color: #fff;\n background: #111827;\n border: none;\n border-radius: 8px;\n cursor: pointer;\n transition: background 150ms ease;\n }\n #twc-nm-overlay .twc-nm-submit:hover {\n background: #374151;\n }\n #twc-nm-overlay .twc-nm-submit:disabled {\n opacity: 0.6;\n cursor: default;\n }\n #twc-nm-overlay .twc-nm-recs {\n margin-top: 20px;\n padding-top: 20px;\n border-top: 1px solid #e5e7eb;\n }\n #twc-nm-overlay .twc-nm-recs-title {\n margin: 0 0 12px;\n font-size: 14px;\n font-weight: 600;\n color: #111827;\n }\n #twc-nm-overlay .twc-nm-recs-row {\n display: flex;\n gap: 12px;\n overflow-x: auto;\n scroll-snap-type: x mandatory;\n -webkit-overflow-scrolling: touch;\n padding-bottom: 8px;\n scrollbar-width: thin;\n }\n #twc-nm-overlay .twc-nm-rec {\n flex: 0 0 132px;\n scroll-snap-align: start;\n display: flex;\n flex-direction: column;\n gap: 6px;\n color: inherit;\n text-decoration: none;\n }\n #twc-nm-overlay .twc-nm-rec:focus-visible {\n outline: 2px solid #111827;\n outline-offset: 2px;\n border-radius: 8px;\n }\n #twc-nm-overlay .twc-nm-rec-imgbox {\n aspect-ratio: 3 / 4;\n overflow: hidden;\n border-radius: 8px;\n background: #f3f4f6;\n }\n #twc-nm-overlay .twc-nm-rec-img {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: cover;\n transition: opacity 150ms ease;\n }\n #twc-nm-overlay .twc-nm-rec:hover .twc-nm-rec-img {\n opacity: 0.85;\n }\n #twc-nm-overlay .twc-nm-rec-name {\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n font-size: 13px;\n line-height: 1.35;\n color: #111827;\n }\n #twc-nm-overlay .twc-nm-rec-price {\n font-size: 13px;\n font-weight: 600;\n color: #111827;\n }\n #twc-nm-overlay .twc-nm-rec-was {\n margin-right: 4px;\n font-weight: 400;\n color: #9ca3af;\n }\n #twc-nm-overlay .twc-nm-rec--skeleton {\n pointer-events: none;\n }\n #twc-nm-overlay .twc-nm-skel {\n background-color: #f3f4f6;\n background-image: linear-gradient(\n 90deg,\n #f3f4f6 0%,\n #e8eaee 50%,\n #f3f4f6 100%\n );\n background-size: 200% 100%;\n border-radius: 4px;\n animation: twc-nm-shimmer 1.3s ease-in-out infinite;\n }\n #twc-nm-overlay .twc-nm-rec-imgbox.twc-nm-skel {\n border-radius: 8px;\n }\n #twc-nm-overlay .twc-nm-skel-line {\n height: 12px;\n width: 100%;\n }\n #twc-nm-overlay .twc-nm-skel-line--short {\n width: 45%;\n }\n @keyframes twc-nm-shimmer {\n from {\n background-position: 200% 0;\n }\n to {\n background-position: -200% 0;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n #twc-nm-overlay,\n #twc-nm-overlay .twc-nm-card,\n #twc-nm-overlay .twc-nm-rec-img {\n transition: none;\n }\n #twc-nm-overlay .twc-nm-card,\n #twc-nm-overlay.twc-nm--panel .twc-nm-card {\n transform: none;\n }\n #twc-nm-overlay .twc-nm-skel {\n animation: none;\n }\n }\n ",document.head.appendChild(e)}();const t=JSON.parse(n.getAttribute("data-fields")||'["email"]'),o=n.getAttribute("data-type")||"notify-me",a="panel"===n.getAttribute("data-display")?"panel":"modal",c=n.getAttribute("data-auth")||"token",i=n.getAttribute("data-tenant")||"victoria-woods",r=n.getAttribute("data-proxy-app")||"twc-sdk",d="false"!==n.getAttribute("data-recommendations"),m=parseInt(n.getAttribute("data-recommendations-count")||"",10),s=Number.isFinite(m)&&m>0?m:8,l=n.getAttribute("data-currency")||null,u=function(){var e,n;const t={countryCode:null,provinceCode:null,marketId:null},o=window.Shopify;if(o){"string"==typeof o.country&&(t.countryCode=o.country);const n=null===(e=o.markets)||void 0===e?void 0:e.currentMarket;if(n&&(n.countryCode&&(t.countryCode=n.countryCode),null!=n.id&&(t.marketId=String(n.id))),!t.countryCode&&"string"==typeof o.locale){const e=o.locale.split("-");e.length>1&&(t.countryCode=e[e.length-1].toUpperCase())}}if(!t.countryCode||!t.provinceCode){const e=null===(n=window.customer)||void 0===n?void 0:n.default_address;e&&(!t.countryCode&&e.country_code&&(t.countryCode=e.country_code),!t.provinceCode&&e.province_code&&(t.provinceCode=e.province_code))}if(!t.countryCode){const e=(navigator.language||"").split("-");e.length>1&&(t.countryCode=e[e.length-1].toUpperCase())}return t}(),p=n.getAttribute("data-market-id")||u.marketId;x({wrapper:e,openButton:n,config:{fields:t,type:o,display:a,authMode:c,tenant:i,proxyApp:r,marketId:p,recommendationsEnabled:d,recommendationsCount:s,currency:l,customerEmail:C(n)},productData:window.currentProduct,countryCtx:u})})}();
1
+ !function(){"use strict";const e=[{code:"AF",name:"Afghanistan"},{code:"AX",name:"Åland Islands"},{code:"AL",name:"Albania"},{code:"DZ",name:"Algeria"},{code:"AS",name:"American Samoa"},{code:"AD",name:"Andorra"},{code:"AO",name:"Angola"},{code:"AI",name:"Anguilla"},{code:"AG",name:"Antigua and Barbuda"},{code:"AR",name:"Argentina"},{code:"AM",name:"Armenia"},{code:"AW",name:"Aruba"},{code:"AU",name:"Australia"},{code:"AT",name:"Austria"},{code:"AZ",name:"Azerbaijan"},{code:"BS",name:"Bahamas"},{code:"BH",name:"Bahrain"},{code:"BD",name:"Bangladesh"},{code:"BB",name:"Barbados"},{code:"BY",name:"Belarus"},{code:"BE",name:"Belgium"},{code:"BZ",name:"Belize"},{code:"BJ",name:"Benin"},{code:"BM",name:"Bermuda"},{code:"BT",name:"Bhutan"},{code:"BO",name:"Bolivia"},{code:"BA",name:"Bosnia and Herzegovina"},{code:"BW",name:"Botswana"},{code:"BR",name:"Brazil"},{code:"BN",name:"Brunei"},{code:"BG",name:"Bulgaria"},{code:"BF",name:"Burkina Faso"},{code:"BI",name:"Burundi"},{code:"CV",name:"Cabo Verde"},{code:"KH",name:"Cambodia"},{code:"CM",name:"Cameroon"},{code:"CA",name:"Canada"},{code:"KY",name:"Cayman Islands"},{code:"CF",name:"Central African Republic"},{code:"TD",name:"Chad"},{code:"CL",name:"Chile"},{code:"CN",name:"China"},{code:"CO",name:"Colombia"},{code:"KM",name:"Comoros"},{code:"CG",name:"Congo"},{code:"CD",name:"Congo, DR"},{code:"CK",name:"Cook Islands"},{code:"CR",name:"Costa Rica"},{code:"HR",name:"Croatia"},{code:"CU",name:"Cuba"},{code:"CW",name:"Curaçao"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czech Republic"},{code:"DK",name:"Denmark"},{code:"DJ",name:"Djibouti"},{code:"DM",name:"Dominica"},{code:"DO",name:"Dominican Republic"},{code:"EC",name:"Ecuador"},{code:"EG",name:"Egypt"},{code:"SV",name:"El Salvador"},{code:"GQ",name:"Equatorial Guinea"},{code:"ER",name:"Eritrea"},{code:"EE",name:"Estonia"},{code:"SZ",name:"Eswatini"},{code:"ET",name:"Ethiopia"},{code:"FO",name:"Faroe Islands"},{code:"FJ",name:"Fiji"},{code:"FI",name:"Finland"},{code:"FR",name:"France"},{code:"GF",name:"French Guiana"},{code:"PF",name:"French Polynesia"},{code:"GA",name:"Gabon"},{code:"GM",name:"Gambia"},{code:"GE",name:"Georgia"},{code:"DE",name:"Germany"},{code:"GH",name:"Ghana"},{code:"GI",name:"Gibraltar"},{code:"GR",name:"Greece"},{code:"GL",name:"Greenland"},{code:"GD",name:"Grenada"},{code:"GP",name:"Guadeloupe"},{code:"GU",name:"Guam"},{code:"GT",name:"Guatemala"},{code:"GN",name:"Guinea"},{code:"GW",name:"Guinea-Bissau"},{code:"GY",name:"Guyana"},{code:"HT",name:"Haiti"},{code:"HN",name:"Honduras"},{code:"HK",name:"Hong Kong"},{code:"HU",name:"Hungary"},{code:"IS",name:"Iceland"},{code:"IN",name:"India"},{code:"ID",name:"Indonesia"},{code:"IR",name:"Iran"},{code:"IQ",name:"Iraq"},{code:"IE",name:"Ireland"},{code:"IM",name:"Isle of Man"},{code:"IL",name:"Israel"},{code:"IT",name:"Italy"},{code:"JM",name:"Jamaica"},{code:"JP",name:"Japan"},{code:"JE",name:"Jersey"},{code:"JO",name:"Jordan"},{code:"KZ",name:"Kazakhstan"},{code:"KE",name:"Kenya"},{code:"KI",name:"Kiribati"},{code:"KR",name:"Korea, South"},{code:"XK",name:"Kosovo"},{code:"KW",name:"Kuwait"},{code:"KG",name:"Kyrgyzstan"},{code:"LA",name:"Laos"},{code:"LV",name:"Latvia"},{code:"LB",name:"Lebanon"},{code:"LS",name:"Lesotho"},{code:"LR",name:"Liberia"},{code:"LY",name:"Libya"},{code:"LI",name:"Liechtenstein"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"MO",name:"Macao"},{code:"MG",name:"Madagascar"},{code:"MW",name:"Malawi"},{code:"MY",name:"Malaysia"},{code:"MV",name:"Maldives"},{code:"ML",name:"Mali"},{code:"MT",name:"Malta"},{code:"MH",name:"Marshall Islands"},{code:"MQ",name:"Martinique"},{code:"MR",name:"Mauritania"},{code:"MU",name:"Mauritius"},{code:"MX",name:"Mexico"},{code:"FM",name:"Micronesia"},{code:"MD",name:"Moldova"},{code:"MC",name:"Monaco"},{code:"MN",name:"Mongolia"},{code:"ME",name:"Montenegro"},{code:"MS",name:"Montserrat"},{code:"MA",name:"Morocco"},{code:"MZ",name:"Mozambique"},{code:"MM",name:"Myanmar"},{code:"NA",name:"Namibia"},{code:"NR",name:"Nauru"},{code:"NP",name:"Nepal"},{code:"NL",name:"Netherlands"},{code:"NC",name:"New Caledonia"},{code:"NZ",name:"New Zealand"},{code:"NI",name:"Nicaragua"},{code:"NE",name:"Niger"},{code:"NG",name:"Nigeria"},{code:"NU",name:"Niue"},{code:"MK",name:"North Macedonia"},{code:"NO",name:"Norway"},{code:"OM",name:"Oman"},{code:"PK",name:"Pakistan"},{code:"PW",name:"Palau"},{code:"PS",name:"Palestine"},{code:"PA",name:"Panama"},{code:"PG",name:"Papua New Guinea"},{code:"PY",name:"Paraguay"},{code:"PE",name:"Peru"},{code:"PH",name:"Philippines"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"PR",name:"Puerto Rico"},{code:"QA",name:"Qatar"},{code:"RE",name:"Réunion"},{code:"RO",name:"Romania"},{code:"RW",name:"Rwanda"},{code:"KN",name:"Saint Kitts and Nevis"},{code:"LC",name:"Saint Lucia"},{code:"VC",name:"Saint Vincent and the Grenadines"},{code:"WS",name:"Samoa"},{code:"SM",name:"San Marino"},{code:"SA",name:"Saudi Arabia"},{code:"SN",name:"Senegal"},{code:"RS",name:"Serbia"},{code:"SC",name:"Seychelles"},{code:"SL",name:"Sierra Leone"},{code:"SG",name:"Singapore"},{code:"SK",name:"Slovakia"},{code:"SI",name:"Slovenia"},{code:"SB",name:"Solomon Islands"},{code:"SO",name:"Somalia"},{code:"ZA",name:"South Africa"},{code:"SS",name:"South Sudan"},{code:"ES",name:"Spain"},{code:"LK",name:"Sri Lanka"},{code:"SD",name:"Sudan"},{code:"SR",name:"Suriname"},{code:"SE",name:"Sweden"},{code:"CH",name:"Switzerland"},{code:"SY",name:"Syria"},{code:"TW",name:"Taiwan"},{code:"TJ",name:"Tajikistan"},{code:"TZ",name:"Tanzania"},{code:"TH",name:"Thailand"},{code:"TL",name:"Timor-Leste"},{code:"TG",name:"Togo"},{code:"TO",name:"Tonga"},{code:"TT",name:"Trinidad and Tobago"},{code:"TN",name:"Tunisia"},{code:"TR",name:"Turkey"},{code:"TM",name:"Turkmenistan"},{code:"TC",name:"Turks and Caicos Islands"},{code:"TV",name:"Tuvalu"},{code:"UG",name:"Uganda"},{code:"UA",name:"Ukraine"},{code:"AE",name:"United Arab Emirates"},{code:"GB",name:"United Kingdom"},{code:"US",name:"United States"},{code:"UY",name:"Uruguay"},{code:"UZ",name:"Uzbekistan"},{code:"VU",name:"Vanuatu"},{code:"VE",name:"Venezuela"},{code:"VN",name:"Vietnam"},{code:"VG",name:"Virgin Islands, British"},{code:"VI",name:"Virgin Islands, U.S."},{code:"YE",name:"Yemen"},{code:"ZM",name:"Zambia"},{code:"ZW",name:"Zimbabwe"}];let n=null;async function t(e){if("proxy"===e.mode){const t=await async function(e){if(n)return n;try{const t=await fetch(`/apps/${e}/auth/token`,{method:"GET",headers:{Accept:"application/json"}}),o=await t.json().catch(()=>null);return t.ok&&o&&o.success&&o.data&&o.data.access_token?(n=o.data.access_token,n):null}catch(e){return console.error("Error fetching proxy access token:",e),null}}(e.proxyApp);return t?`Bearer ${t}`:null}return e.accessToken?/^Bearer /i.test(e.accessToken)?e.accessToken:`Bearer ${e.accessToken}`:(console.error('notify-me-wl: data-auth="token" requires an access token. Set data-access-token on the open button or window.TWC_ACCESS_TOKEN, or use data-auth="proxy" to obtain one via the Shopify App Proxy.'),null)}const o=new Map;function a(e){return"string"==typeof e?e.trim():""}async function c(e,n){const c=o.get(e);if(void 0!==c)return c;const r=await t(n);if(!r)return null;try{const n=await fetch("https://api.au-aws.thewishlist.io/services/eventcollector/api/v1/custom/configs/public",{method:"GET",headers:{Accept:"application/json",Authorization:r,"X-Twc-Tenant":e}});if(!n.ok)return console.error("Tenant config request failed:",n.status),null;const t=function(e){if(!e||"object"!=typeof e)return null;const n=e.websiteRecommendations;if(!n||"object"!=typeof n)return null;const t=a(n.engine).toUpperCase();if("TWC"===t)return{engine:"TWC"};if("ATHOS"===t){const e=a(n.siteIdentifier);return e?{engine:"ATHOS",siteIdentifier:e,profileTag:a(n.profileTag)||a(n.tags)||"similar"}:null}return null}(await n.json().catch(()=>null));return o.set(e,t),t}catch(e){return console.error("Error fetching tenant config:",e),null}}function r(e){return"string"==typeof e?e.trim():""}function i(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){const n=parseFloat(e);if(Number.isFinite(n))return n}return null}function d(e){return Boolean(e.name&&e.imageUrl&&e.productUrl)}function m(e,n){const t=new Map;return e.forEach(e=>{const n=t.get(e.product.ref);n&&n.score>=e.score||t.set(e.product.ref,e)}),Array.from(t.values()).sort((e,n)=>n.score-e.score).slice(0,n).map(e=>e.product)}async function s(e){const{email:n,tenant:o,auth:a,count:c}=e,s=await t(a);if(!s)return null;const l=Math.min(3*c,20),u=`https://api.au-aws.thewishlist.io/services/recommendations/api/v1/recommendations/${encodeURIComponent(o)}/${encodeURIComponent(n)}?n=${l}`;try{const e=await fetch(u,{method:"GET",headers:{Accept:"application/json",Authorization:s,"X-Twc-Tenant":o}});if(!e.ok)return console.error("Recommendations request failed:",e.status),null;return function(e,n){const t=e&&e.recommendations;if(!Array.isArray(t))return[];const o=[];return t.forEach(e=>{var n;const t=e&&e.product;if(!t)return;const a=r(t.name),c=r(t.image_url),m=r(t.product_url);if(!d({name:a,imageUrl:c,productUrl:m}))return;const s=r(t.product_ref)||r(t.product_id)||m;o.push({score:"number"==typeof e.score?e.score:0,product:{id:r(t.product_id)||s,ref:s,name:a,imageUrl:c,productUrl:m,price:null!==(n=i(t.price))&&void 0!==n?n:0,originalPrice:i(t.original_price)}})}),m(o,n)}(await e.json().catch(()=>null),c)}catch(e){return console.error("Error fetching recommendations:",e),null}}async function l(e){const{engine:n,email:t,count:o,productId:a}=e,c=encodeURIComponent(n.siteIdentifier),s=[`tags=${encodeURIComponent(n.profileTag)}`,`limits=${o}`];a&&s.push(`products=${encodeURIComponent(a)}`),t&&s.push(`shopper=${encodeURIComponent(t)}`);const l=`https://${c}.a.searchspring.io/boost/${c}/recommend?`+s.join("&");try{const e=await fetch(l,{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)return console.error("Athos recommendations request failed:",e.status),null;return function(e,n){const t=Array.isArray(e)?e[0]:e,o=t&&t.results;if(!Array.isArray(o))return[];const a=[];return o.forEach((e,n)=>{var t;const c=e&&e.mappings&&e.mappings.core;if(!c)return;const m=r(c.name),s=r(c.imageUrl)||r(c.thumbnailImageUrl),l=r(c.url);if(!d({name:m,imageUrl:s,productUrl:l}))return;const u=r(c.uid)||r(c.sku)||l,p=null!==(t=i(c.price))&&void 0!==t?t:0,w=i(c.msrp);a.push({score:o.length-n,product:{id:r(c.uid)||u,ref:u,name:m,imageUrl:s,productUrl:l,price:p,originalPrice:null!==w&&w>p?w:null}})}),m(a,n)}(await e.json().catch(()=>null),o)}catch(e){return console.error("Error fetching Athos recommendations:",e),null}}const u=new Map;const p="twc-nm-recs",w="twc-nm-recs-title";function f(e,n){if(n)try{return new Intl.NumberFormat(void 0,{style:"currency",currency:n}).format(e)}catch(e){}return new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}function h(){const e=document.createElement("div");e.className="twc-nm-rec twc-nm-rec--skeleton",e.setAttribute("aria-hidden","true");const n=document.createElement("div");n.className="twc-nm-rec-imgbox twc-nm-skel",e.appendChild(n);const t=document.createElement("span");t.className="twc-nm-skel twc-nm-skel-line",e.appendChild(t);const o=document.createElement("span");return o.className="twc-nm-skel twc-nm-skel-line twc-nm-skel-line--short",e.appendChild(o),e}function y(e){const{section:n,row:t}=function(){const e=document.createElement("section");e.id=p,e.className="twc-nm-recs",e.setAttribute("aria-labelledby",w);const n=document.createElement("h3");n.id=w,n.className="twc-nm-recs-title",n.textContent="Shop similar styles",e.appendChild(n);const t=document.createElement("div");return t.className="twc-nm-recs-row",e.appendChild(t),{section:e,row:t}}();n.classList.add("twc-nm-recs--loading"),n.setAttribute("aria-busy","true");for(let n=0;n<e;n++)t.appendChild(h());return n}function g(e,n,t){const o=e.querySelector(".twc-nm-recs-row");if(!o)return;const a=(c=t,window.Shopify&&window.Shopify.currency&&window.Shopify.currency.active||c||null);var c;const r=document.createDocumentFragment();n.forEach(e=>{r.appendChild(function(e,n){const t=document.createElement("a");t.className="twc-nm-rec",t.href=e.productUrl,t.target="_blank",t.rel="noopener noreferrer";const o=document.createElement("div");o.className="twc-nm-rec-imgbox";const a=document.createElement("img");a.className="twc-nm-rec-img",a.src=e.imageUrl,a.alt=e.name,a.loading="lazy",a.decoding="async",o.appendChild(a),t.appendChild(o);const c=document.createElement("span");c.className="twc-nm-rec-name",c.textContent=e.name,t.appendChild(c);const r=document.createElement("span");if(r.className="twc-nm-rec-price",null!==e.originalPrice&&e.originalPrice>e.price){const t=document.createElement("s");t.className="twc-nm-rec-was",t.textContent=f(e.originalPrice,n),r.appendChild(t),r.appendChild(document.createTextNode(" "))}return r.appendChild(document.createTextNode(f(e.price,n))),t.appendChild(r),t}(e,a))}),o.textContent="",o.appendChild(r),e.classList.remove("twc-nm-recs--loading"),e.removeAttribute("aria-busy")}function b(){const e=document.getElementById(p);e&&e.parentNode&&e.parentNode.removeChild(e)}const v={"notify-me":{text:"Register to receive a notification as soon as this item is back in stock",buttonText:"Notify Me"},"coming-soon":{text:"Register your interest to hear more about this item",buttonText:"Register Interest"}};function x(n){const{wrapper:o,openButton:a,config:r,productData:i,localization:d}=n,{fields:m,type:w,display:f,auth:h,tenant:x,recommendationsEnabled:C,recommendationsCount:k,currency:S,customerEmail:E}=r,A=document.createElement("div");A.innerHTML='\n <div id="twc-nm-overlay" role="dialog" aria-modal="true" aria-labelledby="popup-title">\n <div class="twc-nm-card">\n <button type="button" id="popup-close" class="twc-nm-close" aria-label="Close">&times;</button>\n <h2 id="popup-title" class="twc-nm-title"></h2>\n <p id="popup-text" class="twc-nm-text"></p>\n <form id="popup-form" class="twc-nm-form">\n <div class="twc-nm-field">\n <label class="twc-nm-label" for="twc-nm-size">Size</label>\n <select class="twc-nm-select" id="twc-nm-size" name="select-size" required>\n <option value="" disabled selected>Select a size</option>\n </select>\n </div>\n </form>\n </div>\n </div>\n ',o.appendChild(A);const T=document.getElementById("twc-nm-overlay"),M=document.getElementById("popup-close"),N=document.getElementById("popup-title"),I=document.getElementById("popup-text"),B=document.querySelector("select[name='select-size']"),L=document.getElementById("popup-form");if(!(T&&M&&N&&I&&B&&L))return;"panel"===f&&T.classList.add("twc-nm--panel"),I.innerText=v[w].text;const G=e.map(e=>`<option value="${e.code}"${e.code===d.countryCode?" selected":""}>${e.name}</option>`).join(""),P=(e,n,t)=>`<div class="twc-nm-field"><label class="twc-nm-label" for="${e}">${n}</label>${t}</div>`,U={email:P("twc-nm-email","Email",'<input class="twc-nm-input" id="twc-nm-email" name="email" type="email" placeholder="you@example.com" required />'),mobile:P("twc-nm-mobile","Mobile",'<input class="twc-nm-input" id="twc-nm-mobile" name="mobile" type="tel" placeholder="Mobile number" required />'),firstName:P("twc-nm-firstname","First name",'<input class="twc-nm-input" id="twc-nm-firstname" name="firstName" type="text" placeholder="First name" required />'),lastName:P("twc-nm-lastname","Last name",'<input class="twc-nm-input" id="twc-nm-lastname" name="lastName" type="text" placeholder="Last name" required />'),countryCode:P("twc-nm-country","Country",`<select class="twc-nm-select" id="twc-nm-country" name="countryCode"><option value="">Select country</option>${G}</select>`),provinceCode:P("twc-nm-province","State / Province",`<input class="twc-nm-input" id="twc-nm-province" name="provinceCode" type="text" placeholder="State / province code" value="${d.provinceCode||""}" />`)};m.forEach(e=>{U[e]&&L.insertAdjacentHTML("beforeend",U[e])}),L.insertAdjacentHTML("beforeend",'<div class="twc-nm-checks">\n <label class="twc-nm-check"><input type="checkbox" name="mailList" /> Email me store updates</label>\n <label class="twc-nm-check"><input type="checkbox" name="mailListSms" /> Text me store updates</label>\n </div>'),L.insertAdjacentHTML("beforeend",'<div id="popup-status" class="twc-nm-status" role="status" aria-live="polite" hidden></div>'),L.insertAdjacentHTML("beforeend",`<button type="submit" class="twc-nm-submit">${v[w].buttonText}</button>`);const z=document.getElementById("popup-status"),R=L.querySelector(".twc-nm-submit");if(!z||!R)return;function K(e,n){z.textContent=n,z.className=`twc-nm-status twc-nm-status--${e}`,z.hidden=!1}function $(){z.hidden=!0,z.textContent=""}const H=e=>{const n=L.querySelector(e);return n?n.value:""},F=e=>{const n=L.querySelector(e);return!!n&&n.checked},D=T.querySelector(".twc-nm-card");let j=null;async function O(e){const n=await function(e,n){return c(e,n)}(x,h);if(!n)return!1;if(!T.classList.contains("is-open"))return!1;const t=y(k);D.appendChild(t);const o=await async function(e,n){const{email:t,tenant:o,auth:a,count:c,productId:r}=n,i=`${e.engine}|${o}|${t}|${c}|${r||""}`,d=u.get(i);if(d)return d;let m=null;return m="ATHOS"===e.engine?await l({engine:e,email:t,count:c,productId:r}):await s({email:t,tenant:o,auth:a,count:c}),null===m?[]:(u.set(i,m),m)}(n,{email:e,tenant:x,auth:h,count:k,productId:i?String(i.id):null});return!!t.isConnected&&(o.length?(g(t,o,S),!0):(b(),!1))}function q(e){if(!C||!D)return Promise.resolve(!1);if(j)return j;if(document.getElementById(p))return Promise.resolve(!0);const n=O(e);return j=n,n.then(e=>(j===n&&(j=null),e),e=>(j===n&&(j=null),console.error("Error rendering recommendations:",e),!1))}let _=!1,V=null;function W(e){"Escape"===e.key&&Z()}function Z(){T.classList.remove("is-open"),document.body.style.overflow="",document.removeEventListener("keydown",W),$(),b(),j=null,V&&"function"==typeof V.focus&&V.focus()}a.addEventListener("click",function(){if(V=document.activeElement,T.classList.add("is-open"),document.body.style.overflow="hidden",document.addEventListener("keydown",W),!i)return L.hidden=!0,void K("error","Product information is unavailable. Please refresh the page.");N.textContent=i.title,_||((i.variants||[]).forEach(e=>{const n=document.createElement("option");n.value=e.title,n.textContent=e.title,B.appendChild(n)}),_=!0),E&&q(E);const e=L.querySelector("select, input");e&&e.focus()}),M.addEventListener("click",Z),T.addEventListener("click",e=>{e.target===T&&Z()}),L.addEventListener("submit",async e=>{e.preventDefault();const n=((null==i?void 0:i.variants)||[]).find(e=>e.title===B.value);if(!n)return void K("error","Please select a size.");const o={variantRef:n.id,email:H("input[name='email']"),subscribe:F("input[name='mailList']"),subscribeSms:F("input[name='mailListSms']")};if("coming-soon"===w?o.comingSoon=!0:o.notifyMe=!0,m.includes("firstName")&&(o.firstName=H("input[name='firstName']")),m.includes("lastName")&&(o.lastName=H("input[name='lastName']")),m.includes("mobile")&&(o.mobile=H("input[name='mobile']")),m.includes("countryCode")){const e=H("select[name='countryCode']");e&&(o.countryCode=e)}else d.countryCode&&(o.countryCode=d.countryCode);if(m.includes("provinceCode")){const e=H("input[name='provinceCode']");e&&(o.provinceCode=e)}else d.provinceCode&&(o.provinceCode=d.provinceCode);d.marketId&&(o.marketId=d.marketId),d.marketHandle&&(o.marketHandle=d.marketHandle),$();const a=R.textContent||"";R.disabled=!0,R.textContent="Sending…";let c={ok:!1,reason:"error"};try{c=await async function(e,n,o){const a=await t(n);if(!a)return{ok:!1,reason:"auth"};try{return(await fetch("https://api.au-aws.thewishlist.io/services/wsservice/api/wishlist/items/customerInterest",{method:"POST",headers:{"Content-Type":"application/json",Authorization:a,"X-Twc-Tenant":o},body:JSON.stringify(e)})).ok?{ok:!0}:{ok:!1,reason:"error"}}catch(e){return console.error("Error submitting form:",e),{ok:!1,reason:"error"}}}(o,h,x)}finally{R.disabled=!1,R.textContent=a}if(c.ok){K("success","You're on the list. We'll be in touch.");const e=E||H("input[name='email']");!!e&&await q(e)||setTimeout(Z,1500)}else"auth"===c.reason?K("error","proxy"===h.mode?"Please log in to your account to continue.":"Something went wrong. Please try again."):K("error","Something went wrong. Please try again.")})}function C(e){var n;const t=(null!=e?e:"").trim();if(!t)return null;const o=null!==(n=t.split("?")[0].split("/").pop())&&void 0!==n?n:"";return/^\d+$/.test(o)?o:null}function k(e){const n=(null!=e?e:"").trim();return/^[a-z0-9_-]+$/i.test(n)?n:null}function S(e){const n=(null!=e?e:"").trim();return/^[a-z]{2}$/i.test(n)?n.toUpperCase():null}function E(e){const n=e.getAttribute("data-customer-email");if(n&&n.trim())return n.trim();const t=window.customer&&window.customer.email;return t&&t.trim()?t.trim():null}document.addEventListener("DOMContentLoaded",()=>{const e=document.getElementById("notification-widget");if(!e)return;const n=document.getElementById("popup-open");if(!n)return;!function(){const e=document.createElement("style");e.type="text/css",e.innerText="\n .notification-btn {\n display: inline-block;\n width: 100%;\n padding: 12px 24px;\n background: #fff;\n border: 1px solid #111827;\n border-radius: 8px;\n color: #111827;\n font: inherit;\n text-align: center;\n text-transform: uppercase;\n cursor: pointer;\n }\n .notification-btn:hover {\n background: #111827;\n color: #fff;\n }\n #twc-nm-overlay {\n position: fixed;\n inset: 0;\n z-index: 99999;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 16px;\n background: rgba(17, 17, 17, 0.55);\n opacity: 0;\n visibility: hidden;\n transition: opacity 200ms ease;\n }\n #twc-nm-overlay.is-open {\n opacity: 1;\n visibility: visible;\n }\n #twc-nm-overlay * {\n box-sizing: border-box;\n }\n #twc-nm-overlay .twc-nm-card {\n position: relative;\n width: 100%;\n max-width: 400px;\n max-height: calc(100vh - 32px);\n overflow-y: auto;\n padding: 24px;\n background: #fff;\n color: #111827;\n border-radius: 12px;\n box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);\n font: inherit;\n transform: translateY(8px);\n transition: transform 200ms ease;\n }\n #twc-nm-overlay.is-open .twc-nm-card {\n transform: translateY(0);\n }\n /* Panel mode: same blocking backdrop, docked to the right edge and\n full height instead of centred. Declared after the modal rules so\n the shared properties are overridden. */\n #twc-nm-overlay.twc-nm--panel {\n align-items: stretch;\n justify-content: flex-end;\n padding: 0;\n }\n #twc-nm-overlay.twc-nm--panel .twc-nm-card {\n width: 420px;\n max-width: 100%;\n max-height: none;\n border-radius: 0;\n box-shadow: -10px 0 40px rgba(0, 0, 0, 0.18);\n transform: translateX(100%);\n }\n /* Needs the extra class to beat both the .is-open rule above and the\n panel's own resting transform. */\n #twc-nm-overlay.twc-nm--panel.is-open .twc-nm-card {\n transform: translateX(0);\n }\n @media (max-width: 480px) {\n #twc-nm-overlay.twc-nm--panel .twc-nm-card {\n width: 100%;\n }\n }\n #twc-nm-overlay .twc-nm-close {\n position: absolute;\n top: 12px;\n right: 12px;\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n border: none;\n background: transparent;\n border-radius: 6px;\n font-size: 24px;\n line-height: 1;\n color: #6b7280;\n cursor: pointer;\n }\n #twc-nm-overlay .twc-nm-close:hover {\n background: #f3f4f6;\n color: #111827;\n }\n #twc-nm-overlay .twc-nm-title {\n margin: 0 32px 4px 0;\n font-size: 18px;\n font-weight: 600;\n }\n #twc-nm-overlay .twc-nm-text {\n margin: 0 0 16px;\n font-size: 14px;\n line-height: 1.5;\n color: #6b7280;\n }\n #twc-nm-overlay .twc-nm-form {\n display: flex;\n flex-direction: column;\n gap: 14px;\n }\n #twc-nm-overlay .twc-nm-field {\n display: flex;\n flex-direction: column;\n gap: 6px;\n }\n #twc-nm-overlay .twc-nm-label {\n font-size: 13px;\n font-weight: 500;\n color: #374151;\n }\n #twc-nm-overlay .twc-nm-input,\n #twc-nm-overlay .twc-nm-select {\n width: 100%;\n padding: 10px 12px;\n font-size: 14px;\n font-family: inherit;\n color: #111827;\n background: #fff;\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n }\n #twc-nm-overlay .twc-nm-input:focus,\n #twc-nm-overlay .twc-nm-select:focus {\n outline: none;\n border-color: #111827;\n box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);\n }\n #twc-nm-overlay .twc-nm-select {\n appearance: none;\n -webkit-appearance: none;\n padding-right: 36px;\n cursor: pointer;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\");\n background-repeat: no-repeat;\n background-position: right 12px center;\n }\n #twc-nm-overlay .twc-nm-checks {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n #twc-nm-overlay .twc-nm-check {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 13px;\n color: #374151;\n cursor: pointer;\n }\n #twc-nm-overlay .twc-nm-check input {\n width: 16px;\n height: 16px;\n margin: 0;\n accent-color: #111827;\n }\n #twc-nm-overlay .twc-nm-status {\n font-size: 13px;\n line-height: 1.5;\n padding: 10px 12px;\n border-radius: 8px;\n }\n #twc-nm-overlay .twc-nm-status--error {\n color: #b91c1c;\n background: #fef2f2;\n }\n #twc-nm-overlay .twc-nm-status--success {\n color: #15803d;\n background: #f0fdf4;\n }\n #twc-nm-overlay .twc-nm-submit {\n width: 100%;\n padding: 12px 16px;\n font-size: 14px;\n font-weight: 600;\n font-family: inherit;\n color: #fff;\n background: #111827;\n border: none;\n border-radius: 8px;\n cursor: pointer;\n transition: background 150ms ease;\n }\n #twc-nm-overlay .twc-nm-submit:hover {\n background: #374151;\n }\n #twc-nm-overlay .twc-nm-submit:disabled {\n opacity: 0.6;\n cursor: default;\n }\n #twc-nm-overlay .twc-nm-recs {\n margin-top: 20px;\n padding-top: 20px;\n border-top: 1px solid #e5e7eb;\n }\n #twc-nm-overlay .twc-nm-recs-title {\n margin: 0 0 12px;\n font-size: 14px;\n font-weight: 600;\n color: #111827;\n }\n #twc-nm-overlay .twc-nm-recs-row {\n display: flex;\n gap: 12px;\n overflow-x: auto;\n scroll-snap-type: x mandatory;\n -webkit-overflow-scrolling: touch;\n padding-bottom: 8px;\n scrollbar-width: thin;\n }\n #twc-nm-overlay .twc-nm-rec {\n flex: 0 0 132px;\n scroll-snap-align: start;\n display: flex;\n flex-direction: column;\n gap: 6px;\n color: inherit;\n text-decoration: none;\n }\n #twc-nm-overlay .twc-nm-rec:focus-visible {\n outline: 2px solid #111827;\n outline-offset: 2px;\n border-radius: 8px;\n }\n #twc-nm-overlay .twc-nm-rec-imgbox {\n aspect-ratio: 3 / 4;\n overflow: hidden;\n border-radius: 8px;\n background: #f3f4f6;\n }\n #twc-nm-overlay .twc-nm-rec-img {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: cover;\n transition: opacity 150ms ease;\n }\n #twc-nm-overlay .twc-nm-rec:hover .twc-nm-rec-img {\n opacity: 0.85;\n }\n #twc-nm-overlay .twc-nm-rec-name {\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n font-size: 13px;\n line-height: 1.35;\n color: #111827;\n }\n #twc-nm-overlay .twc-nm-rec-price {\n font-size: 13px;\n font-weight: 600;\n color: #111827;\n }\n #twc-nm-overlay .twc-nm-rec-was {\n margin-right: 4px;\n font-weight: 400;\n color: #9ca3af;\n }\n #twc-nm-overlay .twc-nm-rec--skeleton {\n pointer-events: none;\n }\n #twc-nm-overlay .twc-nm-skel {\n background-color: #f3f4f6;\n background-image: linear-gradient(\n 90deg,\n #f3f4f6 0%,\n #e8eaee 50%,\n #f3f4f6 100%\n );\n background-size: 200% 100%;\n border-radius: 4px;\n animation: twc-nm-shimmer 1.3s ease-in-out infinite;\n }\n #twc-nm-overlay .twc-nm-rec-imgbox.twc-nm-skel {\n border-radius: 8px;\n }\n #twc-nm-overlay .twc-nm-skel-line {\n height: 12px;\n width: 100%;\n }\n #twc-nm-overlay .twc-nm-skel-line--short {\n width: 45%;\n }\n @keyframes twc-nm-shimmer {\n from {\n background-position: 200% 0;\n }\n to {\n background-position: -200% 0;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n #twc-nm-overlay,\n #twc-nm-overlay .twc-nm-card,\n #twc-nm-overlay .twc-nm-rec-img {\n transition: none;\n }\n #twc-nm-overlay .twc-nm-card,\n #twc-nm-overlay.twc-nm--panel .twc-nm-card {\n transform: none;\n }\n #twc-nm-overlay .twc-nm-skel {\n animation: none;\n }\n }\n ",document.head.appendChild(e)}();const t=JSON.parse(n.getAttribute("data-fields")||'["email"]'),o=n.getAttribute("data-type")||"notify-me",a="panel"===n.getAttribute("data-display")?"panel":"modal",c=n.getAttribute("data-auth")||"proxy",r=n.getAttribute("data-tenant")||"victoria-woods",i=n.getAttribute("data-proxy-app")||"twc-sdk",d=n.getAttribute("data-access-token")||window.TWC_ACCESS_TOKEN||null,m="false"!==n.getAttribute("data-recommendations"),s=parseInt(n.getAttribute("data-recommendations-count")||"",10),l=Number.isFinite(s)&&s>0?s:8,u=n.getAttribute("data-currency")||null,p=function(e){var n,t,o;const a={countryCode:S(e.getAttribute("data-country-code")),provinceCode:null,marketId:C(e.getAttribute("data-market-id")),marketHandle:k(e.getAttribute("data-market-handle"))},c=window.Shopify;if(c){const e=null===(n=c.markets)||void 0===n?void 0:n.currentMarket;if(e&&(!a.countryCode&&e.countryCode&&(a.countryCode=e.countryCode),a.marketId||(a.marketId=C(String(null!==(t=e.id)&&void 0!==t?t:"")))),a.countryCode||"string"!=typeof c.country||(a.countryCode=c.country),!a.countryCode&&"string"==typeof c.locale){const e=c.locale.split("-");e.length>1&&(a.countryCode=e[e.length-1].toUpperCase())}}if(!a.countryCode||!a.provinceCode){const e=null===(o=window.customer)||void 0===o?void 0:o.default_address;e&&(!a.countryCode&&e.country_code&&(a.countryCode=e.country_code),!a.provinceCode&&e.province_code&&(a.provinceCode=e.province_code))}if(!a.countryCode){const e=(navigator.language||"").split("-");e.length>1&&(a.countryCode=e[e.length-1].toUpperCase())}return a}(n);x({wrapper:e,openButton:n,config:{fields:t,type:o,display:a,auth:{mode:c,proxyApp:i,accessToken:d},tenant:r,recommendationsEnabled:m,recommendationsCount:l,currency:u,customerEmail:E(n)},productData:window.currentProduct,localization:p})})}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notify-me-wl",
3
- "version": "2.1.4",
3
+ "version": "3.0.1",
4
4
  "description": "Coming Soon / Notify Me wishlist widget for retailer product pages.",
5
5
  "main": "build/notify-me-wl.min.js",
6
6
  "files": [