@rustic-ai/ui-components 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/components/calendar/index.js +1 -1
  2. package/dist/components/codeSnippet/index.js +1 -1
  3. package/dist/components/image/index.js +1 -1
  4. package/dist/components/input/multimodal/multimodalInput/index.js +1 -1
  5. package/dist/components/input/multimodal/uploader/index.js +1 -1
  6. package/dist/components/input/textInput/index.js +1 -1
  7. package/dist/components/map/index.js +1 -1
  8. package/dist/components/markdown/index.js +1 -1
  9. package/dist/components/media/audio/index.js +1 -1
  10. package/dist/components/media/video/index.js +1 -1
  11. package/dist/components/messageCanvas/actions/copy/index.js +1 -1
  12. package/dist/components/messageCanvas/actions/index.js +1 -1
  13. package/dist/components/messageCanvas/actions/textToSpeech/index.js +1 -1
  14. package/dist/components/multipart/chatCompletion/index.js +1 -1
  15. package/dist/components/multipart/multipart/index.js +1 -1
  16. package/dist/components/participantsContainer/index.js +1 -1
  17. package/dist/components/pdfViewer/index.js +1 -1
  18. package/dist/components/promptBuilder/index.js +1 -1
  19. package/dist/components/question/index.js +1 -1
  20. package/dist/components/question/question.d.ts.map +1 -1
  21. package/dist/components/table/index.js +1 -1
  22. package/dist/components/text/index.js +1 -1
  23. package/dist/components/types.d.ts +10 -0
  24. package/dist/components/types.d.ts.map +1 -1
  25. package/dist/components/visualization/perspectiveViz/index.js +1 -1
  26. package/dist/components/visualization/perspectiveViz/perspectiveViz.d.ts.map +1 -1
  27. package/dist/components/weather/index.js +1 -1
  28. package/dist/index.js +1 -1
  29. package/package.json +3 -3
@@ -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 a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},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:()=>k,ParticipantType:()=>R,default:()=>w});const r=require("react/jsx-runtime"),a=require("@fullcalendar/daygrid");var o=e.n(a);const i=require("@fullcalendar/react");var n=e.n(i);const d=require("@fullcalendar/timegrid");var c=e.n(d);const u=require("@mui/material/Box");var l=e.n(u);const s=require("@mui/material/styles"),p=require("@mui/material/Typography");var f=e.n(p);const m=require("@mui/material/useMediaQuery");var y=e.n(m);const b=require("react"),v=require("dompurify");var h=e.n(v);const g=require("marked");function x(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=g.marked.parse(t,{async:!1});return h().sanitize(r)}const j=function(e){var t=(0,b.useState)(x(e.text)),a=t[0],o=t[1];return(0,b.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var t=e.updatedData[e.updatedData.length-1].text;o(x(t))}}),[e.text,e.updatedData]),(0,r.jsx)(f(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:a}})};var k,R,q=function(){return q=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},q.apply(this,arguments)};function D(e){return{title:e.title?e.title:"",start:e.start,end:e.end,allDay:e.isAllDay}}!function(e){e.Owner="owner",e.Member="member"}(k||(k={})),function(e){e.Human="human",e.Agent="agent"}(R||(R={}));const w=function(e){var t=(0,s.useTheme)(),a=y()(t.breakpoints.up("md"));return(0,r.jsxs)(l(),{className:"rustic-fc-calendar",sx:{border:"1px solid ".concat(t.palette.divider),borderRadius:"".concat(t.shape.borderRadius,"px"),".fc .fc-toolbar-title":q({},t.typography.h6),".fc .fc-scrollgrid-liquid":{borderRadius:"".concat(t.shape.borderRadius,"px")},".fc td":{borderRadius:"0 0 ".concat(t.shape.borderRadius,"px ").concat(t.shape.borderRadius,"px")},".fc .fc-scrollgrid-section-header > th":{borderRadius:"".concat(t.shape.borderRadius,"px ").concat(t.shape.borderRadius,"px 0 0")},".fc .fc-button, .fc .fc-button:active":{color:t.palette.primary.main,backgroundColor:t.palette.background.paper,border:"1px solid ".concat(t.palette.divider),borderRadius:"".concat(t.shape.borderRadius,"px"),"&:hover":{backgroundColor:t.palette.secondary.light,border:"1px solid ".concat(t.palette.divider)}},".fc .fc-button-group .fc-button.fc-button-active":{backgroundColor:t.palette.secondary.main,border:"1px solid ".concat(t.palette.divider)},".fc a, .fc .fc-event-title, .fc .fc-button, .fc .fc-timegrid-slot":q({},t.typography.caption)},children:[e.title&&(0,r.jsx)(f(),{variant:"h6",children:e.title}),e.description&&(0,r.jsx)(j,{text:e.description}),(0,r.jsx)(n(),{plugins:[c(),o()],initialView:a?"dayGridMonth":"timeGridDay",headerToolbar:{left:"title",right:"prev,next dayGridMonth,timeGridWeek,timeGridDay"},eventColor:t.palette.secondary.main,displayEventTime:!1,titleFormat:{year:"numeric",month:"long"},views:{dayGridMonth:{dayHeaderFormat:{weekday:a?"long":"narrow"}},timeGridWeek:{dayHeaderFormat:{weekday:"short",day:"numeric"}},timeGridDay:{dayHeaderFormat:{weekday:"long",day:"numeric"}}},allDaySlot:!1,initialDate:e.events[0].start,events:e.events.map(D)})]})};return t})()));
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 a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},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,{MessageProcessStatus:()=>R,ParticipantRole:()=>k,ParticipantType:()=>q,default:()=>M});const r=require("react/jsx-runtime"),a=require("@fullcalendar/daygrid");var o=e.n(a);const n=require("@fullcalendar/react");var i=e.n(n);const d=require("@fullcalendar/timegrid");var c=e.n(d);const u=require("@mui/material/Box");var s=e.n(u);const l=require("@mui/material/styles"),p=require("@mui/material/Typography");var f=e.n(p);const m=require("@mui/material/useMediaQuery");var y=e.n(m);const b=require("react"),v=require("dompurify");var g=e.n(v);const h=require("marked");function x(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=h.marked.parse(t,{async:!1});return g().sanitize(r)}const j=function(e){var t=(0,b.useState)(x(e.text)),a=t[0],o=t[1];return(0,b.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var t=e.updatedData[e.updatedData.length-1].text;o(x(t))}}),[e.text,e.updatedData]),(0,r.jsx)(f(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:a}})};var R,k,q,D=function(){return D=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},D.apply(this,arguments)};function w(e){return{title:e.title?e.title:"",start:e.start,end:e.end,allDay:e.isAllDay}}!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(R||(R={})),function(e){e.Owner="owner",e.Member="member"}(k||(k={})),function(e){e.Human="human",e.Agent="agent"}(q||(q={}));const M=function(e){var t=(0,l.useTheme)(),a=y()(t.breakpoints.up("md"));return(0,r.jsxs)(s(),{className:"rustic-fc-calendar",sx:{border:"1px solid ".concat(t.palette.divider),borderRadius:"".concat(t.shape.borderRadius,"px"),".fc .fc-toolbar-title":D({},t.typography.h6),".fc .fc-scrollgrid-liquid":{borderRadius:"".concat(t.shape.borderRadius,"px")},".fc td":{borderRadius:"0 0 ".concat(t.shape.borderRadius,"px ").concat(t.shape.borderRadius,"px")},".fc .fc-scrollgrid-section-header > th":{borderRadius:"".concat(t.shape.borderRadius,"px ").concat(t.shape.borderRadius,"px 0 0")},".fc .fc-button, .fc .fc-button:active":{color:t.palette.primary.main,backgroundColor:t.palette.background.paper,border:"1px solid ".concat(t.palette.divider),borderRadius:"".concat(t.shape.borderRadius,"px"),"&:hover":{backgroundColor:t.palette.secondary.light,border:"1px solid ".concat(t.palette.divider)}},".fc .fc-button-group .fc-button.fc-button-active":{backgroundColor:t.palette.secondary.main,border:"1px solid ".concat(t.palette.divider)},".fc a, .fc .fc-event-title, .fc .fc-button, .fc .fc-timegrid-slot":D({},t.typography.caption)},children:[e.title&&(0,r.jsx)(f(),{variant:"h6",children:e.title}),e.description&&(0,r.jsx)(j,{text:e.description}),(0,r.jsx)(i(),{plugins:[c(),o()],initialView:a?"dayGridMonth":"timeGridDay",headerToolbar:{left:"title",right:"prev,next dayGridMonth,timeGridWeek,timeGridDay"},eventColor:t.palette.secondary.main,displayEventTime:!1,titleFormat:{year:"numeric",month:"long"},views:{dayGridMonth:{dayHeaderFormat:{weekday:a?"long":"narrow"}},timeGridWeek:{dayHeaderFormat:{weekday:"short",day:"numeric"}},timeGridDay:{dayHeaderFormat:{weekday:"long",day:"numeric"}}},allDaySlot:!1,initialDate:e.events[0].start,events:e.events.map(w)})]})};return t})()));
@@ -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 a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},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:()=>b,default:()=>h});const r=require("react/jsx-runtime"),a=require("@codemirror/language"),n=require("@codemirror/language-data"),o=require("@codemirror/state"),i=require("@codemirror/view"),u=require("@mui/material/Typography");var c=e.n(u);const d=require("@mui/system"),s=require("react"),l=require("dompurify");var f=e.n(l);const p=require("marked");function g(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=p.marked.parse(t,{async:!1});return f().sanitize(r)}const m=function(e){var t=(0,s.useState)(g(e.text)),a=t[0],n=t[1];return(0,s.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var t=e.updatedData[e.updatedData.length-1].text;n(g(t))}}),[e.text,e.updatedData]),(0,r.jsx)(c(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:a}})};var y,b;!function(e){e.Owner="owner",e.Member="member"}(y||(y={})),function(e){e.Human="human",e.Agent="agent"}(b||(b={}));const h=function(e){var t=(0,s.useRef)(null),u=(0,s.useRef)(),l=new o.Compartment,f=[o.EditorState.readOnly.of(!0),(0,i.highlightSpecialChars)(),(0,a.syntaxHighlighting)(a.defaultHighlightStyle,{fallback:!0}),l.of([])],p=n.languages.find((function(t){return t.name.toLowerCase()===e.language.toLowerCase()}));return(0,s.useEffect)((function(){if(t.current&&!u.current){var r=t.current,a=o.EditorState.create({doc:e.code,extensions:f});u.current=new i.EditorView({state:a,parent:r}),p&&u.current&&p.load().then((function(e){var t;null===(t=u.current)||void 0===t||t.dispatch({effects:l.reconfigure(e.extension)})}))}}),[]),(0,r.jsxs)(d.Box,{children:[e.title&&(0,r.jsx)(c(),{variant:"h6",children:e.title}),e.description&&(0,r.jsx)(m,{text:e.description}),(0,r.jsx)(d.Box,{className:"rustic-code-snippet",sx:{backgroundColor:"background.default"},"aria-label":"code snippet",ref:t,children:(0,r.jsx)(c(),{variant:"body2","aria-label":"language type",children:e.language})})]})};return t})()));
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,{MessageProcessStatus:()=>y,ParticipantRole:()=>b,ParticipantType:()=>h,default:()=>x});const r=require("react/jsx-runtime"),n=require("@codemirror/language"),a=require("@codemirror/language-data"),o=require("@codemirror/state"),i=require("@codemirror/view"),u=require("@mui/material/Typography");var c=e.n(u);const d=require("@mui/system"),s=require("react"),l=require("dompurify");var f=e.n(l);const p=require("marked");function g(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=p.marked.parse(t,{async:!1});return f().sanitize(r)}const m=function(e){var t=(0,s.useState)(g(e.text)),n=t[0],a=t[1];return(0,s.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)(c(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:n}})};var y,b,h;!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(y||(y={})),function(e){e.Owner="owner",e.Member="member"}(b||(b={})),function(e){e.Human="human",e.Agent="agent"}(h||(h={}));const x=function(e){var t=(0,s.useRef)(null),u=(0,s.useRef)(),l=new o.Compartment,f=[o.EditorState.readOnly.of(!0),(0,i.highlightSpecialChars)(),(0,n.syntaxHighlighting)(n.defaultHighlightStyle,{fallback:!0}),l.of([])],p=a.languages.find((function(t){return t.name.toLowerCase()===e.language.toLowerCase()}));return(0,s.useEffect)((function(){if(t.current&&!u.current){var r=t.current,n=o.EditorState.create({doc:e.code,extensions:f});u.current=new i.EditorView({state:n,parent:r}),p&&u.current&&p.load().then((function(e){var t;null===(t=u.current)||void 0===t||t.dispatch({effects:l.reconfigure(e.extension)})}))}}),[]),(0,r.jsxs)(d.Box,{children:[e.title&&(0,r.jsx)(c(),{variant:"h6",children:e.title}),e.description&&(0,r.jsx)(m,{text:e.description}),(0,r.jsx)(d.Box,{className:"rustic-code-snippet",sx:{backgroundColor:"background.default"},"aria-label":"code snippet",ref:t,children:(0,r.jsx)(c(),{variant:"body2","aria-label":"language type",children:e.language})})]})};return t})()));
@@ -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:()=>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})()));
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,{MessageProcessStatus:()=>g,ParticipantRole:()=>y,ParticipantType:()=>m,default:()=>v});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 g,y,m,b=function(){return b=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},b.apply(this,arguments)};!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(g||(g={})),function(e){e.Owner="owner",e.Member="member"}(y||(y={})),function(e){e.Human="human",e.Agent="agent"}(m||(m={}));const v=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],g=f[1],y=(0,u.useState)(""),m=y[0],v=y[1],O=(0,u.useState)(""),j=O[0],x=O[1];return(0,u.useEffect)((function(){d.getAuthHeaders&&(g(!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"),g(!1)})))}),[d.src,d.getAuthHeaders]),m.length>0?(0,r.jsx)(i(),{variant:"body2",children:m}):(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",b({},(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"),g(!1)},onLoad:function(){g(!1)}})),d.description&&(0,r.jsx)("figcaption",{children:(0,r.jsx)(h,{text:d.description})})]})};return t})()));
@@ -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,n={9767:(e,t,n)=>{n.d(t,{A:()=>a});var r=n(8732),o=(n(2015),function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])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,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:o({},t),children:e.name})}},3110:(e,t,n)=>{n.d(t,{default:()=>r});const r=n(9767).A},8342:e=>{e.exports=require("emoji-picker-element")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var a=r[e]={exports:{}};return n[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(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var a=Object.create(null);o.r(a);var i={};e=e||[null,t({}),t([]),t(t)];for(var c=2&r&&n;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach((e=>i[e]=()=>n[e]));return i.default=()=>n,o.d(a,i),a},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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:()=>ke});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 C=require("@mui/material/Popover");var N=o.n(C);const k=require("@mui/material/TextField");var F=o.n(k);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)(),n=(0,u.useRef)(null),r=(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(){r.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then((function(n){var o=new(0,n.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])})),r.current=o})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,u.useEffect)((function(){return r.current&&r.current.addEventListener("emoji-click",f),function(){var e;null===(e=r.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:n,onClick:function(){l((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)(A.A,{name:"Mood"})})}),r.current&&(0,i.jsx)(N(),{open:c,anchorEl:n.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&&r.current&&!e.contains(r.current)&&e.appendChild(r.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,n=e.isOpen,r=e.onClose,o=e.onSelect,a=e.renderItem,c=e.anchorEl,l=e.selectedIndex;return(0,i.jsx)(N(),{disableAutoFocus:!0,open:n&&t.length>0,anchorEl:c,onClose:r,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 n=e.multiline,r=void 0===n||n,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 n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["multiline","fullWidth","maxRows","enableSpeechToText","maximumEmojiSearchResults"]),b=(0,u.useState)(""),j=b[0],w=b[1],S=(0,u.useState)(!1),O=S[0],C=S[1],N=(0,u.useState)(!1),k=N[0],P=N[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}),ne=!j.trim().length,re="".concat(O?"Stop":"Start"," speech to text"),oe=k?"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],fe=f&&"undefined"!=typeof window&&!!window.webkitSpeechRecognition;function me(){return"boolean"==typeof g.isSendEnabled?!g.isSendEnabled:ne}function he(e,t){if(ee.current){var n=ee.current,r=n.selectionStart,o=n.selectionEnd;if("number"==typeof r&&"number"==typeof o){var a,i=j||"",c=i.substring(0,r),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=r+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 ve(e){he("@".concat(e," "),/@(\w*)$/),se([])}function ge(e,t){void 0===t&&(t=!1),he(e,t?/:(\w+)$/:void 0),Y(!1)}var xe=M?(0,i.jsx)(v(),{size:24}):(0,i.jsx)(E(),{title:re,children:(0,i.jsx)(x(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,O?(e.stop(),z(!0),C(!1)):(e.start(),$(""),C(!0)),e.onstart=function(){C(!0)},e.onresult=function(e){var t,n=e.results[0][0].transcript;j.length>0?w(j+" "+n):w(n),null===(t=ee.current)||void 0===t||t.focus(),C(!1)},e.onerror=function(e){var t=D[e.error];$(t),C(!1)},e.onend=function(){z(!1),C(!1)}},size:"small",sx:{color:ae,"&:hover":{color:"primary.main"}},children:(0,i.jsx)(A.A,{name:ie})})});function be(){var e,t,n=(new Date).toISOString(),r={id:(0,d.v4)(),timestamp:n,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(r),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:k?"secondary.main":"action.disabled",backgroundColor:"background.paper"},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 ge(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 ve(e.displayName)},renderItem:U,selectedIndex:J}),(0,i.jsx)(F(),{className:"rustic-text-field",variant:"outlined",value:j,label:g.label,placeholder:g.placeholder,maxRows:s,multiline:r,fullWidth:a,onKeyDown:function(e){var t,n="ArrowDown"===e.key,r="ArrowUp"===e.key;if("Enter"===e.key||"Tab"===e.key)e.shiftKey||e.preventDefault(),V&&K.length>0&&"unicode"in K[J]?ge(K[J].unicode,!0):de&&le.length>0?ve(le[J].displayName):e.shiftKey||me()||be();else{if(n||r)return e.preventDefault(),t=n?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 n=t[1].toLowerCase();g.getMembers().then((function(e){var t=e.filter((function(e){return e.displayName.toLowerCase().startsWith(n)}));se(t),t.length>0?pe(!0):pe(!1)}))}else se([])}(t);var n,r=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(r){var a=r[0].replace(/:/g,"");te.getEmojiByShortcode(a).then((function(e){if(e&&"unicode"in e){var n=t.replace(r[0],e.unicode);w(n)}else w(t)})).catch((function(){w(t)})),Y(!1)}else o?(n=o[0].replace(":",""),te.getEmojiBySearchQuery(n).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:ge,buttonColor:oe}),fe&&xe]})},inputLabel:{className:k?"":"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:be,disabled:me(),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 ne=require("pdfjs-dist"),re=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"}},n=(t[e.action].label.replaceAll(" ","-").toLowerCase(),t[e.action]);return(0,i.jsx)(E(),{title:n.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:n.symbol})})})})};var oe={pdf:function(e){var t,n=(0,u.useRef)(null),r=(0,u.useState)(1),o=r[0],a=r[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})),C=O[0],N=O[1];function k(t){ne.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:C}),r=n.current;if(r){var o=r.getContext("2d");if(o){var a=window.devicePixelRatio||1;r.style.width="".concat(t.width,"px"),r.style.height="".concat(t.height,"px"),r.width=t.width*a,r.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(){ne.GlobalWorkerOptions.workerSrc||(ne.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(ne.version,"/pdf.worker.mjs")),e.getAuthHeaders?e.getAuthHeaders().then((function(e){return k(e.headers)})).catch((function(){return g(!0)})):k()}),[e.url,o,C]),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)(re,{action:"zoomOut",onClick:function(){N((function(e){return Math.max(e-.2,.2)}))}}),(0,i.jsx)(re,{action:"zoomIn",onClick:function(){N((function(e){return e+.2}))}})]}),(0,i.jsx)(l(),{className:"rustic-pdf-viewer-body",children:(0,i.jsx)(l(),{className:"rustic-pdf-viewer-body-inner",children:(0,i.jsx)("canvas",{ref:n})})}),(0,i.jsxs)(X(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,i.jsx)(re,{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)(F(),{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)(re,{action:"nextPage",onClick:function(){o<s&&(a(o+1),m(o+1))},isDisabled:o===s})]})]})}};function ae(e){var t=e.supportedViewers,n=void 0===t?oe:t,r=e.showFullName,o=void 0===r||r,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(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&&n?n[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,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])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),n=t[0],r=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 r(!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),r(!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(),r(!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:n,onClose:function(){return r(!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,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},be.apply(this,arguments)},ye=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};function je(e){for(var t=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<t.length-1;)e/=1024,n++;var r=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(r," ").concat(t[n])}const we=function(e){var t,n=(0,u.useState)([]),r=n[0],o=n[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,n){var r;h.current=be(be({},h.current),((r={})[e]=h.current[e]--,r)),function(e,t,n){s((function(t){return ye(ye([],t,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),o((function(e){return e.filter((function(e){return e.id!==t}))}))}(e,t,n)}var y=(0,i.jsx)(l(),{className:"rustic-files rustic-padding-16",children:r.map((function(t,n){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,n){var r,a;s([]);var i=t.name;if(h.current=be(be({},h.current),((r={})[i]=h.current[i]--,r)),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!==n}))}))})).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!==n}))})),h.current=be(be({},h.current),((a={})[i]=h.current[i]++,a))}(t,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,i.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)}))}),j=(0,i.jsx)(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 n=document.getElementById(v);n&&(n.accept=t.acceptedFileTypes||e.acceptedFileTypes),n.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 n=t.target.files&&Array.from(t.target.files),a=r.length+(n?n.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=n&&function(e,t,n){return n?t<=n?e:e.slice(0,n-t):e}(n,a,e.maxFileCount);i&&i.forEach((function(t){!function(t){var n;e.maxFileSize&&t.size>e.maxFileSize?(n=t.name,s((function(t){return ye(ye([],t,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&je(e.maxFileSize),".")],!1)}))):function(t){var n=new FormData,r=new AbortController,a=function(e){var t,n,r=e.name,o=h.current[r];if(o){var a=o+1,i=r.lastIndexOf("."),c=r.substring(0,i),l=r.substring(i);r="".concat(c,"(").concat(o,")").concat(l),h.current=be(be({},h.current),((t={})[e.name]=a,t))}else h.current=be(be({},h.current),((n={})[e.name]=1,n));return r}(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];n.append(e,"object"==typeof t?JSON.stringify(t):t)}))}n.append("file",i);var s=(0,d.v4)(),u={name:a,loadingProgress:0,abortController:r,id:s};function p(e){var t,n;e.total&&(t=e.loaded/e.total*100,n=u.id,o((function(e){var r=e.map((function(e){return e.id===n?be(be({},e),{loadingProgress:t}):e}));return r})))}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,n,be(be({},c),{onUploadProgress:p,signal:r.signal})).then((function(t){var r,a,i=n.get("file");t.data.url&&i instanceof File&&i.name&&e.onFileUpdate("update",i.name,t.data.url),t.data.fileId&&(r=t.data,a=u.id,o((function(e){var t=e.findIndex((function(e){return e.id===a}));if(-1!==t){var n=ye([],e,!0);return n[t]=be(be({},n[t]),{id:r.fileId}),n}return e})))})).catch((function(r){var c,l,d=n.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var p,f,m,h;409===(null===(c=r.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,n=0,r=e;n<r.length;n++){var o=r[n];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(r){e.onFileUpdate("add",r);var a=new File([t],r,{type:t.type});n.set("file",a),o((function(e){return e.map((function(e){return e.id===s?be(be({},e),{name:r,loadingProgress:0}):e}))})),i()})).catch((function(){var e;b(t.name,u.id,null===(e=r.response)||void 0===e?void 0:e.data)})):b(t.name,u.id,null===(l=r.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),r.length>0&&w(y,e.filePreviewsContainer)]})};var Se,Oe,Ce=function(){return Ce=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ce.apply(this,arguments)},Ne=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||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 ke=function(e){var t=e.maxFileSize,n=void 0===t?2097152:t,r=e.maxFileCount,o=void 0===r?1:r,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(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)(),C=p.fileList.length>0,N=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,Ce({},a,{send:function(e){e.data=function(e,t,n){var r=e.id,o=[];if(t&&(null==t?void 0:t.trim().length)&&o.push({type:"text",text:t}),n&&n.length>0)for(var a=0;a<(null==n?void 0:n.length);a++)o.push({type:"file_url",file_url:{url:n[a].url,name:n[a].name}});return{messages:[{content:o,role:"user",name:r}]}}(e.sender,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:C?N:void 0,ref:S,children:(0,i.jsx)(l(),{className:"rustic-bottom-buttons",children:(0,i.jsx)(we,{acceptedFileTypes:a.acceptedFileTypes,maxFileCount:o,maxFileSize:n,uploadFileEndpoint:a.uploadFileEndpoint,deleteFileEndpoint:a.deleteFileEndpoint,onFileUpdate:function(e,t,n){if("add"===e)f((function(e){return Ce(Ce({},e),{fileList:Ne(Ne([],e.fileList,!0),[{name:t}],!1)})}));else if("update"===e){if(!n)return void console.error("URL is required for the 'update' action");f((function(e){var r=e.fileList.findIndex((function(e){return e.name===t})),o=Ne(Ne(Ne([],e.uploaded.slice(0,r),!0),[{name:t,url:n}],!1),e.uploaded.slice(r),!0);return Ce(Ce({},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,n={9767:(e,t,n)=>{n.d(t,{A:()=>a});var r=n(8732),o=(n(2015),function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])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,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:o({},t),children:e.name})}},3110:(e,t,n)=>{n.d(t,{default:()=>r});const r=n(9767).A},8342:e=>{e.exports=require("emoji-picker-element")},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var a=r[e]={exports:{}};return n[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(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var a=Object.create(null);o.r(a);var i={};e=e||[null,t({}),t([]),t(t)];for(var c=2&r&&n;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach((e=>i[e]=()=>n[e]));return i.default=()=>n,o.d(a,i),a},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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,{MessageProcessStatus:()=>Se,ParticipantRole:()=>Oe,ParticipantType:()=>Ce,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 C=require("@mui/material/Popover");var N=o.n(C);const k=require("@mui/material/TextField");var F=o.n(k);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)(),n=(0,u.useRef)(null),r=(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(){r.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then((function(n){var o=new(0,n.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])})),r.current=o})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,u.useEffect)((function(){return r.current&&r.current.addEventListener("emoji-click",f),function(){var e;null===(e=r.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:n,onClick:function(){l((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,i.jsx)(A.A,{name:"Mood"})})}),r.current&&(0,i.jsx)(N(),{open:c,anchorEl:n.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&&r.current&&!e.contains(r.current)&&e.appendChild(r.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 M(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 U(e){var t=e.items,n=e.isOpen,r=e.onClose,o=e.onSelect,a=e.renderItem,c=e.anchorEl,l=e.selectedIndex;return(0,i.jsx)(N(),{disableAutoFocus:!0,open:n&&t.length>0,anchorEl:c,onClose:r,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 _=(0,u.forwardRef)((function(e,t){var n=e.multiline,r=void 0===n||n,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 n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["multiline","fullWidth","maxRows","enableSpeechToText","maximumEmojiSearchResults"]),b=(0,u.useState)(""),j=b[0],w=b[1],S=(0,u.useState)(!1),O=S[0],C=S[1],N=(0,u.useState)(!1),k=N[0],P=N[1],I=(0,u.useState)(!1),_=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}),ne=!j.trim().length,re="".concat(O?"Stop":"Start"," speech to text"),oe=k?"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],fe=f&&"undefined"!=typeof window&&!!window.webkitSpeechRecognition;function me(){return"boolean"==typeof g.isSendEnabled?!g.isSendEnabled:ne}function he(e,t){if(ee.current){var n=ee.current,r=n.selectionStart,o=n.selectionEnd;if("number"==typeof r&&"number"==typeof o){var a,i=j||"",c=i.substring(0,r),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=r+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 ve(e){he("@".concat(e," "),/@(\w*)$/),se([])}function ge(e,t){void 0===t&&(t=!1),he(e,t?/:(\w+)$/:void 0),Y(!1)}var xe=_?(0,i.jsx)(v(),{size:24}):(0,i.jsx)(E(),{title:re,children:(0,i.jsx)(x(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,O?(e.stop(),z(!0),C(!1)):(e.start(),$(""),C(!0)),e.onstart=function(){C(!0)},e.onresult=function(e){var t,n=e.results[0][0].transcript;j.length>0?w(j+" "+n):w(n),null===(t=ee.current)||void 0===t||t.focus(),C(!1)},e.onerror=function(e){var t=D[e.error];$(t),C(!1)},e.onend=function(){z(!1),C(!1)}},size:"small",sx:{color:ae,"&:hover":{color:"primary.main"}},children:(0,i.jsx)(A.A,{name:ie})})});function be(){var e,t,n=(new Date).toISOString(),r={id:(0,d.v4)(),timestamp:n,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(r),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:k?"secondary.main":"action.disabled",backgroundColor:"background.paper"},children:[K.length>0&&ee.current&&(0,i.jsx)(U,{anchorEl:ee.current,items:K.filter((function(e){return"unicode"in e})),isOpen:V,onClose:function(){Y(!1),X(0)},onSelect:function(e){return ge(e.unicode,!0)},selectedIndex:J,renderItem:L}),le.length>0&&ee.current&&(0,i.jsx)(U,{anchorEl:ee.current,items:le,isOpen:de,onClose:function(){pe(!1),X(0)},onSelect:function(e){return ve(e.displayName)},renderItem:M,selectedIndex:J}),(0,i.jsx)(F(),{className:"rustic-text-field",variant:"outlined",value:j,label:g.label,placeholder:g.placeholder,maxRows:s,multiline:r,fullWidth:a,onKeyDown:function(e){var t,n="ArrowDown"===e.key,r="ArrowUp"===e.key;if("Enter"===e.key||"Tab"===e.key)e.shiftKey||e.preventDefault(),V&&K.length>0&&"unicode"in K[J]?ge(K[J].unicode,!0):de&&le.length>0?ve(le[J].displayName):e.shiftKey||me()||be();else{if(n||r)return e.preventDefault(),t=n?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 n=t[1].toLowerCase();g.getMembers().then((function(e){var t=e.filter((function(e){return e.displayName.toLowerCase().startsWith(n)}));se(t),t.length>0?pe(!0):pe(!1)}))}else se([])}(t);var n,r=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(r){var a=r[0].replace(/:/g,"");te.getEmojiByShortcode(a).then((function(e){if(e&&"unicode"in e){var n=t.replace(r[0],e.unicode);w(n)}else w(t)})).catch((function(){w(t)})),Y(!1)}else o?(n=o[0].replace(":",""),te.getEmojiBySearchQuery(n).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:ge,buttonColor:oe}),fe&&xe]})},inputLabel:{className:k?"":"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:be,disabled:me(),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 ne=require("pdfjs-dist"),re=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"}},n=(t[e.action].label.replaceAll(" ","-").toLowerCase(),t[e.action]);return(0,i.jsx)(E(),{title:n.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:n.symbol})})})})};var oe={pdf:function(e){var t,n=(0,u.useRef)(null),r=(0,u.useState)(1),o=r[0],a=r[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})),C=O[0],N=O[1];function k(t){ne.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:C}),r=n.current;if(r){var o=r.getContext("2d");if(o){var a=window.devicePixelRatio||1;r.style.width="".concat(t.width,"px"),r.style.height="".concat(t.height,"px"),r.width=t.width*a,r.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(){ne.GlobalWorkerOptions.workerSrc||(ne.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(ne.version,"/pdf.worker.mjs")),e.getAuthHeaders?e.getAuthHeaders().then((function(e){return k(e.headers)})).catch((function(){return g(!0)})):k()}),[e.url,o,C]),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)(re,{action:"zoomOut",onClick:function(){N((function(e){return Math.max(e-.2,.2)}))}}),(0,i.jsx)(re,{action:"zoomIn",onClick:function(){N((function(e){return e+.2}))}})]}),(0,i.jsx)(l(),{className:"rustic-pdf-viewer-body",children:(0,i.jsx)(l(),{className:"rustic-pdf-viewer-body-inner",children:(0,i.jsx)("canvas",{ref:n})})}),(0,i.jsxs)(X(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,i.jsx)(re,{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)(F(),{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)(re,{action:"nextPage",onClick:function(){o<s&&(a(o+1),m(o+1))},isDisabled:o===s})]})]})}};function ae(e){var t=e.supportedViewers,n=void 0===t?oe:t,r=e.showFullName,o=void 0===r||r,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(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&&n?n[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,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])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),n=t[0],r=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 r(!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),r(!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(),r(!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:n,onClose:function(){return r(!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,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},be.apply(this,arguments)},ye=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};function je(e){for(var t=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<t.length-1;)e/=1024,n++;var r=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(r," ").concat(t[n])}const we=function(e){var t,n=(0,u.useState)([]),r=n[0],o=n[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,n){var r;h.current=be(be({},h.current),((r={})[e]=h.current[e]--,r)),function(e,t,n){s((function(t){return ye(ye([],t,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),o((function(e){return e.filter((function(e){return e.id!==t}))}))}(e,t,n)}var y=(0,i.jsx)(l(),{className:"rustic-files rustic-padding-16",children:r.map((function(t,n){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,n){var r,a;s([]);var i=t.name;if(h.current=be(be({},h.current),((r={})[i]=h.current[i]--,r)),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!==n}))}))})).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!==n}))})),h.current=be(be({},h.current),((a={})[i]=h.current[i]++,a))}(t,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,i.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)}))}),j=(0,i.jsx)(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 n=document.getElementById(v);n&&(n.accept=t.acceptedFileTypes||e.acceptedFileTypes),n.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 n=t.target.files&&Array.from(t.target.files),a=r.length+(n?n.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=n&&function(e,t,n){return n?t<=n?e:e.slice(0,n-t):e}(n,a,e.maxFileCount);i&&i.forEach((function(t){!function(t){var n;e.maxFileSize&&t.size>e.maxFileSize?(n=t.name,s((function(t){return ye(ye([],t,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&je(e.maxFileSize),".")],!1)}))):function(t){var n=new FormData,r=new AbortController,a=function(e){var t,n,r=e.name,o=h.current[r];if(o){var a=o+1,i=r.lastIndexOf("."),c=r.substring(0,i),l=r.substring(i);r="".concat(c,"(").concat(o,")").concat(l),h.current=be(be({},h.current),((t={})[e.name]=a,t))}else h.current=be(be({},h.current),((n={})[e.name]=1,n));return r}(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];n.append(e,"object"==typeof t?JSON.stringify(t):t)}))}n.append("file",i);var s=(0,d.v4)(),u={name:a,loadingProgress:0,abortController:r,id:s};function p(e){var t,n;e.total&&(t=e.loaded/e.total*100,n=u.id,o((function(e){var r=e.map((function(e){return e.id===n?be(be({},e),{loadingProgress:t}):e}));return r})))}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,n,be(be({},c),{onUploadProgress:p,signal:r.signal})).then((function(t){var r,a,i=n.get("file");t.data.url&&i instanceof File&&i.name&&e.onFileUpdate("update",i.name,t.data.url),t.data.fileId&&(r=t.data,a=u.id,o((function(e){var t=e.findIndex((function(e){return e.id===a}));if(-1!==t){var n=ye([],e,!0);return n[t]=be(be({},n[t]),{id:r.fileId}),n}return e})))})).catch((function(r){var c,l,d=n.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var p,f,m,h;409===(null===(c=r.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,n=0,r=e;n<r.length;n++){var o=r[n];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(r){e.onFileUpdate("add",r);var a=new File([t],r,{type:t.type});n.set("file",a),o((function(e){return e.map((function(e){return e.id===s?be(be({},e),{name:r,loadingProgress:0}):e}))})),i()})).catch((function(){var e;b(t.name,u.id,null===(e=r.response)||void 0===e?void 0:e.data)})):b(t.name,u.id,null===(l=r.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),r.length>0&&w(y,e.filePreviewsContainer)]})};var Se,Oe,Ce,Ne=function(){return Ne=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ne.apply(this,arguments)},ke=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(Se||(Se={})),function(e){e.Owner="owner",e.Member="member"}(Oe||(Oe={})),function(e){e.Human="human",e.Agent="agent"}(Ce||(Ce={}));const Fe=function(e){var t=e.maxFileSize,n=void 0===t?2097152:t,r=e.maxFileCount,o=void 0===r?1:r,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(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)(),C=p.fileList.length>0,N=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)(_,Ne({},a,{send:function(e){e.data=function(e,t,n){var r=e.id,o=[];if(t&&(null==t?void 0:t.trim().length)&&o.push({type:"text",text:t}),n&&n.length>0)for(var a=0;a<(null==n?void 0:n.length);a++)o.push({type:"file_url",file_url:{url:n[a].url,name:n[a].name}});return{messages:[{content:o,role:"user",name:r}]}}(e.sender,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:C?N:void 0,ref:S,children:(0,i.jsx)(l(),{className:"rustic-bottom-buttons",children:(0,i.jsx)(we,{acceptedFileTypes:a.acceptedFileTypes,maxFileCount:o,maxFileSize:n,uploadFileEndpoint:a.uploadFileEndpoint,deleteFileEndpoint:a.deleteFileEndpoint,onFileUpdate:function(e,t,n){if("add"===e)f((function(e){return Ne(Ne({},e),{fileList:ke(ke([],e.fileList,!0),[{name:t}],!1)})}));else if("update"===e){if(!n)return void console.error("URL is required for the 'update' action");f((function(e){var r=e.fileList.findIndex((function(e){return e.name===t})),o=ke(ke(ke([],e.uploaded.slice(0,r),!0),[{name:t,url:n}],!1),e.uploaded.slice(r),!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,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={9767:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(8732),a=(t(2015),function(){return a=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},a.apply(this,arguments)});function o(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:a({},r),children:e.name})}},3110:(e,r,t)=>{t.d(r,{default:()=>n});const n=t(9767).A},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},r={};function t(n){var a=r[n];if(void 0!==a)return a.exports;var o=r[n]={exports:{}};return e[n](o,o.exports,t),o.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 n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},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 n={};t.r(n),t.d(n,{ParticipantRole:()=>ne,ParticipantType:()=>ae,default:()=>oe});var a=t(8732);const o=require("@mui/material/Box");var i=t.n(o);const l=require("@mui/material/IconButton");var c=t.n(l);const s=require("@mui/material/LinearProgress");var u=t.n(s);const d=require("@mui/material/Tooltip");var m=t.n(d);const p=require("@mui/material/Typography");var f=t.n(p);const v=require("axios");var h=t.n(v),x=t(2015);const g=require("react-dom"),b=require("uuid"),j=require("@mui/material/Card");var y=t.n(j);const w=require("@mui/material/Modal");var F=t.n(w);const N=require("@mui/material/styles");var P;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(P||(P={}));var C=t(9767);const O=require("@mui/material/TextField");var k=t.n(O);const S=require("@mui/material/useMediaQuery");var q=t.n(S);const I=require("@mui/system/Stack");var A=t.n(I);const T=require("@mui/system/useTheme");var D=t.n(T);const U=require("pdfjs-dist"),M=function(e){var r={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},t=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,a.jsx)(m(),{title:t.label,children:(0,a.jsx)("span",{children:(0,a.jsx)(c(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,a.jsx)(C.A,{name:t.symbol})})})})};var R={pdf:function(e){var r,t=(0,x.useRef)(null),n=(0,x.useState)(1),o=n[0],l=n[1],c=(0,x.useState)(1),s=c[0],u=c[1],d=(0,x.useState)(1),m=d[0],p=d[1],v=(0,x.useState)(!1),h=v[0],g=v[1],b=(0,x.useState)(),j=b[0],w=b[1],F=D()(),N=q()(F.breakpoints.down("sm")),P=q()(F.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,a.jsx)(y(),{variant:"outlined",className:"rustic-pdf-error",children:(0,a.jsx)(f(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var C=(0,x.useState)((function(){return N?.5:P?1:1.5})),O=C[0],S=C[1];function I(r){U.getDocument({url:e.url,httpHeaders:r}).promise.then((function(e){u(e.numPages),function(e){e.getPage(o).then((function(e){var r=e.getViewport({scale:O}),n=t.current;if(n){var a=n.getContext("2d");if(a){var o=window.devicePixelRatio||1;n.style.width="".concat(r.width,"px"),n.style.height="".concat(r.height,"px"),n.width=r.width*o,n.height=r.height*o;var i={canvasContext:a,viewport:r,transform:[o,0,0,o,0,0]};j&&j.cancel();var l=e.render(i);w(l),l.promise.then((function(){w(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}return(0,x.useEffect)((function(){U.GlobalWorkerOptions.workerSrc||(U.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(U.version,"/pdf.worker.mjs")),e.getAuthHeaders?e.getAuthHeaders().then((function(e){return I(e.headers)})).catch((function(){return g(!0)})):I()}),[e.url,o,O]),h?(0,a.jsx)(y(),{variant:"outlined",className:"rustic-pdf-error",children:(0,a.jsx)(f(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,a.jsxs)(y(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,a.jsxs)(i(),{className:"rustic-pdf-viewer-header",children:[(0,a.jsx)(M,{action:"zoomOut",onClick:function(){S((function(e){return Math.max(e-.2,.2)}))}}),(0,a.jsx)(M,{action:"zoomIn",onClick:function(){S((function(e){return e+.2}))}})]}),(0,a.jsx)(i(),{className:"rustic-pdf-viewer-body",children:(0,a.jsx)(i(),{className:"rustic-pdf-viewer-body-inner",children:(0,a.jsx)("canvas",{ref:t})})}),(0,a.jsxs)(A(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,a.jsx)(M,{action:"previousPage",onClick:function(){o>1&&(l(o-1),p(o-1))},isDisabled:1===o}),(0,a.jsx)(f(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,a.jsx)(k(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=s&&l(r)},size:"small",className:"rustic-pdf-page-input"}),(0,a.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,a.jsx)(M,{action:"nextPage",onClick:function(){o<s&&(l(o+1),p(o+1))},isDisabled:o===s})]})]})}};function _(e){var r=e.supportedViewers,t=void 0===r?R:r,n=e.showFullName,o=void 0===n||n,i=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(t[n[a]]=e[n[a]])}return t}(e,["supportedViewers","showFullName"]),l=(0,N.useTheme)(),s=(0,x.useState)(!1),u=s[0],d=s[1];function p(){d(!1)}var v,h,g=i.file.url&&(v=i.file.url.split("."))[v.length-1].toLowerCase(),b=g&&t?t[g]:null,j=!!b,w=j?" rustic-cursor-pointer":"",P="rustic-file-preview ".concat(o?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width").concat(w),O=o?i.file.name:(h=i.file.name).length<=15?h:h.substring(0,12)+"...";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(y(),{className:P,variant:"outlined",sx:{boxShadow:l.shadows[1]},onClick:function(){d(!0)},children:[(0,a.jsx)(f(),{variant:"subtitle2",className:"rustic-file-preview-name",children:O}),(0,a.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:i.children})]}),j&&(0,a.jsx)(F(),{open:u,onClose:p,className:"rustic-file-preview-modal",children:(0,a.jsxs)("div",{className:"rustic-modal-content",children:[(0,a.jsx)(m(),{title:"Close",children:(0,a.jsx)(c(),{onClick:p,className:"rustic-close-button",children:(0,a.jsx)(C.A,{name:"close"})})}),i.file.url&&(0,a.jsx)(b,{url:i.file.url,getAuthHeaders:i.getAuthHeaders})]})})]})}var z=t(3110);const E=require("@mui/material"),H=require("@mui/material/Button");var B=t.n(H);const L=require("@mui/material/Drawer");var $=t.n(L);const G=require("@mui/material/ListItemText");var V=t.n(G);const Q=require("@mui/material/Menu");var W=t.n(Q);const Y=require("@mui/material/MenuItem");var Z=t.n(Y);const J=require("@mui/system");var K=function(){return K=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},K.apply(this,arguments)};function X(e){var r=(0,x.useState)(!1),t=r[0],n=r[1],o=(0,x.useRef)(null),i=(0,N.useTheme)(),l=(0,E.useMediaQuery)(i.breakpoints.down("md")),s=l?$():W(),u={borderRadius:"".concat(i.shape.borderRadius,"px"),border:"1px solid ".concat(i.palette.divider)};function d(e){return(0,a.jsxs)(a.Fragment,{children:[e.startDecorator&&(0,a.jsx)(J.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,a.jsx)(V(),{children:(0,a.jsx)(f(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,a.jsx)(J.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}l&&(u=K(K({},u),{borderRadius:"".concat(i.shape.borderRadius,"px ").concat(i.shape.borderRadius,"px 0 0"),borderBottom:0}));var p=e.menuItems.map((function(e){return e.href?(0,a.jsx)(Z(),{component:"a",onClick:function(){return n(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:d(e)},e.label):(0,a.jsx)(Z(),{onClick:function(r){e.onClick&&e.onClick(r),n(!1)},disabled:!e.onClick,children:d(e)},e.label)}));var v,h,g=l?{}:{anchorEl:o.current};return(0,a.jsxs)(a.Fragment,{children:[(v={onClick:function(e){e.stopPropagation(),n(!0)},"aria-label":e.ariaLabel,ref:o,className:"rustic-popover-menu-button"},h=(0,a.jsx)(C.A,{name:"more_vert"}),e.buttonText?(0,a.jsx)(B(),K({},v,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,a.jsx)(m(),{title:e.ariaLabel,children:(0,a.jsx)(c(),K({},v,{children:e.icon?e.icon:h}))})),(0,a.jsx)(s,K({open:t,onClose:function(){return n(!1)}},g,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":K(K({},u),{backgroundImage:"none",boxShadow:i.shadows[2]})},children:p}))]})}var ee=function(){return ee=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},ee.apply(this,arguments)},re=function(e,r,t){if(t||2===arguments.length)for(var n,a=0,o=r.length;a<o;a++)!n&&a in r||(n||(n=Array.prototype.slice.call(r,0,a)),n[a]=r[a]);return e.concat(n||Array.prototype.slice.call(r))};function te(e){for(var r=["Bytes","KB","MB","GB"],t=0;e>=1024&&t<r.length-1;)e/=1024,t++;var n=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(n," ").concat(r[t])}var ne,ae;!function(e){e.Owner="owner",e.Member="member"}(ne||(ne={})),function(e){e.Human="human",e.Agent="agent"}(ae||(ae={}));const oe=function(e){var r,t=(0,x.useState)([]),n=t[0],o=t[1],l=(0,x.useState)([]),s=l[0],d=l[1],p=(0,x.useState)({}),v=p[0],j=p[1],y=(0,x.useRef)({}),w=(0,b.v4)();(0,x.useEffect)((function(){o([]),d([]),y.current={}}),[e.messageId]);var F=e.getUploadHeaders?e.getUploadHeaders():Promise.resolve({headers:{}});function N(e,r,t){var n;y.current=ee(ee({},y.current),((n={})[e]=y.current[e]--,n)),function(e,r,t){d((function(r){return re(re([],r,!0),["Failed to upload ".concat(e,". ").concat((null==t?void 0:t.message)||"")],!1)})),o((function(e){return e.filter((function(e){return e.id!==r}))}))}(e,r,t)}var P=(0,a.jsx)(i(),{className:"rustic-files rustic-padding-16",children:n.map((function(r,t){return(0,a.jsx)(_,{file:{name:r.name},showFullName:e.showFullName,children:(0,a.jsxs)(i(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,a.jsx)(u(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,a.jsx)(m(),{title:"Delete",children:(0,a.jsx)(c(),{color:"primary",onClick:function(){return function(r,t){var n,a;d([]);var i=r.name;if(y.current=ee(ee({},y.current),((n={})[i]=y.current[i]--,n)),e.onFileUpdate("remove",i),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);F.then((function(r){h().delete(l,ee({},r)).then((function(){return o((function(e){return e.filter((function(e,r){return r!==t}))}))})).catch((function(){return e.onFileUpdate("add",i),d((function(e){return re(re([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)}))}))}))}else r.abortController.abort(),o((function(e){return e.filter((function(e,r){return r!==t}))})),y.current=ee(ee({},y.current),((a={})[i]=y.current[i]++,a))}(r,t)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,a.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},t)}))}),C=(0,a.jsx)(i(),{children:s.map((function(e,r){return(0,a.jsx)(f(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function O(e,r){return r?(0,g.createPortal)(e,r):e}var k=null===(r=e.uploadOptions)||void 0===r?void 0:r.map((function(r){return{label:r.label,onClick:function(){return function(r){j(r.metadata);var t=document.getElementById(w);t&&(t.accept=r.acceptedFileTypes||e.acceptedFileTypes),t.click()}(r)},startDecorator:r.iconName&&(0,a.jsx)(z.default,{name:r.iconName})}}));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i(),{className:"rustic-uploader",children:[(0,a.jsx)("label",{htmlFor:w,children:(null==k?void 0:k.length)?(0,a.jsx)(X,{ariaLabel:"Upload",icon:(0,a.jsx)(z.default,{name:"upload_2"}),menuItems:k}):(0,a.jsx)(m(),{title:"Upload",children:(0,a.jsx)(c(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,a.jsx)("input",{type:"file",id:w,onChange:function(r){d([]);var t=r.target.files&&Array.from(r.target.files),a=n.length+(t?t.length:0);e.maxFileCount&&a>e.maxFileCount&&d((function(r){return re(re([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var i=t&&function(e,r,t){return t?r<=t?e:e.slice(0,t-r):e}(t,a,e.maxFileCount);i&&i.forEach((function(r){!function(r){var t;e.maxFileSize&&r.size>e.maxFileSize?(t=r.name,d((function(r){return re(re([],r,!0),["Failed to upload ".concat(t,". You cannot upload files larger than ").concat(e.maxFileSize&&te(e.maxFileSize),".")],!1)}))):function(r){var t=new FormData,n=new AbortController,a=function(e){var r,t,n=e.name,a=y.current[n];if(a){var o=a+1,i=n.lastIndexOf("."),l=n.substring(0,i),c=n.substring(i);n="".concat(l,"(").concat(a,")").concat(c),y.current=ee(ee({},y.current),((r={})[e.name]=o,r))}else y.current=ee(ee({},y.current),((t={})[e.name]=1,t));return n}(r),i=new File([r],a,{type:r.type});if(e.getUploadData||v){var l=e.getUploadData?e.getUploadData(a):{},c=ee(ee({},l),v);Object.keys(c).forEach((function(e){var r=c[e];t.append(e,"object"==typeof r?JSON.stringify(r):r)}))}t.append("file",i);var s=(0,b.v4)(),u={name:a,loadingProgress:0,abortController:n,id:s};function d(e){var r,t;e.total&&(r=e.loaded/e.total*100,t=u.id,o((function(e){var n=e.map((function(e){return e.id===t?ee(ee({},e),{loadingProgress:r}):e}));return n})))}o((function(e){return re(re([],e,!0),[u],!1)})),e.onFileUpdate("add",a);var m="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);!function i(){return F.then((function(l){return h().post(m,t,ee(ee({},l),{onUploadProgress:d,signal:n.signal})).then((function(r){var n,a,i=t.get("file");r.data.url&&i instanceof File&&i.name&&e.onFileUpdate("update",i.name,r.data.url),r.data.fileId&&(n=r.data,a=u.id,o((function(e){var r=e.findIndex((function(e){return e.id===a}));if(-1!==r){var t=re([],e,!0);return t[r]=ee(ee({},t[r]),{id:n.fileId}),t}return e})))})).catch((function(n){var l,c,d=t.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var m,p,f,v;409===(null===(l=n.response)||void 0===l?void 0:l.status)&&e.listFiles?(m=a.lastIndexOf("."),p=a.substring(0,m),f=a.substring(m),v=new RegExp("^".concat(p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"(\\(\\d+\\))?").concat(f,"$"),"i"),e.listFiles?e.listFiles().then((function(e){for(var r=0,t=0,n=e;t<n.length;t++){var a=n[t];if(v.test(a.name)){var o=a.name.match(v),i=o&&o[1]?parseInt(o[1].slice(1,-1),10):0;r=Math.max(r,i)}}return"".concat(p,"(").concat(r+1,")").concat(f)})):Promise.resolve(a)).then((function(n){e.onFileUpdate("add",n);var a=new File([r],n,{type:r.type});t.set("file",a),o((function(e){return e.map((function(e){return e.id===s?ee(ee({},e),{name:n,loadingProgress:0}):e}))})),i()})).catch((function(){var e;N(r.name,u.id,null===(e=n.response)||void 0===e?void 0:e.data)})):N(r.name,u.id,null===(c=n.response)||void 0===c?void 0:c.data)}))}))}()}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),s.length>0&&O(C,e.errorMessagesContainer),n.length>0&&O(P,e.filePreviewsContainer)]})};return n})()));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={9767:(e,r,n)=>{n.d(r,{A:()=>o});var t=n(8732),a=(n(2015),function(){return a=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},a.apply(this,arguments)});function o(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:a({},r),children:e.name})}},3110:(e,r,n)=>{n.d(r,{default:()=>t});const t=n(9767).A},2015:e=>{e.exports=require("react")},8732:e=>{e.exports=require("react/jsx-runtime")}},r={};function n(t){var a=r[t];if(void 0!==a)return a.exports;var o=r[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};n.r(t),n.d(t,{MessageProcessStatus:()=>te,ParticipantRole:()=>ae,ParticipantType:()=>oe,default:()=>ie});var a=n(8732);const o=require("@mui/material/Box");var i=n.n(o);const l=require("@mui/material/IconButton");var c=n.n(l);const s=require("@mui/material/LinearProgress");var u=n.n(s);const d=require("@mui/material/Tooltip");var m=n.n(d);const p=require("@mui/material/Typography");var f=n.n(p);const v=require("axios");var h=n.n(v),x=n(2015);const g=require("react-dom"),b=require("uuid"),j=require("@mui/material/Card");var y=n.n(j);const w=require("@mui/material/Modal");var F=n.n(w);const N=require("@mui/material/styles");var P;!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(P||(P={}));var C=n(9767);const O=require("@mui/material/TextField");var k=n.n(O);const S=require("@mui/material/useMediaQuery");var q=n.n(S);const I=require("@mui/system/Stack");var A=n.n(I);const T=require("@mui/system/useTheme");var D=n.n(T);const U=require("pdfjs-dist"),M=function(e){var r={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},n=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,a.jsx)(m(),{title:n.label,children:(0,a.jsx)("span",{children:(0,a.jsx)(c(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,a.jsx)(C.A,{name:n.symbol})})})})};var R={pdf:function(e){var r,n=(0,x.useRef)(null),t=(0,x.useState)(1),o=t[0],l=t[1],c=(0,x.useState)(1),s=c[0],u=c[1],d=(0,x.useState)(1),m=d[0],p=d[1],v=(0,x.useState)(!1),h=v[0],g=v[1],b=(0,x.useState)(),j=b[0],w=b[1],F=D()(),N=q()(F.breakpoints.down("sm")),P=q()(F.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,a.jsx)(y(),{variant:"outlined",className:"rustic-pdf-error",children:(0,a.jsx)(f(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var C=(0,x.useState)((function(){return N?.5:P?1:1.5})),O=C[0],S=C[1];function I(r){U.getDocument({url:e.url,httpHeaders:r}).promise.then((function(e){u(e.numPages),function(e){e.getPage(o).then((function(e){var r=e.getViewport({scale:O}),t=n.current;if(t){var a=t.getContext("2d");if(a){var o=window.devicePixelRatio||1;t.style.width="".concat(r.width,"px"),t.style.height="".concat(r.height,"px"),t.width=r.width*o,t.height=r.height*o;var i={canvasContext:a,viewport:r,transform:[o,0,0,o,0,0]};j&&j.cancel();var l=e.render(i);w(l),l.promise.then((function(){w(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}return(0,x.useEffect)((function(){U.GlobalWorkerOptions.workerSrc||(U.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(U.version,"/pdf.worker.mjs")),e.getAuthHeaders?e.getAuthHeaders().then((function(e){return I(e.headers)})).catch((function(){return g(!0)})):I()}),[e.url,o,O]),h?(0,a.jsx)(y(),{variant:"outlined",className:"rustic-pdf-error",children:(0,a.jsx)(f(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,a.jsxs)(y(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,a.jsxs)(i(),{className:"rustic-pdf-viewer-header",children:[(0,a.jsx)(M,{action:"zoomOut",onClick:function(){S((function(e){return Math.max(e-.2,.2)}))}}),(0,a.jsx)(M,{action:"zoomIn",onClick:function(){S((function(e){return e+.2}))}})]}),(0,a.jsx)(i(),{className:"rustic-pdf-viewer-body",children:(0,a.jsx)(i(),{className:"rustic-pdf-viewer-body-inner",children:(0,a.jsx)("canvas",{ref:n})})}),(0,a.jsxs)(A(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,a.jsx)(M,{action:"previousPage",onClick:function(){o>1&&(l(o-1),p(o-1))},isDisabled:1===o}),(0,a.jsx)(f(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,a.jsx)(k(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=s&&l(r)},size:"small",className:"rustic-pdf-page-input"}),(0,a.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",s]}),(0,a.jsx)(M,{action:"nextPage",onClick:function(){o<s&&(l(o+1),p(o+1))},isDisabled:o===s})]})]})}};function _(e){var r=e.supportedViewers,n=void 0===r?R:r,t=e.showFullName,o=void 0===t||t,i=function(e,r){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)r.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(n[t[a]]=e[t[a]])}return n}(e,["supportedViewers","showFullName"]),l=(0,N.useTheme)(),s=(0,x.useState)(!1),u=s[0],d=s[1];function p(){d(!1)}var v,h,g=i.file.url&&(v=i.file.url.split("."))[v.length-1].toLowerCase(),b=g&&n?n[g]:null,j=!!b,w=j?" rustic-cursor-pointer":"",P="rustic-file-preview ".concat(o?"rustic-flexible-file-preview-width":"rustic-fixed-file-preview-width").concat(w),O=o?i.file.name:(h=i.file.name).length<=15?h:h.substring(0,12)+"...";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(y(),{className:P,variant:"outlined",sx:{boxShadow:l.shadows[1]},onClick:function(){d(!0)},children:[(0,a.jsx)(f(),{variant:"subtitle2",className:"rustic-file-preview-name",children:O}),(0,a.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:i.children})]}),j&&(0,a.jsx)(F(),{open:u,onClose:p,className:"rustic-file-preview-modal",children:(0,a.jsxs)("div",{className:"rustic-modal-content",children:[(0,a.jsx)(m(),{title:"Close",children:(0,a.jsx)(c(),{onClick:p,className:"rustic-close-button",children:(0,a.jsx)(C.A,{name:"close"})})}),i.file.url&&(0,a.jsx)(b,{url:i.file.url,getAuthHeaders:i.getAuthHeaders})]})})]})}var E=n(3110);const z=require("@mui/material"),H=require("@mui/material/Button");var B=n.n(H);const L=require("@mui/material/Drawer");var $=n.n(L);const G=require("@mui/material/ListItemText");var V=n.n(G);const Q=require("@mui/material/Menu");var W=n.n(Q);const Y=require("@mui/material/MenuItem");var Z=n.n(Y);const J=require("@mui/system");var K=function(){return K=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},K.apply(this,arguments)};function X(e){var r=(0,x.useState)(!1),n=r[0],t=r[1],o=(0,x.useRef)(null),i=(0,N.useTheme)(),l=(0,z.useMediaQuery)(i.breakpoints.down("md")),s=l?$():W(),u={borderRadius:"".concat(i.shape.borderRadius,"px"),border:"1px solid ".concat(i.palette.divider)};function d(e){return(0,a.jsxs)(a.Fragment,{children:[e.startDecorator&&(0,a.jsx)(J.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:e.startDecorator}),(0,a.jsx)(V(),{children:(0,a.jsx)(f(),{variant:"body2",children:e.label})}),e.endDecorator&&(0,a.jsx)(J.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:e.endDecorator})]})}l&&(u=K(K({},u),{borderRadius:"".concat(i.shape.borderRadius,"px ").concat(i.shape.borderRadius,"px 0 0"),borderBottom:0}));var p=e.menuItems.map((function(e){return e.href?(0,a.jsx)(Z(),{component:"a",onClick:function(){return t(!1)},href:e.href,download:e.downloadFileName||e.isFiledownload,children:d(e)},e.label):(0,a.jsx)(Z(),{onClick:function(r){e.onClick&&e.onClick(r),t(!1)},disabled:!e.onClick,children:d(e)},e.label)}));var v,h,g=l?{}:{anchorEl:o.current};return(0,a.jsxs)(a.Fragment,{children:[(v={onClick:function(e){e.stopPropagation(),t(!0)},"aria-label":e.ariaLabel,ref:o,className:"rustic-popover-menu-button"},h=(0,a.jsx)(C.A,{name:"more_vert"}),e.buttonText?(0,a.jsx)(B(),K({},v,{startIcon:e.icon?e.icon:null,children:e.buttonText})):(0,a.jsx)(m(),{title:e.ariaLabel,children:(0,a.jsx)(c(),K({},v,{children:e.icon?e.icon:h}))})),(0,a.jsx)(s,K({open:n,onClose:function(){return t(!1)}},g,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":K(K({},u),{backgroundImage:"none",boxShadow:i.shadows[2]})},children:p}))]})}var ee=function(){return ee=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},ee.apply(this,arguments)},re=function(e,r,n){if(n||2===arguments.length)for(var t,a=0,o=r.length;a<o;a++)!t&&a in r||(t||(t=Array.prototype.slice.call(r,0,a)),t[a]=r[a]);return e.concat(t||Array.prototype.slice.call(r))};function ne(e){for(var r=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<r.length-1;)e/=1024,n++;var t=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(t," ").concat(r[n])}var te,ae,oe;!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(te||(te={})),function(e){e.Owner="owner",e.Member="member"}(ae||(ae={})),function(e){e.Human="human",e.Agent="agent"}(oe||(oe={}));const ie=function(e){var r,n=(0,x.useState)([]),t=n[0],o=n[1],l=(0,x.useState)([]),s=l[0],d=l[1],p=(0,x.useState)({}),v=p[0],j=p[1],y=(0,x.useRef)({}),w=(0,b.v4)();(0,x.useEffect)((function(){o([]),d([]),y.current={}}),[e.messageId]);var F=e.getUploadHeaders?e.getUploadHeaders():Promise.resolve({headers:{}});function N(e,r,n){var t;y.current=ee(ee({},y.current),((t={})[e]=y.current[e]--,t)),function(e,r,n){d((function(r){return re(re([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),o((function(e){return e.filter((function(e){return e.id!==r}))}))}(e,r,n)}var P=(0,a.jsx)(i(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,n){return(0,a.jsx)(_,{file:{name:r.name},showFullName:e.showFullName,children:(0,a.jsxs)(i(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,a.jsx)(u(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,a.jsx)(m(),{title:"Delete",children:(0,a.jsx)(c(),{color:"primary",onClick:function(){return function(r,n){var t,a;d([]);var i=r.name;if(y.current=ee(ee({},y.current),((t={})[i]=y.current[i]--,t)),e.onFileUpdate("remove",i),100===r.loadingProgress){var l="".concat(e.deleteFileEndpoint).replaceAll("fileName",i).replaceAll("messageId",e.messageId).replaceAll("fileId",r.id);F.then((function(r){h().delete(l,ee({},r)).then((function(){return o((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return e.onFileUpdate("add",i),d((function(e){return re(re([],e,!0),["Failed to delete ".concat(i,". Please try again.")],!1)}))}))}))}else r.abortController.abort(),o((function(e){return e.filter((function(e,r){return r!==n}))})),y.current=ee(ee({},y.current),((a={})[i]=y.current[i]++,a))}(r,n)},className:"rustic-delete-button rustic-shift-to-right-by-8","aria-label":"cancel file upload",children:(0,a.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)}))}),C=(0,a.jsx)(i(),{children:s.map((function(e,r){return(0,a.jsx)(f(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function O(e,r){return r?(0,g.createPortal)(e,r):e}var k=null===(r=e.uploadOptions)||void 0===r?void 0:r.map((function(r){return{label:r.label,onClick:function(){return function(r){j(r.metadata);var n=document.getElementById(w);n&&(n.accept=r.acceptedFileTypes||e.acceptedFileTypes),n.click()}(r)},startDecorator:r.iconName&&(0,a.jsx)(E.default,{name:r.iconName})}}));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i(),{className:"rustic-uploader",children:[(0,a.jsx)("label",{htmlFor:w,children:(null==k?void 0:k.length)?(0,a.jsx)(X,{ariaLabel:"Upload",icon:(0,a.jsx)(E.default,{name:"upload_2"}),menuItems:k}):(0,a.jsx)(m(),{title:"Upload",children:(0,a.jsx)(c(),{component:"span","aria-label":"Upload file",sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,a.jsx)("input",{type:"file",id:w,onChange:function(r){d([]);var n=r.target.files&&Array.from(r.target.files),a=t.length+(n?n.length:0);e.maxFileCount&&a>e.maxFileCount&&d((function(r){return re(re([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var i=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,a,e.maxFileCount);i&&i.forEach((function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,d((function(r){return re(re([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&ne(e.maxFileSize),".")],!1)}))):function(r){var n=new FormData,t=new AbortController,a=function(e){var r,n,t=e.name,a=y.current[t];if(a){var o=a+1,i=t.lastIndexOf("."),l=t.substring(0,i),c=t.substring(i);t="".concat(l,"(").concat(a,")").concat(c),y.current=ee(ee({},y.current),((r={})[e.name]=o,r))}else y.current=ee(ee({},y.current),((n={})[e.name]=1,n));return t}(r),i=new File([r],a,{type:r.type});if(e.getUploadData||v){var l=e.getUploadData?e.getUploadData(a):{},c=ee(ee({},l),v);Object.keys(c).forEach((function(e){var r=c[e];n.append(e,"object"==typeof r?JSON.stringify(r):r)}))}n.append("file",i);var s=(0,b.v4)(),u={name:a,loadingProgress:0,abortController:t,id:s};function d(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=u.id,o((function(e){var t=e.map((function(e){return e.id===n?ee(ee({},e),{loadingProgress:r}):e}));return t})))}o((function(e){return re(re([],e,!0),[u],!1)})),e.onFileUpdate("add",a);var m="".concat(e.uploadFileEndpoint).replaceAll("fileName",a).replaceAll("messageId",e.messageId);!function i(){return F.then((function(l){return h().post(m,n,ee(ee({},l),{onUploadProgress:d,signal:t.signal})).then((function(r){var t,a,i=n.get("file");r.data.url&&i instanceof File&&i.name&&e.onFileUpdate("update",i.name,r.data.url),r.data.fileId&&(t=r.data,a=u.id,o((function(e){var r=e.findIndex((function(e){return e.id===a}));if(-1!==r){var n=re([],e,!0);return n[r]=ee(ee({},n[r]),{id:t.fileId}),n}return e})))})).catch((function(t){var l,c,d=n.get("file");d instanceof File&&d.name&&e.onFileUpdate("remove",d.name);var m,p,f,v;409===(null===(l=t.response)||void 0===l?void 0:l.status)&&e.listFiles?(m=a.lastIndexOf("."),p=a.substring(0,m),f=a.substring(m),v=new RegExp("^".concat(p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"(\\(\\d+\\))?").concat(f,"$"),"i"),e.listFiles?e.listFiles().then((function(e){for(var r=0,n=0,t=e;n<t.length;n++){var a=t[n];if(v.test(a.name)){var o=a.name.match(v),i=o&&o[1]?parseInt(o[1].slice(1,-1),10):0;r=Math.max(r,i)}}return"".concat(p,"(").concat(r+1,")").concat(f)})):Promise.resolve(a)).then((function(t){e.onFileUpdate("add",t);var a=new File([r],t,{type:r.type});n.set("file",a),o((function(e){return e.map((function(e){return e.id===s?ee(ee({},e),{name:t,loadingProgress:0}):e}))})),i()})).catch((function(){var e;N(r.name,u.id,null===(e=t.response)||void 0===e?void 0:e.data)})):N(r.name,u.id,null===(c=t.response)||void 0===c?void 0:c.data)}))}))}()}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),s.length>0&&O(C,e.errorMessagesContainer),t.length>0&&O(P,e.filePreviewsContainer)]})};return t})()));
@@ -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,n={8342:e=>{e.exports=require("emoji-picker-element")}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[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(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var i=Object.create(null);o.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&r&&n;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>n[e]));return a.default=()=>n,o.d(i,a),i},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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 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 g=require("@mui/material/InputAdornment");var y=o.n(g);const b=require("@mui/material/MenuItem");var j=o.n(b);const x=require("@mui/material/MenuList");var w=o.n(x);const O=require("@mui/material/Popover");var S=o.n(O);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,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])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)(),n=(0,c.useRef)(null),r=(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(){r.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then((function(n){var o=new(0,n.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])})),r.current=o})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,c.useEffect)((function(){return r.current&&r.current.addEventListener("emoji-click",p),function(){var e;null===(e=r.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:n,onClick:function(){u((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)(I,{name:"Mood"})})}),r.current&&(0,a.jsx)(S(),{open:s,anchorEl:n.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&&r.current&&!e.contains(r.current)&&e.appendChild(r.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)(l(),{src:e.icon,className:"rustic-participant-avatar"}),(0,a.jsx)(T(),{variant:"body1Bold",children:e.displayName})]})}function L(e){var t=e.items,n=e.isOpen,r=e.onClose,o=e.onSelect,i=e.renderItem,c=e.anchorEl,s=e.selectedIndex;return(0,a.jsx)(S(),{disableAutoFocus:!0,open:n&&t.length>0,anchorEl:c,onClose:r,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},className:"rustic-suggestion-menu",children:(0,a.jsx)(w(),{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 n=e.multiline,r=void 0===n||n,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,g=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["multiline","fullWidth","maxRows","enableSpeechToText","maximumEmojiSearchResults"]),b=(0,c.useState)(""),j=b[0],x=b[1],w=(0,c.useState)(!1),O=w[0],S=w[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:g.emojiDataSource}),ne=!j.trim().length,re="".concat(O?"Stop":"Start"," speech to text"),oe=C?"primary.main":"primary.light",ie=O?"error.main":oe,ae=O?"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],me=d&&"undefined"!=typeof window&&!!window.webkitSpeechRecognition;function fe(){return"boolean"==typeof g.isSendEnabled?!g.isSendEnabled:ne}function he(e,t){if(ee.current){var n=ee.current,r=n.selectionStart,o=n.selectionEnd;if("number"==typeof r&&"number"==typeof o){var i,a=j||"",c=a.substring(0,r),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=r+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 ve(e){he("@".concat(e," "),/@(\w*)$/),ue([])}function ge(e,t){void 0===t&&(t=!1),he(e,t?/:(\w+)$/:void 0),V(!1)}var ye=M?(0,a.jsx)(f(),{size:24}):(0,a.jsx)(N(),{title:re,children:(0,a.jsx)(v(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,O?(e.stop(),B(!0),S(!1)):(e.start(),K(""),S(!0)),e.onstart=function(){S(!0)},e.onresult=function(e){var t,n=e.results[0][0].transcript;j.length>0?x(j+" "+n):x(n),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 be(){var e,t,n=(new Date).toISOString(),r={id:(0,R.v4)(),timestamp:n,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(r),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",backgroundColor:"background.paper"},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 ge(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 ve(e.displayName)},renderItem:H,selectedIndex:Y}),(0,a.jsx)(E(),{className:"rustic-text-field",variant:"outlined",value:j,label:g.label,placeholder:g.placeholder,maxRows:u,multiline:r,fullWidth:i,onKeyDown:function(e){var t,n="ArrowDown"===e.key,r="ArrowUp"===e.key;if("Enter"===e.key||"Tab"===e.key)e.shiftKey||e.preventDefault(),J&&$.length>0&&"unicode"in $[Y]?ge($[Y].unicode,!0):de&&se.length>0?ve(se[Y].displayName):e.shiftKey||fe()||be();else{if(n||r)return e.preventDefault(),t=n?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&&g.getMembers){var n=t[1].toLowerCase();g.getMembers().then((function(e){var t=e.filter((function(e){return e.displayName.toLowerCase().startsWith(n)}));ue(t),t.length>0?pe(!0):pe(!1)}))}else ue([])}(t);var n,r=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(r){var i=r[0].replace(/:/g,"");te.getEmojiByShortcode(i).then((function(e){if(e&&"unicode"in e){var n=t.replace(r[0],e.unicode);x(n)}else x(t)})).catch((function(){x(t)})),V(!1)}else o?(n=o[0].replace(":",""),te.getEmojiBySearchQuery(n).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)(y(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(A,{dataSource:g.emojiDataSource,onEmojiClick:ge,buttonColor:oe}),me&&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:[g.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:be,disabled:fe(),color:"secondary",children:(0,a.jsx)(I,{name:"send"})})})})]})]})}));var F,W,K=function(){return K=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])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,n=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["ws"]);return(0,a.jsx)(B,K({},n,{send:function(e){var n,r,o,i;e.data=(n=e.sender,r=e.data.text,o=n.id,i=[],r&&(null==r?void 0:r.trim().length)&&i.push({type:"text",text:r}),{messages:[{content:i,role:"user",name:o}]}),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,n={8342:e=>{e.exports=require("emoji-picker-element")}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[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(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var i=Object.create(null);o.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&r&&n;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>n[e]));return a.default=()=>n,o.d(i,a),i},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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,{MessageProcessStatus:()=>F,ParticipantRole:()=>W,ParticipantType:()=>K,default:()=>$});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 g=require("@mui/material/InputAdornment");var y=o.n(g);const b=require("@mui/material/MenuItem");var j=o.n(b);const x=require("@mui/material/MenuList");var w=o.n(x);const O=require("@mui/material/Popover");var S=o.n(O);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),R=o(8342);const q=require("uuid");var _=function(){return _=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},_.apply(this,arguments)};function M(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 I=require("@mui/material/styles"),A=function(e){var t=(0,I.useTheme)(),n=(0,c.useRef)(null),r=(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(){r.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,8342,23)).then((function(n){var o=new(0,n.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])})),r.current=o})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,c.useEffect)((function(){return r.current&&r.current.addEventListener("emoji-click",p),function(){var e;null===(e=r.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:n,onClick:function(){u((function(e){return!e}))},sx:{color:"primary.light","&:hover":{color:"primary.main"}},children:(0,a.jsx)(M,{name:"Mood"})})}),r.current&&(0,a.jsx)(S(),{open:s,anchorEl:n.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&&r.current&&!e.contains(r.current)&&e.appendChild(r.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)(l(),{src:e.icon,className:"rustic-participant-avatar"}),(0,a.jsx)(T(),{variant:"body1Bold",children:e.displayName})]})}function L(e){var t=e.items,n=e.isOpen,r=e.onClose,o=e.onSelect,i=e.renderItem,c=e.anchorEl,s=e.selectedIndex;return(0,a.jsx)(S(),{disableAutoFocus:!0,open:n&&t.length>0,anchorEl:c,onClose:r,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},className:"rustic-suggestion-menu",children:(0,a.jsx)(w(),{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 n=e.multiline,r=void 0===n||n,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,g=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["multiline","fullWidth","maxRows","enableSpeechToText","maximumEmojiSearchResults"]),b=(0,c.useState)(""),j=b[0],x=b[1],w=(0,c.useState)(!1),O=w[0],S=w[1],k=(0,c.useState)(!1),C=k[0],P=k[1],_=(0,c.useState)(!1),I=_[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 R.Database({dataSource:g.emojiDataSource}),ne=!j.trim().length,re="".concat(O?"Stop":"Start"," speech to text"),oe=C?"primary.main":"primary.light",ie=O?"error.main":oe,ae=O?"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],me=d&&"undefined"!=typeof window&&!!window.webkitSpeechRecognition;function fe(){return"boolean"==typeof g.isSendEnabled?!g.isSendEnabled:ne}function he(e,t){if(ee.current){var n=ee.current,r=n.selectionStart,o=n.selectionEnd;if("number"==typeof r&&"number"==typeof o){var i,a=j||"",c=a.substring(0,r),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=r+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 ve(e){he("@".concat(e," "),/@(\w*)$/),ue([])}function ge(e,t){void 0===t&&(t=!1),he(e,t?/:(\w+)$/:void 0),V(!1)}var ye=I?(0,a.jsx)(f(),{size:24}):(0,a.jsx)(N(),{title:re,children:(0,a.jsx)(v(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,O?(e.stop(),B(!0),S(!1)):(e.start(),K(""),S(!0)),e.onstart=function(){S(!0)},e.onresult=function(e){var t,n=e.results[0][0].transcript;j.length>0?x(j+" "+n):x(n),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)(M,{name:ae})})});function be(){var e,t,n=(new Date).toISOString(),r={id:(0,q.v4)(),timestamp:n,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(r),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",backgroundColor:"background.paper"},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 ge(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 ve(e.displayName)},renderItem:H,selectedIndex:Y}),(0,a.jsx)(E(),{className:"rustic-text-field",variant:"outlined",value:j,label:g.label,placeholder:g.placeholder,maxRows:u,multiline:r,fullWidth:i,onKeyDown:function(e){var t,n="ArrowDown"===e.key,r="ArrowUp"===e.key;if("Enter"===e.key||"Tab"===e.key)e.shiftKey||e.preventDefault(),J&&$.length>0&&"unicode"in $[Y]?ge($[Y].unicode,!0):de&&se.length>0?ve(se[Y].displayName):e.shiftKey||fe()||be();else{if(n||r)return e.preventDefault(),t=n?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&&g.getMembers){var n=t[1].toLowerCase();g.getMembers().then((function(e){var t=e.filter((function(e){return e.displayName.toLowerCase().startsWith(n)}));ue(t),t.length>0?pe(!0):pe(!1)}))}else ue([])}(t);var n,r=t.match(/:(\w{2,}):/g),o=t.match(/:(\w{2,})/g);if(r){var i=r[0].replace(/:/g,"");te.getEmojiByShortcode(i).then((function(e){if(e&&"unicode"in e){var n=t.replace(r[0],e.unicode);x(n)}else x(t)})).catch((function(){x(t)})),V(!1)}else o?(n=o[0].replace(":",""),te.getEmojiBySearchQuery(n).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)(y(),{position:"end",className:"rustic-input-adornment",children:[(0,a.jsx)(A,{dataSource:g.emojiDataSource,onEmojiClick:ge,buttonColor:oe}),me&&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:[g.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:be,disabled:fe(),color:"secondary",children:(0,a.jsx)(M,{name:"send"})})})})]})]})}));var F,W,K,U=function(){return U=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},U.apply(this,arguments)};!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(F||(F={})),function(e){e.Owner="owner",e.Member="member"}(W||(W={})),function(e){e.Human="human",e.Agent="agent"}(K||(K={}));const $=function(e){var t=e.ws,n=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["ws"]);return(0,a.jsx)(B,U({},n,{send:function(e){var n,r,o,i;e.data=(n=e.sender,r=e.data.text,o=n.id,i=[],r&&(null==r?void 0:r.trim().length)&&i.push({type:"text",text:r}),{messages:[{content:i,role:"user",name:o}]}),t.send(e)}}))};return i})()));
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{ParticipantRole:()=>P,ParticipantType:()=>T,default:()=>N});const t=require("react/jsx-runtime"),n=(require("ol/ol.css"),require("@mui/material/Alert"));var a=e.n(n);const o=require("@mui/material/Box");var i=e.n(o);const u=require("@mui/material/Typography");var s=e.n(u);const c=require("ol/layer/Tile.js");var l=e.n(c);const d=require("ol/Map.js");var p=e.n(d);const m=require("ol/Overlay.js");var f=e.n(m);const v=require("ol/proj.js"),y=require("ol/source/OSM.js");var j=e.n(y);const g=require("ol/View.js");var x=e.n(g);const b=require("react");var h=function(){return h=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},h.apply(this,arguments)};function q(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:h({},r),children:e.name})}const w=require("dompurify");var O=e.n(w);const S=require("marked");function _(e){var r=e.replace(/^[\u200B-\u200F\uFEFF]/,""),t=S.marked.parse(r,{async:!1});return O().sanitize(t)}const M=function(e){var r=(0,b.useState)(_(e.text)),n=r[0],a=r[1];return(0,b.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var r=e.updatedData[e.updatedData.length-1].text;a(_(r))}}),[e.text,e.updatedData]),(0,t.jsx)(s(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:n}})};var P,T;!function(e){e.Owner="owner",e.Member="member"}(P||(P={})),function(e){e.Human="human",e.Agent="agent"}(T||(T={}));const N=function(e){var r=(0,b.useState)(""),n=r[0],o=r[1],u=(0,b.useRef)(null),c=(0,b.useRef)(null);return(0,b.useEffect)((function(){if(o(""),e.latitude<-90||e.latitude>90||e.longitude<-180||e.longitude>180)return o("Invalid coordinates");if(u.current&&c.current){var r=new(p())({layers:[new(l())({source:new(j())})],view:new(x())({center:(0,v.fromLonLat)([e.longitude,e.latitude]),zoom:12}),target:u.current}),t=new(f())({element:c.current,position:(0,v.fromLonLat)([e.longitude,e.latitude]),positioning:"bottom-center",stopEvent:!1});return r.addOverlay(t),r.once("postrender",(function(){var e;if(!(null===(e=u.current)||void 0===e?void 0:e.querySelector("canvas")))return o("An error occurred while loading the map")})),function(){r.setTarget(""),r.removeOverlay(t)}}}),[]),(0,t.jsx)(t.Fragment,{children:n.length>0?(0,t.jsx)(a(),{severity:"error",children:n}):(0,t.jsxs)(i(),{children:[e.title&&(0,t.jsx)(s(),{variant:"h6",children:e.title}),e.description&&(0,t.jsx)(M,{text:e.description}),(0,t.jsx)(i(),{ref:c,children:(0,t.jsx)(q,{className:"rustic-open-layers-map-marker",name:"location_on"})}),(0,t.jsx)("div",{ref:u,className:"rustic-open-layers-map-canvas"})]})})};return r})()));
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={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{MessageProcessStatus:()=>_,ParticipantRole:()=>T,ParticipantType:()=>N,default:()=>D});const t=require("react/jsx-runtime"),n=(require("ol/ol.css"),require("@mui/material/Alert"));var o=e.n(n);const a=require("@mui/material/Box");var i=e.n(a);const u=require("@mui/material/Typography");var s=e.n(u);const c=require("ol/layer/Tile.js");var l=e.n(c);const d=require("ol/Map.js");var p=e.n(d);const m=require("ol/Overlay.js");var f=e.n(m);const v=require("ol/proj.js"),y=require("ol/source/OSM.js");var g=e.n(y);const j=require("ol/View.js");var x=e.n(j);const b=require("react");var h=function(){return h=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},h.apply(this,arguments)};function q(e){e.name.replaceAll("_","-");var r={};return e.color&&(r={color:e.color}),(0,t.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:h({},r),children:e.name})}const w=require("dompurify");var O=e.n(w);const S=require("marked");function M(e){var r=e.replace(/^[\u200B-\u200F\uFEFF]/,""),t=S.marked.parse(r,{async:!1});return O().sanitize(t)}const P=function(e){var r=(0,b.useState)(M(e.text)),n=r[0],o=r[1];return(0,b.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var r=e.updatedData[e.updatedData.length-1].text;o(M(r))}}),[e.text,e.updatedData]),(0,t.jsx)(s(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:n}})};var _,T,N;!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(_||(_={})),function(e){e.Owner="owner",e.Member="member"}(T||(T={})),function(e){e.Human="human",e.Agent="agent"}(N||(N={}));const D=function(e){var r=(0,b.useState)(""),n=r[0],a=r[1],u=(0,b.useRef)(null),c=(0,b.useRef)(null);return(0,b.useEffect)((function(){if(a(""),e.latitude<-90||e.latitude>90||e.longitude<-180||e.longitude>180)return a("Invalid coordinates");if(u.current&&c.current){var r=new(p())({layers:[new(l())({source:new(g())})],view:new(x())({center:(0,v.fromLonLat)([e.longitude,e.latitude]),zoom:12}),target:u.current}),t=new(f())({element:c.current,position:(0,v.fromLonLat)([e.longitude,e.latitude]),positioning:"bottom-center",stopEvent:!1});return r.addOverlay(t),r.once("postrender",(function(){var e;if(!(null===(e=u.current)||void 0===e?void 0:e.querySelector("canvas")))return a("An error occurred while loading the map")})),function(){r.setTarget(""),r.removeOverlay(t)}}}),[]),(0,t.jsx)(t.Fragment,{children:n.length>0?(0,t.jsx)(o(),{severity:"error",children:n}):(0,t.jsxs)(i(),{children:[e.title&&(0,t.jsx)(s(),{variant:"h6",children:e.title}),e.description&&(0,t.jsx)(P,{text:e.description}),(0,t.jsx)(i(),{ref:c,children:(0,t.jsx)(q,{className:"rustic-open-layers-map-marker",name:"location_on"})}),(0,t.jsx)("div",{ref:u,className:"rustic-open-layers-map-canvas"})]})})};return r})()));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={227:(e,t,r)=>{r.d(t,{A:()=>c,L:()=>p});var a=r(8732),n=r(785),o=r.n(n),u=r(7447),i=r.n(u),d=r(3840),s=r(2015);function p(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=d.marked.parse(t,{async:!1});return i().sanitize(r)}const c=function(e){var t=(0,s.useState)(p(e.text)),r=t[0],n=t[1];return(0,s.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var t=e.updatedData[e.updatedData.length-1].text;n(p(t))}}),[e.text,e.updatedData]),(0,a.jsx)(o(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:r}})}},4409:(e,t,r)=>{r.d(t,{A:()=>p});var a=r(8732),n=r(5642),o=r.n(n),u=r(785),i=r.n(u),d=r(2015),s=r(227);const p=function(e){var t=(0,d.useState)((0,s.L)(e.text)),r=t[0],n=t[1],u=(0,d.useState)(""),p=u[0],c=u[1];return(0,d.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){for(var t=e.text,r=0,a=e.updatedData;r<a.length;r++){var o=a[r];"string"!=typeof o.text?(t+=" [MISSING TEXT]",c("Some of the incoming text was not correctly formatted. Some data may be missing.")):t+=o.text}n((0,s.L)(t))}}),[e.text,e.updatedData]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i(),{variant:"body2",dangerouslySetInnerHTML:{__html:r}}),p&&(0,a.jsx)(o(),{severity:"error",children:p})]})}},7159:(e,t,r)=>{var a,n;r.d(t,{s:()=>a,y:()=>n}),function(e){e.Owner="owner",e.Member="member"}(a||(a={})),function(e){e.Human="human",e.Agent="agent"}(n||(n={}))},5642:e=>{e.exports=require("@mui/material/Alert")},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")}},t={};function r(a){var n=t[a];if(void 0!==n)return n.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};r.r(a),r.d(a,{MarkedMarkdown:()=>n.A,MarkedStreamingMarkdown:()=>o.A,ParticipantRole:()=>u.s,ParticipantType:()=>u.y,default:()=>i});var n=r(227),o=r(4409),u=r(7159);const i=n.A;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={227:(e,t,r)=>{r.d(t,{A:()=>c,L:()=>p});var a=r(8732),n=r(785),o=r.n(n),u=r(7447),i=r.n(u),d=r(3840),s=r(2015);function p(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=d.marked.parse(t,{async:!1});return i().sanitize(r)}const c=function(e){var t=(0,s.useState)(p(e.text)),r=t[0],n=t[1];return(0,s.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var t=e.updatedData[e.updatedData.length-1].text;n(p(t))}}),[e.text,e.updatedData]),(0,a.jsx)(o(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:r}})}},4409:(e,t,r)=>{r.d(t,{A:()=>p});var a=r(8732),n=r(5642),o=r.n(n),u=r(785),i=r.n(u),d=r(2015),s=r(227);const p=function(e){var t=(0,d.useState)((0,s.L)(e.text)),r=t[0],n=t[1],u=(0,d.useState)(""),p=u[0],c=u[1];return(0,d.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){for(var t=e.text,r=0,a=e.updatedData;r<a.length;r++){var o=a[r];"string"!=typeof o.text?(t+=" [MISSING TEXT]",c("Some of the incoming text was not correctly formatted. Some data may be missing.")):t+=o.text}n((0,s.L)(t))}}),[e.text,e.updatedData]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i(),{variant:"body2",dangerouslySetInnerHTML:{__html:r}}),p&&(0,a.jsx)(o(),{severity:"error",children:p})]})}},7159:(e,t,r)=>{var a,n,o;r.d(t,{sW:()=>n,xx:()=>a,yJ:()=>o}),function(e){e.Running="running",e.Completed="completed",e.Error="error"}(a||(a={})),function(e){e.Owner="owner",e.Member="member"}(n||(n={})),function(e){e.Human="human",e.Agent="agent"}(o||(o={}))},5642:e=>{e.exports=require("@mui/material/Alert")},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")}},t={};function r(a){var n=t[a];if(void 0!==n)return n.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};r.r(a),r.d(a,{MarkedMarkdown:()=>n.A,MarkedStreamingMarkdown:()=>o.A,MessageProcessStatus:()=>u.xx,ParticipantRole:()=>u.sW,ParticipantType:()=>u.yJ,default:()=>i});var n=r(227),o=r(4409),u=r(7159);const i=n.A;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={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:()=>A,ParticipantType:()=>U,default:()=>X});const r=require("react/jsx-runtime"),n=require("@mui/material"),a=require("@mui/material/Alert");var i=e.n(a);const o=require("@mui/material/CircularProgress");var s=e.n(o);const l=require("@mui/material/Typography");var c=e.n(l);const u=require("@mui/system"),m=require("react"),d=require("dompurify");var p=e.n(d);const f=require("marked");function x(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=f.marked.parse(t,{async:!1});return p().sanitize(r)}const v=function(e){var t=(0,m.useState)(x(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(x(t))}}),[e.text,e.updatedData]),(0,r.jsx)(c(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:n}})},y=require("@mui/material/Box");var b=e.n(y);const j=require("@mui/material/Button");var h=e.n(j);const E=require("@mui/material/LinearProgress");var g=e.n(E);const N=require("@mui/material/Slider");var S=e.n(N);const T=require("@mui/material/Tooltip");var O,_=e.n(T);function k(e){var t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=Math.floor(e%60),a=t>0?"".concat(t,":"):"",i="".concat(t>0?r.toString().padStart(2,"0"):r),o=n.toString().padStart(2,"0");return"".concat(a).concat(i,":").concat(o)}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(O||(O={}));var w=function(){return w=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},w.apply(this,arguments)};function P(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:w({},t),children:e.name})}const B=require("@mui/material/IconButton");var q=e.n(B);function C(e){var t,n={play:{symbol:"play_circle",label:"Play"},pause:{symbol:"pause_circle",label:"Pause"},forward:{symbol:"forward_10",label:"Forward ten seconds"},replay:{symbol:"replay_10",label:"Replay ten seconds"},volumeUp:{symbol:"volume_up",label:"Mute"},volumeOff:{symbol:"volume_off",label:"Unmute"},miniPlayer:{symbol:"picture_in_picture",label:"Mini player"},miniPlayerExit:{symbol:"picture_in_picture_off",label:"Exit mini player"},fullscreen:{symbol:"fullscreen",label:"Fullscreen"},fullscreenExit:{symbol:"fullscreen_exit",label:"Exit fullscreen"},captionsOn:{symbol:"closed_caption",label:"Show captions"},captionsOff:{symbol:"closed_caption_disabled",label:"Hide captions"}};return n[e.action].label.replaceAll(" ","-").toLowerCase(),(0,r.jsx)(_(),{title:n[e.action].label,PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,r.jsx)(q(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,r.jsx)(P,{name:n[e.action].symbol,className:"rustic-icon-large"})})})}function M(e){var t="dark"===(0,n.useTheme)().palette.mode,a=k(e.mediaElement.currentTime);return(0,r.jsxs)(b(),{className:"rustic-progress",children:[function(){for(var n=e.mediaElement.buffered,a=0,i=n.length-1;i>=0;--i){var o=n.start(i),s=n.end(i);if(o<e.mediaElement.currentTime){a=s;break}}var l=a/e.mediaElement.duration*100;return(0,r.jsx)(g(),{className:"rustic-progress-buffered",variant:"determinate",value:l,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:t?"secondary.light":"action.selected"}}})}(),(0,r.jsx)(S(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(a),max:e.mediaElement.duration,value:e.mediaElement.currentTime,onChange:function(t,r){e.mediaElement.currentTime=r},valueLabelDisplay:"auto",valueLabelFormat:function(e){return k(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function I(e){var t=(0,m.useState)(e.mediaElement.volume),n=t[0],a=t[1],i=(0,m.useState)(e.mediaElement.volume),o=i[0],s=i[1],l=e.mediaElement.muted?"volumeOff":"volumeUp";return(0,r.jsxs)(b(),{className:"rustic-volume-settings",children:[(0,r.jsx)(C,{onClick:function(){e.mediaElement.muted=!e.mediaElement.muted,e.mediaElement.muted?(s(e.mediaElement.volume),a(0)):a(o)},className:"rustic-mute-button",action:l}),(0,r.jsx)(S(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(100*n,"%"),value:n,onChange:function(t,r){var n=r;e.mediaElement.muted=0===n,e.mediaElement.volume=n,a(e.mediaElement.volume)}})]})}function F(e){var t=e.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",n="".concat(e.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,r.jsx)(h(),{className:"rustic-transcript-toggle",onClick:e.setIsTranscriptVisible,endIcon:(0,r.jsx)(P,{name:t}),children:(0,r.jsx)(c(),{variant:"overline",children:n})})}function L(e){var t=(0,m.useState)(!e.mediaElement.paused),n=t[0],a=t[1],i=n?"pause":"play";return e.mediaElement.onended=function(){a(!1)},e.mediaElement.onpause=function(){a(!1)},e.mediaElement.onplay=function(){a(!0)},(0,r.jsx)(C,{onClick:function(){n?e.mediaElement.pause():e.mediaElement.play().catch((function(t){e.onError("Failed to play the media. Error: ".concat(t.message))}))},action:i,className:"rustic-pause-play-icon"})}function D(e){var t,n=(0,m.useState)(e.mediaElement.playbackRate),a=n[0],i=n[1];return(0,r.jsx)(_(),{title:"Playback rate",PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,r.jsx)(h(),{onClick:function(){var t=1;e.mediaElement.playbackRate<2&&(t=e.mediaElement.playbackRate+.5),e.mediaElement.playbackRate=t,i(t)},className:"rustic-playback-rate-button",children:(0,r.jsxs)(c(),{variant:"body1",children:[a,"X"]})})})}function R(e){var t="replay"===e.movement,n=t?function(){e.mediaElement.currentTime-=10}:function(){e.mediaElement.currentTime+=10},a=t?"replay":"forward";return(0,r.jsx)(C,{onClick:n,action:a})}function H(e){var t=e.style,n=void 0===t?"condensed":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 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,["style"]),i=k(a.elapsedTimeInSeconds),o=k(a.durationTimeInSeconds),s="".concat(i," / ").concat(o);return"wide"===n?(0,r.jsxs)(b(),{className:"rustic-time-container",children:[(0,r.jsx)(c(),{variant:"overline",children:i}),(0,r.jsx)(c(),{variant:"overline",children:o})]}):(0,r.jsx)(c(),{variant:"overline",className:"rustic-time-display",children:s})}const V=require("@mui/material/Divider");var A,U,z=e.n(V);function Q(e){var t=!!document.fullscreenElement;return(0,r.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!t&&(0,r.jsx)(z(),{orientation:"vertical",flexItem:!0}),(0,r.jsx)(c(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}!function(e){e.Owner="owner",e.Member="member"}(A||(A={})),function(e){e.Human="human",e.Agent="agent"}(U||(U={}));const X=function(e){var t=(0,m.useState)(!1),a=t[0],o=t[1],l=(0,m.useState)(!1),d=l[0],p=l[1],f=(0,m.useState)(!0),x=f[0],y=f[1],b=(0,m.useState)(0),j=b[0],h=b[1],E=(0,m.useState)(""),g=E[0],N=E[1],S=(0,m.useState)(""),T=S[0],O=S[1],_=(0,n.useTheme)(),k=(0,m.useRef)(null),w=(0,n.useMediaQuery)(_.breakpoints.down("md"));function P(){return(0,r.jsx)(c(),{variant:"h6",className:"rustic-sound-title",children:e.title})}function B(){if(e.captions&&e.captions.length>0){var t=d?"captionsOff":"captionsOn";return(0,r.jsx)(C,{action:t,onClick:function(){return p(!d)}})}}function q(){if(k.current)return(0,r.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,r.jsx)(R,{mediaElement:k.current,movement:"replay"}),(0,r.jsx)(L,{mediaElement:k.current,onError:O}),(0,r.jsx)(R,{mediaElement:k.current,movement:"forward"})]})}function V(){if(e.transcript&&a)return(0,r.jsx)(Q,{transcript:e.transcript})}function A(){if(e.transcript)return(0,r.jsx)(F,{isTranscriptVisible:a,setIsTranscriptVisible:function(){return o(!a)}})}function U(){return(0,r.jsx)("video",{src:e.src,ref:k,className:d?"rustic-has-captions":"",children:d&&(0,r.jsx)("track",{src:e.captions,kind:"captions",default:!0})})}(0,m.useEffect)((function(){var e,t,r,n;function a(e){N(e)}null===(e=k.current)||void 0===e||e.addEventListener("timeupdate",(function(){k.current&&h(k.current.currentTime)})),null===(t=k.current)||void 0===t||t.addEventListener("canplay",(function(){N(""),y(!1)})),null===(r=k.current)||void 0===r||r.addEventListener("error",(function(){return a("Failed to load the audio.")})),null===(n=k.current)||void 0===n||n.addEventListener("stalled",(function(){return a("Failed to fetch audio data, but trying.")}))}),[]);var z=w?function(){if(k.current)return(0,r.jsxs)(u.Box,{className:"rustic-sound-controls",children:[(0,r.jsx)(H,{elapsedTimeInSeconds:j,durationTimeInSeconds:k.current.duration,style:"wide"}),(0,r.jsx)(M,{mediaElement:k.current}),P(),e.description&&(0,r.jsx)(v,{text:e.description}),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls",children:[(0,r.jsx)(u.Box,{className:"rustic-sound-bottom-controls-left",children:q()}),(0,r.jsx)(I,{mediaElement:k.current}),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls-right",children:[A(),(0,r.jsxs)(u.Box,{children:[B(),(0,r.jsx)(D,{mediaElement:k.current})]})]})]}),V()]})}:function(){if(k.current)return(0,r.jsxs)(r.Fragment,{children:[P(),e.description&&(0,r.jsx)(v,{text:e.description}),(0,r.jsxs)(u.Box,{className:"rustic-sound-controls",children:[(0,r.jsx)(M,{mediaElement:k.current}),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls-left",children:[q(),B(),(0,r.jsx)(D,{mediaElement:k.current}),(0,r.jsx)(I,{mediaElement:k.current}),(0,r.jsx)(H,{elapsedTimeInSeconds:j,durationTimeInSeconds:k.current.duration,style:"condensed"})]}),(0,r.jsx)(u.Box,{className:"rustic-sound-bottom-controls-right",children:A()})]}),V()]})]})};return g.length>0?(0,r.jsx)(i(),{severity:"error",children:g}):x?(0,r.jsxs)(u.Box,{className:"rustic-sound",children:[U(),(0,r.jsx)(s(),{})]}):(0,r.jsxs)(u.Box,{className:"rustic-sound",children:[U(),z(),T.length>0&&(0,r.jsx)(i(),{severity:"error",className:"rustic-control-error",onClose:function(){return O("")},children:T})]})};return t})()));
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,{MessageProcessStatus:()=>A,ParticipantRole:()=>U,ParticipantType:()=>z,default:()=>G});const r=require("react/jsx-runtime"),n=require("@mui/material"),a=require("@mui/material/Alert");var i=e.n(a);const o=require("@mui/material/CircularProgress");var s=e.n(o);const l=require("@mui/material/Typography");var c=e.n(l);const u=require("@mui/system"),m=require("react"),d=require("dompurify");var p=e.n(d);const f=require("marked");function x(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=f.marked.parse(t,{async:!1});return p().sanitize(r)}const v=function(e){var t=(0,m.useState)(x(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(x(t))}}),[e.text,e.updatedData]),(0,r.jsx)(c(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:n}})},y=require("@mui/material/Box");var b=e.n(y);const j=require("@mui/material/Button");var h=e.n(j);const E=require("@mui/material/LinearProgress");var g=e.n(E);const N=require("@mui/material/Slider");var S=e.n(N);const T=require("@mui/material/Tooltip");var O,_=e.n(T);function k(e){var t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=Math.floor(e%60),a=t>0?"".concat(t,":"):"",i="".concat(t>0?r.toString().padStart(2,"0"):r),o=n.toString().padStart(2,"0");return"".concat(a).concat(i,":").concat(o)}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(O||(O={}));var P=function(){return P=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},P.apply(this,arguments)};function w(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:P({},t),children:e.name})}const B=require("@mui/material/IconButton");var C=e.n(B);function q(e){var t,n={play:{symbol:"play_circle",label:"Play"},pause:{symbol:"pause_circle",label:"Pause"},forward:{symbol:"forward_10",label:"Forward ten seconds"},replay:{symbol:"replay_10",label:"Replay ten seconds"},volumeUp:{symbol:"volume_up",label:"Mute"},volumeOff:{symbol:"volume_off",label:"Unmute"},miniPlayer:{symbol:"picture_in_picture",label:"Mini player"},miniPlayerExit:{symbol:"picture_in_picture_off",label:"Exit mini player"},fullscreen:{symbol:"fullscreen",label:"Fullscreen"},fullscreenExit:{symbol:"fullscreen_exit",label:"Exit fullscreen"},captionsOn:{symbol:"closed_caption",label:"Show captions"},captionsOff:{symbol:"closed_caption_disabled",label:"Hide captions"}};return n[e.action].label.replaceAll(" ","-").toLowerCase(),(0,r.jsx)(_(),{title:n[e.action].label,PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,r.jsx)(C(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,r.jsx)(w,{name:n[e.action].symbol,className:"rustic-icon-large"})})})}function M(e){var t="dark"===(0,n.useTheme)().palette.mode,a=k(e.mediaElement.currentTime);return(0,r.jsxs)(b(),{className:"rustic-progress",children:[function(){for(var n=e.mediaElement.buffered,a=0,i=n.length-1;i>=0;--i){var o=n.start(i),s=n.end(i);if(o<e.mediaElement.currentTime){a=s;break}}var l=a/e.mediaElement.duration*100;return(0,r.jsx)(g(),{className:"rustic-progress-buffered",variant:"determinate",value:l,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:t?"secondary.light":"action.selected"}}})}(),(0,r.jsx)(S(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(a),max:e.mediaElement.duration,value:e.mediaElement.currentTime,onChange:function(t,r){e.mediaElement.currentTime=r},valueLabelDisplay:"auto",valueLabelFormat:function(e){return k(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function I(e){var t=(0,m.useState)(e.mediaElement.volume),n=t[0],a=t[1],i=(0,m.useState)(e.mediaElement.volume),o=i[0],s=i[1],l=e.mediaElement.muted?"volumeOff":"volumeUp";return(0,r.jsxs)(b(),{className:"rustic-volume-settings",children:[(0,r.jsx)(q,{onClick:function(){e.mediaElement.muted=!e.mediaElement.muted,e.mediaElement.muted?(s(e.mediaElement.volume),a(0)):a(o)},className:"rustic-mute-button",action:l}),(0,r.jsx)(S(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(100*n,"%"),value:n,onChange:function(t,r){var n=r;e.mediaElement.muted=0===n,e.mediaElement.volume=n,a(e.mediaElement.volume)}})]})}function F(e){var t=e.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",n="".concat(e.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,r.jsx)(h(),{className:"rustic-transcript-toggle",onClick:e.setIsTranscriptVisible,endIcon:(0,r.jsx)(w,{name:t}),children:(0,r.jsx)(c(),{variant:"overline",children:n})})}function L(e){var t=(0,m.useState)(!e.mediaElement.paused),n=t[0],a=t[1],i=n?"pause":"play";return e.mediaElement.onended=function(){a(!1)},e.mediaElement.onpause=function(){a(!1)},e.mediaElement.onplay=function(){a(!0)},(0,r.jsx)(q,{onClick:function(){n?e.mediaElement.pause():e.mediaElement.play().catch((function(t){e.onError("Failed to play the media. Error: ".concat(t.message))}))},action:i,className:"rustic-pause-play-icon"})}function R(e){var t,n=(0,m.useState)(e.mediaElement.playbackRate),a=n[0],i=n[1];return(0,r.jsx)(_(),{title:"Playback rate",PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,r.jsx)(h(),{onClick:function(){var t=1;e.mediaElement.playbackRate<2&&(t=e.mediaElement.playbackRate+.5),e.mediaElement.playbackRate=t,i(t)},className:"rustic-playback-rate-button",children:(0,r.jsxs)(c(),{variant:"body1",children:[a,"X"]})})})}function D(e){var t="replay"===e.movement,n=t?function(){e.mediaElement.currentTime-=10}:function(){e.mediaElement.currentTime+=10},a=t?"replay":"forward";return(0,r.jsx)(q,{onClick:n,action:a})}function H(e){var t=e.style,n=void 0===t?"condensed":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 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,["style"]),i=k(a.elapsedTimeInSeconds),o=k(a.durationTimeInSeconds),s="".concat(i," / ").concat(o);return"wide"===n?(0,r.jsxs)(b(),{className:"rustic-time-container",children:[(0,r.jsx)(c(),{variant:"overline",children:i}),(0,r.jsx)(c(),{variant:"overline",children:o})]}):(0,r.jsx)(c(),{variant:"overline",className:"rustic-time-display",children:s})}const V=require("@mui/material/Divider");var A,U,z,Q=e.n(V);function X(e){var t=!!document.fullscreenElement;return(0,r.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!t&&(0,r.jsx)(Q(),{orientation:"vertical",flexItem:!0}),(0,r.jsx)(c(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(A||(A={})),function(e){e.Owner="owner",e.Member="member"}(U||(U={})),function(e){e.Human="human",e.Agent="agent"}(z||(z={}));const G=function(e){var t=(0,m.useState)(!1),a=t[0],o=t[1],l=(0,m.useState)(!1),d=l[0],p=l[1],f=(0,m.useState)(!0),x=f[0],y=f[1],b=(0,m.useState)(0),j=b[0],h=b[1],E=(0,m.useState)(""),g=E[0],N=E[1],S=(0,m.useState)(""),T=S[0],O=S[1],_=(0,n.useTheme)(),k=(0,m.useRef)(null),P=(0,n.useMediaQuery)(_.breakpoints.down("md"));function w(){return(0,r.jsx)(c(),{variant:"h6",className:"rustic-sound-title",children:e.title})}function B(){if(e.captions&&e.captions.length>0){var t=d?"captionsOff":"captionsOn";return(0,r.jsx)(q,{action:t,onClick:function(){return p(!d)}})}}function C(){if(k.current)return(0,r.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,r.jsx)(D,{mediaElement:k.current,movement:"replay"}),(0,r.jsx)(L,{mediaElement:k.current,onError:O}),(0,r.jsx)(D,{mediaElement:k.current,movement:"forward"})]})}function V(){if(e.transcript&&a)return(0,r.jsx)(X,{transcript:e.transcript})}function A(){if(e.transcript)return(0,r.jsx)(F,{isTranscriptVisible:a,setIsTranscriptVisible:function(){return o(!a)}})}function U(){return(0,r.jsx)("video",{src:e.src,ref:k,className:d?"rustic-has-captions":"",children:d&&(0,r.jsx)("track",{src:e.captions,kind:"captions",default:!0})})}(0,m.useEffect)((function(){var e,t,r,n;function a(e){N(e)}null===(e=k.current)||void 0===e||e.addEventListener("timeupdate",(function(){k.current&&h(k.current.currentTime)})),null===(t=k.current)||void 0===t||t.addEventListener("canplay",(function(){N(""),y(!1)})),null===(r=k.current)||void 0===r||r.addEventListener("error",(function(){return a("Failed to load the audio.")})),null===(n=k.current)||void 0===n||n.addEventListener("stalled",(function(){return a("Failed to fetch audio data, but trying.")}))}),[]);var z=P?function(){if(k.current)return(0,r.jsxs)(u.Box,{className:"rustic-sound-controls",children:[(0,r.jsx)(H,{elapsedTimeInSeconds:j,durationTimeInSeconds:k.current.duration,style:"wide"}),(0,r.jsx)(M,{mediaElement:k.current}),w(),e.description&&(0,r.jsx)(v,{text:e.description}),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls",children:[(0,r.jsx)(u.Box,{className:"rustic-sound-bottom-controls-left",children:C()}),(0,r.jsx)(I,{mediaElement:k.current}),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls-right",children:[A(),(0,r.jsxs)(u.Box,{children:[B(),(0,r.jsx)(R,{mediaElement:k.current})]})]})]}),V()]})}:function(){if(k.current)return(0,r.jsxs)(r.Fragment,{children:[w(),e.description&&(0,r.jsx)(v,{text:e.description}),(0,r.jsxs)(u.Box,{className:"rustic-sound-controls",children:[(0,r.jsx)(M,{mediaElement:k.current}),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls-left",children:[C(),B(),(0,r.jsx)(R,{mediaElement:k.current}),(0,r.jsx)(I,{mediaElement:k.current}),(0,r.jsx)(H,{elapsedTimeInSeconds:j,durationTimeInSeconds:k.current.duration,style:"condensed"})]}),(0,r.jsx)(u.Box,{className:"rustic-sound-bottom-controls-right",children:A()})]}),V()]})]})};return g.length>0?(0,r.jsx)(i(),{severity:"error",children:g}):x?(0,r.jsxs)(u.Box,{className:"rustic-sound",children:[U(),(0,r.jsx)(s(),{})]}):(0,r.jsxs)(u.Box,{className:"rustic-sound",children:[U(),z(),T.length>0&&(0,r.jsx)(i(),{severity:"error",className:"rustic-control-error",onClose:function(){return O("")},children:T})]})};return t})()));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ParticipantRole:()=>z,ParticipantType:()=>Q,default:()=>J});const n=require("react/jsx-runtime"),r=require("@mui/material"),a=require("@mui/material/Alert");var i=e.n(a);const o=require("@mui/material/CircularProgress");var c=e.n(o);const l=require("@mui/material/Typography");var s=e.n(l);const u=require("@mui/system"),m=require("react"),d=require("dompurify");var f=e.n(d);const p=require("marked");function v(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),n=p.marked.parse(t,{async:!1});return f().sanitize(n)}const x=function(e){var t=(0,m.useState)(v(e.text)),r=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(v(t))}}),[e.text,e.updatedData]),(0,n.jsx)(s(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:r}})},y=require("@mui/material/Box");var b=e.n(y);const E=require("@mui/material/Button");var j=e.n(E);const h=require("@mui/material/LinearProgress");var g=e.n(h);const N=require("@mui/material/Slider");var S=e.n(N);const T=require("@mui/material/Tooltip");var k,P=e.n(T);function O(e){var t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60),a=t>0?"".concat(t,":"):"",i="".concat(t>0?n.toString().padStart(2,"0"):n),o=r.toString().padStart(2,"0");return"".concat(a).concat(i,":").concat(o)}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(k||(k={}));var _=function(){return _=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},_.apply(this,arguments)};function w(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:_({},t),children:e.name})}const B=require("@mui/material/IconButton");var C=e.n(B);function F(e){var t,r={play:{symbol:"play_circle",label:"Play"},pause:{symbol:"pause_circle",label:"Pause"},forward:{symbol:"forward_10",label:"Forward ten seconds"},replay:{symbol:"replay_10",label:"Replay ten seconds"},volumeUp:{symbol:"volume_up",label:"Mute"},volumeOff:{symbol:"volume_off",label:"Unmute"},miniPlayer:{symbol:"picture_in_picture",label:"Mini player"},miniPlayerExit:{symbol:"picture_in_picture_off",label:"Exit mini player"},fullscreen:{symbol:"fullscreen",label:"Fullscreen"},fullscreenExit:{symbol:"fullscreen_exit",label:"Exit fullscreen"},captionsOn:{symbol:"closed_caption",label:"Show captions"},captionsOff:{symbol:"closed_caption_disabled",label:"Hide captions"}};return r[e.action].label.replaceAll(" ","-").toLowerCase(),(0,n.jsx)(P(),{title:r[e.action].label,PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,n.jsx)(C(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,n.jsx)(w,{name:r[e.action].symbol,className:"rustic-icon-large"})})})}function q(e){var t="dark"===(0,r.useTheme)().palette.mode,a=O(e.mediaElement.currentTime);return(0,n.jsxs)(b(),{className:"rustic-progress",children:[function(){for(var r=e.mediaElement.buffered,a=0,i=r.length-1;i>=0;--i){var o=r.start(i),c=r.end(i);if(o<e.mediaElement.currentTime){a=c;break}}var l=a/e.mediaElement.duration*100;return(0,n.jsx)(g(),{className:"rustic-progress-buffered",variant:"determinate",value:l,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:t?"secondary.light":"action.selected"}}})}(),(0,n.jsx)(S(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(a),max:e.mediaElement.duration,value:e.mediaElement.currentTime,onChange:function(t,n){e.mediaElement.currentTime=n},valueLabelDisplay:"auto",valueLabelFormat:function(e){return O(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function I(e){var t=(0,m.useState)(e.mediaElement.volume),r=t[0],a=t[1],i=(0,m.useState)(e.mediaElement.volume),o=i[0],c=i[1],l=e.mediaElement.muted?"volumeOff":"volumeUp";return(0,n.jsxs)(b(),{className:"rustic-volume-settings",children:[(0,n.jsx)(F,{onClick:function(){e.mediaElement.muted=!e.mediaElement.muted,e.mediaElement.muted?(c(e.mediaElement.volume),a(0)):a(o)},className:"rustic-mute-button",action:l}),(0,n.jsx)(S(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(100*r,"%"),value:r,onChange:function(t,n){var r=n;e.mediaElement.muted=0===r,e.mediaElement.volume=r,a(e.mediaElement.volume)}})]})}function M(e){var t=e.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",r="".concat(e.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,n.jsx)(j(),{className:"rustic-transcript-toggle",onClick:e.setIsTranscriptVisible,endIcon:(0,n.jsx)(w,{name:t}),children:(0,n.jsx)(s(),{variant:"overline",children:r})})}function L(e){var t=(0,m.useState)(!e.mediaElement.paused),r=t[0],a=t[1],i=r?"pause":"play";return e.mediaElement.onended=function(){a(!1)},e.mediaElement.onpause=function(){a(!1)},e.mediaElement.onplay=function(){a(!0)},(0,n.jsx)(F,{onClick:function(){r?e.mediaElement.pause():e.mediaElement.play().catch((function(t){e.onError("Failed to play the media. Error: ".concat(t.message))}))},action:i,className:"rustic-pause-play-icon"})}function R(e){var t,r=(0,m.useState)(e.mediaElement.playbackRate),a=r[0],i=r[1];return(0,n.jsx)(P(),{title:"Playback rate",PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,n.jsx)(j(),{onClick:function(){var t=1;e.mediaElement.playbackRate<2&&(t=e.mediaElement.playbackRate+.5),e.mediaElement.playbackRate=t,i(t)},className:"rustic-playback-rate-button",children:(0,n.jsxs)(s(),{variant:"body1",children:[a,"X"]})})})}function D(e){var t="replay"===e.movement,r=t?function(){e.mediaElement.currentTime-=10}:function(){e.mediaElement.currentTime+=10},a=t?"replay":"forward";return(0,n.jsx)(F,{onClick:r,action:a})}function H(e){var t=(0,m.useState)(!!document.pictureInPictureElement),r=t[0],a=t[1],i=e.mediaElement,o=r?"miniPlayerExit":"miniPlayer";return i.onleavepictureinpicture=function(){a(!1)},(0,n.jsx)(F,{onClick:function(){r?document.exitPictureInPicture().then((function(){a(!1)})).catch((function(t){e.onError("Failed to exit mini player. Error: ".concat(t.message))})):i.requestPictureInPicture().then((function(){a(!0)})).catch((function(t){e.onError("Failed to enter mini player. Error: ".concat(t.message))}))},action:o})}function V(e){var t=(0,m.useState)(!!document.fullscreenElement),r=t[0],a=t[1],i=e.element,o=r?"fullscreenExit":"fullscreen";return i.onfullscreenchange=function(){a(!!document.fullscreenElement)},(0,n.jsx)(F,{onClick:function(){r?document.exitFullscreen().then((function(){a(!1)})).catch((function(t){e.onError("Failed to exit fullscreen mode. Error: ".concat(t.message))})):i.requestFullscreen().then((function(){a(!0)})).catch((function(t){e.onError("Failed to enter fullscreen mode. Error: ".concat(t.message))}))},action:o})}function A(e){var t=e.style,r=void 0===t?"condensed":t,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]])}return n}(e,["style"]),i=O(a.elapsedTimeInSeconds),o=O(a.durationTimeInSeconds),c="".concat(i," / ").concat(o);return"wide"===r?(0,n.jsxs)(b(),{className:"rustic-time-container",children:[(0,n.jsx)(s(),{variant:"overline",children:i}),(0,n.jsx)(s(),{variant:"overline",children:o})]}):(0,n.jsx)(s(),{variant:"overline",className:"rustic-time-display",children:c})}const U=require("@mui/material/Divider");var z,Q,X=e.n(U);function G(e){var t=!!document.fullscreenElement;return(0,n.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!t&&(0,n.jsx)(X(),{orientation:"vertical",flexItem:!0}),(0,n.jsx)(s(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}!function(e){e.Owner="owner",e.Member="member"}(z||(z={})),function(e){e.Human="human",e.Agent="agent"}(Q||(Q={}));const J=function(e){var t=(0,m.useState)(!1),a=t[0],o=t[1],l=(0,m.useState)(!1),d=l[0],f=l[1],p=(0,m.useState)(!0),v=p[0],y=p[1],b=(0,m.useState)(!!document.fullscreenElement),E=b[0],j=b[1],h=(0,m.useState)(!1),g=h[0],N=h[1],S=(0,m.useState)(""),T=S[0],k=S[1],P=(0,m.useState)(""),O=P[0],_=P[1],w=(0,m.useState)(0),B=w[0],C=w[1],U=(0,m.useRef)(null),z=(0,m.useRef)(null),Q=(0,r.useTheme)(),X=(0,r.useMediaQuery)(Q.breakpoints.down("md"));(0,m.useEffect)((function(){var e,t,n,r,a,i,o,c;function l(e){_(e),y(!1)}function s(){clearTimeout(c),c=setTimeout((function(){return N(!1)}),3e3)}null===(e=z.current)||void 0===e||e.addEventListener("timeupdate",(function(){z.current&&C(z.current.currentTime)})),null===(t=z.current)||void 0===t||t.addEventListener("canplay",(function(){_(""),y(!1)})),null===(n=z.current)||void 0===n||n.addEventListener("error",(function(){return l("Failed to load the video.")})),null===(r=z.current)||void 0===r||r.addEventListener("stalled",(function(){return l("Failed to fetch video data, but trying.")})),document.addEventListener("fullscreenchange",(function(){j(!!document.fullscreenElement)})),null===(a=U.current)||void 0===a||a.addEventListener("mousemove",(function(){N(!0),s()})),null===(i=U.current)||void 0===i||i.addEventListener("mouseleave",(function(){N(!1)})),null===(o=U.current)||void 0===o||o.addEventListener("keydown",(function(){N(!0),s()}))}),[]);var J={backgroundColor:Q.palette.background.paper,opacity:g?1:0};function K(){if(e.transcript&&a)return(0,n.jsx)(G,{transcript:e.transcript})}function W(){if(e.captions&&e.captions.length>0){var t=d?"captionsOff":"captionsOn";return(0,n.jsx)(F,{action:t,onClick:function(){return f(!d)}})}}function Y(){if(e.transcript)return(0,n.jsx)(M,{isTranscriptVisible:a,setIsTranscriptVisible:function(){return o(!a)}})}var Z=X?function(){return E?(0,n.jsx)(n.Fragment,{children:z.current&&U.current&&(0,n.jsxs)(u.Box,{className:"rustic-video-controls",sx:J,children:[(0,n.jsxs)(u.Box,{className:"rustic-video-top-controls",children:[(0,n.jsx)(L,{mediaElement:z.current,onError:k}),(0,n.jsx)(q,{mediaElement:z.current}),(0,n.jsx)(A,{elapsedTimeInSeconds:B,durationTimeInSeconds:z.current.duration})]}),(0,n.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,n.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,n.jsx)(D,{mediaElement:z.current,movement:"replay"}),(0,n.jsx)(D,{mediaElement:z.current,movement:"forward"}),W(),(0,n.jsx)(R,{mediaElement:z.current})]}),Y()]}),K()]})}):(0,n.jsx)(n.Fragment,{children:z.current&&U.current&&(0,n.jsxs)(u.Box,{className:"rustic-video-controls-mobile-preview",children:[(0,n.jsx)(L,{mediaElement:z.current,onError:k}),(0,n.jsxs)(u.Box,{className:"rustic-video-controls-right",children:[Y(),(0,n.jsx)(V,{element:U.current,onError:k})]})]})})}:function(){return(0,n.jsx)(n.Fragment,{children:z.current&&U.current&&(0,n.jsxs)(u.Box,{className:"rustic-video-controls",sx:J,children:[(0,n.jsx)(q,{mediaElement:z.current}),(0,n.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,n.jsxs)(u.Box,{className:"rustic-video-bottom-controls-left",children:[(0,n.jsx)(L,{mediaElement:z.current,onError:k}),(0,n.jsx)(D,{mediaElement:z.current,movement:"replay"}),(0,n.jsx)(D,{mediaElement:z.current,movement:"forward"}),W(),(0,n.jsx)(R,{mediaElement:z.current}),(0,n.jsx)(I,{mediaElement:z.current}),(0,n.jsx)(A,{elapsedTimeInSeconds:B,durationTimeInSeconds:z.current.duration,style:"condensed"})]}),(0,n.jsxs)(u.Box,{className:"rustic-video-bottom-controls-right",children:[Y(),(0,n.jsx)(H,{mediaElement:z.current,onError:k}),(0,n.jsx)(V,{element:U.current,onError:k})]})]}),E&&K()]})})};return O.length>0?(0,n.jsx)(i(),{severity:"error",children:O}):(0,n.jsxs)(u.Box,{className:"rustic-video",children:[v&&(0,n.jsx)(c(),{className:"rustic-video-loading-spinner"}),(0,n.jsxs)(u.Box,{ref:U,className:"rustic-video-screen",sx:{visibility:v?"hidden":"visible"},children:[T.length>0&&(0,n.jsx)(i(),{severity:"error",className:"rustic-control-error",onClose:function(){return k("")},children:T}),(!X||E)&&function(){if(z.current&&U.current)return(0,n.jsxs)(u.Box,{className:"rustic-video-title",sx:J,children:[(0,n.jsx)(s(),{variant:"body2",children:e.title}),E&&X&&(0,n.jsxs)(u.Box,{children:[(0,n.jsx)(H,{mediaElement:z.current,onError:k}),(0,n.jsx)(V,{element:U.current,onError:k})]})]})}(),(0,n.jsx)("video",{className:"rustic-video-element",ref:z,src:e.src,poster:e.poster,children:d&&(0,n.jsx)("track",{src:e.captions,kind:"captions",default:!0})}),Z()]}),!E&&K(),e.description&&(0,n.jsx)(x,{text:e.description})]})};return t})()));
1
+ !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["@rustic-ai/ui-components"]=n():e["@rustic-ai/ui-components"]=n()}(global,(()=>(()=>{"use strict";var e={n:n=>{var r=n&&n.__esModule?()=>n.default:()=>n;return e.d(r,{a:r}),r},d:(n,r)=>{for(var t in r)e.o(r,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:r[t]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{MessageProcessStatus:()=>z,ParticipantRole:()=>Q,ParticipantType:()=>X,default:()=>K});const r=require("react/jsx-runtime"),t=require("@mui/material"),a=require("@mui/material/Alert");var i=e.n(a);const o=require("@mui/material/CircularProgress");var c=e.n(o);const l=require("@mui/material/Typography");var s=e.n(l);const u=require("@mui/system"),m=require("react"),d=require("dompurify");var f=e.n(d);const p=require("marked");function v(e){var n=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=p.marked.parse(n,{async:!1});return f().sanitize(r)}const x=function(e){var n=(0,m.useState)(v(e.text)),t=n[0],a=n[1];return(0,m.useEffect)((function(){if(e.updatedData&&e.updatedData.length>0){var n=e.updatedData[e.updatedData.length-1].text;a(v(n))}}),[e.text,e.updatedData]),(0,r.jsx)(s(),{variant:"body1",className:"rustic-markdown",dangerouslySetInnerHTML:{__html:t}})},y=require("@mui/material/Box");var b=e.n(y);const E=require("@mui/material/Button");var j=e.n(E);const h=require("@mui/material/LinearProgress");var g=e.n(h);const N=require("@mui/material/Slider");var S=e.n(N);const T=require("@mui/material/Tooltip");var k,P=e.n(T);function O(e){var n=Math.floor(e/3600),r=Math.floor(e%3600/60),t=Math.floor(e%60),a=n>0?"".concat(n,":"):"",i="".concat(n>0?r.toString().padStart(2,"0"):r),o=t.toString().padStart(2,"0");return"".concat(a).concat(i,":").concat(o)}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(k||(k={}));var _=function(){return _=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var a in n=arguments[r])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e},_.apply(this,arguments)};function w(e){e.name.replaceAll("_","-");var n={};return e.color&&(n={color:e.color}),(0,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),style:_({},n),children:e.name})}const C=require("@mui/material/IconButton");var B=e.n(C);function F(e){var n,t={play:{symbol:"play_circle",label:"Play"},pause:{symbol:"pause_circle",label:"Pause"},forward:{symbol:"forward_10",label:"Forward ten seconds"},replay:{symbol:"replay_10",label:"Replay ten seconds"},volumeUp:{symbol:"volume_up",label:"Mute"},volumeOff:{symbol:"volume_off",label:"Unmute"},miniPlayer:{symbol:"picture_in_picture",label:"Mini player"},miniPlayerExit:{symbol:"picture_in_picture_off",label:"Exit mini player"},fullscreen:{symbol:"fullscreen",label:"Fullscreen"},fullscreenExit:{symbol:"fullscreen_exit",label:"Exit fullscreen"},captionsOn:{symbol:"closed_caption",label:"Show captions"},captionsOff:{symbol:"closed_caption_disabled",label:"Hide captions"}};return t[e.action].label.replaceAll(" ","-").toLowerCase(),(0,r.jsx)(P(),{title:t[e.action].label,PopperProps:{container:null!==(n=document.fullscreenElement)&&void 0!==n?n:document.body},children:(0,r.jsx)(B(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,r.jsx)(w,{name:t[e.action].symbol,className:"rustic-icon-large"})})})}function q(e){var n="dark"===(0,t.useTheme)().palette.mode,a=O(e.mediaElement.currentTime);return(0,r.jsxs)(b(),{className:"rustic-progress",children:[function(){for(var t=e.mediaElement.buffered,a=0,i=t.length-1;i>=0;--i){var o=t.start(i),c=t.end(i);if(o<e.mediaElement.currentTime){a=c;break}}var l=a/e.mediaElement.duration*100;return(0,r.jsx)(g(),{className:"rustic-progress-buffered",variant:"determinate",value:l,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:n?"secondary.light":"action.selected"}}})}(),(0,r.jsx)(S(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(a),max:e.mediaElement.duration,value:e.mediaElement.currentTime,onChange:function(n,r){e.mediaElement.currentTime=r},valueLabelDisplay:"auto",valueLabelFormat:function(e){return O(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function I(e){var n=(0,m.useState)(e.mediaElement.volume),t=n[0],a=n[1],i=(0,m.useState)(e.mediaElement.volume),o=i[0],c=i[1],l=e.mediaElement.muted?"volumeOff":"volumeUp";return(0,r.jsxs)(b(),{className:"rustic-volume-settings",children:[(0,r.jsx)(F,{onClick:function(){e.mediaElement.muted=!e.mediaElement.muted,e.mediaElement.muted?(c(e.mediaElement.volume),a(0)):a(o)},className:"rustic-mute-button",action:l}),(0,r.jsx)(S(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(100*t,"%"),value:t,onChange:function(n,r){var t=r;e.mediaElement.muted=0===t,e.mediaElement.volume=t,a(e.mediaElement.volume)}})]})}function M(e){var n=e.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",t="".concat(e.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,r.jsx)(j(),{className:"rustic-transcript-toggle",onClick:e.setIsTranscriptVisible,endIcon:(0,r.jsx)(w,{name:n}),children:(0,r.jsx)(s(),{variant:"overline",children:t})})}function L(e){var n=(0,m.useState)(!e.mediaElement.paused),t=n[0],a=n[1],i=t?"pause":"play";return e.mediaElement.onended=function(){a(!1)},e.mediaElement.onpause=function(){a(!1)},e.mediaElement.onplay=function(){a(!0)},(0,r.jsx)(F,{onClick:function(){t?e.mediaElement.pause():e.mediaElement.play().catch((function(n){e.onError("Failed to play the media. Error: ".concat(n.message))}))},action:i,className:"rustic-pause-play-icon"})}function R(e){var n,t=(0,m.useState)(e.mediaElement.playbackRate),a=t[0],i=t[1];return(0,r.jsx)(P(),{title:"Playback rate",PopperProps:{container:null!==(n=document.fullscreenElement)&&void 0!==n?n:document.body},children:(0,r.jsx)(j(),{onClick:function(){var n=1;e.mediaElement.playbackRate<2&&(n=e.mediaElement.playbackRate+.5),e.mediaElement.playbackRate=n,i(n)},className:"rustic-playback-rate-button",children:(0,r.jsxs)(s(),{variant:"body1",children:[a,"X"]})})})}function D(e){var n="replay"===e.movement,t=n?function(){e.mediaElement.currentTime-=10}:function(){e.mediaElement.currentTime+=10},a=n?"replay":"forward";return(0,r.jsx)(F,{onClick:t,action:a})}function H(e){var n=(0,m.useState)(!!document.pictureInPictureElement),t=n[0],a=n[1],i=e.mediaElement,o=t?"miniPlayerExit":"miniPlayer";return i.onleavepictureinpicture=function(){a(!1)},(0,r.jsx)(F,{onClick:function(){t?document.exitPictureInPicture().then((function(){a(!1)})).catch((function(n){e.onError("Failed to exit mini player. Error: ".concat(n.message))})):i.requestPictureInPicture().then((function(){a(!0)})).catch((function(n){e.onError("Failed to enter mini player. Error: ".concat(n.message))}))},action:o})}function V(e){var n=(0,m.useState)(!!document.fullscreenElement),t=n[0],a=n[1],i=e.element,o=t?"fullscreenExit":"fullscreen";return i.onfullscreenchange=function(){a(!!document.fullscreenElement)},(0,r.jsx)(F,{onClick:function(){t?document.exitFullscreen().then((function(){a(!1)})).catch((function(n){e.onError("Failed to exit fullscreen mode. Error: ".concat(n.message))})):i.requestFullscreen().then((function(){a(!0)})).catch((function(n){e.onError("Failed to enter fullscreen mode. Error: ".concat(n.message))}))},action:o})}function A(e){var n=e.style,t=void 0===n?"condensed":n,a=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)n.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(r[t[a]]=e[t[a]])}return r}(e,["style"]),i=O(a.elapsedTimeInSeconds),o=O(a.durationTimeInSeconds),c="".concat(i," / ").concat(o);return"wide"===t?(0,r.jsxs)(b(),{className:"rustic-time-container",children:[(0,r.jsx)(s(),{variant:"overline",children:i}),(0,r.jsx)(s(),{variant:"overline",children:o})]}):(0,r.jsx)(s(),{variant:"overline",className:"rustic-time-display",children:c})}const U=require("@mui/material/Divider");var z,Q,X,G=e.n(U);function J(e){var n=!!document.fullscreenElement;return(0,r.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!n&&(0,r.jsx)(G(),{orientation:"vertical",flexItem:!0}),(0,r.jsx)(s(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}!function(e){e.Running="running",e.Completed="completed",e.Error="error"}(z||(z={})),function(e){e.Owner="owner",e.Member="member"}(Q||(Q={})),function(e){e.Human="human",e.Agent="agent"}(X||(X={}));const K=function(e){var n=(0,m.useState)(!1),a=n[0],o=n[1],l=(0,m.useState)(!1),d=l[0],f=l[1],p=(0,m.useState)(!0),v=p[0],y=p[1],b=(0,m.useState)(!!document.fullscreenElement),E=b[0],j=b[1],h=(0,m.useState)(!1),g=h[0],N=h[1],S=(0,m.useState)(""),T=S[0],k=S[1],P=(0,m.useState)(""),O=P[0],_=P[1],w=(0,m.useState)(0),C=w[0],B=w[1],U=(0,m.useRef)(null),z=(0,m.useRef)(null),Q=(0,t.useTheme)(),X=(0,t.useMediaQuery)(Q.breakpoints.down("md"));(0,m.useEffect)((function(){var e,n,r,t,a,i,o,c;function l(e){_(e),y(!1)}function s(){clearTimeout(c),c=setTimeout((function(){return N(!1)}),3e3)}null===(e=z.current)||void 0===e||e.addEventListener("timeupdate",(function(){z.current&&B(z.current.currentTime)})),null===(n=z.current)||void 0===n||n.addEventListener("canplay",(function(){_(""),y(!1)})),null===(r=z.current)||void 0===r||r.addEventListener("error",(function(){return l("Failed to load the video.")})),null===(t=z.current)||void 0===t||t.addEventListener("stalled",(function(){return l("Failed to fetch video data, but trying.")})),document.addEventListener("fullscreenchange",(function(){j(!!document.fullscreenElement)})),null===(a=U.current)||void 0===a||a.addEventListener("mousemove",(function(){N(!0),s()})),null===(i=U.current)||void 0===i||i.addEventListener("mouseleave",(function(){N(!1)})),null===(o=U.current)||void 0===o||o.addEventListener("keydown",(function(){N(!0),s()}))}),[]);var G={backgroundColor:Q.palette.background.paper,opacity:g?1:0};function K(){if(e.transcript&&a)return(0,r.jsx)(J,{transcript:e.transcript})}function W(){if(e.captions&&e.captions.length>0){var n=d?"captionsOff":"captionsOn";return(0,r.jsx)(F,{action:n,onClick:function(){return f(!d)}})}}function Y(){if(e.transcript)return(0,r.jsx)(M,{isTranscriptVisible:a,setIsTranscriptVisible:function(){return o(!a)}})}var Z=X?function(){return E?(0,r.jsx)(r.Fragment,{children:z.current&&U.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls",sx:G,children:[(0,r.jsxs)(u.Box,{className:"rustic-video-top-controls",children:[(0,r.jsx)(L,{mediaElement:z.current,onError:k}),(0,r.jsx)(q,{mediaElement:z.current}),(0,r.jsx)(A,{elapsedTimeInSeconds:C,durationTimeInSeconds:z.current.duration})]}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,r.jsx)(D,{mediaElement:z.current,movement:"replay"}),(0,r.jsx)(D,{mediaElement:z.current,movement:"forward"}),W(),(0,r.jsx)(R,{mediaElement:z.current})]}),Y()]}),K()]})}):(0,r.jsx)(r.Fragment,{children:z.current&&U.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls-mobile-preview",children:[(0,r.jsx)(L,{mediaElement:z.current,onError:k}),(0,r.jsxs)(u.Box,{className:"rustic-video-controls-right",children:[Y(),(0,r.jsx)(V,{element:U.current,onError:k})]})]})})}:function(){return(0,r.jsx)(r.Fragment,{children:z.current&&U.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls",sx:G,children:[(0,r.jsx)(q,{mediaElement:z.current}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls-left",children:[(0,r.jsx)(L,{mediaElement:z.current,onError:k}),(0,r.jsx)(D,{mediaElement:z.current,movement:"replay"}),(0,r.jsx)(D,{mediaElement:z.current,movement:"forward"}),W(),(0,r.jsx)(R,{mediaElement:z.current}),(0,r.jsx)(I,{mediaElement:z.current}),(0,r.jsx)(A,{elapsedTimeInSeconds:C,durationTimeInSeconds:z.current.duration,style:"condensed"})]}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls-right",children:[Y(),(0,r.jsx)(H,{mediaElement:z.current,onError:k}),(0,r.jsx)(V,{element:U.current,onError:k})]})]}),E&&K()]})})};return O.length>0?(0,r.jsx)(i(),{severity:"error",children:O}):(0,r.jsxs)(u.Box,{className:"rustic-video",children:[v&&(0,r.jsx)(c(),{className:"rustic-video-loading-spinner"}),(0,r.jsxs)(u.Box,{ref:U,className:"rustic-video-screen",sx:{visibility:v?"hidden":"visible"},children:[T.length>0&&(0,r.jsx)(i(),{severity:"error",className:"rustic-control-error",onClose:function(){return k("")},children:T}),(!X||E)&&function(){if(z.current&&U.current)return(0,r.jsxs)(u.Box,{className:"rustic-video-title",sx:G,children:[(0,r.jsx)(s(),{variant:"body2",children:e.title}),E&&X&&(0,r.jsxs)(u.Box,{children:[(0,r.jsx)(H,{mediaElement:z.current,onError:k}),(0,r.jsx)(V,{element:U.current,onError:k})]})]})}(),(0,r.jsx)("video",{className:"rustic-video-element",ref:z,src:e.src,poster:e.poster,children:d&&(0,r.jsx)("track",{src:e.captions,kind:"captions",default:!0})}),Z()]}),!E&&K(),e.description&&(0,r.jsx)(x,{text:e.description})]})};return n})()));