@meltingspot/embed 1.12.0 → 1.13.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/CHANGELOG.md CHANGED
@@ -15,6 +15,14 @@ Date: YYYY-MM-DD
15
15
 
16
16
  -->
17
17
 
18
+ ## v1.13.0
19
+
20
+ Date: 2026-09-29
21
+
22
+ ### Minor Changes
23
+
24
+ - Bump `@meltingspot/core` to `1.13.0`.
25
+
18
26
  ## v1.12.0
19
27
 
20
28
  Date: 2026-09-22
package/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@meltingspot/core");var t=new e.Logger({appName:`Embed SDK`,appVersion:`1.12.0`}),n=class{#e=null;#t=null;constructor(e){this.content=e}set onRemove(e){this.#t=e}inject(t){this.remove();let n=(0,e.getHTMLElement)({input:t,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add(`ms-embed`),n.appendChild(this.#e)}remove(){this.#e&&=(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),null)}},r=class{constructor(t){this.baseURL=(0,e.formatBaseUrl)(t.baseURL),this.spotId=(0,e.formatUUID)(t.spotId),this.authToken=t.authToken??null,this.themeMode=t.themeMode??`auto`,this.domain=t.domain??null,this.deeplink=t.deeplink?(0,e.formatDeeplink)({deeplink:t.deeplink,spotId:this.spotId}):null,this.utmParameters=t.utmParameters??null,this.rootDocument=t.rootDocument}get iframe(){let t=this.authToken&&this.authToken.trim().length>0?`/sso/jwt`:``,n=new URL(`/spot/${this.spotId}${t}`,(0,e.trimSlashRight)(this.baseURL)),r=(0,e.createIframe)({url:n,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...(0,e.flattenUtmParameters)(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add(`ms-spot`),r}},i={READY:`meltingspot:ready`,ERROR:`meltingspot:error`,PREFILL_DRAFT:`meltingspot:prefillDraft`},a=class a{static{this.embeds=[]}static{this.messageListened=!1}static{this.iframeCallbacks=new Map}static injectSpotInto(i,o){let{onReady:s,onError:c,...l}=o,{spotId:u,rootDocument:d,msCommunityWebBaseUrl:f}=e.ConfigurationService.getConfiguration({spotId:l.spotId,rootDocument:l.rootDocument,msCommunityWebBaseUrl:l.baseURL});if(!u)throw t.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let p=new URLSearchParams(window.location.search),m={spotId:u,authToken:l.authToken??p.get(`ms_token`),domain:l.domain,deeplink:l.deeplink??p.get(`ms_url`),themeMode:l.themeMode,utmParameters:l.utmParameters??(0,e.parseUtmParameters)(p),baseURL:f,rootDocument:d},h=new n(new r(m));if(h.inject(i),a.embeds.push(h),s||c){let e=h.content.iframe.contentWindow;e&&(a.iframeCallbacks.set(e,{onReady:s,onError:c}),h.onRemove=e=>{a.iframeCallbacks.delete(e)}),a.ensureMessageListener()}return t.log(`Spot injected`,m,i),h}static clear(){a.embeds.forEach(e=>{e.remove()}),a.embeds=[],a.iframeCallbacks.clear(),a.messageListened&&=(window.removeEventListener(`message`,a.handleMessageEvent),!1),t.log(`All MeltingSpot embeds cleared`)}static handleMessageEvent(t){if(!t.data||typeof t.data!=`object`||t.data.type!==i.READY&&t.data.type!==i.ERROR)return;let n=t.source,r=a.iframeCallbacks.get(n);if(!r)return;let{msCommunityWebBaseUrl:o}=e.ConfigurationService.getConfiguration({});if(o)try{let e=new URL(o).origin;if(t.origin!==e)return}catch{}t.data.type===i.READY?r.onReady?.():r.onError?.(t.data.error)}static ensureMessageListener(){a.messageListened||=(window.addEventListener(`message`,a.handleMessageEvent),!0)}},o=globalThis;o.MeltingSpot||={},o.MeltingSpot.Embed=a,exports.EMBED_POST_MESSAGE_TYPE=i,exports.Embed=a,exports.EmbedFrame=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@meltingspot/core");var t=new e.Logger({appName:`Embed SDK`,appVersion:`1.13.0`}),n=class{#e=null;#t=null;constructor(e){this.content=e}set onRemove(e){this.#t=e}inject(t){this.remove();let n=(0,e.getHTMLElement)({input:t,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add(`ms-embed`),n.appendChild(this.#e)}remove(){this.#e&&=(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),null)}},r=class{constructor(t){this.baseURL=(0,e.formatBaseUrl)(t.baseURL),this.spotId=(0,e.formatUUID)(t.spotId),this.authToken=t.authToken??null,this.themeMode=t.themeMode??`auto`,this.domain=t.domain??null,this.deeplink=t.deeplink?(0,e.formatDeeplink)({deeplink:t.deeplink,spotId:this.spotId}):null,this.utmParameters=t.utmParameters??null,this.rootDocument=t.rootDocument}get iframe(){let t=this.authToken&&this.authToken.trim().length>0?`/sso/jwt`:``,n=new URL(`/spot/${this.spotId}${t}`,(0,e.trimSlashRight)(this.baseURL)),r=(0,e.createIframe)({url:n,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...(0,e.flattenUtmParameters)(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add(`ms-spot`),r}},i={READY:`meltingspot:ready`,ERROR:`meltingspot:error`,PREFILL_DRAFT:`meltingspot:prefillDraft`},a=class a{static{this.embeds=[]}static{this.messageListened=!1}static{this.iframeCallbacks=new Map}static injectSpotInto(i,o){let{onReady:s,onError:c,...l}=o,{spotId:u,rootDocument:d,msCommunityWebBaseUrl:f}=e.ConfigurationService.getConfiguration({spotId:l.spotId,rootDocument:l.rootDocument,msCommunityWebBaseUrl:l.baseURL});if(!u)throw t.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let p=new URLSearchParams(window.location.search),m={spotId:u,authToken:l.authToken??p.get(`ms_token`),domain:l.domain,deeplink:l.deeplink??p.get(`ms_url`),themeMode:l.themeMode,utmParameters:l.utmParameters??(0,e.parseUtmParameters)(p),baseURL:f,rootDocument:d},h=new n(new r(m));if(h.inject(i),a.embeds.push(h),s||c){let e=h.content.iframe.contentWindow;e&&(a.iframeCallbacks.set(e,{onReady:s,onError:c}),h.onRemove=e=>{a.iframeCallbacks.delete(e)}),a.ensureMessageListener()}return t.log(`Spot injected`,m,i),h}static clear(){a.embeds.forEach(e=>{e.remove()}),a.embeds=[],a.iframeCallbacks.clear(),a.messageListened&&=(window.removeEventListener(`message`,a.handleMessageEvent),!1),t.log(`All MeltingSpot embeds cleared`)}static handleMessageEvent(t){if(!t.data||typeof t.data!=`object`||t.data.type!==i.READY&&t.data.type!==i.ERROR)return;let n=t.source,r=a.iframeCallbacks.get(n);if(!r)return;let{msCommunityWebBaseUrl:o}=e.ConfigurationService.getConfiguration({});if(o)try{let e=new URL(o).origin;if(t.origin!==e)return}catch{}t.data.type===i.READY?r.onReady?.():r.onError?.(t.data.error)}static ensureMessageListener(){a.messageListened||=(window.addEventListener(`message`,a.handleMessageEvent),!0)}},o=globalThis;o.MeltingSpot||={},o.MeltingSpot.Embed=a,exports.EMBED_POST_MESSAGE_TYPE=i,exports.Embed=a,exports.EmbedFrame=n;
package/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { ConfigurationService as e, Logger as t, createIframe as n, flattenUtmPa
3
3
  //#region src/logger.ts
4
4
  var u = new t({
5
5
  appName: "Embed SDK",
6
- appVersion: "1.12.0"
6
+ appVersion: "1.13.0"
7
7
  }), d = class {
8
8
  #e = null;
9
9
  #t = null;
@@ -17,4 +17,4 @@ __p += '`),r&&(f+=`' +
17
17
  function print() { __p += __j.call(arguments, '') }
18
18
  `:`;
19
19
  `)+f+`return __p
20
- }`;var g=af(function(){return at(o,m+`return `+f).apply(n,s)});if(g.source=f,ou(g))throw g;return g}function Jd(e){return Q(e).toLowerCase()}function Yd(e){return Q(e).toUpperCase()}function Xd(e,t,r){if(e=Q(e),e&&(r||t===n))return Ln(e);if(!e||!(t=Ca(t)))return e;var i=ar(e),a=ar(t);return Fa(i,Vn(i,a),Hn(i,a)+1).join(``)}function Zd(e,t,r){if(e=Q(e),e&&(r||t===n))return e.slice(0,or(e)+1);if(!e||!(t=Ca(t)))return e;var i=ar(e);return Fa(i,0,Hn(i,ar(t))+1).join(``)}function Qd(e,t,r){if(e=Q(e),e&&(r||t===n))return e.replace(He,``);if(!e||!(t=Ca(t)))return e;var i=ar(e);return Fa(i,Vn(i,ar(t))).join(``)}function $d(e,t){var r=30,i=`...`;if(Y(t)){var a=`separator`in t?t.separator:a;r=`length`in t?Z(t.length):r,i=`omission`in t?Ca(t.omission):i}e=Q(e);var o=e.length;if(Jn(e)){var s=ar(e);o=s.length}if(r>=o)return e;var c=r-ir(i);if(c<1)return i;var l=s?Fa(s,0,c).join(``):e.slice(0,c);if(a===n)return l+i;if(s&&(c+=l.length-c),bu(a)){if(e.slice(c).search(a)){var u,d=l;for(a.global||(a=st(a.source,Q(Xe.exec(a))+`g`)),a.lastIndex=0;u=a.exec(d);)var f=u.index;l=l.slice(0,f===n?c:f)}}else if(e.indexOf(Ca(a),c)!=c){var p=l.lastIndexOf(a);p>-1&&(l=l.slice(0,p))}return l+i}function ef(e){return e=Q(e),e&&Me.test(e)?e.replace(Ae,sr):e}var tf=ro(function(e,t,n){return e+(n?` `:``)+t.toUpperCase()}),nf=no(`toUpperCase`);function rf(e,t,r){return e=Q(e),t=r?n:t,t===n?Yn(e)?ur(e):Cn(e):e.match(t)||[]}var af=G(function(e,t){try{return ln(e,n,t)}catch(e){return ou(e)?e:new it(e)}}),of=Oo(function(e,t){return dn(t,function(t){t=bs(t),oi(e,t,xl(e[t],e))}),e});function sf(e){var t=e==null?0:e.length,n=K();return e=t?V(e,function(e){if(typeof e[1]!=`function`)throw new M(r);return[n(e[0]),e[1]]}):[],G(function(n){for(var r=-1;++r<t;){var i=e[r];if(ln(i[0],this,n))return ln(i[1],this,n)}})}function cf(e){return ui(li(e,1))}function lf(e){return function(){return e}}function uf(e,t){return e==null||e!==e?t:e}var df=so(),ff=so(!0);function pf(e){return e}function mf(e){return Ki(typeof e==`function`?e:li(e,1))}function hf(e){return Zi(li(e,1))}function gf(e,t){return Qi(e,li(t,1))}var _f=G(function(e,t){return function(n){return Pi(n,e,t)}}),vf=G(function(e,t){return function(n){return Pi(e,n,t)}});function yf(e,t,n){var r=$(t),i=wi(t,r);n==null&&!(Y(t)&&(i.length||!r.length))&&(n=t,t=e,e=this,i=wi(t,$(t)));var a=!(Y(n)&&`chain`in n)||!!n.chain,o=cu(e);return dn(i,function(n){var r=t[n];e[n]=r,o&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__);return(n.__actions__=qa(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,_n([this.value()],arguments))})}),e}function bf(){return z._===this&&(z._=_t),this}function xf(){}function Sf(e){return e=Z(e),G(function(t){return ta(t,e)})}var Cf=fo(V),wf=fo(pn),Tf=fo(bn);function Ef(e){return Zo(e)?An(bs(e)):aa(e)}function Df(e){return function(t){return e==null?n:Ti(e,t)}}var Of=ho(),kf=ho(!0);function Af(){return[]}function jf(){return!1}function Mf(){return{}}function Nf(){return``}function Pf(){return!0}function Ff(e,t){if(e=Z(e),e<1||e>g)return[];var n=y,r=R(e,y);t=K(t),e-=y;for(var i=Fn(r,t);++n<e;)t(n);return i}function If(e){return q(e)?V(e,bs):wu(e)?[e]:qa(ys(Q(e)))}function Lf(e){var t=++pt;return Q(e)+t}var Rf=uo(function(e,t){return e+t},0),zf=vo(`ceil`),Bf=uo(function(e,t){return e/t},1),Vf=vo(`floor`);function Hf(e){return e&&e.length?_i(e,pf,Oi):n}function Uf(e,t){return e&&e.length?_i(e,K(t,2),Oi):n}function Wf(e){return kn(e,pf)}function Gf(e,t){return kn(e,K(t,2))}function Kf(e){return e&&e.length?_i(e,pf,Yi):n}function qf(e,t){return e&&e.length?_i(e,K(t,2),Yi):n}var Jf=uo(function(e,t){return e*t},1),Yf=vo(`round`),Xf=uo(function(e,t){return e-t},0);function Zf(e){return e&&e.length?Pn(e,pf):0}function Qf(e,t){return e&&e.length?Pn(e,K(t,2)):0}return H.after=vl,H.ary=yl,H.assign=Lu,H.assignIn=Ru,H.assignInWith=zu,H.assignWith=Bu,H.at=Vu,H.before=bl,H.bind=xl,H.bindAll=of,H.bindKey=Sl,H.castArray=Vl,H.chain=Pc,H.chunk=ws,H.compact=Ts,H.concat=Es,H.cond=sf,H.conforms=cf,H.constant=lf,H.countBy=Gc,H.create=Hu,H.curry=Cl,H.curryRight=wl,H.debounce=Tl,H.defaults=Uu,H.defaultsDeep=Wu,H.defer=El,H.delay=Dl,H.difference=Ds,H.differenceBy=Os,H.differenceWith=ks,H.drop=As,H.dropRight=js,H.dropRightWhile=Ms,H.dropWhile=Ns,H.fill=Ps,H.filter=qc,H.flatMap=Xc,H.flatMapDeep=Zc,H.flatMapDepth=Qc,H.flatten=Ls,H.flattenDeep=Rs,H.flattenDepth=zs,H.flip=Ol,H.flow=df,H.flowRight=ff,H.fromPairs=Bs,H.functions=Zu,H.functionsIn=Qu,H.groupBy=tl,H.initial=Us,H.intersection=Ws,H.intersectionBy=Gs,H.intersectionWith=Ks,H.invert=nd,H.invertBy=rd,H.invokeMap=rl,H.iteratee=mf,H.keyBy=il,H.keys=$,H.keysIn=ad,H.map=al,H.mapKeys=od,H.mapValues=sd,H.matches=hf,H.matchesProperty=gf,H.memoize=kl,H.merge=cd,H.mergeWith=ld,H.method=_f,H.methodOf=vf,H.mixin=yf,H.negate=Al,H.nthArg=Sf,H.omit=ud,H.omitBy=dd,H.once=jl,H.orderBy=ol,H.over=Cf,H.overArgs=Ml,H.overEvery=wf,H.overSome=Tf,H.partial=Nl,H.partialRight=Pl,H.partition=sl,H.pick=fd,H.pickBy=pd,H.property=Ef,H.propertyOf=Df,H.pull=Zs,H.pullAll=Qs,H.pullAllBy=$s,H.pullAllWith=ec,H.pullAt=tc,H.range=Of,H.rangeRight=kf,H.rearg=Fl,H.reject=ul,H.remove=nc,H.rest=Il,H.reverse=rc,H.sampleSize=fl,H.set=hd,H.setWith=gd,H.shuffle=pl,H.slice=ic,H.sortBy=gl,H.sortedUniq=dc,H.sortedUniqBy=fc,H.split=Wd,H.spread=Ll,H.tail=pc,H.take=mc,H.takeRight=hc,H.takeRightWhile=gc,H.takeWhile=_c,H.tap=Fc,H.throttle=Rl,H.thru=Ic,H.toArray=ju,H.toPairs=_d,H.toPairsIn=vd,H.toPath=If,H.toPlainObject=Fu,H.transform=yd,H.unary=zl,H.union=vc,H.unionBy=yc,H.unionWith=bc,H.uniq=xc,H.uniqBy=Sc,H.uniqWith=Cc,H.unset=bd,H.unzip=wc,H.unzipWith=Tc,H.update=xd,H.updateWith=Sd,H.values=Cd,H.valuesIn=wd,H.without=Ec,H.words=rf,H.wrap=Bl,H.xor=Dc,H.xorBy=Oc,H.xorWith=kc,H.zip=Ac,H.zipObject=jc,H.zipObjectDeep=Mc,H.zipWith=Nc,H.entries=_d,H.entriesIn=vd,H.extend=Ru,H.extendWith=zu,yf(H,H),H.add=Rf,H.attempt=af,H.camelCase=Od,H.capitalize=kd,H.ceil=zf,H.clamp=Td,H.clone=Hl,H.cloneDeep=Wl,H.cloneDeepWith=Gl,H.cloneWith=Ul,H.conformsTo=Kl,H.deburr=Ad,H.defaultTo=uf,H.divide=Bf,H.endsWith=jd,H.eq=ql,H.escape=Md,H.escapeRegExp=Nd,H.every=Kc,H.find=Jc,H.findIndex=Fs,H.findKey=Gu,H.findLast=Yc,H.findLastIndex=Is,H.findLastKey=Ku,H.floor=Vf,H.forEach=$c,H.forEachRight=el,H.forIn=qu,H.forInRight=Ju,H.forOwn=Yu,H.forOwnRight=Xu,H.get=$u,H.gt=Jl,H.gte=Yl,H.has=ed,H.hasIn=td,H.head=Vs,H.identity=pf,H.includes=nl,H.indexOf=Hs,H.inRange=Ed,H.invoke=id,H.isArguments=Xl,H.isArray=q,H.isArrayBuffer=Zl,H.isArrayLike=Ql,H.isArrayLikeObject=J,H.isBoolean=$l,H.isBuffer=eu,H.isDate=tu,H.isElement=nu,H.isEmpty=ru,H.isEqual=iu,H.isEqualWith=au,H.isError=ou,H.isFinite=su,H.isFunction=cu,H.isInteger=lu,H.isLength=uu,H.isMap=du,H.isMatch=fu,H.isMatchWith=pu,H.isNaN=mu,H.isNative=hu,H.isNil=_u,H.isNull=gu,H.isNumber=vu,H.isObject=Y,H.isObjectLike=X,H.isPlainObject=yu,H.isRegExp=bu,H.isSafeInteger=xu,H.isSet=Su,H.isString=Cu,H.isSymbol=wu,H.isTypedArray=Tu,H.isUndefined=Eu,H.isWeakMap=Du,H.isWeakSet=Ou,H.join=qs,H.kebabCase=Pd,H.last=Js,H.lastIndexOf=Ys,H.lowerCase=Fd,H.lowerFirst=Id,H.lt=ku,H.lte=Au,H.max=Hf,H.maxBy=Uf,H.mean=Wf,H.meanBy=Gf,H.min=Kf,H.minBy=qf,H.stubArray=Af,H.stubFalse=jf,H.stubObject=Mf,H.stubString=Nf,H.stubTrue=Pf,H.multiply=Jf,H.nth=Xs,H.noConflict=bf,H.noop=xf,H.now=_l,H.pad=Ld,H.padEnd=Rd,H.padStart=zd,H.parseInt=Bd,H.random=Dd,H.reduce=cl,H.reduceRight=ll,H.repeat=Vd,H.replace=Hd,H.result=md,H.round=Yf,H.runInContext=e,H.sample=dl,H.size=ml,H.snakeCase=Ud,H.some=hl,H.sortedIndex=ac,H.sortedIndexBy=oc,H.sortedIndexOf=sc,H.sortedLastIndex=cc,H.sortedLastIndexBy=lc,H.sortedLastIndexOf=uc,H.startCase=Gd,H.startsWith=Kd,H.subtract=Xf,H.sum=Zf,H.sumBy=Qf,H.template=qd,H.times=Ff,H.toFinite=Mu,H.toInteger=Z,H.toLength=Nu,H.toLower=Jd,H.toNumber=Pu,H.toSafeInteger=Iu,H.toString=Q,H.toUpper=Yd,H.trim=Xd,H.trimEnd=Zd,H.trimStart=Qd,H.truncate=$d,H.unescape=ef,H.uniqueId=Lf,H.upperCase=tf,H.upperFirst=nf,H.each=$c,H.eachRight=el,H.first=Vs,yf(H,function(){var e={};return Si(H,function(t,n){P.call(H.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),H.VERSION=`4.17.21`,dn([`bind`,`bindKey`,`curry`,`curryRight`,`partial`,`partialRight`],function(e){H[e].placeholder=H}),dn([`drop`,`take`],function(e,t){U.prototype[e]=function(r){r=r===n?1:F(Z(r),0);var i=this.__filtered__&&!t?new U(this):this.clone();return i.__filtered__?i.__takeCount__=R(r,i.__takeCount__):i.__views__.push({size:R(r,y),type:e+(i.__dir__<0?`Right`:``)}),i},U.prototype[e+`Right`]=function(t){return this.reverse()[e](t).reverse()}}),dn([`filter`,`map`,`takeWhile`],function(e,t){var n=t+1,r=n==1||n==3;U.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:K(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),dn([`head`,`last`],function(e,t){var n=`take`+(t?`Right`:``);U.prototype[e]=function(){return this[n](1).value()[0]}}),dn([`initial`,`tail`],function(e,t){var n=`drop`+(t?``:`Right`);U.prototype[e]=function(){return this.__filtered__?new U(this):this[n](1)}}),U.prototype.compact=function(){return this.filter(pf)},U.prototype.find=function(e){return this.filter(e).head()},U.prototype.findLast=function(e){return this.reverse().find(e)},U.prototype.invokeMap=G(function(e,t){return typeof e==`function`?new U(this):this.map(function(n){return Pi(n,e,t)})}),U.prototype.reject=function(e){return this.filter(Al(K(e)))},U.prototype.slice=function(e,t){e=Z(e);var r=this;return r.__filtered__&&(e>0||t<0)?new U(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(t=Z(t),r=t<0?r.dropRight(-t):r.take(t-e)),r)},U.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},U.prototype.toArray=function(){return this.take(y)},Si(U.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=H[i?`take`+(t==`last`?`Right`:``):t],o=i||/^find/.test(t);a&&(H.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,c=t instanceof U,l=s[0],u=c||q(t),d=function(e){var t=a.apply(H,_n([e],s));return i&&f?t[0]:t};u&&r&&typeof l==`function`&&l.length!=1&&(c=u=!1);var f=this.__chain__,p=!!this.__actions__.length,m=o&&!f,h=c&&!p;if(!o&&u){t=h?t:new U(this);var g=e.apply(t,s);return g.__actions__.push({func:Ic,args:[d],thisArg:n}),new yr(g,f)}return m&&h?e.apply(this,s):(g=this.thru(d),m?i?g.value()[0]:g.value():g)})}),dn([`pop`,`push`,`shift`,`sort`,`splice`,`unshift`],function(e){var t=N[e],n=/^(?:push|sort|unshift)$/.test(e)?`tap`:`thru`,r=/^(?:pop|shift)$/.test(e);H.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(q(i)?i:[],e)}return this[n](function(n){return t.apply(q(n)?n:[],e)})}}),Si(U.prototype,function(e,t){var n=H[t];if(n){var r=n.name+``;P.call(jn,r)||(jn[r]=[]),jn[r].push({name:t,func:n})}}),jn[co(n,s).name]=[{name:`wrapper`,func:n}],U.prototype.clone=br,U.prototype.reverse=xr,U.prototype.value=Sr,H.prototype.at=Lc,H.prototype.chain=Rc,H.prototype.commit=zc,H.prototype.next=Bc,H.prototype.plant=Hc,H.prototype.reverse=Uc,H.prototype.toJSON=H.prototype.valueOf=H.prototype.value=Wc,H.prototype.first=H.prototype.head,Ot&&(H.prototype[Ot]=Vc),H})();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(z._=dr,define(function(){return dr})):$t?(($t.exports=dr)._=dr,Qt._=dr):z._=dr}).call(e)}))(),Object.values(function(e){return e.EditMode=`edit-mode`,e.Preview=`preview`,e}({}));var De=`1.12.0`,Oe=class{constructor(e){this.debug=!1,this.debug=e?.debug??!1,this.appName=e?.appName,this.appVersion=e?.appVersion}log(e,...t){this.debug&&this.print(e,`info`,t)}warn(e,...t){this.print(e,`warn`,t)}error(e,...t){this.print(e,`error`,t)}print(e,t,n){let r=[`[${[`MeltingSpot`,this.appName,this.appVersion].filter(Boolean).join(` - `)}] ${e}`];n.length&&r.push(...n),console[t](...r)}},ke=new Oe({appName:`Core SDK`,appVersion:De}),Ae=e=>e.toLowerCase().replace(/[^a-z0-9-]/g,``),je=[`/user`],Me=({deeplink:e,spotId:t})=>{try{let n=new URL(e,`https://unused.com`),r=n.pathname;return n.search&&(r+=n.search),n.hash&&(r+=n.hash),je.some(e=>r.startsWith(e))||(r=`/spot/${t}/${ie(r)}`),r}catch(e){return ke.warn(`Failed to parse deeplink URL`,e),null}},Ne=[/(^|\.)meltingspot\.io$/i],Pe=e=>{let t;try{let n=oe(e);t=new URL(n)}catch{throw Error(`Invalid baseURL: ${e}`)}let n=t.hostname===`localhost`||t.hostname===`127.0.0.1`,r=t.protocol===`https:`,i=Ne.some(e=>e.test(t.hostname));if(!n&&(!r||!i))throw Error(`Untrusted baseURL origin: ${t.origin}`);return t.origin},Fe={msApiBaseUrl:`https://openapi.meltingspot.io/`,msCommunityWebBaseUrl:`https://go.meltingspot.io/`,ssoToken:void 0,spotId:``,autoJoin:!1,rootDocument:globalThis.document},Ie=class e{constructor(){this.configuration=Fe}static getInstance(){return e.instance||=new e,e.instance}setConfiguration(e){this.configuration={...this.configuration,...e}}static getConfiguration(t={}){return{...e.getInstance().configuration,...t}}},Le=RegExp(`(%[a-f0-9]{2})|([^%]+?)`,`gi`),Re=RegExp(`(%[a-f0-9]{2})+`,`gi`);function ze(e,t){try{return[decodeURIComponent(e.join(``))]}catch{}if(e.length===1)return e;t||=1;let n=e.slice(0,t),r=e.slice(t);return Array.prototype.concat.call([],ze(n),ze(r))}function Be(e){try{return decodeURIComponent(e)}catch{let t=e.match(Le)||[];for(let n=1;n<t.length;n++)e=ze(t,n).join(``),t=e.match(Le)||[];return e}}function Ve(e){let t={"%FE%FF":`��`,"%FF%FE":`��`},n=Re.exec(e);for(;n;){try{t[n[0]]=decodeURIComponent(n[0])}catch{let e=Be(n[0]);e!==n[0]&&(t[n[0]]=e)}n=Re.exec(e)}t[`%C2`]=`�`;let r=Object.keys(t);for(let n of r)e=e.replace(new RegExp(n,`g`),t[n]);return e}function He(e){if(typeof e!=`string`)throw TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return Ve(e)}}function k(e,t){let n={};if(Array.isArray(t))for(let r of t){let t=Object.getOwnPropertyDescriptor(e,r);t?.enumerable&&Object.defineProperty(n,r,t)}else for(let r of Reflect.ownKeys(e)){let i=Object.getOwnPropertyDescriptor(e,r);if(i.enumerable){let a=e[r];t(r,a,e)&&Object.defineProperty(n,r,i)}}return n}function Ue(e,t){if(typeof e!=`string`||typeof t!=`string`)throw TypeError("Expected the arguments to be of type `string`");if(e===``||t===``)return[];let n=e.indexOf(t);return n===-1?[]:[e.slice(0,n),e.slice(n+t.length)]}var We=c({exclude:()=>st,extract:()=>nt,parse:()=>rt,parseUrl:()=>at,pick:()=>j,stringify:()=>it,stringifyUrl:()=>ot}),Ge=e=>e==null,Ke=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),qe=Symbol(`encodeFragmentIdentifier`);function Je(e){switch(e.arrayFormat){case`index`:return t=>(n,r)=>{let i=n.length;return r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[A(t,e),`[`,i,`]`].join(``)]:[...n,[A(t,e),`[`,A(i,e),`]=`,A(r,e)].join(``)]};case`bracket`:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[A(t,e),`[]`].join(``)]:[...n,[A(t,e),`[]=`,A(r,e)].join(``)];case`colon-list-separator`:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[A(t,e),`:list=`].join(``)]:[...n,[A(t,e),`:list=`,A(r,e)].join(``)];case`comma`:case`separator`:case`bracket-separator`:{let t=e.arrayFormat===`bracket-separator`?`[]=`:`=`;return n=>(r,i)=>i===void 0||e.skipNull&&i===null||e.skipEmptyString&&i===``?r:(i=i===null?``:i,r.length===0?[[A(n,e),t,A(i,e)].join(``)]:[[r,A(i,e)].join(e.arrayFormatSeparator)])}default:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,A(t,e)]:[...n,[A(t,e),`=`,A(r,e)].join(``)]}}function Ye(e){let t;switch(e.arrayFormat){case`index`:return(e,n,r)=>{if(t=/\[(\d*)]$/.exec(e),e=e.replace(/\[\d*]$/,``),!t){r[e]=n;return}r[e]===void 0&&(r[e]={}),r[e][t[1]]=n};case`bracket`:return(e,n,r)=>{if(t=/(\[])$/.exec(e),e=e.replace(/\[]$/,``),!t){r[e]=n;return}if(r[e]===void 0){r[e]=[n];return}r[e]=[...r[e],n]};case`colon-list-separator`:return(e,n,r)=>{if(t=/(:list)$/.exec(e),e=e.replace(/:list$/,``),!t){r[e]=n;return}if(r[e]===void 0){r[e]=[n];return}r[e]=[...r[e],n]};case`comma`:case`separator`:return(t,n,r)=>{let i=typeof n==`string`&&n.includes(e.arrayFormatSeparator),a=typeof n==`string`&&!i&&Ze(n,e).includes(e.arrayFormatSeparator);n=a?Ze(n,e):n,r[t]=i||a?n.split(e.arrayFormatSeparator).map(t=>Ze(t,e)):n===null?n:Ze(n,e)};case`bracket-separator`:return(t,n,r)=>{let i=/(\[])$/.test(t);if(t=t.replace(/\[]$/,``),!i){r[t]=n&&Ze(n,e);return}let a=n===null?[]:Ze(n,e).split(e.arrayFormatSeparator);if(r[t]===void 0){r[t]=a;return}r[t]=[...r[t],...a]};default:return(e,t,n)=>{if(n[e]===void 0){n[e]=t;return}n[e]=[...[n[e]].flat(),t]}}}function Xe(e){if(typeof e!=`string`||e.length!==1)throw TypeError(`arrayFormatSeparator must be single character string`)}function A(e,t){return t.encode?t.strict?Ke(e):encodeURIComponent(e):e}function Ze(e,t){return t.decode?He(e):e}function Qe(e){return Array.isArray(e)?e.sort():typeof e==`object`?Qe(Object.keys(e)).sort((e,t)=>Number(e)-Number(t)).map(t=>e[t]):e}function $e(e){let t=e.indexOf(`#`);return t!==-1&&(e=e.slice(0,t)),e}function et(e){let t=``,n=e.indexOf(`#`);return n!==-1&&(t=e.slice(n)),t}function tt(e,t,n){return n===`string`&&typeof e==`string`?e:typeof n==`function`&&typeof e==`string`?n(e):n===`boolean`&&e===null?!0:n===`boolean`&&e!==null&&(e.toLowerCase()===`true`||e.toLowerCase()===`false`)?e.toLowerCase()===`true`:n===`boolean`&&e!==null&&(e.toLowerCase()===`1`||e.toLowerCase()===`0`)?e.toLowerCase()===`1`:n===`string[]`&&t.arrayFormat!==`none`&&typeof e==`string`?[e]:n===`number[]`&&t.arrayFormat!==`none`&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?[Number(e)]:n===`number`&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?Number(e):t.parseBooleans&&e!==null&&(e.toLowerCase()===`true`||e.toLowerCase()===`false`)?e.toLowerCase()===`true`:t.parseNumbers&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?Number(e):e}function nt(e){e=$e(e);let t=e.indexOf(`?`);return t===-1?``:e.slice(t+1)}function rt(e,t){t={decode:!0,sort:!0,arrayFormat:`none`,arrayFormatSeparator:`,`,parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...t},Xe(t.arrayFormatSeparator);let n=Ye(t),r=Object.create(null);if(typeof e!=`string`||(e=e.trim().replace(/^[?#&]/,``),!e))return r;for(let i of e.split(`&`)){if(i===``)continue;let e=t.decode?i.replaceAll(`+`,` `):i,[a,o]=Ue(e,`=`);a===void 0&&(a=e),o=o===void 0?null:[`comma`,`separator`,`bracket-separator`].includes(t.arrayFormat)?o:Ze(o,t),n(Ze(a,t),o,r)}for(let[e,n]of Object.entries(r))if(typeof n==`object`&&n&&t.types[e]!==`string`)for(let[r,i]of Object.entries(n)){let a=t.types[e]?t.types[e].replace(`[]`,``):void 0;n[r]=tt(i,t,a)}else r[e]=typeof n==`object`&&n&&t.types[e]===`string`?Object.values(n).join(t.arrayFormatSeparator):tt(n,t,t.types[e]);return t.sort===!1?r:(t.sort===!0?Object.keys(r).sort():Object.keys(r).sort(t.sort)).reduce((e,t)=>{let n=r[t];return e[t]=n&&typeof n==`object`&&!Array.isArray(n)?Qe(n):n,e},Object.create(null))}function it(e,t){if(!e)return``;t={encode:!0,strict:!0,arrayFormat:`none`,arrayFormatSeparator:`,`,...t},Xe(t.arrayFormatSeparator);let n=n=>t.skipNull&&Ge(e[n])||t.skipEmptyString&&e[n]===``,r=Je(t),i={};for(let[t,r]of Object.entries(e))n(t)||(i[t]=r);let a=Object.keys(i);return t.sort!==!1&&a.sort(t.sort),a.map(n=>{let i=e[n];return i===void 0?``:i===null?A(n,t):Array.isArray(i)?i.length===0&&t.arrayFormat===`bracket-separator`?A(n,t)+`[]`:i.reduce(r(n),[]).join(`&`):A(n,t)+`=`+A(i,t)}).filter(e=>e.length>0).join(`&`)}function at(e,t){t={decode:!0,...t};let[n,r]=Ue(e,`#`);return n===void 0&&(n=e),{url:n?.split(`?`)?.[0]??``,query:rt(nt(e),t),...t&&t.parseFragmentIdentifier&&r?{fragmentIdentifier:Ze(r,t)}:{}}}function ot(e,t){t={encode:!0,strict:!0,[qe]:!0,...t};let n=$e(e.url).split(`?`)[0]||``,r=it({...rt(nt(e.url),{sort:!1,...t}),...e.query},t);r&&=`?${r}`;let i=et(e.url);if(typeof e.fragmentIdentifier==`string`){let r=new URL(n);r.hash=e.fragmentIdentifier,i=t[qe]?r.hash:`#${e.fragmentIdentifier}`}return`${n}${r}${i}`}function j(e,t,n){n={parseFragmentIdentifier:!0,[qe]:!1,...n};let{url:r,query:i,fragmentIdentifier:a}=at(e,n);return ot({url:r,query:k(i,t),fragmentIdentifier:a},n)}function st(e,t,n){return j(e,Array.isArray(t)?e=>!t.includes(e):(e,n)=>!t(e,n),n)}var ct=We,M=class e extends Error{constructor(t,n){super(`HTTP Error ${t}${n?`: ${n}`:``}`),this.code=t,this.name=`HttpError`,Object.setPrototypeOf(this,e.prototype)}},N=function(e){return e.DELETE=`DELETE`,e.GET=`GET`,e.PATCH=`PATCH`,e.POST=`POST`,e}({}),lt=class{constructor(){this.headers={}}setHeaders(e){this.headers=e}async get(e){try{let t=e.query?`${e.url}?${this.serializeQuery(e.query)}`:e.url,n=await fetch(t,{headers:{...this.headers,...e.headers,"Content-Type":`application/json`},...e.signal?{signal:e.signal}:{}});return n.ok?T(await n.json()):E(new M(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}async post(e){try{let t=await fetch(e.url,{method:`POST`,headers:{...this.headers,...e.headers,"Content-Type":`application/json`},body:JSON.stringify(e.payload),...e.signal?{signal:e.signal}:{}});return t.ok?T(await t.json()):E(new M(t.status,await t.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}async delete(e){try{let t=await fetch(e.url,{method:`DELETE`,headers:{...this.headers,...e.headers,Accept:`application/json`},...e.signal?{signal:e.signal}:{}});return t.ok?T(await t.json()):E(new M(t.status,await t.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}async patch(e){try{let t=await fetch(e.url,{method:`PATCH`,headers:{...this.headers,...e.headers,"Content-Type":`application/json`},body:JSON.stringify(e.payload),...e.signal?{signal:e.signal}:{}});return t.ok?T(await t.json()):E(new M(t.status,await t.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}serializeQuery(e){if(typeof e==`string`)return e;if(typeof e==`object`)for(let t in e)e[t]===void 0&&delete e[t];return e=ct.stringify(e,{arrayFormat:`none`}),e}},ut={accessToken:{email:`/v1/auth/accessToken/email`,sso:{jwt:`/v1/auth/accessToken/sso/jwt`}},refreshAccessToken:`/v1/auth/accessToken~refresh`,password:{reset:`/v1/auth/password~reset`}},dt=class e extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return e.instance||=new e,e.instance}async loginWithPassword(e,t){let n=await this.callApi({endpoint:ut.accessToken.email,method:`POST`,body:{email:e,password:t},withSpotId:!0});if(n.isErr())return E(n.error);let{accessToken:r,refreshToken:i}=n.value;return this.setTokens(r.token,i.token),T({accessToken:r.token,refreshToken:i.token})}async loginWithSsoToken(e){let t=await this.callApi({endpoint:ut.accessToken.sso.jwt,method:`POST`,body:{token:e},withSpotId:!0});if(t.isErr())return E(t.error);let{accessToken:n,refreshToken:r}=t.value;return this.setTokens(n.token,r.token),T({accessToken:n.token,refreshToken:r.token})}loginWithAuthTokens(e,t){return this.setTokens(e,t),{accessToken:e,refreshToken:t}}resetPassword(e){return this.callApi({endpoint:ut.password.reset,method:`POST`,body:{email:e}})}async refresh(){let e=await this.callApi({endpoint:ut.refreshAccessToken,method:`POST`,body:{refreshToken:this.refreshToken}});if(e.isErr())return E(e.error);let{accessToken:t,refreshToken:n}=e.value;return this.setTokens(t.token,n.token),T({accessToken:t.token,refreshToken:n.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(e,t){if(this.accessToken!==e||this.refreshToken!==t){this.accessToken=e,this.refreshToken=t;let n=new CustomEvent(`auth:tokens-updated`,{detail:{accessToken:e,refreshToken:t}});this.dispatchEvent(n)}}async callApi(e){try{let{spotId:t,msApiBaseUrl:n}=Ie.getConfiguration(),r=se(e.endpoint,n),i={"Content-Type":`application/json`,...e.headers};e.withSpotId&&t&&(i[ft.SpotId]=t);let a=await fetch(r,{method:e.method,body:e.body?JSON.stringify(e.body):void 0,headers:i});return a.ok?a.status===D.NO_CONTENT?T(void 0):T(await a.json()):E(new M(a.status,a.statusText))}catch(e){return E(new M(D.INTERNAL_SERVER_ERROR,e instanceof Error?e.message:String(e)))}}},ft=function(e){return e.Authorization=`Authorization`,e.SpotId=`x-spotid`,e}({}),P=class e{static getInstance(){return e.instance||=new e,e.instance}static buildAuthenticatedRequest(e){let{msApiBaseUrl:t,spotId:n}=Ie.getConfiguration(),r=se(e,t),i=dt.getInstance().getAccessToken();if(!i)return E(Error(`Not authenticated`));let a={"Content-Type":`application/json`,Authorization:`Bearer ${i}`};return n&&(a[`x-spotid`]=n),T({url:r,headers:a})}static async stream(t,n,r){let{streamTransport:i}=Ie.getConfiguration();if(i)return i({endpoint:t,body:n,signal:r});let a=e.buildAuthenticatedRequest(t);if(a.isErr())return E(a.error);let{url:o,headers:s}=a.value;try{let e=await fetch(o,{method:`POST`,headers:s,...n===void 0?{}:{body:JSON.stringify(n)},...r?{signal:r}:{}});if(!e.ok){let t=await e.text();return E(Error(`HTTP ${e.status}: ${t}`))}return e.body?T(e.body):E(Error(`Response body is empty`))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(e instanceof Error?e:Error(t))}}get pendingCount(){return this.queue.length}constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=dt.getInstance(),this.httpService=new lt}enqueue(e){return new Promise(t=>{this.queue.push(async()=>{try{t(await e())}catch(e){t(E(new M(D.INTERNAL_SERVER_ERROR,e instanceof Error?e.message:`Unknown error`)))}}),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){let e=this.queue.shift();if(!e)break;await e()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){let e=this.isPaused;this.isPaused=!1,e&&this.processQueue()}async call(e){return this.enqueue(async()=>{let t=async()=>{let{spotId:t,msApiBaseUrl:n}=Ie.getConfiguration(),r={...e.options?.headers??{}};t&&(r[`x-spotid`]=t);let i=this.authService.getAccessToken(),{requiresAuth:a=!0}=e;if(!i&&a)return E(new M(D.UNAUTHORIZED));i&&(r.Authorization=`Bearer ${i}`);let o=se(e.endpoint,n);switch(e.method){case N.DELETE:return this.httpService.delete({...e.options??{},headers:r,url:o});case N.GET:return this.httpService.get({...e.options??{},headers:r,url:o});case N.PATCH:return this.httpService.patch({...e.options??{},headers:r,url:o});case N.POST:return this.httpService.post({...e.options??{},headers:r,url:o});default:return E(new M(D.METHOD_NOT_ALLOWED,`Method not allowed`))}},n=await t();if(n.isErr()&&n.error.code===D.UNAUTHORIZED){let e=await this.authService.refresh();if(e.isErr())return E(new M(D.UNAUTHORIZED,e.error.message));n=await t()}return n})}},pt={playbooks:`/v1/playbooks`,pages:e=>`/v1/playbooks/${e}/pages`,hotspots:(e,t)=>`/v1/playbooks/${e}/pages/${t}/hotspots`,hotspot:(e,t,n)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}`,accessibleIntents:(e,t)=>`/v1/playbooks/${e}/pages/${t}/accessibleIntents`,intents:(e,t,n)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}/intents`,intent:(e,t,n,r)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}/intents/${r}`},mt=50,ht=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async listPlaybooks(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.playbooks,options:{query:{page:e?.page??1,limit:e?.limit??mt,...e?.domain?{"domain[eq]":e.domain}:{},...e?.host===void 0?{}:{"domain[matchesHost]":e.host}}}});return t.isErr()?E(t.error):T(t.value)}async listPlaybookPages(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.pages(e.playbookId),options:{query:{page:e.page??1,limit:e.limit??mt,...e.url?{"url[eq]":e.url}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookPage(e,t){let n=await this.meltingSpotApi.call({method:N.POST,endpoint:pt.pages(e.playbookId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async listAccessiblePlaybookIntents(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.accessibleIntents(e.playbookId,e.pageId),options:{query:{...e.domain?{domain:e.domain}:{}}}});return t.isErr()?E(t.error):T(t.value)}async listPlaybookHotspots(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.hotspots(e.playbookId,e.pageId),options:{query:{page:e.page??1,limit:e.limit??mt,...e.intentStatus?{"intentStatus[eq]":e.intentStatus}:{},...e.widgetType?{"widgetType[eq]":e.widgetType}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookHotspot(e,t){let n=await this.meltingSpotApi.call({method:N.POST,endpoint:pt.hotspots(e.playbookId,e.pageId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async updatePlaybookHotspot(e,t){let n=await this.meltingSpotApi.call({method:N.PATCH,endpoint:pt.hotspot(e.playbookId,e.pageId,e.hotspotId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async listPlaybookIntents(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.intents(e.playbookId,e.pageId,e.hotspotId),options:{query:{page:e.page??1,limit:e.limit??mt,...e.status?{"status[eq]":e.status}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookIntent(e,t){let n=await this.meltingSpotApi.call({method:N.POST,endpoint:pt.intents(e.playbookId,e.pageId,e.hotspotId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async updatePlaybookIntent(e,t){let n=await this.meltingSpotApi.call({method:N.PATCH,endpoint:pt.intent(e.playbookId,e.pageId,e.hotspotId,e.intentId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}},gt={me:`/v1/spots/me`},_t=50,vt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async listSpotsForMe(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:gt.me,options:{query:{page:1,limit:_t,...e?.spotMemberRole?{"spotMemberRole[eq]":e.spotMemberRole}:{}}}});return t.isErr()?E(t.error):T(t.value)}},yt={spotMember:{me:`/v1/spotMembers/me`,joinFromSso:`/v1/spotMembers~joinFromSso`,search:`/v1/spotMembers~search`}},bt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async getSpotMemberForMe(){let e=await this.meltingSpotApi.call({method:N.GET,endpoint:yt.spotMember.me});return e.isErr()?E(e.error):T(e.value)}async searchSpotMembers(e){let t={page:e.page,limit:e.limit};e.search&&(t.search=e.search);let n=await this.meltingSpotApi.call({method:N.GET,endpoint:yt.spotMember.search,options:{query:t}});return n.isErr()?E(n.error):T(n.value)}async joinFromSso(e){let t=await this.meltingSpotApi.call({method:N.POST,endpoint:yt.spotMember.joinFromSso,options:{payload:{token:e}}});return t.isErr()?E(t.error):T(t.value)}},xt={spotMemberSsoToken:`/v1/spotMembers/auth/sso/jwt`,previewAccessKey:`/v1/spotMembers/auth/preview/accessKey`},St=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async generateSsoToken(){let e=await this.meltingSpotApi.call({method:N.POST,endpoint:xt.spotMemberSsoToken,options:{payload:{}}});return e.isErr()?E(e.error):T(e.value.token)}async generatePreviewAccessKey(e){let t=await this.meltingSpotApi.call({method:N.POST,endpoint:xt.previewAccessKey,options:{payload:{targetSpotMemberId:e.targetSpotMemberId}}});return t.isErr()?E(t.error):T(t.value)}},Ct=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.spotMemberAuthApiService=St.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}},wt=e=>{let t=e.get(`utm_source`);if(t)return{source:t,medium:e.get(`utm_medium`)??void 0,campaign:e.get(`utm_campaign`)??void 0,term:e.get(`utm_term`)??void 0,content:e.get(`utm_content`)??void 0}},Tt=e=>e?Object.entries(e).reduce((e,[t,n])=>(n!=null&&(e[`utm_${t}`]=n),e),{}):{},Et=Ie.getInstance(),Dt=dt.getInstance(),Ot=Ct.getInstance(),kt={Playbook:ht.getInstance(),Spot:vt.getInstance(),SpotMember:bt.getInstance()},At=globalThis;At.MeltingSpot||={},At.MeltingSpot.Configuration=Et,At.MeltingSpot.Auth=Dt,At.MeltingSpot.Sso=Ot,At.MeltingSpot.Api=kt;var jt=new Oe({appName:`Embed SDK`,appVersion:`1.12.0`}),Mt=class{#e=null;#t=null;constructor(e){this.content=e}set onRemove(e){this.#t=e}inject(e){this.remove();let t=ce({input:e,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add(`ms-embed`),t.appendChild(this.#e)}remove(){this.#e&&=(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),null)}},Nt=class{constructor(e){this.baseURL=Pe(e.baseURL),this.spotId=Ae(e.spotId),this.authToken=e.authToken??null,this.themeMode=e.themeMode??`auto`,this.domain=e.domain??null,this.deeplink=e.deeplink?Me({deeplink:e.deeplink,spotId:this.spotId}):null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){let e=this.authToken&&this.authToken.trim().length>0?`/sso/jwt`:``,t=ue({url:new URL(`/spot/${this.spotId}${e}`,oe(this.baseURL)),searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...Tt(this.utmParameters)},rootDocument:this.rootDocument});return t.classList.add(`ms-spot`),t}},Pt={READY:`meltingspot:ready`,ERROR:`meltingspot:error`,PREFILL_DRAFT:`meltingspot:prefillDraft`},Ft=class e{static{this.embeds=[]}static{this.messageListened=!1}static{this.iframeCallbacks=new Map}static injectSpotInto(t,n){let{onReady:r,onError:i,...a}=n,{spotId:o,rootDocument:s,msCommunityWebBaseUrl:c}=Ie.getConfiguration({spotId:a.spotId,rootDocument:a.rootDocument,msCommunityWebBaseUrl:a.baseURL});if(!o)throw jt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let l=new URLSearchParams(window.location.search),u={spotId:o,authToken:a.authToken??l.get(`ms_token`),domain:a.domain,deeplink:a.deeplink??l.get(`ms_url`),themeMode:a.themeMode,utmParameters:a.utmParameters??wt(l),baseURL:c,rootDocument:s},d=new Mt(new Nt(u));if(d.inject(t),e.embeds.push(d),r||i){let t=d.content.iframe.contentWindow;t&&(e.iframeCallbacks.set(t,{onReady:r,onError:i}),d.onRemove=t=>{e.iframeCallbacks.delete(t)}),e.ensureMessageListener()}return jt.log(`Spot injected`,u,t),d}static clear(){e.embeds.forEach(e=>{e.remove()}),e.embeds=[],e.iframeCallbacks.clear(),e.messageListened&&=(window.removeEventListener(`message`,e.handleMessageEvent),!1),jt.log(`All MeltingSpot embeds cleared`)}static handleMessageEvent(t){if(!t.data||typeof t.data!=`object`||t.data.type!==Pt.READY&&t.data.type!==Pt.ERROR)return;let n=t.source,r=e.iframeCallbacks.get(n);if(!r)return;let{msCommunityWebBaseUrl:i}=Ie.getConfiguration({});if(i)try{let e=new URL(i).origin;if(t.origin!==e)return}catch{}t.data.type===Pt.READY?r.onReady?.():r.onError?.(t.data.error)}static ensureMessageListener(){e.messageListened||=(window.addEventListener(`message`,e.handleMessageEvent),!0)}},It=globalThis;It.MeltingSpot||={},It.MeltingSpot.Embed=Ft,e.EMBED_POST_MESSAGE_TYPE=Pt,e.Embed=Ft,e.EmbedFrame=Mt});
20
+ }`;var g=af(function(){return at(o,m+`return `+f).apply(n,s)});if(g.source=f,ou(g))throw g;return g}function Jd(e){return Q(e).toLowerCase()}function Yd(e){return Q(e).toUpperCase()}function Xd(e,t,r){if(e=Q(e),e&&(r||t===n))return Ln(e);if(!e||!(t=Ca(t)))return e;var i=ar(e),a=ar(t);return Fa(i,Vn(i,a),Hn(i,a)+1).join(``)}function Zd(e,t,r){if(e=Q(e),e&&(r||t===n))return e.slice(0,or(e)+1);if(!e||!(t=Ca(t)))return e;var i=ar(e);return Fa(i,0,Hn(i,ar(t))+1).join(``)}function Qd(e,t,r){if(e=Q(e),e&&(r||t===n))return e.replace(He,``);if(!e||!(t=Ca(t)))return e;var i=ar(e);return Fa(i,Vn(i,ar(t))).join(``)}function $d(e,t){var r=30,i=`...`;if(Y(t)){var a=`separator`in t?t.separator:a;r=`length`in t?Z(t.length):r,i=`omission`in t?Ca(t.omission):i}e=Q(e);var o=e.length;if(Jn(e)){var s=ar(e);o=s.length}if(r>=o)return e;var c=r-ir(i);if(c<1)return i;var l=s?Fa(s,0,c).join(``):e.slice(0,c);if(a===n)return l+i;if(s&&(c+=l.length-c),bu(a)){if(e.slice(c).search(a)){var u,d=l;for(a.global||(a=st(a.source,Q(Xe.exec(a))+`g`)),a.lastIndex=0;u=a.exec(d);)var f=u.index;l=l.slice(0,f===n?c:f)}}else if(e.indexOf(Ca(a),c)!=c){var p=l.lastIndexOf(a);p>-1&&(l=l.slice(0,p))}return l+i}function ef(e){return e=Q(e),e&&Me.test(e)?e.replace(Ae,sr):e}var tf=ro(function(e,t,n){return e+(n?` `:``)+t.toUpperCase()}),nf=no(`toUpperCase`);function rf(e,t,r){return e=Q(e),t=r?n:t,t===n?Yn(e)?ur(e):Cn(e):e.match(t)||[]}var af=G(function(e,t){try{return ln(e,n,t)}catch(e){return ou(e)?e:new it(e)}}),of=Oo(function(e,t){return dn(t,function(t){t=bs(t),oi(e,t,xl(e[t],e))}),e});function sf(e){var t=e==null?0:e.length,n=K();return e=t?V(e,function(e){if(typeof e[1]!=`function`)throw new M(r);return[n(e[0]),e[1]]}):[],G(function(n){for(var r=-1;++r<t;){var i=e[r];if(ln(i[0],this,n))return ln(i[1],this,n)}})}function cf(e){return ui(li(e,1))}function lf(e){return function(){return e}}function uf(e,t){return e==null||e!==e?t:e}var df=so(),ff=so(!0);function pf(e){return e}function mf(e){return Ki(typeof e==`function`?e:li(e,1))}function hf(e){return Zi(li(e,1))}function gf(e,t){return Qi(e,li(t,1))}var _f=G(function(e,t){return function(n){return Pi(n,e,t)}}),vf=G(function(e,t){return function(n){return Pi(e,n,t)}});function yf(e,t,n){var r=$(t),i=wi(t,r);n==null&&!(Y(t)&&(i.length||!r.length))&&(n=t,t=e,e=this,i=wi(t,$(t)));var a=!(Y(n)&&`chain`in n)||!!n.chain,o=cu(e);return dn(i,function(n){var r=t[n];e[n]=r,o&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__);return(n.__actions__=qa(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,_n([this.value()],arguments))})}),e}function bf(){return z._===this&&(z._=_t),this}function xf(){}function Sf(e){return e=Z(e),G(function(t){return ta(t,e)})}var Cf=fo(V),wf=fo(pn),Tf=fo(bn);function Ef(e){return Zo(e)?An(bs(e)):aa(e)}function Df(e){return function(t){return e==null?n:Ti(e,t)}}var Of=ho(),kf=ho(!0);function Af(){return[]}function jf(){return!1}function Mf(){return{}}function Nf(){return``}function Pf(){return!0}function Ff(e,t){if(e=Z(e),e<1||e>g)return[];var n=y,r=R(e,y);t=K(t),e-=y;for(var i=Fn(r,t);++n<e;)t(n);return i}function If(e){return q(e)?V(e,bs):wu(e)?[e]:qa(ys(Q(e)))}function Lf(e){var t=++pt;return Q(e)+t}var Rf=uo(function(e,t){return e+t},0),zf=vo(`ceil`),Bf=uo(function(e,t){return e/t},1),Vf=vo(`floor`);function Hf(e){return e&&e.length?_i(e,pf,Oi):n}function Uf(e,t){return e&&e.length?_i(e,K(t,2),Oi):n}function Wf(e){return kn(e,pf)}function Gf(e,t){return kn(e,K(t,2))}function Kf(e){return e&&e.length?_i(e,pf,Yi):n}function qf(e,t){return e&&e.length?_i(e,K(t,2),Yi):n}var Jf=uo(function(e,t){return e*t},1),Yf=vo(`round`),Xf=uo(function(e,t){return e-t},0);function Zf(e){return e&&e.length?Pn(e,pf):0}function Qf(e,t){return e&&e.length?Pn(e,K(t,2)):0}return H.after=vl,H.ary=yl,H.assign=Lu,H.assignIn=Ru,H.assignInWith=zu,H.assignWith=Bu,H.at=Vu,H.before=bl,H.bind=xl,H.bindAll=of,H.bindKey=Sl,H.castArray=Vl,H.chain=Pc,H.chunk=ws,H.compact=Ts,H.concat=Es,H.cond=sf,H.conforms=cf,H.constant=lf,H.countBy=Gc,H.create=Hu,H.curry=Cl,H.curryRight=wl,H.debounce=Tl,H.defaults=Uu,H.defaultsDeep=Wu,H.defer=El,H.delay=Dl,H.difference=Ds,H.differenceBy=Os,H.differenceWith=ks,H.drop=As,H.dropRight=js,H.dropRightWhile=Ms,H.dropWhile=Ns,H.fill=Ps,H.filter=qc,H.flatMap=Xc,H.flatMapDeep=Zc,H.flatMapDepth=Qc,H.flatten=Ls,H.flattenDeep=Rs,H.flattenDepth=zs,H.flip=Ol,H.flow=df,H.flowRight=ff,H.fromPairs=Bs,H.functions=Zu,H.functionsIn=Qu,H.groupBy=tl,H.initial=Us,H.intersection=Ws,H.intersectionBy=Gs,H.intersectionWith=Ks,H.invert=nd,H.invertBy=rd,H.invokeMap=rl,H.iteratee=mf,H.keyBy=il,H.keys=$,H.keysIn=ad,H.map=al,H.mapKeys=od,H.mapValues=sd,H.matches=hf,H.matchesProperty=gf,H.memoize=kl,H.merge=cd,H.mergeWith=ld,H.method=_f,H.methodOf=vf,H.mixin=yf,H.negate=Al,H.nthArg=Sf,H.omit=ud,H.omitBy=dd,H.once=jl,H.orderBy=ol,H.over=Cf,H.overArgs=Ml,H.overEvery=wf,H.overSome=Tf,H.partial=Nl,H.partialRight=Pl,H.partition=sl,H.pick=fd,H.pickBy=pd,H.property=Ef,H.propertyOf=Df,H.pull=Zs,H.pullAll=Qs,H.pullAllBy=$s,H.pullAllWith=ec,H.pullAt=tc,H.range=Of,H.rangeRight=kf,H.rearg=Fl,H.reject=ul,H.remove=nc,H.rest=Il,H.reverse=rc,H.sampleSize=fl,H.set=hd,H.setWith=gd,H.shuffle=pl,H.slice=ic,H.sortBy=gl,H.sortedUniq=dc,H.sortedUniqBy=fc,H.split=Wd,H.spread=Ll,H.tail=pc,H.take=mc,H.takeRight=hc,H.takeRightWhile=gc,H.takeWhile=_c,H.tap=Fc,H.throttle=Rl,H.thru=Ic,H.toArray=ju,H.toPairs=_d,H.toPairsIn=vd,H.toPath=If,H.toPlainObject=Fu,H.transform=yd,H.unary=zl,H.union=vc,H.unionBy=yc,H.unionWith=bc,H.uniq=xc,H.uniqBy=Sc,H.uniqWith=Cc,H.unset=bd,H.unzip=wc,H.unzipWith=Tc,H.update=xd,H.updateWith=Sd,H.values=Cd,H.valuesIn=wd,H.without=Ec,H.words=rf,H.wrap=Bl,H.xor=Dc,H.xorBy=Oc,H.xorWith=kc,H.zip=Ac,H.zipObject=jc,H.zipObjectDeep=Mc,H.zipWith=Nc,H.entries=_d,H.entriesIn=vd,H.extend=Ru,H.extendWith=zu,yf(H,H),H.add=Rf,H.attempt=af,H.camelCase=Od,H.capitalize=kd,H.ceil=zf,H.clamp=Td,H.clone=Hl,H.cloneDeep=Wl,H.cloneDeepWith=Gl,H.cloneWith=Ul,H.conformsTo=Kl,H.deburr=Ad,H.defaultTo=uf,H.divide=Bf,H.endsWith=jd,H.eq=ql,H.escape=Md,H.escapeRegExp=Nd,H.every=Kc,H.find=Jc,H.findIndex=Fs,H.findKey=Gu,H.findLast=Yc,H.findLastIndex=Is,H.findLastKey=Ku,H.floor=Vf,H.forEach=$c,H.forEachRight=el,H.forIn=qu,H.forInRight=Ju,H.forOwn=Yu,H.forOwnRight=Xu,H.get=$u,H.gt=Jl,H.gte=Yl,H.has=ed,H.hasIn=td,H.head=Vs,H.identity=pf,H.includes=nl,H.indexOf=Hs,H.inRange=Ed,H.invoke=id,H.isArguments=Xl,H.isArray=q,H.isArrayBuffer=Zl,H.isArrayLike=Ql,H.isArrayLikeObject=J,H.isBoolean=$l,H.isBuffer=eu,H.isDate=tu,H.isElement=nu,H.isEmpty=ru,H.isEqual=iu,H.isEqualWith=au,H.isError=ou,H.isFinite=su,H.isFunction=cu,H.isInteger=lu,H.isLength=uu,H.isMap=du,H.isMatch=fu,H.isMatchWith=pu,H.isNaN=mu,H.isNative=hu,H.isNil=_u,H.isNull=gu,H.isNumber=vu,H.isObject=Y,H.isObjectLike=X,H.isPlainObject=yu,H.isRegExp=bu,H.isSafeInteger=xu,H.isSet=Su,H.isString=Cu,H.isSymbol=wu,H.isTypedArray=Tu,H.isUndefined=Eu,H.isWeakMap=Du,H.isWeakSet=Ou,H.join=qs,H.kebabCase=Pd,H.last=Js,H.lastIndexOf=Ys,H.lowerCase=Fd,H.lowerFirst=Id,H.lt=ku,H.lte=Au,H.max=Hf,H.maxBy=Uf,H.mean=Wf,H.meanBy=Gf,H.min=Kf,H.minBy=qf,H.stubArray=Af,H.stubFalse=jf,H.stubObject=Mf,H.stubString=Nf,H.stubTrue=Pf,H.multiply=Jf,H.nth=Xs,H.noConflict=bf,H.noop=xf,H.now=_l,H.pad=Ld,H.padEnd=Rd,H.padStart=zd,H.parseInt=Bd,H.random=Dd,H.reduce=cl,H.reduceRight=ll,H.repeat=Vd,H.replace=Hd,H.result=md,H.round=Yf,H.runInContext=e,H.sample=dl,H.size=ml,H.snakeCase=Ud,H.some=hl,H.sortedIndex=ac,H.sortedIndexBy=oc,H.sortedIndexOf=sc,H.sortedLastIndex=cc,H.sortedLastIndexBy=lc,H.sortedLastIndexOf=uc,H.startCase=Gd,H.startsWith=Kd,H.subtract=Xf,H.sum=Zf,H.sumBy=Qf,H.template=qd,H.times=Ff,H.toFinite=Mu,H.toInteger=Z,H.toLength=Nu,H.toLower=Jd,H.toNumber=Pu,H.toSafeInteger=Iu,H.toString=Q,H.toUpper=Yd,H.trim=Xd,H.trimEnd=Zd,H.trimStart=Qd,H.truncate=$d,H.unescape=ef,H.uniqueId=Lf,H.upperCase=tf,H.upperFirst=nf,H.each=$c,H.eachRight=el,H.first=Vs,yf(H,function(){var e={};return Si(H,function(t,n){P.call(H.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),H.VERSION=`4.17.21`,dn([`bind`,`bindKey`,`curry`,`curryRight`,`partial`,`partialRight`],function(e){H[e].placeholder=H}),dn([`drop`,`take`],function(e,t){U.prototype[e]=function(r){r=r===n?1:F(Z(r),0);var i=this.__filtered__&&!t?new U(this):this.clone();return i.__filtered__?i.__takeCount__=R(r,i.__takeCount__):i.__views__.push({size:R(r,y),type:e+(i.__dir__<0?`Right`:``)}),i},U.prototype[e+`Right`]=function(t){return this.reverse()[e](t).reverse()}}),dn([`filter`,`map`,`takeWhile`],function(e,t){var n=t+1,r=n==1||n==3;U.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:K(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),dn([`head`,`last`],function(e,t){var n=`take`+(t?`Right`:``);U.prototype[e]=function(){return this[n](1).value()[0]}}),dn([`initial`,`tail`],function(e,t){var n=`drop`+(t?``:`Right`);U.prototype[e]=function(){return this.__filtered__?new U(this):this[n](1)}}),U.prototype.compact=function(){return this.filter(pf)},U.prototype.find=function(e){return this.filter(e).head()},U.prototype.findLast=function(e){return this.reverse().find(e)},U.prototype.invokeMap=G(function(e,t){return typeof e==`function`?new U(this):this.map(function(n){return Pi(n,e,t)})}),U.prototype.reject=function(e){return this.filter(Al(K(e)))},U.prototype.slice=function(e,t){e=Z(e);var r=this;return r.__filtered__&&(e>0||t<0)?new U(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(t=Z(t),r=t<0?r.dropRight(-t):r.take(t-e)),r)},U.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},U.prototype.toArray=function(){return this.take(y)},Si(U.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=H[i?`take`+(t==`last`?`Right`:``):t],o=i||/^find/.test(t);a&&(H.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,c=t instanceof U,l=s[0],u=c||q(t),d=function(e){var t=a.apply(H,_n([e],s));return i&&f?t[0]:t};u&&r&&typeof l==`function`&&l.length!=1&&(c=u=!1);var f=this.__chain__,p=!!this.__actions__.length,m=o&&!f,h=c&&!p;if(!o&&u){t=h?t:new U(this);var g=e.apply(t,s);return g.__actions__.push({func:Ic,args:[d],thisArg:n}),new yr(g,f)}return m&&h?e.apply(this,s):(g=this.thru(d),m?i?g.value()[0]:g.value():g)})}),dn([`pop`,`push`,`shift`,`sort`,`splice`,`unshift`],function(e){var t=N[e],n=/^(?:push|sort|unshift)$/.test(e)?`tap`:`thru`,r=/^(?:pop|shift)$/.test(e);H.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(q(i)?i:[],e)}return this[n](function(n){return t.apply(q(n)?n:[],e)})}}),Si(U.prototype,function(e,t){var n=H[t];if(n){var r=n.name+``;P.call(jn,r)||(jn[r]=[]),jn[r].push({name:t,func:n})}}),jn[co(n,s).name]=[{name:`wrapper`,func:n}],U.prototype.clone=br,U.prototype.reverse=xr,U.prototype.value=Sr,H.prototype.at=Lc,H.prototype.chain=Rc,H.prototype.commit=zc,H.prototype.next=Bc,H.prototype.plant=Hc,H.prototype.reverse=Uc,H.prototype.toJSON=H.prototype.valueOf=H.prototype.value=Wc,H.prototype.first=H.prototype.head,Ot&&(H.prototype[Ot]=Vc),H})();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(z._=dr,define(function(){return dr})):$t?(($t.exports=dr)._=dr,Qt._=dr):z._=dr}).call(e)}))(),Object.values(function(e){return e.EditMode=`edit-mode`,e.Preview=`preview`,e}({}));var De=`1.13.0`,Oe=class{constructor(e){this.debug=!1,this.debug=e?.debug??!1,this.appName=e?.appName,this.appVersion=e?.appVersion}log(e,...t){this.debug&&this.print(e,`info`,t)}warn(e,...t){this.print(e,`warn`,t)}error(e,...t){this.print(e,`error`,t)}print(e,t,n){let r=[`[${[`MeltingSpot`,this.appName,this.appVersion].filter(Boolean).join(` - `)}] ${e}`];n.length&&r.push(...n),console[t](...r)}},ke=new Oe({appName:`Core SDK`,appVersion:De}),Ae=e=>e.toLowerCase().replace(/[^a-z0-9-]/g,``),je=[`/user`],Me=({deeplink:e,spotId:t})=>{try{let n=new URL(e,`https://unused.com`),r=n.pathname;return n.search&&(r+=n.search),n.hash&&(r+=n.hash),je.some(e=>r.startsWith(e))||(r=`/spot/${t}/${ie(r)}`),r}catch(e){return ke.warn(`Failed to parse deeplink URL`,e),null}},Ne=[/(^|\.)meltingspot\.io$/i],Pe=e=>{let t;try{let n=oe(e);t=new URL(n)}catch{throw Error(`Invalid baseURL: ${e}`)}let n=t.hostname===`localhost`||t.hostname===`127.0.0.1`,r=t.protocol===`https:`,i=Ne.some(e=>e.test(t.hostname));if(!n&&(!r||!i))throw Error(`Untrusted baseURL origin: ${t.origin}`);return t.origin},Fe={msApiBaseUrl:`https://openapi.meltingspot.io/`,msCommunityWebBaseUrl:`https://go.meltingspot.io/`,ssoToken:void 0,spotId:``,autoJoin:!1,rootDocument:globalThis.document},Ie=class e{constructor(){this.configuration=Fe}static getInstance(){return e.instance||=new e,e.instance}setConfiguration(e){this.configuration={...this.configuration,...e}}static getConfiguration(t={}){return{...e.getInstance().configuration,...t}}},Le=RegExp(`(%[a-f0-9]{2})|([^%]+?)`,`gi`),Re=RegExp(`(%[a-f0-9]{2})+`,`gi`);function ze(e,t){try{return[decodeURIComponent(e.join(``))]}catch{}if(e.length===1)return e;t||=1;let n=e.slice(0,t),r=e.slice(t);return Array.prototype.concat.call([],ze(n),ze(r))}function Be(e){try{return decodeURIComponent(e)}catch{let t=e.match(Le)||[];for(let n=1;n<t.length;n++)e=ze(t,n).join(``),t=e.match(Le)||[];return e}}function Ve(e){let t={"%FE%FF":`��`,"%FF%FE":`��`},n=Re.exec(e);for(;n;){try{t[n[0]]=decodeURIComponent(n[0])}catch{let e=Be(n[0]);e!==n[0]&&(t[n[0]]=e)}n=Re.exec(e)}t[`%C2`]=`�`;let r=Object.keys(t);for(let n of r)e=e.replace(new RegExp(n,`g`),t[n]);return e}function He(e){if(typeof e!=`string`)throw TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return Ve(e)}}function k(e,t){let n={};if(Array.isArray(t))for(let r of t){let t=Object.getOwnPropertyDescriptor(e,r);t?.enumerable&&Object.defineProperty(n,r,t)}else for(let r of Reflect.ownKeys(e)){let i=Object.getOwnPropertyDescriptor(e,r);if(i.enumerable){let a=e[r];t(r,a,e)&&Object.defineProperty(n,r,i)}}return n}function Ue(e,t){if(typeof e!=`string`||typeof t!=`string`)throw TypeError("Expected the arguments to be of type `string`");if(e===``||t===``)return[];let n=e.indexOf(t);return n===-1?[]:[e.slice(0,n),e.slice(n+t.length)]}var We=c({exclude:()=>st,extract:()=>nt,parse:()=>rt,parseUrl:()=>at,pick:()=>j,stringify:()=>it,stringifyUrl:()=>ot}),Ge=e=>e==null,Ke=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),qe=Symbol(`encodeFragmentIdentifier`);function Je(e){switch(e.arrayFormat){case`index`:return t=>(n,r)=>{let i=n.length;return r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[A(t,e),`[`,i,`]`].join(``)]:[...n,[A(t,e),`[`,A(i,e),`]=`,A(r,e)].join(``)]};case`bracket`:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[A(t,e),`[]`].join(``)]:[...n,[A(t,e),`[]=`,A(r,e)].join(``)];case`colon-list-separator`:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,[A(t,e),`:list=`].join(``)]:[...n,[A(t,e),`:list=`,A(r,e)].join(``)];case`comma`:case`separator`:case`bracket-separator`:{let t=e.arrayFormat===`bracket-separator`?`[]=`:`=`;return n=>(r,i)=>i===void 0||e.skipNull&&i===null||e.skipEmptyString&&i===``?r:(i=i===null?``:i,r.length===0?[[A(n,e),t,A(i,e)].join(``)]:[[r,A(i,e)].join(e.arrayFormatSeparator)])}default:return t=>(n,r)=>r===void 0||e.skipNull&&r===null||e.skipEmptyString&&r===``?n:r===null?[...n,A(t,e)]:[...n,[A(t,e),`=`,A(r,e)].join(``)]}}function Ye(e){let t;switch(e.arrayFormat){case`index`:return(e,n,r)=>{if(t=/\[(\d*)]$/.exec(e),e=e.replace(/\[\d*]$/,``),!t){r[e]=n;return}r[e]===void 0&&(r[e]={}),r[e][t[1]]=n};case`bracket`:return(e,n,r)=>{if(t=/(\[])$/.exec(e),e=e.replace(/\[]$/,``),!t){r[e]=n;return}if(r[e]===void 0){r[e]=[n];return}r[e]=[...r[e],n]};case`colon-list-separator`:return(e,n,r)=>{if(t=/(:list)$/.exec(e),e=e.replace(/:list$/,``),!t){r[e]=n;return}if(r[e]===void 0){r[e]=[n];return}r[e]=[...r[e],n]};case`comma`:case`separator`:return(t,n,r)=>{let i=typeof n==`string`&&n.includes(e.arrayFormatSeparator),a=typeof n==`string`&&!i&&Ze(n,e).includes(e.arrayFormatSeparator);n=a?Ze(n,e):n,r[t]=i||a?n.split(e.arrayFormatSeparator).map(t=>Ze(t,e)):n===null?n:Ze(n,e)};case`bracket-separator`:return(t,n,r)=>{let i=/(\[])$/.test(t);if(t=t.replace(/\[]$/,``),!i){r[t]=n&&Ze(n,e);return}let a=n===null?[]:Ze(n,e).split(e.arrayFormatSeparator);if(r[t]===void 0){r[t]=a;return}r[t]=[...r[t],...a]};default:return(e,t,n)=>{if(n[e]===void 0){n[e]=t;return}n[e]=[...[n[e]].flat(),t]}}}function Xe(e){if(typeof e!=`string`||e.length!==1)throw TypeError(`arrayFormatSeparator must be single character string`)}function A(e,t){return t.encode?t.strict?Ke(e):encodeURIComponent(e):e}function Ze(e,t){return t.decode?He(e):e}function Qe(e){return Array.isArray(e)?e.sort():typeof e==`object`?Qe(Object.keys(e)).sort((e,t)=>Number(e)-Number(t)).map(t=>e[t]):e}function $e(e){let t=e.indexOf(`#`);return t!==-1&&(e=e.slice(0,t)),e}function et(e){let t=``,n=e.indexOf(`#`);return n!==-1&&(t=e.slice(n)),t}function tt(e,t,n){return n===`string`&&typeof e==`string`?e:typeof n==`function`&&typeof e==`string`?n(e):n===`boolean`&&e===null?!0:n===`boolean`&&e!==null&&(e.toLowerCase()===`true`||e.toLowerCase()===`false`)?e.toLowerCase()===`true`:n===`boolean`&&e!==null&&(e.toLowerCase()===`1`||e.toLowerCase()===`0`)?e.toLowerCase()===`1`:n===`string[]`&&t.arrayFormat!==`none`&&typeof e==`string`?[e]:n===`number[]`&&t.arrayFormat!==`none`&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?[Number(e)]:n===`number`&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?Number(e):t.parseBooleans&&e!==null&&(e.toLowerCase()===`true`||e.toLowerCase()===`false`)?e.toLowerCase()===`true`:t.parseNumbers&&!Number.isNaN(Number(e))&&typeof e==`string`&&e.trim()!==``?Number(e):e}function nt(e){e=$e(e);let t=e.indexOf(`?`);return t===-1?``:e.slice(t+1)}function rt(e,t){t={decode:!0,sort:!0,arrayFormat:`none`,arrayFormatSeparator:`,`,parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...t},Xe(t.arrayFormatSeparator);let n=Ye(t),r=Object.create(null);if(typeof e!=`string`||(e=e.trim().replace(/^[?#&]/,``),!e))return r;for(let i of e.split(`&`)){if(i===``)continue;let e=t.decode?i.replaceAll(`+`,` `):i,[a,o]=Ue(e,`=`);a===void 0&&(a=e),o=o===void 0?null:[`comma`,`separator`,`bracket-separator`].includes(t.arrayFormat)?o:Ze(o,t),n(Ze(a,t),o,r)}for(let[e,n]of Object.entries(r))if(typeof n==`object`&&n&&t.types[e]!==`string`)for(let[r,i]of Object.entries(n)){let a=t.types[e]?t.types[e].replace(`[]`,``):void 0;n[r]=tt(i,t,a)}else r[e]=typeof n==`object`&&n&&t.types[e]===`string`?Object.values(n).join(t.arrayFormatSeparator):tt(n,t,t.types[e]);return t.sort===!1?r:(t.sort===!0?Object.keys(r).sort():Object.keys(r).sort(t.sort)).reduce((e,t)=>{let n=r[t];return e[t]=n&&typeof n==`object`&&!Array.isArray(n)?Qe(n):n,e},Object.create(null))}function it(e,t){if(!e)return``;t={encode:!0,strict:!0,arrayFormat:`none`,arrayFormatSeparator:`,`,...t},Xe(t.arrayFormatSeparator);let n=n=>t.skipNull&&Ge(e[n])||t.skipEmptyString&&e[n]===``,r=Je(t),i={};for(let[t,r]of Object.entries(e))n(t)||(i[t]=r);let a=Object.keys(i);return t.sort!==!1&&a.sort(t.sort),a.map(n=>{let i=e[n];return i===void 0?``:i===null?A(n,t):Array.isArray(i)?i.length===0&&t.arrayFormat===`bracket-separator`?A(n,t)+`[]`:i.reduce(r(n),[]).join(`&`):A(n,t)+`=`+A(i,t)}).filter(e=>e.length>0).join(`&`)}function at(e,t){t={decode:!0,...t};let[n,r]=Ue(e,`#`);return n===void 0&&(n=e),{url:n?.split(`?`)?.[0]??``,query:rt(nt(e),t),...t&&t.parseFragmentIdentifier&&r?{fragmentIdentifier:Ze(r,t)}:{}}}function ot(e,t){t={encode:!0,strict:!0,[qe]:!0,...t};let n=$e(e.url).split(`?`)[0]||``,r=it({...rt(nt(e.url),{sort:!1,...t}),...e.query},t);r&&=`?${r}`;let i=et(e.url);if(typeof e.fragmentIdentifier==`string`){let r=new URL(n);r.hash=e.fragmentIdentifier,i=t[qe]?r.hash:`#${e.fragmentIdentifier}`}return`${n}${r}${i}`}function j(e,t,n){n={parseFragmentIdentifier:!0,[qe]:!1,...n};let{url:r,query:i,fragmentIdentifier:a}=at(e,n);return ot({url:r,query:k(i,t),fragmentIdentifier:a},n)}function st(e,t,n){return j(e,Array.isArray(t)?e=>!t.includes(e):(e,n)=>!t(e,n),n)}var ct=We,M=class e extends Error{constructor(t,n){super(`HTTP Error ${t}${n?`: ${n}`:``}`),this.code=t,this.name=`HttpError`,Object.setPrototypeOf(this,e.prototype)}},N=function(e){return e.DELETE=`DELETE`,e.GET=`GET`,e.PATCH=`PATCH`,e.POST=`POST`,e}({}),lt=class e{constructor(){this.headers={}}setHeaders(e){this.headers=e}async get(t){try{let n=t.query?`${t.url}?${this.serializeQuery(t.query)}`:t.url,r=await fetch(n,{headers:{...this.headers,...t.headers,"Content-Type":`application/json`},...t.signal?{signal:t.signal}:{}});return r.ok?T(await e.parseBody(r)):E(new M(r.status,await r.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}async post(t){try{let n=await fetch(t.url,{method:`POST`,headers:{...this.headers,...t.headers,"Content-Type":`application/json`},body:JSON.stringify(t.payload),...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new M(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}async delete(t){try{let n=await fetch(t.url,{method:`DELETE`,headers:{...this.headers,...t.headers,Accept:`application/json`},...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new M(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}async patch(t){try{let n=await fetch(t.url,{method:`PATCH`,headers:{...this.headers,...t.headers,"Content-Type":`application/json`},body:JSON.stringify(t.payload),...t.signal?{signal:t.signal}:{}});return n.ok?T(await e.parseBody(n)):E(new M(n.status,await n.text()))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(new M(D.INTERNAL_SERVER_ERROR,t))}}static async parseBody(e){if(e.status!==D.NO_CONTENT)return await e.json()}serializeQuery(e){if(typeof e==`string`)return e;if(typeof e==`object`)for(let t in e)e[t]===void 0&&delete e[t];return e=ct.stringify(e,{arrayFormat:`none`}),e}},ut={accessToken:{email:`/v1/auth/accessToken/email`,sso:{jwt:`/v1/auth/accessToken/sso/jwt`}},refreshAccessToken:`/v1/auth/accessToken~refresh`,password:{reset:`/v1/auth/password~reset`}},dt=class e extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return e.instance||=new e,e.instance}async loginWithPassword(e,t){let n=await this.callApi({endpoint:ut.accessToken.email,method:`POST`,body:{email:e,password:t},withSpotId:!0});if(n.isErr())return E(n.error);let{accessToken:r,refreshToken:i}=n.value;return this.setTokens(r.token,i.token),T({accessToken:r.token,refreshToken:i.token})}async loginWithSsoToken(e){let t=await this.callApi({endpoint:ut.accessToken.sso.jwt,method:`POST`,body:{token:e},withSpotId:!0});if(t.isErr())return E(t.error);let{accessToken:n,refreshToken:r}=t.value;return this.setTokens(n.token,r.token),T({accessToken:n.token,refreshToken:r.token})}loginWithAuthTokens(e,t){return this.setTokens(e,t),{accessToken:e,refreshToken:t}}resetPassword(e){return this.callApi({endpoint:ut.password.reset,method:`POST`,body:{email:e}})}async refresh(){let e=await this.callApi({endpoint:ut.refreshAccessToken,method:`POST`,body:{refreshToken:this.refreshToken}});if(e.isErr())return E(e.error);let{accessToken:t,refreshToken:n}=e.value;return this.setTokens(t.token,n.token),T({accessToken:t.token,refreshToken:n.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(e,t){if(this.accessToken!==e||this.refreshToken!==t){this.accessToken=e,this.refreshToken=t;let n=new CustomEvent(`auth:tokens-updated`,{detail:{accessToken:e,refreshToken:t}});this.dispatchEvent(n)}}async callApi(e){try{let{spotId:t,msApiBaseUrl:n}=Ie.getConfiguration(),r=se(e.endpoint,n),i={"Content-Type":`application/json`,...e.headers};e.withSpotId&&t&&(i[ft.SpotId]=t);let a=await fetch(r,{method:e.method,body:e.body?JSON.stringify(e.body):void 0,headers:i});return a.ok?a.status===D.NO_CONTENT?T(void 0):T(await a.json()):E(new M(a.status,a.statusText))}catch(e){return E(new M(D.INTERNAL_SERVER_ERROR,e instanceof Error?e.message:String(e)))}}},ft=function(e){return e.Authorization=`Authorization`,e.SpotId=`x-spotid`,e}({}),P=class e{static getInstance(){return e.instance||=new e,e.instance}static buildAuthenticatedRequest(e){let{msApiBaseUrl:t,spotId:n}=Ie.getConfiguration(),r=se(e,t),i=dt.getInstance().getAccessToken();if(!i)return E(Error(`Not authenticated`));let a={"Content-Type":`application/json`,Authorization:`Bearer ${i}`};return n&&(a[`x-spotid`]=n),T({url:r,headers:a})}static async stream(t,n,r){let{streamTransport:i}=Ie.getConfiguration();if(i)return i({endpoint:t,body:n,signal:r});let a=e.buildAuthenticatedRequest(t);if(a.isErr())return E(a.error);let{url:o,headers:s}=a.value;try{let e=await fetch(o,{method:`POST`,headers:s,...n===void 0?{}:{body:JSON.stringify(n)},...r?{signal:r}:{}});if(!e.ok){let t=await e.text();return E(Error(`HTTP ${e.status}: ${t}`))}return e.body?T(e.body):E(Error(`Response body is empty`))}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return E(e instanceof Error?e:Error(t))}}get pendingCount(){return this.queue.length}constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=dt.getInstance(),this.httpService=new lt}enqueue(e){return new Promise(t=>{this.queue.push(async()=>{try{t(await e())}catch(e){t(E(new M(D.INTERNAL_SERVER_ERROR,e instanceof Error?e.message:`Unknown error`)))}}),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){let e=this.queue.shift();if(!e)break;await e()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){let e=this.isPaused;this.isPaused=!1,e&&this.processQueue()}async call(e){return this.enqueue(async()=>{let t=async()=>{let{spotId:t,msApiBaseUrl:n}=Ie.getConfiguration(),r={...e.options?.headers??{}};t&&(r[`x-spotid`]=t);let i=this.authService.getAccessToken(),{requiresAuth:a=!0}=e;if(!i&&a)return E(new M(D.UNAUTHORIZED));i&&(r.Authorization=`Bearer ${i}`);let o=se(e.endpoint,n);switch(e.method){case N.DELETE:return this.httpService.delete({...e.options??{},headers:r,url:o});case N.GET:return this.httpService.get({...e.options??{},headers:r,url:o});case N.PATCH:return this.httpService.patch({...e.options??{},headers:r,url:o});case N.POST:return this.httpService.post({...e.options??{},headers:r,url:o});default:return E(new M(D.METHOD_NOT_ALLOWED,`Method not allowed`))}},n=await t();if(n.isErr()&&n.error.code===D.UNAUTHORIZED){let e=await this.authService.refresh();if(e.isErr())return E(new M(D.UNAUTHORIZED,e.error.message));n=await t()}return n})}},pt={playbooks:`/v1/playbooks`,pages:e=>`/v1/playbooks/${e}/pages`,hotspots:(e,t)=>`/v1/playbooks/${e}/pages/${t}/hotspots`,hotspot:(e,t,n)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}`,accessibleIntents:(e,t)=>`/v1/playbooks/${e}/pages/${t}/accessibleIntents`,intents:(e,t,n)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}/intents`,intent:(e,t,n,r)=>`/v1/playbooks/${e}/pages/${t}/hotspots/${n}/intents/${r}`},mt=50,ht=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async listPlaybooks(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.playbooks,options:{query:{page:e?.page??1,limit:e?.limit??mt,...e?.domain?{"domain[eq]":e.domain}:{},...e?.host===void 0?{}:{"domain[matchesHost]":e.host}}}});return t.isErr()?E(t.error):T(t.value)}async listPlaybookPages(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.pages(e.playbookId),options:{query:{page:e.page??1,limit:e.limit??mt,...e.url?{"url[eq]":e.url}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookPage(e,t){let n=await this.meltingSpotApi.call({method:N.POST,endpoint:pt.pages(e.playbookId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async listAccessiblePlaybookIntents(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.accessibleIntents(e.playbookId,e.pageId),options:{query:{...e.domain?{domain:e.domain}:{}}}});return t.isErr()?E(t.error):T(t.value)}async listPlaybookHotspots(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.hotspots(e.playbookId,e.pageId),options:{query:{page:e.page??1,limit:e.limit??mt,...e.intentStatus?{"intentStatus[eq]":e.intentStatus}:{},...e.widgetType?{"widgetType[eq]":e.widgetType}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookHotspot(e,t){let n=await this.meltingSpotApi.call({method:N.POST,endpoint:pt.hotspots(e.playbookId,e.pageId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async updatePlaybookHotspot(e,t){let n=await this.meltingSpotApi.call({method:N.PATCH,endpoint:pt.hotspot(e.playbookId,e.pageId,e.hotspotId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async listPlaybookIntents(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:pt.intents(e.playbookId,e.pageId,e.hotspotId),options:{query:{page:e.page??1,limit:e.limit??mt,...e.status?{"status[eq]":e.status}:{}}}});return t.isErr()?E(t.error):T(t.value)}async createPlaybookIntent(e,t){let n=await this.meltingSpotApi.call({method:N.POST,endpoint:pt.intents(e.playbookId,e.pageId,e.hotspotId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}async updatePlaybookIntent(e,t){let n=await this.meltingSpotApi.call({method:N.PATCH,endpoint:pt.intent(e.playbookId,e.pageId,e.hotspotId,e.intentId),options:{payload:t}});return n.isErr()?E(n.error):T(n.value)}},gt={me:`/v1/spots/me`},_t=50,vt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async listSpotsForMe(e){let t=await this.meltingSpotApi.call({method:N.GET,endpoint:gt.me,options:{query:{page:1,limit:_t,...e?.spotMemberRole?{"spotMemberRole[eq]":e.spotMemberRole}:{}}}});return t.isErr()?E(t.error):T(t.value)}},yt={spotMember:{me:`/v1/spotMembers/me`,joinFromSso:`/v1/spotMembers~joinFromSso`,search:`/v1/spotMembers~search`}},bt=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async getSpotMemberForMe(){let e=await this.meltingSpotApi.call({method:N.GET,endpoint:yt.spotMember.me});return e.isErr()?E(e.error):T(e.value)}async searchSpotMembers(e){let t={page:e.page,limit:e.limit};e.search&&(t.search=e.search);let n=await this.meltingSpotApi.call({method:N.GET,endpoint:yt.spotMember.search,options:{query:t}});return n.isErr()?E(n.error):T(n.value)}async joinFromSso(e){let t=await this.meltingSpotApi.call({method:N.POST,endpoint:yt.spotMember.joinFromSso,options:{payload:{token:e}}});return t.isErr()?E(t.error):T(t.value)}},xt={spotMemberSsoToken:`/v1/spotMembers/auth/sso/jwt`,previewAccessKey:`/v1/spotMembers/auth/preview/accessKey`},St=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.meltingSpotApi=P.getInstance()}async generateSsoToken(){let e=await this.meltingSpotApi.call({method:N.POST,endpoint:xt.spotMemberSsoToken,options:{payload:{}}});return e.isErr()?E(e.error):T(e.value.token)}async generatePreviewAccessKey(e){let t=await this.meltingSpotApi.call({method:N.POST,endpoint:xt.previewAccessKey,options:{payload:{targetSpotMemberId:e.targetSpotMemberId}}});return t.isErr()?E(t.error):T(t.value)}},Ct=class e{static getInstance(){return e.instance||=new e,e.instance}constructor(){this.spotMemberAuthApiService=St.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}},wt=e=>{let t=e.get(`utm_source`);if(t)return{source:t,medium:e.get(`utm_medium`)??void 0,campaign:e.get(`utm_campaign`)??void 0,term:e.get(`utm_term`)??void 0,content:e.get(`utm_content`)??void 0}},Tt=e=>e?Object.entries(e).reduce((e,[t,n])=>(n!=null&&(e[`utm_${t}`]=n),e),{}):{},Et=Ie.getInstance(),Dt=dt.getInstance(),Ot=Ct.getInstance(),kt={Playbook:ht.getInstance(),Spot:vt.getInstance(),SpotMember:bt.getInstance()},At=globalThis;At.MeltingSpot||={},At.MeltingSpot.Configuration=Et,At.MeltingSpot.Auth=Dt,At.MeltingSpot.Sso=Ot,At.MeltingSpot.Api=kt;var jt=new Oe({appName:`Embed SDK`,appVersion:`1.13.0`}),Mt=class{#e=null;#t=null;constructor(e){this.content=e}set onRemove(e){this.#t=e}inject(e){this.remove();let t=ce({input:e,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add(`ms-embed`),t.appendChild(this.#e)}remove(){this.#e&&=(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),null)}},Nt=class{constructor(e){this.baseURL=Pe(e.baseURL),this.spotId=Ae(e.spotId),this.authToken=e.authToken??null,this.themeMode=e.themeMode??`auto`,this.domain=e.domain??null,this.deeplink=e.deeplink?Me({deeplink:e.deeplink,spotId:this.spotId}):null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){let e=this.authToken&&this.authToken.trim().length>0?`/sso/jwt`:``,t=ue({url:new URL(`/spot/${this.spotId}${e}`,oe(this.baseURL)),searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...Tt(this.utmParameters)},rootDocument:this.rootDocument});return t.classList.add(`ms-spot`),t}},Pt={READY:`meltingspot:ready`,ERROR:`meltingspot:error`,PREFILL_DRAFT:`meltingspot:prefillDraft`},Ft=class e{static{this.embeds=[]}static{this.messageListened=!1}static{this.iframeCallbacks=new Map}static injectSpotInto(t,n){let{onReady:r,onError:i,...a}=n,{spotId:o,rootDocument:s,msCommunityWebBaseUrl:c}=Ie.getConfiguration({spotId:a.spotId,rootDocument:a.rootDocument,msCommunityWebBaseUrl:a.baseURL});if(!o)throw jt.error(`Spot ID is required`),Error(`Spot ID is not configured. Please set the spotId in the configuration.`);let l=new URLSearchParams(window.location.search),u={spotId:o,authToken:a.authToken??l.get(`ms_token`),domain:a.domain,deeplink:a.deeplink??l.get(`ms_url`),themeMode:a.themeMode,utmParameters:a.utmParameters??wt(l),baseURL:c,rootDocument:s},d=new Mt(new Nt(u));if(d.inject(t),e.embeds.push(d),r||i){let t=d.content.iframe.contentWindow;t&&(e.iframeCallbacks.set(t,{onReady:r,onError:i}),d.onRemove=t=>{e.iframeCallbacks.delete(t)}),e.ensureMessageListener()}return jt.log(`Spot injected`,u,t),d}static clear(){e.embeds.forEach(e=>{e.remove()}),e.embeds=[],e.iframeCallbacks.clear(),e.messageListened&&=(window.removeEventListener(`message`,e.handleMessageEvent),!1),jt.log(`All MeltingSpot embeds cleared`)}static handleMessageEvent(t){if(!t.data||typeof t.data!=`object`||t.data.type!==Pt.READY&&t.data.type!==Pt.ERROR)return;let n=t.source,r=e.iframeCallbacks.get(n);if(!r)return;let{msCommunityWebBaseUrl:i}=Ie.getConfiguration({});if(i)try{let e=new URL(i).origin;if(t.origin!==e)return}catch{}t.data.type===Pt.READY?r.onReady?.():r.onError?.(t.data.error)}static ensureMessageListener(){e.messageListened||=(window.addEventListener(`message`,e.handleMessageEvent),!0)}},It=globalThis;It.MeltingSpot||={},It.MeltingSpot.Embed=Ft,e.EMBED_POST_MESSAGE_TYPE=Pt,e.Embed=Ft,e.EmbedFrame=Mt});
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "MeltingSpot Embed SDK",
4
4
  "homepage": "https://meltingspot.io",
5
5
  "license": "BSD-3-Clause",
6
- "version": "1.12.0",
6
+ "version": "1.13.0",
7
7
  "main": "./index.cjs",
8
8
  "module": "./index.mjs",
9
9
  "typings": "./index.d.ts",
@@ -17,7 +17,7 @@
17
17
  }
18
18
  },
19
19
  "dependencies": {
20
- "@meltingspot/core": "1.12.0"
20
+ "@meltingspot/core": "1.13.0"
21
21
  },
22
22
  "publishConfig": {
23
23
  "provenance": false