@letscooee/web-sdk 13.1.10 → 13.1.11
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/chunk-7XDM4HDH.js +1 -0
- package/dist/{chunk-VOVXCOBB.js → chunk-BJ5UBWZZ.js} +1 -1
- package/dist/{chunk-2AHALCF3.js → chunk-CFZOV3EF.js} +1 -1
- package/dist/chunk-GIEYLCFF.js +4 -0
- package/dist/chunk-JAIJ74CO.js +39 -0
- package/dist/chunk-MHKDPBHM.js +8 -0
- package/dist/{chunk-LW7ZESZN.js → chunk-Z7UUW7XD.js} +2 -2
- package/dist/{chunk-Y3BMMUFH.js → chunk-ZFMH37WK.js} +1 -1
- package/dist/{debugger.component-G4NYQU2M.js → debugger.component-UQRQT3KM.js} +1 -1
- package/dist/main.min.js +4 -4
- package/dist/renderer-7THALERZ.js +1 -0
- package/dist/sdk-debug-logs-PG5BE6E3.js +1 -0
- package/dist/{share-dialog.component-HDMDNACD.js → share-dialog.component-OXWTLKYG.js} +1 -1
- package/dist/video-detail-dialog.component-E4FB7GMC.js +2 -0
- package/dist/widget.min.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-ALW6N5YB.js +0 -1
- package/dist/chunk-DTWV2VE6.js +0 -4
- package/dist/chunk-K3NDUCRB.js +0 -39
- package/dist/chunk-PC4YRNPG.js +0 -8
- package/dist/renderer-X5CF2PGG.js +0 -1
- package/dist/sdk-debug-logs-OECRZKTM.js +0 -1
- package/dist/video-detail-dialog.component-YQZ6AMST.js +0 -2
package/dist/chunk-PC4YRNPG.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{e as A,g as R}from"./chunk-U4XWPFUW.js";var D=A((V,T)=>{"use strict";(function(t){"use strict";var e={};e.VERSION="1.6.1";var s,f={},E=function(o,r){return function(){return r.apply(o,arguments)}},h=function(){var o=arguments,r=o[0],u,n;for(n=1;n<o.length;n++)for(u in o[n])!(u in r)&&o[n].hasOwnProperty(u)&&(r[u]=o[n][u]);return r},g=function(o,r){return{value:o,name:r}};e.TRACE=g(1,"TRACE"),e.DEBUG=g(2,"DEBUG"),e.INFO=g(3,"INFO"),e.TIME=g(4,"TIME"),e.WARN=g(5,"WARN"),e.ERROR=g(8,"ERROR"),e.OFF=g(99,"OFF");var m=function(o){this.context=o,this.setLevel(o.filterLevel),this.log=this.info};m.prototype={setLevel:function(o){o&&"value"in o&&(this.context.filterLevel=o)},getLevel:function(){return this.context.filterLevel},enabledFor:function(o){var r=this.context.filterLevel;return o.value>=r.value},trace:function(){this.invoke(e.TRACE,arguments)},debug:function(){this.invoke(e.DEBUG,arguments)},info:function(){this.invoke(e.INFO,arguments)},warn:function(){this.invoke(e.WARN,arguments)},error:function(){this.invoke(e.ERROR,arguments)},time:function(o){typeof o=="string"&&o.length>0&&this.invoke(e.TIME,[o,"start"])},timeEnd:function(o){typeof o=="string"&&o.length>0&&this.invoke(e.TIME,[o,"end"])},invoke:function(o,r){s&&this.enabledFor(o)&&s(r,h({level:o},this.context))}};var i=new m({filterLevel:e.OFF});(function(){var o=e;o.enabledFor=E(i,i.enabledFor),o.trace=E(i,i.trace),o.debug=E(i,i.debug),o.time=E(i,i.time),o.timeEnd=E(i,i.timeEnd),o.info=E(i,i.info),o.warn=E(i,i.warn),o.error=E(i,i.error),o.log=o.info})(),e.setHandler=function(o){s=o},e.setLevel=function(o){i.setLevel(o);for(var r in f)f.hasOwnProperty(r)&&f[r].setLevel(o)},e.getLevel=function(){return i.getLevel()},e.get=function(o){return f[o]||(f[o]=new m(h({name:o},i.context)))},e.createDefaultHandler=function(o){o=o||{},o.formatter=o.formatter||function(l,c){c.name&&l.unshift("["+c.name+"]")};var r={},u=function(n,l){Function.prototype.apply.call(n,console,l)};return typeof console>"u"?function(){}:function(n,l){n=Array.prototype.slice.call(n);var c=console.log,d;l.level===e.TIME?(d=(l.name?"["+l.name+"] ":"")+n[0],n[1]==="start"?console.time?console.time(d):r[d]=new Date().getTime():console.timeEnd?console.timeEnd(d):u(c,[d+": "+(new Date().getTime()-r[d])+"ms"])):(l.level===e.WARN&&console.warn?c=console.warn:l.level===e.ERROR&&console.error?c=console.error:l.level===e.INFO&&console.info?c=console.info:l.level===e.DEBUG&&console.debug?c=console.debug:l.level===e.TRACE&&console.trace&&(c=console.trace),o.formatter(n,l),u(c,n))}},e.useDefaults=function(o){e.setLevel(o&&o.defaultLevel||e.DEBUG),e.setHandler(e.createDefaultHandler(o))},e.setDefaults=e.useDefaults,typeof define=="function"&&define.amd?define(e):typeof T<"u"&&T.exports?T.exports=e:(e._prevLogger=t.Logger,e.noConflict=function(){return t.Logger=e._prevLogger,e},t.Logger=e)})(V)});var _="13.1.10";var w=_.split("-")[0].split(".").slice(0,3).map(t=>t.padStart(2,"0")).join(""),M="WEB",N="CooeeSDK",p=_,U=parseInt(w,10);var P=["collection","product","cart"],x=[{identifier:"#flo-checkout-wrapper",gateway:"Shopflow"},{identifier:"#fastrr-main-container",gateway:"Shiprocket"},{identifier:"#gokwik-modal-wrapper",gateway:"Gokwik"},{identifier:"#zecpe",gateway:"Ecom 360"}],F=["View Item","View Cart","View Collection"],G=["CE Screen View","View Collection","View Item","View Cart"],L="https://cdn.jsdelivr.net/npm/swiper@11";var v=`https://cdn.jsdelivr.net/npm/@letscooee/web-sdk@${p}/dist`,C={apiURL:"https://api.sdk.letscooee.com",debug:!1,mode:"production",baseURL:v,styleURL:`${v}/widget.min.css`,widgetURL:`${v}/widget.min.js`,swiperStyleURL:`${L}/swiper-bundle.min.css`};var a=R(D());var I=class{static debuggerEl;static infoLogs=[];static log(...e){a.default.info(...e)}static verbose(...e){a.default.debug(...e)}static error(...e){a.default.error(...e)}static warn(...e){a.default.warn(...e)}static info(...e){a.default.info(...e),this.infoLogs.push({time:new Date,message:e.join(" ")}),this.addToDebugger()}static trace(...e){a.default.trace(...e)}static addToDebugger(){sessionStorage.cooeeDebug&&(this.debuggerEl=this.debuggerEl??document.querySelector("cooee-debugger"),this.debuggerEl&&this.debuggerEl&&(this.debuggerEl.logs=[...this.infoLogs]))}};function $(t=N){a.default.useDefaults({formatter:function(e){e.unshift(`${t} (v${p}):`)}}),O()&&(localStorage.cooeeLogLevel="TRACE"),localStorage.cooeeLogLevel?a.default.setLevel(a.default[localStorage.cooeeLogLevel]):a.default.setLevel(C.debug?a.default.TRACE:a.default.OFF)}function O(){let t=y();return t==="1"||t==="on"}function y(){return new URL(location.href).searchParams?.get("cooee-debug")}function Y(){let t=["display: inline-block;","font-size: 14px;","background: linear-gradient(90deg, #d52dc8 25%, #2179e2 82%);","color: white;","padding: 4px;","border-radius: 4px;"].join(" "),e=`
|
|
2
|
-
`;e+=`\u{1F4E3} Drive higher conversions with AI-powered onsite engagement
|
|
3
|
-
`,e+=`\u{1F50D} Track real-time visitor intent & optimize engagement
|
|
4
|
-
`,e+=`\u{1F4CA} Improve Meta Ads ROAS with intent-driven campaigns
|
|
5
|
-
`,e+=`\u{1F6CD}\uFE0F Boost purchases & repeat sales effortlessly
|
|
6
|
-
`,e+=`
|
|
7
|
-
|
|
8
|
-
`,e+="Learn more: https://www.letscooee.com",console.group("%c Elevate your ecommerce experience with Cooee \u{1F680} ",t),console.log(`%c${e}`,"font-size: 13px; line-height: 1.8;"),console.log(`SDK v${p}`),console.groupEnd(),I.info(`SDK v${p} loaded`)}function q(t){if(t<0)return`${t}ms`;let e=new Date(Date.UTC(0,0,0,0,0,0,t)),s=[];return e.getUTCMinutes()&&s.push(e.getUTCMinutes()+"m"),e.getUTCSeconds()&&s.push(e.getUTCSeconds()+"s"),e.getUTCMilliseconds()&&s.push(e.getUTCMilliseconds()+"ms"),s.length||s.push("0ms"),s.join(" ")}export{M as a,p as b,U as c,P as d,x as e,F as f,G as g,L as h,C as i,D as j,I as k,$ as l,O as m,y as n,Y as o,q as p};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as U,Aa as re,Ba as ie,Ea as ne,Ha as x,M as z,S as $,T as W,U as Y,V as K,W as X,X as j,Y as Z,Z as J,_ as q,b as O,fa as Q,ga as ee,h as d,ha as C,k as F,l as N,o as _,u as G,ua as k,va as g,w as V,wa as i,xa as te}from"./chunk-K3NDUCRB.js";import{e as B,k as m}from"./chunk-PC4YRNPG.js";import{a as s,b as y}from"./chunk-U4XWPFUW.js";var L=class{loadedFonts=[];async loadAllFonts(e){e.elems?.forEach(t=>{t instanceof Y&&this.loadFamily(t.typography?.fam)})}async loadFamily(e){if(!e?.fonts||this.loadedFonts.indexOf(e.name)>-1)return;let t=[];e.fonts.forEach(n=>{if(n.url){let l=new FontFace("cooee"+e.name,n.getURL(),n.getFontDescriptor());t.push(l.load())}}),this.loadedFonts.push(e.name),(await Promise.all(t)).forEach(n=>{document.fonts.add(n)})}};var S=class{static updateIdentity(e){if(!this.isInstalled())return;let t={};e.email&&(t.email=e.email),e.mobile&&(t.phone_number=e.mobile),m.verbose("Sending email/mobile to Klaviyo"),window.klaviyo.push(["identify",t])}static isInstalled(){return window.klaviyo&&typeof window.klaviyo=="object"}};var H=class{action;triggerContext;constructor(e,t){this.action=e,this.triggerContext=t}async execute(){let e=this.containsCTA()?"CE Trigger Clicked":"CE Trigger Closed";switch(this.action.at!==d.SUBMIT_FORM&&await this.closeTriggerAndSendEvent(e),this.action.at){case d.ACCEPT_POPUP:break;case d.GO_TO_URL:this.gotoURLAction();break;case d.SHARE:this.shareAction();break;case d.SUBMIT_FORM:await this.collectFormData();break;case void 0:case d.OPEN_CART:break;default:m.error("Received an invalid ClickActionType: ",this.action.at);return}}externalAction(){this.action.ext?.u&&window.open(this.action.ext.u,"_blank")?.focus()}gotoURLAction(){if(this.action.gu?.u){let e=this.action.gu.u;V(e)||(e=`//${e}`),window.open(e,"_self")}}async closeTriggerAndSendEvent(e,t){this.triggerContext.closeInApp(e,t),await this.dispatchEvent()}shareAction(){if(!this.action.share)return;if(!navigator.share){m.warn("Navigator.share is not compatible with this browser");return}navigator.share({text:this.action.share.text,title:"Share"}).then(t=>console.log(t)).catch(t=>console.error(t))}containsCTA(){return this.action.at&&this.action.at!==d.REJECT_POPUP?!0:!(this.isEmpty(this.action.custKV)&&this.isEmpty(this.action.up))}isEmpty(e){return e?Object.keys(e).length===0:!0}async collectFormData(){let e={};for(let t of this.triggerContext.inputs){if(!t.isValid)return;let n=document.getElementById(t.id).value;t.type===51?e.email=n:t.type===52&&(e.mobile=n)}await this.closeTriggerAndSendEvent("CE Form Submitted",{form:e}),this.action.applyDiscount&&U("Coupon applied on cart"),S.updateIdentity(e)}async dispatchEvent(){let e=this.triggerContext.triggerData,t={clickAction:this.action,items:this.triggerContext.selectedEmbeddedItems??e.embeddedItems??e.items,collections:e.collections,triggerData:e};await new ne().process(t);let r={action:this.containsCTA()?"CLICKED":"CLOSED"};document.dispatchEvent(new CustomEvent("letscooee:outbound:popup-activities",{detail:r}))}};var a=class{renderer=I.get();parentHTMLEl;inappElement;inappHTMLEl;triggerContext;stylesConverter;scalingFactor;constructor(e,t,r){this.parentHTMLEl=e,this.inappElement=t,this.triggerContext=r,this.stylesConverter=new ie(this.renderer.getScalingFactor())}getHTMLElement(){return this.inappHTMLEl}insertElement(){this.parentHTMLEl.appendChild(this.inappHTMLEl)}processCommonBlocks(){this.processWidthAndHeight(),this.processPositionBlock(),this.processTransformBlock(),this.processTransparency(),this.processShadow(),this.registerAction();let e=y(s(s(s(s({},this.getDisplayStyles()),this.getSpaceStyles()),this.getBorderStyles()),this.getBackgroundStyles()),{boxSizing:"border-box",outline:"none"});g(this.inappHTMLEl,e)}getDisplayStyles(){return{display:"block"}}processWidthAndHeight(){this.inappElement.w&&i(this.inappHTMLEl,"width",this.stylesConverter.getSizePx(this.inappElement.w)),this.inappElement.h&&i(this.inappHTMLEl,"height",this.stylesConverter.getSizePx(this.inappElement.h))}processPositionBlock(){let e={position:"absolute",left:this.stylesConverter.getSizePx(this.inappElement.x),top:this.stylesConverter.getSizePx(this.inappElement.y)};g(this.inappHTMLEl,e)}getBorderStyles(){return this.stylesConverter.getBorderStyles(this.inappElement.br)}getSpaceStyles(){return this.stylesConverter.getSpaceStyles(this.inappElement.spc)}processTransparency(){let e=this.inappElement.alpha;if(!isNaN(e)){let t=(e/100).toFixed(2);i(this.inappHTMLEl,"opacity",t)}}processShadow(){let e=this.inappElement.shd;e?i(this.inappHTMLEl,"box-shadow",e.getStyle(this.scalingFactor)):i(this.inappHTMLEl,"box-shadow","unset")}processTransformBlock(){let e=new F(this.inappElement.trf);e&&e.rotate&&i(this.inappHTMLEl,"transform",`rotate(${e.rotate}deg)`)}registerAction(){let e=this.inappElement.clc;!e||Object.keys(e).length===0||(this.inappHTMLEl.addEventListener("click",t=>{t.stopPropagation(),new H(e,this.triggerContext).execute()}),i(this.inappHTMLEl,"cursor","pointer"))}getBackgroundStyles(){return this.stylesConverter.getBackgroundStyles(this.inappElement.bg)}};var p=class extends a{constructor(e,t,r){super(e,t,r)}processCommonBlocks(){super.processCommonBlocks(),this.processFontBlock(),this.processAlignment()}processFontBlock(){let e={},t=this.inappElement.typography;return t&&(e.fontSize=this.stylesConverter.getSizePx(t.fs),e.fontFamily="cooee"+t.fam?.name,e.lineHeight=`${t.lh}`,e.letterSpacing=t.letterSpacing),this.stylesConverter.getColourStyles(this.inappElement.color,"color",e),g(this.inappHTMLEl,e),e}processPart(e,t){let r=[];t.u&&r.push("underline"),t.st&&r.push("line-through"),r.length||r.push("normal"),i(e,"font-weight",t.b?"bold":"normal"),i(e,"font-style",t.i?"italic":"normal"),i(e,"text-decoration",r.join(" ")),i(e,"color",t.c??"inherit"),i(e,"font-family","inherit")}processAlignment(){let e=this.inappElement.typography.ta,t=e?N[e]?.toLowerCase():this.inappElement.typography.alignment;t||(t="start"),i(this.inappHTMLEl,"text-align",t)}};var u=class extends p{constructor(e,t,r){super(e,t,r),this.inappHTMLEl=document.createElement("div"),this.insertElement()}render(){this.inappElement.parts?.forEach(e=>{let t=document.createElement("span");t.innerHTML=e.txt?.toString()?.replace(/\n/g,"<br />"),this.processPart(t,e),this.inappHTMLEl.appendChild(t)}),this.processCommonBlocks()}};var f=class extends a{constructor(e,t,r){super(e,t,r),this.inappHTMLEl=document.createElement("div"),this.insertElement()}render(){this.processCommonBlocks()}};var E=class extends a{constructor(e,t,r){super(e,t,r),this.inappHTMLEl=document.createElement("img"),this.insertElement()}render(){this.inappHTMLEl.setAttribute("src",this.inappElement.src),i(this.inappHTMLEl,"max-width","none"),i(this.inappHTMLEl,"max-height","none"),i(this.inappHTMLEl,"margin","0 auto"),this.processCommonBlocks()}};var v=class o extends a{constructor(t,r,n){super(t,r,n);this.parent=t;this.inappHTMLEl=document.createElement("div")}static MAX_Z_INDEX="2147483647";render(){return this.parent||this.renderer.removeInApp(),this.insertElement(),this.processCommonBlocks(),this.inappHTMLEl.classList.add("cooee-wrapper"),this.inappHTMLEl.classList.add(this.triggerContext.rootClassName),i(this.inappHTMLEl,"z-index",o.MAX_Z_INDEX),this.inappHTMLEl}getBackgroundStyles(){return this.inappElement.cover?super.getBackgroundStyles():{}}processWidthAndHeight(){let t=this.inappElement.cont;if(this.inappElement.cover)this.renderer.isParentNotBody()?(i(this.inappHTMLEl,"width","100%"),i(this.inappHTMLEl,"height","100%")):(i(this.inappHTMLEl,"width","100vw"),i(this.inappHTMLEl,"height","100vh")),i(this.inappHTMLEl,"top","0"),i(this.inappHTMLEl,"left","0");else{let r=this.inappElement.spc,n=this.stylesConverter.getScaledSize(t.w)+r.getHorizontal(),l=this.stylesConverter.getScaledSize(t.h)+r.getVertical();i(this.inappHTMLEl,"width",n+"px"),i(this.inappHTMLEl,"height",l+"px")}}getSpaceStyles(){return{padding:this.inappElement.spc.getPaddingCSS()}}getDisplayStyles(){return s(s({display:"flex"},this.inappElement.getStylesForWrapper()),this.inappElement.getFlexStylesForContainer())}processPositionBlock(){this.renderer.isParentNotBody()?i(this.inappHTMLEl,"position","absolute"):i(this.inappHTMLEl,"position","fixed")}getBorderStyles(){return{}}processTransparency(){}processTransformBlock(){}processShadow(){}};var se="cooee-container",w=class extends a{constructor(e,t,r){super(e,t,r),this.inappHTMLEl=document.createElement("div"),this.insertElement()}render(){return this.processCommonBlocks(),i(this.inappHTMLEl,"position","relative"),i(this.inappHTMLEl,"overflow","hidden"),this.inappHTMLEl.classList.add(se),this}};var A=class o extends p{static DAYS="Days";static HOURS="Hours";static MINUTES="Minutes";static SECONDS="Seconds";elements;spans=[];constructor(e,t,r){super(e,t,r),this.inappHTMLEl=document.createElement("div"),this.insertElement()}render(){this.addTimerChildren(),this.processAndStartTimer(),this.processCommonBlocks();let e=y(s(s(s({flex:"1 1 0"},this.stylesConverter.getBackgroundStyles(this.inappElement.bg)),this.stylesConverter.getBorderStyles(this.inappElement.br)),this.stylesConverter.getSpaceStyles(this.inappElement.spc)),{marginLeft:this.stylesConverter.getSizePx(this.inappElement.gap),marginRight:this.stylesConverter.getSizePx(this.inappElement.gap)});this.addStylesToTimer(e)}getBackgroundStyles(){return{}}processFontBlock(){let e=super.processFontBlock();return this.stylesConverter.getColourStyles(this.inappElement.color,"color",e),this.addStylesToTimer(e),e}getSpaceStyles(){return{}}getBorderStyles(){return{}}getDisplayStyles(){return{display:"flex",flexWrap:"nowrap",justifyContent:"center"}}addStylesToTimer(e){this.elements.forEach(t=>g(t,e))}addTimerChildren(){let e=this.inappElement.show;this.elements=[],e.day&&this.elements.push(this.getChild(o.DAYS)),e.hour&&this.elements.push(this.getChild(o.HOURS)),e.minute&&this.elements.push(this.getChild(o.MINUTES)),e.second&&this.elements.push(this.getChild(o.SECONDS)),this.elements.forEach(t=>this.inappHTMLEl.appendChild(t))}getChild(e){let t=document.createElement("div"),r=document.createElement("span"),n=document.createElement("span");return n.innerText=e,r.innerText="00",r.id=`lc-${e}`,i(n,"font-size","0.5em"),i(n,"text-align","center"),i(n,"font-family","inherit"),i(r,"text-align","center"),i(r,"font-family","inherit"),this.inappElement.lblPos==="start"?(t.appendChild(n),t.appendChild(r)):(t.appendChild(r),t.appendChild(n)),i(t,"display","flex"),i(t,"flex-direction",this.inappElement.horizontal?"":"column"),i(t,"justify-content","center"),i(t,"align-items","center"),i(t,"gap","5px"),this.spans.push(r),t}processAndStartTimer(){let e=this.inappElement.timer.start(this.inappElement.timerType,t=>{this.spans.forEach(r=>{r.id===`lc-${o.DAYS}`?r.innerText=String(t.days).padStart(2,"0"):r.id===`lc-${o.HOURS}`?r.innerText=String(t.hours).padStart(2,"0"):r.id===`lc-${o.MINUTES}`?r.innerText=String(t.minutes).padStart(2,"0"):r.id===`lc-${o.SECONDS}`&&(r.innerText=String(t.seconds).padStart(2,"0"))})});this.triggerContext.intervals.push(e)}};var b=class extends p{constructor(e,t,r){super(e,t,r),this.inappHTMLEl=document.createElement("select"),this.insertElement()}render(){i(this.inappHTMLEl,"background","#ffffff00"),i(this.inappHTMLEl,"outline","none"),this.processCommonBlocks(),this.addListener(this.inappHTMLEl),this.addOptions()}addListener(e){this.triggerContext.selectedEmbeddedItems?.length||this.updateItems(this.triggerContext.triggerData.items[0].vars[0]),e.addEventListener("click",t=>{t.stopPropagation()}),e.addEventListener("change",()=>{let t=new z(JSON.parse(e.value));this.updateItems(t)})}updateItems(e){let t=this.triggerContext.triggerData.items[0];this.triggerContext.selectedEmbeddedItems=[t.toEmbed(e)];let r=this.parentHTMLEl.querySelector("#coo-13");if(!r)return;let n=e.imgs[0]??t.imgs?.at(0);n?.url&&r.setAttribute("src",n.url)}addOptions(){let e=this.triggerContext.triggerData.items,t=this.inappHTMLEl;if(!e?.length){t.add(this.createOption(this.inappElement.placeholderText));return}let r=this.triggerContext.selectedEmbeddedItems?.at(0);e[0].vars.forEach(n=>{t.add(this.createOption(n.name??"Default",n,n.mID===r?.vID))})}createOption(e,t,r){let n=document.createElement("option");return n.text=e,n.value=JSON.stringify(t),r&&(n.selected=!0),t||(n.disabled=!0),n}};var T=class extends p{borderColor="";constructor(e,t,r){super(e,t,r),this.inappHTMLEl=document.createElement("input"),this.insertElement()}render(){let e=this.setInputType();this.inappHTMLEl.setAttribute("placeholder",this.inappElement.placeholderText),i(this.inappHTMLEl,"background","#ffffff00"),i(this.inappHTMLEl,"outline","none"),this.inappHTMLEl.addEventListener("click",t=>{t.stopPropagation()}),this.processCommonBlocks(),this.addListener(this.inappHTMLEl,e),this.triggerContext.addInputField(e,this.inappElement.t)}};var R=class o extends T{static EMAIL_REGEX=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;constructor(e,t,r){super(e,t,r)}setInputType(){let e=`coo-${this.inappElement.t}`;return this.inappHTMLEl.setAttribute("type","email"),this.inappHTMLEl.setAttribute("id",e),e}addListener(e,t){e.addEventListener("keydown",r=>{this.borderColor||(this.borderColor=this.inappHTMLEl.style.borderColor),e.value.match(o.EMAIL_REGEX)?(i(this.inappHTMLEl,"border-color",this.borderColor),this.triggerContext.updateValidation(t,!0)):(i(this.inappHTMLEl,"border-color","red"),this.triggerContext.updateValidation(t,!1)),r.stopPropagation()})}};var D=class o extends T{static MOBILE_REGEX=/^\d+$/;constructor(e,t,r){super(e,t,r)}setInputType(){let e=`coo-${this.inappElement.t}`;return this.inappHTMLEl.setAttribute("type","tel"),this.inappHTMLEl.setAttribute("id",e),e}addListener(e,t){e.addEventListener("keydown",r=>{this.borderColor||(this.borderColor=this.inappHTMLEl.style.borderColor),e.value.match(o.MOBILE_REGEX)?(i(this.inappHTMLEl,"border-color",this.borderColor),this.triggerContext.updateValidation(t,!0)):(i(this.inappHTMLEl,"border-color","red"),this.triggerContext.updateValidation(t,!1)),r.stopPropagation()})}};var P=class extends E{constructor(e,t,r){super(e,t,r)}render(){super.render(),this.inappHTMLEl.setAttribute("id",`coo-${this.inappElement.type}`)}};var I=class o{static DOCUMENT_STANDARD_MODE="CSS1Compat";static ACTIVE_TRIGGER_DATA;static _instance;parent;rootContainer;containerHTMLElement;ian;scalingFactor=1;triggerContext;resizeListener;cartDrawerToggleSubscription;constructor(e){this.resizeListener=()=>this.screenResized(),this.setParentContainer(e)}static get(){return o._instance}render(e){this.renderEngagement(new Q(e))}getScalingFactor(){return this.scalingFactor}calculateScalingFactor(e){let t=e.max,r=e.cont.w,n=e.cont.h,l=e.spc,c=this.getWidth(),h=this.getHeight();t&&(c=c?Math.min(c,t):t,h=h?Math.min(h,t):t),h&&(c-=l.getHorizontal(),h-=l.getVertical(),c/h<r/n?this.scalingFactor=c/r:this.scalingFactor=h/n,this.scalingFactor=Math.min(this.scalingFactor,1))}setParentContainer(e){this.parent=e||document.body,this.isParentNotBody()&&i(this.parent,"position","relative")}isParentNotBody(){return this.parent&&this.parent!==document.body}getWidth(){return this.isParentNotBody()?this.parent.clientWidth:document.compatMode===o.DOCUMENT_STANDARD_MODE?document.documentElement.clientWidth:window.innerWidth}getHeight(){return this.isParentNotBody()?this.parent.clientHeight:document.compatMode===o.DOCUMENT_STANDARD_MODE?document.documentElement.clientHeight:window.innerHeight}async renderEngagement(e){this.triggerContext=new _(new Date,e),this.triggerContext.onClose(t=>{this.closeInApp(t)}),this.ian=e.ian,(k()||e.previewType==="mobile")&&this.ian.overrideForMobileView(),await this.preloadImages(e),e.shouldDelay()?window.setTimeout(()=>{this.withCartDrawerClosed()},e.getDelaySeconds()):this.withCartDrawerClosed()}withCartDrawerClosed(){if(!re.get().isOpen()){this.startRenderingOnce();return}this.cartDrawerToggleSubscription=window.CooeeSDK.cartDrawerToggle$.subscribe(({open:t})=>{!t&&this.startRenderingOnce()})}startRenderingOnce(){if(!this.shouldSkipCampaign()){o.ACTIVE_TRIGGER_DATA=this.triggerContext.triggerData,o._instance=this;try{this.startRendering()}catch(e){G(e,"render-popup",{triggerContext:this.triggerContext});return}this.sendTriggerDisplayed(),k()||window.addEventListener("resize",this.resizeListener),this.cartDrawerToggleSubscription?.unsubscribe()}}shouldSkipCampaign(){let e=this.triggerContext.triggerData;if(!e.previewType&&o.ACTIVE_TRIGGER_DATA){let r={triggerShown:new ee(o.ACTIVE_TRIGGER_DATA??{})};return this.skipTrigger(e,r),!0}if(O().isGoKwikPopupOpen)return this.skipTrigger(e,{reason:"GoKwik popup is open"}),!0;let t=B.find(r=>!!document.querySelector(r.identifier));return t?(this.skipTrigger(e,{reason:`${t.gateway} modal is open`}),!0):!1}startRendering(){this.calculateScalingFactor(this.ian),this.rootContainer=new v(this.parent,this.ian,this.triggerContext).render();try{this.renderContainer(this.triggerContext)}catch(e){throw m.error(e),e}}sendTriggerDisplayed(){let e={};this.triggerContext.triggerData.items?.length&&(e.promotedMIDs=this.triggerContext.triggerData.items?.map(n=>n.mID));let t=new C("CE Trigger Displayed",e,this.triggerContext.triggerData);x(t);let r={action:"DISPLAYED"};document.dispatchEvent(new CustomEvent("letscooee:outbound:popup-activities",{detail:r}))}sendTriggerClosed(e){let t=e.eventName;delete e.eventName;let r=new C(t,e,this.triggerContext.triggerData);r.name==="CE Trigger Clicked"&&(r.items=this.triggerContext.selectedEmbeddedItems??this.triggerContext.triggerData.items?.map(n=>n.toEmbed())),x(r)}addEnterAnimation(e){this.containerHTMLElement.animate(e.getEnterAnimation(),{duration:500})}renderElement(e,t,r){t instanceof Z?new R(e,t,r).render():t instanceof J?new D(e,t,r).render():t instanceof K?new u(e,t,r).render():t instanceof q?new P(e,t,r).render():t instanceof W?new E(e,t,r).render():t instanceof $?new f(e,t,r).render():t instanceof X?new A(e,t,r).render():t instanceof j?new b(e,t,r).render():m.error("Unsupported element type- "+t.type)}renderContainer(e){let t=this.ian?.cont;t&&(this.containerHTMLElement=new w(this.rootContainer,t,e).render().getHTMLElement(),new L().loadAllFonts(this.ian),this.ian.elems?.forEach(async r=>{await this.renderElement(this.containerHTMLElement,r,e)}),this.addEnterAnimation(this.ian.anim))}closeInApp(e){let t=this.ian.anim.getExitAnimation();this.sendTriggerClosed(e),o.ACTIVE_TRIGGER_DATA=void 0;let r=this.containerHTMLElement.animate(t,{duration:500,easing:"ease-in-out"});r.onfinish=()=>{this.removeInApp(),window.removeEventListener("resize",this.resizeListener)}}screenResized(){this.removeInApp(),this.startRendering()}removeInApp(){let e=document.querySelector(`.${this.triggerContext.rootClassName}`);e&&e.parentElement.removeChild(e)}skipTrigger(e,t){let r=new C("CE Campaign Rejected",t,e);x(r)}async preloadImages(e){let t=e.ian;if(!t)return;let r=[];t.elems.forEach(n=>{let l=n.bg?.img?.src;if(l&&r.push(l),n.t===1){let c=n.src;if(!c)return;r.push(c)}}),t.bg?.img?.src&&r.push(t.bg.img.src),t.cont.bg?.img?.src&&r.push(t.cont.bg.img.src),await Promise.all(r.map(n=>te(n)))}};export{I as FreeformRenderer};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{k as n,m as D,p as i}from"./chunk-PC4YRNPG.js";import"./chunk-U4XWPFUW.js";var m="\xA0\xA0\xA0",z=["/v1/engagement/cart-widgets","/v1/engagement/page-widgets","/v1/event/validate-session"];function g(e){if(e===0)return"0 B";let o=1024,t=["B","KB","MB","GB"],a=Math.floor(Math.log(e)/Math.log(o));return`${(e/Math.pow(o,a)).toFixed(2)} ${t[a]}`}function E(e){let o=performance.getEntriesByType?.("resource");if(o)return o.filter(t=>t.name.includes(e)).pop()}function P(e,o){if(!e){n.info(`\u{1F4E6} API Resource Metrics for ${o}: Not available`);return}n.info("\u{1F4E6} \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 API Resource Metrics \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),n.info(`URL: ${o}`),n.info(`Duration: ${i(e.duration)}`);let t=e.transferSize===0;if(n.info(`Served from: ${t?"\u{1F4BE} Cache (disk/memory)":"\u{1F310} Network"}`),!t){n.info(`Transfer size: ${g(e.transferSize)}`),n.info(`Encoded size: ${g(e.encodedBodySize)}`),n.info(`Decoded size: ${g(e.decodedBodySize)}`);let s=(1-e.encodedBodySize/e.decodedBodySize)*100;s>0&&n.info(`Compression ratio: ${s.toFixed(1)}%`)}let a=e.redirectEnd-e.redirectStart,c=e.fetchStart-e.startTime,r=e.domainLookupEnd-e.domainLookupStart,d=e.connectEnd-e.connectStart,u=e.secureConnectionStart>0?e.connectEnd-e.secureConnectionStart:0,S=e.connectEnd===e.connectStart?e.requestStart-e.fetchStart-r:e.requestStart-e.connectEnd,T=e.responseStart-e.requestStart,v=e.responseEnd-e.responseStart;n.info(`Timing breakdown (${i(e.duration)} total):`),a>0&&n.info(`${m}Redirect: ${i(a)}`),c>0&&n.info(`${m}Queued: ${i(c)}`),S>0&&n.info(`${m}Stalled: ${i(S)}`),r>0&&n.info(`${m}DNS lookup: ${i(r)}`),d>0&&n.info(`${m}TCP connect: ${i(d)}`),u>0&&n.info(`${m}SSL handshake: ${i(u)}`),n.info(`${m}Server waiting (TTFB): ${i(T)}`),n.info(`${m}Content download: ${i(v)}`);let $=e.serverTiming;if($?.length){n.info("Server-Timing:");for(let s of $){let l=s.description||s.name;s.duration>0?n.info(`${m}${l}: ${i(s.duration)}`):n.info(`${m}${l}: ${s.duration}`)}}n.info("\u{1F4E6} \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550")}function w(){let e=new Set;for(let t of z){let a=E(t);a?P(a,t):e.add(t)}if(!e.size||typeof PerformanceObserver>"u")return;let o=new PerformanceObserver(t=>{for(let a of t.getEntries())for(let c of e)if(a.name.includes(c)){P(a,c),e.delete(c);break}e.size||o.disconnect()});o.observe({type:"resource",buffered:!1})}function f(e){return e?new Date(e).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,hour12:!1,timeZoneName:"short"}):"N/A"}function N(){let e=performance.getEntriesByType?.("resource");if(e)return e.find(o=>o.name.includes("@letscooee/web-sdk")&&o.name.includes("main.min.js"))}function q(e){window.cooeeSDKPreview||!D()||(document.readyState==="complete"?setTimeout(()=>L(e),100):window.addEventListener("load",()=>{setTimeout(()=>L(e),100)}))}function L(e){try{C(e),w()}catch(o){console.error("Failed to print debugging logs",o)}}function C(e){let o=performance.getEntriesByType?.("navigation")?.[0],t=window.CooeeSDK?.pageLoadTime,a=N(),c=performance.timeOrigin||0,r=o?.responseEnd?c+o.responseEnd:void 0,d=c,u=o?.domContentLoadedEventEnd||0,p=o?.loadEventEnd||0,S=r&&r>0?r:t?t.getTime():0,T=r&&r>0?"HTML download complete":"inline script execution",v=u>0?d+u:void 0,$=p>0?d+p:void 0;n.info("\u23F1\uFE0F \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 Performance Timing Report \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),n.info("\u{1F4C5} Absolute Timestamps (Local Time):"),n.info(" Note: Inline script can execute during HTML download (incremental parsing)"),n.info(""),n.info(` 1. Navigation started: ${f(d)}`);let s=t?t.getTime():0;if(r&&r>0&&s?s<r?(n.info(` 2. Inline script executed: ${f(s)} (during HTML parsing)`),n.info(` 3. HTML download complete: ${f(r)}`)):(n.info(` 2. HTML download complete: ${f(r)}`),n.info(` 3. Inline script executed: ${f(s)}`)):r&&r>0?n.info(` 2. HTML download complete: ${f(r)}`):s&&n.info(` 2. Inline script executed: ${f(s)}`),n.info(` 4. SDK module loaded: ${f(e.getTime())} (from CDN)`),v&&n.info(` 5. DOMContentLoaded: ${f(v)}`),$&&n.info(` 6. Page fully loaded: ${f($)}`),n.info(""),n.info("\u23F1\uFE0F Relative Timings:"),r&&r>0&&d){let l=r-d;n.info(` Shopify backend + HTML download: ${i(l)} (not Cooee SDK)`)}if(S){let l=e.getTime()-S;if(l<0){let h=s>0?s:d,B=s>0?"inline script execution":"navigation start",M=e.getTime()-h;n.info(` SDK module load time: ${i(M)} after ${B}`),n.info(` (Note: Using earlier baseline because SDK loaded before ${T})`)}else n.info(` SDK module load time: ${i(l)} after ${T}`),n.info(` (Baseline: ${T} at ${f(S)})`);let b=e.getTime()-d;n.info(` \u{1F3AF} Total SDK load time: ${i(b)} (from navigation start to SDK ready)`)}u&&u>0&&n.info(` DOMContentLoaded: ${i(u)} after navigation start`),p&&p>0&&n.info(` Page fully loaded: ${i(p)} after navigation start`),R(a),n.info("\u23F1\uFE0F \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550")}function R(e){if(!e){n.info(""),n.info("\u{1F4E6} SDK Resource Metrics: Not available");return}n.info(""),n.info("\u{1F4E6} SDK Resource Metrics:"),n.info(` URL: ${e.name}`),n.info(` Download duration: ${i(e.duration)}`);let o=e.transferSize===0;if(n.info(` Served from: ${o?"\u{1F4BE} Cache (disk/memory)":"\u{1F310} Network"}`),!o){n.info(` Transfer size: ${g(e.transferSize)}`),n.info(` Encoded size: ${g(e.encodedBodySize)}`),n.info(` Decoded size: ${g(e.decodedBodySize)}`);let t=(1-e.encodedBodySize/e.decodedBodySize)*100;t>0&&n.info(` Compression ratio: ${t.toFixed(1)}%`)}if(e.domainLookupEnd>0){let t=e.domainLookupEnd-e.domainLookupStart,a=e.connectEnd-e.connectStart,c=e.responseStart-e.requestStart,r=e.responseEnd-e.responseStart;n.info(" Timing breakdown:"),t>0&&n.info(` DNS lookup: ${i(t)}`),a>0&&n.info(` TCP connect: ${i(a)}`),c>0&&n.info(` Request: ${i(c)}`),r>0&&n.info(` Response: ${i(r)}`)}}export{q as printAllDebugLogs};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as ue,l as be,o as _e,p as Ce,q as ye,r as xe,s as De,t as Ve,u as Ie}from"./chunk-LW7ZESZN.js";import{a as Ee,b as Te}from"./chunk-VOVXCOBB.js";import{a as ge,b as P,c as j,d as he,e as ve,f as fe,g as M}from"./chunk-2AHALCF3.js";import{b as U,h as k,i as we}from"./chunk-ALW6N5YB.js";import{Ba as h,Cb as me,Da as s,E as _,Ga as F,Ha as B,I as K,Ia as H,L as G,La as V,M as Q,Ma as S,O as d,Ta as ie,Ua as oe,V as q,Va as ne,X as y,Za as re,ba as E,fb as se,ha as T,ia as x,ib as ae,ja as D,jb as de,kb as le,la as Y,ma as $,na as L,oa as u,pa as l,qa as a,ra as w,sa as J,sb as ce,ta as X,ua as Z,ub as pe,v,va as ee,wa as te,x as p,xa as A,y as m,za as C}from"./chunk-DTWV2VE6.js";import"./chunk-U4XWPFUW.js";var I="a-f\\d",Me=`#?[${I}]{3}[${I}]?`,Oe=`#?[${I}]{6}([${I}]{2})?`,Ne=new RegExp(`[^#${I}]`,"gi"),Re=new RegExp(`^${Me}$|^${Oe}$`,"i");function W(i,e={}){if(typeof i!="string"||Ne.test(i)||!Re.test(i))throw new TypeError("Expected a valid hex string");i=i.replace(/^#/,"");let t=1;i.length===8&&(t=Number.parseInt(i.slice(6,8),16)/255,i=i.slice(0,6)),i.length===4&&(t=Number.parseInt(i.slice(3,4).repeat(2),16)/255,i=i.slice(0,3)),i.length===3&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]);let o=Number.parseInt(i,16),n=o>>16,r=o>>8&255,f=o&255,b=typeof e.alpha=="number"?e.alpha:t;if(e.format==="array")return[n,r,f,b];if(e.format==="css"){let g=b===1?"":` / ${Number((b*100).toFixed(2))}%`;return`rgb(${n} ${r} ${f}${g})`}return{red:n,green:r,blue:f,alpha:b}}var c=class{h;a=100;g;constructor(e){e??={},this.h=e.h,this.a=e.a,this.g=e.g}get hex(){return this.h}get grad(){return this.g}get rgba(){if(!this.hex)return"";try{return W(this.hex,{format:"css",alpha:this.getAlpha()})}catch(e){return console.error("Invalid hex",e),"#000000"}}getAlpha(){return(this.a??100)/100}};var O=class i{static DEFAULT_FALLBACK=new c({h:"#000000",a:50});r;c;fb;constructor(e){this.r=e.r,e.c&&(this.c=new c(e.c)),e.fb&&(this.fb=new c(e.fb))}get radius(){return this.r}get color(){return this.c}get fallback(){return this.fb??i.DEFAULT_FALLBACK}};var N=class{size;enabled;color;constructor(e){e??={},this.enabled=e.enabled,this.size=e.size,this.color=new c(e.color)}};var R=class i{video=le.required();progress=_(0);constructor(){ae(e=>{let t=this.video(),o=()=>{this.progress.set(t.currentTime/t.duration*100)};t.addEventListener("timeupdate",o),e(()=>{t.removeEventListener("timeupdate",o)})})}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=y({type:i,selectors:[["cooee-video-progress-bar"]],inputs:{video:[1,"video"]},decls:3,vars:3,consts:[[1,"video-untracked-path"],["role","progressbar",1,"video-tracked-path"]],template:function(t,o){t&1&&(J(0,"div",0)(1,"div",1),Z(2,"div"),X()()),t&2&&(d(),S("width",o.progress(),"%"),T("aria-valuenow",o.progress()))},styles:["[_nghost-%COMP%]{display:block;width:100%;position:absolute;z-index:10;top:4px;padding-inline:8px;box-sizing:border-box}.video-untracked-path[_ngcontent-%COMP%], .video-tracked-path[_ngcontent-%COMP%]{height:4px;border-radius:var(--lc-video-progress-bar-radius)}.video-untracked-path[_ngcontent-%COMP%]{background-color:rgba(var(--lc-video-progress-bar-bg-color));width:100%;margin-bottom:2px}.video-tracked-path[_ngcontent-%COMP%]{background-color:rgba(var(--lc-video-progress-bar-color));transition:width .5s ease-in-out}@media (prefers-reduced-motion: reduce){.video-tracked-path[_ngcontent-%COMP%]{transition:none}}"]})};var z=class i{dialogState=de();dialog=v(fe);triggerData=v(ge)().triggerData;eventData=v(P);containerRef=v(q);async share(e){e.stopPropagation(),e.preventDefault(),k()&&we()?await this.shareNative():await this.shareWithDialog()}async shareNative(){let e=Te(this.triggerData,this.eventData.video,!1);await navigator.share(e),Ee(this.triggerData,this.eventData.video,this.eventData.index,"Native")}async shareWithDialog(){let e=await import("./share-dialog.component-HDMDNACD.js");this.dialogState.emit(!0),this.dialog.open(e.ShareDialogComponent,{viewContainerRef:this.containerRef}).closed.subscribe(()=>this.dialogState.emit(!1))}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=y({type:i,selectors:[["cooee-share-button"]],outputs:{dialogState:"dialogState"},decls:2,vars:0,consts:[["type","button","aria-label","Share video",3,"click"],["name","share"]],template:function(t,o){t&1&&(l(0,"button",0),h("click",function(r){return o.share(r)}),w(1,"cooee-icon",1),a())},dependencies:[M],styles:["button[_ngcontent-%COMP%]{width:var(--lc-icon-button-size, 44px);height:var(--lc-icon-button-size, 44px);display:flex;justify-content:center;align-items:center;border:none;border-radius:100%;background:#00000080;background:color-mix(in oklab,#000 50%,transparent)}button[_ngcontent-%COMP%] cooee-icon[name=share][_ngcontent-%COMP%]{color:#fff}"]})};var ze=["swiperComp"],$e=["videoEl"],Le=(i,e)=>e.url;function Ae(i,e){i&1&&(l(0,"div",11),w(1,"div",15),a())}function Fe(i,e){if(i&1&&w(0,"source",13),i&2){let t=e.$implicit;u("type",re(t.mimeType))("src",t.url,G)}}function Be(i,e){i&1&&A(0)}function He(i,e){if(i&1){let t=C();l(0,"cooee-video-promoted-items",24),h("cardClick",function(n){p(t);let r=s(2).$implicit,f=s();return m(f.productCardClicked(n,r))}),a()}if(i&2){let t=s(2).$implicit;u("items",t.items)}}function je(i,e){if(i&1&&w(0,"cooee-video-card",23),i&2){let t=s(2).$implicit;u("card",t.card)}}function Ue(i,e){if(i&1){let t=C();w(0,"cooee-video-progress-bar",16),l(1,"div",17)(2,"cooee-mute-toggle",18),ne("mutedChange",function(n){p(t);let r=s(2);return oe(r.muted,n)||(r.muted=n),m(n)}),h("toggled",function(){p(t);let n=s(2);return m(n.muteToggled())}),a(),E(3,Be,1,0,"ng-container",8),a(),l(4,"div",19)(5,"cooee-share-button",20),h("dialogState",function(n){p(t);let r=s(2);return m(r.shareDialogOpen.set(n))}),a()(),l(6,"div",21),x(7,He,1,1,"cooee-video-promoted-items",22)(8,je,1,1,"cooee-video-card",23),a()}if(i&2){let t=s().$implicit,o=V(5),n=s(),r=V(9);u("video",o),d(2),ie("muted",n.muted),u("videoEl",o),d(),u("ngTemplateOutlet",r),d(4),D(t.items.length&&n.videoConfig.showItems()?7:t.card&&n.videoConfig.footerContent===n.VideoConfigFooterContent.CARD?8:-1)}}function We(i,e){if(i&1){let t=C();l(0,"cooee-item-detail",25),h("closeClick",function(){p(t);let n=s(2);return m(n.productModalClosed())}),a()}if(i&2){let t=s(2);u("item",t.selectedItem)("similarItems",t.selectedVideo.items)("template",t.videoConfig.itemDetailConfig.template)}}function Ke(i,e){if(i&1){let t=C();l(0,"div",6)(1,"div",9)(2,"div",10),x(3,Ae,2,0,"div",11),l(4,"video",12,2),h("click",function(){let n=p(t).$index,r=s();return m(r.currentIndex===n&&r.toggleMute())})("ended",function(){p(t);let n=V(5),r=s();return m(r.onVideoEnded(n))})("loadstart",function(){let n=p(t).$index,r=s();return m(r.onVideoLoadStart(n))})("canplay",function(){let n=p(t).$index,r=s();return m(r.onVideoCanPlay(n))}),$(6,Fe,1,3,"source",13,Le),a(),x(8,Ue,9,5),a(),x(9,We,1,3,"cooee-item-detail",14),a()()}if(i&2){let t=e.$implicit,o=e.$index,n=s();d(2),S("background-image",t.thumbnail?"url("+t.thumbnail+")":null),d(),D(n.shouldShowVideoSpinner(o)?3:-1),d(),u("ngClass",n.viewTemplateClassName)("muted",!0),T("preload",n.isVideoVisible(o)?"metadata":"none")("data-video-id",t.id)("autoplay",null),d(2),L(t.sources),d(2),D(n.currentIndex===o?8:-1),d(),D(n.selectedItem&&n.currentIndex===o?9:-1)}}function Ge(i,e){i&1&&A(0)}function Qe(i,e){if(i&1){let t=C();l(0,"button",26),h("click",function(){p(t);let n=s();return m(n.close())}),w(1,"cooee-icon",27),a()}}var ke=class i{swiperComponent;videoElements;VideoConfigFooterContent=_e;currentIndex=0;muted=_(!1);selectedItem=null;selectedVideo;detailPopupTemplate;viewTemplateClassName="lc-video-only-view";shareDialogOpen=_(!1);data=v(ve);elementRef=v(K);eventData=v(P);dialogRef=v(he);swiperInitialized=_(!1);swiperOptions=_(null);videos=[];videoConfig;triggerContext;engagementTrigger;isMobile=k();navigationConfig;cssLoadedPromise;resizeDebouncer=new be(this.onResize.bind(this));videoLoadingStates=new Map;constructor(){this.videos=this.data.videos,this.currentIndex=this.data.currentIndex,this.selectedItem=this.data.selectedItem??null,this.selectedVideo=this.videos[this.currentIndex],this.triggerContext=this.data.triggerContext,this.engagementTrigger=this.triggerContext.triggerData,this.videoConfig=this.engagementTrigger?.content?.videoConfig??new Ce,this.navigationConfig=new N({enabled:!0,size:50,color:new c({h:"#000000"})}),this.cssLoadedPromise=ue(this.elementRef.nativeElement.shadowRoot)}onKeyDown(e){e.preventDefault(),e.stopPropagation(),this.close()}async ngOnInit(){switch(this.muted.set(await U.get("muted",!1)),this.videoConfig.detailPopup.template){case"PRODUCT_DETAIL_VIEW":this.selectItemForDetailView(),this.viewTemplateClassName="lc-product-detail-view";break;case"VIDEO_ONLY_VIEW":this.viewTemplateClassName="lc-video-only-view";break}}ngAfterViewInit(){this.initializeSwiperWithVideoDimensions()}ngOnDestroy(){this.resizeDebouncer?.destroy()}initializeSwiperWithVideoDimensions(){this.applyOptimalVideoDimensions(),this.initSwiperOptions(),this.playActiveVideo(!1)}close(){let e=this.getCurrentVideoElement();this.dialogRef.close({lastVideo:this.videos[this.currentIndex],lastVideoIndex:this.currentIndex,lastVideoDuration:e?.currentTime})}getCurrentVideoElement(){return this.videoElements.get(this.currentIndex)?.nativeElement}moveToNextVideo(){this.swiperComponent.swiper.slideTo(this.currentIndex+1)}productModalClosed(){this.selectedItem=null}pauseAll(){this.videoElements.forEach(e=>e.nativeElement.pause())}toggleMute(){this.muted.update(e=>!e)}async muteToggled(){await U.set("muted",this.muted());let t=[this.muted()?"CE Video Muted":"CE Video Unmuted",{current:this.currentVideoProps()},{triggerData:this.engagementTrigger}];window.CooeeSDK.events.push(t)}playActiveVideo(e=!0){e&&this.pauseAll();let t=this.getCurrentVideoElement();t&&this.playVideo(t)}playVideo(e){e.currentTime=0,e.play().catch(t=>me.error(t))}onVideoEnded(e){if(this.currentIndex<this.videos.length-1)this.selectedItem||this.shareDialogOpen()?this.playVideo(e):this.moveToNextVideo();else{let t=this.getPreviousVideoDataForEvent(),o=["CE Last Video Ended",{previous:t},{triggerData:this.engagementTrigger}];window.CooeeSDK.events.push(o),this.playVideo(e)}}onSlideChange(e){let t=this.getPreviousVideoDataForEvent();this.currentIndex=e.realIndex,this.selectedVideo=this.videos[this.currentIndex],this.eventData.video=this.selectedVideo,this.eventData.index=this.currentIndex,this.playActiveVideo(),this.isProductDetailView()?this.selectItemForDetailView():this.selectedItem=null;let o=this.currentVideoProps(),n={previous:t,current:o},r=new j("CE Video Changed",n,this.engagementTrigger);r.setVideos(this.videos[this.currentIndex]),window.CooeeSDK.sendEvent(r)}productCardClicked(e,t){let o={videoID:t.id,videoIndex:this.currentIndex},n=new j("CE More Item Info Clicked",{current:o},this.engagementTrigger);n.setVideos(t),window.CooeeSDK.sendEvent(n),this.selectedItem=e}onVideoLoadStart(e){this.videoLoadingStates.set(e,!0)}onVideoCanPlay(e){this.videoLoadingStates.set(e,!1)}shouldShowVideoSpinner(e){return this.swiperInitialized()?this.videoLoadingStates.get(e)===!0&&this.isVideoVisible(e):this.isVideoVisible(e)}isVideoVisible(e){let t=this.currentIndex-1,o=this.currentIndex+1;return e===this.currentIndex||e===t||e===o}async initSwiperOptions(){await this.cssLoadedPromise;let e=this.isMobile?1:"auto",t=0;this.isProductDetailView()&&(e="auto",t=10),this.swiperOptions.set({direction:this.isMobile?"vertical":"horizontal",effect:this.isMobile?"slide":"coverflow",slidesPerView:e,initialSlide:this.currentIndex,centeredSlides:!0,spaceBetween:t,coverflowEffect:{rotate:0,stretch:0,depth:400,modifier:1,slideShadows:!1},on:{init:o=>{this.swiperInitialized.set(!0),setTimeout(()=>{o.update()},100)}},mousewheel:{enabled:!this.isMobile,invert:!1,thresholdDelta:20}})}isProductDetailView(){return this.videoConfig.detailPopup.template==="PRODUCT_DETAIL_VIEW"}currentVideoProps(){return{videoID:this.videos[this.currentIndex].id,videoIndex:this.currentIndex}}getPreviousVideoDataForEvent(){let e=this.currentVideoProps(),t=this.videoElements.find(n=>n.nativeElement.dataset.videoId===this.videos[this.currentIndex].id)?.nativeElement;e.playedTillMS=Math.ceil(t?.currentTime*1e3);let o=t?.duration*1e3;return e.playedTillPercent=+(e.playedTillMS/o).toFixed(4),e}selectItemForDetailView(){this.selectedItem=this.isMobile?null:this.selectedVideo?.items?.[0]??null}applyOptimalVideoDimensions(){if(this.isMobile||this.isProductDetailView())return;let e=this.calculateOptimalVideoDimensions();e&&this.setVideoContainerDimensions(e.width,e.height)}calculateOptimalVideoDimensions(){let e=this.videos.map(g=>g.sources?.[0]).filter(g=>g?.width&&g?.height).map(g=>({width:g.width,height:g.height,aspectRatio:g.width/g.height}));if(e.length===0)return null;let t=e[0],o=window.innerWidth*.9,n=window.innerHeight*.9,r=o/t.width,f=n/t.height,b=Math.min(r,f);return{width:Math.floor(t.width*b),height:Math.floor(t.height*b)}}setVideoContainerDimensions(e,t){let o=this.elementRef.nativeElement;o.style.setProperty("--video-container-width",`${e}px`),o.style.setProperty("--video-container-height",`${t}px`)}onResize(){this.applyOptimalVideoDimensions()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=y({type:i,selectors:[["cooee-video-detail-dialog"]],viewQuery:function(t,o){if(t&1&&(F(ze,7),F($e,5)),t&2){let n;B(n=H())&&(o.swiperComponent=n.first),B(n=H())&&(o.videoElements=n)}},hostAttrs:[1,"letscooee-widget"],hostBindings:function(t,o){t&1&&h("keydown.escape",function(r){return o.onKeyDown(r)},Q)},decls:10,vars:4,consts:[["swiperComp",""],["closeButtonTemplate",""],["videoEl",""],[1,"lc-shadow-inner",3,"ngClass"],[1,"video-swiper",3,"slideChange","options","navigationConfig"],["ngProjectAs","swiper-slides",5,["swiper-slides"]],[1,"swiper-slide","video-slide"],[1,"lc-desktop-controls"],[4,"ngTemplateOutlet"],[1,"lc-video-modal-row"],[1,"lc-video-container"],[1,"video-loading-overlay"],["playsinline","",1,"lc-video-el",3,"click","ended","loadstart","canplay","ngClass","muted"],[3,"src","type"],[1,"swiper-no-swiping","swiper-no-mousewheel",3,"item","similarItems","template"],[1,"loading-spinner"],[3,"video"],[1,"lc-video-controls"],[3,"mutedChange","toggled","muted","videoEl"],[1,"share-controls"],[3,"dialogState"],[1,"lc-card-container"],[3,"items"],[3,"card"],[3,"cardClick","items"],[1,"swiper-no-swiping","swiper-no-mousewheel",3,"closeClick","item","similarItems","template"],["type","button","aria-label","Close",1,"lc-close-button",3,"click"],["name","close","aria-hidden","true"]],template:function(t,o){if(t&1){let n=C();l(0,"div",3)(1,"cooee-swiper",4,0),h("slideChange",function(f){return p(n),m(o.onSlideChange(f))}),ee(3,5),$(4,Ke,10,10,"div",6,Y),te(),a(),l(6,"div",7),E(7,Ge,1,0,"ng-container",8),a()(),E(8,Qe,2,0,"ng-template",null,1,se)}if(t&2){let n=V(9);u("ngClass",o.viewTemplateClassName),d(),u("options",o.swiperOptions())("navigationConfig",o.navigationConfig),d(3),L(o.videos),d(3),u("ngTemplateOutlet",n)}},dependencies:[Ie,ye,Ve,z,R,pe,ce,De,xe,M],styles:[`:host{display:flex}.lc-shadow-inner{position:relative;width:100vw;height:100vh;display:flex}@media (min-width: 768px){.lc-shadow-inner{background-color:color-mix(in oklab,#000 70%,transparent);justify-content:center;align-items:center}}.video-swiper{--swiper-navigation-size: 50px;--swiper-navigation-color: white;width:100dvw;height:100dvh}.lc-product-detail-view .video-swiper{align-items:center}@media (min-width: 768px){.video-swiper{width:100%;height:100%;max-width:90vw;max-height:90vh}}.video-swiper>.swiper-wrapper{max-height:100%;pointer-events:none}.lc-product-detail-view .video-swiper>.swiper-wrapper{align-items:center}@media (max-width: 768px){.video-swiper>.swiper-button-prev{display:none!important}}@media (max-width: 768px){.video-swiper>.swiper-button-next{display:var(--lc-next-video-button-display)!important;width:var(--lc-icon-button-size, 44px);height:var(--lc-icon-button-size, 44px);display:flex;justify-content:center;align-items:center;border:none;border-radius:100%;background:#00000080;background:color-mix(in oklab,#000 50%,transparent);color:#fff;inset:auto auto 12px 50%;transform:translate(-50%) rotate(90deg)}.video-swiper>.swiper-button-next:after{color:#fff;font-weight:900}}.video-swiper:has(cooee-item-detail)>.swiper-button-next{display:none!important}.video-slide{position:relative;display:flex;align-items:center;visibility:hidden;pointer-events:auto}.lc-product-detail-view .video-slide{width:40vw!important;height:70vh!important}@media (min-width: 768px){.lc-product-detail-view .video-slide{min-width:650px!important}}@media (max-width: 768px){.lc-product-detail-view .video-slide{width:100%!important;height:100%!important}}@media (min-width: 768px){.lc-video-only-view .video-slide{width:fit-content!important}}@media (min-width: 768px){.video-slide{border-radius:var(--lc-media-radius);overflow:hidden}}.video-slide.swiper-slide-active,.video-slide.swiper-slide-prev,.video-slide.swiper-slide-next{visibility:visible}video{width:100%;height:100%;object-fit:cover;position:relative;z-index:3}.lc-desktop-controls{position:absolute;top:2rem;right:4rem;z-index:10;display:flex;gap:.5rem}@media (max-width: 768px){.lc-desktop-controls{display:none}}.lc-video-controls{position:absolute;top:1rem;z-index:10;right:.5rem;display:flex;gap:.25rem}@media (min-width: 768px){.lc-video-controls .lc-close-button{display:none}}.share-controls{position:absolute;bottom:30%;right:.5rem;z-index:10;display:flex;gap:.25rem;flex-direction:column;justify-content:center;align-items:center}.lc-close-button{width:var(--lc-icon-button-size, 44px);height:var(--lc-icon-button-size, 44px);display:flex;justify-content:center;align-items:center;border:none;border-radius:100%;background:#00000080;background:color-mix(in oklab,#000 50%,transparent)}.lc-video-container{position:relative;height:100%;width:100%;background:#000000b3 no-repeat center;background-size:cover}@media (min-width: 768px){.lc-product-detail-view .lc-video-container{width:50%}}@media (min-width: 768px){.lc-video-only-view .lc-video-container{width:var(--video-container-width, 100%);height:var(--video-container-height, 100%)}}.lc-card-container{position:absolute;bottom:12px;z-index:10;width:100%;padding-inline:12px;box-sizing:border-box}.lc-product-detail-view .lc-card-container{display:none}@media (max-width: 768px){.lc-product-detail-view .lc-card-container{display:block}}.lc-product-detail-view .lc-video-modal-row{display:flex;justify-content:center;height:100%;width:100%}.lc-video-only-view .lc-video-modal-row{display:block;height:100%}.lc-product-detail-view cooee-item-detail{--header-display: none;width:50%;flex:1}@media (max-width: 768px){.lc-product-detail-view cooee-item-detail{--header-display: flex;width:100%;height:70dvh;position:absolute;bottom:0;z-index:2147483646}}.lc-video-only-view cooee-item-detail{width:100%;height:70dvh;z-index:2147483646;bottom:0;position:absolute;border-radius:var(--lc-card-radius) var(--lc-card-radius) 0 0}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.video-loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;background-color:#0000004d;z-index:2}.video-loading-overlay .loading-spinner{width:30px;height:30px;border:3px solid rgba(255,255,255,.3);border-top:3px solid #fff;border-radius:50%;animation:spin 1s linear infinite}
|
|
2
|
-
`],encapsulation:3})};export{ke as VideoDetailDialogComponent};
|