@customerio/cdp-analytics-browser 0.4.1 → 0.4.3
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/cjs/generated/version.js +1 -1
- package/dist/cjs/plugins/in-app-plugin/inbox_messages.js +13 -2
- package/dist/cjs/plugins/in-app-plugin/inbox_messages.js.map +1 -1
- package/dist/pkg/generated/version.js +1 -1
- package/dist/pkg/plugins/in-app-plugin/inbox_messages.js +13 -2
- package/dist/pkg/plugins/in-app-plugin/inbox_messages.js.map +1 -1
- package/dist/types/core/buffer/index.d.ts +1 -1
- package/dist/types/generated/version.d.ts +1 -1
- package/dist/types/plugins/in-app-plugin/inbox_messages.d.ts.map +1 -1
- package/dist/umd/573.js +1 -1
- package/dist/umd/573.js.gz +0 -0
- package/dist/umd/inAppPlugin.js +1 -1
- package/dist/umd/inAppPlugin.js.gz +0 -0
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.gz +0 -0
- package/dist/umd/standalone.js +1 -1
- package/dist/umd/standalone.js.gz +0 -0
- package/package.json +3 -3
- package/src/generated/version.ts +1 -1
- package/src/plugins/in-app-plugin/inbox_messages.ts +14 -1
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createInboxAPI = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var events_1 = require("./events");
|
|
6
|
+
var CIO_TOPIC_PREFIX = '_cio';
|
|
6
7
|
function createInboxMessage(analyticsInstance, gist, gistMessage) {
|
|
7
8
|
var _this = this;
|
|
8
9
|
return {
|
|
@@ -57,7 +58,7 @@ function createInboxMessage(analyticsInstance, gist, gistMessage) {
|
|
|
57
58
|
}
|
|
58
59
|
function getFilteredMessages(gist, topics, messages) {
|
|
59
60
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
60
|
-
var allMessages;
|
|
61
|
+
var allMessages, hasCioTopic;
|
|
61
62
|
return tslib_1.__generator(this, function (_a) {
|
|
62
63
|
switch (_a.label) {
|
|
63
64
|
case 0:
|
|
@@ -75,13 +76,23 @@ function getFilteredMessages(gist, topics, messages) {
|
|
|
75
76
|
return new Date(b.sentAt).getTime() - new Date(a.sentAt).getTime();
|
|
76
77
|
});
|
|
77
78
|
if (topics.length === 0) {
|
|
78
|
-
return [2 /*return*/, allMessages
|
|
79
|
+
return [2 /*return*/, allMessages.filter(function (message) {
|
|
80
|
+
var messageTopics = message.topics;
|
|
81
|
+
if (!messageTopics || messageTopics.length === 0) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return !messageTopics.some(function (topic) { return topic.startsWith(CIO_TOPIC_PREFIX); });
|
|
85
|
+
})];
|
|
79
86
|
}
|
|
87
|
+
hasCioTopic = topics.some(function (topic) { return topic.startsWith(CIO_TOPIC_PREFIX); });
|
|
80
88
|
return [2 /*return*/, allMessages.filter(function (message) {
|
|
81
89
|
var messageTopics = message.topics;
|
|
82
90
|
if (!messageTopics || messageTopics.length === 0) {
|
|
83
91
|
return false;
|
|
84
92
|
}
|
|
93
|
+
if (!hasCioTopic && messageTopics.some(function (topic) { return topic.startsWith(CIO_TOPIC_PREFIX); })) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
85
96
|
return messageTopics.some(function (messageTopic) { return topics.includes(messageTopic); });
|
|
86
97
|
})];
|
|
87
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbox_messages.js","sourceRoot":"","sources":["../../../../src/plugins/in-app-plugin/inbox_messages.ts"],"names":[],"mappings":";;;;AACA,mCAAyC;
|
|
1
|
+
{"version":3,"file":"inbox_messages.js","sourceRoot":"","sources":["../../../../src/plugins/in-app-plugin/inbox_messages.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __awaiter, __generator } from "tslib";
|
|
2
2
|
import { JourneysEvents } from './events';
|
|
3
|
+
var CIO_TOPIC_PREFIX = '_cio';
|
|
3
4
|
function createInboxMessage(analyticsInstance, gist, gistMessage) {
|
|
4
5
|
var _this = this;
|
|
5
6
|
return {
|
|
@@ -54,7 +55,7 @@ function createInboxMessage(analyticsInstance, gist, gistMessage) {
|
|
|
54
55
|
}
|
|
55
56
|
function getFilteredMessages(gist, topics, messages) {
|
|
56
57
|
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var allMessages;
|
|
58
|
+
var allMessages, hasCioTopic;
|
|
58
59
|
return __generator(this, function (_a) {
|
|
59
60
|
switch (_a.label) {
|
|
60
61
|
case 0:
|
|
@@ -72,13 +73,23 @@ function getFilteredMessages(gist, topics, messages) {
|
|
|
72
73
|
return new Date(b.sentAt).getTime() - new Date(a.sentAt).getTime();
|
|
73
74
|
});
|
|
74
75
|
if (topics.length === 0) {
|
|
75
|
-
return [2 /*return*/, allMessages
|
|
76
|
+
return [2 /*return*/, allMessages.filter(function (message) {
|
|
77
|
+
var messageTopics = message.topics;
|
|
78
|
+
if (!messageTopics || messageTopics.length === 0) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return !messageTopics.some(function (topic) { return topic.startsWith(CIO_TOPIC_PREFIX); });
|
|
82
|
+
})];
|
|
76
83
|
}
|
|
84
|
+
hasCioTopic = topics.some(function (topic) { return topic.startsWith(CIO_TOPIC_PREFIX); });
|
|
77
85
|
return [2 /*return*/, allMessages.filter(function (message) {
|
|
78
86
|
var messageTopics = message.topics;
|
|
79
87
|
if (!messageTopics || messageTopics.length === 0) {
|
|
80
88
|
return false;
|
|
81
89
|
}
|
|
90
|
+
if (!hasCioTopic && messageTopics.some(function (topic) { return topic.startsWith(CIO_TOPIC_PREFIX); })) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
82
93
|
return messageTopics.some(function (messageTopic) { return topics.includes(messageTopic); });
|
|
83
94
|
})];
|
|
84
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbox_messages.js","sourceRoot":"","sources":["../../../../src/plugins/in-app-plugin/inbox_messages.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"inbox_messages.js","sourceRoot":"","sources":["../../../../src/plugins/in-app-plugin/inbox_messages.ts"],"names":[],"mappings":"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"}
|
|
@@ -76,7 +76,7 @@ export declare class AnalyticsBuffered implements PromiseLike<[Analytics, Contex
|
|
|
76
76
|
deregister: (...args: string[]) => Promise<Context>;
|
|
77
77
|
user: () => Promise<import("../user").User>;
|
|
78
78
|
inbox(...topics: string[]): import('../../plugins/in-app-plugin').InboxAPI;
|
|
79
|
-
readonly VERSION = "0.4.
|
|
79
|
+
readonly VERSION = "0.4.3";
|
|
80
80
|
private _createMethod;
|
|
81
81
|
/**
|
|
82
82
|
* These are for methods that where determining when the method gets "flushed" is not important.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.4.
|
|
1
|
+
export declare const version = "0.4.3";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbox_messages.d.ts","sourceRoot":"","sources":["../../../../src/plugins/in-app-plugin/inbox_messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"inbox_messages.d.ts","sourceRoot":"","sources":["../../../../src/plugins/in-app-plugin/inbox_messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAKhD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,YAAY;IAE3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAG1B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IAGxB,QAAQ,CAAC,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;IAG3C,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;IAGrB,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAA;IAGzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAGrB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAA;IAEzB;;;OAGG;IACH,UAAU,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAE1C;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3B;;;OAGG;IACH,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAE7B;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7B;AAED,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IAExB;;;OAGG;IACH,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IAEhC;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;IAEnC;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;CACpE;AA+ED,wBAAgB,cAAc,CAAC,iBAAiB,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CA0ClG"}
|
package/dist/umd/573.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_customerio_cdp_analytics_browser=self.webpackChunk_customerio_cdp_analytics_browser||[]).push([[573],{7573:function(e){var t;t=()=>(()=>{"use strict";var e={d:(t,n)=>{for(var s in n)e.o(n,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:n[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>Ot});class n{constructor(){this.callbacks={}}on(e,t){const n=this.callbacks[e];n?n.push(t):this.callbacks[e]=[t]}off(e,t){const n=this.callbacks[e];if(!n)return;if(!t)return void delete this.callbacks[e];const s=n.indexOf(t);-1!==s&&n.splice(s,1),0===n.length&&delete this.callbacks[e]}dispatch(e,t){const n=this.callbacks[e];n&&n.forEach((e=>e(t)))}}function s(e){Ot.config&&Ot.config.logging&&console.log(`Gist: ${e}`)}const i="gist.web.isPersistingSession";function o(e,t,n=null){let s=n;s||(s=new Date,s.setDate(s.getDate()+365));const i={value:t,expiry:s};c().setItem(e,JSON.stringify(i))}function a(e){return d(e)}function r(e){c().removeItem(e)}function l(){const e=sessionStorage.getItem(i);return null===e?(sessionStorage.setItem(i,"true"),!0):"true"===e}function c(){return l()?localStorage:sessionStorage}function d(e){if(!e)return null;try{const t=c().getItem(e);if(!t)return null;const n=JSON.parse(t);if(!n.expiry)return n.value;const s=new Date,i=new Date(n.expiry),o=e.startsWith("gist.web.message.broadcasts")&&!e.endsWith("shouldShow")&&!e.endsWith("numberOfTimesShown")||e.startsWith("gist.web.message.user")&&!e.endsWith("seen")&&!e.endsWith("state"),a=new Date(s.getTime()+366e4);return o&&i.getTime()>a.getTime()||s.getTime()>i.getTime()?(r(e),null):n.value}catch(t){s(`Error checking key ${e} for expiry: ${t}`)}return null}var u,p=new Uint8Array(16);function g(){if(!u&&!(u="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return u(p)}const m=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var f=[],h=0;h<256;++h)f.push((h+256).toString(16).substr(1));const y=function(e,t,n){var s=(e=e||{}).random||(e.rng||g)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=s[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(f[e[t+0]]+f[e[t+1]]+f[e[t+2]]+f[e[t+3]]+"-"+f[e[t+4]]+f[e[t+5]]+"-"+f[e[t+6]]+f[e[t+7]]+"-"+f[e[t+8]]+f[e[t+9]]+"-"+f[e[t+10]]+f[e[t+11]]+f[e[t+12]]+f[e[t+13]]+f[e[t+14]]+f[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&m.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n}(s)},b="gist.web.userQueueUseSSE",w="gist.web.activeSSEConnection";let v,x=30;const S={RENDERER_HOST:"https://code.gist.build",ENGINE_API_ENDPOINT:{prod:"https://engine.api.gist.build",dev:"https://engine.api.dev.gist.build",local:"http://engine.api.local.gist.build:82"},GIST_QUEUE_API_ENDPOINT:{prod:"https://consumer.cloud.gist.build",dev:"https://consumer.cloud.dev.gist.build",local:"http://api.local.gist.build:86"},GIST_QUEUE_REALTIME_API_ENDPOINT:{prod:"https://realtime.cloud.gist.build",dev:"https://realtime.cloud.dev.gist.build",local:"http://api.local.gist.build:3000"},GIST_VIEW_ENDPOINT:{prod:"https://renderer.gist.build/3.0",dev:"https://renderer.gist.build/3.0",local:"http://app.local.gist.build:8080/web"},getSdkId:()=>(v||(v=y()),v),useSSE:()=>a(b)??!1,setUseSSEFlag(e){o(b,e,new Date((new Date).getTime()+6e4)),s(`Set user uses SSE to "${e}"`)},removeActiveSSEConnection(){r(w)},setActiveSSEConnection(){o(w,S.getSdkId(),new Date((new Date).getTime()+S.getSSEHeartbeat()))},hasActiveSSEConnection:()=>a(w)??!1,isSSEConnectionManagedBySDK:()=>a(w)===S.getSdkId(),getSSEHeartbeat:()=>1e3*(x+5),setSSEHeartbeat(e){e&&e>0&&(x=e)}};function I(e){return null!==e&&"object"==typeof e&&"response"in e}function E(e){return I(e)?e.response:void 0}function C(){const e=S.GIST_QUEUE_API_ENDPOINT[Ot.config.env??"prod"],t={"X-CIO-Site-Id":Ot.config.siteId,"X-CIO-Client-Platform":"web"},n=z();async function s(n,s={}){const i=e+n,o=new AbortController,a=setTimeout((()=>o.abort()),5e3);try{const e=await fetch(i,{method:s.method||"GET",headers:{...t,...s.headers||{}},body:s.method&&"GET"!==s.method.toUpperCase()?s.body:void 0,signal:o.signal});clearTimeout(a);const n=e.headers.get("content-type")?.includes("application/json"),r=n?await e.json():await e.text(),l=Object.fromEntries(e.headers.entries());if(e.status<200||e.status>=400)throw function(e){return Object.assign(new Error,{response:e})}({status:e.status,data:r,headers:l});return{status:e.status,headers:l,data:r}}catch(e){if(clearTimeout(a),I(e))throw e;if(e instanceof Error)throw Object.assign(e,{response:{status:0,data:e.message||"Unknown error",headers:{}}});throw e}}return null!=n&&(t["X-Gist-Encoded-User-Token"]=n),s.post=(e,t={},n={})=>s(e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...n.headers||{}}}),s}const k="gist.web.userLocale";function $(){const e=a(k);return null!==e?e:navigator.language}let P=600,T=!1;const L="gist.web.userQueueNextPullCheck",N="gist.web.sessionId";function M(){let e=a(N);return e||(e=y()),o(N,e,new Date((new Date).getTime()+18e5)),String(e)}const D="gist.web.userToken",q="gist.web.usingGuestUserToken",R="gist.web.guestUserToken";function A(){return null!==a(q)}function W(){return a(D)}function O(){if(null===W()){let e=a(R);null==e&&(e=y(),o(R,e),s(`Set guest user token "${e}" with expiry date set to 1 year from today`)),o(D,e),o(q,!0),s(`Using anonymous session with token: "${e}"`)}}async function U(){const e=W();return null===e?null:await async function(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map((e=>e.toString(16).padStart(2,"0"))).join("")}(e)}function z(){const e=W();return null===e?null:btoa(e)}async function _(e){try{return await C().post(`/api/v1/logs/queue/${e}`)}catch(e){return E(e)}}const F={isEmbedded:!1,elementId:"",hasRouteRule:!1,routeRule:"",position:"",hasPosition:!1,tooltipPosition:"",hasTooltipPosition:!1,tooltipArrowColor:"#fff",shouldScale:!1,campaignId:null,messageWidth:414,overlayColor:"#00000033",persistent:!1,exitClick:!1,hasCustomWidth:!1};function j(e){const t=F,n=e?.properties?.gist;return n?{isEmbedded:!!n.elementId,elementId:n.elementId||"",hasRouteRule:!!n.routeRuleWeb,routeRule:n.routeRuleWeb||"",position:n.position||"",hasPosition:!!n.position,tooltipPosition:n.tooltipPosition||"",hasTooltipPosition:!!n.tooltipPosition,tooltipArrowColor:n.tooltipArrowColor||t.tooltipArrowColor,shouldScale:!!n.scale,campaignId:n.campaignId??null,messageWidth:null!=n.messageWidth&&n.messageWidth>0?n.messageWidth:t.messageWidth,hasCustomWidth:(n.messageWidth??0)>0,overlayColor:n.overlayColor||t.overlayColor,persistent:!!n.persistent,exitClick:!!n.exitClick}:t}const B=["x-gist-top","x-gist-floating-top","x-gist-bottom","x-gist-floating-bottom","x-gist-floating-bottom-left","x-gist-floating-bottom-right","x-gist-floating-top-left","x-gist-floating-top-right"];function H(e){if(document.getElementById(e))return;const t=document.createElement("div");t.id=e,"x-gist-top"===e?document.body.insertBefore(t,document.body.firstChild):document.body.insertAdjacentElement("beforeend",t),s("Top & bottom elements injected into page")}const G=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function V(e){return Ot.currentMessages.find((t=>t.instanceId===e))}function J(e){return!!e&&Ot.currentMessages.some((t=>t.queueId===e))}function X(e){return e?Ot.currentMessages.find((t=>t.elementId===e))??null:null}function Q(e){Ot.currentMessages=Ot.currentMessages.filter((t=>t.instanceId!==e))}function K(e,t){Q(e),Ot.currentMessages.push(t)}function Y(e){const t={topLeft:"x-gist-floating-top-left",topCenter:"x-gist-floating-top",topRight:"x-gist-floating-top-right",bottomLeft:"x-gist-floating-bottom-left",bottomCenter:"x-gist-floating-bottom",bottomRight:"x-gist-floating-bottom-right"};return e&&t[e]?t[e]:(s(`Invalid overlay position "${e}", defaulting to "topCenter"`),t.topCenter)}function Z(e,t){const n=(s=e).tooltipPosition?"tooltip":s.overlay?"modal":s.elementId&&B.includes(s.elementId)?"overlay":s.elementId?"inline":"modal";var s;const i=t.displayType;if(void 0===i)return!1;if(n!==i)return!0;const o=j(e);switch(i){case"modal":{if((e.position||"center")!==(t.modalPosition||"center"))return!0;const n=t.dismissOutsideClick??F.exitClick;if(o.exitClick!==n)return!0;const s=t.overlayColor??F.overlayColor;if(o.overlayColor!==s)return!0;break}case"overlay":{const n=Y(t.overlayPosition);if(e.elementId!==n)return!0;break}case"inline":if(e.elementId!==t.elementSelector)return!0;break;case"tooltip":if(e.tooltipPosition!==t.tooltipPosition)return!0;if(e.elementId!==t.elementSelector)return!0}if("overlay"!==i||!G.includes(Y(t.overlayPosition))){const e=t.maxWidth??F.messageWidth;if(o.messageWidth!==e)return!0}return!1}function ee(e,t){if(e.properties||(e.properties={}),e.properties.gist||(e.properties.gist={}),"modal"===t.displayType)e.overlay=!0,e.elementId=null,e.properties.gist.elementId=null,e.position=t.modalPosition||"center",e.properties.gist.position=t.modalPosition||"center",e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0;else if("overlay"===t.displayType){e.overlay=!1;const n=Y(t.overlayPosition);e.elementId=n,e.properties.gist.elementId=n,e.position=null,e.properties.gist.position=null,e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0}else"inline"===t.displayType?(e.overlay=!1,e.elementId=t.elementSelector,e.properties.gist.elementId=t.elementSelector,e.position=null,e.properties.gist.position=null,e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0):"tooltip"===t.displayType&&(e.overlay=!1,e.elementId=t.elementSelector,e.properties.gist.elementId=t.elementSelector,e.tooltipPosition=t.tooltipPosition,e.properties.gist.tooltipPosition=t.tooltipPosition,e.position=null,e.properties.gist.position=null);e.elementId&&G.includes(e.elementId)?delete e.properties.gist.messageWidth:void 0!==t.maxWidth&&t.maxWidth>0?e.properties.gist.messageWidth=t.maxWidth:delete e.properties.gist.messageWidth,void 0!==t.overlayColor?e.properties.gist.overlayColor=t.overlayColor:delete e.properties.gist.overlayColor,void 0!==t.dismissOutsideClick?e.properties.gist.exitClick=t.dismissOutsideClick:delete e.properties.gist.exitClick}function te(e){const t=de(e);t&&(t.classList.remove("gist-visible"),Array.from(t.classList).filter((e=>e.startsWith("gist-"))).forEach((e=>t.classList.remove(e))),t.style.removeProperty("height"),t.style.removeProperty("width"),t.innerHTML="")}function ne(e){const t=de(e);if(t)return!(!t.style||!t.style.height||"0px"===t.style.height)}function se(e,t,n=null){const s=document.getElementById(e);s&&(s.onload=()=>{!function(e,t,n=null){const s=document.getElementById(e);if(s?.contentWindow){const e={options:t,capabilities:ie};n&&(t.stepId=n),s.contentWindow.postMessage(e,"*")}}(e,t,n)})}const ie=["MultiStepDisplayTypes"];function oe(e){if(!e.displaySettings)return;const t=le(e.instanceId??""),n=document.getElementById(t);n?.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:e.displaySettings},"*")}async function ae(){const e=document.querySelector(".gist-message");e&&(e.classList.remove("gist-visible"),await new Promise((e=>setTimeout(e,300)))),re()}function re(){const e=document.querySelector("#gist-embed-message");e&&e.parentNode?.removeChild(e)}function le(e){return`gist-${e}`}function ce(){const e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}function de(e){try{return(document.getElementById(e)??document.querySelector(e))||null}catch{return null}}new Map;const ue="gist.web.customAttributes";let pe=new Map;function ge(){const e=Array.from(pe.entries()),t=new Date;t.setDate(t.getDate()+30),o(ue,e,t),s(`Saved ${pe.size} custom attributes to storage with TTL of 30 days`)}async function me(e){const t=await be();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),o(t,e.filter(he),n)}async function fe(e,t){return a(e)?.find((e=>e.queueId===t))}function he(e){return!(!e.properties?.gist||!e.properties.gist.broadcast)}function ye(e){if(!he(e))return!1;const t=e.properties.gist.broadcast;return 0===t.frequency.delay&&0===t.frequency.count}async function be(){const e=await U();return e?`gist.web.message.broadcasts.${e}`:null}function we(e,t){return`${e}.${t}.numberOfTimesShown`}function ve(e,t){return`${e}.${t}.shouldShow`}!function(){const e=a(ue);if(e)try{pe=new Map(e)}catch{pe=new Map}else pe=new Map}();const xe="gist.web.message.user";async function Se(e){const t=await Ie();if(!t)return;const n=e.filter((e=>!(e.properties&&e.properties.gist&&e.properties.gist.broadcast))),s=new Date;s.setMinutes(s.getMinutes()+60),o(t,n,s)}async function Ie(){const e=await U();return e?`${xe}.${e}`:null}async function Ee(){const e=await U();return e?`${xe}.${e}.seen`:null}async function Ce(e){const t=await U();return t?`${xe}.${t}.message.${e}.loading`:null}async function ke(e){const t=await U();return t?`${xe}.${t}.message.${e}.state`:null}async function $e(e){const t=await ke(e);t&&(r(t),s(`Cleared message state for queueId: ${e}`))}function Pe(e){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.54223 5.33301L7.7089 9.33301L11.8756 5.33301L12.6121 6.04011L7.7089 10.7472L2.80566 6.04011L3.54223 5.33301Z" fill="${e}"/></svg>`}const Te=`\n #gist-preview-bar {\n position: fixed; bottom: 0; left: 0; right: 0;\n z-index: 99999999999;\n font-family: system-ui, -apple-system, sans-serif;\n pointer-events: none;\n }\n .gist-pb-toggle-row {\n display: flex; justify-content: center;\n padding: 6px 16px;\n border-bottom: 1px solid #e5e7eb;\n }\n .gist-pb-toggle-row--collapsed { border-bottom: none; }\n .gist-pb-toggle-btn {\n background: #08272B; border: none;\n padding: 4px 14px;\n border-radius: 100px;\n font-size: 12px; font-weight: 500;\n font-family: system-ui, -apple-system, sans-serif;\n color: white; cursor: pointer;\n display: flex; align-items: center; gap: 6px;\n pointer-events: auto;\n }\n .gist-pb-controls-row {\n background: #F8F9F9;\n box-shadow: 1px 2px 2px #34344605, 3px 3px 8px #34344614;\n display: flex; flex-wrap: wrap; align-items: center;\n gap: 12px; padding: 10px 16px 12px;\n pointer-events: auto;\n }\n .gist-pb-label-group { display: flex; flex-direction: column; gap: 4px; }\n .gist-pb-label-group--grow { flex: 1; }\n .gist-pb-label {\n font-size: 10px; font-weight: 600; color: #3F4E50;\n letter-spacing: 0.05em; text-transform: uppercase;\n font-family: system-ui, -apple-system, sans-serif;\n }\n .gist-pb-select {\n height: 32px; padding: 0 32px 0 8px;\n border: 1px solid #d1d5db; border-radius: 6px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n background: white url("data:image/svg+xml,${encodeURIComponent(Pe("#3F4E50"))}") no-repeat right 2px center;\n color: #3F4E50; cursor: pointer; outline: none;\n appearance: none; min-width: 120px;\n }\n .gist-pb-input {\n height: 32px; padding: 0 8px;\n border: 1px solid #d1d5db; border-radius: 6px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; outline: none; box-sizing: border-box;\n }\n .gist-pb-checkbox-row { display: flex; align-items: center; gap: 6px; height: 32px; }\n .gist-pb-checkbox-label {\n font-size: 12px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; cursor: pointer; user-select: none;\n }\n .gist-pb-color-control {\n display: flex; align-items: center;\n border: 1px solid #d1d5db; border-radius: 6px;\n overflow: hidden; height: 32px; background: white;\n }\n .gist-pb-color-swatch {\n width: 28px; height: 100%;\n cursor: pointer; flex-shrink: 0;\n border-right: 1px solid #d1d5db; position: relative;\n }\n .gist-pb-color-input {\n position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;\n }\n .gist-pb-color-hex {\n flex: 1; border: none; outline: none; padding: 0 6px;\n font-size: 13px; font-family: monospace; color: #3F4E50;\n min-width: 0; background: transparent;\n }\n .gist-pb-color-opacity {\n width: 36px; border: none; border-left: 1px solid #d1d5db;\n outline: none; padding: 0 4px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; background: transparent; text-align: right;\n }\n .gist-pb-color-pct {\n font-size: 12px; color: #3F4E50; padding: 0 6px 0 2px;\n font-family: system-ui, -apple-system, sans-serif; flex-shrink: 0;\n }\n .gist-pb-inline-row { display: flex; align-items: center; gap: 6px; }\n .gist-pb-select-elem-btn {\n height: 32px; padding: 0 12px;\n border: none; border-radius: 6px;\n font-size: 12px; font-weight: 500; font-family: system-ui, -apple-system, sans-serif;\n background: #08272B; color: white; cursor: pointer; white-space: nowrap; flex-shrink: 0;\n }\n .gist-pb-spacer { flex: 1; min-width: 0; }\n .gist-pb-save-btn {\n height: 36px; padding: 0 18px;\n background: #08272B; color: white;\n border: none; border-radius: 6px;\n font-size: 13px; font-weight: 600;\n font-family: system-ui, -apple-system, sans-serif;\n cursor: pointer; white-space: nowrap; align-self: center;\n }\n .gist-pb-save-btn:disabled {\n background: #CAD6D8; cursor: not-allowed;\n }\n .gist-pb-picker-overlay {\n position: fixed; inset: 0; z-index: 999999999998; cursor: crosshair;\n }\n .gist-pb-checkbox { cursor: pointer; width: 14px; height: 14px; }\n .gist-pb-pick-highlight { outline: 2px solid #006FF5 !important; }\n .gist-pb-pick-error { outline: 2px solid #941616 !important; }\n #gist-preview-bar.gist-pb-hidden { display: none; }\n .gist-pb-ended-row {\n justify-content: center; align-items: center; gap: 10px; padding: 12px 16px;\n flex-wrap: nowrap;\n }\n .gist-pb-ended-icon {\n display: flex; align-items: center; justify-content: center;\n width: 22px; height: 22px; border-radius: 50%;\n background: #08272B; color: white;\n font-size: 13px; font-weight: 700; flex-shrink: 0;\n }\n .gist-pb-ended-text {\n margin: 0; font-size: 13px; color: #3F4E50;\n font-family: system-ui, -apple-system, sans-serif;\n min-width: 0;\n }\n .gist-pb-ended-text strong { color: #08272B; }\n @media (max-width: 1024px) {\n .gist-pb-controls-row { gap: 8px; }\n .gist-pb-label-group { flex: 1 1 100%; }\n .gist-pb-label-group--grow { flex: 1 1 100%; }\n .gist-pb-select { width: 100%; min-width: unset; box-sizing: border-box; }\n .gist-pb-input { width: 100% !important; box-sizing: border-box; }\n .gist-pb-color-control { width: 100%; }\n .gist-pb-checkbox-row { width: 100%; }\n .gist-pb-inline-row { flex-direction: row; align-items: center; }\n .gist-pb-inline-row .gist-pb-input { flex: 1; min-width: 0; }\n .gist-pb-save-btn { width: 100%; box-sizing: border-box; }\n .gist-pb-label--spacer { display: none; }\n }\n`,Le="cioPreviewId",Ne="cioPreviewSettings",Me="gist.previewBar.collapsed",De="gist-pb-styles",qe="gist-preview-bar",Re={topLeft:"Top Left",topCenter:"Top Center",topRight:"Top Right",bottomLeft:"Bottom Left",bottomCenter:"Bottom Center",bottomRight:"Bottom Right"};let Ae=null,We=[],Oe={},Ue=null,ze=!1,_e=!1,Fe=5,je=null,Be=!1,He=null,Ge=null,Ve=null;const Je=new Map;function Xe(e,t={}){const n=document.createElement(e);for(const[e,s]of Object.entries(t))n[e]=s;return n}function Qe(e,t){const n=Xe("div",{className:"gist-pb-label-group"});return n.appendChild(Xe("span",{className:"gist-pb-label",textContent:e})),n.appendChild(t),n}function Ke(e,t){const n=Xe("select",{className:"gist-pb-select"});for(const s of e){const e=Xe("option",{value:s.value,textContent:s.label});s.value===t&&(e.selected=!0),n.appendChild(e)}return n}function Ye(e,t,n){const s=Xe("input",{className:"gist-pb-input",type:e,value:String(t)});return n&&(s.style.width=n),s}function Ze(e,t){const n=Math.round(Math.min(100,Math.max(0,t))/100*255);return"#"+e.replace("#","").toUpperCase()+n.toString(16).padStart(2,"0").toUpperCase()}function et(e){return!!("inline"!==e.displayType&&"tooltip"!==e.displayType||e.elementSelector?.trim())}function tt(e){if("overlay"===e.displayType&&G.includes(Y(e.overlayPosition))){const{maxWidth:t,...n}=e;e=n}if(Oe=e,Ue){const t=We.findIndex((e=>e.stepName===Ue));-1!==t&&(We[t]={...We[t],displaySettings:{...e}})}if(!Ae)return;const t=Ot.currentMessages.find((e=>e.instanceId===Ae));t&&et(e)&&(oe(t),Z(t,e)&&It(t,Ue,e)),function(){const e=new URLSearchParams(window.location.search).get(Le);e&&async function(e,t){try{return await C()(`/api/v1/preview/${e}`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return E(e)}}(e,We).then((e=>{e&&404===e.status&&Ae&&Ot.dismissMessage(Ae)})).catch((()=>s("Failed to persist preview display settings")))}()}function nt(e){if(!e)return null;try{return document.getElementById(e)??document.querySelector(e)}catch{return null}}function st(e){if(!e||Je.has(e))return;const t=nt(e);t&&Je.set(e,t.innerHTML)}function it(e){const t=Je.get(e);if(void 0===t)return;const n=nt(e);n&&(n.innerHTML=t)}function ot(e){if(Be)return;Be=!0;const t={...Oe},n=Ot.currentMessages.find((e=>e.instanceId===Ae))??null;n&&St(n),Oe.elementSelector&&it(Oe.elementSelector);const i=Xe("div",{className:"gist-pb-picker-overlay"});let o=null;const a=e=>{i.style.pointerEvents="none";const t=document.elementFromPoint(e.clientX,e.clientY);i.style.pointerEvents="all",t&&t!==o&&t!==i&&(o?.classList.remove("gist-pb-pick-highlight"),o=t,o.classList.add("gist-pb-pick-highlight"))},r=e=>{if("Escape"===e.key){if(c(),Oe=t,Ue){const e=We.findIndex((e=>e.stepName===Ue));-1!==e&&(We[e]={...We[e],displaySettings:{...t}})}n&&et(t)&&It(n,Ue,t),at()}},l=t=>{t.preventDefault(),t.stopPropagation(),i.style.pointerEvents="none";const o=document.elementFromPoint(t.clientX,t.clientY);if(i.style.pointerEvents="all",o&&o!==i){o.classList.remove("gist-pb-pick-highlight");const t=document.getElementById(qe)?.contains(o)?null:function(e){if(e.id){const t=CSS.escape(e.id);if(1===document.querySelectorAll(`#${t}`).length)return e.id}const t=[];let n=e;for(;n&&"BODY"!==n.tagName&&"HTML"!==n.tagName;){if(n.id){const e=CSS.escape(n.id);if(1===document.querySelectorAll(`#${e}`).length){t.unshift(`#${e}`);break}}let e=n.tagName.toLowerCase();n.className&&"string"==typeof n.className&&(e+=n.className.trim().split(/\s+/).filter(Boolean).map((e=>`.${CSS.escape(e)}`)).join(""));const s=n.parentElement;s&&(e+=`:nth-of-type(${Array.from(s.children).filter((e=>e.tagName===n.tagName)).indexOf(n)+1})`),t.unshift(e);try{if(1===document.querySelectorAll(t.join(" > ")).length)break}catch{}n=n.parentElement}const i=t.join(" > ");try{if(1!==document.querySelectorAll(i).length)return s("buildUniqueSelector: could not produce a unique selector for element"),null}catch{return null}return i}(o);if(null===t)return o.classList.add("gist-pb-pick-error"),void setTimeout((()=>{o.classList.remove("gist-pb-pick-error"),o.classList.add("gist-pb-pick-highlight")}),800);e.value=t,st(t);const i=Oe.elementSelector,a={...Oe,elementSelector:t},r=null!=n&&et(a)&&Z(n,a);tt(a),i&&i!==t&&it(i),n&&!r&&It(n,Ue,a)}c()},c=()=>{o?.classList.remove("gist-pb-pick-highlight"),i.removeEventListener("mousemove",a),i.removeEventListener("click",l),document.removeEventListener("keydown",r),document.body.removeChild(i),Be=!1,He=null};He=c,i.addEventListener("mousemove",a),i.addEventListener("click",l),document.addEventListener("keydown",r),document.body.appendChild(i)}function at(){const e=document.getElementById(qe);if(!e)return;if(e.classList.toggle("gist-pb-hidden",!Ae&&!_e),e.innerHTML="",!Ae){if(_e){const t=Xe("div",{className:"gist-pb-controls-row gist-pb-ended-row"}),n=Xe("span",{className:"gist-pb-ended-icon",textContent:"✓"}),s=Xe("p",{className:"gist-pb-ended-text"});s.innerHTML=`<strong>Preview session ended.</strong> Close this tab and navigate back to the message editor. Refreshing in ${Fe}s…`,t.appendChild(n),t.appendChild(s),e.appendChild(t)}return}const t=Xe("div",{className:"gist-pb-toggle-row"+(ze?" gist-pb-toggle-row--collapsed":"")}),n=Xe("button",{className:"gist-pb-toggle-btn"}),s=ze?"transform:rotate(180deg);display:inline-flex;":"display:inline-flex;";if(n.innerHTML=`${ze?"Expand":"Collapse"}<span style="${s}">${Pe("white")}</span>`,n.addEventListener("click",rt),t.appendChild(n),e.appendChild(t),ze)return;const i=Xe("div",{className:"gist-pb-controls-row"});if(We.length>0){const e=Ue??We[0].stepName,t=Ke(We.map((e=>({value:e.stepName,label:e.stepName}))),e);t.addEventListener("change",(()=>{const e=We.find((e=>e.stepName===t.value));if(e){Ue=e.stepName,Oe={...e.displaySettings};const t=Ot.currentMessages.find((e=>e.instanceId===Ae));t&&et(e.displaySettings)&&It(t,e.stepName,e.displaySettings),at()}})),i.appendChild(Qe("Step",t))}const o=Ke([{value:"modal",label:"Modal"},{value:"overlay",label:"Overlay"},{value:"inline",label:"Inline"}],Oe.displayType||"modal");o.addEventListener("change",(()=>{const e=o.value,t=Oe.displayType,n=Oe.elementSelector,s={...Oe,displayType:e};"modal"===e?(s.modalPosition=s.modalPosition||"center",s.maxWidth=s.maxWidth??414,delete s.overlayPosition,delete s.elementSelector):"overlay"===e?(s.overlayPosition=s.overlayPosition||"topCenter",s.maxWidth=s.maxWidth??414,delete s.modalPosition,delete s.elementSelector):"inline"===e&&(delete s.modalPosition,delete s.overlayPosition),Oe=s,tt(Oe),"inline"!==t&&"tooltip"!==t||!n||"inline"===e||"tooltip"===e||it(n),at()})),i.appendChild(Qe("Display Type",o));const a=Oe.displayType||"modal";"modal"===a?function(e,t){const n=Ke([{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}],e.modalPosition||"center");n.addEventListener("change",(()=>tt({...Oe,modalPosition:n.value}))),t.appendChild(Qe("Position",n));const s=Ye("number",e.maxWidth??414,"80px");s.addEventListener("change",(()=>tt({...Oe,maxWidth:parseInt(s.value)||414}))),t.appendChild(Qe("Max Width",s)),t.appendChild(function(e){const{color:t,opacity:n}=function(e){const t=e.replace("#","");return 8===t.length?{color:"#"+t.slice(0,6).toUpperCase(),opacity:Math.round(parseInt(t.slice(6),16)/255*100)}:6===t.length?{color:"#"+t.toUpperCase(),opacity:100}:{color:"#000000",opacity:20}}(e.overlayColor||"#00000033"),s=Xe("div",{className:"gist-pb-color-control"}),i=Xe("input",{className:"gist-pb-color-input",type:"color",value:t}),o=Xe("div",{className:"gist-pb-color-swatch"});o.style.background=t,o.appendChild(i),o.addEventListener("click",(()=>i.click()));const a=Xe("input",{className:"gist-pb-color-hex",type:"text",maxLength:6,value:t.replace("#","")}),r=Xe("input",{className:"gist-pb-color-opacity",type:"number",min:"0",max:"100",value:String(n)}),l=Xe("span",{className:"gist-pb-color-pct",textContent:"%"}),c=()=>{const e="#"+a.value.replace("#",""),t=parseInt(r.value)||0;o.style.background=e,i.value=e,tt({...Oe,overlayColor:Ze(e,t)})};return i.addEventListener("input",(()=>{a.value=i.value.replace("#","").toUpperCase(),o.style.background=i.value})),i.addEventListener("change",c),a.addEventListener("change",c),r.addEventListener("change",c),s.appendChild(o),s.appendChild(a),s.appendChild(r),s.appendChild(l),Qe("Overlay Color",s)}(e));const i=Xe("div",{className:"gist-pb-checkbox-row"}),o=Xe("input",{className:"gist-pb-checkbox",type:"checkbox"});o.checked=e.dismissOutsideClick??!1;const a=Xe("label",{className:"gist-pb-checkbox-label",textContent:"Dismiss on click outside"});o.addEventListener("change",(()=>tt({...Oe,dismissOutsideClick:o.checked}))),a.addEventListener("click",(()=>{o.checked=!o.checked,tt({...Oe,dismissOutsideClick:o.checked})})),i.appendChild(o),i.appendChild(a);const r=Qe(" ",i);r.classList.add("gist-pb-label-group--grow"),r.firstChild.classList.add("gist-pb-label--spacer"),t.appendChild(r)}(Oe,i):"overlay"===a?function(e,t){const n=Ke(Object.entries(Re).map((([e,t])=>({value:e,label:t}))),e.overlayPosition||"topCenter");if(n.addEventListener("change",(()=>tt({...Oe,overlayPosition:n.value}))),t.appendChild(Qe("Position",n)),!G.includes(Y(e.overlayPosition))){const n=Ye("number",e.maxWidth??414,"80px");n.addEventListener("change",(()=>tt({...Oe,maxWidth:parseInt(n.value)||414}))),t.appendChild(Qe("Max Width",n))}}(Oe,i):"inline"===a&&function(e,t){const n=Ye("text",e.elementSelector||"","260px");n.placeholder="Element ID or selector",n.addEventListener("change",(()=>{const e=n.value.trim(),t=Oe.elementSelector;e&&st(e),tt({...Oe,elementSelector:e}),t&&t!==e&&it(t)}));const s=Xe("button",{className:"gist-pb-select-elem-btn",textContent:"Select Element"});s.addEventListener("click",(()=>ot(n)));const i=Xe("div",{className:"gist-pb-inline-row"});i.appendChild(n),i.appendChild(s),t.appendChild(Qe("Element Selector",i))}(Oe,i),i.appendChild(Xe("div",{className:"gist-pb-spacer"}));const r=Xe("button",{className:"gist-pb-save-btn",textContent:"End session"});r.addEventListener("click",(async()=>{Ae&&await Ot.dismissMessage(Ae)})),i.appendChild(r),e.appendChild(i)}function rt(){ze=!ze;try{sessionStorage.setItem(Me,String(ze))}catch{}at()}function lt(){(function(){for(const e of Je.keys())it(e);Je.clear()})(),Ae=null,We=[],Oe={},Ue=null,_e=!0,Fe=5;const e=new URLSearchParams(window.location.search).get(Le);e&&async function(e){try{return await C()(`/api/v1/preview/${e}`,{method:"DELETE"})}catch(e){return E(e)}}(e).catch((()=>s("Failed to delete preview session"))),at(),je&&clearInterval(je),je=setInterval((()=>{Fe-=1,Fe<=0?(clearInterval(je),je=null,window.location.reload()):at()}),1e3)}async function ct(e){if(Ot.isDocumentVisible){if(J(e.queueId))return s(`Message with queueId ${e.queueId} is already showing.`),null;if(Ot.overlayInstanceId)return s(`Message ${Ot.overlayInstanceId} already showing.`),null;{const t=j(e);return e.instanceId=y(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),Ot.overlayInstanceId=e.instanceId,Ot.currentMessages.push(e),yt(e,null,e.savedStepName||null)}}return s("Document hidden, not showing message now."),null}function dt(e,t){return Ot.isDocumentVisible?J(e.queueId)?(s(`Message with queueId ${e.queueId} is already showing.`),null):X(t)?(s(`Message with elementId ${t} already has a message.`),null):(e.instanceId=y(),e.overlay=!1,e.firstLoad=!0,e.shouldScale=!1,e.elementId=t,e.shouldResizeHeight=!ne(t),e.renderStartTime=(new Date).getTime(),Ot.currentMessages.push(e),yt(e,t,e.savedStepName||null)):(s("Document hidden, not showing message now."),null)}async function ut(e){e?(Ot.messageDismissed(e),await pt(e)):s("Message not found")}async function pt(e){e.overlay?await ft(!0,e):mt(e)}async function gt(e){e?j(e).persistent&&(s("Persistent message dismissed, logging view"),await Et(e),await bt(e),await $e(e.queueId??"")):s("Message not found")}function mt(e){e.instanceId&&Q(e.instanceId),e.elementId&&te(e.elementId),Ot.config.isPreviewSession&&(lt(),ht())}async function ft(e,t){e?await ae():re(),0===Ot.currentMessages.length&&(window.removeEventListener("message",vt),window.removeEventListener("touchstart",wt)),t.instanceId&&Q(t.instanceId),Ot.overlayInstanceId=null,Ot.config.isPreviewSession&&(lt(),ht())}function ht(){const e=new URL(window.location.href);e.searchParams.delete(Le),e.searchParams.delete(Ne),history.replaceState(null,"",e.toString())}function yt(e,t=null,n=null){const i=Ot.config.env,o={endpoint:S.ENGINE_API_ENDPOINT[i],siteId:Ot.config.siteId,dataCenter:Ot.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId??"",livePreview:!1,properties:e.properties,customAttributes:Object.fromEntries(new Map(pe))},a=`${S.GIST_VIEW_ENDPOINT[i]}/index.html`;return window.addEventListener("message",vt),window.addEventListener("touchstart",wt),t?(B.includes(t)&&H(t),function(e,t,n,i,o=null){const a=de(e);if(a){const s=le(n.instanceId??"");a.classList.add(s);const r=j(n);let l=r.messageWidth+"px";G.includes(e)&&!r.hasCustomWidth&&(l="100%"),B.includes(e)&&(a.style.width=l),ne(e)||(a.style.height="0px"),a.innerHTML=function(e,t,n){return function(e,t,n){let s=800;return t.messageWidth>s&&(s=t.messageWidth),`\n <div id="gist-embed">\n <style>\n #x-gist-floating-top, #x-gist-floating-top-left, #x-gist-floating-top-right {\n position: fixed;\n top: 0px;\n z-index: 1000000;\n }\n #x-gist-floating-bottom, #x-gist-floating-bottom-left, #x-gist-floating-bottom-right {\n position: fixed;\n bottom: 0px;\n z-index: 1000000;\n }\n #x-gist-bottom, #x-gist-top, #x-gist-floating-top, #x-gist-floating-bottom {\n left: 50%;\n transform: translate(-50%, 0%);\n }\n #x-gist-floating-top-right, #x-gist-floating-bottom-right {\n right: 0px;\n }\n #gist-embed {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container .gist-frame {\n height: 100%;\n width: 100%;\n border: none;\n }\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${s}px) {\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${e}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(le(t.instanceId??""),n,e)}(t,n,r),se(s,i,o)}else s(`Message could not be embedded, elementId ${e} not found.`)}(t,a,e,o,n)):function(e,t,n,s=null){document.querySelectorAll("#gist-embed-message").forEach((e=>{e.parentNode?.removeChild(e)})),document.body.insertAdjacentHTML("afterbegin",function(e,t){const n=j(t);return function(e,t,n){let s=600;return t.messageWidth>s&&(s=t.messageWidth),`\n <div id="gist-embed-message">\n <style>\n #gist-overlay.gist-background {\n position: fixed;\n z-index: 9999999998;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: ${t.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.gist-background.gist-visible {\n visibility: visible;\n }\n .gist-message {\n width: ${t.messageWidth}px;\n position: absolute;\n border: none;\n opacity: 0;\n transition: opacity 0.3s ease-in-out, height 0.1s ease-in-out;\n z-index: 9999999999;\n left: 50%;\n transform: translateX(-50%);\n }\n .gist-message.gist-visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.gist-center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.gist-bottom {\n bottom: 0;\n }\n .gist-message.gist-top {\n top: 0;\n }\n @media (max-width: ${s}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="gist-background">\n <iframe id="${e}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(le(t.instanceId??""),n,e)}(e,t)),se(le(t.instanceId??""),n,s)}(a,e,o,n),e}async function bt(e){let t;s(`Message shown, logging view for: ${e.messageId}`),null!=e.queueId?(await Et(e),t=await _(e.queueId)):t=await async function(e){try{return await C().post(`/api/v1/logs/message/${e}`)}catch(e){return E(e)}}(e.messageId),s(200===t?.status?"Message view logged":`Problem logging message: ${t?.status}`)}function wt(){}async function vt(e){const t=e.data;if(t.gist&&e.origin===S.RENDERER_HOST){const e=t.gist.instanceId,n=V(e);if(!n)return;const i=j(n);switch(t.gist.method){case"routeLoaded":{const o=.001*((new Date).getTime()-(n.renderStartTime??0));s(`Engine render for message: ${n.messageId} timer elapsed in ${o.toFixed(3)} seconds`),async function(e){const t=await Ce(e);t&&r(t)}(n.queueId??""),n.currentRoute=t.gist.parameters.route,t.gist.parameters.fullDisplaySettings&&!n.displaySettings?n.displaySettings=t.gist.parameters.fullDisplaySettings:n.displaySettings&&(s("SDK already has display settings state, sending it to iframe"),oe(n)),Ot.config.isPreviewSession&&n.properties?.gist?.livePreview&&function(e){_e=!1,Ae=e.instanceId??null;const t=e.displaySettings;if(Array.isArray(t)&&t.length>0?(We=t,Ue||(Ue=We[0].stepName,Oe={...We[0].displaySettings})):t&&"object"==typeof t&&!Array.isArray(t)&&(Oe={...t}),Ge||Ve){const e=!!Ge,t=!!Ve,n=Ge,i=Ve;if(Ge=null,Ve=null,e){const e=We.find((e=>e.stepName===n));if(!e)return s(`Preview bar: step "${n}" not found, ignoring initial step/display override`),void at();Ue=e.stepName,Oe={...e.displaySettings}}if(t){if(!e)return s(`Preview bar: display type "${i}" provided without a step, ignoring`),void at();Oe={...Oe,displayType:i}}at();const o=Ot.currentMessages.find((e=>e.instanceId===Ae));o&&et(Oe)?It(o,Ue,Oe):function(){const e=Oe.displayType;if("inline"!==e&&"tooltip"!==e)return;const t=document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");t&&ot(t)}()}else at()}(n),(n.firstLoad||n.isDisplayChange)&&(n.overlay?function(e){const t=j(e),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");const s=document.querySelector(".gist-message");s&&(e.position?s.classList.add("gist-"+e.position):s.classList.add("gist-center")),setTimeout(ce,100),t.exitClick&&setTimeout((()=>function(e){const t=document.querySelector("#gist-overlay");t&&t.addEventListener("click",(()=>{Ot.dismissMessage(e)}))}(e.instanceId??"")),1e3)}else re()}(n):function(e){const t=de(e);t&&t.classList.add("gist-visible")}(n.elementId),n.firstLoad&&!n.isDisplayChange&&(Ot.messageShown(n),i.persistent?s("Persistent message shown, skipping logging view"):await bt(n)),n.firstLoad=!1,n.isDisplayChange=!1),K(e,n);break}case"tap":{const e=t.gist.parameters.action,s=t.gist.parameters.name;if(Ot.messageAction(n,e,s),t.gist.parameters.system&&!i.persistent){await ut(n);break}try{const t=new URL(e);if(t&&"gist:"===t.protocol)switch(t.href.replace("gist://","").split("?")[0]){case"close":await gt(n),await Ct(n),await ut(n),await qt();break;case"showMessage":{const e=t.searchParams.get("messageId"),n=t.searchParams.get("properties");if(e){const t=n?JSON.parse(atob(n)):void 0;await Ot.showMessage({messageId:e,properties:t})}break}case"loadPage":{const e=t.href.substring(t.href.indexOf("?url=")+5);e&&(e.startsWith("mailto:")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("/")?window.location.href=e:window.location.href=window.location+e);break}}}catch{}break}case"changeMessageStep":{const e=t.gist.parameters.displaySettings,r=t.gist.parameters.messageStepName;Ot.config.isPreviewSession&&r&&n.properties?.gist?.livePreview&&function(e,t){Ue=e;const n=We.find((t=>t.stepName===e));n?Oe={...n.displaySettings}:t&&(Oe={...t}),at()}(r,e),(i.persistent||ye(n))&&await async function(e,t,n){const i=await ke(e);if(!i)return;const r=a(i)||{},l={stepName:void 0!==t?t:r.stepName,displaySettings:void 0!==n?n:r.displaySettings},c=new Date;c.setDate(c.getDate()+30),o(i,l,c),s(`Saved message state for queueId: ${e}`)}(n.queueId??"",r,e),e&&Z(n,e)&&(s("Display settings changed, reloading message"),await St(n),ee(n,e),await xt(n,r??null));break}case"routeChanged":n.currentRoute=t.gist.parameters.route,n.renderStartTime=(new Date).getTime(),K(e,n),s(`Route changed to: ${n.currentRoute}`);break;case"sizeChanged":s(`Size Changed Width: ${t.gist.parameters.width} - Height: ${t.gist.parameters.height}`),n.elementId&&!n.shouldResizeHeight||function(e,t){const n=de(e.elementId?e.elementId:le(e.instanceId??""));if(n){const s=n.style;if(t.height>0)if(t.height>window.innerHeight){const n=1-(t.height/window.innerHeight-1);e.shouldScale&&n>=.4?(s.height=`${t.height}px`,s.transform=`translateX(-50%) translateY(-50%) scale(${n})`):s.height=`${window.innerHeight}px`}else s.height=`${t.height}px`}}(n,t.gist.parameters);break;case"titleChanged":s(`Overlay title changed to: ${t.gist.parameters.title}`),function(e,t){const n=de(le(e));n&&(n.title=t)}(e,t.gist.parameters.title);break;case"eventDispatched":Ot.events.dispatch("eventDispatched",{name:t.gist.parameters.name,payload:t.gist.parameters.payload});break;case"error":case"routeError":Ot.messageError(n),Ot.overlayInstanceId?await ft(!1,n):mt(n)}}}async function xt(e,t){e.isDisplayChange=!0,e.renderStartTime=(new Date).getTime();const n=e.elementId||null;if(n){const t=X(n);t&&t.instanceId!==e.instanceId&&(s(`Dismissing existing message at ${n} to make room for multi-step message`),await ut(t))}if(e.overlay){Ot.overlayInstanceId=e.instanceId??null;const t=j(e);e.shouldScale=t.shouldScale,e.shouldResizeHeight=!0}else Ot.overlayInstanceId=null,e.shouldScale=!1,e.shouldResizeHeight=!ne(n??"");n&&B.includes(n)&&H(n),yt(e,n,t)}async function St(e){e.overlay?await ae():e.elementId&&te(e.elementId)}async function It(e,t,n){n&&Z(e,n)&&(await St(e),ee(e,n)),await xt(e,t??null)}async function Et(e){s(`Logging user message view locally for: ${e.queueId}`),he(e)?await async function(e){s(`Marking broadcast ${e} as seen.`);const t=await be();if(!t)return;const n=await fe(t,e);if(!n)return;const i=n.properties.gist.broadcast,{frequency:r}=i,l=we(t,e),c=ve(t,e),d=a(l)||0;if(o(l,d+1),1===r.count)o(c,!1),s(`Marked broadcast ${e} as seen.`);else{const t=new Date;t.setSeconds(t.getSeconds()+r.delay),o(c,!1,t),s(`Marked broadcast ${e} as seen, broadcast was seen ${d+1} times, next show date is ${t}.`)}}(e.queueId??""):await async function(e){const t=await Ee();if(!t)return;const n=a(t)??[];n.push(e),o(t,n)}(e.queueId??"")}async function Ct(e){he(e)&&(s(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){s(`Marking broadcast ${e} as dismissed.`);const t=await be();if(!t)return;const n=await fe(t,e);n&&(!0!==n.properties.gist.broadcast.frequency.ignoreDismiss?(o(ve(t,e),!1),s(`Marked broadcast ${e} as dismissed and will not show again.`)):s(`Broadcast ${e} is set to ignore dismiss.`))}(e.queueId??""),await $e(e.queueId??""))}const kt="messageInboxUpdated";async function $t(e){const t=await Tt();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),o(t,e,n),Ot.events.dispatch(kt,e)}async function Pt(){const e=await Tt();if(!e)return[];const t=a(e)??[],n=new Date;return t.filter((e=>!e.expiry||new Date(e.expiry)>n))}async function Tt(){const e=await U();return e?`gist.web.inbox.messages.${e}`:null}const Lt=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>Lt(e,t))));let Nt=!1,Mt=null;async function Dt(){Nt?await qt():W()?(s("Queue watcher started"),Nt=!0,Lt((()=>new Promise((()=>{!async function(){if(S.hasActiveSSEConnection())return!S.isSSEConnectionManagedBySDK()&&Mt&&(s("Not the main instance, closing our SSE connection."),Wt()),void await qt();Mt&&(s("SSE connection not active, closing it."),Wt()),!S.useSSE()||A()?await At():await async function(){Wt();const e=function(){const e=z();return null===e?(s("No user token available for SSE endpoint."),null):S.GIST_QUEUE_REALTIME_API_ENDPOINT[Ot.config.env??"prod"]+`/api/v3/sse?userToken=${e}&siteId=${Ot.config.siteId}&sessionId=${M()}`}();if(null===e)return s("SSE endpoint not available, falling back to polling."),void await At();s(`Starting SSE queue listener on ${e}`),Mt=new EventSource(e),S.setActiveSSEConnection(),Mt.addEventListener("connected",(async e=>{try{s("SSE connection received"),S.setUseSSEFlag(!0);const t=JSON.parse(e.data);t.heartbeat&&(S.setSSEHeartbeat(t.heartbeat),s(`SSE heartbeat set to ${t.heartbeat} seconds`)),S.setActiveSSEConnection()}catch(e){s(`Failed to parse SSE settings: ${e}`)}r(L),await At()})),Mt.addEventListener("messages",(async e=>{try{const t=JSON.parse(e.data);s("SSE message received"),await Se(t),await me(t),await qt()}catch(e){s(`Failed to parse SSE message: ${e}`),Wt()}})),Mt.addEventListener("inbox_messages",(async e=>{try{const t=JSON.parse(e.data);s("SSE inbox messages received"),await $t(t)}catch(e){s(`Failed to parse SSE inbox messages: ${e}`)}})),Mt.addEventListener("error",(async()=>{s("SSE error received"),Wt()})),Mt.addEventListener("heartbeat",(async()=>{s("SSE heartbeat received"),S.setActiveSSEConnection(),S.setUseSSEFlag(!0)}))}()}()}))),1e3)):s("User token not setup, queue not started.")}async function qt(){const e=await async function(){const e=await be();return e?(a(e)??[]).filter((t=>{const n=t.properties.gist.broadcast,{frequency:s}=n,i=a(ve(e,t.queueId))??!0,o=a(we(e,t.queueId))||0,r=0===s.count;return i&&(r||o<s.count)})):[]}(),t=await async function(){const e=await Ie();if(!e)return[];const t=a(e)??[],n=await async function(){const e=await Ee();return e?a(e)??[]:[]}();return t.filter((e=>!n.includes(e.queueId??"")))}(),n=e.concat(t);s(`Messages in local queue: ${n.length}`);const i=n.sort(((e,t)=>e.priority-t.priority));for(const e of i)await Rt(e)}async function Rt(e){let t=j(e);if(t.hasRouteRule){let e=Ot.currentRoute;null==e&&(e=new URL(window.location.href).pathname);const n=t.routeRule;if(s(`Verifying route ${e} against rule: ${n}`),!new RegExp(n).test(e))return s(`Route ${e} does not match rule.`),!1}if(t.hasPosition&&(e.position=t.position),t.hasTooltipPosition&&(e.tooltipPosition=t.tooltipPosition),t.persistent||ye(e)){const n=await async function(e){const t=await ke(e);return t?a(t):null}(e.queueId??"");n&&(s(`Restoring saved state for queueId ${e.queueId}`),n.displaySettings&&(ee(e,n.displaySettings),t=j(e)),e.savedStepName=n.stepName??null)}if(t.persistent||ye(e)||!await async function(e){const t=await Ce(e);return!!t&&null!==a(t)}(e.queueId??"")){let n=null;return n=t.isEmbedded?dt(e,t.elementId):await ct(e),n&&async function(e){const t=await Ce(e);t&&o(t,!0,new Date(Date.now()+5e3))}(e.queueId??""),null!==n}return s(`Not showing message with queueId ${e.queueId} because its already loading.`),!1}async function At(){if(W())if(Ot.isDocumentVisible)if(null===a(L)){const e=await async function(){const e=W();let t;try{if(!T){T=!0;const e={"X-Gist-User-Anonymous":String(A()),"Content-Language":String($())};t=await C().post(`/api/v4/users?sessionId=${M()}`,{},{headers:e})}}catch(e){const n=E(e);n?t=n:s(`Error getting user queue: ${e}`)}finally{T=!1}return e!==W()?(s("User token changed, clearing queue next pull check."),void r(L)):(function(e){if(e?.headers){const t=e.headers["x-gist-queue-polling-interval"];t&&Number(t)>0&&(P=Number(t))}const t=new Date((new Date).getTime()+1e3*P);o(L,P,t)}(t),function(e){const t="true"===e?.headers?.["x-cio-use-sse"]?.toLowerCase();S.setUseSSEFlag(t)}(t),t)}();if(e){if(200===e.status||204===e.status){s("200 response, updating local store.");const t=e.data,n=t?.inAppMessages??[],i=t?.inboxMessages??[];Se(n),me(n),$t(i)}else 304===e.status&&s("304 response, using local store.");await qt()}else s("No response object returned while checking message queue.")}else s("Next queue pull scheduled for later.");else s("Document not visible, skipping queue check.");else s("User token reset, skipping queue check.")}function Wt(e=!1){e&&S.removeActiveSSEConnection(),(e||S.isSSEConnectionManagedBySDK())&&S.setUseSSEFlag(!1),Mt&&(s("Stopping SSE queue listener..."),Mt.close(),Mt=null)}class Ot{static async setup(e){this.initialized?s("Gist SDK already initialized, skipping setup."):(this.initialized=!0,this.events=new n,this.config={useAnonymousSession:e.useAnonymousSession??!1,siteId:e.siteId,dataCenter:e.dataCenter,env:e.env??"prod",logging:e.logging??!1,experiments:e.experiments??!1},this.currentMessages=[],this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const e=new URLSearchParams(window.location.search),t=e.get(Le);if(t){sessionStorage.setItem(i,String(!1)),Ot.setUserToken(t),s(`Preview mode enabled with user token: ${t}`),function(){if(document.getElementById(qe))return;!function(){if(document.getElementById(De))return;const e=document.createElement("style");e.id=De,e.textContent=Te,document.head.appendChild(e)}();try{ze="true"===sessionStorage.getItem(Me)}catch{ze=!1}const e=Xe("div",{id:qe});document.body.appendChild(e),at()}();const n=e.get(Ne);if(n)try{const e=JSON.parse(atob(n)),t=e.stepName||null,s=e.displayType||null;(t||s)&&function(e,t){Ge=e,Ve=t}(t,s)}catch{s("Preview bar: failed to parse cioPreviewSettings")}}return!l()}(),function(){const e=c();for(let t=e.length-1;t>=0;t--)d(e.key(t))}(),s(`Setup complete on ${this.config.env} environment.`),this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||O(),await Dt(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await qt())}),!1))}static async setCurrentRoute(e){this.currentRoute=e,s(`Current route set to: ${e}`),await async function(){if(0!==Ot.currentMessages.length)for(const e of[...Ot.currentMessages])null==document.querySelector(`#gist-${e.instanceId}`)&&(s(`Removing active message ${e.instanceId} that no longer exists after route change`),await pt(e))}(),await qt()}static async setUserToken(e,t){this.config.isPreviewSession||(function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),o(D,e,t),A()&&(r(L),r(q)),s(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),Wt(!0),await Dt())}static setUserLocale(e){var t;o(k,t=e),s(`Set user locate to "${t}"`)}static setCustomAttribute(e,t){return function(e,t){return e&&"string"==typeof e?(pe.set(e,t),ge(),s(`Set custom attribute "${e}" to "${t}"`),!0):(s(`Invalid key for custom attribute: ${e}`),!1)}(e,t)}static clearCustomAttributes(){pe.clear(),r(ue),s("Cleared all custom attributes")}static removeCustomAttribute(e){return function(e){if(!e||"string"!=typeof e)return s(`Invalid key for custom attribute: ${e}`),!1;const t=pe.has(e);return pe.delete(e),pe.size>0?ge():r(ue),s(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(r(D),s("Cleared user token"),this.config.useAnonymousSession&&O(),Wt(!0),await Dt())}static async dismissMessage(e){const t=V(e);t&&(await gt(t),await Ct(t),await ut(t),await qt())}static async embedMessage(e,t){return dt(e,t)?.instanceId??null}static async showMessage(e){return(await ct(e))?.instanceId??null}static updateMessageDisplaySettings(e,t){const n=V(e);return!!n&&(n.displaySettings=t,oe(n),!0)}static messageShown(e){s(`Message shown: ${e.messageId}`),this.events.dispatch("messageShown",e)}static messageDismissed(e){null!==e&&(s(`Message dismissed: ${e.messageId}`),this.events.dispatch("messageDismissed",e))}static messageError(e){s(`Message error: ${e.messageId}`),this.events.dispatch("messageError",e)}static messageAction(e,t,n){s(`Message action: ${e.currentRoute}, ${t} with name ${n} on ${e.instanceId}`),this.events.dispatch("messageAction",{message:e,action:t,name:n})}static async getInboxUnopenedCount(){return(await Pt()).filter((e=>!e.opened)).length}static async getInboxMessages(){return await Pt()}static async updateInboxMessageOpenState(e,t){return await async function(e,t){const n=await Tt();if(!n)return;const i=await async function(e,t){try{return await C()(`/api/v1/messages/${e}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return E(e)}}(e,{opened:t});if(!i||i.status<200||i.status>=300){const e=`Failed to mark inbox message opened: ${i?.status??"unknown error"}`;throw s(e),new Error(e)}const a=await Pt();let r=null;const l=a.map((n=>{if(n.queueId===e){const e={...n,opened:t};return r=e,e}return n})),c=new Date;if(c.setMinutes(c.getMinutes()+60),o(n,l,c),r){const e=t?"opened":"unopened";Ot.events.dispatch("inboxMessageAction",{message:r,action:e})}Ot.events.dispatch(kt,await Pt())}(e,t)}static async removeInboxMessage(e){return await async function(e){const t=await Tt();if(!t)return;const n=await _(e);if(!n||n.status<200||n.status>=300){const e=`Failed to remove inbox message: ${n?.status??"unknown error"}`;throw s(e),new Error(e)}const i=(await Pt()).filter((t=>t.queueId!==e)),a=new Date;a.setMinutes(a.getMinutes()+60),o(t,i,a),Ot.events.dispatch(kt,await Pt())}(e)}}return t.default})(),e.exports=t()}}]);
|
|
1
|
+
(self.webpackChunk_customerio_cdp_analytics_browser=self.webpackChunk_customerio_cdp_analytics_browser||[]).push([[573],{7573:function(e){var t;t=()=>(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>Kt});class n{constructor(){this.callbacks={}}on(e,t){const n=this.callbacks[e];n?n.push(t):this.callbacks[e]=[t]}off(e,t){const n=this.callbacks[e];if(!n)return;if(!t)return void delete this.callbacks[e];const i=n.indexOf(t);-1!==i&&n.splice(i,1),0===n.length&&delete this.callbacks[e]}dispatch(e,t){const n=this.callbacks[e];n&&n.forEach((e=>e(t)))}}function i(e){Kt.config&&Kt.config.logging&&console.log(`Gist: ${e}`)}const o="gist.web.isPersistingSession";function s(e,t,n=null){let i=n;i||(i=new Date,i.setDate(i.getDate()+365));const o={value:t,expiry:i};c().setItem(e,JSON.stringify(o))}function a(e){return d(e)}function r(e){c().removeItem(e)}function l(){const e=sessionStorage.getItem(o);return null===e?(sessionStorage.setItem(o,"true"),!0):"true"===e}function c(){return l()?localStorage:sessionStorage}function d(e){if(!e)return null;try{const t=c().getItem(e);if(!t)return null;const n=JSON.parse(t);if(!n.expiry)return n.value;const i=new Date,o=new Date(n.expiry),s=e.startsWith("gist.web.message.broadcasts")&&!e.endsWith("shouldShow")&&!e.endsWith("numberOfTimesShown")||e.startsWith("gist.web.message.user")&&!e.endsWith("seen")&&!e.endsWith("state"),a=new Date(i.getTime()+366e4);return s&&o.getTime()>a.getTime()||i.getTime()>o.getTime()?(r(e),null):n.value}catch(t){i(`Error checking key ${e} for expiry: ${t}`)}return null}var p,u=new Uint8Array(16);function g(){if(!p&&!(p="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return p(u)}const m=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var f=[],h=0;h<256;++h)f.push((h+256).toString(16).substr(1));const w=function(e,t,n){var i=(e=e||{}).random||(e.rng||g)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=i[o];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(f[e[t+0]]+f[e[t+1]]+f[e[t+2]]+f[e[t+3]]+"-"+f[e[t+4]]+f[e[t+5]]+"-"+f[e[t+6]]+f[e[t+7]]+"-"+f[e[t+8]]+f[e[t+9]]+"-"+f[e[t+10]]+f[e[t+11]]+f[e[t+12]]+f[e[t+13]]+f[e[t+14]]+f[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&m.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n}(i)},y="gist.web.userQueueUseSSE",b="gist.web.activeSSEConnection";let v,x=30;const S={RENDERER_HOST:"https://code.gist.build",ENGINE_API_ENDPOINT:{prod:"https://engine.api.gist.build",dev:"https://engine.api.dev.gist.build",local:"http://engine.api.local.gist.build:82"},GIST_QUEUE_API_ENDPOINT:{prod:"https://consumer.cloud.gist.build",dev:"https://consumer.cloud.dev.gist.build",local:"http://api.local.gist.build:86"},GIST_QUEUE_REALTIME_API_ENDPOINT:{prod:"https://realtime.cloud.gist.build",dev:"https://realtime.cloud.dev.gist.build",local:"http://api.local.gist.build:3000"},GIST_VIEW_ENDPOINT:{prod:"https://renderer.gist.build/3.0",dev:"https://renderer.gist.build/3.0",local:"http://app.local.gist.build:8080/web"},getSdkId:()=>(v||(v=w()),v),useSSE:()=>a(y)??!1,setUseSSEFlag(e){s(y,e,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${e}"`)},removeActiveSSEConnection(){r(b)},setActiveSSEConnection(){s(b,S.getSdkId(),new Date((new Date).getTime()+S.getSSEHeartbeat()))},hasActiveSSEConnection:()=>a(b)??!1,isSSEConnectionManagedBySDK:()=>a(b)===S.getSdkId(),getSSEHeartbeat:()=>1e3*(x+5),setSSEHeartbeat(e){e&&e>0&&(x=e)}};function I(e){return null!==e&&"object"==typeof e&&"response"in e}function E(e){return I(e)?e.response:void 0}function $(){const e=S.GIST_QUEUE_API_ENDPOINT[Kt.config.env??"prod"],t={"X-CIO-Site-Id":Kt.config.siteId,"X-CIO-Client-Platform":"web"},n=z();async function i(n,i={}){const o=e+n,s=new AbortController,a=setTimeout((()=>s.abort()),5e3);try{const e=await fetch(o,{method:i.method||"GET",headers:{...t,...i.headers||{}},body:i.method&&"GET"!==i.method.toUpperCase()?i.body:void 0,signal:s.signal});clearTimeout(a);const n=e.headers.get("content-type")?.includes("application/json"),r=n?await e.json():await e.text(),l=Object.fromEntries(e.headers.entries());if(e.status<200||e.status>=400)throw function(e){return Object.assign(new Error,{response:e})}({status:e.status,data:r,headers:l});return{status:e.status,headers:l,data:r}}catch(e){if(clearTimeout(a),I(e))throw e;if(e instanceof Error)throw Object.assign(e,{response:{status:0,data:e.message||"Unknown error",headers:{}}});throw e}}return null!=n&&(t["X-Gist-Encoded-User-Token"]=n),i.post=(e,t={},n={})=>i(e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...n.headers||{}}}),i}const C="gist.web.userLocale";function k(){const e=a(C);return null!==e?e:navigator.language}let P=600,T=!1;const L="gist.web.userQueueNextPullCheck",M="gist.web.sessionId";function N(){let e=a(M);return e||(e=w()),s(M,e,new Date((new Date).getTime()+18e5)),String(e)}const D="gist.web.userToken",q="gist.web.usingGuestUserToken",R="gist.web.guestUserToken";function A(){return null!==a(q)}function W(){return a(D)}function O(){if(null===W()){let e=a(R);null==e&&(e=w(),s(R,e),i(`Set guest user token "${e}" with expiry date set to 1 year from today`)),s(D,e),s(q,!0),i(`Using anonymous session with token: "${e}"`)}}async function U(){const e=W();return null===e?null:await async function(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map((e=>e.toString(16).padStart(2,"0"))).join("")}(e)}function z(){const e=W();return null===e?null:btoa(e)}function B(){r(D),i("Cleared user token")}async function H(e){try{return await $().post(`/api/v1/logs/queue/${e}`)}catch(e){return E(e)}}function _(e){try{return(document.getElementById(e)??document.querySelector(e))||null}catch{return null}}const F={isEmbedded:!1,elementId:"",hasRouteRule:!1,routeRule:"",position:"",hasPosition:!1,tooltipPosition:"",hasTooltipPosition:!1,tooltipArrowColor:"#fff",shouldScale:!1,campaignId:null,messageWidth:414,overlayColor:"#00000033",persistent:!1,exitClick:!1,hasCustomWidth:!1};function j(e){const t=F,n=e?.properties?.gist;return n?{isEmbedded:!!n.elementId&&!n.tooltipPosition,elementId:n.elementId||"",hasRouteRule:!!n.routeRuleWeb,routeRule:n.routeRuleWeb||"",position:n.position||"",hasPosition:!!n.position,tooltipPosition:n.tooltipPosition||"",hasTooltipPosition:!!n.tooltipPosition,tooltipArrowColor:n.tooltipArrowColor||t.tooltipArrowColor,shouldScale:!!n.scale,campaignId:n.campaignId??null,messageWidth:null!=n.messageWidth&&n.messageWidth>0?n.messageWidth:t.messageWidth,hasCustomWidth:(n.messageWidth??0)>0,overlayColor:n.overlayColor||t.overlayColor,persistent:!!n.persistent,exitClick:!!n.exitClick}:t}const G=["x-gist-top","x-gist-floating-top","x-gist-bottom","x-gist-floating-bottom","x-gist-floating-bottom-left","x-gist-floating-bottom-right","x-gist-floating-top-left","x-gist-floating-top-right"];function V(e){if(document.getElementById(e))return;const t=document.createElement("div");t.id=e,"x-gist-top"===e?document.body.insertBefore(t,document.body.firstChild):document.body.insertAdjacentElement("beforeend",t),i("Top & bottom elements injected into page")}const X=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function J(e){return Kt.currentMessages.find((t=>t.instanceId===e))}function Y(e){return!!e&&Kt.currentMessages.some((t=>t.queueId===e))}function Q(e){return e?Kt.currentMessages.find((t=>t.elementId===e))??null:null}function K(e){Kt.currentMessages=Kt.currentMessages.filter((t=>t.instanceId!==e))}function Z(e,t){K(e),Kt.currentMessages.push(t)}function ee(e){const t={topLeft:"x-gist-floating-top-left",topCenter:"x-gist-floating-top",topRight:"x-gist-floating-top-right",bottomLeft:"x-gist-floating-bottom-left",bottomCenter:"x-gist-floating-bottom",bottomRight:"x-gist-floating-bottom-right"};return e&&t[e]?t[e]:(i(`Invalid overlay position "${e}", defaulting to "topCenter"`),t.topCenter)}function te(e){return e.tooltipPosition?"tooltip":e.overlay?"modal":e.elementId&&G.includes(e.elementId)?"overlay":e.elementId?"inline":"modal"}function ne(e,t){const n=te(e),i=t.displayType;if(void 0===i)return!1;if(n!==i)return!0;const o=j(e);switch(i){case"modal":{if((e.position||"center")!==(t.modalPosition||"center"))return!0;const n=t.dismissOutsideClick??F.exitClick;if(o.exitClick!==n)return!0;const i=t.overlayColor??F.overlayColor;if(o.overlayColor!==i)return!0;break}case"overlay":{const n=ee(t.overlayPosition);if(e.elementId!==n)return!0;break}case"inline":if(e.elementId!==t.elementSelector)return!0;break;case"tooltip":if(e.tooltipPosition!==t.tooltipPosition)return!0;if(e.elementId!==t.elementSelector)return!0;if(void 0!==t.tooltipArrowColor&&o.tooltipArrowColor!==t.tooltipArrowColor)return!0}if("overlay"!==i||!X.includes(ee(t.overlayPosition))){const e=t.maxWidth??F.messageWidth;if(o.messageWidth!==e)return!0}return!1}function ie(e,t){if(e.properties||(e.properties={}),e.properties.gist||(e.properties.gist={}),"modal"===t.displayType)e.overlay=!0,e.elementId=null,e.properties.gist.elementId=null,e.position=t.modalPosition||"center",e.properties.gist.position=t.modalPosition||"center",e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0,e.properties.gist.tooltipArrowColor=void 0;else if("overlay"===t.displayType){e.overlay=!1;const n=ee(t.overlayPosition);e.elementId=n,e.properties.gist.elementId=n,e.position=null,e.properties.gist.position=null,e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0,e.properties.gist.tooltipArrowColor=void 0}else"inline"===t.displayType?(e.overlay=!1,e.elementId=t.elementSelector,e.properties.gist.elementId=t.elementSelector,e.position=null,e.properties.gist.position=null,e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0,e.properties.gist.tooltipArrowColor=void 0):"tooltip"===t.displayType&&(e.overlay=!1,e.elementId=t.elementSelector,e.properties.gist.elementId=t.elementSelector,e.tooltipPosition=t.tooltipPosition,e.properties.gist.tooltipPosition=t.tooltipPosition,e.position=null,e.properties.gist.position=null,void 0!==t.tooltipArrowColor&&(e.properties.gist.tooltipArrowColor=t.tooltipArrowColor));e.elementId&&X.includes(e.elementId)?delete e.properties.gist.messageWidth:void 0!==t.maxWidth&&t.maxWidth>0?e.properties.gist.messageWidth=t.maxWidth:delete e.properties.gist.messageWidth,void 0!==t.overlayColor?e.properties.gist.overlayColor=t.overlayColor:delete e.properties.gist.overlayColor,void 0!==t.dismissOutsideClick?e.properties.gist.exitClick=t.dismissOutsideClick:delete e.properties.gist.exitClick}const oe={top:["bottom","left","right"],bottom:["top","left","right"],left:["right","top","bottom"],right:["left","top","bottom"]},se=/auto|scroll/,ae={top:"gist-arrow-bottom",bottom:"gist-arrow-top",left:"gist-arrow-right",right:"gist-arrow-left"};function re(e){const t=_(e);return t||i(`Tooltip target element not found for selector: ${e}`),t}function le(e,t){if(e.bottom<=0||e.top>=window.innerHeight||e.right<=0||e.left>=window.innerWidth)return!1;for(const n of t){const t=n.getBoundingClientRect();if(e.bottom<=t.top||e.top>=t.bottom||e.right<=t.left||e.left>=t.right)return!1}return!0}function ce(e,t,n){const i=function(e,t,n){switch(n){case"top":return{top:t.top-e.height-16,left:t.left+(t.width-e.width)/2};case"bottom":return{top:t.bottom+16,left:t.left+(t.width-e.width)/2};case"left":return{top:t.top+(t.height-e.height)/2,left:t.left-e.width-16};case"right":return{top:t.top+(t.height-e.height)/2,left:t.right+16}}}(e,t,n);return function(e,t,n){return"top"===n||"bottom"===n?e.top>=0&&e.top+t.height<=window.innerHeight:e.left>=0&&e.left+t.width<=window.innerWidth}(i,e,n)&&function(e,t){return"top"===t||"bottom"===t?e.width+8<=window.innerWidth:e.height+8<=window.innerHeight}(e,n)?function(e,t,n){let{top:i,left:o}=e,s=null;if("top"===n||"bottom"===n){const e=4,n=window.innerWidth-t.width-4;n>=e&&(o<e?(s=o-e,o=e):o>n&&(s=o-n,o=n))}else{const e=4,n=window.innerHeight-t.height-4;n>=e&&(i<e?(s=i-e,i=e):i>n&&(s=i-n,i=n))}if(null!==s){const e=("top"===n||"bottom"===n?t.width/2:t.height/2)-16-4;Math.abs(s)>e&&(s=s>0?e:-e)}return{top:i,left:o,position:n,arrowOffset:s}}(i,e,n):null}function de(e,t,n){const i=ce(e,t,n);if(i)return i;for(const i of oe[n]){const n=ce(e,t,i);if(n)return n}return null}function pe(e){const t=[];let n=e.parentElement;for(;n;){const e=getComputedStyle(n),i=e.overflow+e.overflowX+e.overflowY;se.test(i)&&t.push(n),n=n.parentElement}return t}function ue(e){const t=_(e);t&&(t.classList.remove("gist-visible"),Array.from(t.classList).filter((e=>e.startsWith("gist-"))).forEach((e=>t.classList.remove(e))),t.style.removeProperty("height"),t.style.removeProperty("width"),t.innerHTML="")}function ge(e){const t=_(e);if(t)return!(!t.style||!t.style.height||"0px"===t.style.height)}function me(e,t,n=null){const i=document.getElementById(e);i&&(i.onload=()=>{!function(e,t,n=null){const i=document.getElementById(e);if(i?.contentWindow){const e={options:t,capabilities:fe};n&&(t.stepId=n),i.contentWindow.postMessage(e,"*")}}(e,t,n)})}const fe=["MultiStepDisplayTypes"];function he(e){if(!e.displaySettings)return;const t=xe(e.instanceId??""),n=document.getElementById(t);n?.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:e.displaySettings},"*")}async function we(){const e=document.querySelector(".gist-message");e&&(e.classList.remove("gist-visible"),await new Promise((e=>setTimeout(e,300)))),ye()}function ye(){const e=document.querySelector("#gist-embed-message");e&&e.parentNode?.removeChild(e)}const be=new Map;function ve(e){const t=e.instanceId??"",n=be.get(t);n&&(n.cleanup(),be.delete(t));const i=_(`gist-tooltip-${t}`);i&&i.parentNode?.removeChild(i)}function xe(e){return`gist-${e}`}function Se(){const e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}const Ie="gist.web.customAttributes";let Ee=new Map;function $e(){const e=Array.from(Ee.entries()),t=new Date;t.setDate(t.getDate()+30),s(Ie,e,t),i(`Saved ${Ee.size} custom attributes to storage with TTL of 30 days`)}async function Ce(e){const t=await Le();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(t,e.filter(Pe),n)}async function ke(e,t){return a(e)?.find((e=>e.queueId===t))}function Pe(e){return!(!e.properties?.gist||!e.properties.gist.broadcast)}function Te(e){if(!Pe(e))return!1;const t=e.properties.gist.broadcast;return 0===t.frequency.delay&&0===t.frequency.count}async function Le(){const e=await U();return e?`gist.web.message.broadcasts.${e}`:null}function Me(e,t){return`${e}.${t}.numberOfTimesShown`}function Ne(e,t){return`${e}.${t}.shouldShow`}!function(){const e=a(Ie);if(e)try{Ee=new Map(e)}catch{Ee=new Map}else Ee=new Map}();const De="gist.web.message.user";async function qe(e){const t=await Re();if(!t)return;const n=e.filter((e=>!(e.properties&&e.properties.gist&&e.properties.gist.broadcast))),i=new Date;i.setMinutes(i.getMinutes()+60),s(t,n,i)}async function Re(){const e=await U();return e?`${De}.${e}`:null}async function Ae(){const e=await U();return e?`${De}.${e}.seen`:null}async function We(e){const t=await U();return t?`${De}.${t}.message.${e}.loading`:null}async function Oe(e){const t=await U();return t?`${De}.${t}.message.${e}.state`:null}async function Ue(e){const t=await Oe(e);t&&(r(t),i(`Cleared message state for queueId: ${e}`))}function ze(e){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.54223 5.33301L7.7089 9.33301L11.8756 5.33301L12.6121 6.04011L7.7089 10.7472L2.80566 6.04011L3.54223 5.33301Z" fill="${e}"/></svg>`}const Be=`\n #gist-preview-bar {\n position: fixed; bottom: 0; left: 0; right: 0;\n z-index: 99999999999;\n font-family: system-ui, -apple-system, sans-serif;\n pointer-events: none;\n }\n .gist-pb-toggle-row {\n display: flex; justify-content: center;\n padding: 6px 16px;\n border-bottom: 1px solid #e5e7eb;\n }\n .gist-pb-toggle-row--collapsed { border-bottom: none; }\n .gist-pb-toggle-btn {\n background: #08272B; border: none;\n padding: 4px 14px;\n border-radius: 100px;\n font-size: 12px; font-weight: 500;\n font-family: system-ui, -apple-system, sans-serif;\n color: white; cursor: pointer;\n display: flex; align-items: center; gap: 6px;\n pointer-events: auto;\n height: auto; min-width: auto;\n box-sizing: border-box;\n line-height: normal;\n -webkit-appearance: none;\n appearance: none;\n }\n .gist-pb-controls-row {\n background: #F8F9F9;\n box-shadow: 1px 2px 2px #34344605, 3px 3px 8px #34344614;\n display: flex; flex-wrap: wrap; align-items: center;\n gap: 12px; padding: 10px 16px 12px;\n pointer-events: auto;\n }\n .gist-pb-label-group { display: flex; flex-direction: column; gap: 4px; }\n .gist-pb-label-group--grow { flex: 1; }\n .gist-pb-label {\n font-size: 10px; font-weight: 600; color: #3F4E50;\n letter-spacing: 0.05em; text-transform: uppercase;\n font-family: system-ui, -apple-system, sans-serif;\n }\n .gist-pb-select {\n height: 32px; padding: 0 32px 0 8px;\n border: 1px solid #d1d5db; border-radius: 6px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n background: white url("data:image/svg+xml,${encodeURIComponent(ze("#3F4E50"))}") no-repeat right 2px center;\n color: #3F4E50; cursor: pointer; outline: none;\n appearance: none; min-width: 120px;\n }\n .gist-pb-input {\n height: 32px; padding: 0 8px;\n border: 1px solid #d1d5db; border-radius: 6px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; outline: none; box-sizing: border-box;\n }\n .gist-pb-checkbox-row { display: flex; align-items: center; gap: 6px; height: 32px; }\n .gist-pb-checkbox-label {\n font-size: 12px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; cursor: pointer; user-select: none;\n }\n .gist-pb-color-control {\n display: flex; align-items: center;\n border: 1px solid #d1d5db; border-radius: 6px;\n overflow: hidden; height: 32px; background: white;\n }\n .gist-pb-color-swatch {\n width: 28px; height: 100%;\n cursor: pointer; flex-shrink: 0;\n border-right: 1px solid #d1d5db; position: relative;\n }\n .gist-pb-color-input {\n position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;\n }\n .gist-pb-color-hex {\n flex: 1; border: none; outline: none; padding: 0 6px;\n font-size: 13px; font-family: monospace; color: #3F4E50;\n min-width: 0; background: transparent;\n }\n .gist-pb-color-opacity {\n width: 36px; border: none; border-left: 1px solid #d1d5db;\n outline: none; padding: 0 4px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; background: transparent; text-align: right;\n }\n .gist-pb-color-pct {\n font-size: 12px; color: #3F4E50; padding: 0 6px 0 2px;\n font-family: system-ui, -apple-system, sans-serif; flex-shrink: 0;\n }\n .gist-pb-input--invalid { border-color: #941616; outline: 1px solid #941616; }\n .gist-pb-inline-row { display: flex; align-items: center; gap: 6px; }\n .gist-pb-select-elem-btn {\n height: 32px; padding: 0 12px;\n border: none; border-radius: 6px;\n font-size: 12px; font-weight: 500; font-family: system-ui, -apple-system, sans-serif;\n background: #08272B; color: white; cursor: pointer; white-space: nowrap; flex-shrink: 0;\n min-width: auto; box-sizing: border-box;\n -webkit-appearance: none; appearance: none;\n }\n .gist-pb-spacer { flex: 1; min-width: 0; }\n .gist-pb-save-btn {\n height: 36px; padding: 0 18px;\n background: #08272B; color: white;\n border: none; border-radius: 6px;\n font-size: 13px; font-weight: 600;\n font-family: system-ui, -apple-system, sans-serif;\n cursor: pointer; white-space: nowrap; align-self: center;\n min-width: auto; box-sizing: border-box;\n -webkit-appearance: none; appearance: none;\n }\n .gist-pb-save-btn:disabled {\n background: #CAD6D8; cursor: not-allowed;\n }\n .gist-pb-picker-overlay {\n position: fixed; inset: 0; z-index: 999999999998; cursor: crosshair;\n }\n .gist-pb-checkbox { cursor: pointer; width: 14px; height: 14px; }\n .gist-pb-pick-highlight { outline: 2px solid #006FF5 !important; }\n .gist-pb-pick-error { outline: 2px solid #941616 !important; }\n #gist-preview-bar.gist-pb-hidden { display: none; }\n .gist-pb-ended-row {\n justify-content: center; align-items: center; gap: 10px; padding: 12px 16px;\n flex-wrap: nowrap;\n }\n .gist-pb-ended-icon {\n display: flex; align-items: center; justify-content: center;\n width: 22px; height: 22px; border-radius: 50%;\n background: #08272B; color: white;\n font-size: 13px; font-weight: 700; flex-shrink: 0;\n }\n .gist-pb-ended-text {\n margin: 0; font-size: 13px; color: #3F4E50;\n font-family: system-ui, -apple-system, sans-serif;\n min-width: 0;\n }\n .gist-pb-ended-text strong { color: #08272B; }\n @media (max-width: 1024px) {\n .gist-pb-controls-row { gap: 8px; }\n .gist-pb-label-group { flex: 1 1 100%; }\n .gist-pb-label-group--grow { flex: 1 1 100%; }\n .gist-pb-select { width: 100%; min-width: unset; box-sizing: border-box; }\n .gist-pb-input { width: 100% !important; box-sizing: border-box; }\n .gist-pb-color-control { width: 100%; }\n .gist-pb-checkbox-row { width: 100%; }\n .gist-pb-inline-row { flex-direction: row; align-items: center; }\n .gist-pb-inline-row .gist-pb-input { flex: 1; min-width: 0; }\n .gist-pb-save-btn { width: 100%; box-sizing: border-box; }\n .gist-pb-label--spacer { display: none; }\n }\n`,He="cioPreviewId",_e="cioPreviewSettings",Fe="gist.previewBar.collapsed",je="gist-pb-styles",Ge="gist-preview-bar",Ve={topLeft:"Top Left",topCenter:"Top Center",topRight:"Top Right",bottomLeft:"Bottom Left",bottomCenter:"Bottom Center",bottomRight:"Bottom Right"};let Xe=null,Je=[],Ye={},Qe=null,Ke=!1,Ze=!1,et=5,tt=null,nt=!1,it=null,ot=null,st=null;const at=new Map;function rt(e,t={}){const n=document.createElement(e);for(const[e,i]of Object.entries(t))n[e]=i;return n}function lt(e,t){const n=rt("div",{className:"gist-pb-label-group"});return n.appendChild(rt("span",{className:"gist-pb-label",textContent:e})),n.appendChild(t),n}function ct(e,t){const n=rt("select",{className:"gist-pb-select"});for(const i of e){const e=rt("option",{value:i.value,textContent:i.label});i.value===t&&(e.selected=!0),n.appendChild(e)}return n}function dt(e,t,n){const i=rt("input",{className:"gist-pb-input",type:e,value:String(t)});return n&&(i.style.width=n),i}function pt(e,t){const n=Math.round(Math.min(100,Math.max(0,t))/100*255);return"#"+e.replace("#","").toUpperCase()+n.toString(16).padStart(2,"0").toUpperCase()}function ut(e){return!!("inline"!==e.displayType&&"tooltip"!==e.displayType||e.elementSelector?.trim())}function gt(e){if("overlay"===e.displayType&&X.includes(ee(e.overlayPosition))){const{maxWidth:t,...n}=e;e=n}if(Ye=e,Qe){const t=Je.findIndex((e=>e.stepName===Qe));-1!==t&&(Je[t]={...Je[t],displaySettings:{...e}})}if(!Xe)return;const t=Kt.currentMessages.find((e=>e.instanceId===Xe));t&&ut(e)&&(he(t),ne(t,e)&&Wt(t,Qe,e)),function(){const e=new URLSearchParams(window.location.search).get(He);e&&async function(e,t){try{return await $()(`/api/v1/preview/${e}`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return E(e)}}(e,Je).then((e=>{e&&404===e.status&&Xe&&Kt.dismissMessage(Xe)})).catch((()=>i("Failed to persist preview display settings")))}()}function mt(e){const t=e.value.trim();t&&!_(t)?e.classList.add("gist-pb-input--invalid"):e.classList.remove("gist-pb-input--invalid")}function ft(e,t){const n=dt("text",e.elementSelector||"","260px");n.placeholder="Element ID or selector",mt(n),n.addEventListener("change",(()=>{const e=n.value.trim(),t=Ye.elementSelector;e&&ht(e),gt({...Ye,elementSelector:e}),t&&t!==e&&wt(t),mt(n)}));const i=rt("button",{type:"button",className:"gist-pb-select-elem-btn",textContent:"Select Element"});i.addEventListener("click",(()=>yt(n)));const o=rt("div",{className:"gist-pb-inline-row"});o.appendChild(n),o.appendChild(i),t.appendChild(lt("Element Selector",o))}function ht(e){if(!e||at.has(e))return;const t=_(e);t&&at.set(e,t.innerHTML)}function wt(e){const t=at.get(e);if(void 0===t)return;const n=_(e);n&&(n.innerHTML=t)}function yt(e){if(nt)return;nt=!0;const t={...Ye},n=Kt.currentMessages.find((e=>e.instanceId===Xe))??null;n&&At(n),Ye.elementSelector&&wt(Ye.elementSelector);const o=rt("div",{className:"gist-pb-picker-overlay"});let s=null;const a=e=>{o.style.pointerEvents="none";const t=document.elementFromPoint(e.clientX,e.clientY);o.style.pointerEvents="all",t&&t!==s&&t!==o&&(s?.classList.remove("gist-pb-pick-highlight"),s=t,s.classList.add("gist-pb-pick-highlight"))},r=e=>{if("Escape"===e.key){if(c(),Ye=t,Qe){const e=Je.findIndex((e=>e.stepName===Qe));-1!==e&&(Je[e]={...Je[e],displaySettings:{...t}})}n&&ut(t)&&Wt(n,Qe,t),bt()}},l=t=>{t.preventDefault(),t.stopPropagation(),o.style.pointerEvents="none";const s=document.elementFromPoint(t.clientX,t.clientY);if(o.style.pointerEvents="all",s&&s!==o){s.classList.remove("gist-pb-pick-highlight");const t=document.getElementById(Ge)?.contains(s)?null:function(e){if(e.id){const t=CSS.escape(e.id);if(1===document.querySelectorAll(`#${t}`).length)return e.id}const t=[];let n=e;for(;n&&"BODY"!==n.tagName&&"HTML"!==n.tagName;){if(n.id){const e=CSS.escape(n.id);if(1===document.querySelectorAll(`#${e}`).length){t.unshift(`#${e}`);break}}let e=n.tagName.toLowerCase();n.className&&"string"==typeof n.className&&(e+=n.className.trim().split(/\s+/).filter(Boolean).map((e=>`.${CSS.escape(e)}`)).join(""));const i=n.parentElement;i&&(e+=`:nth-of-type(${Array.from(i.children).filter((e=>e.tagName===n.tagName)).indexOf(n)+1})`),t.unshift(e);try{if(1===document.querySelectorAll(t.join(" > ")).length)break}catch{}n=n.parentElement}const o=t.join(" > ");try{if(1!==document.querySelectorAll(o).length)return i("buildUniqueSelector: could not produce a unique selector for element"),null}catch{return null}return o}(s);if(null===t)return s.classList.add("gist-pb-pick-error"),void setTimeout((()=>{s.classList.remove("gist-pb-pick-error"),s.classList.add("gist-pb-pick-highlight")}),800);e.value=t,ht(t);const o=Ye.elementSelector,a={...Ye,elementSelector:t},r=null!=n&&ut(a)&&ne(n,a);gt(a),o&&o!==t&&wt(o),n&&!r&&Wt(n,Qe,a)}c()},c=()=>{s?.classList.remove("gist-pb-pick-highlight"),o.removeEventListener("mousemove",a),o.removeEventListener("click",l),document.removeEventListener("keydown",r),document.body.removeChild(o),nt=!1,it=null};it=c,o.addEventListener("mousemove",a),o.addEventListener("click",l),document.addEventListener("keydown",r),document.body.appendChild(o)}function bt(){const e=document.getElementById(Ge);if(!e)return;if(e.classList.toggle("gist-pb-hidden",!Xe&&!Ze),e.innerHTML="",!Xe){if(Ze){const t=rt("div",{className:"gist-pb-controls-row gist-pb-ended-row"}),n=rt("span",{className:"gist-pb-ended-icon",textContent:"✓"}),i=rt("p",{className:"gist-pb-ended-text"});i.innerHTML=`<strong>Preview session ended.</strong> Close this tab and navigate back to the message editor. Refreshing in ${et}s…`,t.appendChild(n),t.appendChild(i),e.appendChild(t)}return}const t=rt("div",{className:"gist-pb-toggle-row"+(Ke?" gist-pb-toggle-row--collapsed":"")}),n=rt("button",{type:"button",className:"gist-pb-toggle-btn"}),i=Ke?"transform:rotate(180deg);display:inline-flex;":"display:inline-flex;";if(n.innerHTML=`${Ke?"Expand":"Collapse"}<span style="${i}">${ze("white")}</span>`,n.addEventListener("click",vt),t.appendChild(n),e.appendChild(t),Ke)return;const o=rt("div",{className:"gist-pb-controls-row"});if(Je.length>0){const e=Qe??Je[0].stepName,t=ct(Je.map((e=>({value:e.stepName,label:e.stepName}))),e);t.addEventListener("change",(()=>{const e=Je.find((e=>e.stepName===t.value));if(e){Qe=e.stepName,Ye={...e.displaySettings};const t=Kt.currentMessages.find((e=>e.instanceId===Xe));t&&ut(e.displaySettings)&&Wt(t,e.stepName,e.displaySettings),bt()}})),o.appendChild(lt("Step",t))}const s=ct([{value:"modal",label:"Modal"},{value:"overlay",label:"Overlay"},{value:"inline",label:"Inline"},{value:"tooltip",label:"Tooltip"}],Ye.displayType||"modal");s.addEventListener("change",(()=>{const e=s.value,t=Ye.displayType,n=Ye.elementSelector,i={...Ye,displayType:e};"modal"===e?(i.modalPosition=i.modalPosition||"center",i.maxWidth=i.maxWidth??414,delete i.overlayPosition,delete i.elementSelector,delete i.tooltipPosition):"overlay"===e?(i.overlayPosition=i.overlayPosition||"topCenter",i.maxWidth=i.maxWidth??414,delete i.modalPosition,delete i.elementSelector,delete i.tooltipPosition):"inline"===e?(delete i.modalPosition,delete i.overlayPosition,delete i.tooltipPosition):"tooltip"===e&&(i.tooltipPosition=i.tooltipPosition||"top",delete i.modalPosition,delete i.overlayPosition,delete i.overlayColor,delete i.dismissOutsideClick),Ye=i,gt(Ye),"inline"!==t&&"tooltip"!==t||!n||"inline"===e||"tooltip"===e||wt(n),bt()})),o.appendChild(lt("Display Type",s));const a=Ye.displayType||"modal";"modal"===a?function(e,t){const n=ct([{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}],e.modalPosition||"center");n.addEventListener("change",(()=>gt({...Ye,modalPosition:n.value}))),t.appendChild(lt("Position",n));const i=dt("number",e.maxWidth??414,"80px");i.addEventListener("change",(()=>gt({...Ye,maxWidth:parseInt(i.value)||414}))),t.appendChild(lt("Max Width",i)),t.appendChild(function(e){const{color:t,opacity:n}=function(e){const t=e.replace("#","");return 8===t.length?{color:"#"+t.slice(0,6).toUpperCase(),opacity:Math.round(parseInt(t.slice(6),16)/255*100)}:6===t.length?{color:"#"+t.toUpperCase(),opacity:100}:{color:"#000000",opacity:20}}(e.overlayColor||"#00000033"),i=rt("div",{className:"gist-pb-color-control"}),o=rt("input",{className:"gist-pb-color-input",type:"color",value:t}),s=rt("div",{className:"gist-pb-color-swatch"});s.style.background=t,s.appendChild(o),s.addEventListener("click",(()=>o.click()));const a=rt("input",{className:"gist-pb-color-hex",type:"text",maxLength:6,value:t.replace("#","")}),r=rt("input",{className:"gist-pb-color-opacity",type:"number",min:"0",max:"100",value:String(n)}),l=rt("span",{className:"gist-pb-color-pct",textContent:"%"}),c=()=>{const e="#"+a.value.replace("#",""),t=parseInt(r.value)||0;s.style.background=e,o.value=e,gt({...Ye,overlayColor:pt(e,t)})};return o.addEventListener("input",(()=>{a.value=o.value.replace("#","").toUpperCase(),s.style.background=o.value})),o.addEventListener("change",c),a.addEventListener("change",c),r.addEventListener("change",c),i.appendChild(s),i.appendChild(a),i.appendChild(r),i.appendChild(l),lt("Overlay Color",i)}(e));const o=rt("div",{className:"gist-pb-checkbox-row"}),s=rt("input",{className:"gist-pb-checkbox",type:"checkbox"});s.checked=e.dismissOutsideClick??!1;const a=rt("label",{className:"gist-pb-checkbox-label",textContent:"Dismiss on click outside"});s.addEventListener("change",(()=>gt({...Ye,dismissOutsideClick:s.checked}))),a.addEventListener("click",(()=>{s.checked=!s.checked,gt({...Ye,dismissOutsideClick:s.checked})})),o.appendChild(s),o.appendChild(a);const r=lt(" ",o);r.classList.add("gist-pb-label-group--grow"),r.firstChild.classList.add("gist-pb-label--spacer"),t.appendChild(r)}(Ye,o):"overlay"===a?function(e,t){const n=ct(Object.entries(Ve).map((([e,t])=>({value:e,label:t}))),e.overlayPosition||"topCenter");if(n.addEventListener("change",(()=>gt({...Ye,overlayPosition:n.value}))),t.appendChild(lt("Position",n)),!X.includes(ee(e.overlayPosition))){const n=dt("number",e.maxWidth??414,"80px");n.addEventListener("change",(()=>gt({...Ye,maxWidth:parseInt(n.value)||414}))),t.appendChild(lt("Max Width",n))}}(Ye,o):"inline"===a?function(e,t){ft(e,t)}(Ye,o):"tooltip"===a&&function(e,t){ft(e,t);const n=ct([{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],e.tooltipPosition||"top");n.addEventListener("change",(()=>gt({...Ye,tooltipPosition:n.value}))),t.appendChild(lt("Position",n))}(Ye,o),o.appendChild(rt("div",{className:"gist-pb-spacer"}));const r=rt("button",{type:"button",className:"gist-pb-save-btn",textContent:"End session"});r.addEventListener("click",(async()=>{Xe&&await Kt.dismissMessage(Xe)})),o.appendChild(r),e.appendChild(o)}function vt(){Ke=!Ke;try{sessionStorage.setItem(Fe,String(Ke))}catch{}bt()}function xt(){(function(){for(const e of at.keys())wt(e);at.clear()})(),Xe=null,Je=[],Ye={},Qe=null,Ze=!0,et=5;const e=new URLSearchParams(window.location.search).get(He);e&&async function(e){try{return await $()(`/api/v1/preview/${e}`,{method:"DELETE"})}catch(e){return E(e)}}(e).catch((()=>i("Failed to delete preview session"))),bt(),tt&&clearInterval(tt),tt=setInterval((()=>{et-=1,et<=0?(clearInterval(tt),tt=null,B(),function(){try{sessionStorage.removeItem(o)}catch{}}(),window.location.reload()):bt()}),1e3)}async function St(e){if(!Kt.isDocumentVisible)return i("Document hidden, not showing message now."),null;if(Y(e.queueId))return i(`Message with queueId ${e.queueId} is already showing.`),null;const t=j(e);return!e.tooltipPosition&&t.hasTooltipPosition&&(e.tooltipPosition=t.tooltipPosition),e.tooltipPosition?function(e,t){const n=t.elementId||e.elementId;if(!n)return i(`No target selector specified for tooltip message ${e.messageId}`),Kt.messageError(e),null;if(!_(n))return i(`Tooltip target element "${n}" not found for message ${e.messageId}, skipping display`),Kt.messageError(e),null;const o=Kt.currentMessages.find((e=>e.tooltipPosition&&e.elementId===n));return o&&(i(`Tooltip already showing on target "${n}" (instance ${o.instanceId}), dismissing it first`),Kt.messageDismissed(o),ve(o),o.instanceId&&K(o.instanceId)),e.instanceId=w(),e.overlay=!1,e.firstLoad=!0,e.shouldResizeHeight=!1,e.shouldScale=!1,e.renderStartTime=(new Date).getTime(),e.elementId=n,Kt.currentMessages.push(e),Mt(e,null,e.savedStepName||null)}(e,t):Kt.overlayInstanceId?(i(`Message ${Kt.overlayInstanceId} already showing.`),null):(e.instanceId=w(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),Kt.overlayInstanceId=e.instanceId,Kt.currentMessages.push(e),Mt(e,null,e.savedStepName||null))}function It(e,t){return Kt.isDocumentVisible?Y(e.queueId)?(i(`Message with queueId ${e.queueId} is already showing.`),null):Q(t)?(i(`Message with elementId ${t} already has a message.`),null):(e.instanceId=w(),e.overlay=!1,e.firstLoad=!0,e.shouldScale=!1,e.elementId=t,e.shouldResizeHeight=!ge(t),e.renderStartTime=(new Date).getTime(),Kt.currentMessages.push(e),Mt(e,t,e.savedStepName||null)):(i("Document hidden, not showing message now."),null)}async function Et(e){e?(Kt.messageDismissed(e),await $t(e)):i("Message not found")}async function $t(e){"tooltip"===te(e)?Pt(e):e.overlay?await Tt(!0,e):kt(e)}async function Ct(e){e?j(e).persistent&&(i("Persistent message dismissed, logging view"),await Ot(e),await Nt(e),await Ue(e.queueId??"")):i("Message not found")}function kt(e){e.instanceId&&K(e.instanceId),e.elementId&&ue(e.elementId),Kt.config.isPreviewSession&&(xt(),Lt())}function Pt(e){ve(e),e.instanceId&&K(e.instanceId),0===Kt.currentMessages.length&&(window.removeEventListener("message",qt),window.removeEventListener("touchstart",Dt)),Kt.config.isPreviewSession&&(xt(),Lt())}async function Tt(e,t){e?await we():ye(),0===Kt.currentMessages.length&&(window.removeEventListener("message",qt),window.removeEventListener("touchstart",Dt)),t.instanceId&&K(t.instanceId),Kt.overlayInstanceId=null,Kt.config.isPreviewSession&&(xt(),Lt())}function Lt(){const e=new URL(window.location.href);e.searchParams.delete(He),e.searchParams.delete(_e),history.replaceState(null,"",e.toString())}function Mt(e,t=null,n=null){const o=Kt.config.env,s={endpoint:S.ENGINE_API_ENDPOINT[o],siteId:Kt.config.siteId,dataCenter:Kt.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId??"",livePreview:!1,properties:e.properties,customAttributes:Object.fromEntries(new Map(Ee))},a=`${S.GIST_VIEW_ENDPOINT[o]}/index.html`;return window.addEventListener("message",qt),window.addEventListener("touchstart",Dt),"tooltip"===te(e)?function(e,t,n,i=null){const o=t.instanceId??"",s=xe(o),a=j(t),r=be.get(o);r&&(r.cleanup(),be.delete(o)),document.querySelectorAll(`#gist-tooltip-${o}`).forEach((e=>{e.parentNode?.removeChild(e)}));const l=`gist-tooltip-${o}`,c=document.createElement("div");c.id=l,c.innerHTML=function(e,t,n,i=""){let o=600;t.messageWidth>o&&(o=t.messageWidth);const s=t.tooltipArrowColor,a=function(e){switch(e){case"top":default:return"gist-arrow-bottom";case"bottom":return"gist-arrow-top";case"left":return"gist-arrow-right";case"right":return"gist-arrow-left"}}(t.tooltipPosition),r=i?`#${i} `:"";return`\n <div class="gist-tooltip-outer">\n <style>\n ${r}.gist-tooltip-outer {\n position: absolute;\n }\n ${r}.gist-tooltip-container {\n position: relative;\n z-index: 9999999;\n opacity: 0;\n transition: opacity 0.3s ease-in-out;\n }\n ${r}.gist-tooltip-container.gist-visible {\n opacity: 1;\n }\n ${r}.gist-tooltip-frame-clip {\n overflow: hidden;\n }\n ${r}.gist-tooltip-frame {\n display: block;\n width: ${t.messageWidth}px;\n border: none;\n transition: height 0.1s ease-in-out;\n }\n ${r}.gist-tooltip-arrow {\n width: 0;\n height: 0;\n position: absolute;\n z-index: 1;\n }\n ${r}.gist-tooltip-arrow.gist-arrow-bottom {\n bottom: 0;\n left: 50%;\n transform: translateX(-50%) translateY(100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-top: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-top {\n top: 0;\n left: 50%;\n transform: translateX(-50%) translateY(-100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-bottom: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-right {\n right: 0;\n top: 50%;\n transform: translateY(-50%) translateX(100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-left: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-left {\n left: 0;\n top: 50%;\n transform: translateY(-50%) translateX(-100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-right: 10px solid ${s};\n }\n @media (max-width: ${o}px) {\n ${r}.gist-tooltip-frame {\n max-width: 100%;\n }\n }\n </style>\n <div class="gist-tooltip-container">\n <div class="gist-tooltip-arrow ${a}"></div>\n <div class="gist-tooltip-frame-clip">\n <iframe id="${e}" class="gist-tooltip-frame" src="${n}"></iframe>\n </div>\n </div>\n </div>`}(s,a,e,l),document.body.appendChild(c),me(s,n,i)}(a,e,s,n):t?(G.includes(t)&&V(t),function(e,t,n,o,s=null){const a=_(e);if(a){const i=xe(n.instanceId??"");a.classList.add(i);const r=j(n);let l=r.messageWidth+"px";X.includes(e)&&!r.hasCustomWidth&&(l="100%"),G.includes(e)&&(a.style.width=l),ge(e)||(a.style.height="0px"),a.innerHTML=function(e,t,n){return function(e,t,n){let i=800;return t.messageWidth>i&&(i=t.messageWidth),`\n <div id="gist-embed">\n <style>\n #x-gist-floating-top, #x-gist-floating-top-left, #x-gist-floating-top-right {\n position: fixed;\n top: 0px;\n z-index: 1000000;\n }\n #x-gist-floating-bottom, #x-gist-floating-bottom-left, #x-gist-floating-bottom-right {\n position: fixed;\n bottom: 0px;\n z-index: 1000000;\n }\n #x-gist-bottom, #x-gist-top, #x-gist-floating-top, #x-gist-floating-bottom {\n left: 50%;\n transform: translate(-50%, 0%);\n }\n #x-gist-floating-top-right, #x-gist-floating-bottom-right {\n right: 0px;\n }\n #gist-embed {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container .gist-frame {\n height: 100%;\n width: 100%;\n border: none;\n }\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${i}px) {\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${e}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(xe(t.instanceId??""),n,e)}(t,n,r),me(i,o,s)}else i(`Message could not be embedded, elementId ${e} not found.`)}(t,a,e,s,n)):function(e,t,n,i=null){document.querySelectorAll("#gist-embed-message").forEach((e=>{e.parentNode?.removeChild(e)})),document.body.insertAdjacentHTML("afterbegin",function(e,t){const n=j(t);return function(e,t,n){let i=600;return t.messageWidth>i&&(i=t.messageWidth),`\n <div id="gist-embed-message">\n <style>\n #gist-overlay.gist-background {\n position: fixed;\n z-index: 9999999998;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: ${t.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.gist-background.gist-visible {\n visibility: visible;\n }\n .gist-message {\n width: ${t.messageWidth}px;\n position: absolute;\n border: none;\n opacity: 0;\n transition: opacity 0.3s ease-in-out, height 0.1s ease-in-out;\n z-index: 9999999999;\n left: 50%;\n transform: translateX(-50%);\n }\n .gist-message.gist-visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.gist-center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.gist-bottom {\n bottom: 0;\n }\n .gist-message.gist-top {\n top: 0;\n }\n @media (max-width: ${i}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="gist-background">\n <iframe id="${e}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(xe(t.instanceId??""),n,e)}(e,t)),me(xe(t.instanceId??""),n,i)}(a,e,s,n),e}async function Nt(e){let t;i(`Message shown, logging view for: ${e.messageId}`),null!=e.queueId?(await Ot(e),t=await H(e.queueId)):t=await async function(e){try{return await $().post(`/api/v1/logs/message/${e}`)}catch(e){return E(e)}}(e.messageId),i(200===t?.status?"Message view logged":`Problem logging message: ${t?.status}`)}function Dt(){}async function qt(e){const t=e.data;if(t.gist&&e.origin===S.RENDERER_HOST){const e=t.gist.instanceId,n=J(e);if(!n)return;const o=j(n);switch(t.gist.method){case"routeLoaded":{const s=.001*((new Date).getTime()-(n.renderStartTime??0));if(i(`Engine render for message: ${n.messageId} timer elapsed in ${s.toFixed(3)} seconds`),async function(e){const t=await We(e);t&&r(t)}(n.queueId??""),n.currentRoute=t.gist.parameters.route,t.gist.parameters.fullDisplaySettings&&!n.displaySettings?n.displaySettings=t.gist.parameters.fullDisplaySettings:n.displaySettings&&(i("SDK already has display settings state, sending it to iframe"),he(n)),Kt.config.isPreviewSession&&n.properties?.gist?.livePreview&&function(e){Ze=!1,Xe=e.instanceId??null;const t=e.displaySettings;if(Array.isArray(t)&&t.length>0?(Je=t,Qe||(Qe=Je[0].stepName,Ye={...Je[0].displaySettings})):t&&"object"==typeof t&&!Array.isArray(t)&&(Ye={...t}),ot||st){const e=!!ot,t=!!st,n=ot,o=st;if(ot=null,st=null,e){const e=Je.find((e=>e.stepName===n));if(!e)return i(`Preview bar: step "${n}" not found, ignoring initial step/display override`),void bt();Qe=e.stepName,Ye={...e.displaySettings}}if(t){if(!e)return i(`Preview bar: display type "${o}" provided without a step, ignoring`),void bt();Ye={...Ye,displayType:o}}bt();const s=Kt.currentMessages.find((e=>e.instanceId===Xe));s&&ut(Ye)?Wt(s,Qe,Ye):function(){const e=Ye.displayType;if("inline"!==e&&"tooltip"!==e)return;const t=document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");t&&yt(t)}()}else bt()}(n),n.firstLoad||n.isDisplayChange){if("tooltip"===te(n)){const e=n.properties?.gist?.elementId||n.elementId||void 0;if(!e||!_(e)){i(`Tooltip target not found for "${e}", emitting error and skipping display`),Kt.messageError(n),n.firstLoad=!1,n.isDisplayChange=!1,Pt(n);break}const t=await async function(e){const t=e.instanceId??"",n=j(e),o=_(`gist-tooltip-${t}`);if(!o)return i(`Tooltip wrapper not found for instance ${t}`),!1;const s=e.properties?.gist?.elementId||e.elementId||void 0;if(!s)return i(`No target selector for tooltip ${t}`),!1;const a=be.get(t);a&&(a.cleanup(),be.delete(t));const r=o.querySelector(".gist-tooltip-outer");if(!r)return i(`Tooltip inner element not found for instance ${t}`),!1;const l=n.tooltipPosition||"bottom";if(!await async function(e,t,n){const o=re(t);if(!o)return!1;let s=[];try{s=pe(o)}catch{}if(le(o.getBoundingClientRect(),s))return!0;if(!function(e,t,n){const i=re(t);if(!i)return!1;const o=i.getBoundingClientRect(),s=window.innerWidth,a=window.innerHeight,r=new DOMRect(Math.max(0,(s-o.width)/2),Math.max(0,(a-o.height)/2),o.width,o.height);return e.style.display="",null!==de(e.getBoundingClientRect(),r,n)}(e,t,n))return i(`Preflight failed: tooltip would not fit after scrolling target "${t}" into view`),!1;o.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),await function(e){return new Promise((t=>{let n=e.getBoundingClientRect(),i=0;const o=Date.now();setTimeout((function s(){const a=e.getBoundingClientRect();Math.abs(a.top-n.top)<1&&Math.abs(a.left-n.left)<1?i++:i=0,n=a,i>=2||Date.now()-o>1e3?t():setTimeout(s,50)}),50)}))}(o);const a=o.getBoundingClientRect();let r=[];try{r=pe(o)}catch{}return le(a,r)}(r,s,l))return i(`Tooltip for instance ${t} skipped: target "${s}" is off-screen and cannot be scrolled into a valid position`),!1;const c=function(e,t,n){const o=re(t);if(!o)return null;let s=null,a=!1,r=[];try{r=pe(o)}catch{}function l(){if(a)return;if(!o||!document.contains(o)||!document.contains(e))return i("Tooltip or target element removed from DOM, cleaning up listeners"),void d();const t=o.getBoundingClientRect();if(!le(t,r))return void(e.style.display="none");e.style.display="";const s=de(e.getBoundingClientRect(),t,n);s?(function(e,t){e.style.position="absolute",e.style.top=`${t.top+window.scrollY}px`,e.style.left=`${t.left+window.scrollX}px`}(e,s),function(e,t){const n=e.querySelector(".gist-tooltip-arrow");n&&(n.classList.remove("gist-arrow-top","gist-arrow-bottom","gist-arrow-left","gist-arrow-right"),n.classList.add(ae[t.position]),null!==t.arrowOffset?"top"===t.position||"bottom"===t.position?(n.style.left=`calc(50% + ${t.arrowOffset}px)`,n.style.removeProperty("top")):(n.style.top=`calc(50% + ${t.arrowOffset}px)`,n.style.removeProperty("left")):"top"===t.position||"bottom"===t.position?(n.style.left="50%",n.style.removeProperty("top")):(n.style.top="50%",n.style.removeProperty("left")))}(e,s)):e.style.display="none"}function c(){null===s&&(s=requestAnimationFrame((()=>{s=null,l()})))}function d(){if(!a){a=!0,window.removeEventListener("scroll",c),window.removeEventListener("resize",c);for(const e of r)e.removeEventListener("scroll",c);null!==s&&(cancelAnimationFrame(s),s=null)}}if(l(),a)return null;window.addEventListener("scroll",c,{passive:!0}),window.addEventListener("resize",c,{passive:!0});for(const e of r)e.addEventListener("scroll",c,{passive:!0});return{cleanup:d,reposition:l}}(r,s,l);if(c){if("none"!==r.style.display){const e=o.querySelector(".gist-tooltip-container");return e?(be.set(t,c),e.classList.add("gist-visible"),!0):(c.cleanup(),i(`Tooltip container not found for instance ${t}`),!1)}return c.cleanup(),i(`Tooltip for instance ${t} could not be positioned within the viewport, target "${s}" may be off-screen`),!1}return i(`Failed to position tooltip for instance ${t}, target "${s}" may not exist or no position fits the viewport`),!1}(n);if(!t){i(`Tooltip positioning failed for "${e}", emitting error and cleaning up`),Kt.messageError(n),n.firstLoad=!1,n.isDisplayChange=!1,Pt(n);break}}else n.overlay?function(e){const t=j(e),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");const i=document.querySelector(".gist-message");i&&(e.position?i.classList.add("gist-"+e.position):i.classList.add("gist-center")),setTimeout(Se,100),t.exitClick&&setTimeout((()=>function(e){const t=document.querySelector("#gist-overlay");t&&t.addEventListener("click",(()=>{Kt.dismissMessage(e)}))}(e.instanceId??"")),1e3)}else ye()}(n):function(e){const t=_(e);t&&t.classList.add("gist-visible")}(n.elementId);n.firstLoad&&!n.isDisplayChange&&(Kt.messageShown(n),o.persistent?i("Persistent message shown, skipping logging view"):await Nt(n)),n.firstLoad=!1,n.isDisplayChange=!1}Z(e,n);break}case"tap":{const e=t.gist.parameters.action,i=t.gist.parameters.name;if(Kt.messageAction(n,e,i),t.gist.parameters.system&&!o.persistent){await Et(n);break}try{const t=new URL(e);if(t&&"gist:"===t.protocol)switch(t.href.replace("gist://","").split("?")[0]){case"close":await Ct(n),await Ut(n),await Et(n),await Xt();break;case"showMessage":{const e=t.searchParams.get("messageId"),n=t.searchParams.get("properties");if(e){const t=n?JSON.parse(atob(n)):void 0;await Kt.showMessage({messageId:e,properties:t})}break}case"loadPage":{const e=t.href.substring(t.href.indexOf("?url=")+5);e&&(e.startsWith("mailto:")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("/")?window.location.href=e:window.location.href=window.location+e);break}}}catch{}break}case"changeMessageStep":{const e=t.gist.parameters.displaySettings,r=t.gist.parameters.messageStepName;Kt.config.isPreviewSession&&r&&n.properties?.gist?.livePreview&&function(e,t){Qe=e;const n=Je.find((t=>t.stepName===e));n?Ye={...n.displaySettings}:t&&(Ye={...t}),bt()}(r,e),(o.persistent||Te(n))&&await async function(e,t,n){const o=await Oe(e);if(!o)return;const r=a(o)||{},l={stepName:void 0!==t?t:r.stepName,displaySettings:void 0!==n?n:r.displaySettings},c=new Date;c.setDate(c.getDate()+30),s(o,l,c),i(`Saved message state for queueId: ${e}`)}(n.queueId??"",r,e),e&&ne(n,e)&&(i("Display settings changed, reloading message"),await At(n),ie(n,e),await Rt(n,r??null));break}case"routeChanged":n.currentRoute=t.gist.parameters.route,n.renderStartTime=(new Date).getTime(),Z(e,n),i(`Route changed to: ${n.currentRoute}`);break;case"sizeChanged":i(`Size Changed Width: ${t.gist.parameters.width} - Height: ${t.gist.parameters.height}`),"tooltip"===te(n)?function(e,t){const n=e.instanceId??"",i=xe(n),o=document.getElementById(i);if(o&&t.height>0){o.style.height=`${t.height}px`;const e=be.get(n);e&&e.reposition()}}(n,t.gist.parameters):n.elementId&&!n.shouldResizeHeight||function(e,t){const n=_(e.elementId?e.elementId:xe(e.instanceId??""));if(n){const i=n.style;if(t.height>0)if(t.height>window.innerHeight){const n=1-(t.height/window.innerHeight-1);e.shouldScale&&n>=.4?(i.height=`${t.height}px`,i.transform=`translateX(-50%) translateY(-50%) scale(${n})`):i.height=`${window.innerHeight}px`}else i.height=`${t.height}px`}}(n,t.gist.parameters);break;case"titleChanged":i(`Overlay title changed to: ${t.gist.parameters.title}`),function(e,t){const n=_(xe(e));n&&(n.title=t)}(e,t.gist.parameters.title);break;case"eventDispatched":Kt.events.dispatch("eventDispatched",{name:t.gist.parameters.name,payload:t.gist.parameters.payload});break;case"error":case"routeError":Kt.messageError(n),"tooltip"===te(n)?Pt(n):Kt.overlayInstanceId?await Tt(!1,n):kt(n)}}}async function Rt(e,t){e.isDisplayChange=!0,e.renderStartTime=(new Date).getTime();const n=te(e),o=e.elementId||null;if("tooltip"===n)return Kt.overlayInstanceId===e.instanceId&&(Kt.overlayInstanceId=null),e.shouldScale=!1,e.shouldResizeHeight=!1,void Mt(e,null,t);if(o){const t=Q(o);t&&t.instanceId!==e.instanceId&&(i(`Dismissing existing message at ${o} to make room for multi-step message`),await Et(t))}if(e.overlay){Kt.overlayInstanceId=e.instanceId??null;const t=j(e);e.shouldScale=t.shouldScale,e.shouldResizeHeight=!0}else Kt.overlayInstanceId=null,e.shouldScale=!1,e.shouldResizeHeight=!ge(o??"");o&&G.includes(o)&&V(o),Mt(e,o,t)}async function At(e){"tooltip"===te(e)?ve(e):e.overlay?await we():e.elementId&&ue(e.elementId)}async function Wt(e,t,n){n&&ne(e,n)&&(await At(e),ie(e,n)),await Rt(e,t??null)}async function Ot(e){i(`Logging user message view locally for: ${e.queueId}`),Pe(e)?await async function(e){i(`Marking broadcast ${e} as seen.`);const t=await Le();if(!t)return;const n=await ke(t,e);if(!n)return;const o=n.properties.gist.broadcast,{frequency:r}=o,l=Me(t,e),c=Ne(t,e),d=a(l)||0;if(s(l,d+1),1===r.count)s(c,!1),i(`Marked broadcast ${e} as seen.`);else{const t=new Date;t.setSeconds(t.getSeconds()+r.delay),s(c,!1,t),i(`Marked broadcast ${e} as seen, broadcast was seen ${d+1} times, next show date is ${t}.`)}}(e.queueId??""):await async function(e){const t=await Ae();if(!t)return;const n=a(t)??[];n.push(e),s(t,n)}(e.queueId??"")}async function Ut(e){Pe(e)&&(i(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){i(`Marking broadcast ${e} as dismissed.`);const t=await Le();if(!t)return;const n=await ke(t,e);n&&(!0!==n.properties.gist.broadcast.frequency.ignoreDismiss?(s(Ne(t,e),!1),i(`Marked broadcast ${e} as dismissed and will not show again.`)):i(`Broadcast ${e} is set to ignore dismiss.`))}(e.queueId??""),await Ue(e.queueId??""))}const zt="messageInboxUpdated";async function Bt(e){const t=await _t();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(t,e,n),Kt.events.dispatch(zt,e)}async function Ht(){const e=await _t();if(!e)return[];const t=a(e)??[],n=new Date;return t.filter((e=>!e.expiry||new Date(e.expiry)>n))}async function _t(){const e=await U();return e?`gist.web.inbox.messages.${e}`:null}const Ft=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>Ft(e,t))));let jt=!1,Gt=null;async function Vt(){jt?await Xt():W()?(i("Queue watcher started"),jt=!0,Ft((()=>new Promise((()=>{!async function(){if(S.hasActiveSSEConnection())return!S.isSSEConnectionManagedBySDK()&&Gt&&(i("Not the main instance, closing our SSE connection."),Qt()),void await Xt();Gt&&(i("SSE connection not active, closing it."),Qt()),!S.useSSE()||A()?await Yt():await async function(){Qt();const e=function(){const e=z();return null===e?(i("No user token available for SSE endpoint."),null):S.GIST_QUEUE_REALTIME_API_ENDPOINT[Kt.config.env??"prod"]+`/api/v3/sse?userToken=${e}&siteId=${Kt.config.siteId}&sessionId=${N()}`}();if(null===e)return i("SSE endpoint not available, falling back to polling."),void await Yt();i(`Starting SSE queue listener on ${e}`),Gt=new EventSource(e),S.setActiveSSEConnection(),Gt.addEventListener("connected",(async e=>{try{i("SSE connection received"),S.setUseSSEFlag(!0);const t=JSON.parse(e.data);t.heartbeat&&(S.setSSEHeartbeat(t.heartbeat),i(`SSE heartbeat set to ${t.heartbeat} seconds`)),S.setActiveSSEConnection()}catch(e){i(`Failed to parse SSE settings: ${e}`)}r(L),await Yt()})),Gt.addEventListener("messages",(async e=>{try{const t=JSON.parse(e.data);i("SSE message received"),await qe(t),await Ce(t),await Xt()}catch(e){i(`Failed to parse SSE message: ${e}`),Qt()}})),Gt.addEventListener("inbox_messages",(async e=>{try{const t=JSON.parse(e.data);i("SSE inbox messages received"),await Bt(t)}catch(e){i(`Failed to parse SSE inbox messages: ${e}`)}})),Gt.addEventListener("error",(async()=>{i("SSE error received"),Qt()})),Gt.addEventListener("heartbeat",(async()=>{i("SSE heartbeat received"),S.setActiveSSEConnection(),S.setUseSSEFlag(!0)}))}()}()}))),1e3)):i("User token not setup, queue not started.")}async function Xt(){const e=await async function(){const e=await Le();return e?(a(e)??[]).filter((t=>{const n=t.properties.gist.broadcast,{frequency:i}=n,o=a(Ne(e,t.queueId))??!0,s=a(Me(e,t.queueId))||0,r=0===i.count;return o&&(r||s<i.count)})):[]}(),t=await async function(){const e=await Re();if(!e)return[];const t=a(e)??[],n=await async function(){const e=await Ae();return e?a(e)??[]:[]}();return t.filter((e=>!n.includes(e.queueId??"")))}(),n=e.concat(t);i(`Messages in local queue: ${n.length}`);const o=n.sort(((e,t)=>e.priority-t.priority));for(const e of o)await Jt(e)}async function Jt(e){let t=j(e);if(t.hasRouteRule){let e=Kt.currentRoute;null==e&&(e=new URL(window.location.href).pathname);const n=t.routeRule;if(i(`Verifying route ${e} against rule: ${n}`),!new RegExp(n).test(e))return i(`Route ${e} does not match rule.`),!1}if(t.hasPosition&&(e.position=t.position),t.hasTooltipPosition&&(e.tooltipPosition=t.tooltipPosition),t.persistent||Te(e)){const n=await async function(e){const t=await Oe(e);return t?a(t):null}(e.queueId??"");n&&(i(`Restoring saved state for queueId ${e.queueId}`),n.displaySettings&&(ie(e,n.displaySettings),t=j(e)),e.savedStepName=n.stepName??null)}if(t.persistent||Te(e)||!await async function(e){const t=await We(e);return!!t&&null!==a(t)}(e.queueId??"")){let n=null;return t.isEmbedded?Kt.config.isPreviewSession&&e.properties?.gist?.livePreview&&!_(t.elementId)?(i(`Preview: element "${t.elementId}" not found, showing as overlay so placement can be changed`),n=await St(e)):n=It(e,t.elementId):n=await St(e),n&&async function(e){const t=await We(e);t&&s(t,!0,new Date(Date.now()+5e3))}(e.queueId??""),null!==n}return i(`Not showing message with queueId ${e.queueId} because its already loading.`),!1}async function Yt(){if(W())if(Kt.isDocumentVisible)if(null===a(L)){const e=await async function(){const e=W();let t;try{if(!T){T=!0;const e={"X-Gist-User-Anonymous":String(A()),"Content-Language":String(k())};t=await $().post(`/api/v4/users?sessionId=${N()}`,{},{headers:e})}}catch(e){const n=E(e);n?t=n:i(`Error getting user queue: ${e}`)}finally{T=!1}return e!==W()?(i("User token changed, clearing queue next pull check."),void r(L)):(function(e){if(e?.headers){const t=e.headers["x-gist-queue-polling-interval"];t&&Number(t)>0&&(P=Number(t))}const t=new Date((new Date).getTime()+1e3*P);s(L,P,t)}(t),function(e){const t="true"===e?.headers?.["x-cio-use-sse"]?.toLowerCase();S.setUseSSEFlag(t)}(t),t)}();if(e){if(200===e.status||204===e.status){i("200 response, updating local store.");const t=e.data,n=t?.inAppMessages??[],o=t?.inboxMessages??[];qe(n),Ce(n),Bt(o)}else 304===e.status&&i("304 response, using local store.");await Xt()}else i("No response object returned while checking message queue.")}else i("Next queue pull scheduled for later.");else i("Document not visible, skipping queue check.");else i("User token reset, skipping queue check.")}function Qt(e=!1){e&&S.removeActiveSSEConnection(),(e||S.isSSEConnectionManagedBySDK())&&S.setUseSSEFlag(!1),Gt&&(i("Stopping SSE queue listener..."),Gt.close(),Gt=null)}class Kt{static async setup(e){this.initialized?i("Gist SDK already initialized, skipping setup."):(this.initialized=!0,this.events=new n,this.config={useAnonymousSession:e.useAnonymousSession??!1,siteId:e.siteId,dataCenter:e.dataCenter,env:e.env??"prod",logging:e.logging??!1,experiments:e.experiments??!1},this.currentMessages=[],be.forEach((e=>e.cleanup())),be.clear(),document.querySelectorAll('[id^="gist-tooltip-"]').forEach((e=>{e.parentNode?.removeChild(e)})),this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const e=new URLSearchParams(window.location.search),t=e.get(He);if(t){sessionStorage.setItem(o,String(!1)),Kt.setUserToken(t),i(`Preview mode enabled with user token: ${t}`),function(){if(document.getElementById(Ge))return;!function(){if(document.getElementById(je))return;const e=document.createElement("style");e.id=je,e.textContent=Be,document.head.appendChild(e)}();try{Ke="true"===sessionStorage.getItem(Fe)}catch{Ke=!1}const e=rt("div",{id:Ge});document.body.appendChild(e),bt()}();const n=e.get(_e);if(n)try{const e=JSON.parse(atob(n)),t=e.stepName||null,i=e.displayType||null;(t||i)&&function(e,t){ot=e,st=t}(t,i)}catch{i("Preview bar: failed to parse cioPreviewSettings")}}return!l()}(),function(){const e=c();for(let t=e.length-1;t>=0;t--)d(e.key(t))}(),i(`Setup complete on ${this.config.env} environment.`),this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||O(),await Vt(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await Xt())}),!1))}static async setCurrentRoute(e){this.currentRoute=e,i(`Current route set to: ${e}`),await async function(){if(0!==Kt.currentMessages.length)for(const e of[...Kt.currentMessages])null==document.querySelector(`#gist-${e.instanceId}`)&&(i(`Removing active message ${e.instanceId} that no longer exists after route change`),await $t(e))}(),await Xt()}static async setUserToken(e,t){this.config.isPreviewSession||(function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),s(D,e,t),A()&&(r(L),r(q)),i(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),Qt(!0),await Vt())}static setUserLocale(e){var t;s(C,t=e),i(`Set user locate to "${t}"`)}static setCustomAttribute(e,t){return function(e,t){return e&&"string"==typeof e?(Ee.set(e,t),$e(),i(`Set custom attribute "${e}" to "${t}"`),!0):(i(`Invalid key for custom attribute: ${e}`),!1)}(e,t)}static clearCustomAttributes(){Ee.clear(),r(Ie),i("Cleared all custom attributes")}static removeCustomAttribute(e){return function(e){if(!e||"string"!=typeof e)return i(`Invalid key for custom attribute: ${e}`),!1;const t=Ee.has(e);return Ee.delete(e),Ee.size>0?$e():r(Ie),i(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(B(),this.config.useAnonymousSession&&O(),Qt(!0),await Vt())}static async dismissMessage(e){const t=J(e);t&&(await Ct(t),await Ut(t),await Et(t),await Xt())}static async embedMessage(e,t){return It(e,t)?.instanceId??null}static async showMessage(e){return(await St(e))?.instanceId??null}static updateMessageDisplaySettings(e,t){const n=J(e);return!!n&&(n.displaySettings=t,he(n),!0)}static messageShown(e){i(`Message shown: ${e.messageId}`),this.events.dispatch("messageShown",e)}static messageDismissed(e){null!==e&&(i(`Message dismissed: ${e.messageId}`),this.events.dispatch("messageDismissed",e))}static messageError(e){i(`Message error: ${e.messageId}`),this.events.dispatch("messageError",e)}static messageAction(e,t,n){i(`Message action: ${e.currentRoute}, ${t} with name ${n} on ${e.instanceId}`),this.events.dispatch("messageAction",{message:e,action:t,name:n})}static async getInboxUnopenedCount(){return(await Ht()).filter((e=>!e.opened)).length}static async getInboxMessages(){return await Ht()}static async updateInboxMessageOpenState(e,t){return await async function(e,t){const n=await _t();if(!n)return;const o=await async function(e,t){try{return await $()(`/api/v1/messages/${e}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return E(e)}}(e,{opened:t});if(!o||o.status<200||o.status>=300){const e=`Failed to mark inbox message opened: ${o?.status??"unknown error"}`;throw i(e),new Error(e)}const a=await Ht();let r=null;const l=a.map((n=>{if(n.queueId===e){const e={...n,opened:t};return r=e,e}return n})),c=new Date;if(c.setMinutes(c.getMinutes()+60),s(n,l,c),r){const e=t?"opened":"unopened";Kt.events.dispatch("inboxMessageAction",{message:r,action:e})}Kt.events.dispatch(zt,await Ht())}(e,t)}static async removeInboxMessage(e){return await async function(e){const t=await _t();if(!t)return;const n=await H(e);if(!n||n.status<200||n.status>=300){const e=`Failed to remove inbox message: ${n?.status??"unknown error"}`;throw i(e),new Error(e)}const o=(await Ht()).filter((t=>t.queueId!==e)),a=new Date;a.setMinutes(a.getMinutes()+60),s(t,o,a),Kt.events.dispatch(zt,await Ht())}(e)}}return t.default})(),e.exports=t()}}]);
|
package/dist/umd/573.js.gz
CHANGED
|
Binary file
|
package/dist/umd/inAppPlugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_customerio_cdp_analytics_browser=self.webpackChunk_customerio_cdp_analytics_browser||[]).push([[926],{599:function(e,n,t){t.d(n,{InAppPlugin:function(){return
|
|
1
|
+
"use strict";(self.webpackChunk_customerio_cdp_analytics_browser=self.webpackChunk_customerio_cdp_analytics_browser||[]).push([[926],{599:function(e,n,t){t.d(n,{InAppPlugin:function(){return m}});var i,s=t(5478);!function(e){e.MessageOpened="in-app:message-opened",e.MessageDismissed="in-app:message-dismissed",e.MessageError="in-app:message-error",e.MessageAction="in-app:message-action"}(i||(i={}));var o,r=Object.values(i);!function(e){e.Metric="Report Delivery Event",e.Content="Report Content Event",e.Opened="opened",e.Clicked="clicked",e.ViewedContent="viewed_content",e.ClickedContent="clicked_content"}(o||(o={}));var a="in_app_content";function u(e,n){return new CustomEvent(e,{detail:n})}var d=t(7573),c=t.n(d),l="_cio";function v(e,n,t){var i=this;return{sentAt:new Date(t.sentAt),expiresAt:t.expiry?new Date(t.expiry):void 0,messageId:t.queueId,opened:!0===(null==t?void 0:t.opened),properties:t.properties,type:t.type||"",topics:t.topics||[],trackClick:function(n){void 0!==t.deliveryId&&""!==t.deliveryId&&e.track(o.Metric,{deliveryId:t.deliveryId,metric:o.Clicked,actionName:n})},markOpened:function(){return(0,s.sH)(i,void 0,void 0,(function(){return(0,s.YH)(this,(function(e){switch(e.label){case 0:return[4,n.updateInboxMessageOpenState(t.queueId,!0)];case 1:return e.sent(),[2]}}))}))},markUnopened:function(){return(0,s.sH)(i,void 0,void 0,(function(){return(0,s.YH)(this,(function(e){switch(e.label){case 0:return[4,n.updateInboxMessageOpenState(t.queueId,!1)];case 1:return e.sent(),[2]}}))}))},markDeleted:function(){return(0,s.sH)(i,void 0,void 0,(function(){return(0,s.YH)(this,(function(e){switch(e.label){case 0:return[4,n.removeInboxMessage(t.queueId)];case 1:return e.sent(),[2]}}))}))}}}function p(e,n,t){return(0,s.sH)(this,void 0,Promise,(function(){var i,o;return(0,s.YH)(this,(function(s){switch(s.label){case 0:return(i=t)&&Array.isArray(i)?[3,2]:[4,e.getInboxMessages()];case 1:i=s.sent(),s.label=2;case 2:return i&&Array.isArray(i)?(i=i.slice().sort((function(e,n){return new Date(n.sentAt).getTime()-new Date(e.sentAt).getTime()})),0===n.length?[2,i.filter((function(e){var n=e.topics;return!n||0===n.length||!n.some((function(e){return e.startsWith(l)}))}))]:(o=n.some((function(e){return e.startsWith(l)})),[2,i.filter((function(e){var t=e.topics;return!(!t||0===t.length)&&(!(!o&&t.some((function(e){return e.startsWith(l)})))&&t.some((function(e){return n.includes(e)})))}))])):[2,[]]}}))}))}function f(e,n,t){var i=this;return{total:function(){return(0,s.sH)(i,void 0,void 0,(function(){return(0,s.YH)(this,(function(e){switch(e.label){case 0:return[4,p(n,t,null)];case 1:return[2,e.sent().length]}}))}))},totalUnopened:function(){return(0,s.sH)(i,void 0,void 0,(function(){return(0,s.YH)(this,(function(e){switch(e.label){case 0:return[4,p(n,t,null)];case 1:return[2,e.sent().filter((function(e){return!0!==(null==e?void 0:e.opened)})).length]}}))}))},messages:function(){return(0,s.sH)(i,void 0,Promise,(function(){return(0,s.YH)(this,(function(i){switch(i.label){case 0:return[4,p(n,t,null)];case 1:return[2,i.sent().map((function(t){return v(e,n,t)}))]}}))}))},onUpdates:function(o){var r=function(r){return(0,s.sH)(i,void 0,void 0,(function(){var i,a,u;return(0,s.YH)(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,p(n,t,r)];case 1:return i=s.sent(),a=i.map((function(t){return v(e,n,t)})),o(a),[3,3];case 2:return u=s.sent(),console.error("Error processing inbox updates:",u),[3,3];case 3:return[2]}}))}))};return n.events.on("messageInboxUpdated",r),function(){n.events.off("messageInboxUpdated",r)}}}}function m(e){var n,t=this,d=!1,l=!1,v=new EventTarget;function p(){return(0,s.sH)(this,void 0,void 0,(function(){var e;return(0,s.YH)(this,(function(t){switch(t.label){case 0:return(e=n.user().anonymousId())?[4,c().setCustomAttribute("cio_anonymous_id",e)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))}function m(){d&&!l&&(n.on("reset",g),e.events&&(r.forEach((function(n){v.addEventListener(n,null==e?void 0:e.events)})),["messageDismissed","messageError"].forEach((function(e){c().events.on(e,(function(n){var t,s;v.dispatchEvent(u(function(e){switch(e){case"messageShown":return i.MessageOpened;case"messageDismissed":return i.MessageDismissed;case"messageError":return i.MessageError;case"messageAction":return i.MessageAction;default:return""}}(e),{messageId:n.messageId,deliveryId:null===(s=null===(t=n.properties)||void 0===t?void 0:t.gist)||void 0===s?void 0:s.campaignId}))}))}))),c().events.on("messageShown",(function(t){var s,r,d,l,p,f,m,g,h,I,b,y=null===(r=null===(s=null==t?void 0:t.properties)||void 0===s?void 0:s.gist)||void 0===r?void 0:r.campaignId;if(e.events&&v.dispatchEvent(u(i.MessageOpened,{messageId:null==t?void 0:t.messageId,deliveryId:y,message:{dismiss:function(){c().dismissMessage(null==t?void 0:t.instanceId)}}})),void 0===y||""===y){var w=null===(p=null===(l=null===(d=null==t?void 0:t.properties)||void 0===d?void 0:d.gist)||void 0===l?void 0:l.broadcast)||void 0===p?void 0:p.broadcastIdInt;if(w||(w=null===(g=null===(m=null===(f=null==t?void 0:t.properties)||void 0===f?void 0:f.gist)||void 0===m?void 0:m.broadcast)||void 0===g?void 0:g.broadcastId),w){var k=null===(b=null===(I=null===(h=null==t?void 0:t.properties)||void 0===h?void 0:h.gist)||void 0===I?void 0:I.broadcast)||void 0===b?void 0:b.templateId;n.track(o.Content,{actionType:o.ViewedContent,contentId:w,templateId:k,contentType:a})}}else n.track(o.Metric,{deliveryId:y,metric:o.Opened})})),c().events.on("inboxMessageAction",(function(e){var t,i,s,r;(null==e?void 0:e.message)&&""!==(null==e?void 0:e.action)&&(t=n,i=e.message,s=e.action,r=null==i?void 0:i.deliveryId,"opened"===s&&void 0!==r&&""!==r&&t.track(o.Metric,{deliveryId:i.deliveryId,metric:o.Opened}))})),c().events.on("messageAction",(function(t){var s,r,d,l,p,f,m,g,h,I,b,y,w,k,C,H=null===(d=null===(r=null===(s=null==t?void 0:t.message)||void 0===s?void 0:s.properties)||void 0===r?void 0:r.gist)||void 0===d?void 0:d.campaignId;if(e.events&&v.dispatchEvent(u(i.MessageAction,{messageId:t.message.messageId,deliveryId:H,action:t.action,name:t.name,actionName:t.name,actionValue:t.action,message:{dismiss:function(){c().dismissMessage(t.message.instanceId)}}})),"gist://close"!==t.action)if(void 0===H||""===H){var A=null===(m=null===(f=null===(p=null===(l=null==t?void 0:t.message)||void 0===l?void 0:l.properties)||void 0===p?void 0:p.gist)||void 0===f?void 0:f.broadcast)||void 0===m?void 0:m.broadcastIdInt;if(A||(A=null===(b=null===(I=null===(h=null===(g=null==t?void 0:t.message)||void 0===g?void 0:g.properties)||void 0===h?void 0:h.gist)||void 0===I?void 0:I.broadcast)||void 0===b?void 0:b.broadcastId),A){var M=null===(C=null===(k=null===(w=null===(y=null==t?void 0:t.message)||void 0===y?void 0:y.properties)||void 0===w?void 0:w.gist)||void 0===k?void 0:k.broadcast)||void 0===C?void 0:C.templateId;n.track(o.Content,{actionType:o.ClickedContent,contentId:A,templateId:M,contentType:a,actionName:t.name,actionValue:t.action})}}else n.track(o.Metric,{deliveryId:H,metric:o.Clicked,actionName:t.name,actionValue:t.action})})),c().events.on("eventDispatched",(function(e){var t,i,s;if("analytics:track"===e.name){var o=null===(t=e.payload)||void 0===t?void 0:t.event;if(void 0===o||""===o)return;n.track(o,null===(i=e.payload)||void 0===i?void 0:i.properties,null===(s=e.payload)||void 0===s?void 0:s.options)}})))}function g(e){return(0,s.sH)(this,void 0,Promise,(function(){return(0,s.YH)(this,(function(n){switch(n.label){case 0:return[4,c().clearUserToken()];case 1:return n.sent(),[4,c().clearCustomAttributes()];case 2:return n.sent(),[4,p()];case 3:return n.sent(),[2,e]}}))}))}function h(e){return(0,s.sH)(this,void 0,Promise,(function(){var t;return(0,s.YH)(this,(function(i){switch(i.label){case 0:return d?"string"==typeof(t=n.user().id())&&t.length>0?[4,c().setUserToken(t)]:[3,2]:[2,e];case 1:return i.sent(),[3,4];case 2:return[4,c().clearUserToken()];case 3:i.sent(),i.label=4;case 4:return[2,e]}}))}))}var I={name:"Customer.io In-App Plugin",type:"before",version:"0.0.1",isLoaded:function(){return l},load:function(i,o){return(0,s.sH)(t,void 0,void 0,(function(){return(0,s.YH)(this,(function(t){switch(t.label){case 0:return n=o,null==e.siteId||""===e.siteId?(s="siteId is required. Can't initialize.",console.error("[Customer.io In-App Plugin] ".concat(s)),[2,i]):[4,p()];case 1:return t.sent(),[4,c().setup({siteId:e.siteId,env:e._env?e._env:"prod",logging:e._logging,useAnonymousSession:e.anonymousInApp})];case 2:return t.sent(),d=!0,[4,h(i)];case 3:return t.sent(),m(),o.inbox=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(!l)throw new Error("Customer.io In-App Plugin is not loaded yet. Ensure the plugin is initialized before calling inbox().");return f(o,c(),e)},l=!0,[2,Promise.resolve()]}var s}))}))},identify:h,page:function(e){var n,t,i,s,o;if(!l)return e;var r=null!==(i=null===(t=null===(n=e.event)||void 0===n?void 0:n.properties)||void 0===t?void 0:t.name)&&void 0!==i?i:null===(o=null===(s=e.event)||void 0===s?void 0:s.properties)||void 0===o?void 0:o.url;return"string"==typeof r&&r.length>0&&c().setCurrentRoute(r),e},unload:function(){e.events&&r.forEach((function(n){v.removeEventListener(n,null==e?void 0:e.events)}))}};return I}}}]);
|
|
Binary file
|