@rustic-ai/ui-components 0.0.21 → 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/calendar/fCCalendar.d.ts.map +1 -1
- package/dist/components/calendar/index.css +24 -10
- package/dist/components/calendar/index.js +1 -1
- package/dist/components/helper.d.ts +0 -2
- package/dist/components/helper.d.ts.map +1 -1
- package/dist/components/image/index.js +1 -1
- package/dist/components/input/multimodal/multimodalInput/index.css +12 -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/multimodal/uploader/index.js +1 -1
- package/dist/components/input/textInput/index.css +4 -0
- package/dist/components/input/textInput/index.js +1 -1
- package/dist/components/media/audio/index.js +1 -1
- package/dist/components/media/video/index.js +1 -1
- package/dist/components/messageCanvas/index.js +1 -1
- package/dist/components/messageSpace/index.js +1 -1
- package/dist/components/multipart/index.js +1 -1
- package/dist/components/table/index.js +1 -1
- package/dist/components/timestamp/index.js +1 -1
- package/dist/components/video/index.js +1 -1
- package/dist/components/visualization/chart/index.js +1 -1
- package/dist/components/weather/index.js +1 -1
- package/dist/index.css +36 -10
- package/dist/index.js +1 -1
- package/package.json +10 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fCCalendar.d.ts","sourceRoot":"","sources":["../../../src/components/calendar/fCCalendar.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"fCCalendar.d.ts","sourceRoot":"","sources":["../../../src/components/calendar/fCCalendar.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAUzB,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,UAAU,CAAA;AAa3D;;;;;;;;iUAQiU;AACjU,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,EAAE,YAAY,2CA6ErD"}
|
|
@@ -1,21 +1,35 @@
|
|
|
1
|
-
.rustic-fc-calendar
|
|
2
|
-
|
|
1
|
+
.rustic-fc-calendar {
|
|
2
|
+
padding: 16px;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.rustic-fc-calendar .fc-event-title {
|
|
6
|
+
text-overflow: ellipsis;
|
|
3
7
|
}
|
|
4
8
|
|
|
5
9
|
.rustic-fc-calendar .fc-button {
|
|
6
|
-
|
|
7
|
-
padding: 2px 4px;
|
|
10
|
+
padding: 4px 8px;
|
|
8
11
|
}
|
|
9
12
|
|
|
10
|
-
.rustic-fc-calendar
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
.rustic-fc-calendar
|
|
14
|
+
.fc
|
|
15
|
+
.fc-button-primary:not(:disabled).fc-button-active:focus,
|
|
16
|
+
.rustic-fc-calendar .fc .fc-button-primary:focus,
|
|
17
|
+
.rustic-fc-calendar .fc .fc-button-primary:not(:disabled):active:focus {
|
|
18
|
+
box-shadow: none;
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
@media (max-width: 900px) {
|
|
17
|
-
.rustic-fc-calendar {
|
|
18
|
-
|
|
22
|
+
.rustic-fc-calendar .fc-toolbar {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
gap: 4px;
|
|
26
|
+
align-items: flex-start;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.rustic-fc-calendar .fc-toolbar .fc-toolbar-chunk:last-child {
|
|
30
|
+
display: flex;
|
|
31
|
+
justify-content: space-between;
|
|
32
|
+
width: 100%;
|
|
19
33
|
}
|
|
20
34
|
}
|
|
21
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var a in t)e.o(t,a)&&!e.o(r,a)&&Object.defineProperty(r,a,{enumerable:!0,get:t[a]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{default:()=>m});const t=require("react/jsx-runtime"),a=require("@fullcalendar/daygrid");var o=e.n(a);const i=require("@fullcalendar/react");var n=e.n(i);const d=require("@fullcalendar/timegrid");var c=e.n(d);const l=require("@mui/material/Box");var s=e.n(l);const u=require("@mui/material/styles"),p=require("@mui/material/useMediaQuery");var f=e.n(p);require("react");var y=function(){return y=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},y.apply(this,arguments)};function b(e){return{title:e.title?e.title:"",start:e.start,end:e.end,allDay:e.isAllDay}}const m=function(e){var r=(0,u.useTheme)(),a=f()(r.breakpoints.up("md"));return(0,t.jsx)(s(),{className:"rustic-fc-calendar",sx:{border:"1px solid ".concat(r.palette.divider),borderRadius:"".concat(r.shape.borderRadius,"px"),".fc .fc-toolbar-title":y({},r.typography.h6),".fc .fc-scrollgrid-liquid":{borderRadius:"".concat(r.shape.borderRadius,"px")},".fc td":{borderRadius:"0 0 ".concat(r.shape.borderRadius,"px ").concat(r.shape.borderRadius,"px")},".fc .fc-scrollgrid-section-header > th":{borderRadius:"".concat(r.shape.borderRadius,"px ").concat(r.shape.borderRadius,"px 0 0")},".fc .fc-button, .fc .fc-button:active":{color:r.palette.primary.main,backgroundColor:r.palette.background.paper,border:"1px solid ".concat(r.palette.divider),borderRadius:"".concat(r.shape.borderRadius,"px"),"&:hover":{backgroundColor:r.palette.secondary.light,border:"1px solid ".concat(r.palette.divider)}},".fc .fc-button-group .fc-button.fc-button-active":{backgroundColor:r.palette.secondary.main,border:"1px solid ".concat(r.palette.divider)},".fc a, .fc .fc-event-title, .fc .fc-button, .fc .fc-timegrid-slot":y({},r.typography.caption)},children:(0,t.jsx)(n(),{plugins:[c(),o()],initialView:a?"dayGridMonth":"timeGridDay",headerToolbar:{left:"title",right:"prev,next dayGridMonth,timeGridWeek,timeGridDay"},eventColor:r.palette.secondary.main,displayEventTime:!1,titleFormat:{year:"numeric",month:"long"},views:{dayGridMonth:{dayHeaderFormat:{weekday:a?"long":"narrow"}},timeGridWeek:{dayHeaderFormat:{weekday:"short",day:"numeric"}},timeGridDay:{dayHeaderFormat:{weekday:"long",day:"numeric"}}},allDaySlot:!1,initialDate:e.events[0].start,events:e.events.map(b)})})};return r})()));
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export declare function calculateTimeDiffInSeconds(isoDate: string): number;
|
|
2
|
-
export declare function calculateTimeAgo(isoDate: string): string;
|
|
3
2
|
export declare function formatDateAndTime(isoDateTimeInUtc: string): string;
|
|
4
|
-
export declare function formatMessageTimestamp(isoDate: string): string;
|
|
5
3
|
export declare const capitalizeFirstLetter: (str: string) => string;
|
|
6
4
|
export declare enum TimeFormat {
|
|
7
5
|
HOUR = 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/components/helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/components/helper.ts"],"names":[],"mappings":"AAEA,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIlE;AAED,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CA6BlE;AAED,eAAO,MAAM,qBAAqB,QAAS,MAAM,KAAG,MAEnD,CAAA;AAED,oBAAY,UAAU;IACpB,IAAI,IAAA;IACJ,UAAU,IAAA;CACX;AAED,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,MAAM,EACzB,MAAM,EAAE,UAAU,GACjB,MAAM,CAsBR;AAED,wBAAgB,uBAAuB,CACrC,sBAAsB,EAAE,MAAM,EAC9B,oBAAoB,EAAE,MAAM,GAC3B,MAAM,CASR;AAED,wBAAgB,oBAAoB,CAClC,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,MAAM,UAOvB;AAED,wBAAgB,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAapE;AAED,wBAAgB,aAAa,CAC3B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAqBzD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAK3D;AAED,eAAO,MAAM,kBAAkB,aACnB,MAAM,KACf;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAoBvC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>f});const r=require("react/jsx-runtime"),o=require("@mui/material/CircularProgress");var n=e.n(o);const i=require("@mui/material/Typography");var a=e.n(i);const c=require("react");var s,u=function(){return u=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},u.apply(this,arguments)};!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(s||(s={}));var l=function(){return l=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},l.apply(this,arguments)};function d(e){var t,o,i,s=(0,c.useState)(!0),d=s[0],f=s[1],p=(0,c.useState)(""),y=p[0],g=p[1];return y.length>0?(0,r.jsx)(a(),{variant:"body2",children:y}):(0,r.jsxs)("figure",{children:[d&&(0,r.jsx)(n(),{}),(0,r.jsx)("img",l({},(t=e.width,o=e.height,i={},t&&(i={width:t}),o&&(i=u(u({},i),{height:o})),t||o||(i={className:"rustic-fit-container"}),i),{src:e.src,alt:e.alt,onError:function(){g("Image failed to load"),f(!1)},onLoad:function(){f(!1)}})),e.description&&(0,r.jsx)("figcaption",{children:(0,r.jsx)(a(),{variant:"body2",children:e.description})})]})}d.defaultProps={alt:"An image is displayed"};const f=d;return t})()));
|
|
@@ -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',
|
|
@@ -102,6 +110,10 @@ code {
|
|
|
102
110
|
margin: 10px 8px;
|
|
103
111
|
}
|
|
104
112
|
|
|
113
|
+
.rustic-base-input .rustic-input-actions {
|
|
114
|
+
display: flex;
|
|
115
|
+
}
|
|
116
|
+
|
|
105
117
|
span.rustic-icon-large {
|
|
106
118
|
font-size: 32px;
|
|
107
119
|
}
|
|
@@ -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);require("pluralize"),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={n:r=>{var n=r&&r.__esModule?()=>r.default:()=>r;return e.d(n,{a:n}),n},d:(r,n)=>{for(var t in n)e.o(n,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:n[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{default:()=>B});const n=require("react/jsx-runtime"),t=require("@mui/material/Box");var a=e.n(t);const i=require("@mui/material/IconButton");var o=e.n(i);const s=require("@mui/material/LinearProgress");var c=e.n(s);const l=require("@mui/material/Tooltip");var u=e.n(l);const d=require("@mui/material/Typography");var f=e.n(d);const m=require("axios");var p=e.n(m);const v=require("react"),h=require("react-dom"),x=require("uuid"),g=require("@mui/material/Card");var j=e.n(g);const b=require("@mui/material/Modal");var y=e.n(b);const w=require("@mui/material/styles");var N;function C(e){return e.name.replaceAll("_","-"),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}require("pluralize"),function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(N||(N={}));const F=require("@mui/material/TextField");var P=e.n(F);const S=require("@mui/material/useMediaQuery");var k=e.n(S);const q=require("@mui/system/Stack");var O=e.n(q);const z=require("@mui/system/useTheme");var T=e.n(z);const _=require("pdfjs-dist"),I=function(e){var r={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},t=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,n.jsx)(u(),{title:t.label,children:(0,n.jsx)("span",{children:(0,n.jsx)(o(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,n.jsx)(C,{name:t.symbol})})})})};var D={pdf:function(e){var r,t=(0,v.useRef)(null),i=(0,v.useState)(1),o=i[0],s=i[1],c=(0,v.useState)(1),l=c[0],u=c[1],d=(0,v.useState)(1),m=d[0],p=d[1],h=(0,v.useState)(!1),x=h[0],g=h[1],b=(0,v.useState)(),y=b[0],w=b[1],N=T()(),C=k()(N.breakpoints.down("sm")),F=k()(N.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,n.jsx)(j(),{variant:"outlined",className:"rustic-pdf-error",children:(0,n.jsx)(f(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var S=(0,v.useState)((function(){return C?.5:F?1:1.5})),q=S[0],z=S[1];return(0,v.useEffect)((function(){_.GlobalWorkerOptions.workerSrc||(_.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(_.version,"/pdf.worker.mjs")),_.getDocument({url:"".concat(e.url)}).promise.then((function(e){u(e.numPages),function(e){e.getPage(o).then((function(e){var r=e.getViewport({scale:q}),n=t.current;if(n){var a=n.getContext("2d");if(a){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 o={canvasContext:a,viewport:r,transform:[i,0,0,i,0,0]};y&&y.cancel();var s=e.render(o);w(s),s.promise.then((function(){w(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[e.url,o,q]),x?(0,n.jsx)(j(),{variant:"outlined",className:"rustic-pdf-error",children:(0,n.jsx)(f(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,n.jsxs)(j(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,n.jsxs)(a(),{className:"rustic-pdf-viewer-header",children:[(0,n.jsx)(I,{action:"zoomOut",onClick:function(){z((function(e){return Math.max(e-.2,.2)}))}}),(0,n.jsx)(I,{action:"zoomIn",onClick:function(){z((function(e){return e+.2}))}})]}),(0,n.jsx)(a(),{className:"rustic-pdf-viewer-body",children:(0,n.jsx)(a(),{className:"rustic-pdf-viewer-body-inner",children:(0,n.jsx)("canvas",{ref:t})})}),(0,n.jsxs)(O(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,n.jsx)(I,{action:"previousPage",onClick:function(){o>1&&(s(o-1),p(o-1))},isDisabled:1===o}),(0,n.jsx)(f(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,n.jsx)(P(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=l&&s(r)},size:"small",className:"rustic-pdf-page-input"}),(0,n.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",l]}),(0,n.jsx)(I,{action:"nextPage",onClick:function(){o<l&&(s(o+1),p(o+1))},isDisabled:o===l})]})]})}};function M(e){var r=(0,w.useTheme)(),t=(0,v.useState)(!1),a=t[0],i=t[1];function s(){i(!1)}var c,l,d=e.file.url&&(c=e.file.url.split("."))[c.length-1].toLowerCase(),m=d&&e.supportedViewers?e.supportedViewers[d]:null,p=!!m;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(j(),{className:"rustic-file-preview".concat(p?" rustic-cursor-pointer":""),variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){i(!0)},children:[(0,n.jsx)(f(),{variant:"subtitle2",children:(l=e.file.name,15,l.length<=15?l:l.substring(0,12)+"...")}),(0,n.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,n.jsx)(y(),{open:a,onClose:s,className:"rustic-file-preview-modal",children:(0,n.jsxs)("div",{className:"rustic-modal-content",children:[(0,n.jsx)(u(),{title:"Close",children:(0,n.jsx)(o(),{onClick:s,className:"rustic-close-button",children:(0,n.jsx)(C,{name:"close"})})}),e.file.url&&(0,n.jsx)(m,{url:e.file.url})]})})]})}M.defaultProps={supportedViewers:D};var U=function(){return U=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},U.apply(this,arguments)},A=function(e,r,n){if(n||2===arguments.length)for(var t,a=0,i=r.length;a<i;a++)!t&&a in r||(t||(t=Array.prototype.slice.call(r,0,a)),t[a]=r[a]);return e.concat(t||Array.prototype.slice.call(r))};function E(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 B=function(e){var r=(0,v.useState)([]),t=r[0],i=r[1],s=(0,v.useState)([]),l=s[0],d=s[1],m=(0,v.useRef)({}),g=(0,x.v4)();(0,v.useEffect)((function(){i([]),d([]),m.current={}}),[e.messageId]);var j=(0,n.jsx)(a(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,t){return(0,n.jsx)(M,{file:{name:r.name},children:(0,n.jsxs)(a(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,n.jsx)(c(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,n.jsx)(u(),{title:"Delete",children:(0,n.jsx)(o(),{color:"primary",onClick:function(){return function(r,n){var t,a;d([]);var o=r.name;if(m.current=U(U({},m.current),((t={})[o]=m.current[o]--,t)),e.onFileUpdate("remove",o),100===r.loadingProgress){var s="".concat(e.deleteFileEndpoint,"?message-id=").concat(e.messageId,"&file-id=").concat(r.id);p().delete(s).then((function(){return i((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return e.onFileUpdate("add",o),d((function(e){return A(A([],e,!0),["Failed to delete ".concat(o,". Please try again.")],!1)}))}))}else r.abortController.abort(),i((function(e){return e.filter((function(e,r){return r!==n}))})),m.current=U(U({},m.current),((a={})[o]=m.current[o]++,a))}(r,t)},className:"rustic-delete-button","aria-label":"cancel file upload",children:(0,n.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},t)}))}),b=(0,n.jsx)(a(),{children:l.map((function(e,r){return(0,n.jsx)(f(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function y(e,r){return r?(0,h.createPortal)(e,r):e}return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(a(),{className:"rustic-uploader",children:[(0,n.jsx)("label",{htmlFor:g,children:(0,n.jsx)(u(),{title:"Upload",children:(0,n.jsx)(o(),{component:"span","aria-label":"Upload file",color:"primary",children:(0,n.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,n.jsx)("input",{type:"file",id:g,onChange:function(r){d([]);var n=r.target.files&&Array.from(r.target.files),a=t.length+(n?n.length:0);e.maxFileCount&&a>e.maxFileCount&&d((function(r){return A(A([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var o=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,a,e.maxFileCount);o&&o.forEach((function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,d((function(r){return A(A([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&E(e.maxFileSize),".")],!1)}))):function(r){var n=new FormData,t=new AbortController,a=function(e){var r,n,t=e.name,a=m.current[t];if(a){var i=a+1,o=t.lastIndexOf("."),s=t.substring(0,o),c=t.substring(o);t="".concat(s,"(").concat(a,")").concat(c),m.current=U(U({},m.current),((r={})[e.name]=i,r))}else m.current=U(U({},m.current),((n={})[e.name]=1,n));return t}(r),o=new File([r],a,{type:r.type});n.append("file",o);var s=(0,x.v4)(),c={name:a,loadingProgress:0,abortController:t,id:s};i((function(e){return A(A([],e,!0),[c],!1)})),e.onFileUpdate("add",a);var l="".concat(e.uploadFileEndpoint,"?message-id=").concat(e.messageId);p().post(l,n,{onUploadProgress:function(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=c.id,i((function(e){var t=e.map((function(e){return e.id===n?U(U({},e),{loadingProgress:r}):e}));return t})))},signal:t.signal}).then((function(e){var r,n;r=e.data,n=c.id,i((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var a=A([],e,!0);return a[t]=U(U({},a[t]),{id:r.fileId}),a}return e}))})).catch((function(n){var t,o;e.onFileUpdate("remove",a),m.current=U(U({},m.current),((t={})[a]=m.current[r.name]--,t)),function(e,r,n){d((function(r){return A(A([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),i((function(e){return e.filter((function(e){return e.id!==r}))}))}(r.name,c.id,null===(o=n.response)||void 0===o?void 0:o.data)}))}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),l.length>0&&y(b,e.errorMessagesContainer),t.length>0&&y(j,e.filePreviewsContainer)]})};return r})()));
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["@rustic-ai/ui-components"]=r():e["@rustic-ai/ui-components"]=r()}(global,(()=>(()=>{"use strict";var e={n:r=>{var n=r&&r.__esModule?()=>r.default:()=>r;return e.d(n,{a:n}),n},d:(r,n)=>{for(var t in n)e.o(n,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:n[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{default:()=>B});const n=require("react/jsx-runtime"),t=require("@mui/material/Box");var a=e.n(t);const i=require("@mui/material/IconButton");var o=e.n(i);const s=require("@mui/material/LinearProgress");var c=e.n(s);const l=require("@mui/material/Tooltip");var u=e.n(l);const d=require("@mui/material/Typography");var f=e.n(d);const m=require("axios");var p=e.n(m);const v=require("react"),h=require("react-dom"),x=require("uuid"),g=require("@mui/material/Card");var j=e.n(g);const b=require("@mui/material/Modal");var y=e.n(b);const w=require("@mui/material/styles");var N;function C(e){return e.name.replaceAll("_","-"),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(N||(N={}));const F=require("@mui/material/TextField");var P=e.n(F);const S=require("@mui/material/useMediaQuery");var k=e.n(S);const q=require("@mui/system/Stack");var O=e.n(q);const T=require("@mui/system/useTheme");var z=e.n(T);const _=require("pdfjs-dist"),I=function(e){var r={zoomIn:{symbol:"zoom_in",label:"Zoom in"},zoomOut:{symbol:"zoom_out",label:"Zoom out"},close:{symbol:"close",label:"Close"},previousPage:{symbol:"arrow_back",label:"Previous page"},nextPage:{symbol:"arrow_forward",label:"Next page"}},t=(r[e.action].label.replaceAll(" ","-").toLowerCase(),r[e.action]);return(0,n.jsx)(u(),{title:t.label,children:(0,n.jsx)("span",{children:(0,n.jsx)(o(),{onClick:e.onClick,className:e.className,disabled:e.isDisabled,children:(0,n.jsx)(C,{name:t.symbol})})})})};var D={pdf:function(e){var r,t=(0,v.useRef)(null),i=(0,v.useState)(1),o=i[0],s=i[1],c=(0,v.useState)(1),l=c[0],u=c[1],d=(0,v.useState)(1),m=d[0],p=d[1],h=(0,v.useState)(!1),x=h[0],g=h[1],b=(0,v.useState)(),y=b[0],w=b[1],N=z()(),C=k()(N.breakpoints.down("sm")),F=k()(N.breakpoints.between("sm","md"));if(r=e.url,!/\/[^/]+\.pdf$/.test(r))return(0,n.jsx)(j(),{variant:"outlined",className:"rustic-pdf-error",children:(0,n.jsx)(f(),{variant:"body2",children:"The provided URL does not point to a PDF file."})});var S=(0,v.useState)((function(){return C?.5:F?1:1.5})),q=S[0],T=S[1];return(0,v.useEffect)((function(){_.GlobalWorkerOptions.workerSrc||(_.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(_.version,"/pdf.worker.mjs")),_.getDocument({url:"".concat(e.url)}).promise.then((function(e){u(e.numPages),function(e){e.getPage(o).then((function(e){var r=e.getViewport({scale:q}),n=t.current;if(n){var a=n.getContext("2d");if(a){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 o={canvasContext:a,viewport:r,transform:[i,0,0,i,0,0]};y&&y.cancel();var s=e.render(o);w(s),s.promise.then((function(){w(void 0)})).catch((function(e){console.error(e)}))}}}))}(e)})).catch((function(){g(!0)}))}),[e.url,o,q]),x?(0,n.jsx)(j(),{variant:"outlined",className:"rustic-pdf-error",children:(0,n.jsx)(f(),{variant:"body2",children:"Failed to load the PDF file."})}):(0,n.jsxs)(j(),{variant:"outlined",className:"rustic-pdf-viewer",children:[(0,n.jsxs)(a(),{className:"rustic-pdf-viewer-header",children:[(0,n.jsx)(I,{action:"zoomOut",onClick:function(){T((function(e){return Math.max(e-.2,.2)}))}}),(0,n.jsx)(I,{action:"zoomIn",onClick:function(){T((function(e){return e+.2}))}})]}),(0,n.jsx)(a(),{className:"rustic-pdf-viewer-body",children:(0,n.jsx)(a(),{className:"rustic-pdf-viewer-body-inner",children:(0,n.jsx)("canvas",{ref:t})})}),(0,n.jsxs)(O(),{direction:"row",justifyContent:"center",alignItems:"center",gap:1,children:[(0,n.jsx)(I,{action:"previousPage",onClick:function(){o>1&&(s(o-1),p(o-1))},isDisabled:1===o}),(0,n.jsx)(f(),{variant:"body1",className:"rustic-page-indicator",children:"Page"}),(0,n.jsx)(P(),{type:"number",value:m,onChange:function(e){var r=parseInt(e.target.value);p(r),!isNaN(r)&&r>=1&&r<=l&&s(r)},size:"small",className:"rustic-pdf-page-input"}),(0,n.jsxs)(f(),{variant:"body1",className:"rustic-page-indicator",children:["of ",l]}),(0,n.jsx)(I,{action:"nextPage",onClick:function(){o<l&&(s(o+1),p(o+1))},isDisabled:o===l})]})]})}};function M(e){var r=(0,w.useTheme)(),t=(0,v.useState)(!1),a=t[0],i=t[1];function s(){i(!1)}var c,l,d=e.file.url&&(c=e.file.url.split("."))[c.length-1].toLowerCase(),m=d&&e.supportedViewers?e.supportedViewers[d]:null,p=!!m;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(j(),{className:"rustic-file-preview".concat(p?" rustic-cursor-pointer":""),variant:"outlined",sx:{boxShadow:r.shadows[1]},onClick:function(){i(!0)},children:[(0,n.jsx)(f(),{variant:"subtitle2",children:(l=e.file.name,15,l.length<=15?l:l.substring(0,12)+"...")}),(0,n.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:e.children})]}),p&&(0,n.jsx)(y(),{open:a,onClose:s,className:"rustic-file-preview-modal",children:(0,n.jsxs)("div",{className:"rustic-modal-content",children:[(0,n.jsx)(u(),{title:"Close",children:(0,n.jsx)(o(),{onClick:s,className:"rustic-close-button",children:(0,n.jsx)(C,{name:"close"})})}),e.file.url&&(0,n.jsx)(m,{url:e.file.url})]})})]})}M.defaultProps={supportedViewers:D};var U=function(){return U=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},U.apply(this,arguments)},A=function(e,r,n){if(n||2===arguments.length)for(var t,a=0,i=r.length;a<i;a++)!t&&a in r||(t||(t=Array.prototype.slice.call(r,0,a)),t[a]=r[a]);return e.concat(t||Array.prototype.slice.call(r))};function E(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 B=function(e){var r=(0,v.useState)([]),t=r[0],i=r[1],s=(0,v.useState)([]),l=s[0],d=s[1],m=(0,v.useRef)({}),g=(0,x.v4)();(0,v.useEffect)((function(){i([]),d([]),m.current={}}),[e.messageId]);var j=(0,n.jsx)(a(),{className:"rustic-files rustic-padding-16",children:t.map((function(r,t){return(0,n.jsx)(M,{file:{name:r.name},children:(0,n.jsxs)(a(),{className:"rustic-flex-center",children:[r.loadingProgress<100&&(0,n.jsx)(c(),{variant:"determinate",color:"secondary",value:r.loadingProgress,className:"rustic-upload-progress"}),(0,n.jsx)(u(),{title:"Delete",children:(0,n.jsx)(o(),{color:"primary",onClick:function(){return function(r,n){var t,a;d([]);var o=r.name;if(m.current=U(U({},m.current),((t={})[o]=m.current[o]--,t)),e.onFileUpdate("remove",o),100===r.loadingProgress){var s="".concat(e.deleteFileEndpoint,"?message-id=").concat(e.messageId,"&file-id=").concat(r.id);p().delete(s).then((function(){return i((function(e){return e.filter((function(e,r){return r!==n}))}))})).catch((function(){return e.onFileUpdate("add",o),d((function(e){return A(A([],e,!0),["Failed to delete ".concat(o,". Please try again.")],!1)}))}))}else r.abortController.abort(),i((function(e){return e.filter((function(e,r){return r!==n}))})),m.current=U(U({},m.current),((a={})[o]=m.current[o]++,a))}(r,t)},className:"rustic-delete-button","aria-label":"cancel file upload",children:(0,n.jsx)("span",{className:"material-symbols-rounded",children:"cancel"})})})]})},t)}))}),b=(0,n.jsx)(a(),{children:l.map((function(e,r){return(0,n.jsx)(f(),{variant:"caption",color:"error",className:"rustic-error-message",children:e},r)}))});function y(e,r){return r?(0,h.createPortal)(e,r):e}return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(a(),{className:"rustic-uploader",children:[(0,n.jsx)("label",{htmlFor:g,children:(0,n.jsx)(u(),{title:"Upload",children:(0,n.jsx)(o(),{component:"span","aria-label":"Upload file",color:"primary",children:(0,n.jsx)("span",{className:"material-symbols-rounded",children:"upload_2"})})})}),(0,n.jsx)("input",{type:"file",id:g,onChange:function(r){d([]);var n=r.target.files&&Array.from(r.target.files),a=t.length+(n?n.length:0);e.maxFileCount&&a>e.maxFileCount&&d((function(r){return A(A([],r,!0),["You can only upload ".concat(e.maxFileCount," files.")],!1)}));var o=n&&function(e,r,n){return n?r<=n?e:e.slice(0,n-r):e}(n,a,e.maxFileCount);o&&o.forEach((function(r){!function(r){var n;e.maxFileSize&&r.size>e.maxFileSize?(n=r.name,d((function(r){return A(A([],r,!0),["Failed to upload ".concat(n,". You cannot upload files larger than ").concat(e.maxFileSize&&E(e.maxFileSize),".")],!1)}))):function(r){var n=new FormData,t=new AbortController,a=function(e){var r,n,t=e.name,a=m.current[t];if(a){var i=a+1,o=t.lastIndexOf("."),s=t.substring(0,o),c=t.substring(o);t="".concat(s,"(").concat(a,")").concat(c),m.current=U(U({},m.current),((r={})[e.name]=i,r))}else m.current=U(U({},m.current),((n={})[e.name]=1,n));return t}(r),o=new File([r],a,{type:r.type});n.append("file",o);var s=(0,x.v4)(),c={name:a,loadingProgress:0,abortController:t,id:s};i((function(e){return A(A([],e,!0),[c],!1)})),e.onFileUpdate("add",a);var l="".concat(e.uploadFileEndpoint,"?message-id=").concat(e.messageId);p().post(l,n,{onUploadProgress:function(e){var r,n;e.total&&(r=e.loaded/e.total*100,n=c.id,i((function(e){var t=e.map((function(e){return e.id===n?U(U({},e),{loadingProgress:r}):e}));return t})))},signal:t.signal}).then((function(e){var r,n;r=e.data,n=c.id,i((function(e){var t=e.findIndex((function(e){return e.id===n}));if(-1!==t){var a=A([],e,!0);return a[t]=U(U({},a[t]),{id:r.fileId}),a}return e}))})).catch((function(n){var t,o;e.onFileUpdate("remove",a),m.current=U(U({},m.current),((t={})[a]=m.current[r.name]--,t)),function(e,r,n){d((function(r){return A(A([],r,!0),["Failed to upload ".concat(e,". ").concat((null==n?void 0:n.message)||"")],!1)})),i((function(e){return e.filter((function(e){return e.id!==r}))}))}(r.name,c.id,null===(o=n.response)||void 0===o?void 0:o.data)}))}(r)}(r)})),r.target.value=""},multiple:!0,accept:e.acceptedFileTypes})]}),l.length>0&&y(b,e.errorMessagesContainer),t.length>0&&y(j,e.filePreviewsContainer)]})};return r})()));
|
|
@@ -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})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>F});const r=require("react/jsx-runtime"),n=require("@mui/material"),a=require("@mui/material/Alert");var i=e.n(a);const s=require("@mui/material/CircularProgress");var o=e.n(s);const l=require("@mui/material/Typography");var c=e.n(l);const u=require("@mui/system"),m=require("react"),d=require("@mui/material/Box");var f=e.n(d);const p=require("@mui/material/Button");var x=e.n(p);const v=require("@mui/material/LinearProgress");var b=e.n(v);const y=require("@mui/material/Slider");var j=e.n(y);const h=require("@mui/material/Tooltip");var E,N=e.n(h);function g(e){var t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=Math.floor(e%60),a=t>0?"".concat(t,":"):"",i="".concat(t>0?r.toString().padStart(2,"0"):r),s=n.toString().padStart(2,"0");return"".concat(a).concat(i,":").concat(s)}function T(e){return e.name.replaceAll("_","-"),(0,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>F});const r=require("react/jsx-runtime"),n=require("@mui/material"),a=require("@mui/material/Alert");var i=e.n(a);const s=require("@mui/material/CircularProgress");var o=e.n(s);const l=require("@mui/material/Typography");var c=e.n(l);const u=require("@mui/system"),m=require("react"),d=require("@mui/material/Box");var f=e.n(d);const p=require("@mui/material/Button");var x=e.n(p);const v=require("@mui/material/LinearProgress");var b=e.n(v);const y=require("@mui/material/Slider");var j=e.n(y);const h=require("@mui/material/Tooltip");var E,N=e.n(h);function g(e){var t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=Math.floor(e%60),a=t>0?"".concat(t,":"):"",i="".concat(t>0?r.toString().padStart(2,"0"):r),s=n.toString().padStart(2,"0");return"".concat(a).concat(i,":").concat(s)}function T(e){return e.name.replaceAll("_","-"),(0,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(E||(E={}));const S=require("@mui/material/IconButton");var _=e.n(S);function k(e){var t,n={play:{symbol:"play_circle",label:"Play"},pause:{symbol:"pause_circle",label:"Pause"},forward:{symbol:"forward_10",label:"Forward ten seconds"},replay:{symbol:"replay_10",label:"Replay ten seconds"},volumeUp:{symbol:"volume_up",label:"Mute"},volumeOff:{symbol:"volume_off",label:"Unmute"},miniPlayer:{symbol:"picture_in_picture",label:"Mini player"},miniPlayerExit:{symbol:"picture_in_picture_off",label:"Exit mini player"},fullscreen:{symbol:"fullscreen",label:"Fullscreen"},fullscreenExit:{symbol:"fullscreen_exit",label:"Exit fullscreen"},captionsOn:{symbol:"closed_caption",label:"Show captions"},captionsOff:{symbol:"closed_caption_disabled",label:"Hide captions"}};return n[e.action].label.replaceAll(" ","-").toLowerCase(),(0,r.jsx)(N(),{title:n[e.action].label,PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,r.jsx)(_(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,r.jsx)(T,{name:n[e.action].symbol,className:"rustic-icon-large"})})})}function P(e){var t="dark"===(0,n.useTheme)().palette.mode,a=g(e.mediaElement.currentTime);return(0,r.jsxs)(f(),{className:"rustic-progress",children:[function(){for(var n=e.mediaElement.buffered,a=0,i=n.length-1;i>=0;--i){var s=n.start(i),o=n.end(i);if(s<e.mediaElement.currentTime){a=o;break}}var l=a/e.mediaElement.duration*100;return(0,r.jsx)(b(),{className:"rustic-progress-buffered",variant:"determinate",value:l,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:t?"secondary.light":"action.selected"}}})}(),(0,r.jsx)(j(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(a),max:e.mediaElement.duration,value:e.mediaElement.currentTime,onChange:function(t,r){e.mediaElement.currentTime=r},valueLabelDisplay:"auto",valueLabelFormat:function(e){return g(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function B(e){var t=(0,m.useState)(e.mediaElement.volume),n=t[0],a=t[1],i=(0,m.useState)(e.mediaElement.volume),s=i[0],o=i[1],l=e.mediaElement.muted?"volumeOff":"volumeUp";return(0,r.jsxs)(f(),{className:"rustic-volume-settings",children:[(0,r.jsx)(k,{onClick:function(){e.mediaElement.muted=!e.mediaElement.muted,e.mediaElement.muted?(o(e.mediaElement.volume),a(0)):a(s)},className:"rustic-mute-button",action:l}),(0,r.jsx)(j(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(100*n,"%"),value:n,onChange:function(t,r){var n=r;e.mediaElement.muted=0===n,e.mediaElement.volume=n,a(e.mediaElement.volume)}})]})}function C(e){var t=e.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",n="".concat(e.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,r.jsx)(x(),{className:"rustic-transcript-toggle",onClick:e.setIsTranscriptVisible,endIcon:(0,r.jsx)(T,{name:t}),children:(0,r.jsx)(c(),{variant:"overline",children:n})})}function w(e){var t=(0,m.useState)(!e.mediaElement.paused),n=t[0],a=t[1],i=n?"pause":"play";return e.mediaElement.onended=function(){a(!1)},e.mediaElement.onpause=function(){a(!1)},e.mediaElement.onplay=function(){a(!0)},(0,r.jsx)(k,{onClick:function(){n?e.mediaElement.pause():e.mediaElement.play().catch((function(t){e.onError("Failed to play the media. Error: ".concat(t.message))}))},action:i,className:"rustic-pause-play-icon"})}function O(e){var t,n=(0,m.useState)(e.mediaElement.playbackRate),a=n[0],i=n[1];return(0,r.jsx)(N(),{title:"Playback rate",PopperProps:{container:null!==(t=document.fullscreenElement)&&void 0!==t?t:document.body},children:(0,r.jsx)(x(),{onClick:function(){var t=1;e.mediaElement.playbackRate<2&&(t=e.mediaElement.playbackRate+.5),e.mediaElement.playbackRate=t,i(t)},className:"rustic-playback-rate-button",children:(0,r.jsxs)(c(),{variant:"body1",children:[a,"X"]})})})}function q(e){var t="replay"===e.movement,n=t?function(){e.mediaElement.currentTime-=10}:function(){e.mediaElement.currentTime+=10},a=t?"replay":"forward";return(0,r.jsx)(k,{onClick:n,action:a})}function M(e){var t=g(e.elapsedTimeInSeconds),n=g(e.durationTimeInSeconds),a="".concat(t," / ").concat(n);return"wide"===e.style?(0,r.jsxs)(f(),{className:"rustic-time-container",children:[(0,r.jsx)(c(),{variant:"overline",children:t}),(0,r.jsx)(c(),{variant:"overline",children:n})]}):(0,r.jsx)(c(),{variant:"overline",className:"rustic-time-display",children:a})}M.defaultProps={style:"condensed"};const I=require("@mui/material/Divider");var L=e.n(I);function R(e){var t=!!document.fullscreenElement;return(0,r.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!t&&(0,r.jsx)(L(),{orientation:"vertical",flexItem:!0}),(0,r.jsx)(c(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}const F=function(e){var t=(0,m.useState)(!1),a=t[0],s=t[1],l=(0,m.useState)(!1),d=l[0],f=l[1],p=(0,m.useState)(!0),x=p[0],v=p[1],b=(0,m.useState)(0),y=b[0],j=b[1],h=(0,m.useState)(""),E=h[0],N=h[1],g=(0,m.useState)(""),T=g[0],S=g[1],_=(0,n.useTheme)(),I=(0,m.useRef)(null),L=(0,n.useMediaQuery)(_.breakpoints.down("md"));function F(){return(0,r.jsx)(c(),{variant:"h6",className:"rustic-sound-title",children:e.title})}function V(){if(e.captions&&e.captions.length>0){var t=d?"captionsOff":"captionsOn";return(0,r.jsx)(k,{action:t,onClick:function(){return f(!d)}})}}function H(){if(I.current)return(0,r.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,r.jsx)(q,{mediaElement:I.current,movement:"replay"}),(0,r.jsx)(w,{mediaElement:I.current,onError:S}),(0,r.jsx)(q,{mediaElement:I.current,movement:"forward"})]})}function A(){if(e.transcript&&a)return(0,r.jsx)(R,{transcript:e.transcript})}function U(){if(e.transcript)return(0,r.jsx)(C,{isTranscriptVisible:a,setIsTranscriptVisible:function(){return s(!a)}})}function D(){return(0,r.jsx)("video",{src:e.src,ref:I,className:d?"rustic-has-captions":"",children:d&&(0,r.jsx)("track",{src:e.captions,kind:"captions",default:!0})})}(0,m.useEffect)((function(){var e,t,r,n;function a(e){N(e)}null===(e=I.current)||void 0===e||e.addEventListener("timeupdate",(function(){I.current&&j(I.current.currentTime)})),null===(t=I.current)||void 0===t||t.addEventListener("canplay",(function(){N(""),v(!1)})),null===(r=I.current)||void 0===r||r.addEventListener("error",(function(){return a("Failed to load the audio.")})),null===(n=I.current)||void 0===n||n.addEventListener("stalled",(function(){return a("Failed to fetch audio data, but trying.")}))}),[]);var z=L?function(){if(I.current)return(0,r.jsxs)(u.Box,{className:"rustic-sound-controls",children:[(0,r.jsx)(M,{elapsedTimeInSeconds:y,durationTimeInSeconds:I.current.duration,style:"wide"}),(0,r.jsx)(P,{mediaElement:I.current}),F(),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls",children:[(0,r.jsx)(u.Box,{className:"rustic-sound-bottom-controls-left",children:H()}),(0,r.jsx)(B,{mediaElement:I.current}),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls-right",children:[U(),(0,r.jsxs)(u.Box,{children:[V(),(0,r.jsx)(O,{mediaElement:I.current})]})]})]}),A()]})}:function(){if(I.current)return(0,r.jsxs)(r.Fragment,{children:[F(),(0,r.jsxs)(u.Box,{className:"rustic-sound-controls",children:[(0,r.jsx)(P,{mediaElement:I.current}),(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-sound-bottom-controls-left",children:[H(),V(),(0,r.jsx)(O,{mediaElement:I.current}),(0,r.jsx)(B,{mediaElement:I.current}),(0,r.jsx)(M,{elapsedTimeInSeconds:y,durationTimeInSeconds:I.current.duration,style:"condensed"})]}),(0,r.jsx)(u.Box,{className:"rustic-sound-bottom-controls-right",children:U()})]}),A()]})]})};return E.length>0?(0,r.jsx)(i(),{severity:"error",children:E}):x?(0,r.jsxs)(u.Box,{className:"rustic-sound",children:[D(),(0,r.jsx)(o(),{})]}):(0,r.jsxs)(u.Box,{className:"rustic-sound",children:[D(),z(),T.length>0&&(0,r.jsx)(i(),{severity:"error",className:"rustic-control-error",onClose:function(){return S("")},children:T})]})};return t})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["@rustic-ai/ui-components"]=n():e["@rustic-ai/ui-components"]=n()}(global,(()=>(()=>{"use strict";var e={n:n=>{var r=n&&n.__esModule?()=>n.default:()=>n;return e.d(r,{a:r}),r},d:(n,r)=>{for(var t in r)e.o(r,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:r[t]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{default:()=>H});const r=require("react/jsx-runtime"),t=require("@mui/material"),i=require("@mui/material/Alert");var a=e.n(i);const o=require("@mui/material/CircularProgress");var c=e.n(o);const l=require("@mui/material/Typography");var s=e.n(l);const u=require("@mui/system"),m=require("react"),d=require("@mui/material/Box");var f=e.n(d);const p=require("@mui/material/Button");var v=e.n(p);const x=require("@mui/material/LinearProgress");var E=e.n(x);const b=require("@mui/material/Slider");var y=e.n(b);const j=require("@mui/material/Tooltip");var h,g=e.n(j);function N(e){var n=Math.floor(e/3600),r=Math.floor(e%3600/60),t=Math.floor(e%60),i=n>0?"".concat(n,":"):"",a="".concat(n>0?r.toString().padStart(2,"0"):r),o=t.toString().padStart(2,"0");return"".concat(i).concat(a,":").concat(o)}function S(e){return e.name.replaceAll("_","-"),(0,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}require("pluralize"),function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(h||(h={}));const T=require("@mui/material/IconButton");var k=e.n(T);function _(e){var n,t={play:{symbol:"play_circle",label:"Play"},pause:{symbol:"pause_circle",label:"Pause"},forward:{symbol:"forward_10",label:"Forward ten seconds"},replay:{symbol:"replay_10",label:"Replay ten seconds"},volumeUp:{symbol:"volume_up",label:"Mute"},volumeOff:{symbol:"volume_off",label:"Unmute"},miniPlayer:{symbol:"picture_in_picture",label:"Mini player"},miniPlayerExit:{symbol:"picture_in_picture_off",label:"Exit mini player"},fullscreen:{symbol:"fullscreen",label:"Fullscreen"},fullscreenExit:{symbol:"fullscreen_exit",label:"Exit fullscreen"},captionsOn:{symbol:"closed_caption",label:"Show captions"},captionsOff:{symbol:"closed_caption_disabled",label:"Hide captions"}};return t[e.action].label.replaceAll(" ","-").toLowerCase(),(0,r.jsx)(g(),{title:t[e.action].label,PopperProps:{container:null!==(n=document.fullscreenElement)&&void 0!==n?n:document.body},children:(0,r.jsx)(k(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,r.jsx)(S,{name:t[e.action].symbol,className:"rustic-icon-large"})})})}function P(e){var n="dark"===(0,t.useTheme)().palette.mode,i=N(e.mediaElement.currentTime);return(0,r.jsxs)(f(),{className:"rustic-progress",children:[function(){for(var t=e.mediaElement.buffered,i=0,a=t.length-1;a>=0;--a){var o=t.start(a),c=t.end(a);if(o<e.mediaElement.currentTime){i=c;break}}var l=i/e.mediaElement.duration*100;return(0,r.jsx)(E(),{className:"rustic-progress-buffered",variant:"determinate",value:l,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:n?"secondary.light":"action.selected"}}})}(),(0,r.jsx)(y(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(i),max:e.mediaElement.duration,value:e.mediaElement.currentTime,onChange:function(n,r){e.mediaElement.currentTime=r},valueLabelDisplay:"auto",valueLabelFormat:function(e){return N(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function C(e){var n=(0,m.useState)(e.mediaElement.volume),t=n[0],i=n[1],a=(0,m.useState)(e.mediaElement.volume),o=a[0],c=a[1],l=e.mediaElement.muted?"volumeOff":"volumeUp";return(0,r.jsxs)(f(),{className:"rustic-volume-settings",children:[(0,r.jsx)(_,{onClick:function(){e.mediaElement.muted=!e.mediaElement.muted,e.mediaElement.muted?(c(e.mediaElement.volume),i(0)):i(o)},className:"rustic-mute-button",action:l}),(0,r.jsx)(y(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(100*t,"%"),value:t,onChange:function(n,r){var t=r;e.mediaElement.muted=0===t,e.mediaElement.volume=t,i(e.mediaElement.volume)}})]})}function B(e){var n=e.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",t="".concat(e.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,r.jsx)(v(),{className:"rustic-transcript-toggle",onClick:e.setIsTranscriptVisible,endIcon:(0,r.jsx)(S,{name:n}),children:(0,r.jsx)(s(),{variant:"overline",children:t})})}function q(e){var n=(0,m.useState)(!e.mediaElement.paused),t=n[0],i=n[1],a=t?"pause":"play";return e.mediaElement.onended=function(){i(!1)},e.mediaElement.onpause=function(){i(!1)},e.mediaElement.onplay=function(){i(!0)},(0,r.jsx)(_,{onClick:function(){t?e.mediaElement.pause():e.mediaElement.play().catch((function(n){e.onError("Failed to play the media. Error: ".concat(n.message))}))},action:a,className:"rustic-pause-play-icon"})}function w(e){var n,t=(0,m.useState)(e.mediaElement.playbackRate),i=t[0],a=t[1];return(0,r.jsx)(g(),{title:"Playback rate",PopperProps:{container:null!==(n=document.fullscreenElement)&&void 0!==n?n:document.body},children:(0,r.jsx)(v(),{onClick:function(){var n=1;e.mediaElement.playbackRate<2&&(n=e.mediaElement.playbackRate+.5),e.mediaElement.playbackRate=n,a(n)},className:"rustic-playback-rate-button",children:(0,r.jsxs)(s(),{variant:"body1",children:[i,"X"]})})})}function F(e){var n="replay"===e.movement,t=n?function(){e.mediaElement.currentTime-=10}:function(){e.mediaElement.currentTime+=10},i=n?"replay":"forward";return(0,r.jsx)(_,{onClick:t,action:i})}function O(e){var n=(0,m.useState)(!!document.pictureInPictureElement),t=n[0],i=n[1],a=e.mediaElement,o=t?"miniPlayerExit":"miniPlayer";return a.onleavepictureinpicture=function(){i(!1)},(0,r.jsx)(_,{onClick:function(){t?document.exitPictureInPicture().then((function(){i(!1)})).catch((function(n){e.onError("Failed to exit mini player. Error: ".concat(n.message))})):a.requestPictureInPicture().then((function(){i(!0)})).catch((function(n){e.onError("Failed to enter mini player. Error: ".concat(n.message))}))},action:o})}function I(e){var n=(0,m.useState)(!!document.fullscreenElement),t=n[0],i=n[1],a=e.element,o=t?"fullscreenExit":"fullscreen";return a.onfullscreenchange=function(){i(!!document.fullscreenElement)},(0,r.jsx)(_,{onClick:function(){t?document.exitFullscreen().then((function(){i(!1)})).catch((function(n){e.onError("Failed to exit fullscreen mode. Error: ".concat(n.message))})):a.requestFullscreen().then((function(){i(!0)})).catch((function(n){e.onError("Failed to enter fullscreen mode. Error: ".concat(n.message))}))},action:o})}function L(e){var n=N(e.elapsedTimeInSeconds),t=N(e.durationTimeInSeconds),i="".concat(n," / ").concat(t);return"wide"===e.style?(0,r.jsxs)(f(),{className:"rustic-time-container",children:[(0,r.jsx)(s(),{variant:"overline",children:n}),(0,r.jsx)(s(),{variant:"overline",children:t})]}):(0,r.jsx)(s(),{variant:"overline",className:"rustic-time-display",children:i})}L.defaultProps={style:"condensed"};const M=require("@mui/material/Divider");var R=e.n(M);function V(e){var n=!!document.fullscreenElement;return(0,r.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!n&&(0,r.jsx)(R(),{orientation:"vertical",flexItem:!0}),(0,r.jsx)(s(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}const H=function(e){var n=(0,m.useState)(!1),i=n[0],o=n[1],l=(0,m.useState)(!1),d=l[0],f=l[1],p=(0,m.useState)(!0),v=p[0],x=p[1],E=(0,m.useState)(!!document.fullscreenElement),b=E[0],y=E[1],j=(0,m.useState)(!1),h=j[0],g=j[1],N=(0,m.useState)(""),S=N[0],T=N[1],k=(0,m.useState)(""),M=k[0],R=k[1],H=(0,m.useState)(0),A=H[0],U=H[1],D=(0,m.useRef)(null),z=(0,m.useRef)(null),Q=(0,t.useTheme)(),X=(0,t.useMediaQuery)(Q.breakpoints.down("md"));(0,m.useEffect)((function(){var e,n,r,t,i,a,o,c;function l(e){R(e),x(!1)}function s(){clearTimeout(c),c=setTimeout((function(){return g(!1)}),3e3)}null===(e=z.current)||void 0===e||e.addEventListener("timeupdate",(function(){z.current&&U(z.current.currentTime)})),null===(n=z.current)||void 0===n||n.addEventListener("canplay",(function(){R(""),x(!1)})),null===(r=z.current)||void 0===r||r.addEventListener("error",(function(){return l("Failed to load the video.")})),null===(t=z.current)||void 0===t||t.addEventListener("stalled",(function(){return l("Failed to fetch video data, but trying.")})),document.addEventListener("fullscreenchange",(function(){y(!!document.fullscreenElement)})),null===(i=D.current)||void 0===i||i.addEventListener("mousemove",(function(){g(!0),s()})),null===(a=D.current)||void 0===a||a.addEventListener("mouseleave",(function(){g(!1)})),null===(o=D.current)||void 0===o||o.addEventListener("keydown",(function(){g(!0),s()}))}),[]);var G={backgroundColor:Q.palette.background.paper,opacity:h?1:0};function J(){if(e.transcript&&i)return(0,r.jsx)(V,{transcript:e.transcript})}function K(){if(e.captions&&e.captions.length>0){var n=d?"captionsOff":"captionsOn";return(0,r.jsx)(_,{action:n,onClick:function(){return f(!d)}})}}function W(){if(e.transcript)return(0,r.jsx)(B,{isTranscriptVisible:i,setIsTranscriptVisible:function(){return o(!i)}})}var Y=X?function(){return b?(0,r.jsx)(r.Fragment,{children:z.current&&D.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls",sx:G,children:[(0,r.jsxs)(u.Box,{className:"rustic-video-top-controls",children:[(0,r.jsx)(q,{mediaElement:z.current,onError:T}),(0,r.jsx)(P,{mediaElement:z.current}),(0,r.jsx)(L,{elapsedTimeInSeconds:A,durationTimeInSeconds:z.current.duration})]}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,r.jsx)(F,{mediaElement:z.current,movement:"replay"}),(0,r.jsx)(F,{mediaElement:z.current,movement:"forward"}),K(),(0,r.jsx)(w,{mediaElement:z.current})]}),W()]}),J()]})}):(0,r.jsx)(r.Fragment,{children:z.current&&D.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls-mobile-preview",children:[(0,r.jsx)(q,{mediaElement:z.current,onError:T}),(0,r.jsxs)(u.Box,{className:"rustic-video-controls-right",children:[W(),(0,r.jsx)(I,{element:D.current,onError:T})]})]})})}:function(){return(0,r.jsx)(r.Fragment,{children:z.current&&D.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls",sx:G,children:[(0,r.jsx)(P,{mediaElement:z.current}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls-left",children:[(0,r.jsx)(q,{mediaElement:z.current,onError:T}),(0,r.jsx)(F,{mediaElement:z.current,movement:"replay"}),(0,r.jsx)(F,{mediaElement:z.current,movement:"forward"}),K(),(0,r.jsx)(w,{mediaElement:z.current}),(0,r.jsx)(C,{mediaElement:z.current}),(0,r.jsx)(L,{elapsedTimeInSeconds:A,durationTimeInSeconds:z.current.duration,style:"condensed"})]}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls-right",children:[W(),(0,r.jsx)(O,{mediaElement:z.current,onError:T}),(0,r.jsx)(I,{element:D.current,onError:T})]})]}),b&&J()]})})};return M.length>0?(0,r.jsx)(a(),{severity:"error",children:M}):(0,r.jsxs)(u.Box,{className:"rustic-video",children:[v&&(0,r.jsx)(c(),{className:"rustic-video-loading-spinner"}),(0,r.jsxs)(u.Box,{ref:D,className:"rustic-video-screen",sx:{visibility:v?"hidden":"visible"},children:[S.length>0&&(0,r.jsx)(a(),{severity:"error",className:"rustic-control-error",onClose:function(){return T("")},children:S}),(!X||b)&&function(){if(z.current&&D.current)return(0,r.jsxs)(u.Box,{className:"rustic-video-title",sx:G,children:[(0,r.jsx)(s(),{variant:"body2",children:e.title}),b&&X&&(0,r.jsxs)(u.Box,{children:[(0,r.jsx)(O,{mediaElement:z.current,onError:T}),(0,r.jsx)(I,{element:D.current,onError:T})]})]})}(),(0,r.jsx)("video",{className:"rustic-video-element",ref:z,src:e.src,poster:e.poster,children:d&&(0,r.jsx)("track",{src:e.captions,kind:"captions",default:!0})}),Y()]}),!b&&J()]})};return n})()));
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["@rustic-ai/ui-components"]=n():e["@rustic-ai/ui-components"]=n()}(global,(()=>(()=>{"use strict";var e={n:n=>{var r=n&&n.__esModule?()=>n.default:()=>n;return e.d(r,{a:r}),r},d:(n,r)=>{for(var t in r)e.o(r,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:r[t]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{default:()=>H});const r=require("react/jsx-runtime"),t=require("@mui/material"),i=require("@mui/material/Alert");var a=e.n(i);const o=require("@mui/material/CircularProgress");var c=e.n(o);const l=require("@mui/material/Typography");var s=e.n(l);const u=require("@mui/system"),m=require("react"),d=require("@mui/material/Box");var f=e.n(d);const p=require("@mui/material/Button");var v=e.n(p);const x=require("@mui/material/LinearProgress");var E=e.n(x);const b=require("@mui/material/Slider");var y=e.n(b);const j=require("@mui/material/Tooltip");var h,g=e.n(j);function N(e){var n=Math.floor(e/3600),r=Math.floor(e%3600/60),t=Math.floor(e%60),i=n>0?"".concat(n,":"):"",a="".concat(n>0?r.toString().padStart(2,"0"):r),o=t.toString().padStart(2,"0");return"".concat(i).concat(a,":").concat(o)}function S(e){return e.name.replaceAll("_","-"),(0,r.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(h||(h={}));const T=require("@mui/material/IconButton");var k=e.n(T);function _(e){var n,t={play:{symbol:"play_circle",label:"Play"},pause:{symbol:"pause_circle",label:"Pause"},forward:{symbol:"forward_10",label:"Forward ten seconds"},replay:{symbol:"replay_10",label:"Replay ten seconds"},volumeUp:{symbol:"volume_up",label:"Mute"},volumeOff:{symbol:"volume_off",label:"Unmute"},miniPlayer:{symbol:"picture_in_picture",label:"Mini player"},miniPlayerExit:{symbol:"picture_in_picture_off",label:"Exit mini player"},fullscreen:{symbol:"fullscreen",label:"Fullscreen"},fullscreenExit:{symbol:"fullscreen_exit",label:"Exit fullscreen"},captionsOn:{symbol:"closed_caption",label:"Show captions"},captionsOff:{symbol:"closed_caption_disabled",label:"Hide captions"}};return t[e.action].label.replaceAll(" ","-").toLowerCase(),(0,r.jsx)(g(),{title:t[e.action].label,PopperProps:{container:null!==(n=document.fullscreenElement)&&void 0!==n?n:document.body},children:(0,r.jsx)(k(),{onClick:e.onClick,className:e.className,color:"primary",children:(0,r.jsx)(S,{name:t[e.action].symbol,className:"rustic-icon-large"})})})}function P(e){var n="dark"===(0,t.useTheme)().palette.mode,i=N(e.mediaElement.currentTime);return(0,r.jsxs)(f(),{className:"rustic-progress",children:[function(){for(var t=e.mediaElement.buffered,i=0,a=t.length-1;a>=0;--a){var o=t.start(a),c=t.end(a);if(o<e.mediaElement.currentTime){i=c;break}}var l=i/e.mediaElement.duration*100;return(0,r.jsx)(E(),{className:"rustic-progress-buffered",variant:"determinate",value:l,sx:{backgroundColor:"action.focus","& .MuiLinearProgress-bar":{backgroundColor:n?"secondary.light":"action.selected"}}})}(),(0,r.jsx)(y(),{className:"rustic-progress-slider",size:"small","aria-label":"Time","aria-valuetext":"Current time: ".concat(i),max:e.mediaElement.duration,value:e.mediaElement.currentTime,onChange:function(n,r){e.mediaElement.currentTime=r},valueLabelDisplay:"auto",valueLabelFormat:function(e){return N(e)},color:"secondary",sx:{"& .MuiSlider-rail":{color:"action.focus"}}})]})}function C(e){var n=(0,m.useState)(e.mediaElement.volume),t=n[0],i=n[1],a=(0,m.useState)(e.mediaElement.volume),o=a[0],c=a[1],l=e.mediaElement.muted?"volumeOff":"volumeUp";return(0,r.jsxs)(f(),{className:"rustic-volume-settings",children:[(0,r.jsx)(_,{onClick:function(){e.mediaElement.muted=!e.mediaElement.muted,e.mediaElement.muted?(c(e.mediaElement.volume),i(0)):i(o)},className:"rustic-mute-button",action:l}),(0,r.jsx)(y(),{className:"rustic-volume-slider",size:"small",max:1,step:.1,"aria-label":"Volume","aria-valuetext":"Volume: ".concat(100*t,"%"),value:t,onChange:function(n,r){var t=r;e.mediaElement.muted=0===t,e.mediaElement.volume=t,i(e.mediaElement.volume)}})]})}function B(e){var n=e.isTranscriptVisible?"keyboard_arrow_up":"keyboard_arrow_down",t="".concat(e.isTranscriptVisible?"Hide":"Show"," Transcript");return(0,r.jsx)(v(),{className:"rustic-transcript-toggle",onClick:e.setIsTranscriptVisible,endIcon:(0,r.jsx)(S,{name:n}),children:(0,r.jsx)(s(),{variant:"overline",children:t})})}function w(e){var n=(0,m.useState)(!e.mediaElement.paused),t=n[0],i=n[1],a=t?"pause":"play";return e.mediaElement.onended=function(){i(!1)},e.mediaElement.onpause=function(){i(!1)},e.mediaElement.onplay=function(){i(!0)},(0,r.jsx)(_,{onClick:function(){t?e.mediaElement.pause():e.mediaElement.play().catch((function(n){e.onError("Failed to play the media. Error: ".concat(n.message))}))},action:a,className:"rustic-pause-play-icon"})}function q(e){var n,t=(0,m.useState)(e.mediaElement.playbackRate),i=t[0],a=t[1];return(0,r.jsx)(g(),{title:"Playback rate",PopperProps:{container:null!==(n=document.fullscreenElement)&&void 0!==n?n:document.body},children:(0,r.jsx)(v(),{onClick:function(){var n=1;e.mediaElement.playbackRate<2&&(n=e.mediaElement.playbackRate+.5),e.mediaElement.playbackRate=n,a(n)},className:"rustic-playback-rate-button",children:(0,r.jsxs)(s(),{variant:"body1",children:[i,"X"]})})})}function F(e){var n="replay"===e.movement,t=n?function(){e.mediaElement.currentTime-=10}:function(){e.mediaElement.currentTime+=10},i=n?"replay":"forward";return(0,r.jsx)(_,{onClick:t,action:i})}function O(e){var n=(0,m.useState)(!!document.pictureInPictureElement),t=n[0],i=n[1],a=e.mediaElement,o=t?"miniPlayerExit":"miniPlayer";return a.onleavepictureinpicture=function(){i(!1)},(0,r.jsx)(_,{onClick:function(){t?document.exitPictureInPicture().then((function(){i(!1)})).catch((function(n){e.onError("Failed to exit mini player. Error: ".concat(n.message))})):a.requestPictureInPicture().then((function(){i(!0)})).catch((function(n){e.onError("Failed to enter mini player. Error: ".concat(n.message))}))},action:o})}function I(e){var n=(0,m.useState)(!!document.fullscreenElement),t=n[0],i=n[1],a=e.element,o=t?"fullscreenExit":"fullscreen";return a.onfullscreenchange=function(){i(!!document.fullscreenElement)},(0,r.jsx)(_,{onClick:function(){t?document.exitFullscreen().then((function(){i(!1)})).catch((function(n){e.onError("Failed to exit fullscreen mode. Error: ".concat(n.message))})):a.requestFullscreen().then((function(){i(!0)})).catch((function(n){e.onError("Failed to enter fullscreen mode. Error: ".concat(n.message))}))},action:o})}function L(e){var n=N(e.elapsedTimeInSeconds),t=N(e.durationTimeInSeconds),i="".concat(n," / ").concat(t);return"wide"===e.style?(0,r.jsxs)(f(),{className:"rustic-time-container",children:[(0,r.jsx)(s(),{variant:"overline",children:n}),(0,r.jsx)(s(),{variant:"overline",children:t})]}):(0,r.jsx)(s(),{variant:"overline",className:"rustic-time-display",children:i})}L.defaultProps={style:"condensed"};const M=require("@mui/material/Divider");var R=e.n(M);function V(e){var n=!!document.fullscreenElement;return(0,r.jsxs)(u.Box,{className:"rustic-transcript-container",children:[!n&&(0,r.jsx)(R(),{orientation:"vertical",flexItem:!0}),(0,r.jsx)(s(),{className:"rustic-transcript-content",variant:"body2",children:e.transcript})]})}const H=function(e){var n=(0,m.useState)(!1),i=n[0],o=n[1],l=(0,m.useState)(!1),d=l[0],f=l[1],p=(0,m.useState)(!0),v=p[0],x=p[1],E=(0,m.useState)(!!document.fullscreenElement),b=E[0],y=E[1],j=(0,m.useState)(!1),h=j[0],g=j[1],N=(0,m.useState)(""),S=N[0],T=N[1],k=(0,m.useState)(""),M=k[0],R=k[1],H=(0,m.useState)(0),A=H[0],U=H[1],D=(0,m.useRef)(null),z=(0,m.useRef)(null),Q=(0,t.useTheme)(),X=(0,t.useMediaQuery)(Q.breakpoints.down("md"));(0,m.useEffect)((function(){var e,n,r,t,i,a,o,c;function l(e){R(e),x(!1)}function s(){clearTimeout(c),c=setTimeout((function(){return g(!1)}),3e3)}null===(e=z.current)||void 0===e||e.addEventListener("timeupdate",(function(){z.current&&U(z.current.currentTime)})),null===(n=z.current)||void 0===n||n.addEventListener("canplay",(function(){R(""),x(!1)})),null===(r=z.current)||void 0===r||r.addEventListener("error",(function(){return l("Failed to load the video.")})),null===(t=z.current)||void 0===t||t.addEventListener("stalled",(function(){return l("Failed to fetch video data, but trying.")})),document.addEventListener("fullscreenchange",(function(){y(!!document.fullscreenElement)})),null===(i=D.current)||void 0===i||i.addEventListener("mousemove",(function(){g(!0),s()})),null===(a=D.current)||void 0===a||a.addEventListener("mouseleave",(function(){g(!1)})),null===(o=D.current)||void 0===o||o.addEventListener("keydown",(function(){g(!0),s()}))}),[]);var G={backgroundColor:Q.palette.background.paper,opacity:h?1:0};function J(){if(e.transcript&&i)return(0,r.jsx)(V,{transcript:e.transcript})}function K(){if(e.captions&&e.captions.length>0){var n=d?"captionsOff":"captionsOn";return(0,r.jsx)(_,{action:n,onClick:function(){return f(!d)}})}}function W(){if(e.transcript)return(0,r.jsx)(B,{isTranscriptVisible:i,setIsTranscriptVisible:function(){return o(!i)}})}var Y=X?function(){return b?(0,r.jsx)(r.Fragment,{children:z.current&&D.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls",sx:G,children:[(0,r.jsxs)(u.Box,{className:"rustic-video-top-controls",children:[(0,r.jsx)(w,{mediaElement:z.current,onError:T}),(0,r.jsx)(P,{mediaElement:z.current}),(0,r.jsx)(L,{elapsedTimeInSeconds:A,durationTimeInSeconds:z.current.duration})]}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-time-controls",children:[(0,r.jsx)(F,{mediaElement:z.current,movement:"replay"}),(0,r.jsx)(F,{mediaElement:z.current,movement:"forward"}),K(),(0,r.jsx)(q,{mediaElement:z.current})]}),W()]}),J()]})}):(0,r.jsx)(r.Fragment,{children:z.current&&D.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls-mobile-preview",children:[(0,r.jsx)(w,{mediaElement:z.current,onError:T}),(0,r.jsxs)(u.Box,{className:"rustic-video-controls-right",children:[W(),(0,r.jsx)(I,{element:D.current,onError:T})]})]})})}:function(){return(0,r.jsx)(r.Fragment,{children:z.current&&D.current&&(0,r.jsxs)(u.Box,{className:"rustic-video-controls",sx:G,children:[(0,r.jsx)(P,{mediaElement:z.current}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls",children:[(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls-left",children:[(0,r.jsx)(w,{mediaElement:z.current,onError:T}),(0,r.jsx)(F,{mediaElement:z.current,movement:"replay"}),(0,r.jsx)(F,{mediaElement:z.current,movement:"forward"}),K(),(0,r.jsx)(q,{mediaElement:z.current}),(0,r.jsx)(C,{mediaElement:z.current}),(0,r.jsx)(L,{elapsedTimeInSeconds:A,durationTimeInSeconds:z.current.duration,style:"condensed"})]}),(0,r.jsxs)(u.Box,{className:"rustic-video-bottom-controls-right",children:[W(),(0,r.jsx)(O,{mediaElement:z.current,onError:T}),(0,r.jsx)(I,{element:D.current,onError:T})]})]}),b&&J()]})})};return M.length>0?(0,r.jsx)(a(),{severity:"error",children:M}):(0,r.jsxs)(u.Box,{className:"rustic-video",children:[v&&(0,r.jsx)(c(),{className:"rustic-video-loading-spinner"}),(0,r.jsxs)(u.Box,{ref:D,className:"rustic-video-screen",sx:{visibility:v?"hidden":"visible"},children:[S.length>0&&(0,r.jsx)(a(),{severity:"error",className:"rustic-control-error",onClose:function(){return T("")},children:S}),(!X||b)&&function(){if(z.current&&D.current)return(0,r.jsxs)(u.Box,{className:"rustic-video-title",sx:G,children:[(0,r.jsx)(s(),{variant:"body2",children:e.title}),b&&X&&(0,r.jsxs)(u.Box,{children:[(0,r.jsx)(O,{mediaElement:z.current,onError:T}),(0,r.jsx)(I,{element:D.current,onError:T})]})]})}(),(0,r.jsx)("video",{className:"rustic-video-element",ref:z,src:e.src,poster:e.poster,children:d&&(0,r.jsx)("track",{src:e.captions,kind:"captions",default:!0})}),Y()]}),!b&&J()]})};return n})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>g});const r=require("react/jsx-runtime"),a=require("@mui/material"),n=require("@mui/material/Card");var o=e.n(n);const i=require("@mui/material/Stack");var s=e.n(i);const c=require("react"),u=require("@mui/material/Typography");var m,l=e.n(u);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(m||(m={}));const d=function(e){return(0,r.jsx)(l(),{variant:"caption",color:"text.secondary",className:"rustic-timestamp",children:(t=e.timestamp,a=new Date(t),n=navigator.language,o={month:"short",day:"numeric"},i=new Date,s=a.getFullYear()!==i.getFullYear(),c=s?" at ":", ",s&&(o.year="numeric"),a.toLocaleDateString(n,o)+c+a.toLocaleTimeString(n,{hour:"numeric",minute:"2-digit",hour12:!0}))});var t,a,n,o,i,s,c},g=(0,c.forwardRef)((function(e,t){var n=(0,a.useTheme)();return(0,r.jsxs)(s(),{id:e.message.id,className:"rustic-message-canvas",ref:t,children:[(0,r.jsxs)(s(),{direction:"row",alignItems:"center",spacing:1,children:[e.getProfileComponent&&e.getProfileComponent(e.message),(0,r.jsx)(d,{timestamp:e.message.timestamp})]}),e.getActionsComponent&&e.getActionsComponent(e.message)&&(0,r.jsx)(o(),{variant:"outlined",className:"rustic-message-actions-container",sx:{boxShadow:n.shadows[1]},children:e.getActionsComponent(e.message)}),(0,r.jsx)(o(),{variant:"outlined",className:"rustic-message-container",children:e.children})]})}));return t})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@rustic-ai/ui-components"]=t():e["@rustic-ai/ui-components"]=t()}(global,(()=>(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>S});const n=require("react/jsx-runtime"),r=require("@mui/material/Chip");var o=e.n(r);const s=require("@mui/system/Box");var a=e.n(s);const i=require("react");var c=e.n(i);const u=require("@mui/material/Typography");var l=e.n(u),m=function(){return m=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},m.apply(this,arguments)};const d=function(e){var t=e.messages[0],r=e.messages.slice(1),o=e.supportedElements[t.format];return(0,n.jsx)(n.Fragment,{children:o?c().createElement(o,m(m({sender:e.sender,ws:e.ws,messageId:t.id,conversationId:t.conversationId},t.data),r.length>0&&{updatedData:r.map((function(e){return e.data}))})):(0,n.jsxs)(l(),{variant:"body2",children:["Unsupported element format: ",t.format]})})};function f(e){return e.name.replaceAll("_","-"),(0,n.jsx)("span",{className:"".concat(e.className?e.className+" ":"","material-symbols-rounded"),children:e.name})}const p=require("@mui/material"),g=require("@mui/material/Card");var v=e.n(g);const h=require("@mui/material/Stack");var y,j=e.n(h);!function(e){e[e.HOUR=0]="HOUR",e[e.MONTH_DATE=1]="MONTH_DATE"}(y||(y={}));const b=function(e){return(0,n.jsx)(l(),{variant:"caption",color:"text.secondary",className:"rustic-timestamp",children:(t=e.timestamp,r=new Date(t),o=navigator.language,s={month:"short",day:"numeric"},a=new Date,i=r.getFullYear()!==a.getFullYear(),c=i?" at ":", ",i&&(s.year="numeric"),r.toLocaleDateString(o,s)+c+r.toLocaleTimeString(o,{hour:"numeric",minute:"2-digit",hour12:!0}))});var t,r,o,s,a,i,c},w=(0,i.forwardRef)((function(e,t){var r=(0,p.useTheme)();return(0,n.jsxs)(j(),{id:e.message.id,className:"rustic-message-canvas",ref:t,children:[(0,n.jsxs)(j(),{direction:"row",alignItems:"center",spacing:1,children:[e.getProfileComponent&&e.getProfileComponent(e.message),(0,n.jsx)(b,{timestamp:e.message.timestamp})]}),e.getActionsComponent&&e.getActionsComponent(e.message)&&(0,n.jsx)(v(),{variant:"outlined",className:"rustic-message-actions-container",sx:{boxShadow:r.shadows[1]},children:e.getActionsComponent(e.message)}),(0,n.jsx)(v(),{variant:"outlined",className:"rustic-message-container",children:e.children})]})}));var x=function(){return x=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},x.apply(this,arguments)};function O(e,t){var n=t.format.includes("update")?t.threadId:t.id;if(n){var r=x({},e),o=(e[n]||[])[0];return t.format.includes("update")&&o&&o.sender.id!==t.sender.id&&(n=t.id),r[n]||(r[n]=[]),r[n]=r[n].concat(t),r}return e}function E(e){var t,r,s,c=(0,i.useRef)(null),u=(0,i.useRef)(null),l=(0,i.useRef)(),m=(0,i.useState)(!0),p=m[0],g=m[1],v=(0,i.useState)(!0),h=v[0],y=v[1],j=(0,i.useState)(!1),b=j[0],x=j[1],E=(0,i.useState)({}),S=E[0],C=E[1],T=Object.keys(S).length,N=(r=T,s=(0,i.useRef)(0),(0,i.useEffect)((function(){s.current=r})),s.current),P=2e3;function R(){y(!0),l.current&&clearTimeout(l.current),l.current=setTimeout((function(){y(!1)}),P)}function A(){var e=u.current,t=c.current;if(e&&t){var n=e.getBoundingClientRect().bottom,r=t.getBoundingClientRect().bottom;g(r-1<=n)}}function q(){if(function(){var e,t=null===(e=u.current)||void 0===e?void 0:e.querySelectorAll("video");return!t||0===t.length||Array.from(t).every((function(e){return e.readyState>=1}))}()){var e=u.current;x(!0),e&&setTimeout((function(){R(),e.scrollTop=e.scrollHeight}),0)}else setTimeout(q,1)}function D(e){C((function(t){return O(t,e)}))}return(0,i.useEffect)((function(){var e=u.current;if(A(),e)return e.addEventListener("scroll",A),window.addEventListener("resize",A),function(){e.removeEventListener("scroll",A),window.removeEventListener("resize",A)}}),[p]),(0,i.useEffect)((function(){q()}),[b]),(0,i.useEffect)((function(){p&&0!==N&&T>N&&(R(),q())}),[p,Object.keys(S).length]),(0,i.useEffect)((function(){var t,n={};null===(t=e.receivedMessages)||void 0===t||t.forEach((function(e){var t=O(n,e);n=t})),C(n)}),[null===(t=e.receivedMessages)||void 0===t?void 0:t.length]),(0,i.useEffect)((function(){e.ws.onReceive&&e.ws.onReceive(D)}),[]),(0,n.jsxs)(a(),{ref:u,className:"rustic-message-space",children:[Object.keys(S).map((function(t,r){var o=S[t],s=o[o.length-1];return(0,n.jsx)(w,{message:s,getActionsComponent:e.getActionsComponent,getProfileComponent:e.getProfileComponent,ref:r===T-1?c:null,children:(0,n.jsx)(d,{ws:e.ws,sender:e.sender,messages:o,supportedElements:e.supportedElements})},t)})),!p&&!h&&(0,n.jsx)(o(),{variant:"rusticSecondary",className:"rustic-scroll-down-button",size:"medium",onClick:q,label:(0,n.jsxs)(n.Fragment,{children:[e.scrollDownLabel,(0,n.jsx)(f,{name:"arrow_downward"})]})})]})}E.defaultProps={scrollDownLabel:"Scroll down"};const S=E;return t})()));
|