@rustic-ai/ui-components 0.0.44 → 0.0.46
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/elementRenderer/elementRenderer.d.ts +2 -2
- package/dist/components/elementRenderer/elementRenderer.d.ts.map +1 -1
- package/dist/components/image/image.d.ts.map +1 -1
- package/dist/components/image/index.js +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/input/baseInput/baseInput.d.ts.map +1 -1
- package/dist/components/input/multimodal/multimodalInput/index.js +1 -1
- package/dist/components/input/textInput/index.js +1 -1
- package/dist/components/messageArchive/index.css +83 -0
- package/dist/components/messageArchive/index.d.ts +4 -0
- package/dist/components/messageArchive/index.d.ts.map +1 -0
- package/dist/components/messageArchive/index.js +1 -0
- package/dist/components/messageArchive/messageArchive.d.ts +25 -0
- package/dist/components/messageArchive/messageArchive.d.ts.map +1 -0
- package/dist/components/question/index.js +1 -1
- package/dist/components/sharedDescription.d.ts +1 -0
- package/dist/components/sharedDescription.d.ts.map +1 -1
- package/dist/components/types.d.ts +28 -6
- package/dist/components/types.d.ts.map +1 -1
- package/dist/index.css +36 -2
- package/dist/index.js +1 -1
- package/package.json +1 -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={227:(e,r,t)=>{t.d(r,{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={227:(e,r,t)=>{t.d(r,{A:()=>l});var a=t(8732),o=t(785),n=t.n(o),i=t(7447),s=t.n(i),u=t(3840),d=t(2015);function c(e){var r=e.replace(/^[\u200B-\u200F\uFEFF]/,""),t=u.marked.parse(r,{async:!1});return s().sanitize(t)}const l=function(e){var r=(0,d.useState)(c(e.text)),t=r[0],o=r[1];return(0,d.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var r=e.updatedData[e.updatedData.length-1].text;o(c(r))}}),[e.text,e.updatedData]),(0,a.jsx)(n(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:t}})}},6989:e=>{e.exports=require("@mui/material/Box")},785:e=>{e.exports=require("@mui/material/Typography")},7447:e=>{e.exports=require("dompurify")},3840:e=>{e.exports=require("marked")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")},3903:e=>{e.exports=require("uuid")}},r={};function t(a){var o=r[a];if(void 0!==o)return o.exports;var n=r[a]={exports:{}};return e[a](n,n.exports,t),n.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 a in r)t.o(r,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:r[a]})},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 a={};t.r(a),t.d(a,{UniformsForm:()=>x});var o=t(8732),n=t(6989),i=t.n(n),s=t(785),u=t.n(s);const d=require("ajv");var c=t.n(d),l=t(2015);const p=require("uniforms-bridge-json-schema"),m=require("uniforms-mui");var f=t(3903),v=t(227);function x(e){var r=(0,l.useState)(e.data),t=r[0],a=r[1];(0,l.useEffect)((function(){e.data&&a(e.data)}),[e.data]);var n,s,d=new(c())({allErrors:!0,useDefaults:!0,keywords:["uniforms"]}),x=(n=e.schema,s=d.compile(n),function(e){var r;return s(e),(null===(r=s.errors)||void 0===r?void 0:r.length)?{details:s.errors}:null}),y=new p.JSONSchemaBridge({schema:e.schema,validator:x});return(0,o.jsxs)(i(),{className:"rustic-form",children:[e.title&&(0,o.jsx)(u(),{variant:"h6",children:e.title}),e.description&&(0,o.jsx)(v.A,{text:e.description}),(0,o.jsx)(m.AutoForm,{schema:y,onSubmit:function(r){return function(r){var t,o=(new Date).toISOString(),n={id:(0,f.v4)(),timestamp:o,sender:e.sender,conversationId:e.conversationId,format:"formResponse",data:{data:r,inReplyTo:e.messageId}};a(r),null===(t=e.ws)||void 0===t||t.send(n)}(r)},model:t,disabled:!!t||!e.ws})]})}return a})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elementRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/elementRenderer/elementRenderer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE9E,UAAU,oBAAoB;IAC5B,MAAM,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"elementRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/elementRenderer/elementRenderer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE9E,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,eAAe,CAAA;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,iBAAiB,EAAE,YAAY,CAAA;CAChC;AAED,QAAA,MAAM,eAAe,GAAI,OAAO,oBAAoB,4CAyBnD,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/components/image/image.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,iBAAiB,CAAA;AASxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,wTAAwT;AACxT,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,GAA6B,EAC7B,GAAG,KAAK,EACT,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/components/image/image.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,iBAAiB,CAAA;AASxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,wTAAwT;AACxT,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,GAA6B,EAC7B,GAAG,KAAK,EACT,EAAE,WAAW,2CA6Db"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ParticipantRole:()=>
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ParticipantRole:()=>y,ParticipantType:()=>g,default:()=>b});const r=require("react/jsx-runtime"),n=require("@mui/material/CircularProgress");var a=e.n(n);const o=require("@mui/material/Typography");var i=e.n(o);const u=require("react");var c,s=function(){return s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},s.apply(this,arguments)};!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(c||(c={}));const l=require("dompurify");var d=e.n(l);const f=require("marked");function p(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=f.marked.parse(t,{async:!1});return d().sanitize(r)}const h=function(e){var t=(0,u.useState)(p(e.text)),n=t[0],a=t[1];return(0,u.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var t=e.updatedData[e.updatedData.length-1].text;a(p(t))}}),[e.text,e.updatedData]),(0,r.jsx)(i(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:n}})};var y,g,m=function(){return m=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},m.apply(this,arguments)};!function(e){e.Owner="owner",e.Member="member"}(y||(y={})),function(e){e.Human="human",e.Agent="agent"}(g||(g={}));const b=function(e){var t,n,o,c=e.alt,l=void 0===c?"An image is displayed":c,d=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]])}return r}(e,["alt"]),f=(0,u.useState)(!0),p=f[0],y=f[1],g=(0,u.useState)(""),b=g[0],v=g[1],O=(0,u.useState)(""),j=O[0],x=O[1];return(0,u.useEffect)((function(){d.getAuthHeaders&&(y(!0),d.getAuthHeaders().then((function(e){return fetch(d.src,{headers:e.headers})})).then((function(e){return e.blob()})).then((function(e){var t=URL.createObjectURL(e);x(t)})).catch((function(){v("Image failed to load"),y(!1)})))}),[d.src,d.getAuthHeaders]),b.length>0?(0,r.jsx)(i(),{variant:"body2",children:b}):(0,r.jsxs)("figure",{children:[p&&(0,r.jsx)(a(),{}),d.title&&(0,r.jsx)(i(),{variant:"h6",children:d.title}),(!d.getAuthHeaders||j)&&(0,r.jsx)("img",m({},(t=d.width,n=d.height,o={},t&&(o={width:t}),n&&(o=s(s({},o),{height:n})),t||n||(o={className:"rustic-fit-container"}),o),{src:d.getAuthHeaders?j:d.src,alt:l,onError:function(){v("Image failed to load"),y(!1)},onLoad:function(){y(!1)}})),d.description&&(0,r.jsx)("figcaption",{children:(0,r.jsx)(h,{text:d.description})})]})};return t})()));
|
|
@@ -13,6 +13,7 @@ import MarkedStreamingMarkdown from './markdown/markedStreamingMarkdown';
|
|
|
13
13
|
import Sound from './media/audio/sound';
|
|
14
14
|
import Video from './media/video/video';
|
|
15
15
|
import PopoverMenu from './menu/popoverMenu';
|
|
16
|
+
import MessageArchive from './messageArchive/messageArchive';
|
|
16
17
|
import CopyText from './messageCanvas/actions/copy/copyText';
|
|
17
18
|
import Action from './messageCanvas/actions/index';
|
|
18
19
|
import TextToSpeech from './messageCanvas/actions/textToSpeech/textToSpeech';
|
|
@@ -34,7 +35,7 @@ import PerspectiveViz from './visualization/perspectiveViz/perspectiveViz';
|
|
|
34
35
|
import PlotlyGraph from './visualization/plotlyGraph/plotlyGraph';
|
|
35
36
|
import VegaLiteViz from './visualization/vegaLiteViz/vegaLiteViz';
|
|
36
37
|
import Weather from './weather/weather';
|
|
37
|
-
export { Action, ChatCompletion, CodeSnippet, CopyText, ElementRenderer, FCCalendar, Icon, Image, MarkedMarkdown, MarkedStreamingMarkdown, MermaidViz, MessageCanvas, MessageSpace, MultimodalInput, Multipart, OpenLayersMap, ParticipantsContainer, PDFViewer, PerspectiveViz, PlotlyGraph, PopoverMenu, PromptBuilder, Prompts, Question, Sound, StreamingText, Table, Text, TextInput, TextToSpeech, Timestamp, UniformsForm, Uploader, VegaLiteViz, Video, Weather, };
|
|
38
|
+
export { Action, ChatCompletion, CodeSnippet, CopyText, ElementRenderer, FCCalendar, Icon, Image, MarkedMarkdown, MarkedStreamingMarkdown, MermaidViz, MessageArchive, MessageCanvas, MessageSpace, MultimodalInput, Multipart, OpenLayersMap, ParticipantsContainer, PDFViewer, PerspectiveViz, PlotlyGraph, PopoverMenu, PromptBuilder, Prompts, Question, Sound, StreamingText, Table, Text, TextInput, TextToSpeech, Timestamp, UniformsForm, Uploader, VegaLiteViz, Video, Weather, };
|
|
38
39
|
export * from '../rusticTheme';
|
|
39
40
|
export type * from './types';
|
|
40
41
|
export { ParticipantRole, ParticipantType } from './types';
|
|
@@ -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,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,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,KAAK,EACL,aAAa,EACb,KAAK,EACL,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,OAAO,GACR,CAAA;AAED,cAAc,gBAAgB,CAAA;AAC9B,mBAAmB,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC1D,mBAAmB,6CAA6C,CAAA;AAChE,mBAAmB,+CAA+C,CAAA;AAClE,mBAAmB,+CAA+C,CAAA"}
|
|
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,cAAc,MAAM,iCAAiC,CAAA;AAC5D,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,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,cAAc,EACd,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,KAAK,EACL,aAAa,EACb,KAAK,EACL,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,OAAO,GACR,CAAA;AAED,cAAc,gBAAgB,CAAA;AAC9B,mBAAmB,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC1D,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;AACxB,OAAO,oBAAoB,CAAA;AAmB3B,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"baseInput.d.ts","sourceRoot":"","sources":["../../../../src/components/input/baseInput/baseInput.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAA;AACxB,OAAO,oBAAoB,CAAA;AAmB3B,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAA;AA4evE,QAAA,MAAM,SAAS;;wCAA+B,CAAA;AAE9C,eAAe,SAAS,CAAA"}
|
|
@@ -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,t,r={9767:(e,t,r)=>{r.d(t,{A:()=>a});var n=r(8732),o=(r(2015),function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)});function a(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:o({},t),children:e.name})}},3110:(e,t,r)=>{r.d(t,{default:()=>n});const n=r(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 o(e){var t=n[e];if(void 0!==t)return t.exports;var a=n[e]={exports:{}};return r[e](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var a=Object.create(null);o.r(a);var i={};e=e||[null,t({}),t([]),t(t)];for(var c=2&n&&r;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach((e=>i[e]=()=>r[e]));return i.default=()=>r,o.d(a,i),a},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 a={};o.r(a),o.d(a,{ParticipantRole:()=>Se,ParticipantType:()=>Oe,default:()=>Fe});var i=o(8732);const c=require("@mui/material/Box");var l=o.n(c);const s=require("@mui/material/styles");var u=o(2015);const d=require("uuid");var p;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(p||(p={}));const f=require("@mui/material/Avatar");var m=o.n(f);const h=require("@mui/material/CircularProgress");var v=o.n(h);const g=require("@mui/material/IconButton");var x=o.n(g);const b=require("@mui/material/InputAdornment");var y=o.n(b);const j=require("@mui/material/MenuItem");var w=o.n(j);const S=require("@mui/material/MenuList");var O=o.n(S);const N=require("@mui/material/Popover");var C=o.n(N);const F=require("@mui/material/TextField");var k=o.n(F);const P=require("@mui/material/Tooltip");var E=o.n(P);const I=require("@mui/material/Typography");var q=o.n(I),A=o(8342),T=o(9767);const R=function(e){var t=(0,s.useTheme)(),r=(0,u.useRef)(null),n=(0,u.useRef)(null),a=(0,u.useState)(!1),c=a[0],l=a[1],d={"--indicator-color":t.palette.divider,"--background":t.palette.background.paper,"--input-border-color":t.palette.divider,"--outline-color":t.palette.secondary.main};function p(){l(!1)}function f(t){t.detail.unicode&&e.onEmojiClick(t.detail.unicode),p()}return(0,u.useEffect)((function(){n.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then((function(r){var o=new(0,r.Picker)({dataSource:e.dataSource}),a="dark"===t.palette.mode?"dark":"light";o.classList.add(a),Object.keys(d).forEach((function(e){o.style.setProperty(e,d[e])})),n.current=o})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,u.useEffect)((function(){return n.current&&n.current.addEventListener("emoji-click",f),function(){var e;null===(e=n.current)||void 0===e||e.removeEventListener("emoji-click",f)}}),[c,e.onEmojiClick]),(0,i.jsxs)("div",{children:[(0,i.jsx)(E(),{title:"Emoji",children:(0,i.jsx)(x(),{size:"small",ref:r,onClick:function(){l((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:c,anchorEl:r.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 L(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}function U(e){return(0,i.jsxs)(l(),{className:"rustic-participant-profile",children:[(0,i.jsx)(m(),{src:e.icon,className:"rustic-participant-avatar"}),(0,i.jsx)(q(),{variant:"body1Bold",children:e.displayName})]})}function _(e){var t=e.items,r=e.isOpen,n=e.onClose,o=e.onSelect,a=e.renderItem,c=e.anchorEl,l=e.selectedIndex;return(0,i.jsx)(C(),{disableAutoFocus:!0,open:r&&t.length>0,anchorEl:c,onClose:n,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},className:"rustic-suggestion-menu",children:(0,i.jsx)(O(),{children:t.map((function(e,t){return(0,i.jsx)(w(),{onClick:function(){return o(e)},selected:t===l,children:a(e)},t)}))})})}const z=(0,u.forwardRef)((function(e,t){var r=e.multiline,n=void 0===r||r,o=e.fullWidth,a=void 0===o||o,c=e.maxRows,s=void 0===c?6:c,p=e.enableSpeechToText,f=void 0!==p&&p,m=e.maximumEmojiSearchResults,h=void 0===m?5:m,g=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["multiline","fullWidth","maxRows","enableSpeechToText","maximumEmojiSearchResults"]),b=(0,u.useState)(""),j=b[0],w=b[1],S=(0,u.useState)(!1),O=S[0],N=S[1],C=(0,u.useState)(!1),F=C[0],P=C[1],I=(0,u.useState)(!1),z=I[0],M=I[1],B=(0,u.useState)(""),H=B[0],$=B[1],W=(0,u.useState)([]),K=W[0],G=W[1],Q=(0,u.useState)(!1),V=Q[0],Y=Q[1],Z=(0,u.useState)(0),J=Z[0],X=Z[1],ee=(0,u.useRef)(null),te=new A.Database({dataSource:g.emojiDataSource}),re=!j.trim().length,ne="".concat(O?"Stop":"Start"," speech to text"),oe=F?"primary.main":"primary.light",ae=O?"error.main":oe,ie=O?"stop_circle":"speech_to_text",ce=(0,u.useState)([]),le=ce[0],se=ce[1],ue=(0,u.useState)(!1),de=ue[0],pe=ue[1];function fe(){return"boolean"==typeof g.isSendEnabled?!g.isSendEnabled:re}function me(e,t){if(ee.current){var r=ee.current,n=r.selectionStart,o=r.selectionEnd;if("number"==typeof n&&"number"==typeof o){var a,i=j||"",c=i.substring(0,n),l=i.substring(o),s=void 0;t?(s=c.replace(t,e)+l,a=c.replace(t,e).length):(s=c+e+l,a=n+e.length),w(s),setTimeout((function(){var e,t;null===(e=ee.current)||void 0===e||e.focus(),null===(t=ee.current)||void 0===t||t.setSelectionRange(a,a)}),0)}}}function he(e){me("@".concat(e," "),/@(\w*)$/),se([])}function ve(e,t){void 0===t&&(t=!1),me(e,t?/:(\w+)$/:void 0),Y(!1)}var ge=z?(0,i.jsx)(v(),{size:24}):(0,i.jsx)(E(),{title:ne,children:(0,i.jsx)(x(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,O?(e.stop(),M(!0),N(!1)):(e.start(),$(""),N(!0)),e.onstart=function(){N(!0)},e.onresult=function(e){var t,r=e.results[0][0].transcript;j.length>0?w(j+" "+r):w(r),null===(t=ee.current)||void 0===t||t.focus(),N(!1)},e.onerror=function(e){var t=D[e.error];$(t),N(!1)},e.onend=function(){M(!1),N(!1)}},size:"small",sx:{color:ae,"&:hover":{color:"primary.main"}},children:(0,i.jsx)(T.A,{name:ie})})});function xe(){var e=(new Date).toISOString(),t={id:(0,d.v4)(),timestamp:e,sender:g.sender,conversationId:g.conversationId,format:"chatCompletionRequest",data:{text:j}};g.send(t),w(""),$("")}return(0,i.jsxs)(l(),{className:"rustic-base-input",ref:t,children:[(0,i.jsxs)(l(),{className:"rustic-error-and-input-container",children:[(0,i.jsx)(l(),{className:"rustic-error-container",children:(0,i.jsx)(q(),{variant:"caption",color:"error",className:"rustic-error-message",children:H})}),(0,i.jsxs)(l(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:F?"secondary.main":"action.disabled"},children:[K.length>0&&ee.current&&(0,i.jsx)(_,{anchorEl:ee.current,items:K.filter((function(e){return"unicode"in e})),isOpen:V,onClose:function(){Y(!1),X(0)},onSelect:function(e){return ve(e.unicode,!0)},selectedIndex:J,renderItem:L}),le.length>0&&ee.current&&(0,i.jsx)(_,{anchorEl:ee.current,items:le,isOpen:de,onClose:function(){pe(!1),X(0)},onSelect:function(e){return he(e.displayName)},renderItem:U,selectedIndex:J}),(0,i.jsx)(k(),{className:"rustic-text-field",variant:"outlined",value:j,label:g.label,placeholder:g.placeholder,maxRows:s,multiline:n,fullWidth:a,onKeyDown:function(e){var t,r="ArrowDown"===e.key,n="ArrowUp"===e.key;if("Enter"===e.key||"Tab"===e.key)e.shiftKey||e.preventDefault(),V&&K.length>0&&"unicode"in K[J]?ve(K[J].unicode,!0):de&&le.length>0?he(le[J].displayName):e.shiftKey||fe()||xe();else{if(r||n)return e.preventDefault(),t=r?1:-1,void(V?X((function(e){return(e+t+K.length)%K.length})):de&&X((function(e){return(e+t+le.length)%le.length})));0!==J&&X(0)}},onChange:function(e){$("");var t=e.target.value;w(t),function(e){var t=e.match(/@(\w*)$/);if(t&&g.getMembers){var r=t[1].toLowerCase();g.getMembers().then((function(e){var t=e.filter((function(e){return e.displayName.toLowerCase().startsWith(r)}));se(t),t.length>0?pe(!0):pe(!1)}))}else se([])}(t);var r,n=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(n){var a=n[0].replace(/:/g,"");te.getEmojiByShortcode(a).then((function(e){if(e&&"unicode"in e){var r=t.replace(n[0],e.unicode);w(r)}else w(t)})).catch((function(){w(t)})),Y(!1)}else o?(r=o[0].replace(":",""),te.getEmojiBySearchQuery(r).then((function(e){e.length?(G(e.slice(0,h)),Y(!0)):(G([]),Y(!1))})).catch((function(){G([]),Y(!1)}))):Y(!1)},onFocus:function(){return P(!0)},onBlur:function(){return P(!1)},inputRef:ee,color:"secondary",size:"small",slotProps:{input:{endAdornment:(0,i.jsxs)(y(),{position:"end",className:"rustic-input-adornment",children:[(0,i.jsx)(R,{dataSource:g.emojiDataSource,onEmojiClick:ve,buttonColor:oe}),f&&ge]})},inputLabel:{className:F?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}}),(0,i.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,i.jsxs)(l(),{className:"rustic-input-actions",children:[g.children,(0,i.jsx)(E(),{title:"Send",children:(0,i.jsx)("span",{className:"rustic-send-button",children:(0,i.jsx)(x(),{"aria-label":"send message",onClick:xe,disabled:fe(),color:"secondary",children:(0,i.jsx)(T.A,{name:"send"})})})})]})]})})),M=require("@mui/material/LinearProgress");var B=o.n(M);const H=require("axios");var $=o.n(H);const W=require("react-dom"),K=require("@mui/material/Card");var G=o.n(K);const Q=require("@mui/material/Modal");var V=o.n(Q);const Y=require("@mui/material/useMediaQuery");var Z=o.n(Y);const J=require("@mui/system/Stack");var X=o.n(J);const ee=require("@mui/system/useTheme");var te=o.n(ee);const re=require("pdfjs-dist"),ne=function(e){var t={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"}},r=(t[e.action].label.replaceAll(" ","-").toLowerCase(),t[e.action]);return(0,i.jsx)(E(),{title:r.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:r.symbol})})})})};var oe={pdf:function(e){var t,r=(0,u.useRef)(null),n=(0,u.useState)(1),o=n[0],a=n[1],c=(0,u.useState)(1),s=c[0],d=c[1],p=(0,u.useState)(1),f=p[0],m=p[1],h=(0,u.useState)(!1),v=h[0],g=h[1],x=(0,u.useState)(),b=x[0],y=x[1],j=te()(),w=Z()(j.breakpoints.down("sm")),S=Z()(j.breakpoints.between("sm","md"));if(t=e.url,!/\/[^/]+\.pdf$/.test(t))return(0,i.jsx)(G(),{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 O=(0,u.useState)((function(){return w?.5:S?1:1.5})),N=O[0],C=O[1];function F(t){re.getDocument({url:e.url,httpHeaders:t}).promise.then((function(e){d(e.numPages),function(e){e.getPage(o).then((function(e){var t=e.getViewport({scale:N}),n=r.current;if(n){var o=n.getContext("2d");if(o){var a=window.devicePixelRatio||1;n.style.width="".concat(t.width,"px"),n.style.height="".concat(t.height,"px"),n.width=t.width*a,n.height=t.height*a;var i={canvasContext:o,viewport:t,transform:[a,0,0,a,0,0]};b&&b.cancel();var c=e.render(i);y(c),c.promise.then((function(){y(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}return(0,u.useEffect)((function(){re.GlobalWorkerOptions.workerSrc||(re.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(re.version,"/pdf.worker.mjs")),e.getAuthHeaders?e.getAuthHeaders().then((function(e){return F(e.headers)})).catch((function(){return g(!0)})):F()}),[e.url,o,N]),v?(0,i.jsx)(G(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(q(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,i.jsxs)(G(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,i.jsxs)(l(),{className:"rustic-pdf-viewer-header",children:[(0,i.jsx)(ne,{action:"zoomOut",onClick:function(){C((function(e){return Math.max(e-.2,.2)}))}}),(0,i.jsx)(ne,{action:"zoomIn",onClick:function(){C((function(e){return e+.2}))}})]}),(0,i.jsx)(l(),{className:"rustic-pdf-viewer-body",children:(0,i.jsx)(l(),{className:"rustic-pdf-viewer-body-inner",children:(0,i.jsx)("canvas",{ref:r})})}),(0,i.jsxs)(X(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,i.jsx)(ne,{action:"previousPage",onClick:function(){o>1&&(a(o-1),m(o-1))},isDisabled:1===o}),(0,i.jsx)(q(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,i.jsx)(k(),{type:"number",value:f,onChange:function(e){var t=parseInt(e.target.value);m(t),!isNaN(t)&&t>=1&&t<=s&&a(t)},size:"small",className:"rustic-pdf-page-input"}),(0,i.jsxs)(q(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,i.jsx)(ne,{action:"nextPage",onClick:function(){o<s&&(a(o+1),m(o+1))},isDisabled:o===s})]})]})}};function ae(e){var t=e.supportedViewers,r=void 0===t?oe:t,n=e.showFullName,o=void 0===n||n,a=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["supportedViewers","showFullName"]),c=(0,s.useTheme)(),l=(0,u.useState)(!1),d=l[0],p=l[1];function f(){p(!1)}var m,h,v=a.file.url&&(m=a.file.url.split("."))[m.length-1].toLowerCase(),g=v&&r?r[v]:null,b=!!g,y=b?" rustic-cursor-pointer":"",j="rustic-file-preview ".concat(o?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width").concat(y),w=o?a.file.name:(h=a.file.name).length<=15?h:h.substring(0,12)+"...";return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(G(),{className:j,variant:"outlined",sx:{boxShadow:c.shadows[1]},onClick:function(){p(!0)},children:[(0,i.jsx)(q(),{variant:"subtitle2",className:"rustic-file-preview-name",children:w}),(0,i.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:a.children})]}),b&&(0,i.jsx)(V(),{open:d,onClose:f,className:"rustic-file-preview-modal",children:(0,i.jsxs)("div",{className:"rustic-modal-content",children:[(0,i.jsx)(E(),{title:"Close",children:(0,i.jsx)(x(),{onClick:f,className:"rustic-close-button",children:(0,i.jsx)(T.A,{name:"close"})})}),a.file.url&&(0,i.jsx)(g,{url:a.file.url,getAuthHeaders:a.getAuthHeaders})]})})]})}var ie=o(3110);const ce=require("@mui/material"),le=require("@mui/material/Button");var se=o.n(le);const ue=require("@mui/material/Drawer");var de=o.n(ue);const pe=require("@mui/material/ListItemText");var fe=o.n(pe);const me=require("@mui/material/Menu");var he=o.n(me);const ve=require("@mui/system");var ge=function(){return ge=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ge.apply(this,arguments)};function xe(e){var t=(0,u.useState)(!1),r=t[0],n=t[1],o=(0,u.useRef)(null),a=(0,s.useTheme)(),c=(0,ce.useMediaQuery)(a.breakpoints.down("md")),l=c?de():he(),d={borderRadius:"".concat(a.shape.borderRadius,"px"),border:"1px solid ".concat(a.palette.divider)};function p(e){return(0,i.jsxs)(i.Fragment,{children:[e.startDecorator&&(0,i.jsx)(ve.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,i.jsx)(fe(),{children:(0,i.jsx)(q(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,i.jsx)(ve.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}c&&(d=ge(ge({},d),{borderRadius:"".concat(a.shape.borderRadius,"px ").concat(a.shape.borderRadius,"px 0 0"),borderBottom:0}));var f=e.menuItems.map((function(e){return e.href?(0,i.jsx)(w(),{component:"a",onClick:function(){return n(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:p(e)},e.label):(0,i.jsx)(w(),{onClick:function(t){e.onClick&&e.onClick(t),n(!1)},disabled:!e.onClick,children:p(e)},e.label)}));var m,h,v=c?{}:{anchorEl:o.current};return(0,i.jsxs)(i.Fragment,{children:[(m={onClick:function(e){e.stopPropagation(),n(!0)},"aria-label":e.ariaLabel,ref:o,className:"rustic-popover-menu-button"},h=(0,i.jsx)(T.A,{name:"more_vert"}),e.buttonText?(0,i.jsx)(se(),ge({},m,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,i.jsx)(E(),{title:e.ariaLabel,children:(0,i.jsx)(x(),ge({},m,{children:e.icon?e.icon:h}))})),(0,i.jsx)(l,ge({open:r,onClose:function(){return n(!1)}},v,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":ge(ge({},d),{backgroundImage:"none",boxShadow:a.shadows[2]})},children:f}))]})}var be=function(){return be=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},be.apply(this,arguments)},ye=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function je(e){for(var t=["Bytes","KB","MB","GB"],r=0;e>=1024&&r<t.length-1;)e/=1024,r++;var n=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(n," ").concat(t[r])}const we=function(e){var t,r=(0,u.useState)([]),n=r[0],o=r[1],a=(0,u.useState)([]),c=a[0],s=a[1],p=(0,u.useState)({}),f=p[0],m=p[1],h=(0,u.useRef)({}),v=(0,d.v4)();(0,u.useEffect)((function(){o([]),s([]),h.current={}}),[e.messageId]);var g=e.getUploadHeaders?e.getUploadHeaders():Promise.resolve({headers:{}});function b(e,t,r){var n;h.current=be(be({},h.current),((n={})[e]=h.current[e]--,n)),function(e,t,r){s((function(t){return ye(ye([],t,!0),["Failed to upload ".concat(e,". ").concat((null==r?void 0:r.message)||"")],!1)})),o((function(e){return e.filter((function(e){return e.id!==t}))}))}(e,t,r)}var y=(0,i.jsx)(l(),{className:"rustic-files rustic-padding-16",children:n.map((function(t,r){return(0,i.jsx)(ae,{file:{name:t.name},showFullName:e.showFullName,children:(0,i.jsxs)(l(),{className:"rustic-flex-center",children:[t.loadingProgress<100&&(0,i.jsx)(B(),{variant:"determinate",color:"secondary",value:t.loadingProgress,className:"rustic-upload-progress"}),(0,i.jsx)(E(),{title:"Delete",children:(0,i.jsx)(x(),{color:"primary",onClick:function(){return function(t,r){var n,a;s([]);var i=t.name;if(h.current=be(be({},h.current),((n={})[i]=h.current[i]--,n)),e.onFileUpdate("remove",i),100===t.loadingProgress){var c="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",t.id);g.then((function(t){$().delete(c,be({},t)).then((function(){return o((function(e){return e.filter((function(e,t){return t!==r}))}))})).catch((function(){return e.onFileUpdate("add",i),s((function(e){return ye(ye([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)}))}))}))}else t.abortController.abort(),o((function(e){return e.filter((function(e,t){return t!==r}))})),h.current=be(be({},h.current),((a={})[i]=h.current[i]++,a))}(t,r)},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"})})})]})},r)}))}),j=(0,i.jsx)(l(),{children:c.map((function(e,t){return(0,i.jsx)(q(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},t)}))});function w(e,t){return t?(0,W.createPortal)(e,t):e}var S=null===(t=e.uploadOptions)||void 0===t?void 0:t.map((function(t){return{label:t.label,onClick:function(){return function(t){m(t.metadata);var r=document.getElementById(v);r&&(r.accept=t.acceptedFileTypes||e.acceptedFileTypes),r.click()}(t)},startDecorator:t.iconName&&(0,i.jsx)(ie.default,{name:t.iconName})}}));return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(l(),{className:"rustic-uploader",children:[(0,i.jsx)("label",{htmlFor:v,children:(null==S?void 0:S.length)?(0,i.jsx)(xe,{ariaLabel:"Upload",icon:(0,i.jsx)(ie.default,{name:"upload_2"}),menuItems:S}):(0,i.jsx)(E(),{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(t){s([]);var r=t.target.files&&Array.from(t.target.files),a=n.length+(r?r.length:0);e.maxFileCount&&a>e.maxFileCount&&s((function(t){return ye(ye([],t,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var i=r&&function(e,t,r){return r?t<=r?e:e.slice(0,r-t):e}(r,a,e.maxFileCount);i&&i.forEach((function(t){!function(t){var r;e.maxFileSize&&t.size>e.maxFileSize?(r=t.name,s((function(t){return ye(ye([],t,!0),["Failed to upload ".concat(r,". You cannot upload files larger than ").concat(e.maxFileSize&&je(e.maxFileSize),".")],!1)}))):function(t){var r=new FormData,n=new AbortController,a=function(e){var t,r,n=e.name,o=h.current[n];if(o){var a=o+1,i=n.lastIndexOf("."),c=n.substring(0,i),l=n.substring(i);n="".concat(c,"(").concat(o,")").concat(l),h.current=be(be({},h.current),((t={})[e.name]=a,t))}else h.current=be(be({},h.current),((r={})[e.name]=1,r));return n}(t),i=new File([t],a,{type:t.type});if(e.getUploadData||f){var c=e.getUploadData?e.getUploadData(a):{},l=be(be({},c),f);Object.keys(l).forEach((function(e){var t=l[e];r.append(e,"object"==typeof t?JSON.stringify(t):t)}))}r.append("file",i);var s=(0,d.v4)(),u={name:a,loadingProgress:0,abortController:n,id:s};function p(e){var t,r;e.total&&(t=e.loaded/e.total*100,r=u.id,o((function(e){var n=e.map((function(e){return e.id===r?be(be({},e),{loadingProgress:t}):e}));return n})))}o((function(e){return ye(ye([],e,!0),[u],!1)})),e.onFileUpdate("add",a);var m="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);!function i(){return g.then((function(c){return $().post(m,r,be(be({},c),{onUploadProgress:p,signal:n.signal})).then((function(t){var n,a,i=r.get("file");t.data.url&&i instanceof File&&i.name&&e.onFileUpdate("update",i.name,t.data.url),t.data.fileId&&(n=t.data,a=u.id,o((function(e){var t=e.findIndex((function(e){return e.id===a}));if(-1!==t){var r=ye([],e,!0);return r[t]=be(be({},r[t]),{id:n.fileId}),r}return e})))})).catch((function(n){var c,l,d=r.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var p,f,m,h;409===(null===(c=n.response)||void 0===c?void 0:c.status)&&e.listFiles?(p=a.lastIndexOf("."),f=a.substring(0,p),m=a.substring(p),h=new RegExp("^".concat(f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"(\\(\\d+\\))?").concat(m,"$"),"i"),e.listFiles?e.listFiles().then((function(e){for(var t=0,r=0,n=e;r<n.length;r++){var o=n[r];if(h.test(o.name)){var a=o.name.match(h),i=a&&a[1]?parseInt(a[1].slice(1,-1),10):0;t=Math.max(t,i)}}return"".concat(f,"(").concat(t+1,")").concat(m)})):Promise.resolve(a)).then((function(n){e.onFileUpdate("add",n);var a=new File([t],n,{type:t.type});r.set("file",a),o((function(e){return e.map((function(e){return e.id===s?be(be({},e),{name:n,loadingProgress:0}):e}))})),i()})).catch((function(){var e;b(t.name,u.id,null===(e=n.response)||void 0===e?void 0:e.data)})):b(t.name,u.id,null===(l=n.response)||void 0===l?void 0:l.data)}))}))}()}(t)}(t)})),t.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),c.length>0&&w(j,e.errorMessagesContainer),n.length>0&&w(y,e.filePreviewsContainer)]})};var Se,Oe,Ne=function(){return Ne=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ne.apply(this,arguments)},Ce=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};!function(e){e.Owner="owner",e.Member="member"}(Se||(Se={})),function(e){e.Human="human",e.Agent="agent"}(Oe||(Oe={}));const Fe=function(e){var t=e.maxFileSize,r=void 0===t?2097152:t,n=e.maxFileCount,o=void 0===n?1:n,a=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["maxFileSize","maxFileCount"]),c=(0,u.useState)({uploaded:[],fileList:[]}),p=c[0],f=c[1],m=(0,u.useState)((0,d.v4)()),h=m[0],v=m[1],g=(0,u.useState)(),x=g[0],b=g[1],y=(0,u.useState)(),j=y[0],w=y[1],S=(0,u.useRef)(null),O=(0,s.useTheme)(),N=p.fileList.length>0,C=p.uploaded.length===p.fileList.length&&p.uploaded.length>0;return(0,u.useEffect)((function(){S.current&&(w(S.current.querySelector(".rustic-error-container")),b(S.current.querySelector(".rustic-input-extras")))})),(0,i.jsx)(l(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(O.palette.action.disabled),borderRadius:"".concat(O.shape.borderRadius,"px"),":focus-within":{borderColor:O.palette.secondary.main},background:O.palette.background.paper},children:(0,i.jsx)(z,Ne({},a,{send:function(e){e.data=function(e,t){var r=[];if(e&&(null==e?void 0:e.trim().length)&&r.push({type:"text",text:e}),t&&t.length>0)for(var n=0;n<(null==t?void 0:t.length);n++)r.push({type:"file_url",file_url:{url:t[n].url,name:t[n].name}});return{messages:[{content:r,role:"user"}]}}(e.data.text,p.uploaded.map((function(e){return{url:e.url,name:e.name}}))),e.id=h,a.ws.send(e),v((0,d.v4)()),f({uploaded:[],fileList:[]})},isSendEnabled:N?C:void 0,ref:S,children:(0,i.jsx)(l(),{className:"rustic-bottom-buttons",children:(0,i.jsx)(we,{acceptedFileTypes:a.acceptedFileTypes,maxFileCount:o,maxFileSize:r,uploadFileEndpoint:a.uploadFileEndpoint,deleteFileEndpoint:a.deleteFileEndpoint,onFileUpdate:function(e,t,r){if("add"===e)f((function(e){return Ne(Ne({},e),{fileList:Ce(Ce([],e.fileList,!0),[{name:t}],!1)})}));else if("update"===e){if(!r)return void console.error("URL is required for the 'update' action");f((function(e){var n=e.fileList.findIndex((function(e){return e.name===t})),o=Ce(Ce(Ce([],e.uploaded.slice(0,n),!0),[{name:t,url:r}],!1),e.uploaded.slice(n),!0);return Ne(Ne({},e),{uploaded:o})}))}else f((function(e){return{uploaded:e.uploaded.filter((function(e){return e.name!==t})),fileList:e.fileList.filter((function(e){return e.name!==t}))}}))},messageId:h,filePreviewsContainer:x,errorMessagesContainer:j,showFullName:a.showFullName,getUploadData:a.getUploadData,uploadOptions:a.uploadOptions,listFiles:a.listFiles,getUploadHeaders:a.getUploadHeaders})})}))})};return a})()));
|
|
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,t,r={9767:(e,t,r)=>{r.d(t,{A:()=>a});var n=r(8732),o=(r(2015),function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)});function a(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:o({},t),children:e.name})}},3110:(e,t,r)=>{r.d(t,{default:()=>n});const n=r(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 o(e){var t=n[e];if(void 0!==t)return t.exports;var a=n[e]={exports:{}};return r[e](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var a=Object.create(null);o.r(a);var i={};e=e||[null,t({}),t([]),t(t)];for(var c=2&n&&r;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach((e=>i[e]=()=>r[e]));return i.default=()=>r,o.d(a,i),a},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 a={};o.r(a),o.d(a,{ParticipantRole:()=>Se,ParticipantType:()=>Oe,default:()=>Fe});var i=o(8732);const c=require("@mui/material/Box");var l=o.n(c);const s=require("@mui/material/styles");var u=o(2015);const d=require("uuid");var p;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(p||(p={}));const f=require("@mui/material/Avatar");var m=o.n(f);const h=require("@mui/material/CircularProgress");var v=o.n(h);const g=require("@mui/material/IconButton");var x=o.n(g);const b=require("@mui/material/InputAdornment");var y=o.n(b);const j=require("@mui/material/MenuItem");var w=o.n(j);const S=require("@mui/material/MenuList");var O=o.n(S);const N=require("@mui/material/Popover");var C=o.n(N);const F=require("@mui/material/TextField");var k=o.n(F);const P=require("@mui/material/Tooltip");var E=o.n(P);const I=require("@mui/material/Typography");var q=o.n(I),T=o(8342),A=o(9767);const R=function(e){var t=(0,s.useTheme)(),r=(0,u.useRef)(null),n=(0,u.useRef)(null),a=(0,u.useState)(!1),c=a[0],l=a[1],d={"--indicator-color":t.palette.divider,"--background":t.palette.background.paper,"--input-border-color":t.palette.divider,"--outline-color":t.palette.secondary.main};function p(){l(!1)}function f(t){t.detail.unicode&&e.onEmojiClick(t.detail.unicode),p()}return(0,u.useEffect)((function(){n.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then((function(r){var o=new(0,r.Picker)({dataSource:e.dataSource}),a="dark"===t.palette.mode?"dark":"light";o.classList.add(a),Object.keys(d).forEach((function(e){o.style.setProperty(e,d[e])})),n.current=o})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,u.useEffect)((function(){return n.current&&n.current.addEventListener("emoji-click",f),function(){var e;null===(e=n.current)||void 0===e||e.removeEventListener("emoji-click",f)}}),[c,e.onEmojiClick]),(0,i.jsxs)("div",{children:[(0,i.jsx)(E(),{title:"Emoji",children:(0,i.jsx)(x(),{size:"small",ref:r,onClick:function(){l((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)(A.A,{name:"Mood"})})}),n.current&&(0,i.jsx)(C(),{open:c,anchorEl:r.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 L(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}function U(e){return(0,i.jsxs)(l(),{className:"rustic-participant-profile",children:[(0,i.jsx)(m(),{src:e.icon,className:"rustic-participant-avatar"}),(0,i.jsx)(q(),{variant:"body1Bold",children:e.displayName})]})}function _(e){var t=e.items,r=e.isOpen,n=e.onClose,o=e.onSelect,a=e.renderItem,c=e.anchorEl,l=e.selectedIndex;return(0,i.jsx)(C(),{disableAutoFocus:!0,open:r&&t.length>0,anchorEl:c,onClose:n,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},className:"rustic-suggestion-menu",children:(0,i.jsx)(O(),{children:t.map((function(e,t){return(0,i.jsx)(w(),{onClick:function(){return o(e)},selected:t===l,children:a(e)},t)}))})})}const M=(0,u.forwardRef)((function(e,t){var r=e.multiline,n=void 0===r||r,o=e.fullWidth,a=void 0===o||o,c=e.maxRows,s=void 0===c?6:c,p=e.enableSpeechToText,f=void 0!==p&&p,m=e.maximumEmojiSearchResults,h=void 0===m?5:m,g=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["multiline","fullWidth","maxRows","enableSpeechToText","maximumEmojiSearchResults"]),b=(0,u.useState)(""),j=b[0],w=b[1],S=(0,u.useState)(!1),O=S[0],N=S[1],C=(0,u.useState)(!1),F=C[0],P=C[1],I=(0,u.useState)(!1),M=I[0],z=I[1],H=(0,u.useState)(""),B=H[0],$=H[1],W=(0,u.useState)([]),K=W[0],G=W[1],Q=(0,u.useState)(!1),V=Q[0],Y=Q[1],Z=(0,u.useState)(0),J=Z[0],X=Z[1],ee=(0,u.useRef)(null),te=new T.Database({dataSource:g.emojiDataSource}),re=!j.trim().length,ne="".concat(O?"Stop":"Start"," speech to text"),oe=F?"primary.main":"primary.light",ae=O?"error.main":oe,ie=O?"stop_circle":"speech_to_text",ce=(0,u.useState)([]),le=ce[0],se=ce[1],ue=(0,u.useState)(!1),de=ue[0],pe=ue[1];function fe(){return"boolean"==typeof g.isSendEnabled?!g.isSendEnabled:re}function me(e,t){if(ee.current){var r=ee.current,n=r.selectionStart,o=r.selectionEnd;if("number"==typeof n&&"number"==typeof o){var a,i=j||"",c=i.substring(0,n),l=i.substring(o),s=void 0;t?(s=c.replace(t,e)+l,a=c.replace(t,e).length):(s=c+e+l,a=n+e.length),w(s),setTimeout((function(){var e,t;null===(e=ee.current)||void 0===e||e.focus(),null===(t=ee.current)||void 0===t||t.setSelectionRange(a,a)}),0)}}}function he(e){me("@".concat(e," "),/@(\w*)$/),se([])}function ve(e,t){void 0===t&&(t=!1),me(e,t?/:(\w+)$/:void 0),Y(!1)}var ge=M?(0,i.jsx)(v(),{size:24}):(0,i.jsx)(E(),{title:ne,children:(0,i.jsx)(x(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,O?(e.stop(),z(!0),N(!1)):(e.start(),$(""),N(!0)),e.onstart=function(){N(!0)},e.onresult=function(e){var t,r=e.results[0][0].transcript;j.length>0?w(j+" "+r):w(r),null===(t=ee.current)||void 0===t||t.focus(),N(!1)},e.onerror=function(e){var t=D[e.error];$(t),N(!1)},e.onend=function(){z(!1),N(!1)}},size:"small",sx:{color:ae,"&:hover":{color:"primary.main"}},children:(0,i.jsx)(A.A,{name:ie})})});function xe(){var e,t,r=(new Date).toISOString(),n={id:(0,d.v4)(),timestamp:r,sender:g.sender,conversationId:g.conversationId,format:"chatCompletionRequest",data:{text:j},inReplyTo:null===(e=g.lastMsg)||void 0===e?void 0:e.id,messageHistory:null===(t=g.lastMsg)||void 0===t?void 0:t.messageHistory};g.send(n),w(""),$("")}return(0,i.jsxs)(l(),{className:"rustic-base-input",ref:t,children:[(0,i.jsxs)(l(),{className:"rustic-error-and-input-container",children:[(0,i.jsx)(l(),{className:"rustic-error-container",children:(0,i.jsx)(q(),{variant:"caption",color:"error",className:"rustic-error-message",children:B})}),(0,i.jsxs)(l(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:F?"secondary.main":"action.disabled"},children:[K.length>0&&ee.current&&(0,i.jsx)(_,{anchorEl:ee.current,items:K.filter((function(e){return"unicode"in e})),isOpen:V,onClose:function(){Y(!1),X(0)},onSelect:function(e){return ve(e.unicode,!0)},selectedIndex:J,renderItem:L}),le.length>0&&ee.current&&(0,i.jsx)(_,{anchorEl:ee.current,items:le,isOpen:de,onClose:function(){pe(!1),X(0)},onSelect:function(e){return he(e.displayName)},renderItem:U,selectedIndex:J}),(0,i.jsx)(k(),{className:"rustic-text-field",variant:"outlined",value:j,label:g.label,placeholder:g.placeholder,maxRows:s,multiline:n,fullWidth:a,onKeyDown:function(e){var t,r="ArrowDown"===e.key,n="ArrowUp"===e.key;if("Enter"===e.key||"Tab"===e.key)e.shiftKey||e.preventDefault(),V&&K.length>0&&"unicode"in K[J]?ve(K[J].unicode,!0):de&&le.length>0?he(le[J].displayName):e.shiftKey||fe()||xe();else{if(r||n)return e.preventDefault(),t=r?1:-1,void(V?X((function(e){return(e+t+K.length)%K.length})):de&&X((function(e){return(e+t+le.length)%le.length})));0!==J&&X(0)}},onChange:function(e){$("");var t=e.target.value;w(t),function(e){var t=e.match(/@(\w*)$/);if(t&&g.getMembers){var r=t[1].toLowerCase();g.getMembers().then((function(e){var t=e.filter((function(e){return e.displayName.toLowerCase().startsWith(r)}));se(t),t.length>0?pe(!0):pe(!1)}))}else se([])}(t);var r,n=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(n){var a=n[0].replace(/:/g,"");te.getEmojiByShortcode(a).then((function(e){if(e&&"unicode"in e){var r=t.replace(n[0],e.unicode);w(r)}else w(t)})).catch((function(){w(t)})),Y(!1)}else o?(r=o[0].replace(":",""),te.getEmojiBySearchQuery(r).then((function(e){e.length?(G(e.slice(0,h)),Y(!0)):(G([]),Y(!1))})).catch((function(){G([]),Y(!1)}))):Y(!1)},onFocus:function(){return P(!0)},onBlur:function(){return P(!1)},inputRef:ee,color:"secondary",size:"small",slotProps:{input:{endAdornment:(0,i.jsxs)(y(),{position:"end",className:"rustic-input-adornment",children:[(0,i.jsx)(R,{dataSource:g.emojiDataSource,onEmojiClick:ve,buttonColor:oe}),f&&ge]})},inputLabel:{className:F?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}}),(0,i.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,i.jsxs)(l(),{className:"rustic-input-actions",children:[g.children,(0,i.jsx)(E(),{title:"Send",children:(0,i.jsx)("span",{className:"rustic-send-button",children:(0,i.jsx)(x(),{"aria-label":"send message",onClick:xe,disabled:fe(),color:"secondary",children:(0,i.jsx)(A.A,{name:"send"})})})})]})]})})),z=require("@mui/material/LinearProgress");var H=o.n(z);const B=require("axios");var $=o.n(B);const W=require("react-dom"),K=require("@mui/material/Card");var G=o.n(K);const Q=require("@mui/material/Modal");var V=o.n(Q);const Y=require("@mui/material/useMediaQuery");var Z=o.n(Y);const J=require("@mui/system/Stack");var X=o.n(J);const ee=require("@mui/system/useTheme");var te=o.n(ee);const re=require("pdfjs-dist"),ne=function(e){var t={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"}},r=(t[e.action].label.replaceAll(" ","-").toLowerCase(),t[e.action]);return(0,i.jsx)(E(),{title:r.label,children:(0,i.jsx)("span",{children:(0,i.jsx)(x(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,i.jsx)(A.A,{name:r.symbol})})})})};var oe={pdf:function(e){var t,r=(0,u.useRef)(null),n=(0,u.useState)(1),o=n[0],a=n[1],c=(0,u.useState)(1),s=c[0],d=c[1],p=(0,u.useState)(1),f=p[0],m=p[1],h=(0,u.useState)(!1),v=h[0],g=h[1],x=(0,u.useState)(),b=x[0],y=x[1],j=te()(),w=Z()(j.breakpoints.down("sm")),S=Z()(j.breakpoints.between("sm","md"));if(t=e.url,!/\/[^/]+\.pdf$/.test(t))return(0,i.jsx)(G(),{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 O=(0,u.useState)((function(){return w?.5:S?1:1.5})),N=O[0],C=O[1];function F(t){re.getDocument({url:e.url,httpHeaders:t}).promise.then((function(e){d(e.numPages),function(e){e.getPage(o).then((function(e){var t=e.getViewport({scale:N}),n=r.current;if(n){var o=n.getContext("2d");if(o){var a=window.devicePixelRatio||1;n.style.width="".concat(t.width,"px"),n.style.height="".concat(t.height,"px"),n.width=t.width*a,n.height=t.height*a;var i={canvasContext:o,viewport:t,transform:[a,0,0,a,0,0]};b&&b.cancel();var c=e.render(i);y(c),c.promise.then((function(){y(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}return(0,u.useEffect)((function(){re.GlobalWorkerOptions.workerSrc||(re.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(re.version,"/pdf.worker.mjs")),e.getAuthHeaders?e.getAuthHeaders().then((function(e){return F(e.headers)})).catch((function(){return g(!0)})):F()}),[e.url,o,N]),v?(0,i.jsx)(G(),{variant:"outlined",className:"rustic-pdf-error",children:(0,i.jsx)(q(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,i.jsxs)(G(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,i.jsxs)(l(),{className:"rustic-pdf-viewer-header",children:[(0,i.jsx)(ne,{action:"zoomOut",onClick:function(){C((function(e){return Math.max(e-.2,.2)}))}}),(0,i.jsx)(ne,{action:"zoomIn",onClick:function(){C((function(e){return e+.2}))}})]}),(0,i.jsx)(l(),{className:"rustic-pdf-viewer-body",children:(0,i.jsx)(l(),{className:"rustic-pdf-viewer-body-inner",children:(0,i.jsx)("canvas",{ref:r})})}),(0,i.jsxs)(X(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,i.jsx)(ne,{action:"previousPage",onClick:function(){o>1&&(a(o-1),m(o-1))},isDisabled:1===o}),(0,i.jsx)(q(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,i.jsx)(k(),{type:"number",value:f,onChange:function(e){var t=parseInt(e.target.value);m(t),!isNaN(t)&&t>=1&&t<=s&&a(t)},size:"small",className:"rustic-pdf-page-input"}),(0,i.jsxs)(q(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,i.jsx)(ne,{action:"nextPage",onClick:function(){o<s&&(a(o+1),m(o+1))},isDisabled:o===s})]})]})}};function ae(e){var t=e.supportedViewers,r=void 0===t?oe:t,n=e.showFullName,o=void 0===n||n,a=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["supportedViewers","showFullName"]),c=(0,s.useTheme)(),l=(0,u.useState)(!1),d=l[0],p=l[1];function f(){p(!1)}var m,h,v=a.file.url&&(m=a.file.url.split("."))[m.length-1].toLowerCase(),g=v&&r?r[v]:null,b=!!g,y=b?" rustic-cursor-pointer":"",j="rustic-file-preview ".concat(o?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width").concat(y),w=o?a.file.name:(h=a.file.name).length<=15?h:h.substring(0,12)+"...";return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(G(),{className:j,variant:"outlined",sx:{boxShadow:c.shadows[1]},onClick:function(){p(!0)},children:[(0,i.jsx)(q(),{variant:"subtitle2",className:"rustic-file-preview-name",children:w}),(0,i.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:a.children})]}),b&&(0,i.jsx)(V(),{open:d,onClose:f,className:"rustic-file-preview-modal",children:(0,i.jsxs)("div",{className:"rustic-modal-content",children:[(0,i.jsx)(E(),{title:"Close",children:(0,i.jsx)(x(),{onClick:f,className:"rustic-close-button",children:(0,i.jsx)(A.A,{name:"close"})})}),a.file.url&&(0,i.jsx)(g,{url:a.file.url,getAuthHeaders:a.getAuthHeaders})]})})]})}var ie=o(3110);const ce=require("@mui/material"),le=require("@mui/material/Button");var se=o.n(le);const ue=require("@mui/material/Drawer");var de=o.n(ue);const pe=require("@mui/material/ListItemText");var fe=o.n(pe);const me=require("@mui/material/Menu");var he=o.n(me);const ve=require("@mui/system");var ge=function(){return ge=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ge.apply(this,arguments)};function xe(e){var t=(0,u.useState)(!1),r=t[0],n=t[1],o=(0,u.useRef)(null),a=(0,s.useTheme)(),c=(0,ce.useMediaQuery)(a.breakpoints.down("md")),l=c?de():he(),d={borderRadius:"".concat(a.shape.borderRadius,"px"),border:"1px solid ".concat(a.palette.divider)};function p(e){return(0,i.jsxs)(i.Fragment,{children:[e.startDecorator&&(0,i.jsx)(ve.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,i.jsx)(fe(),{children:(0,i.jsx)(q(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,i.jsx)(ve.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}c&&(d=ge(ge({},d),{borderRadius:"".concat(a.shape.borderRadius,"px ").concat(a.shape.borderRadius,"px 0 0"),borderBottom:0}));var f=e.menuItems.map((function(e){return e.href?(0,i.jsx)(w(),{component:"a",onClick:function(){return n(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:p(e)},e.label):(0,i.jsx)(w(),{onClick:function(t){e.onClick&&e.onClick(t),n(!1)},disabled:!e.onClick,children:p(e)},e.label)}));var m,h,v=c?{}:{anchorEl:o.current};return(0,i.jsxs)(i.Fragment,{children:[(m={onClick:function(e){e.stopPropagation(),n(!0)},"aria-label":e.ariaLabel,ref:o,className:"rustic-popover-menu-button"},h=(0,i.jsx)(A.A,{name:"more_vert"}),e.buttonText?(0,i.jsx)(se(),ge({},m,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,i.jsx)(E(),{title:e.ariaLabel,children:(0,i.jsx)(x(),ge({},m,{children:e.icon?e.icon:h}))})),(0,i.jsx)(l,ge({open:r,onClose:function(){return n(!1)}},v,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":ge(ge({},d),{backgroundImage:"none",boxShadow:a.shadows[2]})},children:f}))]})}var be=function(){return be=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},be.apply(this,arguments)},ye=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function je(e){for(var t=["Bytes","KB","MB","GB"],r=0;e>=1024&&r<t.length-1;)e/=1024,r++;var n=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(n," ").concat(t[r])}const we=function(e){var t,r=(0,u.useState)([]),n=r[0],o=r[1],a=(0,u.useState)([]),c=a[0],s=a[1],p=(0,u.useState)({}),f=p[0],m=p[1],h=(0,u.useRef)({}),v=(0,d.v4)();(0,u.useEffect)((function(){o([]),s([]),h.current={}}),[e.messageId]);var g=e.getUploadHeaders?e.getUploadHeaders():Promise.resolve({headers:{}});function b(e,t,r){var n;h.current=be(be({},h.current),((n={})[e]=h.current[e]--,n)),function(e,t,r){s((function(t){return ye(ye([],t,!0),["Failed to upload ".concat(e,". ").concat((null==r?void 0:r.message)||"")],!1)})),o((function(e){return e.filter((function(e){return e.id!==t}))}))}(e,t,r)}var y=(0,i.jsx)(l(),{className:"rustic-files rustic-padding-16",children:n.map((function(t,r){return(0,i.jsx)(ae,{file:{name:t.name},showFullName:e.showFullName,children:(0,i.jsxs)(l(),{className:"rustic-flex-center",children:[t.loadingProgress<100&&(0,i.jsx)(H(),{variant:"determinate",color:"secondary",value:t.loadingProgress,className:"rustic-upload-progress"}),(0,i.jsx)(E(),{title:"Delete",children:(0,i.jsx)(x(),{color:"primary",onClick:function(){return function(t,r){var n,a;s([]);var i=t.name;if(h.current=be(be({},h.current),((n={})[i]=h.current[i]--,n)),e.onFileUpdate("remove",i),100===t.loadingProgress){var c="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",t.id);g.then((function(t){$().delete(c,be({},t)).then((function(){return o((function(e){return e.filter((function(e,t){return t!==r}))}))})).catch((function(){return e.onFileUpdate("add",i),s((function(e){return ye(ye([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)}))}))}))}else t.abortController.abort(),o((function(e){return e.filter((function(e,t){return t!==r}))})),h.current=be(be({},h.current),((a={})[i]=h.current[i]++,a))}(t,r)},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"})})})]})},r)}))}),j=(0,i.jsx)(l(),{children:c.map((function(e,t){return(0,i.jsx)(q(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},t)}))});function w(e,t){return t?(0,W.createPortal)(e,t):e}var S=null===(t=e.uploadOptions)||void 0===t?void 0:t.map((function(t){return{label:t.label,onClick:function(){return function(t){m(t.metadata);var r=document.getElementById(v);r&&(r.accept=t.acceptedFileTypes||e.acceptedFileTypes),r.click()}(t)},startDecorator:t.iconName&&(0,i.jsx)(ie.default,{name:t.iconName})}}));return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(l(),{className:"rustic-uploader",children:[(0,i.jsx)("label",{htmlFor:v,children:(null==S?void 0:S.length)?(0,i.jsx)(xe,{ariaLabel:"Upload",icon:(0,i.jsx)(ie.default,{name:"upload_2"}),menuItems:S}):(0,i.jsx)(E(),{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(t){s([]);var r=t.target.files&&Array.from(t.target.files),a=n.length+(r?r.length:0);e.maxFileCount&&a>e.maxFileCount&&s((function(t){return ye(ye([],t,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var i=r&&function(e,t,r){return r?t<=r?e:e.slice(0,r-t):e}(r,a,e.maxFileCount);i&&i.forEach((function(t){!function(t){var r;e.maxFileSize&&t.size>e.maxFileSize?(r=t.name,s((function(t){return ye(ye([],t,!0),["Failed to upload ".concat(r,". You cannot upload files larger than ").concat(e.maxFileSize&&je(e.maxFileSize),".")],!1)}))):function(t){var r=new FormData,n=new AbortController,a=function(e){var t,r,n=e.name,o=h.current[n];if(o){var a=o+1,i=n.lastIndexOf("."),c=n.substring(0,i),l=n.substring(i);n="".concat(c,"(").concat(o,")").concat(l),h.current=be(be({},h.current),((t={})[e.name]=a,t))}else h.current=be(be({},h.current),((r={})[e.name]=1,r));return n}(t),i=new File([t],a,{type:t.type});if(e.getUploadData||f){var c=e.getUploadData?e.getUploadData(a):{},l=be(be({},c),f);Object.keys(l).forEach((function(e){var t=l[e];r.append(e,"object"==typeof t?JSON.stringify(t):t)}))}r.append("file",i);var s=(0,d.v4)(),u={name:a,loadingProgress:0,abortController:n,id:s};function p(e){var t,r;e.total&&(t=e.loaded/e.total*100,r=u.id,o((function(e){var n=e.map((function(e){return e.id===r?be(be({},e),{loadingProgress:t}):e}));return n})))}o((function(e){return ye(ye([],e,!0),[u],!1)})),e.onFileUpdate("add",a);var m="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);!function i(){return g.then((function(c){return $().post(m,r,be(be({},c),{onUploadProgress:p,signal:n.signal})).then((function(t){var n,a,i=r.get("file");t.data.url&&i instanceof File&&i.name&&e.onFileUpdate("update",i.name,t.data.url),t.data.fileId&&(n=t.data,a=u.id,o((function(e){var t=e.findIndex((function(e){return e.id===a}));if(-1!==t){var r=ye([],e,!0);return r[t]=be(be({},r[t]),{id:n.fileId}),r}return e})))})).catch((function(n){var c,l,d=r.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var p,f,m,h;409===(null===(c=n.response)||void 0===c?void 0:c.status)&&e.listFiles?(p=a.lastIndexOf("."),f=a.substring(0,p),m=a.substring(p),h=new RegExp("^".concat(f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"(\\(\\d+\\))?").concat(m,"$"),"i"),e.listFiles?e.listFiles().then((function(e){for(var t=0,r=0,n=e;r<n.length;r++){var o=n[r];if(h.test(o.name)){var a=o.name.match(h),i=a&&a[1]?parseInt(a[1].slice(1,-1),10):0;t=Math.max(t,i)}}return"".concat(f,"(").concat(t+1,")").concat(m)})):Promise.resolve(a)).then((function(n){e.onFileUpdate("add",n);var a=new File([t],n,{type:t.type});r.set("file",a),o((function(e){return e.map((function(e){return e.id===s?be(be({},e),{name:n,loadingProgress:0}):e}))})),i()})).catch((function(){var e;b(t.name,u.id,null===(e=n.response)||void 0===e?void 0:e.data)})):b(t.name,u.id,null===(l=n.response)||void 0===l?void 0:l.data)}))}))}()}(t)}(t)})),t.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),c.length>0&&w(j,e.errorMessagesContainer),n.length>0&&w(y,e.filePreviewsContainer)]})};var Se,Oe,Ne=function(){return Ne=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ne.apply(this,arguments)},Ce=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};!function(e){e.Owner="owner",e.Member="member"}(Se||(Se={})),function(e){e.Human="human",e.Agent="agent"}(Oe||(Oe={}));const Fe=function(e){var t=e.maxFileSize,r=void 0===t?2097152:t,n=e.maxFileCount,o=void 0===n?1:n,a=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["maxFileSize","maxFileCount"]),c=(0,u.useState)({uploaded:[],fileList:[]}),p=c[0],f=c[1],m=(0,u.useState)((0,d.v4)()),h=m[0],v=m[1],g=(0,u.useState)(),x=g[0],b=g[1],y=(0,u.useState)(),j=y[0],w=y[1],S=(0,u.useRef)(null),O=(0,s.useTheme)(),N=p.fileList.length>0,C=p.uploaded.length===p.fileList.length&&p.uploaded.length>0;return(0,u.useEffect)((function(){S.current&&(w(S.current.querySelector(".rustic-error-container")),b(S.current.querySelector(".rustic-input-extras")))})),(0,i.jsx)(l(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(O.palette.action.disabled),borderRadius:"".concat(O.shape.borderRadius,"px"),":focus-within":{borderColor:O.palette.secondary.main},background:O.palette.background.paper},children:(0,i.jsx)(M,Ne({},a,{send:function(e){e.data=function(e,t){var r=[];if(e&&(null==e?void 0:e.trim().length)&&r.push({type:"text",text:e}),t&&t.length>0)for(var n=0;n<(null==t?void 0:t.length);n++)r.push({type:"file_url",file_url:{url:t[n].url,name:t[n].name}});return{messages:[{content:r,role:"user"}]}}(e.data.text,p.uploaded.map((function(e){return{url:e.url,name:e.name}}))),e.id=h,a.ws.send(e),v((0,d.v4)()),f({uploaded:[],fileList:[]})},isSendEnabled:N?C:void 0,ref:S,children:(0,i.jsx)(l(),{className:"rustic-bottom-buttons",children:(0,i.jsx)(we,{acceptedFileTypes:a.acceptedFileTypes,maxFileCount:o,maxFileSize:r,uploadFileEndpoint:a.uploadFileEndpoint,deleteFileEndpoint:a.deleteFileEndpoint,onFileUpdate:function(e,t,r){if("add"===e)f((function(e){return Ne(Ne({},e),{fileList:Ce(Ce([],e.fileList,!0),[{name:t}],!1)})}));else if("update"===e){if(!r)return void console.error("URL is required for the 'update' action");f((function(e){var n=e.fileList.findIndex((function(e){return e.name===t})),o=Ce(Ce(Ce([],e.uploaded.slice(0,n),!0),[{name:t,url:r}],!1),e.uploaded.slice(n),!0);return Ne(Ne({},e),{uploaded:o})}))}else f((function(e){return{uploaded:e.uploaded.filter((function(e){return e.name!==t})),fileList:e.fileList.filter((function(e){return e.name!==t}))}}))},messageId:h,filePreviewsContainer:x,errorMessagesContainer:j,showFullName:a.showFullName,getUploadData:a.getUploadData,uploadOptions:a.uploadOptions,listFiles:a.listFiles,getUploadHeaders:a.getUploadHeaders})})}))})};return a})()));
|
|
@@ -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,t,r={8342:e=>{e.exports=require("emoji-picker-element")}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var i=Object.create(null);o.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&n&&r;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>r[e]));return a.default=()=>r,o.d(i,a),i},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 i={};o.r(i),o.d(i,{ParticipantRole:()=>H,ParticipantType:()=>W,default:()=>U});const a=require("react/jsx-runtime"),c=require("react");var s;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(s||(s={}));const u=require("@mui/material/Avatar");var l=o.n(u);const d=require("@mui/material/Box");var p=o.n(d);const m=require("@mui/material/CircularProgress");var f=o.n(m);const h=require("@mui/material/IconButton");var v=o.n(h);const y=require("@mui/material/InputAdornment");var g=o.n(y);const b=require("@mui/material/MenuItem");var j=o.n(b);const x=require("@mui/material/MenuList");var O=o.n(x);const w=require("@mui/material/Popover");var S=o.n(w);const k=require("@mui/material/TextField");var E=o.n(k);const C=require("@mui/material/Tooltip");var N=o.n(C);const P=require("@mui/material/Typography");var T=o.n(P),q=o(8342);const R=require("uuid");var _=function(){return _=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},_.apply(this,arguments)};function I(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,a.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:_({},t),children:e.name})}const M=require("@mui/material/styles"),A=function(e){var t=(0,M.useTheme)(),r=(0,c.useRef)(null),n=(0,c.useRef)(null),i=(0,c.useState)(!1),s=i[0],u=i[1],l={"--indicator-color":t.palette.divider,"--background":t.palette.background.paper,"--input-border-color":t.palette.divider,"--outline-color":t.palette.secondary.main};function d(){u(!1)}function p(t){t.detail.unicode&&e.onEmojiClick(t.detail.unicode),d()}return(0,c.useEffect)((function(){n.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then((function(r){var o=new(0,r.Picker)({dataSource:e.dataSource}),i="dark"===t.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)(N(),{title:"Emoji",children:(0,a.jsx)(v(),{size:"small",ref:r,onClick:function(){u((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)(I,{name:"Mood"})})}),n.current&&(0,a.jsx)(S(),{open:s,anchorEl:r.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 z(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}function L(e){return(0,a.jsxs)(p(),{className:"rustic-participant-profile",children:[(0,a.jsx)(l(),{src:e.icon,className:"rustic-participant-avatar"}),(0,a.jsx)(T(),{variant:"body1Bold",children:e.displayName})]})}function B(e){var t=e.items,r=e.isOpen,n=e.onClose,o=e.onSelect,i=e.renderItem,c=e.anchorEl,s=e.selectedIndex;return(0,a.jsx)(S(),{disableAutoFocus:!0,open:r&&t.length>0,anchorEl:c,onClose:n,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},className:"rustic-suggestion-menu",children:(0,a.jsx)(O(),{children:t.map((function(e,t){return(0,a.jsx)(j(),{onClick:function(){return o(e)},selected:t===s,children:i(e)},t)}))})})}const F=(0,c.forwardRef)((function(e,t){var r=e.multiline,n=void 0===r||r,o=e.fullWidth,i=void 0===o||o,s=e.maxRows,u=void 0===s?6:s,l=e.enableSpeechToText,d=void 0!==l&&l,m=e.maximumEmojiSearchResults,h=void 0===m?5:m,y=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["multiline","fullWidth","maxRows","enableSpeechToText","maximumEmojiSearchResults"]),b=(0,c.useState)(""),j=b[0],x=b[1],O=(0,c.useState)(!1),w=O[0],S=O[1],k=(0,c.useState)(!1),C=k[0],P=k[1],_=(0,c.useState)(!1),M=_[0],F=_[1],H=(0,c.useState)(""),W=H[0],K=H[1],U=(0,c.useState)([]),$=U[0],Q=U[1],G=(0,c.useState)(!1),J=G[0],V=G[1],X=(0,c.useState)(0),Y=X[0],Z=X[1],ee=(0,c.useRef)(null),te=new q.Database({dataSource:y.emojiDataSource}),re=!j.trim().length,ne="".concat(w?"Stop":"Start"," speech to text"),oe=C?"primary.main":"primary.light",ie=w?"error.main":oe,ae=w?"stop_circle":"speech_to_text",ce=(0,c.useState)([]),se=ce[0],ue=ce[1],le=(0,c.useState)(!1),de=le[0],pe=le[1];function me(){return"boolean"==typeof y.isSendEnabled?!y.isSendEnabled:re}function fe(e,t){if(ee.current){var r=ee.current,n=r.selectionStart,o=r.selectionEnd;if("number"==typeof n&&"number"==typeof o){var i,a=j||"",c=a.substring(0,n),s=a.substring(o),u=void 0;t?(u=c.replace(t,e)+s,i=c.replace(t,e).length):(u=c+e+s,i=n+e.length),x(u),setTimeout((function(){var e,t;null===(e=ee.current)||void 0===e||e.focus(),null===(t=ee.current)||void 0===t||t.setSelectionRange(i,i)}),0)}}}function he(e){fe("@".concat(e," "),/@(\w*)$/),ue([])}function ve(e,t){void 0===t&&(t=!1),fe(e,t?/:(\w+)$/:void 0),V(!1)}var ye=M?(0,a.jsx)(f(),{size:24}):(0,a.jsx)(N(),{title:ne,children:(0,a.jsx)(v(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,w?(e.stop(),F(!0),S(!1)):(e.start(),K(""),S(!0)),e.onstart=function(){S(!0)},e.onresult=function(e){var t,r=e.results[0][0].transcript;j.length>0?x(j+" "+r):x(r),null===(t=ee.current)||void 0===t||t.focus(),S(!1)},e.onerror=function(e){var t=D[e.error];K(t),S(!1)},e.onend=function(){F(!1),S(!1)}},size:"small",sx:{color:ie,"&:hover":{color:"primary.main"}},children:(0,a.jsx)(I,{name:ae})})});function ge(){var e=(new Date).toISOString(),t={id:(0,R.v4)(),timestamp:e,sender:y.sender,conversationId:y.conversationId,format:"chatCompletionRequest",data:{text:j}};y.send(t),x(""),K("")}return(0,a.jsxs)(p(),{className:"rustic-base-input",ref:t,children:[(0,a.jsxs)(p(),{className:"rustic-error-and-input-container",children:[(0,a.jsx)(p(),{className:"rustic-error-container",children:(0,a.jsx)(T(),{variant:"caption",color:"error",className:"rustic-error-message",children:W})}),(0,a.jsxs)(p(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:C?"secondary.main":"action.disabled"},children:[$.length>0&&ee.current&&(0,a.jsx)(B,{anchorEl:ee.current,items:$.filter((function(e){return"unicode"in e})),isOpen:J,onClose:function(){V(!1),Z(0)},onSelect:function(e){return ve(e.unicode,!0)},selectedIndex:Y,renderItem:z}),se.length>0&&ee.current&&(0,a.jsx)(B,{anchorEl:ee.current,items:se,isOpen:de,onClose:function(){pe(!1),Z(0)},onSelect:function(e){return he(e.displayName)},renderItem:L,selectedIndex:Y}),(0,a.jsx)(E(),{className:"rustic-text-field",variant:"outlined",value:j,label:y.label,placeholder:y.placeholder,maxRows:u,multiline:n,fullWidth:i,onKeyDown:function(e){var t,r="ArrowDown"===e.key,n="ArrowUp"===e.key;if("Enter"===e.key||"Tab"===e.key)e.shiftKey||e.preventDefault(),J&&$.length>0&&"unicode"in $[Y]?ve($[Y].unicode,!0):de&&se.length>0?he(se[Y].displayName):e.shiftKey||me()||ge();else{if(r||n)return e.preventDefault(),t=r?1:-1,void(J?Z((function(e){return(e+t+$.length)%$.length})):de&&Z((function(e){return(e+t+se.length)%se.length})));0!==Y&&Z(0)}},onChange:function(e){K("");var t=e.target.value;x(t),function(e){var t=e.match(/@(\w*)$/);if(t&&y.getMembers){var r=t[1].toLowerCase();y.getMembers().then((function(e){var t=e.filter((function(e){return e.displayName.toLowerCase().startsWith(r)}));ue(t),t.length>0?pe(!0):pe(!1)}))}else ue([])}(t);var r,n=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(n){var i=n[0].replace(/:/g,"");te.getEmojiByShortcode(i).then((function(e){if(e&&"unicode"in e){var r=t.replace(n[0],e.unicode);x(r)}else x(t)})).catch((function(){x(t)})),V(!1)}else o?(r=o[0].replace(":",""),te.getEmojiBySearchQuery(r).then((function(e){e.length?(Q(e.slice(0,h)),V(!0)):(Q([]),V(!1))})).catch((function(){Q([]),V(!1)}))):V(!1)},onFocus:function(){return P(!0)},onBlur:function(){return P(!1)},inputRef:ee,color:"secondary",size:"small",slotProps:{input:{endAdornment:(0,a.jsxs)(g(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(A,{dataSource:y.emojiDataSource,onEmojiClick:ve,buttonColor:oe}),d&&ye]})},inputLabel:{className:C?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}}),(0,a.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,a.jsxs)(p(),{className:"rustic-input-actions",children:[y.children,(0,a.jsx)(N(),{title:"Send",children:(0,a.jsx)("span",{className:"rustic-send-button",children:(0,a.jsx)(v(),{"aria-label":"send message",onClick:ge,disabled:me(),color:"secondary",children:(0,a.jsx)(I,{name:"send"})})})})]})]})}));var H,W,K=function(){return K=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},K.apply(this,arguments)};!function(e){e.Owner="owner",e.Member="member"}(H||(H={})),function(e){e.Human="human",e.Agent="agent"}(W||(W={}));const U=function(e){var t=e.ws,r=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["ws"]);return(0,a.jsx)(F,K({},r,{send:function(e){var r,n;e.data=(r=e.data.text,n=[],r&&(null==r?void 0:r.trim().length)&&n.push({type:"text",text:r}),{messages:[{content:n,role:"user"}]}),t.send(e)}}))};return i})()));
|
|
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,t,r={8342:e=>{e.exports=require("emoji-picker-element")}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var i=Object.create(null);o.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&n&&r;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>r[e]));return a.default=()=>r,o.d(i,a),i},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 i={};o.r(i),o.d(i,{ParticipantRole:()=>F,ParticipantType:()=>W,default:()=>U});const a=require("react/jsx-runtime"),c=require("react");var s;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(s||(s={}));const l=require("@mui/material/Avatar");var u=o.n(l);const d=require("@mui/material/Box");var p=o.n(d);const m=require("@mui/material/CircularProgress");var f=o.n(m);const h=require("@mui/material/IconButton");var v=o.n(h);const y=require("@mui/material/InputAdornment");var g=o.n(y);const b=require("@mui/material/MenuItem");var j=o.n(b);const x=require("@mui/material/MenuList");var O=o.n(x);const w=require("@mui/material/Popover");var S=o.n(w);const k=require("@mui/material/TextField");var E=o.n(k);const C=require("@mui/material/Tooltip");var N=o.n(C);const P=require("@mui/material/Typography");var T=o.n(P),q=o(8342);const R=require("uuid");var _=function(){return _=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},_.apply(this,arguments)};function I(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,a.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:_({},t),children:e.name})}const M=require("@mui/material/styles"),A=function(e){var t=(0,M.useTheme)(),r=(0,c.useRef)(null),n=(0,c.useRef)(null),i=(0,c.useState)(!1),s=i[0],l=i[1],u={"--indicator-color":t.palette.divider,"--background":t.palette.background.paper,"--input-border-color":t.palette.divider,"--outline-color":t.palette.secondary.main};function d(){l(!1)}function p(t){t.detail.unicode&&e.onEmojiClick(t.detail.unicode),d()}return(0,c.useEffect)((function(){n.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then((function(r){var o=new(0,r.Picker)({dataSource:e.dataSource}),i="dark"===t.palette.mode?"dark":"light";o.classList.add(i),Object.keys(u).forEach((function(e){o.style.setProperty(e,u[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)(N(),{title:"Emoji",children:(0,a.jsx)(v(),{size:"small",ref:r,onClick:function(){l((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)(I,{name:"Mood"})})}),n.current&&(0,a.jsx)(S(),{open:s,anchorEl:r.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 z(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}function H(e){return(0,a.jsxs)(p(),{className:"rustic-participant-profile",children:[(0,a.jsx)(u(),{src:e.icon,className:"rustic-participant-avatar"}),(0,a.jsx)(T(),{variant:"body1Bold",children:e.displayName})]})}function L(e){var t=e.items,r=e.isOpen,n=e.onClose,o=e.onSelect,i=e.renderItem,c=e.anchorEl,s=e.selectedIndex;return(0,a.jsx)(S(),{disableAutoFocus:!0,open:r&&t.length>0,anchorEl:c,onClose:n,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},className:"rustic-suggestion-menu",children:(0,a.jsx)(O(),{children:t.map((function(e,t){return(0,a.jsx)(j(),{onClick:function(){return o(e)},selected:t===s,children:i(e)},t)}))})})}const B=(0,c.forwardRef)((function(e,t){var r=e.multiline,n=void 0===r||r,o=e.fullWidth,i=void 0===o||o,s=e.maxRows,l=void 0===s?6:s,u=e.enableSpeechToText,d=void 0!==u&&u,m=e.maximumEmojiSearchResults,h=void 0===m?5:m,y=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["multiline","fullWidth","maxRows","enableSpeechToText","maximumEmojiSearchResults"]),b=(0,c.useState)(""),j=b[0],x=b[1],O=(0,c.useState)(!1),w=O[0],S=O[1],k=(0,c.useState)(!1),C=k[0],P=k[1],_=(0,c.useState)(!1),M=_[0],B=_[1],F=(0,c.useState)(""),W=F[0],K=F[1],U=(0,c.useState)([]),$=U[0],Q=U[1],G=(0,c.useState)(!1),J=G[0],V=G[1],X=(0,c.useState)(0),Y=X[0],Z=X[1],ee=(0,c.useRef)(null),te=new q.Database({dataSource:y.emojiDataSource}),re=!j.trim().length,ne="".concat(w?"Stop":"Start"," speech to text"),oe=C?"primary.main":"primary.light",ie=w?"error.main":oe,ae=w?"stop_circle":"speech_to_text",ce=(0,c.useState)([]),se=ce[0],le=ce[1],ue=(0,c.useState)(!1),de=ue[0],pe=ue[1];function me(){return"boolean"==typeof y.isSendEnabled?!y.isSendEnabled:re}function fe(e,t){if(ee.current){var r=ee.current,n=r.selectionStart,o=r.selectionEnd;if("number"==typeof n&&"number"==typeof o){var i,a=j||"",c=a.substring(0,n),s=a.substring(o),l=void 0;t?(l=c.replace(t,e)+s,i=c.replace(t,e).length):(l=c+e+s,i=n+e.length),x(l),setTimeout((function(){var e,t;null===(e=ee.current)||void 0===e||e.focus(),null===(t=ee.current)||void 0===t||t.setSelectionRange(i,i)}),0)}}}function he(e){fe("@".concat(e," "),/@(\w*)$/),le([])}function ve(e,t){void 0===t&&(t=!1),fe(e,t?/:(\w+)$/:void 0),V(!1)}var ye=M?(0,a.jsx)(f(),{size:24}):(0,a.jsx)(N(),{title:ne,children:(0,a.jsx)(v(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,w?(e.stop(),B(!0),S(!1)):(e.start(),K(""),S(!0)),e.onstart=function(){S(!0)},e.onresult=function(e){var t,r=e.results[0][0].transcript;j.length>0?x(j+" "+r):x(r),null===(t=ee.current)||void 0===t||t.focus(),S(!1)},e.onerror=function(e){var t=D[e.error];K(t),S(!1)},e.onend=function(){B(!1),S(!1)}},size:"small",sx:{color:ie,"&:hover":{color:"primary.main"}},children:(0,a.jsx)(I,{name:ae})})});function ge(){var e,t,r=(new Date).toISOString(),n={id:(0,R.v4)(),timestamp:r,sender:y.sender,conversationId:y.conversationId,format:"chatCompletionRequest",data:{text:j},inReplyTo:null===(e=y.lastMsg)||void 0===e?void 0:e.id,messageHistory:null===(t=y.lastMsg)||void 0===t?void 0:t.messageHistory};y.send(n),x(""),K("")}return(0,a.jsxs)(p(),{className:"rustic-base-input",ref:t,children:[(0,a.jsxs)(p(),{className:"rustic-error-and-input-container",children:[(0,a.jsx)(p(),{className:"rustic-error-container",children:(0,a.jsx)(T(),{variant:"caption",color:"error",className:"rustic-error-message",children:W})}),(0,a.jsxs)(p(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:C?"secondary.main":"action.disabled"},children:[$.length>0&&ee.current&&(0,a.jsx)(L,{anchorEl:ee.current,items:$.filter((function(e){return"unicode"in e})),isOpen:J,onClose:function(){V(!1),Z(0)},onSelect:function(e){return ve(e.unicode,!0)},selectedIndex:Y,renderItem:z}),se.length>0&&ee.current&&(0,a.jsx)(L,{anchorEl:ee.current,items:se,isOpen:de,onClose:function(){pe(!1),Z(0)},onSelect:function(e){return he(e.displayName)},renderItem:H,selectedIndex:Y}),(0,a.jsx)(E(),{className:"rustic-text-field",variant:"outlined",value:j,label:y.label,placeholder:y.placeholder,maxRows:l,multiline:n,fullWidth:i,onKeyDown:function(e){var t,r="ArrowDown"===e.key,n="ArrowUp"===e.key;if("Enter"===e.key||"Tab"===e.key)e.shiftKey||e.preventDefault(),J&&$.length>0&&"unicode"in $[Y]?ve($[Y].unicode,!0):de&&se.length>0?he(se[Y].displayName):e.shiftKey||me()||ge();else{if(r||n)return e.preventDefault(),t=r?1:-1,void(J?Z((function(e){return(e+t+$.length)%$.length})):de&&Z((function(e){return(e+t+se.length)%se.length})));0!==Y&&Z(0)}},onChange:function(e){K("");var t=e.target.value;x(t),function(e){var t=e.match(/@(\w*)$/);if(t&&y.getMembers){var r=t[1].toLowerCase();y.getMembers().then((function(e){var t=e.filter((function(e){return e.displayName.toLowerCase().startsWith(r)}));le(t),t.length>0?pe(!0):pe(!1)}))}else le([])}(t);var r,n=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(n){var i=n[0].replace(/:/g,"");te.getEmojiByShortcode(i).then((function(e){if(e&&"unicode"in e){var r=t.replace(n[0],e.unicode);x(r)}else x(t)})).catch((function(){x(t)})),V(!1)}else o?(r=o[0].replace(":",""),te.getEmojiBySearchQuery(r).then((function(e){e.length?(Q(e.slice(0,h)),V(!0)):(Q([]),V(!1))})).catch((function(){Q([]),V(!1)}))):V(!1)},onFocus:function(){return P(!0)},onBlur:function(){return P(!1)},inputRef:ee,color:"secondary",size:"small",slotProps:{input:{endAdornment:(0,a.jsxs)(g(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(A,{dataSource:y.emojiDataSource,onEmojiClick:ve,buttonColor:oe}),d&&ye]})},inputLabel:{className:C?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}}),(0,a.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,a.jsxs)(p(),{className:"rustic-input-actions",children:[y.children,(0,a.jsx)(N(),{title:"Send",children:(0,a.jsx)("span",{className:"rustic-send-button",children:(0,a.jsx)(v(),{"aria-label":"send message",onClick:ge,disabled:me(),color:"secondary",children:(0,a.jsx)(I,{name:"send"})})})})]})]})}));var F,W,K=function(){return K=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},K.apply(this,arguments)};!function(e){e.Owner="owner",e.Member="member"}(F||(F={})),function(e){e.Human="human",e.Agent="agent"}(W||(W={}));const U=function(e){var t=e.ws,r=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["ws"]);return(0,a.jsx)(B,K({},r,{send:function(e){var r,n;e.data=(r=e.data.text,n=[],r&&(null==r?void 0:r.trim().length)&&n.push({type:"text",text:r}),{messages:[{content:n,role:"user"}]}),t.send(e)}}))};return i})()));
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
.rustic-message-archive {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
flex: 1;
|
|
5
|
+
gap: 16px;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.rustic-message-archive-loading {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex: 1;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.rustic-message-archive .rustic-message-container {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
flex: 1;
|
|
20
|
+
gap: 16px;
|
|
21
|
+
overflow: auto;
|
|
22
|
+
scroll-behavior: smooth;
|
|
23
|
+
scrollbar-width: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.rustic-message-archive .rustic-scroll-down-button {
|
|
27
|
+
position: sticky;
|
|
28
|
+
bottom: 16px;
|
|
29
|
+
left: 50%;
|
|
30
|
+
transform: translateX(-50%);
|
|
31
|
+
z-index: 10;
|
|
32
|
+
width: fit-content;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
span.rustic-icon-large {
|
|
36
|
+
font-size: 32px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.rustic-message-canvas {
|
|
40
|
+
gap: 4px;
|
|
41
|
+
position: relative;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.rustic-message-canvas .rustic-message-container {
|
|
45
|
+
padding: 16px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.rustic-message-canvas .rustic-message-actions-container {
|
|
49
|
+
opacity: 0;
|
|
50
|
+
position: absolute;
|
|
51
|
+
top: 4px;
|
|
52
|
+
right: 16px;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.rustic-message-canvas .rustic-header .rustic-timestamp {
|
|
58
|
+
margin-left: 16px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.rustic-message-canvas:hover .rustic-message-actions-container {
|
|
62
|
+
opacity: 1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.rustic-message-canvas .rustic-footer {
|
|
66
|
+
display: flex;
|
|
67
|
+
flex: 1;
|
|
68
|
+
justify-content: flex-end;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@media (max-width: 900px) {
|
|
72
|
+
.rustic-message-canvas .rustic-message-actions-container {
|
|
73
|
+
bottom: -20px;
|
|
74
|
+
top: unset;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.rustic-message-canvas .rustic-header .rustic-timestamp {
|
|
78
|
+
display: flex;
|
|
79
|
+
flex: 1;
|
|
80
|
+
justify-content: flex-end;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/messageArchive/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAA;AAE7B,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAE7C,eAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>N});const r=require("react/jsx-runtime"),n=require("@mui/material/Alert");var o=e.n(n);const a=require("@mui/material/Chip");var s=e.n(a);const i=require("@mui/material/CircularProgress");var c=e.n(i);const l=require("@mui/system/Box");var u=e.n(l);const d=require("react");var m=e.n(d);const f=require("@mui/material/Typography");var p=e.n(f),g=function(){return g=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},g.apply(this,arguments)};const v=function(e){var t=e.messages[0],n=e.messages.slice(1),o=e.supportedElements[t.format];return(0,r.jsx)(r.Fragment,{children:o?m().createElement(o,g(g({sender:e.sender,ws:e.ws,messageId:t.id,conversationId:t.conversationId},t.data),n.length>0&&{updatedData:n.map((function(e){return e.data}))})):(0,r.jsxs)(p(),{variant:"body2",children:["Unsupported element format: ",t.format]})})};var y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},y.apply(this,arguments)};function h(e){e.name.replaceAll("_","-");var t={};return e.color&&(t={color:e.color}),(0,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:y({},t),children:e.name})}const j=require("@mui/material"),b=require("@mui/material/Card");var x=e.n(b);const O=require("@mui/material/Stack");var w,S=e.n(O);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(w||(w={}));const T=function(e){return(0,r.jsx)(p(),{variant:"caption",color:"text.secondary",className:"rustic-timestamp",children:(t=e.timestamp,n=new Date(t),o=navigator.language,a={month:"short",day:"numeric"},s=new Date,i=n.getFullYear()!==s.getFullYear(),c=i?" at ":", ",i&&(a.year="numeric"),n.toLocaleDateString(o,a)+c+n.toLocaleTimeString(o,{hour:"numeric",minute:"2-digit",hour12:!0}))});var t,n,o,a,s,i,c},R=(0,d.forwardRef)((function(e,t){var n=(0,j.useTheme)(),o=e.inReplyTo?e.inReplyTo:e.message;return(0,r.jsxs)(S(),{id:o.id,className:"rustic-message-canvas",ref:t,children:[(0,r.jsxs)(S(),{direction:"row",alignItems:"center",spacing:1,className:"rustic-header",children:[e.getProfileComponent&&e.getProfileComponent(o),(0,r.jsx)(T,{timestamp:o.timestamp})]}),e.getActionsComponent&&e.getActionsComponent(e.message)&&(0,r.jsx)(x(),{variant:"outlined",className:"rustic-message-actions-container",sx:{boxShadow:n.shadows[1]},children:e.getActionsComponent(o)}),(0,r.jsxs)(x(),{variant:"outlined",className:"rustic-message-container",children:[e.children,e.inReplyTo&&(0,r.jsxs)(p(),{variant:"caption",color:"text.secondary",className:"rustic-footer",children:["Submitted by ",e.message.sender.name," at ",(0,r.jsx)(T,{timestamp:e.message.timestamp})]})]})]})}));var C=function(){return C=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},C.apply(this,arguments)},E=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};const N=function(e){var t=e.scrollDownLabel,n=void 0===t?"Scroll down":t,a=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["scrollDownLabel"]),i=(0,d.useRef)(null),l=(0,d.useRef)(null),m=(0,d.useRef)(),f=(0,d.useState)(!0),p=f[0],g=f[1],y=(0,d.useState)(!0),j=y[0],b=y[1],x=(0,d.useState)(!1),O=x[0],w=x[1],S=(0,d.useState)({}),T=S[0],N=S[1],P=(0,d.useState)(!0),A=P[0],q=P[1],M=(0,d.useState)(""),D=M[0],I=M[1],L=Object.keys(T).length;function _(){var e=l.current,t=i.current;if(e&&t){var r=e.getBoundingClientRect().bottom,n=t.getBoundingClientRect().bottom;g(n-1<=r)}}function H(){if(function(){var e,t=null===(e=l.current)||void 0===e?void 0:e.querySelectorAll("video");return!t||0===t.length||Array.from(t).every((function(e){return e.readyState>=1}))}()){var e=l.current;w(!0),e&&setTimeout((function(){b(!0),m.current&&clearTimeout(m.current),m.current=setTimeout((function(){b(!1)}),2e3),e.scrollTop=e.scrollHeight,g(!0)}),0)}else setTimeout(H,1)}return(0,d.useEffect)((function(){var e={};a.getHistoricMessages().then((function(t){t.forEach((function(t){var r=function(e,t){var r;if(!(r=t.format.includes("update")?t.threadId:t.format.includes("Response")?t.data.inReplyTo:t.id))return e;var n=C({},e),o=(n[r]||[])[0];return t.format.includes("update")&&o&&o.sender.id!==t.sender.id&&(r=t.id),n[r]||(n[r]=[]),t.format.includes("Response")&&o?n[r]=[C(C({},o),{data:C(C({},o.data),t.data)}),t]:n[r]=E(E([],n[r],!0),[t],!1),n}(e,t);e=r})),N(e),q(!1)})).catch((function(e){var t,r,n,o=(null===(r=null===(t=e.response)||void 0===t?void 0:t.data)||void 0===r?void 0:r.detail)||(null===(n=e.response)||void 0===n?void 0:n.data);I(o||"Failed to load messages"),q(!1)}))}),[a.getHistoricMessages]),(0,d.useEffect)((function(){!A&&T&&H();var e=l.current;if(e)return _(),e.addEventListener("scroll",_),window.addEventListener("resize",_),function(){e.removeEventListener("scroll",_),window.removeEventListener("resize",_)}}),[A,T]),(0,d.useEffect)((function(){H()}),[O]),A?(0,r.jsx)(u(),{className:"rustic-message-archive-loading",children:a.loadingIcon?a.loadingIcon:(0,r.jsx)(c(),{})}):(0,r.jsxs)(u(),{className:"rustic-message-archive",children:[a.infoMessage&&!D&&(0,r.jsx)(o(),{severity:"warning",children:a.infoMessage}),D&&(0,r.jsx)(o(),{severity:"error",children:D}),(0,r.jsxs)(u(),{ref:l,className:"rustic-message-container",children:[Object.keys(T).map((function(e,t){var n=T[e],o=n[n.length-1],s=o.format.includes("Response"),c=s&&{inReplyTo:n[0]};return(0,r.jsx)(R,C({message:o},c,{getActionsComponent:a.getActionsComponent,getProfileComponent:a.getProfileComponent,ref:t===L-1?i:null,children:(0,r.jsx)(v,{messages:s?[n[0]]:n,supportedElements:a.supportedElements})}),e)})),!p&&!j&&(0,r.jsx)(s(),{color:"secondary",className:"rustic-scroll-down-button",size:"medium",onClick:H,label:(0,r.jsxs)(r.Fragment,{children:[n,(0,r.jsx)(h,{name:"arrow_downward"})]})})]})]})};return t})()));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import './messageArchive.css';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import { type MessageContainerProps } from '../messageCanvas/messageCanvas';
|
|
4
|
+
import type { ComponentMap, Message } from '../types';
|
|
5
|
+
export interface MessageArchiveProps extends MessageContainerProps {
|
|
6
|
+
/** A component map contains message formats as keys and their corresponding React components as values. */
|
|
7
|
+
supportedElements: ComponentMap;
|
|
8
|
+
/** A function that can be used to get the historic messages */
|
|
9
|
+
getHistoricMessages: () => Promise<Message[]>;
|
|
10
|
+
/** Text label for scroll down button. Default value is 'scroll down'. */
|
|
11
|
+
scrollDownLabel?: string;
|
|
12
|
+
/** Info message to display at the top of the message archive */
|
|
13
|
+
infoMessage?: string;
|
|
14
|
+
/** Loading icon to display while fetching historic messages. If not provided, a default spinner will be shown */
|
|
15
|
+
loadingIcon?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
The `MessageArchive` component uses `MessageCanvas` and `ElementRenderer` to render a list of messages. It serves as a container for individual message items, each encapsulated within a `MessageCanvas` for consistent styling and layout. Unlike the `MessageSpace` component, it does not support message sending functionality. Instead, it is designed to display archived messages in a read-only format. Do not include any components that require a WebSocket connection, such as `Prompts`, in the `supportedElements`.
|
|
19
|
+
|
|
20
|
+
The `MessageArchive` component can combine update messages with the original message and render them as a single message. For this to work, the `threadId` of the update message must match the `id` of the original message, and the format of the update message should be prefixed with 'update'. For example, if the original message format is 'streamingText', the update message format should be 'updateStreamingText'.
|
|
21
|
+
|
|
22
|
+
Note: For more information about the `getActionsComponent` and `getProfileComponent` fields, refer to the [MessageCanvas' docs](https://rustic-ai.github.io/rustic-ui-components/?path=/docs/rustic-ui-message-canvas-message-canvas--docs).
|
|
23
|
+
*/
|
|
24
|
+
export default function MessageArchive({ scrollDownLabel, ...props }: MessageArchiveProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=messageArchive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageArchive.d.ts","sourceRoot":"","sources":["../../../src/components/messageArchive/messageArchive.tsx"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAA;AAM7B,OAAc,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAA;AAI1E,OAAsB,EACpB,KAAK,qBAAqB,EAC3B,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAErD,MAAM,WAAW,mBAAoB,SAAQ,qBAAqB;IAChE,2GAA2G;IAC3G,iBAAiB,EAAE,YAAY,CAAA;IAC/B,+DAA+D;IAC/D,mBAAmB,EAAE,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC7C,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iHAAiH;IACjH,WAAW,CAAC,EAAE,SAAS,CAAA;CACxB;AAqDD;;;;;;EAME;AAEF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,eAA+B,EAC/B,GAAG,KAAK,EACT,EAAE,mBAAmB,2CA4KrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ParticipantRole:()=>j,ParticipantType:()=>q,default:()=>S});const r=require("react/jsx-runtime"),n=require("@mui/material"),a=require("@mui/material/Box");var i=e.n(a);const o=require("@mui/material/Chip");var u=e.n(o);const s=require("@mui/material/Stack");var c=e.n(s);const l=require("@mui/material/Typography");var d=e.n(l);const m=require("react"),p=require("uuid");var f;function
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ParticipantRole:()=>j,ParticipantType:()=>q,default:()=>S});const r=require("react/jsx-runtime"),n=require("@mui/material"),a=require("@mui/material/Box");var i=e.n(a);const o=require("@mui/material/Chip");var u=e.n(o);const s=require("@mui/material/Stack");var c=e.n(s);const l=require("@mui/material/Typography");var d=e.n(l);const m=require("react"),p=require("uuid");var f;function v(e,t){var r=[];if(e&&(null==e?void 0:e.trim().length)&&r.push({type:"text",text:e}),t&&t.length>0)for(var n=0;n<(null==t?void 0:t.length);n++)r.push({type:"file_url",file_url:{url:t[n].url,name:t[n].name}});return{messages:[{content:r,role:"user"}]}}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(f||(f={}));const y=require("dompurify");var x=e.n(y);const b=require("marked");function g(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=b.marked.parse(t,{async:!1});return x().sanitize(r)}const h=function(e){var t=(0,m.useState)(g(e.text)),n=t[0],a=t[1];return(0,m.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var t=e.updatedData[e.updatedData.length-1].text;a(g(t))}}),[e.text,e.updatedData]),(0,r.jsx)(d(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:n}})};var j,q;!function(e){e.Owner="owner",e.Member="member"}(j||(j={})),function(e){e.Human="human",e.Agent="agent"}(q||(q={}));const S=function(e){var t=(0,m.useState)(""),a=t[0],o=t[1],s=(0,n.useTheme)(),l=(0,n.useMediaQuery)(s.breakpoints.down("md"))?"column":"row",f=e.options.map((function(t,n){return(0,r.jsx)(u(),{onClick:function(){return function(t){var r;o(t);var n=(new Date).toISOString(),a={id:(0,p.v4)(),timestamp:n,sender:e.sender,conversationId:e.conversationId,format:"chatCompletionRequest",data:v(t.toString()),inReplyTo:e.messageId};null===(r=e.ws)||void 0===r||r.send(a)}(t)},color:"secondary",size:"small",sx:a===t?{"&.Mui-disabled":{backgroundColor:"secondary.light",color:"text.primary"}}:{},className:"rustic-option",disabled:!!a||!e.ws,"aria-disabled":!!a||!e.ws,label:t},n)}));return(0,r.jsxs)(i(),{className:"rustic-question",children:[(e.title||e.description)&&(0,r.jsxs)(i(),{className:"rustic-question-text",children:[e.title&&(0,r.jsx)(d(),{variant:"h6",className:"rustic-title",children:e.title}),e.description&&(0,r.jsx)(h,{text:e.description})]}),(0,r.jsx)(c(),{direction:l,className:"rustic-options-container",children:f})]})};return t})()));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { InputType } from 'storybook/internal/types';
|
|
2
2
|
export declare const conversationIdDescription: InputType;
|
|
3
3
|
export declare const senderDescription: InputType;
|
|
4
|
+
export declare const optionalWsDescription: InputType;
|
|
4
5
|
export declare const wsDescription: InputType;
|
|
5
6
|
export declare const participantDetail: string;
|
|
6
7
|
export declare const getMembersDescription: InputType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedDescription.d.ts","sourceRoot":"","sources":["../../src/components/sharedDescription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEzD,eAAO,MAAM,yBAAyB,EAAE,SAIvC,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,SAmB/B,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"sharedDescription.d.ts","sourceRoot":"","sources":["../../src/components/sharedDescription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEzD,eAAO,MAAM,yBAAyB,EAAE,SAIvC,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,SAmB/B,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,SAuBnC,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,SAK3B,CAAA;AAED,eAAO,MAAM,iBAAiB,QAMoC,CAAA;AAElE,eAAO,MAAM,qBAAqB,EAAE,SASnC,CAAA;AAED,eAAO,MAAM,oBAAoB,EAAE,SA4ElC,CAAA"}
|
|
@@ -10,6 +10,15 @@ export interface Sender {
|
|
|
10
10
|
/** name of the sender if available */
|
|
11
11
|
name?: string;
|
|
12
12
|
}
|
|
13
|
+
export interface AgentTag {
|
|
14
|
+
id?: string | null;
|
|
15
|
+
name?: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface ProcessEntry {
|
|
18
|
+
agent: AgentTag;
|
|
19
|
+
origin: string;
|
|
20
|
+
result: string;
|
|
21
|
+
}
|
|
13
22
|
export interface Message {
|
|
14
23
|
id: string;
|
|
15
24
|
timestamp: string;
|
|
@@ -22,6 +31,7 @@ export interface Message {
|
|
|
22
31
|
priority?: string;
|
|
23
32
|
taggedParticipants?: string[];
|
|
24
33
|
topic?: string;
|
|
34
|
+
messageHistory?: ProcessEntry[];
|
|
25
35
|
}
|
|
26
36
|
export interface ComponentMap {
|
|
27
37
|
[key: string]: React.ComponentType<any>;
|
|
@@ -93,6 +103,8 @@ export interface ImageFormat extends VisualizationFormat {
|
|
|
93
103
|
width?: number;
|
|
94
104
|
/** Height rendered in pixels. */
|
|
95
105
|
height?: number;
|
|
106
|
+
/** A function that can be used to get the headers for the url requests. */
|
|
107
|
+
getAuthHeaders?: GetAuthHeaders;
|
|
96
108
|
}
|
|
97
109
|
export interface TableHeader {
|
|
98
110
|
/** Field in table data for this header. */
|
|
@@ -219,6 +231,8 @@ export interface BaseInputProps {
|
|
|
219
231
|
emojiDataSource?: string;
|
|
220
232
|
/** Function to fetch the list of members. Should return a promise that resolves to an array of members. */
|
|
221
233
|
getMembers?: () => Promise<Participant[]>;
|
|
234
|
+
/** Used to set inReplyTo and messageHistory */
|
|
235
|
+
lastMsg?: Message;
|
|
222
236
|
}
|
|
223
237
|
export interface TextInputProps extends Omit<BaseInputProps, 'send' | 'isSendEnabled'> {
|
|
224
238
|
/** WebSocket connection to send and receive messages to and from a backend.*/
|
|
@@ -265,9 +279,9 @@ export interface UploaderProps {
|
|
|
265
279
|
listFiles?: () => Promise<FileData[]>;
|
|
266
280
|
}
|
|
267
281
|
export type MultimodalInputProps = TextInputProps & Omit<UploaderProps, 'messageId' | 'onFileUpdate' | 'filePreviewsContainer' | 'errorMessagesContainer'>;
|
|
268
|
-
export interface
|
|
269
|
-
/** WebSocket connection to send and receive messages to and from a backend. This value will be set automatically if the component is rendered with `ElementRenderer` or `MessageSpace`. */
|
|
270
|
-
ws
|
|
282
|
+
export interface ConversationBaseProps {
|
|
283
|
+
/** WebSocket connection to send and receive messages to and from a backend. This value will be set automatically if the component is rendered with `ElementRenderer` or `MessageSpace`. If not provided, the component may not be able to send or receive messages. */
|
|
284
|
+
ws?: WebSocketClient;
|
|
271
285
|
/** Current user. This value will be set automatically if the component is rendered with `ElementRenderer` or `MessageSpace`. */
|
|
272
286
|
sender: Sender;
|
|
273
287
|
/** Id of the current conversation. This value will be set automatically if the component is rendered with `ElementRenderer` or `MessageSpace`. */
|
|
@@ -275,18 +289,26 @@ export interface ConversationProps {
|
|
|
275
289
|
/** Id of the message. This value will be set automatically if the component is rendered with `ElementRenderer` or `MessageSpace`. */
|
|
276
290
|
messageId: string;
|
|
277
291
|
}
|
|
292
|
+
export interface ConversationPropsWithOptionalWs extends ConversationBaseProps {
|
|
293
|
+
/** WebSocket connection to send response messages to a backend. This value will be set automatically if the component is rendered with `ElementRenderer` or `MessageSpace`. If not provided, the component will not be interactive. */
|
|
294
|
+
ws?: WebSocketClient;
|
|
295
|
+
}
|
|
296
|
+
export interface ConversationPropsWithMandatoryWs extends ConversationBaseProps {
|
|
297
|
+
/** WebSocket connection to send and receive messages to and from a backend. This value will be set automatically if the component is rendered with `ElementRenderer` or `MessageSpace`. */
|
|
298
|
+
ws: WebSocketClient;
|
|
299
|
+
}
|
|
278
300
|
export interface QuestionFormat extends DataFormat {
|
|
279
301
|
/** Array of options to choose from. */
|
|
280
302
|
options: (string | number)[];
|
|
281
303
|
}
|
|
282
|
-
export interface QuestionProps extends QuestionFormat,
|
|
304
|
+
export interface QuestionProps extends QuestionFormat, ConversationPropsWithOptionalWs {
|
|
283
305
|
}
|
|
284
306
|
export interface PromptsFormat {
|
|
285
307
|
/** A list of prompt strings for users to select from. These prompts will be displayed as interactive elements in the UI. */
|
|
286
308
|
prompts: string[];
|
|
287
309
|
position?: 'inConversation' | 'hoverOverInput';
|
|
288
310
|
}
|
|
289
|
-
export interface PromptsProps extends PromptsFormat,
|
|
311
|
+
export interface PromptsProps extends PromptsFormat, ConversationPropsWithMandatoryWs {
|
|
290
312
|
/** An optional className to apply to the prompts container. */
|
|
291
313
|
className?: string;
|
|
292
314
|
}
|
|
@@ -334,7 +356,7 @@ export interface FormFormat extends DataFormat {
|
|
|
334
356
|
/** Response for the form fields */
|
|
335
357
|
data?: any;
|
|
336
358
|
}
|
|
337
|
-
export interface DynamicFormProps extends FormFormat,
|
|
359
|
+
export interface DynamicFormProps extends FormFormat, ConversationPropsWithOptionalWs {
|
|
338
360
|
}
|
|
339
361
|
interface ContentBase {
|
|
340
362
|
type: 'text' | 'image_url' | 'input_audio' | 'file_url';
|