ai-error-assistant-pro 0.0.6 → 0.0.7

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.
@@ -6564,7 +6564,7 @@ if (typeof window !== 'undefined') {
6564
6564
  // Indicate to webpack that this file can be concatenated
6565
6565
  /* harmony default export */ var setPublicPath = (null);
6566
6566
 
6567
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/main.vue?vue&type=template&id=63ef79ac&scoped=true
6567
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/main.vue?vue&type=template&id=3f590f5c&scoped=true
6568
6568
  var render = function render() {
6569
6569
  var _vm = this,
6570
6570
  _c = _vm._self._c;
@@ -6581,7 +6581,11 @@ var render = function render() {
6581
6581
  }
6582
6582
  }, [_c('i', {
6583
6583
  staticClass: "el-icon-close"
6584
- })])]), _c('div', {
6584
+ })])]), !_vm.courseFlag ? _c('div', {
6585
+ staticClass: "message-wrap"
6586
+ }, [_c('div', {
6587
+ staticClass: "message-line"
6588
+ }, [_vm._v(_vm._s(_vm.message))])]) : [_c('div', {
6585
6589
  staticClass: "ai-main-content"
6586
6590
  }, [_c('chat', {
6587
6591
  ref: "chatRef",
@@ -6638,7 +6642,7 @@ var render = function render() {
6638
6642
  }
6639
6643
  })])], 1), _c('p', {
6640
6644
  staticClass: "disclaimer"
6641
- }, [_vm._v(" 此功能公测期间对正式版用户开放 ")])]) : _vm._e();
6645
+ }, [_vm._v(" 此功能公测期间对正式版用户开放 ")])]], 2) : _vm._e();
6642
6646
  };
6643
6647
  var staticRenderFns = [function () {
6644
6648
  var _vm = this,
@@ -6659,10 +6663,10 @@ var staticRenderFns = [function () {
6659
6663
  }, [_vm._v("智能解析")])]);
6660
6664
  }];
6661
6665
 
6662
- ;// CONCATENATED MODULE: ./components/demo/src/main.vue?vue&type=template&id=63ef79ac&scoped=true
6666
+ ;// CONCATENATED MODULE: ./components/demo/src/main.vue?vue&type=template&id=3f590f5c&scoped=true
6663
6667
 
6664
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat.vue?vue&type=template&id=8e426b78&scoped=true
6665
- var chatvue_type_template_id_8e426b78_scoped_true_render = function render() {
6668
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat.vue?vue&type=template&id=d21026be&scoped=true
6669
+ var chatvue_type_template_id_d21026be_scoped_true_render = function render() {
6666
6670
  var _vm = this,
6667
6671
  _c = _vm._self._c;
6668
6672
  return _c('div', {
@@ -6699,9 +6703,9 @@ var chatvue_type_template_id_8e426b78_scoped_true_render = function render() {
6699
6703
  }
6700
6704
  }), list.type === 'robot' && list.links.length > 0 ? _c('div', {
6701
6705
  staticClass: "link"
6702
- }, [_c('div', {
6706
+ }, [!list.allIdWithStart ? _c('div', [_c('div', {
6703
6707
  staticClass: "link-title"
6704
- }, [_vm._v("相关链接")]), _c('div', {
6708
+ }, [_vm._v("参考文件")]), _c('div', {
6705
6709
  staticClass: "link-content"
6706
6710
  }, [_vm._l(list.links, function (item) {
6707
6711
  return [!item.title.startsWith(_vm.chatMajorId) ? _c('div', {
@@ -6712,11 +6716,43 @@ var chatvue_type_template_id_8e426b78_scoped_true_render = function render() {
6712
6716
  "target": "_blank"
6713
6717
  }
6714
6718
  }, [_c('span', [_vm._v(_vm._s(item.title))])])]) : _vm._e()];
6715
- })], 2)]) : _vm._e(), list.type === 'robot' ? _c('chat-tools', {
6719
+ })], 2)]) : _vm._e()]) : _vm._e(), list.type === 'robot' && list.connectUrl.length > 0 ? _c('div', {
6720
+ staticClass: "link"
6721
+ }, [_c('div', {
6722
+ staticClass: "link-title"
6723
+ }, [_vm._v("相关链接")]), _c('div', {
6724
+ staticClass: "link-content"
6725
+ }, [_vm._l(list.connectUrl, function (item) {
6726
+ return [_c('div', {
6727
+ staticClass: "links"
6728
+ }, [_c('a', {
6729
+ attrs: {
6730
+ "href": item.iaUrl,
6731
+ "target": "_blank"
6732
+ }
6733
+ }, [_c('span', [_vm._v(_vm._s(item.iaUrlName))])])])];
6734
+ })], 2)]) : _vm._e(), list.type === 'robot' && _vm.finish && list.followUps && list.followUps.length > 0 ? _c('div', [_c('div', {
6735
+ staticClass: "link-title"
6736
+ }, [_vm._v("智能追问")]), _c('div', {
6737
+ staticClass: "link-content"
6738
+ }, _vm._l(list.followUps, function (list, index) {
6739
+ return _c('div', {
6740
+ key: index,
6741
+ staticClass: "hot-list",
6742
+ on: {
6743
+ "click": function ($event) {
6744
+ return _vm.selectModule(list);
6745
+ }
6746
+ }
6747
+ }, [_vm._v(" " + _vm._s(list) + " "), _c('i', {
6748
+ staticClass: "el-icon-arrow-right go-icon"
6749
+ })]);
6750
+ }), 0)]) : _vm._e(), list.type === 'robot' ? _c('chat-tools', {
6716
6751
  attrs: {
6717
6752
  "chatId": _vm.chatId,
6718
6753
  "detail-data": list,
6719
- "sending": list.sending
6754
+ "sending": list.sending,
6755
+ "is-last": index === _vm.messageData.length - 1
6720
6756
  },
6721
6757
  on: {
6722
6758
  "on-reanswer": list => _vm.reanswer(list, index),
@@ -6725,7 +6761,7 @@ var chatvue_type_template_id_8e426b78_scoped_true_render = function render() {
6725
6761
  }) : _vm._e()], 1)]);
6726
6762
  })], 2);
6727
6763
  };
6728
- var chatvue_type_template_id_8e426b78_scoped_true_staticRenderFns = [];
6764
+ var chatvue_type_template_id_d21026be_scoped_true_staticRenderFns = [];
6729
6765
 
6730
6766
  ;// CONCATENATED MODULE: ./node_modules/axios/lib/helpers/bind.js
6731
6767
 
@@ -10500,17 +10536,17 @@ const iv = crypto_js_default().enc.Utf8.parse(n);
10500
10536
  // 解密方法
10501
10537
  function decrypt(word) {
10502
10538
  const stringToEncode = 'Hello, World!'; // 要进行 Base64 编码的字符串
10503
- const encodedString = gBase64.encode(stringToEncode); // 进行 Base64 编码
10504
- const decodedString = gBase64.decode(encodedString); // 进行 Base64 解码
10539
+ const encodedString = Base64.encode(stringToEncode); // 进行 Base64 编码
10540
+ const decodedString = Base64.decode(encodedString); // 进行 Base64 解码
10505
10541
 
10506
- let base64 = crypto_js_default().enc.Base64.parse(word);
10507
- let src = crypto_js_default().enc.Base64.stringify(base64);
10508
- let decrypt = crypto_js_default().AES.decrypt(src, key, {
10542
+ let base64 = CryptoJS.enc.Base64.parse(word);
10543
+ let src = CryptoJS.enc.Base64.stringify(base64);
10544
+ let decrypt = CryptoJS.AES.decrypt(src, key, {
10509
10545
  iv: iv,
10510
- mode: (crypto_js_default()).mode.CBC,
10511
- padding: (crypto_js_default()).pad.Pkcs7
10546
+ mode: CryptoJS.mode.CBC,
10547
+ padding: CryptoJS.pad.Pkcs7
10512
10548
  });
10513
- let decryptedStr = decrypt.toString((crypto_js_default()).enc.Utf8);
10549
+ let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
10514
10550
  return decryptedStr.toString();
10515
10551
  }
10516
10552
  ;// CONCATENATED MODULE: ./components/demo/utils/constants.js
@@ -10544,7 +10580,9 @@ const service = lib_axios.create({
10544
10580
  });
10545
10581
  service.interceptors.request.use(config => {
10546
10582
  if (cache.session.getJSON('SRKJ_TOKEN_CACHE')) {
10547
- config.headers["X-Id-Token"] = cache.session.getJSON('SRKJ_TOKEN_CACHE');
10583
+ // config.headers["X-Id-Token"] = cache.session.getJSON('SRKJ_TOKEN_CACHE');
10584
+ if (!config.params) config.params = {};
10585
+ config.params.token = cache.session.getJSON('SRKJ_TOKEN_CACHE');
10548
10586
  }
10549
10587
  // 是否需要防止数据重复提交
10550
10588
  const isRepeatSubmit = (config.headers || {}).repeatSubmit === false;
@@ -10577,12 +10615,12 @@ service.interceptors.response.use(res => {
10577
10615
  return res.data;
10578
10616
  }
10579
10617
  let srkjData = res.data;
10580
- if (srkjData) {
10581
- const respData = decrypt(srkjData);
10582
- try {
10583
- srkjData = JSON.parse(respData);
10584
- } catch (e) {}
10585
- }
10618
+ // if (srkjData) {
10619
+ // const respData = decrypt(srkjData);
10620
+ // try {
10621
+ // srkjData = JSON.parse(respData);
10622
+ // } catch (e) {}
10623
+ // }
10586
10624
  if (res.status === 401) {
10587
10625
  external_element_ui_.Message.warning(srkjData.message.description);
10588
10626
  return;
@@ -10592,7 +10630,7 @@ service.interceptors.response.use(res => {
10592
10630
  }
10593
10631
  return srkjData.queryData || srkjData.data || srkjData.token;
10594
10632
  });
10595
- /* harmony default export */ var request = (service);
10633
+ /* harmony default export */ var utils_request = (service);
10596
10634
  ;// CONCATENATED MODULE: ./node_modules/@microsoft/fetch-event-source/lib/esm/parse.js
10597
10635
  async function getBytes(stream, onChunk) {
10598
10636
  const reader = stream.getReader();
@@ -10798,11 +10836,14 @@ function defaultOnOpen(response) {
10798
10836
 
10799
10837
 
10800
10838
 
10839
+
10801
10840
  const baseURL = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_BASE_URL') || constants.publicPath;
10802
- const prefix = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_PRE_FIX') || constants.publicPrefix;
10841
+ let prefix = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_PRE_FIX') || constants.publicPrefix;
10803
10842
 
10843
+ // 0.0.7 版本接口升级
10844
+ prefix += '/plugin/v2';
10804
10845
  const ssoAuth = token => {
10805
- return request({
10846
+ return utils_request({
10806
10847
  url: prefix + '/sso/assistant',
10807
10848
  method: 'get',
10808
10849
  params: {
@@ -10818,14 +10859,14 @@ const authUser = headers => {
10818
10859
  });
10819
10860
  };
10820
10861
  const erranalysis = data => {
10821
- return request({
10862
+ return utils_request({
10822
10863
  url: prefix + '/erranalysis/send',
10823
10864
  method: 'post',
10824
10865
  data
10825
10866
  });
10826
10867
  };
10827
10868
  const retryAnalysis = errId => {
10828
- return request({
10869
+ return utils_request({
10829
10870
  url: prefix + '/erranalysis/retry',
10830
10871
  method: 'post',
10831
10872
  params: {
@@ -10834,39 +10875,58 @@ const retryAnalysis = errId => {
10834
10875
  });
10835
10876
  };
10836
10877
  const chatEvaluateAdd = params => {
10837
- return request({
10878
+ return utils_request({
10838
10879
  url: prefix + `/assistant/chatEvaluateAdd`,
10839
10880
  method: 'post',
10840
10881
  data: params
10841
10882
  });
10842
10883
  };
10843
10884
  const stopChat = chatId => {
10844
- return request({
10885
+ return utils_request({
10845
10886
  url: prefix + `/assistant/stop/${chatId}`,
10846
10887
  method: 'post'
10847
10888
  });
10848
10889
  };
10849
10890
  const chatEvaluateCancel = params => {
10850
- return request({
10891
+ return utils_request({
10851
10892
  url: prefix + `/assistant/chatEvaluateCancel`,
10852
10893
  method: 'post',
10853
10894
  data: params
10854
10895
  });
10855
10896
  };
10856
10897
  const chartClear = chatId => {
10857
- return request({
10898
+ return utils_request({
10858
10899
  url: prefix + `/assistant/chartClear/${chatId}`,
10859
10900
  method: 'post'
10860
10901
  });
10861
10902
  };
10903
+ const checkCourseIdIsExist = resId => {
10904
+ return utils_request({
10905
+ url: prefix + `/ia/hasPermission?courseId=${resId}`,
10906
+ method: 'get'
10907
+ });
10908
+ };
10909
+
10910
+ /**
10911
+ * 自动追问
10912
+ * @param iaId 请求参数id
10913
+ * @param message 对话对
10914
+ * @returns 返回节点详情数据
10915
+ */
10916
+ async function getAutoQuestioning(iaId, message) {
10917
+ return utils_request.post(`${prefix}/ia/autoFollowUp`, {
10918
+ iaId,
10919
+ messages: message
10920
+ });
10921
+ }
10862
10922
  async function sendMessageEventSource(params, signal, onmessage) {
10863
- return fetchEventSource(`${baseURL}${prefix}/assistant/conversation`, {
10923
+ return fetchEventSource(`${baseURL}${prefix}/assistant/conversation?token=${cache.session.getJSON('SRKJ_TOKEN_CACHE')}`, {
10864
10924
  method: 'POST',
10865
10925
  signal: signal,
10866
10926
  openWhenHidden: true,
10867
10927
  headers: {
10868
- 'Content-Type': 'application/json',
10869
- 'X-Id-Token': cache.session.getJSON('SRKJ_TOKEN_CACHE')
10928
+ 'Content-Type': 'application/json'
10929
+ // 'X-Id-Token': cache.session.getJSON('SRKJ_TOKEN_CACHE'),
10870
10930
  },
10871
10931
  body: JSON.stringify(params),
10872
10932
  onmessage
@@ -10874,7 +10934,7 @@ async function sendMessageEventSource(params, signal, onmessage) {
10874
10934
  }
10875
10935
  ;// CONCATENATED MODULE: ./components/demo/utils/config.js
10876
10936
 
10877
-
10937
+ // import constants from '../utils/constants';
10878
10938
 
10879
10939
  const errorList = [{
10880
10940
  name: "格式问题",
@@ -10934,25 +10994,29 @@ const cacheMessageList = [{
10934
10994
  // studentAnswer: '错误的简答题简答题错误错误的简答题简答题错误错误的简答题简答题错误错误的简答题简答题错误',
10935
10995
  // }
10936
10996
 
10997
+ // export const getUserInfo = async (token) => {
10998
+ // const ssoRes = await ssoAuth(token);
10999
+ // const userRes = await authUser({
11000
+ // 'X-Auth-User': encodeURIComponent(ssoRes.name),
11001
+ // 'X-Auth-Token': ssoRes.password,
11002
+ // 'X-Enterprise-Id': `${constants['X-Enterprise-Id']}`,
11003
+ // 'X-App-Id': `${constants['X-App-Id']}`,
11004
+ // 'X-App-Secret': `${constants['X-App-Secret']}`,
11005
+ // 'X-Auth-User-Type': '1',
11006
+ // });
11007
+ // cache.session.setJSON('SRKJ_TOKEN_CACHE', userRes);
11008
+ // }
10937
11009
  const getUserInfo = async token => {
10938
- const ssoRes = await ssoAuth(token);
10939
- const userRes = await authUser({
10940
- 'X-Auth-User': encodeURIComponent(ssoRes.name),
10941
- 'X-Auth-Token': ssoRes.password,
10942
- 'X-Enterprise-Id': `${constants['X-Enterprise-Id']}`,
10943
- 'X-App-Id': `${constants['X-App-Id']}`,
10944
- 'X-App-Secret': `${constants['X-App-Secret']}`,
10945
- 'X-Auth-User-Type': '1'
10946
- });
10947
- cache.session.setJSON('SRKJ_TOKEN_CACHE', userRes);
11010
+ await ssoAuth(token);
11011
+ cache.session.setJSON('SRKJ_TOKEN_CACHE', token);
10948
11012
  };
10949
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat-tools.vue?vue&type=template&id=65c1d3ae&scoped=true
10950
- var chat_toolsvue_type_template_id_65c1d3ae_scoped_true_render = function render() {
11013
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat-tools.vue?vue&type=template&id=a40a67cc&scoped=true
11014
+ var chat_toolsvue_type_template_id_a40a67cc_scoped_true_render = function render() {
10951
11015
  var _vm = this,
10952
11016
  _c = _vm._self._c;
10953
11017
  return _vm.listData ? _c('div', {
10954
11018
  staticClass: "robot-tools"
10955
- }, [_vm.listData.stop || _vm.listData.finish || _vm.type === 'error' && !_vm.sending ? _c('div', {
11019
+ }, [(_vm.listData.stop || _vm.listData.finish || _vm.type === 'error' && !_vm.sending) && _vm.isLast ? _c('div', {
10956
11020
  staticClass: "robot-reanswer",
10957
11021
  staticStyle: {
10958
11022
  "margin-bottom": "8px"
@@ -11109,9 +11173,9 @@ var chat_toolsvue_type_template_id_65c1d3ae_scoped_true_render = function render
11109
11173
  }
11110
11174
  }, [_vm._v("提交")])], 1)], 1)])])], 1)]) : _vm._e();
11111
11175
  };
11112
- var chat_toolsvue_type_template_id_65c1d3ae_scoped_true_staticRenderFns = [];
11176
+ var chat_toolsvue_type_template_id_a40a67cc_scoped_true_staticRenderFns = [];
11113
11177
 
11114
- ;// CONCATENATED MODULE: ./components/demo/src/chat-tools.vue?vue&type=template&id=65c1d3ae&scoped=true
11178
+ ;// CONCATENATED MODULE: ./components/demo/src/chat-tools.vue?vue&type=template&id=a40a67cc&scoped=true
11115
11179
 
11116
11180
  ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat-tools.vue?vue&type=script&lang=js
11117
11181
 
@@ -11134,6 +11198,10 @@ var chat_toolsvue_type_template_id_65c1d3ae_scoped_true_staticRenderFns = [];
11134
11198
  sending: {
11135
11199
  type: Boolean,
11136
11200
  default: false
11201
+ },
11202
+ isLast: {
11203
+ type: Boolean,
11204
+ default: false
11137
11205
  }
11138
11206
  },
11139
11207
  data() {
@@ -11208,10 +11276,10 @@ var chat_toolsvue_type_template_id_65c1d3ae_scoped_true_staticRenderFns = [];
11208
11276
  });
11209
11277
  ;// CONCATENATED MODULE: ./components/demo/src/chat-tools.vue?vue&type=script&lang=js
11210
11278
  /* harmony default export */ var src_chat_toolsvue_type_script_lang_js = (chat_toolsvue_type_script_lang_js);
11211
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat-tools.vue?vue&type=style&index=0&id=65c1d3ae&prod&lang=scss&scoped=true
11279
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat-tools.vue?vue&type=style&index=0&id=a40a67cc&prod&lang=scss&scoped=true
11212
11280
  // extracted by mini-css-extract-plugin
11213
11281
 
11214
- ;// CONCATENATED MODULE: ./components/demo/src/chat-tools.vue?vue&type=style&index=0&id=65c1d3ae&prod&lang=scss&scoped=true
11282
+ ;// CONCATENATED MODULE: ./components/demo/src/chat-tools.vue?vue&type=style&index=0&id=a40a67cc&prod&lang=scss&scoped=true
11215
11283
 
11216
11284
  ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
11217
11285
  /* globals __VUE_SSR_CONTEXT__ */
@@ -11322,18 +11390,18 @@ function normalizeComponent(
11322
11390
 
11323
11391
  var component = normalizeComponent(
11324
11392
  src_chat_toolsvue_type_script_lang_js,
11325
- chat_toolsvue_type_template_id_65c1d3ae_scoped_true_render,
11326
- chat_toolsvue_type_template_id_65c1d3ae_scoped_true_staticRenderFns,
11393
+ chat_toolsvue_type_template_id_a40a67cc_scoped_true_render,
11394
+ chat_toolsvue_type_template_id_a40a67cc_scoped_true_staticRenderFns,
11327
11395
  false,
11328
11396
  null,
11329
- "65c1d3ae",
11397
+ "a40a67cc",
11330
11398
  null
11331
11399
 
11332
11400
  )
11333
11401
 
11334
11402
  /* harmony default export */ var chat_tools = (component.exports);
11335
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/error-chat.vue?vue&type=template&id=3c02c55c&scoped=true
11336
- var error_chatvue_type_template_id_3c02c55c_scoped_true_render = function render() {
11403
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/error-chat.vue?vue&type=template&id=72bccb65&scoped=true
11404
+ var error_chatvue_type_template_id_72bccb65_scoped_true_render = function render() {
11337
11405
  var _vm = this,
11338
11406
  _c = _vm._self._c;
11339
11407
  return _c('div', {
@@ -11449,9 +11517,9 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_render = function render
11449
11517
  domProps: {
11450
11518
  "innerHTML": _vm._s(_vm.analysisData.reason)
11451
11519
  }
11452
- }), _vm.analysisData.recommend && _vm.analysisData.recommend.length > 0 ? _c('div', {
11520
+ }), _vm.analysisData.recommend && _vm.analysisData.recommend.length > 0 && !_vm.allIdWithStart ? _c('div', {
11453
11521
  staticClass: "title-label"
11454
- }, [_vm._v("推荐资料")]) : _vm._e(), _c('div', {
11522
+ }, [_vm._v(" 推荐资料 ")]) : _vm._e(), _c('div', {
11455
11523
  staticClass: "answer-content"
11456
11524
  }, _vm._l(_vm.analysisData.recommend, function (list, index) {
11457
11525
  return _c('div', {
@@ -11459,12 +11527,12 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_render = function render
11459
11527
  staticStyle: {
11460
11528
  "margin-bottom": "8px"
11461
11529
  }
11462
- }, [_c('a', {
11530
+ }, [!list.title.startsWith(_vm.chatMajorId) ? _c('a', {
11463
11531
  attrs: {
11464
11532
  "href": 'https://ai-yuliao.hep.com.cn' + list.url,
11465
11533
  "target": "_blank"
11466
11534
  }
11467
- }, [_vm._v(_vm._s(list.title))])]);
11535
+ }, [_vm._v(_vm._s(list.title) + " ")]) : _vm._e()]);
11468
11536
  }), 0), _c('chat-tools', {
11469
11537
  attrs: {
11470
11538
  "type": "error",
@@ -11476,7 +11544,7 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_render = function render
11476
11544
  }
11477
11545
  })], 1)]);
11478
11546
  };
11479
- var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [function () {
11547
+ var error_chatvue_type_template_id_72bccb65_scoped_true_staticRenderFns = [function () {
11480
11548
  var _vm = this,
11481
11549
  _c = _vm._self._c;
11482
11550
  return _c('div', {
@@ -11495,7 +11563,7 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
11495
11563
  })]);
11496
11564
  }];
11497
11565
 
11498
- ;// CONCATENATED MODULE: ./components/demo/src/error-chat.vue?vue&type=template&id=3c02c55c&scoped=true
11566
+ ;// CONCATENATED MODULE: ./components/demo/src/error-chat.vue?vue&type=template&id=72bccb65&scoped=true
11499
11567
 
11500
11568
  ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/error-chat.vue?vue&type=script&lang=js
11501
11569
 
@@ -11514,7 +11582,11 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
11514
11582
  // 记录页面点赞 踩情况
11515
11583
  analysisData: {},
11516
11584
  // 记录页面点赞 踩情况
11517
- chatId: '' // 对话id
11585
+ chatId: '',
11586
+ // 对话id
11587
+ chatMajorId: '',
11588
+ // 智能体id
11589
+ allIdWithStart: true // 智能体id
11518
11590
  };
11519
11591
  },
11520
11592
  watch: {
@@ -11548,6 +11620,7 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
11548
11620
  }],
11549
11621
  xhModelDetailVoList
11550
11622
  } = analysisRes;
11623
+ if (xhModelDetailVoList) this.chatMajorId = xhModelDetailVoList[0].chatMajorId;
11551
11624
  // 传入工具中的值
11552
11625
  this.chatId = chatId;
11553
11626
  this.detailData = {
@@ -11559,6 +11632,11 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
11559
11632
  try {
11560
11633
  this.analysisData = JSON.parse(content);
11561
11634
  this.detailData.errId = errId;
11635
+ for (let item of this.analysisData.recommend) {
11636
+ if (!item.title.startsWith(this.chatMajorId)) {
11637
+ this.allIdWithStart = false;
11638
+ }
11639
+ }
11562
11640
  } catch (e) {
11563
11641
  this.$message.warning('解析失败' + e);
11564
11642
  this.analysisData = {
@@ -11567,7 +11645,7 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
11567
11645
  console.log(e);
11568
11646
  }
11569
11647
  } catch (e) {
11570
- return new Error(e);
11648
+ throw new Error(e);
11571
11649
  }
11572
11650
  },
11573
11651
  async reanswer(list) {
@@ -11610,10 +11688,10 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
11610
11688
  });
11611
11689
  ;// CONCATENATED MODULE: ./components/demo/src/error-chat.vue?vue&type=script&lang=js
11612
11690
  /* harmony default export */ var src_error_chatvue_type_script_lang_js = (error_chatvue_type_script_lang_js);
11613
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/error-chat.vue?vue&type=style&index=0&id=3c02c55c&prod&lang=scss&scoped=true
11691
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/error-chat.vue?vue&type=style&index=0&id=72bccb65&prod&lang=scss&scoped=true
11614
11692
  // extracted by mini-css-extract-plugin
11615
11693
 
11616
- ;// CONCATENATED MODULE: ./components/demo/src/error-chat.vue?vue&type=style&index=0&id=3c02c55c&prod&lang=scss&scoped=true
11694
+ ;// CONCATENATED MODULE: ./components/demo/src/error-chat.vue?vue&type=style&index=0&id=72bccb65&prod&lang=scss&scoped=true
11617
11695
 
11618
11696
  ;// CONCATENATED MODULE: ./components/demo/src/error-chat.vue
11619
11697
 
@@ -11626,175 +11704,2664 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
11626
11704
 
11627
11705
  var error_chat_component = normalizeComponent(
11628
11706
  src_error_chatvue_type_script_lang_js,
11629
- error_chatvue_type_template_id_3c02c55c_scoped_true_render,
11630
- error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns,
11707
+ error_chatvue_type_template_id_72bccb65_scoped_true_render,
11708
+ error_chatvue_type_template_id_72bccb65_scoped_true_staticRenderFns,
11631
11709
  false,
11632
11710
  null,
11633
- "3c02c55c",
11711
+ "72bccb65",
11634
11712
  null
11635
11713
 
11636
11714
  )
11637
11715
 
11638
11716
  /* harmony default export */ var error_chat = (error_chat_component.exports);
11639
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat.vue?vue&type=script&lang=js
11640
-
11717
+ ;// CONCATENATED MODULE: ./node_modules/marked/lib/marked.esm.js
11718
+ /**
11719
+ * marked v14.1.2 - a markdown parser
11720
+ * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
11721
+ * https://github.com/markedjs/marked
11722
+ */
11641
11723
 
11724
+ /**
11725
+ * DO NOT EDIT THIS FILE
11726
+ * The code in this file is generated from files in ./src/
11727
+ */
11642
11728
 
11729
+ /**
11730
+ * Gets the original marked default options.
11731
+ */
11732
+ function _getDefaults() {
11733
+ return {
11734
+ async: false,
11735
+ breaks: false,
11736
+ extensions: null,
11737
+ gfm: true,
11738
+ hooks: null,
11739
+ pedantic: false,
11740
+ renderer: null,
11741
+ silent: false,
11742
+ tokenizer: null,
11743
+ walkTokens: null
11744
+ };
11745
+ }
11746
+ let _defaults = _getDefaults();
11747
+ function changeDefaults(newDefaults) {
11748
+ _defaults = newDefaults;
11749
+ }
11643
11750
 
11644
- const controller = new AbortController();
11645
- const signal = controller.signal;
11646
- /* harmony default export */ var chatvue_type_script_lang_js = ({
11647
- name: 'Chat',
11648
- components: {
11649
- ErrorChat: error_chat,
11650
- ChatTools: chat_tools
11651
- },
11652
- props: {
11653
- analyExercise: {},
11654
- keyWord: {
11655
- type: String,
11656
- default: ''
11657
- },
11658
- resId: {
11659
- type: String,
11660
- default: ''
11751
+ /**
11752
+ * Helpers
11753
+ */
11754
+ const escapeTest = /[&<>"']/;
11755
+ const escapeReplace = new RegExp(escapeTest.source, 'g');
11756
+ const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
11757
+ const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g');
11758
+ const escapeReplacements = {
11759
+ '&': '&amp;',
11760
+ '<': '&lt;',
11761
+ '>': '&gt;',
11762
+ '"': '&quot;',
11763
+ "'": '&#39;'
11764
+ };
11765
+ const getEscapeReplacement = ch => escapeReplacements[ch];
11766
+ function escape$1(html, encode) {
11767
+ if (encode) {
11768
+ if (escapeTest.test(html)) {
11769
+ return html.replace(escapeReplace, getEscapeReplacement);
11770
+ }
11771
+ } else {
11772
+ if (escapeTestNoEncode.test(html)) {
11773
+ return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
11774
+ }
11775
+ }
11776
+ return html;
11777
+ }
11778
+ const caret = /(^|[^\[])\^/g;
11779
+ function edit(regex, opt) {
11780
+ let source = typeof regex === 'string' ? regex : regex.source;
11781
+ opt = opt || '';
11782
+ const obj = {
11783
+ replace: (name, val) => {
11784
+ let valSource = typeof val === 'string' ? val : val.source;
11785
+ valSource = valSource.replace(caret, '$1');
11786
+ source = source.replace(name, valSource);
11787
+ return obj;
11661
11788
  },
11662
- xtId: {
11663
- type: String,
11664
- default: ''
11789
+ getRegex: () => {
11790
+ return new RegExp(source, opt);
11665
11791
  }
11666
- },
11667
- data() {
11668
- return {
11669
- popover: false,
11670
- input: '',
11671
- errors: [],
11672
- errorList: errorList,
11673
- cacheKeyWord: '',
11674
- // 由于外部需要快速清掉 keyword 但是存在重新发送请求的情况,因此需要一个混存记录
11675
- messageData: [],
11676
- chatId: '',
11677
- // 对话id
11678
- chatMajorId: ''
11679
- };
11680
- },
11681
- computed: {
11682
- canSubmit() {
11683
- return this.errors.length === 0 && this.input === "";
11792
+ };
11793
+ return obj;
11794
+ }
11795
+ function cleanUrl(href) {
11796
+ try {
11797
+ href = encodeURI(href).replace(/%25/g, '%');
11798
+ } catch {
11799
+ return null;
11800
+ }
11801
+ return href;
11802
+ }
11803
+ const noopTest = {
11804
+ exec: () => null
11805
+ };
11806
+ function splitCells(tableRow, count) {
11807
+ // ensure that every cell-delimiting pipe has a space
11808
+ // before it to distinguish it from an escaped pipe
11809
+ const row = tableRow.replace(/\|/g, (match, offset, str) => {
11810
+ let escaped = false;
11811
+ let curr = offset;
11812
+ while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
11813
+ if (escaped) {
11814
+ // odd number of slashes means | is escaped
11815
+ // so we leave it alone
11816
+ return '|';
11817
+ } else {
11818
+ // add space before unescaped |
11819
+ return ' |';
11820
+ }
11821
+ }),
11822
+ cells = row.split(/ \|/);
11823
+ let i = 0;
11824
+ // First/last cell in a row cannot be empty if it has no leading/trailing pipe
11825
+ if (!cells[0].trim()) {
11826
+ cells.shift();
11827
+ }
11828
+ if (cells.length > 0 && !cells[cells.length - 1].trim()) {
11829
+ cells.pop();
11830
+ }
11831
+ if (count) {
11832
+ if (cells.length > count) {
11833
+ cells.splice(count);
11834
+ } else {
11835
+ while (cells.length < count) cells.push('');
11684
11836
  }
11685
- },
11686
- watch: {
11687
- keyWord: {
11688
- handler() {
11689
- if (this.keyWord) {
11690
- this.cacheKeyWord = this.keyWord;
11691
- this.postMessage();
11692
- }
11693
- },
11694
- immediate: true
11837
+ }
11838
+ for (; i < cells.length; i++) {
11839
+ // leading or trailing whitespace is ignored per the gfm spec
11840
+ cells[i] = cells[i].trim().replace(/\\\|/g, '|');
11841
+ }
11842
+ return cells;
11843
+ }
11844
+ /**
11845
+ * Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
11846
+ * /c*$/ is vulnerable to REDOS.
11847
+ *
11848
+ * @param str
11849
+ * @param c
11850
+ * @param invert Remove suffix of non-c chars instead. Default falsey.
11851
+ */
11852
+ function rtrim(str, c, invert) {
11853
+ const l = str.length;
11854
+ if (l === 0) {
11855
+ return '';
11856
+ }
11857
+ // Length of suffix matching the invert condition.
11858
+ let suffLen = 0;
11859
+ // Step left until we fail to match the invert condition.
11860
+ while (suffLen < l) {
11861
+ const currChar = str.charAt(l - suffLen - 1);
11862
+ if (currChar === c && !invert) {
11863
+ suffLen++;
11864
+ } else if (currChar !== c && invert) {
11865
+ suffLen++;
11866
+ } else {
11867
+ break;
11695
11868
  }
11696
- },
11697
- methods: {
11698
- cancelPopover() {
11699
- this.popover = false;
11700
- },
11701
- openPopover() {
11702
- this.popover = true;
11703
- },
11704
- scrollToBottom() {
11705
- this.$refs.chatContainer.scrollTop = this.$refs.chatContainer.scrollHeight;
11706
- },
11707
- async postMessage(list, commonKey, parentMsgId) {
11708
- let reanswerParams = {};
11709
- if (list) {
11710
- list.sending = true;
11711
- reanswerParams = {
11712
- reStatus: 1,
11713
- parentMsgId: list.parentMsgId,
11714
- msgId: list.msgId,
11715
- content: this.messageData[list.index - 1].message
11716
- };
11717
- this.messageData[list.index].message = '';
11869
+ }
11870
+ return str.slice(0, l - suffLen);
11871
+ }
11872
+ function findClosingBracket(str, b) {
11873
+ if (str.indexOf(b[1]) === -1) {
11874
+ return -1;
11875
+ }
11876
+ let level = 0;
11877
+ for (let i = 0; i < str.length; i++) {
11878
+ if (str[i] === '\\') {
11879
+ i++;
11880
+ } else if (str[i] === b[0]) {
11881
+ level++;
11882
+ } else if (str[i] === b[1]) {
11883
+ level--;
11884
+ if (level < 0) {
11885
+ return i;
11718
11886
  }
11719
- const params = {
11720
- messageList: [{
11721
- content: this.keyWord || this.cacheKeyWord,
11722
- resId: this.resId,
11723
- chatId: this.chatId || undefined,
11724
- commonKey: commonKey || false,
11725
- parentMsgId: parentMsgId || undefined,
11726
- ...reanswerParams
11727
- }]
11887
+ }
11888
+ }
11889
+ return -1;
11890
+ }
11891
+ function outputLink(cap, link, raw, lexer) {
11892
+ const href = link.href;
11893
+ const title = link.title ? escape$1(link.title) : null;
11894
+ const text = cap[1].replace(/\\([\[\]])/g, '$1');
11895
+ if (cap[0].charAt(0) !== '!') {
11896
+ lexer.state.inLink = true;
11897
+ const token = {
11898
+ type: 'link',
11899
+ raw,
11900
+ href,
11901
+ title,
11902
+ text,
11903
+ tokens: lexer.inlineTokens(text)
11904
+ };
11905
+ lexer.state.inLink = false;
11906
+ return token;
11907
+ }
11908
+ return {
11909
+ type: 'image',
11910
+ raw,
11911
+ href,
11912
+ title,
11913
+ text: escape$1(text)
11914
+ };
11915
+ }
11916
+ function indentCodeCompensation(raw, text) {
11917
+ const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
11918
+ if (matchIndentToCode === null) {
11919
+ return text;
11920
+ }
11921
+ const indentToCode = matchIndentToCode[1];
11922
+ return text.split('\n').map(node => {
11923
+ const matchIndentInNode = node.match(/^\s+/);
11924
+ if (matchIndentInNode === null) {
11925
+ return node;
11926
+ }
11927
+ const [indentInNode] = matchIndentInNode;
11928
+ if (indentInNode.length >= indentToCode.length) {
11929
+ return node.slice(indentToCode.length);
11930
+ }
11931
+ return node;
11932
+ }).join('\n');
11933
+ }
11934
+ /**
11935
+ * Tokenizer
11936
+ */
11937
+ class _Tokenizer {
11938
+ options;
11939
+ rules; // set by the lexer
11940
+ lexer; // set by the lexer
11941
+ constructor(options) {
11942
+ this.options = options || _defaults;
11943
+ }
11944
+ space(src) {
11945
+ const cap = this.rules.block.newline.exec(src);
11946
+ if (cap && cap[0].length > 0) {
11947
+ return {
11948
+ type: 'space',
11949
+ raw: cap[0]
11728
11950
  };
11729
- // list 存在说明是重新生成
11730
- if (!list && !commonKey) {
11731
- this.messageData.push({
11732
- type: 'user',
11733
- message: this.keyWord.replace(/\n/g, '<br>')
11734
- });
11735
- setTimeout(() => this.messageData.push({
11736
- type: 'robot',
11737
- message: '',
11738
- zan: false,
11739
- cai: false,
11740
- stop: false,
11741
- finish: false,
11742
- sending: true,
11743
- links: [],
11744
- reAnswerCount: 0
11745
- }));
11951
+ }
11952
+ }
11953
+ code(src) {
11954
+ const cap = this.rules.block.code.exec(src);
11955
+ if (cap) {
11956
+ const text = cap[0].replace(/^(?: {1,4}| {0,3}\t)/gm, '');
11957
+ return {
11958
+ type: 'code',
11959
+ raw: cap[0],
11960
+ codeBlockStyle: 'indented',
11961
+ text: !this.options.pedantic ? rtrim(text, '\n') : text
11962
+ };
11963
+ }
11964
+ }
11965
+ fences(src) {
11966
+ const cap = this.rules.block.fences.exec(src);
11967
+ if (cap) {
11968
+ const raw = cap[0];
11969
+ const text = indentCodeCompensation(raw, cap[3] || '');
11970
+ return {
11971
+ type: 'code',
11972
+ raw,
11973
+ lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, '$1') : cap[2],
11974
+ text
11975
+ };
11976
+ }
11977
+ }
11978
+ heading(src) {
11979
+ const cap = this.rules.block.heading.exec(src);
11980
+ if (cap) {
11981
+ let text = cap[2].trim();
11982
+ // remove trailing #s
11983
+ if (/#$/.test(text)) {
11984
+ const trimmed = rtrim(text, '#');
11985
+ if (this.options.pedantic) {
11986
+ text = trimmed.trim();
11987
+ } else if (!trimmed || / $/.test(trimmed)) {
11988
+ // CommonMark requires space before trailing #s
11989
+ text = trimmed.trim();
11990
+ }
11746
11991
  }
11747
- await sendMessageEventSource(params, signal, res => {
11748
- this.makeMessageLine(res, list);
11749
- });
11750
- },
11751
- makeMessageLine(res, list) {
11752
- const {
11753
- content,
11754
- status,
11755
- chatId,
11756
- msgId,
11757
- parentMsgId,
11758
- reference,
11759
- commonKey
11760
- } = JSON.parse(res.data);
11761
- let index = list ? list.index : this.messageData.length - 1;
11762
- const currentList = this.messageData[index];
11763
- // 结束标识
11764
- if (status === 2 || status === 1) {
11765
- if (commonKey) {
11766
- currentList.sending = true;
11767
- this.postMessage(list, commonKey, parentMsgId);
11768
- return;
11992
+ return {
11993
+ type: 'heading',
11994
+ raw: cap[0],
11995
+ depth: cap[1].length,
11996
+ text,
11997
+ tokens: this.lexer.inline(text)
11998
+ };
11999
+ }
12000
+ }
12001
+ hr(src) {
12002
+ const cap = this.rules.block.hr.exec(src);
12003
+ if (cap) {
12004
+ return {
12005
+ type: 'hr',
12006
+ raw: rtrim(cap[0], '\n')
12007
+ };
12008
+ }
12009
+ }
12010
+ blockquote(src) {
12011
+ const cap = this.rules.block.blockquote.exec(src);
12012
+ if (cap) {
12013
+ let lines = rtrim(cap[0], '\n').split('\n');
12014
+ let raw = '';
12015
+ let text = '';
12016
+ const tokens = [];
12017
+ while (lines.length > 0) {
12018
+ let inBlockquote = false;
12019
+ const currentLines = [];
12020
+ let i;
12021
+ for (i = 0; i < lines.length; i++) {
12022
+ // get lines up to a continuation
12023
+ if (/^ {0,3}>/.test(lines[i])) {
12024
+ currentLines.push(lines[i]);
12025
+ inBlockquote = true;
12026
+ } else if (!inBlockquote) {
12027
+ currentLines.push(lines[i]);
12028
+ } else {
12029
+ break;
12030
+ }
11769
12031
  }
11770
- currentList.finish = true;
11771
- if (reference) {
11772
- currentList.links = JSON.parse(reference);
12032
+ lines = lines.slice(i);
12033
+ const currentRaw = currentLines.join('\n');
12034
+ const currentText = currentRaw
12035
+ // precede setext continuation with 4 spaces so it isn't a setext
12036
+ .replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, '\n $1').replace(/^ {0,3}>[ \t]?/gm, '');
12037
+ raw = raw ? `${raw}\n${currentRaw}` : currentRaw;
12038
+ text = text ? `${text}\n${currentText}` : currentText;
12039
+ // parse blockquote lines as top level tokens
12040
+ // merge paragraphs if this is a continuation
12041
+ const top = this.lexer.state.top;
12042
+ this.lexer.state.top = true;
12043
+ this.lexer.blockTokens(currentText, tokens, true);
12044
+ this.lexer.state.top = top;
12045
+ // if there is no continuation then we are done
12046
+ if (lines.length === 0) {
12047
+ break;
12048
+ }
12049
+ const lastToken = tokens[tokens.length - 1];
12050
+ if (lastToken?.type === 'code') {
12051
+ // blockquote continuation cannot be preceded by a code block
12052
+ break;
12053
+ } else if (lastToken?.type === 'blockquote') {
12054
+ // include continuation in nested blockquote
12055
+ const oldToken = lastToken;
12056
+ const newText = oldToken.raw + '\n' + lines.join('\n');
12057
+ const newToken = this.blockquote(newText);
12058
+ tokens[tokens.length - 1] = newToken;
12059
+ raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
12060
+ text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
12061
+ break;
12062
+ } else if (lastToken?.type === 'list') {
12063
+ // include continuation in nested list
12064
+ const oldToken = lastToken;
12065
+ const newText = oldToken.raw + '\n' + lines.join('\n');
12066
+ const newToken = this.list(newText);
12067
+ tokens[tokens.length - 1] = newToken;
12068
+ raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
12069
+ text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
12070
+ lines = newText.substring(tokens[tokens.length - 1].raw.length).split('\n');
12071
+ continue;
11773
12072
  }
11774
- this.cacheKeyWord = '';
11775
- this.$emit('on-message-finish', chatId);
11776
- return;
11777
- }
11778
- currentList.message += content.replace(/\n/g, '<br>');
11779
- currentList.msgId = msgId;
11780
- currentList.parentMsgId = parentMsgId;
11781
- currentList.chatId = chatId;
11782
- setTimeout(() => {
11783
- if (!list) this.scrollToBottom();
11784
- }, 100);
11785
- // 防止出现调用基础模型前导致停止回答id错误
11786
- setTimeout(() => currentList.sending = false, 500);
11787
- },
11788
- onStopChat(list) {
11789
- this.$emit('on-message-finish', list.chatId);
11790
- },
11791
- async clearChat() {
11792
- if (this.messageData.length < 1) {
11793
- this.$message.warning('当前对话为最新对话');
11794
- return;
11795
12073
  }
11796
- await chartClear(this.chatId);
11797
- this.messageData = [];
12074
+ return {
12075
+ type: 'blockquote',
12076
+ raw,
12077
+ tokens,
12078
+ text
12079
+ };
12080
+ }
12081
+ }
12082
+ list(src) {
12083
+ let cap = this.rules.block.list.exec(src);
12084
+ if (cap) {
12085
+ let bull = cap[1].trim();
12086
+ const isordered = bull.length > 1;
12087
+ const list = {
12088
+ type: 'list',
12089
+ raw: '',
12090
+ ordered: isordered,
12091
+ start: isordered ? +bull.slice(0, -1) : '',
12092
+ loose: false,
12093
+ items: []
12094
+ };
12095
+ bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
12096
+ if (this.options.pedantic) {
12097
+ bull = isordered ? bull : '[*+-]';
12098
+ }
12099
+ // Get next list item
12100
+ const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`);
12101
+ let endsWithBlankLine = false;
12102
+ // Check if current bullet point can start a new List Item
12103
+ while (src) {
12104
+ let endEarly = false;
12105
+ let raw = '';
12106
+ let itemContents = '';
12107
+ if (!(cap = itemRegex.exec(src))) {
12108
+ break;
12109
+ }
12110
+ if (this.rules.block.hr.test(src)) {
12111
+ // End list if bullet was actually HR (possibly move into itemRegex?)
12112
+ break;
12113
+ }
12114
+ raw = cap[0];
12115
+ src = src.substring(raw.length);
12116
+ let line = cap[2].split('\n', 1)[0].replace(/^\t+/, t => ' '.repeat(3 * t.length));
12117
+ let nextLine = src.split('\n', 1)[0];
12118
+ let blankLine = !line.trim();
12119
+ let indent = 0;
12120
+ if (this.options.pedantic) {
12121
+ indent = 2;
12122
+ itemContents = line.trimStart();
12123
+ } else if (blankLine) {
12124
+ indent = cap[1].length + 1;
12125
+ } else {
12126
+ indent = cap[2].search(/[^ ]/); // Find first non-space char
12127
+ indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
12128
+ itemContents = line.slice(indent);
12129
+ indent += cap[1].length;
12130
+ }
12131
+ if (blankLine && /^[ \t]*$/.test(nextLine)) {
12132
+ // Items begin with at most one blank line
12133
+ raw += nextLine + '\n';
12134
+ src = src.substring(nextLine.length + 1);
12135
+ endEarly = true;
12136
+ }
12137
+ if (!endEarly) {
12138
+ const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`);
12139
+ const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
12140
+ const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
12141
+ const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
12142
+ const htmlBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}<[a-z].*>`, 'i');
12143
+ // Check if following lines should be included in List Item
12144
+ while (src) {
12145
+ const rawLine = src.split('\n', 1)[0];
12146
+ let nextLineWithoutTabs;
12147
+ nextLine = rawLine;
12148
+ // Re-align to follow commonmark nesting rules
12149
+ if (this.options.pedantic) {
12150
+ nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
12151
+ nextLineWithoutTabs = nextLine;
12152
+ } else {
12153
+ nextLineWithoutTabs = nextLine.replace(/\t/g, ' ');
12154
+ }
12155
+ // End list item if found code fences
12156
+ if (fencesBeginRegex.test(nextLine)) {
12157
+ break;
12158
+ }
12159
+ // End list item if found start of new heading
12160
+ if (headingBeginRegex.test(nextLine)) {
12161
+ break;
12162
+ }
12163
+ // End list item if found start of html block
12164
+ if (htmlBeginRegex.test(nextLine)) {
12165
+ break;
12166
+ }
12167
+ // End list item if found start of new bullet
12168
+ if (nextBulletRegex.test(nextLine)) {
12169
+ break;
12170
+ }
12171
+ // Horizontal rule found
12172
+ if (hrRegex.test(nextLine)) {
12173
+ break;
12174
+ }
12175
+ if (nextLineWithoutTabs.search(/[^ ]/) >= indent || !nextLine.trim()) {
12176
+ // Dedent if possible
12177
+ itemContents += '\n' + nextLineWithoutTabs.slice(indent);
12178
+ } else {
12179
+ // not enough indentation
12180
+ if (blankLine) {
12181
+ break;
12182
+ }
12183
+ // paragraph continuation unless last line was a different block level element
12184
+ if (line.replace(/\t/g, ' ').search(/[^ ]/) >= 4) {
12185
+ // indented code block
12186
+ break;
12187
+ }
12188
+ if (fencesBeginRegex.test(line)) {
12189
+ break;
12190
+ }
12191
+ if (headingBeginRegex.test(line)) {
12192
+ break;
12193
+ }
12194
+ if (hrRegex.test(line)) {
12195
+ break;
12196
+ }
12197
+ itemContents += '\n' + nextLine;
12198
+ }
12199
+ if (!blankLine && !nextLine.trim()) {
12200
+ // Check if current line is blank
12201
+ blankLine = true;
12202
+ }
12203
+ raw += rawLine + '\n';
12204
+ src = src.substring(rawLine.length + 1);
12205
+ line = nextLineWithoutTabs.slice(indent);
12206
+ }
12207
+ }
12208
+ if (!list.loose) {
12209
+ // If the previous item ended with a blank line, the list is loose
12210
+ if (endsWithBlankLine) {
12211
+ list.loose = true;
12212
+ } else if (/\n[ \t]*\n[ \t]*$/.test(raw)) {
12213
+ endsWithBlankLine = true;
12214
+ }
12215
+ }
12216
+ let istask = null;
12217
+ let ischecked;
12218
+ // Check for task list items
12219
+ if (this.options.gfm) {
12220
+ istask = /^\[[ xX]\] /.exec(itemContents);
12221
+ if (istask) {
12222
+ ischecked = istask[0] !== '[ ] ';
12223
+ itemContents = itemContents.replace(/^\[[ xX]\] +/, '');
12224
+ }
12225
+ }
12226
+ list.items.push({
12227
+ type: 'list_item',
12228
+ raw,
12229
+ task: !!istask,
12230
+ checked: ischecked,
12231
+ loose: false,
12232
+ text: itemContents,
12233
+ tokens: []
12234
+ });
12235
+ list.raw += raw;
12236
+ }
12237
+ // Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
12238
+ list.items[list.items.length - 1].raw = list.items[list.items.length - 1].raw.trimEnd();
12239
+ list.items[list.items.length - 1].text = list.items[list.items.length - 1].text.trimEnd();
12240
+ list.raw = list.raw.trimEnd();
12241
+ // Item child tokens handled here at end because we needed to have the final item to trim it first
12242
+ for (let i = 0; i < list.items.length; i++) {
12243
+ this.lexer.state.top = false;
12244
+ list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
12245
+ if (!list.loose) {
12246
+ // Check if list should be loose
12247
+ const spacers = list.items[i].tokens.filter(t => t.type === 'space');
12248
+ const hasMultipleLineBreaks = spacers.length > 0 && spacers.some(t => /\n.*\n/.test(t.raw));
12249
+ list.loose = hasMultipleLineBreaks;
12250
+ }
12251
+ }
12252
+ // Set all items to loose if list is loose
12253
+ if (list.loose) {
12254
+ for (let i = 0; i < list.items.length; i++) {
12255
+ list.items[i].loose = true;
12256
+ }
12257
+ }
12258
+ return list;
12259
+ }
12260
+ }
12261
+ html(src) {
12262
+ const cap = this.rules.block.html.exec(src);
12263
+ if (cap) {
12264
+ const token = {
12265
+ type: 'html',
12266
+ block: true,
12267
+ raw: cap[0],
12268
+ pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
12269
+ text: cap[0]
12270
+ };
12271
+ return token;
12272
+ }
12273
+ }
12274
+ def(src) {
12275
+ const cap = this.rules.block.def.exec(src);
12276
+ if (cap) {
12277
+ const tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
12278
+ const href = cap[2] ? cap[2].replace(/^<(.*)>$/, '$1').replace(this.rules.inline.anyPunctuation, '$1') : '';
12279
+ const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, '$1') : cap[3];
12280
+ return {
12281
+ type: 'def',
12282
+ tag,
12283
+ raw: cap[0],
12284
+ href,
12285
+ title
12286
+ };
12287
+ }
12288
+ }
12289
+ table(src) {
12290
+ const cap = this.rules.block.table.exec(src);
12291
+ if (!cap) {
12292
+ return;
12293
+ }
12294
+ if (!/[:|]/.test(cap[2])) {
12295
+ // delimiter row must have a pipe (|) or colon (:) otherwise it is a setext heading
12296
+ return;
12297
+ }
12298
+ const headers = splitCells(cap[1]);
12299
+ const aligns = cap[2].replace(/^\||\| *$/g, '').split('|');
12300
+ const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : [];
12301
+ const item = {
12302
+ type: 'table',
12303
+ raw: cap[0],
12304
+ header: [],
12305
+ align: [],
12306
+ rows: []
12307
+ };
12308
+ if (headers.length !== aligns.length) {
12309
+ // header and align columns must be equal, rows can be different.
12310
+ return;
12311
+ }
12312
+ for (const align of aligns) {
12313
+ if (/^ *-+: *$/.test(align)) {
12314
+ item.align.push('right');
12315
+ } else if (/^ *:-+: *$/.test(align)) {
12316
+ item.align.push('center');
12317
+ } else if (/^ *:-+ *$/.test(align)) {
12318
+ item.align.push('left');
12319
+ } else {
12320
+ item.align.push(null);
12321
+ }
12322
+ }
12323
+ for (let i = 0; i < headers.length; i++) {
12324
+ item.header.push({
12325
+ text: headers[i],
12326
+ tokens: this.lexer.inline(headers[i]),
12327
+ header: true,
12328
+ align: item.align[i]
12329
+ });
12330
+ }
12331
+ for (const row of rows) {
12332
+ item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
12333
+ return {
12334
+ text: cell,
12335
+ tokens: this.lexer.inline(cell),
12336
+ header: false,
12337
+ align: item.align[i]
12338
+ };
12339
+ }));
12340
+ }
12341
+ return item;
12342
+ }
12343
+ lheading(src) {
12344
+ const cap = this.rules.block.lheading.exec(src);
12345
+ if (cap) {
12346
+ return {
12347
+ type: 'heading',
12348
+ raw: cap[0],
12349
+ depth: cap[2].charAt(0) === '=' ? 1 : 2,
12350
+ text: cap[1],
12351
+ tokens: this.lexer.inline(cap[1])
12352
+ };
12353
+ }
12354
+ }
12355
+ paragraph(src) {
12356
+ const cap = this.rules.block.paragraph.exec(src);
12357
+ if (cap) {
12358
+ const text = cap[1].charAt(cap[1].length - 1) === '\n' ? cap[1].slice(0, -1) : cap[1];
12359
+ return {
12360
+ type: 'paragraph',
12361
+ raw: cap[0],
12362
+ text,
12363
+ tokens: this.lexer.inline(text)
12364
+ };
12365
+ }
12366
+ }
12367
+ text(src) {
12368
+ const cap = this.rules.block.text.exec(src);
12369
+ if (cap) {
12370
+ return {
12371
+ type: 'text',
12372
+ raw: cap[0],
12373
+ text: cap[0],
12374
+ tokens: this.lexer.inline(cap[0])
12375
+ };
12376
+ }
12377
+ }
12378
+ escape(src) {
12379
+ const cap = this.rules.inline.escape.exec(src);
12380
+ if (cap) {
12381
+ return {
12382
+ type: 'escape',
12383
+ raw: cap[0],
12384
+ text: escape$1(cap[1])
12385
+ };
12386
+ }
12387
+ }
12388
+ tag(src) {
12389
+ const cap = this.rules.inline.tag.exec(src);
12390
+ if (cap) {
12391
+ if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
12392
+ this.lexer.state.inLink = true;
12393
+ } else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
12394
+ this.lexer.state.inLink = false;
12395
+ }
12396
+ if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
12397
+ this.lexer.state.inRawBlock = true;
12398
+ } else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
12399
+ this.lexer.state.inRawBlock = false;
12400
+ }
12401
+ return {
12402
+ type: 'html',
12403
+ raw: cap[0],
12404
+ inLink: this.lexer.state.inLink,
12405
+ inRawBlock: this.lexer.state.inRawBlock,
12406
+ block: false,
12407
+ text: cap[0]
12408
+ };
12409
+ }
12410
+ }
12411
+ link(src) {
12412
+ const cap = this.rules.inline.link.exec(src);
12413
+ if (cap) {
12414
+ const trimmedUrl = cap[2].trim();
12415
+ if (!this.options.pedantic && /^</.test(trimmedUrl)) {
12416
+ // commonmark requires matching angle brackets
12417
+ if (!/>$/.test(trimmedUrl)) {
12418
+ return;
12419
+ }
12420
+ // ending angle bracket cannot be escaped
12421
+ const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
12422
+ if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
12423
+ return;
12424
+ }
12425
+ } else {
12426
+ // find closing parenthesis
12427
+ const lastParenIndex = findClosingBracket(cap[2], '()');
12428
+ if (lastParenIndex > -1) {
12429
+ const start = cap[0].indexOf('!') === 0 ? 5 : 4;
12430
+ const linkLen = start + cap[1].length + lastParenIndex;
12431
+ cap[2] = cap[2].substring(0, lastParenIndex);
12432
+ cap[0] = cap[0].substring(0, linkLen).trim();
12433
+ cap[3] = '';
12434
+ }
12435
+ }
12436
+ let href = cap[2];
12437
+ let title = '';
12438
+ if (this.options.pedantic) {
12439
+ // split pedantic href and title
12440
+ const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
12441
+ if (link) {
12442
+ href = link[1];
12443
+ title = link[3];
12444
+ }
12445
+ } else {
12446
+ title = cap[3] ? cap[3].slice(1, -1) : '';
12447
+ }
12448
+ href = href.trim();
12449
+ if (/^</.test(href)) {
12450
+ if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
12451
+ // pedantic allows starting angle bracket without ending angle bracket
12452
+ href = href.slice(1);
12453
+ } else {
12454
+ href = href.slice(1, -1);
12455
+ }
12456
+ }
12457
+ return outputLink(cap, {
12458
+ href: href ? href.replace(this.rules.inline.anyPunctuation, '$1') : href,
12459
+ title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title
12460
+ }, cap[0], this.lexer);
12461
+ }
12462
+ }
12463
+ reflink(src, links) {
12464
+ let cap;
12465
+ if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
12466
+ const linkString = (cap[2] || cap[1]).replace(/\s+/g, ' ');
12467
+ const link = links[linkString.toLowerCase()];
12468
+ if (!link) {
12469
+ const text = cap[0].charAt(0);
12470
+ return {
12471
+ type: 'text',
12472
+ raw: text,
12473
+ text
12474
+ };
12475
+ }
12476
+ return outputLink(cap, link, cap[0], this.lexer);
12477
+ }
12478
+ }
12479
+ emStrong(src, maskedSrc, prevChar = '') {
12480
+ let match = this.rules.inline.emStrongLDelim.exec(src);
12481
+ if (!match) return;
12482
+ // _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
12483
+ if (match[3] && prevChar.match(/[\p{L}\p{N}]/u)) return;
12484
+ const nextChar = match[1] || match[2] || '';
12485
+ if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
12486
+ // unicode Regex counts emoji as 1 char; spread into array for proper count (used multiple times below)
12487
+ const lLength = [...match[0]].length - 1;
12488
+ let rDelim,
12489
+ rLength,
12490
+ delimTotal = lLength,
12491
+ midDelimTotal = 0;
12492
+ const endReg = match[0][0] === '*' ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
12493
+ endReg.lastIndex = 0;
12494
+ // Clip maskedSrc to same section of string as src (move to lexer?)
12495
+ maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
12496
+ while ((match = endReg.exec(maskedSrc)) != null) {
12497
+ rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
12498
+ if (!rDelim) continue; // skip single * in __abc*abc__
12499
+ rLength = [...rDelim].length;
12500
+ if (match[3] || match[4]) {
12501
+ // found another Left Delim
12502
+ delimTotal += rLength;
12503
+ continue;
12504
+ } else if (match[5] || match[6]) {
12505
+ // either Left or Right Delim
12506
+ if (lLength % 3 && !((lLength + rLength) % 3)) {
12507
+ midDelimTotal += rLength;
12508
+ continue; // CommonMark Emphasis Rules 9-10
12509
+ }
12510
+ }
12511
+ delimTotal -= rLength;
12512
+ if (delimTotal > 0) continue; // Haven't found enough closing delimiters
12513
+ // Remove extra characters. *a*** -> *a*
12514
+ rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
12515
+ // char length can be >1 for unicode characters;
12516
+ const lastCharLength = [...match[0]][0].length;
12517
+ const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
12518
+ // Create `em` if smallest delimiter has odd char count. *a***
12519
+ if (Math.min(lLength, rLength) % 2) {
12520
+ const text = raw.slice(1, -1);
12521
+ return {
12522
+ type: 'em',
12523
+ raw,
12524
+ text,
12525
+ tokens: this.lexer.inlineTokens(text)
12526
+ };
12527
+ }
12528
+ // Create 'strong' if smallest delimiter has even char count. **a***
12529
+ const text = raw.slice(2, -2);
12530
+ return {
12531
+ type: 'strong',
12532
+ raw,
12533
+ text,
12534
+ tokens: this.lexer.inlineTokens(text)
12535
+ };
12536
+ }
12537
+ }
12538
+ }
12539
+ codespan(src) {
12540
+ const cap = this.rules.inline.code.exec(src);
12541
+ if (cap) {
12542
+ let text = cap[2].replace(/\n/g, ' ');
12543
+ const hasNonSpaceChars = /[^ ]/.test(text);
12544
+ const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
12545
+ if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
12546
+ text = text.substring(1, text.length - 1);
12547
+ }
12548
+ text = escape$1(text, true);
12549
+ return {
12550
+ type: 'codespan',
12551
+ raw: cap[0],
12552
+ text
12553
+ };
12554
+ }
12555
+ }
12556
+ br(src) {
12557
+ const cap = this.rules.inline.br.exec(src);
12558
+ if (cap) {
12559
+ return {
12560
+ type: 'br',
12561
+ raw: cap[0]
12562
+ };
12563
+ }
12564
+ }
12565
+ del(src) {
12566
+ const cap = this.rules.inline.del.exec(src);
12567
+ if (cap) {
12568
+ return {
12569
+ type: 'del',
12570
+ raw: cap[0],
12571
+ text: cap[2],
12572
+ tokens: this.lexer.inlineTokens(cap[2])
12573
+ };
12574
+ }
12575
+ }
12576
+ autolink(src) {
12577
+ const cap = this.rules.inline.autolink.exec(src);
12578
+ if (cap) {
12579
+ let text, href;
12580
+ if (cap[2] === '@') {
12581
+ text = escape$1(cap[1]);
12582
+ href = 'mailto:' + text;
12583
+ } else {
12584
+ text = escape$1(cap[1]);
12585
+ href = text;
12586
+ }
12587
+ return {
12588
+ type: 'link',
12589
+ raw: cap[0],
12590
+ text,
12591
+ href,
12592
+ tokens: [{
12593
+ type: 'text',
12594
+ raw: text,
12595
+ text
12596
+ }]
12597
+ };
12598
+ }
12599
+ }
12600
+ url(src) {
12601
+ let cap;
12602
+ if (cap = this.rules.inline.url.exec(src)) {
12603
+ let text, href;
12604
+ if (cap[2] === '@') {
12605
+ text = escape$1(cap[0]);
12606
+ href = 'mailto:' + text;
12607
+ } else {
12608
+ // do extended autolink path validation
12609
+ let prevCapZero;
12610
+ do {
12611
+ prevCapZero = cap[0];
12612
+ cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? '';
12613
+ } while (prevCapZero !== cap[0]);
12614
+ text = escape$1(cap[0]);
12615
+ if (cap[1] === 'www.') {
12616
+ href = 'http://' + cap[0];
12617
+ } else {
12618
+ href = cap[0];
12619
+ }
12620
+ }
12621
+ return {
12622
+ type: 'link',
12623
+ raw: cap[0],
12624
+ text,
12625
+ href,
12626
+ tokens: [{
12627
+ type: 'text',
12628
+ raw: text,
12629
+ text
12630
+ }]
12631
+ };
12632
+ }
12633
+ }
12634
+ inlineText(src) {
12635
+ const cap = this.rules.inline.text.exec(src);
12636
+ if (cap) {
12637
+ let text;
12638
+ if (this.lexer.state.inRawBlock) {
12639
+ text = cap[0];
12640
+ } else {
12641
+ text = escape$1(cap[0]);
12642
+ }
12643
+ return {
12644
+ type: 'text',
12645
+ raw: cap[0],
12646
+ text
12647
+ };
12648
+ }
12649
+ }
12650
+ }
12651
+
12652
+ /**
12653
+ * Block-Level Grammar
12654
+ */
12655
+ const newline = /^(?:[ \t]*(?:\n|$))+/;
12656
+ const blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
12657
+ const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
12658
+ const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
12659
+ const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
12660
+ const bullet = /(?:[*+-]|\d{1,9}[.)])/;
12661
+ const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet) // lists can interrupt
12662
+ .replace(/blockCode/g, /(?: {4}| {0,3}\t)/) // indented code blocks can interrupt
12663
+ .replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
12664
+ .replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
12665
+ .replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
12666
+ .replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt
12667
+ .getRegex();
12668
+ const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
12669
+ const blockText = /^[^\n]+/;
12670
+ const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
12671
+ const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace('label', _blockLabel).replace('title', /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
12672
+ const list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
12673
+ const _tag = 'address|article|aside|base|basefont|blockquote|body|caption' + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + '|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title' + '|tr|track|ul';
12674
+ const _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
12675
+ const html = edit('^ {0,3}(?:' // optional indentation
12676
+ + '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
12677
+ + '|comment[^\\n]*(\\n+|$)' // (2)
12678
+ + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
12679
+ + '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
12680
+ + '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
12681
+ + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (6)
12682
+ + '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) open tag
12683
+ + '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) closing tag
12684
+ + ')', 'i').replace('comment', _comment).replace('tag', _tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
12685
+ const paragraph = edit(_paragraph).replace('hr', hr).replace('heading', ' {0,3}#{1,6}(?:\\s|$)').replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
12686
+ .replace('|table', '').replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
12687
+ .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', _tag) // pars can be interrupted by type (6) html blocks
12688
+ .getRegex();
12689
+ const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace('paragraph', paragraph).getRegex();
12690
+ /**
12691
+ * Normal Block Grammar
12692
+ */
12693
+ const blockNormal = {
12694
+ blockquote,
12695
+ code: blockCode,
12696
+ def,
12697
+ fences,
12698
+ heading,
12699
+ hr,
12700
+ html,
12701
+ lheading,
12702
+ list,
12703
+ newline,
12704
+ paragraph,
12705
+ table: noopTest,
12706
+ text: blockText
12707
+ };
12708
+ /**
12709
+ * GFM Block Grammar
12710
+ */
12711
+ const gfmTable = edit('^ *([^\\n ].*)\\n' // Header
12712
+ + ' {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)' // Align
12713
+ + '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)') // Cells
12714
+ .replace('hr', hr).replace('heading', ' {0,3}#{1,6}(?:\\s|$)').replace('blockquote', ' {0,3}>').replace('code', '(?: {4}| {0,3}\t)[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
12715
+ .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', _tag) // tables can be interrupted by type (6) html blocks
12716
+ .getRegex();
12717
+ const blockGfm = {
12718
+ ...blockNormal,
12719
+ table: gfmTable,
12720
+ paragraph: edit(_paragraph).replace('hr', hr).replace('heading', ' {0,3}#{1,6}(?:\\s|$)').replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
12721
+ .replace('table', gfmTable) // interrupt paragraphs with table
12722
+ .replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
12723
+ .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', _tag) // pars can be interrupted by type (6) html blocks
12724
+ .getRegex()
12725
+ };
12726
+ /**
12727
+ * Pedantic grammar (original John Gruber's loose markdown specification)
12728
+ */
12729
+ const blockPedantic = {
12730
+ ...blockNormal,
12731
+ html: edit('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
12732
+ + '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace('comment', _comment).replace(/tag/g, '(?!(?:' + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b').getRegex(),
12733
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
12734
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
12735
+ fences: noopTest,
12736
+ // fences not supported
12737
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
12738
+ paragraph: edit(_paragraph).replace('hr', hr).replace('heading', ' *#{1,6} *[^\n]').replace('lheading', lheading).replace('|table', '').replace('blockquote', ' {0,3}>').replace('|fences', '').replace('|list', '').replace('|html', '').replace('|tag', '').getRegex()
12739
+ };
12740
+ /**
12741
+ * Inline-Level Grammar
12742
+ */
12743
+ const marked_esm_escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
12744
+ const inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
12745
+ const br = /^( {2,}|\\)\n(?!\s*$)/;
12746
+ const inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
12747
+ // list of unicode punctuation marks, plus any missing characters from CommonMark spec
12748
+ const _punctuation = '\\p{P}\\p{S}';
12749
+ const punctuation = edit(/^((?![*_])[\spunctuation])/, 'u').replace(/punctuation/g, _punctuation).getRegex();
12750
+ // sequences em should skip over [title](link), `code`, <html>
12751
+ const blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
12752
+ const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, 'u').replace(/punct/g, _punctuation).getRegex();
12753
+ const emStrongRDelimAst = edit('^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)' // Skip orphan inside strong
12754
+ + '|[^*]+(?=[^*])' // Consume to delim
12755
+ + '|(?!\\*)[punct](\\*+)(?=[\\s]|$)' // (1) #*** can only be a Right Delimiter
12756
+ + '|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)' // (2) a***#, a*** can only be a Right Delimiter
12757
+ + '|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])' // (3) #***a, ***a can only be Left Delimiter
12758
+ + '|[\\s](\\*+)(?!\\*)(?=[punct])' // (4) ***# can only be Left Delimiter
12759
+ + '|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])' // (5) #***# can be either Left or Right Delimiter
12760
+ + '|[^punct\\s](\\*+)(?=[^punct\\s])', 'gu') // (6) a***a can be either Left or Right Delimiter
12761
+ .replace(/punct/g, _punctuation).getRegex();
12762
+ // (6) Not allowed for _
12763
+ const emStrongRDelimUnd = edit('^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)' // Skip orphan inside strong
12764
+ + '|[^_]+(?=[^_])' // Consume to delim
12765
+ + '|(?!_)[punct](_+)(?=[\\s]|$)' // (1) #___ can only be a Right Delimiter
12766
+ + '|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)' // (2) a___#, a___ can only be a Right Delimiter
12767
+ + '|(?!_)[punct\\s](_+)(?=[^punct\\s])' // (3) #___a, ___a can only be Left Delimiter
12768
+ + '|[\\s](_+)(?!_)(?=[punct])' // (4) ___# can only be Left Delimiter
12769
+ + '|(?!_)[punct](_+)(?!_)(?=[punct])', 'gu') // (5) #___# can be either Left or Right Delimiter
12770
+ .replace(/punct/g, _punctuation).getRegex();
12771
+ const anyPunctuation = edit(/\\([punct])/, 'gu').replace(/punct/g, _punctuation).getRegex();
12772
+ const autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace('scheme', /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace('email', /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
12773
+ const _inlineComment = edit(_comment).replace('(?:-->|$)', '-->').getRegex();
12774
+ const tag = edit('^comment' + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
12775
+ + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
12776
+ + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
12777
+ + '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
12778
+ + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>') // CDATA section
12779
+ .replace('comment', _inlineComment).replace('attribute', /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
12780
+ const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
12781
+ const marked_esm_link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace('label', _inlineLabel).replace('href', /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
12782
+ const reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace('label', _inlineLabel).replace('ref', _blockLabel).getRegex();
12783
+ const nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace('ref', _blockLabel).getRegex();
12784
+ const reflinkSearch = edit('reflink|nolink(?!\\()', 'g').replace('reflink', reflink).replace('nolink', nolink).getRegex();
12785
+ /**
12786
+ * Normal Inline Grammar
12787
+ */
12788
+ const inlineNormal = {
12789
+ _backpedal: noopTest,
12790
+ // only used for GFM url
12791
+ anyPunctuation,
12792
+ autolink,
12793
+ blockSkip,
12794
+ br,
12795
+ code: inlineCode,
12796
+ del: noopTest,
12797
+ emStrongLDelim,
12798
+ emStrongRDelimAst,
12799
+ emStrongRDelimUnd,
12800
+ escape: marked_esm_escape,
12801
+ link: marked_esm_link,
12802
+ nolink,
12803
+ punctuation,
12804
+ reflink,
12805
+ reflinkSearch,
12806
+ tag,
12807
+ text: inlineText,
12808
+ url: noopTest
12809
+ };
12810
+ /**
12811
+ * Pedantic Inline Grammar
12812
+ */
12813
+ const inlinePedantic = {
12814
+ ...inlineNormal,
12815
+ link: edit(/^!?\[(label)\]\((.*?)\)/).replace('label', _inlineLabel).getRegex(),
12816
+ reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', _inlineLabel).getRegex()
12817
+ };
12818
+ /**
12819
+ * GFM Inline Grammar
12820
+ */
12821
+ const inlineGfm = {
12822
+ ...inlineNormal,
12823
+ escape: edit(marked_esm_escape).replace('])', '~|])').getRegex(),
12824
+ url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, 'i').replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
12825
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
12826
+ del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
12827
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
12828
+ };
12829
+ /**
12830
+ * GFM + Line Breaks Inline Grammar
12831
+ */
12832
+ const inlineBreaks = {
12833
+ ...inlineGfm,
12834
+ br: edit(br).replace('{2,}', '*').getRegex(),
12835
+ text: edit(inlineGfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
12836
+ };
12837
+ /**
12838
+ * exports
12839
+ */
12840
+ const block = {
12841
+ normal: blockNormal,
12842
+ gfm: blockGfm,
12843
+ pedantic: blockPedantic
12844
+ };
12845
+ const inline = {
12846
+ normal: inlineNormal,
12847
+ gfm: inlineGfm,
12848
+ breaks: inlineBreaks,
12849
+ pedantic: inlinePedantic
12850
+ };
12851
+
12852
+ /**
12853
+ * Block Lexer
12854
+ */
12855
+ class _Lexer {
12856
+ tokens;
12857
+ options;
12858
+ state;
12859
+ tokenizer;
12860
+ inlineQueue;
12861
+ constructor(options) {
12862
+ // TokenList cannot be created in one go
12863
+ this.tokens = [];
12864
+ this.tokens.links = Object.create(null);
12865
+ this.options = options || _defaults;
12866
+ this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
12867
+ this.tokenizer = this.options.tokenizer;
12868
+ this.tokenizer.options = this.options;
12869
+ this.tokenizer.lexer = this;
12870
+ this.inlineQueue = [];
12871
+ this.state = {
12872
+ inLink: false,
12873
+ inRawBlock: false,
12874
+ top: true
12875
+ };
12876
+ const rules = {
12877
+ block: block.normal,
12878
+ inline: inline.normal
12879
+ };
12880
+ if (this.options.pedantic) {
12881
+ rules.block = block.pedantic;
12882
+ rules.inline = inline.pedantic;
12883
+ } else if (this.options.gfm) {
12884
+ rules.block = block.gfm;
12885
+ if (this.options.breaks) {
12886
+ rules.inline = inline.breaks;
12887
+ } else {
12888
+ rules.inline = inline.gfm;
12889
+ }
12890
+ }
12891
+ this.tokenizer.rules = rules;
12892
+ }
12893
+ /**
12894
+ * Expose Rules
12895
+ */
12896
+ static get rules() {
12897
+ return {
12898
+ block,
12899
+ inline
12900
+ };
12901
+ }
12902
+ /**
12903
+ * Static Lex Method
12904
+ */
12905
+ static lex(src, options) {
12906
+ const lexer = new _Lexer(options);
12907
+ return lexer.lex(src);
12908
+ }
12909
+ /**
12910
+ * Static Lex Inline Method
12911
+ */
12912
+ static lexInline(src, options) {
12913
+ const lexer = new _Lexer(options);
12914
+ return lexer.inlineTokens(src);
12915
+ }
12916
+ /**
12917
+ * Preprocessing
12918
+ */
12919
+ lex(src) {
12920
+ src = src.replace(/\r\n|\r/g, '\n');
12921
+ this.blockTokens(src, this.tokens);
12922
+ for (let i = 0; i < this.inlineQueue.length; i++) {
12923
+ const next = this.inlineQueue[i];
12924
+ this.inlineTokens(next.src, next.tokens);
12925
+ }
12926
+ this.inlineQueue = [];
12927
+ return this.tokens;
12928
+ }
12929
+ blockTokens(src, tokens = [], lastParagraphClipped = false) {
12930
+ if (this.options.pedantic) {
12931
+ src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
12932
+ }
12933
+ let token;
12934
+ let lastToken;
12935
+ let cutSrc;
12936
+ while (src) {
12937
+ if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some(extTokenizer => {
12938
+ if (token = extTokenizer.call({
12939
+ lexer: this
12940
+ }, src, tokens)) {
12941
+ src = src.substring(token.raw.length);
12942
+ tokens.push(token);
12943
+ return true;
12944
+ }
12945
+ return false;
12946
+ })) {
12947
+ continue;
12948
+ }
12949
+ // newline
12950
+ if (token = this.tokenizer.space(src)) {
12951
+ src = src.substring(token.raw.length);
12952
+ if (token.raw.length === 1 && tokens.length > 0) {
12953
+ // if there's a single \n as a spacer, it's terminating the last line,
12954
+ // so move it there so that we don't get unnecessary paragraph tags
12955
+ tokens[tokens.length - 1].raw += '\n';
12956
+ } else {
12957
+ tokens.push(token);
12958
+ }
12959
+ continue;
12960
+ }
12961
+ // code
12962
+ if (token = this.tokenizer.code(src)) {
12963
+ src = src.substring(token.raw.length);
12964
+ lastToken = tokens[tokens.length - 1];
12965
+ // An indented code block cannot interrupt a paragraph.
12966
+ if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
12967
+ lastToken.raw += '\n' + token.raw;
12968
+ lastToken.text += '\n' + token.text;
12969
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
12970
+ } else {
12971
+ tokens.push(token);
12972
+ }
12973
+ continue;
12974
+ }
12975
+ // fences
12976
+ if (token = this.tokenizer.fences(src)) {
12977
+ src = src.substring(token.raw.length);
12978
+ tokens.push(token);
12979
+ continue;
12980
+ }
12981
+ // heading
12982
+ if (token = this.tokenizer.heading(src)) {
12983
+ src = src.substring(token.raw.length);
12984
+ tokens.push(token);
12985
+ continue;
12986
+ }
12987
+ // hr
12988
+ if (token = this.tokenizer.hr(src)) {
12989
+ src = src.substring(token.raw.length);
12990
+ tokens.push(token);
12991
+ continue;
12992
+ }
12993
+ // blockquote
12994
+ if (token = this.tokenizer.blockquote(src)) {
12995
+ src = src.substring(token.raw.length);
12996
+ tokens.push(token);
12997
+ continue;
12998
+ }
12999
+ // list
13000
+ if (token = this.tokenizer.list(src)) {
13001
+ src = src.substring(token.raw.length);
13002
+ tokens.push(token);
13003
+ continue;
13004
+ }
13005
+ // html
13006
+ if (token = this.tokenizer.html(src)) {
13007
+ src = src.substring(token.raw.length);
13008
+ tokens.push(token);
13009
+ continue;
13010
+ }
13011
+ // def
13012
+ if (token = this.tokenizer.def(src)) {
13013
+ src = src.substring(token.raw.length);
13014
+ lastToken = tokens[tokens.length - 1];
13015
+ if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
13016
+ lastToken.raw += '\n' + token.raw;
13017
+ lastToken.text += '\n' + token.raw;
13018
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
13019
+ } else if (!this.tokens.links[token.tag]) {
13020
+ this.tokens.links[token.tag] = {
13021
+ href: token.href,
13022
+ title: token.title
13023
+ };
13024
+ }
13025
+ continue;
13026
+ }
13027
+ // table (gfm)
13028
+ if (token = this.tokenizer.table(src)) {
13029
+ src = src.substring(token.raw.length);
13030
+ tokens.push(token);
13031
+ continue;
13032
+ }
13033
+ // lheading
13034
+ if (token = this.tokenizer.lheading(src)) {
13035
+ src = src.substring(token.raw.length);
13036
+ tokens.push(token);
13037
+ continue;
13038
+ }
13039
+ // top-level paragraph
13040
+ // prevent paragraph consuming extensions by clipping 'src' to extension start
13041
+ cutSrc = src;
13042
+ if (this.options.extensions && this.options.extensions.startBlock) {
13043
+ let startIndex = Infinity;
13044
+ const tempSrc = src.slice(1);
13045
+ let tempStart;
13046
+ this.options.extensions.startBlock.forEach(getStartIndex => {
13047
+ tempStart = getStartIndex.call({
13048
+ lexer: this
13049
+ }, tempSrc);
13050
+ if (typeof tempStart === 'number' && tempStart >= 0) {
13051
+ startIndex = Math.min(startIndex, tempStart);
13052
+ }
13053
+ });
13054
+ if (startIndex < Infinity && startIndex >= 0) {
13055
+ cutSrc = src.substring(0, startIndex + 1);
13056
+ }
13057
+ }
13058
+ if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
13059
+ lastToken = tokens[tokens.length - 1];
13060
+ if (lastParagraphClipped && lastToken?.type === 'paragraph') {
13061
+ lastToken.raw += '\n' + token.raw;
13062
+ lastToken.text += '\n' + token.text;
13063
+ this.inlineQueue.pop();
13064
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
13065
+ } else {
13066
+ tokens.push(token);
13067
+ }
13068
+ lastParagraphClipped = cutSrc.length !== src.length;
13069
+ src = src.substring(token.raw.length);
13070
+ continue;
13071
+ }
13072
+ // text
13073
+ if (token = this.tokenizer.text(src)) {
13074
+ src = src.substring(token.raw.length);
13075
+ lastToken = tokens[tokens.length - 1];
13076
+ if (lastToken && lastToken.type === 'text') {
13077
+ lastToken.raw += '\n' + token.raw;
13078
+ lastToken.text += '\n' + token.text;
13079
+ this.inlineQueue.pop();
13080
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
13081
+ } else {
13082
+ tokens.push(token);
13083
+ }
13084
+ continue;
13085
+ }
13086
+ if (src) {
13087
+ const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
13088
+ if (this.options.silent) {
13089
+ console.error(errMsg);
13090
+ break;
13091
+ } else {
13092
+ throw new Error(errMsg);
13093
+ }
13094
+ }
13095
+ }
13096
+ this.state.top = true;
13097
+ return tokens;
13098
+ }
13099
+ inline(src, tokens = []) {
13100
+ this.inlineQueue.push({
13101
+ src,
13102
+ tokens
13103
+ });
13104
+ return tokens;
13105
+ }
13106
+ /**
13107
+ * Lexing/Compiling
13108
+ */
13109
+ inlineTokens(src, tokens = []) {
13110
+ let token, lastToken, cutSrc;
13111
+ // String with links masked to avoid interference with em and strong
13112
+ let maskedSrc = src;
13113
+ let match;
13114
+ let keepPrevChar, prevChar;
13115
+ // Mask out reflinks
13116
+ if (this.tokens.links) {
13117
+ const links = Object.keys(this.tokens.links);
13118
+ if (links.length > 0) {
13119
+ while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
13120
+ if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
13121
+ maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
13122
+ }
13123
+ }
13124
+ }
13125
+ }
13126
+ // Mask out other blocks
13127
+ while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
13128
+ maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
13129
+ }
13130
+ // Mask out escaped characters
13131
+ while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
13132
+ maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
13133
+ }
13134
+ while (src) {
13135
+ if (!keepPrevChar) {
13136
+ prevChar = '';
13137
+ }
13138
+ keepPrevChar = false;
13139
+ // extensions
13140
+ if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some(extTokenizer => {
13141
+ if (token = extTokenizer.call({
13142
+ lexer: this
13143
+ }, src, tokens)) {
13144
+ src = src.substring(token.raw.length);
13145
+ tokens.push(token);
13146
+ return true;
13147
+ }
13148
+ return false;
13149
+ })) {
13150
+ continue;
13151
+ }
13152
+ // escape
13153
+ if (token = this.tokenizer.escape(src)) {
13154
+ src = src.substring(token.raw.length);
13155
+ tokens.push(token);
13156
+ continue;
13157
+ }
13158
+ // tag
13159
+ if (token = this.tokenizer.tag(src)) {
13160
+ src = src.substring(token.raw.length);
13161
+ lastToken = tokens[tokens.length - 1];
13162
+ if (lastToken && token.type === 'text' && lastToken.type === 'text') {
13163
+ lastToken.raw += token.raw;
13164
+ lastToken.text += token.text;
13165
+ } else {
13166
+ tokens.push(token);
13167
+ }
13168
+ continue;
13169
+ }
13170
+ // link
13171
+ if (token = this.tokenizer.link(src)) {
13172
+ src = src.substring(token.raw.length);
13173
+ tokens.push(token);
13174
+ continue;
13175
+ }
13176
+ // reflink, nolink
13177
+ if (token = this.tokenizer.reflink(src, this.tokens.links)) {
13178
+ src = src.substring(token.raw.length);
13179
+ lastToken = tokens[tokens.length - 1];
13180
+ if (lastToken && token.type === 'text' && lastToken.type === 'text') {
13181
+ lastToken.raw += token.raw;
13182
+ lastToken.text += token.text;
13183
+ } else {
13184
+ tokens.push(token);
13185
+ }
13186
+ continue;
13187
+ }
13188
+ // em & strong
13189
+ if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
13190
+ src = src.substring(token.raw.length);
13191
+ tokens.push(token);
13192
+ continue;
13193
+ }
13194
+ // code
13195
+ if (token = this.tokenizer.codespan(src)) {
13196
+ src = src.substring(token.raw.length);
13197
+ tokens.push(token);
13198
+ continue;
13199
+ }
13200
+ // br
13201
+ if (token = this.tokenizer.br(src)) {
13202
+ src = src.substring(token.raw.length);
13203
+ tokens.push(token);
13204
+ continue;
13205
+ }
13206
+ // del (gfm)
13207
+ if (token = this.tokenizer.del(src)) {
13208
+ src = src.substring(token.raw.length);
13209
+ tokens.push(token);
13210
+ continue;
13211
+ }
13212
+ // autolink
13213
+ if (token = this.tokenizer.autolink(src)) {
13214
+ src = src.substring(token.raw.length);
13215
+ tokens.push(token);
13216
+ continue;
13217
+ }
13218
+ // url (gfm)
13219
+ if (!this.state.inLink && (token = this.tokenizer.url(src))) {
13220
+ src = src.substring(token.raw.length);
13221
+ tokens.push(token);
13222
+ continue;
13223
+ }
13224
+ // text
13225
+ // prevent inlineText consuming extensions by clipping 'src' to extension start
13226
+ cutSrc = src;
13227
+ if (this.options.extensions && this.options.extensions.startInline) {
13228
+ let startIndex = Infinity;
13229
+ const tempSrc = src.slice(1);
13230
+ let tempStart;
13231
+ this.options.extensions.startInline.forEach(getStartIndex => {
13232
+ tempStart = getStartIndex.call({
13233
+ lexer: this
13234
+ }, tempSrc);
13235
+ if (typeof tempStart === 'number' && tempStart >= 0) {
13236
+ startIndex = Math.min(startIndex, tempStart);
13237
+ }
13238
+ });
13239
+ if (startIndex < Infinity && startIndex >= 0) {
13240
+ cutSrc = src.substring(0, startIndex + 1);
13241
+ }
13242
+ }
13243
+ if (token = this.tokenizer.inlineText(cutSrc)) {
13244
+ src = src.substring(token.raw.length);
13245
+ if (token.raw.slice(-1) !== '_') {
13246
+ // Track prevChar before string of ____ started
13247
+ prevChar = token.raw.slice(-1);
13248
+ }
13249
+ keepPrevChar = true;
13250
+ lastToken = tokens[tokens.length - 1];
13251
+ if (lastToken && lastToken.type === 'text') {
13252
+ lastToken.raw += token.raw;
13253
+ lastToken.text += token.text;
13254
+ } else {
13255
+ tokens.push(token);
13256
+ }
13257
+ continue;
13258
+ }
13259
+ if (src) {
13260
+ const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
13261
+ if (this.options.silent) {
13262
+ console.error(errMsg);
13263
+ break;
13264
+ } else {
13265
+ throw new Error(errMsg);
13266
+ }
13267
+ }
13268
+ }
13269
+ return tokens;
13270
+ }
13271
+ }
13272
+
13273
+ /**
13274
+ * Renderer
13275
+ */
13276
+ class _Renderer {
13277
+ options;
13278
+ parser; // set by the parser
13279
+ constructor(options) {
13280
+ this.options = options || _defaults;
13281
+ }
13282
+ space(token) {
13283
+ return '';
13284
+ }
13285
+ code({
13286
+ text,
13287
+ lang,
13288
+ escaped
13289
+ }) {
13290
+ const langString = (lang || '').match(/^\S*/)?.[0];
13291
+ const code = text.replace(/\n$/, '') + '\n';
13292
+ if (!langString) {
13293
+ return '<pre><code>' + (escaped ? code : escape$1(code, true)) + '</code></pre>\n';
13294
+ }
13295
+ return '<pre><code class="language-' + escape$1(langString) + '">' + (escaped ? code : escape$1(code, true)) + '</code></pre>\n';
13296
+ }
13297
+ blockquote({
13298
+ tokens
13299
+ }) {
13300
+ const body = this.parser.parse(tokens);
13301
+ return `<blockquote>\n${body}</blockquote>\n`;
13302
+ }
13303
+ html({
13304
+ text
13305
+ }) {
13306
+ return text;
13307
+ }
13308
+ heading({
13309
+ tokens,
13310
+ depth
13311
+ }) {
13312
+ return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>\n`;
13313
+ }
13314
+ hr(token) {
13315
+ return '<hr>\n';
13316
+ }
13317
+ list(token) {
13318
+ const ordered = token.ordered;
13319
+ const start = token.start;
13320
+ let body = '';
13321
+ for (let j = 0; j < token.items.length; j++) {
13322
+ const item = token.items[j];
13323
+ body += this.listitem(item);
13324
+ }
13325
+ const type = ordered ? 'ol' : 'ul';
13326
+ const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : '';
13327
+ return '<' + type + startAttr + '>\n' + body + '</' + type + '>\n';
13328
+ }
13329
+ listitem(item) {
13330
+ let itemBody = '';
13331
+ if (item.task) {
13332
+ const checkbox = this.checkbox({
13333
+ checked: !!item.checked
13334
+ });
13335
+ if (item.loose) {
13336
+ if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
13337
+ item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
13338
+ if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
13339
+ item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
13340
+ }
13341
+ } else {
13342
+ item.tokens.unshift({
13343
+ type: 'text',
13344
+ raw: checkbox + ' ',
13345
+ text: checkbox + ' '
13346
+ });
13347
+ }
13348
+ } else {
13349
+ itemBody += checkbox + ' ';
13350
+ }
13351
+ }
13352
+ itemBody += this.parser.parse(item.tokens, !!item.loose);
13353
+ return `<li>${itemBody}</li>\n`;
13354
+ }
13355
+ checkbox({
13356
+ checked
13357
+ }) {
13358
+ return '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox">';
13359
+ }
13360
+ paragraph({
13361
+ tokens
13362
+ }) {
13363
+ return `<p>${this.parser.parseInline(tokens)}</p>\n`;
13364
+ }
13365
+ table(token) {
13366
+ let header = '';
13367
+ // header
13368
+ let cell = '';
13369
+ for (let j = 0; j < token.header.length; j++) {
13370
+ cell += this.tablecell(token.header[j]);
13371
+ }
13372
+ header += this.tablerow({
13373
+ text: cell
13374
+ });
13375
+ let body = '';
13376
+ for (let j = 0; j < token.rows.length; j++) {
13377
+ const row = token.rows[j];
13378
+ cell = '';
13379
+ for (let k = 0; k < row.length; k++) {
13380
+ cell += this.tablecell(row[k]);
13381
+ }
13382
+ body += this.tablerow({
13383
+ text: cell
13384
+ });
13385
+ }
13386
+ if (body) body = `<tbody>${body}</tbody>`;
13387
+ return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
13388
+ }
13389
+ tablerow({
13390
+ text
13391
+ }) {
13392
+ return `<tr>\n${text}</tr>\n`;
13393
+ }
13394
+ tablecell(token) {
13395
+ const content = this.parser.parseInline(token.tokens);
13396
+ const type = token.header ? 'th' : 'td';
13397
+ const tag = token.align ? `<${type} align="${token.align}">` : `<${type}>`;
13398
+ return tag + content + `</${type}>\n`;
13399
+ }
13400
+ /**
13401
+ * span level renderer
13402
+ */
13403
+ strong({
13404
+ tokens
13405
+ }) {
13406
+ return `<strong>${this.parser.parseInline(tokens)}</strong>`;
13407
+ }
13408
+ em({
13409
+ tokens
13410
+ }) {
13411
+ return `<em>${this.parser.parseInline(tokens)}</em>`;
13412
+ }
13413
+ codespan({
13414
+ text
13415
+ }) {
13416
+ return `<code>${text}</code>`;
13417
+ }
13418
+ br(token) {
13419
+ return '<br>';
13420
+ }
13421
+ del({
13422
+ tokens
13423
+ }) {
13424
+ return `<del>${this.parser.parseInline(tokens)}</del>`;
13425
+ }
13426
+ link({
13427
+ href,
13428
+ title,
13429
+ tokens
13430
+ }) {
13431
+ const text = this.parser.parseInline(tokens);
13432
+ const cleanHref = cleanUrl(href);
13433
+ if (cleanHref === null) {
13434
+ return text;
13435
+ }
13436
+ href = cleanHref;
13437
+ let out = '<a href="' + href + '"';
13438
+ if (title) {
13439
+ out += ' title="' + title + '"';
13440
+ }
13441
+ out += '>' + text + '</a>';
13442
+ return out;
13443
+ }
13444
+ image({
13445
+ href,
13446
+ title,
13447
+ text
13448
+ }) {
13449
+ const cleanHref = cleanUrl(href);
13450
+ if (cleanHref === null) {
13451
+ return text;
13452
+ }
13453
+ href = cleanHref;
13454
+ let out = `<img src="${href}" alt="${text}"`;
13455
+ if (title) {
13456
+ out += ` title="${title}"`;
13457
+ }
13458
+ out += '>';
13459
+ return out;
13460
+ }
13461
+ text(token) {
13462
+ return 'tokens' in token && token.tokens ? this.parser.parseInline(token.tokens) : token.text;
13463
+ }
13464
+ }
13465
+
13466
+ /**
13467
+ * TextRenderer
13468
+ * returns only the textual part of the token
13469
+ */
13470
+ class _TextRenderer {
13471
+ // no need for block level renderers
13472
+ strong({
13473
+ text
13474
+ }) {
13475
+ return text;
13476
+ }
13477
+ em({
13478
+ text
13479
+ }) {
13480
+ return text;
13481
+ }
13482
+ codespan({
13483
+ text
13484
+ }) {
13485
+ return text;
13486
+ }
13487
+ del({
13488
+ text
13489
+ }) {
13490
+ return text;
13491
+ }
13492
+ html({
13493
+ text
13494
+ }) {
13495
+ return text;
13496
+ }
13497
+ text({
13498
+ text
13499
+ }) {
13500
+ return text;
13501
+ }
13502
+ link({
13503
+ text
13504
+ }) {
13505
+ return '' + text;
13506
+ }
13507
+ image({
13508
+ text
13509
+ }) {
13510
+ return '' + text;
13511
+ }
13512
+ br() {
13513
+ return '';
13514
+ }
13515
+ }
13516
+
13517
+ /**
13518
+ * Parsing & Compiling
13519
+ */
13520
+ class _Parser {
13521
+ options;
13522
+ renderer;
13523
+ textRenderer;
13524
+ constructor(options) {
13525
+ this.options = options || _defaults;
13526
+ this.options.renderer = this.options.renderer || new _Renderer();
13527
+ this.renderer = this.options.renderer;
13528
+ this.renderer.options = this.options;
13529
+ this.renderer.parser = this;
13530
+ this.textRenderer = new _TextRenderer();
13531
+ }
13532
+ /**
13533
+ * Static Parse Method
13534
+ */
13535
+ static parse(tokens, options) {
13536
+ const parser = new _Parser(options);
13537
+ return parser.parse(tokens);
13538
+ }
13539
+ /**
13540
+ * Static Parse Inline Method
13541
+ */
13542
+ static parseInline(tokens, options) {
13543
+ const parser = new _Parser(options);
13544
+ return parser.parseInline(tokens);
13545
+ }
13546
+ /**
13547
+ * Parse Loop
13548
+ */
13549
+ parse(tokens, top = true) {
13550
+ let out = '';
13551
+ for (let i = 0; i < tokens.length; i++) {
13552
+ const anyToken = tokens[i];
13553
+ // Run any renderer extensions
13554
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
13555
+ const genericToken = anyToken;
13556
+ const ret = this.options.extensions.renderers[genericToken.type].call({
13557
+ parser: this
13558
+ }, genericToken);
13559
+ if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(genericToken.type)) {
13560
+ out += ret || '';
13561
+ continue;
13562
+ }
13563
+ }
13564
+ const token = anyToken;
13565
+ switch (token.type) {
13566
+ case 'space':
13567
+ {
13568
+ out += this.renderer.space(token);
13569
+ continue;
13570
+ }
13571
+ case 'hr':
13572
+ {
13573
+ out += this.renderer.hr(token);
13574
+ continue;
13575
+ }
13576
+ case 'heading':
13577
+ {
13578
+ out += this.renderer.heading(token);
13579
+ continue;
13580
+ }
13581
+ case 'code':
13582
+ {
13583
+ out += this.renderer.code(token);
13584
+ continue;
13585
+ }
13586
+ case 'table':
13587
+ {
13588
+ out += this.renderer.table(token);
13589
+ continue;
13590
+ }
13591
+ case 'blockquote':
13592
+ {
13593
+ out += this.renderer.blockquote(token);
13594
+ continue;
13595
+ }
13596
+ case 'list':
13597
+ {
13598
+ out += this.renderer.list(token);
13599
+ continue;
13600
+ }
13601
+ case 'html':
13602
+ {
13603
+ out += this.renderer.html(token);
13604
+ continue;
13605
+ }
13606
+ case 'paragraph':
13607
+ {
13608
+ out += this.renderer.paragraph(token);
13609
+ continue;
13610
+ }
13611
+ case 'text':
13612
+ {
13613
+ let textToken = token;
13614
+ let body = this.renderer.text(textToken);
13615
+ while (i + 1 < tokens.length && tokens[i + 1].type === 'text') {
13616
+ textToken = tokens[++i];
13617
+ body += '\n' + this.renderer.text(textToken);
13618
+ }
13619
+ if (top) {
13620
+ out += this.renderer.paragraph({
13621
+ type: 'paragraph',
13622
+ raw: body,
13623
+ text: body,
13624
+ tokens: [{
13625
+ type: 'text',
13626
+ raw: body,
13627
+ text: body
13628
+ }]
13629
+ });
13630
+ } else {
13631
+ out += body;
13632
+ }
13633
+ continue;
13634
+ }
13635
+ default:
13636
+ {
13637
+ const errMsg = 'Token with "' + token.type + '" type was not found.';
13638
+ if (this.options.silent) {
13639
+ console.error(errMsg);
13640
+ return '';
13641
+ } else {
13642
+ throw new Error(errMsg);
13643
+ }
13644
+ }
13645
+ }
13646
+ }
13647
+ return out;
13648
+ }
13649
+ /**
13650
+ * Parse Inline Tokens
13651
+ */
13652
+ parseInline(tokens, renderer) {
13653
+ renderer = renderer || this.renderer;
13654
+ let out = '';
13655
+ for (let i = 0; i < tokens.length; i++) {
13656
+ const anyToken = tokens[i];
13657
+ // Run any renderer extensions
13658
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
13659
+ const ret = this.options.extensions.renderers[anyToken.type].call({
13660
+ parser: this
13661
+ }, anyToken);
13662
+ if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(anyToken.type)) {
13663
+ out += ret || '';
13664
+ continue;
13665
+ }
13666
+ }
13667
+ const token = anyToken;
13668
+ switch (token.type) {
13669
+ case 'escape':
13670
+ {
13671
+ out += renderer.text(token);
13672
+ break;
13673
+ }
13674
+ case 'html':
13675
+ {
13676
+ out += renderer.html(token);
13677
+ break;
13678
+ }
13679
+ case 'link':
13680
+ {
13681
+ out += renderer.link(token);
13682
+ break;
13683
+ }
13684
+ case 'image':
13685
+ {
13686
+ out += renderer.image(token);
13687
+ break;
13688
+ }
13689
+ case 'strong':
13690
+ {
13691
+ out += renderer.strong(token);
13692
+ break;
13693
+ }
13694
+ case 'em':
13695
+ {
13696
+ out += renderer.em(token);
13697
+ break;
13698
+ }
13699
+ case 'codespan':
13700
+ {
13701
+ out += renderer.codespan(token);
13702
+ break;
13703
+ }
13704
+ case 'br':
13705
+ {
13706
+ out += renderer.br(token);
13707
+ break;
13708
+ }
13709
+ case 'del':
13710
+ {
13711
+ out += renderer.del(token);
13712
+ break;
13713
+ }
13714
+ case 'text':
13715
+ {
13716
+ out += renderer.text(token);
13717
+ break;
13718
+ }
13719
+ default:
13720
+ {
13721
+ const errMsg = 'Token with "' + token.type + '" type was not found.';
13722
+ if (this.options.silent) {
13723
+ console.error(errMsg);
13724
+ return '';
13725
+ } else {
13726
+ throw new Error(errMsg);
13727
+ }
13728
+ }
13729
+ }
13730
+ }
13731
+ return out;
13732
+ }
13733
+ }
13734
+ class _Hooks {
13735
+ options;
13736
+ block;
13737
+ constructor(options) {
13738
+ this.options = options || _defaults;
13739
+ }
13740
+ static passThroughHooks = new Set(['preprocess', 'postprocess', 'processAllTokens']);
13741
+ /**
13742
+ * Process markdown before marked
13743
+ */
13744
+ preprocess(markdown) {
13745
+ return markdown;
13746
+ }
13747
+ /**
13748
+ * Process HTML after marked is finished
13749
+ */
13750
+ postprocess(html) {
13751
+ return html;
13752
+ }
13753
+ /**
13754
+ * Process all tokens before walk tokens
13755
+ */
13756
+ processAllTokens(tokens) {
13757
+ return tokens;
13758
+ }
13759
+ /**
13760
+ * Provide function to tokenize markdown
13761
+ */
13762
+ provideLexer() {
13763
+ return this.block ? _Lexer.lex : _Lexer.lexInline;
13764
+ }
13765
+ /**
13766
+ * Provide function to parse tokens
13767
+ */
13768
+ provideParser() {
13769
+ return this.block ? _Parser.parse : _Parser.parseInline;
13770
+ }
13771
+ }
13772
+ class Marked {
13773
+ defaults = _getDefaults();
13774
+ options = this.setOptions;
13775
+ parse = this.parseMarkdown(true);
13776
+ parseInline = this.parseMarkdown(false);
13777
+ Parser = _Parser;
13778
+ Renderer = _Renderer;
13779
+ TextRenderer = _TextRenderer;
13780
+ Lexer = _Lexer;
13781
+ Tokenizer = _Tokenizer;
13782
+ Hooks = _Hooks;
13783
+ constructor(...args) {
13784
+ this.use(...args);
13785
+ }
13786
+ /**
13787
+ * Run callback for every token
13788
+ */
13789
+ walkTokens(tokens, callback) {
13790
+ let values = [];
13791
+ for (const token of tokens) {
13792
+ values = values.concat(callback.call(this, token));
13793
+ switch (token.type) {
13794
+ case 'table':
13795
+ {
13796
+ const tableToken = token;
13797
+ for (const cell of tableToken.header) {
13798
+ values = values.concat(this.walkTokens(cell.tokens, callback));
13799
+ }
13800
+ for (const row of tableToken.rows) {
13801
+ for (const cell of row) {
13802
+ values = values.concat(this.walkTokens(cell.tokens, callback));
13803
+ }
13804
+ }
13805
+ break;
13806
+ }
13807
+ case 'list':
13808
+ {
13809
+ const listToken = token;
13810
+ values = values.concat(this.walkTokens(listToken.items, callback));
13811
+ break;
13812
+ }
13813
+ default:
13814
+ {
13815
+ const genericToken = token;
13816
+ if (this.defaults.extensions?.childTokens?.[genericToken.type]) {
13817
+ this.defaults.extensions.childTokens[genericToken.type].forEach(childTokens => {
13818
+ const tokens = genericToken[childTokens].flat(Infinity);
13819
+ values = values.concat(this.walkTokens(tokens, callback));
13820
+ });
13821
+ } else if (genericToken.tokens) {
13822
+ values = values.concat(this.walkTokens(genericToken.tokens, callback));
13823
+ }
13824
+ }
13825
+ }
13826
+ }
13827
+ return values;
13828
+ }
13829
+ use(...args) {
13830
+ const extensions = this.defaults.extensions || {
13831
+ renderers: {},
13832
+ childTokens: {}
13833
+ };
13834
+ args.forEach(pack => {
13835
+ // copy options to new object
13836
+ const opts = {
13837
+ ...pack
13838
+ };
13839
+ // set async to true if it was set to true before
13840
+ opts.async = this.defaults.async || opts.async || false;
13841
+ // ==-- Parse "addon" extensions --== //
13842
+ if (pack.extensions) {
13843
+ pack.extensions.forEach(ext => {
13844
+ if (!ext.name) {
13845
+ throw new Error('extension name required');
13846
+ }
13847
+ if ('renderer' in ext) {
13848
+ // Renderer extensions
13849
+ const prevRenderer = extensions.renderers[ext.name];
13850
+ if (prevRenderer) {
13851
+ // Replace extension with func to run new extension but fall back if false
13852
+ extensions.renderers[ext.name] = function (...args) {
13853
+ let ret = ext.renderer.apply(this, args);
13854
+ if (ret === false) {
13855
+ ret = prevRenderer.apply(this, args);
13856
+ }
13857
+ return ret;
13858
+ };
13859
+ } else {
13860
+ extensions.renderers[ext.name] = ext.renderer;
13861
+ }
13862
+ }
13863
+ if ('tokenizer' in ext) {
13864
+ // Tokenizer Extensions
13865
+ if (!ext.level || ext.level !== 'block' && ext.level !== 'inline') {
13866
+ throw new Error("extension level must be 'block' or 'inline'");
13867
+ }
13868
+ const extLevel = extensions[ext.level];
13869
+ if (extLevel) {
13870
+ extLevel.unshift(ext.tokenizer);
13871
+ } else {
13872
+ extensions[ext.level] = [ext.tokenizer];
13873
+ }
13874
+ if (ext.start) {
13875
+ // Function to check for start of token
13876
+ if (ext.level === 'block') {
13877
+ if (extensions.startBlock) {
13878
+ extensions.startBlock.push(ext.start);
13879
+ } else {
13880
+ extensions.startBlock = [ext.start];
13881
+ }
13882
+ } else if (ext.level === 'inline') {
13883
+ if (extensions.startInline) {
13884
+ extensions.startInline.push(ext.start);
13885
+ } else {
13886
+ extensions.startInline = [ext.start];
13887
+ }
13888
+ }
13889
+ }
13890
+ }
13891
+ if ('childTokens' in ext && ext.childTokens) {
13892
+ // Child tokens to be visited by walkTokens
13893
+ extensions.childTokens[ext.name] = ext.childTokens;
13894
+ }
13895
+ });
13896
+ opts.extensions = extensions;
13897
+ }
13898
+ // ==-- Parse "overwrite" extensions --== //
13899
+ if (pack.renderer) {
13900
+ const renderer = this.defaults.renderer || new _Renderer(this.defaults);
13901
+ for (const prop in pack.renderer) {
13902
+ if (!(prop in renderer)) {
13903
+ throw new Error(`renderer '${prop}' does not exist`);
13904
+ }
13905
+ if (['options', 'parser'].includes(prop)) {
13906
+ // ignore options property
13907
+ continue;
13908
+ }
13909
+ const rendererProp = prop;
13910
+ const rendererFunc = pack.renderer[rendererProp];
13911
+ const prevRenderer = renderer[rendererProp];
13912
+ // Replace renderer with func to run extension, but fall back if false
13913
+ renderer[rendererProp] = (...args) => {
13914
+ let ret = rendererFunc.apply(renderer, args);
13915
+ if (ret === false) {
13916
+ ret = prevRenderer.apply(renderer, args);
13917
+ }
13918
+ return ret || '';
13919
+ };
13920
+ }
13921
+ opts.renderer = renderer;
13922
+ }
13923
+ if (pack.tokenizer) {
13924
+ const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
13925
+ for (const prop in pack.tokenizer) {
13926
+ if (!(prop in tokenizer)) {
13927
+ throw new Error(`tokenizer '${prop}' does not exist`);
13928
+ }
13929
+ if (['options', 'rules', 'lexer'].includes(prop)) {
13930
+ // ignore options, rules, and lexer properties
13931
+ continue;
13932
+ }
13933
+ const tokenizerProp = prop;
13934
+ const tokenizerFunc = pack.tokenizer[tokenizerProp];
13935
+ const prevTokenizer = tokenizer[tokenizerProp];
13936
+ // Replace tokenizer with func to run extension, but fall back if false
13937
+ // @ts-expect-error cannot type tokenizer function dynamically
13938
+ tokenizer[tokenizerProp] = (...args) => {
13939
+ let ret = tokenizerFunc.apply(tokenizer, args);
13940
+ if (ret === false) {
13941
+ ret = prevTokenizer.apply(tokenizer, args);
13942
+ }
13943
+ return ret;
13944
+ };
13945
+ }
13946
+ opts.tokenizer = tokenizer;
13947
+ }
13948
+ // ==-- Parse Hooks extensions --== //
13949
+ if (pack.hooks) {
13950
+ const hooks = this.defaults.hooks || new _Hooks();
13951
+ for (const prop in pack.hooks) {
13952
+ if (!(prop in hooks)) {
13953
+ throw new Error(`hook '${prop}' does not exist`);
13954
+ }
13955
+ if (['options', 'block'].includes(prop)) {
13956
+ // ignore options and block properties
13957
+ continue;
13958
+ }
13959
+ const hooksProp = prop;
13960
+ const hooksFunc = pack.hooks[hooksProp];
13961
+ const prevHook = hooks[hooksProp];
13962
+ if (_Hooks.passThroughHooks.has(prop)) {
13963
+ // @ts-expect-error cannot type hook function dynamically
13964
+ hooks[hooksProp] = arg => {
13965
+ if (this.defaults.async) {
13966
+ return Promise.resolve(hooksFunc.call(hooks, arg)).then(ret => {
13967
+ return prevHook.call(hooks, ret);
13968
+ });
13969
+ }
13970
+ const ret = hooksFunc.call(hooks, arg);
13971
+ return prevHook.call(hooks, ret);
13972
+ };
13973
+ } else {
13974
+ // @ts-expect-error cannot type hook function dynamically
13975
+ hooks[hooksProp] = (...args) => {
13976
+ let ret = hooksFunc.apply(hooks, args);
13977
+ if (ret === false) {
13978
+ ret = prevHook.apply(hooks, args);
13979
+ }
13980
+ return ret;
13981
+ };
13982
+ }
13983
+ }
13984
+ opts.hooks = hooks;
13985
+ }
13986
+ // ==-- Parse WalkTokens extensions --== //
13987
+ if (pack.walkTokens) {
13988
+ const walkTokens = this.defaults.walkTokens;
13989
+ const packWalktokens = pack.walkTokens;
13990
+ opts.walkTokens = function (token) {
13991
+ let values = [];
13992
+ values.push(packWalktokens.call(this, token));
13993
+ if (walkTokens) {
13994
+ values = values.concat(walkTokens.call(this, token));
13995
+ }
13996
+ return values;
13997
+ };
13998
+ }
13999
+ this.defaults = {
14000
+ ...this.defaults,
14001
+ ...opts
14002
+ };
14003
+ });
14004
+ return this;
14005
+ }
14006
+ setOptions(opt) {
14007
+ this.defaults = {
14008
+ ...this.defaults,
14009
+ ...opt
14010
+ };
14011
+ return this;
14012
+ }
14013
+ lexer(src, options) {
14014
+ return _Lexer.lex(src, options ?? this.defaults);
14015
+ }
14016
+ parser(tokens, options) {
14017
+ return _Parser.parse(tokens, options ?? this.defaults);
14018
+ }
14019
+ parseMarkdown(blockType) {
14020
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14021
+ const parse = (src, options) => {
14022
+ const origOpt = {
14023
+ ...options
14024
+ };
14025
+ const opt = {
14026
+ ...this.defaults,
14027
+ ...origOpt
14028
+ };
14029
+ const throwError = this.onError(!!opt.silent, !!opt.async);
14030
+ // throw error if an extension set async to true but parse was called with async: false
14031
+ if (this.defaults.async === true && origOpt.async === false) {
14032
+ return throwError(new Error('marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.'));
14033
+ }
14034
+ // throw error in case of non string input
14035
+ if (typeof src === 'undefined' || src === null) {
14036
+ return throwError(new Error('marked(): input parameter is undefined or null'));
14037
+ }
14038
+ if (typeof src !== 'string') {
14039
+ return throwError(new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected'));
14040
+ }
14041
+ if (opt.hooks) {
14042
+ opt.hooks.options = opt;
14043
+ opt.hooks.block = blockType;
14044
+ }
14045
+ const lexer = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
14046
+ const parser = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
14047
+ if (opt.async) {
14048
+ return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then(src => lexer(src, opt)).then(tokens => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then(tokens => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then(tokens => parser(tokens, opt)).then(html => opt.hooks ? opt.hooks.postprocess(html) : html).catch(throwError);
14049
+ }
14050
+ try {
14051
+ if (opt.hooks) {
14052
+ src = opt.hooks.preprocess(src);
14053
+ }
14054
+ let tokens = lexer(src, opt);
14055
+ if (opt.hooks) {
14056
+ tokens = opt.hooks.processAllTokens(tokens);
14057
+ }
14058
+ if (opt.walkTokens) {
14059
+ this.walkTokens(tokens, opt.walkTokens);
14060
+ }
14061
+ let html = parser(tokens, opt);
14062
+ if (opt.hooks) {
14063
+ html = opt.hooks.postprocess(html);
14064
+ }
14065
+ return html;
14066
+ } catch (e) {
14067
+ return throwError(e);
14068
+ }
14069
+ };
14070
+ return parse;
14071
+ }
14072
+ onError(silent, async) {
14073
+ return e => {
14074
+ e.message += '\nPlease report this to https://github.com/markedjs/marked.';
14075
+ if (silent) {
14076
+ const msg = '<p>An error occurred:</p><pre>' + escape$1(e.message + '', true) + '</pre>';
14077
+ if (async) {
14078
+ return Promise.resolve(msg);
14079
+ }
14080
+ return msg;
14081
+ }
14082
+ if (async) {
14083
+ return Promise.reject(e);
14084
+ }
14085
+ throw e;
14086
+ };
14087
+ }
14088
+ }
14089
+ const markedInstance = new Marked();
14090
+ function marked(src, opt) {
14091
+ return markedInstance.parse(src, opt);
14092
+ }
14093
+ /**
14094
+ * Sets the default options.
14095
+ *
14096
+ * @param options Hash of options
14097
+ */
14098
+ marked.options = marked.setOptions = function (options) {
14099
+ markedInstance.setOptions(options);
14100
+ marked.defaults = markedInstance.defaults;
14101
+ changeDefaults(marked.defaults);
14102
+ return marked;
14103
+ };
14104
+ /**
14105
+ * Gets the original marked default options.
14106
+ */
14107
+ marked.getDefaults = _getDefaults;
14108
+ marked.defaults = _defaults;
14109
+ /**
14110
+ * Use Extension
14111
+ */
14112
+ marked.use = function (...args) {
14113
+ markedInstance.use(...args);
14114
+ marked.defaults = markedInstance.defaults;
14115
+ changeDefaults(marked.defaults);
14116
+ return marked;
14117
+ };
14118
+ /**
14119
+ * Run callback for every token
14120
+ */
14121
+ marked.walkTokens = function (tokens, callback) {
14122
+ return markedInstance.walkTokens(tokens, callback);
14123
+ };
14124
+ /**
14125
+ * Compiles markdown to HTML without enclosing `p` tag.
14126
+ *
14127
+ * @param src String of markdown source to be compiled
14128
+ * @param options Hash of options
14129
+ * @return String of compiled HTML
14130
+ */
14131
+ marked.parseInline = markedInstance.parseInline;
14132
+ /**
14133
+ * Expose
14134
+ */
14135
+ marked.Parser = _Parser;
14136
+ marked.parser = _Parser.parse;
14137
+ marked.Renderer = _Renderer;
14138
+ marked.TextRenderer = _TextRenderer;
14139
+ marked.Lexer = _Lexer;
14140
+ marked.lexer = _Lexer.lex;
14141
+ marked.Tokenizer = _Tokenizer;
14142
+ marked.Hooks = _Hooks;
14143
+ marked.parse = marked;
14144
+ const options = marked.options;
14145
+ const setOptions = marked.setOptions;
14146
+ const use = marked.use;
14147
+ const walkTokens = marked.walkTokens;
14148
+ const parseInline = marked.parseInline;
14149
+ const parse = (/* unused pure expression or super */ null && (marked));
14150
+ const parser = _Parser.parse;
14151
+ const lexer = _Lexer.lex;
14152
+
14153
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat.vue?vue&type=script&lang=js
14154
+
14155
+
14156
+
14157
+
14158
+
14159
+ const controller = new AbortController();
14160
+ const signal = controller.signal;
14161
+ /* harmony default export */ var chatvue_type_script_lang_js = ({
14162
+ name: 'Chat',
14163
+ components: {
14164
+ ErrorChat: error_chat,
14165
+ ChatTools: chat_tools
14166
+ },
14167
+ props: {
14168
+ analyExercise: {},
14169
+ keyWord: {
14170
+ type: String,
14171
+ default: ''
14172
+ },
14173
+ resId: {
14174
+ type: String,
14175
+ default: ''
14176
+ },
14177
+ xtId: {
14178
+ type: String,
14179
+ default: ''
14180
+ }
14181
+ },
14182
+ data() {
14183
+ return {
14184
+ popover: false,
14185
+ input: '',
14186
+ errors: [],
14187
+ errorList: errorList,
14188
+ cacheKeyWord: '',
14189
+ // 由于外部需要快速清掉 keyword 但是存在重新发送请求的情况,因此需要一个混存记录
14190
+ messageData: [],
14191
+ chatId: '',
14192
+ // 对话id
14193
+ chatMajorId: '',
14194
+ finish: false
14195
+ };
14196
+ },
14197
+ computed: {
14198
+ canSubmit() {
14199
+ return this.errors.length === 0 && this.input === "";
14200
+ }
14201
+ },
14202
+ watch: {
14203
+ keyWord: {
14204
+ handler() {
14205
+ if (this.keyWord) {
14206
+ this.cacheKeyWord = this.keyWord;
14207
+ this.postMessage();
14208
+ }
14209
+ },
14210
+ immediate: true
14211
+ }
14212
+ },
14213
+ methods: {
14214
+ cancelPopover() {
14215
+ this.popover = false;
14216
+ },
14217
+ openPopover() {
14218
+ this.popover = true;
14219
+ },
14220
+ scrollToBottom() {
14221
+ this.$refs.chatContainer.scrollTop = this.$refs.chatContainer.scrollHeight;
14222
+ },
14223
+ async postMessage(list, commonKey, parentMsgId) {
14224
+ let reanswerParams = {};
14225
+ this.finish = false;
14226
+ if (list) {
14227
+ list.sending = true;
14228
+ reanswerParams = {
14229
+ reStatus: 1,
14230
+ parentMsgId: list.parentMsgId,
14231
+ msgId: list.msgId,
14232
+ content: this.messageData[list.index - 1].message
14233
+ };
14234
+ this.messageData[list.index].message = '';
14235
+ this.messageData[list.index].cacheMessage = '';
14236
+ this.makeAutoMessage();
14237
+ }
14238
+ const params = {
14239
+ messageList: [{
14240
+ content: this.keyWord || this.cacheKeyWord,
14241
+ resId: this.resId,
14242
+ chatId: this.chatId || undefined,
14243
+ commonKey: commonKey || false,
14244
+ parentMsgId: parentMsgId || undefined,
14245
+ xtId: this.analyExercise.busId,
14246
+ ...reanswerParams
14247
+ }]
14248
+ };
14249
+ // list 存在说明是重新生成
14250
+ if (!list && !commonKey) {
14251
+ const userWord = this.keyWord || this.cacheKeyWord;
14252
+ this.messageData.push({
14253
+ type: 'user',
14254
+ message: userWord.replace(/\n/g, '<br>')
14255
+ });
14256
+ setTimeout(() => {
14257
+ this.messageData.push({
14258
+ type: 'robot',
14259
+ message: '',
14260
+ cacheMessage: '',
14261
+ zan: false,
14262
+ cai: false,
14263
+ stop: false,
14264
+ finish: false,
14265
+ sending: true,
14266
+ links: [],
14267
+ connectUrl: [],
14268
+ reAnswerCount: 0
14269
+ });
14270
+ this.makeAutoMessage();
14271
+ });
14272
+ }
14273
+ await sendMessageEventSource(params, signal, res => {
14274
+ this.makeMessageLine(res, list);
14275
+ });
14276
+ },
14277
+ makeAutoMessage() {
14278
+ const cacheMessage = [];
14279
+ for (let i = 0; i < this.messageData.length; i++) {
14280
+ const current = this.messageData[i];
14281
+ cacheMessage.push({
14282
+ role: current.type === 'robot' ? 'assistant' : 'user',
14283
+ content: current.message || '正在思考中。'
14284
+ });
14285
+ }
14286
+ this.makeAutoQuestioning(cacheMessage);
14287
+ },
14288
+ makeMessageLine(res, list) {
14289
+ const {
14290
+ content,
14291
+ status,
14292
+ chatId,
14293
+ msgId,
14294
+ parentMsgId,
14295
+ reference,
14296
+ commonKey,
14297
+ connectUrl
14298
+ } = JSON.parse(res.data);
14299
+ let index = list ? list.index : this.messageData.length - 1;
14300
+ const currentList = this.messageData[index];
14301
+ let allIdWithStart = true;
14302
+ // 结束标识
14303
+ if (status === 2 || status === 1) {
14304
+ if (commonKey) {
14305
+ currentList.sending = true;
14306
+ this.postMessage(list, commonKey, parentMsgId);
14307
+ return;
14308
+ }
14309
+ currentList.finish = true;
14310
+ if (reference) {
14311
+ currentList.links = JSON.parse(reference);
14312
+ currentList.links.map(item => {
14313
+ if (!item.title.startsWith(this.chatMajorId)) {
14314
+ allIdWithStart = false;
14315
+ }
14316
+ });
14317
+ }
14318
+ if (connectUrl) {
14319
+ currentList.connectUrl = JSON.parse(connectUrl);
14320
+ }
14321
+ currentList.allIdWithStart = allIdWithStart;
14322
+ this.cacheKeyWord = '';
14323
+ this.finish = true;
14324
+ this.$emit('on-message-finish', chatId);
14325
+ return;
14326
+ }
14327
+ currentList.cacheMessage += content;
14328
+ currentList.message = marked.parse(currentList.cacheMessage);
14329
+ currentList.msgId = msgId;
14330
+ currentList.parentMsgId = parentMsgId;
14331
+ currentList.chatId = chatId;
14332
+ setTimeout(() => {
14333
+ if (!list) this.scrollToBottom();
14334
+ }, 100);
14335
+ // 防止出现调用基础模型前导致停止回答id错误
14336
+ setTimeout(() => currentList.sending = false, 500);
14337
+ },
14338
+ async makeAutoQuestioning(messages) {
14339
+ // 首次不触发
14340
+ if (messages.length <= 2) return;
14341
+ const autoRes = await getAutoQuestioning(this.chatMajorId, messages);
14342
+ const {
14343
+ message: {
14344
+ content: {
14345
+ followUps
14346
+ }
14347
+ }
14348
+ } = autoRes;
14349
+ this.messageData[this.messageData.length - 1].followUps = followUps.length > 3 ? followUps.splice(0, 3) : followUps;
14350
+ },
14351
+ onStopChat(list) {
14352
+ this.$emit('on-message-finish', list.chatId);
14353
+ },
14354
+ selectModule(message) {
14355
+ this.cacheKeyWord = message;
14356
+ this.postMessage();
14357
+ },
14358
+ async clearChat() {
14359
+ if (this.messageData.length < 1) {
14360
+ this.$message.warning('当前对话为最新对话');
14361
+ return;
14362
+ }
14363
+ await chartClear(this.chatId);
14364
+ this.messageData = [];
11798
14365
  this.$message.success('对话清除成功!');
11799
14366
  },
11800
14367
  reanswer(list, index) {
@@ -11802,28 +14369,39 @@ const signal = controller.signal;
11802
14369
  list.stop = false;
11803
14370
  list.finish = false;
11804
14371
  list.links = [];
14372
+ list.connectUrl = [];
11805
14373
  this.postMessage(list);
11806
14374
  this.$emit('on-reanser');
11807
14375
  },
11808
14376
  errorChatInit(list, chatId) {
11809
- const {
11810
- chatMajorId
11811
- } = list[0];
11812
- this.chatMajorId = chatMajorId.toString();
11813
14377
  if (list && list[0].contents) {
14378
+ const {
14379
+ chatMajorId
14380
+ } = list[0];
14381
+ this.chatMajorId = chatMajorId && chatMajorId.toString();
11814
14382
  const cacheArray = [];
11815
14383
  list[0].contents.reverse().map(list => {
14384
+ let allIdWithStart = true;
14385
+ if (this.chatMajorId && list.references) {
14386
+ list.references.map(item => {
14387
+ if (!item.title.startsWith(this.chatMajorId)) {
14388
+ allIdWithStart = false;
14389
+ }
14390
+ });
14391
+ }
11816
14392
  const obj = {
11817
14393
  type: list.role === 'assistant' ? 'robot' : 'user',
11818
- message: list.content.replace(/\n/g, '<br>'),
14394
+ message: list.role === 'assistant' ? marked.parse(list.content) : list.content.replace(/\n/g, '<br>'),
11819
14395
  zan: list.type === 1,
11820
14396
  cai: list.type === 2,
11821
14397
  stop: list.status === 1,
11822
14398
  finish: true,
11823
14399
  links: list.references || [],
14400
+ connectUrl: list.connectUrls || [],
11824
14401
  reAnswerCount: 0,
11825
14402
  msgId: list.contentId,
11826
- parentMsgId: list.parentMsgId
14403
+ parentMsgId: list.parentMsgId,
14404
+ allIdWithStart
11827
14405
  };
11828
14406
  cacheArray.push(obj);
11829
14407
  });
@@ -11837,10 +14415,10 @@ const signal = controller.signal;
11837
14415
  });
11838
14416
  ;// CONCATENATED MODULE: ./components/demo/src/chat.vue?vue&type=script&lang=js
11839
14417
  /* harmony default export */ var src_chatvue_type_script_lang_js = (chatvue_type_script_lang_js);
11840
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat.vue?vue&type=style&index=0&id=8e426b78&prod&lang=scss&scoped=true
14418
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat.vue?vue&type=style&index=0&id=d21026be&prod&lang=scss&scoped=true
11841
14419
  // extracted by mini-css-extract-plugin
11842
14420
 
11843
- ;// CONCATENATED MODULE: ./components/demo/src/chat.vue?vue&type=style&index=0&id=8e426b78&prod&lang=scss&scoped=true
14421
+ ;// CONCATENATED MODULE: ./components/demo/src/chat.vue?vue&type=style&index=0&id=d21026be&prod&lang=scss&scoped=true
11844
14422
 
11845
14423
  ;// CONCATENATED MODULE: ./components/demo/src/chat.vue
11846
14424
 
@@ -11853,11 +14431,11 @@ const signal = controller.signal;
11853
14431
 
11854
14432
  var chat_component = normalizeComponent(
11855
14433
  src_chatvue_type_script_lang_js,
11856
- chatvue_type_template_id_8e426b78_scoped_true_render,
11857
- chatvue_type_template_id_8e426b78_scoped_true_staticRenderFns,
14434
+ chatvue_type_template_id_d21026be_scoped_true_render,
14435
+ chatvue_type_template_id_d21026be_scoped_true_staticRenderFns,
11858
14436
  false,
11859
14437
  null,
11860
- "8e426b78",
14438
+ "d21026be",
11861
14439
  null
11862
14440
 
11863
14441
  )
@@ -12000,13 +14578,29 @@ var api = init(defaultConverter, {
12000
14578
  return this.analyExercise.busId;
12001
14579
  }
12002
14580
  },
14581
+ watch: {
14582
+ visible() {
14583
+ if (this.visible) {
14584
+ checkCourseIdIsExist(this.resId).then(res => {
14585
+ if (res.flag === true) {
14586
+ this.courseFlag = true;
14587
+ } else {
14588
+ this.courseFlag = false;
14589
+ this.message = res.message;
14590
+ }
14591
+ });
14592
+ }
14593
+ }
14594
+ },
12003
14595
  data() {
12004
14596
  return {
12005
14597
  aiMessage: '',
12006
14598
  // 页面显示值
12007
14599
  aiMessageKeyWord: '',
12008
14600
  // 传入组件值
12009
- stop: false
14601
+ stop: false,
14602
+ courseFlag: false,
14603
+ message: ''
12010
14604
  };
12011
14605
  },
12012
14606
  mounted() {
@@ -12066,10 +14660,10 @@ var api = init(defaultConverter, {
12066
14660
  });
12067
14661
  ;// CONCATENATED MODULE: ./components/demo/src/main.vue?vue&type=script&lang=js
12068
14662
  /* harmony default export */ var src_mainvue_type_script_lang_js = (mainvue_type_script_lang_js);
12069
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/main.vue?vue&type=style&index=0&id=63ef79ac&prod&lang=scss&scoped=true
14663
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/main.vue?vue&type=style&index=0&id=3f590f5c&prod&lang=scss&scoped=true
12070
14664
  // extracted by mini-css-extract-plugin
12071
14665
 
12072
- ;// CONCATENATED MODULE: ./components/demo/src/main.vue?vue&type=style&index=0&id=63ef79ac&prod&lang=scss&scoped=true
14666
+ ;// CONCATENATED MODULE: ./components/demo/src/main.vue?vue&type=style&index=0&id=3f590f5c&prod&lang=scss&scoped=true
12073
14667
 
12074
14668
  ;// CONCATENATED MODULE: ./components/demo/src/main.vue
12075
14669
 
@@ -12086,7 +14680,7 @@ var main_component = normalizeComponent(
12086
14680
  staticRenderFns,
12087
14681
  false,
12088
14682
  null,
12089
- "63ef79ac",
14683
+ "3f590f5c",
12090
14684
  null
12091
14685
 
12092
14686
  )