@telia-ace/widget-conversation-flamingo 1.1.24-rc.0 → 1.1.24-rc.1
Sign up to get free protection for your applications and to get access to all the features.
- package/{conversation-177be0b6.js → conversation-14f46dc9.js} +5 -5
- package/{conversation-58dc8b79.mjs → conversation-9e21a86a.mjs} +5 -5
- package/{index-20137b10.mjs → index-617ed5e3.mjs} +1 -1
- package/{index-f0a912bc.js → index-9cf31c1f.js} +1 -1
- package/{index-a8d136d9.js → index-c2da390d.js} +1 -1
- package/{index-9e3fb603.mjs → index-e7f4cf90.mjs} +2 -2
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +2 -2
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";const wt=require("./index-
|
1
|
+
"use strict";const wt=require("./index-9cf31c1f.js");/**
|
2
2
|
* @license
|
3
3
|
* Copyright 2019 Google LLC
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -48,7 +48,7 @@
|
|
48
48
|
* @license
|
49
49
|
* Copyright 2018 Google LLC
|
50
50
|
* SPDX-License-Identifier: BSD-3-Clause
|
51
|
-
*/const Wt=bt(class extends Ft{constructor(e){var t;if(super(e),e.type!==yt.ATTRIBUTE||e.name!=="class"||((t=e.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){var i,n;if(this.it===void 0){this.it=new Set,e.strings!==void 0&&(this.st=new Set(e.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in t)t[r]&&!((i=this.st)!=null&&i.has(r))&&this.it.add(r);return this.render(t)}const s=e.element.classList;for(const r of this.it)r in t||(s.remove(r),this.it.delete(r));for(const r in t){const o=!!t[r];o===this.it.has(r)||(n=this.st)!=null&&n.has(r)||(o?(s.add(r),this.it.add(r)):(s.remove(r),this.it.delete(r)))}return C}}),it=(e,t,s)=>{e&&s.style.setProperty(t,e)},ts=(e,t)=>{var s,i,n,r;it((s=e.colors)==null?void 0:s.primaryBackground,"--primary-background",t),it((i=e.colors)==null?void 0:i.textOnPrimaryBackground,"--text-on-primary-background",t),it((n=e.colors)==null?void 0:n.secondaryBackground,"--secondary-background",t),it((r=e.colors)==null?void 0:r.textOnSecondaryBackground,"--text-on-secondary-background",t)};var Pi=Object.defineProperty,Li=Object.getOwnPropertyDescriptor,_t=(e,t,s,i)=>{for(var n=i>1?void 0:i?Li(t,s):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(n=(i?o(t,s,n):o(n))||n);return i&&n&&Pi(t,s,n),n};class U extends m{constructor(){super(...arguments),this.active=!1,this.loaded=!1}async connectedCallback(){super.connectedCallback(),this.icon=await this._renderSymbol(),this.loaded=!0,this._applyBranding()}_toggleActive(){var t;if(!((t=this.application)!=null&&t.root)){console.warn("Could not activate widget. No root element assigned to widget.");return}this.active=!this.active,this.active?this.application.appendToDOM():this.application.hide()}_applyBranding(){var t;(t=this.application)!=null&&t.settings&&ts(this.application.settings.branding,this)}async _renderSymbol(){var a,l,c;const t=(a=this.application)==null?void 0:a.branding(),s=(l=t==null?void 0:t.graphics)==null?void 0:l.trigger;if(s)return g` <img src=${s} class="trigger-icon" alt="" /> `;const i=(c=this.application)==null?void 0:c.triggerIcon;if(!i)return u;const n=async d=>await Promise.resolve().then(()=>require("./index-
|
51
|
+
*/const Wt=bt(class extends Ft{constructor(e){var t;if(super(e),e.type!==yt.ATTRIBUTE||e.name!=="class"||((t=e.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){var i,n;if(this.it===void 0){this.it=new Set,e.strings!==void 0&&(this.st=new Set(e.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in t)t[r]&&!((i=this.st)!=null&&i.has(r))&&this.it.add(r);return this.render(t)}const s=e.element.classList;for(const r of this.it)r in t||(s.remove(r),this.it.delete(r));for(const r in t){const o=!!t[r];o===this.it.has(r)||(n=this.st)!=null&&n.has(r)||(o?(s.add(r),this.it.add(r)):(s.remove(r),this.it.delete(r)))}return C}}),it=(e,t,s)=>{e&&s.style.setProperty(t,e)},ts=(e,t)=>{var s,i,n,r;it((s=e.colors)==null?void 0:s.primaryBackground,"--primary-background",t),it((i=e.colors)==null?void 0:i.textOnPrimaryBackground,"--text-on-primary-background",t),it((n=e.colors)==null?void 0:n.secondaryBackground,"--secondary-background",t),it((r=e.colors)==null?void 0:r.textOnSecondaryBackground,"--text-on-secondary-background",t)};var Pi=Object.defineProperty,Li=Object.getOwnPropertyDescriptor,_t=(e,t,s,i)=>{for(var n=i>1?void 0:i?Li(t,s):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(n=(i?o(t,s,n):o(n))||n);return i&&n&&Pi(t,s,n),n};class U extends m{constructor(){super(...arguments),this.active=!1,this.loaded=!1}async connectedCallback(){super.connectedCallback(),this.icon=await this._renderSymbol(),this.loaded=!0,this._applyBranding()}_toggleActive(){var t;if(!((t=this.application)!=null&&t.root)){console.warn("Could not activate widget. No root element assigned to widget.");return}this.active=!this.active,this.active?this.application.appendToDOM():this.application.hide()}_applyBranding(){var t;(t=this.application)!=null&&t.settings&&ts(this.application.settings.branding,this)}async _renderSymbol(){var a,l,c;const t=(a=this.application)==null?void 0:a.branding(),s=(l=t==null?void 0:t.graphics)==null?void 0:l.trigger;if(s)return g` <img src=${s} class="trigger-icon" alt="" /> `;const i=(c=this.application)==null?void 0:c.triggerIcon;if(!i)return u;const n=async d=>await Promise.resolve().then(()=>require("./index-c2da390d.js")).then(p=>p[d]),{type:r,content:o}=i;switch(r){case"Telia":{const d=await n(o);return d?g`<telia-icon
|
52
52
|
class="trigger-icon"
|
53
53
|
svg=${d.svg}
|
54
54
|
size="lg"
|
@@ -351,7 +351,7 @@
|
|
351
351
|
}
|
352
352
|
|
353
353
|
.conversation-agent-message {
|
354
|
-
--bubble-bg-color: var(--
|
354
|
+
--bubble-bg-color: var(--agent-bg-color);
|
355
355
|
--bubble-text-color: var(--agent-text-color);
|
356
356
|
display: grid;
|
357
357
|
margin-right: 10%;
|
@@ -509,8 +509,8 @@
|
|
509
509
|
--send-icon-opacity: 0.4;
|
510
510
|
--send-icon-color: var(--text-color);
|
511
511
|
--conversation-bg: var(--conversation-bg-color, #fafafa);
|
512
|
-
--
|
513
|
-
|
512
|
+
--agent-bg-color: var(
|
513
|
+
--conversation-agent-bg-color,
|
514
514
|
var(--secondary-background)
|
515
515
|
);
|
516
516
|
--agent-text-color: var(
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { C as wt } from "./index-
|
1
|
+
import { C as wt } from "./index-617ed5e3.mjs";
|
2
2
|
/**
|
3
3
|
* @license
|
4
4
|
* Copyright 2019 Google LLC
|
@@ -1482,7 +1482,7 @@ class U extends v {
|
|
1482
1482
|
const i = (c = this.application) == null ? void 0 : c.triggerIcon;
|
1483
1483
|
if (!i)
|
1484
1484
|
return u;
|
1485
|
-
const n = async (d) => await import("./index-
|
1485
|
+
const n = async (d) => await import("./index-e7f4cf90.mjs").then(
|
1486
1486
|
(p) => p[d]
|
1487
1487
|
), { type: r, content: o } = i;
|
1488
1488
|
switch (r) {
|
@@ -2281,7 +2281,7 @@ pt.styles = [
|
|
2281
2281
|
}
|
2282
2282
|
|
2283
2283
|
.conversation-agent-message {
|
2284
|
-
--bubble-bg-color: var(--
|
2284
|
+
--bubble-bg-color: var(--agent-bg-color);
|
2285
2285
|
--bubble-text-color: var(--agent-text-color);
|
2286
2286
|
display: grid;
|
2287
2287
|
margin-right: 10%;
|
@@ -2572,8 +2572,8 @@ z.styles = [
|
|
2572
2572
|
--send-icon-opacity: 0.4;
|
2573
2573
|
--send-icon-color: var(--text-color);
|
2574
2574
|
--conversation-bg: var(--conversation-bg-color, #fafafa);
|
2575
|
-
--
|
2576
|
-
|
2575
|
+
--agent-bg-color: var(
|
2576
|
+
--conversation-agent-bg-color,
|
2577
2577
|
var(--secondary-background)
|
2578
2578
|
);
|
2579
2579
|
--agent-text-color: var(
|
@@ -1125,7 +1125,7 @@ class M {
|
|
1125
1125
|
}
|
1126
1126
|
}
|
1127
1127
|
const ie = async (e) => {
|
1128
|
-
e.registerComponent("conversation", import("./conversation-
|
1128
|
+
e.registerComponent("conversation", import("./conversation-9e21a86a.mjs").then((r) => r.c)), await M.getInstance(e.container);
|
1129
1129
|
};
|
1130
1130
|
var j = /* @__PURE__ */ ((e) => (e.User = "user", e.Agent = "agent", e.System = "system", e))(j || {});
|
1131
1131
|
class G {
|
@@ -1,3 +1,3 @@
|
|
1
1
|
"use strict";let P;const mt=new Uint8Array(16);function wt(){if(!P&&(P=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!P))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return P(mt)}const d=[];for(let e=0;e<256;++e)d.push((e+256).toString(16).slice(1));function St(e,r=0){return d[e[r+0]]+d[e[r+1]]+d[e[r+2]]+d[e[r+3]]+"-"+d[e[r+4]]+d[e[r+5]]+"-"+d[e[r+6]]+d[e[r+7]]+"-"+d[e[r+8]]+d[e[r+9]]+"-"+d[e[r+10]]+d[e[r+11]]+d[e[r+12]]+d[e[r+13]]+d[e[r+14]]+d[e[r+15]]}const gt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),H={randomUUID:gt};function Et(e,r,t){if(H.randomUUID&&!r&&!e)return H.randomUUID();e=e||{};const n=e.random||(e.rng||wt)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,r){t=t||0;for(let o=0;o<16;++o)r[t+o]=n[o];return r}return St(n)}var L=function(e,r){return L=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])},L(e,r)};function E(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");L(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}function xt(e,r,t,n){function o(i){return i instanceof t?i:new t(function(s){s(i)})}return new(t||(t=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(e,r||[])).next())})}function Q(e,r){var t={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]&&(t=0)),t;)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 t.label++,{value:c[1],done:!1};case 5:t.label++,o=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){t.label=c[1];break}if(c[0]===6&&t.label<i[1]){t.label=i[1],i=c;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(c);break}i[2]&&t.ops.pop(),t.trys.pop();continue}c=r.call(e,t)}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 g(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 U(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),o,i=[],s;try{for(;(r===void 0||r-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(s)throw s.error}}return i}function A(e,r,t){if(t||arguments.length===2)for(var n=0,o=r.length,i;n<o;n++)(i||!(n in r))&&(i||(i=Array.prototype.slice.call(r,0,n)),i[n]=r[n]);return e.concat(i||Array.prototype.slice.call(r))}function S(e){return this instanceof S?(this.v=e,this):new S(e)}function _t(e,r,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(e,r||[]),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,p){i.push([l,v,x,p])>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 S?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 Pt(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e[Symbol.asyncIterator],t;return r?r.call(e):(e=typeof g=="function"?g(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(i){t[i]=e[i]&&function(s){return new Promise(function(u,a){s=e[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(e){return typeof e=="function"}function W(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 R=W(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
|
2
2
|
`+t.map(function(n,o){return o+1+") "+n.toString()}).join(`
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=t}});function D(e,r){if(e){var t=e.indexOf(r);0<=t&&e.splice(t,1)}}var T=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,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=g(s),a=u.next();!a.done;a=u.next()){var c=a.value;c.remove(this)}}catch(p){r={error:p}}finally{try{a&&!a.done&&(t=u.return)&&t.call(u)}finally{if(r)throw r.error}}else s.remove(this);var f=this.initialTeardown;if(h(f))try{f()}catch(p){i=p instanceof R?p.errors:[p]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var l=g(b),v=l.next();!v.done;v=l.next()){var x=v.value;try{z(x)}catch(p){i=i??[],p instanceof R?i=A(A([],U(i)),U(p.errors)):i.push(p)}}}catch(p){n={error:p}}finally{try{v&&!v.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}}if(i)throw new R(i)}},e.prototype.add=function(r){var t;if(r&&r!==this)if(this.closed)z(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)&&D(t,r)},e.prototype.remove=function(r){var t=this._finalizers;t&&D(t,r),r instanceof e&&r._removeParent(this)},e.EMPTY=function(){var r=new e;return r.closed=!0,r}(),e}(),X=T.EMPTY;function Z(e){return e instanceof T||e&&"closed"in e&&h(e.remove)&&h(e.add)&&h(e.unsubscribe)}function z(e){h(e)?e():e.unsubscribe()}var N={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},V={setTimeout:function(e,r){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var o=V.delegate;return o!=null&&o.setTimeout?o.setTimeout.apply(o,A([e,r],U(t))):setTimeout.apply(void 0,A([e,r],U(t)))},clearTimeout:function(e){var r=V.delegate;return((r==null?void 0:r.clearTimeout)||clearTimeout)(e)},delegate:void 0};function tt(e){V.setTimeout(function(){throw e})}function Y(){}function O(e){e()}var B=function(e){E(r,e);function r(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,Z(t)&&t.add(n)):n.destination=At,n}return r.create=function(t,n,o){return new q(t,n,o)},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}(T),It=Function.prototype.bind;function F(e,r){return It.call(e,r)}var Ot=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){I(n)}},e.prototype.error=function(r){var t=this.partialObserver;if(t.error)try{t.error(r)}catch(n){I(n)}else I(r)},e.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(t){I(t)}},e}(),q=function(e){E(r,e);function r(t,n,o){var i=e.call(this)||this,s;if(h(t)||!t)s={next:t??void 0,error:n??void 0,complete:o??void 0};else{var u;i&&N.useDeprecatedNextContext?(u=Object.create(t),u.unsubscribe=function(){return i.unsubscribe()},s={next:t.next&&F(t.next,u),error:t.error&&F(t.error,u),complete:t.complete&&F(t.complete,u)}):s=t}return i.destination=new Ot(s),i}return r}(B);function I(e){tt(e)}function Ut(e){throw e}var At={closed:!0,next:Y,error:Ut,complete:Y},M=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Tt(e){return e}function kt(e){return e.length===0?Tt:e.length===1?e[0]:function(t){return e.reduce(function(n,o){return o(n)},t)}}var y=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 o=this,i=jt(r)?r:new q(r,t,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},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=K(t),new t(function(o,i){var s=new q({next:function(u){try{r(u)}catch(a){i(a),s.unsubscribe()}},error:i,complete:o});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[M]=function(){return this},e.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return kt(r)(this)},e.prototype.toPromise=function(r){var t=this;return r=K(r),new r(function(n,o){var i;t.subscribe(function(s){return i=s},function(s){return o(s)},function(){return n(i)})})},e.create=function(r){return new e(r)},e}();function K(e){var r;return(r=e??N.Promise)!==null&&r!==void 0?r:Promise}function Ct(e){return e&&h(e.next)&&h(e.error)&&h(e.complete)}function jt(e){return e&&e instanceof B||Ct(e)&&Z(e)}function $t(e){return h(e==null?void 0:e.lift)}function k(e){return function(r){if($t(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 G(e,r,t,n,o){return new Rt(e,r,t,n,o)}var Rt=function(e){E(r,e);function r(t,n,o,i,s,u){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=u,a._next=n?function(c){try{n(c)}catch(f){t.error(f)}}:e.prototype._next,a._error=i?function(c){try{i(c)}catch(f){t.error(f)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=o?function(){try{o()}catch(c){t.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,a}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}(B),Ft=W(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),w=function(e){E(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 J(this,this);return n.operator=t,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new Ft},r.prototype.next=function(t){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=g(n.currentObservers),u=s.next();!u.done;u=s.next()){var a=u.value;a.next(t)}}catch(c){o={error:c}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}})},r.prototype.error=function(t){var n=this;O(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var o=n.observers;o.length;)o.shift().error(t)}})},r.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()}})},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,o=this,i=o.hasError,s=o.isStopped,u=o.observers;return i||s?X:(this.currentObservers=null,u.push(t),new T(function(){n.currentObservers=null,D(u,t)}))},r.prototype._checkFinalizedStatuses=function(t){var n=this,o=n.hasError,i=n.thrownError,s=n.isStopped;o?t.error(i):s&&t.complete()},r.prototype.asObservable=function(){var t=new y;return t.source=this,t},r.create=function(t,n){return new J(t,n)},r}(y),J=function(e){E(r,e);function r(t,n){var o=e.call(this)||this;return o.destination=t,o.source=n,o}return r.prototype.next=function(t){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,t)},r.prototype.error=function(t){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.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,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&o!==void 0?o:X},r}(w),et=function(e){E(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,o=t.thrownError,i=t._value;if(n)throw o;return this._throwIfClosed(),i},r.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},r}(w),Lt=new y(function(e){return e.complete()});function Dt(e){return e&&h(e.schedule)}function Vt(e){return e[e.length-1]}function Yt(e){return Dt(Vt(e))?e.pop():void 0}var rt=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function nt(e){return h(e==null?void 0:e.then)}function ot(e){return h(e[M])}function it(e){return Symbol.asyncIterator&&h(e==null?void 0:e[Symbol.asyncIterator])}function st(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function qt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ut=qt();function ct(e){return h(e==null?void 0:e[ut])}function at(e){return _t(this,arguments,function(){var t,n,o,i;return Q(this,function(s){switch(s.label){case 0:t=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,S(t.read())];case 3:return n=s.sent(),o=n.value,i=n.done,i?[4,S(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,S(o)];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 lt(e){return h(e==null?void 0:e.getReader)}function C(e){if(e instanceof y)return e;if(e!=null){if(ot(e))return Bt(e);if(rt(e))return Mt(e);if(nt(e))return Gt(e);if(it(e))return ft(e);if(ct(e))return Ht(e);if(lt(e))return zt(e)}throw st(e)}function Bt(e){return new y(function(r){var t=e[M]();if(h(t.subscribe))return t.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Mt(e){return new y(function(r){for(var t=0;t<e.length&&!r.closed;t++)r.next(e[t]);r.complete()})}function Gt(e){return new y(function(r){e.then(function(t){r.closed||(r.next(t),r.complete())},function(t){return r.error(t)}).then(null,tt)})}function Ht(e){return new y(function(r){var t,n;try{for(var o=g(e),i=o.next();!i.done;i=o.next()){var s=i.value;if(r.next(s),r.closed)return}}catch(u){t={error:u}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}r.complete()})}function ft(e){return new y(function(r){Kt(e,r).catch(function(t){return r.error(t)})})}function zt(e){return ft(at(e))}function Kt(e,r){var t,n,o,i;return xt(this,void 0,void 0,function(){var s,u;return Q(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),t=Pt(e),a.label=1;case 1:return[4,t.next()];case 2:if(n=a.sent(),!!n.done)return[3,4];if(s=n.value,r.next(s),r.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=t.return)?[4,i.call(t)]:[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 r.complete(),[2]}})})}function m(e,r,t,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var i=r.schedule(function(){t(),o?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(i),!o)return i}function ht(e,r){return r===void 0&&(r=0),k(function(t,n){t.subscribe(G(n,function(o){return m(n,e,function(){return n.next(o)},r)},function(){return m(n,e,function(){return n.complete()},r)},function(o){return m(n,e,function(){return n.error(o)},r)}))})}function dt(e,r){return r===void 0&&(r=0),k(function(t,n){n.add(e.schedule(function(){return t.subscribe(n)},r))})}function Jt(e,r){return C(e).pipe(dt(r),ht(r))}function Qt(e,r){return C(e).pipe(dt(r),ht(r))}function Wt(e,r){return new y(function(t){var n=0;return r.schedule(function(){n===e.length?t.complete():(t.next(e[n++]),t.closed||this.schedule())})})}function Xt(e,r){return new y(function(t){var n;return m(t,r,function(){n=e[ut](),m(t,r,function(){var o,i,s;try{o=n.next(),i=o.value,s=o.done}catch(u){t.error(u);return}s?t.complete():t.next(i)},0,!0)}),function(){return h(n==null?void 0:n.return)&&n.return()}})}function pt(e,r){if(!e)throw new Error("Iterable cannot be null");return new y(function(t){m(t,r,function(){var n=e[Symbol.asyncIterator]();m(t,r,function(){n.next().then(function(o){o.done?t.complete():t.next(o.value)})},0,!0)})})}function Zt(e,r){return pt(at(e),r)}function Nt(e,r){if(e!=null){if(ot(e))return Jt(e,r);if(rt(e))return Wt(e,r);if(nt(e))return Qt(e,r);if(it(e))return pt(e,r);if(ct(e))return Xt(e,r);if(lt(e))return Zt(e,r)}throw st(e)}function te(e,r){return r?Nt(e,r):C(e)}function ee(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=Yt(e);return te(e,t)}function re(e){return e<=0?function(){return Lt}:k(function(r,t){var n=0;r.subscribe(G(t,function(o){++n<=e&&(t.next(o),e<=n&&t.complete())}))})}function ne(e){return k(function(r,t){C(e).subscribe(G(t,function(){return t.complete()},Y)),!t.closed&&r.subscribe(t)})}class vt{constructor(r,t,n){this.id=r,this.platform=n,this.entries$=new et([]),this.kill$=new w,this.queue=[],t.addEventListener("user-submit",o=>{if(!this.provider){console.warn("No provider activated, unable to print message to conversation.");return}this.provider.onUserSubmit(o.detail)})}write(r){this.entries$.pipe(re(1)).subscribe(t=>{this.entries$.next([...t,r])})}entries(){return this.entries$.asObservable()}setProvider(r){this.provider=r,this.provider.actions().pipe(ne(this.kill$)).subscribe(t=>{this.write(t)})}handover(r){const t=this.platform.registeredProviders.get(r);if(t){this.provider&&this.queue.unshift(this.provider),this.kill$.next();const n=t(this);this.setProvider(n)}}completeProvider(){const[r]=this.queue;r&&this.setProvider(r)}isTyping(){return this.provider?this.provider.isTyping():ee(!1)}}class j{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 j,await r.register("conversation",t),t)}registerProvider(r,t){this.registeredProviders.set(r,t)}createSession(r){const t=new vt(Et(),r,this),n=this.getProviderByConfiguration(r);if(n){const o=n(t);t.setProvider(o)}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 oe=async e=>{e.registerComponent("conversation",Promise.resolve().then(()=>require("./conversation-177be0b6.js")).then(r=>r.conversation)),await j.getInstance(e.container)};var _=(e=>(e.User="user",e.Agent="agent",e.System="system",e))(_||{});class ${constructor(r,t,n){this.type=r,this.sender=t,this.messages=n,this.didUpdate=new w,this.timestamp=Date.now()}update(r){this.messages=[{items:r}],this.didUpdate.next(this)}}class yt{constructor(r){this.name=r,this.print$=new w}print(r){const t=new $(_.Agent,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class bt{constructor(r){this.name=r,this.print$=new w}print(r){const t=new $(_.User,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class ie{constructor(r,t){this.name=r,this.session=t,this.print$=new w,this.typingState$=new et(!1)}onUserSubmit(r){this.print(_.User,r.text)}print(r,t){const n=new $(r,{name:""},[{items:[["html",{content:t}]]}]);return this.printEntry(n)}printEntry(r){return this.print$.next(r),r}createAgent(r){const t=new yt(r);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}createUser(r){const t=new bt(r);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}setTypingState(r){this.typingState$.next(r)}isTyping(){return this.typingState$.asObservable()}actions(){return this.print$.asObservable()}complete(){this.session.completeProvider()}}exports.Agent=yt;exports.ConversationComponent=oe;exports.ConversationEntry=$;exports.ConversationMessageType=_;exports.ConversationPlatform=j;exports.ConversationProvider=ie;exports.ConversationSessionState=vt;exports.User=bt;
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=t}});function D(e,r){if(e){var t=e.indexOf(r);0<=t&&e.splice(t,1)}}var T=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,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=g(s),a=u.next();!a.done;a=u.next()){var c=a.value;c.remove(this)}}catch(p){r={error:p}}finally{try{a&&!a.done&&(t=u.return)&&t.call(u)}finally{if(r)throw r.error}}else s.remove(this);var f=this.initialTeardown;if(h(f))try{f()}catch(p){i=p instanceof R?p.errors:[p]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var l=g(b),v=l.next();!v.done;v=l.next()){var x=v.value;try{z(x)}catch(p){i=i??[],p instanceof R?i=A(A([],U(i)),U(p.errors)):i.push(p)}}}catch(p){n={error:p}}finally{try{v&&!v.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}}if(i)throw new R(i)}},e.prototype.add=function(r){var t;if(r&&r!==this)if(this.closed)z(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)&&D(t,r)},e.prototype.remove=function(r){var t=this._finalizers;t&&D(t,r),r instanceof e&&r._removeParent(this)},e.EMPTY=function(){var r=new e;return r.closed=!0,r}(),e}(),X=T.EMPTY;function Z(e){return e instanceof T||e&&"closed"in e&&h(e.remove)&&h(e.add)&&h(e.unsubscribe)}function z(e){h(e)?e():e.unsubscribe()}var N={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},V={setTimeout:function(e,r){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var o=V.delegate;return o!=null&&o.setTimeout?o.setTimeout.apply(o,A([e,r],U(t))):setTimeout.apply(void 0,A([e,r],U(t)))},clearTimeout:function(e){var r=V.delegate;return((r==null?void 0:r.clearTimeout)||clearTimeout)(e)},delegate:void 0};function tt(e){V.setTimeout(function(){throw e})}function Y(){}function O(e){e()}var B=function(e){E(r,e);function r(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,Z(t)&&t.add(n)):n.destination=At,n}return r.create=function(t,n,o){return new q(t,n,o)},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}(T),It=Function.prototype.bind;function F(e,r){return It.call(e,r)}var Ot=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){I(n)}},e.prototype.error=function(r){var t=this.partialObserver;if(t.error)try{t.error(r)}catch(n){I(n)}else I(r)},e.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(t){I(t)}},e}(),q=function(e){E(r,e);function r(t,n,o){var i=e.call(this)||this,s;if(h(t)||!t)s={next:t??void 0,error:n??void 0,complete:o??void 0};else{var u;i&&N.useDeprecatedNextContext?(u=Object.create(t),u.unsubscribe=function(){return i.unsubscribe()},s={next:t.next&&F(t.next,u),error:t.error&&F(t.error,u),complete:t.complete&&F(t.complete,u)}):s=t}return i.destination=new Ot(s),i}return r}(B);function I(e){tt(e)}function Ut(e){throw e}var At={closed:!0,next:Y,error:Ut,complete:Y},M=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Tt(e){return e}function kt(e){return e.length===0?Tt:e.length===1?e[0]:function(t){return e.reduce(function(n,o){return o(n)},t)}}var y=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 o=this,i=jt(r)?r:new q(r,t,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},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=K(t),new t(function(o,i){var s=new q({next:function(u){try{r(u)}catch(a){i(a),s.unsubscribe()}},error:i,complete:o});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[M]=function(){return this},e.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return kt(r)(this)},e.prototype.toPromise=function(r){var t=this;return r=K(r),new r(function(n,o){var i;t.subscribe(function(s){return i=s},function(s){return o(s)},function(){return n(i)})})},e.create=function(r){return new e(r)},e}();function K(e){var r;return(r=e??N.Promise)!==null&&r!==void 0?r:Promise}function Ct(e){return e&&h(e.next)&&h(e.error)&&h(e.complete)}function jt(e){return e&&e instanceof B||Ct(e)&&Z(e)}function $t(e){return h(e==null?void 0:e.lift)}function k(e){return function(r){if($t(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 G(e,r,t,n,o){return new Rt(e,r,t,n,o)}var Rt=function(e){E(r,e);function r(t,n,o,i,s,u){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=u,a._next=n?function(c){try{n(c)}catch(f){t.error(f)}}:e.prototype._next,a._error=i?function(c){try{i(c)}catch(f){t.error(f)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=o?function(){try{o()}catch(c){t.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,a}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}(B),Ft=W(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),w=function(e){E(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 J(this,this);return n.operator=t,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new Ft},r.prototype.next=function(t){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=g(n.currentObservers),u=s.next();!u.done;u=s.next()){var a=u.value;a.next(t)}}catch(c){o={error:c}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}})},r.prototype.error=function(t){var n=this;O(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var o=n.observers;o.length;)o.shift().error(t)}})},r.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()}})},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,o=this,i=o.hasError,s=o.isStopped,u=o.observers;return i||s?X:(this.currentObservers=null,u.push(t),new T(function(){n.currentObservers=null,D(u,t)}))},r.prototype._checkFinalizedStatuses=function(t){var n=this,o=n.hasError,i=n.thrownError,s=n.isStopped;o?t.error(i):s&&t.complete()},r.prototype.asObservable=function(){var t=new y;return t.source=this,t},r.create=function(t,n){return new J(t,n)},r}(y),J=function(e){E(r,e);function r(t,n){var o=e.call(this)||this;return o.destination=t,o.source=n,o}return r.prototype.next=function(t){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,t)},r.prototype.error=function(t){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.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,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&o!==void 0?o:X},r}(w),et=function(e){E(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,o=t.thrownError,i=t._value;if(n)throw o;return this._throwIfClosed(),i},r.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},r}(w),Lt=new y(function(e){return e.complete()});function Dt(e){return e&&h(e.schedule)}function Vt(e){return e[e.length-1]}function Yt(e){return Dt(Vt(e))?e.pop():void 0}var rt=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function nt(e){return h(e==null?void 0:e.then)}function ot(e){return h(e[M])}function it(e){return Symbol.asyncIterator&&h(e==null?void 0:e[Symbol.asyncIterator])}function st(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function qt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ut=qt();function ct(e){return h(e==null?void 0:e[ut])}function at(e){return _t(this,arguments,function(){var t,n,o,i;return Q(this,function(s){switch(s.label){case 0:t=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,S(t.read())];case 3:return n=s.sent(),o=n.value,i=n.done,i?[4,S(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,S(o)];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 lt(e){return h(e==null?void 0:e.getReader)}function C(e){if(e instanceof y)return e;if(e!=null){if(ot(e))return Bt(e);if(rt(e))return Mt(e);if(nt(e))return Gt(e);if(it(e))return ft(e);if(ct(e))return Ht(e);if(lt(e))return zt(e)}throw st(e)}function Bt(e){return new y(function(r){var t=e[M]();if(h(t.subscribe))return t.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Mt(e){return new y(function(r){for(var t=0;t<e.length&&!r.closed;t++)r.next(e[t]);r.complete()})}function Gt(e){return new y(function(r){e.then(function(t){r.closed||(r.next(t),r.complete())},function(t){return r.error(t)}).then(null,tt)})}function Ht(e){return new y(function(r){var t,n;try{for(var o=g(e),i=o.next();!i.done;i=o.next()){var s=i.value;if(r.next(s),r.closed)return}}catch(u){t={error:u}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}r.complete()})}function ft(e){return new y(function(r){Kt(e,r).catch(function(t){return r.error(t)})})}function zt(e){return ft(at(e))}function Kt(e,r){var t,n,o,i;return xt(this,void 0,void 0,function(){var s,u;return Q(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),t=Pt(e),a.label=1;case 1:return[4,t.next()];case 2:if(n=a.sent(),!!n.done)return[3,4];if(s=n.value,r.next(s),r.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=t.return)?[4,i.call(t)]:[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 r.complete(),[2]}})})}function m(e,r,t,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var i=r.schedule(function(){t(),o?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(i),!o)return i}function ht(e,r){return r===void 0&&(r=0),k(function(t,n){t.subscribe(G(n,function(o){return m(n,e,function(){return n.next(o)},r)},function(){return m(n,e,function(){return n.complete()},r)},function(o){return m(n,e,function(){return n.error(o)},r)}))})}function dt(e,r){return r===void 0&&(r=0),k(function(t,n){n.add(e.schedule(function(){return t.subscribe(n)},r))})}function Jt(e,r){return C(e).pipe(dt(r),ht(r))}function Qt(e,r){return C(e).pipe(dt(r),ht(r))}function Wt(e,r){return new y(function(t){var n=0;return r.schedule(function(){n===e.length?t.complete():(t.next(e[n++]),t.closed||this.schedule())})})}function Xt(e,r){return new y(function(t){var n;return m(t,r,function(){n=e[ut](),m(t,r,function(){var o,i,s;try{o=n.next(),i=o.value,s=o.done}catch(u){t.error(u);return}s?t.complete():t.next(i)},0,!0)}),function(){return h(n==null?void 0:n.return)&&n.return()}})}function pt(e,r){if(!e)throw new Error("Iterable cannot be null");return new y(function(t){m(t,r,function(){var n=e[Symbol.asyncIterator]();m(t,r,function(){n.next().then(function(o){o.done?t.complete():t.next(o.value)})},0,!0)})})}function Zt(e,r){return pt(at(e),r)}function Nt(e,r){if(e!=null){if(ot(e))return Jt(e,r);if(rt(e))return Wt(e,r);if(nt(e))return Qt(e,r);if(it(e))return pt(e,r);if(ct(e))return Xt(e,r);if(lt(e))return Zt(e,r)}throw st(e)}function te(e,r){return r?Nt(e,r):C(e)}function ee(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=Yt(e);return te(e,t)}function re(e){return e<=0?function(){return Lt}:k(function(r,t){var n=0;r.subscribe(G(t,function(o){++n<=e&&(t.next(o),e<=n&&t.complete())}))})}function ne(e){return k(function(r,t){C(e).subscribe(G(t,function(){return t.complete()},Y)),!t.closed&&r.subscribe(t)})}class vt{constructor(r,t,n){this.id=r,this.platform=n,this.entries$=new et([]),this.kill$=new w,this.queue=[],t.addEventListener("user-submit",o=>{if(!this.provider){console.warn("No provider activated, unable to print message to conversation.");return}this.provider.onUserSubmit(o.detail)})}write(r){this.entries$.pipe(re(1)).subscribe(t=>{this.entries$.next([...t,r])})}entries(){return this.entries$.asObservable()}setProvider(r){this.provider=r,this.provider.actions().pipe(ne(this.kill$)).subscribe(t=>{this.write(t)})}handover(r){const t=this.platform.registeredProviders.get(r);if(t){this.provider&&this.queue.unshift(this.provider),this.kill$.next();const n=t(this);this.setProvider(n)}}completeProvider(){const[r]=this.queue;r&&this.setProvider(r)}isTyping(){return this.provider?this.provider.isTyping():ee(!1)}}class j{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 j,await r.register("conversation",t),t)}registerProvider(r,t){this.registeredProviders.set(r,t)}createSession(r){const t=new vt(Et(),r,this),n=this.getProviderByConfiguration(r);if(n){const o=n(t);t.setProvider(o)}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 oe=async e=>{e.registerComponent("conversation",Promise.resolve().then(()=>require("./conversation-14f46dc9.js")).then(r=>r.conversation)),await j.getInstance(e.container)};var _=(e=>(e.User="user",e.Agent="agent",e.System="system",e))(_||{});class ${constructor(r,t,n){this.type=r,this.sender=t,this.messages=n,this.didUpdate=new w,this.timestamp=Date.now()}update(r){this.messages=[{items:r}],this.didUpdate.next(this)}}class yt{constructor(r){this.name=r,this.print$=new w}print(r){const t=new $(_.Agent,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class bt{constructor(r){this.name=r,this.print$=new w}print(r){const t=new $(_.User,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class ie{constructor(r,t){this.name=r,this.session=t,this.print$=new w,this.typingState$=new et(!1)}onUserSubmit(r){this.print(_.User,r.text)}print(r,t){const n=new $(r,{name:""},[{items:[["html",{content:t}]]}]);return this.printEntry(n)}printEntry(r){return this.print$.next(r),r}createAgent(r){const t=new yt(r);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}createUser(r){const t=new bt(r);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}setTypingState(r){this.typingState$.next(r)}isTyping(){return this.typingState$.asObservable()}actions(){return this.print$.asObservable()}complete(){this.session.completeProvider()}}exports.Agent=yt;exports.ConversationComponent=oe;exports.ConversationEntry=$;exports.ConversationMessageType=_;exports.ConversationPlatform=j;exports.ConversationProvider=ie;exports.ConversationSessionState=vt;exports.User=bt;
|