storyly-web 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -9
- package/dist/storyly-web.css +1 -1
- package/dist/storyly-web.js +11 -9
- package/index.html +9 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -108,7 +108,7 @@ var e=require("./arrayWithHoles.js"),r=require("./iterableToArray.js"),o=require
|
|
|
108
108
|
},{}],"XhEk":[function(require,module,exports) {
|
|
109
109
|
module.exports={USD:"$",AED:"د.إ",AFN:"؋",ALL:"L",AMD:"֏",ANG:"ƒ",AOA:"Kz",ARS:"$",AUD:"$",AWG:"ƒ",AZN:"₼",BAM:"KM",BBD:"$",BDT:"৳",BGN:"лв",BHD:".د.ب",BIF:"FBu",BMD:"$",BND:"$",BOB:"$b",BOV:"BOV",BRL:"R$",BSD:"$",BTC:"₿",BTN:"Nu.",BWP:"P",BYN:"Br",BYR:"Br",BZD:"BZ$",CAD:"$",CDF:"FC",CHE:"CHE",CHF:"CHF",CHW:"CHW",CLF:"CLF",CLP:"$",CNH:"¥",CNY:"¥",COP:"$",COU:"COU",CRC:"₡",CUC:"$",CUP:"₱",CVE:"$",CZK:"Kč",DJF:"Fdj",DKK:"kr",DOP:"RD$",DZD:"دج",EEK:"kr",EGP:"£",ERN:"Nfk",ETB:"Br",ETH:"Ξ",EUR:"€",FJD:"$",FKP:"£",GBP:"£",GEL:"₾",GGP:"£",GHC:"₵",GHS:"GH₵",GIP:"£",GMD:"D",GNF:"FG",GTQ:"Q",GYD:"$",HKD:"$",HNL:"L",HRK:"kn",HTG:"G",HUF:"Ft",IDR:"Rp",ILS:"₪",IMP:"£",INR:"₹",IQD:"ع.د",IRR:"﷼",ISK:"kr",JEP:"£",JMD:"J$",JOD:"JD",JPY:"¥",KES:"KSh",KGS:"лв",KHR:"៛",KMF:"CF",KPW:"₩",KRW:"₩",KWD:"KD",KYD:"$",KZT:"₸",LAK:"₭",LBP:"£",LKR:"₨",LRD:"$",LSL:"M",LTC:"Ł",LTL:"Lt",LVL:"Ls",LYD:"LD",MAD:"MAD",MDL:"lei",MGA:"Ar",MKD:"ден",MMK:"K",MNT:"₮",MOP:"MOP$",MRO:"UM",MRU:"UM",MUR:"₨",MVR:"Rf",MWK:"MK",MXN:"$",MXV:"MXV",MYR:"RM",MZN:"MT",NAD:"$",NGN:"₦",NIO:"C$",NOK:"kr",NPR:"₨",NZD:"$",OMR:"﷼",PAB:"B/.",PEN:"S/.",PGK:"K",PHP:"₱",PKR:"₨",PLN:"zł",PYG:"Gs",QAR:"﷼",RMB:"¥",RON:"lei",RSD:"Дин.",RUB:"₽",RWF:"R₣",SAR:"﷼",SBD:"$",SCR:"₨",SDG:"ج.س.",SEK:"kr",SGD:"S$",SHP:"£",SLL:"Le",SOS:"S",SRD:"$",SSP:"£",STD:"Db",STN:"Db",SVC:"$",SYP:"£",SZL:"E",THB:"฿",TJS:"SM",TMT:"T",TND:"د.ت",TOP:"T$",TRL:"₤",TRY:"₺",TTD:"TT$",TVD:"$",TWD:"NT$",TZS:"TSh",UAH:"₴",UGX:"USh",UYI:"UYI",UYU:"$U",UYW:"UYW",UZS:"лв",VEF:"Bs",VES:"Bs.S",VND:"₫",VUV:"VT",WST:"WS$",XAF:"FCFA",XBT:"Ƀ",XCD:"$",XOF:"CFA",XPF:"₣",XSU:"Sucre",XUA:"XUA",YER:"﷼",ZAR:"R",ZMW:"ZK",ZWD:"Z$",ZWL:"$"};
|
|
110
110
|
},{}],"PesM":[function(require,module,exports) {
|
|
111
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setClickEventListener=exports.setAttribute=exports.removeClickEventListener=exports.removeAttribute=exports.randomAlphaNum=exports.productEventPayloadHandler=exports.openProductDetail=exports.openLink=exports.objectLength=exports.kFormatter=exports.isVideoPlaying=exports.isStringHTML=exports.isMobileView=exports.isLiveVideo=exports.isIphone=exports.isHexColor=exports.isArraysEqual=exports.imageAnimationHandler=exports.getTransformString=exports.getTextLines=exports.getStoryMedia=exports.getStoryAssetFromLayers=exports.getProductLayers=exports.getFontFamily=exports.getContrastBgColor=exports.getBrowser=exports.getAssetRatio=exports.generateHtmlFromTemplate=exports.domShow=exports.domHide=exports.decodeJwt=exports.debounce=exports.currencyFormatter=exports.createAndDispatchEvent=exports.copyToClipboard=exports.convertHex=exports.closeProductDetail=exports.checkProductCatalogAtLeastOne=exports.calculateCountdownTimes=exports.calcBorderRadius=void 0,exports.shuffleArray=Y,exports.videoHasAudio=exports.updateStorylyUrlParams=exports.storyBackgroundColorHandler=exports.stopEventBubbling=exports.splitTime=void 0;var t=u(require("@babel/runtime/helpers/defineProperty")),e=u(require("@babel/runtime/helpers/toArray")),r=u(require("@babel/runtime/helpers/toConsumableArray")),o=u(require("../constants/layouts")),n=u(require("./proxy")),a=require("../constants/layerTypes"),i=u(require("./storage")),s=u(require("./currencies")),c=void 0;function u(t){return t&&t.__esModule?t:{default:t}}function l(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,o)}return r}function p(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?l(Object(o),!0).forEach(function(r){(0,t.default)(e,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):l(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}var d=exports.setAttribute=function(t,e,r){t.setAttribute(e,r)},f=exports.removeAttribute=function(t,e){t.removeAttribute(e)},g=exports.generateHtmlFromTemplate=function(t){var e=document.createElement("template");return e.innerHTML=t,e.content.firstElementChild.cloneNode(!0)},m=exports.objectLength=function(t){return Object.keys(t).length},h=exports.randomAlphaNum=function(t){for(var e="0123456789ABCDEFGHIJKLMNOPQRSTUWVXYZabcdefghijklmnoprqstuwvxyz",r="",o=0;o<t;o+=1)r+=e[Math.floor(Math.random()*e.length)];return r},v=exports.isMobileView=function(){return(/mobile/i.test(navigator.userAgent)||window.innerWidth<481)&&!/ipad|tablet/i.test(navigator.userAgent)},y=exports.isHexColor=function(t){return/^#[0-9A-F]{6}[0-9a-f]{0,2}$/i.test(t)},x=exports.convertHex=function(t,e){var r=t.substring(1,3),o=t.substring(3,9),n={FF:100,FC:99,FA:98,F7:97,F5:96,F2:95,F0:94,ED:93,EB:92,E8:91,E6:90,E3:89,E0:88,DE:87,DB:86,D9:85,D6:84,D4:83,D1:82,CF:81,CC:80,C9:79,C7:78,C4:77,C2:76,BF:75,BD:74,BA:73,B8:72,B5:71,B3:70,B0:69,AD:68,AB:67,A8:66,A6:65,A3:64,A1:63,"9E":62,"9C":61,99:60,96:59,94:58,91:57,"8F":56,"8C":55,"8A":54,87:53,85:52,82:51,80:50,"7D":49,"7A":48,78:47,75:46,73:45,70:44,"6E":43,"6B":42,69:41,66:40,63:39,61:38,"5E":37,"5C":36,59:35,57:34,54:33,52:32,"4F":31,"4D":30,"4A":29,47:28,45:27,42:26,40:25,"3D":24,"3B":23,38:22,36:21,33:20,30:19,"2E":18,"2B":17,29:16,26:15,24:14,21:13,"1F":12,"1C":11,"1A":10,17:9,14:8,12:7,"0F":6,"0D":5,"0A":4,"08":3,"05":2,"03":1,"00":0}[r.toLocaleUpperCase()],a=parseInt(o.substring(0,2),16),i=parseInt(o.substring(2,4),16),s=parseInt(o.substring(4,6),16);return"rgba(".concat(a,", ").concat(i,", ").concat(s,", ").concat(null!=e?e:n/100,")")},b=exports.getBrowser=function(){var t=function(t){return t.test(window.navigator.userAgent)};switch(!0){case t(/edg/i):return"edge";case t(/trident/i):return"explorer";case t(/firefox|fxios/i):return"firefox";case t(/opr\//i):return"opera";case t(/ucbrowser/i):return"uc_browser";case t(/samsungbrowser/i):return"samsung_browser";case t(/chrome|chromium|crios/i):return"chrome";case t(/safari/i):return"safari";default:return"other"}},A=exports.stopEventBubbling=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"click",r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t.addEventListener(e,function(t){t.stopPropagation(),r&&t.preventDefault(),t.stopImmediatePropagation()})},C=exports.createAndDispatchEvent=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],n=new CustomEvent(e,{detail:r,bubbles:o});t.dispatchEvent(n)},w=exports.domHide=function(t){return d(t,"hidden",!0)},_=exports.domShow=function(t){return f(t,"hidden")},T=exports.isIphone=function(){return window.navigator.userAgent.toLocaleLowerCase().includes("iphone")},L=exports.splitTime=function(t){return(t<0?0:t).toString().padStart(2,"0").split("")},D=exports.openLink=function(t){var e=t.match(/(http|https|:\/\/)/g)?t:"http://".concat(t);v()?window.location.href=e:window.open(e,"_blank")},F=exports.copyToClipboard=function(t){if(window.clipboardData&&window.clipboardData.setData)return window.clipboardData.setData("Text",t);var e=document.createElement("textarea");e.textContent=t,e.style.position="fixed",document.body.appendChild(e),e.select(),e.setSelectionRange(0,99999);try{return navigator.clipboard.writeText(e.value)}catch(r){return window.prompt("Copy to clipboard: Ctrl+C, Enter",t)}finally{document.body.removeChild(e)}},E=exports.debounce=function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return function(){for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];clearTimeout(e),e=setTimeout(function(){t.apply(c,n)},r)}},O=exports.getAssetRatio=function(t,e){return new Promise(function(r){if("video"===e){var o=document.createElement("video");return o.addEventListener("loadedmetadata",function(){r({asset:o,width:o.videoWidth,height:o.videoHeight})}),void(o.src=t)}var n=new Image;n.src=t,n.onload=function(){r({asset:n,width:n.width,height:n.height})}})},S=exports.getFontFamily=function(t){var e=t.font,o=t.instanceId,a=n.default.getNodeByInstanceId(o).getDataFromGlobal().globalInstanceData;if(!a.properties)return"";var i=a.properties.storyTextFont,s=["Storyly-Inter"];return!e||s.includes(e)&&i?(0,r.default)(new Set([i,e].concat(s,["sans-serif"]))).filter(Boolean).join(", "):e},B=exports.isStringHTML=function(t){return"string"==typeof t&&!t.replace(/<([^>]+?)([^>]*?)>(.*?)<\/\1>/gi,"").replace(/(<([^>]+)>)/gi,"").trim()},P=exports.decodeJwt=function(t){return JSON.parse(atob(t.split(".")[1]))},R=exports.setClickEventListener=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];window.navigator.maxTouchPoints>0?t.addEventListener("pointerdown",e,r):t.addEventListener("click",e,r)},k=exports.removeClickEventListener=function(t,e){window.navigator.maxTouchPoints>0?t.removeEventListener("pointerdown",e):t.removeEventListener("click",e)},I=exports.storyBackgroundColorHandler=function(t,e){return(null==t?void 0:t.length)>1?"linear-gradient(to bottom, ".concat(t.join(", "),")"):e?x(e):"#000"},M=exports.getStoryAssetFromLayers=function(t){var r,o=t.find(function(t){return"studio_main_layer"===t.studio_component_type}),n=null!==(r=t.find(function(t){return t.is_bg}))&&void 0!==r?r:{bg_color:"#FF000000"},a=t.filter(function(t){return"studio_main_layer"!==t.studio_component_type&&!t.is_bg}),i=o;if(!o){var s=(0,e.default)(t);i=s[0],a=s.slice(1)}return{storyData:i,layers:a,storyBg:p(p({},n),{},{bg_color:I(n.gradient_colors,n.bg_color)})}};function j(){}j.prototype={fontSize:14,rgbClass:{toString:function(){return"<r: ".concat(this.r," g: ").concat(this.g," b: ").concat(this.b," >")}},isValidSixDigitColorCode:function(t){return/^(#)?([0-9a-fA-F]{6})?$/.test(t)},isValidThreeDigitColorCode:function(t){return/^(#)?([0-9a-fA-F]{3})?$/.test(t)},isValidColorCode:function(t){return this.isValidSixDigitColorCode(t)||this.isValidThreeDigitColorCode(t)},isValidRatio:function(t){return"number"==typeof t},convertColorToSixDigit:function(t){return"#".concat(t[1]).concat(t[1]).concat(t[2]).concat(t[2]).concat(t[3]).concat(t[3])},hexToLuminance:function(t){if(!this.isValidColorCode(t))throw new Error("Invalid Color :".concat(t));this.isValidThreeDigitColorCode(t)&&(t=this.convertColorToSixDigit(t)),t=this.getRGBFromHex(t);var e=this.calculateLRGB(t);return this.calculateLuminance(e)},check:function(t,e,r,o){if(void 0!==r&&(this.fontSize=r),!t||!e)return!1;var n=this.hexToLuminance(t),a=this.hexToLuminance(e),i=this.getContrastRatio(n,a);return void 0!==o?!!this.isValidRatio(o)&&this.verifyCustomContrastRatio(i,o):this.verifyContrastRatio(i)},calculateLuminance:function(t){return.2126*t.r+.7152*t.g+.0722*t.b},isLevelAA:function(t,e,r){return this.check(t,e,r).WCAG_AA},isLevelAAA:function(t,e,r){return this.check(t,e,r).WCAG_AAA},isLevelCustom:function(t,e,r){return this.check(t,e,void 0,r).customRatio},getRGBFromHex:function(t){var e=Object.create(this.rgbClass);if("string"!=typeof t)throw new Error("must use string");var r=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return e.r=r,e.g=o,e.b=n,e},calculateSRGB:function(t){var e,r=Object.create(this.rgbClass);for(e in t)t.hasOwnProperty(e)&&(r[e]=parseFloat(t[e]/255,10));return r},calculateLRGB:function(t){var e,r=this.calculateSRGB(t),o=Object.create(this.rgbClass),n=0;for(e in r)r.hasOwnProperty(e)&&(n=parseFloat(r[e],10),o[e]=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4));return o},getContrastRatio:function(t,e){var r,o;return t>=e?(r=t,o=e):(r=e,o=t),(r+.05)/(o+.05)},verifyContrastRatio:function(t){var e=Object.create({toString:function(){return"< WCAG-AA: ".concat(this.WCAG_AA?"pass":"fail"," WCAG-AAA: ").concat(this.WCAG_AAA?"pass":"fail"," >")}});return(this.fontSize||14)>=18?(e.WCAG_AA=t>=3,e.WCAG_AAA=t>=4.5):(e.WCAG_AA=t>=4.5,e.WCAG_AAA=t>=7),e},verifyCustomContrastRatio:function(t,e){var r=Object.create({toString:function(){return"< Custom Ratio: ".concat(this.customRatio?"pass":"fail"," >")}});return r.customRatio=t>=e,r}};var H=exports.getContrastBgColor=function(t){var e=new j;if(!t||3!==t.length&&6!==t.length&&9!==t.length)return"#ff000000";var r=e.hexToLuminance("#".concat("#ff000000".slice(3))),o=e.hexToLuminance("#".concat("#ffffffff".slice(3))),n=e.hexToLuminance("#".concat(null==t?void 0:t.slice(3)));return e.getContrastRatio(r,n)>e.getContrastRatio(o,n)?"#ff000000":"#ffffffff"},G=exports.openProductDetail=function(t){return n.default.getNodeByInstanceId(t).getDataFromGlobal().globalInstanceData.layout===o.default.MODERN?"onModalToggle":"onBottomSheetOpen"},q=exports.closeProductDetail=function(t){return n.default.getNodeByInstanceId(t).getDataFromGlobal().globalInstanceData.layout===o.default.MODERN?"onModalToggle":"onBottomSheetClose"},V=exports.isArraysEqual=function(t,e){return t.length===e.length&&t.every(function(t,r){return t===e[r]})},W=exports.kFormatter=function(t){var e=t||0;return e<1e3?e:e>=1e3&&e<1e6?"".concat(+(e/1e3).toFixed(),"k"):e>=1e6&&e<1e9?"".concat(+(e/1e6).toFixed(),"m"):e>=1e9&&e<1e12?"".concat(+(e/1e9).toFixed(),"b"):e>=1e12?"".concat(+(e/1e12).toFixed(),"t"):e},N=exports.currencyFormatter=function(t,e){var r=Object.values(s.default).findIndex(function(t){return t===e}),o=Object.keys(s.default)[r];return new Intl.NumberFormat(Intl.NumberFormat.supportedLocalesOf(navigator.languages||navigator.language,{localeMatcher:"lookup"}),{style:"currency",currency:o||e,currencyDisplay:o?"narrowSymbol":"symbol"}).format(t)},U=exports.calcBorderRadius=function(t,e){var r,o=parseFloat(t.h)*e.offsetHeight/100;return(null!==(r=t.border_radius)&&void 0!==r?r:0)*(o/2)},z=exports.getProductLayers=function(t){var e=[a.LayerTemplateTypes.PRODUCT_CATALOG,a.LayerTemplateTypes.PRODUCT_TAG,a.LayerTemplateTypes.PRODUCT_CARD,a.LayerTemplateTypes.IMAGE_CTA,a.LayerTemplateTypes.SWIPE,a.LayerTemplateTypes.BUTTON];return(t.media?t.media.layers:t.stories.flatMap(function(t){return t.media}).flatMap(function(t){return t.layers})).filter(function(t){return e.includes(t.type)&&t.products})},J=exports.checkProductCatalogAtLeastOne=function(t,e){var r=t.filter(function(t){return t.type===a.LayerTemplateTypes.PRODUCT_CATALOG});if(!r.length)return!0;for(var o=!0,n=0;n<r.length;n+=1){if(!r[n].products.some(function(t){return e.some(function(e){return e.product_group_id===t.product_group_id})})){o=!1;break}}return o},$=exports.calculateCountdownTimes=function(t){var e=t/864e5,r=e%1*24,o=r%1*60,n=o%1*60,a=[Math.floor(e),Math.floor(r),Math.floor(o),Math.floor(n)];return[e=a[0],r=a[1],o=a[2],n=a[3]]},X=exports.isLiveVideo=function(t){return"live"===t};function Y(t){for(var e=(0,r.default)(t),o=e.length-1;o>0;o-=1){var n=Math.floor(Math.random()*(o+1)),a=[e[n],e[o]];e[o]=a[0],e[n]=a[1]}return e}var K=exports.productEventPayloadHandler=function(t){var e=i.default.getItemFromGlobal("Storyly_userConfig");return{account_id:t.account_id,id:t.id,p_id:t.product_id,p_group_id:t.product_group_id,title:t.title,url:t.url,image_urls:t.image_urls,price:t.price,total_price:(t.sales_price||t.price)*t.quantity,sales_price:t.sales_price,currency:t.price_currency,quantity:t.quantity,language:e.language,country:e.country}},Q=exports.imageAnimationHandler=function(t,e){var r=Array.from(t.querySelectorAll(e));requestAnimationFrame(function t(){var e=!0;r.forEach(function(t){if(!t.classList.contains("storyly__animate-image-horizontal")&&!t.classList.contains("storyly__animate-image-vertical")){var r=t.clientWidth,o=t.clientHeight,n=t.naturalWidth,a=t.naturalHeight;if(r&&o){var i=r/o,s=n/a,c=Math.abs(100*(s/i-1));i===s||c<=2||(s>i?t.classList.add("storyly__animate-image-horizontal"):t.classList.add("storyly__animate-image-vertical"))}else e=!1}}),e||requestAnimationFrame(t)})},Z=exports.videoHasAudio=function(t){var e;return!!t&&(t.mozHasAudio||Boolean(t.webkitAudioDecodedByteCount)||Boolean(null===(e=t.audioTracks)||void 0===e?void 0:e.length))},tt=exports.getTextLines=function(t){var e=t.innerText.replace(/\s+/gm," ").trim().split(" "),r=e.map(function(t){return'<span style="display: inline-block;">'.concat(t," </span>")});t.innerHTML=r.join(" ");var o=[],n=null,a=[];return t.querySelectorAll("span").forEach(function(t,r){var i=t.getBoundingClientRect();n!==i.top&&r>0?(o.push(a),a=[e[r]]):a.push(e[r]),n=i.top}),o.push(a),o.map(function(t){return t.join(" ")})},et=exports.getStoryMedia=function(t){var e=t.host,r=t.story,o=t.path,n="";if(o)n=null!=o&&o.match(/(http|https|:\/\/)/g)?o:"".concat(e).concat(o);else{var a=r.image_path,i=r.video_path,s=r.video_url,c=r.image_url;n=c||s?null!=c?c:s:null!=a&&a.match(/(http|https|:\/\/)/g)?a:null!=i&&i.match(/(http|https|:\/\/)/g)?i:"".concat(e).concat(null!=a?a:i)}return n},rt=exports.getTransformString=function(t,e,r){var o="rotate(".concat(t.r?e+(t.r||0):e,"deg)"),n=t.s?"scale(".concat(t.s,")"):"",a=function(t){return r?"".concat(t,"%"):"".concat(t/6,"em")},i="translateX(".concat(t.x?a(t.x):0,")"),s="translateY(".concat(t.y?a(t.y):0,")");return"".concat(i," ").concat(s," ").concat(o," ").concat(n)},ot=exports.isVideoPlaying=function(t){return t.currentTime>0&&!t.paused&&!t.ended&&t.readyState>2},nt=exports.updateStorylyUrlParams=function(t,e,r){if(!Object.keys(r).length||r.resumeStory){var o=new URLSearchParams(window.location.search);o.set("storyly","[".concat(t,", ").concat(e,"]")),o.set("storylyResume","1"),window.history.replaceState({},"","".concat(window.location.pathname,"?").concat(o))}};
|
|
111
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setClickEventListener=exports.setAttribute=exports.removeClickEventListener=exports.removeAttribute=exports.randomAlphaNum=exports.productEventPayloadHandler=exports.openProductDetail=exports.openLink=exports.objectLength=exports.kFormatter=exports.isVideoPlaying=exports.isStringHTML=exports.isMobileView=exports.isLiveVideo=exports.isIphone=exports.isHexColor=exports.isArraysEqual=exports.imageAnimationHandler=exports.getTransformString=exports.getTextLines=exports.getStoryMedia=exports.getStoryAssetFromLayers=exports.getProductLayers=exports.getFontFamily=exports.getContrastBgColor=exports.getBrowser=exports.getAssetRatio=exports.generateHtmlFromTemplate=exports.domShow=exports.domHide=exports.decodeJwt=exports.debounce=exports.currencyFormatter=exports.createAndDispatchEvent=exports.copyToClipboard=exports.convertHex=exports.closeProductDetail=exports.checkProductCatalogAtLeastOne=exports.calculateCountdownTimes=exports.calcBorderRadius=void 0,exports.shuffleArray=Y,exports.videoHasAudio=exports.updateStorylyUrlParams=exports.storyBackgroundColorHandler=exports.stopEventBubbling=exports.splitTime=void 0;var t=u(require("@babel/runtime/helpers/defineProperty")),e=u(require("@babel/runtime/helpers/toArray")),r=u(require("@babel/runtime/helpers/toConsumableArray")),o=u(require("../constants/layouts")),n=u(require("./proxy")),a=require("../constants/layerTypes"),i=u(require("./storage")),s=u(require("./currencies")),c=void 0;function u(t){return t&&t.__esModule?t:{default:t}}function l(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,o)}return r}function p(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?l(Object(o),!0).forEach(function(r){(0,t.default)(e,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):l(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}var d=exports.setAttribute=function(t,e,r){t.setAttribute(e,r)},f=exports.removeAttribute=function(t,e){t.removeAttribute(e)},g=exports.generateHtmlFromTemplate=function(t){var e=document.createElement("template");return e.innerHTML=t,e.content.firstElementChild.cloneNode(!0)},m=exports.objectLength=function(t){return Object.keys(t).length},h=exports.randomAlphaNum=function(t){for(var e="0123456789ABCDEFGHIJKLMNOPQRSTUWVXYZabcdefghijklmnoprqstuwvxyz",r="",o=0;o<t;o+=1)r+=e[Math.floor(Math.random()*e.length)];return r},v=exports.isMobileView=function(){return(/mobile/i.test(navigator.userAgent)||window.innerWidth<481)&&!/ipad|tablet/i.test(navigator.userAgent)},y=exports.isHexColor=function(t){return/^#[0-9A-F]{6}[0-9a-f]{0,2}$/i.test(t)},x=exports.convertHex=function(t,e){var r=t.substring(1,3),o=t.substring(3,9),n={FF:100,FC:99,FA:98,F7:97,F5:96,F2:95,F0:94,ED:93,EB:92,E8:91,E6:90,E3:89,E0:88,DE:87,DB:86,D9:85,D6:84,D4:83,D1:82,CF:81,CC:80,C9:79,C7:78,C4:77,C2:76,BF:75,BD:74,BA:73,B8:72,B5:71,B3:70,B0:69,AD:68,AB:67,A8:66,A6:65,A3:64,A1:63,"9E":62,"9C":61,99:60,96:59,94:58,91:57,"8F":56,"8C":55,"8A":54,87:53,85:52,82:51,80:50,"7D":49,"7A":48,78:47,75:46,73:45,70:44,"6E":43,"6B":42,69:41,66:40,63:39,61:38,"5E":37,"5C":36,59:35,57:34,54:33,52:32,"4F":31,"4D":30,"4A":29,47:28,45:27,42:26,40:25,"3D":24,"3B":23,38:22,36:21,33:20,30:19,"2E":18,"2B":17,29:16,26:15,24:14,21:13,"1F":12,"1C":11,"1A":10,17:9,14:8,12:7,"0F":6,"0D":5,"0A":4,"08":3,"05":2,"03":1,"00":0}[r.toLocaleUpperCase()],a=parseInt(o.substring(0,2),16),i=parseInt(o.substring(2,4),16),s=parseInt(o.substring(4,6),16);return"rgba(".concat(a,", ").concat(i,", ").concat(s,", ").concat(null!=e?e:n/100,")")},b=exports.getBrowser=function(){var t=function(t){return t.test(window.navigator.userAgent)};switch(!0){case t(/edg/i):return"edge";case t(/trident/i):return"explorer";case t(/firefox|fxios/i):return"firefox";case t(/opr\//i):return"opera";case t(/ucbrowser/i):return"uc_browser";case t(/samsungbrowser/i):return"samsung_browser";case t(/chrome|chromium|crios/i):return"chrome";case t(/safari/i):return"safari";default:return"other"}},A=exports.stopEventBubbling=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"click",r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t.addEventListener(e,function(t){t.stopPropagation(),r&&t.preventDefault(),t.stopImmediatePropagation()})},C=exports.createAndDispatchEvent=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],n=new CustomEvent(e,{detail:r,bubbles:o});t.dispatchEvent(n)},w=exports.domHide=function(t){return d(t,"hidden",!0)},_=exports.domShow=function(t){return f(t,"hidden")},T=exports.isIphone=function(){return window.navigator.userAgent.toLocaleLowerCase().includes("iphone")},L=exports.splitTime=function(t){return(t<0?0:t).toString().padStart(2,"0").split("")},D=exports.openLink=function(t){var e=t.match(/(http|https|:\/\/)/g)?t:"http://".concat(t);v()?window.location.href=e:window.open(e,"_blank")},F=exports.copyToClipboard=function(t){if(window.clipboardData&&window.clipboardData.setData)return window.clipboardData.setData("Text",t);var e=document.createElement("textarea");e.textContent=t,e.style.position="fixed",document.body.appendChild(e),e.select(),e.setSelectionRange(0,99999);try{return navigator.clipboard.writeText(e.value)}catch(r){return window.prompt("Copy to clipboard: Ctrl+C, Enter",t)}finally{document.body.removeChild(e)}},E=exports.debounce=function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return function(){for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];clearTimeout(e),e=setTimeout(function(){t.apply(c,n)},r)}},O=exports.getAssetRatio=function(t,e){return new Promise(function(r){if("video"===e){var o=document.createElement("video");return o.addEventListener("loadedmetadata",function(){r({asset:o,width:o.videoWidth,height:o.videoHeight})}),void(o.src=t)}var n=new Image;n.src=t,n.onload=function(){r({asset:n,width:n.width,height:n.height})}})},S=exports.getFontFamily=function(t){var e=t.font,o=t.instanceId,a=n.default.getNodeByInstanceId(o).getDataFromGlobal().globalInstanceData;if(!a.properties)return"";var i=a.properties.storyTextFont,s=["Storyly-Inter"];return!e||s.includes(e)&&i?(0,r.default)(new Set([i,e].concat(s,["sans-serif"]))).filter(Boolean).join(", "):e},B=exports.isStringHTML=function(t){return"string"==typeof t&&!t.replace(/<([^>]+?)([^>]*?)>(.*?)<\/\1>/gi,"").replace(/(<([^>]+)>)/gi,"").trim()},P=exports.decodeJwt=function(t){return JSON.parse(atob(t.split(".")[1]))},R=exports.setClickEventListener=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];window.navigator.maxTouchPoints>0?t.addEventListener("pointerdown",e,r):t.addEventListener("click",e,r)},k=exports.removeClickEventListener=function(t,e){window.navigator.maxTouchPoints>0?t.removeEventListener("pointerdown",e):t.removeEventListener("click",e)},I=exports.storyBackgroundColorHandler=function(t,e){return(null==t?void 0:t.length)>1?"linear-gradient(to bottom, ".concat(t.join(", "),")"):e?x(e):"#000"},M=exports.getStoryAssetFromLayers=function(t){var r,o=t.find(function(t){return"studio_main_layer"===t.studio_component_type}),n=null!==(r=t.find(function(t){return t.is_bg}))&&void 0!==r?r:{bg_color:"#FF000000"},a=t.filter(function(t){return"studio_main_layer"!==t.studio_component_type&&!t.is_bg}),i=o;if(!o){var s=(0,e.default)(t);i=s[0],a=s.slice(1)}return{storyData:i,layers:a,storyBg:p(p({},n),{},{bg_color:I(n.gradient_colors,n.bg_color)})}};function j(){}j.prototype={fontSize:14,rgbClass:{toString:function(){return"<r: ".concat(this.r," g: ").concat(this.g," b: ").concat(this.b," >")}},isValidSixDigitColorCode:function(t){return/^(#)?([0-9a-fA-F]{6})?$/.test(t)},isValidThreeDigitColorCode:function(t){return/^(#)?([0-9a-fA-F]{3})?$/.test(t)},isValidColorCode:function(t){return this.isValidSixDigitColorCode(t)||this.isValidThreeDigitColorCode(t)},isValidRatio:function(t){return"number"==typeof t},convertColorToSixDigit:function(t){return"#".concat(t[1]).concat(t[1]).concat(t[2]).concat(t[2]).concat(t[3]).concat(t[3])},hexToLuminance:function(t){if(!this.isValidColorCode(t))throw new Error("Invalid Color :".concat(t));this.isValidThreeDigitColorCode(t)&&(t=this.convertColorToSixDigit(t)),t=this.getRGBFromHex(t);var e=this.calculateLRGB(t);return this.calculateLuminance(e)},check:function(t,e,r,o){if(void 0!==r&&(this.fontSize=r),!t||!e)return!1;var n=this.hexToLuminance(t),a=this.hexToLuminance(e),i=this.getContrastRatio(n,a);return void 0!==o?!!this.isValidRatio(o)&&this.verifyCustomContrastRatio(i,o):this.verifyContrastRatio(i)},calculateLuminance:function(t){return.2126*t.r+.7152*t.g+.0722*t.b},isLevelAA:function(t,e,r){return this.check(t,e,r).WCAG_AA},isLevelAAA:function(t,e,r){return this.check(t,e,r).WCAG_AAA},isLevelCustom:function(t,e,r){return this.check(t,e,void 0,r).customRatio},getRGBFromHex:function(t){var e=Object.create(this.rgbClass);if("string"!=typeof t)throw new Error("must use string");var r=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return e.r=r,e.g=o,e.b=n,e},calculateSRGB:function(t){var e,r=Object.create(this.rgbClass);for(e in t)t.hasOwnProperty(e)&&(r[e]=parseFloat(t[e]/255,10));return r},calculateLRGB:function(t){var e,r=this.calculateSRGB(t),o=Object.create(this.rgbClass),n=0;for(e in r)r.hasOwnProperty(e)&&(n=parseFloat(r[e],10),o[e]=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4));return o},getContrastRatio:function(t,e){var r,o;return t>=e?(r=t,o=e):(r=e,o=t),(r+.05)/(o+.05)},verifyContrastRatio:function(t){var e=Object.create({toString:function(){return"< WCAG-AA: ".concat(this.WCAG_AA?"pass":"fail"," WCAG-AAA: ").concat(this.WCAG_AAA?"pass":"fail"," >")}});return(this.fontSize||14)>=18?(e.WCAG_AA=t>=3,e.WCAG_AAA=t>=4.5):(e.WCAG_AA=t>=4.5,e.WCAG_AAA=t>=7),e},verifyCustomContrastRatio:function(t,e){var r=Object.create({toString:function(){return"< Custom Ratio: ".concat(this.customRatio?"pass":"fail"," >")}});return r.customRatio=t>=e,r}};var H=exports.getContrastBgColor=function(t){var e=new j;if(!t||3!==t.length&&6!==t.length&&9!==t.length)return"#ff000000";var r=e.hexToLuminance("#".concat("#ff000000".slice(3))),o=e.hexToLuminance("#".concat("#ffffffff".slice(3))),n=e.hexToLuminance("#".concat(null==t?void 0:t.slice(3)));return e.getContrastRatio(r,n)>e.getContrastRatio(o,n)?"#ff000000":"#ffffffff"},G=exports.openProductDetail=function(t){return n.default.getNodeByInstanceId(t).getDataFromGlobal().globalInstanceData.layout===o.default.MODERN?"onModalToggle":"onBottomSheetOpen"},q=exports.closeProductDetail=function(t){return n.default.getNodeByInstanceId(t).getDataFromGlobal().globalInstanceData.layout===o.default.MODERN?"onModalToggle":"onBottomSheetClose"},V=exports.isArraysEqual=function(t,e){return t.length===e.length&&t.every(function(t,r){return t===e[r]})},W=exports.kFormatter=function(t){var e=t||0;return e<1e3?e:e>=1e3&&e<1e6?"".concat(+(e/1e3).toFixed(),"k"):e>=1e6&&e<1e9?"".concat(+(e/1e6).toFixed(),"m"):e>=1e9&&e<1e12?"".concat(+(e/1e9).toFixed(),"b"):e>=1e12?"".concat(+(e/1e12).toFixed(),"t"):e},N=exports.currencyFormatter=function(t,e){var r=Object.values(s.default).findIndex(function(t){return t===e}),o=Object.keys(s.default)[r];return new Intl.NumberFormat(Intl.NumberFormat.supportedLocalesOf(navigator.languages||navigator.language,{localeMatcher:"lookup"}),{style:"currency",currency:o||e,currencyDisplay:o?"narrowSymbol":"symbol"}).format(t)},U=exports.calcBorderRadius=function(t,e){var r,o=parseFloat(t.h)*e.offsetHeight/100;return(null!==(r=t.border_radius)&&void 0!==r?r:0)*(o/2)},z=exports.getProductLayers=function(t){var e=[a.LayerTemplateTypes.PRODUCT_CATALOG,a.LayerTemplateTypes.PRODUCT_TAG,a.LayerTemplateTypes.PRODUCT_CARD,a.LayerTemplateTypes.IMAGE_CTA,a.LayerTemplateTypes.SWIPE,a.LayerTemplateTypes.BUTTON];return(t.media?t.media.layers:t.stories.flatMap(function(t){return t.media}).flatMap(function(t){return t.layers})).filter(function(t){return e.includes(t.type)&&t.products})},J=exports.checkProductCatalogAtLeastOne=function(t,e){var r=t.filter(function(t){return t.type===a.LayerTemplateTypes.PRODUCT_CATALOG});if(!r.length)return!0;for(var o=!0,n=0;n<r.length;n+=1){if(!r[n].products.some(function(t){return e.some(function(e){return e.product_group_id===t.product_group_id})})){o=!1;break}}return o},$=exports.calculateCountdownTimes=function(t){var e=t/864e5,r=e%1*24,o=r%1*60,n=o%1*60,a=[Math.floor(e),Math.floor(r),Math.floor(o),Math.floor(n)];return[e=a[0],r=a[1],o=a[2],n=a[3]]},X=exports.isLiveVideo=function(t){return"live"===t};function Y(t){for(var e=(0,r.default)(t),o=e.length-1;o>0;o-=1){var n=Math.floor(Math.random()*(o+1)),a=[e[n],e[o]];e[o]=a[0],e[n]=a[1]}return e}var K=exports.productEventPayloadHandler=function(t){var e=i.default.getItemFromGlobal("Storyly_userConfig");return{account_id:t.account_id,id:t.id,p_id:t.product_id,p_group_id:t.product_group_id,title:t.title,url:t.url,image_urls:t.image_urls,price:t.price,total_price:(t.sales_price||t.price)*t.quantity,sales_price:t.sales_price,currency:t.price_currency,quantity:t.quantity,language:e.language,country:e.country,availability:t.availability}},Q=exports.imageAnimationHandler=function(t,e){var r=Array.from(t.querySelectorAll(e));requestAnimationFrame(function t(){var e=!0;r.forEach(function(t){if(!t.classList.contains("storyly__animate-image-horizontal")&&!t.classList.contains("storyly__animate-image-vertical")){var r=t.clientWidth,o=t.clientHeight,n=t.naturalWidth,a=t.naturalHeight;if(r&&o){var i=r/o,s=n/a,c=Math.abs(100*(s/i-1));i===s||c<=2||(s>i?t.classList.add("storyly__animate-image-horizontal"):t.classList.add("storyly__animate-image-vertical"))}else e=!1}}),e||requestAnimationFrame(t)})},Z=exports.videoHasAudio=function(t){var e;return!!t&&(t.mozHasAudio||Boolean(t.webkitAudioDecodedByteCount)||Boolean(null===(e=t.audioTracks)||void 0===e?void 0:e.length))},tt=exports.getTextLines=function(t){var e=t.innerText.replace(/\s+/gm," ").trim().split(" "),r=e.map(function(t){return'<span style="display: inline-block;">'.concat(t," </span>")});t.innerHTML=r.join(" ");var o=[],n=null,a=[];return t.querySelectorAll("span").forEach(function(t,r){var i=t.getBoundingClientRect();n!==i.top&&r>0?(o.push(a),a=[e[r]]):a.push(e[r]),n=i.top}),o.push(a),o.map(function(t){return t.join(" ")})},et=exports.getStoryMedia=function(t){var e=t.host,r=t.story,o=t.path,n="";if(o)n=null!=o&&o.match(/(http|https|:\/\/)/g)?o:"".concat(e).concat(o);else{var a=r.image_path,i=r.video_path,s=r.video_url,c=r.image_url;n=c||s?null!=c?c:s:null!=a&&a.match(/(http|https|:\/\/)/g)?a:null!=i&&i.match(/(http|https|:\/\/)/g)?i:"".concat(e).concat(null!=a?a:i)}return n},rt=exports.getTransformString=function(t,e,r){var o="rotate(".concat(t.r?e+(t.r||0):e,"deg)"),n=t.s?"scale(".concat(t.s,")"):"",a=function(t){return r?"".concat(t,"%"):"".concat(t/6,"em")},i="translateX(".concat(t.x?a(t.x):0,")"),s="translateY(".concat(t.y?a(t.y):0,")");return"".concat(i," ").concat(s," ").concat(o," ").concat(n)},ot=exports.isVideoPlaying=function(t){return t.currentTime>0&&!t.paused&&!t.ended&&t.readyState>2},nt=exports.updateStorylyUrlParams=function(t,e,r){if(!Object.keys(r).length||r.resumeStory){var o=new URLSearchParams(window.location.search);o.set("storyly","[".concat(t,", ").concat(e,"]")),o.set("storylyResume","1"),window.history.replaceState({},"","".concat(window.location.pathname,"?").concat(o))}};
|
|
112
112
|
},{"@babel/runtime/helpers/defineProperty":"IxO8","@babel/runtime/helpers/toArray":"kQhN","@babel/runtime/helpers/toConsumableArray":"Fhqp","../constants/layouts":"kUgL","./proxy":"qmVm","../constants/layerTypes":"aJRz","./storage":"NA5d","./currencies":"XhEk"}],"Ooqf":[function(require,module,exports) {
|
|
113
113
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e="sg",t="s",s=exports.default={STORY_GROUP:e,STORY:t};
|
|
114
114
|
},{}],"WCGv":[function(require,module,exports) {
|
|
@@ -214,7 +214,7 @@ var t=null;function e(){return t||(t=n()),t}function n(){try{throw new Error}cat
|
|
|
214
214
|
},{}],"TUK3":[function(require,module,exports) {
|
|
215
215
|
var r=require("./bundle-url").getBundleURL;function e(r){Array.isArray(r)||(r=[r]);var e=r[r.length-1];try{return Promise.resolve(require(e))}catch(n){if("MODULE_NOT_FOUND"===n.code)return new s(function(n,i){t(r.slice(0,-1)).then(function(){return require(e)}).then(n,i)});throw n}}function t(r){return Promise.all(r.map(u))}var n={};function i(r,e){n[r]=e}module.exports=exports=e,exports.load=t,exports.register=i;var o={};function u(e){var t;if(Array.isArray(e)&&(t=e[1],e=e[0]),o[e])return o[e];var i=(e.substring(e.lastIndexOf(".")+1,e.length)||e).toLowerCase(),u=n[i];return u?o[e]=u(r()+e).then(function(r){return r&&module.bundle.register(t,r),r}).catch(function(r){throw delete o[e],r}):void 0}function s(r){this.executor=r,this.promise=null}s.prototype.then=function(r,e){return null===this.promise&&(this.promise=new Promise(this.executor)),this.promise.then(r,e)},s.prototype.catch=function(r){return null===this.promise&&(this.promise=new Promise(this.executor)),this.promise.catch(r)};
|
|
216
216
|
},{"./bundle-url":"FheM"}],"Lwlj":[function(require,module,exports) {
|
|
217
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=x(require("@babel/runtime/helpers/toConsumableArray")),t=x(require("@babel/runtime/helpers/asyncToGenerator")),r=x(require("@babel/runtime/helpers/slicedToArray")),s=x(require("@babel/runtime/helpers/defineProperty")),n=x(require("@babel/runtime/helpers/classCallCheck")),o=x(require("@babel/runtime/helpers/createClass")),i=x(require("@babel/runtime/helpers/inherits")),a=x(require("@babel/runtime/helpers/possibleConstructorReturn")),u=x(require("@babel/runtime/helpers/getPrototypeOf")),l=x(require("@babel/runtime/helpers/wrapNativeSuper")),d=x(require("@babel/runtime/regenerator")),h=require("uuid"),c=x(require("./lib/api.ts")),p=x(require("./lib/storage")),_=require("./lib/style"),y=require("./lib/util"),v=x(require("./constants/playmode"));require("./main.scss");var g=require("./service/custom-story-group-design-impl"),f=require("./constants/common"),m=require("./service"),S=x(require("./constants/layouts")),b=require("./constants/events"),w=x(require("./constants/directions")),C=x(require("./constants/instanceStyleKeys")),I=x(require("./constants/barLayouts")),E=x(require("./components/AdGroup")),G=require("./constants/layerTypes"),k=x(require("./service/focal-point-impl.ts"));function x(e){return e&&e.__esModule?e:{default:e}}function A(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,s)}return r}function P(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?A(Object(r),!0).forEach(function(t){(0,s.default)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):A(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function D(e){var t=T();return function(){var r,s=(0,u.default)(e);if(t){var n=(0,u.default)(this).constructor;r=Reflect.construct(s,arguments,n)}else r=s.apply(this,arguments);return(0,a.default)(this,r)}}function T(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(T=function(){return!!e})()}var O=function(a){(0,i.default)(l,a);var u=D(l);function l(){var e;return(0,n.default)(this,l),(e=u.call(this)).groupShadowRoot_=e.attachShadow({mode:"open"}),e.storyShadowRoot_=null,e.groups_=[],e.token_=null,e.uuid_=null,e.sessionId_=null,e.selectedGroup_={},e.storylyOpen_=!1,e.retryCount_=0,e.shareParams_={},e.openStoryParams_=null,e.seenGroups_=[],e.groupCircleNodes_=[],e.hiddenStoryGroupNodes_=[],e.currentGroupIndex_=0,e.adGroups_=[],e.adSettings_={},e.properties_={storyGroupTextColor:"#4A4A4A",storyGroupTextVisibility:!0,storyGroupSize:"72x72",storyGroupBorderRadius:72,storyGroupTextFont:"Storyly-Inter",storyTextFont:"Storyly-Inter",storyGroupAlign:"center",storyGroupMarginHorizontal:10,storyGroupIconBorderColorNotSeen:["#FFCC64","#DC475B","#992DBD"],storyGroupIconBorderColorSeen:["#DBDBDB"],storyGroupTextSize:13,storyGroupTextWeight:"600",storyGroupBorderSize:7,storyGroupTextLineHeight:1.3,storyGroupPinBackgroundColor:"#FFCB00",storyGroupPinBorderColor:"#fdbc59",storyGroupPinIcon:null,storyGroupTextMarginTop:6,storyGroupTextSeenColor:"#333",storyBorderGapSize:3,storyBorderGapColor:"#fff",storyGroupAnimation:{},scrollIndicatorOptions:{indicatorWidth:32,indicatorHeight:32,indicatorBorderRadius:16,indicatorBorderWidth:1,indicatorBorderColor:"#D8D8D8",indicatorBoxBackgroundColor:"#FFFFFF",indicatorDefaultIconsColor:"#000000",indicatorBoxShadow:"none",customLeftIndicator:"",customRightIndicator:"",leftIndicatorMargin:8,rightIndicatorMargin:8},storyGroupProgressBackgroundColor:"rgba(255, 255, 255, 0.5)",storyGroupProgressFillColor:"rgba(255, 255, 255, 1)",storyGroupTitleVisible:!0,storyGroupCoverVisible:!0,storyGroupCloseButtonVisible:!0},e.events_={},e.payload_={app:{bundle:window.location.host,version:"3.3.0"},device:{height:window.innerHeight,unique_id:null,locale:navigator.language,width:window.innerWidth,userAgent:navigator.userAgent,is_test:!1},sdk_version:"latest",user:{segments:null},custom_parameter:null,session_id:null,preview_session_id:null,payload:{}},e.swipingDown_={scrollY:0,pageY:0},e.swiperMove_=!1,e.isMobileView_=(0,y.isMobileView)(),e.layout_=S.default.MODERN,e.layoutInstance_=null,e.userConfig_={},e.hasAdblocker_=!1,e.storylyConnected_=!1,e.init_=!1,e.documentDir_=document.documentElement.dir||w.default.LTR,e.storylyCheckoutProducts={products:[],price:"",sales_price:"",price_currency:""},e.isStorylyCartActive=!1,e.storylyHydration=[],e.globalInstanceData={shareParams:{},direction:e.documentDir_,accessibility:p.default.getItemFromGlobal("accessibilitiy",!1),storylyEmbed:{},videoMuted:!0,languageJSON:{}},e.storylyWebCss_=null,e.storylyFontCss_=null,e}return(0,o.default)(l,[{key:"connectedCallback",value:function(){var e=this;this.storylyConnected_||(this.attachCallbacksToElement_(),this.renderMainDoms_(),this.adBlockerDetector_(),this.storylyConnected_=!0,window.addEventListener("resize",function(){e.windowResize_=!0,e.isMobileView_&&(0,m.calcStorySizeImpl)(e.groupsOverlay_),e.setOverlayVh_()}))}},{key:"attachCallbacksToElement_",value:function(){this.handleNextGroup_=this.handleNextGroup_.bind(this),this.handlePrevGroup_=this.handlePrevGroup_.bind(this),this.handleCloseGroup_=this.handleCloseGroup_.bind(this),this.handleContainerTouchStart_=this.handleContainerTouchStart_.bind(this),this.handleContainerTouchEnd_=this.handleContainerTouchEnd_.bind(this),this.handleContainerTouchMove_=this.handleContainerTouchMove_.bind(this),this.handleNextStory_=this.handleNextStory_.bind(this),this.handlePrevStory_=this.handlePrevStory_.bind(this),this.handleImpressionEvent_=this.handleImpressionEvent_.bind(this),this.handleKeyboard_=this.handleKeyboard_.bind(this),this.handleClickGroup_=this.handleClickGroup_.bind(this),this.handleContextMenu_=this.handleContextMenu_.bind(this),this.getStoryGroupElement_=this.getStoryGroupElement_.bind(this),this.groupObserverCallback_=this.groupObserverCallback_.bind(this),this.handleTabVisibility_=this.handleTabVisibility_.bind(this),this.handleCustomerEvent_=this.handleCustomerEvent_.bind(this),this.handleConditionalEvent_=this.handleConditionalEvent_.bind(this),this.handleI18n_=this.handleI18n_.bind(this),this.handleUserEvent_=this.handleUserEvent_.bind(this)}},{key:"renderMainDoms_",value:function(){var e;this.storyShadowDom_=document.createElement("storyly-stories"),this.storyShadowRoot_=this.storyShadowDom_.attachShadow({mode:"open"}),this.storyShadowDom_.setAttribute("tabindex","-1"),this.storyShadowDom_.setAttribute("role","application"),this.setAttribute("role","application"),this.swiperContainer_=document.createElement("div"),this.swiperWrapper_=document.createElement("div"),this.groupContainer_=document.createElement("div"),this.groupsWrapper_=document.createElement("div"),this.groupsList_=document.createElement("div"),this.groupsOverlay_=document.createElement("div");var t=null===(e=this.parentElement)||void 0===e?void 0:e.parentElement;if("STORYLY-WEB-EMBED"===(null==t?void 0:t.nodeName)){t.firstElementChild.appendChild(this.storyShadowDom_),this.globalInstanceData.storylyEmbed={init:!0,autoPlay:t.hasAttribute("autoplay"),closeButton:t.hasAttribute("useClose"),shareButton:t.hasAttribute("useShare"),container:t,canPlay:!1},(0,y.setAttribute)(this.groupsOverlay_,"embed-mode",!0),(0,y.setAttribute)(this.groupsWrapper_,"embed-mode",!0);var r=t.getAttribute("group");this.openStoryParams_=[r]}else document.body.appendChild(this.storyShadowDom_);var s=[w.default.LTR,w.default.RTL].includes(this.documentDir_)?this.documentDir_:w.default.LTR;this.globalInstanceData.direction=s,(0,y.setAttribute)(this.swiperContainer_,"dir",s),(0,y.setAttribute)(this.groupsOverlay_,"direction",s),(0,y.setAttribute)(this.groupsList_,"role","list"),(0,y.setAttribute)(this.groupsOverlay_,"role","dialog"),(0,y.setAttribute)(this.groupsOverlay_,"aria-modal","true"),this.groupsOverlay_.style.visibility="hidden",(0,_.setClass)(this.groupContainer_,"storyly__group-container"),(0,_.setClass)(this.swiperContainer_,"swiper"),(0,_.setClass)(this.swiperWrapper_,"swiper-wrapper"),(0,_.setClass)(this.groupsWrapper_,"storyly__story-groups"),(0,_.setClass)(this.groupsOverlay_,"storyly__groups-overlay"),(0,_.setClass)(this.groupsList_,"storyly__groups-list"),this.groupsWrapper_.appendChild(this.groupsList_),this.swiperContainer_.appendChild(this.swiperWrapper_),this.groupContainer_.appendChild(this.swiperContainer_),this.groupsOverlay_.appendChild(this.groupContainer_),this.storyShadowRoot_.appendChild(this.groupsOverlay_),this.groupShadowRoot_.appendChild(this.groupsWrapper_),this.storyGroupStyle=document.createElement("style"),this.storyGroupStyle.id="storyly__story-group-style-tag",this.groupShadowRoot_.appendChild(this.storyGroupStyle)}},{key:"init",value:function(e){if(!this.init_){this.init_=!0,this.userConfig_=null!=e?e:{};var t=p.default.getItemFromGlobal("Storyly_userConfig");this.userConfigChanged_=JSON.stringify(P(P({},t),{},{props:void 0}))!==JSON.stringify(P(P({},e),{},{props:void 0})),p.default.setItemToGlobal("Storyly_userConfig",this.userConfig_);var s=this.userConfig_,n=s.token,o=s.props,i=s.userPropertyData,a=s.productFeed,u=s.customStoryGroupHTML,l=s.presentationData,d=s.barLayout,c=s.isProductFallbackEnabled,v=void 0===c||c,g=s.isProductCartEnabled,b=s.inboxStory,w=s.shopify,C=s.events;if(!n)throw this.failed_(f.failedMessages.token),new Error("Token not found!");C&&console.warn("There is no events key in the 3.0 version. Please check docs: https://docs.storyly.io/docs/initial-web-sdk-setup"),this.shopify_=w,this.token_=n;var E=!l&&(0,y.decodeJwt)(this.token_);if(this.instanceId_=l?n:E.ins_id,(0,y.setAttribute)(this,"data-storyly-instance-id",this.instanceId_),(0,y.setAttribute)(this.storyShadowDom_,"data-storyly-instance-id",this.instanceId_),this.uuid_=p.default.setInstanceId(this.instanceId_).getItemFromInstance("Storyly_uuid",!1)||p.default.setInstanceId(this.instanceId_).setItemToInstance("Storyly_uuid",(0,h.v4)(),!1),this.sessionId_=p.default.setInstanceId(this.instanceId_).setItemToInstance("Storyly_session_id",(0,h.v4)(),!1),sessionStorage.removeItem("Storyly__fonts"),this.presentationData_=l,this.isProductFallbackEnabled_=!!v,this.isStorylyCartActive=g,d&&[I.default.CLASSIC,I.default.ENERGIZED].includes(d.view)&&!u){var G,k=320;(null===(G=d.style)||void 0===G?void 0:G.height)>0&&(k=d.style.height<200?200:d.style.height),this.barLayout_=P(P({},d),{},{style:P(P({},null==d?void 0:d.style),{},{height:k})}),(0,_.setStyle)(this.groupsWrapper_,["padding","".concat(.1*this.barLayout_.style.height,"px")]),this.customStoryGroupHTML_=(0,m.barLayoutImpl)(this.barLayout_,this)}this.isMobileView_&&(this.layout_=S.default.CLASSIC),i&&"Object"===Object.getPrototypeOf(i).constructor.name&&!l?this.userPropertyData_=i:this.setPropsByParams_(),a&&"Object"===Object.getPrototypeOf(a).constructor.name&&(this.productFeed_=a),this.properties_=P(P(P({},this.properties_),o),{},{scrollIndicatorOptions:P(P({},this.properties_.scrollIndicatorOptions),(null==o?void 0:o.scrollIndicatorOptions)||{})}),u&&(0,y.isStringHTML)(u)&&(this.customStoryGroupHTML_=u,this.properties_.storyGroupAnimation=void 0);var x=m.LocalizationImpl.getLocalizedJSON(null,this.userConfig_.locale||navigator.language);if("string"==typeof this.userConfig_.locale){var A=this.userConfig_.locale.split(/[-_]/),D=(0,r.default)(A,2),T=D[0],O=D[1];this.userConfig_.language=T,this.userConfig_.country=O}this.globalInstanceData.languageJSON=x,this.globalInstanceData.properties=this.properties_,this.globalInstanceData.presentationData=!!this.presentationData_,this.globalInstanceData.layout=this.layout_,this.globalInstanceData.inboxStory=b,this.globalInstanceData.apiEnv=this.userConfig_.apiEnv,this.groupCircleNodes_=[],this.handleInitMethods_()}}},{key:"handleInitMethods_",value:function(){var e=(0,t.default)(d.default.mark(function e(){return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setLayoutInstance_();case 2:this.setPayload_(),this.buildCallback_(),this.implementEvent_();case 5:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"setPropsByParams_",value:function(){var e=new URLSearchParams(window.location.search),t={},s=e.get("userProps"),n=e.get("customParameter");s&&(s.split(",").forEach(function(e){var s=e.split(":"),n=(0,r.default)(s,2),o=n[0],i=n[1];t["{".concat(o,"}")]=i}),this.userPropertyData_=t);n&&(this.userConfig_=P(P({},this.userConfig_),{},{customParameter:n}))}},{key:"setStorylyBarObserver_",value:function(){var t=this;(0,m.intersectionObserverImpl)(null,function(r){r.forEach(function(r){r.isIntersecting&&(t.layoutImpl_=(0,m.layoutImpl)(t.groupsList_,t.instanceId_),t.setContainerHeight_(),(0,m.renderScrollIndicator)(t.groupsWrapper_,t.properties_),t.layoutImpl_.on("layoutEnd",function(){[].concat((0,e.default)(t.groupCircleNodes_),(0,e.default)(t.hiddenStoryGroupNodes_)).forEach(function(e){t.storyGroupObserver_.observe(e)}),setTimeout(function(){return(0,m.renderScrollIndicator)(t.groupsWrapper_,t.properties_)},0)}),setTimeout(function(){return t.sendBarViewEvent_()},100),t.barViewed_=!0)})}).observe(this)}},{key:"sendBarViewEvent_",value:function(){var e=[],t=[];if(this.groups_.forEach(function(r){var s=r;r.onView&&!r.viewEventSend&&(e.push(r.group_id),s.viewEventSend=!0),r.onView&&t.push(P(P({},r),{},{instance:void 0}))}),0!==e.length){var r={sg_ids:e},s={detail:{eventName:b.CustomerEventTypes.renderedStoryGroups,params:t}};this.EventImpl.onBarViewedEvent(r),this.handleCustomerEvent_(s)}}},{key:"setLayoutInstance_",value:function(){var e=(0,t.default)(d.default.mark(function e(){var t,r,s,n,o;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.layout_!==S.default.MODERN){e.next=13;break}return e.next=3,require("_bundle_loader")(require.resolve("./layouts/Modern"));case 3:t=e.sent.default,r=new t(this.groupsOverlay_,this.getActiveGroup_.bind(this),this.instanceId_),this.layoutInstance_=r,(s=document.createElement("canvas")).width=3,s.height=3,(0,_.setClass)(s,"background-blur-canvas"),this.groupsOverlay_.appendChild(s),e.next=18;break;case 13:return e.next=15,require("_bundle_loader")(require.resolve("./layouts/Classic"));case 15:n=e.sent.default,o=new n(this.groupsOverlay_,this.instanceId_),this.layoutInstance_=o;case 18:(0,_.setClass)(this.groupContainer_,this.layout_===S.default.MODERN?"storyly__modern-layout":"storyly__classic-layout"),this.globalInstanceData.storylyEmbed.init&&(0,y.setAttribute)(this.groupContainer_,"embed-mode",this.globalInstanceData.storylyEmbed.init),(0,y.setAttribute)(this.groupContainer_,"direction",this.documentDir_),this.swiper_=(0,m.swiperImpl)(this.swiperContainer_,this.layout_);case 22:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"implementEvent_",value:function(){var e=this.getActiveGroup_.bind(this),t=this.getPrevGroup_.bind(this),r=this.getNextGroup_.bind(this);this.EventImpl=new m.EventImpl(this.storyShadowRoot_,e,t,r,this.api_)}},{key:"setPayload_",value:function(){var e=this.userConfig_,t=e.isTestMode,r=e.segments,s=e.customParameter,n=e.locale,o=(0,m.platformIml)(),i=o.os,a=o.browser,u=Array.isArray(r)&&r.length>0?r.map(function(e){return String(e)}):null;this.payload_=P(P({},this.payload_),{},{device:P(P({},this.payload_.device),{},{unique_id:this.uuid_,is_test:t,os:i,browser:a}),user:P(P({},this.payload_.user),{},{segments:u}),custom_parameter:s?String(s):null,locale:n,session_id:this.sessionId_}),this.globalInstanceData.eventPayload=this.payload_}},{key:"buildCallback_",value:function(){this.setAPI_(),this.setEventListeners_(),this.presentationData_?this.handleGroupsData_(this.presentationData_):this.fetchGroups_()}},{key:"setAPI_",value:function(){this.api_=new c.default(this.token_,this.instanceId_),this.globalInstanceData.API=this.api_}},{key:"setEventListeners_",value:function(){var e=this;this.storyShadowRoot_.addEventListener(b.CustomerEventTypes.nextStoryGroup,this.handleNextGroup_),this.storyShadowRoot_.addEventListener(b.CustomerEventTypes.previousStoryGroup,this.handlePrevGroup_),this.storyShadowRoot_.addEventListener("storyImpression",this.handleImpressionEvent_),this.storyShadowRoot_.addEventListener("onCloseGroup",this.handleCloseGroup_),this.storyShadowRoot_.addEventListener(b.CustomerEventTypes.nextStory,this.handleNextStory_),this.storyShadowRoot_.addEventListener(b.CustomerEventTypes.previousStory,this.handlePrevStory_),this.storyShadowRoot_.addEventListener("onCustomerEvent",this.handleCustomerEvent_),this.storyShadowRoot_.addEventListener("onConditionalEvent",this.handleConditionalEvent_),this.storyShadowRoot_.addEventListener("userEvent",this.handleUserEvent_),this.storyShadowRoot_.addEventListener("onI18nEvent",this.handleI18n_),this.storyShadowRoot_.addEventListener("onStorylyCartOpen",function(){var t;null===(t=e.getActiveGroup_().instance.storylyCart)||void 0===t||t.open()}),this.addEventListener("keydown",this.handleTabKeyPressListener_),this.layout_===S.default.MODERN&&this.storyShadowRoot_.addEventListener("storyChange",function(t){return(0,m.backgroundBlurImpl)(t,e.groupsOverlay_)}),(0,m.tabVisibilityImpl)(this.handleTabVisibility_)}},{key:"handleUserEvent_",value:function(e){var t=e.detail;this.handleEvent_(b.UserEvent,t)}},{key:"handleCustomerEvent_",value:function(e){var t=e.detail,r=t.eventName,s=t.params;this.handleEvent_(r,s)}},{key:"handleTabKeyPressListener_",value:function(e){var t=e.code,r=this.shadowRoot.activeElement;if(r=r||document.activeElement){this.lastActiveElement_=r;["Space","Enter"].includes(t)&&(r.classList.contains("group")||r.hasAttribute("slot"))&&(e.stopImmediatePropagation(),this.globalInstanceData.storiesHasAltText&&(this.globalInstanceData.accessibility=!0),this.handleClickGroup_({target:r}))}}},{key:"handleTabVisibility_",value:function(e){if(this.storylyOpen_&&this.globalInstanceData.storylyEmbed.canPlay){var t,r=this.getActiveStory_();if(document[e])r.instance.pause(!0);else null===(t=this.lastActiveElement_)||void 0===t||t.focus(),r.instance.play(!0)}}},{key:"setStoryNavigationEvents_",value:function(){this.isMobileView_&&(window.addEventListener(this.globalInstanceData.storylyEmbed.init?"pointerdown":"touchstart",this.handleContainerTouchStart_),window.addEventListener(this.globalInstanceData.storylyEmbed.init?"pointerup":"touchend",this.handleContainerTouchEnd_),this.globalInstanceData.storylyEmbed.init||window.addEventListener("touchmove",this.handleContainerTouchMove_),window.oncontextmenu=this.handleContextMenu_),this.globalInstanceData.storylyEmbed.init&&!this.isMobileView_&&this.groupsOverlay_.addEventListener("click",this.handleContainerTouchEnd_),window.addEventListener("keydown",this.handleKeyboard_)}},{key:"removeStoryNavigationEvents_",value:function(){this.isMobileView_&&(window.removeEventListener(this.globalInstanceData.storylyEmbed.init?"pointerdown":"touchstart",this.handleContainerTouchStart_),window.removeEventListener(this.globalInstanceData.storylyEmbed.init?"pointerup":"touchend",this.handleContainerTouchEnd_),this.globalInstanceData.storylyEmbed.init||window.removeEventListener("touchmove",this.handleContainerTouchMove_),window.oncontextmenu=null),window.removeEventListener("keydown",this.handleKeyboard_)}},{key:"handleContextMenu_",value:function(e){return e.preventDefault(),e.stopPropagation(),!1}},{key:"handleKeyboard_",value:function(e){var t=this.focusableEls_[0],r=this.focusableEls_[this.focusableEls_.length-1];if(("Tab"===e.key||9===e.keyCode)&&(e.shiftKey&&this.storyShadowRoot_.activeElement===t&&(r.focus(),e.preventDefault()),this.storyShadowRoot_.activeElement===r&&(t.focus(),e.preventDefault())),this.storylyOpen_){var s,n=e.key,o=e.code,i=e.keyCode;if("ArrowRight"===n||39===i)this.documentDir_===w.default.RTL?this.handlePrevStory_():this.handleNextStory_();else if("ArrowLeft"===n||37===i)this.documentDir_===w.default.RTL?this.handleNextStory_():this.handlePrevStory_();else if("Escape"===n||27===i){var a=this.groupsOverlay_.querySelector(".storyly__action-container"),u=null==a?void 0:a.classList.contains("active"),l=this.getActiveStory_(),d=this.groupsOverlay_.querySelector(".storyly__share-popup");if(u){var h=this.groupsOverlay_.querySelector(".storyly__story-group-overlay");return a.classList.remove("active"),h.classList.remove("active"),l.instance.playAndPauseStory(),void this.storyShadowRoot_.activeElement.blur()}if(d)return l.instance.hideShareWidget(),void l.instance.playAndPauseStory();this.handleCloseGroup_()}else if("Space"!==o&&32!==i||"BUTTON"===(null===(s=this.storyShadowRoot_.activeElement)||void 0===s?void 0:s.tagName)){if("KeyS"===o){var c=this.groupsOverlay_.querySelector(".storyly__action-container"),p=null==c?void 0:c.classList.contains("active"),_=this.groupsOverlay_.querySelector(".storyly__share-popup");if(p){var y=this.groupsOverlay_.querySelector(".storyly__story-group-overlay");c.classList.remove("active"),y.classList.remove("active")}if(_)return;this.getActiveStory_().instance.renderShareWidget()}}else{this.getActiveStory_().instance.playAndPauseStory()}}}},{key:"handleContainerTouchStart_",value:function(e){e.stopPropagation(),this.handleNavigation_=!0,this.storyPauseByTouch_()}},{key:"handleContainerTouchEnd_",value:function(e){this.handleStoryNavigationByTouch_(e),!this.globalInstanceData.storylyEmbed.init&&this.isMobileView_&&this.closeStorylyBySwiping_(),this.storyPlayAfterTouched_()}},{key:"closeStorylyBySwiping_",value:function(){var e=this;this.swiperMove_||(this.swipingDown_.scrollY>15*this.groupContainer_.offsetHeight/100?(this.groupContainer_.style.setProperty("transform","translateY(50vh) scale(0)"),this.groupsOverlay_.style.setProperty("background","transparent"),window.requestAnimationFrame(function(){e.handleCloseGroup_(),setTimeout(function(){e.groupContainer_.style.removeProperty("transform"),e.groupsOverlay_.style.removeProperty("background")},300)})):this.groupContainer_.style.setProperty("transform","translateY(0)"),this.swipingDown_={scrollY:0,pageY:0})}},{key:"handleStoryNavigationByTouch_",value:function(e){var t,r;if(this.globalInstanceData.storylyEmbed.init||this.handleNavigation_&&this.isMobileView_){var s=null!==(t=null===(r=e.changedTouches)||void 0===r||null===(r=r[0])||void 0===r?void 0:r.pageX)&&void 0!==t?t:e.offsetX,n=this.groupsOverlay_.offsetWidth,o=n-20*n/100;s>0&&s<20*n/100?this.documentDir_===w.default.RTL?this.handleNextStory_():this.handlePrevStory_():s>o&&s<n&&(this.documentDir_===w.default.RTL?this.handlePrevStory_():this.handleNextStory_()),this.handleNavigation_=!0}}},{key:"handleContainerTouchMove_",value:function(e){this.handleNavigation_=!1;var t=e.changedTouches[0].pageY;this.swiperMove_||(this.swipingDown_.scrollY+=this.swipingDown_.pageY>0?t-this.swipingDown_.pageY:0,this.swipingDown_.pageY=t,this.swipingDown_.scrollY>=0&&(this.groupContainer_.style.transform="translateY(".concat(this.swipingDown_.scrollY,"px)")))}},{key:"storyPauseByTouch_",value:function(){var e=this;this.isMobileView_&&(this.touchTimeout_=setTimeout(function(){e.getActiveStory_().instance.pauseByTouch(),e.storyTouchAction_=!0,e.handleNavigation_=!1},300))}},{key:"storyPlayAfterTouched_",value:function(){if(this.isMobileView_){if(this.storyTouchAction_)this.getActiveStory_().instance.playAfterTouch();clearTimeout(this.touchTimeout_)}}},{key:"handleCloseGroup_",value:function(){var e=(0,t.default)(d.default.mark(function e(){var t,r,s,n,o,i,a,u,l=this;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.storylyOpen_){e.next=2;break}return e.abrupt("return");case 2:if(!this.globalInstanceData.storylyEmbed.init){e.next=6;break}return r=this.getActiveGroup_(),this.handleEvent_(b.UserEventTypes.closeStoryGroup,P(P({},null!=r?r:{}),{},{instance:void 0})),e.abrupt("return");case 6:return this.groupsOverlay_.ariaHidden="true",this.swiper_.slides[this.swiper_.realIndex].ariaHidden="true",this.storyShadowDom_.setAttribute("tabindex","-1"),(0,_.removeClass)(this.groupsOverlay_,"active"),this.storylyOpen_=!1,this.removeStoryNavigationEvents_(),this.addEventListener("keydown",this.handleTabKeyPressListener_),null===(t=this.lastActiveElement_)||void 0===t||t.focus(),this.EventImpl.handleCloseEvent(),this.resetStyleToDocument_(),this.shareParams_.playMode&&(this.swiper_.allowTouchMove=!0),this.shareParams_={},(s=new URLSearchParams(window.location.search)).delete("storylyResume"),s.delete("storyly"),window.history.replaceState({},"","".concat(window.location.pathname).concat(s.size?"?".concat(s):"")),n=this.getActiveGroup_(),this.handleEvent_(b.UserEventTypes.closeStoryGroup,P(P({},null!=n?n:{}),{},{instance:void 0})),n.instance.hide({holdActive:!0}),this.removeAdGroups_(),this.isAdEnable_()&&document.querySelectorAll(".storyly-ad-wrapper").forEach(function(e){return e.remove()}),this.customStoryGroupHTML_&&(o=n.instance.getActiveStory(),i=o.storyIndex,a=this.getStoryGroupElement_(n),u=this.getCustomGroupAssignedElement_(a),(0,g.handleCustomStoryGroupStyles)(n,u,i,this.instanceId_)),e.next=31,this.clearNudgeGroups_();case 31:this.presentationData_&&!(0,y.isLiveVideo)(n.type)||this.handleSeenGroupsPosition_().then(function(){l.layoutImpl_.refreshSortData(),l.layoutImpl_.sort("order"),l.groups_.forEach(function(e,t){e.instance.setKey(t)})}).catch(function(){});case 32:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"removeAdGroups_",value:function(){if(this.isAdEnable_()&&0!==this.adGroups_.length){var e=[],t=[];this.groups_.forEach(function(r,s){r.ad?t.push(s):e.push(r)}),this.groups_=e,this.swiper_.removeSlide(t)}}},{key:"handleSeenGroupsPosition_",value:function(){var e=this;return 0===this.seenGroups_.length?Promise.reject():(this.seenGroups_.forEach(function(t){var r=e.getStoryGroupElement_(t);if(!t.pinned){var s=e.groupCircleNodes_.length-1;e.groupCircleNodes_.forEach(function(e,t){e.dataset.ad||e.classList.contains("seen")&&r.dataset.order<+e.dataset.order||(s=t)});var n=e.hiddenStoryGroupNodes_.filter(function(e){return e.classList.contains("hidden")&&+r.dataset.sortorder>=+e.dataset.sortorder}),o=+r.dataset.sortorder-n.length;e.groupCircleNodes_.splice(o,1),e.groupCircleNodes_.splice(s,0,r),e.groupCircleNodes_.forEach(function(t,r){e.customStoryGroupHTML_&&(e.getCustomGroupAssignedElement_(t).dataset.sortorder=r);t.dataset.ad||(e.groupsList_.querySelector('.storyly__story-group-container[data-id="'.concat(t.dataset.id,'"]')).dataset.sortorder=r);var s=e.hiddenStoryGroupNodes_.find(function(e){return e.dataset.id===t.dataset.id});s&&(s.dataset.sortOrder=t.dataset.sortorder,s.dataset.order=t.dataset.order)});var i=e.swiper_.slides[o];e.swiper_.removeSlide(o),e.swiper_.addSlide(s,i);var a=e.groups_[o];e.groups_.splice(o,1),e.groups_.splice(s,0,a)}e.customStoryGroupHTML_&&e.getCustomGroupAssignedElement_(r).classList.toggle("storyly__story-group-seen");r.classList.toggle("seen")}),this.seenGroups_=[],Promise.resolve())}},{key:"getActiveGroup_",value:function(){return this.groups_[this.currentGroupIndex_]}},{key:"getNextGroup_",value:function(){return this.groups_[this.currentGroupIndex_+1]}},{key:"getPrevGroup_",value:function(){return this.groups_[this.currentGroupIndex_-1]}},{key:"getActiveStory_",value:function(){return this.getActiveGroup_().instance.getActiveStory()}},{key:"getPrevStory_",value:function(){return this.getActiveGroup_().instance.getPrevStory()}},{key:"getCustomGroupAssignedElement_",value:function(e){return"SLOT"===e.tagName?e.assignedElements()[0]:e}},{key:"getStoryGroupElement_",value:function(e){return this.groupCircleNodes_.find(function(t){return+t.dataset.id===e.group_id})}},{key:"getActiveGroupWithoutInstance",value:function(){var e=P({},this.getActiveGroup_());return delete e.instance,delete e.currentOrder,delete e.onView,e}},{key:"handleNextGroup_",value:function(){if(this.handleCompleteGroupEvent_(),this.shareParams_.playMode!==v.default.STORY_GROUP||this.getActiveGroup_().group_id!==this.shareParams_.group.group_id)if(this.currentGroupIndex_===this.groups_.length-1)this.handleCloseGroup_();else{this.getActiveGroup_().instance.sendGroupClickedEvent("next");var e=this.getNextGroup_();this.groups_[this.currentGroupIndex_].instance.unLoad({holdActive:!0}),this.currentGroupIndex_+=1,this.loadNextGroupInstance_(),this.swiper_.slideTo(this.currentGroupIndex_),e.instance.show(),this.EventImpl.handleSwipingGroupEvent("next")}else this.handleCloseGroup_()}},{key:"handleCompleteGroupEvent_",value:function(){var e,t=this.getActiveGroup_();!t.ad&&t.instance.isAllStoriesSeen()&&(this.handleEvent_(b.UserEvent,{event:b.UserEventTypes.groupCompleted,storyGroup:P(P({},null!==(e=this.groups_[this.currentGroupIndex_])&&void 0!==e?e:{}),{},{instance:void 0})}),this.EventImpl.handleCompleteGroupEvent())}},{key:"loadNextGroupInstance_",value:function(){var e=this.getNextGroup_(),t=this.getPrevGroup_();!e||null!=e&&e.onView||e.ad||e.nudge||this.loadGroupInstance_(e),!t||null!=t&&t.onView||t.ad||t.nudge||this.loadGroupInstance_(t)}},{key:"handlePrevGroup_",value:function(){if(this.shareParams_.playMode!==v.default.STORY_GROUP||this.getActiveGroup_().group_id!==this.shareParams_.group.group_id){if(0!==this.currentGroupIndex_){this.getActiveGroup_().instance.sendGroupClickedEvent("prev");var e=this.getPrevGroup_();this.groups_[this.currentGroupIndex_].instance.unLoad({holdActive:!0}),this.currentGroupIndex_-=1,this.loadNextGroupInstance_(),this.swiper_.slideTo(this.currentGroupIndex_),e.instance.show(),this.EventImpl.handleSwipingGroupEvent("prev"),this.handleImpressionEvent_()}}else this.handleCloseGroup_()}},{key:"handleNextStory_",value:function(e){var t;e&&"detail"in e&&(t=e.detail.storyIndex);this.getActiveStory_().instance.sendStoryClickedEvent("next"),this.EventImpl.handleSwipingStoryEvent("next"),this.getActiveGroup_().instance.nextStory(t),this.handleImpressionEvent_()}},{key:"handlePrevStory_",value:function(e){var t=this.getActiveStory_();if(0!==this.currentGroupIndex_||0!==t.storyIndex){var r;if(e&&"detail"in e)r=e.detail.storyIndex;t.instance.sendStoryClickedEvent("prev"),this.EventImpl.handleSwipingStoryEvent("prev"),this.getActiveGroup_().instance.prevStory(r)}}},{key:"fetchGroups_",value:function(){var e=this,t=p.default.setInstanceId(this.instanceId_).getItemFromInstance("Storyly_responseData");if(this.checkCacheData_())this.loadCacheData_(t);else{this.isCache_=!1;var r,s,n,o=[],i=!1,a=setTimeout(function(){var a,u;i=!0,o=null!==(a=t.story_groups)&&void 0!==a?a:[],s=t.style,r=null!==(u=t.ad)&&void 0!==u?u:{},n=t.nudge_settings,r&&(e.adSettings_=r),o?(e.handleGroupsData_(o),e.handleInstanceLevelStyling_(s)):(e.retryCount_+=1,e.retryCount_<3?e.fetchGroups_():e.removeStoryly_())},2e3);this.api_.getGroups(this.payload_).then(function(t){var u;t.error?e.failed_(f.failedMessages.network):(clearTimeout(a),p.default.setInstanceId(e.instanceId_).setItemToInstance("Storyly_responseData",P(P({},t),{},{ttl:Date.now()})),0!==t.story_groups.length||e.shopify_?(o=t.story_groups,s=t.style,r=null!==(u=t.ad)&&void 0!==u?u:{},n=t.nudge_settings,i||(e.adSettings_=r,e.nudgeSettings_=n,e.handleGroupsData_(o),e.handleInstanceLevelStyling_(s))):e.removeStoryly_())}).catch(function(){e.failed_(f.failedMessages.network)})}}},{key:"checkCacheData_",value:function(){if("dashboard.storyly.io"===window.location.hostname||"docs.developers.storyly.io"===window.location.hostname||"dev.storyly"===window.location.hostname||this.userConfigChanged_||this.userConfig_.isTestMode)return!1;var e=p.default.setInstanceId(this.instanceId_).getItemFromInstance("Storyly_responseData"),t=e.story_groups,r=e.ttl,s=new Date(Date.now()-r);return!!(t&&s.getMinutes()<3)}},{key:"loadCacheData_",value:function(e){var t=e.story_groups,r=e.ads,s=e.style;this.adSettings_=null!=r?r:{},this.handleGroupsData_(t||[]),this.handleInstanceLevelStyling_(s),this.isCache_=!0}},{key:"handleGroupsData_",value:function(){var s=(0,t.default)(d.default.mark(function t(){var s,n,o,i,a,u,l,h,c,p,_,y,v,g,S,w=this,C=arguments;return d.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return s=C.length>0&&void 0!==C[0]?C[0]:[],this.loadInlineStyle_(),n=s.map(function(e,t){return P(P({},e),{},{order:t})}),t.next=5,this.handleConditionalGroups_(s);case 5:if(n=t.sent,o=new URLSearchParams(window.location.search),!this.nudgeSettings_){t.next=12;break}return t.next=10,require("_bundle_loader")(require.resolve("./service/nudge-story-groups-impl"));case 10:i=t.sent.default,this.nudgeImpl_=i(this.nudgeSettings_);case 12:if((this.globalInstanceData.storylyEmbed.init||o.get("storylyMail")||this.globalInstanceData.inboxStory)&&(a=(0,r.default)(this.openStoryParams_,1),u=a[0],n=n.filter(function(e){return e.group_id===+u})),l=n.filter(function(e){return e.type===f.groupTypes.SDK_AUTOMATED_SHOPPABLE}),n=n.filter(function(e){return e.type!==f.groupTypes.SDK_AUTOMATED_SHOPPABLE}),!(this.productFeed_&&l.length>0)){t.next=27;break}return h=Object.values(this.productFeed_).flatMap(function(e){return e}),this.allProductsOfProductFeed_=h.map(function(e){var t;return P(P({},e),{},{variant:null!==(t=e.variant)&&void 0!==t?t:[]})}),this.storylyHydration=[].concat((0,e.default)(this.storylyHydration),(0,e.default)(this.allProductsOfProductFeed_)),t.next=21,require("_bundle_loader")(require.resolve("./service/create-product-feed-impl"));case 21:return c=t.sent.default,t.next=24,c(this.productFeed_,l);case 24:p=t.sent,_=[].concat((0,e.default)(n),(0,e.default)(null!=p?p:[])).sort(function(e,t){return e.order-t.order}),n=_;case 27:if(y=(0,e.default)(n),v=[],n.forEach(function(t,r){var s=(0,m.createUserPropertyImpl)(w.userPropertyData_,t);if(s.has_user_property&&(w.storyGroupsWithUserProperties_=[].concat((0,e.default)(w.storyGroupsWithUserProperties_||[]),[P(P({},y[r]),{},{is_user_property_used:s.is_user_property_used})])),y[r]=s,t.type!==f.groupTypes.SDK_AUTOMATED_SHOPPABLE){var n=w.handleProductGroups_(y[r]),o=n.productGroup,i=n.productIds;v.push.apply(v,(0,e.default)(i)),y[r]=o}}),!v.length){t.next=42;break}if(g={products:v,language:this.userConfig_.language,country:this.userConfig_.country},this.handleEvent_(b.CustomerEventTypes.storylyHydration,v),!this.isProductFallbackEnabled_){t.next=42;break}if(!o.get("storylyMail")&&!this.globalInstanceData.inboxStory){t.next=41;break}return t.next=37,this.api_.getProductDetails(g);case 37:S=t.sent,this.storylyHydration=S.products,t.next=42;break;case 41:this.api_.getProductDetails(g).then(function(e){w.setStorylyHydration(e.products)});case 42:this.loadGroupCircles_(y);case 43:case"end":return t.stop()}},t,this)}));return function(){return s.apply(this,arguments)}}()},{key:"handleConditionalGroups_",value:function(e){var t=p.default.setInstanceId(this.instanceId_).getItemFromInstance("Storyly_componentsData"),r=e.map(function(e){var r=!1,s=e.stories.filter(function(e){var s=e;if(!e.conditions)return s.visible=!0,!0;r=!0;var n=e.conditions.every(function(e){return e.some(function(e){var r=t[e.i];return void 0!==r&&r===+e.r.p})});return s.visible=n,n});return P(P({},e),{},{conditional:r,hidden:0===s.length})});return Promise.resolve(r)}},{key:"handleConditionalEvent_",value:function(){var r=(0,t.default)(d.default.mark(function r(){var s,n,o,i,a=this;return d.default.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return s=this.groups_.filter(function(e){return e.conditional}),r.next=3,s.forEach(function(){var e=(0,t.default)(d.default.mark(function e(t){var r,s;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=t,e.next=3,t.instance.handleConditionalStories(!0);case 3:s=e.sent,r.stories=s;case 5:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}());case 3:return n=this.hiddenConditionalGroups_.filter(function(e){return e.conditional}),r.next=6,this.handleConditionalGroups_(n);case 6:n=r.sent.filter(function(e){return!e.hidden}),o=(0,e.default)(this.groups_),n.length>0&&(i=[],n.forEach(function(){var e=(0,t.default)(d.default.mark(function e(t){return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a.createGroupInstanceAndReorderCircleNodes_(t),i.push(t.group_id);case 2:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()),this.hiddenConditionalGroups_=this.hiddenConditionalGroups_.filter(function(e){return!i.includes(e.group_id)}),this.groups_=o.filter(function(e){return Boolean(e)&&0!==e.stories.length}),this.layout_===S.default.MODERN&&this.layoutInstance_.handleStoryGroupNavigationButtons(this.groups_,this.currentGroupIndex_));case 9:case"end":return r.stop()}},r,this)}));return function(){return r.apply(this,arguments)}}()},{key:"handleInstanceLevelStyling_",value:function(e){var t=this;e&&(Object.keys(C.default).forEach(function(r){Object.keys(e).includes(r)&&(Array.isArray(e[r])?t.properties_[C.default[r]]=e[r].map(function(e){return(0,y.isHexColor)(e)?(0,y.convertHex)(e):e}):(0,y.isHexColor)(e[r])?t.properties_[C.default[r]]=(0,y.convertHex)(e[r]):t.properties_[C.default[r]]=e[r]),"animation"===r&&e.animation&&(t.properties_.storyGroupAnimation={type:"pulse",mode:!1},m.StoryGroupAnimationImpl.add(t.groupCircleNodes_,t.properties_.storyGroupAnimation))}),this.setProperties(this.properties_))}},{key:"handleProductGroups_",value:function(e){var t=(0,y.getProductLayers)(e),r=t.flatMap(function(e){return e.products}),s=new URLSearchParams(window.location.search);return{productGroup:P(P({},e),{},{hidden:e.hidden||!(s.get("storylyMail")||this.globalInstanceData.inboxStory)&&!!t.length}),productIds:r}}},{key:"createGroupInstanceAndReorderCircleNodes_",value:function(){var r=(0,t.default)(d.default.mark(function t(r){var s,n,o,i,a,u,l,h,c,p,v,g,f,b,w=this;return d.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return s=!Object.keys(this.shareParams_).length||this.hiddenStoryGroups_.includes(function(e){var t;return e.group_id===(null===(t=w.shareParams_.group)||void 0===t?void 0:t.group_id)}),t.next=3,new Promise(function(e){return setTimeout(e,s?0:1e3)});case 3:if(n=[].concat((0,e.default)(this.groupCircleNodes_),(0,e.default)(this.hiddenStoryGroupNodes_)).find(function(e){return+e.dataset.id===r.group_id}),o=+n.dataset.sortorder,i=o,!this.storylyOpen_||!this.nudgeImpl_){t.next=11;break}return t.next=9,this.nudgeImpl_.getAddedNudgeCount(+o);case 9:a=t.sent,o+="number"==typeof a?a:0;case 11:return(u=this.swiper_.slides.findIndex(function(e){return+e.dataset.id===r.group_id}))>-1&&this.swiper_.removeSlide(u),l=this.setGroupInstance_(r,o),t.next=16,l.instance.render();case 16:h=t.sent,this.swiper_.addSlide(o,h),r.is_user_property_used&&(c=r.title,p=r.icon_image_url,v=n,"SLOT"===n.tagName&&(v=this.querySelector("[slot='story-group-".concat(r.group_id,"']"))),g=v.querySelector(".storyly__story-group-title"),(f=v.querySelector(".storyly__story-group-cover"))&&(f.src=p),g&&(c.length>25?((0,y.setAttribute)(n,"title",c),g.innerHTML="".concat(c.substring(0,25),"...")):((0,y.setAttribute)(n,"title",""),g.innerHTML=c))),(0,_.removeClass)(n,"seen"),(0,_.removeClass)(n,"hidden"),(b=this.groups_.findIndex(function(e){return e.group_id===r.group_id}))>-1?(this.groups_[b]=P(P({},l),{},{hidden:!1}),this.groupCircleNodes_[b]=n):(this.groups_.splice(o,0,P(P({},l),{},{hidden:!1})),this.groupCircleNodes_.splice(o,0,n)),this.groupsList_.insertBefore(n,this.groupsList_.children[o]),this.layout_===S.default.MODERN&&this.nudgeImpl_&&this.storylyOpen_&&this.layoutInstance_.handleStoryGroupNavigationButtons(this.groups_,i),this.layoutImpl_&&(this.layoutImpl_.add(n),this.layoutImpl_.refreshSortData(),this.layoutImpl_.sort("order")),this.setContainerHeight_(),s&&this.loadShareParams_().then(function(){return w.handleOpenStoryByUrl_()}).catch(function(){}),m.StoryGroupAnimationImpl.add(this.groupCircleNodes_,this.properties_.storyGroupAnimation),this.handleI18n_({detail:{wrapperDom:this.groupsList_}});case 30:case"end":return t.stop()}},t,this)}));return function(e){return r.apply(this,arguments)}}()},{key:"removeGroupInstanceAndReorderCircleNodes_",value:function(e,t){var r=this.swiper_.slides.findIndex(function(e){return+e.dataset.id===t.group_id});this.swiper_.removeSlide(r);var s=this.groups_.findIndex(function(e){return e.group_id===t.group_id});this.groups_.splice(s,1),this.groupCircleNodes_.splice(s,1),this.groupsList_.removeChild(e),this.layoutImpl_&&(this.layoutImpl_.remove(e),this.layoutImpl_.refreshSortData(),this.layoutImpl_.sort("order"))}},{key:"adBlockerDetector_",value:function(){var e=document.createElement("div");e.classList.add("adsbygoogle"),this.groupsOverlay_.appendChild(e),"none"===getComputedStyle(e).getPropertyValue("display")&&(this.hasAdblocker_=!0),e.remove()}},{key:"isAdEnable_",value:function(){return Object.keys(this.adSettings_).length>0&&!this.hasAdblocker_}},{key:"loadAdGroups_",value:function(){var e=(0,t.default)(d.default.mark(function e(t){var r,s,n,o,i,a,u,l,h,c,p,_,v=this;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isAdEnable_()){e.next=2;break}return e.abrupt("return");case 2:for(this.loadAdStyle_(),r=this.adSettings_,s=r.ad_cap,n=r.ad_manager_body,(o=document.createElement("div")).style.position="absolute",o.style.top="-100vh",i=[],a=[],u=[],l=0;l<=s;l+=1)h={ad:!0,title:"Sponsored",settings:this.adSettings_,id:(0,y.randomAlphaNum)(10)},c=new E.default(h,h.id,this.groupsOverlay_,this.layout_,this.instanceId_),h.instance=c,p=c.render(),_=c.load(),i.push(p),a.push(_),u.push(h);Promise.all(i).then(function(e){e.forEach(function(e,r){o.appendChild(e),v.storyShadowRoot_.appendChild(o),u[r].node=e,a[r].then(function(e){"filled"===e&&(v.adGroups_.push(u[r]),n||v.renderAdGroup_(t,u[r]))})})});case 12:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"loadAdStyle_",value:function(){if(!this.storyShadowDom_.querySelector('style[data-type="ad-style"]')){var e=document.createElement("style");e.dataset.type="ad-style",e.textContent="\n .storyly-adsense {\n --i--storyly-story-desktop-one-panel-ratio: 69/116;\n --i--storyly-story-desktop-one-panel-responsive-margin: max(74px,8.25vh);\n --i--storyly-story-desktop-one-panel-height: calc(100vh - var(--i--storyly-story-desktop-one-panel-responsive-margin)*2);\n --i--storyly-story-desktop-one-panel-width: calc(var(--i--storyly-story-desktop-one-panel-height)*var(--i--storyly-story-desktop-one-panel-ratio));\n position: absolute;\n left: 50%;\n top: 12%;\n transform: translateX(-50%);\n width: calc(var(--i--storyly-story-desktop-one-panel-width) - 20%) !important;\n height: calc(var(--i--storyly-story-desktop-one-panel-height) - 20%) !important;\n text-align: center;\n }\n .storyly-ad-manager {\n position: absolute;\n left: 50%;\n top: 12%;\n transform: translateX(-50%);\n text-align: center;\n min-width: 300px;\n min-height: 200px;\n }\n ".replace(/\s+/g," "),this.storyShadowDom_.appendChild(e)}}},{key:"removeStoryly_",value:function(){this.remove(),this.handleEvent_("noStoryGroup")}},{key:"on",value:function(e,t){this.events_=P(P({},this.events_),{},(0,s.default)({},e,t)),this.globalInstanceData.events=this.events_}},{key:"handleEvent_",value:function(e,t){if(this.events_[e]&&"function"==typeof this.events_[e])try{this.events_[e](t)}catch(r){console.error(r)}else if(this.events_[e])throw TypeError("".concat(e," event must be a function!"))}},{key:"loaded",value:function(){var t=this,r=[].concat((0,e.default)(this.groups_),(0,e.default)(this.hiddenStoryGroups_)).filter(function(e){return!e.ad}).map(function(e){var t;return{title:e.title,iconUrl:null!==(t=e.icon_image_url)&&void 0!==t?t:e.icon_video_url,id:e.group_id,pinned:e.pinned,stories:e.stories,type:e.type,nudge:e.nudge}});this.handleEvent_(b.UserEventTypes.loaded,{groupList:r,dataSource:this.isCache_?f.dataSource.cache:f.dataSource.network}),this.EventImpl.onScreenEvent(this.isCache_),this.handleOpenStoryByUrl_(),this.adSettings_.ad_manager_body&&(this.adInterval_=setInterval(function(){window.googletag&&(t.loadAdGroups_(),clearInterval(t.adInterval_))},100)),this.setStorylyBarObserver_(),this.handleI18n_()}},{key:"failed_",value:function(){this.handleEvent_(b.UserEventTypes.loadFailed)}},{key:"handleI18n_",value:function(e){var t,r=this,s=(null!=e?e:{}).detail;(null!==(t=null==s?void 0:s.wrapperDom)&&void 0!==t?t:this.storyShadowRoot_).querySelectorAll("[data-i18n-key]").forEach(function(e){var t=e,s=e.getAttribute("data-i18n-key"),n=r.globalInstanceData.languageJSON[s];n&&m.LocalizationImpl.localizeTexts(t,n)})}},{key:"setContainerHeight_",value:function(){var e=[];this.groupsWrapper_.querySelectorAll(".storyly__story-group-container").forEach(function(t){return e.push(t.offsetHeight)});var t=Math.max.apply(Math,e);(0,_.setStyle)(this.groupsWrapper_,["height","".concat(t+2,"px")])}},{key:"handleOpenStoryByUrl_",value:function(){var e=this.shareParams_,t=e.group,r=e.storyIndex;void 0===t||"number"!=typeof r&&r>0||this.showStory_()}},{key:"setSeenForGroup_",value:function(){var e=this.getSeenGroups_(),t=this.getActiveGroup_(),r=this.getActiveStory_();if(!(t.ad||t.nudge||(0,y.isLiveVideo)(t.type))){e[t.group_id]?e[t.group_id].stories.includes(r.story_id)||e[t.group_id].stories.push(r.story_id):e[t.group_id]={seen:!0,stories:[r.story_id]},p.default.setInstanceId(this.instanceId_).setItemToInstance("Storyly_groupSeenState",e);var s=this.groups_.find(function(e){return e.group_id===t.group_id}),n=this.groupCircleNodes_.some(function(e){return+e.dataset.id===s.group_id&&e.classList.contains("seen")}),o=this.seenGroups_.some(function(e){return e.group_id===s.group_id});!this.checkSeenStories_(s)||n||o||this.seenGroups_.push(s)}}},{key:"handleImpressionEvent_",value:function(){var e={products:this.storylyHydration,language:this.userConfig_.language,country:this.userConfig_.country};this.EventImpl.handleImpressionEvent(e),this.setSeenForGroup_()}},{key:"loadGroupCircles_",value:function(){var r=(0,t.default)(d.default.mark(function t(r){var s,n,o,i,a,u,l,h,c=this;return d.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.nudgeGroups_=r.filter(function(e){return e.nudge}),0!==(s=r.filter(function(e){return!e.nudge})).length){t.next=4;break}return t.abrupt("return");case 4:return n={seenList:[],unseenList:[]},o={seenList:[],unseenList:[]},this.storyGroupObserver_=(0,m.intersectionObserverImpl)(this.groupsWrapper_,this.groupObserverCallback_),i=[],a=[],u=(0,m.storyGroupCircleTemplateImpl)(this.customStoryGroupHTML_),l=this.groupsWrapper_.classList.contains("style-scope"),s.forEach(function(e,t){var r=e.title,d=e.type,h=e.pinned;h=h||(0,y.isLiveVideo)(d);var p=(0,y.generateHtmlFromTemplate)(u(e,c.instanceId_,c.groupsWrapper_)),v=p.querySelector(".storyly__story-group-title");if(v){var f=r;r.length>25&&(f="".concat(r.substring(0,25),"...")),v.innerText=f}var m,S=c.checkSeenStories_(e);c.customStoryGroupHTML_&&(m=(0,g.handleCustomStoryGroupElement)(e,t,c.customStoryGroupHTML_,S),l?p=m:c.appendChild(m)),p.dataset.id=e.group_id,e.hidden&&(0,_.setClass)(p,"hidden"),h?((0,_.setClass)(p,"pinned"),i.push(e),a.push(p),S&&(0,_.setClass)(p,"seen")):S?((0,_.setClass)(p,"seen"),n.seenList.push(p),o.seenList.push(e)):(n.unseenList.push(p),o.unseenList.push(e)),p.dataset.order=t;var b=S?c.globalInstanceData.languageJSON.seen:c.globalInstanceData.languageJSON.unseen,w=h?c.globalInstanceData.languageJSON.pinned:" ";p.ariaLabel="of {@_".concat(s.length,"_2}, {@_").concat(r,"_3}, {@_").concat(w,"_4}, {@_").concat(b,"_5}"),m&&(m.ariaLabel="Story position ".concat(t+1," of ").concat(s.length,", ").concat(r,", ").concat(h?"pinned, ":"").concat(b)),(e.stories.some(function(e){return e.alt_text})||c.globalInstanceData.accessibility)&&(c.globalInstanceData.storiesHasAltText=!0),p.addEventListener("click",c.handleClickGroup_,!1),c.customStoryGroupHTML_&&c.handleBarStyleEvents_(p)}),h=[].concat(i,(0,e.default)(o.unseenList),(0,e.default)(o.seenList)),this.hiddenStoryGroups_=h.filter(function(e){return e.hidden&&!e.conditional}),this.hiddenConditionalGroups_=h.filter(function(e){return e.hidden&&e.conditional}),t.next=17,h.filter(function(e){return!e.hidden&&!e.nudge}).map(function(e,t){var r=e;return(r=c.setGroupInstance_(e,t)).instance.render().then(function(e){c.swiper_.appendSlide(e)}),r});case 17:this.groups_=t.sent,[].concat(a,(0,e.default)(n.unseenList),(0,e.default)(n.seenList)).forEach(function(e,t){var r=e;if(e.classList.contains("hidden")?c.hiddenStoryGroupNodes_.push(e):(c.groupCircleNodes_.push(e),c.groupsList_.appendChild(e)),r.ariaLabel="Story position {@_".concat(t+1,"_1} ").concat(r.ariaLabel),c.customStoryGroupHTML_){var s=c.getCustomGroupAssignedElement_(e);s&&(s.dataset.sortorder=t)}r.dataset.sortorder=t}),(0,_.setClass)(this.groupsWrapper_,this.properties_.storyGroupAlign),this.handleI18n_({detail:{wrapperDom:this.groupsList_}}),this.loadShareParams_().catch(function(){}),this.loaded(),m.StoryGroupAnimationImpl.add(this.groupCircleNodes_,this.properties_.storyGroupAnimation);case 24:case"end":return t.stop()}},t,this)}));return function(e){return r.apply(this,arguments)}}()},{key:"handleBarStyleEvents_",value:function(e){var t=this;e.addEventListener("mouseenter",function(){var r=t.getCustomGroupAssignedElement_(e),s=r.querySelector(".storyly__story-preview-video");if((0,_.setClass)(r,"storyly__story-group-hovered"),s){var n=r.querySelector(".storyly__story-preview-video source");if(""===n.getAttribute("src")){var o=s.dataset.src;n.src=o,s.load()}s.play()}},!1),e.addEventListener("mouseleave",function(){var r,s=t.getCustomGroupAssignedElement_(e);(0,_.removeClass)(s,"storyly__story-group-hovered"),null===(r=s.querySelector(".storyly__story-preview-video"))||void 0===r||r.pause()},!1)}},{key:"groupObserverCallback_",value:function(e){var t=this;e.forEach(function(e){if(e.isIntersecting){var r,s=e.target,n=s.dataset.id;if(t.groups_.forEach(function(e){e.group_id===+n&&(r=e)}),!r.onView){var o;if(t.loadGroupInstance_(r),s.setAttribute("onView",""),"SLOT"!==s.nodeName)(0,k.default)({mediaDom:null!==(o=s.querySelector("img"))&&void 0!==o?o:s.querySelector("video"),group:r,containerStyle:{width:"".concat(Number(t.properties_.storyGroupSize.split("x")[0])),height:"".concat(Number(t.properties_.storyGroupSize.split("x")[1])),position:"absolute",border:"3px solid #fff"}});clearTimeout(t.eventTimeout_),t.barViewed_&&(t.eventTimeout_=setTimeout(function(){return t.sendBarViewEvent_()},1e3))}r.onView=!0}})}},{key:"loadShareParams_",value:function(){var e,t,s,n=new URLSearchParams(window.location.search),o=n.get("storyly");if(!o&&!this.openStoryParams_)return Promise.reject();if(2===(o=this.openStoryParams_||JSON.parse(o)).length){var i=o,a=(0,r.default)(i,2);e=a[0],"number"==typeof(s=a[1])&&(t=s,s=null)}else{var u=o,l=(0,r.default)(u,3);e=l[0],t=l[1],s=l[2]}var d=this.groups_.find(function(t){return t.group_id===+e}),h=null==d?void 0:d.stories.findIndex(function(e){return e.story_id===+t});if(!d){var c={detail:{eventName:b.CustomerEventTypes.storyOpenFailed,params:{errorMessage:"story group does not exist."}}};return this.handleCustomerEvent_(c),Promise.reject(new Error("story group does not exist."))}if(-1===h&&t){var p={detail:{eventName:b.CustomerEventTypes.storyOpenFailed,params:{errorMessage:"story does not exist."}}};return this.handleCustomerEvent_(p),Promise.reject(new Error("story does not exist."))}t||(h=0);var _=!!+n.get("storylyResume");return this.shareParams_={group:d,storyIndex:h,playMode:s,resumeStory:_},s&&(this.swiper_.allowTouchMove=!1),this.globalInstanceData.shareParams=this.shareParams_,Promise.resolve()}},{key:"setSwiperEvents_",value:function(){var e=this;this.swiper_.on("sliderFirstMove",function(){e.swiperMove_=!0}),this.swiper_.on("realIndexChange",function(t){if(e.storylyOpen_){if(!e.shareParams_.group)e.getActiveStory_().instance.pause();e.layout_===S.default.MODERN&&e.layoutInstance_.handleStoryGroupNavigationButtons(e.groups_,t.activeIndex)}}),this.swiper_.on("transitionEnd",function(t){if(e.swiperMove_=!1,e.storylyOpen_)if(e.shareParams_.group)e.currentGroupIndex_=t.activeIndex;else{if(t.activeIndex!==e.currentGroupIndex_){if(e.layout_===S.default.CLASSIC){var r=e.getActiveGroup_(),s=t.realIndex<t.previousIndex?"prev":"next";r.instance.sendGroupClickedEvent(s),e.getActiveStory_().instance.sendStoryClickedEvent(s)}e.handleCompleteGroupEvent_(),e.groups_[e.currentGroupIndex_].instance.unLoad({holdActive:!0}),e.currentGroupIndex_=t.activeIndex,e.loadNextGroupInstance_(),e.EventImpl.handleSwipingGroupEvent(t.swipeDirection),e.groups_[e.currentGroupIndex_].instance.show(),e.handleImpressionEvent_()}else e.windowResize_||(e.storyTouchAction_=!1);e.windowResize_=!1,t.slides.forEach(function(e){e.classList.contains("swiper-slide-active")?(0,y.setAttribute)(e,"aria-hidden","false"):(0,y.setAttribute)(e,"aria-hidden","true")})}})}},{key:"setGroupInstance_",value:function(e,t){var r=this.layoutInstance_.setGroupInstance(e,t);return P(P({},e),{},{currentOrder:t,instance:r})}},{key:"loadGroupInstance_",value:function(e){e.instance&&e.instance.load()}},{key:"checkSeenStories_",value:function(e){var t=this.getSeenGroups_(),r=e.stories.filter(function(e){return e.visible});return 0!==r.length&&r.every(function(r){var s;return!(null===(s=t[e.group_id])||void 0===s||null===(s=s.stories)||void 0===s||!s.includes(r.story_id))})}},{key:"renderAdGroup_",value:function(e,t){if(this.isAdEnable_()&&0!==this.adGroups_.length){var r=this.adSettings_,s=r.ad_frequency,n=r.ad_first,o=r.ad_cap,i=0,a=e+n,u=0;this.groups_.forEach(function(e,t){e.ad&&(u=t,a=t+(s+1),i+=1)}),i>=o||u===this.groups_.length-1||(this.groups_.splice(a,0,t),this.swiper_.addSlide(a,t.node))}}},{key:"handleClickGroup_",value:function(e){var t,r,s=this,n=e.target.dataset.id;this.groups_.forEach(function(e,s){e.group_id===+n&&(r=s,t=e)}),this.adSettings_.ad_manager_body?this.adGroups_.forEach(function(e){s.renderAdGroup_(r,e)}):this.loadAdGroups_(r),this.showGroup_(t,r)}},{key:"setFocusableElements_",value:function(){var e=[];if(this.layout_===S.default.CLASSIC){var t=this.groupsOverlay_.querySelector("button.storyly__mobile-view-close-story");e=[this.groupsOverlay_.querySelector(".navigate-button.prev-button button"),t]}if(this.layout_===S.default.MODERN){var r=this.groupsOverlay_.querySelector("button.close-story"),s=this.groupsOverlay_.querySelector(".story-group-navigation-button.prev-story-group .story-group-navigation-button-container");"none"===s.parentElement.style.display&&(s=this.groupsOverlay_.querySelector(".prev-story-button")),e=[s,r]}this.focusableEls_=e}},{key:"handleNudgeGroups_",value:function(){var e=(0,t.default)(d.default.mark(function e(t){var r,s;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.shareParams_.playMode,!this.nudgeImpl_||r){e.next=6;break}return e.next=4,this.nudgeImpl_.renderNudgeGroups({layoutInstance:this.layoutInstance_,groups:{default:this.groups_,nudge:this.nudgeGroups_},swiperInstance:this.swiper_,groupIndex:t});case 4:s=e.sent,this.groups_=s;case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"clearNudgeGroups_",value:function(){var e=(0,t.default)(d.default.mark(function e(){var t;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.nudgeImpl_){e.next=5;break}return e.next=3,this.nudgeImpl_.clearNudgeGroups(this.groups_);case 3:t=e.sent,this.groups_=t;case 5:return e.abrupt("return",Promise.resolve());case 6:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"showGroup_",value:function(e,t){var r=this;this.isMobileView_&&(0,m.calcStorySizeImpl)(this.groupsOverlay_),this.handleNudgeGroups_(t),this.handleI18n_(),this.setOverlayVh_(),this.setStoryNavigationEvents_(),this.removeEventListener("keydown",this.handleTabKeyPressListener_),this.setStyleToDocument_(),m.StoryGroupAnimationImpl.remove(this.groupCircleNodes_,this.properties_.storyGroupAnimation),this.swiper_.slideTo(t),this.swiper_.update();var s=this.swiper_.slides[t];this.storylyOpen_=!0,setTimeout(function(){e.instance.show(),(0,_.setClass)(r.groupsOverlay_,"active"),s.ariaHidden="false",r.storyShadowDom_.removeAttribute("tabindex"),r.groupsOverlay_.ariaHidden="false",r.setFocusableElements_()},150),this.currentGroupIndex_=t,this.loadNextGroupInstance_(),this.setSwiperEvents_(),this.layout_===S.default.MODERN&&this.layoutInstance_.handleStoryGroupNavigationButtons(this.groups_,t),this.EventImpl.handleSelectedGroupEvent(),this.handleImpressionEvent_(),this.handleEvent_(b.UserEventTypes.openStoryGroup,P(P({},null!=e?e:{}),{},{instance:void 0}))}},{key:"setStyleToDocument_",value:function(){this.globalInstanceData.storylyEmbed.init||((0,_.setStyle)(document.documentElement,["overflow","hidden"]),(0,_.setStyle)(document.documentElement,["overscrollBehaviorX","none"]))}},{key:"resetStyleToDocument_",value:function(){(0,_.resetStyle)(document.documentElement,["overflow","overscrollBehaviorX","position"])}},{key:"showStory_",value:function(){var e=this,t=this.shareParams_,r=t.group,s=t.storyIndex,n=t.playMode,o=this.groups_.find(function(e){return e.group_id===r.group_id}),i=this.getStoryGroupElement_(r),a=this.groups_.findIndex(function(e){return e.group_id===r.group_id});i.setAttribute("onView","");var u=i.querySelector("img"),l=i.querySelector("video");(u||l)&&(0,k.default)({mediaDom:null!=u?u:l,group:o,containerStyle:{width:"".concat(Number(this.properties_.storyGroupSize.split("x")[0])),height:"".concat(Number(this.properties_.storyGroupSize.split("x")[1])),position:"absolute",border:"3px solid #fff"}}),o.onView=!0,o.instance.loadByParameters(s),"string"!=typeof n&&(this.adSettings_.ad_manager_body?this.adGroups_.forEach(function(t){e.renderAdGroup_(a,t)}):this.loadAdGroups_(a)),this.showGroup_(o,a)}},{key:"getSeenGroups_",value:function(){return p.default.setInstanceId(this.instanceId_).getItemFromInstance("Storyly_groupSeenState")}},{key:"loadInlineStyle_",value:function(){var e=this;if(this.storyGroupStyle.textContent=(0,_.inlineStyle)(this.properties_,this.instanceId_),this.customStoryGroupHTML_){var t=document.createElement("style");t.textContent=_.slotStyle.replace(/\s+/g," "),this.appendChild(t)}this.setOverlayVh_(),this.storylyFontCssDom_=document.createElement("style"),document.head.appendChild(this.storylyFontCssDom_);var r=document.createElement("style");this.storyShadowRoot_.appendChild(r),r.textContent+=(0,_.inlineStoryGroupStyle)(this.properties_);var s="sdk/".concat("3.3.0");"showcase.storyly.io"===window.location.hostname&&(s=new URLSearchParams(window.location.search).get("version")),fetch("https://web-story.storyly.io/".concat(s,"/storyly-web.css")).then(function(e){return e.text()}).then(function(e){r.textContent+=e.replace(/\s+/g," ")}),fetch("https://web-story.storyly.io/fonts/fonts.css").then(function(e){return e.text()}).then(function(t){e.storylyFontCssDom_.textContent+=t.replace(/\s+/g," ")})}},{key:"setOverlayVh_",value:function(){var e=.01*window.innerHeight;this.groupsOverlay_.style.setProperty("--vh","".concat(e,"px"))}},{key:"close",value:function(){this.handleCloseGroup_()}},{key:"openStory",value:function(e){var t=this,r=e.group,s=e.story,n=e.playMode;this.openStoryParams_=[r,s,n],this.groups_.length>0&&this.loadShareParams_().then(function(){t.handleOpenStoryByUrl_()}).catch(function(){})}},{key:"setSegments",value:function(t){var r=this;this.userConfig_.segments&&(0,y.isArraysEqual)(this.userConfig_.segments,t)||(this.segmentsDebounce_&&clearTimeout(this.segmentsDebounce_),this.segmentsDebounce_=setTimeout(function(){var s;r.groupShadowRoot_.innerHTML="",r.storylyFontCssDom_.remove(),r.replaceChildren(),r.renderMainDoms_();var n=[].concat((0,e.default)(null!==(s=r.userConfig_.segments)&&void 0!==s?s:[]),(0,e.default)(Array.isArray(t)?t:[])).length>0?(0,e.default)(new Set(t.map(function(e){return String(e)}))):null;r.init_=!1,r.userConfig_=P(P({},r.userConfig_),{},{segments:n}),r.init(r.userConfig_)},200))}},{key:"setProperties",value:function(e){(0,_.removeClass)(this.groupsWrapper_,this.properties_.storyGroupAlign),this.properties_=P(P(P({},this.properties_),e),{},{scrollIndicatorOptions:P(P({},this.properties_.scrollIndicatorOptions),(null==e?void 0:e.scrollIndicatorOptions)||{})}),(0,_.setClass)(this.groupsWrapper_,this.properties_.storyGroupAlign),this.globalInstanceData.properties=this.properties_,this.groupShadowRoot_.querySelector("#storyly__story-group-style-tag").textContent=(0,_.inlineStyle)(this.properties_,this.instanceId_),this.storyShadowRoot_.querySelector("style")&&(this.storyShadowRoot_.querySelector("style").textContent+=(0,_.inlineStoryGroupStyle)(this.properties_)),this.layoutImpl_&&(this.layoutImpl_.refreshSortData(),this.layoutImpl_.sort("order")),this.setContainerHeight_()}},{key:"setUserPropertiesData",value:function(){var e=(0,t.default)(d.default.mark(function e(r){var s,n,o=this;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r&&null!==(s=Object.keys(r))&&void 0!==s&&s.length){e.next=2;break}return e.abrupt("return");case 2:if(this.userPropertyData_=r,null!==(n=this.storyGroupsWithUserProperties_)&&void 0!==n&&n.length){e.next=5;break}return e.abrupt("return");case 5:this.storyGroupsWithUserProperties_.forEach(function(){var e=(0,t.default)(d.default.mark(function e(t){var r;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=(0,m.createUserPropertyImpl)(o.userPropertyData_,t)).hidden){e.next=3;break}return e.abrupt("return");case 3:o.createGroupInstanceAndReorderCircleNodes_(r);case 4:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}());case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setEmbedContainerRatio",value:function(e){this.groupsOverlay_.style.setProperty("--i--storyly-story-layer-width","".concat(e.width,"px")),this.groupsOverlay_.style.setProperty("--i--storyly-story-layer-height","".concat(e.height,"px"))}},{key:"setStorylyHydration",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!Array.isArray(r))throw new Error("Hydration Data must be an Array!");this.storylyHydration=[].concat((0,e.default)(r),(0,e.default)(this.allProductsOfProductFeed_||[])),this.hiddenStoryGroups_.forEach(function(e){var r=(0,m.createUserPropertyImpl)(t.userPropertyData_,e);if(!r.hidden)if(r.stories.forEach(function(e){var r=(0,y.getProductLayers)(e),s=r.flatMap(function(e){return e.products.map(function(t){return P(P({},t),{},{type:e.type})})});if(s.length){var n=s.filter(function(e){return e.type!==G.LayerTemplateTypes.PRODUCT_CATALOG}).every(function(e){return t.storylyHydration.some(function(t){return t.product_group_id===e.product_group_id})}),o=(0,y.checkProductCatalogAtLeastOne)(r,t.storylyHydration);e.hidden=!n||!o}}),r.stories.some(function(e){return!e.hidden}))t.createGroupInstanceAndReorderCircleNodes_(r);else{var s=t.groupCircleNodes_.find(function(t){return+t.dataset.id===e.group_id});s&&t.removeGroupInstanceAndReorderCircleNodes_(s,e)}})}},{key:"updateCart",value:function(e){this.isStorylyCartActive=!0,this.setProductCartItems(e)}},{key:"setProductCartItems",value:function(e){this.storylyCheckoutProducts=e||{products:[],price:"",sales_price:"",price_currency:""};var t=this.getActiveGroup_();if(t){var r=t.instance;null!=r&&r.storylyCart&&e&&r.storylyCart.updateCart(e)}}},{key:"setLang",value:function(e){var t=e.language,r=e.json,s=t||this.userConfig_.locale||navigator.language,n=m.LocalizationImpl.getLocalizedJSON(r,s),o=this.globalInstanceData.languageJSON;this.globalInstanceData.languageJSON=P(P({},o),n),this.handleI18n_()}},{key:"setExternalData",value:function(){}},{key:"remove",value:function(){this.parentElement.removeChild(this),this.storyShadowDom_.remove(),this.storylyFontCssDom_.remove()}}]),l}((0,l.default)(HTMLElement));window.StorylyWeb=O;var L=exports.default=O;
|
|
217
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=x(require("@babel/runtime/helpers/toConsumableArray")),t=x(require("@babel/runtime/helpers/asyncToGenerator")),r=x(require("@babel/runtime/helpers/slicedToArray")),s=x(require("@babel/runtime/helpers/defineProperty")),n=x(require("@babel/runtime/helpers/classCallCheck")),o=x(require("@babel/runtime/helpers/createClass")),i=x(require("@babel/runtime/helpers/inherits")),a=x(require("@babel/runtime/helpers/possibleConstructorReturn")),u=x(require("@babel/runtime/helpers/getPrototypeOf")),l=x(require("@babel/runtime/helpers/wrapNativeSuper")),d=x(require("@babel/runtime/regenerator")),h=require("uuid"),c=x(require("./lib/api.ts")),p=x(require("./lib/storage")),_=require("./lib/style"),y=require("./lib/util"),v=x(require("./constants/playmode"));require("./main.scss");var g=require("./service/custom-story-group-design-impl"),f=require("./constants/common"),m=require("./service"),S=x(require("./constants/layouts")),b=require("./constants/events"),w=x(require("./constants/directions")),C=x(require("./constants/instanceStyleKeys")),I=x(require("./constants/barLayouts")),E=x(require("./components/AdGroup")),G=require("./constants/layerTypes"),k=x(require("./service/focal-point-impl.ts"));function x(e){return e&&e.__esModule?e:{default:e}}function A(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,s)}return r}function P(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?A(Object(r),!0).forEach(function(t){(0,s.default)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):A(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function D(e){var t=T();return function(){var r,s=(0,u.default)(e);if(t){var n=(0,u.default)(this).constructor;r=Reflect.construct(s,arguments,n)}else r=s.apply(this,arguments);return(0,a.default)(this,r)}}function T(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(T=function(){return!!e})()}var O=function(a){(0,i.default)(l,a);var u=D(l);function l(){var e;return(0,n.default)(this,l),(e=u.call(this)).groupShadowRoot_=e.attachShadow({mode:"open"}),e.storyShadowRoot_=null,e.groups_=[],e.token_=null,e.uuid_=null,e.sessionId_=null,e.selectedGroup_={},e.storylyOpen_=!1,e.retryCount_=0,e.shareParams_={},e.openStoryParams_=null,e.seenGroups_=[],e.groupCircleNodes_=[],e.hiddenStoryGroupNodes_=[],e.currentGroupIndex_=0,e.adGroups_=[],e.adSettings_={},e.properties_={storyGroupTextColor:"#4A4A4A",storyGroupTextVisibility:!0,storyGroupSize:"72x72",storyGroupBorderRadius:72,storyGroupTextFont:"Storyly-Inter",storyTextFont:"Storyly-Inter",storyGroupAlign:"center",storyGroupMarginHorizontal:10,storyGroupIconBorderColorNotSeen:["#FFCC64","#DC475B","#992DBD"],storyGroupIconBorderColorSeen:["#DBDBDB"],storyGroupTextSize:13,storyGroupTextWeight:"600",storyGroupBorderSize:7,storyGroupTextLineHeight:1.3,storyGroupPinBackgroundColor:"#FFCB00",storyGroupPinBorderColor:"#fdbc59",storyGroupPinIcon:null,storyGroupTextMarginTop:6,storyGroupTextSeenColor:"#333",storyBorderGapSize:3,storyBorderGapColor:"#fff",storyGroupAnimation:{},scrollIndicatorOptions:{indicatorWidth:32,indicatorHeight:32,indicatorBorderRadius:16,indicatorBorderWidth:1,indicatorBorderColor:"#D8D8D8",indicatorBoxBackgroundColor:"#FFFFFF",indicatorDefaultIconsColor:"#000000",indicatorBoxShadow:"none",customLeftIndicator:"",customRightIndicator:"",leftIndicatorMargin:8,rightIndicatorMargin:8},storyGroupProgressBackgroundColor:"rgba(255, 255, 255, 0.5)",storyGroupProgressFillColor:"rgba(255, 255, 255, 1)",storyGroupTitleVisible:!0,storyGroupCoverVisible:!0,storyGroupCloseButtonVisible:!0},e.events_={},e.payload_={app:{bundle:window.location.host,version:"3.4.0"},device:{height:window.innerHeight,unique_id:null,locale:navigator.language,width:window.innerWidth,userAgent:navigator.userAgent,is_test:!1},sdk_version:"latest",user:{segments:null},custom_parameter:null,session_id:null,preview_session_id:null,payload:{}},e.swipingDown_={scrollY:0,pageY:0},e.swiperMove_=!1,e.isMobileView_=(0,y.isMobileView)(),e.layout_=S.default.MODERN,e.layoutInstance_=null,e.userConfig_={},e.hasAdblocker_=!1,e.storylyConnected_=!1,e.init_=!1,e.documentDir_=document.documentElement.dir||w.default.LTR,e.storylyCheckoutProducts={products:[],price:"",sales_price:"",price_currency:""},e.isStorylyCartActive=!1,e.storylyHydration=[],e.globalInstanceData={shareParams:{},direction:e.documentDir_,accessibility:p.default.getItemFromGlobal("accessibilitiy",!1),storylyEmbed:{},videoMuted:!0,languageJSON:{}},e.storylyWebCss_=null,e.storylyFontCss_=null,e}return(0,o.default)(l,[{key:"connectedCallback",value:function(){var e=this;this.storylyConnected_||(this.attachCallbacksToElement_(),this.renderMainDoms_(),this.adBlockerDetector_(),this.storylyConnected_=!0,window.addEventListener("resize",function(){e.windowResize_=!0,e.isMobileView_&&(0,m.calcStorySizeImpl)(e.groupsOverlay_),e.setOverlayVh_()}))}},{key:"attachCallbacksToElement_",value:function(){this.handleNextGroup_=this.handleNextGroup_.bind(this),this.handlePrevGroup_=this.handlePrevGroup_.bind(this),this.handleCloseGroup_=this.handleCloseGroup_.bind(this),this.handleContainerTouchStart_=this.handleContainerTouchStart_.bind(this),this.handleContainerTouchEnd_=this.handleContainerTouchEnd_.bind(this),this.handleContainerTouchMove_=this.handleContainerTouchMove_.bind(this),this.handleNextStory_=this.handleNextStory_.bind(this),this.handlePrevStory_=this.handlePrevStory_.bind(this),this.handleImpressionEvent_=this.handleImpressionEvent_.bind(this),this.handleKeyboard_=this.handleKeyboard_.bind(this),this.handleClickGroup_=this.handleClickGroup_.bind(this),this.handleContextMenu_=this.handleContextMenu_.bind(this),this.getStoryGroupElement_=this.getStoryGroupElement_.bind(this),this.groupObserverCallback_=this.groupObserverCallback_.bind(this),this.handleTabVisibility_=this.handleTabVisibility_.bind(this),this.handleCustomerEvent_=this.handleCustomerEvent_.bind(this),this.handleConditionalEvent_=this.handleConditionalEvent_.bind(this),this.handleI18n_=this.handleI18n_.bind(this),this.handleUserEvent_=this.handleUserEvent_.bind(this)}},{key:"renderMainDoms_",value:function(){var e;this.storyShadowDom_=document.createElement("storyly-stories"),this.storyShadowRoot_=this.storyShadowDom_.attachShadow({mode:"open"}),this.storyShadowDom_.setAttribute("tabindex","-1"),this.storyShadowDom_.setAttribute("role","application"),this.setAttribute("role","application"),this.swiperContainer_=document.createElement("div"),this.swiperWrapper_=document.createElement("div"),this.groupContainer_=document.createElement("div"),this.groupsWrapper_=document.createElement("div"),this.groupsList_=document.createElement("div"),this.groupsOverlay_=document.createElement("div");var t=null===(e=this.parentElement)||void 0===e?void 0:e.parentElement;if("STORYLY-WEB-EMBED"===(null==t?void 0:t.nodeName)){t.firstElementChild.appendChild(this.storyShadowDom_),this.globalInstanceData.storylyEmbed={init:!0,autoPlay:t.hasAttribute("autoplay"),closeButton:t.hasAttribute("useClose"),shareButton:t.hasAttribute("useShare"),container:t,canPlay:!1},(0,y.setAttribute)(this.groupsOverlay_,"embed-mode",!0),(0,y.setAttribute)(this.groupsWrapper_,"embed-mode",!0);var r=t.getAttribute("group");this.openStoryParams_=[r]}else document.body.appendChild(this.storyShadowDom_);var s=[w.default.LTR,w.default.RTL].includes(this.documentDir_)?this.documentDir_:w.default.LTR;this.globalInstanceData.direction=s,(0,y.setAttribute)(this.swiperContainer_,"dir",s),(0,y.setAttribute)(this.groupsOverlay_,"direction",s),(0,y.setAttribute)(this.groupsList_,"role","list"),(0,y.setAttribute)(this.groupsOverlay_,"role","dialog"),(0,y.setAttribute)(this.groupsOverlay_,"aria-modal","true"),this.groupsOverlay_.style.visibility="hidden",(0,_.setClass)(this.groupContainer_,"storyly__group-container"),(0,_.setClass)(this.swiperContainer_,"swiper"),(0,_.setClass)(this.swiperWrapper_,"swiper-wrapper"),(0,_.setClass)(this.groupsWrapper_,"storyly__story-groups"),(0,_.setClass)(this.groupsOverlay_,"storyly__groups-overlay"),(0,_.setClass)(this.groupsList_,"storyly__groups-list"),this.groupsWrapper_.appendChild(this.groupsList_),this.swiperContainer_.appendChild(this.swiperWrapper_),this.groupContainer_.appendChild(this.swiperContainer_),this.groupsOverlay_.appendChild(this.groupContainer_),this.storyShadowRoot_.appendChild(this.groupsOverlay_),this.groupShadowRoot_.appendChild(this.groupsWrapper_),this.storyGroupStyle=document.createElement("style"),this.storyGroupStyle.id="storyly__story-group-style-tag",this.groupShadowRoot_.appendChild(this.storyGroupStyle)}},{key:"init",value:function(e){if(!this.init_){this.init_=!0,this.userConfig_=null!=e?e:{};var t=p.default.getItemFromGlobal("Storyly_userConfig");this.userConfigChanged_=JSON.stringify(P(P({},t),{},{props:void 0}))!==JSON.stringify(P(P({},e),{},{props:void 0})),p.default.setItemToGlobal("Storyly_userConfig",this.userConfig_);var s=this.userConfig_,n=s.token,o=s.props,i=s.userPropertyData,a=s.productFeed,u=s.customStoryGroupHTML,l=s.presentationData,d=s.barLayout,c=s.isProductFallbackEnabled,v=void 0===c||c,g=s.isProductCartEnabled,b=s.inboxStory,w=s.shopify,C=s.events;if(!n)throw this.failed_(f.failedMessages.token),new Error("Token not found!");C&&console.warn("There is no events key in the 3.0 version. Please check docs: https://docs.storyly.io/docs/initial-web-sdk-setup"),this.shopify_=w,this.token_=n;var E=!l&&(0,y.decodeJwt)(this.token_);if(this.instanceId_=l?n:E.ins_id,(0,y.setAttribute)(this,"data-storyly-instance-id",this.instanceId_),(0,y.setAttribute)(this.storyShadowDom_,"data-storyly-instance-id",this.instanceId_),this.uuid_=p.default.setInstanceId(this.instanceId_).getItemFromInstance("Storyly_uuid",!1)||p.default.setInstanceId(this.instanceId_).setItemToInstance("Storyly_uuid",(0,h.v4)(),!1),this.sessionId_=p.default.setInstanceId(this.instanceId_).setItemToInstance("Storyly_session_id",(0,h.v4)(),!1),sessionStorage.removeItem("Storyly__fonts"),this.presentationData_=l,this.isProductFallbackEnabled_=!!v,this.isStorylyCartActive=g,d&&[I.default.CLASSIC,I.default.ENERGIZED].includes(d.view)&&!u){var G,k=320;(null===(G=d.style)||void 0===G?void 0:G.height)>0&&(k=d.style.height<200?200:d.style.height),this.barLayout_=P(P({},d),{},{style:P(P({},null==d?void 0:d.style),{},{height:k})}),(0,_.setStyle)(this.groupsWrapper_,["padding","".concat(.1*this.barLayout_.style.height,"px")]),this.customStoryGroupHTML_=(0,m.barLayoutImpl)(this.barLayout_,this)}this.isMobileView_&&(this.layout_=S.default.CLASSIC),i&&"Object"===Object.getPrototypeOf(i).constructor.name&&!l?this.userPropertyData_=i:this.setPropsByParams_(),a&&"Object"===Object.getPrototypeOf(a).constructor.name&&(this.productFeed_=a),this.properties_=P(P(P({},this.properties_),o),{},{scrollIndicatorOptions:P(P({},this.properties_.scrollIndicatorOptions),(null==o?void 0:o.scrollIndicatorOptions)||{})}),u&&(0,y.isStringHTML)(u)&&(this.customStoryGroupHTML_=u,this.properties_.storyGroupAnimation=void 0);var x=m.LocalizationImpl.getLocalizedJSON(null,this.userConfig_.locale||navigator.language);if("string"==typeof this.userConfig_.locale){var A=this.userConfig_.locale.split(/[-_]/),D=(0,r.default)(A,2),T=D[0],O=D[1];this.userConfig_.language=T,this.userConfig_.country=O}this.globalInstanceData.languageJSON=x,this.globalInstanceData.properties=this.properties_,this.globalInstanceData.presentationData=!!this.presentationData_,this.globalInstanceData.layout=this.layout_,this.globalInstanceData.inboxStory=b,this.globalInstanceData.apiEnv=this.userConfig_.apiEnv,this.groupCircleNodes_=[],this.handleInitMethods_()}}},{key:"handleInitMethods_",value:function(){var e=(0,t.default)(d.default.mark(function e(){return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setLayoutInstance_();case 2:this.setPayload_(),this.buildCallback_(),this.implementEvent_();case 5:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"setPropsByParams_",value:function(){var e=new URLSearchParams(window.location.search),t={},s=e.get("userProps"),n=e.get("customParameter");s&&(s.split(",").forEach(function(e){var s=e.split(":"),n=(0,r.default)(s,2),o=n[0],i=n[1];t["{".concat(o,"}")]=i}),this.userPropertyData_=t);n&&(this.userConfig_=P(P({},this.userConfig_),{},{customParameter:n}))}},{key:"setStorylyBarObserver_",value:function(){var t=this;(0,m.intersectionObserverImpl)(null,function(r){r.forEach(function(r){r.isIntersecting&&(t.layoutImpl_=(0,m.layoutImpl)(t.groupsList_,t.instanceId_),t.setContainerHeight_(),(0,m.renderScrollIndicator)(t.groupsWrapper_,t.properties_),t.layoutImpl_.on("layoutEnd",function(){[].concat((0,e.default)(t.groupCircleNodes_),(0,e.default)(t.hiddenStoryGroupNodes_)).forEach(function(e){t.storyGroupObserver_.observe(e)}),setTimeout(function(){return(0,m.renderScrollIndicator)(t.groupsWrapper_,t.properties_)},0)}),setTimeout(function(){return t.sendBarViewEvent_()},100),t.barViewed_=!0)})}).observe(this)}},{key:"sendBarViewEvent_",value:function(){var e=[],t=[];if(this.groups_.forEach(function(r){var s=r;r.onView&&!r.viewEventSend&&(e.push(r.group_id),s.viewEventSend=!0),r.onView&&t.push(P(P({},r),{},{instance:void 0}))}),0!==e.length){var r={sg_ids:e},s={detail:{eventName:b.CustomerEventTypes.renderedStoryGroups,params:t}};this.EventImpl.onBarViewedEvent(r),this.handleCustomerEvent_(s)}}},{key:"setLayoutInstance_",value:function(){var e=(0,t.default)(d.default.mark(function e(){var t,r,s,n,o;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.layout_!==S.default.MODERN){e.next=13;break}return e.next=3,require("_bundle_loader")(require.resolve("./layouts/Modern"));case 3:t=e.sent.default,r=new t(this.groupsOverlay_,this.getActiveGroup_.bind(this),this.instanceId_),this.layoutInstance_=r,(s=document.createElement("canvas")).width=3,s.height=3,(0,_.setClass)(s,"background-blur-canvas"),this.groupsOverlay_.appendChild(s),e.next=18;break;case 13:return e.next=15,require("_bundle_loader")(require.resolve("./layouts/Classic"));case 15:n=e.sent.default,o=new n(this.groupsOverlay_,this.instanceId_),this.layoutInstance_=o;case 18:(0,_.setClass)(this.groupContainer_,this.layout_===S.default.MODERN?"storyly__modern-layout":"storyly__classic-layout"),this.globalInstanceData.storylyEmbed.init&&(0,y.setAttribute)(this.groupContainer_,"embed-mode",this.globalInstanceData.storylyEmbed.init),(0,y.setAttribute)(this.groupContainer_,"direction",this.documentDir_),this.swiper_=(0,m.swiperImpl)(this.swiperContainer_,this.layout_);case 22:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"implementEvent_",value:function(){var e=this.getActiveGroup_.bind(this),t=this.getPrevGroup_.bind(this),r=this.getNextGroup_.bind(this);this.EventImpl=new m.EventImpl(this.storyShadowRoot_,e,t,r,this.api_)}},{key:"setPayload_",value:function(){var e=this.userConfig_,t=e.isTestMode,r=e.segments,s=e.customParameter,n=e.locale,o=(0,m.platformIml)(),i=o.os,a=o.browser,u=Array.isArray(r)&&r.length>0?r.map(function(e){return String(e)}):null;this.payload_=P(P({},this.payload_),{},{device:P(P({},this.payload_.device),{},{unique_id:this.uuid_,is_test:t,os:i,browser:a}),user:P(P({},this.payload_.user),{},{segments:u}),custom_parameter:s?String(s):null,locale:n,session_id:this.sessionId_}),this.globalInstanceData.eventPayload=this.payload_}},{key:"buildCallback_",value:function(){this.setAPI_(),this.setEventListeners_(),this.presentationData_?this.handleGroupsData_(this.presentationData_):this.fetchGroups_()}},{key:"setAPI_",value:function(){this.api_=new c.default(this.token_,this.instanceId_),this.globalInstanceData.API=this.api_}},{key:"setEventListeners_",value:function(){var e=this;this.storyShadowRoot_.addEventListener(b.CustomerEventTypes.nextStoryGroup,this.handleNextGroup_),this.storyShadowRoot_.addEventListener(b.CustomerEventTypes.previousStoryGroup,this.handlePrevGroup_),this.storyShadowRoot_.addEventListener("storyImpression",this.handleImpressionEvent_),this.storyShadowRoot_.addEventListener("onCloseGroup",this.handleCloseGroup_),this.storyShadowRoot_.addEventListener(b.CustomerEventTypes.nextStory,this.handleNextStory_),this.storyShadowRoot_.addEventListener(b.CustomerEventTypes.previousStory,this.handlePrevStory_),this.storyShadowRoot_.addEventListener("onCustomerEvent",this.handleCustomerEvent_),this.storyShadowRoot_.addEventListener("onConditionalEvent",this.handleConditionalEvent_),this.storyShadowRoot_.addEventListener("userEvent",this.handleUserEvent_),this.storyShadowRoot_.addEventListener("onI18nEvent",this.handleI18n_),this.storyShadowRoot_.addEventListener("onStorylyCartOpen",function(){var t;null===(t=e.getActiveGroup_().instance.storylyCart)||void 0===t||t.open()}),this.addEventListener("keydown",this.handleTabKeyPressListener_),this.layout_===S.default.MODERN&&this.storyShadowRoot_.addEventListener("storyChange",function(t){return(0,m.backgroundBlurImpl)(t,e.groupsOverlay_)}),(0,m.tabVisibilityImpl)(this.handleTabVisibility_)}},{key:"handleUserEvent_",value:function(e){var t=e.detail;this.handleEvent_(b.UserEvent,t)}},{key:"handleCustomerEvent_",value:function(e){var t=e.detail,r=t.eventName,s=t.params;this.handleEvent_(r,s)}},{key:"handleTabKeyPressListener_",value:function(e){var t=e.code,r=this.shadowRoot.activeElement;if(r=r||document.activeElement){this.lastActiveElement_=r;["Space","Enter"].includes(t)&&(r.classList.contains("group")||r.hasAttribute("slot"))&&(e.stopImmediatePropagation(),this.globalInstanceData.storiesHasAltText&&(this.globalInstanceData.accessibility=!0),this.handleClickGroup_({target:r}))}}},{key:"handleTabVisibility_",value:function(e){if(this.storylyOpen_&&this.globalInstanceData.storylyEmbed.canPlay){var t,r=this.getActiveStory_();if(document[e])r.instance.pause(!0);else null===(t=this.lastActiveElement_)||void 0===t||t.focus(),r.instance.play(!0)}}},{key:"setStoryNavigationEvents_",value:function(){this.isMobileView_&&(window.addEventListener(this.globalInstanceData.storylyEmbed.init?"pointerdown":"touchstart",this.handleContainerTouchStart_),window.addEventListener(this.globalInstanceData.storylyEmbed.init?"pointerup":"touchend",this.handleContainerTouchEnd_),this.globalInstanceData.storylyEmbed.init||window.addEventListener("touchmove",this.handleContainerTouchMove_),window.oncontextmenu=this.handleContextMenu_),this.globalInstanceData.storylyEmbed.init&&!this.isMobileView_&&this.groupsOverlay_.addEventListener("click",this.handleContainerTouchEnd_),window.addEventListener("keydown",this.handleKeyboard_)}},{key:"removeStoryNavigationEvents_",value:function(){this.isMobileView_&&(window.removeEventListener(this.globalInstanceData.storylyEmbed.init?"pointerdown":"touchstart",this.handleContainerTouchStart_),window.removeEventListener(this.globalInstanceData.storylyEmbed.init?"pointerup":"touchend",this.handleContainerTouchEnd_),this.globalInstanceData.storylyEmbed.init||window.removeEventListener("touchmove",this.handleContainerTouchMove_),window.oncontextmenu=null),window.removeEventListener("keydown",this.handleKeyboard_)}},{key:"handleContextMenu_",value:function(e){return e.preventDefault(),e.stopPropagation(),!1}},{key:"handleKeyboard_",value:function(e){var t=this.focusableEls_[0],r=this.focusableEls_[this.focusableEls_.length-1];if(("Tab"===e.key||9===e.keyCode)&&(e.shiftKey&&this.storyShadowRoot_.activeElement===t&&(r.focus(),e.preventDefault()),this.storyShadowRoot_.activeElement===r&&(t.focus(),e.preventDefault())),this.storylyOpen_){var s,n=e.key,o=e.code,i=e.keyCode;if("ArrowRight"===n||39===i)this.documentDir_===w.default.RTL?this.handlePrevStory_():this.handleNextStory_();else if("ArrowLeft"===n||37===i)this.documentDir_===w.default.RTL?this.handleNextStory_():this.handlePrevStory_();else if("Escape"===n||27===i){var a=this.groupsOverlay_.querySelector(".storyly__action-container"),u=null==a?void 0:a.classList.contains("active"),l=this.getActiveStory_(),d=this.groupsOverlay_.querySelector(".storyly__share-popup");if(u){var h=this.groupsOverlay_.querySelector(".storyly__story-group-overlay");return a.classList.remove("active"),h.classList.remove("active"),l.instance.playAndPauseStory(),void this.storyShadowRoot_.activeElement.blur()}if(d)return l.instance.hideShareWidget(),void l.instance.playAndPauseStory();this.handleCloseGroup_()}else if("Space"!==o&&32!==i||"BUTTON"===(null===(s=this.storyShadowRoot_.activeElement)||void 0===s?void 0:s.tagName)){if("KeyS"===o){var c=this.groupsOverlay_.querySelector(".storyly__action-container"),p=null==c?void 0:c.classList.contains("active"),_=this.groupsOverlay_.querySelector(".storyly__share-popup");if(p){var y=this.groupsOverlay_.querySelector(".storyly__story-group-overlay");c.classList.remove("active"),y.classList.remove("active")}if(_)return;this.getActiveStory_().instance.renderShareWidget()}}else{this.getActiveStory_().instance.playAndPauseStory()}}}},{key:"handleContainerTouchStart_",value:function(e){e.stopPropagation(),this.handleNavigation_=!0,this.storyPauseByTouch_()}},{key:"handleContainerTouchEnd_",value:function(e){this.handleStoryNavigationByTouch_(e),!this.globalInstanceData.storylyEmbed.init&&this.isMobileView_&&this.closeStorylyBySwiping_(),this.storyPlayAfterTouched_()}},{key:"closeStorylyBySwiping_",value:function(){var e=this;this.swiperMove_||(this.swipingDown_.scrollY>15*this.groupContainer_.offsetHeight/100?(this.groupContainer_.style.setProperty("transform","translateY(50vh) scale(0)"),this.groupsOverlay_.style.setProperty("background","transparent"),window.requestAnimationFrame(function(){e.handleCloseGroup_(),setTimeout(function(){e.groupContainer_.style.removeProperty("transform"),e.groupsOverlay_.style.removeProperty("background")},300)})):this.groupContainer_.style.setProperty("transform","translateY(0)"),this.swipingDown_={scrollY:0,pageY:0})}},{key:"handleStoryNavigationByTouch_",value:function(e){var t,r;if(this.globalInstanceData.storylyEmbed.init||this.handleNavigation_&&this.isMobileView_){var s=null!==(t=null===(r=e.changedTouches)||void 0===r||null===(r=r[0])||void 0===r?void 0:r.pageX)&&void 0!==t?t:e.offsetX,n=this.groupsOverlay_.offsetWidth,o=n-20*n/100;s>0&&s<20*n/100?this.documentDir_===w.default.RTL?this.handleNextStory_():this.handlePrevStory_():s>o&&s<n&&(this.documentDir_===w.default.RTL?this.handlePrevStory_():this.handleNextStory_()),this.handleNavigation_=!0}}},{key:"handleContainerTouchMove_",value:function(e){this.handleNavigation_=!1;var t=e.changedTouches[0].pageY;this.swiperMove_||(this.swipingDown_.scrollY+=this.swipingDown_.pageY>0?t-this.swipingDown_.pageY:0,this.swipingDown_.pageY=t,this.swipingDown_.scrollY>=0&&(this.groupContainer_.style.transform="translateY(".concat(this.swipingDown_.scrollY,"px)")))}},{key:"storyPauseByTouch_",value:function(){var e=this;this.isMobileView_&&(this.touchTimeout_=setTimeout(function(){e.getActiveStory_().instance.pauseByTouch(),e.storyTouchAction_=!0,e.handleNavigation_=!1},300))}},{key:"storyPlayAfterTouched_",value:function(){if(this.isMobileView_){if(this.storyTouchAction_)this.getActiveStory_().instance.playAfterTouch();clearTimeout(this.touchTimeout_)}}},{key:"handleCloseGroup_",value:function(){var e=(0,t.default)(d.default.mark(function e(){var t,r,s,n,o,i,a,u,l=this;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.storylyOpen_){e.next=2;break}return e.abrupt("return");case 2:if(!this.globalInstanceData.storylyEmbed.init){e.next=6;break}return r=this.getActiveGroup_(),this.handleEvent_(b.UserEventTypes.closeStoryGroup,P(P({},null!=r?r:{}),{},{instance:void 0})),e.abrupt("return");case 6:return this.groupsOverlay_.ariaHidden="true",this.swiper_.slides[this.swiper_.realIndex].ariaHidden="true",this.storyShadowDom_.setAttribute("tabindex","-1"),(0,_.removeClass)(this.groupsOverlay_,"active"),this.storylyOpen_=!1,this.removeStoryNavigationEvents_(),this.addEventListener("keydown",this.handleTabKeyPressListener_),null===(t=this.lastActiveElement_)||void 0===t||t.focus(),this.EventImpl.handleCloseEvent(),this.resetStyleToDocument_(),this.shareParams_.playMode&&(this.swiper_.allowTouchMove=!0),this.shareParams_={},(s=new URLSearchParams(window.location.search)).delete("storylyResume"),s.delete("storyly"),window.history.replaceState({},"","".concat(window.location.pathname).concat(s.size?"?".concat(s):"")),n=this.getActiveGroup_(),this.handleEvent_(b.UserEventTypes.closeStoryGroup,P(P({},null!=n?n:{}),{},{instance:void 0})),n.instance.hide({holdActive:!0}),this.removeAdGroups_(),this.isAdEnable_()&&document.querySelectorAll(".storyly-ad-wrapper").forEach(function(e){return e.remove()}),this.customStoryGroupHTML_&&(o=n.instance.getActiveStory(),i=o.storyIndex,a=this.getStoryGroupElement_(n),u=this.getCustomGroupAssignedElement_(a),(0,g.handleCustomStoryGroupStyles)(n,u,i,this.instanceId_)),e.next=31,this.clearNudgeGroups_();case 31:this.presentationData_&&!(0,y.isLiveVideo)(n.type)||this.handleSeenGroupsPosition_().then(function(){l.layoutImpl_.refreshSortData(),l.layoutImpl_.sort("order"),l.groups_.forEach(function(e,t){e.instance.setKey(t)})}).catch(function(){});case 32:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"removeAdGroups_",value:function(){if(this.isAdEnable_()&&0!==this.adGroups_.length){var e=[],t=[];this.groups_.forEach(function(r,s){r.ad?t.push(s):e.push(r)}),this.groups_=e,this.swiper_.removeSlide(t)}}},{key:"handleSeenGroupsPosition_",value:function(){var e=this;return 0===this.seenGroups_.length?Promise.reject():(this.seenGroups_.forEach(function(t){var r=e.getStoryGroupElement_(t);if(!t.pinned){var s=e.groupCircleNodes_.length-1;e.groupCircleNodes_.forEach(function(e,t){e.dataset.ad||e.classList.contains("seen")&&r.dataset.order<+e.dataset.order||(s=t)});var n=e.hiddenStoryGroupNodes_.filter(function(e){return e.classList.contains("hidden")&&+r.dataset.sortorder>=+e.dataset.sortorder}),o=+r.dataset.sortorder-n.length;e.groupCircleNodes_.splice(o,1),e.groupCircleNodes_.splice(s,0,r),e.groupCircleNodes_.forEach(function(t,r){e.customStoryGroupHTML_&&(e.getCustomGroupAssignedElement_(t).dataset.sortorder=r);t.dataset.ad||(e.groupsList_.querySelector('.storyly__story-group-container[data-id="'.concat(t.dataset.id,'"]')).dataset.sortorder=r);var s=e.hiddenStoryGroupNodes_.find(function(e){return e.dataset.id===t.dataset.id});s&&(s.dataset.sortOrder=t.dataset.sortorder,s.dataset.order=t.dataset.order)});var i=e.swiper_.slides[o];e.swiper_.removeSlide(o),e.swiper_.addSlide(s,i);var a=e.groups_[o];e.groups_.splice(o,1),e.groups_.splice(s,0,a)}e.customStoryGroupHTML_&&e.getCustomGroupAssignedElement_(r).classList.toggle("storyly__story-group-seen");r.classList.toggle("seen")}),this.seenGroups_=[],Promise.resolve())}},{key:"getActiveGroup_",value:function(){return this.groups_[this.currentGroupIndex_]}},{key:"getNextGroup_",value:function(){return this.groups_[this.currentGroupIndex_+1]}},{key:"getPrevGroup_",value:function(){return this.groups_[this.currentGroupIndex_-1]}},{key:"getActiveStory_",value:function(){return this.getActiveGroup_().instance.getActiveStory()}},{key:"getPrevStory_",value:function(){return this.getActiveGroup_().instance.getPrevStory()}},{key:"getCustomGroupAssignedElement_",value:function(e){return"SLOT"===e.tagName?e.assignedElements()[0]:e}},{key:"getStoryGroupElement_",value:function(e){return this.groupCircleNodes_.find(function(t){return+t.dataset.id===e.group_id})}},{key:"getActiveGroupWithoutInstance",value:function(){var e=P({},this.getActiveGroup_());return delete e.instance,delete e.currentOrder,delete e.onView,e}},{key:"handleNextGroup_",value:function(){if(this.handleCompleteGroupEvent_(),this.shareParams_.playMode!==v.default.STORY_GROUP||this.getActiveGroup_().group_id!==this.shareParams_.group.group_id)if(this.currentGroupIndex_===this.groups_.length-1)this.handleCloseGroup_();else{this.getActiveGroup_().instance.sendGroupClickedEvent("next");var e=this.getNextGroup_();this.groups_[this.currentGroupIndex_].instance.unLoad({holdActive:!0}),this.currentGroupIndex_+=1,this.loadNextGroupInstance_(),this.swiper_.slideTo(this.currentGroupIndex_),e.instance.show(),this.EventImpl.handleSwipingGroupEvent("next")}else this.handleCloseGroup_()}},{key:"handleCompleteGroupEvent_",value:function(){var e,t=this.getActiveGroup_();!t.ad&&t.instance.isAllStoriesSeen()&&(this.handleEvent_(b.UserEvent,{event:b.UserEventTypes.groupCompleted,storyGroup:P(P({},null!==(e=this.groups_[this.currentGroupIndex_])&&void 0!==e?e:{}),{},{instance:void 0})}),this.EventImpl.handleCompleteGroupEvent())}},{key:"loadNextGroupInstance_",value:function(){var e=this.getNextGroup_(),t=this.getPrevGroup_();!e||null!=e&&e.onView||e.ad||e.nudge||this.loadGroupInstance_(e),!t||null!=t&&t.onView||t.ad||t.nudge||this.loadGroupInstance_(t)}},{key:"handlePrevGroup_",value:function(){if(this.shareParams_.playMode!==v.default.STORY_GROUP||this.getActiveGroup_().group_id!==this.shareParams_.group.group_id){if(0!==this.currentGroupIndex_){this.getActiveGroup_().instance.sendGroupClickedEvent("prev");var e=this.getPrevGroup_();this.groups_[this.currentGroupIndex_].instance.unLoad({holdActive:!0}),this.currentGroupIndex_-=1,this.loadNextGroupInstance_(),this.swiper_.slideTo(this.currentGroupIndex_),e.instance.show(),this.EventImpl.handleSwipingGroupEvent("prev"),this.handleImpressionEvent_()}}else this.handleCloseGroup_()}},{key:"handleNextStory_",value:function(e){var t;e&&"detail"in e&&(t=e.detail.storyIndex);this.getActiveStory_().instance.sendStoryClickedEvent("next"),this.EventImpl.handleSwipingStoryEvent("next"),this.getActiveGroup_().instance.nextStory(t),this.handleImpressionEvent_()}},{key:"handlePrevStory_",value:function(e){var t=this.getActiveStory_();if(0!==this.currentGroupIndex_||0!==t.storyIndex){var r;if(e&&"detail"in e)r=e.detail.storyIndex;t.instance.sendStoryClickedEvent("prev"),this.EventImpl.handleSwipingStoryEvent("prev"),this.getActiveGroup_().instance.prevStory(r)}}},{key:"fetchGroups_",value:function(){var e=this,t=p.default.setInstanceId(this.instanceId_).getItemFromInstance("Storyly_responseData");if(this.checkCacheData_())this.loadCacheData_(t);else{this.isCache_=!1;var r,s,n,o=[],i=!1,a=setTimeout(function(){var a,u;i=!0,o=null!==(a=t.story_groups)&&void 0!==a?a:[],s=t.style,r=null!==(u=t.ad)&&void 0!==u?u:{},n=t.nudge_settings,r&&(e.adSettings_=r),o?(e.handleGroupsData_(o),e.handleInstanceLevelStyling_(s)):(e.retryCount_+=1,e.retryCount_<3?e.fetchGroups_():e.removeStoryly_())},2e3);this.api_.getGroups(this.payload_).then(function(t){var u;t.error?e.failed_(f.failedMessages.network):(clearTimeout(a),p.default.setInstanceId(e.instanceId_).setItemToInstance("Storyly_responseData",P(P({},t),{},{ttl:Date.now()})),0!==t.story_groups.length||e.shopify_?(o=t.story_groups,s=t.style,r=null!==(u=t.ad)&&void 0!==u?u:{},n=t.nudge_settings,i||(e.adSettings_=r,e.nudgeSettings_=n,e.handleGroupsData_(o),e.handleInstanceLevelStyling_(s))):e.removeStoryly_())}).catch(function(){e.failed_(f.failedMessages.network)})}}},{key:"checkCacheData_",value:function(){if("dashboard.storyly.io"===window.location.hostname||"docs.developers.storyly.io"===window.location.hostname||"dev.storyly"===window.location.hostname||this.userConfigChanged_||this.userConfig_.isTestMode)return!1;var e=p.default.setInstanceId(this.instanceId_).getItemFromInstance("Storyly_responseData"),t=e.story_groups,r=e.ttl,s=new Date(Date.now()-r);return!!(t&&s.getMinutes()<3)}},{key:"loadCacheData_",value:function(e){var t=e.story_groups,r=e.ads,s=e.style;this.adSettings_=null!=r?r:{},this.handleGroupsData_(t||[]),this.handleInstanceLevelStyling_(s),this.isCache_=!0}},{key:"handleGroupsData_",value:function(){var s=(0,t.default)(d.default.mark(function t(){var s,n,o,i,a,u,l,h,c,p,_,y,v,g,S,w=this,C=arguments;return d.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return s=C.length>0&&void 0!==C[0]?C[0]:[],this.loadInlineStyle_(),n=s.map(function(e,t){return P(P({},e),{},{order:t})}),t.next=5,this.handleConditionalGroups_(s);case 5:if(n=t.sent,o=new URLSearchParams(window.location.search),!this.nudgeSettings_){t.next=12;break}return t.next=10,require("_bundle_loader")(require.resolve("./service/nudge-story-groups-impl"));case 10:i=t.sent.default,this.nudgeImpl_=i(this.nudgeSettings_);case 12:if((this.globalInstanceData.storylyEmbed.init||o.get("storylyMail")||this.globalInstanceData.inboxStory)&&(a=(0,r.default)(this.openStoryParams_,1),u=a[0],n=n.filter(function(e){return e.group_id===+u})),l=n.filter(function(e){return e.type===f.groupTypes.SDK_AUTOMATED_SHOPPABLE}),n=n.filter(function(e){return e.type!==f.groupTypes.SDK_AUTOMATED_SHOPPABLE}),!(this.productFeed_&&l.length>0)){t.next=27;break}return h=Object.values(this.productFeed_).flatMap(function(e){return e}),this.allProductsOfProductFeed_=h.map(function(e){var t;return P(P({},e),{},{variant:null!==(t=e.variant)&&void 0!==t?t:[]})}),this.storylyHydration=[].concat((0,e.default)(this.storylyHydration),(0,e.default)(this.allProductsOfProductFeed_)),t.next=21,require("_bundle_loader")(require.resolve("./service/create-product-feed-impl"));case 21:return c=t.sent.default,t.next=24,c(this.productFeed_,l);case 24:p=t.sent,_=[].concat((0,e.default)(n),(0,e.default)(null!=p?p:[])).sort(function(e,t){return e.order-t.order}),n=_;case 27:if(y=(0,e.default)(n),v=[],n.forEach(function(t,r){var s=(0,m.createUserPropertyImpl)(w.userPropertyData_,t);if(s.has_user_property&&(w.storyGroupsWithUserProperties_=[].concat((0,e.default)(w.storyGroupsWithUserProperties_||[]),[P(P({},y[r]),{},{is_user_property_used:s.is_user_property_used})])),y[r]=s,t.type!==f.groupTypes.SDK_AUTOMATED_SHOPPABLE){var n=w.handleProductGroups_(y[r]),o=n.productGroup,i=n.productIds;v.push.apply(v,(0,e.default)(i)),y[r]=o}}),!v.length){t.next=42;break}if(g={products:v,language:this.userConfig_.language,country:this.userConfig_.country},this.handleEvent_(b.CustomerEventTypes.storylyHydration,v),!this.isProductFallbackEnabled_){t.next=42;break}if(!o.get("storylyMail")&&!this.globalInstanceData.inboxStory){t.next=41;break}return t.next=37,this.api_.getProductDetails(g);case 37:S=t.sent,this.storylyHydration=S.products,t.next=42;break;case 41:this.api_.getProductDetails(g).then(function(e){w.setStorylyHydration(e.products)});case 42:this.loadGroupCircles_(y);case 43:case"end":return t.stop()}},t,this)}));return function(){return s.apply(this,arguments)}}()},{key:"handleConditionalGroups_",value:function(e){var t=p.default.setInstanceId(this.instanceId_).getItemFromInstance("Storyly_componentsData"),r=e.map(function(e){var r=!1,s=e.stories.filter(function(e){var s=e;if(!e.conditions)return s.visible=!0,!0;r=!0;var n=e.conditions.every(function(e){return e.some(function(e){var r=t[e.i];return void 0!==r&&r===+e.r.p})});return s.visible=n,n});return P(P({},e),{},{conditional:r,hidden:0===s.length})});return Promise.resolve(r)}},{key:"handleConditionalEvent_",value:function(){var r=(0,t.default)(d.default.mark(function r(){var s,n,o,i,a=this;return d.default.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return s=this.groups_.filter(function(e){return e.conditional}),r.next=3,s.forEach(function(){var e=(0,t.default)(d.default.mark(function e(t){var r,s;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=t,e.next=3,t.instance.handleConditionalStories(!0);case 3:s=e.sent,r.stories=s;case 5:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}());case 3:return n=this.hiddenConditionalGroups_.filter(function(e){return e.conditional}),r.next=6,this.handleConditionalGroups_(n);case 6:n=r.sent.filter(function(e){return!e.hidden}),o=(0,e.default)(this.groups_),n.length>0&&(i=[],n.forEach(function(){var e=(0,t.default)(d.default.mark(function e(t){return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a.createGroupInstanceAndReorderCircleNodes_(t),i.push(t.group_id);case 2:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()),this.hiddenConditionalGroups_=this.hiddenConditionalGroups_.filter(function(e){return!i.includes(e.group_id)}),this.groups_=o.filter(function(e){return Boolean(e)&&0!==e.stories.length}),this.layout_===S.default.MODERN&&this.layoutInstance_.handleStoryGroupNavigationButtons(this.groups_,this.currentGroupIndex_));case 9:case"end":return r.stop()}},r,this)}));return function(){return r.apply(this,arguments)}}()},{key:"handleInstanceLevelStyling_",value:function(e){var t=this;e&&(Object.keys(C.default).forEach(function(r){Object.keys(e).includes(r)&&(Array.isArray(e[r])?t.properties_[C.default[r]]=e[r].map(function(e){return(0,y.isHexColor)(e)?(0,y.convertHex)(e):e}):(0,y.isHexColor)(e[r])?t.properties_[C.default[r]]=(0,y.convertHex)(e[r]):t.properties_[C.default[r]]=e[r]),"animation"===r&&e.animation&&(t.properties_.storyGroupAnimation={type:"pulse",mode:!1},m.StoryGroupAnimationImpl.add(t.groupCircleNodes_,t.properties_.storyGroupAnimation))}),this.setProperties(this.properties_))}},{key:"handleProductGroups_",value:function(e){var t=(0,y.getProductLayers)(e),r=t.flatMap(function(e){return e.products}),s=new URLSearchParams(window.location.search);return{productGroup:P(P({},e),{},{hidden:e.hidden||!(s.get("storylyMail")||this.globalInstanceData.inboxStory)&&!!t.length}),productIds:r}}},{key:"createGroupInstanceAndReorderCircleNodes_",value:function(){var r=(0,t.default)(d.default.mark(function t(r){var s,n,o,i,a,u,l,h,c,p,v,g,f,b,w=this;return d.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return s=!Object.keys(this.shareParams_).length||this.hiddenStoryGroups_.includes(function(e){var t;return e.group_id===(null===(t=w.shareParams_.group)||void 0===t?void 0:t.group_id)}),t.next=3,new Promise(function(e){return setTimeout(e,s?0:1e3)});case 3:if(n=[].concat((0,e.default)(this.groupCircleNodes_),(0,e.default)(this.hiddenStoryGroupNodes_)).find(function(e){return+e.dataset.id===r.group_id}),o=+n.dataset.sortorder,i=o,!this.storylyOpen_||!this.nudgeImpl_){t.next=11;break}return t.next=9,this.nudgeImpl_.getAddedNudgeCount(+o);case 9:a=t.sent,o+="number"==typeof a?a:0;case 11:return(u=this.swiper_.slides.findIndex(function(e){return+e.dataset.id===r.group_id}))>-1&&this.swiper_.removeSlide(u),l=this.setGroupInstance_(r,o),t.next=16,l.instance.render();case 16:h=t.sent,this.swiper_.addSlide(o,h),r.is_user_property_used&&(c=r.title,p=r.icon_image_url,v=n,"SLOT"===n.tagName&&(v=this.querySelector("[slot='story-group-".concat(r.group_id,"']"))),g=v.querySelector(".storyly__story-group-title"),(f=v.querySelector(".storyly__story-group-cover"))&&(f.src=p),g&&(c.length>25?((0,y.setAttribute)(n,"title",c),g.innerHTML="".concat(c.substring(0,25),"...")):((0,y.setAttribute)(n,"title",""),g.innerHTML=c))),(0,_.removeClass)(n,"seen"),(0,_.removeClass)(n,"hidden"),(b=this.groups_.findIndex(function(e){return e.group_id===r.group_id}))>-1?(this.groups_[b]=P(P({},l),{},{hidden:!1}),this.groupCircleNodes_[b]=n):(this.groups_.splice(o,0,P(P({},l),{},{hidden:!1})),this.groupCircleNodes_.splice(o,0,n)),this.groupsList_.insertBefore(n,this.groupsList_.children[o]),this.layout_===S.default.MODERN&&this.nudgeImpl_&&this.storylyOpen_&&this.layoutInstance_.handleStoryGroupNavigationButtons(this.groups_,i),this.layoutImpl_&&(this.layoutImpl_.add(n),this.layoutImpl_.refreshSortData(),this.layoutImpl_.sort("order")),this.setContainerHeight_(),s&&this.loadShareParams_().then(function(){return w.handleOpenStoryByUrl_()}).catch(function(){}),m.StoryGroupAnimationImpl.add(this.groupCircleNodes_,this.properties_.storyGroupAnimation),this.handleI18n_({detail:{wrapperDom:this.groupsList_}});case 30:case"end":return t.stop()}},t,this)}));return function(e){return r.apply(this,arguments)}}()},{key:"removeGroupInstanceAndReorderCircleNodes_",value:function(e,t){var r=this.swiper_.slides.findIndex(function(e){return+e.dataset.id===t.group_id});this.swiper_.removeSlide(r);var s=this.groups_.findIndex(function(e){return e.group_id===t.group_id});this.groups_.splice(s,1),this.groupCircleNodes_.splice(s,1),this.groupsList_.removeChild(e),this.layoutImpl_&&(this.layoutImpl_.remove(e),this.layoutImpl_.refreshSortData(),this.layoutImpl_.sort("order"))}},{key:"adBlockerDetector_",value:function(){var e=document.createElement("div");e.classList.add("adsbygoogle"),this.groupsOverlay_.appendChild(e),"none"===getComputedStyle(e).getPropertyValue("display")&&(this.hasAdblocker_=!0),e.remove()}},{key:"isAdEnable_",value:function(){return Object.keys(this.adSettings_).length>0&&!this.hasAdblocker_}},{key:"loadAdGroups_",value:function(){var e=(0,t.default)(d.default.mark(function e(t){var r,s,n,o,i,a,u,l,h,c,p,_,v=this;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isAdEnable_()){e.next=2;break}return e.abrupt("return");case 2:for(this.loadAdStyle_(),r=this.adSettings_,s=r.ad_cap,n=r.ad_manager_body,(o=document.createElement("div")).style.position="absolute",o.style.top="-100vh",i=[],a=[],u=[],l=0;l<=s;l+=1)h={ad:!0,title:"Sponsored",settings:this.adSettings_,id:(0,y.randomAlphaNum)(10)},c=new E.default(h,h.id,this.groupsOverlay_,this.layout_,this.instanceId_),h.instance=c,p=c.render(),_=c.load(),i.push(p),a.push(_),u.push(h);Promise.all(i).then(function(e){e.forEach(function(e,r){o.appendChild(e),v.storyShadowRoot_.appendChild(o),u[r].node=e,a[r].then(function(e){"filled"===e&&(v.adGroups_.push(u[r]),n||v.renderAdGroup_(t,u[r]))})})});case 12:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"loadAdStyle_",value:function(){if(!this.storyShadowDom_.querySelector('style[data-type="ad-style"]')){var e=document.createElement("style");e.dataset.type="ad-style",e.textContent="\n .storyly-adsense {\n --i--storyly-story-desktop-one-panel-ratio: 69/116;\n --i--storyly-story-desktop-one-panel-responsive-margin: max(74px,8.25vh);\n --i--storyly-story-desktop-one-panel-height: calc(100vh - var(--i--storyly-story-desktop-one-panel-responsive-margin)*2);\n --i--storyly-story-desktop-one-panel-width: calc(var(--i--storyly-story-desktop-one-panel-height)*var(--i--storyly-story-desktop-one-panel-ratio));\n position: absolute;\n left: 50%;\n top: 12%;\n transform: translateX(-50%);\n width: calc(var(--i--storyly-story-desktop-one-panel-width) - 20%) !important;\n height: calc(var(--i--storyly-story-desktop-one-panel-height) - 20%) !important;\n text-align: center;\n }\n .storyly-ad-manager {\n position: absolute;\n left: 50%;\n top: 12%;\n transform: translateX(-50%);\n text-align: center;\n min-width: 300px;\n min-height: 200px;\n }\n ".replace(/\s+/g," "),this.storyShadowDom_.appendChild(e)}}},{key:"removeStoryly_",value:function(){this.remove(),this.handleEvent_("noStoryGroup")}},{key:"on",value:function(e,t){this.events_=P(P({},this.events_),{},(0,s.default)({},e,t)),this.globalInstanceData.events=this.events_}},{key:"handleEvent_",value:function(e,t){if(this.events_[e]&&"function"==typeof this.events_[e])try{this.events_[e](t)}catch(r){console.error(r)}else if(this.events_[e])throw TypeError("".concat(e," event must be a function!"))}},{key:"loaded",value:function(){var t=this,r=[].concat((0,e.default)(this.groups_),(0,e.default)(this.hiddenStoryGroups_)).filter(function(e){return!e.ad}).map(function(e){var t;return{title:e.title,iconUrl:null!==(t=e.icon_image_url)&&void 0!==t?t:e.icon_video_url,id:e.group_id,pinned:e.pinned,stories:e.stories,type:e.type,nudge:e.nudge}});this.handleEvent_(b.UserEventTypes.loaded,{groupList:r,dataSource:this.isCache_?f.dataSource.cache:f.dataSource.network}),this.EventImpl.onScreenEvent(this.isCache_),this.handleOpenStoryByUrl_(),this.adSettings_.ad_manager_body&&(this.adInterval_=setInterval(function(){window.googletag&&(t.loadAdGroups_(),clearInterval(t.adInterval_))},100)),this.setStorylyBarObserver_(),this.handleI18n_()}},{key:"failed_",value:function(){this.handleEvent_(b.UserEventTypes.loadFailed)}},{key:"handleI18n_",value:function(e){var t,r=this,s=(null!=e?e:{}).detail;(null!==(t=null==s?void 0:s.wrapperDom)&&void 0!==t?t:this.storyShadowRoot_).querySelectorAll("[data-i18n-key]").forEach(function(e){var t=e,s=e.getAttribute("data-i18n-key"),n=r.globalInstanceData.languageJSON[s];n&&m.LocalizationImpl.localizeTexts(t,n)})}},{key:"setContainerHeight_",value:function(){var e=[];this.groupsWrapper_.querySelectorAll(".storyly__story-group-container").forEach(function(t){return e.push(t.offsetHeight)});var t=Math.max.apply(Math,e);(0,_.setStyle)(this.groupsWrapper_,["height","".concat(t+2,"px")])}},{key:"handleOpenStoryByUrl_",value:function(){var e=this.shareParams_,t=e.group,r=e.storyIndex;void 0===t||"number"!=typeof r&&r>0||this.showStory_()}},{key:"setSeenForGroup_",value:function(){var e=this.getSeenGroups_(),t=this.getActiveGroup_(),r=this.getActiveStory_();if(!(t.ad||t.nudge||(0,y.isLiveVideo)(t.type))){e[t.group_id]?e[t.group_id].stories.includes(r.story_id)||e[t.group_id].stories.push(r.story_id):e[t.group_id]={seen:!0,stories:[r.story_id]},p.default.setInstanceId(this.instanceId_).setItemToInstance("Storyly_groupSeenState",e);var s=this.groups_.find(function(e){return e.group_id===t.group_id}),n=this.groupCircleNodes_.some(function(e){return+e.dataset.id===s.group_id&&e.classList.contains("seen")}),o=this.seenGroups_.some(function(e){return e.group_id===s.group_id});!this.checkSeenStories_(s)||n||o||this.seenGroups_.push(s)}}},{key:"handleImpressionEvent_",value:function(){var e={products:this.storylyHydration,language:this.userConfig_.language,country:this.userConfig_.country};this.EventImpl.handleImpressionEvent(e),this.setSeenForGroup_()}},{key:"loadGroupCircles_",value:function(){var r=(0,t.default)(d.default.mark(function t(r){var s,n,o,i,a,u,l,h,c=this;return d.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.nudgeGroups_=r.filter(function(e){return e.nudge}),0!==(s=r.filter(function(e){return!e.nudge})).length){t.next=4;break}return t.abrupt("return");case 4:return n={seenList:[],unseenList:[]},o={seenList:[],unseenList:[]},this.storyGroupObserver_=(0,m.intersectionObserverImpl)(this.groupsWrapper_,this.groupObserverCallback_),i=[],a=[],u=(0,m.storyGroupCircleTemplateImpl)(this.customStoryGroupHTML_),l=this.groupsWrapper_.classList.contains("style-scope"),s.forEach(function(e,t){var r=e.title,d=e.type,h=e.pinned;h=h||(0,y.isLiveVideo)(d);var p=(0,y.generateHtmlFromTemplate)(u(e,c.instanceId_,c.groupsWrapper_)),v=p.querySelector(".storyly__story-group-title");if(v){var f=r;r.length>25&&(f="".concat(r.substring(0,25),"...")),v.innerText=f}var m,S=c.checkSeenStories_(e);c.customStoryGroupHTML_&&(m=(0,g.handleCustomStoryGroupElement)(e,t,c.customStoryGroupHTML_,S),l?p=m:c.appendChild(m)),p.dataset.id=e.group_id,e.hidden&&(0,_.setClass)(p,"hidden"),h?((0,_.setClass)(p,"pinned"),i.push(e),a.push(p),S&&(0,_.setClass)(p,"seen")):S?((0,_.setClass)(p,"seen"),n.seenList.push(p),o.seenList.push(e)):(n.unseenList.push(p),o.unseenList.push(e)),p.dataset.order=t;var b=S?c.globalInstanceData.languageJSON.seen:c.globalInstanceData.languageJSON.unseen,w=h?c.globalInstanceData.languageJSON.pinned:" ";p.ariaLabel="of {@_".concat(s.length,"_2}, {@_").concat(r,"_3}, {@_").concat(w,"_4}, {@_").concat(b,"_5}"),m&&(m.ariaLabel="Story position ".concat(t+1," of ").concat(s.length,", ").concat(r,", ").concat(h?"pinned, ":"").concat(b)),(e.stories.some(function(e){return e.alt_text})||c.globalInstanceData.accessibility)&&(c.globalInstanceData.storiesHasAltText=!0),p.addEventListener("click",c.handleClickGroup_,!1),c.customStoryGroupHTML_&&c.handleBarStyleEvents_(p)}),h=[].concat(i,(0,e.default)(o.unseenList),(0,e.default)(o.seenList)),this.hiddenStoryGroups_=h.filter(function(e){return e.hidden&&!e.conditional}),this.hiddenConditionalGroups_=h.filter(function(e){return e.hidden&&e.conditional}),t.next=17,h.filter(function(e){return!e.hidden&&!e.nudge}).map(function(e,t){var r=e;return(r=c.setGroupInstance_(e,t)).instance.render().then(function(e){c.swiper_.appendSlide(e)}),r});case 17:this.groups_=t.sent,[].concat(a,(0,e.default)(n.unseenList),(0,e.default)(n.seenList)).forEach(function(e,t){var r=e;if(e.classList.contains("hidden")?c.hiddenStoryGroupNodes_.push(e):(c.groupCircleNodes_.push(e),c.groupsList_.appendChild(e)),r.ariaLabel="Story position {@_".concat(t+1,"_1} ").concat(r.ariaLabel),c.customStoryGroupHTML_){var s=c.getCustomGroupAssignedElement_(e);s&&(s.dataset.sortorder=t)}r.dataset.sortorder=t}),(0,_.setClass)(this.groupsWrapper_,this.properties_.storyGroupAlign),this.handleI18n_({detail:{wrapperDom:this.groupsList_}}),this.loadShareParams_().catch(function(){}),this.loaded(),m.StoryGroupAnimationImpl.add(this.groupCircleNodes_,this.properties_.storyGroupAnimation);case 24:case"end":return t.stop()}},t,this)}));return function(e){return r.apply(this,arguments)}}()},{key:"handleBarStyleEvents_",value:function(e){var t=this;e.addEventListener("mouseenter",function(){var r=t.getCustomGroupAssignedElement_(e),s=r.querySelector(".storyly__story-preview-video");if((0,_.setClass)(r,"storyly__story-group-hovered"),s){var n=r.querySelector(".storyly__story-preview-video source");if(""===n.getAttribute("src")){var o=s.dataset.src;n.src=o,s.load()}s.play()}},!1),e.addEventListener("mouseleave",function(){var r,s=t.getCustomGroupAssignedElement_(e);(0,_.removeClass)(s,"storyly__story-group-hovered"),null===(r=s.querySelector(".storyly__story-preview-video"))||void 0===r||r.pause()},!1)}},{key:"groupObserverCallback_",value:function(e){var t=this;e.forEach(function(e){if(e.isIntersecting){var r,s=e.target,n=s.dataset.id;if(t.groups_.forEach(function(e){e.group_id===+n&&(r=e)}),!r.onView){var o;if(t.loadGroupInstance_(r),s.setAttribute("onView",""),"SLOT"!==s.nodeName)(0,k.default)({mediaDom:null!==(o=s.querySelector("img"))&&void 0!==o?o:s.querySelector("video"),group:r,containerStyle:{width:"".concat(Number(t.properties_.storyGroupSize.split("x")[0])),height:"".concat(Number(t.properties_.storyGroupSize.split("x")[1])),position:"absolute",border:"3px solid #fff"}});clearTimeout(t.eventTimeout_),t.barViewed_&&(t.eventTimeout_=setTimeout(function(){return t.sendBarViewEvent_()},1e3))}r.onView=!0}})}},{key:"loadShareParams_",value:function(){var e,t,s,n=new URLSearchParams(window.location.search),o=n.get("storyly");if(!o&&!this.openStoryParams_)return Promise.reject();if(2===(o=this.openStoryParams_||JSON.parse(o)).length){var i=o,a=(0,r.default)(i,2);e=a[0],"number"==typeof(s=a[1])&&(t=s,s=null)}else{var u=o,l=(0,r.default)(u,3);e=l[0],t=l[1],s=l[2]}var d=this.groups_.find(function(t){return t.group_id===+e}),h=null==d?void 0:d.stories.findIndex(function(e){return e.story_id===+t});if(!d){var c={detail:{eventName:b.CustomerEventTypes.storyOpenFailed,params:{errorMessage:"story group does not exist."}}};return this.handleCustomerEvent_(c),Promise.reject(new Error("story group does not exist."))}if(-1===h&&t){var p={detail:{eventName:b.CustomerEventTypes.storyOpenFailed,params:{errorMessage:"story does not exist."}}};return this.handleCustomerEvent_(p),Promise.reject(new Error("story does not exist."))}t||(h=0);var _=!!+n.get("storylyResume");return this.shareParams_={group:d,storyIndex:h,playMode:s,resumeStory:_},s&&(this.swiper_.allowTouchMove=!1),this.globalInstanceData.shareParams=this.shareParams_,Promise.resolve()}},{key:"setSwiperEvents_",value:function(){var e=this;this.swiper_.on("sliderFirstMove",function(){e.swiperMove_=!0}),this.swiper_.on("realIndexChange",function(t){if(e.storylyOpen_){if(!e.shareParams_.group)e.getActiveStory_().instance.pause();e.layout_===S.default.MODERN&&e.layoutInstance_.handleStoryGroupNavigationButtons(e.groups_,t.activeIndex)}}),this.swiper_.on("transitionEnd",function(t){if(e.swiperMove_=!1,e.storylyOpen_)if(e.shareParams_.group)e.currentGroupIndex_=t.activeIndex;else{if(t.activeIndex!==e.currentGroupIndex_){if(e.layout_===S.default.CLASSIC){var r=e.getActiveGroup_(),s=t.realIndex<t.previousIndex?"prev":"next";r.instance.sendGroupClickedEvent(s),e.getActiveStory_().instance.sendStoryClickedEvent(s)}e.handleCompleteGroupEvent_(),e.groups_[e.currentGroupIndex_].instance.unLoad({holdActive:!0}),e.currentGroupIndex_=t.activeIndex,e.loadNextGroupInstance_(),e.EventImpl.handleSwipingGroupEvent(t.swipeDirection),e.groups_[e.currentGroupIndex_].instance.show(),e.handleImpressionEvent_()}else e.windowResize_||(e.storyTouchAction_=!1);e.windowResize_=!1,t.slides.forEach(function(e){e.classList.contains("swiper-slide-active")?(0,y.setAttribute)(e,"aria-hidden","false"):(0,y.setAttribute)(e,"aria-hidden","true")})}})}},{key:"setGroupInstance_",value:function(e,t){var r=this.layoutInstance_.setGroupInstance(e,t);return P(P({},e),{},{currentOrder:t,instance:r})}},{key:"loadGroupInstance_",value:function(e){e.instance&&e.instance.load()}},{key:"checkSeenStories_",value:function(e){var t=this.getSeenGroups_(),r=e.stories.filter(function(e){return e.visible});return 0!==r.length&&r.every(function(r){var s;return!(null===(s=t[e.group_id])||void 0===s||null===(s=s.stories)||void 0===s||!s.includes(r.story_id))})}},{key:"renderAdGroup_",value:function(e,t){if(this.isAdEnable_()&&0!==this.adGroups_.length){var r=this.adSettings_,s=r.ad_frequency,n=r.ad_first,o=r.ad_cap,i=0,a=e+n,u=0;this.groups_.forEach(function(e,t){e.ad&&(u=t,a=t+(s+1),i+=1)}),i>=o||u===this.groups_.length-1||(this.groups_.splice(a,0,t),this.swiper_.addSlide(a,t.node))}}},{key:"handleClickGroup_",value:function(e){var t,r,s=this,n=e.target.dataset.id;this.groups_.forEach(function(e,s){e.group_id===+n&&(r=s,t=e)}),this.adSettings_.ad_manager_body?this.adGroups_.forEach(function(e){s.renderAdGroup_(r,e)}):this.loadAdGroups_(r),this.showGroup_(t,r)}},{key:"setFocusableElements_",value:function(){var e=[];if(this.layout_===S.default.CLASSIC){var t=this.groupsOverlay_.querySelector("button.storyly__mobile-view-close-story");e=[this.groupsOverlay_.querySelector(".navigate-button.prev-button button"),t]}if(this.layout_===S.default.MODERN){var r=this.groupsOverlay_.querySelector("button.close-story"),s=this.groupsOverlay_.querySelector(".story-group-navigation-button.prev-story-group .story-group-navigation-button-container");"none"===s.parentElement.style.display&&(s=this.groupsOverlay_.querySelector(".prev-story-button")),e=[s,r]}this.focusableEls_=e}},{key:"handleNudgeGroups_",value:function(){var e=(0,t.default)(d.default.mark(function e(t){var r,s;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.shareParams_.playMode,!this.nudgeImpl_||r){e.next=6;break}return e.next=4,this.nudgeImpl_.renderNudgeGroups({layoutInstance:this.layoutInstance_,groups:{default:this.groups_,nudge:this.nudgeGroups_},swiperInstance:this.swiper_,groupIndex:t});case 4:s=e.sent,this.groups_=s;case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"clearNudgeGroups_",value:function(){var e=(0,t.default)(d.default.mark(function e(){var t;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.nudgeImpl_){e.next=5;break}return e.next=3,this.nudgeImpl_.clearNudgeGroups(this.groups_);case 3:t=e.sent,this.groups_=t;case 5:return e.abrupt("return",Promise.resolve());case 6:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"showGroup_",value:function(e,t){var r=this;this.isMobileView_&&(0,m.calcStorySizeImpl)(this.groupsOverlay_),this.handleNudgeGroups_(t),this.handleI18n_(),this.setOverlayVh_(),this.setStoryNavigationEvents_(),this.removeEventListener("keydown",this.handleTabKeyPressListener_),this.setStyleToDocument_(),m.StoryGroupAnimationImpl.remove(this.groupCircleNodes_,this.properties_.storyGroupAnimation),this.swiper_.slideTo(t),this.swiper_.update();var s=this.swiper_.slides[t];this.storylyOpen_=!0,setTimeout(function(){e.instance.show(),(0,_.setClass)(r.groupsOverlay_,"active"),s.ariaHidden="false",r.storyShadowDom_.removeAttribute("tabindex"),r.groupsOverlay_.ariaHidden="false",r.setFocusableElements_()},150),this.currentGroupIndex_=t,this.loadNextGroupInstance_(),this.setSwiperEvents_(),this.layout_===S.default.MODERN&&this.layoutInstance_.handleStoryGroupNavigationButtons(this.groups_,t),this.EventImpl.handleSelectedGroupEvent(),this.handleImpressionEvent_(),this.handleEvent_(b.UserEventTypes.openStoryGroup,P(P({},null!=e?e:{}),{},{instance:void 0}))}},{key:"setStyleToDocument_",value:function(){this.globalInstanceData.storylyEmbed.init||((0,_.setStyle)(document.documentElement,["overflow","hidden"]),(0,_.setStyle)(document.documentElement,["overscrollBehaviorX","none"]))}},{key:"resetStyleToDocument_",value:function(){(0,_.resetStyle)(document.documentElement,["overflow","overscrollBehaviorX","position"])}},{key:"showStory_",value:function(){var e=this,t=this.shareParams_,r=t.group,s=t.storyIndex,n=t.playMode,o=this.groups_.find(function(e){return e.group_id===r.group_id}),i=this.getStoryGroupElement_(r),a=this.groups_.findIndex(function(e){return e.group_id===r.group_id});i.setAttribute("onView","");var u=i.querySelector("img"),l=i.querySelector("video");(u||l)&&(0,k.default)({mediaDom:null!=u?u:l,group:o,containerStyle:{width:"".concat(Number(this.properties_.storyGroupSize.split("x")[0])),height:"".concat(Number(this.properties_.storyGroupSize.split("x")[1])),position:"absolute",border:"3px solid #fff"}}),o.onView=!0,o.instance.loadByParameters(s),"string"!=typeof n&&(this.adSettings_.ad_manager_body?this.adGroups_.forEach(function(t){e.renderAdGroup_(a,t)}):this.loadAdGroups_(a)),this.showGroup_(o,a)}},{key:"getSeenGroups_",value:function(){return p.default.setInstanceId(this.instanceId_).getItemFromInstance("Storyly_groupSeenState")}},{key:"loadInlineStyle_",value:function(){var e=this;if(this.storyGroupStyle.textContent=(0,_.inlineStyle)(this.properties_,this.instanceId_),this.customStoryGroupHTML_){var t=document.createElement("style");t.textContent=_.slotStyle.replace(/\s+/g," "),this.appendChild(t)}this.setOverlayVh_(),this.storylyFontCssDom_=document.createElement("style"),document.head.appendChild(this.storylyFontCssDom_);var r=document.createElement("style");this.storyShadowRoot_.appendChild(r),r.textContent+=(0,_.inlineStoryGroupStyle)(this.properties_);var s="sdk/".concat("3.4.0");"showcase.storyly.io"===window.location.hostname&&(s=new URLSearchParams(window.location.search).get("version")),fetch("https://web-story.storyly.io/".concat(s,"/storyly-web.css")).then(function(e){return e.text()}).then(function(e){r.textContent+=e.replace(/\s+/g," ")}),fetch("https://web-story.storyly.io/fonts/fonts.css").then(function(e){return e.text()}).then(function(t){e.storylyFontCssDom_.textContent+=t.replace(/\s+/g," ")})}},{key:"setOverlayVh_",value:function(){var e=.01*window.innerHeight;this.groupsOverlay_.style.setProperty("--vh","".concat(e,"px"))}},{key:"close",value:function(){this.handleCloseGroup_()}},{key:"openStory",value:function(e){var t=this,r=e.group,s=e.story,n=e.playMode;this.openStoryParams_=[r,s,n],this.groups_.length>0&&this.loadShareParams_().then(function(){t.handleOpenStoryByUrl_()}).catch(function(){})}},{key:"setSegments",value:function(t){var r=this;this.userConfig_.segments&&(0,y.isArraysEqual)(this.userConfig_.segments,t)||(this.segmentsDebounce_&&clearTimeout(this.segmentsDebounce_),this.segmentsDebounce_=setTimeout(function(){var s;r.groupShadowRoot_.innerHTML="",r.storylyFontCssDom_.remove(),r.replaceChildren(),r.renderMainDoms_();var n=[].concat((0,e.default)(null!==(s=r.userConfig_.segments)&&void 0!==s?s:[]),(0,e.default)(Array.isArray(t)?t:[])).length>0?(0,e.default)(new Set(t.map(function(e){return String(e)}))):null;r.init_=!1,r.userConfig_=P(P({},r.userConfig_),{},{segments:n}),r.init(r.userConfig_)},200))}},{key:"setProperties",value:function(e){(0,_.removeClass)(this.groupsWrapper_,this.properties_.storyGroupAlign),this.properties_=P(P(P({},this.properties_),e),{},{scrollIndicatorOptions:P(P({},this.properties_.scrollIndicatorOptions),(null==e?void 0:e.scrollIndicatorOptions)||{})}),(0,_.setClass)(this.groupsWrapper_,this.properties_.storyGroupAlign),this.globalInstanceData.properties=this.properties_,this.groupShadowRoot_.querySelector("#storyly__story-group-style-tag").textContent=(0,_.inlineStyle)(this.properties_,this.instanceId_),this.storyShadowRoot_.querySelector("style")&&(this.storyShadowRoot_.querySelector("style").textContent+=(0,_.inlineStoryGroupStyle)(this.properties_)),this.layoutImpl_&&(this.layoutImpl_.refreshSortData(),this.layoutImpl_.sort("order")),this.setContainerHeight_()}},{key:"setUserPropertiesData",value:function(){var e=(0,t.default)(d.default.mark(function e(r){var s,n,o=this;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r&&null!==(s=Object.keys(r))&&void 0!==s&&s.length){e.next=2;break}return e.abrupt("return");case 2:if(this.userPropertyData_=r,null!==(n=this.storyGroupsWithUserProperties_)&&void 0!==n&&n.length){e.next=5;break}return e.abrupt("return");case 5:this.storyGroupsWithUserProperties_.forEach(function(){var e=(0,t.default)(d.default.mark(function e(t){var r;return d.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=(0,m.createUserPropertyImpl)(o.userPropertyData_,t)).hidden){e.next=3;break}return e.abrupt("return");case 3:o.createGroupInstanceAndReorderCircleNodes_(r);case 4:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}());case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setEmbedContainerRatio",value:function(e){this.groupsOverlay_.style.setProperty("--i--storyly-story-layer-width","".concat(e.width,"px")),this.groupsOverlay_.style.setProperty("--i--storyly-story-layer-height","".concat(e.height,"px"))}},{key:"setStorylyHydration",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!Array.isArray(r))throw new Error("Hydration Data must be an Array!");this.storylyHydration=[].concat((0,e.default)(r),(0,e.default)(this.allProductsOfProductFeed_||[])),this.hiddenStoryGroups_.forEach(function(e){var r=(0,m.createUserPropertyImpl)(t.userPropertyData_,e);if(!r.hidden)if(r.stories.forEach(function(e){var r=(0,y.getProductLayers)(e),s=r.flatMap(function(e){return e.products.map(function(t){return P(P({},t),{},{type:e.type})})});if(s.length){var n=s.filter(function(e){return e.type!==G.LayerTemplateTypes.PRODUCT_CATALOG}).every(function(e){return t.storylyHydration.some(function(t){return t.product_group_id===e.product_group_id})}),o=(0,y.checkProductCatalogAtLeastOne)(r,t.storylyHydration);e.hidden=!n||!o}}),r.stories.some(function(e){return!e.hidden}))t.createGroupInstanceAndReorderCircleNodes_(r);else{var s=t.groupCircleNodes_.find(function(t){return+t.dataset.id===e.group_id});s&&t.removeGroupInstanceAndReorderCircleNodes_(s,e)}})}},{key:"updateCart",value:function(e){this.isStorylyCartActive=!0,this.setProductCartItems(e)}},{key:"setProductCartItems",value:function(e){this.storylyCheckoutProducts=e||{products:[],price:"",sales_price:"",price_currency:""};var t=this.getActiveGroup_();if(t){var r=t.instance;null!=r&&r.storylyCart&&e&&r.storylyCart.updateCart(e)}}},{key:"setLang",value:function(e){var t=e.language,r=e.json,s=t||this.userConfig_.locale||navigator.language,n=m.LocalizationImpl.getLocalizedJSON(r,s),o=this.globalInstanceData.languageJSON;this.globalInstanceData.languageJSON=P(P({},o),n),this.handleI18n_()}},{key:"setExternalData",value:function(){}},{key:"remove",value:function(){this.parentElement.removeChild(this),this.storyShadowDom_.remove(),this.storylyFontCssDom_.remove()}}]),l}((0,l.default)(HTMLElement));window.StorylyWeb=O;var L=exports.default=O;
|
|
218
218
|
},{"@babel/runtime/helpers/toConsumableArray":"Fhqp","@babel/runtime/helpers/asyncToGenerator":"agGE","@babel/runtime/helpers/slicedToArray":"HETk","@babel/runtime/helpers/defineProperty":"IxO8","@babel/runtime/helpers/classCallCheck":"fcMS","@babel/runtime/helpers/createClass":"P8NW","@babel/runtime/helpers/inherits":"d4H2","@babel/runtime/helpers/possibleConstructorReturn":"pxk2","@babel/runtime/helpers/getPrototypeOf":"UJE0","@babel/runtime/helpers/wrapNativeSuper":"ozpi","@babel/runtime/regenerator":"PMvg","uuid":"D6fo","./lib/api.ts":"JllC","./lib/storage":"NA5d","./lib/style":"vgU2","./lib/util":"PesM","./constants/playmode":"Ooqf","./main.scss":"yCDU","./service/custom-story-group-design-impl":"TkWu","./constants/common":"VKZr","./service":"hs1C","./constants/layouts":"kUgL","./constants/events":"d0lR","./constants/directions":"w67G","./constants/instanceStyleKeys":"FlW1","./constants/barLayouts":"HgmH","./components/AdGroup":"R6v9","./constants/layerTypes":"aJRz","./service/focal-point-impl.ts":"cofP","_bundle_loader":"TUK3","./layouts/Modern":[["Modern.ba02a4b1.js","ajqo"],"ajqo"],"./layouts/Classic":[["Classic.03f725b7.js","egGP"],"egGP"],"./service/nudge-story-groups-impl":[["nudge-story-groups-impl.13a886d7.js","MG73"],"MG73"],"./service/create-product-feed-impl":[["create-product-feed-impl.7b3fb1f7.js","GGgr"],"GGgr"]}],"Focm":[function(require,module,exports) {
|
|
219
219
|
"use strict";var e=n(require("./StorylyEmbed")),t=n(require("./StorylyWeb")),o=n(require("./lib/storage"));function n(e){return e&&e.__esModule?e:{default:e}}var r=new URLSearchParams(window.location.search),s=r.get("StorylyTestEnv"),l=o.default.getItemFromGlobal("Storyly_userConfig"),i=["v2-beta","latest"];window.structuredClone||(window.structuredClone=function(e){return JSON.parse(JSON.stringify(e))}),s&&l&&i.includes(s)?window.storylyInit||(window.storylyInit=!0,HTMLElement.prototype.init=function(){},fetch("https://web-story.storyly.io/".concat(s,"/storyly-web.js")).then(function(e){return e.text()}).then(function(e){customElements.define("storyly-web",window.StorylyWeb);var t=document.createElement("script");t.setAttribute("custom-element","storyly-web"),t.innerHTML=e,t.async=!0,document.body.appendChild(t),setTimeout(function(){var e=document.querySelector("storyly-web"),t=document.createElement("div");t.innerText='Storyly Test Env Activated!!. Now you are in "'.concat(s,'" script!'),t.style.color="red",t.style.fontSize="20px",t.style.fontWeight="bold",e.parentNode.insertBefore(t,e),e.init(l)},7500)})):(customElements.get("storyly-web")||customElements.define("storyly-web",t.default),customElements.get("storyly-web-embed")||customElements.define("storyly-web-embed",e.default));
|
|
220
220
|
},{"./StorylyEmbed":"vBxD","./StorylyWeb":"Lwlj","./lib/storage":"NA5d"}],"aYhM":[function(require,module,exports) {
|
|
@@ -231,9 +231,11 @@ var e=function(){var e=document.getSelection();if(!e.rangeCount)return function(
|
|
|
231
231
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=exports.default='\n <div class="storyly__audio-notification">\n <p>Video Has No Sound</p>\n </div>\n';
|
|
232
232
|
},{}],"LJ77":[function(require,module,exports) {
|
|
233
233
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=s(require("@babel/runtime/helpers/asyncToGenerator")),t=s(require("@babel/runtime/regenerator")),n=require("../constants/events"),r=require("../lib/util");function s(e){return e&&e.__esModule?e:{default:e}}function u(e){return a.apply(this,arguments)}function a(){return(a=(0,e.default)(t.default.mark(function e(s){var u,a,i,o,c,l,d;return t.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(u=s.source,a=s.tag,(i=s.thumbnail)&&(0,r.setAttribute)(a,"poster",i),void 0!==window.Hls){e.next=12;break}return e.next=5,fetch("https://cdn.jsdelivr.net/npm/hls.js@1");case 5:return o=e.sent,e.next=8,o.text();case 8:c=e.sent,(l=document.createElement("script")).innerHTML=c,document.body.appendChild(l);case 12:return(d=new window.Hls).attachMedia(a),d.on(window.Hls.Events.MEDIA_ATTACHED,function(){a.firstElementChild.type="application/x-mpegURL",d.loadSource(u)}),d.on(window.Hls.Events.ERROR,function(){(0,r.createAndDispatchEvent)(a,n.CustomerEventTypes.nextStoryGroup),d.destroy()}),e.abrupt("return",d);case 17:case"end":return e.stop()}},e)}))).apply(this,arguments)}var i=exports.default=u;
|
|
234
|
-
},{"@babel/runtime/helpers/asyncToGenerator":"agGE","@babel/runtime/regenerator":"PMvg","../constants/events":"d0lR","../lib/util":"PesM"}],"
|
|
235
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var
|
|
236
|
-
},{
|
|
234
|
+
},{"@babel/runtime/helpers/asyncToGenerator":"agGE","@babel/runtime/regenerator":"PMvg","../constants/events":"d0lR","../lib/util":"PesM"}],"A52n":[function(require,module,exports) {
|
|
235
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=exports.default=["0","1"];
|
|
236
|
+
},{}],"skR7":[function(require,module,exports) {
|
|
237
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=f(require("@babel/runtime/helpers/asyncToGenerator")),e=f(require("@babel/runtime/helpers/defineProperty")),a=f(require("@babel/runtime/helpers/slicedToArray")),r=f(require("@babel/runtime/helpers/toConsumableArray")),n=f(require("@babel/runtime/helpers/classCallCheck")),i=f(require("@babel/runtime/helpers/createClass")),o=f(require("@babel/runtime/regenerator")),s=f(require("../constants/availabilityStatus")),l=require("../constants/layerTypes"),u=f(require("../lib/proxy")),c=f(require("../lib/storage")),y=require("../lib/style"),m=require("../lib/util");function f(t){return t&&t.__esModule?t:{default:t}}function h(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function d(t){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?h(Object(r),!0).forEach(function(a){(0,e.default)(t,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}var p=function(){function e(t){var a=t.type,r=t.storyDom,i=t.instanceId;(0,n.default)(this,e),this.storyDom_=r,this.componentType_=a,this.instanceId=i,this.layerData={},this.isLayerShowing_=!1,this.instanceClass=u.default.getNodeByInstanceId(this.instanceId).getDataFromGlobal(),this.globalInstanceData=this.instanceClass.globalInstanceData,this.api=this.globalInstanceData.API,c.default.setInstanceId(this.instanceId)}return(0,i.default)(e,[{key:"getLocalComponentData",value:function(){return c.default.getItemFromInstance("Storyly_componentsData")}},{key:"setLocalComponentData",value:function(t){return this.globalInstanceData.presentationData?null:(c.default.setItemToInstance("Storyly_componentsData",t),t)}},{key:"setLayerData",value:function(t){this.layerData=t,this.loadFont_(t.font),this.handleAutomatedProducts_()}},{key:"handleAutomatedProducts_",value:function(){var t=this;if(this.layerData.products){var e,a=this.instanceClass.storylyHydration.filter(function(e){return t.layerData.products.find(function(t){return t.product_group_id===e.product_group_id})}),r=a.find(function(e){return e.product_id===t.layerData.products[0].product_id});if(this.layerData.productVariants=a,this.layerData.initialProduct=r,[l.LayerTemplateTypes.PRODUCT_TAG,l.LayerTemplateTypes.PRODUCT_CARD].includes(this.componentType_))this.layerData.title=r.title||this.layerData.title,this.layerData.image_url=(null===(e=r.image_urls)||void 0===e?void 0:e[0])||this.layerData.image_url,this.layerData.price=this.layerData.price&&(r.sales_price||r.price)?(0,m.currencyFormatter)(r.sales_price||r.price,r.price_currency):this.layerData.price,this.layerData.old_price=this.layerData.old_price&&r.price?(0,m.currencyFormatter)(r.price,r.price_currency):""}}},{key:"selector",value:function(t,e){return t.querySelector(e)}},{key:"selectorAll",value:function(t,e){return t.querySelectorAll(e)}},{key:"setStyle",value:function(t,e,a){t.style[e]=a}},{key:"getStyle",value:function(t,e){return t.style[e]}},{key:"setDataset",value:function(t,e,a){t.dataset[e]=a}},{key:"sumArrayValues",value:function(t){return t.map(Number).reduce(function(t,e){return t+e},0)}},{key:"isTextOverflow",value:function(t,e){var a=t.clientHeight,r=e.scrollHeight,n=e.scrollWidth,i=e.offsetWidth;return r>a||i<n}},{key:"generateHtmlFromTemplate",value:function(t){var e=document.createElement("template");return e.innerHTML=t,e.content.firstElementChild.cloneNode(!0)}},{key:"generateComponentAndAppendToPage",value:function(t){var e=this.generateHtmlFromTemplate(t);return this.storyDom_.appendChild(e),this.layerDom_=e.firstElementChild,this.animateLayerObserver_(),Promise.resolve(e.firstElementChild)}},{key:"getComponentLocalData",value:function(t,e){var a,r=c.default.getItemFromInstance("Storyly_localComponentData")[t];return r&&null!==(a=r[e.uid])&&void 0!==a?a:{}}},{key:"setComponentLocalData",value:function(t,e){var a;if(!this.globalInstanceData.presentationData){var r=c.default.getItemFromInstance("Storyly_localComponentData"),n=r[t];(n=null!==(a=n)&&void 0!==a?a:{})[e.uid]=e,r[t]=n,c.default.setItemToInstance("Storyly_localComponentData",r)}}},{key:"storyObserver_",value:function(t){if(!this.storyDom_.classList.contains("layers-container"))throw Error("Story Dom Not Found!");var e=new MutationObserver(t);return e.observe(this.storyDom_.parentElement,{attributes:!0}),e}},{key:"hideLayer",value:function(){var t=this;this.layerData.animation||(0,y.setClass)(this.layerDom_,"timed-interactive-animation-visually-hide"),setTimeout(function(){var e;null===(e=t.customAnimations_)||void 0===e||e.cancel(),(0,y.setClass)(t.layerDom_,"timed-interactive-animation-hide"),t.layerDom_.removeAttribute("data-use-animation")},20)}},{key:"showLayer",value:function(){var t=this;(0,y.removeClass)(this.layerDom_,"timed-interactive-animation-hide"),this.layerData.animation?this.setAnimationAttr_():setTimeout(function(){(0,y.removeClass)(t.layerDom_,"timed-interactive-animation-visually-hide")},100)}},{key:"setAnimationAttr_",value:function(){this.layerDom_.hasAttribute("data-use-animation")||(this.layerDom_.setAttribute("data-use-animation",""),this.useAnimation())}},{key:"useAnimation",value:function(t){var e=this,n=this.layerData.animation;if(n&&!this.animationActive_&&(this.layerData.type!==l.LayerTemplateTypes.TEXT||t===l.LayerTemplateTypes.TEXT)){this.layerDom_.style.transition="",this.layerDom_.style.opacity="0",this.layerDom_.style.visibility="visible";var i=n.by&&"box"!==n.by,o=this.layerDom_.querySelectorAll("*"),s=Array.from([].concat((0,r.default)(o),[this.layerDom_])).flatMap(function(t){return t.getAnimations()});s.forEach(function(t){t.pause(),t.cancel()});var u=this.getAnimationKeyframes_(),c=(0,a.default)(u,2),y=c[0],m=c[1];if(this.layerData.type===l.LayerTemplateTypes.TEXT&&i)return this.layerDom_.style.opacity="1",this.layerDom_.firstElementChild.style.overflow="visible",void(0,r.default)(this.layerDom_.querySelectorAll('[data-animate="true"]')).forEach(function(t,a){e.setStyle(t,"opacity","0");var r=new KeyframeEffect(t,y,d(d({},m),{},{delay:(a+1)*("letter"===n.by?50:200)+200})),i=new Animation(r);i.play(),i.onfinish=function(t){var a=t.target;e.hiddenInteractiveCommitStyles_(a),a.cancel()}});var f=new KeyframeEffect(this.layerDom_,y,m);this.customAnimations_=new Animation(f),this.customAnimations_.play(),this.customAnimations_.onfinish=function(t){var a=t.target;e.animationActive_=!1,e.hiddenInteractiveCommitStyles_(a),e.layerData.type!==l.LayerTemplateTypes.TEXT&&s.forEach(function(t){return t.play()})}}}},{key:"hiddenInteractiveCommitStyles_",value:function(t){this.layerDom_.classList.contains("timed-interactive-animation-hide")||t.commitStyles()}},{key:"getAnimationKeyframes_",value:function(){var t=this.layerData,e=t.animation,a=t.rotation,n=e.by&&"box"!==e.by,i=e.en||[{s:1}],o=n?0:null!=a?a:0,s=e.du||600,l="cubic-bezier(".concat(((null==e?void 0:e.ea)||[.5,-.1,.5,1.1]).join(","),")");return[[].concat((0,r.default)(i.map(function(t){var e;return{transform:(0,m.getTransformString)(t,o,n),opacity:null!==(e=t.o)&&void 0!==e?e:1}})),[{opacity:1,transform:"translateX(0) translateY(0) rotate(".concat(o,"deg) scale(1)")}]),{duration:s,easing:l,fill:"forwards",delay:200}]}},{key:"animateLayerObserver_",value:function(){var t=this,e="component"===this.layerDom_.getAttribute("role"),a=!(!this.layerData.start_time&&!this.layerData.end_time),r=this.layerData.animation;if(e&&r&&!a){this.setStyle(this.layerDom_,"opacity","0");new MutationObserver(function(e){e.forEach(function(e){var a;"attributes"===e.type&&"show"===e.attributeName&&(e.target.hasAttribute("show")?setTimeout(function(){t.setAnimationAttr_()},300):(null===(a=t.customAnimations_)||void 0===a||a.cancel(),t.layerDom_.style.opacity="0",t.animationActive_=!1,t.layerDom_.removeAttribute("data-use-animation")))})}).observe(this.layerDom_.closest(".storyly__story"),{attributes:!0})}}},{key:"loadFont_",value:function(){var e=(0,t.default)(o.default.mark(function t(e){var a,r,n,i,s,l;return o.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:if(a=JSON.parse(sessionStorage.getItem("Storyly__fonts")||"{}"),r=Object.values(a).findIndex(function(t){return t===e.url}),n=Object.keys(a)[r],i=n||"Storyly__font-".concat((0,m.randomAlphaNum)(4)),this.layerData.fontFamily=i,!n){t.next=9;break}return t.abrupt("return");case 9:return s=new FontFace(i,"url(".concat(e.url.replace("http://","https://"),")"),{display:"swap"}),a[i]=e.url,sessionStorage.setItem("Storyly__fonts",JSON.stringify(a)),t.next=14,s.load();case 14:l=t.sent,document.fonts.add(l);case 16:case"end":return t.stop()}},t,this)}));return function(t){return e.apply(this,arguments)}}()}]),e}(),v=exports.default=p;
|
|
238
|
+
},{"@babel/runtime/helpers/asyncToGenerator":"agGE","@babel/runtime/helpers/defineProperty":"IxO8","@babel/runtime/helpers/slicedToArray":"HETk","@babel/runtime/helpers/toConsumableArray":"Fhqp","@babel/runtime/helpers/classCallCheck":"fcMS","@babel/runtime/helpers/createClass":"P8NW","@babel/runtime/regenerator":"PMvg","../constants/availabilityStatus":"A52n","../constants/layerTypes":"aJRz","../lib/proxy":"qmVm","../lib/storage":"NA5d","../lib/style":"vgU2","../lib/util":"PesM"}],"A6vb":[function(require,module,exports) {
|
|
237
239
|
"use strict";var e=r(require("@babel/runtime/helpers/slicedToArray"));function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../../constants/layerTypes"),o=require("../../lib/util"),a=function(r,a){var c,n,i=Object.assign(Object.assign({border_radius:0,w:100,h:100,x:0,y:0},r),{text_font:(null===(c=r.text_font)||void 0===c?void 0:c.includes("Poppins"))?void 0:r.text_font,fontFamily:!r.text_font||(null===(n=r.text_font)||void 0===n?void 0:n.includes("Poppins"))?"Storyly-Inter":void 0});return Object.keys(i).forEach(function(r){switch(r){case"bg_color":case"background_color":case"text_span_color":var c=(0,o.convertHex)(i[r]);i.background=c;break;case"text_color":var n=(0,o.convertHex)(i[r]);i.color=n;break;case"icon_color":var s=(0,o.convertHex)(i[r]),l=(0,o.getContrastBgColor)(i[r]);i.background_color=s,i.text_color=(0,o.convertHex)(l),i.border_color=(0,o.convertHex)(l,.3);break;case"rotation":i.transform="rotate(".concat(i[r],"deg)");break;case"is_bold":i.fontWeight=i[r]?700:"normal";break;case"is_italic":i.fontStyle=i[r]?"italic":"normal";break;case"text_font":if(i[r]){var d=i[r].split("-"),b=(0,e.default)(d,2),u=b[0],_=b[1];i.fontFamily="Storyly-".concat(u),i.fontWeight=_.includes("Bold")?700:"normal",i.fontStyle=_.includes("Italic")?"italic":"normal"}break;case"text_size":var f=2*i[r]+14;i.fontSize=f;break;case"x":i.x=i[r];break;case"w":i.width="".concat(i[r],"%");break;case"y":i.y=i[r];break;case"h":i.height="".concat(i[r],"%");break;case"border_color":if(!i[r])break;var v=(0,o.convertHex)(i[r]);i.borderColor=v;break;case"border_thickness":if(!1===i[r])break;var k=2*i[r]>=0?2*i[r]+2:0;i.borderWidth=k;break;case"scale":var x=i[r]+1;i.compScale=x;break;case"border_radius":i.type===t.LayerTemplateTypes.BUTTON&&(i.border_radius=(0,o.calcBorderRadius)(i,a));break;default:return!0}return!0}),i};exports.default=a;
|
|
238
240
|
},{"@babel/runtime/helpers/slicedToArray":"HETk","../../constants/layerTypes":"aJRz","../../lib/util":"PesM"}],"ddlQ":[function(require,module,exports) {
|
|
239
241
|
"use strict";var n=t(require("@babel/runtime/helpers/toConsumableArray"));function t(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(exports,"__esModule",{value:!0});var o=require("../../../lib/util"),e=function(n){return'\n<div class="arrow-lines">\n <span class="arrow-lines-left" '.concat(n?'style="background-color: '.concat(n,'"'):"",'></span>\n <span class="arrow-lines-right" ').concat(n?'style="background-color: '.concat(n,'"'):"","></span>\n</div>")};exports.default=function(t,a,c){var r;return'\n <div class="component-layer swipe" dir="'.concat(a.direction,'">\n <div\n class="swipe-up"\n style="\n z-index: ').concat(null!==(r=t.z_index)&&void 0!==r?r:1,';\n "\n >\n ').concat(t.button_text?e(t.background_color):"",'\n <button\n style="\n font-family: ').concat((0,o.getFontFamily)({font:t.fontFamily,instanceId:c}),";\n font-weight: ").concat(t.fontWeight,";\n font-style: ").concat(t.fontStyle,";\n border-color: ").concat(t.border_color,";\n --text-color: ").concat(t.text_color,";\n --background-color: ").concat(t.background_color,';\n "\n aria-hidden="true"\n aria-label="{@_').concat(t.button_text,'_1}, opens in a new tab"\n data-i18n-key="a11y_cta_redirect_button"\n class="swipe-up-button"\n >\n ').concat(t.button_text||(0,n.default)(Array(2)).map(function(){var n=e();return"".concat(n)}).join(""),"\n </button>\n </div>\n </div>")};
|
|
@@ -242,8 +244,8 @@ var e=function(){var e=document.getSelection();if(!e.rangeCount)return function(
|
|
|
242
244
|
},{"../../../lib/util":"PesM"}],"vow2":[function(require,module,exports) {
|
|
243
245
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.injectSVGByType=exports.applyVisibilityIfKeyExists=exports.applyColorStyleIfKeyExists=void 0;var e=require("../../lib/icons"),t=require("../../lib/util"),r=function(e,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return e?'style="'.concat(String(r),": ").concat((0,t.convertHex)(e),"; ").concat(o,'"'):'style="'.concat(o,'"')};exports.applyColorStyleIfKeyExists=r;var o=function(e,t){return"boolean"==typeof e&&!1===e?"":t};exports.applyVisibilityIfKeyExists=o;var i=function(r){var o,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#ffffffff";switch(r){case"bag":o=(0,e.shoppingBagIcon)((0,t.convertHex)(i));break;case"cart":o=(0,e.cartIcon)((0,t.convertHex)(i));break;case"purse":o=(0,e.purseIcon)((0,t.convertHex)(i));break;default:o=(0,e.shoppingBagIcon)((0,t.convertHex)(i))}return o};exports.injectSVGByType=i;
|
|
244
246
|
},{"../../lib/icons":"irwm","../../lib/util":"PesM"}],"zYZy":[function(require,module,exports) {
|
|
245
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=
|
|
246
|
-
},{"@babel/runtime/helpers/toConsumableArray":"Fhqp","../../../constants/layouts":"kUgL","../../../lib/util":"PesM","../util.ts":"vow2"}],"BYjw":[function(require,module,exports) {
|
|
247
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=c(require("@babel/runtime/helpers/toConsumableArray")),n=c(require("@babel/runtime/helpers/defineProperty")),e=c(require("../../../constants/availabilityStatus.js")),r=c(require("../../../constants/layouts")),a=require("../../../lib/util"),i=require("../util.ts");function c(t){return t&&t.__esModule?t:{default:t}}function o(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),e.push.apply(e,r)}return e}function l(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach(function(e){(0,n.default)(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}var u=function(n,r){var i=n[r].variant.map(function(t){return t.v}),c=n.flatMap(function(t){return t.variant.map(function(n){return l(l({},n),{},{availability:t.availability})})}),o=n.map(function(t){return t.variant.map(function(t){return t.v})});function u(r,a){var c=(0,t.default)(i);c[r]=a,c.length=r+1;var o=n.find(function(t){return t.variant.map(function(t){return t.v}).toString().startsWith(c.toString())});return o?e.default.includes(o.availability)?Number(o.availability):1:0}var s=(0,t.default)(new Set(c.map(function(t){return t.n}))).map(function(n){return{title:n,values:(0,t.default)(new Set(c.filter(function(t){return t.n===n}).sort(function(t,n){return t.o-n.o}).map(function(t){return t.v}))).map(function(n){return{value:n,selected:function(t){return u(t,n)&&i.includes(n)},isColor:(0,a.isHexColor)(n),disabled:function(e){var r=(0,t.default)(i);return r[e]=n,r.length=e+1,!o.find(function(t){return t.toString().startsWith(r.toString())})},availability:function(t){return u(t,n)}}})}});return s.map(function(t,n){var e=t.title,r=t.values;return'\n <div class="product-detail-variant">\n <h6 class="product-detail-title-small">'.concat(e.toLocaleUpperCase(),'</h6>\n <div class="product-detail-variant-row">\n ').concat(r.map(function(t){var r=t.isColor,a=t.selected,i=t.value,c=t.disabled,o=t.availability;return'\n <div\n class="'.concat(function(t,n,e,r){return t(r)?"selected":0===e(r)?"unavailable":n(r)&&0!==r?"disabled":""}(a,c,o,n),'"\n data-variant="').concat(e,'"\n data-value="').concat(i,'"\n data-order="').concat(n,'">\n ').concat(r?'<span style="background-color: '.concat(i,'"></span>'):"<span>".concat(i,"</span>"),"\n </div>")}).join(""),"\n </div>\n </div>")}).join("")},s=function(t){return'\n <div class="product-detail-price">'.concat((0,i.applyVisibilityIfKeyExists)(t.p_p_v,!t.sales_price&&t.price?'<span class="product-card-current-price">'.concat((0,a.currencyFormatter)(t.price,t.price_currency),"</span>"):"")).concat(t.sales_price&&t.price?"".concat((0,i.applyVisibilityIfKeyExists)(t.p_sp_v,'<span class="product-card-current-price">'.concat((0,a.currencyFormatter)(t.sales_price,t.price_currency),"</span>"))).concat((0,i.applyVisibilityIfKeyExists)(t.p_p_v,' <span class="product-card-old-price">'.concat((0,a.currencyFormatter)(t.price,t.price_currency),"</span>"))):"","</div>\n")},d=function(t){return'\n <div class="product-detail-description">\n <h6\n class="product-detail-title-small"\n '.concat(t.p_d_title?"":'data-i18n-key="description"',"\n >\n ").concat(t.p_d_title,"\n </h6>\n <p>").concat(t.description||"","</p>\n </div>\n")},p=function(t,n){return"\n ".concat(t.length>0||n.layout!==r.default.MODERN?'<div class="product-detail-media-small">\n '.concat(t.map(function(t,n){return'<div class="product-detail-media-small-container '.concat(0===n?"selected":"",'">\n <img src="').concat(t,'" />\n </div>')}).join(""),"\n </div>"):"",'\n <div class="product-detail-media-large">\n <img src="').concat(t[0],'" />\n </div>\n')},v=exports.default=function(t,n,e,c){return'\n <div\n class="product-detail '.concat(e.layout===r.default.MODERN?"modal":"bottom-sheet",'"\n style="font-family: ').concat((0,a.getFontFamily)({instanceId:c}),';"\n >\n <div class="product-detail-media">\n ').concat(p(t[n].image_urls,e),'\n </div>\n <div class="product-detail-variants">\n ').concat((0,i.applyVisibilityIfKeyExists)(t[n].p_t_v,'<h4 class="product-detail-title-md">'.concat(t[n].title,"</h4>")),"\n\n ").concat(s(t[n]),"\n ").concat(u(t,n),"\n ").concat((0,i.applyVisibilityIfKeyExists)(t[n].p_d_v,d(t[n])),"\n </div>\n </div>")};
|
|
248
|
+
},{"@babel/runtime/helpers/toConsumableArray":"Fhqp","@babel/runtime/helpers/defineProperty":"IxO8","../../../constants/availabilityStatus.js":"A52n","../../../constants/layouts":"kUgL","../../../lib/util":"PesM","../util.ts":"vow2"}],"BYjw":[function(require,module,exports) {
|
|
247
249
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=o(require("../../../constants/layouts")),n=require("../../../lib/util"),c=require("../util.ts");function o(t){return t&&t.__esModule?t:{default:t}}var e=exports.default=function(o,e,r){return'\n <div\n class="product-detail-footer '.concat(e.layout===t.default.MODERN?"modal":"bottom-sheet",'"\n style="font-family: ').concat((0,n.getFontFamily)({instanceId:r}),';"\n >\n <div class="product-detail-footer-price">\n ').concat((0,c.applyVisibilityIfKeyExists)(o.p_p_v,!o.sales_price&&o.price?'<span class="product-card-current-price">'.concat((0,n.currencyFormatter)(o.price,o.price_currency),"</span>"):""),"\n ").concat(o.sales_price&&o.price?"\n ".concat((0,c.applyVisibilityIfKeyExists)(o.p_sp_v,'<span class="product-card-current-price">'.concat((0,n.currencyFormatter)(o.sales_price,o.price_currency),"</span>")),"\n ").concat((0,c.applyVisibilityIfKeyExists)(o.p_p_v,' <span class="product-card-old-price">'.concat((0,n.currencyFormatter)(o.price,o.price_currency),"</span>")),"\n "):"",'\n </div>\n <div class="product-detail-footer-action">\n ').concat((0,c.applyVisibilityIfKeyExists)(o.p_q_v,'<div class="counter">\n <button class="counter-button" data-type="minus">\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none"><path stroke="#242450" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.482" d="M3.333 8h9.334"/></svg>\n </button>\n <span class="counter-count">1</span>\n <button class="counter-button" data-type="plus">\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none"><path fill="#242450" fill-rule="evenodd" d="M8.741 3.333a.741.741 0 0 0-1.482 0V7.26H3.334a.741.741 0 1 0 0 1.482h3.925v3.926a.741.741 0 1 0 1.482 0V8.74h3.926a.741.741 0 0 0 0-1.482H8.741V3.333Z" clip-rule="evenodd"/></svg>\n </button>\n </div>'),'\n <button\n class="product-detail-footer-action-button"\n ').concat((0,c.applyColorStyleIfKeyExists)(o.p_b_bg_color,"background-color","".concat(o.p_b_text_color?"border: 1px solid ".concat((0,n.convertHex)(o.p_b_text_color,.1)):"")),"\n >\n ").concat((0,c.applyVisibilityIfKeyExists)(o.p_b_icon_v,'<div class="product-detail-footer-action-button-icon">\n '.concat((0,c.injectSVGByType)(o.p_b_icon,o.p_b_text_color),"\n </div>")),"\n <span \n ").concat(o.p_b_text?"":'data-i18n-key="add_to_cart"'," \n ").concat((0,c.applyColorStyleIfKeyExists)(o.p_b_text_color,"color"),"\n >\n ").concat(o.p_b_text,"\n </span>\n </button>\n </div>\n </div>\n")};
|
|
248
250
|
},{"../../../constants/layouts":"kUgL","../../../lib/util":"PesM","../util.ts":"vow2"}],"vFtU":[function(require,module,exports) {
|
|
249
251
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=require("../../../lib/util"),o=require("../util.ts"),n=exports.default=function(n,c){return'\n <div\n class="product-checkout-footer"\n style="font-family: '.concat((0,t.getFontFamily)({instanceId:c}),';">\n <p>\n ').concat((0,o.applyVisibilityIfKeyExists)(n.s_icon_v,'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" fill="none"><path stroke="#212121" stroke-linecap="round" stroke-linejoin="round" stroke-width="4" d="M40 14 18 36 8 26"/></svg>'),"\n <span ").concat(n.s_message?"":'data-i18n-key="added_cart_sucessfully"',">\n ").concat(n.s_message,'\n </span>\n </p>\n <div class="product-checkout-footer-buttons">\n <button\n ').concat((0,o.applyColorStyleIfKeyExists)(n.s_b_back_bg_color,"background-color","".concat(n.s_b_back_text_color?"border: 1px solid ".concat((0,t.convertHex)(n.s_b_back_text_color,.1)):"")),' \n type="button"\n class="continue-button">\n <span\n ').concat(n.s_b_back_text?"":'data-i18n-key="continue_with_stories"',"\n ").concat((0,o.applyColorStyleIfKeyExists)(n.s_b_back_text_color,"color")," \n >\n ").concat(n.s_b_back_text,'\n </span>\n </button>\n <button type="button" class="checkout-button" ').concat((0,o.applyColorStyleIfKeyExists)(n.s_b_cart_bg_color,"background-color","".concat(n.s_b_cart_text_color?"border: 1px solid ".concat((0,t.convertHex)(n.s_b_cart_text_color,.1)):"")),">\n ").concat((0,o.applyVisibilityIfKeyExists)(n.s_b_cart_icon_v,(0,o.injectSVGByType)(n.s_b_cart_icon,n.s_b_cart_text_color)),"\n <span\n ").concat((0,o.applyColorStyleIfKeyExists)(n.s_b_cart_text_color,"color")," \n ").concat(n.s_b_cart_text?"":'data-i18n-key="go_to_cart"',"\n >\n ").concat(n.s_b_cart_text,"\n </span>\n </button>\n </div>\n </div>\n")};
|
|
@@ -258,8 +260,8 @@ var e=function(){var e=document.getSelection();if(!e.rangeCount)return function(
|
|
|
258
260
|
},{"platform":"kohK","../../constants/os":"Ms5h","./template/android":"VSr3"}],"tk2H":[function(require,module,exports) {
|
|
259
261
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=require("../../lib/icons"),c=exports.default=function(c){var e=c.text;return'\n <div class="storyly__alert-box">\n <div class="storyly__alert-box-icon">\n <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path fill="#212121" d="M11.996 17.354c.33 0 .603-.104.818-.312.214-.208.322-.477.322-.807 0-.33-.106-.604-.319-.824a1.083 1.083 0 0 0-.813-.33c-.33 0-.603.11-.818.33a1.13 1.13 0 0 0-.322.824c0 .33.106.599.319.806.212.209.483.313.813.313Zm.083-4.165c.28 0 .514-.095.703-.286a.963.963 0 0 0 .283-.704V7.614a.955.955 0 0 0-.287-.704.963.963 0 0 0-.707-.286.949.949 0 0 0-.703.286.963.963 0 0 0-.283.704V12.2c0 .279.096.513.287.704.192.19.428.286.707.286Zm-.07 9.165c-1.437 0-2.783-.27-4.038-.81a10.449 10.449 0 0 1-3.294-2.221 10.45 10.45 0 0 1-2.22-3.294c-.54-1.255-.81-2.601-.81-4.04 0-1.438.27-2.785.81-4.041.54-1.256 1.28-2.35 2.218-3.284A10.608 10.608 0 0 1 7.967 2.45c1.256-.544 2.603-.816 4.042-.816 1.44 0 2.787.272 4.045.815a10.471 10.471 0 0 1 3.284 2.212c.932.932 1.67 2.027 2.214 3.287a10.1 10.1 0 0 1 .815 4.047c0 1.438-.272 2.784-.816 4.039a10.56 10.56 0 0 1-2.215 3.287 10.413 10.413 0 0 1-3.286 2.219 10.086 10.086 0 0 1-4.041.814Zm.003-1.981c2.321 0 4.295-.814 5.921-2.443 1.627-1.63 2.44-3.61 2.44-5.942 0-2.32-.812-4.294-2.435-5.92-1.623-1.627-3.605-2.44-5.945-2.44-2.317 0-4.29.811-5.92 2.434-1.63 1.624-2.446 3.605-2.446 5.945 0 2.317.815 4.29 2.443 5.92 1.63 1.631 3.61 2.446 5.942 2.446Z"/></svg>\n </div>\n <div class="storyly__alert-box-message">\n <p>'.concat(e,'</p>\n </div>\n <div class="storyly__alert-box-close">\n ').concat((0,t.xIcon)("#616161"),"\n </div>\n </div>\n")};
|
|
260
262
|
},{"../../lib/icons":"irwm"}],"GdVG":[function(require,module,exports) {
|
|
261
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=_(require("@babel/runtime/helpers/defineProperty")),e=_(require("@babel/runtime/helpers/classCallCheck")),r=_(require("@babel/runtime/helpers/createClass")),o=_(require("@babel/runtime/helpers/inherits")),i=_(require("@babel/runtime/helpers/possibleConstructorReturn")),n=_(require("@babel/runtime/helpers/getPrototypeOf")),s=require("./template"),a=require("../../constants/events"),c=require("../../lib/util"),u=_(require("../../layers/base")),l=_(require("../../constants/layouts")),d=_(require("../LoadingSpinner")),h=_(require("../Alert"));function _(t){return t&&t.__esModule?t:{default:t}}function p(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,o)}return r}function y(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?p(Object(o),!0).forEach(function(r){(0,t.default)(e,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):p(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function v(t){var e=m();return function(){var r,o=(0,n.default)(t);if(e){var s=(0,n.default)(this).constructor;r=Reflect.construct(o,arguments,s)}else r=o.apply(this,arguments);return(0,i.default)(this,r)}}function m(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(m=function(){return!!t})()}var f=function(t){(0,o.default)(n,t);var i=v(n);function n(t){var r,o=t.instanceId,a=t.layer,c=t.storyDom,u=t.group,l=t.story;return(0,e.default)(this,n),(r=i.call(this,{instanceId:o,storyDom:c})).group_=u,r.story_=l,r.selectedProduct_={},r.productData_=a,r.loading_=!1,r.productCheckoutFooter_=r.generateHtmlFromTemplate((0,s.ProductCheckoutFooterTemplate)(r.productData_,o)),r.setLayerData(y({},a)),r.attachCallbacksToElement_(),r}return(0,r.default)(n,[{key:"attachCallbacksToElement_",value:function(){this.eventListeners_=this.eventListeners_.bind(this),this.onPurchase=this.onPurchase.bind(this),this.onCounter_=this.onCounter_.bind(this),this.onMediaSelect_=this.onMediaSelect_.bind(this),this.onVariantSelect_=this.onVariantSelect_.bind(this),this.onAddToCart_=this.onAddToCart_.bind(this),this.renderCheckoutBottomSheetFooter_=this.renderCheckoutBottomSheetFooter_.bind(this),this.onCheckoutToCart_=this.onCheckoutToCart_.bind(this),this.onSuccess_=this.onSuccess_.bind(this),this.onError_=this.onError_.bind(this)}},{key:"eventListeners_",value:function(){var t=this;if(this.counterButton_.forEach(function(e){return(0,c.setClickEventListener)(e,t.onCounter_)}),Array.from(this.medias_).forEach(function(t){var e=t.firstElementChild;e.addEventListener("load",function(){e.style.width="".concat(e.width,"px"),e.style.opacity="1",e.parentElement.style.width="".concat(e.width,"px")},{once:!0})}),this.globalInstanceData.layout===l.default.MODERN){var e=this.productDetailBody_.querySelector(".product-detail-media-large");e.firstElementChild.addEventListener("load",function(){(0,c.imageAnimationHandler)(e,"img")})}var r=this.productCheckoutFooter_.querySelector(".continue-button"),o=this.productCheckoutFooter_.querySelector(".checkout-button");((0,c.setClickEventListener)(this.addToCartButton_,this.onAddToCart_),(0,c.setClickEventListener)(o,this.onCheckoutToCart_),(0,c.setClickEventListener)(r,function(){(0,c.createAndDispatchEvent)(t.storyDom_,(0,c.closeProductDetail)(t.instanceId))}),(0,c.isMobileView)())?(this.productDetailBody_.querySelectorAll(".product-detail-variant-row").forEach(function(e){e.addEventListener("touchstart",function(r){r.stopPropagation(),r.stopImmediatePropagation(),e.childNodes.forEach(function(e){e.addEventListener("touchend",t.onVariantSelect_)})}),e.addEventListener("scroll",function(){e.childNodes.forEach(function(e){e.removeEventListener("touchend",t.onVariantSelect_)})})}),this.productDetailBody_.parentElement.addEventListener("scroll",function(){t.variants_.forEach(function(e){e.removeEventListener("touchend",t.onVariantSelect_)})})):(this.medias_.forEach(function(e){return(0,c.setClickEventListener)(e,t.onMediaSelect_)}),this.variants_.forEach(function(e){e.addEventListener("click",t.onVariantSelect_)}))}},{key:"renderCheckoutModalFooter_",value:function(){this.productCheckoutFooter_.classList.add("modal");var t=this.productDetailFooter_.parentNode,e=this.productDetailBody_.parentNode,r=t.parentElement;r.insertBefore(this.productCheckoutFooter_,t),this.setStyle(this.productDetailBody_,"opacity","0.3"),this.setStyle(r,"maxHeight","calc(100vh * 0.65 + 50px)"),this.setStyle(e,"boxShadow","rgb(134 134 134 / 20%) 0px 7px 10.5px"),this.setStyle(e,"borderBottomLeftRadius","8px"),this.setStyle(e,"borderBottomRightRadius","8px"),this.setStyle(e,"pointerEvents","none");var o=new KeyframeEffect(t,[{opacity:1},{opacity:0,pointerEvents:"none"}],{duration:300,iterations:1,fill:"forwards"});new Animation(o).play()}},{key:"renderCheckoutBottomSheetFooter_",value:function(){var t=this.generateHtmlFromTemplate('<div style="display: none;"></div>');this.productCheckoutFooter_.classList.add("bottom-sheet"),(0,c.createAndDispatchEvent)(this.storyDom_,(0,c.openProductDetail)(this.instanceId),{body:this.productCheckoutFooter_,footer:t,rerender:!0})}},{key:"onPurchase",value:function(t,e){var r=this;this.loading_=!1;var o=this.productData_.productVariants,i=o.find(function(e){return e.product_id===t});if(this.selectedProduct_=i,"cta"!==this.layerData.cta_t){var n=this.instanceClass,u=n.isStorylyCartActive,l=n.globalInstanceData;if(u||!l.events[a.CustomerEventTypes.storyNoCartIntegration]){var d=o.filter(function(t){return t.product_group_id===i.product_group_id}).map(function(t){return y(y({},r.layerData),t)}),_=d.findIndex(function(e){return e.product_id===t});this.selectedProduct_.quantity=1,this.selectedProducGroup_=d,this.productDetailBody_=this.generateHtmlFromTemplate((0,s.ProductDetailTemplate)(d,_,this.globalInstanceData,this.instanceId)),this.medias_=this.productDetailBody_.querySelectorAll(".product-detail-media-small-container"),this.variants_=this.productDetailBody_.querySelectorAll(".product-detail-variant-row div"),this.productDetailFooter_=this.generateHtmlFromTemplate((0,s.ProductDetailFooterTemplate)(y(y({},this.productData_),i),this.globalInstanceData,this.instanceId)),this.counterButton_=this.productDetailFooter_.querySelectorAll(".counter .counter-button"),this.addToCartButton_=this.productDetailFooter_.querySelector(".product-detail-footer-action-button"),(0,c.createAndDispatchEvent)(this.storyDom_,(0,c.openProductDetail)(this.instanceId),{body:this.productDetailBody_,footer:this.productDetailFooter_,rerender:e}),this.handleEvent_(a.LayerEventTypes.ProductSelected,{product:i}),e||this.handleEvent_(a.LayerEventTypes.ProductSheetOpened,{product:i}),this.alert_=this.generateHtmlFromTemplate((0,h.default)({text:""}));var p=this.alert_.querySelector(".storyly__alert-box-close");(0,c.setClickEventListener)(p,function(){return r.alert_.classList.remove("active")}),this.productDetailBody_.prepend(this.alert_),this.eventListeners_(),(0,c.createAndDispatchEvent)(this.storyDom_,"onI18nEvent",{wrapperDom:this.productDetailBody_}),(0,c.createAndDispatchEvent)(this.storyDom_,"onI18nEvent",{wrapperDom:this.productDetailFooter_})}else(0,c.createAndDispatchEvent)(this.storyDom_,"onCustomerEvent",{eventName:a.CustomerEventTypes.storyNoCartIntegration,params:i})}else this.handleCTAEvent_()}},{key:"onCounter_",value:function(t){if(!this.loading_){var e=t.target.dataset,r=this.productDetailFooter_.querySelector(".counter-count"),o=Number(r.innerHTML);"plus"===e.type?(o+=1,r.innerHTML=o):o>1&&"minus"===e.type&&(o-=1,r.innerHTML=o),this.selectedProduct_.quantity=o}}},{key:"onAddToCart_",value:function(){var t,e=this;if(!this.loading_){var r={group:this.group_,story_id:this.story_.story_id,alt_text:this.story_.alt_text,is_sharable:this.story_.is_sharable,product:y({},this.selectedProduct_),product_type:a.LayerEventTypes.ProductAdded,onError:this.onError_,onSuccess:this.onSuccess_};this.timeout_=setTimeout(function(){e.onError_({message:"Something went wrong!"})},5e3),this.loading_=!0;var o=this.generateHtmlFromTemplate((0,d.default)(16));this.addToCartButtonSvg_=this.addToCartButton_.querySelector(".product-detail-footer-action-button-icon"),null===(t=this.addToCartButtonSvg_)||void 0===t||t.replaceWith(o),(0,c.createAndDispatchEvent)(this.storyDom_,"onCustomerEvent",{eventName:a.CustomerEventTypes.storyCartUpdate,params:r})}}},{key:"onSuccess_",value:function(t){var e=this;setTimeout(function(){return clearTimeout(e.timeout_)},0),this.alert_.classList.remove("active"),this.instanceClass.setProductCartItems(t),this.globalInstanceData.layout===l.default.MODERN?this.renderCheckoutModalFooter_():this.renderCheckoutBottomSheetFooter_(),(0,c.createAndDispatchEvent)(this.storyDom_,"onI18nEvent",{wrapperDom:this.productCheckoutFooter_}),this.handleEvent_(a.LayerEventTypes.ProductCartAdded)}},{key:"onError_",value:function(t){var e=this,r=t.message;setTimeout(function(){return clearTimeout(e.timeout_)},0),this.alert_.querySelector("p").innerHTML=r,this.alert_.classList.add("active"),this.loading_=!1;var o=this.addToCartButton_.querySelector(".storyly-spinner-container");null==o||o.replaceWith(this.addToCartButtonSvg_),this.handleEvent_(a.LayerEventTypes.ProductCartAddFailed)}},{key:"onMediaSelect_",value:function(t){var e=t.target,r=e.src,o=this.productDetailBody_.querySelector(".product-detail-media-large img");Array.from(this.medias_).find(function(t){return t.classList.contains("selected")}).classList.remove("selected"),o.src!==r&&(o.src=r,o.classList.remove("storyly__animate-image-horizontal"),o.classList.remove("storyly__animate-image-vertical")),e.parentElement.classList.add("selected")}},{key:"onVariantSelect_",value:function(t){var e=t.target,r=e.dataset,o=r.value,i=r.order;if(!e.classList.contains("selected")){var n="0"===i?null:this.selectedProduct_.variant[0].v,s=this.selectedProducGroup_.find(function(t){var e=t.variant.map(function(t){return t.v}),r=[n,o],s="0"===i;s&&r.shift();var a=r.filter(function(t){return t&&e.includes(t)});return s?a.length>0:a.length>1});this.onPurchase(s.product_id,!0)}}},{key:"onCheckoutToCart_",value:function(){var t=this,e=this.instanceClass,r=e.storylyCheckoutProducts;if(e.isStorylyCartActive)(0,c.createAndDispatchEvent)(this.storyDom_,(0,c.closeProductDetail)(this.instanceId)),setTimeout(function(){(0,c.createAndDispatchEvent)(t.storyDom_,"onStorylyCartOpen")},250);else{var o={group:this.group_,story_id:this.story_.story_id,alt_text:this.story_.alt_text,is_sharable:this.story_.is_sharable,products:r.products};(0,c.createAndDispatchEvent)(this.storyDom_,"onCustomerEvent",{eventName:a.CustomerEventTypes.storyCartClicked,params:o})}}},{key:"handleCTAEvent_",value:function(){var t,e=this;this.handleEvent_(a.LayerEventTypes.ActionClicked);var r=this.group_.stories.findIndex(function(t){return t.story_id===e.story_.story_id}),o={id:this.story_.story_id,title:null!==(t=this.story_.title)&&void 0!==t?t:null,seen:!0,index:r,group_id:this.group_.group_id,actionUrl:this.layerData.outlink,products:[this.selectedProduct_]};this.globalInstanceData.events.actionClicked(o)}},{key:"handleEvent_",value:function(t){var e={event_type:t,story_group_id:+this.group_.group_id,story_id:+this.story_.story_id,story_group_index:null,story_index:null,story_group_type:"default",story_interactive_x:null,story_interactive_y:null,duration:null,watch_length:null,event_time:Date.now(),products:[(0,c.productEventPayloadHandler)(y({},this.selectedProduct_))]};this.api.sendEvent(e)}}]),n}(u.default),E=exports.default=f;
|
|
262
|
-
},{"@babel/runtime/helpers/defineProperty":"IxO8","@babel/runtime/helpers/classCallCheck":"fcMS","@babel/runtime/helpers/createClass":"P8NW","@babel/runtime/helpers/inherits":"d4H2","@babel/runtime/helpers/possibleConstructorReturn":"pxk2","@babel/runtime/helpers/getPrototypeOf":"UJE0","./template":"lyP4","../../constants/events":"d0lR","../../lib/util":"PesM","../../layers/base":"skR7","../../constants/layouts":"kUgL","../LoadingSpinner":"hb2d","../Alert":"tk2H"}],"z87C":[function(require,module,exports) {
|
|
263
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=p(require("@babel/runtime/helpers/defineProperty")),e=p(require("@babel/runtime/helpers/classCallCheck")),r=p(require("@babel/runtime/helpers/createClass")),o=p(require("@babel/runtime/helpers/inherits")),i=p(require("@babel/runtime/helpers/possibleConstructorReturn")),n=p(require("@babel/runtime/helpers/getPrototypeOf")),a=require("./template"),s=require("../../constants/events"),c=require("../../lib/util"),u=p(require("../../layers/base")),l=p(require("../../constants/layouts")),d=p(require("../LoadingSpinner")),h=p(require("../Alert")),_=p(require("../../constants/availabilityStatus"));function p(t){return t&&t.__esModule?t:{default:t}}function y(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,o)}return r}function v(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?y(Object(o),!0).forEach(function(r){(0,t.default)(e,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):y(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function m(t){var e=f();return function(){var r,o=(0,n.default)(t);if(e){var a=(0,n.default)(this).constructor;r=Reflect.construct(o,arguments,a)}else r=o.apply(this,arguments);return(0,i.default)(this,r)}}function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(f=function(){return!!t})()}var E=function(t){(0,o.default)(n,t);var i=m(n);function n(t){var r,o=t.instanceId,s=t.layer,c=t.storyDom,u=t.group,l=t.story;return(0,e.default)(this,n),(r=i.call(this,{instanceId:o,storyDom:c})).group_=u,r.story_=l,r.selectedProduct_={},r.productData_=s,r.loading_=!1,r.productCheckoutFooter_=r.generateHtmlFromTemplate((0,a.ProductCheckoutFooterTemplate)(r.productData_,o)),r.setLayerData(v({},s)),r.attachCallbacksToElement_(),r}return(0,r.default)(n,[{key:"attachCallbacksToElement_",value:function(){this.eventListeners_=this.eventListeners_.bind(this),this.onPurchase=this.onPurchase.bind(this),this.onCounter_=this.onCounter_.bind(this),this.onMediaSelect_=this.onMediaSelect_.bind(this),this.onVariantSelect_=this.onVariantSelect_.bind(this),this.onAddToCart_=this.onAddToCart_.bind(this),this.renderCheckoutBottomSheetFooter_=this.renderCheckoutBottomSheetFooter_.bind(this),this.onCheckoutToCart_=this.onCheckoutToCart_.bind(this),this.onSuccess_=this.onSuccess_.bind(this),this.onError_=this.onError_.bind(this)}},{key:"eventListeners_",value:function(){var t=this;if(this.counterButton_.forEach(function(e){return(0,c.setClickEventListener)(e,t.onCounter_)}),Array.from(this.medias_).forEach(function(t){var e=t.firstElementChild;e.addEventListener("load",function(){e.style.width="".concat(e.width,"px"),e.style.opacity="1",e.parentElement.style.width="".concat(e.width,"px")},{once:!0})}),this.globalInstanceData.layout===l.default.MODERN){var e=this.productDetailBody_.querySelector(".product-detail-media-large");e.firstElementChild.addEventListener("load",function(){(0,c.imageAnimationHandler)(e,"img")})}var r=this.productCheckoutFooter_.querySelector(".continue-button"),o=this.productCheckoutFooter_.querySelector(".checkout-button");((0,c.setClickEventListener)(this.addToCartButton_,this.onAddToCart_),(0,c.setClickEventListener)(o,this.onCheckoutToCart_),(0,c.setClickEventListener)(r,function(){(0,c.createAndDispatchEvent)(t.storyDom_,(0,c.closeProductDetail)(t.instanceId))}),(0,c.isMobileView)())?(this.productDetailBody_.querySelectorAll(".product-detail-variant-row").forEach(function(e){e.addEventListener("touchstart",function(r){r.stopPropagation(),r.stopImmediatePropagation(),e.childNodes.forEach(function(e){e.addEventListener("touchend",t.onVariantSelect_)})}),e.addEventListener("scroll",function(){e.childNodes.forEach(function(e){e.removeEventListener("touchend",t.onVariantSelect_)})})}),this.productDetailBody_.parentElement.addEventListener("scroll",function(){t.variants_.forEach(function(e){e.removeEventListener("touchend",t.onVariantSelect_)})})):(this.medias_.forEach(function(e){return(0,c.setClickEventListener)(e,t.onMediaSelect_)}),this.variants_.forEach(function(e){e.addEventListener("click",t.onVariantSelect_)}))}},{key:"renderCheckoutModalFooter_",value:function(){this.productCheckoutFooter_.classList.add("modal");var t=this.productDetailFooter_.parentNode,e=this.productDetailBody_.parentNode,r=t.parentElement;r.insertBefore(this.productCheckoutFooter_,t),this.setStyle(this.productDetailBody_,"opacity","0.3"),this.setStyle(r,"maxHeight","calc(100vh * 0.65 + 50px)"),this.setStyle(e,"boxShadow","rgb(134 134 134 / 20%) 0px 7px 10.5px"),this.setStyle(e,"borderBottomLeftRadius","8px"),this.setStyle(e,"borderBottomRightRadius","8px"),this.setStyle(e,"pointerEvents","none");var o=new KeyframeEffect(t,[{opacity:1},{opacity:0,pointerEvents:"none"}],{duration:300,iterations:1,fill:"forwards"});new Animation(o).play()}},{key:"renderCheckoutBottomSheetFooter_",value:function(){var t=this.generateHtmlFromTemplate('<div style="display: none;"></div>');this.productCheckoutFooter_.classList.add("bottom-sheet"),(0,c.createAndDispatchEvent)(this.storyDom_,(0,c.openProductDetail)(this.instanceId),{body:this.productCheckoutFooter_,footer:t,rerender:!0})}},{key:"onPurchase",value:function(t,e){var r=this;this.loading_=!1;var o=this.productData_.productVariants,i=o.find(function(e){return e.product_id===t});if(this.selectedProduct_=i,"cta"!==this.layerData.cta_t){var n=this.instanceClass,u=n.isStorylyCartActive,l=n.globalInstanceData;if(u||!l.events[s.CustomerEventTypes.storyNoCartIntegration]){var d=o.filter(function(t){return t.product_group_id===i.product_group_id}).map(function(t){return v(v({},r.layerData),t)}),p=d.findIndex(function(e){return e.product_id===t});this.selectedProduct_.quantity=1,this.selectedProducGroup_=d,this.productDetailBody_=this.generateHtmlFromTemplate((0,a.ProductDetailTemplate)(d,p,this.globalInstanceData,this.instanceId));var y=d.some(function(t){return!_.default.includes(t.availability)||!!Number(t.availability)});this.medias_=this.productDetailBody_.querySelectorAll(".product-detail-media-small-container"),this.variants_=this.productDetailBody_.querySelectorAll(".product-detail-variant-row div"),this.productDetailFooter_=this.generateHtmlFromTemplate((0,a.ProductDetailFooterTemplate)(v(v({},this.productData_),i),this.globalInstanceData,this.instanceId)),this.counterButton_=this.productDetailFooter_.querySelectorAll(".counter .counter-button"),this.addToCartButton_=this.productDetailFooter_.querySelector(".product-detail-footer-action-button"),y||(this.addToCartButton_.classList.add("disabled"),this.productDetailFooter_.querySelector(".counter").style.display="none"),(0,c.createAndDispatchEvent)(this.storyDom_,(0,c.openProductDetail)(this.instanceId),{body:this.productDetailBody_,footer:this.productDetailFooter_,rerender:e}),this.handleEvent_(s.LayerEventTypes.ProductSelected,{product:i}),e||this.handleEvent_(s.LayerEventTypes.ProductSheetOpened,{product:i}),this.alert_=this.generateHtmlFromTemplate((0,h.default)({text:""}));var m=this.alert_.querySelector(".storyly__alert-box-close");(0,c.setClickEventListener)(m,function(){return r.alert_.classList.remove("active")}),this.productDetailBody_.prepend(this.alert_),this.eventListeners_(),(0,c.createAndDispatchEvent)(this.storyDom_,"onI18nEvent",{wrapperDom:this.productDetailBody_}),(0,c.createAndDispatchEvent)(this.storyDom_,"onI18nEvent",{wrapperDom:this.productDetailFooter_})}else(0,c.createAndDispatchEvent)(this.storyDom_,"onCustomerEvent",{eventName:s.CustomerEventTypes.storyNoCartIntegration,params:i})}else this.handleCTAEvent_()}},{key:"onCounter_",value:function(t){if(!this.loading_){var e=t.target.dataset,r=this.productDetailFooter_.querySelector(".counter-count"),o=Number(r.innerHTML);"plus"===e.type?(o+=1,r.innerHTML=o):o>1&&"minus"===e.type&&(o-=1,r.innerHTML=o),this.selectedProduct_.quantity=o}}},{key:"onAddToCart_",value:function(){var t,e=this;if(!this.loading_){var r={group:this.group_,story_id:this.story_.story_id,alt_text:this.story_.alt_text,is_sharable:this.story_.is_sharable,product:v({},this.selectedProduct_),product_type:s.LayerEventTypes.ProductAdded,onError:this.onError_,onSuccess:this.onSuccess_};this.timeout_=setTimeout(function(){e.onError_({message:"Something went wrong!"})},5e3),this.loading_=!0;var o=this.generateHtmlFromTemplate((0,d.default)(16));this.addToCartButtonSvg_=this.addToCartButton_.querySelector(".product-detail-footer-action-button-icon"),null===(t=this.addToCartButtonSvg_)||void 0===t||t.replaceWith(o),(0,c.createAndDispatchEvent)(this.storyDom_,"onCustomerEvent",{eventName:s.CustomerEventTypes.storyCartUpdate,params:r})}}},{key:"onSuccess_",value:function(t){var e=this;setTimeout(function(){return clearTimeout(e.timeout_)},0),this.alert_.classList.remove("active"),this.instanceClass.setProductCartItems(t),this.globalInstanceData.layout===l.default.MODERN?this.renderCheckoutModalFooter_():this.renderCheckoutBottomSheetFooter_(),(0,c.createAndDispatchEvent)(this.storyDom_,"onI18nEvent",{wrapperDom:this.productCheckoutFooter_}),this.handleEvent_(s.LayerEventTypes.ProductCartAdded)}},{key:"onError_",value:function(t){var e=this,r=t.message;setTimeout(function(){return clearTimeout(e.timeout_)},0),this.alert_.querySelector("p").innerHTML=r,this.alert_.classList.add("active"),this.loading_=!1;var o=this.addToCartButton_.querySelector(".storyly-spinner-container");null==o||o.replaceWith(this.addToCartButtonSvg_),this.handleEvent_(s.LayerEventTypes.ProductCartAddFailed)}},{key:"onMediaSelect_",value:function(t){var e=t.target,r=e.src,o=this.productDetailBody_.querySelector(".product-detail-media-large img");Array.from(this.medias_).find(function(t){return t.classList.contains("selected")}).classList.remove("selected"),o.src!==r&&(o.src=r,o.classList.remove("storyly__animate-image-horizontal"),o.classList.remove("storyly__animate-image-vertical")),e.parentElement.classList.add("selected")}},{key:"onVariantSelect_",value:function(t){var e=t.target,r=e.dataset,o=r.value,i=r.order;if(!e.classList.contains("selected")){var n="0"===i?null:this.selectedProduct_.variant[0].v,a=this.selectedProducGroup_.find(function(t){var e=t.variant.map(function(t){return t.v}),r=[n,o],a="0"===i;a&&r.shift();var s=r.filter(function(t){return t&&e.includes(t)});return a?s.length>0:s.length>1});this.onPurchase(a.product_id,!0)}}},{key:"onCheckoutToCart_",value:function(){var t=this,e=this.instanceClass,r=e.storylyCheckoutProducts;if(e.isStorylyCartActive)(0,c.createAndDispatchEvent)(this.storyDom_,(0,c.closeProductDetail)(this.instanceId)),setTimeout(function(){(0,c.createAndDispatchEvent)(t.storyDom_,"onStorylyCartOpen")},250);else{var o={group:this.group_,story_id:this.story_.story_id,alt_text:this.story_.alt_text,is_sharable:this.story_.is_sharable,products:r.products};(0,c.createAndDispatchEvent)(this.storyDom_,"onCustomerEvent",{eventName:s.CustomerEventTypes.storyCartClicked,params:o})}}},{key:"handleCTAEvent_",value:function(){var t,e=this;this.handleEvent_(s.LayerEventTypes.ActionClicked);var r=this.group_.stories.findIndex(function(t){return t.story_id===e.story_.story_id}),o={id:this.story_.story_id,title:null!==(t=this.story_.title)&&void 0!==t?t:null,seen:!0,index:r,group_id:this.group_.group_id,actionUrl:this.layerData.outlink,products:[this.selectedProduct_]};this.globalInstanceData.events.actionClicked(o)}},{key:"handleEvent_",value:function(t){var e={event_type:t,story_group_id:+this.group_.group_id,story_id:+this.story_.story_id,story_group_index:null,story_index:null,story_group_type:"default",story_interactive_x:null,story_interactive_y:null,duration:null,watch_length:null,event_time:Date.now(),products:[(0,c.productEventPayloadHandler)(v({},this.selectedProduct_))]};this.api.sendEvent(e)}}]),n}(u.default),C=exports.default=E;
|
|
264
|
+
},{"@babel/runtime/helpers/defineProperty":"IxO8","@babel/runtime/helpers/classCallCheck":"fcMS","@babel/runtime/helpers/createClass":"P8NW","@babel/runtime/helpers/inherits":"d4H2","@babel/runtime/helpers/possibleConstructorReturn":"pxk2","@babel/runtime/helpers/getPrototypeOf":"UJE0","./template":"lyP4","../../constants/events":"d0lR","../../lib/util":"PesM","../../layers/base":"skR7","../../constants/layouts":"kUgL","../LoadingSpinner":"hb2d","../Alert":"tk2H","../../constants/availabilityStatus":"A52n"}],"z87C":[function(require,module,exports) {
|
|
263
265
|
"use strict";var t=s(require("@babel/runtime/helpers/classCallCheck")),e=s(require("@babel/runtime/helpers/createClass")),r=s(require("@babel/runtime/helpers/inherits")),a=s(require("@babel/runtime/helpers/possibleConstructorReturn")),i=s(require("@babel/runtime/helpers/getPrototypeOf")),n=s(require("@babel/runtime/regenerator"));function s(t){return t&&t.__esModule?t:{default:t}}function o(t){var e=l();return function(){var r,n=(0,i.default)(t);if(e){var s=(0,i.default)(this).constructor;r=Reflect.construct(n,arguments,s)}else r=n.apply(this,arguments);return(0,a.default)(this,r)}}function l(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(l=function(){return!!t})()}var u=function(t,e,r,a){return new(r||(r=Promise))(function(i,n){function s(t){try{l(a.next(t))}catch(e){n(e)}}function o(t){try{l(a.throw(t))}catch(e){n(e)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,o)}l((a=a.apply(t,e||[])).next())})},c=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});var h=require("../../constants/layerTypes.js"),d=require("../../lib/util.js"),y=c(require("../base.js")),_=c(require("./dataConvertor.ts")),p=c(require("./template/swipe.ts")),f=c(require("./template/button.ts")),v=require("../../constants/events.js"),b=c(require("../../components/StoryProduct/index.js")),m=function(a){(0,r.default)(s,a);var i=o(s);function s(e){var r,a=e.layer,n=e.group,o=e.story,l=e.type,u=e.storyDom,c=e.instanceId;return(0,t.default)(this,s),(r=i.call(this,{type:l,storyDom:u,instanceId:c})).story_=o,r.group_=n,r.touchstartY=0,r.touchendY=0,r.setLayerData((0,_.default)(Object.assign({},a),u)),r.generateComponentAndAppendToPage(r.layerData.type===h.LayerTemplateTypes.SWIPE?(0,p.default)(r.layerData,r.globalInstanceData,c):(0,f.default)(r.layerData,r.globalInstanceData,c)).then(function(t){r.dom_=t,l===h.LayerTemplateTypes.SWIPE&&(r.dom_=t.parentElement),r.init_()}),r.attachCallbacksToElement_(),r}return(0,e.default)(s,[{key:"attachCallbacksToElement_",value:function(){this.handleClickCTA_=this.handleClickCTA_.bind(this),this.storyObserverCallback_=this.storyObserverCallback_.bind(this)}},{key:"init_",value:function(){var t=(0,d.isMobileView)();this.layerData.type===h.LayerTemplateTypes.SWIPE?(this.storyObserver_(this.storyObserverCallback_),(0,d.setClickEventListener)(this.dom_.firstElementChild,this.handleClickCTA_),t&&((0,d.stopEventBubbling)(this.dom_.firstElementChild,"touchstart"),this.handleSwipe_())):((0,d.setClickEventListener)(this.dom_,this.handleClickCTA_),t?(0,d.stopEventBubbling)(this.dom_,"touchstart"):(0,d.stopEventBubbling)(this.dom_,"click")),this.layerData.initialProduct&&(this.storyProduct_=new b.default({instanceId:this.instanceId,layer:this.layerData,storyDom:this.storyDom_,group:this.group_,story:this.story_}))}},{key:"storyObserverCallback_",value:function(t){var e=this;t.forEach(function(t){"attributes"===t.type&&"show"===t.attributeName&&e.dom_.firstElementChild.classList.toggle("animating")})}},{key:"handleClickCTA_",value:function(){var t,e;0!==this.touchstartY&&this.layerData.type===h.LayerTemplateTypes.SWIPE||(null===(t=this.storyProduct_)||void 0===t||t.onPurchase(null===(e=this.layerData.initialProduct)||void 0===e?void 0:e.product_id,!1),this.layerData.outlink&&"cta"!==this.layerData.cta_t&&this.handleClickOrSwipe_())}},{key:"handleClickOrSwipe_",value:function(){var t,e;return u(this,void 0,void 0,n.default.mark(function r(){var a,i,s,o=this;return n.default.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(this.story_.story_id&&this.group_.group_id&&this.layerData.outlink){r.next=2;break}return r.abrupt("return");case 2:a={event_type:v.LayerEventTypes.ActionClicked,story_group_id:+this.group_.group_id,story_id:+this.story_.story_id,story_group_type:"default",story_interactive_id:null,story_interactive_type:this.layerData.type,watch_length:null,event_time:Date.now(),uid:this.layerData.uid,click_url:null!==(t=this.layerData.outlink)&&void 0!==t?t:""},(this.dom_.querySelector("button")||this.dom_).blur();try{this.api.sendEvent(a)}catch(n){}if(!this.globalInstanceData.events.actionClicked){r.next=10;break}return i=this.group_.stories.findIndex(function(t){return t.story_id===o.story_.story_id}),s={id:this.story_.story_id,title:null!==(e=this.story_.title)&&void 0!==e?e:null,seen:!0,index:i,group_id:this.group_.group_id,actionUrl:this.layerData.outlink},this.globalInstanceData.events.actionClicked(s),r.abrupt("return");case 10:this.layerData.outlink&&!this.layerData.initialProduct&&(0,d.openLink)(this.layerData.outlink);case 11:case"end":return r.stop()}},r,this)}))}},{key:"handleSwipe_",value:function(){var t=this;this.dom_.parentElement.addEventListener("touchstart",function(e){e.changedTouches[0].screenY<0||(t.touchstartY=e.changedTouches[0].screenY)},!1),this.dom_.parentElement.addEventListener("touchend",function(e){t.touchendY=e.changedTouches[0].screenY,t.handleGesture_()},!1)}},{key:"handleGesture_",value:function(){this.touchstartY-this.touchendY>100&&this.handleClickOrSwipe_()}}]),s}(y.default);exports.default=m;
|
|
264
266
|
},{"@babel/runtime/helpers/classCallCheck":"fcMS","@babel/runtime/helpers/createClass":"P8NW","@babel/runtime/helpers/inherits":"d4H2","@babel/runtime/helpers/possibleConstructorReturn":"pxk2","@babel/runtime/helpers/getPrototypeOf":"UJE0","@babel/runtime/regenerator":"PMvg","../../constants/layerTypes.js":"aJRz","../../lib/util.js":"PesM","../base.js":"skR7","./dataConvertor.ts":"A6vb","./template/swipe.ts":"ddlQ","./template/button.ts":"He1W","../../constants/events.js":"d0lR","../../components/StoryProduct/index.js":"GdVG"}],"Vbpk":[function(require,module,exports) {
|
|
265
267
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=m(require("@babel/runtime/helpers/asyncToGenerator")),t=m(require("@babel/runtime/helpers/defineProperty")),s=m(require("@babel/runtime/helpers/toConsumableArray")),i=m(require("@babel/runtime/helpers/classCallCheck")),r=m(require("@babel/runtime/helpers/createClass")),o=m(require("@babel/runtime/regenerator")),a=require("../constants/layerTypes"),n=require("../lib/style"),d=require("../lib/util"),u=require("../constants/events"),l=m(require("../constants/directions")),h=require("../service"),y=m(require("../lib/proxy")),_=m(require("../components/ShareWidget")),c=m(require("../components/AudioNotification")),p=m(require("../service/HlsPlayer")),v=m(require("../layers/CTA/index.ts"));function m(e){return e&&e.__esModule?e:{default:e}}function f(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),s.push.apply(s,i)}return s}function g(e){for(var s=1;s<arguments.length;s++){var i=null!=arguments[s]?arguments[s]:{};s%2?f(Object(i),!0).forEach(function(s){(0,t.default)(e,s,i[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):f(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var b=function(){function t(e){var s=e.story,r=e.key,o=e.group,a=e.storiesContainer,u=e.groupWrapper,h=e.progressDoms,y=e.instanceId,_=e.condition;(0,i.default)(this,t),this.storyDom_=null,this.layersContainer_=document.createElement("div"),this.story_=s,this.storyData_={},this.layers_=[],this.group_=o,this.key_=r,this.storiesContainer_=a,this.groupWrapper_=u,this.progressDoms_=new Proxy(h,[]),this.storyProgressSecond_=7,this.progressPaused_=!0,this.imageAsset_=null,this.videoAsset_=null,this.videoAssetLoadingStarted_=!1,this.storyProgressRemain_=this.storyProgressSecond_,this.progressTime_=0,this.isBlankStory_=!1,this.imageAssetLoaded_=!1,this.instanceId_=y,this.timedLayers_=[],this.condition_=_,(0,n.setClass)(this.layersContainer_,"layers-container"),(0,d.setAttribute)(this.layersContainer_,"dir",l.default.LTR),this.attachCallbacksToElement_()}return(0,r.default)(t,[{key:"attachCallbacksToElement_",value:function(){this.onVideoLoadedData_=this.onVideoLoadedData_.bind(this),this.onVideoEnded_=this.onVideoEnded_.bind(this),this.onVideoWaiting_=this.onVideoWaiting_.bind(this),this.onVideoPlaying_=this.onVideoPlaying_.bind(this),this.handleSoundStory_=this.handleSoundStory_.bind(this),this.playAndPauseStory=this.playAndPauseStory.bind(this),this.handleCloseGroup_=this.handleCloseGroup_.bind(this),this.onImageLoad_=this.onImageLoad_.bind(this),this.renderShareWidget=this.renderShareWidget.bind(this),this.handleLayersVisibility_=this.handleLayersVisibility_.bind(this)}},{key:"setCustomEvents_",value:function(){this.storyDom_.addEventListener("onPlayPause",this.playAndPauseStory)}},{key:"render",value:function(e){var t=(0,d.getStoryAssetFromLayers)(this.story_.media.layers),i=t.storyData,r=t.layers,o=t.storyBg;this.storyData_=i,this.layers_=(0,s.default)(r);var a=e({story:g(g({},this.storyData_),{},{story_id:this.story_.story_id}),type:this.storyData_.type,altText:this.story_.alt_text,mediaHost:this.group_.media_host,storyBg:o});if(this.storyDom_=(0,d.generateHtmlFromTemplate)(a),this.storyDom_.appendChild(this.layersContainer_),this.condition_?0===this.key_?this.storiesContainer_.querySelectorAll(".storyly__story")[this.key_].before(this.storyDom_):this.storiesContainer_.querySelectorAll(".storyly__story")[this.key_-1].after(this.storyDom_):this.storiesContainer_.appendChild(this.storyDom_),this.loadLayers_(),"video"===this.storyData_.type)this.videoAsset_=this.storyDom_.querySelector("video"),this.handleVideoEvents_();else if(this.isBlankStory_){if(this.isBlankStory_){var u=this.storyDom_.querySelector(".story-image");(0,n.setStyle)(u,["opacity","0"])}}else this.imageAsset_=this.storyDom_.querySelector("img"),this.imageAsset_.addEventListener("load",this.onImageLoad_,{once:!0});var l=y.default.getNodeByInstanceId(this.instanceId_).getDataFromGlobal().globalInstanceData;return this.globalInstanceData=l,this.setCustomEvents_(),this.handleStoryEvent_(),Promise.resolve(this.storyDom_)}},{key:"onImageLoad_",value:function(){if(!this.imageAssetLoaded_&&(this.handleProgressBar_(),this.imageAssetLoaded_=!0,!this.storyData_.position&&!this.storyData_.sizing)){var e=this.imageAsset_,t=e.clientHeight,s=e.clientWidth;this.setStoryClassByAsset_({height:t,width:s})}}},{key:"setStoryClassByAsset_",value:function(e){var t=e.width;+(56.25*e.height/t).toFixed(2)<100&&(0,n.setClass)(this.storyDom_,"story-9_16")}},{key:"handleVideoEvents_",value:function(){this.videoAsset_.addEventListener("loadedmetadata",this.onVideoLoadedData_),this.videoAsset_.addEventListener("ended",this.onVideoEnded_),this.videoAsset_.addEventListener("waiting",this.onVideoWaiting_),this.videoAsset_.addEventListener("playing",this.onVideoPlaying_)}},{key:"onVideoLoadedData_",value:function(){var t=(0,e.default)(o.default.mark(function e(){var t;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.videoAssetLoaded_=!0,this.setStoryClassByAsset_({height:this.videoAsset_.videoHeight,width:this.videoAsset_.videoWidth}),this.storyProgressRemain_=this.videoAsset_.duration,this.storyProgressSecond_=this.videoAsset_.duration,!(this.videoAsset_.duration>=120)||(0,d.isLiveVideo)(this.storyData_.video_type)){e.next=12;break}return e.next=7,require("_bundle_loader")(require.resolve("../components/VideoSeekBar"));case 7:return e.next=9,e.sent.default;case 9:t=e.sent,this.videoSeekbar_=new t({storyDom:this.storyDom_,videoDom:this.videoAsset_,layers:this.timedLayers_,playPauseStory:this.playAndPauseStory.bind(this),setProgressTime:this.setProgressTime.bind(this),instanceId:this.instanceId_}),this.videoAsset_.addEventListener("seeking",this.handleLayersVisibility_);case 12:this.videoAsset_.addEventListener("timeupdate",this.handleLayersVisibility_);case 13:case"end":return e.stop()}},e,this)}));return function(){return t.apply(this,arguments)}}()},{key:"onVideoEnded_",value:function(){this.globalInstanceData.accessibility||(0,d.createAndDispatchEvent)(this.storyDom_,u.CustomerEventTypes.nextStory)}},{key:"onVideoWaiting_",value:function(){this.progressPaused_=!0}},{key:"onVideoPlaying_",value:function(){if(this.videoAssetLoaded_){var e=this.groupWrapper_.querySelector(".storyly__story-actions").querySelector('button[data-type="sound"]');(0,d.videoHasAudio)(this.videoAsset_)||(this.soundOn_=!1,e.classList.replace("sound-on","sound-off")),this.soundOn_?this.soundOn():this.soundOff(),this.progressPaused_=!1,this.handleProgressBar_()}}},{key:"onVideoShown_",value:function(){var t=(0,e.default)(o.default.mark(function e(){var t,s,i=this;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.videoAsset_.querySelector("source"),s=this.videoAsset_.querySelector("source").dataset.src,!(0,d.isLiveVideo)(this.storyData_.video_type)){e.next=8;break}return e.next=5,(0,p.default)({source:s,tag:this.videoAsset_,thumbnail:this.storyData_.thumbnail_url});case 5:this.hls_=e.sent,e.next=10;break;case 8:t.src=s,this.videoAsset_.load();case 10:this.videoAsset_.oncanplay=function(){i.videoPausedPromise_?i.videoPausedPromise_.then(function(){i.videoPlayedPromise_=i.videoAsset_.play()}):i.videoPlayedPromise_=i.videoAsset_.play()};case 11:case"end":return e.stop()}},e,this)}));return function(){return t.apply(this,arguments)}}()},{key:"removeEvents_",value:function(){var e=this.groupWrapper_.querySelector(".storyly__story-actions"),t=e.querySelector('button[data-type="sound"]'),s=e.querySelector('button[data-type="share"]');this.playPauseAction_&&(0,d.removeClickEventListener)(this.playPauseAction_,this.playAndPauseStory),(0,d.removeClickEventListener)(t,this.handleSoundStory_),(0,d.removeClickEventListener)(s,this.renderShareWidget)}},{key:"loadLayers_",value:function(){var t=(0,e.default)(o.default.mark(function t(){var s=this;return o.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:this.layers_.forEach(function(){var t=(0,e.default)(o.default.mark(function e(t,i){var r,n,d,u,l,h,y,_,c,p,m,f,b,A,P,S,k;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t,n={layer:g(g({},t),{},{z_index:i}),group:s.group_,story:s.story_,storyDom:s.layersContainer_,instanceId:s.instanceId_},!t.is_bg||!t.bg_color&&!t.gradient_colors){e.next=8;break}return s.isBlankStory_=!0,e.next=6,require("_bundle_loader")(require.resolve("../layers/BlankStory/index.ts"));case 6:d=e.sent.default,r.instance=new d(g({},n));case 8:if(t.type!==a.LayerTemplateTypes.EMOJI){e.next=15;break}return e.next=11,require("_bundle_loader")(require.resolve("../layers/Emoji/index.ts"));case 11:u=e.sent.default,r.instance=new u(g({},n)),e.next=108;break;case 15:if(t.type!==a.LayerTemplateTypes.POLL){e.next=22;break}return e.next=18,require("_bundle_loader")(require.resolve("../layers/Poll/index.ts"));case 18:l=e.sent.default,r.instance=new l(g({},n)),e.next=108;break;case 22:if(t.type!==a.LayerTemplateTypes.RATING){e.next=29;break}return e.next=25,require("_bundle_loader")(require.resolve("../layers/Rating/index.ts"));case 25:h=e.sent.default,r.instance=new h(g({},n)),e.next=108;break;case 29:if(t.type!==a.LayerTemplateTypes.QUIZ){e.next=36;break}return e.next=32,require("_bundle_loader")(require.resolve("../layers/Quiz/index.ts"));case 32:y=e.sent.default,r.instance=new y(g({},n)),e.next=108;break;case 36:if(t.type!==a.LayerTemplateTypes.COUNTDOWN){e.next=43;break}return e.next=39,require("_bundle_loader")(require.resolve("../layers/Countdown/index.ts"));case 39:_=e.sent.default,r.instance=new _(g({},n)),e.next=108;break;case 43:if(t.type!==a.LayerTemplateTypes.IMAGE_CTA){e.next=50;break}return e.next=46,require("_bundle_loader")(require.resolve("../layers/ImageCTA/index.ts"));case 46:c=e.sent.default,r.instance=new c(g(g({},n),{},{type:a.LayerTemplateTypes.IMAGE_CTA})),e.next=108;break;case 50:if(t.type!==a.LayerTemplateTypes.BUTTON&&t.type!==a.LayerTemplateTypes.SWIPE){e.next=54;break}r.instance=new v.default(g(g({},n),{},{type:t.type===a.LayerTemplateTypes.BUTTON?a.LayerTemplateTypes.BUTTON:a.LayerTemplateTypes.SWIPE})),e.next=108;break;case 54:if(!(t.image_path||t.video_path||t.image_url)||!t.studio_component_type){e.next=61;break}return e.next=57,require("_bundle_loader")(require.resolve("../layers/Media/index.ts"));case 57:p=e.sent.default,r.instance=new p(g(g({},n),{},{mediaHost:s.group_.media_host})),e.next=108;break;case 61:if(t.type!==a.LayerTemplateTypes.TEXT){e.next=68;break}return e.next=64,require("_bundle_loader")(require.resolve("../layers/Text/index.ts"));case 64:m=e.sent.default,r.instance=new m(g({},n)),e.next=108;break;case 68:if(t.type!==a.LayerTemplateTypes.PRODUCT_TAG){e.next=75;break}return e.next=71,require("_bundle_loader")(require.resolve("../layers/ProductTag/index.ts"));case 71:f=e.sent.default,r.instance=new f(g({},n)),e.next=108;break;case 75:if(t.type!==a.LayerTemplateTypes.PROMO_CODE){e.next=82;break}return e.next=78,require("_bundle_loader")(require.resolve("../layers/PromoCode/index.ts"));case 78:b=e.sent.default,r.instance=new b(g({},n)),e.next=108;break;case 82:if(t.type!==a.LayerTemplateTypes.QUESTION){e.next=89;break}return e.next=85,require("_bundle_loader")(require.resolve("../layers/Question/index.ts"));case 85:A=e.sent.default,r.instance=new A(g(g({},n),{},{storiesContainer:s.storiesContainer_})),e.next=108;break;case 89:if(t.type!==a.LayerTemplateTypes.PRODUCT_CARD){e.next=96;break}return e.next=92,require("_bundle_loader")(require.resolve("../layers/ProductCard/index.ts"));case 92:P=e.sent.default,r.instance=new P(g({},n)),e.next=108;break;case 96:if(t.type!==a.LayerTemplateTypes.PRODUCT_CATALOG){e.next=103;break}return e.next=99,require("_bundle_loader")(require.resolve("../layers/ProductCatalog/index.ts"));case 99:S=e.sent.default,r.instance=new S(g({},n)),e.next=108;break;case 103:if(t.type!==a.LayerTemplateTypes.IMAGE_QUIZ){e.next=108;break}return e.next=106,require("_bundle_loader")(require.resolve("../layers/ImageQuiz/index.ts"));case 106:k=e.sent.default,r.instance=new k(g({},n));case 108:(r.start_time||r.end_time)&&(r.instance.hideLayer(),s.timedLayers_.push(r));case 109:case"end":return e.stop()}},e)}));return function(e,s){return t.apply(this,arguments)}}());case 1:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"handleProgressBar_",value:function(){var e=this;if(!this.progressInterval_){this.progressCount_=0;var t=this.progressDoms_[this.key_].querySelector("span");if((0,d.isLiveVideo)(this.storyData_.video_type))return this.progressCount_=100,void(0,n.setStyle)(t,["width","".concat(this.progressCount_,"%")]);this.progressInterval_=setInterval(function(){e.progressPaused_||(e.progressTime_+=.1,e.storyProgressRemain_-=.1,e.videoAsset_?e.play():(e.handleLayersVisibility_(),e.handleProgress_()),e.progressCount_=100*e.progressTime_/e.storyProgressSecond_,e.progressCount_<=100&&(0,n.setStyle)(t,["width","".concat(e.progressCount_,"%")]))},100)}}},{key:"handleLayersVisibility_",value:function(){var e=this;if(!this.progressPaused_||this.videoAsset_){var t=1e3*(this.videoAsset_?this.videoAsset_.currentTime:this.progressTime_);this.timedLayers_.forEach(function(s){var i=s.start_time?1e3*s.start_time-300:0,r=s.end_time?1e3*s.end_time:e.videoAsset_?1e3*e.videoAsset_.duration:1e3*e.storyProgressSecond_;t>=i&&t<=r?s.instance.showLayer():s.instance.hideLayer()})}}},{key:"handleProgress_",value:function(){this.storyProgressRemain_<=0&&!this.globalInstanceData.accessibility&&((0,d.createAndDispatchEvent)(this.storyDom_,u.CustomerEventTypes.nextStory),clearInterval(this.progressInterval_))}},{key:"handleStoryActions_",value:function(){var e=this.groupWrapper_.querySelector(".storyly__story-actions"),t=e.querySelector('button[data-type="sound"]'),s=e.querySelector('button[data-type="share"]');this.playPauseAction_=e.querySelector('button[data-type="play-pause"]'),(0,d.removeAttribute)(this.playPauseAction_,"hidden"),this.playPauseAction_.classList.replace("play","pause"),(0,d.setClickEventListener)(this.playPauseAction_,this.playAndPauseStory),this.videoAsset_?((0,d.removeAttribute)(t,"hidden"),(0,d.setClickEventListener)(t,this.handleSoundStory_)):(0,d.setAttribute)(t,"hidden",!0),!this.globalInstanceData.videoMuted&&this.videoAsset_?(this.videoAsset_.muted=!1,this.soundOn_=!0,t.classList.replace("sound-off","sound-on")):this.videoAsset_&&(this.videoAsset_.muted=!0,this.soundOn_=!1,t.classList.replace("sound-on","sound-off")),this.story_.is_sharable&&((0,d.removeAttribute)(s,"hidden"),(0,d.setClickEventListener)(s,this.renderShareWidget))}},{key:"handleCloseGroup_",value:function(){(0,d.createAndDispatchEvent)(this.storyDom_,"onCloseGroup")}},{key:"handleSoundStory_",value:function(e){var t=this;if(!(0,d.videoHasAudio)(this.videoAsset_)){var s=(0,d.generateHtmlFromTemplate)(c.default);return this.storyDom_.append(s),void setTimeout(function(){t.storyDom_.removeChild(s)},1e3)}var i=e.target,r="sound-on",o="sound-off";i.classList.contains("sound-off")?((0,h.readAccessibilityText)(this.storyDom_,"Story Unmuted"),i.setAttribute("aria-pressed","false"),this.soundOn_=!0,this.soundOn(),this.globalInstanceData.videoMuted=!1):((0,h.readAccessibilityText)(this.storyDom_,"Story Muted"),i.setAttribute("aria-pressed","true"),this.soundOn_=!1,this.soundOff(),r="sound-off",o="sound-on",this.globalInstanceData.videoMuted=!0),i.classList.replace(o,r)}},{key:"exposeAccessibilityElements_",value:function(){this.storyDom_.querySelectorAll(".cta-button").forEach(function(e){(0,d.setAttribute)(e,"tabindex","21"),(0,d.setAttribute)(e,"aria-hidden","false")}),this.storyDom_.querySelectorAll(".swipe-up-button").forEach(function(e){(0,d.setAttribute)(e,"tabindex","21"),(0,d.setAttribute)(e,"aria-hidden","false")}),this.storyDom_.querySelectorAll(".product-tag-tooltip").forEach(function(e){(0,d.setAttribute)(e,"tabindex","21"),(0,d.setAttribute)(e,"aria-hidden","false")}),this.storyDom_.querySelectorAll(".poll-component").forEach(function(e){e.querySelectorAll("button").forEach(function(e){return(0,d.setAttribute)(e,"tabindex","22")}),(0,d.setAttribute)(e,"tabindex","22"),(0,d.setAttribute)(e,"aria-hidden","false")})}},{key:"hideAccessibilityElements_",value:function(){this.storyDom_.querySelectorAll(".cta-button").forEach(function(e){(0,d.removeAttribute)(e,"tabindex"),(0,d.setAttribute)(e,"aria-hidden","true")}),this.storyDom_.querySelectorAll(".swipe-up-button").forEach(function(e){(0,d.removeAttribute)(e,"tabindex"),(0,d.setAttribute)(e,"aria-hidden","true")}),this.storyDom_.querySelectorAll(".product-tag-tooltip").forEach(function(e){(0,d.removeAttribute)(e,"tabindex"),(0,d.setAttribute)(e,"aria-hidden","true")}),this.storyDom_.querySelectorAll(".poll-component").forEach(function(e){e.querySelectorAll("button").forEach(function(e){return(0,d.removeAttribute)(e,"tabindex")}),(0,d.removeAttribute)(e,"tabindex"),(0,d.setAttribute)(e,"aria-hidden","true")})}},{key:"renderShareWidget",value:function(){var t=(0,e.default)(o.default.mark(function e(){return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,_.default)({dom:this.storyDom_,group:this.group_,story:this.story_,playAndPauseStory:this.playAndPauseStory.bind(this)});case 2:this.shareWidget_=e.sent;case 3:case"end":return e.stop()}},e,this)}));return function(){return t.apply(this,arguments)}}()},{key:"soundOn",value:function(){this.videoAsset_.muted=!1}},{key:"soundOff",value:function(){this.videoAsset_.muted=!0}},{key:"pause",value:function(){var e=this;arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&this.hideShareWidget(),this.progressPaused_=!0,this.storyDom_.setAttribute("paused",""),this.videoAsset_&&(this.videoPlayedPromise_?this.videoPlayedPromise_.then(function(){e.videoPausedPromise_=e.videoAsset_.pause()}):this.videoPausedPromise_=this.videoAsset_.pause())}},{key:"play",value:function(){var e=this;arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&this.playPauseAction_.classList.contains("play")&&this.playPauseAction_.classList.replace("play","pause"),this.progressPaused_=!1,this.storyDom_.removeAttribute("paused"),this.videoAsset_&&!(0,d.isVideoPlaying)(this.videoAsset_)&&(this.videoPausedPromise_?this.videoPausedPromise_.then(function(){e.videoPlayedPromise_=e.videoAsset_.play()}):this.videoPlayedPromise_=this.videoAsset_.play())}},{key:"setVideoStoryAsset",value:function(){if(("video"===this.storyData_.type||this.story_.media.thumbnail_url)&&!(0,d.isLiveVideo)(this.storyData_.video_type)){var e=(0,d.getStoryMedia)({host:this.group_.media_host,path:this.story_.media.thumbnail_url,story:this.storyData_});(0,d.setAttribute)(this.storyDom_.querySelector("video"),"poster",e)}}},{key:"playAndPauseStory",value:function(){if(!this.globalInstanceData.accessibility){var e="play",t="pause";this.playPauseAction_.classList.contains("pause")?(this.pause(),this.playPauseAction_.setAttribute("aria-pressed","true"),(0,d.createAndDispatchEvent)(this.storyDom_,"onPlayPauseEvent",{eventType:u.EventTypes.Paused})):(this.play(),this.playPauseAction_.setAttribute("aria-pressed","false"),(0,d.createAndDispatchEvent)(this.storyDom_,"onPlayPauseEvent",{eventType:u.EventTypes.Resumed}),e="pause",t="play"),this.playPauseAction_.classList.replace(t,e)}}},{key:"sendStoryViewedEvent_",value:function(){var e=g({},this.getStoryData());(0,d.createAndDispatchEvent)(this.storyDom_,"onCustomerEvent",{eventName:u.CustomerEventTypes.storyViewed,params:e})}},{key:"handleStoryTitleOnChange_",value:function(){var e=this.story_.title;e&&(this.groupWrapper_.querySelector(".storyly__sg-info h4").textContent=e)}},{key:"handleStoryEvent_",value:function(){var e=this;this.storyDom_.addEventListener("onStoryEvent",function(t){var s,i={storyComponent:t.detail,storyGroup:g(g({},e.group_),{},{iconUrl:null!==(s=e.group_.icon_image_url)&&void 0!==s?s:e.group_.icon_video_url,icon_image_url:void 0}),story:g(g({},e.story_),{},{componentList:e.story_.media.layers,currentTime:e.getWatchLength(),media:void 0})};(0,d.createAndDispatchEvent)(e.storyDom_,"onCustomerEvent",{eventName:u.UserInteracted,params:i})})}},{key:"show",value:function(){var e,t=this;this.storyDom_.setAttribute("show",""),(0,d.createAndDispatchEvent)(this.storyDom_,"storyChange",{asset:this.isBlankStory_?"":null!==(e=this.imageAsset_)&&void 0!==e?e:this.videoAsset_}),(0,d.updateStorylyUrlParams)(this.group_.group_id,this.story_.story_id,this.globalInstanceData.shareParams),this.handleStoryActions_(),this.handleStoryTitleOnChange_(),this.progressPaused_=!1,this.storyProgressRemain_=this.storyProgressSecond_,this.progressTime_=0,(0,n.removeClass)(this.progressDoms_[this.key_],"seen"),this.videoAsset_?this.onVideoShown_():this.isBlankStory_||this.imageAssetLoaded_?this.handleProgressBar_():this.imageAsset_.style.paddingBottom="0.5px",this.globalInstanceData.accessibility&&(0,n.setStyle)(this.playPauseAction_,["display","none"]),this.exposeAccessibilityElements_(),(0,n.setClass)(this.progressDoms_[this.key_],"active"),(0,n.setClass)(this.storyDom_,"active"),setTimeout(function(){t.storyDom_.focus()},500),this.sendStoryViewedEvent_()}},{key:"hide",value:function(){var e,t=this,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=s.isBack,r=void 0!==i&&i,o=s.holdActive,a=void 0!==o&&o;if(this.storyDom_.removeAttribute("show"),this.storyDom_.hasAttribute("paused")&&this.storyDom_.removeAttribute("paused"),this.hideAccessibilityElements_(),clearInterval(this.progressInterval_),clearInterval(this.startInterval_),this.progressInterval_=null,this.startInterval_=null,this.videoAsset_){if(this.videoAsset_.currentTime=0,this.videoPlayedPromise_?this.videoPlayedPromise_.then(function(){t.videoPausedPromise_=t.videoAsset_.pause()}):this.videoPausedPromise_=this.videoAsset_.pause(),this.hls_)return void this.hls_.stopLoad();this.videoAsset_.querySelector("source").src="",this.videoAsset_.load()}this.removeEvents_(),this.progressPaused_=!0,(0,n.removeClass)(this.progressDoms_[this.key_],"active"),a||(0,n.removeClass)(this.storyDom_,"active"),(0,n.resetStyle)(this.progressDoms_[this.key_].querySelector("span"),["width"]),r?(0,n.removeClass)(this.progressDoms_[this.key_],"seen"):(0,n.setClass)(this.progressDoms_[this.key_],"seen"),null===(e=this.shareWidget_)||void 0===e||e.hide(),this.timedLayers_.forEach(function(e){return e.instance.hideLayer()})}},{key:"getWatchLength",value:function(){var e=this.storyProgressRemain_<0?0:Math.round(this.storyProgressRemain_);return 1e3*(Math.round(this.storyProgressSecond_)-e)}},{key:"getProgressPausedStatus",value:function(){return this.progressPaused_}},{key:"getStoryData",value:function(){var e=(0,d.getStoryMedia)({host:this.group_.media_host,story:this.storyData_});return{story_id:this.story_.story_id,media:e,group:this.group_,index:this.key_}}},{key:"sendStoryClickedEvent",value:function(e){var t=g({},this.getStoryData());(0,d.createAndDispatchEvent)(this.storyDom_,"onCustomerEvent",{eventName:"next"===e?"CustomerEventTypes.nextStory":u.CustomerEventTypes.previousStory,params:t})}},{key:"setKey",value:function(e){this.key_=e}},{key:"setProgressTime",value:function(e){this.progressTime_=+e.toFixed(1)}},{key:"pauseByTouch",value:function(){this.pause(),(0,n.setStyle)(this.storiesContainer_.querySelector(".storyly__story-header"),["opacity",0])}},{key:"playAfterTouch",value:function(){(0,n.setStyle)(this.storiesContainer_.querySelector(".storyly__story-header"),["opacity",1]),this.play()}},{key:"hideShareWidget",value:function(){this.shareWidget_&&this.shareWidget_.hide()}}]),t}(),A=exports.default=b;
|