customerio-gist-web 3.18.2 → 3.19.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 +1 -1
- package/dist/types/gist.d.ts +37 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/managers/custom-attribute-manager.d.ts +5 -0
- package/dist/types/managers/gist-properties-manager.d.ts +15 -0
- package/dist/types/managers/inbox-message-manager.d.ts +5 -0
- package/dist/types/managers/locale-manager.d.ts +2 -0
- package/dist/types/managers/message-broadcast-manager.d.ts +6 -0
- package/dist/types/managers/message-component-manager.d.ts +12 -0
- package/dist/types/managers/message-manager.d.ts +5 -0
- package/dist/types/managers/message-user-queue-manager.d.ts +9 -0
- package/dist/types/managers/page-component-manager.d.ts +2 -0
- package/dist/types/managers/queue-manager.d.ts +4 -0
- package/dist/types/managers/user-manager.d.ts +8 -0
- package/dist/types/services/log-service.d.ts +2 -0
- package/dist/types/services/message-service.d.ts +1 -0
- package/dist/types/services/network.d.ts +16 -0
- package/dist/types/services/queue-service.d.ts +4 -0
- package/dist/types/services/settings.d.ts +41 -0
- package/dist/types/templates/embed.d.ts +1 -0
- package/dist/types/templates/message.d.ts +1 -0
- package/dist/types/types.d.ts +68 -0
- package/dist/types/utilities/event-emitter.d.ts +5 -0
- package/dist/types/utilities/local-storage.d.ts +6 -0
- package/dist/types/utilities/log.d.ts +1 -0
- package/dist/types/utilities/message-utils.d.ts +10 -0
- package/dist/types/utilities/preview-mode.d.ts +1 -0
- package/package.json +18 -3
- package/src/gist.js +80 -24
- package/src/index.js +1 -2
- package/src/managers/message-component-manager.js +3 -0
- package/src/types.ts +74 -0
- package/.github/workflows/eslint.yml +0 -26
- package/.github/workflows/release.yml +0 -92
- package/.github/workflows/release_hotfix.yml +0 -41
- package/.github/workflows/release_version.yml +0 -57
- package/.mise/config.toml +0 -2
- package/CODEOWNERS +0 -2
- package/eslint.config.mjs +0 -10
- package/examples/inbox.js +0 -84
- package/examples/index.html +0 -319
- package/examples/settings.js +0 -76
- package/examples/styles.css +0 -424
- package/index.d.ts +0 -1
- package/index.js +0 -2
- package/test.sh +0 -4
- package/webpack.config.js +0 -11
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,(()=>(()=>{var e={595:(e,t,n)=>{"use strict";n.d(t,{A:()=>nt});class s{on(e,t){var n=this[e];n?n.push(t):this[e]=[t]}off(e,t){var n=this[e];if(n)if(t){var s=n.indexOf(t);-1!==s&&n.splice(s,1),0===n.length&&delete this[e]}else delete this[e]}dispatch(e,t){var n=this[e];n&&n.forEach((e=>e(t)))}}function i(e){nt.config&&nt.config.logging&&console.log(`Gist: ${e}`)}const a=365,o="gist.web.isPersistingSession";function r(e,t,n=null){var s=n;s||(s=new Date).setDate(s.getDate()+a);const i={value:t,expiry:s};l().setItem(e,JSON.stringify(i))}function c(e){return g(e)}function u(e){l().removeItem(e)}function d(){const e=sessionStorage.getItem(o);return null===e?(sessionStorage.setItem(o,"true"),!0):"true"===e}function l(){return d()?localStorage:sessionStorage}function g(e){if(!e)return null;try{const t=l().getItem(e);if(!t)return null;const n=JSON.parse(t);if(!n.expiry)return n.value;const s=new Date,i=new Date(n.expiry),a=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(s.getTime()+366e4);return a&&i.getTime()>o.getTime()||s.getTime()>i.getTime()?(u(e),null):n.value}catch(t){i(`Error checking key ${e} for expiry: ${t}`)}return null}var m,p=new Uint8Array(16);function f(){if(!m&&!(m="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 m(p)}const h=/^(?:[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 y=[],w=0;w<256;++w)y.push((w+256).toString(16).substr(1));const v=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(y[e[t+0]]+y[e[t+1]]+y[e[t+2]]+y[e[t+3]]+"-"+y[e[t+4]]+y[e[t+5]]+"-"+y[e[t+6]]+y[e[t+7]]+"-"+y[e[t+8]]+y[e[t+9]]+"-"+y[e[t+10]]+y[e[t+11]]+y[e[t+12]]+y[e[t+13]]+y[e[t+14]]+y[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&h.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n},b=function(e,t,n){var s=(e=e||{}).random||(e.rng||f)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=s[i];return t}return v(s)},S="gist.web.userQueueUseSSE",I="gist.web.activeSSEConnection";let x,$=30;const E={RENDERER_HOST:"https://code.gist.build",ENGINE_API_ENDPOINT:{prod:"https://engine.api.gist.build",dev:"https://engine.api.dev.gist.build",local:"http://engine.api.local.gist.build:82"},GIST_QUEUE_API_ENDPOINT:{prod:"https://consumer.cloud.gist.build",dev:"https://consumer.cloud.dev.gist.build",local:"http://api.local.gist.build:86"},GIST_QUEUE_REALTIME_API_ENDPOINT:{prod:"https://realtime.cloud.gist.build",dev:"https://realtime.cloud.dev.gist.build",local:"http://api.local.gist.build:3000"},GIST_VIEW_ENDPOINT:{prod:"https://renderer.gist.build/3.0",dev:"https://renderer.gist.build/3.0",local:"http://app.local.gist.build:8080/web"},getSdkId:function(){return x||(x=b()),x},useSSE:function(){return c(S)??!1},setUseSSEFlag:function(e){r(S,e,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${e}"`)},removeActiveSSEConnection:function(){u(I)},setActiveSSEConnection:function(){r(I,E.getSdkId(),new Date((new Date).getTime()+E.getSSEHeartbeat()))},hasActiveSSEConnection:function(){return c(I)??!1},isSSEConnectionManagedBySDK:function(){return c(I)===E.getSdkId()},getSSEHeartbeat:function(){return 1e3*($+5)},setSSEHeartbeat:function(e){e&&e>0&&($=e)}};function C(){const e=E.GIST_QUEUE_API_ENDPOINT[nt.config.env],t={"X-CIO-Site-Id":nt.config.siteId,"X-CIO-Client-Platform":"web"},n=_();async function s(n,s={}){const i=e+n,a=new AbortController,o=setTimeout((()=>a.abort()),5e3);try{const e=await fetch(i,{method:s.method||"GET",headers:{...t,...s.headers||{}},body:s.method&&"GET"!==s.method.toUpperCase()?s.body:void 0,signal:a.signal});clearTimeout(o);const n=e.headers.get("content-type")?.includes("application/json"),r=n?await e.json():await e.text(),c=Object.fromEntries(e.headers.entries());if(e.status<200||e.status>=400)throw{response:{status:e.status,data:r,headers:c}};return{status:e.status,headers:c,data:r}}catch(e){throw clearTimeout(o),e.response||(e.response={status:0,data:e.message||"Unknown error"}),e}}return null!=n&&(t["X-Gist-Encoded-User-Token"]=n),s.post=(e,t={},n={})=>s(e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...n.headers||{}}}),s}const D="gist.web.userLocale";var T=600,k=!1;const M="gist.web.userQueueNextPullCheck",q="gist.web.sessionId";function P(){var e=c(q);return e||(e=b()),r(q,e,new Date((new Date).getTime()+18e5)),e}const R="gist.web.userToken",L="gist.web.usingGuestUserToken",A="gist.web.guestUserToken";function N(){return null!==c(L)}function W(){return c(R)}function U(){if(null===W()){var e=c(A);null==e&&(e=b(),r(A,e),i(`Set guest user token "${e}" with expiry date set to 1 year from today`)),r(R,e),r(L,!0),i(`Using anonymous session with token: "${e}"`)}}async function O(){var e=W();return null===e?null:await async function(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map((e=>e.toString(16).padStart(2,"0"))).join("")}(e)}function _(){var e=W();return null===e?null:btoa(e)}async function H(e){try{return await C().post(`/api/v1/logs/queue/${e}`)}catch(e){return e.response}}function j(e){const t={isEmbedded:!1,elementId:"",hasRouteRule:!1,routeRule:"",position:"",hasPosition:!1,shouldScale:!1,campaignId:null,messageWidth:414,overlayColor:"#00000033",persistent:!1,exitClick:!1,hasCustomWidth:!1},n=e?.properties?.gist;return n?{isEmbedded:!!n.elementId,elementId:n.elementId||"",hasRouteRule:!!n.routeRuleWeb,routeRule:n.routeRuleWeb||"",position:n.position||"",hasPosition:!!n.position,shouldScale:!!n.scale,campaignId:n.campaignId??null,messageWidth:n.messageWidth>0?n.messageWidth:t.messageWidth,hasCustomWidth:n.messageWidth>0,overlayColor:n.overlayColor||t.overlayColor,persistent:!!n.persistent,exitClick:!!n.exitClick}:t}var G=["x-gist-top","x-gist-floating-top","x-gist-bottom","x-gist-floating-bottom","x-gist-floating-bottom-left","x-gist-floating-bottom-right","x-gist-floating-top-left","x-gist-floating-top-right"];function V(e){if(document.getElementById(e))return;const t=document.createElement("div");t.id=e,"x-gist-top"===e?document.body.insertBefore(t,document.body.firstChild):document.body.insertAdjacentElement("beforeend",t),i("Top & bottom elements injected into page")}const z=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function F(e){return nt.currentMessages.find((t=>t.instanceId===e))}function B(e){return!!e&&nt.currentMessages.some((t=>t.queueId===e))}function J(e){return e?nt.currentMessages.find((t=>t.elementId===e)):null}function Q(e){nt.currentMessages=nt.currentMessages.filter((t=>t.instanceId!==e))}function X(e,t){Q(e),nt.currentMessages.push(t)}function K(e){const t={topLeft:"x-gist-floating-top-left",topCenter:"x-gist-floating-top",topRight:"x-gist-floating-top-right",bottomLeft:"x-gist-floating-bottom-left",bottomCenter:"x-gist-floating-bottom",bottomRight:"x-gist-floating-bottom-right"};return e&&t[e]?t[e]:(i(`Invalid overlay position "${e}", defaulting to "topCenter"`),t.topCenter)}function Y(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";else if("overlay"===t.displayType){e.overlay=!1;const n=K(t.overlayPosition);e.elementId=n,e.properties.gist.elementId=n,e.position=null,e.properties.gist.position=null}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.elementId&&z.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 Z=e=>new Promise((t=>setTimeout(t,e)));function ee(e){var t=ue(e);t&&(t.classList.remove("gist-visible"),Array.from(t.classList).filter((e=>e.startsWith("gist-"))).forEach((e=>t.classList.remove(e))),t.style.removeProperty("height"),t.style.removeProperty("width"),t.innerHTML="")}function te(e){var t=ue(e);if(t)return t.style&&t.style.height&&"0px"!=t.style.height}function ne(e,t,n=null){const s=document.getElementById(e);s&&(s.onload=function(){!function(e,t,n=null){const s=document.getElementById(e);if(s&&s.contentWindow){const e={options:t,capabilities:se};n&&(t.stepId=n),s.contentWindow.postMessage(e,"*")}}(e,t,n)})}const se=["MultiStepDisplayTypes"];function ie(e){if(!e.displaySettings)return;const t=re(e.instanceId),n=document.getElementById(t);n&&n.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:e.displaySettings},"*")}async function ae(){var e=document.querySelector(".gist-message");e&&(e.classList.remove("gist-visible"),await Z(300)),oe()}function oe(){var e=document.querySelector("#gist-embed-message");e&&e.parentNode.removeChild(e)}function re(e){return`gist-${e}`}function ce(){var e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}function ue(e){try{return document.querySelector(`#${e}`)||null}catch{return null}}const de="gist.web.customAttributes";let le=new Map;function ge(){const e=Array.from(le.entries()),t=new Date;t.setDate(t.getDate()+30),r(de,e,t),i(`Saved ${le.size} custom attributes to storage with TTL of 30 days`)}!function(){const e=c(de);if(e)try{le=new Map(e)}catch{le=new Map}else le=new Map}();const me="gist.web.message.broadcasts",pe=60;async function fe(e){const t=await ve();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+pe),r(t,e.filter(ye),n)}async function he(e,t){return c(e).find((e=>e.queueId===t))}function ye(e){return e.properties&&e.properties.gist&&e.properties.gist.broadcast}function we(e){if(!ye(e))return!1;const{broadcast:t}=e.properties.gist;return 0===t.frequency.delay&&0===t.frequency.count}async function ve(){const e=await O();return e?`${me}.${e}`:null}function be(e,t){return`${e}.${t}.numberOfTimesShown`}function Se(e,t){return`${e}.${t}.shouldShow`}const Ie="gist.web.message.user",xe=60;async function $e(e){const t=await Ee();if(!t)return;const n=e.filter((e=>!(e.properties&&e.properties.gist&&e.properties.gist.broadcast))),s=new Date;s.setMinutes(s.getMinutes()+xe),r(t,n,s)}async function Ee(){const e=await O();return e?`${Ie}.${e}`:null}async function Ce(){const e=await O();return e?`${Ie}.${e}.seen`:null}async function De(e){const t=await O();return t?`${Ie}.${t}.message.${e}.loading`:null}async function Te(e){const t=await O();return t?`${Ie}.${t}.message.${e}.state`:null}async function ke(e){const t=await Te(e);t&&(u(t),i(`Cleared message state for queueId: ${e}`))}async function Me(e){if(nt.isDocumentVisible){if(B(e.queueId))return i(`Message with queueId ${e.queueId} is already showing.`),null;if(nt.overlayInstanceId)return i(`Message ${nt.overlayInstanceId} already showing.`),null;var t=j(e);return e.instanceId=b(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),nt.overlayInstanceId=e.instanceId,nt.currentMessages.push(e),Ne(e,null,e.savedStepName||null)}return i("Document hidden, not showing message now."),null}function qe(e,t){return nt.isDocumentVisible?B(e.queueId)?(i(`Message with queueId ${e.queueId} is already showing.`),null):J(t)?(i(`Message with elementId ${t} already has a message.`),null):(e.instanceId=b(),e.overlay=!1,e.firstLoad=!0,e.shouldScale=!1,e.elementId=t,e.shouldResizeHeight=!te(t),e.renderStartTime=(new Date).getTime(),nt.currentMessages.push(e),Ne(e,t,e.savedStepName||null)):(i("Document hidden, not showing message now."),null)}async function Pe(e){e?(nt.messageDismissed(e),e.overlay?await Ae(!0,e):Le(e)):i(`Message with instance id: ${e.instanceId} not found`)}async function Re(e){var t=j(e);e?t.persistent&&(i("Persistent message dismissed, logging view"),await _e(e),await We(e),await ke(e.queueId)):i(`Message with instance id: ${e.instanceId} not found`)}function Le(e){Q(e.instanceId),ee(e.elementId)}async function Ae(e,t){e?await ae():oe(),0==nt.currentMessages.length&&(window.removeEventListener("message",Oe),window.removeEventListener("touchstart",Ue)),Q(t.instanceId),nt.overlayInstanceId=null}function Ne(e,t=null,n=null){var s={endpoint:E.ENGINE_API_ENDPOINT[nt.config.env],siteId:nt.config.siteId,dataCenter:nt.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId,livePreview:!1,properties:e.properties,customAttributes:Object.fromEntries(new Map(le))},a=`${E.GIST_VIEW_ENDPOINT[nt.config.env]}/index.html`;return window.addEventListener("message",Oe),window.addEventListener("touchstart",Ue),t?(G.includes(t)&&V(t),function(e,t,n,s,a=null){var o=ue(e);if(o){var r=re(n.instanceId);o.classList.add(r);var c=j(n),u=c.messageWidth+"px";z.includes(e)&&!c.hasCustomWidth&&(u="100%"),G.includes(e)&&(o.style.width=u),te(e)||(o.style.height="0px"),o.innerHTML=function(e,t,n){var s=function(e,t,n){var s=800;return t.messageWidth>s&&(s=t.messageWidth),`\n <div id="gist-embed">\n <style>\n #x-gist-floating-top, #x-gist-floating-top-left, #x-gist-floating-top-right {\n position: fixed;\n top: 0px;\n z-index: 1000000;\n }\n #x-gist-floating-bottom, #x-gist-floating-bottom-left, #x-gist-floating-bottom-right {\n position: fixed;\n bottom: 0px;\n z-index: 1000000;\n }\n #x-gist-bottom, #x-gist-top, #x-gist-floating-top, #x-gist-floating-bottom {\n left: 50%;\n transform: translate(-50%, 0%);\n }\n #x-gist-floating-top-right, #x-gist-floating-bottom-right {\n right: 0px;\n }\n #gist-embed {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container .gist-frame {\n height: 100%;\n width: 100%;\n border: none;\n }\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${s}px) {\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${e}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(re(t.instanceId),n,e);return s}(t,n,c),ne(r,s,a)}else i(`Message could not be embedded, elementId ${e} not found.`)}(t,a,e,s,n)):function(e,t,n,s=null){document.body.insertAdjacentHTML("afterbegin",function(e,t){var n=j(t),s=function(e,t,n){var s=600;return t.messageWidth>s&&(s=t.messageWidth),`\n <div id="gist-embed-message">\n <style>\n #gist-overlay.gist-background {\n position: fixed;\n z-index: 9999999998;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: ${t.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.gist-background.gist-visible {\n visibility: visible;\n }\n .gist-message {\n width: ${t.messageWidth}px;\n position: absolute;\n border: none;\n opacity: 0;\n transition: opacity 0.3s ease-in-out, height 0.1s ease-in-out;\n z-index: 9999999999;\n left: 50%;\n transform: translateX(-50%);\n }\n .gist-message.gist-visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.gist-center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.gist-bottom {\n bottom: 0;\n }\n .gist-message.gist-top {\n top: 0;\n }\n @media (max-width: ${s}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="gist-background">\n <iframe id="${e}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(re(t.instanceId),n,e);return s}(e,t)),ne(re(t.instanceId),n,s)}(a,e,s,n),e}async function We(e){i(`Message shown, logging view for: ${e.messageId}`);var t={};null!=e.queueId?(await _e(e),t=await H(e.queueId)):t=await async function(e){try{return await C().post(`/api/v1/logs/message/${e}`)}catch(e){return e.response}}(e.messageId),200===t.status?i("Message view logged"):i(`Problem logging message: ${t.status}`)}function Ue(){}async function Oe(e){if(e.data.gist&&e.origin===E.RENDERER_HOST){var t=e.data.gist.instanceId,n=F(t);if(!n)return;var s=j(n);switch(e.data.gist.method){case"routeLoaded":var a=.001*((new Date).getTime()-n.renderStartTime);i(`Engine render for message: ${n.messageId} timer elapsed in ${a.toFixed(3)} seconds`),async function(e){const t=await De(e);if(!t)return!1;u(t)}(n.queueId),n.currentRoute=e.data.gist.parameters.route,e.data.gist.parameters.fullDisplaySettings&&!n.displaySettings?n.displaySettings=e.data.gist.parameters.fullDisplaySettings:n.displaySettings&&(i("SDK already has display settings state, sending it to iframe"),ie(n)),(n.firstLoad||n.isDisplayChange)&&(n.overlay?function(e){var t=j(e),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");var s=document.querySelector(".gist-message");e.position?s.classList.add("gist-"+e.position):s.classList.add("gist-center"),setTimeout(ce,100),t.exitClick&&setTimeout((()=>function(e){var t=document.querySelector("#gist-overlay");t&&t.addEventListener("click",(function(){nt.dismissMessage(e)}))}(e.instanceId)),1e3)}else oe()}(n):(h=ue(n.elementId))&&h.classList.add("gist-visible"),n.firstLoad&&!n.isDisplayChange&&(nt.messageShown(n),s.persistent?i("Persistent message shown, skipping logging view"):await We(n)),n.firstLoad=!1,n.isDisplayChange=!1),X(t,n);break;case"tap":var o=e.data.gist.parameters.action,d=e.data.gist.parameters.name;if(nt.messageAction(n,o,d),e.data.gist.parameters.system&&!s.persistent){await Pe(n);break}try{var l=new URL(o);if(l&&"gist:"===l.protocol)switch(l.href.replace("gist://","").split("?")[0]){case"close":await Pe(n),await Re(n),await He(n),await Ye();break;case"showMessage":var g=l.searchParams.get("messageId"),m=l.searchParams.get("properties");g&&(m&&(m=JSON.parse(atob(m))),await nt.showMessage({messageId:g,properties:m}));break;case"loadPage":(l=l.href.substring(l.href.indexOf("?url=")+5))&&(l.startsWith("mailto:")||l.startsWith("https://")||l.startsWith("http://")||l.startsWith("/")?window.location.href=l:window.location.href=window.location+l)}}catch{}break;case"changeMessageStep":var p=e.data.gist.parameters.displaySettings,f=e.data.gist.parameters.messageStepName;(s.persistent||we(n))&&await async function(e,t,n){const s=await Te(e);if(!s)return;const a=c(s)||{},o={stepName:void 0!==t?t:a.stepName,displaySettings:void 0!==n?n:a.displaySettings},u=new Date;u.setDate(u.getDate()+30),r(s,o,u),i(`Saved message state for queueId: ${e}`)}(n.queueId,f,p),p&&function(e,t){const n=(s=e).overlay?"modal":s.elementId&&G.includes(s.elementId)?"overlay":s.elementId?"inline":"modal";var s;const i=t.displayType;if(void 0===i)return!1;if(n!==i)return!0;const a=j(e);switch(i){case"modal":if((e.position||"center")!==(t.modalPosition||"center"))return!0;if(void 0!==t.dismissOutsideClick&&a.exitClick!==t.dismissOutsideClick)return!0;if(void 0!==t.overlayColor&&a.overlayColor!==t.overlayColor)return!0;break;case"overlay":{const n=K(t.overlayPosition);if(e.elementId!==n)return!0;break}case"inline":if(e.elementId!==t.elementSelector)return!0}return void 0!==t.maxWidth&&a.messageWidth!==t.maxWidth}(n,p)&&(i("Display settings changed, reloading message"),await async function(e){e.overlay?await ae():ee(e.elementId)}(n),Y(n,p),await async function(e,t){e.isDisplayChange=!0,e.renderStartTime=(new Date).getTime();var n=e.elementId||null;if(n){const t=J(n);t&&t.instanceId!==e.instanceId&&(i(`Dismissing existing message at ${n} to make room for multi-step message`),await Pe(t))}if(e.overlay){nt.overlayInstanceId=e.instanceId;var s=j(e);e.shouldScale=s.shouldScale,e.shouldResizeHeight=!0}else nt.overlayInstanceId=null,e.shouldScale=!1,e.shouldResizeHeight=!te(n);n&&G.includes(n)&&V(n),Ne(e,n,t)}(n,f));break;case"routeChanged":n.currentRoute=e.data.gist.parameters.route,n.renderStartTime=(new Date).getTime(),X(t,n),i(`Route changed to: ${n.currentRoute}`);break;case"sizeChanged":i(`Size Changed Width: ${e.data.gist.parameters.width} - Height: ${e.data.gist.parameters.height}`),n.elementId&&!n.shouldResizeHeight||function(e,t){var n=ue(e.elementId?e.elementId:re(e.instanceId));if(n){var s=n.style;if(t.height>0)if(t.height>window.innerHeight){var i=1-(t.height/window.innerHeight-1);e.shouldScale&&i>=.4?(s.height=`${t.height}px`,s.transform=`translateX(-50%) translateY(-50%) scale(${i})`):s.height=`${window.innerHeight}px`}else s.height=`${t.height}px`}}(n,e.data.gist.parameters);break;case"titleChanged":i(`Overlay title changed to: ${e.data.gist.parameters.title}`),function(e,t){var n=ue(re(e));n&&(n.title=t)}(t,e.data.gist.parameters.title);break;case"eventDispatched":nt.events.dispatch("eventDispatched",{name:e.data.gist.parameters.name,payload:e.data.gist.parameters.payload});break;case"error":case"routeError":nt.messageError(n),nt.overlayInstanceId?Ae(!1,n):Le(n)}}var h}async function _e(e){i(`Logging user message view locally for: ${e.queueId}`),ye(e)?await async function(e){i(`Marking broadcast ${e} as seen.`);const t=await ve();if(!t)return;const n=await he(t,e);if(!n)return;const{broadcast:s}=n.properties.gist,a=be(t,e),o=Se(t,e);let u=c(a)||0;if(r(a,u+1),1===s.frequency.count)r(o,!1),i(`Marked broadcast ${e} as seen.`);else{let t=new Date;t.setSeconds(t.getSeconds()+s.frequency.delay),r(o,!1,t),i(`Marked broadcast ${e} as seen, broadcast was seen ${u+1} times, next show date is ${t}.`)}}(e.queueId):await async function(e){const t=await Ce();if(!t)return;const n=c(t)??[];n.push(e),r(t,n)}(e.queueId)}async function He(e){ye(e)&&(i(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){i(`Marking broadcast ${e} as dismissed.`);const t=await ve();if(!t)return;const n=await he(t,e);if(!n)return;const{broadcast:s}=n.properties.gist;!0!==s.frequency.ignoreDismiss?(r(Se(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 ke(e.queueId))}const je="messageInboxUpdated",Ge="gist.web.inbox.messages",Ve=60;async function ze(e){const t=await Be();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+Ve),r(t,e,n),nt.events.dispatch(je,e)}async function Fe(){const e=await Be();if(!e)return[];const t=c(e)??[],n=new Date;return t.filter((e=>!e.expiry||new Date(e.expiry)>n))}async function Be(){const e=await O();return e?`${Ge}.${e}`:null}var Je=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>Je(e,t)))),Qe=!1;let Xe=null;async function Ke(){Qe?await Ye():W()?(i("Queue watcher started"),Qe=!0,Je((()=>new Promise((()=>async function(){if(E.hasActiveSSEConnection())return!E.isSSEConnectionManagedBySDK()&&Xe&&(i("Not the main instance, closing our SSE connection."),tt()),void await Ye();Xe&&(i("SSE connection not active, closing it."),tt()),!E.useSSE()||N()?await et():await async function(){tt();const e=null===(t=_())?(i("No user token available for SSE endpoint."),null):E.GIST_QUEUE_REALTIME_API_ENDPOINT[nt.config.env]+`/api/v3/sse?userToken=${t}&siteId=${nt.config.siteId}&sessionId=${P()}`;var t;if(null===e)return i("SSE endpoint not available, falling back to polling."),void await et();i(`Starting SSE queue listener on ${e}`),Xe=new EventSource(e),E.setActiveSSEConnection(),Xe.addEventListener("connected",(async e=>{try{i("SSE connection received:"),E.setUseSSEFlag(!0);var t=JSON.parse(e.data);t.heartbeat&&(E.setSSEHeartbeat(t.heartbeat),i(`SSE heartbeat set to ${t.heartbeat} seconds`)),E.setActiveSSEConnection()}catch(e){i(`Failed to parse SSE settings: ${e}`)}u(M),await et()})),Xe.addEventListener("messages",(async e=>{try{var t=JSON.parse(e.data);i("SSE message received:"),await $e(t),await fe(t),await Ye()}catch(e){i("Failed to parse SSE message"),tt()}})),Xe.addEventListener("inbox_messages",(async e=>{try{var t=JSON.parse(e.data);i("SSE inbox messages received:"),await ze(t)}catch(e){i("Failed to parse SSE inbox messages")}})),Xe.addEventListener("error",(async e=>{i("SSE error received:"),tt()})),Xe.addEventListener("heartbeat",(async e=>{i("SSE heartbeat received:"),E.setActiveSSEConnection(),E.setUseSSEFlag(!0)}))}()}()))),1e3)):i("User token not setup, queue not started.")}async function Ye(){var e=await async function(){const e=await ve();return e?(c(e)??[]).filter((t=>{const{broadcast:n}=t.properties.gist,s=c(Se(e,t.queueId))??!0,i=c(be(e,t.queueId))||0,a=0===n.frequency.count;return s&&(a||i<n.frequency.count)})):[]}(),t=await async function(){const e=await Ee();if(!e)return[];const t=c(e)??[],n=await async function(){const e=await Ce();return e?c(e)??[]:[]}();return t.filter((e=>!n.includes(e.queueId)))}(),n=e.concat(t);i(`Messages in local queue: ${n.length}`);var s=n.sort(((e,t)=>e.priority-t.priority));for(const e of s)await Ze(e)}async function Ze(e){var t=j(e);if(t.hasRouteRule){var n=nt.currentRoute;null==n&&(n=new URL(window.location.href).pathname);var s=t.routeRule;if(i(`Verifying route ${n} against rule: ${s}`),!new RegExp(s).test(n))return i(`Route ${n} does not match rule.`),!1}if(t.hasPosition&&(e.position=t.position),t.persistent||we(e)){const n=await async function(e){const t=await Te(e);return t?c(t):null}(e.queueId);n&&(i(`Restoring saved state for queueId ${e.queueId}`),n.displaySettings&&(Y(e,n.displaySettings),t=j(e)),e.savedStepName=n.stepName)}if(t.persistent||we(e)||!await async function(e){const t=await De(e);return!!t&&null!==c(t)}(e.queueId)){var a;return(a=t.isEmbedded?qe(e,t.elementId):await Me(e))&&async function(e){const t=await De(e);if(!t)return!1;r(t,!0,new Date(Date.now()+5e3))}(e.queueId),a}return i(`Not showing message with queueId ${e.queueId} because its already loading.`),!1}async function et(){if(W())if(nt.isDocumentVisible)if(null===c(M)){var e=await async function(){const e=W();var t;try{if(!k){k=!0;var n={"X-Gist-User-Anonymous":N(),"Content-Language":null!==c(D)?c(D):navigator.language};t=await C().post(`/api/v4/users?sessionId=${P()}`,{},{headers:n})}}catch(e){e.response?t=e.response:i(`Error getting user queue: ${e}`)}finally{k=!1}return e!==W()?(i("User token changed, clearing queue next pull check."),void u(M)):(function(e){if(e&&e.headers){var t=e.headers["x-gist-queue-polling-interval"];t&&t>0&&(T=t)}var n=new Date((new Date).getTime()+1e3*T);r(M,T,n)}(t),function(e){const t="true"===e?.headers?.["x-cio-use-sse"]?.toLowerCase();E.setUseSSEFlag(t)}(t),t)}();if(e){if(200===e.status||204===e.status){i("200 response, updating local store.");var t=e.data?.inAppMessages||[],n=e.data?.inboxMessages||[];$e(t),fe(t),ze(n)}else 304===e.status&&i("304 response, using local store.");await Ye()}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 tt(e=!1){e&&E.removeActiveSSEConnection(),(e||E.isSSEConnectionManagedBySDK())&&E.setUseSSEFlag(!1),Xe&&(i("Stopping SSE queue listener..."),Xe.close(),Xe=null)}const nt=class{static async setup(e){this.events=new s,this.config={useAnonymousSession:void 0!==e.useAnonymousSession&&e.useAnonymousSession,siteId:e.siteId,dataCenter:e.dataCenter,env:void 0===e.env?"prod":e.env,logging:void 0!==e.logging&&e.logging,experiments:void 0!==e.experiments&&e.experiments},this.currentMessages=[],this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const e=new URLSearchParams(window.location.search).get("cioPreviewId");return e&&(sessionStorage.setItem(o,!1),nt.setUserToken(e),i(`Preview mode enabled with user token: ${e}`)),!d()}(),function(){const e=l();for(let t=e.length-1;t>=0;t--)g(e.key(t))}(),i(`Setup complete on ${this.config.env} environment.`),this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||U(),await Ke(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await Ye())}),!1)}static async setCurrentRoute(e){this.currentRoute=e,i(`Current route set to: ${e}`),await Ye()}static async setUserToken(e,t){this.config.isPreviewSession||(function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),r(R,e,t),N()&&(u(M),u(L)),i(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),tt(!0),await Ke())}static setUserLocale(e){var t;r(D,t=e),i(`Set user locate to "${t}"`)}static setCustomAttribute(e,t){return function(e,t){return e&&"string"==typeof e?(le.set(e,t),ge(),i(`Set custom attribute "${e}" to "${t}"`),!0):(i(`Invalid key for custom attribute: ${e}`),!1)}(e,t)}static clearCustomAttributes(){le.clear(),u(de),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=le.has(e);return le.delete(e),le.size>0?ge():u(de),i(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(u(R),i("Cleared user token"),this.config.useAnonymousSession&&U(),tt(!0),await Ke())}static async dismissMessage(e){var t=F(e);await Pe(t),await Re(t),await He(t),await Ye()}static async embedMessage(e,t){var n=qe(e,t);return n?n.instanceId:null}static async showMessage(e){var t=await Me(e);return t?t.instanceId:null}static updateMessageDisplaySettings(e,t){var n=F(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 Fe()).filter((e=>!e.opened)).length}static async getInboxMessages(){return await Fe()}static async updateInboxMessageOpenState(e,t){return await async function(e,t){const n=await Be();if(!n)return;const s=await async function(e,t){try{return await C()(`/api/v1/messages/${e}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return e.response}}(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 Fe();let o=null;const c=a.map((n=>n.queueId===e?(n.opened=t,o=n,{...n}):n)),u=new Date;if(u.setMinutes(u.getMinutes()+Ve),r(n,c,u),o){const e=t?"opened":"unopened";nt.events.dispatch("inboxMessageAction",{message:o,action:e})}nt.events.dispatch(je,await Fe())}(e,t)}static async removeInboxMessage(e){return await async function(e){const t=await Be();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 Fe()).filter((t=>t.queueId!==e)),a=new Date;a.setMinutes(a.getMinutes()+Ve),r(t,s,a),nt.events.dispatch(je,await Fe())}(e)}}},44:(e,t,n)=>{const s=n(595).A;e.exports=s}},t={};function n(s){var i=t[s];if(void 0!==i)return i.exports;var a=t[s]={exports:{}};return e[s](a,a.exports,n),a.exports}return n.d=(e,t)=>{for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(44)})()));
|
|
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,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>tt});class s{on(e,t){var s=this[e];s?s.push(t):this[e]=[t]}off(e,t){var s=this[e];if(s)if(t){var n=s.indexOf(t);-1!==n&&s.splice(n,1),0===s.length&&delete this[e]}else delete this[e]}dispatch(e,t){var s=this[e];s&&s.forEach((e=>e(t)))}}function n(e){tt.config&&tt.config.logging&&console.log(`Gist: ${e}`)}const i=365,a="gist.web.isPersistingSession";function o(e,t,s=null){var n=s;n||(n=new Date).setDate(n.getDate()+i);const a={value:t,expiry:n};d().setItem(e,JSON.stringify(a))}function r(e){return l(e)}function c(e){d().removeItem(e)}function u(){const e=sessionStorage.getItem(a);return null===e?(sessionStorage.setItem(a,"true"),!0):"true"===e}function d(){return u()?localStorage:sessionStorage}function l(e){if(!e)return null;try{const t=d().getItem(e);if(!t)return null;const s=JSON.parse(t);if(!s.expiry)return s.value;const n=new Date,i=new Date(s.expiry),a=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(n.getTime()+366e4);return a&&i.getTime()>o.getTime()||n.getTime()>i.getTime()?(c(e),null):s.value}catch(t){n(`Error checking key ${e} for expiry: ${t}`)}return null}var g,m=new Uint8Array(16);function p(){if(!g&&!(g="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 g(m)}const f=/^(?:[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 h=[],y=0;y<256;++y)h.push((y+256).toString(16).substr(1));const w=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=(h[e[t+0]]+h[e[t+1]]+h[e[t+2]]+h[e[t+3]]+"-"+h[e[t+4]]+h[e[t+5]]+"-"+h[e[t+6]]+h[e[t+7]]+"-"+h[e[t+8]]+h[e[t+9]]+"-"+h[e[t+10]]+h[e[t+11]]+h[e[t+12]]+h[e[t+13]]+h[e[t+14]]+h[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&f.test(e)}(s))throw TypeError("Stringified UUID is invalid");return s},v=function(e,t,s){var n=(e=e||{}).random||(e.rng||p)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){s=s||0;for(var i=0;i<16;++i)t[s+i]=n[i];return t}return w(n)},b="gist.web.userQueueUseSSE",S="gist.web.activeSSEConnection";let I,$=30;const x={RENDERER_HOST:"https://code.gist.build",ENGINE_API_ENDPOINT:{prod:"https://engine.api.gist.build",dev:"https://engine.api.dev.gist.build",local:"http://engine.api.local.gist.build:82"},GIST_QUEUE_API_ENDPOINT:{prod:"https://consumer.cloud.gist.build",dev:"https://consumer.cloud.dev.gist.build",local:"http://api.local.gist.build:86"},GIST_QUEUE_REALTIME_API_ENDPOINT:{prod:"https://realtime.cloud.gist.build",dev:"https://realtime.cloud.dev.gist.build",local:"http://api.local.gist.build:3000"},GIST_VIEW_ENDPOINT:{prod:"https://renderer.gist.build/3.0",dev:"https://renderer.gist.build/3.0",local:"http://app.local.gist.build:8080/web"},getSdkId:function(){return I||(I=v()),I},useSSE:function(){return r(b)??!1},setUseSSEFlag:function(e){o(b,e,new Date((new Date).getTime()+6e4)),n(`Set user uses SSE to "${e}"`)},removeActiveSSEConnection:function(){c(S)},setActiveSSEConnection:function(){o(S,x.getSdkId(),new Date((new Date).getTime()+x.getSSEHeartbeat()))},hasActiveSSEConnection:function(){return r(S)??!1},isSSEConnectionManagedBySDK:function(){return r(S)===x.getSdkId()},getSSEHeartbeat:function(){return 1e3*($+5)},setSSEHeartbeat:function(e){e&&e>0&&($=e)}};function E(){const e=x.GIST_QUEUE_API_ENDPOINT[tt.config.env],t={"X-CIO-Site-Id":tt.config.siteId,"X-CIO-Client-Platform":"web"},s=O();async function n(s,n={}){const i=e+s,a=new AbortController,o=setTimeout((()=>a.abort()),5e3);try{const e=await fetch(i,{method:n.method||"GET",headers:{...t,...n.headers||{}},body:n.method&&"GET"!==n.method.toUpperCase()?n.body:void 0,signal:a.signal});clearTimeout(o);const s=e.headers.get("content-type")?.includes("application/json"),r=s?await e.json():await e.text(),c=Object.fromEntries(e.headers.entries());if(e.status<200||e.status>=400)throw{response:{status:e.status,data:r,headers:c}};return{status:e.status,headers:c,data:r}}catch(e){throw clearTimeout(o),e.response||(e.response={status:0,data:e.message||"Unknown error"}),e}}return null!=s&&(t["X-Gist-Encoded-User-Token"]=s),n.post=(e,t={},s={})=>n(e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...s.headers||{}}}),n}const C="gist.web.userLocale";var D=600,k=!1;const T="gist.web.userQueueNextPullCheck",M="gist.web.sessionId";function q(){var e=r(M);return e||(e=v()),o(M,e,new Date((new Date).getTime()+18e5)),e}const P="gist.web.userToken",R="gist.web.usingGuestUserToken",L="gist.web.guestUserToken";function N(){return null!==r(R)}function W(){return r(P)}function A(){if(null===W()){var e=r(L);null==e&&(e=v(),o(L,e),n(`Set guest user token "${e}" with expiry date set to 1 year from today`)),o(P,e),o(R,!0),n(`Using anonymous session with token: "${e}"`)}}async function U(){var e=W();return null===e?null:await async function(e){const t=(new TextEncoder).encode(e),s=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(s)).map((e=>e.toString(16).padStart(2,"0"))).join("")}(e)}function O(){var e=W();return null===e?null:btoa(e)}async function _(e){try{return await E().post(`/api/v1/logs/queue/${e}`)}catch(e){return e.response}}function H(e){const t={isEmbedded:!1,elementId:"",hasRouteRule:!1,routeRule:"",position:"",hasPosition:!1,shouldScale:!1,campaignId:null,messageWidth:414,overlayColor:"#00000033",persistent:!1,exitClick:!1,hasCustomWidth:!1},s=e?.properties?.gist;return s?{isEmbedded:!!s.elementId,elementId:s.elementId||"",hasRouteRule:!!s.routeRuleWeb,routeRule:s.routeRuleWeb||"",position:s.position||"",hasPosition:!!s.position,shouldScale:!!s.scale,campaignId:s.campaignId??null,messageWidth:s.messageWidth>0?s.messageWidth:t.messageWidth,hasCustomWidth:s.messageWidth>0,overlayColor:s.overlayColor||t.overlayColor,persistent:!!s.persistent,exitClick:!!s.exitClick}:t}var j=["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 z(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),n("Top & bottom elements injected into page")}const G=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function V(e){return tt.currentMessages.find((t=>t.instanceId===e))}function F(e){return!!e&&tt.currentMessages.some((t=>t.queueId===e))}function B(e){return e?tt.currentMessages.find((t=>t.elementId===e)):null}function J(e){tt.currentMessages=tt.currentMessages.filter((t=>t.instanceId!==e))}function Q(e,t){J(e),tt.currentMessages.push(t)}function X(e){const t={topLeft:"x-gist-floating-top-left",topCenter:"x-gist-floating-top",topRight:"x-gist-floating-top-right",bottomLeft:"x-gist-floating-bottom-left",bottomCenter:"x-gist-floating-bottom",bottomRight:"x-gist-floating-bottom-right"};return e&&t[e]?t[e]:(n(`Invalid overlay position "${e}", defaulting to "topCenter"`),t.topCenter)}function K(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";else if("overlay"===t.displayType){e.overlay=!1;const s=X(t.overlayPosition);e.elementId=s,e.properties.gist.elementId=s,e.position=null,e.properties.gist.position=null}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.elementId&&G.includes(e.elementId)?delete e.properties.gist.messageWidth:void 0!==t.maxWidth&&t.maxWidth>0?e.properties.gist.messageWidth=t.maxWidth:delete e.properties.gist.messageWidth,void 0!==t.overlayColor?e.properties.gist.overlayColor=t.overlayColor:delete e.properties.gist.overlayColor,void 0!==t.dismissOutsideClick?e.properties.gist.exitClick=t.dismissOutsideClick:delete e.properties.gist.exitClick}const Y=e=>new Promise((t=>setTimeout(t,e)));function Z(e){var t=ce(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 ee(e){var t=ce(e);if(t)return t.style&&t.style.height&&"0px"!=t.style.height}function te(e,t,s=null){const n=document.getElementById(e);n&&(n.onload=function(){!function(e,t,s=null){const n=document.getElementById(e);if(n&&n.contentWindow){const e={options:t,capabilities:se};s&&(t.stepId=s),n.contentWindow.postMessage(e,"*")}}(e,t,s)})}const se=["MultiStepDisplayTypes"];function ne(e){if(!e.displaySettings)return;const t=oe(e.instanceId),s=document.getElementById(t);s&&s.contentWindow&&s.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:e.displaySettings},"*")}async function ie(){var e=document.querySelector(".gist-message");e&&(e.classList.remove("gist-visible"),await Y(300)),ae()}function ae(){var e=document.querySelector("#gist-embed-message");e&&e.parentNode.removeChild(e)}function oe(e){return`gist-${e}`}function re(){var e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}function ce(e){try{return document.querySelector(`#${e}`)||null}catch{return null}}const ue="gist.web.customAttributes";let de=new Map;function le(){const e=Array.from(de.entries()),t=new Date;t.setDate(t.getDate()+30),o(ue,e,t),n(`Saved ${de.size} custom attributes to storage with TTL of 30 days`)}!function(){const e=r(ue);if(e)try{de=new Map(e)}catch{de=new Map}else de=new Map}();const ge="gist.web.message.broadcasts",me=60;async function pe(e){const t=await we();if(!t)return;const s=new Date;s.setMinutes(s.getMinutes()+me),o(t,e.filter(he),s)}async function fe(e,t){return r(e).find((e=>e.queueId===t))}function he(e){return e.properties&&e.properties.gist&&e.properties.gist.broadcast}function ye(e){if(!he(e))return!1;const{broadcast:t}=e.properties.gist;return 0===t.frequency.delay&&0===t.frequency.count}async function we(){const e=await U();return e?`${ge}.${e}`:null}function ve(e,t){return`${e}.${t}.numberOfTimesShown`}function be(e,t){return`${e}.${t}.shouldShow`}const Se="gist.web.message.user",Ie=60;async function $e(e){const t=await xe();if(!t)return;const s=e.filter((e=>!(e.properties&&e.properties.gist&&e.properties.gist.broadcast))),n=new Date;n.setMinutes(n.getMinutes()+Ie),o(t,s,n)}async function xe(){const e=await U();return e?`${Se}.${e}`:null}async function Ee(){const e=await U();return e?`${Se}.${e}.seen`:null}async function Ce(e){const t=await U();return t?`${Se}.${t}.message.${e}.loading`:null}async function De(e){const t=await U();return t?`${Se}.${t}.message.${e}.state`:null}async function ke(e){const t=await De(e);t&&(c(t),n(`Cleared message state for queueId: ${e}`))}async function Te(e){if(tt.isDocumentVisible){if(F(e.queueId))return n(`Message with queueId ${e.queueId} is already showing.`),null;if(tt.overlayInstanceId)return n(`Message ${tt.overlayInstanceId} already showing.`),null;var t=H(e);return e.instanceId=v(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),tt.overlayInstanceId=e.instanceId,tt.currentMessages.push(e),Ne(e,null,e.savedStepName||null)}return n("Document hidden, not showing message now."),null}function Me(e,t){return tt.isDocumentVisible?F(e.queueId)?(n(`Message with queueId ${e.queueId} is already showing.`),null):B(t)?(n(`Message with elementId ${t} already has a message.`),null):(e.instanceId=v(),e.overlay=!1,e.firstLoad=!0,e.shouldScale=!1,e.elementId=t,e.shouldResizeHeight=!ee(t),e.renderStartTime=(new Date).getTime(),tt.currentMessages.push(e),Ne(e,t,e.savedStepName||null)):(n("Document hidden, not showing message now."),null)}async function qe(e){e?(tt.messageDismissed(e),e.overlay?await Le(!0,e):Re(e)):n(`Message with instance id: ${e.instanceId} not found`)}async function Pe(e){var t=H(e);e?t.persistent&&(n("Persistent message dismissed, logging view"),await Oe(e),await We(e),await ke(e.queueId)):n(`Message with instance id: ${e.instanceId} not found`)}function Re(e){J(e.instanceId),Z(e.elementId)}async function Le(e,t){e?await ie():ae(),0==tt.currentMessages.length&&(window.removeEventListener("message",Ue),window.removeEventListener("touchstart",Ae)),J(t.instanceId),tt.overlayInstanceId=null}function Ne(e,t=null,s=null){var i={endpoint:x.ENGINE_API_ENDPOINT[tt.config.env],siteId:tt.config.siteId,dataCenter:tt.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId,livePreview:!1,properties:e.properties,customAttributes:Object.fromEntries(new Map(de))},a=`${x.GIST_VIEW_ENDPOINT[tt.config.env]}/index.html`;return window.addEventListener("message",Ue),window.addEventListener("touchstart",Ae),t?(j.includes(t)&&z(t),function(e,t,s,i,a=null){var o=ce(e);if(o){var r=oe(s.instanceId);o.classList.add(r);var c=H(s),u=c.messageWidth+"px";G.includes(e)&&!c.hasCustomWidth&&(u="100%"),j.includes(e)&&(o.style.width=u),ee(e)||(o.style.height="0px"),o.innerHTML=function(e,t,s){var n=function(e,t,s){var n=800;return t.messageWidth>n&&(n=t.messageWidth),`\n <div id="gist-embed">\n <style>\n #x-gist-floating-top, #x-gist-floating-top-left, #x-gist-floating-top-right {\n position: fixed;\n top: 0px;\n z-index: 1000000;\n }\n #x-gist-floating-bottom, #x-gist-floating-bottom-left, #x-gist-floating-bottom-right {\n position: fixed;\n bottom: 0px;\n z-index: 1000000;\n }\n #x-gist-bottom, #x-gist-top, #x-gist-floating-top, #x-gist-floating-bottom {\n left: 50%;\n transform: translate(-50%, 0%);\n }\n #x-gist-floating-top-right, #x-gist-floating-bottom-right {\n right: 0px;\n }\n #gist-embed {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container .gist-frame {\n height: 100%;\n width: 100%;\n border: none;\n }\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${n}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="${s}"></iframe>\n </div>\n </div>`}(oe(t.instanceId),s,e);return n}(t,s,c),te(r,i,a)}else n(`Message could not be embedded, elementId ${e} not found.`)}(t,a,e,i,s)):function(e,t,s,n=null){document.querySelectorAll("#gist-embed-message").forEach((function(e){e.parentNode.removeChild(e)})),document.body.insertAdjacentHTML("afterbegin",function(e,t){var s=H(t),n=function(e,t,s){var n=600;return t.messageWidth>n&&(n=t.messageWidth),`\n <div id="gist-embed-message">\n <style>\n #gist-overlay.gist-background {\n position: fixed;\n z-index: 9999999998;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: ${t.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.gist-background.gist-visible {\n visibility: visible;\n }\n .gist-message {\n width: ${t.messageWidth}px;\n position: absolute;\n border: none;\n opacity: 0;\n transition: opacity 0.3s ease-in-out, height 0.1s ease-in-out;\n z-index: 9999999999;\n left: 50%;\n transform: translateX(-50%);\n }\n .gist-message.gist-visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.gist-center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.gist-bottom {\n bottom: 0;\n }\n .gist-message.gist-top {\n top: 0;\n }\n @media (max-width: ${n}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="${s}"></iframe>\n </div>\n </div>`}(oe(t.instanceId),s,e);return n}(e,t)),te(oe(t.instanceId),s,n)}(a,e,i,s),e}async function We(e){n(`Message shown, logging view for: ${e.messageId}`);var t={};null!=e.queueId?(await Oe(e),t=await _(e.queueId)):t=await async function(e){try{return await E().post(`/api/v1/logs/message/${e}`)}catch(e){return e.response}}(e.messageId),200===t.status?n("Message view logged"):n(`Problem logging message: ${t.status}`)}function Ae(){}async function Ue(e){if(e.data.gist&&e.origin===x.RENDERER_HOST){var t=e.data.gist.instanceId,s=V(t);if(!s)return;var i=H(s);switch(e.data.gist.method){case"routeLoaded":var a=.001*((new Date).getTime()-s.renderStartTime);n(`Engine render for message: ${s.messageId} timer elapsed in ${a.toFixed(3)} seconds`),async function(e){const t=await Ce(e);if(!t)return!1;c(t)}(s.queueId),s.currentRoute=e.data.gist.parameters.route,e.data.gist.parameters.fullDisplaySettings&&!s.displaySettings?s.displaySettings=e.data.gist.parameters.fullDisplaySettings:s.displaySettings&&(n("SDK already has display settings state, sending it to iframe"),ne(s)),(s.firstLoad||s.isDisplayChange)&&(s.overlay?function(e){var t=H(e),s=document.querySelector("#gist-overlay");if(s){s.classList.add("gist-visible");var n=document.querySelector(".gist-message");e.position?n.classList.add("gist-"+e.position):n.classList.add("gist-center"),setTimeout(re,100),t.exitClick&&setTimeout((()=>function(e){var t=document.querySelector("#gist-overlay");t&&t.addEventListener("click",(function(){tt.dismissMessage(e)}))}(e.instanceId)),1e3)}else ae()}(s):(h=ce(s.elementId))&&h.classList.add("gist-visible"),s.firstLoad&&!s.isDisplayChange&&(tt.messageShown(s),i.persistent?n("Persistent message shown, skipping logging view"):await We(s)),s.firstLoad=!1,s.isDisplayChange=!1),Q(t,s);break;case"tap":var u=e.data.gist.parameters.action,d=e.data.gist.parameters.name;if(tt.messageAction(s,u,d),e.data.gist.parameters.system&&!i.persistent){await qe(s);break}try{var l=new URL(u);if(l&&"gist:"===l.protocol)switch(l.href.replace("gist://","").split("?")[0]){case"close":await qe(s),await Pe(s),await _e(s),await Ke();break;case"showMessage":var g=l.searchParams.get("messageId"),m=l.searchParams.get("properties");g&&(m&&(m=JSON.parse(atob(m))),await tt.showMessage({messageId:g,properties:m}));break;case"loadPage":(l=l.href.substring(l.href.indexOf("?url=")+5))&&(l.startsWith("mailto:")||l.startsWith("https://")||l.startsWith("http://")||l.startsWith("/")?window.location.href=l:window.location.href=window.location+l)}}catch{}break;case"changeMessageStep":var p=e.data.gist.parameters.displaySettings,f=e.data.gist.parameters.messageStepName;(i.persistent||ye(s))&&await async function(e,t,s){const i=await De(e);if(!i)return;const a=r(i)||{},c={stepName:void 0!==t?t:a.stepName,displaySettings:void 0!==s?s:a.displaySettings},u=new Date;u.setDate(u.getDate()+30),o(i,c,u),n(`Saved message state for queueId: ${e}`)}(s.queueId,f,p),p&&function(e,t){const s=(n=e).overlay?"modal":n.elementId&&j.includes(n.elementId)?"overlay":n.elementId?"inline":"modal";var n;const i=t.displayType;if(void 0===i)return!1;if(s!==i)return!0;const a=H(e);switch(i){case"modal":if((e.position||"center")!==(t.modalPosition||"center"))return!0;if(void 0!==t.dismissOutsideClick&&a.exitClick!==t.dismissOutsideClick)return!0;if(void 0!==t.overlayColor&&a.overlayColor!==t.overlayColor)return!0;break;case"overlay":{const s=X(t.overlayPosition);if(e.elementId!==s)return!0;break}case"inline":if(e.elementId!==t.elementSelector)return!0}return void 0!==t.maxWidth&&a.messageWidth!==t.maxWidth}(s,p)&&(n("Display settings changed, reloading message"),await async function(e){e.overlay?await ie():Z(e.elementId)}(s),K(s,p),await async function(e,t){e.isDisplayChange=!0,e.renderStartTime=(new Date).getTime();var s=e.elementId||null;if(s){const t=B(s);t&&t.instanceId!==e.instanceId&&(n(`Dismissing existing message at ${s} to make room for multi-step message`),await qe(t))}if(e.overlay){tt.overlayInstanceId=e.instanceId;var i=H(e);e.shouldScale=i.shouldScale,e.shouldResizeHeight=!0}else tt.overlayInstanceId=null,e.shouldScale=!1,e.shouldResizeHeight=!ee(s);s&&j.includes(s)&&z(s),Ne(e,s,t)}(s,f));break;case"routeChanged":s.currentRoute=e.data.gist.parameters.route,s.renderStartTime=(new Date).getTime(),Q(t,s),n(`Route changed to: ${s.currentRoute}`);break;case"sizeChanged":n(`Size Changed Width: ${e.data.gist.parameters.width} - Height: ${e.data.gist.parameters.height}`),s.elementId&&!s.shouldResizeHeight||function(e,t){var s=ce(e.elementId?e.elementId:oe(e.instanceId));if(s){var n=s.style;if(t.height>0)if(t.height>window.innerHeight){var i=1-(t.height/window.innerHeight-1);e.shouldScale&&i>=.4?(n.height=`${t.height}px`,n.transform=`translateX(-50%) translateY(-50%) scale(${i})`):n.height=`${window.innerHeight}px`}else n.height=`${t.height}px`}}(s,e.data.gist.parameters);break;case"titleChanged":n(`Overlay title changed to: ${e.data.gist.parameters.title}`),function(e,t){var s=ce(oe(e));s&&(s.title=t)}(t,e.data.gist.parameters.title);break;case"eventDispatched":tt.events.dispatch("eventDispatched",{name:e.data.gist.parameters.name,payload:e.data.gist.parameters.payload});break;case"error":case"routeError":tt.messageError(s),tt.overlayInstanceId?Le(!1,s):Re(s)}}var h}async function Oe(e){n(`Logging user message view locally for: ${e.queueId}`),he(e)?await async function(e){n(`Marking broadcast ${e} as seen.`);const t=await we();if(!t)return;const s=await fe(t,e);if(!s)return;const{broadcast:i}=s.properties.gist,a=ve(t,e),c=be(t,e);let u=r(a)||0;if(o(a,u+1),1===i.frequency.count)o(c,!1),n(`Marked broadcast ${e} as seen.`);else{let t=new Date;t.setSeconds(t.getSeconds()+i.frequency.delay),o(c,!1,t),n(`Marked broadcast ${e} as seen, broadcast was seen ${u+1} times, next show date is ${t}.`)}}(e.queueId):await async function(e){const t=await Ee();if(!t)return;const s=r(t)??[];s.push(e),o(t,s)}(e.queueId)}async function _e(e){he(e)&&(n(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){n(`Marking broadcast ${e} as dismissed.`);const t=await we();if(!t)return;const s=await fe(t,e);if(!s)return;const{broadcast:i}=s.properties.gist;!0!==i.frequency.ignoreDismiss?(o(be(t,e),!1),n(`Marked broadcast ${e} as dismissed and will not show again.`)):n(`Broadcast ${e} is set to ignore dismiss.`)}(e.queueId),await ke(e.queueId))}const He="messageInboxUpdated",je="gist.web.inbox.messages",ze=60;async function Ge(e){const t=await Fe();if(!t)return;const s=new Date;s.setMinutes(s.getMinutes()+ze),o(t,e,s),tt.events.dispatch(He,e)}async function Ve(){const e=await Fe();if(!e)return[];const t=r(e)??[],s=new Date;return t.filter((e=>!e.expiry||new Date(e.expiry)>s))}async function Fe(){const e=await U();return e?`${je}.${e}`:null}var Be=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>Be(e,t)))),Je=!1;let Qe=null;async function Xe(){Je?await Ke():W()?(n("Queue watcher started"),Je=!0,Be((()=>new Promise((()=>async function(){if(x.hasActiveSSEConnection())return!x.isSSEConnectionManagedBySDK()&&Qe&&(n("Not the main instance, closing our SSE connection."),et()),void await Ke();Qe&&(n("SSE connection not active, closing it."),et()),!x.useSSE()||N()?await Ze():await async function(){et();const e=null===(t=O())?(n("No user token available for SSE endpoint."),null):x.GIST_QUEUE_REALTIME_API_ENDPOINT[tt.config.env]+`/api/v3/sse?userToken=${t}&siteId=${tt.config.siteId}&sessionId=${q()}`;var t;if(null===e)return n("SSE endpoint not available, falling back to polling."),void await Ze();n(`Starting SSE queue listener on ${e}`),Qe=new EventSource(e),x.setActiveSSEConnection(),Qe.addEventListener("connected",(async e=>{try{n("SSE connection received:"),x.setUseSSEFlag(!0);var t=JSON.parse(e.data);t.heartbeat&&(x.setSSEHeartbeat(t.heartbeat),n(`SSE heartbeat set to ${t.heartbeat} seconds`)),x.setActiveSSEConnection()}catch(e){n(`Failed to parse SSE settings: ${e}`)}c(T),await Ze()})),Qe.addEventListener("messages",(async e=>{try{var t=JSON.parse(e.data);n("SSE message received:"),await $e(t),await pe(t),await Ke()}catch(e){n("Failed to parse SSE message"),et()}})),Qe.addEventListener("inbox_messages",(async e=>{try{var t=JSON.parse(e.data);n("SSE inbox messages received:"),await Ge(t)}catch(e){n("Failed to parse SSE inbox messages")}})),Qe.addEventListener("error",(async e=>{n("SSE error received:"),et()})),Qe.addEventListener("heartbeat",(async e=>{n("SSE heartbeat received:"),x.setActiveSSEConnection(),x.setUseSSEFlag(!0)}))}()}()))),1e3)):n("User token not setup, queue not started.")}async function Ke(){var e=await async function(){const e=await we();return e?(r(e)??[]).filter((t=>{const{broadcast:s}=t.properties.gist,n=r(be(e,t.queueId))??!0,i=r(ve(e,t.queueId))||0,a=0===s.frequency.count;return n&&(a||i<s.frequency.count)})):[]}(),t=await async function(){const e=await xe();if(!e)return[];const t=r(e)??[],s=await async function(){const e=await Ee();return e?r(e)??[]:[]}();return t.filter((e=>!s.includes(e.queueId)))}(),s=e.concat(t);n(`Messages in local queue: ${s.length}`);var i=s.sort(((e,t)=>e.priority-t.priority));for(const e of i)await Ye(e)}async function Ye(e){var t=H(e);if(t.hasRouteRule){var s=tt.currentRoute;null==s&&(s=new URL(window.location.href).pathname);var i=t.routeRule;if(n(`Verifying route ${s} against rule: ${i}`),!new RegExp(i).test(s))return n(`Route ${s} does not match rule.`),!1}if(t.hasPosition&&(e.position=t.position),t.persistent||ye(e)){const s=await async function(e){const t=await De(e);return t?r(t):null}(e.queueId);s&&(n(`Restoring saved state for queueId ${e.queueId}`),s.displaySettings&&(K(e,s.displaySettings),t=H(e)),e.savedStepName=s.stepName)}if(t.persistent||ye(e)||!await async function(e){const t=await Ce(e);return!!t&&null!==r(t)}(e.queueId)){var a;return(a=t.isEmbedded?Me(e,t.elementId):await Te(e))&&async function(e){const t=await Ce(e);if(!t)return!1;o(t,!0,new Date(Date.now()+5e3))}(e.queueId),a}return n(`Not showing message with queueId ${e.queueId} because its already loading.`),!1}async function Ze(){if(W())if(tt.isDocumentVisible)if(null===r(T)){var e=await async function(){const e=W();var t;try{if(!k){k=!0;var s={"X-Gist-User-Anonymous":N(),"Content-Language":null!==r(C)?r(C):navigator.language};t=await E().post(`/api/v4/users?sessionId=${q()}`,{},{headers:s})}}catch(e){e.response?t=e.response:n(`Error getting user queue: ${e}`)}finally{k=!1}return e!==W()?(n("User token changed, clearing queue next pull check."),void c(T)):(function(e){if(e&&e.headers){var t=e.headers["x-gist-queue-polling-interval"];t&&t>0&&(D=t)}var s=new Date((new Date).getTime()+1e3*D);o(T,D,s)}(t),function(e){const t="true"===e?.headers?.["x-cio-use-sse"]?.toLowerCase();x.setUseSSEFlag(t)}(t),t)}();if(e){if(200===e.status||204===e.status){n("200 response, updating local store.");var t=e.data?.inAppMessages||[],s=e.data?.inboxMessages||[];$e(t),pe(t),Ge(s)}else 304===e.status&&n("304 response, using local store.");await Ke()}else n("No response object returned while checking message queue.")}else n("Next queue pull scheduled for later.");else n("Document not visible, skipping queue check.");else n("User token reset, skipping queue check.")}function et(e=!1){e&&x.removeActiveSSEConnection(),(e||x.isSSEConnectionManagedBySDK())&&x.setUseSSEFlag(!1),Qe&&(n("Stopping SSE queue listener..."),Qe.close(),Qe=null)}const tt=class{static events;static config;static initialized;static currentMessages;static overlayInstanceId;static currentRoute;static isDocumentVisible;static async setup(e){this.initialized?n("Gist SDK already initialized, skipping setup."):(this.initialized=!0,this.events=new s,this.config={useAnonymousSession:void 0!==e.useAnonymousSession&&e.useAnonymousSession,siteId:e.siteId,dataCenter:e.dataCenter,env:void 0===e.env?"prod":e.env,logging:void 0!==e.logging&&e.logging,experiments:void 0!==e.experiments&&e.experiments},this.currentMessages=[],this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const e=new URLSearchParams(window.location.search).get("cioPreviewId");return e&&(sessionStorage.setItem(a,!1),tt.setUserToken(e),n(`Preview mode enabled with user token: ${e}`)),!u()}(),function(){const e=d();for(let t=e.length-1;t>=0;t--)l(e.key(t))}(),n(`Setup complete on ${this.config.env} environment.`),this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||A(),await Xe(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await Ke())}),!1))}static async setCurrentRoute(e){this.currentRoute=e,n(`Current route set to: ${e}`),await Ke()}static async setUserToken(e,t){this.config.isPreviewSession||(function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),o(P,e,t),N()&&(c(T),c(R)),n(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),et(!0),await Xe())}static setUserLocale(e){var t;o(C,t=e),n(`Set user locate to "${t}"`)}static setCustomAttribute(e,t){return function(e,t){return e&&"string"==typeof e?(de.set(e,t),le(),n(`Set custom attribute "${e}" to "${t}"`),!0):(n(`Invalid key for custom attribute: ${e}`),!1)}(e,t)}static clearCustomAttributes(){de.clear(),c(ue),n("Cleared all custom attributes")}static removeCustomAttribute(e){return function(e){if(!e||"string"!=typeof e)return n(`Invalid key for custom attribute: ${e}`),!1;const t=de.has(e);return de.delete(e),de.size>0?le():c(ue),n(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(c(P),n("Cleared user token"),this.config.useAnonymousSession&&A(),et(!0),await Xe())}static async dismissMessage(e){var t=V(e);await qe(t),await Pe(t),await _e(t),await Ke()}static async embedMessage(e,t){var s=Me(e,t);return s?s.instanceId:null}static async showMessage(e){var t=await Te(e);return t?t.instanceId:null}static updateMessageDisplaySettings(e,t){var s=V(e);return!!s&&(s.displaySettings=t,ne(s),!0)}static messageShown(e){n(`Message shown: ${e.messageId}`),this.events.dispatch("messageShown",e)}static messageDismissed(e){null!==e&&(n(`Message dismissed: ${e.messageId}`),this.events.dispatch("messageDismissed",e))}static messageError(e){n(`Message error: ${e.messageId}`),this.events.dispatch("messageError",e)}static messageAction(e,t,s){n(`Message action: ${e.currentRoute}, ${t} with name ${s} on ${e.instanceId}`),this.events.dispatch("messageAction",{message:e,action:t,name:s})}static async getInboxUnopenedCount(){return(await Ve()).filter((e=>!e.opened)).length}static async getInboxMessages(){return await Ve()}static async updateInboxMessageOpenState(e,t){return await async function(e,t){const s=await Fe();if(!s)return;const i=await async function(e,t){try{return await E()(`/api/v1/messages/${e}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return e.response}}(e,{opened:t});if(!i||i.status<200||i.status>=300){const e=`Failed to mark inbox message opened: ${i?.status||"unknown error"}`;throw n(e),new Error(e)}const a=await Ve();let r=null;const c=a.map((s=>s.queueId===e?(s.opened=t,r=s,{...s}):s)),u=new Date;if(u.setMinutes(u.getMinutes()+ze),o(s,c,u),r){const e=t?"opened":"unopened";tt.events.dispatch("inboxMessageAction",{message:r,action:e})}tt.events.dispatch(He,await Ve())}(e,t)}static async removeInboxMessage(e){return await async function(e){const t=await Fe();if(!t)return;const s=await _(e);if(!s||s.status<200||s.status>=300){const e=`Failed to remove inbox message: ${s?.status||"unknown error"}`;throw n(e),new Error(e)}const i=(await Ve()).filter((t=>t.queueId!==e)),a=new Date;a.setMinutes(a.getMinutes()+ze),o(t,i,a),tt.events.dispatch(He,await Ve())}(e)}};return t.default})()));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default class _default {
|
|
2
|
+
/** @type {import('./utilities/event-emitter').default} */
|
|
3
|
+
static events: import("./utilities/event-emitter").default;
|
|
4
|
+
/** @type {import('./types').GistConfig} */
|
|
5
|
+
static config: import("./types").GistConfig;
|
|
6
|
+
/** @type {boolean} */
|
|
7
|
+
static initialized: boolean;
|
|
8
|
+
/** @type {any[]} */
|
|
9
|
+
static currentMessages: any[];
|
|
10
|
+
/** @type {string | null} */
|
|
11
|
+
static overlayInstanceId: string | null;
|
|
12
|
+
/** @type {string | null} */
|
|
13
|
+
static currentRoute: string | null;
|
|
14
|
+
/** @type {boolean} */
|
|
15
|
+
static isDocumentVisible: boolean;
|
|
16
|
+
static setup(config: any): Promise<void>;
|
|
17
|
+
static setCurrentRoute(route: any): Promise<void>;
|
|
18
|
+
/** @param {string} userToken @param {Date} [expiryDate] */
|
|
19
|
+
static setUserToken(userToken: string, expiryDate?: Date): Promise<void>;
|
|
20
|
+
static setUserLocale(userLocale: any): void;
|
|
21
|
+
static setCustomAttribute(key: any, value: any): boolean;
|
|
22
|
+
static clearCustomAttributes(): void;
|
|
23
|
+
static removeCustomAttribute(key: any): boolean;
|
|
24
|
+
static clearUserToken(): Promise<void>;
|
|
25
|
+
static dismissMessage(instanceId: any): Promise<void>;
|
|
26
|
+
static embedMessage(message: any, elementId: any): Promise<any>;
|
|
27
|
+
static showMessage(message: any): Promise<any>;
|
|
28
|
+
static updateMessageDisplaySettings(instanceId: any, displaySettings: any): boolean;
|
|
29
|
+
static messageShown(message: any): void;
|
|
30
|
+
static messageDismissed(message: any): void;
|
|
31
|
+
static messageError(message: any): void;
|
|
32
|
+
static messageAction(message: any, action: any, name: any): void;
|
|
33
|
+
static getInboxUnopenedCount(): Promise<any>;
|
|
34
|
+
static getInboxMessages(): Promise<any>;
|
|
35
|
+
static updateInboxMessageOpenState(queueId: any, opened: any): Promise<void>;
|
|
36
|
+
static removeInboxMessage(queueId: any): Promise<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./gist";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function setCustomAttribute(key: any, value: any): boolean;
|
|
2
|
+
export function getCustomAttribute(key: any): any;
|
|
3
|
+
export function getAllCustomAttributes(): Map<any, any>;
|
|
4
|
+
export function clearCustomAttributes(): void;
|
|
5
|
+
export function removeCustomAttribute(key: any): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function resolveMessageProperties(message: any): {
|
|
2
|
+
isEmbedded: boolean;
|
|
3
|
+
elementId: any;
|
|
4
|
+
hasRouteRule: boolean;
|
|
5
|
+
routeRule: any;
|
|
6
|
+
position: any;
|
|
7
|
+
hasPosition: boolean;
|
|
8
|
+
shouldScale: boolean;
|
|
9
|
+
campaignId: any;
|
|
10
|
+
messageWidth: any;
|
|
11
|
+
hasCustomWidth: boolean;
|
|
12
|
+
overlayColor: any;
|
|
13
|
+
persistent: boolean;
|
|
14
|
+
exitClick: boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function updateInboxMessagesLocalStore(messages: any): Promise<void>;
|
|
2
|
+
export function getInboxMessagesFromLocalStore(): Promise<any>;
|
|
3
|
+
export function getInboxMessagesByTopic(topic: any): Promise<any>;
|
|
4
|
+
export function updateInboxMessageOpenState(queueId: any, opened: any): Promise<void>;
|
|
5
|
+
export function removeInboxMessage(queueId: any): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function updateBroadcastsLocalStore(messages: any): Promise<void>;
|
|
2
|
+
export function getEligibleBroadcasts(): Promise<any>;
|
|
3
|
+
export function markBroadcastAsSeen(broadcastId: any): Promise<void>;
|
|
4
|
+
export function markBroadcastAsDismissed(broadcastId: any): Promise<void>;
|
|
5
|
+
export function isMessageBroadcast(message: any): any;
|
|
6
|
+
export function isShowAlwaysBroadcast(message: any): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function loadEmbedComponent(elementId: any, url: any, message: any, options: any, stepName?: null): void;
|
|
2
|
+
export function showEmbedComponent(elementId: any): void;
|
|
3
|
+
export function hideEmbedComponent(elementId: any): void;
|
|
4
|
+
export function elementHasHeight(elementId: any): any;
|
|
5
|
+
export function resizeComponent(message: any, size: any): void;
|
|
6
|
+
export function loadOverlayComponent(url: any, message: any, options: any, stepName?: null): void;
|
|
7
|
+
export function sendOptionsToIframe(iframeId: any, options: any, stepName?: null): void;
|
|
8
|
+
export function sendDisplaySettingsToIframe(message: any): void;
|
|
9
|
+
export function showOverlayComponent(message: any): void;
|
|
10
|
+
export function hideOverlayComponent(): Promise<void>;
|
|
11
|
+
export function removeOverlayComponent(): void;
|
|
12
|
+
export function changeOverlayTitle(instanceId: any, title: any): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function showMessage(message: any): Promise<any>;
|
|
2
|
+
export function embedMessage(message: any, elementId: any): any;
|
|
3
|
+
export function hideMessage(message: any): Promise<void>;
|
|
4
|
+
export function removePersistentMessage(message: any): Promise<void>;
|
|
5
|
+
export function logBroadcastDismissedLocally(message: any): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function updateQueueLocalStore(messages: any): Promise<void>;
|
|
2
|
+
export function getMessagesFromLocalStore(): Promise<any>;
|
|
3
|
+
export function markUserQueueMessageAsSeen(queueId: any): Promise<void>;
|
|
4
|
+
export function isMessageLoading(queueId: any): Promise<boolean>;
|
|
5
|
+
export function setMessageLoading(queueId: any): Promise<false | undefined>;
|
|
6
|
+
export function setMessageLoaded(queueId: any): Promise<false | undefined>;
|
|
7
|
+
export function saveMessageState(queueId: any, stepName: any, displaySettings: any): Promise<void>;
|
|
8
|
+
export function getSavedMessageState(queueId: any): Promise<any>;
|
|
9
|
+
export function clearMessageState(queueId: any): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function isUsingGuestUserToken(): boolean;
|
|
2
|
+
export function getUserToken(): any;
|
|
3
|
+
export function setUserToken(userToken: any, expiryDate: any): void;
|
|
4
|
+
export function useGuestSession(): void;
|
|
5
|
+
export function isAnonymousUser(): boolean;
|
|
6
|
+
export function getHashedUserToken(): Promise<string | null>;
|
|
7
|
+
export function getEncodedUserToken(): string | null;
|
|
8
|
+
export function clearUserToken(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function updateMessage(queueId: any, updatedFields: any): Promise<any>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function UserNetworkInstance(): {
|
|
2
|
+
(path: any, options?: {}): Promise<{
|
|
3
|
+
status: number;
|
|
4
|
+
headers: {
|
|
5
|
+
[k: string]: string;
|
|
6
|
+
};
|
|
7
|
+
data: any;
|
|
8
|
+
}>;
|
|
9
|
+
post(path: any, data?: {}, config?: {}): Promise<{
|
|
10
|
+
status: number;
|
|
11
|
+
headers: {
|
|
12
|
+
[k: string]: string;
|
|
13
|
+
};
|
|
14
|
+
data: any;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export namespace settings {
|
|
2
|
+
let RENDERER_HOST: string;
|
|
3
|
+
namespace ENGINE_API_ENDPOINT {
|
|
4
|
+
let prod: string;
|
|
5
|
+
let dev: string;
|
|
6
|
+
let local: string;
|
|
7
|
+
}
|
|
8
|
+
namespace GIST_QUEUE_API_ENDPOINT {
|
|
9
|
+
let prod_1: string;
|
|
10
|
+
export { prod_1 as prod };
|
|
11
|
+
let dev_1: string;
|
|
12
|
+
export { dev_1 as dev };
|
|
13
|
+
let local_1: string;
|
|
14
|
+
export { local_1 as local };
|
|
15
|
+
}
|
|
16
|
+
namespace GIST_QUEUE_REALTIME_API_ENDPOINT {
|
|
17
|
+
let prod_2: string;
|
|
18
|
+
export { prod_2 as prod };
|
|
19
|
+
let dev_2: string;
|
|
20
|
+
export { dev_2 as dev };
|
|
21
|
+
let local_2: string;
|
|
22
|
+
export { local_2 as local };
|
|
23
|
+
}
|
|
24
|
+
namespace GIST_VIEW_ENDPOINT {
|
|
25
|
+
let prod_3: string;
|
|
26
|
+
export { prod_3 as prod };
|
|
27
|
+
let dev_3: string;
|
|
28
|
+
export { dev_3 as dev };
|
|
29
|
+
let local_3: string;
|
|
30
|
+
export { local_3 as local };
|
|
31
|
+
}
|
|
32
|
+
function getSdkId(): any;
|
|
33
|
+
function useSSE(): any;
|
|
34
|
+
function setUseSSEFlag(useSSE: any): void;
|
|
35
|
+
function removeActiveSSEConnection(): void;
|
|
36
|
+
function setActiveSSEConnection(): void;
|
|
37
|
+
function hasActiveSSEConnection(): any;
|
|
38
|
+
function isSSEConnectionManagedBySDK(): boolean;
|
|
39
|
+
function getSSEHeartbeat(): number;
|
|
40
|
+
function setSSEHeartbeat(heartbeat: any): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function embedHTMLTemplate(elementId: any, messageProperties: any, url: any): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function messageHTMLTemplate(elementId: any, messageProperties: any, url: any): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export type GistEnv = "prod" | "dev" | "local";
|
|
2
|
+
export interface GistConfig {
|
|
3
|
+
siteId: string;
|
|
4
|
+
dataCenter: string;
|
|
5
|
+
env?: GistEnv;
|
|
6
|
+
logging?: boolean;
|
|
7
|
+
experiments?: boolean;
|
|
8
|
+
useAnonymousSession?: boolean;
|
|
9
|
+
isPreviewSession?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface GistMessage {
|
|
12
|
+
messageId: string;
|
|
13
|
+
queueId?: string;
|
|
14
|
+
instanceId?: string;
|
|
15
|
+
overlay?: boolean;
|
|
16
|
+
elementId?: string | null;
|
|
17
|
+
firstLoad?: boolean;
|
|
18
|
+
shouldScale?: boolean;
|
|
19
|
+
shouldResizeHeight?: boolean;
|
|
20
|
+
renderStartTime?: number;
|
|
21
|
+
currentRoute?: string;
|
|
22
|
+
position?: string;
|
|
23
|
+
savedStepName?: string | null;
|
|
24
|
+
isDisplayChange?: boolean;
|
|
25
|
+
displaySettings?: DisplaySettings;
|
|
26
|
+
properties?: MessageProperties;
|
|
27
|
+
}
|
|
28
|
+
export interface DisplaySettings {
|
|
29
|
+
displayType?: "modal" | "overlay" | "inline" | "tooltip";
|
|
30
|
+
modalPosition?: string;
|
|
31
|
+
overlayPosition?: string;
|
|
32
|
+
elementSelector?: string;
|
|
33
|
+
maxWidth?: number;
|
|
34
|
+
overlayColor?: string;
|
|
35
|
+
dismissOutsideClick?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface MessageProperties {
|
|
38
|
+
gist?: GistProperties;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
export interface GistProperties {
|
|
42
|
+
elementId?: string | null;
|
|
43
|
+
position?: string | null;
|
|
44
|
+
messageWidth?: number;
|
|
45
|
+
overlayColor?: string;
|
|
46
|
+
exitClick?: boolean;
|
|
47
|
+
tooltipPosition?: string;
|
|
48
|
+
routeRuleWeb?: string;
|
|
49
|
+
scale?: boolean;
|
|
50
|
+
campaignId?: string | null;
|
|
51
|
+
persistent?: boolean;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
export interface ResolvedMessageProperties {
|
|
55
|
+
isEmbedded: boolean;
|
|
56
|
+
elementId: string;
|
|
57
|
+
hasRouteRule: boolean;
|
|
58
|
+
routeRule: string;
|
|
59
|
+
position: string;
|
|
60
|
+
hasPosition: boolean;
|
|
61
|
+
shouldScale: boolean;
|
|
62
|
+
campaignId: string | null;
|
|
63
|
+
messageWidth: number;
|
|
64
|
+
overlayColor: string;
|
|
65
|
+
persistent: boolean;
|
|
66
|
+
exitClick: boolean;
|
|
67
|
+
hasCustomWidth: boolean;
|
|
68
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function shouldPersistSession(presisted: any): void;
|
|
2
|
+
export function setKeyToLocalStore(key: any, value: any, ttl?: null): void;
|
|
3
|
+
export function getKeyFromLocalStore(key: any): any;
|
|
4
|
+
export function clearKeyFromLocalStore(key: any): void;
|
|
5
|
+
export function clearExpiredFromLocalStore(): void;
|
|
6
|
+
export function isSessionBeingPersisted(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function log(message: any): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function fetchMessageByInstanceId(instanceId: any): any;
|
|
2
|
+
export function isQueueIdAlreadyShowing(queueId: any): boolean;
|
|
3
|
+
export function fetchMessageByElementId(elementId: any): any;
|
|
4
|
+
export function removeMessageByInstanceId(instanceId: any): void;
|
|
5
|
+
export function updateMessageByInstanceId(instanceId: any, message: any): void;
|
|
6
|
+
export function mapOverlayPositionToElementId(overlayPosition: any): any;
|
|
7
|
+
export function getCurrentDisplayType(message: any): "modal" | "overlay" | "inline";
|
|
8
|
+
export function hasDisplayChanged(currentMessage: any, displaySettings: any): boolean;
|
|
9
|
+
export function applyDisplaySettings(message: any, displaySettings: any): void;
|
|
10
|
+
export const wideOverlayPositions: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function setupPreview(): boolean;
|
package/package.json
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "customerio-gist-web",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.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
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"src"
|
|
9
|
+
],
|
|
6
10
|
"scripts": {
|
|
7
11
|
"start": "npm-run-all --parallel watch:server watch:build",
|
|
8
|
-
"build:prod": "webpack --mode=production --output-filename gist.min.js",
|
|
12
|
+
"build:prod": "webpack --mode=production --output-filename gist.min.js && npm run build:types",
|
|
13
|
+
"build:types": "tsc --project tsconfig.build.json",
|
|
9
14
|
"watch:build": "webpack --watch --progress --mode=development",
|
|
10
|
-
"watch:server": "http-server"
|
|
15
|
+
"watch:server": "http-server",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"typecheck": "tsc --noEmit"
|
|
11
19
|
},
|
|
20
|
+
"types": "./dist/types/index.d.ts",
|
|
12
21
|
"browser": "dist/gist.min.js",
|
|
13
22
|
"exports": {
|
|
23
|
+
"types": "./dist/types/index.d.ts",
|
|
14
24
|
"require": "./dist/gist.min.js",
|
|
15
25
|
"import": "./src/index.js"
|
|
16
26
|
},
|
|
@@ -21,7 +31,12 @@
|
|
|
21
31
|
"eslint": "^9.13.0",
|
|
22
32
|
"globals": "^15.11.0",
|
|
23
33
|
"http-server": "^14.1.1",
|
|
34
|
+
"jsdom": "^27.0.1",
|
|
24
35
|
"npm-run-all": "^4.1.5",
|
|
36
|
+
"ts-loader": "^9.5.4",
|
|
37
|
+
"typescript": "^5.9.3",
|
|
38
|
+
"typescript-eslint": "^8.56.0",
|
|
39
|
+
"vitest": "^4.0.18",
|
|
25
40
|
"webpack": "^5.91.0",
|
|
26
41
|
"webpack-cli": "^5.1.4"
|
|
27
42
|
},
|