@telia-ace/widget-conversation-flamingo 1.1.45-rc.3 → 1.1.45-rc.4

Sign up to get free protection for your applications and to get access to all the features.
package/conversation.d.ts CHANGED
@@ -2,6 +2,7 @@ import { LitElement } from 'lit';
2
2
  import { Ref } from 'lit-html/directives/ref.js';
3
3
  import { ConversationPlatform } from './conversation-platform';
4
4
  import { ConversationSessionState } from './models/conversation-session-state';
5
+ import { Observable } from 'rxjs';
5
6
  declare const WidgetElement: (new (...args: any[]) => import("@telia-ace/widget-core-flamingo").WidgetComponentType) & typeof LitElement;
6
7
  export declare class Conversation extends WidgetElement {
7
8
  static styles: import("lit").CSSResultGroup[];
@@ -25,7 +26,7 @@ export declare class Conversation extends WidgetElement {
25
26
  disableInput(): void;
26
27
  enableInput(): void;
27
28
  setToastMessage(message: string | null): void;
28
- handover(providerKey: string, handoverOptions?: Record<string, any>): void;
29
+ handover(providerKey: string, handoverOptions?: Record<string, any>): Observable<void>;
29
30
  render(): import("lit-html").TemplateResult<1>;
30
31
  }
31
32
  export default Conversation;
@@ -0,0 +1,3 @@
1
+ "use strict";let I;const ct=new Uint8Array(16);function at(){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(ct)}const h=[];for(let r=0;r<256;++r)h.push((r+256).toString(16).slice(1));function lt(r,e=0){return h[r[e+0]]+h[r[e+1]]+h[r[e+2]]+h[r[e+3]]+"-"+h[r[e+4]]+h[r[e+5]]+"-"+h[r[e+6]]+h[r[e+7]]+"-"+h[r[e+8]]+h[r[e+9]]+"-"+h[r[e+10]]+h[r[e+11]]+h[r[e+12]]+h[r[e+13]]+h[r[e+14]]+h[r[e+15]]}const ft=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),z={randomUUID:ft};function ht(r,e,t){if(z.randomUUID&&!e&&!r)return z.randomUUID();r=r||{};const n=r.random||(r.rng||at)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){t=t||0;for(let i=0;i<16;++i)e[t+i]=n[i];return e}return lt(n)}var R=function(r,e){return R=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])},R(r,e)};function g(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");R(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function pt(r,e,t,n){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function u(l){try{c(n.next(l))}catch(v){s(v)}}function a(l){try{c(n.throw(l))}catch(v){s(v)}}function c(l){l.done?o(l.value):i(l.value).then(u,a)}c((n=n.apply(r,e||[])).next())})}function X(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,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(l){return a([c,l])}}function a(c){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(l){c=[6,l],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function S(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function T(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],s;try{for(;(e===void 0||e-- >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 U(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}function w(r){return this instanceof w?(this.v=r,this):new w(r)}function dt(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(f){n[f]&&(i[f]=function(y){return new Promise(function(x,d){o.push([f,y,x,d])>1||u(f,y)})})}function u(f,y){try{a(n[f](y))}catch(x){v(o[0][3],x)}}function a(f){f.value instanceof w?Promise.resolve(f.value.v).then(c,l):v(o[0][2],f)}function c(f){u("next",f)}function l(f){u("throw",f)}function v(f,y){f(y),o.shift(),o.length&&u(o[0][0],o[0][1])}}function vt(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof S=="function"?S(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(s){return new Promise(function(u,a){s=r[o](s),i(u,a,s.done,s.value)})}}function i(o,s,u,a){Promise.resolve(a).then(function(c){o({value:c,done:u})},s)}}function p(r){return typeof r=="function"}function Z(r){var e=function(n){Error.call(n),n.stack=new Error().stack},t=r(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var k=Z(function(r){return function(t){r(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 F(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var A=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,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=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&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}else s.remove(this);var l=this.initialTeardown;if(p(l))try{l()}catch(d){o=d instanceof k?d.errors:[d]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var f=S(v),y=f.next();!y.done;y=f.next()){var x=y.value;try{K(x)}catch(d){o=o??[],d instanceof k?o=U(U([],T(o)),T(d.errors)):o.push(d)}}}catch(d){n={error:d}}finally{try{y&&!y.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}}if(o)throw new k(o)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)K(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&F(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&F(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}(),N=A.EMPTY;function tt(r){return r instanceof A||r&&"closed"in r&&p(r.remove)&&p(r.add)&&p(r.unsubscribe)}function K(r){p(r)?r():r.unsubscribe()}var et={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},M={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=M.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,U([r,e],T(t))):setTimeout.apply(void 0,U([r,e],T(t)))},clearTimeout:function(r){var e=M.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(r)},delegate:void 0};function rt(r){M.setTimeout(function(){throw r})}function D(){}function O(r){r()}var B=function(r){g(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,tt(t)&&t.add(n)):n.destination=wt,n}return e.create=function(t,n,i){return new L(t,n,i)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(A),yt=Function.prototype.bind;function j(r,e){return yt.call(r,e)}var bt=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){P(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){P(n)}else P(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){P(t)}},r}(),L=function(r){g(e,r);function e(t,n,i){var o=r.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&&et.useDeprecatedNextContext?(u=Object.create(t),u.unsubscribe=function(){return o.unsubscribe()},s={next:t.next&&j(t.next,u),error:t.error&&j(t.error,u),complete:t.complete&&j(t.complete,u)}):s=t}return o.destination=new bt(s),o}return e}(B);function P(r){rt(r)}function mt(r){throw r}var wt={closed:!0,next:D,error:mt,complete:D},H=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function St(r){return r}function gt(r){return r.length===0?St:r.length===1?r[0]:function(t){return r.reduce(function(n,i){return i(n)},t)}}var m=function(){function r(e){e&&(this._subscribe=e)}return r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,n){var i=this,o=xt(e)?e:new L(e,t,n);return O(function(){var s=i,u=s.operator,a=s.source;o.add(u?u.call(o,a):a?i._subscribe(o):i._trySubscribe(o))}),o},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var n=this;return t=J(t),new t(function(i,o){var s=new L({next:function(u){try{e(u)}catch(a){o(a),s.unsubscribe()}},error:o,complete:i});n.subscribe(s)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[H]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return gt(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=J(e),new e(function(n,i){var o;t.subscribe(function(s){return o=s},function(s){return i(s)},function(){return n(o)})})},r.create=function(e){return new r(e)},r}();function J(r){var e;return(e=r??et.Promise)!==null&&e!==void 0?e:Promise}function Et(r){return r&&p(r.next)&&p(r.error)&&p(r.complete)}function xt(r){return r&&r instanceof B||Et(r)&&tt(r)}function _t(r){return p(r==null?void 0:r.lift)}function G(r){return function(e){if(_t(e))return e.lift(function(t){try{return r(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function $(r,e,t,n,i){return new It(r,e,t,n,i)}var It=function(r){g(e,r);function e(t,n,i,o,s,u){var a=r.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=u,a._next=n?function(c){try{n(c)}catch(l){t.error(l)}}:r.prototype._next,a._error=o?function(c){try{o(c)}catch(l){t.error(l)}finally{this.unsubscribe()}}:r.prototype._error,a._complete=i?function(){try{i()}catch(c){t.error(c)}finally{this.unsubscribe()}}:r.prototype._complete,a}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;r.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(B),Pt=Z(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),b=function(r){g(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var n=new Q(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Pt},e.prototype.next=function(t){var n=this;O(function(){var i,o;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(t)}}catch(c){i={error:c}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},e.prototype.error=function(t){var n=this;O(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)}})},e.prototype.complete=function(){var t=this;O(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.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 t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,i=this,o=i.hasError,s=i.isStopped,u=i.observers;return o||s?N:(this.currentObservers=null,u.push(t),new A(function(){n.currentObservers=null,F(u,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,o=n.thrownError,s=n.isStopped;i?t.error(o):s&&t.complete()},e.prototype.asObservable=function(){var t=new m;return t.source=this,t},e.create=function(t,n){return new Q(t,n)},e}(m),Q=function(r){g(e,r);function e(t,n){var i=r.call(this)||this;return i.destination=t,i.source=n,i}return e.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)},e.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)},e.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)},e.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:N},e}(b),Y=function(r){g(e,r);function e(t){var n=r.call(this)||this;return n._value=t,n}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(t){var n=r.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},e.prototype.getValue=function(){var t=this,n=t.hasError,i=t.thrownError,o=t._value;if(n)throw i;return this._throwIfClosed(),o},e.prototype.next=function(t){r.prototype.next.call(this,this._value=t)},e}(b),q=new m(function(r){return r.complete()}),Ot=function(r){return r&&typeof r.length=="number"&&typeof r!="function"};function Tt(r){return p(r==null?void 0:r.then)}function Ut(r){return p(r[H])}function $t(r){return Symbol.asyncIterator&&p(r==null?void 0:r[Symbol.asyncIterator])}function At(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Ct(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var kt=Ct();function jt(r){return p(r==null?void 0:r[kt])}function Rt(r){return dt(this,arguments,function(){var t,n,i,o;return X(this,function(s){switch(s.label){case 0:t=r.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,w(t.read())];case 3:return n=s.sent(),i=n.value,o=n.done,o?[4,w(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,w(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Ft(r){return p(r==null?void 0:r.getReader)}function nt(r){if(r instanceof m)return r;if(r!=null){if(Ut(r))return Mt(r);if(Ot(r))return Dt(r);if(Tt(r))return Lt(r);if($t(r))return it(r);if(jt(r))return Yt(r);if(Ft(r))return Vt(r)}throw At(r)}function Mt(r){return new m(function(e){var t=r[H]();if(p(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Dt(r){return new m(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}function Lt(r){return new m(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,rt)})}function Yt(r){return new m(function(e){var t,n;try{for(var i=S(r),o=i.next();!o.done;o=i.next()){var s=o.value;if(e.next(s),e.closed)return}}catch(u){t={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.complete()})}function it(r){return new m(function(e){Bt(r,e).catch(function(t){return e.error(t)})})}function Vt(r){return it(Rt(r))}function Bt(r,e){var t,n,i,o;return pt(this,void 0,void 0,function(){var s,u;return X(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),t=vt(r),a.label=1;case 1:return[4,t.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(),i={error:u},[3,11];case 6:return a.trys.push([6,,9,10]),n&&!n.done&&(o=t.return)?[4,o.call(t)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function V(r){return r<=0?function(){return q}:G(function(e,t){var n=0;e.subscribe($(t,function(i){++n<=r&&(t.next(i),r<=n&&t.complete())}))})}function Ht(r,e){return G(function(t,n){var i=null,o=0,s=!1,u=function(){return s&&!i&&n.complete()};t.subscribe($(n,function(a){i==null||i.unsubscribe();var c=0,l=o++;nt(r(a,l)).subscribe(i=$(n,function(v){return n.next(e?e(a,v,l,c++):v)},function(){i=null,u()}))},function(){s=!0,u()}))})}function W(r){return G(function(e,t){nt(r).subscribe($(t,function(){return t.complete()},D)),!t.closed&&e.subscribe(t)})}class ot{constructor(e,t,n){this.id=e,this.component=t,this.platform=n,this.entries$=new Y([]),this.kill$=new b,this.isTyping$=new Y(!1),t.addEventListener("user-submit",i=>{if(!this.provider){console.warn("No provider activated, unable to print message to conversation.");return}this.provider.onUserSubmit(i.detail)})}write(e){this.addEntryRemoveHandler(e),this.entries$.pipe(V(1)).subscribe(t=>{this.entries$.next([...t,e])})}entries(){return this.entries$.asObservable()}setProvider(e,t={}){this.provider=e,this.provider.actions().pipe(W(this.kill$)).subscribe(n=>{this.write(n)}),this.provider.isTyping().pipe(W(this.kill$)).subscribe(n=>{this.isTyping$.next(n)}),this.provider.connect(t)}handover(e,t={}){var i;(i=this.provider)==null||i.setTypingState(!1);const n=this.platform.registeredProviders.get(e);if(n){this.kill$.next();const o=n(this);return this.setProvider(o,t),o.onComplete()}return q}addEntryRemoveHandler(e){e.remove$.pipe(Ht(()=>this.entries$),V(1)).subscribe(t=>{this.entries$.next(t.filter(n=>n!==e))})}isTyping(){return this.isTyping$.asObservable()}}class C{constructor(){this.sessions=new Map,this.registeredProviders=new Map,this.activeSessionId=null}static async getInstance(e){let t=await e.get("conversation");return t||(t=new C,await e.register("conversation",t),t)}registerProvider(e,t){this.registeredProviders.set(e,t)}createSession(e){const t=new ot(ht(),e,this),n=this.getProviderByConfiguration(e);if(n){const i=n(t);t.setProvider(i)}return this.sessions.set(t.id,t),this.activeSessionId=t.id,t}getProviderByConfiguration(e){const[t]=e.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 Gt=async r=>{r.registerComponent("conversation",Promise.resolve().then(()=>require("./conversation-4cae227d.js"))),await C.getInstance(r.container)};var E=(r=>(r.User="user",r.Agent="agent",r.System="system",r))(E||{});class _{constructor(e,t,n){this.type=e,this.sender=t,this.messages=n,this.status="delivered",this.didUpdate=new b,this.actions$=new b,this.remove$=new b,this.timestamp=Date.now()}update(e){this.messages=[{items:e}],this.didUpdate.next(this)}setStatus(e){this.status=e,this.didUpdate.next(this)}remove(){this.remove$.next()}}class st{constructor(e){this.name=e,this.print$=new b}print(e){const t=new _(E.Agent,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class ut{constructor(e){this.name=e,this.print$=new b}print(e){const t=new _(E.User,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class qt{constructor(){this.print$=new b,this.name="system"}print(e){const t=new _(E.System,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class zt{constructor(e,t){this.name=e,this.session=t,this.print$=new b,this.typingState$=new Y(!1),this.complete$=new b,this.system=this.createSystem(),this.onComplete=()=>this.complete$.asObservable()}connect(e={}){this.complete$.pipe(V(1)).subscribe(()=>{this.disconnected()})}disconnected(){}onUserSubmit(e){this.print(E.User,e.text)}print(e,t){const n=new _(e,{name:""},[{items:[["html",{content:t}]]}]);return this.printEntry(n)}printEntry(e){return this.print$.next(e),e}createAgent(e){const t=new st(e);return t.subscribe().subscribe(n=>{this.playNotification(),this.printEntry(n)}),t}createUser(e){const t=new ut(e);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}createSystem(){const e=new qt;return e.subscribe().subscribe(t=>{this.printEntry(t)}),e}setTypingState(e){this.typingState$.next(e)}setToastMessage(e){this.session.component.setToastMessage(e)}isTyping(){return this.typingState$.asObservable()}actions(){return this.print$.asObservable()}playNotification(){const e="https://publicpoc.blob.core.windows.net/widget-assets/notification.mp3";this.session.component.application.branding().other.disableSound||new Audio(e).play()}complete(){this.complete$.next()}}exports.Agent=st;exports.ConversationComponent=Gt;exports.ConversationEntry=_;exports.ConversationMessageType=E;exports.ConversationPlatform=C;exports.ConversationProvider=zt;exports.ConversationSessionState=ot;exports.EMPTY=q;exports.User=ut;