@digipair/skill-web-chatbot 0.33.14 → 0.33.16

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/index.cjs2.js CHANGED
@@ -36822,14 +36822,14 @@ function indent(str, spaces) {
36822
36822
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
36823
36823
  // match is required
36824
36824
  if (!match) {
36825
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
36825
+ return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
36826
36826
  v: nextMatch1
36827
36827
  };
36828
36828
  }
36829
36829
  var token = match.token, offset = match.offset;
36830
36830
  i1 += offset;
36831
36831
  if (token === " ") {
36832
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
36832
+ return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
36833
36833
  }
36834
36834
  tokens1 = _to_consumable_array$c(tokens1).concat([
36835
36835
  token
@@ -36848,7 +36848,7 @@ function indent(str, spaces) {
36848
36848
  if (contextKeys.some(function(el) {
36849
36849
  return el.startsWith(name);
36850
36850
  })) {
36851
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
36851
+ return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
36852
36852
  }
36853
36853
  if (dateTimeIdentifiers.some(function(el) {
36854
36854
  return el === name;
@@ -36867,9 +36867,9 @@ function indent(str, spaces) {
36867
36867
  if (dateTimeIdentifiers.some(function(el) {
36868
36868
  return el.startsWith(name);
36869
36869
  })) {
36870
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
36870
+ return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
36871
36871
  }
36872
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
36872
+ return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
36873
36873
  v: nextMatch1
36874
36874
  };
36875
36875
  };
@@ -56821,6 +56821,18 @@ class ChatElement extends s$3 {
56821
56821
  }, boost)
56822
56822
  }));
56823
56823
  }
56824
+ canAnswerToMessageBoost(boost) {
56825
+ if (!boost) {
56826
+ return false;
56827
+ }
56828
+ if (boost.checkUrl && !boost.checkUrl.test(window.location.href)) {
56829
+ return false;
56830
+ }
56831
+ if (boost.selector && !document.querySelector(boost.selector)) {
56832
+ return false;
56833
+ }
56834
+ return true;
56835
+ }
56824
56836
  pushMessage(message) {
56825
56837
  this.messages.push(message);
56826
56838
  this.requestUpdate();
@@ -56841,7 +56853,7 @@ class ChatElement extends s$3 {
56841
56853
  return x`
56842
56854
  <section class="container ${this.currentBoost ? 'with-boost' : ''}">
56843
56855
  ${this.messages.map((message)=>x`<section class="${message.role}">
56844
- ${message.role === 'assistant' && message.boost ? x`<ui5-icon
56856
+ ${this.canAnswerToMessageBoost(message.boost) ? x`<ui5-icon
56845
56857
  name="response"
56846
56858
  class="button action"
56847
56859
  @click=${()=>this.answer(message)}
@@ -56888,8 +56900,8 @@ class ChatElement extends s$3 {
56888
56900
 
56889
56901
  <ui5-icon
56890
56902
  name="begin"
56891
- class="button ${this.loading || (!this.messageInput || this.messageInput.value === '') && (!this.currentBoost || this.currentBoost.required) || !this.hasInputsValues() ? 'disabled' : ''}"
56892
- @click=${()=>this.loading || (!this.messageInput || this.messageInput.value === '') && (!this.currentBoost || this.currentBoost.required) || !this.hasInputsValues() ? void 0 : this.addMessage(this.messageInput.value.trim())}
56903
+ class="button ${this.currentBoost && !this.canAnswerToMessageBoost(this.currentBoost) || this.loading || (!this.messageInput || this.messageInput.value === '') && (!this.currentBoost || this.currentBoost.required) || !this.hasInputsValues() ? 'disabled' : ''}"
56904
+ @click=${()=>this.currentBoost && !this.canAnswerToMessageBoost(this.currentBoost) || this.loading || (!this.messageInput || this.messageInput.value === '') && (!this.currentBoost || this.currentBoost.required) || !this.hasInputsValues() ? void 0 : this.addMessage(this.messageInput.value.trim())}
56893
56905
  ></ui5-icon>
56894
56906
  </section>
56895
56907
  `;
@@ -58693,9 +58705,13 @@ class ChatbotElement extends s$3 {
58693
58705
  async loadHistory() {
58694
58706
  const userId = this.userId;
58695
58707
  const reasoning = 'history';
58696
- const messages = await this.executeScene(reasoning, {
58708
+ const messages = (await this.executeScene(reasoning, {
58697
58709
  userId
58698
- });
58710
+ })).map((message)=>_extends({}, message, {
58711
+ boost: message.boost ? _extends({}, message.boost, {
58712
+ checkUrl: message.boost.url ? new RegExp(message.boost.url) : null
58713
+ }) : null
58714
+ }));
58699
58715
  if (messages.length > 0) {
58700
58716
  this.messages = messages;
58701
58717
  }
@@ -58776,6 +58792,7 @@ class ChatbotElement extends s$3 {
58776
58792
  setTimeout(()=>{
58777
58793
  var _this_chatbot_shadowRoot, _this_chatbot;
58778
58794
  ((_this_chatbot = this.chatbot) == null ? void 0 : (_this_chatbot_shadowRoot = _this_chatbot.shadowRoot) == null ? void 0 : _this_chatbot_shadowRoot.querySelector('#messageInput')).focus();
58795
+ this.chatbot.requestUpdate();
58779
58796
  }, 1);
58780
58797
  this.alreadyOpened = true;
58781
58798
  }
@@ -59114,9 +59131,13 @@ class DigipairFullElement extends s$3 {
59114
59131
  async loadHistory() {
59115
59132
  const userId = this.userId;
59116
59133
  const reasoning = 'history';
59117
- const messages = await this.executeScene(reasoning, {
59134
+ const messages = (await this.executeScene(reasoning, {
59118
59135
  userId
59119
- });
59136
+ })).map((message)=>_extends({}, message, {
59137
+ boost: message.boost ? _extends({}, message.boost, {
59138
+ checkUrl: message.boost.url ? new RegExp(message.boost.url) : null
59139
+ }) : null
59140
+ }));
59120
59141
  if (messages.length > 0) {
59121
59142
  this.messages = messages;
59122
59143
  }
package/index.esm2.js CHANGED
@@ -36802,14 +36802,14 @@ function indent(str, spaces) {
36802
36802
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
36803
36803
  // match is required
36804
36804
  if (!match) {
36805
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
36805
+ return nextMatch = nextMatch1, i = i1, tokens = tokens1, {
36806
36806
  v: nextMatch1
36807
36807
  };
36808
36808
  }
36809
36809
  var token = match.token, offset = match.offset;
36810
36810
  i1 += offset;
36811
36811
  if (token === " ") {
36812
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
36812
+ return nextMatch = nextMatch1, i = i1, tokens = tokens1, "continue";
36813
36813
  }
36814
36814
  tokens1 = _to_consumable_array$c(tokens1).concat([
36815
36815
  token
@@ -36828,7 +36828,7 @@ function indent(str, spaces) {
36828
36828
  if (contextKeys.some(function(el) {
36829
36829
  return el.startsWith(name);
36830
36830
  })) {
36831
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
36831
+ return nextMatch = nextMatch1, i = i1, tokens = tokens1, "continue";
36832
36832
  }
36833
36833
  if (dateTimeIdentifiers.some(function(el) {
36834
36834
  return el === name;
@@ -36847,9 +36847,9 @@ function indent(str, spaces) {
36847
36847
  if (dateTimeIdentifiers.some(function(el) {
36848
36848
  return el.startsWith(name);
36849
36849
  })) {
36850
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
36850
+ return nextMatch = nextMatch1, i = i1, tokens = tokens1, "continue";
36851
36851
  }
36852
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
36852
+ return nextMatch = nextMatch1, i = i1, tokens = tokens1, {
36853
36853
  v: nextMatch1
36854
36854
  };
36855
36855
  };
@@ -56801,6 +56801,18 @@ class ChatElement extends s$3 {
56801
56801
  }, boost)
56802
56802
  }));
56803
56803
  }
56804
+ canAnswerToMessageBoost(boost) {
56805
+ if (!boost) {
56806
+ return false;
56807
+ }
56808
+ if (boost.checkUrl && !boost.checkUrl.test(window.location.href)) {
56809
+ return false;
56810
+ }
56811
+ if (boost.selector && !document.querySelector(boost.selector)) {
56812
+ return false;
56813
+ }
56814
+ return true;
56815
+ }
56804
56816
  pushMessage(message) {
56805
56817
  this.messages.push(message);
56806
56818
  this.requestUpdate();
@@ -56821,7 +56833,7 @@ class ChatElement extends s$3 {
56821
56833
  return x`
56822
56834
  <section class="container ${this.currentBoost ? 'with-boost' : ''}">
56823
56835
  ${this.messages.map((message)=>x`<section class="${message.role}">
56824
- ${message.role === 'assistant' && message.boost ? x`<ui5-icon
56836
+ ${this.canAnswerToMessageBoost(message.boost) ? x`<ui5-icon
56825
56837
  name="response"
56826
56838
  class="button action"
56827
56839
  @click=${()=>this.answer(message)}
@@ -56868,8 +56880,8 @@ class ChatElement extends s$3 {
56868
56880
 
56869
56881
  <ui5-icon
56870
56882
  name="begin"
56871
- class="button ${this.loading || (!this.messageInput || this.messageInput.value === '') && (!this.currentBoost || this.currentBoost.required) || !this.hasInputsValues() ? 'disabled' : ''}"
56872
- @click=${()=>this.loading || (!this.messageInput || this.messageInput.value === '') && (!this.currentBoost || this.currentBoost.required) || !this.hasInputsValues() ? void 0 : this.addMessage(this.messageInput.value.trim())}
56883
+ class="button ${this.currentBoost && !this.canAnswerToMessageBoost(this.currentBoost) || this.loading || (!this.messageInput || this.messageInput.value === '') && (!this.currentBoost || this.currentBoost.required) || !this.hasInputsValues() ? 'disabled' : ''}"
56884
+ @click=${()=>this.currentBoost && !this.canAnswerToMessageBoost(this.currentBoost) || this.loading || (!this.messageInput || this.messageInput.value === '') && (!this.currentBoost || this.currentBoost.required) || !this.hasInputsValues() ? void 0 : this.addMessage(this.messageInput.value.trim())}
56873
56885
  ></ui5-icon>
56874
56886
  </section>
56875
56887
  `;
@@ -58673,9 +58685,13 @@ class ChatbotElement extends s$3 {
58673
58685
  async loadHistory() {
58674
58686
  const userId = this.userId;
58675
58687
  const reasoning = 'history';
58676
- const messages = await this.executeScene(reasoning, {
58688
+ const messages = (await this.executeScene(reasoning, {
58677
58689
  userId
58678
- });
58690
+ })).map((message)=>_extends({}, message, {
58691
+ boost: message.boost ? _extends({}, message.boost, {
58692
+ checkUrl: message.boost.url ? new RegExp(message.boost.url) : null
58693
+ }) : null
58694
+ }));
58679
58695
  if (messages.length > 0) {
58680
58696
  this.messages = messages;
58681
58697
  }
@@ -58756,6 +58772,7 @@ class ChatbotElement extends s$3 {
58756
58772
  setTimeout(()=>{
58757
58773
  var _this_chatbot_shadowRoot, _this_chatbot;
58758
58774
  ((_this_chatbot = this.chatbot) == null ? void 0 : (_this_chatbot_shadowRoot = _this_chatbot.shadowRoot) == null ? void 0 : _this_chatbot_shadowRoot.querySelector('#messageInput')).focus();
58775
+ this.chatbot.requestUpdate();
58759
58776
  }, 1);
58760
58777
  this.alreadyOpened = true;
58761
58778
  }
@@ -59094,9 +59111,13 @@ class DigipairFullElement extends s$3 {
59094
59111
  async loadHistory() {
59095
59112
  const userId = this.userId;
59096
59113
  const reasoning = 'history';
59097
- const messages = await this.executeScene(reasoning, {
59114
+ const messages = (await this.executeScene(reasoning, {
59098
59115
  userId
59099
- });
59116
+ })).map((message)=>_extends({}, message, {
59117
+ boost: message.boost ? _extends({}, message.boost, {
59118
+ checkUrl: message.boost.url ? new RegExp(message.boost.url) : null
59119
+ }) : null
59120
+ }));
59100
59121
  if (messages.length > 0) {
59101
59122
  this.messages = messages;
59102
59123
  }
@@ -20,6 +20,7 @@ export declare class ChatElement extends LitElement {
20
20
  private keypressManagement;
21
21
  private hasInputsValues;
22
22
  private answer;
23
+ private canAnswerToMessageBoost;
23
24
  pushMessage(message: any): void;
24
25
  render(): TemplateResult;
25
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-web-chatbot",
3
- "version": "0.33.14",
3
+ "version": "0.33.16",
4
4
  "dependencies": {},
5
5
  "typings": "./index.d.ts",
6
6
  "main": "./index.cjs.js",