@telia-ace/widget-conversation-flamingo 1.1.14-rc.2 → 1.1.14

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.
@@ -0,0 +1,3 @@
1
+ "use strict";let S;const Q=new Uint8Array(16);function W(){if(!S&&(S=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!S))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return S(Q)}const a=[];for(let e=0;e<256;++e)a.push((e+256).toString(16).slice(1));function X(e,r=0){return a[e[r+0]]+a[e[r+1]]+a[e[r+2]]+a[e[r+3]]+"-"+a[e[r+4]]+a[e[r+5]]+"-"+a[e[r+6]]+a[e[r+7]]+"-"+a[e[r+8]]+a[e[r+9]]+"-"+a[e[r+10]]+a[e[r+11]]+a[e[r+12]]+a[e[r+13]]+a[e[r+14]]+a[e[r+15]]}const Z=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),B={randomUUID:Z};function N(e,r,t){if(B.randomUUID&&!r&&!e)return B.randomUUID();e=e||{};const n=e.random||(e.rng||W)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,r){t=t||0;for(let i=0;i<16;++i)r[t+i]=n[i];return r}return X(n)}var C=function(e,r){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},C(e,r)};function d(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");C(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}function j(e){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),i,o=[],s;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(u){s={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(s)throw s.error}}return o}function E(e,r,t){if(t||arguments.length===2)for(var n=0,i=r.length,o;n<i;n++)(o||!(n in r))&&(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return e.concat(o||Array.prototype.slice.call(r))}function p(e){return typeof e=="function"}function H(e){var r=function(n){Error.call(n),n.stack=new Error().stack},t=e(r);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var O=H(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
2
+ `+t.map(function(n,i){return i+1+") "+n.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function I(e,r){if(e){var t=e.indexOf(r);0<=t&&e.splice(t,1)}}var U=function(){function e(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var r,t,n,i,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var u=j(s),c=u.next();!c.done;c=u.next()){var h=c.value;h.remove(this)}}catch(l){r={error:l}}finally{try{c&&!c.done&&(t=u.return)&&t.call(u)}finally{if(r)throw r.error}}else s.remove(this);var f=this.initialTeardown;if(p(f))try{f()}catch(l){o=l instanceof O?l.errors:[l]}var R=this._finalizers;if(R){this._finalizers=null;try{for(var m=j(R),b=m.next();!b.done;b=m.next()){var J=b.value;try{V(J)}catch(l){o=o??[],l instanceof O?o=E(E([],_(o)),_(l.errors)):o.push(l)}}}catch(l){n={error:l}}finally{try{b&&!b.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}}if(o)throw new O(o)}},e.prototype.add=function(r){var t;if(r&&r!==this)if(this.closed)V(r);else{if(r instanceof e){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(r)}},e.prototype._hasParent=function(r){var t=this._parentage;return t===r||Array.isArray(t)&&t.includes(r)},e.prototype._addParent=function(r){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(r),t):t?[t,r]:r},e.prototype._removeParent=function(r){var t=this._parentage;t===r?this._parentage=null:Array.isArray(t)&&I(t,r)},e.prototype.remove=function(r){var t=this._finalizers;t&&I(t,r),r instanceof e&&r._removeParent(this)},e.EMPTY=function(){var r=new e;return r.closed=!0,r}(),e}(),L=U.EMPTY;function q(e){return e instanceof U||e&&"closed"in e&&p(e.remove)&&p(e.add)&&p(e.unsubscribe)}function V(e){p(e)?e():e.unsubscribe()}var z={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},T={setTimeout:function(e,r){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=T.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,E([e,r],_(t))):setTimeout.apply(void 0,E([e,r],_(t)))},clearTimeout:function(e){var r=T.delegate;return((r==null?void 0:r.clearTimeout)||clearTimeout)(e)},delegate:void 0};function tt(e){T.setTimeout(function(){throw e})}function k(){}function w(e){e()}var F=function(e){d(r,e);function r(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,q(t)&&t.add(n)):n.destination=it,n}return r.create=function(t,n,i){return new $(t,n,i)},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(U),rt=Function.prototype.bind;function A(e,r){return rt.call(e,r)}var et=function(){function e(r){this.partialObserver=r}return e.prototype.next=function(r){var t=this.partialObserver;if(t.next)try{t.next(r)}catch(n){g(n)}},e.prototype.error=function(r){var t=this.partialObserver;if(t.error)try{t.error(r)}catch(n){g(n)}else g(r)},e.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(t){g(t)}},e}(),$=function(e){d(r,e);function r(t,n,i){var o=e.call(this)||this,s;if(p(t)||!t)s={next:t??void 0,error:n??void 0,complete:i??void 0};else{var u;o&&z.useDeprecatedNextContext?(u=Object.create(t),u.unsubscribe=function(){return o.unsubscribe()},s={next:t.next&&A(t.next,u),error:t.error&&A(t.error,u),complete:t.complete&&A(t.complete,u)}):s=t}return o.destination=new et(s),o}return r}(F);function g(e){tt(e)}function nt(e){throw e}var it={closed:!0,next:k,error:nt,complete:k},ot=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function st(e){return e}function ut(e){return e.length===0?st:e.length===1?e[0]:function(t){return e.reduce(function(n,i){return i(n)},t)}}var D=function(){function e(r){r&&(this._subscribe=r)}return e.prototype.lift=function(r){var t=new e;return t.source=this,t.operator=r,t},e.prototype.subscribe=function(r,t,n){var i=this,o=at(r)?r:new $(r,t,n);return w(function(){var s=i,u=s.operator,c=s.source;o.add(u?u.call(o,c):c?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){r.error(t)}},e.prototype.forEach=function(r,t){var n=this;return t=M(t),new t(function(i,o){var s=new $({next:function(u){try{r(u)}catch(c){o(c),s.unsubscribe()}},error:o,complete:i});n.subscribe(s)})},e.prototype._subscribe=function(r){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(r)},e.prototype[ot]=function(){return this},e.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return ut(r)(this)},e.prototype.toPromise=function(r){var t=this;return r=M(r),new r(function(n,i){var o;t.subscribe(function(s){return o=s},function(s){return i(s)},function(){return n(o)})})},e.create=function(r){return new e(r)},e}();function M(e){var r;return(r=e??z.Promise)!==null&&r!==void 0?r:Promise}function ct(e){return e&&p(e.next)&&p(e.error)&&p(e.complete)}function at(e){return e&&e instanceof F||ct(e)&&q(e)}function lt(e){return p(e==null?void 0:e.lift)}function pt(e){return function(r){if(lt(r))return r.lift(function(t){try{return e(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function ht(e,r,t,n,i){return new ft(e,r,t,n,i)}var ft=function(e){d(r,e);function r(t,n,i,o,s,u){var c=e.call(this,t)||this;return c.onFinalize=s,c.shouldUnsubscribe=u,c._next=n?function(h){try{n(h)}catch(f){t.error(f)}}:e.prototype._next,c._error=o?function(h){try{o(h)}catch(f){t.error(f)}finally{this.unsubscribe()}}:e.prototype._error,c._complete=i?function(){try{i()}catch(h){t.error(h)}finally{this.unsubscribe()}}:e.prototype._complete,c}return r.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},r}(F),dt=H(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),v=function(e){d(r,e);function r(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return r.prototype.lift=function(t){var n=new Y(this,this);return n.operator=t,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new dt},r.prototype.next=function(t){var n=this;w(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var s=j(n.currentObservers),u=s.next();!u.done;u=s.next()){var c=u.value;c.next(t)}}catch(h){i={error:h}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},r.prototype.error=function(t){var n=this;w(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var i=n.observers;i.length;)i.shift().error(t)}})},r.prototype.complete=function(){var t=this;w(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},r.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},r.prototype._innerSubscribe=function(t){var n=this,i=this,o=i.hasError,s=i.isStopped,u=i.observers;return o||s?L:(this.currentObservers=null,u.push(t),new U(function(){n.currentObservers=null,I(u,t)}))},r.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,o=n.thrownError,s=n.isStopped;i?t.error(o):s&&t.complete()},r.prototype.asObservable=function(){var t=new D;return t.source=this,t},r.create=function(t,n){return new Y(t,n)},r}(D),Y=function(e){d(r,e);function r(t,n){var i=e.call(this)||this;return i.destination=t,i.source=n,i}return r.prototype.next=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,t)},r.prototype.error=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,t)},r.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},r.prototype._subscribe=function(t){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&i!==void 0?i:L},r}(v),vt=function(e){d(r,e);function r(t){var n=e.call(this)||this;return n._value=t,n}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},r.prototype.getValue=function(){var t=this,n=t.hasError,i=t.thrownError,o=t._value;if(n)throw i;return this._throwIfClosed(),o},r.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},r}(v),bt=new D(function(e){return e.complete()});function yt(e){return e<=0?function(){return bt}:pt(function(r,t){var n=0;r.subscribe(ht(t,function(i){++n<=e&&(t.next(i),e<=n&&t.complete())}))})}class mt{constructor(r,t){this.id=r,this.entries$=new vt([]),t.addEventListener("user-submit",n=>{if(!this.provider){console.warn("No provider activated, unable to print message to conversation.");return}this.provider.onUserSubmit(n.detail)})}write(r){this.entries$.pipe(yt(1)).subscribe(t=>{this.entries$.next([...t,r])})}entries(){return this.entries$.asObservable()}setProvider(r){this.provider=r,this.provider.actions().subscribe(t=>{this.write(t)})}}class x{constructor(){this.sessions=new Map,this.registeredProviders=new Map,this.activeSessionId=null}static async getInstance(r){let t=await r.get("conversation");return t||(t=new x,await r.register("conversation",t),t)}registerProvider(r,t){this.registeredProviders.set(r,t)}createSession(r){const t=new mt(N(),r),n=this.getProviderByConfiguration(r);if(n){const i=n();t.setProvider(i)}return this.sessions.set(t.id,t),this.activeSessionId=t.id,t}getProviderByConfiguration(r){const[t]=r.properties.providers||[];if(!t){console.warn("No providers registered. You most likely forgot to add a provider to the conversation component properties.");return}return this.registeredProviders.get(t)}}const St=async e=>{e.registerComponent("conversation",Promise.resolve().then(()=>require("./conversation-c7b20faa.js")).then(r=>r.conversation)),await x.getInstance(e.container)};var y=(e=>(e.User="user",e.Agent="agent",e.System="system",e))(y||{});class P{constructor(r,t,n){this.type=r,this.sender=t,this.messages=n,this.didUpdate=new v,this.timestamp=Date.now()}update(r){this.messages=[{items:r}],this.didUpdate.next(this)}}class K{constructor(r){this.name=r,this.print$=new v}print(r){const t=new P(y.Agent,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class G{constructor(r){this.name=r,this.print$=new v}print(r){const t=new P(y.User,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class gt{constructor(r){this.name=r,this.print$=new v}onUserSubmit(r){this.print(y.User,r.text)}print(r,t){const n=new P(r,{name:"Botsson"},[{items:[["html",{content:t}]]}]);return this.printEntry(n)}printEntry(r){return this.print$.next(r),r}createAgent(r){const t=new K(r);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}createUser(r){const t=new G(r);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}actions(){return this.print$.asObservable()}}exports.Agent=K;exports.ConversationComponent=St;exports.ConversationEntry=P;exports.ConversationMessageType=y;exports.ConversationPlatform=x;exports.ConversationProvider=gt;exports.User=G;
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-23b605ae.js");exports.Agent=o.Agent;exports.ConversationComponent=o.ConversationComponent;exports.ConversationEntry=o.ConversationEntry;exports.ConversationPlatform=o.ConversationPlatform;exports.ConversationProvider=o.ConversationProvider;exports.User=o.User;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-cec07deb.js");exports.Agent=o.Agent;exports.ConversationComponent=o.ConversationComponent;exports.ConversationEntry=o.ConversationEntry;exports.ConversationPlatform=o.ConversationPlatform;exports.ConversationProvider=o.ConversationProvider;exports.User=o.User;
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as n, a as r, d as s, b as e, c as t, U as i } from "./index-ccbeb601.mjs";
1
+ import { A as n, a as r, d as s, b as e, c as t, U as i } from "./index-7ce12d5a.mjs";
2
2
  export {
3
3
  n as Agent,
4
4
  r as ConversationComponent,
@@ -8,15 +8,12 @@ type UserSubmitEvent = {
8
8
  export declare class ConversationProvider {
9
9
  name: string;
10
10
  private print$;
11
- private typingState$;
12
11
  constructor(name: string);
13
12
  onUserSubmit(action: UserSubmitEvent): void;
14
13
  print(type: ConversationMessageType, text: string): ConversationEntry;
15
14
  printEntry(entry: ConversationEntry): ConversationEntry;
16
15
  createAgent(name: string): Agent;
17
16
  createUser(name: string): User;
18
- setTypingState(isTyping: boolean): void;
19
- isTyping(): import("rxjs").Observable<boolean>;
20
17
  actions(): import("rxjs").Observable<ConversationEntry>;
21
18
  }
22
19
  export {};
@@ -1,4 +1,4 @@
1
- import { BehaviorSubject, Observable } from 'rxjs';
1
+ import { BehaviorSubject } from 'rxjs';
2
2
  import { ConversationEntry } from './conversation-entry';
3
3
  import { ConversationProvider } from './conversation-provider';
4
4
  import Conversation from '../conversation';
@@ -8,7 +8,6 @@ export declare class ConversationSessionState {
8
8
  private provider?;
9
9
  constructor(id: string, component: Conversation);
10
10
  private write;
11
- entries(): Observable<ConversationEntry[]>;
11
+ entries(): import("rxjs").Observable<ConversationEntry[]>;
12
12
  setProvider(provider: ConversationProvider): void;
13
- isTyping(): Observable<boolean>;
14
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-conversation-flamingo",
3
- "version": "1.1.14-rc.2",
3
+ "version": "1.1.14",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -9,7 +9,7 @@
9
9
  "@lit-labs/motion": "^1.0.4",
10
10
  "@teliads/icons": "^8.4.0",
11
11
  "@teliads/components": "^22.1.1",
12
- "@telia-ace/widget-core-flamingo": "1.1.14-rc.2",
12
+ "@telia-ace/widget-core-flamingo": "1.1.14",
13
13
  "uuid": "^9.0.1",
14
14
  "lit-html": "^3.0.2",
15
15
  "rxjs": "^7.8.1"
package/index-23b605ae.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";let I;const bt=new Uint8Array(16);function mt(){if(!I&&(I=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!I))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return I(bt)}const p=[];for(let t=0;t<256;++t)p.push((t+256).toString(16).slice(1));function wt(t,e=0){return p[t[e+0]]+p[t[e+1]]+p[t[e+2]]+p[t[e+3]]+"-"+p[t[e+4]]+p[t[e+5]]+"-"+p[t[e+6]]+p[t[e+7]]+"-"+p[t[e+8]]+p[t[e+9]]+"-"+p[t[e+10]]+p[t[e+11]]+p[t[e+12]]+p[t[e+13]]+p[t[e+14]]+p[t[e+15]]}const St=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),G={randomUUID:St};function gt(t,e,r){if(G.randomUUID&&!e&&!t)return G.randomUUID();t=t||{};const n=t.random||(t.rng||mt)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=n[o];return e}return wt(n)}var R=function(t,e){return R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])},R(t,e)};function g(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");R(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function Et(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function u(f){try{c(n.next(f))}catch(b){s(b)}}function a(f){try{c(n.throw(f))}catch(b){s(b)}}function c(f){f.done?i(f.value):o(f.value).then(u,a)}c((n=n.apply(t,e||[])).next())})}function J(t,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(c){return function(f){return a([c,f])}}function a(c){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(r=0)),r;)try{if(n=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,o=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){r.label=c[1];break}if(c[0]===6&&r.label<i[1]){r.label=i[1],i=c;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(c);break}i[2]&&r.ops.pop(),r.trys.pop();continue}c=e.call(t,r)}catch(f){c=[6,f],o=0}finally{n=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function S(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function U(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i}function A(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,i;n<o;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function w(t){return this instanceof w?(this.v=t,this):new w(t)}function xt(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),o,i=[];return o={},s("next"),s("throw"),s("return"),o[Symbol.asyncIterator]=function(){return this},o;function s(l){n[l]&&(o[l]=function(v){return new Promise(function(x,d){i.push([l,v,x,d])>1||u(l,v)})})}function u(l,v){try{a(n[l](v))}catch(x){b(i[0][3],x)}}function a(l){l.value instanceof w?Promise.resolve(l.value.v).then(c,f):b(i[0][2],l)}function c(l){u("next",l)}function f(l){u("throw",l)}function b(l,v){l(v),i.shift(),i.length&&u(i[0][0],i[0][1])}}function _t(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof S=="function"?S(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=t[i]&&function(s){return new Promise(function(u,a){s=t[i](s),o(u,a,s.done,s.value)})}}function o(i,s,u,a){Promise.resolve(a).then(function(c){i({value:c,done:u})},s)}}function h(t){return typeof t=="function"}function Q(t){var e=function(n){Error.call(n),n.stack=new Error().stack},r=t(e);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var k=Q(function(t){return function(r){t(this),this.message=r?r.length+` errors occurred during unsubscription:
2
- `+r.map(function(n,o){return o+1+") "+n.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=r}});function F(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}var T=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,r,n,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var u=S(s),a=u.next();!a.done;a=u.next()){var c=a.value;c.remove(this)}}catch(d){e={error:d}}finally{try{a&&!a.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}else s.remove(this);var f=this.initialTeardown;if(h(f))try{f()}catch(d){i=d instanceof k?d.errors:[d]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var l=S(b),v=l.next();!v.done;v=l.next()){var x=v.value;try{H(x)}catch(d){i=i??[],d instanceof k?i=A(A([],U(i)),U(d.errors)):i.push(d)}}}catch(d){n={error:d}}finally{try{v&&!v.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}}if(i)throw new k(i)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)H(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(e)}},t.prototype._hasParent=function(e){var r=this._parentage;return r===e||Array.isArray(r)&&r.includes(e)},t.prototype._addParent=function(e){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(e),r):r?[r,e]:e},t.prototype._removeParent=function(e){var r=this._parentage;r===e?this._parentage=null:Array.isArray(r)&&F(r,e)},t.prototype.remove=function(e){var r=this._finalizers;r&&F(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),W=T.EMPTY;function X(t){return t instanceof T||t&&"closed"in t&&h(t.remove)&&h(t.add)&&h(t.unsubscribe)}function H(t){h(t)?t():t.unsubscribe()}var Z={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},L={setTimeout:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=L.delegate;return o!=null&&o.setTimeout?o.setTimeout.apply(o,A([t,e],U(r))):setTimeout.apply(void 0,A([t,e],U(r)))},clearTimeout:function(t){var e=L.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function N(t){L.setTimeout(function(){throw t})}function q(){}function O(t){t()}var V=function(t){g(e,t);function e(r){var n=t.call(this)||this;return n.isStopped=!1,r?(n.destination=r,X(r)&&r.add(n)):n.destination=Ut,n}return e.create=function(r,n,o){return new D(r,n,o)},e.prototype.next=function(r){this.isStopped||this._next(r)},e.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(r){this.destination.next(r)},e.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(T),It=Function.prototype.bind;function $(t,e){return It.call(t,e)}var Pt=function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var r=this.partialObserver;if(r.next)try{r.next(e)}catch(n){P(n)}},t.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(n){P(n)}else P(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){P(r)}},t}(),D=function(t){g(e,t);function e(r,n,o){var i=t.call(this)||this,s;if(h(r)||!r)s={next:r??void 0,error:n??void 0,complete:o??void 0};else{var u;i&&Z.useDeprecatedNextContext?(u=Object.create(r),u.unsubscribe=function(){return i.unsubscribe()},s={next:r.next&&$(r.next,u),error:r.error&&$(r.error,u),complete:r.complete&&$(r.complete,u)}):s=r}return i.destination=new Pt(s),i}return e}(V);function P(t){N(t)}function Ot(t){throw t}var Ut={closed:!0,next:q,error:Ot,complete:q},Y=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function At(t){return t}function Tt(t){return t.length===0?At:t.length===1?t[0]:function(r){return t.reduce(function(n,o){return o(n)},r)}}var y=function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(e,r,n){var o=this,i=jt(e)?e:new D(e,r,n);return O(function(){var s=o,u=s.operator,a=s.source;i.add(u?u.call(i,a):a?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(r){e.error(r)}},t.prototype.forEach=function(e,r){var n=this;return r=z(r),new r(function(o,i){var s=new D({next:function(u){try{e(u)}catch(a){i(a),s.unsubscribe()}},error:i,complete:o});n.subscribe(s)})},t.prototype._subscribe=function(e){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(e)},t.prototype[Y]=function(){return this},t.prototype.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Tt(e)(this)},t.prototype.toPromise=function(e){var r=this;return e=z(e),new e(function(n,o){var i;r.subscribe(function(s){return i=s},function(s){return o(s)},function(){return n(i)})})},t.create=function(e){return new t(e)},t}();function z(t){var e;return(e=t??Z.Promise)!==null&&e!==void 0?e:Promise}function Ct(t){return t&&h(t.next)&&h(t.error)&&h(t.complete)}function jt(t){return t&&t instanceof V||Ct(t)&&X(t)}function kt(t){return h(t==null?void 0:t.lift)}function B(t){return function(e){if(kt(e))return e.lift(function(r){try{return t(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function tt(t,e,r,n,o){return new $t(t,e,r,n,o)}var $t=function(t){g(e,t);function e(r,n,o,i,s,u){var a=t.call(this,r)||this;return a.onFinalize=s,a.shouldUnsubscribe=u,a._next=n?function(c){try{n(c)}catch(f){r.error(f)}}:t.prototype._next,a._error=i?function(c){try{i(c)}catch(f){r.error(f)}finally{this.unsubscribe()}}:t.prototype._error,a._complete=o?function(){try{o()}catch(c){r.error(c)}finally{this.unsubscribe()}}:t.prototype._complete,a}return e.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},e}(V),Rt=Q(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),E=function(t){g(e,t);function e(){var r=t.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return e.prototype.lift=function(r){var n=new K(this,this);return n.operator=r,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Rt},e.prototype.next=function(r){var n=this;O(function(){var o,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var s=S(n.currentObservers),u=s.next();!u.done;u=s.next()){var a=u.value;a.next(r)}}catch(c){o={error:c}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}})},e.prototype.error=function(r){var n=this;O(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var o=n.observers;o.length;)o.shift().error(r)}})},e.prototype.complete=function(){var r=this;O(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(r){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,r)},e.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},e.prototype._innerSubscribe=function(r){var n=this,o=this,i=o.hasError,s=o.isStopped,u=o.observers;return i||s?W:(this.currentObservers=null,u.push(r),new T(function(){n.currentObservers=null,F(u,r)}))},e.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,i=n.thrownError,s=n.isStopped;o?r.error(i):s&&r.complete()},e.prototype.asObservable=function(){var r=new y;return r.source=this,r},e.create=function(r,n){return new K(r,n)},e}(y),K=function(t){g(e,t);function e(r,n){var o=t.call(this)||this;return o.destination=r,o.source=n,o}return e.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},e.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,r)},e.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},e.prototype._subscribe=function(r){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:W},e}(E),rt=function(t){g(e,t);function e(r){var n=t.call(this)||this;return n._value=r,n}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(r){var n=t.prototype._subscribe.call(this,r);return!n.closed&&r.next(this._value),n},e.prototype.getValue=function(){var r=this,n=r.hasError,o=r.thrownError,i=r._value;if(n)throw o;return this._throwIfClosed(),i},e.prototype.next=function(r){t.prototype.next.call(this,this._value=r)},e}(E),Ft=new y(function(t){return t.complete()});function Lt(t){return t&&h(t.schedule)}function Dt(t){return t[t.length-1]}function Vt(t){return Lt(Dt(t))?t.pop():void 0}var et=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function nt(t){return h(t==null?void 0:t.then)}function ot(t){return h(t[Y])}function it(t){return Symbol.asyncIterator&&h(t==null?void 0:t[Symbol.asyncIterator])}function st(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Yt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ut=Yt();function ct(t){return h(t==null?void 0:t[ut])}function at(t){return xt(this,arguments,function(){var r,n,o,i;return J(this,function(s){switch(s.label){case 0:r=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,w(r.read())];case 3:return n=s.sent(),o=n.value,i=n.done,i?[4,w(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,w(o)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function lt(t){return h(t==null?void 0:t.getReader)}function M(t){if(t instanceof y)return t;if(t!=null){if(ot(t))return Bt(t);if(et(t))return Mt(t);if(nt(t))return Gt(t);if(it(t))return ft(t);if(ct(t))return Ht(t);if(lt(t))return qt(t)}throw st(t)}function Bt(t){return new y(function(e){var r=t[Y]();if(h(r.subscribe))return r.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Mt(t){return new y(function(e){for(var r=0;r<t.length&&!e.closed;r++)e.next(t[r]);e.complete()})}function Gt(t){return new y(function(e){t.then(function(r){e.closed||(e.next(r),e.complete())},function(r){return e.error(r)}).then(null,N)})}function Ht(t){return new y(function(e){var r,n;try{for(var o=S(t),i=o.next();!i.done;i=o.next()){var s=i.value;if(e.next(s),e.closed)return}}catch(u){r={error:u}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()})}function ft(t){return new y(function(e){zt(t,e).catch(function(r){return e.error(r)})})}function qt(t){return ft(at(t))}function zt(t,e){var r,n,o,i;return Et(this,void 0,void 0,function(){var s,u;return J(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),r=_t(t),a.label=1;case 1:return[4,r.next()];case 2:if(n=a.sent(),!!n.done)return[3,4];if(s=n.value,e.next(s),e.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=a.sent(),o={error:u},[3,11];case 6:return a.trys.push([6,,9,10]),n&&!n.done&&(i=r.return)?[4,i.call(r)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function m(t,e,r,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var i=e.schedule(function(){r(),o?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(i),!o)return i}function ht(t,e){return e===void 0&&(e=0),B(function(r,n){r.subscribe(tt(n,function(o){return m(n,t,function(){return n.next(o)},e)},function(){return m(n,t,function(){return n.complete()},e)},function(o){return m(n,t,function(){return n.error(o)},e)}))})}function pt(t,e){return e===void 0&&(e=0),B(function(r,n){n.add(t.schedule(function(){return r.subscribe(n)},e))})}function Kt(t,e){return M(t).pipe(pt(e),ht(e))}function Jt(t,e){return M(t).pipe(pt(e),ht(e))}function Qt(t,e){return new y(function(r){var n=0;return e.schedule(function(){n===t.length?r.complete():(r.next(t[n++]),r.closed||this.schedule())})})}function Wt(t,e){return new y(function(r){var n;return m(r,e,function(){n=t[ut](),m(r,e,function(){var o,i,s;try{o=n.next(),i=o.value,s=o.done}catch(u){r.error(u);return}s?r.complete():r.next(i)},0,!0)}),function(){return h(n==null?void 0:n.return)&&n.return()}})}function dt(t,e){if(!t)throw new Error("Iterable cannot be null");return new y(function(r){m(r,e,function(){var n=t[Symbol.asyncIterator]();m(r,e,function(){n.next().then(function(o){o.done?r.complete():r.next(o.value)})},0,!0)})})}function Xt(t,e){return dt(at(t),e)}function Zt(t,e){if(t!=null){if(ot(t))return Kt(t,e);if(et(t))return Qt(t,e);if(nt(t))return Jt(t,e);if(it(t))return dt(t,e);if(ct(t))return Wt(t,e);if(lt(t))return Xt(t,e)}throw st(t)}function Nt(t,e){return e?Zt(t,e):M(t)}function tr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=Vt(t);return Nt(t,r)}function rr(t){return t<=0?function(){return Ft}:B(function(e,r){var n=0;e.subscribe(tt(r,function(o){++n<=t&&(r.next(o),t<=n&&r.complete())}))})}class er{constructor(e,r){this.id=e,this.entries$=new rt([]),r.addEventListener("user-submit",n=>{if(!this.provider){console.warn("No provider activated, unable to print message to conversation.");return}this.provider.onUserSubmit(n.detail)})}write(e){this.entries$.pipe(rr(1)).subscribe(r=>{this.entries$.next([...r,e])})}entries(){return this.entries$.asObservable()}setProvider(e){this.provider=e,this.provider.actions().subscribe(r=>{this.write(r)})}isTyping(){return this.provider?this.provider.isTyping():tr(!1)}}class C{constructor(){this.sessions=new Map,this.registeredProviders=new Map,this.activeSessionId=null}static async getInstance(e){let r=await e.get("conversation");return r||(r=new C,await e.register("conversation",r),r)}registerProvider(e,r){this.registeredProviders.set(e,r)}createSession(e){const r=new er(gt(),e),n=this.getProviderByConfiguration(e);if(n){const o=n();r.setProvider(o)}return this.sessions.set(r.id,r),this.activeSessionId=r.id,r}getProviderByConfiguration(e){const[r]=e.properties.providers||[];if(!r){console.warn("No providers registered. You most likely forgot to add a provider to the conversation component properties.");return}return this.registeredProviders.get(r)}}const nr=async t=>{t.registerComponent("conversation",Promise.resolve().then(()=>require("./conversation-2e20f9c4.js")).then(e=>e.conversation)),await C.getInstance(t.container)};var _=(t=>(t.User="user",t.Agent="agent",t.System="system",t))(_||{});class j{constructor(e,r,n){this.type=e,this.sender=r,this.messages=n,this.didUpdate=new E,this.timestamp=Date.now()}update(e){this.messages=[{items:e}],this.didUpdate.next(this)}}class vt{constructor(e){this.name=e,this.print$=new E}print(e){const r=new j(_.Agent,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(r),r}subscribe(){return this.print$.asObservable()}}class yt{constructor(e){this.name=e,this.print$=new E}print(e){const r=new j(_.User,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(r),r}subscribe(){return this.print$.asObservable()}}class or{constructor(e){this.name=e,this.print$=new E,this.typingState$=new rt(!1)}onUserSubmit(e){this.print(_.User,e.text)}print(e,r){const n=new j(e,{name:""},[{items:[["html",{content:r}]]}]);return this.printEntry(n)}printEntry(e){return this.print$.next(e),e}createAgent(e){const r=new vt(e);return r.subscribe().subscribe(n=>{this.printEntry(n)}),r}createUser(e){const r=new yt(e);return r.subscribe().subscribe(n=>{this.printEntry(n)}),r}setTypingState(e){this.typingState$.next(e)}isTyping(){return this.typingState$.asObservable()}actions(){return this.print$.asObservable()}}exports.Agent=vt;exports.ConversationComponent=nr;exports.ConversationEntry=j;exports.ConversationMessageType=_;exports.ConversationPlatform=C;exports.ConversationProvider=or;exports.User=yt;