@zonos/elements 1.3.215 → 1.3.217
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/dist/cjs/{cart-e0b62259.js → cart-54ff39d6.js} +51 -22
- package/dist/cjs/{handleFetch-7cf3752e.js → handleFetch-0313ebba.js} +3 -3
- package/dist/cjs/index.cjs.js +8 -8
- package/dist/cjs/{localization-91bcde0e.js → localization-721a5ec3.js} +1 -1
- package/dist/cjs/{paypal-93e5de01.js → paypal-e7504122.js} +3 -3
- package/dist/cjs/{updateCheckoutSessionAttributes-047bc0cb.js → updateCheckoutSessionAttributes-8db49644.js} +1 -1
- package/dist/cjs/zonos-address_11.cjs.entry.js +25 -16
- package/dist/cjs/zonos-cart-items_14.cjs.entry.js +10 -7
- package/dist/cjs/zonos-checkout.cjs.entry.js +5 -5
- package/dist/cjs/zonos-controller.cjs.entry.js +3 -3
- package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +4 -4
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-address-update-dialog/zonos-address-form/zonos-address-form.js +8 -7
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +6 -2
- package/dist/collection/components/store/checkout/stripe.js +6 -2
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +9 -2
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +8 -4
- package/dist/collection/components/utils/api/prepCalculateLandedCost.js +13 -8
- package/dist/collection/components/utils/checkout/buildTranslateRequest.js +14 -10
- package/dist/collection/components/utils/extractName.js +17 -0
- package/dist/collection/components/utils/getNextFallbackApi.js +1 -1
- package/dist/collection/components/utils/handleFetch.js +2 -2
- package/dist/esm/{cart-c3540cd7.js → cart-010402f9.js} +51 -23
- package/dist/esm/{handleFetch-dd74bbb1.js → handleFetch-fa90f7f6.js} +3 -3
- package/dist/esm/index.js +8 -8
- package/dist/esm/{localization-cf31c728.js → localization-9db8b6e9.js} +1 -1
- package/dist/esm/{paypal-5963c1ab.js → paypal-70b140d9.js} +3 -3
- package/dist/esm/{updateCheckoutSessionAttributes-7babf0f2.js → updateCheckoutSessionAttributes-691cdc6d.js} +1 -1
- package/dist/esm/zonos-address_11.entry.js +25 -16
- package/dist/esm/zonos-cart-items_14.entry.js +10 -7
- package/dist/esm/zonos-checkout.entry.js +5 -5
- package/dist/esm/zonos-controller.entry.js +3 -3
- package/dist/esm/zonos-country-flag.entry.js +2 -2
- package/dist/esm/zonos-country-select_4.entry.js +2 -2
- package/dist/esm/zonos-empty-state-payment_4.entry.js +4 -4
- package/dist/esm/zonos-hello-dialog.entry.js +2 -2
- package/dist/esm/zonos-hello.entry.js +2 -2
- package/dist/esm/zonos-language-select_2.entry.js +2 -2
- package/dist/esm-es5/cart-010402f9.js +1 -0
- package/dist/esm-es5/{handleFetch-dd74bbb1.js → handleFetch-fa90f7f6.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{localization-cf31c728.js → localization-9db8b6e9.js} +1 -1
- package/dist/esm-es5/{paypal-5963c1ab.js → paypal-70b140d9.js} +1 -1
- package/dist/esm-es5/{updateCheckoutSessionAttributes-7babf0f2.js → updateCheckoutSessionAttributes-691cdc6d.js} +1 -1
- package/dist/esm-es5/zonos-address_11.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_14.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/scripts/index.d.ts +1 -1
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/utils/extractName.d.ts +14 -0
- package/dist/types/components/utils/getNextFallbackApi.d.ts +2 -2
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-0a7ef032.entry.js +1 -0
- package/dist/zonos-elements/p-0e8bdf5c.js +1 -0
- package/dist/zonos-elements/p-164ba7ae.system.entry.js +1 -0
- package/dist/zonos-elements/{p-2820aff2.system.js → p-1efc348b.system.js} +1 -1
- package/dist/zonos-elements/{p-6e8354c1.system.entry.js → p-242dd7ca.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a537a179.system.entry.js → p-300e0d47.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a1cd5572.system.entry.js → p-37aa481c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c34645cb.js → p-425096c9.js} +1 -1
- package/dist/zonos-elements/{p-79a3756e.entry.js → p-4cd33d08.entry.js} +1 -1
- package/dist/zonos-elements/{p-e72b61c1.system.entry.js → p-57f391e6.system.entry.js} +1 -1
- package/dist/zonos-elements/p-58b3a0fc.entry.js +1 -0
- package/dist/zonos-elements/{p-f99c254c.system.js → p-608f965f.system.js} +1 -1
- package/dist/zonos-elements/{p-a45a15a0.js → p-65c68531.js} +1 -1
- package/dist/zonos-elements/{p-41ec9531.entry.js → p-680149ed.entry.js} +1 -1
- package/dist/zonos-elements/p-6d44f441.system.js +1 -0
- package/dist/zonos-elements/{p-8d37bb03.entry.js → p-7c88d2ac.entry.js} +1 -1
- package/dist/zonos-elements/p-81b357f7.system.js +1 -1
- package/dist/zonos-elements/{p-ac784ab8.system.entry.js → p-9ddb4533.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-6c69c5fa.system.entry.js → p-a91024b6.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b22fcbda.system.entry.js → p-a9d41e7c.system.entry.js} +1 -1
- package/dist/zonos-elements/p-ad8b1fe8.entry.js +1 -0
- package/dist/zonos-elements/{p-c8433f89.js → p-afa4b4f0.js} +1 -1
- package/dist/zonos-elements/{p-4444bb4e.system.js → p-b83b382e.system.js} +1 -1
- package/dist/zonos-elements/{p-755cf8bc.system.js → p-c1d86f32.system.js} +1 -1
- package/dist/zonos-elements/{p-2eec2d7c.js → p-d93ecc57.js} +1 -1
- package/dist/zonos-elements/{p-752220fe.entry.js → p-dcedcdda.entry.js} +1 -1
- package/dist/zonos-elements/p-e11c61a5.entry.js +1 -0
- package/dist/zonos-elements/{p-fb898c4f.system.js → p-e17ac0d1.system.js} +1 -1
- package/dist/zonos-elements/{p-137ee43a.system.entry.js → p-e1a7a85f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-6a157c84.entry.js → p-ef34e1ce.entry.js} +1 -1
- package/dist/zonos-elements/{p-1d0e40b7.entry.js → p-f54123b5.entry.js} +1 -1
- package/dist/zonos-elements/p-f7300f5b.system.entry.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/cart-c3540cd7.js +0 -1
- package/dist/zonos-elements/p-0707379c.entry.js +0 -1
- package/dist/zonos-elements/p-299efbcf.system.entry.js +0 -1
- package/dist/zonos-elements/p-6d7e45f3.entry.js +0 -1
- package/dist/zonos-elements/p-9004bdda.entry.js +0 -1
- package/dist/zonos-elements/p-9e037920.system.entry.js +0 -1
- package/dist/zonos-elements/p-adbc4643.system.js +0 -1
- package/dist/zonos-elements/p-c9c96740.entry.js +0 -1
- package/dist/zonos-elements/p-f979a131.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,n,r,o){function t(e){return e instanceof r?e:new r((function(n){n(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function u(e){try{s(o["throw"](e))}catch(e){i(e)}}function s(e){e.done?r(e.value):t(e.value).then(a,u)}s((o=o.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,t,i,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(e){return function(n){return s([e,n])}}function s(u){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(r=0)),r)try{if(o=1,t&&(i=u[0]&2?t["return"]:u[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,u[1])).done)return i;if(t=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:r.label++;return{value:u[1],done:false};case 5:r.label++;t=u[1];u=[0];continue;case 7:u=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){r.label=u[1];break}if(u[0]===6&&r.label<i[1]){r.label=i[1];i=u;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(u);break}if(i[2])r.ops.pop();r.trys.pop();continue}u=n.call(e,r)}catch(e){u=[6,e];t=0}finally{o=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,r){if(r||arguments.length===2)for(var o=0,t=n.length,i;o<t;o++){if(i||!(o in n)){if(!i)i=Array.prototype.slice.call(n,0,o);i[o]=n[o]}}return e.concat(i||Array.prototype.slice.call(n))};System.register([],(function(e){"use strict";return{execute:function(){var n=this;var r=performance.now();var o=e("d",[]);var t=e("c",(function(){var e=performance.now()-r;var n=e>1e3?"".concat((e/1e3).toFixed(2),"s"):"".concat(e.toFixed(2),"ms");return{elapsedTime:e,elapsedTimePretty:n}}));var i=function(e){if(typeof e==="string"){return e}try{var n=JSON.stringify(e);return n}catch(n){if(e&&typeof e.toString==="function"){var r=e.toString();return r}return"Unable to stringify info"}};var a=e("l",(function(e,n){var r=[];for(var a=2;a<arguments.length;a++){r[a-2]=arguments[a]}var u,s;var d=t().elapsedTimePretty;var c=__spreadArray(["(".concat(d,")")],r,true);var l=c.map(i).join(" ");o.push([n,e,l].filter(Boolean).join(" "));var f=!!((u=window.Zonos)===null||u===void 0?void 0:u.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/);if(!f){return}var v=document.querySelector("iframe#zonos---debug-logging-iframe");if(!v){v=document.createElement("iframe");v.id="zonos---debug-logging-iframe";v.style.display="none";v.style.opacity="0";v.style.position="absolute";v.style.top="-9999px";v.style.left="-9999px";v.style.width="1px";v.style.height="1px";v.style.border="none";v.style.overflow="hidden";v.style.visibility="hidden";document.body.appendChild(v)}var w=((s=v.contentWindow)===null||s===void 0?void 0:s.window.console)||window.console;switch(n){case"warn":w.warn.apply(w,__spreadArray([e],c,false));break;case"info":w.info.apply(w,__spreadArray([e],c,false));break;case"error":w.error.apply(w,__spreadArray([e],c,false));break;default:w.groupCollapsed.apply(w,__spreadArray([e],c,false));w.trace();w.groupEnd();break}}));var u=e("b",(function(e){var n=[];for(var r=1;r<arguments.length;r++){n[r-1]=arguments[r]}a.apply(void 0,__spreadArray([e,"error"],n,false))}));var s=e("a",(function(){return window.location.search.includes("zonosStagingMode=1")}));var d=e("g",(function(){var e;return((e=window.Zonos.zonosApiKey)===null||e===void 0?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")}));var c=["cloudflare","vercel"];var l=c[0];var f=e("f",{cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"});var v=f[l];var w=function(e){if(e===void 0){e=l}var n=c.indexOf(e);var r=c[n+1];if(!r){return null}return r};var p=e("j",(function(e){if(typeof e==="string"){try{var n=JSON.parse(e);return n}catch(e){return null}}return null}));var h=890;var b=e("i",(function(e){return e||window.innerWidth<h}));var y=function(){var e="connection"in window.navigator?window.navigator.connection:null;var n="mozConnection"in window.navigator?window.navigator.mozConnection:null;var r="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;var o=e||n||r;return o};var m=e("e",(function(){var e="userAgentData"in window.navigator?window.navigator.userAgentData:null;var n=y();return{connectionDownlink:n===null||n===void 0?void 0:n.downlink,connectionEffectiveType:n===null||n===void 0?void 0:n.effectiveType,connectionRtt:n===null||n===void 0?void 0:n.rtt,connectionSaveData:n===null||n===void 0?void 0:n.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}}));var g=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"];var _=function(e){var n=e.apiPath,r=e.apiType,o=e.loadTimeInternal,t=e.loadTimeTotal;if(g.includes(n)){return}var i=t-o;if(i<0){return}var a=n.split("?")[0]||n;var u=m();var s=typeof u.userAgent==="object"&&u.userAgent.mobile;var d={apiType:r,connectionType:u.connectionEffectiveType,href:a,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:b(s),loadTimeBrowserApi:i,loadTimeInternal:o,loadTimeTotal:t,metadata:Object.assign({},u),screenHeight:u.screenHeight,screenWidth:u.screenWidth,userAgent:typeof u.userAgent==="string"?u.userAgent:u.userAgent["brands"].map((function(e){return e.brand})).filter((function(e){return!/Not.*A.*Brand.*/.test(e)})).join(",")};window.Zonos.loadTimeApiInfoList.push(d)};var T=1*3600*1e3;var k=e("s",(function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i;var u=e.endpoint,s=e.errors,d=e.metadata,c=e.shouldPostReleaseErrorReporting;return __generator(this,(function(e){a("sendErrorLog","warn",u,d,s);if(c){n=Number(window.Zonos.releaseDate);r=(new Date).getTime();if(r-n>T){return[2]}}o="userAgentData"in window.navigator?window.navigator.userAgentData:null;t={endpoint:u,errors:s,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:o&&o.brands.length>0?o:window.navigator.userAgent},d)};try{void fetch("".concat(v,"/api/zonos-elements/log-error"),{body:JSON.stringify(t),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){i=w();if(!i){return[2]}void fetch("".concat(f[i],"/api/zonos-elements/log-error"),{body:JSON.stringify(t),method:"POST"})}return[2]}))}))}));var j=undefined&&undefined.__rest||function(e,n){var r={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0)r[o]=e[o];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var t=0,o=Object.getOwnPropertySymbols(e);t<o.length;t++){if(n.indexOf(o[t])<0&&Object.prototype.propertyIsEnumerable.call(e,o[t]))r[o[t]]=e[o[t]]}return r};var z=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o;var t=e.response,i=e.shouldLog,a=i===void 0?true:i,u=e.shouldThrow,s=u===void 0?false:u;return __generator(this,(function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4,t.text()];case 1:n=e.sent();r=p(n);if(!r){throw new Error("Failed to parse content: ".concat(n))}return[2,r];case 2:o=e.sent();if(s){throw o}if(a){console.error(o)}return[2,null];case 3:return[2]}}))}))};var A=function(e){try{var n=btoa(e).replace(/=/g,"");return n}catch(n){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}};var O=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i,a,u,s,d,c,v,c,w,p,u,h,u;var b=e.basePathType,y=e.options,m=e.path;return __generator(this,(function(e){switch(e.label){case 0:r=window.Zonos.zonosQaUrlApi||f[b]||l;o=r+m;t=new URL(o);i=window.Zonos.cartId?"".concat(window.location.hostname,"-").concat(window.Zonos.cartId):window.location.hostname;t.searchParams.set("zToken",A(i));e.label=1;case 1:e.trys.push([1,3,,4]);return[4,fetch(t.toString(),y)];case 2:n=e.sent();return[3,4];case 3:a=e.sent();if(a instanceof Error){return[2,{baseUrl:r,errors:[{message:a.message,type:"unknown"}],json:null,response:null,zonosMode:null}]}u="Failed to fetch";return[2,{baseUrl:r,errors:[{message:u,type:"unknown"}],json:null,response:null,zonosMode:null}];case 4:s=n.headers.get("Zonos-Mode");d=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&s&&d){window.Zonos.modeAlerted=true}if(!n.ok)return[3,6];return[4,z({response:n})];case 5:c=e.sent();return[2,{baseUrl:r,errors:[],json:c,response:n,zonosMode:s}];case 6:v=n.status.toString();e.label=7;case 7:e.trys.push([7,9,,10]);return[4,z({response:n,shouldThrow:true})];case 8:c=e.sent();if(c&&"errors"in c&&Array.isArray(c.errors)){w=c.errors;p=w.map((function(e){if(typeof e==="string"){return{message:e,type:v}}return e}));return[2,{baseUrl:r,errors:p,json:null,response:n,zonosMode:s}]}u=JSON.stringify(c);return[2,{baseUrl:r,errors:[{message:u,type:v}],json:null,response:n,zonosMode:s}];case 9:h=e.sent();u="Unknown error";return[2,{baseUrl:r,errors:[{message:"".concat(v,": ").concat(u),type:v}],json:null,response:null,zonosMode:s}];case 10:return[2]}}))}))};var S=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i,u,s,d,c,l,v,h,b,y,m,g,T;var z=e.basePathType,A=e.options,P=e.path;return __generator(this,(function(e){switch(e.label){case 0:o=P.startsWith("/api/bigcommerce");t=o?"vercel":z;i=performance.now();return[4,O({basePathType:t,options:A,path:P})];case 1:u=e.sent(),s=u.errors,d=u.response,c=j(u,["errors","response"]);l=performance.now();v=l-i;a("".concat(P," (").concat(v.toFixed(2),"ms)"),"info");h=d===null||d===void 0?void 0:d.headers.get("Zonos-Duration");if((d===null||d===void 0?void 0:d.status)===200){_({apiPath:P,apiType:t,loadTimeInternal:h?Number(h):0,loadTimeTotal:v})}b=w(t);y=s.find((function(e){var n=e.type;return n==="unknown"}));m=s.find((function(e){var n=e.message;return typeof n==="string"&&(n.includes("signal is aborted")||n.includes("The operation was aborted")||n.includes("Fetch is aborted"))}));g=!!y||(d===null||d===void 0?void 0:d.status)===404;T=b&&g;if(g&&!m){void k({endpoint:f[t]+P,errors:s.map((function(e){var n=e.message;return"API: ".concat(n)})),metadata:{currentBasePath:t,nextFallbackApiType:b,requestHeaders:A===null||A===void 0?void 0:A.headers,requestPayload:p((n=A===null||A===void 0?void 0:A.body)===null||n===void 0?void 0:n.toString())||((r=A===null||A===void 0?void 0:A.body)===null||r===void 0?void 0:r.toString()),status:d===null||d===void 0?void 0:d.status,statusText:d===null||d===void 0?void 0:d.statusText},shouldPostReleaseErrorReporting:true})}if(T){a('=== "'.concat(P,'" failed to fetch, trying next fallback ').concat(b));return[2,S({basePathType:b,options:A,path:P})]}return[2,Object.assign({errors:s,response:d},c)]}}))}))};var P=e("h",(function(e,r){return __awaiter(n,void 0,void 0,(function(){var n,o,t,i,a,u;return __generator(this,(function(c){n=j(r||{},[]);o=n.body?JSON.stringify(n.body):undefined;t=n.method||"GET";i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":s()?"1":undefined,"Zonos-Test-Mode":d()?"1":undefined,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach((function(e){return i[e]===undefined&&delete i[e]}));a=Object.assign(Object.assign({},n),{body:t==="GET"?undefined:o,headers:i,method:t});u=new URLSearchParams(window.location.search).get("useFallbackApi");return[2,S({basePathType:u||l,options:a,path:e})]}))}))}))}}}));
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,n,r,o){function t(e){return e instanceof r?e:new r((function(n){n(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function u(e){try{s(o["throw"](e))}catch(e){i(e)}}function s(e){e.done?r(e.value):t(e.value).then(a,u)}s((o=o.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,t,i,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(e){return function(n){return s([e,n])}}function s(u){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(r=0)),r)try{if(o=1,t&&(i=u[0]&2?t["return"]:u[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,u[1])).done)return i;if(t=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:r.label++;return{value:u[1],done:false};case 5:r.label++;t=u[1];u=[0];continue;case 7:u=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){r.label=u[1];break}if(u[0]===6&&r.label<i[1]){r.label=i[1];i=u;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(u);break}if(i[2])r.ops.pop();r.trys.pop();continue}u=n.call(e,r)}catch(e){u=[6,e];t=0}finally{o=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,r){if(r||arguments.length===2)for(var o=0,t=n.length,i;o<t;o++){if(i||!(o in n)){if(!i)i=Array.prototype.slice.call(n,0,o);i[o]=n[o]}}return e.concat(i||Array.prototype.slice.call(n))};System.register([],(function(e){"use strict";return{execute:function(){var n=this;var r=performance.now();var o=e("d",[]);var t=e("c",(function(){var e=performance.now()-r;var n=e>1e3?"".concat((e/1e3).toFixed(2),"s"):"".concat(e.toFixed(2),"ms");return{elapsedTime:e,elapsedTimePretty:n}}));var i=function(e){if(typeof e==="string"){return e}try{var n=JSON.stringify(e);return n}catch(n){if(e&&typeof e.toString==="function"){var r=e.toString();return r}return"Unable to stringify info"}};var a=e("l",(function(e,n){var r=[];for(var a=2;a<arguments.length;a++){r[a-2]=arguments[a]}var u,s;var d=t().elapsedTimePretty;var c=__spreadArray(["(".concat(d,")")],r,true);var l=c.map(i).join(" ");o.push([n,e,l].filter(Boolean).join(" "));var f=!!((u=window.Zonos)===null||u===void 0?void 0:u.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/);if(!f){return}var v=document.querySelector("iframe#zonos---debug-logging-iframe");if(!v){v=document.createElement("iframe");v.id="zonos---debug-logging-iframe";v.style.display="none";v.style.opacity="0";v.style.position="absolute";v.style.top="-9999px";v.style.left="-9999px";v.style.width="1px";v.style.height="1px";v.style.border="none";v.style.overflow="hidden";v.style.visibility="hidden";document.body.appendChild(v)}var w=((s=v.contentWindow)===null||s===void 0?void 0:s.window.console)||window.console;switch(n){case"warn":w.warn.apply(w,__spreadArray([e],c,false));break;case"info":w.info.apply(w,__spreadArray([e],c,false));break;case"error":w.error.apply(w,__spreadArray([e],c,false));break;default:w.groupCollapsed.apply(w,__spreadArray([e],c,false));w.trace();w.groupEnd();break}}));var u=e("b",(function(e){var n=[];for(var r=1;r<arguments.length;r++){n[r-1]=arguments[r]}a.apply(void 0,__spreadArray([e,"error"],n,false))}));var s=e("a",(function(){return window.location.search.includes("zonosStagingMode=1")}));var d=e("g",(function(){var e;return((e=window.Zonos.zonosApiKey)===null||e===void 0?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")}));var c=["vercel","cloudflare"];var l=c[0];var f=e("f",{cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"});var v=f[l];var w=function(e){if(e===void 0){e=l}var n=c.indexOf(e);var r=c[n+1];if(!r){return null}return r};var p=e("j",(function(e){if(typeof e==="string"){try{var n=JSON.parse(e);return n}catch(e){return null}}return null}));var h=890;var b=e("i",(function(e){return e||window.innerWidth<h}));var y=function(){var e="connection"in window.navigator?window.navigator.connection:null;var n="mozConnection"in window.navigator?window.navigator.mozConnection:null;var r="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;var o=e||n||r;return o};var m=e("e",(function(){var e="userAgentData"in window.navigator?window.navigator.userAgentData:null;var n=y();return{connectionDownlink:n===null||n===void 0?void 0:n.downlink,connectionEffectiveType:n===null||n===void 0?void 0:n.effectiveType,connectionRtt:n===null||n===void 0?void 0:n.rtt,connectionSaveData:n===null||n===void 0?void 0:n.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}}));var g=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"];var _=function(e){var n=e.apiPath,r=e.apiType,o=e.loadTimeInternal,t=e.loadTimeTotal;if(g.includes(n)){return}var i=t-o;if(i<0){return}var a=n.split("?")[0]||n;var u=m();var s=typeof u.userAgent==="object"&&u.userAgent.mobile;var d={apiType:r,connectionType:u.connectionEffectiveType,href:a,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:b(s),loadTimeBrowserApi:i,loadTimeInternal:o,loadTimeTotal:t,metadata:Object.assign({},u),screenHeight:u.screenHeight,screenWidth:u.screenWidth,userAgent:typeof u.userAgent==="string"?u.userAgent:u.userAgent["brands"].map((function(e){return e.brand})).filter((function(e){return!/Not.*A.*Brand.*/.test(e)})).join(",")};window.Zonos.loadTimeApiInfoList.push(d)};var T=1*3600*1e3;var k=e("s",(function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i;var u=e.endpoint,s=e.errors,d=e.metadata,c=e.shouldPostReleaseErrorReporting;return __generator(this,(function(e){a("sendErrorLog","warn",u,d,s);if(c){n=Number(window.Zonos.releaseDate);r=(new Date).getTime();if(r-n>T){return[2]}}o="userAgentData"in window.navigator?window.navigator.userAgentData:null;t={endpoint:u,errors:s,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:o&&o.brands.length>0?o:window.navigator.userAgent},d)};try{void fetch("".concat(v,"/api/zonos-elements/log-error"),{body:JSON.stringify(t),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){i=w();if(!i){return[2]}void fetch("".concat(f[i],"/api/zonos-elements/log-error"),{body:JSON.stringify(t),method:"POST"})}return[2]}))}))}));var j=undefined&&undefined.__rest||function(e,n){var r={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0)r[o]=e[o];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var t=0,o=Object.getOwnPropertySymbols(e);t<o.length;t++){if(n.indexOf(o[t])<0&&Object.prototype.propertyIsEnumerable.call(e,o[t]))r[o[t]]=e[o[t]]}return r};var z=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o;var t=e.response,i=e.shouldLog,a=i===void 0?true:i,u=e.shouldThrow,s=u===void 0?false:u;return __generator(this,(function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4,t.text()];case 1:n=e.sent();r=p(n);if(!r){throw new Error("Failed to parse content: ".concat(n))}return[2,r];case 2:o=e.sent();if(s){throw o}if(a){console.error(o)}return[2,null];case 3:return[2]}}))}))};var A=function(e){try{var n=btoa(e).replace(/=/g,"");return n}catch(n){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}};var O=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i,a,u,s,d,c,v,c,w,p,u,h,u;var b=e.basePathType,y=e.options,m=e.path;return __generator(this,(function(e){switch(e.label){case 0:r=window.Zonos.zonosQaUrlApi||f[b]||l;o=r+m;t=new URL(o);i=window.Zonos.cartId?"".concat(window.location.hostname,"-").concat(window.Zonos.cartId):window.location.hostname;t.searchParams.set("zToken",A(i));e.label=1;case 1:e.trys.push([1,3,,4]);return[4,fetch(t.toString(),y)];case 2:n=e.sent();return[3,4];case 3:a=e.sent();if(a instanceof Error){return[2,{baseUrl:r,errors:[{message:a.message,type:"unknown"}],json:null,response:null,zonosMode:null}]}u="Failed to fetch";return[2,{baseUrl:r,errors:[{message:u,type:"unknown"}],json:null,response:null,zonosMode:null}];case 4:s=n.headers.get("Zonos-Mode");d=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&s&&d){window.Zonos.modeAlerted=true}if(!n.ok)return[3,6];return[4,z({response:n})];case 5:c=e.sent();return[2,{baseUrl:r,errors:[],json:c,response:n,zonosMode:s}];case 6:v=n.status.toString();e.label=7;case 7:e.trys.push([7,9,,10]);return[4,z({response:n,shouldThrow:true})];case 8:c=e.sent();if(c&&"errors"in c&&Array.isArray(c.errors)){w=c.errors;p=w.map((function(e){if(typeof e==="string"){return{message:e,type:v}}return e}));return[2,{baseUrl:r,errors:p,json:null,response:n,zonosMode:s}]}u=JSON.stringify(c);return[2,{baseUrl:r,errors:[{message:u,type:v}],json:null,response:n,zonosMode:s}];case 9:h=e.sent();u="Unknown error";return[2,{baseUrl:r,errors:[{message:"".concat(v,": ").concat(u),type:v}],json:null,response:null,zonosMode:s}];case 10:return[2]}}))}))};var S=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i,u,s,d,c,l,v,h,b,y,m,g,T;var z=e.basePathType,A=e.options,P=e.path;return __generator(this,(function(e){switch(e.label){case 0:o=P.startsWith("/api/bigcommerce");t=o?"vercel":z;i=performance.now();return[4,O({basePathType:t,options:A,path:P})];case 1:u=e.sent(),s=u.errors,d=u.response,c=j(u,["errors","response"]);l=performance.now();v=l-i;a("".concat(P," (").concat(v.toFixed(2),"ms)"),"info");h=d===null||d===void 0?void 0:d.headers.get("Zonos-Duration");if((d===null||d===void 0?void 0:d.status)===200){_({apiPath:P,apiType:t,loadTimeInternal:h?Number(h):0,loadTimeTotal:v})}b=w(t);y=s.find((function(e){var n=e.type;return n==="unknown"}));m=s.find((function(e){var n=e.message;return typeof n==="string"&&(n.includes("signal is aborted")||n.includes("The operation was aborted")||n.includes("Fetch is aborted"))}));g=!!y||(d===null||d===void 0?void 0:d.status)===404||(d===null||d===void 0?void 0:d.status)===500;T=b&&g;if(g&&!m){void k({endpoint:f[t]+P,errors:s.map((function(e){var n=e.message;return"API: ".concat(n)})),metadata:{currentBasePath:t,nextFallbackApiType:b,requestHeaders:A===null||A===void 0?void 0:A.headers,requestPayload:p((n=A===null||A===void 0?void 0:A.body)===null||n===void 0?void 0:n.toString())||((r=A===null||A===void 0?void 0:A.body)===null||r===void 0?void 0:r.toString()),status:d===null||d===void 0?void 0:d.status,statusText:d===null||d===void 0?void 0:d.statusText},shouldPostReleaseErrorReporting:true})}if(T){a('=== "'.concat(P,'" failed to fetch, trying next fallback ').concat(b));return[2,S({basePathType:b,options:A,path:P})]}return[2,Object.assign({errors:s,response:d},c)]}}))}))};var P=e("h",(function(e,r){return __awaiter(n,void 0,void 0,(function(){var n,o,t,i,a,u;return __generator(this,(function(c){n=j(r||{},[]);o=n.body?JSON.stringify(n.body):undefined;t=n.method||"GET";i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":s()?"1":undefined,"Zonos-Test-Mode":d()?"1":undefined,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach((function(e){return i[e]===undefined&&delete i[e]}));a=Object.assign(Object.assign({},n),{body:t==="GET"?undefined:o,headers:i,method:t});u=new URLSearchParams(window.location.search).get("useFallbackApi");return[2,S({basePathType:u||l,options:a,path:e})]}))}))}))}}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=performance.now(),o=[],n=()=>{const o=performance.now()-e,n=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:n}},t=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){return e&&"function"==typeof e.toString?e.toString():"Unable to stringify info"}},r=(e,r,...s)=>{var i,a;const{elapsedTimePretty:l}=n(),d=[`(${l})`,...s],c=d.map(t).join(" ");if(o.push([r,e,c].filter(Boolean).join(" ")),!(null===(i=window.Zonos)||void 0===i?void 0:i.debug)&&!window.location.search.match(/\?.*(&*)zonosDebug=1/))return;let w=document.querySelector("iframe#zonos---debug-logging-iframe");w||(w=document.createElement("iframe"),w.id="zonos---debug-logging-iframe",w.style.display="none",w.style.opacity="0",w.style.position="absolute",w.style.top="-9999px",w.style.left="-9999px",w.style.width="1px",w.style.height="1px",w.style.border="none",w.style.overflow="hidden",w.style.visibility="hidden",document.body.appendChild(w));const u=(null===(a=w.contentWindow)||void 0===a?void 0:a.window.console)||window.console;switch(r){case"warn":u.warn(e,...d);break;case"info":u.info(e,...d);break;case"error":u.error(e,...d);break;default:u.groupCollapsed(e,...d),u.trace(),u.groupEnd()}},s=(e,...o)=>{r(e,"error",...o)},i=()=>window.location.search.includes("zonosStagingMode=1"),a=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")},l=["
|
|
1
|
+
const e=performance.now(),o=[],n=()=>{const o=performance.now()-e,n=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:n}},t=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){return e&&"function"==typeof e.toString?e.toString():"Unable to stringify info"}},r=(e,r,...s)=>{var i,a;const{elapsedTimePretty:l}=n(),d=[`(${l})`,...s],c=d.map(t).join(" ");if(o.push([r,e,c].filter(Boolean).join(" ")),!(null===(i=window.Zonos)||void 0===i?void 0:i.debug)&&!window.location.search.match(/\?.*(&*)zonosDebug=1/))return;let w=document.querySelector("iframe#zonos---debug-logging-iframe");w||(w=document.createElement("iframe"),w.id="zonos---debug-logging-iframe",w.style.display="none",w.style.opacity="0",w.style.position="absolute",w.style.top="-9999px",w.style.left="-9999px",w.style.width="1px",w.style.height="1px",w.style.border="none",w.style.overflow="hidden",w.style.visibility="hidden",document.body.appendChild(w));const u=(null===(a=w.contentWindow)||void 0===a?void 0:a.window.console)||window.console;switch(r){case"warn":u.warn(e,...d);break;case"info":u.info(e,...d);break;case"error":u.error(e,...d);break;default:u.groupCollapsed(e,...d),u.trace(),u.groupEnd()}},s=(e,...o)=>{r(e,"error",...o)},i=()=>window.location.search.includes("zonosStagingMode=1"),a=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")},l=["vercel","cloudflare"],d=l[0],c={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},w=c[d],u=(e=d)=>{const o=l.indexOf(e);return l[o+1]||null},p=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},f=e=>e||window.innerWidth<890,h=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||n})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},m=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(r("sendErrorLog","warn",e,n,o),t){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${w}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=u();if(!o)return;fetch(`${c[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}};var g=function(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(e);r<t.length;r++)o.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(e,t[r])&&(n[t[r]]=e[t[r]])}return n};const y=async({response:e,shouldLog:o=!0,shouldThrow:n=!1})=>{try{const o=await e.text(),n=p(o);if(!n)throw new Error(`Failed to parse content: ${o}`);return n}catch(e){if(n)throw e;return o&&console.error(e),null}},v=async({basePathType:e,options:o,path:n})=>{var t,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await(async({basePathType:e,options:o,path:n})=>{let t;const r=window.Zonos.zonosQaUrlApi||c[e]||d,s=new URL(r+n),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{t=await fetch(s.toString(),o)}catch(e){return e instanceof Error?{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null}:{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=t.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),t.ok)return{baseUrl:r,errors:[],json:await y({response:t}),response:t,zonosMode:a};const w=t.status.toString();try{const e=await y({response:t,shouldThrow:!0});return e&&"errors"in e&&Array.isArray(e.errors)?{baseUrl:r,errors:e.errors.map((e=>"string"==typeof e?{message:e,type:w}:e)),json:null,response:t,zonosMode:a}:{baseUrl:r,errors:[{message:JSON.stringify(e),type:w}],json:null,response:t,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${w}: Unknown error`,type:w}],json:null,response:null,zonosMode:a}}})({basePathType:i,options:o,path:n}),{errors:w,response:T}=l,j=g(l,["errors","response"]),z=performance.now()-a;r(`${n} (${z.toFixed(2)}ms)`,"info");const O=null==T?void 0:T.headers.get("Zonos-Duration");200===(null==T?void 0:T.status)&&(({apiPath:e,apiType:o,loadTimeInternal:n,loadTimeTotal:t})=>{if(m.includes(e))return;const r=t-n;if(r<0)return;const s=e.split("?")[0]||e,i=h(),a={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:f("object"==typeof i.userAgent&&i.userAgent.mobile),loadTimeBrowserApi:r,loadTimeInternal:n,loadTimeTotal:t,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};window.Zonos.loadTimeApiInfoList.push(a)})({apiPath:n,apiType:i,loadTimeInternal:O?Number(O):0,loadTimeTotal:z});const k=u(i),P=w.find((({type:e})=>"unknown"===e)),$=w.find((({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted")))),A=!!P||404===(null==T?void 0:T.status)||500===(null==T?void 0:T.status),M=k&&A;return A&&!$&&b({endpoint:c[i]+n,errors:w.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:k,requestHeaders:null==o?void 0:o.headers,requestPayload:p(null===(t=null==o?void 0:o.body)||void 0===t?void 0:t.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==T?void 0:T.status,statusText:null==T?void 0:T.statusText},shouldPostReleaseErrorReporting:!0}),M?(r(`=== "${n}" failed to fetch, trying next fallback ${k}`),v({basePathType:k,options:o,path:n})):Object.assign({errors:w,response:T},j)},T=async(e,o)=>{const n=g(o||{},[]),t=n.body?JSON.stringify(n.body):void 0,r=n.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":i()?"1":void 0,"Zonos-Test-Mode":a()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const l=Object.assign(Object.assign({},n),{body:"GET"===r?void 0:t,headers:s,method:r}),c=new URLSearchParams(window.location.search).get("useFallbackApi");return v({basePathType:c||d,options:l,path:e})};export{i as a,s as b,n as c,o as d,h as e,c as f,a as g,T as h,f as i,p as j,r as l,b as s}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,h as e,H as t,a as s}from"./p-b30c2ad9.js";import{d as i}from"./p-0ae53ff0.js";import{l as n,i as l,t as r,g as h,h as a,j as d,k as c,m,d as g}from"./p-a45a15a0.js";import{z as p,g as w,m as f}from"./p-7ce093aa.js";import{c as z}from"./p-b4b7f705.js";import{h as u,b,l as v}from"./p-2eec2d7c.js";import{g as x}from"./p-5883217a.js";import"./p-04a01cb1.js";const y=o=>{const e=null==o?void 0:o.replace("www.","").replace("https://","");return e&&new RegExp(e).test(window.location.href)},k=()=>{var o,e;const{productAddToCartElementSelector:t,productDescriptionElementSelector:s,productTitleElementSelector:i,restrictionBehavior:n}=p.helloSettings;i&&s||v("Hello could not check item restrictions - must provide title and description selectors.");const r=i&&l(i)&&document.querySelectorAll(i)||[],h=s&&l(s)&&document.querySelectorAll(s)||[];if(r.length!==h.length)return v("Hello could not check item restrictions - Title and description selectors do not match"),[];const a="RESTRICT_AND_BLOCK"===n,d=a&&t&&l(t)&&document.querySelectorAll(t)||[];a&&d.length!==h.length&&v('Hello could not disable "Add to cart" buttons - Title and add to cart selectors do not match');const c=[];for(let t=0;t<r.length;t++){const s=r[t],i=h[t];if(s&&i){const n={cartButtonNode:d[t]||null,description:(null===(o=i.textContent)||void 0===o?void 0:o.trim())||"",title:(null===(e=s.textContent)||void 0===e?void 0:e.trim())||""};c.push(n)}}return c},L=class{constructor(e){o(this,e),this.showPeekMessage=!1,this.zonosStoreHelloSettings=p.helloSettings,this.showDialog=!1,this.peekMessage="",this.initialUrl="",this.allRestrictedItems=[],this.allFoundProducts=[],this.productsOnPage=[],this.isHelloWidgetRendered=!1,this.isMobile=!1,this.getHelloPeekMessage=o=>{if(("productDetail"===p.currentHelloPage||"productList"===p.currentHelloPage)&&this.allRestrictedItems.length){const o=r("click to learn more");return`${r("productDetail"===p.currentHelloPage?"Restricted item":"Restricted items found")} - ${o}`}switch(p.currentHelloPage){case"cart":return r("Prepay duties and taxes at checkout");case"productList":case"productDetail":return r("See duty and tax thresholds");default:return r("Welcome to [storeName]",{storeName:o})}},this.enableShowPeekMessage=()=>{this.peekMessage&&(this.showPeekMessage=!0)},this.getNewItemRestrictions=async o=>"productDetail"!==p.currentHelloPage&&"productList"!==p.currentHelloPage||"DISABLED"===p.helloSettings.restrictionBehavior?[]:await(async o=>{if(!o.length)return[];const{selectedCountryCode:e}=n;if(!e)return b("Hello could not check item restrictions - No country code selected"),[];const t=o.map((o=>({description:o.description,name:o.title})));return(await(async({items:o,shipFrom:e,shipTo:t})=>{var s;const i={items:o,shipFrom:e,shipTo:t},{errors:n,json:l}=await u("/api/zonos-elements/check-item-restrictions",{body:i,method:"POST"});return n.length||!l?(b(`Error fetching item restrictions: ${null===(s=n.find(Boolean))||void 0===s?void 0:s.message}`),[]):l.filter(Boolean)})({items:t,shipFrom:"AD",shipTo:e})).map((o=>{var e;const s=(null===(e=t.filter((e=>e.description===o.itemDescription)).find(Boolean))||void 0===e?void 0:e.name)||"";return Object.assign(Object.assign({},o),{name:s})}))})(o),this.triggerShowPeekMessage=()=>{this.peekMessage=this.getHelloPeekMessage(p.organizationName);const{peekMessageBehavior:o,peekMessageDelay:e}=p.helloSettings;"ENABLED"===o&&setTimeout((()=>{this.enableShowPeekMessage(),this.allRestrictedItems.some((o=>this.productsOnPage.some((e=>e.description===o.itemDescription))))||setTimeout((()=>{this.showPeekMessage=!1}),3e3)}),1e3*e)},this.disableAddToCartButtons=()=>{this.productsOnPage.length&&this.productsOnPage.forEach((o=>{var e,t;this.allRestrictedItems.some((e=>e.itemDescription===o.description))?null===(e=o.cartButtonNode)||void 0===e||e.setAttribute("disabled","disabled"):null===(t=o.cartButtonNode)||void 0===t||t.removeAttribute("disabled")}))},this.handleItemRestrictions=async()=>{this.productsOnPage=k();const o=this.productsOnPage.filter((o=>!this.allFoundProducts.some((e=>e.title===o.title)))),e=await this.getNewItemRestrictions(o);this.allRestrictedItems.push(...e),this.allFoundProducts.push(...o),this.disableAddToCartButtons()},this.reloadHelloData=async()=>{await this.handleItemRestrictions(),this.triggerShowPeekMessage()},this.handleProductCountChange=i((()=>{const{productTitleElementSelector:o}=p.helloSettings;if(o){const o=k();if(this.allFoundProducts.length!==o.length&&window.location.href===this.initialUrl){if(!this.allFoundProducts.length)return;this.reloadHelloData()}}}),1e3),this.watchProductCountChange=()=>{var o;const e=new MutationObserver(this.handleProductCountChange);e.observe(document.body,{childList:!0,subtree:!0}),null===(o=this.observerWatcher)||void 0===o||o.push(e)},this.watchPriceChange=()=>{var o;const e=new MutationObserver((()=>{this.displayCurrency()}));e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),null===(o=this.observerWatcher)||void 0===o||o.push(e)},this.updateHelloOnPageChange=()=>{this.watchProductCountChange(),setInterval((()=>{if(window.location.href!==this.initialUrl){const o=this.initialUrl&&new URL(this.initialUrl);(o&&h(o.searchParams))!==n.selectedCountryCode&&(this.allFoundProducts=[],this.allRestrictedItems=[],this.productsOnPage=[]),this.initialUrl=window.location.href,p.currentHelloPage=(()=>{const{cartUrlPattern:o,homepageUrlPattern:e,productDetailUrlPattern:t,productListUrlPattern:s}=p.helloSettings;return y(o)?"cart":y(t)?"productDetail":y(s)?"productList":y(e)?"home":""})();const e=new URL(window.location.href);if(!h(e.searchParams))return void a(n.selectedCountryCode);this.reloadHelloData()}}),1e3)},this.changeShowDialog=o=>{this.showDialog=o},this.shouldAnimateLeftDesktop=()=>{const o=this.helloRef&&getComputedStyle(this.helloRef).position;if(this.helloRef&&"relative"===o)return x(this.helloRef)},this.shouldRenderHello=(o=!0)=>{if(!n.localizationLoaded)return!1;const{showForCountries:e}=p.helloSettings;return o&&(n.isShippableCountry||v(`Hello: not shippable country - Show for countries: ${e}`)),"ONLY_SHIPPABLE"===e?n.isShippableCountry:"ALL"===e||(null==e?void 0:e.includes(n.selectedCountryCode||""))}}showDialogHandler(o){var e;if(o){const o=null===(e=this.helloElement)||void 0===e?void 0:e.parentElement;o&&o.parentElement===document.body&&(o.style.zIndex="2147483647",document.body.appendChild(o))}}async getCountryList(){return n.helloCountryList}componentWillLoad(){const o=setInterval((async()=>{this.helloRef&&p.loadedConfig&&(this.helloRef.setAttribute("data-zonos-hello-loaded",""),this.updateHelloOnPageChange(),this.watchPriceChange(),this.handleAppearanceSettingsOverrideChange(),clearInterval(o))}),100)}disconnectedCallback(){var o;null===(o=this.observerWatcher)||void 0===o||o.forEach((o=>o.disconnect()))}async displayCurrency(){"DISABLED"!==p.helloSettings.currencyBehavior&&(n.exchangeRate?d():v("Could not display currency. Exchange rate and format data is not available.","warn"))}async convertAndFormat(o){return c(o)}async convert(o){return m(o)}async format(o){return g({amount:o})}async openHelloDialog(o){this.changeShowDialog(o)}handleResize(){this.isMobile=window.innerWidth<=768}handleHelloWidgetInitializedState({countryCode:o,currencyCode:e}){var t,s;this.isHelloWidgetRendered||n.selectedCountryCode&&"function"==typeof p.helloSettings.onInitSuccess&&(this.isHelloWidgetRendered=!0,null===(s=(t=p.helloSettings).onInitSuccess)||void 0===s||s.call(t,{countryCode:o,currencyCode:e}))}getHelloLocation(){const o=this.mobileLocationOverride||p.helloSettings.mobileLocation,e=p.helloSettings.desktopLocation,t=this.isMobile;if(!0===t)return{isMobileWindow:t,isOnLeft:this.animateFromLeftOverride||(null==o?void 0:o.includes("LEFT")),isOnTop:null==o?void 0:o.includes("TOP"),shouldFloat:!!o};{const o=!p.helloSettings.anchorElementSelector&&!!e;return{isMobileWindow:t,isOnLeft:this.animateFromLeftOverride||(null==e?void 0:e.includes("LEFT"))||this.shouldAnimateLeftDesktop(),isOnTop:null==e?void 0:e.includes("TOP"),shouldFloat:o}}}handleAppearanceSettingsOverrideChange(){var o;(null===(o=this.appearanceSettingsOverride)||void 0===o?void 0:o.theme)&&(this.appearanceSettingsOverride.theme=w(this.appearanceSettingsOverride.theme))}componentDidLoad(){this.isMobile=window.innerWidth<=768}render(){var o,s;if(null===(o=p.helloSettings.excludedUrlPatterns)||void 0===o?void 0:o.some((o=>o&&new RegExp(o).test(window.location.href))))return v("Hello is excluded on this url","warn"),null;const{selectedCountryCode:i,targetCurrency:l}=n,{isOnLeft:r,isOnTop:h,shouldFloat:a}=this.getHelloLocation(),d=f(p.appearance,this.appearanceSettingsOverride||null),{theme:c}=d,m=null===(s=this.allRestrictedItems)||void 0===s?void 0:s.filter((o=>this.productsOnPage.some((e=>e.description===o.itemDescription))));this.peekMessage=this.getHelloPeekMessage(p.organizationName);const g=this.shouldRenderHello()&&!!i;return g&&!this.isHelloWidgetRendered&&this.handleHelloWidgetInitializedState({countryCode:i,currencyCode:l}),e(t,{class:"zonos--hello zonos--elements","data-theme":c},g&&e("div",{class:z(["zonos--hello-wrapper",a&&"zonos--hello-widget-float"])},e("button",{class:z(["zonos--hello-widget",this.showPeekMessage&&"zonos--hello-show-peek-message",this.mobileLocationOverride&&"zonos--hello-mobile-override",r&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",h&&"zonos--hello-widget-top",!!this.allRestrictedItems.length&&"zonos--hello-has-restrictions",a&&"zonos--hello-widget-float"]),onClick:()=>{this.changeShowDialog(!this.showDialog)},onMouseEnter:()=>this.enableShowPeekMessage(),onMouseLeave:()=>this.showPeekMessage=!1,ref:o=>o&&(this.helloRef=o),type:"button"},e("zonos-text",{class:"zonos--hello-message"},this.peekMessage),i&&e("div",{class:"zonos--hello-country-flag-wrapper"},e("zonos-country-flag",{class:"zonos--hello-country-flag",countryCode:i}))),e("div",{class:z(["zonos--hello-dialog-wrapper",this.mobileLocationOverride&&"zonos--hello-dialog-wrapper-mobile-override",a&&"zonos--hello-widget-float"]),style:{height:this.showDialog?"fit-content":"0px"}},e("zonos-hello-dialog",{animateFromLeftOverride:this.animateFromLeftOverride,appearanceSettings:d,isOpen:this.showDialog,mobileLocationOverride:this.mobileLocationOverride,restrictedItems:m,setIsOpen:this.changeShowDialog}))))}get helloElement(){return s(this)}static get watchers(){return{showDialog:["showDialogHandler"],appearanceSettingsOverride:["handleAppearanceSettingsOverrideChange"]}}};L.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:inline-block}:host .zonos--hello-wrapper{position:relative}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper-mobile-override{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media (max-width: 768px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}}:host .zonos--hello-widget{-webkit-transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);padding:6px;border-radius:30px;background:var(--zonos-elements-page-background);font-size:var(--zonos-elements-font-size-s);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;cursor:pointer;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;position:relative;z-index:1000}:host .zonos--hello-widget>.zonos--hello-message{-ms-flex-order:0;order:0;max-width:0;height:100%;white-space:nowrap;-webkit-transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);overflow:hidden;color:var(--zonos-elements-text-color);position:absolute;background:var(--zonos-elements-page-background);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top-left-radius:30px;border-bottom-left-radius:30px;left:0;-webkit-transform:translateX(calc(-100% + 16px));transform:translateX(calc(-100% + 16px));width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border-top:var(--zonos-elements-border);border-bottom:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-has-restrictions{background:var(--zonos-elements-red-100);border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-has-restrictions>.zonos--hello-message{background:var(--zonos-elements-red-100);color:var(--zonos-elements-red-800);font-weight:500}:host .zonos--hello-widget.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-show-peek-message{max-width:100vw;width:100%}:host .zonos--hello-widget.zonos--hello-show-peek-message>.zonos--hello-message{max-width:100vw;padding:0 6px;padding-right:16px;border:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-show-peek-message:not(.zonos--hello-widget-animate-from-left)>.zonos--hello-message{border-right:none}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{border-left:0}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:16px;padding-right:6px;border-left:none}:host .zonos--hello-widget.zonos--hello-widget-animate-from-left>.zonos--hello-message{-ms-flex-order:1;order:1;-webkit-transform:translateX(calc(100% - 16px));transform:translateX(calc(100% - 16px));right:0;left:auto;border-top-right-radius:30px;border-bottom-right-radius:30px}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper .zonos--hello-country-flag{height:18px;width:18px;position:relative;overflow:hidden;border-radius:30px;-webkit-box-shadow:var(--zonos-elements-v3-shadow-medium);box-shadow:var(--zonos-elements-v3-shadow-medium);z-index:10;justify-self:center}:host .zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}";export{L as zonos_hello}
|
|
1
|
+
import{r as o,h as e,H as t,a as s}from"./p-b30c2ad9.js";import{d as i}from"./p-0ae53ff0.js";import{l as n,i as l,t as r,g as h,h as a,j as d,k as c,m,d as g}from"./p-65c68531.js";import{z as p,g as w,m as f}from"./p-7ce093aa.js";import{c as z}from"./p-b4b7f705.js";import{h as u,b,l as v}from"./p-d93ecc57.js";import{g as x}from"./p-5883217a.js";import"./p-04a01cb1.js";const y=o=>{const e=null==o?void 0:o.replace("www.","").replace("https://","");return e&&new RegExp(e).test(window.location.href)},k=()=>{var o,e;const{productAddToCartElementSelector:t,productDescriptionElementSelector:s,productTitleElementSelector:i,restrictionBehavior:n}=p.helloSettings;i&&s||v("Hello could not check item restrictions - must provide title and description selectors.");const r=i&&l(i)&&document.querySelectorAll(i)||[],h=s&&l(s)&&document.querySelectorAll(s)||[];if(r.length!==h.length)return v("Hello could not check item restrictions - Title and description selectors do not match"),[];const a="RESTRICT_AND_BLOCK"===n,d=a&&t&&l(t)&&document.querySelectorAll(t)||[];a&&d.length!==h.length&&v('Hello could not disable "Add to cart" buttons - Title and add to cart selectors do not match');const c=[];for(let t=0;t<r.length;t++){const s=r[t],i=h[t];if(s&&i){const n={cartButtonNode:d[t]||null,description:(null===(o=i.textContent)||void 0===o?void 0:o.trim())||"",title:(null===(e=s.textContent)||void 0===e?void 0:e.trim())||""};c.push(n)}}return c},L=class{constructor(e){o(this,e),this.showPeekMessage=!1,this.zonosStoreHelloSettings=p.helloSettings,this.showDialog=!1,this.peekMessage="",this.initialUrl="",this.allRestrictedItems=[],this.allFoundProducts=[],this.productsOnPage=[],this.isHelloWidgetRendered=!1,this.isMobile=!1,this.getHelloPeekMessage=o=>{if(("productDetail"===p.currentHelloPage||"productList"===p.currentHelloPage)&&this.allRestrictedItems.length){const o=r("click to learn more");return`${r("productDetail"===p.currentHelloPage?"Restricted item":"Restricted items found")} - ${o}`}switch(p.currentHelloPage){case"cart":return r("Prepay duties and taxes at checkout");case"productList":case"productDetail":return r("See duty and tax thresholds");default:return r("Welcome to [storeName]",{storeName:o})}},this.enableShowPeekMessage=()=>{this.peekMessage&&(this.showPeekMessage=!0)},this.getNewItemRestrictions=async o=>"productDetail"!==p.currentHelloPage&&"productList"!==p.currentHelloPage||"DISABLED"===p.helloSettings.restrictionBehavior?[]:await(async o=>{if(!o.length)return[];const{selectedCountryCode:e}=n;if(!e)return b("Hello could not check item restrictions - No country code selected"),[];const t=o.map((o=>({description:o.description,name:o.title})));return(await(async({items:o,shipFrom:e,shipTo:t})=>{var s;const i={items:o,shipFrom:e,shipTo:t},{errors:n,json:l}=await u("/api/zonos-elements/check-item-restrictions",{body:i,method:"POST"});return n.length||!l?(b(`Error fetching item restrictions: ${null===(s=n.find(Boolean))||void 0===s?void 0:s.message}`),[]):l.filter(Boolean)})({items:t,shipFrom:"AD",shipTo:e})).map((o=>{var e;const s=(null===(e=t.filter((e=>e.description===o.itemDescription)).find(Boolean))||void 0===e?void 0:e.name)||"";return Object.assign(Object.assign({},o),{name:s})}))})(o),this.triggerShowPeekMessage=()=>{this.peekMessage=this.getHelloPeekMessage(p.organizationName);const{peekMessageBehavior:o,peekMessageDelay:e}=p.helloSettings;"ENABLED"===o&&setTimeout((()=>{this.enableShowPeekMessage(),this.allRestrictedItems.some((o=>this.productsOnPage.some((e=>e.description===o.itemDescription))))||setTimeout((()=>{this.showPeekMessage=!1}),3e3)}),1e3*e)},this.disableAddToCartButtons=()=>{this.productsOnPage.length&&this.productsOnPage.forEach((o=>{var e,t;this.allRestrictedItems.some((e=>e.itemDescription===o.description))?null===(e=o.cartButtonNode)||void 0===e||e.setAttribute("disabled","disabled"):null===(t=o.cartButtonNode)||void 0===t||t.removeAttribute("disabled")}))},this.handleItemRestrictions=async()=>{this.productsOnPage=k();const o=this.productsOnPage.filter((o=>!this.allFoundProducts.some((e=>e.title===o.title)))),e=await this.getNewItemRestrictions(o);this.allRestrictedItems.push(...e),this.allFoundProducts.push(...o),this.disableAddToCartButtons()},this.reloadHelloData=async()=>{await this.handleItemRestrictions(),this.triggerShowPeekMessage()},this.handleProductCountChange=i((()=>{const{productTitleElementSelector:o}=p.helloSettings;if(o){const o=k();if(this.allFoundProducts.length!==o.length&&window.location.href===this.initialUrl){if(!this.allFoundProducts.length)return;this.reloadHelloData()}}}),1e3),this.watchProductCountChange=()=>{var o;const e=new MutationObserver(this.handleProductCountChange);e.observe(document.body,{childList:!0,subtree:!0}),null===(o=this.observerWatcher)||void 0===o||o.push(e)},this.watchPriceChange=()=>{var o;const e=new MutationObserver((()=>{this.displayCurrency()}));e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),null===(o=this.observerWatcher)||void 0===o||o.push(e)},this.updateHelloOnPageChange=()=>{this.watchProductCountChange(),setInterval((()=>{if(window.location.href!==this.initialUrl){const o=this.initialUrl&&new URL(this.initialUrl);(o&&h(o.searchParams))!==n.selectedCountryCode&&(this.allFoundProducts=[],this.allRestrictedItems=[],this.productsOnPage=[]),this.initialUrl=window.location.href,p.currentHelloPage=(()=>{const{cartUrlPattern:o,homepageUrlPattern:e,productDetailUrlPattern:t,productListUrlPattern:s}=p.helloSettings;return y(o)?"cart":y(t)?"productDetail":y(s)?"productList":y(e)?"home":""})();const e=new URL(window.location.href);if(!h(e.searchParams))return void a(n.selectedCountryCode);this.reloadHelloData()}}),1e3)},this.changeShowDialog=o=>{this.showDialog=o},this.shouldAnimateLeftDesktop=()=>{const o=this.helloRef&&getComputedStyle(this.helloRef).position;if(this.helloRef&&"relative"===o)return x(this.helloRef)},this.shouldRenderHello=(o=!0)=>{if(!n.localizationLoaded)return!1;const{showForCountries:e}=p.helloSettings;return o&&(n.isShippableCountry||v(`Hello: not shippable country - Show for countries: ${e}`)),"ONLY_SHIPPABLE"===e?n.isShippableCountry:"ALL"===e||(null==e?void 0:e.includes(n.selectedCountryCode||""))}}showDialogHandler(o){var e;if(o){const o=null===(e=this.helloElement)||void 0===e?void 0:e.parentElement;o&&o.parentElement===document.body&&(o.style.zIndex="2147483647",document.body.appendChild(o))}}async getCountryList(){return n.helloCountryList}componentWillLoad(){const o=setInterval((async()=>{this.helloRef&&p.loadedConfig&&(this.helloRef.setAttribute("data-zonos-hello-loaded",""),this.updateHelloOnPageChange(),this.watchPriceChange(),this.handleAppearanceSettingsOverrideChange(),clearInterval(o))}),100)}disconnectedCallback(){var o;null===(o=this.observerWatcher)||void 0===o||o.forEach((o=>o.disconnect()))}async displayCurrency(){"DISABLED"!==p.helloSettings.currencyBehavior&&(n.exchangeRate?d():v("Could not display currency. Exchange rate and format data is not available.","warn"))}async convertAndFormat(o){return c(o)}async convert(o){return m(o)}async format(o){return g({amount:o})}async openHelloDialog(o){this.changeShowDialog(o)}handleResize(){this.isMobile=window.innerWidth<=768}handleHelloWidgetInitializedState({countryCode:o,currencyCode:e}){var t,s;this.isHelloWidgetRendered||n.selectedCountryCode&&"function"==typeof p.helloSettings.onInitSuccess&&(this.isHelloWidgetRendered=!0,null===(s=(t=p.helloSettings).onInitSuccess)||void 0===s||s.call(t,{countryCode:o,currencyCode:e}))}getHelloLocation(){const o=this.mobileLocationOverride||p.helloSettings.mobileLocation,e=p.helloSettings.desktopLocation,t=this.isMobile;if(!0===t)return{isMobileWindow:t,isOnLeft:this.animateFromLeftOverride||(null==o?void 0:o.includes("LEFT")),isOnTop:null==o?void 0:o.includes("TOP"),shouldFloat:!!o};{const o=!p.helloSettings.anchorElementSelector&&!!e;return{isMobileWindow:t,isOnLeft:this.animateFromLeftOverride||(null==e?void 0:e.includes("LEFT"))||this.shouldAnimateLeftDesktop(),isOnTop:null==e?void 0:e.includes("TOP"),shouldFloat:o}}}handleAppearanceSettingsOverrideChange(){var o;(null===(o=this.appearanceSettingsOverride)||void 0===o?void 0:o.theme)&&(this.appearanceSettingsOverride.theme=w(this.appearanceSettingsOverride.theme))}componentDidLoad(){this.isMobile=window.innerWidth<=768}render(){var o,s;if(null===(o=p.helloSettings.excludedUrlPatterns)||void 0===o?void 0:o.some((o=>o&&new RegExp(o).test(window.location.href))))return v("Hello is excluded on this url","warn"),null;const{selectedCountryCode:i,targetCurrency:l}=n,{isOnLeft:r,isOnTop:h,shouldFloat:a}=this.getHelloLocation(),d=f(p.appearance,this.appearanceSettingsOverride||null),{theme:c}=d,m=null===(s=this.allRestrictedItems)||void 0===s?void 0:s.filter((o=>this.productsOnPage.some((e=>e.description===o.itemDescription))));this.peekMessage=this.getHelloPeekMessage(p.organizationName);const g=this.shouldRenderHello()&&!!i;return g&&!this.isHelloWidgetRendered&&this.handleHelloWidgetInitializedState({countryCode:i,currencyCode:l}),e(t,{class:"zonos--hello zonos--elements","data-theme":c},g&&e("div",{class:z(["zonos--hello-wrapper",a&&"zonos--hello-widget-float"])},e("button",{class:z(["zonos--hello-widget",this.showPeekMessage&&"zonos--hello-show-peek-message",this.mobileLocationOverride&&"zonos--hello-mobile-override",r&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",h&&"zonos--hello-widget-top",!!this.allRestrictedItems.length&&"zonos--hello-has-restrictions",a&&"zonos--hello-widget-float"]),onClick:()=>{this.changeShowDialog(!this.showDialog)},onMouseEnter:()=>this.enableShowPeekMessage(),onMouseLeave:()=>this.showPeekMessage=!1,ref:o=>o&&(this.helloRef=o),type:"button"},e("zonos-text",{class:"zonos--hello-message"},this.peekMessage),i&&e("div",{class:"zonos--hello-country-flag-wrapper"},e("zonos-country-flag",{class:"zonos--hello-country-flag",countryCode:i}))),e("div",{class:z(["zonos--hello-dialog-wrapper",this.mobileLocationOverride&&"zonos--hello-dialog-wrapper-mobile-override",a&&"zonos--hello-widget-float"]),style:{height:this.showDialog?"fit-content":"0px"}},e("zonos-hello-dialog",{animateFromLeftOverride:this.animateFromLeftOverride,appearanceSettings:d,isOpen:this.showDialog,mobileLocationOverride:this.mobileLocationOverride,restrictedItems:m,setIsOpen:this.changeShowDialog}))))}get helloElement(){return s(this)}static get watchers(){return{showDialog:["showDialogHandler"],appearanceSettingsOverride:["handleAppearanceSettingsOverrideChange"]}}};L.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:inline-block}:host .zonos--hello-wrapper{position:relative}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper-mobile-override{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media (max-width: 768px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}}:host .zonos--hello-widget{-webkit-transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);padding:6px;border-radius:30px;background:var(--zonos-elements-page-background);font-size:var(--zonos-elements-font-size-s);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;cursor:pointer;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;position:relative;z-index:1000}:host .zonos--hello-widget>.zonos--hello-message{-ms-flex-order:0;order:0;max-width:0;height:100%;white-space:nowrap;-webkit-transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);overflow:hidden;color:var(--zonos-elements-text-color);position:absolute;background:var(--zonos-elements-page-background);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top-left-radius:30px;border-bottom-left-radius:30px;left:0;-webkit-transform:translateX(calc(-100% + 16px));transform:translateX(calc(-100% + 16px));width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border-top:var(--zonos-elements-border);border-bottom:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-has-restrictions{background:var(--zonos-elements-red-100);border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-has-restrictions>.zonos--hello-message{background:var(--zonos-elements-red-100);color:var(--zonos-elements-red-800);font-weight:500}:host .zonos--hello-widget.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-show-peek-message{max-width:100vw;width:100%}:host .zonos--hello-widget.zonos--hello-show-peek-message>.zonos--hello-message{max-width:100vw;padding:0 6px;padding-right:16px;border:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-show-peek-message:not(.zonos--hello-widget-animate-from-left)>.zonos--hello-message{border-right:none}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{border-left:0}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:16px;padding-right:6px;border-left:none}:host .zonos--hello-widget.zonos--hello-widget-animate-from-left>.zonos--hello-message{-ms-flex-order:1;order:1;-webkit-transform:translateX(calc(100% - 16px));transform:translateX(calc(100% - 16px));right:0;left:auto;border-top-right-radius:30px;border-bottom-right-radius:30px}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper .zonos--hello-country-flag{height:18px;width:18px;position:relative;overflow:hidden;border-radius:30px;-webkit-box-shadow:var(--zonos-elements-v3-shadow-medium);box-shadow:var(--zonos-elements-v3-shadow-medium);z-index:10;justify-self:center}:host .zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}";export{L as zonos_hello}
|