@rustic-ai/ui-components 0.0.32 → 0.0.34
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/dynamicForm/index.js +1 -1
- package/dist/components/filePreview/filePreview.d.ts +1 -0
- package/dist/components/filePreview/filePreview.d.ts.map +1 -1
- package/dist/components/helper.d.ts +6 -1
- package/dist/components/helper.d.ts.map +1 -1
- package/dist/components/icon/index.js +1 -1
- package/dist/components/index.d.ts +8 -6
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/input/baseInput/baseInput.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 +5 -2
- 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.css +4 -0
- 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 +1 -2
- package/dist/components/input/textInput/index.js +1 -1
- package/dist/components/messageCanvas/actions/copy/index.js +1 -1
- package/dist/components/messageCanvas/actions/index.js +1 -1
- package/dist/components/messageCanvas/actions/textToSpeech/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/multipart/chatCompletion/chatCompletion.d.ts +11 -0
- package/dist/components/multipart/chatCompletion/chatCompletion.d.ts.map +1 -0
- package/dist/components/multipart/{index.css → chatCompletion/index.css} +4 -0
- package/dist/components/multipart/chatCompletion/index.d.ts +4 -0
- package/dist/components/multipart/chatCompletion/index.d.ts.map +1 -0
- package/dist/components/multipart/chatCompletion/index.js +1 -0
- package/dist/components/multipart/multipart/index.css +149 -0
- package/dist/components/multipart/{index.d.ts → multipart/index.d.ts} +1 -1
- package/dist/components/multipart/multipart/index.d.ts.map +1 -0
- package/dist/components/multipart/{index.js → multipart/index.js} +1 -1
- package/dist/components/multipart/{multipart.d.ts → multipart/multipart.d.ts} +2 -2
- package/dist/components/multipart/multipart/multipart.d.ts.map +1 -0
- 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/text/index.js +1 -1
- package/dist/components/types.d.ts +69 -4
- 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/components/weather/index.js +1 -1
- package/dist/index.css +18 -4
- 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 +35 -28
- package/dist/components/multipart/index.d.ts.map +0 -1
- package/dist/components/multipart/multipart.d.ts.map +0 -1
|
@@ -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={
|
|
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={6989:e=>{e.exports=require("@mui/material/Box")},785:e=>{e.exports=require("@mui/material/Typography")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")},3903:e=>{e.exports=require("uuid")}},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var i=r[o]={exports:{}};return e[o](i,i.exports,t),i.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};t.r(o),t.d(o,{UniformsForm:()=>v});var n=t(8732),i=t(6989),a=t.n(i),s=t(785),u=t.n(s);const d=require("ajv");var c=t.n(d),l=t(2015);const m=require("uniforms-bridge-json-schema"),p=require("uniforms-mui");var f=t(3903);function v(e){var r=(0,l.useState)(e.data),t=r[0],o=r[1];(0,l.useEffect)((function(){e.data&&o(e.data)}),[e.data]);var i,s,d=new(c())({allErrors:!0,useDefaults:!0,keywords:["uniforms"]}),v=(i=e.schema,s=d.compile(i),function(e){var r;return s(e),(null===(r=s.errors)||void 0===r?void 0:r.length)?{details:s.errors}:null}),x=new m.JSONSchemaBridge({schema:e.schema,validator:v});return(0,n.jsxs)(a(),{className:"rustic-form",children:[e.title&&(0,n.jsx)(u(),{variant:"h6",children:e.title}),e.description&&(0,n.jsx)(u(),{variant:"body1",children:e.description}),(0,n.jsx)(p.AutoForm,{schema:x,onSubmit:function(r){return function(r){var t=(new Date).toISOString(),n={id:(0,f.v4)(),timestamp:t,sender:e.sender,conversationId:e.conversationId,format:"formResponse",data:r,inReplyTo:e.messageId};o(r),e.ws.send(n)}(r)},model:t,disabled:!!t})]})}return o})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filePreview.d.ts","sourceRoot":"","sources":["../../../src/components/filePreview/filePreview.tsx"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAA;AAC1B,OAAO,iBAAiB,CAAA;AAQxB,OAAO,KAAmB,MAAM,OAAO,CAAA;AAKvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,QAAQ,CAAA;IACd,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAA;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AASD,iBAAwB,WAAW,CACjC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"filePreview.d.ts","sourceRoot":"","sources":["../../../src/components/filePreview/filePreview.tsx"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAA;AAC1B,OAAO,iBAAiB,CAAA;AAQxB,OAAO,KAAmB,MAAM,OAAO,CAAA;AAKvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,QAAQ,CAAA;IACd,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAA;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AASD,iBAAwB,WAAW,CACjC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,2CA4EjD;kBA7EuB,WAAW;;;;;;;;;;eAAX,WAAW"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ChatCompletionRequest } from './types';
|
|
1
2
|
export declare function calculateTimeDiffInSeconds(isoDate: string): number;
|
|
2
3
|
export declare function formatDateAndTime(isoDateTimeInUtc: string): string;
|
|
3
4
|
export declare const capitalizeFirstLetter: (str: string) => string;
|
|
@@ -15,8 +16,12 @@ export declare function getSizeStyles(maybeWidth: number | undefined, maybeHeigh
|
|
|
15
16
|
className?: string;
|
|
16
17
|
};
|
|
17
18
|
export declare function shortenString(str: string, maxLength: number): string;
|
|
18
|
-
export declare
|
|
19
|
+
export declare function getDayFromUnixTime(unixTime: number): {
|
|
19
20
|
shortName: string;
|
|
20
21
|
fullName: string;
|
|
21
22
|
};
|
|
23
|
+
export declare function toChatRequest(msg?: string, files?: {
|
|
24
|
+
url: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
}[]): ChatCompletionRequest;
|
|
22
27
|
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/components/helper.ts"],"names":[],"mappings":"AAEA,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIlE;AAED,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CA6BlE;AAED,eAAO,MAAM,qBAAqB,QAAS,MAAM,KAAG,MAEnD,CAAA;AAED,oBAAY,UAAU;IACpB,IAAI,IAAA;IACJ,UAAU,IAAA;CACX;AAED,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,MAAM,EACzB,MAAM,EAAE,UAAU,GACjB,MAAM,CAsBR;AAED,wBAAgB,uBAAuB,CACrC,sBAAsB,EAAE,MAAM,EAC9B,oBAAoB,EAAE,MAAM,GAC3B,MAAM,CASR;AAED,wBAAgB,oBAAoB,CAClC,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,MAAM,UAOvB;AAED,wBAAgB,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAapE;AAED,wBAAgB,aAAa,CAC3B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAqBzD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAK3D;AAED,
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/components/helper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAW,MAAM,SAAS,CAAA;AAE7D,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIlE;AAED,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CA6BlE;AAED,eAAO,MAAM,qBAAqB,QAAS,MAAM,KAAG,MAEnD,CAAA;AAED,oBAAY,UAAU;IACpB,IAAI,IAAA;IACJ,UAAU,IAAA;CACX;AAED,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,MAAM,EACzB,MAAM,EAAE,UAAU,GACjB,MAAM,CAsBR;AAED,wBAAgB,uBAAuB,CACrC,sBAAsB,EAAE,MAAM,EAC9B,oBAAoB,EAAE,MAAM,GAC3B,MAAM,CASR;AAED,wBAAgB,oBAAoB,CAClC,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,MAAM,UAOvB;AAED,wBAAgB,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAapE;AAED,wBAAgB,aAAa,CAC3B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAqBzD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAK3D;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG;IACpD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAoBA;AAED,wBAAgB,aAAa,CAC3B,GAAG,CAAC,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,GACvC,qBAAqB,CAsBvB"}
|
|
@@ -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={
|
|
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={9767:(e,r,t)=>{t.d(r,{A:()=>a});var o=t(8732),n=(t(2015),function(){return n=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},n.apply(this,arguments)});function a(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:n({},r),children:e.name})}},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var a=r[o]={exports:{}};return e[o](a,a.exports,t),a.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};t.r(o),t.d(o,{default:()=>n});const n=t(9767).A;return o})()));
|
|
@@ -18,10 +18,12 @@ import Action from './messageCanvas/actions/index';
|
|
|
18
18
|
import TextToSpeech from './messageCanvas/actions/textToSpeech/textToSpeech';
|
|
19
19
|
import MessageCanvas from './messageCanvas/messageCanvas';
|
|
20
20
|
import MessageSpace from './messageSpace/messageSpace';
|
|
21
|
-
import
|
|
21
|
+
import ChatCompletion from './multipart/chatCompletion/chatCompletion';
|
|
22
|
+
import Multipart from './multipart/multipart/multipart';
|
|
22
23
|
import ParticipantsContainer from './participantsContainer/participantsContainer';
|
|
23
24
|
import PDFViewer from './pdfViewer/pdfViewer';
|
|
24
25
|
import PromptBuilder from './promptBuilder/promptBuilder';
|
|
26
|
+
import Prompts from './prompts/prompts';
|
|
25
27
|
import Question from './question/question';
|
|
26
28
|
import Table from './table/table';
|
|
27
29
|
import StreamingText from './text/streamingText';
|
|
@@ -34,10 +36,10 @@ import PerspectiveViz from './visualization/perspectiveViz/perspectiveViz';
|
|
|
34
36
|
import PlotlyGraph from './visualization/plotlyGraph/plotlyGraph';
|
|
35
37
|
import VegaLiteViz from './visualization/vegaLiteViz/vegaLiteViz';
|
|
36
38
|
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,
|
|
39
|
+
export { Action, ChatCompletion, 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
40
|
export * from '../rusticTheme';
|
|
39
|
-
export * from './types';
|
|
40
|
-
export * from './visualization/mermaidViz/mermaidViz.types';
|
|
41
|
-
export * from './visualization/
|
|
42
|
-
export * from './visualization/
|
|
41
|
+
export type * from './types';
|
|
42
|
+
export type * from './visualization/mermaidViz/mermaidViz.types';
|
|
43
|
+
export type * from './visualization/plotlyGraph/plotlyGraph.types';
|
|
44
|
+
export type * from './visualization/vegaLiteViz/vegaLiteViz.types';
|
|
43
45
|
//# 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,
|
|
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,cAAc,MAAM,2CAA2C,CAAA;AACtE,OAAO,SAAS,MAAM,iCAAiC,CAAA;AACvD,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,cAAc,EACd,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,mBAAmB,SAAS,CAAA;AAC5B,mBAAmB,6CAA6C,CAAA;AAChE,mBAAmB,+CAA+C,CAAA;AAClE,mBAAmB,+CAA+C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseInput.d.ts","sourceRoot":"","sources":["../../../../src/components/input/baseInput/baseInput.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAA;AAexB,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"baseInput.d.ts","sourceRoot":"","sources":["../../../../src/components/input/baseInput/baseInput.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAA;AAexB,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,KAAK,EAAE,cAAc,EAAW,MAAM,aAAa,CAAA;AAyW1D,QAAA,MAAM,SAAS;;wCAA+B,CAAA;AAU9C,eAAe,SAAS,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={
|
|
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={8342: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(8342);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,8342,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})()));
|
|
@@ -99,7 +99,7 @@ code {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
.rustic-base-input .rustic-input-label {
|
|
102
|
-
padding-top:
|
|
102
|
+
padding-top: 10px;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
.rustic-base-input .rustic-text-field .MuiOutlinedInput-input {
|
|
@@ -120,7 +120,6 @@ code {
|
|
|
120
120
|
|
|
121
121
|
.rustic-base-input .rustic-input-adornment {
|
|
122
122
|
align-self: start;
|
|
123
|
-
margin-top: 12px;
|
|
124
123
|
}
|
|
125
124
|
|
|
126
125
|
span.rustic-icon-large {
|
|
@@ -178,6 +177,10 @@ emoji-picker {
|
|
|
178
177
|
min-width: 220px;
|
|
179
178
|
}
|
|
180
179
|
|
|
180
|
+
.rustic-file-preview-name {
|
|
181
|
+
margin-right: 8px;
|
|
182
|
+
}
|
|
183
|
+
|
|
181
184
|
.rustic-file-preview-modal {
|
|
182
185
|
width: 90vw;
|
|
183
186
|
height: 90vh;
|
|
@@ -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,t={9767:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(8732),a=(t(2015),function(){return a=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])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,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:a({},r),children:e.name})}},3110:(e,r,t)=>{t.d(r,{default:()=>n});const n=t(9767).A},8342:e=>{e.exports=require("emoji-picker-element")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},n={};function a(e){var r=n[e];if(void 0!==r)return r.exports;var o=n[e]={exports:{}};return t[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(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 o=Object.create(null);a.r(o);var i={};e=e||[null,r({}),r([]),r(r)];for(var l=2&n&&t;"object"==typeof l&&!~e.indexOf(l);l=r(l))Object.getOwnPropertyNames(l).forEach((e=>i[e]=()=>t[e]));return i.default=()=>t,a.d(o,i),o},a.d=(e,r)=>{for(var t in r)a.o(r,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},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(8732);const l=require("@mui/material/Box");var c=a.n(l);const s=require("@mui/material/styles");var u=a(2015);const d=require("uuid");var p;function m(e,r){var t=[];if(e&&(null==e?void 0:e.trim().length)&&t.push({type:"text",text:e}),r&&r.length>0)for(var n=0;n<(null==r?void 0:r.length);n++)t.push({type:"file_url",file_url:{url:r[n].url,name:r[n].name}});return{messages:[{content:t,role:"user"}]}}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(p||(p={}));const f=require("@mui/material/CircularProgress");var h=a.n(f);const v=require("@mui/material/IconButton");var x=a.n(v);const g=require("@mui/material/InputAdornment");var b=a.n(g);const j=require("@mui/material/MenuItem");var y=a.n(j);const w=require("@mui/material/MenuList");var F=a.n(w);const S=require("@mui/material/Popover");var C=a.n(S);const N=require("@mui/material/TextField");var k=a.n(N);const P=require("@mui/material/Tooltip");var O=a.n(P);const E=require("@mui/material/Typography");var q=a.n(E),R=a(8342),T=a(9767);const I=function(e){var r=(0,s.useTheme)(),t=(0,u.useRef)(null),n=(0,u.useRef)(null),o=(0,u.useState)(!1),l=o[0],c=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 p(){c(!1)}function m(r){r.detail.unicode&&e.onEmojiClick(r.detail.unicode),p()}return(0,u.useEffect)((function(){n.current||"undefined"==typeof window||Promise.resolve().then(a.t.bind(a,8342,23)).then((function(t){var a=new(0,t.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])})),n.current=a})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,u.useEffect)((function(){return n.current&&n.current.addEventListener("emoji-click",m),function(){var e;null===(e=n.current)||void 0===e||e.removeEventListener("emoji-click",m)}}),[l,e.onEmojiClick]),(0,i.jsxs)("div",{children:[(0,i.jsx)(O(),{title:"Emoji",children:(0,i.jsx)(x(),{size:"small",ref:t,onClick:function(){c((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)(T.A,{name:"Mood"})})}),n.current&&(0,i.jsx)(C(),{open:l,anchorEl:t.current,onClose:p,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,i.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&n.current&&!e.contains(n.current)&&e.appendChild(n.current)}})})]})};var D={"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 A(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var _=(0,u.forwardRef)((function(e,r){var t=(0,u.useState)(""),n=t[0],a=t[1],o=(0,u.useState)(!1),l=o[0],s=o[1],p=(0,u.useState)(!1),f=p[0],v=p[1],g=(0,u.useState)(!1),j=g[0],w=g[1],S=(0,u.useState)(""),N=S[0],P=S[1],E=(0,u.useState)([]),_=E[0],z=E[1],L=(0,u.useState)(!1),U=L[0],M=L[1],B=(0,u.useRef)(null),$=new R.Database({dataSource:e.emojiDataSource}),W=!n.trim().length&&!e.isSendEnabled,H="".concat(l?"Stop":"Start"," speech to text"),V=f?"primary.main":"primary.light",G=l?"error.main":V,K=l?"stop_circle":"speech_to_text";function Q(e,r){if(void 0===r&&(r=!1),B.current){var t=B.current,o=t.selectionStart,i=t.selectionEnd;if("number"==typeof o&&"number"==typeof i){var l,c=n||"",s=c.substring(0,o),u=c.substring(i);l=r?s.replace(/:(\w+)$/,e)+u:s+e+u,a(l);var d=r?s.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)}}M(!1)}var Y=j?(0,i.jsx)(h(),{size:24}):(0,i.jsx)(O(),{title:H,children:(0,i.jsx)(x(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,l?(e.stop(),w(!0),s(!1)):(e.start(),P(""),s(!0)),e.onstart=function(){s(!0)},e.onresult=function(e){var r,t=e.results[0][0].transcript;n.length>0?a(n+" "+t):a(t),null===(r=B.current)||void 0===r||r.focus(),s(!1)},e.onerror=function(e){var r=D[e.error];P(r),s(!1)},e.onend=function(){w(!1),s(!1)}},size:"small",sx:{color:G,"&:hover":{color:"primary.main"}},children:(0,i.jsx)(T.A,{name:K})})});function Z(){var r=(new Date).toISOString(),t={id:(0,d.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"chatCompletionRequest",data:m(n)};e.send(t),a(""),P("")}return(0,i.jsxs)(c(),{className:"rustic-base-input",ref:r,children:[(0,i.jsxs)(c(),{className:"rustic-error-and-input-container",children:[(0,i.jsx)(c(),{className:"rustic-error-container",children:(0,i.jsx)(q(),{variant:"caption",color:"error",className:"rustic-error-message",children:N})}),(0,i.jsxs)(c(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:f?"secondary.main":"action.disabled"},children:[_.length>0&&(0,i.jsx)(C(),{open:U,anchorEl:B.current,onClose:function(){return M(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,i.jsx)(F(),{children:_.map((function(e,r){return"unicode"in e&&(0,i.jsx)(y(),{onClick:function(){return Q(e.unicode,!0)},children:A(e)},r)}))})}),(0,i.jsx)(k(),{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(),W||Z())},onChange:function(r){P("");var t=r.target.value;a(t);var n,o=t.match(/:(\w{2,}):/g),i=t.match(/:(\w{2,})/g);if(o){var l=o[0].replace(/:/g,"");$.getEmojiByShortcode(l).then((function(e){if(e&&"unicode"in e){var r=t.replace(o[0],e.unicode);a(r)}else a(t)})).catch((function(){a(t)})),M(!1)}else i?(n=i[0].replace(":",""),$.getEmojiBySearchQuery(n).then((function(r){r.length?(z(r.slice(0,e.maximumEmojiSearchResults)),M(!0)):(z([]),M(!1))})).catch((function(){z([]),M(!1)}))):M(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:B,color:"secondary",size:"small",slotProps:{input:{endAdornment:(0,i.jsxs)(b(),{position:"end",className:"rustic-input-adornment",children:[(0,i.jsx)(I,{dataSource:e.emojiDataSource,onEmojiClick:Q,buttonColor:V}),e.enableSpeechToText&&Y]})},inputLabel:{className:f?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}}),(0,i.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,i.jsxs)(c(),{className:"rustic-input-actions",children:[e.children,(0,i.jsx)(O(),{title:"Send",children:(0,i.jsx)("span",{className:"rustic-send-button",children:(0,i.jsx)(x(),{"aria-label":"send message",onClick:Z,disabled:W,color:"secondary",children:(0,i.jsx)(T.A,{name:"send"})})})})]})]})}));_.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const z=_,L=require("@mui/material/LinearProgress");var U=a.n(L);const M=require("axios");var B=a.n(M);const $=require("react-dom"),W=require("@mui/material/Card");var H=a.n(W);const V=require("@mui/material/Modal");var G=a.n(V);const K=require("@mui/material/useMediaQuery");var Q=a.n(K);const Y=require("@mui/system/Stack");var Z=a.n(Y);const J=require("@mui/system/useTheme");var X=a.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"}},t=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,i.jsx)(O(),{title:t.label,children:(0,i.jsx)("span",{children:(0,i.jsx)(x(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,i.jsx)(T.A,{name:t.symbol})})})})};var te={pdf:function(e){var r,t=(0,u.useRef)(null),n=(0,u.useState)(1),a=n[0],o=n[1],l=(0,u.useState)(1),s=l[0],d=l[1],p=(0,u.useState)(1),m=p[0],f=p[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")),F=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)(q(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var S=(0,u.useState)((function(){return w?.5:F?1:1.5})),C=S[0],N=S[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(a).then((function(e){var r=e.getViewport({scale:C}),n=t.current;if(n){var a=n.getContext("2d");if(a){var o=window.devicePixelRatio||1;n.style.width="".concat(r.width,"px"),n.style.height="".concat(r.height,"px"),n.width=r.width*o,n.height=r.height*o;var i={canvasContext:a,viewport:r,transform:[o,0,0,o,0,0]};b&&b.cancel();var l=e.render(i);j(l),l.promise.then((function(){j(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){x(!0)}))}),[e.url,a,C]),v?(0,i.jsx)(H(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(q(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,i.jsxs)(H(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,i.jsxs)(c(),{className:"rustic-pdf-viewer-header",children:[(0,i.jsx)(re,{action:"zoomOut",onClick:function(){N((function(e){return Math.max(e-.2,.2)}))}}),(0,i.jsx)(re,{action:"zoomIn",onClick:function(){N((function(e){return e+.2}))}})]}),(0,i.jsx)(c(),{className:"rustic-pdf-viewer-body",children:(0,i.jsx)(c(),{className:"rustic-pdf-viewer-body-inner",children:(0,i.jsx)("canvas",{ref:t})})}),(0,i.jsxs)(Z(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,i.jsx)(re,{action:"previousPage",onClick:function(){a>1&&(o(a-1),f(a-1))},isDisabled:1===a}),(0,i.jsx)(q(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,i.jsx)(k(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);f(r),!isNaN(r)&&r>=1&&r<=s&&o(r)},size:"small",className:"rustic-pdf-page-input"}),(0,i.jsxs)(q(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,i.jsx)(re,{action:"nextPage",onClick:function(){a<s&&(o(a+1),f(a+1))},isDisabled:a===s})]})]})}};function ne(e){var r=(0,s.useTheme)(),t=(0,u.useState)(!1),n=t[0],a=t[1];function o(){a(!1)}var l,c,d=e.file.url&&(l=e.file.url.split("."))[l.length-1].toLowerCase(),p=d&&e.supportedViewers?e.supportedViewers[d]:null,m=!!p,f=e.showFullName?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width",h=m?" rustic-cursor-pointer":"",v="rustic-file-preview ".concat(f).concat(h),g=e.showFullName?e.file.name:(c=e.file.name).length<=15?c:c.substring(0,12)+"...";return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(H(),{className:v,variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){a(!0)},children:[(0,i.jsx)(q(),{variant:"subtitle2",className:"rustic-file-preview-name",children:g}),(0,i.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),m&&(0,i.jsx)(G(),{open:n,onClose:o,className:"rustic-file-preview-modal",children:(0,i.jsxs)("div",{className:"rustic-modal-content",children:[(0,i.jsx)(O(),{title:"Close",children:(0,i.jsx)(x(),{onClick:o,className:"rustic-close-button",children:(0,i.jsx)(T.A,{name:"close"})})}),e.file.url&&(0,i.jsx)(p,{url:e.file.url})]})})]})}ne.defaultProps={supportedViewers:te,showFullName:!0};var ae=a(3110);const oe=require("@mui/material"),ie=require("@mui/material/Button");var le=a.n(ie);const ce=require("@mui/material/Drawer");var se=a.n(ce);const ue=require("@mui/material/ListItemText");var de=a.n(ue);const pe=require("@mui/material/Menu");var me=a.n(pe);const fe=require("@mui/system");var he=function(){return he=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},he.apply(this,arguments)};function ve(e){var r=(0,u.useState)(!1),t=r[0],n=r[1],a=(0,u.useRef)(null),o=(0,s.useTheme)(),l=(0,oe.useMediaQuery)(o.breakpoints.down("md")),c=l?se():me(),d={borderRadius:"".concat(o.shape.borderRadius,"px"),border:"1px solid ".concat(o.palette.divider)};function p(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)(q(),{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})]})}l&&(d=he(he({},d),{borderRadius:"".concat(o.shape.borderRadius,"px ").concat(o.shape.borderRadius,"px 0 0"),borderBottom:0}));var m=e.menuItems.map((function(e){return e.href?(0,i.jsx)(y(),{component:"a",onClick:function(){return n(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:p(e)},e.label):(0,i.jsx)(y(),{onClick:function(r){e.onClick&&e.onClick(r),n(!1)},disabled:!e.onClick,children:p(e)},e.label)}));var f,h,v=l?{}:{anchorEl:a.current};return(0,i.jsxs)(i.Fragment,{children:[(f={onClick:function(e){e.stopPropagation(),n(!0)},"aria-label":e.ariaLabel,ref:a,className:"rustic-popover-menu-button"},h=(0,i.jsx)(T.A,{name:"more_vert"}),e.buttonText?(0,i.jsx)(le(),he({},f,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,i.jsx)(O(),{title:e.ariaLabel,children:(0,i.jsx)(x(),he({},f,{children:e.icon?e.icon:h}))})),(0,i.jsx)(c,he({open:t,onClose:function(){return n(!1)}},v,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":he(he({},d),{backgroundImage:"none",boxShadow:o.shadows[2]})},children:m}))]})}var xe=function(){return xe=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},xe.apply(this,arguments)},ge=function(e,r,t){if(t||2===arguments.length)for(var n,a=0,o=r.length;a<o;a++)!n&&a in r||(n||(n=Array.prototype.slice.call(r,0,a)),n[a]=r[a]);return e.concat(n||Array.prototype.slice.call(r))};function be(e){for(var r=["Bytes","KB","MB","GB"],t=0;e>=1024&&t<r.length-1;)e/=1024,t++;var n=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(n," ").concat(r[t])}const je=function(e){var r,t=(0,u.useState)([]),n=t[0],a=t[1],o=(0,u.useState)([]),l=o[0],s=o[1],p=(0,u.useState)({}),m=p[0],f=p[1],h=(0,u.useRef)({}),v=(0,d.v4)();function g(e,r,t){var n;h.current=xe(xe({},h.current),((n={})[e]=h.current[e]--,n)),function(e,r,t){s((function(r){return ge(ge([],r,!0),["Failed to upload ".concat(e,". ").concat((null==t?void 0:t.message)||"")],!1)})),a((function(e){return e.filter((function(e){return e.id!==r}))}))}(e,r,t)}(0,u.useEffect)((function(){a([]),s([]),h.current={}}),[e.messageId]);var b=(0,i.jsx)(c(),{className:"rustic-files rustic-padding-16",children:n.map((function(r,t){return(0,i.jsx)(ne,{file:{name:r.name},showFullName:e.showFullName,children:(0,i.jsxs)(c(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,i.jsx)(U(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,i.jsx)(O(),{title:"Delete",children:(0,i.jsx)(x(),{color:"primary",onClick:function(){return function(r,t){var n,o;s([]);var i=r.name;if(h.current=xe(xe({},h.current),((n={})[i]=h.current[i]--,n)),e.onFileUpdate("remove",i),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);B().delete(l).then((function(){return a((function(e){return e.filter((function(e,r){return r!==t}))}))})).catch((function(){return e.onFileUpdate("add",i),s((function(e){return ge(ge([],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!==t}))})),h.current=xe(xe({},h.current),((o={})[i]=h.current[i]++,o))}(r,t)},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"})})})]})},t)}))}),j=(0,i.jsx)(c(),{children:l.map((function(e,r){return(0,i.jsx)(q(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function y(e,r){return r?(0,$.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 t=document.getElementById(v);t&&(t.accept=r.acceptedFileTypes||e.acceptedFileTypes),t.click()}(r)},startDecorator:r.iconName&&(0,i.jsx)(ae.default,{name:r.iconName})}}));return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(c(),{className:"rustic-uploader",children:[(0,i.jsx)("label",{htmlFor:v,children:(null==w?void 0:w.length)?(0,i.jsx)(ve,{ariaLabel:"Upload",icon:(0,i.jsx)(ae.default,{name:"upload_2"}),menuItems:w}):(0,i.jsx)(O(),{title:"Upload",children:(0,i.jsx)(x(),{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:v,onChange:function(r){s([]);var t=r.target.files&&Array.from(r.target.files),o=n.length+(t?t.length:0);e.maxFileCount&&o>e.maxFileCount&&s((function(r){return ge(ge([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var i=t&&function(e,r,t){return t?r<=t?e:e.slice(0,t-r):e}(t,o,e.maxFileCount);i&&i.forEach((function(r){!function(r){var t;e.maxFileSize&&r.size>e.maxFileSize?(t=r.name,s((function(r){return ge(ge([],r,!0),["Failed to upload ".concat(t,". You cannot upload files larger than ").concat(e.maxFileSize&&be(e.maxFileSize),".")],!1)}))):function(r){var t=new FormData,n=new AbortController,o=function(e){var r,t,n=e.name,a=h.current[n];if(a){var o=a+1,i=n.lastIndexOf("."),l=n.substring(0,i),c=n.substring(i);n="".concat(l,"(").concat(a,")").concat(c),h.current=xe(xe({},h.current),((r={})[e.name]=o,r))}else h.current=xe(xe({},h.current),((t={})[e.name]=1,t));return n}(r),i=new File([r],o,{type:r.type});if(e.getUploadData||m){var l=e.getUploadData?e.getUploadData(o):{},c=xe(xe({},l),m);Object.keys(c).forEach((function(e){var r=c[e];t.append(e,"object"==typeof r?JSON.stringify(r):r)}))}t.append("file",i);var s=(0,d.v4)(),u={name:o,loadingProgress:0,abortController:n,id:s};function p(e){var r,t;e.total&&(r=e.loaded/e.total*100,t=u.id,a((function(e){var n=e.map((function(e){return e.id===t?xe(xe({},e),{loadingProgress:r}):e}));return n})))}a((function(e){return ge(ge([],e,!0),[u],!1)})),e.onFileUpdate("add",o);var f="".concat(e.uploadFileEndpoint).replaceAll("fileName",o).replaceAll("messageId",e.messageId);!function i(){return B().post(f,t,{onUploadProgress:p,signal:n.signal}).then((function(r){var n,o,i=t.get("file");r.data.url&&i instanceof File&&i.name&&e.onFileUpdate("update",i.name,r.data.url),r.data.fileId&&(n=r.data,o=u.id,a((function(e){var r=e.findIndex((function(e){return e.id===o}));if(-1!==r){var t=ge([],e,!0);return t[r]=xe(xe({},t[r]),{id:n.fileId}),t}return e})))})).catch((function(n){var l,c,d=t.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var p,m,f,h;409===(null===(l=n.response)||void 0===l?void 0:l.status)&&e.listFiles?(p=o.lastIndexOf("."),m=o.substring(0,p),f=o.substring(p),h=new RegExp("^".concat(m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"(\\(\\d+\\))?").concat(f,"$"),"i"),e.listFiles?e.listFiles().then((function(e){for(var r=0,t=0,n=e;t<n.length;t++){var a=n[t];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(m,"(").concat(r+1,")").concat(f)})):Promise.resolve(o)).then((function(n){e.onFileUpdate("add",n);var o=new File([r],n,{type:r.type});t.set("file",o),a((function(e){return e.map((function(e){return e.id===s?xe(xe({},e),{name:n,loadingProgress:0}):e}))})),i()})).catch((function(){var e;g(r.name,u.id,null===(e=n.response)||void 0===e?void 0:e.data)})):g(r.name,u.id,null===(c=n.response)||void 0===c?void 0:c.data)}))}()}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),l.length>0&&y(j,e.errorMessagesContainer),n.length>0&&y(b,e.filePreviewsContainer)]})};var ye=function(){return ye=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},ye.apply(this,arguments)},we=function(e,r,t){if(t||2===arguments.length)for(var n,a=0,o=r.length;a<o;a++)!n&&a in r||(n||(n=Array.prototype.slice.call(r,0,a)),n[a]=r[a]);return e.concat(n||Array.prototype.slice.call(r))};function Fe(e){var r=(0,u.useState)({uploaded:[],fileList:[]}),t=r[0],n=r[1],a=(0,u.useState)((0,d.v4)()),o=a[0],l=a[1],p=(0,u.useState)(),f=p[0],h=p[1],v=(0,u.useState)(),x=v[0],g=v[1],b=(0,u.useRef)(null),j=(0,s.useTheme)(),y=t.uploaded.length===t.fileList.length&&t.uploaded.length>0;return(0,u.useEffect)((function(){b.current&&(g(b.current.querySelector(".rustic-error-container")),h(b.current.querySelector(".rustic-input-extras")))})),(0,i.jsx)(c(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(j.palette.action.disabled),borderRadius:"".concat(j.shape.borderRadius,"px"),":focus-within":{borderColor:j.palette.secondary.main},background:j.palette.background.paper},children:(0,i.jsx)(z,ye({},e,{send:function(r){y&&(r.id=o,r.format="chatCompletionRequest",r.data=m(r.data.text,t.uploaded.map((function(e){return{url:e.url,name:e.name}})))),e.ws.send(r),l((0,d.v4)()),n({uploaded:[],fileList:[]})},isSendEnabled:y,ref:b,children:(0,i.jsx)(c(),{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){if("add"===e)n((function(e){return ye(ye({},e),{fileList:we(we([],e.fileList,!0),[{name:r}],!1)})}));else if("update"===e){if(!t)return void console.error("URL is required for the 'update' action");n((function(e){var n=e.fileList.findIndex((function(e){return e.name===r})),a=we(we(we([],e.uploaded.slice(0,n),!0),[{name:r,url:t}],!1),e.uploaded.slice(n),!0);return ye(ye({},e),{uploaded:a})}))}else n((function(e){return{uploaded:e.uploaded.filter((function(e){return e.name!==r})),fileList:e.fileList.filter((function(e){return e.name!==r}))}}))},messageId:o,filePreviewsContainer:f,errorMessagesContainer:x,showFullName:e.showFullName,getUploadData:e.getUploadData,uploadOptions:e.uploadOptions,listFiles:e.listFiles})})}))})}Fe.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1};const Se=Fe;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;
|
|
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;AAS9B,OAAO,KAAK,EAAqB,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAI7E;;;;;;;;;;;;;;;EAeE;AACF,iBAAwB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CA+HlE;kBA/HuB,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={9767:(e,r,n)=>{n.d(r,{A:()=>i});var t=n(8732),a=(n(2015),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 i(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})}},3110:(e,r,n)=>{n.d(r,{default:()=>t});const t=n(9767).A},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},r={};function n(t){var a=r[t];if(void 0!==a)return a.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.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(8732);const i=require("@mui/material/Box");var o=n.n(i);const l=require("@mui/material/IconButton");var s=n.n(l);const c=require("@mui/material/LinearProgress");var u=n.n(c);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(2015);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 F=n.n(w);const N=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(9767);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 U=require("pdfjs-dist"),M=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)(s(),{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),i=t[0],l=t[1],s=(0,x.useState)(1),c=s[0],u=s[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],F=A()(),N=q()(F.breakpoints.down("sm")),C=q()(F.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 N?.5:C?1:1.5})),k=P[0],S=P[1];return(0,x.useEffect)((function(){U.GlobalWorkerOptions.workerSrc||(U.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(U.version,"/pdf.worker.mjs")),U.getDocument({url:"".concat(e.url)}).promise.then((function(e){u(e.numPages),function(e){e.getPage(i).then((function(e){var r=e.getViewport({scale:k}),t=n.current;if(t){var a=t.getContext("2d");if(a){var i=window.devicePixelRatio||1;t.style.width="".concat(r.width,"px"),t.style.height="".concat(r.height,"px"),t.width=r.width*i,t.height=r.height*i;var o={canvasContext:a,viewport:r,transform:[i,0,0,i,0,0]};j&&j.cancel();var l=e.render(o);w(l),l.promise.then((function(){w(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[e.url,i,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)(o(),{className:"rustic-pdf-viewer-header",children:[(0,a.jsx)(M,{action:"zoomOut",onClick:function(){S((function(e){return Math.max(e-.2,.2)}))}}),(0,a.jsx)(M,{action:"zoomIn",onClick:function(){S((function(e){return e+.2}))}})]}),(0,a.jsx)(o(),{className:"rustic-pdf-viewer-body",children:(0,a.jsx)(o(),{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)(M,{action:"previousPage",onClick:function(){i>1&&(l(i-1),p(i-1))},isDisabled:1===i}),(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<=c&&l(r)},size:"small",className:"rustic-pdf-page-input"}),(0,a.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",c]}),(0,a.jsx)(M,{action:"nextPage",onClick:function(){i<c&&(l(i+1),p(i+1))},isDisabled:i===c})]})]})}};function R(e){var r=(0,N.useTheme)(),n=(0,x.useState)(!1),t=n[0],i=n[1];function o(){i(!1)}var l,c,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:(c=e.file.name).length<=15?c:c.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(){i(!0)},children:[(0,a.jsx)(f(),{variant:"subtitle2",className:"rustic-file-preview-name",children:b}),(0,a.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,a.jsx)(F(),{open:t,onClose:o,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)(s(),{onClick:o,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:_,showFullName:!0};var z=n(3110);const B=require("@mui/material"),E=require("@mui/material/Button");var L=n.n(E);const $=require("@mui/material/Drawer");var H=n.n($);const V=require("@mui/material/ListItemText");var G=n.n(V);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],i=(0,x.useRef)(null),o=(0,N.useTheme)(),l=(0,B.useMediaQuery)(o.breakpoints.down("md")),c=l?H():W(),u={borderRadius:"".concat(o.shape.borderRadius,"px"),border:"1px solid ".concat(o.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)(G(),{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(o.shape.borderRadius,"px ").concat(o.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:i.current};return(0,a.jsxs)(a.Fragment,{children:[(v={onClick:function(e){e.stopPropagation(),t(!0)},"aria-label":e.ariaLabel,ref:i,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)(s(),K({},v,{children:e.icon?e.icon:h}))})),(0,a.jsx)(c,K({open:n,onClose:function(){return t(!1)}},g,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":K(K({},u),{backgroundImage:"none",boxShadow:o.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,i=r.length;a<i;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],i=n[1],l=(0,x.useState)([]),c=l[0],d=l[1],p=(0,x.useState)({}),v=p[0],j=p[1],y=(0,x.useRef)({}),w=(0,b.v4)();function F(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)})),i((function(e){return e.filter((function(e){return e.id!==r}))}))}(e,r,n)}(0,x.useEffect)((function(){i([]),d([]),y.current={}}),[e.messageId]);var N=(0,a.jsx)(o(),{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)(o(),{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)(s(),{color:"primary",onClick:function(){return function(r,n){var t,a;d([]);var o=r.name;if(y.current=ee(ee({},y.current),((t={})[o]=y.current[o]--,t)),e.onFileUpdate("remove",o),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",o).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);h().delete(l).then((function(){return i((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return e.onFileUpdate("add",o),d((function(e){return re(re([],e,!0),["Failed to delete ".concat(o,". Please try again.")],!1)}))}))}else r.abortController.abort(),i((function(e){return e.filter((function(e,r){return r!==n}))})),y.current=ee(ee({},y.current),((a={})[o]=y.current[o]++,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)(o(),{children:c.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)(o(),{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)(s(),{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 o=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,a,e.maxFileCount);o&&o.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 i=a+1,o=t.lastIndexOf("."),l=t.substring(0,o),s=t.substring(o);t="".concat(l,"(").concat(a,")").concat(s),y.current=ee(ee({},y.current),((r={})[e.name]=i,r))}else y.current=ee(ee({},y.current),((n={})[e.name]=1,n));return t}(r),o=new File([r],a,{type:r.type});if(e.getUploadData||v){var l=e.getUploadData?e.getUploadData(a):{},s=ee(ee({},l),v);Object.keys(s).forEach((function(e){var r=s[e];n.append(e,"object"==typeof r?JSON.stringify(r):r)}))}n.append("file",o);var c=(0,b.v4)(),u={name:a,loadingProgress:0,abortController:t,id:c};function d(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=u.id,i((function(e){var t=e.map((function(e){return e.id===n?ee(ee({},e),{loadingProgress:r}):e}));return t})))}i((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 o(){return h().post(m,n,{onUploadProgress:d,signal:t.signal}).then((function(r){var t,a,o=n.get("file");r.data.url&&o instanceof File&&o.name&&e.onFileUpdate("update",o.name,r.data.url),r.data.fileId&&(t=r.data,a=u.id,i((function(e){var r=e.findIndex((function(e){return e.id===a}));if(-1!==r){var n=re([],e,!0);return n[r]=ee(ee({},n[r]),{id:t.fileId}),n}return e})))})).catch((function(t){var l,s,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(/[.*+?^${}()|[\]\\]/g,"\\$&"),"(\\(\\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 i=a.name.match(v),o=i&&i[1]?parseInt(i[1].slice(1,-1),10):0;r=Math.max(r,o)}}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),i((function(e){return e.map((function(e){return e.id===c?ee(ee({},e),{name:t,loadingProgress:0}):e}))})),o()})).catch((function(){var e;F(r.name,u.id,null===(e=t.response)||void 0===e?void 0:e.data)})):F(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&&P(C,e.errorMessagesContainer),t.length>0&&P(N,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,2CAobrC;AACD,eAAe,QAAQ,CAAA"}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
.rustic-base-input .rustic-input-label {
|
|
27
|
-
padding-top:
|
|
27
|
+
padding-top: 10px;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.rustic-base-input .rustic-text-field .MuiOutlinedInput-input {
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
|
|
46
46
|
.rustic-base-input .rustic-input-adornment {
|
|
47
47
|
align-self: start;
|
|
48
|
-
margin-top: 12px;
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
span.rustic-icon-large {
|
|
@@ -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:()=>A});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 w=require("@mui/material/TextField");var O=o.n(w);const S=require("@mui/material/Tooltip");var k=o.n(S);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(e){var t=new(0,e.Picker),o="dark"===r.palette.mode?"dark":"light";t.classList.add(o),Object.keys(l).forEach((function(e){t.style.setProperty(e,l[e])})),n.current=t})).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=new C.Database,B=(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],w=g[1],S=(0,c.useState)(""),E=S[0],C=S[1],q=(0,c.useState)([]),_=q[0],B=q[1],F=(0,c.useState)(!1),L=F[0],A=F[1],D=(0,c.useRef)(null),W=!n.trim().length&&!e.isSendEnabled,K="".concat(s?"Stop":"Start"," speech to text"),$=f?"primary.main":"primary.light",Q=s?"error.main":$,G=s?"stop_circle":"speech_to_text";function H(e,r){if(void 0===r&&(r=!1),D.current){var t=D.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=D.current)||void 0===e||e.focus(),null===(r=D.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}A(!1)}var J=j?(0,a.jsx)(d(),{size:24}):(0,a.jsx)(k(),{title:K,children:(0,a.jsx)(m(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,s?(e.stop(),w(!0),l(!1)):(e.start(),C(""),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=D.current)||void 0===r||r.focus(),l(!1)},e.onerror=function(e){var r=I[e.error];C(r),l(!1)},e.onend=function(){w(!1),l(!1)}},size:"small",sx:{color:Q,"&:hover":{color:"primary.main"}},children:(0,a.jsx)(T,{name:G})})});function U(){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(""),C("")}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:[_.length>0&&(0,a.jsx)(x(),{open:L,anchorEl:D.current,onClose:function(){return A(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,a.jsx)(b(),{children:_.map((function(e,r){return"unicode"in e&&(0,a.jsx)(y(),{onClick:function(){return H(e.unicode,!0)},children:z(e)},r)}))})}),(0,a.jsx)(O(),{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(),!W&&U())},onChange:function(r){C("");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,"");M.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)})),A(!1)}else a?(n=a[0].replace(":",""),M.getEmojiBySearchQuery(n).then((function(r){r.length?(B(r.slice(0,e.maximumEmojiSearchResults)),A(!0)):(B([]),A(!1))})).catch((function(){B([]),A(!1)}))):A(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:D,color:"secondary",size:"small",InputProps:{endAdornment:(0,a.jsxs)(h(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(R,{onEmojiClick:H,buttonColor:$}),e.enableSpeechToText&&J]})},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:U,disabled:W,color:"secondary",children:(0,a.jsx)(T,{name:"send"})})})})]})]})}));B.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const F=B;var L=function(){return L=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},L.apply(this,arguments)};const A=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)(F,L({},t,{send:function(e){r.send(e)}}))};return i})()));
|
|
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={8342: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:()=>L});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 g=o.n(v);const y=require("@mui/material/MenuList");var b=o.n(y);const j=require("@mui/material/Popover");var x=o.n(j);const O=require("@mui/material/TextField");var S=o.n(O);const w=require("@mui/material/Tooltip");var k=o.n(w);const E=require("@mui/material/Typography");var C=o.n(E),P=o(8342);const N=require("uuid");var T;function _(e,r){var t=[];if(e&&(null==e?void 0:e.trim().length)&&t.push({type:"text",text:e}),r&&r.length>0)for(var n=0;n<(null==r?void 0:r.length);n++)t.push({type:"file_url",file_url:{url:r[n].url,name:r[n].name}});return{messages:[{content:t,role:"user"}]}}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(T||(T={}));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 R(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 M=require("@mui/material/styles"),z=function(e){var r=(0,M.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,8342,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)(R,{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 D={"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 I(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var A=(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],y=(0,c.useState)(!1),j=y[0],O=y[1],w=(0,c.useState)(""),E=w[0],T=w[1],q=(0,c.useState)([]),M=q[0],A=q[1],B=(0,c.useState)(!1),F=B[0],L=B[1],H=(0,c.useRef)(null),W=new P.Database({dataSource:e.emojiDataSource}),K=!n.trim().length&&!e.isSendEnabled,U="".concat(s?"Stop":"Start"," speech to text"),$=f?"primary.main":"primary.light",Q=s?"error.main":$,G=s?"stop_circle":"speech_to_text";function J(e,r){if(void 0===r&&(r=!1),H.current){var t=H.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=H.current)||void 0===e||e.focus(),null===(r=H.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}L(!1)}var V=j?(0,a.jsx)(d(),{size:24}):(0,a.jsx)(k(),{title:U,children:(0,a.jsx)(m(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,s?(e.stop(),O(!0),l(!1)):(e.start(),T(""),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=H.current)||void 0===r||r.focus(),l(!1)},e.onerror=function(e){var r=D[e.error];T(r),l(!1)},e.onend=function(){O(!1),l(!1)}},size:"small",sx:{color:Q,"&:hover":{color:"primary.main"}},children:(0,a.jsx)(R,{name:G})})});function X(){var r=(new Date).toISOString(),t={id:(0,N.v4)(),timestamp:r,sender:e.sender,conversationId:e.conversationId,format:"chatCompletionRequest",data:_(n)};e.send(t),o(""),T("")}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)(C(),{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:H.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)(g(),{onClick:function(){return J(e.unicode,!0)},children:I(e)},r)}))})}),(0,a.jsx)(S(),{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||X())},onChange:function(r){T("");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?(A(r.slice(0,e.maximumEmojiSearchResults)),L(!0)):(A([]),L(!1))})).catch((function(){A([]),L(!1)}))):L(!1)},onFocus:function(){return v(!0)},onBlur:function(){return v(!1)},inputRef:H,color:"secondary",size:"small",slotProps:{input:{endAdornment:(0,a.jsxs)(h(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(z,{dataSource:e.emojiDataSource,onEmojiClick:J,buttonColor:$}),e.enableSpeechToText&&V]})},inputLabel:{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:X,disabled:K,color:"secondary",children:(0,a.jsx)(R,{name:"send"})})})})]})]})}));A.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const B=A;var F=function(){return F=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},F.apply(this,arguments)};const L=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)(B,F({},t,{send:function(e){r.send(e)}}))};return i})()));
|
|
@@ -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={
|
|
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={4445:(e,t,o)=>{o.d(t,{default:()=>l});var r=o(8732),n=o(909),a=o.n(n),i=o(4603),c=o.n(i);o(2015);const l=function(e){return(0,r.jsx)(c(),{title:e.label,children:(0,r.jsx)(a(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})}},909:e=>{e.exports=require("@mui/material/IconButton")},4603:e=>{e.exports=require("@mui/material/Tooltip")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};o.r(r),o.d(r,{default:()=>s});var n=o(8732),a=o(2015),i=function(){return i=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},i.apply(this,arguments)};function c(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:i({},t),children:e.name})}var l=o(4445);const s=function(e){var t=(0,a.useState)("Copy text"),o=t[0],r=t[1];return(0,n.jsx)(l.default,{message:e.message,icon:(0,n.jsx)(c,{name:"file_copy"}),onClick:function(e){e.data.text&&navigator.clipboard.writeText(e.data.text).then((function(){r("Copied"),setTimeout((function(){r("Copy text")}),2e3)})).catch((function(){r("Failed to copy")}))},label:o})};return r})()));
|
|
@@ -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={909:e=>{e.exports=require("@mui/material/IconButton")},
|
|
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={909:e=>{e.exports=require("@mui/material/IconButton")},4603:e=>{e.exports=require("@mui/material/Tooltip")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};r.r(o),r.d(o,{default:()=>s});var n=r(8732),i=r(909),a=r.n(i),u=r(4603),l=r.n(u);r(2015);const s=function(e){return(0,n.jsx)(l(),{title:e.label,children:(0,n.jsx)(a(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})};return o})()));
|
|
@@ -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={
|
|
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={4445:(e,t,r)=>{r.d(t,{default:()=>l});var a=r(8732),o=r(909),n=r.n(o),s=r(4603),i=r.n(s);r(2015);const l=function(e){return(0,a.jsx)(i(),{title:e.label,children:(0,a.jsx)(n(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})}},909:e=>{e.exports=require("@mui/material/IconButton")},4603:e=>{e.exports=require("@mui/material/Tooltip")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},t={};function r(a){var o=t[a];if(void 0!==o)return o.exports;var n=t[a]={exports:{}};return e[a](n,n.exports,r),n.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};r.r(a),r.d(a,{default:()=>c});var o=r(8732),n=r(2015),s=function(){return s=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function i(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,o.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:s({},t),children:e.name})}var l=r(4445);const c=function(e){var t=(0,n.useState)("Start reading aloud"),r=t[0],a=t[1],s=[e.message.data.title,e.message.data.description,e.message.data.alt,e.message.data.text,e.message.data.transcript].filter(Boolean).join(" "),c=new SpeechSynthesisUtterance(s);return(0,o.jsx)(l.default,{message:e.message,icon:(0,o.jsx)(i,{name:"text_to_speech"}),onClick:function(){window.speechSynthesis.speaking?(window.speechSynthesis.cancel(),a("Start reading aloud")):(c.onend=function(){a("Start reading aloud")},window.speechSynthesis.speak(c),a("Stop reading aloud"))},label:r})};return a})()));
|
|
@@ -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
|
}
|