@commversion/libs 0.17.10 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
var lcChannelWidgets=function(m){"use strict";var Fe=Object.defineProperty,je=Object.defineProperties;var Ge=Object.getOwnPropertyDescriptors;var de=Object.getOwnPropertySymbols;var Xe=Object.prototype.hasOwnProperty,Ye=Object.prototype.propertyIsEnumerable;var ue=(m,g,v)=>g in m?Fe(m,g,{enumerable:!0,configurable:!0,writable:!0,value:v}):m[g]=v,L=(m,g)=>{for(var v in g||(g={}))Xe.call(g,v)&&ue(m,v,g[v]);if(de)for(var v of de(g))Ye.call(g,v)&&ue(m,v,g[v]);return m},he=(m,g)=>je(m,Ge(g));const fe={whatsapp:{label:"WhatsApp",icon:'<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd" viewBox="0 0 509 511.514"><path fill="#fff" d="M434.762 74.334C387.553 26.81 323.245 0 256.236 0h-.768C115.795.001 2.121 113.696 2.121 253.456l.001.015a253.516 253.516 0 0033.942 126.671L0 511.514l134.373-35.269a253.416 253.416 0 00121.052 30.9h.003.053C395.472 507.145 509 393.616 509 253.626c0-67.225-26.742-131.727-74.252-179.237l.014-.055zM255.555 464.453c-37.753 0-74.861-10.22-107.293-29.479l-7.72-4.602-79.741 20.889 21.207-77.726-4.984-7.975c-21.147-33.606-32.415-72.584-32.415-112.308 0-116.371 94.372-210.743 210.741-210.743 56.011 0 109.758 22.307 149.277 61.98a210.93 210.93 0 0161.744 149.095c0 116.44-94.403 210.869-210.844 210.869h.028zm115.583-157.914c-6.363-3.202-37.474-18.472-43.243-20.593-5.769-2.121-10.01-3.202-14.315 3.203-4.305 6.404-16.373 20.593-20.063 24.855-3.69 4.263-7.401 4.815-13.679 1.612-6.278-3.202-26.786-9.883-50.899-31.472a192.748 192.748 0 01-35.411-43.867c-3.712-6.363-.404-9.777 2.82-12.873 3.224-3.096 6.363-7.381 9.48-11.092a41.58 41.58 0 006.357-10.597 11.678 11.678 0 00-.508-11.09c-1.718-3.18-14.444-34.357-19.534-47.06-5.09-12.703-10.37-10.603-14.272-10.901-3.902-.297-7.911-.19-12.089-.19a23.322 23.322 0 00-16.964 7.911c-5.707 6.298-22.1 21.673-22.1 52.849s22.671 61.249 25.852 65.532c3.182 4.284 44.663 68.227 108.288 95.649 15.099 6.489 26.891 10.392 36.053 13.403a87.504 87.504 0 0025.216 3.718c4.905 0 9.82-.416 14.65-1.237 12.174-1.782 37.453-15.291 42.776-30.073s5.303-27.57 3.711-30.093c-1.591-2.524-5.704-4.369-12.088-7.615l-.038.021z"/></svg>',backgroundColor:"#25D366",prefilledmessage:"Hi, I'd like to learn more.",mobile:{enabled:!1,url:"https://wa.me/{number}[?text={prefilledmessage}]"},desktop:{enabled:!1,url:"https://web.whatsapp.com/send?phone={number}[&text={prefilledmessage}]"}},sms:{label:"SMS",icon:'<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#fff"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 13H6v-2h2v2zm5 0h-2v-2h2v2zm5 0h-2v-2h2v2z"/></svg>',backgroundColor:"#3478F6",prefilledmessage:"Hi, I'd like to learn more.",mobile:{enabled:!1,url:"sms:{number}[?body={prefilledmessage}]"},desktop:{enabled:!1,url:"sms:{number}[?body={prefilledmessage}]"},popover:{title:"Text us \u2014 we're available 24/7",description:"US numbers only. Msg & carrier rates may apply. Reply STOP to opt out.",buttonLabel:"Start Conversation"}}},pe=new Set(["prefilledmessage"]);function me(e,n){return e.replace(/\[([^\]]*)\]/g,(l,o)=>{for(const[,c]of o.matchAll(/\{(\w+)\}/g)){const a=n[c];if(a==null||a==="")return""}return o}).replace(/\{(\w+)\}/g,(l,o)=>{const c=n[o];if(c==null)return"";const a=String(c);return pe.has(o)?encodeURIComponent(a):a})}const j=e=>e&&typeof e.enabled=="boolean"?{enabled:e.enabled}:{},ge=e=>e===!0?!0:e&&typeof e=="object"?e.enabled===!0:!1,G={title:60,description:140,buttonLabel:24},be=(e,n)=>{if(!e||e===!0||typeof e!="object")return{};const t={},l=o=>{if(typeof e[o]!="string")return;const c=G[o];if(c!=null&&e[o].length>c){console.warn(`[lc-channel-widgets] ${n} popover.${o} exceeds ${c} chars (got ${e[o].length}); using registry default`);return}t[o]=e[o]};return Object.keys(G).forEach(l),t};function _e(e,n){if(!e||typeof e.type!="string")return null;const t=fe[e.type];if(!t)return null;const l=t[n]||{},o=he(L({},e),{prefilledmessage:typeof e.prefilledmessage=="string"?e.prefilledmessage:t.prefilledmessage||""});return{type:e.type,label:t.label,icon:t.icon,backgroundColor:t.backgroundColor,mobile:L(L({},t.mobile),j(e.mobile)),desktop:L(L({},t.desktop),j(e.desktop)),popover:t.popover&&ge(e.popover)?L(L({},t.popover),be(e.popover,e.type)):void 0,href:l.url?me(l.url,o):""}}const we="screen and (max-width: 992px) and (pointer: coarse)",ye=()=>window.matchMedia(we).matches?"mobile":"desktop",C=[];function X(){for(let e=C.length-1;e>=0;e--){const n=C[e];n&&n.parentNode&&n.parentNode.removeChild(n),C.splice(e,1)}}let Y=!1;function ve(){Y||(Y=!0,document.addEventListener("click",e=>{for(let n=0;n<C.length;n++){const t=C[n];t.__isOpen&&!t.contains(e.target)&&O(t)}}))}function Ce(){if(window.__lcHistoryPatched)return;window.__lcHistoryPatched=!0,window.__lcLastUrl=window.__lcLastUrl||location.href;const e=l=>{const o=window.__lcLastUrl,c=location.href,a=o!==c;window.__lcLastUrl=c,!(!a&&l!=="popstate")&&window.dispatchEvent(new Event("lc:locationchange"))},n=history.pushState;typeof n=="function"&&(history.pushState=function(...l){const o=n.apply(this,l);return e("pushState"),o});const t=history.replaceState;typeof t=="function"&&(history.replaceState=function(...l){const o=t.apply(this,l);return e("replaceState"),o}),window.addEventListener("popstate",()=>e("popstate")),window.addEventListener("hashchange",()=>e("hashchange"))}function Q(e){var l;if(document.__lcVisibilityBound&&!e)return!0;if(typeof((l=window.LiveChatWidget)==null?void 0:l.on)!="function")return!1;const n=document.__lcVisibilityCb;if(n&&typeof window.LiveChatWidget.off=="function")try{window.LiveChatWidget.off("visibility_changed",n)}catch(o){}const t=o=>{var a,s;const c=document.__lcStack;!c||!c.isConnected||(o&&typeof o.visibility=="string"&&(c.__lcVisibility=o.visibility),(a=document.__lcCurrentRebind)==null||a.call(document),(s=document.__lcCurrentSync)==null||s.call(document))};return window.LiveChatWidget.on("visibility_changed",t),document.__lcVisibilityCb=t,document.__lcVisibilityBound=!0,!0}function xe(e){if(Q(e)||document.__lcVisibilityPolling)return;document.__lcVisibilityPolling=!0;let n=0;const t=setInterval(()=>{(Q(e)||++n>=200)&&(clearInterval(t),document.__lcVisibilityPolling=!1)},200)}function Se(){document.__lcBodyMutationObs||typeof MutationObserver!="undefined"&&(document.__lcBodyMutationObs=new MutationObserver(e=>{const n=document.__lcStack;if(!!n)for(let t=0;t<e.length;t++){const l=e[t].removedNodes;if(!(!l||l.length===0))for(let o=0;o<l.length;o++){const c=l[o];if(c.nodeType===1&&(c===n||c.contains&&c.contains(n))){const a=document.__lcChannelWidgetsConfig;a&&Z(a);return}}}}),document.__lcBodyMutationObs.observe(document.body,{childList:!0,subtree:!0}))}let I=null,V=null;function Z(e){V=e,!I&&(I=setTimeout(()=>{I=null;const n=V;V=null,H(n)},100))}const Be=["#chat-widget-minimized","#chat-overlay-container"],Ee=15,J=100,Le=150;function Oe(e){return{width:e.width,height:e.height,fromLeft:e.left,fromRight:window.innerWidth-e.right,fromTop:e.top,fromBottom:window.innerHeight-e.bottom}}function ke(e){const n=e.fromLeft<=e.fromRight,t=e.fromTop<=e.fromBottom,l=n?e.fromLeft:window.innerWidth-e.fromRight-e.width,o=t?e.fromTop:window.innerHeight-e.fromBottom-e.height;return{left:l,top:o,right:l+e.width,bottom:o+e.height,width:e.width,height:e.height}}const k=60;function Ae(e){const n=window.innerWidth-e.right<=e.left,t=e.bottom,l=t-k,o=n?e.right:e.left+k;return{left:o-k,right:o,top:l,bottom:t,width:k,height:k}}const ze=200,Te=150;function K(e,n,{interval:t=ze,maxRetries:l=Te}={}){let o=0;const c=setInterval(()=>{const a=document.querySelector(e);if(a){clearInterval(c),n(a);return}++o>=l&&clearInterval(c)},t)}function We(){if(document.getElementById("lc-channel-widgets-style"))return;const e=document.createElement("style");e.id="lc-channel-widgets-style",e.textContent=`
|
|
2
|
+
.lc-channel-stack {
|
|
3
|
+
position: fixed;
|
|
4
|
+
top: 0;
|
|
5
|
+
left: 0;
|
|
6
|
+
z-index: 999999;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
pointer-events: auto;
|
|
10
|
+
/* All position changes go through transform: translate(...) rather
|
|
11
|
+
than top/left so they don't contribute to CLS \u2014 top/left changes
|
|
12
|
+
are layout shifts; transforms are compositor-only and excluded. */
|
|
13
|
+
will-change: transform;
|
|
14
|
+
/* Sizes are driven inline by syncPosition so widget icons match
|
|
15
|
+
LC's bubble (which itself resizes with branding/state). */
|
|
16
|
+
--lc-channel-size: 48px;
|
|
17
|
+
--lc-channel-icon-size: 28px;
|
|
18
|
+
/* Stay invisible until syncPosition commits a verified transform.
|
|
19
|
+
.lc-stack-ready is added one frame after that first commit;
|
|
20
|
+
until then the stack occupies its position but is not painted,
|
|
21
|
+
so the user never sees the brief "wrong position" frame caused
|
|
22
|
+
by LC's open/close animation producing a panel rect mid-flight
|
|
23
|
+
(sync N) before the resize observer catches up (sync N+1). */
|
|
24
|
+
opacity: 0;
|
|
25
|
+
}
|
|
26
|
+
.lc-channel-stack.lc-stack-ready {
|
|
27
|
+
opacity: 1;
|
|
28
|
+
/* Smooth subsequent moves (chat open/close, viewport resize) on
|
|
29
|
+
the same timescale as LC's own animation. Compositor-only;
|
|
30
|
+
no CLS impact. */
|
|
31
|
+
transition: transform 220ms cubic-bezier(0.22, 0.61, 0.36, 1),
|
|
32
|
+
opacity 120ms ease-out;
|
|
33
|
+
}
|
|
34
|
+
/* Mobile = vertical column below the bubble. Desktop = horizontal row
|
|
35
|
+
next to the chat button. Exact transform (left- vs right-of-button)
|
|
36
|
+
is set inline by syncPosition. */
|
|
37
|
+
.lc-channel-stack--horizontal {
|
|
38
|
+
flex-direction: row;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.lc-channel-button {
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
width: var(--lc-channel-size);
|
|
44
|
+
height: var(--lc-channel-size);
|
|
45
|
+
flex: 0 0 auto;
|
|
46
|
+
display: flex;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
align-items: center;
|
|
49
|
+
border-radius: 50%;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.lc-channel-icon {
|
|
53
|
+
display: block;
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
width: var(--lc-channel-icon-size);
|
|
56
|
+
height: var(--lc-channel-icon-size);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.lc-channel-popover {
|
|
60
|
+
position: fixed;
|
|
61
|
+
/* Anchor at (0,0); visual position is driven entirely by transform
|
|
62
|
+
so repositioning is a compositor matrix update \u2014 no layout pass. */
|
|
63
|
+
top: 0;
|
|
64
|
+
left: 0;
|
|
65
|
+
z-index: 2147483641;
|
|
66
|
+
width: 280px;
|
|
67
|
+
padding: 18px 22px 16px 18px;
|
|
68
|
+
background: #fff;
|
|
69
|
+
color: #1a1a1a;
|
|
70
|
+
border-radius: 12px;
|
|
71
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
|
|
72
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
73
|
+
/* Pre-promote to own compositor layer. Box-shadow / border-radius /
|
|
74
|
+
text are painted once into the backing store at init; subsequent
|
|
75
|
+
open/close pays only a GPU matrix/alpha update \u2014 no layout, no paint.
|
|
76
|
+
Declaring BOTH animated properties lets Chrome schedule them in a
|
|
77
|
+
single compositor frame instead of two GPU passes. */
|
|
78
|
+
will-change: opacity, transform;
|
|
79
|
+
}
|
|
80
|
+
.lc-channel-popover-title {
|
|
81
|
+
margin: 0 0 6px;
|
|
82
|
+
padding-right: 16px;
|
|
83
|
+
font-size: 15px;
|
|
84
|
+
font-weight: 600;
|
|
85
|
+
line-height: 1.3;
|
|
86
|
+
}
|
|
87
|
+
.lc-channel-popover-description {
|
|
88
|
+
margin: 0 0 14px;
|
|
89
|
+
font-size: 13px;
|
|
90
|
+
line-height: 1.4;
|
|
91
|
+
color: #555;
|
|
92
|
+
}
|
|
93
|
+
.lc-channel-popover-button {
|
|
94
|
+
width: 100%;
|
|
95
|
+
padding: 10px 14px;
|
|
96
|
+
border: none;
|
|
97
|
+
border-radius: 8px;
|
|
98
|
+
color: #fff;
|
|
99
|
+
font-size: 14px;
|
|
100
|
+
font-weight: 600;
|
|
101
|
+
cursor: pointer;
|
|
102
|
+
}
|
|
103
|
+
.lc-channel-popover-close {
|
|
104
|
+
position: absolute;
|
|
105
|
+
top: 6px;
|
|
106
|
+
right: 8px;
|
|
107
|
+
background: transparent;
|
|
108
|
+
border: none;
|
|
109
|
+
font-size: 18px;
|
|
110
|
+
line-height: 1;
|
|
111
|
+
color: #888;
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
padding: 4px 6px;
|
|
114
|
+
}
|
|
115
|
+
/* Directional arrow. 12px square rotated 45\xB0 so half sits outside
|
|
116
|
+
the popover as a triangular tip. Inline left/top is set per open
|
|
117
|
+
so the tip aligns with the trigger button's center. */
|
|
118
|
+
.lc-channel-popover-arrow {
|
|
119
|
+
position: absolute;
|
|
120
|
+
width: 12px;
|
|
121
|
+
height: 12px;
|
|
122
|
+
background: #fff;
|
|
123
|
+
transform: rotate(45deg);
|
|
124
|
+
pointer-events: none;
|
|
125
|
+
}
|
|
126
|
+
.lc-channel-popover--arrow-bottom > .lc-channel-popover-arrow {
|
|
127
|
+
bottom: -6px;
|
|
128
|
+
box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.08);
|
|
129
|
+
}
|
|
130
|
+
.lc-channel-popover--arrow-top > .lc-channel-popover-arrow {
|
|
131
|
+
top: -6px;
|
|
132
|
+
box-shadow: -3px -3px 6px rgba(0, 0, 0, 0.06);
|
|
133
|
+
}
|
|
134
|
+
`,document.head.appendChild(e)}function Pe(e,n){if(typeof e!="string"||e.length===0)return null;if(/^(data:|https?:\/\/)/.test(e)){const o=document.createElement("img");return o.className="lc-channel-icon",o.alt=n||"",o.src=e,o}const t=document.createElement("span");t.className="lc-channel-icon",t.setAttribute("aria-hidden","true"),t.innerHTML=e;const l=t.querySelector("svg");return l&&(l.setAttribute("width","100%"),l.setAttribute("height","100%"),l.style.display="block"),t}function Me(e,n,t){const a=e.left+e.width/2;let s=e.top-t-12,A="bottom";s<8&&(s=e.bottom+12,A="top"),s+t>window.innerHeight-8&&(s=window.innerHeight-t-8),s<8&&(s=8);let S=a-n/2;S<8&&(S=8),S+n>window.innerWidth-8&&(S=window.innerWidth-n-8);const r=18,z=Math.max(r,n-18),N=Math.max(r,Math.min(z,a-S));return{tx:S,ty:s,arrowSide:A,arrowOffset:N}}function ee(e,n,t){e.__appliedArrowSide!==n&&(e.classList.remove("lc-channel-popover--arrow-top","lc-channel-popover--arrow-bottom"),e.classList.add(`lc-channel-popover--arrow-${n}`),e.__appliedArrowSide=n),e.__arrowEl.style.left=`${t-6}px`}function O(e){e.__isOpen=!1,e.style.opacity="0",e.style.pointerEvents="none",requestAnimationFrame(()=>{e.setAttribute("aria-hidden","true")})}function Re(e){C.forEach(n=>{n!==e&&n.__isOpen&&O(n)}),e.__cachedTransform&&(e.style.transform=e.__cachedTransform),e.__arrowSide&&e.__arrowEl&&ee(e,e.__arrowSide,e.__arrowOffset),e.style.opacity="1",e.style.pointerEvents="auto",requestAnimationFrame(()=>{e.removeAttribute("aria-hidden")}),e.__isOpen=!0}function Ie(e){const n=e.popover,t=document.createElement("div");if(t.className="lc-channel-popover",t.setAttribute("data-popover-channel-id",e.type),n.title){const s=document.createElement("h3");s.className="lc-channel-popover-title",s.textContent=n.title,t.appendChild(s)}if(n.description){const s=document.createElement("p");s.className="lc-channel-popover-description",s.textContent=n.description,t.appendChild(s)}const l=document.createElement("button");l.type="button",l.className="lc-channel-popover-button",l.textContent=n.buttonLabel||"Start Conversation",l.style.backgroundColor=e.backgroundColor||"#1a1a1a",l.onclick=s=>{s.stopPropagation(),typeof e.href=="string"&&e.href.length>0&&window.open(e.href,"_blank","noopener,noreferrer"),O(t)},t.appendChild(l);const o=document.createElement("button");o.type="button",o.className="lc-channel-popover-close",o.setAttribute("aria-label","Close"),o.textContent="\xD7",o.onclick=s=>{s.stopPropagation(),O(t)},t.appendChild(o);const c=document.createElement("div");c.className="lc-channel-popover-arrow",t.appendChild(c),t.__arrowEl=c,t.__isOpen=!1,t.style.opacity="0",t.style.pointerEvents="none",t.setAttribute("aria-hidden","true"),t.style.transform="translate3d(0,0,0)",document.body.appendChild(t);const a=t.getBoundingClientRect();return t.__cachedWidth=a.width>0?a.width:280,t.__cachedHeight=a.height,C.push(t),ve(),t}function Ve(e){const n=document.createElement("div");n.className="lc-channel-button",n.setAttribute("data-channel-id",e.type),e.label&&n.setAttribute("aria-label",e.label),e.backgroundColor&&(n.style.backgroundColor=e.backgroundColor);const t=e.popover?Ie(e):null;n.__popoverEl=t,n.onclick=o=>{if(t){o.stopPropagation(),t.__isOpen?O(t):Re(t);return}typeof e.href=="string"&&e.href.length>0&&window.open(e.href,"_blank","noopener,noreferrer")};const l=Pe(e.icon,e.label||e.type);return l&&n.appendChild(l),n}function He(e,n){const t=e==null?void 0:e[n];return t&&typeof t.enabled=="boolean"?t.enabled:n==="mobile"}function Ne(e){var W,ne,oe;const{deviceType:n,chatWidgetSelector:t,channels:l,bubbleSelector:o}=e,c=e[n];if(!document.querySelector(t))return;const s=()=>document.querySelector(t),A=[];l.forEach(i=>{const u=_e(i,n);if(!u){console.warn("[lc-channel-widgets] unknown or invalid channel \u2014 skipping:",i);return}A.push(u)});const S=A.filter(i=>He(i,n));if(S.length===0)return;We();let r=document.body.querySelector(":scope > .lc-channel-stack");if(!r){X(),r=document.createElement("div");const i=n==="mobile"?"vertical":"horizontal";r.className=`lc-channel-stack lc-channel-stack--${i}`,r.style.gap=c.gap,r.setAttribute("role","group"),r.setAttribute("aria-label","Contact channels"),document.body.appendChild(r)}document.__lcStack=r,S.forEach(i=>{r.querySelector(`[data-channel-id="${CSS.escape(i.type)}"]`)||r.appendChild(Ve(i))});const z=parseInt(c.gapBelow,10)||8,N=()=>{const i=s();for(let u=0;u<o.length;u++){const f=o[u],b=i&&i.querySelector(f)||document.querySelector(f);if(!b)continue;const _=b.getBoundingClientRect();if(_.width>0&&_.height>0)return _}return null},De=()=>{const i=s(),u=[];for(let f=0;f<o.length;f++){const b=o[f],_=i?i.querySelector(b):null,T=document.querySelector(b);_&&u.indexOf(_)===-1&&u.push(_),T&&T!==_&&u.indexOf(T)===-1&&u.push(T)}return i&&u.indexOf(i)===-1&&u.push(i),u};let te="minimized";try{const i=(oe=(ne=(W=window.LiveChatWidget)==null?void 0:W.get)==null?void 0:ne.call(W,"state"))==null?void 0:oe.visibility;typeof i=="string"&&(te=i)}catch(i){}r.__lcVisibility=te;const D=()=>{const i=N();i&&r.__lcVisibility==="minimized"&&i.width<=J&&i.height<=J&&window.innerHeight-i.bottom<=Le&&(document.__lcBubbleAnchor=Oe(i));let u=null,f=null;if(r.__lcVisibility==="minimized")i&&(u=i,f=i);else if(r.__lcVisibility==="maximized"&&n!=="mobile"){const d=s();if(d){const h=d.getBoundingClientRect();h.width>0&&h.height>0&&(u=h,f=document.__lcBubbleAnchor?ke(document.__lcBubbleAnchor):Ae(h))}}if(!u||!f){for(let d=0;d<C.length;d++)C[d].__isOpen&&O(C[d]);r.style.display="none";return}r.style.display="flex";const b=f,_=Math.max(b.width,b.height),P=Math.min(_,n==="mobile"?60:40),Ue=Math.round(P*.5),ie=r.__lcLastButtonSize!==P;ie&&(r.style.setProperty("--lc-channel-size",`${P}px`),r.style.setProperty("--lc-channel-icon-size",`${Ue}px`),r.__lcCachedDims=null,r.__lcLastButtonSize=P);const w=8,re=r.children.length,le=r.__lcLastButtonCount!==re;le&&(r.__lcCachedDims=null);const B=r.__lcCachedDims||r.getBoundingClientRect();r.__lcCachedDims=B,r.__lcLastButtonCount=re;let M,R;if(n==="mobile"){const d=f,h=Math.min(d.height,d.width,80);let x=d.left<window.innerWidth-d.right?d.left+h/2:d.right-h/2;const p=B.width/2;x-p<w&&(x=p+w),x+p>window.innerWidth-w&&(x=window.innerWidth-p-w),M=x-B.width/2,R=d.bottom+z-Ee}else{const d=u.left+u.width/2<window.innerWidth/2,h=B.height/2;let E=f.top+f.height/2;E-h<w&&(E=h+w),E+h>window.innerHeight-w&&(E=window.innerHeight-h-w);const x=-h;let p,y;d?(p=u.right+z,p+B.width>window.innerWidth-w&&(p=window.innerWidth-B.width-w),y=0):(p=u.left-z,p-B.width<w&&(p=B.width+w),y=-B.width),M=p+y,R=E+x}const F=`translate(${M}px, ${R}px)`;!(F!==r.__lcLastTransform)&&!ie&&!le||(r.style.transform=F,r.__lcLastTransform=F,r.__lcTransitionActivated||requestAnimationFrame(()=>{r.classList.add("lc-stack-ready"),r.__lcTransitionActivated=!0}),r.querySelectorAll(".lc-channel-button").forEach(d=>{const h=M+d.offsetLeft,E=R+d.offsetTop,x=d.offsetWidth,p=d.offsetHeight;if(d.__cachedRect={left:h,top:E,right:h+x,bottom:E+p,width:x,height:p},d.__popoverEl){const y=d.__popoverEl,{tx:qe,ty:$e,arrowSide:ce,arrowOffset:se}=Me(d.__cachedRect,y.__cachedWidth,y.__cachedHeight),ae=`translate3d(${qe}px,${$e}px,0)`;y.__cachedTransform=ae,y.__arrowSide=ce,y.__arrowOffset=se,y.__isOpen&&(y.style.transform=ae,ee(y,ce,se))}}))};let U=0;const q=()=>{U||(U=requestAnimationFrame(()=>{U=0,D()}))};D(),document.__lcCurrentSync=q,document.__lcWindowListenersBound||(window.addEventListener("resize",()=>{var i;return(i=document.__lcCurrentSync)==null?void 0:i.call(document)}),window.addEventListener("orientationchange",()=>{var i;document.__lcBubbleAnchor=null,(i=document.__lcCurrentSync)==null||i.call(document)}),window.visualViewport&&(window.visualViewport.addEventListener("resize",()=>{var i;return(i=document.__lcCurrentSync)==null?void 0:i.call(document)}),window.visualViewport.addEventListener("scroll",()=>{var i;return(i=document.__lcCurrentSync)==null?void 0:i.call(document)})),window.addEventListener("scroll",()=>{var i;return(i=document.__lcCurrentSync)==null?void 0:i.call(document)},!0),document.__lcWindowListenersBound=!0),typeof ResizeObserver!="undefined"&&!r.__lcResizeObserved&&(new ResizeObserver(q).observe(r),r.__lcResizeObserved=!0);const $=()=>{const i=De();if(i.length===0)return;const u=r.__lcObservedBubbles||[];i.length===u.length&&i.every((b,_)=>b===u[_])||(r.__lcBubbleObserver&&r.__lcBubbleObserver.disconnect(),r.__lcObservedBubbles=i,typeof ResizeObserver!="undefined"&&(r.__lcBubbleObserver=new ResizeObserver(q),i.forEach(b=>r.__lcBubbleObserver.observe(b))))};$(),(!r.__lcObservedBubbles||r.__lcObservedBubbles.length===0)&&o.forEach(i=>{K(i,()=>{$(),D()})}),document.__lcCurrentRebind=$,document.__lcVisibilityBound=!1,xe(!0)}function H(e={}){const n=e.channelWidgetsConfig||{},t={gap:"8px",gapBelow:"8px"},l={gap:"8px",gapBelow:"8px"},o={chatWidgetSelector:n.chatWidgetSelector||"#chat-widget-container",bubbleSelector:Be,channels:Array.isArray(n.channels)?n.channels:[],mobile:Object.assign({},t,n.mobile),desktop:Object.assign({},l,n.desktop)},c=ye();if(o.deviceType=c,o.channels.length===0)return;document.__lcChannelWidgetsConfig=e,K(o.chatWidgetSelector,()=>{Ne(o),Se()});const a=()=>{document.__lcBubbleAnchor=null,document.__lcVisibilityBound=!1,X();const s=document.__lcChannelWidgetsConfig;s&&Z(s)};document.__lcChannelWidgetsSpaBound||(Ce(),window.addEventListener("lc:locationchange",a),document.__lcChannelWidgetsSpaBound=!0),document.__lcChannelWidgetsTurbolinksBound||(document.addEventListener("turbolinks:load",a),document.__lcChannelWidgetsTurbolinksBound=!0)}return window.commversion=window.commversion||{},window.LiveChatWidget.on("ready",()=>H(window.commversion)),m.lcAddChannelWidgets=H,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),m}({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const d=u=>{const{exitIntentDebounceMs:l=1500,exitIntentMargin:n=10}=u,{LiveChatWidget:s}=window;let i=!0,e=null;function r(t,c){const o=window.innerWidth,a=window.innerHeight;return t>=n&&t<=o-n&&c>=n&&c<=a-n}document.addEventListener("mousemove",t=>{r(t.clientX,t.clientY)?(i||(i=!0,console.log("[lc-exit-intent-debounced] Mouse re-entered inner screen, resetting exit_intent to false"),s.call("update_session_variables",{exit_intent:"false"})),e&&(console.log("[lc-exit-intent-debounced] Mouse re-entered before debounce, clearing exit intent timer"),clearTimeout(e),e=null)):i&&(i=!1,console.log(`[lc-exit-intent-debounced] Mouse left inner screen, starting debounce timer (${l}ms)`),e=setTimeout(()=>{const{status:o}=s.get("customer_data");o==="browsing"?(console.log("[lc-exit-intent-debounced] Debounce elapsed, setting exit_intent to true"),s.call("update_session_variables",{exit_intent:"true"})):console.log(`[lc-exit-intent-debounced] Debounce elapsed, but status is not 'browsing' (status: ${o}), not setting exit_intent`),e=null},l))})};window.commversion=window.commversion||{},window.LiveChatWidget.on("ready",d(window.commversion))})();
|
|
1
|
+
(function(){"use strict";const d=u=>()=>{const{exitIntentDebounceMs:l=1500,exitIntentMargin:n=10}=u,{LiveChatWidget:s}=window;let i=!0,e=null;function r(t,c){const o=window.innerWidth,a=window.innerHeight;return t>=n&&t<=o-n&&c>=n&&c<=a-n}document.addEventListener("mousemove",t=>{r(t.clientX,t.clientY)?(i||(i=!0,console.log("[lc-exit-intent-debounced] Mouse re-entered inner screen, resetting exit_intent to false"),s.call("update_session_variables",{exit_intent:"false"})),e&&(console.log("[lc-exit-intent-debounced] Mouse re-entered before debounce, clearing exit intent timer"),clearTimeout(e),e=null)):i&&(i=!1,console.log(`[lc-exit-intent-debounced] Mouse left inner screen, starting debounce timer (${l}ms)`),e=setTimeout(()=>{const{status:o}=s.get("customer_data");o==="browsing"?(console.log("[lc-exit-intent-debounced] Debounce elapsed, setting exit_intent to true"),s.call("update_session_variables",{exit_intent:"true"})):console.log(`[lc-exit-intent-debounced] Debounce elapsed, but status is not 'browsing' (status: ${o}), not setting exit_intent`),e=null},l))})};window.commversion=window.commversion||{},window.LiveChatWidget.on("ready",d(window.commversion))})();
|
|
@@ -27,4 +27,4 @@
|
|
|
27
27
|
height: 50%;
|
|
28
28
|
object-fit: contain;
|
|
29
29
|
}
|
|
30
|
-
`,document.head.appendChild(t)}function f(t){if(t.style.right&&t.style.right!=="auto")return"right";if(t.style.left&&t.style.left!=="auto")return"left";const s=window.getComputedStyle(t);return s.right!=="auto"?"right":s.left!=="auto"?"left":"right"}function w(t,s){const e=document.createElement("img");e.className="lc-whatsapp-icon",e.alt="WhatsApp",e.src="data:image/svg+xml;utf8,"+encodeURIComponent('<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd" viewBox="0 0 509 511.514"><path fill="#fff" d="M434.762 74.334C387.553 26.81 323.245 0 256.236 0h-.768C115.795.001 2.121 113.696 2.121 253.456l.001.015a253.516 253.516 0 0033.942 126.671L0 511.514l134.373-35.269a253.416 253.416 0 00121.052 30.9h.003.053C395.472 507.145 509 393.616 509 253.626c0-67.225-26.742-131.727-74.252-179.237l.014-.055zM255.555 464.453c-37.753 0-74.861-10.22-107.293-29.479l-7.72-4.602-79.741 20.889 21.207-77.726-4.984-7.975c-21.147-33.606-32.415-72.584-32.415-112.308 0-116.371 94.372-210.743 210.741-210.743 56.011 0 109.758 22.307 149.277 61.98a210.93 210.93 0 0161.744 149.095c0 116.44-94.403 210.869-210.844 210.869h.028zm115.583-157.914c-6.363-3.202-37.474-18.472-43.243-20.593-5.769-2.121-10.01-3.202-14.315 3.203-4.305 6.404-16.373 20.593-20.063 24.855-3.69 4.263-7.401 4.815-13.679 1.612-6.278-3.202-26.786-9.883-50.899-31.472a192.748 192.748 0 01-35.411-43.867c-3.712-6.363-.404-9.777 2.82-12.873 3.224-3.096 6.363-7.381 9.48-11.092a41.58 41.58 0 006.357-10.597 11.678 11.678 0 00-.508-11.09c-1.718-3.18-14.444-34.357-19.534-47.06-5.09-12.703-10.37-10.603-14.272-10.901-3.902-.297-7.911-.19-12.089-.19a23.322 23.322 0 00-16.964 7.911c-5.707 6.298-22.1 21.673-22.1 52.849s22.671 61.249 25.852 65.532c3.182 4.284 44.663 68.227 108.288 95.649 15.099 6.489 26.891 10.392 36.053 13.403a87.504 87.504 0 0025.216 3.718c4.905 0 9.82-.416 14.65-1.237 12.174-1.782 37.453-15.291 42.776-30.073s5.303-27.57 3.711-30.093c-1.591-2.524-5.704-4.369-12.088-7.615l-.038.021z"/></svg>');const o=document.createElement("div");return o.className="lc-whatsapp-wrapper",o.onclick=function(){const n=s==="mobile"?`https://wa.me/${t}`:`https://web.whatsapp.com/send?phone=${t}`;window.open(n,"_blank","noopener,noreferrer")},o.appendChild(e),{waDiv:o}}function g(t){const s=document.querySelector(u);if(!s)return!1;if(s.querySelector(".lc-whatsapp-wrapper"))return!0;m();const{waDiv:e}=w(t.number,t.deviceType);e.style.position="absolute";const o=f(s);t.deviceType==="mobile"?(e.style.top="100%",e.style.marginTop="-10px",o==="left"?(e.style.left="10px",e.style.right="auto"):(e.style.right="10px",e.style.left="auto")):(e.style.top="50%",e.style.transform="translateY(-50%)",o==="left"?(e.style.left="100%",e.style.marginLeft="8px",e.style.right="auto"):(e.style.right="100%",e.style.marginRight="8px",e.style.left="auto"));const n=l=>{const c=new ResizeObserver(()=>{const d=Math.round(l.getBoundingClientRect().height);if(d===0)return;const r=Math.min(Math.max(d,40),64);e.style.width=r+"px",e.style.height=r+"px",e.classList.add("lc-wa-ready"),c.disconnect()});c.observe(l)};s.appendChild(e);const i=document.querySelector(y);return i?n(i):a(y,l=>n(l),{interval:300,maxRetries:130}),!0}function v(t){const{deviceType:s}=t,e=document.querySelector(t.chatWidgetSelector);if(!e||(e.style.overflow="unset",m(),e.querySelector(".lc-whatsapp-wrapper")))return;const n=f(e)==="left",{waDiv:i}=w(t.number,s);e.appendChild(i);const l="#chat-widget-minimized",c=e.querySelector(l)||document.querySelector(l),d=r=>{if(!r)return;new ResizeObserver(()=>{const h=Math.round(r.getBoundingClientRect().width);if(h===0){s==="mobile"?i.style.display="none":(i.style.width="40px",i.style.height="40px",i.classList.add("lc-wa-ready"));return}i.style.display="flex";let p=20;h===84?p=30:h>100&&(p=20),s==="mobile"&&(i.style.bottom=p===30?"-50px":"-25px"),i.style.width=`${p*2}px`,i.style.height=`${p*2}px`,i.classList.add("lc-wa-ready")}).observe(r)};c?d(c):a(l,r=>d(r),{interval:300,maxRetries:130}),t.deviceType==="mobile"?n?(i.style.left=t.mobile.left,i.style.right="auto"):(i.style.right=t.mobile.right,i.style.left="auto"):(i.style.bottom=t.desktop.bottom,n?(i.style.right=t.desktop.right,i.style.left="auto"):(i.style.left=t.desktop.left,i.style.right="auto"))}function a(t,s,{interval:e=300,maxRetries:o=100}={}){let n=0;const i=setInterval(()=>{const l=document.querySelector(t);if(l){clearInterval(i),s(l);return}++n>=o&&clearInterval(i)},e)}let b=!1;
|
|
30
|
+
`,document.head.appendChild(t)}function f(t){if(t.style.right&&t.style.right!=="auto")return"right";if(t.style.left&&t.style.left!=="auto")return"left";const s=window.getComputedStyle(t);return s.right!=="auto"?"right":s.left!=="auto"?"left":"right"}function w(t,s){const e=document.createElement("img");e.className="lc-whatsapp-icon",e.alt="WhatsApp",e.src="data:image/svg+xml;utf8,"+encodeURIComponent('<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd" viewBox="0 0 509 511.514"><path fill="#fff" d="M434.762 74.334C387.553 26.81 323.245 0 256.236 0h-.768C115.795.001 2.121 113.696 2.121 253.456l.001.015a253.516 253.516 0 0033.942 126.671L0 511.514l134.373-35.269a253.416 253.416 0 00121.052 30.9h.003.053C395.472 507.145 509 393.616 509 253.626c0-67.225-26.742-131.727-74.252-179.237l.014-.055zM255.555 464.453c-37.753 0-74.861-10.22-107.293-29.479l-7.72-4.602-79.741 20.889 21.207-77.726-4.984-7.975c-21.147-33.606-32.415-72.584-32.415-112.308 0-116.371 94.372-210.743 210.741-210.743 56.011 0 109.758 22.307 149.277 61.98a210.93 210.93 0 0161.744 149.095c0 116.44-94.403 210.869-210.844 210.869h.028zm115.583-157.914c-6.363-3.202-37.474-18.472-43.243-20.593-5.769-2.121-10.01-3.202-14.315 3.203-4.305 6.404-16.373 20.593-20.063 24.855-3.69 4.263-7.401 4.815-13.679 1.612-6.278-3.202-26.786-9.883-50.899-31.472a192.748 192.748 0 01-35.411-43.867c-3.712-6.363-.404-9.777 2.82-12.873 3.224-3.096 6.363-7.381 9.48-11.092a41.58 41.58 0 006.357-10.597 11.678 11.678 0 00-.508-11.09c-1.718-3.18-14.444-34.357-19.534-47.06-5.09-12.703-10.37-10.603-14.272-10.901-3.902-.297-7.911-.19-12.089-.19a23.322 23.322 0 00-16.964 7.911c-5.707 6.298-22.1 21.673-22.1 52.849s22.671 61.249 25.852 65.532c3.182 4.284 44.663 68.227 108.288 95.649 15.099 6.489 26.891 10.392 36.053 13.403a87.504 87.504 0 0025.216 3.718c4.905 0 9.82-.416 14.65-1.237 12.174-1.782 37.453-15.291 42.776-30.073s5.303-27.57 3.711-30.093c-1.591-2.524-5.704-4.369-12.088-7.615l-.038.021z"/></svg>');const o=document.createElement("div");return o.className="lc-whatsapp-wrapper",o.onclick=function(){const n=s==="mobile"?`https://wa.me/${t}`:`https://web.whatsapp.com/send?phone=${t}`;window.open(n,"_blank","noopener,noreferrer")},o.appendChild(e),{waDiv:o}}function g(t){const s=document.querySelector(u);if(!s)return!1;if(s.querySelector(".lc-whatsapp-wrapper"))return!0;m();const{waDiv:e}=w(t.number,t.deviceType);e.style.position="absolute";const o=f(s);t.deviceType==="mobile"?(e.style.top="100%",e.style.marginTop="-10px",o==="left"?(e.style.left="10px",e.style.right="auto"):(e.style.right="10px",e.style.left="auto")):(e.style.top="50%",e.style.transform="translateY(-50%)",o==="left"?(e.style.left="100%",e.style.marginLeft="8px",e.style.right="auto"):(e.style.right="100%",e.style.marginRight="8px",e.style.left="auto"));const n=l=>{const c=new ResizeObserver(()=>{const d=Math.round(l.getBoundingClientRect().height);if(d===0)return;const r=Math.min(Math.max(d,40),64);e.style.width=r+"px",e.style.height=r+"px",e.classList.add("lc-wa-ready"),c.disconnect()});c.observe(l)};s.appendChild(e);const i=document.querySelector(y);return i?n(i):a(y,l=>n(l),{interval:300,maxRetries:130}),!0}function v(t){const{deviceType:s}=t,e=document.querySelector(t.chatWidgetSelector);if(!e||(e.style.overflow="unset",m(),e.querySelector(".lc-whatsapp-wrapper")))return;const n=f(e)==="left",{waDiv:i}=w(t.number,s);e.appendChild(i);const l="#chat-widget-minimized",c=e.querySelector(l)||document.querySelector(l),d=r=>{if(!r)return;new ResizeObserver(()=>{const h=Math.round(r.getBoundingClientRect().width);if(h===0){s==="mobile"?i.style.display="none":(i.style.width="40px",i.style.height="40px",i.classList.add("lc-wa-ready"));return}i.style.display="flex";let p=20;h===84?p=30:h>100&&(p=20),s==="mobile"&&(i.style.bottom=p===30?"-50px":"-25px"),i.style.width=`${p*2}px`,i.style.height=`${p*2}px`,i.classList.add("lc-wa-ready")}).observe(r)};c?d(c):a(l,r=>d(r),{interval:300,maxRetries:130}),t.deviceType==="mobile"?n?(i.style.left=t.mobile.left,i.style.right="auto"):(i.style.right=t.mobile.right,i.style.left="auto"):(i.style.bottom=t.desktop.bottom,n?(i.style.right=t.desktop.right,i.style.left="auto"):(i.style.left=t.desktop.left,i.style.right="auto"))}function a(t,s,{interval:e=300,maxRetries:o=100}={}){let n=0;const i=setInterval(()=>{const l=document.querySelector(t);if(l){clearInterval(i),s(l);return}++n>=o&&clearInterval(i)},e)}let b=!1;const C=(t={})=>()=>{const s=t.whatsappConfig||{},e={enabled:!1,left:"8px",right:"8px"},o={enabled:!1,bottom:"-100px",left:"-43px",right:"-43px"},n={chatWidgetSelector:s.chatWidgetSelector||"#chat-widget-container",number:s.number||"",mobile:Object.assign({},e,s.mobile),desktop:Object.assign({},o,s.desktop)},i=S(),l=n[i];n.deviceType=i,l!=null&&l.enabled&&(a(u,()=>g(n)),a(n.chatWidgetSelector,()=>v(n)),b||(b=!0,document.addEventListener("turbolinks:load",()=>{a(u,()=>g(n)),a(n.chatWidgetSelector,()=>v(n))})))};window.commversion=window.commversion||{},window.LiveChatWidget.on("ready",C(window.commversion))})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commversion/libs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"author": "Commversion",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"scripts": {
|
|
@@ -58,7 +58,9 @@
|
|
|
58
58
|
"dev:lc-whatsapp-widget-combo": "vite serve scripts/lc-whatsapp-widget-combo/src/",
|
|
59
59
|
"build:lc-whatsapp-widget-combo": "vite build -c scripts/lc-whatsapp-widget-combo/vite.config.js",
|
|
60
60
|
"dev:lc-whatsapp-widget-only": "vite serve scripts/lc-whatsapp-widget-only/src/",
|
|
61
|
-
"build:lc-whatsapp-widget-only": "vite build -c scripts/lc-whatsapp-widget-only/vite.config.js"
|
|
61
|
+
"build:lc-whatsapp-widget-only": "vite build -c scripts/lc-whatsapp-widget-only/vite.config.js",
|
|
62
|
+
"dev:lc-channel-widgets": "vite serve scripts/lc-channel-widgets/src/",
|
|
63
|
+
"build:lc-channel-widgets": "vite build -c scripts/lc-channel-widgets/vite.config.js"
|
|
62
64
|
},
|
|
63
65
|
"publishConfig": {
|
|
64
66
|
"access": "public"
|