plugin-ai-chat-file-preview 1.0.11 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,44 +1,44 @@
1
- # plugin-ai-chat-file-preview
2
-
3
- Enhances the NocoBase AI Employee chat interface by providing a seamless, in-browser popup preview for uploaded file attachments.
4
-
5
- ## Features
6
-
7
- - **Instant File Preview**: Click on any document, image, or spreadsheet attachment in the AI chat window to open a rich modal preview instantly, without navigating away or opening a new tab.
8
- - **Smart Client-side Caching**: Leverages IndexedDB to cache files locally as soon as they are fetched or uploaded, dramatically improving load times and reducing server bandwidth for subsequent previews.
9
- - **Multi-format Support**:
10
- - **PDF**: Native browser iframe rendering
11
- - **Images**: PNG, JPG, GIF, WebP, SVG, BMP
12
- - **Text**: TXT, CSV, HTML, JSON, XML, YAML, MD
13
- - **Documents**: Word (.docx) via `docx-preview`
14
- - **Spreadsheets**: Excel (.xlsx, .xls) via `xlsx`
15
- - **Zero Configuration**: 100% plug-and-play. Hooks directly into the existing NocoBase AI chat system using non-intrusive DOM event interception and global React Providers.
16
- - **Graceful Fallback**: Automatically provides a secure download link containing the proper Bearer Token for un-previewable formats.
17
-
18
- ## Installation
19
-
20
- You can install this plugin in your NocoBase project via the Plugin Manager:
21
-
22
- ```bash
23
- yarn pm add plugin-ai-chat-file-preview
24
- yarn pm enable plugin-ai-chat-file-preview
25
- ```
26
-
27
- *(If utilizing the `.tgz` package directly offline, place it in the application or upload it via UI)*
28
-
29
- ## Technical Details
30
-
31
- - **No Core Modifications**: This plugin relies on catching global DOM click events targeted at `.ant-attachments-file-card` components rendered by `@ant-design/x`, avoiding any necessity to modify the core `@nocobase/plugin-ai`.
32
- - **Session Continuity**: Hooks into the Axios instance to track NocoBase's `sessionId`, ensuring that files are grouped naturally and their Blob caches are completely cleared when a conversation is destroyed.
33
-
34
- ## Usage
35
-
36
- Simply enable the plugin. Once activated:
37
- 1. Open the **AI Chat** panel on any page.
38
- 2. Drag and drop, or select a file to upload.
39
- 3. Once the file appears as a chip in the chat, click it!
40
- 4. The file will pop up in a gorgeous, centered overlay window.
41
-
42
- ## License
43
-
44
- Apache-2.0
1
+ # plugin-ai-chat-file-preview
2
+
3
+ Enhances the NocoBase AI Employee chat interface by providing a seamless, in-browser popup preview for uploaded file attachments.
4
+
5
+ ## Features
6
+
7
+ - **Instant File Preview**: Click on any document, image, or spreadsheet attachment in the AI chat window to open a rich modal preview instantly, without navigating away or opening a new tab.
8
+ - **Smart Client-side Caching**: Leverages IndexedDB to cache files locally as soon as they are fetched or uploaded, dramatically improving load times and reducing server bandwidth for subsequent previews.
9
+ - **Multi-format Support**:
10
+ - **PDF**: Native browser iframe rendering
11
+ - **Images**: PNG, JPG, GIF, WebP, SVG, BMP
12
+ - **Text**: TXT, CSV, HTML, JSON, XML, YAML, MD
13
+ - **Documents**: Word (.docx) via `docx-preview`
14
+ - **Spreadsheets**: Excel (.xlsx, .xls) via `xlsx`
15
+ - **Zero Configuration**: 100% plug-and-play. Hooks directly into the existing NocoBase AI chat system using non-intrusive DOM event interception and global React Providers.
16
+ - **Graceful Fallback**: Automatically provides a secure download link containing the proper Bearer Token for un-previewable formats.
17
+
18
+ ## Installation
19
+
20
+ You can install this plugin in your NocoBase project via the Plugin Manager:
21
+
22
+ ```bash
23
+ yarn pm add plugin-ai-chat-file-preview
24
+ yarn pm enable plugin-ai-chat-file-preview
25
+ ```
26
+
27
+ *(If utilizing the `.tgz` package directly offline, place it in the application or upload it via UI)*
28
+
29
+ ## Technical Details
30
+
31
+ - **No Core Modifications**: This plugin relies on catching global DOM click events targeted at `.ant-attachments-file-card` components rendered by `@ant-design/x`, avoiding any necessity to modify the core `@nocobase/plugin-ai`.
32
+ - **Session Continuity**: Hooks into the Axios instance to track NocoBase's `sessionId`, ensuring that files are grouped naturally and their Blob caches are completely cleared when a conversation is destroyed.
33
+
34
+ ## Usage
35
+
36
+ Simply enable the plugin. Once activated:
37
+ 1. Open the **AI Chat** panel on any page.
38
+ 2. Drag and drop, or select a file to upload.
39
+ 3. Once the file appears as a chip in the chat, click it!
40
+ 4. The file will pop up in a gorgeous, centered overlay window.
41
+
42
+ ## License
43
+
44
+ Apache-2.0
package/client.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './dist/client';
2
- export { default } from './dist/client';
1
+ export * from './dist/client';
2
+ export { default } from './dist/client';
package/client.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./dist/client');
1
+ module.exports = require('./dist/client');
@@ -0,0 +1,44 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import React from 'react';
10
+ export interface PreviewFile {
11
+ id?: string | number;
12
+ uid?: string;
13
+ url?: string;
14
+ filename?: string;
15
+ name?: string;
16
+ title?: string;
17
+ extname?: string;
18
+ mimetype?: string;
19
+ size?: number;
20
+ path?: string;
21
+ [key: string]: any;
22
+ }
23
+ export declare const AppRamCache: Map<string, File | Blob>;
24
+ /**
25
+ * Top-level provider that wraps the app.
26
+ * Wrapped in try/catch ErrorBoundary so that if plugin-ai isn't loaded,
27
+ * the app still works normally without preview functionality.
28
+ */
29
+ export declare class ChatFilePreviewErrorBoundary extends React.Component<{
30
+ children: React.ReactNode;
31
+ }, {
32
+ hasError: boolean;
33
+ }> {
34
+ constructor(props: {
35
+ children: React.ReactNode;
36
+ });
37
+ static getDerivedStateFromError(): {
38
+ hasError: boolean;
39
+ };
40
+ render(): React.ReactNode;
41
+ }
42
+ export declare const ChatFilePreviewProvider: React.FC<{
43
+ children: React.ReactNode;
44
+ }>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Plugin } from '@nocobase/client';
10
+ export declare class PluginAIChatFilePreviewClient extends Plugin {
11
+ load(): Promise<void>;
12
+ }
13
+ export default PluginAIChatFilePreviewClient;
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/plugin-ai/client"),require("@nocobase/client"),require("react"),require("@ant-design/icons"),require("antd")):"function"==typeof define&&define.amd?define("plugin-ai-chat-file-preview",["@nocobase/plugin-ai/client","@nocobase/client","react","@ant-design/icons","antd"],t):"object"==typeof exports?exports["plugin-ai-chat-file-preview"]=t(require("@nocobase/plugin-ai/client"),require("@nocobase/client"),require("react"),require("@ant-design/icons"),require("antd")):e["plugin-ai-chat-file-preview"]=t(e["@nocobase/plugin-ai/client"],e["@nocobase/client"],e.react,e["@ant-design/icons"],e.antd)}(self,function(e,t,n,r,o){return function(){var i,a,l,u,c,s,f={581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},482:function(e){"use strict";e.exports=r},772:function(e){"use strict";e.exports=t},645:function(t){"use strict";t.exports=e},721:function(e){"use strict";e.exports=o},156:function(e){"use strict";e.exports=n}},d={};function p(e){var t=d[e];if(void 0!==t)return t.exports;var n=d[e]={exports:{}};return f[e](n,n.exports,p),n.exports}p.m=f,p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.f={},p.e=function(e){return Promise.all(Object.keys(p.f).reduce(function(t,n){return p.f[n](e,t),t},[]))},p.u=function(e){return""+({395:"0ef9cbd6bccd7aff",463:"7e04271656f34237"})[e]+".js"},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i={},a="plugin-ai-chat-file-preview:",p.l=function(e,t,n,r){if(i[e])return void i[e].push(t);if(void 0!==n)for(var o,l,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var s=u[c];if(s.getAttribute("src")==e||s.getAttribute("data-webpack")==a+n){o=s;break}}o||(l=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,p.nc&&o.setAttribute("nonce",p.nc),o.setAttribute("data-webpack",a+n),o.src=e),i[e]=[t];var f=function(t,n){o.onerror=o.onload=null,clearTimeout(d);var r=i[e];if(delete i[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},d=setTimeout(f.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=f.bind(null,o.onerror),o.onload=f.bind(null,o.onload),l&&document.head.appendChild(o)},p.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(l=window.__webpack_public_path__||"/").endsWith("/")||(l+="/"),p.p=l+"static/plugins/plugin-ai-chat-file-preview/dist/client/",u={909:0},p.f.j=function(e,t){var n=p.o(u,e)?u[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=u[e]=[t,r]});t.push(n[2]=r);var o=p.p+p.u(e),i=Error();p.l(o,function(t){if(p.o(u,e)&&(0!==(n=u[e])&&(u[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},c=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],l=0;if(o.some(function(e){return 0!==u[e]})){for(n in i)p.o(i,n)&&(p.m[n]=i[n]);a&&a(p)}for(e&&e(t);l<o.length;l++)r=o[l],p.o(u,r)&&u[r]&&u[r][0](),u[r]=0},(s=self.webpackChunkplugin_ai_chat_file_preview=self.webpackChunkplugin_ai_chat_file_preview||[]).forEach(c.bind(null,0)),s.push=c.bind(null,s.push.bind(s));var v={};return!function(){"use strict";p.r(v),p.d(v,{PluginAIChatFilePreviewClient:function(){return eg},default:function(){return ew}});var e=p(772),t=p(156),n=p.n(t),r=p(645),o=p(721),i=p(482);function a(e,t,n,r,o,i,a){try{var l=e[i](a),u=l.value}catch(e){n(e);return}l.done?t(u):Promise.resolve(u).then(r,o)}function l(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){a(i,r,o,l,u,"next",e)}function u(e){a(i,r,o,l,u,"throw",e)}l(void 0)})}}function u(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){var u=[i,l];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var c="blobs";function s(){return new Promise(function(e,t){var n=indexedDB.open("nb-ai-chat-file-preview",1);n.onupgradeneeded=function(){var e=n.result;e.objectStoreNames.contains(c)||e.createObjectStore(c)},n.onsuccess=function(){return e(n.result)},n.onerror=function(){return t(n.error)}})}function f(e,t){return"".concat(e,":").concat(t)}var d={get:function(e,t){return l(function(){var n;return u(this,function(r){switch(r.label){case 0:return[4,s()];case 1:return n=r.sent(),[2,new Promise(function(r,o){var i=n.transaction(c,"readonly").objectStore(c).get(f(e,t));i.onsuccess=function(){return r(i.result||null)},i.onerror=function(){return o(i.error)}})]}})})()},has:function(e,t){return l(function(){var n;return u(this,function(r){switch(r.label){case 0:return[4,s()];case 1:return n=r.sent(),[2,new Promise(function(r,o){var i=n.transaction(c,"readonly").objectStore(c).count(f(e,t));i.onsuccess=function(){return r(i.result>0)},i.onerror=function(){return o(i.error)}})]}})})()},listLocalUploads:function(){return l(function(){var e;return u(this,function(t){switch(t.label){case 0:return[4,s()];case 1:return e=t.sent(),[2,new Promise(function(t,n){var r=e.transaction(c,"readonly").objectStore(c).getAllKeys();r.onsuccess=function(){t(r.result.filter(function(e){return e.startsWith("local_uploads:")}).map(function(e){return e.replace("local_uploads:","")}))},r.onerror=function(){return n(r.error)}})]}})})()},put:function(e,t,n){return l(function(){var r;return u(this,function(o){switch(o.label){case 0:return[4,s()];case 1:return r=o.sent(),[2,new Promise(function(o,i){var a=r.transaction(c,"readwrite");a.objectStore(c).put(n,f(e,t)),a.oncomplete=function(){return o()},a.onerror=function(){return i(a.error)}})]}})})()},delete:function(e,t){return l(function(){var n;return u(this,function(r){switch(r.label){case 0:return[4,s()];case 1:return n=r.sent(),[2,new Promise(function(r,o){var i=n.transaction(c,"readwrite");i.objectStore(c).delete(f(e,t)),i.oncomplete=function(){return r()},i.onerror=function(){return o(i.error)}})]}})})()},clearSession:function(e){return l(function(){var t;return u(this,function(n){switch(n.label){case 0:return[4,s()];case 1:return t=n.sent(),[2,new Promise(function(n,r){var o=t.transaction(c,"readwrite"),i=o.objectStore(c).openCursor();i.onsuccess=function(){var t=i.result;t&&("string"==typeof t.key&&t.key.startsWith("".concat(e,":"))&&t.delete(),t.continue())},o.oncomplete=function(){return n()},o.onerror=function(){return r(o.error)}})]}})})()},clearAll:function(){return l(function(){var e;return u(this,function(t){switch(t.label){case 0:return[4,s()];case 1:return e=t.sent(),[2,new Promise(function(t,n){var r=e.transaction(c,"readwrite");r.objectStore(c).clear(),r.oncomplete=function(){return t()},r.onerror=function(){return n(r.error)}})]}})})()}};function h(){var t=(0,e.useApp)();return{t:function(e){return t.i18n.t(e,{ns:"@nocobase/plugin-ai-chat-file-preview"})}}}var m=p(581);function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t,n,r,o,i,a){try{var l=e[i](a),u=l.value}catch(e){n(e);return}l.done?t(u):Promise.resolve(u).then(r,o)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){b(i,r,o,a,l,"next",e)}function l(e){b(i,r,o,a,l,"throw",e)}a(void 0)})}}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){var u=[i,l];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var S=["application/pdf"],E=["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/bmp"],k=["text/plain","text/csv","text/html","text/css","text/javascript","application/json","application/xml","text/xml","text/yaml","application/x-yaml"],C=["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],j=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],_=["pdf"],O=["png","jpg","jpeg","gif","webp","svg","bmp"],P=["txt","csv","html","css","js","json","xml","log","md","yaml","yml","xaml"],L=["docx"],A=["xlsx","xls"];function I(e){var t="string"==typeof e?e:null==e?void 0:e.url;return t?t.startsWith("http://")||t.startsWith("https://")?t:"".concat(location.origin,"/").concat(t.replace(/^\//,"")):""}function R(e,t,n){if((null==e?void 0:e.mimetype)&&t.includes(e.mimetype))return!0;var r,o,i=-1!==(o=(r=("string"==typeof e?e:(null==e?void 0:e.extname)||(null==e?void 0:e.name)||(null==e?void 0:e.filename)||(null==e?void 0:e.url)||"").split("?")[0].split("#")[0]).lastIndexOf("."))?r.slice(o+1).toLowerCase().replace(/^\./,""):"";return!!i&&n.includes(i)}var T=function(e){return R(e,S,_)},F=function(e){return R(e,E,O)},U=function(e){return R(e,k,P)},q=function(e){return R(e,C,L)},B=function(e){return R(e,j,A)};function M(e,t){return z.apply(this,arguments)}function z(){return(z=g(function(e,t){return x(this,function(n){switch(n.label){case 0:return[4,e.axios.get(t,{responseType:"blob"})];case 1:return[2,n.sent().data]}})})).apply(this,arguments)}function N(){return(N=g(function(e,t,n){var r,o,i,a,l;return x(this,function(u){switch(u.label){case 0:if(r=I(e),o=String((null==e?void 0:e.id)||(null==e?void 0:e.uid)||r),(i=(null==e?void 0:e.filename)||(null==e?void 0:e.name)||(null==e?void 0:e.title))&&ei.has(i))return[2,ei.get(i)];if((null==e?void 0:e.title)&&ei.has(e.title))return[2,ei.get(e.title)];if(!(n&&o))return[3,2];return[4,d.get(n,o).catch(function(){return null})];case 1:if(a=u.sent())return[2,a];u.label=2;case 2:if(!r)throw Error("No valid URL");return[4,M(t,r)];case 3:return l=u.sent(),n&&o&&d.put(n,o,l).catch(function(){}),[2,l]}})})).apply(this,arguments)}function D(){return(D=g(function(e,t){var n,r,o,i;return x(this,function(a){switch(a.label){case 0:return[4,function(e,t,n){return N.apply(this,arguments)}(e,t,"")];case 1:return n=a.sent(),r=(null==e?void 0:e.title)&&(null==e?void 0:e.extname)?"".concat(e.title).concat(e.extname):(null==e?void 0:e.filename)||(null==e?void 0:e.name)||"download",(o=document.createElement("a")).href=i=URL.createObjectURL(n),o.download=r,document.body.appendChild(o),o.click(),document.body.removeChild(o),setTimeout(function(){return URL.revokeObjectURL(i)},1e3),[2]}})})).apply(this,arguments)}function W(e){var t=e.msg;return n().createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",width:"100%"}},n().createElement(o.Spin,{tip:t}))}function H(e){var t=e.msg;return n().createElement("div",{style:{padding:20,textAlign:"center",color:"#ff4d4f"}},t)}function X(e,n,r){var o=w((0,t.useState)(null),2),i=o[0],a=o[1],l=w((0,t.useState)(!0),2),u=l[0],c=l[1],s=w((0,t.useState)(null),2),f=s[0],p=s[1],v=(0,t.useRef)(null),h=(null==e?void 0:e.id)||(null==e?void 0:e.uid)||"",m=I(e);return(0,t.useEffect)(function(){var e=!1;if(!m){c(!1),p("No file URL");return}return c(!0),p(null),g(function(){var t,o,i,l,u;return x(this,function(s){switch(s.label){case 0:if(s.trys.push([0,4,,5]),!(r&&h))return[3,2];return[4,d.get(r,String(h))];case 1:if((t=s.sent())&&!e)return v.current=o=URL.createObjectURL(t),a(o),c(!1),[2];s.label=2;case 2:return[4,M(n,m)];case 3:if(i=s.sent(),e)return[2];return r&&h&&d.put(r,String(h),i).catch(function(){}),v.current=l=URL.createObjectURL(i),a(l),c(!1),[3,5];case 4:if(u=s.sent(),e)return[2];return p(u.message||"Failed to load"),c(!1),[3,5];case 5:return[2]}})})(),function(){e=!0,v.current&&(URL.revokeObjectURL(v.current),v.current=null)}},[m,n,r,h]),{blobUrl:i,loading:u,error:f}}function G(t){var r=t.file,o=t.sessionId,i=(0,e.useAPIClient)(),a=h().t,l=X(r,i,o),u=l.blobUrl,c=l.loading,s=l.error;return c?n().createElement(W,{msg:a("Loading preview...")}):s||!u?n().createElement(H,{msg:a("Failed to load file preview")}):n().createElement("iframe",{src:u,width:"100%",height:"100%",style:{border:"none"}})}function V(t){var r=t.file,o=t.sessionId,i=(0,e.useAPIClient)(),a=h().t,l=X(r,i,o),u=l.blobUrl,c=l.loading,s=l.error;return c?n().createElement(W,{msg:a("Loading preview...")}):s||!u?n().createElement(H,{msg:a("Failed to load file preview")}):n().createElement("img",{src:u,style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"},alt:(null==r?void 0:r.filename)||""})}function $(r){var o,i,a,l,u,c,s,f,p,v,m,y=r.file,b=r.sessionId,S=(0,e.useAPIClient)(),E=h().t,k=(i=(o=w((0,t.useState)(null),2))[0],a=o[1],u=(l=w((0,t.useState)(!0),2))[0],c=l[1],f=(s=w((0,t.useState)(null),2))[0],p=s[1],v=(null==y?void 0:y.id)||(null==y?void 0:y.uid)||"",m=I(y),(0,t.useEffect)(function(){var e=!1;if(!m){c(!1),p("No file URL");return}return c(!0),p(null),g(function(){var t,n,r,o;return x(this,function(i){switch(i.label){case 0:if(i.trys.push([0,5,,6]),!(b&&v))return[3,3];return[4,d.get(b,String(v))];case 1:if(!((t=i.sent())&&!e))return[3,3];return[4,t.text()];case 2:return a(i.sent()),c(!1),[2];case 3:return[4,fetchFileAsText(S,m)];case 4:if(n=i.sent(),e)return[2];return b&&v&&(r=new Blob([n],{type:"text/plain"}),d.put(b,String(v),r).catch(function(){})),a(n),c(!1),[3,6];case 5:if(o=i.sent(),e)return[2];return p(o.message||"Failed to load"),c(!1),[3,6];case 6:return[2]}})})(),function(){e=!0}},[m,S,b,v]),{text:i,loading:u,error:f}),C=k.text,j=k.loading,_=k.error;return j?n().createElement(W,{msg:E("Loading preview...")}):_||null===C?n().createElement(H,{msg:E("Failed to load file preview")}):n().createElement("pre",{style:{width:"100%",height:"100%",overflow:"auto",padding:16,margin:0,fontSize:13,lineHeight:1.6,whiteSpace:"pre-wrap",wordWrap:"break-word",background:"#f5f5f5",border:"none"}},C)}function J(r){var o=r.file,i=r.sessionId,a=(0,e.useAPIClient)(),l=h().t,u=(0,t.useRef)(null),c=w((0,t.useState)(!0),2),s=c[0],f=c[1],v=w((0,t.useState)(null),2),y=v[0],b=v[1],S=I(o),E=(null==o?void 0:o.id)||(null==o?void 0:o.uid)||"";return(0,t.useEffect)(function(){var e=!1;if(!S||!u.current){f(!1),b("No file URL");return}return f(!0),b(null),g(function(){var t,n,r,o;return x(this,function(l){switch(l.label){case 0:if(l.trys.push([0,10,,11]),!(i&&E))return[3,5];return[4,d.get(i,String(E))];case 1:if(!((n=l.sent())&&!e))return[3,2];return t=n,[3,4];case 2:return[4,M(a,S)];case 3:if(t=l.sent(),e)return[2];d.put(i,String(E),t).catch(function(){}),l.label=4;case 4:return[3,7];case 5:return[4,M(a,S)];case 6:t=l.sent(),l.label=7;case 7:if(e||!u.current)return[2];return[4,m("imported_-1dm6lbf_component",p.e("395").then(p.bind(p,835)))];case 8:if(r=l.sent(),e||!u.current)return[2];return u.current.innerHTML="",[4,r.renderAsync(t,u.current,void 0,{className:"docx-preview-wrapper",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!1,ignoreFonts:!1,breakPages:!0,ignoreLastRenderedPageBreak:!0,experimental:!1,trimXmlDeclaration:!0,useBase64URL:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,renderEndnotes:!0})];case 9:return l.sent(),f(!1),[3,11];case 10:if(o=l.sent(),e)return[2];return b(o.message||"Failed to render DOCX"),f(!1),[3,11];case 11:return[2]}})})(),function(){e=!0}},[S,a,i,E]),n().createElement("div",{style:{width:"100%",height:"100%",position:"relative"}},s&&n().createElement(W,{msg:l("Loading preview...")}),y&&n().createElement(H,{msg:l("Failed to load file preview")}),n().createElement("div",{ref:u,style:{width:"100%",height:"100%",overflow:"auto",display:s||y?"none":"block"}}))}function K(r){var o=r.file,i=r.sessionId,a=(0,e.useAPIClient)(),l=h().t,u=w((0,t.useState)(!0),2),c=u[0],s=u[1],f=w((0,t.useState)(null),2),v=f[0],y=f[1],b=w((0,t.useState)([]),2),S=b[0],E=b[1],k=w((0,t.useState)(""),2),C=k[0],j=k[1],_=w((0,t.useState)({}),2),O=_[0],P=_[1],L=I(o),A=(null==o?void 0:o.id)||(null==o?void 0:o.uid)||"";return(0,t.useEffect)(function(){var e=!1;if(!L){s(!1),y("No file URL");return}return s(!0),y(null),g(function(){var t,n,r,o,l,u,c,f,v,h,b,g,w,S;return x(this,function(x){switch(x.label){case 0:if(x.trys.push([0,10,,11]),!(i&&A))return[3,5];return[4,d.get(i,String(A))];case 1:if(!((n=x.sent())&&!e))return[3,2];return t=n,[3,4];case 2:return[4,M(a,L)];case 3:if(t=x.sent(),e)return[2];d.put(i,String(A),t).catch(function(){}),x.label=4;case 4:return[3,7];case 5:return[4,M(a,L)];case 6:t=x.sent(),x.label=7;case 7:if(e)return[2];return[4,m("imported_-1lj2ifg_component",p.e("463").then(p.bind(p,312)))];case 8:if(r=x.sent(),e)return[2];return[4,t.arrayBuffer()];case 9:if(o=x.sent(),e)return[2];u=(l=r.read(o,{type:"array"})).SheetNames,c={},f=!0,v=!1,h=void 0;try{for(b=u[Symbol.iterator]();!(f=(g=b.next()).done);f=!0)c[w=g.value]=r.utils.sheet_to_html(l.Sheets[w],{id:"xlsx-preview-table"})}catch(e){v=!0,h=e}finally{try{f||null==b.return||b.return()}finally{if(v)throw h}}if(e)return[2];return E(u),j(u[0]||""),P(c),s(!1),[3,11];case 10:if(S=x.sent(),e)return[2];return y(S.message||"Failed to render XLSX"),s(!1),[3,11];case 11:return[2]}})})(),function(){e=!0}},[L,a,i,A]),n().createElement("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column"}},c&&n().createElement(W,{msg:l("Loading preview...")}),v&&n().createElement(H,{msg:l("Failed to load file preview")}),!c&&!v&&n().createElement(n().Fragment,null,S.length>1&&n().createElement("div",{style:{display:"flex",gap:0,borderBottom:"1px solid #e8e8e8",background:"#fafafa",padding:"0 8px",flexShrink:0,overflowX:"auto"}},S.map(function(e){return n().createElement("button",{key:e,onClick:function(){return j(e)},style:{padding:"8px 16px",border:"none",borderBottom:C===e?"2px solid #1890ff":"2px solid transparent",background:C===e?"#fff":"transparent",color:C===e?"#1890ff":"#666",fontWeight:C===e?600:400,cursor:"pointer",fontSize:13,whiteSpace:"nowrap",transition:"all 0.2s"}},e)})),n().createElement("div",{style:{flex:1,overflow:"auto",padding:0},dangerouslySetInnerHTML:{__html:O[C]||""}}),n().createElement("style",null,"\n #xlsx-preview-table { border-collapse: collapse; width: 100%; font-size: 13px; }\n #xlsx-preview-table td, #xlsx-preview-table th {\n border: 1px solid #e8e8e8; padding: 6px 10px; text-align: left;\n max-width: 33vw; white-space: normal; word-break: break-word;\n }\n #xlsx-preview-table tr:first-child td, #xlsx-preview-table tr:first-child th {\n background: #fafafa; font-weight: 600; position: sticky; top: 0; z-index: 1;\n }\n #xlsx-preview-table tr:nth-child(even) { background: #fafafa; }\n #xlsx-preview-table tr:hover { background: #f0f7ff; }\n ")))}var Y=function(r){var a=r.open,l=r.file,u=r.sessionId,c=r.onClose,s=(0,e.useAPIClient)(),f=h().t,p=w((0,t.useState)(!1),2),v=p[0],m=p[1],y=(null==l?void 0:l.id)||(null==l?void 0:l.uid)||"",b=(0,t.useCallback)(g(function(){return x(this,function(e){switch(e.label){case 0:if(!l)return[2];m(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,function(e,t){return D.apply(this,arguments)}(l,s)];case 2:return e.sent(),[3,5];case 3:return e.sent(),o.message.error(f("Failed to download file")),[3,5];case 4:return m(!1),[7];case 5:return[2]}})}),[l,s,f]),S=(0,t.useCallback)(g(function(){return x(this,function(e){switch(e.label){case 0:if(!u||!y)return[2];return[4,d.delete(u,String(y))];case 1:return e.sent(),o.message.success(f("Cache cleared")),[2]}})}),[u,y,f]),E=(0,t.useMemo)(function(){return l?T(l)?G:F(l)?V:U(l)?$:q(l)?J:B(l)?K:null:null},[l]),k=null!=E,C=(null==l?void 0:l.title)&&(null==l?void 0:l.extname)?"".concat(l.title).concat(l.extname):(null==l?void 0:l.filename)||(null==l?void 0:l.name)||"File";return n().createElement(o.Modal,{open:a,title:C,onCancel:c,destroyOnClose:!0,footer:[u&&y?n().createElement(o.Button,{key:"clear-cache",icon:n().createElement(i.DeleteOutlined,null),onClick:S},f("Clear cache")):null,n().createElement(o.Button,{key:"download",icon:n().createElement(i.DownloadOutlined,null),onClick:b,loading:v},f("Download")),n().createElement(o.Button,{key:"close",onClick:c},f("Close"))].filter(Boolean),width:k?"60vw":520,centered:!0},n().createElement("div",{style:{maxWidth:"100%",maxHeight:k?"calc(100vh - 256px)":"auto",height:k?"70vh":"auto",width:"100%",background:"white",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",overflowY:"auto"}},k&&l?n().createElement(E,{file:l,sessionId:u}):n().createElement(o.Alert,{type:"info",style:{width:"100%"},description:f("This file type cannot be previewed. Click Download to save the file."),showIcon:!0})))};function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Z(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ee(e){return(ee=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function et(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function en(e,t){return(en=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function er(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Q(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eo(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eo=function(){return!!e})()}var ei=new Map;function ea(e){var t=e.querySelector('[class*="-name"]');if(null==t?void 0:t.textContent)return t.textContent.trim();for(var n=e.querySelectorAll("a"),r=0;r<n.length;r++){var o,i,a=null==(i=n[r].textContent)?void 0:i.trim();if(a)return a}var l=e.querySelector('[class*="ellipsis-prefix"]'),u=e.querySelector('[class*="ellipsis-suffix"]');return l&&u?(l.textContent||"")+(u.textContent||""):(null==(o=e.textContent)?void 0:o.trim())||""}function el(e){return{id:e.id,uid:e.uid,url:e.url,filename:e.filename||e.name,name:e.name||e.filename,title:e.title,extname:e.extname,mimetype:e.mimetype,size:e.size}}function eu(e,t,n){if(!e)return null;var r=!0,o=!1,i=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done);r=!0){var u=a.value,c=u.content||u,s=null==c?void 0:c.attachments;if(null==s?void 0:s.length){var f=!0,d=!1,p=void 0;try{for(var v,h=s[Symbol.iterator]();!(f=(v=h.next()).done);f=!0){var m=v.value;if((m.filename||m.name||"")===e||"".concat(m.title||"").concat(m.extname||"")===e)return el(m)}}catch(e){d=!0,p=e}finally{try{f||null==h.return||h.return()}finally{if(d)throw p}}}}}catch(e){o=!0,i=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}var y=!0,b=!1,g=void 0;try{for(var w,x=(n||[])[Symbol.iterator]();!(y=(w=x.next()).done);y=!0){var S=w.value;if((S.filename||S.name||"")===e||"".concat(S.title||"").concat(S.extname||"")===e)return el(S)}}catch(e){b=!0,g=e}finally{try{y||null==x.return||x.return()}finally{if(b)throw g}}return null}function ec(e,t,n){if(!e)return null;var r=function(e,t){return!!e&&!!t&&e.split("?")[0].replace(location.origin,"").replace(/^\//,"")===t.split("?")[0].replace(location.origin,"").replace(/^\//,"")},o=!0,i=!1,a=void 0;try{for(var l,u=t[Symbol.iterator]();!(o=(l=u.next()).done);o=!0){var c=l.value,s=c.content||c,f=null==s?void 0:s.attachments;if(null==f?void 0:f.length){var d=!0,p=!1,v=void 0;try{for(var h,m=f[Symbol.iterator]();!(d=(h=m.next()).done);d=!0){var y=h.value;if(r(y.url,e)||r(y.preview,e))return el(y)}}catch(e){p=!0,v=e}finally{try{d||null==m.return||m.return()}finally{if(p)throw v}}}}}catch(e){i=!0,a=e}finally{try{o||null==u.return||u.return()}finally{if(i)throw a}}var b=!0,g=!1,w=void 0;try{for(var x,S=(n||[])[Symbol.iterator]();!(b=(x=S.next()).done);b=!0){var E=x.value;if(r(E.url,e)||r(E.preview,e))return el(E)}}catch(e){g=!0,w=e}finally{try{b||null==S.return||S.return()}finally{if(g)throw w}}return null}var es=function(o){var i=o.children,a=er((0,t.useState)(!1),2),l=a[0],u=a[1],c=er((0,t.useState)(null),2),s=c[0],f=c[1],p=er((0,t.useState)(""),2),v=p[0],h=p[1],m=(0,e.useAPIClient)(),y=r.useChatMessagesStore.use.messages(),b=r.useChatMessagesStore.use.attachments(),g=(0,t.useRef)(y),w=(0,t.useRef)(b);g.current=y,w.current=b;var x=(0,t.useRef)("");(0,t.useEffect)(function(){var e=m.axios.interceptors.request.use(function(e){var t=e.url||"";if(t.includes("aiConversations:getMessages")){var n=t.match(/sessionId=([^&]+)/);n&&(x.current=decodeURIComponent(n[1]))}if(t.includes("aiConversations:sendMessages")&&e.data)try{var r="string"==typeof e.data?JSON.parse(e.data):e.data;(null==r?void 0:r.sessionId)&&(x.current=r.sessionId)}catch(e){}return e});return function(){m.axios.interceptors.request.eject(e)}},[m]),(0,t.useEffect)(function(){var e=function(e){var t,n=e.target;n&&n.closest&&(n.closest(".ant-x-sender")||n.closest(".ant-x-attachments"))&&(null==(t=e.dataTransfer)?void 0:t.files)&&Array.from(e.dataTransfer.files).forEach(function(e){e.name&&ei.set(e.name,e)})},t=function(e){var t=e.target;t&&t.closest&&(t.closest(".ant-x-sender")||t.closest(".ant-x-attachments"))&&(null==t?void 0:t.type)==="file"&&t.files&&Array.from(t.files).forEach(function(e){e.name&&ei.set(e.name,e)})};return window.addEventListener("drop",e,!0),document.addEventListener("change",t,!0),function(){window.removeEventListener("drop",e,!0),document.removeEventListener("change",t,!0)}},[]),(0,t.useEffect)(function(){var e;(null==(e=w.current)?void 0:e.length)&&w.current.forEach(function(e){var t=e.originFileObj||e;if(t&&(et(t,Blob)||et(t,File)||"size"in t)){var n=e.name||e.filename||t.name;n&&ei.set(n,t)}})},[b]),(0,t.useEffect)(function(){var e=setInterval(function(){var e=document.querySelectorAll(".ant-x-sender, .ant-x-attachments, .ant-x-message"),t=[];e.forEach(function(e){e.querySelectorAll('div[class*="attachment-list-card"]:not([class*="attachment-list-card-"])').forEach(function(e){return t.push(e)})}),t.forEach(function(e){var t=ea(e),n=e.querySelectorAll("a"),r="";n.forEach(function(e){e.href&&(r=e.href)});var o=eu(t,g.current,w.current)||ec(r,g.current,w.current),i=(null==o?void 0:o.filename)||(null==o?void 0:o.name)||(null==o?void 0:o.title);(i&&ei.has(i)?i:t&&ei.has(t)?t:null)?e.classList.add("is-cached-previewable"):e.classList.remove("is-cached-previewable")})},1e3);return function(){return clearInterval(e)}},[]),(0,t.useEffect)(function(){var e=document.createElement("style");return e.innerHTML='\n div[class*="attachment-list-card"]:not([class*="attachment-list-card-"]) {\n position: relative !important;\n cursor: pointer !important;\n }\n /* Prevent pointer events on inner text and icons so the outer div receives the absolute click */\n div[class*="attachment-list-card"]:not([class*="attachment-list-card-"]) a,\n div[class*="attachment-list-card"]:not([class*="attachment-list-card-"]) [class*="-icon"],\n div[class*="attachment-list-card"]:not([class*="attachment-list-card-"]) span {\n pointer-events: none !important;\n }\n /* Re-enable pointer events for the delete button specifically */\n div[class*="attachment-list-card"]:not([class*="attachment-list-card-"]) [class*="-remove"],\n div[class*="attachment-list-card"]:not([class*="attachment-list-card-"]) button,\n div[class*="attachment-list-card"]:not([class*="attachment-list-card-"]) .ant-btn {\n pointer-events: auto !important;\n }\n /* Visual "Preview" badge at the top-left corner using proper SVG */\n div[class*="attachment-list-card"]:not([class*="attachment-list-card-"]).is-cached-previewable::after {\n content: \'\';\n background-image: url("data:image/svg+xml,%3Csvg viewBox=\'64 64 896 896\' xmlns=\'http://www.w3.org/2000/svg\' fill=\'rgba(0,0,0,0.65)\'%3E%3Cpath d=\'M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z\'/%3E%3C/svg%3E");\n background-size: contain;\n background-repeat: no-repeat;\n position: absolute;\n top: 6px;\n left: 6px;\n width: 14px;\n height: 14px;\n z-index: 10;\n pointer-events: none;\n }\n /* Hide native antd thumbnail icon if we placed an eye so it doesnt look messy */\n div[class*="attachment-list-card"]:not([class*="attachment-list-card-"]).is-cached-previewable .ant-upload-list-item-thumbnail {\n opacity: 0.2;\n }\n ',document.head.appendChild(e),function(){e.remove()}},[]),(0,t.useEffect)(function(){var e=function(e){var t=e.target;if(!t||"function"!=typeof t.closest)return;var n=t.closest('[class*="attachment-list-card"]:not([class*="attachment-list-card-"])');if(!(!n||t.closest('[class*="-remove"]')||t.closest(".ant-btn"))&&n.classList.contains("is-cached-previewable")){var r=ea(n),o=n.querySelectorAll("a"),i="";o.forEach(function(e){e.href&&(i=e.href)});var a=eu(r,g.current,w.current)||ec(i,g.current,w.current);a&&(T(a)||F(a)||U(a)||q(a)||B(a))&&(e.preventDefault(),e.stopPropagation(),h(x.current||""),f(a),u(!0))}};return document.addEventListener("click",e,{capture:!0}),function(){return document.removeEventListener("click",e,{capture:!0})}},[]),(0,t.useEffect)(function(){var e=m.axios.interceptors.response.use(function(e){try{var t,n=(null==(t=e.config)?void 0:t.url)||"";if(n.includes("aiConversations:destroy")){var r=n.match(/filterByTk=([^&]+)/);r&&d.clearSession(decodeURIComponent(r[1])).catch(function(){})}}catch(e){}return e});return function(){m.axios.interceptors.response.eject(e)}},[m]);var S=(0,t.useCallback)(function(){u(!1),f(null)},[]);return n().createElement(n().Fragment,null,i,n().createElement(Y,{open:l,file:s,sessionId:v,onClose:S}))},ef=function(e){var t,n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(e){var t,n,o;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return n=r,o=[e],n=ee(n),(t=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eo()?Reflect.construct(n,o||[],ee(this).constructor):n.apply(this,o))).state={hasError:!1},t}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&en(r,e),n=[{key:"getDerivedStateFromError",value:function(){return{hasError:!0}}}],t=[{key:"render",value:function(){return this.state.hasError,this.props.children}}],Z(r.prototype,t),n&&Z(r,n),r}(n().Component),ed=function(e){var t=e.children;return n().createElement(ef,null,n().createElement(es,null,t))};function ep(e,t,n,r,o,i,a){try{var l=e[i](a),u=l.value}catch(e){n(e);return}l.done?t(u):Promise.resolve(u).then(r,o)}function ev(e,t,n){return(ev=eb()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&em(o,n.prototype),o}).apply(null,arguments)}function eh(e){return(eh=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function em(e,t){return(em=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ey(e){var t="function"==typeof Map?new Map:void 0;return(ey=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return ev(e,arguments,eh(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),em(n,e)})(e)}function eb(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eb=function(){return!!e})()}var eg=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=eh(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eb()?Reflect.construct(e,t||[],eh(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&em(n,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){var u=[i,l];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return t.app.use(ed),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){ep(i,r,o,a,l,"next",e)}function l(e){ep(i,r,o,a,l,"throw",e)}a(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(ey(e.Plugin)),ew=eg}(),v}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@nocobase/plugin-ai/client"),require("@nocobase/client"),require("antd")):"function"==typeof define&&define.amd?define("plugin-ai-chat-file-preview",["react","@nocobase/plugin-ai/client","@nocobase/client","antd"],t):"object"==typeof exports?exports["plugin-ai-chat-file-preview"]=t(require("react"),require("@nocobase/plugin-ai/client"),require("@nocobase/client"),require("antd")):e["plugin-ai-chat-file-preview"]=t(e.react,e["@nocobase/plugin-ai/client"],e["@nocobase/client"],e.antd)}(self,function(e,t,n,r){return function(){"use strict";var o={772:function(e){e.exports=n},645:function(e){e.exports=t},721:function(e){e.exports=r},156:function(t){t.exports=e}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return o[e](n,n.exports,i),n.exports}i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,{a:t}),t},i.d=function(e,t){for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return!function(){i.r(l),i.d(l,{PluginAIChatFilePreviewClient:function(){return A},default:function(){return q}});var e=i(772),t=i(156),n=i.n(t),r=i(645),o=i(721);function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}function v(e){var t=e.index,r=e.list,a=e.onSwitchIndex,i=null==r?void 0:r[t];if(!i)return null;var l="string"==typeof i?i:null==i?void 0:i.url,c=l&&(l.startsWith("https://")||l.startsWith("http://"))?l:"".concat(window.location.origin,"/").concat((l||"").replace(/^\//,""));return n().createElement(o.Modal,{open:null!=t,title:(null==i?void 0:i.title)||(null==i?void 0:i.filename)||(null==i?void 0:i.name)||"File Preview (Fallback)",onCancel:function(){return a(null)},footer:n().createElement("div",{style:{display:"flex",justifyContent:"flex-end",gap:8}},n().createElement(o.Button,{onClick:function(){return window.open(c,"_blank")}},"Open Default"),n().createElement(o.Button,{onClick:function(){return a(null)}},"Close")),width:"90%",centered:!0},n().createElement("div",{style:{width:"100%",height:"70vh",background:"white",display:"flex",flexDirection:"column"}},n().createElement("iframe",{src:c,style:{width:"100%",height:"100%",border:"none",flex:1}})))}var h=new Map;function m(e){if("A"===e.tagName)return(null==(o=e.textContent)?void 0:o.trim())||"";var t=e.querySelector('[class*="-name"]');if(null==t?void 0:t.textContent)return t.textContent.trim();for(var n=e.querySelectorAll("a"),r=0;r<n.length;r++){var o,a,i,l=null==(i=n[r].textContent)?void 0:i.trim();if(l)return l}var c=e.querySelector('[class*="ellipsis-prefix"]'),u=e.querySelector('[class*="ellipsis-suffix"]');return c&&u?(c.textContent||"")+(u.textContent||""):(null==(a=e.textContent)?void 0:a.trim())||""}function y(e){return{id:e.id,uid:e.uid,url:e.url,filename:e.filename||e.name,name:e.name||e.filename,title:e.title,extname:e.extname,mimetype:e.mimetype,size:e.size}}function b(e,t,n){if(!e)return null;var r=!0,o=!1,a=void 0;try{for(var i,l=t[Symbol.iterator]();!(r=(i=l.next()).done);r=!0){var c=i.value,u=c.content||c,s=null==u?void 0:u.attachments;if(null==s?void 0:s.length){var f=!0,d=!1,p=void 0;try{for(var v,h=s[Symbol.iterator]();!(f=(v=h.next()).done);f=!0){var m=v.value,b=m.filename||m.name||"",g="".concat(m.title||"").concat(m.extname||"");if(b===e||g===e||b&&e.includes(b.replace(/\.[^/.]+$/,""))||m.title&&e.includes(m.title))return y(m)}}catch(e){d=!0,p=e}finally{try{f||null==h.return||h.return()}finally{if(d)throw p}}}}}catch(e){o=!0,a=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw a}}var w=!0,x=!1,E=void 0;try{for(var O,S=(n||[])[Symbol.iterator]();!(w=(O=S.next()).done);w=!0){var k=O.value,C=k.filename||k.name||"",P="".concat(k.title||"").concat(k.extname||"");if(C===e||P===e||C&&e.includes(C.replace(/\.[^/.]+$/,""))||k.title&&e.includes(k.title))return y(k)}}catch(e){x=!0,E=e}finally{try{w||null==S.return||S.return()}finally{if(x)throw E}}return null}function g(e,t,n){if(!e)return null;var r=function(e,t){return!!e&&!!t&&e.split("?")[0].replace(location.origin,"").replace(/^\//,"")===t.split("?")[0].replace(location.origin,"").replace(/^\//,"")},o=!0,a=!1,i=void 0;try{for(var l,c=t[Symbol.iterator]();!(o=(l=c.next()).done);o=!0){var u=l.value,s=u.content||u,f=null==s?void 0:s.attachments;if(null==f?void 0:f.length){var d=!0,p=!1,v=void 0;try{for(var h,m=f[Symbol.iterator]();!(d=(h=m.next()).done);d=!0){var b=h.value;if(r(b.url,e)||r(b.preview,e))return y(b)}}catch(e){p=!0,v=e}finally{try{d||null==m.return||m.return()}finally{if(p)throw v}}}}}catch(e){a=!0,i=e}finally{try{o||null==c.return||c.return()}finally{if(a)throw i}}var g=!0,w=!1,x=void 0;try{for(var E,O=(n||[])[Symbol.iterator]();!(g=(E=O.next()).done);g=!0){var S=E.value;if(r(S.url,e)||r(S.preview,e))return y(S)}}catch(e){w=!0,x=e}finally{try{g||null==O.return||O.return()}finally{if(w)throw x}}return null}var w=function(o){var a=o.children,i=d((0,t.useState)(!1),2),l=i[0],c=i[1],u=d((0,t.useState)(null),2),f=u[0],p=u[1],y=d((0,t.useState)(""),2),w=(y[0],y[1]),x=(0,e.useAPIClient)(),E=r.useChatMessagesStore.use.messages(),O=r.useChatMessagesStore.use.attachments(),S=(0,t.useRef)(E),k=(0,t.useRef)(O);S.current=E,k.current=O;var C=(0,t.useRef)("");(0,t.useEffect)(function(){var e=x.axios.interceptors.request.use(function(e){var t=e.url||"";if(t.includes("aiConversations:getMessages")){var n=t.match(/sessionId=([^&]+)/);n&&(C.current=decodeURIComponent(n[1]))}if(t.includes("aiConversations:sendMessages")&&e.data)try{var r="string"==typeof e.data?JSON.parse(e.data):e.data;(null==r?void 0:r.sessionId)&&(C.current=r.sessionId)}catch(e){}return e});return function(){x.axios.interceptors.request.eject(e)}},[x]),(0,t.useEffect)(function(){var e=setInterval(function(){document.querySelectorAll(".ant-attachment-list-card-name").forEach(function(e){var t=e.getAttribute("href");t&&!t.includes("/api/filePreviewAuth:download")&&e.setAttribute("href","/api/filePreviewAuth:download?url=".concat(encodeURIComponent(t)))}),document.querySelectorAll("a.ai-attachment-link").forEach(function(e){var t=e.getAttribute("href");!t||t.includes("/api/filePreviewAuth:download")||t.includes("skillHub:download")||t.includes("worker-monitor")||e.setAttribute("href","/api/filePreviewAuth:download?url=".concat(encodeURIComponent(t)))}),document.querySelectorAll('.nb-markdown a[href*="skillHub:download"], .nb-markdown a[href*="worker-monitor"]').forEach(function(e){e.classList.contains("ai-attachment-link")||e.classList.add("ai-attachment-link")})},1e3);return function(){return clearInterval(e)}},[]),(0,t.useEffect)(function(){var e=function(e){var t,n=e.target;n&&n.closest&&(n.closest(".ant-x-sender")||n.closest(".ant-x-attachments"))&&(null==(t=e.dataTransfer)?void 0:t.files)&&Array.from(e.dataTransfer.files).forEach(function(e){e.name&&h.set(e.name,e)})},t=function(e){var t=e.target;t&&t.closest&&(t.closest(".ant-x-sender")||t.closest(".ant-x-attachments"))&&(null==t?void 0:t.type)==="file"&&t.files&&Array.from(t.files).forEach(function(e){e.name&&h.set(e.name,e)})};return window.addEventListener("drop",e,!0),document.addEventListener("change",t,!0),function(){window.removeEventListener("drop",e,!0),document.removeEventListener("change",t,!0)}},[]),(0,t.useEffect)(function(){var e;(null==(e=k.current)?void 0:e.length)&&k.current.forEach(function(e){var t=e.originFileObj||e;if(t&&(s(t,Blob)||s(t,File)||"size"in t)){var n=e.name||e.filename||t.name;n&&h.set(n,t)}})},[O]),(0,t.useEffect)(function(){var e=setInterval(function(){var e=document.querySelectorAll(".ant-x-sender, .ant-x-attachments, .ant-x-message"),t=[];e.forEach(function(e){e.querySelectorAll('div[class*="attachment-list-card"]:not([class*="attachment-list-card-"])').forEach(function(e){return t.push(e)}),e.querySelectorAll("a").forEach(function(e){var n=e.href;n&&(n.includes("/api/attachments/")||n.includes("/api/files/download/")||n.includes("/api/worker-monitor/")||n.includes("/api/skillHub:download"))&&(t.push(e),e.classList.contains("ai-attachment-link")||(e.classList.add("ai-attachment-link"),e.classList.add("attachment-list-card")))})}),t.forEach(function(e){var t=m(e),n="";"A"===e.tagName?n=e.href:e.querySelectorAll("a").forEach(function(e){e.href&&(n=e.href)});var r=b(t,S.current,k.current)||g(n,S.current,k.current),o=(null==r?void 0:r.filename)||(null==r?void 0:r.name)||(null==r?void 0:r.title),a=o&&h.has(o)?o:t&&h.has(t)?t:null,i=n&&(n.includes("/api/attachments/")||n.includes("/api/files/download/")||n.includes("/api/worker-monitor/")||n.includes("/api/skillHub:download"));r||a||i?e.classList.add("is-cached-previewable"):e.classList.remove("is-cached-previewable")})},1e3);return function(){return clearInterval(e)}},[]),(0,t.useEffect)(function(){var e=document.createElement("style");return e.innerHTML="\n .ant-attachment-list-card {\n position: relative !important;\n cursor: pointer !important;\n }\n /* Prevent pointer events on inner text and icons so the outer div receives the absolute click */\n .ant-attachment-list-card a,\n .ant-attachment-list-card [class*=\"-icon\"],\n .ant-attachment-list-card span {\n pointer-events: none !important;\n }\n /* Re-enable pointer events for the delete button specifically */\n .ant-attachment-list-card [class*=\"-remove\"],\n .ant-attachment-list-card button,\n .ant-attachment-list-card .ant-btn {\n pointer-events: auto !important;\n }\n /* Visual \"Preview\" badge at the top-left corner using proper SVG */\n .ant-attachment-list-card.is-cached-previewable::after {\n content: '';\n background-image: url(\"data:image/svg+xml,%3Csvg viewBox='64 64 896 896' xmlns='http://www.w3.org/2000/svg' fill='rgba(0,0,0,0.65)'%3E%3Cpath d='M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z'/%3E%3C/svg%3E\");\n background-size: contain;\n background-repeat: no-repeat;\n position: absolute;\n top: 6px;\n left: 6px;\n width: 14px;\n height: 14px;\n z-index: 10;\n pointer-events: none;\n }\n /* Hide native antd thumbnail icon if we placed an eye so it doesnt look messy */\n .ant-attachment-list-card.is-cached-previewable .ant-upload-list-item-thumbnail {\n opacity: 0.2;\n }\n /* Custom aesthetics for raw AI-generated links to match cards */\n a.ai-attachment-link {\n display: inline-flex;\n align-items: center;\n padding: 8px 12px;\n margin: 4px;\n border: 1px solid #d9d9d9;\n border-radius: 8px;\n background: #fafafa;\n color: rgba(0, 0, 0, 0.88);\n text-decoration: none !important;\n position: relative;\n cursor: pointer !important;\n transition: all 0.2s;\n line-height: 1.5;\n }\n a.ai-attachment-link:hover {\n background: #f0f0f0;\n }\n a.ai-attachment-link::before {\n content: '\uD83D\uDCC4 ';\n margin-right: 8px;\n font-size: 14px;\n }\n a.ai-attachment-link.is-cached-previewable::after {\n content: '';\n background-image: url(\"data:image/svg+xml,%3Csvg viewBox='64 64 896 896' xmlns='http://www.w3.org/2000/svg' fill='rgba(0,0,0,0.65)'%3E%3Cpath d='M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z'/%3E%3C/svg%3E\");\n background-size: contain;\n background-repeat: no-repeat;\n position: absolute;\n top: -6px;\n left: -6px;\n width: 14px;\n height: 14px;\n z-index: 10;\n pointer-events: none;\n }\n ",document.head.appendChild(e),function(){e.remove()}},[]),(0,t.useEffect)(function(){var e=function(e){var t=e.target;if(!t||"function"!=typeof t.closest)return;var n="",r="",o=t.closest("a"),a=t.closest(".ant-attachment-list-card"),i=t.closest(".ant-tag");if(!(!o&&!a&&!i||t.closest('[class*="-remove"]')||t.closest(".ant-tag-close-icon")||t.closest(".ant-btn"))){a?(r=m(a),"A"===a.tagName?n=a.href:a.querySelectorAll("a").forEach(function(e){e.href&&(n=e.href)})):o?(n=o.href,r=o.textContent||"download"):i&&(r=(null==(d=i.textContent)?void 0:d.trim())||"");var l=n;if(n&&n.includes("/api/filePreviewAuth:download?url="))try{var u=new URL(n,window.location.origin);l=decodeURIComponent(u.searchParams.get("url")||n)}catch(e){}var s=b(r,S.current,k.current)||g(l,S.current,k.current),f=l&&(l.includes("/api/attachments/")||l.includes("/api/files/download/")||l.includes("/api/worker-monitor/")||l.includes("/api/skillHub:download")||l.includes("/storage/uploads/")||l.includes("amazonaws.com"));if(s||f||!o||a){if(!s&&f){var d,v,h=null==(v=l.match(/\.([a-z0-9]+)(?:[\?#]|$)/i))?void 0:v[1];s={id:l,uid:l,url:l,filename:r||"attachment",name:r||"attachment",extname:h?".".concat(h):void 0,mimetype:""}}if(s||f){e.preventDefault(),e.stopPropagation();var y,x,E=!l||l.includes("skillHub:download")||l.includes("worker-monitor")?l||s.url:"/api/filePreviewAuth:download?url=".concat(encodeURIComponent(l));y=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},s),x=x={url:E},Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(x)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(x)).forEach(function(e){Object.defineProperty(y,e,Object.getOwnPropertyDescriptor(x,e))}),s=y,w(C.current||""),p(s),c(!0)}}}};return document.addEventListener("click",e,{capture:!0}),function(){return document.removeEventListener("click",e,{capture:!0})}},[]);var P=(0,t.useCallback)(function(){c(!1),p(null)},[]),j=(0,t.useMemo)(function(){if(!f||!l)return null;var t=e.attachmentFileTypes.getTypeByFile(f);return(null==t?void 0:t.Previewer)||v},[f,l]);return n().createElement(n().Fragment,null,a,j&&l&&f&&n().createElement(j,{index:0,list:[f],onSwitchIndex:function(e){null===e&&P()}}))},x=function(e){var t,n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(e){var t,n,o;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return n=r,o=[e],n=u(n),(t=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,p()?Reflect.construct(n,o||[],u(this).constructor):n.apply(this,o))).state={hasError:!1},t}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&f(r,e),n=[{key:"getDerivedStateFromError",value:function(){return{hasError:!0}}}],t=[{key:"render",value:function(){return this.state.hasError,this.props.children}}],c(r.prototype,t),n&&c(r,n),r}(n().Component),E=function(e){var t=e.children;return n().createElement(x,null,n().createElement(w,null,t))};function O(e,t,n,r,o,a,i){try{var l=e[a](i),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function S(e,t,n){return(S=j()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&C(o,n.prototype),o}).apply(null,arguments)}function k(e){return(k=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e,t){return(C=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function P(e){var t="function"==typeof Map?new Map:void 0;return(P=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return S(e,arguments,k(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),C(n,e)})(e)}function j(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(j=function(){return!!e})()}var A=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=k(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,j()?Reflect.construct(e,t||[],k(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&C(n,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var c=[a,l];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(e){return t.app.use(E),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){O(a,r,o,i,l,"next",e)}function l(e){O(a,r,o,i,l,"throw",e)}i(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(P(e.Plugin)),q=A}(),l}()});
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export declare function useTranslation(): {
10
+ t: (key: string) => string;
11
+ };
@@ -9,9 +9,8 @@
9
9
 
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
- "@nocobase/client": "2.0.32",
13
- "@nocobase/plugin-ai": "2.0.32",
12
+ "@nocobase/client": "2.0.38",
13
+ "@nocobase/plugin-ai": "2.0.38",
14
14
  "antd": "5.24.2",
15
- "@ant-design/icons": "5.6.1",
16
- "@nocobase/server": "2.0.32"
15
+ "@nocobase/server": "2.0.38"
17
16
  };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export * from './server';
10
+ export { default } from './server';
@@ -1,10 +1,10 @@
1
- {
2
- "Loading preview...": "Loading preview...",
3
- "Failed to load file preview": "Failed to load file preview",
4
- "Failed to download file": "Failed to download file",
5
- "Download": "Download",
6
- "Close": "Close",
7
- "Clear cache": "Clear cache",
8
- "Cache cleared": "Cache cleared",
9
- "This file type cannot be previewed. Click Download to save the file.": "This file type cannot be previewed. Click Download to save the file."
10
- }
1
+ {
2
+ "Loading preview...": "Loading preview...",
3
+ "Failed to load file preview": "Failed to load file preview",
4
+ "Failed to download file": "Failed to download file",
5
+ "Download": "Download",
6
+ "Close": "Close",
7
+ "Clear cache": "Clear cache",
8
+ "Cache cleared": "Cache cleared",
9
+ "This file type cannot be previewed. Click Download to save the file.": "This file type cannot be previewed. Click Download to save the file."
10
+ }
@@ -1,10 +1,10 @@
1
- {
2
- "Loading preview...": "Đang tải xem trước...",
3
- "Failed to load file preview": "Không thể tải xem trước file",
4
- "Failed to download file": "Không thể tải file",
5
- "Download": "Tải xuống",
6
- "Close": "Đóng",
7
- "Clear cache": "Xóa bộ nhớ đệm",
8
- "Cache cleared": "Đã xóa bộ nhớ đệm",
9
- "This file type cannot be previewed. Click Download to save the file.": "Loại file này không thể xem trước. Nhấn Tải xuống để lưu file."
10
- }
1
+ {
2
+ "Loading preview...": "Đang tải xem trước...",
3
+ "Failed to load file preview": "Không thể tải xem trước file",
4
+ "Failed to download file": "Không thể tải file",
5
+ "Download": "Tải xuống",
6
+ "Close": "Đóng",
7
+ "Clear cache": "Xóa bộ nhớ đệm",
8
+ "Cache cleared": "Đã xóa bộ nhớ đệm",
9
+ "This file type cannot be previewed. Click Download to save the file.": "Loại file này không thể xem trước. Nhấn Tải xuống để lưu file."
10
+ }
@@ -1,10 +1,10 @@
1
- {
2
- "Loading preview...": "加载预览中...",
3
- "Failed to load file preview": "加载文件预览失败",
4
- "Failed to download file": "下载文件失败",
5
- "Download": "下载",
6
- "Close": "关闭",
7
- "Clear cache": "清除缓存",
8
- "Cache cleared": "缓存已清除",
9
- "This file type cannot be previewed. Click Download to save the file.": "此文件类型无法预览。点击下载保存文件。"
10
- }
1
+ {
2
+ "Loading preview...": "加载预览中...",
3
+ "Failed to load file preview": "加载文件预览失败",
4
+ "Failed to download file": "下载文件失败",
5
+ "Download": "下载",
6
+ "Close": "关闭",
7
+ "Clear cache": "清除缓存",
8
+ "Cache cleared": "缓存已清除",
9
+ "This file type cannot be previewed. Click Download to save the file.": "此文件类型无法预览。点击下载保存文件。"
10
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export { default } from './plugin';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Plugin } from '@nocobase/server';
10
+ export declare class PluginAIChatFilePreviewServer extends Plugin {
11
+ load(): Promise<void>;
12
+ }
13
+ export default PluginAIChatFilePreviewServer;
package/package.json CHANGED
@@ -1,30 +1,32 @@
1
- {
2
- "name": "plugin-ai-chat-file-preview",
3
- "displayName": "AI Chat File Preview",
4
- "displayName.vi-VN": "Xem trước file trong Chat AI",
5
- "displayName.zh-CN": "AI聊天文件预览",
6
- "description": "Preview uploaded file attachments directly in AI Employee chat with in-browser caching.",
7
- "description.vi-VN": "Xem trước file đính kèm đã tải lên trực tiếp trong chat AI Employee với bộ nhớ đệm trình duyệt.",
8
- "description.zh-CN": "在AI员工聊天中直接预览上传的文件附件,支持浏览器缓存。",
9
- "version": "1.0.11",
10
- "main": "dist/server/index.js",
11
- "dependencies": {
12
- "xlsx": "^0.18.5",
13
- "docx-preview": "^0.3.3"
14
- },
15
- "peerDependencies": {
16
- "@nocobase/client": "2.x",
17
- "@nocobase/server": "2.x",
18
- "@nocobase/database": "2.x",
19
- "@nocobase/plugin-ai": "2.x",
20
- "@nocobase/plugin-file-manager": "2.x"
21
- },
22
- "devDependencies": {},
23
- "keywords": [
24
- "AI",
25
- "Chat",
26
- "File preview",
27
- "Cache"
28
- ],
29
- "license": "Apache-2.0"
30
- }
1
+ {
2
+ "name": "plugin-ai-chat-file-preview",
3
+ "displayName": "AI Chat File Preview",
4
+ "displayName.vi-VN": "Xem trước file trong Chat AI",
5
+ "displayName.zh-CN": "AI聊天文件预览",
6
+ "description": "NocoBase AI Assistant 预览附件(Word, Excel, PDF, CSV...)支持 S3 auth",
7
+ "description.vi-VN": "Preview file attachment tren AI Chat (Word, Excel, PDF, CSV...) kem S3 auth",
8
+ "description.zh-CN": "在AI员工聊天中直接预览上传的文件附件,支持浏览器缓存。",
9
+ "version": "1.0.16",
10
+ "main": "dist/server/index.js",
11
+ "dependencies": {},
12
+ "peerDependencies": {
13
+ "@nocobase/client": "2.x",
14
+ "@nocobase/server": "2.x",
15
+ "@nocobase/database": "2.x",
16
+ "@nocobase/plugin-ai": "2.x",
17
+ "@nocobase/plugin-file-manager": "2.x"
18
+ },
19
+ "nocobase": {
20
+ "supportedVersions": [
21
+ "2.x"
22
+ ]
23
+ },
24
+ "devDependencies": {},
25
+ "keywords": [
26
+ "AI",
27
+ "Chat",
28
+ "File preview",
29
+ "Cache"
30
+ ],
31
+ "license": "Apache-2.0"
32
+ }
package/server.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './dist/server';
2
- export { default } from './dist/server';
1
+ export * from './dist/server';
2
+ export { default } from './dist/server';
package/server.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./dist/server');
1
+ module.exports = require('./dist/server');