@telia-ace/widget-conversation-flamingo 1.1.14-rc.1 → 1.1.14-rc.2
Sign up to get free protection for your applications and to get access to all the features.
- package/{conversation-c7b20faa.js → conversation-2e20f9c4.js} +82 -85
- package/{conversation-863ede7a.mjs → conversation-d58bd503.mjs} +444 -427
- package/index-23b605ae.js +3 -0
- package/{index-b8394e84.js → index-6e5d6521.js} +1 -1
- package/{index-94b25fbe.mjs → index-cc3fb480.mjs} +2 -2
- package/index-ccbeb601.mjs +1218 -0
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/models/conversation-provider.d.ts +3 -0
- package/models/conversation-session-state.d.ts +3 -2
- package/package.json +2 -2
- package/typing.d.ts +5 -0
- package/index-7ce12d5a.mjs +0 -773
- package/index-cec07deb.js +0 -3
package/index-cec07deb.js
DELETED
@@ -1,3 +0,0 @@
|
|
1
|
-
"use strict";let S;const Q=new Uint8Array(16);function W(){if(!S&&(S=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!S))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return S(Q)}const a=[];for(let e=0;e<256;++e)a.push((e+256).toString(16).slice(1));function X(e,r=0){return a[e[r+0]]+a[e[r+1]]+a[e[r+2]]+a[e[r+3]]+"-"+a[e[r+4]]+a[e[r+5]]+"-"+a[e[r+6]]+a[e[r+7]]+"-"+a[e[r+8]]+a[e[r+9]]+"-"+a[e[r+10]]+a[e[r+11]]+a[e[r+12]]+a[e[r+13]]+a[e[r+14]]+a[e[r+15]]}const Z=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),B={randomUUID:Z};function N(e,r,t){if(B.randomUUID&&!r&&!e)return B.randomUUID();e=e||{};const n=e.random||(e.rng||W)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,r){t=t||0;for(let i=0;i<16;++i)r[t+i]=n[i];return r}return X(n)}var C=function(e,r){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},C(e,r)};function d(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");C(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}function j(e){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),i,o=[],s;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(u){s={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(s)throw s.error}}return o}function E(e,r,t){if(t||arguments.length===2)for(var n=0,i=r.length,o;n<i;n++)(o||!(n in r))&&(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return e.concat(o||Array.prototype.slice.call(r))}function p(e){return typeof e=="function"}function H(e){var r=function(n){Error.call(n),n.stack=new Error().stack},t=e(r);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var O=H(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
|
2
|
-
`+t.map(function(n,i){return i+1+") "+n.toString()}).join(`
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=t}});function I(e,r){if(e){var t=e.indexOf(r);0<=t&&e.splice(t,1)}}var U=function(){function e(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var r,t,n,i,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var u=j(s),c=u.next();!c.done;c=u.next()){var h=c.value;h.remove(this)}}catch(l){r={error:l}}finally{try{c&&!c.done&&(t=u.return)&&t.call(u)}finally{if(r)throw r.error}}else s.remove(this);var f=this.initialTeardown;if(p(f))try{f()}catch(l){o=l instanceof O?l.errors:[l]}var R=this._finalizers;if(R){this._finalizers=null;try{for(var m=j(R),b=m.next();!b.done;b=m.next()){var J=b.value;try{V(J)}catch(l){o=o??[],l instanceof O?o=E(E([],_(o)),_(l.errors)):o.push(l)}}}catch(l){n={error:l}}finally{try{b&&!b.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}}if(o)throw new O(o)}},e.prototype.add=function(r){var t;if(r&&r!==this)if(this.closed)V(r);else{if(r instanceof e){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(r)}},e.prototype._hasParent=function(r){var t=this._parentage;return t===r||Array.isArray(t)&&t.includes(r)},e.prototype._addParent=function(r){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(r),t):t?[t,r]:r},e.prototype._removeParent=function(r){var t=this._parentage;t===r?this._parentage=null:Array.isArray(t)&&I(t,r)},e.prototype.remove=function(r){var t=this._finalizers;t&&I(t,r),r instanceof e&&r._removeParent(this)},e.EMPTY=function(){var r=new e;return r.closed=!0,r}(),e}(),L=U.EMPTY;function q(e){return e instanceof U||e&&"closed"in e&&p(e.remove)&&p(e.add)&&p(e.unsubscribe)}function V(e){p(e)?e():e.unsubscribe()}var z={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},T={setTimeout:function(e,r){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=T.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,E([e,r],_(t))):setTimeout.apply(void 0,E([e,r],_(t)))},clearTimeout:function(e){var r=T.delegate;return((r==null?void 0:r.clearTimeout)||clearTimeout)(e)},delegate:void 0};function tt(e){T.setTimeout(function(){throw e})}function k(){}function w(e){e()}var F=function(e){d(r,e);function r(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,q(t)&&t.add(n)):n.destination=it,n}return r.create=function(t,n,i){return new $(t,n,i)},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(U),rt=Function.prototype.bind;function A(e,r){return rt.call(e,r)}var et=function(){function e(r){this.partialObserver=r}return e.prototype.next=function(r){var t=this.partialObserver;if(t.next)try{t.next(r)}catch(n){g(n)}},e.prototype.error=function(r){var t=this.partialObserver;if(t.error)try{t.error(r)}catch(n){g(n)}else g(r)},e.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(t){g(t)}},e}(),$=function(e){d(r,e);function r(t,n,i){var o=e.call(this)||this,s;if(p(t)||!t)s={next:t??void 0,error:n??void 0,complete:i??void 0};else{var u;o&&z.useDeprecatedNextContext?(u=Object.create(t),u.unsubscribe=function(){return o.unsubscribe()},s={next:t.next&&A(t.next,u),error:t.error&&A(t.error,u),complete:t.complete&&A(t.complete,u)}):s=t}return o.destination=new et(s),o}return r}(F);function g(e){tt(e)}function nt(e){throw e}var it={closed:!0,next:k,error:nt,complete:k},ot=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function st(e){return e}function ut(e){return e.length===0?st:e.length===1?e[0]:function(t){return e.reduce(function(n,i){return i(n)},t)}}var D=function(){function e(r){r&&(this._subscribe=r)}return e.prototype.lift=function(r){var t=new e;return t.source=this,t.operator=r,t},e.prototype.subscribe=function(r,t,n){var i=this,o=at(r)?r:new $(r,t,n);return w(function(){var s=i,u=s.operator,c=s.source;o.add(u?u.call(o,c):c?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){r.error(t)}},e.prototype.forEach=function(r,t){var n=this;return t=M(t),new t(function(i,o){var s=new $({next:function(u){try{r(u)}catch(c){o(c),s.unsubscribe()}},error:o,complete:i});n.subscribe(s)})},e.prototype._subscribe=function(r){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(r)},e.prototype[ot]=function(){return this},e.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return ut(r)(this)},e.prototype.toPromise=function(r){var t=this;return r=M(r),new r(function(n,i){var o;t.subscribe(function(s){return o=s},function(s){return i(s)},function(){return n(o)})})},e.create=function(r){return new e(r)},e}();function M(e){var r;return(r=e??z.Promise)!==null&&r!==void 0?r:Promise}function ct(e){return e&&p(e.next)&&p(e.error)&&p(e.complete)}function at(e){return e&&e instanceof F||ct(e)&&q(e)}function lt(e){return p(e==null?void 0:e.lift)}function pt(e){return function(r){if(lt(r))return r.lift(function(t){try{return e(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function ht(e,r,t,n,i){return new ft(e,r,t,n,i)}var ft=function(e){d(r,e);function r(t,n,i,o,s,u){var c=e.call(this,t)||this;return c.onFinalize=s,c.shouldUnsubscribe=u,c._next=n?function(h){try{n(h)}catch(f){t.error(f)}}:e.prototype._next,c._error=o?function(h){try{o(h)}catch(f){t.error(f)}finally{this.unsubscribe()}}:e.prototype._error,c._complete=i?function(){try{i()}catch(h){t.error(h)}finally{this.unsubscribe()}}:e.prototype._complete,c}return r.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},r}(F),dt=H(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),v=function(e){d(r,e);function r(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return r.prototype.lift=function(t){var n=new Y(this,this);return n.operator=t,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new dt},r.prototype.next=function(t){var n=this;w(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var s=j(n.currentObservers),u=s.next();!u.done;u=s.next()){var c=u.value;c.next(t)}}catch(h){i={error:h}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},r.prototype.error=function(t){var n=this;w(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var i=n.observers;i.length;)i.shift().error(t)}})},r.prototype.complete=function(){var t=this;w(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},r.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},r.prototype._innerSubscribe=function(t){var n=this,i=this,o=i.hasError,s=i.isStopped,u=i.observers;return o||s?L:(this.currentObservers=null,u.push(t),new U(function(){n.currentObservers=null,I(u,t)}))},r.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,o=n.thrownError,s=n.isStopped;i?t.error(o):s&&t.complete()},r.prototype.asObservable=function(){var t=new D;return t.source=this,t},r.create=function(t,n){return new Y(t,n)},r}(D),Y=function(e){d(r,e);function r(t,n){var i=e.call(this)||this;return i.destination=t,i.source=n,i}return r.prototype.next=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,t)},r.prototype.error=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,t)},r.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},r.prototype._subscribe=function(t){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&i!==void 0?i:L},r}(v),vt=function(e){d(r,e);function r(t){var n=e.call(this)||this;return n._value=t,n}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},r.prototype.getValue=function(){var t=this,n=t.hasError,i=t.thrownError,o=t._value;if(n)throw i;return this._throwIfClosed(),o},r.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},r}(v),bt=new D(function(e){return e.complete()});function yt(e){return e<=0?function(){return bt}:pt(function(r,t){var n=0;r.subscribe(ht(t,function(i){++n<=e&&(t.next(i),e<=n&&t.complete())}))})}class mt{constructor(r,t){this.id=r,this.entries$=new vt([]),t.addEventListener("user-submit",n=>{if(!this.provider){console.warn("No provider activated, unable to print message to conversation.");return}this.provider.onUserSubmit(n.detail)})}write(r){this.entries$.pipe(yt(1)).subscribe(t=>{this.entries$.next([...t,r])})}entries(){return this.entries$.asObservable()}setProvider(r){this.provider=r,this.provider.actions().subscribe(t=>{this.write(t)})}}class x{constructor(){this.sessions=new Map,this.registeredProviders=new Map,this.activeSessionId=null}static async getInstance(r){let t=await r.get("conversation");return t||(t=new x,await r.register("conversation",t),t)}registerProvider(r,t){this.registeredProviders.set(r,t)}createSession(r){const t=new mt(N(),r),n=this.getProviderByConfiguration(r);if(n){const i=n();t.setProvider(i)}return this.sessions.set(t.id,t),this.activeSessionId=t.id,t}getProviderByConfiguration(r){const[t]=r.properties.providers||[];if(!t){console.warn("No providers registered. You most likely forgot to add a provider to the conversation component properties.");return}return this.registeredProviders.get(t)}}const St=async e=>{e.registerComponent("conversation",Promise.resolve().then(()=>require("./conversation-c7b20faa.js")).then(r=>r.conversation)),await x.getInstance(e.container)};var y=(e=>(e.User="user",e.Agent="agent",e.System="system",e))(y||{});class P{constructor(r,t,n){this.type=r,this.sender=t,this.messages=n,this.didUpdate=new v,this.timestamp=Date.now()}update(r){this.messages=[{items:r}],this.didUpdate.next(this)}}class K{constructor(r){this.name=r,this.print$=new v}print(r){const t=new P(y.Agent,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class G{constructor(r){this.name=r,this.print$=new v}print(r){const t=new P(y.User,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class gt{constructor(r){this.name=r,this.print$=new v}onUserSubmit(r){this.print(y.User,r.text)}print(r,t){const n=new P(r,{name:"Botsson"},[{items:[["html",{content:t}]]}]);return this.printEntry(n)}printEntry(r){return this.print$.next(r),r}createAgent(r){const t=new K(r);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}createUser(r){const t=new G(r);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}actions(){return this.print$.asObservable()}}exports.Agent=K;exports.ConversationComponent=St;exports.ConversationEntry=P;exports.ConversationMessageType=y;exports.ConversationPlatform=x;exports.ConversationProvider=gt;exports.User=G;
|