@meltingspot/embed 1.4.0 → 1.5.1

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,22 @@ Date: YYYY-MM-DD
15
15
 
16
16
  -->
17
17
 
18
+ ## v1.5.1
19
+
20
+ Date: 2026-07-23
21
+
22
+ ### Patch Changes
23
+
24
+ - Bump `@meltingspot/core` to `1.5.1`.
25
+
26
+ ## v1.5.0
27
+
28
+ Date: 2026-07-20
29
+
30
+ ### Minor Changes
31
+
32
+ - Bump `@meltingspot/core` to `1.5.0`.
33
+
18
34
  ## v1.4.0
19
35
 
20
36
  Date: 2026-07-17
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@meltingspot/core"),L="1.4.0",l=new s.Logger({appName:"Embed SDK",appVersion:L});class g{constructor(e){this.content=e}#e=null;#t=null;set onRemove(e){this.#t=e}inject(e){this.remove();const i=s.getHTMLElement({input:e,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add("ms-embed"),i.appendChild(this.#e)}remove(){this.#e&&(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),this.#e=null)}}class D{constructor(e){this.baseURL=s.formatBaseUrl(e.baseURL),this.spotId=s.formatUUID(e.spotId),this.authToken=e.authToken??null,this.themeMode=e.themeMode??"auto",this.domain=e.domain??null,this.deeplink=e.deeplink?s.formatDeeplink({deeplink:e.deeplink,spotId:this.spotId}):null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){const e=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",i=new URL(`/spot/${this.spotId}${e}`,s.trimSlashRight(this.baseURL)),n=s.createIframe({url:i,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...s.flattenUtmParameters(this.utmParameters)},rootDocument:this.rootDocument});return n.classList.add("ms-spot"),n}}const m={READY:"meltingspot:ready",ERROR:"meltingspot:error",PREFILL_DRAFT:"meltingspot:prefillDraft"},t=class t{static injectSpotInto(e,i){const{onReady:n,onError:a,...o}=i,{spotId:u,rootDocument:E,msCommunityWebBaseUrl:k}=s.ConfigurationService.getConfiguration({spotId:o.spotId,rootDocument:o.rootDocument,msCommunityWebBaseUrl:o.baseURL});if(!u)throw l.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const d=new URLSearchParams(window.location.search),p={spotId:u,authToken:o.authToken??d.get("ms_token"),domain:o.domain,deeplink:o.deeplink??d.get("ms_url"),themeMode:o.themeMode,utmParameters:o.utmParameters??s.parseUtmParameters(d),baseURL:k,rootDocument:E},r=new g(new D(p));if(r.inject(e),t.embeds.push(r),n||a){const f=r.content.iframe.contentWindow;f&&(t.iframeCallbacks.set(f,{onReady:n,onError:a}),r.onRemove=R=>{t.iframeCallbacks.delete(R)}),t.ensureMessageListener()}return l.log("Spot injected",p,e),r}static clear(){t.embeds.forEach(e=>{e.remove()}),t.embeds=[],t.iframeCallbacks.clear(),t.messageListened&&(window.removeEventListener("message",t.handleMessageEvent),t.messageListened=!1),l.log("All MeltingSpot embeds cleared")}static handleMessageEvent(e){if(!e.data||typeof e.data!="object"||e.data.type!==m.READY&&e.data.type!==m.ERROR)return;const i=e.source,n=t.iframeCallbacks.get(i);if(!n)return;const{msCommunityWebBaseUrl:a}=s.ConfigurationService.getConfiguration({});if(a)try{const o=new URL(a).origin;if(e.origin!==o)return}catch{}e.data.type===m.READY?n.onReady?.():n.onError?.(e.data.error)}static ensureMessageListener(){t.messageListened||(window.addEventListener("message",t.handleMessageEvent),t.messageListened=!0)}};t.embeds=[],t.messageListened=!1,t.iframeCallbacks=new Map;let c=t;const h=globalThis;h.MeltingSpot||(h.MeltingSpot={});h.MeltingSpot.Embed=c;exports.EMBED_POST_MESSAGE_TYPE=m;exports.Embed=c;exports.EmbedFrame=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@meltingspot/core"),L="1.5.1",l=new s.Logger({appName:"Embed SDK",appVersion:L});class g{constructor(e){this.content=e}#e=null;#t=null;set onRemove(e){this.#t=e}inject(e){this.remove();const i=s.getHTMLElement({input:e,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add("ms-embed"),i.appendChild(this.#e)}remove(){this.#e&&(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),this.#e=null)}}class D{constructor(e){this.baseURL=s.formatBaseUrl(e.baseURL),this.spotId=s.formatUUID(e.spotId),this.authToken=e.authToken??null,this.themeMode=e.themeMode??"auto",this.domain=e.domain??null,this.deeplink=e.deeplink?s.formatDeeplink({deeplink:e.deeplink,spotId:this.spotId}):null,this.utmParameters=e.utmParameters??null,this.rootDocument=e.rootDocument}get iframe(){const e=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",i=new URL(`/spot/${this.spotId}${e}`,s.trimSlashRight(this.baseURL)),n=s.createIframe({url:i,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...s.flattenUtmParameters(this.utmParameters)},rootDocument:this.rootDocument});return n.classList.add("ms-spot"),n}}const m={READY:"meltingspot:ready",ERROR:"meltingspot:error",PREFILL_DRAFT:"meltingspot:prefillDraft"},t=class t{static injectSpotInto(e,i){const{onReady:n,onError:a,...o}=i,{spotId:u,rootDocument:E,msCommunityWebBaseUrl:k}=s.ConfigurationService.getConfiguration({spotId:o.spotId,rootDocument:o.rootDocument,msCommunityWebBaseUrl:o.baseURL});if(!u)throw l.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const d=new URLSearchParams(window.location.search),p={spotId:u,authToken:o.authToken??d.get("ms_token"),domain:o.domain,deeplink:o.deeplink??d.get("ms_url"),themeMode:o.themeMode,utmParameters:o.utmParameters??s.parseUtmParameters(d),baseURL:k,rootDocument:E},r=new g(new D(p));if(r.inject(e),t.embeds.push(r),n||a){const f=r.content.iframe.contentWindow;f&&(t.iframeCallbacks.set(f,{onReady:n,onError:a}),r.onRemove=R=>{t.iframeCallbacks.delete(R)}),t.ensureMessageListener()}return l.log("Spot injected",p,e),r}static clear(){t.embeds.forEach(e=>{e.remove()}),t.embeds=[],t.iframeCallbacks.clear(),t.messageListened&&(window.removeEventListener("message",t.handleMessageEvent),t.messageListened=!1),l.log("All MeltingSpot embeds cleared")}static handleMessageEvent(e){if(!e.data||typeof e.data!="object"||e.data.type!==m.READY&&e.data.type!==m.ERROR)return;const i=e.source,n=t.iframeCallbacks.get(i);if(!n)return;const{msCommunityWebBaseUrl:a}=s.ConfigurationService.getConfiguration({});if(a)try{const o=new URL(a).origin;if(e.origin!==o)return}catch{}e.data.type===m.READY?n.onReady?.():n.onError?.(e.data.error)}static ensureMessageListener(){t.messageListened||(window.addEventListener("message",t.handleMessageEvent),t.messageListened=!0)}};t.embeds=[],t.messageListened=!1,t.iframeCallbacks=new Map;let c=t;const h=globalThis;h.MeltingSpot||(h.MeltingSpot={});h.MeltingSpot.Embed=c;exports.EMBED_POST_MESSAGE_TYPE=m;exports.Embed=c;exports.EmbedFrame=g;
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Logger as L, getHTMLElement as E, formatBaseUrl as w, formatUUID as D, formatDeeplink as I, trimSlashRight as U, createIframe as M, flattenUtmParameters as P, ConfigurationService as f, parseUtmParameters as S } from "@meltingspot/core";
2
- const C = "1.4.0", m = new L({ appName: "Embed SDK", appVersion: C });
2
+ const C = "1.5.1", m = new L({ appName: "Embed SDK", appVersion: C });
3
3
  class T {
4
4
  constructor(e) {
5
5
  this.content = e;
@@ -17,4 +17,4 @@ __p += '`),tn&&(y+=`' +
17
17
  function print() { __p += __j.call(arguments, '') }
18
18
  `:`;
19
19
  `)+y+`return __p
20
- }`;var Z=Za(function(){return un(f,D+"return "+y).apply(r,l)});if(Z.source=y,Lu(Z))throw Z;return Z}function lm(n){return an(n).toLowerCase()}function hm(n){return an(n).toUpperCase()}function dm(n,e,t){if(n=an(n),n&&(t||e===r))return is(n);if(!n||!(e=ee(e)))return n;var i=ve(n),s=ve(e),f=us(i,s),l=os(i,s)+1;return Ze(i,f,l).join("")}function pm(n,e,t){if(n=an(n),n&&(t||e===r))return n.slice(0,as(n)+1);if(!n||!(e=ee(e)))return n;var i=ve(n),s=os(i,ve(e))+1;return Ze(i,0,s).join("")}function _m(n,e,t){if(n=an(n),n&&(t||e===r))return n.replace(Li,"");if(!n||!(e=ee(e)))return n;var i=ve(n),s=us(i,ve(e));return Ze(i,s).join("")}function gm(n,e){var t=cn,i=rn;if(En(e)){var s="separator"in e?e.separator:s;t="length"in e?K(e.length):t,i="omission"in e?ee(e.omission):i}n=an(n);var f=n.length;if(Tt(n)){var l=ve(n);f=l.length}if(t>=f)return n;var h=t-yt(i);if(h<1)return i;var g=l?Ze(l,0,h).join(""):n.slice(0,h);if(s===r)return g+i;if(l&&(h+=g.length-h),bu(s)){if(n.slice(h).search(s)){var w,T=g;for(s.global||(s=qi(s.source,an(Ro.exec(s))+"g")),s.lastIndex=0;w=s.exec(T);)var y=w.index;g=g.slice(0,y===r?h:y)}}else if(n.indexOf(ee(s),h)!=h){var R=g.lastIndexOf(s);R>-1&&(g=g.slice(0,R))}return g+i}function mm(n){return n=an(n),n&&xc.test(n)?n.replace(Ao,ql):n}var vm=Lt(function(n,e,t){return n+(t?" ":"")+e.toUpperCase()}),Nu=Js("toUpperCase");function Ka(n,e,t){return n=an(n),e=t?r:e,e===r?kl(n)?Zl(n):Dl(n):n.match(e)||[]}var Za=J(function(n,e){try{return jn(n,r,e)}catch(t){return Lu(t)?t:new W(t)}}),Em=Ue(function(n,e){return se(e,function(t){t=Me(t),Ne(n,t,Mu(n[t],n))}),n});function wm(n){var e=n==null?0:n.length,t=U();return n=e?_n(n,function(i){if(typeof i[1]!="function")throw new ae(p);return[t(i[0]),i[1]]}):[],J(function(i){for(var s=-1;++s<e;){var f=n[s];if(jn(f[0],this,i))return jn(f[1],this,i)}})}function Tm(n){return qh(ce(n,N))}function $u(n){return function(){return n}}function ym(n,e){return n==null||n!==n?e:n}var Am=Vs(),Im=Vs(!0);function Kn(n){return n}function Uu(n){return xs(typeof n=="function"?n:ce(n,N))}function Om(n){return bs(ce(n,N))}function Rm(n,e){return Ss(n,ce(e,N))}var Mm=J(function(n,e){return function(t){return Zt(t,n,e)}}),xm=J(function(n,e){return function(t){return Zt(n,t,e)}});function Pu(n,e,t){var i=Nn(e),s=zr(e,i);t==null&&!(En(e)&&(s.length||!i.length))&&(t=e,e=n,n=this,s=zr(e,Nn(e)));var f=!(En(t)&&"chain"in t)||!!t.chain,l=Fe(n);return se(s,function(h){var g=e[h];n[h]=g,l&&(n.prototype[h]=function(){var w=this.__chain__;if(f||w){var T=n(this.__wrapped__),y=T.__actions__=zn(this.__actions__);return y.push({func:g,args:arguments,thisArg:n}),T.__chain__=w,T}return g.apply(n,Be([this.value()],arguments))})}),n}function Lm(){return Pn._===this&&(Pn._=eh),this}function Fu(){}function bm(n){return n=K(n),J(function(e){return Ds(e,n)})}var Sm=pu(_n),Dm=pu(jo),Nm=pu(Ci);function Ja(n){return Tu(n)?Hi(Me(n)):fd(n)}function $m(n){return function(e){return n==null?r:st(n,e)}}var Um=na(),Pm=na(!0);function Yu(){return[]}function Cu(){return!1}function Fm(){return{}}function Ym(){return""}function Cm(){return!0}function Hm(n,e){if(n=K(n),n<1||n>O)return[];var t=X,i=Cn(n,X);e=U(e),n-=X;for(var s=Bi(i,e);++t<n;)e(t);return s}function km(n){return G(n)?_n(n,Me):te(n)?[n]:zn(ga(an(n)))}function Wm(n){var e=++jl;return an(n)+e}var Bm=Xr(function(n,e){return n+e},0),Gm=_u("ceil"),zm=Xr(function(n,e){return n/e},1),qm=_u("floor");function Qm(n){return n&&n.length?Gr(n,Kn,nu):r}function Km(n,e){return n&&n.length?Gr(n,U(e,2),nu):r}function Zm(n){return ts(n,Kn)}function Jm(n,e){return ts(n,U(e,2))}function Xm(n){return n&&n.length?Gr(n,Kn,iu):r}function Vm(n,e){return n&&n.length?Gr(n,U(e,2),iu):r}var jm=Xr(function(n,e){return n*e},1),n0=_u("round"),e0=Xr(function(n,e){return n-e},0);function t0(n){return n&&n.length?Wi(n,Kn):0}function r0(n,e){return n&&n.length?Wi(n,U(e,2)):0}return a.after=O_,a.ary=Ma,a.assign=hg,a.assignIn=ka,a.assignInWith=ci,a.assignWith=dg,a.at=pg,a.before=xa,a.bind=Mu,a.bindAll=Em,a.bindKey=La,a.castArray=F_,a.chain=Ia,a.chunk=qd,a.compact=Qd,a.concat=Kd,a.cond=wm,a.conforms=Tm,a.constant=$u,a.countBy=t_,a.create=_g,a.curry=ba,a.curryRight=Sa,a.debounce=Da,a.defaults=gg,a.defaultsDeep=mg,a.defer=R_,a.delay=M_,a.difference=Zd,a.differenceBy=Jd,a.differenceWith=Xd,a.drop=Vd,a.dropRight=jd,a.dropRightWhile=np,a.dropWhile=ep,a.fill=tp,a.filter=i_,a.flatMap=s_,a.flatMapDeep=a_,a.flatMapDepth=f_,a.flatten=wa,a.flattenDeep=rp,a.flattenDepth=ip,a.flip=x_,a.flow=Am,a.flowRight=Im,a.fromPairs=up,a.functions=Ig,a.functionsIn=Og,a.groupBy=c_,a.initial=sp,a.intersection=ap,a.intersectionBy=fp,a.intersectionWith=cp,a.invert=Mg,a.invertBy=xg,a.invokeMap=h_,a.iteratee=Uu,a.keyBy=d_,a.keys=Nn,a.keysIn=Qn,a.map=ii,a.mapKeys=bg,a.mapValues=Sg,a.matches=Om,a.matchesProperty=Rm,a.memoize=oi,a.merge=Dg,a.mergeWith=Wa,a.method=Mm,a.methodOf=xm,a.mixin=Pu,a.negate=si,a.nthArg=bm,a.omit=Ng,a.omitBy=$g,a.once=L_,a.orderBy=p_,a.over=Sm,a.overArgs=b_,a.overEvery=Dm,a.overSome=Nm,a.partial=xu,a.partialRight=Na,a.partition=__,a.pick=Ug,a.pickBy=Ba,a.property=Ja,a.propertyOf=$m,a.pull=pp,a.pullAll=ya,a.pullAllBy=_p,a.pullAllWith=gp,a.pullAt=mp,a.range=Um,a.rangeRight=Pm,a.rearg=S_,a.reject=v_,a.remove=vp,a.rest=D_,a.reverse=Ou,a.sampleSize=w_,a.set=Fg,a.setWith=Yg,a.shuffle=T_,a.slice=Ep,a.sortBy=I_,a.sortedUniq=Rp,a.sortedUniqBy=Mp,a.split=sm,a.spread=N_,a.tail=xp,a.take=Lp,a.takeRight=bp,a.takeRightWhile=Sp,a.takeWhile=Dp,a.tap=Qp,a.throttle=$_,a.thru=ri,a.toArray=Ya,a.toPairs=Ga,a.toPairsIn=za,a.toPath=km,a.toPlainObject=Ha,a.transform=Cg,a.unary=U_,a.union=Np,a.unionBy=$p,a.unionWith=Up,a.uniq=Pp,a.uniqBy=Fp,a.uniqWith=Yp,a.unset=Hg,a.unzip=Ru,a.unzipWith=Aa,a.update=kg,a.updateWith=Wg,a.values=Dt,a.valuesIn=Bg,a.without=Cp,a.words=Ka,a.wrap=P_,a.xor=Hp,a.xorBy=kp,a.xorWith=Wp,a.zip=Bp,a.zipObject=Gp,a.zipObjectDeep=zp,a.zipWith=qp,a.entries=Ga,a.entriesIn=za,a.extend=ka,a.extendWith=ci,Pu(a,a),a.add=Bm,a.attempt=Za,a.camelCase=Qg,a.capitalize=qa,a.ceil=Gm,a.clamp=Gg,a.clone=Y_,a.cloneDeep=H_,a.cloneDeepWith=k_,a.cloneWith=C_,a.conformsTo=W_,a.deburr=Qa,a.defaultTo=ym,a.divide=zm,a.endsWith=Kg,a.eq=we,a.escape=Zg,a.escapeRegExp=Jg,a.every=r_,a.find=u_,a.findIndex=va,a.findKey=vg,a.findLast=o_,a.findLastIndex=Ea,a.findLastKey=Eg,a.floor=qm,a.forEach=Oa,a.forEachRight=Ra,a.forIn=wg,a.forInRight=Tg,a.forOwn=yg,a.forOwnRight=Ag,a.get=Su,a.gt=B_,a.gte=G_,a.has=Rg,a.hasIn=Du,a.head=Ta,a.identity=Kn,a.includes=l_,a.indexOf=op,a.inRange=zg,a.invoke=Lg,a.isArguments=ct,a.isArray=G,a.isArrayBuffer=z_,a.isArrayLike=qn,a.isArrayLikeObject=yn,a.isBoolean=q_,a.isBuffer=Je,a.isDate=Q_,a.isElement=K_,a.isEmpty=Z_,a.isEqual=J_,a.isEqualWith=X_,a.isError=Lu,a.isFinite=V_,a.isFunction=Fe,a.isInteger=$a,a.isLength=ai,a.isMap=Ua,a.isMatch=j_,a.isMatchWith=ng,a.isNaN=eg,a.isNative=tg,a.isNil=ig,a.isNull=rg,a.isNumber=Pa,a.isObject=En,a.isObjectLike=wn,a.isPlainObject=er,a.isRegExp=bu,a.isSafeInteger=ug,a.isSet=Fa,a.isString=fi,a.isSymbol=te,a.isTypedArray=St,a.isUndefined=og,a.isWeakMap=sg,a.isWeakSet=ag,a.join=lp,a.kebabCase=Xg,a.last=he,a.lastIndexOf=hp,a.lowerCase=Vg,a.lowerFirst=jg,a.lt=fg,a.lte=cg,a.max=Qm,a.maxBy=Km,a.mean=Zm,a.meanBy=Jm,a.min=Xm,a.minBy=Vm,a.stubArray=Yu,a.stubFalse=Cu,a.stubObject=Fm,a.stubString=Ym,a.stubTrue=Cm,a.multiply=jm,a.nth=dp,a.noConflict=Lm,a.noop=Fu,a.now=ui,a.pad=nm,a.padEnd=em,a.padStart=tm,a.parseInt=rm,a.random=qg,a.reduce=g_,a.reduceRight=m_,a.repeat=im,a.replace=um,a.result=Pg,a.round=n0,a.runInContext=d,a.sample=E_,a.size=y_,a.snakeCase=om,a.some=A_,a.sortedIndex=wp,a.sortedIndexBy=Tp,a.sortedIndexOf=yp,a.sortedLastIndex=Ap,a.sortedLastIndexBy=Ip,a.sortedLastIndexOf=Op,a.startCase=am,a.startsWith=fm,a.subtract=e0,a.sum=t0,a.sumBy=r0,a.template=cm,a.times=Hm,a.toFinite=Ye,a.toInteger=K,a.toLength=Ca,a.toLower=lm,a.toNumber=de,a.toSafeInteger=lg,a.toString=an,a.toUpper=hm,a.trim=dm,a.trimEnd=pm,a.trimStart=_m,a.truncate=gm,a.unescape=mm,a.uniqueId=Wm,a.upperCase=vm,a.upperFirst=Nu,a.each=Oa,a.eachRight=Ra,a.first=Ta,Pu(a,(function(){var n={};return Oe(a,function(e,t){fn.call(a.prototype,t)||(n[t]=e)}),n})(),{chain:!1}),a.VERSION=c,se(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){a[n].placeholder=a}),se(["drop","take"],function(n,e){j.prototype[n]=function(t){t=t===r?1:bn(K(t),0);var i=this.__filtered__&&!e?new j(this):this.clone();return i.__filtered__?i.__takeCount__=Cn(t,i.__takeCount__):i.__views__.push({size:Cn(t,X),type:n+(i.__dir__<0?"Right":"")}),i},j.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),se(["filter","map","takeWhile"],function(n,e){var t=e+1,i=t==Y||t==M;j.prototype[n]=function(s){var f=this.clone();return f.__iteratees__.push({iteratee:U(s,3),type:t}),f.__filtered__=f.__filtered__||i,f}}),se(["head","last"],function(n,e){var t="take"+(e?"Right":"");j.prototype[n]=function(){return this[t](1).value()[0]}}),se(["initial","tail"],function(n,e){var t="drop"+(e?"":"Right");j.prototype[n]=function(){return this.__filtered__?new j(this):this[t](1)}}),j.prototype.compact=function(){return this.filter(Kn)},j.prototype.find=function(n){return this.filter(n).head()},j.prototype.findLast=function(n){return this.reverse().find(n)},j.prototype.invokeMap=J(function(n,e){return typeof n=="function"?new j(this):this.map(function(t){return Zt(t,n,e)})}),j.prototype.reject=function(n){return this.filter(si(U(n)))},j.prototype.slice=function(n,e){n=K(n);var t=this;return t.__filtered__&&(n>0||e<0)?new j(t):(n<0?t=t.takeRight(-n):n&&(t=t.drop(n)),e!==r&&(e=K(e),t=e<0?t.dropRight(-e):t.take(e-n)),t)},j.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},j.prototype.toArray=function(){return this.take(X)},Oe(j.prototype,function(n,e){var t=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),s=a[i?"take"+(e=="last"?"Right":""):e],f=i||/^find/.test(e);s&&(a.prototype[e]=function(){var l=this.__wrapped__,h=i?[1]:arguments,g=l instanceof j,w=h[0],T=g||G(l),y=function(V){var tn=s.apply(a,Be([V],h));return i&&R?tn[0]:tn};T&&t&&typeof w=="function"&&w.length!=1&&(g=T=!1);var R=this.__chain__,D=!!this.__actions__.length,P=f&&!R,Z=g&&!D;if(!f&&T){l=Z?l:new j(this);var F=n.apply(l,h);return F.__actions__.push({func:ri,args:[y],thisArg:r}),new fe(F,R)}return P&&Z?n.apply(this,h):(F=this.thru(y),P?i?F.value()[0]:F.value():F)})}),se(["pop","push","shift","sort","splice","unshift"],function(n){var e=Lr[n],t=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",i=/^(?:pop|shift)$/.test(n);a.prototype[n]=function(){var s=arguments;if(i&&!this.__chain__){var f=this.value();return e.apply(G(f)?f:[],s)}return this[t](function(l){return e.apply(G(l)?l:[],s)})}}),Oe(j.prototype,function(n,e){var t=a[e];if(t){var i=t.name+"";fn.call(Rt,i)||(Rt[i]=[]),Rt[i].push({name:e,func:t})}}),Rt[Jr(r,hn).name]=[{name:"wrapper",func:r}],j.prototype.clone=mh,j.prototype.reverse=vh,j.prototype.value=Eh,a.prototype.at=Kp,a.prototype.chain=Zp,a.prototype.commit=Jp,a.prototype.next=Xp,a.prototype.plant=jp,a.prototype.reverse=n_,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=e_,a.prototype.first=a.prototype.head,Wt&&(a.prototype[Wt]=Vp),a}),At=Jl();tt?((tt.exports=At)._=At,Ui._=At):Pn._=At}).call(Wf)})(Ut,Ut.exports)),Ut.exports}Bf();const Gf="1.4.0";class uo{constructor(u){this.debug=!1,this.debug=u?.debug??!1,this.appName=u?.appName,this.appVersion=u?.appVersion}log(u,...r){this.debug&&this.print(u,"info",r)}warn(u,...r){this.print(u,"warn",r)}error(u,...r){this.print(u,"error",r)}print(u,r,c){const p=[`[${["MeltingSpot",this.appName,this.appVersion].filter(Boolean).join(" - ")}] ${u}`];c.length&&p.push(...c),console[r](...p)}}const zf=new uo({appName:"Core SDK",appVersion:Gf}),qf=o=>o.toLowerCase().replace(/[^a-z0-9-]/g,""),Qf=["/user"],Kf=({deeplink:o,spotId:u})=>{try{const r=new URL(o,"https://unused.com");let c=r.pathname;return r.search&&(c+=r.search),r.hash&&(c+=r.hash),Qf.some(_=>c.startsWith(_))||(c=`/spot/${u}/${uf(c)}`),c}catch(r){return zf.warn("Failed to parse deeplink URL",r),null}},Zf=[/(^|\.)meltingspot\.io$/i],Jf=o=>{let u;try{const v=zu(o);u=new URL(v)}catch{throw new Error(`Invalid baseURL: ${o}`)}const r=u.hostname==="localhost"||u.hostname==="127.0.0.1",c=u.protocol==="https:",_=Zf.some(v=>v.test(u.hostname));if(!r&&(!c||!_))throw new Error(`Untrusted baseURL origin: ${u.origin}`);return u.origin},Xf={msApiBaseUrl:"https://openapi.meltingspot.io/",msCommunityWebBaseUrl:"https://go.meltingspot.io/",ssoToken:void 0,spotId:"",autoJoin:!1,rootDocument:globalThis.document};class Jn{constructor(){this.configuration=Xf}static getInstance(){return Jn.instance||(Jn.instance=new Jn),Jn.instance}setConfiguration(u){this.configuration={...this.configuration,...u}}static getConfiguration(u={}){return{...Jn.getInstance().configuration,...u}}}const oo="%[a-f0-9]{2}",so=new RegExp("("+oo+")|([^%]+?)","gi"),ao=new RegExp("("+oo+")+","gi");function di(o,u){try{return[decodeURIComponent(o.join(""))]}catch{}if(o.length===1)return o;u=u||1;const r=o.slice(0,u),c=o.slice(u);return Array.prototype.concat.call([],di(r),di(c))}function Vf(o){try{return decodeURIComponent(o)}catch{let u=o.match(so)||[];for(let r=1;r<u.length;r++)o=di(u,r).join(""),u=o.match(so)||[];return o}}function jf(o){const u={"%FE%FF":"��","%FF%FE":"��"};let r=ao.exec(o);for(;r;){try{u[r[0]]=decodeURIComponent(r[0])}catch{const _=Vf(r[0]);_!==r[0]&&(u[r[0]]=_)}r=ao.exec(o)}u["%C2"]="�";const c=Object.keys(u);for(const _ of c)o=o.replace(new RegExp(_,"g"),u[_]);return o}function nc(o){if(typeof o!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof o+"`");try{return decodeURIComponent(o)}catch{return jf(o)}}function ec(o,u){const r={};if(Array.isArray(u))for(const c of u){const _=Object.getOwnPropertyDescriptor(o,c);_?.enumerable&&Object.defineProperty(r,c,_)}else for(const c of Reflect.ownKeys(o)){const _=Object.getOwnPropertyDescriptor(o,c);if(_.enumerable){const v=o[c];u(c,v,o)&&Object.defineProperty(r,c,_)}}return r}function fo(o,u){if(!(typeof o=="string"&&typeof u=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(o===""||u==="")return[];const r=o.indexOf(u);return r===-1?[]:[o.slice(0,r),o.slice(r+u.length)]}const tc=o=>o==null,rc=o=>encodeURIComponent(o).replaceAll(/[!'()*]/g,u=>`%${u.charCodeAt(0).toString(16).toUpperCase()}`),pi=Symbol("encodeFragmentIdentifier");function ic(o){switch(o.arrayFormat){case"index":return u=>(r,c)=>{const _=r.length;return c===void 0||o.skipNull&&c===null||o.skipEmptyString&&c===""?r:c===null?[...r,[In(u,o),"[",_,"]"].join("")]:[...r,[In(u,o),"[",In(_,o),"]=",In(c,o)].join("")]};case"bracket":return u=>(r,c)=>c===void 0||o.skipNull&&c===null||o.skipEmptyString&&c===""?r:c===null?[...r,[In(u,o),"[]"].join("")]:[...r,[In(u,o),"[]=",In(c,o)].join("")];case"colon-list-separator":return u=>(r,c)=>c===void 0||o.skipNull&&c===null||o.skipEmptyString&&c===""?r:c===null?[...r,[In(u,o),":list="].join("")]:[...r,[In(u,o),":list=",In(c,o)].join("")];case"comma":case"separator":case"bracket-separator":{const u=o.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(c,_)=>_===void 0||o.skipNull&&_===null||o.skipEmptyString&&_===""?c:(_=_===null?"":_,c.length===0?[[In(r,o),u,In(_,o)].join("")]:[[c,In(_,o)].join(o.arrayFormatSeparator)])}default:return u=>(r,c)=>c===void 0||o.skipNull&&c===null||o.skipEmptyString&&c===""?r:c===null?[...r,In(u,o)]:[...r,[In(u,o),"=",In(c,o)].join("")]}}function uc(o){let u;switch(o.arrayFormat){case"index":return(r,c,_)=>{if(u=/\[(\d*)]$/.exec(r),r=r.replace(/\[\d*]$/,""),!u){_[r]=c;return}_[r]===void 0&&(_[r]={}),_[r][u[1]]=c};case"bracket":return(r,c,_)=>{if(u=/(\[])$/.exec(r),r=r.replace(/\[]$/,""),!u){_[r]=c;return}if(_[r]===void 0){_[r]=[c];return}_[r]=[..._[r],c]};case"colon-list-separator":return(r,c,_)=>{if(u=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!u){_[r]=c;return}if(_[r]===void 0){_[r]=[c];return}_[r]=[..._[r],c]};case"comma":case"separator":return(r,c,_)=>{const v=typeof c=="string"&&c.includes(o.arrayFormatSeparator),p=typeof c=="string"&&!v&&xe(c,o).includes(o.arrayFormatSeparator);c=p?xe(c,o):c;const A=v||p?c.split(o.arrayFormatSeparator).map(I=>xe(I,o)):c===null?c:xe(c,o);_[r]=A};case"bracket-separator":return(r,c,_)=>{const v=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!v){_[r]=c&&xe(c,o);return}const p=c===null?[]:xe(c,o).split(o.arrayFormatSeparator);if(_[r]===void 0){_[r]=p;return}_[r]=[..._[r],...p]};default:return(r,c,_)=>{if(_[r]===void 0){_[r]=c;return}_[r]=[...[_[r]].flat(),c]}}}function co(o){if(typeof o!="string"||o.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function In(o,u){return u.encode?u.strict?rc(o):encodeURIComponent(o):o}function xe(o,u){return u.decode?nc(o):o}function lo(o){return Array.isArray(o)?o.sort():typeof o=="object"?lo(Object.keys(o)).sort((u,r)=>Number(u)-Number(r)).map(u=>o[u]):o}function ho(o){const u=o.indexOf("#");return u!==-1&&(o=o.slice(0,u)),o}function oc(o){let u="";const r=o.indexOf("#");return r!==-1&&(u=o.slice(r)),u}function po(o,u,r){return r==="string"&&typeof o=="string"?o:typeof r=="function"&&typeof o=="string"?r(o):r==="boolean"&&o===null?!0:r==="boolean"&&o!==null&&(o.toLowerCase()==="true"||o.toLowerCase()==="false")?o.toLowerCase()==="true":r==="boolean"&&o!==null&&(o.toLowerCase()==="1"||o.toLowerCase()==="0")?o.toLowerCase()==="1":r==="string[]"&&u.arrayFormat!=="none"&&typeof o=="string"?[o]:r==="number[]"&&u.arrayFormat!=="none"&&!Number.isNaN(Number(o))&&typeof o=="string"&&o.trim()!==""?[Number(o)]:r==="number"&&!Number.isNaN(Number(o))&&typeof o=="string"&&o.trim()!==""?Number(o):u.parseBooleans&&o!==null&&(o.toLowerCase()==="true"||o.toLowerCase()==="false")?o.toLowerCase()==="true":u.parseNumbers&&!Number.isNaN(Number(o))&&typeof o=="string"&&o.trim()!==""?Number(o):o}function _i(o){o=ho(o);const u=o.indexOf("?");return u===-1?"":o.slice(u+1)}function gi(o,u){u={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...u},co(u.arrayFormatSeparator);const r=uc(u),c=Object.create(null);if(typeof o!="string"||(o=o.trim().replace(/^[?#&]/,""),!o))return c;for(const _ of o.split("&")){if(_==="")continue;const v=u.decode?_.replaceAll("+"," "):_;let[p,A]=fo(v,"=");p===void 0&&(p=v),A=A===void 0?null:["comma","separator","bracket-separator"].includes(u.arrayFormat)?A:xe(A,u),r(xe(p,u),A,c)}for(const[_,v]of Object.entries(c))if(typeof v=="object"&&v!==null&&u.types[_]!=="string")for(const[p,A]of Object.entries(v)){const I=u.types[_]?u.types[_].replace("[]",""):void 0;v[p]=po(A,u,I)}else typeof v=="object"&&v!==null&&u.types[_]==="string"?c[_]=Object.values(v).join(u.arrayFormatSeparator):c[_]=po(v,u,u.types[_]);return u.sort===!1?c:(u.sort===!0?Object.keys(c).sort():Object.keys(c).sort(u.sort)).reduce((_,v)=>{const p=c[v];return _[v]=p&&typeof p=="object"&&!Array.isArray(p)?lo(p):p,_},Object.create(null))}function _o(o,u){if(!o)return"";u={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...u},co(u.arrayFormatSeparator);const r=p=>u.skipNull&&tc(o[p])||u.skipEmptyString&&o[p]==="",c=ic(u),_={};for(const[p,A]of Object.entries(o))r(p)||(_[p]=A);const v=Object.keys(_);return u.sort!==!1&&v.sort(u.sort),v.map(p=>{const A=o[p];return A===void 0?"":A===null?In(p,u):Array.isArray(A)?A.length===0&&u.arrayFormat==="bracket-separator"?In(p,u)+"[]":A.reduce(c(p),[]).join("&"):In(p,u)+"="+In(A,u)}).filter(p=>p.length>0).join("&")}function go(o,u){u={decode:!0,...u};let[r,c]=fo(o,"#");return r===void 0&&(r=o),{url:r?.split("?")?.[0]??"",query:gi(_i(o),u),...u&&u.parseFragmentIdentifier&&c?{fragmentIdentifier:xe(c,u)}:{}}}function mo(o,u){u={encode:!0,strict:!0,[pi]:!0,...u};const r=ho(o.url).split("?")[0]||"",c=_i(o.url),_={...gi(c,{sort:!1,...u}),...o.query};let v=_o(_,u);v&&=`?${v}`;let p=oc(o.url);if(typeof o.fragmentIdentifier=="string"){const A=new URL(r);A.hash=o.fragmentIdentifier,p=u[pi]?A.hash:`#${o.fragmentIdentifier}`}return`${r}${v}${p}`}function vo(o,u,r){r={parseFragmentIdentifier:!0,[pi]:!1,...r};const{url:c,query:_,fragmentIdentifier:v}=go(o,r);return mo({url:c,query:ec(_,u),fragmentIdentifier:v},r)}function sc(o,u,r){const c=Array.isArray(u)?_=>!u.includes(_):(_,v)=>!u(_,v);return vo(o,c,r)}const ac=Object.freeze(Object.defineProperty({__proto__:null,exclude:sc,extract:_i,parse:gi,parseUrl:go,pick:vo,stringify:_o,stringifyUrl:mo},Symbol.toStringTag,{value:"Module"}));class Gn extends Error{constructor(u,r){super(`HTTP Error ${u}${r?`: ${r}`:""}`),this.code=u,this.name="HttpError",Object.setPrototypeOf(this,Gn.prototype)}}var Sn=(o=>(o.GET="GET",o.PATCH="PATCH",o.POST="POST",o))(Sn||{});class fc{constructor(){this.headers={}}setHeaders(u){this.headers=u}async get(u){try{const r=u.query?`${u.url}?${this.serializeQuery(u.query)}`:u.url,c=await fetch(r,{headers:{...this.headers,...u.headers,"Content-Type":"application/json"},...u.signal?{signal:u.signal}:{}});return c.ok?on(await c.json()):Q(new Gn(c.status,await c.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return Q(new Gn(ue.INTERNAL_SERVER_ERROR,c))}}async post(u){try{const r=await fetch(u.url,{method:"POST",headers:{...this.headers,...u.headers,"Content-Type":"application/json"},body:JSON.stringify(u.payload),...u.signal?{signal:u.signal}:{}});return r.ok?on(await r.json()):Q(new Gn(r.status,await r.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return Q(new Gn(ue.INTERNAL_SERVER_ERROR,c))}}async patch(u){try{const r=await fetch(u.url,{method:"PATCH",headers:{...this.headers,...u.headers,"Content-Type":"application/json"},body:JSON.stringify(u.payload),...u.signal?{signal:u.signal}:{}});return r.ok?on(await r.json()):Q(new Gn(r.status,await r.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return Q(new Gn(ue.INTERNAL_SERVER_ERROR,c))}}serializeQuery(u){if(typeof u=="string")return u;if(typeof u=="object")for(const r in u)u[r]===void 0&&delete u[r];return u=ac.stringify(u,{arrayFormat:"none"}),u}}const mr={accessToken:{email:"/v1/auth/accessToken/email",sso:{jwt:"/v1/auth/accessToken/sso/jwt"}},refreshAccessToken:"/v1/auth/accessToken~refresh",password:{reset:"/v1/auth/password~reset"}};class ke extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return ke.instance||(ke.instance=new ke),ke.instance}async loginWithPassword(u,r){const c=await this.callApi({endpoint:mr.accessToken.email,method:"POST",body:{email:u,password:r},withSpotId:!0});if(c.isErr())return Q(c.error);const{accessToken:_,refreshToken:v}=c.value;return this.setTokens(_.token,v.token),on({accessToken:_.token,refreshToken:v.token})}async loginWithSsoToken(u){const r=await this.callApi({endpoint:mr.accessToken.sso.jwt,method:"POST",body:{token:u},withSpotId:!0});if(r.isErr())return Q(r.error);const{accessToken:c,refreshToken:_}=r.value;return this.setTokens(c.token,_.token),on({accessToken:c.token,refreshToken:_.token})}loginWithAuthTokens(u,r){return this.setTokens(u,r),{accessToken:u,refreshToken:r}}resetPassword(u){return this.callApi({endpoint:mr.password.reset,method:"POST",body:{email:u}})}async refresh(){const u=await this.callApi({endpoint:mr.refreshAccessToken,method:"POST",body:{refreshToken:this.refreshToken}});if(u.isErr())return Q(u.error);const{accessToken:r,refreshToken:c}=u.value;return this.setTokens(r.token,c.token),on({accessToken:r.token,refreshToken:c.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(u,r){if(this.accessToken!==u||this.refreshToken!==r){this.accessToken=u,this.refreshToken=r;const c=new CustomEvent("auth:tokens-updated",{detail:{accessToken:u,refreshToken:r}});this.dispatchEvent(c)}}async callApi(u){try{const{spotId:r,msApiBaseUrl:c}=Jn.getConfiguration(),_=hi(u.endpoint,c),v={"Content-Type":"application/json",...u.headers};u.withSpotId&&r&&(v[Eo.SpotId]=r);const p=await fetch(_,{method:u.method,body:u.body?JSON.stringify(u.body):void 0,headers:v});if(!p.ok)return Q(new Gn(p.status,p.statusText));if(p.status===ue.NO_CONTENT)return on(void 0);const A=await p.json();return on(A)}catch(r){return Q(new Gn(ue.INTERNAL_SERVER_ERROR,r instanceof Error?r.message:String(r)))}}}var Eo=(o=>(o.Authorization="Authorization",o.SpotId="x-spotid",o))(Eo||{});class ye{constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=ke.getInstance(),this.httpService=new fc}static getInstance(){return ye.instance||(ye.instance=new ye),ye.instance}static buildAuthenticatedRequest(u){const{msApiBaseUrl:r,spotId:c}=Jn.getConfiguration(),_=hi(u,r),v=ke.getInstance().getAccessToken();if(!v)return Q(new Error("Not authenticated"));const p={"Content-Type":"application/json",Authorization:`Bearer ${v}`};return c&&(p["x-spotid"]=c),on({url:_,headers:p})}static async stream(u,r,c){const{streamTransport:_}=Jn.getConfiguration();if(_)return _({endpoint:u,body:r,signal:c});const v=ye.buildAuthenticatedRequest(u);if(v.isErr())return Q(v.error);const{url:p,headers:A}=v.value;try{const I=await fetch(p,{method:"POST",headers:A,...r!==void 0?{body:JSON.stringify(r)}:{},...c?{signal:c}:{}});if(!I.ok){const H=await I.text();return Q(new Error(`HTTP ${I.status}: ${H}`))}return I.body?on(I.body):Q(new Error("Response body is empty"))}catch(I){const H=I instanceof Error?I.message:"Unknown error";return Q(I instanceof Error?I:new Error(H))}}get pendingCount(){return this.queue.length}enqueue(u){return new Promise(r=>{const c=async()=>{try{const _=await u();r(_)}catch(_){r(Q(new Gn(ue.INTERNAL_SERVER_ERROR,_ instanceof Error?_.message:"Unknown error")))}};this.queue.push(c),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){const u=this.queue.shift();if(!u)break;await u()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){const u=this.isPaused;this.isPaused=!1,u&&this.processQueue()}async call(u){return this.enqueue(async()=>{const r=async()=>{const{spotId:_,msApiBaseUrl:v}=Jn.getConfiguration(),p={...u.options?.headers??{}};_&&(p["x-spotid"]=_);const A=this.authService.getAccessToken(),{requiresAuth:I=!0}=u;if(!A&&I)return Q(new Gn(ue.UNAUTHORIZED));A&&(p.Authorization=`Bearer ${A}`);const H=hi(u.endpoint,v);switch(u.method){case Sn.GET:return this.httpService.get({...u.options??{},headers:p,url:H});case Sn.PATCH:return this.httpService.patch({...u.options??{},headers:p,url:H});case Sn.POST:return this.httpService.post({...u.options??{},headers:p,url:H});default:return Q(new Gn(ue.METHOD_NOT_ALLOWED,"Method not allowed"))}};let c=await r();if(c.isErr()&&c.error.code===ue.UNAUTHORIZED){const _=await this.authService.refresh();if(_.isErr())return Q(new Gn(ue.UNAUTHORIZED,_.error.message));c=await r()}return c})}}const Ae={playbooks:"/v1/playbooks",pages:o=>`/v1/playbooks/${o}/pages`,hotspots:(o,u)=>`/v1/playbooks/${o}/pages/${u}/hotspots`,hotspot:(o,u,r)=>`/v1/playbooks/${o}/pages/${u}/hotspots/${r}`,accessibleIntents:(o,u)=>`/v1/playbooks/${o}/pages/${u}/accessibleIntents`,intents:(o,u,r)=>`/v1/playbooks/${o}/pages/${u}/hotspots/${r}/intents`,intent:(o,u,r,c)=>`/v1/playbooks/${o}/pages/${u}/hotspots/${r}/intents/${c}`},vr=50;class lt{static getInstance(){return lt.instance||(lt.instance=new lt),lt.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async listPlaybooks(u){const r=await this.meltingSpotApi.call({method:Sn.GET,endpoint:Ae.playbooks,options:{query:{page:u?.page??1,limit:u?.limit??vr,...u?.domain?{"domain[eq]":u.domain}:{}}}});return r.isErr()?Q(r.error):on(r.value)}async listPlaybookPages(u){const r=await this.meltingSpotApi.call({method:Sn.GET,endpoint:Ae.pages(u.playbookId),options:{query:{page:u.page??1,limit:u.limit??vr,...u.url?{"url[eq]":u.url}:{}}}});return r.isErr()?Q(r.error):on(r.value)}async createPlaybookPage(u,r){const c=await this.meltingSpotApi.call({method:Sn.POST,endpoint:Ae.pages(u.playbookId),options:{payload:r}});return c.isErr()?Q(c.error):on(c.value)}async listAccessiblePlaybookIntents(u){const r=await this.meltingSpotApi.call({method:Sn.GET,endpoint:Ae.accessibleIntents(u.playbookId,u.pageId),options:{query:{...u.domain?{domain:u.domain}:{}}}});return r.isErr()?Q(r.error):on(r.value)}async listPlaybookHotspots(u){const r=await this.meltingSpotApi.call({method:Sn.GET,endpoint:Ae.hotspots(u.playbookId,u.pageId),options:{query:{page:u.page??1,limit:u.limit??vr,...u.intentStatus?{"intentStatus[eq]":u.intentStatus}:{},...u.widgetType?{"widgetType[eq]":u.widgetType}:{}}}});return r.isErr()?Q(r.error):on(r.value)}async createPlaybookHotspot(u,r){const c=await this.meltingSpotApi.call({method:Sn.POST,endpoint:Ae.hotspots(u.playbookId,u.pageId),options:{payload:r}});return c.isErr()?Q(c.error):on(c.value)}async updatePlaybookHotspot(u,r){const c=await this.meltingSpotApi.call({method:Sn.PATCH,endpoint:Ae.hotspot(u.playbookId,u.pageId,u.hotspotId),options:{payload:r}});return c.isErr()?Q(c.error):on(c.value)}async listPlaybookIntents(u){const r=await this.meltingSpotApi.call({method:Sn.GET,endpoint:Ae.intents(u.playbookId,u.pageId,u.hotspotId),options:{query:{page:u.page??1,limit:u.limit??vr,...u.status?{"status[eq]":u.status}:{}}}});return r.isErr()?Q(r.error):on(r.value)}async createPlaybookIntent(u,r){const c=await this.meltingSpotApi.call({method:Sn.POST,endpoint:Ae.intents(u.playbookId,u.pageId,u.hotspotId),options:{payload:r}});return c.isErr()?Q(c.error):on(c.value)}async updatePlaybookIntent(u,r){const c=await this.meltingSpotApi.call({method:Sn.PATCH,endpoint:Ae.intent(u.playbookId,u.pageId,u.hotspotId,u.intentId),options:{payload:r}});return c.isErr()?Q(c.error):on(c.value)}}const cc={me:"/v1/spots/me"},lc=50;class ht{static getInstance(){return ht.instance||(ht.instance=new ht),ht.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async listSpotsForMe(u){const r=await this.meltingSpotApi.call({method:Sn.GET,endpoint:cc.me,options:{query:{page:1,limit:lc,...u?.spotMemberRole?{"spotMemberRole[eq]":u.spotMemberRole}:{}}}});return r.isErr()?Q(r.error):on(r.value)}}const wo={spotMember:{me:"/v1/spotMembers/me",joinFromSso:"/v1/spotMembers~joinFromSso"}};class dt{static getInstance(){return dt.instance||(dt.instance=new dt),dt.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async getSpotMemberForMe(){const u=await this.meltingSpotApi.call({method:Sn.GET,endpoint:wo.spotMember.me});return u.isErr()?Q(u.error):on(u.value)}async joinFromSso(u){const r=await this.meltingSpotApi.call({method:Sn.POST,endpoint:wo.spotMember.joinFromSso,options:{payload:{token:u}}});return r.isErr()?Q(r.error):on(r.value)}}const hc={spotMemberSsoToken:"/v1/spotMembers/auth/sso/jwt"};class pt{static getInstance(){return pt.instance||(pt.instance=new pt),pt.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async generateSsoToken(){const u=await this.meltingSpotApi.call({method:Sn.POST,endpoint:hc.spotMemberSsoToken,options:{payload:{}}});return u.isErr()?Q(u.error):on(u.value.token)}}class _t{static getInstance(){return _t.instance||(_t.instance=new _t),_t.instance}constructor(){this.spotMemberAuthApiService=pt.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}}const dc=o=>{const u=o.get("utm_source");if(u)return{source:u,medium:o.get("utm_medium")??void 0,campaign:o.get("utm_campaign")??void 0,term:o.get("utm_term")??void 0,content:o.get("utm_content")??void 0}},pc=o=>o?Object.entries(o).reduce((u,[r,c])=>(c!=null&&(u[`utm_${r}`]=c),u),{}):{},_c=Jn.getInstance(),gc=ke.getInstance(),mc=_t.getInstance(),vc={Playbook:lt.getInstance(),Spot:ht.getInstance(),SpotMember:dt.getInstance()},gt=globalThis;gt.MeltingSpot||(gt.MeltingSpot={}),gt.MeltingSpot.Configuration=_c,gt.MeltingSpot.Auth=gc,gt.MeltingSpot.Sso=mc,gt.MeltingSpot.Api=vc;const Ec="1.4.0",mi=new uo({appName:"Embed SDK",appVersion:Ec});class To{constructor(u){this.content=u}#n=null;#e=null;set onRemove(u){this.#e=u}inject(u){this.remove();const r=sf({input:u,rootDocument:this.content.rootDocument});this.#n=this.content.iframe,this.#n.classList.add("ms-embed"),r.appendChild(this.#n)}remove(){this.#n&&(this.#n.contentWindow&&this.#e?.(this.#n.contentWindow),this.#n.remove(),this.#n=null)}}class wc{constructor(u){this.baseURL=Jf(u.baseURL),this.spotId=qf(u.spotId),this.authToken=u.authToken??null,this.themeMode=u.themeMode??"auto",this.domain=u.domain??null,this.deeplink=u.deeplink?Kf({deeplink:u.deeplink,spotId:this.spotId}):null,this.utmParameters=u.utmParameters??null,this.rootDocument=u.rootDocument}get iframe(){const u=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",r=new URL(`/spot/${this.spotId}${u}`,zu(this.baseURL)),c=ff({url:r,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...pc(this.utmParameters)},rootDocument:this.rootDocument});return c.classList.add("ms-spot"),c}}const Er={READY:"meltingspot:ready",ERROR:"meltingspot:error",PREFILL_DRAFT:"meltingspot:prefillDraft"},Mn=class Mn{static injectSpotInto(u,r){const{onReady:c,onError:_,...v}=r,{spotId:p,rootDocument:A,msCommunityWebBaseUrl:I}=Jn.getConfiguration({spotId:v.spotId,rootDocument:v.rootDocument,msCommunityWebBaseUrl:v.baseURL});if(!p)throw mi.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const H=new URLSearchParams(window.location.search),nn={spotId:p,authToken:v.authToken??H.get("ms_token"),domain:v.domain,deeplink:v.deeplink??H.get("ms_url"),themeMode:v.themeMode,utmParameters:v.utmParameters??dc(H),baseURL:I,rootDocument:A},N=new To(new wc(nn));if(N.inject(u),Mn.embeds.push(N),c||_){const $=N.content.iframe.contentWindow;$&&(Mn.iframeCallbacks.set($,{onReady:c,onError:_}),N.onRemove=z=>{Mn.iframeCallbacks.delete(z)}),Mn.ensureMessageListener()}return mi.log("Spot injected",nn,u),N}static clear(){Mn.embeds.forEach(u=>{u.remove()}),Mn.embeds=[],Mn.iframeCallbacks.clear(),Mn.messageListened&&(window.removeEventListener("message",Mn.handleMessageEvent),Mn.messageListened=!1),mi.log("All MeltingSpot embeds cleared")}static handleMessageEvent(u){if(!u.data||typeof u.data!="object"||u.data.type!==Er.READY&&u.data.type!==Er.ERROR)return;const r=u.source,c=Mn.iframeCallbacks.get(r);if(!c)return;const{msCommunityWebBaseUrl:_}=Jn.getConfiguration({});if(_)try{const v=new URL(_).origin;if(u.origin!==v)return}catch{}u.data.type===Er.READY?c.onReady?.():c.onError?.(u.data.error)}static ensureMessageListener(){Mn.messageListened||(window.addEventListener("message",Mn.handleMessageEvent),Mn.messageListened=!0)}};Mn.embeds=[],Mn.messageListened=!1,Mn.iframeCallbacks=new Map;let wr=Mn;const vi=globalThis;vi.MeltingSpot||(vi.MeltingSpot={}),vi.MeltingSpot.Embed=wr,He.EMBED_POST_MESSAGE_TYPE=Er,He.Embed=wr,He.EmbedFrame=To,Object.defineProperty(He,Symbol.toStringTag,{value:"Module"})}));
20
+ }`;var Z=Za(function(){return un(f,D+"return "+y).apply(r,l)});if(Z.source=y,Lu(Z))throw Z;return Z}function lm(n){return an(n).toLowerCase()}function hm(n){return an(n).toUpperCase()}function dm(n,e,t){if(n=an(n),n&&(t||e===r))return is(n);if(!n||!(e=ee(e)))return n;var i=ve(n),s=ve(e),f=us(i,s),l=os(i,s)+1;return Ze(i,f,l).join("")}function pm(n,e,t){if(n=an(n),n&&(t||e===r))return n.slice(0,as(n)+1);if(!n||!(e=ee(e)))return n;var i=ve(n),s=os(i,ve(e))+1;return Ze(i,0,s).join("")}function _m(n,e,t){if(n=an(n),n&&(t||e===r))return n.replace(Li,"");if(!n||!(e=ee(e)))return n;var i=ve(n),s=us(i,ve(e));return Ze(i,s).join("")}function gm(n,e){var t=cn,i=rn;if(En(e)){var s="separator"in e?e.separator:s;t="length"in e?K(e.length):t,i="omission"in e?ee(e.omission):i}n=an(n);var f=n.length;if(Tt(n)){var l=ve(n);f=l.length}if(t>=f)return n;var h=t-yt(i);if(h<1)return i;var g=l?Ze(l,0,h).join(""):n.slice(0,h);if(s===r)return g+i;if(l&&(h+=g.length-h),bu(s)){if(n.slice(h).search(s)){var w,T=g;for(s.global||(s=qi(s.source,an(Ro.exec(s))+"g")),s.lastIndex=0;w=s.exec(T);)var y=w.index;g=g.slice(0,y===r?h:y)}}else if(n.indexOf(ee(s),h)!=h){var R=g.lastIndexOf(s);R>-1&&(g=g.slice(0,R))}return g+i}function mm(n){return n=an(n),n&&xc.test(n)?n.replace(Ao,ql):n}var vm=Lt(function(n,e,t){return n+(t?" ":"")+e.toUpperCase()}),Nu=Js("toUpperCase");function Ka(n,e,t){return n=an(n),e=t?r:e,e===r?kl(n)?Zl(n):Dl(n):n.match(e)||[]}var Za=J(function(n,e){try{return jn(n,r,e)}catch(t){return Lu(t)?t:new W(t)}}),Em=Ue(function(n,e){return se(e,function(t){t=Me(t),Ne(n,t,Mu(n[t],n))}),n});function wm(n){var e=n==null?0:n.length,t=U();return n=e?_n(n,function(i){if(typeof i[1]!="function")throw new ae(p);return[t(i[0]),i[1]]}):[],J(function(i){for(var s=-1;++s<e;){var f=n[s];if(jn(f[0],this,i))return jn(f[1],this,i)}})}function Tm(n){return qh(ce(n,N))}function $u(n){return function(){return n}}function ym(n,e){return n==null||n!==n?e:n}var Am=Vs(),Im=Vs(!0);function Kn(n){return n}function Uu(n){return xs(typeof n=="function"?n:ce(n,N))}function Om(n){return bs(ce(n,N))}function Rm(n,e){return Ss(n,ce(e,N))}var Mm=J(function(n,e){return function(t){return Zt(t,n,e)}}),xm=J(function(n,e){return function(t){return Zt(n,t,e)}});function Pu(n,e,t){var i=Nn(e),s=zr(e,i);t==null&&!(En(e)&&(s.length||!i.length))&&(t=e,e=n,n=this,s=zr(e,Nn(e)));var f=!(En(t)&&"chain"in t)||!!t.chain,l=Fe(n);return se(s,function(h){var g=e[h];n[h]=g,l&&(n.prototype[h]=function(){var w=this.__chain__;if(f||w){var T=n(this.__wrapped__),y=T.__actions__=zn(this.__actions__);return y.push({func:g,args:arguments,thisArg:n}),T.__chain__=w,T}return g.apply(n,Be([this.value()],arguments))})}),n}function Lm(){return Pn._===this&&(Pn._=eh),this}function Fu(){}function bm(n){return n=K(n),J(function(e){return Ds(e,n)})}var Sm=pu(_n),Dm=pu(jo),Nm=pu(Ci);function Ja(n){return Tu(n)?Hi(Me(n)):fd(n)}function $m(n){return function(e){return n==null?r:st(n,e)}}var Um=na(),Pm=na(!0);function Yu(){return[]}function Cu(){return!1}function Fm(){return{}}function Ym(){return""}function Cm(){return!0}function Hm(n,e){if(n=K(n),n<1||n>O)return[];var t=X,i=Cn(n,X);e=U(e),n-=X;for(var s=Bi(i,e);++t<n;)e(t);return s}function km(n){return G(n)?_n(n,Me):te(n)?[n]:zn(ga(an(n)))}function Wm(n){var e=++jl;return an(n)+e}var Bm=Xr(function(n,e){return n+e},0),Gm=_u("ceil"),zm=Xr(function(n,e){return n/e},1),qm=_u("floor");function Qm(n){return n&&n.length?Gr(n,Kn,nu):r}function Km(n,e){return n&&n.length?Gr(n,U(e,2),nu):r}function Zm(n){return ts(n,Kn)}function Jm(n,e){return ts(n,U(e,2))}function Xm(n){return n&&n.length?Gr(n,Kn,iu):r}function Vm(n,e){return n&&n.length?Gr(n,U(e,2),iu):r}var jm=Xr(function(n,e){return n*e},1),n0=_u("round"),e0=Xr(function(n,e){return n-e},0);function t0(n){return n&&n.length?Wi(n,Kn):0}function r0(n,e){return n&&n.length?Wi(n,U(e,2)):0}return a.after=O_,a.ary=Ma,a.assign=hg,a.assignIn=ka,a.assignInWith=ci,a.assignWith=dg,a.at=pg,a.before=xa,a.bind=Mu,a.bindAll=Em,a.bindKey=La,a.castArray=F_,a.chain=Ia,a.chunk=qd,a.compact=Qd,a.concat=Kd,a.cond=wm,a.conforms=Tm,a.constant=$u,a.countBy=t_,a.create=_g,a.curry=ba,a.curryRight=Sa,a.debounce=Da,a.defaults=gg,a.defaultsDeep=mg,a.defer=R_,a.delay=M_,a.difference=Zd,a.differenceBy=Jd,a.differenceWith=Xd,a.drop=Vd,a.dropRight=jd,a.dropRightWhile=np,a.dropWhile=ep,a.fill=tp,a.filter=i_,a.flatMap=s_,a.flatMapDeep=a_,a.flatMapDepth=f_,a.flatten=wa,a.flattenDeep=rp,a.flattenDepth=ip,a.flip=x_,a.flow=Am,a.flowRight=Im,a.fromPairs=up,a.functions=Ig,a.functionsIn=Og,a.groupBy=c_,a.initial=sp,a.intersection=ap,a.intersectionBy=fp,a.intersectionWith=cp,a.invert=Mg,a.invertBy=xg,a.invokeMap=h_,a.iteratee=Uu,a.keyBy=d_,a.keys=Nn,a.keysIn=Qn,a.map=ii,a.mapKeys=bg,a.mapValues=Sg,a.matches=Om,a.matchesProperty=Rm,a.memoize=oi,a.merge=Dg,a.mergeWith=Wa,a.method=Mm,a.methodOf=xm,a.mixin=Pu,a.negate=si,a.nthArg=bm,a.omit=Ng,a.omitBy=$g,a.once=L_,a.orderBy=p_,a.over=Sm,a.overArgs=b_,a.overEvery=Dm,a.overSome=Nm,a.partial=xu,a.partialRight=Na,a.partition=__,a.pick=Ug,a.pickBy=Ba,a.property=Ja,a.propertyOf=$m,a.pull=pp,a.pullAll=ya,a.pullAllBy=_p,a.pullAllWith=gp,a.pullAt=mp,a.range=Um,a.rangeRight=Pm,a.rearg=S_,a.reject=v_,a.remove=vp,a.rest=D_,a.reverse=Ou,a.sampleSize=w_,a.set=Fg,a.setWith=Yg,a.shuffle=T_,a.slice=Ep,a.sortBy=I_,a.sortedUniq=Rp,a.sortedUniqBy=Mp,a.split=sm,a.spread=N_,a.tail=xp,a.take=Lp,a.takeRight=bp,a.takeRightWhile=Sp,a.takeWhile=Dp,a.tap=Qp,a.throttle=$_,a.thru=ri,a.toArray=Ya,a.toPairs=Ga,a.toPairsIn=za,a.toPath=km,a.toPlainObject=Ha,a.transform=Cg,a.unary=U_,a.union=Np,a.unionBy=$p,a.unionWith=Up,a.uniq=Pp,a.uniqBy=Fp,a.uniqWith=Yp,a.unset=Hg,a.unzip=Ru,a.unzipWith=Aa,a.update=kg,a.updateWith=Wg,a.values=Dt,a.valuesIn=Bg,a.without=Cp,a.words=Ka,a.wrap=P_,a.xor=Hp,a.xorBy=kp,a.xorWith=Wp,a.zip=Bp,a.zipObject=Gp,a.zipObjectDeep=zp,a.zipWith=qp,a.entries=Ga,a.entriesIn=za,a.extend=ka,a.extendWith=ci,Pu(a,a),a.add=Bm,a.attempt=Za,a.camelCase=Qg,a.capitalize=qa,a.ceil=Gm,a.clamp=Gg,a.clone=Y_,a.cloneDeep=H_,a.cloneDeepWith=k_,a.cloneWith=C_,a.conformsTo=W_,a.deburr=Qa,a.defaultTo=ym,a.divide=zm,a.endsWith=Kg,a.eq=we,a.escape=Zg,a.escapeRegExp=Jg,a.every=r_,a.find=u_,a.findIndex=va,a.findKey=vg,a.findLast=o_,a.findLastIndex=Ea,a.findLastKey=Eg,a.floor=qm,a.forEach=Oa,a.forEachRight=Ra,a.forIn=wg,a.forInRight=Tg,a.forOwn=yg,a.forOwnRight=Ag,a.get=Su,a.gt=B_,a.gte=G_,a.has=Rg,a.hasIn=Du,a.head=Ta,a.identity=Kn,a.includes=l_,a.indexOf=op,a.inRange=zg,a.invoke=Lg,a.isArguments=ct,a.isArray=G,a.isArrayBuffer=z_,a.isArrayLike=qn,a.isArrayLikeObject=yn,a.isBoolean=q_,a.isBuffer=Je,a.isDate=Q_,a.isElement=K_,a.isEmpty=Z_,a.isEqual=J_,a.isEqualWith=X_,a.isError=Lu,a.isFinite=V_,a.isFunction=Fe,a.isInteger=$a,a.isLength=ai,a.isMap=Ua,a.isMatch=j_,a.isMatchWith=ng,a.isNaN=eg,a.isNative=tg,a.isNil=ig,a.isNull=rg,a.isNumber=Pa,a.isObject=En,a.isObjectLike=wn,a.isPlainObject=er,a.isRegExp=bu,a.isSafeInteger=ug,a.isSet=Fa,a.isString=fi,a.isSymbol=te,a.isTypedArray=St,a.isUndefined=og,a.isWeakMap=sg,a.isWeakSet=ag,a.join=lp,a.kebabCase=Xg,a.last=he,a.lastIndexOf=hp,a.lowerCase=Vg,a.lowerFirst=jg,a.lt=fg,a.lte=cg,a.max=Qm,a.maxBy=Km,a.mean=Zm,a.meanBy=Jm,a.min=Xm,a.minBy=Vm,a.stubArray=Yu,a.stubFalse=Cu,a.stubObject=Fm,a.stubString=Ym,a.stubTrue=Cm,a.multiply=jm,a.nth=dp,a.noConflict=Lm,a.noop=Fu,a.now=ui,a.pad=nm,a.padEnd=em,a.padStart=tm,a.parseInt=rm,a.random=qg,a.reduce=g_,a.reduceRight=m_,a.repeat=im,a.replace=um,a.result=Pg,a.round=n0,a.runInContext=d,a.sample=E_,a.size=y_,a.snakeCase=om,a.some=A_,a.sortedIndex=wp,a.sortedIndexBy=Tp,a.sortedIndexOf=yp,a.sortedLastIndex=Ap,a.sortedLastIndexBy=Ip,a.sortedLastIndexOf=Op,a.startCase=am,a.startsWith=fm,a.subtract=e0,a.sum=t0,a.sumBy=r0,a.template=cm,a.times=Hm,a.toFinite=Ye,a.toInteger=K,a.toLength=Ca,a.toLower=lm,a.toNumber=de,a.toSafeInteger=lg,a.toString=an,a.toUpper=hm,a.trim=dm,a.trimEnd=pm,a.trimStart=_m,a.truncate=gm,a.unescape=mm,a.uniqueId=Wm,a.upperCase=vm,a.upperFirst=Nu,a.each=Oa,a.eachRight=Ra,a.first=Ta,Pu(a,(function(){var n={};return Oe(a,function(e,t){fn.call(a.prototype,t)||(n[t]=e)}),n})(),{chain:!1}),a.VERSION=c,se(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){a[n].placeholder=a}),se(["drop","take"],function(n,e){j.prototype[n]=function(t){t=t===r?1:bn(K(t),0);var i=this.__filtered__&&!e?new j(this):this.clone();return i.__filtered__?i.__takeCount__=Cn(t,i.__takeCount__):i.__views__.push({size:Cn(t,X),type:n+(i.__dir__<0?"Right":"")}),i},j.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),se(["filter","map","takeWhile"],function(n,e){var t=e+1,i=t==Y||t==M;j.prototype[n]=function(s){var f=this.clone();return f.__iteratees__.push({iteratee:U(s,3),type:t}),f.__filtered__=f.__filtered__||i,f}}),se(["head","last"],function(n,e){var t="take"+(e?"Right":"");j.prototype[n]=function(){return this[t](1).value()[0]}}),se(["initial","tail"],function(n,e){var t="drop"+(e?"":"Right");j.prototype[n]=function(){return this.__filtered__?new j(this):this[t](1)}}),j.prototype.compact=function(){return this.filter(Kn)},j.prototype.find=function(n){return this.filter(n).head()},j.prototype.findLast=function(n){return this.reverse().find(n)},j.prototype.invokeMap=J(function(n,e){return typeof n=="function"?new j(this):this.map(function(t){return Zt(t,n,e)})}),j.prototype.reject=function(n){return this.filter(si(U(n)))},j.prototype.slice=function(n,e){n=K(n);var t=this;return t.__filtered__&&(n>0||e<0)?new j(t):(n<0?t=t.takeRight(-n):n&&(t=t.drop(n)),e!==r&&(e=K(e),t=e<0?t.dropRight(-e):t.take(e-n)),t)},j.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},j.prototype.toArray=function(){return this.take(X)},Oe(j.prototype,function(n,e){var t=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),s=a[i?"take"+(e=="last"?"Right":""):e],f=i||/^find/.test(e);s&&(a.prototype[e]=function(){var l=this.__wrapped__,h=i?[1]:arguments,g=l instanceof j,w=h[0],T=g||G(l),y=function(V){var tn=s.apply(a,Be([V],h));return i&&R?tn[0]:tn};T&&t&&typeof w=="function"&&w.length!=1&&(g=T=!1);var R=this.__chain__,D=!!this.__actions__.length,P=f&&!R,Z=g&&!D;if(!f&&T){l=Z?l:new j(this);var F=n.apply(l,h);return F.__actions__.push({func:ri,args:[y],thisArg:r}),new fe(F,R)}return P&&Z?n.apply(this,h):(F=this.thru(y),P?i?F.value()[0]:F.value():F)})}),se(["pop","push","shift","sort","splice","unshift"],function(n){var e=Lr[n],t=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",i=/^(?:pop|shift)$/.test(n);a.prototype[n]=function(){var s=arguments;if(i&&!this.__chain__){var f=this.value();return e.apply(G(f)?f:[],s)}return this[t](function(l){return e.apply(G(l)?l:[],s)})}}),Oe(j.prototype,function(n,e){var t=a[e];if(t){var i=t.name+"";fn.call(Rt,i)||(Rt[i]=[]),Rt[i].push({name:e,func:t})}}),Rt[Jr(r,hn).name]=[{name:"wrapper",func:r}],j.prototype.clone=mh,j.prototype.reverse=vh,j.prototype.value=Eh,a.prototype.at=Kp,a.prototype.chain=Zp,a.prototype.commit=Jp,a.prototype.next=Xp,a.prototype.plant=jp,a.prototype.reverse=n_,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=e_,a.prototype.first=a.prototype.head,Wt&&(a.prototype[Wt]=Vp),a}),At=Jl();tt?((tt.exports=At)._=At,Ui._=At):Pn._=At}).call(Wf)})(Ut,Ut.exports)),Ut.exports}Bf();const Gf="1.5.1";class uo{constructor(u){this.debug=!1,this.debug=u?.debug??!1,this.appName=u?.appName,this.appVersion=u?.appVersion}log(u,...r){this.debug&&this.print(u,"info",r)}warn(u,...r){this.print(u,"warn",r)}error(u,...r){this.print(u,"error",r)}print(u,r,c){const p=[`[${["MeltingSpot",this.appName,this.appVersion].filter(Boolean).join(" - ")}] ${u}`];c.length&&p.push(...c),console[r](...p)}}const zf=new uo({appName:"Core SDK",appVersion:Gf}),qf=o=>o.toLowerCase().replace(/[^a-z0-9-]/g,""),Qf=["/user"],Kf=({deeplink:o,spotId:u})=>{try{const r=new URL(o,"https://unused.com");let c=r.pathname;return r.search&&(c+=r.search),r.hash&&(c+=r.hash),Qf.some(_=>c.startsWith(_))||(c=`/spot/${u}/${uf(c)}`),c}catch(r){return zf.warn("Failed to parse deeplink URL",r),null}},Zf=[/(^|\.)meltingspot\.io$/i],Jf=o=>{let u;try{const v=zu(o);u=new URL(v)}catch{throw new Error(`Invalid baseURL: ${o}`)}const r=u.hostname==="localhost"||u.hostname==="127.0.0.1",c=u.protocol==="https:",_=Zf.some(v=>v.test(u.hostname));if(!r&&(!c||!_))throw new Error(`Untrusted baseURL origin: ${u.origin}`);return u.origin},Xf={msApiBaseUrl:"https://openapi.meltingspot.io/",msCommunityWebBaseUrl:"https://go.meltingspot.io/",ssoToken:void 0,spotId:"",autoJoin:!1,rootDocument:globalThis.document};class Jn{constructor(){this.configuration=Xf}static getInstance(){return Jn.instance||(Jn.instance=new Jn),Jn.instance}setConfiguration(u){this.configuration={...this.configuration,...u}}static getConfiguration(u={}){return{...Jn.getInstance().configuration,...u}}}const oo="%[a-f0-9]{2}",so=new RegExp("("+oo+")|([^%]+?)","gi"),ao=new RegExp("("+oo+")+","gi");function di(o,u){try{return[decodeURIComponent(o.join(""))]}catch{}if(o.length===1)return o;u=u||1;const r=o.slice(0,u),c=o.slice(u);return Array.prototype.concat.call([],di(r),di(c))}function Vf(o){try{return decodeURIComponent(o)}catch{let u=o.match(so)||[];for(let r=1;r<u.length;r++)o=di(u,r).join(""),u=o.match(so)||[];return o}}function jf(o){const u={"%FE%FF":"��","%FF%FE":"��"};let r=ao.exec(o);for(;r;){try{u[r[0]]=decodeURIComponent(r[0])}catch{const _=Vf(r[0]);_!==r[0]&&(u[r[0]]=_)}r=ao.exec(o)}u["%C2"]="�";const c=Object.keys(u);for(const _ of c)o=o.replace(new RegExp(_,"g"),u[_]);return o}function nc(o){if(typeof o!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof o+"`");try{return decodeURIComponent(o)}catch{return jf(o)}}function ec(o,u){const r={};if(Array.isArray(u))for(const c of u){const _=Object.getOwnPropertyDescriptor(o,c);_?.enumerable&&Object.defineProperty(r,c,_)}else for(const c of Reflect.ownKeys(o)){const _=Object.getOwnPropertyDescriptor(o,c);if(_.enumerable){const v=o[c];u(c,v,o)&&Object.defineProperty(r,c,_)}}return r}function fo(o,u){if(!(typeof o=="string"&&typeof u=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(o===""||u==="")return[];const r=o.indexOf(u);return r===-1?[]:[o.slice(0,r),o.slice(r+u.length)]}const tc=o=>o==null,rc=o=>encodeURIComponent(o).replaceAll(/[!'()*]/g,u=>`%${u.charCodeAt(0).toString(16).toUpperCase()}`),pi=Symbol("encodeFragmentIdentifier");function ic(o){switch(o.arrayFormat){case"index":return u=>(r,c)=>{const _=r.length;return c===void 0||o.skipNull&&c===null||o.skipEmptyString&&c===""?r:c===null?[...r,[In(u,o),"[",_,"]"].join("")]:[...r,[In(u,o),"[",In(_,o),"]=",In(c,o)].join("")]};case"bracket":return u=>(r,c)=>c===void 0||o.skipNull&&c===null||o.skipEmptyString&&c===""?r:c===null?[...r,[In(u,o),"[]"].join("")]:[...r,[In(u,o),"[]=",In(c,o)].join("")];case"colon-list-separator":return u=>(r,c)=>c===void 0||o.skipNull&&c===null||o.skipEmptyString&&c===""?r:c===null?[...r,[In(u,o),":list="].join("")]:[...r,[In(u,o),":list=",In(c,o)].join("")];case"comma":case"separator":case"bracket-separator":{const u=o.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(c,_)=>_===void 0||o.skipNull&&_===null||o.skipEmptyString&&_===""?c:(_=_===null?"":_,c.length===0?[[In(r,o),u,In(_,o)].join("")]:[[c,In(_,o)].join(o.arrayFormatSeparator)])}default:return u=>(r,c)=>c===void 0||o.skipNull&&c===null||o.skipEmptyString&&c===""?r:c===null?[...r,In(u,o)]:[...r,[In(u,o),"=",In(c,o)].join("")]}}function uc(o){let u;switch(o.arrayFormat){case"index":return(r,c,_)=>{if(u=/\[(\d*)]$/.exec(r),r=r.replace(/\[\d*]$/,""),!u){_[r]=c;return}_[r]===void 0&&(_[r]={}),_[r][u[1]]=c};case"bracket":return(r,c,_)=>{if(u=/(\[])$/.exec(r),r=r.replace(/\[]$/,""),!u){_[r]=c;return}if(_[r]===void 0){_[r]=[c];return}_[r]=[..._[r],c]};case"colon-list-separator":return(r,c,_)=>{if(u=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!u){_[r]=c;return}if(_[r]===void 0){_[r]=[c];return}_[r]=[..._[r],c]};case"comma":case"separator":return(r,c,_)=>{const v=typeof c=="string"&&c.includes(o.arrayFormatSeparator),p=typeof c=="string"&&!v&&xe(c,o).includes(o.arrayFormatSeparator);c=p?xe(c,o):c;const A=v||p?c.split(o.arrayFormatSeparator).map(I=>xe(I,o)):c===null?c:xe(c,o);_[r]=A};case"bracket-separator":return(r,c,_)=>{const v=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!v){_[r]=c&&xe(c,o);return}const p=c===null?[]:xe(c,o).split(o.arrayFormatSeparator);if(_[r]===void 0){_[r]=p;return}_[r]=[..._[r],...p]};default:return(r,c,_)=>{if(_[r]===void 0){_[r]=c;return}_[r]=[...[_[r]].flat(),c]}}}function co(o){if(typeof o!="string"||o.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function In(o,u){return u.encode?u.strict?rc(o):encodeURIComponent(o):o}function xe(o,u){return u.decode?nc(o):o}function lo(o){return Array.isArray(o)?o.sort():typeof o=="object"?lo(Object.keys(o)).sort((u,r)=>Number(u)-Number(r)).map(u=>o[u]):o}function ho(o){const u=o.indexOf("#");return u!==-1&&(o=o.slice(0,u)),o}function oc(o){let u="";const r=o.indexOf("#");return r!==-1&&(u=o.slice(r)),u}function po(o,u,r){return r==="string"&&typeof o=="string"?o:typeof r=="function"&&typeof o=="string"?r(o):r==="boolean"&&o===null?!0:r==="boolean"&&o!==null&&(o.toLowerCase()==="true"||o.toLowerCase()==="false")?o.toLowerCase()==="true":r==="boolean"&&o!==null&&(o.toLowerCase()==="1"||o.toLowerCase()==="0")?o.toLowerCase()==="1":r==="string[]"&&u.arrayFormat!=="none"&&typeof o=="string"?[o]:r==="number[]"&&u.arrayFormat!=="none"&&!Number.isNaN(Number(o))&&typeof o=="string"&&o.trim()!==""?[Number(o)]:r==="number"&&!Number.isNaN(Number(o))&&typeof o=="string"&&o.trim()!==""?Number(o):u.parseBooleans&&o!==null&&(o.toLowerCase()==="true"||o.toLowerCase()==="false")?o.toLowerCase()==="true":u.parseNumbers&&!Number.isNaN(Number(o))&&typeof o=="string"&&o.trim()!==""?Number(o):o}function _i(o){o=ho(o);const u=o.indexOf("?");return u===-1?"":o.slice(u+1)}function gi(o,u){u={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...u},co(u.arrayFormatSeparator);const r=uc(u),c=Object.create(null);if(typeof o!="string"||(o=o.trim().replace(/^[?#&]/,""),!o))return c;for(const _ of o.split("&")){if(_==="")continue;const v=u.decode?_.replaceAll("+"," "):_;let[p,A]=fo(v,"=");p===void 0&&(p=v),A=A===void 0?null:["comma","separator","bracket-separator"].includes(u.arrayFormat)?A:xe(A,u),r(xe(p,u),A,c)}for(const[_,v]of Object.entries(c))if(typeof v=="object"&&v!==null&&u.types[_]!=="string")for(const[p,A]of Object.entries(v)){const I=u.types[_]?u.types[_].replace("[]",""):void 0;v[p]=po(A,u,I)}else typeof v=="object"&&v!==null&&u.types[_]==="string"?c[_]=Object.values(v).join(u.arrayFormatSeparator):c[_]=po(v,u,u.types[_]);return u.sort===!1?c:(u.sort===!0?Object.keys(c).sort():Object.keys(c).sort(u.sort)).reduce((_,v)=>{const p=c[v];return _[v]=p&&typeof p=="object"&&!Array.isArray(p)?lo(p):p,_},Object.create(null))}function _o(o,u){if(!o)return"";u={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...u},co(u.arrayFormatSeparator);const r=p=>u.skipNull&&tc(o[p])||u.skipEmptyString&&o[p]==="",c=ic(u),_={};for(const[p,A]of Object.entries(o))r(p)||(_[p]=A);const v=Object.keys(_);return u.sort!==!1&&v.sort(u.sort),v.map(p=>{const A=o[p];return A===void 0?"":A===null?In(p,u):Array.isArray(A)?A.length===0&&u.arrayFormat==="bracket-separator"?In(p,u)+"[]":A.reduce(c(p),[]).join("&"):In(p,u)+"="+In(A,u)}).filter(p=>p.length>0).join("&")}function go(o,u){u={decode:!0,...u};let[r,c]=fo(o,"#");return r===void 0&&(r=o),{url:r?.split("?")?.[0]??"",query:gi(_i(o),u),...u&&u.parseFragmentIdentifier&&c?{fragmentIdentifier:xe(c,u)}:{}}}function mo(o,u){u={encode:!0,strict:!0,[pi]:!0,...u};const r=ho(o.url).split("?")[0]||"",c=_i(o.url),_={...gi(c,{sort:!1,...u}),...o.query};let v=_o(_,u);v&&=`?${v}`;let p=oc(o.url);if(typeof o.fragmentIdentifier=="string"){const A=new URL(r);A.hash=o.fragmentIdentifier,p=u[pi]?A.hash:`#${o.fragmentIdentifier}`}return`${r}${v}${p}`}function vo(o,u,r){r={parseFragmentIdentifier:!0,[pi]:!1,...r};const{url:c,query:_,fragmentIdentifier:v}=go(o,r);return mo({url:c,query:ec(_,u),fragmentIdentifier:v},r)}function sc(o,u,r){const c=Array.isArray(u)?_=>!u.includes(_):(_,v)=>!u(_,v);return vo(o,c,r)}const ac=Object.freeze(Object.defineProperty({__proto__:null,exclude:sc,extract:_i,parse:gi,parseUrl:go,pick:vo,stringify:_o,stringifyUrl:mo},Symbol.toStringTag,{value:"Module"}));class Gn extends Error{constructor(u,r){super(`HTTP Error ${u}${r?`: ${r}`:""}`),this.code=u,this.name="HttpError",Object.setPrototypeOf(this,Gn.prototype)}}var Sn=(o=>(o.GET="GET",o.PATCH="PATCH",o.POST="POST",o))(Sn||{});class fc{constructor(){this.headers={}}setHeaders(u){this.headers=u}async get(u){try{const r=u.query?`${u.url}?${this.serializeQuery(u.query)}`:u.url,c=await fetch(r,{headers:{...this.headers,...u.headers,"Content-Type":"application/json"},...u.signal?{signal:u.signal}:{}});return c.ok?on(await c.json()):Q(new Gn(c.status,await c.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return Q(new Gn(ue.INTERNAL_SERVER_ERROR,c))}}async post(u){try{const r=await fetch(u.url,{method:"POST",headers:{...this.headers,...u.headers,"Content-Type":"application/json"},body:JSON.stringify(u.payload),...u.signal?{signal:u.signal}:{}});return r.ok?on(await r.json()):Q(new Gn(r.status,await r.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return Q(new Gn(ue.INTERNAL_SERVER_ERROR,c))}}async patch(u){try{const r=await fetch(u.url,{method:"PATCH",headers:{...this.headers,...u.headers,"Content-Type":"application/json"},body:JSON.stringify(u.payload),...u.signal?{signal:u.signal}:{}});return r.ok?on(await r.json()):Q(new Gn(r.status,await r.text()))}catch(r){const c=r instanceof Error?r.message:"Unknown error";return Q(new Gn(ue.INTERNAL_SERVER_ERROR,c))}}serializeQuery(u){if(typeof u=="string")return u;if(typeof u=="object")for(const r in u)u[r]===void 0&&delete u[r];return u=ac.stringify(u,{arrayFormat:"none"}),u}}const mr={accessToken:{email:"/v1/auth/accessToken/email",sso:{jwt:"/v1/auth/accessToken/sso/jwt"}},refreshAccessToken:"/v1/auth/accessToken~refresh",password:{reset:"/v1/auth/password~reset"}};class ke extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return ke.instance||(ke.instance=new ke),ke.instance}async loginWithPassword(u,r){const c=await this.callApi({endpoint:mr.accessToken.email,method:"POST",body:{email:u,password:r},withSpotId:!0});if(c.isErr())return Q(c.error);const{accessToken:_,refreshToken:v}=c.value;return this.setTokens(_.token,v.token),on({accessToken:_.token,refreshToken:v.token})}async loginWithSsoToken(u){const r=await this.callApi({endpoint:mr.accessToken.sso.jwt,method:"POST",body:{token:u},withSpotId:!0});if(r.isErr())return Q(r.error);const{accessToken:c,refreshToken:_}=r.value;return this.setTokens(c.token,_.token),on({accessToken:c.token,refreshToken:_.token})}loginWithAuthTokens(u,r){return this.setTokens(u,r),{accessToken:u,refreshToken:r}}resetPassword(u){return this.callApi({endpoint:mr.password.reset,method:"POST",body:{email:u}})}async refresh(){const u=await this.callApi({endpoint:mr.refreshAccessToken,method:"POST",body:{refreshToken:this.refreshToken}});if(u.isErr())return Q(u.error);const{accessToken:r,refreshToken:c}=u.value;return this.setTokens(r.token,c.token),on({accessToken:r.token,refreshToken:c.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(u,r){if(this.accessToken!==u||this.refreshToken!==r){this.accessToken=u,this.refreshToken=r;const c=new CustomEvent("auth:tokens-updated",{detail:{accessToken:u,refreshToken:r}});this.dispatchEvent(c)}}async callApi(u){try{const{spotId:r,msApiBaseUrl:c}=Jn.getConfiguration(),_=hi(u.endpoint,c),v={"Content-Type":"application/json",...u.headers};u.withSpotId&&r&&(v[Eo.SpotId]=r);const p=await fetch(_,{method:u.method,body:u.body?JSON.stringify(u.body):void 0,headers:v});if(!p.ok)return Q(new Gn(p.status,p.statusText));if(p.status===ue.NO_CONTENT)return on(void 0);const A=await p.json();return on(A)}catch(r){return Q(new Gn(ue.INTERNAL_SERVER_ERROR,r instanceof Error?r.message:String(r)))}}}var Eo=(o=>(o.Authorization="Authorization",o.SpotId="x-spotid",o))(Eo||{});class ye{constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=ke.getInstance(),this.httpService=new fc}static getInstance(){return ye.instance||(ye.instance=new ye),ye.instance}static buildAuthenticatedRequest(u){const{msApiBaseUrl:r,spotId:c}=Jn.getConfiguration(),_=hi(u,r),v=ke.getInstance().getAccessToken();if(!v)return Q(new Error("Not authenticated"));const p={"Content-Type":"application/json",Authorization:`Bearer ${v}`};return c&&(p["x-spotid"]=c),on({url:_,headers:p})}static async stream(u,r,c){const{streamTransport:_}=Jn.getConfiguration();if(_)return _({endpoint:u,body:r,signal:c});const v=ye.buildAuthenticatedRequest(u);if(v.isErr())return Q(v.error);const{url:p,headers:A}=v.value;try{const I=await fetch(p,{method:"POST",headers:A,...r!==void 0?{body:JSON.stringify(r)}:{},...c?{signal:c}:{}});if(!I.ok){const H=await I.text();return Q(new Error(`HTTP ${I.status}: ${H}`))}return I.body?on(I.body):Q(new Error("Response body is empty"))}catch(I){const H=I instanceof Error?I.message:"Unknown error";return Q(I instanceof Error?I:new Error(H))}}get pendingCount(){return this.queue.length}enqueue(u){return new Promise(r=>{const c=async()=>{try{const _=await u();r(_)}catch(_){r(Q(new Gn(ue.INTERNAL_SERVER_ERROR,_ instanceof Error?_.message:"Unknown error")))}};this.queue.push(c),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){const u=this.queue.shift();if(!u)break;await u()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){const u=this.isPaused;this.isPaused=!1,u&&this.processQueue()}async call(u){return this.enqueue(async()=>{const r=async()=>{const{spotId:_,msApiBaseUrl:v}=Jn.getConfiguration(),p={...u.options?.headers??{}};_&&(p["x-spotid"]=_);const A=this.authService.getAccessToken(),{requiresAuth:I=!0}=u;if(!A&&I)return Q(new Gn(ue.UNAUTHORIZED));A&&(p.Authorization=`Bearer ${A}`);const H=hi(u.endpoint,v);switch(u.method){case Sn.GET:return this.httpService.get({...u.options??{},headers:p,url:H});case Sn.PATCH:return this.httpService.patch({...u.options??{},headers:p,url:H});case Sn.POST:return this.httpService.post({...u.options??{},headers:p,url:H});default:return Q(new Gn(ue.METHOD_NOT_ALLOWED,"Method not allowed"))}};let c=await r();if(c.isErr()&&c.error.code===ue.UNAUTHORIZED){const _=await this.authService.refresh();if(_.isErr())return Q(new Gn(ue.UNAUTHORIZED,_.error.message));c=await r()}return c})}}const Ae={playbooks:"/v1/playbooks",pages:o=>`/v1/playbooks/${o}/pages`,hotspots:(o,u)=>`/v1/playbooks/${o}/pages/${u}/hotspots`,hotspot:(o,u,r)=>`/v1/playbooks/${o}/pages/${u}/hotspots/${r}`,accessibleIntents:(o,u)=>`/v1/playbooks/${o}/pages/${u}/accessibleIntents`,intents:(o,u,r)=>`/v1/playbooks/${o}/pages/${u}/hotspots/${r}/intents`,intent:(o,u,r,c)=>`/v1/playbooks/${o}/pages/${u}/hotspots/${r}/intents/${c}`},vr=50;class lt{static getInstance(){return lt.instance||(lt.instance=new lt),lt.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async listPlaybooks(u){const r=await this.meltingSpotApi.call({method:Sn.GET,endpoint:Ae.playbooks,options:{query:{page:u?.page??1,limit:u?.limit??vr,...u?.domain?{"domain[eq]":u.domain}:{}}}});return r.isErr()?Q(r.error):on(r.value)}async listPlaybookPages(u){const r=await this.meltingSpotApi.call({method:Sn.GET,endpoint:Ae.pages(u.playbookId),options:{query:{page:u.page??1,limit:u.limit??vr,...u.url?{"url[eq]":u.url}:{}}}});return r.isErr()?Q(r.error):on(r.value)}async createPlaybookPage(u,r){const c=await this.meltingSpotApi.call({method:Sn.POST,endpoint:Ae.pages(u.playbookId),options:{payload:r}});return c.isErr()?Q(c.error):on(c.value)}async listAccessiblePlaybookIntents(u){const r=await this.meltingSpotApi.call({method:Sn.GET,endpoint:Ae.accessibleIntents(u.playbookId,u.pageId),options:{query:{...u.domain?{domain:u.domain}:{}}}});return r.isErr()?Q(r.error):on(r.value)}async listPlaybookHotspots(u){const r=await this.meltingSpotApi.call({method:Sn.GET,endpoint:Ae.hotspots(u.playbookId,u.pageId),options:{query:{page:u.page??1,limit:u.limit??vr,...u.intentStatus?{"intentStatus[eq]":u.intentStatus}:{},...u.widgetType?{"widgetType[eq]":u.widgetType}:{}}}});return r.isErr()?Q(r.error):on(r.value)}async createPlaybookHotspot(u,r){const c=await this.meltingSpotApi.call({method:Sn.POST,endpoint:Ae.hotspots(u.playbookId,u.pageId),options:{payload:r}});return c.isErr()?Q(c.error):on(c.value)}async updatePlaybookHotspot(u,r){const c=await this.meltingSpotApi.call({method:Sn.PATCH,endpoint:Ae.hotspot(u.playbookId,u.pageId,u.hotspotId),options:{payload:r}});return c.isErr()?Q(c.error):on(c.value)}async listPlaybookIntents(u){const r=await this.meltingSpotApi.call({method:Sn.GET,endpoint:Ae.intents(u.playbookId,u.pageId,u.hotspotId),options:{query:{page:u.page??1,limit:u.limit??vr,...u.status?{"status[eq]":u.status}:{}}}});return r.isErr()?Q(r.error):on(r.value)}async createPlaybookIntent(u,r){const c=await this.meltingSpotApi.call({method:Sn.POST,endpoint:Ae.intents(u.playbookId,u.pageId,u.hotspotId),options:{payload:r}});return c.isErr()?Q(c.error):on(c.value)}async updatePlaybookIntent(u,r){const c=await this.meltingSpotApi.call({method:Sn.PATCH,endpoint:Ae.intent(u.playbookId,u.pageId,u.hotspotId,u.intentId),options:{payload:r}});return c.isErr()?Q(c.error):on(c.value)}}const cc={me:"/v1/spots/me"},lc=50;class ht{static getInstance(){return ht.instance||(ht.instance=new ht),ht.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async listSpotsForMe(u){const r=await this.meltingSpotApi.call({method:Sn.GET,endpoint:cc.me,options:{query:{page:1,limit:lc,...u?.spotMemberRole?{"spotMemberRole[eq]":u.spotMemberRole}:{}}}});return r.isErr()?Q(r.error):on(r.value)}}const wo={spotMember:{me:"/v1/spotMembers/me",joinFromSso:"/v1/spotMembers~joinFromSso"}};class dt{static getInstance(){return dt.instance||(dt.instance=new dt),dt.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async getSpotMemberForMe(){const u=await this.meltingSpotApi.call({method:Sn.GET,endpoint:wo.spotMember.me});return u.isErr()?Q(u.error):on(u.value)}async joinFromSso(u){const r=await this.meltingSpotApi.call({method:Sn.POST,endpoint:wo.spotMember.joinFromSso,options:{payload:{token:u}}});return r.isErr()?Q(r.error):on(r.value)}}const hc={spotMemberSsoToken:"/v1/spotMembers/auth/sso/jwt"};class pt{static getInstance(){return pt.instance||(pt.instance=new pt),pt.instance}constructor(){this.meltingSpotApi=ye.getInstance()}async generateSsoToken(){const u=await this.meltingSpotApi.call({method:Sn.POST,endpoint:hc.spotMemberSsoToken,options:{payload:{}}});return u.isErr()?Q(u.error):on(u.value.token)}}class _t{static getInstance(){return _t.instance||(_t.instance=new _t),_t.instance}constructor(){this.spotMemberAuthApiService=pt.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}}const dc=o=>{const u=o.get("utm_source");if(u)return{source:u,medium:o.get("utm_medium")??void 0,campaign:o.get("utm_campaign")??void 0,term:o.get("utm_term")??void 0,content:o.get("utm_content")??void 0}},pc=o=>o?Object.entries(o).reduce((u,[r,c])=>(c!=null&&(u[`utm_${r}`]=c),u),{}):{},_c=Jn.getInstance(),gc=ke.getInstance(),mc=_t.getInstance(),vc={Playbook:lt.getInstance(),Spot:ht.getInstance(),SpotMember:dt.getInstance()},gt=globalThis;gt.MeltingSpot||(gt.MeltingSpot={}),gt.MeltingSpot.Configuration=_c,gt.MeltingSpot.Auth=gc,gt.MeltingSpot.Sso=mc,gt.MeltingSpot.Api=vc;const Ec="1.5.1",mi=new uo({appName:"Embed SDK",appVersion:Ec});class To{constructor(u){this.content=u}#n=null;#e=null;set onRemove(u){this.#e=u}inject(u){this.remove();const r=sf({input:u,rootDocument:this.content.rootDocument});this.#n=this.content.iframe,this.#n.classList.add("ms-embed"),r.appendChild(this.#n)}remove(){this.#n&&(this.#n.contentWindow&&this.#e?.(this.#n.contentWindow),this.#n.remove(),this.#n=null)}}class wc{constructor(u){this.baseURL=Jf(u.baseURL),this.spotId=qf(u.spotId),this.authToken=u.authToken??null,this.themeMode=u.themeMode??"auto",this.domain=u.domain??null,this.deeplink=u.deeplink?Kf({deeplink:u.deeplink,spotId:this.spotId}):null,this.utmParameters=u.utmParameters??null,this.rootDocument=u.rootDocument}get iframe(){const u=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",r=new URL(`/spot/${this.spotId}${u}`,zu(this.baseURL)),c=ff({url:r,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...pc(this.utmParameters)},rootDocument:this.rootDocument});return c.classList.add("ms-spot"),c}}const Er={READY:"meltingspot:ready",ERROR:"meltingspot:error",PREFILL_DRAFT:"meltingspot:prefillDraft"},Mn=class Mn{static injectSpotInto(u,r){const{onReady:c,onError:_,...v}=r,{spotId:p,rootDocument:A,msCommunityWebBaseUrl:I}=Jn.getConfiguration({spotId:v.spotId,rootDocument:v.rootDocument,msCommunityWebBaseUrl:v.baseURL});if(!p)throw mi.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const H=new URLSearchParams(window.location.search),nn={spotId:p,authToken:v.authToken??H.get("ms_token"),domain:v.domain,deeplink:v.deeplink??H.get("ms_url"),themeMode:v.themeMode,utmParameters:v.utmParameters??dc(H),baseURL:I,rootDocument:A},N=new To(new wc(nn));if(N.inject(u),Mn.embeds.push(N),c||_){const $=N.content.iframe.contentWindow;$&&(Mn.iframeCallbacks.set($,{onReady:c,onError:_}),N.onRemove=z=>{Mn.iframeCallbacks.delete(z)}),Mn.ensureMessageListener()}return mi.log("Spot injected",nn,u),N}static clear(){Mn.embeds.forEach(u=>{u.remove()}),Mn.embeds=[],Mn.iframeCallbacks.clear(),Mn.messageListened&&(window.removeEventListener("message",Mn.handleMessageEvent),Mn.messageListened=!1),mi.log("All MeltingSpot embeds cleared")}static handleMessageEvent(u){if(!u.data||typeof u.data!="object"||u.data.type!==Er.READY&&u.data.type!==Er.ERROR)return;const r=u.source,c=Mn.iframeCallbacks.get(r);if(!c)return;const{msCommunityWebBaseUrl:_}=Jn.getConfiguration({});if(_)try{const v=new URL(_).origin;if(u.origin!==v)return}catch{}u.data.type===Er.READY?c.onReady?.():c.onError?.(u.data.error)}static ensureMessageListener(){Mn.messageListened||(window.addEventListener("message",Mn.handleMessageEvent),Mn.messageListened=!0)}};Mn.embeds=[],Mn.messageListened=!1,Mn.iframeCallbacks=new Map;let wr=Mn;const vi=globalThis;vi.MeltingSpot||(vi.MeltingSpot={}),vi.MeltingSpot.Embed=wr,He.EMBED_POST_MESSAGE_TYPE=Er,He.Embed=wr,He.EmbedFrame=To,Object.defineProperty(He,Symbol.toStringTag,{value:"Module"})}));
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.4.0",
6
+ "version": "1.5.1",
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.4.0"
20
+ "@meltingspot/core": "1.5.1"
21
21
  },
22
22
  "publishConfig": {
23
23
  "provenance": false