@pocketping/widget 2.2.0 → 2.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.cjs +32 -5
- package/dist/index.js +32 -5
- package/dist/pocketping.min.global.js +4 -4
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -705,7 +705,7 @@ function styles(options) {
|
|
|
705
705
|
|
|
706
706
|
.pp-input-form {
|
|
707
707
|
display: flex;
|
|
708
|
-
padding:
|
|
708
|
+
padding: 12px 10px 6px;
|
|
709
709
|
gap: 8px;
|
|
710
710
|
background: ${resolvedFooterColor};
|
|
711
711
|
align-items: flex-end;
|
|
@@ -2991,9 +2991,23 @@ function AttachmentDisplay({ attachment }) {
|
|
|
2991
2991
|
}
|
|
2992
2992
|
|
|
2993
2993
|
// src/version.ts
|
|
2994
|
-
var VERSION = "0.3.
|
|
2994
|
+
var VERSION = "0.3.8";
|
|
2995
2995
|
|
|
2996
2996
|
// src/client.ts
|
|
2997
|
+
function detectBotSignals() {
|
|
2998
|
+
return {
|
|
2999
|
+
// navigator.webdriver is true in Puppeteer/Selenium/Playwright
|
|
3000
|
+
webdriver: !!navigator.webdriver,
|
|
3001
|
+
// Headless browsers typically have no plugins
|
|
3002
|
+
plugins: navigator.plugins.length === 0,
|
|
3003
|
+
// Headless browsers may have empty languages
|
|
3004
|
+
languages: navigator.languages.length === 0,
|
|
3005
|
+
// HeadlessChrome doesn't have window.chrome
|
|
3006
|
+
chrome: /Chrome/.test(navigator.userAgent) && typeof window.chrome === "undefined",
|
|
3007
|
+
// Notification permission in headless is often 'denied' by default
|
|
3008
|
+
permissions: typeof Notification !== "undefined" && Notification.permission === "denied"
|
|
3009
|
+
};
|
|
3010
|
+
}
|
|
2997
3011
|
var PocketPingClient = class {
|
|
2998
3012
|
constructor(config) {
|
|
2999
3013
|
this.session = null;
|
|
@@ -3044,7 +3058,8 @@ var PocketPingClient = class {
|
|
|
3044
3058
|
userAgent: navigator.userAgent,
|
|
3045
3059
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
3046
3060
|
language: navigator.language,
|
|
3047
|
-
screenResolution: `${window.screen.width}x${window.screen.height}
|
|
3061
|
+
screenResolution: `${window.screen.width}x${window.screen.height}`,
|
|
3062
|
+
botSignals: detectBotSignals()
|
|
3048
3063
|
},
|
|
3049
3064
|
// Include stored identity if available
|
|
3050
3065
|
identity: storedIdentity || void 0
|
|
@@ -4315,7 +4330,11 @@ var PocketPingClient = class {
|
|
|
4315
4330
|
// Visitor Disconnect Notification
|
|
4316
4331
|
// ─────────────────────────────────────────────────────────────────
|
|
4317
4332
|
setupUnloadListeners() {
|
|
4318
|
-
|
|
4333
|
+
console.log("[PocketPing] Setting up unload listeners");
|
|
4334
|
+
this.boundHandleUnload = () => {
|
|
4335
|
+
console.log("[PocketPing] beforeunload/pagehide fired");
|
|
4336
|
+
this.notifyDisconnect();
|
|
4337
|
+
};
|
|
4319
4338
|
window.addEventListener("beforeunload", this.boundHandleUnload);
|
|
4320
4339
|
window.addEventListener("pagehide", this.boundHandleUnload);
|
|
4321
4340
|
this.boundHandleVisibilityChange = () => {
|
|
@@ -4343,7 +4362,13 @@ var PocketPingClient = class {
|
|
|
4343
4362
|
* Uses sendBeacon for reliability on page unload
|
|
4344
4363
|
*/
|
|
4345
4364
|
notifyDisconnect() {
|
|
4365
|
+
console.log("[PocketPing] notifyDisconnect called", {
|
|
4366
|
+
disconnectNotified: this.disconnectNotified,
|
|
4367
|
+
hasSession: !!this.session,
|
|
4368
|
+
sessionId: this.session?.sessionId
|
|
4369
|
+
});
|
|
4346
4370
|
if (this.disconnectNotified || !this.session) {
|
|
4371
|
+
console.log("[PocketPing] Skipping disconnect notification (already notified or no session)");
|
|
4347
4372
|
return;
|
|
4348
4373
|
}
|
|
4349
4374
|
this.disconnectNotified = true;
|
|
@@ -4354,9 +4379,11 @@ var PocketPingClient = class {
|
|
|
4354
4379
|
duration: sessionDuration,
|
|
4355
4380
|
reason: "page_unload"
|
|
4356
4381
|
});
|
|
4382
|
+
console.log("[PocketPing] Sending disconnect beacon to:", url, "data:", data);
|
|
4357
4383
|
if (navigator.sendBeacon) {
|
|
4358
4384
|
const blob = new Blob([data], { type: "application/json" });
|
|
4359
|
-
navigator.sendBeacon(url, blob);
|
|
4385
|
+
const success = navigator.sendBeacon(url, blob);
|
|
4386
|
+
console.log("[PocketPing] sendBeacon result:", success);
|
|
4360
4387
|
} else {
|
|
4361
4388
|
try {
|
|
4362
4389
|
const xhr = new XMLHttpRequest();
|
package/dist/index.js
CHANGED
|
@@ -664,7 +664,7 @@ function styles(options) {
|
|
|
664
664
|
|
|
665
665
|
.pp-input-form {
|
|
666
666
|
display: flex;
|
|
667
|
-
padding:
|
|
667
|
+
padding: 12px 10px 6px;
|
|
668
668
|
gap: 8px;
|
|
669
669
|
background: ${resolvedFooterColor};
|
|
670
670
|
align-items: flex-end;
|
|
@@ -2950,9 +2950,23 @@ function AttachmentDisplay({ attachment }) {
|
|
|
2950
2950
|
}
|
|
2951
2951
|
|
|
2952
2952
|
// src/version.ts
|
|
2953
|
-
var VERSION = "0.3.
|
|
2953
|
+
var VERSION = "0.3.8";
|
|
2954
2954
|
|
|
2955
2955
|
// src/client.ts
|
|
2956
|
+
function detectBotSignals() {
|
|
2957
|
+
return {
|
|
2958
|
+
// navigator.webdriver is true in Puppeteer/Selenium/Playwright
|
|
2959
|
+
webdriver: !!navigator.webdriver,
|
|
2960
|
+
// Headless browsers typically have no plugins
|
|
2961
|
+
plugins: navigator.plugins.length === 0,
|
|
2962
|
+
// Headless browsers may have empty languages
|
|
2963
|
+
languages: navigator.languages.length === 0,
|
|
2964
|
+
// HeadlessChrome doesn't have window.chrome
|
|
2965
|
+
chrome: /Chrome/.test(navigator.userAgent) && typeof window.chrome === "undefined",
|
|
2966
|
+
// Notification permission in headless is often 'denied' by default
|
|
2967
|
+
permissions: typeof Notification !== "undefined" && Notification.permission === "denied"
|
|
2968
|
+
};
|
|
2969
|
+
}
|
|
2956
2970
|
var PocketPingClient = class {
|
|
2957
2971
|
constructor(config) {
|
|
2958
2972
|
this.session = null;
|
|
@@ -3003,7 +3017,8 @@ var PocketPingClient = class {
|
|
|
3003
3017
|
userAgent: navigator.userAgent,
|
|
3004
3018
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
3005
3019
|
language: navigator.language,
|
|
3006
|
-
screenResolution: `${window.screen.width}x${window.screen.height}
|
|
3020
|
+
screenResolution: `${window.screen.width}x${window.screen.height}`,
|
|
3021
|
+
botSignals: detectBotSignals()
|
|
3007
3022
|
},
|
|
3008
3023
|
// Include stored identity if available
|
|
3009
3024
|
identity: storedIdentity || void 0
|
|
@@ -4274,7 +4289,11 @@ var PocketPingClient = class {
|
|
|
4274
4289
|
// Visitor Disconnect Notification
|
|
4275
4290
|
// ─────────────────────────────────────────────────────────────────
|
|
4276
4291
|
setupUnloadListeners() {
|
|
4277
|
-
|
|
4292
|
+
console.log("[PocketPing] Setting up unload listeners");
|
|
4293
|
+
this.boundHandleUnload = () => {
|
|
4294
|
+
console.log("[PocketPing] beforeunload/pagehide fired");
|
|
4295
|
+
this.notifyDisconnect();
|
|
4296
|
+
};
|
|
4278
4297
|
window.addEventListener("beforeunload", this.boundHandleUnload);
|
|
4279
4298
|
window.addEventListener("pagehide", this.boundHandleUnload);
|
|
4280
4299
|
this.boundHandleVisibilityChange = () => {
|
|
@@ -4302,7 +4321,13 @@ var PocketPingClient = class {
|
|
|
4302
4321
|
* Uses sendBeacon for reliability on page unload
|
|
4303
4322
|
*/
|
|
4304
4323
|
notifyDisconnect() {
|
|
4324
|
+
console.log("[PocketPing] notifyDisconnect called", {
|
|
4325
|
+
disconnectNotified: this.disconnectNotified,
|
|
4326
|
+
hasSession: !!this.session,
|
|
4327
|
+
sessionId: this.session?.sessionId
|
|
4328
|
+
});
|
|
4305
4329
|
if (this.disconnectNotified || !this.session) {
|
|
4330
|
+
console.log("[PocketPing] Skipping disconnect notification (already notified or no session)");
|
|
4306
4331
|
return;
|
|
4307
4332
|
}
|
|
4308
4333
|
this.disconnectNotified = true;
|
|
@@ -4313,9 +4338,11 @@ var PocketPingClient = class {
|
|
|
4313
4338
|
duration: sessionDuration,
|
|
4314
4339
|
reason: "page_unload"
|
|
4315
4340
|
});
|
|
4341
|
+
console.log("[PocketPing] Sending disconnect beacon to:", url, "data:", data);
|
|
4316
4342
|
if (navigator.sendBeacon) {
|
|
4317
4343
|
const blob = new Blob([data], { type: "application/json" });
|
|
4318
|
-
navigator.sendBeacon(url, blob);
|
|
4344
|
+
const success = navigator.sendBeacon(url, blob);
|
|
4345
|
+
console.log("[PocketPing] sendBeacon result:", success);
|
|
4319
4346
|
} else {
|
|
4320
4347
|
try {
|
|
4321
4348
|
const xhr = new XMLHttpRequest();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var PocketPing=(()=>{var bt=Object.defineProperty;var ko=Object.getOwnPropertyDescriptor;var So=Object.getOwnPropertyNames;var No=Object.prototype.hasOwnProperty;var Io=(t,e)=>{for(var n in e)bt(t,n,{get:e[n],enumerable:!0})},To=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of So(e))!No.call(t,o)&&o!==n&&bt(t,o,{get:()=>e[o],enumerable:!(r=ko(e,o))||r.enumerable});return t};var Oo=t=>To(bt({},"__esModule",{value:!0}),t);var Vd={};Io(Vd,{close:()=>Xr,default:()=>Gd,destroy:()=>zr,getIdentity:()=>so,getTrackedElements:()=>to,identify:()=>oo,init:()=>ln,offEvent:()=>ro,on:()=>ao,onEvent:()=>no,open:()=>Kr,reset:()=>io,sendMessage:()=>qr,setupTrackedElements:()=>eo,toggle:()=>Yr,trigger:()=>Qr,uploadFile:()=>Jr,uploadFiles:()=>Zr});var et,T,Cn,Ao,le,yn,Pn,En,kn,_t,vt,yt,Mo,Ee={},Sn=[],Fo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,tt=Array.isArray;function oe(t,e){for(var n in e)t[n]=e[n];return t}function wt(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Ct(t,e,n){var r,o,d,i={};for(d in e)d=="key"?r=e[d]:d=="ref"?o=e[d]:i[d]=e[d];if(arguments.length>2&&(i.children=arguments.length>3?et.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(d in t.defaultProps)i[d]===void 0&&(i[d]=t.defaultProps[d]);return Je(t,i,r,o,null)}function Je(t,e,n,r,o){var d={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++Cn,__i:-1,__u:0};return o==null&&T.vnode!=null&&T.vnode(d),d}function D(t){return t.children}function Ze(t,e){this.props=t,this.context=e}function he(t,e){if(e==null)return t.__?he(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?he(t):null}function Nn(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Nn(t)}}function xn(t){(!t.__d&&(t.__d=!0)&&le.push(t)&&!Qe.__r++||yn!=T.debounceRendering)&&((yn=T.debounceRendering)||Pn)(Qe)}function Qe(){for(var t,e,n,r,o,d,i,s=1;le.length;)le.length>s&&le.sort(En),t=le.shift(),s=le.length,t.__d&&(n=void 0,r=void 0,o=(r=(e=t).__v).__e,d=[],i=[],e.__P&&((n=oe({},r)).__v=r.__v+1,T.vnode&&T.vnode(n),Pt(e.__P,n,r,e.__n,e.__P.namespaceURI,32&r.__u?[o]:null,d,o??he(r),!!(32&r.__u),i),n.__v=r.__v,n.__.__k[n.__i]=n,On(d,n,i),r.__e=r.__=null,n.__e!=o&&Nn(n)));Qe.__r=0}function In(t,e,n,r,o,d,i,s,p,l,f){var c,$,h,C,k,E,m,_=r&&r.__k||Sn,M=e.length;for(p=Ro(n,e,_,p,M),c=0;c<M;c++)(h=n.__k[c])!=null&&($=h.__i==-1?Ee:_[h.__i]||Ee,h.__i=c,E=Pt(t,h,$,o,d,i,s,p,l,f),C=h.__e,h.ref&&$.ref!=h.ref&&($.ref&&Et($.ref,null,h),f.push(h.ref,h.__c||C,h)),k==null&&C!=null&&(k=C),(m=!!(4&h.__u))||$.__k===h.__k?p=Tn(h,p,t,m):typeof h.type=="function"&&E!==void 0?p=E:C&&(p=C.nextSibling),h.__u&=-7);return n.__e=k,p}function Ro(t,e,n,r,o){var d,i,s,p,l,f=n.length,c=f,$=0;for(t.__k=new Array(o),d=0;d<o;d++)(i=e[d])!=null&&typeof i!="boolean"&&typeof i!="function"?(typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?i=t.__k[d]=Je(null,i,null,null,null):tt(i)?i=t.__k[d]=Je(D,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?i=t.__k[d]=Je(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):t.__k[d]=i,p=d+$,i.__=t,i.__b=t.__b+1,s=null,(l=i.__i=Lo(i,n,p,c))!=-1&&(c--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(o>f?$--:o<f&&$++),typeof i.type!="function"&&(i.__u|=4)):l!=p&&(l==p-1?$--:l==p+1?$++:(l>p?$--:$++,i.__u|=4))):t.__k[d]=null;if(c)for(d=0;d<f;d++)(s=n[d])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=he(s)),Mn(s,s));return r}function Tn(t,e,n,r){var o,d;if(typeof t.type=="function"){for(o=t.__k,d=0;o&&d<o.length;d++)o[d]&&(o[d].__=t,e=Tn(o[d],e,n,r));return e}t.__e!=e&&(r&&(e&&t.type&&!e.parentNode&&(e=he(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Lo(t,e,n,r){var o,d,i,s=t.key,p=t.type,l=e[n],f=l!=null&&(2&l.__u)==0;if(l===null&&s==null||f&&s==l.key&&p==l.type)return n;if(r>(f?1:0)){for(o=n-1,d=n+1;o>=0||d<e.length;)if((l=e[i=o>=0?o--:d++])!=null&&(2&l.__u)==0&&s==l.key&&p==l.type)return i}return-1}function _n(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Fo.test(e)?n:n+"px"}function qe(t,e,n,r,o){var d,i;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||_n(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||_n(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")d=e!=(e=e.replace(kn,"$1")),i=e.toLowerCase(),e=i in t||e=="onFocusOut"||e=="onFocusIn"?i.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+d]=n,n?r?n.u=r.u:(n.u=_t,t.addEventListener(e,d?yt:vt,d)):t.removeEventListener(e,d?yt:vt,d);else{if(o=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function wn(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=_t++;else if(e.t<n.u)return;return n(T.event?T.event(e):e)}}}function Pt(t,e,n,r,o,d,i,s,p,l){var f,c,$,h,C,k,E,m,_,M,F,x,U,J,L,V,j,R=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(p=!!(32&n.__u),d=[s=e.__e=n.__e]),(f=T.__b)&&f(e);e:if(typeof R=="function")try{if(m=e.props,_="prototype"in R&&R.prototype.render,M=(f=R.contextType)&&r[f.__c],F=f?M?M.props.value:f.__:r,n.__c?E=(c=e.__c=n.__c).__=c.__E:(_?e.__c=c=new R(m,F):(e.__c=c=new Ze(m,F),c.constructor=R,c.render=Ho),M&&M.sub(c),c.state||(c.state={}),c.__n=r,$=c.__d=!0,c.__h=[],c._sb=[]),_&&c.__s==null&&(c.__s=c.state),_&&R.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=oe({},c.__s)),oe(c.__s,R.getDerivedStateFromProps(m,c.__s))),h=c.props,C=c.state,c.__v=e,$)_&&R.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),_&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(_&&R.getDerivedStateFromProps==null&&m!==h&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(m,F),e.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(m,c.__s,F)===!1){for(e.__v!=n.__v&&(c.props=m,c.state=c.__s,c.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(Y){Y&&(Y.__=e)}),x=0;x<c._sb.length;x++)c.__h.push(c._sb[x]);c._sb=[],c.__h.length&&i.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(m,c.__s,F),_&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(h,C,k)})}if(c.context=F,c.props=m,c.__P=t,c.__e=!1,U=T.__r,J=0,_){for(c.state=c.__s,c.__d=!1,U&&U(e),f=c.render(c.props,c.state,c.context),L=0;L<c._sb.length;L++)c.__h.push(c._sb[L]);c._sb=[]}else do c.__d=!1,U&&U(e),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++J<25);c.state=c.__s,c.getChildContext!=null&&(r=oe(oe({},r),c.getChildContext())),_&&!$&&c.getSnapshotBeforeUpdate!=null&&(k=c.getSnapshotBeforeUpdate(h,C)),V=f,f!=null&&f.type===D&&f.key==null&&(V=An(f.props.children)),s=In(t,tt(V)?V:[V],e,n,r,o,d,i,s,p,l),c.base=e.__e,e.__u&=-161,c.__h.length&&i.push(c),E&&(c.__E=c.__=null)}catch(Y){if(e.__v=null,p||d!=null)if(Y.then){for(e.__u|=p?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;d[d.indexOf(s)]=null,e.__e=s}else{for(j=d.length;j--;)wt(d[j]);xt(e)}else e.__e=n.__e,e.__k=n.__k,Y.then||xt(e);T.__e(Y,e,n)}else d==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):s=e.__e=Do(n.__e,e,n,r,o,d,i,p,l);return(f=T.diffed)&&f(e),128&e.__u?void 0:s}function xt(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(xt)}function On(t,e,n){for(var r=0;r<n.length;r++)Et(n[r],n[++r],n[++r]);T.__c&&T.__c(e,t),t.some(function(o){try{t=o.__h,o.__h=[],t.some(function(d){d.call(o)})}catch(d){T.__e(d,o.__v)}})}function An(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:tt(t)?t.map(An):oe({},t)}function Do(t,e,n,r,o,d,i,s,p){var l,f,c,$,h,C,k,E=n.props||Ee,m=e.props,_=e.type;if(_=="svg"?o="http://www.w3.org/2000/svg":_=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),d!=null){for(l=0;l<d.length;l++)if((h=d[l])&&"setAttribute"in h==!!_&&(_?h.localName==_:h.nodeType==3)){t=h,d[l]=null;break}}if(t==null){if(_==null)return document.createTextNode(m);t=document.createElementNS(o,_,m.is&&m),s&&(T.__m&&T.__m(e,d),s=!1),d=null}if(_==null)E===m||s&&t.data==m||(t.data=m);else{if(d=d&&et.call(t.childNodes),!s&&d!=null)for(E={},l=0;l<t.attributes.length;l++)E[(h=t.attributes[l]).name]=h.value;for(l in E)if(h=E[l],l!="children"){if(l=="dangerouslySetInnerHTML")c=h;else if(!(l in m)){if(l=="value"&&"defaultValue"in m||l=="checked"&&"defaultChecked"in m)continue;qe(t,l,null,h,o)}}for(l in m)h=m[l],l=="children"?$=h:l=="dangerouslySetInnerHTML"?f=h:l=="value"?C=h:l=="checked"?k=h:s&&typeof h!="function"||E[l]===h||qe(t,l,h,E[l],o);if(f)s||c&&(f.__html==c.__html||f.__html==t.innerHTML)||(t.innerHTML=f.__html),e.__k=[];else if(c&&(t.innerHTML=""),In(e.type=="template"?t.content:t,tt($)?$:[$],e,n,r,_=="foreignObject"?"http://www.w3.org/1999/xhtml":o,d,i,d?d[0]:n.__k&&he(n,0),s,p),d!=null)for(l=d.length;l--;)wt(d[l]);s||(l="value",_=="progress"&&C==null?t.removeAttribute("value"):C!=null&&(C!==t[l]||_=="progress"&&!C||_=="option"&&C!=E[l])&&qe(t,l,C,E[l],o),l="checked",k!=null&&k!=t[l]&&qe(t,l,k,E[l],o))}return t}function Et(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(o){T.__e(o,n)}}function Mn(t,e,n){var r,o;if(T.unmount&&T.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||Et(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(d){T.__e(d,e)}r.base=r.__P=null}if(r=t.__k)for(o=0;o<r.length;o++)r[o]&&Mn(r[o],e,n||typeof t.type!="function");n||wt(t.__e),t.__c=t.__=t.__e=void 0}function Ho(t,e,n){return this.constructor(t,n)}function kt(t,e,n){var r,o,d,i;e==document&&(e=document.documentElement),T.__&&T.__(t,e),o=(r=typeof n=="function")?null:n&&n.__k||e.__k,d=[],i=[],Pt(e,t=(!r&&n||e).__k=Ct(D,null,[t]),o||Ee,Ee,e.namespaceURI,!r&&n?[n]:o?null:e.firstChild?et.call(e.childNodes):null,d,!r&&n?n:o?o.__e:e.firstChild,r,i),On(d,t,i)}et=Sn.slice,T={__e:function(t,e,n,r){for(var o,d,i;e=e.__;)if((o=e.__c)&&!o.__)try{if((d=o.constructor)&&d.getDerivedStateFromError!=null&&(o.setState(d.getDerivedStateFromError(t)),i=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(t,r||{}),i=o.__d),i)return o.__E=o}catch(s){t=s}throw t}},Cn=0,Ao=function(t){return t!=null&&t.constructor===void 0},Ze.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=oe({},this.state),typeof t=="function"&&(t=t(oe({},n),this.props)),t&&oe(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),xn(this))},Ze.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),xn(this))},Ze.prototype.render=D,le=[],Pn=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,En=function(t,e){return t.__v.__b-e.__v.__b},Qe.__r=0,kn=/(PointerCapture)$|Capture$/i,_t=0,vt=wn(!1),yt=wn(!0),Mo=0;var ke,H,St,Fn,Se=0,Gn=[],B=T,Rn=B.__b,Ln=B.__r,Dn=B.diffed,Hn=B.__c,Un=B.unmount,Bn=B.__;function It(t,e){B.__h&&B.__h(H,t,Se||e),Se=0;var n=H.__H||(H.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function N(t){return Se=1,Uo(Kn,t)}function Uo(t,e,n){var r=It(ke++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):Kn(void 0,e),function(s){var p=r.__N?r.__N[0]:r.__[0],l=r.t(p,s);p!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=H,!H.__f)){var o=function(s,p,l){if(!r.__c.__H)return!0;var f=r.__c.__H.__.filter(function($){return!!$.__c});if(f.every(function($){return!$.__N}))return!d||d.call(this,s,p,l);var c=r.__c.props!==s;return f.forEach(function($){if($.__N){var h=$.__[0];$.__=$.__N,$.__N=void 0,h!==$.__[0]&&(c=!0)}}),d&&d.call(this,s,p,l)||c};H.__f=!0;var d=H.shouldComponentUpdate,i=H.componentWillUpdate;H.componentWillUpdate=function(s,p,l){if(this.__e){var f=d;d=void 0,o(s,p,l),d=f}i&&i.call(this,s,p,l)},H.shouldComponentUpdate=o}return r.__N||r.__}function q(t,e){var n=It(ke++,3);!B.__s&&zn(n.__H,e)&&(n.__=t,n.u=e,H.__H.__h.push(n))}function ne(t){return Se=5,Vn(function(){return{current:t}},[])}function Vn(t,e){var n=It(ke++,7);return zn(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function Wn(t,e){return Se=8,Vn(function(){return t},e)}function Bo(){for(var t;t=Gn.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(nt),t.__H.__h.forEach(Nt),t.__H.__h=[]}catch(e){t.__H.__h=[],B.__e(e,t.__v)}}B.__b=function(t){H=null,Rn&&Rn(t)},B.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Bn&&Bn(t,e)},B.__r=function(t){Ln&&Ln(t),ke=0;var e=(H=t.__c).__H;e&&(St===H?(e.__h=[],H.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(nt),e.__h.forEach(Nt),e.__h=[],ke=0)),St=H},B.diffed=function(t){Dn&&Dn(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Gn.push(e)!==1&&Fn===B.requestAnimationFrame||((Fn=B.requestAnimationFrame)||jo)(Bo)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),St=H=null},B.__c=function(t,e){e.some(function(n){try{n.__h.forEach(nt),n.__h=n.__h.filter(function(r){return!r.__||Nt(r)})}catch(r){e.some(function(o){o.__h&&(o.__h=[])}),e=[],B.__e(r,n.__v)}}),Hn&&Hn(t,e)},B.unmount=function(t){Un&&Un(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{nt(r)}catch(o){e=o}}),n.__H=void 0,e&&B.__e(e,n.__v))};var jn=typeof requestAnimationFrame=="function";function jo(t){var e,n=function(){clearTimeout(r),jn&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);jn&&(e=requestAnimationFrame(n))}function nt(t){var e=H,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),H=e}function Nt(t){var e=H;t.__c=t.__(),H=e}function zn(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function Kn(t,e){return typeof e=="function"?e(t):e}var ge={from:"#36e3ff",to:"#7c5cff",direction:"to right"};function ot(t){return typeof t=="object"&&t!==null&&"from"in t&&"to"in t}function Tt(t){return ot(t)?`linear-gradient(${t.direction||"to right"}, ${t.from}, ${t.to})`:t}function Ot(t){return ot(t)?t.to:t}function rt(t,e,n,r){if(!t)return Tt(e?r:n);if(typeof t=="string")return t;if(ot(t))return Tt(t);let o=e?t.dark:t.light;return Tt(o)}function Xn(t,e,n,r){if(!t)return Ot(e?r:n);if(typeof t=="string")return t;if(ot(t))return Ot(t);let o=e?t.dark:t.light;return Ot(o)}function Yn(t){let{primaryColor:e,theme:n,headerColor:r,footerColor:o,chatBackground:d,toggleColor:i}=t,s=n==="dark",p=rt(r,s,ge,"#202c33"),l=rt(o,s,"#f0f2f5","#202c33"),f=rt(i,s,ge,ge),c=Xn(r,s,ge,"#202c33"),$=Xn(i,s,ge,ge),h=U($,-15),C=U(c,-15),k=s?`url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`:`url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`,E=s?`url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='10' cy='10' r='1' fill='%23ffffff' fill-opacity='0.05'/%3E%3C/svg%3E")`:`url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='10' cy='10' r='1' fill='%23000000' fill-opacity='0.05'/%3E%3C/svg%3E")`,m=rt(d,s,"whatsapp","whatsapp"),_=s?"#0b141a":"#e5ddd5",M=k,F="auto";m==="plain"?M="none":m==="dots"?M=E:m==="whatsapp"||!m?M=k:(m.startsWith("http")||m.startsWith("/")||m.startsWith("data:"))&&(M=`url("${m}")`,F="cover");let x={bg:s?"#1f2937":"#ffffff",bgSecondary:s?"#374151":"#f3f4f6",text:s?"#f9fafb":"#111827",textSecondary:s?"#9ca3af":"#6b7280",border:s?"#4b5563":"#e5e7eb",messageBg:s?"#374151":"#f3f4f6"};function U(J,L){let V=parseInt(J.replace("#",""),16),j=Math.min(255,Math.max(0,(V>>16)+L)),R=Math.min(255,Math.max(0,(V>>8&255)+L)),Y=Math.min(255,Math.max(0,(V&255)+L));return"#"+(16777216+(j<<16)+(R<<8)+Y).toString(16).slice(1)}return`
|
|
1
|
+
"use strict";var PocketPing=(()=>{var bt=Object.defineProperty;var ko=Object.getOwnPropertyDescriptor;var So=Object.getOwnPropertyNames;var No=Object.prototype.hasOwnProperty;var Io=(t,e)=>{for(var n in e)bt(t,n,{get:e[n],enumerable:!0})},To=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of So(e))!No.call(t,o)&&o!==n&&bt(t,o,{get:()=>e[o],enumerable:!(r=ko(e,o))||r.enumerable});return t};var Oo=t=>To(bt({},"__esModule",{value:!0}),t);var Wd={};Io(Wd,{close:()=>Xr,default:()=>Vd,destroy:()=>zr,getIdentity:()=>so,getTrackedElements:()=>to,identify:()=>oo,init:()=>ln,offEvent:()=>ro,on:()=>ao,onEvent:()=>no,open:()=>Kr,reset:()=>io,sendMessage:()=>qr,setupTrackedElements:()=>eo,toggle:()=>Yr,trigger:()=>Qr,uploadFile:()=>Jr,uploadFiles:()=>Zr});var et,T,Cn,Ao,le,yn,Pn,En,kn,_t,vt,yt,Mo,Ee={},Sn=[],Fo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,tt=Array.isArray;function oe(t,e){for(var n in e)t[n]=e[n];return t}function wt(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Ct(t,e,n){var r,o,d,i={};for(d in e)d=="key"?r=e[d]:d=="ref"?o=e[d]:i[d]=e[d];if(arguments.length>2&&(i.children=arguments.length>3?et.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(d in t.defaultProps)i[d]===void 0&&(i[d]=t.defaultProps[d]);return Je(t,i,r,o,null)}function Je(t,e,n,r,o){var d={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++Cn,__i:-1,__u:0};return o==null&&T.vnode!=null&&T.vnode(d),d}function D(t){return t.children}function Ze(t,e){this.props=t,this.context=e}function he(t,e){if(e==null)return t.__?he(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?he(t):null}function Nn(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Nn(t)}}function xn(t){(!t.__d&&(t.__d=!0)&&le.push(t)&&!Qe.__r++||yn!=T.debounceRendering)&&((yn=T.debounceRendering)||Pn)(Qe)}function Qe(){for(var t,e,n,r,o,d,i,s=1;le.length;)le.length>s&&le.sort(En),t=le.shift(),s=le.length,t.__d&&(n=void 0,r=void 0,o=(r=(e=t).__v).__e,d=[],i=[],e.__P&&((n=oe({},r)).__v=r.__v+1,T.vnode&&T.vnode(n),Pt(e.__P,n,r,e.__n,e.__P.namespaceURI,32&r.__u?[o]:null,d,o??he(r),!!(32&r.__u),i),n.__v=r.__v,n.__.__k[n.__i]=n,On(d,n,i),r.__e=r.__=null,n.__e!=o&&Nn(n)));Qe.__r=0}function In(t,e,n,r,o,d,i,s,p,l,f){var c,$,h,C,k,E,m,_=r&&r.__k||Sn,M=e.length;for(p=Ro(n,e,_,p,M),c=0;c<M;c++)(h=n.__k[c])!=null&&($=h.__i==-1?Ee:_[h.__i]||Ee,h.__i=c,E=Pt(t,h,$,o,d,i,s,p,l,f),C=h.__e,h.ref&&$.ref!=h.ref&&($.ref&&Et($.ref,null,h),f.push(h.ref,h.__c||C,h)),k==null&&C!=null&&(k=C),(m=!!(4&h.__u))||$.__k===h.__k?p=Tn(h,p,t,m):typeof h.type=="function"&&E!==void 0?p=E:C&&(p=C.nextSibling),h.__u&=-7);return n.__e=k,p}function Ro(t,e,n,r,o){var d,i,s,p,l,f=n.length,c=f,$=0;for(t.__k=new Array(o),d=0;d<o;d++)(i=e[d])!=null&&typeof i!="boolean"&&typeof i!="function"?(typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?i=t.__k[d]=Je(null,i,null,null,null):tt(i)?i=t.__k[d]=Je(D,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?i=t.__k[d]=Je(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):t.__k[d]=i,p=d+$,i.__=t,i.__b=t.__b+1,s=null,(l=i.__i=Lo(i,n,p,c))!=-1&&(c--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(o>f?$--:o<f&&$++),typeof i.type!="function"&&(i.__u|=4)):l!=p&&(l==p-1?$--:l==p+1?$++:(l>p?$--:$++,i.__u|=4))):t.__k[d]=null;if(c)for(d=0;d<f;d++)(s=n[d])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=he(s)),Mn(s,s));return r}function Tn(t,e,n,r){var o,d;if(typeof t.type=="function"){for(o=t.__k,d=0;o&&d<o.length;d++)o[d]&&(o[d].__=t,e=Tn(o[d],e,n,r));return e}t.__e!=e&&(r&&(e&&t.type&&!e.parentNode&&(e=he(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Lo(t,e,n,r){var o,d,i,s=t.key,p=t.type,l=e[n],f=l!=null&&(2&l.__u)==0;if(l===null&&s==null||f&&s==l.key&&p==l.type)return n;if(r>(f?1:0)){for(o=n-1,d=n+1;o>=0||d<e.length;)if((l=e[i=o>=0?o--:d++])!=null&&(2&l.__u)==0&&s==l.key&&p==l.type)return i}return-1}function _n(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Fo.test(e)?n:n+"px"}function qe(t,e,n,r,o){var d,i;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||_n(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||_n(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")d=e!=(e=e.replace(kn,"$1")),i=e.toLowerCase(),e=i in t||e=="onFocusOut"||e=="onFocusIn"?i.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+d]=n,n?r?n.u=r.u:(n.u=_t,t.addEventListener(e,d?yt:vt,d)):t.removeEventListener(e,d?yt:vt,d);else{if(o=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function wn(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=_t++;else if(e.t<n.u)return;return n(T.event?T.event(e):e)}}}function Pt(t,e,n,r,o,d,i,s,p,l){var f,c,$,h,C,k,E,m,_,M,F,x,U,J,L,V,j,R=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(p=!!(32&n.__u),d=[s=e.__e=n.__e]),(f=T.__b)&&f(e);e:if(typeof R=="function")try{if(m=e.props,_="prototype"in R&&R.prototype.render,M=(f=R.contextType)&&r[f.__c],F=f?M?M.props.value:f.__:r,n.__c?E=(c=e.__c=n.__c).__=c.__E:(_?e.__c=c=new R(m,F):(e.__c=c=new Ze(m,F),c.constructor=R,c.render=Ho),M&&M.sub(c),c.state||(c.state={}),c.__n=r,$=c.__d=!0,c.__h=[],c._sb=[]),_&&c.__s==null&&(c.__s=c.state),_&&R.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=oe({},c.__s)),oe(c.__s,R.getDerivedStateFromProps(m,c.__s))),h=c.props,C=c.state,c.__v=e,$)_&&R.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),_&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(_&&R.getDerivedStateFromProps==null&&m!==h&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(m,F),e.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(m,c.__s,F)===!1){for(e.__v!=n.__v&&(c.props=m,c.state=c.__s,c.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(Y){Y&&(Y.__=e)}),x=0;x<c._sb.length;x++)c.__h.push(c._sb[x]);c._sb=[],c.__h.length&&i.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(m,c.__s,F),_&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(h,C,k)})}if(c.context=F,c.props=m,c.__P=t,c.__e=!1,U=T.__r,J=0,_){for(c.state=c.__s,c.__d=!1,U&&U(e),f=c.render(c.props,c.state,c.context),L=0;L<c._sb.length;L++)c.__h.push(c._sb[L]);c._sb=[]}else do c.__d=!1,U&&U(e),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++J<25);c.state=c.__s,c.getChildContext!=null&&(r=oe(oe({},r),c.getChildContext())),_&&!$&&c.getSnapshotBeforeUpdate!=null&&(k=c.getSnapshotBeforeUpdate(h,C)),V=f,f!=null&&f.type===D&&f.key==null&&(V=An(f.props.children)),s=In(t,tt(V)?V:[V],e,n,r,o,d,i,s,p,l),c.base=e.__e,e.__u&=-161,c.__h.length&&i.push(c),E&&(c.__E=c.__=null)}catch(Y){if(e.__v=null,p||d!=null)if(Y.then){for(e.__u|=p?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;d[d.indexOf(s)]=null,e.__e=s}else{for(j=d.length;j--;)wt(d[j]);xt(e)}else e.__e=n.__e,e.__k=n.__k,Y.then||xt(e);T.__e(Y,e,n)}else d==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):s=e.__e=Do(n.__e,e,n,r,o,d,i,p,l);return(f=T.diffed)&&f(e),128&e.__u?void 0:s}function xt(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(xt)}function On(t,e,n){for(var r=0;r<n.length;r++)Et(n[r],n[++r],n[++r]);T.__c&&T.__c(e,t),t.some(function(o){try{t=o.__h,o.__h=[],t.some(function(d){d.call(o)})}catch(d){T.__e(d,o.__v)}})}function An(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:tt(t)?t.map(An):oe({},t)}function Do(t,e,n,r,o,d,i,s,p){var l,f,c,$,h,C,k,E=n.props||Ee,m=e.props,_=e.type;if(_=="svg"?o="http://www.w3.org/2000/svg":_=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),d!=null){for(l=0;l<d.length;l++)if((h=d[l])&&"setAttribute"in h==!!_&&(_?h.localName==_:h.nodeType==3)){t=h,d[l]=null;break}}if(t==null){if(_==null)return document.createTextNode(m);t=document.createElementNS(o,_,m.is&&m),s&&(T.__m&&T.__m(e,d),s=!1),d=null}if(_==null)E===m||s&&t.data==m||(t.data=m);else{if(d=d&&et.call(t.childNodes),!s&&d!=null)for(E={},l=0;l<t.attributes.length;l++)E[(h=t.attributes[l]).name]=h.value;for(l in E)if(h=E[l],l!="children"){if(l=="dangerouslySetInnerHTML")c=h;else if(!(l in m)){if(l=="value"&&"defaultValue"in m||l=="checked"&&"defaultChecked"in m)continue;qe(t,l,null,h,o)}}for(l in m)h=m[l],l=="children"?$=h:l=="dangerouslySetInnerHTML"?f=h:l=="value"?C=h:l=="checked"?k=h:s&&typeof h!="function"||E[l]===h||qe(t,l,h,E[l],o);if(f)s||c&&(f.__html==c.__html||f.__html==t.innerHTML)||(t.innerHTML=f.__html),e.__k=[];else if(c&&(t.innerHTML=""),In(e.type=="template"?t.content:t,tt($)?$:[$],e,n,r,_=="foreignObject"?"http://www.w3.org/1999/xhtml":o,d,i,d?d[0]:n.__k&&he(n,0),s,p),d!=null)for(l=d.length;l--;)wt(d[l]);s||(l="value",_=="progress"&&C==null?t.removeAttribute("value"):C!=null&&(C!==t[l]||_=="progress"&&!C||_=="option"&&C!=E[l])&&qe(t,l,C,E[l],o),l="checked",k!=null&&k!=t[l]&&qe(t,l,k,E[l],o))}return t}function Et(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(o){T.__e(o,n)}}function Mn(t,e,n){var r,o;if(T.unmount&&T.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||Et(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(d){T.__e(d,e)}r.base=r.__P=null}if(r=t.__k)for(o=0;o<r.length;o++)r[o]&&Mn(r[o],e,n||typeof t.type!="function");n||wt(t.__e),t.__c=t.__=t.__e=void 0}function Ho(t,e,n){return this.constructor(t,n)}function kt(t,e,n){var r,o,d,i;e==document&&(e=document.documentElement),T.__&&T.__(t,e),o=(r=typeof n=="function")?null:n&&n.__k||e.__k,d=[],i=[],Pt(e,t=(!r&&n||e).__k=Ct(D,null,[t]),o||Ee,Ee,e.namespaceURI,!r&&n?[n]:o?null:e.firstChild?et.call(e.childNodes):null,d,!r&&n?n:o?o.__e:e.firstChild,r,i),On(d,t,i)}et=Sn.slice,T={__e:function(t,e,n,r){for(var o,d,i;e=e.__;)if((o=e.__c)&&!o.__)try{if((d=o.constructor)&&d.getDerivedStateFromError!=null&&(o.setState(d.getDerivedStateFromError(t)),i=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(t,r||{}),i=o.__d),i)return o.__E=o}catch(s){t=s}throw t}},Cn=0,Ao=function(t){return t!=null&&t.constructor===void 0},Ze.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=oe({},this.state),typeof t=="function"&&(t=t(oe({},n),this.props)),t&&oe(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),xn(this))},Ze.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),xn(this))},Ze.prototype.render=D,le=[],Pn=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,En=function(t,e){return t.__v.__b-e.__v.__b},Qe.__r=0,kn=/(PointerCapture)$|Capture$/i,_t=0,vt=wn(!1),yt=wn(!0),Mo=0;var ke,H,St,Fn,Se=0,Gn=[],B=T,Rn=B.__b,Ln=B.__r,Dn=B.diffed,Hn=B.__c,Un=B.unmount,Bn=B.__;function It(t,e){B.__h&&B.__h(H,t,Se||e),Se=0;var n=H.__H||(H.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function N(t){return Se=1,Uo(Kn,t)}function Uo(t,e,n){var r=It(ke++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):Kn(void 0,e),function(s){var p=r.__N?r.__N[0]:r.__[0],l=r.t(p,s);p!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=H,!H.__f)){var o=function(s,p,l){if(!r.__c.__H)return!0;var f=r.__c.__H.__.filter(function($){return!!$.__c});if(f.every(function($){return!$.__N}))return!d||d.call(this,s,p,l);var c=r.__c.props!==s;return f.forEach(function($){if($.__N){var h=$.__[0];$.__=$.__N,$.__N=void 0,h!==$.__[0]&&(c=!0)}}),d&&d.call(this,s,p,l)||c};H.__f=!0;var d=H.shouldComponentUpdate,i=H.componentWillUpdate;H.componentWillUpdate=function(s,p,l){if(this.__e){var f=d;d=void 0,o(s,p,l),d=f}i&&i.call(this,s,p,l)},H.shouldComponentUpdate=o}return r.__N||r.__}function q(t,e){var n=It(ke++,3);!B.__s&&zn(n.__H,e)&&(n.__=t,n.u=e,H.__H.__h.push(n))}function ne(t){return Se=5,Vn(function(){return{current:t}},[])}function Vn(t,e){var n=It(ke++,7);return zn(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function Wn(t,e){return Se=8,Vn(function(){return t},e)}function Bo(){for(var t;t=Gn.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(nt),t.__H.__h.forEach(Nt),t.__H.__h=[]}catch(e){t.__H.__h=[],B.__e(e,t.__v)}}B.__b=function(t){H=null,Rn&&Rn(t)},B.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Bn&&Bn(t,e)},B.__r=function(t){Ln&&Ln(t),ke=0;var e=(H=t.__c).__H;e&&(St===H?(e.__h=[],H.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(nt),e.__h.forEach(Nt),e.__h=[],ke=0)),St=H},B.diffed=function(t){Dn&&Dn(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Gn.push(e)!==1&&Fn===B.requestAnimationFrame||((Fn=B.requestAnimationFrame)||jo)(Bo)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),St=H=null},B.__c=function(t,e){e.some(function(n){try{n.__h.forEach(nt),n.__h=n.__h.filter(function(r){return!r.__||Nt(r)})}catch(r){e.some(function(o){o.__h&&(o.__h=[])}),e=[],B.__e(r,n.__v)}}),Hn&&Hn(t,e)},B.unmount=function(t){Un&&Un(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{nt(r)}catch(o){e=o}}),n.__H=void 0,e&&B.__e(e,n.__v))};var jn=typeof requestAnimationFrame=="function";function jo(t){var e,n=function(){clearTimeout(r),jn&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);jn&&(e=requestAnimationFrame(n))}function nt(t){var e=H,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),H=e}function Nt(t){var e=H;t.__c=t.__(),H=e}function zn(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function Kn(t,e){return typeof e=="function"?e(t):e}var ge={from:"#36e3ff",to:"#7c5cff",direction:"to right"};function ot(t){return typeof t=="object"&&t!==null&&"from"in t&&"to"in t}function Tt(t){return ot(t)?`linear-gradient(${t.direction||"to right"}, ${t.from}, ${t.to})`:t}function Ot(t){return ot(t)?t.to:t}function rt(t,e,n,r){if(!t)return Tt(e?r:n);if(typeof t=="string")return t;if(ot(t))return Tt(t);let o=e?t.dark:t.light;return Tt(o)}function Xn(t,e,n,r){if(!t)return Ot(e?r:n);if(typeof t=="string")return t;if(ot(t))return Ot(t);let o=e?t.dark:t.light;return Ot(o)}function Yn(t){let{primaryColor:e,theme:n,headerColor:r,footerColor:o,chatBackground:d,toggleColor:i}=t,s=n==="dark",p=rt(r,s,ge,"#202c33"),l=rt(o,s,"#f0f2f5","#202c33"),f=rt(i,s,ge,ge),c=Xn(r,s,ge,"#202c33"),$=Xn(i,s,ge,ge),h=U($,-15),C=U(c,-15),k=s?`url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`:`url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`,E=s?`url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='10' cy='10' r='1' fill='%23ffffff' fill-opacity='0.05'/%3E%3C/svg%3E")`:`url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='10' cy='10' r='1' fill='%23000000' fill-opacity='0.05'/%3E%3C/svg%3E")`,m=rt(d,s,"whatsapp","whatsapp"),_=s?"#0b141a":"#e5ddd5",M=k,F="auto";m==="plain"?M="none":m==="dots"?M=E:m==="whatsapp"||!m?M=k:(m.startsWith("http")||m.startsWith("/")||m.startsWith("data:"))&&(M=`url("${m}")`,F="cover");let x={bg:s?"#1f2937":"#ffffff",bgSecondary:s?"#374151":"#f3f4f6",text:s?"#f9fafb":"#111827",textSecondary:s?"#9ca3af":"#6b7280",border:s?"#4b5563":"#e5e7eb",messageBg:s?"#374151":"#f3f4f6"};function U(J,L){let V=parseInt(J.replace("#",""),16),j=Math.min(255,Math.max(0,(V>>16)+L)),R=Math.min(255,Math.max(0,(V>>8&255)+L)),Y=Math.min(255,Math.max(0,(V&255)+L));return"#"+(16777216+(j<<16)+(R<<8)+Y).toString(16).slice(1)}return`
|
|
2
2
|
#pocketping-container {
|
|
3
3
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
4
4
|
font-size: 14px;
|
|
@@ -572,7 +572,7 @@
|
|
|
572
572
|
|
|
573
573
|
.pp-input-form {
|
|
574
574
|
display: flex;
|
|
575
|
-
padding:
|
|
575
|
+
padding: 12px 10px 6px;
|
|
576
576
|
gap: 8px;
|
|
577
577
|
background: ${l};
|
|
578
578
|
align-items: flex-end;
|
|
@@ -1528,7 +1528,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1528
1528
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fi(t,e){if(t){if(typeof t=="string")return ar(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ar(t,e):void 0}}function ar(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Gt(t,e){var n=e.countries,r=e.metadata;r=new O(r);for(var o=ui(n),d;!(d=o()).done;){var i=d.value;if(r.selectNumberingPlan(i),r.leadingDigits()){if(t&&t.search(r.leadingDigits())===0)return i}else if(ue({phone:t,country:i},void 0,r.metadata))return i}}var $i=!1;function Oe(t,e){var n=e.nationalNumber,r=e.metadata;if($i&&r.isNonGeographicCallingCode(t))return"001";var o=r.getCountryCodesForCallingCode(t);if(o)return o.length===1?o[0]:Gt(n,{countries:o,metadata:r.metadata})}function ve(t,e,n){var r=jt(t,n),o=r.carrierCode,d=r.nationalNumber;if(d!==t){if(!hi(t,d,n))return{nationalNumber:t};if(n.numberingPlan.possibleLengths()&&(e||(e=Oe(n.numberingPlan.callingCode(),{nationalNumber:d,metadata:n})),!gi(d,e,n)))return{nationalNumber:t}}return{nationalNumber:d,carrierCode:o}}function hi(t,e,n){return!(K(t,n.nationalNumberPattern())&&!K(e,n.nationalNumberPattern()))}function gi(t,e,n){switch(pe(t,e,n)){case"TOO_SHORT":case"INVALID_LENGTH":return!1;default:return!0}}function Vt(t,e,n,r,o){var d=e||n?ce(e||n,o):r;if(t.indexOf(d)===0){o=new O(o),o.selectNumberingPlan(e||n,d);var i=t.slice(d.length),s=ve(i,e,o),p=s.nationalNumber,l=ve(t,e,o),f=l.nationalNumber;if(!K(f,o.nationalNumberPattern())&&K(p,o.nationalNumberPattern())||pe(f,e,o)==="TOO_LONG")return{countryCallingCode:d,number:i}}return{number:t}}function Ae(t,e,n,r,o){if(!t)return{};var d;if(t[0]!=="+"){var i=Bt(t,e||n,r,o);if(i&&i!==t)d=!0,t="+"+i;else{if(e||n||r){var s=Vt(t,e,n,r,o),p=s.countryCallingCode,l=s.number;if(p)return{countryCallingCodeSource:"FROM_NUMBER_WITHOUT_PLUS_SIGN",countryCallingCode:p,number:l}}return{number:t}}}if(t[1]==="0")return{};o=new O(o);for(var f=2;f-1<=sr&&f<=t.length;){var c=t.slice(1,f);if(o.hasCallingCode(c))return o.selectNumberingPlan(c),{countryCallingCodeSource:d?"FROM_NUMBER_WITH_IDD":"FROM_NUMBER_WITH_PLUS_SIGN",countryCallingCode:c,number:t.slice(f)};f++}return{}}function Wt(t){return t.replace(new RegExp("[".concat(be,"]+"),"g")," ").trim()}var mi=/(\$\d)/;function zt(t,e,n){var r=n.useInternationalFormat,o=n.withNationalPrefix,d=n.carrierCode,i=n.metadata,s=t.replace(new RegExp(e.pattern()),r?e.internationalFormat():o&&e.nationalPrefixFormattingRule()?e.format().replace(mi,e.nationalPrefixFormattingRule()):e.format());return r?Wt(s):s}var bi=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;function Kt(t,e,n){var r=new O(n);if(r.selectNumberingPlan(t,e),r.defaultIDDPrefix())return r.defaultIDDPrefix();if(bi.test(r.IDDPrefix()))return r.IDDPrefix()}var vi=";ext=",ye=function(e){return"([".concat(X,"]{1,").concat(e,"})")};function Me(t){var e="20",n="15",r="9",o="6",d="[ \xA0\\t,]*",i="[:\\.\uFF0E]?[ \xA0\\t,-]*",s="#?",p="(?:e?xt(?:ensi(?:o\u0301?|\xF3))?n?|\uFF45?\uFF58\uFF54\uFF4E?|\u0434\u043E\u0431|anexo)",l="(?:[x\uFF58#\uFF03~\uFF5E]|int|\uFF49\uFF4E\uFF54)",f="[- ]+",c="[ \xA0\\t]*",$="(?:,{2}|;)",h=vi+ye(e),C=d+p+i+ye(e)+s,k=d+l+i+ye(r)+s,E=f+ye(o)+"#",m=c+$+i+ye(n)+s,_=c+"(?:,)+"+i+ye(r)+s;return h+"|"+C+"|"+k+"|"+E+"|"+m+"|"+_}var yi="["+X+"]{"+Ie+"}",xi="["+Te+"]{0,1}(?:["+be+"]*["+X+"]){3,}["+be+X+"]*",_i=new RegExp("^["+Te+"]{0,1}(?:["+be+"]*["+X+"]){1,2}$","i"),wi=xi+"(?:"+Me()+")?",Ci=new RegExp("^"+yi+"$|^"+wi+"$","i");function Xt(t){return t.length>=Ie&&Ci.test(t)}function lr(t){return _i.test(t)}function cr(t){var e=t.number,n=t.ext;if(!e)return"";if(e[0]!=="+")throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');return"tel:".concat(e).concat(n?";ext="+n:"")}var pr={formatExtension:function(e,n,r){return"".concat(e).concat(r.ext()).concat(n)}};function qt(t,e,n,r){if(n?n=ki({},pr,n):n=pr,r=new O(r),t.country&&t.country!=="001"){if(!r.hasCountry(t.country))throw new Error("Unknown country: ".concat(t.country));r.selectNumberingPlan(t.country)}else if(t.countryCallingCode)r.selectNumberingPlan(t.countryCallingCode);else return t.phone||"";var o=r.countryCallingCode(),d=n.v2?t.nationalNumber:t.phone,i;switch(e){case"NATIONAL":return d?(i=st(d,t.carrierCode,"NATIONAL",r,n),Yt(i,t.ext,r,n.formatExtension)):"";case"INTERNATIONAL":return d?(i=st(d,null,"INTERNATIONAL",r,n),i="+".concat(o," ").concat(i),Yt(i,t.ext,r,n.formatExtension)):"+".concat(o);case"E.164":return"+".concat(o).concat(d);case"RFC3966":return cr({number:"+".concat(o).concat(d),ext:t.ext});case"IDD":if(!n.fromCountry)return;var s=Ei(d,t.carrierCode,o,n.fromCountry,r);return s?Yt(s,t.ext,r,n.formatExtension):void 0;default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(e,'"'))}}function st(t,e,n,r,o){var d=Pi(r.formats(),t);return d?zt(t,d,{useInternationalFormat:n==="INTERNATIONAL",withNationalPrefix:!(d.nationalPrefixIsOptionalWhenFormattingInNationalFormat()&&o&&o.nationalPrefix===!1),carrierCode:e,metadata:r}):t}function Pi(t,e){return Si(t,function(n){if(n.leadingDigitsPatterns().length>0){var r=n.leadingDigitsPatterns()[n.leadingDigitsPatterns().length-1];if(e.search(r)!==0)return!1}return K(e,n.pattern())})}function Yt(t,e,n,r){return e?r(t,e,n):t}function Ei(t,e,n,r,o){var d=ce(r,o.metadata);if(d===n){var i=st(t,e,"NATIONAL",o);return n==="1"?n+" "+i:i}var s=Kt(r,void 0,o.metadata);if(s)return"".concat(s," ").concat(n," ").concat(st(t,null,"INTERNATIONAL",o))}function ki(){for(var t=1,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];for(;t<n.length;){if(n[t])for(var o in n[t])n[0][o]=n[t][o];t++}return n[0]}function Si(t,e){for(var n=0;n<t.length;){if(e(t[n]))return t[n];n++}}function Fe(t){"@babel/helpers - typeof";return Fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fe(t)}function ur(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function fr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ur(Object(n),!0).forEach(function(r){Ni(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ur(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ni(t,e,n){return(e=hr(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ii(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function $r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,hr(r.key),r)}}function Ti(t,e,n){return e&&$r(t.prototype,e),n&&$r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function hr(t){var e=Oi(t,"string");return Fe(e)=="symbol"?e:e+""}function Oi(t,e){if(Fe(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(Fe(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Ai=!1,gr=(function(){function t(e,n,r){if(Ii(this,t),!e)throw new TypeError("First argument is required");if(typeof e!="string")throw new TypeError("First argument must be a string");if(e[0]==="+"&&!n)throw new TypeError("`metadata` argument not passed");if(re(n)&&re(n.countries)){r=n;var o=e;if(!Ri.test(o))throw new Error('Invalid `number` argument passed: must consist of a "+" followed by digits');var d=Ae(o,void 0,void 0,void 0,r),i=d.countryCallingCode,s=d.number;if(n=s,e=i,!n)throw new Error("Invalid `number` argument passed: too short")}if(!n)throw new TypeError("`nationalNumber` argument is required");if(typeof n!="string")throw new TypeError("`nationalNumber` argument must be a string");Mt(r);var p=Fi(e,r),l=p.country,f=p.countryCallingCode;this.country=l,this.countryCallingCode=f,this.nationalNumber=n,this.number="+"+this.countryCallingCode+this.nationalNumber,this.getMetadata=function(){return r}}return Ti(t,[{key:"setExt",value:function(n){this.ext=n}},{key:"getPossibleCountries",value:function(){return this.country?[this.country]:Ut(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function(){return Rt(this,{v2:!0},this.getMetadata())}},{key:"isValid",value:function(){return Ht(this,{v2:!0},this.getMetadata())}},{key:"isNonGeographic",value:function(){var n=new O(this.getMetadata());return n.isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function(n){return this.number===n.number&&this.ext===n.ext}},{key:"getType",value:function(){return ue(this,{v2:!0},this.getMetadata())}},{key:"format",value:function(n,r){return qt(this,n,r?fr(fr({},r),{},{v2:!0}):{v2:!0},this.getMetadata())}},{key:"formatNational",value:function(n){return this.format("NATIONAL",n)}},{key:"formatInternational",value:function(n){return this.format("INTERNATIONAL",n)}},{key:"getURI",value:function(n){return this.format("RFC3966",n)}}])})();var Mi=function(e){return/^[A-Z]{2}$/.test(e)};function Fi(t,e){var n,r,o=new O(e);return Mi(t)?(n=t,o.selectNumberingPlan(n),r=o.countryCallingCode()):(r=t,Ai&&o.isNonGeographicCallingCode(r)&&(n="001")),{country:n,countryCallingCode:r}}var Ri=/^\+\d+$/;function xe(t){"@babel/helpers - typeof";return xe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xe(t)}function mr(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Di(r.key),r)}}function Li(t,e,n){return e&&mr(t.prototype,e),n&&mr(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Di(t){var e=Hi(t,"string");return xe(e)=="symbol"?e:e+""}function Hi(t,e){if(xe(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(xe(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ui(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Bi(t,e,n){return e=Le(e),ji(t,Zt()?Reflect.construct(e,n||[],Le(t).constructor):e.apply(t,n))}function ji(t,e){if(e&&(xe(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Gi(t)}function Gi(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Vi(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Re(t,e)}function Jt(t){var e=typeof Map=="function"?new Map:void 0;return Jt=function(r){if(r===null||!zi(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(e!==void 0){if(e.has(r))return e.get(r);e.set(r,o)}function o(){return Wi(r,arguments,Le(this).constructor)}return o.prototype=Object.create(r.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),Re(o,r)},Jt(t)}function Wi(t,e,n){if(Zt())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var o=new(t.bind.apply(t,r));return n&&Re(o,n.prototype),o}function Zt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Zt=function(){return!!t})()}function zi(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch{return typeof t=="function"}}function Re(t,e){return Re=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Re(t,e)}function Le(t){return Le=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Le(t)}var Z=(function(t){function e(n){var r;return Ui(this,e),r=Bi(this,e,[n]),Object.setPrototypeOf(r,e.prototype),r.name=r.constructor.name,r}return Vi(e,t),Li(e)})(Jt(Error));var br=new RegExp("(?:"+Me()+")$","i");function Qt(t){var e=t.search(br);if(e<0)return{};for(var n=t.slice(0,e),r=t.match(br),o=1;o<r.length;){if(r[o])return{number:n,ext:r[o]};o++}}var Ki={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","\uFF10":"0","\uFF11":"1","\uFF12":"2","\uFF13":"3","\uFF14":"4","\uFF15":"5","\uFF16":"6","\uFF17":"7","\uFF18":"8","\uFF19":"9","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u06F0":"0","\u06F1":"1","\u06F2":"2","\u06F3":"3","\u06F4":"4","\u06F5":"5","\u06F6":"6","\u06F7":"7","\u06F8":"8","\u06F9":"9"};function vr(t){return Ki[t]}function Xi(t,e){var n=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=Yi(t))||e&&t&&typeof t.length=="number"){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
1529
1529
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yi(t,e){if(t){if(typeof t=="string")return yr(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?yr(t,e):void 0}}function yr(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function at(t){for(var e="",n=Xi(t.split("")),r;!(r=n()).done;){var o=r.value;e+=qi(o,e)||""}return e}function qi(t,e,n){if(t==="+"){if(e){typeof n=="function"&&n("end");return}return"+"}return vr(t)}var tn="+",Ji="[\\-\\.\\(\\)]?",xr="(["+X+"]|"+Ji+")",Zi="^\\"+tn+xr+"*["+X+"]"+xr+"*$",Qi=new RegExp(Zi,"g"),en=X,ed="["+en+"]+((\\-)*["+en+"])*",td="a-zA-Z",nd="["+td+"]+((\\-)*["+en+"])*",rd="^("+ed+"\\.)*"+nd+"\\.?$",od=new RegExp(rd,"g"),nn="tel:",lt=";phone-context=",_r=";isub=";function rn(t){var e=t.indexOf(lt);if(e<0)return null;var n=e+lt.length;if(n>=t.length)return"";var r=t.indexOf(";",n);return r>=0?t.substring(n,r):t.substring(n)}function wr(t){return t===null?!0:t.length===0?!1:Qi.test(t)||od.test(t)}function on(t,e){var n=e.extractFormattedPhoneNumber,r=rn(t);if(!wr(r))throw new Z("NOT_A_NUMBER");var o;if(r===null)o=n(t)||"";else{o="",r.charAt(0)===tn&&(o+=r);var d=t.indexOf(nn),i;d>=0?i=d+nn.length:i=0;var s=t.indexOf(lt);o+=t.substring(i,s)}var p=o.indexOf(_r);if(p>0&&(o=o.substring(0,p)),o!=="")return o}var id=250,dd=new RegExp("["+Te+X+"]"),sd=new RegExp("[^"+X+"#]+$"),ad=!1;function dn(t,e,n){if(e=e||{},n=new O(n),e.defaultCountry&&!n.hasCountry(e.defaultCountry))throw e.v2?new Z("INVALID_COUNTRY"):new Error("Unknown country: ".concat(e.defaultCountry));var r=cd(t,e.v2,e.extract),o=r.number,d=r.ext,i=r.error;if(!o){if(e.v2)throw i==="TOO_SHORT"?new Z("TOO_SHORT"):new Z("NOT_A_NUMBER");return{}}var s=ud(o,e.defaultCountry,e.defaultCallingCode,n),p=s.country,l=s.nationalNumber,f=s.countryCallingCode,c=s.countryCallingCodeSource,$=s.carrierCode;if(!n.hasSelectedNumberingPlan()){if(e.v2)throw new Z("INVALID_COUNTRY");return{}}if(!l||l.length<Ie){if(e.v2)throw new Z("TOO_SHORT");return{}}if(l.length>dr){if(e.v2)throw new Z("TOO_LONG");return{}}if(e.v2){var h=new gr(f,l,n.metadata);return p&&(h.country=p),$&&(h.carrierCode=$),d&&(h.ext=d),h.__countryCallingCodeSource=c,h}var C=(e.extended?n.hasSelectedNumberingPlan():p)?K(l,n.nationalNumberPattern()):!1;return e.extended?{country:p,countryCallingCode:f,carrierCode:$,valid:C,possible:C?!0:!!(e.extended===!0&&n.possibleLengths()&&Lt(l,p,n)),phone:l,ext:d}:C?pd(p,l,d):{}}function ld(t,e,n){if(t){if(t.length>id){if(n)throw new Z("TOO_LONG");return}if(e===!1)return t;var r=t.search(dd);if(!(r<0))return t.slice(r).replace(sd,"")}}function cd(t,e,n){var r=on(t,{extractFormattedPhoneNumber:function(i){return ld(i,n,e)}});if(!r)return{};if(!Xt(r))return lr(r)?{error:"TOO_SHORT"}:{};var o=Qt(r);return o.ext?o:{number:r}}function pd(t,e,n){var r={country:t,phone:e};return n&&(r.ext=n),r}function ud(t,e,n,r){var o=Ae(at(t),void 0,e,n,r.metadata),d=o.countryCallingCodeSource,i=o.countryCallingCode,s=o.number,p;if(i)r.selectNumberingPlan(i);else if(s&&(e||n))r.selectNumberingPlan(e,n),e?p=e:ad&&r.isNonGeographicCallingCode(n)&&(p="001"),i=n||ce(e,r.metadata);else return{};if(!s)return{countryCallingCodeSource:d,countryCallingCode:i};var l=ve(at(s),p,r),f=l.nationalNumber,c=l.carrierCode,$=Oe(i,{nationalNumber:f,metadata:r});return $&&(p=$,$==="001"||r.selectNumberingPlan(p)),{country:p,countryCallingCode:i,countryCallingCodeSource:d,nationalNumber:f,carrierCode:c}}function De(t){"@babel/helpers - typeof";return De=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},De(t)}function Cr(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Pr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Cr(Object(n),!0).forEach(function(r){fd(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Cr(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fd(t,e,n){return(e=$d(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $d(t){var e=hd(t,"string");return De(e)=="symbol"?e:e+""}function hd(t,e){if(De(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(De(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function He(t,e,n){return dn(t,Pr(Pr({},e),{},{v2:!0}),n)}function Ue(t){"@babel/helpers - typeof";return Ue=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ue(t)}function Er(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function gd(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Er(Object(n),!0).forEach(function(r){md(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Er(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function md(t,e,n){return(e=bd(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bd(t){var e=vd(t,"string");return Ue(e)=="symbol"?e:e+""}function vd(t,e){if(Ue(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(Ue(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function yd(t,e){return Cd(t)||wd(t,e)||_d(t,e)||xd()}function xd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
1530
1530
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _d(t,e){if(t){if(typeof t=="string")return kr(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?kr(t,e):void 0}}function kr(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function wd(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,o,d,i,s=[],p=!0,l=!1;try{if(d=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;p=!1}else for(;!(p=(r=d.call(n)).done)&&(s.push(r.value),s.length!==e);p=!0);}catch(f){l=!0,o=f}finally{try{if(!p&&n.return!=null&&(i=n.return(),Object(i)!==i))return}finally{if(l)throw o}}return s}}function Cd(t){if(Array.isArray(t))return t}function Be(t){var e=Array.prototype.slice.call(t),n=yd(e,4),r=n[0],o=n[1],d=n[2],i=n[3],s,p,l;if(typeof r=="string")s=r;else throw new TypeError("A text for parsing must be a string.");if(!o||typeof o=="string")i?(p=d,l=i):(p=void 0,l=d),o&&(p=gd({defaultCountry:o},p));else if(re(o))d?(p=o,l=d):l=o;else throw new Error("Invalid second argument: ".concat(o));return{text:s,options:p,metadata:l}}function je(){var t=Be(arguments),e=t.text,n=t.options,r=t.metadata;return He(e,n,r)}function Ge(t){"@babel/helpers - typeof";return Ge=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ge(t)}function Sr(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Nr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Sr(Object(n),!0).forEach(function(r){Pd(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Sr(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Pd(t,e,n){return(e=Ed(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ed(t){var e=kd(t,"string");return Ge(e)=="symbol"?e:e+""}function kd(t,e){if(Ge(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(Ge(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function sn(t,e,n){e&&e.defaultCountry&&!tr(e.defaultCountry,n)&&(e=Nr(Nr({},e),{},{defaultCountry:void 0}));try{return He(t,e,n)}catch(r){if(!(r instanceof Z))throw r}}function Ve(t){"@babel/helpers - typeof";return Ve=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ve(t)}function Ir(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Tr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ir(Object(n),!0).forEach(function(r){Sd(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ir(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Sd(t,e,n){return(e=Nd(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Nd(t){var e=Id(t,"string");return Ve(e)=="symbol"?e:e+""}function Id(t,e){if(Ve(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(Ve(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ct(){var t=Be(arguments),e=t.text,n=t.options,r=t.metadata;n=Tr(Tr({},n),{},{extract:!1});var o=sn(e,n,r);return o&&o.isValid()||!1}function pt(){return Ne(je,arguments)}function ut(){return Ne(ct,arguments)}var an=[{code:"FR",name:"France",dialCode:"+33",flag:"\u{1F1EB}\u{1F1F7}"},{code:"DE",name:"Germany",dialCode:"+49",flag:"\u{1F1E9}\u{1F1EA}"},{code:"GB",name:"United Kingdom",dialCode:"+44",flag:"\u{1F1EC}\u{1F1E7}"},{code:"ES",name:"Spain",dialCode:"+34",flag:"\u{1F1EA}\u{1F1F8}"},{code:"IT",name:"Italy",dialCode:"+39",flag:"\u{1F1EE}\u{1F1F9}"},{code:"PT",name:"Portugal",dialCode:"+351",flag:"\u{1F1F5}\u{1F1F9}"},{code:"NL",name:"Netherlands",dialCode:"+31",flag:"\u{1F1F3}\u{1F1F1}"},{code:"BE",name:"Belgium",dialCode:"+32",flag:"\u{1F1E7}\u{1F1EA}"},{code:"CH",name:"Switzerland",dialCode:"+41",flag:"\u{1F1E8}\u{1F1ED}"},{code:"AT",name:"Austria",dialCode:"+43",flag:"\u{1F1E6}\u{1F1F9}"},{code:"SE",name:"Sweden",dialCode:"+46",flag:"\u{1F1F8}\u{1F1EA}"},{code:"NO",name:"Norway",dialCode:"+47",flag:"\u{1F1F3}\u{1F1F4}"},{code:"DK",name:"Denmark",dialCode:"+45",flag:"\u{1F1E9}\u{1F1F0}"},{code:"FI",name:"Finland",dialCode:"+358",flag:"\u{1F1EB}\u{1F1EE}"},{code:"PL",name:"Poland",dialCode:"+48",flag:"\u{1F1F5}\u{1F1F1}"},{code:"CZ",name:"Czech Republic",dialCode:"+420",flag:"\u{1F1E8}\u{1F1FF}"},{code:"GR",name:"Greece",dialCode:"+30",flag:"\u{1F1EC}\u{1F1F7}"},{code:"IE",name:"Ireland",dialCode:"+353",flag:"\u{1F1EE}\u{1F1EA}"},{code:"RO",name:"Romania",dialCode:"+40",flag:"\u{1F1F7}\u{1F1F4}"},{code:"HU",name:"Hungary",dialCode:"+36",flag:"\u{1F1ED}\u{1F1FA}"},{code:"US",name:"United States",dialCode:"+1",flag:"\u{1F1FA}\u{1F1F8}"},{code:"CA",name:"Canada",dialCode:"+1",flag:"\u{1F1E8}\u{1F1E6}"},{code:"MX",name:"Mexico",dialCode:"+52",flag:"\u{1F1F2}\u{1F1FD}"},{code:"BR",name:"Brazil",dialCode:"+55",flag:"\u{1F1E7}\u{1F1F7}"},{code:"AR",name:"Argentina",dialCode:"+54",flag:"\u{1F1E6}\u{1F1F7}"},{code:"CL",name:"Chile",dialCode:"+56",flag:"\u{1F1E8}\u{1F1F1}"},{code:"CO",name:"Colombia",dialCode:"+57",flag:"\u{1F1E8}\u{1F1F4}"},{code:"PE",name:"Peru",dialCode:"+51",flag:"\u{1F1F5}\u{1F1EA}"},{code:"CN",name:"China",dialCode:"+86",flag:"\u{1F1E8}\u{1F1F3}"},{code:"JP",name:"Japan",dialCode:"+81",flag:"\u{1F1EF}\u{1F1F5}"},{code:"KR",name:"South Korea",dialCode:"+82",flag:"\u{1F1F0}\u{1F1F7}"},{code:"IN",name:"India",dialCode:"+91",flag:"\u{1F1EE}\u{1F1F3}"},{code:"ID",name:"Indonesia",dialCode:"+62",flag:"\u{1F1EE}\u{1F1E9}"},{code:"TH",name:"Thailand",dialCode:"+66",flag:"\u{1F1F9}\u{1F1ED}"},{code:"VN",name:"Vietnam",dialCode:"+84",flag:"\u{1F1FB}\u{1F1F3}"},{code:"MY",name:"Malaysia",dialCode:"+60",flag:"\u{1F1F2}\u{1F1FE}"},{code:"SG",name:"Singapore",dialCode:"+65",flag:"\u{1F1F8}\u{1F1EC}"},{code:"PH",name:"Philippines",dialCode:"+63",flag:"\u{1F1F5}\u{1F1ED}"},{code:"PK",name:"Pakistan",dialCode:"+92",flag:"\u{1F1F5}\u{1F1F0}"},{code:"BD",name:"Bangladesh",dialCode:"+880",flag:"\u{1F1E7}\u{1F1E9}"},{code:"AE",name:"United Arab Emirates",dialCode:"+971",flag:"\u{1F1E6}\u{1F1EA}"},{code:"SA",name:"Saudi Arabia",dialCode:"+966",flag:"\u{1F1F8}\u{1F1E6}"},{code:"IL",name:"Israel",dialCode:"+972",flag:"\u{1F1EE}\u{1F1F1}"},{code:"TR",name:"Turkey",dialCode:"+90",flag:"\u{1F1F9}\u{1F1F7}"},{code:"EG",name:"Egypt",dialCode:"+20",flag:"\u{1F1EA}\u{1F1EC}"},{code:"ZA",name:"South Africa",dialCode:"+27",flag:"\u{1F1FF}\u{1F1E6}"},{code:"NG",name:"Nigeria",dialCode:"+234",flag:"\u{1F1F3}\u{1F1EC}"},{code:"KE",name:"Kenya",dialCode:"+254",flag:"\u{1F1F0}\u{1F1EA}"},{code:"MA",name:"Morocco",dialCode:"+212",flag:"\u{1F1F2}\u{1F1E6}"},{code:"TN",name:"Tunisia",dialCode:"+216",flag:"\u{1F1F9}\u{1F1F3}"},{code:"DZ",name:"Algeria",dialCode:"+213",flag:"\u{1F1E9}\u{1F1FF}"},{code:"AU",name:"Australia",dialCode:"+61",flag:"\u{1F1E6}\u{1F1FA}"},{code:"NZ",name:"New Zealand",dialCode:"+64",flag:"\u{1F1F3}\u{1F1FF}"},{code:"RU",name:"Russia",dialCode:"+7",flag:"\u{1F1F7}\u{1F1FA}"},{code:"UA",name:"Ukraine",dialCode:"+380",flag:"\u{1F1FA}\u{1F1E6}"}].sort((t,e)=>t.name.localeCompare(e.name));function Td(t){return an.find(e=>e.code===t.toUpperCase())}var Or=Td("FR");var Od=0;function a(t,e,n,r,o,d){e||(e={});var i,s,p=e;if("ref"in p)for(s in p={},e)s=="ref"?i=e[s]:p[s]=e[s];var l={type:t,props:p,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Od,__i:-1,__u:0,__source:o,__self:d};if(typeof t=="function"&&(i=t.defaultProps))for(s in i)p[s]===void 0&&(p[s]=i[s]);return T.vnode&&T.vnode(l),l}var Ad=()=>a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),a("path",{d:"M22 7l-10 7L2 7"})]}),Md=()=>a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a("path",{d:"M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.5 19.5 0 01-6-6 19.79 19.79 0 01-3.07-8.67A2 2 0 014.11 2h3a2 2 0 012 1.72 12.84 12.84 0 00.7 2.81 2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45 12.84 12.84 0 002.81.7A2 2 0 0122 16.92z"})}),Fd=()=>a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a("path",{d:"M6 9l6 6 6-6"})});function Ar(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function Mr({client:t,config:e,onComplete:n,onSkip:r}){let o=e.fields==="email-only",d=e.fields==="phone-only",i=e.fields==="email-and-phone",s=e.fields==="email-or-phone",p=()=>d?"phone":"email",[l,f]=N(p()),[c,$]=N(""),[h,C]=N(""),[k,E]=N(Or),[m,_]=N(!1),[M,F]=N(""),[x,U]=N(""),[J,L]=N(""),[V,j]=N(!1),R=ne(null),Y=ne(null);q(()=>{let y=W=>{R.current&&!R.current.contains(W.target)&&_(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]),q(()=>{m&&Y.current&&Y.current.focus()},[m]);let _e=an.filter(y=>y.name.toLowerCase().includes(M.toLowerCase())||y.dialCode.includes(M)||y.code.toLowerCase().includes(M.toLowerCase())),de=y=>{E(y),_(!1),F("")},se=y=>y.replace(/\D/g,""),fe=y=>{let W=y.target,we=se(W.value);C(we),L("")},ee=()=>h?`${k.dialCode}${h}`:"",te=()=>{let y=!0;if((o||i)&&(c.trim()?Ar(c)||(U("Please enter a valid email"),y=!1):(U("Email is required"),y=!1)),d||i){let W=ee();h.trim()?ut(W,k.code)||(L("Please enter a valid phone number"),y=!1):(L("Phone number is required"),y=!1)}if(s)if(l==="email")c.trim()?Ar(c)||(U("Please enter a valid email"),y=!1):(U("Email is required"),y=!1);else{let W=ee();h.trim()?ut(W,k.code)||(L("Please enter a valid phone number"),y=!1):(L("Phone number is required"),y=!1)}return y},z=async y=>{if(y.preventDefault(),!!te()){j(!0);try{let W={};if((o||i||s&&l==="email")&&(W.email=c.trim()),d||i||s&&l==="phone"){let we=ee(),$e=pt(we,k.code);$e&&(W.phone=$e.format("E.164"),W.phoneCountry=k.code)}await t.submitPreChat(W),n()}catch(W){console.error("[PreChatForm] Submit error:",W),l==="email"||o||i?U("Something went wrong. Please try again."):L("Something went wrong. Please try again.")}finally{j(!1)}}},ae=()=>a("div",{class:"pp-prechat-field",children:[a("label",{class:"pp-prechat-label",children:"Email address"}),a("input",{type:"email",class:`pp-prechat-input ${x?"error":""}`,placeholder:"you@example.com",value:c,onInput:y=>{$(y.target.value),U("")}}),x&&a("div",{class:"pp-prechat-error",children:x})]}),Q=()=>a("div",{class:"pp-prechat-field",children:[a("label",{class:"pp-prechat-label",children:"Phone number"}),a("div",{class:"pp-phone-input-wrapper",children:[a("div",{class:"pp-country-select",ref:R,children:[a("button",{type:"button",class:"pp-country-btn",onClick:()=>_(!m),children:[a("span",{class:"pp-country-flag",children:k.flag}),a("span",{class:"pp-country-code",children:k.dialCode}),a(Fd,{})]}),m&&a("div",{class:"pp-country-dropdown",children:[a("div",{class:"pp-country-search",children:a("input",{ref:Y,type:"text",class:"pp-country-search-input",placeholder:"Search country...",value:M,onInput:y=>F(y.target.value)})}),a("div",{class:"pp-country-list",children:_e.map(y=>a("div",{class:`pp-country-option ${y.code===k.code?"selected":""}`,onClick:()=>de(y),children:[a("span",{class:"pp-country-flag",children:y.flag}),a("span",{class:"pp-country-name",children:y.name}),a("span",{class:"pp-country-dial",children:y.dialCode})]},y.code))})]})]}),a("input",{type:"tel",class:`pp-prechat-input pp-phone-number-input ${J?"error":""}`,placeholder:"612 345 678",value:h,onInput:fe})]}),J&&a("div",{class:"pp-prechat-error",children:J})]});return a("div",{class:"pp-prechat",children:[a("h2",{class:"pp-prechat-title",children:"How can we reach you?"}),a("p",{class:"pp-prechat-subtitle",children:i?"Please provide your contact information so we can follow up if needed.":s?"Choose how you would like us to contact you.":o?"Enter your email so we can follow up with you.":"Enter your phone number so we can call you back."}),a("form",{onSubmit:z,children:[s&&a("div",{class:"pp-prechat-tabs",children:[a("button",{type:"button",class:`pp-prechat-tab ${l==="email"?"active":""}`,onClick:()=>{f("email"),L("")},children:[a(Ad,{}),"Email"]}),a("button",{type:"button",class:`pp-prechat-tab ${l==="phone"?"active":""}`,onClick:()=>{f("phone"),U("")},children:[a(Md,{}),"Phone"]})]}),o&&ae(),d&&Q(),i&&a(D,{children:[ae(),Q()]}),s&&a(D,{children:[l==="email"&&ae(),l==="phone"&&Q()]}),a("button",{type:"submit",class:"pp-prechat-submit",disabled:V,children:V?"Submitting...":"Start chatting"}),!e.required&&a("button",{type:"button",class:"pp-prechat-skip",onClick:r,children:"Skip for now"})]})]})}function Rr(t){if(!t)return"";let e=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),n=e.split(`
|
|
1531
|
-
`),r=!1,o=[];for(let d of n){let i=d.match(/^[\s]*[*-]\s+(.+)$/);i?(r||(o.push('<ul class="pp-md-list">'),r=!0),o.push(`<li>${Fr(i[1])}</li>`)):(r&&(o.push("</ul>"),r=!1),o.push(Fr(d)))}return r&&o.push("</ul>"),e=o.join("<br />"),e=e.replace(/<br \/><ul/g,"<ul").replace(/<\/ul><br \/>/g,"</ul>").replace(/<br \/><li>/g,"<li>").replace(/<\/li><br \/>/g,"</li>"),e}function Fr(t){return t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/__(.+?)__/g,"<strong>$1</strong>").replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,"<em>$1</em>").replace(/(?<!_)_([^_]+)_(?!_)/g,"<em>$1</em>").replace(/`([^`]+)`/g,"<code>$1</code>")}function Rd(t){let e=new Date,n=new Date(t),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),o=new Date(n.getFullYear(),n.getMonth(),n.getDate()),d=Math.floor((r.getTime()-o.getTime())/(1e3*60*60*24));return d===0?"Today":d===1?"Yesterday":n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:n.getFullYear()!==e.getFullYear()?"numeric":void 0})}function Lr(t){let e=new Date(t);return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Vr({client:t,config:e}){let[n,r]=N(!1),[o,d]=N([]),[i,s]=N(""),[p,l]=N(!1),[f,c]=N(!1),[$,h]=N(!1),[C,k]=N(0),[E,m]=N([]),[_,M]=N(!1),[F,x]=N(null),[U,J]=N(null),[L,V]=N(""),[j,R]=N(null),[Y,_e]=N(!1),[de,se]=N(null),[fe,ee]=N(0),te=ne(null),[z,ae]=N(e),[Q,y]=N(void 0),[W,we]=N(!1),$e=ne(null),Ce=ne(null),cn=ne(null),lo=ne(null);q(()=>{let u=t.on("openChange",r),g=t.on("message",()=>{d([...t.getMessages()])}),b=t.on("typing",v=>{l(v.isTyping)}),S=t.on("presence",v=>{c(v.online)}),I=t.on("connect",()=>{h(!0),d(t.getMessages()),c(t.getSession()?.operatorOnline??!1),ae(t.getConfig()),y(t.getSession()?.preChatForm)}),A=t.on("preChatCompleted",()=>{y(v=>v&&{...v,completed:!0})}),w=t.on("configUpdate",()=>{ae(t.getConfig())});return t.isConnected()&&(h(!0),d(t.getMessages()),c(t.getSession()?.operatorOnline??!1),ae(t.getConfig()),y(t.getSession()?.preChatForm)),()=>{u(),g(),b(),S(),I(),A(),w()}},[t]),q(()=>{n&&$e.current?.scrollIntoView({behavior:"smooth"})},[o,n]),q(()=>{n&&(setTimeout(()=>{$e.current?.scrollIntoView({behavior:"auto"})},50),Ce.current?.focus(),k(0))},[n]),q(()=>{let u=window.innerWidth<=480;if(n&&u){let g=window.scrollY,b={overflow:document.body.style.overflow,position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,right:document.body.style.right,width:document.body.style.width};return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${g}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%",()=>{document.body.style.overflow=b.overflow,document.body.style.position=b.position,document.body.style.top=b.top,document.body.style.left=b.left,document.body.style.right=b.right,document.body.style.width=b.width,window.scrollTo(0,g)}}},[n]);let[We,pn]=N(null);q(()=>{let u=window.innerWidth<=480;if(!n||!u){pn(null);return}let g=window.visualViewport;if(!g)return;let b=()=>{pn({height:g.height,top:g.offsetTop})};return b(),g.addEventListener("resize",b),g.addEventListener("scroll",b),()=>{g.removeEventListener("resize",b),g.removeEventListener("scroll",b)}},[n]),q(()=>{if(!n&&o.length>0){let u=o.filter(g=>g.sender!=="visitor"&&g.status!=="read").length;k(u)}},[o,n]);let ze=Wn(()=>{if(!n||!$)return;let u=o.filter(g=>g.sender!=="visitor"&&g.status!=="read");if(u.length>0){let g=u.map(b=>b.id);t.sendReadStatus(g,"read")}},[n,$,o,t]);if(q(()=>{if(!n||!$)return;let u=setTimeout(()=>{ze()},1e3);return()=>clearTimeout(u)},[n,$,o,ze]),q(()=>{let u=()=>{document.visibilityState==="visible"&&n&&ze()};return document.addEventListener("visibilitychange",u),()=>document.removeEventListener("visibilitychange",u)},[n,ze]),q(()=>{let u=t.on("read",()=>{d([...t.getMessages()])});return()=>u()},[t]),!Ld(z))return null;let co=async u=>{u.preventDefault();let g=i.trim().length>0,b=E.filter(w=>w.status==="ready"&&w.attachment);if(!g&&b.length===0)return;let S=i,I=b.map(w=>w.attachment.id),A=F?.id;s(""),m([]),x(null),Ce.current&&(Ce.current.style.height="auto");try{await t.sendMessage(S,I,A)}catch(w){console.error("[PocketPing] Failed to send message:",w)}},po=u=>{let g=u.target;s(g.value),g.style.height="auto",g.style.height=Math.min(g.scrollHeight,120)+"px",t.sendTyping(!0)},uo=u=>{if(u.key==="Enter"&&!u.shiftKey){u.preventDefault();let g=u.target.closest("form");g&&g.requestSubmit()}},fo=async u=>{let g=u.target,b=g.files;if(!b||b.length===0)return;let S=[];for(let I=0;I<b.length;I++){let A=b[I],w=`pending-${Date.now()}-${I}`,v;A.type.startsWith("image/")&&(v=URL.createObjectURL(A)),S.push({id:w,file:A,preview:v,progress:0,status:"pending"})}m(I=>[...I,...S]),g.value="",M(!0);for(let I of S)try{m(w=>w.map(v=>v.id===I.id?{...v,status:"uploading"}:v));let A=await t.uploadFile(I.file,w=>{m(v=>v.map(Xe=>Xe.id===I.id?{...Xe,progress:w}:Xe))});m(w=>w.map(v=>v.id===I.id?{...v,status:"ready",progress:100,attachment:A}:v))}catch(A){console.error("[PocketPing] Failed to upload file:",A),m(w=>w.map(v=>v.id===I.id?{...v,status:"error",error:"Upload failed"}:v))}M(!1)},$o=u=>{m(g=>{let b=g.find(S=>S.id===u);return b?.preview&&URL.revokeObjectURL(b.preview),g.filter(S=>S.id!==u)})},un=u=>{x(u),R(null),Ce.current?.focus()},ho=()=>{x(null)},fn=u=>{u.sender==="visitor"&&(J(u),V(u.content),R(null))},$n=()=>{J(null),V("")},go=async()=>{if(!(!U||!L.trim()))try{await t.editMessage(U.id,L.trim()),J(null),V("")}catch(u){console.error("[PocketPing] Failed to edit message:",u)}},hn=async u=>{if(u.sender==="visitor"&&(R(null),confirm("Delete this message?")))try{await t.deleteMessage(u.id)}catch(g){console.error("[PocketPing] Failed to delete message:",g)}},mo=(u,g)=>{u.preventDefault();let b=u;R({message:g,x:b.clientX,y:b.clientY})},bo=(u,g)=>{let b=u.touches[0];te.current={x:b.clientX,y:b.clientY,time:Date.now()},de&&de!==g.id&&(se(null),ee(0))},vo=(u,g)=>{if(!te.current)return;let b=u.touches[0],S=b.clientX-te.current.x,I=b.clientY-te.current.y;if(Math.abs(I)>10||Math.abs(S)<15){de===g.id&&fe!==0&&(ee(0),se(null));return}if(u.preventDefault(),S<0){let A=Math.max(S,-80);ee(A),se(g.id)}},gn=u=>{if(!te.current)return;let g=Date.now()-te.current.time;fe<-50||fe<-20&&g<200?(ee(-80),navigator.vibrate&&navigator.vibrate(30)):(ee(0),se(null)),te.current=null},Ke=()=>{se(null),ee(0)};q(()=>{if(!j)return;let u=()=>R(null);return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[j]);let mn=u=>{let g=document.getElementById(`pp-msg-${u}`);g&&(g.scrollIntoView({behavior:"smooth",block:"center"}),g.classList.add("pp-message-highlight"),setTimeout(()=>{g.classList.remove("pp-message-highlight")},1500))},Pe=ne(0),yo=u=>{u.preventDefault(),u.stopPropagation(),Pe.current++,Pe.current===1&&_e(!0)},xo=u=>{u.preventDefault(),u.stopPropagation()},_o=u=>{u.preventDefault(),u.stopPropagation(),Pe.current--,Pe.current===0&&_e(!1)},wo=async u=>{u.preventDefault(),u.stopPropagation(),Pe.current=0,_e(!1);let g=u.dataTransfer?.files;if(!g||g.length===0)return;let b=[];for(let S=0;S<g.length;S++){let I=g[S],A=`pending-${Date.now()}-${S}`,w;I.type.startsWith("image/")&&(w=URL.createObjectURL(I)),b.push({id:A,file:I,preview:w,progress:0,status:"pending"})}m(S=>[...S,...b]),M(!0);for(let S of b)try{m(A=>A.map(w=>w.id===S.id?{...w,status:"uploading"}:w));let I=await t.uploadFile(S.file,A=>{m(w=>w.map(v=>v.id===S.id?{...v,progress:A}:v))});m(A=>A.map(w=>w.id===S.id?{...w,status:"ready",progress:100,attachment:I}:w))}catch(I){console.error("[PocketPing] Failed to upload dropped file:",I),m(A=>A.map(w=>w.id===S.id?{...w,status:"error",error:"Upload failed"}:w))}M(!1)},bn=z.position??"bottom-right",gt=Dd(z.theme??"auto"),Co=z.primaryColor??"#6366f1",vn=gt==="dark"?"#9ca3af":"#6b7280",Po={primaryColor:Co,theme:gt,headerColor:z.headerColor,footerColor:z.footerColor,chatBackground:z.chatBackground,toggleColor:z.toggleColor},mt=Q&&Q.enabled&&!Q.completed&&!W&&(Q.timing==="before-first-message"&&o.length===0||Q.timing==="after-first-message"&&o.some(u=>u.sender==="visitor"));return a(D,{children:[a("style",{children:Yn(Po)}),!n&&a("button",{class:`pp-toggle pp-${bn}`,onClick:()=>t.toggleOpen(),"aria-label":"Open chat",children:[a(Hd,{}),C>0&&a("span",{class:"pp-unread-badge",children:C>9?"9+":C}),C===0&&f&&a("span",{class:"pp-online-dot"})]}),n&&a("div",{class:`pp-window pp-${bn} pp-theme-${gt} ${Y?"pp-dragging":""}`,style:We?{height:`${We.height}px`,maxHeight:`${We.height}px`,top:`${We.top}px`,bottom:"auto"}:void 0,onDragEnter:yo,onDragOver:xo,onDragLeave:_o,onDrop:wo,children:[Y&&a("div",{class:"pp-drop-overlay",children:[a("div",{class:"pp-drop-icon",children:a(Ur,{})}),a("div",{class:"pp-drop-text",children:"Drop files to upload"})]}),a("div",{class:"pp-header",children:[a("div",{class:"pp-header-info",children:[z.operatorAvatar&&a("img",{src:z.operatorAvatar,alt:"",class:"pp-avatar"}),a("div",{children:[a("div",{class:"pp-header-title",children:z.operatorName??"Support"}),a("div",{class:"pp-header-status",children:f?a(D,{children:[a("span",{class:"pp-status-dot pp-online"})," Online"]}):a(D,{children:[a("span",{class:"pp-status-dot"})," Away"]})})]})]}),a("button",{class:"pp-close-btn",onClick:()=>t.setOpen(!1),"aria-label":"Close chat",children:a(ft,{})})]}),mt&&Q&&a(Mr,{client:t,config:Q,onComplete:()=>{y(u=>u&&{...u,completed:!0})},onSkip:()=>{we(!0)}}),!mt&&a("div",{class:"pp-messages",ref:lo,onClick:()=>de&&Ke(),children:[z.welcomeMessage&&o.length===0&&a("div",{class:"pp-welcome",children:z.welcomeMessage}),o.map((u,g)=>{let b=!!u.deletedAt,S=!!u.editedAt,I=new Date(u.timestamp),A=g>0?o[g-1]:null,w=!A||Lr(new Date(A.timestamp))!==Lr(I),v=null;if(u.replyTo)if(typeof u.replyTo=="object")v=u.replyTo;else{let G=o.find(Ye=>Ye.id===u.replyTo);if(G){let Ye=!!(G.attachments&&G.attachments.length>0);v={id:G.id,sender:G.sender,content:G.content,deleted:!!G.deletedAt,hasAttachment:Ye,attachmentType:Ye?G.attachments[0].mimeType:void 0}}}let Eo=de===u.id?fe:0;return a(D,{children:[w&&a("div",{class:"pp-date-separator",children:a("span",{children:Rd(I)})}),a("div",{class:`pp-message-swipe-container ${u.sender==="visitor"?"pp-swipe-left":"pp-swipe-right"}`,children:[a("div",{class:"pp-swipe-actions",children:[a("button",{class:"pp-swipe-action pp-swipe-reply",onClick:()=>{un(u),Ke()},children:a(Br,{color:"#fff"})}),u.sender==="visitor"&&!b&&a(D,{children:[a("button",{class:"pp-swipe-action pp-swipe-edit",onClick:()=>{fn(u),Ke()},children:a(jr,{color:"#fff"})}),a("button",{class:"pp-swipe-action pp-swipe-delete",onClick:()=>{hn(u),Ke()},children:a(Gr,{color:"#fff"})})]})]}),a("div",{id:`pp-msg-${u.id}`,class:`pp-message pp-message-${u.sender} ${b?"pp-message-deleted":""}`,style:{transform:`translateX(${Eo}px)`,transition:te.current?"none":"transform 0.2s ease-out"},onContextMenu:G=>mo(G,u),onTouchStart:G=>bo(G,u),onTouchMove:G=>vo(G,u),onTouchEnd:()=>gn(u),onTouchCancel:()=>gn(u),children:[v&&(v.content||v.hasAttachment)&&a("div",{class:"pp-reply-quote pp-reply-quote-clickable",onClick:()=>mn(v.id),role:"button",tabIndex:0,onKeyDown:G=>G.key==="Enter"&&mn(v.id),children:[a("span",{class:"pp-reply-sender",children:v.sender==="visitor"?"You":"Support"}),a("span",{class:"pp-reply-content",children:v.deleted?"Message deleted":a(D,{children:[v.hasAttachment&&a("span",{class:"pp-reply-attachment-icon",children:v.attachmentType?.startsWith("image/")?"\u{1F4F7} ":"\u{1F4CE} "}),v.content?a(D,{children:[(v.content||"").slice(0,50),(v.content||"").length>50?"...":""]}):v.attachmentType?.startsWith("image/")?"Photo":"File"]})})]}),b?a("div",{class:"pp-message-content pp-deleted-content",children:[a("span",{class:"pp-deleted-icon",children:"\u{1F5D1}\uFE0F"})," Message deleted"]}):a(D,{children:[u.content&&a("div",{class:"pp-message-content",children:[a("span",{dangerouslySetInnerHTML:{__html:Rr(u.content)}}),a("span",{class:"pp-message-time",children:[Dr(u.timestamp),S&&a("span",{class:"pp-edited-badge",children:"edited"}),u.sender==="ai"&&a("span",{class:"pp-ai-badge",children:"AI"}),u.sender==="visitor"&&a("span",{class:`pp-status pp-status-${u.status??"sent"}`,children:a(Hr,{status:u.status})})]})]}),u.attachments&&u.attachments.length>0&&a("div",{class:"pp-message-attachments",children:[u.attachments.map(G=>a(Bd,{attachment:G},G.id)),!u.content&&a("span",{class:"pp-message-time pp-attachment-time",children:[Dr(u.timestamp),S&&a("span",{class:"pp-edited-badge",children:"edited"}),u.sender==="ai"&&a("span",{class:"pp-ai-badge",children:"AI"}),u.sender==="visitor"&&a("span",{class:`pp-status pp-status-${u.status??"sent"}`,children:a(Hr,{status:u.status})})]})]})]})]})]})]},u.id)}),p&&a("div",{class:"pp-message pp-message-operator pp-typing",children:[a("span",{}),a("span",{}),a("span",{})]}),a("div",{ref:$e})]}),j&&a("div",{class:"pp-message-menu",style:{top:`${j.y}px`,left:`${j.x}px`},children:[a("button",{onClick:()=>un(j.message),children:[a(Br,{color:vn})," Reply"]}),j.message.sender==="visitor"&&!j.message.deletedAt&&a(D,{children:[a("button",{onClick:()=>fn(j.message),children:[a(jr,{color:vn})," Edit"]}),a("button",{class:"pp-menu-delete",onClick:()=>hn(j.message),children:[a(Gr,{color:"#ef4444"})," Delete"]})]})]}),U&&a("div",{class:"pp-edit-modal",children:[a("div",{class:"pp-edit-header",children:[a("span",{children:"Edit message"}),a("button",{onClick:$n,children:a(ft,{})})]}),a("textarea",{class:"pp-edit-input",value:L,onInput:u=>V(u.target.value),autoFocus:!0}),a("div",{class:"pp-edit-actions",children:[a("button",{class:"pp-edit-cancel",onClick:$n,children:"Cancel"}),a("button",{class:"pp-edit-save",onClick:go,disabled:!L.trim(),children:"Save"})]})]}),F&&a("div",{class:"pp-reply-preview",children:[a("div",{class:"pp-reply-preview-content",children:[a("span",{class:"pp-reply-label",children:"Replying to"}),a("span",{class:"pp-reply-text",children:[F.attachments&&F.attachments.length>0&&a("span",{class:"pp-reply-attachment-icon",children:F.attachments[0].mimeType.startsWith("image/")?"\u{1F4F7} ":"\u{1F4CE} "}),F.content?a(D,{children:[F.content.slice(0,50),F.content.length>50?"...":""]}):F.attachments?.[0]?.mimeType.startsWith("image/")?"Photo":"File"]})]}),a("button",{class:"pp-reply-cancel",onClick:ho,children:a(ft,{})})]}),E.length>0&&a("div",{class:"pp-attachments-preview",children:E.map(u=>a("div",{class:`pp-attachment-preview pp-attachment-${u.status}`,children:[u.preview?a("img",{src:u.preview,alt:u.file.name,class:"pp-preview-img"}):a("div",{class:"pp-preview-file",children:a(Wr,{mimeType:u.file.type})}),a("button",{class:"pp-remove-attachment",onClick:()=>$o(u.id),"aria-label":"Remove attachment",type:"button",children:a(ft,{})}),u.status==="uploading"&&a("div",{class:"pp-upload-progress",style:{width:`${u.progress}%`}}),u.status==="error"&&a("div",{class:"pp-upload-error",title:u.error,children:"!"})]},u.id))}),!mt&&a("form",{class:"pp-input-form",onSubmit:co,children:[a("input",{ref:u=>{cn.current=u,u&&(u.onchange=fo)},type:"file",class:"pp-file-input",accept:"image/*,audio/*,video/*,.pdf,.doc,.docx,.xls,.xlsx,.txt",multiple:!0}),a("button",{type:"button",class:"pp-attach-btn",onClick:()=>cn.current?.click(),disabled:!$||_,"aria-label":"Attach file",children:a(Ur,{})}),a("textarea",{ref:Ce,class:"pp-input",placeholder:z.placeholder??"Type a message...",value:i,onInput:po,onKeyDown:uo,disabled:!$,rows:1}),a("button",{type:"submit",class:"pp-send-btn",disabled:!i.trim()&&E.filter(u=>u.status==="ready").length===0||!$||_,"aria-label":"Send message",children:a(Ud,{})})]}),a("div",{class:"pp-footer",children:["Powered by ",a("a",{href:"https://pocketping.io",target:"_blank",rel:"noopener",children:"PocketPing"})]})]})]})}function Ld(t){let e=window.location.pathname;return t.hideOnPages?.some(n=>new RegExp(n).test(e))?!1:t.showOnPages?.length?t.showOnPages.some(n=>new RegExp(n).test(e)):!0}function Dd(t){return t==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t}function Dr(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Hd(){return a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:a("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function ft(){return a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[a("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Ud(){return a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[a("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),a("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function Hr({status:t}){return!t||t==="sending"||t==="sent"?a("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check",children:a("polyline",{points:"3 8 7 12 13 4"})}):t==="delivered"?a("svg",{viewBox:"0 0 20 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check-double",children:[a("polyline",{points:"1 8 5 12 11 4"}),a("polyline",{points:"7 8 11 12 17 4"})]}):t==="read"?a("svg",{viewBox:"0 0 20 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check-double pp-check-read",children:[a("polyline",{points:"1 8 5 12 11 4"}),a("polyline",{points:"7 8 11 12 17 4"})]}):null}function Ur(){return a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:a("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}function Br({color:t,size:e=16}){return a("svg",{viewBox:"0 0 24 24",fill:"none","stroke-width":"2",style:{stroke:t||"currentColor",width:`${e}px`,minWidth:`${e}px`,height:`${e}px`,display:"block",flexShrink:0},children:[a("polyline",{points:"9 17 4 12 9 7"}),a("path",{d:"M20 18v-2a4 4 0 0 0-4-4H4"})]})}function jr({color:t,size:e=16}){return a("svg",{viewBox:"0 0 24 24",fill:"none","stroke-width":"2",style:{stroke:t||"currentColor",width:`${e}px`,minWidth:`${e}px`,height:`${e}px`,display:"block",flexShrink:0},children:a("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}function Gr({color:t,size:e=16}){return a("svg",{viewBox:"0 0 24 24",fill:"none","stroke-width":"2",style:{stroke:t||"currentColor",width:`${e}px`,minWidth:`${e}px`,height:`${e}px`,display:"block",flexShrink:0},children:[a("polyline",{points:"3 6 5 6 21 6"}),a("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}function Wr({mimeType:t}){return t==="application/pdf"?a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[a("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a("polyline",{points:"14 2 14 8 20 8"}),a("path",{d:"M9 15h6"}),a("path",{d:"M9 11h6"})]}):t.startsWith("audio/")?a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[a("path",{d:"M9 18V5l12-2v13"}),a("circle",{cx:"6",cy:"18",r:"3"}),a("circle",{cx:"18",cy:"16",r:"3"})]}):t.startsWith("video/")?a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[a("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2.18",ry:"2.18"}),a("line",{x1:"7",y1:"2",x2:"7",y2:"22"}),a("line",{x1:"17",y1:"2",x2:"17",y2:"22"}),a("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),a("line",{x1:"2",y1:"7",x2:"7",y2:"7"}),a("line",{x1:"2",y1:"17",x2:"7",y2:"17"}),a("line",{x1:"17",y1:"17",x2:"22",y2:"17"}),a("line",{x1:"17",y1:"7",x2:"22",y2:"7"})]}):a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[a("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a("polyline",{points:"14 2 14 8 20 8"})]})}function Bd({attachment:t}){let e=t.mimeType.startsWith("image/"),n=t.mimeType.startsWith("audio/"),r=t.mimeType.startsWith("video/"),o=d=>d<1024?`${d} B`:d<1024*1024?`${(d/1024).toFixed(1)} KB`:`${(d/(1024*1024)).toFixed(1)} MB`;return e?a("a",{href:t.url,target:"_blank",rel:"noopener",class:"pp-attachment pp-attachment-image",children:a("img",{src:t.thumbnailUrl||t.url,alt:t.filename})}):n?a("div",{class:"pp-attachment pp-attachment-audio",children:[a("audio",{controls:!0,preload:"metadata",children:a("source",{src:t.url,type:t.mimeType})}),a("span",{class:"pp-attachment-name",children:t.filename})]}):r?a("div",{class:"pp-attachment pp-attachment-video",children:a("video",{controls:!0,preload:"metadata",children:a("source",{src:t.url,type:t.mimeType})})}):a("a",{href:t.url,target:"_blank",rel:"noopener",class:"pp-attachment pp-attachment-file",children:[a(Wr,{mimeType:t.mimeType}),a("div",{class:"pp-attachment-info",children:[a("span",{class:"pp-attachment-name",children:t.filename}),a("span",{class:"pp-attachment-size",children:o(t.size)})]})]})}var $t="0.3.7";var ht=class{constructor(e){this.session=null;this.ws=null;this.sse=null;this.isOpen=!1;this.listeners=new Map;this.customEventHandlers=new Map;this.reconnectAttempts=0;this.maxReconnectAttempts=5;this.reconnectTimeout=null;this.pollingTimeout=null;this.pollingFailures=0;this.maxPollingFailures=10;this.wsConnectedAt=0;this.quickFailureThreshold=2e3;this.connectionMode="none";this.trackedElementCleanups=[];this.currentTrackedElements=[];this.inspectorMode=!1;this.inspectorCleanup=null;this.connectedAt=0;this.disconnectNotified=!1;this.boundHandleUnload=null;this.boundHandleVisibilityChange=null;this.config=e}async connect(){let e=this.getOrCreateVisitorId(),n=this.getStoredSessionId(),r=this.getStoredIdentity(),d=new URLSearchParams(window.location.search).get("pp_inspector"),i=await this.fetch("/connect",{method:"POST",body:JSON.stringify({visitorId:e,sessionId:n,inspectorToken:d||void 0,metadata:{url:window.location.href,referrer:document.referrer||void 0,pageTitle:document.title||void 0,userAgent:navigator.userAgent,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,language:navigator.language,screenResolution:`${window.screen.width}x${window.screen.height}`},identity:r||void 0})});return this.session={sessionId:i.sessionId,visitorId:i.visitorId,operatorOnline:i.operatorOnline??!1,messages:i.messages??[],identity:i.identity||r||void 0,preChatForm:i.preChatForm},i.operatorName&&(this.config.operatorName=i.operatorName),i.operatorAvatar&&(this.config.operatorAvatar=i.operatorAvatar),i.primaryColor&&(this.config.primaryColor=i.primaryColor),i.headerColor&&(this.config.headerColor=i.headerColor),i.footerColor&&(this.config.footerColor=i.footerColor),i.chatBackground&&(this.config.chatBackground=i.chatBackground),i.toggleColor&&(this.config.toggleColor=i.toggleColor),i.welcomeMessage&&(this.config.welcomeMessage=i.welcomeMessage),this.emit("configUpdate",{operatorName:this.config.operatorName,operatorAvatar:this.config.operatorAvatar,primaryColor:this.config.primaryColor,headerColor:this.config.headerColor,footerColor:this.config.footerColor,chatBackground:this.config.chatBackground,toggleColor:this.config.toggleColor,welcomeMessage:this.config.welcomeMessage}),this.storeSessionId(i.sessionId),this.connectedAt=Date.now(),this.disconnectNotified=!1,this.setupUnloadListeners(),this.connectRealtime(),i.inspectorMode?this.enableInspectorMode():i.trackedElements?.length&&this.setupTrackedElements(i.trackedElements),this.emit("connect",this.session),this.config.onConnect?.(i.sessionId),this.session}disconnect(){this.notifyDisconnect(),this.cleanupUnloadListeners(),this.ws&&(this.ws.onclose=null,this.ws.onmessage=null,this.ws.onerror=null,this.ws.onopen=null,this.ws.close(),this.ws=null),this.sse&&(this.sse.close(),this.sse=null),this.session=null,this.connectionMode="none",this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.stopPolling(),this.cleanupTrackedElements(),this.disableInspectorMode()}async sendMessage(e,n,r){if(!this.session)throw new Error("Not connected");let o=`temp-${this.generateId()}`,d={id:o,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:new Date().toISOString(),status:"sending",replyTo:r};this.session.messages.push(d),this.emit("message",d);try{let i=await this.fetch("/message",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,content:e,sender:"visitor",attachmentIds:n||[],replyTo:r})}),s=this.session.messages.findIndex(l=>l.id===o);s>=0&&(this.session.messages[s].id=i.messageId,this.session.messages[s].timestamp=i.timestamp,this.session.messages[s].status="sent",i.attachments&&i.attachments.length>0&&(this.session.messages[s].attachments=i.attachments),this.emit("message",this.session.messages[s]));let p=this.session.messages[s]||{id:i.messageId,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:i.timestamp,status:"sent",attachments:i.attachments};return this.config.onMessage?.(p),p}catch(i){let s=this.session.messages.findIndex(p=>p.id===o);throw s>=0&&(this.session.messages.splice(s,1),this.emit("message",d)),i}}async uploadFile(e,n){if(!this.session)throw new Error("Not connected");this.emit("uploadStart",{filename:e.name,size:e.size});try{let r=await this.fetch("/upload",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,filename:e.name,mimeType:e.type||"application/octet-stream",size:e.size})});n?.(10),this.emit("uploadProgress",{filename:e.name,progress:10}),await this.uploadToPresignedUrl(r.uploadUrl,e,d=>{let i=10+d*.8;n?.(i),this.emit("uploadProgress",{filename:e.name,progress:i})});let o=await this.fetch("/upload/complete",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,attachmentId:r.attachmentId})});return n?.(100),this.emit("uploadComplete",o),{id:o.id,filename:o.filename,mimeType:o.mimeType,size:o.size,url:o.url,thumbnailUrl:o.thumbnailUrl,status:o.status}}catch(r){throw this.emit("uploadError",{filename:e.name,error:r}),r}}async uploadFiles(e,n){let r=[],o=e.length;for(let d=0;d<o;d++){let i=e[d],s=d/o*100,p=100/o,l=await this.uploadFile(i,f=>{let c=s+f/100*p;n?.(c)});r.push(l)}return r}uploadToPresignedUrl(e,n,r){return new Promise((o,d)=>{let i=new XMLHttpRequest;i.upload.addEventListener("progress",s=>{if(s.lengthComputable){let p=s.loaded/s.total*100;r?.(p)}}),i.addEventListener("load",()=>{i.status>=200&&i.status<300?o():d(new Error(`Upload failed with status ${i.status}`))}),i.addEventListener("error",()=>{d(new Error("Upload failed"))}),i.open("PUT",e),i.setRequestHeader("Content-Type",n.type||"application/octet-stream"),i.send(n)})}async fetchMessages(e){if(!this.session)throw new Error("Not connected");let n=new URLSearchParams({sessionId:this.session.sessionId});return e&&n.set("after",e),(await this.fetch(`/messages?${n}`,{method:"GET"})).messages}async sendTyping(e=!0){this.session&&await this.fetch("/typing",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,sender:"visitor",isTyping:e})})}async sendReadStatus(e,n){if(!(!this.session||e.length===0))try{await this.fetch("/read",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,messageIds:e,status:n})});for(let r of this.session.messages)e.includes(r.id)&&(r.status=n,n==="delivered"?r.deliveredAt=new Date().toISOString():n==="read"&&(r.readAt=new Date().toISOString()));this.emit("readStatusSent",{messageIds:e,status:n})}catch(r){console.error("[PocketPing] Failed to send read status:",r)}}async editMessage(e,n){if(!this.session)throw new Error("Not connected");let r=await this.fetch(`/message/${e}`,{method:"PATCH",body:JSON.stringify({sessionId:this.session.sessionId,content:n})}),o=this.session.messages.findIndex(d=>d.id===e);return o>=0&&(this.session.messages[o].content=r.message.content,this.session.messages[o].editedAt=r.message.editedAt,this.emit("messageEdited",this.session.messages[o])),this.session.messages[o]}async deleteMessage(e){if(!this.session)throw new Error("Not connected");let n=await this.fetch(`/message/${e}?sessionId=${encodeURIComponent(this.session.sessionId)}`,{method:"DELETE"});if(n.deleted){let r=this.session.messages.findIndex(o=>o.id===e);r>=0&&(this.session.messages[r].deletedAt=new Date().toISOString(),this.session.messages[r].content="",this.emit("messageDeleted",this.session.messages[r]))}return n.deleted}async getPresence(){return this.fetch("/presence",{method:"GET"})}async identify(e){if(!e?.id)throw new Error("[PocketPing] identity.id is required");if(this.storeIdentity(e),this.session)try{await this.fetch("/identify",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,identity:e})}),this.session.identity=e,this.emit("identify",e)}catch(n){throw console.error("[PocketPing] Failed to identify:",n),n}}async submitPreChat(e){if(!this.session)throw new Error("[PocketPing] Not connected");if(!e.email&&!e.phone)throw new Error("[PocketPing] Either email or phone is required");try{await this.fetch("/prechat",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,email:e.email,phone:e.phone,phoneCountry:e.phoneCountry})}),this.session.preChatForm&&(this.session.preChatForm.completed=!0),this.emit("preChatCompleted",e)}catch(n){throw console.error("[PocketPing] Failed to submit pre-chat form:",n),n}}async reset(e){this.clearIdentity(),this.session&&(this.session.identity=void 0),e?.newSession&&(localStorage.removeItem("pocketping_session_id"),localStorage.removeItem("pocketping_visitor_id"),this.disconnect(),await this.connect()),this.emit("reset",null)}getIdentity(){return this.session?.identity||this.getStoredIdentity()}getSession(){return this.session}getMessages(){return this.session?.messages??[]}isConnected(){return this.session!==null}isWidgetOpen(){return this.isOpen}getConfig(){return this.config}setOpen(e){this.isOpen=e,this.emit("openChange",e),e?this.config.onOpen?.():this.config.onClose?.()}toggleOpen(){this.setOpen(!this.isOpen)}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{this.listeners.get(e)?.delete(n)}}emit(e,n){this.listeners.get(e)?.forEach(r=>r(n))}trigger(e,n,r){if(!this.ws||this.ws.readyState!==WebSocket.OPEN){console.warn("[PocketPing] Cannot trigger event: WebSocket not connected");return}let o={name:e,data:n,timestamp:new Date().toISOString()};this.ws.send(JSON.stringify({type:"event",data:o})),this.emit(`event:${e}`,o),r?.widgetMessage&&(this.setOpen(!0),this.emit("triggerMessage",{message:r.widgetMessage,eventName:e}))}onEvent(e,n){return this.customEventHandlers.has(e)||this.customEventHandlers.set(e,new Set),this.customEventHandlers.get(e).add(n),()=>{this.customEventHandlers.get(e)?.delete(n)}}offEvent(e,n){this.customEventHandlers.get(e)?.delete(n)}emitCustomEvent(e){let n=this.customEventHandlers.get(e.name);n&&n.forEach(r=>r(e.data,e)),this.config.onEvent?.(e),this.emit("event",e),this.emit(`event:${e.name}`,e)}setupTrackedElements(e){this.cleanupTrackedElements(),this.currentTrackedElements=e;for(let n of e){let r=n.event||"click",o=i=>{let s={...n.data,selector:n.selector,elementText:i.target?.textContent?.trim().slice(0,100),url:window.location.href};this.trigger(n.name,s,{widgetMessage:n.widgetMessage})},d=i=>{i.target?.closest(n.selector)&&o(i)};document.addEventListener(r,d,!0),this.trackedElementCleanups.push(()=>{document.removeEventListener(r,d,!0)})}e.length>0&&console.info(`[PocketPing] Tracking ${e.length} element(s)`)}cleanupTrackedElements(){for(let e of this.trackedElementCleanups)e();this.trackedElementCleanups=[],this.currentTrackedElements=[]}getTrackedElements(){return[...this.currentTrackedElements]}enableInspectorMode(){if(this.inspectorMode)return;this.inspectorMode=!0,console.info("[PocketPing] \u{1F50D} Inspector mode active - click on any element to select it");let e=document.createElement("div");e.id="pp-inspector-overlay",e.innerHTML=`
|
|
1531
|
+
`),r=!1,o=[];for(let d of n){let i=d.match(/^[\s]*[*-]\s+(.+)$/);i?(r||(o.push('<ul class="pp-md-list">'),r=!0),o.push(`<li>${Fr(i[1])}</li>`)):(r&&(o.push("</ul>"),r=!1),o.push(Fr(d)))}return r&&o.push("</ul>"),e=o.join("<br />"),e=e.replace(/<br \/><ul/g,"<ul").replace(/<\/ul><br \/>/g,"</ul>").replace(/<br \/><li>/g,"<li>").replace(/<\/li><br \/>/g,"</li>"),e}function Fr(t){return t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/__(.+?)__/g,"<strong>$1</strong>").replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,"<em>$1</em>").replace(/(?<!_)_([^_]+)_(?!_)/g,"<em>$1</em>").replace(/`([^`]+)`/g,"<code>$1</code>")}function Rd(t){let e=new Date,n=new Date(t),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),o=new Date(n.getFullYear(),n.getMonth(),n.getDate()),d=Math.floor((r.getTime()-o.getTime())/(1e3*60*60*24));return d===0?"Today":d===1?"Yesterday":n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:n.getFullYear()!==e.getFullYear()?"numeric":void 0})}function Lr(t){let e=new Date(t);return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Vr({client:t,config:e}){let[n,r]=N(!1),[o,d]=N([]),[i,s]=N(""),[p,l]=N(!1),[f,c]=N(!1),[$,h]=N(!1),[C,k]=N(0),[E,m]=N([]),[_,M]=N(!1),[F,x]=N(null),[U,J]=N(null),[L,V]=N(""),[j,R]=N(null),[Y,_e]=N(!1),[de,se]=N(null),[fe,ee]=N(0),te=ne(null),[z,ae]=N(e),[Q,y]=N(void 0),[W,we]=N(!1),$e=ne(null),Ce=ne(null),cn=ne(null),lo=ne(null);q(()=>{let u=t.on("openChange",r),g=t.on("message",()=>{d([...t.getMessages()])}),b=t.on("typing",v=>{l(v.isTyping)}),S=t.on("presence",v=>{c(v.online)}),I=t.on("connect",()=>{h(!0),d(t.getMessages()),c(t.getSession()?.operatorOnline??!1),ae(t.getConfig()),y(t.getSession()?.preChatForm)}),A=t.on("preChatCompleted",()=>{y(v=>v&&{...v,completed:!0})}),w=t.on("configUpdate",()=>{ae(t.getConfig())});return t.isConnected()&&(h(!0),d(t.getMessages()),c(t.getSession()?.operatorOnline??!1),ae(t.getConfig()),y(t.getSession()?.preChatForm)),()=>{u(),g(),b(),S(),I(),A(),w()}},[t]),q(()=>{n&&$e.current?.scrollIntoView({behavior:"smooth"})},[o,n]),q(()=>{n&&(setTimeout(()=>{$e.current?.scrollIntoView({behavior:"auto"})},50),Ce.current?.focus(),k(0))},[n]),q(()=>{let u=window.innerWidth<=480;if(n&&u){let g=window.scrollY,b={overflow:document.body.style.overflow,position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,right:document.body.style.right,width:document.body.style.width};return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${g}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%",()=>{document.body.style.overflow=b.overflow,document.body.style.position=b.position,document.body.style.top=b.top,document.body.style.left=b.left,document.body.style.right=b.right,document.body.style.width=b.width,window.scrollTo(0,g)}}},[n]);let[We,pn]=N(null);q(()=>{let u=window.innerWidth<=480;if(!n||!u){pn(null);return}let g=window.visualViewport;if(!g)return;let b=()=>{pn({height:g.height,top:g.offsetTop})};return b(),g.addEventListener("resize",b),g.addEventListener("scroll",b),()=>{g.removeEventListener("resize",b),g.removeEventListener("scroll",b)}},[n]),q(()=>{if(!n&&o.length>0){let u=o.filter(g=>g.sender!=="visitor"&&g.status!=="read").length;k(u)}},[o,n]);let ze=Wn(()=>{if(!n||!$)return;let u=o.filter(g=>g.sender!=="visitor"&&g.status!=="read");if(u.length>0){let g=u.map(b=>b.id);t.sendReadStatus(g,"read")}},[n,$,o,t]);if(q(()=>{if(!n||!$)return;let u=setTimeout(()=>{ze()},1e3);return()=>clearTimeout(u)},[n,$,o,ze]),q(()=>{let u=()=>{document.visibilityState==="visible"&&n&&ze()};return document.addEventListener("visibilitychange",u),()=>document.removeEventListener("visibilitychange",u)},[n,ze]),q(()=>{let u=t.on("read",()=>{d([...t.getMessages()])});return()=>u()},[t]),!Ld(z))return null;let co=async u=>{u.preventDefault();let g=i.trim().length>0,b=E.filter(w=>w.status==="ready"&&w.attachment);if(!g&&b.length===0)return;let S=i,I=b.map(w=>w.attachment.id),A=F?.id;s(""),m([]),x(null),Ce.current&&(Ce.current.style.height="auto");try{await t.sendMessage(S,I,A)}catch(w){console.error("[PocketPing] Failed to send message:",w)}},po=u=>{let g=u.target;s(g.value),g.style.height="auto",g.style.height=Math.min(g.scrollHeight,120)+"px",t.sendTyping(!0)},uo=u=>{if(u.key==="Enter"&&!u.shiftKey){u.preventDefault();let g=u.target.closest("form");g&&g.requestSubmit()}},fo=async u=>{let g=u.target,b=g.files;if(!b||b.length===0)return;let S=[];for(let I=0;I<b.length;I++){let A=b[I],w=`pending-${Date.now()}-${I}`,v;A.type.startsWith("image/")&&(v=URL.createObjectURL(A)),S.push({id:w,file:A,preview:v,progress:0,status:"pending"})}m(I=>[...I,...S]),g.value="",M(!0);for(let I of S)try{m(w=>w.map(v=>v.id===I.id?{...v,status:"uploading"}:v));let A=await t.uploadFile(I.file,w=>{m(v=>v.map(Xe=>Xe.id===I.id?{...Xe,progress:w}:Xe))});m(w=>w.map(v=>v.id===I.id?{...v,status:"ready",progress:100,attachment:A}:v))}catch(A){console.error("[PocketPing] Failed to upload file:",A),m(w=>w.map(v=>v.id===I.id?{...v,status:"error",error:"Upload failed"}:v))}M(!1)},$o=u=>{m(g=>{let b=g.find(S=>S.id===u);return b?.preview&&URL.revokeObjectURL(b.preview),g.filter(S=>S.id!==u)})},un=u=>{x(u),R(null),Ce.current?.focus()},ho=()=>{x(null)},fn=u=>{u.sender==="visitor"&&(J(u),V(u.content),R(null))},$n=()=>{J(null),V("")},go=async()=>{if(!(!U||!L.trim()))try{await t.editMessage(U.id,L.trim()),J(null),V("")}catch(u){console.error("[PocketPing] Failed to edit message:",u)}},hn=async u=>{if(u.sender==="visitor"&&(R(null),confirm("Delete this message?")))try{await t.deleteMessage(u.id)}catch(g){console.error("[PocketPing] Failed to delete message:",g)}},mo=(u,g)=>{u.preventDefault();let b=u;R({message:g,x:b.clientX,y:b.clientY})},bo=(u,g)=>{let b=u.touches[0];te.current={x:b.clientX,y:b.clientY,time:Date.now()},de&&de!==g.id&&(se(null),ee(0))},vo=(u,g)=>{if(!te.current)return;let b=u.touches[0],S=b.clientX-te.current.x,I=b.clientY-te.current.y;if(Math.abs(I)>10||Math.abs(S)<15){de===g.id&&fe!==0&&(ee(0),se(null));return}if(u.preventDefault(),S<0){let A=Math.max(S,-80);ee(A),se(g.id)}},gn=u=>{if(!te.current)return;let g=Date.now()-te.current.time;fe<-50||fe<-20&&g<200?(ee(-80),navigator.vibrate&&navigator.vibrate(30)):(ee(0),se(null)),te.current=null},Ke=()=>{se(null),ee(0)};q(()=>{if(!j)return;let u=()=>R(null);return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[j]);let mn=u=>{let g=document.getElementById(`pp-msg-${u}`);g&&(g.scrollIntoView({behavior:"smooth",block:"center"}),g.classList.add("pp-message-highlight"),setTimeout(()=>{g.classList.remove("pp-message-highlight")},1500))},Pe=ne(0),yo=u=>{u.preventDefault(),u.stopPropagation(),Pe.current++,Pe.current===1&&_e(!0)},xo=u=>{u.preventDefault(),u.stopPropagation()},_o=u=>{u.preventDefault(),u.stopPropagation(),Pe.current--,Pe.current===0&&_e(!1)},wo=async u=>{u.preventDefault(),u.stopPropagation(),Pe.current=0,_e(!1);let g=u.dataTransfer?.files;if(!g||g.length===0)return;let b=[];for(let S=0;S<g.length;S++){let I=g[S],A=`pending-${Date.now()}-${S}`,w;I.type.startsWith("image/")&&(w=URL.createObjectURL(I)),b.push({id:A,file:I,preview:w,progress:0,status:"pending"})}m(S=>[...S,...b]),M(!0);for(let S of b)try{m(A=>A.map(w=>w.id===S.id?{...w,status:"uploading"}:w));let I=await t.uploadFile(S.file,A=>{m(w=>w.map(v=>v.id===S.id?{...v,progress:A}:v))});m(A=>A.map(w=>w.id===S.id?{...w,status:"ready",progress:100,attachment:I}:w))}catch(I){console.error("[PocketPing] Failed to upload dropped file:",I),m(A=>A.map(w=>w.id===S.id?{...w,status:"error",error:"Upload failed"}:w))}M(!1)},bn=z.position??"bottom-right",gt=Dd(z.theme??"auto"),Co=z.primaryColor??"#6366f1",vn=gt==="dark"?"#9ca3af":"#6b7280",Po={primaryColor:Co,theme:gt,headerColor:z.headerColor,footerColor:z.footerColor,chatBackground:z.chatBackground,toggleColor:z.toggleColor},mt=Q&&Q.enabled&&!Q.completed&&!W&&(Q.timing==="before-first-message"&&o.length===0||Q.timing==="after-first-message"&&o.some(u=>u.sender==="visitor"));return a(D,{children:[a("style",{children:Yn(Po)}),!n&&a("button",{class:`pp-toggle pp-${bn}`,onClick:()=>t.toggleOpen(),"aria-label":"Open chat",children:[a(Hd,{}),C>0&&a("span",{class:"pp-unread-badge",children:C>9?"9+":C}),C===0&&f&&a("span",{class:"pp-online-dot"})]}),n&&a("div",{class:`pp-window pp-${bn} pp-theme-${gt} ${Y?"pp-dragging":""}`,style:We?{height:`${We.height}px`,maxHeight:`${We.height}px`,top:`${We.top}px`,bottom:"auto"}:void 0,onDragEnter:yo,onDragOver:xo,onDragLeave:_o,onDrop:wo,children:[Y&&a("div",{class:"pp-drop-overlay",children:[a("div",{class:"pp-drop-icon",children:a(Ur,{})}),a("div",{class:"pp-drop-text",children:"Drop files to upload"})]}),a("div",{class:"pp-header",children:[a("div",{class:"pp-header-info",children:[z.operatorAvatar&&a("img",{src:z.operatorAvatar,alt:"",class:"pp-avatar"}),a("div",{children:[a("div",{class:"pp-header-title",children:z.operatorName??"Support"}),a("div",{class:"pp-header-status",children:f?a(D,{children:[a("span",{class:"pp-status-dot pp-online"})," Online"]}):a(D,{children:[a("span",{class:"pp-status-dot"})," Away"]})})]})]}),a("button",{class:"pp-close-btn",onClick:()=>t.setOpen(!1),"aria-label":"Close chat",children:a(ft,{})})]}),mt&&Q&&a(Mr,{client:t,config:Q,onComplete:()=>{y(u=>u&&{...u,completed:!0})},onSkip:()=>{we(!0)}}),!mt&&a("div",{class:"pp-messages",ref:lo,onClick:()=>de&&Ke(),children:[z.welcomeMessage&&o.length===0&&a("div",{class:"pp-welcome",children:z.welcomeMessage}),o.map((u,g)=>{let b=!!u.deletedAt,S=!!u.editedAt,I=new Date(u.timestamp),A=g>0?o[g-1]:null,w=!A||Lr(new Date(A.timestamp))!==Lr(I),v=null;if(u.replyTo)if(typeof u.replyTo=="object")v=u.replyTo;else{let G=o.find(Ye=>Ye.id===u.replyTo);if(G){let Ye=!!(G.attachments&&G.attachments.length>0);v={id:G.id,sender:G.sender,content:G.content,deleted:!!G.deletedAt,hasAttachment:Ye,attachmentType:Ye?G.attachments[0].mimeType:void 0}}}let Eo=de===u.id?fe:0;return a(D,{children:[w&&a("div",{class:"pp-date-separator",children:a("span",{children:Rd(I)})}),a("div",{class:`pp-message-swipe-container ${u.sender==="visitor"?"pp-swipe-left":"pp-swipe-right"}`,children:[a("div",{class:"pp-swipe-actions",children:[a("button",{class:"pp-swipe-action pp-swipe-reply",onClick:()=>{un(u),Ke()},children:a(Br,{color:"#fff"})}),u.sender==="visitor"&&!b&&a(D,{children:[a("button",{class:"pp-swipe-action pp-swipe-edit",onClick:()=>{fn(u),Ke()},children:a(jr,{color:"#fff"})}),a("button",{class:"pp-swipe-action pp-swipe-delete",onClick:()=>{hn(u),Ke()},children:a(Gr,{color:"#fff"})})]})]}),a("div",{id:`pp-msg-${u.id}`,class:`pp-message pp-message-${u.sender} ${b?"pp-message-deleted":""}`,style:{transform:`translateX(${Eo}px)`,transition:te.current?"none":"transform 0.2s ease-out"},onContextMenu:G=>mo(G,u),onTouchStart:G=>bo(G,u),onTouchMove:G=>vo(G,u),onTouchEnd:()=>gn(u),onTouchCancel:()=>gn(u),children:[v&&(v.content||v.hasAttachment)&&a("div",{class:"pp-reply-quote pp-reply-quote-clickable",onClick:()=>mn(v.id),role:"button",tabIndex:0,onKeyDown:G=>G.key==="Enter"&&mn(v.id),children:[a("span",{class:"pp-reply-sender",children:v.sender==="visitor"?"You":"Support"}),a("span",{class:"pp-reply-content",children:v.deleted?"Message deleted":a(D,{children:[v.hasAttachment&&a("span",{class:"pp-reply-attachment-icon",children:v.attachmentType?.startsWith("image/")?"\u{1F4F7} ":"\u{1F4CE} "}),v.content?a(D,{children:[(v.content||"").slice(0,50),(v.content||"").length>50?"...":""]}):v.attachmentType?.startsWith("image/")?"Photo":"File"]})})]}),b?a("div",{class:"pp-message-content pp-deleted-content",children:[a("span",{class:"pp-deleted-icon",children:"\u{1F5D1}\uFE0F"})," Message deleted"]}):a(D,{children:[u.content&&a("div",{class:"pp-message-content",children:[a("span",{dangerouslySetInnerHTML:{__html:Rr(u.content)}}),a("span",{class:"pp-message-time",children:[Dr(u.timestamp),S&&a("span",{class:"pp-edited-badge",children:"edited"}),u.sender==="ai"&&a("span",{class:"pp-ai-badge",children:"AI"}),u.sender==="visitor"&&a("span",{class:`pp-status pp-status-${u.status??"sent"}`,children:a(Hr,{status:u.status})})]})]}),u.attachments&&u.attachments.length>0&&a("div",{class:"pp-message-attachments",children:[u.attachments.map(G=>a(Bd,{attachment:G},G.id)),!u.content&&a("span",{class:"pp-message-time pp-attachment-time",children:[Dr(u.timestamp),S&&a("span",{class:"pp-edited-badge",children:"edited"}),u.sender==="ai"&&a("span",{class:"pp-ai-badge",children:"AI"}),u.sender==="visitor"&&a("span",{class:`pp-status pp-status-${u.status??"sent"}`,children:a(Hr,{status:u.status})})]})]})]})]})]})]},u.id)}),p&&a("div",{class:"pp-message pp-message-operator pp-typing",children:[a("span",{}),a("span",{}),a("span",{})]}),a("div",{ref:$e})]}),j&&a("div",{class:"pp-message-menu",style:{top:`${j.y}px`,left:`${j.x}px`},children:[a("button",{onClick:()=>un(j.message),children:[a(Br,{color:vn})," Reply"]}),j.message.sender==="visitor"&&!j.message.deletedAt&&a(D,{children:[a("button",{onClick:()=>fn(j.message),children:[a(jr,{color:vn})," Edit"]}),a("button",{class:"pp-menu-delete",onClick:()=>hn(j.message),children:[a(Gr,{color:"#ef4444"})," Delete"]})]})]}),U&&a("div",{class:"pp-edit-modal",children:[a("div",{class:"pp-edit-header",children:[a("span",{children:"Edit message"}),a("button",{onClick:$n,children:a(ft,{})})]}),a("textarea",{class:"pp-edit-input",value:L,onInput:u=>V(u.target.value),autoFocus:!0}),a("div",{class:"pp-edit-actions",children:[a("button",{class:"pp-edit-cancel",onClick:$n,children:"Cancel"}),a("button",{class:"pp-edit-save",onClick:go,disabled:!L.trim(),children:"Save"})]})]}),F&&a("div",{class:"pp-reply-preview",children:[a("div",{class:"pp-reply-preview-content",children:[a("span",{class:"pp-reply-label",children:"Replying to"}),a("span",{class:"pp-reply-text",children:[F.attachments&&F.attachments.length>0&&a("span",{class:"pp-reply-attachment-icon",children:F.attachments[0].mimeType.startsWith("image/")?"\u{1F4F7} ":"\u{1F4CE} "}),F.content?a(D,{children:[F.content.slice(0,50),F.content.length>50?"...":""]}):F.attachments?.[0]?.mimeType.startsWith("image/")?"Photo":"File"]})]}),a("button",{class:"pp-reply-cancel",onClick:ho,children:a(ft,{})})]}),E.length>0&&a("div",{class:"pp-attachments-preview",children:E.map(u=>a("div",{class:`pp-attachment-preview pp-attachment-${u.status}`,children:[u.preview?a("img",{src:u.preview,alt:u.file.name,class:"pp-preview-img"}):a("div",{class:"pp-preview-file",children:a(Wr,{mimeType:u.file.type})}),a("button",{class:"pp-remove-attachment",onClick:()=>$o(u.id),"aria-label":"Remove attachment",type:"button",children:a(ft,{})}),u.status==="uploading"&&a("div",{class:"pp-upload-progress",style:{width:`${u.progress}%`}}),u.status==="error"&&a("div",{class:"pp-upload-error",title:u.error,children:"!"})]},u.id))}),!mt&&a("form",{class:"pp-input-form",onSubmit:co,children:[a("input",{ref:u=>{cn.current=u,u&&(u.onchange=fo)},type:"file",class:"pp-file-input",accept:"image/*,audio/*,video/*,.pdf,.doc,.docx,.xls,.xlsx,.txt",multiple:!0}),a("button",{type:"button",class:"pp-attach-btn",onClick:()=>cn.current?.click(),disabled:!$||_,"aria-label":"Attach file",children:a(Ur,{})}),a("textarea",{ref:Ce,class:"pp-input",placeholder:z.placeholder??"Type a message...",value:i,onInput:po,onKeyDown:uo,disabled:!$,rows:1}),a("button",{type:"submit",class:"pp-send-btn",disabled:!i.trim()&&E.filter(u=>u.status==="ready").length===0||!$||_,"aria-label":"Send message",children:a(Ud,{})})]}),a("div",{class:"pp-footer",children:["Powered by ",a("a",{href:"https://pocketping.io",target:"_blank",rel:"noopener",children:"PocketPing"})]})]})]})}function Ld(t){let e=window.location.pathname;return t.hideOnPages?.some(n=>new RegExp(n).test(e))?!1:t.showOnPages?.length?t.showOnPages.some(n=>new RegExp(n).test(e)):!0}function Dd(t){return t==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t}function Dr(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Hd(){return a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:a("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function ft(){return a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[a("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Ud(){return a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[a("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),a("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function Hr({status:t}){return!t||t==="sending"||t==="sent"?a("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check",children:a("polyline",{points:"3 8 7 12 13 4"})}):t==="delivered"?a("svg",{viewBox:"0 0 20 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check-double",children:[a("polyline",{points:"1 8 5 12 11 4"}),a("polyline",{points:"7 8 11 12 17 4"})]}):t==="read"?a("svg",{viewBox:"0 0 20 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check-double pp-check-read",children:[a("polyline",{points:"1 8 5 12 11 4"}),a("polyline",{points:"7 8 11 12 17 4"})]}):null}function Ur(){return a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:a("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}function Br({color:t,size:e=16}){return a("svg",{viewBox:"0 0 24 24",fill:"none","stroke-width":"2",style:{stroke:t||"currentColor",width:`${e}px`,minWidth:`${e}px`,height:`${e}px`,display:"block",flexShrink:0},children:[a("polyline",{points:"9 17 4 12 9 7"}),a("path",{d:"M20 18v-2a4 4 0 0 0-4-4H4"})]})}function jr({color:t,size:e=16}){return a("svg",{viewBox:"0 0 24 24",fill:"none","stroke-width":"2",style:{stroke:t||"currentColor",width:`${e}px`,minWidth:`${e}px`,height:`${e}px`,display:"block",flexShrink:0},children:a("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}function Gr({color:t,size:e=16}){return a("svg",{viewBox:"0 0 24 24",fill:"none","stroke-width":"2",style:{stroke:t||"currentColor",width:`${e}px`,minWidth:`${e}px`,height:`${e}px`,display:"block",flexShrink:0},children:[a("polyline",{points:"3 6 5 6 21 6"}),a("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}function Wr({mimeType:t}){return t==="application/pdf"?a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[a("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a("polyline",{points:"14 2 14 8 20 8"}),a("path",{d:"M9 15h6"}),a("path",{d:"M9 11h6"})]}):t.startsWith("audio/")?a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[a("path",{d:"M9 18V5l12-2v13"}),a("circle",{cx:"6",cy:"18",r:"3"}),a("circle",{cx:"18",cy:"16",r:"3"})]}):t.startsWith("video/")?a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[a("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2.18",ry:"2.18"}),a("line",{x1:"7",y1:"2",x2:"7",y2:"22"}),a("line",{x1:"17",y1:"2",x2:"17",y2:"22"}),a("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),a("line",{x1:"2",y1:"7",x2:"7",y2:"7"}),a("line",{x1:"2",y1:"17",x2:"7",y2:"17"}),a("line",{x1:"17",y1:"17",x2:"22",y2:"17"}),a("line",{x1:"17",y1:"7",x2:"22",y2:"7"})]}):a("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[a("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a("polyline",{points:"14 2 14 8 20 8"})]})}function Bd({attachment:t}){let e=t.mimeType.startsWith("image/"),n=t.mimeType.startsWith("audio/"),r=t.mimeType.startsWith("video/"),o=d=>d<1024?`${d} B`:d<1024*1024?`${(d/1024).toFixed(1)} KB`:`${(d/(1024*1024)).toFixed(1)} MB`;return e?a("a",{href:t.url,target:"_blank",rel:"noopener",class:"pp-attachment pp-attachment-image",children:a("img",{src:t.thumbnailUrl||t.url,alt:t.filename})}):n?a("div",{class:"pp-attachment pp-attachment-audio",children:[a("audio",{controls:!0,preload:"metadata",children:a("source",{src:t.url,type:t.mimeType})}),a("span",{class:"pp-attachment-name",children:t.filename})]}):r?a("div",{class:"pp-attachment pp-attachment-video",children:a("video",{controls:!0,preload:"metadata",children:a("source",{src:t.url,type:t.mimeType})})}):a("a",{href:t.url,target:"_blank",rel:"noopener",class:"pp-attachment pp-attachment-file",children:[a(Wr,{mimeType:t.mimeType}),a("div",{class:"pp-attachment-info",children:[a("span",{class:"pp-attachment-name",children:t.filename}),a("span",{class:"pp-attachment-size",children:o(t.size)})]})]})}var $t="0.3.8";function jd(){return{webdriver:!!navigator.webdriver,plugins:navigator.plugins.length===0,languages:navigator.languages.length===0,chrome:/Chrome/.test(navigator.userAgent)&&typeof window.chrome>"u",permissions:typeof Notification<"u"&&Notification.permission==="denied"}}var ht=class{constructor(e){this.session=null;this.ws=null;this.sse=null;this.isOpen=!1;this.listeners=new Map;this.customEventHandlers=new Map;this.reconnectAttempts=0;this.maxReconnectAttempts=5;this.reconnectTimeout=null;this.pollingTimeout=null;this.pollingFailures=0;this.maxPollingFailures=10;this.wsConnectedAt=0;this.quickFailureThreshold=2e3;this.connectionMode="none";this.trackedElementCleanups=[];this.currentTrackedElements=[];this.inspectorMode=!1;this.inspectorCleanup=null;this.connectedAt=0;this.disconnectNotified=!1;this.boundHandleUnload=null;this.boundHandleVisibilityChange=null;this.config=e}async connect(){let e=this.getOrCreateVisitorId(),n=this.getStoredSessionId(),r=this.getStoredIdentity(),d=new URLSearchParams(window.location.search).get("pp_inspector"),i=await this.fetch("/connect",{method:"POST",body:JSON.stringify({visitorId:e,sessionId:n,inspectorToken:d||void 0,metadata:{url:window.location.href,referrer:document.referrer||void 0,pageTitle:document.title||void 0,userAgent:navigator.userAgent,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,language:navigator.language,screenResolution:`${window.screen.width}x${window.screen.height}`,botSignals:jd()},identity:r||void 0})});return this.session={sessionId:i.sessionId,visitorId:i.visitorId,operatorOnline:i.operatorOnline??!1,messages:i.messages??[],identity:i.identity||r||void 0,preChatForm:i.preChatForm},i.operatorName&&(this.config.operatorName=i.operatorName),i.operatorAvatar&&(this.config.operatorAvatar=i.operatorAvatar),i.primaryColor&&(this.config.primaryColor=i.primaryColor),i.headerColor&&(this.config.headerColor=i.headerColor),i.footerColor&&(this.config.footerColor=i.footerColor),i.chatBackground&&(this.config.chatBackground=i.chatBackground),i.toggleColor&&(this.config.toggleColor=i.toggleColor),i.welcomeMessage&&(this.config.welcomeMessage=i.welcomeMessage),this.emit("configUpdate",{operatorName:this.config.operatorName,operatorAvatar:this.config.operatorAvatar,primaryColor:this.config.primaryColor,headerColor:this.config.headerColor,footerColor:this.config.footerColor,chatBackground:this.config.chatBackground,toggleColor:this.config.toggleColor,welcomeMessage:this.config.welcomeMessage}),this.storeSessionId(i.sessionId),this.connectedAt=Date.now(),this.disconnectNotified=!1,this.setupUnloadListeners(),this.connectRealtime(),i.inspectorMode?this.enableInspectorMode():i.trackedElements?.length&&this.setupTrackedElements(i.trackedElements),this.emit("connect",this.session),this.config.onConnect?.(i.sessionId),this.session}disconnect(){this.notifyDisconnect(),this.cleanupUnloadListeners(),this.ws&&(this.ws.onclose=null,this.ws.onmessage=null,this.ws.onerror=null,this.ws.onopen=null,this.ws.close(),this.ws=null),this.sse&&(this.sse.close(),this.sse=null),this.session=null,this.connectionMode="none",this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.stopPolling(),this.cleanupTrackedElements(),this.disableInspectorMode()}async sendMessage(e,n,r){if(!this.session)throw new Error("Not connected");let o=`temp-${this.generateId()}`,d={id:o,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:new Date().toISOString(),status:"sending",replyTo:r};this.session.messages.push(d),this.emit("message",d);try{let i=await this.fetch("/message",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,content:e,sender:"visitor",attachmentIds:n||[],replyTo:r})}),s=this.session.messages.findIndex(l=>l.id===o);s>=0&&(this.session.messages[s].id=i.messageId,this.session.messages[s].timestamp=i.timestamp,this.session.messages[s].status="sent",i.attachments&&i.attachments.length>0&&(this.session.messages[s].attachments=i.attachments),this.emit("message",this.session.messages[s]));let p=this.session.messages[s]||{id:i.messageId,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:i.timestamp,status:"sent",attachments:i.attachments};return this.config.onMessage?.(p),p}catch(i){let s=this.session.messages.findIndex(p=>p.id===o);throw s>=0&&(this.session.messages.splice(s,1),this.emit("message",d)),i}}async uploadFile(e,n){if(!this.session)throw new Error("Not connected");this.emit("uploadStart",{filename:e.name,size:e.size});try{let r=await this.fetch("/upload",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,filename:e.name,mimeType:e.type||"application/octet-stream",size:e.size})});n?.(10),this.emit("uploadProgress",{filename:e.name,progress:10}),await this.uploadToPresignedUrl(r.uploadUrl,e,d=>{let i=10+d*.8;n?.(i),this.emit("uploadProgress",{filename:e.name,progress:i})});let o=await this.fetch("/upload/complete",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,attachmentId:r.attachmentId})});return n?.(100),this.emit("uploadComplete",o),{id:o.id,filename:o.filename,mimeType:o.mimeType,size:o.size,url:o.url,thumbnailUrl:o.thumbnailUrl,status:o.status}}catch(r){throw this.emit("uploadError",{filename:e.name,error:r}),r}}async uploadFiles(e,n){let r=[],o=e.length;for(let d=0;d<o;d++){let i=e[d],s=d/o*100,p=100/o,l=await this.uploadFile(i,f=>{let c=s+f/100*p;n?.(c)});r.push(l)}return r}uploadToPresignedUrl(e,n,r){return new Promise((o,d)=>{let i=new XMLHttpRequest;i.upload.addEventListener("progress",s=>{if(s.lengthComputable){let p=s.loaded/s.total*100;r?.(p)}}),i.addEventListener("load",()=>{i.status>=200&&i.status<300?o():d(new Error(`Upload failed with status ${i.status}`))}),i.addEventListener("error",()=>{d(new Error("Upload failed"))}),i.open("PUT",e),i.setRequestHeader("Content-Type",n.type||"application/octet-stream"),i.send(n)})}async fetchMessages(e){if(!this.session)throw new Error("Not connected");let n=new URLSearchParams({sessionId:this.session.sessionId});return e&&n.set("after",e),(await this.fetch(`/messages?${n}`,{method:"GET"})).messages}async sendTyping(e=!0){this.session&&await this.fetch("/typing",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,sender:"visitor",isTyping:e})})}async sendReadStatus(e,n){if(!(!this.session||e.length===0))try{await this.fetch("/read",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,messageIds:e,status:n})});for(let r of this.session.messages)e.includes(r.id)&&(r.status=n,n==="delivered"?r.deliveredAt=new Date().toISOString():n==="read"&&(r.readAt=new Date().toISOString()));this.emit("readStatusSent",{messageIds:e,status:n})}catch(r){console.error("[PocketPing] Failed to send read status:",r)}}async editMessage(e,n){if(!this.session)throw new Error("Not connected");let r=await this.fetch(`/message/${e}`,{method:"PATCH",body:JSON.stringify({sessionId:this.session.sessionId,content:n})}),o=this.session.messages.findIndex(d=>d.id===e);return o>=0&&(this.session.messages[o].content=r.message.content,this.session.messages[o].editedAt=r.message.editedAt,this.emit("messageEdited",this.session.messages[o])),this.session.messages[o]}async deleteMessage(e){if(!this.session)throw new Error("Not connected");let n=await this.fetch(`/message/${e}?sessionId=${encodeURIComponent(this.session.sessionId)}`,{method:"DELETE"});if(n.deleted){let r=this.session.messages.findIndex(o=>o.id===e);r>=0&&(this.session.messages[r].deletedAt=new Date().toISOString(),this.session.messages[r].content="",this.emit("messageDeleted",this.session.messages[r]))}return n.deleted}async getPresence(){return this.fetch("/presence",{method:"GET"})}async identify(e){if(!e?.id)throw new Error("[PocketPing] identity.id is required");if(this.storeIdentity(e),this.session)try{await this.fetch("/identify",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,identity:e})}),this.session.identity=e,this.emit("identify",e)}catch(n){throw console.error("[PocketPing] Failed to identify:",n),n}}async submitPreChat(e){if(!this.session)throw new Error("[PocketPing] Not connected");if(!e.email&&!e.phone)throw new Error("[PocketPing] Either email or phone is required");try{await this.fetch("/prechat",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,email:e.email,phone:e.phone,phoneCountry:e.phoneCountry})}),this.session.preChatForm&&(this.session.preChatForm.completed=!0),this.emit("preChatCompleted",e)}catch(n){throw console.error("[PocketPing] Failed to submit pre-chat form:",n),n}}async reset(e){this.clearIdentity(),this.session&&(this.session.identity=void 0),e?.newSession&&(localStorage.removeItem("pocketping_session_id"),localStorage.removeItem("pocketping_visitor_id"),this.disconnect(),await this.connect()),this.emit("reset",null)}getIdentity(){return this.session?.identity||this.getStoredIdentity()}getSession(){return this.session}getMessages(){return this.session?.messages??[]}isConnected(){return this.session!==null}isWidgetOpen(){return this.isOpen}getConfig(){return this.config}setOpen(e){this.isOpen=e,this.emit("openChange",e),e?this.config.onOpen?.():this.config.onClose?.()}toggleOpen(){this.setOpen(!this.isOpen)}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{this.listeners.get(e)?.delete(n)}}emit(e,n){this.listeners.get(e)?.forEach(r=>r(n))}trigger(e,n,r){if(!this.ws||this.ws.readyState!==WebSocket.OPEN){console.warn("[PocketPing] Cannot trigger event: WebSocket not connected");return}let o={name:e,data:n,timestamp:new Date().toISOString()};this.ws.send(JSON.stringify({type:"event",data:o})),this.emit(`event:${e}`,o),r?.widgetMessage&&(this.setOpen(!0),this.emit("triggerMessage",{message:r.widgetMessage,eventName:e}))}onEvent(e,n){return this.customEventHandlers.has(e)||this.customEventHandlers.set(e,new Set),this.customEventHandlers.get(e).add(n),()=>{this.customEventHandlers.get(e)?.delete(n)}}offEvent(e,n){this.customEventHandlers.get(e)?.delete(n)}emitCustomEvent(e){let n=this.customEventHandlers.get(e.name);n&&n.forEach(r=>r(e.data,e)),this.config.onEvent?.(e),this.emit("event",e),this.emit(`event:${e.name}`,e)}setupTrackedElements(e){this.cleanupTrackedElements(),this.currentTrackedElements=e;for(let n of e){let r=n.event||"click",o=i=>{let s={...n.data,selector:n.selector,elementText:i.target?.textContent?.trim().slice(0,100),url:window.location.href};this.trigger(n.name,s,{widgetMessage:n.widgetMessage})},d=i=>{i.target?.closest(n.selector)&&o(i)};document.addEventListener(r,d,!0),this.trackedElementCleanups.push(()=>{document.removeEventListener(r,d,!0)})}e.length>0&&console.info(`[PocketPing] Tracking ${e.length} element(s)`)}cleanupTrackedElements(){for(let e of this.trackedElementCleanups)e();this.trackedElementCleanups=[],this.currentTrackedElements=[]}getTrackedElements(){return[...this.currentTrackedElements]}enableInspectorMode(){if(this.inspectorMode)return;this.inspectorMode=!0,console.info("[PocketPing] \u{1F50D} Inspector mode active - click on any element to select it");let e=document.createElement("div");e.id="pp-inspector-overlay",e.innerHTML=`
|
|
1532
1532
|
<style>
|
|
1533
1533
|
#pp-inspector-overlay {
|
|
1534
1534
|
position: fixed;
|
|
@@ -1616,4 +1616,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1616
1616
|
<polyline points="20 6 9 17 4 12"/>
|
|
1617
1617
|
</svg>
|
|
1618
1618
|
<span>Selector captured: <code style="background:rgba(255,255,255,0.2);padding:2px 6px;border-radius:4px;font-family:monospace;">${f}</code></span>
|
|
1619
|
-
`,setTimeout(()=>{c&&this.inspectorMode&&(c.innerHTML=$,document.getElementById("pp-inspector-exit")?.addEventListener("click",()=>{this.disableInspectorMode()}))},2e3)}console.info(`[PocketPing] \u{1F4CC} Selector captured: ${f}`)};document.addEventListener("mouseover",d,!0),document.addEventListener("mouseout",i,!0),document.addEventListener("click",s,!0),this.inspectorCleanup=()=>{document.removeEventListener("mouseover",d,!0),document.removeEventListener("mouseout",i,!0),document.removeEventListener("click",s,!0),e.remove(),r&&r.classList.remove("pp-inspector-highlight")},document.getElementById("pp-inspector-exit")?.addEventListener("click",()=>{this.disableInspectorMode()})}disableInspectorMode(){this.inspectorMode&&(this.inspectorMode=!1,this.inspectorCleanup&&(this.inspectorCleanup(),this.inspectorCleanup=null),console.info("[PocketPing] Inspector mode disabled"),this.emit("inspectorDisabled",null))}isInspectorModeActive(){return this.inspectorMode}connectRealtime(){if(this.session){if(this.connectionMode==="polling"){this.startPolling();return}if(this.connectionMode==="sse"){this.connectSSE();return}this.connectWebSocket()}}connectWebSocket(){if(!this.session)return;let e=this.config.endpoint.replace(/^http/,"ws").replace(/\/$/,"")+`/stream?sessionId=${this.session.sessionId}`;try{this.ws=new WebSocket(e),this.wsConnectedAt=Date.now();let n=setTimeout(()=>{console.warn("[PocketPing] \u23F1\uFE0F WebSocket timeout - trying SSE"),this.ws&&this.ws.readyState!==WebSocket.OPEN&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.onopen=null,this.ws.close(),this.ws=null,this.connectSSE())},5e3);this.ws.onopen=()=>{clearTimeout(n),this.connectionMode="ws",this.reconnectAttempts=0,this.wsConnectedAt=Date.now(),this.emit("wsConnected",null)},this.ws.onmessage=r=>{try{let o=JSON.parse(r.data);this.handleRealtimeEvent(o)}catch(o){console.error("[PocketPing] Failed to parse WS message:",o)}},this.ws.onclose=()=>{clearTimeout(n),this.emit("wsDisconnected",null),this.handleWsFailure()},this.ws.onerror=()=>{clearTimeout(n)}}catch{console.warn("[PocketPing] WebSocket unavailable - trying SSE"),this.connectSSE()}}connectSSE(){if(!this.session)return;let e=new URLSearchParams({sessionId:this.session.sessionId}),n=this.getLastEventTimestamp();n&&e.set("after",n);let r=this.config.endpoint.replace(/\/$/,"")+`/stream?${e.toString()}`;try{this.sse=new EventSource(r);let o=setTimeout(()=>{console.warn("[PocketPing] \u23F1\uFE0F SSE timeout - falling back to polling"),this.sse&&this.sse.readyState!==EventSource.OPEN&&(this.sse.close(),this.sse=null,this.connectionMode="polling",this.startPolling())},5e3);this.sse.onopen=()=>{clearTimeout(o),this.connectionMode="sse",this.emit("sseConnected",null)},this.sse.addEventListener("message",d=>{try{let i=JSON.parse(d.data);this.handleRealtimeEvent(i)}catch(i){console.error("[PocketPing] Failed to parse SSE message:",i)}}),this.sse.addEventListener("connected",()=>{}),this.sse.onerror=()=>{clearTimeout(o),console.warn("[PocketPing] \u274C SSE error - falling back to polling"),this.sse&&(this.sse.close(),this.sse=null),this.connectionMode="polling",this.startPolling()}}catch{console.warn("[PocketPing] SSE unavailable - falling back to polling"),this.connectionMode="polling",this.startPolling()}}handleWsFailure(){if(Date.now()-this.wsConnectedAt<this.quickFailureThreshold){console.info("[PocketPing] WebSocket failed quickly - trying SSE"),this.connectSSE();return}this.scheduleReconnect()}handleRealtimeEvent(e){this.handleWebSocketEvent(e)}getLastEventTimestamp(){if(!this.session)return null;let e=null;for(let n of this.session.messages){let r=[n.timestamp,n.editedAt,n.deletedAt,n.deliveredAt,n.readAt].filter(Boolean).map(o=>new Date(o)).filter(o=>!isNaN(o.getTime()));for(let o of r)(!e||o>e)&&(e=o)}return e?e.toISOString():null}handleWebSocketEvent(e){switch(e.type){case"message":let n=e.data;if(this.session){let p=this.session.messages.findIndex(l=>l.id===n.id);if(p<0&&n.sender==="visitor"&&(p=this.session.messages.findIndex(l=>l.id.startsWith("temp-")&&l.content===n.content&&l.sender==="visitor"),p>=0&&(this.session.messages[p].id=n.id)),p<0&&n.sender!=="visitor"){let l=new Date(n.timestamp).getTime();p=this.session.messages.findIndex(f=>f.sender===n.sender&&f.content===n.content&&Math.abs(new Date(f.timestamp).getTime()-l)<2e3)}if(p>=0){let l=this.session.messages[p],f=!1;n.status&&n.status!==l.status&&(l.status=n.status,f=!0,n.deliveredAt&&(l.deliveredAt=n.deliveredAt),n.readAt&&(l.readAt=n.readAt),this.emit("read",{messageIds:[n.id],status:n.status})),n.content!==void 0&&n.content!==l.content&&(l.content=n.content,f=!0),n.editedAt!==void 0&&n.editedAt!==l.editedAt&&(l.editedAt=n.editedAt,f=!0),n.deletedAt!==void 0&&n.deletedAt!==l.deletedAt&&(l.deletedAt=n.deletedAt,f=!0),n.replyTo!==void 0&&(l.replyTo=n.replyTo,f=!0),n.attachments!==void 0&&(l.attachments=n.attachments,f=!0),f&&this.emit("message",l)}else this.session.messages.push(n),this.emit("message",n),this.config.onMessage?.(n),n.sender!=="visitor"&&!this.isOpen&&(this.config.autoOpenOnMessage??!0)&&this.setOpen(!0)}n.sender!=="visitor"&&this.emit("typing",{isTyping:!1});break;case"typing":let r=e.data;r.sender!=="visitor"&&this.emit("typing",{isTyping:r.isTyping});break;case"presence":this.session&&(this.session.operatorOnline=e.data.online),this.emit("presence",e.data);break;case"ai_takeover":this.emit("aiTakeover",e.data);break;case"read":let o=e.data;if(this.session)for(let p of this.session.messages)o.messageIds.includes(p.id)&&(p.status=o.status,o.deliveredAt&&(p.deliveredAt=o.deliveredAt),o.readAt&&(p.readAt=o.readAt));this.emit("read",o);break;case"message_edited":if(this.session){let p=e.data,l=this.session.messages.findIndex(f=>f.id===p.messageId);if(l>=0){let f=this.session.messages[l];f.content=p.content,f.editedAt=p.editedAt??new Date().toISOString(),this.emit("message",f)}}break;case"message_deleted":if(this.session){let p=e.data,l=this.session.messages.findIndex(f=>f.id===p.messageId);if(l>=0){let f=this.session.messages[l];f.deletedAt=p.deletedAt??new Date().toISOString(),this.emit("message",f)}}break;case"event":let d=e.data;this.emitCustomEvent(d);break;case"version_warning":let i=e.data;this.handleVersionWarning(i);break;case"config_update":let s=e.data;s.trackedElements&&(this.setupTrackedElements(s.trackedElements),this.emit("configUpdate",s));break}}handleVersionWarning(e){let n="[PocketPing]",r=e.upgradeUrl?` Upgrade: ${e.upgradeUrl}`:" Update your widget to the latest version.";switch(e.severity){case"error":console.error(`${n} \u{1F6A8} VERSION ERROR: ${e.message}${r}`),console.error(`${n} Current: ${e.currentVersion}, Required: ${e.minVersion||"unknown"}`);break;case"warning":console.warn(`${n} \u26A0\uFE0F VERSION WARNING: ${e.message}${r}`),console.warn(`${n} Current: ${e.currentVersion}, Latest: ${e.latestVersion||"unknown"}`);break;case"info":console.info(`${n} \u2139\uFE0F ${e.message}`);break}this.emit("versionWarning",e),this.config.onVersionWarning?.(e),e.canContinue||(console.error(`${n} Widget is incompatible with backend. Please update immediately.`),this.disconnect())}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts){console.warn("[PocketPing] Max reconnect attempts reached, trying SSE"),this.connectSSE();return}let e=Math.min(1e3*Math.pow(2,this.reconnectAttempts),3e4);this.reconnectAttempts++,this.reconnectTimeout=setTimeout(()=>{this.connectWebSocket()},e)}startPolling(){let e=async()=>{if(this.session){try{let n=this.getLastEventTimestamp(),r=await this.fetchMessages(n??void 0);this.pollingFailures=0;for(let o of r){let d=this.session.messages.findIndex(i=>i.id===o.id);if(d>=0){let i=this.session.messages[d],s=!1;o.status&&o.status!==i.status&&(i.status=o.status,s=!0,o.deliveredAt&&(i.deliveredAt=o.deliveredAt),o.readAt&&(i.readAt=o.readAt),this.emit("read",{messageIds:[o.id],status:o.status})),o.content!==void 0&&o.content!==i.content&&(i.content=o.content,s=!0),o.editedAt!==void 0&&o.editedAt!==i.editedAt&&(i.editedAt=o.editedAt,s=!0),o.deletedAt!==void 0&&o.deletedAt!==i.deletedAt&&(i.deletedAt=o.deletedAt,s=!0),o.replyTo!==void 0&&(i.replyTo=o.replyTo,s=!0),o.attachments!==void 0&&(i.attachments=o.attachments,s=!0),s&&this.emit("message",i)}else this.session.messages.push(o),this.emit("message",o),this.config.onMessage?.(o),o.sender!=="visitor"&&!this.isOpen&&(this.config.autoOpenOnMessage??!0)&&this.setOpen(!0)}}catch(n){if(this.pollingFailures++,console.error("[PocketPing] \u274C Polling error:",n),(this.pollingFailures<=3||this.pollingFailures%3===0)&&console.warn(`[PocketPing] Polling failed (${this.pollingFailures}/${this.maxPollingFailures})`),this.pollingFailures>=this.maxPollingFailures){console.error("[PocketPing] Polling disabled after too many failures. Real-time updates unavailable."),this.emit("pollingDisabled",{failures:this.pollingFailures});return}}if(this.session){let n=this.pollingFailures>0?Math.min(2e3*Math.pow(2,this.pollingFailures-1),3e4):2e3;this.pollingTimeout=setTimeout(e,n)}}};this.pollingTimeout=setTimeout(e,500)}stopPolling(){this.pollingTimeout&&(clearTimeout(this.pollingTimeout),this.pollingTimeout=null),this.pollingFailures=0}setupUnloadListeners(){this.boundHandleUnload=()=>this.notifyDisconnect(),window.addEventListener("beforeunload",this.boundHandleUnload),window.addEventListener("pagehide",this.boundHandleUnload),this.boundHandleVisibilityChange=()=>{document.visibilityState==="hidden"?this.sendVisibilityPing("hidden"):document.visibilityState==="visible"&&this.sendVisibilityPing("visible")},document.addEventListener("visibilitychange",this.boundHandleVisibilityChange)}cleanupUnloadListeners(){this.boundHandleUnload&&(window.removeEventListener("beforeunload",this.boundHandleUnload),window.removeEventListener("pagehide",this.boundHandleUnload),this.boundHandleUnload=null),this.boundHandleVisibilityChange&&(document.removeEventListener("visibilitychange",this.boundHandleVisibilityChange),this.boundHandleVisibilityChange=null)}notifyDisconnect(){if(this.disconnectNotified||!this.session)return;this.disconnectNotified=!0;let e=this.connectedAt?Math.round((Date.now()-this.connectedAt)/1e3):0,n=this.config.endpoint.replace(/\/$/,"")+"/disconnect",r=JSON.stringify({sessionId:this.session.sessionId,duration:e,reason:"page_unload"});if(navigator.sendBeacon){let o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)}else try{let o=new XMLHttpRequest;o.open("POST",n,!1),o.setRequestHeader("Content-Type","application/json"),o.send(r)}catch{}}sendVisibilityPing(e){if(!this.session)return;let n=this.config.endpoint.replace(/\/$/,"")+"/visibility",r=JSON.stringify({sessionId:this.session.sessionId,state:e,timestamp:Date.now()});if(e==="hidden"&&navigator.sendBeacon){let o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)}else fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0}).catch(()=>{})}async fetch(e,n){let r=this.config.endpoint.replace(/\/$/,"")+e,o=await fetch(r,{...n,headers:{"Content-Type":"application/json","X-PocketPing-Version":$t,...n.headers}});if(this.checkVersionHeaders(o),!o.ok){let d=await o.text();throw new Error(`PocketPing API error: ${o.status} ${d}`)}return o.json()}checkVersionHeaders(e){let n=e.headers.get("X-PocketPing-Version-Status"),r=e.headers.get("X-PocketPing-Min-Version"),o=e.headers.get("X-PocketPing-Latest-Version"),d=e.headers.get("X-PocketPing-Version-Message");if(!n||n==="ok")return;let i="info",s=!0;n==="deprecated"?i="warning":n==="unsupported"?(i="error",s=!1):n==="outdated"&&(i="info");let p={severity:i,message:d||`Widget version ${$t} is ${n}`,currentVersion:$t,minVersion:r||void 0,latestVersion:o||void 0,canContinue:s,upgradeUrl:"https://docs.pocketping.io/widget/installation"};this.handleVersionWarning(p)}getOrCreateVisitorId(){let e="pocketping_visitor_id",n=localStorage.getItem(e);return n||(n=this.generateId(),localStorage.setItem(e,n)),n}getStoredSessionId(){return localStorage.getItem("pocketping_session_id")}storeSessionId(e){localStorage.setItem("pocketping_session_id",e)}getStoredIdentity(){try{let e=localStorage.getItem("pocketping_user_identity");return e?JSON.parse(e):null}catch{return null}}storeIdentity(e){localStorage.setItem("pocketping_user_identity",JSON.stringify(e))}clearIdentity(){localStorage.removeItem("pocketping_user_identity")}generateId(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}};var P=null,ie=null,jd="https://app.pocketping.io/api/widget";function ln(t){if(P)return console.warn("[PocketPing] Already initialized"),P;let e=t.endpoint;if(!e&&t.projectId&&(e=`${jd}/${t.projectId}`),!e)throw new Error("[PocketPing] endpoint or projectId is required");let n={...t,endpoint:e};return P=new ht(n),ie=document.createElement("div"),ie.id="pocketping-container",document.body.appendChild(ie),kt(Ct(Vr,{client:P,config:t}),ie),P.connect().catch(r=>{console.error("[PocketPing] Failed to connect:",r)}),P}function zr(){ie&&(kt(null,ie),ie.remove(),ie=null),P&&(P.disconnect(),P=null)}function Kr(){P?.setOpen(!0)}function Xr(){P?.setOpen(!1)}function Yr(){P?.toggleOpen()}function qr(t,e){if(!P)throw new Error("[PocketPing] Not initialized");return P.sendMessage(t,e)}async function Jr(t,e){if(!P)throw new Error("[PocketPing] Not initialized");return P.uploadFile(t,e)}async function Zr(t,e){if(!P)throw new Error("[PocketPing] Not initialized");return P.uploadFiles(t,e)}function Qr(t,e,n){if(!P){console.warn("[PocketPing] Not initialized, cannot trigger event");return}P.trigger(t,e,n)}function eo(t){if(!P){console.warn("[PocketPing] Not initialized, cannot setup tracked elements");return}P.setupTrackedElements(t)}function to(){return P?.getTrackedElements()||[]}function no(t,e){return P?P.onEvent(t,e):(console.warn("[PocketPing] Not initialized, cannot subscribe to event"),()=>{})}function ro(t,e){P?.offEvent(t,e)}async function oo(t){if(!P)throw new Error("[PocketPing] Not initialized");return P.identify(t)}async function io(t){if(!P){console.warn("[PocketPing] Not initialized");return}return P.reset(t)}function so(){return P?.getIdentity()||null}function ao(t,e){return P?P.on(t,e):(console.warn("[PocketPing] Not initialized, cannot subscribe to event"),()=>{})}if(typeof document<"u"){let t=document.currentScript;if(t){let e=t.dataset.projectId,n=t.dataset.endpoint;(e||n)&&ln({projectId:e,endpoint:n,theme:t.dataset.theme||"auto",position:t.dataset.position||"bottom-right"})}}var Gd={init:ln,destroy:zr,open:Kr,close:Xr,toggle:Yr,sendMessage:qr,uploadFile:Jr,uploadFiles:Zr,trigger:Qr,onEvent:no,offEvent:ro,on:ao,identify:oo,reset:io,getIdentity:so,setupTrackedElements:eo,getTrackedElements:to};return Oo(Vd);})();
|
|
1619
|
+
`,setTimeout(()=>{c&&this.inspectorMode&&(c.innerHTML=$,document.getElementById("pp-inspector-exit")?.addEventListener("click",()=>{this.disableInspectorMode()}))},2e3)}console.info(`[PocketPing] \u{1F4CC} Selector captured: ${f}`)};document.addEventListener("mouseover",d,!0),document.addEventListener("mouseout",i,!0),document.addEventListener("click",s,!0),this.inspectorCleanup=()=>{document.removeEventListener("mouseover",d,!0),document.removeEventListener("mouseout",i,!0),document.removeEventListener("click",s,!0),e.remove(),r&&r.classList.remove("pp-inspector-highlight")},document.getElementById("pp-inspector-exit")?.addEventListener("click",()=>{this.disableInspectorMode()})}disableInspectorMode(){this.inspectorMode&&(this.inspectorMode=!1,this.inspectorCleanup&&(this.inspectorCleanup(),this.inspectorCleanup=null),console.info("[PocketPing] Inspector mode disabled"),this.emit("inspectorDisabled",null))}isInspectorModeActive(){return this.inspectorMode}connectRealtime(){if(this.session){if(this.connectionMode==="polling"){this.startPolling();return}if(this.connectionMode==="sse"){this.connectSSE();return}this.connectWebSocket()}}connectWebSocket(){if(!this.session)return;let e=this.config.endpoint.replace(/^http/,"ws").replace(/\/$/,"")+`/stream?sessionId=${this.session.sessionId}`;try{this.ws=new WebSocket(e),this.wsConnectedAt=Date.now();let n=setTimeout(()=>{console.warn("[PocketPing] \u23F1\uFE0F WebSocket timeout - trying SSE"),this.ws&&this.ws.readyState!==WebSocket.OPEN&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.onopen=null,this.ws.close(),this.ws=null,this.connectSSE())},5e3);this.ws.onopen=()=>{clearTimeout(n),this.connectionMode="ws",this.reconnectAttempts=0,this.wsConnectedAt=Date.now(),this.emit("wsConnected",null)},this.ws.onmessage=r=>{try{let o=JSON.parse(r.data);this.handleRealtimeEvent(o)}catch(o){console.error("[PocketPing] Failed to parse WS message:",o)}},this.ws.onclose=()=>{clearTimeout(n),this.emit("wsDisconnected",null),this.handleWsFailure()},this.ws.onerror=()=>{clearTimeout(n)}}catch{console.warn("[PocketPing] WebSocket unavailable - trying SSE"),this.connectSSE()}}connectSSE(){if(!this.session)return;let e=new URLSearchParams({sessionId:this.session.sessionId}),n=this.getLastEventTimestamp();n&&e.set("after",n);let r=this.config.endpoint.replace(/\/$/,"")+`/stream?${e.toString()}`;try{this.sse=new EventSource(r);let o=setTimeout(()=>{console.warn("[PocketPing] \u23F1\uFE0F SSE timeout - falling back to polling"),this.sse&&this.sse.readyState!==EventSource.OPEN&&(this.sse.close(),this.sse=null,this.connectionMode="polling",this.startPolling())},5e3);this.sse.onopen=()=>{clearTimeout(o),this.connectionMode="sse",this.emit("sseConnected",null)},this.sse.addEventListener("message",d=>{try{let i=JSON.parse(d.data);this.handleRealtimeEvent(i)}catch(i){console.error("[PocketPing] Failed to parse SSE message:",i)}}),this.sse.addEventListener("connected",()=>{}),this.sse.onerror=()=>{clearTimeout(o),console.warn("[PocketPing] \u274C SSE error - falling back to polling"),this.sse&&(this.sse.close(),this.sse=null),this.connectionMode="polling",this.startPolling()}}catch{console.warn("[PocketPing] SSE unavailable - falling back to polling"),this.connectionMode="polling",this.startPolling()}}handleWsFailure(){if(Date.now()-this.wsConnectedAt<this.quickFailureThreshold){console.info("[PocketPing] WebSocket failed quickly - trying SSE"),this.connectSSE();return}this.scheduleReconnect()}handleRealtimeEvent(e){this.handleWebSocketEvent(e)}getLastEventTimestamp(){if(!this.session)return null;let e=null;for(let n of this.session.messages){let r=[n.timestamp,n.editedAt,n.deletedAt,n.deliveredAt,n.readAt].filter(Boolean).map(o=>new Date(o)).filter(o=>!isNaN(o.getTime()));for(let o of r)(!e||o>e)&&(e=o)}return e?e.toISOString():null}handleWebSocketEvent(e){switch(e.type){case"message":let n=e.data;if(this.session){let p=this.session.messages.findIndex(l=>l.id===n.id);if(p<0&&n.sender==="visitor"&&(p=this.session.messages.findIndex(l=>l.id.startsWith("temp-")&&l.content===n.content&&l.sender==="visitor"),p>=0&&(this.session.messages[p].id=n.id)),p<0&&n.sender!=="visitor"){let l=new Date(n.timestamp).getTime();p=this.session.messages.findIndex(f=>f.sender===n.sender&&f.content===n.content&&Math.abs(new Date(f.timestamp).getTime()-l)<2e3)}if(p>=0){let l=this.session.messages[p],f=!1;n.status&&n.status!==l.status&&(l.status=n.status,f=!0,n.deliveredAt&&(l.deliveredAt=n.deliveredAt),n.readAt&&(l.readAt=n.readAt),this.emit("read",{messageIds:[n.id],status:n.status})),n.content!==void 0&&n.content!==l.content&&(l.content=n.content,f=!0),n.editedAt!==void 0&&n.editedAt!==l.editedAt&&(l.editedAt=n.editedAt,f=!0),n.deletedAt!==void 0&&n.deletedAt!==l.deletedAt&&(l.deletedAt=n.deletedAt,f=!0),n.replyTo!==void 0&&(l.replyTo=n.replyTo,f=!0),n.attachments!==void 0&&(l.attachments=n.attachments,f=!0),f&&this.emit("message",l)}else this.session.messages.push(n),this.emit("message",n),this.config.onMessage?.(n),n.sender!=="visitor"&&!this.isOpen&&(this.config.autoOpenOnMessage??!0)&&this.setOpen(!0)}n.sender!=="visitor"&&this.emit("typing",{isTyping:!1});break;case"typing":let r=e.data;r.sender!=="visitor"&&this.emit("typing",{isTyping:r.isTyping});break;case"presence":this.session&&(this.session.operatorOnline=e.data.online),this.emit("presence",e.data);break;case"ai_takeover":this.emit("aiTakeover",e.data);break;case"read":let o=e.data;if(this.session)for(let p of this.session.messages)o.messageIds.includes(p.id)&&(p.status=o.status,o.deliveredAt&&(p.deliveredAt=o.deliveredAt),o.readAt&&(p.readAt=o.readAt));this.emit("read",o);break;case"message_edited":if(this.session){let p=e.data,l=this.session.messages.findIndex(f=>f.id===p.messageId);if(l>=0){let f=this.session.messages[l];f.content=p.content,f.editedAt=p.editedAt??new Date().toISOString(),this.emit("message",f)}}break;case"message_deleted":if(this.session){let p=e.data,l=this.session.messages.findIndex(f=>f.id===p.messageId);if(l>=0){let f=this.session.messages[l];f.deletedAt=p.deletedAt??new Date().toISOString(),this.emit("message",f)}}break;case"event":let d=e.data;this.emitCustomEvent(d);break;case"version_warning":let i=e.data;this.handleVersionWarning(i);break;case"config_update":let s=e.data;s.trackedElements&&(this.setupTrackedElements(s.trackedElements),this.emit("configUpdate",s));break}}handleVersionWarning(e){let n="[PocketPing]",r=e.upgradeUrl?` Upgrade: ${e.upgradeUrl}`:" Update your widget to the latest version.";switch(e.severity){case"error":console.error(`${n} \u{1F6A8} VERSION ERROR: ${e.message}${r}`),console.error(`${n} Current: ${e.currentVersion}, Required: ${e.minVersion||"unknown"}`);break;case"warning":console.warn(`${n} \u26A0\uFE0F VERSION WARNING: ${e.message}${r}`),console.warn(`${n} Current: ${e.currentVersion}, Latest: ${e.latestVersion||"unknown"}`);break;case"info":console.info(`${n} \u2139\uFE0F ${e.message}`);break}this.emit("versionWarning",e),this.config.onVersionWarning?.(e),e.canContinue||(console.error(`${n} Widget is incompatible with backend. Please update immediately.`),this.disconnect())}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts){console.warn("[PocketPing] Max reconnect attempts reached, trying SSE"),this.connectSSE();return}let e=Math.min(1e3*Math.pow(2,this.reconnectAttempts),3e4);this.reconnectAttempts++,this.reconnectTimeout=setTimeout(()=>{this.connectWebSocket()},e)}startPolling(){let e=async()=>{if(this.session){try{let n=this.getLastEventTimestamp(),r=await this.fetchMessages(n??void 0);this.pollingFailures=0;for(let o of r){let d=this.session.messages.findIndex(i=>i.id===o.id);if(d>=0){let i=this.session.messages[d],s=!1;o.status&&o.status!==i.status&&(i.status=o.status,s=!0,o.deliveredAt&&(i.deliveredAt=o.deliveredAt),o.readAt&&(i.readAt=o.readAt),this.emit("read",{messageIds:[o.id],status:o.status})),o.content!==void 0&&o.content!==i.content&&(i.content=o.content,s=!0),o.editedAt!==void 0&&o.editedAt!==i.editedAt&&(i.editedAt=o.editedAt,s=!0),o.deletedAt!==void 0&&o.deletedAt!==i.deletedAt&&(i.deletedAt=o.deletedAt,s=!0),o.replyTo!==void 0&&(i.replyTo=o.replyTo,s=!0),o.attachments!==void 0&&(i.attachments=o.attachments,s=!0),s&&this.emit("message",i)}else this.session.messages.push(o),this.emit("message",o),this.config.onMessage?.(o),o.sender!=="visitor"&&!this.isOpen&&(this.config.autoOpenOnMessage??!0)&&this.setOpen(!0)}}catch(n){if(this.pollingFailures++,console.error("[PocketPing] \u274C Polling error:",n),(this.pollingFailures<=3||this.pollingFailures%3===0)&&console.warn(`[PocketPing] Polling failed (${this.pollingFailures}/${this.maxPollingFailures})`),this.pollingFailures>=this.maxPollingFailures){console.error("[PocketPing] Polling disabled after too many failures. Real-time updates unavailable."),this.emit("pollingDisabled",{failures:this.pollingFailures});return}}if(this.session){let n=this.pollingFailures>0?Math.min(2e3*Math.pow(2,this.pollingFailures-1),3e4):2e3;this.pollingTimeout=setTimeout(e,n)}}};this.pollingTimeout=setTimeout(e,500)}stopPolling(){this.pollingTimeout&&(clearTimeout(this.pollingTimeout),this.pollingTimeout=null),this.pollingFailures=0}setupUnloadListeners(){console.log("[PocketPing] Setting up unload listeners"),this.boundHandleUnload=()=>{console.log("[PocketPing] beforeunload/pagehide fired"),this.notifyDisconnect()},window.addEventListener("beforeunload",this.boundHandleUnload),window.addEventListener("pagehide",this.boundHandleUnload),this.boundHandleVisibilityChange=()=>{document.visibilityState==="hidden"?this.sendVisibilityPing("hidden"):document.visibilityState==="visible"&&this.sendVisibilityPing("visible")},document.addEventListener("visibilitychange",this.boundHandleVisibilityChange)}cleanupUnloadListeners(){this.boundHandleUnload&&(window.removeEventListener("beforeunload",this.boundHandleUnload),window.removeEventListener("pagehide",this.boundHandleUnload),this.boundHandleUnload=null),this.boundHandleVisibilityChange&&(document.removeEventListener("visibilitychange",this.boundHandleVisibilityChange),this.boundHandleVisibilityChange=null)}notifyDisconnect(){if(console.log("[PocketPing] notifyDisconnect called",{disconnectNotified:this.disconnectNotified,hasSession:!!this.session,sessionId:this.session?.sessionId}),this.disconnectNotified||!this.session){console.log("[PocketPing] Skipping disconnect notification (already notified or no session)");return}this.disconnectNotified=!0;let e=this.connectedAt?Math.round((Date.now()-this.connectedAt)/1e3):0,n=this.config.endpoint.replace(/\/$/,"")+"/disconnect",r=JSON.stringify({sessionId:this.session.sessionId,duration:e,reason:"page_unload"});if(console.log("[PocketPing] Sending disconnect beacon to:",n,"data:",r),navigator.sendBeacon){let o=new Blob([r],{type:"application/json"}),d=navigator.sendBeacon(n,o);console.log("[PocketPing] sendBeacon result:",d)}else try{let o=new XMLHttpRequest;o.open("POST",n,!1),o.setRequestHeader("Content-Type","application/json"),o.send(r)}catch{}}sendVisibilityPing(e){if(!this.session)return;let n=this.config.endpoint.replace(/\/$/,"")+"/visibility",r=JSON.stringify({sessionId:this.session.sessionId,state:e,timestamp:Date.now()});if(e==="hidden"&&navigator.sendBeacon){let o=new Blob([r],{type:"application/json"});navigator.sendBeacon(n,o)}else fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0}).catch(()=>{})}async fetch(e,n){let r=this.config.endpoint.replace(/\/$/,"")+e,o=await fetch(r,{...n,headers:{"Content-Type":"application/json","X-PocketPing-Version":$t,...n.headers}});if(this.checkVersionHeaders(o),!o.ok){let d=await o.text();throw new Error(`PocketPing API error: ${o.status} ${d}`)}return o.json()}checkVersionHeaders(e){let n=e.headers.get("X-PocketPing-Version-Status"),r=e.headers.get("X-PocketPing-Min-Version"),o=e.headers.get("X-PocketPing-Latest-Version"),d=e.headers.get("X-PocketPing-Version-Message");if(!n||n==="ok")return;let i="info",s=!0;n==="deprecated"?i="warning":n==="unsupported"?(i="error",s=!1):n==="outdated"&&(i="info");let p={severity:i,message:d||`Widget version ${$t} is ${n}`,currentVersion:$t,minVersion:r||void 0,latestVersion:o||void 0,canContinue:s,upgradeUrl:"https://docs.pocketping.io/widget/installation"};this.handleVersionWarning(p)}getOrCreateVisitorId(){let e="pocketping_visitor_id",n=localStorage.getItem(e);return n||(n=this.generateId(),localStorage.setItem(e,n)),n}getStoredSessionId(){return localStorage.getItem("pocketping_session_id")}storeSessionId(e){localStorage.setItem("pocketping_session_id",e)}getStoredIdentity(){try{let e=localStorage.getItem("pocketping_user_identity");return e?JSON.parse(e):null}catch{return null}}storeIdentity(e){localStorage.setItem("pocketping_user_identity",JSON.stringify(e))}clearIdentity(){localStorage.removeItem("pocketping_user_identity")}generateId(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`}};var P=null,ie=null,Gd="https://app.pocketping.io/api/widget";function ln(t){if(P)return console.warn("[PocketPing] Already initialized"),P;let e=t.endpoint;if(!e&&t.projectId&&(e=`${Gd}/${t.projectId}`),!e)throw new Error("[PocketPing] endpoint or projectId is required");let n={...t,endpoint:e};return P=new ht(n),ie=document.createElement("div"),ie.id="pocketping-container",document.body.appendChild(ie),kt(Ct(Vr,{client:P,config:t}),ie),P.connect().catch(r=>{console.error("[PocketPing] Failed to connect:",r)}),P}function zr(){ie&&(kt(null,ie),ie.remove(),ie=null),P&&(P.disconnect(),P=null)}function Kr(){P?.setOpen(!0)}function Xr(){P?.setOpen(!1)}function Yr(){P?.toggleOpen()}function qr(t,e){if(!P)throw new Error("[PocketPing] Not initialized");return P.sendMessage(t,e)}async function Jr(t,e){if(!P)throw new Error("[PocketPing] Not initialized");return P.uploadFile(t,e)}async function Zr(t,e){if(!P)throw new Error("[PocketPing] Not initialized");return P.uploadFiles(t,e)}function Qr(t,e,n){if(!P){console.warn("[PocketPing] Not initialized, cannot trigger event");return}P.trigger(t,e,n)}function eo(t){if(!P){console.warn("[PocketPing] Not initialized, cannot setup tracked elements");return}P.setupTrackedElements(t)}function to(){return P?.getTrackedElements()||[]}function no(t,e){return P?P.onEvent(t,e):(console.warn("[PocketPing] Not initialized, cannot subscribe to event"),()=>{})}function ro(t,e){P?.offEvent(t,e)}async function oo(t){if(!P)throw new Error("[PocketPing] Not initialized");return P.identify(t)}async function io(t){if(!P){console.warn("[PocketPing] Not initialized");return}return P.reset(t)}function so(){return P?.getIdentity()||null}function ao(t,e){return P?P.on(t,e):(console.warn("[PocketPing] Not initialized, cannot subscribe to event"),()=>{})}if(typeof document<"u"){let t=document.currentScript;if(t){let e=t.dataset.projectId,n=t.dataset.endpoint;(e||n)&&ln({projectId:e,endpoint:n,theme:t.dataset.theme||"auto",position:t.dataset.position||"bottom-right"})}}var Vd={init:ln,destroy:zr,open:Kr,close:Xr,toggle:Yr,sendMessage:qr,uploadFile:Jr,uploadFiles:Zr,trigger:Qr,onEvent:no,offEvent:ro,on:ao,identify:oo,reset:io,getIdentity:so,setupTrackedElements:eo,getTrackedElements:to};return Oo(Wd);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pocketping/widget",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Embeddable chat widget for PocketPing",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@preact/preset-vite": "^2.10.2",
|
|
35
35
|
"@testing-library/preact": "^3.2.4",
|
|
36
36
|
"@vitest/coverage-v8": "^4.0.18",
|
|
37
|
-
"jsdom": "^
|
|
37
|
+
"jsdom": "^28.0.0",
|
|
38
38
|
"tsup": "^8.0.0",
|
|
39
39
|
"typescript": "^5.3.0",
|
|
40
40
|
"vitest": "^4.0.18"
|