@pocketping/widget 0.3.4 → 1.0.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 +28 -4
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +28 -4
- package/dist/pocketping.min.global.js +8 -5
- package/package.json +27 -10
- package/LICENSE +0 -21
package/dist/index.cjs
CHANGED
|
@@ -116,6 +116,7 @@ function styles(primaryColor, theme) {
|
|
|
116
116
|
width: 380px;
|
|
117
117
|
height: 520px;
|
|
118
118
|
max-height: calc(100vh - 100px);
|
|
119
|
+
max-height: calc(100dvh - 100px);
|
|
119
120
|
background: ${colors.bg};
|
|
120
121
|
border-radius: 16px;
|
|
121
122
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
|
|
@@ -138,7 +139,9 @@ function styles(primaryColor, theme) {
|
|
|
138
139
|
@media (max-width: 480px) {
|
|
139
140
|
.pp-window {
|
|
140
141
|
width: calc(100vw - 20px);
|
|
141
|
-
height:
|
|
142
|
+
height: auto;
|
|
143
|
+
max-height: calc(100vh - 100px);
|
|
144
|
+
max-height: calc(100dvh - 100px);
|
|
142
145
|
bottom: 80px;
|
|
143
146
|
right: 10px;
|
|
144
147
|
left: 10px;
|
|
@@ -639,7 +642,7 @@ function StatusIcon({ status }) {
|
|
|
639
642
|
}
|
|
640
643
|
|
|
641
644
|
// src/version.ts
|
|
642
|
-
var VERSION = "0.3.
|
|
645
|
+
var VERSION = "0.3.6";
|
|
643
646
|
|
|
644
647
|
// src/client.ts
|
|
645
648
|
var PocketPingClient = class {
|
|
@@ -652,6 +655,9 @@ var PocketPingClient = class {
|
|
|
652
655
|
this.reconnectAttempts = 0;
|
|
653
656
|
this.maxReconnectAttempts = 5;
|
|
654
657
|
this.reconnectTimeout = null;
|
|
658
|
+
this.pollingTimeout = null;
|
|
659
|
+
this.pollingFailures = 0;
|
|
660
|
+
this.maxPollingFailures = 10;
|
|
655
661
|
this.trackedElementCleanups = [];
|
|
656
662
|
this.currentTrackedElements = [];
|
|
657
663
|
this.inspectorMode = false;
|
|
@@ -711,6 +717,7 @@ var PocketPingClient = class {
|
|
|
711
717
|
if (this.reconnectTimeout) {
|
|
712
718
|
clearTimeout(this.reconnectTimeout);
|
|
713
719
|
}
|
|
720
|
+
this.stopPolling();
|
|
714
721
|
this.cleanupTrackedElements();
|
|
715
722
|
this.disableInspectorMode();
|
|
716
723
|
}
|
|
@@ -1465,6 +1472,7 @@ var PocketPingClient = class {
|
|
|
1465
1472
|
try {
|
|
1466
1473
|
const lastMessageId = this.session.messages[this.session.messages.length - 1]?.id;
|
|
1467
1474
|
const newMessages = await this.fetchMessages(lastMessageId);
|
|
1475
|
+
this.pollingFailures = 0;
|
|
1468
1476
|
for (const message of newMessages) {
|
|
1469
1477
|
if (!this.session.messages.find((m) => m.id === message.id)) {
|
|
1470
1478
|
this.session.messages.push(message);
|
|
@@ -1473,14 +1481,30 @@ var PocketPingClient = class {
|
|
|
1473
1481
|
}
|
|
1474
1482
|
}
|
|
1475
1483
|
} catch (err) {
|
|
1476
|
-
|
|
1484
|
+
this.pollingFailures++;
|
|
1485
|
+
if (this.pollingFailures <= 3 || this.pollingFailures % 3 === 0) {
|
|
1486
|
+
console.warn(`[PocketPing] Polling failed (${this.pollingFailures}/${this.maxPollingFailures})`);
|
|
1487
|
+
}
|
|
1488
|
+
if (this.pollingFailures >= this.maxPollingFailures) {
|
|
1489
|
+
console.error("[PocketPing] Polling disabled after too many failures. Real-time updates unavailable.");
|
|
1490
|
+
this.emit("pollingDisabled", { failures: this.pollingFailures });
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1477
1493
|
}
|
|
1478
1494
|
if (this.session) {
|
|
1479
|
-
|
|
1495
|
+
const delay = this.pollingFailures > 0 ? Math.min(3e3 * Math.pow(2, this.pollingFailures - 1), 3e4) : 3e3;
|
|
1496
|
+
this.pollingTimeout = setTimeout(poll, delay);
|
|
1480
1497
|
}
|
|
1481
1498
|
};
|
|
1482
1499
|
poll();
|
|
1483
1500
|
}
|
|
1501
|
+
stopPolling() {
|
|
1502
|
+
if (this.pollingTimeout) {
|
|
1503
|
+
clearTimeout(this.pollingTimeout);
|
|
1504
|
+
this.pollingTimeout = null;
|
|
1505
|
+
}
|
|
1506
|
+
this.pollingFailures = 0;
|
|
1507
|
+
}
|
|
1484
1508
|
// ─────────────────────────────────────────────────────────────────
|
|
1485
1509
|
// HTTP
|
|
1486
1510
|
// ─────────────────────────────────────────────────────────────────
|
package/dist/index.d.cts
CHANGED
|
@@ -177,6 +177,9 @@ declare class PocketPingClient {
|
|
|
177
177
|
private reconnectAttempts;
|
|
178
178
|
private maxReconnectAttempts;
|
|
179
179
|
private reconnectTimeout;
|
|
180
|
+
private pollingTimeout;
|
|
181
|
+
private pollingFailures;
|
|
182
|
+
private maxPollingFailures;
|
|
180
183
|
private trackedElementCleanups;
|
|
181
184
|
private currentTrackedElements;
|
|
182
185
|
private inspectorMode;
|
|
@@ -286,6 +289,7 @@ declare class PocketPingClient {
|
|
|
286
289
|
private handleVersionWarning;
|
|
287
290
|
private scheduleReconnect;
|
|
288
291
|
private startPolling;
|
|
292
|
+
private stopPolling;
|
|
289
293
|
private fetch;
|
|
290
294
|
private checkVersionHeaders;
|
|
291
295
|
private getOrCreateVisitorId;
|
package/dist/index.d.ts
CHANGED
|
@@ -177,6 +177,9 @@ declare class PocketPingClient {
|
|
|
177
177
|
private reconnectAttempts;
|
|
178
178
|
private maxReconnectAttempts;
|
|
179
179
|
private reconnectTimeout;
|
|
180
|
+
private pollingTimeout;
|
|
181
|
+
private pollingFailures;
|
|
182
|
+
private maxPollingFailures;
|
|
180
183
|
private trackedElementCleanups;
|
|
181
184
|
private currentTrackedElements;
|
|
182
185
|
private inspectorMode;
|
|
@@ -286,6 +289,7 @@ declare class PocketPingClient {
|
|
|
286
289
|
private handleVersionWarning;
|
|
287
290
|
private scheduleReconnect;
|
|
288
291
|
private startPolling;
|
|
292
|
+
private stopPolling;
|
|
289
293
|
private fetch;
|
|
290
294
|
private checkVersionHeaders;
|
|
291
295
|
private getOrCreateVisitorId;
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,7 @@ function styles(primaryColor, theme) {
|
|
|
77
77
|
width: 380px;
|
|
78
78
|
height: 520px;
|
|
79
79
|
max-height: calc(100vh - 100px);
|
|
80
|
+
max-height: calc(100dvh - 100px);
|
|
80
81
|
background: ${colors.bg};
|
|
81
82
|
border-radius: 16px;
|
|
82
83
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
|
|
@@ -99,7 +100,9 @@ function styles(primaryColor, theme) {
|
|
|
99
100
|
@media (max-width: 480px) {
|
|
100
101
|
.pp-window {
|
|
101
102
|
width: calc(100vw - 20px);
|
|
102
|
-
height:
|
|
103
|
+
height: auto;
|
|
104
|
+
max-height: calc(100vh - 100px);
|
|
105
|
+
max-height: calc(100dvh - 100px);
|
|
103
106
|
bottom: 80px;
|
|
104
107
|
right: 10px;
|
|
105
108
|
left: 10px;
|
|
@@ -600,7 +603,7 @@ function StatusIcon({ status }) {
|
|
|
600
603
|
}
|
|
601
604
|
|
|
602
605
|
// src/version.ts
|
|
603
|
-
var VERSION = "0.3.
|
|
606
|
+
var VERSION = "0.3.6";
|
|
604
607
|
|
|
605
608
|
// src/client.ts
|
|
606
609
|
var PocketPingClient = class {
|
|
@@ -613,6 +616,9 @@ var PocketPingClient = class {
|
|
|
613
616
|
this.reconnectAttempts = 0;
|
|
614
617
|
this.maxReconnectAttempts = 5;
|
|
615
618
|
this.reconnectTimeout = null;
|
|
619
|
+
this.pollingTimeout = null;
|
|
620
|
+
this.pollingFailures = 0;
|
|
621
|
+
this.maxPollingFailures = 10;
|
|
616
622
|
this.trackedElementCleanups = [];
|
|
617
623
|
this.currentTrackedElements = [];
|
|
618
624
|
this.inspectorMode = false;
|
|
@@ -672,6 +678,7 @@ var PocketPingClient = class {
|
|
|
672
678
|
if (this.reconnectTimeout) {
|
|
673
679
|
clearTimeout(this.reconnectTimeout);
|
|
674
680
|
}
|
|
681
|
+
this.stopPolling();
|
|
675
682
|
this.cleanupTrackedElements();
|
|
676
683
|
this.disableInspectorMode();
|
|
677
684
|
}
|
|
@@ -1426,6 +1433,7 @@ var PocketPingClient = class {
|
|
|
1426
1433
|
try {
|
|
1427
1434
|
const lastMessageId = this.session.messages[this.session.messages.length - 1]?.id;
|
|
1428
1435
|
const newMessages = await this.fetchMessages(lastMessageId);
|
|
1436
|
+
this.pollingFailures = 0;
|
|
1429
1437
|
for (const message of newMessages) {
|
|
1430
1438
|
if (!this.session.messages.find((m) => m.id === message.id)) {
|
|
1431
1439
|
this.session.messages.push(message);
|
|
@@ -1434,14 +1442,30 @@ var PocketPingClient = class {
|
|
|
1434
1442
|
}
|
|
1435
1443
|
}
|
|
1436
1444
|
} catch (err) {
|
|
1437
|
-
|
|
1445
|
+
this.pollingFailures++;
|
|
1446
|
+
if (this.pollingFailures <= 3 || this.pollingFailures % 3 === 0) {
|
|
1447
|
+
console.warn(`[PocketPing] Polling failed (${this.pollingFailures}/${this.maxPollingFailures})`);
|
|
1448
|
+
}
|
|
1449
|
+
if (this.pollingFailures >= this.maxPollingFailures) {
|
|
1450
|
+
console.error("[PocketPing] Polling disabled after too many failures. Real-time updates unavailable.");
|
|
1451
|
+
this.emit("pollingDisabled", { failures: this.pollingFailures });
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1438
1454
|
}
|
|
1439
1455
|
if (this.session) {
|
|
1440
|
-
|
|
1456
|
+
const delay = this.pollingFailures > 0 ? Math.min(3e3 * Math.pow(2, this.pollingFailures - 1), 3e4) : 3e3;
|
|
1457
|
+
this.pollingTimeout = setTimeout(poll, delay);
|
|
1441
1458
|
}
|
|
1442
1459
|
};
|
|
1443
1460
|
poll();
|
|
1444
1461
|
}
|
|
1462
|
+
stopPolling() {
|
|
1463
|
+
if (this.pollingTimeout) {
|
|
1464
|
+
clearTimeout(this.pollingTimeout);
|
|
1465
|
+
this.pollingTimeout = null;
|
|
1466
|
+
}
|
|
1467
|
+
this.pollingFailures = 0;
|
|
1468
|
+
}
|
|
1445
1469
|
// ─────────────────────────────────────────────────────────────────
|
|
1446
1470
|
// HTTP
|
|
1447
1471
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var PocketPing=(()=>{var Q=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var ct=(t,e)=>{for(var n in e)Q(t,n,{get:e[n],enumerable:!0})},lt=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of rt(e))!at.call(t,o)&&o!==n&&Q(t,o,{get:()=>e[o],enumerable:!(s=it(e,o))||s.enumerable});return t};var pt=t=>lt(Q({},"__esModule",{value:!0}),t);var Mt={};ct(Mt,{close:()=>Je,default:()=>Tt,destroy:()=>Be,getIdentity:()=>st,getTrackedElements:()=>Ke,identify:()=>tt,init:()=>_e,offEvent:()=>et,on:()=>ot,onEvent:()=>Qe,open:()=>qe,reset:()=>nt,sendMessage:()=>Ge,setupTrackedElements:()=>Ze,toggle:()=>Xe,trigger:()=>Ye});var X,f,ve,dt,L,ge,ye,be,ke,se,ee,te,ut,D={},xe=[],_t=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,G=Array.isArray;function O(t,e){for(var n in e)t[n]=e[n];return t}function oe(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function ie(t,e,n){var s,o,i,c={};for(i in e)i=="key"?s=e[i]:i=="ref"?o=e[i]:c[i]=e[i];if(arguments.length>2&&(c.children=arguments.length>3?X.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)c[i]===void 0&&(c[i]=t.defaultProps[i]);return B(t,c,s,o,null)}function B(t,e,n,s,o){var i={type:t,props:e,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++ve,__i:-1,__u:0};return o==null&&f.vnode!=null&&f.vnode(i),i}function C(t){return t.children}function q(t,e){this.props=t,this.context=e}function V(t,e){if(e==null)return t.__?V(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"?V(t):null}function we(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 we(t)}}function fe(t){(!t.__d&&(t.__d=!0)&&L.push(t)&&!J.__r++||ge!=f.debounceRendering)&&((ge=f.debounceRendering)||ye)(J)}function J(){for(var t,e,n,s,o,i,c,l=1;L.length;)L.length>l&&L.sort(be),t=L.shift(),l=L.length,t.__d&&(n=void 0,s=void 0,o=(s=(e=t).__v).__e,i=[],c=[],e.__P&&((n=O({},s)).__v=s.__v+1,f.vnode&&f.vnode(n),re(e.__P,n,s,e.__n,e.__P.namespaceURI,32&s.__u?[o]:null,i,o??V(s),!!(32&s.__u),c),n.__v=s.__v,n.__.__k[n.__i]=n,Pe(i,n,c),s.__e=s.__=null,n.__e!=o&&we(n)));J.__r=0}function Ee(t,e,n,s,o,i,c,l,p,a,_){var r,d,g,k,E,y,b,m=s&&s.__k||xe,T=e.length;for(p=gt(n,e,m,p,T),r=0;r<T;r++)(g=n.__k[r])!=null&&(d=g.__i==-1?D:m[g.__i]||D,g.__i=r,y=re(t,g,d,o,i,c,l,p,a,_),k=g.__e,g.ref&&d.ref!=g.ref&&(d.ref&&ae(d.ref,null,g),_.push(g.ref,g.__c||k,g)),E==null&&k!=null&&(E=k),(b=!!(4&g.__u))||d.__k===g.__k?p=Se(g,p,t,b):typeof g.type=="function"&&y!==void 0?p=y:k&&(p=k.nextSibling),g.__u&=-7);return n.__e=E,p}function gt(t,e,n,s,o){var i,c,l,p,a,_=n.length,r=_,d=0;for(t.__k=new Array(o),i=0;i<o;i++)(c=e[i])!=null&&typeof c!="boolean"&&typeof c!="function"?(typeof c=="string"||typeof c=="number"||typeof c=="bigint"||c.constructor==String?c=t.__k[i]=B(null,c,null,null,null):G(c)?c=t.__k[i]=B(C,{children:c},null,null,null):c.constructor===void 0&&c.__b>0?c=t.__k[i]=B(c.type,c.props,c.key,c.ref?c.ref:null,c.__v):t.__k[i]=c,p=i+d,c.__=t,c.__b=t.__b+1,l=null,(a=c.__i=ft(c,n,p,r))!=-1&&(r--,(l=n[a])&&(l.__u|=2)),l==null||l.__v==null?(a==-1&&(o>_?d--:o<_&&d++),typeof c.type!="function"&&(c.__u|=4)):a!=p&&(a==p-1?d--:a==p+1?d++:(a>p?d--:d++,c.__u|=4))):t.__k[i]=null;if(r)for(i=0;i<_;i++)(l=n[i])!=null&&(2&l.__u)==0&&(l.__e==s&&(s=V(l)),Ce(l,l));return s}function Se(t,e,n,s){var o,i;if(typeof t.type=="function"){for(o=t.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=t,e=Se(o[i],e,n,s));return e}t.__e!=e&&(s&&(e&&t.type&&!e.parentNode&&(e=V(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ft(t,e,n,s){var o,i,c,l=t.key,p=t.type,a=e[n],_=a!=null&&(2&a.__u)==0;if(a===null&&l==null||_&&l==a.key&&p==a.type)return n;if(s>(_?1:0)){for(o=n-1,i=n+1;o>=0||i<e.length;)if((a=e[c=o>=0?o--:i++])!=null&&(2&a.__u)==0&&l==a.key&&p==a.type)return c}return-1}function he(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||_t.test(e)?n:n+"px"}function j(t,e,n,s,o){var i,c;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof s=="string"&&(t.style.cssText=s=""),s)for(e in s)n&&e in n||he(t.style,e,"");if(n)for(e in n)s&&n[e]==s[e]||he(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(ke,"$1")),c=e.toLowerCase(),e=c in t||e=="onFocusOut"||e=="onFocusIn"?c.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=n,n?s?n.u=s.u:(n.u=se,t.addEventListener(e,i?te:ee,i)):t.removeEventListener(e,i?te:ee,i);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 me(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=se++;else if(e.t<n.u)return;return n(f.event?f.event(e):e)}}}function re(t,e,n,s,o,i,c,l,p,a){var _,r,d,g,k,E,y,b,m,T,M,H,R,v,S,I,U,P=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(p=!!(32&n.__u),i=[l=e.__e=n.__e]),(_=f.__b)&&_(e);e:if(typeof P=="function")try{if(b=e.props,m="prototype"in P&&P.prototype.render,T=(_=P.contextType)&&s[_.__c],M=_?T?T.props.value:_.__:s,n.__c?y=(r=e.__c=n.__c).__=r.__E:(m?e.__c=r=new P(b,M):(e.__c=r=new q(b,M),r.constructor=P,r.render=mt),T&&T.sub(r),r.state||(r.state={}),r.__n=s,d=r.__d=!0,r.__h=[],r._sb=[]),m&&r.__s==null&&(r.__s=r.state),m&&P.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=O({},r.__s)),O(r.__s,P.getDerivedStateFromProps(b,r.__s))),g=r.props,k=r.state,r.__v=e,d)m&&P.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),m&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(m&&P.getDerivedStateFromProps==null&&b!==g&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(b,M),e.__v==n.__v||!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(b,r.__s,M)===!1){for(e.__v!=n.__v&&(r.props=b,r.state=r.__s,r.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function($){$&&($.__=e)}),H=0;H<r._sb.length;H++)r.__h.push(r._sb[H]);r._sb=[],r.__h.length&&c.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(b,r.__s,M),m&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(g,k,E)})}if(r.context=M,r.props=b,r.__P=t,r.__e=!1,R=f.__r,v=0,m){for(r.state=r.__s,r.__d=!1,R&&R(e),_=r.render(r.props,r.state,r.context),S=0;S<r._sb.length;S++)r.__h.push(r._sb[S]);r._sb=[]}else do r.__d=!1,R&&R(e),_=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++v<25);r.state=r.__s,r.getChildContext!=null&&(s=O(O({},s),r.getChildContext())),m&&!d&&r.getSnapshotBeforeUpdate!=null&&(E=r.getSnapshotBeforeUpdate(g,k)),I=_,_!=null&&_.type===C&&_.key==null&&(I=Ie(_.props.children)),l=Ee(t,G(I)?I:[I],e,n,s,o,i,c,l,p,a),r.base=e.__e,e.__u&=-161,r.__h.length&&c.push(r),y&&(r.__E=r.__=null)}catch($){if(e.__v=null,p||i!=null)if($.then){for(e.__u|=p?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;i[i.indexOf(l)]=null,e.__e=l}else{for(U=i.length;U--;)oe(i[U]);ne(e)}else e.__e=n.__e,e.__k=n.__k,$.then||ne(e);f.__e($,e,n)}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):l=e.__e=ht(n.__e,e,n,s,o,i,c,p,a);return(_=f.diffed)&&_(e),128&e.__u?void 0:l}function ne(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(ne)}function Pe(t,e,n){for(var s=0;s<n.length;s++)ae(n[s],n[++s],n[++s]);f.__c&&f.__c(e,t),t.some(function(o){try{t=o.__h,o.__h=[],t.some(function(i){i.call(o)})}catch(i){f.__e(i,o.__v)}})}function Ie(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:G(t)?t.map(Ie):O({},t)}function ht(t,e,n,s,o,i,c,l,p){var a,_,r,d,g,k,E,y=n.props||D,b=e.props,m=e.type;if(m=="svg"?o="http://www.w3.org/2000/svg":m=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),i!=null){for(a=0;a<i.length;a++)if((g=i[a])&&"setAttribute"in g==!!m&&(m?g.localName==m:g.nodeType==3)){t=g,i[a]=null;break}}if(t==null){if(m==null)return document.createTextNode(b);t=document.createElementNS(o,m,b.is&&b),l&&(f.__m&&f.__m(e,i),l=!1),i=null}if(m==null)y===b||l&&t.data==b||(t.data=b);else{if(i=i&&X.call(t.childNodes),!l&&i!=null)for(y={},a=0;a<t.attributes.length;a++)y[(g=t.attributes[a]).name]=g.value;for(a in y)if(g=y[a],a!="children"){if(a=="dangerouslySetInnerHTML")r=g;else if(!(a in b)){if(a=="value"&&"defaultValue"in b||a=="checked"&&"defaultChecked"in b)continue;j(t,a,null,g,o)}}for(a in b)g=b[a],a=="children"?d=g:a=="dangerouslySetInnerHTML"?_=g:a=="value"?k=g:a=="checked"?E=g:l&&typeof g!="function"||y[a]===g||j(t,a,g,y[a],o);if(_)l||r&&(_.__html==r.__html||_.__html==t.innerHTML)||(t.innerHTML=_.__html),e.__k=[];else if(r&&(t.innerHTML=""),Ee(e.type=="template"?t.content:t,G(d)?d:[d],e,n,s,m=="foreignObject"?"http://www.w3.org/1999/xhtml":o,i,c,i?i[0]:n.__k&&V(n,0),l,p),i!=null)for(a=i.length;a--;)oe(i[a]);l||(a="value",m=="progress"&&k==null?t.removeAttribute("value"):k!=null&&(k!==t[a]||m=="progress"&&!k||m=="option"&&k!=y[a])&&j(t,a,k,y[a],o),a="checked",E!=null&&E!=t[a]&&j(t,a,E,y[a],o))}return t}function ae(t,e,n){try{if(typeof t=="function"){var s=typeof t.__u=="function";s&&t.__u(),s&&e==null||(t.__u=t(e))}else t.current=e}catch(o){f.__e(o,n)}}function Ce(t,e,n){var s,o;if(f.unmount&&f.unmount(t),(s=t.ref)&&(s.current&&s.current!=t.__e||ae(s,null,e)),(s=t.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(i){f.__e(i,e)}s.base=s.__P=null}if(s=t.__k)for(o=0;o<s.length;o++)s[o]&&Ce(s[o],e,n||typeof t.type!="function");n||oe(t.__e),t.__c=t.__=t.__e=void 0}function mt(t,e,n){return this.constructor(t,n)}function ce(t,e,n){var s,o,i,c;e==document&&(e=document.documentElement),f.__&&f.__(t,e),o=(s=typeof n=="function")?null:n&&n.__k||e.__k,i=[],c=[],re(e,t=(!s&&n||e).__k=ie(C,null,[t]),o||D,D,e.namespaceURI,!s&&n?[n]:o?null:e.firstChild?X.call(e.childNodes):null,i,!s&&n?n:o?o.__e:e.firstChild,s,c),Pe(i,t,c)}X=xe.slice,f={__e:function(t,e,n,s){for(var o,i,c;e=e.__;)if((o=e.__c)&&!o.__)try{if((i=o.constructor)&&i.getDerivedStateFromError!=null&&(o.setState(i.getDerivedStateFromError(t)),c=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(t,s||{}),c=o.__d),c)return o.__E=o}catch(l){t=l}throw t}},ve=0,dt=function(t){return t!=null&&t.constructor===void 0},q.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=O({},this.state),typeof t=="function"&&(t=t(O({},n),this.props)),t&&O(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),fe(this))},q.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),fe(this))},q.prototype.render=C,L=[],ye=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,be=function(t,e){return t.__v.__b-e.__v.__b},J.__r=0,ke=/(PointerCapture)$|Capture$/i,se=0,ee=me(!1),te=me(!0),ut=0;var z,x,le,Te,F=0,We=[],w=f,Me=w.__b,$e=w.__r,Oe=w.diffed,Ae=w.__c,He=w.unmount,Re=w.__;function de(t,e){w.__h&&w.__h(x,t,F||e),F=0;var n=x.__H||(x.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function W(t){return F=1,vt(De,t)}function vt(t,e,n){var s=de(z++,2);if(s.t=t,!s.__c&&(s.__=[n?n(e):De(void 0,e),function(l){var p=s.__N?s.__N[0]:s.__[0],a=s.t(p,l);p!==a&&(s.__N=[a,s.__[1]],s.__c.setState({}))}],s.__c=x,!x.__f)){var o=function(l,p,a){if(!s.__c.__H)return!0;var _=s.__c.__H.__.filter(function(d){return!!d.__c});if(_.every(function(d){return!d.__N}))return!i||i.call(this,l,p,a);var r=s.__c.props!==l;return _.forEach(function(d){if(d.__N){var g=d.__[0];d.__=d.__N,d.__N=void 0,g!==d.__[0]&&(r=!0)}}),i&&i.call(this,l,p,a)||r};x.__f=!0;var i=x.shouldComponentUpdate,c=x.componentWillUpdate;x.componentWillUpdate=function(l,p,a){if(this.__e){var _=i;i=void 0,o(l,p,a),i=_}c&&c.call(this,l,p,a)},x.shouldComponentUpdate=o}return s.__N||s.__}function N(t,e){var n=de(z++,3);!w.__s&&Ue(n.__H,e)&&(n.__=t,n.u=e,x.__H.__h.push(n))}function ue(t){return F=5,Ne(function(){return{current:t}},[])}function Ne(t,e){var n=de(z++,7);return Ue(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function Ve(t,e){return F=8,Ne(function(){return t},e)}function yt(){for(var t;t=We.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Y),t.__H.__h.forEach(pe),t.__H.__h=[]}catch(e){t.__H.__h=[],w.__e(e,t.__v)}}w.__b=function(t){x=null,Me&&Me(t)},w.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Re&&Re(t,e)},w.__r=function(t){$e&&$e(t),z=0;var e=(x=t.__c).__H;e&&(le===x?(e.__h=[],x.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(Y),e.__h.forEach(pe),e.__h=[],z=0)),le=x},w.diffed=function(t){Oe&&Oe(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(We.push(e)!==1&&Te===w.requestAnimationFrame||((Te=w.requestAnimationFrame)||bt)(yt)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),le=x=null},w.__c=function(t,e){e.some(function(n){try{n.__h.forEach(Y),n.__h=n.__h.filter(function(s){return!s.__||pe(s)})}catch(s){e.some(function(o){o.__h&&(o.__h=[])}),e=[],w.__e(s,n.__v)}}),Ae&&Ae(t,e)},w.unmount=function(t){He&&He(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(s){try{Y(s)}catch(o){e=o}}),n.__H=void 0,e&&w.__e(e,n.__v))};var Le=typeof requestAnimationFrame=="function";function bt(t){var e,n=function(){clearTimeout(s),Le&&cancelAnimationFrame(e),setTimeout(t)},s=setTimeout(n,35);Le&&(e=requestAnimationFrame(n))}function Y(t){var e=x,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),x=e}function pe(t){var e=x;t.__c=t.__(),x=e}function Ue(t,e){return!t||t.length!==e.length||e.some(function(n,s){return n!==t[s]})}function De(t,e){return typeof e=="function"?e(t):e}function ze(t,e){let n=e==="dark",s={bg:n?"#1f2937":"#ffffff",bgSecondary:n?"#374151":"#f3f4f6",text:n?"#f9fafb":"#111827",textSecondary:n?"#9ca3af":"#6b7280",border:n?"#4b5563":"#e5e7eb",messageBg:n?"#374151":"#f3f4f6"};return`
|
|
1
|
+
"use strict";var PocketPing=(()=>{var Q=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var lt=(t,e)=>{for(var n in e)Q(t,n,{get:e[n],enumerable:!0})},ct=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of rt(e))!at.call(t,i)&&i!==n&&Q(t,i,{get:()=>e[i],enumerable:!(s=ot(e,i))||s.enumerable});return t};var pt=t=>ct(Q({},"__esModule",{value:!0}),t);var Mt={};lt(Mt,{close:()=>Je,default:()=>Tt,destroy:()=>Be,getIdentity:()=>st,getTrackedElements:()=>Ke,identify:()=>tt,init:()=>_e,offEvent:()=>et,on:()=>it,onEvent:()=>Qe,open:()=>qe,reset:()=>nt,sendMessage:()=>Ge,setupTrackedElements:()=>Ze,toggle:()=>Xe,trigger:()=>Ye});var X,h,ve,dt,L,ge,ye,be,xe,se,ee,te,ut,U={},ke=[],_t=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,G=Array.isArray;function O(t,e){for(var n in e)t[n]=e[n];return t}function ie(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function oe(t,e,n){var s,i,o,l={};for(o in e)o=="key"?s=e[o]:o=="ref"?i=e[o]:l[o]=e[o];if(arguments.length>2&&(l.children=arguments.length>3?X.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)l[o]===void 0&&(l[o]=t.defaultProps[o]);return B(t,l,s,i,null)}function B(t,e,n,s,i){var o={type:t,props:e,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++ve,__i:-1,__u:0};return i==null&&h.vnode!=null&&h.vnode(o),o}function C(t){return t.children}function q(t,e){this.props=t,this.context=e}function V(t,e){if(e==null)return t.__?V(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"?V(t):null}function we(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 we(t)}}function he(t){(!t.__d&&(t.__d=!0)&&L.push(t)&&!J.__r++||ge!=h.debounceRendering)&&((ge=h.debounceRendering)||ye)(J)}function J(){for(var t,e,n,s,i,o,l,c=1;L.length;)L.length>c&&L.sort(be),t=L.shift(),c=L.length,t.__d&&(n=void 0,s=void 0,i=(s=(e=t).__v).__e,o=[],l=[],e.__P&&((n=O({},s)).__v=s.__v+1,h.vnode&&h.vnode(n),re(e.__P,n,s,e.__n,e.__P.namespaceURI,32&s.__u?[i]:null,o,i??V(s),!!(32&s.__u),l),n.__v=s.__v,n.__.__k[n.__i]=n,Se(o,n,l),s.__e=s.__=null,n.__e!=i&&we(n)));J.__r=0}function Pe(t,e,n,s,i,o,l,c,p,a,_){var r,d,g,x,P,y,b,m=s&&s.__k||ke,T=e.length;for(p=gt(n,e,m,p,T),r=0;r<T;r++)(g=n.__k[r])!=null&&(d=g.__i==-1?U:m[g.__i]||U,g.__i=r,y=re(t,g,d,i,o,l,c,p,a,_),x=g.__e,g.ref&&d.ref!=g.ref&&(d.ref&&ae(d.ref,null,g),_.push(g.ref,g.__c||x,g)),P==null&&x!=null&&(P=x),(b=!!(4&g.__u))||d.__k===g.__k?p=Ee(g,p,t,b):typeof g.type=="function"&&y!==void 0?p=y:x&&(p=x.nextSibling),g.__u&=-7);return n.__e=P,p}function gt(t,e,n,s,i){var o,l,c,p,a,_=n.length,r=_,d=0;for(t.__k=new Array(i),o=0;o<i;o++)(l=e[o])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=t.__k[o]=B(null,l,null,null,null):G(l)?l=t.__k[o]=B(C,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=t.__k[o]=B(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):t.__k[o]=l,p=o+d,l.__=t,l.__b=t.__b+1,c=null,(a=l.__i=ht(l,n,p,r))!=-1&&(r--,(c=n[a])&&(c.__u|=2)),c==null||c.__v==null?(a==-1&&(i>_?d--:i<_&&d++),typeof l.type!="function"&&(l.__u|=4)):a!=p&&(a==p-1?d--:a==p+1?d++:(a>p?d--:d++,l.__u|=4))):t.__k[o]=null;if(r)for(o=0;o<_;o++)(c=n[o])!=null&&(2&c.__u)==0&&(c.__e==s&&(s=V(c)),Ce(c,c));return s}function Ee(t,e,n,s){var i,o;if(typeof t.type=="function"){for(i=t.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=t,e=Ee(i[o],e,n,s));return e}t.__e!=e&&(s&&(e&&t.type&&!e.parentNode&&(e=V(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ht(t,e,n,s){var i,o,l,c=t.key,p=t.type,a=e[n],_=a!=null&&(2&a.__u)==0;if(a===null&&c==null||_&&c==a.key&&p==a.type)return n;if(s>(_?1:0)){for(i=n-1,o=n+1;i>=0||o<e.length;)if((a=e[l=i>=0?i--:o++])!=null&&(2&a.__u)==0&&c==a.key&&p==a.type)return l}return-1}function fe(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||_t.test(e)?n:n+"px"}function j(t,e,n,s,i){var o,l;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof s=="string"&&(t.style.cssText=s=""),s)for(e in s)n&&e in n||fe(t.style,e,"");if(n)for(e in n)s&&n[e]==s[e]||fe(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(xe,"$1")),l=e.toLowerCase(),e=l in t||e=="onFocusOut"||e=="onFocusIn"?l.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?s?n.u=s.u:(n.u=se,t.addEventListener(e,o?te:ee,o)):t.removeEventListener(e,o?te:ee,o);else{if(i=="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 me(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=se++;else if(e.t<n.u)return;return n(h.event?h.event(e):e)}}}function re(t,e,n,s,i,o,l,c,p,a){var _,r,d,g,x,P,y,b,m,T,M,H,R,v,E,I,F,S=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(p=!!(32&n.__u),o=[c=e.__e=n.__e]),(_=h.__b)&&_(e);e:if(typeof S=="function")try{if(b=e.props,m="prototype"in S&&S.prototype.render,T=(_=S.contextType)&&s[_.__c],M=_?T?T.props.value:_.__:s,n.__c?y=(r=e.__c=n.__c).__=r.__E:(m?e.__c=r=new S(b,M):(e.__c=r=new q(b,M),r.constructor=S,r.render=mt),T&&T.sub(r),r.state||(r.state={}),r.__n=s,d=r.__d=!0,r.__h=[],r._sb=[]),m&&r.__s==null&&(r.__s=r.state),m&&S.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=O({},r.__s)),O(r.__s,S.getDerivedStateFromProps(b,r.__s))),g=r.props,x=r.state,r.__v=e,d)m&&S.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),m&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(m&&S.getDerivedStateFromProps==null&&b!==g&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(b,M),e.__v==n.__v||!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(b,r.__s,M)===!1){for(e.__v!=n.__v&&(r.props=b,r.state=r.__s,r.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function($){$&&($.__=e)}),H=0;H<r._sb.length;H++)r.__h.push(r._sb[H]);r._sb=[],r.__h.length&&l.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(b,r.__s,M),m&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(g,x,P)})}if(r.context=M,r.props=b,r.__P=t,r.__e=!1,R=h.__r,v=0,m){for(r.state=r.__s,r.__d=!1,R&&R(e),_=r.render(r.props,r.state,r.context),E=0;E<r._sb.length;E++)r.__h.push(r._sb[E]);r._sb=[]}else do r.__d=!1,R&&R(e),_=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++v<25);r.state=r.__s,r.getChildContext!=null&&(s=O(O({},s),r.getChildContext())),m&&!d&&r.getSnapshotBeforeUpdate!=null&&(P=r.getSnapshotBeforeUpdate(g,x)),I=_,_!=null&&_.type===C&&_.key==null&&(I=Ie(_.props.children)),c=Pe(t,G(I)?I:[I],e,n,s,i,o,l,c,p,a),r.base=e.__e,e.__u&=-161,r.__h.length&&l.push(r),y&&(r.__E=r.__=null)}catch($){if(e.__v=null,p||o!=null)if($.then){for(e.__u|=p?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,e.__e=c}else{for(F=o.length;F--;)ie(o[F]);ne(e)}else e.__e=n.__e,e.__k=n.__k,$.then||ne(e);h.__e($,e,n)}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):c=e.__e=ft(n.__e,e,n,s,i,o,l,p,a);return(_=h.diffed)&&_(e),128&e.__u?void 0:c}function ne(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(ne)}function Se(t,e,n){for(var s=0;s<n.length;s++)ae(n[s],n[++s],n[++s]);h.__c&&h.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){h.__e(o,i.__v)}})}function Ie(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:G(t)?t.map(Ie):O({},t)}function ft(t,e,n,s,i,o,l,c,p){var a,_,r,d,g,x,P,y=n.props||U,b=e.props,m=e.type;if(m=="svg"?i="http://www.w3.org/2000/svg":m=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(a=0;a<o.length;a++)if((g=o[a])&&"setAttribute"in g==!!m&&(m?g.localName==m:g.nodeType==3)){t=g,o[a]=null;break}}if(t==null){if(m==null)return document.createTextNode(b);t=document.createElementNS(i,m,b.is&&b),c&&(h.__m&&h.__m(e,o),c=!1),o=null}if(m==null)y===b||c&&t.data==b||(t.data=b);else{if(o=o&&X.call(t.childNodes),!c&&o!=null)for(y={},a=0;a<t.attributes.length;a++)y[(g=t.attributes[a]).name]=g.value;for(a in y)if(g=y[a],a!="children"){if(a=="dangerouslySetInnerHTML")r=g;else if(!(a in b)){if(a=="value"&&"defaultValue"in b||a=="checked"&&"defaultChecked"in b)continue;j(t,a,null,g,i)}}for(a in b)g=b[a],a=="children"?d=g:a=="dangerouslySetInnerHTML"?_=g:a=="value"?x=g:a=="checked"?P=g:c&&typeof g!="function"||y[a]===g||j(t,a,g,y[a],i);if(_)c||r&&(_.__html==r.__html||_.__html==t.innerHTML)||(t.innerHTML=_.__html),e.__k=[];else if(r&&(t.innerHTML=""),Pe(e.type=="template"?t.content:t,G(d)?d:[d],e,n,s,m=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,l,o?o[0]:n.__k&&V(n,0),c,p),o!=null)for(a=o.length;a--;)ie(o[a]);c||(a="value",m=="progress"&&x==null?t.removeAttribute("value"):x!=null&&(x!==t[a]||m=="progress"&&!x||m=="option"&&x!=y[a])&&j(t,a,x,y[a],i),a="checked",P!=null&&P!=t[a]&&j(t,a,P,y[a],i))}return t}function ae(t,e,n){try{if(typeof t=="function"){var s=typeof t.__u=="function";s&&t.__u(),s&&e==null||(t.__u=t(e))}else t.current=e}catch(i){h.__e(i,n)}}function Ce(t,e,n){var s,i;if(h.unmount&&h.unmount(t),(s=t.ref)&&(s.current&&s.current!=t.__e||ae(s,null,e)),(s=t.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(o){h.__e(o,e)}s.base=s.__P=null}if(s=t.__k)for(i=0;i<s.length;i++)s[i]&&Ce(s[i],e,n||typeof t.type!="function");n||ie(t.__e),t.__c=t.__=t.__e=void 0}function mt(t,e,n){return this.constructor(t,n)}function le(t,e,n){var s,i,o,l;e==document&&(e=document.documentElement),h.__&&h.__(t,e),i=(s=typeof n=="function")?null:n&&n.__k||e.__k,o=[],l=[],re(e,t=(!s&&n||e).__k=oe(C,null,[t]),i||U,U,e.namespaceURI,!s&&n?[n]:i?null:e.firstChild?X.call(e.childNodes):null,o,!s&&n?n:i?i.__e:e.firstChild,s,l),Se(o,t,l)}X=ke.slice,h={__e:function(t,e,n,s){for(var i,o,l;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),l=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,s||{}),l=i.__d),l)return i.__E=i}catch(c){t=c}throw t}},ve=0,dt=function(t){return t!=null&&t.constructor===void 0},q.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=O({},this.state),typeof t=="function"&&(t=t(O({},n),this.props)),t&&O(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),he(this))},q.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),he(this))},q.prototype.render=C,L=[],ye=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,be=function(t,e){return t.__v.__b-e.__v.__b},J.__r=0,xe=/(PointerCapture)$|Capture$/i,se=0,ee=me(!1),te=me(!0),ut=0;var D,k,ce,Te,z=0,We=[],w=h,Me=w.__b,$e=w.__r,Oe=w.diffed,Ae=w.__c,He=w.unmount,Re=w.__;function de(t,e){w.__h&&w.__h(k,t,z||e),z=0;var n=k.__H||(k.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function W(t){return z=1,vt(Ue,t)}function vt(t,e,n){var s=de(D++,2);if(s.t=t,!s.__c&&(s.__=[n?n(e):Ue(void 0,e),function(c){var p=s.__N?s.__N[0]:s.__[0],a=s.t(p,c);p!==a&&(s.__N=[a,s.__[1]],s.__c.setState({}))}],s.__c=k,!k.__f)){var i=function(c,p,a){if(!s.__c.__H)return!0;var _=s.__c.__H.__.filter(function(d){return!!d.__c});if(_.every(function(d){return!d.__N}))return!o||o.call(this,c,p,a);var r=s.__c.props!==c;return _.forEach(function(d){if(d.__N){var g=d.__[0];d.__=d.__N,d.__N=void 0,g!==d.__[0]&&(r=!0)}}),o&&o.call(this,c,p,a)||r};k.__f=!0;var o=k.shouldComponentUpdate,l=k.componentWillUpdate;k.componentWillUpdate=function(c,p,a){if(this.__e){var _=o;o=void 0,i(c,p,a),o=_}l&&l.call(this,c,p,a)},k.shouldComponentUpdate=i}return s.__N||s.__}function N(t,e){var n=de(D++,3);!w.__s&&Fe(n.__H,e)&&(n.__=t,n.u=e,k.__H.__h.push(n))}function ue(t){return z=5,Ne(function(){return{current:t}},[])}function Ne(t,e){var n=de(D++,7);return Fe(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function Ve(t,e){return z=8,Ne(function(){return t},e)}function yt(){for(var t;t=We.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Y),t.__H.__h.forEach(pe),t.__H.__h=[]}catch(e){t.__H.__h=[],w.__e(e,t.__v)}}w.__b=function(t){k=null,Me&&Me(t)},w.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Re&&Re(t,e)},w.__r=function(t){$e&&$e(t),D=0;var e=(k=t.__c).__H;e&&(ce===k?(e.__h=[],k.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(Y),e.__h.forEach(pe),e.__h=[],D=0)),ce=k},w.diffed=function(t){Oe&&Oe(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(We.push(e)!==1&&Te===w.requestAnimationFrame||((Te=w.requestAnimationFrame)||bt)(yt)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ce=k=null},w.__c=function(t,e){e.some(function(n){try{n.__h.forEach(Y),n.__h=n.__h.filter(function(s){return!s.__||pe(s)})}catch(s){e.some(function(i){i.__h&&(i.__h=[])}),e=[],w.__e(s,n.__v)}}),Ae&&Ae(t,e)},w.unmount=function(t){He&&He(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(s){try{Y(s)}catch(i){e=i}}),n.__H=void 0,e&&w.__e(e,n.__v))};var Le=typeof requestAnimationFrame=="function";function bt(t){var e,n=function(){clearTimeout(s),Le&&cancelAnimationFrame(e),setTimeout(t)},s=setTimeout(n,35);Le&&(e=requestAnimationFrame(n))}function Y(t){var e=k,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),k=e}function pe(t){var e=k;t.__c=t.__(),k=e}function Fe(t,e){return!t||t.length!==e.length||e.some(function(n,s){return n!==t[s]})}function Ue(t,e){return typeof e=="function"?e(t):e}function De(t,e){let n=e==="dark",s={bg:n?"#1f2937":"#ffffff",bgSecondary:n?"#374151":"#f3f4f6",text:n?"#f9fafb":"#111827",textSecondary:n?"#9ca3af":"#6b7280",border:n?"#4b5563":"#e5e7eb",messageBg:n?"#374151":"#f3f4f6"};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;
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
width: 380px;
|
|
60
60
|
height: 520px;
|
|
61
61
|
max-height: calc(100vh - 100px);
|
|
62
|
+
max-height: calc(100dvh - 100px);
|
|
62
63
|
background: ${s.bg};
|
|
63
64
|
border-radius: 16px;
|
|
64
65
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
|
|
@@ -81,7 +82,9 @@
|
|
|
81
82
|
@media (max-width: 480px) {
|
|
82
83
|
.pp-window {
|
|
83
84
|
width: calc(100vw - 20px);
|
|
84
|
-
height:
|
|
85
|
+
height: auto;
|
|
86
|
+
max-height: calc(100vh - 100px);
|
|
87
|
+
max-height: calc(100dvh - 100px);
|
|
85
88
|
bottom: 80px;
|
|
86
89
|
right: 10px;
|
|
87
90
|
left: 10px;
|
|
@@ -326,7 +329,7 @@
|
|
|
326
329
|
.pp-footer a:hover {
|
|
327
330
|
text-decoration: underline;
|
|
328
331
|
}
|
|
329
|
-
`}var kt=0;function u(t,e,n,s,o,i){e||(e={});var c,l,p=e;if("ref"in p)for(l in p={},e)l=="ref"?c=e[l]:p[l]=e[l];var a={type:t,props:p,key:n,ref:c,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--kt,__i:-1,__u:0,__source:o,__self:i};if(typeof t=="function"&&(c=t.defaultProps))for(l in c)p[l]===void 0&&(p[l]=c[l]);return f.vnode&&f.vnode(a),a}function je({client:t,config:e}){let[n,s]=W(!1),[o,i]=W([]),[c,l]=W(""),[p,a]=W(!1),[_,r]=W(!1),[d,g]=W(!1),k=ue(null),E=ue(null);N(()=>{let v=t.on("openChange",s),S=t.on("message",()=>{i([...t.getMessages()])}),I=t.on("typing",$=>{a($.isTyping)}),U=t.on("presence",$=>{r($.online)}),P=t.on("connect",()=>{g(!0),i(t.getMessages()),r(t.getSession()?.operatorOnline??!1)});return t.isConnected()&&(g(!0),i(t.getMessages()),r(t.getSession()?.operatorOnline??!1)),()=>{v(),S(),I(),U(),P()}},[t]),N(()=>{k.current?.scrollIntoView({behavior:"smooth"})},[o]),N(()=>{n&&E.current?.focus()},[n]);let y=Ve(()=>{if(!n||!d)return;let v=o.filter(S=>S.sender!=="visitor"&&S.status!=="read");if(v.length>0){let S=v.map(I=>I.id);t.sendReadStatus(S,"read")}},[n,d,o,t]);if(N(()=>{if(!n||!d)return;let v=setTimeout(()=>{y()},1e3);return()=>clearTimeout(v)},[n,d,o,y]),N(()=>{let v=()=>{document.visibilityState==="visible"&&n&&y()};return document.addEventListener("visibilitychange",v),()=>document.removeEventListener("visibilitychange",v)},[n,y]),N(()=>{let v=t.on("read",()=>{i([...t.getMessages()])});return()=>v()},[t]),!xt(e))return null;let m=async v=>{if(v.preventDefault(),!c.trim())return;let S=c;l("");try{await t.sendMessage(S)}catch(I){console.error("[PocketPing] Failed to send message:",I)}},T=v=>{let S=v.target;l(S.value),t.sendTyping(!0)},M=e.position??"bottom-right",H=wt(e.theme??"auto"),R=e.primaryColor??"#6366f1";return u(C,{children:[u("style",{children:ze(R,H)}),u("button",{class:`pp-toggle pp-${M}`,onClick:()=>t.toggleOpen(),"aria-label":n?"Close chat":"Open chat",children:[n?u(Fe,{}):u(St,{}),!n&&_&&u("span",{class:"pp-online-dot"})]}),n&&u("div",{class:`pp-window pp-${M} pp-theme-${H}`,children:[u("div",{class:"pp-header",children:[u("div",{class:"pp-header-info",children:[e.operatorAvatar&&u("img",{src:e.operatorAvatar,alt:"",class:"pp-avatar"}),u("div",{children:[u("div",{class:"pp-header-title",children:e.operatorName??"Support"}),u("div",{class:"pp-header-status",children:_?u(C,{children:[u("span",{class:"pp-status-dot pp-online"})," Online"]}):u(C,{children:[u("span",{class:"pp-status-dot"})," Away"]})})]})]}),u("button",{class:"pp-close-btn",onClick:()=>t.setOpen(!1),"aria-label":"Close chat",children:u(Fe,{})})]}),u("div",{class:"pp-messages",children:[e.welcomeMessage&&o.length===0&&u("div",{class:"pp-welcome",children:e.welcomeMessage}),o.map(v=>u("div",{class:`pp-message pp-message-${v.sender}`,children:[u("div",{class:"pp-message-content",children:v.content}),u("div",{class:"pp-message-time",children:[Et(v.timestamp),v.sender==="ai"&&u("span",{class:"pp-ai-badge",children:"AI"}),v.sender==="visitor"&&u("span",{class:`pp-status pp-status-${v.status??"sent"}`,children:u(It,{status:v.status})})]})]},v.id)),p&&u("div",{class:"pp-message pp-message-operator pp-typing",children:[u("span",{}),u("span",{}),u("span",{})]}),u("div",{ref:k})]}),u("form",{class:"pp-input-form",onSubmit:m,children:[u("input",{ref:E,type:"text",class:"pp-input",placeholder:e.placeholder??"Type a message...",value:c,onInput:T,disabled:!d}),u("button",{type:"submit",class:"pp-send-btn",disabled:!c.trim()||!d,"aria-label":"Send message",children:u(Pt,{})})]}),u("div",{class:"pp-footer",children:["Powered by ",u("a",{href:"https://pocketping.io",target:"_blank",rel:"noopener",children:"PocketPing"})]})]})]})}function xt(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 wt(t){return t==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t}function Et(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function St(){return u("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:u("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 Fe(){return u("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[u("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Pt(){return u("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[u("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),u("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function It({status:t}){return!t||t==="sending"||t==="sent"?u("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check",children:u("polyline",{points:"3 8 7 12 13 4"})}):t==="delivered"?u("svg",{viewBox:"0 0 20 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check-double",children:[u("polyline",{points:"1 8 5 12 11 4"}),u("polyline",{points:"7 8 11 12 17 4"})]}):t==="read"?u("svg",{viewBox:"0 0 20 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check-double pp-check-read",children:[u("polyline",{points:"1 8 5 12 11 4"}),u("polyline",{points:"7 8 11 12 17 4"})]}):null}var Z="0.3.4";var K=class{constructor(e){this.session=null;this.ws=null;this.isOpen=!1;this.listeners=new Map;this.customEventHandlers=new Map;this.reconnectAttempts=0;this.maxReconnectAttempts=5;this.reconnectTimeout=null;this.trackedElementCleanups=[];this.currentTrackedElements=[];this.inspectorMode=!1;this.inspectorCleanup=null;this.config=e}async connect(){let e=this.getOrCreateVisitorId(),n=this.getStoredSessionId(),s=this.getStoredIdentity(),i=new URLSearchParams(window.location.search).get("pp_inspector"),c=await this.fetch("/connect",{method:"POST",body:JSON.stringify({visitorId:e,sessionId:n,inspectorToken:i||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:s||void 0})});return this.session={sessionId:c.sessionId,visitorId:c.visitorId,operatorOnline:c.operatorOnline??!1,messages:c.messages??[],identity:c.identity||s||void 0},this.storeSessionId(c.sessionId),this.connectWebSocket(),c.inspectorMode?this.enableInspectorMode():c.trackedElements?.length&&this.setupTrackedElements(c.trackedElements),this.emit("connect",this.session),this.config.onConnect?.(c.sessionId),this.session}disconnect(){this.ws?.close(),this.ws=null,this.session=null,this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.cleanupTrackedElements(),this.disableInspectorMode()}async sendMessage(e){if(!this.session)throw new Error("Not connected");let n=`temp-${this.generateId()}`,s={id:n,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:new Date().toISOString(),status:"sending"};this.session.messages.push(s),this.emit("message",s);try{let o=await this.fetch("/message",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,content:e,sender:"visitor"})}),i=this.session.messages.findIndex(l=>l.id===n);i>=0&&(this.session.messages[i].id=o.messageId,this.session.messages[i].timestamp=o.timestamp,this.session.messages[i].status="sent",this.emit("message",this.session.messages[i]));let c=this.session.messages[i]||{id:o.messageId,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:o.timestamp,status:"sent"};return this.config.onMessage?.(c),c}catch(o){let i=this.session.messages.findIndex(c=>c.id===n);throw i>=0&&(this.session.messages.splice(i,1),this.emit("message",s)),o}}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 s of this.session.messages)e.includes(s.id)&&(s.status=n,n==="delivered"?s.deliveredAt=new Date().toISOString():n==="read"&&(s.readAt=new Date().toISOString()));this.emit("readStatusSent",{messageIds:e,status:n})}catch(s){console.error("[PocketPing] Failed to send read status:",s)}}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 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}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(s=>s(n))}trigger(e,n,s){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),s?.widgetMessage&&(this.setOpen(!0),this.emit("triggerMessage",{message:s.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(s=>s(e.data,e)),this.emit("event",e),this.emit(`event:${e.name}`,e)}setupTrackedElements(e){this.cleanupTrackedElements(),this.currentTrackedElements=e;for(let n of e){let s=n.event||"click",o=c=>{let l={...n.data,selector:n.selector,elementText:c.target?.textContent?.trim().slice(0,100),url:window.location.href};this.trigger(n.name,l,{widgetMessage:n.widgetMessage})},i=c=>{c.target?.closest(n.selector)&&o(c)};document.addEventListener(s,i,!0),this.trackedElementCleanups.push(()=>{document.removeEventListener(s,i,!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=`
|
|
332
|
+
`}var xt=0;function u(t,e,n,s,i,o){e||(e={});var l,c,p=e;if("ref"in p)for(c in p={},e)c=="ref"?l=e[c]:p[c]=e[c];var a={type:t,props:p,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--xt,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(l=t.defaultProps))for(c in l)p[c]===void 0&&(p[c]=l[c]);return h.vnode&&h.vnode(a),a}function je({client:t,config:e}){let[n,s]=W(!1),[i,o]=W([]),[l,c]=W(""),[p,a]=W(!1),[_,r]=W(!1),[d,g]=W(!1),x=ue(null),P=ue(null);N(()=>{let v=t.on("openChange",s),E=t.on("message",()=>{o([...t.getMessages()])}),I=t.on("typing",$=>{a($.isTyping)}),F=t.on("presence",$=>{r($.online)}),S=t.on("connect",()=>{g(!0),o(t.getMessages()),r(t.getSession()?.operatorOnline??!1)});return t.isConnected()&&(g(!0),o(t.getMessages()),r(t.getSession()?.operatorOnline??!1)),()=>{v(),E(),I(),F(),S()}},[t]),N(()=>{x.current?.scrollIntoView({behavior:"smooth"})},[i]),N(()=>{n&&P.current?.focus()},[n]);let y=Ve(()=>{if(!n||!d)return;let v=i.filter(E=>E.sender!=="visitor"&&E.status!=="read");if(v.length>0){let E=v.map(I=>I.id);t.sendReadStatus(E,"read")}},[n,d,i,t]);if(N(()=>{if(!n||!d)return;let v=setTimeout(()=>{y()},1e3);return()=>clearTimeout(v)},[n,d,i,y]),N(()=>{let v=()=>{document.visibilityState==="visible"&&n&&y()};return document.addEventListener("visibilitychange",v),()=>document.removeEventListener("visibilitychange",v)},[n,y]),N(()=>{let v=t.on("read",()=>{o([...t.getMessages()])});return()=>v()},[t]),!kt(e))return null;let m=async v=>{if(v.preventDefault(),!l.trim())return;let E=l;c("");try{await t.sendMessage(E)}catch(I){console.error("[PocketPing] Failed to send message:",I)}},T=v=>{let E=v.target;c(E.value),t.sendTyping(!0)},M=e.position??"bottom-right",H=wt(e.theme??"auto"),R=e.primaryColor??"#6366f1";return u(C,{children:[u("style",{children:De(R,H)}),u("button",{class:`pp-toggle pp-${M}`,onClick:()=>t.toggleOpen(),"aria-label":n?"Close chat":"Open chat",children:[n?u(ze,{}):u(Et,{}),!n&&_&&u("span",{class:"pp-online-dot"})]}),n&&u("div",{class:`pp-window pp-${M} pp-theme-${H}`,children:[u("div",{class:"pp-header",children:[u("div",{class:"pp-header-info",children:[e.operatorAvatar&&u("img",{src:e.operatorAvatar,alt:"",class:"pp-avatar"}),u("div",{children:[u("div",{class:"pp-header-title",children:e.operatorName??"Support"}),u("div",{class:"pp-header-status",children:_?u(C,{children:[u("span",{class:"pp-status-dot pp-online"})," Online"]}):u(C,{children:[u("span",{class:"pp-status-dot"})," Away"]})})]})]}),u("button",{class:"pp-close-btn",onClick:()=>t.setOpen(!1),"aria-label":"Close chat",children:u(ze,{})})]}),u("div",{class:"pp-messages",children:[e.welcomeMessage&&i.length===0&&u("div",{class:"pp-welcome",children:e.welcomeMessage}),i.map(v=>u("div",{class:`pp-message pp-message-${v.sender}`,children:[u("div",{class:"pp-message-content",children:v.content}),u("div",{class:"pp-message-time",children:[Pt(v.timestamp),v.sender==="ai"&&u("span",{class:"pp-ai-badge",children:"AI"}),v.sender==="visitor"&&u("span",{class:`pp-status pp-status-${v.status??"sent"}`,children:u(It,{status:v.status})})]})]},v.id)),p&&u("div",{class:"pp-message pp-message-operator pp-typing",children:[u("span",{}),u("span",{}),u("span",{})]}),u("div",{ref:x})]}),u("form",{class:"pp-input-form",onSubmit:m,children:[u("input",{ref:P,type:"text",class:"pp-input",placeholder:e.placeholder??"Type a message...",value:l,onInput:T,disabled:!d}),u("button",{type:"submit",class:"pp-send-btn",disabled:!l.trim()||!d,"aria-label":"Send message",children:u(St,{})})]}),u("div",{class:"pp-footer",children:["Powered by ",u("a",{href:"https://pocketping.io",target:"_blank",rel:"noopener",children:"PocketPing"})]})]})]})}function kt(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 wt(t){return t==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t}function Pt(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Et(){return u("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:u("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 ze(){return u("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[u("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function St(){return u("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:[u("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),u("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function It({status:t}){return!t||t==="sending"||t==="sent"?u("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check",children:u("polyline",{points:"3 8 7 12 13 4"})}):t==="delivered"?u("svg",{viewBox:"0 0 20 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check-double",children:[u("polyline",{points:"1 8 5 12 11 4"}),u("polyline",{points:"7 8 11 12 17 4"})]}):t==="read"?u("svg",{viewBox:"0 0 20 16",fill:"none",stroke:"currentColor","stroke-width":"2",class:"pp-check-double pp-check-read",children:[u("polyline",{points:"1 8 5 12 11 4"}),u("polyline",{points:"7 8 11 12 17 4"})]}):null}var Z="0.3.6";var K=class{constructor(e){this.session=null;this.ws=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.trackedElementCleanups=[];this.currentTrackedElements=[];this.inspectorMode=!1;this.inspectorCleanup=null;this.config=e}async connect(){let e=this.getOrCreateVisitorId(),n=this.getStoredSessionId(),s=this.getStoredIdentity(),o=new URLSearchParams(window.location.search).get("pp_inspector"),l=await this.fetch("/connect",{method:"POST",body:JSON.stringify({visitorId:e,sessionId:n,inspectorToken:o||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:s||void 0})});return this.session={sessionId:l.sessionId,visitorId:l.visitorId,operatorOnline:l.operatorOnline??!1,messages:l.messages??[],identity:l.identity||s||void 0},this.storeSessionId(l.sessionId),this.connectWebSocket(),l.inspectorMode?this.enableInspectorMode():l.trackedElements?.length&&this.setupTrackedElements(l.trackedElements),this.emit("connect",this.session),this.config.onConnect?.(l.sessionId),this.session}disconnect(){this.ws?.close(),this.ws=null,this.session=null,this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.stopPolling(),this.cleanupTrackedElements(),this.disableInspectorMode()}async sendMessage(e){if(!this.session)throw new Error("Not connected");let n=`temp-${this.generateId()}`,s={id:n,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:new Date().toISOString(),status:"sending"};this.session.messages.push(s),this.emit("message",s);try{let i=await this.fetch("/message",{method:"POST",body:JSON.stringify({sessionId:this.session.sessionId,content:e,sender:"visitor"})}),o=this.session.messages.findIndex(c=>c.id===n);o>=0&&(this.session.messages[o].id=i.messageId,this.session.messages[o].timestamp=i.timestamp,this.session.messages[o].status="sent",this.emit("message",this.session.messages[o]));let l=this.session.messages[o]||{id:i.messageId,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:i.timestamp,status:"sent"};return this.config.onMessage?.(l),l}catch(i){let o=this.session.messages.findIndex(l=>l.id===n);throw o>=0&&(this.session.messages.splice(o,1),this.emit("message",s)),i}}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 s of this.session.messages)e.includes(s.id)&&(s.status=n,n==="delivered"?s.deliveredAt=new Date().toISOString():n==="read"&&(s.readAt=new Date().toISOString()));this.emit("readStatusSent",{messageIds:e,status:n})}catch(s){console.error("[PocketPing] Failed to send read status:",s)}}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 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}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(s=>s(n))}trigger(e,n,s){if(!this.ws||this.ws.readyState!==WebSocket.OPEN){console.warn("[PocketPing] Cannot trigger event: WebSocket not connected");return}let i={name:e,data:n,timestamp:new Date().toISOString()};this.ws.send(JSON.stringify({type:"event",data:i})),this.emit(`event:${e}`,i),s?.widgetMessage&&(this.setOpen(!0),this.emit("triggerMessage",{message:s.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(s=>s(e.data,e)),this.emit("event",e),this.emit(`event:${e.name}`,e)}setupTrackedElements(e){this.cleanupTrackedElements(),this.currentTrackedElements=e;for(let n of e){let s=n.event||"click",i=l=>{let c={...n.data,selector:n.selector,elementText:l.target?.textContent?.trim().slice(0,100),url:window.location.href};this.trigger(n.name,c,{widgetMessage:n.widgetMessage})},o=l=>{l.target?.closest(n.selector)&&i(l)};document.addEventListener(s,o,!0),this.trackedElementCleanups.push(()=>{document.removeEventListener(s,o,!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=`
|
|
330
333
|
<style>
|
|
331
334
|
#pp-inspector-overlay {
|
|
332
335
|
position: fixed;
|
|
@@ -409,9 +412,9 @@
|
|
|
409
412
|
<button id="pp-inspector-exit">Exit</button>
|
|
410
413
|
</div>
|
|
411
414
|
<div id="pp-inspector-tooltip"></div>
|
|
412
|
-
`,document.body.appendChild(e);let n=document.getElementById("pp-inspector-tooltip"),s=null,
|
|
415
|
+
`,document.body.appendChild(e);let n=document.getElementById("pp-inspector-tooltip"),s=null,i=p=>{if(p.id&&!p.id.startsWith("pp-"))return`#${CSS.escape(p.id)}`;let a=Array.from(p.classList).filter(d=>!d.startsWith("pp-"));if(a.length>0){let d="."+a.map(g=>CSS.escape(g)).join(".");if(document.querySelectorAll(d).length===1)return d}for(let d of Array.from(p.attributes))if(d.name.startsWith("data-")&&d.value){let g=`[${d.name}="${CSS.escape(d.value)}"]`;if(document.querySelectorAll(g).length===1)return g}let _=[],r=p;for(;r&&r!==document.body;){let d=r.tagName.toLowerCase();if(r.id&&!r.id.startsWith("pp-")){d=`#${CSS.escape(r.id)}`,_.unshift(d);break}let g=r.parentElement;if(g){let x=r.tagName,P=Array.from(g.children).filter(y=>y.tagName===x);if(P.length>1){let y=P.indexOf(r)+1;d+=`:nth-of-type(${y})`}}_.unshift(d),r=g}return _.join(" > ")},o=p=>{let a=p.target;if(a.closest("#pp-inspector-overlay")||a.closest("#pocketping-widget"))return;s&&s.classList.remove("pp-inspector-highlight"),a.classList.add("pp-inspector-highlight"),s=a;let _=i(a);n.textContent=_,n.style.display="block",n.style.left=`${p.clientX+15}px`,n.style.top=`${p.clientY+15}px`;let r=n.getBoundingClientRect();r.right>window.innerWidth&&(n.style.left=`${p.clientX-r.width-15}px`),r.bottom>window.innerHeight&&(n.style.top=`${p.clientY-r.height-15}px`)},l=p=>{let a=p.target;a.closest("#pp-inspector-overlay")||(a.classList.remove("pp-inspector-highlight"),n.style.display="none")},c=p=>{let a=p.target;if(a.id==="pp-inspector-exit"){this.disableInspectorMode();return}if(a.closest("#pp-inspector-overlay")||a.closest("#pocketping-widget"))return;p.preventDefault(),p.stopPropagation();let _=i(a);this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"inspector_select",data:{selector:_,tagName:a.tagName.toLowerCase(),text:a.textContent?.trim().slice(0,50)||"",url:window.location.href}})),this.emit("inspectorSelect",{selector:_,element:a}),a.classList.remove("pp-inspector-highlight"),a.classList.add("pp-inspector-highlight"),setTimeout(()=>{a.classList.remove("pp-inspector-highlight")},500);let r=document.getElementById("pp-inspector-banner");if(r){let d=r.innerHTML;r.innerHTML=`
|
|
413
416
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
414
417
|
<polyline points="20 6 9 17 4 12"/>
|
|
415
418
|
</svg>
|
|
416
419
|
<span>Selector captured: <code style="background:rgba(255,255,255,0.2);padding:2px 6px;border-radius:4px;font-family:monospace;">${_}</code></span>
|
|
417
|
-
`,setTimeout(()=>{r&&this.inspectorMode&&(r.innerHTML=d,document.getElementById("pp-inspector-exit")?.addEventListener("click",()=>{this.disableInspectorMode()}))},2e3)}console.info(`[PocketPing] \u{1F4CC} Selector captured: ${_}`)};document.addEventListener("mouseover",
|
|
420
|
+
`,setTimeout(()=>{r&&this.inspectorMode&&(r.innerHTML=d,document.getElementById("pp-inspector-exit")?.addEventListener("click",()=>{this.disableInspectorMode()}))},2e3)}console.info(`[PocketPing] \u{1F4CC} Selector captured: ${_}`)};document.addEventListener("mouseover",o,!0),document.addEventListener("mouseout",l,!0),document.addEventListener("click",c,!0),this.inspectorCleanup=()=>{document.removeEventListener("mouseover",o,!0),document.removeEventListener("mouseout",l,!0),document.removeEventListener("click",c,!0),e.remove(),s&&s.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}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.ws.onopen=()=>{this.reconnectAttempts=0,this.emit("wsConnected",null)},this.ws.onmessage=n=>{try{let s=JSON.parse(n.data);this.handleWebSocketEvent(s)}catch(s){console.error("[PocketPing] Failed to parse WS message:",s)}},this.ws.onclose=()=>{this.emit("wsDisconnected",null),this.scheduleReconnect()},this.ws.onerror=n=>{console.error("[PocketPing] WebSocket error:",n)}}catch{console.warn("[PocketPing] WebSocket unavailable, using polling"),this.startPolling()}}handleWebSocketEvent(e){switch(e.type){case"message":let n=e.data;if(this.session){let p=this.session.messages.findIndex(a=>a.id===n.id);if(p<0&&n.sender==="visitor"&&(p=this.session.messages.findIndex(a=>a.id.startsWith("temp-")&&a.content===n.content&&a.sender==="visitor"),p>=0&&(this.session.messages[p].id=n.id)),p<0&&n.sender!=="visitor"){let a=new Date(n.timestamp).getTime();p=this.session.messages.findIndex(_=>_.sender===n.sender&&_.content===n.content&&Math.abs(new Date(_.timestamp).getTime()-a)<2e3)}if(p>=0){let a=this.session.messages[p];n.status&&n.status!==a.status&&(a.status=n.status,n.deliveredAt&&(a.deliveredAt=n.deliveredAt),n.readAt&&(a.readAt=n.readAt),this.emit("read",{messageIds:[n.id],status:n.status}))}else this.session.messages.push(n),this.emit("message",n),this.config.onMessage?.(n)}n.sender!=="visitor"&&this.emit("typing",{isTyping:!1});break;case"typing":let s=e.data;s.sender!=="visitor"&&this.emit("typing",{isTyping:s.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 i=e.data;if(this.session)for(let p of this.session.messages)i.messageIds.includes(p.id)&&(p.status=i.status,i.deliveredAt&&(p.deliveredAt=i.deliveredAt),i.readAt&&(p.readAt=i.readAt));this.emit("read",i);break;case"event":let o=e.data;this.emitCustomEvent(o);break;case"version_warning":let l=e.data;this.handleVersionWarning(l);break;case"config_update":let c=e.data;c.trackedElements&&(this.setupTrackedElements(c.trackedElements),this.emit("configUpdate",c));break}}handleVersionWarning(e){let n="[PocketPing]",s=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}${s}`),console.error(`${n} Current: ${e.currentVersion}, Required: ${e.minVersion||"unknown"}`);break;case"warning":console.warn(`${n} \u26A0\uFE0F VERSION WARNING: ${e.message}${s}`),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, switching to polling"),this.startPolling();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.session.messages[this.session.messages.length-1]?.id,s=await this.fetchMessages(n);this.pollingFailures=0;for(let i of s)this.session.messages.find(o=>o.id===i.id)||(this.session.messages.push(i),this.emit("message",i),this.config.onMessage?.(i))}catch{if(this.pollingFailures++,(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(3e3*Math.pow(2,this.pollingFailures-1),3e4):3e3;this.pollingTimeout=setTimeout(e,n)}}};e()}stopPolling(){this.pollingTimeout&&(clearTimeout(this.pollingTimeout),this.pollingTimeout=null),this.pollingFailures=0}async fetch(e,n){let s=this.config.endpoint.replace(/\/$/,"")+e,i=await fetch(s,{...n,headers:{"Content-Type":"application/json","X-PocketPing-Version":Z,...n.headers}});if(this.checkVersionHeaders(i),!i.ok){let o=await i.text();throw new Error(`PocketPing API error: ${i.status} ${o}`)}return i.json()}checkVersionHeaders(e){let n=e.headers.get("X-PocketPing-Version-Status"),s=e.headers.get("X-PocketPing-Min-Version"),i=e.headers.get("X-PocketPing-Latest-Version"),o=e.headers.get("X-PocketPing-Version-Message");if(!n||n==="ok")return;let l="info",c=!0;n==="deprecated"?l="warning":n==="unsupported"?(l="error",c=!1):n==="outdated"&&(l="info");let p={severity:l,message:o||`Widget version ${Z} is ${n}`,currentVersion:Z,minVersion:s||void 0,latestVersion:i||void 0,canContinue:c,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 f=null,A=null,Ct="https://app.pocketping.io/api/widget";function _e(t){if(f)return console.warn("[PocketPing] Already initialized"),f;let e=t.endpoint;if(!e&&t.projectId&&(e=`${Ct}/${t.projectId}`),!e)throw new Error("[PocketPing] endpoint or projectId is required");let n={...t,endpoint:e};return f=new K(n),A=document.createElement("div"),A.id="pocketping-container",document.body.appendChild(A),le(oe(je,{client:f,config:t}),A),f.connect().catch(s=>{console.error("[PocketPing] Failed to connect:",s)}),f}function Be(){A&&(le(null,A),A.remove(),A=null),f&&(f.disconnect(),f=null)}function qe(){f?.setOpen(!0)}function Je(){f?.setOpen(!1)}function Xe(){f?.toggleOpen()}function Ge(t){if(!f)throw new Error("[PocketPing] Not initialized");return f.sendMessage(t)}function Ye(t,e,n){if(!f){console.warn("[PocketPing] Not initialized, cannot trigger event");return}f.trigger(t,e,n)}function Ze(t){if(!f){console.warn("[PocketPing] Not initialized, cannot setup tracked elements");return}f.setupTrackedElements(t)}function Ke(){return f?.getTrackedElements()||[]}function Qe(t,e){return f?f.onEvent(t,e):(console.warn("[PocketPing] Not initialized, cannot subscribe to event"),()=>{})}function et(t,e){f?.offEvent(t,e)}async function tt(t){if(!f)throw new Error("[PocketPing] Not initialized");return f.identify(t)}async function nt(t){if(!f){console.warn("[PocketPing] Not initialized");return}return f.reset(t)}function st(){return f?.getIdentity()||null}function it(t,e){return f?f.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)&&_e({projectId:e,endpoint:n,theme:t.dataset.theme||"auto",position:t.dataset.position||"bottom-right"})}}var Tt={init:_e,destroy:Be,open:qe,close:Je,toggle:Xe,sendMessage:Ge,trigger:Ye,onEvent:Qe,offEvent:et,on:it,identify:tt,reset:nt,getIdentity:st,setupTrackedElements:Ze,getTrackedElements:Ke};return pt(Mt);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pocketping/widget",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Embeddable chat widget for PocketPing",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -17,6 +17,15 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"clean": "rm -rf dist && find src -name '*.js' -o -name '*.js.map' -o -name '*.d.ts' -o -name '*.d.ts.map' | xargs rm -f 2>/dev/null || true",
|
|
22
|
+
"prebuild": "pnpm clean",
|
|
23
|
+
"build": "tsup",
|
|
24
|
+
"dev": "tsup --watch",
|
|
25
|
+
"dev:test": "pnpm build && npx serve . -p 3333 --cors",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest"
|
|
28
|
+
},
|
|
20
29
|
"dependencies": {
|
|
21
30
|
"preact": "^10.19.0"
|
|
22
31
|
},
|
|
@@ -43,13 +52,21 @@
|
|
|
43
52
|
"url": "https://github.com/Ruwad-io/pocketping.git",
|
|
44
53
|
"directory": "packages/widget"
|
|
45
54
|
},
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
"release": {
|
|
56
|
+
"extends": "semantic-release-monorepo",
|
|
57
|
+
"branches": [
|
|
58
|
+
"main"
|
|
59
|
+
],
|
|
60
|
+
"plugins": [
|
|
61
|
+
"@semantic-release/commit-analyzer",
|
|
62
|
+
"@semantic-release/release-notes-generator",
|
|
63
|
+
[
|
|
64
|
+
"@semantic-release/exec",
|
|
65
|
+
{
|
|
66
|
+
"prepareCmd": "npm pkg set version=${nextRelease.version}"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"@semantic-release/github"
|
|
70
|
+
]
|
|
54
71
|
}
|
|
55
|
-
}
|
|
72
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 PocketPing Contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|