@rustic-ai/ui-components 0.0.31 → 0.0.33
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/dist/components/index.d.ts +3 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/input/emoji/emoji.d.ts +1 -0
- package/dist/components/input/emoji/emoji.d.ts.map +1 -1
- package/dist/components/input/emoji/index.js +1 -1
- package/dist/components/input/multimodal/multimodalInput/index.css +0 -1
- package/dist/components/input/multimodal/multimodalInput/index.js +1 -1
- package/dist/components/input/multimodal/multimodalInput/multimodalInput.d.ts +2 -2
- package/dist/components/input/multimodal/multimodalInput/multimodalInput.d.ts.map +1 -1
- package/dist/components/input/multimodal/uploader/index.js +1 -1
- package/dist/components/input/multimodal/uploader/uploader.d.ts.map +1 -1
- package/dist/components/input/textInput/index.css +0 -1
- package/dist/components/input/textInput/index.js +1 -1
- package/dist/components/messageSpace/index.css +8 -2
- package/dist/components/messageSpace/index.js +1 -1
- package/dist/components/messageSpace/messageSpace.d.ts.map +1 -1
- package/dist/components/prompts/index.css +5 -0
- package/dist/components/prompts/index.d.ts +4 -0
- package/dist/components/prompts/index.d.ts.map +1 -0
- package/dist/components/prompts/index.js +1 -0
- package/dist/components/prompts/prompts.d.ts +12 -0
- package/dist/components/prompts/prompts.d.ts.map +1 -0
- package/dist/components/sharedDescription.d.ts +5 -0
- package/dist/components/sharedDescription.d.ts.map +1 -0
- package/dist/components/types.d.ts +13 -1
- package/dist/components/types.d.ts.map +1 -1
- package/dist/components/visualization/perspectiveViz/index.js +1 -1
- package/dist/components/visualization/perspectiveViz/perspectiveViz.d.ts.map +1 -1
- package/dist/index.css +13 -3
- package/dist/index.js +1 -1
- package/dist/rusticTheme.d.ts +0 -1
- package/dist/rusticTheme.d.ts.map +1 -1
- package/dist/rusticTheme.js +1 -1
- package/package.json +25 -19
|
@@ -22,6 +22,7 @@ import Multipart from './multipart/multipart';
|
|
|
22
22
|
import ParticipantsContainer from './participantsContainer/participantsContainer';
|
|
23
23
|
import PDFViewer from './pdfViewer/pdfViewer';
|
|
24
24
|
import PromptBuilder from './promptBuilder/promptBuilder';
|
|
25
|
+
import Prompts from './prompts/prompts';
|
|
25
26
|
import Question from './question/question';
|
|
26
27
|
import Table from './table/table';
|
|
27
28
|
import StreamingText from './text/streamingText';
|
|
@@ -34,10 +35,10 @@ import PerspectiveViz from './visualization/perspectiveViz/perspectiveViz';
|
|
|
34
35
|
import PlotlyGraph from './visualization/plotlyGraph/plotlyGraph';
|
|
35
36
|
import VegaLiteViz from './visualization/vegaLiteViz/vegaLiteViz';
|
|
36
37
|
import Weather from './weather/weather';
|
|
37
|
-
export { Action, CodeSnippet, CopyText, ElementRenderer, FCCalendar, Icon, Image, MarkedMarkdown, MarkedStreamingMarkdown, MermaidViz, MessageCanvas, MessageSpace, MultimodalInput, Multipart, OpenLayersMap, ParticipantsContainer, PDFViewer, PerspectiveViz, PopoverMenu, PromptBuilder,
|
|
38
|
+
export { Action, CodeSnippet, CopyText, ElementRenderer, FCCalendar, Icon, Image, MarkedMarkdown, MarkedStreamingMarkdown, MermaidViz, MessageCanvas, MessageSpace, MultimodalInput, Multipart, OpenLayersMap, ParticipantsContainer, PDFViewer, PerspectiveViz, PlotlyGraph, PopoverMenu, PromptBuilder, Prompts, Question, RechartsTimeSeries, Sound, StreamingText, Table, Text, TextInput, TextToSpeech, Timestamp, UniformsForm, Uploader, VegaLiteViz, Video, Weather, YoutubeVideo, };
|
|
38
39
|
export * from '../rusticTheme';
|
|
39
40
|
export * from './types';
|
|
40
41
|
export * from './visualization/mermaidViz/mermaidViz.types';
|
|
41
|
-
export * from './visualization/vegaLiteViz/vegaLiteViz.types';
|
|
42
42
|
export * from './visualization/plotlyGraph/plotlyGraph.types';
|
|
43
|
+
export * from './visualization/vegaLiteViz/vegaLiteViz.types';
|
|
43
44
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,uBAAuB,CAAA;AAC9C,OAAO,WAAW,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,eAAe,MAAM,mCAAmC,CAAA;AAC/D,OAAO,IAAI,MAAM,aAAa,CAAA;AAC9B,OAAO,KAAK,MAAM,eAAe,CAAA;AACjC,OAAO,eAAe,MAAM,oDAAoD,CAAA;AAChF,OAAO,QAAQ,MAAM,sCAAsC,CAAA;AAC3D,OAAO,SAAS,MAAM,6BAA6B,CAAA;AACnD,OAAO,aAAa,MAAM,qBAAqB,CAAA;AAC/C,OAAO,cAAc,MAAM,2BAA2B,CAAA;AACtD,OAAO,uBAAuB,MAAM,oCAAoC,CAAA;AACxE,OAAO,KAAK,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,MAAM,qBAAqB,CAAA;AACvC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAC5C,OAAO,QAAQ,MAAM,uCAAuC,CAAA;AAC5D,OAAO,MAAM,MAAM,+BAA+B,CAAA;AAClD,OAAO,YAAY,MAAM,mDAAmD,CAAA;AAC5E,OAAO,aAAa,MAAM,+BAA+B,CAAA;AACzD,OAAO,YAAY,MAAM,6BAA6B,CAAA;AACtD,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,qBAAqB,MAAM,+CAA+C,CAAA;AACjF,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,aAAa,MAAM,+BAA+B,CAAA;AACzD,OAAO,QAAQ,MAAM,qBAAqB,CAAA;AAC1C,OAAO,KAAK,MAAM,eAAe,CAAA;AACjC,OAAO,aAAa,MAAM,sBAAsB,CAAA;AAChD,OAAO,IAAI,MAAM,aAAa,CAAA;AAC9B,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,YAAY,MAAM,sBAAsB,CAAA;AAC/C,OAAO,kBAAkB,MAAM,0CAA0C,CAAA;AACzE,OAAO,UAAU,MAAM,uCAAuC,CAAA;AAC9D,OAAO,cAAc,MAAM,+CAA+C,CAAA;AAC1E,OAAO,WAAW,MAAM,yCAAyC,CAAA;AACjE,OAAO,WAAW,MAAM,yCAAyC,CAAA;AACjE,OAAO,OAAO,MAAM,mBAAmB,CAAA;AAEvC,OAAO,EACL,MAAM,EACN,WAAW,EACX,QAAQ,EACR,eAAe,EACf,UAAU,EACV,IAAI,EACJ,KAAK,EACL,cAAc,EACd,uBAAuB,EACvB,UAAU,EACV,aAAa,EACb,YAAY,EACZ,eAAe,EACf,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,WAAW,EACX,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,uBAAuB,CAAA;AAC9C,OAAO,WAAW,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,eAAe,MAAM,mCAAmC,CAAA;AAC/D,OAAO,IAAI,MAAM,aAAa,CAAA;AAC9B,OAAO,KAAK,MAAM,eAAe,CAAA;AACjC,OAAO,eAAe,MAAM,oDAAoD,CAAA;AAChF,OAAO,QAAQ,MAAM,sCAAsC,CAAA;AAC3D,OAAO,SAAS,MAAM,6BAA6B,CAAA;AACnD,OAAO,aAAa,MAAM,qBAAqB,CAAA;AAC/C,OAAO,cAAc,MAAM,2BAA2B,CAAA;AACtD,OAAO,uBAAuB,MAAM,oCAAoC,CAAA;AACxE,OAAO,KAAK,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,MAAM,qBAAqB,CAAA;AACvC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAC5C,OAAO,QAAQ,MAAM,uCAAuC,CAAA;AAC5D,OAAO,MAAM,MAAM,+BAA+B,CAAA;AAClD,OAAO,YAAY,MAAM,mDAAmD,CAAA;AAC5E,OAAO,aAAa,MAAM,+BAA+B,CAAA;AACzD,OAAO,YAAY,MAAM,6BAA6B,CAAA;AACtD,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,qBAAqB,MAAM,+CAA+C,CAAA;AACjF,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,aAAa,MAAM,+BAA+B,CAAA;AACzD,OAAO,OAAO,MAAM,mBAAmB,CAAA;AACvC,OAAO,QAAQ,MAAM,qBAAqB,CAAA;AAC1C,OAAO,KAAK,MAAM,eAAe,CAAA;AACjC,OAAO,aAAa,MAAM,sBAAsB,CAAA;AAChD,OAAO,IAAI,MAAM,aAAa,CAAA;AAC9B,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,YAAY,MAAM,sBAAsB,CAAA;AAC/C,OAAO,kBAAkB,MAAM,0CAA0C,CAAA;AACzE,OAAO,UAAU,MAAM,uCAAuC,CAAA;AAC9D,OAAO,cAAc,MAAM,+CAA+C,CAAA;AAC1E,OAAO,WAAW,MAAM,yCAAyC,CAAA;AACjE,OAAO,WAAW,MAAM,yCAAyC,CAAA;AACjE,OAAO,OAAO,MAAM,mBAAmB,CAAA;AAEvC,OAAO,EACL,MAAM,EACN,WAAW,EACX,QAAQ,EACR,eAAe,EACf,UAAU,EACV,IAAI,EACJ,KAAK,EACL,cAAc,EACd,uBAAuB,EACvB,UAAU,EACV,aAAa,EACb,YAAY,EACZ,eAAe,EACf,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,OAAO,EACP,QAAQ,EACR,kBAAkB,EAClB,KAAK,EACL,aAAa,EACb,KAAK,EACL,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,OAAO,EACP,YAAY,GACb,CAAA;AAED,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,6CAA6C,CAAA;AAC3D,cAAc,+CAA+C,CAAA;AAC7D,cAAc,+CAA+C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emoji.d.ts","sourceRoot":"","sources":["../../../../src/components/input/emoji/emoji.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,sBAAsB,CAAA;AAY7B,UAAU,UAAU;IAClB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,WAAW,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"emoji.d.ts","sourceRoot":"","sources":["../../../../src/components/input/emoji/emoji.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,sBAAsB,CAAA;AAY7B,UAAU,UAAU;IAClB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,iBAAS,KAAK,CAAC,KAAK,EAAE,UAAU,2CAyG/B;AAED,eAAe,KAAK,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,t={342:e=>{e.exports=require("emoji-picker-element")}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(t,o){if(1&o&&(t=this(t)),8&o)return t;if("object"==typeof t&&t){if(4&o&&t.__esModule)return t;if(16&o&&"function"==typeof t.then)return t}var i=Object.create(null);n.r(i);var c={};e=e||[null,r({}),r([]),r(r)];for(var a=2&o&&t;"object"==typeof a&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>c[e]=()=>t[e]));return c.default=()=>t,n.d(i,c),i},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};n.r(i),n.d(i,{default:()=>y});const c=require("react/jsx-runtime");n(342);const a=require("@mui/material/IconButton");var u=n.n(a);const l=require("@mui/material/Popover");var s=n.n(l);const d=require("@mui/material/styles"),f=require("@mui/material/Tooltip");var p=n.n(f);const m=require("react");var v=function(){return v=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},v.apply(this,arguments)};function j(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,c.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:v({},r),children:e.name})}const y=function(e){var r=(0,d.useTheme)(),t=(0,m.useRef)(null),o=(0,m.useRef)(null),i=(0,m.useState)(!1),a=i[0],l=i[1],f={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function v(){l(!1)}function y(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),v()}return(0,m.useEffect)((function(){o.current||"undefined"==typeof window||Promise.resolve().then(n.t.bind(n,342,23)).then((function(
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,t={342:e=>{e.exports=require("emoji-picker-element")}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(t,o){if(1&o&&(t=this(t)),8&o)return t;if("object"==typeof t&&t){if(4&o&&t.__esModule)return t;if(16&o&&"function"==typeof t.then)return t}var i=Object.create(null);n.r(i);var c={};e=e||[null,r({}),r([]),r(r)];for(var a=2&o&&t;"object"==typeof a&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>c[e]=()=>t[e]));return c.default=()=>t,n.d(i,c),i},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};n.r(i),n.d(i,{default:()=>y});const c=require("react/jsx-runtime");n(342);const a=require("@mui/material/IconButton");var u=n.n(a);const l=require("@mui/material/Popover");var s=n.n(l);const d=require("@mui/material/styles"),f=require("@mui/material/Tooltip");var p=n.n(f);const m=require("react");var v=function(){return v=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},v.apply(this,arguments)};function j(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,c.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:v({},r),children:e.name})}const y=function(e){var r=(0,d.useTheme)(),t=(0,m.useRef)(null),o=(0,m.useRef)(null),i=(0,m.useState)(!1),a=i[0],l=i[1],f={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function v(){l(!1)}function y(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),v()}return(0,m.useEffect)((function(){o.current||"undefined"==typeof window||Promise.resolve().then(n.t.bind(n,342,23)).then((function(t){var n=new(0,t.Picker)({dataSource:e.dataSource}),i="dark"===r.palette.mode?"dark":"light";n.classList.add(i),Object.keys(f).forEach((function(e){n.style.setProperty(e,f[e])})),o.current=n})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,m.useEffect)((function(){return o.current&&o.current.addEventListener("emoji-click",y),function(){var e;null===(e=o.current)||void 0===e||e.removeEventListener("emoji-click",y)}}),[a,e.onEmojiClick]),(0,c.jsxs)("div",{children:[(0,c.jsx)(p(),{title:"Emoji",children:(0,c.jsx)(u(),{size:"small",ref:t,onClick:function(){l((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,c.jsx)(j,{name:"Mood"})})}),o.current&&(0,c.jsx)(s(),{open:a,anchorEl:t.current,onClose:v,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,c.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&o.current&&!e.contains(o.current)&&e.appendChild(o.current)}})})]})};return i})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,n={767:(e,r,n)=>{n.d(r,{A:()=>a});var t=n(732),o=(n(15),function(){return o=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var o in r=arguments[n])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},o.apply(this,arguments)});function a(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:o({},r),children:e.name})}},110:(e,r,n)=>{n.d(r,{default:()=>t});const t=n(767).A},342:e=>{e.exports=require("emoji-picker-element")},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},t={};function o(e){var r=t[e];if(void 0!==r)return r.exports;var a=t[e]={exports:{}};return n[e](a,a.exports,o),a.exports}o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(n,t){if(1&t&&(n=this(n)),8&t)return n;if("object"==typeof n&&n){if(4&t&&n.__esModule)return n;if(16&t&&"function"==typeof n.then)return n}var a=Object.create(null);o.r(a);var i={};e=e||[null,r({}),r([]),r(r)];for(var c=2&t&&n;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>i[e]=()=>n[e]));return i.default=()=>n,o.d(a,i),a},o.d=(e,r)=>{for(var n in r)o.o(r,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};o.r(a),o.d(a,{default:()=>Ne});var i=o(732);const c=require("@mui/material/Box");var s=o.n(c);const l=require("@mui/material/styles");var u=o(15);const d=require("uuid"),m=require("@mui/material/CircularProgress");var p=o.n(m);const f=require("@mui/material/IconButton");var h=o.n(f);const v=require("@mui/material/InputAdornment");var x=o.n(v);const g=require("@mui/material/MenuItem");var b=o.n(g);const j=require("@mui/material/MenuList");var y=o.n(j);const w=require("@mui/material/Popover");var C=o.n(w);const N=require("@mui/material/TextField");var k=o.n(N);const S=require("@mui/material/Tooltip");var F=o.n(S);const P=require("@mui/material/Typography");var O=o.n(P),E=o(342),q=o(767);const T=function(e){var r=(0,l.useTheme)(),n=(0,u.useRef)(null),t=(0,u.useRef)(null),a=(0,u.useState)(!1),c=a[0],s=a[1],d={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function m(){s(!1)}function p(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),m()}return(0,u.useEffect)((function(){t.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,342,23)).then((function(e){var n=new(0,e.Picker),o="dark"===r.palette.mode?"dark":"light";n.classList.add(o),Object.keys(d).forEach((function(e){n.style.setProperty(e,d[e])})),t.current=n})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,u.useEffect)((function(){return t.current&&t.current.addEventListener("emoji-click",p),function(){var e;null===(e=t.current)||void 0===e||e.removeEventListener("emoji-click",p)}}),[c,e.onEmojiClick]),(0,i.jsxs)("div",{children:[(0,i.jsx)(F(),{title:"Emoji",children:(0,i.jsx)(h(),{size:"small",ref:n,onClick:function(){s((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)(q.A,{name:"Mood"})})}),t.current&&(0,i.jsx)(C(),{open:c,anchorEl:n.current,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,i.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&t.current&&!e.contains(t.current)&&e.appendChild(t.current)}})})]})};var I={"no-speech":"No speech detected. Check your microphone volume and try again.",aborted:"Speech input was aborted. Ensure no other windows are accessing your microphone and try again.","audio-capture":"Could not capture any audio. Check that your microphone is connected and try again.",network:"Failed to connect to the internet for recognition. Check your internet connection and try again.","not-allowed":"This functionality requires microphone access. Please allow microphone access and try again.","service-not-allowed":"Speech recognition service is not allowed, either because the browser doesn't support it or because of reasons of security, privacy or user preference.","bad-grammar":"There was an error in the speech recognition grammar or format. Check your speech input or grammar rules.","language-not-supported":"The language you're speaking isn't supported. Try speaking in a different language or check your device settings."};function R(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var A=new E.Database,D=(0,u.forwardRef)((function(e,r){var n=(0,u.useState)(""),t=n[0],o=n[1],a=(0,u.useState)(!1),c=a[0],l=a[1],m=(0,u.useState)(!1),f=m[0],v=m[1],g=(0,u.useState)(!1),j=g[0],w=g[1],N=(0,u.useState)(""),S=N[0],P=N[1],E=(0,u.useState)([]),D=E[0],z=E[1],_=(0,u.useState)(!1),M=_[0],U=_[1],B=(0,u.useRef)(null),L=!t.trim().length&&!e.isSendEnabled,W="".concat(c?"Stop":"Start"," speech to text"),H=f?"primary.main":"primary.light",V=c?"error.main":H,$=c?"stop_circle":"speech_to_text";function G(e,r){if(void 0===r&&(r=!1),B.current){var n=B.current,a=n.selectionStart,i=n.selectionEnd;if("number"==typeof a&&"number"==typeof i){var c,s=t||"",l=s.substring(0,a),u=s.substring(i);c=r?l.replace(/:(\w+)$/,e)+u:l+e+u,o(c);var d=r?l.replace(/:(\w+)$/,e).length:a+e.length;setTimeout((function(){var e,r;null===(e=B.current)||void 0===e||e.focus(),null===(r=B.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}U(!1)}var K=j?(0,i.jsx)(p(),{size:24}):(0,i.jsx)(F(),{title:W,children:(0,i.jsx)(h(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,c?(e.stop(),w(!0),l(!1)):(e.start(),P(""),l(!0)),e.onstart=function(){l(!0)},e.onresult=function(e){var r,n=e.results[0][0].transcript;t.length>0?o(t+" "+n):o(n),null===(r=B.current)||void 0===r||r.focus(),l(!1)},e.onerror=function(e){var r=I[e.error];P(r),l(!1)},e.onend=function(){w(!1),l(!1)}},size:"small",sx:{color:V,"&:hover":{color:"primary.main"}},children:(0,i.jsx)(q.A,{name:$})})});function Q(){var r=(new Date).toISOString(),n={id:(0,d.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"text",data:{text:t}};e.send(n),o(""),P("")}return(0,i.jsxs)(s(),{className:"rustic-base-input",ref:r,children:[(0,i.jsxs)(s(),{className:"rustic-error-and-input-container",children:[(0,i.jsx)(s(),{className:"rustic-error-container",children:(0,i.jsx)(O(),{variant:"caption",color:"error",className:"rustic-error-message",children:S})}),(0,i.jsxs)(s(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:f?"secondary.main":"action.disabled"},children:[D.length>0&&(0,i.jsx)(C(),{open:M,anchorEl:B.current,onClose:function(){return U(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,i.jsx)(y(),{children:D.map((function(e,r){return"unicode"in e&&(0,i.jsx)(b(),{onClick:function(){return G(e.unicode,!0)},children:R(e)},r)}))})}),(0,i.jsx)(k(),{className:"rustic-text-field",variant:"outlined",value:t,label:e.label,placeholder:e.placeholder,maxRows:e.maxRows,multiline:e.multiline,fullWidth:e.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!L&&Q())},onChange:function(r){P("");var n=r.target.value;o(n);var t,a=n.match(/:(\w{2,}):/g),i=n.match(/:(\w{2,})/g);if(a){var c=a[0].replace(/:/g,"");A.getEmojiByShortcode(c).then((function(e){if(e&&"unicode"in e){var r=n.replace(a[0],e.unicode);o(r)}else o(n)})).catch((function(){o(n)})),U(!1)}else i?(t=i[0].replace(":",""),A.getEmojiBySearchQuery(t).then((function(r){r.length?(z(r.slice(0,e.maximumEmojiSearchResults)),U(!0)):(z([]),U(!1))})).catch((function(){z([]),U(!1)}))):U(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:B,color:"secondary",size:"small",InputProps:{endAdornment:(0,i.jsxs)(x(),{position:"end",className:"rustic-input-adornment",children:[(0,i.jsx)(T,{onEmojiClick:G,buttonColor:H}),e.enableSpeechToText&&K]})},InputLabelProps:{className:f?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,i.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,i.jsxs)(s(),{className:"rustic-input-actions",children:[e.children,(0,i.jsx)(F(),{title:"Send",children:(0,i.jsx)("span",{className:"rustic-send-button",children:(0,i.jsx)(h(),{"aria-label":"send message",onClick:Q,disabled:L,color:"secondary",children:(0,i.jsx)(q.A,{name:"send"})})})})]})]})}));D.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const z=D,_=require("@mui/material/LinearProgress");var M=o.n(_);const U=require("axios");var B=o.n(U);const L=require("react-dom"),W=require("@mui/material/Card");var H=o.n(W);const V=require("@mui/material/Modal");var $,G=o.n(V);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}($||($={}));const K=require("@mui/material/useMediaQuery");var Q=o.n(K);const Y=require("@mui/system/Stack");var Z=o.n(Y);const J=require("@mui/system/useTheme");var X=o.n(J);const ee=require("pdfjs-dist"),re=function(e){var r={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},n=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,i.jsx)(F(),{title:n.label,children:(0,i.jsx)("span",{children:(0,i.jsx)(h(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,i.jsx)(q.A,{name:n.symbol})})})})};var ne={pdf:function(e){var r,n=(0,u.useRef)(null),t=(0,u.useState)(1),o=t[0],a=t[1],c=(0,u.useState)(1),l=c[0],d=c[1],m=(0,u.useState)(1),p=m[0],f=m[1],h=(0,u.useState)(!1),v=h[0],x=h[1],g=(0,u.useState)(),b=g[0],j=g[1],y=X()(),w=Q()(y.breakpoints.down("sm")),C=Q()(y.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,i.jsx)(H(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(O(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var N=(0,u.useState)((function(){return w?.5:C?1:1.5})),S=N[0],F=N[1];return(0,u.useEffect)((function(){ee.GlobalWorkerOptions.workerSrc||(ee.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(ee.version,"/pdf.worker.mjs")),ee.getDocument({url:"".concat(e.url)}).promise.then((function(e){d(e.numPages),function(e){e.getPage(o).then((function(e){var r=e.getViewport({scale:S}),t=n.current;if(t){var o=t.getContext("2d");if(o){var a=window.devicePixelRatio||1;t.style.width="".concat(r.width,"px"),t.style.height="".concat(r.height,"px"),t.width=r.width*a,t.height=r.height*a;var i={canvasContext:o,viewport:r,transform:[a,0,0,a,0,0]};b&&b.cancel();var c=e.render(i);j(c),c.promise.then((function(){j(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){x(!0)}))}),[e.url,o,S]),v?(0,i.jsx)(H(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(O(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,i.jsxs)(H(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,i.jsxs)(s(),{className:"rustic-pdf-viewer-header",children:[(0,i.jsx)(re,{action:"zoomOut",onClick:function(){F((function(e){return Math.max(e-.2,.2)}))}}),(0,i.jsx)(re,{action:"zoomIn",onClick:function(){F((function(e){return e+.2}))}})]}),(0,i.jsx)(s(),{className:"rustic-pdf-viewer-body",children:(0,i.jsx)(s(),{className:"rustic-pdf-viewer-body-inner",children:(0,i.jsx)("canvas",{ref:n})})}),(0,i.jsxs)(Z(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,i.jsx)(re,{action:"previousPage",onClick:function(){o>1&&(a(o-1),f(o-1))},isDisabled:1===o}),(0,i.jsx)(O(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,i.jsx)(k(),{type:"number",value:p,onChange:function(e){var r=parseInt(e.target.value);f(r),!isNaN(r)&&r>=1&&r<=l&&a(r)},size:"small",className:"rustic-pdf-page-input"}),(0,i.jsxs)(O(),{variant:"body1",className:"rustic-page-indicator",children:["of ",l]}),(0,i.jsx)(re,{action:"nextPage",onClick:function(){o<l&&(a(o+1),f(o+1))},isDisabled:o===l})]})]})}};function te(e){var r=(0,l.useTheme)(),n=(0,u.useState)(!1),t=n[0],o=n[1];function a(){o(!1)}var c,s,d=e.file.url&&(c=e.file.url.split("."))[c.length-1].toLowerCase(),m=d&&e.supportedViewers?e.supportedViewers[d]:null,p=!!m,f=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",v=p?" rustic-cursor-pointer":"",x="rustic-file-preview ".concat(f).concat(v),g=e.showFullName?e.file.name:(15,(s=e.file.name).length<=15?s:s.substring(0,12)+"...");return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(H(),{className:x,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){o(!0)},children:[(0,i.jsx)(O(),{variant:"subtitle2",children:g}),(0,i.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,i.jsx)(G(),{open:t,onClose:a,className:"rustic-file-preview-modal",children:(0,i.jsxs)("div",{className:"rustic-modal-content",children:[(0,i.jsx)(F(),{title:"Close",children:(0,i.jsx)(h(),{onClick:a,className:"rustic-close-button",children:(0,i.jsx)(q.A,{name:"close"})})}),e.file.url&&(0,i.jsx)(m,{url:e.file.url})]})})]})}te.defaultProps={supportedViewers:ne};var oe=o(110);const ae=require("@mui/material"),ie=require("@mui/material/Button");var ce=o.n(ie);const se=require("@mui/material/Drawer");var le=o.n(se);const ue=require("@mui/material/ListItemText");var de=o.n(ue);const me=require("@mui/material/Menu");var pe=o.n(me);const fe=require("@mui/system");var he=function(){return he=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var o in r=arguments[n])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},he.apply(this,arguments)};function ve(e){var r=(0,u.useState)(!1),n=r[0],t=r[1],o=(0,u.useRef)(null),a=(0,l.useTheme)(),c=(0,ae.useMediaQuery)(a.breakpoints.down("md")),s=c?le():pe(),d={borderRadius:"".concat(a.shape.borderRadius,"px"),border:"1px solid ".concat(a.palette.divider)};function m(e){return(0,i.jsxs)(i.Fragment,{children:[e.startDecorator&&(0,i.jsx)(fe.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,i.jsx)(de(),{children:(0,i.jsx)(O(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,i.jsx)(fe.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}c&&(d=he(he({},d),{borderRadius:"".concat(a.shape.borderRadius,"px ").concat(a.shape.borderRadius,"px 0 0"),borderBottom:0}));var p=e.menuItems.map((function(e){return e.href?(0,i.jsx)(b(),{component:"a",onClick:function(){return t(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:m(e)},e.label):(0,i.jsx)(b(),{onClick:function(r){e.onClick&&e.onClick(r),t(!1)},disabled:!e.onClick,children:m(e)},e.label)}));var f,v,x=c?{}:{anchorEl:o.current};return(0,i.jsxs)(i.Fragment,{children:[(f={onClick:function(e){e.stopPropagation(),t(!0)},"aria-label":e.ariaLabel,ref:o,className:"rustic-popover-menu-button"},v=(0,i.jsx)(q.A,{name:"more_vert"}),e.buttonText?(0,i.jsx)(ce(),he({},f,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,i.jsx)(F(),{title:e.ariaLabel,children:(0,i.jsx)(h(),he({},f,{children:e.icon?e.icon:v}))})),(0,i.jsx)(s,he({open:n,onClose:function(){return t(!1)}},x,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":he(he({},d),{backgroundImage:"none",boxShadow:a.shadows[2]})},children:p}))]})}var xe=function(){return xe=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var o in r=arguments[n])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},xe.apply(this,arguments)},ge=function(e,r,n){if(n||2===arguments.length)for(var t,o=0,a=r.length;o<a;o++)!t&&o in r||(t||(t=Array.prototype.slice.call(r,0,o)),t[o]=r[o]);return e.concat(t||Array.prototype.slice.call(r))};function be(e){for(var r=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<r.length-1;)e/=1024,n++;var t=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(t," ").concat(r[n])}const je=function(e){var r,n=(0,u.useState)([]),t=n[0],o=n[1],a=(0,u.useState)([]),c=a[0],l=a[1],m=(0,u.useState)({}),p=m[0],f=m[1],v=(0,u.useRef)({}),x=(0,d.v4)();(0,u.useEffect)((function(){o([]),l([]),v.current={}}),[e.messageId]);var g=(0,i.jsx)(s(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,n){return(0,i.jsx)(te,{file:{name:r.name},showFullName:e.showFullName,children:(0,i.jsxs)(s(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,i.jsx)(M(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,i.jsx)(F(),{title:"Delete",children:(0,i.jsx)(h(),{color:"primary",onClick:function(){return function(r,n){var t,a;l([]);var i=r.name;if(v.current=xe(xe({},v.current),((t={})[i]=v.current[i]--,t)),e.onFileUpdate("remove",i),100===r.loadingProgress){var c="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);B().delete(c).then((function(){return o((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return e.onFileUpdate("add",i),l((function(e){return ge(ge([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)}))}))}else r.abortController.abort(),o((function(e){return e.filter((function(e,r){return r!==n}))})),v.current=xe(xe({},v.current),((a={})[i]=v.current[i]++,a))}(r,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,i.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)}))}),b=(0,i.jsx)(s(),{children:c.map((function(e,r){return(0,i.jsx)(O(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function j(e,r){return r?(0,L.createPortal)(e,r):e}var y=null===(r=e.uploadOptions)||void 0===r?void 0:r.map((function(r){return{label:r.label,onClick:function(){return function(r){f(r.metadata);var n=document.getElementById(x);n&&(n.accept=r.acceptedFileTypes||e.acceptedFileTypes),n.click()}(r)},startDecorator:r.iconName&&(0,i.jsx)(oe.default,{name:r.iconName})}}));return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(s(),{className:"rustic-uploader",children:[(0,i.jsx)("label",{htmlFor:x,children:(null==y?void 0:y.length)?(0,i.jsx)(ve,{ariaLabel:"Upload",icon:(0,i.jsx)(oe.default,{name:"upload_2"}),menuItems:y}):(0,i.jsx)(F(),{title:"Upload",children:(0,i.jsx)(h(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,i.jsx)("input",{type:"file",id:x,onChange:function(r){l([]);var n=r.target.files&&Array.from(r.target.files),a=t.length+(n?n.length:0);e.maxFileCount&&a>e.maxFileCount&&l((function(r){return ge(ge([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var i=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,a,e.maxFileCount);i&&i.forEach((function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,l((function(r){return ge(ge([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&be(e.maxFileSize),".")],!1)}))):function(r){var n=new FormData,t=new AbortController,a=function(e){var r,n,t=e.name,o=v.current[t];if(o){var a=o+1,i=t.lastIndexOf("."),c=t.substring(0,i),s=t.substring(i);t="".concat(c,"(").concat(o,")").concat(s),v.current=xe(xe({},v.current),((r={})[e.name]=a,r))}else v.current=xe(xe({},v.current),((n={})[e.name]=1,n));return t}(r),i=new File([r],a,{type:r.type});if(e.getUploadData||p){var c=e.getUploadData?e.getUploadData(a):{},s=xe(xe({},c),p);Object.keys(s).forEach((function(e){var r=s[e];n.append(e,"object"==typeof r?JSON.stringify(r):r)}))}n.append("file",i);var u=(0,d.v4)(),m={name:a,loadingProgress:0,abortController:t,id:u};o((function(e){return ge(ge([],e,!0),[m],!1)})),e.onFileUpdate("add",a);var f="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);B().post(f,n,{onUploadProgress:function(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=m.id,o((function(e){var t=e.map((function(e){return e.id===n?xe(xe({},e),{loadingProgress:r}):e}));return t})))},signal:t.signal}).then((function(e){var r,n;e.data.fileId&&(r=e.data,n=m.id,o((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var o=ge([],e,!0);return o[t]=xe(xe({},o[t]),{id:r.fileId}),o}return e})))})).catch((function(n){var t,i;e.onFileUpdate("remove",a),v.current=xe(xe({},v.current),((t={})[a]=v.current[r.name]--,t)),function(e,r,n){l((function(r){return ge(ge([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),o((function(e){return e.filter((function(e){return e.id!==r}))}))}(r.name,m.id,null===(i=n.response)||void 0===i?void 0:i.data)}))}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),c.length>0&&j(b,e.errorMessagesContainer),t.length>0&&j(g,e.filePreviewsContainer)]})};var ye=function(){return ye=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var o in r=arguments[n])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},ye.apply(this,arguments)},we=function(e,r,n){if(n||2===arguments.length)for(var t,o=0,a=r.length;o<a;o++)!t&&o in r||(t||(t=Array.prototype.slice.call(r,0,o)),t[o]=r[o]);return e.concat(t||Array.prototype.slice.call(r))};function Ce(e){var r=(0,u.useState)([]),n=r[0],t=r[1],o=(0,u.useState)((0,d.v4)()),a=o[0],c=o[1],m=(0,u.useState)(),p=m[0],f=m[1],h=(0,u.useState)(),v=h[0],x=h[1],g=(0,u.useRef)(null),b=(0,l.useTheme)(),j=n.length>0;return(0,u.useEffect)((function(){g.current&&(x(g.current.querySelector(".rustic-error-container")),f(g.current.querySelector(".rustic-input-extras")))})),(0,i.jsx)(s(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(b.palette.action.disabled),borderRadius:"".concat(b.shape.borderRadius,"px"),":focus-within":{borderColor:b.palette.secondary.main},background:b.palette.background.paper},children:(0,i.jsx)(z,ye({},e,{send:function(r){j&&(r.id=a,r.format="filesWithText",r.data.files=n),e.ws.send(r),c((0,d.v4)()),t([])},isSendEnabled:j,ref:g,children:(0,i.jsx)(s(),{className:"rustic-bottom-buttons",children:(0,i.jsx)(je,{acceptedFileTypes:e.acceptedFileTypes,maxFileCount:e.maxFileCount,maxFileSize:e.maxFileSize,uploadFileEndpoint:e.uploadFileEndpoint,deleteFileEndpoint:e.deleteFileEndpoint,onFileUpdate:function(e,r){t("add"===e?function(e){return we(we([],e,!0),[{name:r}],!1)}:function(e){return e.filter((function(e){return e.name!==r}))})},messageId:a,filePreviewsContainer:p,errorMessagesContainer:v,showFullName:e.showFullName,getUploadData:e.getUploadData,uploadOptions:e.uploadOptions})})}))})}Ce.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1};const Ne=Ce;return a})()));
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,n={767:(e,r,n)=>{n.d(r,{A:()=>o});var t=n(732),a=(n(15),function(){return a=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},a.apply(this,arguments)});function o(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:a({},r),children:e.name})}},110:(e,r,n)=>{n.d(r,{default:()=>t});const t=n(767).A},342:e=>{e.exports=require("emoji-picker-element")},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},t={};function a(e){var r=t[e];if(void 0!==r)return r.exports;var o=t[e]={exports:{}};return n[e](o,o.exports,a),o.exports}a.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return a.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(n,t){if(1&t&&(n=this(n)),8&t)return n;if("object"==typeof n&&n){if(4&t&&n.__esModule)return n;if(16&t&&"function"==typeof n.then)return n}var o=Object.create(null);a.r(o);var i={};e=e||[null,r({}),r([]),r(r)];for(var c=2&t&&n;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>i[e]=()=>n[e]));return i.default=()=>n,a.d(o,i),o},a.d=(e,r)=>{for(var n in r)a.o(r,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},a.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};a.r(o),a.d(o,{default:()=>Se});var i=a(732);const c=require("@mui/material/Box");var s=a.n(c);const l=require("@mui/material/styles");var u=a(15);const d=require("uuid"),m=require("@mui/material/CircularProgress");var p=a.n(m);const f=require("@mui/material/IconButton");var h=a.n(f);const v=require("@mui/material/InputAdornment");var x=a.n(v);const g=require("@mui/material/MenuItem");var b=a.n(g);const j=require("@mui/material/MenuList");var y=a.n(j);const w=require("@mui/material/Popover");var S=a.n(w);const F=require("@mui/material/TextField");var C=a.n(F);const N=require("@mui/material/Tooltip");var k=a.n(N);const P=require("@mui/material/Typography");var O=a.n(P),E=a(342),q=a(767);const T=function(e){var r=(0,l.useTheme)(),n=(0,u.useRef)(null),t=(0,u.useRef)(null),o=(0,u.useState)(!1),c=o[0],s=o[1],d={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function m(){s(!1)}function p(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),m()}return(0,u.useEffect)((function(){t.current||"undefined"==typeof window||Promise.resolve().then(a.t.bind(a,342,23)).then((function(n){var a=new(0,n.Picker)({dataSource:e.dataSource}),o="dark"===r.palette.mode?"dark":"light";a.classList.add(o),Object.keys(d).forEach((function(e){a.style.setProperty(e,d[e])})),t.current=a})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,u.useEffect)((function(){return t.current&&t.current.addEventListener("emoji-click",p),function(){var e;null===(e=t.current)||void 0===e||e.removeEventListener("emoji-click",p)}}),[c,e.onEmojiClick]),(0,i.jsxs)("div",{children:[(0,i.jsx)(k(),{title:"Emoji",children:(0,i.jsx)(h(),{size:"small",ref:n,onClick:function(){s((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)(q.A,{name:"Mood"})})}),t.current&&(0,i.jsx)(S(),{open:c,anchorEl:n.current,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,i.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&t.current&&!e.contains(t.current)&&e.appendChild(t.current)}})})]})};var I={"no-speech":"No speech detected. Check your microphone volume and try again.",aborted:"Speech input was aborted. Ensure no other windows are accessing your microphone and try again.","audio-capture":"Could not capture any audio. Check that your microphone is connected and try again.",network:"Failed to connect to the internet for recognition. Check your internet connection and try again.","not-allowed":"This functionality requires microphone access. Please allow microphone access and try again.","service-not-allowed":"Speech recognition service is not allowed, either because the browser doesn't support it or because of reasons of security, privacy or user preference.","bad-grammar":"There was an error in the speech recognition grammar or format. Check your speech input or grammar rules.","language-not-supported":"The language you're speaking isn't supported. Try speaking in a different language or check your device settings."};function R(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var D=(0,u.forwardRef)((function(e,r){var n=(0,u.useState)(""),t=n[0],a=n[1],o=(0,u.useState)(!1),c=o[0],l=o[1],m=(0,u.useState)(!1),f=m[0],v=m[1],g=(0,u.useState)(!1),j=g[0],w=g[1],F=(0,u.useState)(""),N=F[0],P=F[1],D=(0,u.useState)([]),A=D[0],z=D[1],_=(0,u.useState)(!1),M=_[0],U=_[1],B=(0,u.useRef)(null),L=new E.Database({dataSource:e.emojiDataSource}),W=!t.trim().length&&!e.isSendEnabled,$="".concat(c?"Stop":"Start"," speech to text"),H=f?"primary.main":"primary.light",V=c?"error.main":H,G=c?"stop_circle":"speech_to_text";function K(e,r){if(void 0===r&&(r=!1),B.current){var n=B.current,o=n.selectionStart,i=n.selectionEnd;if("number"==typeof o&&"number"==typeof i){var c,s=t||"",l=s.substring(0,o),u=s.substring(i);c=r?l.replace(/:(\w+)$/,e)+u:l+e+u,a(c);var d=r?l.replace(/:(\w+)$/,e).length:o+e.length;setTimeout((function(){var e,r;null===(e=B.current)||void 0===e||e.focus(),null===(r=B.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}U(!1)}var Q=j?(0,i.jsx)(p(),{size:24}):(0,i.jsx)(k(),{title:$,children:(0,i.jsx)(h(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,c?(e.stop(),w(!0),l(!1)):(e.start(),P(""),l(!0)),e.onstart=function(){l(!0)},e.onresult=function(e){var r,n=e.results[0][0].transcript;t.length>0?a(t+" "+n):a(n),null===(r=B.current)||void 0===r||r.focus(),l(!1)},e.onerror=function(e){var r=I[e.error];P(r),l(!1)},e.onend=function(){w(!1),l(!1)}},size:"small",sx:{color:V,"&:hover":{color:"primary.main"}},children:(0,i.jsx)(q.A,{name:G})})});function Y(){var r=(new Date).toISOString(),n={id:(0,d.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"text",data:{text:t}};e.send(n),a(""),P("")}return(0,i.jsxs)(s(),{className:"rustic-base-input",ref:r,children:[(0,i.jsxs)(s(),{className:"rustic-error-and-input-container",children:[(0,i.jsx)(s(),{className:"rustic-error-container",children:(0,i.jsx)(O(),{variant:"caption",color:"error",className:"rustic-error-message",children:N})}),(0,i.jsxs)(s(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:f?"secondary.main":"action.disabled"},children:[A.length>0&&(0,i.jsx)(S(),{open:M,anchorEl:B.current,onClose:function(){return U(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,i.jsx)(y(),{children:A.map((function(e,r){return"unicode"in e&&(0,i.jsx)(b(),{onClick:function(){return K(e.unicode,!0)},children:R(e)},r)}))})}),(0,i.jsx)(C(),{className:"rustic-text-field",variant:"outlined",value:t,label:e.label,placeholder:e.placeholder,maxRows:e.maxRows,multiline:e.multiline,fullWidth:e.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!W&&Y())},onChange:function(r){P("");var n=r.target.value;a(n);var t,o=n.match(/:(\w{2,}):/g),i=n.match(/:(\w{2,})/g);if(o){var c=o[0].replace(/:/g,"");L.getEmojiByShortcode(c).then((function(e){if(e&&"unicode"in e){var r=n.replace(o[0],e.unicode);a(r)}else a(n)})).catch((function(){a(n)})),U(!1)}else i?(t=i[0].replace(":",""),L.getEmojiBySearchQuery(t).then((function(r){r.length?(z(r.slice(0,e.maximumEmojiSearchResults)),U(!0)):(z([]),U(!1))})).catch((function(){z([]),U(!1)}))):U(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:B,color:"secondary",size:"small",InputProps:{endAdornment:(0,i.jsxs)(x(),{position:"end",className:"rustic-input-adornment",children:[(0,i.jsx)(T,{dataSource:e.emojiDataSource,onEmojiClick:K,buttonColor:H}),e.enableSpeechToText&&Q]})},InputLabelProps:{className:f?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,i.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,i.jsxs)(s(),{className:"rustic-input-actions",children:[e.children,(0,i.jsx)(k(),{title:"Send",children:(0,i.jsx)("span",{className:"rustic-send-button",children:(0,i.jsx)(h(),{"aria-label":"send message",onClick:Y,disabled:W,color:"secondary",children:(0,i.jsx)(q.A,{name:"send"})})})})]})]})}));D.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const A=D,z=require("@mui/material/LinearProgress");var _=a.n(z);const M=require("axios");var U=a.n(M);const B=require("react-dom"),L=require("@mui/material/Card");var W=a.n(L);const $=require("@mui/material/Modal");var H,V=a.n($);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(H||(H={}));const G=require("@mui/material/useMediaQuery");var K=a.n(G);const Q=require("@mui/system/Stack");var Y=a.n(Q);const Z=require("@mui/system/useTheme");var J=a.n(Z);const X=require("pdfjs-dist"),ee=function(e){var r={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},n=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,i.jsx)(k(),{title:n.label,children:(0,i.jsx)("span",{children:(0,i.jsx)(h(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,i.jsx)(q.A,{name:n.symbol})})})})};var re={pdf:function(e){var r,n=(0,u.useRef)(null),t=(0,u.useState)(1),a=t[0],o=t[1],c=(0,u.useState)(1),l=c[0],d=c[1],m=(0,u.useState)(1),p=m[0],f=m[1],h=(0,u.useState)(!1),v=h[0],x=h[1],g=(0,u.useState)(),b=g[0],j=g[1],y=J()(),w=K()(y.breakpoints.down("sm")),S=K()(y.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,i.jsx)(W(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(O(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var F=(0,u.useState)((function(){return w?.5:S?1:1.5})),N=F[0],k=F[1];return(0,u.useEffect)((function(){X.GlobalWorkerOptions.workerSrc||(X.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(X.version,"/pdf.worker.mjs")),X.getDocument({url:"".concat(e.url)}).promise.then((function(e){d(e.numPages),function(e){e.getPage(a).then((function(e){var r=e.getViewport({scale:N}),t=n.current;if(t){var a=t.getContext("2d");if(a){var o=window.devicePixelRatio||1;t.style.width="".concat(r.width,"px"),t.style.height="".concat(r.height,"px"),t.width=r.width*o,t.height=r.height*o;var i={canvasContext:a,viewport:r,transform:[o,0,0,o,0,0]};b&&b.cancel();var c=e.render(i);j(c),c.promise.then((function(){j(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){x(!0)}))}),[e.url,a,N]),v?(0,i.jsx)(W(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(O(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,i.jsxs)(W(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,i.jsxs)(s(),{className:"rustic-pdf-viewer-header",children:[(0,i.jsx)(ee,{action:"zoomOut",onClick:function(){k((function(e){return Math.max(e-.2,.2)}))}}),(0,i.jsx)(ee,{action:"zoomIn",onClick:function(){k((function(e){return e+.2}))}})]}),(0,i.jsx)(s(),{className:"rustic-pdf-viewer-body",children:(0,i.jsx)(s(),{className:"rustic-pdf-viewer-body-inner",children:(0,i.jsx)("canvas",{ref:n})})}),(0,i.jsxs)(Y(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,i.jsx)(ee,{action:"previousPage",onClick:function(){a>1&&(o(a-1),f(a-1))},isDisabled:1===a}),(0,i.jsx)(O(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,i.jsx)(C(),{type:"number",value:p,onChange:function(e){var r=parseInt(e.target.value);f(r),!isNaN(r)&&r>=1&&r<=l&&o(r)},size:"small",className:"rustic-pdf-page-input"}),(0,i.jsxs)(O(),{variant:"body1",className:"rustic-page-indicator",children:["of ",l]}),(0,i.jsx)(ee,{action:"nextPage",onClick:function(){a<l&&(o(a+1),f(a+1))},isDisabled:a===l})]})]})}};function ne(e){var r=(0,l.useTheme)(),n=(0,u.useState)(!1),t=n[0],a=n[1];function o(){a(!1)}var c,s,d=e.file.url&&(c=e.file.url.split("."))[c.length-1].toLowerCase(),m=d&&e.supportedViewers?e.supportedViewers[d]:null,p=!!m,f=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",v=p?" rustic-cursor-pointer":"",x="rustic-file-preview ".concat(f).concat(v),g=e.showFullName?e.file.name:(15,(s=e.file.name).length<=15?s:s.substring(0,12)+"...");return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(W(),{className:x,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){a(!0)},children:[(0,i.jsx)(O(),{variant:"subtitle2",children:g}),(0,i.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,i.jsx)(V(),{open:t,onClose:o,className:"rustic-file-preview-modal",children:(0,i.jsxs)("div",{className:"rustic-modal-content",children:[(0,i.jsx)(k(),{title:"Close",children:(0,i.jsx)(h(),{onClick:o,className:"rustic-close-button",children:(0,i.jsx)(q.A,{name:"close"})})}),e.file.url&&(0,i.jsx)(m,{url:e.file.url})]})})]})}ne.defaultProps={supportedViewers:re};var te=a(110);const ae=require("@mui/material"),oe=require("@mui/material/Button");var ie=a.n(oe);const ce=require("@mui/material/Drawer");var se=a.n(ce);const le=require("@mui/material/ListItemText");var ue=a.n(le);const de=require("@mui/material/Menu");var me=a.n(de);const pe=require("@mui/system");var fe=function(){return fe=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},fe.apply(this,arguments)};function he(e){var r=(0,u.useState)(!1),n=r[0],t=r[1],a=(0,u.useRef)(null),o=(0,l.useTheme)(),c=(0,ae.useMediaQuery)(o.breakpoints.down("md")),s=c?se():me(),d={borderRadius:"".concat(o.shape.borderRadius,"px"),border:"1px solid ".concat(o.palette.divider)};function m(e){return(0,i.jsxs)(i.Fragment,{children:[e.startDecorator&&(0,i.jsx)(pe.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,i.jsx)(ue(),{children:(0,i.jsx)(O(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,i.jsx)(pe.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}c&&(d=fe(fe({},d),{borderRadius:"".concat(o.shape.borderRadius,"px ").concat(o.shape.borderRadius,"px 0 0"),borderBottom:0}));var p=e.menuItems.map((function(e){return e.href?(0,i.jsx)(b(),{component:"a",onClick:function(){return t(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:m(e)},e.label):(0,i.jsx)(b(),{onClick:function(r){e.onClick&&e.onClick(r),t(!1)},disabled:!e.onClick,children:m(e)},e.label)}));var f,v,x=c?{}:{anchorEl:a.current};return(0,i.jsxs)(i.Fragment,{children:[(f={onClick:function(e){e.stopPropagation(),t(!0)},"aria-label":e.ariaLabel,ref:a,className:"rustic-popover-menu-button"},v=(0,i.jsx)(q.A,{name:"more_vert"}),e.buttonText?(0,i.jsx)(ie(),fe({},f,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,i.jsx)(k(),{title:e.ariaLabel,children:(0,i.jsx)(h(),fe({},f,{children:e.icon?e.icon:v}))})),(0,i.jsx)(s,fe({open:n,onClose:function(){return t(!1)}},x,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":fe(fe({},d),{backgroundImage:"none",boxShadow:o.shadows[2]})},children:p}))]})}var ve=function(){return ve=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},ve.apply(this,arguments)},xe=function(e,r,n){if(n||2===arguments.length)for(var t,a=0,o=r.length;a<o;a++)!t&&a in r||(t||(t=Array.prototype.slice.call(r,0,a)),t[a]=r[a]);return e.concat(t||Array.prototype.slice.call(r))};function ge(e){for(var r=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<r.length-1;)e/=1024,n++;var t=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(t," ").concat(r[n])}const be=function(e){var r,n=(0,u.useState)([]),t=n[0],a=n[1],o=(0,u.useState)([]),c=o[0],l=o[1],m=(0,u.useState)({}),p=m[0],f=m[1],v=(0,u.useRef)({}),x=(0,d.v4)();function g(e,r,n){var t;v.current=ve(ve({},v.current),((t={})[e]=v.current[e]--,t)),function(e,r,n){l((function(r){return xe(xe([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),a((function(e){return e.filter((function(e){return e.id!==r}))}))}(e,r,n)}(0,u.useEffect)((function(){a([]),l([]),v.current={}}),[e.messageId]);var b=(0,i.jsx)(s(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,n){return(0,i.jsx)(ne,{file:{name:r.name},showFullName:e.showFullName,children:(0,i.jsxs)(s(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,i.jsx)(_(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,i.jsx)(k(),{title:"Delete",children:(0,i.jsx)(h(),{color:"primary",onClick:function(){return function(r,n){var t,o;l([]);var i=r.name;if(v.current=ve(ve({},v.current),((t={})[i]=v.current[i]--,t)),e.onFileUpdate("remove",i),100===r.loadingProgress){var c="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);U().delete(c).then((function(){return a((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return e.onFileUpdate("add",i),l((function(e){return xe(xe([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)}))}))}else r.abortController.abort(),a((function(e){return e.filter((function(e,r){return r!==n}))})),v.current=ve(ve({},v.current),((o={})[i]=v.current[i]++,o))}(r,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,i.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)}))}),j=(0,i.jsx)(s(),{children:c.map((function(e,r){return(0,i.jsx)(O(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function y(e,r){return r?(0,B.createPortal)(e,r):e}var w=null===(r=e.uploadOptions)||void 0===r?void 0:r.map((function(r){return{label:r.label,onClick:function(){return function(r){f(r.metadata);var n=document.getElementById(x);n&&(n.accept=r.acceptedFileTypes||e.acceptedFileTypes),n.click()}(r)},startDecorator:r.iconName&&(0,i.jsx)(te.default,{name:r.iconName})}}));return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(s(),{className:"rustic-uploader",children:[(0,i.jsx)("label",{htmlFor:x,children:(null==w?void 0:w.length)?(0,i.jsx)(he,{ariaLabel:"Upload",icon:(0,i.jsx)(te.default,{name:"upload_2"}),menuItems:w}):(0,i.jsx)(k(),{title:"Upload",children:(0,i.jsx)(h(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,i.jsx)("input",{type:"file",id:x,onChange:function(r){l([]);var n=r.target.files&&Array.from(r.target.files),o=t.length+(n?n.length:0);e.maxFileCount&&o>e.maxFileCount&&l((function(r){return xe(xe([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var i=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,o,e.maxFileCount);i&&i.forEach((function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,l((function(r){return xe(xe([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&ge(e.maxFileSize),".")],!1)}))):function(r){var n=new FormData,t=new AbortController,o=function(e){var r,n,t=e.name,a=v.current[t];if(a){var o=a+1,i=t.lastIndexOf("."),c=t.substring(0,i),s=t.substring(i);t="".concat(c,"(").concat(a,")").concat(s),v.current=ve(ve({},v.current),((r={})[e.name]=o,r))}else v.current=ve(ve({},v.current),((n={})[e.name]=1,n));return t}(r),i=new File([r],o,{type:r.type});if(e.getUploadData||p){var c=e.getUploadData?e.getUploadData(o):{},s=ve(ve({},c),p);Object.keys(s).forEach((function(e){var r=s[e];n.append(e,"object"==typeof r?JSON.stringify(r):r)}))}n.append("file",i);var l=(0,d.v4)(),u={name:o,loadingProgress:0,abortController:t,id:l};function m(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=u.id,a((function(e){var t=e.map((function(e){return e.id===n?ve(ve({},e),{loadingProgress:r}):e}));return t})))}a((function(e){return xe(xe([],e,!0),[u],!1)})),e.onFileUpdate("add",o);var f="".concat(e.uploadFileEndpoint).replaceAll("fileName",o).replaceAll("messageId",e.messageId);!function i(){return U().post(f,n,{onUploadProgress:m,signal:t.signal}).then((function(e){var r,n;e.data.fileId&&(r=e.data,n=u.id,a((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var a=xe([],e,!0);return a[t]=ve(ve({},a[t]),{id:r.fileId}),a}return e})))})).catch((function(t){var c,s,d=n.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var m,p,f,h;409===(null===(c=t.response)||void 0===c?void 0:c.status)&&e.listFiles?(m=o.lastIndexOf("."),p=o.substring(0,m),f=o.substring(m),h=new RegExp("^".concat(p.replace(".","\\."),"(\\(\\d+\\))?").concat(f,"$"),"i"),e.listFiles?e.listFiles().then((function(e){for(var r=0,n=0,t=e;n<t.length;n++){var a=t[n];if(h.test(a.name)){var o=a.name.match(h),i=o&&o[1]?parseInt(o[1].slice(1,-1),10):0;r=Math.max(r,i)}}return"".concat(p,"(").concat(r+1,")").concat(f)})):Promise.resolve(o)).then((function(t){e.onFileUpdate("add",t);var o=new File([r],t,{type:r.type});n.set("file",o),a((function(e){return e.map((function(e){return e.id===l?ve(ve({},e),{name:t,loadingProgress:0}):e}))})),i()})).catch((function(){var e;g(r.name,u.id,null===(e=t.response)||void 0===e?void 0:e.data)})):g(r.name,u.id,null===(s=t.response)||void 0===s?void 0:s.data)}))}()}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),c.length>0&&y(j,e.errorMessagesContainer),t.length>0&&y(b,e.filePreviewsContainer)]})};var je=function(){return je=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},je.apply(this,arguments)},ye=function(e,r,n){if(n||2===arguments.length)for(var t,a=0,o=r.length;a<o;a++)!t&&a in r||(t||(t=Array.prototype.slice.call(r,0,a)),t[a]=r[a]);return e.concat(t||Array.prototype.slice.call(r))};function we(e){var r=(0,u.useState)([]),n=r[0],t=r[1],a=(0,u.useState)((0,d.v4)()),o=a[0],c=a[1],m=(0,u.useState)(),p=m[0],f=m[1],h=(0,u.useState)(),v=h[0],x=h[1],g=(0,u.useRef)(null),b=(0,l.useTheme)(),j=n.length>0;return(0,u.useEffect)((function(){g.current&&(x(g.current.querySelector(".rustic-error-container")),f(g.current.querySelector(".rustic-input-extras")))})),(0,i.jsx)(s(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(b.palette.action.disabled),borderRadius:"".concat(b.shape.borderRadius,"px"),":focus-within":{borderColor:b.palette.secondary.main},background:b.palette.background.paper},children:(0,i.jsx)(A,je({},e,{send:function(r){j&&(r.id=o,r.format="filesWithText",r.data.files=n),e.ws.send(r),c((0,d.v4)()),t([])},isSendEnabled:j,ref:g,children:(0,i.jsx)(s(),{className:"rustic-bottom-buttons",children:(0,i.jsx)(be,{acceptedFileTypes:e.acceptedFileTypes,maxFileCount:e.maxFileCount,maxFileSize:e.maxFileSize,uploadFileEndpoint:e.uploadFileEndpoint,deleteFileEndpoint:e.deleteFileEndpoint,onFileUpdate:function(e,r){t("add"===e?function(e){return ye(ye([],e,!0),[{name:r}],!1)}:function(e){return e.filter((function(e){return e.name!==r}))})},messageId:o,filePreviewsContainer:p,errorMessagesContainer:v,showFullName:e.showFullName,getUploadData:e.getUploadData,uploadOptions:e.uploadOptions,listFiles:e.listFiles})})}))})}we.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1};const Se=we;return o})()));
|
|
@@ -11,10 +11,10 @@ __How does file upload work?__
|
|
|
11
11
|
4. Once uploaded, the file names are appended to the data sent over WebSocket. Files can also be deleted after being uploaded and an HTTP API is sent to delete the file from storage.
|
|
12
12
|
5. The backend server of the application utilizes the uploaded files along with the text messages for message processing.
|
|
13
13
|
|
|
14
|
-
* **Note**: `emoji-picker-element` and `uuid` are not bundled, so please install the following packages using npm:
|
|
14
|
+
* **Note**: `emoji-picker-element`, `emoji-picker-element-data` and `uuid` are not bundled, so please install the following packages using npm:
|
|
15
15
|
*
|
|
16
16
|
* ```typescript
|
|
17
|
-
* npm i emoji-picker-element uuid
|
|
17
|
+
* npm i emoji-picker-element emoji-picker-element-data uuid
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
declare function MultimodalInput(props: MultimodalInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multimodalInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/multimodal/multimodalInput/multimodalInput.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAC9B,OAAO,uBAAuB,CAAA;AAQ9B,OAAO,KAAK,EAAqB,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAI7E;;;;;;;;;;;;;;;EAeE;AACF,iBAAwB,eAAe,CAAC,KAAK,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"multimodalInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/multimodal/multimodalInput/multimodalInput.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAC9B,OAAO,uBAAuB,CAAA;AAQ9B,OAAO,KAAK,EAAqB,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAI7E;;;;;;;;;;;;;;;EAeE;AACF,iBAAwB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CAoFlE;kBApFuB,eAAe;;;;;;;;;eAAf,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={767:(e,r,n)=>{n.d(r,{A:()=>o});var t=n(732),a=(n(15),function(){return a=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},a.apply(this,arguments)});function o(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:a({},r),children:e.name})}},110:(e,r,n)=>{n.d(r,{default:()=>t});const t=n(767).A},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},r={};function n(t){var a=r[t];if(void 0!==a)return a.exports;var o=r[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};n.r(t),n.d(t,{default:()=>te});var a=n(732);const o=require("@mui/material/Box");var i=n.n(o);const l=require("@mui/material/IconButton");var c=n.n(l);const s=require("@mui/material/LinearProgress");var u=n.n(s);const d=require("@mui/material/Tooltip");var m=n.n(d);const p=require("@mui/material/Typography");var f=n.n(p);const v=require("axios");var h=n.n(v),x=n(15);const g=require("react-dom"),b=require("uuid"),j=require("@mui/material/Card");var y=n.n(j);const w=require("@mui/material/Modal");var N=n.n(w);const C=require("@mui/material/styles");var F;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(F||(F={}));var P=n(767);const k=require("@mui/material/TextField");var S=n.n(k);const O=require("@mui/material/useMediaQuery");var q=n.n(O);const I=require("@mui/system/Stack");var D=n.n(I);const T=require("@mui/system/useTheme");var A=n.n(T);const M=require("pdfjs-dist"),U=function(e){var r={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},n=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,a.jsx)(m(),{title:n.label,children:(0,a.jsx)("span",{children:(0,a.jsx)(c(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,a.jsx)(P.A,{name:n.symbol})})})})};var _={pdf:function(e){var r,n=(0,x.useRef)(null),t=(0,x.useState)(1),o=t[0],l=t[1],c=(0,x.useState)(1),s=c[0],u=c[1],d=(0,x.useState)(1),m=d[0],p=d[1],v=(0,x.useState)(!1),h=v[0],g=v[1],b=(0,x.useState)(),j=b[0],w=b[1],N=A()(),C=q()(N.breakpoints.down("sm")),F=q()(N.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,a.jsx)(y(),{variant:"outlined",className:"rustic-pdf-error",children:(0,a.jsx)(f(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var P=(0,x.useState)((function(){return C?.5:F?1:1.5})),k=P[0],O=P[1];return(0,x.useEffect)((function(){M.GlobalWorkerOptions.workerSrc||(M.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(M.version,"/pdf.worker.mjs")),M.getDocument({url:"".concat(e.url)}).promise.then((function(e){u(e.numPages),function(e){e.getPage(o).then((function(e){var r=e.getViewport({scale:k}),t=n.current;if(t){var a=t.getContext("2d");if(a){var o=window.devicePixelRatio||1;t.style.width="".concat(r.width,"px"),t.style.height="".concat(r.height,"px"),t.width=r.width*o,t.height=r.height*o;var i={canvasContext:a,viewport:r,transform:[o,0,0,o,0,0]};j&&j.cancel();var l=e.render(i);w(l),l.promise.then((function(){w(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[e.url,o,k]),h?(0,a.jsx)(y(),{variant:"outlined",className:"rustic-pdf-error",children:(0,a.jsx)(f(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,a.jsxs)(y(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,a.jsxs)(i(),{className:"rustic-pdf-viewer-header",children:[(0,a.jsx)(U,{action:"zoomOut",onClick:function(){O((function(e){return Math.max(e-.2,.2)}))}}),(0,a.jsx)(U,{action:"zoomIn",onClick:function(){O((function(e){return e+.2}))}})]}),(0,a.jsx)(i(),{className:"rustic-pdf-viewer-body",children:(0,a.jsx)(i(),{className:"rustic-pdf-viewer-body-inner",children:(0,a.jsx)("canvas",{ref:n})})}),(0,a.jsxs)(D(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,a.jsx)(U,{action:"previousPage",onClick:function(){o>1&&(l(o-1),p(o-1))},isDisabled:1===o}),(0,a.jsx)(f(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,a.jsx)(S(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=s&&l(r)},size:"small",className:"rustic-pdf-page-input"}),(0,a.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,a.jsx)(U,{action:"nextPage",onClick:function(){o<s&&(l(o+1),p(o+1))},isDisabled:o===s})]})]})}};function z(e){var r=(0,C.useTheme)(),n=(0,x.useState)(!1),t=n[0],o=n[1];function i(){o(!1)}var l,s,u=e.file.url&&(l=e.file.url.split("."))[l.length-1].toLowerCase(),d=u&&e.supportedViewers?e.supportedViewers[u]:null,p=!!d,v=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",h=p?" rustic-cursor-pointer":"",g="rustic-file-preview ".concat(v).concat(h),b=e.showFullName?e.file.name:(15,(s=e.file.name).length<=15?s:s.substring(0,12)+"...");return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(y(),{className:g,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){o(!0)},children:[(0,a.jsx)(f(),{variant:"subtitle2",children:b}),(0,a.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,a.jsx)(N(),{open:t,onClose:i,className:"rustic-file-preview-modal",children:(0,a.jsxs)("div",{className:"rustic-modal-content",children:[(0,a.jsx)(m(),{title:"Close",children:(0,a.jsx)(c(),{onClick:i,className:"rustic-close-button",children:(0,a.jsx)(P.A,{name:"close"})})}),e.file.url&&(0,a.jsx)(d,{url:e.file.url})]})})]})}z.defaultProps={supportedViewers:_};var R=n(110);const B=require("@mui/material"),E=require("@mui/material/Button");var L=n.n(E);const H=require("@mui/material/Drawer");var V=n.n(H);const G=require("@mui/material/ListItemText");var Q=n.n(G);const W=require("@mui/material/Menu");var Y=n.n(W);const Z=require("@mui/material/MenuItem");var $=n.n(Z);const J=require("@mui/system");var K=function(){return K=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},K.apply(this,arguments)};function X(e){var r=(0,x.useState)(!1),n=r[0],t=r[1],o=(0,x.useRef)(null),i=(0,C.useTheme)(),l=(0,B.useMediaQuery)(i.breakpoints.down("md")),s=l?V():Y(),u={borderRadius:"".concat(i.shape.borderRadius,"px"),border:"1px solid ".concat(i.palette.divider)};function d(e){return(0,a.jsxs)(a.Fragment,{children:[e.startDecorator&&(0,a.jsx)(J.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,a.jsx)(Q(),{children:(0,a.jsx)(f(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,a.jsx)(J.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}l&&(u=K(K({},u),{borderRadius:"".concat(i.shape.borderRadius,"px ").concat(i.shape.borderRadius,"px 0 0"),borderBottom:0}));var p=e.menuItems.map((function(e){return e.href?(0,a.jsx)($(),{component:"a",onClick:function(){return t(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:d(e)},e.label):(0,a.jsx)($(),{onClick:function(r){e.onClick&&e.onClick(r),t(!1)},disabled:!e.onClick,children:d(e)},e.label)}));var v,h,g=l?{}:{anchorEl:o.current};return(0,a.jsxs)(a.Fragment,{children:[(v={onClick:function(e){e.stopPropagation(),t(!0)},"aria-label":e.ariaLabel,ref:o,className:"rustic-popover-menu-button"},h=(0,a.jsx)(P.A,{name:"more_vert"}),e.buttonText?(0,a.jsx)(L(),K({},v,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,a.jsx)(m(),{title:e.ariaLabel,children:(0,a.jsx)(c(),K({},v,{children:e.icon?e.icon:h}))})),(0,a.jsx)(s,K({open:n,onClose:function(){return t(!1)}},g,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":K(K({},u),{backgroundImage:"none",boxShadow:i.shadows[2]})},children:p}))]})}var ee=function(){return ee=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},ee.apply(this,arguments)},re=function(e,r,n){if(n||2===arguments.length)for(var t,a=0,o=r.length;a<o;a++)!t&&a in r||(t||(t=Array.prototype.slice.call(r,0,a)),t[a]=r[a]);return e.concat(t||Array.prototype.slice.call(r))};function ne(e){for(var r=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<r.length-1;)e/=1024,n++;var t=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(t," ").concat(r[n])}const te=function(e){var r,n=(0,x.useState)([]),t=n[0],o=n[1],l=(0,x.useState)([]),s=l[0],d=l[1],p=(0,x.useState)({}),v=p[0],j=p[1],y=(0,x.useRef)({}),w=(0,b.v4)();(0,x.useEffect)((function(){o([]),d([]),y.current={}}),[e.messageId]);var N=(0,a.jsx)(i(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,n){return(0,a.jsx)(z,{file:{name:r.name},showFullName:e.showFullName,children:(0,a.jsxs)(i(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,a.jsx)(u(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,a.jsx)(m(),{title:"Delete",children:(0,a.jsx)(c(),{color:"primary",onClick:function(){return function(r,n){var t,a;d([]);var i=r.name;if(y.current=ee(ee({},y.current),((t={})[i]=y.current[i]--,t)),e.onFileUpdate("remove",i),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);h().delete(l).then((function(){return o((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return e.onFileUpdate("add",i),d((function(e){return re(re([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)}))}))}else r.abortController.abort(),o((function(e){return e.filter((function(e,r){return r!==n}))})),y.current=ee(ee({},y.current),((a={})[i]=y.current[i]++,a))}(r,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,a.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)}))}),C=(0,a.jsx)(i(),{children:s.map((function(e,r){return(0,a.jsx)(f(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function F(e,r){return r?(0,g.createPortal)(e,r):e}var P=null===(r=e.uploadOptions)||void 0===r?void 0:r.map((function(r){return{label:r.label,onClick:function(){return function(r){j(r.metadata);var n=document.getElementById(w);n&&(n.accept=r.acceptedFileTypes||e.acceptedFileTypes),n.click()}(r)},startDecorator:r.iconName&&(0,a.jsx)(R.default,{name:r.iconName})}}));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i(),{className:"rustic-uploader",children:[(0,a.jsx)("label",{htmlFor:w,children:(null==P?void 0:P.length)?(0,a.jsx)(X,{ariaLabel:"Upload",icon:(0,a.jsx)(R.default,{name:"upload_2"}),menuItems:P}):(0,a.jsx)(m(),{title:"Upload",children:(0,a.jsx)(c(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,a.jsx)("input",{type:"file",id:w,onChange:function(r){d([]);var n=r.target.files&&Array.from(r.target.files),a=t.length+(n?n.length:0);e.maxFileCount&&a>e.maxFileCount&&d((function(r){return re(re([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var i=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,a,e.maxFileCount);i&&i.forEach((function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,d((function(r){return re(re([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&ne(e.maxFileSize),".")],!1)}))):function(r){var n=new FormData,t=new AbortController,a=function(e){var r,n,t=e.name,a=y.current[t];if(a){var o=a+1,i=t.lastIndexOf("."),l=t.substring(0,i),c=t.substring(i);t="".concat(l,"(").concat(a,")").concat(c),y.current=ee(ee({},y.current),((r={})[e.name]=o,r))}else y.current=ee(ee({},y.current),((n={})[e.name]=1,n));return t}(r),i=new File([r],a,{type:r.type});if(e.getUploadData||v){var l=e.getUploadData?e.getUploadData(a):{},c=ee(ee({},l),v);Object.keys(c).forEach((function(e){var r=c[e];n.append(e,"object"==typeof r?JSON.stringify(r):r)}))}n.append("file",i);var s=(0,b.v4)(),u={name:a,loadingProgress:0,abortController:t,id:s};o((function(e){return re(re([],e,!0),[u],!1)})),e.onFileUpdate("add",a);var m="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);h().post(m,n,{onUploadProgress:function(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=u.id,o((function(e){var t=e.map((function(e){return e.id===n?ee(ee({},e),{loadingProgress:r}):e}));return t})))},signal:t.signal}).then((function(e){var r,n;e.data.fileId&&(r=e.data,n=u.id,o((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var a=re([],e,!0);return a[t]=ee(ee({},a[t]),{id:r.fileId}),a}return e})))})).catch((function(n){var t,i;e.onFileUpdate("remove",a),y.current=ee(ee({},y.current),((t={})[a]=y.current[r.name]--,t)),function(e,r,n){d((function(r){return re(re([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),o((function(e){return e.filter((function(e){return e.id!==r}))}))}(r.name,u.id,null===(i=n.response)||void 0===i?void 0:i.data)}))}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),s.length>0&&F(C,e.errorMessagesContainer),t.length>0&&F(N,e.filePreviewsContainer)]})};return t})()));
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={767:(e,r,n)=>{n.d(r,{A:()=>o});var t=n(732),a=(n(15),function(){return a=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},a.apply(this,arguments)});function o(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:a({},r),children:e.name})}},110:(e,r,n)=>{n.d(r,{default:()=>t});const t=n(767).A},15:e=>{e.exports=require("react")},732:e=>{e.exports=require("react/jsx-runtime")}},r={};function n(t){var a=r[t];if(void 0!==a)return a.exports;var o=r[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};n.r(t),n.d(t,{default:()=>te});var a=n(732);const o=require("@mui/material/Box");var i=n.n(o);const l=require("@mui/material/IconButton");var c=n.n(l);const s=require("@mui/material/LinearProgress");var u=n.n(s);const d=require("@mui/material/Tooltip");var m=n.n(d);const p=require("@mui/material/Typography");var f=n.n(p);const v=require("axios");var h=n.n(v),x=n(15);const g=require("react-dom"),b=require("uuid"),j=require("@mui/material/Card");var y=n.n(j);const w=require("@mui/material/Modal");var N=n.n(w);const F=require("@mui/material/styles");var C;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(C||(C={}));var P=n(767);const k=require("@mui/material/TextField");var O=n.n(k);const S=require("@mui/material/useMediaQuery");var q=n.n(S);const I=require("@mui/system/Stack");var D=n.n(I);const T=require("@mui/system/useTheme");var A=n.n(T);const M=require("pdfjs-dist"),U=function(e){var r={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},n=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,a.jsx)(m(),{title:n.label,children:(0,a.jsx)("span",{children:(0,a.jsx)(c(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,a.jsx)(P.A,{name:n.symbol})})})})};var _={pdf:function(e){var r,n=(0,x.useRef)(null),t=(0,x.useState)(1),o=t[0],l=t[1],c=(0,x.useState)(1),s=c[0],u=c[1],d=(0,x.useState)(1),m=d[0],p=d[1],v=(0,x.useState)(!1),h=v[0],g=v[1],b=(0,x.useState)(),j=b[0],w=b[1],N=A()(),F=q()(N.breakpoints.down("sm")),C=q()(N.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,a.jsx)(y(),{variant:"outlined",className:"rustic-pdf-error",children:(0,a.jsx)(f(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var P=(0,x.useState)((function(){return F?.5:C?1:1.5})),k=P[0],S=P[1];return(0,x.useEffect)((function(){M.GlobalWorkerOptions.workerSrc||(M.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(M.version,"/pdf.worker.mjs")),M.getDocument({url:"".concat(e.url)}).promise.then((function(e){u(e.numPages),function(e){e.getPage(o).then((function(e){var r=e.getViewport({scale:k}),t=n.current;if(t){var a=t.getContext("2d");if(a){var o=window.devicePixelRatio||1;t.style.width="".concat(r.width,"px"),t.style.height="".concat(r.height,"px"),t.width=r.width*o,t.height=r.height*o;var i={canvasContext:a,viewport:r,transform:[o,0,0,o,0,0]};j&&j.cancel();var l=e.render(i);w(l),l.promise.then((function(){w(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[e.url,o,k]),h?(0,a.jsx)(y(),{variant:"outlined",className:"rustic-pdf-error",children:(0,a.jsx)(f(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,a.jsxs)(y(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,a.jsxs)(i(),{className:"rustic-pdf-viewer-header",children:[(0,a.jsx)(U,{action:"zoomOut",onClick:function(){S((function(e){return Math.max(e-.2,.2)}))}}),(0,a.jsx)(U,{action:"zoomIn",onClick:function(){S((function(e){return e+.2}))}})]}),(0,a.jsx)(i(),{className:"rustic-pdf-viewer-body",children:(0,a.jsx)(i(),{className:"rustic-pdf-viewer-body-inner",children:(0,a.jsx)("canvas",{ref:n})})}),(0,a.jsxs)(D(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,a.jsx)(U,{action:"previousPage",onClick:function(){o>1&&(l(o-1),p(o-1))},isDisabled:1===o}),(0,a.jsx)(f(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,a.jsx)(O(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=s&&l(r)},size:"small",className:"rustic-pdf-page-input"}),(0,a.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,a.jsx)(U,{action:"nextPage",onClick:function(){o<s&&(l(o+1),p(o+1))},isDisabled:o===s})]})]})}};function R(e){var r=(0,F.useTheme)(),n=(0,x.useState)(!1),t=n[0],o=n[1];function i(){o(!1)}var l,s,u=e.file.url&&(l=e.file.url.split("."))[l.length-1].toLowerCase(),d=u&&e.supportedViewers?e.supportedViewers[u]:null,p=!!d,v=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",h=p?" rustic-cursor-pointer":"",g="rustic-file-preview ".concat(v).concat(h),b=e.showFullName?e.file.name:(15,(s=e.file.name).length<=15?s:s.substring(0,12)+"...");return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(y(),{className:g,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){o(!0)},children:[(0,a.jsx)(f(),{variant:"subtitle2",children:b}),(0,a.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,a.jsx)(N(),{open:t,onClose:i,className:"rustic-file-preview-modal",children:(0,a.jsxs)("div",{className:"rustic-modal-content",children:[(0,a.jsx)(m(),{title:"Close",children:(0,a.jsx)(c(),{onClick:i,className:"rustic-close-button",children:(0,a.jsx)(P.A,{name:"close"})})}),e.file.url&&(0,a.jsx)(d,{url:e.file.url})]})})]})}R.defaultProps={supportedViewers:_};var z=n(110);const B=require("@mui/material"),E=require("@mui/material/Button");var L=n.n(E);const H=require("@mui/material/Drawer");var V=n.n(H);const G=require("@mui/material/ListItemText");var $=n.n(G);const Q=require("@mui/material/Menu");var W=n.n(Q);const Y=require("@mui/material/MenuItem");var Z=n.n(Y);const J=require("@mui/system");var K=function(){return K=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},K.apply(this,arguments)};function X(e){var r=(0,x.useState)(!1),n=r[0],t=r[1],o=(0,x.useRef)(null),i=(0,F.useTheme)(),l=(0,B.useMediaQuery)(i.breakpoints.down("md")),s=l?V():W(),u={borderRadius:"".concat(i.shape.borderRadius,"px"),border:"1px solid ".concat(i.palette.divider)};function d(e){return(0,a.jsxs)(a.Fragment,{children:[e.startDecorator&&(0,a.jsx)(J.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,a.jsx)($(),{children:(0,a.jsx)(f(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,a.jsx)(J.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}l&&(u=K(K({},u),{borderRadius:"".concat(i.shape.borderRadius,"px ").concat(i.shape.borderRadius,"px 0 0"),borderBottom:0}));var p=e.menuItems.map((function(e){return e.href?(0,a.jsx)(Z(),{component:"a",onClick:function(){return t(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:d(e)},e.label):(0,a.jsx)(Z(),{onClick:function(r){e.onClick&&e.onClick(r),t(!1)},disabled:!e.onClick,children:d(e)},e.label)}));var v,h,g=l?{}:{anchorEl:o.current};return(0,a.jsxs)(a.Fragment,{children:[(v={onClick:function(e){e.stopPropagation(),t(!0)},"aria-label":e.ariaLabel,ref:o,className:"rustic-popover-menu-button"},h=(0,a.jsx)(P.A,{name:"more_vert"}),e.buttonText?(0,a.jsx)(L(),K({},v,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,a.jsx)(m(),{title:e.ariaLabel,children:(0,a.jsx)(c(),K({},v,{children:e.icon?e.icon:h}))})),(0,a.jsx)(s,K({open:n,onClose:function(){return t(!1)}},g,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":K(K({},u),{backgroundImage:"none",boxShadow:i.shadows[2]})},children:p}))]})}var ee=function(){return ee=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},ee.apply(this,arguments)},re=function(e,r,n){if(n||2===arguments.length)for(var t,a=0,o=r.length;a<o;a++)!t&&a in r||(t||(t=Array.prototype.slice.call(r,0,a)),t[a]=r[a]);return e.concat(t||Array.prototype.slice.call(r))};function ne(e){for(var r=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<r.length-1;)e/=1024,n++;var t=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(t," ").concat(r[n])}const te=function(e){var r,n=(0,x.useState)([]),t=n[0],o=n[1],l=(0,x.useState)([]),s=l[0],d=l[1],p=(0,x.useState)({}),v=p[0],j=p[1],y=(0,x.useRef)({}),w=(0,b.v4)();function N(e,r,n){var t;y.current=ee(ee({},y.current),((t={})[e]=y.current[e]--,t)),function(e,r,n){d((function(r){return re(re([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),o((function(e){return e.filter((function(e){return e.id!==r}))}))}(e,r,n)}(0,x.useEffect)((function(){o([]),d([]),y.current={}}),[e.messageId]);var F=(0,a.jsx)(i(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,n){return(0,a.jsx)(R,{file:{name:r.name},showFullName:e.showFullName,children:(0,a.jsxs)(i(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,a.jsx)(u(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,a.jsx)(m(),{title:"Delete",children:(0,a.jsx)(c(),{color:"primary",onClick:function(){return function(r,n){var t,a;d([]);var i=r.name;if(y.current=ee(ee({},y.current),((t={})[i]=y.current[i]--,t)),e.onFileUpdate("remove",i),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);h().delete(l).then((function(){return o((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return e.onFileUpdate("add",i),d((function(e){return re(re([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)}))}))}else r.abortController.abort(),o((function(e){return e.filter((function(e,r){return r!==n}))})),y.current=ee(ee({},y.current),((a={})[i]=y.current[i]++,a))}(r,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,a.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)}))}),C=(0,a.jsx)(i(),{children:s.map((function(e,r){return(0,a.jsx)(f(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function P(e,r){return r?(0,g.createPortal)(e,r):e}var k=null===(r=e.uploadOptions)||void 0===r?void 0:r.map((function(r){return{label:r.label,onClick:function(){return function(r){j(r.metadata);var n=document.getElementById(w);n&&(n.accept=r.acceptedFileTypes||e.acceptedFileTypes),n.click()}(r)},startDecorator:r.iconName&&(0,a.jsx)(z.default,{name:r.iconName})}}));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i(),{className:"rustic-uploader",children:[(0,a.jsx)("label",{htmlFor:w,children:(null==k?void 0:k.length)?(0,a.jsx)(X,{ariaLabel:"Upload",icon:(0,a.jsx)(z.default,{name:"upload_2"}),menuItems:k}):(0,a.jsx)(m(),{title:"Upload",children:(0,a.jsx)(c(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,a.jsx)("input",{type:"file",id:w,onChange:function(r){d([]);var n=r.target.files&&Array.from(r.target.files),a=t.length+(n?n.length:0);e.maxFileCount&&a>e.maxFileCount&&d((function(r){return re(re([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var i=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,a,e.maxFileCount);i&&i.forEach((function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,d((function(r){return re(re([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&ne(e.maxFileSize),".")],!1)}))):function(r){var n=new FormData,t=new AbortController,a=function(e){var r,n,t=e.name,a=y.current[t];if(a){var o=a+1,i=t.lastIndexOf("."),l=t.substring(0,i),c=t.substring(i);t="".concat(l,"(").concat(a,")").concat(c),y.current=ee(ee({},y.current),((r={})[e.name]=o,r))}else y.current=ee(ee({},y.current),((n={})[e.name]=1,n));return t}(r),i=new File([r],a,{type:r.type});if(e.getUploadData||v){var l=e.getUploadData?e.getUploadData(a):{},c=ee(ee({},l),v);Object.keys(c).forEach((function(e){var r=c[e];n.append(e,"object"==typeof r?JSON.stringify(r):r)}))}n.append("file",i);var s=(0,b.v4)(),u={name:a,loadingProgress:0,abortController:t,id:s};function d(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=u.id,o((function(e){var t=e.map((function(e){return e.id===n?ee(ee({},e),{loadingProgress:r}):e}));return t})))}o((function(e){return re(re([],e,!0),[u],!1)})),e.onFileUpdate("add",a);var m="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);!function i(){return h().post(m,n,{onUploadProgress:d,signal:t.signal}).then((function(e){var r,n;e.data.fileId&&(r=e.data,n=u.id,o((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var a=re([],e,!0);return a[t]=ee(ee({},a[t]),{id:r.fileId}),a}return e})))})).catch((function(t){var l,c,d=n.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var m,p,f,v;409===(null===(l=t.response)||void 0===l?void 0:l.status)&&e.listFiles?(m=a.lastIndexOf("."),p=a.substring(0,m),f=a.substring(m),v=new RegExp("^".concat(p.replace(".","\\."),"(\\(\\d+\\))?").concat(f,"$"),"i"),e.listFiles?e.listFiles().then((function(e){for(var r=0,n=0,t=e;n<t.length;n++){var a=t[n];if(v.test(a.name)){var o=a.name.match(v),i=o&&o[1]?parseInt(o[1].slice(1,-1),10):0;r=Math.max(r,i)}}return"".concat(p,"(").concat(r+1,")").concat(f)})):Promise.resolve(a)).then((function(t){e.onFileUpdate("add",t);var a=new File([r],t,{type:r.type});n.set("file",a),o((function(e){return e.map((function(e){return e.id===s?ee(ee({},e),{name:t,loadingProgress:0}):e}))})),i()})).catch((function(){var e;N(r.name,u.id,null===(e=t.response)||void 0===e?void 0:e.data)})):N(r.name,u.id,null===(c=t.response)||void 0===c?void 0:c.data)}))}()}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),s.length>0&&P(C,e.errorMessagesContainer),t.length>0&&P(F,e.filePreviewsContainer)]})};return t})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/multimodal/uploader/uploader.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AAgBvB,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,gBAAgB,CAAA;AAWjE,wBAAgB,aAAa,CAC3B,KAAK,EAAE,IAAI,EAAE,EACb,cAAc,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,EAAE,GAAG,SAAS,CAUpB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAYvD;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/multimodal/uploader/uploader.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AAgBvB,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,gBAAgB,CAAA;AAWjE,wBAAgB,aAAa,CAC3B,KAAK,EAAE,IAAI,EAAE,EACb,cAAc,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,EAAE,GAAG,SAAS,CAUpB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAYvD;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAgbrC;AACD,eAAe,QAAQ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,t={342:e=>{e.exports=require("emoji-picker-element")}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var i=Object.create(null);o.r(i);var a={};e=e||[null,r({}),r([]),r(r)];for(var c=2&n&&t;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,o.d(i,a),i},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};o.r(i),o.d(i,{default:()=>
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,t={342:e=>{e.exports=require("emoji-picker-element")}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var i=Object.create(null);o.r(i);var a={};e=e||[null,r({}),r([]),r(r)];for(var c=2&n&&t;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,o.d(i,a),i},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};o.r(i),o.d(i,{default:()=>F});const a=require("react/jsx-runtime"),c=require("react"),s=require("@mui/material/Box");var u=o.n(s);const l=require("@mui/material/CircularProgress");var d=o.n(l);const p=require("@mui/material/IconButton");var m=o.n(p);const f=require("@mui/material/InputAdornment");var h=o.n(f);const v=require("@mui/material/MenuItem");var y=o.n(v);const g=require("@mui/material/MenuList");var b=o.n(g);const j=require("@mui/material/Popover");var x=o.n(j);const S=require("@mui/material/TextField");var w=o.n(S);const O=require("@mui/material/Tooltip");var k=o.n(O);const E=require("@mui/material/Typography");var P=o.n(E),C=o(342);const N=require("uuid");var q=function(){return q=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},q.apply(this,arguments)};function T(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,a.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:q({},r),children:e.name})}const _=require("@mui/material/styles"),R=function(e){var r=(0,_.useTheme)(),t=(0,c.useRef)(null),n=(0,c.useRef)(null),i=(0,c.useState)(!1),s=i[0],u=i[1],l={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function d(){u(!1)}function p(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),d()}return(0,c.useEffect)((function(){n.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,342,23)).then((function(t){var o=new(0,t.Picker)({dataSource:e.dataSource}),i="dark"===r.palette.mode?"dark":"light";o.classList.add(i),Object.keys(l).forEach((function(e){o.style.setProperty(e,l[e])})),n.current=o})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,c.useEffect)((function(){return n.current&&n.current.addEventListener("emoji-click",p),function(){var e;null===(e=n.current)||void 0===e||e.removeEventListener("emoji-click",p)}}),[s,e.onEmojiClick]),(0,a.jsxs)("div",{children:[(0,a.jsx)(k(),{title:"Emoji",children:(0,a.jsx)(m(),{size:"small",ref:t,onClick:function(){u((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)(T,{name:"Mood"})})}),n.current&&(0,a.jsx)(x(),{open:s,anchorEl:t.current,onClose:d,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,a.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&n.current&&!e.contains(n.current)&&e.appendChild(n.current)}})})]})};var I={"no-speech":"No speech detected. Check your microphone volume and try again.",aborted:"Speech input was aborted. Ensure no other windows are accessing your microphone and try again.","audio-capture":"Could not capture any audio. Check that your microphone is connected and try again.",network:"Failed to connect to the internet for recognition. Check your internet connection and try again.","not-allowed":"This functionality requires microphone access. Please allow microphone access and try again.","service-not-allowed":"Speech recognition service is not allowed, either because the browser doesn't support it or because of reasons of security, privacy or user preference.","bad-grammar":"There was an error in the speech recognition grammar or format. Check your speech input or grammar rules.","language-not-supported":"The language you're speaking isn't supported. Try speaking in a different language or check your device settings."};function z(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var M=(0,c.forwardRef)((function(e,r){var t=(0,c.useState)(""),n=t[0],o=t[1],i=(0,c.useState)(!1),s=i[0],l=i[1],p=(0,c.useState)(!1),f=p[0],v=p[1],g=(0,c.useState)(!1),j=g[0],S=g[1],O=(0,c.useState)(""),E=O[0],q=O[1],_=(0,c.useState)([]),M=_[0],D=_[1],B=(0,c.useState)(!1),F=B[0],L=B[1],A=(0,c.useRef)(null),W=new C.Database({dataSource:e.emojiDataSource}),K=!n.trim().length&&!e.isSendEnabled,$="".concat(s?"Stop":"Start"," speech to text"),Q=f?"primary.main":"primary.light",G=s?"error.main":Q,H=s?"stop_circle":"speech_to_text";function J(e,r){if(void 0===r&&(r=!1),A.current){var t=A.current,i=t.selectionStart,a=t.selectionEnd;if("number"==typeof i&&"number"==typeof a){var c,s=n||"",u=s.substring(0,i),l=s.substring(a);c=r?u.replace(/:(\w+)$/,e)+l:u+e+l,o(c);var d=r?u.replace(/:(\w+)$/,e).length:i+e.length;setTimeout((function(){var e,r;null===(e=A.current)||void 0===e||e.focus(),null===(r=A.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}L(!1)}var U=j?(0,a.jsx)(d(),{size:24}):(0,a.jsx)(k(),{title:$,children:(0,a.jsx)(m(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,s?(e.stop(),S(!0),l(!1)):(e.start(),q(""),l(!0)),e.onstart=function(){l(!0)},e.onresult=function(e){var r,t=e.results[0][0].transcript;n.length>0?o(n+" "+t):o(t),null===(r=A.current)||void 0===r||r.focus(),l(!1)},e.onerror=function(e){var r=I[e.error];q(r),l(!1)},e.onend=function(){S(!1),l(!1)}},size:"small",sx:{color:G,"&:hover":{color:"primary.main"}},children:(0,a.jsx)(T,{name:H})})});function V(){var r=(new Date).toISOString(),t={id:(0,N.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"text",data:{text:n}};e.send(t),o(""),q("")}return(0,a.jsxs)(u(),{className:"rustic-base-input",ref:r,children:[(0,a.jsxs)(u(),{className:"rustic-error-and-input-container",children:[(0,a.jsx)(u(),{className:"rustic-error-container",children:(0,a.jsx)(P(),{variant:"caption",color:"error",className:"rustic-error-message",children:E})}),(0,a.jsxs)(u(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:f?"secondary.main":"action.disabled"},children:[M.length>0&&(0,a.jsx)(x(),{open:F,anchorEl:A.current,onClose:function(){return L(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,a.jsx)(b(),{children:M.map((function(e,r){return"unicode"in e&&(0,a.jsx)(y(),{onClick:function(){return J(e.unicode,!0)},children:z(e)},r)}))})}),(0,a.jsx)(w(),{className:"rustic-text-field",variant:"outlined",value:n,label:e.label,placeholder:e.placeholder,maxRows:e.maxRows,multiline:e.multiline,fullWidth:e.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!K&&V())},onChange:function(r){q("");var t=r.target.value;o(t);var n,i=t.match(/:(\w{2,}):/g),a=t.match(/:(\w{2,})/g);if(i){var c=i[0].replace(/:/g,"");W.getEmojiByShortcode(c).then((function(e){if(e&&"unicode"in e){var r=t.replace(i[0],e.unicode);o(r)}else o(t)})).catch((function(){o(t)})),L(!1)}else a?(n=a[0].replace(":",""),W.getEmojiBySearchQuery(n).then((function(r){r.length?(D(r.slice(0,e.maximumEmojiSearchResults)),L(!0)):(D([]),L(!1))})).catch((function(){D([]),L(!1)}))):L(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:A,color:"secondary",size:"small",InputProps:{endAdornment:(0,a.jsxs)(h(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(R,{dataSource:e.emojiDataSource,onEmojiClick:J,buttonColor:Q}),e.enableSpeechToText&&U]})},InputLabelProps:{className:f?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,a.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,a.jsxs)(u(),{className:"rustic-input-actions",children:[e.children,(0,a.jsx)(k(),{title:"Send",children:(0,a.jsx)("span",{className:"rustic-send-button",children:(0,a.jsx)(m(),{"aria-label":"send message",onClick:V,disabled:K,color:"secondary",children:(0,a.jsx)(T,{name:"send"})})})})]})]})}));M.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const D=M;var B=function(){return B=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},B.apply(this,arguments)};const F=function(e){var r=e.ws,t=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}(e,["ws"]);return(0,a.jsx)(D,B({},t,{send:function(e){r.send(e)}}))};return i})()));
|
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
flex: 1;
|
|
5
5
|
gap: 16px;
|
|
6
|
-
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.rustic-message-container {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
flex: 1;
|
|
13
|
+
gap: 16px;
|
|
7
14
|
overflow: auto;
|
|
8
|
-
position: relative;
|
|
9
15
|
scroll-behavior: smooth;
|
|
10
16
|
scrollbar-width: none;
|
|
11
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>S});const n=require("react/jsx-runtime"),r=require("@mui/material/Chip");var s=e.n(r);const o=require("@mui/system/Box");var a=e.n(o);const i=require("react");var c=e.n(i);const u=require("@mui/material/Typography");var l=e.n(u),d=function(){return d=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},d.apply(this,arguments)};const m=function(e){var t=e.messages[0],r=e.messages.slice(1),s=e.supportedElements[t.format];return(0,n.jsx)(n.Fragment,{children:s?c().createElement(s,d(d({sender:e.sender,ws:e.ws,messageId:t.id,conversationId:t.conversationId},t.data),r.length>0&&{updatedData:r.map((function(e){return e.data}))})):(0,n.jsxs)(l(),{variant:"body2",children:["Unsupported element format: ",t.format]})})};var f=function(){return f=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},f.apply(this,arguments)};function p(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:f({},t),children:e.name})}const v=require("@mui/material"),g=require("@mui/material/Card");var y=e.n(g);const h=require("@mui/material/Stack");var j,b=e.n(h);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(j||(j={}));const w=function(e){return(0,n.jsx)(l(),{variant:"caption",color:"text.secondary",className:"rustic-timestamp",children:(t=e.timestamp,r=new Date(t),s=navigator.language,o={month:"short",day:"numeric"},a=new Date,i=r.getFullYear()!==a.getFullYear(),c=i?" at ":", ",i&&(o.year="numeric"),r.toLocaleDateString(s,o)+c+r.toLocaleTimeString(s,{hour:"numeric",minute:"2-digit",hour12:!0}))});var t,r,s,o,a,i,c},x=(0,i.forwardRef)((function(e,t){var r=(0,v.useTheme)(),s=e.inReplyTo?e.inReplyTo:e.message;return(0,n.jsxs)(b(),{id:s.id,className:"rustic-message-canvas",ref:t,children:[(0,n.jsxs)(b(),{direction:"row",alignItems:"center",spacing:1,className:"rustic-header",children:[e.getProfileComponent&&e.getProfileComponent(s),(0,n.jsx)(w,{timestamp:s.timestamp})]}),e.getActionsComponent&&e.getActionsComponent(e.message)&&(0,n.jsx)(y(),{variant:"outlined",className:"rustic-message-actions-container",sx:{boxShadow:r.shadows[1]},children:e.getActionsComponent(s)}),(0,n.jsxs)(y(),{variant:"outlined",className:"rustic-message-container",children:[e.children,e.inReplyTo&&(0,n.jsxs)(l(),{variant:"caption",color:"text.secondary",className:"rustic-footer",children:["Submitted by ",e.message.sender.name," at ",(0,n.jsx)(w,{timestamp:e.message.timestamp})]})]})]})}));var O=function(){return O=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},O.apply(this,arguments)},E=function(e,t,n){if(n||2===arguments.length)for(var r,s=0,o=t.length;s<o;s++)!r&&s in t||(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return e.concat(r||Array.prototype.slice.call(t))};function R(e,t){var n;if(!(n=t.format.includes("update")?t.threadId:t.format.includes("Response")?t.inReplyTo:t.id))return e;var r=O({},e),s=(r[n]||[])[0];return t.format.includes("update")&&s&&s.sender.id!==t.sender.id&&(n=t.id),r[n]||(r[n]=[]),t.format.includes("Response")&&s?r[n]=[O(O({},s),{data:O(O({},s.data),t.data)}),t]:r[n]=E(E([],r[n],!0),[t],!1),r}function T(e){var t,r,o,c=(0,i.useRef)(null),u=(0,i.useRef)(null),l=(0,i.useRef)(),d=(0,i.useState)(!0),f=d[0],v=d[1],g=(0,i.useState)(!0),y=g[0],h=g[1],j=(0,i.useState)(!1),b=j[0],w=j[1],E=(0,i.useState)({}),T=E[0],S=E[1],C=Object.keys(T).length,N=(r=C,o=(0,i.useRef)(0),(0,i.useEffect)((function(){o.current=r})),o.current),A=2e3;function P(){h(!0),l.current&&clearTimeout(l.current),l.current=setTimeout((function(){h(!1)}),A)}function q(){var e=u.current,t=c.current;if(e&&t){var n=e.getBoundingClientRect().bottom,r=t.getBoundingClientRect().bottom;v(r-1<=n)}}function D(){if(function(){var e,t=null===(e=u.current)||void 0===e?void 0:e.querySelectorAll("video");return!t||0===t.length||Array.from(t).every((function(e){return e.readyState>=1}))}()){var e=u.current;w(!0),e&&setTimeout((function(){P(),e.scrollTop=e.scrollHeight}),0)}else setTimeout(D,1)}function L(e){S((function(t){return R(t,e)}))}return(0,i.useEffect)((function(){var e=u.current;if(q(),e)return e.addEventListener("scroll",q),window.addEventListener("resize",q),function(){e.removeEventListener("scroll",q),window.removeEventListener("resize",q)}}),[f]),(0,i.useEffect)((function(){D()}),[b]),(0,i.useEffect)((function(){f&&0!==N&&C>N&&(P(),D())}),[f,Object.keys(T).length]),(0,i.useEffect)((function(){var t,n={};null===(t=e.receivedMessages)||void 0===t||t.forEach((function(e){var t=R(n,e);n=t})),S(n)}),[null===(t=e.receivedMessages)||void 0===t?void 0:t.length]),(0,i.useEffect)((function(){e.ws.onReceive&&e.ws.onReceive(L)}),[]),(0,n.jsxs)(a(),{className:"rustic-message-space",children:[(0,n.jsxs)(a(),{ref:u,className:"rustic-message-container",children:[Object.keys(T).map((function(t,r){var s,o=T[t],a=o[o.length-1],i=a.format.includes("Response"),u=i&&{inReplyTo:o[0]};return"prompts"!==a.format?(0,n.jsx)(x,O({message:a},u,{getActionsComponent:e.getActionsComponent,getProfileComponent:e.getProfileComponent,ref:r===C-1?c:null,children:(0,n.jsx)(m,{ws:e.ws,sender:e.sender,messages:i?[o[0]]:o,supportedElements:e.supportedElements})}),t):"inConversation"===(null===(s=a.data)||void 0===s?void 0:s.position)?(0,n.jsx)("div",{ref:r===C-1?c:null,children:(0,n.jsx)(m,{ws:e.ws,sender:e.sender,messages:i?[o[0]]:o,supportedElements:e.supportedElements})},t):void 0})),!f&&!y&&(0,n.jsx)(s(),{variant:"rusticSecondary",className:"rustic-scroll-down-button",size:"medium",onClick:D,label:(0,n.jsxs)(n.Fragment,{children:[e.scrollDownLabel,(0,n.jsx)(p,{name:"arrow_downward"})]})})]}),function(t){var r,s=Object.values(t).flat(),o=s[s.length-1];return"prompts"===(null==o?void 0:o.format)&&"inConversation"!==(null===(r=null==o?void 0:o.data)||void 0===r?void 0:r.position)?(0,n.jsx)(m,{ws:e.ws,sender:e.sender,messages:[o],supportedElements:e.supportedElements}):null}(T)]})}T.defaultProps={scrollDownLabel:"Scroll down"};const S=T;return t})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageSpace.d.ts","sourceRoot":"","sources":["../../../src/components/messageSpace/messageSpace.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAQ3B,OAAsB,EACpB,KAAK,qBAAqB,EAC3B,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE9E,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D,0LAA0L;IAC1L,EAAE,EAAE,eAAe,CAAA;IACnB,0GAA0G;IAC1G,MAAM,EAAE,MAAM,CAAA;IACd,2GAA2G;IAC3G,iBAAiB,EAAE,YAAY,CAAA;IAC/B,2IAA2I;IAC3I,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAA;IAC5B,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AA6DD;;;;;;EAME;AAEF,iBAAwB,YAAY,CAAC,KAAK,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"messageSpace.d.ts","sourceRoot":"","sources":["../../../src/components/messageSpace/messageSpace.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAQ3B,OAAsB,EACpB,KAAK,qBAAqB,EAC3B,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE9E,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D,0LAA0L;IAC1L,EAAE,EAAE,eAAe,CAAA;IACnB,0GAA0G;IAC1G,MAAM,EAAE,MAAM,CAAA;IACd,2GAA2G;IAC3G,iBAAiB,EAAE,YAAY,CAAA;IAC/B,2IAA2I;IAC3I,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAA;IAC5B,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AA6DD;;;;;;EAME;AAEF,iBAAwB,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CAmN5D;kBAnNuB,YAAY;;;;;eAAZ,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AAEtB,OAAO,OAAO,MAAM,WAAW,CAAA;AAE/B,eAAe,OAAO,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>s});const r=require("react/jsx-runtime"),o=require("@mui/material/Box");var n=e.n(o);const a=require("@mui/material/Chip");var i=e.n(a);require("react");const u=require("uuid"),s=function(e){var t=e.prompts.map((function(t,o){return(0,r.jsx)(i(),{onClick:function(){return r=t,o=(new Date).toISOString(),n={id:(0,u.v4)(),timestamp:o,sender:e.sender,conversationId:e.conversationId,format:"text",data:{text:r}},void e.ws.send(n);var r,o,n},variant:"rusticSecondary",size:"small",className:"rustic-prompt",label:t},o)}));return(0,r.jsx)(n(),{className:e.className,children:t})};return t})()));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import './prompts.css';
|
|
2
|
+
import type { PromptsProps } from '../types';
|
|
3
|
+
/** The `Prompts` component renders a list of actionable prompts that users can click to send a predefined message.
|
|
4
|
+
|
|
5
|
+
To use the `Prompts` component within `MessageSpace`, you need to add prompts to the supportedElements map and include an additional property, `position`, in the `data` field of the message.
|
|
6
|
+
The `position` property determines where the prompts are displayed and can be one of the following:
|
|
7
|
+
|
|
8
|
+
- `inConversation`: Prompts are displayed at the top, integrated with other chat messages.
|
|
9
|
+
- `hoverOverInput` (default): Prompts are displayed above the input field at the bottom of the chat interface. Note that prompts with this position will only appear if they are part of the last message in the message list.
|
|
10
|
+
*/
|
|
11
|
+
export default function Prompts(props: PromptsProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/components/prompts/prompts.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AAOtB,OAAO,KAAK,EAAW,YAAY,EAAE,MAAM,UAAU,CAAA;AAErD;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EAAE,YAAY,2CAkClD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedDescription.d.ts","sourceRoot":"","sources":["../../src/components/sharedDescription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEzD,eAAO,MAAM,yBAAyB,EAAE,SAIvC,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,SAmB/B,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,SAwB3B,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { MessageSpaceProps } from './messageSpace/messageSpace';
|
|
3
2
|
export type MessageData = {
|
|
4
3
|
[key: string]: any;
|
|
@@ -192,6 +191,8 @@ export interface BaseInputProps {
|
|
|
192
191
|
enableSpeechToText?: boolean;
|
|
193
192
|
/** Specifies the maximum number of emoji search results to display when the user enters a search query. The search query is triggered when the user types in a format like `:text`. */
|
|
194
193
|
maximumEmojiSearchResults?: number;
|
|
194
|
+
/** URL to fetch the emoji data from. You need to host the emoji data by yourself. If not provided, the default url will be used. */
|
|
195
|
+
emojiDataSource?: string;
|
|
195
196
|
}
|
|
196
197
|
export interface TextInputProps extends Omit<BaseInputProps, 'send' | 'isSendEnabled'> {
|
|
197
198
|
/** WebSocket connection to send and receive messages to and from a backend.*/
|
|
@@ -232,6 +233,8 @@ export interface UploaderProps {
|
|
|
232
233
|
};
|
|
233
234
|
/** Defines the available options for file upload, displayed within a popover menu. If no options are provided, an upload icon button will be displayed by default.*/
|
|
234
235
|
uploadOptions?: UploadOption[];
|
|
236
|
+
/** A function to fetch and format existing file data when a file upload fails due to a conflict error (HTTP status code 409). The returned value will be used to determine a unique file name by appending an incremented number to the base name. */
|
|
237
|
+
listFiles?: () => Promise<FileData[]>;
|
|
235
238
|
}
|
|
236
239
|
export type MultimodalInputProps = TextInputProps & Omit<UploaderProps, 'messageId' | 'onFileUpdate' | 'filePreviewsContainer' | 'errorMessagesContainer'>;
|
|
237
240
|
export interface ConversationProps {
|
|
@@ -250,6 +253,15 @@ export interface QuestionFormat extends DataFormat {
|
|
|
250
253
|
}
|
|
251
254
|
export interface QuestionProps extends QuestionFormat, ConversationProps {
|
|
252
255
|
}
|
|
256
|
+
export interface PromptsFormat {
|
|
257
|
+
/** A list of prompt strings for users to select from. These prompts will be displayed as interactive elements in the UI. */
|
|
258
|
+
prompts: string[];
|
|
259
|
+
position?: 'inConversation' | 'hoverOverInput';
|
|
260
|
+
}
|
|
261
|
+
export interface PromptsProps extends PromptsFormat, ConversationProps {
|
|
262
|
+
/** An optional className to apply to the prompts container. */
|
|
263
|
+
className?: string;
|
|
264
|
+
}
|
|
253
265
|
export interface PDFViewerProps {
|
|
254
266
|
/** The url of the PDF file to be displayed. */
|
|
255
267
|
url: string;
|