@feathery/react 2.54.1 → 2.55.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.
- package/cjs/assistant/AssistantChat.d.ts.map +1 -1
- package/cjs/assistant/AttachmentParts.d.ts +28 -0
- package/cjs/assistant/AttachmentParts.d.ts.map +1 -0
- package/cjs/assistant/ToolStatus.d.ts +3 -1
- package/cjs/assistant/ToolStatus.d.ts.map +1 -1
- package/cjs/assistant/attachmentIcon.d.ts +11 -0
- package/cjs/assistant/attachmentIcon.d.ts.map +1 -0
- package/cjs/assistant/attachments.d.ts +39 -0
- package/cjs/assistant/attachments.d.ts.map +1 -0
- package/cjs/assistant/icons.d.ts +2 -0
- package/cjs/assistant/icons.d.ts.map +1 -1
- package/cjs/assistant/useChatAttachments.d.ts +23 -0
- package/cjs/assistant/useChatAttachments.d.ts.map +1 -0
- package/cjs/{fthry_AssistantChat.DC9xTDBq.js → fthry_AssistantChat.Cwyk3iiA.js} +956 -79
- package/cjs/{fthry_FormControl.Bdf7uZbI.js → fthry_FormControl.DQFuYIrs.js} +1 -1
- package/cjs/{fthry_InlineTooltip.2VyC_zlO.js → fthry_InlineTooltip.C-3eLvAv.js} +1 -1
- package/cjs/{fthry_PaymentMethodField.DX_e5Cso.js → fthry_PaymentMethodField.Cs9nBB47.js} +3 -3
- package/cjs/{fthry_Placeholder.ChSA2IUD.js → fthry_Placeholder.CUmM_ix-.js} +1 -1
- package/cjs/{fthry_ShowEyeIcon.BygC4iZn.js → fthry_ShowEyeIcon.D6Lwhfy_.js} +1 -1
- package/cjs/{fthry_TabsElement.CtLQwrj7.js → fthry_TabsElement.CgL3YMbf.js} +1 -1
- package/cjs/{fthry_auto-track.CsRLwF_7.js → fthry_auto-track.DhDJ7Six.js} +2 -2
- package/cjs/{fthry_highlighted-body-TPN3WLV5.9jZwkvuV.js → fthry_highlighted-body-TPN3WLV5.BzjtpXVW.js} +3 -3
- package/cjs/{fthry_index.BIIaLCnQ.js → fthry_index.BBtmp2lX.js} +2 -2
- package/cjs/{fthry_index.ChNOkT2I.js → fthry_index.BF-anQOj.js} +29 -29
- package/cjs/{fthry_index.CzDrCb8q.js → fthry_index.BLh4y2dS.js} +1 -1
- package/cjs/{fthry_index.DHfH5dUT.js → fthry_index.Bgz8QD73.js} +1 -1
- package/cjs/{fthry_index.BCsydmxn.js → fthry_index.BiQgM_mp.js} +5 -5
- package/cjs/{fthry_index.BQ1PDK75.js → fthry_index.BiYemmOs.js} +7 -7
- package/cjs/{fthry_index.DzwK56rK.js → fthry_index.BkUZn1Wx.js} +2 -2
- package/cjs/{fthry_index.DAMJSPDY.js → fthry_index.C0qSps2I.js} +4 -4
- package/cjs/{fthry_index.-t8SJQod.js → fthry_index.C9hwfIUQ.js} +5 -5
- package/cjs/{fthry_index.CQjWjwkb.js → fthry_index.CD8G4Ned.js} +2 -2
- package/cjs/{fthry_index.DDFvIZR1.js → fthry_index.CGx_UCOl.js} +10 -10
- package/cjs/{fthry_index.CvWhzgMd.js → fthry_index.COUHEKea.js} +1 -1
- package/cjs/{fthry_index.CA0CmgZ4.js → fthry_index.CPrsbFNe.js} +1 -1
- package/cjs/{fthry_index.DmrFRKyN.js → fthry_index.CPx7ld_r.js} +1 -1
- package/cjs/{fthry_index.BSW1HMfh.js → fthry_index.CbTgNihl.js} +2 -2
- package/cjs/{fthry_index.D-RpAapg.js → fthry_index.CizURN5l.js} +5 -5
- package/cjs/{fthry_index.vE97mYTi.js → fthry_index.Cl8PTNLj.js} +5 -5
- package/cjs/{fthry_index.DYDegaGW.js → fthry_index.CusanmZ4.js} +1 -1
- package/cjs/{fthry_index.DUgslBs4.js → fthry_index.D--5x2--.js} +1 -1
- package/cjs/{fthry_index.BIMFZ8jD.js → fthry_index.D-JzzjZq.js} +1 -1
- package/cjs/{fthry_index.Bd4Ki2jq.js → fthry_index.D01OXK-l.js} +2 -2
- package/cjs/{fthry_index.CFV4pCZG.js → fthry_index.DPvMA8nx.js} +1 -1
- package/cjs/{fthry_index.g_KiTGIC.js → fthry_index.DYt_hVte.js} +4 -4
- package/cjs/{fthry_index.C9_33yc4.js → fthry_index.DZ7mRbvH.js} +4 -4
- package/cjs/{fthry_index.rLo-GP4e.js → fthry_index.DcLxtTSW.js} +2 -2
- package/cjs/{fthry_index.DVYmg2dL.js → fthry_index.DjoQ9rvl.js} +1 -1
- package/cjs/{fthry_index.DEwX9wLw.js → fthry_index.DxAMmenQ.js} +3 -3
- package/cjs/{fthry_index.Czq6v8vF.js → fthry_index.ZlEa6xRd.js} +2 -2
- package/cjs/{fthry_index.D2b6CFHh.js → fthry_index.fHBYZguT.js} +3 -3
- package/cjs/{fthry_index.DLcJ6-kL.js → fthry_index.hoemhTIo.js} +4 -4
- package/cjs/{fthry_index.CqeDMnGC.js → fthry_index.mHIYCN--.js} +3 -3
- package/cjs/{fthry_index.umd.oim0GOsP.js → fthry_index.umd.DcnVOTNd.js} +1 -1
- package/cjs/{fthry_index.NRIwQAZb.js → fthry_index.y6sfh246.js} +1 -1
- package/cjs/{fthry_input.CaVTEiAk.js → fthry_input.D_ZZBUiA.js} +1 -1
- package/cjs/{fthry_logging.BOawaGT3.js → fthry_logging.DnMqEtZk.js} +1 -1
- package/cjs/{fthry_mermaid-O7DHMXV3.BUbH9Bc_.js → fthry_mermaid-O7DHMXV3.D2BXxJ0r.js} +3 -3
- package/cjs/{fthry_script.CIquRYMv.js → fthry_script.CiEL5EkQ.js} +1 -1
- package/cjs/{fthry_styles.wtdZ0TVk.js → fthry_styles.BQvJdT7h.js} +1 -1
- package/cjs/{fthry_useElementSize.CoMSw1CX.js → fthry_useElementSize.DuwzR_F7.js} +1 -1
- package/cjs/{fthry_useSalesforceSync.DLst19Gd.js → fthry_useSalesforceSync.B6nQeLV2.js} +1 -1
- package/cjs/{fthry_webfontloader.Cc0PNQPM.js → fthry_webfontloader.DKvYHlYz.js} +1 -1
- package/cjs/index.js +1 -1
- package/cjs/thumbnail-renderer.js +1 -1
- package/dist/assistant/AssistantChat.d.ts.map +1 -1
- package/dist/assistant/AttachmentParts.d.ts +28 -0
- package/dist/assistant/AttachmentParts.d.ts.map +1 -0
- package/dist/assistant/ToolStatus.d.ts +3 -1
- package/dist/assistant/ToolStatus.d.ts.map +1 -1
- package/dist/assistant/attachmentIcon.d.ts +11 -0
- package/dist/assistant/attachmentIcon.d.ts.map +1 -0
- package/dist/assistant/attachments.d.ts +39 -0
- package/dist/assistant/attachments.d.ts.map +1 -0
- package/dist/assistant/icons.d.ts +2 -0
- package/dist/assistant/icons.d.ts.map +1 -1
- package/dist/assistant/useChatAttachments.d.ts +23 -0
- package/dist/assistant/useChatAttachments.d.ts.map +1 -0
- package/dist/{fthry_AssistantChat.CPE5WlOV.js → fthry_AssistantChat.Be6Mlyxj.js} +956 -79
- package/dist/{fthry_FormControl.C_9IBGCz.js → fthry_FormControl.CCkAPkgv.js} +1 -1
- package/dist/{fthry_InlineTooltip.X4qb_h52.js → fthry_InlineTooltip.DZD_oDzB.js} +1 -1
- package/dist/{fthry_PaymentMethodField.Co9wIIWl.js → fthry_PaymentMethodField.CtsyjvwX.js} +3 -3
- package/dist/{fthry_Placeholder.tXEd80yu.js → fthry_Placeholder.DuqjLBhG.js} +1 -1
- package/dist/{fthry_ShowEyeIcon.BL4SODVQ.js → fthry_ShowEyeIcon.Dl2TsElo.js} +1 -1
- package/dist/{fthry_TabsElement.CefoTVIr.js → fthry_TabsElement.CYi3mzi8.js} +1 -1
- package/dist/{fthry_auto-track.K-xWX3KP.js → fthry_auto-track.IfDBqGyL.js} +2 -2
- package/dist/{fthry_highlighted-body-TPN3WLV5.CqH7kZh1.js → fthry_highlighted-body-TPN3WLV5.HLcU1iPh.js} +3 -3
- package/dist/{fthry_index.8G4DCva4.js → fthry_index.4qpRAeb_.js} +1 -1
- package/dist/{fthry_index.DVKk9DNh.js → fthry_index.9S43igFs.js} +1 -1
- package/dist/{fthry_index.QmJ7llJy.js → fthry_index.B5JfgN_s.js} +1 -1
- package/dist/{fthry_index.D2uuo-Hp.js → fthry_index.B8hwXw5R.js} +7 -7
- package/dist/{fthry_index.CIUN5omC.js → fthry_index.BEMCjmqu.js} +29 -29
- package/dist/{fthry_index.eUA7gKd_.js → fthry_index.BN-dojiL.js} +2 -2
- package/dist/{fthry_index.CYa-BeVL.js → fthry_index.BOvYhhGJ.js} +4 -4
- package/dist/{fthry_index.Dt6tQ9YA.js → fthry_index.BP1lC3Ex.js} +1 -1
- package/dist/{fthry_index.B5gAQiuF.js → fthry_index.BbE2kPjj.js} +3 -3
- package/dist/{fthry_index.DXLRXJ4G.js → fthry_index.BvcpsGy9.js} +1 -1
- package/dist/{fthry_index.BRN8lHtb.js → fthry_index.C09MbTMD.js} +2 -2
- package/dist/{fthry_index.CGYJ3nnH.js → fthry_index.C0NfUYmR.js} +2 -2
- package/dist/{fthry_index.CC3ua88H.js → fthry_index.C2LGfmCQ.js} +2 -2
- package/dist/{fthry_index.B80HhVUt.js → fthry_index.C3o7HpC2.js} +4 -4
- package/dist/{fthry_index.CC8Uh5gL.js → fthry_index.C5AkH2wz.js} +1 -1
- package/dist/{fthry_index.-NrRAjJG.js → fthry_index.C5qllWuc.js} +1 -1
- package/dist/{fthry_index.D6GyUvFt.js → fthry_index.CK3aIPly.js} +5 -5
- package/dist/{fthry_index.vvzR2QO1.js → fthry_index.CaMfiw6o.js} +3 -3
- package/dist/{fthry_index.BS4E7I-K.js → fthry_index.CfnDnR43.js} +1 -1
- package/dist/{fthry_index.AnuSOreY.js → fthry_index.CtdDjHjk.js} +3 -3
- package/dist/{fthry_index.8HF4sRHu.js → fthry_index.D7q1aD6-.js} +4 -4
- package/dist/{fthry_index.zsPt4ANk.js → fthry_index.DDTSEIcr.js} +4 -4
- package/dist/{fthry_index.DfnBmlMN.js → fthry_index.DM3jqh2p.js} +10 -10
- package/dist/{fthry_index.CXo7Ei4g.js → fthry_index.DMH1cJrX.js} +2 -2
- package/dist/{fthry_index.B_lMLNyy.js → fthry_index.DP8hzsWg.js} +1 -1
- package/dist/{fthry_index.J4ksi0Sm.js → fthry_index.DYf0nmmc.js} +1 -1
- package/dist/{fthry_index.GTJWvsNs.js → fthry_index.Dk6aTBdA.js} +1 -1
- package/dist/{fthry_index.DsfyJrK_.js → fthry_index.DvUMGcjt.js} +2 -2
- package/dist/{fthry_index.B4fdBk_2.js → fthry_index.IYd_eVta.js} +5 -5
- package/dist/{fthry_index.DMwfwUer.js → fthry_index.Ob5rm80I.js} +5 -5
- package/dist/{fthry_index.C4ZsKex6.js → fthry_index.T0q4NPjx.js} +4 -4
- package/dist/{fthry_index.DqUkarFt.js → fthry_index.okrffQYp.js} +2 -2
- package/dist/{fthry_index.umd.DHsdRPRZ.js → fthry_index.umd.DNLZlzl6.js} +1 -1
- package/dist/{fthry_input.Ci7lyHy3.js → fthry_input.DBmpsGLP.js} +1 -1
- package/dist/{fthry_logging.DQALXb9A.js → fthry_logging.DXY4LvSS.js} +1 -1
- package/dist/fthry_mermaid-O7DHMXV3.C56szY3n.js +8 -0
- package/dist/{fthry_script.BDiZrpF8.js → fthry_script.C894YzAl.js} +1 -1
- package/dist/{fthry_styles.fEY_n086.js → fthry_styles.Ds16q-VH.js} +1 -1
- package/dist/{fthry_useElementSize.CEbFfmei.js → fthry_useElementSize.DAdDGR_p.js} +1 -1
- package/dist/{fthry_useSalesforceSync.BfAudVDV.js → fthry_useSalesforceSync.BGUfOU7k.js} +1 -1
- package/dist/{fthry_webfontloader.CCmkUKka.js → fthry_webfontloader.j-I3KznG.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/thumbnail-renderer.js +1 -1
- package/package.json +1 -1
- package/umd/AssistantChat.31154097f6b644e3a50b.js +1 -0
- package/umd/index.js +1 -1
- package/dist/fthry_mermaid-O7DHMXV3.D6DhpWPU.js +0 -8
- package/umd/AssistantChat.e42d65ae6bc7cfc4b909.js +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index$1 = require('./fthry_index.
|
|
3
|
+
var index$1 = require('./fthry_index.BF-anQOj.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var clsx = require('./fthry_clsx.BtxeOLZW.js');
|
|
6
6
|
var ReactJSXRuntime = require('react/jsx-runtime');
|
|
7
7
|
var ReactDOM = require('react-dom');
|
|
8
|
-
var index$2 = require('./fthry_index.
|
|
8
|
+
var index$2 = require('./fthry_index.Bgz8QD73.js');
|
|
9
9
|
|
|
10
10
|
// src/errors/ai-sdk-error.ts
|
|
11
11
|
var marker = "vercel.ai.error";
|
|
@@ -9765,7 +9765,774 @@ var ChevronsLeftIcon = function (props) { return (index$1.jsxs("svg", index$1.__
|
|
|
9765
9765
|
var ChevronsRightIcon = function (props) { return (index$1.jsxs("svg", index$1.__assign({ width: '16', height: '16', viewBox: '0 0 24 24', fill: 'none' }, props, { children: [index$1.jsx("path", { d: 'm6 17 5-5-5-5', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' }), index$1.jsx("path", { d: 'm13 17 5-5-5-5', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' })] }))); };
|
|
9766
9766
|
var LinkIcon = function (props) { return (index$1.jsxs("svg", index$1.__assign({ width: '12', height: '12', viewBox: '0 0 24 24', fill: 'none' }, props, { children: [index$1.jsx("path", { d: 'M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' }), index$1.jsx("path", { d: 'M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' })] }))); };
|
|
9767
9767
|
var MicIcon = function (props) { return (index$1.jsxs("svg", index$1.__assign({ width: '20', height: '20', viewBox: '0 0 24 24', fill: 'none' }, props, { children: [index$1.jsx("rect", { x: '9', y: '3', width: '6', height: '12', rx: '3', stroke: 'currentColor', strokeWidth: '2' }), index$1.jsx("path", { d: 'M5 11a7 7 0 0 0 14 0', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M12 18v3', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' })] }))); };
|
|
9768
|
-
var WaveformIcon = function (props) { return (index$1.jsxs("svg", index$1.__assign({ width: '18', height: '18', viewBox: '0 0 24 24', fill: 'none' }, props, { children: [index$1.jsx("path", { d: 'M4 12v0', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M8 9v6', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M12 5v14', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M16 9v6', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M20 11v2', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' })] }))); };
|
|
9768
|
+
var WaveformIcon = function (props) { return (index$1.jsxs("svg", index$1.__assign({ width: '18', height: '18', viewBox: '0 0 24 24', fill: 'none' }, props, { children: [index$1.jsx("path", { d: 'M4 12v0', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M8 9v6', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M12 5v14', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M16 9v6', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M20 11v2', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' })] }))); };
|
|
9769
|
+
var PaperclipIcon = function (props) { return (index$1.jsx("svg", index$1.__assign({ width: '18', height: '18', viewBox: '0 0 24 24', fill: 'none' }, props, { children: index$1.jsx("path", { d: 'm21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' }) }))); };
|
|
9770
|
+
var DocumentIcon = function (props) { return (index$1.jsxs("svg", index$1.__assign({ width: '16', height: '16', viewBox: '0 0 24 24', fill: 'none' }, props, { children: [index$1.jsx("path", { d: 'M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' }), index$1.jsx("path", { d: 'M14 2v6h6', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' })] }))); };
|
|
9771
|
+
|
|
9772
|
+
var MAX_DIMENSION = 1568;
|
|
9773
|
+
var MAX_FILE_SIZE = 25 * 1024 * 1024;
|
|
9774
|
+
var MAX_ATTACHMENTS = 5;
|
|
9775
|
+
var IMAGE_MEDIA_TYPES = new Set([
|
|
9776
|
+
'image/png',
|
|
9777
|
+
'image/jpeg',
|
|
9778
|
+
'image/gif',
|
|
9779
|
+
'image/webp'
|
|
9780
|
+
]);
|
|
9781
|
+
// Mirrors MEDIA_TYPE_TO_EXTENSION on the ai-services side
|
|
9782
|
+
// (src/modules/robin/attachment/mediaTypes.ts), keep in sync
|
|
9783
|
+
var DOC_MEDIA_TYPES = new Set([
|
|
9784
|
+
'application/pdf',
|
|
9785
|
+
'application/msword',
|
|
9786
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
9787
|
+
'application/rtf',
|
|
9788
|
+
'text/rtf',
|
|
9789
|
+
'application/vnd.ms-powerpoint',
|
|
9790
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
9791
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
9792
|
+
'application/vnd.ms-excel.sheet.macroEnabled.12',
|
|
9793
|
+
'application/vnd.ms-excel',
|
|
9794
|
+
'text/csv'
|
|
9795
|
+
]);
|
|
9796
|
+
var ALLOWED_MEDIA_TYPES = new Set(index$1.__spreadArray(index$1.__spreadArray([], index$1.__read(IMAGE_MEDIA_TYPES), false), index$1.__read(DOC_MEDIA_TYPES), false));
|
|
9797
|
+
var ACCEPT_ATTR = [
|
|
9798
|
+
'image/png',
|
|
9799
|
+
'image/jpeg',
|
|
9800
|
+
'image/gif',
|
|
9801
|
+
'image/webp',
|
|
9802
|
+
'application/pdf',
|
|
9803
|
+
'.pdf',
|
|
9804
|
+
'application/msword',
|
|
9805
|
+
'.doc',
|
|
9806
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
9807
|
+
'.docx',
|
|
9808
|
+
'application/rtf',
|
|
9809
|
+
'text/rtf',
|
|
9810
|
+
'.rtf',
|
|
9811
|
+
'application/vnd.ms-powerpoint',
|
|
9812
|
+
'.ppt',
|
|
9813
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
9814
|
+
'.pptx',
|
|
9815
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
9816
|
+
'.xlsx',
|
|
9817
|
+
'application/vnd.ms-excel.sheet.macroEnabled.12',
|
|
9818
|
+
'.xlsm',
|
|
9819
|
+
'application/vnd.ms-excel',
|
|
9820
|
+
'.xls',
|
|
9821
|
+
'text/csv',
|
|
9822
|
+
'.csv'
|
|
9823
|
+
].join(',');
|
|
9824
|
+
var isImageType = function (mediaType) {
|
|
9825
|
+
return IMAGE_MEDIA_TYPES.has(mediaType);
|
|
9826
|
+
};
|
|
9827
|
+
var isTerminalStatus = function (s) { return s === 'ready' || s === 'failed' || s === 'skipped'; };
|
|
9828
|
+
// Attachment endpoints are the /agent/attachment/ sibling of the chat base,
|
|
9829
|
+
// same origin (threadsBase precedent in utils.ts)
|
|
9830
|
+
var attachmentBase = function (baseUrl) {
|
|
9831
|
+
return new URL('/agent/attachment/', baseUrl).href;
|
|
9832
|
+
};
|
|
9833
|
+
// The thread id doubles as the attachment session key (builder convention:
|
|
9834
|
+
// a new chat mints the uuid that becomes the thread id on first message)
|
|
9835
|
+
var chatSessionIds = new WeakMap();
|
|
9836
|
+
var setChatSessionId = function (chat, sessionId) {
|
|
9837
|
+
return chatSessionIds.set(chat, sessionId);
|
|
9838
|
+
};
|
|
9839
|
+
var getChatSessionId = function (chat) {
|
|
9840
|
+
return chatSessionIds.get(chat);
|
|
9841
|
+
};
|
|
9842
|
+
function compressImage(file) {
|
|
9843
|
+
return index$1.__awaiter(this, void 0, void 0, function () {
|
|
9844
|
+
var bitmap, width, height, scale, canvas_1, ctx, blob;
|
|
9845
|
+
return index$1.__generator(this, function (_b) {
|
|
9846
|
+
switch (_b.label) {
|
|
9847
|
+
case 0:
|
|
9848
|
+
_b.trys.push([0, 3, , 4]);
|
|
9849
|
+
return [4 /*yield*/, createImageBitmap(file)];
|
|
9850
|
+
case 1:
|
|
9851
|
+
bitmap = _b.sent();
|
|
9852
|
+
width = bitmap.width, height = bitmap.height;
|
|
9853
|
+
if (width <= MAX_DIMENSION &&
|
|
9854
|
+
height <= MAX_DIMENSION &&
|
|
9855
|
+
file.type === 'image/jpeg') {
|
|
9856
|
+
bitmap.close();
|
|
9857
|
+
return [2 /*return*/, file];
|
|
9858
|
+
}
|
|
9859
|
+
scale = Math.min(MAX_DIMENSION / width, MAX_DIMENSION / height, 1);
|
|
9860
|
+
canvas_1 = index$1.featheryDoc().createElement('canvas');
|
|
9861
|
+
canvas_1.width = Math.round(width * scale);
|
|
9862
|
+
canvas_1.height = Math.round(height * scale);
|
|
9863
|
+
ctx = canvas_1.getContext('2d');
|
|
9864
|
+
if (!ctx)
|
|
9865
|
+
return [2 /*return*/, file];
|
|
9866
|
+
ctx.drawImage(bitmap, 0, 0, canvas_1.width, canvas_1.height);
|
|
9867
|
+
bitmap.close();
|
|
9868
|
+
return [4 /*yield*/, new Promise(function (resolve) {
|
|
9869
|
+
return canvas_1.toBlob(resolve, 'image/jpeg', 0.85);
|
|
9870
|
+
})];
|
|
9871
|
+
case 2:
|
|
9872
|
+
blob = _b.sent();
|
|
9873
|
+
if (!blob)
|
|
9874
|
+
return [2 /*return*/, file];
|
|
9875
|
+
return [2 /*return*/, new File([blob], file.name.replace(/\.\w+$/, '.jpg'), {
|
|
9876
|
+
type: 'image/jpeg'
|
|
9877
|
+
})];
|
|
9878
|
+
case 3:
|
|
9879
|
+
_b.sent();
|
|
9880
|
+
return [2 /*return*/, file];
|
|
9881
|
+
case 4: return [2 /*return*/];
|
|
9882
|
+
}
|
|
9883
|
+
});
|
|
9884
|
+
});
|
|
9885
|
+
}
|
|
9886
|
+
function uploadAttachment(file, baseUrl, headers, sessionId, signal) {
|
|
9887
|
+
return index$1.__awaiter(this, void 0, void 0, function () {
|
|
9888
|
+
var form, response, message, body, err;
|
|
9889
|
+
return index$1.__generator(this, function (_b) {
|
|
9890
|
+
switch (_b.label) {
|
|
9891
|
+
case 0:
|
|
9892
|
+
form = new FormData();
|
|
9893
|
+
form.append('file', file);
|
|
9894
|
+
return [4 /*yield*/, fetch(attachmentBase(baseUrl), {
|
|
9895
|
+
method: 'POST',
|
|
9896
|
+
headers: index$1.__assign(index$1.__assign({}, headers()), { 'X-Session-ID': sessionId }),
|
|
9897
|
+
body: form,
|
|
9898
|
+
signal: signal
|
|
9899
|
+
})];
|
|
9900
|
+
case 1:
|
|
9901
|
+
response = _b.sent();
|
|
9902
|
+
if (!!response.ok) return [3 /*break*/, 6];
|
|
9903
|
+
message = "Upload failed (".concat(response.status, ")");
|
|
9904
|
+
_b.label = 2;
|
|
9905
|
+
case 2:
|
|
9906
|
+
_b.trys.push([2, 4, , 5]);
|
|
9907
|
+
return [4 /*yield*/, response.json()];
|
|
9908
|
+
case 3:
|
|
9909
|
+
body = _b.sent();
|
|
9910
|
+
if (body === null || body === void 0 ? void 0 : body.error)
|
|
9911
|
+
message = body.error;
|
|
9912
|
+
return [3 /*break*/, 5];
|
|
9913
|
+
case 4:
|
|
9914
|
+
_b.sent();
|
|
9915
|
+
return [3 /*break*/, 5];
|
|
9916
|
+
case 5:
|
|
9917
|
+
err = new Error(message);
|
|
9918
|
+
err.status = response.status;
|
|
9919
|
+
throw err;
|
|
9920
|
+
case 6: return [2 /*return*/, response.json()];
|
|
9921
|
+
}
|
|
9922
|
+
});
|
|
9923
|
+
});
|
|
9924
|
+
}
|
|
9925
|
+
var POLL_INTERVAL_MS = 2000;
|
|
9926
|
+
var POLL_TIMEOUT_MS = 390000; // ~6.5 min: pipeline budget (~6 min) + slack
|
|
9927
|
+
var delay = function (ms, signal) {
|
|
9928
|
+
return new Promise(function (resolve, reject) {
|
|
9929
|
+
if (signal.aborted) {
|
|
9930
|
+
reject(new DOMException('Aborted', 'AbortError'));
|
|
9931
|
+
return;
|
|
9932
|
+
}
|
|
9933
|
+
var onAbort = function () {
|
|
9934
|
+
clearTimeout(t);
|
|
9935
|
+
reject(new DOMException('Aborted', 'AbortError'));
|
|
9936
|
+
};
|
|
9937
|
+
var t = setTimeout(function () {
|
|
9938
|
+
signal.removeEventListener('abort', onAbort);
|
|
9939
|
+
resolve();
|
|
9940
|
+
}, ms);
|
|
9941
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
9942
|
+
});
|
|
9943
|
+
};
|
|
9944
|
+
// Poll GET /:id/url/ until the row reaches a terminal state, upload
|
|
9945
|
+
// auto-dispatches embedding server-side so polling is the whole client
|
|
9946
|
+
// contract
|
|
9947
|
+
function pollAttachmentStatus(attachmentId, baseUrl, headers, sessionId, signal) {
|
|
9948
|
+
return index$1.__awaiter(this, void 0, void 0, function () {
|
|
9949
|
+
var id, deadline, resp, err_1, body;
|
|
9950
|
+
return index$1.__generator(this, function (_a) {
|
|
9951
|
+
switch (_a.label) {
|
|
9952
|
+
case 0:
|
|
9953
|
+
id = encodeURIComponent(attachmentId);
|
|
9954
|
+
deadline = Date.now() + POLL_TIMEOUT_MS;
|
|
9955
|
+
_a.label = 1;
|
|
9956
|
+
case 1:
|
|
9957
|
+
resp = null;
|
|
9958
|
+
_a.label = 2;
|
|
9959
|
+
case 2:
|
|
9960
|
+
_a.trys.push([2, 4, , 5]);
|
|
9961
|
+
return [4 /*yield*/, fetch("".concat(attachmentBase(baseUrl)).concat(id, "/url/"), {
|
|
9962
|
+
method: 'GET',
|
|
9963
|
+
headers: index$1.__assign(index$1.__assign({}, headers()), { 'X-Session-ID': sessionId }),
|
|
9964
|
+
signal: signal
|
|
9965
|
+
})];
|
|
9966
|
+
case 3:
|
|
9967
|
+
resp = _a.sent();
|
|
9968
|
+
return [3 /*break*/, 5];
|
|
9969
|
+
case 4:
|
|
9970
|
+
err_1 = _a.sent();
|
|
9971
|
+
// Network blips retry until the deadline, aborts exit the loop
|
|
9972
|
+
if (signal.aborted)
|
|
9973
|
+
throw err_1;
|
|
9974
|
+
return [3 /*break*/, 5];
|
|
9975
|
+
case 5:
|
|
9976
|
+
if (!(resp === null || resp === void 0 ? void 0 : resp.ok)) return [3 /*break*/, 7];
|
|
9977
|
+
return [4 /*yield*/, resp.json()];
|
|
9978
|
+
case 6:
|
|
9979
|
+
body = (_a.sent());
|
|
9980
|
+
if (isTerminalStatus(body.processingStatus)) {
|
|
9981
|
+
return [2 /*return*/, body];
|
|
9982
|
+
}
|
|
9983
|
+
return [3 /*break*/, 8];
|
|
9984
|
+
case 7:
|
|
9985
|
+
if (resp && [401, 403, 404].includes(resp.status)) {
|
|
9986
|
+
// Definitive 4xx won't heal, 5xx retries until the deadline
|
|
9987
|
+
throw new Error("Attachment status check failed (".concat(resp.status, ")"));
|
|
9988
|
+
}
|
|
9989
|
+
_a.label = 8;
|
|
9990
|
+
case 8:
|
|
9991
|
+
if (Date.now() >= deadline) {
|
|
9992
|
+
throw new Error("Embedding timed out after ".concat(Math.round(POLL_TIMEOUT_MS / 1000), "s"));
|
|
9993
|
+
}
|
|
9994
|
+
return [4 /*yield*/, delay(POLL_INTERVAL_MS, signal)];
|
|
9995
|
+
case 9:
|
|
9996
|
+
_a.sent();
|
|
9997
|
+
return [3 /*break*/, 1];
|
|
9998
|
+
case 10: return [2 /*return*/];
|
|
9999
|
+
}
|
|
10000
|
+
});
|
|
10001
|
+
});
|
|
10002
|
+
}
|
|
10003
|
+
function getFilePart(attachment) {
|
|
10004
|
+
var _a, _b, _c;
|
|
10005
|
+
return index$1.__assign({ type: 'file', mediaType: (_a = attachment.uploadedMediaType) !== null && _a !== void 0 ? _a : attachment.file.type, filename: (_b = attachment.uploadedFilename) !== null && _b !== void 0 ? _b : attachment.file.name, url: (_c = attachment.uploadedUrl) !== null && _c !== void 0 ? _c : attachment.previewUrl }, (attachment.id
|
|
10006
|
+
? { providerMetadata: { feathery: { attachmentId: attachment.id } } }
|
|
10007
|
+
: {}));
|
|
10008
|
+
}
|
|
10009
|
+
|
|
10010
|
+
var DEFAULT_CHAT_COLOR = '#6b7280';
|
|
10011
|
+
var GRAY_50 = '#f9fafb';
|
|
10012
|
+
var GRAY_100 = '#f3f4f6';
|
|
10013
|
+
var GRAY_200 = '#e5e7eb';
|
|
10014
|
+
var GRAY_400 = '#9ca3af';
|
|
10015
|
+
var GRAY_500 = '#6b7280';
|
|
10016
|
+
var GRAY_800 = '#1f2937';
|
|
10017
|
+
var RED_500 = '#ef4444';
|
|
10018
|
+
// Generate lighter/darker variants from hex color
|
|
10019
|
+
var adjustColor = function (hex, percent) {
|
|
10020
|
+
var num = parseInt(hex.replace('#', ''), 16);
|
|
10021
|
+
var r = Math.min(255, Math.max(0, (num >> 16) + Math.round(2.55 * percent)));
|
|
10022
|
+
var g = Math.min(255, Math.max(0, ((num >> 8) & 0x00ff) + Math.round(2.55 * percent)));
|
|
10023
|
+
var b = Math.min(255, Math.max(0, (num & 0x0000ff) + Math.round(2.55 * percent)));
|
|
10024
|
+
return "#".concat(((r << 16) | (g << 8) | b).toString(16).padStart(6, '0'));
|
|
10025
|
+
};
|
|
10026
|
+
var blendToWhite = function (hex, percent) {
|
|
10027
|
+
var num = parseInt(hex.replace('#', ''), 16);
|
|
10028
|
+
var r = (num >> 16) & 0xff;
|
|
10029
|
+
var g = (num >> 8) & 0xff;
|
|
10030
|
+
var b = num & 0xff;
|
|
10031
|
+
var blend = percent / 100;
|
|
10032
|
+
var newR = Math.round(r + (255 - r) * blend);
|
|
10033
|
+
var newG = Math.round(g + (255 - g) * blend);
|
|
10034
|
+
var newB = Math.round(b + (255 - b) * blend);
|
|
10035
|
+
return "#".concat(((newR << 16) | (newG << 8) | newB)
|
|
10036
|
+
.toString(16)
|
|
10037
|
+
.padStart(6, '0'));
|
|
10038
|
+
};
|
|
10039
|
+
// Compute all color variants from primary
|
|
10040
|
+
var getChatColors = function (primary) { return ({
|
|
10041
|
+
primary: primary,
|
|
10042
|
+
hover: adjustColor(primary, -15),
|
|
10043
|
+
disabled: adjustColor(primary, 30),
|
|
10044
|
+
light: blendToWhite(primary, 90) // Light: assistant bubbles
|
|
10045
|
+
}); };
|
|
10046
|
+
|
|
10047
|
+
function FilePageGlyph(_a) {
|
|
10048
|
+
var label = _a.label, props = index$1.__rest(_a, ["label"]);
|
|
10049
|
+
return (index$1.jsxs("svg", index$1.__assign({ viewBox: '0 0 24 24', fill: 'none', "aria-hidden": 'true' }, props, { children: [index$1.jsx("path", { d: 'M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z', stroke: 'currentColor', strokeWidth: 1.75, strokeLinecap: 'round', strokeLinejoin: 'round' }), index$1.jsx("path", { d: 'M14 2v6h6', stroke: 'currentColor', strokeWidth: 1.75, strokeLinecap: 'round', strokeLinejoin: 'round' }), index$1.jsx("text", index$1.__assign({ x: 12, y: 18, textAnchor: 'middle', fontSize: 6, fontWeight: 700, fontFamily: 'ui-sans-serif, system-ui, -apple-system, sans-serif', letterSpacing: -0.2, fill: 'currentColor', stroke: 'none' }, { children: label }))] })));
|
|
10050
|
+
}
|
|
10051
|
+
var PdfIcon = function (props) { return (index$1.jsx(FilePageGlyph, index$1.__assign({ label: 'PDF' }, props))); };
|
|
10052
|
+
var WordIcon = function (props) { return (index$1.jsx(FilePageGlyph, index$1.__assign({ label: 'DOC' }, props))); };
|
|
10053
|
+
var ExcelIcon = function (props) { return (index$1.jsx(FilePageGlyph, index$1.__assign({ label: 'XLS' }, props))); };
|
|
10054
|
+
var PowerpointIcon = function (props) { return (index$1.jsx(FilePageGlyph, index$1.__assign({ label: 'PPT' }, props))); };
|
|
10055
|
+
var CsvIcon = function (props) { return (index$1.jsx(FilePageGlyph, index$1.__assign({ label: 'CSV' }, props))); };
|
|
10056
|
+
function getAttachmentIcon(file) {
|
|
10057
|
+
var _a, _b, _c, _d;
|
|
10058
|
+
var mime = (_a = file.type) !== null && _a !== void 0 ? _a : '';
|
|
10059
|
+
var ext = (_d = (_c = (_b = file.name) === null || _b === void 0 ? void 0 : _b.split('.').pop()) === null || _c === void 0 ? void 0 : _c.toLowerCase()) !== null && _d !== void 0 ? _d : '';
|
|
10060
|
+
if (mime === 'application/pdf' || ext === 'pdf') {
|
|
10061
|
+
return { Icon: PdfIcon, color: '#fb7185' };
|
|
10062
|
+
}
|
|
10063
|
+
if (mime === 'application/msword' ||
|
|
10064
|
+
mime ===
|
|
10065
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
|
|
10066
|
+
mime === 'application/rtf' ||
|
|
10067
|
+
mime === 'text/rtf' ||
|
|
10068
|
+
ext === 'doc' ||
|
|
10069
|
+
ext === 'docx' ||
|
|
10070
|
+
ext === 'rtf') {
|
|
10071
|
+
return { Icon: WordIcon, color: '#38bdf8' };
|
|
10072
|
+
}
|
|
10073
|
+
if (mime === 'application/vnd.ms-excel' ||
|
|
10074
|
+
mime ===
|
|
10075
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ||
|
|
10076
|
+
mime === 'application/vnd.ms-excel.sheet.macroEnabled.12' ||
|
|
10077
|
+
ext === 'xls' ||
|
|
10078
|
+
ext === 'xlsx' ||
|
|
10079
|
+
ext === 'xlsm') {
|
|
10080
|
+
return { Icon: ExcelIcon, color: '#34d399' };
|
|
10081
|
+
}
|
|
10082
|
+
if (mime === 'application/vnd.ms-powerpoint' ||
|
|
10083
|
+
mime ===
|
|
10084
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation' ||
|
|
10085
|
+
ext === 'ppt' ||
|
|
10086
|
+
ext === 'pptx') {
|
|
10087
|
+
return { Icon: PowerpointIcon, color: '#fb923c' };
|
|
10088
|
+
}
|
|
10089
|
+
if (mime === 'text/csv' || ext === 'csv') {
|
|
10090
|
+
return { Icon: CsvIcon, color: '#2dd4bf' };
|
|
10091
|
+
}
|
|
10092
|
+
return null;
|
|
10093
|
+
}
|
|
10094
|
+
|
|
10095
|
+
// pdf.js loads from the CDN at runtime, never bundled (the UMD build and
|
|
10096
|
+
// consumer bundlers choke on pdfjs-dist's ESM), same version pin as the
|
|
10097
|
+
// dashboard document editor, new Function hides the import from bundlers
|
|
10098
|
+
var PDFJS_VERSION = '5.4.296';
|
|
10099
|
+
var PDFJS_CDN = "https://cdn.jsdelivr.net/npm/pdfjs-dist@".concat(PDFJS_VERSION, "/build/pdf.min.mjs");
|
|
10100
|
+
var PDFJS_WORKER_CDN = "https://cdn.jsdelivr.net/npm/pdfjs-dist@".concat(PDFJS_VERSION, "/build/pdf.worker.min.mjs");
|
|
10101
|
+
// eslint-disable-next-line no-new-func
|
|
10102
|
+
var importFromCdn = new Function('url', 'return import(url)');
|
|
10103
|
+
var pdfjsPromise = null;
|
|
10104
|
+
var loadPdfjs = function () {
|
|
10105
|
+
if (!pdfjsPromise) {
|
|
10106
|
+
pdfjsPromise = importFromCdn(PDFJS_CDN)
|
|
10107
|
+
.then(function (mod) {
|
|
10108
|
+
mod.GlobalWorkerOptions.workerSrc = PDFJS_WORKER_CDN;
|
|
10109
|
+
return mod;
|
|
10110
|
+
})
|
|
10111
|
+
.catch(function (err) {
|
|
10112
|
+
console.warn('[feathery] pdf.js failed to load from CDN', err);
|
|
10113
|
+
// Retry on the next thumbnail instead of caching the failure
|
|
10114
|
+
pdfjsPromise = null;
|
|
10115
|
+
return null;
|
|
10116
|
+
});
|
|
10117
|
+
}
|
|
10118
|
+
return pdfjsPromise;
|
|
10119
|
+
};
|
|
10120
|
+
// Colored per-type glyph (PDF/DOC/XLS/PPT/CSV), gray generic icon otherwise
|
|
10121
|
+
var TypedFileIcon = function (_a) {
|
|
10122
|
+
var mediaType = _a.mediaType, filename = _a.filename, _b = _a.size, size = _b === void 0 ? 24 : _b;
|
|
10123
|
+
var typed = getAttachmentIcon({ type: mediaType, name: filename });
|
|
10124
|
+
if (!typed) {
|
|
10125
|
+
return (index$1.jsx(DocumentIcon, { css: { width: size, height: size, color: GRAY_400 } }));
|
|
10126
|
+
}
|
|
10127
|
+
var Icon = typed.Icon, color = typed.color;
|
|
10128
|
+
return index$1.jsx(Icon, { css: { width: size, height: size, color: color, flexShrink: 0 } });
|
|
10129
|
+
};
|
|
10130
|
+
var LazyPdfThumbnail = React.memo(function LazyPdfThumbnail(_a) {
|
|
10131
|
+
var _this = this;
|
|
10132
|
+
var url = _a.url, _b = _a.width, width = _b === void 0 ? 140 : _b, glyph = _a.glyph;
|
|
10133
|
+
var canvasRef = React.useRef(null);
|
|
10134
|
+
var _c = index$1.__read(React.useState('loading'), 2), state = _c[0], setState = _c[1];
|
|
10135
|
+
React.useEffect(function () {
|
|
10136
|
+
var cancelled = false;
|
|
10137
|
+
// no reset to 'loading' here, when the optimistic blob URL swaps to the
|
|
10138
|
+
// signed URL the old render stays visible until the new one lands
|
|
10139
|
+
(function () { return index$1.__awaiter(_this, void 0, void 0, function () {
|
|
10140
|
+
var pdfjs, doc, page, base, viewport, canvas, err_1;
|
|
10141
|
+
return index$1.__generator(this, function (_a) {
|
|
10142
|
+
switch (_a.label) {
|
|
10143
|
+
case 0: return [4 /*yield*/, loadPdfjs()];
|
|
10144
|
+
case 1:
|
|
10145
|
+
pdfjs = _a.sent();
|
|
10146
|
+
if (cancelled)
|
|
10147
|
+
return [2 /*return*/];
|
|
10148
|
+
if (!pdfjs) {
|
|
10149
|
+
setState('error');
|
|
10150
|
+
return [2 /*return*/];
|
|
10151
|
+
}
|
|
10152
|
+
_a.label = 2;
|
|
10153
|
+
case 2:
|
|
10154
|
+
_a.trys.push([2, 6, , 7]);
|
|
10155
|
+
return [4 /*yield*/, pdfjs.getDocument({ url: url }).promise];
|
|
10156
|
+
case 3:
|
|
10157
|
+
doc = _a.sent();
|
|
10158
|
+
return [4 /*yield*/, doc.getPage(1)];
|
|
10159
|
+
case 4:
|
|
10160
|
+
page = _a.sent();
|
|
10161
|
+
base = page.getViewport({ scale: 1 });
|
|
10162
|
+
viewport = page.getViewport({ scale: width / base.width });
|
|
10163
|
+
canvas = canvasRef.current;
|
|
10164
|
+
if (!canvas || cancelled)
|
|
10165
|
+
return [2 /*return*/];
|
|
10166
|
+
canvas.width = viewport.width;
|
|
10167
|
+
canvas.height = viewport.height;
|
|
10168
|
+
return [4 /*yield*/, page.render({
|
|
10169
|
+
canvasContext: canvas.getContext('2d'),
|
|
10170
|
+
viewport: viewport
|
|
10171
|
+
}).promise];
|
|
10172
|
+
case 5:
|
|
10173
|
+
_a.sent();
|
|
10174
|
+
if (!cancelled)
|
|
10175
|
+
setState('ready');
|
|
10176
|
+
return [3 /*break*/, 7];
|
|
10177
|
+
case 6:
|
|
10178
|
+
err_1 = _a.sent();
|
|
10179
|
+
console.warn('[feathery] PDF preview failed to load', { url: url, err: err_1 });
|
|
10180
|
+
if (!cancelled)
|
|
10181
|
+
setState('error');
|
|
10182
|
+
return [3 /*break*/, 7];
|
|
10183
|
+
case 7: return [2 /*return*/];
|
|
10184
|
+
}
|
|
10185
|
+
});
|
|
10186
|
+
}); })();
|
|
10187
|
+
return function () {
|
|
10188
|
+
cancelled = true;
|
|
10189
|
+
};
|
|
10190
|
+
}, [url, width]);
|
|
10191
|
+
// Fixed-size slice, builder parity (h-28 w-[140px]), the page renders at
|
|
10192
|
+
// full width and the box crops the rest, loading/error is the same box as
|
|
10193
|
+
// a flat gray square so the swap never shifts layout
|
|
10194
|
+
var height = Math.round(width * 0.8);
|
|
10195
|
+
var ready = state === 'ready';
|
|
10196
|
+
return (index$1.jsxs("div", index$1.__assign({ css: index$1.__assign({ width: "".concat(width, "px"), height: "".concat(height, "px"), overflow: 'hidden', borderRadius: '8px', border: "1px solid ".concat(GRAY_200), backgroundColor: ready ? 'white' : GRAY_100 }, (ready
|
|
10197
|
+
? {}
|
|
10198
|
+
: {
|
|
10199
|
+
display: 'flex',
|
|
10200
|
+
alignItems: 'center',
|
|
10201
|
+
justifyContent: 'center',
|
|
10202
|
+
color: GRAY_400
|
|
10203
|
+
})) }, { children: [!ready && (glyph === undefined ? index$1.jsx(DocumentIcon, {}) : glyph), index$1.jsx("canvas", { ref: canvasRef, css: {
|
|
10204
|
+
display: ready ? 'block' : 'none',
|
|
10205
|
+
maxWidth: '100%'
|
|
10206
|
+
} })] })));
|
|
10207
|
+
});
|
|
10208
|
+
// Composer chip: thumbnail or typed icon + truncated name, failed badge,
|
|
10209
|
+
// per-chip remove, no processing indicator (builder parity, in-flight shows
|
|
10210
|
+
// on the optimistic message thumbnail)
|
|
10211
|
+
var AttachmentChip = function (_a) {
|
|
10212
|
+
var _b, _c;
|
|
10213
|
+
var attachment = _a.attachment, onRemove = _a.onRemove;
|
|
10214
|
+
var mediaType = (_b = attachment.uploadedMediaType) !== null && _b !== void 0 ? _b : attachment.file.type;
|
|
10215
|
+
var filename = (_c = attachment.uploadedFilename) !== null && _c !== void 0 ? _c : attachment.file.name;
|
|
10216
|
+
var failed = attachment.processingStatus === 'failed';
|
|
10217
|
+
return (index$1.jsxs("div", index$1.__assign({ css: {
|
|
10218
|
+
position: 'relative',
|
|
10219
|
+
display: 'flex',
|
|
10220
|
+
alignItems: 'center',
|
|
10221
|
+
gap: '6px',
|
|
10222
|
+
padding: '4px 6px',
|
|
10223
|
+
border: "1px solid ".concat(failed ? '#fca5a5' : GRAY_200),
|
|
10224
|
+
borderRadius: '8px',
|
|
10225
|
+
backgroundColor: 'white',
|
|
10226
|
+
maxWidth: '160px',
|
|
10227
|
+
flexShrink: 0
|
|
10228
|
+
} }, { children: [isImageType(mediaType) ? (index$1.jsx("img", { src: attachment.previewUrl, alt: filename, css: {
|
|
10229
|
+
width: '28px',
|
|
10230
|
+
height: '28px',
|
|
10231
|
+
objectFit: 'cover',
|
|
10232
|
+
borderRadius: '4px',
|
|
10233
|
+
flexShrink: 0
|
|
10234
|
+
} })) : (index$1.jsx(TypedFileIcon, { mediaType: mediaType, filename: filename, size: 24 })), index$1.jsxs("div", index$1.__assign({ css: { minWidth: 0 } }, { children: [index$1.jsx("div", index$1.__assign({ css: {
|
|
10235
|
+
fontSize: '11px',
|
|
10236
|
+
color: GRAY_800,
|
|
10237
|
+
whiteSpace: 'nowrap',
|
|
10238
|
+
overflow: 'hidden',
|
|
10239
|
+
textOverflow: 'ellipsis'
|
|
10240
|
+
} }, { children: filename })), failed && (index$1.jsx("div", index$1.__assign({ css: { fontSize: '10px', color: '#dc2626' } }, { children: "Index failed" })))] })), index$1.jsx("button", index$1.__assign({ type: 'button', onClick: onRemove, "aria-label": 'Remove attachment', css: {
|
|
10241
|
+
position: 'absolute',
|
|
10242
|
+
top: '-6px',
|
|
10243
|
+
right: '-6px',
|
|
10244
|
+
width: '16px',
|
|
10245
|
+
height: '16px',
|
|
10246
|
+
display: 'flex',
|
|
10247
|
+
alignItems: 'center',
|
|
10248
|
+
justifyContent: 'center',
|
|
10249
|
+
borderRadius: '50%',
|
|
10250
|
+
border: "1px solid ".concat(GRAY_200),
|
|
10251
|
+
backgroundColor: 'white',
|
|
10252
|
+
color: GRAY_800,
|
|
10253
|
+
cursor: 'pointer',
|
|
10254
|
+
padding: 0,
|
|
10255
|
+
'& svg': { width: '10px', height: '10px' }
|
|
10256
|
+
} }, { children: index$1.jsx(CloseIcon, {}) }))] })));
|
|
10257
|
+
};
|
|
10258
|
+
// Attachment in a sent message: images inline, docs via the page-1
|
|
10259
|
+
// thumbnail (converted docs point at a PDF), click opens the viewer
|
|
10260
|
+
// overlay, in-flight uploads dim under a spinner
|
|
10261
|
+
var MessageAttachment = function (_a) {
|
|
10262
|
+
var mediaType = _a.mediaType, filename = _a.filename, url = _a.url, onOpen = _a.onOpen, _b = _a.inFlight, inFlight = _b === void 0 ? false : _b;
|
|
10263
|
+
// Persisted attachment URLs are time-limited presigns, old history falls
|
|
10264
|
+
// back to the doc icon instead of a broken image
|
|
10265
|
+
var _c = index$1.__read(React.useState(false), 2), imgErrored = _c[0], setImgErrored = _c[1];
|
|
10266
|
+
var content = isImageType(mediaType) ? (!imgErrored ? (index$1.jsx("img", { src: url, alt: filename !== null && filename !== void 0 ? filename : 'attachment', onError: function () { return setImgErrored(true); }, css: {
|
|
10267
|
+
maxWidth: '140px',
|
|
10268
|
+
maxHeight: '112px',
|
|
10269
|
+
borderRadius: '8px',
|
|
10270
|
+
objectFit: 'cover',
|
|
10271
|
+
display: 'block'
|
|
10272
|
+
} })) : (index$1.jsx("div", index$1.__assign({ css: {
|
|
10273
|
+
width: '140px',
|
|
10274
|
+
height: '112px',
|
|
10275
|
+
display: 'flex',
|
|
10276
|
+
alignItems: 'center',
|
|
10277
|
+
justifyContent: 'center',
|
|
10278
|
+
borderRadius: '8px',
|
|
10279
|
+
border: "1px solid ".concat(GRAY_200),
|
|
10280
|
+
backgroundColor: GRAY_100,
|
|
10281
|
+
color: GRAY_400
|
|
10282
|
+
} }, { children: index$1.jsx(DocumentIcon, {}) })))) : (index$1.jsx(LazyPdfThumbnail, { url: url, width: 140, glyph: inFlight ? null : (index$1.jsx(TypedFileIcon, { mediaType: mediaType, filename: filename, size: 28 })) }));
|
|
10283
|
+
return (index$1.jsxs("div", index$1.__assign({ onClick: inFlight ? undefined : onOpen, title: filename, css: { position: 'relative', cursor: inFlight ? 'default' : 'pointer' } }, { children: [index$1.jsx("div", index$1.__assign({ css: { opacity: inFlight ? 0.6 : 1 } }, { children: content })), inFlight && (index$1.jsx("div", index$1.__assign({ css: {
|
|
10284
|
+
position: 'absolute',
|
|
10285
|
+
inset: 0,
|
|
10286
|
+
display: 'flex',
|
|
10287
|
+
alignItems: 'center',
|
|
10288
|
+
justifyContent: 'center'
|
|
10289
|
+
} }, { children: index$1.jsx(SpinnerIcon, {}) })))] })));
|
|
10290
|
+
};
|
|
10291
|
+
// Full-size viewer overlay, builder parity: PDFs via the browser's native
|
|
10292
|
+
// iframe viewer, images inline, filename pill below, dismiss on backdrop
|
|
10293
|
+
// click or Escape
|
|
10294
|
+
var AttachmentPreviewOverlay = function (_a) {
|
|
10295
|
+
var _b, _c;
|
|
10296
|
+
var preview = _a.preview, onClose = _a.onClose;
|
|
10297
|
+
React.useEffect(function () {
|
|
10298
|
+
var onKeyDown = function (e) {
|
|
10299
|
+
if (e.key === 'Escape')
|
|
10300
|
+
onClose();
|
|
10301
|
+
};
|
|
10302
|
+
index$1.featheryDoc().addEventListener('keydown', onKeyDown);
|
|
10303
|
+
return function () { return index$1.featheryDoc().removeEventListener('keydown', onKeyDown); };
|
|
10304
|
+
}, [onClose]);
|
|
10305
|
+
return (index$1.jsxs("div", index$1.__assign({ onClick: onClose, css: {
|
|
10306
|
+
position: 'fixed',
|
|
10307
|
+
inset: 0,
|
|
10308
|
+
zIndex: 1002,
|
|
10309
|
+
display: 'flex',
|
|
10310
|
+
flexDirection: 'column',
|
|
10311
|
+
alignItems: 'center',
|
|
10312
|
+
justifyContent: 'center',
|
|
10313
|
+
backgroundColor: 'rgba(0, 0, 0, 0.6)'
|
|
10314
|
+
} }, { children: [preview.mediaType === 'application/pdf' ? (index$1.jsx("iframe", { src: preview.url, title: (_b = preview.filename) !== null && _b !== void 0 ? _b : 'PDF preview', onClick: function (e) { return e.stopPropagation(); }, css: {
|
|
10315
|
+
height: '85vh',
|
|
10316
|
+
width: '85vw',
|
|
10317
|
+
maxWidth: '1000px',
|
|
10318
|
+
borderRadius: '8px',
|
|
10319
|
+
border: 'none',
|
|
10320
|
+
backgroundColor: 'white'
|
|
10321
|
+
} })) : (index$1.jsx("img", { src: preview.url, alt: (_c = preview.filename) !== null && _c !== void 0 ? _c : 'Image preview', onClick: function (e) { return e.stopPropagation(); }, onError: onClose, css: {
|
|
10322
|
+
maxHeight: '85vh',
|
|
10323
|
+
maxWidth: '85vw',
|
|
10324
|
+
borderRadius: '8px',
|
|
10325
|
+
objectFit: 'contain'
|
|
10326
|
+
} })), preview.filename && (index$1.jsx("span", index$1.__assign({ css: {
|
|
10327
|
+
marginTop: '12px',
|
|
10328
|
+
maxWidth: '85vw',
|
|
10329
|
+
whiteSpace: 'nowrap',
|
|
10330
|
+
overflow: 'hidden',
|
|
10331
|
+
textOverflow: 'ellipsis',
|
|
10332
|
+
borderRadius: '9999px',
|
|
10333
|
+
backgroundColor: 'white',
|
|
10334
|
+
padding: '4px 12px',
|
|
10335
|
+
fontSize: '13px',
|
|
10336
|
+
color: GRAY_800
|
|
10337
|
+
} }, { children: preview.filename })))] })));
|
|
10338
|
+
};
|
|
10339
|
+
|
|
10340
|
+
// Owns the composer's staged-attachment lifecycle, validate + compress on
|
|
10341
|
+
// add, upload, poll until terminal, per-chip abort on remove, full reset on
|
|
10342
|
+
// chat switch (another thread's session can't send them)
|
|
10343
|
+
function useChatAttachments(_a) {
|
|
10344
|
+
var _this = this;
|
|
10345
|
+
var activeChat = _a.activeChat, baseUrl = _a.baseUrl, headers = _a.headers;
|
|
10346
|
+
var _b = index$1.__read(React.useState([]), 2), attachments = _b[0], setAttachments = _b[1];
|
|
10347
|
+
var _c = index$1.__read(React.useState(null), 2), attachmentError = _c[0], setAttachmentError = _c[1];
|
|
10348
|
+
var _d = index$1.__read(React.useState(false), 2), isDragging = _d[0], setIsDragging = _d[1];
|
|
10349
|
+
var attachmentsRef = React.useRef(attachments);
|
|
10350
|
+
attachmentsRef.current = attachments;
|
|
10351
|
+
// AbortController per previewUrl so removing a chip cancels its upload+poll
|
|
10352
|
+
var uploadControllersRef = React.useRef(new Map());
|
|
10353
|
+
var fileInputRef = React.useRef(null);
|
|
10354
|
+
React.useEffect(function () {
|
|
10355
|
+
var controllers = uploadControllersRef.current;
|
|
10356
|
+
return function () {
|
|
10357
|
+
controllers.forEach(function (controller) { return controller.abort(); });
|
|
10358
|
+
controllers.clear();
|
|
10359
|
+
attachmentsRef.current.forEach(function (attachment) {
|
|
10360
|
+
return URL.revokeObjectURL(attachment.previewUrl);
|
|
10361
|
+
});
|
|
10362
|
+
setAttachments([]);
|
|
10363
|
+
setAttachmentError(null);
|
|
10364
|
+
};
|
|
10365
|
+
}, [activeChat]);
|
|
10366
|
+
var uploadAndTrack = React.useCallback(function (previewUrl, file) { return index$1.__awaiter(_this, void 0, void 0, function () {
|
|
10367
|
+
var sessionId, controller, stamp, uploaded, processed, err_1, message;
|
|
10368
|
+
var _a;
|
|
10369
|
+
return index$1.__generator(this, function (_b) {
|
|
10370
|
+
switch (_b.label) {
|
|
10371
|
+
case 0:
|
|
10372
|
+
sessionId = getChatSessionId(activeChat);
|
|
10373
|
+
if (!sessionId)
|
|
10374
|
+
return [2 /*return*/];
|
|
10375
|
+
controller = new AbortController();
|
|
10376
|
+
uploadControllersRef.current.set(previewUrl, controller);
|
|
10377
|
+
stamp = function (updates) {
|
|
10378
|
+
return setAttachments(function (prev) {
|
|
10379
|
+
return prev.map(function (a) {
|
|
10380
|
+
return a.previewUrl === previewUrl ? index$1.__assign(index$1.__assign({}, a), updates) : a;
|
|
10381
|
+
});
|
|
10382
|
+
});
|
|
10383
|
+
};
|
|
10384
|
+
_b.label = 1;
|
|
10385
|
+
case 1:
|
|
10386
|
+
_b.trys.push([1, 4, 5, 6]);
|
|
10387
|
+
return [4 /*yield*/, uploadAttachment(file, baseUrl, headers, sessionId, controller.signal)];
|
|
10388
|
+
case 2:
|
|
10389
|
+
uploaded = _b.sent();
|
|
10390
|
+
if (controller.signal.aborted)
|
|
10391
|
+
return [2 /*return*/];
|
|
10392
|
+
stamp({
|
|
10393
|
+
id: uploaded.id,
|
|
10394
|
+
uploadedUrl: uploaded.url,
|
|
10395
|
+
uploadedFilename: uploaded.filename,
|
|
10396
|
+
uploadedMediaType: uploaded.mediaType,
|
|
10397
|
+
processingStatus: uploaded.processingStatus
|
|
10398
|
+
});
|
|
10399
|
+
if (isTerminalStatus(uploaded.processingStatus))
|
|
10400
|
+
return [2 /*return*/];
|
|
10401
|
+
return [4 /*yield*/, pollAttachmentStatus(uploaded.id, baseUrl, headers, sessionId, controller.signal)];
|
|
10402
|
+
case 3:
|
|
10403
|
+
processed = _b.sent();
|
|
10404
|
+
if (controller.signal.aborted)
|
|
10405
|
+
return [2 /*return*/];
|
|
10406
|
+
stamp({
|
|
10407
|
+
uploadedUrl: (_a = processed.url) !== null && _a !== void 0 ? _a : uploaded.url,
|
|
10408
|
+
uploadedFilename: processed.filename,
|
|
10409
|
+
uploadedMediaType: processed.mediaType,
|
|
10410
|
+
processingStatus: processed.processingStatus
|
|
10411
|
+
});
|
|
10412
|
+
return [3 /*break*/, 6];
|
|
10413
|
+
case 4:
|
|
10414
|
+
err_1 = _b.sent();
|
|
10415
|
+
if (controller.signal.aborted)
|
|
10416
|
+
return [2 /*return*/];
|
|
10417
|
+
message = err_1 instanceof Error ? err_1.message : 'Failed to upload attachment.';
|
|
10418
|
+
if (err_1.status === 403) {
|
|
10419
|
+
// Anonymous fillers can't attach, drop the chip + surface inline
|
|
10420
|
+
setAttachments(function (prev) {
|
|
10421
|
+
return prev.filter(function (a) { return a.previewUrl !== previewUrl; });
|
|
10422
|
+
});
|
|
10423
|
+
URL.revokeObjectURL(previewUrl);
|
|
10424
|
+
setAttachmentError(message);
|
|
10425
|
+
}
|
|
10426
|
+
else {
|
|
10427
|
+
stamp({ processingStatus: 'failed', uploadError: message });
|
|
10428
|
+
}
|
|
10429
|
+
return [3 /*break*/, 6];
|
|
10430
|
+
case 5:
|
|
10431
|
+
uploadControllersRef.current.delete(previewUrl);
|
|
10432
|
+
return [7 /*endfinally*/];
|
|
10433
|
+
case 6: return [2 /*return*/];
|
|
10434
|
+
}
|
|
10435
|
+
});
|
|
10436
|
+
}); }, [activeChat, baseUrl, headers]);
|
|
10437
|
+
var addFiles = React.useCallback(function (files) { return index$1.__awaiter(_this, void 0, void 0, function () {
|
|
10438
|
+
var validFiles, processedFiles, remaining, additions;
|
|
10439
|
+
return index$1.__generator(this, function (_a) {
|
|
10440
|
+
switch (_a.label) {
|
|
10441
|
+
case 0:
|
|
10442
|
+
setAttachmentError(null);
|
|
10443
|
+
validFiles = files.filter(function (file) {
|
|
10444
|
+
return ALLOWED_MEDIA_TYPES.has(file.type) && file.size <= MAX_FILE_SIZE;
|
|
10445
|
+
});
|
|
10446
|
+
if (validFiles.length < files.length) {
|
|
10447
|
+
setAttachmentError('Only images, PDFs, Word documents, Excel spreadsheets, and Powerpoints up to 25MB are supported.');
|
|
10448
|
+
}
|
|
10449
|
+
if (!validFiles.length)
|
|
10450
|
+
return [2 /*return*/];
|
|
10451
|
+
return [4 /*yield*/, Promise.all(validFiles.map(function (file) {
|
|
10452
|
+
return isImageType(file.type) ? compressImage(file) : file;
|
|
10453
|
+
}))];
|
|
10454
|
+
case 1:
|
|
10455
|
+
processedFiles = _a.sent();
|
|
10456
|
+
remaining = Math.max(0, MAX_ATTACHMENTS - attachmentsRef.current.length);
|
|
10457
|
+
if (processedFiles.length > remaining) {
|
|
10458
|
+
setAttachmentError("You can attach up to ".concat(MAX_ATTACHMENTS, " files."));
|
|
10459
|
+
}
|
|
10460
|
+
if (remaining === 0)
|
|
10461
|
+
return [2 /*return*/];
|
|
10462
|
+
additions = processedFiles.slice(0, remaining).map(function (file) { return ({
|
|
10463
|
+
file: file,
|
|
10464
|
+
previewUrl: URL.createObjectURL(file),
|
|
10465
|
+
processingStatus: 'uploading'
|
|
10466
|
+
}); });
|
|
10467
|
+
setAttachments(function (prev) { return index$1.__spreadArray(index$1.__spreadArray([], index$1.__read(prev), false), index$1.__read(additions), false); });
|
|
10468
|
+
additions.forEach(function (a) {
|
|
10469
|
+
uploadAndTrack(a.previewUrl, a.file);
|
|
10470
|
+
});
|
|
10471
|
+
return [2 /*return*/];
|
|
10472
|
+
}
|
|
10473
|
+
});
|
|
10474
|
+
}); }, [uploadAndTrack]);
|
|
10475
|
+
var removeFile = React.useCallback(function (previewUrl) {
|
|
10476
|
+
var controller = uploadControllersRef.current.get(previewUrl);
|
|
10477
|
+
if (controller) {
|
|
10478
|
+
controller.abort();
|
|
10479
|
+
uploadControllersRef.current.delete(previewUrl);
|
|
10480
|
+
}
|
|
10481
|
+
URL.revokeObjectURL(previewUrl);
|
|
10482
|
+
setAttachments(function (prev) { return prev.filter(function (a) { return a.previewUrl !== previewUrl; }); });
|
|
10483
|
+
}, []);
|
|
10484
|
+
// Hands staged attachments to the caller and clears them from the
|
|
10485
|
+
// composer, previewUrls narrows to one batch (late additions stay for the
|
|
10486
|
+
// next message), caller owns revoking the preview URLs
|
|
10487
|
+
var takeAttachments = React.useCallback(function (previewUrls) {
|
|
10488
|
+
var all = attachmentsRef.current;
|
|
10489
|
+
if (!previewUrls) {
|
|
10490
|
+
setAttachments([]);
|
|
10491
|
+
setAttachmentError(null);
|
|
10492
|
+
return all;
|
|
10493
|
+
}
|
|
10494
|
+
var taken = all.filter(function (a) { return previewUrls.includes(a.previewUrl); });
|
|
10495
|
+
setAttachments(all.filter(function (a) { return !previewUrls.includes(a.previewUrl); }));
|
|
10496
|
+
return taken;
|
|
10497
|
+
}, []);
|
|
10498
|
+
var handlePaste = React.useCallback(function (e) {
|
|
10499
|
+
var pastedFiles = Array.from(e.clipboardData.items)
|
|
10500
|
+
.filter(function (item) { return item.kind === 'file' && ALLOWED_MEDIA_TYPES.has(item.type); })
|
|
10501
|
+
.map(function (item) { return item.getAsFile(); })
|
|
10502
|
+
.filter(Boolean);
|
|
10503
|
+
if (pastedFiles.length)
|
|
10504
|
+
addFiles(pastedFiles);
|
|
10505
|
+
}, [addFiles]);
|
|
10506
|
+
var handleDragOver = React.useCallback(function (e) {
|
|
10507
|
+
if (e.dataTransfer.types.includes('Files')) {
|
|
10508
|
+
e.preventDefault();
|
|
10509
|
+
setIsDragging(true);
|
|
10510
|
+
}
|
|
10511
|
+
}, []);
|
|
10512
|
+
var handleDragLeave = React.useCallback(function () { return setIsDragging(false); }, []);
|
|
10513
|
+
var handleDrop = React.useCallback(function (e) {
|
|
10514
|
+
e.preventDefault();
|
|
10515
|
+
setIsDragging(false);
|
|
10516
|
+
if (e.dataTransfer.files.length > 0) {
|
|
10517
|
+
addFiles(Array.from(e.dataTransfer.files));
|
|
10518
|
+
}
|
|
10519
|
+
}, [addFiles]);
|
|
10520
|
+
var attachmentsInFlight = attachments.some(function (a) { return !isTerminalStatus(a.processingStatus); });
|
|
10521
|
+
return {
|
|
10522
|
+
attachments: attachments,
|
|
10523
|
+
attachmentError: attachmentError,
|
|
10524
|
+
attachmentsInFlight: attachmentsInFlight,
|
|
10525
|
+
isDragging: isDragging,
|
|
10526
|
+
fileInputRef: fileInputRef,
|
|
10527
|
+
addFiles: addFiles,
|
|
10528
|
+
removeFile: removeFile,
|
|
10529
|
+
takeAttachments: takeAttachments,
|
|
10530
|
+
handlePaste: handlePaste,
|
|
10531
|
+
handleDragOver: handleDragOver,
|
|
10532
|
+
handleDragLeave: handleDragLeave,
|
|
10533
|
+
handleDrop: handleDrop
|
|
10534
|
+
};
|
|
10535
|
+
}
|
|
9769
10536
|
|
|
9770
10537
|
function base64ToBytes(base64) {
|
|
9771
10538
|
var binary = index$1.featheryWindow().atob(base64);
|
|
@@ -9933,10 +10700,10 @@ var VoiceMic = /** @class */ (function () {
|
|
|
9933
10700
|
switch (_d.label) {
|
|
9934
10701
|
case 0:
|
|
9935
10702
|
_d.trys.push([0, 4, , 5]);
|
|
9936
|
-
return [4 /*yield*/, Promise.resolve().then(function () { return require('./fthry_index.
|
|
10703
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return require('./fthry_index.DPvMA8nx.js'); }).then(function (n) { return n.index; })];
|
|
9937
10704
|
case 1:
|
|
9938
10705
|
_a = _d.sent(), MicVAD_1 = _a.MicVAD, vadUtils_1 = _a.utils;
|
|
9939
|
-
return [4 /*yield*/, Promise.resolve().then(function () { return require('./fthry_logging.
|
|
10706
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return require('./fthry_logging.DnMqEtZk.js'); }).then(function (n) { return n.logging; })];
|
|
9940
10707
|
case 2:
|
|
9941
10708
|
vadLog = (_d.sent()).log;
|
|
9942
10709
|
vadLog.debug = function () { return undefined; };
|
|
@@ -10202,43 +10969,6 @@ function useAssistantVoice(_a) {
|
|
|
10202
10969
|
};
|
|
10203
10970
|
}
|
|
10204
10971
|
|
|
10205
|
-
var DEFAULT_CHAT_COLOR = '#6b7280';
|
|
10206
|
-
var GRAY_50 = '#f9fafb';
|
|
10207
|
-
var GRAY_100 = '#f3f4f6';
|
|
10208
|
-
var GRAY_200 = '#e5e7eb';
|
|
10209
|
-
var GRAY_400 = '#9ca3af';
|
|
10210
|
-
var GRAY_500 = '#6b7280';
|
|
10211
|
-
var GRAY_800 = '#1f2937';
|
|
10212
|
-
var RED_500 = '#ef4444';
|
|
10213
|
-
// Generate lighter/darker variants from hex color
|
|
10214
|
-
var adjustColor = function (hex, percent) {
|
|
10215
|
-
var num = parseInt(hex.replace('#', ''), 16);
|
|
10216
|
-
var r = Math.min(255, Math.max(0, (num >> 16) + Math.round(2.55 * percent)));
|
|
10217
|
-
var g = Math.min(255, Math.max(0, ((num >> 8) & 0x00ff) + Math.round(2.55 * percent)));
|
|
10218
|
-
var b = Math.min(255, Math.max(0, (num & 0x0000ff) + Math.round(2.55 * percent)));
|
|
10219
|
-
return "#".concat(((r << 16) | (g << 8) | b).toString(16).padStart(6, '0'));
|
|
10220
|
-
};
|
|
10221
|
-
var blendToWhite = function (hex, percent) {
|
|
10222
|
-
var num = parseInt(hex.replace('#', ''), 16);
|
|
10223
|
-
var r = (num >> 16) & 0xff;
|
|
10224
|
-
var g = (num >> 8) & 0xff;
|
|
10225
|
-
var b = num & 0xff;
|
|
10226
|
-
var blend = percent / 100;
|
|
10227
|
-
var newR = Math.round(r + (255 - r) * blend);
|
|
10228
|
-
var newG = Math.round(g + (255 - g) * blend);
|
|
10229
|
-
var newB = Math.round(b + (255 - b) * blend);
|
|
10230
|
-
return "#".concat(((newR << 16) | (newG << 8) | newB)
|
|
10231
|
-
.toString(16)
|
|
10232
|
-
.padStart(6, '0'));
|
|
10233
|
-
};
|
|
10234
|
-
// Compute all color variants from primary
|
|
10235
|
-
var getChatColors = function (primary) { return ({
|
|
10236
|
-
primary: primary,
|
|
10237
|
-
hover: adjustColor(primary, -15),
|
|
10238
|
-
disabled: adjustColor(primary, 30),
|
|
10239
|
-
light: blendToWhite(primary, 90) // Light: assistant bubbles
|
|
10240
|
-
}); };
|
|
10241
|
-
|
|
10242
10972
|
var TOOL_LABELS = {
|
|
10243
10973
|
searchWeb: {
|
|
10244
10974
|
running: 'Searching the web...',
|
|
@@ -10277,6 +11007,10 @@ var TOOL_LABELS = {
|
|
|
10277
11007
|
running: 'Running table action...',
|
|
10278
11008
|
done: 'Ran the table action'
|
|
10279
11009
|
},
|
|
11010
|
+
queryAttachmentSemantic: {
|
|
11011
|
+
running: 'Reading attachments...',
|
|
11012
|
+
done: 'Read the attachments'
|
|
11013
|
+
},
|
|
10280
11014
|
getPanelSnapshot: {
|
|
10281
11015
|
running: 'Reading the form...',
|
|
10282
11016
|
done: 'Reviewed the form'
|
|
@@ -10551,7 +11285,8 @@ var ToolChunkRow = function (_a) {
|
|
|
10551
11285
|
} }))] })), expandable && expanded && (index$1.jsx(ToolRowDetail, { row: row, linkColor: linkColor }))] })));
|
|
10552
11286
|
};
|
|
10553
11287
|
// Mimics the chunk header so a real tool arriving doesn't reflow the layout
|
|
10554
|
-
var ToolChunkPlaceholder = function () {
|
|
11288
|
+
var ToolChunkPlaceholder = function (_a) {
|
|
11289
|
+
var _b = _a.label, label = _b === void 0 ? 'Working on it...' : _b;
|
|
10555
11290
|
return (index$1.jsx("div", index$1.__assign({ css: {
|
|
10556
11291
|
display: 'flex',
|
|
10557
11292
|
flexDirection: 'column',
|
|
@@ -10569,7 +11304,7 @@ var ToolChunkPlaceholder = function () {
|
|
|
10569
11304
|
color: GRAY_500,
|
|
10570
11305
|
fontSize: '13px',
|
|
10571
11306
|
alignSelf: 'flex-start'
|
|
10572
|
-
} }, { children: index$1.jsx("span", index$1.__assign({ css: shimmerCss }, { children:
|
|
11307
|
+
} }, { children: index$1.jsx("span", index$1.__assign({ css: shimmerCss }, { children: label })) })) })));
|
|
10573
11308
|
};
|
|
10574
11309
|
|
|
10575
11310
|
/**
|
|
@@ -51740,14 +52475,14 @@ ${e}</tr>
|
|
|
51740
52475
|
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+T(n.message+"",true)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}};var L$1=new D;function g(u,e){return L$1.parse(u,e)}g.options=g.setOptions=function(u){return L$1.setOptions(u),g.defaults=L$1.defaults,G(g.defaults),g};g.getDefaults=M;g.defaults=O;g.use=function(...u){return L$1.use(...u),g.defaults=L$1.defaults,G(g.defaults),g};g.walkTokens=function(u,e){return L$1.walkTokens(u,e)};g.parseInline=L$1.parseInline;g.Parser=b;g.parser=b.parse;g.Renderer=y$1;g.TextRenderer=$;g.Lexer=x;g.lexer=x.lex;g.Tokenizer=w;g.Hooks=P;g.parse=g;g.options;g.setOptions;g.use;g.walkTokens;g.parseInline;b.parse;x.lex;
|
|
51741
52476
|
|
|
51742
52477
|
var En=300,Hn="300px",Dn=500;function Lt(e={}){let{immediate:t=false,debounceDelay:o=En,rootMargin:n=Hn,idleTimeout:r=Dn}=e,[s,a]=React.useState(false),l=React.useRef(null),i=React.useRef(null),c=React.useRef(null),d=React.useMemo(()=>p=>{let g=Date.now();return window.setTimeout(()=>{p({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-g))});},1)},[]),u=React.useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(p,g)=>window.requestIdleCallback(p,g):d,[d]),m=React.useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?p=>window.cancelIdleCallback(p):p=>{clearTimeout(p);},[]);return React.useEffect(()=>{if(t){a(true);return}let p=l.current;if(!p)return;i.current&&(clearTimeout(i.current),i.current=null),c.current&&(m(c.current),c.current=null);let g=()=>{i.current&&(clearTimeout(i.current),i.current=null),c.current&&(m(c.current),c.current=null);},h=x=>{c.current=u(w=>{w.timeRemaining()>0||w.didTimeout?(a(true),x.disconnect()):c.current=u(()=>{a(true),x.disconnect();},{timeout:r/2});},{timeout:r});},b=x=>{g(),i.current=window.setTimeout(()=>{var I,H;let w=x.takeRecords();(w.length===0||(H=(I=w.at(-1))==null?void 0:I.isIntersecting)!=null&&H)&&h(x);},o);},f=(x,w)=>{x.isIntersecting?b(w):g();},T=new IntersectionObserver(x=>{for(let w of x)f(w,T);},{rootMargin:n,threshold:0});return T.observe(p),()=>{i.current&&clearTimeout(i.current),c.current&&m(c.current),T.disconnect();}},[t,o,n,r,m,u]),{shouldRender:s,containerRef:l}}var Rt=/\s/,On=/^\s+$/,Vn=new Set(["code","pre","svg","math","annotation"]),jn=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",Fn=e=>e.some(t=>jn(t)&&Vn.has(t.tagName)),zn=e=>{let t=[],o="",n=false;for(let r of e){let s=Rt.test(r);s!==n&&o&&(t.push(o),o=""),o+=r,n=s;}return o&&t.push(o),t},_n=e=>{let t=[],o="";for(let n of e)Rt.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},qn=(e,t,o,n,r)=>({type:"element",tagName:"span",properties:{"data-sd-animate":true,style:r?`--sd-animation:sd-${t};--sd-duration:0ms;--sd-easing:${n}`:`--sd-animation:sd-${t};--sd-duration:${o}ms;--sd-easing:${n}`},children:[{type:"text",value:e}]}),$n=(e,t,o,n,r)=>{let s=t.at(-1);if(!(s&&"children"in s))return;if(Fn(t))return SKIP;let a=s,l=a.children.indexOf(e);if(l===-1)return;let i=e.value;if(!i.trim()){r.count+=i.length;return}let c=o.sep==="char"?_n(i):zn(i),d=n.prevContentLength,u=c.map(m=>{let p=r.count;if(r.count+=m.length,On.test(m))return {type:"text",value:m};let g=d>0&&p<d;return qn(m,o.animation,o.duration,o.easing,g)});return a.children.splice(l,1,...u),l+u.length},Wn=0;function be(e){var s,a,l,i;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word"},o={prevContentLength:0,lastRenderCharCount:0},n=Wn++,r=()=>c=>{let d={count:0};visitParents(c,"text",(u,m)=>$n(u,m,t,o,d)),o.lastRenderCharCount=d.count,o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setPrevContentLength(c){o.prevContentLength=c;},getLastRenderCharCount(){let c=o.lastRenderCharCount;return o.lastRenderCharCount=0,c}}}be();var Qe=React.createContext(false),et=()=>React.useContext(Qe);var he=(...e)=>twMerge(clsx.clsx(e)),Jn=(e,t)=>{if(!e||!t)return t;let o=`${e}:`;return t.split(/\s+/).filter(Boolean).map(n=>n.startsWith(o)?n:`${e}:${n}`).join(" ")},Ht=e=>e?(...t)=>Jn(e,twMerge(clsx.clsx(t))):he,J=(e,t,o)=>{let n=typeof t=="string"?new Blob([t],{type:o}):t,r=URL.createObjectURL(n),s=document.createElement("a");s.href=r,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r);};var Se=React.createContext(he),y=()=>React.useContext(Se);var Yn=he("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),Qn=e=>{let t={};for(let o of e.split(";")){let n=o.indexOf(":");if(n>0){let r=o.slice(0,n).trim(),s=o.slice(n+1).trim();r&&s&&(t[r]=s);}}return t},Bt=React.memo(({children:e,result:t,language:o,className:n,startLine:r,...s})=>{let a=y(),l=React.useMemo(()=>a(Yn),[a]),i=React.useMemo(()=>{let c={};return t.bg&&(c["--sdm-bg"]=t.bg),t.fg&&(c["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(c,Qn(t.rootStyle)),c},[t.bg,t.fg,t.rootStyle]);return ReactJSXRuntime.jsx("div",{className:a(n,"overflow-hidden rounded-md border border-border bg-background p-4 text-sm"),"data-language":o,"data-streamdown":"code-block-body",...s,children:ReactJSXRuntime.jsx("pre",{className:a(n,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:i,children:ReactJSXRuntime.jsx("code",{className:a("[counter-increment:line_0] [counter-reset:line]"),style:r&&r>1?{counterReset:`line ${r-1}`}:void 0,children:t.tokens.map((c,d)=>ReactJSXRuntime.jsx("span",{className:l,children:c.length===0||c.length===1&&c[0].content===""?`
|
|
51743
|
-
`:c.map((u,m)=>{let p={},g=!!u.bgColor;if(u.color&&(p["--sdm-c"]=u.color),u.bgColor&&(p["--sdm-tbg"]=u.bgColor),u.htmlStyle)for(let[h,b]of Object.entries(u.htmlStyle))h==="color"?p["--sdm-c"]=b:h==="background-color"?(p["--sdm-tbg"]=b,g=true):p[h]=b;return ReactJSXRuntime.jsx("span",{className:a("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",g&&"bg-[var(--sdm-tbg)]",g&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:p,...u.htmlAttrs,children:u.content},m)})},d))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine);var tt=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let s=y();return ReactJSXRuntime.jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var ot=React.createContext({code:""}),Ee=()=>React.useContext(ot);var nt=({language:e})=>{let t=y();return ReactJSXRuntime.jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:ReactJSXRuntime.jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var sr=/\n+$/,ar=React.lazy(()=>Promise.resolve().then(function () { return require('./fthry_highlighted-body-TPN3WLV5.
|
|
52478
|
+
`:c.map((u,m)=>{let p={},g=!!u.bgColor;if(u.color&&(p["--sdm-c"]=u.color),u.bgColor&&(p["--sdm-tbg"]=u.bgColor),u.htmlStyle)for(let[h,b]of Object.entries(u.htmlStyle))h==="color"?p["--sdm-c"]=b:h==="background-color"?(p["--sdm-tbg"]=b,g=true):p[h]=b;return ReactJSXRuntime.jsx("span",{className:a("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",g&&"bg-[var(--sdm-tbg)]",g&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:p,...u.htmlAttrs,children:u.content},m)})},d))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine);var tt=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let s=y();return ReactJSXRuntime.jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var ot=React.createContext({code:""}),Ee=()=>React.useContext(ot);var nt=({language:e})=>{let t=y();return ReactJSXRuntime.jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:ReactJSXRuntime.jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var sr=/\n+$/,ar=React.lazy(()=>Promise.resolve().then(function () { return require('./fthry_highlighted-body-TPN3WLV5.BzjtpXVW.js'); }).then(e=>({default:e.HighlightedCodeBlockBody}))),rt=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,...a})=>{let l=y(),i=React.useMemo(()=>e.replace(sr,""),[e]),c=React.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:i.split(`
|
|
51744
52479
|
`).map(d=>[{content:d,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[i]);return ReactJSXRuntime.jsx(ot.Provider,{value:{code:e},children:ReactJSXRuntime.jsxs(tt,{isIncomplete:r,language:t,children:[ReactJSXRuntime.jsx(nt,{language:t}),n?ReactJSXRuntime.jsx("div",{className:l("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:ReactJSXRuntime.jsx("div",{className:l("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:n})}):null,ReactJSXRuntime.jsx(React.Suspense,{fallback:ReactJSXRuntime.jsx(Bt,{className:o,language:t,result:c,startLine:s,...a}),children:ReactJSXRuntime.jsx(ar,{className:o,code:i,language:t,raw:c,startLine:s,...a})})]})})};var Vt=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),jt=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),Ft=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),zt=e=>ReactJSXRuntime.jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[ReactJSXRuntime.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),_t=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),qt=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),$t=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),Wt=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),Zt=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Xt=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var we={CheckIcon:Vt,CopyIcon:jt,DownloadIcon:Ft,ExternalLinkIcon:Wt,Loader2Icon:zt,Maximize2Icon:_t,RotateCcwIcon:qt,XIcon:$t,ZoomInIcon:Zt,ZoomOutIcon:Xt},Kt=React.createContext(we),mr=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let o=Object.keys(e),n=Object.keys(t);return o.length!==n.length?false:o.every(r=>e[r]===t[r])},st=({icons:e,children:t})=>{let o=React.useRef(e),n=React.useRef(e?{...we,...e}:we);mr(o.current,e)||(o.current=e,n.current=e?{...we,...e}:we);let r=n.current;return ReactJSXRuntime.jsx(Kt.Provider,{value:r,children:t})},L=()=>React.useContext(Kt);var He={copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},De=React.createContext(He),B=()=>React.useContext(De);var Be=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let l=y(),[i,c]=React.useState(false),d=React.useRef(0),{code:u}=Ee(),{isAnimating:m}=React.useContext(R),p=B(),g=s!=null?s:u,h=async()=>{var T;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(g),c(!0),e==null||e(),d.current=window.setTimeout(()=>c(!1),o));}catch(x){t==null||t(x);}};React.useEffect(()=>()=>{window.clearTimeout(d.current);},[]);let b=L(),f=i?b.CheckIcon:b.CopyIcon;return ReactJSXRuntime.jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:m,onClick:h,title:p.copyCode,type:"button",...a,children:n!=null?n:ReactJSXRuntime.jsx(f,{size:14})})};var Gt={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},at=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let l=y(),{code:i}=Ee(),{isAnimating:c}=React.useContext(R),d=B(),u=L(),m=s!=null?s:i,g=`file.${o&&o in Gt?Gt[o]:"txt"}`,h="text/plain",b=()=>{try{J(g,m,h),e==null||e();}catch(f){t==null||t(f);}};return ReactJSXRuntime.jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:c,onClick:b,title:d.downloadFile,type:"button",...a,children:n!=null?n:ReactJSXRuntime.jsx(u.DownloadIcon,{size:14})})};var Ae=()=>{let{Loader2Icon:e}=L(),t=y();return ReactJSXRuntime.jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[ReactJSXRuntime.jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),ReactJSXRuntime.jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:ReactJSXRuntime.jsx(e,{className:t("size-4 animate-spin")})})]})};var xr=/\.[^/.]+$/,to=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,...a})=>{let{DownloadIcon:l}=L(),i=y(),c=React.useRef(null),[d,u]=React.useState(false),[m,p]=React.useState(false),g=B(),h=a.width!=null||a.height!=null,b=(d||h)&&!m,f=m&&!h;React.useEffect(()=>{let k=c.current;if(k!=null&&k.complete){let I=k.naturalWidth>0;u(I),p(!I);}},[]);let T=React.useCallback(k=>{u(true),p(false),r==null||r(k);},[r]),x=React.useCallback(k=>{u(false),p(true),s==null||s(k);},[s]),w=async()=>{if(o)try{let I=await(await fetch(o)).blob(),S=new URL(o,window.location.origin).pathname.split("/").pop()||"",F=S.split(".").pop(),z=S.includes(".")&&F!==void 0&&F.length<=4,q="";if(z)q=S;else {let A=I.type,K="png";A.includes("jpeg")||A.includes("jpg")?K="jpg":A.includes("png")?K="png":A.includes("svg")?K="svg":A.includes("gif")?K="gif":A.includes("webp")&&(K="webp"),q=`${(n||S||"image").replace(xr,"")}.${K}`;}J(q,I,I.type);}catch(k){window.open(o,"_blank");}};return o?ReactJSXRuntime.jsxs("div",{className:i("group relative my-4 inline-block"),"data-streamdown":"image-wrapper",children:[ReactJSXRuntime.jsx("img",{alt:n,className:i("max-w-full rounded-lg",f&&"hidden",t),"data-streamdown":"image",onError:x,onLoad:T,ref:c,src:o,...a}),f&&ReactJSXRuntime.jsx("span",{className:i("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:g.imageNotAvailable}),ReactJSXRuntime.jsx("div",{className:i("pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block")}),b&&ReactJSXRuntime.jsx("button",{className:i("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:w,title:g.downloadImage,type:"button",children:ReactJSXRuntime.jsx(l,{size:14})})]}):null};var ke=0,le=()=>{ke+=1,ke===1&&(document.body.style.overflow="hidden");},ce=()=>{ke=Math.max(0,ke-1),ke===0&&(document.body.style.overflow="");};var ro=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=L(),i=y(),[c,d]=React.useState(false),u=B(),m=React.useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(g){}},[e]),p=React.useCallback(()=>{n(),o();},[n,o]);return React.useEffect(()=>{if(t){le();let g=h=>{h.key==="Escape"&&o();};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),ce();}}},[t,o]),t?ReactJSXRuntime.jsx("div",{className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:o,onKeyDown:g=>{g.key==="Escape"&&o();},role:"button",tabIndex:0,children:ReactJSXRuntime.jsxs("div",{className:i("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:[ReactJSXRuntime.jsx("button",{className:i("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:o,title:u.close,type:"button",children:ReactJSXRuntime.jsx(l,{size:16})}),ReactJSXRuntime.jsxs("div",{className:i("flex flex-col gap-2"),children:[ReactJSXRuntime.jsxs("div",{className:i("flex items-center gap-2 font-semibold text-lg"),children:[ReactJSXRuntime.jsx(a,{size:20}),ReactJSXRuntime.jsx("span",{children:u.openExternalLink})]}),ReactJSXRuntime.jsx("p",{className:i("text-muted-foreground text-sm"),children:u.externalLinkWarning})]}),ReactJSXRuntime.jsx("div",{className:i("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),ReactJSXRuntime.jsxs("div",{className:i("flex gap-2"),children:[ReactJSXRuntime.jsx("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:m,type:"button",children:c?ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx(r,{size:14}),ReactJSXRuntime.jsx("span",{children:u.copied})]}):ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx(s,{size:14}),ReactJSXRuntime.jsx("span",{children:u.copyLink})]})}),ReactJSXRuntime.jsxs("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:p,type:"button",children:[ReactJSXRuntime.jsx(a,{size:14}),ReactJSXRuntime.jsx("span",{children:u.openLink})]})]})]})}):null};var Oe=React.createContext(null),lt=()=>React.useContext(Oe),Mi=()=>{var t;let e=lt();return (t=e==null?void 0:e.code)!=null?t:null},de=()=>{var t;let e=lt();return (t=e==null?void 0:e.mermaid)!=null?t:null};var so=e=>{var o;let t=lt();return t!=null&&t.renderers&&e&&(o=t.renderers.find(n=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?o:null};var ao=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),l=new Image;l.crossOrigin="anonymous",l.onload=()=>{let i=document.createElement("canvas"),c=l.width*o,d=l.height*o;i.width=c,i.height=d;let u=i.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(l,0,0,c,d),i.toBlob(m=>{if(!m){s(new Error("Failed to create PNG blob"));return}r(m);},"image/png");},l.onerror=()=>s(new Error("Failed to load SVG image")),l.src=a;})};var lo=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=y(),[l,i]=React.useState(false),c=React.useRef(null),{isAnimating:d}=React.useContext(R),u=L(),m=de(),p=B(),g=async h=>{try{if(h==="mmd"){J("diagram.mmd",e,"text/plain"),i(!1),n==null||n(h);return}if(!m){s==null||s(new Error("Mermaid plugin not available"));return}let b=m.getMermaid(r),f=e.split("").reduce((w,k)=>(w<<5)-w+k.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(f)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:x}=await b.render(T,e);if(!x){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(h==="svg"){J("diagram.svg",x,"image/svg+xml"),i(!1),n==null||n(h);return}if(h==="png"){let w=await ao(x);J("diagram.png",w,"image/png"),n==null||n(h),i(!1);return}}catch(b){s==null||s(b);}};return React.useEffect(()=>{let h=b=>{let f=b.composedPath();c.current&&!f.includes(c.current)&&i(false);};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[]),ReactJSXRuntime.jsxs("div",{className:a("relative"),ref:c,children:[ReactJSXRuntime.jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:d,onClick:()=>i(!l),title:p.downloadDiagram,type:"button",children:t!=null?t:ReactJSXRuntime.jsx(u.DownloadIcon,{size:14})}),l?ReactJSXRuntime.jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[ReactJSXRuntime.jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("svg"),title:p.downloadDiagramAsSvg,type:"button",children:p.mermaidFormatSvg}),ReactJSXRuntime.jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("png"),title:p.downloadDiagramAsPng,type:"button",children:p.mermaidFormatPng}),ReactJSXRuntime.jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("mmd"),title:p.downloadDiagramAsMmd,type:"button",children:p.mermaidFormatMmd})]}):null]})};var po=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=L(),i=y(),[c,d]=React.useState(false),{isAnimating:u,controls:m}=React.useContext(R),p=B(),g=(()=>{if(typeof m=="boolean")return m;let b=m.mermaid;return b===false?false:b===true||b===void 0?true:b.panZoom!==false})(),h=()=>{d(!c);};return React.useEffect(()=>{if(c){le();let b=f=>{f.key==="Escape"&&d(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),ce();}}},[c]),React.useEffect(()=>{c?o==null||o():n&&n();},[c,o,n]),ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:u,onClick:h,title:p.viewFullscreen,type:"button",...s,children:ReactJSXRuntime.jsx(a,{size:14})}),c?ReactDOM.createPortal(ReactJSXRuntime.jsxs("div",{className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),onClick:h,onKeyDown:b=>{b.key==="Escape"&&h();},role:"button",tabIndex:0,children:[ReactJSXRuntime.jsx("button",{className:i("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:p.exitFullscreen,type:"button",children:ReactJSXRuntime.jsx(l,{size:20})}),ReactJSXRuntime.jsx("div",{className:i("flex size-full items-center justify-center p-4"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:ReactJSXRuntime.jsx(uo,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:g})})]}),document.body):null]})};var ue=e=>{var s,a;let t=[],o=[],n=e.querySelectorAll("thead th");for(let l of n)t.push(((s=l.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let l of r){let i=[],c=l.querySelectorAll("td");for(let d of c)i.push(((a=d.textContent)==null?void 0:a.trim())||"");o.push(i);}return {headers:t,rows:o}},oe=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false,c=false;for(let d of l){if(d==='"'){i=true,c=true;break}(d===","||d===`
|
|
51745
52480
|
`)&&(i=true);}return i?c?`"${l.replace(/"/g,'""')}"`:`"${l}"`:l},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(","),a+=1);for(let l of o)s[a]=l.map(n).join(","),a+=1;return s.join(`
|
|
51746
52481
|
`)},ct=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false;for(let d of l)if(d===" "||d===`
|
|
51747
52482
|
`||d==="\r"){i=true;break}if(!i)return l;let c=[];for(let d of l)d===" "?c.push("\\t"):d===`
|
|
51748
52483
|
`?c.push("\\n"):d==="\r"?c.push("\\r"):c.push(d);return c.join("")},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(" "),a+=1);for(let l of o)s[a]=l.map(n).join(" "),a+=1;return s.join(`
|
|
51749
52484
|
`)},Ve=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):o.push(n);return o.join("")},ne=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,s=t.map(l=>Ve(l));n[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let l=0;l<t.length;l+=1)a[l]="---";n[r]=`| ${a.join(" | ")} |`,r+=1;for(let l of o)if(l.length<t.length){let i=new Array(t.length);for(let c=0;c<t.length;c+=1)i[c]=c<l.length?Ve(l[c]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(c=>Ve(c));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
|
|
51750
|
-
`)};var Te=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=y(),[a,l]=React.useState(false),[i,c]=React.useState(false),d=React.useRef(null),u=React.useRef(0),{isAnimating:m}=React.useContext(R),p=B(),g=async f=>{var T,x;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.write)){n==null||n(new Error("Clipboard API not available"));return}try{let w=(x=d.current)==null?void 0:x.closest('[data-streamdown="table-wrapper"]'),k=w==null?void 0:w.querySelector("table");if(!k){n==null||n(new Error("Table not found"));return}let I=ue(k),F=({csv:oe,tsv:ct,md:ne}[f]||ne)(I),z=new ClipboardItem({"text/plain":new Blob([F],{type:"text/plain"}),"text/html":new Blob([k.outerHTML],{type:"text/html"})});await navigator.clipboard.write([z]),c(!0),l(!1),o==null||o(f),u.current=window.setTimeout(()=>c(!1),r);}catch(w){n==null||n(w);}};React.useEffect(()=>{let f=T=>{let x=T.composedPath();d.current&&!x.includes(d.current)&&l(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(u.current);}},[]);let h=L(),b=i?h.CheckIcon:h.CopyIcon;return ReactJSXRuntime.jsxs("div",{className:s("relative"),ref:d,children:[ReactJSXRuntime.jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>l(!a),title:p.copyTable,type:"button",children:e!=null?e:ReactJSXRuntime.jsx(b,{height:14,width:14})}),a?ReactJSXRuntime.jsxs("div",{className:s("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[ReactJSXRuntime.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("md"),title:p.copyTableAsMarkdown,type:"button",children:p.tableFormatMarkdown}),ReactJSXRuntime.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("csv"),title:p.copyTableAsCsv,type:"button",children:p.tableFormatCsv}),ReactJSXRuntime.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("tsv"),title:p.copyTableAsTsv,type:"button",children:p.tableFormatTsv})]}):null]})};var Pe=({children:e,className:t,onDownload:o,onError:n})=>{let r=y(),[s,a]=React.useState(false),l=React.useRef(null),{isAnimating:i}=React.useContext(R),c=B(),d=L(),u=m=>{var p;try{let g=(p=l.current)==null?void 0:p.closest('[data-streamdown="table-wrapper"]'),h=g==null?void 0:g.querySelector("table");if(!h){n==null||n(new Error("Table not found"));return}let b=ue(h),f=m==="csv"?oe(b):ne(b);J(`table.${m==="csv"?"csv":"md"}`,f,m==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(m);}catch(g){n==null||n(g);}};return React.useEffect(()=>{let m=p=>{let g=p.composedPath();l.current&&!g.includes(l.current)&&a(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),ReactJSXRuntime.jsxs("div",{className:r("relative"),ref:l,children:[ReactJSXRuntime.jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>a(!s),title:c.downloadTable,type:"button",children:e!=null?e:ReactJSXRuntime.jsx(d.DownloadIcon,{size:14})}),s?ReactJSXRuntime.jsxs("div",{className:r("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[ReactJSXRuntime.jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>u("csv"),title:c.downloadTableAsCsv,type:"button",children:c.tableFormatCsv}),ReactJSXRuntime.jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>u("markdown"),title:c.downloadTableAsMarkdown,type:"button",children:c.tableFormatMarkdown})]}):null]})};var wo=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=L(),a=y(),[l,i]=React.useState(false),{isAnimating:c}=React.useContext(R),d=B(),u=()=>{i(true);},m=()=>{i(false);};return React.useEffect(()=>{if(l){le();let p=g=>{g.key==="Escape"&&i(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),ce();}}},[l]),ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:u,title:d.viewFullscreen,type:"button",children:ReactJSXRuntime.jsx(r,{size:14})}),l?ReactDOM.createPortal(ReactJSXRuntime.jsx("div",{"aria-label":d.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:m,onKeyDown:p=>{p.key==="Escape"&&m();},role:"dialog",children:ReactJSXRuntime.jsxs("div",{className:a("flex h-full flex-col"),onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:[ReactJSXRuntime.jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?ReactJSXRuntime.jsx(Te,{}):null,n?ReactJSXRuntime.jsx(Pe,{}):null,ReactJSXRuntime.jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:m,title:d.exitFullscreen,type:"button",children:ReactJSXRuntime.jsx(s,{size:20})})]}),ReactJSXRuntime.jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:ReactJSXRuntime.jsx("table",{className:a("w-full border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var ko=({children:e,className:t,showControls:o,showCopy:n=true,showDownload:r=true,showFullscreen:s=true,...a})=>{let l=y(),i=o&&n,c=o&&r,d=o&&s,u=i||c||d;return ReactJSXRuntime.jsxs("div",{className:l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[u?ReactJSXRuntime.jsxs("div",{className:l("flex items-center justify-end gap-1"),children:[i?ReactJSXRuntime.jsx(Te,{}):null,c?ReactJSXRuntime.jsx(Pe,{}):null,d?ReactJSXRuntime.jsx(wo,{showCopy:i,showDownload:c,children:e}):null]}):null,ReactJSXRuntime.jsx("div",{className:l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),children:ReactJSXRuntime.jsx("table",{className:l("w-full divide-y divide-border",t),"data-streamdown":"table",...a,children:e})})]})};var Gr=/startLine=(\d+)/,Yr=React.lazy(()=>Promise.resolve().then(function () { return require('./fthry_mermaid-O7DHMXV3.BUbH9Bc_.js'); }).then(e=>({default:e.Mermaid}))),Qr=/language-([^\s]+)/;function _e(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let o=e.position.start,n=t.position.start,r=e.position.end,s=t.position.end;return (o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function E(e,t){return e.className===t.className&&_e(e.node,t.node)}var pt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ut=(e,t)=>{if(typeof e=="boolean")return e;let o=e.table;return o===false?false:o===true||o===void 0?true:o[t]!==false},xo=(e,t)=>{if(typeof e=="boolean")return e;let o=e.code;return o===false?false:o===true||o===void 0?true:o[t]!==false},je=(e,t)=>{if(typeof e=="boolean")return e;let o=e.mermaid;return o===false?false:o===true||o===void 0?true:o[t]!==false},gt=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e})},(e,t)=>E(e,t));gt.displayName="MarkdownOl";var To=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("li",{className:r("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e})},(e,t)=>e.className===t.className&&_e(e.node,t.node));To.displayName="MarkdownLi";var Po=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("ul",{className:r("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e})},(e,t)=>E(e,t));Po.displayName="MarkdownUl";var Mo=React.memo(({className:e,node:t,...o})=>{let n=y();return ReactJSXRuntime.jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>E(e,t));Mo.displayName="MarkdownHr";var Io=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>E(e,t));Io.displayName="MarkdownStrong";var es=({children:e,className:t,href:o,node:n,...r})=>{let s=y(),{linkSafety:a}=React.useContext(R),[l,i]=React.useState(false),c=o==="streamdown:incomplete-link",d=React.useCallback(async g=>{if(!(!(a!=null&&a.enabled&&o)||c)){if(g.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[a,o,c]),u=React.useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),m=React.useCallback(()=>{i(false);},[]),p={url:o!=null?o:"",isOpen:l,onClose:m,onConfirm:u};return a!=null&&a.enabled&&o?ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",onClick:d,type:"button",children:e}),a.renderModal?a.renderModal(p):ReactJSXRuntime.jsx(ro,{...p})]}):ReactJSXRuntime.jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},No=React.memo(es,(e,t)=>E(e,t)&&e.href===t.href);No.displayName="MarkdownA";var Lo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>E(e,t));Lo.displayName="MarkdownH1";var Ro=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>E(e,t));Ro.displayName="MarkdownH2";var So=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>E(e,t));So.displayName="MarkdownH3";var Eo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>E(e,t));Eo.displayName="MarkdownH4";var Ho=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>E(e,t));Ho.displayName="MarkdownH5";var Do=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>E(e,t));Do.displayName="MarkdownH6";var Bo=React.memo(({children:e,className:t,node:o,...n})=>{let{controls:r}=React.useContext(R),s=pt(r,"table"),a=ut(r,"copy"),l=ut(r,"download"),i=ut(r,"fullscreen");return ReactJSXRuntime.jsx(ko,{className:t,showControls:s,showCopy:a,showDownload:l,showFullscreen:i,...n,children:e})},(e,t)=>E(e,t));Bo.displayName="MarkdownTable";var Ao=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>E(e,t));Ao.displayName="MarkdownThead";var Oo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>E(e,t));Oo.displayName="MarkdownTbody";var Vo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>E(e,t));Vo.displayName="MarkdownTr";var jo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>E(e,t));jo.displayName="MarkdownTh";var Fo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>E(e,t));Fo.displayName="MarkdownTd";var zo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e})},(e,t)=>E(e,t));zo.displayName="MarkdownBlockquote";var _o=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>E(e,t));_o.displayName="MarkdownSup";var qo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>E(e,t));qo.displayName="MarkdownSub";var $o=React.memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=i=>{var m,p;if(!React.isValidElement(i))return false;let c=Array.isArray(i.props.children)?i.props.children:[i.props.children],d=false,u=false;for(let g of c)if(g){if(typeof g=="string")g.trim()!==""&&(d=true);else if(React.isValidElement(g))if(((m=g.props)==null?void 0:m["data-footnote-backref"])!==void 0)u=true;else {let h=Array.isArray(g.props.children)?g.props.children:[g.props.children];for(let b of h){if(typeof b=="string"&&b.trim()!==""){d=true;break}if(React.isValidElement(b)&&((p=b.props)==null?void 0:p["data-footnote-backref"])===void 0){d=true;break}}}}return u&&!d},a=Array.isArray(e)?e.map(i=>{if(!React.isValidElement(i))return i;if(i.type===gt){let d=(Array.isArray(i.props.children)?i.props.children:[i.props.children]).filter(u=>!s(u));return d.length===0?null:{...i,props:{...i.props,children:d}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?ReactJSXRuntime.jsx("section",{className:t,...n,children:a}):null}return ReactJSXRuntime.jsx("section",{className:t,...n,children:e})},(e,t)=>E(e,t));$o.displayName="MarkdownSection";var ts=({node:e,className:t,children:o,...n})=>{var k,I;let r=y(),s=!("data-block"in n),{mermaid:a,controls:l}=React.useContext(R),i=de(),c=et(),d=t==null?void 0:t.match(Qr),u=(k=d==null?void 0:d.at(1))!=null?k:"",m=so(u);if(s)return ReactJSXRuntime.jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let p=(I=e==null?void 0:e.properties)==null?void 0:I.metastring,g=p==null?void 0:p.match(Gr),h=g?Number.parseInt(g[1],10):void 0,b=h!==void 0&&h>=1?h:void 0,f="";if(React.isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?f=o.props.children:typeof o=="string"&&(f=o),m){let H=m.component;return ReactJSXRuntime.jsx(React.Suspense,{fallback:ReactJSXRuntime.jsx(Ae,{}),children:ReactJSXRuntime.jsx(H,{code:f,isIncomplete:c,language:u})})}if(u==="mermaid"&&i){let H=pt(l,"mermaid"),S=je(l,"download"),F=je(l,"copy"),z=je(l,"fullscreen"),q=je(l,"panZoom"),A=H&&(S||F||z);return ReactJSXRuntime.jsx(React.Suspense,{fallback:ReactJSXRuntime.jsx(Ae,{}),children:ReactJSXRuntime.jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-streamdown":"mermaid-block",children:[ReactJSXRuntime.jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:ReactJSXRuntime.jsx("span",{className:r("ml-1 font-mono lowercase"),children:"mermaid"})}),A?ReactJSXRuntime.jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:ReactJSXRuntime.jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"mermaid-block-actions",children:[S?ReactJSXRuntime.jsx(lo,{chart:f,config:a==null?void 0:a.config}):null,F?ReactJSXRuntime.jsx(Be,{code:f}):null,z?ReactJSXRuntime.jsx(po,{chart:f,config:a==null?void 0:a.config}):null]})}):null,ReactJSXRuntime.jsx("div",{className:r("rounded-md border border-border bg-background"),children:ReactJSXRuntime.jsx(Yr,{chart:f,config:a==null?void 0:a.config,showControls:q})})]})})}let T=pt(l,"code"),x=xo(l,"download"),w=xo(l,"copy");return ReactJSXRuntime.jsx(rt,{className:t,code:f,isIncomplete:c,language:u,startLine:b,children:T?ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[x?ReactJSXRuntime.jsx(at,{code:f,language:u}):null,w?ReactJSXRuntime.jsx(Be,{}):null]}):null})},Wo=React.memo(ts,(e,t)=>e.className===t.className&&_e(e.node,t.node));Wo.displayName="MarkdownCode";var Zo=React.memo(to,(e,t)=>e.className===t.className&&_e(e.node,t.node));Zo.displayName="MarkdownImg";var Xo=React.memo(({children:e,node:t,...o})=>{let r=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");if(r.length===1&&React.isValidElement(r[0])){let s=r[0].props.node,a=s==null?void 0:s.tagName;if(a==="img")return ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment,{children:e});if(a==="code"&&"data-block"in r[0].props)return ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment,{children:e})}return ReactJSXRuntime.jsx("p",{...o,children:e})},(e,t)=>E(e,t));Xo.displayName="MarkdownParagraph";var Jo={ol:gt,li:To,ul:Po,hr:Mo,strong:Io,a:No,h1:Lo,h2:Ro,h3:So,h4:Eo,h5:Ho,h6:Do,table:Bo,thead:Ao,tbody:Oo,tr:Vo,th:jo,td:Fo,blockquote:zo,code:Wo,img:Zo,pre:({children:e})=>React.isValidElement(e)?React.cloneElement(e,{"data-block":"true"}):e,sup:_o,sub:qo,p:Xo,section:$o};var os=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,ns=/\p{L}/u;function qe(e){let t=e.replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,"");for(let o of t){if(os.test(o))return "rtl";if(ns.test(o))return "ltr"}return "ltr"}var rs=/^[ \t]{0,3}(`{3,}|~{3,})/,ss=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,bt=e=>{let t=e.split(`
|
|
52485
|
+
`)};var Te=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=y(),[a,l]=React.useState(false),[i,c]=React.useState(false),d=React.useRef(null),u=React.useRef(0),{isAnimating:m}=React.useContext(R),p=B(),g=async f=>{var T,x;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.write)){n==null||n(new Error("Clipboard API not available"));return}try{let w=(x=d.current)==null?void 0:x.closest('[data-streamdown="table-wrapper"]'),k=w==null?void 0:w.querySelector("table");if(!k){n==null||n(new Error("Table not found"));return}let I=ue(k),F=({csv:oe,tsv:ct,md:ne}[f]||ne)(I),z=new ClipboardItem({"text/plain":new Blob([F],{type:"text/plain"}),"text/html":new Blob([k.outerHTML],{type:"text/html"})});await navigator.clipboard.write([z]),c(!0),l(!1),o==null||o(f),u.current=window.setTimeout(()=>c(!1),r);}catch(w){n==null||n(w);}};React.useEffect(()=>{let f=T=>{let x=T.composedPath();d.current&&!x.includes(d.current)&&l(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(u.current);}},[]);let h=L(),b=i?h.CheckIcon:h.CopyIcon;return ReactJSXRuntime.jsxs("div",{className:s("relative"),ref:d,children:[ReactJSXRuntime.jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>l(!a),title:p.copyTable,type:"button",children:e!=null?e:ReactJSXRuntime.jsx(b,{height:14,width:14})}),a?ReactJSXRuntime.jsxs("div",{className:s("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[ReactJSXRuntime.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("md"),title:p.copyTableAsMarkdown,type:"button",children:p.tableFormatMarkdown}),ReactJSXRuntime.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("csv"),title:p.copyTableAsCsv,type:"button",children:p.tableFormatCsv}),ReactJSXRuntime.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("tsv"),title:p.copyTableAsTsv,type:"button",children:p.tableFormatTsv})]}):null]})};var Pe=({children:e,className:t,onDownload:o,onError:n})=>{let r=y(),[s,a]=React.useState(false),l=React.useRef(null),{isAnimating:i}=React.useContext(R),c=B(),d=L(),u=m=>{var p;try{let g=(p=l.current)==null?void 0:p.closest('[data-streamdown="table-wrapper"]'),h=g==null?void 0:g.querySelector("table");if(!h){n==null||n(new Error("Table not found"));return}let b=ue(h),f=m==="csv"?oe(b):ne(b);J(`table.${m==="csv"?"csv":"md"}`,f,m==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(m);}catch(g){n==null||n(g);}};return React.useEffect(()=>{let m=p=>{let g=p.composedPath();l.current&&!g.includes(l.current)&&a(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),ReactJSXRuntime.jsxs("div",{className:r("relative"),ref:l,children:[ReactJSXRuntime.jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>a(!s),title:c.downloadTable,type:"button",children:e!=null?e:ReactJSXRuntime.jsx(d.DownloadIcon,{size:14})}),s?ReactJSXRuntime.jsxs("div",{className:r("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[ReactJSXRuntime.jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>u("csv"),title:c.downloadTableAsCsv,type:"button",children:c.tableFormatCsv}),ReactJSXRuntime.jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>u("markdown"),title:c.downloadTableAsMarkdown,type:"button",children:c.tableFormatMarkdown})]}):null]})};var wo=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=L(),a=y(),[l,i]=React.useState(false),{isAnimating:c}=React.useContext(R),d=B(),u=()=>{i(true);},m=()=>{i(false);};return React.useEffect(()=>{if(l){le();let p=g=>{g.key==="Escape"&&i(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),ce();}}},[l]),ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:u,title:d.viewFullscreen,type:"button",children:ReactJSXRuntime.jsx(r,{size:14})}),l?ReactDOM.createPortal(ReactJSXRuntime.jsx("div",{"aria-label":d.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:m,onKeyDown:p=>{p.key==="Escape"&&m();},role:"dialog",children:ReactJSXRuntime.jsxs("div",{className:a("flex h-full flex-col"),onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:[ReactJSXRuntime.jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?ReactJSXRuntime.jsx(Te,{}):null,n?ReactJSXRuntime.jsx(Pe,{}):null,ReactJSXRuntime.jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:m,title:d.exitFullscreen,type:"button",children:ReactJSXRuntime.jsx(s,{size:20})})]}),ReactJSXRuntime.jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:ReactJSXRuntime.jsx("table",{className:a("w-full border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var ko=({children:e,className:t,showControls:o,showCopy:n=true,showDownload:r=true,showFullscreen:s=true,...a})=>{let l=y(),i=o&&n,c=o&&r,d=o&&s,u=i||c||d;return ReactJSXRuntime.jsxs("div",{className:l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[u?ReactJSXRuntime.jsxs("div",{className:l("flex items-center justify-end gap-1"),children:[i?ReactJSXRuntime.jsx(Te,{}):null,c?ReactJSXRuntime.jsx(Pe,{}):null,d?ReactJSXRuntime.jsx(wo,{showCopy:i,showDownload:c,children:e}):null]}):null,ReactJSXRuntime.jsx("div",{className:l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),children:ReactJSXRuntime.jsx("table",{className:l("w-full divide-y divide-border",t),"data-streamdown":"table",...a,children:e})})]})};var Gr=/startLine=(\d+)/,Yr=React.lazy(()=>Promise.resolve().then(function () { return require('./fthry_mermaid-O7DHMXV3.D2BXxJ0r.js'); }).then(e=>({default:e.Mermaid}))),Qr=/language-([^\s]+)/;function _e(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let o=e.position.start,n=t.position.start,r=e.position.end,s=t.position.end;return (o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function E(e,t){return e.className===t.className&&_e(e.node,t.node)}var pt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ut=(e,t)=>{if(typeof e=="boolean")return e;let o=e.table;return o===false?false:o===true||o===void 0?true:o[t]!==false},xo=(e,t)=>{if(typeof e=="boolean")return e;let o=e.code;return o===false?false:o===true||o===void 0?true:o[t]!==false},je=(e,t)=>{if(typeof e=="boolean")return e;let o=e.mermaid;return o===false?false:o===true||o===void 0?true:o[t]!==false},gt=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e})},(e,t)=>E(e,t));gt.displayName="MarkdownOl";var To=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("li",{className:r("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e})},(e,t)=>e.className===t.className&&_e(e.node,t.node));To.displayName="MarkdownLi";var Po=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("ul",{className:r("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e})},(e,t)=>E(e,t));Po.displayName="MarkdownUl";var Mo=React.memo(({className:e,node:t,...o})=>{let n=y();return ReactJSXRuntime.jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>E(e,t));Mo.displayName="MarkdownHr";var Io=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>E(e,t));Io.displayName="MarkdownStrong";var es=({children:e,className:t,href:o,node:n,...r})=>{let s=y(),{linkSafety:a}=React.useContext(R),[l,i]=React.useState(false),c=o==="streamdown:incomplete-link",d=React.useCallback(async g=>{if(!(!(a!=null&&a.enabled&&o)||c)){if(g.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[a,o,c]),u=React.useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),m=React.useCallback(()=>{i(false);},[]),p={url:o!=null?o:"",isOpen:l,onClose:m,onConfirm:u};return a!=null&&a.enabled&&o?ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",onClick:d,type:"button",children:e}),a.renderModal?a.renderModal(p):ReactJSXRuntime.jsx(ro,{...p})]}):ReactJSXRuntime.jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},No=React.memo(es,(e,t)=>E(e,t)&&e.href===t.href);No.displayName="MarkdownA";var Lo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>E(e,t));Lo.displayName="MarkdownH1";var Ro=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>E(e,t));Ro.displayName="MarkdownH2";var So=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>E(e,t));So.displayName="MarkdownH3";var Eo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>E(e,t));Eo.displayName="MarkdownH4";var Ho=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>E(e,t));Ho.displayName="MarkdownH5";var Do=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>E(e,t));Do.displayName="MarkdownH6";var Bo=React.memo(({children:e,className:t,node:o,...n})=>{let{controls:r}=React.useContext(R),s=pt(r,"table"),a=ut(r,"copy"),l=ut(r,"download"),i=ut(r,"fullscreen");return ReactJSXRuntime.jsx(ko,{className:t,showControls:s,showCopy:a,showDownload:l,showFullscreen:i,...n,children:e})},(e,t)=>E(e,t));Bo.displayName="MarkdownTable";var Ao=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>E(e,t));Ao.displayName="MarkdownThead";var Oo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>E(e,t));Oo.displayName="MarkdownTbody";var Vo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>E(e,t));Vo.displayName="MarkdownTr";var jo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>E(e,t));jo.displayName="MarkdownTh";var Fo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>E(e,t));Fo.displayName="MarkdownTd";var zo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e})},(e,t)=>E(e,t));zo.displayName="MarkdownBlockquote";var _o=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>E(e,t));_o.displayName="MarkdownSup";var qo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>E(e,t));qo.displayName="MarkdownSub";var $o=React.memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=i=>{var m,p;if(!React.isValidElement(i))return false;let c=Array.isArray(i.props.children)?i.props.children:[i.props.children],d=false,u=false;for(let g of c)if(g){if(typeof g=="string")g.trim()!==""&&(d=true);else if(React.isValidElement(g))if(((m=g.props)==null?void 0:m["data-footnote-backref"])!==void 0)u=true;else {let h=Array.isArray(g.props.children)?g.props.children:[g.props.children];for(let b of h){if(typeof b=="string"&&b.trim()!==""){d=true;break}if(React.isValidElement(b)&&((p=b.props)==null?void 0:p["data-footnote-backref"])===void 0){d=true;break}}}}return u&&!d},a=Array.isArray(e)?e.map(i=>{if(!React.isValidElement(i))return i;if(i.type===gt){let d=(Array.isArray(i.props.children)?i.props.children:[i.props.children]).filter(u=>!s(u));return d.length===0?null:{...i,props:{...i.props,children:d}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?ReactJSXRuntime.jsx("section",{className:t,...n,children:a}):null}return ReactJSXRuntime.jsx("section",{className:t,...n,children:e})},(e,t)=>E(e,t));$o.displayName="MarkdownSection";var ts=({node:e,className:t,children:o,...n})=>{var k,I;let r=y(),s=!("data-block"in n),{mermaid:a,controls:l}=React.useContext(R),i=de(),c=et(),d=t==null?void 0:t.match(Qr),u=(k=d==null?void 0:d.at(1))!=null?k:"",m=so(u);if(s)return ReactJSXRuntime.jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let p=(I=e==null?void 0:e.properties)==null?void 0:I.metastring,g=p==null?void 0:p.match(Gr),h=g?Number.parseInt(g[1],10):void 0,b=h!==void 0&&h>=1?h:void 0,f="";if(React.isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?f=o.props.children:typeof o=="string"&&(f=o),m){let H=m.component;return ReactJSXRuntime.jsx(React.Suspense,{fallback:ReactJSXRuntime.jsx(Ae,{}),children:ReactJSXRuntime.jsx(H,{code:f,isIncomplete:c,language:u})})}if(u==="mermaid"&&i){let H=pt(l,"mermaid"),S=je(l,"download"),F=je(l,"copy"),z=je(l,"fullscreen"),q=je(l,"panZoom"),A=H&&(S||F||z);return ReactJSXRuntime.jsx(React.Suspense,{fallback:ReactJSXRuntime.jsx(Ae,{}),children:ReactJSXRuntime.jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-streamdown":"mermaid-block",children:[ReactJSXRuntime.jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:ReactJSXRuntime.jsx("span",{className:r("ml-1 font-mono lowercase"),children:"mermaid"})}),A?ReactJSXRuntime.jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:ReactJSXRuntime.jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"mermaid-block-actions",children:[S?ReactJSXRuntime.jsx(lo,{chart:f,config:a==null?void 0:a.config}):null,F?ReactJSXRuntime.jsx(Be,{code:f}):null,z?ReactJSXRuntime.jsx(po,{chart:f,config:a==null?void 0:a.config}):null]})}):null,ReactJSXRuntime.jsx("div",{className:r("rounded-md border border-border bg-background"),children:ReactJSXRuntime.jsx(Yr,{chart:f,config:a==null?void 0:a.config,showControls:q})})]})})}let T=pt(l,"code"),x=xo(l,"download"),w=xo(l,"copy");return ReactJSXRuntime.jsx(rt,{className:t,code:f,isIncomplete:c,language:u,startLine:b,children:T?ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[x?ReactJSXRuntime.jsx(at,{code:f,language:u}):null,w?ReactJSXRuntime.jsx(Be,{}):null]}):null})},Wo=React.memo(ts,(e,t)=>e.className===t.className&&_e(e.node,t.node));Wo.displayName="MarkdownCode";var Zo=React.memo(to,(e,t)=>e.className===t.className&&_e(e.node,t.node));Zo.displayName="MarkdownImg";var Xo=React.memo(({children:e,node:t,...o})=>{let r=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");if(r.length===1&&React.isValidElement(r[0])){let s=r[0].props.node,a=s==null?void 0:s.tagName;if(a==="img")return ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment,{children:e});if(a==="code"&&"data-block"in r[0].props)return ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment,{children:e})}return ReactJSXRuntime.jsx("p",{...o,children:e})},(e,t)=>E(e,t));Xo.displayName="MarkdownParagraph";var Jo={ol:gt,li:To,ul:Po,hr:Mo,strong:Io,a:No,h1:Lo,h2:Ro,h3:So,h4:Eo,h5:Ho,h6:Do,table:Bo,thead:Ao,tbody:Oo,tr:Vo,th:jo,td:Fo,blockquote:zo,code:Wo,img:Zo,pre:({children:e})=>React.isValidElement(e)?React.cloneElement(e,{"data-block":"true"}):e,sup:_o,sub:qo,p:Xo,section:$o};var os=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,ns=/\p{L}/u;function qe(e){let t=e.replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,"");for(let o of t){if(os.test(o))return "rtl";if(ns.test(o))return "ltr"}return "ltr"}var rs=/^[ \t]{0,3}(`{3,}|~{3,})/,ss=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,bt=e=>{let t=e.split(`
|
|
51751
52486
|
`),o=null,n=0;for(let r of t){let s=rs.exec(r);if(o===null){if(s){let a=s[1];o=a[0],n=a.length;}}else if(s){let a=s[1],l=a[0],i=a.length;l===o&&i>=n&&(o=null,n=0);}}return o!==null},Ko=e=>{let t=e.split(`
|
|
51752
52487
|
`);for(let o of t){let n=o.trim();if(n.length>0&&n.includes("|")&&ss.test(n))return true}return false};var Uo=()=>e=>{visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var Yo=[],Qo={allowDangerousHtml:true},$e=new WeakMap,yt=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let o=this.keyCache.get(t);if(o)return o;let n=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||r||s)){let u="default";return this.keyCache.set(t,u),u}let a=u=>{if(!u||u.length===0)return "";let m="";for(let p=0;p<u.length;p+=1){let g=u[p];if(p>0&&(m+=","),Array.isArray(g)){let[h,b]=g;if(typeof h=="function"){let f=$e.get(h);f||(f=h.name,$e.set(h,f)),m+=f;}else m+=String(h);m+=":",m+=JSON.stringify(b);}else if(typeof g=="function"){let h=$e.get(g);h||(h=g.name,$e.set(g,h)),m+=h;}else m+=String(g);}return m},l=a(n),i=a(r),c=s?JSON.stringify(s):"",d=`${i}::${l}::${c}`;return this.keyCache.set(t,d),d}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(n,o);}clear(){this.cache.clear();}},en=new yt,wt=e=>{let t=gs(e),o=e.children||"",n=t.runSync(t.parse(o),o);return ks(n,e)},gs=e=>{let t=en.get(e);if(t)return t;let o=hs(e);return en.set(e,o),o},bs=e=>e.some(t=>Array.isArray(t)?t[0]===rehypeRaw:t===rehypeRaw),hs=e=>{let t=e.rehypePlugins||Yo,o=e.remarkPlugins||Yo,n=bs(t)?o:[...o,Uo],r=e.remarkRehypeOptions?{...Qo,...e.remarkRehypeOptions}:Qo;return unified().use(remarkParse).use(n).use(remarkRehype,r).use(t)},tn=e=>e,ys=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},ws=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],s=urlAttributes[n];(s===null||s.includes(e.tagName))&&(e.properties[n]=(o=t(String(r||""),n,e))!=null?o:void 0);}},Cs=(e,t,o,n,r,s)=>{let a=false;return n?a=!n.includes(e.tagName):r&&(a=r.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,o)),a},ks=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:l}=t;if(o||n||r||s||l){let c=l||tn;visit(e,(d,u,m)=>{if(d.type==="raw"&&m&&typeof u=="number")return ys(m,u,s,d.value),u;if(d.type==="element"&&(ws(d,c),Cs(d,u,m,n,r,o)&&m&&typeof u=="number"))return a&&d.children?m.children.splice(u,1,...d.children):m.children.splice(u,1),u});}return toJsxRuntime(e,{Fragment:ReactJSXRuntime.Fragment,components:t.components,ignoreInvalidStyle:true,jsx:ReactJSXRuntime.jsx,jsxs:ReactJSXRuntime.jsxs,passKeys:true,passNode:true})};var xs=/\[\^[\w-]{1,200}\](?!:)/,Ts=/\[\^[\w-]{1,200}\]:/;var Ps=/<(\w+)[\s>]/,Ms=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),on=new Map,nn=new Map,Is=e=>{let t=e.toLowerCase(),o=on.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return on.set(t,n),n},Ns=e=>{let t=e.toLowerCase(),o=nn.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return nn.set(t,n),n},rn=(e,t)=>{if(Ms.has(t.toLowerCase()))return 0;let o=e.match(Is(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},sn=(e,t)=>{let o=e.match(Ns(t));return o?o.length:0},Ls=e=>{let t=0;for(let o=0;o<e.length-1;o+=1)e[o]==="$"&&e[o+1]==="$"&&(t+=1,o+=1);return t},Ct=e=>{let t=xs.test(e),o=Ts.test(e);if(t||o)return [e];let n=x.lex(e,{gfm:true}),r=[],s=[],a=false;for(let l of n){let i=l.raw,c=r.length;if(s.length>0){r[c-1]+=i;let d=s.at(-1),u=rn(i,d),m=sn(i,d);for(let p=0;p<u;p+=1)s.push(d);for(let p=0;p<m;p+=1)s.length>0&&s.at(-1)===d&&s.pop();continue}if(l.type==="html"&&l.block){let d=i.match(Ps);if(d){let u=d[1],m=rn(i,u),p=sn(i,u);m>p&&s.push(u);}}if(c>0&&!a){let d=r[c-1];if(Ls(d)%2===1){r[c-1]=d+i;continue}}r.push(i),l.type!=="space"&&(a=l.type==="code");}return r};var an=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(s,a,l,i)=>{let c=l.replace(/\n\n/g,`
|
|
51753
52488
|
<!---->
|
|
@@ -53728,6 +54463,10 @@ var AssistantChat = function (_a) {
|
|
|
53728
54463
|
var colors = React.useMemo(function () { return getChatColors(color || DEFAULT_CHAT_COLOR); }, [color]);
|
|
53729
54464
|
var makeChat = function (threadId, initialMessages, initialTitle) {
|
|
53730
54465
|
if (initialMessages === void 0) { initialMessages = []; }
|
|
54466
|
+
// Attachment session key, a new chat sends the minted id as thread_id
|
|
54467
|
+
// and the server adopts it on first message (builder convention) so
|
|
54468
|
+
// pre-thread uploads land in the right thread
|
|
54469
|
+
var sessionId = threadId !== null && threadId !== void 0 ? threadId : index$1.v4();
|
|
53731
54470
|
var resolvedThreadId = threadId;
|
|
53732
54471
|
var titleGenerated = !!initialTitle;
|
|
53733
54472
|
// Title the thread from its first user message, whether typed or a voice transcript
|
|
@@ -53758,7 +54497,7 @@ var AssistantChat = function (_a) {
|
|
|
53758
54497
|
var chatTransport = new DefaultChatTransport({
|
|
53759
54498
|
api: baseUrl,
|
|
53760
54499
|
headers: headers,
|
|
53761
|
-
body: function () { return (index$1.__assign(index$1.__assign({}, buildChatBody()), { thread_id: resolvedThreadId ||
|
|
54500
|
+
body: function () { return (index$1.__assign(index$1.__assign({}, buildChatBody()), { thread_id: resolvedThreadId || sessionId })); },
|
|
53762
54501
|
fetch: function (url, init) { return index$1.__awaiter(void 0, void 0, void 0, function () {
|
|
53763
54502
|
var res, form, audio, threadId;
|
|
53764
54503
|
var _a, _b, _c, _d;
|
|
@@ -53951,6 +54690,7 @@ var AssistantChat = function (_a) {
|
|
|
53951
54690
|
});
|
|
53952
54691
|
}
|
|
53953
54692
|
});
|
|
54693
|
+
setChatSessionId(chat, sessionId);
|
|
53954
54694
|
return chat;
|
|
53955
54695
|
};
|
|
53956
54696
|
var readyChat = React.useMemo(function () { return makeChat(null); }, [headers, getTargets, getJwt]);
|
|
@@ -53959,6 +54699,17 @@ var AssistantChat = function (_a) {
|
|
|
53959
54699
|
var _u = useChat({
|
|
53960
54700
|
chat: activeChat
|
|
53961
54701
|
}), rawMessages = _u.messages, sendMessage = _u.sendMessage, setMessages = _u.setMessages, status = _u.status, error = _u.error;
|
|
54702
|
+
var _v = useChatAttachments({ activeChat: activeChat, baseUrl: baseUrl, headers: headers }), attachments = _v.attachments, attachmentError = _v.attachmentError, attachmentsInFlight = _v.attachmentsInFlight, isDragging = _v.isDragging, fileInputRef = _v.fileInputRef, addFiles = _v.addFiles, removeFile = _v.removeFile, takeAttachments = _v.takeAttachments, handleComposerPaste = _v.handlePaste, handleDragOver = _v.handleDragOver, handleDragLeave = _v.handleDragLeave, handleDrop = _v.handleDrop;
|
|
54703
|
+
var _w = index$1.__read(React.useState(null), 2), attachmentPreview = _w[0], setAttachmentPreview = _w[1];
|
|
54704
|
+
// A send fired while attachments were indexing, the message shows
|
|
54705
|
+
// optimistically and the real request replaces it via messageId once its
|
|
54706
|
+
// batch is terminal, files attached meanwhile stay for the next message
|
|
54707
|
+
var _x = index$1.__read(React.useState(null), 2), pendingSubmit = _x[0], setPendingSubmit = _x[1];
|
|
54708
|
+
React.useEffect(function () { return setPendingSubmit(null); }, [activeChat]);
|
|
54709
|
+
var stagedAttachments = pendingSubmit
|
|
54710
|
+
? attachments.filter(function (a) { return !pendingSubmit.previewUrls.includes(a.previewUrl); })
|
|
54711
|
+
: attachments;
|
|
54712
|
+
var showAttachmentBar = stagedAttachments.length > 0 || !!attachmentError;
|
|
53962
54713
|
var messages = React.useMemo(function () {
|
|
53963
54714
|
var e_1, _a;
|
|
53964
54715
|
var _b, _c;
|
|
@@ -54017,6 +54768,8 @@ var AssistantChat = function (_a) {
|
|
|
54017
54768
|
fetchThreads();
|
|
54018
54769
|
}, [isOpen, fetchThreads]);
|
|
54019
54770
|
var handleNewThread = function () {
|
|
54771
|
+
if (pendingSubmit)
|
|
54772
|
+
return;
|
|
54020
54773
|
stopVoice();
|
|
54021
54774
|
atBottomRef.current = true;
|
|
54022
54775
|
var id = index$1.v4();
|
|
@@ -54040,6 +54793,8 @@ var AssistantChat = function (_a) {
|
|
|
54040
54793
|
return index$1.__generator(this, function (_c) {
|
|
54041
54794
|
switch (_c.label) {
|
|
54042
54795
|
case 0:
|
|
54796
|
+
if (pendingSubmit)
|
|
54797
|
+
return [2 /*return*/];
|
|
54043
54798
|
stopVoice();
|
|
54044
54799
|
atBottomRef.current = true;
|
|
54045
54800
|
if ((_a = threads.find(function (t) { return t.id === id; })) === null || _a === void 0 ? void 0 : _a.chat) {
|
|
@@ -54106,7 +54861,7 @@ var AssistantChat = function (_a) {
|
|
|
54106
54861
|
], index$1.__read(prev.filter(function (t) { return t.id !== activeThreadId; })), false); });
|
|
54107
54862
|
}
|
|
54108
54863
|
}, [activeThreadId, activeThread, activeChat]);
|
|
54109
|
-
var
|
|
54864
|
+
var _y = useAssistantVoice({
|
|
54110
54865
|
status: status,
|
|
54111
54866
|
sendMessage: function (message) { return index$1.__awaiter(void 0, void 0, void 0, function () {
|
|
54112
54867
|
return index$1.__generator(this, function (_a) {
|
|
@@ -54123,27 +54878,102 @@ var AssistantChat = function (_a) {
|
|
|
54123
54878
|
voiceActiveRef: voiceActiveRef,
|
|
54124
54879
|
pendingAudioRef: pendingAudioRef,
|
|
54125
54880
|
voiceDataRef: voiceDataRef
|
|
54126
|
-
}), voiceState =
|
|
54881
|
+
}), voiceState = _y.voiceState, voiceActive = _y.voiceActive, micAvailable = _y.micAvailable, spokenChars = _y.spokenChars, audioDraining = _y.audioDraining, startVoice = _y.startVoice, stopVoice = _y.stopVoice, skipSpeaking = _y.skipSpeaking;
|
|
54127
54882
|
// Voice: keep the view pinned to the bottom as the reply reveals during playback
|
|
54128
54883
|
React.useEffect(function () {
|
|
54129
54884
|
pinToBottom();
|
|
54130
54885
|
}, [spokenChars, audioDraining, pinToBottom]);
|
|
54131
54886
|
var handleSend = function () { return index$1.__awaiter(void 0, void 0, void 0, function () {
|
|
54887
|
+
var hasText, tempId, parts_1, staged, fileParts;
|
|
54132
54888
|
return index$1.__generator(this, function (_a) {
|
|
54133
54889
|
switch (_a.label) {
|
|
54134
54890
|
case 0:
|
|
54135
|
-
if (
|
|
54891
|
+
if (status !== 'ready' || pendingSubmit)
|
|
54892
|
+
return [2 /*return*/];
|
|
54893
|
+
hasText = !!input.trim();
|
|
54894
|
+
if (!hasText && attachments.length === 0)
|
|
54895
|
+
return [2 /*return*/];
|
|
54136
54896
|
registerActiveThread();
|
|
54897
|
+
// Show the message now with local previews, the resolver fires the
|
|
54898
|
+
// real request once the batch is terminal
|
|
54899
|
+
if (attachmentsInFlight) {
|
|
54900
|
+
tempId = index$1.v4();
|
|
54901
|
+
parts_1 = [];
|
|
54902
|
+
if (hasText)
|
|
54903
|
+
parts_1.push({ type: 'text', text: input });
|
|
54904
|
+
attachments.forEach(function (a) { return parts_1.push(getFilePart(a)); });
|
|
54905
|
+
setMessages(index$1.__spreadArray(index$1.__spreadArray([], index$1.__read(rawMessages), false), [
|
|
54906
|
+
{ id: tempId, role: 'user', parts: parts_1 }
|
|
54907
|
+
], false));
|
|
54908
|
+
setPendingSubmit({
|
|
54909
|
+
tempId: tempId,
|
|
54910
|
+
text: input,
|
|
54911
|
+
previewUrls: attachments.map(function (a) { return a.previewUrl; })
|
|
54912
|
+
});
|
|
54913
|
+
setInput('');
|
|
54914
|
+
return [2 /*return*/];
|
|
54915
|
+
}
|
|
54137
54916
|
return [4 /*yield*/, ensureCompletedSteps(instanceId)];
|
|
54138
54917
|
case 1:
|
|
54139
54918
|
_a.sent();
|
|
54140
|
-
|
|
54919
|
+
staged = takeAttachments();
|
|
54920
|
+
fileParts = staged.filter(function (a) { return a.id; }).map(getFilePart);
|
|
54921
|
+
sendMessage(index$1.__assign({ text: input }, (fileParts.length > 0 ? { files: fileParts } : {})));
|
|
54141
54922
|
setInput('');
|
|
54142
|
-
|
|
54143
|
-
|
|
54923
|
+
staged.forEach(function (a) { return URL.revokeObjectURL(a.previewUrl); });
|
|
54924
|
+
return [2 /*return*/];
|
|
54144
54925
|
}
|
|
54145
54926
|
});
|
|
54146
54927
|
}); };
|
|
54928
|
+
// Optimistic-submit resolver: swap the placeholder for the real send once
|
|
54929
|
+
// the batch is terminal, pendingSubmit clears only when the swap lands so
|
|
54930
|
+
// the dim+spinner holds through the pre-send flush
|
|
54931
|
+
var resolvingRef = React.useRef(false);
|
|
54932
|
+
React.useEffect(function () {
|
|
54933
|
+
if (!pendingSubmit || resolvingRef.current)
|
|
54934
|
+
return;
|
|
54935
|
+
var submitted = attachments.filter(function (a) {
|
|
54936
|
+
return pendingSubmit.previewUrls.includes(a.previewUrl);
|
|
54937
|
+
});
|
|
54938
|
+
if (submitted.some(function (a) { return !isTerminalStatus(a.processingStatus); }))
|
|
54939
|
+
return;
|
|
54940
|
+
resolvingRef.current = true;
|
|
54941
|
+
var tempId = pendingSubmit.tempId, text = pendingSubmit.text, previewUrls = pendingSubmit.previewUrls;
|
|
54942
|
+
var staged = takeAttachments(previewUrls);
|
|
54943
|
+
var fileParts = staged.filter(function (a) { return a.id; }).map(getFilePart);
|
|
54944
|
+
if (!text.trim() && fileParts.length === 0) {
|
|
54945
|
+
// Every upload failed outright, drop the placeholder
|
|
54946
|
+
setMessages(function (prev) { return prev.filter(function (m) { return m.id !== tempId; }); });
|
|
54947
|
+
staged.forEach(function (a) { return URL.revokeObjectURL(a.previewUrl); });
|
|
54948
|
+
resolvingRef.current = false;
|
|
54949
|
+
setPendingSubmit(null);
|
|
54950
|
+
return;
|
|
54951
|
+
}
|
|
54952
|
+
(function () { return index$1.__awaiter(void 0, void 0, void 0, function () {
|
|
54953
|
+
var sent;
|
|
54954
|
+
return index$1.__generator(this, function (_a) {
|
|
54955
|
+
switch (_a.label) {
|
|
54956
|
+
case 0: return [4 /*yield*/, ensureCompletedSteps(instanceId)];
|
|
54957
|
+
case 1:
|
|
54958
|
+
_a.sent();
|
|
54959
|
+
sent = sendMessage(index$1.__assign(index$1.__assign({ text: text }, (fileParts.length > 0 ? { files: fileParts } : {})), { messageId: tempId }));
|
|
54960
|
+
resolvingRef.current = false;
|
|
54961
|
+
setPendingSubmit(null);
|
|
54962
|
+
// Revoke the local previews only after the send settles, the
|
|
54963
|
+
// placeholder renders from them until the swap lands, send errors
|
|
54964
|
+
// surface via the chat's own error path
|
|
54965
|
+
return [4 /*yield*/, sent.catch(function () { })];
|
|
54966
|
+
case 2:
|
|
54967
|
+
// Revoke the local previews only after the send settles, the
|
|
54968
|
+
// placeholder renders from them until the swap lands, send errors
|
|
54969
|
+
// surface via the chat's own error path
|
|
54970
|
+
_a.sent();
|
|
54971
|
+
staged.forEach(function (a) { return URL.revokeObjectURL(a.previewUrl); });
|
|
54972
|
+
return [2 /*return*/];
|
|
54973
|
+
}
|
|
54974
|
+
});
|
|
54975
|
+
}); })();
|
|
54976
|
+
}, [pendingSubmit, attachments]);
|
|
54147
54977
|
var handleWorkflowAction = function (action) { return index$1.__awaiter(void 0, void 0, void 0, function () {
|
|
54148
54978
|
return index$1.__generator(this, function (_a) {
|
|
54149
54979
|
switch (_a.label) {
|
|
@@ -54495,27 +55325,51 @@ var AssistantChat = function (_a) {
|
|
|
54495
55325
|
fontSize: '14px',
|
|
54496
55326
|
marginTop: '40px'
|
|
54497
55327
|
} }, { children: "How can I help?" }))), messages.map(function (message, mIdx) {
|
|
54498
|
-
var _a;
|
|
55328
|
+
var _a, _b, _c;
|
|
54499
55329
|
return message.role === 'user' ? (
|
|
54500
|
-
// Show the bubble only once its transcript
|
|
54501
|
-
|
|
55330
|
+
// Show the bubble only once its transcript or attachments land,
|
|
55331
|
+
// not as an empty placeholder
|
|
55332
|
+
((_a = message.parts) !== null && _a !== void 0 ? _a : []).some(function (p) {
|
|
55333
|
+
var _a;
|
|
55334
|
+
return (p.type === 'text' && ((_a = p.text) !== null && _a !== void 0 ? _a : '').trim()) ||
|
|
55335
|
+
p.type === 'file';
|
|
55336
|
+
}) ? (index$1.jsxs("div", index$1.__assign({ css: {
|
|
54502
55337
|
display: 'flex',
|
|
54503
|
-
|
|
54504
|
-
|
|
54505
|
-
|
|
54506
|
-
|
|
54507
|
-
|
|
54508
|
-
|
|
54509
|
-
|
|
54510
|
-
|
|
54511
|
-
|
|
54512
|
-
|
|
54513
|
-
|
|
54514
|
-
|
|
54515
|
-
|
|
54516
|
-
|
|
54517
|
-
|
|
54518
|
-
|
|
55338
|
+
flexDirection: 'column',
|
|
55339
|
+
alignItems: 'flex-end',
|
|
55340
|
+
gap: '6px'
|
|
55341
|
+
} }, { children: [index$1.jsx("div", index$1.__assign({ css: {
|
|
55342
|
+
display: 'flex',
|
|
55343
|
+
flexWrap: 'wrap',
|
|
55344
|
+
justifyContent: 'flex-end',
|
|
55345
|
+
gap: '6px'
|
|
55346
|
+
} }, { children: ((_b = message.parts) !== null && _b !== void 0 ? _b : [])
|
|
55347
|
+
.filter(function (part) { return part.type === 'file'; })
|
|
55348
|
+
.map(function (part, index) {
|
|
55349
|
+
var _a;
|
|
55350
|
+
return (index$1.jsx(MessageAttachment, { mediaType: (_a = part.mediaType) !== null && _a !== void 0 ? _a : '', filename: part.filename, url: part.url, inFlight: (pendingSubmit === null || pendingSubmit === void 0 ? void 0 : pendingSubmit.tempId) === message.id, onOpen: function () {
|
|
55351
|
+
var _a;
|
|
55352
|
+
return setAttachmentPreview({
|
|
55353
|
+
url: part.url,
|
|
55354
|
+
mediaType: (_a = part.mediaType) !== null && _a !== void 0 ? _a : '',
|
|
55355
|
+
filename: part.filename
|
|
55356
|
+
});
|
|
55357
|
+
} }, "file-".concat(index)));
|
|
55358
|
+
}) })), ((_c = message.parts) !== null && _c !== void 0 ? _c : []).some(function (p) { var _a; return p.type === 'text' && ((_a = p.text) !== null && _a !== void 0 ? _a : '').trim(); }) && (index$1.jsx("div", index$1.__assign({ css: {
|
|
55359
|
+
maxWidth: '80%',
|
|
55360
|
+
padding: '10px 14px',
|
|
55361
|
+
borderRadius: '12px',
|
|
55362
|
+
fontSize: '14px',
|
|
55363
|
+
lineHeight: '1.5',
|
|
55364
|
+
backgroundColor: colors.primary,
|
|
55365
|
+
color: 'white',
|
|
55366
|
+
overflowWrap: 'anywhere',
|
|
55367
|
+
wordBreak: 'break-word'
|
|
55368
|
+
} }, { children: message.parts
|
|
55369
|
+
.filter(function (part) { return !part.hidden; })
|
|
55370
|
+
.map(function (part, index) {
|
|
55371
|
+
return part.type === 'text' ? (index$1.jsx("span", { children: part.text }, index)) : null;
|
|
55372
|
+
}) })))] }), message.id)) : null) : (index$1.jsx(React.Fragment, { children: (function () {
|
|
54519
55373
|
var isLastMsg = mIdx === messages.length - 1;
|
|
54520
55374
|
var chunks = mergeAssistantParts(message.parts);
|
|
54521
55375
|
var lastPart = message.parts[message.parts.length - 1];
|
|
@@ -54603,7 +55457,7 @@ var AssistantChat = function (_a) {
|
|
|
54603
55457
|
return null;
|
|
54604
55458
|
}
|
|
54605
55459
|
return index$1.jsx(ToolChunkPlaceholder, {});
|
|
54606
|
-
})(), error && (index$1.jsx("div", index$1.__assign({ css: {
|
|
55460
|
+
})(), pendingSubmit && index$1.jsx(ToolChunkPlaceholder, { label: 'Uploading...' }), error && (index$1.jsx("div", index$1.__assign({ css: {
|
|
54607
55461
|
padding: '10px 14px',
|
|
54608
55462
|
borderRadius: '8px',
|
|
54609
55463
|
backgroundColor: '#fef2f2',
|
|
@@ -54653,14 +55507,35 @@ var AssistantChat = function (_a) {
|
|
|
54653
55507
|
whiteSpace: 'nowrap',
|
|
54654
55508
|
pointerEvents: 'none',
|
|
54655
55509
|
zIndex: 10000
|
|
54656
|
-
} }, { children: actionTooltip.text })))] }))), index$1.jsxs("div", index$1.__assign({ css: {
|
|
55510
|
+
} }, { children: actionTooltip.text })))] }))), showAttachmentBar && (index$1.jsxs("div", index$1.__assign({ css: {
|
|
54657
55511
|
display: 'flex',
|
|
54658
|
-
|
|
55512
|
+
flexWrap: 'wrap',
|
|
54659
55513
|
gap: '8px',
|
|
54660
|
-
padding: '
|
|
55514
|
+
padding: '10px 16px 0',
|
|
54661
55515
|
borderTop: "1px solid ".concat(GRAY_200),
|
|
54662
55516
|
backgroundColor: GRAY_50
|
|
54663
|
-
} }, { children: [
|
|
55517
|
+
} }, { children: [attachmentError && (index$1.jsx("div", index$1.__assign({ css: { fontSize: '12px', color: '#dc2626', width: '100%' } }, { children: attachmentError }))), stagedAttachments.map(function (attachment) { return (index$1.jsx(AttachmentChip, { attachment: attachment, onRemove: function () { return removeFile(attachment.previewUrl); } }, attachment.previewUrl)); })] }))), index$1.jsxs("div", index$1.__assign({ onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, css: index$1.__assign({ display: 'flex', alignItems: 'center', gap: '8px', padding: '12px 16px', borderTop: showAttachmentBar ? 'none' : "1px solid ".concat(GRAY_200), backgroundColor: GRAY_50 }, (isDragging
|
|
55518
|
+
? { outline: "2px dashed ".concat(colors.primary), outlineOffset: '-4px' }
|
|
55519
|
+
: {})) }, { children: [!voiceActive && (index$1.jsxs(index$1.Fragment, { children: [index$1.jsx("input", { ref: fileInputRef, type: 'file', multiple: true, accept: ACCEPT_ATTR, onChange: function (e) {
|
|
55520
|
+
var _a;
|
|
55521
|
+
var files = Array.from((_a = e.target.files) !== null && _a !== void 0 ? _a : []);
|
|
55522
|
+
if (files.length)
|
|
55523
|
+
addFiles(files);
|
|
55524
|
+
e.target.value = '';
|
|
55525
|
+
}, css: { display: 'none' } }), index$1.jsx("button", index$1.__assign({ type: 'button', onClick: function () { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, disabled: isLoading, "aria-label": 'Attach files', css: {
|
|
55526
|
+
padding: '10px',
|
|
55527
|
+
backgroundColor: 'transparent',
|
|
55528
|
+
color: GRAY_800,
|
|
55529
|
+
border: "1px solid ".concat(GRAY_200),
|
|
55530
|
+
borderRadius: '8px',
|
|
55531
|
+
cursor: 'pointer',
|
|
55532
|
+
display: 'flex',
|
|
55533
|
+
alignItems: 'center',
|
|
55534
|
+
justifyContent: 'center',
|
|
55535
|
+
transition: 'background-color 0.2s',
|
|
55536
|
+
':hover:not(:disabled)': { backgroundColor: GRAY_100 },
|
|
55537
|
+
':disabled': { cursor: 'not-allowed', color: GRAY_400 }
|
|
55538
|
+
} }, { children: index$1.jsx(PaperclipIcon, {}) }))] })), voiceActive ? (index$1.jsxs("button", index$1.__assign({ type: 'button', onClick: voiceState === 'speaking' ? skipSpeaking : undefined, css: {
|
|
54664
55539
|
flex: 1,
|
|
54665
55540
|
display: 'flex',
|
|
54666
55541
|
alignItems: 'center',
|
|
@@ -54680,7 +55555,7 @@ var AssistantChat = function (_a) {
|
|
|
54680
55555
|
? 'Thinking…'
|
|
54681
55556
|
: voiceState === 'speaking'
|
|
54682
55557
|
? 'Tap to skip'
|
|
54683
|
-
: 'Listening…'] }))) : (index$1.jsx("input", { type: 'text', value: input, onChange: function (e) { return setInput(e.target.value); }, onKeyDown: handleKeyDown, placeholder: 'Type a message...', css: {
|
|
55558
|
+
: 'Listening…'] }))) : (index$1.jsx("input", { type: 'text', value: input, onChange: function (e) { return setInput(e.target.value); }, onKeyDown: handleKeyDown, onPaste: handleComposerPaste, placeholder: 'Type a message...', css: {
|
|
54684
55559
|
flex: 1,
|
|
54685
55560
|
padding: '10px 14px',
|
|
54686
55561
|
border: "1px solid ".concat(GRAY_200),
|
|
@@ -54691,7 +55566,9 @@ var AssistantChat = function (_a) {
|
|
|
54691
55566
|
':focus': {
|
|
54692
55567
|
borderColor: colors.primary
|
|
54693
55568
|
}
|
|
54694
|
-
} })), voiceActive ? (index$1.jsx("button", index$1.__assign({ type: 'button', onClick: stopVoice, "aria-label": 'Exit voice mode', css: composerButtonCss }, { children: index$1.jsx(CloseIcon, {}) }))) : !voiceEnabled || input.trim()
|
|
55569
|
+
} })), voiceActive ? (index$1.jsx("button", index$1.__assign({ type: 'button', onClick: stopVoice, "aria-label": 'Exit voice mode', css: composerButtonCss }, { children: index$1.jsx(CloseIcon, {}) }))) : !voiceEnabled || input.trim() || attachments.length > 0 ? (index$1.jsx("button", index$1.__assign({ type: 'button', onClick: handleSend, disabled: isLoading ||
|
|
55570
|
+
!!pendingSubmit ||
|
|
55571
|
+
(!input.trim() && attachments.length === 0), css: composerButtonCss }, { children: index$1.jsx(SendIcon, {}) }))) : (index$1.jsx("button", index$1.__assign({ type: 'button', onClick: startVoice, disabled: isLoading || !micAvailable, "aria-label": 'Start voice mode', title: micAvailable ? undefined : 'Microphone unavailable', css: composerButtonCss }, { children: index$1.jsx(MicIcon, {}) })))] })), attachmentPreview && (index$1.jsx(AttachmentPreviewOverlay, { preview: attachmentPreview, onClose: function () { return setAttachmentPreview(null); } }))] })));
|
|
54695
55572
|
};
|
|
54696
55573
|
|
|
54697
55574
|
var AssistantChat$1 = /*#__PURE__*/Object.freeze({
|