wi-chat 0.0.0-stage → 0.4.0

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.
Files changed (99) hide show
  1. package/dist/core/index.cjs +2 -0
  2. package/dist/core/index.d.ts +13 -0
  3. package/dist/core/index.js +454 -0
  4. package/dist/core/useAgent.d.ts +35 -0
  5. package/dist/core/useChat.d.ts +195 -0
  6. package/dist/core/useChatSession.d.ts +89 -0
  7. package/dist/core/useHistory.d.ts +63 -0
  8. package/dist/index.cjs +2 -0
  9. package/dist/index.d.ts +11 -0
  10. package/dist/index.js +81 -0
  11. package/dist/mobile-ui/chat/ChatContainer.vue.d.ts +129 -0
  12. package/dist/mobile-ui/chat/ChatMessagesView.vue.d.ts +77 -0
  13. package/dist/mobile-ui/chat/types.d.ts +9 -0
  14. package/dist/mobile-ui/index.cjs +2 -0
  15. package/dist/mobile-ui/index.d.ts +7 -0
  16. package/dist/mobile-ui/index.js +225 -0
  17. package/dist/mobile-ui/inputbox/Inputbox.vue.d.ts +95 -0
  18. package/dist/mobile-ui/style.css +1 -0
  19. package/dist/parser/answer.d.ts +51 -0
  20. package/dist/parser/answerCom/iframePage/parseIframePage.d.ts +49 -0
  21. package/dist/parser/answerCom/iframePage/types.d.ts +11 -0
  22. package/dist/parser/answerCom/knowledgeStream/parseKnowledgeStream.d.ts +54 -0
  23. package/dist/parser/answerCom/knowledgeStream/types.d.ts +27 -0
  24. package/dist/parser/answerCom/outputFile/parseOutputFile.d.ts +43 -0
  25. package/dist/parser/answerCom/outputFile/types.d.ts +17 -0
  26. package/dist/parser/answerCom/recordset/parseRecordset.d.ts +48 -0
  27. package/dist/parser/answerCom/recordset/types.d.ts +36 -0
  28. package/dist/parser/attach/attachActions.d.ts +43 -0
  29. package/dist/parser/attach/index.d.ts +9 -0
  30. package/dist/parser/attach/parseAttach.d.ts +27 -0
  31. package/dist/parser/attach/types.d.ts +48 -0
  32. package/dist/parser/deepThinking/parseDeepThinking.d.ts +30 -0
  33. package/dist/parser/deepThinking/types.d.ts +14 -0
  34. package/dist/parser/history/history.d.ts +54 -0
  35. package/dist/parser/history/index.d.ts +7 -0
  36. package/dist/parser/index.cjs +3 -0
  37. package/dist/parser/index.d.ts +45 -0
  38. package/dist/parser/index.js +479 -0
  39. package/dist/parser/message.d.ts +60 -0
  40. package/dist/parser/registry.d.ts +81 -0
  41. package/dist/parser/sse.d.ts +34 -0
  42. package/dist/parser/stream.d.ts +8 -0
  43. package/dist/renderers/aiAnswer/AiAnswerBubble.vue.d.ts +58 -0
  44. package/dist/renderers/aiAnswer/contentMap.d.ts +13 -0
  45. package/dist/renderers/deepThinking/DeepThinkingSteps.vue.d.ts +21 -0
  46. package/dist/renderers/iframePage/IframePage.vue.d.ts +19 -0
  47. package/dist/renderers/iframePage/useIframePage.d.ts +64 -0
  48. package/dist/renderers/index.cjs +2 -0
  49. package/dist/renderers/index.d.ts +12 -0
  50. package/dist/renderers/index.js +609 -0
  51. package/dist/renderers/knowledgeStream/KnowledgeStreamResult.vue.d.ts +19 -0
  52. package/dist/renderers/outputFile/OutputFile.vue.d.ts +19 -0
  53. package/dist/renderers/outputFile/useOutputFile.d.ts +85 -0
  54. package/dist/renderers/style.css +1 -0
  55. package/dist/request/api.d.ts +132 -0
  56. package/dist/request/client.d.ts +30 -0
  57. package/dist/request/index.cjs +4 -0
  58. package/dist/request/index.d.ts +18 -0
  59. package/dist/request/index.js +264 -0
  60. package/dist/request/login.d.ts +37 -0
  61. package/dist/request/ws.d.ts +91 -0
  62. package/dist/style.css +24 -0
  63. package/dist/styles/github.css +2 -0
  64. package/dist/styles/katex.css +2 -0
  65. package/dist/theme/index.cjs +3 -0
  66. package/dist/theme/index.d.ts +3 -0
  67. package/dist/theme/index.js +37 -0
  68. package/dist/theme/theme.d.ts +40 -0
  69. package/dist/tools/attachDownload.d.ts +20 -0
  70. package/dist/tools/index.cjs +17 -0
  71. package/dist/tools/index.d.ts +8 -0
  72. package/dist/tools/index.js +251 -0
  73. package/dist/tools/markdown/MarkdownContent.vue.d.ts +36 -0
  74. package/dist/tools/markdown/imagePreview.d.ts +15 -0
  75. package/dist/tools/markdown/index.d.ts +5 -0
  76. package/dist/tools/markdown/renderMarkdown.d.ts +22 -0
  77. package/dist/tools/markdown/tableDownload.d.ts +14 -0
  78. package/dist/tools/stream.d.ts +9 -0
  79. package/dist/tools/style.css +1 -0
  80. package/dist/tools/useAutoScroll.d.ts +31 -0
  81. package/dist/web-ui/attach/AttachmentCard.vue.d.ts +91 -0
  82. package/dist/web-ui/attach/AttachmentList.vue.d.ts +94 -0
  83. package/dist/web-ui/attach/types.d.ts +5 -0
  84. package/dist/web-ui/chat/ChatContainer.vue.d.ts +165 -0
  85. package/dist/web-ui/chat/ChatMessagesView.vue.d.ts +88 -0
  86. package/dist/web-ui/chat/types.d.ts +24 -0
  87. package/dist/web-ui/envswitch/EnvSwitch.vue.d.ts +67 -0
  88. package/dist/web-ui/envswitch/types.d.ts +22 -0
  89. package/dist/web-ui/index.cjs +2 -0
  90. package/dist/web-ui/index.d.ts +14 -0
  91. package/dist/web-ui/index.js +1048 -0
  92. package/dist/web-ui/inputbox/Inputbox.vue.d.ts +215 -0
  93. package/dist/web-ui/recordset/RecordsetTable.vue.d.ts +37 -0
  94. package/dist/web-ui/recordset/webAnswerContentMap.d.ts +9 -0
  95. package/dist/web-ui/style.css +1 -0
  96. package/package.json +124 -4
  97. package/styles/github.css +2 -0
  98. package/styles/katex.css +2 -0
  99. package/README.md +0 -3
@@ -0,0 +1,479 @@
1
+ const E = () => ({
2
+ answer_type: "knowledge_stream_result",
3
+ values: [{ answer: "" }]
4
+ }), A = (e) => (e.answer_type = "knowledge_stream_result", (!Array.isArray(e.values) || !e.values.length) && (e.values = [{ answer: "" }]), e), D = (e = "", t = "") => ({
5
+ id: e,
6
+ question: t,
7
+ answer: { reports: [] }
8
+ }), W = [
9
+ "knowledge_stream_begin",
10
+ "knowledge_stream",
11
+ "knowledge_stream_result",
12
+ "knowledge_stream_end"
13
+ ], R = (e, t, n, o) => {
14
+ var u;
15
+ if (!e.mode || !W.includes(e.mode))
16
+ return !1;
17
+ if (e.mode === "knowledge_stream_result" || e.mode === "knowledge_stream_end")
18
+ return !0;
19
+ const i = o == null ? void 0 : o.beforeKnowledgeRender, r = (l) => i ? i(l) : l;
20
+ if (e.mode === "knowledge_stream_begin") {
21
+ const l = t.at(-1);
22
+ return (l == null ? void 0 : l.answer_type) === "knowledge_stream_result" ? (l.values = l.values ?? [], l.values.push({ answer: "" }), !0) : l && !l.answer_type ? (A(l), !0) : (t.push(E()), !0);
23
+ }
24
+ if (e.mode !== "knowledge_stream")
25
+ return !1;
26
+ let s = t.at(-1);
27
+ s && !s.answer_type ? s = A(s) : (!s || s.answer_type !== "knowledge_stream_result") && (s = E(), t.push(s)), s.values = (u = s.values) != null && u.length ? s.values : [{ answer: "" }];
28
+ const a = s.values[s.values.length - 1], c = `${a.raw ?? ""}${e.value || ""}`;
29
+ return a.raw = c, a.answer = r(c), !0;
30
+ }, q = (e, t) => {
31
+ if (Array.isArray(e.values) && e.values.length)
32
+ return e;
33
+ const n = t == null ? void 0 : t.beforeKnowledgeRender, o = (r) => n ? n(r) : r;
34
+ let i = [];
35
+ return Array.isArray(e.knowledge) && (i = e.knowledge.map((r) => typeof r == "string" ? r : r == null ? void 0 : r.answer).filter((r) => typeof r == "string" && r !== "")), i.length === 0 && typeof e.answer == "string" && e.answer !== "" && (i = [e.answer]), i.length && (e.values = i.map((r) => ({ answer: o(r), raw: r }))), e;
36
+ }, K = {
37
+ id: "knowledge_stream",
38
+ answerType: "knowledge_stream_result",
39
+ applyChunk: R,
40
+ normalizeReport: q
41
+ }, j = ["begin", "begin_stream", "send_stream", "end_stream"], X = (e, t) => {
42
+ if (!j.includes(e.mode || ""))
43
+ return !1;
44
+ let n = t.at(-1);
45
+ return (!n || n.answer_type) && (n = { exec_process: [] }, t.push(n)), n.exec_process = n.exec_process ?? [], n.exec_process.push({ mode: e.mode, type: e.type, value: e.value }), !0;
46
+ }, V = (e) => {
47
+ const t = [];
48
+ let n = "", o = !1;
49
+ for (const i of (e.exec_process ?? []).filter(
50
+ (r) => j.includes(r.mode || "")
51
+ )) {
52
+ const r = typeof i.value == "string" ? i.value : "";
53
+ i.mode === "begin" ? (o && n.trim() && t.push(n.trim()), o = !1, n = "", r.trim() && t.push(r.trim())) : i.mode === "begin_stream" ? (o && n.trim() && t.push(n.trim()), o = !0, n = r) : i.mode === "send_stream" && o ? n += r : i.mode === "end_stream" && o && (n += r, n.trim() && t.push(n.trim()), o = !1, n = "");
54
+ }
55
+ return o && n.trim() && t.push(n.trim()), t;
56
+ }, I = (e) => {
57
+ var t;
58
+ return (((t = e.answer) == null ? void 0 : t.reports) ?? []).flatMap(V);
59
+ }, G = {
60
+ id: "deep_thinking",
61
+ applyChunk: X
62
+ }, $ = '/**\n * Skipped minification because the original files appears to be already minified.\n * Original file: /npm/@iframe-resizer/child@5.1.5/index.umd.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n/*!\n * @preserve\n * \n * @module iframe-resizer/child 5.1.5 (umd) - 2024-07-09\n *\n * @license GPL-3.0 for non-commercial use only.\n * For commercial use, you must purchase a license from\n * https://iframe-resizer.com/pricing\n * \n * @desciption Keep same and cross domain iFrames sized to their content \n *\n * @author David J. Bradshaw <info@iframe-resizer.com>\n * \n * @see {@link https://iframe-resizer.com}\n * \n * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.\n */\n\n\n!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="5.1.5",t=10,n="data-iframe-size",o=(e,t,n,o)=>e.addEventListener(t,n,o||!1),i=(e,t,n)=>e.removeEventListener(t,n,!1),r=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const a=e=>(e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(r[e]),l={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},c={height:()=>(de("Custom height calculation function not defined"),He.auto()),width:()=>(de("Custom width calculation function not defined"),Ue.auto())},s={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,documentElementBoundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},u=128,d={},m="checkVisibility"in window,f="auto",p="[iFrameSizer]",h=p.length,y={max:1,min:1,bodyScroll:1,documentElementScroll:1},g=["body"],v="scroll";let b,w,z=!0,S="",$=0,j="",E=null,P="",O=!0,M=!1,A=null,C=!0,T=!1,k=1,I=f,x=!0,N="",R={},B=!0,q=!1,L=0,W=!1,D="",H="child",U=null,F=!1,V="",J=window.parent,Z="*",Q=0,X=!1,Y="",G=1,K=v,_=window,ee=()=>{de("onMessage function not defined")},te=()=>{},ne=null,oe=null;const ie=e=>""!=`${e}`&&void 0!==e,re=new WeakSet,ae=e=>"object"==typeof e&&re.add(e);function le(e){switch(!0){case!ie(e):return"";case ie(e.id):return`${e.nodeName.toUpperCase()}#${e.id}`;case ie(e.name):return`${e.nodeName.toUpperCase()} (${e.name})`;default:return e.nodeName.toUpperCase()+(ie(e.className)?`.${e.className}`:"")}}function ce(e,t=30){const n=e?.outerHTML?.toString();return n?n.length<t?n:`${n.slice(0,t).replaceAll("\\n"," ")}...`:e}const se=(...e)=>[`[iframe-resizer][${D}]`,...e].join(" "),ue=(...e)=>console?.info(se(...e)),de=(...e)=>console?.warn(se(...e)),me=(...e)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\\n").replaceAll("<rb>","\x1B[31;1m").replaceAll("</>","\x1B[m").replaceAll("<b>","\x1B[1m").replaceAll("<i>","\x1B[3m").replaceAll("<u>","\x1B[4m")):e(t.replaceAll("<br>","\\n").replaceAll(/<[/a-z]+>/gi,"")))(se)(...e)),fe=e=>me(e);function pe(){!function(){try{F="iframeParentListener"in window.parent}catch(e){}}(),function(){const e=e=>"true"===e,t=N.slice(h).split(":");D=t[0],$=void 0===t[1]?$:Number(t[1]),M=void 0===t[2]?M:e(t[2]),q=void 0===t[3]?q:e(t[3]),z=void 0===t[6]?z:e(t[6]),j=t[7],I=void 0===t[8]?I:t[8],S=t[9],P=t[10],Q=void 0===t[11]?Q:Number(t[11]),R.enable=void 0!==t[12]&&e(t[12]),H=void 0===t[13]?H:t[13],K=void 0===t[14]?K:t[14],W=void 0===t[15]?W:e(t[15]),b=void 0===t[16]?b:Number(t[16]),w=void 0===t[17]?w:Number(t[17]),O=void 0===t[18]?O:e(t[18]),t[19],Y=t[20]||Y,L=void 0===t[21]?L:Number(t[21])}(),function(){function e(){const e=window.iframeResizer||window.iFrameResizer;ee=e?.onMessage||ee,te=e?.onReady||te,"number"==typeof e?.offset&&(O&&(b=e?.offset),M&&(w=e?.offset)),Object.prototype.hasOwnProperty.call(e,"sizeSelector")&&(V=e.sizeSelector),Z=e?.targetOrigin||Z,I=e?.heightCalculationMethod||I,K=e?.widthCalculationMethod||K}function t(e,t){return"function"==typeof e&&(c[t]=e,e="custom"),e}if(1===L)return;"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),I=t(I,"height"),K=t(K,"width"))}(),function(){void 0===j&&(j=`${$}px`);he("margin",function(e,t){t.includes("-")&&(de(`Negative CSS value ignored for ${e}`),t="");return t}("margin",j))}(),he("background",S),he("padding",P),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),ye(),L<0?fe(`${a(L+2)}${a(2)}`):Y.codePointAt(0)>4||L<2&&fe(a(3)),function(){if(!Y||""===Y||"false"===Y)return void me("<rb>Legacy version detected on parent page</>\\n\\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\\n\\nSee <u>https://iframe-resizer.com/setup/</> for more details.\\n");Y!==e&&me(`<rb>Version mismatch</>\\n\\nThe parent and child pages are running different versions of <i>iframe resizer</>.\\n\\nParent page: ${Y} - Child page: ${e}.\\n`)}(),ze(),Se(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((o=>{e=!0,o.removeAttribute(t),o.setAttribute(n,null)}));t("data-iframe-height"),t("data-iframe-width"),e&&me("<rb>Deprecated Attributes</>\\n \\nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),document.querySelectorAll(`[${n}]`).length>0&&("auto"===I&&(I="autoOverflow"),"auto"===K&&(K="autoOverflow")),be(),function(){if(1===L)return;_.parentIframe=Object.freeze({autoResize:e=>(!0===e&&!1===z?(z=!0,$e()):!1===e&&!0===z&&(z=!1,ve("remove"),U?.disconnect(),E?.disconnect()),Xe(0,0,"autoResize",JSON.stringify(z)),z),close(){Xe(0,0,"close")},getId:()=>D,getPageInfo(e){if("function"==typeof e)return ne=e,Xe(0,0,"pageInfo"),void me("<rb>Deprecated Method</>\\n \\nThe <b>getPageInfo()</> method has been deprecated and replaced with <b>getParentProps()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n");ne=null,Xe(0,0,"pageInfoStop")},getParentProps(e){if("function"!=typeof e)throw new TypeError("parentIFrame.getParentProps(callback) callback not a function");return oe=e,Xe(0,0,"parentInfo"),()=>{oe=null,Xe(0,0,"parentInfoStop")}},getParentProperties(e){me("<rb>Renamed Method</>\\n \\nThe <b>getParentProperties()</> method has been renamed <b>getParentProps()</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.\\n"),this.getParentProps(e)},moveToAnchor(e){R.findTarget(e)},reset(){Qe()},scrollBy(e,t){Xe(t,e,"scrollBy")},scrollTo(e,t){Xe(t,e,"scrollTo")},scrollToOffset(e,t){Xe(t,e,"scrollToOffset")},sendMessage(e,t){Xe(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){I=e,ze()},setWidthCalculationMethod(e){K=e,Se()},setTargetOrigin(e){Z=e},resize(e,t){Ve("size",`parentIFrame.size(${`${e||""}${t?`,${t}`:""}`})`,e,t)},size(e,t){me("<rb>Deprecated Method</>\\n \\nThe <b>size()</> method has been deprecated and replaced with <b>resize()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n"),this.resize(e,t)}}),_.parentIFrame=_.parentIframe}(),function(){if(!0!==W)return;function e(e){Xe(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){o(window.document,t,e)}t("mouseenter"),t("mouseleave")}(),$e(),R=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(n){const o=n.getBoundingClientRect(),i=e();return{x:parseInt(o.left,t)+parseInt(i.x,t),y:parseInt(o.top,t)+parseInt(i.y,t)}}function i(e){function t(e){const t=n(e);Xe(t.y,t.x,"scrollToOffset")}const o=e.split("#")[1]||e,i=decodeURIComponent(o),r=document.getElementById(i)||document.getElementsByName(i)[0];void 0===r?Xe(0,0,"inPageLink",`#${o}`):t(r)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){function e(e){function t(e){e.preventDefault(),i(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&o(e,"click",t)}document.querySelectorAll(\'a[href^="#"]\').forEach(e)}function l(){o(window,"hashchange",r)}function c(){setTimeout(r,u)}function s(){a(),l(),c()}R.enable&&(1===L?me("In page linking requires a Professional or Business license. Please see https://iframe-resizer.com/pricing for more details."):s());return{findTarget:i}}(),ae(document.documentElement),ae(document.body),Ve("init","Init message from host page",void 0,void 0,e),document.title&&""!==document.title&&Xe(0,0,"title",document.title),te(),B=!1}function he(e,t){void 0!==t&&""!==t&&"null"!==t&&document.body.style.setProperty(e,t)}function ye(){""!==V&&document.querySelectorAll(V).forEach((e=>{e.dataset.iframeSize=!0}))}function ge(e){({add(t){function n(){Ve(e.eventName,e.eventType)}d[t]=n,o(window,t,n,{passive:!0})},remove(e){const t=d[e];delete d[e],i(window,e,t)}})[e.method](e.eventName)}function ve(e){ge({method:e,eventType:"After Print",eventName:"afterprint"}),ge({method:e,eventType:"Before Print",eventName:"beforeprint"}),ge({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}function be(){const e=document.querySelectorAll(`[${n}]`);T=e.length>0,A=T?e:Re(document)()}function we(e,t,n,o){return t!==e&&(e in n||(de(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in s&&me(`<rb>Deprecated ${o}CalculationMethod (${e})</>\\n\\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you remove this option.`)),e}function ze(){I=we(I,f,He,"height")}function Se(){K=we(K,v,Ue,"width")}function $e(){!0===z&&(ve("add"),E=function(){function e(e){e.forEach(Te),ye(),be()}function t(){const t=new window.MutationObserver(e),n=document.querySelector("body"),o={attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return t.observe(n,o),t}const n=t();return{disconnect(){n.disconnect()}}}(),U=new ResizeObserver(Ee),Ce(window.document))}let je;function Ee(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;je=()=>Ve("resizeObserver",`Resize Observed: ${le(t)}`),setTimeout((()=>{je&&je(),je=void 0}),0)}const Pe=e=>{const t=getComputedStyle(e);return""!==t?.position&&"static"!==t?.position},Oe=()=>[...Re(document)()].filter(Pe),Me=new WeakSet;function Ae(e){e&&(Me.has(e)||(U.observe(e),Me.add(e)))}function Ce(e){[...Oe(),...g.flatMap((t=>e.querySelector(t)))].forEach(Ae)}function Te(e){"childList"===e.type&&Ce(e.target)}let ke=4,Ie=4;function xe(e){const t=(n=e).charAt(0).toUpperCase()+n.slice(1);var n;let o=0,i=A.length,r=document.documentElement,a=T?0:document.documentElement.getBoundingClientRect().bottom,c=performance.now();var s;A.forEach((t=>{T||!m||t.checkVisibility(l)?(o=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),o>a&&(a=o,r=t)):i-=1})),c=performance.now()-c,i>1&&(s=r,re.has(s)||(ae(s),ue(`\\nHeight calculated from: ${le(s)} (${ce(s)})`)));const u=`\\nParsed ${i} element${1===i?"":"s"} in ${c.toPrecision(3)}ms\\n${t} ${T?"tagged ":""}element found at: ${a}px\\nPosition calculated from HTML element: ${le(r)} (${ce(r,100)})`;return c<4||i<99||T||B||ke<c&&ke<Ie&&(ke=1.2*c,me(`<rb>Performance Warning</>\\n\\nCalculating the page size took an excessive amount of time. To improve performance add the <b>data-iframe-size</> attribute to the ${e} most element on the page.\\n${u}`)),Ie=c,a}const Ne=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.documentElementBoundingClientRect()],Re=e=>()=>e.querySelectorAll("* :not(head):not(meta):not(base):not(title):not(script):not(link):not(style):not(map):not(area):not(option):not(optgroup):not(template):not(track):not(wbr):not(nobr)");let Be=!1;function qe({ceilBoundingSize:e,dimension:t,getDimension:n,isHeight:o,scrollSize:i}){if(!Be)return Be=!0,n.taggedElement();const r=o?"bottom":"right";return me(`<rb>Detected content overflowing html element</>\\n \\nThis causes <i>iframe-resizer</> to fall back to checking the position of every element on the page in order to calculate the correct dimensions of the iframe. Inspecting the size, ${r} margin, and position of every visible HTML element will have a performance impact on more complex pages. \\n\\nTo fix this issue, and remove this warning, you can either ensure the content of the page does not overflow the <b><HTML></> element or alternatively you can add the attribute <b>data-iframe-size</> to the elements on the page that you want <i>iframe-resizer</> to use when calculating the dimensions of the iframe. \\n \\nWhen present the ${r} margin of the ${o?"lowest":"right most"} element with a <b>data-iframe-size</> attribute will be used to set the ${t} of the iframe.\\n\\nMore info: https://iframe-resizer.com/performance.\\n\\n(Page size: ${i} > document size: ${e})`),o?I="autoOverflow":K="autoOverflow",n.taggedElement()}const Le={height:0,width:0},We={height:0,width:0};function De(e,t){function n(){return We[i]=r,Le[i]=c,r}const o=e===He,i=o?"height":"width",r=e.documentElementBoundingClientRect(),a=Math.ceil(r),l=Math.floor(r),c=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e);switch(!0){case!e.enabled():return c;case!t&&0===We[i]&&0===Le[i]:if(e.taggedElement(!0)<=a)return n();break;case X&&r===We[i]&&c===Le[i]:return Math.max(r,c);case 0===r:return c;case!t&&r!==We[i]&&c<=Le[i]:return n();case!o:return t?e.taggedElement():qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c});case!t&&r<We[i]:case c===l||c===a:case r>c:return n();case!t:return qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c})}return Math.max(e.taggedElement(),n())}const He={enabled:()=>O,getOffset:()=>b,type:"height",auto:()=>De(He,!1),autoOverflow:()=>De(He,!0),bodyOffset:()=>{const{body:e}=document,n=getComputedStyle(e);return e.offsetHeight+parseInt(n.marginTop,t)+parseInt(n.marginBottom,t)},bodyScroll:()=>document.body.scrollHeight,offset:()=>He.bodyOffset(),custom:()=>c.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().bottom,max:()=>Math.max(...Ne(He)),min:()=>Math.min(...Ne(He)),grow:()=>He.max(),lowestElement:()=>xe("bottom"),taggedElement:()=>xe("bottom")},Ue={enabled:()=>M,getOffset:()=>w,type:"width",auto:()=>De(Ue,!1),autoOverflow:()=>De(Ue,!0),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>c.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().right,max:()=>Math.max(...Ne(Ue)),min:()=>Math.min(...Ne(Ue)),rightMostElement:()=>xe("right"),scroll:()=>Math.max(Ue.bodyScroll(),Ue.documentElementScroll()),taggedElement:()=>xe("right")};function Fe(e,t,n,o,i){let r,a;!function(){const e=(e,t)=>!(Math.abs(e-t)<=Q);return r=void 0===n?He[I]():n,a=void 0===o?Ue[K]():o,O&&e(k,r)||M&&e(G,a)}()&&"init"!==e?!(e in{init:1,size:1})&&(O&&I in y||M&&K in y)&&Qe():(Je(),k=r,G=a,Xe(k,G,e,i))}function Ve(e,t,n,o,i){document.hidden||Fe(e,0,n,o,i)}function Je(){X||(X=!0,requestAnimationFrame((()=>{X=!1})))}function Ze(e){k=He[I](),G=Ue[K](),Xe(k,G,e)}function Qe(e){const t=I;I=f,Je(),Ze("reset"),I=t}function Xe(e,t,n,o,i){L<-1||(void 0!==i||(i=Z),function(){const r=`${D}:${`${e+(b||0)}:${t+(w||0)}`}:${n}${void 0===o?"":`:${o}`}`;F?window.parent.iframeParentListener(p+r):J.postMessage(p+r,i)}())}function Ye(e){const t={init:function(){N=e.data,J=e.source,pe(),C=!1,setTimeout((()=>{x=!1}),u)},reset(){x||Ze("resetPage")},resize(){Ve("resizeParent")},moveToAnchor(){R.findTarget(o())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=o();ne?ne(JSON.parse(e)):Xe(0,0,"pageInfoStop")},parentInfo(){const e=o();oe?oe(Object.freeze(JSON.parse(e))):Xe(0,0,"parentInfoStop")},message(){const e=o();ee(JSON.parse(e))}},n=()=>e.data.split("]")[1].split(":")[0],o=()=>e.data.slice(e.data.indexOf(":")+1),i=()=>"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype,r=()=>e.data.split(":")[2]in{true:1,false:1};p===`${e.data}`.slice(0,h)&&(!1!==C?r()&&t.init():function(){const o=n();o in t?t[o]():i()||r()||de(`Unexpected message (${e.data})`)}())}function Ge(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"undefined"!=typeof window&&(window.iframeChildListener=e=>Ye({data:e,sameDomain:!0}),o(window,"message",Ye),o(window,"readystatechange",Ge),Ge())}));\n', J = "iframe-resizer/child 5.1.5", be = $, v = `<script>${$}<\/script>`, Y = (e) => !e || typeof e != "object" ? "" : String(e.type || e.answer_type || ""), k = (e) => {
63
+ if (!e || typeof e != "object")
64
+ return {};
65
+ const t = e.values, n = (r) => {
66
+ const s = t && typeof t == "object" ? t[r] : void 0;
67
+ if (typeof s == "string" && s)
68
+ return s;
69
+ const a = e[r];
70
+ return typeof a == "string" && a ? a : void 0;
71
+ }, o = n("url"), i = n("srcdoc");
72
+ return {
73
+ ...o ? { url: o } : {},
74
+ ...i ? { srcdoc: i } : {}
75
+ };
76
+ }, O = (e) => e && (e.includes("</head>") ? e.replace("</head>", `${v}</head>`) : e.includes("<body") ? e.replace("<body", `${v}<body`) : v + e), Z = (e) => !e || typeof e != "object" || Array.isArray(e) || !e.url && !e.srcdoc ? !1 : !e.srcdoc || e.srcdoc.includes(J), Q = (e, t) => {
77
+ if (e.mode !== "result" || Y(e.value) !== "url")
78
+ return !1;
79
+ const n = k(e.value);
80
+ return !n.url && !n.srcdoc || (n.srcdoc && (n.srcdoc = O(n.srcdoc)), t.push({ answer_type: "url", values: n })), !0;
81
+ }, F = (e) => {
82
+ if (Z(e.values))
83
+ return e;
84
+ const t = k(e);
85
+ return !t.url && !t.srcdoc || (t.srcdoc && (t.srcdoc = O(t.srcdoc)), e.values = t), e;
86
+ }, ee = {
87
+ id: "iframe_page",
88
+ answerType: "url",
89
+ applyChunk: Q,
90
+ normalizeReport: F
91
+ }, z = "recordset", te = ["cols", "values", "chart", "title", "max_cols", "parent_link_col", "agent_key"], ne = (e) => !e || typeof e != "object" ? "" : String(e.type || e.answer_type || ""), h = (e) => !!e && typeof e == "object" && !Array.isArray(e) && (Array.isArray(e.cols) || Array.isArray(e.values)), oe = (e) => {
92
+ if (!e || typeof e != "object" || Array.isArray(e))
93
+ return;
94
+ const t = e.values;
95
+ if (h(t))
96
+ return t;
97
+ if (h(e))
98
+ return e;
99
+ }, re = (e, t) => {
100
+ if (e.mode !== "result" || ne(e.value) !== z)
101
+ return !1;
102
+ const n = oe(e.value);
103
+ return n && t.push({ answer_type: z, values: n }), !0;
104
+ }, ie = (e) => {
105
+ if (h(e.values))
106
+ return e;
107
+ const t = e;
108
+ if (!h(t))
109
+ return e;
110
+ const n = {};
111
+ for (const o of te)
112
+ n[o] = t[o];
113
+ return e.values = n, e;
114
+ }, se = {
115
+ id: "recordset",
116
+ answerType: z,
117
+ applyChunk: re,
118
+ normalizeReport: ie
119
+ }, g = "output_file", ae = (e) => !e || typeof e != "object" ? "" : String(e.type || e.answer_type || ""), y = (e, t) => {
120
+ if (!e || typeof e != "object")
121
+ return;
122
+ const n = e[t];
123
+ return typeof n == "string" && n ? n : void 0;
124
+ }, M = (e) => {
125
+ if (!e || typeof e != "object")
126
+ return {};
127
+ const t = e.values && typeof e.values == "object" ? e.values : void 0, n = y(t, "file_id") ?? y(e, "file_id"), o = y(t, "file_name") ?? y(e, "file_name");
128
+ return {
129
+ ...n ? { file_id: n } : {},
130
+ ...o ? { file_name: o } : {}
131
+ };
132
+ }, ce = (e, t) => {
133
+ if (e.mode !== "result" || ae(e.value) !== g)
134
+ return !1;
135
+ const n = M(e.value);
136
+ return !n.file_id && !n.file_name || t.push({ answer_type: g, values: n }), !0;
137
+ }, le = (e) => {
138
+ const t = M(e);
139
+ if (!t.file_id && !t.file_name)
140
+ return e;
141
+ const n = e.values && typeof e.values == "object" && !Array.isArray(e.values) ? e.values : {};
142
+ return (!t.file_id || n.file_id) && (!t.file_name || n.file_name) || (e.values = { ...n, ...t }), e;
143
+ }, ue = {
144
+ id: g,
145
+ answerType: g,
146
+ applyChunk: ce,
147
+ normalizeReport: le
148
+ }, w = [
149
+ G,
150
+ K,
151
+ ee,
152
+ se,
153
+ ue
154
+ ], de = (e) => {
155
+ const t = (e == null ? void 0 : e.parsers) ?? [];
156
+ return t.length ? [...w, ...t] : w;
157
+ }, ve = (e, t, n) => {
158
+ var s;
159
+ const o = (s = e.answer) == null ? void 0 : s.reports;
160
+ if (!o)
161
+ return [];
162
+ const i = new Set(
163
+ ((n == null ? void 0 : n.parsers) ?? []).filter((a) => a.applyChunk && a.answerType).map((a) => a.answerType)
164
+ ), r = [];
165
+ for (const a of de(n))
166
+ a.applyChunk && (w.includes(a) && a.answerType && i.has(a.answerType) || a.applyChunk(t, o, e, n) && r.push(a.id));
167
+ return r;
168
+ }, fe = (e, t) => {
169
+ var r;
170
+ const n = e.answer_type;
171
+ if (!n)
172
+ return;
173
+ const i = ((t == null ? void 0 : t.parsers) ?? []).find((s) => s.answerType === n && !!s.normalizeReport) ?? w.find((s) => s.answerType === n && !!s.normalizeReport);
174
+ (r = i == null ? void 0 : i.normalizeReport) == null || r.call(i, e, t);
175
+ }, x = (e, t = "", n = "", o) => {
176
+ var s;
177
+ const i = (e == null ? void 0 : e.values) ?? e;
178
+ if ((s = i == null ? void 0 : i.answer) != null && s.reports) {
179
+ const a = i;
180
+ for (const c of a.answer.reports)
181
+ fe(c, o);
182
+ return a;
183
+ }
184
+ const r = D(t, n);
185
+ return typeof i == "string" && R({ mode: "knowledge_stream", value: i }, r.answer.reports, r, o), r;
186
+ }, ze = {
187
+ User: "user",
188
+ Assistant: "assistant"
189
+ };
190
+ let me = 0;
191
+ const P = (e = "msg") => `${e}-${++me}`, pe = (e) => {
192
+ const t = e.trim();
193
+ if (!t || t === "[DONE]")
194
+ return null;
195
+ const n = t.replace(/^data:\s*/, "");
196
+ try {
197
+ return JSON.parse(n);
198
+ } catch {
199
+ try {
200
+ return JSON.parse(decodeURIComponent(n));
201
+ } catch {
202
+ return null;
203
+ }
204
+ }
205
+ }, ye = () => {
206
+ let e = "";
207
+ return {
208
+ push(t) {
209
+ const n = (e + t).split(`
210
+ `);
211
+ return e = n.pop() || "", n;
212
+ },
213
+ flush() {
214
+ const t = e;
215
+ return e = "", t ? [t] : [];
216
+ }
217
+ };
218
+ }, _e = async (e, t) => {
219
+ const n = e.getReader(), o = new TextDecoder(), i = ye(), r = (s) => {
220
+ const a = pe(s);
221
+ a && t(a);
222
+ };
223
+ try {
224
+ for (; ; ) {
225
+ const { done: s, value: a } = await n.read();
226
+ if (s)
227
+ break;
228
+ i.push(o.decode(a, { stream: !0 })).forEach(r);
229
+ }
230
+ i.flush().forEach(r);
231
+ } catch (s) {
232
+ throw await n.cancel().catch(() => {
233
+ }), s;
234
+ } finally {
235
+ n.releaseLock();
236
+ }
237
+ }, b = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "gif", "webp", "svg", "bmp"]), N = (e) => !e || isNaN(e) ? "" : e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`, Se = (e) => {
238
+ var o;
239
+ if (e.type && e.type !== "file")
240
+ return !1;
241
+ const t = e.attachContent || {};
242
+ if (t.groupType === "image")
243
+ return !0;
244
+ const n = (t.suffix || ((o = e.name) != null && o.includes(".") ? e.name.split(".").pop() : "") || "").toLowerCase();
245
+ return !!(b.has(n) || t.raw && typeof t.raw.type == "string" && t.raw.type.startsWith("image/"));
246
+ }, he = (e, t, n) => e.startsWith("http://") || e.startsWith("https://") || e.startsWith("/") ? e : `${(t || "").replace(/\/$/, "")}${n}?file_id=${e}`, ge = (e, t = "", n) => e ? n ? n(e) : he(e, t, "/file/download_file") : "", Ce = (e, t = "", n) => {
247
+ const o = e.attachContent || {};
248
+ return o.url ? o.url : typeof o.fileContent == "string" && o.fileContent.startsWith("data:image/") ? o.fileContent : o.fileId ? ge(o.fileId, t, n) : "";
249
+ }, T = (e) => {
250
+ var a;
251
+ const t = (e == null ? void 0 : e.name) || "", n = t.includes(".") && ((a = t.split(".").pop()) == null ? void 0 : a.toLowerCase()) || "", o = b.has(n) || (e == null ? void 0 : e.type) && typeof e.type == "string" && e.type.startsWith("image/");
252
+ let i;
253
+ if (o && typeof window < "u" && typeof URL < "u" && e instanceof Blob)
254
+ try {
255
+ i = URL.createObjectURL(e);
256
+ } catch {
257
+ i = void 0;
258
+ }
259
+ const r = N(e == null ? void 0 : e.size), s = [n.toUpperCase(), r].filter(Boolean).join(" · ");
260
+ return {
261
+ type: "file",
262
+ name: t,
263
+ description: s,
264
+ attachContent: {
265
+ file_name: t,
266
+ size: e == null ? void 0 : e.size,
267
+ suffix: n,
268
+ raw: e,
269
+ url: i,
270
+ groupType: o ? "image" : "file"
271
+ }
272
+ };
273
+ }, L = (e) => {
274
+ var r;
275
+ const t = (e == null ? void 0 : e.file_name) ?? (e == null ? void 0 : e.name) ?? (e == null ? void 0 : e.title) ?? "", n = t.includes(".") && ((r = t.split(".").pop()) == null ? void 0 : r.toLowerCase()) || "", o = b.has(n) || (e == null ? void 0 : e.groupType) === "image", i = n ? n.toUpperCase() : "";
276
+ return {
277
+ type: "file",
278
+ name: t,
279
+ description: i,
280
+ attachContent: {
281
+ file_name: (e == null ? void 0 : e.file_name) ?? t,
282
+ fileId: (e == null ? void 0 : e.file_id) ?? (e == null ? void 0 : e.id),
283
+ fileContent: e == null ? void 0 : e.file_content,
284
+ suffix: n,
285
+ groupType: o ? "image" : "file"
286
+ }
287
+ };
288
+ }, we = (e) => {
289
+ var o, i, r, s;
290
+ const t = (e == null ? void 0 : e.values) ?? e, n = ((o = t == null ? void 0 : t.attach) == null ? void 0 : o.files) ?? ((r = (i = t == null ? void 0 : t.answer) == null ? void 0 : i.attach) == null ? void 0 : r.files) ?? (t == null ? void 0 : t.attach_files) ?? ((s = t == null ? void 0 : t.answer) == null ? void 0 : s.attach_files) ?? [];
291
+ return !Array.isArray(n) || n.length === 0 ? [] : n.map((a) => L(a));
292
+ }, Ee = (e) => {
293
+ var o, i;
294
+ if (!e)
295
+ return { type: "file", name: "", description: "", attachContent: {} };
296
+ if (typeof Blob < "u" && e instanceof Blob)
297
+ return T(e);
298
+ if (typeof e == "object" && e.attachContent) {
299
+ const r = e.type || "file", s = e.name || e.attachContent.file_name || e.attachContent.name || "";
300
+ let a = e.description || "";
301
+ const c = { ...e.attachContent };
302
+ if (r === "file" && (!c.suffix && s.includes(".") && (c.suffix = ((o = s.split(".").pop()) == null ? void 0 : o.toLowerCase()) || ""), (c.groupType === "image" || c.suffix && b.has(c.suffix.toLowerCase()) || c.raw && typeof c.raw.type == "string" && c.raw.type.startsWith("image/")) && (c.groupType = "image"), !a)) {
303
+ const l = typeof c.size == "number" ? N(c.size) : c.size || "";
304
+ a = [c.suffix ? c.suffix.toUpperCase() : "", l].filter(Boolean).join(" · ");
305
+ }
306
+ return {
307
+ ...e,
308
+ type: r,
309
+ name: s,
310
+ description: a,
311
+ attachContent: c
312
+ };
313
+ }
314
+ if (e.file_id || e.fileId)
315
+ return L(e);
316
+ if (e.raw && typeof Blob < "u" && e.raw instanceof Blob) {
317
+ const r = T(e.raw);
318
+ return {
319
+ ...r,
320
+ ...e,
321
+ attachContent: {
322
+ ...r.attachContent,
323
+ ...e.attachContent
324
+ }
325
+ };
326
+ }
327
+ const t = e.name || e.title || "", n = t.includes(".") && ((i = t.split(".").pop()) == null ? void 0 : i.toLowerCase()) || "";
328
+ return {
329
+ type: e.type || "file",
330
+ name: t,
331
+ description: e.description || (n ? n.toUpperCase() : ""),
332
+ attachContent: {
333
+ file_name: t,
334
+ suffix: n,
335
+ ...e
336
+ }
337
+ };
338
+ }, H = (e) => we(e), Ae = async (e) => [...(await e.getHistoryGroups()).groups ?? []].sort((o, i) => String(i.create_time ?? "").localeCompare(String(o.create_time ?? ""))), Te = async (e, t) => {
339
+ const n = await e.createHistoryGroup(t), o = (n == null ? void 0 : n.group_id) ?? (n == null ? void 0 : n.history_group_id) ?? "";
340
+ if (!o)
341
+ throw new Error("创建对话分组失败");
342
+ return o;
343
+ }, Re = (e, t) => e.deleteHistoryGroup(t), je = (e, t, n) => e.setHistoryGroupTitle(t, n), B = 5, U = async (e, t, n) => {
344
+ const o = new Array(e.length);
345
+ let i = 0;
346
+ const r = Array.from({ length: Math.min(t, e.length) }, async () => {
347
+ for (; i < e.length; ) {
348
+ const s = i++;
349
+ o[s] = await n(e[s], s);
350
+ }
351
+ });
352
+ return await Promise.all(r), o;
353
+ }, Ie = async (e, t, n = 10, o = 0, i) => {
354
+ if (!t)
355
+ return [];
356
+ const s = [...await e.getHistoryDetail(t, o, n)].sort((u, l) => String(u.create_time || "").localeCompare(String(l.create_time || ""))), a = await U(s, B, async (u) => {
357
+ try {
358
+ return await e.getHistoryAnswer(u.history_id || "");
359
+ } catch {
360
+ return null;
361
+ }
362
+ }), c = [];
363
+ return s.forEach((u, l) => {
364
+ const p = u.history_id || P("h"), d = a[l], f = d != null ? H(d) : [];
365
+ if (c.push({
366
+ id: p,
367
+ historyId: u.history_id,
368
+ role: "user",
369
+ content: u.question ?? "",
370
+ attachments: f.length > 0 ? f : void 0
371
+ }), d != null) {
372
+ const m = x(d, p, u.question ?? "", i);
373
+ c.push({
374
+ id: `${p}-answer`,
375
+ historyId: u.history_id,
376
+ role: "assistant",
377
+ answer: m,
378
+ error: !1,
379
+ stopped: !1,
380
+ thinking: { steps: I(m), expanded: !1 }
381
+ });
382
+ }
383
+ }), c;
384
+ }, $e = async (e, t, n = 10, o, i = 0, r) => {
385
+ if (!t)
386
+ return o == null || o({ type: "users", users: [] }), [];
387
+ const a = [...await e.getHistoryDetail(t, i, n)].sort((d, f) => String(d.create_time || "").localeCompare(String(f.create_time || ""))), c = a.map((d) => d.history_id || P("h")), u = a.map((d, f) => ({
388
+ id: c[f],
389
+ historyId: d.history_id,
390
+ role: "user",
391
+ content: d.question ?? ""
392
+ }));
393
+ o == null || o({ type: "users", users: u });
394
+ const l = new Array(a.length).fill(null);
395
+ await U(a, B, async (d, f) => {
396
+ let m = null;
397
+ try {
398
+ m = await e.getHistoryAnswer(d.history_id || "");
399
+ } catch {
400
+ m = null;
401
+ }
402
+ if (m == null)
403
+ return;
404
+ const _ = H(m);
405
+ _.length > 0 && (u[f].attachments = _);
406
+ const S = x(m, c[f], d.question ?? "", r), C = {
407
+ id: `${c[f]}-answer`,
408
+ historyId: d.history_id,
409
+ role: "assistant",
410
+ answer: S,
411
+ error: !1,
412
+ stopped: !1,
413
+ thinking: { steps: I(S), expanded: !1 }
414
+ };
415
+ l[f] = C, o == null || o({
416
+ type: "assistant",
417
+ index: f,
418
+ user: u[f],
419
+ assistant: C
420
+ });
421
+ });
422
+ const p = [];
423
+ return a.forEach((d, f) => {
424
+ p.push(u[f]);
425
+ const m = l[f];
426
+ m && p.push(m);
427
+ }), p;
428
+ };
429
+ export {
430
+ be as IFRAME_RESIZER_CHILD_SCRIPT,
431
+ b as IMAGE_EXTENSIONS,
432
+ g as OUTPUT_FILE_ANSWER_TYPE,
433
+ z as RECORDSET_ANSWER_TYPE,
434
+ ze as RoleEnum,
435
+ ve as applyAnswerChunk,
436
+ X as applyDeepThinkingChunk,
437
+ Q as applyIframePageChunk,
438
+ R as applyKnowledgeStreamChunk,
439
+ ce as applyOutputFileChunk,
440
+ re as applyRecordsetChunk,
441
+ V as collectDeepThinkingSteps,
442
+ I as collectThinkingSteps,
443
+ _e as consumeStream,
444
+ D as createEmptyAnswerValues,
445
+ Te as createHistoryGroup,
446
+ ye as createLineSplitter,
447
+ G as deepThinkingParser,
448
+ Re as deleteHistoryGroup,
449
+ H as extractAttachmentsFromHistory,
450
+ we as extractHistoryAttachments,
451
+ N as formatFileSize,
452
+ Ae as getHistoryGroups,
453
+ ee as iframePageParser,
454
+ O as injectIframeResizerScript,
455
+ Se as isImageAttachment,
456
+ K as knowledgeStreamParser,
457
+ Ie as loadGroupMessages,
458
+ $e as loadGroupMessagesByStep,
459
+ P as nextLocalMessageId,
460
+ x as normalizeAnswer,
461
+ fe as normalizeAnswerReport,
462
+ Ee as normalizeAttachment,
463
+ F as normalizeIframePageReport,
464
+ q as normalizeKnowledgeStreamReport,
465
+ le as normalizeOutputFileReport,
466
+ ie as normalizeRecordsetReport,
467
+ ue as outputFileParser,
468
+ L as parseHistoryAttachment,
469
+ T as parseRealtimeAttachment,
470
+ pe as parseSseLine,
471
+ M as readOutputFilePayload,
472
+ oe as readRecordsetPayload,
473
+ se as recordsetParser,
474
+ ge as resolveAttachDownloadUrl,
475
+ Ce as resolveAttachPreviewUrl,
476
+ he as resolveRemoteFileUrl,
477
+ je as setHistoryGroupTitle
478
+ };
479
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,60 @@
1
+ import { AiAnswerValues } from './answer';
2
+ import { ChatAttachment } from './attach';
3
+
4
+ export type { ChatAttachment, FileAttachContent, AttachmentType } from './attach';
5
+ /**
6
+ * 消息角色
7
+ */
8
+ export declare const RoleEnum: {
9
+ readonly User: "user";
10
+ readonly Assistant: "assistant";
11
+ };
12
+ export type Role = (typeof RoleEnum)[keyof typeof RoleEnum];
13
+ /**
14
+ * 用户消息
15
+ */
16
+ export interface UserMessage {
17
+ /** 消息 id(本地生成或 history_id) */
18
+ id: string;
19
+ /** 关联的服务端历史明细 id(历史加载自 query_history_detail;实时新消息尚无,留空) */
20
+ historyId?: string;
21
+ /** 消息角色:user */
22
+ role: typeof RoleEnum.User;
23
+ /** 用户输入的原文 */
24
+ content: string;
25
+ /** 用户提问携带的附件列表 */
26
+ attachments?: ChatAttachment[];
27
+ }
28
+ /**
29
+ * 助手消息
30
+ */
31
+ export interface AssistantMessage {
32
+ /** 消息 id(由关联明细 id 派生或本地生成) */
33
+ id: string;
34
+ /** 关联的服务端历史明细 id(历史加载自 query_history_detail;实时新消息尚无,留空) */
35
+ historyId?: string;
36
+ /** 消息角色:assistant */
37
+ role: typeof RoleEnum.Assistant;
38
+ /** 回答内容(流式解析过程中逐步累积) */
39
+ answer: AiAnswerValues;
40
+ /** 是否回答出错 */
41
+ error: boolean;
42
+ /** 是否已被用户停止 */
43
+ stopped: boolean;
44
+ /** 深度思考(已算好的展示步骤 + 展开态) */
45
+ thinking: {
46
+ /** 深度思考展示步骤(组装消息时已解析,UI 不再拼接) */
47
+ steps: string[];
48
+ /** 深度思考步骤是否展开 */
49
+ expanded: boolean;
50
+ };
51
+ }
52
+ /**
53
+ * 消息(用户 / 助手 的联合类型)
54
+ */
55
+ export type Message = UserMessage | AssistantMessage;
56
+ /**
57
+ * 生成本地消息 id(服务端 history_id 缺失或本地即时构造消息时使用)。
58
+ * 模块级自增保证同一次会话内绝不重复。
59
+ */
60
+ export declare const nextLocalMessageId: (prefix?: string) => string;
@@ -0,0 +1,81 @@
1
+ import { Component } from 'vue';
2
+ import { AiAnswerReport, AiAnswerValues } from './answer';
3
+ import { StreamChunk } from './sse';
4
+ import { KnowledgeRenderOptions } from './answerCom/knowledgeStream/types';
5
+
6
+ /**
7
+ * 一个回答类型的解析器:实时流 chunk 应用与历史 report 归一化的双链路收敛单元。
8
+ * `T` 为该类型 report 的 values 形态(如知识流为 `KnowledgeStreamValue[]`),供 normalizeReport 强类型标注。
9
+ */
10
+ export interface AnswerParser<T = any> {
11
+ /** 唯一标识(`applyAnswerChunk` 消费后返回该 id,调用方据此做类型联动,如重算 thinking.steps) */
12
+ id: string;
13
+ /**
14
+ * 历史 report 分发键:`report.answer_type` 等于该值时,归一化交给本 parser 的
15
+ * `normalizeReport`(answerType 冲突时自定义优先于内置)。缺省不参与历史分发。
16
+ * 实时链路上,自定义 parser 声明与内置相同的 `answerType` 且实现 `applyChunk` 时,
17
+ * 对应内置 parser 会被**自动替换**(跳过),无需额外开关。
18
+ */
19
+ answerType?: string;
20
+ /**
21
+ * 实时流 chunk 应用:内部按 `chunk.mode` 自行判断是否消费。
22
+ * 签名(chunk 在前,reports 已预取、answerValues 兜底可用):
23
+ * `reports` 是 registry 从 `answerValues.answer.reports` 取出的**同一引用**,push 即累积,
24
+ * 无需再从 answerValues 内部取;`answerValues` 供需要操作 reports 之外的整体结构时使用。
25
+ * @param chunk 流式数据块
26
+ * @param reports 回答 reports 数组(registry 预取的 `answerValues.answer.reports` 同一引用,push 即累积)
27
+ * @param answerValues 回答整体结构(仅需操作 answer 层其它字段时使用)
28
+ * @param options 解析配置(含 beforeKnowledgeRender 与自定义 parsers)
29
+ * @returns 是否消费了该 chunk(true 计入消费者 id 列表;广播语义下不再阻止后续 parser)
30
+ */
31
+ applyChunk?: (chunk: StreamChunk, reports: AiAnswerReport<any>[], answerValues: AiAnswerValues, options?: AnswerParseOptions) => boolean;
32
+ /**
33
+ * 历史 report 归一化:把服务端历史形态就地标准化成渲染层结构(保证与实时累积产出一致)。
34
+ * @param report 历史 reports 中 `answer_type` 命中本 parser 的一个元素(就地修改)
35
+ * @param options 解析配置(含 beforeKnowledgeRender 与自定义 parsers)
36
+ */
37
+ normalizeReport?: (report: AiAnswerReport<T>, options?: AnswerParseOptions) => void;
38
+ /**
39
+ * 本类型回答的渲染组件:以 `answerType` 为键注册进 contentMap 供 AiAnswerBubble 分发。
40
+ * 可选——内置 parser 不在本包填值(本包纯逻辑、不依赖 UI,装配在 wi-chat/renderers 的
41
+ * `createAnswerContentMap` 侧完成);页面级 parser 可直接携带本地组件,使「解析 + 渲染」
42
+ * 一站式声明。组件可为普通组件或 `defineAsyncComponent` 懒加载组件。
43
+ */
44
+ component?: Component;
45
+ }
46
+ /**
47
+ * 答案解析链路的可选配置:在知识流文本处理配置之上,追加自定义解析器的实例注入。
48
+ */
49
+ export interface AnswerParseOptions extends KnowledgeRenderOptions {
50
+ /**
51
+ * 额外的自定义解析器(内置类型始终生效、无需在此重复注入)。
52
+ * 实时流为广播语义:内置在前、自定义在后,所有 parser 都收到 chunk;自定义若声明了
53
+ * 与内置相同的 `answerType` 且实现 `applyChunk`,对应内置自动被替换(跳过),避免重复产出。
54
+ * 历史归一化按 answerType 查表,自定义优先于内置。
55
+ */
56
+ parsers?: AnswerParser[];
57
+ }
58
+ /**
59
+ * 实时流 chunk 分发:按「内置(deepThinking → knowledgeStream → iframePage → recordset → outputFile)+ options.parsers」
60
+ * 顺序把 chunk **广播**给每个 parser——`applyChunk` 返回 true 表示已消费,但不再中断后续遍历,
61
+ * 返回全部消费者 id。
62
+ * 自定义 parser 声明了与内置相同的 `answerType` 且实现 `applyChunk` 时,同类型内置会被**自动替换**
63
+ * (在本轮及后续轮次整体跳过),从而避免内置与自定义同时消费同一 chunk 而重复产出;自定义之间
64
+ * 不互相替换(多个同 answerType 自定义会各自消费,需调用方自行保证唯一)。
65
+ * reports 由本入口统一从 `answerValues.answer.reports` 取出并以引用传给各 parser(push 即累积,
66
+ * parser 无需再自行判空提取);answer 缺 reports 的畸形结构直接返回 []、不分发,
67
+ * 与原先各 parser 内部判空拦截的语义一致。
68
+ * @param answerValues 回答整体结构(流式过程中逐步累积的目标)
69
+ * @param chunk 流式数据块
70
+ * @param options 解析配置(自定义 parsers 注入;同名 answerType 自动替换内置)
71
+ * @returns 消费者 id 列表(按遍历顺序;未被任何 parser 消费为 `[]`)
72
+ */
73
+ export declare const applyAnswerChunk: (answerValues: AiAnswerValues, chunk: StreamChunk, options?: AnswerParseOptions) => string[];
74
+ /**
75
+ * 历史 report 归一化分发:`report.answer_type` 命中(自定义优先、其次内置)即调对应
76
+ * `normalizeReport` 就地标准化,一处只调一个;未命中(或命中的 parser 未实现
77
+ * `normalizeReport`)时不动该 report。
78
+ * @param report 历史 reports 中的一个元素(就地标准化)
79
+ * @param options 解析配置(自定义 parsers 注入;answerType 冲突时自定义优先于内置)
80
+ */
81
+ export declare const normalizeAnswerReport: (report: AiAnswerReport<any>, options?: AnswerParseOptions) => void;