customerio-gist-web 3.21.19 → 3.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/gist.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Gist=t():e.Gist=t()}(this,()=>(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>mn});class n{constructor(){this.callbacks={}}on(e,t){const n=this.callbacks[e];n?n.push(t):this.callbacks[e]=[t]}off(e,t){const n=this.callbacks[e];if(!n)return;if(!t)return void delete this.callbacks[e];const i=n.indexOf(t);-1!==i&&n.splice(i,1),0===n.length&&delete this.callbacks[e]}dispatch(e,t){const n=this.callbacks[e];n&&[...n].forEach(n=>{try{n(t)}catch(t){console.warn(`[Gist] Error in "${e}" event listener:`,t)}})}}function i(e){mn.config&&mn.config.logging&&console.log(`Gist: ${e}`)}const s="gist.web.isPersistingSession";function o(e,t,n=null){let i=n;i||(i=new Date,i.setDate(i.getDate()+365));const s={value:t,expiry:i};c().setItem(e,JSON.stringify(s))}function a(e){return d(e)}function r(e){c().removeItem(e)}function l(){const e=sessionStorage.getItem(s);return null===e?(sessionStorage.setItem(s,"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;if(e.startsWith("gist.")){const t=new Date,i=new Date(n.expiry),s=e.startsWith("gist.web.message.broadcasts")&&!e.endsWith("shouldShow")&&!e.endsWith("numberOfTimesShown")||e.startsWith("gist.web.message.user")&&!e.endsWith("seen")&&!e.endsWith("state"),o=new Date(t.getTime()+366e4);if(s&&i.getTime()>o.getTime())return r(e),null;if(t.getTime()>i.getTime())return r(e),null}return n.value}catch(t){i(`Error checking key ${e} for expiry: ${t}`)}return null}var p,u=new Uint8Array(16);function g(){if(!p&&!(p="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return p(u)}const m=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var f=[],h=0;h<256;++h)f.push((h+256).toString(16).substr(1));const b=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},y=function(e,t,n){var i=(e=e||{}).random||(e.rng||g)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var s=0;s<16;++s)t[n+s]=i[s];return t}return b(i)},w="gist.web.userQueueUseSSE",v="gist.web.activeSSEConnection";let x,S=30;const I={RENDERER_HOST:{prod:"https://code.gist.build",dev:"https://code.gist.build",local:"http://localhost:9998"},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://localhost:3010"},GIST_QUEUE_REALTIME_API_ENDPOINT:{prod:"https://realtime.cloud.gist.build",dev:"https://realtime.cloud.dev.gist.build",local:"http://localhost:3009"},GIST_VIEW_ENDPOINT:{prod:"https://renderer.gist.build/3.0",dev:"https://renderer.gist.build/3.0",local:"http://localhost:9998"},getSdkId:()=>(x||(x=y()),x),useSSE:()=>a(w)??!1,setUseSSEFlag(e){o(w,e,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${e}"`)},removeActiveSSEConnection(){r(v)},setActiveSSEConnection(){o(v,I.getSdkId(),new Date((new Date).getTime()+I.getSSEHeartbeat()))},hasActiveSSEConnection:()=>a(v)??!1,isSSEConnectionManagedBySDK:()=>a(v)===I.getSdkId(),getSSEHeartbeat:()=>1e3*(S+5),setSSEHeartbeat(e){e&&e>0&&(S=e)}};function C(e){return null!==e&&"object"==typeof e&&"response"in e}function E(e){return C(e)?e.response:void 0}function $(){const e=I.GIST_QUEUE_API_ENDPOINT[mn.config.env??"prod"],t={"X-CIO-Site-Id":mn.config.siteId,"X-CIO-Client-Platform":"web"},n=B();async function i(n,i={}){const s=e+n,o=new AbortController,a=setTimeout(()=>o.abort(),5e3);try{const e=await fetch(s,{method:i.method||"GET",headers:{...t,...i.headers||{}},body:i.method&&"GET"!==i.method.toUpperCase()?i.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),C(e))throw e;if(e instanceof Error)throw Object.assign(e,{response:{status:0,data:e.message||"Unknown error",headers:{}}});throw e}}return null!=n&&(t["X-Gist-Encoded-User-Token"]=n),i.post=(e,t={},n={})=>i(e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...n.headers||{}}}),i}const k="gist.web.userLocale";function P(){const e=a(k);return null!==e?e:navigator.language}let L=600,N=!1;const T="gist.web.userQueueNextPullCheck",D="gist.web.sessionId";function M(){let e=a(D);return e||(e=y()),o(D,e,new Date((new Date).getTime()+18e5)),String(e)}const R="gist.web.userToken",q="gist.web.usingGuestUserToken",A="gist.web.guestUserToken";function W(){return null!==a(q)}function O(){return a(R)}function z(){if(null===O()){let e=a(A);null==e&&(e=y(),o(A,e),i(`Set guest user token "${e}" with expiry date set to 1 year from today`)),o(R,e),o(q,!0),i(`Using anonymous session with token: "${e}"`)}}async function U(){const e=O();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 B(){const e=O();return null===e?null:btoa(e)}function F(){r(R),i("Cleared user token")}async function H(e){try{return await $().post(`/api/v1/logs/queue/${e}`)}catch(e){return E(e)}}function j(e){try{return(document.getElementById(e)??document.querySelector(e))||null}catch{return null}}function _(e,t={}){const n=document.createElement(e);for(const[e,i]of Object.entries(t))n[e]=i;return n}function V(e,t){if(document.getElementById(e))return;const n=document.createElement("style");n.id=e,n.textContent=t,document.head.appendChild(n)}const G={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 X(e){let t=G.tooltipArrowColor;if((e?.properties?.gist?.tooltipArrowColor?.length??0)>0)t=e.properties.gist.tooltipArrowColor;else{if(!Array.isArray(e?.displaySettings)||0===e.displaySettings.length)return t;let n=e.displaySettings[0];if(e.savedStepName){const t=e.displaySettings.find(t=>t?.stepName===e.savedStepName&&t.displaySettings);t&&(n=t)}n?.displaySettings?.tooltipArrowColor&&(t=n.displaySettings.tooltipArrowColor)}return t}function J(e){const t=G,n=e?.properties?.gist;return n?{isEmbedded:!!n.elementId&&!n.tooltipPosition,elementId:n.elementId||"",hasRouteRule:!!n.routeRuleWeb,routeRule:n.routeRuleWeb||"",position:n.position||"",hasPosition:!!n.position,tooltipPosition:n.tooltipPosition||"",hasTooltipPosition:!!n.tooltipPosition,tooltipArrowColor:X(e),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 Y=["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 Q(e){if(document.getElementById(e))return;const t=document.createElement("div");t.id=e,"x-gist-top"===e?document.body.insertBefore(t,document.body.firstChild):document.body.insertAdjacentElement("beforeend",t),i("Top & bottom elements injected into page")}const K=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function Z(e){return mn.currentMessages.find(t=>t.instanceId===e)}function ee(e){return!!e&&mn.currentMessages.some(t=>t.queueId===e)}function te(e){return e?mn.currentMessages.find(t=>t.elementId===e)??null:null}function ne(e){mn.currentMessages=mn.currentMessages.filter(t=>t.instanceId!==e)}function ie(e,t){ne(e),mn.currentMessages.push(t)}const se={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"},oe=Object.fromEntries(Object.entries(se).map(([e,t])=>[t,e]));function ae(e){return e&&se[e]?se[e]:(i(`Invalid overlay position "${e}", defaulting to "topCenter"`),se.topCenter)}function re(e){try{const t=new RegExp(e),n=new URL(window.location.href).pathname,i=null!=mn.currentRoute&&t.test(mn.currentRoute),s=mn.currentRoute!==n&&t.test(n);return i||s}catch{return!1}}function le(e){return e.tooltipPosition?"tooltip":e.overlay?"modal":e.elementId&&Y.includes(e.elementId)?"overlay":e.elementId?"inline":"modal"}function ce(e,t){const n=le(e),i=t.displayType;if(void 0===i)return!1;if(n!==i)return!0;const s=J(e);switch(i){case"modal":{if((e.position||"center")!==(t.modalPosition||"center"))return!0;const n=t.dismissOutsideClick??G.exitClick;if(s.exitClick!==n)return!0;const i=t.overlayColor??G.overlayColor;if(s.overlayColor!==i)return!0;break}case"overlay":{const n=ae(t.overlayPosition);if(e.elementId!==n)return!0;break}case"inline":if(e.elementId!==t.elementSelector)return!0;break;case"tooltip":if(e.tooltipPosition!==t.tooltipPosition)return!0;if(e.elementId!==t.elementSelector)return!0;if(void 0!==t.tooltipArrowColor&&s.tooltipArrowColor!==t.tooltipArrowColor)return!0}if("overlay"!==i||!K.includes(ae(t.overlayPosition))){const e=t.maxWidth??G.messageWidth;if(s.messageWidth!==e)return!0}return!1}function de(e,t){if(e.properties||(e.properties={}),e.properties.gist||(e.properties.gist={}),"modal"===t.displayType)e.overlay=!0,e.elementId=null,e.properties.gist.elementId=null,e.position=t.modalPosition||"center",e.properties.gist.position=t.modalPosition||"center",e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0,e.properties.gist.tooltipArrowColor=void 0;else if("overlay"===t.displayType){e.overlay=!1;const n=ae(t.overlayPosition);e.elementId=n,e.properties.gist.elementId=n,e.position=null,e.properties.gist.position=null,e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0,e.properties.gist.tooltipArrowColor=void 0}else"inline"===t.displayType?(e.overlay=!1,e.elementId=t.elementSelector,e.properties.gist.elementId=t.elementSelector,e.position=null,e.properties.gist.position=null,e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0,e.properties.gist.tooltipArrowColor=void 0):"tooltip"===t.displayType&&(e.overlay=!1,e.elementId=t.elementSelector,e.properties.gist.elementId=t.elementSelector,e.tooltipPosition=t.tooltipPosition,e.properties.gist.tooltipPosition=t.tooltipPosition,e.position=null,e.properties.gist.position=null,void 0!==t.tooltipArrowColor&&(e.properties.gist.tooltipArrowColor=t.tooltipArrowColor));e.elementId&&K.includes(e.elementId)?delete e.properties.gist.messageWidth:void 0!==t.maxWidth&&t.maxWidth>0?e.properties.gist.messageWidth=t.maxWidth:delete e.properties.gist.messageWidth,void 0!==t.overlayColor?e.properties.gist.overlayColor=t.overlayColor:delete e.properties.gist.overlayColor,void 0!==t.dismissOutsideClick?e.properties.gist.exitClick=t.dismissOutsideClick:delete e.properties.gist.exitClick}const pe={top:["bottom","left","right"],bottom:["top","left","right"],left:["right","top","bottom"],right:["left","top","bottom"]},ue=/auto|scroll/,ge={top:"gist-arrow-bottom",bottom:"gist-arrow-top",left:"gist-arrow-right",right:"gist-arrow-left"};function me(e){const t=j(e);return t||i(`Tooltip target element not found for selector: ${e}`),t}function fe(e,t){if(e.bottom<=0||e.top>=window.innerHeight||e.right<=0||e.left>=window.innerWidth)return!1;for(const n of t){const t=n.getBoundingClientRect();if(e.bottom<=t.top||e.top>=t.bottom||e.right<=t.left||e.left>=t.right)return!1}return!0}function he(e,t,n){const i=function(e,t,n){switch(n){case"top":return{top:t.top-e.height-16,left:t.left+(t.width-e.width)/2};case"bottom":return{top:t.bottom+16,left:t.left+(t.width-e.width)/2};case"left":return{top:t.top+(t.height-e.height)/2,left:t.left-e.width-16};case"right":return{top:t.top+(t.height-e.height)/2,left:t.right+16}}}(e,t,n);return function(e,t,n){return"top"===n||"bottom"===n?e.top>=0&&e.top+t.height<=window.innerHeight:e.left>=0&&e.left+t.width<=window.innerWidth}(i,e,n)&&function(e,t){return"top"===t||"bottom"===t?e.width+8<=window.innerWidth:e.height+8<=window.innerHeight}(e,n)?function(e,t,n){let{top:i,left:s}=e,o=null;if("top"===n||"bottom"===n){const e=4,n=window.innerWidth-t.width-4;n>=e&&(s<e?(o=s-e,s=e):s>n&&(o=s-n,s=n))}else{const e=4,n=window.innerHeight-t.height-4;n>=e&&(i<e?(o=i-e,i=e):i>n&&(o=i-n,i=n))}if(null!==o){const e=("top"===n||"bottom"===n?t.width/2:t.height/2)-16-4;Math.abs(o)>e&&(o=o>0?e:-e)}return{top:i,left:s,position:n,arrowOffset:o}}(i,e,n):null}function be(e,t,n){const i=he(e,t,n);if(i)return i;for(const i of pe[n]){const n=he(e,t,i);if(n)return n}return null}function ye(e){const t=[];let n=e.parentElement;for(;n;){const e=getComputedStyle(n),i=e.overflow+e.overflowX+e.overflowY;ue.test(i)&&t.push(n),n=n.parentElement}return t}function we(e){const t=j(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 ve(e){const t=j(e);if(t)return!(!t.style||!t.style.height||"0px"===t.style.height)}function xe(e,t,n=null){const i=document.getElementById(e);i&&(i.onload=()=>{!function(e,t,n=null){const i=document.getElementById(e);if(i?.contentWindow){const e={options:t,capabilities:Se};n&&(t.stepId=n),i.contentWindow.postMessage(e,"*")}}(e,t,n)})}const Se=["MultiStepDisplayTypes"];function Ie(e){if(!e.displaySettings)return;const t=Pe(e.instanceId??""),n=document.getElementById(t);n?.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:e.displaySettings},"*")}async function Ce(){const e=document.querySelector(".gist-message");e&&(e.classList.remove("gist-visible"),await new Promise(e=>setTimeout(e,300))),Ee()}function Ee(){const e=document.querySelector("#gist-embed-message");e&&e.parentNode?.removeChild(e)}const $e=new Map;function ke(e){const t=e.instanceId??"",n=$e.get(t);n&&(n.cleanup(),$e.delete(t));const i=j(`gist-tooltip-${t}`);i&&i.parentNode?.removeChild(i)}function Pe(e){return`gist-${e}`}function Le(){const e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}const Ne="gist.web.customAttributes";let Te=new Map;function De(){const e=Array.from(Te.entries()),t=new Date;t.setDate(t.getDate()+30),o(Ne,e,t),i(`Saved ${Te.size} custom attributes to storage with TTL of 30 days`)}async function Me(e){const t=await Oe();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),o(t,e.filter(Ae),n)}async function Re(){const e=await Oe();return e?(a(e)??[]).filter(t=>{const n=t.properties.gist.broadcast,{frequency:i}=n,s=a(Ue(e,t.queueId))??!0,o=a(ze(e,t.queueId))||0,r=0===i.count;return s&&(r||o<i.count)}):[]}async function qe(e,t){const n=a(e);return n?.find(e=>e.queueId===t)}function Ae(e){return!(!e.properties?.gist||!e.properties.gist.broadcast)}function We(e){if(!Ae(e))return!1;const t=e.properties.gist.broadcast;return 0===t.frequency.delay&&0===t.frequency.count}async function Oe(){const e=await U();return e?`gist.web.message.broadcasts.${e}`:null}function ze(e,t){return`${e}.${t}.numberOfTimesShown`}function Ue(e,t){return`${e}.${t}.shouldShow`}!function(){const e=a(Ne);if(e)try{Te=new Map(e)}catch{Te=new Map}else Te=new Map}();const Be="gist.web.message.user";async function Fe(e){const t=await je();if(!t)return;const n=e.filter(e=>!(e.properties&&e.properties.gist&&e.properties.gist.broadcast)),i=new Date;i.setMinutes(i.getMinutes()+60),o(t,n,i)}async function He(){const e=await je();if(!e)return[];const t=a(e)??[],n=await async function(){const e=await _e();return e?a(e)??[]:[]}();return t.filter(e=>!n.includes(e.queueId??""))}async function je(){const e=await U();return e?`${Be}.${e}`:null}async function _e(){const e=await U();return e?`${Be}.${e}.seen`:null}async function Ve(e){const t=await U();return t?`${Be}.${t}.message.${e}.loading`:null}async function Ge(e){const t=await U();return t?`${Be}.${t}.message.${e}.state`:null}async function Xe(e){const t=await Ge(e);t&&(r(t),i(`Cleared message state for queueId: ${e}`))}function Je(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 Ye=`\n #gist-preview-bar {\n position: fixed; bottom: 0; left: 0; right: 0;\n z-index: 99999999999;\n font-family: system-ui, -apple-system, sans-serif;\n pointer-events: none;\n }\n .gist-pb-toggle-row {\n display: flex; justify-content: center;\n padding: 6px 16px;\n border-bottom: 1px solid #e5e7eb;\n }\n .gist-pb-toggle-row--collapsed { border-bottom: none; }\n .gist-pb-toggle-btn {\n background: #08272B; border: none;\n padding: 4px 14px;\n border-radius: 100px;\n font-size: 12px; font-weight: 500;\n font-family: system-ui, -apple-system, sans-serif;\n color: white; cursor: pointer;\n display: flex; align-items: center; gap: 6px;\n pointer-events: auto;\n height: auto; min-width: auto;\n box-sizing: border-box;\n line-height: normal;\n -webkit-appearance: none;\n appearance: none;\n }\n .gist-pb-controls-row {\n background: #F8F9F9;\n box-shadow: 1px 2px 2px #34344605, 3px 3px 8px #34344614;\n display: flex; flex-wrap: wrap; align-items: center;\n gap: 12px; padding: 10px 16px 12px;\n pointer-events: auto;\n }\n .gist-pb-label-group { display: flex; flex-direction: column; gap: 4px; }\n .gist-pb-label-group--grow { flex: 1; }\n .gist-pb-label {\n font-size: 10px; font-weight: 600; color: #3F4E50;\n letter-spacing: 0.05em; text-transform: uppercase;\n font-family: system-ui, -apple-system, sans-serif;\n }\n .gist-pb-select {\n height: 32px; padding: 0 32px 0 8px;\n border: 1px solid #d1d5db; border-radius: 6px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n background: white ${`url("data:image/svg+xml,${encodeURIComponent(Je("#3F4E50"))}")`} no-repeat right 2px center;\n color: #3F4E50; cursor: pointer; outline: none;\n appearance: none; min-width: 120px;\n }\n .gist-pb-input {\n height: 32px; padding: 0 8px;\n border: 1px solid #d1d5db; border-radius: 6px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; outline: none; box-sizing: border-box;\n }\n .gist-pb-checkbox-row { display: flex; align-items: center; gap: 6px; height: 32px; }\n .gist-pb-checkbox-label {\n font-size: 12px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; cursor: pointer; user-select: none;\n }\n .gist-pb-color-control {\n display: flex; align-items: center;\n border: 1px solid #d1d5db; border-radius: 6px;\n overflow: hidden; height: 32px; background: white;\n }\n .gist-pb-color-swatch {\n width: 28px; height: 100%;\n cursor: pointer; flex-shrink: 0;\n border-right: 1px solid #d1d5db; position: relative;\n }\n .gist-pb-color-input {\n position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;\n }\n .gist-pb-color-hex {\n flex: 1; border: none; outline: none; padding: 0 6px;\n font-size: 13px; font-family: monospace; color: #3F4E50;\n min-width: 0; background: transparent;\n }\n .gist-pb-color-opacity {\n width: 36px; border: none; border-left: 1px solid #d1d5db;\n outline: none; padding: 0 4px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; background: transparent; text-align: right;\n }\n .gist-pb-color-pct {\n font-size: 12px; color: #3F4E50; padding: 0 6px 0 2px;\n font-family: system-ui, -apple-system, sans-serif; flex-shrink: 0;\n }\n .gist-pb-input--invalid { border-color: #941616; outline: 1px solid #941616; }\n .gist-pb-inline-row { display: flex; align-items: center; gap: 6px; }\n .gist-pb-select-elem-btn, .gist-pb-cancel-btn {\n height: 32px; padding: 0 12px;\n border: none; border-radius: 6px;\n font-size: 12px; font-weight: 500; font-family: system-ui, -apple-system, sans-serif;\n background: #08272B; color: white; cursor: pointer; white-space: nowrap; flex-shrink: 0;\n min-width: auto; box-sizing: border-box;\n -webkit-appearance: none; appearance: none;\n }\n .gist-pb-select-elem-btn:disabled {\n opacity: 0.4; cursor: not-allowed;\n }\n .gist-pb-spacer { flex: 1; min-width: 0; }\n .gist-pb-save-btn {\n height: 36px; padding: 0 18px;\n background: #08272B; color: white;\n border: none; border-radius: 6px;\n font-size: 13px; font-weight: 600;\n font-family: system-ui, -apple-system, sans-serif;\n cursor: pointer; white-space: nowrap; align-self: center;\n min-width: auto; box-sizing: border-box;\n -webkit-appearance: none; appearance: none;\n }\n .gist-pb-save-btn:disabled {\n background: #CAD6D8; cursor: not-allowed;\n }\n .gist-pb-picker-overlay {\n position: fixed; inset: 0; z-index: 999999999998; cursor: crosshair;\n }\n .gist-pb-checkbox { cursor: pointer; width: 14px; height: 14px; }\n .gist-pb-pick-highlight { outline: 2px solid #006FF5 !important; }\n .gist-pb-pick-error { outline: 2px solid #941616 !important; }\n #gist-preview-bar.gist-pb-hidden { display: none; }\n .gist-pb-ended-row {\n justify-content: center; align-items: center; gap: 10px; padding: 12px 16px;\n flex-wrap: nowrap;\n }\n .gist-pb-ended-icon {\n display: flex; align-items: center; justify-content: center;\n width: 22px; height: 22px; border-radius: 50%;\n background: #08272B; color: white;\n font-size: 13px; font-weight: 700; flex-shrink: 0;\n }\n .gist-pb-ended-text {\n margin: 0; font-size: 13px; color: #3F4E50;\n font-family: system-ui, -apple-system, sans-serif;\n min-width: 0;\n }\n .gist-pb-ended-text strong { color: #08272B; }\n @media (max-width: 1024px) {\n .gist-pb-controls-row { gap: 8px; }\n .gist-pb-label-group { flex: 1 1 100%; }\n .gist-pb-label-group--grow { flex: 1 1 100%; }\n .gist-pb-select { width: 100%; min-width: unset; box-sizing: border-box; }\n .gist-pb-input { width: 100% !important; box-sizing: border-box; }\n .gist-pb-color-control { width: 100%; }\n .gist-pb-checkbox-row { width: 100%; }\n .gist-pb-inline-row { flex-direction: row; align-items: center; }\n .gist-pb-inline-row .gist-pb-input { flex: 1; min-width: 0; }\n .gist-pb-save-btn { width: 100%; box-sizing: border-box; }\n .gist-pb-label--spacer { display: none; }\n }\n`;const Qe="cioPreviewId",Ke="cioPreviewSettings";const Ze="gist.previewBar.collapsed",et="gist-pb-styles",tt="gist-preview-bar",nt={topLeft:"Top Left",topCenter:"Top Center",topRight:"Top Right",bottomLeft:"Bottom Left",bottomCenter:"Bottom Center",bottomRight:"Bottom Right"};let it=null,st=[],ot={},at=null,rt=!1,lt=!1,ct=5,dt=null,pt=!0,ut=!1,gt=!1,mt=null,ft=null,ht=null;const bt=new Map;function yt(e,t){const n=_("div",{className:"gist-pb-label-group"});return n.appendChild(_("span",{className:"gist-pb-label",textContent:e})),n.appendChild(t),n}function wt(e,t){const n=_("select",{className:"gist-pb-select"});for(const i of e){const e=_("option",{value:i.value,textContent:i.label});i.value===t&&(e.selected=!0),n.appendChild(e)}return n}function vt(e,t,n){const i=_("input",{className:"gist-pb-input",type:e,value:String(t)});return n&&(i.style.width=n),i}function xt(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 St(e){return!!("inline"!==e.displayType&&"tooltip"!==e.displayType||e.elementSelector?.trim())}function It(e){if("overlay"===e.displayType&&K.includes(ae(e.overlayPosition))){const{maxWidth:t,...n}=e;e=n}if(ot=e,at){const t=st.findIndex(e=>e.stepName===at);-1!==t&&(st[t]={...st[t],displaySettings:{...e}})}if(!it)return;const t=mn.currentMessages.find(e=>e.instanceId===it);t&&St(e)&&(Ie(t),ce(t,e)&&Kt(t,at,e)),function(){const e=new URLSearchParams(window.location.search).get(Qe);e&&async function(e,t){try{return await $()(`/api/v1/preview/${e}`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return E(e)}}(e,st).then(e=>{e&&404===e.status&&it&&mn.dismissMessage(it)}).catch(()=>i("Failed to persist preview display settings"))}()}function Ct(e){const t=e.value.trim();t&&!j(t)?e.classList.add("gist-pb-input--invalid"):e.classList.remove("gist-pb-input--invalid")}function Et(e,t){const n=vt("text",e.elementSelector||"","260px");n.placeholder="Element ID or selector",Ct(n),n.addEventListener("change",()=>{const e=n.value.trim(),t=ot.elementSelector;e&&$t(e),It({...ot,elementSelector:e}),t&&t!==e&&kt(t),Ct(n)});const i=_("button",{type:"button",className:"gist-pb-select-elem-btn",textContent:"Select Element"});gt&&(i.disabled=!0),i.addEventListener("click",()=>Lt(n));const s=_("div",{className:"gist-pb-inline-row"});s.appendChild(n),s.appendChild(i),t.appendChild(yt("Element Selector",s))}function $t(e){if(!e||bt.has(e))return;const t=j(e);t&&bt.set(e,t.innerHTML)}function kt(e){const t=bt.get(e);if(void 0===t)return;const n=j(e);n&&(n.innerHTML=t)}function Pt(){for(const e of bt.keys())kt(e);bt.clear()}function Lt(e){if(gt)return;gt=!0;const t=document.querySelector(`#${tt} .gist-pb-select-elem-btn`);t&&(t.disabled=!0);const n={...ot},s=mn.currentMessages.find(e=>e.instanceId===it)??null;s&&Qt(s),ot.elementSelector&&kt(ot.elementSelector);const o=_("div",{className:"gist-pb-picker-overlay"});let a=null;const r=e=>{o.style.pointerEvents="none";const t=document.elementFromPoint(e.clientX,e.clientY);o.style.pointerEvents="all",t&&t!==a&&t!==o&&(a?.classList.remove("gist-pb-pick-highlight"),a=t,a.classList.add("gist-pb-pick-highlight"))},l=e=>{if("Escape"===e.key){if(d(),ot=n,at){const e=st.findIndex(e=>e.stepName===at);-1!==e&&(st[e]={...st[e],displaySettings:{...n}})}s&&St(n)&&Kt(s,at,n),Nt()}},c=t=>{t.preventDefault(),t.stopPropagation(),o.style.pointerEvents="none";const n=document.elementFromPoint(t.clientX,t.clientY);if(o.style.pointerEvents="all",n&&n!==o){n.classList.remove("gist-pb-pick-highlight");const t=document.getElementById(tt),o=t?.contains(n)?null:function(e){if(e.id){const t=CSS.escape(e.id);if(1===document.querySelectorAll(`#${t}`).length)return e.id}const t=[];let n=e;for(;n&&"BODY"!==n.tagName&&"HTML"!==n.tagName;){if(n.id){const e=CSS.escape(n.id);if(1===document.querySelectorAll(`#${e}`).length){t.unshift(`#${e}`);break}}let e=n.tagName.toLowerCase();n.className&&"string"==typeof n.className&&(e+=n.className.trim().split(/\s+/).filter(Boolean).map(e=>`.${CSS.escape(e)}`).join(""));const i=n.parentElement;i&&(e+=`:nth-of-type(${Array.from(i.children).filter(e=>e.tagName===n.tagName).indexOf(n)+1})`),t.unshift(e);try{if(1===document.querySelectorAll(t.join(" > ")).length)break}catch{}n=n.parentElement}const s=t.join(" > ");try{if(1!==document.querySelectorAll(s).length)return i("buildUniqueSelector: could not produce a unique selector for element"),null}catch{return null}return s}(n);if(null===o)return n.classList.add("gist-pb-pick-error"),void setTimeout(()=>{n.classList.remove("gist-pb-pick-error"),n.classList.add("gist-pb-pick-highlight")},800);e.value=o,$t(o);const a=ot.elementSelector,r={...ot,elementSelector:o},l=null!=s&&St(r)&&ce(s,r);It(r),a&&a!==o&&kt(a),s&&!l&&Kt(s,at,r)}d(),Nt()},d=()=>{a?.classList.remove("gist-pb-pick-highlight"),o.removeEventListener("mousemove",r),o.removeEventListener("click",c),document.removeEventListener("keydown",l),document.body.removeChild(o),gt=!1,mt=null};mt=d,o.addEventListener("mousemove",r),o.addEventListener("click",c),document.addEventListener("keydown",l),document.body.appendChild(o)}function Nt(){const e=document.getElementById(tt);if(!e)return;if(e.classList.toggle("gist-pb-hidden",!it&&!lt),e.innerHTML="",!it){if(lt){const t=_("div",{className:"gist-pb-controls-row gist-pb-ended-row"}),n=_("span",{className:"gist-pb-ended-icon",textContent:"✓"}),i=_("p",{className:"gist-pb-ended-text"});if(i.innerHTML=Dt(ct),t.appendChild(n),t.appendChild(i),pt){const e=_("button",{type:"button",className:"gist-pb-cancel-btn",textContent:"Cancel"});e.addEventListener("click",Mt),t.appendChild(e)}e.appendChild(t)}return}const t=_("div",{className:"gist-pb-toggle-row"+(rt?" gist-pb-toggle-row--collapsed":"")}),n=_("button",{type:"button",className:"gist-pb-toggle-btn"}),i=rt?"transform:rotate(180deg);display:inline-flex;":"display:inline-flex;";if(n.innerHTML=`${rt?"Expand":"Collapse"}<span style="${i}">${Je("white")}</span>`,n.addEventListener("click",Rt),t.appendChild(n),e.appendChild(t),rt)return;const s=_("div",{className:"gist-pb-controls-row"});if(st.length>0){const e=at??st[0].stepName,t=wt(st.map(e=>({value:e.stepName,label:e.stepName})),e);t.addEventListener("change",()=>{const e=st.find(e=>e.stepName===t.value);if(e){at=e.stepName,ot={...e.displaySettings};const t=mn.currentMessages.find(e=>e.instanceId===it);t&&St(e.displaySettings)&&Kt(t,e.stepName,e.displaySettings),Nt()}}),s.appendChild(yt("Step",t))}const o=wt([{value:"modal",label:"Modal"},{value:"overlay",label:"Overlay"},{value:"inline",label:"Inline"},{value:"tooltip",label:"Tooltip"}],ot.displayType||"modal");o.addEventListener("change",()=>{const e=o.value,t=ot.displayType,n=ot.elementSelector,i={...ot,displayType:e};"modal"===e?(i.modalPosition=i.modalPosition||"center",i.maxWidth=i.maxWidth??414,delete i.overlayPosition,delete i.elementSelector,delete i.tooltipPosition):"overlay"===e?(i.overlayPosition=i.overlayPosition||"topCenter",i.maxWidth=i.maxWidth??414,delete i.modalPosition,delete i.elementSelector,delete i.tooltipPosition):"inline"===e?(delete i.modalPosition,delete i.overlayPosition,delete i.tooltipPosition):"tooltip"===e&&(i.tooltipPosition=i.tooltipPosition||"top",delete i.modalPosition,delete i.overlayPosition,delete i.overlayColor,delete i.dismissOutsideClick),ot=i,It(ot),"inline"!==t&&"tooltip"!==t||!n||"inline"===e||"tooltip"===e||kt(n),Nt()}),s.appendChild(yt("Display Type",o));const a=ot.displayType||"modal";"modal"===a?function(e,t){const n=wt([{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}],e.modalPosition||"center");n.addEventListener("change",()=>It({...ot,modalPosition:n.value})),t.appendChild(yt("Position",n));const i=vt("number",e.maxWidth??414,"80px");i.addEventListener("change",()=>It({...ot,maxWidth:parseInt(i.value)||414})),t.appendChild(yt("Max Width",i)),t.appendChild(function(e){const{color:t,opacity:n}=function(e){const t=e.replace("#","");return 8===t.length?{color:"#"+t.slice(0,6).toUpperCase(),opacity:Math.round(parseInt(t.slice(6),16)/255*100)}:6===t.length?{color:"#"+t.toUpperCase(),opacity:100}:{color:"#000000",opacity:20}}(e.overlayColor||"#00000033"),i=_("div",{className:"gist-pb-color-control"}),s=_("input",{className:"gist-pb-color-input",type:"color",value:t}),o=_("div",{className:"gist-pb-color-swatch"});o.style.background=t,o.appendChild(s),o.addEventListener("click",()=>s.click());const a=_("input",{className:"gist-pb-color-hex",type:"text",maxLength:6,value:t.replace("#","")}),r=_("input",{className:"gist-pb-color-opacity",type:"number",min:"0",max:"100",value:String(n)}),l=_("span",{className:"gist-pb-color-pct",textContent:"%"}),c=()=>{const e="#"+a.value.replace("#",""),t=parseInt(r.value)||0;o.style.background=e,s.value=e,It({...ot,overlayColor:xt(e,t)})};return s.addEventListener("input",()=>{a.value=s.value.replace("#","").toUpperCase(),o.style.background=s.value}),s.addEventListener("change",c),a.addEventListener("change",c),r.addEventListener("change",c),i.appendChild(o),i.appendChild(a),i.appendChild(r),i.appendChild(l),yt("Overlay Color",i)}(e));const s=_("div",{className:"gist-pb-checkbox-row"}),o=_("input",{className:"gist-pb-checkbox",type:"checkbox"});o.checked=e.dismissOutsideClick??!1;const a=_("label",{className:"gist-pb-checkbox-label",textContent:"Dismiss on click outside"});o.addEventListener("change",()=>It({...ot,dismissOutsideClick:o.checked})),a.addEventListener("click",()=>{o.checked=!o.checked,It({...ot,dismissOutsideClick:o.checked})}),s.appendChild(o),s.appendChild(a);const r=yt(" ",s);r.classList.add("gist-pb-label-group--grow"),r.firstChild.classList.add("gist-pb-label--spacer"),t.appendChild(r)}(ot,s):"overlay"===a?function(e,t){const n=wt(Object.entries(nt).map(([e,t])=>({value:e,label:t})),e.overlayPosition||"topCenter");if(n.addEventListener("change",()=>It({...ot,overlayPosition:n.value})),t.appendChild(yt("Position",n)),!K.includes(ae(e.overlayPosition))){const n=vt("number",e.maxWidth??414,"80px");n.addEventListener("change",()=>It({...ot,maxWidth:parseInt(n.value)||414})),t.appendChild(yt("Max Width",n))}}(ot,s):"inline"===a?function(e,t){Et(e,t)}(ot,s):"tooltip"===a&&function(e,t){const n=wt([{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],e.tooltipPosition||"top");n.addEventListener("change",()=>It({...ot,tooltipPosition:n.value})),t.appendChild(yt("Position",n)),Et(e,t)}(ot,s),s.appendChild(_("div",{className:"gist-pb-spacer"}));const r=_("button",{type:"button",className:"gist-pb-save-btn",textContent:"End session"});r.addEventListener("click",async()=>{it&&await mn.dismissMessage(it)}),s.appendChild(r),e.appendChild(s)}async function Tt(){if(!ut)if(ut=!0,F(),function(){try{sessionStorage.removeItem(s)}catch{}}(),pt){try{window.close()}catch{}try{window.location.reload()}catch{}mt&&mt(),dt&&(clearInterval(dt),dt=null),Pt(),document.getElementById(tt)?.remove(),document.getElementById(et)?.remove(),it=null,st=[],ot={},at=null,lt=!1,ct=5,pt=!0,ut=!1}else lt=!1,ut=!1,Nt()}function Dt(e){return pt?`<strong>Preview session ended.</strong> This tab will close in ${e}s…`:`<strong>Preview session ended.</strong> Finishing session in ${e}s… This tab will stay open.`}function Mt(){lt&&dt&&(pt=!1,Nt())}function Rt(){rt=!rt;try{sessionStorage.setItem(Ze,String(rt))}catch{}Nt()}function qt(e){if(lt)return;it=e.instanceId??null;const t=e.displaySettings;if(Array.isArray(t)&&t.length>0?(st=t,at||(at=st[0].stepName,ot={...st[0].displaySettings})):t&&"object"==typeof t&&!Array.isArray(t)&&(ot={...t}),ft||ht){const e=!!ft,t=!!ht,n=ft,s=ht;if(ft=null,ht=null,e){const e=st.find(e=>e.stepName===n);if(!e)return i(`Preview bar: step "${n}" not found, ignoring initial step/display override`),void Nt();at=e.stepName,ot={...e.displaySettings}}if(t){if(!e)return i(`Preview bar: display type "${s}" provided without a step, ignoring`),void Nt();ot={...ot,displayType:s}}Nt();const o=mn.currentMessages.find(e=>e.instanceId===it);return void(o&&St(ot)?Kt(o,at,ot):function(){const e=ot.displayType;if("inline"!==e&&"tooltip"!==e)return;const t=document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");t&&Lt(t)}())}Nt()}function At(){Pt(),it=null,st=[],ot={},at=null,lt=!0,ct=5,pt=!0,ut=!1;const e=new URLSearchParams(window.location.search).get(Qe);e&&async function(e){try{return await $()(`/api/v1/preview/${e}`,{method:"DELETE"})}catch(e){return E(e)}}(e).catch(()=>i("Failed to delete preview session")),Nt(),dt&&clearInterval(dt),dt=setInterval(async()=>{if(ct-=1,ct<=0)clearInterval(dt),dt=null,await Tt();else{const e=document.querySelector(`#${tt} .gist-pb-ended-text`);e?e.innerHTML=Dt(ct):Nt()}},1e3)}async function Wt(e){if(!mn.isDocumentVisible)return i("Document hidden, not showing message now."),null;if(ee(e.queueId))return i(`Message with queueId ${e.queueId} is already showing.`),null;const t=J(e);return!e.tooltipPosition&&t.hasTooltipPosition&&(e.tooltipPosition=t.tooltipPosition),e.tooltipPosition?function(e,t){const n=t.elementId||e.elementId;if(!n)return i(`No target selector specified for tooltip message ${e.messageId}`),mn.messageError(e),null;if(!j(n)){if(!mn.config.isPreviewSession||!e.properties?.gist?.livePreview)return i(`Tooltip target element "${n}" not found for message ${e.messageId}, skipping display`),mn.messageError(e),null;i(`Preview: tooltip target "${n}" not found, loading message for preview bar`)}const s=mn.currentMessages.find(e=>e.tooltipPosition&&e.elementId===n);s&&(i(`Tooltip already showing on target "${n}" (instance ${s.instanceId}), dismissing it first`),mn.messageDismissed(s),ke(s),s.instanceId&&ne(s.instanceId)),e.instanceId=y(),e.overlay=!1,e.firstLoad=!0,e.shouldResizeHeight=!1,e.shouldScale=!1,e.renderStartTime=(new Date).getTime(),e.elementId=n,mn.currentMessages.push(e);return Vt(e,null,e.savedStepName||null)}(e,t):mn.overlayInstanceId?(i(`Message ${mn.overlayInstanceId} already showing.`),null):(e.instanceId=y(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),mn.overlayInstanceId=e.instanceId,mn.currentMessages.push(e),Vt(e,null,e.savedStepName||null))}function Ot(e,t){return mn.isDocumentVisible?ee(e.queueId)?(i(`Message with queueId ${e.queueId} is already showing.`),null):te(t)?(i(`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=!ve(t),e.renderStartTime=(new Date).getTime(),mn.currentMessages.push(e),Vt(e,t,e.savedStepName||null)):(i("Document hidden, not showing message now."),null)}async function zt(e){e?(mn.messageDismissed(e),await Ut(e)):i("Message not found")}async function Ut(e){"tooltip"===le(e)?Ht(e):e.overlay?await jt(!0,e):Ft(e)}async function Bt(e){e?J(e).persistent&&(i("Persistent message dismissed, logging view"),await Zt(e),await Gt(e),await Xe(e.queueId??"")):i("Message not found")}function Ft(e){e.instanceId&&ne(e.instanceId),e.elementId&&we(e.elementId),mn.config.isPreviewSession&&(At(),_t())}function Ht(e){ke(e),e.instanceId&&ne(e.instanceId),0===mn.currentMessages.length&&(window.removeEventListener("message",Jt),window.removeEventListener("touchstart",Xt)),mn.config.isPreviewSession&&(At(),_t())}async function jt(e,t){e?await Ce():Ee(),0===mn.currentMessages.length&&(window.removeEventListener("message",Jt),window.removeEventListener("touchstart",Xt)),t.instanceId&&ne(t.instanceId),mn.overlayInstanceId=null,mn.config.isPreviewSession&&(At(),_t())}function _t(){const e=new URL(window.location.href);e.searchParams.delete(Qe),e.searchParams.delete(Ke),history.replaceState(null,"",e.toString())}function Vt(e,t=null,n=null){const s=mn.config.env,o={endpoint:I.ENGINE_API_ENDPOINT[s],siteId:mn.config.siteId,dataCenter:mn.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId??"",livePreview:!1,properties:e.properties,customAttributes:Object.fromEntries(new Map(Te))},a=`${I.GIST_VIEW_ENDPOINT[s]}/index.html`;return window.addEventListener("message",Jt),window.addEventListener("touchstart",Xt),"tooltip"===le(e)?function(e,t,n,i=null){const s=t.instanceId??"",o=Pe(s),a=J(t),r=$e.get(s);r&&(r.cleanup(),$e.delete(s)),document.querySelectorAll(`#gist-tooltip-${s}`).forEach(e=>{e.parentNode?.removeChild(e)});const l=`gist-tooltip-${s}`,c=document.createElement("div");c.id=l,c.innerHTML=function(e,t,n,i=""){let s=600;t.messageWidth>s&&(s=t.messageWidth);const o=t.tooltipArrowColor,a=function(e){switch(e){case"top":default:return"gist-arrow-bottom";case"bottom":return"gist-arrow-top";case"left":return"gist-arrow-right";case"right":return"gist-arrow-left"}}(t.tooltipPosition),r=i?`#${i} `:"";return`\n <div class="gist-tooltip-outer">\n <style>\n ${r}.gist-tooltip-outer {\n position: absolute;\n }\n ${r}.gist-tooltip-container {\n position: relative;\n z-index: 9999999;\n opacity: 0;\n transition: opacity 0.3s ease-in-out;\n }\n ${r}.gist-tooltip-container.gist-visible {\n opacity: 1;\n }\n ${r}.gist-tooltip-frame-clip {\n overflow: hidden;\n }\n ${r}.gist-tooltip-frame {\n display: block;\n width: ${t.messageWidth}px;\n border: none;\n transition: height 0.1s ease-in-out;\n color-scheme: light only;\n }\n ${r}.gist-tooltip-arrow {\n width: 0;\n height: 0;\n position: absolute;\n z-index: 1;\n }\n ${r}.gist-tooltip-arrow.gist-arrow-bottom {\n bottom: 0;\n left: 50%;\n transform: translateX(-50%) translateY(100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-top: 10px solid ${o};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-top {\n top: 0;\n left: 50%;\n transform: translateX(-50%) translateY(-100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-bottom: 10px solid ${o};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-right {\n right: 0;\n top: 50%;\n transform: translateY(-50%) translateX(100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-left: 10px solid ${o};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-left {\n left: 0;\n top: 50%;\n transform: translateY(-50%) translateX(-100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-right: 10px solid ${o};\n }\n @media (max-width: ${s}px) {\n ${r}.gist-tooltip-frame {\n max-width: 100%;\n }\n }\n </style>\n <div class="gist-tooltip-container">\n <div class="gist-tooltip-arrow ${a}"></div>\n <div class="gist-tooltip-frame-clip">\n <iframe id="${e}" class="gist-tooltip-frame" src="${n}"></iframe>\n </div>\n </div>\n </div>`}(o,a,e,l),document.body.appendChild(c),xe(o,n,i)}(a,e,o,n):t?(Y.includes(t)&&Q(t),function(e,t,n,s,o=null){const a=j(e);if(a){const i=Pe(n.instanceId??"");a.classList.add(i);const r=J(n);let l=r.messageWidth+"px";K.includes(e)&&!r.hasCustomWidth&&(l="100%"),Y.includes(e)&&(a.style.width=l),ve(e)||(a.style.height="0px"),a.innerHTML=function(e,t,n){return function(e,t,n){let i=800;return t.messageWidth>i&&(i=t.messageWidth),`\n <div id="gist-embed">\n <style>\n #x-gist-floating-top, #x-gist-floating-top-left, #x-gist-floating-top-right {\n position: fixed;\n top: 0px;\n z-index: 1000000;\n }\n #x-gist-floating-bottom, #x-gist-floating-bottom-left, #x-gist-floating-bottom-right {\n position: fixed;\n bottom: 0px;\n z-index: 1000000;\n }\n #x-gist-bottom, #x-gist-top, #x-gist-floating-top, #x-gist-floating-bottom {\n left: 50%;\n transform: translate(-50%, 0%);\n }\n #x-gist-floating-top-right, #x-gist-floating-bottom-right {\n right: 0px;\n }\n #gist-embed {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container .gist-frame {\n height: 100%;\n width: 100%;\n border: none;\n color-scheme: light only;\n }\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${i}px) {\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${e}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(Pe(t.instanceId??""),n,e)}(t,n,r),xe(i,s,o)}else i(`Message could not be embedded, elementId ${e} not found.`)}(t,a,e,o,n)):function(e,t,n,i=null){document.querySelectorAll("#gist-embed-message").forEach(e=>{e.parentNode?.removeChild(e)}),document.body.insertAdjacentHTML("afterbegin",function(e,t){const n=J(t);return function(e,t,n){let i=600;return t.messageWidth>i&&(i=t.messageWidth),`\n <div id="gist-embed-message">\n <style>\n #gist-overlay.gist-background {\n position: fixed;\n z-index: 9999999998;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: ${t.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.gist-background.gist-visible {\n visibility: visible;\n }\n .gist-message {\n width: ${t.messageWidth}px;\n position: absolute;\n border: none;\n opacity: 0;\n transition: opacity 0.3s ease-in-out, height 0.1s ease-in-out;\n z-index: 9999999999;\n left: 50%;\n transform: translateX(-50%);\n color-scheme: light only;\n }\n .gist-message.gist-visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.gist-center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.gist-bottom {\n bottom: 0;\n }\n .gist-message.gist-top {\n top: 0;\n }\n @media (max-width: ${i}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="gist-background">\n <iframe id="${e}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(Pe(t.instanceId??""),n,e)}(e,t)),xe(Pe(t.instanceId??""),n,i)}(a,e,o,n),e}async function Gt(e){let t;i(`Message shown, logging view for: ${e.messageId}`),null!=e.queueId?(await Zt(e),t=await H(e.queueId)):t=await async function(e){try{return await $().post(`/api/v1/logs/message/${e}`)}catch(e){return E(e)}}(e.messageId),i(200===t?.status?"Message view logged":`Problem logging message: ${t?.status}`)}function Xt(){}async function Jt(e){const t=mn.config.env,n=e.data;if(n.gist&&e.origin===I.RENDERER_HOST[t]){const e=n.gist.instanceId,t=Z(e);if(!t)return;const s=J(t);switch(n.gist.method){case"routeLoaded":{const o=.001*((new Date).getTime()-(t.renderStartTime??0));if(i(`Engine render for message: ${t.messageId} timer elapsed in ${o.toFixed(3)} seconds`),async function(e){const t=await Ve(e);t&&r(t)}(t.queueId??""),t.currentRoute=n.gist.parameters.route,n.gist.parameters.fullDisplaySettings&&!t.displaySettings?t.displaySettings=n.gist.parameters.fullDisplaySettings:t.displaySettings&&(i("SDK already has display settings state, sending it to iframe"),Ie(t)),mn.config.isPreviewSession&&t.properties?.gist?.livePreview&&qt(t),t.firstLoad||t.isDisplayChange){if("tooltip"===le(t)){const e=t.properties?.gist?.elementId||t.elementId||void 0;if(!e||!j(e)){if(mn.config.isPreviewSession&&t.properties?.gist?.livePreview){i(`Preview: tooltip target "${e}" not found, preview bar will show element picker`),t.firstLoad=!1,t.isDisplayChange=!1;break}i(`Tooltip target not found for "${e}", emitting error and skipping display`),mn.messageError(t),t.firstLoad=!1,t.isDisplayChange=!1,Ht(t);break}const n=await async function(e){const t=e.instanceId??"",n=J(e),s=`gist-tooltip-${t}`,o=j(s);if(!o)return i(`Tooltip wrapper not found for instance ${t}`),!1;const a=e.properties?.gist?.elementId||e.elementId||void 0;if(!a)return i(`No target selector for tooltip ${t}`),!1;const r=$e.get(t);r&&(r.cleanup(),$e.delete(t));const l=o.querySelector(".gist-tooltip-outer");if(!l)return i(`Tooltip inner element not found for instance ${t}`),!1;const c=n.tooltipPosition||"bottom";if(!await async function(e,t,n){const s=me(t);if(!s)return!1;let o=[];try{o=ye(s)}catch{}if(fe(s.getBoundingClientRect(),o))return!0;if(!function(e,t,n){const i=me(t);if(!i)return!1;const s=i.getBoundingClientRect(),o=window.innerWidth,a=window.innerHeight,r=new DOMRect(Math.max(0,(o-s.width)/2),Math.max(0,(a-s.height)/2),s.width,s.height);return e.style.display="",null!==be(e.getBoundingClientRect(),r,n)}(e,t,n))return i(`Preflight failed: tooltip would not fit after scrolling target "${t}" into view`),!1;s.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),await function(e){return new Promise(t=>{let n=e.getBoundingClientRect(),i=0;const s=Date.now();setTimeout(function o(){const a=e.getBoundingClientRect();Math.abs(a.top-n.top)<1&&Math.abs(a.left-n.left)<1?i++:i=0,n=a,i>=2||Date.now()-s>1e3?t():setTimeout(o,50)},50)})}(s);const a=s.getBoundingClientRect();let r=[];try{r=ye(s)}catch{}return fe(a,r)}(l,a,c))return i(`Tooltip for instance ${t} skipped: target "${a}" is off-screen and cannot be scrolled into a valid position`),!1;const d=function(e,t,n,s){const o=me(t);if(!o)return null;let a=null,r=null,l=!1,c=[],d=null;try{c=ye(o)}catch{}function p(){if(l)return;if(!o||!document.contains(o)||!document.contains(e))return i("Tooltip or target element removed from DOM, cleaning up listeners"),g(),void s?.onDetach?.();const t=o.getBoundingClientRect();if(!fe(t,c))return void(e.style.display="none");e.style.display="";const a=be(e.getBoundingClientRect(),t,n);a?(function(e,t){e.style.position="absolute",e.style.top=`${t.top+window.scrollY}px`,e.style.left=`${t.left+window.scrollX}px`}(e,a),function(e,t){const n=e.querySelector(".gist-tooltip-arrow");n&&(n.classList.remove("gist-arrow-top","gist-arrow-bottom","gist-arrow-left","gist-arrow-right"),n.classList.add(ge[t.position]),null!==t.arrowOffset?"top"===t.position||"bottom"===t.position?(n.style.left=`calc(50% + ${t.arrowOffset}px)`,n.style.removeProperty("top")):(n.style.top=`calc(50% + ${t.arrowOffset}px)`,n.style.removeProperty("left")):"top"===t.position||"bottom"===t.position?(n.style.left="50%",n.style.removeProperty("top")):(n.style.top="50%",n.style.removeProperty("left")))}(e,a)):e.style.display="none"}function u(){null===a&&(a=requestAnimationFrame(()=>{a=null,p()}))}function g(){if(!l){l=!0,d&&(d.disconnect(),d=null),window.removeEventListener("scroll",u),window.removeEventListener("resize",u);for(const e of c)e.removeEventListener("scroll",u);null!==a&&(cancelAnimationFrame(a),a=null),null!==r&&(cancelAnimationFrame(r),r=null)}}if(p(),l)return null;window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u,{passive:!0});for(const e of c)e.addEventListener("scroll",u,{passive:!0});try{d=new MutationObserver(()=>{null===r&&(r=requestAnimationFrame(()=>{r=null,document.contains(o)||p()}))}),d.observe(document.body,{childList:!0,subtree:!0})}catch{}return{cleanup:g,reposition:p}}(l,a,c,{onDetach:()=>{$e.delete(t);const e=j(s);e&&e.parentNode?.removeChild(e)}});if(d){if("none"!==l.style.display){const e=o.querySelector(".gist-tooltip-container");return e?($e.set(t,d),e.classList.add("gist-visible"),!0):(d.cleanup(),i(`Tooltip container not found for instance ${t}`),!1)}return d.cleanup(),i(`Tooltip for instance ${t} could not be positioned within the viewport, target "${a}" may be off-screen`),!1}return i(`Failed to position tooltip for instance ${t}, target "${a}" may not exist or no position fits the viewport`),!1}(t);if(!n){if(mn.config.isPreviewSession&&t.properties?.gist?.livePreview){i(`Preview: tooltip positioning failed for "${e}", preview bar will remain active`),t.firstLoad=!1,t.isDisplayChange=!1;break}i(`Tooltip positioning failed for "${e}", emitting error and cleaning up`),mn.messageError(t),t.firstLoad=!1,t.isDisplayChange=!1,Ht(t);break}}else t.overlay?function(e){const t=J(e),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");const i=document.querySelector(".gist-message");i&&(e.position?i.classList.add("gist-"+e.position):i.classList.add("gist-center")),setTimeout(Le,100),t.exitClick&&setTimeout(()=>function(e){const t=document.querySelector("#gist-overlay");t&&t.addEventListener("click",()=>{mn.dismissMessage(e)})}(e.instanceId??""),1e3)}else Ee()}(t):function(e){const t=j(e);t&&t.classList.add("gist-visible")}(t.elementId);t.firstLoad&&!t.isDisplayChange&&(mn.messageShown(t),s.persistent?i("Persistent message shown, skipping logging view"):await Gt(t)),t.firstLoad=!1,t.isDisplayChange=!1}ie(e,t);break}case"tap":{const e=n.gist.parameters.action,i=n.gist.parameters.name;if(mn.messageAction(t,e,i),n.gist.parameters.system&&!s.persistent){await zt(t);break}try{const n=new URL(e);if(n&&"gist:"===n.protocol)switch(n.href.replace("gist://","").split("?")[0]){case"close":await Bt(t),await en(t),await zt(t),await dn();break;case"showMessage":{const e=n.searchParams.get("messageId"),t=n.searchParams.get("properties");if(e){const n=t?JSON.parse(atob(t)):void 0;await mn.showMessage({messageId:e,properties:n})}break}case"loadPage":{const e=n.href.substring(n.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=n.gist.parameters.displaySettings,r=n.gist.parameters.messageStepName;mn.config.isPreviewSession&&r&&t.properties?.gist?.livePreview&&function(e,t){if(lt)return;at=e;const n=st.find(t=>t.stepName===e);n?ot={...n.displaySettings}:t&&(ot={...t}),Nt()}(r,e),(s.persistent||We(t))&&await async function(e,t,n){const s=await Ge(e);if(!s)return;const r=a(s)||{},l={stepName:void 0!==t?t:r.stepName,displaySettings:void 0!==n?n:r.displaySettings},c=new Date;c.setDate(c.getDate()+30),o(s,l,c),i(`Saved message state for queueId: ${e}`)}(t.queueId??"",r,e),e&&ce(t,e)&&(i("Display settings changed, reloading message"),await Qt(t),de(t,e),await Yt(t,r??null));break}case"routeChanged":t.currentRoute=n.gist.parameters.route,t.renderStartTime=(new Date).getTime(),ie(e,t),i(`Route changed to: ${t.currentRoute}`);break;case"sizeChanged":i(`Size Changed Width: ${n.gist.parameters.width} - Height: ${n.gist.parameters.height}`),"tooltip"===le(t)?function(e,t){const n=e.instanceId??"",i=Pe(n),s=document.getElementById(i);if(s&&t.height>0){s.style.height=`${t.height}px`;const e=$e.get(n);e&&e.reposition()}}(t,n.gist.parameters):t.elementId&&!t.shouldResizeHeight||function(e,t){const n=j(e.elementId?e.elementId:Pe(e.instanceId??""));if(n){const i=n.style;if(t.height>0)if(t.height>window.innerHeight){const n=1-(t.height/window.innerHeight-1);e.shouldScale&&n>=.4?(i.height=`${t.height}px`,i.transform=`translateX(-50%) translateY(-50%) scale(${n})`):i.height=`${window.innerHeight}px`}else i.height=`${t.height}px`}}(t,n.gist.parameters);break;case"titleChanged":i(`Overlay title changed to: ${n.gist.parameters.title}`),function(e,t){const n=j(Pe(e));n&&(n.title=t)}(e,n.gist.parameters.title);break;case"eventDispatched":mn.events.dispatch("eventDispatched",{name:n.gist.parameters.name,payload:n.gist.parameters.payload});break;case"error":case"routeError":mn.messageError(t),"tooltip"===le(t)?Ht(t):mn.overlayInstanceId?await jt(!1,t):Ft(t)}}}async function Yt(e,t){e.isDisplayChange=!0,e.renderStartTime=(new Date).getTime();const n=le(e),s=e.elementId||null;if("tooltip"===n)return mn.overlayInstanceId===e.instanceId&&(mn.overlayInstanceId=null),e.shouldScale=!1,e.shouldResizeHeight=!1,void Vt(e,null,t);if(s){const t=te(s);t&&t.instanceId!==e.instanceId&&(i(`Dismissing existing message at ${s} to make room for multi-step message`),await zt(t))}if(e.overlay){mn.overlayInstanceId=e.instanceId??null;const t=J(e);e.shouldScale=t.shouldScale,e.shouldResizeHeight=!0}else mn.overlayInstanceId=null,e.shouldScale=!1,e.shouldResizeHeight=!ve(s??"");s&&Y.includes(s)&&Q(s),Vt(e,s,t)}async function Qt(e){"tooltip"===le(e)?ke(e):e.overlay?await Ce():e.elementId&&we(e.elementId)}async function Kt(e,t,n){n&&ce(e,n)&&(await Qt(e),de(e,n)),await Yt(e,t??null)}async function Zt(e){i(`Logging user message view locally for: ${e.queueId}`),Ae(e)?await async function(e){i(`Marking broadcast ${e} as seen.`);const t=await Oe();if(!t)return;const n=await qe(t,e);if(!n)return;const s=n.properties.gist.broadcast,{frequency:r}=s,l=ze(t,e),c=Ue(t,e),d=a(l)||0;if(o(l,d+1),1===r.count)o(c,!1),i(`Marked broadcast ${e} as seen.`);else{const t=new Date;t.setSeconds(t.getSeconds()+r.delay),o(c,!1,t),i(`Marked broadcast ${e} as seen, broadcast was seen ${d+1} times, next show date is ${t}.`)}}(e.queueId??""):await async function(e){const t=await _e();if(!t)return;const n=a(t)??[];n.push(e),o(t,n)}(e.queueId??"")}async function en(e){Ae(e)&&(i(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){i(`Marking broadcast ${e} as dismissed.`);const t=await Oe();if(!t)return;const n=await qe(t,e);n&&(!0!==n.properties.gist.broadcast.frequency.ignoreDismiss?(o(Ue(t,e),!1),i(`Marked broadcast ${e} as dismissed and will not show again.`)):i(`Broadcast ${e} is set to ignore dismiss.`))}(e.queueId??""),await Xe(e.queueId??""))}const tn="messageInboxUpdated";async function nn(e){const t=await on();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),o(t,e,n),mn.events.dispatch(tn,e)}async function sn(){const e=await on();if(!e)return[];const t=a(e)??[],n=new Date;return t.filter(e=>!e.expiry||new Date(e.expiry)>n)}async function on(){const e=await U();return e?`gist.web.inbox.messages.${e}`:null}const an=(e,t)=>e().then((e=>new Promise(t=>setTimeout(t,e)))(t).then(()=>an(e,t)));let rn=!1,ln=null;async function cn(){rn?await dn():O()?(i("Queue watcher started"),rn=!0,an(()=>new Promise(()=>{!async function(){if(I.hasActiveSSEConnection())return!I.isSSEConnectionManagedBySDK()&&ln&&(i("Not the main instance, closing our SSE connection."),gn()),void await dn();ln&&(i("SSE connection not active, closing it."),gn()),!I.useSSE()||W()?await un():await async function(){gn();const e=function(){const e=B();return null===e?(i("No user token available for SSE endpoint."),null):I.GIST_QUEUE_REALTIME_API_ENDPOINT[mn.config.env??"prod"]+`/api/v3/sse?userToken=${e}&siteId=${mn.config.siteId}&sessionId=${M()}`}();if(null===e)return i("SSE endpoint not available, falling back to polling."),void await un();i(`Starting SSE queue listener on ${e}`),ln=new EventSource(e),I.setActiveSSEConnection(),ln.addEventListener("connected",async e=>{try{i("SSE connection received"),I.setUseSSEFlag(!0);const t=JSON.parse(e.data);t.heartbeat&&(I.setSSEHeartbeat(t.heartbeat),i(`SSE heartbeat set to ${t.heartbeat} seconds`)),I.setActiveSSEConnection()}catch(e){i(`Failed to parse SSE settings: ${e}`)}r(T),await un()}),ln.addEventListener("messages",async e=>{try{const t=JSON.parse(e.data);i("SSE message received"),await Fe(t),await Me(t),await dn()}catch(e){i(`Failed to parse SSE message: ${e}`),gn()}}),ln.addEventListener("inbox_messages",async e=>{try{const t=JSON.parse(e.data);i("SSE inbox messages received"),await nn(t)}catch(e){i(`Failed to parse SSE inbox messages: ${e}`)}}),ln.addEventListener("error",async()=>{i("SSE error received"),gn()}),ln.addEventListener("heartbeat",async()=>{i("SSE heartbeat received"),I.setActiveSSEConnection(),I.setUseSSEFlag(!0)})}()}()}),1e3)):i("User token not setup, queue not started.")}async function dn(){const e=await Re(),t=await He(),n=e.concat(t);i(`Messages in local queue: ${n.length}`);const s=n.sort((e,t)=>e.priority-t.priority);for(const e of s)await pn(e)}async function pn(e){let t=J(e);if(t.hasRouteRule){if(null==mn.currentRoute&&"loading"===document.readyState)return i(`Deferring message ${e.queueId}, page not fully loaded`),!1;if(!re(t.routeRule))return i(`Route ${new URL(window.location.href).pathname} (currentRoute: ${mn.currentRoute}) does not match rule: ${t.routeRule}`),!1}if(t.hasPosition&&(e.position=t.position),t.hasTooltipPosition&&(e.tooltipPosition=t.tooltipPosition),t.persistent||We(e)){const n=await async function(e){const t=await Ge(e);return t?a(t):null}(e.queueId??"");n&&(i(`Restoring saved state for queueId ${e.queueId}`),n.displaySettings&&(de(e,n.displaySettings),t=J(e)),e.savedStepName=n.stepName??null)}if(t.persistent||We(e)||!await async function(e){const t=await Ve(e);return!!t&&null!==a(t)}(e.queueId??"")){let n=null;return t.isEmbedded?!mn.config.isPreviewSession||!e.properties?.gist?.livePreview||j(t.elementId)||Y.includes(t.elementId)?n=Ot(e,t.elementId):(i(`Preview: element "${t.elementId}" not found, showing as overlay so placement can be changed`),n=await Wt(e)):n=await Wt(e),n&&async function(e){const t=await Ve(e);t&&o(t,!0,new Date(Date.now()+5e3))}(e.queueId??""),null!==n}return i(`Not showing message with queueId ${e.queueId} because its already loading.`),!1}async function un(){if(O())if(mn.isDocumentVisible)if(null===a(T)){const e=await async function(){if(N)return;N=!0;const e=O();let t;try{const e={"X-Gist-User-Anonymous":String(W()),"Content-Language":String(P())};t=await $().post(`/api/v4/users?sessionId=${M()}`,{},{headers:e})}catch(e){const n=E(e);n?t=n:i(`Error getting user queue: ${e}`)}finally{N=!1}return e!==O()?(i("User token changed, clearing queue next pull check."),void r(T)):(function(e){const t=e?.headers?.["x-gist-queue-polling-interval"];L=t&&Number(t)>0?Number(t):Math.min(2*L,600);const n=new Date((new Date).getTime()+1e3*L);o(T,L,n)}(t),function(e){const t="true"===e?.headers?.["x-cio-use-sse"]?.toLowerCase();I.setUseSSEFlag(t)}(t),t)}();if(e){if(200===e.status||204===e.status){i("200 response, updating local store.");const t=e.data,n=t?.inAppMessages??[],s=t?.inboxMessages??[];Fe(n),Me(n),nn(s)}else 304===e.status&&i("304 response, using local store.");await dn()}else i("No response object returned while checking message queue.")}else i("Next queue pull scheduled for later.");else i("Document not visible, skipping queue check.");else i("User token reset, skipping queue check.")}function gn(e=!1){e&&I.removeActiveSSEConnection(),(e||I.isSSEConnectionManagedBySDK())&&I.setUseSSEFlag(!1),ln&&(i("Stopping SSE queue listener..."),ln.close(),ln=null)}class mn{static async setup(e){this.initialized?i("Gist SDK already initialized, skipping setup."):(this.initialized=!0,this.events=new n,this.config={useAnonymousSession:e.useAnonymousSession??!1,siteId:e.siteId,dataCenter:e.dataCenter,env:e.env??"prod",logging:e.logging??!1,experiments:e.experiments??!1},this.currentMessages=[],$e.forEach(e=>e.cleanup()),$e.clear(),document.querySelectorAll('[id^="gist-tooltip-"]').forEach(e=>{e.parentNode?.removeChild(e)}),this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const e=new URLSearchParams(window.location.search),t=e.get(Qe);if(t){sessionStorage.setItem(s,String(!1)),mn.setUserToken(t),i(`Preview mode enabled with user token: ${t}`),function(){if(document.getElementById(tt))return;V(et,Ye);try{rt="true"===sessionStorage.getItem(Ze)}catch{rt=!1}const e=_("div",{id:tt});document.body.appendChild(e),Nt()}();const n=e.get(Ke);if(n)try{const e=JSON.parse(atob(n)),t=e.stepName||null,i=e.displayType||null;(t||i)&&function(e,t){ft=e,ht=t}(t,i)}catch{i("Preview bar: failed to parse cioPreviewSettings")}}return!l()}(),An(),function(){const e=c();for(let t=e.length-1;t>=0;t--){const n=e.key(t);n?.startsWith("gist.")&&d(n)}}(),i(`Setup complete on ${this.config.env} environment.`),this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||z(),await cn(),"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",()=>{dn()},{once:!0}),document.addEventListener("visibilitychange",async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await dn())},!1))}static setupDebugOverlay(){An()}static async setCurrentRoute(e){this.currentRoute=e,i(`Current route set to: ${e}`),await async function(){if(0!==mn.currentMessages.length)for(const e of[...mn.currentMessages])null==document.querySelector(`#gist-${e.instanceId}`)&&(i(`Removing active message ${e.instanceId} that no longer exists after route change`),await Ut(e))}(),await dn(),this.events?.dispatch("routeChanged",e)}static async setUserToken(e,t){this.config.isPreviewSession||(function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),o(R,e,t),W()&&(r(T),r(q)),i(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),gn(!0),await cn())}static setUserLocale(e){var t;o(k,t=e),i(`Set user locate to "${t}"`)}static setCustomAttribute(e,t){return function(e,t){return e&&"string"==typeof e?(Te.set(e,t),De(),i(`Set custom attribute "${e}" to "${t}"`),!0):(i(`Invalid key for custom attribute: ${e}`),!1)}(e,t)}static clearCustomAttributes(){Te.clear(),r(Ne),i("Cleared all custom attributes")}static removeCustomAttribute(e){return function(e){if(!e||"string"!=typeof e)return i(`Invalid key for custom attribute: ${e}`),!1;const t=Te.has(e);return Te.delete(e),Te.size>0?De():r(Ne),i(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(F(),this.config.useAnonymousSession&&z(),gn(!0),await cn())}static async dismissMessage(e){const t=Z(e);t&&(await Bt(t),await en(t),await zt(t),await dn())}static async embedMessage(e,t){const n=Ot(e,t);return n?.instanceId??null}static async showMessage(e){const t=await Wt(e);return t?.instanceId??null}static updateMessageDisplaySettings(e,t){const n=Z(e);return!!n&&(n.displaySettings=t,Ie(n),!0)}static messageShown(e){i(`Message shown: ${e.messageId}`),this.events.dispatch("messageShown",e)}static messageDismissed(e){null!==e&&(i(`Message dismissed: ${e.messageId}`),this.events.dispatch("messageDismissed",e))}static messageError(e){i(`Message error: ${e.messageId}`),this.events.dispatch("messageError",e)}static messageAction(e,t,n){i(`Message action: ${e.currentRoute}, ${t} with name ${n} on ${e.instanceId}`),this.events.dispatch("messageAction",{message:e,action:t,name:n})}static async getInboxUnopenedCount(){return(await sn()).filter(e=>!e.opened).length}static async getInboxMessages(){return await sn()}static async updateInboxMessageOpenState(e,t){return await async function(e,t){const n=await on();if(!n)return;const s=await async function(e,t){try{return await $()(`/api/v1/messages/${e}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return E(e)}}(e,{opened:t});if(!s||s.status<200||s.status>=300){const e=`Failed to mark inbox message opened: ${s?.status??"unknown error"}`;throw i(e),new Error(e)}const a=await sn();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";mn.events.dispatch("inboxMessageAction",{message:r,action:e})}mn.events.dispatch(tn,await sn())}(e,t)}static async removeInboxMessage(e){return await async function(e){const t=await on();if(!t)return;const n=await H(e);if(!n||n.status<200||n.status>=300){const e=`Failed to remove inbox message: ${n?.status??"unknown error"}`;throw i(e),new Error(e)}const s=(await sn()).filter(t=>t.queueId!==e),a=new Date;a.setMinutes(a.getMinutes()+60),o(t,s,a),mn.events.dispatch(tn,await sn())}(e)}}const fn="\n #gist-debug-overlay {\n position: fixed; bottom: 16px; right: 16px;\n z-index: 99999999999;\n background: #08272B; color: white;\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 11px;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0,0,0,0.3);\n width: 300px;\n max-height: min(700px, calc(100vh - 32px));\n display: flex;\n flex-direction: column;\n pointer-events: auto;\n overflow: hidden;\n }\n .gist-debug-header {\n display: flex; align-items: center;\n padding: 8px 12px;\n border-bottom: 1px solid rgba(255,255,255,0.1);\n flex-shrink: 0;\n }\n .gist-debug-title {\n flex: 1;\n font-weight: 700;\n font-size: 12px;\n letter-spacing: 0.02em;\n }\n #gist-debug-overlay-close {\n background: none; border: none;\n color: white; cursor: pointer;\n padding: 0; font-size: 18px; line-height: 1;\n opacity: 0.6; flex-shrink: 0;\n font-family: system-ui, -apple-system, sans-serif;\n -webkit-appearance: none; appearance: none;\n }\n #gist-debug-overlay-close:hover { opacity: 1; }\n .gist-debug-section {\n padding: 0 12px 8px;\n border-bottom: 1px solid rgba(255,255,255,0.07);\n overflow-y: auto;\n max-height: 180px;\n }\n .gist-debug-section:last-child { border-bottom: none; }\n .gist-debug-label {\n position: sticky;\n top: 0;\n z-index: 1;\n background: #08272B;\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.08em;\n color: rgba(255,255,255,0.45);\n padding: 8px 0 5px;\n font-weight: 600;\n }\n .gist-debug-value {\n font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;\n font-size: 11px;\n color: rgba(255,255,255,0.9);\n overflow-wrap: break-word;\n }\n .gist-debug-msg {\n background: rgba(255,255,255,0.06);\n border-radius: 4px;\n padding: 5px 7px;\n margin-bottom: 8px;\n }\n .gist-debug-msg:last-child { margin-bottom: 0; }\n .gist-debug-msg-row {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-bottom: 2px;\n }\n .gist-debug-msg-row:last-child { margin-bottom: 0; }\n .gist-debug-msg-meta {\n display: flex;\n align-items: center;\n gap: 5px;\n margin-bottom: 4px;\n }\n .gist-debug-msg-state {\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n border-radius: 3px;\n padding: 1px 4px;\n flex-shrink: 0;\n }\n .gist-debug-msg-state--active {\n color: #4caf82;\n background: rgba(76,175,130,0.12);\n }\n .gist-debug-msg-state--queued {\n color: rgba(255,200,100,0.9);\n background: rgba(255,200,100,0.1);\n }\n .gist-debug-msg-dismiss {\n margin-left: auto;\n background: none;\n border: none;\n color: rgba(255,255,255,0.3);\n cursor: pointer;\n padding: 0;\n font-size: 13px;\n line-height: 1;\n font-family: system-ui, -apple-system, sans-serif;\n -webkit-appearance: none;\n appearance: none;\n }\n .gist-debug-msg-dismiss:hover { color: rgba(255,255,255,0.7); }\n .gist-debug-element-found {\n color: #4caf82;\n font-size: 9px;\n font-weight: 700;\n flex-shrink: 0;\n }\n .gist-debug-route-mismatch {\n color: #ff6b6b;\n font-size: 9px;\n font-weight: 700;\n flex-shrink: 0;\n }\n .gist-debug-msg-type {\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: rgba(255,255,255,0.45);\n background: rgba(255,255,255,0.08);\n border-radius: 3px;\n padding: 1px 4px;\n flex-shrink: 0;\n }\n .gist-debug-msg-key {\n color: rgba(255,255,255,0.45);\n font-size: 10px;\n line-height: 1.4;\n min-width: 64px;\n flex-shrink: 0;\n }\n .gist-debug-msg-val {\n font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;\n font-size: 10px;\n line-height: 1.4;\n color: rgba(255,255,255,0.9);\n overflow-wrap: break-word;\n }\n .gist-debug-val-error {\n color: #ff6b6b;\n font-weight: 600;\n }\n .gist-debug-expand-detail {\n background: rgba(255,107,107,0.08);\n border-left: 2px solid rgba(255,107,107,0.4);\n color: rgba(255,255,255,0.75);\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 10px;\n padding: 4px 6px;\n margin-top: 4px;\n margin-bottom: 6px;\n border-radius: 0 3px 3px 0;\n }\n .gist-debug-expand-list {\n margin: 0;\n padding: 0 0 0 14px;\n list-style: disc;\n }\n .gist-debug-expand-list li {\n margin-bottom: 3px;\n line-height: 1.4;\n }\n .gist-debug-expand-list li:last-child { margin-bottom: 0; }\n .gist-debug-msg-details {\n margin: 5px 0 0;\n padding: 0 0 0 14px;\n list-style: disc;\n color: rgba(255,255,255,0.5);\n font-size: 10px;\n line-height: 1.4;\n font-family: system-ui, -apple-system, sans-serif;\n }\n .gist-debug-msg-details li { margin-bottom: 2px; }\n .gist-debug-msg-details li:last-child { margin-bottom: 0; }\n",hn="gist-debug-overlay-styles",bn=2e3,yn=5e3;let wn=null,vn=!1,xn=!1,Sn=null;function In(e){const t=e.properties?.gist;return le(t?{...e,tooltipPosition:t.tooltipPosition??e.tooltipPosition,elementId:null!=t.elementId?String(t.elementId):e.elementId}:e)}function Cn(e,t,n=!1){const i=_("div",{className:"gist-debug-msg-row"});return i.appendChild(_("span",{className:"gist-debug-msg-key",textContent:e})),i.appendChild(_("span",{className:n?"gist-debug-msg-val gist-debug-val-error":"gist-debug-msg-val",textContent:t})),i}function En(e,t,n=!1){e.replaceChildren(...t.map(([e,t])=>Cn(e,t,n)))}function $n(e,t){const n=_("div",{className:"gist-debug-msg"}),i=_("div",{className:"gist-debug-msg-meta"});if(i.appendChild(_("span",{className:"gist-debug-msg-type",textContent:In(e)})),i.appendChild(_("span",{className:`gist-debug-msg-state gist-debug-msg-state--${t}`,textContent:t})),e.instanceId){const t=_("button",{className:"gist-debug-msg-dismiss",textContent:"×"});t.addEventListener("click",()=>{Ln(),mn.dismissMessage(e.instanceId).then(()=>{Ln(),Nn()})}),i.appendChild(t)}n.appendChild(i);const s=[];for(const[t,i]of function(e){const t=e.properties?.gist,n=[];t?.routeRuleWeb&&n.push(["Route Rule",String(t.routeRuleWeb)]);const i=t?.elementId??e.elementId,s=In(e);if(i&&"overlay"===s){const e=function(e){if(e)return oe[e]}(String(i));e&&n.push(["Position",e.replace(/([A-Z])/g," $1").toLowerCase()])}else i&&"modal"!==s&&n.push(["Target",String(i)]);const o=t?.position??e.position;o&&"overlay"!==s&&n.push(["Position",String(o)]);const a=t?.tooltipPosition??e.tooltipPosition;return a&&n.push(["Tooltip",String(a)]),n}(e)){let e=null,o=null;if("Route Rule"===t){const t=!re(i);e=t?"gist-debug-route-mismatch":"gist-debug-element-found",o=t?"✕":"✓",t&&s.push("Route rule does not match current route. If it should, verify the route is set correctly and that analytics.page() is called on route changes.")}else if("Target"===t){const t=!!j(i);e=t?"gist-debug-element-found":"gist-debug-route-mismatch",o=t?"✓":"✕",t||s.push("Target element not found on the page. If it should, verify the selector is correct.")}const a=Cn(t,i);e&&o&&a.appendChild(_("span",{className:e,textContent:o})),n.appendChild(a)}if(s.length>0){const e=_("ul",{className:"gist-debug-msg-details"});for(const t of s)e.appendChild(_("li",{textContent:t}));n.appendChild(e)}return n}function kn(e){const t=_("div",{className:"gist-debug-expand-detail"}),n=_("ul",{className:"gist-debug-expand-list"});return n.appendChild(_("li",{textContent:e})),t.appendChild(n),t}function Pn(){wn&&(wn.root.remove(),document.getElementById(hn)?.remove(),null!==Sn&&(clearInterval(Sn),Sn=null),vn&&(mn.events&&(mn.events.off("messageShown",Tn),mn.events.off("messageDismissed",Tn),mn.events.off("messageInboxUpdated",Dn),mn.events.off("routeChanged",Tn)),vn=!1),wn=null)}function Ln(){if(!wn)return;mn.config?En(wn.configRows,[["Site ID",mn.config.siteId],["Connection",I.useSSE()?"SSE":`Polling ${L}s`]]):En(wn.configRows,[["Status","NOT INITIALIZED"]],!0),wn.configDetail.style.display=mn.config?"none":"";const e=O();e?W()?wn.userValue.textContent="(anonymous)":wn.userValue.textContent=e.length>32?`${e.slice(0,32)}…`:e:wn.userValue.textContent="(none)";const t=mn.currentRoute;wn.routeValue.replaceChildren(_("span",{className:t?"gist-debug-msg-val":"gist-debug-msg-val gist-debug-val-error",textContent:t??"NONE"})),wn.routeDetail.style.display=t?"none":""}async function Nn(){if(!xn&&wn){xn=!0;try{const e=mn.currentMessages??[],[t,n]=mn.config?await Promise.all([He(),Re()]):[[],[]],i=new Set(e.map(e=>e.queueId??e.messageId)),s=new Set,o=[...n,...t].filter(e=>{const t=e.queueId??e.messageId;return!i.has(t)&&!s.has(t)&&(s.add(t),!0)});if(!wn)return;const a=e.length+o.length;wn.messagesLabel.textContent=`Messages (${a})`,wn.messagesList.replaceChildren(...e.map(e=>$n(e,"active")),...o.map(e=>$n(e,"queued")))}finally{xn=!1}}}function Tn(){Ln(),Nn()}function Dn(){Nn()}async function Mn(){vn||(!vn&&mn.events&&(mn.events.on("messageShown",Tn),mn.events.on("messageDismissed",Tn),mn.events.on("messageInboxUpdated",Dn),mn.events.on("routeChanged",Tn),vn=!0),vn&&Rn(yn)),Ln(),await Nn()}function Rn(e){null!==Sn&&clearInterval(Sn),Sn=setInterval(()=>{Mn()},e)}const qn="cio_debug_session";function An(){if("undefined"!=typeof window&&"true"===new URLSearchParams(window.location.search).get(qn))try{wn||null!==Sn||(V(hn,fn),wn=function(){const e=_("div",{id:"gist-debug-overlay"}),t=_("div",{className:"gist-debug-header"});t.appendChild(_("span",{className:"gist-debug-title",textContent:"Customer.io In-App SDK Debugger"}));const n=_("button",{id:"gist-debug-overlay-close",ariaLabel:"Dismiss debug overlay",textContent:"×"});n.addEventListener("click",Pn),t.appendChild(n),e.appendChild(t);const i=_("div",{className:"gist-debug-section"}),s=_("div",{className:"gist-debug-label"});s.appendChild(_("span",{textContent:"Config"})),i.appendChild(s);const o=_("div",{});i.appendChild(o);const a=kn("Verify your site ID and credentials are correct.");i.appendChild(a),e.appendChild(i);const r=_("div",{className:"gist-debug-section"}),l=_("div",{className:"gist-debug-label",textContent:"User"});r.appendChild(l);const c=_("div",{className:"gist-debug-value"});r.appendChild(c),e.appendChild(r);const d=_("div",{className:"gist-debug-section"}),p=_("div",{className:"gist-debug-label"});p.appendChild(_("span",{textContent:"Route"})),d.appendChild(p);const u=_("div",{className:"gist-debug-value"});d.appendChild(u);const g=kn("The current route is used to match against potential message page rules.");d.appendChild(g),e.appendChild(d);const m=_("div",{className:"gist-debug-section"}),f=_("div",{className:"gist-debug-label"});m.appendChild(f);const h=_("div",{});return m.appendChild(h),e.appendChild(m),{root:e,configRows:o,configDetail:a,userValue:c,routeValue:u,routeDetail:g,messagesLabel:f,messagesList:h}}(),e=wn.root,document.body?document.body.appendChild(e):document.addEventListener("DOMContentLoaded",()=>document.body.appendChild(e),{once:!0}),Rn(bn),Mn())}catch(e){i(`Failed to initialize debug overlay: ${e}`)}var e}return"undefined"!=typeof window&&An(),t.default})());
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Gist=e():t.Gist=e()}(this,()=>(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>ii});class n{constructor(){this.callbacks={}}on(t,e){const n=this.callbacks[t];n?n.push(e):this.callbacks[t]=[e]}off(t,e){const n=this.callbacks[t];if(!n)return;if(!e)return void delete this.callbacks[t];const i=n.indexOf(e);-1!==i&&n.splice(i,1),0===n.length&&delete this.callbacks[t]}dispatch(t,e){const n=this.callbacks[t];n&&[...n].forEach(n=>{try{n(e)}catch(e){console.warn(`[Gist] Error in "${t}" event listener:`,e)}})}}function i(t){ii.config&&ii.config.logging&&console.log(`Gist: ${t}`)}const o="gist.web.isPersistingSession";function s(t,e,n=null){let i=n;i||(i=new Date,i.setDate(i.getDate()+365));const o={value:e,expiry:i};d().setItem(t,JSON.stringify(o))}function a(t){return c(t)}function r(t){d().removeItem(t)}function l(){const t=sessionStorage.getItem(o);return null===t?(sessionStorage.setItem(o,"true"),!0):"true"===t}function d(){return l()?localStorage:sessionStorage}function c(t){if(!t)return null;try{const e=d().getItem(t);if(!e)return null;const n=JSON.parse(e);if(!n.expiry)return n.value;if(t.startsWith("gist.")){const e=new Date,i=new Date(n.expiry),o=t.startsWith("gist.web.message.broadcasts")&&!t.endsWith("shouldShow")&&!t.endsWith("numberOfTimesShown")||t.startsWith("gist.web.message.user")&&!t.endsWith("seen")&&!t.endsWith("state"),s=new Date(e.getTime()+366e4);if(o&&i.getTime()>s.getTime())return r(t),null;if(e.getTime()>i.getTime())return r(t),null}return n.value}catch(e){i(`Error checking key ${t} for expiry: ${e}`)}return null}var p,u=new Uint8Array(16);function g(){if(!p&&!(p="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return p(u)}const m=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var f=[],h=0;h<256;++h)f.push((h+256).toString(16).substr(1));const b=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(f[t[e+0]]+f[t[e+1]]+f[t[e+2]]+f[t[e+3]]+"-"+f[t[e+4]]+f[t[e+5]]+"-"+f[t[e+6]]+f[t[e+7]]+"-"+f[t[e+8]]+f[t[e+9]]+"-"+f[t[e+10]]+f[t[e+11]]+f[t[e+12]]+f[t[e+13]]+f[t[e+14]]+f[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&m.test(t)}(n))throw TypeError("Stringified UUID is invalid");return n},y=function(t,e,n){var i=(t=t||{}).random||(t.rng||g)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e){n=n||0;for(var o=0;o<16;++o)e[n+o]=i[o];return e}return b(i)},v="gist.web.inbox.enabled",w="gist.web.userQueueUseSSE",x="gist.web.activeSSEConnection";let S,I=30;const C={RENDERER_HOST:{prod:"https://code.gist.build",dev:"https://code.gist.build",local:"http://localhost:9998"},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://localhost:3010"},GIST_QUEUE_REALTIME_API_ENDPOINT:{prod:"https://realtime.cloud.gist.build",dev:"https://realtime.cloud.dev.gist.build",local:"http://localhost:3009"},GIST_VIEW_ENDPOINT:{prod:"https://renderer.gist.build/3.0",dev:"https://renderer.gist.build/3.0",local:"http://localhost:9998"},getSdkId:()=>(S||(S=y()),S),useSSE:()=>a(w)??!1,setUseSSEFlag(t){s(w,t,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${t}"`)},removeActiveSSEConnection(){r(x)},setActiveSSEConnection(){s(x,C.getSdkId(),new Date((new Date).getTime()+C.getSSEHeartbeat()))},hasActiveSSEConnection:()=>a(x)??!1,isSSEConnectionManagedBySDK:()=>a(x)===C.getSdkId(),getSSEHeartbeat:()=>1e3*(I+5),setSSEHeartbeat(t){t&&t>0&&(I=t)},inboxEnabled:()=>a(v)??!1,setInboxEnabledFlag(t){s(v,t,new Date((new Date).getTime()+36e5)),i(`Set inbox enabled to "${t}"`)}};function $(t){return null!==t&&"object"==typeof t&&"response"in t}function k(t){return $(t)?t.response:void 0}function E(){const t=C.GIST_QUEUE_API_ENDPOINT[ii.config.env??"prod"],e={"X-CIO-Site-Id":ii.config.siteId,"X-CIO-Client-Platform":"web"},n=zt();async function i(n,i={}){const o=t+n,s=new AbortController,a=setTimeout(()=>s.abort(),5e3);try{const t=await fetch(o,{method:i.method||"GET",headers:{...e,...i.headers||{}},body:i.method&&"GET"!==i.method.toUpperCase()?i.body:void 0,signal:s.signal});clearTimeout(a);const n=t.headers.get("content-type")?.includes("application/json"),r=n?await t.json():await t.text(),l=Object.fromEntries(t.headers.entries());if(t.status<200||t.status>=400)throw function(t){return Object.assign(new Error,{response:t})}({status:t.status,data:r,headers:l});return{status:t.status,headers:l,data:r}}catch(t){if(clearTimeout(a),$(t))throw t;if(t instanceof Error)throw Object.assign(t,{response:{status:0,data:t.message||"Unknown error",headers:{}}});throw t}}return null!=n&&(e["X-Gist-Encoded-User-Token"]=n),i.post=(t,e={},n={})=>i(t,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",...n.headers||{}}}),i}const j="gist.web.userLocale";function L(){const t=a(j);return null!==t?t:navigator.language}const T="gist.web.branding";async function P(){if(null!==a(T))return void i("Branding already cached.");const t=await async function(){try{return await E()("/api/v1/branding")}catch(t){return k(t)}}();if(t&&t.status>=200&&t.status<300){const e=new Date;e.setMinutes(e.getMinutes()+10),s(T,t.data,e),i("Branding fetched and cached.")}}function D(){return a(T)}const N="gist.web.templates";async function M(){if(null!==a(N))return void i("Templates already cached.");const t=await async function(){try{return await E()("/api/v1/templates")}catch(t){return k(t)}}();if(t&&t.status>=200&&t.status<300){const e=new Date;e.setMinutes(e.getMinutes()+60),s(N,t.data,e),i("Templates fetched and cached.")}}function A(){return a(N)}function R(t){try{return(document.getElementById(t)??document.querySelector(t))||null}catch{return null}}function q(t,e={}){const n=document.createElement(t);for(const[t,i]of Object.entries(e))n[t]=i;return n}function z(t,e){if(document.getElementById(t))return;const n=document.createElement("style");n.id=t,n.textContent=e,document.head.appendChild(n)}function W(t){document.body?document.body.appendChild(t):document.addEventListener("DOMContentLoaded",()=>document.body.appendChild(t),{once:!0})}async function _(t){try{return await E().post(`/api/v1/logs/queue/${t}`)}catch(t){return k(t)}}const O="messageInboxUpdated";async function B(t){const e=await V();if(!e)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(e,t,n),ii.events.dispatch(O,t)}async function U(){const t=await V();if(!t)return[];const e=a(t)??[],n=new Date;return e.filter(t=>!t.expiry||new Date(t.expiry)>n)}async function H(t,e){const n=await V();if(!n)return;const o=await async function(t,e){try{return await E()(`/api/v1/messages/${t}`,{method:"PATCH",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}catch(t){return k(t)}}(t,{opened:e});if(!o||o.status<200||o.status>=300){const t=`Failed to mark inbox message opened: ${o?.status??"unknown error"}`;throw i(t),new Error(t)}const a=await U();let r=null;const l=a.map(n=>{if(n.queueId===t){const t={...n,opened:e};return r=t,t}return n}),d=new Date;if(d.setMinutes(d.getMinutes()+60),s(n,l,d),r){const t=e?"opened":"unopened";ii.events.dispatch("inboxMessageAction",{message:r,action:t})}ii.events.dispatch(O,await U())}async function F(t){const e=await V();if(!e)return;const n=(await U()).filter(e=>e.queueId!==t),o=new Date;o.setMinutes(o.getMinutes()+60),s(e,n,o),ii.events.dispatch(O,await U());const a=await _(t);(!a||a.status<200||a.status>=300)&&i(`Failed to log inbox message view: ${a?.status??"unknown error"}`)}async function V(){const t=await qt();return t?`gist.web.inbox.messages.${t}`:null}const G="jist",X={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},J={start:"flex-start",end:"flex-end",center:"center","space-between":"space-between","space-around":"space-around","space-evenly":"space-evenly"};function Q(t){return"number"==typeof t?`${t}px`:"fill"===t?"100%":t}function Y(t){try{return new Date(t).toLocaleDateString(navigator.language)}catch{return t}}class K{#t;#e;#n;#i=0;constructor({formatDate:t,onAction:e,templates:n}={}){this.#t=t||Y,this.#e=e||null,this.#n=n||{}}render(t,e){if(!t)return null;switch(t.type){case"layout":return this.#o(t,e);case"action":return this.#s(t,e);case"heading":return this.#a(t,e);case"text":return this.#r("p",t,e);case"date":return this.#l(t,e);case"button":return this.#d(t,e);case"image":return this.#c(t,e);case"dynamicLayout":return this.#p(t,e);case"template":return this.#u(t,e);default:return null}}#o(t,e){const n=document.createElement("div");n.style.display="flex",n.style.flexDirection="horizontal"===t.direction?"row":"column",t.gap&&(n.style.gap=Q(t.gap)),t.align&&(n.style.alignItems=X[t.align]||t.align),t.justify&&(n.style.justifyContent=J[t.justify]||t.justify),t.margin&&(t.margin.top&&(n.style.marginTop=Q(t.margin.top)),t.margin.right&&(n.style.marginRight=Q(t.margin.right)),t.margin.bottom&&(n.style.marginBottom=Q(t.margin.bottom)),t.margin.left&&(n.style.marginLeft=Q(t.margin.left)));const i="horizontal"===t.direction,o=i&&(!t.justify||"start"===t.justify),s=i||"center"!==t.align?i||"end"!==t.align?"":"right":"center";for(const i of t.children||[]){const t=this.render(i,e);t&&(o&&"layout"===i.type&&(t.style.flex="1",t.style.minWidth="0"),s&&(t.style.textAlign=s),n.appendChild(t))}return n}#s(t,e){const n=t.name||"action",i=document.createElement("div");this.#g(i,"action",n),i.setAttribute("role","button"),i.setAttribute("tabindex","0");for(const n of t.children||[]){const t=this.render(n,e);t&&i.appendChild(t)}const o=e[n],s=t.meta||null;if(this.#e){const t=this.#e,e=e=>{e.stopPropagation(),t({component:"action",name:n,data:o,meta:s,event:e})};i.addEventListener("click",e),i.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e(t))})}return i}#a(t,e){const n=t.variant||"h3";return this.#r(n,t,e,n)}#r(t,e,n,i){const o=e.name||e.type,s=document.createElement(t);return this.#g(s,e.type,o,i||e.variant),s.textContent=n[o]||"",s}#l(t,e){const n=t.name||"date",i=document.createElement("time");this.#g(i,"date",n,t.variant);const o=e[n];return i.textContent=o?this.#t(o,n):"",i}#d(t,e){const n=t.name||"button",i=e[n];if(!i)return null;const o=document.createElement("button");this.#g(o,"button",n,t.variant),o.textContent=i.label,i.disabled&&(o.disabled=!0);const s=t.meta||null;return o.addEventListener("click",t=>{t.stopPropagation(),this.#e&&this.#e({component:"button",name:n,data:i,meta:s,event:t})}),o}#c(t,e){const n=t.name||"image",i=e[n];if(!i)return null;const o=document.createElement("div");this.#g(o,"image",n,t.variant),o.style.overflow="hidden";const s=document.createElement("img");return s.src=i,s.alt=e.title||"",s.style.display="block",t.width&&(s.style.width=Q(t.width)),t.height&&(s.style.height=Q(t.height)),t.objectFit&&(s.style.objectFit=t.objectFit),t.borderRadius&&(s.style.borderRadius=Q(t.borderRadius)),o.appendChild(s),o}#p(t,e){const n=e[t.name];if(!Array.isArray(n))return null;const i=document.createElement("div"),o=t.direction||"vertical";i.style.display="flex",i.style.flexDirection="horizontal"===o?"row":"column",t.gap&&(i.style.gap=Q(t.gap)),t.align&&(i.style.alignItems=X[t.align]||t.align),t.justify&&(i.style.justifyContent=J[t.justify]||t.justify),t.margin&&(t.margin.top&&(i.style.marginTop=Q(t.margin.top)),t.margin.right&&(i.style.marginRight=Q(t.margin.right)),t.margin.bottom&&(i.style.marginBottom=Q(t.margin.bottom)),t.margin.left&&(i.style.marginLeft=Q(t.margin.left)));for(const e of n){const n="object"==typeof e&&null!==e?e:{},o=this.render(t.template,n);o&&i.appendChild(o)}return i}#u(t,e){const n=this.#n[t.name];if(!n||this.#i>=10)return null;this.#i++;const i=this.render(n.root,e);return this.#i--,i}#g(t,e,n,i){t.classList.add(`${G}__${e}`),i&&t.classList.add(`${G}__${e}--${i}`),n!==e&&t.classList.add(`${G}__${n}`)}}var Z;const tt=new Set(["fontWeight","maxLines","lineHeight","opacity"]),et=new Set(["lineHeight","letterSpacing"]),nt={"text-font-size":"font-size","text-font-weight":"font-weight","text-font-family":"font-family","text-color":"color","text-line-height":"line-height","text-letter-spacing":"letter-spacing","text-max-lines":"-webkit-line-clamp","background-color":"background-color","border-width":"border-width","border-color":"border-color","border-radius":"border-radius","padding-top":"padding-top","padding-right":"padding-right","padding-bottom":"padding-bottom","padding-left":"padding-left","margin-top":"margin-top","margin-right":"margin-right","margin-bottom":"margin-bottom","margin-left":"margin-left","min-width":"min-width","min-height":"min-height"},it=["shadow-offset-x","shadow-offset-y","shadow-blur","shadow-color"],ot={"shadow-offset-x":"0","shadow-offset-y":"0","shadow-blur":"0","shadow-color":"transparent"},st={heading:new Set(["text","padding","margin"]),text:new Set(["text","padding","margin"]),date:new Set(["text","padding","margin"]),button:new Set(["text","background","border","shadow","padding","margin","minWidth","minHeight","states"]),image:new Set(["border","padding","margin"])},at=["hover","active","disabled"],rt=[["background-color","background-color"],["color","text-color"]];class lt extends HTMLElement{static observedAttributes=["template","data","theme","mode"];static#m=!1;static#f=null;static#h=0;static#b=new Map;static#y(){if(Z.#m)return;if(Z.#m=!0,document.querySelector("style[data-jist-base]"))return;const t=document.createElement("style");t.setAttribute("data-jist-base",""),t.textContent="/* ═══════════════════════════════════════════\n Jist Template Styles\n ═══════════════════════════════════════════ */\n\n/* ── Host Element ───────────────────────── */\n\njist-template {\n display: block;\n}\n\n/* ── Base Reset ─────────────────────────── */\n\n.jist__heading,\n.jist__text,\n.jist__date {\n margin: 0;\n padding: 0;\n}\n\n/* ── Heading ────────────────────────────── */\n\n.jist__heading {\n font-size: var(--jist-heading-text-font-size, 16px);\n font-weight: var(--jist-heading-text-font-weight, 600);\n color: var(--jist-heading-text-color, #000000);\n font-family: var(--jist-heading-text-font-family, inherit);\n line-height: var(--jist-heading-text-line-height, 1.3);\n letter-spacing: var(--jist-heading-text-letter-spacing, normal);\n padding-top: var(--jist-heading-padding-top, 0);\n padding-right: var(--jist-heading-padding-right, 0);\n padding-bottom: var(--jist-heading-padding-bottom, 0);\n padding-left: var(--jist-heading-padding-left, 0);\n margin-top: var(--jist-heading-margin-top, 0);\n margin-right: var(--jist-heading-margin-right, 0);\n margin-bottom: var(--jist-heading-margin-bottom, 0);\n margin-left: var(--jist-heading-margin-left, 0);\n /* Line clamping — active when --jist-heading-text-max-lines is set */\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: var(--jist-heading-text-max-lines, none);\n overflow: hidden;\n}\n\n/* ── Text ───────────────────────────────── */\n\n.jist__text {\n font-size: var(--jist-text-text-font-size, 14px);\n font-weight: var(--jist-text-text-font-weight, 400);\n color: var(--jist-text-text-color, #000000);\n font-family: var(--jist-text-text-font-family, inherit);\n line-height: var(--jist-text-text-line-height, 1.5);\n letter-spacing: var(--jist-text-text-letter-spacing, normal);\n padding-top: var(--jist-text-padding-top, 0);\n padding-right: var(--jist-text-padding-right, 0);\n padding-bottom: var(--jist-text-padding-bottom, 0);\n padding-left: var(--jist-text-padding-left, 0);\n margin-top: var(--jist-text-margin-top, 0);\n margin-right: var(--jist-text-margin-right, 0);\n margin-bottom: var(--jist-text-margin-bottom, 0);\n margin-left: var(--jist-text-margin-left, 0);\n /* Line clamping — active when --jist-text-text-max-lines is set */\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: var(--jist-text-text-max-lines, none);\n overflow: hidden;\n}\n\n/* ── Date ───────────────────────────────── */\n\n.jist__date {\n font-size: var(--jist-date-text-font-size, 12px);\n font-weight: var(--jist-date-text-font-weight, 400);\n color: var(--jist-date-text-color, #000000);\n font-family: var(--jist-date-text-font-family, inherit);\n line-height: var(--jist-date-text-line-height, 1.4);\n letter-spacing: var(--jist-date-text-letter-spacing, normal);\n padding-top: var(--jist-date-padding-top, 0);\n padding-right: var(--jist-date-padding-right, 0);\n padding-bottom: var(--jist-date-padding-bottom, 0);\n padding-left: var(--jist-date-padding-left, 0);\n margin-top: var(--jist-date-margin-top, 0);\n margin-right: var(--jist-date-margin-right, 0);\n margin-bottom: var(--jist-date-margin-bottom, 0);\n margin-left: var(--jist-date-margin-left, 0);\n}\n\n/* ── Button ─────────────────────────────── */\n\n.jist__button {\n appearance: none;\n -webkit-appearance: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n border: none;\n font-size: var(--jist-button-text-font-size, 14px);\n font-weight: var(--jist-button-text-font-weight, 500);\n color: var(--jist-button-text-color, #ffffff);\n font-family: var(--jist-button-text-font-family, inherit);\n line-height: var(--jist-button-text-line-height, 1);\n background-color: var(--jist-button-background-color, #4f46e5);\n border-width: var(--jist-button-border-width, 0);\n border-style: solid;\n border-color: var(--jist-button-border-color, transparent);\n border-radius: var(--jist-button-border-radius, 6px);\n box-shadow:\n var(--jist-button-shadow-offset-x, 0)\n var(--jist-button-shadow-offset-y, 0)\n var(--jist-button-shadow-blur, 0)\n var(--jist-button-shadow-color, transparent);\n padding-top: var(--jist-button-padding-top, 8px);\n padding-right: var(--jist-button-padding-right, 16px);\n padding-bottom: var(--jist-button-padding-bottom, 8px);\n padding-left: var(--jist-button-padding-left, 16px);\n margin-top: var(--jist-button-margin-top, 0);\n margin-right: var(--jist-button-margin-right, 0);\n margin-bottom: var(--jist-button-margin-bottom, 0);\n margin-left: var(--jist-button-margin-left, 0);\n min-width: var(--jist-button-min-width, 0);\n min-height: var(--jist-button-min-height, 0);\n transition: background-color 0.15s ease, color 0.15s ease,\n border-color 0.15s ease, box-shadow 0.15s ease;\n}\n\n.jist__button:hover {\n background-color: var(--jist-button-states-hover-background-color,\n var(--jist-button-background-color, #4338ca));\n color: var(--jist-button-states-hover-text-color,\n var(--jist-button-text-color, #ffffff));\n}\n\n.jist__button:active {\n background-color: var(--jist-button-states-active-background-color,\n var(--jist-button-background-color, #3730a3));\n color: var(--jist-button-states-active-text-color,\n var(--jist-button-text-color, #ffffff));\n}\n\n.jist__button:disabled {\n background-color: var(--jist-button-states-disabled-background-color,\n var(--jist-button-background-color, #c7d2fe));\n color: var(--jist-button-states-disabled-text-color,\n var(--jist-button-text-color, #a5b4fc));\n cursor: not-allowed;\n}\n\n/* ── Image ──────────────────────────────── */\n\n.jist__image {\n display: block;\n max-width: 100%;\n overflow: hidden;\n border-radius: var(--jist-image-border-radius, 0);\n padding-top: var(--jist-image-padding-top, 0);\n padding-right: var(--jist-image-padding-right, 0);\n padding-bottom: var(--jist-image-padding-bottom, 0);\n padding-left: var(--jist-image-padding-left, 0);\n margin-top: var(--jist-image-margin-top, 0);\n margin-right: var(--jist-image-margin-right, 0);\n margin-bottom: var(--jist-image-margin-bottom, 0);\n margin-left: var(--jist-image-margin-left, 0);\n}\n\n.jist__image img {\n border-radius: inherit;\n}\n\n/* ── Dark Mode Defaults ────────────────── */\n\n[data-jist-dark] .jist__heading { color: var(--jist-heading-text-color, #ffffff); }\n[data-jist-dark] .jist__text { color: var(--jist-text-text-color, #ffffff); }\n[data-jist-dark] .jist__date { color: var(--jist-date-text-color, #ffffff); }\n[data-jist-dark] .jist__button { color: var(--jist-button-text-color, #ffffff); }\n\n/* ── Action (clickable wrapper) ─────────── */\n\n.jist__action {\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n\n.jist__action:focus-visible {\n outline: 2px solid var(--jist-button-background-color, #4f46e5);\n outline-offset: 2px;\n border-radius: 4px;\n}\n",document.head.appendChild(t)}#v=null;#w=null;#x=null;#S=null;#I="auto";#t=null;#e=null;#n={};#C=null;#$=null;get template(){return this.#w}set template(t){this.#w=t,this.#k()}get data(){return this.#x}set data(t){this.#x="string"==typeof t?JSON.parse(t):t,this.#k()}get theme(){return this.#S}set theme(t){this.#S="string"==typeof t?JSON.parse(t):t,this.#E(),this.#k()}get mode(){return this.#I}set mode(t){this.#I=t||"auto",this.#E()}get formatDate(){return this.#t}set formatDate(t){this.#t=t,this.#k()}get onAction(){return this.#e}set onAction(t){this.#e=t}get templates(){return this.#n}set templates(t){const e="string"==typeof t?JSON.parse(t):t||{},n={};for(const[t,i]of Object.entries(e)){if(t.startsWith("$"))continue;if(!Array.isArray(i))continue;const e=i.find(t=>"1"===t.version);e&&(n[t]=e)}this.#n=n,this.#k()}connectedCallback(){Z.#y(),this.#C=window.matchMedia("(prefers-color-scheme: dark)"),this.#$=()=>{"auto"===this.#I&&(this.#E(),this.#k())},this.#C.addEventListener("change",this.#$),this.#E(),this.#k()}disconnectedCallback(){this.#C&&this.#$&&this.#C.removeEventListener("change",this.#$),this.#j(),Z.#L()}attributeChangedCallback(t,e,n){if(e!==n)switch(t){case"template":this.#w=n||null,this.#k();break;case"data":this.#x=n?JSON.parse(n):null,this.#k();break;case"theme":this.#S=n?JSON.parse(n):null,this.#E(),this.#k();break;case"mode":this.#I=n||"auto",this.#E(),this.#k()}}#T(){return"dark"===this.#I||"light"!==this.#I&&(this.#C?.matches??!1)}#E(){if(!this.isConnected)return void(this.#S||(this.#j(),Z.#L()));if(this.#T()?this.setAttribute("data-jist-dark",""):this.removeAttribute("data-jist-dark"),!this.#S)return this.#j(),void Z.#L();const t=[];for(let e=0;e<this.style.length;e++)this.style[e].startsWith("--jist-")&&t.push(this.style[e]);if(t.forEach(t=>this.style.removeProperty(t)),this.#P(this.#S,"--jist"),this.#T()){const t=this.#S.modes?.dark;t&&this.#P(t,"--jist")}this.#D()}#P(t,e){for(const[n,i]of Object.entries(t)){if("modes"===n||n.startsWith("$"))continue;const t=`${e}-${n.replace(/([A-Z])/g,"-$1").toLowerCase()}`;if(null===i||"object"!=typeof i||Array.isArray(i)){if(null!=i&&""!==i){const e=0===i&&et.has(n)?"normal":"number"!=typeof i||tt.has(n)?String(i):`${i}px`;this.style.setProperty(t,e)}}else this.#P(i,t)}}#D(){const t=[],e=this.#S;if(!e)return;const n=e.modes?.dark;for(const i of Object.keys(st)){const o=e[i],s=n?.[i],a=st[i],r=new Set;for(const t of[o,s])if(t)for(const e of Object.keys(t))a.has(e)||e.startsWith("$")||r.add(e);for(const e of r){const n=o?.[e]??{},a=s?.[e]??{};t.push(this.#N(i,e,n,a))}}const i=t.join("\n");if(this.#j(),!i)return;let o=Z.#b.get(i);o||(o={id:Z.#h++,refs:0},Z.#b.set(i,o)),o.refs++,this.#v=i,this.setAttribute("data-jist-v",String(o.id)),Z.#L()}#j(){if(!this.#v)return;const t=Z.#b.get(this.#v);t&&(t.refs--,t.refs<=0&&Z.#b.delete(this.#v)),this.#v=null,this.removeAttribute("data-jist-v")}static#L(){if(0===Z.#b.size)return void(Z.#f&&(Z.#f.remove(),Z.#f=null));Z.#f||(Z.#f=document.createElement("style"),Z.#f.setAttribute("data-jist-variants",""),document.head.appendChild(Z.#f));const t=[];for(const[e,{id:n}]of Z.#b){const i=`[data-jist-v="${n}"]`;t.push(e.replace(/^(\.[a-z_-]+)/gm,`${i} $1`))}Z.#f.textContent=t.join("\n")}#N(t,e,n,i){const o=e.replace(/([A-Z])/g,"-$1").toLowerCase(),s=`.jist__${t}--${o}`,a=new Set,r=(t,e)=>{for(const[n,i]of Object.entries(t)){if("states"===n||n.startsWith("$"))continue;const t=n.replace(/([A-Z])/g,"-$1").toLowerCase(),o=e?`${e}-${t}`:t;null===i||"object"!=typeof i||Array.isArray(i)?a.add(o):r(i,o)}};r(n,""),r(i,"");const l=[];for(const e of a){const n=nt[e];if(!n)continue;const i=`--jist-${t}-${o}-${e}`,s=`--jist-${t}-${e}`;l.push(` ${n}: var(${i}, var(${s}));`)}if("button"===t&&[...a].some(t=>t.startsWith("shadow-"))){const t=it.map(t=>`var(--jist-button-${o}-${t}, var(--jist-button-${t}, ${ot[t]}))`);l.push(` box-shadow: ${t.join(" ")};`)}let d=`${s} {\n${l.join("\n")}\n}`;if("button"===t&&(n.states||i.states))for(const t of at){const e=n.states?.[t],a=i.states?.[t];if(!e&&!a)continue;const r=[];for(const[e,n]of rt){const i=`--jist-button-${o}-states-${t}-${n}`,s=`--jist-button-states-${t}-${n}`,a=`--jist-button-${o}-${n}`,l=`--jist-button-${n}`;r.push(` ${e}: var(${i}, var(${s}, var(${a}, var(${l}))));`)}d+=`\n${s}${"disabled"===t?":disabled":`:${t}`} {\n${r.join("\n")}\n}`}return d}#k(){if(!this.#w||!this.#x)return;if(!this.isConnected)return;const t=this.#n[this.#w];if(!t)return void(this.innerHTML="");const e=new K({formatDate:this.#t||void 0,templates:this.#n,onAction:t=>{this.#e&&this.#e(t),this.dispatchEvent(new CustomEvent("jist-action",{bubbles:!0,detail:{component:t.component,name:t.name,data:t.data,meta:t.meta}}))}});this.innerHTML="";const n=e.render(t.root,this.#x);n&&this.appendChild(n)}}Z=lt,customElements.define("jist-template",lt);const dt=lt,ct="gist-inbox-button",pt="gist-inbox-badge",ut="gist-inbox-panel",gt="gist-inbox-messages";let mt=!1,ft=!1;const ht=new Set;function bt(){mt||(mt=!0,customElements.get("jist-template")||customElements.define("jist-template",dt),z("gist-inbox-styles","\n#gist-inbox-button {\n position: fixed;\n width: 56px;\n height: 56px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n z-index: 9998;\n border: none;\n transition: background-color 0.2s ease,\n box-shadow 0.2s ease,\n transform 0.15s ease;\n}\n#gist-inbox-button:hover {\n transform: scale(1.05);\n}\n#gist-inbox-button:active {\n transform: scale(0.93);\n}\n#gist-inbox-button svg {\n width: 24px;\n height: 24px;\n}\n#gist-inbox-badge {\n position: absolute;\n top: -4px;\n right: -4px;\n min-width: 20px;\n height: 20px;\n border-radius: 10px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0 6px;\n box-sizing: border-box;\n}\n#gist-inbox-panel {\n position: fixed;\n width: 400px;\n max-height: 600px;\n z-index: 9999;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n user-select: none;\n -webkit-user-select: none;\n transform: translateY(8px) scale(0.96);\n opacity: 0;\n pointer-events: none;\n transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),\n opacity 0.2s ease;\n}\n#gist-inbox-panel.gist-inbox-panel--open {\n transform: translateY(0) scale(1);\n opacity: 1;\n pointer-events: auto;\n}\n#gist-inbox-messages {\n overflow-y: auto;\n flex: 1;\n}\n.gist-inbox-message-row {\n transition: background-color 0.15s ease;\n}\n"),ii.events.on("messageInboxUpdated",t=>{yt(t)}),yt())}async function yt(t){t||(t=await U());const e=function(t){return t.filter(t=>t.topics?.some(t=>t.startsWith("cio_inbox"))).sort((t,e)=>{const n=(t.priority??Number.MAX_SAFE_INTEGER)-(e.priority??Number.MAX_SAFE_INTEGER);return 0!==n?n:new Date(e.sentAt??0).getTime()-new Date(t.sentAt??0).getTime()})}(t);if(0===e.length)return void vt();let n=D();n||(await $t(),n=D());const o=n?.patterns?.inbox;if(o){if(function(t,e){let n=document.getElementById(ct);n||(n=q("div",{id:ct}),n.addEventListener("click",()=>{ft?(ft=!1,document.getElementById(ut)?.classList.remove("gist-inbox-panel--open")):(ft=!0,yt())}),W(n));const i=Ct(t.position);n.style.background=t.floatingIcon.background,n.style.color=t.floatingIcon.color,n.style.boxShadow="0 2px 8px rgba(0,0,0,0.15)",Object.assign(n.style,i),n.querySelector("svg")||n.insertAdjacentHTML("afterbegin",t.floatingIcon.svg);!function(t,e,n){let i=document.getElementById(pt);if(0===n||!e.unreadIndicator.showAlert)return void i?.remove();i||(i=q("span",{id:pt}),t.appendChild(i));const o=e.unreadIndicator;i.textContent=String(n),i.style.background=o.background,i.style.color=o.text.color,i.style.fontSize=`${o.text.fontSize}px`,i.style.fontWeight=String(o.text.fontWeight),i.style.fontFamily=o.text.fontFamily,i.style.lineHeight=String(o.text.lineHeight)}(n,t,e.filter(t=>!t.opened).length)}(o,e),ft){!function(t,e){let n=document.getElementById(ut);const o=!n;o&&(n=q("div",{id:ut}),W(n));const s=Ct(t.position,!0);n.style.background=t.background,n.style.borderRadius=`${t.cornerRadius}px`,n.style.border=`1px solid ${t.borderColor}`,n.style.boxShadow=`${t.shadow.offsetX}px ${t.shadow.offsetY}px ${t.shadow.blur}px ${t.shadow.color}`,Object.assign(n.style,s);let a=document.getElementById(gt);a||(a=q("div",{id:gt}),n.appendChild(a)),a.innerHTML="";const r=D(),l=A();e.forEach((n,o)=>{const s=q("div",{className:"gist-inbox-message-row"});s.style.padding="12px 16px",s.style.cursor="pointer",s.addEventListener("mouseenter",()=>{s.style.background=t.hoverBackground}),s.addEventListener("mouseleave",()=>{s.style.background=""});const d=document.createElement("jist-template");s.appendChild(d),a.appendChild(s);const c=d;if(c.onAction=t=>{i(`Inbox action: ${t.name}`);const e=function(t){if(!t||"object"!=typeof t)return null;const e=t;return"string"==typeof e.behavior&&["openUrl","dismiss","openDeeplink","performAction"].includes(e.behavior)?{behavior:e.behavior,action:"string"==typeof e.action?e.action:void 0,name:"string"==typeof e.name?e.name:void 0,dismiss:"boolean"==typeof e.dismiss?e.dismiss:void 0,newTab:"boolean"==typeof e.newTab?e.newTab:void 0}:null}(t.data);e&&function(t,e){"openUrl"!==e.behavior&&"openDeeplink"!==e.behavior||!e.action||(function(t){try{return"javascript:"!==new URL(t,window.location.href).protocol}catch{return!1}}(e.action)?e.newTab?window.open(e.action,"_blank","noopener"):window.location.href=e.action:i(`Blocked unsafe URL: ${e.action}`)),("dismiss"===e.behavior||e.dismiss)&&t.queueId&&F(t.queueId),ii.events.dispatch("inboxMessageAction",{message:t,action:"clicked"})}(n,e)},l&&(c.templates=l),r?.theme&&(c.theme=r.theme),c.formatDate=It,c.data=n.properties??{},c.template=n.type??null,o<e.length-1){const e=q("div",{className:"gist-inbox-divider"});e.style.height="1px",e.style.background=t.dividerColor,e.style.margin="0",a.appendChild(e)}}),o?requestAnimationFrame(()=>{n.classList.add("gist-inbox-panel--open")}):n.classList.add("gist-inbox-panel--open")}(o,e);for(const t of e){const e=t.queueId;t.opened||!e||ht.has(e)||(ht.add(e),H(e,!0).finally(()=>{ht.delete(e)}))}}}else vt()}function vt(){document.getElementById(ct)?.remove(),document.getElementById(ut)?.remove(),ft=!1}const wt=[[60,"second",1],[3600,"minute",60],[86400,"hour",3600],[2592e3,"day",86400],[31536e3,"month",2592e3],[1/0,"year",31536e3]];let xt=null,St=null;function It(t){const e=Math.round((Date.now()-new Date(t).getTime())/1e3);if(Number.isNaN(e))return t;const[,n,i]=wt.find(([t])=>Math.abs(e)<t);return function(){const t=L();return xt&&St===t||(St=t,xt=new Intl.RelativeTimeFormat(t,{numeric:"auto"})),xt}().format(-Math.round(e/i),n)}function Ct(t,e=!1){const n=e?"":"24px",i="96px";switch(t){case"bottom-left":return e?{bottom:i,left:"24px",right:"",top:""}:{bottom:n,left:n,right:"",top:""};case"top-right":return e?{top:i,right:"24px",bottom:"",left:""}:{top:n,right:n,bottom:"",left:""};case"top-left":return e?{top:i,left:"24px",bottom:"",right:""}:{top:n,left:n,bottom:"",right:""};default:return e?{bottom:i,right:"24px",left:"",top:""}:{bottom:n,right:n,left:"",top:""}}}async function $t(){await Promise.all([P(),M()])}let kt=600,Et=!1;const jt="gist.web.userQueueNextPullCheck",Lt="gist.web.sessionId";function Tt(){let t=a(Lt);return t||(t=y()),s(Lt,t,new Date((new Date).getTime()+18e5)),String(t)}const Pt="gist.web.userToken",Dt="gist.web.usingGuestUserToken",Nt="gist.web.guestUserToken";function Mt(){return null!==a(Dt)}function At(){return a(Pt)}function Rt(){if(null===At()){let t=a(Nt);null==t&&(t=y(),s(Nt,t),i(`Set guest user token "${t}" with expiry date set to 1 year from today`)),s(Pt,t),s(Dt,!0),i(`Using anonymous session with token: "${t}"`)}}async function qt(){const t=At();return null===t?null:await async function(t){const e=(new TextEncoder).encode(t),n=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n)).map(t=>t.toString(16).padStart(2,"0")).join("")}(t)}function zt(){const t=At();return null===t?null:btoa(t)}function Wt(){r(Pt),i("Cleared user token")}const _t={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 Ot(t){let e=_t.tooltipArrowColor;if((t?.properties?.gist?.tooltipArrowColor?.length??0)>0)e=t.properties.gist.tooltipArrowColor;else{if(!Array.isArray(t?.displaySettings)||0===t.displaySettings.length)return e;let n=t.displaySettings[0];if(t.savedStepName){const e=t.displaySettings.find(e=>e?.stepName===t.savedStepName&&e.displaySettings);e&&(n=e)}n?.displaySettings?.tooltipArrowColor&&(e=n.displaySettings.tooltipArrowColor)}return e}function Bt(t){const e=_t,n=t?.properties?.gist;return n?{isEmbedded:!!n.elementId&&!n.tooltipPosition,elementId:n.elementId||"",hasRouteRule:!!n.routeRuleWeb,routeRule:n.routeRuleWeb||"",position:n.position||"",hasPosition:!!n.position,tooltipPosition:n.tooltipPosition||"",hasTooltipPosition:!!n.tooltipPosition,tooltipArrowColor:Ot(t),shouldScale:!!n.scale,campaignId:n.campaignId??null,messageWidth:null!=n.messageWidth&&n.messageWidth>0?n.messageWidth:e.messageWidth,hasCustomWidth:(n.messageWidth??0)>0,overlayColor:n.overlayColor||e.overlayColor,persistent:!!n.persistent,exitClick:!!n.exitClick}:e}const Ut=["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 Ht(t){if(document.getElementById(t))return;const e=document.createElement("div");e.id=t,"x-gist-top"===t?document.body.insertBefore(e,document.body.firstChild):document.body.insertAdjacentElement("beforeend",e),i("Top & bottom elements injected into page")}const Ft=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function Vt(t){return ii.currentMessages.find(e=>e.instanceId===t)}function Gt(t){return!!t&&ii.currentMessages.some(e=>e.queueId===t)}function Xt(t){return t?ii.currentMessages.find(e=>e.elementId===t)??null:null}function Jt(t){ii.currentMessages=ii.currentMessages.filter(e=>e.instanceId!==t)}function Qt(t,e){Jt(t),ii.currentMessages.push(e)}const Yt={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"},Kt=Object.fromEntries(Object.entries(Yt).map(([t,e])=>[e,t]));function Zt(t){return t&&Yt[t]?Yt[t]:(i(`Invalid overlay position "${t}", defaulting to "topCenter"`),Yt.topCenter)}function te(t){try{const e=new RegExp(t),n=new URL(window.location.href).pathname,i=null!=ii.currentRoute&&e.test(ii.currentRoute),o=ii.currentRoute!==n&&e.test(n);return i||o}catch{return!1}}function ee(t){return t.tooltipPosition?"tooltip":t.overlay?"modal":t.elementId&&Ut.includes(t.elementId)?"overlay":t.elementId?"inline":"modal"}function ne(t,e){const n=ee(t),i=e.displayType;if(void 0===i)return!1;if(n!==i)return!0;const o=Bt(t);switch(i){case"modal":{if((t.position||"center")!==(e.modalPosition||"center"))return!0;const n=e.dismissOutsideClick??_t.exitClick;if(o.exitClick!==n)return!0;const i=e.overlayColor??_t.overlayColor;if(o.overlayColor!==i)return!0;break}case"overlay":{const n=Zt(e.overlayPosition);if(t.elementId!==n)return!0;break}case"inline":if(t.elementId!==e.elementSelector)return!0;break;case"tooltip":if(t.tooltipPosition!==e.tooltipPosition)return!0;if(t.elementId!==e.elementSelector)return!0;if(void 0!==e.tooltipArrowColor&&o.tooltipArrowColor!==e.tooltipArrowColor)return!0}if("overlay"!==i||!Ft.includes(Zt(e.overlayPosition))){const t=e.maxWidth??_t.messageWidth;if(o.messageWidth!==t)return!0}return!1}function ie(t,e){if(t.properties||(t.properties={}),t.properties.gist||(t.properties.gist={}),"modal"===e.displayType)t.overlay=!0,t.elementId=null,t.properties.gist.elementId=null,t.position=e.modalPosition||"center",t.properties.gist.position=e.modalPosition||"center",t.tooltipPosition=void 0,t.properties.gist.tooltipPosition=void 0,t.properties.gist.tooltipArrowColor=void 0;else if("overlay"===e.displayType){t.overlay=!1;const n=Zt(e.overlayPosition);t.elementId=n,t.properties.gist.elementId=n,t.position=null,t.properties.gist.position=null,t.tooltipPosition=void 0,t.properties.gist.tooltipPosition=void 0,t.properties.gist.tooltipArrowColor=void 0}else"inline"===e.displayType?(t.overlay=!1,t.elementId=e.elementSelector,t.properties.gist.elementId=e.elementSelector,t.position=null,t.properties.gist.position=null,t.tooltipPosition=void 0,t.properties.gist.tooltipPosition=void 0,t.properties.gist.tooltipArrowColor=void 0):"tooltip"===e.displayType&&(t.overlay=!1,t.elementId=e.elementSelector,t.properties.gist.elementId=e.elementSelector,t.tooltipPosition=e.tooltipPosition,t.properties.gist.tooltipPosition=e.tooltipPosition,t.position=null,t.properties.gist.position=null,void 0!==e.tooltipArrowColor&&(t.properties.gist.tooltipArrowColor=e.tooltipArrowColor));t.elementId&&Ft.includes(t.elementId)?delete t.properties.gist.messageWidth:void 0!==e.maxWidth&&e.maxWidth>0?t.properties.gist.messageWidth=e.maxWidth:delete t.properties.gist.messageWidth,void 0!==e.overlayColor?t.properties.gist.overlayColor=e.overlayColor:delete t.properties.gist.overlayColor,void 0!==e.dismissOutsideClick?t.properties.gist.exitClick=e.dismissOutsideClick:delete t.properties.gist.exitClick}const oe={top:["bottom","left","right"],bottom:["top","left","right"],left:["right","top","bottom"],right:["left","top","bottom"]},se=/auto|scroll/,ae={top:"gist-arrow-bottom",bottom:"gist-arrow-top",left:"gist-arrow-right",right:"gist-arrow-left"};function re(t){const e=R(t);return e||i(`Tooltip target element not found for selector: ${t}`),e}function le(t,e){if(t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth)return!1;for(const n of e){const e=n.getBoundingClientRect();if(t.bottom<=e.top||t.top>=e.bottom||t.right<=e.left||t.left>=e.right)return!1}return!0}function de(t,e,n){const i=function(t,e,n){switch(n){case"top":return{top:e.top-t.height-16,left:e.left+(e.width-t.width)/2};case"bottom":return{top:e.bottom+16,left:e.left+(e.width-t.width)/2};case"left":return{top:e.top+(e.height-t.height)/2,left:e.left-t.width-16};case"right":return{top:e.top+(e.height-t.height)/2,left:e.right+16}}}(t,e,n);return function(t,e,n){return"top"===n||"bottom"===n?t.top>=0&&t.top+e.height<=window.innerHeight:t.left>=0&&t.left+e.width<=window.innerWidth}(i,t,n)&&function(t,e){return"top"===e||"bottom"===e?t.width+8<=window.innerWidth:t.height+8<=window.innerHeight}(t,n)?function(t,e,n){let{top:i,left:o}=t,s=null;if("top"===n||"bottom"===n){const t=4,n=window.innerWidth-e.width-4;n>=t&&(o<t?(s=o-t,o=t):o>n&&(s=o-n,o=n))}else{const t=4,n=window.innerHeight-e.height-4;n>=t&&(i<t?(s=i-t,i=t):i>n&&(s=i-n,i=n))}if(null!==s){const t=("top"===n||"bottom"===n?e.width/2:e.height/2)-16-4;Math.abs(s)>t&&(s=s>0?t:-t)}return{top:i,left:o,position:n,arrowOffset:s}}(i,t,n):null}function ce(t,e,n){const i=de(t,e,n);if(i)return i;for(const i of oe[n]){const n=de(t,e,i);if(n)return n}return null}function pe(t){const e=[];let n=t.parentElement;for(;n;){const t=getComputedStyle(n),i=t.overflow+t.overflowX+t.overflowY;se.test(i)&&e.push(n),n=n.parentElement}return e}function ue(t){const e=R(t);e&&(e.classList.remove("gist-visible"),Array.from(e.classList).filter(t=>t.startsWith("gist-")).forEach(t=>e.classList.remove(t)),e.style.removeProperty("height"),e.style.removeProperty("width"),e.innerHTML="")}function ge(t){const e=R(t);if(e)return!(!e.style||!e.style.height||"0px"===e.style.height)}function me(t,e,n=null){const i=document.getElementById(t);i&&(i.onload=()=>{!function(t,e,n=null){const i=document.getElementById(t);if(i?.contentWindow){const t={options:e,capabilities:fe};n&&(e.stepId=n),i.contentWindow.postMessage(t,"*")}}(t,e,n)})}const fe=["MultiStepDisplayTypes"];function he(t){if(!t.displaySettings)return;const e=xe(t.instanceId??""),n=document.getElementById(e);n?.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:t.displaySettings},"*")}async function be(){const t=document.querySelector(".gist-message");t&&(t.classList.remove("gist-visible"),await new Promise(t=>setTimeout(t,300))),ye()}function ye(){const t=document.querySelector("#gist-embed-message");t&&t.parentNode?.removeChild(t)}const ve=new Map;function we(t){const e=t.instanceId??"",n=ve.get(e);n&&(n.cleanup(),ve.delete(e));const i=R(`gist-tooltip-${e}`);i&&i.parentNode?.removeChild(i)}function xe(t){return`gist-${t}`}function Se(){const t=document.querySelector(".gist-message");t&&t.classList.add("gist-visible")}const Ie="gist.web.customAttributes";let Ce=new Map;function $e(){const t=Array.from(Ce.entries()),e=new Date;e.setDate(e.getDate()+30),s(Ie,t,e),i(`Saved ${Ce.size} custom attributes to storage with TTL of 30 days`)}async function ke(t){const e=await Pe();if(!e)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(e,t.filter(Le),n)}async function Ee(){const t=await Pe();return t?(a(t)??[]).filter(e=>{const n=e.properties.gist.broadcast,{frequency:i}=n,o=a(Ne(t,e.queueId))??!0,s=a(De(t,e.queueId))||0,r=0===i.count;return o&&(r||s<i.count)}):[]}async function je(t,e){const n=a(t);return n?.find(t=>t.queueId===e)}function Le(t){return!(!t.properties?.gist||!t.properties.gist.broadcast)}function Te(t){if(!Le(t))return!1;const e=t.properties.gist.broadcast;return 0===e.frequency.delay&&0===e.frequency.count}async function Pe(){const t=await qt();return t?`gist.web.message.broadcasts.${t}`:null}function De(t,e){return`${t}.${e}.numberOfTimesShown`}function Ne(t,e){return`${t}.${e}.shouldShow`}!function(){const t=a(Ie);if(t)try{Ce=new Map(t)}catch{Ce=new Map}else Ce=new Map}();const Me="gist.web.message.user";async function Ae(t){const e=await qe();if(!e)return;const n=t.filter(t=>!(t.properties&&t.properties.gist&&t.properties.gist.broadcast)),i=new Date;i.setMinutes(i.getMinutes()+60),s(e,n,i)}async function Re(){const t=await qe();if(!t)return[];const e=a(t)??[],n=await async function(){const t=await ze();return t?a(t)??[]:[]}();return e.filter(t=>!n.includes(t.queueId??""))}async function qe(){const t=await qt();return t?`${Me}.${t}`:null}async function ze(){const t=await qt();return t?`${Me}.${t}.seen`:null}async function We(t){const e=await qt();return e?`${Me}.${e}.message.${t}.loading`:null}async function _e(t){const e=await qt();return e?`${Me}.${e}.message.${t}.state`:null}async function Oe(t){const e=await _e(t);e&&(r(e),i(`Cleared message state for queueId: ${t}`))}function Be(t){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="${t}"/></svg>`}const Ue=`\n #gist-preview-bar {\n position: fixed; bottom: 0; left: 0; right: 0;\n z-index: 99999999999;\n font-family: system-ui, -apple-system, sans-serif;\n pointer-events: none;\n }\n .gist-pb-toggle-row {\n display: flex; justify-content: center;\n padding: 6px 16px;\n border-bottom: 1px solid #e5e7eb;\n }\n .gist-pb-toggle-row--collapsed { border-bottom: none; }\n .gist-pb-toggle-btn {\n background: #08272B; border: none;\n padding: 4px 14px;\n border-radius: 100px;\n font-size: 12px; font-weight: 500;\n font-family: system-ui, -apple-system, sans-serif;\n color: white; cursor: pointer;\n display: flex; align-items: center; gap: 6px;\n pointer-events: auto;\n height: auto; min-width: auto;\n box-sizing: border-box;\n line-height: normal;\n -webkit-appearance: none;\n appearance: none;\n }\n .gist-pb-controls-row {\n background: #F8F9F9;\n box-shadow: 1px 2px 2px #34344605, 3px 3px 8px #34344614;\n display: flex; flex-wrap: wrap; align-items: center;\n gap: 12px; padding: 10px 16px 12px;\n pointer-events: auto;\n }\n .gist-pb-label-group { display: flex; flex-direction: column; gap: 4px; }\n .gist-pb-label-group--grow { flex: 1; }\n .gist-pb-label {\n font-size: 10px; font-weight: 600; color: #3F4E50;\n letter-spacing: 0.05em; text-transform: uppercase;\n font-family: system-ui, -apple-system, sans-serif;\n }\n .gist-pb-select {\n height: 32px; padding: 0 32px 0 8px;\n border: 1px solid #d1d5db; border-radius: 6px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n background: white ${`url("data:image/svg+xml,${encodeURIComponent(Be("#3F4E50"))}")`} no-repeat right 2px center;\n color: #3F4E50; cursor: pointer; outline: none;\n appearance: none; min-width: 120px;\n }\n .gist-pb-input {\n height: 32px; padding: 0 8px;\n border: 1px solid #d1d5db; border-radius: 6px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; outline: none; box-sizing: border-box;\n }\n .gist-pb-checkbox-row { display: flex; align-items: center; gap: 6px; height: 32px; }\n .gist-pb-checkbox-label {\n font-size: 12px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; cursor: pointer; user-select: none;\n }\n .gist-pb-color-control {\n display: flex; align-items: center;\n border: 1px solid #d1d5db; border-radius: 6px;\n overflow: hidden; height: 32px; background: white;\n }\n .gist-pb-color-swatch {\n width: 28px; height: 100%;\n cursor: pointer; flex-shrink: 0;\n border-right: 1px solid #d1d5db; position: relative;\n }\n .gist-pb-color-input {\n position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;\n }\n .gist-pb-color-hex {\n flex: 1; border: none; outline: none; padding: 0 6px;\n font-size: 13px; font-family: monospace; color: #3F4E50;\n min-width: 0; background: transparent;\n }\n .gist-pb-color-opacity {\n width: 36px; border: none; border-left: 1px solid #d1d5db;\n outline: none; padding: 0 4px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; background: transparent; text-align: right;\n }\n .gist-pb-color-pct {\n font-size: 12px; color: #3F4E50; padding: 0 6px 0 2px;\n font-family: system-ui, -apple-system, sans-serif; flex-shrink: 0;\n }\n .gist-pb-input--invalid { border-color: #941616; outline: 1px solid #941616; }\n .gist-pb-inline-row { display: flex; align-items: center; gap: 6px; }\n .gist-pb-select-elem-btn, .gist-pb-cancel-btn {\n height: 32px; padding: 0 12px;\n border: none; border-radius: 6px;\n font-size: 12px; font-weight: 500; font-family: system-ui, -apple-system, sans-serif;\n background: #08272B; color: white; cursor: pointer; white-space: nowrap; flex-shrink: 0;\n min-width: auto; box-sizing: border-box;\n -webkit-appearance: none; appearance: none;\n }\n .gist-pb-select-elem-btn:disabled {\n opacity: 0.4; cursor: not-allowed;\n }\n .gist-pb-spacer { flex: 1; min-width: 0; }\n .gist-pb-save-btn {\n height: 36px; padding: 0 18px;\n background: #08272B; color: white;\n border: none; border-radius: 6px;\n font-size: 13px; font-weight: 600;\n font-family: system-ui, -apple-system, sans-serif;\n cursor: pointer; white-space: nowrap; align-self: center;\n min-width: auto; box-sizing: border-box;\n -webkit-appearance: none; appearance: none;\n }\n .gist-pb-save-btn:disabled {\n background: #CAD6D8; cursor: not-allowed;\n }\n .gist-pb-picker-overlay {\n position: fixed; inset: 0; z-index: 999999999998; cursor: crosshair;\n }\n .gist-pb-checkbox { cursor: pointer; width: 14px; height: 14px; }\n .gist-pb-pick-highlight { outline: 2px solid #006FF5 !important; }\n .gist-pb-pick-error { outline: 2px solid #941616 !important; }\n #gist-preview-bar.gist-pb-hidden { display: none; }\n .gist-pb-ended-row {\n justify-content: center; align-items: center; gap: 10px; padding: 12px 16px;\n flex-wrap: nowrap;\n }\n .gist-pb-ended-icon {\n display: flex; align-items: center; justify-content: center;\n width: 22px; height: 22px; border-radius: 50%;\n background: #08272B; color: white;\n font-size: 13px; font-weight: 700; flex-shrink: 0;\n }\n .gist-pb-ended-text {\n margin: 0; font-size: 13px; color: #3F4E50;\n font-family: system-ui, -apple-system, sans-serif;\n min-width: 0;\n }\n .gist-pb-ended-text strong { color: #08272B; }\n @media (max-width: 1024px) {\n .gist-pb-controls-row { gap: 8px; }\n .gist-pb-label-group { flex: 1 1 100%; }\n .gist-pb-label-group--grow { flex: 1 1 100%; }\n .gist-pb-select { width: 100%; min-width: unset; box-sizing: border-box; }\n .gist-pb-input { width: 100% !important; box-sizing: border-box; }\n .gist-pb-color-control { width: 100%; }\n .gist-pb-checkbox-row { width: 100%; }\n .gist-pb-inline-row { flex-direction: row; align-items: center; }\n .gist-pb-inline-row .gist-pb-input { flex: 1; min-width: 0; }\n .gist-pb-save-btn { width: 100%; box-sizing: border-box; }\n .gist-pb-label--spacer { display: none; }\n }\n`;const He="cioPreviewId",Fe="cioPreviewSettings";const Ve="gist.previewBar.collapsed",Ge="gist-pb-styles",Xe="gist-preview-bar",Je={topLeft:"Top Left",topCenter:"Top Center",topRight:"Top Right",bottomLeft:"Bottom Left",bottomCenter:"Bottom Center",bottomRight:"Bottom Right"};let Qe=null,Ye=[],Ke={},Ze=null,tn=!1,en=!1,nn=5,on=null,sn=!0,an=!1,rn=!1,ln=null,dn=null,cn=null;const pn=new Map;function un(t,e){const n=q("div",{className:"gist-pb-label-group"});return n.appendChild(q("span",{className:"gist-pb-label",textContent:t})),n.appendChild(e),n}function gn(t,e){const n=q("select",{className:"gist-pb-select"});for(const i of t){const t=q("option",{value:i.value,textContent:i.label});i.value===e&&(t.selected=!0),n.appendChild(t)}return n}function mn(t,e,n){const i=q("input",{className:"gist-pb-input",type:t,value:String(e)});return n&&(i.style.width=n),i}function fn(t,e){const n=Math.round(Math.min(100,Math.max(0,e))/100*255);return"#"+t.replace("#","").toUpperCase()+n.toString(16).padStart(2,"0").toUpperCase()}function hn(t){return!!("inline"!==t.displayType&&"tooltip"!==t.displayType||t.elementSelector?.trim())}function bn(t){if("overlay"===t.displayType&&Ft.includes(Zt(t.overlayPosition))){const{maxWidth:e,...n}=t;t=n}if(Ke=t,Ze){const e=Ye.findIndex(t=>t.stepName===Ze);-1!==e&&(Ye[e]={...Ye[e],displaySettings:{...t}})}if(!Qe)return;const e=ii.currentMessages.find(t=>t.instanceId===Qe);e&&hn(t)&&(he(e),ne(e,t)&&Vn(e,Ze,t)),function(){const t=new URLSearchParams(window.location.search).get(He);t&&async function(t,e){try{return await E()(`/api/v1/preview/${t}`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}catch(t){return k(t)}}(t,Ye).then(t=>{t&&404===t.status&&Qe&&ii.dismissMessage(Qe)}).catch(()=>i("Failed to persist preview display settings"))}()}function yn(t){const e=t.value.trim();e&&!R(e)?t.classList.add("gist-pb-input--invalid"):t.classList.remove("gist-pb-input--invalid")}function vn(t,e){const n=mn("text",t.elementSelector||"","260px");n.placeholder="Element ID or selector",yn(n),n.addEventListener("change",()=>{const t=n.value.trim(),e=Ke.elementSelector;t&&wn(t),bn({...Ke,elementSelector:t}),e&&e!==t&&xn(e),yn(n)});const i=q("button",{type:"button",className:"gist-pb-select-elem-btn",textContent:"Select Element"});rn&&(i.disabled=!0),i.addEventListener("click",()=>In(n));const o=q("div",{className:"gist-pb-inline-row"});o.appendChild(n),o.appendChild(i),e.appendChild(un("Element Selector",o))}function wn(t){if(!t||pn.has(t))return;const e=R(t);e&&pn.set(t,e.innerHTML)}function xn(t){const e=pn.get(t);if(void 0===e)return;const n=R(t);n&&(n.innerHTML=e)}function Sn(){for(const t of pn.keys())xn(t);pn.clear()}function In(t){if(rn)return;rn=!0;const e=document.querySelector(`#${Xe} .gist-pb-select-elem-btn`);e&&(e.disabled=!0);const n={...Ke},o=ii.currentMessages.find(t=>t.instanceId===Qe)??null;o&&Fn(o),Ke.elementSelector&&xn(Ke.elementSelector);const s=q("div",{className:"gist-pb-picker-overlay"});let a=null;const r=t=>{s.style.pointerEvents="none";const e=document.elementFromPoint(t.clientX,t.clientY);s.style.pointerEvents="all",e&&e!==a&&e!==s&&(a?.classList.remove("gist-pb-pick-highlight"),a=e,a.classList.add("gist-pb-pick-highlight"))},l=t=>{if("Escape"===t.key){if(c(),Ke=n,Ze){const t=Ye.findIndex(t=>t.stepName===Ze);-1!==t&&(Ye[t]={...Ye[t],displaySettings:{...n}})}o&&hn(n)&&Vn(o,Ze,n),Cn()}},d=e=>{e.preventDefault(),e.stopPropagation(),s.style.pointerEvents="none";const n=document.elementFromPoint(e.clientX,e.clientY);if(s.style.pointerEvents="all",n&&n!==s){n.classList.remove("gist-pb-pick-highlight");const e=document.getElementById(Xe),s=e?.contains(n)?null:function(t){if(t.id){const e=CSS.escape(t.id);if(1===document.querySelectorAll(`#${e}`).length)return t.id}const e=[];let n=t;for(;n&&"BODY"!==n.tagName&&"HTML"!==n.tagName;){if(n.id){const t=CSS.escape(n.id);if(1===document.querySelectorAll(`#${t}`).length){e.unshift(`#${t}`);break}}let t=n.tagName.toLowerCase();n.className&&"string"==typeof n.className&&(t+=n.className.trim().split(/\s+/).filter(Boolean).map(t=>`.${CSS.escape(t)}`).join(""));const i=n.parentElement;i&&(t+=`:nth-of-type(${Array.from(i.children).filter(t=>t.tagName===n.tagName).indexOf(n)+1})`),e.unshift(t);try{if(1===document.querySelectorAll(e.join(" > ")).length)break}catch{}n=n.parentElement}const o=e.join(" > ");try{if(1!==document.querySelectorAll(o).length)return i("buildUniqueSelector: could not produce a unique selector for element"),null}catch{return null}return o}(n);if(null===s)return n.classList.add("gist-pb-pick-error"),void setTimeout(()=>{n.classList.remove("gist-pb-pick-error"),n.classList.add("gist-pb-pick-highlight")},800);t.value=s,wn(s);const a=Ke.elementSelector,r={...Ke,elementSelector:s},l=null!=o&&hn(r)&&ne(o,r);bn(r),a&&a!==s&&xn(a),o&&!l&&Vn(o,Ze,r)}c(),Cn()},c=()=>{a?.classList.remove("gist-pb-pick-highlight"),s.removeEventListener("mousemove",r),s.removeEventListener("click",d),document.removeEventListener("keydown",l),document.body.removeChild(s),rn=!1,ln=null};ln=c,s.addEventListener("mousemove",r),s.addEventListener("click",d),document.addEventListener("keydown",l),document.body.appendChild(s)}function Cn(){const t=document.getElementById(Xe);if(!t)return;if(t.classList.toggle("gist-pb-hidden",!Qe&&!en),t.innerHTML="",!Qe){if(en){const e=q("div",{className:"gist-pb-controls-row gist-pb-ended-row"}),n=q("span",{className:"gist-pb-ended-icon",textContent:"✓"}),i=q("p",{className:"gist-pb-ended-text"});if(i.innerHTML=kn(nn),e.appendChild(n),e.appendChild(i),sn){const t=q("button",{type:"button",className:"gist-pb-cancel-btn",textContent:"Cancel"});t.addEventListener("click",En),e.appendChild(t)}t.appendChild(e)}return}const e=q("div",{className:"gist-pb-toggle-row"+(tn?" gist-pb-toggle-row--collapsed":"")}),n=q("button",{type:"button",className:"gist-pb-toggle-btn"}),i=tn?"transform:rotate(180deg);display:inline-flex;":"display:inline-flex;";if(n.innerHTML=`${tn?"Expand":"Collapse"}<span style="${i}">${Be("white")}</span>`,n.addEventListener("click",jn),e.appendChild(n),t.appendChild(e),tn)return;const o=q("div",{className:"gist-pb-controls-row"});if(Ye.length>0){const t=Ze??Ye[0].stepName,e=gn(Ye.map(t=>({value:t.stepName,label:t.stepName})),t);e.addEventListener("change",()=>{const t=Ye.find(t=>t.stepName===e.value);if(t){Ze=t.stepName,Ke={...t.displaySettings};const e=ii.currentMessages.find(t=>t.instanceId===Qe);e&&hn(t.displaySettings)&&Vn(e,t.stepName,t.displaySettings),Cn()}}),o.appendChild(un("Step",e))}const s=gn([{value:"modal",label:"Modal"},{value:"overlay",label:"Overlay"},{value:"inline",label:"Inline"},{value:"tooltip",label:"Tooltip"}],Ke.displayType||"modal");s.addEventListener("change",()=>{const t=s.value,e=Ke.displayType,n=Ke.elementSelector,i={...Ke,displayType:t};"modal"===t?(i.modalPosition=i.modalPosition||"center",i.maxWidth=i.maxWidth??414,delete i.overlayPosition,delete i.elementSelector,delete i.tooltipPosition):"overlay"===t?(i.overlayPosition=i.overlayPosition||"topCenter",i.maxWidth=i.maxWidth??414,delete i.modalPosition,delete i.elementSelector,delete i.tooltipPosition):"inline"===t?(delete i.modalPosition,delete i.overlayPosition,delete i.tooltipPosition):"tooltip"===t&&(i.tooltipPosition=i.tooltipPosition||"top",delete i.modalPosition,delete i.overlayPosition,delete i.overlayColor,delete i.dismissOutsideClick),Ke=i,bn(Ke),"inline"!==e&&"tooltip"!==e||!n||"inline"===t||"tooltip"===t||xn(n),Cn()}),o.appendChild(un("Display Type",s));const a=Ke.displayType||"modal";"modal"===a?function(t,e){const n=gn([{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}],t.modalPosition||"center");n.addEventListener("change",()=>bn({...Ke,modalPosition:n.value})),e.appendChild(un("Position",n));const i=mn("number",t.maxWidth??414,"80px");i.addEventListener("change",()=>bn({...Ke,maxWidth:parseInt(i.value)||414})),e.appendChild(un("Max Width",i)),e.appendChild(function(t){const{color:e,opacity:n}=function(t){const e=t.replace("#","");return 8===e.length?{color:"#"+e.slice(0,6).toUpperCase(),opacity:Math.round(parseInt(e.slice(6),16)/255*100)}:6===e.length?{color:"#"+e.toUpperCase(),opacity:100}:{color:"#000000",opacity:20}}(t.overlayColor||"#00000033"),i=q("div",{className:"gist-pb-color-control"}),o=q("input",{className:"gist-pb-color-input",type:"color",value:e}),s=q("div",{className:"gist-pb-color-swatch"});s.style.background=e,s.appendChild(o),s.addEventListener("click",()=>o.click());const a=q("input",{className:"gist-pb-color-hex",type:"text",maxLength:6,value:e.replace("#","")}),r=q("input",{className:"gist-pb-color-opacity",type:"number",min:"0",max:"100",value:String(n)}),l=q("span",{className:"gist-pb-color-pct",textContent:"%"}),d=()=>{const t="#"+a.value.replace("#",""),e=parseInt(r.value)||0;s.style.background=t,o.value=t,bn({...Ke,overlayColor:fn(t,e)})};return o.addEventListener("input",()=>{a.value=o.value.replace("#","").toUpperCase(),s.style.background=o.value}),o.addEventListener("change",d),a.addEventListener("change",d),r.addEventListener("change",d),i.appendChild(s),i.appendChild(a),i.appendChild(r),i.appendChild(l),un("Overlay Color",i)}(t));const o=q("div",{className:"gist-pb-checkbox-row"}),s=q("input",{className:"gist-pb-checkbox",type:"checkbox"});s.checked=t.dismissOutsideClick??!1;const a=q("label",{className:"gist-pb-checkbox-label",textContent:"Dismiss on click outside"});s.addEventListener("change",()=>bn({...Ke,dismissOutsideClick:s.checked})),a.addEventListener("click",()=>{s.checked=!s.checked,bn({...Ke,dismissOutsideClick:s.checked})}),o.appendChild(s),o.appendChild(a);const r=un(" ",o);r.classList.add("gist-pb-label-group--grow"),r.firstChild.classList.add("gist-pb-label--spacer"),e.appendChild(r)}(Ke,o):"overlay"===a?function(t,e){const n=gn(Object.entries(Je).map(([t,e])=>({value:t,label:e})),t.overlayPosition||"topCenter");if(n.addEventListener("change",()=>bn({...Ke,overlayPosition:n.value})),e.appendChild(un("Position",n)),!Ft.includes(Zt(t.overlayPosition))){const n=mn("number",t.maxWidth??414,"80px");n.addEventListener("change",()=>bn({...Ke,maxWidth:parseInt(n.value)||414})),e.appendChild(un("Max Width",n))}}(Ke,o):"inline"===a?function(t,e){vn(t,e)}(Ke,o):"tooltip"===a&&function(t,e){const n=gn([{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],t.tooltipPosition||"top");n.addEventListener("change",()=>bn({...Ke,tooltipPosition:n.value})),e.appendChild(un("Position",n)),vn(t,e)}(Ke,o),o.appendChild(q("div",{className:"gist-pb-spacer"}));const r=q("button",{type:"button",className:"gist-pb-save-btn",textContent:"End session"});r.addEventListener("click",async()=>{Qe&&await ii.dismissMessage(Qe)}),o.appendChild(r),t.appendChild(o)}async function $n(){if(!an)if(an=!0,Wt(),function(){try{sessionStorage.removeItem(o)}catch{}}(),sn){try{window.close()}catch{}try{window.location.reload()}catch{}ln&&ln(),on&&(clearInterval(on),on=null),Sn(),document.getElementById(Xe)?.remove(),document.getElementById(Ge)?.remove(),Qe=null,Ye=[],Ke={},Ze=null,en=!1,nn=5,sn=!0,an=!1}else en=!1,an=!1,Cn()}function kn(t){return sn?`<strong>Preview session ended.</strong> This tab will close in ${t}s…`:`<strong>Preview session ended.</strong> Finishing session in ${t}s… This tab will stay open.`}function En(){en&&on&&(sn=!1,Cn())}function jn(){tn=!tn;try{sessionStorage.setItem(Ve,String(tn))}catch{}Cn()}function Ln(t){if(en)return;Qe=t.instanceId??null;const e=t.displaySettings;if(Array.isArray(e)&&e.length>0?(Ye=e,Ze||(Ze=Ye[0].stepName,Ke={...Ye[0].displaySettings})):e&&"object"==typeof e&&!Array.isArray(e)&&(Ke={...e}),dn||cn){const t=!!dn,e=!!cn,n=dn,o=cn;if(dn=null,cn=null,t){const t=Ye.find(t=>t.stepName===n);if(!t)return i(`Preview bar: step "${n}" not found, ignoring initial step/display override`),void Cn();Ze=t.stepName,Ke={...t.displaySettings}}if(e){if(!t)return i(`Preview bar: display type "${o}" provided without a step, ignoring`),void Cn();Ke={...Ke,displayType:o}}Cn();const s=ii.currentMessages.find(t=>t.instanceId===Qe);return void(s&&hn(Ke)?Vn(s,Ze,Ke):function(){const t=Ke.displayType;if("inline"!==t&&"tooltip"!==t)return;const e=document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");e&&In(e)}())}Cn()}function Tn(){Sn(),Qe=null,Ye=[],Ke={},Ze=null,en=!0,nn=5,sn=!0,an=!1;const t=new URLSearchParams(window.location.search).get(He);t&&async function(t){try{return await E()(`/api/v1/preview/${t}`,{method:"DELETE"})}catch(t){return k(t)}}(t).catch(()=>i("Failed to delete preview session")),Cn(),on&&clearInterval(on),on=setInterval(async()=>{if(nn-=1,nn<=0)clearInterval(on),on=null,await $n();else{const t=document.querySelector(`#${Xe} .gist-pb-ended-text`);t?t.innerHTML=kn(nn):Cn()}},1e3)}async function Pn(t){if(!ii.isDocumentVisible)return i("Document hidden, not showing message now."),null;if(Gt(t.queueId))return i(`Message with queueId ${t.queueId} is already showing.`),null;const e=Bt(t);return!t.tooltipPosition&&e.hasTooltipPosition&&(t.tooltipPosition=e.tooltipPosition),t.tooltipPosition?function(t,e){const n=e.elementId||t.elementId;if(!n)return i(`No target selector specified for tooltip message ${t.messageId}`),ii.messageError(t),null;if(!R(n)){if(!ii.config.isPreviewSession||!t.properties?.gist?.livePreview)return i(`Tooltip target element "${n}" not found for message ${t.messageId}, skipping display`),ii.messageError(t),null;i(`Preview: tooltip target "${n}" not found, loading message for preview bar`)}const o=ii.currentMessages.find(t=>t.tooltipPosition&&t.elementId===n);o&&(i(`Tooltip already showing on target "${n}" (instance ${o.instanceId}), dismissing it first`),ii.messageDismissed(o),we(o),o.instanceId&&Jt(o.instanceId)),t.instanceId=y(),t.overlay=!1,t.firstLoad=!0,t.shouldResizeHeight=!1,t.shouldScale=!1,t.renderStartTime=(new Date).getTime(),t.elementId=n,ii.currentMessages.push(t);return _n(t,null,t.savedStepName||null)}(t,e):ii.overlayInstanceId?(i(`Message ${ii.overlayInstanceId} already showing.`),null):(t.instanceId=y(),t.overlay=!0,t.firstLoad=!0,t.shouldResizeHeight=!0,t.shouldScale=e.shouldScale,t.renderStartTime=(new Date).getTime(),ii.overlayInstanceId=t.instanceId,ii.currentMessages.push(t),_n(t,null,t.savedStepName||null))}function Dn(t,e){return ii.isDocumentVisible?Gt(t.queueId)?(i(`Message with queueId ${t.queueId} is already showing.`),null):Xt(e)?(i(`Message with elementId ${e} already has a message.`),null):(t.instanceId=y(),t.overlay=!1,t.firstLoad=!0,t.shouldScale=!1,t.elementId=e,t.shouldResizeHeight=!ge(e),t.renderStartTime=(new Date).getTime(),ii.currentMessages.push(t),_n(t,e,t.savedStepName||null)):(i("Document hidden, not showing message now."),null)}async function Nn(t){t?(ii.messageDismissed(t),await Mn(t)):i("Message not found")}async function Mn(t){"tooltip"===ee(t)?qn(t):t.overlay?await zn(!0,t):Rn(t)}async function An(t){t?Bt(t).persistent&&(i("Persistent message dismissed, logging view"),await Gn(t),await On(t),await Oe(t.queueId??"")):i("Message not found")}function Rn(t){t.instanceId&&Jt(t.instanceId),t.elementId&&ue(t.elementId),ii.config.isPreviewSession&&(Tn(),Wn())}function qn(t){we(t),t.instanceId&&Jt(t.instanceId),0===ii.currentMessages.length&&(window.removeEventListener("message",Un),window.removeEventListener("touchstart",Bn)),ii.config.isPreviewSession&&(Tn(),Wn())}async function zn(t,e){t?await be():ye(),0===ii.currentMessages.length&&(window.removeEventListener("message",Un),window.removeEventListener("touchstart",Bn)),e.instanceId&&Jt(e.instanceId),ii.overlayInstanceId=null,ii.config.isPreviewSession&&(Tn(),Wn())}function Wn(){const t=new URL(window.location.href);t.searchParams.delete(He),t.searchParams.delete(Fe),history.replaceState(null,"",t.toString())}function _n(t,e=null,n=null){const o=ii.config.env,s={endpoint:C.ENGINE_API_ENDPOINT[o],siteId:ii.config.siteId,dataCenter:ii.config.dataCenter,messageId:t.messageId,instanceId:t.instanceId??"",livePreview:!1,properties:t.properties,customAttributes:Object.fromEntries(new Map(Ce))},a=`${C.GIST_VIEW_ENDPOINT[o]}/index.html`;return window.addEventListener("message",Un),window.addEventListener("touchstart",Bn),"tooltip"===ee(t)?function(t,e,n,i=null){const o=e.instanceId??"",s=xe(o),a=Bt(e),r=ve.get(o);r&&(r.cleanup(),ve.delete(o)),document.querySelectorAll(`#gist-tooltip-${o}`).forEach(t=>{t.parentNode?.removeChild(t)});const l=`gist-tooltip-${o}`,d=document.createElement("div");d.id=l,d.innerHTML=function(t,e,n,i=""){let o=600;e.messageWidth>o&&(o=e.messageWidth);const s=e.tooltipArrowColor,a=function(t){switch(t){case"top":default:return"gist-arrow-bottom";case"bottom":return"gist-arrow-top";case"left":return"gist-arrow-right";case"right":return"gist-arrow-left"}}(e.tooltipPosition),r=i?`#${i} `:"";return`\n <div class="gist-tooltip-outer">\n <style>\n ${r}.gist-tooltip-outer {\n position: absolute;\n }\n ${r}.gist-tooltip-container {\n position: relative;\n z-index: 9999999;\n opacity: 0;\n transition: opacity 0.3s ease-in-out;\n }\n ${r}.gist-tooltip-container.gist-visible {\n opacity: 1;\n }\n ${r}.gist-tooltip-frame-clip {\n overflow: hidden;\n }\n ${r}.gist-tooltip-frame {\n display: block;\n width: ${e.messageWidth}px;\n border: none;\n transition: height 0.1s ease-in-out;\n color-scheme: light only;\n }\n ${r}.gist-tooltip-arrow {\n width: 0;\n height: 0;\n position: absolute;\n z-index: 1;\n }\n ${r}.gist-tooltip-arrow.gist-arrow-bottom {\n bottom: 0;\n left: 50%;\n transform: translateX(-50%) translateY(100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-top: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-top {\n top: 0;\n left: 50%;\n transform: translateX(-50%) translateY(-100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-bottom: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-right {\n right: 0;\n top: 50%;\n transform: translateY(-50%) translateX(100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-left: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-left {\n left: 0;\n top: 50%;\n transform: translateY(-50%) translateX(-100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-right: 10px solid ${s};\n }\n @media (max-width: ${o}px) {\n ${r}.gist-tooltip-frame {\n max-width: 100%;\n }\n }\n </style>\n <div class="gist-tooltip-container">\n <div class="gist-tooltip-arrow ${a}"></div>\n <div class="gist-tooltip-frame-clip">\n <iframe id="${t}" class="gist-tooltip-frame" src="${n}"></iframe>\n </div>\n </div>\n </div>`}(s,a,t,l),document.body.appendChild(d),me(s,n,i)}(a,t,s,n):e?(Ut.includes(e)&&Ht(e),function(t,e,n,o,s=null){const a=R(t);if(a){const i=xe(n.instanceId??"");a.classList.add(i);const r=Bt(n);let l=r.messageWidth+"px";Ft.includes(t)&&!r.hasCustomWidth&&(l="100%"),Ut.includes(t)&&(a.style.width=l),ge(t)||(a.style.height="0px"),a.innerHTML=function(t,e,n){return function(t,e,n){let i=800;return e.messageWidth>i&&(i=e.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 color-scheme: light only;\n }\n #x-gist-top.${t},\n #x-gist-bottom.${t},\n #x-gist-floating-top.${t},\n #x-gist-floating-bottom.${t},\n #x-gist-floating-top-left.${t},\n #x-gist-floating-top-right.${t},\n #x-gist-floating-bottom-left.${t},\n #x-gist-floating-bottom-right.${t} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${i}px) {\n #x-gist-top.${t},\n #x-gist-bottom.${t},\n #x-gist-floating-top.${t},\n #x-gist-floating-bottom.${t},\n #x-gist-floating-top-left.${t},\n #x-gist-floating-top-right.${t},\n #x-gist-floating-bottom-left.${t},\n #x-gist-floating-bottom-right.${t} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${t}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(xe(e.instanceId??""),n,t)}(e,n,r),me(i,o,s)}else i(`Message could not be embedded, elementId ${t} not found.`)}(e,a,t,s,n)):function(t,e,n,i=null){document.querySelectorAll("#gist-embed-message").forEach(t=>{t.parentNode?.removeChild(t)}),document.body.insertAdjacentHTML("afterbegin",function(t,e){const n=Bt(e);return function(t,e,n){let i=600;return e.messageWidth>i&&(i=e.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: ${e.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.gist-background.gist-visible {\n visibility: visible;\n }\n .gist-message {\n width: ${e.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 color-scheme: light only;\n }\n .gist-message.gist-visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.gist-center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.gist-bottom {\n bottom: 0;\n }\n .gist-message.gist-top {\n top: 0;\n }\n @media (max-width: ${i}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="gist-background">\n <iframe id="${t}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(xe(e.instanceId??""),n,t)}(t,e)),me(xe(e.instanceId??""),n,i)}(a,t,s,n),t}async function On(t){let e;i(`Message shown, logging view for: ${t.messageId}`),null!=t.queueId?(await Gn(t),e=await _(t.queueId)):e=await async function(t){try{return await E().post(`/api/v1/logs/message/${t}`)}catch(t){return k(t)}}(t.messageId),i(200===e?.status?"Message view logged":`Problem logging message: ${e?.status}`)}function Bn(){}async function Un(t){const e=ii.config.env,n=t.data;if(n.gist&&t.origin===C.RENDERER_HOST[e]){const t=n.gist.instanceId,e=Vt(t);if(!e)return;const o=Bt(e);switch(n.gist.method){case"routeLoaded":{const s=.001*((new Date).getTime()-(e.renderStartTime??0));if(i(`Engine render for message: ${e.messageId} timer elapsed in ${s.toFixed(3)} seconds`),async function(t){const e=await We(t);e&&r(e)}(e.queueId??""),e.currentRoute=n.gist.parameters.route,n.gist.parameters.fullDisplaySettings&&!e.displaySettings?e.displaySettings=n.gist.parameters.fullDisplaySettings:e.displaySettings&&(i("SDK already has display settings state, sending it to iframe"),he(e)),ii.config.isPreviewSession&&e.properties?.gist?.livePreview&&Ln(e),e.firstLoad||e.isDisplayChange){if("tooltip"===ee(e)){const t=e.properties?.gist?.elementId||e.elementId||void 0;if(!t||!R(t)){if(ii.config.isPreviewSession&&e.properties?.gist?.livePreview){i(`Preview: tooltip target "${t}" not found, preview bar will show element picker`),e.firstLoad=!1,e.isDisplayChange=!1;break}i(`Tooltip target not found for "${t}", emitting error and skipping display`),ii.messageError(e),e.firstLoad=!1,e.isDisplayChange=!1,qn(e);break}const n=await async function(t){const e=t.instanceId??"",n=Bt(t),o=`gist-tooltip-${e}`,s=R(o);if(!s)return i(`Tooltip wrapper not found for instance ${e}`),!1;const a=t.properties?.gist?.elementId||t.elementId||void 0;if(!a)return i(`No target selector for tooltip ${e}`),!1;const r=ve.get(e);r&&(r.cleanup(),ve.delete(e));const l=s.querySelector(".gist-tooltip-outer");if(!l)return i(`Tooltip inner element not found for instance ${e}`),!1;const d=n.tooltipPosition||"bottom";if(!await async function(t,e,n){const o=re(e);if(!o)return!1;let s=[];try{s=pe(o)}catch{}if(le(o.getBoundingClientRect(),s))return!0;if(!function(t,e,n){const i=re(e);if(!i)return!1;const o=i.getBoundingClientRect(),s=window.innerWidth,a=window.innerHeight,r=new DOMRect(Math.max(0,(s-o.width)/2),Math.max(0,(a-o.height)/2),o.width,o.height);return t.style.display="",null!==ce(t.getBoundingClientRect(),r,n)}(t,e,n))return i(`Preflight failed: tooltip would not fit after scrolling target "${e}" into view`),!1;o.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),await function(t){return new Promise(e=>{let n=t.getBoundingClientRect(),i=0;const o=Date.now();setTimeout(function s(){const a=t.getBoundingClientRect();Math.abs(a.top-n.top)<1&&Math.abs(a.left-n.left)<1?i++:i=0,n=a,i>=2||Date.now()-o>1e3?e():setTimeout(s,50)},50)})}(o);const a=o.getBoundingClientRect();let r=[];try{r=pe(o)}catch{}return le(a,r)}(l,a,d))return i(`Tooltip for instance ${e} skipped: target "${a}" is off-screen and cannot be scrolled into a valid position`),!1;const c=function(t,e,n,o){const s=re(e);if(!s)return null;let a=null,r=null,l=!1,d=[],c=null;try{d=pe(s)}catch{}function p(){if(l)return;if(!s||!document.contains(s)||!document.contains(t))return i("Tooltip or target element removed from DOM, cleaning up listeners"),g(),void o?.onDetach?.();const e=s.getBoundingClientRect();if(!le(e,d))return void(t.style.display="none");t.style.display="";const a=ce(t.getBoundingClientRect(),e,n);a?(function(t,e){t.style.position="absolute",t.style.top=`${e.top+window.scrollY}px`,t.style.left=`${e.left+window.scrollX}px`}(t,a),function(t,e){const n=t.querySelector(".gist-tooltip-arrow");n&&(n.classList.remove("gist-arrow-top","gist-arrow-bottom","gist-arrow-left","gist-arrow-right"),n.classList.add(ae[e.position]),null!==e.arrowOffset?"top"===e.position||"bottom"===e.position?(n.style.left=`calc(50% + ${e.arrowOffset}px)`,n.style.removeProperty("top")):(n.style.top=`calc(50% + ${e.arrowOffset}px)`,n.style.removeProperty("left")):"top"===e.position||"bottom"===e.position?(n.style.left="50%",n.style.removeProperty("top")):(n.style.top="50%",n.style.removeProperty("left")))}(t,a)):t.style.display="none"}function u(){null===a&&(a=requestAnimationFrame(()=>{a=null,p()}))}function g(){if(!l){l=!0,c&&(c.disconnect(),c=null),window.removeEventListener("scroll",u),window.removeEventListener("resize",u);for(const t of d)t.removeEventListener("scroll",u);null!==a&&(cancelAnimationFrame(a),a=null),null!==r&&(cancelAnimationFrame(r),r=null)}}if(p(),l)return null;window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u,{passive:!0});for(const t of d)t.addEventListener("scroll",u,{passive:!0});try{c=new MutationObserver(()=>{null===r&&(r=requestAnimationFrame(()=>{r=null,document.contains(s)||p()}))}),c.observe(document.body,{childList:!0,subtree:!0})}catch{}return{cleanup:g,reposition:p}}(l,a,d,{onDetach:()=>{ve.delete(e);const t=R(o);t&&t.parentNode?.removeChild(t)}});if(c){if("none"!==l.style.display){const t=s.querySelector(".gist-tooltip-container");return t?(ve.set(e,c),t.classList.add("gist-visible"),!0):(c.cleanup(),i(`Tooltip container not found for instance ${e}`),!1)}return c.cleanup(),i(`Tooltip for instance ${e} could not be positioned within the viewport, target "${a}" may be off-screen`),!1}return i(`Failed to position tooltip for instance ${e}, target "${a}" may not exist or no position fits the viewport`),!1}(e);if(!n){if(ii.config.isPreviewSession&&e.properties?.gist?.livePreview){i(`Preview: tooltip positioning failed for "${t}", preview bar will remain active`),e.firstLoad=!1,e.isDisplayChange=!1;break}i(`Tooltip positioning failed for "${t}", emitting error and cleaning up`),ii.messageError(e),e.firstLoad=!1,e.isDisplayChange=!1,qn(e);break}}else e.overlay?function(t){const e=Bt(t),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");const i=document.querySelector(".gist-message");i&&(t.position?i.classList.add("gist-"+t.position):i.classList.add("gist-center")),setTimeout(Se,100),e.exitClick&&setTimeout(()=>function(t){const e=document.querySelector("#gist-overlay");e&&e.addEventListener("click",()=>{ii.dismissMessage(t)})}(t.instanceId??""),1e3)}else ye()}(e):function(t){const e=R(t);e&&e.classList.add("gist-visible")}(e.elementId);e.firstLoad&&!e.isDisplayChange&&(ii.messageShown(e),o.persistent?i("Persistent message shown, skipping logging view"):await On(e)),e.firstLoad=!1,e.isDisplayChange=!1}Qt(t,e);break}case"tap":{const t=n.gist.parameters.action,i=n.gist.parameters.name;if(ii.messageAction(e,t,i),n.gist.parameters.system&&!o.persistent){await Nn(e);break}try{const n=new URL(t);if(n&&"gist:"===n.protocol)switch(n.href.replace("gist://","").split("?")[0]){case"close":await An(e),await Xn(e),await Nn(e),await Zn();break;case"showMessage":{const t=n.searchParams.get("messageId"),e=n.searchParams.get("properties");if(t){const n=e?JSON.parse(atob(e)):void 0;await ii.showMessage({messageId:t,properties:n})}break}case"loadPage":{const t=n.href.substring(n.href.indexOf("?url=")+5);t&&(t.startsWith("mailto:")||t.startsWith("https://")||t.startsWith("http://")||t.startsWith("/")?window.location.href=t:window.location.href=window.location+t);break}}}catch{}break}case"changeMessageStep":{const t=n.gist.parameters.displaySettings,r=n.gist.parameters.messageStepName;ii.config.isPreviewSession&&r&&e.properties?.gist?.livePreview&&function(t,e){if(en)return;Ze=t;const n=Ye.find(e=>e.stepName===t);n?Ke={...n.displaySettings}:e&&(Ke={...e}),Cn()}(r,t),(o.persistent||Te(e))&&await async function(t,e,n){const o=await _e(t);if(!o)return;const r=a(o)||{},l={stepName:void 0!==e?e:r.stepName,displaySettings:void 0!==n?n:r.displaySettings},d=new Date;d.setDate(d.getDate()+30),s(o,l,d),i(`Saved message state for queueId: ${t}`)}(e.queueId??"",r,t),t&&ne(e,t)&&(i("Display settings changed, reloading message"),await Fn(e),ie(e,t),await Hn(e,r??null));break}case"routeChanged":e.currentRoute=n.gist.parameters.route,e.renderStartTime=(new Date).getTime(),Qt(t,e),i(`Route changed to: ${e.currentRoute}`);break;case"sizeChanged":i(`Size Changed Width: ${n.gist.parameters.width} - Height: ${n.gist.parameters.height}`),"tooltip"===ee(e)?function(t,e){const n=t.instanceId??"",i=xe(n),o=document.getElementById(i);if(o&&e.height>0){o.style.height=`${e.height}px`;const t=ve.get(n);t&&t.reposition()}}(e,n.gist.parameters):e.elementId&&!e.shouldResizeHeight||function(t,e){const n=R(t.elementId?t.elementId:xe(t.instanceId??""));if(n){const i=n.style;if(e.height>0)if(e.height>window.innerHeight){const n=1-(e.height/window.innerHeight-1);t.shouldScale&&n>=.4?(i.height=`${e.height}px`,i.transform=`translateX(-50%) translateY(-50%) scale(${n})`):i.height=`${window.innerHeight}px`}else i.height=`${e.height}px`}}(e,n.gist.parameters);break;case"titleChanged":i(`Overlay title changed to: ${n.gist.parameters.title}`),function(t,e){const n=R(xe(t));n&&(n.title=e)}(t,n.gist.parameters.title);break;case"eventDispatched":ii.events.dispatch("eventDispatched",{name:n.gist.parameters.name,payload:n.gist.parameters.payload});break;case"error":case"routeError":ii.messageError(e),"tooltip"===ee(e)?qn(e):ii.overlayInstanceId?await zn(!1,e):Rn(e)}}}async function Hn(t,e){t.isDisplayChange=!0,t.renderStartTime=(new Date).getTime();const n=ee(t),o=t.elementId||null;if("tooltip"===n)return ii.overlayInstanceId===t.instanceId&&(ii.overlayInstanceId=null),t.shouldScale=!1,t.shouldResizeHeight=!1,void _n(t,null,e);if(o){const e=Xt(o);e&&e.instanceId!==t.instanceId&&(i(`Dismissing existing message at ${o} to make room for multi-step message`),await Nn(e))}if(t.overlay){ii.overlayInstanceId=t.instanceId??null;const e=Bt(t);t.shouldScale=e.shouldScale,t.shouldResizeHeight=!0}else ii.overlayInstanceId=null,t.shouldScale=!1,t.shouldResizeHeight=!ge(o??"");o&&Ut.includes(o)&&Ht(o),_n(t,o,e)}async function Fn(t){"tooltip"===ee(t)?we(t):t.overlay?await be():t.elementId&&ue(t.elementId)}async function Vn(t,e,n){n&&ne(t,n)&&(await Fn(t),ie(t,n)),await Hn(t,e??null)}async function Gn(t){i(`Logging user message view locally for: ${t.queueId}`),Le(t)?await async function(t){i(`Marking broadcast ${t} as seen.`);const e=await Pe();if(!e)return;const n=await je(e,t);if(!n)return;const o=n.properties.gist.broadcast,{frequency:r}=o,l=De(e,t),d=Ne(e,t),c=a(l)||0;if(s(l,c+1),1===r.count)s(d,!1),i(`Marked broadcast ${t} as seen.`);else{const e=new Date;e.setSeconds(e.getSeconds()+r.delay),s(d,!1,e),i(`Marked broadcast ${t} as seen, broadcast was seen ${c+1} times, next show date is ${e}.`)}}(t.queueId??""):await async function(t){const e=await ze();if(!e)return;const n=a(e)??[];n.push(t),s(e,n)}(t.queueId??"")}async function Xn(t){Le(t)&&(i(`Logging broadcast dismissed locally for: ${t.queueId}`),await async function(t){i(`Marking broadcast ${t} as dismissed.`);const e=await Pe();if(!e)return;const n=await je(e,t);n&&(!0!==n.properties.gist.broadcast.frequency.ignoreDismiss?(s(Ne(e,t),!1),i(`Marked broadcast ${t} as dismissed and will not show again.`)):i(`Broadcast ${t} is set to ignore dismiss.`))}(t.queueId??""),await Oe(t.queueId??""))}const Jn=(t,e)=>t().then((t=>new Promise(e=>setTimeout(e,t)))(e).then(()=>Jn(t,e)));let Qn=!1,Yn=null;async function Kn(){Qn?await Zn():At()?(i("Queue watcher started"),Qn=!0,Jn(()=>new Promise(()=>{!async function(){if(C.hasActiveSSEConnection())return!C.isSSEConnectionManagedBySDK()&&Yn&&(i("Not the main instance, closing our SSE connection."),ni()),void await Zn();Yn&&(i("SSE connection not active, closing it."),ni()),!C.useSSE()||Mt()?await ei():await async function(){ni();const t=function(){const t=zt();return null===t?(i("No user token available for SSE endpoint."),null):C.GIST_QUEUE_REALTIME_API_ENDPOINT[ii.config.env??"prod"]+`/api/v3/sse?userToken=${t}&siteId=${ii.config.siteId}&sessionId=${Tt()}`}();if(null===t)return i("SSE endpoint not available, falling back to polling."),void await ei();i(`Starting SSE queue listener on ${t}`),Yn=new EventSource(t),C.setActiveSSEConnection(),Yn.addEventListener("connected",async t=>{try{i("SSE connection received"),C.setUseSSEFlag(!0);const e=JSON.parse(t.data);e.heartbeat&&(C.setSSEHeartbeat(e.heartbeat),i(`SSE heartbeat set to ${e.heartbeat} seconds`)),C.setActiveSSEConnection()}catch(t){i(`Failed to parse SSE settings: ${t}`)}r(jt),await ei()}),Yn.addEventListener("messages",async t=>{try{const e=JSON.parse(t.data);i("SSE message received"),await Ae(e),await ke(e),await Zn()}catch(t){i(`Failed to parse SSE message: ${t}`),ni()}}),Yn.addEventListener("inbox_messages",async t=>{try{const e=JSON.parse(t.data);i("SSE inbox messages received"),await B(e)}catch(t){i(`Failed to parse SSE inbox messages: ${t}`)}}),Yn.addEventListener("error",async()=>{i("SSE error received"),ni()}),Yn.addEventListener("heartbeat",async()=>{i("SSE heartbeat received"),C.setActiveSSEConnection(),C.setUseSSEFlag(!0)})}()}()}),1e3)):i("User token not setup, queue not started.")}async function Zn(){const t=await Ee(),e=await Re(),n=t.concat(e);i(`Messages in local queue: ${n.length}`);const o=n.sort((t,e)=>t.priority-e.priority);for(const t of o)await ti(t)}async function ti(t){let e=Bt(t);if(e.hasRouteRule){if(null==ii.currentRoute&&"loading"===document.readyState)return i(`Deferring message ${t.queueId}, page not fully loaded`),!1;if(!te(e.routeRule))return i(`Route ${new URL(window.location.href).pathname} (currentRoute: ${ii.currentRoute}) does not match rule: ${e.routeRule}`),!1}if(e.hasPosition&&(t.position=e.position),e.hasTooltipPosition&&(t.tooltipPosition=e.tooltipPosition),e.persistent||Te(t)){const n=await async function(t){const e=await _e(t);return e?a(e):null}(t.queueId??"");n&&(i(`Restoring saved state for queueId ${t.queueId}`),n.displaySettings&&(ie(t,n.displaySettings),e=Bt(t)),t.savedStepName=n.stepName??null)}if(e.persistent||Te(t)||!await async function(t){const e=await We(t);return!!e&&null!==a(e)}(t.queueId??"")){let n=null;return e.isEmbedded?!ii.config.isPreviewSession||!t.properties?.gist?.livePreview||R(e.elementId)||Ut.includes(e.elementId)?n=Dn(t,e.elementId):(i(`Preview: element "${e.elementId}" not found, showing as overlay so placement can be changed`),n=await Pn(t)):n=await Pn(t),n&&async function(t){const e=await We(t);e&&s(e,!0,new Date(Date.now()+5e3))}(t.queueId??""),null!==n}return i(`Not showing message with queueId ${t.queueId} because its already loading.`),!1}async function ei(){if(At())if(ii.isDocumentVisible)if(null===a(jt)){const t=await async function(){if(Et)return;Et=!0;const t=At();let e;try{const t={"X-Gist-User-Anonymous":String(Mt()),"Content-Language":String(L())};e=await E().post(`/api/v4/users?sessionId=${Tt()}`,{},{headers:t})}catch(t){const n=k(t);n?e=n:i(`Error getting user queue: ${t}`)}finally{Et=!1}return t!==At()?(i("User token changed, clearing queue next pull check."),void r(jt)):(function(t){const e=t?.headers?.["x-gist-queue-polling-interval"];kt=e&&Number(e)>0?Number(e):Math.min(2*kt,600);const n=new Date((new Date).getTime()+1e3*kt);s(jt,kt,n)}(e),function(t){const e="true"===t?.headers?.["x-cio-use-sse"]?.toLowerCase();C.setUseSSEFlag(e)}(e),await async function(t){const e=t?.headers?.["x-cio-inbox-enabled"]?.toLowerCase();if(void 0===e)return;const n="true"===e;C.setInboxEnabledFlag(n),n&&(i("Inbox enabled, ensuring branding and templates are cached."),await $t(),bt())}(e),e)}();if(t){if(200===t.status||204===t.status){i("200 response, updating local store.");const e=t.data,n=e?.inAppMessages??[],o=e?.inboxMessages??[];Ae(n),ke(n),B(o)}else 304===t.status&&i("304 response, using local store.");await Zn()}else i("No response object returned while checking message queue.")}else i("Next queue pull scheduled for later.");else i("Document not visible, skipping queue check.");else i("User token reset, skipping queue check.")}function ni(t=!1){t&&C.removeActiveSSEConnection(),(t||C.isSSEConnectionManagedBySDK())&&C.setUseSSEFlag(!1),Yn&&(i("Stopping SSE queue listener..."),Yn.close(),Yn=null)}class ii{static async setup(t){this.initialized?i("Gist SDK already initialized, skipping setup."):(this.initialized=!0,this.events=new n,this.config={useAnonymousSession:t.useAnonymousSession??!1,siteId:t.siteId,dataCenter:t.dataCenter,env:t.env??"prod",logging:t.logging??!1,experiments:t.experiments??!1},this.currentMessages=[],ve.forEach(t=>t.cleanup()),ve.clear(),document.querySelectorAll('[id^="gist-tooltip-"]').forEach(t=>{t.parentNode?.removeChild(t)}),this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const t=new URLSearchParams(window.location.search),e=t.get(He);if(e){sessionStorage.setItem(o,String(!1)),ii.setUserToken(e),i(`Preview mode enabled with user token: ${e}`),function(){if(document.getElementById(Xe))return;z(Ge,Ue);try{tn="true"===sessionStorage.getItem(Ve)}catch{tn=!1}const t=q("div",{id:Xe});document.body.appendChild(t),Cn()}();const n=t.get(Fe);if(n)try{const t=JSON.parse(atob(n)),e=t.stepName||null,i=t.displayType||null;(e||i)&&function(t,e){dn=t,cn=e}(e,i)}catch{i("Preview bar: failed to parse cioPreviewSettings")}}return!l()}(),$i(),function(){const t=d();for(let e=t.length-1;e>=0;e--){const n=t.key(e);n?.startsWith("gist.")&&c(n)}}(),async function(){C.inboxEnabled()&&(D()&&A()||(i("Inbox enabled but missing cached branding/templates, fetching."),await $t()),bt())}(),i(`Setup complete on ${this.config.env} environment.`),this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||Rt(),await Kn(),"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",()=>{Zn()},{once:!0}),document.addEventListener("visibilitychange",async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await Zn())},!1))}static setupDebugOverlay(){$i()}static async setCurrentRoute(t){this.currentRoute=t,i(`Current route set to: ${t}`),await async function(){if(0!==ii.currentMessages.length)for(const t of[...ii.currentMessages])null==document.querySelector(`#gist-${t.instanceId}`)&&(i(`Removing active message ${t.instanceId} that no longer exists after route change`),await Mn(t))}(),await Zn(),this.events?.dispatch("routeChanged",t)}static async setUserToken(t,e){this.config.isPreviewSession||(function(t,e){void 0===e&&(e=new Date).setDate(e.getDate()+30),s(Pt,t,e),Mt()&&(r(jt),r(Dt)),i(`Set user token "${t}" with expiry date set to ${e}`)}(t,e),ni(!0),await Kn())}static setUserLocale(t){var e;s(j,e=t),i(`Set user locate to "${e}"`)}static setCustomAttribute(t,e){return function(t,e){return t&&"string"==typeof t?(Ce.set(t,e),$e(),i(`Set custom attribute "${t}" to "${e}"`),!0):(i(`Invalid key for custom attribute: ${t}`),!1)}(t,e)}static clearCustomAttributes(){Ce.clear(),r(Ie),i("Cleared all custom attributes")}static removeCustomAttribute(t){return function(t){if(!t||"string"!=typeof t)return i(`Invalid key for custom attribute: ${t}`),!1;const e=Ce.has(t);return Ce.delete(t),Ce.size>0?$e():r(Ie),i(`Removed custom attribute "${t}"`),e}(t)}static async clearUserToken(){this.config.isPreviewSession||(Wt(),this.config.useAnonymousSession&&Rt(),ni(!0),await Kn())}static async dismissMessage(t){const e=Vt(t);e&&(await An(e),await Xn(e),await Nn(e),await Zn())}static async embedMessage(t,e){const n=Dn(t,e);return n?.instanceId??null}static async showMessage(t){const e=await Pn(t);return e?.instanceId??null}static updateMessageDisplaySettings(t,e){const n=Vt(t);return!!n&&(n.displaySettings=e,he(n),!0)}static messageShown(t){i(`Message shown: ${t.messageId}`),this.events.dispatch("messageShown",t)}static messageDismissed(t){null!==t&&(i(`Message dismissed: ${t.messageId}`),this.events.dispatch("messageDismissed",t))}static messageError(t){i(`Message error: ${t.messageId}`),this.events.dispatch("messageError",t)}static messageAction(t,e,n){i(`Message action: ${t.currentRoute}, ${e} with name ${n} on ${t.instanceId}`),this.events.dispatch("messageAction",{message:t,action:e,name:n})}static async getInboxUnopenedCount(){return(await U()).filter(t=>!t.opened).length}static async getInboxMessages(){return await U()}static async updateInboxMessageOpenState(t,e){return await H(t,e)}static async removeInboxMessage(t){return await F(t)}static isInboxEnabled(){return C.inboxEnabled()}}const oi="\n #gist-debug-overlay {\n position: fixed; bottom: 16px; right: 16px;\n z-index: 99999999999;\n background: #08272B; color: white;\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 11px;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0,0,0,0.3);\n width: 300px;\n max-height: min(700px, calc(100vh - 32px));\n display: flex;\n flex-direction: column;\n pointer-events: auto;\n overflow: hidden;\n }\n .gist-debug-header {\n display: flex; align-items: center;\n padding: 8px 12px;\n border-bottom: 1px solid rgba(255,255,255,0.1);\n flex-shrink: 0;\n }\n .gist-debug-title {\n flex: 1;\n font-weight: 700;\n font-size: 12px;\n letter-spacing: 0.02em;\n }\n #gist-debug-overlay-close {\n background: none; border: none;\n color: white; cursor: pointer;\n padding: 0; font-size: 18px; line-height: 1;\n opacity: 0.6; flex-shrink: 0;\n font-family: system-ui, -apple-system, sans-serif;\n -webkit-appearance: none; appearance: none;\n }\n #gist-debug-overlay-close:hover { opacity: 1; }\n .gist-debug-section {\n padding: 0 12px 8px;\n border-bottom: 1px solid rgba(255,255,255,0.07);\n overflow-y: auto;\n max-height: 180px;\n }\n .gist-debug-section:last-child { border-bottom: none; }\n .gist-debug-label {\n position: sticky;\n top: 0;\n z-index: 1;\n background: #08272B;\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.08em;\n color: rgba(255,255,255,0.45);\n padding: 8px 0 5px;\n font-weight: 600;\n }\n .gist-debug-value {\n font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;\n font-size: 11px;\n color: rgba(255,255,255,0.9);\n overflow-wrap: break-word;\n }\n .gist-debug-msg {\n background: rgba(255,255,255,0.06);\n border-radius: 4px;\n padding: 5px 7px;\n margin-bottom: 8px;\n }\n .gist-debug-msg:last-child { margin-bottom: 0; }\n .gist-debug-msg-row {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-bottom: 2px;\n }\n .gist-debug-msg-row:last-child { margin-bottom: 0; }\n .gist-debug-msg-meta {\n display: flex;\n align-items: center;\n gap: 5px;\n margin-bottom: 4px;\n }\n .gist-debug-msg-state {\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n border-radius: 3px;\n padding: 1px 4px;\n flex-shrink: 0;\n }\n .gist-debug-msg-state--active {\n color: #4caf82;\n background: rgba(76,175,130,0.12);\n }\n .gist-debug-msg-state--queued {\n color: rgba(255,200,100,0.9);\n background: rgba(255,200,100,0.1);\n }\n .gist-debug-msg-dismiss {\n margin-left: auto;\n background: none;\n border: none;\n color: rgba(255,255,255,0.3);\n cursor: pointer;\n padding: 0;\n font-size: 13px;\n line-height: 1;\n font-family: system-ui, -apple-system, sans-serif;\n -webkit-appearance: none;\n appearance: none;\n }\n .gist-debug-msg-dismiss:hover { color: rgba(255,255,255,0.7); }\n .gist-debug-element-found {\n color: #4caf82;\n font-size: 9px;\n font-weight: 700;\n flex-shrink: 0;\n }\n .gist-debug-route-mismatch {\n color: #ff6b6b;\n font-size: 9px;\n font-weight: 700;\n flex-shrink: 0;\n }\n .gist-debug-msg-type {\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: rgba(255,255,255,0.45);\n background: rgba(255,255,255,0.08);\n border-radius: 3px;\n padding: 1px 4px;\n flex-shrink: 0;\n }\n .gist-debug-msg-key {\n color: rgba(255,255,255,0.45);\n font-size: 10px;\n line-height: 1.4;\n min-width: 64px;\n flex-shrink: 0;\n }\n .gist-debug-msg-val {\n font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;\n font-size: 10px;\n line-height: 1.4;\n color: rgba(255,255,255,0.9);\n overflow-wrap: break-word;\n }\n .gist-debug-val-error {\n color: #ff6b6b;\n font-weight: 600;\n }\n .gist-debug-expand-detail {\n background: rgba(255,107,107,0.08);\n border-left: 2px solid rgba(255,107,107,0.4);\n color: rgba(255,255,255,0.75);\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 10px;\n padding: 4px 6px;\n margin-top: 4px;\n margin-bottom: 6px;\n border-radius: 0 3px 3px 0;\n }\n .gist-debug-expand-list {\n margin: 0;\n padding: 0 0 0 14px;\n list-style: disc;\n }\n .gist-debug-expand-list li {\n margin-bottom: 3px;\n line-height: 1.4;\n }\n .gist-debug-expand-list li:last-child { margin-bottom: 0; }\n .gist-debug-msg-details {\n margin: 5px 0 0;\n padding: 0 0 0 14px;\n list-style: disc;\n color: rgba(255,255,255,0.5);\n font-size: 10px;\n line-height: 1.4;\n font-family: system-ui, -apple-system, sans-serif;\n }\n .gist-debug-msg-details li { margin-bottom: 2px; }\n .gist-debug-msg-details li:last-child { margin-bottom: 0; }\n",si="gist-debug-overlay-styles",ai=2e3,ri=5e3;let li=null,di=!1,ci=!1,pi=null;function ui(t){const e=t.properties?.gist;return ee(e?{...t,tooltipPosition:e.tooltipPosition??t.tooltipPosition,elementId:null!=e.elementId?String(e.elementId):t.elementId}:t)}function gi(t,e,n=!1){const i=q("div",{className:"gist-debug-msg-row"});return i.appendChild(q("span",{className:"gist-debug-msg-key",textContent:t})),i.appendChild(q("span",{className:n?"gist-debug-msg-val gist-debug-val-error":"gist-debug-msg-val",textContent:e})),i}function mi(t,e,n=!1){t.replaceChildren(...e.map(([t,e])=>gi(t,e,n)))}function fi(t,e){const n=q("div",{className:"gist-debug-msg"}),i=q("div",{className:"gist-debug-msg-meta"});if(i.appendChild(q("span",{className:"gist-debug-msg-type",textContent:ui(t)})),i.appendChild(q("span",{className:`gist-debug-msg-state gist-debug-msg-state--${e}`,textContent:e})),t.instanceId){const e=q("button",{className:"gist-debug-msg-dismiss",textContent:"×"});e.addEventListener("click",()=>{yi(),ii.dismissMessage(t.instanceId).then(()=>{yi(),vi()})}),i.appendChild(e)}n.appendChild(i);const o=[];for(const[e,i]of function(t){const e=t.properties?.gist,n=[];e?.routeRuleWeb&&n.push(["Route Rule",String(e.routeRuleWeb)]);const i=e?.elementId??t.elementId,o=ui(t);if(i&&"overlay"===o){const t=function(t){if(t)return Kt[t]}(String(i));t&&n.push(["Position",t.replace(/([A-Z])/g," $1").toLowerCase()])}else i&&"modal"!==o&&n.push(["Target",String(i)]);const s=e?.position??t.position;s&&"overlay"!==o&&n.push(["Position",String(s)]);const a=e?.tooltipPosition??t.tooltipPosition;return a&&n.push(["Tooltip",String(a)]),n}(t)){let t=null,s=null;if("Route Rule"===e){const e=!te(i);t=e?"gist-debug-route-mismatch":"gist-debug-element-found",s=e?"✕":"✓",e&&o.push("Route rule does not match current route. If it should, verify the route is set correctly and that analytics.page() is called on route changes.")}else if("Target"===e){const e=!!R(i);t=e?"gist-debug-element-found":"gist-debug-route-mismatch",s=e?"✓":"✕",e||o.push("Target element not found on the page. If it should, verify the selector is correct.")}const a=gi(e,i);t&&s&&a.appendChild(q("span",{className:t,textContent:s})),n.appendChild(a)}if(o.length>0){const t=q("ul",{className:"gist-debug-msg-details"});for(const e of o)t.appendChild(q("li",{textContent:e}));n.appendChild(t)}return n}function hi(t){const e=q("div",{className:"gist-debug-expand-detail"}),n=q("ul",{className:"gist-debug-expand-list"});return n.appendChild(q("li",{textContent:t})),e.appendChild(n),e}function bi(){li&&(li.root.remove(),document.getElementById(si)?.remove(),null!==pi&&(clearInterval(pi),pi=null),di&&(ii.events&&(ii.events.off("messageShown",wi),ii.events.off("messageDismissed",wi),ii.events.off("messageInboxUpdated",xi),ii.events.off("routeChanged",wi)),di=!1),li=null)}function yi(){if(!li)return;ii.config?mi(li.configRows,[["Site ID",ii.config.siteId],["Connection",C.useSSE()?"SSE":`Polling ${kt}s`]]):mi(li.configRows,[["Status","NOT INITIALIZED"]],!0),li.configDetail.style.display=ii.config?"none":"";const t=At();t?Mt()?li.userValue.textContent="(anonymous)":li.userValue.textContent=t.length>32?`${t.slice(0,32)}…`:t:li.userValue.textContent="(none)";const e=ii.currentRoute;li.routeValue.replaceChildren(q("span",{className:e?"gist-debug-msg-val":"gist-debug-msg-val gist-debug-val-error",textContent:e??"NONE"})),li.routeDetail.style.display=e?"none":""}async function vi(){if(!ci&&li){ci=!0;try{const t=ii.currentMessages??[],[e,n]=ii.config?await Promise.all([Re(),Ee()]):[[],[]],i=new Set(t.map(t=>t.queueId??t.messageId)),o=new Set,s=[...n,...e].filter(t=>{const e=t.queueId??t.messageId;return!i.has(e)&&!o.has(e)&&(o.add(e),!0)});if(!li)return;const a=t.length+s.length;li.messagesLabel.textContent=`Messages (${a})`,li.messagesList.replaceChildren(...t.map(t=>fi(t,"active")),...s.map(t=>fi(t,"queued")))}finally{ci=!1}}}function wi(){yi(),vi()}function xi(){vi()}async function Si(){di||(!di&&ii.events&&(ii.events.on("messageShown",wi),ii.events.on("messageDismissed",wi),ii.events.on("messageInboxUpdated",xi),ii.events.on("routeChanged",wi),di=!0),di&&Ii(ri)),yi(),await vi()}function Ii(t){null!==pi&&clearInterval(pi),pi=setInterval(()=>{Si()},t)}const Ci="cio_debug_session";function $i(){if("undefined"!=typeof window&&"true"===new URLSearchParams(window.location.search).get(Ci))try{li||null!==pi||(z(si,oi),li=function(){const t=q("div",{id:"gist-debug-overlay"}),e=q("div",{className:"gist-debug-header"});e.appendChild(q("span",{className:"gist-debug-title",textContent:"Customer.io In-App SDK Debugger"}));const n=q("button",{id:"gist-debug-overlay-close",ariaLabel:"Dismiss debug overlay",textContent:"×"});n.addEventListener("click",bi),e.appendChild(n),t.appendChild(e);const i=q("div",{className:"gist-debug-section"}),o=q("div",{className:"gist-debug-label"});o.appendChild(q("span",{textContent:"Config"})),i.appendChild(o);const s=q("div",{});i.appendChild(s);const a=hi("Verify your site ID and credentials are correct.");i.appendChild(a),t.appendChild(i);const r=q("div",{className:"gist-debug-section"}),l=q("div",{className:"gist-debug-label",textContent:"User"});r.appendChild(l);const d=q("div",{className:"gist-debug-value"});r.appendChild(d),t.appendChild(r);const c=q("div",{className:"gist-debug-section"}),p=q("div",{className:"gist-debug-label"});p.appendChild(q("span",{textContent:"Route"})),c.appendChild(p);const u=q("div",{className:"gist-debug-value"});c.appendChild(u);const g=hi("The current route is used to match against potential message page rules.");c.appendChild(g),t.appendChild(c);const m=q("div",{className:"gist-debug-section"}),f=q("div",{className:"gist-debug-label"});m.appendChild(f);const h=q("div",{});return m.appendChild(h),t.appendChild(m),{root:t,configRows:s,configDetail:a,userValue:d,routeValue:u,routeDetail:g,messagesLabel:f,messagesList:h}}(),W(li.root),Ii(ai),Si())}catch(t){i(`Failed to initialize debug overlay: ${t}`)}}return"undefined"!=typeof window&&$i(),e.default})());
@@ -30,4 +30,5 @@ export default class Gist {
30
30
  static getInboxMessages(): Promise<InboxMessage[]>;
31
31
  static updateInboxMessageOpenState(queueId: string, opened: boolean): Promise<void>;
32
32
  static removeInboxMessage(queueId: string): Promise<void>;
33
+ static isInboxEnabled(): boolean;
33
34
  }
@@ -0,0 +1,3 @@
1
+ import type { Branding } from '../types';
2
+ export declare function fetchBrandingIfNeeded(): Promise<void>;
3
+ export declare function getBranding(): Branding | null;
@@ -0,0 +1,5 @@
1
+ import type { InboxMessage } from './inbox-message-manager';
2
+ export declare function resetInboxComponentState(): void;
3
+ export declare function initializeInboxComponent(): void;
4
+ export declare function updateInbox(messages?: InboxMessage[]): Promise<void>;
5
+ export declare function destroyInbox(): void;
@@ -0,0 +1 @@
1
+ export declare const INBOX_CSS = "\n#gist-inbox-button {\n position: fixed;\n width: 56px;\n height: 56px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n z-index: 9998;\n border: none;\n transition: background-color 0.2s ease,\n box-shadow 0.2s ease,\n transform 0.15s ease;\n}\n#gist-inbox-button:hover {\n transform: scale(1.05);\n}\n#gist-inbox-button:active {\n transform: scale(0.93);\n}\n#gist-inbox-button svg {\n width: 24px;\n height: 24px;\n}\n#gist-inbox-badge {\n position: absolute;\n top: -4px;\n right: -4px;\n min-width: 20px;\n height: 20px;\n border-radius: 10px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0 6px;\n box-sizing: border-box;\n}\n#gist-inbox-panel {\n position: fixed;\n width: 400px;\n max-height: 600px;\n z-index: 9999;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n user-select: none;\n -webkit-user-select: none;\n transform: translateY(8px) scale(0.96);\n opacity: 0;\n pointer-events: none;\n transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),\n opacity 0.2s ease;\n}\n#gist-inbox-panel.gist-inbox-panel--open {\n transform: translateY(0) scale(1);\n opacity: 1;\n pointer-events: auto;\n}\n#gist-inbox-messages {\n overflow-y: auto;\n flex: 1;\n}\n.gist-inbox-message-row {\n transition: background-color 0.15s ease;\n}\n";
@@ -0,0 +1,5 @@
1
+ import type { NetworkResponse } from '../services/network';
2
+ export declare function ensureInboxDependencies(): Promise<void>;
3
+ export declare function initializeInboxFromCache(): Promise<void>;
4
+ export declare function processInboxConfig(response: NetworkResponse | undefined): Promise<void>;
5
+ export declare function isInboxEnabled(): boolean;
@@ -4,6 +4,8 @@ export interface InboxMessage {
4
4
  queueId?: string;
5
5
  opened?: boolean;
6
6
  expiry?: string;
7
+ priority?: number;
8
+ sentAt?: string;
7
9
  topics?: string[];
8
10
  properties?: MessageProperties;
9
11
  [key: string]: unknown;
@@ -0,0 +1,2 @@
1
+ export declare function fetchTemplatesIfNeeded(): Promise<void>;
2
+ export declare function getTemplates(): unknown;
@@ -0,0 +1,2 @@
1
+ import type { NetworkResponse } from './network';
2
+ export declare function fetchBranding(): Promise<NetworkResponse | undefined>;
@@ -14,5 +14,7 @@ export interface Settings {
14
14
  isSSEConnectionManagedBySDK: () => boolean;
15
15
  getSSEHeartbeat: () => number;
16
16
  setSSEHeartbeat: (heartbeat: number) => void;
17
+ inboxEnabled: () => boolean;
18
+ setInboxEnabledFlag: (enabled: boolean) => void;
17
19
  }
18
20
  export declare const settings: Settings;
@@ -0,0 +1,2 @@
1
+ import type { NetworkResponse } from './network';
2
+ export declare function fetchTemplates(): Promise<NetworkResponse | undefined>;
@@ -59,6 +59,46 @@ export interface GistProperties {
59
59
  persistent?: boolean;
60
60
  [key: string]: unknown;
61
61
  }
62
+ export interface TextStyle {
63
+ fontSize: number;
64
+ fontWeight: number;
65
+ fontFamily: string;
66
+ color: string;
67
+ lineHeight: number;
68
+ }
69
+ export interface BoxShadow {
70
+ color: string;
71
+ offsetX: number;
72
+ offsetY: number;
73
+ blur: number;
74
+ }
75
+ export interface InboxFloatingIcon {
76
+ background: string;
77
+ color: string;
78
+ svg: string;
79
+ }
80
+ export interface InboxUnreadIndicator {
81
+ showAlert: boolean;
82
+ text: TextStyle;
83
+ background: string;
84
+ }
85
+ export interface InboxPattern {
86
+ floatingIcon: InboxFloatingIcon;
87
+ background: string;
88
+ cornerRadius: number;
89
+ borderColor: string;
90
+ dividerColor: string;
91
+ shadow: BoxShadow;
92
+ position: string;
93
+ hoverBackground: string;
94
+ unreadIndicator: InboxUnreadIndicator;
95
+ }
96
+ export interface Branding {
97
+ theme: unknown;
98
+ patterns: {
99
+ inbox: InboxPattern;
100
+ };
101
+ }
62
102
  export interface ResolvedMessageProperties {
63
103
  isEmbedded: boolean;
64
104
  elementId: string;
@@ -77,3 +117,11 @@ export interface ResolvedMessageProperties {
77
117
  exitClick: boolean;
78
118
  hasCustomWidth: boolean;
79
119
  }
120
+ export type InboxActionBehavior = 'openUrl' | 'dismiss' | 'openDeeplink' | 'performAction';
121
+ export interface InboxActionConfig {
122
+ behavior: InboxActionBehavior;
123
+ action?: string;
124
+ name?: string;
125
+ dismiss?: boolean;
126
+ newTab?: boolean;
127
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customerio-gist-web",
3
- "version": "3.21.19",
3
+ "version": "3.22.0",
4
4
  "description": "Build beautiful in-app flows with no code and deliver them instantly to your app. http://customer.io",
5
5
  "private": false,
6
6
  "files": [
@@ -51,6 +51,7 @@
51
51
  "webpack-cli": "^5.1.4"
52
52
  },
53
53
  "dependencies": {
54
+ "@customerio/jist": "^0.1.6",
54
55
  "uuid": "^8.3.2"
55
56
  },
56
57
  "repository": {