@meetelise/chat 1.20.237 → 1.20.239

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.20.237",
3
+ "version": "1.20.239",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -133,50 +133,9 @@
133
133
  MEChat.start({
134
134
  organization: "test-company",
135
135
  building: "e2e-test-yardi-building",
136
- onWidgetLoaded: onWidgetLoaded,
137
- // organization: "00f18938-9632-40b9-8d7f-f30e219c94fc",
138
- // building: "19e21cda-d05b-11ee-b3bd-cf9cc1ace7e5",
139
- // 123 Main Street
140
- // organization: "edward-rose",
141
- // building: "rivers-edge-apartments",
142
- // // mobileStyles: {
143
- // // bottom: "100px",
144
- // // },
145
- // // organization: "mill-creek",
146
- // // building: "5ec32c42-2548-11ec-b813-e361780537f5",
147
- // // organization: "d1a1060d-3844-48d4-a454-1ba26292bc69",
148
- // // building: "25feb690-c76f-11ed-83b9-a7aa9698a486",
149
- // // organization: "TT",
150
- // // building: "ffc97070-5c73-11ed-8507-77860136d3bf",
151
- // // AMLI
152
- // organization: "amli",
153
- // building: "6e43581c-c4a4-11ec-a62b-9311f60f23f8",
154
- // organization: "d1a1060d-3844-48d4-a454-1ba26292bc69",
155
- // building: "25fead9e-c76f-11ed-83b2-7b1e7b442e9f",
156
- // // Taylor Street Apartments
157
- // organization: "test-company",
158
- // building: "e2e-test-yardi-building",
159
- // position: {
160
- // bottom: 100,
161
- // left: 0,
162
- // },
163
- // // The Qual People
164
- // // organization: "Pacific Urban Residential",
165
- // // building: "1ac49f90-6150-11ed-b327-1b3f05e7b9db",
166
- // // organization: "Pacific Urban Residential",
167
- // // building: "1ac49f90-6150-11ed-b327-1b3f05e7b9db",
168
- // // Cambridge House
169
- // organization: "elise-ai",
170
- // building: "the-cambridge-house-3",
171
- // // Artistry on 10th
172
- // // organization: "lindy",
173
- // // building: "c4cfc3ec-c4da-11ec-bda4-43aed00ca1b2",
174
- // // brandColor: "#a44ef5",
175
- // // organization: "Pacific Urban Residential",
176
- // // building: "1ac49f90-6150-11ed-b327-1b3f05e7b9db",
177
- // // organization: "sparrow",
178
- // // building: "8e87ae6e-eae8-11ed-aae8-fb82f4692a79",
179
- // });
136
+
137
+ // onWidgetLoaded: onWidgetLoaded,
138
+
180
139
  // MEChat.healthcareStart({
181
140
  // id: "6a9e65e5-9699-4c96-af75-1741d0df79aa",
182
141
  });
@@ -3621,7 +3621,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3621
3621
  transform: rotate(360deg);
3622
3622
  }
3623
3623
  }
3624
- `,Vr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([ae("mini-loader")],Vr);var Qr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let Kr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[],this.isLeadMessage=!1}isMessageStillStreamingChunks(){if(!this.message)return!1;const e=this.message.chunks.find((e=>e.isDone));return!e||this.message.chunks.length===e.order}updated(e){if(this.onMount(),!e.has("message"))return;if(!this.message)return;const{hyperlinks:t,markedText:n}=this.mapAndMarkHyperLinks(this.message.message),i=/(https?:\/\/[^\s]+)/g,r=[],o=[];this.parsedMessage=U`${n.trim().split("\n").map((e=>{const n=this.sanitizeMarkdownText(e),a=this.preserveHTMLTags(n);return a?U`${a.map((e=>{if(t.find((t=>t.id===e))){const n=t.find((t=>t.id===e));if(!n)return;return o.push({redirectTo:null==n?void 0:n.link,source:null==n?void 0:n.link}),U`<a
3624
+ `,Vr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([ae("mini-loader")],Vr);var Qr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let Kr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[],this.isLeadMessage=!1}isMessageStillStreamingChunks(){if(!this.message)return!1;const e=this.message.chunks.find((e=>e.isDone));return!e||this.message.chunks.length===e.order}updated(e){if(this.onMount(),!e.has("message"))return;if(!this.message)return;try{!this.isLeadMessage&&this.invalidMarkdownText(this.message.message)&&si({logType:ai.error,logTitle:"IMPROPER_MARKDOWN",logData:{message:this.message.message}})}catch(e){console.error("Error parsing markdown:",e)}const{hyperlinks:t,markedText:n}=this.mapAndMarkHyperLinks(this.message.message),i=/(https?:\/\/[^\s]+)/g,r=[],o=[];this.parsedMessage=U`${n.trim().split("\n").map((e=>{const n=this.sanitizeMarkdownText(e),a=this.preserveHTMLTags(n);return a?U`${a.map((e=>{if(t.find((t=>t.id===e))){const n=t.find((t=>t.id===e));if(!n)return;return o.push({redirectTo:null==n?void 0:n.link,source:null==n?void 0:n.link}),U`<a
3625
3625
  class="redirect-link"
3626
3626
  href="${null==n?void 0:n.link}"
3627
3627
  target="_blank"
@@ -3633,7 +3633,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3633
3633
  target="_blank"
3634
3634
  rel="noopener noreferrer"
3635
3635
  >${t}
3636
- </a>`}return!this.isLeadMessage&&this.invalidMarkdownText(e)?(si({logType:ai.error,logTitle:"[IMPROPER_MARKDOWN]",logData:{message:this.message,word:e}}),U``):U`${Wr(Gr().sanitize(e))} `}))}<br />`:U``}))}`,this.imagesToDisplay=o,Promise.all(r).then((e=>{this.websitePreviewInfo=e}))}invalidMarkdownText(e){return["*","_","`","~",">","<"].some((t=>e===t))}preserveHTMLTags(e){var t;const n=e.match(/(<\/?[a-z][^>]*>[^<]*<\/?[a-z]*>|[^\s]+[.,?!]?|\S)/gi);return null!==(t=null==n?void 0:n.filter((e=>""!==e.trim())))&&void 0!==t?t:[]}sanitizeMarkdownText(e){return e.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*?)\*\*/gim,"<b>$1</b>").replace(/\*(.*?)\*/gim,"<i>$1</i>").trim()}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>|<a href="[^"]+"(?: target="[^"]*")?>[^<]+<\/a>|\[.*?\]\([^)]*\.[^)]*\)/g)),n=[],i=t.map((t=>{const n=t[0];if(void 0===t.index)return;const i=e[t.index-1],r=e[t.index+n.length];if(n.startsWith("<https")||n.startsWith("<http"))return{matchedLink:n,link:n.split("|")[0].replace("<",""),hyperlink:n.split("|")[1].replace(">",""),addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)};if(n.startsWith("<a href=")){const e=n.match(/href="([^"]+)"/),t=n.match(/>[^<]+</);return{matchedLink:n,link:e?e[1]:"",hyperlink:t?t[0].slice(1,-1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}{const[e,t]=n.split("](");return{matchedLink:n,link:t?t.slice(0,-1):"",hyperlink:e?e.slice(1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}}));return i.forEach((t=>{if(t&&t.link&&t.hyperlink){const i=Ir().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(t.link),hyperlink:this.removeTrailingPunctuation(t.hyperlink),mark:t.matchedLink,id:i}),e=e.replace(t.matchedLink,`${t.addSpaceBefore?" ":""}${i}${t.addSpaceAfter?" ":""}`)}})),{hyperlinks:n,markedText:e}}async getLinkData(e){var n,i,r,o;try{const a=(await t().get(e)).data,s=(new DOMParser).parseFromString(a,"text/html");return s?{title:null!==(i=null===(n=s.querySelector("title"))||void 0===n?void 0:n.textContent)&&void 0!==i?i:null,description:(null===(r=s.querySelector('meta[name="description"]'))||void 0===r?void 0:r.getAttribute("content"))||null,image:(null===(o=s.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:null,link:e}:{title:null,description:null,image:null,favicon:null,link:e}}catch(t){return console.error("Error fetching website details:",t),{title:null,description:null,image:null,favicon:null,link:e}}}render(){return this.message?U`<div class="message-inner-body">
3636
+ </a>`}return U`${Wr(Gr().sanitize(e))} `}))}<br />`:U``}))}`,this.imagesToDisplay=o,Promise.all(r).then((e=>{this.websitePreviewInfo=e}))}invalidMarkdownText(e){try{return[/\*\*[^*]*$/,/__[^_]*$/,/`[^`]*$/,/\[[^\]]*$/,/\[[^\]]*\]\([^)]*$/,/^(#+)\s*$/,/(^|[^!])\[[^\]]*\]\(([^)]+)\s*$/,/(?:^|\s)[*_]{1,2}(?:\s|$)/].some((t=>t.test(e)))}catch(e){return!1}}preserveHTMLTags(e){var t;const n=e.match(/(<\/?[a-z][^>]*>[^<]*<\/?[a-z]*>|[^\s]+[.,?!]?|\S)/gi);return null!==(t=null==n?void 0:n.filter((e=>""!==e.trim())))&&void 0!==t?t:[]}sanitizeMarkdownText(e){return e.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*?)\*\*/gim,"<b>$1</b>").replace(/\*(.*?)\*/gim,"<i>$1</i>").trim()}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>|<a href="[^"]+"(?: target="[^"]*")?>[^<]+<\/a>|\[.*?\]\([^)]*\.[^)]*\)/g)),n=[],i=t.map((t=>{const n=t[0];if(void 0===t.index)return;const i=e[t.index-1],r=e[t.index+n.length];if(n.startsWith("<https")||n.startsWith("<http"))return{matchedLink:n,link:n.split("|")[0].replace("<",""),hyperlink:n.split("|")[1].replace(">",""),addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)};if(n.startsWith("<a href=")){const e=n.match(/href="([^"]+)"/),t=n.match(/>[^<]+</);return{matchedLink:n,link:e?e[1]:"",hyperlink:t?t[0].slice(1,-1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}{const[e,t]=n.split("](");return{matchedLink:n,link:t?t.slice(0,-1):"",hyperlink:e?e.slice(1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}}));return i.forEach((t=>{if(t&&t.link&&t.hyperlink){const i=Ir().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(t.link),hyperlink:this.removeTrailingPunctuation(t.hyperlink),mark:t.matchedLink,id:i}),e=e.replace(t.matchedLink,`${t.addSpaceBefore?" ":""}${i}${t.addSpaceAfter?" ":""}`)}})),{hyperlinks:n,markedText:e}}async getLinkData(e){var n,i,r,o;try{const a=(await t().get(e)).data,s=(new DOMParser).parseFromString(a,"text/html");return s?{title:null!==(i=null===(n=s.querySelector("title"))||void 0===n?void 0:n.textContent)&&void 0!==i?i:null,description:(null===(r=s.querySelector('meta[name="description"]'))||void 0===r?void 0:r.getAttribute("content"))||null,image:(null===(o=s.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:null,link:e}:{title:null,description:null,image:null,favicon:null,link:e}}catch(t){return console.error("Error fetching website details:",t),{title:null,description:null,image:null,favicon:null,link:e}}}render(){return this.message?U`<div class="message-inner-body">
3637
3637
  ${this.isMessageStillStreamingChunks()?U`<div class="message-loader"><mini-loader></mini-loader></div>`:""}
3638
3638
  <p
3639
3639
  class=${fe({"message-text":!0,"webchat-font__desktop":!dn(),"webchat-font__mobile":dn()})}
@@ -85,6 +85,24 @@ export class PubnubMessage extends LitElement {
85
85
  this.onMount();
86
86
  if (!changedProperties.has("message")) return;
87
87
  if (!this.message) return;
88
+
89
+ try {
90
+ if (
91
+ !this.isLeadMessage &&
92
+ this.invalidMarkdownText(this.message.message)
93
+ ) {
94
+ sendLoggingEvent({
95
+ logType: LogType.error,
96
+ logTitle: "IMPROPER_MARKDOWN",
97
+ logData: { message: this.message.message },
98
+ });
99
+ //return html``;
100
+ }
101
+ } catch (error) {
102
+ // eslint-disable-next-line no-console
103
+ console.error("Error parsing markdown:", error);
104
+ }
105
+
88
106
  const { hyperlinks, markedText } = this.mapAndMarkHyperLinks(
89
107
  this.message.message
90
108
  );
@@ -127,15 +145,6 @@ export class PubnubMessage extends LitElement {
127
145
  >${link}
128
146
  </a>`;
129
147
  } else {
130
- if (!this.isLeadMessage && this.invalidMarkdownText(word)) {
131
- sendLoggingEvent({
132
- logType: LogType.error,
133
- logTitle: "[IMPROPER_MARKDOWN]",
134
- logData: { message: this.message, word },
135
- });
136
- return html``;
137
- }
138
-
139
148
  return html`${unsafeHTML(DOMPurify.sanitize(word))} `;
140
149
  }
141
150
  })}<br />`;
@@ -147,8 +156,22 @@ export class PubnubMessage extends LitElement {
147
156
  }
148
157
 
149
158
  private invalidMarkdownText(text: string): boolean {
150
- const invalidChars = ["*", "_", "`", "~", ">", "<"];
151
- return invalidChars.some((char) => text === char);
159
+ try {
160
+ const markdownErrors = [
161
+ /\*\*[^*]*$/, // Unclosed bold
162
+ /__[^_]*$/, // Unclosed italic
163
+ /`[^`]*$/, // Unclosed code
164
+ /\[[^\]]*$/, // Unclosed link text
165
+ /\[[^\]]*\]\([^)]*$/, // Unclosed link URL
166
+ /^(#+)\s*$/, // Header without text
167
+ /(^|[^!])\[[^\]]*\]\(([^)]+)\s*$/, // Improperly formatted link
168
+ /(?:^|\s)[*_]{1,2}(?:\s|$)/, // Improper use of bold or italic
169
+ ];
170
+
171
+ return markdownErrors.some((regex) => regex.test(text));
172
+ } catch (error) {
173
+ return false;
174
+ }
152
175
  }
153
176
 
154
177
  private preserveHTMLTags(text: string): string[] {