@customerio/cdp-analytics-browser 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // This file is generated.
5
- exports.version = '0.4.0';
5
+ exports.version = '0.4.2';
6
6
  //# sourceMappingURL=version.js.map
@@ -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;AA0FzC,SAAS,kBAAkB,CACzB,iBAA4B,EAC5B,IAAS,EACT,WAA6B;IAH/B,iBAiCC;IA5BC,OAAO;QACL,MAAM,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;QACpC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;QACxE,SAAS,EAAE,WAAW,CAAC,OAAO;QAC9B,MAAM,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,MAAK,IAAI;QACpC,UAAU,EAAE,WAAW,CAAC,UAAU;QAClC,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,EAAE;QAC5B,MAAM,EAAE,WAAW,CAAC,MAAM,IAAI,EAAE;QAChC,UAAU,EAAE,UAAC,eAAwB;YACnC,IAAG,OAAO,WAAW,CAAC,UAAU,KAAK,WAAW,IAAI,WAAW,CAAC,UAAU,KAAK,EAAE,EAAE;gBACjF,OAAM;aACP;YACD,KAAK,iBAAiB,CAAC,KAAK,CAAC,uBAAc,CAAC,MAAM,EAAE;gBAClD,UAAU,EAAE,WAAW,CAAC,UAAU;gBAClC,MAAM,EAAE,uBAAc,CAAC,OAAO;gBAC9B,UAAU,EAAE,eAAe;aAC5B,CAAC,CAAA;QACJ,CAAC;QACD,UAAU,EAAE;;;4BACV,qBAAM,IAAI,CAAC,2BAA2B,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,EAAA;;wBAAjE,SAAiE,CAAA;;;;aAClE;QAC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,OAAO,CAAC,CAAA;YAE9C,8BAA8B;YAC9B,OAAO;gBACL,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAA;YACjD,CAAC,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AA1CD,wCA0CC"}
@@ -1,3 +1,3 @@
1
1
  // This file is generated.
2
- export var version = '0.4.0';
2
+ export var version = '0.4.2';
3
3
  //# sourceMappingURL=version.js.map
@@ -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;AA0FzC,SAAS,kBAAkB,CACzB,iBAA4B,EAC5B,IAAS,EACT,WAA6B;IAH/B,iBAiCC;IA5BC,OAAO;QACL,MAAM,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;QACpC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;QACxE,SAAS,EAAE,WAAW,CAAC,OAAO;QAC9B,MAAM,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,MAAK,IAAI;QACpC,UAAU,EAAE,WAAW,CAAC,UAAU;QAClC,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,EAAE;QAC5B,MAAM,EAAE,WAAW,CAAC,MAAM,IAAI,EAAE;QAChC,UAAU,EAAE,UAAC,eAAwB;YACnC,IAAG,OAAO,WAAW,CAAC,UAAU,KAAK,WAAW,IAAI,WAAW,CAAC,UAAU,KAAK,EAAE,EAAE;gBACjF,OAAM;aACP;YACD,KAAK,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE;gBAClD,UAAU,EAAE,WAAW,CAAC,UAAU;gBAClC,MAAM,EAAE,cAAc,CAAC,OAAO;gBAC9B,UAAU,EAAE,eAAe;aAC5B,CAAC,CAAA;QACJ,CAAC;QACD,UAAU,EAAE;;;4BACV,qBAAM,IAAI,CAAC,2BAA2B,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,EAAA;;wBAAjE,SAAiE,CAAA;;;;aAClE;QACD,YAAY,EAAE;;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,EAAE,OAAO,CAAC,CAAA;YAE9C,8BAA8B;YAC9B,OAAO;gBACL,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAA;YACjD,CAAC,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -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.0";
79
+ readonly VERSION = "0.4.2";
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.0";
1
+ export declare const version = "0.4.2";
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;AAGhD,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,O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AAC,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 j={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 B(e){const t=j,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 F=["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&&F.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=B(e);switch(i){case"modal":{if((e.position||"center")!==(t.modalPosition||"center"))return!0;const n=t.dismissOutsideClick??j.exitClick;if(o.exitClick!==n)return!0;const s=t.overlayColor??j.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??j.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,je=5,Be=null,Fe=!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(Fe)return;Fe=!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),Fe=!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 ${je}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,je=5,at(),Be&&clearInterval(Be),Be=setInterval((()=>{je-=1,je<=0?(clearInterval(Be),Be=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=B(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?B(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?(F.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=B(n);let l=r.messageWidth+"px";G.includes(e)&&!r.hasCustomWidth&&(l="100%"),F.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=B(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=B(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=B(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=B(e);e.shouldScale=t.shouldScale,e.shouldResizeHeight=!0}else Ot.overlayInstanceId=null,e.shouldScale=!1,e.shouldResizeHeight=!ne(n??"");n&&F.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=B(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=B(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 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:()=>Ut});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){Ut.config&&Ut.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[Ut.config.env??"prod"],t={"X-CIO-Site-Id":Ut.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)}function _(){r(D),s("Cleared user token")}async function F(e){try{return await C().post(`/api/v1/logs/queue/${e}`)}catch(e){return E(e)}}const j={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 B(e){const t=j,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 H=["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 G(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 V=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function J(e){return Ut.currentMessages.find((t=>t.instanceId===e))}function X(e){return!!e&&Ut.currentMessages.some((t=>t.queueId===e))}function Q(e){return e?Ut.currentMessages.find((t=>t.elementId===e))??null:null}function K(e){Ut.currentMessages=Ut.currentMessages.filter((t=>t.instanceId!==e))}function Y(e,t){K(e),Ut.currentMessages.push(t)}function Z(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 ee(e,t){const n=(s=e).tooltipPosition?"tooltip":s.overlay?"modal":s.elementId&&H.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=B(e);switch(i){case"modal":{if((e.position||"center")!==(t.modalPosition||"center"))return!0;const n=t.dismissOutsideClick??j.exitClick;if(o.exitClick!==n)return!0;const s=t.overlayColor??j.overlayColor;if(o.overlayColor!==s)return!0;break}case"overlay":{const n=Z(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||!V.includes(Z(t.overlayPosition))){const e=t.maxWidth??j.messageWidth;if(o.messageWidth!==e)return!0}return!1}function te(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=Z(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&&V.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 ne(e){const t=ue(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 se(e){const t=ue(e);if(t)return!(!t.style||!t.style.height||"0px"===t.style.height)}function ie(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:oe};n&&(t.stepId=n),s.contentWindow.postMessage(e,"*")}}(e,t,n)})}const oe=["MultiStepDisplayTypes"];function ae(e){if(!e.displaySettings)return;const t=ce(e.instanceId??""),n=document.getElementById(t);n?.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:e.displaySettings},"*")}async function re(){const e=document.querySelector(".gist-message");e&&(e.classList.remove("gist-visible"),await new Promise((e=>setTimeout(e,300)))),le()}function le(){const e=document.querySelector("#gist-embed-message");e&&e.parentNode?.removeChild(e)}function ce(e){return`gist-${e}`}function de(){const e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}function ue(e){try{return(document.getElementById(e)??document.querySelector(e))||null}catch{return null}}new Map;const pe="gist.web.customAttributes";let ge=new Map;function me(){const e=Array.from(ge.entries()),t=new Date;t.setDate(t.getDate()+30),o(pe,e,t),s(`Saved ${ge.size} custom attributes to storage with TTL of 30 days`)}async function fe(e){const t=await we();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),o(t,e.filter(ye),n)}async function he(e,t){return a(e)?.find((e=>e.queueId===t))}function ye(e){return!(!e.properties?.gist||!e.properties.gist.broadcast)}function be(e){if(!ye(e))return!1;const t=e.properties.gist.broadcast;return 0===t.frequency.delay&&0===t.frequency.count}async function we(){const e=await U();return e?`gist.web.message.broadcasts.${e}`:null}function ve(e,t){return`${e}.${t}.numberOfTimesShown`}function xe(e,t){return`${e}.${t}.shouldShow`}!function(){const e=a(pe);if(e)try{ge=new Map(e)}catch{ge=new Map}else ge=new Map}();const Se="gist.web.message.user";async function Ie(e){const t=await Ee();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 Ee(){const e=await U();return e?`${Se}.${e}`:null}async function Ce(){const e=await U();return e?`${Se}.${e}.seen`:null}async function ke(e){const t=await U();return t?`${Se}.${t}.message.${e}.loading`:null}async function $e(e){const t=await U();return t?`${Se}.${t}.message.${e}.state`:null}async function Pe(e){const t=await $e(e);t&&(r(t),s(`Cleared message state for queueId: ${e}`))}function Te(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 Le=`\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(Te("#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`,Ne="cioPreviewId",Me="cioPreviewSettings",De="gist.previewBar.collapsed",qe="gist-pb-styles",Re="gist-preview-bar",Ae={topLeft:"Top Left",topCenter:"Top Center",topRight:"Top Right",bottomLeft:"Bottom Left",bottomCenter:"Bottom Center",bottomRight:"Bottom Right"};let We=null,Oe=[],Ue={},ze=null,_e=!1,Fe=!1,je=5,Be=null,He=!1,Ge=null,Ve=null,Je=null;const Xe=new Map;function Qe(e,t={}){const n=document.createElement(e);for(const[e,s]of Object.entries(t))n[e]=s;return n}function Ke(e,t){const n=Qe("div",{className:"gist-pb-label-group"});return n.appendChild(Qe("span",{className:"gist-pb-label",textContent:e})),n.appendChild(t),n}function Ye(e,t){const n=Qe("select",{className:"gist-pb-select"});for(const s of e){const e=Qe("option",{value:s.value,textContent:s.label});s.value===t&&(e.selected=!0),n.appendChild(e)}return n}function Ze(e,t,n){const s=Qe("input",{className:"gist-pb-input",type:e,value:String(t)});return n&&(s.style.width=n),s}function et(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 tt(e){return!!("inline"!==e.displayType&&"tooltip"!==e.displayType||e.elementSelector?.trim())}function nt(e){if("overlay"===e.displayType&&V.includes(Z(e.overlayPosition))){const{maxWidth:t,...n}=e;e=n}if(Ue=e,ze){const t=Oe.findIndex((e=>e.stepName===ze));-1!==t&&(Oe[t]={...Oe[t],displaySettings:{...e}})}if(!We)return;const t=Ut.currentMessages.find((e=>e.instanceId===We));t&&tt(e)&&(ae(t),ee(t,e)&&Et(t,ze,e)),function(){const e=new URLSearchParams(window.location.search).get(Ne);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,Oe).then((e=>{e&&404===e.status&&We&&Ut.dismissMessage(We)})).catch((()=>s("Failed to persist preview display settings")))}()}function st(e){if(!e)return null;try{return document.getElementById(e)??document.querySelector(e)}catch{return null}}function it(e){if(!e||Xe.has(e))return;const t=st(e);t&&Xe.set(e,t.innerHTML)}function ot(e){const t=Xe.get(e);if(void 0===t)return;const n=st(e);n&&(n.innerHTML=t)}function at(e){if(He)return;He=!0;const t={...Ue},n=Ut.currentMessages.find((e=>e.instanceId===We))??null;n&&It(n),Ue.elementSelector&&ot(Ue.elementSelector);const i=Qe("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(),Ue=t,ze){const e=Oe.findIndex((e=>e.stepName===ze));-1!==e&&(Oe[e]={...Oe[e],displaySettings:{...t}})}n&&tt(t)&&Et(n,ze,t),rt()}},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(Re)?.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,it(t);const i=Ue.elementSelector,a={...Ue,elementSelector:t},r=null!=n&&tt(a)&&ee(n,a);nt(a),i&&i!==t&&ot(i),n&&!r&&Et(n,ze,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),He=!1,Ge=null};Ge=c,i.addEventListener("mousemove",a),i.addEventListener("click",l),document.addEventListener("keydown",r),document.body.appendChild(i)}function rt(){const e=document.getElementById(Re);if(!e)return;if(e.classList.toggle("gist-pb-hidden",!We&&!Fe),e.innerHTML="",!We){if(Fe){const t=Qe("div",{className:"gist-pb-controls-row gist-pb-ended-row"}),n=Qe("span",{className:"gist-pb-ended-icon",textContent:"✓"}),s=Qe("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 ${je}s…`,t.appendChild(n),t.appendChild(s),e.appendChild(t)}return}const t=Qe("div",{className:"gist-pb-toggle-row"+(_e?" gist-pb-toggle-row--collapsed":"")}),n=Qe("button",{className:"gist-pb-toggle-btn"}),s=_e?"transform:rotate(180deg);display:inline-flex;":"display:inline-flex;";if(n.innerHTML=`${_e?"Expand":"Collapse"}<span style="${s}">${Te("white")}</span>`,n.addEventListener("click",lt),t.appendChild(n),e.appendChild(t),_e)return;const i=Qe("div",{className:"gist-pb-controls-row"});if(Oe.length>0){const e=ze??Oe[0].stepName,t=Ye(Oe.map((e=>({value:e.stepName,label:e.stepName}))),e);t.addEventListener("change",(()=>{const e=Oe.find((e=>e.stepName===t.value));if(e){ze=e.stepName,Ue={...e.displaySettings};const t=Ut.currentMessages.find((e=>e.instanceId===We));t&&tt(e.displaySettings)&&Et(t,e.stepName,e.displaySettings),rt()}})),i.appendChild(Ke("Step",t))}const o=Ye([{value:"modal",label:"Modal"},{value:"overlay",label:"Overlay"},{value:"inline",label:"Inline"}],Ue.displayType||"modal");o.addEventListener("change",(()=>{const e=o.value,t=Ue.displayType,n=Ue.elementSelector,s={...Ue,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),Ue=s,nt(Ue),"inline"!==t&&"tooltip"!==t||!n||"inline"===e||"tooltip"===e||ot(n),rt()})),i.appendChild(Ke("Display Type",o));const a=Ue.displayType||"modal";"modal"===a?function(e,t){const n=Ye([{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}],e.modalPosition||"center");n.addEventListener("change",(()=>nt({...Ue,modalPosition:n.value}))),t.appendChild(Ke("Position",n));const s=Ze("number",e.maxWidth??414,"80px");s.addEventListener("change",(()=>nt({...Ue,maxWidth:parseInt(s.value)||414}))),t.appendChild(Ke("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=Qe("div",{className:"gist-pb-color-control"}),i=Qe("input",{className:"gist-pb-color-input",type:"color",value:t}),o=Qe("div",{className:"gist-pb-color-swatch"});o.style.background=t,o.appendChild(i),o.addEventListener("click",(()=>i.click()));const a=Qe("input",{className:"gist-pb-color-hex",type:"text",maxLength:6,value:t.replace("#","")}),r=Qe("input",{className:"gist-pb-color-opacity",type:"number",min:"0",max:"100",value:String(n)}),l=Qe("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,nt({...Ue,overlayColor:et(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),Ke("Overlay Color",s)}(e));const i=Qe("div",{className:"gist-pb-checkbox-row"}),o=Qe("input",{className:"gist-pb-checkbox",type:"checkbox"});o.checked=e.dismissOutsideClick??!1;const a=Qe("label",{className:"gist-pb-checkbox-label",textContent:"Dismiss on click outside"});o.addEventListener("change",(()=>nt({...Ue,dismissOutsideClick:o.checked}))),a.addEventListener("click",(()=>{o.checked=!o.checked,nt({...Ue,dismissOutsideClick:o.checked})})),i.appendChild(o),i.appendChild(a);const r=Ke(" ",i);r.classList.add("gist-pb-label-group--grow"),r.firstChild.classList.add("gist-pb-label--spacer"),t.appendChild(r)}(Ue,i):"overlay"===a?function(e,t){const n=Ye(Object.entries(Ae).map((([e,t])=>({value:e,label:t}))),e.overlayPosition||"topCenter");if(n.addEventListener("change",(()=>nt({...Ue,overlayPosition:n.value}))),t.appendChild(Ke("Position",n)),!V.includes(Z(e.overlayPosition))){const n=Ze("number",e.maxWidth??414,"80px");n.addEventListener("change",(()=>nt({...Ue,maxWidth:parseInt(n.value)||414}))),t.appendChild(Ke("Max Width",n))}}(Ue,i):"inline"===a&&function(e,t){const n=Ze("text",e.elementSelector||"","260px");n.placeholder="Element ID or selector",n.addEventListener("change",(()=>{const e=n.value.trim(),t=Ue.elementSelector;e&&it(e),nt({...Ue,elementSelector:e}),t&&t!==e&&ot(t)}));const s=Qe("button",{className:"gist-pb-select-elem-btn",textContent:"Select Element"});s.addEventListener("click",(()=>at(n)));const i=Qe("div",{className:"gist-pb-inline-row"});i.appendChild(n),i.appendChild(s),t.appendChild(Ke("Element Selector",i))}(Ue,i),i.appendChild(Qe("div",{className:"gist-pb-spacer"}));const r=Qe("button",{className:"gist-pb-save-btn",textContent:"End session"});r.addEventListener("click",(async()=>{We&&await Ut.dismissMessage(We)})),i.appendChild(r),e.appendChild(i)}function lt(){_e=!_e;try{sessionStorage.setItem(De,String(_e))}catch{}rt()}function ct(){(function(){for(const e of Xe.keys())ot(e);Xe.clear()})(),We=null,Oe=[],Ue={},ze=null,Fe=!0,je=5;const e=new URLSearchParams(window.location.search).get(Ne);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"))),rt(),Be&&clearInterval(Be),Be=setInterval((()=>{je-=1,je<=0?(clearInterval(Be),Be=null,_(),function(){try{sessionStorage.removeItem(i)}catch{}}(),window.location.reload()):rt()}),1e3)}async function dt(e){if(Ut.isDocumentVisible){if(X(e.queueId))return s(`Message with queueId ${e.queueId} is already showing.`),null;if(Ut.overlayInstanceId)return s(`Message ${Ut.overlayInstanceId} already showing.`),null;{const t=B(e);return e.instanceId=y(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),Ut.overlayInstanceId=e.instanceId,Ut.currentMessages.push(e),bt(e,null,e.savedStepName||null)}}return s("Document hidden, not showing message now."),null}function ut(e,t){return Ut.isDocumentVisible?X(e.queueId)?(s(`Message with queueId ${e.queueId} is already showing.`),null):Q(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=!se(t),e.renderStartTime=(new Date).getTime(),Ut.currentMessages.push(e),bt(e,t,e.savedStepName||null)):(s("Document hidden, not showing message now."),null)}async function pt(e){e?(Ut.messageDismissed(e),await gt(e)):s("Message not found")}async function gt(e){e.overlay?await ht(!0,e):ft(e)}async function mt(e){e?B(e).persistent&&(s("Persistent message dismissed, logging view"),await Ct(e),await wt(e),await Pe(e.queueId??"")):s("Message not found")}function ft(e){e.instanceId&&K(e.instanceId),e.elementId&&ne(e.elementId),Ut.config.isPreviewSession&&(ct(),yt())}async function ht(e,t){e?await re():le(),0===Ut.currentMessages.length&&(window.removeEventListener("message",xt),window.removeEventListener("touchstart",vt)),t.instanceId&&K(t.instanceId),Ut.overlayInstanceId=null,Ut.config.isPreviewSession&&(ct(),yt())}function yt(){const e=new URL(window.location.href);e.searchParams.delete(Ne),e.searchParams.delete(Me),history.replaceState(null,"",e.toString())}function bt(e,t=null,n=null){const i=Ut.config.env,o={endpoint:S.ENGINE_API_ENDPOINT[i],siteId:Ut.config.siteId,dataCenter:Ut.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId??"",livePreview:!1,properties:e.properties,customAttributes:Object.fromEntries(new Map(ge))},a=`${S.GIST_VIEW_ENDPOINT[i]}/index.html`;return window.addEventListener("message",xt),window.addEventListener("touchstart",vt),t?(H.includes(t)&&G(t),function(e,t,n,i,o=null){const a=ue(e);if(a){const s=ce(n.instanceId??"");a.classList.add(s);const r=B(n);let l=r.messageWidth+"px";V.includes(e)&&!r.hasCustomWidth&&(l="100%"),H.includes(e)&&(a.style.width=l),se(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>`}(ce(t.instanceId??""),n,e)}(t,n,r),ie(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=B(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>`}(ce(t.instanceId??""),n,e)}(e,t)),ie(ce(t.instanceId??""),n,s)}(a,e,o,n),e}async function wt(e){let t;s(`Message shown, logging view for: ${e.messageId}`),null!=e.queueId?(await Ct(e),t=await F(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 vt(){}async function xt(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 i=B(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 ke(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"),ae(n)),Ut.config.isPreviewSession&&n.properties?.gist?.livePreview&&function(e){Fe=!1,We=e.instanceId??null;const t=e.displaySettings;if(Array.isArray(t)&&t.length>0?(Oe=t,ze||(ze=Oe[0].stepName,Ue={...Oe[0].displaySettings})):t&&"object"==typeof t&&!Array.isArray(t)&&(Ue={...t}),Ve||Je){const e=!!Ve,t=!!Je,n=Ve,i=Je;if(Ve=null,Je=null,e){const e=Oe.find((e=>e.stepName===n));if(!e)return s(`Preview bar: step "${n}" not found, ignoring initial step/display override`),void rt();ze=e.stepName,Ue={...e.displaySettings}}if(t){if(!e)return s(`Preview bar: display type "${i}" provided without a step, ignoring`),void rt();Ue={...Ue,displayType:i}}rt();const o=Ut.currentMessages.find((e=>e.instanceId===We));o&&tt(Ue)?Et(o,ze,Ue):function(){const e=Ue.displayType;if("inline"!==e&&"tooltip"!==e)return;const t=document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");t&&at(t)}()}else rt()}(n),(n.firstLoad||n.isDisplayChange)&&(n.overlay?function(e){const t=B(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(de,100),t.exitClick&&setTimeout((()=>function(e){const t=document.querySelector("#gist-overlay");t&&t.addEventListener("click",(()=>{Ut.dismissMessage(e)}))}(e.instanceId??"")),1e3)}else le()}(n):function(e){const t=ue(e);t&&t.classList.add("gist-visible")}(n.elementId),n.firstLoad&&!n.isDisplayChange&&(Ut.messageShown(n),i.persistent?s("Persistent message shown, skipping logging view"):await wt(n)),n.firstLoad=!1,n.isDisplayChange=!1),Y(e,n);break}case"tap":{const e=t.gist.parameters.action,s=t.gist.parameters.name;if(Ut.messageAction(n,e,s),t.gist.parameters.system&&!i.persistent){await pt(n);break}try{const t=new URL(e);if(t&&"gist:"===t.protocol)switch(t.href.replace("gist://","").split("?")[0]){case"close":await mt(n),await kt(n),await pt(n),await Rt();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 Ut.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;Ut.config.isPreviewSession&&r&&n.properties?.gist?.livePreview&&function(e,t){ze=e;const n=Oe.find((t=>t.stepName===e));n?Ue={...n.displaySettings}:t&&(Ue={...t}),rt()}(r,e),(i.persistent||be(n))&&await async function(e,t,n){const i=await $e(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&&ee(n,e)&&(s("Display settings changed, reloading message"),await It(n),te(n,e),await St(n,r??null));break}case"routeChanged":n.currentRoute=t.gist.parameters.route,n.renderStartTime=(new Date).getTime(),Y(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=ue(e.elementId?e.elementId:ce(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=ue(ce(e));n&&(n.title=t)}(e,t.gist.parameters.title);break;case"eventDispatched":Ut.events.dispatch("eventDispatched",{name:t.gist.parameters.name,payload:t.gist.parameters.payload});break;case"error":case"routeError":Ut.messageError(n),Ut.overlayInstanceId?await ht(!1,n):ft(n)}}}async function St(e,t){e.isDisplayChange=!0,e.renderStartTime=(new Date).getTime();const n=e.elementId||null;if(n){const t=Q(n);t&&t.instanceId!==e.instanceId&&(s(`Dismissing existing message at ${n} to make room for multi-step message`),await pt(t))}if(e.overlay){Ut.overlayInstanceId=e.instanceId??null;const t=B(e);e.shouldScale=t.shouldScale,e.shouldResizeHeight=!0}else Ut.overlayInstanceId=null,e.shouldScale=!1,e.shouldResizeHeight=!se(n??"");n&&H.includes(n)&&G(n),bt(e,n,t)}async function It(e){e.overlay?await re():e.elementId&&ne(e.elementId)}async function Et(e,t,n){n&&ee(e,n)&&(await It(e),te(e,n)),await St(e,t??null)}async function Ct(e){s(`Logging user message view locally for: ${e.queueId}`),ye(e)?await async function(e){s(`Marking broadcast ${e} as seen.`);const t=await we();if(!t)return;const n=await he(t,e);if(!n)return;const i=n.properties.gist.broadcast,{frequency:r}=i,l=ve(t,e),c=xe(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 Ce();if(!t)return;const n=a(t)??[];n.push(e),o(t,n)}(e.queueId??"")}async function kt(e){ye(e)&&(s(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){s(`Marking broadcast ${e} as dismissed.`);const t=await we();if(!t)return;const n=await he(t,e);n&&(!0!==n.properties.gist.broadcast.frequency.ignoreDismiss?(o(xe(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 Pe(e.queueId??""))}const $t="messageInboxUpdated";async function Pt(e){const t=await Lt();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),o(t,e,n),Ut.events.dispatch($t,e)}async function Tt(){const e=await Lt();if(!e)return[];const t=a(e)??[],n=new Date;return t.filter((e=>!e.expiry||new Date(e.expiry)>n))}async function Lt(){const e=await U();return e?`gist.web.inbox.messages.${e}`:null}const Nt=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>Nt(e,t))));let Mt=!1,Dt=null;async function qt(){Mt?await Rt():W()?(s("Queue watcher started"),Mt=!0,Nt((()=>new Promise((()=>{!async function(){if(S.hasActiveSSEConnection())return!S.isSSEConnectionManagedBySDK()&&Dt&&(s("Not the main instance, closing our SSE connection."),Ot()),void await Rt();Dt&&(s("SSE connection not active, closing it."),Ot()),!S.useSSE()||A()?await Wt():await async function(){Ot();const e=function(){const e=z();return null===e?(s("No user token available for SSE endpoint."),null):S.GIST_QUEUE_REALTIME_API_ENDPOINT[Ut.config.env??"prod"]+`/api/v3/sse?userToken=${e}&siteId=${Ut.config.siteId}&sessionId=${M()}`}();if(null===e)return s("SSE endpoint not available, falling back to polling."),void await Wt();s(`Starting SSE queue listener on ${e}`),Dt=new EventSource(e),S.setActiveSSEConnection(),Dt.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 Wt()})),Dt.addEventListener("messages",(async e=>{try{const t=JSON.parse(e.data);s("SSE message received"),await Ie(t),await fe(t),await Rt()}catch(e){s(`Failed to parse SSE message: ${e}`),Ot()}})),Dt.addEventListener("inbox_messages",(async e=>{try{const t=JSON.parse(e.data);s("SSE inbox messages received"),await Pt(t)}catch(e){s(`Failed to parse SSE inbox messages: ${e}`)}})),Dt.addEventListener("error",(async()=>{s("SSE error received"),Ot()})),Dt.addEventListener("heartbeat",(async()=>{s("SSE heartbeat received"),S.setActiveSSEConnection(),S.setUseSSEFlag(!0)}))}()}()}))),1e3)):s("User token not setup, queue not started.")}async function Rt(){const e=await async function(){const e=await we();return e?(a(e)??[]).filter((t=>{const n=t.properties.gist.broadcast,{frequency:s}=n,i=a(xe(e,t.queueId))??!0,o=a(ve(e,t.queueId))||0,r=0===s.count;return i&&(r||o<s.count)})):[]}(),t=await async function(){const e=await Ee();if(!e)return[];const t=a(e)??[],n=await async function(){const e=await Ce();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 At(e)}async function At(e){let t=B(e);if(t.hasRouteRule){let e=Ut.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||be(e)){const n=await async function(e){const t=await $e(e);return t?a(t):null}(e.queueId??"");n&&(s(`Restoring saved state for queueId ${e.queueId}`),n.displaySettings&&(te(e,n.displaySettings),t=B(e)),e.savedStepName=n.stepName??null)}if(t.persistent||be(e)||!await async function(e){const t=await ke(e);return!!t&&null!==a(t)}(e.queueId??"")){let n=null;return n=t.isEmbedded?ut(e,t.elementId):await dt(e),n&&async function(e){const t=await ke(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 Wt(){if(W())if(Ut.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??[];Ie(n),fe(n),Pt(i)}else 304===e.status&&s("304 response, using local store.");await Rt()}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 Ot(e=!1){e&&S.removeActiveSSEConnection(),(e||S.isSSEConnectionManagedBySDK())&&S.setUseSSEFlag(!1),Dt&&(s("Stopping SSE queue listener..."),Dt.close(),Dt=null)}class Ut{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(Ne);if(t){sessionStorage.setItem(i,String(!1)),Ut.setUserToken(t),s(`Preview mode enabled with user token: ${t}`),function(){if(document.getElementById(Re))return;!function(){if(document.getElementById(qe))return;const e=document.createElement("style");e.id=qe,e.textContent=Le,document.head.appendChild(e)}();try{_e="true"===sessionStorage.getItem(De)}catch{_e=!1}const e=Qe("div",{id:Re});document.body.appendChild(e),rt()}();const n=e.get(Me);if(n)try{const e=JSON.parse(atob(n)),t=e.stepName||null,s=e.displayType||null;(t||s)&&function(e,t){Ve=e,Je=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 qt(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await Rt())}),!1))}static async setCurrentRoute(e){this.currentRoute=e,s(`Current route set to: ${e}`),await async function(){if(0!==Ut.currentMessages.length)for(const e of[...Ut.currentMessages])null==document.querySelector(`#gist-${e.instanceId}`)&&(s(`Removing active message ${e.instanceId} that no longer exists after route change`),await gt(e))}(),await Rt()}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),Ot(!0),await qt())}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?(ge.set(e,t),me(),s(`Set custom attribute "${e}" to "${t}"`),!0):(s(`Invalid key for custom attribute: ${e}`),!1)}(e,t)}static clearCustomAttributes(){ge.clear(),r(pe),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=ge.has(e);return ge.delete(e),ge.size>0?me():r(pe),s(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(_(),this.config.useAnonymousSession&&O(),Ot(!0),await qt())}static async dismissMessage(e){const t=J(e);t&&(await mt(t),await kt(t),await pt(t),await Rt())}static async embedMessage(e,t){return ut(e,t)?.instanceId??null}static async showMessage(e){return(await dt(e))?.instanceId??null}static updateMessageDisplaySettings(e,t){const n=J(e);return!!n&&(n.displaySettings=t,ae(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 Tt()).filter((e=>!e.opened)).length}static async getInboxMessages(){return await Tt()}static async updateInboxMessageOpenState(e,t){return await async function(e,t){const n=await Lt();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 Tt();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";Ut.events.dispatch("inboxMessageAction",{message:r,action:e})}Ut.events.dispatch($t,await Tt())}(e,t)}static async removeInboxMessage(e){return await async function(e){const t=await Lt();if(!t)return;const n=await F(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 Tt()).filter((t=>t.queueId!==e)),a=new Date;a.setMinutes(a.getMinutes()+60),o(t,i,a),Ut.events.dispatch($t,await Tt())}(e)}}return t.default})(),e.exports=t()}}]);
Binary file
@@ -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 f}});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);function l(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 v(e,n,t){return(0,s.sH)(this,void 0,Promise,(function(){var i;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]:[2,i.filter((function(e){var t=e.topics;return!(!t||0===t.length)&&t.some((function(e){return n.includes(e)}))}))]):[2,[]]}}))}))}function p(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,v(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,v(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,v(n,t,null)];case 1:return[2,i.sent().map((function(t){return l(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,v(n,t,r)];case 1:return i=s.sent(),a=i.map((function(t){return l(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 f(e){var n,t=this,d=!1,l=!1,v=new EventTarget;function f(){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,I,h,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===(h=null===(I=null==t?void 0:t.properties)||void 0===I?void 0:I.gist)||void 0===h?void 0:h.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,I,h,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===(h=null===(I=null===(g=null==t?void 0:t.message)||void 0===g?void 0:g.properties)||void 0===I?void 0:I.gist)||void 0===h?void 0:h.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,f()];case 3:return n.sent(),[2,e]}}))}))}function I(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 h={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,f()];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,I(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 p(o,c(),e)},l=!0,[2,Promise.resolve()]}var s}))}))},identify:I,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 h}}}]);
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