@asgard-js/core 0.0.2 → 0.0.4

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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- (function(p,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(p=typeof globalThis<"u"?globalThis:p||self,b(p["@asgard-js/core"]={}))})(this,function(p){"use strict";var Ln=Object.defineProperty;var jn=(p,b,m)=>b in p?Ln(p,b,{enumerable:!0,configurable:!0,writable:!0,value:m}):p[b]=m;var P=(p,b,m)=>jn(p,typeof b!="symbol"?b+"":b,m);var b=(n=>(n.RESET_CHANNEL="RESET_CHANNEL",n.NONE="NONE",n))(b||{}),m=(n=>(n.INIT="asgard.run.init",n.MESSAGE_START="asgard.message.start",n.MESSAGE_DELTA="asgard.message.delta",n.MESSAGE_COMPLETE="asgard.message.complete",n.DONE="asgard.run.done",n))(m||{}),J=(n=>(n.TEXT="TEXT",n.HINT="HINT",n.BUTTON="BUTTON",n.IMAGE="IMAGE",n.VIDEO="VIDEO",n.AUDIO="AUDIO",n.LOCATION="LOCATION",n.CAROUSEL="CAROUSEL",n))(J||{}),H=function(n,t){return H=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},H(n,t)};function O(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");H(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function ke(n,t,e,r){function i(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function c(l){try{a(r.next(l))}catch(h){o(h)}}function u(l){try{a(r.throw(l))}catch(h){o(h)}}function a(l){l.done?s(l.value):i(l.value).then(c,u)}a((r=r.apply(n,t||[])).next())})}function Q(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(a){return function(l){return u([a,l])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(e=0)),e;)try{if(r=1,i&&(s=a[0]&2?i.return:a[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,a[1])).done)return s;switch(i=0,s&&(a=[a[0]&2,s.value]),a[0]){case 0:case 1:s=a;break;case 4:return e.label++,{value:a[1],done:!1};case 5:e.label++,i=a[1],a=[0];continue;case 7:a=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){e.label=a[1];break}if(a[0]===6&&e.label<s[1]){e.label=s[1],s=a;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(a);break}s[2]&&e.ops.pop(),e.trys.pop();continue}a=t.call(n,e)}catch(l){a=[6,l],i=0}finally{r=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function D(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function j(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return s}function N(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return n.concat(s||Array.prototype.slice.call(t))}function k(n){return this instanceof k?(this.v=n,this):new k(n)}function Le(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(f){return function(y){return Promise.resolve(y).then(f,h)}}function c(f,y){r[f]&&(i[f]=function(d){return new Promise(function(E,I){s.push([f,d,E,I])>1||u(f,d)})},y&&(i[f]=y(i[f])))}function u(f,y){try{a(r[f](y))}catch(d){g(s[0][3],d)}}function a(f){f.value instanceof k?Promise.resolve(f.value.v).then(l,h):g(s[0][2],f)}function l(f){u("next",f)}function h(f){u("throw",f)}function g(f,y){f(y),s.shift(),s.length&&u(s[0][0],s[0][1])}}function je(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof D=="function"?D(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(s){e[s]=n[s]&&function(o){return new Promise(function(c,u){o=n[s](o),i(c,u,o.done,o.value)})}}function i(s,o,c,u){Promise.resolve(u).then(function(a){s({value:a,done:c})},o)}}typeof SuppressedError=="function"&&SuppressedError;function v(n){return typeof n=="function"}function Z(n){var t=function(r){Error.call(r),r.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var $=Z(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
1
+ (function(p,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(p=typeof globalThis<"u"?globalThis:p||self,b(p["@asgard-js/core"]={}))})(this,function(p){"use strict";var Lt=Object.defineProperty;var Ut=(p,b,g)=>b in p?Lt(p,b,{enumerable:!0,configurable:!0,writable:!0,value:g}):p[b]=g;var S=(p,b,g)=>Ut(p,typeof b!="symbol"?b+"":b,g);var b=(t=>(t.RESET_CHANNEL="RESET_CHANNEL",t.NONE="NONE",t))(b||{}),g=(t=>(t.INIT="asgard.run.init",t.MESSAGE_START="asgard.message.start",t.MESSAGE_DELTA="asgard.message.delta",t.MESSAGE_COMPLETE="asgard.message.complete",t.DONE="asgard.run.done",t))(g||{}),Q=(t=>(t.TEXT="TEXT",t.HINT="HINT",t.BUTTON="BUTTON",t.IMAGE="IMAGE",t.VIDEO="VIDEO",t.AUDIO="AUDIO",t.LOCATION="LOCATION",t.CAROUSEL="CAROUSEL",t))(Q||{}),K=function(t,n){return K=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},K(t,n)};function I(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");K(t,n);function e(){this.constructor=t}t.prototype=n===null?Object.create(n):(e.prototype=n.prototype,new e)}function je(t,n,e,r){function i(u){return u instanceof e?u:new e(function(o){o(u)})}return new(e||(e=Promise))(function(u,o){function s(l){try{a(r.next(l))}catch(h){o(h)}}function c(l){try{a(r.throw(l))}catch(h){o(h)}}function a(l){l.done?u(l.value):i(l.value).then(s,c)}a((r=r.apply(t,n||[])).next())})}function Z(t,n){var e={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},r,i,u,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(a){return function(l){return c([a,l])}}function c(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(e=0)),e;)try{if(r=1,i&&(u=a[0]&2?i.return:a[0]?i.throw||((u=i.return)&&u.call(i),0):i.next)&&!(u=u.call(i,a[1])).done)return u;switch(i=0,u&&(a=[a[0]&2,u.value]),a[0]){case 0:case 1:u=a;break;case 4:return e.label++,{value:a[1],done:!1};case 5:e.label++,i=a[1],a=[0];continue;case 7:a=e.ops.pop(),e.trys.pop();continue;default:if(u=e.trys,!(u=u.length>0&&u[u.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!u||a[1]>u[0]&&a[1]<u[3])){e.label=a[1];break}if(a[0]===6&&e.label<u[1]){e.label=u[1],u=a;break}if(u&&e.label<u[2]){e.label=u[2],e.ops.push(a);break}u[2]&&e.ops.pop(),e.trys.pop();continue}a=n.call(t,e)}catch(l){a=[6,l],i=0}finally{r=u=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function D(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function L(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,u=[],o;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)u.push(i.value)}catch(s){o={error:s}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return u}function U(t,n,e){if(e||arguments.length===2)for(var r=0,i=n.length,u;r<i;r++)(u||!(r in n))&&(u||(u=Array.prototype.slice.call(n,0,r)),u[r]=n[r]);return t.concat(u||Array.prototype.slice.call(n))}function k(t){return this instanceof k?(this.v=t,this):new k(t)}function Le(t,n,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(t,n||[]),i,u=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(f){return function(y){return Promise.resolve(y).then(f,h)}}function s(f,y){r[f]&&(i[f]=function(d){return new Promise(function(E,O){u.push([f,d,E,O])>1||c(f,d)})},y&&(i[f]=y(i[f])))}function c(f,y){try{a(r[f](y))}catch(d){m(u[0][3],d)}}function a(f){f.value instanceof k?Promise.resolve(f.value.v).then(l,h):m(u[0][2],f)}function l(f){c("next",f)}function h(f){c("throw",f)}function m(f,y){f(y),u.shift(),u.length&&c(u[0][0],u[0][1])}}function Ue(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t[Symbol.asyncIterator],e;return n?n.call(t):(t=typeof D=="function"?D(t):t[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(u){e[u]=t[u]&&function(o){return new Promise(function(s,c){o=t[u](o),i(s,c,o.done,o.value)})}}function i(u,o,s,c){Promise.resolve(c).then(function(a){u({value:a,done:s})},o)}}typeof SuppressedError=="function"&&SuppressedError;function v(t){return typeof t=="function"}function ee(t){var n=function(r){Error.call(r),r.stack=new Error().stack},e=t(n);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var H=ee(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
2
2
  `+e.map(function(r,i){return i+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=e}});function R(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var L=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=D(o),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(d){t={error:d}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else o.remove(this);var l=this.initialTeardown;if(v(l))try{l()}catch(d){s=d instanceof $?d.errors:[d]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var g=D(h),f=g.next();!f.done;f=g.next()){var y=f.value;try{te(y)}catch(d){s=s??[],d instanceof $?s=N(N([],j(s)),j(d.errors)):s.push(d)}}}catch(d){r={error:d}}finally{try{f&&!f.done&&(i=g.return)&&i.call(g)}finally{if(r)throw r.error}}}if(s)throw new $(s)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)te(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&R(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&R(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),ee=L.EMPTY;function ne(n){return n instanceof L||n&&"closed"in n&&v(n.remove)&&v(n.add)&&v(n.unsubscribe)}function te(n){v(n)?n():n.unsubscribe()}var Ne={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},re={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,N([n,t],j(e)))},clearTimeout:function(n){var t=re.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function ie(n){re.setTimeout(function(){throw n})}function V(){}function U(n){n()}var Y=function(n){O(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,ne(e)&&e.add(r)):r.destination=Ge,r}return t.create=function(e,r,i){return new q(e,r,i)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(L),Re=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){G(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){G(r)}else G(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){G(e)}},n}(),q=function(n){O(t,n);function t(e,r,i){var s=n.call(this)||this,o;return v(e)||!e?o={next:e??void 0,error:r??void 0,complete:i??void 0}:o=e,s.destination=new Re(o),s}return t}(Y);function G(n){ie(n)}function Ue(n){throw n}var Ge={closed:!0,next:V,error:Ue,complete:V},B=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function se(n){return n}function Fe(n){return n.length===0?se:n.length===1?n[0]:function(e){return n.reduce(function(r,i){return i(r)},e)}}var w=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var i=this,s=He(t)?t:new q(t,e,r);return U(function(){var o=i,c=o.operator,u=o.source;s.add(c?c.call(s,u):u?i._subscribe(s):i._trySubscribe(s))}),s},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=oe(e),new e(function(i,s){var o=new q({next:function(c){try{t(c)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[B]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Fe(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=oe(t),new t(function(r,i){var s;e.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},n.create=function(t){return new n(t)},n}();function oe(n){var t;return(t=n??Ne.Promise)!==null&&t!==void 0?t:Promise}function Ke(n){return n&&v(n.next)&&v(n.error)&&v(n.complete)}function He(n){return n&&n instanceof Y||Ke(n)&&ne(n)}function $e(n){return v(n==null?void 0:n.lift)}function _(n){return function(t){if($e(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function A(n,t,e,r,i){return new Ve(n,t,e,r,i)}var Ve=function(n){O(t,n);function t(e,r,i,s,o,c){var u=n.call(this,e)||this;return u.onFinalize=o,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(l){e.error(l)}}:n.prototype._next,u._error=s?function(a){try{s(a)}catch(l){e.error(l)}finally{this.unsubscribe()}}:n.prototype._error,u._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:n.prototype._complete,u}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(Y),Ye=Z(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ue=function(n){O(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var r=new ae(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Ye},t.prototype.next=function(e){var r=this;U(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=D(r.currentObservers),c=o.next();!c.done;c=o.next()){var u=c.value;u.next(e)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var r=this;U(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var i=r.observers;i.length;)i.shift().error(e)}})},t.prototype.complete=function(){var e=this;U(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var r=this,i=this,s=i.hasError,o=i.isStopped,c=i.observers;return s||o?ee:(this.currentObservers=null,c.push(e),new L(function(){r.currentObservers=null,R(c,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?e.error(s):o&&e.complete()},t.prototype.asObservable=function(){var e=new w;return e.source=this,e},t.create=function(e,r){return new ae(e,r)},t}(w),ae=function(n){O(t,n);function t(e,r){var i=n.call(this)||this;return i.destination=e,i.source=r,i}return t.prototype.next=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,e)},t.prototype.error=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,e)},t.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},t.prototype._subscribe=function(e){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&i!==void 0?i:ee},t}(ue),qe={now:function(){return Date.now()},delegate:void 0},Be=function(n){O(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(L),ce={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,N([n,t],j(e)))},clearInterval:function(n){return clearInterval(n)},delegate:void 0},We=function(n){O(t,n);function t(e,r){var i=n.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(e,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),ce.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&ce.clearInterval(r)},t.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,r){var i=!1,s;try{this.work(e)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,R(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Be),fe=function(){function n(t,e){e===void 0&&(e=n.now),this.schedulerActionCtor=t,this.now=e}return n.prototype.schedule=function(t,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},n.now=qe.now,n}(),Xe=function(n){O(t,n);function t(e,r){r===void 0&&(r=fe.now);var i=n.call(this,e,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,i){for(;e=r.shift();)e.unsubscribe();throw i}},t}(fe),le=new Xe(We),ze=le,Je=new w(function(n){return n.complete()});function de(n){return n&&v(n.schedule)}function Qe(n){return n[n.length-1]}function Ze(n){return de(Qe(n))?n.pop():void 0}var he=function(n){return n&&typeof n.length=="number"&&typeof n!="function"};function ye(n){return v(n==null?void 0:n.then)}function ve(n){return v(n[B])}function pe(n){return Symbol.asyncIterator&&v(n==null?void 0:n[Symbol.asyncIterator])}function be(n){return new TypeError("You provided "+(n!==null&&typeof n=="object"?"an invalid object":"'"+n+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function en(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var me=en();function ge(n){return v(n==null?void 0:n[me])}function we(n){return Le(this,arguments,function(){var e,r,i,s;return Q(this,function(o){switch(o.label){case 0:e=n.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,k(e.read())];case 3:return r=o.sent(),i=r.value,s=r.done,s?[4,k(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,k(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Se(n){return v(n==null?void 0:n.getReader)}function x(n){if(n instanceof w)return n;if(n!=null){if(ve(n))return nn(n);if(he(n))return tn(n);if(ye(n))return rn(n);if(pe(n))return Ee(n);if(ge(n))return sn(n);if(Se(n))return on(n)}throw be(n)}function nn(n){return new w(function(t){var e=n[B]();if(v(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function tn(n){return new w(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}function rn(n){return new w(function(t){n.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,ie)})}function sn(n){return new w(function(t){var e,r;try{for(var i=D(n),s=i.next();!s.done;s=i.next()){var o=s.value;if(t.next(o),t.closed)return}}catch(c){e={error:c}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}t.complete()})}function Ee(n){return new w(function(t){un(n,t).catch(function(e){return t.error(e)})})}function on(n){return Ee(we(n))}function un(n,t){var e,r,i,s;return ke(this,void 0,void 0,function(){var o,c;return Q(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),e=je(n),u.label=1;case 1:return[4,e.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),i={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(s=e.return)?[4,s.call(e)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function M(n,t,e,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var s=t.schedule(function(){e(),i?n.add(this.schedule(null,r)):this.unsubscribe()},r);if(n.add(s),!i)return s}function Ie(n,t){return t===void 0&&(t=0),_(function(e,r){e.subscribe(A(r,function(i){return M(r,n,function(){return r.next(i)},t)},function(){return M(r,n,function(){return r.complete()},t)},function(i){return M(r,n,function(){return r.error(i)},t)}))})}function Oe(n,t){return t===void 0&&(t=0),_(function(e,r){r.add(n.schedule(function(){return e.subscribe(r)},t))})}function an(n,t){return x(n).pipe(Oe(t),Ie(t))}function cn(n,t){return x(n).pipe(Oe(t),Ie(t))}function fn(n,t){return new w(function(e){var r=0;return t.schedule(function(){r===n.length?e.complete():(e.next(n[r++]),e.closed||this.schedule())})})}function ln(n,t){return new w(function(e){var r;return M(e,t,function(){r=n[me](),M(e,t,function(){var i,s,o;try{i=r.next(),s=i.value,o=i.done}catch(c){e.error(c);return}o?e.complete():e.next(s)},0,!0)}),function(){return v(r==null?void 0:r.return)&&r.return()}})}function Ae(n,t){if(!n)throw new Error("Iterable cannot be null");return new w(function(e){M(e,t,function(){var r=n[Symbol.asyncIterator]();M(e,t,function(){r.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function dn(n,t){return Ae(we(n),t)}function hn(n,t){if(n!=null){if(ve(n))return an(n,t);if(he(n))return fn(n,t);if(ye(n))return cn(n,t);if(pe(n))return Ae(n,t);if(ge(n))return ln(n,t);if(Se(n))return dn(n,t)}throw be(n)}function yn(n,t){return t?hn(n,t):x(n)}function vn(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ze(n);return yn(n,e)}function pn(n){return n instanceof Date&&!isNaN(n)}function xe(n,t){return _(function(e,r){var i=0;e.subscribe(A(r,function(s){r.next(n.call(t,s,i++))}))})}function bn(n,t,e,r,i,s,o,c){var u=[],a=0,l=0,h=!1,g=function(){h&&!u.length&&!a&&t.complete()},f=function(d){return a<r?y(d):u.push(d)},y=function(d){a++;var E=!1;x(e(d,l++)).subscribe(A(t,function(I){t.next(I)},function(){E=!0},void 0,function(){if(E)try{a--;for(var I=function(){var C=u.shift();o||y(C)};u.length&&a<r;)I();g()}catch(C){t.error(C)}}))};return n.subscribe(A(t,f,function(){h=!0,g()})),function(){}}function F(n,t,e){return e===void 0&&(e=1/0),v(t)?F(function(r,i){return xe(function(s,o){return t(r,s,i,o)})(x(n(r,i)))},e):(typeof t=="number"&&(e=t),_(function(r,i){return bn(r,i,n,e)}))}function Te(n,t,e){n===void 0&&(n=0),e===void 0&&(e=ze);var r=-1;return t!=null&&(de(t)?e=t:r=t),new w(function(i){var s=pn(n)?+n-e.now():n;s<0&&(s=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},s)})}function mn(n,t){return v(t)?F(n,t,1):F(n,1)}function gn(n){return n<=0?function(){return Je}:_(function(t,e){var r=0;t.subscribe(A(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function wn(n){return xe(function(){return n})}function Sn(n,t){return F(function(e,r){return x(n(e,r)).pipe(gn(1),wn(e))})}function En(n,t){t===void 0&&(t=le);var e=Te(n,t);return Sn(function(){return e})}function _e(n){var t;t={count:n};var e=t.count,r=e===void 0?1/0:e,i=t.delay,s=t.resetOnSuccess,o=s===void 0?!1:s;return r<=0?se:_(function(c,u){var a=0,l,h=function(){var g=!1;l=c.subscribe(A(u,function(f){o&&(a=0),u.next(f)},void 0,function(f){if(a++<r){var y=function(){l?(l.unsubscribe(),l=null,h()):g=!0};if(i!=null){var d=typeof i=="number"?Te(i):x(i(f,a)),E=A(u,function(){E.unsubscribe(),y()},function(){u.complete()});d.subscribe(E)}else y()}else u.error(f)})),g&&(l.unsubscribe(),l=null,h())};h()})}function Me(n){return _(function(t,e){x(n).subscribe(A(e,function(){return e.complete()},V)),!e.closed&&t.subscribe(e)})}async function In(n,t){const e=n.getReader();let r;for(;!(r=await e.read()).done;)t(r.value)}function On(n){let t,e,r,i=!1;return function(o){t===void 0?(t=o,e=0,r=-1):t=xn(t,o);const c=t.length;let u=0;for(;e<c;){i&&(t[e]===10&&(u=++e),i=!1);let a=-1;for(;e<c&&a===-1;++e)switch(t[e]){case 58:r===-1&&(r=e-u);break;case 13:i=!0;case 10:a=e;break}if(a===-1)break;n(t.subarray(u,a),r),u=e,r=-1}u===c?t=void 0:u!==0&&(t=t.subarray(u),e-=u)}}function An(n,t,e){let r=Ce();const i=new TextDecoder;return function(o,c){if(o.length===0)e==null||e(r),r=Ce();else if(c>0){const u=i.decode(o.subarray(0,c)),a=c+(o[c+1]===32?2:1),l=i.decode(o.subarray(a));switch(u){case"data":r.data=r.data?r.data+`
4
- `+l:l;break;case"event":r.event=l;break;case"id":n(r.id=l);break;case"retry":const h=parseInt(l,10);isNaN(h)||t(r.retry=h);break}}}}function xn(n,t){const e=new Uint8Array(n.length+t.length);return e.set(n),e.set(t,n.length),e}function Ce(){return{data:"",event:"",id:"",retry:void 0}}var Tn=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]]);return e};const W="text/event-stream",_n=1e3,Pe="last-event-id";function Mn(n,t){var{signal:e,headers:r,onopen:i,onmessage:s,onclose:o,onerror:c,openWhenHidden:u,fetch:a}=t,l=Tn(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((h,g)=>{const f=Object.assign({},r);f.accept||(f.accept=W);let y;function d(){y.abort(),document.hidden||X()}u||document.addEventListener("visibilitychange",d);let E=_n,I=0;function C(){document.removeEventListener("visibilitychange",d),window.clearTimeout(I),y.abort()}e==null||e.addEventListener("abort",()=>{C(),h()});const Dn=a??window.fetch,kn=i??Cn;async function X(){var z;y=new AbortController;try{const K=await Dn(n,Object.assign(Object.assign({},l),{headers:f,signal:y.signal}));await kn(K),await In(K.body,On(An(T=>{T?f[Pe]=T:delete f[Pe]},T=>{E=T},s))),o==null||o(),C(),h()}catch(K){if(!y.signal.aborted)try{const T=(z=c==null?void 0:c(K))!==null&&z!==void 0?z:E;window.clearTimeout(I),I=window.setTimeout(X,T)}catch(T){C(),g(T)}}}X()})}function Cn(n){const t=n.headers.get("content-type");if(!(t!=null&&t.startsWith(W)))throw new Error(`Expected content-type to be ${W}, Actual: ${t}`)}function De(n){const{endpoint:t,apiKey:e,payload:r}=n;return new w(i=>{const s=new AbortController;return Mn(t,{method:"POST",headers:{"X-API-KEY":e,"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0,signal:s.signal,onopen:async o=>{o.ok||(i.error(o),s.abort())},onmessage:o=>{i.next(JSON.parse(o.data))},onclose:()=>{i.complete()},onerror:o=>{throw i.error(o),s.abort(),o}}),()=>{s.abort()}})}class Pn{constructor(t){P(this,"isConnecting",!1);P(this,"apiKey");P(this,"endpoint");P(this,"destroy$",new ue);if(!t.apiKey)throw new Error("apiKey must be required");if(!t.endpoint)throw new Error("botProviderName must be required");this.apiKey=t.apiKey,this.endpoint=t.endpoint}setChannel(t,e){var r;(r=e==null?void 0:e.onSseStart)==null||r.call(e),this.isConnecting=!0,De({apiKey:this.apiKey,endpoint:this.endpoint,payload:{action:b.RESET_CHANNEL,customChannelId:t.customChannelId,customMessageId:t==null?void 0:t.customMessageId,text:""}}).pipe(Me(this.destroy$),_e(3)).subscribe({next:i=>{var s;(s=e==null?void 0:e.onSseMessage)==null||s.call(e,i)},error:i=>{var s;(s=e==null?void 0:e.onSseError)==null||s.call(e,i),this.isConnecting=!1},complete:()=>{var i;(i=e==null?void 0:e.onSseCompleted)==null||i.call(e),this.isConnecting=!1}})}sendMessage(t,e){var r;this.isConnecting=!0,(r=e==null?void 0:e.onSseStart)==null||r.call(e),De({apiKey:this.apiKey,endpoint:this.endpoint,payload:{action:b.NONE,customChannelId:t.customChannelId,customMessageId:t==null?void 0:t.customMessageId,text:t.text}}).pipe(mn(i=>vn(i).pipe(En((e==null?void 0:e.delayTime)??50))),Me(this.destroy$),_e(3)).subscribe({next:i=>{var s;(s=e==null?void 0:e.onSseMessage)==null||s.call(e,i)},error:i=>{var s;(s=e==null?void 0:e.onSseError)==null||s.call(e,i),this.isConnecting=!1},complete:()=>{var i;(i=e==null?void 0:e.onSseCompleted)==null||i.call(e),this.isConnecting=!1}})}close(){this.isConnecting=!1,this.destroy$.next(),this.destroy$.complete()}}class S{constructor({messages:t,typingMessages:e}){P(this,"messages");P(this,"typingMessages",null);this.messages=t,this.typingMessages=e}resetConversation(){return new S({messages:null,typingMessages:null})}pushMessage(t,e){const r=new Map(t.messages);return r.set(e.messageId,e),new S({messages:r,typingMessages:t.typingMessages})}onMessage(t,e,r){const i=(r==null?void 0:r.showDebugMessage)??!1;switch(e.eventType){case m.MESSAGE_START:return t.onMessageStart(t,e,{showDebugMessage:i});case m.MESSAGE_DELTA:return t.onMessageDelta(t,e,{showDebugMessage:i});case m.MESSAGE_COMPLETE:return t.onMessageComplete(t,e,{showDebugMessage:i});case m.DONE:return t.onMessageDone(t);default:return t}}onMessageStart(t,e,r){const i=e.fact.messageStart.message,s=new Map(t.typingMessages);return i.isDebug&&!r.showDebugMessage||s!=null&&s.has(i.messageId)?new S({messages:t.messages,typingMessages:s}):(s.set(i.messageId,{type:"bot",eventType:m.MESSAGE_START,isTyping:!0,typingText:"",messageId:i.messageId,message:i,time:new Date}),new S({messages:t.messages,typingMessages:s}))}onMessageDelta(t,e,r){const i=e.fact.messageDelta.message,s=new Map(t.messages),o=new Map(t.typingMessages),c=o.get(i.messageId);if(i.isDebug&&!r.showDebugMessage||s.has(i.messageId)||(c==null?void 0:c.eventType)===m.MESSAGE_COMPLETE)return new S({messages:t.messages,typingMessages:o});const u=`${(c==null?void 0:c.typingText)??""}${i.text}`;return o.set(i.messageId,{type:"bot",eventType:m.MESSAGE_DELTA,isTyping:!0,typingText:u,messageId:i.messageId,message:i,time:new Date}),new S({messages:t.messages,typingMessages:o})}onMessageComplete(t,e,r){const i=e.fact.messageComplete.message,s=new Map(t.messages),o=new Map(t.typingMessages);return i.isDebug&&!r.showDebugMessage?new S({messages:s,typingMessages:o}):(s.set(i.messageId,{type:"bot",eventType:m.MESSAGE_COMPLETE,isTyping:!1,typingText:null,messageId:i.messageId,message:i,time:new Date}),o.delete(i.messageId),new S({messages:s,typingMessages:o}))}onMessageDone(t){const e=new Map(t.messages),r=new Map(t.typingMessages);return r.forEach((i,s)=>{i.eventType===m.MESSAGE_COMPLETE&&(e.set(i.messageId,i),r.delete(s))}),new S({messages:t.messages,typingMessages:r})}}p.AsgardServiceClient=Pn,p.Conversation=S,p.EventType=m,p.FetchSseAction=b,p.MessageTemplateType=J,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
3
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function N(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var j=function(){function t(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var n,e,r,i,u;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var s=D(o),c=s.next();!c.done;c=s.next()){var a=c.value;a.remove(this)}}catch(d){n={error:d}}finally{try{c&&!c.done&&(e=s.return)&&e.call(s)}finally{if(n)throw n.error}}else o.remove(this);var l=this.initialTeardown;if(v(l))try{l()}catch(d){u=d instanceof H?d.errors:[d]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var m=D(h),f=m.next();!f.done;f=m.next()){var y=f.value;try{re(y)}catch(d){u=u??[],d instanceof H?u=U(U([],L(u)),L(d.errors)):u.push(d)}}}catch(d){r={error:d}}finally{try{f&&!f.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}}if(u)throw new H(u)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)re(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(n)}},t.prototype._hasParent=function(n){var e=this._parentage;return e===n||Array.isArray(e)&&e.includes(n)},t.prototype._addParent=function(n){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(n),e):e?[e,n]:n},t.prototype._removeParent=function(n){var e=this._parentage;e===n?this._parentage=null:Array.isArray(e)&&N(e,n)},t.prototype.remove=function(n){var e=this._finalizers;e&&N(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=function(){var n=new t;return n.closed=!0,n}(),t}(),te=j.EMPTY;function ne(t){return t instanceof j||t&&"closed"in t&&v(t.remove)&&v(t.add)&&v(t.unsubscribe)}function re(t){v(t)?t():t.unsubscribe()}var Ne={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ie={setTimeout:function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,U([t,n],L(e)))},clearTimeout:function(t){var n=ie.delegate;return((n==null?void 0:n.clearTimeout)||clearTimeout)(t)},delegate:void 0};function ue(t){ie.setTimeout(function(){throw t})}function V(){}function R(t){t()}var q=function(t){I(n,t);function n(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,ne(e)&&e.add(r)):r.destination=Ge,r}return n.create=function(e,r,i){return new B(e,r,i)},n.prototype.next=function(e){this.isStopped||this._next(e)},n.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},n.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},n.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},n.prototype._next=function(e){this.destination.next(e)},n.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},n.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},n}(j),Re=function(){function t(n){this.partialObserver=n}return t.prototype.next=function(n){var e=this.partialObserver;if(e.next)try{e.next(n)}catch(r){$(r)}},t.prototype.error=function(n){var e=this.partialObserver;if(e.error)try{e.error(n)}catch(r){$(r)}else $(n)},t.prototype.complete=function(){var n=this.partialObserver;if(n.complete)try{n.complete()}catch(e){$(e)}},t}(),B=function(t){I(n,t);function n(e,r,i){var u=t.call(this)||this,o;return v(e)||!e?o={next:e??void 0,error:r??void 0,complete:i??void 0}:o=e,u.destination=new Re(o),u}return n}(q);function $(t){ue(t)}function $e(t){throw t}var Ge={closed:!0,next:V,error:$e,complete:V},Y=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function oe(t){return t}function Fe(t){return t.length===0?oe:t.length===1?t[0]:function(e){return t.reduce(function(r,i){return i(r)},e)}}var w=function(){function t(n){n&&(this._subscribe=n)}return t.prototype.lift=function(n){var e=new t;return e.source=this,e.operator=n,e},t.prototype.subscribe=function(n,e,r){var i=this,u=He(n)?n:new B(n,e,r);return R(function(){var o=i,s=o.operator,c=o.source;u.add(s?s.call(u,c):c?i._subscribe(u):i._trySubscribe(u))}),u},t.prototype._trySubscribe=function(n){try{return this._subscribe(n)}catch(e){n.error(e)}},t.prototype.forEach=function(n,e){var r=this;return e=se(e),new e(function(i,u){var o=new B({next:function(s){try{n(s)}catch(c){u(c),o.unsubscribe()}},error:u,complete:i});r.subscribe(o)})},t.prototype._subscribe=function(n){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(n)},t.prototype[Y]=function(){return this},t.prototype.pipe=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return Fe(n)(this)},t.prototype.toPromise=function(n){var e=this;return n=se(n),new n(function(r,i){var u;e.subscribe(function(o){return u=o},function(o){return i(o)},function(){return r(u)})})},t.create=function(n){return new t(n)},t}();function se(t){var n;return(n=t??Ne.Promise)!==null&&n!==void 0?n:Promise}function Ke(t){return t&&v(t.next)&&v(t.error)&&v(t.complete)}function He(t){return t&&t instanceof q||Ke(t)&&ne(t)}function Ve(t){return v(t==null?void 0:t.lift)}function C(t){return function(n){if(Ve(n))return n.lift(function(e){try{return t(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function A(t,n,e,r,i){return new qe(t,n,e,r,i)}var qe=function(t){I(n,t);function n(e,r,i,u,o,s){var c=t.call(this,e)||this;return c.onFinalize=o,c.shouldUnsubscribe=s,c._next=r?function(a){try{r(a)}catch(l){e.error(l)}}:t.prototype._next,c._error=u?function(a){try{u(a)}catch(l){e.error(l)}finally{this.unsubscribe()}}:t.prototype._error,c._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:t.prototype._complete,c}return n.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},n}(q),Be=ee(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),W=function(t){I(n,t);function n(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return n.prototype.lift=function(e){var r=new ae(this,this);return r.operator=e,r},n.prototype._throwIfClosed=function(){if(this.closed)throw new Be},n.prototype.next=function(e){var r=this;R(function(){var i,u;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=D(r.currentObservers),s=o.next();!s.done;s=o.next()){var c=s.value;c.next(e)}}catch(a){i={error:a}}finally{try{s&&!s.done&&(u=o.return)&&u.call(o)}finally{if(i)throw i.error}}}})},n.prototype.error=function(e){var r=this;R(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var i=r.observers;i.length;)i.shift().error(e)}})},n.prototype.complete=function(){var e=this;R(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},n.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(n.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),n.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},n.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},n.prototype._innerSubscribe=function(e){var r=this,i=this,u=i.hasError,o=i.isStopped,s=i.observers;return u||o?te:(this.currentObservers=null,s.push(e),new j(function(){r.currentObservers=null,N(s,e)}))},n.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,u=r.thrownError,o=r.isStopped;i?e.error(u):o&&e.complete()},n.prototype.asObservable=function(){var e=new w;return e.source=this,e},n.create=function(e,r){return new ae(e,r)},n}(w),ae=function(t){I(n,t);function n(e,r){var i=t.call(this)||this;return i.destination=e,i.source=r,i}return n.prototype.next=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,e)},n.prototype.error=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,e)},n.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},n.prototype._subscribe=function(e){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&i!==void 0?i:te},n}(W),ce=function(t){I(n,t);function n(e){var r=t.call(this)||this;return r._value=e,r}return Object.defineProperty(n.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),n.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},n.prototype.getValue=function(){var e=this,r=e.hasError,i=e.thrownError,u=e._value;if(r)throw i;return this._throwIfClosed(),u},n.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},n}(W),Ye={now:function(){return Date.now()},delegate:void 0},We=function(t){I(n,t);function n(e,r){return t.call(this)||this}return n.prototype.schedule=function(e,r){return this},n}(j),fe={setInterval:function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,U([t,n],L(e)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},Xe=function(t){I(n,t);function n(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return n.prototype.schedule=function(e,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var u=this.id,o=this.scheduler;return u!=null&&(this.id=this.recycleAsyncId(o,u,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},n.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),fe.setInterval(e.flush.bind(e,this),i)},n.prototype.recycleAsyncId=function(e,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&fe.clearInterval(r)},n.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},n.prototype._execute=function(e,r){var i=!1,u;try{this.work(e)}catch(o){i=!0,u=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),u},n.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,u=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,N(u,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},n}(We),le=function(){function t(n,e){e===void 0&&(e=t.now),this.schedulerActionCtor=n,this.now=e}return t.prototype.schedule=function(n,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,n).schedule(r,e)},t.now=Ye.now,t}(),ze=function(t){I(n,t);function n(e,r){r===void 0&&(r=le.now);var i=t.call(this,e,r)||this;return i.actions=[],i._active=!1,i}return n.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,i){for(;e=r.shift();)e.unsubscribe();throw i}},n}(le),de=new ze(Xe),Je=de,Qe=new w(function(t){return t.complete()});function he(t){return t&&v(t.schedule)}function Ze(t){return t[t.length-1]}function et(t){return he(Ze(t))?t.pop():void 0}var ye=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function ve(t){return v(t==null?void 0:t.then)}function pe(t){return v(t[Y])}function be(t){return Symbol.asyncIterator&&v(t==null?void 0:t[Symbol.asyncIterator])}function me(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 tt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ge=tt();function we(t){return v(t==null?void 0:t[ge])}function Se(t){return Le(this,arguments,function(){var e,r,i,u;return Z(this,function(o){switch(o.label){case 0:e=t.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,k(e.read())];case 3:return r=o.sent(),i=r.value,u=r.done,u?[4,k(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,k(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Ee(t){return v(t==null?void 0:t.getReader)}function _(t){if(t instanceof w)return t;if(t!=null){if(pe(t))return nt(t);if(ye(t))return rt(t);if(ve(t))return it(t);if(be(t))return Ie(t);if(we(t))return ut(t);if(Ee(t))return ot(t)}throw me(t)}function nt(t){return new w(function(n){var e=t[Y]();if(v(e.subscribe))return e.subscribe(n);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function rt(t){return new w(function(n){for(var e=0;e<t.length&&!n.closed;e++)n.next(t[e]);n.complete()})}function it(t){return new w(function(n){t.then(function(e){n.closed||(n.next(e),n.complete())},function(e){return n.error(e)}).then(null,ue)})}function ut(t){return new w(function(n){var e,r;try{for(var i=D(t),u=i.next();!u.done;u=i.next()){var o=u.value;if(n.next(o),n.closed)return}}catch(s){e={error:s}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}n.complete()})}function Ie(t){return new w(function(n){st(t,n).catch(function(e){return n.error(e)})})}function ot(t){return Ie(Se(t))}function st(t,n){var e,r,i,u;return je(this,void 0,void 0,function(){var o,s;return Z(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),e=Ue(t),c.label=1;case 1:return[4,e.next()];case 2:if(r=c.sent(),!!r.done)return[3,4];if(o=r.value,n.next(o),n.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=c.sent(),i={error:s},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(u=e.return)?[4,u.call(e)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return n.complete(),[2]}})})}function P(t,n,e,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var u=n.schedule(function(){e(),i?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(u),!i)return u}function xe(t,n){return n===void 0&&(n=0),C(function(e,r){e.subscribe(A(r,function(i){return P(r,t,function(){return r.next(i)},n)},function(){return P(r,t,function(){return r.complete()},n)},function(i){return P(r,t,function(){return r.error(i)},n)}))})}function Oe(t,n){return n===void 0&&(n=0),C(function(e,r){r.add(t.schedule(function(){return e.subscribe(r)},n))})}function at(t,n){return _(t).pipe(Oe(n),xe(n))}function ct(t,n){return _(t).pipe(Oe(n),xe(n))}function ft(t,n){return new w(function(e){var r=0;return n.schedule(function(){r===t.length?e.complete():(e.next(t[r++]),e.closed||this.schedule())})})}function lt(t,n){return new w(function(e){var r;return P(e,n,function(){r=t[ge](),P(e,n,function(){var i,u,o;try{i=r.next(),u=i.value,o=i.done}catch(s){e.error(s);return}o?e.complete():e.next(u)},0,!0)}),function(){return v(r==null?void 0:r.return)&&r.return()}})}function Ae(t,n){if(!t)throw new Error("Iterable cannot be null");return new w(function(e){P(e,n,function(){var r=t[Symbol.asyncIterator]();P(e,n,function(){r.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function dt(t,n){return Ae(Se(t),n)}function ht(t,n){if(t!=null){if(pe(t))return at(t,n);if(ye(t))return ft(t,n);if(ve(t))return ct(t,n);if(be(t))return Ae(t,n);if(we(t))return lt(t,n);if(Ee(t))return dt(t,n)}throw me(t)}function yt(t,n){return n?ht(t,n):_(t)}function vt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=et(t);return yt(t,e)}function pt(t){return t instanceof Date&&!isNaN(t)}function _e(t,n){return C(function(e,r){var i=0;e.subscribe(A(r,function(u){r.next(t.call(n,u,i++))}))})}function bt(t,n,e,r,i,u,o,s){var c=[],a=0,l=0,h=!1,m=function(){h&&!c.length&&!a&&n.complete()},f=function(d){return a<r?y(d):c.push(d)},y=function(d){a++;var E=!1;_(e(d,l++)).subscribe(A(n,function(O){n.next(O)},function(){E=!0},void 0,function(){if(E)try{a--;for(var O=function(){var M=c.shift();o||y(M)};c.length&&a<r;)O();m()}catch(M){n.error(M)}}))};return t.subscribe(A(n,f,function(){h=!0,m()})),function(){}}function G(t,n,e){return e===void 0&&(e=1/0),v(n)?G(function(r,i){return _e(function(u,o){return n(r,u,i,o)})(_(t(r,i)))},e):(typeof n=="number"&&(e=n),C(function(r,i){return bt(r,i,t,e)}))}function Te(t,n,e){t===void 0&&(t=0),e===void 0&&(e=Je);var r=-1;return n!=null&&(he(n)?e=n:r=n),new w(function(i){var u=pt(t)?+t-e.now():t;u<0&&(u=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},u)})}function mt(t,n){return v(n)?G(t,n,1):G(t,1)}function gt(t){return t<=0?function(){return Qe}:C(function(n,e){var r=0;n.subscribe(A(e,function(i){++r<=t&&(e.next(i),t<=r&&e.complete())}))})}function wt(t){return _e(function(){return t})}function St(t,n){return G(function(e,r){return _(t(e,r)).pipe(gt(1),wt(e))})}function Et(t,n){n===void 0&&(n=de);var e=Te(t,n);return St(function(){return e})}function Ce(t){var n;n={count:t};var e=n.count,r=e===void 0?1/0:e,i=n.delay,u=n.resetOnSuccess,o=u===void 0?!1:u;return r<=0?oe:C(function(s,c){var a=0,l,h=function(){var m=!1;l=s.subscribe(A(c,function(f){o&&(a=0),c.next(f)},void 0,function(f){if(a++<r){var y=function(){l?(l.unsubscribe(),l=null,h()):m=!0};if(i!=null){var d=typeof i=="number"?Te(i):_(i(f,a)),E=A(c,function(){E.unsubscribe(),y()},function(){c.complete()});d.subscribe(E)}else y()}else c.error(f)})),m&&(l.unsubscribe(),l=null,h())};h()})}function Pe(t){return C(function(n,e){_(t).subscribe(A(e,function(){return e.complete()},V)),!e.closed&&n.subscribe(e)})}async function It(t,n){const e=t.getReader();let r;for(;!(r=await e.read()).done;)n(r.value)}function xt(t){let n,e,r,i=!1;return function(o){n===void 0?(n=o,e=0,r=-1):n=At(n,o);const s=n.length;let c=0;for(;e<s;){i&&(n[e]===10&&(c=++e),i=!1);let a=-1;for(;e<s&&a===-1;++e)switch(n[e]){case 58:r===-1&&(r=e-c);break;case 13:i=!0;case 10:a=e;break}if(a===-1)break;t(n.subarray(c,a),r),c=e,r=-1}c===s?n=void 0:c!==0&&(n=n.subarray(c),e-=c)}}function Ot(t,n,e){let r=Me();const i=new TextDecoder;return function(o,s){if(o.length===0)e==null||e(r),r=Me();else if(s>0){const c=i.decode(o.subarray(0,s)),a=s+(o[s+1]===32?2:1),l=i.decode(o.subarray(a));switch(c){case"data":r.data=r.data?r.data+`
4
+ `+l:l;break;case"event":r.event=l;break;case"id":t(r.id=l);break;case"retry":const h=parseInt(l,10);isNaN(h)||n(r.retry=h);break}}}}function At(t,n){const e=new Uint8Array(t.length+n.length);return e.set(t),e.set(n,t.length),e}function Me(){return{data:"",event:"",id:"",retry:void 0}}var _t=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(e[r[i]]=t[r[i]]);return e};const X="text/event-stream",Tt=1e3,De="last-event-id";function Ct(t,n){var{signal:e,headers:r,onopen:i,onmessage:u,onclose:o,onerror:s,openWhenHidden:c,fetch:a}=n,l=_t(n,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((h,m)=>{const f=Object.assign({},r);f.accept||(f.accept=X);let y;function d(){y.abort(),document.hidden||z()}c||document.addEventListener("visibilitychange",d);let E=Tt,O=0;function M(){document.removeEventListener("visibilitychange",d),window.clearTimeout(O),y.abort()}e==null||e.addEventListener("abort",()=>{M(),h()});const kt=a??window.fetch,jt=i??Pt;async function z(){var J;y=new AbortController;try{const F=await kt(t,Object.assign(Object.assign({},l),{headers:f,signal:y.signal}));await jt(F),await It(F.body,xt(Ot(T=>{T?f[De]=T:delete f[De]},T=>{E=T},u))),o==null||o(),M(),h()}catch(F){if(!y.signal.aborted)try{const T=(J=s==null?void 0:s(F))!==null&&J!==void 0?J:E;window.clearTimeout(O),O=window.setTimeout(z,T)}catch(T){M(),m(T)}}}z()})}function Pt(t){const n=t.headers.get("content-type");if(!(n!=null&&n.startsWith(X)))throw new Error(`Expected content-type to be ${X}, Actual: ${n}`)}function ke(t){const{endpoint:n,apiKey:e,payload:r}=t;return new w(i=>{const u=new AbortController;return Ct(n,{method:"POST",headers:{"X-API-KEY":e,"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0,signal:u.signal,onopen:async o=>{o.ok||(i.error(o),u.abort())},onmessage:o=>{i.next(JSON.parse(o.data))},onclose:()=>{i.complete()},onerror:o=>{throw i.error(o),u.abort(),o}}),()=>{u.abort()}})}class Mt{constructor(n){S(this,"apiKey");S(this,"endpoint");S(this,"destroy$",new W);S(this,"transformSsePayload");if(!n.apiKey)throw new Error("apiKey must be required");if(!n.endpoint)throw new Error("endpoint must be required");this.apiKey=n.apiKey,this.endpoint=n.endpoint,this.transformSsePayload=n.transformSsePayload}resetChannel(n,e){var i,u;(i=e==null?void 0:e.onSseStart)==null||i.call(e);const r={action:b.RESET_CHANNEL,customChannelId:n.customChannelId,customMessageId:n==null?void 0:n.customMessageId,text:""};ke({apiKey:this.apiKey,endpoint:this.endpoint,payload:((u=this.transformSsePayload)==null?void 0:u.call(this,r))??r}).pipe(Pe(this.destroy$),Ce(3)).subscribe({next:o=>{var s;(s=e==null?void 0:e.onSseMessage)==null||s.call(e,o)},error:o=>{var s;(s=e==null?void 0:e.onSseError)==null||s.call(e,o)},complete:()=>{var o;(o=e==null?void 0:e.onSseCompleted)==null||o.call(e)}})}sendMessage(n,e){var i,u;(i=e==null?void 0:e.onSseStart)==null||i.call(e);const r={action:b.NONE,customChannelId:n.customChannelId,customMessageId:n==null?void 0:n.customMessageId,text:n.text};ke({apiKey:this.apiKey,endpoint:this.endpoint,payload:((u=this.transformSsePayload)==null?void 0:u.call(this,r))??r}).pipe(mt(o=>vt(o).pipe(Et((e==null?void 0:e.delayTime)??50))),Pe(this.destroy$),Ce(3)).subscribe({next:o=>{var s;(s=e==null?void 0:e.onSseMessage)==null||s.call(e,o)},error:o=>{var s;(s=e==null?void 0:e.onSseError)==null||s.call(e,o)},complete:()=>{var o;(o=e==null?void 0:e.onSseCompleted)==null||o.call(e)}})}close(){this.destroy$.next(),this.destroy$.complete()}}class Dt{constructor(n){S(this,"client");S(this,"isConnecting$");S(this,"conversation$");S(this,"customChannelId");if(!n.client)throw new Error("client must be required");if(!n.customChannelId)throw new Error("customChannelId must be required");this.client=n.client,this.customChannelId=n.customChannelId,this.isConnecting$=new ce(!1),this.conversation$=new ce(n.conversation)}sendMessage(n,e){this.isConnecting$.next(!0);const r=n.customMessageId??crypto.randomUUID();this.conversation$.next(this.conversation$.value.pushMessage({type:"user",messageId:r,text:n.text,time:new Date})),this.client.sendMessage({customChannelId:this.customChannelId,customMessageId:r,text:n.text},{onSseStart:e==null?void 0:e.onSseStart,onSseMessage:i=>{var u;(u=e==null?void 0:e.onSseMessage)==null||u.call(e,i),this.conversation$.next(this.conversation$.value.onMessage(i))},onSseError:i=>{var u;(u=e==null?void 0:e.onSseError)==null||u.call(e,i),this.isConnecting$.next(!1)},onSseCompleted:()=>{var i;(i=e==null?void 0:e.onSseCompleted)==null||i.call(e),this.isConnecting$.next(!1)}})}close(){this.isConnecting$.complete(),this.conversation$.complete()}}class x{constructor({messages:n,showDebugMessage:e}){S(this,"showDebugMessage",!1);S(this,"messages",null);this.messages=n,this.showDebugMessage=e??!1}pushMessage(n){const e=new Map(this.messages);return e.set(n.messageId,n),new x({messages:e})}onMessage(n){switch(n.eventType){case g.MESSAGE_START:return this.onMessageStart(n);case g.MESSAGE_DELTA:return this.onMessageDelta(n);case g.MESSAGE_COMPLETE:return this.onMessageComplete(n);default:return this}}onMessageStart(n){const e=n.fact.messageStart.message,r=new Map(this.messages);return e.isDebug&&!this.showDebugMessage||r!=null&&r.has(e.messageId)?new x({messages:r}):(r.set(e.messageId,{type:"bot",eventType:g.MESSAGE_START,isTyping:!0,typingText:"",messageId:e.messageId,message:e,time:new Date}),new x({messages:r}))}onMessageDelta(n){const e=n.fact.messageDelta.message,r=new Map(this.messages),i=r.get(e.messageId);if((i==null?void 0:i.type)==="user")return this;if(e.isDebug&&!this.showDebugMessage||(i==null?void 0:i.eventType)===g.MESSAGE_COMPLETE)return new x({messages:r});const u=`${(i==null?void 0:i.typingText)??""}${e.text}`;return r.set(e.messageId,{type:"bot",eventType:g.MESSAGE_DELTA,isTyping:!0,typingText:u,messageId:e.messageId,message:e,time:new Date}),new x({messages:r})}onMessageComplete(n){const e=n.fact.messageComplete.message,r=new Map(this.messages);return e.isDebug&&!this.showDebugMessage?new x({messages:r}):(r.set(e.messageId,{type:"bot",eventType:g.MESSAGE_COMPLETE,isTyping:!1,typingText:null,messageId:e.messageId,message:e,time:new Date}),new x({messages:r}))}}p.AsgardServiceClient=Mt,p.Channel=Dt,p.Conversation=x,p.EventType=g,p.FetchSseAction=b,p.MessageTemplateType=Q,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
5
5
  //# sourceMappingURL=index.js.map