@pocketping/widget 1.0.0 → 1.0.2

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 CHANGED
@@ -111,6 +111,31 @@ function styles(primaryColor, theme) {
111
111
  border: 2px solid white;
112
112
  }
113
113
 
114
+ .pp-unread-badge {
115
+ position: absolute;
116
+ top: -4px;
117
+ right: -4px;
118
+ min-width: 20px;
119
+ height: 20px;
120
+ padding: 0 6px;
121
+ background: #ef4444;
122
+ color: white;
123
+ border-radius: 10px;
124
+ border: 2px solid white;
125
+ font-size: 11px;
126
+ font-weight: 600;
127
+ display: flex;
128
+ align-items: center;
129
+ justify-content: center;
130
+ animation: pp-badge-pop 0.3s ease-out;
131
+ }
132
+
133
+ @keyframes pp-badge-pop {
134
+ 0% { transform: scale(0); }
135
+ 50% { transform: scale(1.2); }
136
+ 100% { transform: scale(1); }
137
+ }
138
+
114
139
  .pp-window {
115
140
  position: fixed;
116
141
  width: 380px;
@@ -391,13 +416,15 @@ function styles(primaryColor, theme) {
391
416
 
392
417
  // src/components/ChatWidget.tsx
393
418
  var import_jsx_runtime = require("preact/jsx-runtime");
394
- function ChatWidget({ client: client2, config }) {
419
+ function ChatWidget({ client: client2, config: initialConfig }) {
395
420
  const [isOpen, setIsOpen] = (0, import_hooks.useState)(false);
396
421
  const [messages, setMessages] = (0, import_hooks.useState)([]);
397
422
  const [inputValue, setInputValue] = (0, import_hooks.useState)("");
398
423
  const [isTyping, setIsTyping] = (0, import_hooks.useState)(false);
399
424
  const [operatorOnline, setOperatorOnline] = (0, import_hooks.useState)(false);
400
425
  const [isConnected, setIsConnected] = (0, import_hooks.useState)(false);
426
+ const [unreadCount, setUnreadCount] = (0, import_hooks.useState)(0);
427
+ const [config, setConfig] = (0, import_hooks.useState)(initialConfig);
401
428
  const messagesEndRef = (0, import_hooks.useRef)(null);
402
429
  const inputRef = (0, import_hooks.useRef)(null);
403
430
  (0, import_hooks.useEffect)(() => {
@@ -415,11 +442,16 @@ function ChatWidget({ client: client2, config }) {
415
442
  setIsConnected(true);
416
443
  setMessages(client2.getMessages());
417
444
  setOperatorOnline(client2.getSession()?.operatorOnline ?? false);
445
+ setConfig(client2.getConfig());
446
+ });
447
+ const unsubConfig = client2.on("configUpdate", () => {
448
+ setConfig(client2.getConfig());
418
449
  });
419
450
  if (client2.isConnected()) {
420
451
  setIsConnected(true);
421
452
  setMessages(client2.getMessages());
422
453
  setOperatorOnline(client2.getSession()?.operatorOnline ?? false);
454
+ setConfig(client2.getConfig());
423
455
  }
424
456
  return () => {
425
457
  unsubOpen();
@@ -427,16 +459,31 @@ function ChatWidget({ client: client2, config }) {
427
459
  unsubTyping();
428
460
  unsubPresence();
429
461
  unsubConnect();
462
+ unsubConfig();
430
463
  };
431
464
  }, [client2]);
432
465
  (0, import_hooks.useEffect)(() => {
433
- messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
434
- }, [messages]);
466
+ if (isOpen) {
467
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
468
+ }
469
+ }, [messages, isOpen]);
435
470
  (0, import_hooks.useEffect)(() => {
436
471
  if (isOpen) {
472
+ setTimeout(() => {
473
+ messagesEndRef.current?.scrollIntoView({ behavior: "auto" });
474
+ }, 50);
437
475
  inputRef.current?.focus();
476
+ setUnreadCount(0);
438
477
  }
439
478
  }, [isOpen]);
479
+ (0, import_hooks.useEffect)(() => {
480
+ if (!isOpen && messages.length > 0) {
481
+ const unread = messages.filter(
482
+ (msg) => msg.sender !== "visitor" && msg.status !== "read"
483
+ ).length;
484
+ setUnreadCount(unread);
485
+ }
486
+ }, [messages, isOpen]);
440
487
  const markMessagesAsRead = (0, import_hooks.useCallback)(() => {
441
488
  if (!isOpen || !isConnected) return;
442
489
  const unreadMessages = messages.filter(
@@ -503,7 +550,8 @@ function ChatWidget({ client: client2, config }) {
503
550
  "aria-label": isOpen ? "Close chat" : "Open chat",
504
551
  children: [
505
552
  isOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CloseIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChatIcon, {}),
506
- !isOpen && operatorOnline && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { class: "pp-online-dot" })
553
+ !isOpen && unreadCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { class: "pp-unread-badge", children: unreadCount > 9 ? "9+" : unreadCount }),
554
+ !isOpen && unreadCount === 0 && operatorOnline && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { class: "pp-online-dot" })
507
555
  ]
508
556
  }
509
557
  ),
@@ -642,7 +690,7 @@ function StatusIcon({ status }) {
642
690
  }
643
691
 
644
692
  // src/version.ts
645
- var VERSION = "0.3.6";
693
+ var VERSION = "1.0.2";
646
694
 
647
695
  // src/client.ts
648
696
  var PocketPingClient = class {
@@ -658,6 +706,10 @@ var PocketPingClient = class {
658
706
  this.pollingTimeout = null;
659
707
  this.pollingFailures = 0;
660
708
  this.maxPollingFailures = 10;
709
+ this.wsConnectedAt = 0;
710
+ this.quickFailureThreshold = 2e3;
711
+ // If WS fails within 2s, assume serverless
712
+ this.usePollingFallback = false;
661
713
  this.trackedElementCleanups = [];
662
714
  this.currentTrackedElements = [];
663
715
  this.inspectorMode = false;
@@ -699,6 +751,24 @@ var PocketPingClient = class {
699
751
  messages: response.messages ?? [],
700
752
  identity: response.identity || storedIdentity || void 0
701
753
  };
754
+ if (response.operatorName) {
755
+ this.config.operatorName = response.operatorName;
756
+ }
757
+ if (response.operatorAvatar) {
758
+ this.config.operatorAvatar = response.operatorAvatar;
759
+ }
760
+ if (response.primaryColor) {
761
+ this.config.primaryColor = response.primaryColor;
762
+ }
763
+ if (response.welcomeMessage) {
764
+ this.config.welcomeMessage = response.welcomeMessage;
765
+ }
766
+ this.emit("configUpdate", {
767
+ operatorName: this.config.operatorName,
768
+ operatorAvatar: this.config.operatorAvatar,
769
+ primaryColor: this.config.primaryColor,
770
+ welcomeMessage: this.config.welcomeMessage
771
+ });
702
772
  this.storeSessionId(response.sessionId);
703
773
  this.connectWebSocket();
704
774
  if (response.inspectorMode) {
@@ -905,6 +975,9 @@ var PocketPingClient = class {
905
975
  isWidgetOpen() {
906
976
  return this.isOpen;
907
977
  }
978
+ getConfig() {
979
+ return this.config;
980
+ }
908
981
  setOpen(open2) {
909
982
  this.isOpen = open2;
910
983
  this.emit("openChange", open2);
@@ -1318,11 +1391,17 @@ var PocketPingClient = class {
1318
1391
  // ─────────────────────────────────────────────────────────────────
1319
1392
  connectWebSocket() {
1320
1393
  if (!this.session) return;
1394
+ if (this.usePollingFallback) {
1395
+ this.startPolling();
1396
+ return;
1397
+ }
1321
1398
  const wsUrl = this.config.endpoint.replace(/^http/, "ws").replace(/\/$/, "") + `/stream?sessionId=${this.session.sessionId}`;
1322
1399
  try {
1323
1400
  this.ws = new WebSocket(wsUrl);
1401
+ this.wsConnectedAt = Date.now();
1324
1402
  this.ws.onopen = () => {
1325
1403
  this.reconnectAttempts = 0;
1404
+ this.wsConnectedAt = Date.now();
1326
1405
  this.emit("wsConnected", null);
1327
1406
  };
1328
1407
  this.ws.onmessage = (event) => {
@@ -1335,16 +1414,29 @@ var PocketPingClient = class {
1335
1414
  };
1336
1415
  this.ws.onclose = () => {
1337
1416
  this.emit("wsDisconnected", null);
1338
- this.scheduleReconnect();
1417
+ this.handleWsFailure();
1339
1418
  };
1340
- this.ws.onerror = (err) => {
1341
- console.error("[PocketPing] WebSocket error:", err);
1419
+ this.ws.onerror = () => {
1342
1420
  };
1343
1421
  } catch (err) {
1344
1422
  console.warn("[PocketPing] WebSocket unavailable, using polling");
1423
+ this.usePollingFallback = true;
1345
1424
  this.startPolling();
1346
1425
  }
1347
1426
  }
1427
+ handleWsFailure() {
1428
+ const timeSinceConnect = Date.now() - this.wsConnectedAt;
1429
+ if (timeSinceConnect < this.quickFailureThreshold) {
1430
+ this.reconnectAttempts++;
1431
+ if (this.reconnectAttempts >= 2) {
1432
+ console.info("[PocketPing] WebSocket not available (serverless?), using polling");
1433
+ this.usePollingFallback = true;
1434
+ this.startPolling();
1435
+ return;
1436
+ }
1437
+ }
1438
+ this.scheduleReconnect();
1439
+ }
1348
1440
  handleWebSocketEvent(event) {
1349
1441
  switch (event.type) {
1350
1442
  case "message":
package/dist/index.d.cts CHANGED
@@ -180,6 +180,9 @@ declare class PocketPingClient {
180
180
  private pollingTimeout;
181
181
  private pollingFailures;
182
182
  private maxPollingFailures;
183
+ private wsConnectedAt;
184
+ private quickFailureThreshold;
185
+ private usePollingFallback;
183
186
  private trackedElementCleanups;
184
187
  private currentTrackedElements;
185
188
  private inspectorMode;
@@ -223,6 +226,7 @@ declare class PocketPingClient {
223
226
  getMessages(): Message[];
224
227
  isConnected(): boolean;
225
228
  isWidgetOpen(): boolean;
229
+ getConfig(): ResolvedPocketPingConfig;
226
230
  setOpen(open: boolean): void;
227
231
  toggleOpen(): void;
228
232
  on<T>(event: string, listener: Listener<T>): () => void;
@@ -285,6 +289,7 @@ declare class PocketPingClient {
285
289
  */
286
290
  isInspectorModeActive(): boolean;
287
291
  private connectWebSocket;
292
+ private handleWsFailure;
288
293
  private handleWebSocketEvent;
289
294
  private handleVersionWarning;
290
295
  private scheduleReconnect;
package/dist/index.d.ts CHANGED
@@ -180,6 +180,9 @@ declare class PocketPingClient {
180
180
  private pollingTimeout;
181
181
  private pollingFailures;
182
182
  private maxPollingFailures;
183
+ private wsConnectedAt;
184
+ private quickFailureThreshold;
185
+ private usePollingFallback;
183
186
  private trackedElementCleanups;
184
187
  private currentTrackedElements;
185
188
  private inspectorMode;
@@ -223,6 +226,7 @@ declare class PocketPingClient {
223
226
  getMessages(): Message[];
224
227
  isConnected(): boolean;
225
228
  isWidgetOpen(): boolean;
229
+ getConfig(): ResolvedPocketPingConfig;
226
230
  setOpen(open: boolean): void;
227
231
  toggleOpen(): void;
228
232
  on<T>(event: string, listener: Listener<T>): () => void;
@@ -285,6 +289,7 @@ declare class PocketPingClient {
285
289
  */
286
290
  isInspectorModeActive(): boolean;
287
291
  private connectWebSocket;
292
+ private handleWsFailure;
288
293
  private handleWebSocketEvent;
289
294
  private handleVersionWarning;
290
295
  private scheduleReconnect;
package/dist/index.js CHANGED
@@ -72,6 +72,31 @@ function styles(primaryColor, theme) {
72
72
  border: 2px solid white;
73
73
  }
74
74
 
75
+ .pp-unread-badge {
76
+ position: absolute;
77
+ top: -4px;
78
+ right: -4px;
79
+ min-width: 20px;
80
+ height: 20px;
81
+ padding: 0 6px;
82
+ background: #ef4444;
83
+ color: white;
84
+ border-radius: 10px;
85
+ border: 2px solid white;
86
+ font-size: 11px;
87
+ font-weight: 600;
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: center;
91
+ animation: pp-badge-pop 0.3s ease-out;
92
+ }
93
+
94
+ @keyframes pp-badge-pop {
95
+ 0% { transform: scale(0); }
96
+ 50% { transform: scale(1.2); }
97
+ 100% { transform: scale(1); }
98
+ }
99
+
75
100
  .pp-window {
76
101
  position: fixed;
77
102
  width: 380px;
@@ -352,13 +377,15 @@ function styles(primaryColor, theme) {
352
377
 
353
378
  // src/components/ChatWidget.tsx
354
379
  import { Fragment as Fragment2, jsx, jsxs } from "preact/jsx-runtime";
355
- function ChatWidget({ client: client2, config }) {
380
+ function ChatWidget({ client: client2, config: initialConfig }) {
356
381
  const [isOpen, setIsOpen] = useState(false);
357
382
  const [messages, setMessages] = useState([]);
358
383
  const [inputValue, setInputValue] = useState("");
359
384
  const [isTyping, setIsTyping] = useState(false);
360
385
  const [operatorOnline, setOperatorOnline] = useState(false);
361
386
  const [isConnected, setIsConnected] = useState(false);
387
+ const [unreadCount, setUnreadCount] = useState(0);
388
+ const [config, setConfig] = useState(initialConfig);
362
389
  const messagesEndRef = useRef(null);
363
390
  const inputRef = useRef(null);
364
391
  useEffect(() => {
@@ -376,11 +403,16 @@ function ChatWidget({ client: client2, config }) {
376
403
  setIsConnected(true);
377
404
  setMessages(client2.getMessages());
378
405
  setOperatorOnline(client2.getSession()?.operatorOnline ?? false);
406
+ setConfig(client2.getConfig());
407
+ });
408
+ const unsubConfig = client2.on("configUpdate", () => {
409
+ setConfig(client2.getConfig());
379
410
  });
380
411
  if (client2.isConnected()) {
381
412
  setIsConnected(true);
382
413
  setMessages(client2.getMessages());
383
414
  setOperatorOnline(client2.getSession()?.operatorOnline ?? false);
415
+ setConfig(client2.getConfig());
384
416
  }
385
417
  return () => {
386
418
  unsubOpen();
@@ -388,16 +420,31 @@ function ChatWidget({ client: client2, config }) {
388
420
  unsubTyping();
389
421
  unsubPresence();
390
422
  unsubConnect();
423
+ unsubConfig();
391
424
  };
392
425
  }, [client2]);
393
426
  useEffect(() => {
394
- messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
395
- }, [messages]);
427
+ if (isOpen) {
428
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
429
+ }
430
+ }, [messages, isOpen]);
396
431
  useEffect(() => {
397
432
  if (isOpen) {
433
+ setTimeout(() => {
434
+ messagesEndRef.current?.scrollIntoView({ behavior: "auto" });
435
+ }, 50);
398
436
  inputRef.current?.focus();
437
+ setUnreadCount(0);
399
438
  }
400
439
  }, [isOpen]);
440
+ useEffect(() => {
441
+ if (!isOpen && messages.length > 0) {
442
+ const unread = messages.filter(
443
+ (msg) => msg.sender !== "visitor" && msg.status !== "read"
444
+ ).length;
445
+ setUnreadCount(unread);
446
+ }
447
+ }, [messages, isOpen]);
401
448
  const markMessagesAsRead = useCallback(() => {
402
449
  if (!isOpen || !isConnected) return;
403
450
  const unreadMessages = messages.filter(
@@ -464,7 +511,8 @@ function ChatWidget({ client: client2, config }) {
464
511
  "aria-label": isOpen ? "Close chat" : "Open chat",
465
512
  children: [
466
513
  isOpen ? /* @__PURE__ */ jsx(CloseIcon, {}) : /* @__PURE__ */ jsx(ChatIcon, {}),
467
- !isOpen && operatorOnline && /* @__PURE__ */ jsx("span", { class: "pp-online-dot" })
514
+ !isOpen && unreadCount > 0 && /* @__PURE__ */ jsx("span", { class: "pp-unread-badge", children: unreadCount > 9 ? "9+" : unreadCount }),
515
+ !isOpen && unreadCount === 0 && operatorOnline && /* @__PURE__ */ jsx("span", { class: "pp-online-dot" })
468
516
  ]
469
517
  }
470
518
  ),
@@ -603,7 +651,7 @@ function StatusIcon({ status }) {
603
651
  }
604
652
 
605
653
  // src/version.ts
606
- var VERSION = "0.3.6";
654
+ var VERSION = "1.0.2";
607
655
 
608
656
  // src/client.ts
609
657
  var PocketPingClient = class {
@@ -619,6 +667,10 @@ var PocketPingClient = class {
619
667
  this.pollingTimeout = null;
620
668
  this.pollingFailures = 0;
621
669
  this.maxPollingFailures = 10;
670
+ this.wsConnectedAt = 0;
671
+ this.quickFailureThreshold = 2e3;
672
+ // If WS fails within 2s, assume serverless
673
+ this.usePollingFallback = false;
622
674
  this.trackedElementCleanups = [];
623
675
  this.currentTrackedElements = [];
624
676
  this.inspectorMode = false;
@@ -660,6 +712,24 @@ var PocketPingClient = class {
660
712
  messages: response.messages ?? [],
661
713
  identity: response.identity || storedIdentity || void 0
662
714
  };
715
+ if (response.operatorName) {
716
+ this.config.operatorName = response.operatorName;
717
+ }
718
+ if (response.operatorAvatar) {
719
+ this.config.operatorAvatar = response.operatorAvatar;
720
+ }
721
+ if (response.primaryColor) {
722
+ this.config.primaryColor = response.primaryColor;
723
+ }
724
+ if (response.welcomeMessage) {
725
+ this.config.welcomeMessage = response.welcomeMessage;
726
+ }
727
+ this.emit("configUpdate", {
728
+ operatorName: this.config.operatorName,
729
+ operatorAvatar: this.config.operatorAvatar,
730
+ primaryColor: this.config.primaryColor,
731
+ welcomeMessage: this.config.welcomeMessage
732
+ });
663
733
  this.storeSessionId(response.sessionId);
664
734
  this.connectWebSocket();
665
735
  if (response.inspectorMode) {
@@ -866,6 +936,9 @@ var PocketPingClient = class {
866
936
  isWidgetOpen() {
867
937
  return this.isOpen;
868
938
  }
939
+ getConfig() {
940
+ return this.config;
941
+ }
869
942
  setOpen(open2) {
870
943
  this.isOpen = open2;
871
944
  this.emit("openChange", open2);
@@ -1279,11 +1352,17 @@ var PocketPingClient = class {
1279
1352
  // ─────────────────────────────────────────────────────────────────
1280
1353
  connectWebSocket() {
1281
1354
  if (!this.session) return;
1355
+ if (this.usePollingFallback) {
1356
+ this.startPolling();
1357
+ return;
1358
+ }
1282
1359
  const wsUrl = this.config.endpoint.replace(/^http/, "ws").replace(/\/$/, "") + `/stream?sessionId=${this.session.sessionId}`;
1283
1360
  try {
1284
1361
  this.ws = new WebSocket(wsUrl);
1362
+ this.wsConnectedAt = Date.now();
1285
1363
  this.ws.onopen = () => {
1286
1364
  this.reconnectAttempts = 0;
1365
+ this.wsConnectedAt = Date.now();
1287
1366
  this.emit("wsConnected", null);
1288
1367
  };
1289
1368
  this.ws.onmessage = (event) => {
@@ -1296,16 +1375,29 @@ var PocketPingClient = class {
1296
1375
  };
1297
1376
  this.ws.onclose = () => {
1298
1377
  this.emit("wsDisconnected", null);
1299
- this.scheduleReconnect();
1378
+ this.handleWsFailure();
1300
1379
  };
1301
- this.ws.onerror = (err) => {
1302
- console.error("[PocketPing] WebSocket error:", err);
1380
+ this.ws.onerror = () => {
1303
1381
  };
1304
1382
  } catch (err) {
1305
1383
  console.warn("[PocketPing] WebSocket unavailable, using polling");
1384
+ this.usePollingFallback = true;
1306
1385
  this.startPolling();
1307
1386
  }
1308
1387
  }
1388
+ handleWsFailure() {
1389
+ const timeSinceConnect = Date.now() - this.wsConnectedAt;
1390
+ if (timeSinceConnect < this.quickFailureThreshold) {
1391
+ this.reconnectAttempts++;
1392
+ if (this.reconnectAttempts >= 2) {
1393
+ console.info("[PocketPing] WebSocket not available (serverless?), using polling");
1394
+ this.usePollingFallback = true;
1395
+ this.startPolling();
1396
+ return;
1397
+ }
1398
+ }
1399
+ this.scheduleReconnect();
1400
+ }
1309
1401
  handleWebSocketEvent(event) {
1310
1402
  switch (event.type) {
1311
1403
  case "message":
@@ -1,4 +1,4 @@
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`
1
+ "use strict";var PocketPing=(()=>{var te=Object.defineProperty;var pt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var gt=(t,e)=>{for(var n in e)te(t,n,{get:e[n],enumerable:!0})},_t=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of dt(e))!ut.call(t,i)&&i!==n&&te(t,i,{get:()=>e[i],enumerable:!(s=pt(e,i))||s.enumerable});return t};var ft=t=>_t(te({},"__esModule",{value:!0}),t);var Rt={};gt(Rt,{close:()=>Ge,default:()=>Ht,destroy:()=>Je,getIdentity:()=>ot,getTrackedElements:()=>et,identify:()=>st,init:()=>fe,offEvent:()=>nt,on:()=>rt,onEvent:()=>tt,open:()=>Xe,reset:()=>it,sendMessage:()=>Ze,setupTrackedElements:()=>Qe,toggle:()=>Ye,trigger:()=>Ke});var G,y,be,ht,N,he,xe,ke,we,oe,ne,se,mt,U={},Pe=[],vt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Y=Array.isArray;function T(t,e){for(var n in e)t[n]=e[n];return t}function re(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function ae(t,e,n){var s,i,o,a={};for(o in e)o=="key"?s=e[o]:o=="ref"?i=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?G.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)a[o]===void 0&&(a[o]=t.defaultProps[o]);return q(t,a,s,i,null)}function q(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??++be,__i:-1,__u:0};return i==null&&y.vnode!=null&&y.vnode(o),o}function I(t){return t.children}function J(t,e){this.props=t,this.context=e}function L(t,e){if(e==null)return t.__?L(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"?L(t):null}function Se(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 Se(t)}}function me(t){(!t.__d&&(t.__d=!0)&&N.push(t)&&!X.__r++||he!=y.debounceRendering)&&((he=y.debounceRendering)||xe)(X)}function X(){for(var t,e,n,s,i,o,a,c=1;N.length;)N.length>c&&N.sort(ke),t=N.shift(),c=N.length,t.__d&&(n=void 0,s=void 0,i=(s=(e=t).__v).__e,o=[],a=[],e.__P&&((n=T({},s)).__v=s.__v+1,y.vnode&&y.vnode(n),le(e.__P,n,s,e.__n,e.__P.namespaceURI,32&s.__u?[i]:null,o,i??L(s),!!(32&s.__u),a),n.__v=s.__v,n.__.__k[n.__i]=n,Ie(o,n,a),s.__e=s.__=null,n.__e!=i&&Se(n)));X.__r=0}function Ee(t,e,n,s,i,o,a,c,p,l,g){var r,d,_,x,S,h,v,m=s&&s.__k||Pe,C=e.length;for(p=yt(n,e,m,p,C),r=0;r<C;r++)(_=n.__k[r])!=null&&(d=_.__i==-1?U:m[_.__i]||U,_.__i=r,h=le(t,_,d,i,o,a,c,p,l,g),x=_.__e,_.ref&&d.ref!=_.ref&&(d.ref&&ce(d.ref,null,_),g.push(_.ref,_.__c||x,_)),S==null&&x!=null&&(S=x),(v=!!(4&_.__u))||d.__k===_.__k?p=Ce(_,p,t,v):typeof _.type=="function"&&h!==void 0?p=h:x&&(p=x.nextSibling),_.__u&=-7);return n.__e=S,p}function yt(t,e,n,s,i){var o,a,c,p,l,g=n.length,r=g,d=0;for(t.__k=new Array(i),o=0;o<i;o++)(a=e[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=t.__k[o]=q(null,a,null,null,null):Y(a)?a=t.__k[o]=q(I,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[o]=q(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[o]=a,p=o+d,a.__=t,a.__b=t.__b+1,c=null,(l=a.__i=bt(a,n,p,r))!=-1&&(r--,(c=n[l])&&(c.__u|=2)),c==null||c.__v==null?(l==-1&&(i>g?d--:i<g&&d++),typeof a.type!="function"&&(a.__u|=4)):l!=p&&(l==p-1?d--:l==p+1?d++:(l>p?d--:d++,a.__u|=4))):t.__k[o]=null;if(r)for(o=0;o<g;o++)(c=n[o])!=null&&(2&c.__u)==0&&(c.__e==s&&(s=L(c)),Me(c,c));return s}function Ce(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=Ce(i[o],e,n,s));return e}t.__e!=e&&(s&&(e&&t.type&&!e.parentNode&&(e=L(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function bt(t,e,n,s){var i,o,a,c=t.key,p=t.type,l=e[n],g=l!=null&&(2&l.__u)==0;if(l===null&&c==null||g&&c==l.key&&p==l.type)return n;if(s>(g?1:0)){for(i=n-1,o=n+1;i>=0||o<e.length;)if((l=e[a=i>=0?i--:o++])!=null&&(2&l.__u)==0&&c==l.key&&p==l.type)return a}return-1}function ve(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||vt.test(e)?n:n+"px"}function B(t,e,n,s,i){var o,a;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||ve(t.style,e,"");if(n)for(e in n)s&&n[e]==s[e]||ve(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(we,"$1")),a=e.toLowerCase(),e=a in t||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?s?n.u=s.u:(n.u=oe,t.addEventListener(e,o?se:ne,o)):t.removeEventListener(e,o?se:ne,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 ye(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=oe++;else if(e.t<n.u)return;return n(y.event?y.event(e):e)}}}function le(t,e,n,s,i,o,a,c,p,l){var g,r,d,_,x,S,h,v,m,C,E,W,H,j,R,$,F,f=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(p=!!(32&n.__u),o=[c=e.__e=n.__e]),(g=y.__b)&&g(e);e:if(typeof f=="function")try{if(v=e.props,m="prototype"in f&&f.prototype.render,C=(g=f.contextType)&&s[g.__c],E=g?C?C.props.value:g.__:s,n.__c?h=(r=e.__c=n.__c).__=r.__E:(m?e.__c=r=new f(v,E):(e.__c=r=new J(v,E),r.constructor=f,r.render=kt),C&&C.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&&f.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=T({},r.__s)),T(r.__s,f.getDerivedStateFromProps(v,r.__s))),_=r.props,x=r.state,r.__v=e,d)m&&f.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),m&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(m&&f.getDerivedStateFromProps==null&&v!==_&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(v,E),e.__v==n.__v||!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(v,r.__s,E)===!1){for(e.__v!=n.__v&&(r.props=v,r.state=r.__s,r.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(w){w&&(w.__=e)}),W=0;W<r._sb.length;W++)r.__h.push(r._sb[W]);r._sb=[],r.__h.length&&a.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(v,r.__s,E),m&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(_,x,S)})}if(r.context=E,r.props=v,r.__P=t,r.__e=!1,H=y.__r,j=0,m){for(r.state=r.__s,r.__d=!1,H&&H(e),g=r.render(r.props,r.state,r.context),R=0;R<r._sb.length;R++)r.__h.push(r._sb[R]);r._sb=[]}else do r.__d=!1,H&&H(e),g=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++j<25);r.state=r.__s,r.getChildContext!=null&&(s=T(T({},s),r.getChildContext())),m&&!d&&r.getSnapshotBeforeUpdate!=null&&(S=r.getSnapshotBeforeUpdate(_,x)),$=g,g!=null&&g.type===I&&g.key==null&&($=Te(g.props.children)),c=Ee(t,Y($)?$:[$],e,n,s,i,o,a,c,p,l),r.base=e.__e,e.__u&=-161,r.__h.length&&a.push(r),h&&(r.__E=r.__=null)}catch(w){if(e.__v=null,p||o!=null)if(w.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--;)re(o[F]);ie(e)}else e.__e=n.__e,e.__k=n.__k,w.then||ie(e);y.__e(w,e,n)}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):c=e.__e=xt(n.__e,e,n,s,i,o,a,p,l);return(g=y.diffed)&&g(e),128&e.__u?void 0:c}function ie(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(ie)}function Ie(t,e,n){for(var s=0;s<n.length;s++)ce(n[s],n[++s],n[++s]);y.__c&&y.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){y.__e(o,i.__v)}})}function Te(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:Y(t)?t.map(Te):T({},t)}function xt(t,e,n,s,i,o,a,c,p){var l,g,r,d,_,x,S,h=n.props||U,v=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(l=0;l<o.length;l++)if((_=o[l])&&"setAttribute"in _==!!m&&(m?_.localName==m:_.nodeType==3)){t=_,o[l]=null;break}}if(t==null){if(m==null)return document.createTextNode(v);t=document.createElementNS(i,m,v.is&&v),c&&(y.__m&&y.__m(e,o),c=!1),o=null}if(m==null)h===v||c&&t.data==v||(t.data=v);else{if(o=o&&G.call(t.childNodes),!c&&o!=null)for(h={},l=0;l<t.attributes.length;l++)h[(_=t.attributes[l]).name]=_.value;for(l in h)if(_=h[l],l!="children"){if(l=="dangerouslySetInnerHTML")r=_;else if(!(l in v)){if(l=="value"&&"defaultValue"in v||l=="checked"&&"defaultChecked"in v)continue;B(t,l,null,_,i)}}for(l in v)_=v[l],l=="children"?d=_:l=="dangerouslySetInnerHTML"?g=_:l=="value"?x=_:l=="checked"?S=_:c&&typeof _!="function"||h[l]===_||B(t,l,_,h[l],i);if(g)c||r&&(g.__html==r.__html||g.__html==t.innerHTML)||(t.innerHTML=g.__html),e.__k=[];else if(r&&(t.innerHTML=""),Ee(e.type=="template"?t.content:t,Y(d)?d:[d],e,n,s,m=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&L(n,0),c,p),o!=null)for(l=o.length;l--;)re(o[l]);c||(l="value",m=="progress"&&x==null?t.removeAttribute("value"):x!=null&&(x!==t[l]||m=="progress"&&!x||m=="option"&&x!=h[l])&&B(t,l,x,h[l],i),l="checked",S!=null&&S!=t[l]&&B(t,l,S,h[l],i))}return t}function ce(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){y.__e(i,n)}}function Me(t,e,n){var s,i;if(y.unmount&&y.unmount(t),(s=t.ref)&&(s.current&&s.current!=t.__e||ce(s,null,e)),(s=t.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(o){y.__e(o,e)}s.base=s.__P=null}if(s=t.__k)for(i=0;i<s.length;i++)s[i]&&Me(s[i],e,n||typeof t.type!="function");n||re(t.__e),t.__c=t.__=t.__e=void 0}function kt(t,e,n){return this.constructor(t,n)}function pe(t,e,n){var s,i,o,a;e==document&&(e=document.documentElement),y.__&&y.__(t,e),i=(s=typeof n=="function")?null:n&&n.__k||e.__k,o=[],a=[],le(e,t=(!s&&n||e).__k=ae(I,null,[t]),i||U,U,e.namespaceURI,!s&&n?[n]:i?null:e.firstChild?G.call(e.childNodes):null,o,!s&&n?n:i?i.__e:e.firstChild,s,a),Ie(o,t,a)}G=Pe.slice,y={__e:function(t,e,n,s){for(var i,o,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,s||{}),a=i.__d),a)return i.__E=i}catch(c){t=c}throw t}},be=0,ht=function(t){return t!=null&&t.constructor===void 0},J.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=T({},this.state),typeof t=="function"&&(t=t(T({},n),this.props)),t&&T(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),me(this))},J.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),me(this))},J.prototype.render=I,N=[],xe=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ke=function(t,e){return t.__v.__b-e.__v.__b},X.__r=0,we=/(PointerCapture)$|Capture$/i,oe=0,ne=ye(!1),se=ye(!0),mt=0;var D,k,de,$e,z=0,Fe=[],P=y,Ae=P.__b,Oe=P.__r,He=P.diffed,Re=P.__c,Ne=P.unmount,Le=P.__;function ge(t,e){P.__h&&P.__h(k,t,z||e),z=0;var n=k.__H||(k.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function M(t){return z=1,wt(ze,t)}function wt(t,e,n){var s=ge(D++,2);if(s.t=t,!s.__c&&(s.__=[n?n(e):ze(void 0,e),function(c){var p=s.__N?s.__N[0]:s.__[0],l=s.t(p,c);p!==l&&(s.__N=[l,s.__[1]],s.__c.setState({}))}],s.__c=k,!k.__f)){var i=function(c,p,l){if(!s.__c.__H)return!0;var g=s.__c.__H.__.filter(function(d){return!!d.__c});if(g.every(function(d){return!d.__N}))return!o||o.call(this,c,p,l);var r=s.__c.props!==c;return g.forEach(function(d){if(d.__N){var _=d.__[0];d.__=d.__N,d.__N=void 0,_!==d.__[0]&&(r=!0)}}),o&&o.call(this,c,p,l)||r};k.__f=!0;var o=k.shouldComponentUpdate,a=k.componentWillUpdate;k.componentWillUpdate=function(c,p,l){if(this.__e){var g=o;o=void 0,i(c,p,l),o=g}a&&a.call(this,c,p,l)},k.shouldComponentUpdate=i}return s.__N||s.__}function A(t,e){var n=ge(D++,3);!P.__s&&De(n.__H,e)&&(n.__=t,n.u=e,k.__H.__h.push(n))}function _e(t){return z=5,Ve(function(){return{current:t}},[])}function Ve(t,e){var n=ge(D++,7);return De(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function Ue(t,e){return z=8,Ve(function(){return t},e)}function Pt(){for(var t;t=Fe.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Z),t.__H.__h.forEach(ue),t.__H.__h=[]}catch(e){t.__H.__h=[],P.__e(e,t.__v)}}P.__b=function(t){k=null,Ae&&Ae(t)},P.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Le&&Le(t,e)},P.__r=function(t){Oe&&Oe(t),D=0;var e=(k=t.__c).__H;e&&(de===k?(e.__h=[],k.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(Z),e.__h.forEach(ue),e.__h=[],D=0)),de=k},P.diffed=function(t){He&&He(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Fe.push(e)!==1&&$e===P.requestAnimationFrame||(($e=P.requestAnimationFrame)||St)(Pt)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),de=k=null},P.__c=function(t,e){e.some(function(n){try{n.__h.forEach(Z),n.__h=n.__h.filter(function(s){return!s.__||ue(s)})}catch(s){e.some(function(i){i.__h&&(i.__h=[])}),e=[],P.__e(s,n.__v)}}),Re&&Re(t,e)},P.unmount=function(t){Ne&&Ne(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(s){try{Z(s)}catch(i){e=i}}),n.__H=void 0,e&&P.__e(e,n.__v))};var We=typeof requestAnimationFrame=="function";function St(t){var e,n=function(){clearTimeout(s),We&&cancelAnimationFrame(e),setTimeout(t)},s=setTimeout(n,35);We&&(e=requestAnimationFrame(n))}function Z(t){var e=k,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),k=e}function ue(t){var e=k;t.__c=t.__(),k=e}function De(t,e){return!t||t.length!==e.length||e.some(function(n,s){return n!==t[s]})}function ze(t,e){return typeof e=="function"?e(t):e}function je(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;
@@ -54,6 +54,31 @@
54
54
  border: 2px solid white;
55
55
  }
56
56
 
57
+ .pp-unread-badge {
58
+ position: absolute;
59
+ top: -4px;
60
+ right: -4px;
61
+ min-width: 20px;
62
+ height: 20px;
63
+ padding: 0 6px;
64
+ background: #ef4444;
65
+ color: white;
66
+ border-radius: 10px;
67
+ border: 2px solid white;
68
+ font-size: 11px;
69
+ font-weight: 600;
70
+ display: flex;
71
+ align-items: center;
72
+ justify-content: center;
73
+ animation: pp-badge-pop 0.3s ease-out;
74
+ }
75
+
76
+ @keyframes pp-badge-pop {
77
+ 0% { transform: scale(0); }
78
+ 50% { transform: scale(1.2); }
79
+ 100% { transform: scale(1); }
80
+ }
81
+
57
82
  .pp-window {
58
83
  position: fixed;
59
84
  width: 380px;
@@ -329,7 +354,7 @@
329
354
  .pp-footer a:hover {
330
355
  text-decoration: underline;
331
356
  }
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=`
357
+ `}var Et=0;function u(t,e,n,s,i,o){e||(e={});var a,c,p=e;if("ref"in p)for(c in p={},e)c=="ref"?a=e[c]:p[c]=e[c];var l={type:t,props:p,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Et,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(a=t.defaultProps))for(c in a)p[c]===void 0&&(p[c]=a[c]);return y.vnode&&y.vnode(l),l}function qe({client:t,config:e}){let[n,s]=M(!1),[i,o]=M([]),[a,c]=M(""),[p,l]=M(!1),[g,r]=M(!1),[d,_]=M(!1),[x,S]=M(0),[h,v]=M(e),m=_e(null),C=_e(null);A(()=>{let f=t.on("openChange",s),w=t.on("message",()=>{o([...t.getMessages()])}),V=t.on("typing",ee=>{l(ee.isTyping)}),at=t.on("presence",ee=>{r(ee.online)}),lt=t.on("connect",()=>{_(!0),o(t.getMessages()),r(t.getSession()?.operatorOnline??!1),v(t.getConfig())}),ct=t.on("configUpdate",()=>{v(t.getConfig())});return t.isConnected()&&(_(!0),o(t.getMessages()),r(t.getSession()?.operatorOnline??!1),v(t.getConfig())),()=>{f(),w(),V(),at(),lt(),ct()}},[t]),A(()=>{n&&m.current?.scrollIntoView({behavior:"smooth"})},[i,n]),A(()=>{n&&(setTimeout(()=>{m.current?.scrollIntoView({behavior:"auto"})},50),C.current?.focus(),S(0))},[n]),A(()=>{if(!n&&i.length>0){let f=i.filter(w=>w.sender!=="visitor"&&w.status!=="read").length;S(f)}},[i,n]);let E=Ue(()=>{if(!n||!d)return;let f=i.filter(w=>w.sender!=="visitor"&&w.status!=="read");if(f.length>0){let w=f.map(V=>V.id);t.sendReadStatus(w,"read")}},[n,d,i,t]);if(A(()=>{if(!n||!d)return;let f=setTimeout(()=>{E()},1e3);return()=>clearTimeout(f)},[n,d,i,E]),A(()=>{let f=()=>{document.visibilityState==="visible"&&n&&E()};return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[n,E]),A(()=>{let f=t.on("read",()=>{o([...t.getMessages()])});return()=>f()},[t]),!Ct(h))return null;let H=async f=>{if(f.preventDefault(),!a.trim())return;let w=a;c("");try{await t.sendMessage(w)}catch(V){console.error("[PocketPing] Failed to send message:",V)}},j=f=>{let w=f.target;c(w.value),t.sendTyping(!0)},R=h.position??"bottom-right",$=It(h.theme??"auto"),F=h.primaryColor??"#6366f1";return u(I,{children:[u("style",{children:je(F,$)}),u("button",{class:`pp-toggle pp-${R}`,onClick:()=>t.toggleOpen(),"aria-label":n?"Close chat":"Open chat",children:[n?u(Be,{}):u(Mt,{}),!n&&x>0&&u("span",{class:"pp-unread-badge",children:x>9?"9+":x}),!n&&x===0&&g&&u("span",{class:"pp-online-dot"})]}),n&&u("div",{class:`pp-window pp-${R} pp-theme-${$}`,children:[u("div",{class:"pp-header",children:[u("div",{class:"pp-header-info",children:[h.operatorAvatar&&u("img",{src:h.operatorAvatar,alt:"",class:"pp-avatar"}),u("div",{children:[u("div",{class:"pp-header-title",children:h.operatorName??"Support"}),u("div",{class:"pp-header-status",children:g?u(I,{children:[u("span",{class:"pp-status-dot pp-online"})," Online"]}):u(I,{children:[u("span",{class:"pp-status-dot"})," Away"]})})]})]}),u("button",{class:"pp-close-btn",onClick:()=>t.setOpen(!1),"aria-label":"Close chat",children:u(Be,{})})]}),u("div",{class:"pp-messages",children:[h.welcomeMessage&&i.length===0&&u("div",{class:"pp-welcome",children:h.welcomeMessage}),i.map(f=>u("div",{class:`pp-message pp-message-${f.sender}`,children:[u("div",{class:"pp-message-content",children:f.content}),u("div",{class:"pp-message-time",children:[Tt(f.timestamp),f.sender==="ai"&&u("span",{class:"pp-ai-badge",children:"AI"}),f.sender==="visitor"&&u("span",{class:`pp-status pp-status-${f.status??"sent"}`,children:u(At,{status:f.status})})]})]},f.id)),p&&u("div",{class:"pp-message pp-message-operator pp-typing",children:[u("span",{}),u("span",{}),u("span",{})]}),u("div",{ref:m})]}),u("form",{class:"pp-input-form",onSubmit:H,children:[u("input",{ref:C,type:"text",class:"pp-input",placeholder:h.placeholder??"Type a message...",value:a,onInput:j,disabled:!d}),u("button",{type:"submit",class:"pp-send-btn",disabled:!a.trim()||!d,"aria-label":"Send message",children:u($t,{})})]}),u("div",{class:"pp-footer",children:["Powered by ",u("a",{href:"https://pocketping.io",target:"_blank",rel:"noopener",children:"PocketPing"})]})]})]})}function Ct(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 It(t){return t==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t}function Tt(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Mt(){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 Be(){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 $t(){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 At({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 K="1.0.2";var Q=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.wsConnectedAt=0;this.quickFailureThreshold=2e3;this.usePollingFallback=!1;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"),a=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:a.sessionId,visitorId:a.visitorId,operatorOnline:a.operatorOnline??!1,messages:a.messages??[],identity:a.identity||s||void 0},a.operatorName&&(this.config.operatorName=a.operatorName),a.operatorAvatar&&(this.config.operatorAvatar=a.operatorAvatar),a.primaryColor&&(this.config.primaryColor=a.primaryColor),a.welcomeMessage&&(this.config.welcomeMessage=a.welcomeMessage),this.emit("configUpdate",{operatorName:this.config.operatorName,operatorAvatar:this.config.operatorAvatar,primaryColor:this.config.primaryColor,welcomeMessage:this.config.welcomeMessage}),this.storeSessionId(a.sessionId),this.connectWebSocket(),a.inspectorMode?this.enableInspectorMode():a.trackedElements?.length&&this.setupTrackedElements(a.trackedElements),this.emit("connect",this.session),this.config.onConnect?.(a.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 a=this.session.messages[o]||{id:i.messageId,sessionId:this.session.sessionId,content:e,sender:"visitor",timestamp:i.timestamp,status:"sent"};return this.config.onMessage?.(a),a}catch(i){let o=this.session.messages.findIndex(a=>a.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}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(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=a=>{let c={...n.data,selector:n.selector,elementText:a.target?.textContent?.trim().slice(0,100),url:window.location.href};this.trigger(n.name,c,{widgetMessage:n.widgetMessage})},o=a=>{a.target?.closest(n.selector)&&i(a)};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=`
333
358
  <style>
334
359
  #pp-inspector-overlay {
335
360
  position: fixed;
@@ -412,9 +437,9 @@
412
437
  <button id="pp-inspector-exit">Exit</button>
413
438
  </div>
414
439
  <div id="pp-inspector-tooltip"></div>
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=`
440
+ `,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 l=Array.from(p.classList).filter(d=>!d.startsWith("pp-"));if(l.length>0){let d="."+l.map(_=>CSS.escape(_)).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 _=`[${d.name}="${CSS.escape(d.value)}"]`;if(document.querySelectorAll(_).length===1)return _}let g=[],r=p;for(;r&&r!==document.body;){let d=r.tagName.toLowerCase();if(r.id&&!r.id.startsWith("pp-")){d=`#${CSS.escape(r.id)}`,g.unshift(d);break}let _=r.parentElement;if(_){let x=r.tagName,S=Array.from(_.children).filter(h=>h.tagName===x);if(S.length>1){let h=S.indexOf(r)+1;d+=`:nth-of-type(${h})`}}g.unshift(d),r=_}return g.join(" > ")},o=p=>{let l=p.target;if(l.closest("#pp-inspector-overlay")||l.closest("#pocketping-widget"))return;s&&s.classList.remove("pp-inspector-highlight"),l.classList.add("pp-inspector-highlight"),s=l;let g=i(l);n.textContent=g,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`)},a=p=>{let l=p.target;l.closest("#pp-inspector-overlay")||(l.classList.remove("pp-inspector-highlight"),n.style.display="none")},c=p=>{let l=p.target;if(l.id==="pp-inspector-exit"){this.disableInspectorMode();return}if(l.closest("#pp-inspector-overlay")||l.closest("#pocketping-widget"))return;p.preventDefault(),p.stopPropagation();let g=i(l);this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"inspector_select",data:{selector:g,tagName:l.tagName.toLowerCase(),text:l.textContent?.trim().slice(0,50)||"",url:window.location.href}})),this.emit("inspectorSelect",{selector:g,element:l}),l.classList.remove("pp-inspector-highlight"),l.classList.add("pp-inspector-highlight"),setTimeout(()=>{l.classList.remove("pp-inspector-highlight")},500);let r=document.getElementById("pp-inspector-banner");if(r){let d=r.innerHTML;r.innerHTML=`
416
441
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
417
442
  <polyline points="20 6 9 17 4 12"/>
418
443
  </svg>
419
- <span>Selector captured: <code style="background:rgba(255,255,255,0.2);padding:2px 6px;border-radius:4px;font-family:monospace;">${_}</code></span>
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);})();
444
+ <span>Selector captured: <code style="background:rgba(255,255,255,0.2);padding:2px 6px;border-radius:4px;font-family:monospace;">${g}</code></span>
445
+ `,setTimeout(()=>{r&&this.inspectorMode&&(r.innerHTML=d,document.getElementById("pp-inspector-exit")?.addEventListener("click",()=>{this.disableInspectorMode()}))},2e3)}console.info(`[PocketPing] \u{1F4CC} Selector captured: ${g}`)};document.addEventListener("mouseover",o,!0),document.addEventListener("mouseout",a,!0),document.addEventListener("click",c,!0),this.inspectorCleanup=()=>{document.removeEventListener("mouseover",o,!0),document.removeEventListener("mouseout",a,!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;if(this.usePollingFallback){this.startPolling();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(),this.ws.onopen=()=>{this.reconnectAttempts=0,this.wsConnectedAt=Date.now(),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.handleWsFailure()},this.ws.onerror=()=>{}}catch{console.warn("[PocketPing] WebSocket unavailable, using polling"),this.usePollingFallback=!0,this.startPolling()}}handleWsFailure(){if(Date.now()-this.wsConnectedAt<this.quickFailureThreshold&&(this.reconnectAttempts++,this.reconnectAttempts>=2)){console.info("[PocketPing] WebSocket not available (serverless?), using polling"),this.usePollingFallback=!0,this.startPolling();return}this.scheduleReconnect()}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(g=>g.sender===n.sender&&g.content===n.content&&Math.abs(new Date(g.timestamp).getTime()-l)<2e3)}if(p>=0){let l=this.session.messages[p];n.status&&n.status!==l.status&&(l.status=n.status,n.deliveredAt&&(l.deliveredAt=n.deliveredAt),n.readAt&&(l.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 a=e.data;this.handleVersionWarning(a);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":K,...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 a="info",c=!0;n==="deprecated"?a="warning":n==="unsupported"?(a="error",c=!1):n==="outdated"&&(a="info");let p={severity:a,message:o||`Widget version ${K} is ${n}`,currentVersion:K,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 b=null,O=null,Ot="https://app.pocketping.io/api/widget";function fe(t){if(b)return console.warn("[PocketPing] Already initialized"),b;let e=t.endpoint;if(!e&&t.projectId&&(e=`${Ot}/${t.projectId}`),!e)throw new Error("[PocketPing] endpoint or projectId is required");let n={...t,endpoint:e};return b=new Q(n),O=document.createElement("div"),O.id="pocketping-container",document.body.appendChild(O),pe(ae(qe,{client:b,config:t}),O),b.connect().catch(s=>{console.error("[PocketPing] Failed to connect:",s)}),b}function Je(){O&&(pe(null,O),O.remove(),O=null),b&&(b.disconnect(),b=null)}function Xe(){b?.setOpen(!0)}function Ge(){b?.setOpen(!1)}function Ye(){b?.toggleOpen()}function Ze(t){if(!b)throw new Error("[PocketPing] Not initialized");return b.sendMessage(t)}function Ke(t,e,n){if(!b){console.warn("[PocketPing] Not initialized, cannot trigger event");return}b.trigger(t,e,n)}function Qe(t){if(!b){console.warn("[PocketPing] Not initialized, cannot setup tracked elements");return}b.setupTrackedElements(t)}function et(){return b?.getTrackedElements()||[]}function tt(t,e){return b?b.onEvent(t,e):(console.warn("[PocketPing] Not initialized, cannot subscribe to event"),()=>{})}function nt(t,e){b?.offEvent(t,e)}async function st(t){if(!b)throw new Error("[PocketPing] Not initialized");return b.identify(t)}async function it(t){if(!b){console.warn("[PocketPing] Not initialized");return}return b.reset(t)}function ot(){return b?.getIdentity()||null}function rt(t,e){return b?b.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)&&fe({projectId:e,endpoint:n,theme:t.dataset.theme||"auto",position:t.dataset.position||"bottom-right"})}}var Ht={init:fe,destroy:Je,open:Xe,close:Ge,toggle:Ye,sendMessage:Ze,trigger:Ke,onEvent:tt,offEvent:nt,on:rt,identify:st,reset:it,getIdentity:ot,setupTrackedElements:Qe,getTrackedElements:et};return ft(Rt);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pocketping/widget",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "description": "Embeddable chat widget for PocketPing",
6
6
  "main": "dist/index.cjs",
@@ -54,18 +54,11 @@
54
54
  },
55
55
  "release": {
56
56
  "extends": "semantic-release-monorepo",
57
- "branches": [
58
- "main"
59
- ],
57
+ "branches": ["main"],
60
58
  "plugins": [
61
59
  "@semantic-release/commit-analyzer",
62
60
  "@semantic-release/release-notes-generator",
63
- [
64
- "@semantic-release/exec",
65
- {
66
- "prepareCmd": "npm pkg set version=${nextRelease.version}"
67
- }
68
- ],
61
+ ["@semantic-release/exec", {"prepareCmd": "npm pkg set version=${nextRelease.version}"}],
69
62
  "@semantic-release/github"
70
63
  ]
71
64
  }