@meltingspot/widget 1.6.0 → 1.7.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 +8 -0
- package/index.cjs +1 -1
- package/index.mjs +1 -1
- package/index.standalone.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@meltingspot/core"),p=require("@meltingspot/embed"),C="1.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@meltingspot/core"),p=require("@meltingspot/embed"),C="1.7.0",d=new i.Logger({appName:"Widget SDK",appVersion:C});class b{constructor(t,e,o){this.content=t,this.rootDocument=e,this.dialogClassname=o,this.dialogElement=null,this.triggerElement=null,this.iframeElement=null,this.currentListener=null}inject({into:t,bind:e,options:o}){this.remove();const r=i.getHTMLElement({input:t,rootDocument:this.rootDocument});if(this.dialogElement=i.createDialog(this.rootDocument),this.dialogElement.classList.add(this.dialogClassname),this.dialogElement.onclose=()=>this.#e(),r.appendChild(this.dialogElement),e){this.triggerElement=i.getHTMLElement({input:e,rootDocument:this.rootDocument});const c=this.open.bind(this,o);this.currentListener=a=>{a.stopPropagation(),a.preventDefault(),c()},this.triggerElement.addEventListener("click",this.currentListener)}}remove(){this.dialogElement&&(this.dialogElement.remove(),this.dialogElement.onclose=null,this.dialogElement=null),this.triggerElement&&(this.currentListener&&this.triggerElement.removeEventListener("click",this.currentListener),this.triggerElement=null,this.currentListener=null)}open(t){this.dialogElement||this.inject({into:this.rootDocument.body}),this.dialogElement&&(this.#t(),this.dialogElement.showModal())}close(){this.dialogElement&&this.dialogElement.close()}#t(){this.dialogElement&&(this.iframeElement=this.dialogElement.appendChild(this.content.iframe))}#e(){this.iframeElement&&(this.iframeElement.remove(),this.iframeElement=null)}}class w extends b{constructor(t,e){super(t,e,"ms-drawer")}open(t){const{position:e="right"}=t??{};super.open(t),this.dialogElement&&(this.dialogElement.dataset.position=e)}}class I extends b{constructor(t,e){super(t,e,"ms-modal")}}class U{constructor(t){this.baseURL=i.formatBaseUrl(t.baseURL),this.spotId=i.formatUUID(t.spotId),this.widgetId=i.formatUUID(t.widgetId),this.authToken=t.authToken??null,this.themeMode=t.themeMode??"auto",this.domain=t.domain??null,this.utmParameters=t.utmParameters??null,this.rootDocument=t.rootDocument}get iframe(){const t=new URL(`/widgets/spot/${this.spotId}/widget/${this.widgetId}`,i.trimSlashRight(this.baseURL)),e=i.createIframe({url:t,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,...i.flattenUtmParameters(this.utmParameters)},rootDocument:this.rootDocument});return e.classList.add("ms-widget"),e}}class L{constructor(t){this.baseURL=i.formatBaseUrl(t.baseURL),this.spotId=i.formatUUID(t.spotId),this.widgetContentId=i.formatUUID(t.widgetContentId),this.contentId=i.formatUUID(t.contentId),this.widgetId=i.formatUUID(t.widgetId),this.contentType=t.contentType,this.authToken=t.authToken??null,this.themeMode=t.themeMode??"auto",this.domain=t.domain??null,this.utmParameters=t.utmParameters??null,this.rootDocument=t.rootDocument}get iframe(){const t=new URL(`/widgets/spot/${this.spotId}/widgetContent/${this.widgetContentId}`,i.trimSlashRight(this.baseURL));t.searchParams.set("widgetId",this.widgetId);const e=i.createIframe({url:t,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,contentId:this.contentId,contentType:this.contentType,...i.flattenUtmParameters(this.utmParameters)},rootDocument:this.rootDocument});return e.classList.add("ms-widget-content"),e}}const n=class n{static injectWidgetInto(t,e){const{spotId:o,rootDocument:r,msCommunityWebBaseUrl:c}=i.ConfigurationService.getConfiguration({spotId:e.spotId,rootDocument:e.rootDocument,msCommunityWebBaseUrl:e.baseURL});if(!o)throw d.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widget:a,args:m}=n.createWidget({...e,spotId:o,rootDocument:r,baseURL:c}),s=new p.EmbedFrame(a);return s.inject(t),n.widgets.push(s),d.log("Widget injected",n.cleanupLoggedArgs(m),t),s}static injectWidgetContentInto(t,e){const{spotId:o,rootDocument:r,msCommunityWebBaseUrl:c}=i.ConfigurationService.getConfiguration({spotId:e.spotId,rootDocument:e.rootDocument,msCommunityWebBaseUrl:e.baseURL});if(!o)throw d.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widgetContent:a,args:m}=n.createWidgetContent({...e,spotId:o,rootDocument:r,baseURL:c}),s=new p.EmbedFrame(a);return s.inject(t),n.widgets.push(s),d.log("WidgetContent injected",n.cleanupLoggedArgs(m),t),s}static bindWidgetModalTo(t,e){return n.bindEntityModalTo(t,{type:"Widget",data:e})}static bindWidgetDrawerTo(t,e){return n.bindEntityDrawerTo(t,{type:"Widget",data:e})}static createWidgetDrawer(t){const{widget:e}=n.createWidget(t);return d.log("Create Widget drawer",{data:n.cleanupLoggedArgs(t)}),new w(e,t.rootDocument??document)}static createWidgetModal(t){const{widget:e}=n.createWidget(t);return d.log("Create Widget modal",{data:n.cleanupLoggedArgs(t)}),new I(e,t.rootDocument??document)}static createWidgetEmbed(t){const{widget:e}=n.createWidget(t),o=new p.EmbedFrame(e);return d.log("Create Widget embed",{data:n.cleanupLoggedArgs(t)}),o}static clear(){n.widgets.forEach(t=>{t.remove()}),n.widgets=[],n.widgetOptions={},d.log("All Widget SDK MeltingSpot elements were cleared")}static bindEntityDrawerTo(t,e){const{spotId:o,rootDocument:r,msCommunityWebBaseUrl:c}=i.ConfigurationService.getConfiguration({spotId:e.data.spotId,rootDocument:e.data.rootDocument??document,msCommunityWebBaseUrl:e.data.baseURL});if(!o)throw d.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let a,m;switch(e.type){case"Widget":{const u=n.createWidget({...e.data,spotId:o,rootDocument:r,baseURL:c});a=u.widget,m=u.args}break;case"WidgetContent":{const u=n.createWidgetContent({...e.data,spotId:o,rootDocument:r,baseURL:c});a=u.widgetContent,m=u.args}}const s=new w(a,r),l={position:e.data.position},g=e.data.into??r.body;return s.inject({into:g,bind:t,options:l}),n.widgets.push(s),d.log("Widget bound to drawer",n.cleanupLoggedArgs(m),l,g,t),s}static bindEntityModalTo(t,e){const{spotId:o,rootDocument:r,msCommunityWebBaseUrl:c}=i.ConfigurationService.getConfiguration({spotId:e.data.spotId,rootDocument:e.data.rootDocument??document,msCommunityWebBaseUrl:e.data.baseURL});if(!o)throw d.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let a,m;switch(e.type){case"Widget":{const g=n.createWidget({...e.data,spotId:o,rootDocument:r,baseURL:c});a=g.widget,m=g.args}break;case"WidgetContent":{const g=n.createWidgetContent({...e.data,spotId:o,rootDocument:r,baseURL:c});a=g.widgetContent,m=g.args}}const s=new I(a,r),l=e.data.into??r.body;return s.inject({into:l,bind:t}),n.widgets.push(s),d.log("Widget bound to modal",n.cleanupLoggedArgs(m),l,t),s}static handleMessageEvent(t){if(!t.data||typeof t.data!="object"||t.data.type!=="OpenWidgetContent")return;const e=t.data?.widgetId;if(!e||typeof e!="string"){d.error("widgetId is required in the message event data");return}const o=n.widgetOptions[e];if(!o){d.error("No widget options found for widgetId",{widgetId:e});return}let r=null;try{r=new URL(o.baseURL).origin}catch{r=null}if(!r||t.origin!==r){d.warn("Ignoring OpenWidgetContent from unexpected origin",{origin:t.origin,expectedOrigin:r});return}const{spotId:c,rootDocument:a,msCommunityWebBaseUrl:m}=i.ConfigurationService.getConfiguration({spotId:o.spotId,rootDocument:o.rootDocument??document,msCommunityWebBaseUrl:o.baseURL}),{widgetContent:s}=n.createWidgetContent({...o,widgetContentId:t.data.widgetContentId,contentType:t.data.contentType,contentId:t.data.contentId,widgetId:e,spotId:c,rootDocument:a,baseURL:m});t.data.openingIn==="Drawer"?new w(s,a).open():t.data.openingIn==="Modal"&&new I(s,a).open()}static createWidget(t){const e=new URLSearchParams(window.location.search),o={spotId:t.spotId,widgetId:t.widgetId,authToken:t.authToken,themeMode:t.themeMode,domain:t.domain,rootDocument:t.rootDocument,baseURL:t.baseURL,utmParameters:t.utmParameters??i.parseUtmParameters(e)};return n.widgetOptions[o.widgetId]=o,n.messageListened||(window.addEventListener("message",n.handleMessageEvent),n.messageListened=!0),{widget:new U(o),args:o}}static createWidgetContent(t){const e=new URLSearchParams(window.location.search),o={spotId:t.spotId,contentId:t.contentId,contentType:t.contentType,widgetContentId:t.widgetContentId,widgetId:t.widgetId,authToken:t.authToken,themeMode:t.themeMode,domain:t.domain,rootDocument:t.rootDocument,baseURL:t.baseURL,utmParameters:t.utmParameters??i.parseUtmParameters(e)};return{widgetContent:new L(o),args:o}}static cleanupLoggedArgs(t){const{authToken:e,...o}=t;return{...o,authToken:e?"***":void 0}}};n.widgets=[],n.messageListened=!1,n.widgetOptions={};let f=n;const D=globalThis;D.MeltingSpot||(D.MeltingSpot={});D.MeltingSpot.Widget=f;exports.Drawer=w;exports.Modal=I;exports.Widget=f;
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Logger as T, getHTMLElement as L, createDialog as P, formatBaseUrl as W, formatUUID as l, trimSlashRight as E, createIframe as U, flattenUtmParameters as y, ConfigurationService as h, parseUtmParameters as C } from "@meltingspot/core";
|
|
2
2
|
import { EmbedFrame as I } from "@meltingspot/embed";
|
|
3
|
-
const M = "1.
|
|
3
|
+
const M = "1.7.0", r = new T({
|
|
4
4
|
appName: "Widget SDK",
|
|
5
5
|
appVersion: M
|
|
6
6
|
});
|
package/index.standalone.js
CHANGED
|
@@ -30,4 +30,4 @@ __p += '`),re&&(I+=`' +
|
|
|
30
30
|
function print() { __p += __j.call(arguments, '') }
|
|
31
31
|
`:`;
|
|
32
32
|
`)+I+`return __p
|
|
33
|
-
}`;var J=cf(function(){return se(c,S+"return "+I).apply(r,l)});if(J.source=I,qo(J))throw J;return J}function y_(e){return ae(e).toLowerCase()}function I_(e){return ae(e).toUpperCase()}function A_(e,t,n){if(e=ae(e),e&&(n||t===r))return vu(e);if(!e||!(t=nt(t)))return e;var i=wt(e),u=wt(t),c=wu(i,u),l=Eu(i,u)+1;return Jt(i,c,l).join("")}function R_(e,t,n){if(e=ae(e),e&&(n||t===r))return e.slice(0,yu(e)+1);if(!e||!(t=nt(t)))return e;var i=wt(e),u=Eu(i,wt(t))+1;return Jt(i,0,u).join("")}function L_(e,t,n){if(e=ae(e),e&&(n||t===r))return e.replace(zi,"");if(!e||!(t=nt(t)))return e;var i=wt(e),u=wu(i,wt(t));return Jt(i,u).join("")}function M_(e,t){var n=ce,i=ie;if(we(t)){var u="separator"in t?t.separator:u;n="length"in t?Z(t.length):n,i="omission"in t?nt(t.omission):i}e=ae(e);var c=e.length;if(An(e)){var l=wt(e);c=l.length}if(n>=c)return e;var h=n-Rn(i);if(h<1)return i;var m=l?Jt(l,0,h).join(""):e.slice(0,h);if(u===r)return m+i;if(l&&(h+=m.length-h),Ko(u)){if(e.slice(h).search(u)){var E,T=m;for(u.global||(u=ao(u.source,ae(Ys.exec(u))+"g")),u.lastIndex=0;E=u.exec(T);)var I=E.index;m=m.slice(0,I===r?h:I)}}else if(e.indexOf(nt(u),h)!=h){var L=m.lastIndexOf(u);L>-1&&(m=m.slice(0,L))}return m+i}function O_(e){return e=ae(e),e&&Wc.test(e)?e.replace(Cs,rh):e}var b_=Sn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Jo=ca("toUpperCase");function ff(e,t,n){return e=ae(e),t=n?r:t,t===r?Vl(e)?sh(e):Bl(e):e.match(t)||[]}var cf=X(function(e,t){try{return et(e,r,t)}catch(n){return qo(n)?n:new B(n)}}),x_=Pt(function(e,t){return at(t,function(n){n=Ot(n),$t(e,n,Go(e[n],e))}),e});function D_(e){var t=e==null?0:e.length,n=P();return e=t?pe(e,function(i){if(typeof i[1]!="function")throw new ft(g);return[n(i[0]),i[1]]}):[],X(function(i){for(var u=-1;++u<t;){var c=e[u];if(et(c[0],this,i))return et(c[1],this,i)}})}function S_(e){return rd(lt(e,U))}function Xo(e){return function(){return e}}function U_(e,t){return e==null||e!==e?t:e}var $_=ha(),N_=ha(!0);function Je(e){return e}function Vo(e){return Hu(typeof e=="function"?e:lt(e,U))}function P_(e){return Gu(lt(e,U))}function C_(e,t){return zu(e,lt(t,U))}var F_=X(function(e,t){return function(n){return Vn(n,e,t)}}),W_=X(function(e,t){return function(n){return Vn(e,n,t)}});function jo(e,t,n){var i=$e(t),u=Xr(t,i);n==null&&!(we(t)&&(u.length||!i.length))&&(n=t,t=e,e=this,u=Xr(t,$e(t)));var c=!(we(n)&&"chain"in n)||!!n.chain,l=Ft(e);return at(u,function(h){var m=t[h];e[h]=m,l&&(e.prototype[h]=function(){var E=this.__chain__;if(c||E){var T=e(this.__wrapped__),I=T.__actions__=Ke(this.__actions__);return I.push({func:m,args:arguments,thisArg:e}),T.__chain__=E,T}return m.apply(e,Gt([this.value()],arguments))})}),e}function Y_(){return Ce._===this&&(Ce._=hh),this}function es(){}function k_(e){return e=Z(e),X(function(t){return qu(t,e)})}var H_=Do(pe),B_=Do(du),G_=Do(to);function lf(e){return Fo(e)?no(Ot(e)):Ed(e)}function z_(e){return function(t){return e==null?r:cn(e,t)}}var q_=ga(),K_=ga(!0);function ts(){return[]}function ns(){return!1}function Q_(){return{}}function Z_(){return""}function J_(){return!0}function X_(e,t){if(e=Z(e),e<1||e>R)return[];var n=V,i=Ye(e,V);t=P(t),e-=V;for(var u=oo(i,t);++n<e;)t(n);return u}function V_(e){return q(e)?pe(e,Ot):rt(e)?[e]:Ke(xa(ae(e)))}function j_(e){var t=++ch;return ae(e)+t}var e0=ri(function(e,t){return e+t},0),t0=So("ceil"),n0=ri(function(e,t){return e/t},1),r0=So("floor");function i0(e){return e&&e.length?Jr(e,Je,_o):r}function o0(e,t){return e&&e.length?Jr(e,P(t,2),_o):r}function s0(e){return mu(e,Je)}function u0(e,t){return mu(e,P(t,2))}function a0(e){return e&&e.length?Jr(e,Je,To):r}function f0(e,t){return e&&e.length?Jr(e,P(t,2),To):r}var c0=ri(function(e,t){return e*t},1),l0=So("round"),h0=ri(function(e,t){return e-t},0);function d0(e){return e&&e.length?io(e,Je):0}function g0(e,t){return e&&e.length?io(e,P(t,2)):0}return a.after=Pp,a.ary=ka,a.assign=Im,a.assignIn=tf,a.assignInWith=mi,a.assignWith=Am,a.at=Rm,a.before=Ha,a.bind=Go,a.bindAll=x_,a.bindKey=Ba,a.castArray=Qp,a.chain=Fa,a.chunk=rg,a.compact=ig,a.concat=og,a.cond=D_,a.conforms=S_,a.constant=Xo,a.countBy=dp,a.create=Lm,a.curry=Ga,a.curryRight=za,a.debounce=qa,a.defaults=Mm,a.defaultsDeep=Om,a.defer=Cp,a.delay=Fp,a.difference=sg,a.differenceBy=ug,a.differenceWith=ag,a.drop=fg,a.dropRight=cg,a.dropRightWhile=lg,a.dropWhile=hg,a.fill=dg,a.filter=pp,a.flatMap=vp,a.flatMapDeep=wp,a.flatMapDepth=Ep,a.flatten=$a,a.flattenDeep=gg,a.flattenDepth=pg,a.flip=Wp,a.flow=$_,a.flowRight=N_,a.fromPairs=mg,a.functions=Nm,a.functionsIn=Pm,a.groupBy=Tp,a.initial=vg,a.intersection=wg,a.intersectionBy=Eg,a.intersectionWith=Tg,a.invert=Fm,a.invertBy=Wm,a.invokeMap=Ip,a.iteratee=Vo,a.keyBy=Ap,a.keys=$e,a.keysIn=Ze,a.map=ci,a.mapKeys=km,a.mapValues=Hm,a.matches=P_,a.matchesProperty=C_,a.memoize=hi,a.merge=Bm,a.mergeWith=nf,a.method=F_,a.methodOf=W_,a.mixin=jo,a.negate=di,a.nthArg=k_,a.omit=Gm,a.omitBy=zm,a.once=Yp,a.orderBy=Rp,a.over=H_,a.overArgs=kp,a.overEvery=B_,a.overSome=G_,a.partial=zo,a.partialRight=Ka,a.partition=Lp,a.pick=qm,a.pickBy=rf,a.property=lf,a.propertyOf=z_,a.pull=Rg,a.pullAll=Pa,a.pullAllBy=Lg,a.pullAllWith=Mg,a.pullAt=Og,a.range=q_,a.rangeRight=K_,a.rearg=Hp,a.reject=bp,a.remove=bg,a.rest=Bp,a.reverse=Ho,a.sampleSize=Dp,a.set=Qm,a.setWith=Zm,a.shuffle=Sp,a.slice=xg,a.sortBy=Np,a.sortedUniq=Cg,a.sortedUniqBy=Fg,a.split=v_,a.spread=Gp,a.tail=Wg,a.take=Yg,a.takeRight=kg,a.takeRightWhile=Hg,a.takeWhile=Bg,a.tap=ip,a.throttle=zp,a.thru=fi,a.toArray=Va,a.toPairs=of,a.toPairsIn=sf,a.toPath=V_,a.toPlainObject=ef,a.transform=Jm,a.unary=qp,a.union=Gg,a.unionBy=zg,a.unionWith=qg,a.uniq=Kg,a.uniqBy=Qg,a.uniqWith=Zg,a.unset=Xm,a.unzip=Bo,a.unzipWith=Ca,a.update=Vm,a.updateWith=jm,a.values=Nn,a.valuesIn=e_,a.without=Jg,a.words=ff,a.wrap=Kp,a.xor=Xg,a.xorBy=Vg,a.xorWith=jg,a.zip=ep,a.zipObject=tp,a.zipObjectDeep=np,a.zipWith=rp,a.entries=of,a.entriesIn=sf,a.extend=tf,a.extendWith=mi,jo(a,a),a.add=e0,a.attempt=cf,a.camelCase=i_,a.capitalize=uf,a.ceil=t0,a.clamp=t_,a.clone=Zp,a.cloneDeep=Xp,a.cloneDeepWith=Vp,a.cloneWith=Jp,a.conformsTo=jp,a.deburr=af,a.defaultTo=U_,a.divide=n0,a.endsWith=o_,a.eq=Tt,a.escape=s_,a.escapeRegExp=u_,a.every=gp,a.find=mp,a.findIndex=Sa,a.findKey=bm,a.findLast=_p,a.findLastIndex=Ua,a.findLastKey=xm,a.floor=r0,a.forEach=Wa,a.forEachRight=Ya,a.forIn=Dm,a.forInRight=Sm,a.forOwn=Um,a.forOwnRight=$m,a.get=Qo,a.gt=em,a.gte=tm,a.has=Cm,a.hasIn=Zo,a.head=Na,a.identity=Je,a.includes=yp,a.indexOf=_g,a.inRange=n_,a.invoke=Ym,a.isArguments=dn,a.isArray=q,a.isArrayBuffer=nm,a.isArrayLike=Qe,a.isArrayLikeObject=ye,a.isBoolean=rm,a.isBuffer=Xt,a.isDate=im,a.isElement=om,a.isEmpty=sm,a.isEqual=um,a.isEqualWith=am,a.isError=qo,a.isFinite=fm,a.isFunction=Ft,a.isInteger=Qa,a.isLength=gi,a.isMap=Za,a.isMatch=cm,a.isMatchWith=lm,a.isNaN=hm,a.isNative=dm,a.isNil=pm,a.isNull=gm,a.isNumber=Ja,a.isObject=we,a.isObjectLike=Ee,a.isPlainObject=ir,a.isRegExp=Ko,a.isSafeInteger=mm,a.isSet=Xa,a.isString=pi,a.isSymbol=rt,a.isTypedArray=$n,a.isUndefined=_m,a.isWeakMap=vm,a.isWeakSet=wm,a.join=yg,a.kebabCase=a_,a.last=dt,a.lastIndexOf=Ig,a.lowerCase=f_,a.lowerFirst=c_,a.lt=Em,a.lte=Tm,a.max=i0,a.maxBy=o0,a.mean=s0,a.meanBy=u0,a.min=a0,a.minBy=f0,a.stubArray=ts,a.stubFalse=ns,a.stubObject=Q_,a.stubString=Z_,a.stubTrue=J_,a.multiply=c0,a.nth=Ag,a.noConflict=Y_,a.noop=es,a.now=li,a.pad=l_,a.padEnd=h_,a.padStart=d_,a.parseInt=g_,a.random=r_,a.reduce=Mp,a.reduceRight=Op,a.repeat=p_,a.replace=m_,a.result=Km,a.round=l0,a.runInContext=p,a.sample=xp,a.size=Up,a.snakeCase=__,a.some=$p,a.sortedIndex=Dg,a.sortedIndexBy=Sg,a.sortedIndexOf=Ug,a.sortedLastIndex=$g,a.sortedLastIndexBy=Ng,a.sortedLastIndexOf=Pg,a.startCase=w_,a.startsWith=E_,a.subtract=h0,a.sum=d0,a.sumBy=g0,a.template=T_,a.times=X_,a.toFinite=Wt,a.toInteger=Z,a.toLength=ja,a.toLower=y_,a.toNumber=gt,a.toSafeInteger=ym,a.toString=ae,a.toUpper=I_,a.trim=A_,a.trimEnd=R_,a.trimStart=L_,a.truncate=M_,a.unescape=O_,a.uniqueId=j_,a.upperCase=b_,a.upperFirst=Jo,a.each=Wa,a.eachRight=Ya,a.first=Na,jo(a,(function(){var e={};return Lt(a,function(t,n){fe.call(a.prototype,n)||(e[n]=t)}),e})(),{chain:!1}),a.VERSION=f,at(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){a[e].placeholder=a}),at(["drop","take"],function(e,t){te.prototype[e]=function(n){n=n===r?1:De(Z(n),0);var i=this.__filtered__&&!t?new te(this):this.clone();return i.__filtered__?i.__takeCount__=Ye(n,i.__takeCount__):i.__views__.push({size:Ye(n,V),type:e+(i.__dir__<0?"Right":"")}),i},te.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),at(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==W||n==M;te.prototype[e]=function(u){var c=this.clone();return c.__iteratees__.push({iteratee:P(u,3),type:n}),c.__filtered__=c.__filtered__||i,c}}),at(["head","last"],function(e,t){var n="take"+(t?"Right":"");te.prototype[e]=function(){return this[n](1).value()[0]}}),at(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");te.prototype[e]=function(){return this.__filtered__?new te(this):this[n](1)}}),te.prototype.compact=function(){return this.filter(Je)},te.prototype.find=function(e){return this.filter(e).head()},te.prototype.findLast=function(e){return this.reverse().find(e)},te.prototype.invokeMap=X(function(e,t){return typeof e=="function"?new te(this):this.map(function(n){return Vn(n,e,t)})}),te.prototype.reject=function(e){return this.filter(di(P(e)))},te.prototype.slice=function(e,t){e=Z(e);var n=this;return n.__filtered__&&(e>0||t<0)?new te(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=Z(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},te.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},te.prototype.toArray=function(){return this.take(V)},Lt(te.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),u=a[i?"take"+(t=="last"?"Right":""):t],c=i||/^find/.test(t);u&&(a.prototype[t]=function(){var l=this.__wrapped__,h=i?[1]:arguments,m=l instanceof te,E=h[0],T=m||q(l),I=function(j){var re=u.apply(a,Gt([j],h));return i&&L?re[0]:re};T&&n&&typeof E=="function"&&E.length!=1&&(m=T=!1);var L=this.__chain__,S=!!this.__actions__.length,C=c&&!L,J=m&&!S;if(!c&&T){l=J?l:new te(this);var F=e.apply(l,h);return F.__actions__.push({func:fi,args:[I],thisArg:r}),new ct(F,L)}return C&&J?e.apply(this,h):(F=this.thru(I),C?i?F.value()[0]:F.value():F)})}),at(["pop","push","shift","sort","splice","unshift"],function(e){var t=Nr[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);a.prototype[e]=function(){var u=arguments;if(i&&!this.__chain__){var c=this.value();return t.apply(q(c)?c:[],u)}return this[n](function(l){return t.apply(q(l)?l:[],u)})}}),Lt(te.prototype,function(e,t){var n=a[t];if(n){var i=n.name+"";fe.call(bn,i)||(bn[i]=[]),bn[i].push({name:t,func:n})}}),bn[ni(r,he).name]=[{name:"wrapper",func:r}],te.prototype.clone=Oh,te.prototype.reverse=bh,te.prototype.value=xh,a.prototype.at=op,a.prototype.chain=sp,a.prototype.commit=up,a.prototype.next=ap,a.prototype.plant=cp,a.prototype.reverse=lp,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=hp,a.prototype.first=a.prototype.head,zn&&(a.prototype[zn]=fp),a}),Ln=uh();on?((on.exports=Ln)._=Ln,Xi._=Ln):Ce._=Ln}).call(tc)})(Fn,Fn.exports)),Fn.exports}nc();const rc="1.6.0";class Ti{constructor(o){this.debug=!1,this.debug=o?.debug??!1,this.appName=o?.appName,this.appVersion=o?.appVersion}log(o,...r){this.debug&&this.print(o,"info",r)}warn(o,...r){this.print(o,"warn",r)}error(o,...r){this.print(o,"error",r)}print(o,r,f){const g=[`[${["MeltingSpot",this.appName,this.appVersion].filter(Boolean).join(" - ")}] ${o}`];f.length&&g.push(...f),console[r](...g)}}const ic=new Ti({appName:"Core SDK",appVersion:rc}),nn=s=>s.toLowerCase().replace(/[^a-z0-9-]/g,""),oc=["/user"],sc=({deeplink:s,spotId:o})=>{try{const r=new URL(s,"https://unused.com");let f=r.pathname;return r.search&&(f+=r.search),r.hash&&(f+=r.hash),oc.some(d=>f.startsWith(d))||(f=`/spot/${o}/${wf(f)}`),f}catch(r){return ic.warn("Failed to parse deeplink URL",r),null}},uc=[/(^|\.)meltingspot\.io$/i],yi=s=>{let o;try{const _=sr(s);o=new URL(_)}catch{throw new Error(`Invalid baseURL: ${s}`)}const r=o.hostname==="localhost"||o.hostname==="127.0.0.1",f=o.protocol==="https:",d=uc.some(_=>_.test(o.hostname));if(!r&&(!f||!d))throw new Error(`Untrusted baseURL origin: ${o.origin}`);return o.origin},ac={msApiBaseUrl:"https://openapi.meltingspot.io/",msCommunityWebBaseUrl:"https://go.meltingspot.io/",ssoToken:void 0,spotId:"",autoJoin:!1,rootDocument:globalThis.document};class Se{constructor(){this.configuration=ac}static getInstance(){return Se.instance||(Se.instance=new Se),Se.instance}setConfiguration(o){this.configuration={...this.configuration,...o}}static getConfiguration(o={}){return{...Se.getInstance().configuration,...o}}}const Ts="%[a-f0-9]{2}",ys=new RegExp("("+Ts+")|([^%]+?)","gi"),Is=new RegExp("("+Ts+")+","gi");function Ii(s,o){try{return[decodeURIComponent(s.join(""))]}catch{}if(s.length===1)return s;o=o||1;const r=s.slice(0,o),f=s.slice(o);return Array.prototype.concat.call([],Ii(r),Ii(f))}function fc(s){try{return decodeURIComponent(s)}catch{let o=s.match(ys)||[];for(let r=1;r<o.length;r++)s=Ii(o,r).join(""),o=s.match(ys)||[];return s}}function cc(s){const o={"%FE%FF":"��","%FF%FE":"��"};let r=Is.exec(s);for(;r;){try{o[r[0]]=decodeURIComponent(r[0])}catch{const d=fc(r[0]);d!==r[0]&&(o[r[0]]=d)}r=Is.exec(s)}o["%C2"]="�";const f=Object.keys(o);for(const d of f)s=s.replace(new RegExp(d,"g"),o[d]);return s}function lc(s){if(typeof s!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof s+"`");try{return decodeURIComponent(s)}catch{return cc(s)}}function hc(s,o){const r={};if(Array.isArray(o))for(const f of o){const d=Object.getOwnPropertyDescriptor(s,f);d?.enumerable&&Object.defineProperty(r,f,d)}else for(const f of Reflect.ownKeys(s)){const d=Object.getOwnPropertyDescriptor(s,f);if(d.enumerable){const _=s[f];o(f,_,s)&&Object.defineProperty(r,f,d)}}return r}function As(s,o){if(!(typeof s=="string"&&typeof o=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(s===""||o==="")return[];const r=s.indexOf(o);return r===-1?[]:[s.slice(0,r),s.slice(r+o.length)]}const dc=s=>s==null,gc=s=>encodeURIComponent(s).replaceAll(/[!'()*]/g,o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`),Ai=Symbol("encodeFragmentIdentifier");function pc(s){switch(s.arrayFormat){case"index":return o=>(r,f)=>{const d=r.length;return f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,[Ae(o,s),"[",d,"]"].join("")]:[...r,[Ae(o,s),"[",Ae(d,s),"]=",Ae(f,s)].join("")]};case"bracket":return o=>(r,f)=>f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,[Ae(o,s),"[]"].join("")]:[...r,[Ae(o,s),"[]=",Ae(f,s)].join("")];case"colon-list-separator":return o=>(r,f)=>f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,[Ae(o,s),":list="].join("")]:[...r,[Ae(o,s),":list=",Ae(f,s)].join("")];case"comma":case"separator":case"bracket-separator":{const o=s.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(f,d)=>d===void 0||s.skipNull&&d===null||s.skipEmptyString&&d===""?f:(d=d===null?"":d,f.length===0?[[Ae(r,s),o,Ae(d,s)].join("")]:[[f,Ae(d,s)].join(s.arrayFormatSeparator)])}default:return o=>(r,f)=>f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,Ae(o,s)]:[...r,[Ae(o,s),"=",Ae(f,s)].join("")]}}function mc(s){let o;switch(s.arrayFormat){case"index":return(r,f,d)=>{if(o=/\[(\d*)]$/.exec(r),r=r.replace(/\[\d*]$/,""),!o){d[r]=f;return}d[r]===void 0&&(d[r]={}),d[r][o[1]]=f};case"bracket":return(r,f,d)=>{if(o=/(\[])$/.exec(r),r=r.replace(/\[]$/,""),!o){d[r]=f;return}if(d[r]===void 0){d[r]=[f];return}d[r]=[...d[r],f]};case"colon-list-separator":return(r,f,d)=>{if(o=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!o){d[r]=f;return}if(d[r]===void 0){d[r]=[f];return}d[r]=[...d[r],f]};case"comma":case"separator":return(r,f,d)=>{const _=typeof f=="string"&&f.includes(s.arrayFormatSeparator),g=typeof f=="string"&&!_&&bt(f,s).includes(s.arrayFormatSeparator);f=g?bt(f,s):f;const y=_||g?f.split(s.arrayFormatSeparator).map(A=>bt(A,s)):f===null?f:bt(f,s);d[r]=y};case"bracket-separator":return(r,f,d)=>{const _=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!_){d[r]=f&&bt(f,s);return}const g=f===null?[]:bt(f,s).split(s.arrayFormatSeparator);if(d[r]===void 0){d[r]=g;return}d[r]=[...d[r],...g]};default:return(r,f,d)=>{if(d[r]===void 0){d[r]=f;return}d[r]=[...[d[r]].flat(),f]}}}function Rs(s){if(typeof s!="string"||s.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function Ae(s,o){return o.encode?o.strict?gc(s):encodeURIComponent(s):s}function bt(s,o){return o.decode?lc(s):s}function Ls(s){return Array.isArray(s)?s.sort():typeof s=="object"?Ls(Object.keys(s)).sort((o,r)=>Number(o)-Number(r)).map(o=>s[o]):s}function Ms(s){const o=s.indexOf("#");return o!==-1&&(s=s.slice(0,o)),s}function _c(s){let o="";const r=s.indexOf("#");return r!==-1&&(o=s.slice(r)),o}function Os(s,o,r){return r==="string"&&typeof s=="string"?s:typeof r=="function"&&typeof s=="string"?r(s):r==="boolean"&&s===null?!0:r==="boolean"&&s!==null&&(s.toLowerCase()==="true"||s.toLowerCase()==="false")?s.toLowerCase()==="true":r==="boolean"&&s!==null&&(s.toLowerCase()==="1"||s.toLowerCase()==="0")?s.toLowerCase()==="1":r==="string[]"&&o.arrayFormat!=="none"&&typeof s=="string"?[s]:r==="number[]"&&o.arrayFormat!=="none"&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?[Number(s)]:r==="number"&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?Number(s):o.parseBooleans&&s!==null&&(s.toLowerCase()==="true"||s.toLowerCase()==="false")?s.toLowerCase()==="true":o.parseNumbers&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?Number(s):s}function Ri(s){s=Ms(s);const o=s.indexOf("?");return o===-1?"":s.slice(o+1)}function Li(s,o){o={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...o},Rs(o.arrayFormatSeparator);const r=mc(o),f=Object.create(null);if(typeof s!="string"||(s=s.trim().replace(/^[?#&]/,""),!s))return f;for(const d of s.split("&")){if(d==="")continue;const _=o.decode?d.replaceAll("+"," "):d;let[g,y]=As(_,"=");g===void 0&&(g=_),y=y===void 0?null:["comma","separator","bracket-separator"].includes(o.arrayFormat)?y:bt(y,o),r(bt(g,o),y,f)}for(const[d,_]of Object.entries(f))if(typeof _=="object"&&_!==null&&o.types[d]!=="string")for(const[g,y]of Object.entries(_)){const A=o.types[d]?o.types[d].replace("[]",""):void 0;_[g]=Os(y,o,A)}else typeof _=="object"&&_!==null&&o.types[d]==="string"?f[d]=Object.values(_).join(o.arrayFormatSeparator):f[d]=Os(_,o,o.types[d]);return o.sort===!1?f:(o.sort===!0?Object.keys(f).sort():Object.keys(f).sort(o.sort)).reduce((d,_)=>{const g=f[_];return d[_]=g&&typeof g=="object"&&!Array.isArray(g)?Ls(g):g,d},Object.create(null))}function bs(s,o){if(!s)return"";o={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...o},Rs(o.arrayFormatSeparator);const r=g=>o.skipNull&&dc(s[g])||o.skipEmptyString&&s[g]==="",f=pc(o),d={};for(const[g,y]of Object.entries(s))r(g)||(d[g]=y);const _=Object.keys(d);return o.sort!==!1&&_.sort(o.sort),_.map(g=>{const y=s[g];return y===void 0?"":y===null?Ae(g,o):Array.isArray(y)?y.length===0&&o.arrayFormat==="bracket-separator"?Ae(g,o)+"[]":y.reduce(f(g),[]).join("&"):Ae(g,o)+"="+Ae(y,o)}).filter(g=>g.length>0).join("&")}function xs(s,o){o={decode:!0,...o};let[r,f]=As(s,"#");return r===void 0&&(r=s),{url:r?.split("?")?.[0]??"",query:Li(Ri(s),o),...o&&o.parseFragmentIdentifier&&f?{fragmentIdentifier:bt(f,o)}:{}}}function Ds(s,o){o={encode:!0,strict:!0,[Ai]:!0,...o};const r=Ms(s.url).split("?")[0]||"",f=Ri(s.url),d={...Li(f,{sort:!1,...o}),...s.query};let _=bs(d,o);_&&=`?${_}`;let g=_c(s.url);if(typeof s.fragmentIdentifier=="string"){const y=new URL(r);y.hash=s.fragmentIdentifier,g=o[Ai]?y.hash:`#${s.fragmentIdentifier}`}return`${r}${_}${g}`}function Ss(s,o,r){r={parseFragmentIdentifier:!0,[Ai]:!1,...r};const{url:f,query:d,fragmentIdentifier:_}=xs(s,r);return Ds({url:f,query:hc(d,o),fragmentIdentifier:_},r)}function vc(s,o,r){const f=Array.isArray(o)?d=>!o.includes(d):(d,_)=>!o(d,_);return Ss(s,f,r)}const wc=Object.freeze(Object.defineProperty({__proto__:null,exclude:vc,extract:Ri,parse:Li,parseUrl:xs,pick:Ss,stringify:bs,stringifyUrl:Ds},Symbol.toStringTag,{value:"Module"}));class qe extends Error{constructor(o,r){super(`HTTP Error ${o}${r?`: ${r}`:""}`),this.code=o,this.name="HttpError",Object.setPrototypeOf(this,qe.prototype)}}var Re=(s=>(s.GET="GET",s.PATCH="PATCH",s.POST="POST",s))(Re||{});class Ec{constructor(){this.headers={}}setHeaders(o){this.headers=o}async get(o){try{const r=o.query?`${o.url}?${this.serializeQuery(o.query)}`:o.url,f=await fetch(r,{headers:{...this.headers,...o.headers,"Content-Type":"application/json"},...o.signal?{signal:o.signal}:{}});return f.ok?oe(await f.json()):G(new qe(f.status,await f.text()))}catch(r){const f=r instanceof Error?r.message:"Unknown error";return G(new qe(st.INTERNAL_SERVER_ERROR,f))}}async post(o){try{const r=await fetch(o.url,{method:"POST",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload),...o.signal?{signal:o.signal}:{}});return r.ok?oe(await r.json()):G(new qe(r.status,await r.text()))}catch(r){const f=r instanceof Error?r.message:"Unknown error";return G(new qe(st.INTERNAL_SERVER_ERROR,f))}}async patch(o){try{const r=await fetch(o.url,{method:"PATCH",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload),...o.signal?{signal:o.signal}:{}});return r.ok?oe(await r.json()):G(new qe(r.status,await r.text()))}catch(r){const f=r instanceof Error?r.message:"Unknown error";return G(new qe(st.INTERNAL_SERVER_ERROR,f))}}serializeQuery(o){if(typeof o=="string")return o;if(typeof o=="object")for(const r in o)o[r]===void 0&&delete o[r];return o=wc.stringify(o,{arrayFormat:"none"}),o}}const Tr={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 Ht extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return Ht.instance||(Ht.instance=new Ht),Ht.instance}async loginWithPassword(o,r){const f=await this.callApi({endpoint:Tr.accessToken.email,method:"POST",body:{email:o,password:r},withSpotId:!0});if(f.isErr())return G(f.error);const{accessToken:d,refreshToken:_}=f.value;return this.setTokens(d.token,_.token),oe({accessToken:d.token,refreshToken:_.token})}async loginWithSsoToken(o){const r=await this.callApi({endpoint:Tr.accessToken.sso.jwt,method:"POST",body:{token:o},withSpotId:!0});if(r.isErr())return G(r.error);const{accessToken:f,refreshToken:d}=r.value;return this.setTokens(f.token,d.token),oe({accessToken:f.token,refreshToken:d.token})}loginWithAuthTokens(o,r){return this.setTokens(o,r),{accessToken:o,refreshToken:r}}resetPassword(o){return this.callApi({endpoint:Tr.password.reset,method:"POST",body:{email:o}})}async refresh(){const o=await this.callApi({endpoint:Tr.refreshAccessToken,method:"POST",body:{refreshToken:this.refreshToken}});if(o.isErr())return G(o.error);const{accessToken:r,refreshToken:f}=o.value;return this.setTokens(r.token,f.token),oe({accessToken:r.token,refreshToken:f.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(o,r){if(this.accessToken!==o||this.refreshToken!==r){this.accessToken=o,this.refreshToken=r;const f=new CustomEvent("auth:tokens-updated",{detail:{accessToken:o,refreshToken:r}});this.dispatchEvent(f)}}async callApi(o){try{const{spotId:r,msApiBaseUrl:f}=Se.getConfiguration(),d=vi(o.endpoint,f),_={"Content-Type":"application/json",...o.headers};o.withSpotId&&r&&(_[Us.SpotId]=r);const g=await fetch(d,{method:o.method,body:o.body?JSON.stringify(o.body):void 0,headers:_});if(!g.ok)return G(new qe(g.status,g.statusText));if(g.status===st.NO_CONTENT)return oe(void 0);const y=await g.json();return oe(y)}catch(r){return G(new qe(st.INTERNAL_SERVER_ERROR,r instanceof Error?r.message:String(r)))}}}var Us=(s=>(s.Authorization="Authorization",s.SpotId="x-spotid",s))(Us||{});class It{constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=Ht.getInstance(),this.httpService=new Ec}static getInstance(){return It.instance||(It.instance=new It),It.instance}static buildAuthenticatedRequest(o){const{msApiBaseUrl:r,spotId:f}=Se.getConfiguration(),d=vi(o,r),_=Ht.getInstance().getAccessToken();if(!_)return G(new Error("Not authenticated"));const g={"Content-Type":"application/json",Authorization:`Bearer ${_}`};return f&&(g["x-spotid"]=f),oe({url:d,headers:g})}static async stream(o,r,f){const{streamTransport:d}=Se.getConfiguration();if(d)return d({endpoint:o,body:r,signal:f});const _=It.buildAuthenticatedRequest(o);if(_.isErr())return G(_.error);const{url:g,headers:y}=_.value;try{const A=await fetch(g,{method:"POST",headers:y,...r!==void 0?{body:JSON.stringify(r)}:{},...f?{signal:f}:{}});if(!A.ok){const $=await A.text();return G(new Error(`HTTP ${A.status}: ${$}`))}return A.body?oe(A.body):G(new Error("Response body is empty"))}catch(A){const $=A instanceof Error?A.message:"Unknown error";return G(A instanceof Error?A:new Error($))}}get pendingCount(){return this.queue.length}enqueue(o){return new Promise(r=>{const f=async()=>{try{const d=await o();r(d)}catch(d){r(G(new qe(st.INTERNAL_SERVER_ERROR,d instanceof Error?d.message:"Unknown error")))}};this.queue.push(f),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){const o=this.queue.shift();if(!o)break;await o()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){const o=this.isPaused;this.isPaused=!1,o&&this.processQueue()}async call(o){return this.enqueue(async()=>{const r=async()=>{const{spotId:d,msApiBaseUrl:_}=Se.getConfiguration(),g={...o.options?.headers??{}};d&&(g["x-spotid"]=d);const y=this.authService.getAccessToken(),{requiresAuth:A=!0}=o;if(!y&&A)return G(new qe(st.UNAUTHORIZED));y&&(g.Authorization=`Bearer ${y}`);const $=vi(o.endpoint,_);switch(o.method){case Re.GET:return this.httpService.get({...o.options??{},headers:g,url:$});case Re.PATCH:return this.httpService.patch({...o.options??{},headers:g,url:$});case Re.POST:return this.httpService.post({...o.options??{},headers:g,url:$});default:return G(new qe(st.METHOD_NOT_ALLOWED,"Method not allowed"))}};let f=await r();if(f.isErr()&&f.error.code===st.UNAUTHORIZED){const d=await this.authService.refresh();if(d.isErr())return G(new qe(st.UNAUTHORIZED,d.error.message));f=await r()}return f})}}const At={playbooks:"/v1/playbooks",pages:s=>`/v1/playbooks/${s}/pages`,hotspots:(s,o)=>`/v1/playbooks/${s}/pages/${o}/hotspots`,hotspot:(s,o,r)=>`/v1/playbooks/${s}/pages/${o}/hotspots/${r}`,accessibleIntents:(s,o)=>`/v1/playbooks/${s}/pages/${o}/accessibleIntents`,intents:(s,o,r)=>`/v1/playbooks/${s}/pages/${o}/hotspots/${r}/intents`,intent:(s,o,r,f)=>`/v1/playbooks/${s}/pages/${o}/hotspots/${r}/intents/${f}`},yr=50;class gn{static getInstance(){return gn.instance||(gn.instance=new gn),gn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async listPlaybooks(o){const r=await this.meltingSpotApi.call({method:Re.GET,endpoint:At.playbooks,options:{query:{page:o?.page??1,limit:o?.limit??yr,...o?.domain?{"domain[eq]":o.domain}:{}}}});return r.isErr()?G(r.error):oe(r.value)}async listPlaybookPages(o){const r=await this.meltingSpotApi.call({method:Re.GET,endpoint:At.pages(o.playbookId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.url?{"url[eq]":o.url}:{}}}});return r.isErr()?G(r.error):oe(r.value)}async createPlaybookPage(o,r){const f=await this.meltingSpotApi.call({method:Re.POST,endpoint:At.pages(o.playbookId),options:{payload:r}});return f.isErr()?G(f.error):oe(f.value)}async listAccessiblePlaybookIntents(o){const r=await this.meltingSpotApi.call({method:Re.GET,endpoint:At.accessibleIntents(o.playbookId,o.pageId),options:{query:{...o.domain?{domain:o.domain}:{}}}});return r.isErr()?G(r.error):oe(r.value)}async listPlaybookHotspots(o){const r=await this.meltingSpotApi.call({method:Re.GET,endpoint:At.hotspots(o.playbookId,o.pageId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.intentStatus?{"intentStatus[eq]":o.intentStatus}:{},...o.widgetType?{"widgetType[eq]":o.widgetType}:{}}}});return r.isErr()?G(r.error):oe(r.value)}async createPlaybookHotspot(o,r){const f=await this.meltingSpotApi.call({method:Re.POST,endpoint:At.hotspots(o.playbookId,o.pageId),options:{payload:r}});return f.isErr()?G(f.error):oe(f.value)}async updatePlaybookHotspot(o,r){const f=await this.meltingSpotApi.call({method:Re.PATCH,endpoint:At.hotspot(o.playbookId,o.pageId,o.hotspotId),options:{payload:r}});return f.isErr()?G(f.error):oe(f.value)}async listPlaybookIntents(o){const r=await this.meltingSpotApi.call({method:Re.GET,endpoint:At.intents(o.playbookId,o.pageId,o.hotspotId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.status?{"status[eq]":o.status}:{}}}});return r.isErr()?G(r.error):oe(r.value)}async createPlaybookIntent(o,r){const f=await this.meltingSpotApi.call({method:Re.POST,endpoint:At.intents(o.playbookId,o.pageId,o.hotspotId),options:{payload:r}});return f.isErr()?G(f.error):oe(f.value)}async updatePlaybookIntent(o,r){const f=await this.meltingSpotApi.call({method:Re.PATCH,endpoint:At.intent(o.playbookId,o.pageId,o.hotspotId,o.intentId),options:{payload:r}});return f.isErr()?G(f.error):oe(f.value)}}const Tc={me:"/v1/spots/me"},yc=50;class pn{static getInstance(){return pn.instance||(pn.instance=new pn),pn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async listSpotsForMe(o){const r=await this.meltingSpotApi.call({method:Re.GET,endpoint:Tc.me,options:{query:{page:1,limit:yc,...o?.spotMemberRole?{"spotMemberRole[eq]":o.spotMemberRole}:{}}}});return r.isErr()?G(r.error):oe(r.value)}}const Mi={spotMember:{me:"/v1/spotMembers/me",joinFromSso:"/v1/spotMembers~joinFromSso",search:"/v1/spotMembers~search"}};class mn{static getInstance(){return mn.instance||(mn.instance=new mn),mn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async getSpotMemberForMe(){const o=await this.meltingSpotApi.call({method:Re.GET,endpoint:Mi.spotMember.me});return o.isErr()?G(o.error):oe(o.value)}async searchSpotMembers(o){const r={page:o.page,limit:o.limit};o.search&&(r.search=o.search);const f=await this.meltingSpotApi.call({method:Re.GET,endpoint:Mi.spotMember.search,options:{query:r}});return f.isErr()?G(f.error):oe(f.value)}async joinFromSso(o){const r=await this.meltingSpotApi.call({method:Re.POST,endpoint:Mi.spotMember.joinFromSso,options:{payload:{token:o}}});return r.isErr()?G(r.error):oe(r.value)}}const $s={spotMemberSsoToken:"/v1/spotMembers/auth/sso/jwt",previewAccessKey:"/v1/spotMembers/auth/preview/accessKey"};class _n{static getInstance(){return _n.instance||(_n.instance=new _n),_n.instance}constructor(){this.meltingSpotApi=It.getInstance()}async generateSsoToken(){const o=await this.meltingSpotApi.call({method:Re.POST,endpoint:$s.spotMemberSsoToken,options:{payload:{}}});return o.isErr()?G(o.error):oe(o.value.token)}async generatePreviewAccessKey(o){const r=await this.meltingSpotApi.call({method:Re.POST,endpoint:$s.previewAccessKey,options:{payload:{targetSpotMemberId:o.targetSpotMemberId}}});return r.isErr()?G(r.error):oe(r.value)}}class vn{static getInstance(){return vn.instance||(vn.instance=new vn),vn.instance}constructor(){this.spotMemberAuthApiService=_n.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}}const Oi=s=>{const o=s.get("utm_source");if(o)return{source:o,medium:s.get("utm_medium")??void 0,campaign:s.get("utm_campaign")??void 0,term:s.get("utm_term")??void 0,content:s.get("utm_content")??void 0}},bi=s=>s?Object.entries(s).reduce((o,[r,f])=>(f!=null&&(o[`utm_${r}`]=f),o),{}):{},Ic=Se.getInstance(),Ac=Ht.getInstance(),Rc=vn.getInstance(),Lc={Playbook:gn.getInstance(),Spot:pn.getInstance(),SpotMember:mn.getInstance()},wn=globalThis;wn.MeltingSpot||(wn.MeltingSpot={}),wn.MeltingSpot.Configuration=Ic,wn.MeltingSpot.Auth=Ac,wn.MeltingSpot.Sso=Rc,wn.MeltingSpot.Api=Lc;const Mc="1.6.0",xi=new Ti({appName:"Embed SDK",appVersion:Mc});class Ir{constructor(o){this.content=o}#e=null;#t=null;set onRemove(o){this.#t=o}inject(o){this.remove();const r=wi({input:o,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add("ms-embed"),r.appendChild(this.#e)}remove(){this.#e&&(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),this.#e=null)}}class Oc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.deeplink=o.deeplink?sc({deeplink:o.deeplink,spotId:this.spotId}):null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",r=new URL(`/spot/${this.spotId}${o}`,sr(this.baseURL)),f=Ei({url:r,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...bi(this.utmParameters)},rootDocument:this.rootDocument});return f.classList.add("ms-spot"),f}}const Di={READY:"meltingspot:ready",ERROR:"meltingspot:error"},Oe=class Oe{static injectSpotInto(o,r){const{onReady:f,onError:d,..._}=r,{spotId:g,rootDocument:y,msCommunityWebBaseUrl:A}=Se.getConfiguration({spotId:_.spotId,rootDocument:_.rootDocument,msCommunityWebBaseUrl:_.baseURL});if(!g)throw xi.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const $=new URLSearchParams(window.location.search),H={spotId:g,authToken:_.authToken??$.get("ms_token"),domain:_.domain,deeplink:_.deeplink??$.get("ms_url"),themeMode:_.themeMode,utmParameters:_.utmParameters??Oi($),baseURL:A,rootDocument:y},U=new Ir(new Oc(H));if(U.inject(o),Oe.embeds.push(U),f||d){const N=U.content.iframe.contentWindow;N&&(Oe.iframeCallbacks.set(N,{onReady:f,onError:d}),U.onRemove=K=>{Oe.iframeCallbacks.delete(K)}),Oe.ensureMessageListener()}return xi.log("Spot injected",H,o),U}static clear(){Oe.embeds.forEach(o=>{o.remove()}),Oe.embeds=[],Oe.iframeCallbacks.clear(),Oe.messageListened&&(window.removeEventListener("message",Oe.handleMessageEvent),Oe.messageListened=!1),xi.log("All MeltingSpot embeds cleared")}static handleMessageEvent(o){if(!o.data||typeof o.data!="object"||o.data.type!==Di.READY&&o.data.type!==Di.ERROR)return;const r=o.source,f=Oe.iframeCallbacks.get(r);if(!f)return;const{msCommunityWebBaseUrl:d}=Se.getConfiguration({});if(d)try{const _=new URL(d).origin;if(o.origin!==_)return}catch{}o.data.type===Di.READY?f.onReady?.():f.onError?.(o.data.error)}static ensureMessageListener(){Oe.messageListened||(window.addEventListener("message",Oe.handleMessageEvent),Oe.messageListened=!0)}};Oe.embeds=[],Oe.messageListened=!1,Oe.iframeCallbacks=new Map;let Si=Oe;const Ui=globalThis;Ui.MeltingSpot||(Ui.MeltingSpot={}),Ui.MeltingSpot.Embed=Si;const bc="1.6.0",He=new Ti({appName:"Widget SDK",appVersion:bc});class Ns{constructor(o,r,f){this.content=o,this.rootDocument=r,this.dialogClassname=f,this.dialogElement=null,this.triggerElement=null,this.iframeElement=null,this.currentListener=null}inject({into:o,bind:r,options:f}){this.remove();const d=wi({input:o,rootDocument:this.rootDocument});if(this.dialogElement=Tf(this.rootDocument),this.dialogElement.classList.add(this.dialogClassname),this.dialogElement.onclose=()=>this.#t(),d.appendChild(this.dialogElement),r){this.triggerElement=wi({input:r,rootDocument:this.rootDocument});const _=this.open.bind(this,f);this.currentListener=g=>{g.stopPropagation(),g.preventDefault(),_()},this.triggerElement.addEventListener("click",this.currentListener)}}remove(){this.dialogElement&&(this.dialogElement.remove(),this.dialogElement.onclose=null,this.dialogElement=null),this.triggerElement&&(this.currentListener&&this.triggerElement.removeEventListener("click",this.currentListener),this.triggerElement=null,this.currentListener=null)}open(o){this.dialogElement||this.inject({into:this.rootDocument.body}),this.dialogElement&&(this.#e(),this.dialogElement.showModal())}close(){this.dialogElement&&this.dialogElement.close()}#e(){this.dialogElement&&(this.iframeElement=this.dialogElement.appendChild(this.content.iframe))}#t(){this.iframeElement&&(this.iframeElement.remove(),this.iframeElement=null)}}class Ar extends Ns{constructor(o,r){super(o,r,"ms-drawer")}open(o){const{position:r="right"}=o??{};super.open(o),this.dialogElement&&(this.dialogElement.dataset.position=r)}}class Rr extends Ns{constructor(o,r){super(o,r,"ms-modal")}}class xc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.widgetId=nn(o.widgetId),this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=new URL(`/widgets/spot/${this.spotId}/widget/${this.widgetId}`,sr(this.baseURL)),r=Ei({url:o,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,...bi(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add("ms-widget"),r}}class Dc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.widgetContentId=nn(o.widgetContentId),this.contentId=nn(o.contentId),this.widgetId=nn(o.widgetId),this.contentType=o.contentType,this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=new URL(`/widgets/spot/${this.spotId}/widgetContent/${this.widgetContentId}`,sr(this.baseURL));o.searchParams.set("widgetId",this.widgetId);const r=Ei({url:o,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,contentId:this.contentId,contentType:this.contentType,...bi(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add("ms-widget-content"),r}}const ee=class ee{static injectWidgetInto(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=Se.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument,msCommunityWebBaseUrl:r.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widget:g,args:y}=ee.createWidget({...r,spotId:f,rootDocument:d,baseURL:_}),A=new Ir(g);return A.inject(o),ee.widgets.push(A),He.log("Widget injected",ee.cleanupLoggedArgs(y),o),A}static injectWidgetContentInto(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=Se.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument,msCommunityWebBaseUrl:r.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widgetContent:g,args:y}=ee.createWidgetContent({...r,spotId:f,rootDocument:d,baseURL:_}),A=new Ir(g);return A.inject(o),ee.widgets.push(A),He.log("WidgetContent injected",ee.cleanupLoggedArgs(y),o),A}static bindWidgetModalTo(o,r){return ee.bindEntityModalTo(o,{type:"Widget",data:r})}static bindWidgetDrawerTo(o,r){return ee.bindEntityDrawerTo(o,{type:"Widget",data:r})}static createWidgetDrawer(o){const{widget:r}=ee.createWidget(o);return He.log("Create Widget drawer",{data:ee.cleanupLoggedArgs(o)}),new Ar(r,o.rootDocument??document)}static createWidgetModal(o){const{widget:r}=ee.createWidget(o);return He.log("Create Widget modal",{data:ee.cleanupLoggedArgs(o)}),new Rr(r,o.rootDocument??document)}static createWidgetEmbed(o){const{widget:r}=ee.createWidget(o),f=new Ir(r);return He.log("Create Widget embed",{data:ee.cleanupLoggedArgs(o)}),f}static clear(){ee.widgets.forEach(o=>{o.remove()}),ee.widgets=[],ee.widgetOptions={},He.log("All Widget SDK MeltingSpot elements were cleared")}static bindEntityDrawerTo(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=Se.getConfiguration({spotId:r.data.spotId,rootDocument:r.data.rootDocument??document,msCommunityWebBaseUrl:r.data.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let g,y;switch(r.type){case"Widget":{const U=ee.createWidget({...r.data,spotId:f,rootDocument:d,baseURL:_});g=U.widget,y=U.args}break;case"WidgetContent":{const U=ee.createWidgetContent({...r.data,spotId:f,rootDocument:d,baseURL:_});g=U.widgetContent,y=U.args}}const A=new Ar(g,d),$={position:r.data.position},H=r.data.into??d.body;return A.inject({into:H,bind:o,options:$}),ee.widgets.push(A),He.log("Widget bound to drawer",ee.cleanupLoggedArgs(y),$,H,o),A}static bindEntityModalTo(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=Se.getConfiguration({spotId:r.data.spotId,rootDocument:r.data.rootDocument??document,msCommunityWebBaseUrl:r.data.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let g,y;switch(r.type){case"Widget":{const H=ee.createWidget({...r.data,spotId:f,rootDocument:d,baseURL:_});g=H.widget,y=H.args}break;case"WidgetContent":{const H=ee.createWidgetContent({...r.data,spotId:f,rootDocument:d,baseURL:_});g=H.widgetContent,y=H.args}}const A=new Rr(g,d),$=r.data.into??d.body;return A.inject({into:$,bind:o}),ee.widgets.push(A),He.log("Widget bound to modal",ee.cleanupLoggedArgs(y),$,o),A}static handleMessageEvent(o){if(!o.data||typeof o.data!="object"||o.data.type!=="OpenWidgetContent")return;const r=o.data?.widgetId;if(!r||typeof r!="string"){He.error("widgetId is required in the message event data");return}const f=ee.widgetOptions[r];if(!f){He.error("No widget options found for widgetId",{widgetId:r});return}let d=null;try{d=new URL(f.baseURL).origin}catch{d=null}if(!d||o.origin!==d){He.warn("Ignoring OpenWidgetContent from unexpected origin",{origin:o.origin,expectedOrigin:d});return}const{spotId:_,rootDocument:g,msCommunityWebBaseUrl:y}=Se.getConfiguration({spotId:f.spotId,rootDocument:f.rootDocument??document,msCommunityWebBaseUrl:f.baseURL}),{widgetContent:A}=ee.createWidgetContent({...f,widgetContentId:o.data.widgetContentId,contentType:o.data.contentType,contentId:o.data.contentId,widgetId:r,spotId:_,rootDocument:g,baseURL:y});o.data.openingIn==="Drawer"?new Ar(A,g).open():o.data.openingIn==="Modal"&&new Rr(A,g).open()}static createWidget(o){const r=new URLSearchParams(window.location.search),f={spotId:o.spotId,widgetId:o.widgetId,authToken:o.authToken,themeMode:o.themeMode,domain:o.domain,rootDocument:o.rootDocument,baseURL:o.baseURL,utmParameters:o.utmParameters??Oi(r)};return ee.widgetOptions[f.widgetId]=f,ee.messageListened||(window.addEventListener("message",ee.handleMessageEvent),ee.messageListened=!0),{widget:new xc(f),args:f}}static createWidgetContent(o){const r=new URLSearchParams(window.location.search),f={spotId:o.spotId,contentId:o.contentId,contentType:o.contentType,widgetContentId:o.widgetContentId,widgetId:o.widgetId,authToken:o.authToken,themeMode:o.themeMode,domain:o.domain,rootDocument:o.rootDocument,baseURL:o.baseURL,utmParameters:o.utmParameters??Oi(r)};return{widgetContent:new Dc(f),args:f}}static cleanupLoggedArgs(o){const{authToken:r,...f}=o;return{...f,authToken:r?"***":void 0}}};ee.widgets=[],ee.messageListened=!1,ee.widgetOptions={};let Lr=ee;const $i=globalThis;$i.MeltingSpot||($i.MeltingSpot={}),$i.MeltingSpot.Widget=Lr,kt.Drawer=Ar,kt.Modal=Rr,kt.Widget=Lr,Object.defineProperty(kt,Symbol.toStringTag,{value:"Module"})}));
|
|
33
|
+
}`;var J=cf(function(){return se(c,S+"return "+I).apply(r,l)});if(J.source=I,qo(J))throw J;return J}function y_(e){return ae(e).toLowerCase()}function I_(e){return ae(e).toUpperCase()}function A_(e,t,n){if(e=ae(e),e&&(n||t===r))return vu(e);if(!e||!(t=nt(t)))return e;var i=wt(e),u=wt(t),c=wu(i,u),l=Eu(i,u)+1;return Jt(i,c,l).join("")}function R_(e,t,n){if(e=ae(e),e&&(n||t===r))return e.slice(0,yu(e)+1);if(!e||!(t=nt(t)))return e;var i=wt(e),u=Eu(i,wt(t))+1;return Jt(i,0,u).join("")}function L_(e,t,n){if(e=ae(e),e&&(n||t===r))return e.replace(zi,"");if(!e||!(t=nt(t)))return e;var i=wt(e),u=wu(i,wt(t));return Jt(i,u).join("")}function M_(e,t){var n=ce,i=ie;if(we(t)){var u="separator"in t?t.separator:u;n="length"in t?Z(t.length):n,i="omission"in t?nt(t.omission):i}e=ae(e);var c=e.length;if(An(e)){var l=wt(e);c=l.length}if(n>=c)return e;var h=n-Rn(i);if(h<1)return i;var m=l?Jt(l,0,h).join(""):e.slice(0,h);if(u===r)return m+i;if(l&&(h+=m.length-h),Ko(u)){if(e.slice(h).search(u)){var E,T=m;for(u.global||(u=ao(u.source,ae(Ys.exec(u))+"g")),u.lastIndex=0;E=u.exec(T);)var I=E.index;m=m.slice(0,I===r?h:I)}}else if(e.indexOf(nt(u),h)!=h){var L=m.lastIndexOf(u);L>-1&&(m=m.slice(0,L))}return m+i}function O_(e){return e=ae(e),e&&Wc.test(e)?e.replace(Cs,rh):e}var b_=Sn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Jo=ca("toUpperCase");function ff(e,t,n){return e=ae(e),t=n?r:t,t===r?Vl(e)?sh(e):Bl(e):e.match(t)||[]}var cf=X(function(e,t){try{return et(e,r,t)}catch(n){return qo(n)?n:new B(n)}}),x_=Pt(function(e,t){return at(t,function(n){n=Ot(n),$t(e,n,Go(e[n],e))}),e});function D_(e){var t=e==null?0:e.length,n=P();return e=t?pe(e,function(i){if(typeof i[1]!="function")throw new ft(g);return[n(i[0]),i[1]]}):[],X(function(i){for(var u=-1;++u<t;){var c=e[u];if(et(c[0],this,i))return et(c[1],this,i)}})}function S_(e){return rd(lt(e,U))}function Xo(e){return function(){return e}}function U_(e,t){return e==null||e!==e?t:e}var $_=ha(),N_=ha(!0);function Je(e){return e}function Vo(e){return Hu(typeof e=="function"?e:lt(e,U))}function P_(e){return Gu(lt(e,U))}function C_(e,t){return zu(e,lt(t,U))}var F_=X(function(e,t){return function(n){return Vn(n,e,t)}}),W_=X(function(e,t){return function(n){return Vn(e,n,t)}});function jo(e,t,n){var i=$e(t),u=Xr(t,i);n==null&&!(we(t)&&(u.length||!i.length))&&(n=t,t=e,e=this,u=Xr(t,$e(t)));var c=!(we(n)&&"chain"in n)||!!n.chain,l=Ft(e);return at(u,function(h){var m=t[h];e[h]=m,l&&(e.prototype[h]=function(){var E=this.__chain__;if(c||E){var T=e(this.__wrapped__),I=T.__actions__=Ke(this.__actions__);return I.push({func:m,args:arguments,thisArg:e}),T.__chain__=E,T}return m.apply(e,Gt([this.value()],arguments))})}),e}function Y_(){return Ce._===this&&(Ce._=hh),this}function es(){}function k_(e){return e=Z(e),X(function(t){return qu(t,e)})}var H_=Do(pe),B_=Do(du),G_=Do(to);function lf(e){return Fo(e)?no(Ot(e)):Ed(e)}function z_(e){return function(t){return e==null?r:cn(e,t)}}var q_=ga(),K_=ga(!0);function ts(){return[]}function ns(){return!1}function Q_(){return{}}function Z_(){return""}function J_(){return!0}function X_(e,t){if(e=Z(e),e<1||e>R)return[];var n=V,i=Ye(e,V);t=P(t),e-=V;for(var u=oo(i,t);++n<e;)t(n);return u}function V_(e){return q(e)?pe(e,Ot):rt(e)?[e]:Ke(xa(ae(e)))}function j_(e){var t=++ch;return ae(e)+t}var e0=ri(function(e,t){return e+t},0),t0=So("ceil"),n0=ri(function(e,t){return e/t},1),r0=So("floor");function i0(e){return e&&e.length?Jr(e,Je,_o):r}function o0(e,t){return e&&e.length?Jr(e,P(t,2),_o):r}function s0(e){return mu(e,Je)}function u0(e,t){return mu(e,P(t,2))}function a0(e){return e&&e.length?Jr(e,Je,To):r}function f0(e,t){return e&&e.length?Jr(e,P(t,2),To):r}var c0=ri(function(e,t){return e*t},1),l0=So("round"),h0=ri(function(e,t){return e-t},0);function d0(e){return e&&e.length?io(e,Je):0}function g0(e,t){return e&&e.length?io(e,P(t,2)):0}return a.after=Pp,a.ary=ka,a.assign=Im,a.assignIn=tf,a.assignInWith=mi,a.assignWith=Am,a.at=Rm,a.before=Ha,a.bind=Go,a.bindAll=x_,a.bindKey=Ba,a.castArray=Qp,a.chain=Fa,a.chunk=rg,a.compact=ig,a.concat=og,a.cond=D_,a.conforms=S_,a.constant=Xo,a.countBy=dp,a.create=Lm,a.curry=Ga,a.curryRight=za,a.debounce=qa,a.defaults=Mm,a.defaultsDeep=Om,a.defer=Cp,a.delay=Fp,a.difference=sg,a.differenceBy=ug,a.differenceWith=ag,a.drop=fg,a.dropRight=cg,a.dropRightWhile=lg,a.dropWhile=hg,a.fill=dg,a.filter=pp,a.flatMap=vp,a.flatMapDeep=wp,a.flatMapDepth=Ep,a.flatten=$a,a.flattenDeep=gg,a.flattenDepth=pg,a.flip=Wp,a.flow=$_,a.flowRight=N_,a.fromPairs=mg,a.functions=Nm,a.functionsIn=Pm,a.groupBy=Tp,a.initial=vg,a.intersection=wg,a.intersectionBy=Eg,a.intersectionWith=Tg,a.invert=Fm,a.invertBy=Wm,a.invokeMap=Ip,a.iteratee=Vo,a.keyBy=Ap,a.keys=$e,a.keysIn=Ze,a.map=ci,a.mapKeys=km,a.mapValues=Hm,a.matches=P_,a.matchesProperty=C_,a.memoize=hi,a.merge=Bm,a.mergeWith=nf,a.method=F_,a.methodOf=W_,a.mixin=jo,a.negate=di,a.nthArg=k_,a.omit=Gm,a.omitBy=zm,a.once=Yp,a.orderBy=Rp,a.over=H_,a.overArgs=kp,a.overEvery=B_,a.overSome=G_,a.partial=zo,a.partialRight=Ka,a.partition=Lp,a.pick=qm,a.pickBy=rf,a.property=lf,a.propertyOf=z_,a.pull=Rg,a.pullAll=Pa,a.pullAllBy=Lg,a.pullAllWith=Mg,a.pullAt=Og,a.range=q_,a.rangeRight=K_,a.rearg=Hp,a.reject=bp,a.remove=bg,a.rest=Bp,a.reverse=Ho,a.sampleSize=Dp,a.set=Qm,a.setWith=Zm,a.shuffle=Sp,a.slice=xg,a.sortBy=Np,a.sortedUniq=Cg,a.sortedUniqBy=Fg,a.split=v_,a.spread=Gp,a.tail=Wg,a.take=Yg,a.takeRight=kg,a.takeRightWhile=Hg,a.takeWhile=Bg,a.tap=ip,a.throttle=zp,a.thru=fi,a.toArray=Va,a.toPairs=of,a.toPairsIn=sf,a.toPath=V_,a.toPlainObject=ef,a.transform=Jm,a.unary=qp,a.union=Gg,a.unionBy=zg,a.unionWith=qg,a.uniq=Kg,a.uniqBy=Qg,a.uniqWith=Zg,a.unset=Xm,a.unzip=Bo,a.unzipWith=Ca,a.update=Vm,a.updateWith=jm,a.values=Nn,a.valuesIn=e_,a.without=Jg,a.words=ff,a.wrap=Kp,a.xor=Xg,a.xorBy=Vg,a.xorWith=jg,a.zip=ep,a.zipObject=tp,a.zipObjectDeep=np,a.zipWith=rp,a.entries=of,a.entriesIn=sf,a.extend=tf,a.extendWith=mi,jo(a,a),a.add=e0,a.attempt=cf,a.camelCase=i_,a.capitalize=uf,a.ceil=t0,a.clamp=t_,a.clone=Zp,a.cloneDeep=Xp,a.cloneDeepWith=Vp,a.cloneWith=Jp,a.conformsTo=jp,a.deburr=af,a.defaultTo=U_,a.divide=n0,a.endsWith=o_,a.eq=Tt,a.escape=s_,a.escapeRegExp=u_,a.every=gp,a.find=mp,a.findIndex=Sa,a.findKey=bm,a.findLast=_p,a.findLastIndex=Ua,a.findLastKey=xm,a.floor=r0,a.forEach=Wa,a.forEachRight=Ya,a.forIn=Dm,a.forInRight=Sm,a.forOwn=Um,a.forOwnRight=$m,a.get=Qo,a.gt=em,a.gte=tm,a.has=Cm,a.hasIn=Zo,a.head=Na,a.identity=Je,a.includes=yp,a.indexOf=_g,a.inRange=n_,a.invoke=Ym,a.isArguments=dn,a.isArray=q,a.isArrayBuffer=nm,a.isArrayLike=Qe,a.isArrayLikeObject=ye,a.isBoolean=rm,a.isBuffer=Xt,a.isDate=im,a.isElement=om,a.isEmpty=sm,a.isEqual=um,a.isEqualWith=am,a.isError=qo,a.isFinite=fm,a.isFunction=Ft,a.isInteger=Qa,a.isLength=gi,a.isMap=Za,a.isMatch=cm,a.isMatchWith=lm,a.isNaN=hm,a.isNative=dm,a.isNil=pm,a.isNull=gm,a.isNumber=Ja,a.isObject=we,a.isObjectLike=Ee,a.isPlainObject=ir,a.isRegExp=Ko,a.isSafeInteger=mm,a.isSet=Xa,a.isString=pi,a.isSymbol=rt,a.isTypedArray=$n,a.isUndefined=_m,a.isWeakMap=vm,a.isWeakSet=wm,a.join=yg,a.kebabCase=a_,a.last=dt,a.lastIndexOf=Ig,a.lowerCase=f_,a.lowerFirst=c_,a.lt=Em,a.lte=Tm,a.max=i0,a.maxBy=o0,a.mean=s0,a.meanBy=u0,a.min=a0,a.minBy=f0,a.stubArray=ts,a.stubFalse=ns,a.stubObject=Q_,a.stubString=Z_,a.stubTrue=J_,a.multiply=c0,a.nth=Ag,a.noConflict=Y_,a.noop=es,a.now=li,a.pad=l_,a.padEnd=h_,a.padStart=d_,a.parseInt=g_,a.random=r_,a.reduce=Mp,a.reduceRight=Op,a.repeat=p_,a.replace=m_,a.result=Km,a.round=l0,a.runInContext=p,a.sample=xp,a.size=Up,a.snakeCase=__,a.some=$p,a.sortedIndex=Dg,a.sortedIndexBy=Sg,a.sortedIndexOf=Ug,a.sortedLastIndex=$g,a.sortedLastIndexBy=Ng,a.sortedLastIndexOf=Pg,a.startCase=w_,a.startsWith=E_,a.subtract=h0,a.sum=d0,a.sumBy=g0,a.template=T_,a.times=X_,a.toFinite=Wt,a.toInteger=Z,a.toLength=ja,a.toLower=y_,a.toNumber=gt,a.toSafeInteger=ym,a.toString=ae,a.toUpper=I_,a.trim=A_,a.trimEnd=R_,a.trimStart=L_,a.truncate=M_,a.unescape=O_,a.uniqueId=j_,a.upperCase=b_,a.upperFirst=Jo,a.each=Wa,a.eachRight=Ya,a.first=Na,jo(a,(function(){var e={};return Lt(a,function(t,n){fe.call(a.prototype,n)||(e[n]=t)}),e})(),{chain:!1}),a.VERSION=f,at(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){a[e].placeholder=a}),at(["drop","take"],function(e,t){te.prototype[e]=function(n){n=n===r?1:De(Z(n),0);var i=this.__filtered__&&!t?new te(this):this.clone();return i.__filtered__?i.__takeCount__=Ye(n,i.__takeCount__):i.__views__.push({size:Ye(n,V),type:e+(i.__dir__<0?"Right":"")}),i},te.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),at(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==W||n==M;te.prototype[e]=function(u){var c=this.clone();return c.__iteratees__.push({iteratee:P(u,3),type:n}),c.__filtered__=c.__filtered__||i,c}}),at(["head","last"],function(e,t){var n="take"+(t?"Right":"");te.prototype[e]=function(){return this[n](1).value()[0]}}),at(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");te.prototype[e]=function(){return this.__filtered__?new te(this):this[n](1)}}),te.prototype.compact=function(){return this.filter(Je)},te.prototype.find=function(e){return this.filter(e).head()},te.prototype.findLast=function(e){return this.reverse().find(e)},te.prototype.invokeMap=X(function(e,t){return typeof e=="function"?new te(this):this.map(function(n){return Vn(n,e,t)})}),te.prototype.reject=function(e){return this.filter(di(P(e)))},te.prototype.slice=function(e,t){e=Z(e);var n=this;return n.__filtered__&&(e>0||t<0)?new te(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=Z(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},te.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},te.prototype.toArray=function(){return this.take(V)},Lt(te.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),u=a[i?"take"+(t=="last"?"Right":""):t],c=i||/^find/.test(t);u&&(a.prototype[t]=function(){var l=this.__wrapped__,h=i?[1]:arguments,m=l instanceof te,E=h[0],T=m||q(l),I=function(j){var re=u.apply(a,Gt([j],h));return i&&L?re[0]:re};T&&n&&typeof E=="function"&&E.length!=1&&(m=T=!1);var L=this.__chain__,S=!!this.__actions__.length,C=c&&!L,J=m&&!S;if(!c&&T){l=J?l:new te(this);var F=e.apply(l,h);return F.__actions__.push({func:fi,args:[I],thisArg:r}),new ct(F,L)}return C&&J?e.apply(this,h):(F=this.thru(I),C?i?F.value()[0]:F.value():F)})}),at(["pop","push","shift","sort","splice","unshift"],function(e){var t=Nr[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);a.prototype[e]=function(){var u=arguments;if(i&&!this.__chain__){var c=this.value();return t.apply(q(c)?c:[],u)}return this[n](function(l){return t.apply(q(l)?l:[],u)})}}),Lt(te.prototype,function(e,t){var n=a[t];if(n){var i=n.name+"";fe.call(bn,i)||(bn[i]=[]),bn[i].push({name:t,func:n})}}),bn[ni(r,he).name]=[{name:"wrapper",func:r}],te.prototype.clone=Oh,te.prototype.reverse=bh,te.prototype.value=xh,a.prototype.at=op,a.prototype.chain=sp,a.prototype.commit=up,a.prototype.next=ap,a.prototype.plant=cp,a.prototype.reverse=lp,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=hp,a.prototype.first=a.prototype.head,zn&&(a.prototype[zn]=fp),a}),Ln=uh();on?((on.exports=Ln)._=Ln,Xi._=Ln):Ce._=Ln}).call(tc)})(Fn,Fn.exports)),Fn.exports}nc();const rc="1.7.0";class Ti{constructor(o){this.debug=!1,this.debug=o?.debug??!1,this.appName=o?.appName,this.appVersion=o?.appVersion}log(o,...r){this.debug&&this.print(o,"info",r)}warn(o,...r){this.print(o,"warn",r)}error(o,...r){this.print(o,"error",r)}print(o,r,f){const g=[`[${["MeltingSpot",this.appName,this.appVersion].filter(Boolean).join(" - ")}] ${o}`];f.length&&g.push(...f),console[r](...g)}}const ic=new Ti({appName:"Core SDK",appVersion:rc}),nn=s=>s.toLowerCase().replace(/[^a-z0-9-]/g,""),oc=["/user"],sc=({deeplink:s,spotId:o})=>{try{const r=new URL(s,"https://unused.com");let f=r.pathname;return r.search&&(f+=r.search),r.hash&&(f+=r.hash),oc.some(d=>f.startsWith(d))||(f=`/spot/${o}/${wf(f)}`),f}catch(r){return ic.warn("Failed to parse deeplink URL",r),null}},uc=[/(^|\.)meltingspot\.io$/i],yi=s=>{let o;try{const _=sr(s);o=new URL(_)}catch{throw new Error(`Invalid baseURL: ${s}`)}const r=o.hostname==="localhost"||o.hostname==="127.0.0.1",f=o.protocol==="https:",d=uc.some(_=>_.test(o.hostname));if(!r&&(!f||!d))throw new Error(`Untrusted baseURL origin: ${o.origin}`);return o.origin},ac={msApiBaseUrl:"https://openapi.meltingspot.io/",msCommunityWebBaseUrl:"https://go.meltingspot.io/",ssoToken:void 0,spotId:"",autoJoin:!1,rootDocument:globalThis.document};class Se{constructor(){this.configuration=ac}static getInstance(){return Se.instance||(Se.instance=new Se),Se.instance}setConfiguration(o){this.configuration={...this.configuration,...o}}static getConfiguration(o={}){return{...Se.getInstance().configuration,...o}}}const Ts="%[a-f0-9]{2}",ys=new RegExp("("+Ts+")|([^%]+?)","gi"),Is=new RegExp("("+Ts+")+","gi");function Ii(s,o){try{return[decodeURIComponent(s.join(""))]}catch{}if(s.length===1)return s;o=o||1;const r=s.slice(0,o),f=s.slice(o);return Array.prototype.concat.call([],Ii(r),Ii(f))}function fc(s){try{return decodeURIComponent(s)}catch{let o=s.match(ys)||[];for(let r=1;r<o.length;r++)s=Ii(o,r).join(""),o=s.match(ys)||[];return s}}function cc(s){const o={"%FE%FF":"��","%FF%FE":"��"};let r=Is.exec(s);for(;r;){try{o[r[0]]=decodeURIComponent(r[0])}catch{const d=fc(r[0]);d!==r[0]&&(o[r[0]]=d)}r=Is.exec(s)}o["%C2"]="�";const f=Object.keys(o);for(const d of f)s=s.replace(new RegExp(d,"g"),o[d]);return s}function lc(s){if(typeof s!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof s+"`");try{return decodeURIComponent(s)}catch{return cc(s)}}function hc(s,o){const r={};if(Array.isArray(o))for(const f of o){const d=Object.getOwnPropertyDescriptor(s,f);d?.enumerable&&Object.defineProperty(r,f,d)}else for(const f of Reflect.ownKeys(s)){const d=Object.getOwnPropertyDescriptor(s,f);if(d.enumerable){const _=s[f];o(f,_,s)&&Object.defineProperty(r,f,d)}}return r}function As(s,o){if(!(typeof s=="string"&&typeof o=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(s===""||o==="")return[];const r=s.indexOf(o);return r===-1?[]:[s.slice(0,r),s.slice(r+o.length)]}const dc=s=>s==null,gc=s=>encodeURIComponent(s).replaceAll(/[!'()*]/g,o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`),Ai=Symbol("encodeFragmentIdentifier");function pc(s){switch(s.arrayFormat){case"index":return o=>(r,f)=>{const d=r.length;return f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,[Ae(o,s),"[",d,"]"].join("")]:[...r,[Ae(o,s),"[",Ae(d,s),"]=",Ae(f,s)].join("")]};case"bracket":return o=>(r,f)=>f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,[Ae(o,s),"[]"].join("")]:[...r,[Ae(o,s),"[]=",Ae(f,s)].join("")];case"colon-list-separator":return o=>(r,f)=>f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,[Ae(o,s),":list="].join("")]:[...r,[Ae(o,s),":list=",Ae(f,s)].join("")];case"comma":case"separator":case"bracket-separator":{const o=s.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(f,d)=>d===void 0||s.skipNull&&d===null||s.skipEmptyString&&d===""?f:(d=d===null?"":d,f.length===0?[[Ae(r,s),o,Ae(d,s)].join("")]:[[f,Ae(d,s)].join(s.arrayFormatSeparator)])}default:return o=>(r,f)=>f===void 0||s.skipNull&&f===null||s.skipEmptyString&&f===""?r:f===null?[...r,Ae(o,s)]:[...r,[Ae(o,s),"=",Ae(f,s)].join("")]}}function mc(s){let o;switch(s.arrayFormat){case"index":return(r,f,d)=>{if(o=/\[(\d*)]$/.exec(r),r=r.replace(/\[\d*]$/,""),!o){d[r]=f;return}d[r]===void 0&&(d[r]={}),d[r][o[1]]=f};case"bracket":return(r,f,d)=>{if(o=/(\[])$/.exec(r),r=r.replace(/\[]$/,""),!o){d[r]=f;return}if(d[r]===void 0){d[r]=[f];return}d[r]=[...d[r],f]};case"colon-list-separator":return(r,f,d)=>{if(o=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!o){d[r]=f;return}if(d[r]===void 0){d[r]=[f];return}d[r]=[...d[r],f]};case"comma":case"separator":return(r,f,d)=>{const _=typeof f=="string"&&f.includes(s.arrayFormatSeparator),g=typeof f=="string"&&!_&&bt(f,s).includes(s.arrayFormatSeparator);f=g?bt(f,s):f;const y=_||g?f.split(s.arrayFormatSeparator).map(A=>bt(A,s)):f===null?f:bt(f,s);d[r]=y};case"bracket-separator":return(r,f,d)=>{const _=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!_){d[r]=f&&bt(f,s);return}const g=f===null?[]:bt(f,s).split(s.arrayFormatSeparator);if(d[r]===void 0){d[r]=g;return}d[r]=[...d[r],...g]};default:return(r,f,d)=>{if(d[r]===void 0){d[r]=f;return}d[r]=[...[d[r]].flat(),f]}}}function Rs(s){if(typeof s!="string"||s.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function Ae(s,o){return o.encode?o.strict?gc(s):encodeURIComponent(s):s}function bt(s,o){return o.decode?lc(s):s}function Ls(s){return Array.isArray(s)?s.sort():typeof s=="object"?Ls(Object.keys(s)).sort((o,r)=>Number(o)-Number(r)).map(o=>s[o]):s}function Ms(s){const o=s.indexOf("#");return o!==-1&&(s=s.slice(0,o)),s}function _c(s){let o="";const r=s.indexOf("#");return r!==-1&&(o=s.slice(r)),o}function Os(s,o,r){return r==="string"&&typeof s=="string"?s:typeof r=="function"&&typeof s=="string"?r(s):r==="boolean"&&s===null?!0:r==="boolean"&&s!==null&&(s.toLowerCase()==="true"||s.toLowerCase()==="false")?s.toLowerCase()==="true":r==="boolean"&&s!==null&&(s.toLowerCase()==="1"||s.toLowerCase()==="0")?s.toLowerCase()==="1":r==="string[]"&&o.arrayFormat!=="none"&&typeof s=="string"?[s]:r==="number[]"&&o.arrayFormat!=="none"&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?[Number(s)]:r==="number"&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?Number(s):o.parseBooleans&&s!==null&&(s.toLowerCase()==="true"||s.toLowerCase()==="false")?s.toLowerCase()==="true":o.parseNumbers&&!Number.isNaN(Number(s))&&typeof s=="string"&&s.trim()!==""?Number(s):s}function Ri(s){s=Ms(s);const o=s.indexOf("?");return o===-1?"":s.slice(o+1)}function Li(s,o){o={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...o},Rs(o.arrayFormatSeparator);const r=mc(o),f=Object.create(null);if(typeof s!="string"||(s=s.trim().replace(/^[?#&]/,""),!s))return f;for(const d of s.split("&")){if(d==="")continue;const _=o.decode?d.replaceAll("+"," "):d;let[g,y]=As(_,"=");g===void 0&&(g=_),y=y===void 0?null:["comma","separator","bracket-separator"].includes(o.arrayFormat)?y:bt(y,o),r(bt(g,o),y,f)}for(const[d,_]of Object.entries(f))if(typeof _=="object"&&_!==null&&o.types[d]!=="string")for(const[g,y]of Object.entries(_)){const A=o.types[d]?o.types[d].replace("[]",""):void 0;_[g]=Os(y,o,A)}else typeof _=="object"&&_!==null&&o.types[d]==="string"?f[d]=Object.values(_).join(o.arrayFormatSeparator):f[d]=Os(_,o,o.types[d]);return o.sort===!1?f:(o.sort===!0?Object.keys(f).sort():Object.keys(f).sort(o.sort)).reduce((d,_)=>{const g=f[_];return d[_]=g&&typeof g=="object"&&!Array.isArray(g)?Ls(g):g,d},Object.create(null))}function bs(s,o){if(!s)return"";o={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...o},Rs(o.arrayFormatSeparator);const r=g=>o.skipNull&&dc(s[g])||o.skipEmptyString&&s[g]==="",f=pc(o),d={};for(const[g,y]of Object.entries(s))r(g)||(d[g]=y);const _=Object.keys(d);return o.sort!==!1&&_.sort(o.sort),_.map(g=>{const y=s[g];return y===void 0?"":y===null?Ae(g,o):Array.isArray(y)?y.length===0&&o.arrayFormat==="bracket-separator"?Ae(g,o)+"[]":y.reduce(f(g),[]).join("&"):Ae(g,o)+"="+Ae(y,o)}).filter(g=>g.length>0).join("&")}function xs(s,o){o={decode:!0,...o};let[r,f]=As(s,"#");return r===void 0&&(r=s),{url:r?.split("?")?.[0]??"",query:Li(Ri(s),o),...o&&o.parseFragmentIdentifier&&f?{fragmentIdentifier:bt(f,o)}:{}}}function Ds(s,o){o={encode:!0,strict:!0,[Ai]:!0,...o};const r=Ms(s.url).split("?")[0]||"",f=Ri(s.url),d={...Li(f,{sort:!1,...o}),...s.query};let _=bs(d,o);_&&=`?${_}`;let g=_c(s.url);if(typeof s.fragmentIdentifier=="string"){const y=new URL(r);y.hash=s.fragmentIdentifier,g=o[Ai]?y.hash:`#${s.fragmentIdentifier}`}return`${r}${_}${g}`}function Ss(s,o,r){r={parseFragmentIdentifier:!0,[Ai]:!1,...r};const{url:f,query:d,fragmentIdentifier:_}=xs(s,r);return Ds({url:f,query:hc(d,o),fragmentIdentifier:_},r)}function vc(s,o,r){const f=Array.isArray(o)?d=>!o.includes(d):(d,_)=>!o(d,_);return Ss(s,f,r)}const wc=Object.freeze(Object.defineProperty({__proto__:null,exclude:vc,extract:Ri,parse:Li,parseUrl:xs,pick:Ss,stringify:bs,stringifyUrl:Ds},Symbol.toStringTag,{value:"Module"}));class qe extends Error{constructor(o,r){super(`HTTP Error ${o}${r?`: ${r}`:""}`),this.code=o,this.name="HttpError",Object.setPrototypeOf(this,qe.prototype)}}var Re=(s=>(s.GET="GET",s.PATCH="PATCH",s.POST="POST",s))(Re||{});class Ec{constructor(){this.headers={}}setHeaders(o){this.headers=o}async get(o){try{const r=o.query?`${o.url}?${this.serializeQuery(o.query)}`:o.url,f=await fetch(r,{headers:{...this.headers,...o.headers,"Content-Type":"application/json"},...o.signal?{signal:o.signal}:{}});return f.ok?oe(await f.json()):G(new qe(f.status,await f.text()))}catch(r){const f=r instanceof Error?r.message:"Unknown error";return G(new qe(st.INTERNAL_SERVER_ERROR,f))}}async post(o){try{const r=await fetch(o.url,{method:"POST",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload),...o.signal?{signal:o.signal}:{}});return r.ok?oe(await r.json()):G(new qe(r.status,await r.text()))}catch(r){const f=r instanceof Error?r.message:"Unknown error";return G(new qe(st.INTERNAL_SERVER_ERROR,f))}}async patch(o){try{const r=await fetch(o.url,{method:"PATCH",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload),...o.signal?{signal:o.signal}:{}});return r.ok?oe(await r.json()):G(new qe(r.status,await r.text()))}catch(r){const f=r instanceof Error?r.message:"Unknown error";return G(new qe(st.INTERNAL_SERVER_ERROR,f))}}serializeQuery(o){if(typeof o=="string")return o;if(typeof o=="object")for(const r in o)o[r]===void 0&&delete o[r];return o=wc.stringify(o,{arrayFormat:"none"}),o}}const Tr={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 Ht extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return Ht.instance||(Ht.instance=new Ht),Ht.instance}async loginWithPassword(o,r){const f=await this.callApi({endpoint:Tr.accessToken.email,method:"POST",body:{email:o,password:r},withSpotId:!0});if(f.isErr())return G(f.error);const{accessToken:d,refreshToken:_}=f.value;return this.setTokens(d.token,_.token),oe({accessToken:d.token,refreshToken:_.token})}async loginWithSsoToken(o){const r=await this.callApi({endpoint:Tr.accessToken.sso.jwt,method:"POST",body:{token:o},withSpotId:!0});if(r.isErr())return G(r.error);const{accessToken:f,refreshToken:d}=r.value;return this.setTokens(f.token,d.token),oe({accessToken:f.token,refreshToken:d.token})}loginWithAuthTokens(o,r){return this.setTokens(o,r),{accessToken:o,refreshToken:r}}resetPassword(o){return this.callApi({endpoint:Tr.password.reset,method:"POST",body:{email:o}})}async refresh(){const o=await this.callApi({endpoint:Tr.refreshAccessToken,method:"POST",body:{refreshToken:this.refreshToken}});if(o.isErr())return G(o.error);const{accessToken:r,refreshToken:f}=o.value;return this.setTokens(r.token,f.token),oe({accessToken:r.token,refreshToken:f.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(o,r){if(this.accessToken!==o||this.refreshToken!==r){this.accessToken=o,this.refreshToken=r;const f=new CustomEvent("auth:tokens-updated",{detail:{accessToken:o,refreshToken:r}});this.dispatchEvent(f)}}async callApi(o){try{const{spotId:r,msApiBaseUrl:f}=Se.getConfiguration(),d=vi(o.endpoint,f),_={"Content-Type":"application/json",...o.headers};o.withSpotId&&r&&(_[Us.SpotId]=r);const g=await fetch(d,{method:o.method,body:o.body?JSON.stringify(o.body):void 0,headers:_});if(!g.ok)return G(new qe(g.status,g.statusText));if(g.status===st.NO_CONTENT)return oe(void 0);const y=await g.json();return oe(y)}catch(r){return G(new qe(st.INTERNAL_SERVER_ERROR,r instanceof Error?r.message:String(r)))}}}var Us=(s=>(s.Authorization="Authorization",s.SpotId="x-spotid",s))(Us||{});class It{constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=Ht.getInstance(),this.httpService=new Ec}static getInstance(){return It.instance||(It.instance=new It),It.instance}static buildAuthenticatedRequest(o){const{msApiBaseUrl:r,spotId:f}=Se.getConfiguration(),d=vi(o,r),_=Ht.getInstance().getAccessToken();if(!_)return G(new Error("Not authenticated"));const g={"Content-Type":"application/json",Authorization:`Bearer ${_}`};return f&&(g["x-spotid"]=f),oe({url:d,headers:g})}static async stream(o,r,f){const{streamTransport:d}=Se.getConfiguration();if(d)return d({endpoint:o,body:r,signal:f});const _=It.buildAuthenticatedRequest(o);if(_.isErr())return G(_.error);const{url:g,headers:y}=_.value;try{const A=await fetch(g,{method:"POST",headers:y,...r!==void 0?{body:JSON.stringify(r)}:{},...f?{signal:f}:{}});if(!A.ok){const $=await A.text();return G(new Error(`HTTP ${A.status}: ${$}`))}return A.body?oe(A.body):G(new Error("Response body is empty"))}catch(A){const $=A instanceof Error?A.message:"Unknown error";return G(A instanceof Error?A:new Error($))}}get pendingCount(){return this.queue.length}enqueue(o){return new Promise(r=>{const f=async()=>{try{const d=await o();r(d)}catch(d){r(G(new qe(st.INTERNAL_SERVER_ERROR,d instanceof Error?d.message:"Unknown error")))}};this.queue.push(f),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){const o=this.queue.shift();if(!o)break;await o()}}finally{this.isProcessing=!1,!this.isPaused&&this.queue.length>0&&Promise.resolve().then(()=>this.processQueue())}}}pauseQueue(){this.isPaused=!0}resumeQueue(){const o=this.isPaused;this.isPaused=!1,o&&this.processQueue()}async call(o){return this.enqueue(async()=>{const r=async()=>{const{spotId:d,msApiBaseUrl:_}=Se.getConfiguration(),g={...o.options?.headers??{}};d&&(g["x-spotid"]=d);const y=this.authService.getAccessToken(),{requiresAuth:A=!0}=o;if(!y&&A)return G(new qe(st.UNAUTHORIZED));y&&(g.Authorization=`Bearer ${y}`);const $=vi(o.endpoint,_);switch(o.method){case Re.GET:return this.httpService.get({...o.options??{},headers:g,url:$});case Re.PATCH:return this.httpService.patch({...o.options??{},headers:g,url:$});case Re.POST:return this.httpService.post({...o.options??{},headers:g,url:$});default:return G(new qe(st.METHOD_NOT_ALLOWED,"Method not allowed"))}};let f=await r();if(f.isErr()&&f.error.code===st.UNAUTHORIZED){const d=await this.authService.refresh();if(d.isErr())return G(new qe(st.UNAUTHORIZED,d.error.message));f=await r()}return f})}}const At={playbooks:"/v1/playbooks",pages:s=>`/v1/playbooks/${s}/pages`,hotspots:(s,o)=>`/v1/playbooks/${s}/pages/${o}/hotspots`,hotspot:(s,o,r)=>`/v1/playbooks/${s}/pages/${o}/hotspots/${r}`,accessibleIntents:(s,o)=>`/v1/playbooks/${s}/pages/${o}/accessibleIntents`,intents:(s,o,r)=>`/v1/playbooks/${s}/pages/${o}/hotspots/${r}/intents`,intent:(s,o,r,f)=>`/v1/playbooks/${s}/pages/${o}/hotspots/${r}/intents/${f}`},yr=50;class gn{static getInstance(){return gn.instance||(gn.instance=new gn),gn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async listPlaybooks(o){const r=await this.meltingSpotApi.call({method:Re.GET,endpoint:At.playbooks,options:{query:{page:o?.page??1,limit:o?.limit??yr,...o?.domain?{"domain[eq]":o.domain}:{}}}});return r.isErr()?G(r.error):oe(r.value)}async listPlaybookPages(o){const r=await this.meltingSpotApi.call({method:Re.GET,endpoint:At.pages(o.playbookId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.url?{"url[eq]":o.url}:{}}}});return r.isErr()?G(r.error):oe(r.value)}async createPlaybookPage(o,r){const f=await this.meltingSpotApi.call({method:Re.POST,endpoint:At.pages(o.playbookId),options:{payload:r}});return f.isErr()?G(f.error):oe(f.value)}async listAccessiblePlaybookIntents(o){const r=await this.meltingSpotApi.call({method:Re.GET,endpoint:At.accessibleIntents(o.playbookId,o.pageId),options:{query:{...o.domain?{domain:o.domain}:{}}}});return r.isErr()?G(r.error):oe(r.value)}async listPlaybookHotspots(o){const r=await this.meltingSpotApi.call({method:Re.GET,endpoint:At.hotspots(o.playbookId,o.pageId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.intentStatus?{"intentStatus[eq]":o.intentStatus}:{},...o.widgetType?{"widgetType[eq]":o.widgetType}:{}}}});return r.isErr()?G(r.error):oe(r.value)}async createPlaybookHotspot(o,r){const f=await this.meltingSpotApi.call({method:Re.POST,endpoint:At.hotspots(o.playbookId,o.pageId),options:{payload:r}});return f.isErr()?G(f.error):oe(f.value)}async updatePlaybookHotspot(o,r){const f=await this.meltingSpotApi.call({method:Re.PATCH,endpoint:At.hotspot(o.playbookId,o.pageId,o.hotspotId),options:{payload:r}});return f.isErr()?G(f.error):oe(f.value)}async listPlaybookIntents(o){const r=await this.meltingSpotApi.call({method:Re.GET,endpoint:At.intents(o.playbookId,o.pageId,o.hotspotId),options:{query:{page:o.page??1,limit:o.limit??yr,...o.status?{"status[eq]":o.status}:{}}}});return r.isErr()?G(r.error):oe(r.value)}async createPlaybookIntent(o,r){const f=await this.meltingSpotApi.call({method:Re.POST,endpoint:At.intents(o.playbookId,o.pageId,o.hotspotId),options:{payload:r}});return f.isErr()?G(f.error):oe(f.value)}async updatePlaybookIntent(o,r){const f=await this.meltingSpotApi.call({method:Re.PATCH,endpoint:At.intent(o.playbookId,o.pageId,o.hotspotId,o.intentId),options:{payload:r}});return f.isErr()?G(f.error):oe(f.value)}}const Tc={me:"/v1/spots/me"},yc=50;class pn{static getInstance(){return pn.instance||(pn.instance=new pn),pn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async listSpotsForMe(o){const r=await this.meltingSpotApi.call({method:Re.GET,endpoint:Tc.me,options:{query:{page:1,limit:yc,...o?.spotMemberRole?{"spotMemberRole[eq]":o.spotMemberRole}:{}}}});return r.isErr()?G(r.error):oe(r.value)}}const Mi={spotMember:{me:"/v1/spotMembers/me",joinFromSso:"/v1/spotMembers~joinFromSso",search:"/v1/spotMembers~search"}};class mn{static getInstance(){return mn.instance||(mn.instance=new mn),mn.instance}constructor(){this.meltingSpotApi=It.getInstance()}async getSpotMemberForMe(){const o=await this.meltingSpotApi.call({method:Re.GET,endpoint:Mi.spotMember.me});return o.isErr()?G(o.error):oe(o.value)}async searchSpotMembers(o){const r={page:o.page,limit:o.limit};o.search&&(r.search=o.search);const f=await this.meltingSpotApi.call({method:Re.GET,endpoint:Mi.spotMember.search,options:{query:r}});return f.isErr()?G(f.error):oe(f.value)}async joinFromSso(o){const r=await this.meltingSpotApi.call({method:Re.POST,endpoint:Mi.spotMember.joinFromSso,options:{payload:{token:o}}});return r.isErr()?G(r.error):oe(r.value)}}const $s={spotMemberSsoToken:"/v1/spotMembers/auth/sso/jwt",previewAccessKey:"/v1/spotMembers/auth/preview/accessKey"};class _n{static getInstance(){return _n.instance||(_n.instance=new _n),_n.instance}constructor(){this.meltingSpotApi=It.getInstance()}async generateSsoToken(){const o=await this.meltingSpotApi.call({method:Re.POST,endpoint:$s.spotMemberSsoToken,options:{payload:{}}});return o.isErr()?G(o.error):oe(o.value.token)}async generatePreviewAccessKey(o){const r=await this.meltingSpotApi.call({method:Re.POST,endpoint:$s.previewAccessKey,options:{payload:{targetSpotMemberId:o.targetSpotMemberId}}});return r.isErr()?G(r.error):oe(r.value)}}class vn{static getInstance(){return vn.instance||(vn.instance=new vn),vn.instance}constructor(){this.spotMemberAuthApiService=_n.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}}const Oi=s=>{const o=s.get("utm_source");if(o)return{source:o,medium:s.get("utm_medium")??void 0,campaign:s.get("utm_campaign")??void 0,term:s.get("utm_term")??void 0,content:s.get("utm_content")??void 0}},bi=s=>s?Object.entries(s).reduce((o,[r,f])=>(f!=null&&(o[`utm_${r}`]=f),o),{}):{},Ic=Se.getInstance(),Ac=Ht.getInstance(),Rc=vn.getInstance(),Lc={Playbook:gn.getInstance(),Spot:pn.getInstance(),SpotMember:mn.getInstance()},wn=globalThis;wn.MeltingSpot||(wn.MeltingSpot={}),wn.MeltingSpot.Configuration=Ic,wn.MeltingSpot.Auth=Ac,wn.MeltingSpot.Sso=Rc,wn.MeltingSpot.Api=Lc;const Mc="1.7.0",xi=new Ti({appName:"Embed SDK",appVersion:Mc});class Ir{constructor(o){this.content=o}#e=null;#t=null;set onRemove(o){this.#t=o}inject(o){this.remove();const r=wi({input:o,rootDocument:this.content.rootDocument});this.#e=this.content.iframe,this.#e.classList.add("ms-embed"),r.appendChild(this.#e)}remove(){this.#e&&(this.#e.contentWindow&&this.#t?.(this.#e.contentWindow),this.#e.remove(),this.#e=null)}}class Oc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.deeplink=o.deeplink?sc({deeplink:o.deeplink,spotId:this.spotId}):null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=this.authToken&&this.authToken.trim().length>0?"/sso/jwt":"",r=new URL(`/spot/${this.spotId}${o}`,sr(this.baseURL)),f=Ei({url:r,searchParams:{embed:this.spotId,themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,deeplink:this.deeplink,...bi(this.utmParameters)},rootDocument:this.rootDocument});return f.classList.add("ms-spot"),f}}const Di={READY:"meltingspot:ready",ERROR:"meltingspot:error"},Oe=class Oe{static injectSpotInto(o,r){const{onReady:f,onError:d,..._}=r,{spotId:g,rootDocument:y,msCommunityWebBaseUrl:A}=Se.getConfiguration({spotId:_.spotId,rootDocument:_.rootDocument,msCommunityWebBaseUrl:_.baseURL});if(!g)throw xi.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const $=new URLSearchParams(window.location.search),H={spotId:g,authToken:_.authToken??$.get("ms_token"),domain:_.domain,deeplink:_.deeplink??$.get("ms_url"),themeMode:_.themeMode,utmParameters:_.utmParameters??Oi($),baseURL:A,rootDocument:y},U=new Ir(new Oc(H));if(U.inject(o),Oe.embeds.push(U),f||d){const N=U.content.iframe.contentWindow;N&&(Oe.iframeCallbacks.set(N,{onReady:f,onError:d}),U.onRemove=K=>{Oe.iframeCallbacks.delete(K)}),Oe.ensureMessageListener()}return xi.log("Spot injected",H,o),U}static clear(){Oe.embeds.forEach(o=>{o.remove()}),Oe.embeds=[],Oe.iframeCallbacks.clear(),Oe.messageListened&&(window.removeEventListener("message",Oe.handleMessageEvent),Oe.messageListened=!1),xi.log("All MeltingSpot embeds cleared")}static handleMessageEvent(o){if(!o.data||typeof o.data!="object"||o.data.type!==Di.READY&&o.data.type!==Di.ERROR)return;const r=o.source,f=Oe.iframeCallbacks.get(r);if(!f)return;const{msCommunityWebBaseUrl:d}=Se.getConfiguration({});if(d)try{const _=new URL(d).origin;if(o.origin!==_)return}catch{}o.data.type===Di.READY?f.onReady?.():f.onError?.(o.data.error)}static ensureMessageListener(){Oe.messageListened||(window.addEventListener("message",Oe.handleMessageEvent),Oe.messageListened=!0)}};Oe.embeds=[],Oe.messageListened=!1,Oe.iframeCallbacks=new Map;let Si=Oe;const Ui=globalThis;Ui.MeltingSpot||(Ui.MeltingSpot={}),Ui.MeltingSpot.Embed=Si;const bc="1.7.0",He=new Ti({appName:"Widget SDK",appVersion:bc});class Ns{constructor(o,r,f){this.content=o,this.rootDocument=r,this.dialogClassname=f,this.dialogElement=null,this.triggerElement=null,this.iframeElement=null,this.currentListener=null}inject({into:o,bind:r,options:f}){this.remove();const d=wi({input:o,rootDocument:this.rootDocument});if(this.dialogElement=Tf(this.rootDocument),this.dialogElement.classList.add(this.dialogClassname),this.dialogElement.onclose=()=>this.#t(),d.appendChild(this.dialogElement),r){this.triggerElement=wi({input:r,rootDocument:this.rootDocument});const _=this.open.bind(this,f);this.currentListener=g=>{g.stopPropagation(),g.preventDefault(),_()},this.triggerElement.addEventListener("click",this.currentListener)}}remove(){this.dialogElement&&(this.dialogElement.remove(),this.dialogElement.onclose=null,this.dialogElement=null),this.triggerElement&&(this.currentListener&&this.triggerElement.removeEventListener("click",this.currentListener),this.triggerElement=null,this.currentListener=null)}open(o){this.dialogElement||this.inject({into:this.rootDocument.body}),this.dialogElement&&(this.#e(),this.dialogElement.showModal())}close(){this.dialogElement&&this.dialogElement.close()}#e(){this.dialogElement&&(this.iframeElement=this.dialogElement.appendChild(this.content.iframe))}#t(){this.iframeElement&&(this.iframeElement.remove(),this.iframeElement=null)}}class Ar extends Ns{constructor(o,r){super(o,r,"ms-drawer")}open(o){const{position:r="right"}=o??{};super.open(o),this.dialogElement&&(this.dialogElement.dataset.position=r)}}class Rr extends Ns{constructor(o,r){super(o,r,"ms-modal")}}class xc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.widgetId=nn(o.widgetId),this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=new URL(`/widgets/spot/${this.spotId}/widget/${this.widgetId}`,sr(this.baseURL)),r=Ei({url:o,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,...bi(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add("ms-widget"),r}}class Dc{constructor(o){this.baseURL=yi(o.baseURL),this.spotId=nn(o.spotId),this.widgetContentId=nn(o.widgetContentId),this.contentId=nn(o.contentId),this.widgetId=nn(o.widgetId),this.contentType=o.contentType,this.authToken=o.authToken??null,this.themeMode=o.themeMode??"auto",this.domain=o.domain??null,this.utmParameters=o.utmParameters??null,this.rootDocument=o.rootDocument}get iframe(){const o=new URL(`/widgets/spot/${this.spotId}/widgetContent/${this.widgetContentId}`,sr(this.baseURL));o.searchParams.set("widgetId",this.widgetId);const r=Ei({url:o,searchParams:{themeMode:this.themeMode,ms_token:this.authToken,domain:this.domain,contentId:this.contentId,contentType:this.contentType,...bi(this.utmParameters)},rootDocument:this.rootDocument});return r.classList.add("ms-widget-content"),r}}const ee=class ee{static injectWidgetInto(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=Se.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument,msCommunityWebBaseUrl:r.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widget:g,args:y}=ee.createWidget({...r,spotId:f,rootDocument:d,baseURL:_}),A=new Ir(g);return A.inject(o),ee.widgets.push(A),He.log("Widget injected",ee.cleanupLoggedArgs(y),o),A}static injectWidgetContentInto(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=Se.getConfiguration({spotId:r.spotId,rootDocument:r.rootDocument,msCommunityWebBaseUrl:r.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");const{widgetContent:g,args:y}=ee.createWidgetContent({...r,spotId:f,rootDocument:d,baseURL:_}),A=new Ir(g);return A.inject(o),ee.widgets.push(A),He.log("WidgetContent injected",ee.cleanupLoggedArgs(y),o),A}static bindWidgetModalTo(o,r){return ee.bindEntityModalTo(o,{type:"Widget",data:r})}static bindWidgetDrawerTo(o,r){return ee.bindEntityDrawerTo(o,{type:"Widget",data:r})}static createWidgetDrawer(o){const{widget:r}=ee.createWidget(o);return He.log("Create Widget drawer",{data:ee.cleanupLoggedArgs(o)}),new Ar(r,o.rootDocument??document)}static createWidgetModal(o){const{widget:r}=ee.createWidget(o);return He.log("Create Widget modal",{data:ee.cleanupLoggedArgs(o)}),new Rr(r,o.rootDocument??document)}static createWidgetEmbed(o){const{widget:r}=ee.createWidget(o),f=new Ir(r);return He.log("Create Widget embed",{data:ee.cleanupLoggedArgs(o)}),f}static clear(){ee.widgets.forEach(o=>{o.remove()}),ee.widgets=[],ee.widgetOptions={},He.log("All Widget SDK MeltingSpot elements were cleared")}static bindEntityDrawerTo(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=Se.getConfiguration({spotId:r.data.spotId,rootDocument:r.data.rootDocument??document,msCommunityWebBaseUrl:r.data.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let g,y;switch(r.type){case"Widget":{const U=ee.createWidget({...r.data,spotId:f,rootDocument:d,baseURL:_});g=U.widget,y=U.args}break;case"WidgetContent":{const U=ee.createWidgetContent({...r.data,spotId:f,rootDocument:d,baseURL:_});g=U.widgetContent,y=U.args}}const A=new Ar(g,d),$={position:r.data.position},H=r.data.into??d.body;return A.inject({into:H,bind:o,options:$}),ee.widgets.push(A),He.log("Widget bound to drawer",ee.cleanupLoggedArgs(y),$,H,o),A}static bindEntityModalTo(o,r){const{spotId:f,rootDocument:d,msCommunityWebBaseUrl:_}=Se.getConfiguration({spotId:r.data.spotId,rootDocument:r.data.rootDocument??document,msCommunityWebBaseUrl:r.data.baseURL});if(!f)throw He.error("Spot ID is required"),new Error("Spot ID is not configured. Please set the spotId in the configuration.");let g,y;switch(r.type){case"Widget":{const H=ee.createWidget({...r.data,spotId:f,rootDocument:d,baseURL:_});g=H.widget,y=H.args}break;case"WidgetContent":{const H=ee.createWidgetContent({...r.data,spotId:f,rootDocument:d,baseURL:_});g=H.widgetContent,y=H.args}}const A=new Rr(g,d),$=r.data.into??d.body;return A.inject({into:$,bind:o}),ee.widgets.push(A),He.log("Widget bound to modal",ee.cleanupLoggedArgs(y),$,o),A}static handleMessageEvent(o){if(!o.data||typeof o.data!="object"||o.data.type!=="OpenWidgetContent")return;const r=o.data?.widgetId;if(!r||typeof r!="string"){He.error("widgetId is required in the message event data");return}const f=ee.widgetOptions[r];if(!f){He.error("No widget options found for widgetId",{widgetId:r});return}let d=null;try{d=new URL(f.baseURL).origin}catch{d=null}if(!d||o.origin!==d){He.warn("Ignoring OpenWidgetContent from unexpected origin",{origin:o.origin,expectedOrigin:d});return}const{spotId:_,rootDocument:g,msCommunityWebBaseUrl:y}=Se.getConfiguration({spotId:f.spotId,rootDocument:f.rootDocument??document,msCommunityWebBaseUrl:f.baseURL}),{widgetContent:A}=ee.createWidgetContent({...f,widgetContentId:o.data.widgetContentId,contentType:o.data.contentType,contentId:o.data.contentId,widgetId:r,spotId:_,rootDocument:g,baseURL:y});o.data.openingIn==="Drawer"?new Ar(A,g).open():o.data.openingIn==="Modal"&&new Rr(A,g).open()}static createWidget(o){const r=new URLSearchParams(window.location.search),f={spotId:o.spotId,widgetId:o.widgetId,authToken:o.authToken,themeMode:o.themeMode,domain:o.domain,rootDocument:o.rootDocument,baseURL:o.baseURL,utmParameters:o.utmParameters??Oi(r)};return ee.widgetOptions[f.widgetId]=f,ee.messageListened||(window.addEventListener("message",ee.handleMessageEvent),ee.messageListened=!0),{widget:new xc(f),args:f}}static createWidgetContent(o){const r=new URLSearchParams(window.location.search),f={spotId:o.spotId,contentId:o.contentId,contentType:o.contentType,widgetContentId:o.widgetContentId,widgetId:o.widgetId,authToken:o.authToken,themeMode:o.themeMode,domain:o.domain,rootDocument:o.rootDocument,baseURL:o.baseURL,utmParameters:o.utmParameters??Oi(r)};return{widgetContent:new Dc(f),args:f}}static cleanupLoggedArgs(o){const{authToken:r,...f}=o;return{...f,authToken:r?"***":void 0}}};ee.widgets=[],ee.messageListened=!1,ee.widgetOptions={};let Lr=ee;const $i=globalThis;$i.MeltingSpot||($i.MeltingSpot={}),$i.MeltingSpot.Widget=Lr,kt.Drawer=Ar,kt.Modal=Rr,kt.Widget=Lr,Object.defineProperty(kt,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "MeltingSpot Widget SDK",
|
|
4
4
|
"homepage": "https://meltingspot.io",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.7.0",
|
|
7
7
|
"main": "./index.cjs",
|
|
8
8
|
"module": "./index.mjs",
|
|
9
9
|
"typings": "./index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@meltingspot/core": "1.
|
|
25
|
-
"@meltingspot/embed": "1.
|
|
24
|
+
"@meltingspot/core": "1.7.0",
|
|
25
|
+
"@meltingspot/embed": "1.7.0"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"provenance": false
|