@rustic-ai/ui-components 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/input/multimodal/multimodalInput/index.css +8 -0
- package/dist/components/input/multimodal/multimodalInput/index.js +1 -1
- package/dist/components/input/multimodal/multimodalInput/multimodalInput.d.ts.map +1 -1
- package/dist/components/input/textInput/index.js +1 -1
- package/dist/index.css +8 -0
- package/dist/index.js +1 -1
- package/package.json +3 -3
|
@@ -27,6 +27,14 @@
|
|
|
27
27
|
padding: 8px;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
.rustic-multimodal-input .rustic-error-container {
|
|
31
|
+
margin: 8px 16px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.rustic-multimodal-input .rustic-input-field {
|
|
35
|
+
border: none;
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
body {
|
|
31
39
|
margin: 0;
|
|
32
40
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,n={13:e=>{e.exports=require("emoji-picker-element")}},t={};function i(e){var r=t[e];if(void 0!==r)return r.exports;var o=t[e]={exports:{}};return n[e](o,o.exports,i),o.exports}i.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return i.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(n,t){if(1&t&&(n=this(n)),8&t)return n;if("object"==typeof n&&n){if(4&t&&n.__esModule)return n;if(16&t&&"function"==typeof n.then)return n}var o=Object.create(null);i.r(o);var a={};e=e||[null,r({}),r([]),r(r)];for(var c=2&t&&n;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>n[e]));return a.default=()=>n,i.d(o,a),o},i.d=(e,r)=>{for(var n in r)i.o(r,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{i.r(o),i.d(o,{default:()=>ae});const e=require("react/jsx-runtime"),r=require("@mui/material/Box");var n=i.n(r);const t=require("react"),a=require("uuid"),c=require("@mui/material/CircularProgress");var s=i.n(c);const l=require("@mui/material/IconButton");var u=i.n(l);const d=require("@mui/material/InputAdornment");var f=i.n(d);const m=require("@mui/material/MenuItem");var p=i.n(m);const h=require("@mui/material/MenuList");var v=i.n(h);const g=require("@mui/material/Popover");var x=i.n(g);const j=require("@mui/material/TextField");var b=i.n(j);const y=require("@mui/material/Tooltip");var w=i.n(y);const S=require("@mui/material/Typography");var C=i.n(S),k=i(13);function N(r){return r.name.replaceAll("_","-"),(0,e.jsx)("span",{className:"".concat(r.className?r.className+" ":"","material-symbols-rounded"),children:r.name})}const F=require("@mui/material/styles"),P=function(r){var n=(0,F.useTheme)(),o=(0,t.useRef)(null),a=(0,t.useRef)(null),c=(0,t.useState)(!1),s=c[0],l=c[1],d={"--indicator-color":n.palette.divider,"--background":n.palette.background.paper,"--input-border-color":n.palette.divider,"--outline-color":n.palette.secondary.main};function f(){l(!1)}function m(e){e.detail.unicode&&r.onEmojiClick(e.detail.unicode),f()}return(0,t.useEffect)((function(){a.current||"undefined"==typeof window||Promise.resolve().then(i.t.bind(i,13,23)).then((function(e){var r=new(0,e.Picker),t="dark"===n.palette.mode?"dark":"light";r.classList.add(t),Object.keys(d).forEach((function(e){r.style.setProperty(e,d[e])})),a.current=r})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,t.useEffect)((function(){return a.current&&a.current.addEventListener("emoji-click",m),function(){var e;null===(e=a.current)||void 0===e||e.removeEventListener("emoji-click",m)}}),[s,r.onEmojiClick]),(0,e.jsxs)("div",{children:[(0,e.jsx)(w(),{title:"Emoji",children:(0,e.jsx)(u(),{size:"small",ref:o,onClick:function(){l((function(e){return!e}))},sx:{color:r.buttonColor},children:(0,e.jsx)(N,{name:"Mood"})})}),a.current&&(0,e.jsx)(x(),{open:s,anchorEl:o.current,onClose:f,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,e.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&a.current&&!e.contains(a.current)&&e.appendChild(a.current)}})})]})};var O={"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 E(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var q=(0,t.forwardRef)((function(r,i){var o=(0,t.useState)(""),c=o[0],l=o[1],d=(0,t.useState)(!1),m=d[0],h=d[1],g=(0,t.useState)(!1),j=g[0],y=g[1],S=(0,t.useState)(!1),F=S[0],q=S[1],T=(0,t.useState)(""),z=T[0],_=T[1],R=(0,t.useState)([]),I=R[0],M=R[1],D=(0,t.useState)(!1),A=D[0],U=D[1],B=(0,t.useRef)(null),L=!c.trim().length&&!r.isSendEnabled,W="".concat(m?"Stop":"Start"," speech to text"),H=j?"primary.main":"primary.light",V=m?"error.main":H,$=m?"stop_circle":"speech_to_text";function G(e,r){if(void 0===r&&(r=!1),B.current){var n=B.current,t=n.selectionStart,i=n.selectionEnd;if("number"==typeof t&&"number"==typeof i){var o,a=c||"",s=a.substring(0,t),u=a.substring(i);o=r?s.replace(/:(\w+)$/,e)+u:s+e+u,l(o);var d=r?s.replace(/:(\w+)$/,e).length:t+e.length;setTimeout((function(){var e,r;null===(e=B.current)||void 0===e||e.focus(),null===(r=B.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}U(!1)}var K=new k.Database,Q=F?(0,e.jsx)(s(),{size:24}):(0,e.jsx)(w(),{title:W,children:(0,e.jsx)(u(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,m?(e.stop(),q(!0),h(!1)):(e.start(),_(""),h(!0)),e.onstart=function(){h(!0)},e.onresult=function(e){var r,n=e.results[0][0].transcript;c.length>0?l(c+" "+n):l(n),null===(r=B.current)||void 0===r||r.focus(),h(!1)},e.onerror=function(e){var r=O[e.error];_(r),h(!1)},e.onend=function(){q(!1),h(!1)}},size:"small",sx:{color:V},children:(0,e.jsx)(N,{name:$})})});function Y(){var e=(new Date).toISOString(),n={id:(0,a.v4)(),timestamp:e,sender:r.sender,conversationId:r.conversationId,format:"text",data:{text:c}};r.send(n),l(""),_("")}return(0,e.jsxs)(n(),{className:"rustic-base-input",ref:i,children:[(0,e.jsxs)(n(),{className:"rustic-error-and-input-container",children:[(0,e.jsx)(n(),{className:"rustic-error-container",children:(0,e.jsx)(C(),{variant:"caption",color:"error",className:"rustic-error-message",children:z})}),(0,e.jsxs)(n(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:j?"secondary.main":"action.disabled"},children:[I.length>0&&(0,e.jsx)(x(),{open:A,anchorEl:B.current,onClose:function(){return U(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,e.jsx)(v(),{children:I.map((function(r,n){return"unicode"in r&&(0,e.jsx)(p(),{onClick:function(){return G(r.unicode,!0)},children:E(r)},n)}))})}),(0,e.jsx)(b(),{className:"rustic-text-field",variant:"outlined",value:c,label:r.label,placeholder:r.placeholder,maxRows:r.maxRows,multiline:r.multiline,fullWidth:r.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!L&&Y())},onChange:function(e){_("");var n=e.target.value;l(n);var t,i=n.match(/:(\w{2,}):/g),o=n.match(/:(\w{2,})/g);if(i){var a=i[0].replace(/:/g,"");K.getEmojiByShortcode(a).then((function(e){if(e&&"unicode"in e){var r=n.replace(i[0],e.unicode);l(r)}else l(n)})).catch((function(){l(n)})),U(!1)}else o?(t=o[0].replace(":",""),K.getEmojiBySearchQuery(t).then((function(e){e.length?(M(e.slice(0,r.maximumEmojiSearchResults)),U(!0)):(M([]),U(!1))})).catch((function(){M([]),U(!1)}))):U(!1)},onFocus:function(){return y(!0)},onBlur:function(){return y(!1)},inputRef:B,color:"secondary",size:"small",InputProps:{endAdornment:(0,e.jsxs)(f(),{position:"end",children:[(0,e.jsx)(P,{onEmojiClick:G,buttonColor:H}),r.enableSpeechToText&&Q]})},InputLabelProps:{className:j?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,e.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,e.jsxs)(n(),{className:"rustic-input-actions",children:[r.children,(0,e.jsx)(w(),{title:"Send",children:(0,e.jsx)("span",{className:"rustic-send-button",children:(0,e.jsx)(u(),{"aria-label":"send message",onClick:Y,disabled:L,color:"primary",children:(0,e.jsx)(N,{name:"send"})})})})]})]})}));q.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const T=q,z=require("@mui/material/LinearProgress");var _=i.n(z);const R=require("axios");var I=i.n(R);const M=require("react-dom"),D=require("@mui/material/Card");var A=i.n(D);const U=require("@mui/material/Modal");var B,L=i.n(U);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(B||(B={}));const W=require("@mui/material/useMediaQuery");var H=i.n(W);const V=require("@mui/system/Stack");var $=i.n(V);const G=require("@mui/system/useTheme");var K=i.n(G);const Q=require("pdfjs-dist"),Y=function(r){var n={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=(n[r.action].label.replaceAll(" ","-").toLowerCase(),n[r.action]);return(0,e.jsx)(w(),{title:t.label,children:(0,e.jsx)("span",{children:(0,e.jsx)(u(),{onClick:r.onClick,className:r.className,disabled:r.isDisabled,children:(0,e.jsx)(N,{name:t.symbol})})})})};var Z={pdf:function(r){var i,o=(0,t.useRef)(null),a=(0,t.useState)(1),c=a[0],s=a[1],l=(0,t.useState)(1),u=l[0],d=l[1],f=(0,t.useState)(1),m=f[0],p=f[1],h=(0,t.useState)(!1),v=h[0],g=h[1],x=(0,t.useState)(),j=x[0],y=x[1],w=K()(),S=H()(w.breakpoints.down("sm")),k=H()(w.breakpoints.between("sm","md"));if(i=r.url,!/\/[^/]+\.pdf$/.test(i))return(0,e.jsx)(A(),{variant:"outlined",className:"rustic-pdf-error",children:(0,e.jsx)(C(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var N=(0,t.useState)((function(){return S?.5:k?1:1.5})),F=N[0],P=N[1];return(0,t.useEffect)((function(){Q.GlobalWorkerOptions.workerSrc||(Q.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(Q.version,"/pdf.worker.mjs")),Q.getDocument({url:"".concat(r.url)}).promise.then((function(e){d(e.numPages),function(e){e.getPage(c).then((function(e){var r=e.getViewport({scale:F}),n=o.current;if(n){var t=n.getContext("2d");if(t){var i=window.devicePixelRatio||1;n.style.width="".concat(r.width,"px"),n.style.height="".concat(r.height,"px"),n.width=r.width*i,n.height=r.height*i;var a={canvasContext:t,viewport:r,transform:[i,0,0,i,0,0]};j&&j.cancel();var c=e.render(a);y(c),c.promise.then((function(){y(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[r.url,c,F]),v?(0,e.jsx)(A(),{variant:"outlined",className:"rustic-pdf-error",children:(0,e.jsx)(C(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,e.jsxs)(A(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,e.jsxs)(n(),{className:"rustic-pdf-viewer-header",children:[(0,e.jsx)(Y,{action:"zoomOut",onClick:function(){P((function(e){return Math.max(e-.2,.2)}))}}),(0,e.jsx)(Y,{action:"zoomIn",onClick:function(){P((function(e){return e+.2}))}})]}),(0,e.jsx)(n(),{className:"rustic-pdf-viewer-body",children:(0,e.jsx)(n(),{className:"rustic-pdf-viewer-body-inner",children:(0,e.jsx)("canvas",{ref:o})})}),(0,e.jsxs)($(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,e.jsx)(Y,{action:"previousPage",onClick:function(){c>1&&(s(c-1),p(c-1))},isDisabled:1===c}),(0,e.jsx)(C(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,e.jsx)(b(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=u&&s(r)},size:"small",className:"rustic-pdf-page-input"}),(0,e.jsxs)(C(),{variant:"body1",className:"rustic-page-indicator",children:["of ",u]}),(0,e.jsx)(Y,{action:"nextPage",onClick:function(){c<u&&(s(c+1),p(c+1))},isDisabled:c===u})]})]})}};function J(r){var n=(0,F.useTheme)(),i=(0,t.useState)(!1),o=i[0],a=i[1];function c(){a(!1)}var s,l,d=r.file.url&&(s=r.file.url.split("."))[s.length-1].toLowerCase(),f=d&&r.supportedViewers?r.supportedViewers[d]:null,m=!!f;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(A(),{className:"rustic-file-preview".concat(m?" rustic-cursor-pointer":""),variant:"outlined",sx:{boxShadow:n.shadows[1]},onClick:function(){a(!0)},children:[(0,e.jsx)(C(),{variant:"subtitle2",children:(l=r.file.name,15,l.length<=15?l:l.substring(0,12)+"...")}),(0,e.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:r.children})]}),m&&(0,e.jsx)(L(),{open:o,onClose:c,className:"rustic-file-preview-modal",children:(0,e.jsxs)("div",{className:"rustic-modal-content",children:[(0,e.jsx)(w(),{title:"Close",children:(0,e.jsx)(u(),{onClick:c,className:"rustic-close-button",children:(0,e.jsx)(N,{name:"close"})})}),r.file.url&&(0,e.jsx)(f,{url:r.file.url})]})})]})}J.defaultProps={supportedViewers:Z};var X=function(){return X=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var i in r=arguments[n])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e},X.apply(this,arguments)},ee=function(e,r,n){if(n||2===arguments.length)for(var t,i=0,o=r.length;i<o;i++)!t&&i in r||(t||(t=Array.prototype.slice.call(r,0,i)),t[i]=r[i]);return e.concat(t||Array.prototype.slice.call(r))};function re(e){for(var r=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<r.length-1;)e/=1024,n++;var t=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(t," ").concat(r[n])}const ne=function(r){var i=(0,t.useState)([]),o=i[0],c=i[1],s=(0,t.useState)([]),l=s[0],d=s[1],f=(0,t.useRef)({}),m=(0,a.v4)();(0,t.useEffect)((function(){c([]),d([]),f.current={}}),[r.messageId]);var p=(0,e.jsx)(n(),{className:"rustic-files rustic-padding-16",children:o.map((function(t,i){return(0,e.jsx)(J,{file:{name:t.name},children:(0,e.jsxs)(n(),{className:"rustic-flex-center",children:[t.loadingProgress<100&&(0,e.jsx)(_(),{variant:"determinate",color:"secondary",value:t.loadingProgress,className:"rustic-upload-progress"}),(0,e.jsx)(w(),{title:"Delete",children:(0,e.jsx)(u(),{color:"primary",onClick:function(){return function(e,n){var t,i;d([]);var o=e.name;if(f.current=X(X({},f.current),((t={})[o]=f.current[o]--,t)),r.onFileUpdate("remove",o),100===e.loadingProgress){var a="".concat(r.deleteFileEndpoint,"?message-id=").concat(r.messageId,"&file-id=").concat(e.id);I().delete(a).then((function(){return c((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return r.onFileUpdate("add",o),d((function(e){return ee(ee([],e,!0),["Failed to delete ".concat(o,". Please try again.")],!1)}))}))}else e.abortController.abort(),c((function(e){return e.filter((function(e,r){return r!==n}))})),f.current=X(X({},f.current),((i={})[o]=f.current[o]++,i))}(t,i)},className:"rustic-delete-button","aria-label":"cancel file upload",children:(0,e.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},i)}))}),h=(0,e.jsx)(n(),{children:l.map((function(r,n){return(0,e.jsx)(C(),{variant:"caption",color:"error",className:"rustic-error-message",children:r},n)}))});function v(e,r){return r?(0,M.createPortal)(e,r):e}return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(n(),{className:"rustic-uploader",children:[(0,e.jsx)("label",{htmlFor:m,children:(0,e.jsx)(w(),{title:"Upload",children:(0,e.jsx)(u(),{component:"span","aria-label":"Upload file",color:"primary",children:(0,e.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,e.jsx)("input",{type:"file",id:m,onChange:function(e){d([]);var n=e.target.files&&Array.from(e.target.files),t=o.length+(n?n.length:0);r.maxFileCount&&t>r.maxFileCount&&d((function(e){return ee(ee([],e,!0),["You can only upload ".concat(r.maxFileCount," files.")],!1)}));var i=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,t,r.maxFileCount);i&&i.forEach((function(e){!function(e){var n;r.maxFileSize&&e.size>r.maxFileSize?(n=e.name,d((function(e){return ee(ee([],e,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(r.maxFileSize&&re(r.maxFileSize),".")],!1)}))):function(e){var n=new FormData,t=new AbortController,i=function(e){var r,n,t=e.name,i=f.current[t];if(i){var o=i+1,a=t.lastIndexOf("."),c=t.substring(0,a),s=t.substring(a);t="".concat(c,"(").concat(i,")").concat(s),f.current=X(X({},f.current),((r={})[e.name]=o,r))}else f.current=X(X({},f.current),((n={})[e.name]=1,n));return t}(e),o=new File([e],i,{type:e.type});n.append("file",o);var s=(0,a.v4)(),l={name:i,loadingProgress:0,abortController:t,id:s};c((function(e){return ee(ee([],e,!0),[l],!1)})),r.onFileUpdate("add",i);var u="".concat(r.uploadFileEndpoint,"?message-id=").concat(r.messageId);I().post(u,n,{onUploadProgress:function(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=l.id,c((function(e){var t=e.map((function(e){return e.id===n?X(X({},e),{loadingProgress:r}):e}));return t})))},signal:t.signal}).then((function(e){var r,n;r=e.data,n=l.id,c((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var i=ee([],e,!0);return i[t]=X(X({},i[t]),{id:r.fileId}),i}return e}))})).catch((function(n){var t,o;r.onFileUpdate("remove",i),f.current=X(X({},f.current),((t={})[i]=f.current[e.name]--,t)),function(e,r,n){d((function(r){return ee(ee([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),c((function(e){return e.filter((function(e){return e.id!==r}))}))}(e.name,l.id,null===(o=n.response)||void 0===o?void 0:o.data)}))}(e)}(e)})),e.target.value=""},multiple:!0,accept:r.acceptedFileTypes})]}),l.length>0&&v(h,r.errorMessagesContainer),o.length>0&&v(p,r.filePreviewsContainer)]})};var te=function(){return te=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var i in r=arguments[n])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e},te.apply(this,arguments)},ie=function(e,r,n){if(n||2===arguments.length)for(var t,i=0,o=r.length;i<o;i++)!t&&i in r||(t||(t=Array.prototype.slice.call(r,0,i)),t[i]=r[i]);return e.concat(t||Array.prototype.slice.call(r))};function oe(r){var i=(0,t.useState)([]),o=i[0],c=i[1],s=(0,t.useState)((0,a.v4)()),l=s[0],u=s[1],d=(0,t.useState)(),f=d[0],m=d[1],p=(0,t.useState)(),h=p[0],v=p[1],g=(0,t.useRef)(null),x=o.length>0;return(0,t.useEffect)((function(){g.current&&(v(g.current.querySelector(".rustic-error-container")),m(g.current.querySelector(".rustic-input-extras")))})),(0,e.jsx)(n(),{className:"rustic-multimodal-input",children:(0,e.jsx)(T,te({},r,{send:function(e){x&&(e.id=l,e.format="filesWithText",e.data.files=o),r.ws.send(e),u((0,a.v4)()),c([])},isSendEnabled:x,ref:g,children:(0,e.jsx)(n(),{className:"rustic-bottom-buttons",children:(0,e.jsx)(ne,{acceptedFileTypes:r.acceptedFileTypes,maxFileCount:r.maxFileCount,maxFileSize:r.maxFileSize,uploadFileEndpoint:r.uploadFileEndpoint,deleteFileEndpoint:r.deleteFileEndpoint,onFileUpdate:function(e,r){c("add"===e?function(e){return ie(ie([],e,!0),[{name:r}],!1)}:function(e){return e.filter((function(e){return e.name!==r}))})},messageId:l,filePreviewsContainer:f,errorMessagesContainer:h})})}))})}oe.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1};const ae=oe})(),o})()));
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,n={13:e=>{e.exports=require("emoji-picker-element")}},t={};function i(e){var r=t[e];if(void 0!==r)return r.exports;var o=t[e]={exports:{}};return n[e](o,o.exports,i),o.exports}i.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return i.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(n,t){if(1&t&&(n=this(n)),8&t)return n;if("object"==typeof n&&n){if(4&t&&n.__esModule)return n;if(16&t&&"function"==typeof n.then)return n}var o=Object.create(null);i.r(o);var a={};e=e||[null,r({}),r([]),r(r)];for(var c=2&t&&n;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>n[e]));return a.default=()=>n,i.d(o,a),o},i.d=(e,r)=>{for(var n in r)i.o(r,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{i.r(o),i.d(o,{default:()=>ce});const e=require("react/jsx-runtime"),r=require("@mui/material/Box");var n=i.n(r);const t=require("@mui/material/styles"),a=require("react"),c=require("uuid"),s=require("@mui/material/CircularProgress");var l=i.n(s);const u=require("@mui/material/IconButton");var d=i.n(u);const f=require("@mui/material/InputAdornment");var m=i.n(f);const p=require("@mui/material/MenuItem");var h=i.n(p);const v=require("@mui/material/MenuList");var g=i.n(v);const x=require("@mui/material/Popover");var j=i.n(x);const b=require("@mui/material/TextField");var y=i.n(b);const w=require("@mui/material/Tooltip");var S=i.n(w);const C=require("@mui/material/Typography");var k=i.n(C),N=i(13);function F(r){return r.name.replaceAll("_","-"),(0,e.jsx)("span",{className:"".concat(r.className?r.className+" ":"","material-symbols-rounded"),children:r.name})}const P=function(r){var n=(0,t.useTheme)(),o=(0,a.useRef)(null),c=(0,a.useRef)(null),s=(0,a.useState)(!1),l=s[0],u=s[1],f={"--indicator-color":n.palette.divider,"--background":n.palette.background.paper,"--input-border-color":n.palette.divider,"--outline-color":n.palette.secondary.main};function m(){u(!1)}function p(e){e.detail.unicode&&r.onEmojiClick(e.detail.unicode),m()}return(0,a.useEffect)((function(){c.current||"undefined"==typeof window||Promise.resolve().then(i.t.bind(i,13,23)).then((function(e){var r=new(0,e.Picker),t="dark"===n.palette.mode?"dark":"light";r.classList.add(t),Object.keys(f).forEach((function(e){r.style.setProperty(e,f[e])})),c.current=r})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,a.useEffect)((function(){return c.current&&c.current.addEventListener("emoji-click",p),function(){var e;null===(e=c.current)||void 0===e||e.removeEventListener("emoji-click",p)}}),[l,r.onEmojiClick]),(0,e.jsxs)("div",{children:[(0,e.jsx)(S(),{title:"Emoji",children:(0,e.jsx)(d(),{size:"small",ref:o,onClick:function(){u((function(e){return!e}))},sx:{color:r.buttonColor},children:(0,e.jsx)(F,{name:"Mood"})})}),c.current&&(0,e.jsx)(j(),{open:l,anchorEl:o.current,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,e.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&c.current&&!e.contains(c.current)&&e.appendChild(c.current)}})})]})};var O={"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 E(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var q=new N.Database,T=(0,a.forwardRef)((function(r,t){var i=(0,a.useState)(""),o=i[0],s=i[1],u=(0,a.useState)(!1),f=u[0],p=u[1],v=(0,a.useState)(!1),x=v[0],b=v[1],w=(0,a.useState)(!1),C=w[0],N=w[1],T=(0,a.useState)(""),z=T[0],R=T[1],_=(0,a.useState)([]),I=_[0],M=_[1],D=(0,a.useState)(!1),A=D[0],U=D[1],B=(0,a.useRef)(null),L=!o.trim().length&&!r.isSendEnabled,W="".concat(f?"Stop":"Start"," speech to text"),H=x?"primary.main":"primary.light",V=f?"error.main":H,$=f?"stop_circle":"speech_to_text";function G(e,r){if(void 0===r&&(r=!1),B.current){var n=B.current,t=n.selectionStart,i=n.selectionEnd;if("number"==typeof t&&"number"==typeof i){var a,c=o||"",l=c.substring(0,t),u=c.substring(i);a=r?l.replace(/:(\w+)$/,e)+u:l+e+u,s(a);var d=r?l.replace(/:(\w+)$/,e).length:t+e.length;setTimeout((function(){var e,r;null===(e=B.current)||void 0===e||e.focus(),null===(r=B.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}U(!1)}var K=C?(0,e.jsx)(l(),{size:24}):(0,e.jsx)(S(),{title:W,children:(0,e.jsx)(d(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,f?(e.stop(),N(!0),p(!1)):(e.start(),R(""),p(!0)),e.onstart=function(){p(!0)},e.onresult=function(e){var r,n=e.results[0][0].transcript;o.length>0?s(o+" "+n):s(n),null===(r=B.current)||void 0===r||r.focus(),p(!1)},e.onerror=function(e){var r=O[e.error];R(r),p(!1)},e.onend=function(){N(!1),p(!1)}},size:"small",sx:{color:V},children:(0,e.jsx)(F,{name:$})})});function Q(){var e=(new Date).toISOString(),n={id:(0,c.v4)(),timestamp:e,sender:r.sender,conversationId:r.conversationId,format:"text",data:{text:o}};r.send(n),s(""),R("")}return(0,e.jsxs)(n(),{className:"rustic-base-input",ref:t,children:[(0,e.jsxs)(n(),{className:"rustic-error-and-input-container",children:[(0,e.jsx)(n(),{className:"rustic-error-container",children:(0,e.jsx)(k(),{variant:"caption",color:"error",className:"rustic-error-message",children:z})}),(0,e.jsxs)(n(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:x?"secondary.main":"action.disabled"},children:[I.length>0&&(0,e.jsx)(j(),{open:A,anchorEl:B.current,onClose:function(){return U(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,e.jsx)(g(),{children:I.map((function(r,n){return"unicode"in r&&(0,e.jsx)(h(),{onClick:function(){return G(r.unicode,!0)},children:E(r)},n)}))})}),(0,e.jsx)(y(),{className:"rustic-text-field",variant:"outlined",value:o,label:r.label,placeholder:r.placeholder,maxRows:r.maxRows,multiline:r.multiline,fullWidth:r.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!L&&Q())},onChange:function(e){R("");var n=e.target.value;s(n);var t,i=n.match(/:(\w{2,}):/g),o=n.match(/:(\w{2,})/g);if(i){var a=i[0].replace(/:/g,"");q.getEmojiByShortcode(a).then((function(e){if(e&&"unicode"in e){var r=n.replace(i[0],e.unicode);s(r)}else s(n)})).catch((function(){s(n)})),U(!1)}else o?(t=o[0].replace(":",""),q.getEmojiBySearchQuery(t).then((function(e){e.length?(M(e.slice(0,r.maximumEmojiSearchResults)),U(!0)):(M([]),U(!1))})).catch((function(){M([]),U(!1)}))):U(!1)},onFocus:function(){return b(!0)},onBlur:function(){return b(!1)},inputRef:B,color:"secondary",size:"small",InputProps:{endAdornment:(0,e.jsxs)(m(),{position:"end",children:[(0,e.jsx)(P,{onEmojiClick:G,buttonColor:H}),r.enableSpeechToText&&K]})},InputLabelProps:{className:x?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,e.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,e.jsxs)(n(),{className:"rustic-input-actions",children:[r.children,(0,e.jsx)(S(),{title:"Send",children:(0,e.jsx)("span",{className:"rustic-send-button",children:(0,e.jsx)(d(),{"aria-label":"send message",onClick:Q,disabled:L,color:"primary",children:(0,e.jsx)(F,{name:"send"})})})})]})]})}));T.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const z=T,R=require("@mui/material/LinearProgress");var _=i.n(R);const I=require("axios");var M=i.n(I);const D=require("react-dom"),A=require("@mui/material/Card");var U=i.n(A);const B=require("@mui/material/Modal");var L,W=i.n(B);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(L||(L={}));const H=require("@mui/material/useMediaQuery");var V=i.n(H);const $=require("@mui/system/Stack");var G=i.n($);const K=require("@mui/system/useTheme");var Q=i.n(K);const Y=require("pdfjs-dist"),Z=function(r){var n={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=(n[r.action].label.replaceAll(" ","-").toLowerCase(),n[r.action]);return(0,e.jsx)(S(),{title:t.label,children:(0,e.jsx)("span",{children:(0,e.jsx)(d(),{onClick:r.onClick,className:r.className,disabled:r.isDisabled,children:(0,e.jsx)(F,{name:t.symbol})})})})};var J={pdf:function(r){var t,i=(0,a.useRef)(null),o=(0,a.useState)(1),c=o[0],s=o[1],l=(0,a.useState)(1),u=l[0],d=l[1],f=(0,a.useState)(1),m=f[0],p=f[1],h=(0,a.useState)(!1),v=h[0],g=h[1],x=(0,a.useState)(),j=x[0],b=x[1],w=Q()(),S=V()(w.breakpoints.down("sm")),C=V()(w.breakpoints.between("sm","md"));if(t=r.url,!/\/[^/]+\.pdf$/.test(t))return(0,e.jsx)(U(),{variant:"outlined",className:"rustic-pdf-error",children:(0,e.jsx)(k(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var N=(0,a.useState)((function(){return S?.5:C?1:1.5})),F=N[0],P=N[1];return(0,a.useEffect)((function(){Y.GlobalWorkerOptions.workerSrc||(Y.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(Y.version,"/pdf.worker.mjs")),Y.getDocument({url:"".concat(r.url)}).promise.then((function(e){d(e.numPages),function(e){e.getPage(c).then((function(e){var r=e.getViewport({scale:F}),n=i.current;if(n){var t=n.getContext("2d");if(t){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 a={canvasContext:t,viewport:r,transform:[o,0,0,o,0,0]};j&&j.cancel();var c=e.render(a);b(c),c.promise.then((function(){b(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[r.url,c,F]),v?(0,e.jsx)(U(),{variant:"outlined",className:"rustic-pdf-error",children:(0,e.jsx)(k(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,e.jsxs)(U(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,e.jsxs)(n(),{className:"rustic-pdf-viewer-header",children:[(0,e.jsx)(Z,{action:"zoomOut",onClick:function(){P((function(e){return Math.max(e-.2,.2)}))}}),(0,e.jsx)(Z,{action:"zoomIn",onClick:function(){P((function(e){return e+.2}))}})]}),(0,e.jsx)(n(),{className:"rustic-pdf-viewer-body",children:(0,e.jsx)(n(),{className:"rustic-pdf-viewer-body-inner",children:(0,e.jsx)("canvas",{ref:i})})}),(0,e.jsxs)(G(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,e.jsx)(Z,{action:"previousPage",onClick:function(){c>1&&(s(c-1),p(c-1))},isDisabled:1===c}),(0,e.jsx)(k(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,e.jsx)(y(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=u&&s(r)},size:"small",className:"rustic-pdf-page-input"}),(0,e.jsxs)(k(),{variant:"body1",className:"rustic-page-indicator",children:["of ",u]}),(0,e.jsx)(Z,{action:"nextPage",onClick:function(){c<u&&(s(c+1),p(c+1))},isDisabled:c===u})]})]})}};function X(r){var n=(0,t.useTheme)(),i=(0,a.useState)(!1),o=i[0],c=i[1];function s(){c(!1)}var l,u,f=r.file.url&&(l=r.file.url.split("."))[l.length-1].toLowerCase(),m=f&&r.supportedViewers?r.supportedViewers[f]:null,p=!!m;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(U(),{className:"rustic-file-preview".concat(p?" rustic-cursor-pointer":""),variant:"outlined",sx:{boxShadow:n.shadows[1]},onClick:function(){c(!0)},children:[(0,e.jsx)(k(),{variant:"subtitle2",children:(u=r.file.name,15,u.length<=15?u:u.substring(0,12)+"...")}),(0,e.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:r.children})]}),p&&(0,e.jsx)(W(),{open:o,onClose:s,className:"rustic-file-preview-modal",children:(0,e.jsxs)("div",{className:"rustic-modal-content",children:[(0,e.jsx)(S(),{title:"Close",children:(0,e.jsx)(d(),{onClick:s,className:"rustic-close-button",children:(0,e.jsx)(F,{name:"close"})})}),r.file.url&&(0,e.jsx)(m,{url:r.file.url})]})})]})}X.defaultProps={supportedViewers:J};var ee=function(){return ee=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var i in r=arguments[n])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e},ee.apply(this,arguments)},re=function(e,r,n){if(n||2===arguments.length)for(var t,i=0,o=r.length;i<o;i++)!t&&i in r||(t||(t=Array.prototype.slice.call(r,0,i)),t[i]=r[i]);return e.concat(t||Array.prototype.slice.call(r))};function ne(e){for(var r=["Bytes","KB","MB","GB"],n=0;e>=1024&&n<r.length-1;)e/=1024,n++;var t=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(t," ").concat(r[n])}const te=function(r){var t=(0,a.useState)([]),i=t[0],o=t[1],s=(0,a.useState)([]),l=s[0],u=s[1],f=(0,a.useRef)({}),m=(0,c.v4)();(0,a.useEffect)((function(){o([]),u([]),f.current={}}),[r.messageId]);var p=(0,e.jsx)(n(),{className:"rustic-files rustic-padding-16",children:i.map((function(t,i){return(0,e.jsx)(X,{file:{name:t.name},children:(0,e.jsxs)(n(),{className:"rustic-flex-center",children:[t.loadingProgress<100&&(0,e.jsx)(_(),{variant:"determinate",color:"secondary",value:t.loadingProgress,className:"rustic-upload-progress"}),(0,e.jsx)(S(),{title:"Delete",children:(0,e.jsx)(d(),{color:"primary",onClick:function(){return function(e,n){var t,i;u([]);var a=e.name;if(f.current=ee(ee({},f.current),((t={})[a]=f.current[a]--,t)),r.onFileUpdate("remove",a),100===e.loadingProgress){var c="".concat(r.deleteFileEndpoint,"?message-id=").concat(r.messageId,"&file-id=").concat(e.id);M().delete(c).then((function(){return o((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return r.onFileUpdate("add",a),u((function(e){return re(re([],e,!0),["Failed to delete ".concat(a,". Please try again.")],!1)}))}))}else e.abortController.abort(),o((function(e){return e.filter((function(e,r){return r!==n}))})),f.current=ee(ee({},f.current),((i={})[a]=f.current[a]++,i))}(t,i)},className:"rustic-delete-button","aria-label":"cancel file upload",children:(0,e.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},i)}))}),h=(0,e.jsx)(n(),{children:l.map((function(r,n){return(0,e.jsx)(k(),{variant:"caption",color:"error",className:"rustic-error-message",children:r},n)}))});function v(e,r){return r?(0,D.createPortal)(e,r):e}return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(n(),{className:"rustic-uploader",children:[(0,e.jsx)("label",{htmlFor:m,children:(0,e.jsx)(S(),{title:"Upload",children:(0,e.jsx)(d(),{component:"span","aria-label":"Upload file",color:"primary",children:(0,e.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,e.jsx)("input",{type:"file",id:m,onChange:function(e){u([]);var n=e.target.files&&Array.from(e.target.files),t=i.length+(n?n.length:0);r.maxFileCount&&t>r.maxFileCount&&u((function(e){return re(re([],e,!0),["You can only upload ".concat(r.maxFileCount," files.")],!1)}));var a=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,t,r.maxFileCount);a&&a.forEach((function(e){!function(e){var n;r.maxFileSize&&e.size>r.maxFileSize?(n=e.name,u((function(e){return re(re([],e,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(r.maxFileSize&&ne(r.maxFileSize),".")],!1)}))):function(e){var n=new FormData,t=new AbortController,i=function(e){var r,n,t=e.name,i=f.current[t];if(i){var o=i+1,a=t.lastIndexOf("."),c=t.substring(0,a),s=t.substring(a);t="".concat(c,"(").concat(i,")").concat(s),f.current=ee(ee({},f.current),((r={})[e.name]=o,r))}else f.current=ee(ee({},f.current),((n={})[e.name]=1,n));return t}(e),a=new File([e],i,{type:e.type});n.append("file",a);var s=(0,c.v4)(),l={name:i,loadingProgress:0,abortController:t,id:s};o((function(e){return re(re([],e,!0),[l],!1)})),r.onFileUpdate("add",i);var d="".concat(r.uploadFileEndpoint,"?message-id=").concat(r.messageId);M().post(d,n,{onUploadProgress:function(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=l.id,o((function(e){var t=e.map((function(e){return e.id===n?ee(ee({},e),{loadingProgress:r}):e}));return t})))},signal:t.signal}).then((function(e){var r,n;r=e.data,n=l.id,o((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var i=re([],e,!0);return i[t]=ee(ee({},i[t]),{id:r.fileId}),i}return e}))})).catch((function(n){var t,a;r.onFileUpdate("remove",i),f.current=ee(ee({},f.current),((t={})[i]=f.current[e.name]--,t)),function(e,r,n){u((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.name,l.id,null===(a=n.response)||void 0===a?void 0:a.data)}))}(e)}(e)})),e.target.value=""},multiple:!0,accept:r.acceptedFileTypes})]}),l.length>0&&v(h,r.errorMessagesContainer),i.length>0&&v(p,r.filePreviewsContainer)]})};var ie=function(){return ie=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var i in r=arguments[n])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e},ie.apply(this,arguments)},oe=function(e,r,n){if(n||2===arguments.length)for(var t,i=0,o=r.length;i<o;i++)!t&&i in r||(t||(t=Array.prototype.slice.call(r,0,i)),t[i]=r[i]);return e.concat(t||Array.prototype.slice.call(r))};function ae(r){var i=(0,a.useState)([]),o=i[0],s=i[1],l=(0,a.useState)((0,c.v4)()),u=l[0],d=l[1],f=(0,a.useState)(),m=f[0],p=f[1],h=(0,a.useState)(),v=h[0],g=h[1],x=(0,a.useRef)(null),j=(0,t.useTheme)(),b=o.length>0;return(0,a.useEffect)((function(){x.current&&(g(x.current.querySelector(".rustic-error-container")),p(x.current.querySelector(".rustic-input-extras")))})),(0,e.jsx)(n(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(j.palette.action.disabled),borderRadius:"".concat(j.shape.borderRadius,"px"),":focus-within":{borderColor:j.palette.secondary.main}},children:(0,e.jsx)(z,ie({},r,{send:function(e){b&&(e.id=u,e.format="filesWithText",e.data.files=o),r.ws.send(e),d((0,c.v4)()),s([])},isSendEnabled:b,ref:x,children:(0,e.jsx)(n(),{className:"rustic-bottom-buttons",children:(0,e.jsx)(te,{acceptedFileTypes:r.acceptedFileTypes,maxFileCount:r.maxFileCount,maxFileSize:r.maxFileSize,uploadFileEndpoint:r.uploadFileEndpoint,deleteFileEndpoint:r.deleteFileEndpoint,onFileUpdate:function(e,r){s("add"===e?function(e){return oe(oe([],e,!0),[{name:r}],!1)}:function(e){return e.filter((function(e){return e.name!==r}))})},messageId:u,filePreviewsContainer:m,errorMessagesContainer:v})})}))})}ae.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1};const ce=ae})(),o})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multimodalInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/multimodal/multimodalInput/multimodalInput.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAC9B,OAAO,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"multimodalInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/multimodal/multimodalInput/multimodalInput.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAC9B,OAAO,uBAAuB,CAAA;AAQ9B,OAAO,KAAK,EAAqB,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAI7E;;;;;;;;;;;;;;;EAeE;AACF,iBAAwB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CA+ElE;kBA/EuB,eAAe;;;;;;;;;eAAf,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,t={13:e=>{e.exports=require("emoji-picker-element")}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var i=Object.create(null);o.r(i);var a={};e=e||[null,r({}),r([]),r(r)];for(var c=2&n&&t;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,o.d(i,a),i},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{default:()=>
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e,r,t={13:e=>{e.exports=require("emoji-picker-element")}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var i=Object.create(null);o.r(i);var a={};e=e||[null,r({}),r([]),r(r)];for(var c=2&n&&t;"object"==typeof c&&!~e.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,o.d(i,a),i},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{default:()=>z});const e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Box");var n=o.n(t);const a=require("@mui/material/CircularProgress");var c=o.n(a);const s=require("@mui/material/IconButton");var u=o.n(s);const l=require("@mui/material/InputAdornment");var d=o.n(l);const p=require("@mui/material/MenuItem");var m=o.n(p);const f=require("@mui/material/MenuList");var h=o.n(f);const v=require("@mui/material/Popover");var g=o.n(v);const y=require("@mui/material/TextField");var b=o.n(y);const j=require("@mui/material/Tooltip");var x=o.n(j);const w=require("@mui/material/Typography");var S=o.n(w),O=o(13);const k=require("uuid");function C(r){return r.name.replaceAll("_","-"),(0,e.jsx)("span",{className:"".concat(r.className?r.className+" ":"","material-symbols-rounded"),children:r.name})}const E=require("@mui/material/styles"),P=function(t){var n=(0,E.useTheme)(),i=(0,r.useRef)(null),a=(0,r.useRef)(null),c=(0,r.useState)(!1),s=c[0],l=c[1],d={"--indicator-color":n.palette.divider,"--background":n.palette.background.paper,"--input-border-color":n.palette.divider,"--outline-color":n.palette.secondary.main};function p(){l(!1)}function m(e){e.detail.unicode&&t.onEmojiClick(e.detail.unicode),p()}return(0,r.useEffect)((function(){a.current||"undefined"==typeof window||Promise.resolve().then(o.t.bind(o,13,23)).then((function(e){var r=new(0,e.Picker),t="dark"===n.palette.mode?"dark":"light";r.classList.add(t),Object.keys(d).forEach((function(e){r.style.setProperty(e,d[e])})),a.current=r})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,r.useEffect)((function(){return a.current&&a.current.addEventListener("emoji-click",m),function(){var e;null===(e=a.current)||void 0===e||e.removeEventListener("emoji-click",m)}}),[s,t.onEmojiClick]),(0,e.jsxs)("div",{children:[(0,e.jsx)(x(),{title:"Emoji",children:(0,e.jsx)(u(),{size:"small",ref:i,onClick:function(){l((function(e){return!e}))},sx:{color:t.buttonColor},children:(0,e.jsx)(C,{name:"Mood"})})}),a.current&&(0,e.jsx)(g(),{open:s,anchorEl:i.current,onClose:p,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,e.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&a.current&&!e.contains(a.current)&&e.appendChild(a.current)}})})]})};var q={"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 N(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var T=new O.Database,_=(0,r.forwardRef)((function(t,o){var i=(0,r.useState)(""),a=i[0],s=i[1],l=(0,r.useState)(!1),p=l[0],f=l[1],v=(0,r.useState)(!1),y=v[0],j=v[1],w=(0,r.useState)(!1),O=w[0],E=w[1],_=(0,r.useState)(""),R=_[0],I=_[1],z=(0,r.useState)([]),M=z[0],B=z[1],F=(0,r.useState)(!1),L=F[0],A=F[1],D=(0,r.useRef)(null),W=!a.trim().length&&!t.isSendEnabled,K="".concat(p?"Stop":"Start"," speech to text"),$=y?"primary.main":"primary.light",Q=p?"error.main":$,G=p?"stop_circle":"speech_to_text";function H(e,r){if(void 0===r&&(r=!1),D.current){var t=D.current,n=t.selectionStart,o=t.selectionEnd;if("number"==typeof n&&"number"==typeof o){var i,c=a||"",u=c.substring(0,n),l=c.substring(o);i=r?u.replace(/:(\w+)$/,e)+l:u+e+l,s(i);var d=r?u.replace(/:(\w+)$/,e).length:n+e.length;setTimeout((function(){var e,r;null===(e=D.current)||void 0===e||e.focus(),null===(r=D.current)||void 0===r||r.setSelectionRange(d,d)}),0)}}A(!1)}var J=O?(0,e.jsx)(c(),{size:24}):(0,e.jsx)(x(),{title:K,children:(0,e.jsx)(u(),{onClick:function(){var e=new window.webkitSpeechRecognition,r=navigator.language;e.lang=r,p?(e.stop(),E(!0),f(!1)):(e.start(),I(""),f(!0)),e.onstart=function(){f(!0)},e.onresult=function(e){var r,t=e.results[0][0].transcript;a.length>0?s(a+" "+t):s(t),null===(r=D.current)||void 0===r||r.focus(),f(!1)},e.onerror=function(e){var r=q[e.error];I(r),f(!1)},e.onend=function(){E(!1),f(!1)}},size:"small",sx:{color:Q},children:(0,e.jsx)(C,{name:G})})});function U(){var e=(new Date).toISOString(),r={id:(0,k.v4)(),timestamp:e,sender:t.sender,conversationId:t.conversationId,format:"text",data:{text:a}};t.send(r),s(""),I("")}return(0,e.jsxs)(n(),{className:"rustic-base-input",ref:o,children:[(0,e.jsxs)(n(),{className:"rustic-error-and-input-container",children:[(0,e.jsx)(n(),{className:"rustic-error-container",children:(0,e.jsx)(S(),{variant:"caption",color:"error",className:"rustic-error-message",children:R})}),(0,e.jsxs)(n(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:y?"secondary.main":"action.disabled"},children:[M.length>0&&(0,e.jsx)(g(),{open:L,anchorEl:D.current,onClose:function(){return A(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,e.jsx)(h(),{children:M.map((function(r,t){return"unicode"in r&&(0,e.jsx)(m(),{onClick:function(){return H(r.unicode,!0)},children:N(r)},t)}))})}),(0,e.jsx)(b(),{className:"rustic-text-field",variant:"outlined",value:a,label:t.label,placeholder:t.placeholder,maxRows:t.maxRows,multiline:t.multiline,fullWidth:t.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!W&&U())},onChange:function(e){I("");var r=e.target.value;s(r);var n,o=r.match(/:(\w{2,}):/g),i=r.match(/:(\w{2,})/g);if(o){var a=o[0].replace(/:/g,"");T.getEmojiByShortcode(a).then((function(e){if(e&&"unicode"in e){var t=r.replace(o[0],e.unicode);s(t)}else s(r)})).catch((function(){s(r)})),A(!1)}else i?(n=i[0].replace(":",""),T.getEmojiBySearchQuery(n).then((function(e){e.length?(B(e.slice(0,t.maximumEmojiSearchResults)),A(!0)):(B([]),A(!1))})).catch((function(){B([]),A(!1)}))):A(!1)},onFocus:function(){return j(!0)},onBlur:function(){return j(!1)},inputRef:D,color:"secondary",size:"small",InputProps:{endAdornment:(0,e.jsxs)(d(),{position:"end",children:[(0,e.jsx)(P,{onEmojiClick:H,buttonColor:$}),t.enableSpeechToText&&J]})},InputLabelProps:{className:y?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,e.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,e.jsxs)(n(),{className:"rustic-input-actions",children:[t.children,(0,e.jsx)(x(),{title:"Send",children:(0,e.jsx)("span",{className:"rustic-send-button",children:(0,e.jsx)(u(),{"aria-label":"send message",onClick:U,disabled:W,color:"primary",children:(0,e.jsx)(C,{name:"send"})})})})]})]})}));_.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const R=_;var I=function(){return I=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},I.apply(this,arguments)};const z=function(r){var t=r.ws,n=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}(r,["ws"]);return(0,e.jsx)(R,I({},n,{send:function(e){t.send(e)}}))}})(),i})()));
|
package/dist/index.css
CHANGED
|
@@ -119,6 +119,14 @@ code {
|
|
|
119
119
|
padding: 8px;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
.rustic-multimodal-input .rustic-error-container {
|
|
123
|
+
margin: 8px 16px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.rustic-multimodal-input .rustic-input-field {
|
|
127
|
+
border: none;
|
|
128
|
+
}
|
|
129
|
+
|
|
122
130
|
.rustic-base-input {
|
|
123
131
|
display: flex;
|
|
124
132
|
align-items: flex-start;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e,t,r={986:(e,t,r)=>{r.d(t,{default:()=>c});var n=r(997),i=r(934),a=r.n(i),o=r(229),s=r.n(o);r(689);const c=function(e){return(0,n.jsx)(s(),{title:e.label,children:(0,n.jsx)(a(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})}},470:(e,t,r)=>{r.d(t,{rusticDarkTheme:()=>J,rusticLightTheme:()=>q});var n=r(442);const i=require("@mui/utils");var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)},o="#000000",s="#FFFFFF",c="#FF6928",l="#E54500",u="#FF692899",d="#FF69284D",p=(0,n.createTheme)({shape:{borderRadius:16},typography:{fontFamily:"Inter",h1:{fontStyle:"normal",fontWeight:300,fontSize:"94px",lineHeight:1.167,letterSpacing:"-1.5px"},h2:{fontStyle:"normal",fontWeight:300,fontSize:"59px",letterSpacing:"-0.5px",lineHeight:1.2},h3:{fontStyle:"normal",fontWeight:400,fontSize:"47px",letterSpacing:"0px",lineHeight:1.167},h4:{fontStyle:"normal",fontWeight:400,fontSize:"33px",letterSpacing:"0.25px",lineHeight:1.235},h5:{fontStyle:"normal",fontWeight:400,fontSize:"24px",letterSpacing:"0px",lineHeight:1.334},h6:{fontStyle:"normal",fontWeight:500,fontSize:"20px",letterSpacing:"0.15px",lineHeight:1.6},body1:{fontStyle:"normal",fontWeight:400,fontSize:"16px",letterSpacing:"0.5px",lineHeight:1.5},body2:{fontStyle:"normal",fontWeight:400,fontSize:"14px",letterSpacing:"0.25px",lineHeight:1.43},subtitle1:{fontStyle:"normal",fontWeight:400,fontSize:"16px",letterSpacing:"0.15px",lineHeight:1.75},subtitle2:{fontStyle:"normal",fontWeight:500,fontSize:"14px",letterSpacing:"0.1px",lineHeight:1.57},overline:{fontStyle:"normal",fontWeight:400,fontSize:"10px",letterSpacing:"1.5px",lineHeight:1.5,textTransform:"uppercase"},caption:{fontStyle:"normal",fontWeight:400,fontSize:"12px",letterSpacing:"0.4px",lineHeight:1.66},button:{textTransform:"none"}},palette:{common:{black:o,white:s},error:{main:"#F82A43",dark:"#C82639",light:"#FF9BA7"},warning:{main:"#FFB800",dark:"#DC8400",light:"#FFDB7D"},info:{main:"#0094FF",dark:"#005A9B",light:"#8CCFFF"}},shadows:function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}([],(0,n.createTheme)({}).shadows.map((function(e,t){return 1===t?"0 4px 5px rgba(0, 0, 0, 0.05)":2===t?"0 4px 10px rgba(0, 0, 0, 0.1)":3===t?"0 4px 15px rgba(0, 0, 0, 0.15)":"none"})),!0)}),m={fontSize:"12px",lineHeight:1.5,letterSpacing:"0.5px",padding:"0 12px",minHeight:"26px"},f={fontSize:"14px",lineHeight:1.43,letterSpacing:"0.25px",padding:"0 16px",minHeight:"40px"},h={fontSize:"16px",lineHeight:1.75,letterSpacing:"0.15px",padding:"0 24px",minHeight:"64px"},x="#E1D9D5",v="#0000001F",g="#2D2825",b="#2D282599",y="#1E0C04",j="#9C9795",S="#00000061",w="#2D282514",k="#2D28251F",F="#2D28254D",C="#2D282580",E={fontWeight:700},N={"&.Mui-disabled":{background:s,color:j,border:"1px solid ".concat(S)}},T=a(a(a({},E),{background:g,color:s,"&:hover":{background:b},"&:focus":{border:"4px solid ".concat(b)}}),N),O=a(a(a({},E),{background:s,color:y,border:"1px solid ".concat(b),"&:focus":{border:"4px solid ".concat(b)}}),N),P={fontWeight:400,"& .MuiChip-label":{padding:0,display:"flex",alignItems:"center",gap:"8px"}},R=a({background:F,color:y,border:"1px solid ".concat(C),"&:hover":{border:"1px solid ".concat(C),background:w},"&:focus":{border:"3px solid ".concat(C),background:k},"&.Mui-disabled":{background:S,opacity:100,border:"none",color:s,"& .MuiChip-icon":{color:s}},"& .MuiChip-icon":{margin:"0px 8px 0px 0px",color:y}},P),D=a({background:s,color:y,border:"1px solid ".concat(u),"&:focus":{border:"4px solid ".concat(u)},"&.Mui-disabled":{border:"1px solid ".concat(u),background:s,color:u,opacity:100},"& .MuiChip-icon":{margin:"0px 8px 0px 0px",color:y}},P),q=(0,n.createTheme)((0,i.deepmerge)(p,{palette:{mode:"light",divider:x,text:{primary:y,secondary:"#4E443F",disabled:j},primary:{main:g,dark:o,light:b,contrastText:s,focus:k,focusVisible:F,hover:w,selected:"#2D282529",border:C},secondary:{main:c,light:u,dark:l,contrastText:s,focus:"#FF69281F",focusVisible:d,hover:"#FF692814",selected:"#FF692829",border:"#FF692880"},background:{default:"#F7F6F5",paper:s},action:{active:"#0000008F",hover:"#00000014",selected:"#00000029",disabledBackground:v,focus:v,disabled:S},success:{main:"#007F51",dark:"#014F33",light:"#00D788",contrastText:s},error:{contrastText:s},warning:{contrastText:s},info:{contrastText:s}},components:{MuiTooltip:{styleOverrides:{tooltip:{backgroundColor:g,color:s}}},MuiTableCell:{styleOverrides:{head:{backgroundColor:v},root:{borderBottom:"1px solid ".concat(x),padding:"8px 16px"}}},MuiTableSortLabel:{styleOverrides:{root:{"&.Mui-active":{"& .MuiTableSortLabel-icon":{color:y}}}}},MuiPopover:{styleOverrides:{paper:{border:"1px solid ".concat(x),backgroundImage:"none"}}},MuiButton:{variants:[{props:{variant:"rusticPrimary",size:"small"},style:a(a({borderRadius:"8px"},m),T)},{props:{variant:"rusticPrimary",size:"medium"},style:a(a({borderRadius:"12px"},f),T)},{props:{variant:"rusticPrimary",size:"large"},style:a(a({borderRadius:"16px"},h),T)},{props:{variant:"rusticSecondary",size:"small"},style:a(a({borderRadius:"8px","&:hover":{border:"1px solid ".concat(o),background:s}},m),O)},{props:{variant:"rusticSecondary",size:"medium"},style:a(a({borderRadius:"12px","&:hover":{border:"2px solid ".concat(o),background:s}},f),O)},{props:{variant:"rusticSecondary",size:"large"},style:a(a({borderRadius:"16px","&:hover":{border:"2px solid ".concat(o),background:s}},h),O)}]},MuiChip:{variants:[{props:{variant:"rusticPrimary",size:"small"},style:a(a({borderRadius:"24px"},m),R)},{props:{variant:"rusticPrimary",size:"medium"},style:a(a({borderRadius:"32px"},f),R)},{props:{variant:"rusticPrimary",size:"large"},style:a(a({borderRadius:"48px"},h),R)},{props:{variant:"rusticSecondary",size:"small"},style:a(a({borderRadius:"24px","&:hover":{border:"1px solid ".concat(c),background:s}},m),D)},{props:{variant:"rusticSecondary",size:"medium"},style:a(a({borderRadius:"32px","&:hover":{border:"2px solid ".concat(c),background:s}},f),D)},{props:{variant:"rusticSecondary",size:"large"},style:a(a({borderRadius:"48px","&:hover":{border:"2px solid ".concat(c),background:s}},h),D)}]}}})),M="#FFFFFF61",z="#FFFFFF1F",I="#E1D9D5",L="#202020",B="#FFFCFB",_="#FFFCFB99",A="#000000DE",H="#FFFFFF61",W="#FF692880",V="#FFFCFB1F",U="#FFFCFB4D",G="#FFFCFB14",K="#FFFFFF4D",Q={"&.Mui-disabled":{background:K,color:M,border:"1px solid ".concat(H)}},Y=a(a(a({},E),{background:B,color:o,"&:hover":{background:_},"&:focus":{border:"4px solid ".concat(_)}}),Q),X=a(a(a({},E),{background:L,color:s,border:"1px solid ".concat(_),"&:focus":{border:"4px solid ".concat(_)}}),Q),$=a(a({background:U,color:s,border:"1px solid ".concat(W),"&:hover":{border:"1px solid ".concat(W),background:G},"&:focus":{border:"4px solid ".concat(_),background:V},"&.Mui-disabled":{background:H,opacity:100,border:"none",color:A,"& .MuiChip-icon":{color:A}}},P),{"& .MuiChip-icon":{margin:"0px 8px 0px 0px",color:s}}),Z=a({background:L,color:s,border:"1px solid ".concat(u),"&:focus":{border:"4px solid ".concat(u)},"&.Mui-disabled":{background:L,color:u,border:"1px solid ".concat(u),opacity:100},"& .MuiChip-icon":{margin:"0px 8px 0px 0px",color:s}},P),J=(0,n.createTheme)((0,i.deepmerge)(p,{palette:{mode:"dark",divider:I,primary:{main:B,dark:s,light:_,contrastText:A,hover:G,selected:"#FFFCFB29",focus:V,focusVisible:U,border:W},secondary:{main:c,light:u,dark:l,contrastText:A,hover:"#FF692814",selected:"#FF692829",focus:"#FF69281F",focusVisible:d,border:"#FF692880"},background:{default:"#2C2C2C",paper:L},text:{primary:s,secondary:"#FFFFFFB2",disabled:M},action:{active:K,hover:K,selected:"#FFFFFF29",focus:z,disabledBackground:z,disabled:H},success:{main:"#00B775",dark:"#01784D",light:"#00E390",contrastText:A},error:{contrastText:A},warning:{contrastText:A},info:{contrastText:A}},components:{MuiTooltip:{styleOverrides:{tooltip:{backgroundColor:B,color:o}}},MuiTableSortLabel:{styleOverrides:{root:{"&.Mui-active":{"& .MuiTableSortLabel-icon":{color:s}}}}},MuiTableCell:{styleOverrides:{head:{backgroundColor:z},root:{borderBottom:"1px solid ".concat(I),padding:"8px 16px"}}},MuiPopover:{styleOverrides:{paper:{border:"1px solid ".concat(I),backgroundImage:"none"}}},MuiChip:{variants:[{props:{variant:"rusticPrimary",size:"small"},style:a(a({borderRadius:"24px"},m),$)},{props:{variant:"rusticPrimary",size:"medium"},style:a(a({borderRadius:"32px"},f),$)},{props:{variant:"rusticPrimary",size:"large"},style:a(a({borderRadius:"48px"},h),$)},{props:{variant:"rusticSecondary",size:"small"},style:a(a({borderRadius:"24px","&:hover":{background:L,border:"1px solid ".concat(c)}},m),Z)},{props:{variant:"rusticSecondary",size:"medium"},style:a(a({borderRadius:"32px","&:hover":{background:L,border:"2px solid ".concat(c)}},f),Z)},{props:{variant:"rusticSecondary",size:"large"},style:a(a({borderRadius:"48px","&:hover":{background:L,border:"2px solid ".concat(c)}},h),Z)}]},MuiButton:{variants:[{props:{variant:"rusticPrimary",size:"small"},style:a(a({borderRadius:"8px"},m),Y)},{props:{variant:"rusticPrimary",size:"medium"},style:a(a({borderRadius:"12px"},f),Y)},{props:{variant:"rusticPrimary",size:"large"},style:a(a({borderRadius:"16px"},h),Y)},{props:{variant:"rusticSecondary",size:"small"},style:a(a({borderRadius:"8px","&:hover":{background:L,border:"1px solid ".concat(s)}},m),X)},{props:{variant:"rusticSecondary",size:"medium"},style:a(a({borderRadius:"12px","&:hover":{background:L,border:"2px solid ".concat(s)}},f),X)},{props:{variant:"rusticSecondary",size:"large"},style:a(a({borderRadius:"16px","&:hover":{background:L,border:"2px solid ".concat(s)}},h),X)}]}}}));q=(0,n.responsiveFontSizes)(q),J=(0,n.responsiveFontSizes)(J)},934:e=>{e.exports=require("@mui/material/IconButton")},229:e=>{e.exports=require("@mui/material/Tooltip")},442:e=>{e.exports=require("@mui/material/styles")},13:e=>{e.exports=require("emoji-picker-element")},689:e=>{e.exports=require("react")},997:e=>{e.exports=require("react/jsx-runtime")}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var a=n[e]={exports:{}};return r[e](a,a.exports,i),a.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var a=Object.create(null);i.r(a);var o={};e=e||[null,t({}),t([]),t(t)];for(var s=2&n&&r;"object"==typeof s&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach((e=>o[e]=()=>r[e]));return o.default=()=>r,i.d(a,o),a},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{i.r(a),i.d(a,{Action:()=>Pt.default,CodeSnippet:()=>C,CopyText:()=>Rt,ElementRenderer:()=>N,FCCalendar:()=>g,Image:()=>B,MarkedMarkdown:()=>et,MarkedStreamingMarkdown:()=>tt,MermaidViz:()=>Jr,MessageCanvas:()=>It,MessageSpace:()=>Vt,MultimodalInput:()=>Re,Multipart:()=>Gt,OpenLayersMap:()=>Ye,PDFViewer:()=>we,ParticipantsContainer:()=>cr,PerspectiveViz:()=>an,PopoverMenu:()=>Ot,PromptBuilder:()=>vr,Question:()=>gr,RechartsTimeSeries:()=>Yr,Sound:()=>bt,StreamingText:()=>Br,Table:()=>Lr,Text:()=>Ut,TextInput:()=>Me,TextToSpeech:()=>Dt,Timestamp:()=>zt,Uploader:()=>Te,VegaLiteViz:()=>dn,Video:()=>St,Weather:()=>pn,YoutubeVideo:()=>Ar,rusticDarkTheme:()=>mn.rusticDarkTheme,rusticLightTheme:()=>mn.rusticLightTheme});var e=i(997);const t=require("@fullcalendar/daygrid");var r=i.n(t);const n=require("@fullcalendar/react");var o=i.n(n);const s=require("@fullcalendar/timegrid");var c=i.n(s);const l=require("@mui/material/Box");var u=i.n(l),d=i(442);const p=require("@mui/material/useMediaQuery");var m=i.n(p),f=i(689),h=i.n(f),x=function(){return x=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},x.apply(this,arguments)};function v(e){return{title:e.title?e.title:"",start:e.start,end:e.end,allDay:e.isAllDay}}function g(t){var n=(0,d.useTheme)(),i=m()(n.breakpoints.up("md"));return(0,e.jsx)(u(),{className:"rustic-fc-calendar",sx:{border:"1px solid ".concat(n.palette.divider),borderRadius:"".concat(n.shape.borderRadius,"px"),".fc .fc-toolbar-title":x({},n.typography.h6),".fc .fc-scrollgrid-liquid":{borderRadius:"".concat(n.shape.borderRadius,"px")},".fc td":{borderRadius:"0 0 ".concat(n.shape.borderRadius,"px ").concat(n.shape.borderRadius,"px")},".fc .fc-scrollgrid-section-header > th":{borderRadius:"".concat(n.shape.borderRadius,"px ").concat(n.shape.borderRadius,"px 0 0")},".fc .fc-button, .fc .fc-button:active":{color:n.palette.primary.main,backgroundColor:n.palette.background.paper,border:"1px solid ".concat(n.palette.divider),borderRadius:"".concat(n.shape.borderRadius,"px"),"&:hover":{backgroundColor:n.palette.secondary.light,border:"1px solid ".concat(n.palette.divider)}},".fc .fc-button-group .fc-button.fc-button-active":{backgroundColor:n.palette.secondary.main,border:"1px solid ".concat(n.palette.divider)},".fc a, .fc .fc-event-title, .fc .fc-button, .fc .fc-timegrid-slot":x({},n.typography.caption)},children:(0,e.jsx)(o(),{plugins:[c(),r()],initialView:i?"dayGridMonth":"timeGridDay",headerToolbar:{left:"title",right:"prev,next dayGridMonth,timeGridWeek,timeGridDay"},eventColor:n.palette.secondary.main,displayEventTime:!1,titleFormat:{year:"numeric",month:"long"},views:{dayGridMonth:{dayHeaderFormat:{weekday:i?"long":"narrow"}},timeGridWeek:{dayHeaderFormat:{weekday:"short",day:"numeric"}},timeGridDay:{dayHeaderFormat:{weekday:"long",day:"numeric"}}},allDaySlot:!1,initialDate:t.events[0].start,events:t.events.map(v)})})}const b=require("@codemirror/language"),y=require("@codemirror/language-data"),j=require("@codemirror/state"),S=require("@codemirror/view"),w=require("@mui/material/Typography");var k=i.n(w);const F=require("@mui/system");function C(t){var r=(0,f.useRef)(null),n=(0,f.useRef)(),i=new j.Compartment,a=[j.EditorState.readOnly.of(!0),(0,S.highlightSpecialChars)(),(0,b.syntaxHighlighting)(b.defaultHighlightStyle,{fallback:!0}),i.of([])],o=y.languages.find((function(e){return e.name.toLowerCase()===t.language.toLowerCase()}));return(0,f.useEffect)((function(){if(r.current&&!n.current){var e=r.current,s=j.EditorState.create({doc:t.code,extensions:a});n.current=new S.EditorView({state:s,parent:e}),o&&n.current&&o.load().then((function(e){var t;null===(t=n.current)||void 0===t||t.dispatch({effects:i.reconfigure(e.extension)})}))}}),[]),(0,e.jsx)(F.Box,{sx:{backgroundColor:"background.default"},className:"rustic-code-snippet",children:(0,e.jsx)("div",{"aria-label":"code snippet",ref:r,children:(0,e.jsx)(k(),{variant:"body2","aria-label":"language type",children:t.language})})})}var E=function(){return E=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},E.apply(this,arguments)};const N=function(t){var r=t.messages[0],n=t.messages.slice(1),i=t.supportedElements[r.format];return(0,e.jsx)(e.Fragment,{children:i?h().createElement(i,E(E({sender:t.sender,ws:t.ws,messageId:r.id,conversationId:r.conversationId},r.data),n.length>0&&{updatedData:n.map((function(e){return e.data}))})):(0,e.jsxs)(k(),{variant:"body2",children:["Unsupported element format: ",r.format]})})},T=require("@mui/material/CircularProgress");var O,P=i.n(T),R=function(){return R=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},R.apply(this,arguments)},D=function(e){return e.charAt(0).toUpperCase()+e.slice(1)};function q(e,t){return function(e,t){var r,n=new Date(e),i=navigator.language;return r=t===O.HOUR?{hour:"numeric",minute:"2-digit",hour12:!0}:{month:"short",day:"numeric"},n.toLocaleString(i,r)}(e,t<=1?O.HOUR:O.MONTH_DATE)}function M(e){var t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=Math.floor(e%60),i=t>0?"".concat(t,":"):"",a="".concat(t>0?r.toString().padStart(2,"0"):r),o=n.toString().padStart(2,"0");return"".concat(i).concat(a,":").concat(o)}function z(e,t){var r={};return e&&(r={width:e}),t&&(r=R(R({},r),{height:t})),e||t||(r={className:"rustic-fit-container"}),r}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(O||(O={}));var I=function(e){var t=["Sun","Mon","Tues","Wed","Thurs","Fri","Sat"][new Date(1e3*e).getDay()];return{shortName:t,fullName:{Sun:"Sunday",Mon:"Monday",Tues:"Tuesday",Wed:"Wednesday",Thurs:"Thursday",Fri:"Friday",Sat:"Saturday"}[t]}},L=function(){return L=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},L.apply(this,arguments)};function B(t){var r=(0,f.useState)(!0),n=r[0],i=r[1],a=(0,f.useState)(""),o=a[0],s=a[1];return o.length>0?(0,e.jsx)(k(),{variant:"body2",children:o}):(0,e.jsxs)("figure",{children:[n&&(0,e.jsx)(P(),{}),(0,e.jsx)("img",L({},z(t.width,t.height),{src:t.src,alt:t.alt,onError:function(){s("Image failed to load"),i(!1)},onLoad:function(){i(!1)}})),t.description&&(0,e.jsx)("figcaption",{children:(0,e.jsx)(k(),{variant:"body2",children:t.description})})]})}B.defaultProps={alt:"An image is displayed"};const _=require("uuid");var A=i(934),H=i.n(A);const W=require("@mui/material/InputAdornment");var V=i.n(W);const U=require("@mui/material/MenuItem");var G=i.n(U);const K=require("@mui/material/MenuList");var Q=i.n(K);const Y=require("@mui/material/Popover");var X=i.n(Y);const $=require("@mui/material/TextField");var Z=i.n($),J=i(229),ee=i.n(J),te=i(13);function re(t){return t.name.replaceAll("_","-"),(0,e.jsx)("span",{className:"".concat(t.className?t.className+" ":"","material-symbols-rounded"),children:t.name})}const ne=function(t){var r=(0,d.useTheme)(),n=(0,f.useRef)(null),a=(0,f.useRef)(null),o=(0,f.useState)(!1),s=o[0],c=o[1],l={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function u(){c(!1)}function p(e){e.detail.unicode&&t.onEmojiClick(e.detail.unicode),u()}return(0,f.useEffect)((function(){a.current||"undefined"==typeof window||Promise.resolve().then(i.t.bind(i,13,23)).then((function(e){var t=new(0,e.Picker),n="dark"===r.palette.mode?"dark":"light";t.classList.add(n),Object.keys(l).forEach((function(e){t.style.setProperty(e,l[e])})),a.current=t})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,f.useEffect)((function(){return a.current&&a.current.addEventListener("emoji-click",p),function(){var e;null===(e=a.current)||void 0===e||e.removeEventListener("emoji-click",p)}}),[s,t.onEmojiClick]),(0,e.jsxs)("div",{children:[(0,e.jsx)(ee(),{title:"Emoji",children:(0,e.jsx)(H(),{size:"small",ref:n,onClick:function(){c((function(e){return!e}))},sx:{color:t.buttonColor},children:(0,e.jsx)(re,{name:"Mood"})})}),a.current&&(0,e.jsx)(X(),{open:s,anchorEl:n.current,onClose:u,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,e.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&a.current&&!e.contains(a.current)&&e.appendChild(a.current)}})})]})};var ie={"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 ae(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var oe=(0,f.forwardRef)((function(t,r){var n=(0,f.useState)(""),i=n[0],a=n[1],o=(0,f.useState)(!1),s=o[0],c=o[1],l=(0,f.useState)(!1),d=l[0],p=l[1],m=(0,f.useState)(!1),h=m[0],x=m[1],v=(0,f.useState)(""),g=v[0],b=v[1],y=(0,f.useState)([]),j=y[0],S=y[1],w=(0,f.useState)(!1),F=w[0],C=w[1],E=(0,f.useRef)(null),N=!i.trim().length&&!t.isSendEnabled,T="".concat(s?"Stop":"Start"," speech to text"),O=d?"primary.main":"primary.light",R=s?"error.main":O,D=s?"stop_circle":"speech_to_text";function q(e,t){if(void 0===t&&(t=!1),E.current){var r=E.current,n=r.selectionStart,o=r.selectionEnd;if("number"==typeof n&&"number"==typeof o){var s,c=i||"",l=c.substring(0,n),u=c.substring(o);s=t?l.replace(/:(\w+)$/,e)+u:l+e+u,a(s);var d=t?l.replace(/:(\w+)$/,e).length:n+e.length;setTimeout((function(){var e,t;null===(e=E.current)||void 0===e||e.focus(),null===(t=E.current)||void 0===t||t.setSelectionRange(d,d)}),0)}}C(!1)}var M=new te.Database,z=h?(0,e.jsx)(P(),{size:24}):(0,e.jsx)(ee(),{title:T,children:(0,e.jsx)(H(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,s?(e.stop(),x(!0),c(!1)):(e.start(),b(""),c(!0)),e.onstart=function(){c(!0)},e.onresult=function(e){var t,r=e.results[0][0].transcript;i.length>0?a(i+" "+r):a(r),null===(t=E.current)||void 0===t||t.focus(),c(!1)},e.onerror=function(e){var t=ie[e.error];b(t),c(!1)},e.onend=function(){x(!1),c(!1)}},size:"small",sx:{color:R},children:(0,e.jsx)(re,{name:D})})});function I(){var e=(new Date).toISOString(),r={id:(0,_.v4)(),timestamp:e,sender:t.sender,conversationId:t.conversationId,format:"text",data:{text:i}};t.send(r),a(""),b("")}return(0,e.jsxs)(u(),{className:"rustic-base-input",ref:r,children:[(0,e.jsxs)(u(),{className:"rustic-error-and-input-container",children:[(0,e.jsx)(u(),{className:"rustic-error-container",children:(0,e.jsx)(k(),{variant:"caption",color:"error",className:"rustic-error-message",children:g})}),(0,e.jsxs)(u(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:d?"secondary.main":"action.disabled"},children:[j.length>0&&(0,e.jsx)(X(),{open:F,anchorEl:E.current,onClose:function(){return C(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,e.jsx)(Q(),{children:j.map((function(t,r){return"unicode"in t&&(0,e.jsx)(G(),{onClick:function(){return q(t.unicode,!0)},children:ae(t)},r)}))})}),(0,e.jsx)(Z(),{className:"rustic-text-field",variant:"outlined",value:i,label:t.label,placeholder:t.placeholder,maxRows:t.maxRows,multiline:t.multiline,fullWidth:t.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!N&&I())},onChange:function(e){b("");var r=e.target.value;a(r);var n,i=r.match(/:(\w{2,}):/g),o=r.match(/:(\w{2,})/g);if(i){var s=i[0].replace(/:/g,"");M.getEmojiByShortcode(s).then((function(e){if(e&&"unicode"in e){var t=r.replace(i[0],e.unicode);a(t)}else a(r)})).catch((function(){a(r)})),C(!1)}else o?(n=o[0].replace(":",""),M.getEmojiBySearchQuery(n).then((function(e){e.length?(S(e.slice(0,t.maximumEmojiSearchResults)),C(!0)):(S([]),C(!1))})).catch((function(){S([]),C(!1)}))):C(!1)},onFocus:function(){return p(!0)},onBlur:function(){return p(!1)},inputRef:E,color:"secondary",size:"small",InputProps:{endAdornment:(0,e.jsxs)(V(),{position:"end",children:[(0,e.jsx)(ne,{onEmojiClick:q,buttonColor:O}),t.enableSpeechToText&&z]})},InputLabelProps:{className:d?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,e.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,e.jsxs)(u(),{className:"rustic-input-actions",children:[t.children,(0,e.jsx)(ee(),{title:"Send",children:(0,e.jsx)("span",{className:"rustic-send-button",children:(0,e.jsx)(H(),{"aria-label":"send message",onClick:I,disabled:N,color:"primary",children:(0,e.jsx)(re,{name:"send"})})})})]})]})}));oe.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const se=oe,ce=require("@mui/material/LinearProgress");var le=i.n(ce);const ue=require("axios");var de=i.n(ue);const pe=require("react-dom"),me=require("@mui/material/Card");var fe=i.n(me);const he=require("@mui/material/Modal");var xe=i.n(he);const ve=require("@mui/system/Stack");var ge=i.n(ve);const be=require("@mui/system/useTheme");var ye=i.n(be);const je=require("pdfjs-dist"),Se=function(t){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[t.action].label.replaceAll(" ","-").toLowerCase(),r[t.action]);return(0,e.jsx)(ee(),{title:n.label,children:(0,e.jsx)("span",{children:(0,e.jsx)(H(),{onClick:t.onClick,className:t.className,disabled:t.isDisabled,children:(0,e.jsx)(re,{name:n.symbol})})})})},we=function(t){var r,n=(0,f.useRef)(null),i=(0,f.useState)(1),a=i[0],o=i[1],s=(0,f.useState)(1),c=s[0],l=s[1],d=(0,f.useState)(1),p=d[0],h=d[1],x=(0,f.useState)(!1),v=x[0],g=x[1],b=(0,f.useState)(),y=b[0],j=b[1],S=ye()(),w=m()(S.breakpoints.down("sm")),F=m()(S.breakpoints.between("sm","md"));if(r=t.url,!/\/[^/]+\.pdf$/.test(r))return(0,e.jsx)(fe(),{variant:"outlined",className:"rustic-pdf-error",children:(0,e.jsx)(k(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var C=(0,f.useState)((function(){return w?.5:F?1:1.5})),E=C[0],N=C[1];return(0,f.useEffect)((function(){je.GlobalWorkerOptions.workerSrc||(je.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(je.version,"/pdf.worker.mjs")),je.getDocument({url:"".concat(t.url)}).promise.then((function(e){l(e.numPages),function(e){e.getPage(a).then((function(e){var t=e.getViewport({scale:E}),r=n.current;if(r){var i=r.getContext("2d");if(i){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 o={canvasContext:i,viewport:t,transform:[a,0,0,a,0,0]};y&&y.cancel();var s=e.render(o);j(s),s.promise.then((function(){j(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[t.url,a,E]),v?(0,e.jsx)(fe(),{variant:"outlined",className:"rustic-pdf-error",children:(0,e.jsx)(k(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,e.jsxs)(fe(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,e.jsxs)(u(),{className:"rustic-pdf-viewer-header",children:[(0,e.jsx)(Se,{action:"zoomOut",onClick:function(){N((function(e){return Math.max(e-.2,.2)}))}}),(0,e.jsx)(Se,{action:"zoomIn",onClick:function(){N((function(e){return e+.2}))}})]}),(0,e.jsx)(u(),{className:"rustic-pdf-viewer-body",children:(0,e.jsx)(u(),{className:"rustic-pdf-viewer-body-inner",children:(0,e.jsx)("canvas",{ref:n})})}),(0,e.jsxs)(ge(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,e.jsx)(Se,{action:"previousPage",onClick:function(){a>1&&(o(a-1),h(a-1))},isDisabled:1===a}),(0,e.jsx)(k(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,e.jsx)(Z(),{type:"number",value:p,onChange:function(e){var t=parseInt(e.target.value);h(t),!isNaN(t)&&t>=1&&t<=c&&o(t)},size:"small",className:"rustic-pdf-page-input"}),(0,e.jsxs)(k(),{variant:"body1",className:"rustic-page-indicator",children:["of ",c]}),(0,e.jsx)(Se,{action:"nextPage",onClick:function(){a<c&&(o(a+1),h(a+1))},isDisabled:a===c})]})]})};var ke={pdf:we};function Fe(t){var r=(0,d.useTheme)(),n=(0,f.useState)(!1),i=n[0],a=n[1];function o(){a(!1)}var s,c,l=t.file.url&&(s=t.file.url.split("."))[s.length-1].toLowerCase(),u=l&&t.supportedViewers?t.supportedViewers[l]:null,p=!!u;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(fe(),{className:"rustic-file-preview".concat(p?" rustic-cursor-pointer":""),variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){a(!0)},children:[(0,e.jsx)(k(),{variant:"subtitle2",children:(c=t.file.name,15,c.length<=15?c:c.substring(0,12)+"...")}),(0,e.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:t.children})]}),p&&(0,e.jsx)(xe(),{open:i,onClose:o,className:"rustic-file-preview-modal",children:(0,e.jsxs)("div",{className:"rustic-modal-content",children:[(0,e.jsx)(ee(),{title:"Close",children:(0,e.jsx)(H(),{onClick:o,className:"rustic-close-button",children:(0,e.jsx)(re,{name:"close"})})}),t.file.url&&(0,e.jsx)(u,{url:t.file.url})]})})]})}Fe.defaultProps={supportedViewers:ke};var Ce=function(){return Ce=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ce.apply(this,arguments)},Ee=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function Ne(e){for(var t=["Bytes","KB","MB","GB"],r=0;e>=1024&&r<t.length-1;)e/=1024,r++;var n=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(n," ").concat(t[r])}const Te=function(t){var r=(0,f.useState)([]),n=r[0],i=r[1],a=(0,f.useState)([]),o=a[0],s=a[1],c=(0,f.useRef)({}),l=(0,_.v4)();(0,f.useEffect)((function(){i([]),s([]),c.current={}}),[t.messageId]);var d=(0,e.jsx)(u(),{className:"rustic-files rustic-padding-16",children:n.map((function(r,n){return(0,e.jsx)(Fe,{file:{name:r.name},children:(0,e.jsxs)(u(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,e.jsx)(le(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,e.jsx)(ee(),{title:"Delete",children:(0,e.jsx)(H(),{color:"primary",onClick:function(){return function(e,r){var n,a;s([]);var o=e.name;if(c.current=Ce(Ce({},c.current),((n={})[o]=c.current[o]--,n)),t.onFileUpdate("remove",o),100===e.loadingProgress){var l="".concat(t.deleteFileEndpoint,"?message-id=").concat(t.messageId,"&file-id=").concat(e.id);de().delete(l).then((function(){return i((function(e){return e.filter((function(e,t){return t!==r}))}))})).catch((function(){return t.onFileUpdate("add",o),s((function(e){return Ee(Ee([],e,!0),["Failed to delete ".concat(o,". Please try again.")],!1)}))}))}else e.abortController.abort(),i((function(e){return e.filter((function(e,t){return t!==r}))})),c.current=Ce(Ce({},c.current),((a={})[o]=c.current[o]++,a))}(r,n)},className:"rustic-delete-button","aria-label":"cancel file upload",children:(0,e.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)}))}),p=(0,e.jsx)(u(),{children:o.map((function(t,r){return(0,e.jsx)(k(),{variant:"caption",color:"error",className:"rustic-error-message",children:t},r)}))});function m(e,t){return t?(0,pe.createPortal)(e,t):e}return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(u(),{className:"rustic-uploader",children:[(0,e.jsx)("label",{htmlFor:l,children:(0,e.jsx)(ee(),{title:"Upload",children:(0,e.jsx)(H(),{component:"span","aria-label":"Upload file",color:"primary",children:(0,e.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,e.jsx)("input",{type:"file",id:l,onChange:function(e){s([]);var r=e.target.files&&Array.from(e.target.files),a=n.length+(r?r.length:0);t.maxFileCount&&a>t.maxFileCount&&s((function(e){return Ee(Ee([],e,!0),["You can only upload ".concat(t.maxFileCount," files.")],!1)}));var o=r&&function(e,t,r){return r?t<=r?e:e.slice(0,r-t):e}(r,a,t.maxFileCount);o&&o.forEach((function(e){!function(e){var r;t.maxFileSize&&e.size>t.maxFileSize?(r=e.name,s((function(e){return Ee(Ee([],e,!0),["Failed to upload ".concat(r,". You cannot upload files larger than ").concat(t.maxFileSize&&Ne(t.maxFileSize),".")],!1)}))):function(e){var r=new FormData,n=new AbortController,a=function(e){var t,r,n=e.name,i=c.current[n];if(i){var a=i+1,o=n.lastIndexOf("."),s=n.substring(0,o),l=n.substring(o);n="".concat(s,"(").concat(i,")").concat(l),c.current=Ce(Ce({},c.current),((t={})[e.name]=a,t))}else c.current=Ce(Ce({},c.current),((r={})[e.name]=1,r));return n}(e),o=new File([e],a,{type:e.type});r.append("file",o);var l=(0,_.v4)(),u={name:a,loadingProgress:0,abortController:n,id:l};i((function(e){return Ee(Ee([],e,!0),[u],!1)})),t.onFileUpdate("add",a);var d="".concat(t.uploadFileEndpoint,"?message-id=").concat(t.messageId);de().post(d,r,{onUploadProgress:function(e){var t,r;e.total&&(t=e.loaded/e.total*100,r=u.id,i((function(e){var n=e.map((function(e){return e.id===r?Ce(Ce({},e),{loadingProgress:t}):e}));return n})))},signal:n.signal}).then((function(e){var t,r;t=e.data,r=u.id,i((function(e){var n=e.findIndex((function(e){return e.id===r}));if(-1!==n){var i=Ee([],e,!0);return i[n]=Ce(Ce({},i[n]),{id:t.fileId}),i}return e}))})).catch((function(r){var n,o;t.onFileUpdate("remove",a),c.current=Ce(Ce({},c.current),((n={})[a]=c.current[e.name]--,n)),function(e,t,r){s((function(t){return Ee(Ee([],t,!0),["Failed to upload ".concat(e,". ").concat((null==r?void 0:r.message)||"")],!1)})),i((function(e){return e.filter((function(e){return e.id!==t}))}))}(e.name,u.id,null===(o=r.response)||void 0===o?void 0:o.data)}))}(e)}(e)})),e.target.value=""},multiple:!0,accept:t.acceptedFileTypes})]}),o.length>0&&m(p,t.errorMessagesContainer),n.length>0&&m(d,t.filePreviewsContainer)]})};var Oe=function(){return Oe=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Oe.apply(this,arguments)},Pe=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function Re(t){var r=(0,f.useState)([]),n=r[0],i=r[1],a=(0,f.useState)((0,_.v4)()),o=a[0],s=a[1],c=(0,f.useState)(),l=c[0],d=c[1],p=(0,f.useState)(),m=p[0],h=p[1],x=(0,f.useRef)(null),v=n.length>0;return(0,f.useEffect)((function(){x.current&&(h(x.current.querySelector(".rustic-error-container")),d(x.current.querySelector(".rustic-input-extras")))})),(0,e.jsx)(u(),{className:"rustic-multimodal-input",children:(0,e.jsx)(se,Oe({},t,{send:function(e){v&&(e.id=o,e.format="filesWithText",e.data.files=n),t.ws.send(e),s((0,_.v4)()),i([])},isSendEnabled:v,ref:x,children:(0,e.jsx)(u(),{className:"rustic-bottom-buttons",children:(0,e.jsx)(Te,{acceptedFileTypes:t.acceptedFileTypes,maxFileCount:t.maxFileCount,maxFileSize:t.maxFileSize,uploadFileEndpoint:t.uploadFileEndpoint,deleteFileEndpoint:t.deleteFileEndpoint,onFileUpdate:function(e,t){i("add"===e?function(e){return Pe(Pe([],e,!0),[{name:t}],!1)}:function(e){return e.filter((function(e){return e.name!==t}))})},messageId:o,filePreviewsContainer:l,errorMessagesContainer:m})})}))})}Re.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1};var De=function(){return De=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},De.apply(this,arguments)},qe=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 i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r};function Me(t){var r=t.ws,n=qe(t,["ws"]);return(0,e.jsx)(se,De({},n,{send:function(e){r.send(e)}}))}require("ol/ol.css");const ze=require("@mui/material/Alert");var Ie=i.n(ze);const Le=require("ol/layer/Tile.js");var Be=i.n(Le);const _e=require("ol/Map.js");var Ae=i.n(_e);const He=require("ol/Overlay.js");var We=i.n(He);const Ve=require("ol/proj.js"),Ue=require("ol/source/OSM.js");var Ge=i.n(Ue);const Ke=require("ol/View.js");var Qe=i.n(Ke);function Ye(t){var r=(0,f.useState)(""),n=r[0],i=r[1],a=(0,f.useRef)(null),o=(0,f.useRef)(null);return(0,f.useEffect)((function(){if(i(""),t.latitude<-90||t.latitude>90||t.longitude<-180||t.longitude>180)return i("Invalid coordinates");if(a.current&&o.current){var e=new(Ae())({layers:[new(Be())({source:new(Ge())})],view:new(Qe())({center:(0,Ve.fromLonLat)([t.longitude,t.latitude]),zoom:12}),target:a.current}),r=new(We())({element:o.current,position:(0,Ve.fromLonLat)([t.longitude,t.latitude]),positioning:"bottom-center",stopEvent:!1});return e.addOverlay(r),e.once("postrender",(function(){var e;if(!(null===(e=a.current)||void 0===e?void 0:e.querySelector("canvas")))return i("An error occurred while loading the map")})),function(){e.setTarget(""),e.removeOverlay(r)}}}),[]),(0,e.jsx)(e.Fragment,{children:n.length>0?(0,e.jsx)(Ie(),{severity:"error",children:n}):(0,e.jsxs)(u(),{children:[(0,e.jsx)(u(),{ref:o,children:(0,e.jsx)(re,{className:"rustic-open-layers-map-marker",name:"location_on"})}),(0,e.jsx)("div",{ref:a,className:"rustic-open-layers-map-canvas"})]})})}const Xe=require("dompurify");var $e=i.n(Xe);const Ze=require("marked");function Je(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=Ze.marked.parse(t);return $e().sanitize(r)}const et=function(t){var r=(0,f.useState)(Je(t.text)),n=r[0],i=r[1];return(0,f.useEffect)((function(){if(t.updatedData&&t.updatedData.length>0){var e=t.updatedData[t.updatedData.length-1].text;i(Je(e))}}),[t.text,t.updatedData]),(0,e.jsx)(k(),{variant:"body2",dangerouslySetInnerHTML:{__html:n}})},tt=function(t){var r=(0,f.useState)(Je(t.text)),n=r[0],i=r[1],a=(0,f.useState)(""),o=a[0],s=a[1];return(0,f.useEffect)((function(){if(t.updatedData&&t.updatedData.length>0){for(var e=t.text,r=0,n=t.updatedData;r<n.length;r++){var a=n[r];"string"!=typeof a.text?(e+=" [MISSING TEXT]",s("Some of the incoming text was not correctly formatted. Some data may be missing.")):e+=a.text}i(Je(e))}}),[t.text,t.updatedData]),(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(k(),{variant:"body2",dangerouslySetInnerHTML:{__html:n}}),o&&(0,e.jsx)(Ie(),{severity:"error",children:o})]})},rt=require("@mui/material"),nt=require("@mui/material/Button");var it=i.n(nt);const at=require("@mui/material/Slider");var ot=i.n(at);function st(t){var r,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[t.action].label.replaceAll(" ","-").toLowerCase(),(0,e.jsx)(ee(),{title:n[t.action].label,PopperProps:{container:null!==(r=document.fullscreenElement)&&void 0!==r?r:document.body},children:(0,e.jsx)(H(),{onClick:t.onClick,className:t.className,color:"primary",children:(0,e.jsx)(re,{name:n[t.action].symbol,className:"rustic-icon-large"})})})}var ct=100;function lt(t){var r="dark"===(0,rt.useTheme)().palette.mode,n=M(t.mediaElement.currentTime);return(0,e.jsxs)(u(),{className:"rustic-progress",children:[function(){for(var n=t.mediaElement.buffered,i=0,a=n.length-1;a>=0;--a){var o=n.start(a),s=n.end(a);if(o<t.mediaElement.currentTime){i=s;break}}var c=i/t.mediaElement.duration*ct;return(0,e.jsx)(le(),{className:"rustic-progress-buffered",variant:"determinate",value:c,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:r?"secondary.light":"action.selected"}}})}(),(0,e.jsx)(ot(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(n),max:t.mediaElement.duration,value:t.mediaElement.currentTime,onChange:function(e,r){t.mediaElement.currentTime=r},valueLabelDisplay:"auto",valueLabelFormat:function(e){return M(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function ut(t){var r=(0,f.useState)(t.mediaElement.volume),n=r[0],i=r[1],a=(0,f.useState)(t.mediaElement.volume),o=a[0],s=a[1],c=t.mediaElement.muted?"volumeOff":"volumeUp";return(0,e.jsxs)(u(),{className:"rustic-volume-settings",children:[(0,e.jsx)(st,{onClick:function(){t.mediaElement.muted=!t.mediaElement.muted,t.mediaElement.muted?(s(t.mediaElement.volume),i(0)):i(o)},className:"rustic-mute-button",action:c}),(0,e.jsx)(ot(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(n*ct,"%"),value:n,onChange:function(e,r){var n=r;t.mediaElement.muted=0===n,t.mediaElement.volume=n,i(t.mediaElement.volume)}})]})}function dt(t){var r=t.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",n="".concat(t.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,e.jsx)(it(),{className:"rustic-transcript-toggle",onClick:t.setIsTranscriptVisible,endIcon:(0,e.jsx)(re,{name:r}),children:(0,e.jsx)(k(),{variant:"overline",children:n})})}function pt(t){var r=(0,f.useState)(!t.mediaElement.paused),n=r[0],i=r[1],a=n?"pause":"play";return t.mediaElement.onended=function(){i(!1)},t.mediaElement.onpause=function(){i(!1)},t.mediaElement.onplay=function(){i(!0)},(0,e.jsx)(st,{onClick:function(){n?t.mediaElement.pause():t.mediaElement.play().catch((function(e){t.onError("Failed to play the media. Error: ".concat(e.message))}))},action:a,className:"rustic-pause-play-icon"})}function mt(t){var r,n=(0,f.useState)(t.mediaElement.playbackRate),i=n[0],a=n[1];return(0,e.jsx)(ee(),{title:"Playback rate",PopperProps:{container:null!==(r=document.fullscreenElement)&&void 0!==r?r:document.body},children:(0,e.jsx)(it(),{onClick:function(){var e=1;t.mediaElement.playbackRate<2&&(e=t.mediaElement.playbackRate+.5),t.mediaElement.playbackRate=e,a(e)},className:"rustic-playback-rate-button",children:(0,e.jsxs)(k(),{variant:"body1",children:[i,"X"]})})})}function ft(t){var r="replay"===t.movement,n=r?function(){t.mediaElement.currentTime-=10}:function(){t.mediaElement.currentTime+=10},i=r?"replay":"forward";return(0,e.jsx)(st,{onClick:n,action:i})}function ht(t){var r=M(t.elapsedTimeInSeconds),n=M(t.durationTimeInSeconds),i="".concat(r," / ").concat(n);return"wide"===t.style?(0,e.jsxs)(u(),{className:"rustic-time-container",children:[(0,e.jsx)(k(),{variant:"overline",children:r}),(0,e.jsx)(k(),{variant:"overline",children:n})]}):(0,e.jsx)(k(),{variant:"overline",className:"rustic-time-display",children:i})}ht.defaultProps={style:"condensed"};const xt=require("@mui/material/Divider");var vt=i.n(xt);function gt(t){var r=!!document.fullscreenElement;return(0,e.jsxs)(F.Box,{className:"rustic-transcript-container",children:[!r&&(0,e.jsx)(vt(),{orientation:"vertical",flexItem:!0}),(0,e.jsx)(k(),{className:"rustic-transcript-content",variant:"body2",children:t.transcript})]})}function bt(t){var r=(0,f.useState)(!1),n=r[0],i=r[1],a=(0,f.useState)(!1),o=a[0],s=a[1],c=(0,f.useState)(!0),l=c[0],u=c[1],d=(0,f.useState)(0),p=d[0],m=d[1],h=(0,f.useState)(""),x=h[0],v=h[1],g=(0,f.useState)(""),b=g[0],y=g[1],j=(0,rt.useTheme)(),S=(0,f.useRef)(null),w=(0,rt.useMediaQuery)(j.breakpoints.down("md"));function C(){return(0,e.jsx)(k(),{variant:"h6",className:"rustic-sound-title",children:t.title})}function E(){if(t.captions&&t.captions.length>0){var r=o?"captionsOff":"captionsOn";return(0,e.jsx)(st,{action:r,onClick:function(){return s(!o)}})}}function N(){if(S.current)return(0,e.jsxs)(F.Box,{className:"rustic-time-controls",children:[(0,e.jsx)(ft,{mediaElement:S.current,movement:"replay"}),(0,e.jsx)(pt,{mediaElement:S.current,onError:y}),(0,e.jsx)(ft,{mediaElement:S.current,movement:"forward"})]})}function T(){if(t.transcript&&n)return(0,e.jsx)(gt,{transcript:t.transcript})}function O(){if(t.transcript)return(0,e.jsx)(dt,{isTranscriptVisible:n,setIsTranscriptVisible:function(){return i(!n)}})}function R(){return(0,e.jsx)("video",{src:t.src,ref:S,className:o?"rustic-has-captions":"",children:o&&(0,e.jsx)("track",{src:t.captions,kind:"captions",default:!0})})}(0,f.useEffect)((function(){var e,t,r,n;function i(e){v(e)}null===(e=S.current)||void 0===e||e.addEventListener("timeupdate",(function(){S.current&&m(S.current.currentTime)})),null===(t=S.current)||void 0===t||t.addEventListener("canplay",(function(){v(""),u(!1)})),null===(r=S.current)||void 0===r||r.addEventListener("error",(function(){return i("Failed to load the audio.")})),null===(n=S.current)||void 0===n||n.addEventListener("stalled",(function(){return i("Failed to fetch audio data, but trying.")}))}),[]);var D=w?function(){if(S.current)return(0,e.jsxs)(F.Box,{className:"rustic-sound-controls",children:[(0,e.jsx)(ht,{elapsedTimeInSeconds:p,durationTimeInSeconds:S.current.duration,style:"wide"}),(0,e.jsx)(lt,{mediaElement:S.current}),C(),(0,e.jsxs)(F.Box,{className:"rustic-sound-bottom-controls",children:[(0,e.jsx)(F.Box,{className:"rustic-sound-bottom-controls-left",children:N()}),(0,e.jsx)(ut,{mediaElement:S.current}),(0,e.jsxs)(F.Box,{className:"rustic-sound-bottom-controls-right",children:[O(),(0,e.jsxs)(F.Box,{children:[E(),(0,e.jsx)(mt,{mediaElement:S.current})]})]})]}),T()]})}:function(){if(S.current)return(0,e.jsxs)(e.Fragment,{children:[C(),(0,e.jsxs)(F.Box,{className:"rustic-sound-controls",children:[(0,e.jsx)(lt,{mediaElement:S.current}),(0,e.jsxs)(F.Box,{className:"rustic-sound-bottom-controls",children:[(0,e.jsxs)(F.Box,{className:"rustic-sound-bottom-controls-left",children:[N(),E(),(0,e.jsx)(mt,{mediaElement:S.current}),(0,e.jsx)(ut,{mediaElement:S.current}),(0,e.jsx)(ht,{elapsedTimeInSeconds:p,durationTimeInSeconds:S.current.duration,style:"condensed"})]}),(0,e.jsx)(F.Box,{className:"rustic-sound-bottom-controls-right",children:O()})]}),T()]})]})};return x.length>0?(0,e.jsx)(Ie(),{severity:"error",children:x}):l?(0,e.jsxs)(F.Box,{className:"rustic-sound",children:[R(),(0,e.jsx)(P(),{})]}):(0,e.jsxs)(F.Box,{className:"rustic-sound",children:[R(),D(),b.length>0&&(0,e.jsx)(Ie(),{severity:"error",className:"rustic-control-error",onClose:function(){return y("")},children:b})]})}function yt(t){var r=(0,f.useState)(!!document.pictureInPictureElement),n=r[0],i=r[1],a=t.mediaElement,o=n?"miniPlayerExit":"miniPlayer";return a.onleavepictureinpicture=function(){i(!1)},(0,e.jsx)(st,{onClick:function(){n?document.exitPictureInPicture().then((function(){i(!1)})).catch((function(e){t.onError("Failed to exit mini player. Error: ".concat(e.message))})):a.requestPictureInPicture().then((function(){i(!0)})).catch((function(e){t.onError("Failed to enter mini player. Error: ".concat(e.message))}))},action:o})}function jt(t){var r=(0,f.useState)(!!document.fullscreenElement),n=r[0],i=r[1],a=t.element,o=n?"fullscreenExit":"fullscreen";return a.onfullscreenchange=function(){i(!!document.fullscreenElement)},(0,e.jsx)(st,{onClick:function(){n?document.exitFullscreen().then((function(){i(!1)})).catch((function(e){t.onError("Failed to exit fullscreen mode. Error: ".concat(e.message))})):a.requestFullscreen().then((function(){i(!0)})).catch((function(e){t.onError("Failed to enter fullscreen mode. Error: ".concat(e.message))}))},action:o})}function St(t){var r=(0,f.useState)(!1),n=r[0],i=r[1],a=(0,f.useState)(!1),o=a[0],s=a[1],c=(0,f.useState)(!0),l=c[0],u=c[1],d=(0,f.useState)(!!document.fullscreenElement),p=d[0],m=d[1],h=(0,f.useState)(!1),x=h[0],v=h[1],g=(0,f.useState)(""),b=g[0],y=g[1],j=(0,f.useState)(""),S=j[0],w=j[1],C=(0,f.useState)(0),E=C[0],N=C[1],T=(0,f.useRef)(null),O=(0,f.useRef)(null),R=(0,rt.useTheme)(),D=(0,rt.useMediaQuery)(R.breakpoints.down("md"));(0,f.useEffect)((function(){var e,t,r,n,i,a,o,s;function c(e){w(e),u(!1)}function l(){clearTimeout(s),s=setTimeout((function(){return v(!1)}),3e3)}null===(e=O.current)||void 0===e||e.addEventListener("timeupdate",(function(){O.current&&N(O.current.currentTime)})),null===(t=O.current)||void 0===t||t.addEventListener("canplay",(function(){w(""),u(!1)})),null===(r=O.current)||void 0===r||r.addEventListener("error",(function(){return c("Failed to load the video.")})),null===(n=O.current)||void 0===n||n.addEventListener("stalled",(function(){return c("Failed to fetch video data, but trying.")})),document.addEventListener("fullscreenchange",(function(){m(!!document.fullscreenElement)})),null===(i=T.current)||void 0===i||i.addEventListener("mousemove",(function(){v(!0),l()})),null===(a=T.current)||void 0===a||a.addEventListener("mouseleave",(function(){v(!1)})),null===(o=T.current)||void 0===o||o.addEventListener("keydown",(function(){v(!0),l()}))}),[]);var q={backgroundColor:R.palette.background.paper,opacity:x?1:0};function M(){if(t.transcript&&n)return(0,e.jsx)(gt,{transcript:t.transcript})}function z(){if(t.captions&&t.captions.length>0){var r=o?"captionsOff":"captionsOn";return(0,e.jsx)(st,{action:r,onClick:function(){return s(!o)}})}}function I(){if(t.transcript)return(0,e.jsx)(dt,{isTranscriptVisible:n,setIsTranscriptVisible:function(){return i(!n)}})}var L=D?function(){return p?(0,e.jsx)(e.Fragment,{children:O.current&&T.current&&(0,e.jsxs)(F.Box,{className:"rustic-video-controls",sx:q,children:[(0,e.jsxs)(F.Box,{className:"rustic-video-top-controls",children:[(0,e.jsx)(pt,{mediaElement:O.current,onError:y}),(0,e.jsx)(lt,{mediaElement:O.current}),(0,e.jsx)(ht,{elapsedTimeInSeconds:E,durationTimeInSeconds:O.current.duration})]}),(0,e.jsxs)(F.Box,{className:"rustic-video-bottom-controls",children:[(0,e.jsxs)(F.Box,{className:"rustic-time-controls",children:[(0,e.jsx)(ft,{mediaElement:O.current,movement:"replay"}),(0,e.jsx)(ft,{mediaElement:O.current,movement:"forward"}),z(),(0,e.jsx)(mt,{mediaElement:O.current})]}),I()]}),M()]})}):(0,e.jsx)(e.Fragment,{children:O.current&&T.current&&(0,e.jsxs)(F.Box,{className:"rustic-video-controls-mobile-preview",children:[(0,e.jsx)(pt,{mediaElement:O.current,onError:y}),(0,e.jsxs)(F.Box,{className:"rustic-video-controls-right",children:[I(),(0,e.jsx)(jt,{element:T.current,onError:y})]})]})})}:function(){return(0,e.jsx)(e.Fragment,{children:O.current&&T.current&&(0,e.jsxs)(F.Box,{className:"rustic-video-controls",sx:q,children:[(0,e.jsx)(lt,{mediaElement:O.current}),(0,e.jsxs)(F.Box,{className:"rustic-video-bottom-controls",children:[(0,e.jsxs)(F.Box,{className:"rustic-video-bottom-controls-left",children:[(0,e.jsx)(pt,{mediaElement:O.current,onError:y}),(0,e.jsx)(ft,{mediaElement:O.current,movement:"replay"}),(0,e.jsx)(ft,{mediaElement:O.current,movement:"forward"}),z(),(0,e.jsx)(mt,{mediaElement:O.current}),(0,e.jsx)(ut,{mediaElement:O.current}),(0,e.jsx)(ht,{elapsedTimeInSeconds:E,durationTimeInSeconds:O.current.duration,style:"condensed"})]}),(0,e.jsxs)(F.Box,{className:"rustic-video-bottom-controls-right",children:[I(),(0,e.jsx)(yt,{mediaElement:O.current,onError:y}),(0,e.jsx)(jt,{element:T.current,onError:y})]})]}),p&&M()]})})};return S.length>0?(0,e.jsx)(Ie(),{severity:"error",children:S}):(0,e.jsxs)(F.Box,{className:"rustic-video",children:[l&&(0,e.jsx)(P(),{className:"rustic-video-loading-spinner"}),(0,e.jsxs)(F.Box,{ref:T,className:"rustic-video-screen",sx:{visibility:l?"hidden":"visible"},children:[b.length>0&&(0,e.jsx)(Ie(),{severity:"error",className:"rustic-control-error",onClose:function(){return y("")},children:b}),(!D||p)&&function(){if(O.current&&T.current)return(0,e.jsxs)(F.Box,{className:"rustic-video-title",sx:q,children:[(0,e.jsx)(k(),{variant:"body2",children:t.title}),p&&D&&(0,e.jsxs)(F.Box,{children:[(0,e.jsx)(yt,{mediaElement:O.current,onError:y}),(0,e.jsx)(jt,{element:T.current,onError:y})]})]})}(),(0,e.jsx)("video",{className:"rustic-video-element",ref:O,src:t.src,poster:t.poster,children:o&&(0,e.jsx)("track",{src:t.captions,kind:"captions",default:!0})}),L()]}),!p&&M()]})}const wt=require("@mui/material/Drawer");var kt=i.n(wt);const Ft=require("@mui/material/ListItemText");var Ct=i.n(Ft);const Et=require("@mui/material/Menu");var Nt=i.n(Et),Tt=function(){return Tt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Tt.apply(this,arguments)};function Ot(t){var r=(0,f.useState)(!1),n=r[0],i=r[1],a=(0,f.useRef)(null),o=(0,d.useTheme)(),s=(0,rt.useMediaQuery)(o.breakpoints.down("md")),c=s?kt():Nt(),l={borderRadius:"".concat(o.shape.borderRadius,"px"),border:"1px solid ".concat(o.palette.divider)};function u(t){return(0,e.jsxs)(e.Fragment,{children:[t.startDecorator&&(0,e.jsx)(F.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:t.startDecorator}),(0,e.jsx)(Ct(),{children:(0,e.jsx)(k(),{variant:"body2",children:t.label})}),t.endDecorator&&(0,e.jsx)(F.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:t.endDecorator})]})}s&&(l=Tt(Tt({},l),{borderRadius:"".concat(o.shape.borderRadius,"px ").concat(o.shape.borderRadius,"px 0 0"),borderBottom:0}));var p=t.menuItems.map((function(t){return t.href?(0,e.jsx)(G(),{component:"a",onClick:function(){return i(!1)},href:t.href,download:t.downloadFileName||t.isFiledownload,children:u(t)},t.label):(0,e.jsx)(G(),{onClick:function(e){t.onClick&&t.onClick(e),i(!1)},disabled:!t.onClick,children:u(t)},t.label)}));var m,h,x=s?{}:{anchorEl:a.current};return(0,e.jsxs)(e.Fragment,{children:[(m={onClick:function(e){e.stopPropagation(),i(!0)},"aria-label":t.ariaLabel,ref:a,className:"rustic-popover-menu-button"},h=(0,e.jsx)(re,{name:"more_vert"}),t.buttonText?(0,e.jsx)(it(),Tt({},m,{startIcon:t.icon?t.icon:null,children:t.buttonText})):(0,e.jsx)(ee(),{title:t.ariaLabel,children:(0,e.jsx)(H(),Tt({},m,{children:t.icon?t.icon:h}))})),(0,e.jsx)(c,Tt({open:n,onClose:function(){return i(!1)}},x,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":Tt(Tt({},l),{backgroundImage:"none",boxShadow:o.shadows[2]})},children:p}))]})}var Pt=i(986);function Rt(t){var r=(0,f.useState)("Copy text"),n=r[0],i=r[1];return(0,e.jsx)(Pt.default,{message:t.message,icon:(0,e.jsx)(re,{name:"file_copy"}),onClick:function(e){e.data.text&&navigator.clipboard.writeText(e.data.text).then((function(){i("Copied"),setTimeout((function(){i("Copy text")}),2e3)})).catch((function(){i("Failed to copy")}))},label:n})}function Dt(t){var r=(0,f.useState)("Start reading aloud"),n=r[0],i=r[1],a=[t.message.data.title,t.message.data.description,t.message.data.alt,t.message.data.text,t.message.data.transcript].filter(Boolean).join(" "),o=new SpeechSynthesisUtterance(a);return(0,e.jsx)(Pt.default,{message:t.message,icon:(0,e.jsx)(re,{name:"text_to_speech"}),onClick:function(){window.speechSynthesis.speaking?(window.speechSynthesis.cancel(),i("Start reading aloud")):(o.onend=function(){i("Start reading aloud")},window.speechSynthesis.speak(o),i("Stop reading aloud"))},label:n})}const qt=require("@mui/material/Stack");var Mt=i.n(qt);const zt=function(t){return(0,e.jsx)(k(),{variant:"caption",color:"text.secondary",className:"rustic-timestamp",children:(r=t.timestamp,n=new Date(r),i=navigator.language,a={month:"short",day:"numeric"},o=new Date,s=n.getFullYear()!==o.getFullYear(),c=s?" at ":", ",s&&(a.year="numeric"),n.toLocaleDateString(i,a)+c+n.toLocaleTimeString(i,{hour:"numeric",minute:"2-digit",hour12:!0}))});var r,n,i,a,o,s,c},It=(0,f.forwardRef)((function(t,r){var n=(0,rt.useTheme)();return(0,e.jsxs)(Mt(),{id:t.message.id,className:"rustic-message-canvas",ref:r,children:[(0,e.jsxs)(Mt(),{direction:"row",alignItems:"center",spacing:1,children:[t.getProfileComponent&&t.getProfileComponent(t.message),(0,e.jsx)(zt,{timestamp:t.message.timestamp})]}),t.getActionsComponent&&t.getActionsComponent(t.message)&&(0,e.jsx)(fe(),{variant:"outlined",className:"rustic-message-actions-container",sx:{boxShadow:n.shadows[1]},children:t.getActionsComponent(t.message)}),(0,e.jsx)(fe(),{variant:"outlined",className:"rustic-message-container",children:t.children})]})})),Lt=require("@mui/material/Chip");var Bt=i.n(Lt);const _t=require("@mui/system/Box");var At=i.n(_t),Ht=function(){return Ht=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ht.apply(this,arguments)};function Wt(e,t){var r=t.format.includes("update")?t.threadId:t.id;if(r){var n=Ht({},e),i=(e[r]||[])[0];return t.format.includes("update")&&i&&i.sender.id!==t.sender.id&&(r=t.id),n[r]||(n[r]=[]),n[r]=n[r].concat(t),n}return e}function Vt(t){var r,n,i,a=(0,f.useRef)(null),o=(0,f.useRef)(null),s=(0,f.useRef)(),c=(0,f.useState)(!0),l=c[0],u=c[1],d=(0,f.useState)(!0),p=d[0],m=d[1],h=(0,f.useState)(!1),x=h[0],v=h[1],g=(0,f.useState)({}),b=g[0],y=g[1],j=Object.keys(b).length,S=(n=j,i=(0,f.useRef)(0),(0,f.useEffect)((function(){i.current=n})),i.current),w=2e3;function k(){m(!0),s.current&&clearTimeout(s.current),s.current=setTimeout((function(){m(!1)}),w)}function F(){var e=o.current,t=a.current;if(e&&t){var r=e.getBoundingClientRect().bottom,n=t.getBoundingClientRect().bottom;u(n-1<=r)}}function C(){if(function(){var e,t=null===(e=o.current)||void 0===e?void 0:e.querySelectorAll("video");return!t||0===t.length||Array.from(t).every((function(e){return e.readyState>=1}))}()){var e=o.current;v(!0),e&&setTimeout((function(){k(),e.scrollTop=e.scrollHeight}),0)}else setTimeout(C,1)}function E(e){y((function(t){return Wt(t,e)}))}return(0,f.useEffect)((function(){var e=o.current;if(F(),e)return e.addEventListener("scroll",F),window.addEventListener("resize",F),function(){e.removeEventListener("scroll",F),window.removeEventListener("resize",F)}}),[l]),(0,f.useEffect)((function(){C()}),[x]),(0,f.useEffect)((function(){l&&0!==S&&j>S&&(k(),C())}),[l,Object.keys(b).length]),(0,f.useEffect)((function(){var e,r={};null===(e=t.receivedMessages)||void 0===e||e.forEach((function(e){var t=Wt(r,e);r=t})),y(r)}),[null===(r=t.receivedMessages)||void 0===r?void 0:r.length]),(0,f.useEffect)((function(){t.ws.onReceive&&t.ws.onReceive(E)}),[]),(0,e.jsxs)(At(),{ref:o,className:"rustic-message-space",children:[Object.keys(b).map((function(r,n){var i=b[r],o=i[i.length-1];return(0,e.jsx)(It,{message:o,getActionsComponent:t.getActionsComponent,getProfileComponent:t.getProfileComponent,ref:n===j-1?a:null,children:(0,e.jsx)(N,{ws:t.ws,sender:t.sender,messages:i,supportedElements:t.supportedElements})},r)})),!l&&!p&&(0,e.jsx)(Bt(),{variant:"rusticSecondary",className:"rustic-scroll-down-button",size:"medium",onClick:C,label:(0,e.jsxs)(e.Fragment,{children:[t.scrollDownLabel,(0,e.jsx)(re,{name:"arrow_downward"})]})})]})}Vt.defaultProps={scrollDownLabel:"Scroll down"};const Ut=function(t){return(0,e.jsx)(k(),{variant:"body2",className:"rustic-text",children:$e().sanitize(t.text)})};function Gt(t){return(0,e.jsxs)(At(),{className:"rustic-multipart",children:[t.text&&(0,e.jsx)(Ut,{text:t.text}),(r=t.files.map((function(t,r){return(0,e.jsx)(Fe,{file:t,children:t.url&&(0,e.jsx)(ee(),{title:"Download",children:(0,e.jsx)(H(),{component:"a",href:t.url,download:t.name,children:(0,e.jsx)(re,{name:"download"})})})},r)})),(0,e.jsx)(At(),{className:"rustic-files",children:r}))]});var r}const Kt=require("@mui/material/Dialog");var Qt=i.n(Kt);const Yt=require("@mui/material/DialogTitle");var Xt=i.n(Yt);const $t=require("@mui/material/List");var Zt=i.n($t);const Jt=require("@mui/material/ListItem");var er=i.n(Jt);const tr=require("@mui/material/ListSubheader");var rr=i.n(tr);const nr=require("pluralize");var ir,ar,or=i.n(nr);function sr(t){var r=(0,f.useState)(!1),n=r[0],i=r[1],a=t.participants.length,o=n?t.participants:t.participants.slice(0,3),s="".concat(or()(t.participantType,a)," (").concat(a,")"),c=n?"Show Less":"Show All ".concat(a);return 0===a?(0,e.jsx)(k(),{variant:"caption",className:"rustic-participant-list-no-participants-message",children:"There are currently no participants."}):(0,e.jsx)(Zt(),{className:"rustic-participant-list",subheader:(0,e.jsxs)(rr(),{disableSticky:!0,className:"rustic-participant-list-subheader",children:[(0,e.jsxs)(F.Box,{className:"rustic-participant-list-subheader-title",children:[t.participantTypeIcon,(0,e.jsx)(k(),{variant:"subtitle2",color:"text.secondary",children:s})]}),a>3&&(0,e.jsx)(it(),{onClick:function(){return i(!n)},color:"primary",size:"small",startIcon:(0,e.jsx)(re,{name:"keyboard_arrow_down"}),children:c})]}),children:o.map((function(t){return(0,e.jsxs)(er(),{className:"rustic-participant-list-item",children:[(0,e.jsx)(k(),{variant:"subtitle2",children:t.displayName}),(0,e.jsx)(k(),{variant:t.participantRole===ir.Owner?"subtitle2":"caption",children:D(t.participantRole)})]},t.id)}))})}!function(e){e.Owner="owner",e.Member="member"}(ir||(ir={})),function(e){e.Human="human",e.Agent="agent"}(ar||(ar={}));const cr=function(t){function r(e,t){return function(e){return function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}([],e,!0).sort((function(e,t){return t.participantRole===ir.Owner?1:-1}))}(e.filter((function(e){return e.participantType===t})))}var n=r(t.participants,ar.Human),i=r(t.participants,ar.Agent),a="".concat(or()("Participant",t.participants.length)," (").concat(t.participants.length,")");return(0,e.jsxs)(Qt(),{open:t.isParticipantListOpen,onClose:t.onClose,className:"rustic-participants-container",maxWidth:"sm",fullWidth:!0,children:[(0,e.jsx)(Xt(),{sx:{borderBottom:"1px solid",borderColor:"divider"},component:"h6",className:"rustic-participants-container-title",children:a}),(0,e.jsx)(sr,{participantType:"Human",participantTypeIcon:(0,e.jsx)(re,{name:"account_circle"}),participants:n}),i.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(vt(),{className:"rustic-participants-container-divider"}),(0,e.jsx)(sr,{participantType:"Agent",participantTypeIcon:(0,e.jsx)(re,{name:"smart_toy"}),participants:i})]})]})},lr=require("@mui/material/DialogActions");var ur=i.n(lr);const dr=require("@mui/material/DialogContent");var pr=i.n(dr);const mr=require("@mui/material/DialogContentText");var fr=i.n(mr),hr=function(){return hr=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},hr.apply(this,arguments)},xr=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function vr(t){var r=(0,f.useState)(!1),n=r[0],i=r[1],a=(0,f.useState)(!1),o=a[0],s=a[1],c=(0,f.useState)(!1),l=c[0],u=c[1],d=(0,f.useState)(!1),p=d[0],m=d[1],h=(0,f.useState)([]),x=h[0],v=h[1],g=(0,f.useState)(null),b=g[0],y=g[1],j=(0,F.useTheme)(),S=x[x.length-1],w=hr(hr({},t.ws),{send:function(e){y(e)}});function C(e){v((function(t){return xr(xr([],t,!0),[e],!1)}))}function E(){if(b){var e=hr(hr({},b),{threadId:t.messageId});t.ws.send(e)}}if((0,f.useEffect)((function(){t.ws.onReceive&&t.ws.onReceive(C)}),[t.ws]),(0,f.useEffect)((function(){x.length>0&&(S&&S.sender.id!==t.sender.id&&s(!1),"promptBuilder"===S.format&&S.data.isLastQuestion&&i(!0))}),[x.length]),0!==x.length)return(0,e.jsxs)(fe(),{variant:"outlined",className:"rustic-prompt-builder",children:[(0,e.jsxs)(Qt(),{open:l,onClose:function(){return u(!1)},"aria-labelledby":"quit-dialog-title","aria-describedby":"quit-dialog-description",sx:{"& .MuiPaper-root":{width:"clamp(320px,50vw,600px)",border:"1px solid ".concat(j.palette.divider)}},children:[(0,e.jsx)(Xt(),{id:"quit-dialog-title",className:"rustic-align-self-center",children:"Are you sure?"}),(0,e.jsx)(vt(),{}),(0,e.jsx)(pr(),{children:(0,e.jsx)(fr(),{id:"quit-dialog-description",className:"rustic-align-self-center",children:"All progress will be lost."})}),(0,e.jsxs)(ur(),{className:"rustic-prompt-builder-dialog-buttons",disableSpacing:!0,children:[(0,e.jsx)(it(),{variant:"rusticSecondary",startIcon:(0,e.jsx)(re,{name:"close"}),onClick:function(){u(!1),t.onCancel()},children:"Quit"}),(0,e.jsx)(it(),{variant:"rusticPrimary",onClick:function(){return u(!1)},children:"Continue build"})]})]}),t.getProfileComponent?t.getProfileComponent(x[0]):(0,e.jsx)(k(),{color:"text.secondary",children:"Prompt Builder"}),(0,e.jsx)(vt(),{className:"rustic-prompt-builder-divider"}),(0,e.jsxs)(F.Box,{className:"rustic-prompt-builder-questions",children:[function(){if(!p&&x.length>0)return x.map((function(r){if(r.sender.id!==t.sender.id&&"promptBuilder"!==r.format)return(0,e.jsx)(N,{ws:w,sender:t.sender,messages:[r],supportedElements:t.supportedElements},r.id)}))}(),o&&(0,e.jsx)(P(),{color:"secondary",className:"rustic-align-self-center"})]}),(0,e.jsx)(e.Fragment,{children:!p&&(0,e.jsxs)(F.Box,{className:"rustic-prompt-builder-buttons",children:[(0,e.jsxs)(F.Box,{className:"rustic-prompt-builder-buttons-left",children:[(0,e.jsx)(it(),{variant:"rusticSecondary",startIcon:(0,e.jsx)(re,{name:"close"}),onClick:function(){return u(!0)},children:"Quit"}),(0,e.jsx)(it(),{variant:"rusticSecondary",endIcon:(0,e.jsx)(re,{name:"chevron_right"}),onClick:function(){E(),y(null),s(!0)},disabled:!b,"aria-disabled":!b,children:"Next question"})]}),n&&(0,e.jsx)(F.Box,{className:"rustic-prompt-builder-buttons-right",children:(0,e.jsx)(it(),{variant:"rusticPrimary",onClick:function(){E(),m(!0),s(!0),t.onSubmit()},disabled:o,"aria-disabled":o,children:"Generate"})})]})})]})}function gr(t){var r=(0,f.useState)(""),n=r[0],i=r[1],a=(0,rt.useTheme)(),o=(0,rt.useMediaQuery)(a.breakpoints.down("md"))?"column":"row",s=t.options.map((function(r,a){return(0,e.jsx)(Bt(),{onClick:function(){return function(e){i(e);var r=(new Date).toISOString(),n={id:(0,_.v4)(),timestamp:r,sender:t.sender,conversationId:t.conversationId,format:"text",data:{text:e},inReplyTo:t.messageId};t.ws.send(n)}(r)},variant:"rusticSecondary",size:"small",sx:n===r?{"&.Mui-disabled":{backgroundColor:"secondary.light",color:"text.primary"}}:{},className:"rustic-option",disabled:!!n,"aria-disabled":!!n,label:r},a)}));return(0,e.jsxs)(u(),{className:"rustic-question",children:[(t.title||t.description)&&(0,e.jsxs)(u(),{className:"rustic-question-text",children:[t.title&&(0,e.jsx)(k(),{variant:"subtitle2",className:"rustic-title",children:t.title}),t.description&&(0,e.jsx)(k(),{variant:"caption",children:t.description})]}),(0,e.jsx)(Mt(),{direction:o,className:"rustic-options-container",children:s})]})}const br=require("@mui/material/Table");var yr=i.n(br);const jr=require("@mui/material/TableBody");var Sr=i.n(jr);const wr=require("@mui/material/TableCell");var kr=i.n(wr);const Fr=require("@mui/material/TableContainer");var Cr=i.n(Fr);const Er=require("@mui/material/TableHead");var Nr=i.n(Er);const Tr=require("@mui/material/TablePagination");var Or=i.n(Tr);const Pr=require("@mui/material/TableRow");var Rr=i.n(Pr);const Dr=require("@mui/material/TableSortLabel");var qr,Mr=i.n(Dr),zr=10;function Ir(){return(0,e.jsx)(re,{name:"expand_all"})}function Lr(t){if(0===t.data.length)return(0,e.jsx)(k(),{variant:"body2",children:"No data available"});var r,n,i,a=t.data.length>zr,o=(0,f.useState)({}),s=o[0],c=o[1],l=(0,f.useState)(a?zr:-1),u=l[0],d=l[1],p=(0,f.useState)(0),m=p[0],h=p[1],x=(0,rt.useTheme)(),v=Array.from(new Set(t.data.flatMap((function(e){return Object.keys(e)})))),g=t.headers||v.map((function(e){return{dataKey:e}})),b=(r=t.data,n=Object.keys(s)[0],i=s[n],n&&i?r.slice().sort((function(e,t){var r=Object.keys(s)[0],n=s[r];return e[r]<t[r]?n===qr.Descending?1:-1:e[r]>t[r]?n===qr.Descending?-1:1:0})):r),y=b.slice(m*u,m*u+u),j=u>0?y:b;function S(e){if(!s[e])return Ir}return(0,e.jsxs)(Mt(),{className:"rustic-table",spacing:1,children:[t.title&&(0,e.jsx)(k(),{variant:"h6",className:"rustic-table-title",children:t.title}),t.description&&(0,e.jsx)(k(),{variant:"body1",children:t.description}),(0,e.jsx)(Cr(),{className:"rustic-table-container",children:(0,e.jsxs)(yr(),{"aria-label":t.title||"a table of data",size:"small",stickyHeader:!0,children:[g.length>0&&(0,e.jsx)(Nr(),{children:(0,e.jsx)(Rr(),{children:g.map((function(t,r){return(0,e.jsx)(kr(),{sortDirection:s[t.dataKey]||!1,children:(0,e.jsx)(ee(),{title:(n=t.dataKey,i=s[n],i?Object.keys(qr)[Object.values(qr).indexOf(i)]:"Sort"),children:(0,e.jsx)(Mr(),{active:!0,direction:s[t.dataKey],onClick:function(){return function(e){c((function(t){var r,n,i={};switch(t[e]){case qr.Ascending:(r={})[e]=qr.Descending,i=r;break;case qr.Descending:i={};break;default:(n={})[e]=qr.Ascending,i=n}return i}))}(t.dataKey)},className:"rustic-table-header",IconComponent:S(t.dataKey),children:t.label||D(t.dataKey)})})},"header-".concat(r));var n,i}))})}),(0,e.jsx)(Sr(),{children:j.map((function(t,r){return(0,e.jsx)(Rr(),{children:g.map((function(n,i){return(0,e.jsx)(kr(),{children:t[n.dataKey]},"cell-".concat(r,"-").concat(i))}))},"row-".concat(r))}))})]})}),a&&(0,e.jsx)(Or(),{className:"rustic-table-pagination",component:"div",count:t.data.length,rowsPerPage:u,labelRowsPerPage:"Rows:",page:m,onPageChange:function(e,t){return h(t)},onRowsPerPageChange:function(e){d(+e.target.value),h(0)},sx:{"& .MuiTablePagination-selectLabel":{color:x.palette.text.disabled}},classes:{toolbar:"rustic-table-toolbar",input:"rustic-table-input",spacer:"rustic-table-spacer",displayedRows:"rustic-table-displayed-rows",actions:"rustic-table-actions"}})]})}!function(e){e.Ascending="asc",e.Descending="desc"}(qr||(qr={}));const Br=function(t){var r=(0,f.useState)($e().sanitize(t.text)),n=r[0],i=r[1],a=(0,f.useState)(""),o=a[0],s=a[1];return(0,f.useEffect)((function(){if(t.updatedData&&t.updatedData.length>0){for(var e=t.text,r=0,n=t.updatedData;r<n.length;r++){var a=n[r];"string"!=typeof a.text&&(e+=" [MISSING TEXT]",s("Some of the incoming text was not correctly formatted. Some data may be missing.")),e+=a.text}i($e().sanitize(e))}}),[t.text,t.updatedData]),(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(k(),{variant:"body2",children:n}),o&&(0,e.jsx)(Ie(),{severity:"error",children:o})]})};var _r=function(){return _r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},_r.apply(this,arguments)};function Ar(t){var r=$e().sanitize(t.youtubeVideoId);return(0,e.jsx)("iframe",_r({},z(t.width,t.height),{src:"https://www.youtube.com/embed/".concat(r),title:t.title,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen",loading:"lazy"}))}Ar.defaultProps={title:"Embedded video"};const Hr=require("@mui/material/FormControl");var Wr=i.n(Hr);const Vr=require("recharts");var Ur=function(){return Ur=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ur.apply(this,arguments)},Gr={line:Vr.LineChart,bar:Vr.BarChart,area:Vr.AreaChart};function Kr(e){var t={};return e.forEach((function(e){t[e]=!0})),t}function Qr(t){var r=(0,f.useState)(t.defaultChartType||"line"),n=r[0],i=r[1],a=(0,f.useState)(null),o=a[0],s=a[1],c=(0,f.useState)(t.timeSeries),l=c[0],u=c[1],d=ye()(),p=l.length>0?Object.keys(l[0]):[],m=p[0],h=p.slice(1),x=(0,f.useState)(Kr(h)),v=x[0],g=x[1];(0,f.useEffect)((function(){if(t.updatedData&&t.updatedData.length>0){var e=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}([],t.timeSeries,!0);t.updatedData.forEach((function(t){e=e.concat(t.timeSeries),u(e)}))}}),[t.timeSeries,t.updatedData]);var b=Gr[n];function y(e){o?s(null):e&&s(e.currentTarget)}function j(e,r){return v[e]?t.chartColors[r%t.chartColors.length]:"grey"}function S(e){return v[e]?"none":"line-through"}if(0===l.length)return(0,e.jsx)(k(),{variant:"body2",children:"No data available"});var w,F,C,E,N=t.timeSeries[t.timeSeries.length-1],T=(w=t.timeSeries[0][m],F=N[m],C=new Date(w),E=new Date(F),Math.round(Math.abs((E.getTime()-C.getTime())/864e5)));return(0,e.jsxs)(At(),{className:"rustic-recharts-time-series",children:[!t.disableChartTypeToggle&&(0,e.jsxs)(Wr(),{className:"rustic-recharts-time-series-chart-toggle",children:[(0,e.jsx)(H(),{"aria-label":"chart options","aria-expanded":Boolean(o),"aria-haspopup":"true",onClick:y,color:"primary",children:(0,e.jsx)(re,{name:"more_vert"})}),(0,e.jsxs)(Nt(),{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,open:Boolean(o),onClose:function(e){return y(e)},children:[(0,e.jsx)(k(),{className:"rustic-recharts-time-series-chart-toggle-title",children:"Chart Types:"}),Object.keys(Gr).map((function(t){return(0,e.jsxs)(G(),{value:t,selected:t===n,onClick:function(){return function(e){i(e),y()}(t)},children:[t.charAt(0).toUpperCase()+t.slice(1)," ","Chart"]},t)}))]})]}),(0,e.jsxs)(At(),{children:[t.title&&(0,e.jsx)(k(),{variant:"subtitle2",className:"rustic-recharts-time-series-title",children:t.title}),t.description&&(0,e.jsx)(k(),{variant:"caption",className:"rustic-recharts-time-series-description",children:t.description}),(0,e.jsx)(Vr.ResponsiveContainer,{aspect:t.aspectRatio,width:t.width,maxHeight:t.maxHeight,minWidth:t.minChartWidth,children:(0,e.jsxs)(b,{data:l,margin:t.chartContainerMargin,children:[(0,e.jsx)(Vr.XAxis,{dataKey:m,tickFormatter:function(e){return q(e,T)},stroke:d.palette.text.primary}),(0,e.jsx)(Vr.YAxis,{domain:["auto","auto"],width:t.yAxisLabelWidth,tickFormatter:t.yAxisTickFormatter,stroke:d.palette.text.primary}),(0,e.jsx)(Vr.Tooltip,{labelFormatter:function(e){return[q(e,T)]},formatter:t.tooltipFormatter,contentStyle:{color:d.palette.common.black}}),(0,e.jsx)(Vr.Legend,{content:function(){return(0,e.jsx)(At(),{className:"rustic-recharts-time-series-legend",children:h.map((function(t,r){return(0,e.jsxs)(At(),{className:"rustic-recharts-time-series-legend-item",onClick:function(){return function(e){var t,r=v[e]&&!h.find((function(t){return t!==e&&v[t]}));if(function(e){return Object.values(e).every((function(e){return!0===e}))}(v)){for(var n={},i=0,a=h;i<a.length;i++){var o=a[i],s=o===e;n[o]=s}g(n)}else g(r?Kr(h):Ur(Ur({},v),((t={})[e]=!v[e],t)))}(t)},sx:{color:j(t,r)},children:[(0,e.jsx)(re,{name:"crop_16_9"}),(0,e.jsx)(k(),{variant:"body2",display:"inline",sx:{textDecorationLine:S(t)},children:t})]},r)}))})}}),h.map((function(r,i){return v[r]?function(r,i){var a=i%t.chartColors.length,o=v[r]?t.chartColors[a]:"transparent",s={onClick:t.onClick,cursor:"pointer"};switch(n){case"line":return(0,e.jsx)(Vr.Line,{type:"monotone",isAnimationActive:!1,dataKey:r,name:r,dot:!1,stroke:o,activeDot:t.onClick&&s},r);case"bar":return(0,e.jsx)(Vr.Bar,{dataKey:r,fill:o,onClick:t.onClick&&s.onClick,cursor:t.onClick&&s.cursor},r);case"area":return(0,e.jsxs)(f.Fragment,{children:[(0,e.jsx)("defs",{children:(0,e.jsxs)("linearGradient",{id:"color".concat(r),x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,e.jsx)("stop",{offset:"5%",stopColor:o,stopOpacity:.8}),(0,e.jsx)("stop",{offset:"95%",stopColor:o,stopOpacity:0})]})}),(0,e.jsx)(Vr.Area,{isAnimationActive:!1,dataKey:r,type:"monotone",stroke:o,fillOpacity:1,fill:"url(#color".concat(r,")"),activeDot:t.onClick&&s},r)]},r)}}(r,i):null})),t.referenceLineYAxis&&t.referenceLineYAxis.map((function(r,n){return(0,e.jsx)(Vr.ReferenceLine,{y:r,label:t.referenceLineLabel&&t.referenceLineLabel[n],stroke:t.referenceLineColor&&t.referenceLineColor[n],strokeDasharray:"3 3",ifOverflow:"extendDomain",strokeWidth:t.referenceLineStrokeWidth&&t.referenceLineStrokeWidth[n],isFront:!0},n)}))]})})]})]})}Qr.defaultProps={minChartWidth:200,maxHeight:600,yAxisLabelWidth:30,aspectRatio:16/9,disableChartTypeToggle:!1};const Yr=Qr,Xr=require("mermaid");var $r=i.n(Xr),Zr=function(){return Zr=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Zr.apply(this,arguments)};const Jr=function(t){var r=(0,f.useRef)(null),n=(0,f.useState)(),i=n[0],a=n[1],o=ye()(),s=(0,_.v4)();return(0,f.useEffect)((function(){var e="dark"===o.palette.mode?"dark":"neutral",n=o.typography.fontFamily;r.current&&($r().initialize(Zr({theme:e,themeVariables:{fontFamily:n}},t.config)),$r().render("mermaid-svg-".concat(s),t.diagram,r.current).then((function(e){r.current&&(r.current.innerHTML=e.svg),a("")})).catch((function(){var e;null===(e=r.current)||void 0===e||e.replaceChildren(),a("Failed to render the diagram.")})))})),(0,e.jsxs)(Mt(),{className:"rustic-mermaid-container",children:[t.title&&(0,e.jsx)(k(),{variant:"subtitle2",children:t.title}),t.description&&(0,e.jsx)(k(),{variant:"caption",children:t.description}),(0,e.jsx)("div",{className:"rustic-mermaid",ref:r}),i&&(0,e.jsx)(k(),{variant:"body2",children:i})]})},en=(require("@finos/perspective-viewer"),require("@finos/perspective-viewer-datagrid"),require("@finos/perspective-viewer-d3fc"),require("@finos/perspective-viewer/dist/css/pro.css"),require("@finos/perspective-viewer/dist/css/pro-dark.css"),require("@finos/perspective"));var tn=i.n(en),rn=function(){return rn=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},rn.apply(this,arguments)};function nn(e){return e?e.reduce((function(e,t){var r=t.dataKey,n=t.label;return e[r]=n||r,e}),{}):{}}const an=function(t){if(0===t.data.length)return(0,e.jsx)(k(),{variant:"body2",children:"No data available."});var r=(0,f.useRef)(null),n=(0,d.useTheme)(),i=(0,f.useState)(!1),a=i[0],o=i[1],s=n.palette.mode,c="dark"===s?"Pro Dark":"Pro Light",l=nn(t.headers),u="\n /* General Button Styles */\n button, .button:hover, #editor-container, .editable, #settings_button {\n border-radius: 16px !important;\n color: ".concat(n.palette.text.primary," !important;\n /* TODO: add background color after updating the theme */\n }\n \n #settings_button {\n border: 1px solid ").concat(n.palette.primary.light," !important;\n }\n \n /* Hide border for aggregate Selector */\n .aggregate-selector:hover {\n border: none !important;\n }\n \n /* Input and Select Elements */\n input, select, .noselect, #add-expression, .dropdown-width-container, \n .pivot-column-border, .pivot-column, .column-selector-column-border {\n border-radius: 8px !important;\n }\n \n /* Change background color */\n #settings_panel, #column_settings_sidebar {\n background: ").concat("dark"===s?"dark":"white"," !important;\n background-image: none !important;\n }\n \n /* Expression Edit Button */\n .expression-edit-button {\n display: none;\n }\n \n /* Add padding to expression input */\n #editor-container, .editable {\n padding: 8px !important;\n }\n \n /* Change Button Font Size */\n .button select, .button {\n font-size: 12px !important;\n }\n \n /* Button and Icon Colors */\n span.button {\n color: ").concat(n.palette.primary.main," !important;\n }\n \n span.button:hover:before {\n background-color: ").concat(n.palette.primary.main," !important;\n }\n \n .button select:hover, .button:hover, .psp-expression-editor__button:hover, \n .sidebar_close_button_inner:hover {\n background-color: ").concat(n.palette.primary.light," !important;\n }\n \n /* Enable Scrolling */\n #plugin_selector_container.open, #status_bar, #menu-bar, #app_panel {\n overflow: scroll !important;\n }\n \n /* Hide unused buttons */\n #debug_open_button.sidebar_close_button, .reset-default-style-disabled, \n .expression-edit-button, #theme, #status, #status_bar .input-sizer {\n display: none !important;\n }\n ");var p,m,h,x,v,g,b,y,j,S=t.config&&(m=(p=t.config).groupBy,h=p.splitBy,x=p.aggregates,v=p.sort,g=p.filter,b=p.columns,y=null==v?void 0:v.map((function(e){return[l[e[0]]||e[0],e[1]]})),j=x&&Object.fromEntries(Object.entries(x).map((function(e){var t=e[0],r=e[1];return[l[t]||t,r]}))),{group_by:null==m?void 0:m.map((function(e){return l[e]||e})),split_by:null==h?void 0:h.map((function(e){return l[e]||e})),aggregates:j,sort:y,filter:g&&function(e){return e.map((function(e){return[l[e[0]]||e[0],e[1],e[e.length-1]]}))}(g),columns:null==b?void 0:b.map((function(e){return l[e]||e}))});return(0,f.useEffect)((function(){tn().worker().table(function(e,t){var r=nn(t);return e.map((function(e){for(var t={},n=0,i=Object.entries(e);n<i.length;n++){var a=i[n],o=a[0],s=a[1];t[r[o]||o]=[s]}return t}))}(t.data,t.headers)).then((function(e){var n=r.current;n&&n.load(e).then((function(){if(n.restore(rn(rn({},S),{theme:c,title:t.title,settings:!1})),n.shadowRoot){var e=new CSSStyleSheet;e.replaceSync(u),n.shadowRoot.adoptedStyleSheets.push(e)}})).catch((function(){o(!0)}))})).catch((function(){o(!0)}))}),[t.data,c]),a?(0,e.jsx)(k(),{variant:"body2",children:"Failed to create table from data."}):(0,e.jsxs)(ge(),{direction:"column",className:"rustic-perspective-viz",children:[t.title&&(0,e.jsx)(k(),{variant:"h6",children:t.title}),t.description&&(0,e.jsx)(k(),{variant:"body1",children:t.description}),(0,e.jsx)("perspective-viewer",{ref:r,style:{fontFamily:n.typography.fontFamily}})]})},on=require("react-dom/server"),sn=require("vega-embed");var cn=i.n(sn),ln=function(){return ln=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ln.apply(this,arguments)};function un(t){var r=(0,f.useRef)(null),n=(0,f.useState)(!1),i=n[0],a=n[1],o=ye()(),s="dark"===o.palette.mode,c=o.typography.fontFamily,l={backgroundColor:o.palette.primary.main,color:o.palette.background.paper,borderRadius:o.shape.borderRadius+"px",padding:"4px 8px",fontSize:o.typography.caption.fontSize,fontFamily:c,fontWeight:o.typography.caption.fontWeight},u={formatTooltip:function(t,r){return(0,on.renderToStaticMarkup)((0,e.jsx)("div",{role:"tooltip",className:"rustic-vega-lite-tooltip-content",style:l,children:Object.entries(t).map((function(t){var n=t[0],i=t[1];return(0,e.jsxs)("div",{children:[(0,e.jsxs)("strong",{children:[r(n),":"]})," ",r(i)]},n)}))}))},disableDefaultStyle:!0,id:"rustic-vega-lite-tooltip"},d=[{label:"Save as SVG"},{label:"Save as PNG"}];function p(){var e,n,i,o;if(r.current&&t.spec){var l=ln(ln({config:{font:c}},t.options),{theme:s?null===(e=t.theme)||void 0===e?void 0:e.dark:null===(n=t.theme)||void 0===n?void 0:n.light,tooltip:u,actions:!1});(null===(o=null===(i=t.options)||void 0===i?void 0:i.config)||void 0===o?void 0:o.font)||(l.config.font=c);var p=ln({},t.spec);delete p.title,cn()(r.current,p,l).then((function(e){var t=e.embedOptions,r=e.embedOptions.downloadFileName||"visualization";["svg","png"].map((function(n,i){var a="object"==typeof t.scaleFactor?t.scaleFactor[n]:t.scaleFactor;e.view.toImageURL(n,a).then((function(e){d[i].href=e,d[i].downloadFileName="".concat(r,".").concat(n)}))})),a(!1)})).catch((function(){a(!0)}))}}return(0,f.useEffect)((function(){function e(){p()}return p(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[t.spec,s]),i?(0,e.jsx)(k(),{variant:"body2",children:"Failed to load the chart."}):(0,e.jsxs)(ge(),{direction:"column",className:"rustic-vega-lite-container",children:[(0,e.jsx)(At(),{justifyContent:"end",display:"flex",children:(0,e.jsx)(Ot,{menuItems:d,ariaLabel:"Download options"})}),t.title&&(0,e.jsx)(k(),{variant:"h6",children:t.title}),t.description&&(0,e.jsx)(k(),{variant:"body1",children:t.description}),(0,e.jsxs)(At(),{textAlign:"center",mt:1,children:["string"==typeof t.spec.title&&(0,e.jsx)(k(),{variant:"subtitle2",children:t.spec.title}),t.spec.description&&(0,e.jsx)(k(),{variant:"caption",children:t.spec.description})]}),(0,e.jsx)("div",{ref:r,className:"rustic-vega-lite"})]})}const dn=un;function pn(t){var r=(0,f.useState)(t.units),n=r[0],i=r[1];function a(e){return"metric"===t.units&&"imperial"===n?Math.round(1.8*e+32):"imperial"===t.units&&"metric"===n?Math.round(e*(5/9)-32):Math.round(e)}var o=new Date(1e3*t.weather[0].timestamp),s=I(t.weather[0].timestamp).shortName,c=o.getDate(),l=o.getFullYear().toString().slice(2),d="".concat(s," ").concat(c,"/").concat(l," TODAY"),p="HIGH: ".concat(a(t.weather[0].temp.high)," / LOW: ").concat(a(t.weather[0].temp.high)),m=t.weather.map((function(t,r){if(0!==r)return(0,e.jsxs)(fe(),{variant:"outlined",className:"rustic-daily-weather-card",children:[(0,e.jsx)(k(),{variant:"h5",component:"span",color:"text.secondary","aria-label":I(t.timestamp).fullName,children:I(t.timestamp).shortName}),(0,e.jsx)("img",{src:t.weatherIcon.icon,alt:t.weatherIcon.description}),(0,e.jsxs)(k(),{variant:"body2",color:"text.secondary",children:["High: ",a(t.temp.high),"°"]}),(0,e.jsxs)(k(),{variant:"body2",color:"text.secondary",children:["Low: ",a(t.temp.low),"°"]})]},r)}));return(0,e.jsxs)(fe(),{variant:"outlined",className:"rustic-weather",children:[(0,e.jsx)(Ot,{ariaLabel:"Temperature units",menuItems:[{label:"Celsius",endDecorator:"°C",onClick:function(){return i("metric")}},{label:"Fahrenheit",endDecorator:"°F",onClick:function(){return i("imperial")}}]}),(0,e.jsxs)(Mt(),{alignItems:"center",children:[(0,e.jsx)(k(),{variant:"h4",component:"span",children:t.location}),(0,e.jsxs)(Mt(),{direction:"row",alignItems:"center",spacing:1,className:"rustic-current-weather-description",children:[(0,e.jsx)("img",{src:t.weather[0].weatherIcon.icon,alt:""}),(0,e.jsx)(k(),{variant:"body2",children:t.weather[0].weatherIcon.description})]}),t.weather[0].temp.current&&(0,e.jsxs)(k(),{variant:"h1",component:"span",className:"rustic-current-temp",children:[a(t.weather[0].temp.current),"°",function(e){switch(e){case"imperial":return"F";case"metric":return"C"}}(n)]}),(0,e.jsxs)(Mt(),{direction:"row",spacing:2,children:[(0,e.jsx)(k(),{variant:"overline",children:d}),(0,e.jsx)(k(),{variant:"overline",children:p})]})]}),(0,e.jsx)(u(),{className:"rustic-daily-weather-container",children:m}),t.weatherProvider&&(0,e.jsxs)(Mt(),{alignItems:"center",direction:"row",spacing:1,alignSelf:"center",className:"rustic-weather-attribution",children:[(0,e.jsx)(re,{name:"cloud"}),(0,e.jsx)(k(),{variant:"body2",children:"Weather data provided by ".concat(t.weatherProvider)})]})]})}un.defaultProps={theme:{dark:"dark"}};var mn=i(470)})(),a})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e,t,r={986:(e,t,r)=>{r.d(t,{default:()=>c});var n=r(997),i=r(934),a=r.n(i),o=r(229),s=r.n(o);r(689);const c=function(e){return(0,n.jsx)(s(),{title:e.label,children:(0,n.jsx)(a(),{color:"inherit","aria-label":e.label,onClick:function(t){t.stopPropagation(),t.preventDefault(),e.onClick(e.message)},className:"rustic-message-actions",children:e.icon})})}},470:(e,t,r)=>{r.d(t,{rusticDarkTheme:()=>J,rusticLightTheme:()=>q});var n=r(442);const i=require("@mui/utils");var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)},o="#000000",s="#FFFFFF",c="#FF6928",l="#E54500",u="#FF692899",d="#FF69284D",p=(0,n.createTheme)({shape:{borderRadius:16},typography:{fontFamily:"Inter",h1:{fontStyle:"normal",fontWeight:300,fontSize:"94px",lineHeight:1.167,letterSpacing:"-1.5px"},h2:{fontStyle:"normal",fontWeight:300,fontSize:"59px",letterSpacing:"-0.5px",lineHeight:1.2},h3:{fontStyle:"normal",fontWeight:400,fontSize:"47px",letterSpacing:"0px",lineHeight:1.167},h4:{fontStyle:"normal",fontWeight:400,fontSize:"33px",letterSpacing:"0.25px",lineHeight:1.235},h5:{fontStyle:"normal",fontWeight:400,fontSize:"24px",letterSpacing:"0px",lineHeight:1.334},h6:{fontStyle:"normal",fontWeight:500,fontSize:"20px",letterSpacing:"0.15px",lineHeight:1.6},body1:{fontStyle:"normal",fontWeight:400,fontSize:"16px",letterSpacing:"0.5px",lineHeight:1.5},body2:{fontStyle:"normal",fontWeight:400,fontSize:"14px",letterSpacing:"0.25px",lineHeight:1.43},subtitle1:{fontStyle:"normal",fontWeight:400,fontSize:"16px",letterSpacing:"0.15px",lineHeight:1.75},subtitle2:{fontStyle:"normal",fontWeight:500,fontSize:"14px",letterSpacing:"0.1px",lineHeight:1.57},overline:{fontStyle:"normal",fontWeight:400,fontSize:"10px",letterSpacing:"1.5px",lineHeight:1.5,textTransform:"uppercase"},caption:{fontStyle:"normal",fontWeight:400,fontSize:"12px",letterSpacing:"0.4px",lineHeight:1.66},button:{textTransform:"none"}},palette:{common:{black:o,white:s},error:{main:"#F82A43",dark:"#C82639",light:"#FF9BA7"},warning:{main:"#FFB800",dark:"#DC8400",light:"#FFDB7D"},info:{main:"#0094FF",dark:"#005A9B",light:"#8CCFFF"}},shadows:function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}([],(0,n.createTheme)({}).shadows.map((function(e,t){return 1===t?"0 4px 5px rgba(0, 0, 0, 0.05)":2===t?"0 4px 10px rgba(0, 0, 0, 0.1)":3===t?"0 4px 15px rgba(0, 0, 0, 0.15)":"none"})),!0)}),m={fontSize:"12px",lineHeight:1.5,letterSpacing:"0.5px",padding:"0 12px",minHeight:"26px"},f={fontSize:"14px",lineHeight:1.43,letterSpacing:"0.25px",padding:"0 16px",minHeight:"40px"},h={fontSize:"16px",lineHeight:1.75,letterSpacing:"0.15px",padding:"0 24px",minHeight:"64px"},x="#E1D9D5",v="#0000001F",g="#2D2825",b="#2D282599",y="#1E0C04",j="#9C9795",S="#00000061",w="#2D282514",k="#2D28251F",F="#2D28254D",C="#2D282580",E={fontWeight:700},N={"&.Mui-disabled":{background:s,color:j,border:"1px solid ".concat(S)}},T=a(a(a({},E),{background:g,color:s,"&:hover":{background:b},"&:focus":{border:"4px solid ".concat(b)}}),N),O=a(a(a({},E),{background:s,color:y,border:"1px solid ".concat(b),"&:focus":{border:"4px solid ".concat(b)}}),N),P={fontWeight:400,"& .MuiChip-label":{padding:0,display:"flex",alignItems:"center",gap:"8px"}},R=a({background:F,color:y,border:"1px solid ".concat(C),"&:hover":{border:"1px solid ".concat(C),background:w},"&:focus":{border:"3px solid ".concat(C),background:k},"&.Mui-disabled":{background:S,opacity:100,border:"none",color:s,"& .MuiChip-icon":{color:s}},"& .MuiChip-icon":{margin:"0px 8px 0px 0px",color:y}},P),D=a({background:s,color:y,border:"1px solid ".concat(u),"&:focus":{border:"4px solid ".concat(u)},"&.Mui-disabled":{border:"1px solid ".concat(u),background:s,color:u,opacity:100},"& .MuiChip-icon":{margin:"0px 8px 0px 0px",color:y}},P),q=(0,n.createTheme)((0,i.deepmerge)(p,{palette:{mode:"light",divider:x,text:{primary:y,secondary:"#4E443F",disabled:j},primary:{main:g,dark:o,light:b,contrastText:s,focus:k,focusVisible:F,hover:w,selected:"#2D282529",border:C},secondary:{main:c,light:u,dark:l,contrastText:s,focus:"#FF69281F",focusVisible:d,hover:"#FF692814",selected:"#FF692829",border:"#FF692880"},background:{default:"#F7F6F5",paper:s},action:{active:"#0000008F",hover:"#00000014",selected:"#00000029",disabledBackground:v,focus:v,disabled:S},success:{main:"#007F51",dark:"#014F33",light:"#00D788",contrastText:s},error:{contrastText:s},warning:{contrastText:s},info:{contrastText:s}},components:{MuiTooltip:{styleOverrides:{tooltip:{backgroundColor:g,color:s}}},MuiTableCell:{styleOverrides:{head:{backgroundColor:v},root:{borderBottom:"1px solid ".concat(x),padding:"8px 16px"}}},MuiTableSortLabel:{styleOverrides:{root:{"&.Mui-active":{"& .MuiTableSortLabel-icon":{color:y}}}}},MuiPopover:{styleOverrides:{paper:{border:"1px solid ".concat(x),backgroundImage:"none"}}},MuiButton:{variants:[{props:{variant:"rusticPrimary",size:"small"},style:a(a({borderRadius:"8px"},m),T)},{props:{variant:"rusticPrimary",size:"medium"},style:a(a({borderRadius:"12px"},f),T)},{props:{variant:"rusticPrimary",size:"large"},style:a(a({borderRadius:"16px"},h),T)},{props:{variant:"rusticSecondary",size:"small"},style:a(a({borderRadius:"8px","&:hover":{border:"1px solid ".concat(o),background:s}},m),O)},{props:{variant:"rusticSecondary",size:"medium"},style:a(a({borderRadius:"12px","&:hover":{border:"2px solid ".concat(o),background:s}},f),O)},{props:{variant:"rusticSecondary",size:"large"},style:a(a({borderRadius:"16px","&:hover":{border:"2px solid ".concat(o),background:s}},h),O)}]},MuiChip:{variants:[{props:{variant:"rusticPrimary",size:"small"},style:a(a({borderRadius:"24px"},m),R)},{props:{variant:"rusticPrimary",size:"medium"},style:a(a({borderRadius:"32px"},f),R)},{props:{variant:"rusticPrimary",size:"large"},style:a(a({borderRadius:"48px"},h),R)},{props:{variant:"rusticSecondary",size:"small"},style:a(a({borderRadius:"24px","&:hover":{border:"1px solid ".concat(c),background:s}},m),D)},{props:{variant:"rusticSecondary",size:"medium"},style:a(a({borderRadius:"32px","&:hover":{border:"2px solid ".concat(c),background:s}},f),D)},{props:{variant:"rusticSecondary",size:"large"},style:a(a({borderRadius:"48px","&:hover":{border:"2px solid ".concat(c),background:s}},h),D)}]}}})),M="#FFFFFF61",z="#FFFFFF1F",I="#E1D9D5",L="#202020",B="#FFFCFB",_="#FFFCFB99",A="#000000DE",H="#FFFFFF61",W="#FF692880",V="#FFFCFB1F",U="#FFFCFB4D",G="#FFFCFB14",K="#FFFFFF4D",Q={"&.Mui-disabled":{background:K,color:M,border:"1px solid ".concat(H)}},Y=a(a(a({},E),{background:B,color:o,"&:hover":{background:_},"&:focus":{border:"4px solid ".concat(_)}}),Q),X=a(a(a({},E),{background:L,color:s,border:"1px solid ".concat(_),"&:focus":{border:"4px solid ".concat(_)}}),Q),$=a(a({background:U,color:s,border:"1px solid ".concat(W),"&:hover":{border:"1px solid ".concat(W),background:G},"&:focus":{border:"4px solid ".concat(_),background:V},"&.Mui-disabled":{background:H,opacity:100,border:"none",color:A,"& .MuiChip-icon":{color:A}}},P),{"& .MuiChip-icon":{margin:"0px 8px 0px 0px",color:s}}),Z=a({background:L,color:s,border:"1px solid ".concat(u),"&:focus":{border:"4px solid ".concat(u)},"&.Mui-disabled":{background:L,color:u,border:"1px solid ".concat(u),opacity:100},"& .MuiChip-icon":{margin:"0px 8px 0px 0px",color:s}},P),J=(0,n.createTheme)((0,i.deepmerge)(p,{palette:{mode:"dark",divider:I,primary:{main:B,dark:s,light:_,contrastText:A,hover:G,selected:"#FFFCFB29",focus:V,focusVisible:U,border:W},secondary:{main:c,light:u,dark:l,contrastText:A,hover:"#FF692814",selected:"#FF692829",focus:"#FF69281F",focusVisible:d,border:"#FF692880"},background:{default:"#2C2C2C",paper:L},text:{primary:s,secondary:"#FFFFFFB2",disabled:M},action:{active:K,hover:K,selected:"#FFFFFF29",focus:z,disabledBackground:z,disabled:H},success:{main:"#00B775",dark:"#01784D",light:"#00E390",contrastText:A},error:{contrastText:A},warning:{contrastText:A},info:{contrastText:A}},components:{MuiTooltip:{styleOverrides:{tooltip:{backgroundColor:B,color:o}}},MuiTableSortLabel:{styleOverrides:{root:{"&.Mui-active":{"& .MuiTableSortLabel-icon":{color:s}}}}},MuiTableCell:{styleOverrides:{head:{backgroundColor:z},root:{borderBottom:"1px solid ".concat(I),padding:"8px 16px"}}},MuiPopover:{styleOverrides:{paper:{border:"1px solid ".concat(I),backgroundImage:"none"}}},MuiChip:{variants:[{props:{variant:"rusticPrimary",size:"small"},style:a(a({borderRadius:"24px"},m),$)},{props:{variant:"rusticPrimary",size:"medium"},style:a(a({borderRadius:"32px"},f),$)},{props:{variant:"rusticPrimary",size:"large"},style:a(a({borderRadius:"48px"},h),$)},{props:{variant:"rusticSecondary",size:"small"},style:a(a({borderRadius:"24px","&:hover":{background:L,border:"1px solid ".concat(c)}},m),Z)},{props:{variant:"rusticSecondary",size:"medium"},style:a(a({borderRadius:"32px","&:hover":{background:L,border:"2px solid ".concat(c)}},f),Z)},{props:{variant:"rusticSecondary",size:"large"},style:a(a({borderRadius:"48px","&:hover":{background:L,border:"2px solid ".concat(c)}},h),Z)}]},MuiButton:{variants:[{props:{variant:"rusticPrimary",size:"small"},style:a(a({borderRadius:"8px"},m),Y)},{props:{variant:"rusticPrimary",size:"medium"},style:a(a({borderRadius:"12px"},f),Y)},{props:{variant:"rusticPrimary",size:"large"},style:a(a({borderRadius:"16px"},h),Y)},{props:{variant:"rusticSecondary",size:"small"},style:a(a({borderRadius:"8px","&:hover":{background:L,border:"1px solid ".concat(s)}},m),X)},{props:{variant:"rusticSecondary",size:"medium"},style:a(a({borderRadius:"12px","&:hover":{background:L,border:"2px solid ".concat(s)}},f),X)},{props:{variant:"rusticSecondary",size:"large"},style:a(a({borderRadius:"16px","&:hover":{background:L,border:"2px solid ".concat(s)}},h),X)}]}}}));q=(0,n.responsiveFontSizes)(q),J=(0,n.responsiveFontSizes)(J)},934:e=>{e.exports=require("@mui/material/IconButton")},229:e=>{e.exports=require("@mui/material/Tooltip")},442:e=>{e.exports=require("@mui/material/styles")},13:e=>{e.exports=require("emoji-picker-element")},689:e=>{e.exports=require("react")},997:e=>{e.exports=require("react/jsx-runtime")}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var a=n[e]={exports:{}};return r[e](a,a.exports,i),a.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var a=Object.create(null);i.r(a);var o={};e=e||[null,t({}),t([]),t(t)];for(var s=2&n&&r;"object"==typeof s&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach((e=>o[e]=()=>r[e]));return o.default=()=>r,i.d(a,o),a},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{i.r(a),i.d(a,{Action:()=>Rt.default,CodeSnippet:()=>C,CopyText:()=>Dt,ElementRenderer:()=>N,FCCalendar:()=>g,Image:()=>B,MarkedMarkdown:()=>tt,MarkedStreamingMarkdown:()=>rt,MermaidViz:()=>en,MessageCanvas:()=>Lt,MessageSpace:()=>Ut,MultimodalInput:()=>De,Multipart:()=>Kt,OpenLayersMap:()=>Xe,PDFViewer:()=>ke,ParticipantsContainer:()=>lr,PerspectiveViz:()=>on,PopoverMenu:()=>Pt,PromptBuilder:()=>gr,Question:()=>br,RechartsTimeSeries:()=>Xr,Sound:()=>yt,StreamingText:()=>_r,Table:()=>Br,Text:()=>Gt,TextInput:()=>ze,TextToSpeech:()=>qt,Timestamp:()=>It,Uploader:()=>Oe,VegaLiteViz:()=>pn,Video:()=>wt,Weather:()=>mn,YoutubeVideo:()=>Hr,rusticDarkTheme:()=>fn.rusticDarkTheme,rusticLightTheme:()=>fn.rusticLightTheme});var e=i(997);const t=require("@fullcalendar/daygrid");var r=i.n(t);const n=require("@fullcalendar/react");var o=i.n(n);const s=require("@fullcalendar/timegrid");var c=i.n(s);const l=require("@mui/material/Box");var u=i.n(l),d=i(442);const p=require("@mui/material/useMediaQuery");var m=i.n(p),f=i(689),h=i.n(f),x=function(){return x=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},x.apply(this,arguments)};function v(e){return{title:e.title?e.title:"",start:e.start,end:e.end,allDay:e.isAllDay}}function g(t){var n=(0,d.useTheme)(),i=m()(n.breakpoints.up("md"));return(0,e.jsx)(u(),{className:"rustic-fc-calendar",sx:{border:"1px solid ".concat(n.palette.divider),borderRadius:"".concat(n.shape.borderRadius,"px"),".fc .fc-toolbar-title":x({},n.typography.h6),".fc .fc-scrollgrid-liquid":{borderRadius:"".concat(n.shape.borderRadius,"px")},".fc td":{borderRadius:"0 0 ".concat(n.shape.borderRadius,"px ").concat(n.shape.borderRadius,"px")},".fc .fc-scrollgrid-section-header > th":{borderRadius:"".concat(n.shape.borderRadius,"px ").concat(n.shape.borderRadius,"px 0 0")},".fc .fc-button, .fc .fc-button:active":{color:n.palette.primary.main,backgroundColor:n.palette.background.paper,border:"1px solid ".concat(n.palette.divider),borderRadius:"".concat(n.shape.borderRadius,"px"),"&:hover":{backgroundColor:n.palette.secondary.light,border:"1px solid ".concat(n.palette.divider)}},".fc .fc-button-group .fc-button.fc-button-active":{backgroundColor:n.palette.secondary.main,border:"1px solid ".concat(n.palette.divider)},".fc a, .fc .fc-event-title, .fc .fc-button, .fc .fc-timegrid-slot":x({},n.typography.caption)},children:(0,e.jsx)(o(),{plugins:[c(),r()],initialView:i?"dayGridMonth":"timeGridDay",headerToolbar:{left:"title",right:"prev,next dayGridMonth,timeGridWeek,timeGridDay"},eventColor:n.palette.secondary.main,displayEventTime:!1,titleFormat:{year:"numeric",month:"long"},views:{dayGridMonth:{dayHeaderFormat:{weekday:i?"long":"narrow"}},timeGridWeek:{dayHeaderFormat:{weekday:"short",day:"numeric"}},timeGridDay:{dayHeaderFormat:{weekday:"long",day:"numeric"}}},allDaySlot:!1,initialDate:t.events[0].start,events:t.events.map(v)})})}const b=require("@codemirror/language"),y=require("@codemirror/language-data"),j=require("@codemirror/state"),S=require("@codemirror/view"),w=require("@mui/material/Typography");var k=i.n(w);const F=require("@mui/system");function C(t){var r=(0,f.useRef)(null),n=(0,f.useRef)(),i=new j.Compartment,a=[j.EditorState.readOnly.of(!0),(0,S.highlightSpecialChars)(),(0,b.syntaxHighlighting)(b.defaultHighlightStyle,{fallback:!0}),i.of([])],o=y.languages.find((function(e){return e.name.toLowerCase()===t.language.toLowerCase()}));return(0,f.useEffect)((function(){if(r.current&&!n.current){var e=r.current,s=j.EditorState.create({doc:t.code,extensions:a});n.current=new S.EditorView({state:s,parent:e}),o&&n.current&&o.load().then((function(e){var t;null===(t=n.current)||void 0===t||t.dispatch({effects:i.reconfigure(e.extension)})}))}}),[]),(0,e.jsx)(F.Box,{sx:{backgroundColor:"background.default"},className:"rustic-code-snippet",children:(0,e.jsx)("div",{"aria-label":"code snippet",ref:r,children:(0,e.jsx)(k(),{variant:"body2","aria-label":"language type",children:t.language})})})}var E=function(){return E=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},E.apply(this,arguments)};const N=function(t){var r=t.messages[0],n=t.messages.slice(1),i=t.supportedElements[r.format];return(0,e.jsx)(e.Fragment,{children:i?h().createElement(i,E(E({sender:t.sender,ws:t.ws,messageId:r.id,conversationId:r.conversationId},r.data),n.length>0&&{updatedData:n.map((function(e){return e.data}))})):(0,e.jsxs)(k(),{variant:"body2",children:["Unsupported element format: ",r.format]})})},T=require("@mui/material/CircularProgress");var O,P=i.n(T),R=function(){return R=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},R.apply(this,arguments)},D=function(e){return e.charAt(0).toUpperCase()+e.slice(1)};function q(e,t){return function(e,t){var r,n=new Date(e),i=navigator.language;return r=t===O.HOUR?{hour:"numeric",minute:"2-digit",hour12:!0}:{month:"short",day:"numeric"},n.toLocaleString(i,r)}(e,t<=1?O.HOUR:O.MONTH_DATE)}function M(e){var t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=Math.floor(e%60),i=t>0?"".concat(t,":"):"",a="".concat(t>0?r.toString().padStart(2,"0"):r),o=n.toString().padStart(2,"0");return"".concat(i).concat(a,":").concat(o)}function z(e,t){var r={};return e&&(r={width:e}),t&&(r=R(R({},r),{height:t})),e||t||(r={className:"rustic-fit-container"}),r}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(O||(O={}));var I=function(e){var t=["Sun","Mon","Tues","Wed","Thurs","Fri","Sat"][new Date(1e3*e).getDay()];return{shortName:t,fullName:{Sun:"Sunday",Mon:"Monday",Tues:"Tuesday",Wed:"Wednesday",Thurs:"Thursday",Fri:"Friday",Sat:"Saturday"}[t]}},L=function(){return L=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},L.apply(this,arguments)};function B(t){var r=(0,f.useState)(!0),n=r[0],i=r[1],a=(0,f.useState)(""),o=a[0],s=a[1];return o.length>0?(0,e.jsx)(k(),{variant:"body2",children:o}):(0,e.jsxs)("figure",{children:[n&&(0,e.jsx)(P(),{}),(0,e.jsx)("img",L({},z(t.width,t.height),{src:t.src,alt:t.alt,onError:function(){s("Image failed to load"),i(!1)},onLoad:function(){i(!1)}})),t.description&&(0,e.jsx)("figcaption",{children:(0,e.jsx)(k(),{variant:"body2",children:t.description})})]})}B.defaultProps={alt:"An image is displayed"};const _=require("uuid");var A=i(934),H=i.n(A);const W=require("@mui/material/InputAdornment");var V=i.n(W);const U=require("@mui/material/MenuItem");var G=i.n(U);const K=require("@mui/material/MenuList");var Q=i.n(K);const Y=require("@mui/material/Popover");var X=i.n(Y);const $=require("@mui/material/TextField");var Z=i.n($),J=i(229),ee=i.n(J),te=i(13);function re(t){return t.name.replaceAll("_","-"),(0,e.jsx)("span",{className:"".concat(t.className?t.className+" ":"","material-symbols-rounded"),children:t.name})}const ne=function(t){var r=(0,d.useTheme)(),n=(0,f.useRef)(null),a=(0,f.useRef)(null),o=(0,f.useState)(!1),s=o[0],c=o[1],l={"--indicator-color":r.palette.divider,"--background":r.palette.background.paper,"--input-border-color":r.palette.divider,"--outline-color":r.palette.secondary.main};function u(){c(!1)}function p(e){e.detail.unicode&&t.onEmojiClick(e.detail.unicode),u()}return(0,f.useEffect)((function(){a.current||"undefined"==typeof window||Promise.resolve().then(i.t.bind(i,13,23)).then((function(e){var t=new(0,e.Picker),n="dark"===r.palette.mode?"dark":"light";t.classList.add(n),Object.keys(l).forEach((function(e){t.style.setProperty(e,l[e])})),a.current=t})).catch((function(e){console.error("Failed to load emoji picker",e)}))}),[]),(0,f.useEffect)((function(){return a.current&&a.current.addEventListener("emoji-click",p),function(){var e;null===(e=a.current)||void 0===e||e.removeEventListener("emoji-click",p)}}),[s,t.onEmojiClick]),(0,e.jsxs)("div",{children:[(0,e.jsx)(ee(),{title:"Emoji",children:(0,e.jsx)(H(),{size:"small",ref:n,onClick:function(){c((function(e){return!e}))},sx:{color:t.buttonColor},children:(0,e.jsx)(re,{name:"Mood"})})}),a.current&&(0,e.jsx)(X(),{open:s,anchorEl:n.current,onClose:u,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"right"},children:(0,e.jsx)("div",{className:"rustic-emoji-picker",ref:function(e){e&&a.current&&!e.contains(a.current)&&e.appendChild(a.current)}})})]})};var ie={"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 ae(e){if("unicode"in e&&"annotation"in e)return"".concat(e.unicode," ").concat(e.annotation)}var oe=new te.Database,se=(0,f.forwardRef)((function(t,r){var n=(0,f.useState)(""),i=n[0],a=n[1],o=(0,f.useState)(!1),s=o[0],c=o[1],l=(0,f.useState)(!1),d=l[0],p=l[1],m=(0,f.useState)(!1),h=m[0],x=m[1],v=(0,f.useState)(""),g=v[0],b=v[1],y=(0,f.useState)([]),j=y[0],S=y[1],w=(0,f.useState)(!1),F=w[0],C=w[1],E=(0,f.useRef)(null),N=!i.trim().length&&!t.isSendEnabled,T="".concat(s?"Stop":"Start"," speech to text"),O=d?"primary.main":"primary.light",R=s?"error.main":O,D=s?"stop_circle":"speech_to_text";function q(e,t){if(void 0===t&&(t=!1),E.current){var r=E.current,n=r.selectionStart,o=r.selectionEnd;if("number"==typeof n&&"number"==typeof o){var s,c=i||"",l=c.substring(0,n),u=c.substring(o);s=t?l.replace(/:(\w+)$/,e)+u:l+e+u,a(s);var d=t?l.replace(/:(\w+)$/,e).length:n+e.length;setTimeout((function(){var e,t;null===(e=E.current)||void 0===e||e.focus(),null===(t=E.current)||void 0===t||t.setSelectionRange(d,d)}),0)}}C(!1)}var M=h?(0,e.jsx)(P(),{size:24}):(0,e.jsx)(ee(),{title:T,children:(0,e.jsx)(H(),{onClick:function(){var e=new window.webkitSpeechRecognition,t=navigator.language;e.lang=t,s?(e.stop(),x(!0),c(!1)):(e.start(),b(""),c(!0)),e.onstart=function(){c(!0)},e.onresult=function(e){var t,r=e.results[0][0].transcript;i.length>0?a(i+" "+r):a(r),null===(t=E.current)||void 0===t||t.focus(),c(!1)},e.onerror=function(e){var t=ie[e.error];b(t),c(!1)},e.onend=function(){x(!1),c(!1)}},size:"small",sx:{color:R},children:(0,e.jsx)(re,{name:D})})});function z(){var e=(new Date).toISOString(),r={id:(0,_.v4)(),timestamp:e,sender:t.sender,conversationId:t.conversationId,format:"text",data:{text:i}};t.send(r),a(""),b("")}return(0,e.jsxs)(u(),{className:"rustic-base-input",ref:r,children:[(0,e.jsxs)(u(),{className:"rustic-error-and-input-container",children:[(0,e.jsx)(u(),{className:"rustic-error-container",children:(0,e.jsx)(k(),{variant:"caption",color:"error",className:"rustic-error-message",children:g})}),(0,e.jsxs)(u(),{className:"rustic-input-field",sx:{border:"1px solid",borderColor:d?"secondary.main":"action.disabled"},children:[j.length>0&&(0,e.jsx)(X(),{open:F,anchorEl:E.current,onClose:function(){return C(!1)},disableAutoFocus:!0,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:(0,e.jsx)(Q(),{children:j.map((function(t,r){return"unicode"in t&&(0,e.jsx)(G(),{onClick:function(){return q(t.unicode,!0)},children:ae(t)},r)}))})}),(0,e.jsx)(Z(),{className:"rustic-text-field",variant:"outlined",value:i,label:t.label,placeholder:t.placeholder,maxRows:t.maxRows,multiline:t.multiline,fullWidth:t.fullWidth,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!N&&z())},onChange:function(e){b("");var r=e.target.value;a(r);var n,i=r.match(/:(\w{2,}):/g),o=r.match(/:(\w{2,})/g);if(i){var s=i[0].replace(/:/g,"");oe.getEmojiByShortcode(s).then((function(e){if(e&&"unicode"in e){var t=r.replace(i[0],e.unicode);a(t)}else a(r)})).catch((function(){a(r)})),C(!1)}else o?(n=o[0].replace(":",""),oe.getEmojiBySearchQuery(n).then((function(e){e.length?(S(e.slice(0,t.maximumEmojiSearchResults)),C(!0)):(S([]),C(!1))})).catch((function(){S([]),C(!1)}))):C(!1)},onFocus:function(){return p(!0)},onBlur:function(){return p(!1)},inputRef:E,color:"secondary",size:"small",InputProps:{endAdornment:(0,e.jsxs)(V(),{position:"end",children:[(0,e.jsx)(ne,{onEmojiClick:q,buttonColor:O}),t.enableSpeechToText&&M]})},InputLabelProps:{className:d?"":"rustic-input-label",sx:{backgroundColor:"background.paper"}}}),(0,e.jsx)("div",{className:"rustic-input-extras"})]})]}),(0,e.jsxs)(u(),{className:"rustic-input-actions",children:[t.children,(0,e.jsx)(ee(),{title:"Send",children:(0,e.jsx)("span",{className:"rustic-send-button",children:(0,e.jsx)(H(),{"aria-label":"send message",onClick:z,disabled:N,color:"primary",children:(0,e.jsx)(re,{name:"send"})})})})]})]})}));se.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,enableSpeechToText:!1,maximumEmojiSearchResults:5};const ce=se,le=require("@mui/material/LinearProgress");var ue=i.n(le);const de=require("axios");var pe=i.n(de);const me=require("react-dom"),fe=require("@mui/material/Card");var he=i.n(fe);const xe=require("@mui/material/Modal");var ve=i.n(xe);const ge=require("@mui/system/Stack");var be=i.n(ge);const ye=require("@mui/system/useTheme");var je=i.n(ye);const Se=require("pdfjs-dist"),we=function(t){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[t.action].label.replaceAll(" ","-").toLowerCase(),r[t.action]);return(0,e.jsx)(ee(),{title:n.label,children:(0,e.jsx)("span",{children:(0,e.jsx)(H(),{onClick:t.onClick,className:t.className,disabled:t.isDisabled,children:(0,e.jsx)(re,{name:n.symbol})})})})},ke=function(t){var r,n=(0,f.useRef)(null),i=(0,f.useState)(1),a=i[0],o=i[1],s=(0,f.useState)(1),c=s[0],l=s[1],d=(0,f.useState)(1),p=d[0],h=d[1],x=(0,f.useState)(!1),v=x[0],g=x[1],b=(0,f.useState)(),y=b[0],j=b[1],S=je()(),w=m()(S.breakpoints.down("sm")),F=m()(S.breakpoints.between("sm","md"));if(r=t.url,!/\/[^/]+\.pdf$/.test(r))return(0,e.jsx)(he(),{variant:"outlined",className:"rustic-pdf-error",children:(0,e.jsx)(k(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var C=(0,f.useState)((function(){return w?.5:F?1:1.5})),E=C[0],N=C[1];return(0,f.useEffect)((function(){Se.GlobalWorkerOptions.workerSrc||(Se.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(Se.version,"/pdf.worker.mjs")),Se.getDocument({url:"".concat(t.url)}).promise.then((function(e){l(e.numPages),function(e){e.getPage(a).then((function(e){var t=e.getViewport({scale:E}),r=n.current;if(r){var i=r.getContext("2d");if(i){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 o={canvasContext:i,viewport:t,transform:[a,0,0,a,0,0]};y&&y.cancel();var s=e.render(o);j(s),s.promise.then((function(){j(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[t.url,a,E]),v?(0,e.jsx)(he(),{variant:"outlined",className:"rustic-pdf-error",children:(0,e.jsx)(k(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,e.jsxs)(he(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,e.jsxs)(u(),{className:"rustic-pdf-viewer-header",children:[(0,e.jsx)(we,{action:"zoomOut",onClick:function(){N((function(e){return Math.max(e-.2,.2)}))}}),(0,e.jsx)(we,{action:"zoomIn",onClick:function(){N((function(e){return e+.2}))}})]}),(0,e.jsx)(u(),{className:"rustic-pdf-viewer-body",children:(0,e.jsx)(u(),{className:"rustic-pdf-viewer-body-inner",children:(0,e.jsx)("canvas",{ref:n})})}),(0,e.jsxs)(be(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,e.jsx)(we,{action:"previousPage",onClick:function(){a>1&&(o(a-1),h(a-1))},isDisabled:1===a}),(0,e.jsx)(k(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,e.jsx)(Z(),{type:"number",value:p,onChange:function(e){var t=parseInt(e.target.value);h(t),!isNaN(t)&&t>=1&&t<=c&&o(t)},size:"small",className:"rustic-pdf-page-input"}),(0,e.jsxs)(k(),{variant:"body1",className:"rustic-page-indicator",children:["of ",c]}),(0,e.jsx)(we,{action:"nextPage",onClick:function(){a<c&&(o(a+1),h(a+1))},isDisabled:a===c})]})]})};var Fe={pdf:ke};function Ce(t){var r=(0,d.useTheme)(),n=(0,f.useState)(!1),i=n[0],a=n[1];function o(){a(!1)}var s,c,l=t.file.url&&(s=t.file.url.split("."))[s.length-1].toLowerCase(),u=l&&t.supportedViewers?t.supportedViewers[l]:null,p=!!u;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(he(),{className:"rustic-file-preview".concat(p?" rustic-cursor-pointer":""),variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){a(!0)},children:[(0,e.jsx)(k(),{variant:"subtitle2",children:(c=t.file.name,15,c.length<=15?c:c.substring(0,12)+"...")}),(0,e.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:t.children})]}),p&&(0,e.jsx)(ve(),{open:i,onClose:o,className:"rustic-file-preview-modal",children:(0,e.jsxs)("div",{className:"rustic-modal-content",children:[(0,e.jsx)(ee(),{title:"Close",children:(0,e.jsx)(H(),{onClick:o,className:"rustic-close-button",children:(0,e.jsx)(re,{name:"close"})})}),t.file.url&&(0,e.jsx)(u,{url:t.file.url})]})})]})}Ce.defaultProps={supportedViewers:Fe};var Ee=function(){return Ee=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ee.apply(this,arguments)},Ne=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function Te(e){for(var t=["Bytes","KB","MB","GB"],r=0;e>=1024&&r<t.length-1;)e/=1024,r++;var n=e.toFixed(1).toString().replace(/\.0$/,"");return"".concat(n," ").concat(t[r])}const Oe=function(t){var r=(0,f.useState)([]),n=r[0],i=r[1],a=(0,f.useState)([]),o=a[0],s=a[1],c=(0,f.useRef)({}),l=(0,_.v4)();(0,f.useEffect)((function(){i([]),s([]),c.current={}}),[t.messageId]);var d=(0,e.jsx)(u(),{className:"rustic-files rustic-padding-16",children:n.map((function(r,n){return(0,e.jsx)(Ce,{file:{name:r.name},children:(0,e.jsxs)(u(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,e.jsx)(ue(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,e.jsx)(ee(),{title:"Delete",children:(0,e.jsx)(H(),{color:"primary",onClick:function(){return function(e,r){var n,a;s([]);var o=e.name;if(c.current=Ee(Ee({},c.current),((n={})[o]=c.current[o]--,n)),t.onFileUpdate("remove",o),100===e.loadingProgress){var l="".concat(t.deleteFileEndpoint,"?message-id=").concat(t.messageId,"&file-id=").concat(e.id);pe().delete(l).then((function(){return i((function(e){return e.filter((function(e,t){return t!==r}))}))})).catch((function(){return t.onFileUpdate("add",o),s((function(e){return Ne(Ne([],e,!0),["Failed to delete ".concat(o,". Please try again.")],!1)}))}))}else e.abortController.abort(),i((function(e){return e.filter((function(e,t){return t!==r}))})),c.current=Ee(Ee({},c.current),((a={})[o]=c.current[o]++,a))}(r,n)},className:"rustic-delete-button","aria-label":"cancel file upload",children:(0,e.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},n)}))}),p=(0,e.jsx)(u(),{children:o.map((function(t,r){return(0,e.jsx)(k(),{variant:"caption",color:"error",className:"rustic-error-message",children:t},r)}))});function m(e,t){return t?(0,me.createPortal)(e,t):e}return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(u(),{className:"rustic-uploader",children:[(0,e.jsx)("label",{htmlFor:l,children:(0,e.jsx)(ee(),{title:"Upload",children:(0,e.jsx)(H(),{component:"span","aria-label":"Upload file",color:"primary",children:(0,e.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,e.jsx)("input",{type:"file",id:l,onChange:function(e){s([]);var r=e.target.files&&Array.from(e.target.files),a=n.length+(r?r.length:0);t.maxFileCount&&a>t.maxFileCount&&s((function(e){return Ne(Ne([],e,!0),["You can only upload ".concat(t.maxFileCount," files.")],!1)}));var o=r&&function(e,t,r){return r?t<=r?e:e.slice(0,r-t):e}(r,a,t.maxFileCount);o&&o.forEach((function(e){!function(e){var r;t.maxFileSize&&e.size>t.maxFileSize?(r=e.name,s((function(e){return Ne(Ne([],e,!0),["Failed to upload ".concat(r,". You cannot upload files larger than ").concat(t.maxFileSize&&Te(t.maxFileSize),".")],!1)}))):function(e){var r=new FormData,n=new AbortController,a=function(e){var t,r,n=e.name,i=c.current[n];if(i){var a=i+1,o=n.lastIndexOf("."),s=n.substring(0,o),l=n.substring(o);n="".concat(s,"(").concat(i,")").concat(l),c.current=Ee(Ee({},c.current),((t={})[e.name]=a,t))}else c.current=Ee(Ee({},c.current),((r={})[e.name]=1,r));return n}(e),o=new File([e],a,{type:e.type});r.append("file",o);var l=(0,_.v4)(),u={name:a,loadingProgress:0,abortController:n,id:l};i((function(e){return Ne(Ne([],e,!0),[u],!1)})),t.onFileUpdate("add",a);var d="".concat(t.uploadFileEndpoint,"?message-id=").concat(t.messageId);pe().post(d,r,{onUploadProgress:function(e){var t,r;e.total&&(t=e.loaded/e.total*100,r=u.id,i((function(e){var n=e.map((function(e){return e.id===r?Ee(Ee({},e),{loadingProgress:t}):e}));return n})))},signal:n.signal}).then((function(e){var t,r;t=e.data,r=u.id,i((function(e){var n=e.findIndex((function(e){return e.id===r}));if(-1!==n){var i=Ne([],e,!0);return i[n]=Ee(Ee({},i[n]),{id:t.fileId}),i}return e}))})).catch((function(r){var n,o;t.onFileUpdate("remove",a),c.current=Ee(Ee({},c.current),((n={})[a]=c.current[e.name]--,n)),function(e,t,r){s((function(t){return Ne(Ne([],t,!0),["Failed to upload ".concat(e,". ").concat((null==r?void 0:r.message)||"")],!1)})),i((function(e){return e.filter((function(e){return e.id!==t}))}))}(e.name,u.id,null===(o=r.response)||void 0===o?void 0:o.data)}))}(e)}(e)})),e.target.value=""},multiple:!0,accept:t.acceptedFileTypes})]}),o.length>0&&m(p,t.errorMessagesContainer),n.length>0&&m(d,t.filePreviewsContainer)]})};var Pe=function(){return Pe=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Pe.apply(this,arguments)},Re=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function De(t){var r=(0,f.useState)([]),n=r[0],i=r[1],a=(0,f.useState)((0,_.v4)()),o=a[0],s=a[1],c=(0,f.useState)(),l=c[0],p=c[1],m=(0,f.useState)(),h=m[0],x=m[1],v=(0,f.useRef)(null),g=(0,d.useTheme)(),b=n.length>0;return(0,f.useEffect)((function(){v.current&&(x(v.current.querySelector(".rustic-error-container")),p(v.current.querySelector(".rustic-input-extras")))})),(0,e.jsx)(u(),{className:"rustic-multimodal-input",sx:{border:"1px solid ".concat(g.palette.action.disabled),borderRadius:"".concat(g.shape.borderRadius,"px"),":focus-within":{borderColor:g.palette.secondary.main}},children:(0,e.jsx)(ce,Pe({},t,{send:function(e){b&&(e.id=o,e.format="filesWithText",e.data.files=n),t.ws.send(e),s((0,_.v4)()),i([])},isSendEnabled:b,ref:v,children:(0,e.jsx)(u(),{className:"rustic-bottom-buttons",children:(0,e.jsx)(Oe,{acceptedFileTypes:t.acceptedFileTypes,maxFileCount:t.maxFileCount,maxFileSize:t.maxFileSize,uploadFileEndpoint:t.uploadFileEndpoint,deleteFileEndpoint:t.deleteFileEndpoint,onFileUpdate:function(e,t){i("add"===e?function(e){return Re(Re([],e,!0),[{name:t}],!1)}:function(e){return e.filter((function(e){return e.name!==t}))})},messageId:o,filePreviewsContainer:l,errorMessagesContainer:h})})}))})}De.defaultProps={multiline:!0,fullWidth:!0,maxRows:6,maxFileSize:2097152,maxFileCount:1};var qe=function(){return qe=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},qe.apply(this,arguments)},Me=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 i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r};function ze(t){var r=t.ws,n=Me(t,["ws"]);return(0,e.jsx)(ce,qe({},n,{send:function(e){r.send(e)}}))}require("ol/ol.css");const Ie=require("@mui/material/Alert");var Le=i.n(Ie);const Be=require("ol/layer/Tile.js");var _e=i.n(Be);const Ae=require("ol/Map.js");var He=i.n(Ae);const We=require("ol/Overlay.js");var Ve=i.n(We);const Ue=require("ol/proj.js"),Ge=require("ol/source/OSM.js");var Ke=i.n(Ge);const Qe=require("ol/View.js");var Ye=i.n(Qe);function Xe(t){var r=(0,f.useState)(""),n=r[0],i=r[1],a=(0,f.useRef)(null),o=(0,f.useRef)(null);return(0,f.useEffect)((function(){if(i(""),t.latitude<-90||t.latitude>90||t.longitude<-180||t.longitude>180)return i("Invalid coordinates");if(a.current&&o.current){var e=new(He())({layers:[new(_e())({source:new(Ke())})],view:new(Ye())({center:(0,Ue.fromLonLat)([t.longitude,t.latitude]),zoom:12}),target:a.current}),r=new(Ve())({element:o.current,position:(0,Ue.fromLonLat)([t.longitude,t.latitude]),positioning:"bottom-center",stopEvent:!1});return e.addOverlay(r),e.once("postrender",(function(){var e;if(!(null===(e=a.current)||void 0===e?void 0:e.querySelector("canvas")))return i("An error occurred while loading the map")})),function(){e.setTarget(""),e.removeOverlay(r)}}}),[]),(0,e.jsx)(e.Fragment,{children:n.length>0?(0,e.jsx)(Le(),{severity:"error",children:n}):(0,e.jsxs)(u(),{children:[(0,e.jsx)(u(),{ref:o,children:(0,e.jsx)(re,{className:"rustic-open-layers-map-marker",name:"location_on"})}),(0,e.jsx)("div",{ref:a,className:"rustic-open-layers-map-canvas"})]})})}const $e=require("dompurify");var Ze=i.n($e);const Je=require("marked");function et(e){var t=e.replace(/^[\u200B-\u200F\uFEFF]/,""),r=Je.marked.parse(t);return Ze().sanitize(r)}const tt=function(t){var r=(0,f.useState)(et(t.text)),n=r[0],i=r[1];return(0,f.useEffect)((function(){if(t.updatedData&&t.updatedData.length>0){var e=t.updatedData[t.updatedData.length-1].text;i(et(e))}}),[t.text,t.updatedData]),(0,e.jsx)(k(),{variant:"body2",dangerouslySetInnerHTML:{__html:n}})},rt=function(t){var r=(0,f.useState)(et(t.text)),n=r[0],i=r[1],a=(0,f.useState)(""),o=a[0],s=a[1];return(0,f.useEffect)((function(){if(t.updatedData&&t.updatedData.length>0){for(var e=t.text,r=0,n=t.updatedData;r<n.length;r++){var a=n[r];"string"!=typeof a.text?(e+=" [MISSING TEXT]",s("Some of the incoming text was not correctly formatted. Some data may be missing.")):e+=a.text}i(et(e))}}),[t.text,t.updatedData]),(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(k(),{variant:"body2",dangerouslySetInnerHTML:{__html:n}}),o&&(0,e.jsx)(Le(),{severity:"error",children:o})]})},nt=require("@mui/material"),it=require("@mui/material/Button");var at=i.n(it);const ot=require("@mui/material/Slider");var st=i.n(ot);function ct(t){var r,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[t.action].label.replaceAll(" ","-").toLowerCase(),(0,e.jsx)(ee(),{title:n[t.action].label,PopperProps:{container:null!==(r=document.fullscreenElement)&&void 0!==r?r:document.body},children:(0,e.jsx)(H(),{onClick:t.onClick,className:t.className,color:"primary",children:(0,e.jsx)(re,{name:n[t.action].symbol,className:"rustic-icon-large"})})})}var lt=100;function ut(t){var r="dark"===(0,nt.useTheme)().palette.mode,n=M(t.mediaElement.currentTime);return(0,e.jsxs)(u(),{className:"rustic-progress",children:[function(){for(var n=t.mediaElement.buffered,i=0,a=n.length-1;a>=0;--a){var o=n.start(a),s=n.end(a);if(o<t.mediaElement.currentTime){i=s;break}}var c=i/t.mediaElement.duration*lt;return(0,e.jsx)(ue(),{className:"rustic-progress-buffered",variant:"determinate",value:c,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:r?"secondary.light":"action.selected"}}})}(),(0,e.jsx)(st(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(n),max:t.mediaElement.duration,value:t.mediaElement.currentTime,onChange:function(e,r){t.mediaElement.currentTime=r},valueLabelDisplay:"auto",valueLabelFormat:function(e){return M(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function dt(t){var r=(0,f.useState)(t.mediaElement.volume),n=r[0],i=r[1],a=(0,f.useState)(t.mediaElement.volume),o=a[0],s=a[1],c=t.mediaElement.muted?"volumeOff":"volumeUp";return(0,e.jsxs)(u(),{className:"rustic-volume-settings",children:[(0,e.jsx)(ct,{onClick:function(){t.mediaElement.muted=!t.mediaElement.muted,t.mediaElement.muted?(s(t.mediaElement.volume),i(0)):i(o)},className:"rustic-mute-button",action:c}),(0,e.jsx)(st(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(n*lt,"%"),value:n,onChange:function(e,r){var n=r;t.mediaElement.muted=0===n,t.mediaElement.volume=n,i(t.mediaElement.volume)}})]})}function pt(t){var r=t.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",n="".concat(t.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,e.jsx)(at(),{className:"rustic-transcript-toggle",onClick:t.setIsTranscriptVisible,endIcon:(0,e.jsx)(re,{name:r}),children:(0,e.jsx)(k(),{variant:"overline",children:n})})}function mt(t){var r=(0,f.useState)(!t.mediaElement.paused),n=r[0],i=r[1],a=n?"pause":"play";return t.mediaElement.onended=function(){i(!1)},t.mediaElement.onpause=function(){i(!1)},t.mediaElement.onplay=function(){i(!0)},(0,e.jsx)(ct,{onClick:function(){n?t.mediaElement.pause():t.mediaElement.play().catch((function(e){t.onError("Failed to play the media. Error: ".concat(e.message))}))},action:a,className:"rustic-pause-play-icon"})}function ft(t){var r,n=(0,f.useState)(t.mediaElement.playbackRate),i=n[0],a=n[1];return(0,e.jsx)(ee(),{title:"Playback rate",PopperProps:{container:null!==(r=document.fullscreenElement)&&void 0!==r?r:document.body},children:(0,e.jsx)(at(),{onClick:function(){var e=1;t.mediaElement.playbackRate<2&&(e=t.mediaElement.playbackRate+.5),t.mediaElement.playbackRate=e,a(e)},className:"rustic-playback-rate-button",children:(0,e.jsxs)(k(),{variant:"body1",children:[i,"X"]})})})}function ht(t){var r="replay"===t.movement,n=r?function(){t.mediaElement.currentTime-=10}:function(){t.mediaElement.currentTime+=10},i=r?"replay":"forward";return(0,e.jsx)(ct,{onClick:n,action:i})}function xt(t){var r=M(t.elapsedTimeInSeconds),n=M(t.durationTimeInSeconds),i="".concat(r," / ").concat(n);return"wide"===t.style?(0,e.jsxs)(u(),{className:"rustic-time-container",children:[(0,e.jsx)(k(),{variant:"overline",children:r}),(0,e.jsx)(k(),{variant:"overline",children:n})]}):(0,e.jsx)(k(),{variant:"overline",className:"rustic-time-display",children:i})}xt.defaultProps={style:"condensed"};const vt=require("@mui/material/Divider");var gt=i.n(vt);function bt(t){var r=!!document.fullscreenElement;return(0,e.jsxs)(F.Box,{className:"rustic-transcript-container",children:[!r&&(0,e.jsx)(gt(),{orientation:"vertical",flexItem:!0}),(0,e.jsx)(k(),{className:"rustic-transcript-content",variant:"body2",children:t.transcript})]})}function yt(t){var r=(0,f.useState)(!1),n=r[0],i=r[1],a=(0,f.useState)(!1),o=a[0],s=a[1],c=(0,f.useState)(!0),l=c[0],u=c[1],d=(0,f.useState)(0),p=d[0],m=d[1],h=(0,f.useState)(""),x=h[0],v=h[1],g=(0,f.useState)(""),b=g[0],y=g[1],j=(0,nt.useTheme)(),S=(0,f.useRef)(null),w=(0,nt.useMediaQuery)(j.breakpoints.down("md"));function C(){return(0,e.jsx)(k(),{variant:"h6",className:"rustic-sound-title",children:t.title})}function E(){if(t.captions&&t.captions.length>0){var r=o?"captionsOff":"captionsOn";return(0,e.jsx)(ct,{action:r,onClick:function(){return s(!o)}})}}function N(){if(S.current)return(0,e.jsxs)(F.Box,{className:"rustic-time-controls",children:[(0,e.jsx)(ht,{mediaElement:S.current,movement:"replay"}),(0,e.jsx)(mt,{mediaElement:S.current,onError:y}),(0,e.jsx)(ht,{mediaElement:S.current,movement:"forward"})]})}function T(){if(t.transcript&&n)return(0,e.jsx)(bt,{transcript:t.transcript})}function O(){if(t.transcript)return(0,e.jsx)(pt,{isTranscriptVisible:n,setIsTranscriptVisible:function(){return i(!n)}})}function R(){return(0,e.jsx)("video",{src:t.src,ref:S,className:o?"rustic-has-captions":"",children:o&&(0,e.jsx)("track",{src:t.captions,kind:"captions",default:!0})})}(0,f.useEffect)((function(){var e,t,r,n;function i(e){v(e)}null===(e=S.current)||void 0===e||e.addEventListener("timeupdate",(function(){S.current&&m(S.current.currentTime)})),null===(t=S.current)||void 0===t||t.addEventListener("canplay",(function(){v(""),u(!1)})),null===(r=S.current)||void 0===r||r.addEventListener("error",(function(){return i("Failed to load the audio.")})),null===(n=S.current)||void 0===n||n.addEventListener("stalled",(function(){return i("Failed to fetch audio data, but trying.")}))}),[]);var D=w?function(){if(S.current)return(0,e.jsxs)(F.Box,{className:"rustic-sound-controls",children:[(0,e.jsx)(xt,{elapsedTimeInSeconds:p,durationTimeInSeconds:S.current.duration,style:"wide"}),(0,e.jsx)(ut,{mediaElement:S.current}),C(),(0,e.jsxs)(F.Box,{className:"rustic-sound-bottom-controls",children:[(0,e.jsx)(F.Box,{className:"rustic-sound-bottom-controls-left",children:N()}),(0,e.jsx)(dt,{mediaElement:S.current}),(0,e.jsxs)(F.Box,{className:"rustic-sound-bottom-controls-right",children:[O(),(0,e.jsxs)(F.Box,{children:[E(),(0,e.jsx)(ft,{mediaElement:S.current})]})]})]}),T()]})}:function(){if(S.current)return(0,e.jsxs)(e.Fragment,{children:[C(),(0,e.jsxs)(F.Box,{className:"rustic-sound-controls",children:[(0,e.jsx)(ut,{mediaElement:S.current}),(0,e.jsxs)(F.Box,{className:"rustic-sound-bottom-controls",children:[(0,e.jsxs)(F.Box,{className:"rustic-sound-bottom-controls-left",children:[N(),E(),(0,e.jsx)(ft,{mediaElement:S.current}),(0,e.jsx)(dt,{mediaElement:S.current}),(0,e.jsx)(xt,{elapsedTimeInSeconds:p,durationTimeInSeconds:S.current.duration,style:"condensed"})]}),(0,e.jsx)(F.Box,{className:"rustic-sound-bottom-controls-right",children:O()})]}),T()]})]})};return x.length>0?(0,e.jsx)(Le(),{severity:"error",children:x}):l?(0,e.jsxs)(F.Box,{className:"rustic-sound",children:[R(),(0,e.jsx)(P(),{})]}):(0,e.jsxs)(F.Box,{className:"rustic-sound",children:[R(),D(),b.length>0&&(0,e.jsx)(Le(),{severity:"error",className:"rustic-control-error",onClose:function(){return y("")},children:b})]})}function jt(t){var r=(0,f.useState)(!!document.pictureInPictureElement),n=r[0],i=r[1],a=t.mediaElement,o=n?"miniPlayerExit":"miniPlayer";return a.onleavepictureinpicture=function(){i(!1)},(0,e.jsx)(ct,{onClick:function(){n?document.exitPictureInPicture().then((function(){i(!1)})).catch((function(e){t.onError("Failed to exit mini player. Error: ".concat(e.message))})):a.requestPictureInPicture().then((function(){i(!0)})).catch((function(e){t.onError("Failed to enter mini player. Error: ".concat(e.message))}))},action:o})}function St(t){var r=(0,f.useState)(!!document.fullscreenElement),n=r[0],i=r[1],a=t.element,o=n?"fullscreenExit":"fullscreen";return a.onfullscreenchange=function(){i(!!document.fullscreenElement)},(0,e.jsx)(ct,{onClick:function(){n?document.exitFullscreen().then((function(){i(!1)})).catch((function(e){t.onError("Failed to exit fullscreen mode. Error: ".concat(e.message))})):a.requestFullscreen().then((function(){i(!0)})).catch((function(e){t.onError("Failed to enter fullscreen mode. Error: ".concat(e.message))}))},action:o})}function wt(t){var r=(0,f.useState)(!1),n=r[0],i=r[1],a=(0,f.useState)(!1),o=a[0],s=a[1],c=(0,f.useState)(!0),l=c[0],u=c[1],d=(0,f.useState)(!!document.fullscreenElement),p=d[0],m=d[1],h=(0,f.useState)(!1),x=h[0],v=h[1],g=(0,f.useState)(""),b=g[0],y=g[1],j=(0,f.useState)(""),S=j[0],w=j[1],C=(0,f.useState)(0),E=C[0],N=C[1],T=(0,f.useRef)(null),O=(0,f.useRef)(null),R=(0,nt.useTheme)(),D=(0,nt.useMediaQuery)(R.breakpoints.down("md"));(0,f.useEffect)((function(){var e,t,r,n,i,a,o,s;function c(e){w(e),u(!1)}function l(){clearTimeout(s),s=setTimeout((function(){return v(!1)}),3e3)}null===(e=O.current)||void 0===e||e.addEventListener("timeupdate",(function(){O.current&&N(O.current.currentTime)})),null===(t=O.current)||void 0===t||t.addEventListener("canplay",(function(){w(""),u(!1)})),null===(r=O.current)||void 0===r||r.addEventListener("error",(function(){return c("Failed to load the video.")})),null===(n=O.current)||void 0===n||n.addEventListener("stalled",(function(){return c("Failed to fetch video data, but trying.")})),document.addEventListener("fullscreenchange",(function(){m(!!document.fullscreenElement)})),null===(i=T.current)||void 0===i||i.addEventListener("mousemove",(function(){v(!0),l()})),null===(a=T.current)||void 0===a||a.addEventListener("mouseleave",(function(){v(!1)})),null===(o=T.current)||void 0===o||o.addEventListener("keydown",(function(){v(!0),l()}))}),[]);var q={backgroundColor:R.palette.background.paper,opacity:x?1:0};function M(){if(t.transcript&&n)return(0,e.jsx)(bt,{transcript:t.transcript})}function z(){if(t.captions&&t.captions.length>0){var r=o?"captionsOff":"captionsOn";return(0,e.jsx)(ct,{action:r,onClick:function(){return s(!o)}})}}function I(){if(t.transcript)return(0,e.jsx)(pt,{isTranscriptVisible:n,setIsTranscriptVisible:function(){return i(!n)}})}var L=D?function(){return p?(0,e.jsx)(e.Fragment,{children:O.current&&T.current&&(0,e.jsxs)(F.Box,{className:"rustic-video-controls",sx:q,children:[(0,e.jsxs)(F.Box,{className:"rustic-video-top-controls",children:[(0,e.jsx)(mt,{mediaElement:O.current,onError:y}),(0,e.jsx)(ut,{mediaElement:O.current}),(0,e.jsx)(xt,{elapsedTimeInSeconds:E,durationTimeInSeconds:O.current.duration})]}),(0,e.jsxs)(F.Box,{className:"rustic-video-bottom-controls",children:[(0,e.jsxs)(F.Box,{className:"rustic-time-controls",children:[(0,e.jsx)(ht,{mediaElement:O.current,movement:"replay"}),(0,e.jsx)(ht,{mediaElement:O.current,movement:"forward"}),z(),(0,e.jsx)(ft,{mediaElement:O.current})]}),I()]}),M()]})}):(0,e.jsx)(e.Fragment,{children:O.current&&T.current&&(0,e.jsxs)(F.Box,{className:"rustic-video-controls-mobile-preview",children:[(0,e.jsx)(mt,{mediaElement:O.current,onError:y}),(0,e.jsxs)(F.Box,{className:"rustic-video-controls-right",children:[I(),(0,e.jsx)(St,{element:T.current,onError:y})]})]})})}:function(){return(0,e.jsx)(e.Fragment,{children:O.current&&T.current&&(0,e.jsxs)(F.Box,{className:"rustic-video-controls",sx:q,children:[(0,e.jsx)(ut,{mediaElement:O.current}),(0,e.jsxs)(F.Box,{className:"rustic-video-bottom-controls",children:[(0,e.jsxs)(F.Box,{className:"rustic-video-bottom-controls-left",children:[(0,e.jsx)(mt,{mediaElement:O.current,onError:y}),(0,e.jsx)(ht,{mediaElement:O.current,movement:"replay"}),(0,e.jsx)(ht,{mediaElement:O.current,movement:"forward"}),z(),(0,e.jsx)(ft,{mediaElement:O.current}),(0,e.jsx)(dt,{mediaElement:O.current}),(0,e.jsx)(xt,{elapsedTimeInSeconds:E,durationTimeInSeconds:O.current.duration,style:"condensed"})]}),(0,e.jsxs)(F.Box,{className:"rustic-video-bottom-controls-right",children:[I(),(0,e.jsx)(jt,{mediaElement:O.current,onError:y}),(0,e.jsx)(St,{element:T.current,onError:y})]})]}),p&&M()]})})};return S.length>0?(0,e.jsx)(Le(),{severity:"error",children:S}):(0,e.jsxs)(F.Box,{className:"rustic-video",children:[l&&(0,e.jsx)(P(),{className:"rustic-video-loading-spinner"}),(0,e.jsxs)(F.Box,{ref:T,className:"rustic-video-screen",sx:{visibility:l?"hidden":"visible"},children:[b.length>0&&(0,e.jsx)(Le(),{severity:"error",className:"rustic-control-error",onClose:function(){return y("")},children:b}),(!D||p)&&function(){if(O.current&&T.current)return(0,e.jsxs)(F.Box,{className:"rustic-video-title",sx:q,children:[(0,e.jsx)(k(),{variant:"body2",children:t.title}),p&&D&&(0,e.jsxs)(F.Box,{children:[(0,e.jsx)(jt,{mediaElement:O.current,onError:y}),(0,e.jsx)(St,{element:T.current,onError:y})]})]})}(),(0,e.jsx)("video",{className:"rustic-video-element",ref:O,src:t.src,poster:t.poster,children:o&&(0,e.jsx)("track",{src:t.captions,kind:"captions",default:!0})}),L()]}),!p&&M()]})}const kt=require("@mui/material/Drawer");var Ft=i.n(kt);const Ct=require("@mui/material/ListItemText");var Et=i.n(Ct);const Nt=require("@mui/material/Menu");var Tt=i.n(Nt),Ot=function(){return Ot=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ot.apply(this,arguments)};function Pt(t){var r=(0,f.useState)(!1),n=r[0],i=r[1],a=(0,f.useRef)(null),o=(0,d.useTheme)(),s=(0,nt.useMediaQuery)(o.breakpoints.down("md")),c=s?Ft():Tt(),l={borderRadius:"".concat(o.shape.borderRadius,"px"),border:"1px solid ".concat(o.palette.divider)};function u(t){return(0,e.jsxs)(e.Fragment,{children:[t.startDecorator&&(0,e.jsx)(F.Box,{sx:{color:"primary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-start-icon",children:t.startDecorator}),(0,e.jsx)(Et(),{children:(0,e.jsx)(k(),{variant:"body2",children:t.label})}),t.endDecorator&&(0,e.jsx)(F.Box,{sx:{color:"secondary.main"},className:"rustic-popover-menu-item-icon rustic-popover-menu-item-end-icon",children:t.endDecorator})]})}s&&(l=Ot(Ot({},l),{borderRadius:"".concat(o.shape.borderRadius,"px ").concat(o.shape.borderRadius,"px 0 0"),borderBottom:0}));var p=t.menuItems.map((function(t){return t.href?(0,e.jsx)(G(),{component:"a",onClick:function(){return i(!1)},href:t.href,download:t.downloadFileName||t.isFiledownload,children:u(t)},t.label):(0,e.jsx)(G(),{onClick:function(e){t.onClick&&t.onClick(e),i(!1)},disabled:!t.onClick,children:u(t)},t.label)}));var m,h,x=s?{}:{anchorEl:a.current};return(0,e.jsxs)(e.Fragment,{children:[(m={onClick:function(e){e.stopPropagation(),i(!0)},"aria-label":t.ariaLabel,ref:a,className:"rustic-popover-menu-button"},h=(0,e.jsx)(re,{name:"more_vert"}),t.buttonText?(0,e.jsx)(at(),Ot({},m,{startIcon:t.icon?t.icon:null,children:t.buttonText})):(0,e.jsx)(ee(),{title:t.ariaLabel,children:(0,e.jsx)(H(),Ot({},m,{children:t.icon?t.icon:h}))})),(0,e.jsx)(c,Ot({open:n,onClose:function(){return i(!1)}},x,{anchor:"bottom",className:"rustic-popover-menu",sx:{"& .MuiPaper-root":Ot(Ot({},l),{backgroundImage:"none",boxShadow:o.shadows[2]})},children:p}))]})}var Rt=i(986);function Dt(t){var r=(0,f.useState)("Copy text"),n=r[0],i=r[1];return(0,e.jsx)(Rt.default,{message:t.message,icon:(0,e.jsx)(re,{name:"file_copy"}),onClick:function(e){e.data.text&&navigator.clipboard.writeText(e.data.text).then((function(){i("Copied"),setTimeout((function(){i("Copy text")}),2e3)})).catch((function(){i("Failed to copy")}))},label:n})}function qt(t){var r=(0,f.useState)("Start reading aloud"),n=r[0],i=r[1],a=[t.message.data.title,t.message.data.description,t.message.data.alt,t.message.data.text,t.message.data.transcript].filter(Boolean).join(" "),o=new SpeechSynthesisUtterance(a);return(0,e.jsx)(Rt.default,{message:t.message,icon:(0,e.jsx)(re,{name:"text_to_speech"}),onClick:function(){window.speechSynthesis.speaking?(window.speechSynthesis.cancel(),i("Start reading aloud")):(o.onend=function(){i("Start reading aloud")},window.speechSynthesis.speak(o),i("Stop reading aloud"))},label:n})}const Mt=require("@mui/material/Stack");var zt=i.n(Mt);const It=function(t){return(0,e.jsx)(k(),{variant:"caption",color:"text.secondary",className:"rustic-timestamp",children:(r=t.timestamp,n=new Date(r),i=navigator.language,a={month:"short",day:"numeric"},o=new Date,s=n.getFullYear()!==o.getFullYear(),c=s?" at ":", ",s&&(a.year="numeric"),n.toLocaleDateString(i,a)+c+n.toLocaleTimeString(i,{hour:"numeric",minute:"2-digit",hour12:!0}))});var r,n,i,a,o,s,c},Lt=(0,f.forwardRef)((function(t,r){var n=(0,nt.useTheme)();return(0,e.jsxs)(zt(),{id:t.message.id,className:"rustic-message-canvas",ref:r,children:[(0,e.jsxs)(zt(),{direction:"row",alignItems:"center",spacing:1,children:[t.getProfileComponent&&t.getProfileComponent(t.message),(0,e.jsx)(It,{timestamp:t.message.timestamp})]}),t.getActionsComponent&&t.getActionsComponent(t.message)&&(0,e.jsx)(he(),{variant:"outlined",className:"rustic-message-actions-container",sx:{boxShadow:n.shadows[1]},children:t.getActionsComponent(t.message)}),(0,e.jsx)(he(),{variant:"outlined",className:"rustic-message-container",children:t.children})]})})),Bt=require("@mui/material/Chip");var _t=i.n(Bt);const At=require("@mui/system/Box");var Ht=i.n(At),Wt=function(){return Wt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Wt.apply(this,arguments)};function Vt(e,t){var r=t.format.includes("update")?t.threadId:t.id;if(r){var n=Wt({},e),i=(e[r]||[])[0];return t.format.includes("update")&&i&&i.sender.id!==t.sender.id&&(r=t.id),n[r]||(n[r]=[]),n[r]=n[r].concat(t),n}return e}function Ut(t){var r,n,i,a=(0,f.useRef)(null),o=(0,f.useRef)(null),s=(0,f.useRef)(),c=(0,f.useState)(!0),l=c[0],u=c[1],d=(0,f.useState)(!0),p=d[0],m=d[1],h=(0,f.useState)(!1),x=h[0],v=h[1],g=(0,f.useState)({}),b=g[0],y=g[1],j=Object.keys(b).length,S=(n=j,i=(0,f.useRef)(0),(0,f.useEffect)((function(){i.current=n})),i.current),w=2e3;function k(){m(!0),s.current&&clearTimeout(s.current),s.current=setTimeout((function(){m(!1)}),w)}function F(){var e=o.current,t=a.current;if(e&&t){var r=e.getBoundingClientRect().bottom,n=t.getBoundingClientRect().bottom;u(n-1<=r)}}function C(){if(function(){var e,t=null===(e=o.current)||void 0===e?void 0:e.querySelectorAll("video");return!t||0===t.length||Array.from(t).every((function(e){return e.readyState>=1}))}()){var e=o.current;v(!0),e&&setTimeout((function(){k(),e.scrollTop=e.scrollHeight}),0)}else setTimeout(C,1)}function E(e){y((function(t){return Vt(t,e)}))}return(0,f.useEffect)((function(){var e=o.current;if(F(),e)return e.addEventListener("scroll",F),window.addEventListener("resize",F),function(){e.removeEventListener("scroll",F),window.removeEventListener("resize",F)}}),[l]),(0,f.useEffect)((function(){C()}),[x]),(0,f.useEffect)((function(){l&&0!==S&&j>S&&(k(),C())}),[l,Object.keys(b).length]),(0,f.useEffect)((function(){var e,r={};null===(e=t.receivedMessages)||void 0===e||e.forEach((function(e){var t=Vt(r,e);r=t})),y(r)}),[null===(r=t.receivedMessages)||void 0===r?void 0:r.length]),(0,f.useEffect)((function(){t.ws.onReceive&&t.ws.onReceive(E)}),[]),(0,e.jsxs)(Ht(),{ref:o,className:"rustic-message-space",children:[Object.keys(b).map((function(r,n){var i=b[r],o=i[i.length-1];return(0,e.jsx)(Lt,{message:o,getActionsComponent:t.getActionsComponent,getProfileComponent:t.getProfileComponent,ref:n===j-1?a:null,children:(0,e.jsx)(N,{ws:t.ws,sender:t.sender,messages:i,supportedElements:t.supportedElements})},r)})),!l&&!p&&(0,e.jsx)(_t(),{variant:"rusticSecondary",className:"rustic-scroll-down-button",size:"medium",onClick:C,label:(0,e.jsxs)(e.Fragment,{children:[t.scrollDownLabel,(0,e.jsx)(re,{name:"arrow_downward"})]})})]})}Ut.defaultProps={scrollDownLabel:"Scroll down"};const Gt=function(t){return(0,e.jsx)(k(),{variant:"body2",className:"rustic-text",children:Ze().sanitize(t.text)})};function Kt(t){return(0,e.jsxs)(Ht(),{className:"rustic-multipart",children:[t.text&&(0,e.jsx)(Gt,{text:t.text}),(r=t.files.map((function(t,r){return(0,e.jsx)(Ce,{file:t,children:t.url&&(0,e.jsx)(ee(),{title:"Download",children:(0,e.jsx)(H(),{component:"a",href:t.url,download:t.name,children:(0,e.jsx)(re,{name:"download"})})})},r)})),(0,e.jsx)(Ht(),{className:"rustic-files",children:r}))]});var r}const Qt=require("@mui/material/Dialog");var Yt=i.n(Qt);const Xt=require("@mui/material/DialogTitle");var $t=i.n(Xt);const Zt=require("@mui/material/List");var Jt=i.n(Zt);const er=require("@mui/material/ListItem");var tr=i.n(er);const rr=require("@mui/material/ListSubheader");var nr=i.n(rr);const ir=require("pluralize");var ar,or,sr=i.n(ir);function cr(t){var r=(0,f.useState)(!1),n=r[0],i=r[1],a=t.participants.length,o=n?t.participants:t.participants.slice(0,3),s="".concat(sr()(t.participantType,a)," (").concat(a,")"),c=n?"Show Less":"Show All ".concat(a);return 0===a?(0,e.jsx)(k(),{variant:"caption",className:"rustic-participant-list-no-participants-message",children:"There are currently no participants."}):(0,e.jsx)(Jt(),{className:"rustic-participant-list",subheader:(0,e.jsxs)(nr(),{disableSticky:!0,className:"rustic-participant-list-subheader",children:[(0,e.jsxs)(F.Box,{className:"rustic-participant-list-subheader-title",children:[t.participantTypeIcon,(0,e.jsx)(k(),{variant:"subtitle2",color:"text.secondary",children:s})]}),a>3&&(0,e.jsx)(at(),{onClick:function(){return i(!n)},color:"primary",size:"small",startIcon:(0,e.jsx)(re,{name:"keyboard_arrow_down"}),children:c})]}),children:o.map((function(t){return(0,e.jsxs)(tr(),{className:"rustic-participant-list-item",children:[(0,e.jsx)(k(),{variant:"subtitle2",children:t.displayName}),(0,e.jsx)(k(),{variant:t.participantRole===ar.Owner?"subtitle2":"caption",children:D(t.participantRole)})]},t.id)}))})}!function(e){e.Owner="owner",e.Member="member"}(ar||(ar={})),function(e){e.Human="human",e.Agent="agent"}(or||(or={}));const lr=function(t){function r(e,t){return function(e){return function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}([],e,!0).sort((function(e,t){return t.participantRole===ar.Owner?1:-1}))}(e.filter((function(e){return e.participantType===t})))}var n=r(t.participants,or.Human),i=r(t.participants,or.Agent),a="".concat(sr()("Participant",t.participants.length)," (").concat(t.participants.length,")");return(0,e.jsxs)(Yt(),{open:t.isParticipantListOpen,onClose:t.onClose,className:"rustic-participants-container",maxWidth:"sm",fullWidth:!0,children:[(0,e.jsx)($t(),{sx:{borderBottom:"1px solid",borderColor:"divider"},component:"h6",className:"rustic-participants-container-title",children:a}),(0,e.jsx)(cr,{participantType:"Human",participantTypeIcon:(0,e.jsx)(re,{name:"account_circle"}),participants:n}),i.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(gt(),{className:"rustic-participants-container-divider"}),(0,e.jsx)(cr,{participantType:"Agent",participantTypeIcon:(0,e.jsx)(re,{name:"smart_toy"}),participants:i})]})]})},ur=require("@mui/material/DialogActions");var dr=i.n(ur);const pr=require("@mui/material/DialogContent");var mr=i.n(pr);const fr=require("@mui/material/DialogContentText");var hr=i.n(fr),xr=function(){return xr=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},xr.apply(this,arguments)},vr=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function gr(t){var r=(0,f.useState)(!1),n=r[0],i=r[1],a=(0,f.useState)(!1),o=a[0],s=a[1],c=(0,f.useState)(!1),l=c[0],u=c[1],d=(0,f.useState)(!1),p=d[0],m=d[1],h=(0,f.useState)([]),x=h[0],v=h[1],g=(0,f.useState)(null),b=g[0],y=g[1],j=(0,F.useTheme)(),S=x[x.length-1],w=xr(xr({},t.ws),{send:function(e){y(e)}});function C(e){v((function(t){return vr(vr([],t,!0),[e],!1)}))}function E(){if(b){var e=xr(xr({},b),{threadId:t.messageId});t.ws.send(e)}}if((0,f.useEffect)((function(){t.ws.onReceive&&t.ws.onReceive(C)}),[t.ws]),(0,f.useEffect)((function(){x.length>0&&(S&&S.sender.id!==t.sender.id&&s(!1),"promptBuilder"===S.format&&S.data.isLastQuestion&&i(!0))}),[x.length]),0!==x.length)return(0,e.jsxs)(he(),{variant:"outlined",className:"rustic-prompt-builder",children:[(0,e.jsxs)(Yt(),{open:l,onClose:function(){return u(!1)},"aria-labelledby":"quit-dialog-title","aria-describedby":"quit-dialog-description",sx:{"& .MuiPaper-root":{width:"clamp(320px,50vw,600px)",border:"1px solid ".concat(j.palette.divider)}},children:[(0,e.jsx)($t(),{id:"quit-dialog-title",className:"rustic-align-self-center",children:"Are you sure?"}),(0,e.jsx)(gt(),{}),(0,e.jsx)(mr(),{children:(0,e.jsx)(hr(),{id:"quit-dialog-description",className:"rustic-align-self-center",children:"All progress will be lost."})}),(0,e.jsxs)(dr(),{className:"rustic-prompt-builder-dialog-buttons",disableSpacing:!0,children:[(0,e.jsx)(at(),{variant:"rusticSecondary",startIcon:(0,e.jsx)(re,{name:"close"}),onClick:function(){u(!1),t.onCancel()},children:"Quit"}),(0,e.jsx)(at(),{variant:"rusticPrimary",onClick:function(){return u(!1)},children:"Continue build"})]})]}),t.getProfileComponent?t.getProfileComponent(x[0]):(0,e.jsx)(k(),{color:"text.secondary",children:"Prompt Builder"}),(0,e.jsx)(gt(),{className:"rustic-prompt-builder-divider"}),(0,e.jsxs)(F.Box,{className:"rustic-prompt-builder-questions",children:[function(){if(!p&&x.length>0)return x.map((function(r){if(r.sender.id!==t.sender.id&&"promptBuilder"!==r.format)return(0,e.jsx)(N,{ws:w,sender:t.sender,messages:[r],supportedElements:t.supportedElements},r.id)}))}(),o&&(0,e.jsx)(P(),{color:"secondary",className:"rustic-align-self-center"})]}),(0,e.jsx)(e.Fragment,{children:!p&&(0,e.jsxs)(F.Box,{className:"rustic-prompt-builder-buttons",children:[(0,e.jsxs)(F.Box,{className:"rustic-prompt-builder-buttons-left",children:[(0,e.jsx)(at(),{variant:"rusticSecondary",startIcon:(0,e.jsx)(re,{name:"close"}),onClick:function(){return u(!0)},children:"Quit"}),(0,e.jsx)(at(),{variant:"rusticSecondary",endIcon:(0,e.jsx)(re,{name:"chevron_right"}),onClick:function(){E(),y(null),s(!0)},disabled:!b,"aria-disabled":!b,children:"Next question"})]}),n&&(0,e.jsx)(F.Box,{className:"rustic-prompt-builder-buttons-right",children:(0,e.jsx)(at(),{variant:"rusticPrimary",onClick:function(){E(),m(!0),s(!0),t.onSubmit()},disabled:o,"aria-disabled":o,children:"Generate"})})]})})]})}function br(t){var r=(0,f.useState)(""),n=r[0],i=r[1],a=(0,nt.useTheme)(),o=(0,nt.useMediaQuery)(a.breakpoints.down("md"))?"column":"row",s=t.options.map((function(r,a){return(0,e.jsx)(_t(),{onClick:function(){return function(e){i(e);var r=(new Date).toISOString(),n={id:(0,_.v4)(),timestamp:r,sender:t.sender,conversationId:t.conversationId,format:"text",data:{text:e},inReplyTo:t.messageId};t.ws.send(n)}(r)},variant:"rusticSecondary",size:"small",sx:n===r?{"&.Mui-disabled":{backgroundColor:"secondary.light",color:"text.primary"}}:{},className:"rustic-option",disabled:!!n,"aria-disabled":!!n,label:r},a)}));return(0,e.jsxs)(u(),{className:"rustic-question",children:[(t.title||t.description)&&(0,e.jsxs)(u(),{className:"rustic-question-text",children:[t.title&&(0,e.jsx)(k(),{variant:"subtitle2",className:"rustic-title",children:t.title}),t.description&&(0,e.jsx)(k(),{variant:"caption",children:t.description})]}),(0,e.jsx)(zt(),{direction:o,className:"rustic-options-container",children:s})]})}const yr=require("@mui/material/Table");var jr=i.n(yr);const Sr=require("@mui/material/TableBody");var wr=i.n(Sr);const kr=require("@mui/material/TableCell");var Fr=i.n(kr);const Cr=require("@mui/material/TableContainer");var Er=i.n(Cr);const Nr=require("@mui/material/TableHead");var Tr=i.n(Nr);const Or=require("@mui/material/TablePagination");var Pr=i.n(Or);const Rr=require("@mui/material/TableRow");var Dr=i.n(Rr);const qr=require("@mui/material/TableSortLabel");var Mr,zr=i.n(qr),Ir=10;function Lr(){return(0,e.jsx)(re,{name:"expand_all"})}function Br(t){if(0===t.data.length)return(0,e.jsx)(k(),{variant:"body2",children:"No data available"});var r,n,i,a=t.data.length>Ir,o=(0,f.useState)({}),s=o[0],c=o[1],l=(0,f.useState)(a?Ir:-1),u=l[0],d=l[1],p=(0,f.useState)(0),m=p[0],h=p[1],x=(0,nt.useTheme)(),v=Array.from(new Set(t.data.flatMap((function(e){return Object.keys(e)})))),g=t.headers||v.map((function(e){return{dataKey:e}})),b=(r=t.data,n=Object.keys(s)[0],i=s[n],n&&i?r.slice().sort((function(e,t){var r=Object.keys(s)[0],n=s[r];return e[r]<t[r]?n===Mr.Descending?1:-1:e[r]>t[r]?n===Mr.Descending?-1:1:0})):r),y=b.slice(m*u,m*u+u),j=u>0?y:b;function S(e){if(!s[e])return Lr}return(0,e.jsxs)(zt(),{className:"rustic-table",spacing:1,children:[t.title&&(0,e.jsx)(k(),{variant:"h6",className:"rustic-table-title",children:t.title}),t.description&&(0,e.jsx)(k(),{variant:"body1",children:t.description}),(0,e.jsx)(Er(),{className:"rustic-table-container",children:(0,e.jsxs)(jr(),{"aria-label":t.title||"a table of data",size:"small",stickyHeader:!0,children:[g.length>0&&(0,e.jsx)(Tr(),{children:(0,e.jsx)(Dr(),{children:g.map((function(t,r){return(0,e.jsx)(Fr(),{sortDirection:s[t.dataKey]||!1,children:(0,e.jsx)(ee(),{title:(n=t.dataKey,i=s[n],i?Object.keys(Mr)[Object.values(Mr).indexOf(i)]:"Sort"),children:(0,e.jsx)(zr(),{active:!0,direction:s[t.dataKey],onClick:function(){return function(e){c((function(t){var r,n,i={};switch(t[e]){case Mr.Ascending:(r={})[e]=Mr.Descending,i=r;break;case Mr.Descending:i={};break;default:(n={})[e]=Mr.Ascending,i=n}return i}))}(t.dataKey)},className:"rustic-table-header",IconComponent:S(t.dataKey),children:t.label||D(t.dataKey)})})},"header-".concat(r));var n,i}))})}),(0,e.jsx)(wr(),{children:j.map((function(t,r){return(0,e.jsx)(Dr(),{children:g.map((function(n,i){return(0,e.jsx)(Fr(),{children:t[n.dataKey]},"cell-".concat(r,"-").concat(i))}))},"row-".concat(r))}))})]})}),a&&(0,e.jsx)(Pr(),{className:"rustic-table-pagination",component:"div",count:t.data.length,rowsPerPage:u,labelRowsPerPage:"Rows:",page:m,onPageChange:function(e,t){return h(t)},onRowsPerPageChange:function(e){d(+e.target.value),h(0)},sx:{"& .MuiTablePagination-selectLabel":{color:x.palette.text.disabled}},classes:{toolbar:"rustic-table-toolbar",input:"rustic-table-input",spacer:"rustic-table-spacer",displayedRows:"rustic-table-displayed-rows",actions:"rustic-table-actions"}})]})}!function(e){e.Ascending="asc",e.Descending="desc"}(Mr||(Mr={}));const _r=function(t){var r=(0,f.useState)(Ze().sanitize(t.text)),n=r[0],i=r[1],a=(0,f.useState)(""),o=a[0],s=a[1];return(0,f.useEffect)((function(){if(t.updatedData&&t.updatedData.length>0){for(var e=t.text,r=0,n=t.updatedData;r<n.length;r++){var a=n[r];"string"!=typeof a.text&&(e+=" [MISSING TEXT]",s("Some of the incoming text was not correctly formatted. Some data may be missing.")),e+=a.text}i(Ze().sanitize(e))}}),[t.text,t.updatedData]),(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(k(),{variant:"body2",children:n}),o&&(0,e.jsx)(Le(),{severity:"error",children:o})]})};var Ar=function(){return Ar=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ar.apply(this,arguments)};function Hr(t){var r=Ze().sanitize(t.youtubeVideoId);return(0,e.jsx)("iframe",Ar({},z(t.width,t.height),{src:"https://www.youtube.com/embed/".concat(r),title:t.title,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen",loading:"lazy"}))}Hr.defaultProps={title:"Embedded video"};const Wr=require("@mui/material/FormControl");var Vr=i.n(Wr);const Ur=require("recharts");var Gr=function(){return Gr=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Gr.apply(this,arguments)},Kr={line:Ur.LineChart,bar:Ur.BarChart,area:Ur.AreaChart};function Qr(e){var t={};return e.forEach((function(e){t[e]=!0})),t}function Yr(t){var r=(0,f.useState)(t.defaultChartType||"line"),n=r[0],i=r[1],a=(0,f.useState)(null),o=a[0],s=a[1],c=(0,f.useState)(t.timeSeries),l=c[0],u=c[1],d=je()(),p=l.length>0?Object.keys(l[0]):[],m=p[0],h=p.slice(1),x=(0,f.useState)(Qr(h)),v=x[0],g=x[1];(0,f.useEffect)((function(){if(t.updatedData&&t.updatedData.length>0){var e=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}([],t.timeSeries,!0);t.updatedData.forEach((function(t){e=e.concat(t.timeSeries),u(e)}))}}),[t.timeSeries,t.updatedData]);var b=Kr[n];function y(e){o?s(null):e&&s(e.currentTarget)}function j(e,r){return v[e]?t.chartColors[r%t.chartColors.length]:"grey"}function S(e){return v[e]?"none":"line-through"}if(0===l.length)return(0,e.jsx)(k(),{variant:"body2",children:"No data available"});var w,F,C,E,N=t.timeSeries[t.timeSeries.length-1],T=(w=t.timeSeries[0][m],F=N[m],C=new Date(w),E=new Date(F),Math.round(Math.abs((E.getTime()-C.getTime())/864e5)));return(0,e.jsxs)(Ht(),{className:"rustic-recharts-time-series",children:[!t.disableChartTypeToggle&&(0,e.jsxs)(Vr(),{className:"rustic-recharts-time-series-chart-toggle",children:[(0,e.jsx)(H(),{"aria-label":"chart options","aria-expanded":Boolean(o),"aria-haspopup":"true",onClick:y,color:"primary",children:(0,e.jsx)(re,{name:"more_vert"})}),(0,e.jsxs)(Tt(),{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:o,open:Boolean(o),onClose:function(e){return y(e)},children:[(0,e.jsx)(k(),{className:"rustic-recharts-time-series-chart-toggle-title",children:"Chart Types:"}),Object.keys(Kr).map((function(t){return(0,e.jsxs)(G(),{value:t,selected:t===n,onClick:function(){return function(e){i(e),y()}(t)},children:[t.charAt(0).toUpperCase()+t.slice(1)," ","Chart"]},t)}))]})]}),(0,e.jsxs)(Ht(),{children:[t.title&&(0,e.jsx)(k(),{variant:"subtitle2",className:"rustic-recharts-time-series-title",children:t.title}),t.description&&(0,e.jsx)(k(),{variant:"caption",className:"rustic-recharts-time-series-description",children:t.description}),(0,e.jsx)(Ur.ResponsiveContainer,{aspect:t.aspectRatio,width:t.width,maxHeight:t.maxHeight,minWidth:t.minChartWidth,children:(0,e.jsxs)(b,{data:l,margin:t.chartContainerMargin,children:[(0,e.jsx)(Ur.XAxis,{dataKey:m,tickFormatter:function(e){return q(e,T)},stroke:d.palette.text.primary}),(0,e.jsx)(Ur.YAxis,{domain:["auto","auto"],width:t.yAxisLabelWidth,tickFormatter:t.yAxisTickFormatter,stroke:d.palette.text.primary}),(0,e.jsx)(Ur.Tooltip,{labelFormatter:function(e){return[q(e,T)]},formatter:t.tooltipFormatter,contentStyle:{color:d.palette.common.black}}),(0,e.jsx)(Ur.Legend,{content:function(){return(0,e.jsx)(Ht(),{className:"rustic-recharts-time-series-legend",children:h.map((function(t,r){return(0,e.jsxs)(Ht(),{className:"rustic-recharts-time-series-legend-item",onClick:function(){return function(e){var t,r=v[e]&&!h.find((function(t){return t!==e&&v[t]}));if(function(e){return Object.values(e).every((function(e){return!0===e}))}(v)){for(var n={},i=0,a=h;i<a.length;i++){var o=a[i],s=o===e;n[o]=s}g(n)}else g(r?Qr(h):Gr(Gr({},v),((t={})[e]=!v[e],t)))}(t)},sx:{color:j(t,r)},children:[(0,e.jsx)(re,{name:"crop_16_9"}),(0,e.jsx)(k(),{variant:"body2",display:"inline",sx:{textDecorationLine:S(t)},children:t})]},r)}))})}}),h.map((function(r,i){return v[r]?function(r,i){var a=i%t.chartColors.length,o=v[r]?t.chartColors[a]:"transparent",s={onClick:t.onClick,cursor:"pointer"};switch(n){case"line":return(0,e.jsx)(Ur.Line,{type:"monotone",isAnimationActive:!1,dataKey:r,name:r,dot:!1,stroke:o,activeDot:t.onClick&&s},r);case"bar":return(0,e.jsx)(Ur.Bar,{dataKey:r,fill:o,onClick:t.onClick&&s.onClick,cursor:t.onClick&&s.cursor},r);case"area":return(0,e.jsxs)(f.Fragment,{children:[(0,e.jsx)("defs",{children:(0,e.jsxs)("linearGradient",{id:"color".concat(r),x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,e.jsx)("stop",{offset:"5%",stopColor:o,stopOpacity:.8}),(0,e.jsx)("stop",{offset:"95%",stopColor:o,stopOpacity:0})]})}),(0,e.jsx)(Ur.Area,{isAnimationActive:!1,dataKey:r,type:"monotone",stroke:o,fillOpacity:1,fill:"url(#color".concat(r,")"),activeDot:t.onClick&&s},r)]},r)}}(r,i):null})),t.referenceLineYAxis&&t.referenceLineYAxis.map((function(r,n){return(0,e.jsx)(Ur.ReferenceLine,{y:r,label:t.referenceLineLabel&&t.referenceLineLabel[n],stroke:t.referenceLineColor&&t.referenceLineColor[n],strokeDasharray:"3 3",ifOverflow:"extendDomain",strokeWidth:t.referenceLineStrokeWidth&&t.referenceLineStrokeWidth[n],isFront:!0},n)}))]})})]})]})}Yr.defaultProps={minChartWidth:200,maxHeight:600,yAxisLabelWidth:30,aspectRatio:16/9,disableChartTypeToggle:!1};const Xr=Yr,$r=require("mermaid");var Zr=i.n($r),Jr=function(){return Jr=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Jr.apply(this,arguments)};const en=function(t){var r=(0,f.useRef)(null),n=(0,f.useState)(),i=n[0],a=n[1],o=je()(),s=(0,_.v4)();return(0,f.useEffect)((function(){var e="dark"===o.palette.mode?"dark":"neutral",n=o.typography.fontFamily;r.current&&(Zr().initialize(Jr({theme:e,themeVariables:{fontFamily:n}},t.config)),Zr().render("mermaid-svg-".concat(s),t.diagram,r.current).then((function(e){r.current&&(r.current.innerHTML=e.svg),a("")})).catch((function(){var e;null===(e=r.current)||void 0===e||e.replaceChildren(),a("Failed to render the diagram.")})))})),(0,e.jsxs)(zt(),{className:"rustic-mermaid-container",children:[t.title&&(0,e.jsx)(k(),{variant:"subtitle2",children:t.title}),t.description&&(0,e.jsx)(k(),{variant:"caption",children:t.description}),(0,e.jsx)("div",{className:"rustic-mermaid",ref:r}),i&&(0,e.jsx)(k(),{variant:"body2",children:i})]})},tn=(require("@finos/perspective-viewer"),require("@finos/perspective-viewer-datagrid"),require("@finos/perspective-viewer-d3fc"),require("@finos/perspective-viewer/dist/css/pro.css"),require("@finos/perspective-viewer/dist/css/pro-dark.css"),require("@finos/perspective"));var rn=i.n(tn),nn=function(){return nn=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},nn.apply(this,arguments)};function an(e){return e?e.reduce((function(e,t){var r=t.dataKey,n=t.label;return e[r]=n||r,e}),{}):{}}const on=function(t){if(0===t.data.length)return(0,e.jsx)(k(),{variant:"body2",children:"No data available."});var r=(0,f.useRef)(null),n=(0,d.useTheme)(),i=(0,f.useState)(!1),a=i[0],o=i[1],s=n.palette.mode,c="dark"===s?"Pro Dark":"Pro Light",l=an(t.headers),u="\n /* General Button Styles */\n button, .button:hover, #editor-container, .editable, #settings_button {\n border-radius: 16px !important;\n color: ".concat(n.palette.text.primary," !important;\n /* TODO: add background color after updating the theme */\n }\n \n #settings_button {\n border: 1px solid ").concat(n.palette.primary.light," !important;\n }\n \n /* Hide border for aggregate Selector */\n .aggregate-selector:hover {\n border: none !important;\n }\n \n /* Input and Select Elements */\n input, select, .noselect, #add-expression, .dropdown-width-container, \n .pivot-column-border, .pivot-column, .column-selector-column-border {\n border-radius: 8px !important;\n }\n \n /* Change background color */\n #settings_panel, #column_settings_sidebar {\n background: ").concat("dark"===s?"dark":"white"," !important;\n background-image: none !important;\n }\n \n /* Expression Edit Button */\n .expression-edit-button {\n display: none;\n }\n \n /* Add padding to expression input */\n #editor-container, .editable {\n padding: 8px !important;\n }\n \n /* Change Button Font Size */\n .button select, .button {\n font-size: 12px !important;\n }\n \n /* Button and Icon Colors */\n span.button {\n color: ").concat(n.palette.primary.main," !important;\n }\n \n span.button:hover:before {\n background-color: ").concat(n.palette.primary.main," !important;\n }\n \n .button select:hover, .button:hover, .psp-expression-editor__button:hover, \n .sidebar_close_button_inner:hover {\n background-color: ").concat(n.palette.primary.light," !important;\n }\n \n /* Enable Scrolling */\n #plugin_selector_container.open, #status_bar, #menu-bar, #app_panel {\n overflow: scroll !important;\n }\n \n /* Hide unused buttons */\n #debug_open_button.sidebar_close_button, .reset-default-style-disabled, \n .expression-edit-button, #theme, #status, #status_bar .input-sizer {\n display: none !important;\n }\n ");var p,m,h,x,v,g,b,y,j,S=t.config&&(m=(p=t.config).groupBy,h=p.splitBy,x=p.aggregates,v=p.sort,g=p.filter,b=p.columns,y=null==v?void 0:v.map((function(e){return[l[e[0]]||e[0],e[1]]})),j=x&&Object.fromEntries(Object.entries(x).map((function(e){var t=e[0],r=e[1];return[l[t]||t,r]}))),{group_by:null==m?void 0:m.map((function(e){return l[e]||e})),split_by:null==h?void 0:h.map((function(e){return l[e]||e})),aggregates:j,sort:y,filter:g&&function(e){return e.map((function(e){return[l[e[0]]||e[0],e[1],e[e.length-1]]}))}(g),columns:null==b?void 0:b.map((function(e){return l[e]||e}))});return(0,f.useEffect)((function(){rn().worker().table(function(e,t){var r=an(t);return e.map((function(e){for(var t={},n=0,i=Object.entries(e);n<i.length;n++){var a=i[n],o=a[0],s=a[1];t[r[o]||o]=[s]}return t}))}(t.data,t.headers)).then((function(e){var n=r.current;n&&n.load(e).then((function(){if(n.restore(nn(nn({},S),{theme:c,title:t.title,settings:!1})),n.shadowRoot){var e=new CSSStyleSheet;e.replaceSync(u),n.shadowRoot.adoptedStyleSheets.push(e)}})).catch((function(){o(!0)}))})).catch((function(){o(!0)}))}),[t.data,c]),a?(0,e.jsx)(k(),{variant:"body2",children:"Failed to create table from data."}):(0,e.jsxs)(be(),{direction:"column",className:"rustic-perspective-viz",children:[t.title&&(0,e.jsx)(k(),{variant:"h6",children:t.title}),t.description&&(0,e.jsx)(k(),{variant:"body1",children:t.description}),(0,e.jsx)("perspective-viewer",{ref:r,style:{fontFamily:n.typography.fontFamily}})]})},sn=require("react-dom/server"),cn=require("vega-embed");var ln=i.n(cn),un=function(){return un=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},un.apply(this,arguments)};function dn(t){var r=(0,f.useRef)(null),n=(0,f.useState)(!1),i=n[0],a=n[1],o=je()(),s="dark"===o.palette.mode,c=o.typography.fontFamily,l={backgroundColor:o.palette.primary.main,color:o.palette.background.paper,borderRadius:o.shape.borderRadius+"px",padding:"4px 8px",fontSize:o.typography.caption.fontSize,fontFamily:c,fontWeight:o.typography.caption.fontWeight},u={formatTooltip:function(t,r){return(0,sn.renderToStaticMarkup)((0,e.jsx)("div",{role:"tooltip",className:"rustic-vega-lite-tooltip-content",style:l,children:Object.entries(t).map((function(t){var n=t[0],i=t[1];return(0,e.jsxs)("div",{children:[(0,e.jsxs)("strong",{children:[r(n),":"]})," ",r(i)]},n)}))}))},disableDefaultStyle:!0,id:"rustic-vega-lite-tooltip"},d=[{label:"Save as SVG"},{label:"Save as PNG"}];function p(){var e,n,i,o;if(r.current&&t.spec){var l=un(un({config:{font:c}},t.options),{theme:s?null===(e=t.theme)||void 0===e?void 0:e.dark:null===(n=t.theme)||void 0===n?void 0:n.light,tooltip:u,actions:!1});(null===(o=null===(i=t.options)||void 0===i?void 0:i.config)||void 0===o?void 0:o.font)||(l.config.font=c);var p=un({},t.spec);delete p.title,ln()(r.current,p,l).then((function(e){var t=e.embedOptions,r=e.embedOptions.downloadFileName||"visualization";["svg","png"].map((function(n,i){var a="object"==typeof t.scaleFactor?t.scaleFactor[n]:t.scaleFactor;e.view.toImageURL(n,a).then((function(e){d[i].href=e,d[i].downloadFileName="".concat(r,".").concat(n)}))})),a(!1)})).catch((function(){a(!0)}))}}return(0,f.useEffect)((function(){function e(){p()}return p(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[t.spec,s]),i?(0,e.jsx)(k(),{variant:"body2",children:"Failed to load the chart."}):(0,e.jsxs)(be(),{direction:"column",className:"rustic-vega-lite-container",children:[(0,e.jsx)(Ht(),{justifyContent:"end",display:"flex",children:(0,e.jsx)(Pt,{menuItems:d,ariaLabel:"Download options"})}),t.title&&(0,e.jsx)(k(),{variant:"h6",children:t.title}),t.description&&(0,e.jsx)(k(),{variant:"body1",children:t.description}),(0,e.jsxs)(Ht(),{textAlign:"center",mt:1,children:["string"==typeof t.spec.title&&(0,e.jsx)(k(),{variant:"subtitle2",children:t.spec.title}),t.spec.description&&(0,e.jsx)(k(),{variant:"caption",children:t.spec.description})]}),(0,e.jsx)("div",{ref:r,className:"rustic-vega-lite"})]})}const pn=dn;function mn(t){var r=(0,f.useState)(t.units),n=r[0],i=r[1];function a(e){return"metric"===t.units&&"imperial"===n?Math.round(1.8*e+32):"imperial"===t.units&&"metric"===n?Math.round(e*(5/9)-32):Math.round(e)}var o=new Date(1e3*t.weather[0].timestamp),s=I(t.weather[0].timestamp).shortName,c=o.getDate(),l=o.getFullYear().toString().slice(2),d="".concat(s," ").concat(c,"/").concat(l," TODAY"),p="HIGH: ".concat(a(t.weather[0].temp.high)," / LOW: ").concat(a(t.weather[0].temp.high)),m=t.weather.map((function(t,r){if(0!==r)return(0,e.jsxs)(he(),{variant:"outlined",className:"rustic-daily-weather-card",children:[(0,e.jsx)(k(),{variant:"h5",component:"span",color:"text.secondary","aria-label":I(t.timestamp).fullName,children:I(t.timestamp).shortName}),(0,e.jsx)("img",{src:t.weatherIcon.icon,alt:t.weatherIcon.description}),(0,e.jsxs)(k(),{variant:"body2",color:"text.secondary",children:["High: ",a(t.temp.high),"°"]}),(0,e.jsxs)(k(),{variant:"body2",color:"text.secondary",children:["Low: ",a(t.temp.low),"°"]})]},r)}));return(0,e.jsxs)(he(),{variant:"outlined",className:"rustic-weather",children:[(0,e.jsx)(Pt,{ariaLabel:"Temperature units",menuItems:[{label:"Celsius",endDecorator:"°C",onClick:function(){return i("metric")}},{label:"Fahrenheit",endDecorator:"°F",onClick:function(){return i("imperial")}}]}),(0,e.jsxs)(zt(),{alignItems:"center",children:[(0,e.jsx)(k(),{variant:"h4",component:"span",children:t.location}),(0,e.jsxs)(zt(),{direction:"row",alignItems:"center",spacing:1,className:"rustic-current-weather-description",children:[(0,e.jsx)("img",{src:t.weather[0].weatherIcon.icon,alt:""}),(0,e.jsx)(k(),{variant:"body2",children:t.weather[0].weatherIcon.description})]}),t.weather[0].temp.current&&(0,e.jsxs)(k(),{variant:"h1",component:"span",className:"rustic-current-temp",children:[a(t.weather[0].temp.current),"°",function(e){switch(e){case"imperial":return"F";case"metric":return"C"}}(n)]}),(0,e.jsxs)(zt(),{direction:"row",spacing:2,children:[(0,e.jsx)(k(),{variant:"overline",children:d}),(0,e.jsx)(k(),{variant:"overline",children:p})]})]}),(0,e.jsx)(u(),{className:"rustic-daily-weather-container",children:m}),t.weatherProvider&&(0,e.jsxs)(zt(),{alignItems:"center",direction:"row",spacing:1,alignSelf:"center",className:"rustic-weather-attribution",children:[(0,e.jsx)(re,{name:"cloud"}),(0,e.jsx)(k(),{variant:"body2",children:"Weather data provided by ".concat(t.weatherProvider)})]})]})}dn.defaultProps={theme:{dark:"dark"}};var fn=i(470)})(),a})()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rustic-ai/ui-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"rustic-ai",
|
|
6
6
|
"conversational-ui"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@mui/material": "5.15.7",
|
|
31
31
|
"@mui/styled-engine-sc": "5.14.11",
|
|
32
32
|
"@mui/system": "5.15.8",
|
|
33
|
-
"axios": "1.
|
|
33
|
+
"axios": "1.7.4",
|
|
34
34
|
"react": "18.2.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"@mui/system": "^5.15.8",
|
|
134
134
|
"@types/react": "^18.2.37",
|
|
135
135
|
"@types/react-dom": "^18.2.15",
|
|
136
|
-
"axios": "1.
|
|
136
|
+
"axios": "1.7.4",
|
|
137
137
|
"dompurify": "^3.0.6",
|
|
138
138
|
"emoji-picker-element": "^1.21.3",
|
|
139
139
|
"marked": "^10.0.0",
|