@meltingspot/core 0.1.0 → 1.0.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 ADDED
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ <!--
4
+ To add a new release, copy from this template:
5
+
6
+ ## vX.Y.Z
7
+
8
+ Date: YYYY-MM-DD
9
+
10
+ ### Major Changes
11
+
12
+ ### Minor Changes
13
+
14
+ ### Patch Changes
15
+
16
+ -->
17
+
18
+ ## v1.0.0
19
+
20
+ Date: 2026-06-17
21
+
22
+ ### Major Changes
23
+
24
+ Initial release of the `@meltingspot/core` SDK.
25
+
26
+ Shared foundation (auth, configuration, transport) consumed by the
27
+ `@meltingspot/embed`, `@meltingspot/widget` and `@meltingspot/coach` SDKs.
package/README.md CHANGED
@@ -2,41 +2,6 @@
2
2
 
3
3
  Foundation layer of the MeltingSpot SDKs. It exposes the shared services (configuration, authentication, SSO, HTTP/API access) and types consumed by the higher-level SDKs (`@meltingspot/embed`, `@meltingspot/widget`, `@meltingspot/coach`).
4
4
 
5
- > You usually don't install this package directly — it comes as a dependency of the SDK you integrate. Install it explicitly only for advanced programmatic usage.
6
-
7
- ## Installation
8
-
9
- ```bash
10
- npm install @meltingspot/core
11
- ```
12
-
13
- ## Usage
14
-
15
- ```typescript
16
- import { ConfigurationService, AuthService } from '@meltingspot/core';
17
-
18
- // Configure the SDK once for your spot.
19
- ConfigurationService.setConfiguration({ spotId: 'YOUR_SPOT_ID' });
20
-
21
- // Authenticate the current user with a MeltingSpot SSO token.
22
- const result = await AuthService.loginWithSsoToken('CURRENT_USER_SSO_TOKEN');
23
- if (result.isErr()) {
24
- console.error('Authentication failed', result.error);
25
- }
26
- ```
27
-
28
- ## What's inside
29
-
30
- | Export | Description |
31
- | ---------------------- | ------------------------------------------------------ |
32
- | `ConfigurationService` | Global SDK configuration (spot id, theme, API base...) |
33
- | `AuthService` | Authentication & token lifecycle |
34
- | `SsoService` | SSO token exchange |
35
- | `MeltingSpotApi` | Typed HTTP client for the MeltingSpot API |
36
- | `Logger` | Namespaced logger with debug toggle |
37
-
38
- See the [MeltingSpot helpdesk](https://help.meltingspot.io) for integration guides.
39
-
40
- ```
41
-
42
- ```
5
+ > This package is an internal dependency of the other SDKs and is not meant to be used directly.
6
+ >
7
+ > It comes installed automatically with the SDK you integrate.
package/index.mjs CHANGED
@@ -4921,7 +4921,7 @@ class n0 {
4921
4921
  this.listener !== null && typeof document < "u" && document.removeEventListener(xa, this.listener), this.listener = null, this.lastOptions = null;
4922
4922
  }
4923
4923
  }
4924
- const Km = "0.1.0";
4924
+ const Km = "1.0.0";
4925
4925
  class Qm {
4926
4926
  constructor(s) {
4927
4927
  this.debug = !1, this.debug = s?.debug ?? !1, this.appName = s?.appName, this.appVersion = s?.appVersion;
package/index.umd.js CHANGED
@@ -30,4 +30,4 @@ __p += '`),tn&&(A+=`' +
30
30
  function print() { __p += __j.call(arguments, '') }
31
31
  `:`;
32
32
  `)+A+`return __p
33
- }`;var Z=$f(function(){return on(f,U+"return "+A).apply(i,l)});if(Z.source=A,Du(Z))throw Z;return Z}function Pv(n){return fn(n).toLowerCase()}function Cv(n){return fn(n).toUpperCase()}function Yv(n,e,t){if(n=fn(n),n&&(t||e===i))return ks(n);if(!n||!(e=ne(e)))return n;var u=Te(n),s=Te(e),f=Gs(u,s),l=zs(u,s)+1;return Ze(u,f,l).join("")}function Fv(n,e,t){if(n=fn(n),n&&(t||e===i))return n.slice(0,Ks(n)+1);if(!n||!(e=ne(e)))return n;var u=Te(n),s=zs(u,Te(e))+1;return Ze(u,0,s).join("")}function Hv(n,e,t){if(n=fn(n),n&&(t||e===i))return n.replace(Di,"");if(!n||!(e=ne(e)))return n;var u=Te(n),s=Gs(u,Te(e));return Ze(u,s).join("")}function Bv(n,e){var t=ln,u=rn;if(Tn(e)){var s="separator"in e?e.separator:s;t="length"in e?K(e.length):t,u="omission"in e?ne(e.omission):u}n=fn(n);var f=n.length;if(It(n)){var l=Te(n);f=l.length}if(t>=f)return n;var h=t-Lt(u);if(h<1)return u;var p=l?Ze(l,0,h).join(""):n.slice(0,h);if(s===i)return p+u;if(l&&(h+=p.length-h),Su(s)){if(n.slice(h).search(s)){var T,w=p;for(s.global||(s=qi(s.source,fn(ls.exec(s))+"g")),s.lastIndex=0;T=s.exec(w);)var A=T.index;p=p.slice(0,A===i?h:A)}}else if(n.indexOf(ne(s),h)!=h){var R=p.lastIndexOf(s);R>-1&&(p=p.slice(0,R))}return p+u}function Wv(n){return n=fn(n),n&&jl.test(n)?n.replace(as,md):n}var kv=xt(function(n,e,t){return n+(t?" ":"")+e.toUpperCase()}),Uu=$a("toUpperCase");function Nf(n,e,t){return n=fn(n),e=t?i:e,e===i?hd(n)?Td(n):rd(n):n.match(e)||[]}var $f=J(function(n,e){try{return Xn(n,i,e)}catch(t){return Du(t)?t:new W(t)}}),Gv=Ce(function(n,e){return se(e,function(t){t=Oe(t),$e(n,t,Mu(n[t],n))}),n});function zv(n){var e=n==null?0:n.length,t=N();return n=e?gn(n,function(u){if(typeof u[1]!="function")throw new ae(g);return[t(u[0]),u[1]]}):[],J(function(u){for(var s=-1;++s<e;){var f=n[s];if(Xn(f[0],this,u))return Xn(f[1],this,u)}})}function qv(n){return m_(ce(n,H))}function Nu(n){return function(){return n}}function Kv(n,e){return n==null||n!==n?e:n}var Qv=Ca(),Zv=Ca(!0);function Qn(n){return n}function $u(n){return da(typeof n=="function"?n:ce(n,H))}function Jv(n){return pa(ce(n,H))}function Vv(n,e){return ga(n,ce(e,H))}var Xv=J(function(n,e){return function(t){return Vt(t,n,e)}}),jv=J(function(n,e){return function(t){return Vt(n,t,e)}});function Pu(n,e,t){var u=Un(e),s=qr(e,u);t==null&&!(Tn(e)&&(s.length||!u.length))&&(t=e,e=n,n=this,s=qr(e,Un(e)));var f=!(Tn(t)&&"chain"in t)||!!t.chain,l=Fe(n);return se(s,function(h){var p=e[h];n[h]=p,l&&(n.prototype[h]=function(){var T=this.__chain__;if(f||T){var w=n(this.__wrapped__),A=w.__actions__=zn(this.__actions__);return A.push({func:p,args:arguments,thisArg:n}),w.__chain__=T,w}return p.apply(n,ke([this.value()],arguments))})}),n}function n0(){return Pn._===this&&(Pn._=Rd),this}function Cu(){}function e0(n){return n=K(n),J(function(e){return ma(e,n)})}var t0=_u(gn),r0=_u(Ys),i0=_u(Fi);function Pf(n){return wu(n)?Hi(Oe(n)):N_(n)}function u0(n){return function(e){return n==null?i:ft(n,e)}}var o0=Fa(),s0=Fa(!0);function Yu(){return[]}function Fu(){return!1}function a0(){return{}}function f0(){return""}function c0(){return!0}function l0(n,e){if(n=K(n),n<1||n>L)return[];var t=X,u=Fn(n,X);e=N(e),n-=X;for(var s=ki(u,e);++t<n;)e(t);return s}function h0(n){return G(n)?gn(n,Oe):ee(n)?[n]:zn(ef(fn(n)))}function d0(n){var e=++Id;return fn(n)+e}var _0=Xr(function(n,e){return n+e},0),p0=pu("ceil"),g0=Xr(function(n,e){return n/e},1),m0=pu("floor");function v0(n){return n&&n.length?zr(n,Qn,nu):i}function E0(n,e){return n&&n.length?zr(n,N(e,2),nu):i}function T0(n){return Bs(n,Qn)}function w0(n,e){return Bs(n,N(e,2))}function A0(n){return n&&n.length?zr(n,Qn,iu):i}function y0(n,e){return n&&n.length?zr(n,N(e,2),iu):i}var I0=Xr(function(n,e){return n*e},1),L0=pu("round"),R0=Xr(function(n,e){return n-e},0);function M0(n){return n&&n.length?Wi(n,Qn):0}function O0(n,e){return n&&n.length?Wi(n,N(e,2)):0}return a.after=Jg,a.ary=df,a.assign=Cm,a.assignIn=Mf,a.assignInWith=li,a.assignWith=Ym,a.at=Fm,a.before=_f,a.bind=Mu,a.bindAll=Gv,a.bindKey=pf,a.castArray=am,a.chain=cf,a.chunk=mp,a.compact=vp,a.concat=Ep,a.cond=zv,a.conforms=qv,a.constant=Nu,a.countBy=Mg,a.create=Hm,a.curry=gf,a.curryRight=mf,a.debounce=vf,a.defaults=Bm,a.defaultsDeep=Wm,a.defer=Vg,a.delay=Xg,a.difference=Tp,a.differenceBy=wp,a.differenceWith=Ap,a.drop=yp,a.dropRight=Ip,a.dropRightWhile=Lp,a.dropWhile=Rp,a.fill=Mp,a.filter=Dg,a.flatMap=xg,a.flatMapDeep=Ug,a.flatMapDepth=Ng,a.flatten=of,a.flattenDeep=Op,a.flattenDepth=Dp,a.flip=jg,a.flow=Qv,a.flowRight=Zv,a.fromPairs=Sp,a.functions=Zm,a.functionsIn=Jm,a.groupBy=$g,a.initial=xp,a.intersection=Up,a.intersectionBy=Np,a.intersectionWith=$p,a.invert=Xm,a.invertBy=jm,a.invokeMap=Cg,a.iteratee=$u,a.keyBy=Yg,a.keys=Un,a.keysIn=Kn,a.map=ui,a.mapKeys=ev,a.mapValues=tv,a.matches=Jv,a.matchesProperty=Vv,a.memoize=si,a.merge=rv,a.mergeWith=Of,a.method=Xv,a.methodOf=jv,a.mixin=Pu,a.negate=ai,a.nthArg=e0,a.omit=iv,a.omitBy=uv,a.once=nm,a.orderBy=Fg,a.over=t0,a.overArgs=em,a.overEvery=r0,a.overSome=i0,a.partial=Ou,a.partialRight=Ef,a.partition=Hg,a.pick=ov,a.pickBy=Df,a.property=Pf,a.propertyOf=u0,a.pull=Fp,a.pullAll=af,a.pullAllBy=Hp,a.pullAllWith=Bp,a.pullAt=Wp,a.range=o0,a.rangeRight=s0,a.rearg=tm,a.reject=kg,a.remove=kp,a.rest=rm,a.reverse=Lu,a.sampleSize=zg,a.set=av,a.setWith=fv,a.shuffle=qg,a.slice=Gp,a.sortBy=Zg,a.sortedUniq=Vp,a.sortedUniqBy=Xp,a.split=xv,a.spread=im,a.tail=jp,a.take=ng,a.takeRight=eg,a.takeRightWhile=tg,a.takeWhile=rg,a.tap=vg,a.throttle=um,a.thru=ii,a.toArray=If,a.toPairs=Sf,a.toPairsIn=bf,a.toPath=h0,a.toPlainObject=Rf,a.transform=cv,a.unary=om,a.union=ig,a.unionBy=ug,a.unionWith=og,a.uniq=sg,a.uniqBy=ag,a.uniqWith=fg,a.unset=lv,a.unzip=Ru,a.unzipWith=ff,a.update=hv,a.updateWith=dv,a.values=$t,a.valuesIn=_v,a.without=cg,a.words=Nf,a.wrap=sm,a.xor=lg,a.xorBy=hg,a.xorWith=dg,a.zip=_g,a.zipObject=pg,a.zipObjectDeep=gg,a.zipWith=mg,a.entries=Sf,a.entriesIn=bf,a.extend=Mf,a.extendWith=li,Pu(a,a),a.add=_0,a.attempt=$f,a.camelCase=vv,a.capitalize=xf,a.ceil=p0,a.clamp=pv,a.clone=fm,a.cloneDeep=lm,a.cloneDeepWith=hm,a.cloneWith=cm,a.conformsTo=dm,a.deburr=Uf,a.defaultTo=Kv,a.divide=g0,a.endsWith=Ev,a.eq=Ae,a.escape=Tv,a.escapeRegExp=wv,a.every=Og,a.find=Sg,a.findIndex=rf,a.findKey=km,a.findLast=bg,a.findLastIndex=uf,a.findLastKey=Gm,a.floor=m0,a.forEach=lf,a.forEachRight=hf,a.forIn=zm,a.forInRight=qm,a.forOwn=Km,a.forOwnRight=Qm,a.get=bu,a.gt=_m,a.gte=pm,a.has=Vm,a.hasIn=xu,a.head=sf,a.identity=Qn,a.includes=Pg,a.indexOf=bp,a.inRange=gv,a.invoke=nv,a.isArguments=ht,a.isArray=G,a.isArrayBuffer=gm,a.isArrayLike=qn,a.isArrayLikeObject=yn,a.isBoolean=mm,a.isBuffer=Je,a.isDate=vm,a.isElement=Em,a.isEmpty=Tm,a.isEqual=wm,a.isEqualWith=Am,a.isError=Du,a.isFinite=ym,a.isFunction=Fe,a.isInteger=Tf,a.isLength=fi,a.isMap=wf,a.isMatch=Im,a.isMatchWith=Lm,a.isNaN=Rm,a.isNative=Mm,a.isNil=Dm,a.isNull=Om,a.isNumber=Af,a.isObject=Tn,a.isObjectLike=wn,a.isPlainObject=rr,a.isRegExp=Su,a.isSafeInteger=Sm,a.isSet=yf,a.isString=ci,a.isSymbol=ee,a.isTypedArray=Nt,a.isUndefined=bm,a.isWeakMap=xm,a.isWeakSet=Um,a.join=Pp,a.kebabCase=Av,a.last=he,a.lastIndexOf=Cp,a.lowerCase=yv,a.lowerFirst=Iv,a.lt=Nm,a.lte=$m,a.max=v0,a.maxBy=E0,a.mean=T0,a.meanBy=w0,a.min=A0,a.minBy=y0,a.stubArray=Yu,a.stubFalse=Fu,a.stubObject=a0,a.stubString=f0,a.stubTrue=c0,a.multiply=I0,a.nth=Yp,a.noConflict=n0,a.noop=Cu,a.now=oi,a.pad=Lv,a.padEnd=Rv,a.padStart=Mv,a.parseInt=Ov,a.random=mv,a.reduce=Bg,a.reduceRight=Wg,a.repeat=Dv,a.replace=Sv,a.result=sv,a.round=L0,a.runInContext=_,a.sample=Gg,a.size=Kg,a.snakeCase=bv,a.some=Qg,a.sortedIndex=zp,a.sortedIndexBy=qp,a.sortedIndexOf=Kp,a.sortedLastIndex=Qp,a.sortedLastIndexBy=Zp,a.sortedLastIndexOf=Jp,a.startCase=Uv,a.startsWith=Nv,a.subtract=R0,a.sum=M0,a.sumBy=O0,a.template=$v,a.times=l0,a.toFinite=He,a.toInteger=K,a.toLength=Lf,a.toLower=Pv,a.toNumber=de,a.toSafeInteger=Pm,a.toString=fn,a.toUpper=Cv,a.trim=Yv,a.trimEnd=Fv,a.trimStart=Hv,a.truncate=Bv,a.unescape=Wv,a.uniqueId=d0,a.upperCase=kv,a.upperFirst=Uu,a.each=lf,a.eachRight=hf,a.first=sf,Pu(a,(function(){var n={};return Re(a,function(e,t){cn.call(a.prototype,t)||(n[t]=e)}),n})(),{chain:!1}),a.VERSION=c,se(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){a[n].placeholder=a}),se(["drop","take"],function(n,e){nn.prototype[n]=function(t){t=t===i?1:bn(K(t),0);var u=this.__filtered__&&!e?new nn(this):this.clone();return u.__filtered__?u.__takeCount__=Fn(t,u.__takeCount__):u.__views__.push({size:Fn(t,X),type:n+(u.__dir__<0?"Right":"")}),u},nn.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),se(["filter","map","takeWhile"],function(n,e){var t=e+1,u=t==Y||t==M;nn.prototype[n]=function(s){var f=this.clone();return f.__iteratees__.push({iteratee:N(s,3),type:t}),f.__filtered__=f.__filtered__||u,f}}),se(["head","last"],function(n,e){var t="take"+(e?"Right":"");nn.prototype[n]=function(){return this[t](1).value()[0]}}),se(["initial","tail"],function(n,e){var t="drop"+(e?"":"Right");nn.prototype[n]=function(){return this.__filtered__?new nn(this):this[t](1)}}),nn.prototype.compact=function(){return this.filter(Qn)},nn.prototype.find=function(n){return this.filter(n).head()},nn.prototype.findLast=function(n){return this.reverse().find(n)},nn.prototype.invokeMap=J(function(n,e){return typeof n=="function"?new nn(this):this.map(function(t){return Vt(t,n,e)})}),nn.prototype.reject=function(n){return this.filter(ai(N(n)))},nn.prototype.slice=function(n,e){n=K(n);var t=this;return t.__filtered__&&(n>0||e<0)?new nn(t):(n<0?t=t.takeRight(-n):n&&(t=t.drop(n)),e!==i&&(e=K(e),t=e<0?t.dropRight(-e):t.take(e-n)),t)},nn.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},nn.prototype.toArray=function(){return this.take(X)},Re(nn.prototype,function(n,e){var t=/^(?:filter|find|map|reject)|While$/.test(e),u=/^(?:head|last)$/.test(e),s=a[u?"take"+(e=="last"?"Right":""):e],f=u||/^find/.test(e);s&&(a.prototype[e]=function(){var l=this.__wrapped__,h=u?[1]:arguments,p=l instanceof nn,T=h[0],w=p||G(l),A=function(j){var tn=s.apply(a,ke([j],h));return u&&R?tn[0]:tn};w&&t&&typeof T=="function"&&T.length!=1&&(p=w=!1);var R=this.__chain__,U=!!this.__actions__.length,$=f&&!R,Z=p&&!U;if(!f&&w){l=Z?l:new nn(this);var P=n.apply(l,h);return P.__actions__.push({func:ii,args:[A],thisArg:i}),new fe(P,R)}return $&&Z?n.apply(this,h):(P=this.thru(A),$?u?P.value()[0]:P.value():P)})}),se(["pop","push","shift","sort","splice","unshift"],function(n){var e=Sr[n],t=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",u=/^(?:pop|shift)$/.test(n);a.prototype[n]=function(){var s=arguments;if(u&&!this.__chain__){var f=this.value();return e.apply(G(f)?f:[],s)}return this[t](function(l){return e.apply(G(l)?l:[],s)})}}),Re(nn.prototype,function(n,e){var t=a[e];if(t){var u=t.name+"";cn.call(Dt,u)||(Dt[u]=[]),Dt[u].push({name:e,func:t})}}),Dt[Vr(i,dn).name]=[{name:"wrapper",func:i}],nn.prototype.clone=Wd,nn.prototype.reverse=kd,nn.prototype.value=Gd,a.prototype.at=Eg,a.prototype.chain=Tg,a.prototype.commit=wg,a.prototype.next=Ag,a.prototype.plant=Ig,a.prototype.reverse=Lg,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=Rg,a.prototype.first=a.prototype.head,Gt&&(a.prototype[Gt]=yg),a}),Rt=wd();it?((it.exports=Rt)._=Rt,$i._=Rt):Pn._=Rt}).call(Uc)})(Ct,Ct.exports)),Ct.exports}var $c=Nc();const so=dt($c),ao=(r,o)=>{switch(o){case"fr":case"it":return so.capitalize(r.format("dddd D MMMM"));case"es":return so.capitalize(r.format("dddd D [de] MMMM"));case"de":return r.format("dddd, D. MMMM");default:return r.format("dddd, MMMM Do")}},fo=r=>r.format("LT"),Pc=(r,o)=>{const i=ao(r,o),c=fo(r);switch(o){case"fr":return`${i} à ${c}`;case"it":return`${i} alle ${c}`;case"es":return`${i} a las ${c}`;case"de":return`${i} um ${c}`;default:return`${i} at ${c}`}},Cc=r=>r.format("ll"),Yc=(r,o)=>{switch(o){case"fr":case"de":case"it":return r.format("HH:mm");case"es":return r.format("H:mm");default:return r.format("h:mm")}},Fc=r=>r.format("L"),Hc=r=>r.format("L LT");var co=(r=>(r.SimpleDate="SimpleDate",r.SimpleDateTime="SimpleDateTime",r.ExtraShortDate="ExtraShortDate",r.InlineExtraShortDate="InlineExtraShortDate",r.ShortDate="ShortDate",r.InlineShortDate="InlineShortDate",r.Date="Date",r.LongDate="LongDate",r.LongDateTime="LongDateTime",r.ShortTime="ShortTime",r.Time="Time",r.DateTime="DateTime",r))(co||{});const Bc=(r,o,i,c)=>{let d=_t(r);c&&(d=d.tz(c)),i&&(d=d.locale(i));const E=d.locale();switch(o){case"SimpleDate":return Fc(d);case"SimpleDateTime":return Hc(d);case"ExtraShortDate":return Sc(d,E);case"InlineExtraShortDate":return bc(d,E);case"ShortDate":return Cc(d);case"InlineShortDate":return xc(d,E);case"Date":return Oc(d);case"LongDate":return ao(d,E);case"LongDateTime":return Pc(d,E);case"ShortTime":return Yc(d,E);case"Time":return fo(d);case"DateTime":return Dc(d)}};var _e=(r=>(r.Contains="Contains",r.DoesntContain="DoesntContain",r.DoesntEndWith="DoesntEndWith",r.DoesntEqual="DoesntEqual",r.DoesntStartWith="DoesntStartWith",r.EndsWith="EndsWith",r.Equals="Equals",r.MatchesRegex="MatchesRegex",r.StartsWith="StartsWith",r))(_e||{});const Wc="http://_meltingspot.local",kc=200,Gc=/(\([^()]*[+*][^()]*\))[+*]/,zc=r=>r.length<=kc&&!Gc.test(r),qc=r=>{try{const o=new URL(r,Wc);return`${o.pathname}${o.search}${o.hash}`}catch{return r}},Er=r=>r.startsWith("/")?r:`/${r}`,Kc=(r,o)=>{switch(o.operator){case _e.MatchesRegex:if(!zc(o.value))return!1;try{return new RegExp(o.value).test(r)}catch{return!1}case _e.StartsWith:return r.startsWith(Er(o.value));case _e.DoesntStartWith:return!r.startsWith(Er(o.value));case _e.EndsWith:return r.endsWith(o.value);case _e.DoesntEndWith:return!r.endsWith(o.value);case _e.Contains:return r.includes(o.value);case _e.DoesntContain:return!r.includes(o.value);case _e.Equals:return r===Er(o.value);case _e.DoesntEqual:return r!==Er(o.value)}},Qc=(r,o)=>{const i=o.rules.map(c=>Kc(r,c));return o.ruleOperator==="AND"?i.every(Boolean):i.some(Boolean)},Zc=(r,o)=>{const i=qc(r),c=o.blocks.map(d=>Qc(i,d));return o.blockOperator==="AND"?c.every(Boolean):c.some(Boolean)},Jc="data-meltingspot-playbook-editor-active",di="meltingspot:playbook-editor:active-changed",Vc=()=>typeof document<"u"&&typeof document.dispatchEvent=="function",lo=()=>Vc()?document.documentElement.getAttribute(Jc)==="true":!1;class Xc{constructor(){this.listener=null,this.lastOptions=null,this.chain=Promise.resolve()}enqueue(o){const i=this.chain.then(o);return this.chain=i.catch(()=>{}),i}get isBound(){return this.listener!==null}bind(o){if(this.listener!==null||typeof document>"u")return;const i=()=>{if(lo()){Promise.resolve().then(()=>o.onEditorActive()).catch(d=>{console.warn("[playbook-editor] onEditorActive callback failed",d)});return}const c=this.lastOptions;c!==null&&Promise.resolve().then(()=>o.onEditorInactive(c)).catch(d=>{console.warn("[playbook-editor] onEditorInactive callback failed",d)})};document.addEventListener(di,i),this.listener=i}cacheOptions(o){this.lastOptions=o}clearOptions(){this.lastOptions=null}unbind(){this.listener!==null&&typeof document<"u"&&document.removeEventListener(di,this.listener),this.listener=null,this.lastOptions=null}}const jc="0.1.0";class ho{constructor(o){this.debug=!1,this.debug=o?.debug??!1,this.appName=o?.appName,this.appVersion=o?.appVersion}log(o,...i){this.debug&&this.print(o,"info",i)}warn(o,...i){this.print(o,"warn",i)}error(o,...i){this.print(o,"error",i)}print(o,i,c){const g=[`[${["MeltingSpot",this.appName,this.appVersion].filter(Boolean).join(" - ")}] ${o}`];c.length&&g.push(...c),console[i](...g)}}const _o=new ho({appName:"Core SDK",appVersion:jc}),nl=r=>{_o.debug=r},el=r=>r.toLowerCase().replace(/[^a-z0-9-]/g,""),tl=["/user"],rl=({deeplink:r,spotId:o})=>{try{const i=new URL(r,"https://unused.com");let c=i.pathname;return i.search&&(c+=i.search),i.hash&&(c+=i.hash),tl.some(d=>c.startsWith(d))||(c=`/spot/${o}/${zu(c)}`),c}catch(i){return _o.warn("Failed to parse deeplink URL",i),null}},il=[/(^|\.)meltingspot\.io$/i],ul=r=>{let o;try{const E=qu(r);o=new URL(E)}catch{throw new Error(`Invalid baseURL: ${r}`)}const i=o.hostname==="localhost"||o.hostname==="127.0.0.1",c=o.protocol==="https:",d=il.some(E=>E.test(o.hostname));if(!i&&(!c||!d))throw new Error(`Untrusted baseURL origin: ${o.origin}`);return o.origin},ol={msApiBaseUrl:"https://openapi.meltingspot.io/",msCommunityWebBaseUrl:"https://go.meltingspot.io/",ssoToken:void 0,spotId:"",rootDocument:globalThis.document};class pe{constructor(){this.configuration=ol}static getInstance(){return pe.instance||(pe.instance=new pe),pe.instance}setConfiguration(o){this.configuration={...this.configuration,...o}}static getConfiguration(o={}){return{...pe.getInstance().configuration,...o}}}const po="%[a-f0-9]{2}",go=new RegExp("("+po+")|([^%]+?)","gi"),mo=new RegExp("("+po+")+","gi");function _i(r,o){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;o=o||1;const i=r.slice(0,o),c=r.slice(o);return Array.prototype.concat.call([],_i(i),_i(c))}function sl(r){try{return decodeURIComponent(r)}catch{let o=r.match(go)||[];for(let i=1;i<o.length;i++)r=_i(o,i).join(""),o=r.match(go)||[];return r}}function al(r){const o={"%FE%FF":"��","%FF%FE":"��"};let i=mo.exec(r);for(;i;){try{o[i[0]]=decodeURIComponent(i[0])}catch{const d=sl(i[0]);d!==i[0]&&(o[i[0]]=d)}i=mo.exec(r)}o["%C2"]="�";const c=Object.keys(o);for(const d of c)r=r.replace(new RegExp(d,"g"),o[d]);return r}function fl(r){if(typeof r!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof r+"`");try{return decodeURIComponent(r)}catch{return al(r)}}function cl(r,o){const i={};if(Array.isArray(o))for(const c of o){const d=Object.getOwnPropertyDescriptor(r,c);d?.enumerable&&Object.defineProperty(i,c,d)}else for(const c of Reflect.ownKeys(r)){const d=Object.getOwnPropertyDescriptor(r,c);if(d.enumerable){const E=r[c];o(c,E,r)&&Object.defineProperty(i,c,d)}}return i}function vo(r,o){if(!(typeof r=="string"&&typeof o=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(r===""||o==="")return[];const i=r.indexOf(o);return i===-1?[]:[r.slice(0,i),r.slice(i+o.length)]}const ll=r=>r==null,hl=r=>encodeURIComponent(r).replaceAll(/[!'()*]/g,o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`),pi=Symbol("encodeFragmentIdentifier");function dl(r){switch(r.arrayFormat){case"index":return o=>(i,c)=>{const d=i.length;return c===void 0||r.skipNull&&c===null||r.skipEmptyString&&c===""?i:c===null?[...i,[Ln(o,r),"[",d,"]"].join("")]:[...i,[Ln(o,r),"[",Ln(d,r),"]=",Ln(c,r)].join("")]};case"bracket":return o=>(i,c)=>c===void 0||r.skipNull&&c===null||r.skipEmptyString&&c===""?i:c===null?[...i,[Ln(o,r),"[]"].join("")]:[...i,[Ln(o,r),"[]=",Ln(c,r)].join("")];case"colon-list-separator":return o=>(i,c)=>c===void 0||r.skipNull&&c===null||r.skipEmptyString&&c===""?i:c===null?[...i,[Ln(o,r),":list="].join("")]:[...i,[Ln(o,r),":list=",Ln(c,r)].join("")];case"comma":case"separator":case"bracket-separator":{const o=r.arrayFormat==="bracket-separator"?"[]=":"=";return i=>(c,d)=>d===void 0||r.skipNull&&d===null||r.skipEmptyString&&d===""?c:(d=d===null?"":d,c.length===0?[[Ln(i,r),o,Ln(d,r)].join("")]:[[c,Ln(d,r)].join(r.arrayFormatSeparator)])}default:return o=>(i,c)=>c===void 0||r.skipNull&&c===null||r.skipEmptyString&&c===""?i:c===null?[...i,Ln(o,r)]:[...i,[Ln(o,r),"=",Ln(c,r)].join("")]}}function _l(r){let o;switch(r.arrayFormat){case"index":return(i,c,d)=>{if(o=/\[(\d*)]$/.exec(i),i=i.replace(/\[\d*]$/,""),!o){d[i]=c;return}d[i]===void 0&&(d[i]={}),d[i][o[1]]=c};case"bracket":return(i,c,d)=>{if(o=/(\[])$/.exec(i),i=i.replace(/\[]$/,""),!o){d[i]=c;return}if(d[i]===void 0){d[i]=[c];return}d[i]=[...d[i],c]};case"colon-list-separator":return(i,c,d)=>{if(o=/(:list)$/.exec(i),i=i.replace(/:list$/,""),!o){d[i]=c;return}if(d[i]===void 0){d[i]=[c];return}d[i]=[...d[i],c]};case"comma":case"separator":return(i,c,d)=>{const E=typeof c=="string"&&c.includes(r.arrayFormatSeparator),g=typeof c=="string"&&!E&&De(c,r).includes(r.arrayFormatSeparator);c=g?De(c,r):c;const y=E||g?c.split(r.arrayFormatSeparator).map(D=>De(D,r)):c===null?c:De(c,r);d[i]=y};case"bracket-separator":return(i,c,d)=>{const E=/(\[])$/.test(i);if(i=i.replace(/\[]$/,""),!E){d[i]=c&&De(c,r);return}const g=c===null?[]:De(c,r).split(r.arrayFormatSeparator);if(d[i]===void 0){d[i]=g;return}d[i]=[...d[i],...g]};default:return(i,c,d)=>{if(d[i]===void 0){d[i]=c;return}d[i]=[...[d[i]].flat(),c]}}}function Eo(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function Ln(r,o){return o.encode?o.strict?hl(r):encodeURIComponent(r):r}function De(r,o){return o.decode?fl(r):r}function To(r){return Array.isArray(r)?r.sort():typeof r=="object"?To(Object.keys(r)).sort((o,i)=>Number(o)-Number(i)).map(o=>r[o]):r}function wo(r){const o=r.indexOf("#");return o!==-1&&(r=r.slice(0,o)),r}function pl(r){let o="";const i=r.indexOf("#");return i!==-1&&(o=r.slice(i)),o}function Ao(r,o,i){return i==="string"&&typeof r=="string"?r:typeof i=="function"&&typeof r=="string"?i(r):i==="boolean"&&r===null?!0:i==="boolean"&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")?r.toLowerCase()==="true":i==="boolean"&&r!==null&&(r.toLowerCase()==="1"||r.toLowerCase()==="0")?r.toLowerCase()==="1":i==="string[]"&&o.arrayFormat!=="none"&&typeof r=="string"?[r]:i==="number[]"&&o.arrayFormat!=="none"&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?[Number(r)]:i==="number"&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?Number(r):o.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")?r.toLowerCase()==="true":o.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?Number(r):r}function gi(r){r=wo(r);const o=r.indexOf("?");return o===-1?"":r.slice(o+1)}function mi(r,o){o={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...o},Eo(o.arrayFormatSeparator);const i=_l(o),c=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return c;for(const d of r.split("&")){if(d==="")continue;const E=o.decode?d.replaceAll("+"," "):d;let[g,y]=vo(E,"=");g===void 0&&(g=E),y=y===void 0?null:["comma","separator","bracket-separator"].includes(o.arrayFormat)?y:De(y,o),i(De(g,o),y,c)}for(const[d,E]of Object.entries(c))if(typeof E=="object"&&E!==null&&o.types[d]!=="string")for(const[g,y]of Object.entries(E)){const D=o.types[d]?o.types[d].replace("[]",""):void 0;E[g]=Ao(y,o,D)}else typeof E=="object"&&E!==null&&o.types[d]==="string"?c[d]=Object.values(E).join(o.arrayFormatSeparator):c[d]=Ao(E,o,o.types[d]);return o.sort===!1?c:(o.sort===!0?Object.keys(c).sort():Object.keys(c).sort(o.sort)).reduce((d,E)=>{const g=c[E];return d[E]=g&&typeof g=="object"&&!Array.isArray(g)?To(g):g,d},Object.create(null))}function yo(r,o){if(!r)return"";o={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...o},Eo(o.arrayFormatSeparator);const i=g=>o.skipNull&&ll(r[g])||o.skipEmptyString&&r[g]==="",c=dl(o),d={};for(const[g,y]of Object.entries(r))i(g)||(d[g]=y);const E=Object.keys(d);return o.sort!==!1&&E.sort(o.sort),E.map(g=>{const y=r[g];return y===void 0?"":y===null?Ln(g,o):Array.isArray(y)?y.length===0&&o.arrayFormat==="bracket-separator"?Ln(g,o)+"[]":y.reduce(c(g),[]).join("&"):Ln(g,o)+"="+Ln(y,o)}).filter(g=>g.length>0).join("&")}function Io(r,o){o={decode:!0,...o};let[i,c]=vo(r,"#");return i===void 0&&(i=r),{url:i?.split("?")?.[0]??"",query:mi(gi(r),o),...o&&o.parseFragmentIdentifier&&c?{fragmentIdentifier:De(c,o)}:{}}}function Lo(r,o){o={encode:!0,strict:!0,[pi]:!0,...o};const i=wo(r.url).split("?")[0]||"",c=gi(r.url),d={...mi(c,{sort:!1,...o}),...r.query};let E=yo(d,o);E&&=`?${E}`;let g=pl(r.url);if(typeof r.fragmentIdentifier=="string"){const y=new URL(i);y.hash=r.fragmentIdentifier,g=o[pi]?y.hash:`#${r.fragmentIdentifier}`}return`${i}${E}${g}`}function Ro(r,o,i){i={parseFragmentIdentifier:!0,[pi]:!1,...i};const{url:c,query:d,fragmentIdentifier:E}=Io(r,i);return Lo({url:c,query:cl(d,o),fragmentIdentifier:E},i)}function gl(r,o,i){const c=Array.isArray(o)?d=>!o.includes(d):(d,E)=>!o(d,E);return Ro(r,c,i)}const ml=Object.freeze(Object.defineProperty({__proto__:null,exclude:gl,extract:gi,parse:mi,parseUrl:Io,pick:Ro,stringify:yo,stringifyUrl:Lo},Symbol.toStringTag,{value:"Module"}));class Gn extends Error{constructor(o,i){super(`HTTP Error ${o}${i?`: ${i}`:""}`),this.code=o,this.name="HttpError",Object.setPrototypeOf(this,Gn.prototype)}}var On=(r=>(r.GET="GET",r.PATCH="PATCH",r.POST="POST",r))(On||{});class Mo{constructor(){this.headers={}}setHeaders(o){this.headers=o}async get(o){try{const i=o.query?`${o.url}?${this.serializeQuery(o.query)}`:o.url,c=await fetch(i,{headers:{...this.headers,...o.headers,"Content-Type":"application/json"}});return c.ok?sn(await c.json()):q(new Gn(c.status,await c.text()))}catch(i){const c=i instanceof Error?i.message:"Unknown error";return q(new Gn(ie.INTERNAL_SERVER_ERROR,c))}}async post(o){try{const i=await fetch(o.url,{method:"POST",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload)});return i.ok?sn(await i.json()):q(new Gn(i.status,await i.text()))}catch(i){const c=i instanceof Error?i.message:"Unknown error";return q(new Gn(ie.INTERNAL_SERVER_ERROR,c))}}async patch(o){try{const i=await fetch(o.url,{method:"PATCH",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload)});return i.ok?sn(await i.json()):q(new Gn(i.status,await i.text()))}catch(i){const c=i instanceof Error?i.message:"Unknown error";return q(new Gn(ie.INTERNAL_SERVER_ERROR,c))}}serializeQuery(o){if(typeof o=="string")return o;if(typeof o=="object")for(const i in o)o[i]===void 0&&delete o[i];return o=ml.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"}};var Oo=(r=>(r.TokensUpdated="auth:tokens-updated",r))(Oo||{});class Se extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return Se.instance||(Se.instance=new Se),Se.instance}async loginWithPassword(o,i){const c=await this.callApi({endpoint:Tr.accessToken.email,method:"POST",body:{email:o,password:i},withSpotId:!0});if(c.isErr())return q(c.error);const{accessToken:d,refreshToken:E}=c.value;return this.setTokens(d.token,E.token),sn({accessToken:d.token,refreshToken:E.token})}async loginWithSsoToken(o){const i=await this.callApi({endpoint:Tr.accessToken.sso.jwt,method:"POST",body:{token:o},withSpotId:!0});if(i.isErr())return q(i.error);const{accessToken:c,refreshToken:d}=i.value;return this.setTokens(c.token,d.token),sn({accessToken:c.token,refreshToken:d.token})}loginWithAuthTokens(o,i){return this.setTokens(o,i),{accessToken:o,refreshToken:i}}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 q(o.error);const{accessToken:i,refreshToken:c}=o.value;return this.setTokens(i.token,c.token),sn({accessToken:i.token,refreshToken:c.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(o,i){if(this.accessToken!==o||this.refreshToken!==i){this.accessToken=o,this.refreshToken=i;const c=new CustomEvent("auth:tokens-updated",{detail:{accessToken:o,refreshToken:i}});this.dispatchEvent(c)}}async callApi(o){try{const{spotId:i,msApiBaseUrl:c}=pe.getConfiguration(),d=ur(o.endpoint,c),E={"Content-Type":"application/json",...o.headers};o.withSpotId&&i&&(E[Do.SpotId]=i);const g=await fetch(d,{method:o.method,body:o.body?JSON.stringify(o.body):void 0,headers:E});if(!g.ok)return q(new Gn(g.status,g.statusText));if(g.status===ie.NO_CONTENT)return sn(void 0);const y=await g.json();return sn(y)}catch(i){return q(new Gn(ie.INTERNAL_SERVER_ERROR,i instanceof Error?i.message:String(i)))}}}var Do=(r=>(r.Authorization="Authorization",r.SpotId="x-spotid",r))(Do||{});class ue{constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=Se.getInstance(),this.httpService=new Mo}static getInstance(){return ue.instance||(ue.instance=new ue),ue.instance}static buildAuthenticatedRequest(o){const{msApiBaseUrl:i,spotId:c}=pe.getConfiguration(),d=ur(o,i),E=Se.getInstance().getAccessToken();if(!E)return q(new Error("Not authenticated"));const g={"Content-Type":"application/json",Authorization:`Bearer ${E}`};return c&&(g["x-spotid"]=c),sn({url:d,headers:g})}static async stream(o,i,c){const d=ue.buildAuthenticatedRequest(o);if(d.isErr())return q(d.error);const{url:E,headers:g}=d.value;try{const y=await fetch(E,{method:"POST",headers:g,...i!==void 0?{body:JSON.stringify(i)}:{},...c?{signal:c}:{}});if(!y.ok){const D=await y.text();return q(new Error(`HTTP ${y.status}: ${D}`))}return y.body?sn(y.body):q(new Error("Response body is empty"))}catch(y){const D=y instanceof Error?y.message:"Unknown error";return q(y instanceof Error?y:new Error(D))}}get pendingCount(){return this.queue.length}enqueue(o){return new Promise(i=>{const c=async()=>{try{const d=await o();i(d)}catch(d){i(q(new Gn(ie.INTERNAL_SERVER_ERROR,d instanceof Error?d.message:"Unknown error")))}};this.queue.push(c),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){const 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 i=async()=>{const{spotId:d,msApiBaseUrl:E}=pe.getConfiguration(),g={...o.options?.headers??{}};d&&(g["x-spotid"]=d);const y=this.authService.getAccessToken(),{requiresAuth:D=!0}=o;if(!y&&D)return q(new Gn(ie.UNAUTHORIZED));y&&(g.Authorization=`Bearer ${y}`);const V=ur(o.endpoint,E);switch(o.method){case On.GET:return this.httpService.get({...o.options??{},headers:g,url:V});case On.PATCH:return this.httpService.patch({...o.options??{},headers:g,url:V});case On.POST:return this.httpService.post({...o.options??{},headers:g,url:V});default:return q(new Gn(ie.METHOD_NOT_ALLOWED,"Method not allowed"))}};let c=await i();if(c.isErr()&&c.error.code===ie.UNAUTHORIZED){const d=await this.authService.refresh();if(d.isErr())return q(new Gn(ie.UNAUTHORIZED,d.error.message));c=await i()}return c})}}const Ie={playbooks:"/v1/playbooks",pages:r=>`/v1/playbooks/${r}/pages`,hotspots:(r,o)=>`/v1/playbooks/${r}/pages/${o}/hotspots`,hotspot:(r,o,i)=>`/v1/playbooks/${r}/pages/${o}/hotspots/${i}`,accessibleIntents:(r,o)=>`/v1/playbooks/${r}/pages/${o}/accessibleIntents`,intents:(r,o,i)=>`/v1/playbooks/${r}/pages/${o}/hotspots/${i}/intents`,intent:(r,o,i,c)=>`/v1/playbooks/${r}/pages/${o}/hotspots/${i}/intents/${c}`},wr=50;class pt{static getInstance(){return pt.instance||(pt.instance=new pt),pt.instance}constructor(){this.meltingSpotApi=ue.getInstance()}async listPlaybooks(o){const i=await this.meltingSpotApi.call({method:On.GET,endpoint:Ie.playbooks,options:{query:{page:o?.page??1,limit:o?.limit??wr,...o?.domain?{"domain[eq]":o.domain}:{}}}});return i.isErr()?q(i.error):sn(i.value)}async listPlaybookPages(o){const i=await this.meltingSpotApi.call({method:On.GET,endpoint:Ie.pages(o.playbookId),options:{query:{page:o.page??1,limit:o.limit??wr,...o.url?{"url[eq]":o.url}:{}}}});return i.isErr()?q(i.error):sn(i.value)}async createPlaybookPage(o,i){const c=await this.meltingSpotApi.call({method:On.POST,endpoint:Ie.pages(o.playbookId),options:{payload:i}});return c.isErr()?q(c.error):sn(c.value)}async listAccessiblePlaybookIntents(o){const i=await this.meltingSpotApi.call({method:On.GET,endpoint:Ie.accessibleIntents(o.playbookId,o.pageId),options:{query:{...o.domain?{"domain[eq]":o.domain}:{}}}});return i.isErr()?q(i.error):sn(i.value)}async listPlaybookHotspots(o){const i=await this.meltingSpotApi.call({method:On.GET,endpoint:Ie.hotspots(o.playbookId,o.pageId),options:{query:{page:o.page??1,limit:o.limit??wr,...o.intentStatus?{"intentStatus[eq]":o.intentStatus}:{},...o.widgetType?{"widgetType[eq]":o.widgetType}:{}}}});return i.isErr()?q(i.error):sn(i.value)}async createPlaybookHotspot(o,i){const c=await this.meltingSpotApi.call({method:On.POST,endpoint:Ie.hotspots(o.playbookId,o.pageId),options:{payload:i}});return c.isErr()?q(c.error):sn(c.value)}async updatePlaybookHotspot(o,i){const c=await this.meltingSpotApi.call({method:On.PATCH,endpoint:Ie.hotspot(o.playbookId,o.pageId,o.hotspotId),options:{payload:i}});return c.isErr()?q(c.error):sn(c.value)}async listPlaybookIntents(o){const i=await this.meltingSpotApi.call({method:On.GET,endpoint:Ie.intents(o.playbookId,o.pageId,o.hotspotId),options:{query:{page:o.page??1,limit:o.limit??wr,...o.status?{"status[eq]":o.status}:{}}}});return i.isErr()?q(i.error):sn(i.value)}async createPlaybookIntent(o,i){const c=await this.meltingSpotApi.call({method:On.POST,endpoint:Ie.intents(o.playbookId,o.pageId,o.hotspotId),options:{payload:i}});return c.isErr()?q(c.error):sn(c.value)}async updatePlaybookIntent(o,i){const c=await this.meltingSpotApi.call({method:On.PATCH,endpoint:Ie.intent(o.playbookId,o.pageId,o.hotspotId,o.intentId),options:{payload:i}});return c.isErr()?q(c.error):sn(c.value)}}const vl={me:"/v1/spots/me"},El=50;class gt{static getInstance(){return gt.instance||(gt.instance=new gt),gt.instance}constructor(){this.meltingSpotApi=ue.getInstance()}async listSpotsForMe(o){const i=await this.meltingSpotApi.call({method:On.GET,endpoint:vl.me,options:{query:{page:1,limit:El,...o?.spotMemberRole?{"spotMemberRole[eq]":o.spotMemberRole}:{}}}});return i.isErr()?q(i.error):sn(i.value)}}const Tl={spotMember:{me:"/v1/spotMembers/me"}};class et{static getInstance(){return et.instance||(et.instance=new et),et.instance}constructor(){this.meltingSpotApi=ue.getInstance()}async getSpotMemberForMe(){const o=await this.meltingSpotApi.call({method:On.GET,endpoint:Tl.spotMember.me});return o.isErr()?q(o.error):sn(o.value)}}const wl={spotMemberSsoToken:"/v1/spotMembers/auth/sso/jwt"};class mt{static getInstance(){return mt.instance||(mt.instance=new mt),mt.instance}constructor(){this.meltingSpotApi=ue.getInstance()}async generateSsoToken(){const o=await this.meltingSpotApi.call({method:On.POST,endpoint:wl.spotMemberSsoToken,options:{payload:{}}});return o.isErr()?q(o.error):sn(o.value.token)}}class tt{static getInstance(){return tt.instance||(tt.instance=new tt),tt.instance}constructor(){this.spotMemberAuthApiService=mt.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}}class Al{constructor(o){this.active=!1,this.lastObservedUrl=null,this.options={onRouteChange:o.onRouteChange,debounceMs:o.debounceMs??0,enableDeduplication:o.enableDeduplication??!0,enableDomMutationDetection:o.enableDomMutationDetection??!1,enableHistoryChange:o.enableHistoryChange??!0,enablePopState:o.enablePopState??!0,enableHashChange:o.enableHashChange??!0,enableLoad:o.enableLoad??!0,rootDocument:o.rootDocument}}start(){this.active||(this.active=!0,this.lastObservedUrl=null,this.options.enablePopState&&(this.popStateListener=()=>this.handleNavigationEvent("popstate"),window.addEventListener("popstate",this.popStateListener)),this.options.enableHashChange&&(this.hashChangeListener=()=>this.handleNavigationEvent("hashchange"),window.addEventListener("hashchange",this.hashChangeListener)),this.options.enableLoad&&(this.loadListener=()=>this.handleNavigationEvent("load"),window.addEventListener("load",this.loadListener)),this.options.enableDomMutationDetection&&(this.mutationObserver=new MutationObserver(()=>{this.handleNavigationEvent("locationchange")}),this.mutationObserver.observe(this.options.rootDocument??document,{childList:!0,subtree:!0})),this.options.enableHistoryChange&&this.patchHistoryListeners())}stop(){this.active&&(this.active=!1,this.debounceTimer!==void 0&&(clearTimeout(this.debounceTimer),this.debounceTimer=void 0),this.popStateListener&&(window.removeEventListener("popstate",this.popStateListener),this.popStateListener=void 0),this.hashChangeListener&&(window.removeEventListener("hashchange",this.hashChangeListener),this.hashChangeListener=void 0),this.loadListener&&(window.removeEventListener("load",this.loadListener),this.loadListener=void 0),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=void 0),(this.originalPushState||this.originalReplaceState)&&this.restoreHistoryListeners(),this.lastObservedUrl=null)}handleNavigationEvent(o){if(!this.active)return;const i=window.location.href;this.options.enableDeduplication&&this.lastObservedUrl===i||(this.lastObservedUrl=i,this.options.debounceMs>0?(this.debounceTimer!==void 0&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=void 0,this.options.onRouteChange(i,o)},this.options.debounceMs)):this.options.onRouteChange(i,o))}patchHistoryListeners(){this.originalPushState=window.history.pushState,this.originalReplaceState=window.history.replaceState,window.history.pushState=(...o)=>{const i=this.originalPushState?.apply(window.history,o);return this.handleNavigationEvent("history.pushState"),i},window.history.replaceState=(...o)=>{const i=this.originalReplaceState?.apply(window.history,o);return this.handleNavigationEvent("history.replaceState"),i}}restoreHistoryListeners(){this.originalPushState&&(window.history.pushState=this.originalPushState,this.originalPushState=void 0),this.originalReplaceState&&(window.history.replaceState=this.originalReplaceState,this.originalReplaceState=void 0)}}const yl={events:"/v1/analytics/events"};class vt{static getInstance(){return vt.instance||(vt.instance=new vt),vt.instance}constructor(){this.meltingSpotApi=ue.getInstance()}async appendEvent(o){const i=await this.meltingSpotApi.call({method:On.POST,endpoint:yl.events,options:{payload:o}});return i.isErr()?q(i.error):sn(i.value)}}const Il=r=>{const o=r.get("utm_source");if(o)return{source:o,medium:r.get("utm_medium")??void 0,campaign:r.get("utm_campaign")??void 0,term:r.get("utm_term")??void 0,content:r.get("utm_content")??void 0}},Ll=r=>r?Object.entries(r).reduce((o,[i,c])=>(c!=null&&(o[`utm_${i}`]=c),o),{}):{};var So=(r=>(r.Active="Active",r.Closed="Closed",r.Expired="Expired",r))(So||{}),bo=(r=>(r.User="User",r.Assistant="Assistant",r))(bo||{}),xo=(r=>(r.Metadata="metadata",r.Token="token",r.Action="action",r.Bubble="bubble",r.Done="done",r.Error="error",r))(xo||{}),Uo=(r=>(r.PlaybookIntent="PlaybookIntent",r.UserInitiated="UserInitiated",r.Welcome="Welcome",r.Resume="Resume",r.Discover="Discover",r.Recommend="Recommend",r))(Uo||{}),No=(r=>(r.ExtraExtraSmall="ExtraExtraSmall",r.ExtraSmall="ExtraSmall",r.Small="Small",r.Medium="Medium",r.Large="Large",r))(No||{}),$o=(r=>(r.Dropdown="Dropdown",r.Inline="Inline",r.Overlay="Overlay",r))($o||{}),Po=(r=>(r.Left="Left",r.Right="Right",r))(Po||{}),Co=(r=>(r.Top="Top",r.Bottom="Bottom",r))(Co||{}),Yo=(r=>(r.TopLeft="TopLeft",r.TopRight="TopRight",r.BottomLeft="BottomLeft",r.BottomRight="BottomRight",r))(Yo||{}),Fo=(r=>(r.Button="Button",r.Card="Card",r.CardInline="CardInline",r.Carousel="Carousel",r.Helper="Helper",r.ListOfContent="ListOfContent",r.ListOfContentInline="ListOfContentInline",r))(Fo||{}),Ho=(r=>(r.Inline="Inline",r.Modal="Modal",r.Drawer="Drawer",r))(Ho||{}),Bo=(r=>(r.Self="Self",r.Parent="Parent",r.Top="Top",r))(Bo||{}),Wo=(r=>(r.Left="Left",r.Right="Right",r))(Wo||{}),ko=(r=>(r.Body="Body",r.DOMSelector="DOMSelector",r))(ko||{}),Go=(r=>(r.After="After",r.AppendChild="AppendChild",r.Before="Before",r.PrependChild="PrependChild",r))(Go||{}),zo=(r=>(r.CSSSelector="CSSSelector",r.Slot="Slot",r))(zo||{}),qo=(r=>(r.Element="Element",r.WebComponent="WebComponent",r))(qo||{}),Ko=(r=>(r.Inline="Inline",r.Flex="Flex",r))(Ko||{}),Qo=(r=>(r.Horizontal="Horizontal",r.Vertical="Vertical",r))(Qo||{}),Zo=(r=>(r.Start="Start",r.Center="Center",r.End="End",r.Stretch="Stretch",r.Baseline="Baseline",r))(Zo||{}),Jo=(r=>(r.Course="Course",r.Live="Live",r.Link="Link",r.Page="Page",r))(Jo||{}),Vo=(r=>(r.Workshop="Workshop",r.Conference="Conference",r))(Vo||{}),Xo=(r=>(r.Ended="Ended",r.Planned="Planned",r.Live="Live",r))(Xo||{}),jo=(r=>(r.CloseA="CloseA",r.CloseB="CloseB",r.Later="Later",r))(jo||{});const Rl="a",Ml="mention_input",Ol="mention",Dl="var",Sl="p",bl="h1",xl="h2",Ul="h3",Nl="blockquote",$l="layout",Pl="layout-column",Cl="ul",Yl="ol",Fl="lic",Hl="li",Bl="img",Wl="iframely",kl="code_block",Gl="code_line";var ns=(r=>(r.Element="Element",r.FullPage="FullPage",r))(ns||{}),es=(r=>(r.Draft="Draft",r.Pending="Pending",r.Published="Published",r))(es||{}),ts=(r=>(r.Beacon="Beacon",r.List="List",r))(ts||{}),vi=(r=>(r.Channel="Channel",r.Collection="Collection",r.Course="Course",r.Forum="Forum",r.Link="Link",r.Live="Live",r.LearningPath="LearningPath",r.Page="Page",r.RichText="RichText",r.Topic="Topic",r))(vi||{});function zl(r){return Object.values(vi).includes(r)}const rs=pe.getInstance(),is=Se.getInstance(),us=tt.getInstance(),os={Playbook:pt.getInstance(),Spot:gt.getInstance(),SpotMember:et.getInstance()},Et=globalThis;Et.MeltingSpot||(Et.MeltingSpot={}),Et.MeltingSpot.Configuration=rs,Et.MeltingSpot.Auth=is,Et.MeltingSpot.Sso=us,Et.MeltingSpot.Api=os,I.ATTRIBUTE_BLOCKQUOTE=Nl,I.ATTRIBUTE_CODE_BLOCK=kl,I.ATTRIBUTE_CODE_LINE=Gl,I.ATTRIBUTE_H1=bl,I.ATTRIBUTE_H2=xl,I.ATTRIBUTE_H3=Ul,I.ATTRIBUTE_IFRAMELY=Wl,I.ATTRIBUTE_IMAGE=Bl,I.ATTRIBUTE_LAYOUT=$l,I.ATTRIBUTE_LAYOUT_COLUMN=Pl,I.ATTRIBUTE_LI=Hl,I.ATTRIBUTE_LIC=Fl,I.ATTRIBUTE_LINK=Rl,I.ATTRIBUTE_MENTION=Ol,I.ATTRIBUTE_MENTION_INPUT=Ml,I.ATTRIBUTE_OL=Yl,I.ATTRIBUTE_PARAGRAPH=Sl,I.ATTRIBUTE_UL=Cl,I.ATTRIBUTE_VARIABLE=Dl,I.AnalyticsApiService=vt,I.Api=os,I.Auth=is,I.AuthService=Se,I.AuthServiceEvents=Oo,I.BeaconIntegrationType=$o,I.BeaconRenderType=Fo,I.ButtonBeaconSize=No,I.Configuration=rs,I.ConfigurationService=pe,I.ConversationMessageRole=bo,I.ConversationSseEventType=xo,I.ConversationStatus=So,I.DEFAULT_PERMISSION_POLICIES=Ku,I.DateFormat=co,I.DrawerWidgetPosition=Wo,I.DropdownBeaconHorizontalPosition=Po,I.DropdownBeaconVerticalPosition=Co,I.HttpMethods=On,I.HttpService=Mo,I.LastActionState=jo,I.LearningPathContentType=Jo,I.LiveBuiltInType=Vo,I.LiveStatus=Xo,I.Logger=ho,I.MeltingSpotApi=ue,I.OverlayBeaconPosition=Yo,I.PLAYBOOK_EDITOR_ACTIVE_EVENT=di,I.PlaybookEditorAwareLifecycle=Xc,I.PlaybookHotspotLocation=ns,I.PlaybookIntentStatus=es,I.PlaybookIntentWidgetMode=ts,I.PlaybookPageMatchingOperator=_e,I.RouteChangeDetector=Al,I.SpotMemberApiService=et,I.SpotWidgetContentType=vi,I.Sso=us,I.SsoService=tt,I.TouchPointAnchorType=ko,I.TouchPointDOMInjectionPosition=Go,I.TouchPointDOMSelectorCssStepMode=qo,I.TouchPointDOMSelectorPathStepType=zo,I.TouchPointFlexAlign=Zo,I.TouchPointFlexDirection=Qo,I.TouchPointLayoutType=Ko,I.TriggerType=Uo,I.WidgetInjectionTarget=Bo,I.WidgetInjectionType=Ho,I.createDialog=qf,I.createIframe=Kf,I.dayjs=_t,I.flattenUtmParameters=Ll,I.formatBaseUrl=ul,I.formatDate=Bc,I.formatDeeplink=rl,I.formatUUID=el,I.getHTMLElement=zf,I.getTimeInfoWithStartAndEndDate=Mc,I.isPlaybookEditorActive=lo,I.isSpotWidgetContentType=zl,I.isTouchDevice=Qf,I.parseUtmParameters=Il,I.sanitizeUrl=ur,I.setLoggerDebugMode=nl,I.testUrlMatching=Zc,I.trimSlashLeft=zu,I.trimSlashRight=qu,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));
33
+ }`;var Z=$f(function(){return on(f,U+"return "+A).apply(i,l)});if(Z.source=A,Du(Z))throw Z;return Z}function Pv(n){return fn(n).toLowerCase()}function Cv(n){return fn(n).toUpperCase()}function Yv(n,e,t){if(n=fn(n),n&&(t||e===i))return ks(n);if(!n||!(e=ne(e)))return n;var u=Te(n),s=Te(e),f=Gs(u,s),l=zs(u,s)+1;return Ze(u,f,l).join("")}function Fv(n,e,t){if(n=fn(n),n&&(t||e===i))return n.slice(0,Ks(n)+1);if(!n||!(e=ne(e)))return n;var u=Te(n),s=zs(u,Te(e))+1;return Ze(u,0,s).join("")}function Hv(n,e,t){if(n=fn(n),n&&(t||e===i))return n.replace(Di,"");if(!n||!(e=ne(e)))return n;var u=Te(n),s=Gs(u,Te(e));return Ze(u,s).join("")}function Bv(n,e){var t=ln,u=rn;if(Tn(e)){var s="separator"in e?e.separator:s;t="length"in e?K(e.length):t,u="omission"in e?ne(e.omission):u}n=fn(n);var f=n.length;if(It(n)){var l=Te(n);f=l.length}if(t>=f)return n;var h=t-Lt(u);if(h<1)return u;var p=l?Ze(l,0,h).join(""):n.slice(0,h);if(s===i)return p+u;if(l&&(h+=p.length-h),Su(s)){if(n.slice(h).search(s)){var T,w=p;for(s.global||(s=qi(s.source,fn(ls.exec(s))+"g")),s.lastIndex=0;T=s.exec(w);)var A=T.index;p=p.slice(0,A===i?h:A)}}else if(n.indexOf(ne(s),h)!=h){var R=p.lastIndexOf(s);R>-1&&(p=p.slice(0,R))}return p+u}function Wv(n){return n=fn(n),n&&jl.test(n)?n.replace(as,md):n}var kv=xt(function(n,e,t){return n+(t?" ":"")+e.toUpperCase()}),Uu=$a("toUpperCase");function Nf(n,e,t){return n=fn(n),e=t?i:e,e===i?hd(n)?Td(n):rd(n):n.match(e)||[]}var $f=J(function(n,e){try{return Xn(n,i,e)}catch(t){return Du(t)?t:new W(t)}}),Gv=Ce(function(n,e){return se(e,function(t){t=Oe(t),$e(n,t,Mu(n[t],n))}),n});function zv(n){var e=n==null?0:n.length,t=N();return n=e?gn(n,function(u){if(typeof u[1]!="function")throw new ae(g);return[t(u[0]),u[1]]}):[],J(function(u){for(var s=-1;++s<e;){var f=n[s];if(Xn(f[0],this,u))return Xn(f[1],this,u)}})}function qv(n){return m_(ce(n,H))}function Nu(n){return function(){return n}}function Kv(n,e){return n==null||n!==n?e:n}var Qv=Ca(),Zv=Ca(!0);function Qn(n){return n}function $u(n){return da(typeof n=="function"?n:ce(n,H))}function Jv(n){return pa(ce(n,H))}function Vv(n,e){return ga(n,ce(e,H))}var Xv=J(function(n,e){return function(t){return Vt(t,n,e)}}),jv=J(function(n,e){return function(t){return Vt(n,t,e)}});function Pu(n,e,t){var u=Un(e),s=qr(e,u);t==null&&!(Tn(e)&&(s.length||!u.length))&&(t=e,e=n,n=this,s=qr(e,Un(e)));var f=!(Tn(t)&&"chain"in t)||!!t.chain,l=Fe(n);return se(s,function(h){var p=e[h];n[h]=p,l&&(n.prototype[h]=function(){var T=this.__chain__;if(f||T){var w=n(this.__wrapped__),A=w.__actions__=zn(this.__actions__);return A.push({func:p,args:arguments,thisArg:n}),w.__chain__=T,w}return p.apply(n,ke([this.value()],arguments))})}),n}function n0(){return Pn._===this&&(Pn._=Rd),this}function Cu(){}function e0(n){return n=K(n),J(function(e){return ma(e,n)})}var t0=_u(gn),r0=_u(Ys),i0=_u(Fi);function Pf(n){return wu(n)?Hi(Oe(n)):N_(n)}function u0(n){return function(e){return n==null?i:ft(n,e)}}var o0=Fa(),s0=Fa(!0);function Yu(){return[]}function Fu(){return!1}function a0(){return{}}function f0(){return""}function c0(){return!0}function l0(n,e){if(n=K(n),n<1||n>L)return[];var t=X,u=Fn(n,X);e=N(e),n-=X;for(var s=ki(u,e);++t<n;)e(t);return s}function h0(n){return G(n)?gn(n,Oe):ee(n)?[n]:zn(ef(fn(n)))}function d0(n){var e=++Id;return fn(n)+e}var _0=Xr(function(n,e){return n+e},0),p0=pu("ceil"),g0=Xr(function(n,e){return n/e},1),m0=pu("floor");function v0(n){return n&&n.length?zr(n,Qn,nu):i}function E0(n,e){return n&&n.length?zr(n,N(e,2),nu):i}function T0(n){return Bs(n,Qn)}function w0(n,e){return Bs(n,N(e,2))}function A0(n){return n&&n.length?zr(n,Qn,iu):i}function y0(n,e){return n&&n.length?zr(n,N(e,2),iu):i}var I0=Xr(function(n,e){return n*e},1),L0=pu("round"),R0=Xr(function(n,e){return n-e},0);function M0(n){return n&&n.length?Wi(n,Qn):0}function O0(n,e){return n&&n.length?Wi(n,N(e,2)):0}return a.after=Jg,a.ary=df,a.assign=Cm,a.assignIn=Mf,a.assignInWith=li,a.assignWith=Ym,a.at=Fm,a.before=_f,a.bind=Mu,a.bindAll=Gv,a.bindKey=pf,a.castArray=am,a.chain=cf,a.chunk=mp,a.compact=vp,a.concat=Ep,a.cond=zv,a.conforms=qv,a.constant=Nu,a.countBy=Mg,a.create=Hm,a.curry=gf,a.curryRight=mf,a.debounce=vf,a.defaults=Bm,a.defaultsDeep=Wm,a.defer=Vg,a.delay=Xg,a.difference=Tp,a.differenceBy=wp,a.differenceWith=Ap,a.drop=yp,a.dropRight=Ip,a.dropRightWhile=Lp,a.dropWhile=Rp,a.fill=Mp,a.filter=Dg,a.flatMap=xg,a.flatMapDeep=Ug,a.flatMapDepth=Ng,a.flatten=of,a.flattenDeep=Op,a.flattenDepth=Dp,a.flip=jg,a.flow=Qv,a.flowRight=Zv,a.fromPairs=Sp,a.functions=Zm,a.functionsIn=Jm,a.groupBy=$g,a.initial=xp,a.intersection=Up,a.intersectionBy=Np,a.intersectionWith=$p,a.invert=Xm,a.invertBy=jm,a.invokeMap=Cg,a.iteratee=$u,a.keyBy=Yg,a.keys=Un,a.keysIn=Kn,a.map=ui,a.mapKeys=ev,a.mapValues=tv,a.matches=Jv,a.matchesProperty=Vv,a.memoize=si,a.merge=rv,a.mergeWith=Of,a.method=Xv,a.methodOf=jv,a.mixin=Pu,a.negate=ai,a.nthArg=e0,a.omit=iv,a.omitBy=uv,a.once=nm,a.orderBy=Fg,a.over=t0,a.overArgs=em,a.overEvery=r0,a.overSome=i0,a.partial=Ou,a.partialRight=Ef,a.partition=Hg,a.pick=ov,a.pickBy=Df,a.property=Pf,a.propertyOf=u0,a.pull=Fp,a.pullAll=af,a.pullAllBy=Hp,a.pullAllWith=Bp,a.pullAt=Wp,a.range=o0,a.rangeRight=s0,a.rearg=tm,a.reject=kg,a.remove=kp,a.rest=rm,a.reverse=Lu,a.sampleSize=zg,a.set=av,a.setWith=fv,a.shuffle=qg,a.slice=Gp,a.sortBy=Zg,a.sortedUniq=Vp,a.sortedUniqBy=Xp,a.split=xv,a.spread=im,a.tail=jp,a.take=ng,a.takeRight=eg,a.takeRightWhile=tg,a.takeWhile=rg,a.tap=vg,a.throttle=um,a.thru=ii,a.toArray=If,a.toPairs=Sf,a.toPairsIn=bf,a.toPath=h0,a.toPlainObject=Rf,a.transform=cv,a.unary=om,a.union=ig,a.unionBy=ug,a.unionWith=og,a.uniq=sg,a.uniqBy=ag,a.uniqWith=fg,a.unset=lv,a.unzip=Ru,a.unzipWith=ff,a.update=hv,a.updateWith=dv,a.values=$t,a.valuesIn=_v,a.without=cg,a.words=Nf,a.wrap=sm,a.xor=lg,a.xorBy=hg,a.xorWith=dg,a.zip=_g,a.zipObject=pg,a.zipObjectDeep=gg,a.zipWith=mg,a.entries=Sf,a.entriesIn=bf,a.extend=Mf,a.extendWith=li,Pu(a,a),a.add=_0,a.attempt=$f,a.camelCase=vv,a.capitalize=xf,a.ceil=p0,a.clamp=pv,a.clone=fm,a.cloneDeep=lm,a.cloneDeepWith=hm,a.cloneWith=cm,a.conformsTo=dm,a.deburr=Uf,a.defaultTo=Kv,a.divide=g0,a.endsWith=Ev,a.eq=Ae,a.escape=Tv,a.escapeRegExp=wv,a.every=Og,a.find=Sg,a.findIndex=rf,a.findKey=km,a.findLast=bg,a.findLastIndex=uf,a.findLastKey=Gm,a.floor=m0,a.forEach=lf,a.forEachRight=hf,a.forIn=zm,a.forInRight=qm,a.forOwn=Km,a.forOwnRight=Qm,a.get=bu,a.gt=_m,a.gte=pm,a.has=Vm,a.hasIn=xu,a.head=sf,a.identity=Qn,a.includes=Pg,a.indexOf=bp,a.inRange=gv,a.invoke=nv,a.isArguments=ht,a.isArray=G,a.isArrayBuffer=gm,a.isArrayLike=qn,a.isArrayLikeObject=yn,a.isBoolean=mm,a.isBuffer=Je,a.isDate=vm,a.isElement=Em,a.isEmpty=Tm,a.isEqual=wm,a.isEqualWith=Am,a.isError=Du,a.isFinite=ym,a.isFunction=Fe,a.isInteger=Tf,a.isLength=fi,a.isMap=wf,a.isMatch=Im,a.isMatchWith=Lm,a.isNaN=Rm,a.isNative=Mm,a.isNil=Dm,a.isNull=Om,a.isNumber=Af,a.isObject=Tn,a.isObjectLike=wn,a.isPlainObject=rr,a.isRegExp=Su,a.isSafeInteger=Sm,a.isSet=yf,a.isString=ci,a.isSymbol=ee,a.isTypedArray=Nt,a.isUndefined=bm,a.isWeakMap=xm,a.isWeakSet=Um,a.join=Pp,a.kebabCase=Av,a.last=he,a.lastIndexOf=Cp,a.lowerCase=yv,a.lowerFirst=Iv,a.lt=Nm,a.lte=$m,a.max=v0,a.maxBy=E0,a.mean=T0,a.meanBy=w0,a.min=A0,a.minBy=y0,a.stubArray=Yu,a.stubFalse=Fu,a.stubObject=a0,a.stubString=f0,a.stubTrue=c0,a.multiply=I0,a.nth=Yp,a.noConflict=n0,a.noop=Cu,a.now=oi,a.pad=Lv,a.padEnd=Rv,a.padStart=Mv,a.parseInt=Ov,a.random=mv,a.reduce=Bg,a.reduceRight=Wg,a.repeat=Dv,a.replace=Sv,a.result=sv,a.round=L0,a.runInContext=_,a.sample=Gg,a.size=Kg,a.snakeCase=bv,a.some=Qg,a.sortedIndex=zp,a.sortedIndexBy=qp,a.sortedIndexOf=Kp,a.sortedLastIndex=Qp,a.sortedLastIndexBy=Zp,a.sortedLastIndexOf=Jp,a.startCase=Uv,a.startsWith=Nv,a.subtract=R0,a.sum=M0,a.sumBy=O0,a.template=$v,a.times=l0,a.toFinite=He,a.toInteger=K,a.toLength=Lf,a.toLower=Pv,a.toNumber=de,a.toSafeInteger=Pm,a.toString=fn,a.toUpper=Cv,a.trim=Yv,a.trimEnd=Fv,a.trimStart=Hv,a.truncate=Bv,a.unescape=Wv,a.uniqueId=d0,a.upperCase=kv,a.upperFirst=Uu,a.each=lf,a.eachRight=hf,a.first=sf,Pu(a,(function(){var n={};return Re(a,function(e,t){cn.call(a.prototype,t)||(n[t]=e)}),n})(),{chain:!1}),a.VERSION=c,se(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){a[n].placeholder=a}),se(["drop","take"],function(n,e){nn.prototype[n]=function(t){t=t===i?1:bn(K(t),0);var u=this.__filtered__&&!e?new nn(this):this.clone();return u.__filtered__?u.__takeCount__=Fn(t,u.__takeCount__):u.__views__.push({size:Fn(t,X),type:n+(u.__dir__<0?"Right":"")}),u},nn.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),se(["filter","map","takeWhile"],function(n,e){var t=e+1,u=t==Y||t==M;nn.prototype[n]=function(s){var f=this.clone();return f.__iteratees__.push({iteratee:N(s,3),type:t}),f.__filtered__=f.__filtered__||u,f}}),se(["head","last"],function(n,e){var t="take"+(e?"Right":"");nn.prototype[n]=function(){return this[t](1).value()[0]}}),se(["initial","tail"],function(n,e){var t="drop"+(e?"":"Right");nn.prototype[n]=function(){return this.__filtered__?new nn(this):this[t](1)}}),nn.prototype.compact=function(){return this.filter(Qn)},nn.prototype.find=function(n){return this.filter(n).head()},nn.prototype.findLast=function(n){return this.reverse().find(n)},nn.prototype.invokeMap=J(function(n,e){return typeof n=="function"?new nn(this):this.map(function(t){return Vt(t,n,e)})}),nn.prototype.reject=function(n){return this.filter(ai(N(n)))},nn.prototype.slice=function(n,e){n=K(n);var t=this;return t.__filtered__&&(n>0||e<0)?new nn(t):(n<0?t=t.takeRight(-n):n&&(t=t.drop(n)),e!==i&&(e=K(e),t=e<0?t.dropRight(-e):t.take(e-n)),t)},nn.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},nn.prototype.toArray=function(){return this.take(X)},Re(nn.prototype,function(n,e){var t=/^(?:filter|find|map|reject)|While$/.test(e),u=/^(?:head|last)$/.test(e),s=a[u?"take"+(e=="last"?"Right":""):e],f=u||/^find/.test(e);s&&(a.prototype[e]=function(){var l=this.__wrapped__,h=u?[1]:arguments,p=l instanceof nn,T=h[0],w=p||G(l),A=function(j){var tn=s.apply(a,ke([j],h));return u&&R?tn[0]:tn};w&&t&&typeof T=="function"&&T.length!=1&&(p=w=!1);var R=this.__chain__,U=!!this.__actions__.length,$=f&&!R,Z=p&&!U;if(!f&&w){l=Z?l:new nn(this);var P=n.apply(l,h);return P.__actions__.push({func:ii,args:[A],thisArg:i}),new fe(P,R)}return $&&Z?n.apply(this,h):(P=this.thru(A),$?u?P.value()[0]:P.value():P)})}),se(["pop","push","shift","sort","splice","unshift"],function(n){var e=Sr[n],t=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",u=/^(?:pop|shift)$/.test(n);a.prototype[n]=function(){var s=arguments;if(u&&!this.__chain__){var f=this.value();return e.apply(G(f)?f:[],s)}return this[t](function(l){return e.apply(G(l)?l:[],s)})}}),Re(nn.prototype,function(n,e){var t=a[e];if(t){var u=t.name+"";cn.call(Dt,u)||(Dt[u]=[]),Dt[u].push({name:e,func:t})}}),Dt[Vr(i,dn).name]=[{name:"wrapper",func:i}],nn.prototype.clone=Wd,nn.prototype.reverse=kd,nn.prototype.value=Gd,a.prototype.at=Eg,a.prototype.chain=Tg,a.prototype.commit=wg,a.prototype.next=Ag,a.prototype.plant=Ig,a.prototype.reverse=Lg,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=Rg,a.prototype.first=a.prototype.head,Gt&&(a.prototype[Gt]=yg),a}),Rt=wd();it?((it.exports=Rt)._=Rt,$i._=Rt):Pn._=Rt}).call(Uc)})(Ct,Ct.exports)),Ct.exports}var $c=Nc();const so=dt($c),ao=(r,o)=>{switch(o){case"fr":case"it":return so.capitalize(r.format("dddd D MMMM"));case"es":return so.capitalize(r.format("dddd D [de] MMMM"));case"de":return r.format("dddd, D. MMMM");default:return r.format("dddd, MMMM Do")}},fo=r=>r.format("LT"),Pc=(r,o)=>{const i=ao(r,o),c=fo(r);switch(o){case"fr":return`${i} à ${c}`;case"it":return`${i} alle ${c}`;case"es":return`${i} a las ${c}`;case"de":return`${i} um ${c}`;default:return`${i} at ${c}`}},Cc=r=>r.format("ll"),Yc=(r,o)=>{switch(o){case"fr":case"de":case"it":return r.format("HH:mm");case"es":return r.format("H:mm");default:return r.format("h:mm")}},Fc=r=>r.format("L"),Hc=r=>r.format("L LT");var co=(r=>(r.SimpleDate="SimpleDate",r.SimpleDateTime="SimpleDateTime",r.ExtraShortDate="ExtraShortDate",r.InlineExtraShortDate="InlineExtraShortDate",r.ShortDate="ShortDate",r.InlineShortDate="InlineShortDate",r.Date="Date",r.LongDate="LongDate",r.LongDateTime="LongDateTime",r.ShortTime="ShortTime",r.Time="Time",r.DateTime="DateTime",r))(co||{});const Bc=(r,o,i,c)=>{let d=_t(r);c&&(d=d.tz(c)),i&&(d=d.locale(i));const E=d.locale();switch(o){case"SimpleDate":return Fc(d);case"SimpleDateTime":return Hc(d);case"ExtraShortDate":return Sc(d,E);case"InlineExtraShortDate":return bc(d,E);case"ShortDate":return Cc(d);case"InlineShortDate":return xc(d,E);case"Date":return Oc(d);case"LongDate":return ao(d,E);case"LongDateTime":return Pc(d,E);case"ShortTime":return Yc(d,E);case"Time":return fo(d);case"DateTime":return Dc(d)}};var _e=(r=>(r.Contains="Contains",r.DoesntContain="DoesntContain",r.DoesntEndWith="DoesntEndWith",r.DoesntEqual="DoesntEqual",r.DoesntStartWith="DoesntStartWith",r.EndsWith="EndsWith",r.Equals="Equals",r.MatchesRegex="MatchesRegex",r.StartsWith="StartsWith",r))(_e||{});const Wc="http://_meltingspot.local",kc=200,Gc=/(\([^()]*[+*][^()]*\))[+*]/,zc=r=>r.length<=kc&&!Gc.test(r),qc=r=>{try{const o=new URL(r,Wc);return`${o.pathname}${o.search}${o.hash}`}catch{return r}},Er=r=>r.startsWith("/")?r:`/${r}`,Kc=(r,o)=>{switch(o.operator){case _e.MatchesRegex:if(!zc(o.value))return!1;try{return new RegExp(o.value).test(r)}catch{return!1}case _e.StartsWith:return r.startsWith(Er(o.value));case _e.DoesntStartWith:return!r.startsWith(Er(o.value));case _e.EndsWith:return r.endsWith(o.value);case _e.DoesntEndWith:return!r.endsWith(o.value);case _e.Contains:return r.includes(o.value);case _e.DoesntContain:return!r.includes(o.value);case _e.Equals:return r===Er(o.value);case _e.DoesntEqual:return r!==Er(o.value)}},Qc=(r,o)=>{const i=o.rules.map(c=>Kc(r,c));return o.ruleOperator==="AND"?i.every(Boolean):i.some(Boolean)},Zc=(r,o)=>{const i=qc(r),c=o.blocks.map(d=>Qc(i,d));return o.blockOperator==="AND"?c.every(Boolean):c.some(Boolean)},Jc="data-meltingspot-playbook-editor-active",di="meltingspot:playbook-editor:active-changed",Vc=()=>typeof document<"u"&&typeof document.dispatchEvent=="function",lo=()=>Vc()?document.documentElement.getAttribute(Jc)==="true":!1;class Xc{constructor(){this.listener=null,this.lastOptions=null,this.chain=Promise.resolve()}enqueue(o){const i=this.chain.then(o);return this.chain=i.catch(()=>{}),i}get isBound(){return this.listener!==null}bind(o){if(this.listener!==null||typeof document>"u")return;const i=()=>{if(lo()){Promise.resolve().then(()=>o.onEditorActive()).catch(d=>{console.warn("[playbook-editor] onEditorActive callback failed",d)});return}const c=this.lastOptions;c!==null&&Promise.resolve().then(()=>o.onEditorInactive(c)).catch(d=>{console.warn("[playbook-editor] onEditorInactive callback failed",d)})};document.addEventListener(di,i),this.listener=i}cacheOptions(o){this.lastOptions=o}clearOptions(){this.lastOptions=null}unbind(){this.listener!==null&&typeof document<"u"&&document.removeEventListener(di,this.listener),this.listener=null,this.lastOptions=null}}const jc="1.0.0";class ho{constructor(o){this.debug=!1,this.debug=o?.debug??!1,this.appName=o?.appName,this.appVersion=o?.appVersion}log(o,...i){this.debug&&this.print(o,"info",i)}warn(o,...i){this.print(o,"warn",i)}error(o,...i){this.print(o,"error",i)}print(o,i,c){const g=[`[${["MeltingSpot",this.appName,this.appVersion].filter(Boolean).join(" - ")}] ${o}`];c.length&&g.push(...c),console[i](...g)}}const _o=new ho({appName:"Core SDK",appVersion:jc}),nl=r=>{_o.debug=r},el=r=>r.toLowerCase().replace(/[^a-z0-9-]/g,""),tl=["/user"],rl=({deeplink:r,spotId:o})=>{try{const i=new URL(r,"https://unused.com");let c=i.pathname;return i.search&&(c+=i.search),i.hash&&(c+=i.hash),tl.some(d=>c.startsWith(d))||(c=`/spot/${o}/${zu(c)}`),c}catch(i){return _o.warn("Failed to parse deeplink URL",i),null}},il=[/(^|\.)meltingspot\.io$/i],ul=r=>{let o;try{const E=qu(r);o=new URL(E)}catch{throw new Error(`Invalid baseURL: ${r}`)}const i=o.hostname==="localhost"||o.hostname==="127.0.0.1",c=o.protocol==="https:",d=il.some(E=>E.test(o.hostname));if(!i&&(!c||!d))throw new Error(`Untrusted baseURL origin: ${o.origin}`);return o.origin},ol={msApiBaseUrl:"https://openapi.meltingspot.io/",msCommunityWebBaseUrl:"https://go.meltingspot.io/",ssoToken:void 0,spotId:"",rootDocument:globalThis.document};class pe{constructor(){this.configuration=ol}static getInstance(){return pe.instance||(pe.instance=new pe),pe.instance}setConfiguration(o){this.configuration={...this.configuration,...o}}static getConfiguration(o={}){return{...pe.getInstance().configuration,...o}}}const po="%[a-f0-9]{2}",go=new RegExp("("+po+")|([^%]+?)","gi"),mo=new RegExp("("+po+")+","gi");function _i(r,o){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;o=o||1;const i=r.slice(0,o),c=r.slice(o);return Array.prototype.concat.call([],_i(i),_i(c))}function sl(r){try{return decodeURIComponent(r)}catch{let o=r.match(go)||[];for(let i=1;i<o.length;i++)r=_i(o,i).join(""),o=r.match(go)||[];return r}}function al(r){const o={"%FE%FF":"��","%FF%FE":"��"};let i=mo.exec(r);for(;i;){try{o[i[0]]=decodeURIComponent(i[0])}catch{const d=sl(i[0]);d!==i[0]&&(o[i[0]]=d)}i=mo.exec(r)}o["%C2"]="�";const c=Object.keys(o);for(const d of c)r=r.replace(new RegExp(d,"g"),o[d]);return r}function fl(r){if(typeof r!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof r+"`");try{return decodeURIComponent(r)}catch{return al(r)}}function cl(r,o){const i={};if(Array.isArray(o))for(const c of o){const d=Object.getOwnPropertyDescriptor(r,c);d?.enumerable&&Object.defineProperty(i,c,d)}else for(const c of Reflect.ownKeys(r)){const d=Object.getOwnPropertyDescriptor(r,c);if(d.enumerable){const E=r[c];o(c,E,r)&&Object.defineProperty(i,c,d)}}return i}function vo(r,o){if(!(typeof r=="string"&&typeof o=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(r===""||o==="")return[];const i=r.indexOf(o);return i===-1?[]:[r.slice(0,i),r.slice(i+o.length)]}const ll=r=>r==null,hl=r=>encodeURIComponent(r).replaceAll(/[!'()*]/g,o=>`%${o.charCodeAt(0).toString(16).toUpperCase()}`),pi=Symbol("encodeFragmentIdentifier");function dl(r){switch(r.arrayFormat){case"index":return o=>(i,c)=>{const d=i.length;return c===void 0||r.skipNull&&c===null||r.skipEmptyString&&c===""?i:c===null?[...i,[Ln(o,r),"[",d,"]"].join("")]:[...i,[Ln(o,r),"[",Ln(d,r),"]=",Ln(c,r)].join("")]};case"bracket":return o=>(i,c)=>c===void 0||r.skipNull&&c===null||r.skipEmptyString&&c===""?i:c===null?[...i,[Ln(o,r),"[]"].join("")]:[...i,[Ln(o,r),"[]=",Ln(c,r)].join("")];case"colon-list-separator":return o=>(i,c)=>c===void 0||r.skipNull&&c===null||r.skipEmptyString&&c===""?i:c===null?[...i,[Ln(o,r),":list="].join("")]:[...i,[Ln(o,r),":list=",Ln(c,r)].join("")];case"comma":case"separator":case"bracket-separator":{const o=r.arrayFormat==="bracket-separator"?"[]=":"=";return i=>(c,d)=>d===void 0||r.skipNull&&d===null||r.skipEmptyString&&d===""?c:(d=d===null?"":d,c.length===0?[[Ln(i,r),o,Ln(d,r)].join("")]:[[c,Ln(d,r)].join(r.arrayFormatSeparator)])}default:return o=>(i,c)=>c===void 0||r.skipNull&&c===null||r.skipEmptyString&&c===""?i:c===null?[...i,Ln(o,r)]:[...i,[Ln(o,r),"=",Ln(c,r)].join("")]}}function _l(r){let o;switch(r.arrayFormat){case"index":return(i,c,d)=>{if(o=/\[(\d*)]$/.exec(i),i=i.replace(/\[\d*]$/,""),!o){d[i]=c;return}d[i]===void 0&&(d[i]={}),d[i][o[1]]=c};case"bracket":return(i,c,d)=>{if(o=/(\[])$/.exec(i),i=i.replace(/\[]$/,""),!o){d[i]=c;return}if(d[i]===void 0){d[i]=[c];return}d[i]=[...d[i],c]};case"colon-list-separator":return(i,c,d)=>{if(o=/(:list)$/.exec(i),i=i.replace(/:list$/,""),!o){d[i]=c;return}if(d[i]===void 0){d[i]=[c];return}d[i]=[...d[i],c]};case"comma":case"separator":return(i,c,d)=>{const E=typeof c=="string"&&c.includes(r.arrayFormatSeparator),g=typeof c=="string"&&!E&&De(c,r).includes(r.arrayFormatSeparator);c=g?De(c,r):c;const y=E||g?c.split(r.arrayFormatSeparator).map(D=>De(D,r)):c===null?c:De(c,r);d[i]=y};case"bracket-separator":return(i,c,d)=>{const E=/(\[])$/.test(i);if(i=i.replace(/\[]$/,""),!E){d[i]=c&&De(c,r);return}const g=c===null?[]:De(c,r).split(r.arrayFormatSeparator);if(d[i]===void 0){d[i]=g;return}d[i]=[...d[i],...g]};default:return(i,c,d)=>{if(d[i]===void 0){d[i]=c;return}d[i]=[...[d[i]].flat(),c]}}}function Eo(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function Ln(r,o){return o.encode?o.strict?hl(r):encodeURIComponent(r):r}function De(r,o){return o.decode?fl(r):r}function To(r){return Array.isArray(r)?r.sort():typeof r=="object"?To(Object.keys(r)).sort((o,i)=>Number(o)-Number(i)).map(o=>r[o]):r}function wo(r){const o=r.indexOf("#");return o!==-1&&(r=r.slice(0,o)),r}function pl(r){let o="";const i=r.indexOf("#");return i!==-1&&(o=r.slice(i)),o}function Ao(r,o,i){return i==="string"&&typeof r=="string"?r:typeof i=="function"&&typeof r=="string"?i(r):i==="boolean"&&r===null?!0:i==="boolean"&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")?r.toLowerCase()==="true":i==="boolean"&&r!==null&&(r.toLowerCase()==="1"||r.toLowerCase()==="0")?r.toLowerCase()==="1":i==="string[]"&&o.arrayFormat!=="none"&&typeof r=="string"?[r]:i==="number[]"&&o.arrayFormat!=="none"&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?[Number(r)]:i==="number"&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?Number(r):o.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")?r.toLowerCase()==="true":o.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?Number(r):r}function gi(r){r=wo(r);const o=r.indexOf("?");return o===-1?"":r.slice(o+1)}function mi(r,o){o={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...o},Eo(o.arrayFormatSeparator);const i=_l(o),c=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return c;for(const d of r.split("&")){if(d==="")continue;const E=o.decode?d.replaceAll("+"," "):d;let[g,y]=vo(E,"=");g===void 0&&(g=E),y=y===void 0?null:["comma","separator","bracket-separator"].includes(o.arrayFormat)?y:De(y,o),i(De(g,o),y,c)}for(const[d,E]of Object.entries(c))if(typeof E=="object"&&E!==null&&o.types[d]!=="string")for(const[g,y]of Object.entries(E)){const D=o.types[d]?o.types[d].replace("[]",""):void 0;E[g]=Ao(y,o,D)}else typeof E=="object"&&E!==null&&o.types[d]==="string"?c[d]=Object.values(E).join(o.arrayFormatSeparator):c[d]=Ao(E,o,o.types[d]);return o.sort===!1?c:(o.sort===!0?Object.keys(c).sort():Object.keys(c).sort(o.sort)).reduce((d,E)=>{const g=c[E];return d[E]=g&&typeof g=="object"&&!Array.isArray(g)?To(g):g,d},Object.create(null))}function yo(r,o){if(!r)return"";o={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...o},Eo(o.arrayFormatSeparator);const i=g=>o.skipNull&&ll(r[g])||o.skipEmptyString&&r[g]==="",c=dl(o),d={};for(const[g,y]of Object.entries(r))i(g)||(d[g]=y);const E=Object.keys(d);return o.sort!==!1&&E.sort(o.sort),E.map(g=>{const y=r[g];return y===void 0?"":y===null?Ln(g,o):Array.isArray(y)?y.length===0&&o.arrayFormat==="bracket-separator"?Ln(g,o)+"[]":y.reduce(c(g),[]).join("&"):Ln(g,o)+"="+Ln(y,o)}).filter(g=>g.length>0).join("&")}function Io(r,o){o={decode:!0,...o};let[i,c]=vo(r,"#");return i===void 0&&(i=r),{url:i?.split("?")?.[0]??"",query:mi(gi(r),o),...o&&o.parseFragmentIdentifier&&c?{fragmentIdentifier:De(c,o)}:{}}}function Lo(r,o){o={encode:!0,strict:!0,[pi]:!0,...o};const i=wo(r.url).split("?")[0]||"",c=gi(r.url),d={...mi(c,{sort:!1,...o}),...r.query};let E=yo(d,o);E&&=`?${E}`;let g=pl(r.url);if(typeof r.fragmentIdentifier=="string"){const y=new URL(i);y.hash=r.fragmentIdentifier,g=o[pi]?y.hash:`#${r.fragmentIdentifier}`}return`${i}${E}${g}`}function Ro(r,o,i){i={parseFragmentIdentifier:!0,[pi]:!1,...i};const{url:c,query:d,fragmentIdentifier:E}=Io(r,i);return Lo({url:c,query:cl(d,o),fragmentIdentifier:E},i)}function gl(r,o,i){const c=Array.isArray(o)?d=>!o.includes(d):(d,E)=>!o(d,E);return Ro(r,c,i)}const ml=Object.freeze(Object.defineProperty({__proto__:null,exclude:gl,extract:gi,parse:mi,parseUrl:Io,pick:Ro,stringify:yo,stringifyUrl:Lo},Symbol.toStringTag,{value:"Module"}));class Gn extends Error{constructor(o,i){super(`HTTP Error ${o}${i?`: ${i}`:""}`),this.code=o,this.name="HttpError",Object.setPrototypeOf(this,Gn.prototype)}}var On=(r=>(r.GET="GET",r.PATCH="PATCH",r.POST="POST",r))(On||{});class Mo{constructor(){this.headers={}}setHeaders(o){this.headers=o}async get(o){try{const i=o.query?`${o.url}?${this.serializeQuery(o.query)}`:o.url,c=await fetch(i,{headers:{...this.headers,...o.headers,"Content-Type":"application/json"}});return c.ok?sn(await c.json()):q(new Gn(c.status,await c.text()))}catch(i){const c=i instanceof Error?i.message:"Unknown error";return q(new Gn(ie.INTERNAL_SERVER_ERROR,c))}}async post(o){try{const i=await fetch(o.url,{method:"POST",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload)});return i.ok?sn(await i.json()):q(new Gn(i.status,await i.text()))}catch(i){const c=i instanceof Error?i.message:"Unknown error";return q(new Gn(ie.INTERNAL_SERVER_ERROR,c))}}async patch(o){try{const i=await fetch(o.url,{method:"PATCH",headers:{...this.headers,...o.headers,"Content-Type":"application/json"},body:JSON.stringify(o.payload)});return i.ok?sn(await i.json()):q(new Gn(i.status,await i.text()))}catch(i){const c=i instanceof Error?i.message:"Unknown error";return q(new Gn(ie.INTERNAL_SERVER_ERROR,c))}}serializeQuery(o){if(typeof o=="string")return o;if(typeof o=="object")for(const i in o)o[i]===void 0&&delete o[i];return o=ml.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"}};var Oo=(r=>(r.TokensUpdated="auth:tokens-updated",r))(Oo||{});class Se extends EventTarget{constructor(){super(),this.accessToken=null,this.refreshToken=null}static getInstance(){return Se.instance||(Se.instance=new Se),Se.instance}async loginWithPassword(o,i){const c=await this.callApi({endpoint:Tr.accessToken.email,method:"POST",body:{email:o,password:i},withSpotId:!0});if(c.isErr())return q(c.error);const{accessToken:d,refreshToken:E}=c.value;return this.setTokens(d.token,E.token),sn({accessToken:d.token,refreshToken:E.token})}async loginWithSsoToken(o){const i=await this.callApi({endpoint:Tr.accessToken.sso.jwt,method:"POST",body:{token:o},withSpotId:!0});if(i.isErr())return q(i.error);const{accessToken:c,refreshToken:d}=i.value;return this.setTokens(c.token,d.token),sn({accessToken:c.token,refreshToken:d.token})}loginWithAuthTokens(o,i){return this.setTokens(o,i),{accessToken:o,refreshToken:i}}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 q(o.error);const{accessToken:i,refreshToken:c}=o.value;return this.setTokens(i.token,c.token),sn({accessToken:i.token,refreshToken:c.token})}async logout(){this.setTokens(null,null)}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}setTokens(o,i){if(this.accessToken!==o||this.refreshToken!==i){this.accessToken=o,this.refreshToken=i;const c=new CustomEvent("auth:tokens-updated",{detail:{accessToken:o,refreshToken:i}});this.dispatchEvent(c)}}async callApi(o){try{const{spotId:i,msApiBaseUrl:c}=pe.getConfiguration(),d=ur(o.endpoint,c),E={"Content-Type":"application/json",...o.headers};o.withSpotId&&i&&(E[Do.SpotId]=i);const g=await fetch(d,{method:o.method,body:o.body?JSON.stringify(o.body):void 0,headers:E});if(!g.ok)return q(new Gn(g.status,g.statusText));if(g.status===ie.NO_CONTENT)return sn(void 0);const y=await g.json();return sn(y)}catch(i){return q(new Gn(ie.INTERNAL_SERVER_ERROR,i instanceof Error?i.message:String(i)))}}}var Do=(r=>(r.Authorization="Authorization",r.SpotId="x-spotid",r))(Do||{});class ue{constructor(){this.queue=[],this.isProcessing=!1,this.isPaused=!1,this.authService=Se.getInstance(),this.httpService=new Mo}static getInstance(){return ue.instance||(ue.instance=new ue),ue.instance}static buildAuthenticatedRequest(o){const{msApiBaseUrl:i,spotId:c}=pe.getConfiguration(),d=ur(o,i),E=Se.getInstance().getAccessToken();if(!E)return q(new Error("Not authenticated"));const g={"Content-Type":"application/json",Authorization:`Bearer ${E}`};return c&&(g["x-spotid"]=c),sn({url:d,headers:g})}static async stream(o,i,c){const d=ue.buildAuthenticatedRequest(o);if(d.isErr())return q(d.error);const{url:E,headers:g}=d.value;try{const y=await fetch(E,{method:"POST",headers:g,...i!==void 0?{body:JSON.stringify(i)}:{},...c?{signal:c}:{}});if(!y.ok){const D=await y.text();return q(new Error(`HTTP ${y.status}: ${D}`))}return y.body?sn(y.body):q(new Error("Response body is empty"))}catch(y){const D=y instanceof Error?y.message:"Unknown error";return q(y instanceof Error?y:new Error(D))}}get pendingCount(){return this.queue.length}enqueue(o){return new Promise(i=>{const c=async()=>{try{const d=await o();i(d)}catch(d){i(q(new Gn(ie.INTERNAL_SERVER_ERROR,d instanceof Error?d.message:"Unknown error")))}};this.queue.push(c),this.processQueue()})}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;!this.isPaused&&this.queue.length>0;){const 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 i=async()=>{const{spotId:d,msApiBaseUrl:E}=pe.getConfiguration(),g={...o.options?.headers??{}};d&&(g["x-spotid"]=d);const y=this.authService.getAccessToken(),{requiresAuth:D=!0}=o;if(!y&&D)return q(new Gn(ie.UNAUTHORIZED));y&&(g.Authorization=`Bearer ${y}`);const V=ur(o.endpoint,E);switch(o.method){case On.GET:return this.httpService.get({...o.options??{},headers:g,url:V});case On.PATCH:return this.httpService.patch({...o.options??{},headers:g,url:V});case On.POST:return this.httpService.post({...o.options??{},headers:g,url:V});default:return q(new Gn(ie.METHOD_NOT_ALLOWED,"Method not allowed"))}};let c=await i();if(c.isErr()&&c.error.code===ie.UNAUTHORIZED){const d=await this.authService.refresh();if(d.isErr())return q(new Gn(ie.UNAUTHORIZED,d.error.message));c=await i()}return c})}}const Ie={playbooks:"/v1/playbooks",pages:r=>`/v1/playbooks/${r}/pages`,hotspots:(r,o)=>`/v1/playbooks/${r}/pages/${o}/hotspots`,hotspot:(r,o,i)=>`/v1/playbooks/${r}/pages/${o}/hotspots/${i}`,accessibleIntents:(r,o)=>`/v1/playbooks/${r}/pages/${o}/accessibleIntents`,intents:(r,o,i)=>`/v1/playbooks/${r}/pages/${o}/hotspots/${i}/intents`,intent:(r,o,i,c)=>`/v1/playbooks/${r}/pages/${o}/hotspots/${i}/intents/${c}`},wr=50;class pt{static getInstance(){return pt.instance||(pt.instance=new pt),pt.instance}constructor(){this.meltingSpotApi=ue.getInstance()}async listPlaybooks(o){const i=await this.meltingSpotApi.call({method:On.GET,endpoint:Ie.playbooks,options:{query:{page:o?.page??1,limit:o?.limit??wr,...o?.domain?{"domain[eq]":o.domain}:{}}}});return i.isErr()?q(i.error):sn(i.value)}async listPlaybookPages(o){const i=await this.meltingSpotApi.call({method:On.GET,endpoint:Ie.pages(o.playbookId),options:{query:{page:o.page??1,limit:o.limit??wr,...o.url?{"url[eq]":o.url}:{}}}});return i.isErr()?q(i.error):sn(i.value)}async createPlaybookPage(o,i){const c=await this.meltingSpotApi.call({method:On.POST,endpoint:Ie.pages(o.playbookId),options:{payload:i}});return c.isErr()?q(c.error):sn(c.value)}async listAccessiblePlaybookIntents(o){const i=await this.meltingSpotApi.call({method:On.GET,endpoint:Ie.accessibleIntents(o.playbookId,o.pageId),options:{query:{...o.domain?{"domain[eq]":o.domain}:{}}}});return i.isErr()?q(i.error):sn(i.value)}async listPlaybookHotspots(o){const i=await this.meltingSpotApi.call({method:On.GET,endpoint:Ie.hotspots(o.playbookId,o.pageId),options:{query:{page:o.page??1,limit:o.limit??wr,...o.intentStatus?{"intentStatus[eq]":o.intentStatus}:{},...o.widgetType?{"widgetType[eq]":o.widgetType}:{}}}});return i.isErr()?q(i.error):sn(i.value)}async createPlaybookHotspot(o,i){const c=await this.meltingSpotApi.call({method:On.POST,endpoint:Ie.hotspots(o.playbookId,o.pageId),options:{payload:i}});return c.isErr()?q(c.error):sn(c.value)}async updatePlaybookHotspot(o,i){const c=await this.meltingSpotApi.call({method:On.PATCH,endpoint:Ie.hotspot(o.playbookId,o.pageId,o.hotspotId),options:{payload:i}});return c.isErr()?q(c.error):sn(c.value)}async listPlaybookIntents(o){const i=await this.meltingSpotApi.call({method:On.GET,endpoint:Ie.intents(o.playbookId,o.pageId,o.hotspotId),options:{query:{page:o.page??1,limit:o.limit??wr,...o.status?{"status[eq]":o.status}:{}}}});return i.isErr()?q(i.error):sn(i.value)}async createPlaybookIntent(o,i){const c=await this.meltingSpotApi.call({method:On.POST,endpoint:Ie.intents(o.playbookId,o.pageId,o.hotspotId),options:{payload:i}});return c.isErr()?q(c.error):sn(c.value)}async updatePlaybookIntent(o,i){const c=await this.meltingSpotApi.call({method:On.PATCH,endpoint:Ie.intent(o.playbookId,o.pageId,o.hotspotId,o.intentId),options:{payload:i}});return c.isErr()?q(c.error):sn(c.value)}}const vl={me:"/v1/spots/me"},El=50;class gt{static getInstance(){return gt.instance||(gt.instance=new gt),gt.instance}constructor(){this.meltingSpotApi=ue.getInstance()}async listSpotsForMe(o){const i=await this.meltingSpotApi.call({method:On.GET,endpoint:vl.me,options:{query:{page:1,limit:El,...o?.spotMemberRole?{"spotMemberRole[eq]":o.spotMemberRole}:{}}}});return i.isErr()?q(i.error):sn(i.value)}}const Tl={spotMember:{me:"/v1/spotMembers/me"}};class et{static getInstance(){return et.instance||(et.instance=new et),et.instance}constructor(){this.meltingSpotApi=ue.getInstance()}async getSpotMemberForMe(){const o=await this.meltingSpotApi.call({method:On.GET,endpoint:Tl.spotMember.me});return o.isErr()?q(o.error):sn(o.value)}}const wl={spotMemberSsoToken:"/v1/spotMembers/auth/sso/jwt"};class mt{static getInstance(){return mt.instance||(mt.instance=new mt),mt.instance}constructor(){this.meltingSpotApi=ue.getInstance()}async generateSsoToken(){const o=await this.meltingSpotApi.call({method:On.POST,endpoint:wl.spotMemberSsoToken,options:{payload:{}}});return o.isErr()?q(o.error):sn(o.value.token)}}class tt{static getInstance(){return tt.instance||(tt.instance=new tt),tt.instance}constructor(){this.spotMemberAuthApiService=mt.getInstance()}async generateSsoToken(){return this.spotMemberAuthApiService.generateSsoToken()}}class Al{constructor(o){this.active=!1,this.lastObservedUrl=null,this.options={onRouteChange:o.onRouteChange,debounceMs:o.debounceMs??0,enableDeduplication:o.enableDeduplication??!0,enableDomMutationDetection:o.enableDomMutationDetection??!1,enableHistoryChange:o.enableHistoryChange??!0,enablePopState:o.enablePopState??!0,enableHashChange:o.enableHashChange??!0,enableLoad:o.enableLoad??!0,rootDocument:o.rootDocument}}start(){this.active||(this.active=!0,this.lastObservedUrl=null,this.options.enablePopState&&(this.popStateListener=()=>this.handleNavigationEvent("popstate"),window.addEventListener("popstate",this.popStateListener)),this.options.enableHashChange&&(this.hashChangeListener=()=>this.handleNavigationEvent("hashchange"),window.addEventListener("hashchange",this.hashChangeListener)),this.options.enableLoad&&(this.loadListener=()=>this.handleNavigationEvent("load"),window.addEventListener("load",this.loadListener)),this.options.enableDomMutationDetection&&(this.mutationObserver=new MutationObserver(()=>{this.handleNavigationEvent("locationchange")}),this.mutationObserver.observe(this.options.rootDocument??document,{childList:!0,subtree:!0})),this.options.enableHistoryChange&&this.patchHistoryListeners())}stop(){this.active&&(this.active=!1,this.debounceTimer!==void 0&&(clearTimeout(this.debounceTimer),this.debounceTimer=void 0),this.popStateListener&&(window.removeEventListener("popstate",this.popStateListener),this.popStateListener=void 0),this.hashChangeListener&&(window.removeEventListener("hashchange",this.hashChangeListener),this.hashChangeListener=void 0),this.loadListener&&(window.removeEventListener("load",this.loadListener),this.loadListener=void 0),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=void 0),(this.originalPushState||this.originalReplaceState)&&this.restoreHistoryListeners(),this.lastObservedUrl=null)}handleNavigationEvent(o){if(!this.active)return;const i=window.location.href;this.options.enableDeduplication&&this.lastObservedUrl===i||(this.lastObservedUrl=i,this.options.debounceMs>0?(this.debounceTimer!==void 0&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=void 0,this.options.onRouteChange(i,o)},this.options.debounceMs)):this.options.onRouteChange(i,o))}patchHistoryListeners(){this.originalPushState=window.history.pushState,this.originalReplaceState=window.history.replaceState,window.history.pushState=(...o)=>{const i=this.originalPushState?.apply(window.history,o);return this.handleNavigationEvent("history.pushState"),i},window.history.replaceState=(...o)=>{const i=this.originalReplaceState?.apply(window.history,o);return this.handleNavigationEvent("history.replaceState"),i}}restoreHistoryListeners(){this.originalPushState&&(window.history.pushState=this.originalPushState,this.originalPushState=void 0),this.originalReplaceState&&(window.history.replaceState=this.originalReplaceState,this.originalReplaceState=void 0)}}const yl={events:"/v1/analytics/events"};class vt{static getInstance(){return vt.instance||(vt.instance=new vt),vt.instance}constructor(){this.meltingSpotApi=ue.getInstance()}async appendEvent(o){const i=await this.meltingSpotApi.call({method:On.POST,endpoint:yl.events,options:{payload:o}});return i.isErr()?q(i.error):sn(i.value)}}const Il=r=>{const o=r.get("utm_source");if(o)return{source:o,medium:r.get("utm_medium")??void 0,campaign:r.get("utm_campaign")??void 0,term:r.get("utm_term")??void 0,content:r.get("utm_content")??void 0}},Ll=r=>r?Object.entries(r).reduce((o,[i,c])=>(c!=null&&(o[`utm_${i}`]=c),o),{}):{};var So=(r=>(r.Active="Active",r.Closed="Closed",r.Expired="Expired",r))(So||{}),bo=(r=>(r.User="User",r.Assistant="Assistant",r))(bo||{}),xo=(r=>(r.Metadata="metadata",r.Token="token",r.Action="action",r.Bubble="bubble",r.Done="done",r.Error="error",r))(xo||{}),Uo=(r=>(r.PlaybookIntent="PlaybookIntent",r.UserInitiated="UserInitiated",r.Welcome="Welcome",r.Resume="Resume",r.Discover="Discover",r.Recommend="Recommend",r))(Uo||{}),No=(r=>(r.ExtraExtraSmall="ExtraExtraSmall",r.ExtraSmall="ExtraSmall",r.Small="Small",r.Medium="Medium",r.Large="Large",r))(No||{}),$o=(r=>(r.Dropdown="Dropdown",r.Inline="Inline",r.Overlay="Overlay",r))($o||{}),Po=(r=>(r.Left="Left",r.Right="Right",r))(Po||{}),Co=(r=>(r.Top="Top",r.Bottom="Bottom",r))(Co||{}),Yo=(r=>(r.TopLeft="TopLeft",r.TopRight="TopRight",r.BottomLeft="BottomLeft",r.BottomRight="BottomRight",r))(Yo||{}),Fo=(r=>(r.Button="Button",r.Card="Card",r.CardInline="CardInline",r.Carousel="Carousel",r.Helper="Helper",r.ListOfContent="ListOfContent",r.ListOfContentInline="ListOfContentInline",r))(Fo||{}),Ho=(r=>(r.Inline="Inline",r.Modal="Modal",r.Drawer="Drawer",r))(Ho||{}),Bo=(r=>(r.Self="Self",r.Parent="Parent",r.Top="Top",r))(Bo||{}),Wo=(r=>(r.Left="Left",r.Right="Right",r))(Wo||{}),ko=(r=>(r.Body="Body",r.DOMSelector="DOMSelector",r))(ko||{}),Go=(r=>(r.After="After",r.AppendChild="AppendChild",r.Before="Before",r.PrependChild="PrependChild",r))(Go||{}),zo=(r=>(r.CSSSelector="CSSSelector",r.Slot="Slot",r))(zo||{}),qo=(r=>(r.Element="Element",r.WebComponent="WebComponent",r))(qo||{}),Ko=(r=>(r.Inline="Inline",r.Flex="Flex",r))(Ko||{}),Qo=(r=>(r.Horizontal="Horizontal",r.Vertical="Vertical",r))(Qo||{}),Zo=(r=>(r.Start="Start",r.Center="Center",r.End="End",r.Stretch="Stretch",r.Baseline="Baseline",r))(Zo||{}),Jo=(r=>(r.Course="Course",r.Live="Live",r.Link="Link",r.Page="Page",r))(Jo||{}),Vo=(r=>(r.Workshop="Workshop",r.Conference="Conference",r))(Vo||{}),Xo=(r=>(r.Ended="Ended",r.Planned="Planned",r.Live="Live",r))(Xo||{}),jo=(r=>(r.CloseA="CloseA",r.CloseB="CloseB",r.Later="Later",r))(jo||{});const Rl="a",Ml="mention_input",Ol="mention",Dl="var",Sl="p",bl="h1",xl="h2",Ul="h3",Nl="blockquote",$l="layout",Pl="layout-column",Cl="ul",Yl="ol",Fl="lic",Hl="li",Bl="img",Wl="iframely",kl="code_block",Gl="code_line";var ns=(r=>(r.Element="Element",r.FullPage="FullPage",r))(ns||{}),es=(r=>(r.Draft="Draft",r.Pending="Pending",r.Published="Published",r))(es||{}),ts=(r=>(r.Beacon="Beacon",r.List="List",r))(ts||{}),vi=(r=>(r.Channel="Channel",r.Collection="Collection",r.Course="Course",r.Forum="Forum",r.Link="Link",r.Live="Live",r.LearningPath="LearningPath",r.Page="Page",r.RichText="RichText",r.Topic="Topic",r))(vi||{});function zl(r){return Object.values(vi).includes(r)}const rs=pe.getInstance(),is=Se.getInstance(),us=tt.getInstance(),os={Playbook:pt.getInstance(),Spot:gt.getInstance(),SpotMember:et.getInstance()},Et=globalThis;Et.MeltingSpot||(Et.MeltingSpot={}),Et.MeltingSpot.Configuration=rs,Et.MeltingSpot.Auth=is,Et.MeltingSpot.Sso=us,Et.MeltingSpot.Api=os,I.ATTRIBUTE_BLOCKQUOTE=Nl,I.ATTRIBUTE_CODE_BLOCK=kl,I.ATTRIBUTE_CODE_LINE=Gl,I.ATTRIBUTE_H1=bl,I.ATTRIBUTE_H2=xl,I.ATTRIBUTE_H3=Ul,I.ATTRIBUTE_IFRAMELY=Wl,I.ATTRIBUTE_IMAGE=Bl,I.ATTRIBUTE_LAYOUT=$l,I.ATTRIBUTE_LAYOUT_COLUMN=Pl,I.ATTRIBUTE_LI=Hl,I.ATTRIBUTE_LIC=Fl,I.ATTRIBUTE_LINK=Rl,I.ATTRIBUTE_MENTION=Ol,I.ATTRIBUTE_MENTION_INPUT=Ml,I.ATTRIBUTE_OL=Yl,I.ATTRIBUTE_PARAGRAPH=Sl,I.ATTRIBUTE_UL=Cl,I.ATTRIBUTE_VARIABLE=Dl,I.AnalyticsApiService=vt,I.Api=os,I.Auth=is,I.AuthService=Se,I.AuthServiceEvents=Oo,I.BeaconIntegrationType=$o,I.BeaconRenderType=Fo,I.ButtonBeaconSize=No,I.Configuration=rs,I.ConfigurationService=pe,I.ConversationMessageRole=bo,I.ConversationSseEventType=xo,I.ConversationStatus=So,I.DEFAULT_PERMISSION_POLICIES=Ku,I.DateFormat=co,I.DrawerWidgetPosition=Wo,I.DropdownBeaconHorizontalPosition=Po,I.DropdownBeaconVerticalPosition=Co,I.HttpMethods=On,I.HttpService=Mo,I.LastActionState=jo,I.LearningPathContentType=Jo,I.LiveBuiltInType=Vo,I.LiveStatus=Xo,I.Logger=ho,I.MeltingSpotApi=ue,I.OverlayBeaconPosition=Yo,I.PLAYBOOK_EDITOR_ACTIVE_EVENT=di,I.PlaybookEditorAwareLifecycle=Xc,I.PlaybookHotspotLocation=ns,I.PlaybookIntentStatus=es,I.PlaybookIntentWidgetMode=ts,I.PlaybookPageMatchingOperator=_e,I.RouteChangeDetector=Al,I.SpotMemberApiService=et,I.SpotWidgetContentType=vi,I.Sso=us,I.SsoService=tt,I.TouchPointAnchorType=ko,I.TouchPointDOMInjectionPosition=Go,I.TouchPointDOMSelectorCssStepMode=qo,I.TouchPointDOMSelectorPathStepType=zo,I.TouchPointFlexAlign=Zo,I.TouchPointFlexDirection=Qo,I.TouchPointLayoutType=Ko,I.TriggerType=Uo,I.WidgetInjectionTarget=Bo,I.WidgetInjectionType=Ho,I.createDialog=qf,I.createIframe=Kf,I.dayjs=_t,I.flattenUtmParameters=Ll,I.formatBaseUrl=ul,I.formatDate=Bc,I.formatDeeplink=rl,I.formatUUID=el,I.getHTMLElement=zf,I.getTimeInfoWithStartAndEndDate=Mc,I.isPlaybookEditorActive=lo,I.isSpotWidgetContentType=zl,I.isTouchDevice=Qf,I.parseUtmParameters=Il,I.sanitizeUrl=ur,I.setLoggerDebugMode=nl,I.testUrlMatching=Zc,I.trimSlashLeft=zu,I.trimSlashRight=qu,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "MeltingSpot Core SDK",
4
4
  "homepage": "https://meltingspot.io",
5
5
  "license": "BSD-3-Clause",
6
- "version": "0.1.0",
6
+ "version": "1.0.0",
7
7
  "main": "./index.umd.js",
8
8
  "module": "./index.mjs",
9
9
  "typings": "./index.d.ts",