@ghchinoy/lit-audio-ui 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +134 -60
- package/dist/components/atoms/ui-audio-next-button.js +9 -13
- package/dist/components/atoms/ui-audio-play-button.js +10 -14
- package/dist/components/atoms/ui-audio-player-error.js +10 -14
- package/dist/components/atoms/ui-audio-prev-button.js +9 -13
- package/dist/components/atoms/ui-audio-progress-slider.js +16 -20
- package/dist/components/atoms/ui-audio-time-display.js +15 -19
- package/dist/components/atoms/ui-audio-volume-slider.js +17 -21
- package/dist/components/atoms/ui-speech-cancel-button.js +5 -5
- package/dist/components/atoms/ui-speech-record-button.js +5 -5
- package/dist/components/atoms/ui-timed-text.js +14 -18
- package/dist/components/atoms/ui-voice-waveform.js +15 -19
- package/dist/components/molecules/ui-live-waveform.js +33 -32
- package/dist/components/molecules/ui-mic-selector.js +14 -18
- package/dist/components/molecules/ui-playlist.js +15 -19
- package/dist/components/molecules/ui-scrolling-waveform.js +30 -29
- package/dist/components/molecules/ui-spectrum-visualizer.js +23 -25
- package/dist/components/molecules/ui-speech-preview.js +16 -20
- package/dist/components/molecules/ui-voice-button.js +25 -29
- package/dist/components/molecules/ui-voice-picker.js +21 -25
- package/dist/components/molecules/ui-voice-pill.js +5 -5
- package/dist/components/molecules/ui-waveform.js +46 -36
- package/dist/components/organisms/ui-audio-player.js +7 -11
- package/dist/components/providers/ui-audio-provider.js +17 -22
- package/dist/components/providers/ui-speech-provider.js +13 -17
- package/dist/index.js +36 -36
- package/dist/node_modules/@chenglou/pretext/dist/analysis.js +456 -0
- package/dist/node_modules/@chenglou/pretext/dist/bidi.js +62 -0
- package/dist/node_modules/@chenglou/pretext/dist/layout.js +190 -0
- package/dist/node_modules/@chenglou/pretext/dist/line-break.js +234 -0
- package/dist/node_modules/@chenglou/pretext/dist/measurement.js +106 -0
- package/dist/scream-audio-ui.umd.js +45 -42
- package/dist/src/components/molecules/ui-waveform.d.ts +7 -1
- package/dist/src/components/providers/ui-audio-provider.d.ts +2 -1
- package/dist/src/utils/audio-context.d.ts +0 -1
- package/dist/src/utils/audio-utils.d.ts +8 -0
- package/dist/standalone/scream-audio-ui.standalone.js +2626 -1655
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/audio-utils.js +27 -16
- package/package.json +7 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@material/web/icon/icon.js`),require(`lit`),require(`lit/decorators.js`),require(`@lit/context`),require(`@material/web/iconbutton/filled-icon-button.js`),require(`@material/web/progress/circular-progress.js`),require(`@material/web/iconbutton/icon-button.js`),require(`@material/web/slider/slider.js`),require(`@material/web/menu/menu.js`),require(`@material/web/menu/menu-item.js`),require(`@material/web/divider/divider.js`),require(`@material/web/button/text-button.js`),require(`@material/web/button/filled-tonal-button.js`),require(`@material/web/button/outlined-button.js`),require(`@material/web/textfield/outlined-text-field.js`),require(`three`),require(`@material/web/list/list.js`),require(`@material/web/list/list-item.js`),require(`lit/directives/class-map.js`),require(`@material/web/button/filled-button.js`)):typeof define==`function`&&define.amd?define([`exports`,`@material/web/icon/icon.js`,`lit`,`lit/decorators.js`,`@lit/context`,`@material/web/iconbutton/filled-icon-button.js`,`@material/web/progress/circular-progress.js`,`@material/web/iconbutton/icon-button.js`,`@material/web/slider/slider.js`,`@material/web/menu/menu.js`,`@material/web/menu/menu-item.js`,`@material/web/divider/divider.js`,`@material/web/button/text-button.js`,`@material/web/button/filled-tonal-button.js`,`@material/web/button/outlined-button.js`,`@material/web/textfield/outlined-text-field.js`,`three`,`@material/web/list/list.js`,`@material/web/list/list-item.js`,`lit/directives/class-map.js`,`@material/web/button/filled-button.js`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ScreamAudioUI={},e.MdIcon,e.Lit,e.LitDecorators,e.LitContext,e._material_web_iconbutton_filled_icon_button_js,e._material_web_progress_circular_progress_js,e._material_web_iconbutton_icon_button_js,e._material_web_slider_slider_js,e._material_web_menu_menu_js,e._material_web_menu_menu_item_js,e._material_web_divider_divider_js,e._material_web_button_text_button_js,e._material_web_button_filled_tonal_button_js,e.MdOutlinedButton,e._material_web_textfield_outlined_text_field_js,e.THREE,e._material_web_list_list_js,e._material_web_list_list_item_js,e.lit_directives_class_map_js,e.MdFilledButton))})(this,function(e,t,n,r,i,a,o,s,c,l,
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@material/web/icon/icon.js`),require(`lit`),require(`lit/decorators.js`),require(`@lit/context`),require(`@material/web/iconbutton/filled-icon-button.js`),require(`@material/web/progress/circular-progress.js`),require(`@material/web/iconbutton/icon-button.js`),require(`@material/web/slider/slider.js`),require(`@material/web/menu/menu.js`),require(`@material/web/menu/menu-item.js`),require(`@material/web/divider/divider.js`),require(`@material/web/button/text-button.js`),require(`@material/web/button/filled-tonal-button.js`),require(`@material/web/button/outlined-button.js`),require(`@material/web/textfield/outlined-text-field.js`),require(`three`),require(`@material/web/list/list.js`),require(`@material/web/list/list-item.js`),require(`lit/directives/class-map.js`),require(`@material/web/button/filled-button.js`)):typeof define==`function`&&define.amd?define([`exports`,`@material/web/icon/icon.js`,`lit`,`lit/decorators.js`,`@lit/context`,`@material/web/iconbutton/filled-icon-button.js`,`@material/web/progress/circular-progress.js`,`@material/web/iconbutton/icon-button.js`,`@material/web/slider/slider.js`,`@material/web/menu/menu.js`,`@material/web/menu/menu-item.js`,`@material/web/divider/divider.js`,`@material/web/button/text-button.js`,`@material/web/button/filled-tonal-button.js`,`@material/web/button/outlined-button.js`,`@material/web/textfield/outlined-text-field.js`,`three`,`@material/web/list/list.js`,`@material/web/list/list-item.js`,`lit/directives/class-map.js`,`@material/web/button/filled-button.js`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ScreamAudioUI={},e.MdIcon,e.Lit,e.LitDecorators,e.LitContext,e._material_web_iconbutton_filled_icon_button_js,e._material_web_progress_circular_progress_js,e._material_web_iconbutton_icon_button_js,e._material_web_slider_slider_js,e._material_web_menu_menu_js,e._material_web_menu_menu_item_js,e._material_web_divider_divider_js,e._material_web_button_text_button_js,e._material_web_button_filled_tonal_button_js,e.MdOutlinedButton,e._material_web_textfield_outlined_text_field_js,e.THREE,e._material_web_list_list_js,e._material_web_list_list_item_js,e.lit_directives_class_map_js,e.MdFilledButton))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var x=Object.create,S=Object.defineProperty,C=Object.getOwnPropertyDescriptor,w=Object.getOwnPropertyNames,ee=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty,te=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=w(t),a=0,o=i.length,s;a<o;a++)s=i[a],!T.call(e,s)&&s!==n&&S(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=C(t,s))||r.enumerable});return e};g=((e,t,n)=>(n=e==null?{}:x(ee(e)),te(t||!e||!e.__esModule?S(n,`default`,{value:e,enumerable:!0}):n,e)))(g);let E=(0,i.createContext)(`ui-audio-player-context`);function D(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var ne=class extends n.LitElement{static{this.styles=n.css`
|
|
2
2
|
:host {
|
|
3
3
|
display: inline-flex;
|
|
4
4
|
position: relative;
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
>
|
|
66
66
|
${t&&e&&!r?n.html`<md-circular-progress indeterminate></md-circular-progress>`:n.html`<md-icon>${r?`error`:e?`pause`:`play_arrow`}</md-icon>`}
|
|
67
67
|
</md-filled-icon-button>
|
|
68
|
-
`}_handleClick(){this.playerState&&this.playerState.togglePlay()}};
|
|
68
|
+
`}_handleClick(){this.playerState&&this.playerState.togglePlay()}};D([(0,i.consume)({context:E,subscribe:!0}),(0,r.property)({attribute:!1})],ne.prototype,`playerState`,void 0),ne=D([(0,r.customElement)(`ui-audio-play-button`)],ne);var re=class extends n.LitElement{static{this.styles=n.css`
|
|
69
69
|
:host {
|
|
70
70
|
display: inline-block;
|
|
71
71
|
}
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
>
|
|
78
78
|
<md-icon>skip_next</md-icon>
|
|
79
79
|
</md-icon-button>
|
|
80
|
-
`}};
|
|
80
|
+
`}};D([(0,i.consume)({context:E,subscribe:!0})],re.prototype,`playerState`,void 0),re=D([(0,r.customElement)(`ui-audio-next-button`)],re);var ie=class extends n.LitElement{static{this.styles=n.css`
|
|
81
81
|
:host {
|
|
82
82
|
display: inline-block;
|
|
83
83
|
}
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
>
|
|
90
90
|
<md-icon>skip_previous</md-icon>
|
|
91
91
|
</md-icon-button>
|
|
92
|
-
`}};
|
|
92
|
+
`}};D([(0,i.consume)({context:E,subscribe:!0})],ie.prototype,`playerState`,void 0),ie=D([(0,r.customElement)(`ui-audio-prev-button`)],ie);function ae(){return{fftSize:256,frequencyBinCount:128,getByteFrequencyData:e=>{let t=performance.now()/1e3;for(let n=0;n<e.length;n++){let r=Math.sin(t*2+n*.1)*50+Math.sin(t*5+n*.2)*30+100;e[n]=Math.max(0,Math.min(255,r))}}}}function oe(e,t={}){let n=new(window.AudioContext||window.webkitAudioContext),r=n.createMediaStreamSource(e),i=n.createAnalyser();return t.fftSize!==void 0&&(i.fftSize=t.fftSize),t.smoothingTimeConstant!==void 0&&(i.smoothingTimeConstant=t.smoothingTimeConstant),t.minDecibels!==void 0&&(i.minDecibels=t.minDecibels),t.maxDecibels!==void 0&&(i.maxDecibels=t.maxDecibels),r.connect(i),{analyser:i,audioContext:n,cleanup:()=>{r.disconnect(),n.state!==`closed`&&n.close()}}}function se(e,t){e.getByteFrequencyData(t);let n=[];for(let e=0;e<t.length;e++)n.push(t[e]/255);return n}function ce(e,t=.5){let n=[];for(let r=0;r<e;r++)n.push(Math.random()*t);return n}function le(e,t,n,r){if(r<=0||t<=0)return;let i=e.createLinearGradient(0,0,t,0),a=Math.min(.2,r/t);i.addColorStop(0,`rgba(0,0,0,0)`),i.addColorStop(a,`rgba(0,0,0,1)`),i.addColorStop(1-a,`rgba(0,0,0,1)`),i.addColorStop(1,`rgba(0,0,0,0)`),e.globalCompositeOperation=`destination-in`,e.fillStyle=i,e.fillRect(0,0,t,n),e.globalCompositeOperation=`source-over`}function ue(e){if(!e||isNaN(e))return`0:00`;let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.floor(e%60),i=``;return t>0&&(i+=``+t+`:`+(n<10?`0`:``)),i+=``+n+`:`+(r<10?`0`:``),i+=``+r,i}async function de(e,t=100){try{let n=await fetch(e);if(!n.ok)throw Error(`Fetch failed: ${n.statusText}`);let r=await n.arrayBuffer(),i=new(window.AudioContext||window.webkitAudioContext),a=(await i.decodeAudioData(r)).getChannelData(0),o=Math.max(1,Math.floor(a.length/t)),s=[];for(let e=0;e<t;e++){let t=e*o,n=Math.min(t+o*2,a.length),r=0;for(let e=t;e<n;e++)r+=a[e]*a[e];let i=Math.sqrt(r/(n-t));s.push(i)}let c=Math.max(...s),l=.1;if(c>0)for(let e=0;e<s.length;e++)s[e]=s[e]/c*.9+l;else return Array(t).fill(l);return i.state!==`closed`&&i.close(),s}catch(e){return console.error(`Error computing audio peaks:`,e),Array(t).fill(.1)}}var O=class extends n.LitElement{constructor(...e){super(...e),this._isDragging=!1,this._dragValue=0,this.hoverTimestamp=!1,this._hoverX=0,this._showHover=!1,this._hoverTime=0}static{this.styles=n.css`
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
:host {
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
class="hover-tooltip ${this._showHover?`show`:``}"
|
|
154
154
|
style="left: ${this._hoverX}px;"
|
|
155
155
|
>
|
|
156
|
-
${
|
|
156
|
+
${ue(this._hoverTime)}
|
|
157
157
|
</div>
|
|
158
158
|
`:``}
|
|
159
159
|
<md-slider
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
@change="${this._handleChange}"
|
|
169
169
|
></md-slider>
|
|
170
170
|
</div>
|
|
171
|
-
`}_handleMouseMove(e){if(!this.hoverTimestamp||!this._sliderEl||!this.playerState?.duration)return;let t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left;n=Math.max(0,Math.min(n,t.width)),this._hoverX=n,this._hoverTime=n/t.width*this.playerState.duration}_handleInput(e){this._isDragging=!0,this._dragValue=e.target.value}_handleChange(e){this._dragValue=e.target.value,this.playerState&&this.playerState.seek(this._dragValue),this._isDragging=!1}};
|
|
171
|
+
`}_handleMouseMove(e){if(!this.hoverTimestamp||!this._sliderEl||!this.playerState?.duration)return;let t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left;n=Math.max(0,Math.min(n,t.width)),this._hoverX=n,this._hoverTime=n/t.width*this.playerState.duration}_handleInput(e){this._isDragging=!0,this._dragValue=e.target.value}_handleChange(e){this._dragValue=e.target.value,this.playerState&&this.playerState.seek(this._dragValue),this._isDragging=!1}};D([(0,i.consume)({context:E,subscribe:!0}),(0,r.property)({attribute:!1})],O.prototype,`playerState`,void 0),D([(0,r.property)({type:Boolean})],O.prototype,`hoverTimestamp`,void 0),D([(0,r.state)()],O.prototype,`_hoverX`,void 0),D([(0,r.state)()],O.prototype,`_showHover`,void 0),D([(0,r.state)()],O.prototype,`_hoverTime`,void 0),D([(0,r.query)(`md-slider`)],O.prototype,`_sliderEl`,void 0),O=D([(0,r.customElement)(`ui-audio-progress-slider`)],O);var k=class extends n.LitElement{constructor(...e){super(...e),this.format=`combined`,this.separator=` / `,this.compact=!1}static{this.styles=n.css`
|
|
172
172
|
:host {
|
|
173
173
|
display: inline-block;
|
|
174
174
|
font-variant-numeric: tabular-nums;
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
color: var(--md-sys-color-on-surface-variant, #444);
|
|
177
177
|
font-family: inherit;
|
|
178
178
|
}
|
|
179
|
-
`}render(){let e=this.playerState?.currentTime||0,t=this.playerState?.duration||0;if(this.format===`elapsed`)return n.html`${this._formatTime(e)}`;if(this.format===`remaining`){let r=Math.max(0,t-e);return n.html`-${this._formatTime(r)}`}else return n.html`${this._formatTime(e)}${this.separator}${t?this._formatTime(t):`--:--`}`}_formatTime(e){return
|
|
179
|
+
`}render(){let e=this.playerState?.currentTime||0,t=this.playerState?.duration||0;if(this.format===`elapsed`)return n.html`${this._formatTime(e)}`;if(this.format===`remaining`){let r=Math.max(0,t-e);return n.html`-${this._formatTime(r)}`}else return n.html`${this._formatTime(e)}${this.separator}${t?this._formatTime(t):`--:--`}`}_formatTime(e){return ue(e)}};D([(0,i.consume)({context:E,subscribe:!0}),(0,r.property)({attribute:!1})],k.prototype,`playerState`,void 0),D([(0,r.property)({type:String})],k.prototype,`format`,void 0),D([(0,r.property)({type:String})],k.prototype,`separator`,void 0),D([(0,r.property)({type:Boolean})],k.prototype,`compact`,void 0),k=D([(0,r.customElement)(`ui-audio-time-display`)],k);var fe=class extends n.LitElement{static{this.styles=n.css`
|
|
180
180
|
:host {
|
|
181
181
|
display: inline-flex;
|
|
182
182
|
align-items: center;
|
|
@@ -211,7 +211,7 @@
|
|
|
211
211
|
`}render(){let e=this.playerState?.error;return e?n.html`
|
|
212
212
|
<md-icon class="error-icon">error</md-icon>
|
|
213
213
|
<span class="error-text" title="${e}">${e}</span>
|
|
214
|
-
`:n.html``}};
|
|
214
|
+
`:n.html``}};D([(0,i.consume)({context:E,subscribe:!0}),(0,r.property)({attribute:!1})],fe.prototype,`playerState`,void 0),fe=D([(0,r.customElement)(`ui-audio-player-error`)],fe);var pe=class extends n.LitElement{static{this.styles=n.css`
|
|
215
215
|
:host {
|
|
216
216
|
display: block;
|
|
217
217
|
font-family: inherit;
|
|
@@ -265,7 +265,7 @@
|
|
|
265
265
|
part="word ${r?`word-active`:``} ${i?`word-past`:``}"
|
|
266
266
|
>${e.text}</span
|
|
267
267
|
>
|
|
268
|
-
`}};
|
|
268
|
+
`}};D([(0,i.consume)({context:E,subscribe:!0}),(0,r.property)({attribute:!1})],pe.prototype,`playerState`,void 0),pe=D([(0,r.customElement)(`ui-timed-text`)],pe);var me=class extends n.LitElement{constructor(...e){super(...e),this.variant=`inline`,this._isOpen=!1}static{this.styles=n.css`
|
|
269
269
|
:host([variant="popover"]) {
|
|
270
270
|
display: inline-block;
|
|
271
271
|
width: auto;
|
|
@@ -395,7 +395,7 @@
|
|
|
395
395
|
?disabled="${!this.playerState?.src}"
|
|
396
396
|
@input="${this._handleInput}"
|
|
397
397
|
></md-slider>
|
|
398
|
-
`}_handleInput(e){let t=e.target;this.playerState&&this.playerState.setVolume(t.value)}_toggleMute(){this.playerState&&this.playerState.toggleMute()}};
|
|
398
|
+
`}_handleInput(e){let t=e.target;this.playerState&&this.playerState.setVolume(t.value)}_toggleMute(){this.playerState&&this.playerState.toggleMute()}};D([(0,i.consume)({context:E,subscribe:!0}),(0,r.property)({attribute:!1})],me.prototype,`playerState`,void 0),D([(0,r.property)({type:String,reflect:!0})],me.prototype,`variant`,void 0),D([(0,r.property)({type:Boolean,state:!0})],me.prototype,`_isOpen`,void 0),me=D([(0,r.customElement)(`ui-audio-volume-slider`)],me);let A=(0,i.createContext)(`ui-speech-context`);var he=class extends n.LitElement{constructor(...e){super(...e),this.size=`default`}static{this.styles=n.css`
|
|
399
399
|
:host {
|
|
400
400
|
display: inline-block;
|
|
401
401
|
}
|
|
@@ -450,7 +450,7 @@
|
|
|
450
450
|
>
|
|
451
451
|
<md-icon>${i}</md-icon>
|
|
452
452
|
</md-filled-icon-button>
|
|
453
|
-
`}_handleClick(){this._context&&(this._context.state===`idle`?this._context.start():this._context.state===`recording`&&this._context.stop())}};
|
|
453
|
+
`}_handleClick(){this._context&&(this._context.state===`idle`?this._context.start():this._context.state===`recording`&&this._context.stop())}};D([(0,i.consume)({context:A,subscribe:!0})],he.prototype,`_context`,void 0),D([(0,r.property)({type:String})],he.prototype,`size`,void 0),he=D([(0,r.customElement)(`ui-speech-record-button`)],he);var ge=class extends n.LitElement{static{this.styles=n.css`
|
|
454
454
|
:host {
|
|
455
455
|
display: inline-block;
|
|
456
456
|
opacity: 0;
|
|
@@ -474,7 +474,7 @@
|
|
|
474
474
|
<md-icon-button aria-label="Cancel recording" @click=${this._handleClick}>
|
|
475
475
|
<md-icon>close</md-icon>
|
|
476
476
|
</md-icon-button>
|
|
477
|
-
`):n.html``}_handleClick(){this._context?.cancel()}};
|
|
477
|
+
`):n.html``}_handleClick(){this._context?.cancel()}};D([(0,i.consume)({context:A,subscribe:!0})],ge.prototype,`_context`,void 0),ge=D([(0,r.customElement)(`ui-speech-cancel-button`)],ge);var j=class extends n.LitElement{constructor(...e){super(...e),this.active=!1,this.processing=!1,this.barWidth=3,this.barHeight=4,this.barGap=1,this.barRadius=1.5,this.fadeEdges=!0,this.fadeWidth=24,this.sensitivity=1,this.updateRate=30,this._animationFrameId=0,this._lastUpdateTime=0,this._currentBars=[],this._processingTime=0,this._transitionProgress=0,this._lastActiveData=[]}static{this.styles=n.css`
|
|
478
478
|
:host {
|
|
479
479
|
display: block;
|
|
480
480
|
width: 100%;
|
|
@@ -497,7 +497,7 @@
|
|
|
497
497
|
<div class="container" style="height: ${this.height===void 0?`100%`:typeof this.height==`number`||!isNaN(Number(this.height))?`${this.height}px`:this.height};">
|
|
498
498
|
<canvas></canvas>
|
|
499
499
|
</div>
|
|
500
|
-
`}firstUpdated(){this._resizeObserver=new ResizeObserver(()=>{this._handleResize()}),this._resizeObserver.observe(this._container),this._themeObserver=new MutationObserver(()=>{this._renderFrame()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}),this._startAnimationLoop()}updated(e){super.updated(e),e.has(`analyserNode`)&&this.analyserNode&&(this._dataArray=new Uint8Array(this.analyserNode.frequencyBinCount)),e.has(`processing`)&&this.processing&&!this.active&&(this._processingTime=0,this._transitionProgress=0)}disconnectedCallback(){super.disconnectedCallback(),this._resizeObserver&&this._resizeObserver.disconnect(),this._themeObserver&&this._themeObserver.disconnect(),this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)}_handleResize(){if(!this._canvas||!this._container)return;let e=this._container.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._canvas.style.width=`${e.width}px`,this._canvas.style.height=`${e.height}px`;let n=this._canvas.getContext(`2d`);n&&n.scale(t,t),this._renderFrame()}_startAnimationLoop(){let e=t=>{this._updateData(t),this._renderFrame(),this._animationFrameId=requestAnimationFrame(e)};this._animationFrameId=requestAnimationFrame(e)}_updateData(e){if(!this.
|
|
500
|
+
`}firstUpdated(){this._resizeObserver=new ResizeObserver(()=>{this._handleResize()}),this._resizeObserver.observe(this._container),this._themeObserver=new MutationObserver(()=>{this._renderFrame()}),this._themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}),this._startAnimationLoop()}updated(e){super.updated(e),e.has(`analyserNode`)&&this.analyserNode&&(this._dataArray=new Uint8Array(this.analyserNode.frequencyBinCount)),e.has(`processing`)&&this.processing&&!this.active&&(this._processingTime=0,this._transitionProgress=0)}disconnectedCallback(){super.disconnectedCallback(),this._resizeObserver&&this._resizeObserver.disconnect(),this._themeObserver&&this._themeObserver.disconnect(),this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)}_handleResize(){if(!this._canvas||!this._container)return;let e=this._container.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._canvas.style.width=`${e.width}px`,this._canvas.style.height=`${e.height}px`;let n=this._canvas.getContext(`2d`);n&&n.scale(t,t),this._renderFrame()}_startAnimationLoop(){let e=t=>{this._updateData(t),this._renderFrame(),this._animationFrameId=requestAnimationFrame(e)};this._animationFrameId=requestAnimationFrame(e)}_updateData(e){if(!this._container)return;let t=this._container.getBoundingClientRect(),n=Math.floor(t.width/(this.barWidth+this.barGap));if(this.active&&this.analyserNode&&this._dataArray){if(e-this._lastUpdateTime>this.updateRate){this._lastUpdateTime=e;let t=se(this.analyserNode,this._dataArray),r=Math.floor(t.length*.05),i=Math.floor(t.length*.4),a=t.slice(r,i),o=Math.floor(n/2),s=Array(n).fill(.05),c=a.length-1;for(let e=0;e<=o;e++){let t=e/o,r=a[Math.floor(t*c)]||0;t>.8&&(r*=1-(t-.8)*5);let i=Math.max(.05,Math.min(1,r*this.sensitivity)),l=o+e,u=o-e;l<n&&(s[l]=i),u>=0&&(s[u]=i)}this._currentBars=s,this._lastActiveData=[...s]}}else if(this.processing&&!this.active){this._processingTime+=.03,this._transitionProgress=Math.min(1,this._transitionProgress+.02);let e=Array(n).fill(.05),t=Math.floor(n/2);for(let r=0;r<n;r++){let n=(r-t)/t,i=1-Math.abs(n)*.4,a=Math.sin(this._processingTime*1.5+n*3)*.25,o=Math.sin(this._processingTime*.8-n*2)*.2,s=Math.cos(this._processingTime*2+n)*.15,c=(.2+(a+o+s))*i,l=c;if(this._lastActiveData.length>0&&this._transitionProgress<1){let e=Math.min(r,this._lastActiveData.length-1);l=(this._lastActiveData[e]||0)*(1-this._transitionProgress)+c*this._transitionProgress}e[r]=Math.max(.05,Math.min(1,l))}this._currentBars=e}else if(this._currentBars.length>0){let e=!0;for(let t=0;t<this._currentBars.length;t++)this._currentBars[t]=Math.max(.05,this._currentBars[t]*.85),this._currentBars[t]>.06&&(e=!1);e&&(this._currentBars=[])}}_renderFrame(){if(!this._canvas)return;let e=this._canvas.getContext(`2d`);if(!e)return;let t=window.devicePixelRatio||1,n=this._container.getBoundingClientRect();if(n.width===0||n.height===0){this._animationFrameId=requestAnimationFrame(()=>this._renderFrame());return}let r=Math.round(n.width*t),i=Math.round(n.height*t);this._canvas.width!==r||this._canvas.height!==i?(this._canvas.width=r,this._canvas.height=i,this._canvas.style.width=`${n.width}px`,this._canvas.style.height=`${n.height}px`,e.scale(t,t)):e.clearRect(0,0,n.width,n.height);let a=getComputedStyle(this),o=this.barColor||`currentColor`;if(o.startsWith(`var(`)){let e=o.match(/var\(([^,)]+)/)?.[1].trim();if(e){let t=a.getPropertyValue(e).trim();t&&(o=t)}}(o===`currentColor`||!o)&&(o=a.getPropertyValue(`--md-sys-color-primary`).trim()||`#0066cc`);let s=this.barWidth+this.barGap,c=Math.floor(n.width/s),l=n.height/2;for(let t=0;t<c&&t<this._currentBars.length;t++){let r=this._currentBars[t]||.05,i=t*s,a=Math.max(this.barHeight,r*n.height*.8),c=l-a/2;e.fillStyle=o,e.globalAlpha=.6+r*.4,this.barRadius>0?(e.beginPath(),e.roundRect(i,c,this.barWidth,a,this.barRadius),e.fill()):e.fillRect(i,c,this.barWidth,a)}this.fadeEdges&&le(e,n.width,n.height,this.fadeWidth),e.globalAlpha=1}};D([(0,r.property)({type:Boolean})],j.prototype,`active`,void 0),D([(0,r.property)({type:Boolean})],j.prototype,`processing`,void 0),D([(0,r.property)({attribute:!1})],j.prototype,`analyserNode`,void 0),D([(0,r.property)({type:Number})],j.prototype,`barWidth`,void 0),D([(0,r.property)({type:Number})],j.prototype,`barHeight`,void 0),D([(0,r.property)({type:Number})],j.prototype,`barGap`,void 0),D([(0,r.property)({type:Number})],j.prototype,`barRadius`,void 0),D([(0,r.property)({type:String})],j.prototype,`barColor`,void 0),D([(0,r.property)({type:Boolean})],j.prototype,`fadeEdges`,void 0),D([(0,r.property)({type:Number})],j.prototype,`fadeWidth`,void 0),D([(0,r.property)()],j.prototype,`height`,void 0),D([(0,r.property)({type:Number})],j.prototype,`sensitivity`,void 0),D([(0,r.property)({type:Number})],j.prototype,`updateRate`,void 0),D([(0,r.query)(`canvas`)],j.prototype,`_canvas`,void 0),D([(0,r.query)(`.container`)],j.prototype,`_container`,void 0),j=D([(0,r.customElement)(`ui-live-waveform`)],j);var M=class extends n.LitElement{constructor(...e){super(...e),this.barWidth=2,this.barGap=1,this.barColor=`currentColor`,this.height=20}static{this.styles=n.css`
|
|
501
501
|
:host {
|
|
502
502
|
display: block;
|
|
503
503
|
width: 100%;
|
|
@@ -512,7 +512,7 @@
|
|
|
512
512
|
.barColor=${this.barColor}
|
|
513
513
|
.height=${this.height}
|
|
514
514
|
></ui-live-waveform>
|
|
515
|
-
`:n.html``}};
|
|
515
|
+
`:n.html``}};D([(0,i.consume)({context:A,subscribe:!0})],M.prototype,`_context`,void 0),D([(0,r.property)({type:Number})],M.prototype,`barWidth`,void 0),D([(0,r.property)({type:Number})],M.prototype,`barGap`,void 0),D([(0,r.property)({type:String})],M.prototype,`barColor`,void 0),D([(0,r.property)({type:Number})],M.prototype,`height`,void 0),M=D([(0,r.customElement)(`ui-voice-waveform`)],M);var N=class extends n.LitElement{constructor(...e){super(...e),this.text=``,this.duration=2,this.delay=0,this.repeat=!0,this.repeatDelay=.5,this.startOnView=!0,this.once=!1,this.spread=2,this._isInView=!1}static{this.styles=n.css`
|
|
516
516
|
:host {
|
|
517
517
|
display: inline-block;
|
|
518
518
|
font-family: inherit;
|
|
@@ -561,7 +561,7 @@
|
|
|
561
561
|
class="${e?`active`:``}"
|
|
562
562
|
style="${o}"
|
|
563
563
|
>${this.text}</span
|
|
564
|
-
>`}};
|
|
564
|
+
>`}};D([(0,r.property)({type:String})],N.prototype,`text`,void 0),D([(0,r.property)({type:Number})],N.prototype,`duration`,void 0),D([(0,r.property)({type:Number})],N.prototype,`delay`,void 0),D([(0,r.property)({type:Boolean})],N.prototype,`repeat`,void 0),D([(0,r.property)({type:Number})],N.prototype,`repeatDelay`,void 0),D([(0,r.property)({type:Boolean})],N.prototype,`startOnView`,void 0),D([(0,r.property)({type:Boolean})],N.prototype,`once`,void 0),D([(0,r.property)({type:Number})],N.prototype,`spread`,void 0),D([(0,r.property)({type:String})],N.prototype,`color`,void 0),D([(0,r.property)({type:String})],N.prototype,`shimmerColor`,void 0),D([(0,r.state)()],N.prototype,`_isInView`,void 0),N=D([(0,r.customElement)(`ui-shimmering-text`)],N);var _e=class extends n.LitElement{constructor(...e){super(...e),this.variant=`contained`,this.direction=`inbound`}static{this.styles=n.css`
|
|
565
565
|
:host {
|
|
566
566
|
display: inline-flex;
|
|
567
567
|
max-width: 85%;
|
|
@@ -621,7 +621,7 @@
|
|
|
621
621
|
<div class="bubble">
|
|
622
622
|
<slot></slot>
|
|
623
623
|
</div>
|
|
624
|
-
`}};
|
|
624
|
+
`}};D([(0,r.property)({type:String,reflect:!0})],_e.prototype,`variant`,void 0),D([(0,r.property)({type:String,reflect:!0})],_e.prototype,`direction`,void 0),_e=D([(0,r.customElement)(`ui-message-bubble`)],_e);var ve=class extends n.LitElement{constructor(...e){super(...e),this.delay=`0s`}static{this.styles=n.css`
|
|
625
625
|
:host {
|
|
626
626
|
display: inline-block;
|
|
627
627
|
}
|
|
@@ -644,7 +644,11 @@
|
|
|
644
644
|
opacity: 1;
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
|
-
`}render(){return n.html`<div class="dot" style="animation-delay: ${this.delay}"></div>`}};
|
|
647
|
+
`}render(){return n.html`<div class="dot" style="animation-delay: ${this.delay}"></div>`}};D([(0,r.property)({type:String})],ve.prototype,`delay`,void 0),ve=D([(0,r.customElement)(`ui-typing-dot`)],ve);var ye=`BN.BN.BN.BN.BN.BN.BN.BN.BN.S.B.S.WS.B.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.B.B.B.S.WS.ON.ON.ET.ET.ET.ON.ON.ON.ON.ON.ON.CS.ON.CS.ON.EN.EN.EN.EN.EN.EN.EN.EN.EN.EN.ON.ON.ON.ON.ON.ON.ON.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.ON.ON.ON.ON.ON.ON.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.ON.ON.ON.ON.BN.BN.BN.BN.BN.BN.B.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.BN.CS.ON.ET.ET.ET.ET.ON.ON.ON.ON.L.ON.ON.ON.ON.ON.ET.ET.EN.EN.ON.L.ON.ON.ON.EN.L.ON.ON.ON.ON.ON.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.ON.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.ON.L.L.L.L.L.L.L.L`.split(`.`),be=`AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.CS.AL.ON.ON.NSM.NSM.NSM.NSM.NSM.NSM.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.AL.AL.AL.AL.AL.AL.AL.AN.AN.AN.AN.AN.AN.AN.AN.AN.AN.ET.AN.AN.AL.AL.AL.NSM.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.NSM.ON.NSM.NSM.NSM.NSM.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL.AL`.split(`.`);function xe(e){return e<=255?ye[e]:1424<=e&&e<=1524?`R`:1536<=e&&e<=1791?be[e&255]:1792<=e&&e<=2220?`AL`:`L`}function Se(e){let t=e.length;if(t===0)return null;let n=Array(t),r=0;for(let i=0;i<t;i++){let t=xe(e.charCodeAt(i));(t===`R`||t===`AL`||t===`AN`)&&r++,n[i]=t}if(r===0)return null;let i=t/r<.3?0:1,a=new Int8Array(t);for(let e=0;e<t;e++)a[e]=i;let o=i&1?`R`:`L`,s=o,c=s;for(let e=0;e<t;e++)n[e]===`NSM`?n[e]=c:c=n[e];c=s;for(let e=0;e<t;e++){let t=n[e];t===`EN`?n[e]=c===`AL`?`AN`:`EN`:(t===`R`||t===`L`||t===`AL`)&&(c=t)}for(let e=0;e<t;e++)n[e]===`AL`&&(n[e]=`R`);for(let e=1;e<t-1;e++)n[e]===`ES`&&n[e-1]===`EN`&&n[e+1]===`EN`&&(n[e]=`EN`),n[e]===`CS`&&(n[e-1]===`EN`||n[e-1]===`AN`)&&n[e+1]===n[e-1]&&(n[e]=n[e-1]);for(let e=0;e<t;e++){if(n[e]!==`EN`)continue;let r;for(r=e-1;r>=0&&n[r]===`ET`;r--)n[r]=`EN`;for(r=e+1;r<t&&n[r]===`ET`;r++)n[r]=`EN`}for(let e=0;e<t;e++){let t=n[e];(t===`WS`||t===`ES`||t===`ET`||t===`CS`)&&(n[e]=`ON`)}c=s;for(let e=0;e<t;e++){let t=n[e];t===`EN`?n[e]=c===`L`?`L`:`EN`:(t===`R`||t===`L`)&&(c=t)}for(let e=0;e<t;e++){if(n[e]!==`ON`)continue;let r=e+1;for(;r<t&&n[r]===`ON`;)r++;let i=e>0?n[e-1]:s,a=r<t?n[r]:s,o=i===`L`?`L`:`R`;if(o===(a===`L`?`L`:`R`))for(let t=e;t<r;t++)n[t]=o;e=r-1}for(let e=0;e<t;e++)n[e]===`ON`&&(n[e]=o);for(let e=0;e<t;e++){let t=n[e];a[e]&1?(t===`L`||t===`AN`||t===`EN`)&&a[e]++:t===`R`?a[e]++:(t===`AN`||t===`EN`)&&(a[e]+=2)}return a}function Ce(e,t){let n=Se(e);if(n===null)return null;let r=new Int8Array(t.length);for(let e=0;e<t.length;e++)r[e]=n[t[e]];return r}var we=/[ \t\n\r\f]+/g,Te=/[\t\n\r\f]| {2,}|^ | $/;function Ee(e){let t=e??`normal`;return t===`pre-wrap`?{mode:t,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:t,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function De(e){if(!Te.test(e))return e;let t=e.replace(we,` `);return t.charCodeAt(0)===32&&(t=t.slice(1)),t.length>0&&t.charCodeAt(t.length-1)===32&&(t=t.slice(0,-1)),t}function Oe(e){return/[\r\f]/.test(e)?e.replace(/\r\n/g,`
|
|
648
|
+
`).replace(/[\r\f]/g,`
|
|
649
|
+
`):e.replace(/\r\n/g,`
|
|
650
|
+
`)}var ke=null,Ae;function je(){return ke===null&&(ke=new Intl.Segmenter(Ae,{granularity:`word`})),ke}function Me(){ke=null}var Ne=/\p{Script=Arabic}/u,Pe=/\p{M}/u,Fe=/\p{Nd}/u;function Ie(e){return Ne.test(e)}function P(e){for(let t of e){let e=t.codePointAt(0);if(e>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=183984&&e<=191471||e>=196608&&e<=201551||e>=63744&&e<=64255||e>=194560&&e<=195103||e>=12288&&e<=12351||e>=12352&&e<=12447||e>=12448&&e<=12543||e>=44032&&e<=55215||e>=65280&&e<=65519)return!0}return!1}let Le=new Set(`,...!.:.;.?.、.。.・.).〕.〉.》.」.』.】.〗.〙.〛.ー.々.〻.ゝ.ゞ.ヽ.ヾ`.split(`.`)),Re=new Set([`"`,`(`,`[`,`{`,`“`,`‘`,`«`,`‹`,`(`,`〔`,`〈`,`《`,`「`,`『`,`【`,`〖`,`〘`,`〚`]);var ze=new Set([`'`,`’`]);let Be=new Set(`.(,(!(?(:(;(،(؛(؟(।(॥(၊(။(၌(၍(၏()(](}(%("(”(’(»(›(…`.split(`(`));var Ve=new Set([`:`,`.`,`،`,`؛`]),He=new Set([`၏`]),Ue=new Set([`”`,`’`,`»`,`›`,`」`,`』`,`】`,`》`,`〉`,`〕`,`)`]);function We(e){if(qe(e))return!0;let t=!1;for(let n of e){if(Be.has(n)){t=!0;continue}if(!(t&&Pe.test(n)))return!1}return t}function Ge(e){for(let t of e)if(!Le.has(t)&&!Be.has(t))return!1;return e.length>0}function Ke(e){if(qe(e))return!0;for(let t of e)if(!Re.has(t)&&!ze.has(t)&&!Pe.test(t))return!1;return e.length>0}function qe(e){let t=!1;for(let n of e)if(!(n===`\\`||Pe.test(n))){if(Re.has(n)||Be.has(n)||ze.has(n)){t=!0;continue}return!1}return t}function Je(e){let t=Array.from(e),n=t.length;for(;n>0;){let e=t[n-1];if(Pe.test(e)){n--;continue}if(Re.has(e)||ze.has(e)){n--;continue}break}return n<=0||n===t.length?null:{head:t.slice(0,n).join(``),tail:t.slice(n).join(``)}}function Ye(e,t){if(e.length===0)return!1;for(let n of e)if(n!==t)return!1;return!0}function Xe(e){return!Ie(e)||e.length===0?!1:Ve.has(e[e.length-1])}function Ze(e){return e.length===0?!1:He.has(e[e.length-1])}function Qe(e){if(e.length<2||e[0]!==` `)return null;let t=e.slice(1);return/^\p{M}+$/u.test(t)?{space:` `,marks:t}:null}function $e(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(Ue.has(n))return!0;if(!Be.has(n))return!1}return!1}function et(e,t){if(t.preserveOrdinarySpaces||t.preserveHardBreaks){if(e===` `)return`preserved-space`;if(e===` `)return`tab`;if(t.preserveHardBreaks&&e===`
|
|
651
|
+
`)return`hard-break`}return e===` `?`space`:e===`\xA0`||e===` `||e===``||e===``?`glue`:e===``?`zero-width-break`:e===``?`soft-hyphen`:`text`}function F(e){return e.length===1?e[0]:e.join(``)}function tt(e,t,n,r){let i=[],a=null,o=[],s=n,c=!1,l=0;for(let u of e){let e=et(u,r),d=e===`text`&&t;if(a!==null&&e===a&&d===c){o.push(u),l+=u.length;continue}a!==null&&i.push({text:F(o),isWordLike:c,kind:a,start:s}),a=e,o=[u],s=n+l,c=d,l+=u.length}return a!==null&&i.push({text:F(o),isWordLike:c,kind:a,start:s}),i}function nt(e){return e===`space`||e===`preserved-space`||e===`zero-width-break`||e===`hard-break`}var rt=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function it(e,t){let n=e.texts[t];return n.startsWith(`www.`)?!0:rt.test(n)&&t+1<e.len&&e.kinds[t+1]===`text`&&e.texts[t+1]===`//`}function at(e){return e.includes(`?`)&&(e.includes(`://`)||e.startsWith(`www.`))}function ot(e){let t=e.texts.slice(),n=e.isWordLike.slice(),r=e.kinds.slice(),i=e.starts.slice();for(let i=0;i<e.len;i++){if(r[i]!==`text`||!it(e,i))continue;let a=[t[i]],o=i+1;for(;o<e.len&&!nt(r[o]);){a.push(t[o]),n[i]=!0;let e=t[o].includes(`?`);if(r[o]=`text`,t[o]=``,o++,e)break}t[i]=F(a)}let a=0;for(let e=0;e<t.length;e++){let o=t[e];o.length!==0&&(a!==e&&(t[a]=o,n[a]=n[e],r[a]=r[e],i[a]=i[e]),a++)}return t.length=a,n.length=a,r.length=a,i.length=a,{len:a,texts:t,isWordLike:n,kinds:r,starts:i}}function st(e){let t=[],n=[],r=[],i=[];for(let a=0;a<e.len;a++){let o=e.texts[a];if(t.push(o),n.push(e.isWordLike[a]),r.push(e.kinds[a]),i.push(e.starts[a]),!at(o))continue;let s=a+1;if(s>=e.len||nt(e.kinds[s]))continue;let c=[],l=e.starts[s],u=s;for(;u<e.len&&!nt(e.kinds[u]);)c.push(e.texts[u]),u++;c.length>0&&(t.push(F(c)),n.push(!0),r.push(`text`),i.push(l),a=u-1)}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}var ct=new Set([`:`,`-`,`/`,`×`,`,`,`.`,`+`,`–`,`—`]),lt=/^[A-Za-z0-9_]+[,:;]*$/,ut=/[,:;]+$/;function dt(e){for(let t of e)if(Fe.test(t))return!0;return!1}function ft(e){if(e.length===0)return!1;for(let t of e)if(!(Fe.test(t)||ct.has(t)))return!1;return!0}function pt(e){let t=[],n=[],r=[],i=[];for(let a=0;a<e.len;a++){let o=e.texts[a],s=e.kinds[a];if(s===`text`&&ft(o)&&dt(o)){let s=[o],c=a+1;for(;c<e.len&&e.kinds[c]===`text`&&ft(e.texts[c]);)s.push(e.texts[c]),c++;t.push(F(s)),n.push(!0),r.push(`text`),i.push(e.starts[a]),a=c-1;continue}t.push(o),n.push(e.isWordLike[a]),r.push(s),i.push(e.starts[a])}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function mt(e){let t=[],n=[],r=[],i=[];for(let a=0;a<e.len;a++){let o=e.texts[a],s=e.kinds[a],c=e.isWordLike[a];if(s===`text`&&c&<.test(o)){let s=[o],c=ut.test(o),l=a+1;for(;c&&l<e.len&&e.kinds[l]===`text`&&e.isWordLike[l]&<.test(e.texts[l]);){let t=e.texts[l];s.push(t),c=ut.test(t),l++}t.push(F(s)),n.push(!0),r.push(`text`),i.push(e.starts[a]),a=l-1;continue}t.push(o),n.push(c),r.push(s),i.push(e.starts[a])}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function ht(e){let t=[],n=[],r=[],i=[];for(let a=0;a<e.len;a++){let o=e.texts[a];if(e.kinds[a]===`text`&&o.includes(`-`)){let s=o.split(`-`),c=s.length>1;for(let e=0;e<s.length;e++){let t=s[e];if(!c)break;(t.length===0||!dt(t)||!ft(t))&&(c=!1)}if(c){let o=0;for(let c=0;c<s.length;c++){let l=s[c],u=c<s.length-1?`${l}-`:l;t.push(u),n.push(!0),r.push(`text`),i.push(e.starts[a]+o),o+=u.length}continue}}t.push(o),n.push(e.isWordLike[a]),r.push(e.kinds[a]),i.push(e.starts[a])}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function gt(e){let t=[],n=[],r=[],i=[],a=0;for(;a<e.len;){let o=[e.texts[a]],s=e.isWordLike[a],c=e.kinds[a],l=e.starts[a];if(c===`glue`){let u=[o[0]],d=l;for(a++;a<e.len&&e.kinds[a]===`glue`;)u.push(e.texts[a]),a++;let f=F(u);if(a<e.len&&e.kinds[a]===`text`)o[0]=f,o.push(e.texts[a]),s=e.isWordLike[a],c=`text`,l=d,a++;else{t.push(f),n.push(!1),r.push(`glue`),i.push(d);continue}}else a++;if(c===`text`)for(;a<e.len&&e.kinds[a]===`glue`;){let t=[];for(;a<e.len&&e.kinds[a]===`glue`;)t.push(e.texts[a]),a++;let n=F(t);if(a<e.len&&e.kinds[a]===`text`){o.push(n,e.texts[a]),s||=e.isWordLike[a],a++;continue}o.push(n)}t.push(F(o)),n.push(s),r.push(c),i.push(l)}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function _t(e){let t=e.texts.slice(),n=e.isWordLike.slice(),r=e.kinds.slice(),i=e.starts.slice();for(let e=0;e<t.length-1;e++){if(r[e]!==`text`||r[e+1]!==`text`||!P(t[e])||!P(t[e+1]))continue;let n=Je(t[e]);n!==null&&(t[e]=n.head,t[e+1]=n.tail+t[e+1],i[e+1]=i[e]+n.head.length)}return{len:t.length,texts:t,isWordLike:n,kinds:r,starts:i}}function vt(e,t,n){let r=je(),i=0,a=[],o=[],s=[],c=[];for(let l of r.segment(e))for(let e of tt(l.segment,l.isWordLike??!1,l.index,n)){let n=e.kind===`text`;t.carryCJKAfterClosingQuote&&n&&i>0&&s[i-1]===`text`&&P(e.text)&&P(a[i-1])&&$e(a[i-1])||n&&i>0&&s[i-1]===`text`&&Ge(e.text)&&P(a[i-1])||n&&i>0&&s[i-1]===`text`&&Ze(a[i-1])?(a[i-1]+=e.text,o[i-1]=o[i-1]||e.isWordLike):n&&i>0&&s[i-1]===`text`&&e.isWordLike&&Ie(e.text)&&Xe(a[i-1])?(a[i-1]+=e.text,o[i-1]=!0):n&&!e.isWordLike&&i>0&&s[i-1]===`text`&&e.text.length===1&&e.text!==`-`&&e.text!==`—`&&Ye(a[i-1],e.text)||n&&!e.isWordLike&&i>0&&s[i-1]===`text`&&(We(e.text)||e.text===`-`&&o[i-1])?a[i-1]+=e.text:(a[i]=e.text,o[i]=e.isWordLike,s[i]=e.kind,c[i]=e.start,i++)}for(let e=1;e<i;e++)s[e]===`text`&&!o[e]&&qe(a[e])&&s[e-1]===`text`&&(a[e-1]+=a[e],o[e-1]=o[e-1]||o[e],a[e]=``);for(let e=i-2;e>=0;e--)if(s[e]===`text`&&!o[e]&&Ke(a[e])){let t=e+1;for(;t<i&&a[t]===``;)t++;t<i&&s[t]===`text`&&(a[t]=a[e]+a[t],c[t]=c[e],a[e]=``)}let l=0;for(let e=0;e<i;e++){let t=a[e];t.length!==0&&(l!==e&&(a[l]=t,o[l]=o[e],s[l]=s[e],c[l]=c[e]),l++)}a.length=l,o.length=l,s.length=l,c.length=l;let u=_t(mt(ht(pt(st(ot(gt({len:l,texts:a,isWordLike:o,kinds:s,starts:c})))))));for(let e=0;e<u.len-1;e++){let t=Qe(u.texts[e]);t!==null&&(u.kinds[e]!==`space`&&u.kinds[e]!==`preserved-space`||u.kinds[e+1]!==`text`||!Ie(u.texts[e+1])||(u.texts[e]=t.space,u.isWordLike[e]=!1,u.kinds[e]=u.kinds[e]===`preserved-space`?`preserved-space`:`space`,u.texts[e+1]=t.marks+u.texts[e+1],u.starts[e+1]=u.starts[e]+t.space.length))}return u}function yt(e,t){if(e.len===0)return[];if(!t.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:e.len,consumedEndSegmentIndex:e.len}];let n=[],r=0;for(let t=0;t<e.len;t++)e.kinds[t]===`hard-break`&&(n.push({startSegmentIndex:r,endSegmentIndex:t,consumedEndSegmentIndex:t+1}),r=t+1);return r<e.len&&n.push({startSegmentIndex:r,endSegmentIndex:e.len,consumedEndSegmentIndex:e.len}),n}function bt(e,t,n=`normal`){let r=Ee(n),i=r.mode===`pre-wrap`?Oe(e):De(e);if(i.length===0)return{normalized:i,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let a=vt(i,t,r);return{normalized:i,chunks:yt(a,r),...a}}var I=null,xt=new Map,St=null,Ct=/\p{Emoji_Presentation}/u,wt=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u,Tt=null,Et=new Map;function Dt(){if(I!==null)return I;if(typeof OffscreenCanvas<`u`)return I=new OffscreenCanvas(1,1).getContext(`2d`),I;if(typeof document<`u`)return I=document.createElement(`canvas`).getContext(`2d`),I;throw Error(`Text measurement requires OffscreenCanvas or a DOM canvas context.`)}function Ot(e){let t=xt.get(e);return t||(t=new Map,xt.set(e,t)),t}function L(e,t){let n=t.get(e);return n===void 0&&(n={width:Dt().measureText(e).width,containsCJK:P(e)},t.set(e,n)),n}function kt(){if(St!==null)return St;if(typeof navigator>`u`)return St={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},St;let e=navigator.userAgent,t=navigator.vendor===`Apple Computer, Inc.`&&e.includes(`Safari/`)&&!e.includes(`Chrome/`)&&!e.includes(`Chromium/`)&&!e.includes(`CriOS/`)&&!e.includes(`FxiOS/`)&&!e.includes(`EdgiOS/`),n=e.includes(`Chrome/`)||e.includes(`Chromium/`)||e.includes(`CriOS/`)||e.includes(`Edg/`);return St={lineFitEpsilon:t?1/64:.005,carryCJKAfterClosingQuote:n,preferPrefixWidthsForBreakableRuns:t,preferEarlySoftHyphenBreak:t},St}function At(e){let t=e.match(/(\d+(?:\.\d+)?)\s*px/);return t?parseFloat(t[1]):16}function jt(){return Tt===null&&(Tt=new Intl.Segmenter(void 0,{granularity:`grapheme`})),Tt}function Mt(e){return Ct.test(e)||e.includes(`️`)}function Nt(e){return wt.test(e)}function Pt(e,t){let n=Et.get(e);if(n!==void 0)return n;let r=Dt();r.font=e;let i=r.measureText(`😀`).width;if(n=0,i>t+.5&&typeof document<`u`&&document.body!==null){let t=document.createElement(`span`);t.style.font=e,t.style.display=`inline-block`,t.style.visibility=`hidden`,t.style.position=`absolute`,t.textContent=`😀`,document.body.appendChild(t);let r=t.getBoundingClientRect().width;document.body.removeChild(t),i-r>.5&&(n=i-r)}return Et.set(e,n),n}function Ft(e){let t=0,n=jt();for(let r of n.segment(e))Mt(r.segment)&&t++;return t}function It(e,t){return t.emojiCount===void 0&&(t.emojiCount=Ft(e)),t.emojiCount}function R(e,t,n){return n===0?t.width:t.width-It(e,t)*n}function Lt(e,t,n,r){if(t.graphemeWidths!==void 0)return t.graphemeWidths;let i=[],a=jt();for(let t of a.segment(e)){let e=L(t.segment,n);i.push(R(t.segment,e,r))}return t.graphemeWidths=i.length>1?i:null,t.graphemeWidths}function Rt(e,t,n,r){if(t.graphemePrefixWidths!==void 0)return t.graphemePrefixWidths;let i=[],a=jt(),o=``;for(let t of a.segment(e)){o+=t.segment;let e=L(o,n);i.push(R(o,e,r))}return t.graphemePrefixWidths=i.length>1?i:null,t.graphemePrefixWidths}function zt(e,t){let n=Dt();n.font=e;let r=Ot(e),i=At(e);return{cache:r,fontSize:i,emojiCorrection:t?Pt(e,i):0}}function Bt(){xt.clear(),Et.clear(),Tt=null}function Vt(e){return e===`space`||e===`preserved-space`||e===`tab`||e===`zero-width-break`||e===`soft-hyphen`}function Ht(e,t){for(;t<e.widths.length;){let n=e.kinds[t];if(n!==`space`&&n!==`zero-width-break`&&n!==`soft-hyphen`)break;t++}return t}function Ut(e,t){if(t<=0)return 0;let n=e%t;return Math.abs(n)<=1e-6?t:t-n}function Wt(e,t,n,r){return!r||t===null?e[n]:t[n]-(n>0?t[n-1]:0)}function Gt(e,t,n,r,i,a){let o=0,s=t;for(;o<e.length;){let c=a?t+e[o]:s+e[o];if((o+1<e.length?c+i:c)>n+r)break;s=c,o++}return{fitCount:o,fittedWidth:s}}function Kt(e,t,n){let{widths:r,kinds:i,breakableWidths:a,breakablePrefixWidths:o}=e;if(r.length===0)return 0;let s=kt(),c=s.lineFitEpsilon,l=0,u=0,d=!1,f=0,p=0,m=0,h=0,g=-1,_=0;function v(){g=-1,_=0}function y(e=m,t=h,r=u){l++,n?.({startSegmentIndex:f,startGraphemeIndex:p,endSegmentIndex:e,endGraphemeIndex:t,width:r}),u=0,d=!1,v()}function b(e,t){d=!0,f=e,p=0,m=e+1,h=0,u=t}function x(e,t,n){d=!0,f=e,p=t,m=e,h=t+1,u=n}function S(e,t){if(!d){b(e,t);return}u+=t,m=e+1,h=0}function C(e,t){Vt(i[e])&&(g=e+1,_=u-t)}function w(e){ee(e,0)}function ee(e,n){let r=a[e],i=o[e]??null;for(let a=n;a<r.length;a++){let n=Wt(r,i,a,s.preferPrefixWidthsForBreakableRuns);if(!d){x(e,a,n);continue}u+n>t+c?(y(),x(e,a,n)):(u+=n,m=e,h=a+1)}d&&m===e&&h===r.length&&(m=e+1,h=0)}let T=0;for(;T<r.length&&!(!d&&(T=Ht(e,T),T>=r.length));){let e=r[T],n=i[T];if(!d){e>t&&a[T]!==null?w(T):b(T,e),C(T,e),T++;continue}if(u+e>t+c){if(Vt(n)){S(T,e),y(T+1,0,u-e),T++;continue}if(g>=0){if(m>g||m===g&&h>0){y();continue}y(g,0,_);continue}if(e>t&&a[T]!==null){y(),w(T),T++;continue}y();continue}S(T,e),C(T,e),T++}return d&&y(),l}function qt(e,t,n){if(e.simpleLineWalkFastPath)return Kt(e,t,n);let{widths:r,lineEndFitAdvances:i,lineEndPaintAdvances:a,kinds:o,breakableWidths:s,breakablePrefixWidths:c,discretionaryHyphenWidth:l,tabStopAdvance:u,chunks:d}=e;if(r.length===0||d.length===0)return 0;let f=kt(),p=f.lineFitEpsilon,m=0,h=0,g=!1,_=0,v=0,y=0,b=0,x=-1,S=0,C=0,w=null;function ee(){x=-1,S=0,C=0,w=null}function T(e=y,t=b,r=h){m++,n?.({startSegmentIndex:_,startGraphemeIndex:v,endSegmentIndex:e,endGraphemeIndex:t,width:r}),h=0,g=!1,ee()}function te(e,t){g=!0,_=e,v=0,y=e+1,b=0,h=t}function E(e,t,n){g=!0,_=e,v=t,y=e,b=t+1,h=n}function D(e,t){if(!g){te(e,t);return}h+=t,y=e+1,b=0}function ne(e,t){if(!Vt(o[e]))return;let n=o[e]===`tab`?0:i[e],r=o[e]===`tab`?t:a[e];x=e+1,S=h-t+n,C=h-t+r,w=o[e]}function re(e){ie(e,0)}function ie(e,n){let r=s[e],i=c[e]??null;for(let a=n;a<r.length;a++){let n=Wt(r,i,a,f.preferPrefixWidthsForBreakableRuns);if(!g){E(e,a,n);continue}h+n>t+p?(T(),E(e,a,n)):(h+=n,y=e,b=a+1)}g&&y===e&&b===r.length&&(y=e+1,b=0)}function ae(e){if(w!==`soft-hyphen`)return!1;let n=s[e];if(n===null)return!1;let r=f.preferPrefixWidthsForBreakableRuns?c[e]??n:n,{fitCount:i,fittedWidth:a}=Gt(r,h,t,p,l,r!==n);return i===0?!1:(h=a,y=e,b=i,ee(),i===n.length?(y=e+1,b=0,!0):(T(e,i,a+l),ie(e,i),!0))}function oe(e){m++,n?.({startSegmentIndex:e.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:e.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),ee()}for(let e=0;e<d.length;e++){let n=d[e];if(n.startSegmentIndex===n.endSegmentIndex){oe(n);continue}g=!1,h=0,_=n.startSegmentIndex,v=0,y=n.startSegmentIndex,b=0,ee();let c=n.startSegmentIndex;for(;c<n.endSegmentIndex;){let e=o[c],n=e===`tab`?Ut(h,u):r[c];if(e===`soft-hyphen`){g&&(y=c+1,b=0,x=c+1,S=h+l,C=h+l,w=e),c++;continue}if(!g){n>t&&s[c]!==null?re(c):te(c,n),ne(c,n),c++;continue}if(h+n>t+p){let r=h+(e===`tab`?0:i[c]),o=h+(e===`tab`?n:a[c]);if(w===`soft-hyphen`&&f.preferEarlySoftHyphenBreak&&S<=t+p){T(x,0,C);continue}if(w===`soft-hyphen`&&ae(c)){c++;continue}if(Vt(e)&&r<=t+p){D(c,n),T(c+1,0,o),c++;continue}if(x>=0&&S<=t+p){if(y>x||y===x&&b>0){T();continue}let e=x;T(e,0,C),c=e;continue}if(n>t&&s[c]!==null){T(),re(c),c++;continue}T();continue}D(c,n),ne(c,n),c++}if(g){let e=x===n.consumedEndSegmentIndex?C:h;T(n.consumedEndSegmentIndex,0,e)}}return m}var Jt=null,Yt=new WeakMap;function Xt(){return Jt===null&&(Jt=new Intl.Segmenter(void 0,{granularity:`grapheme`})),Jt}function Zt(e){return e?{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}:{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function Qt(e,t,n){let r=Xt(),i=kt(),{cache:a,emojiCorrection:o}=zt(t,Nt(e.normalized)),s=R(`-`,L(`-`,a),o),c=R(` `,L(` `,a),o)*8;if(e.len===0)return Zt(n);let l=[],u=[],d=[],f=[],p=e.chunks.length<=1,m=n?[]:null,h=[],g=[],_=n?[]:null,v=Array.from({length:e.len}),y=Array.from({length:e.len});function b(e,t,n,r,i,a,o,s){i!==`text`&&i!==`space`&&i!==`zero-width-break`&&(p=!1),l.push(t),u.push(n),d.push(r),f.push(i),m?.push(a),h.push(o),g.push(s),_!==null&&_.push(e)}for(let t=0;t<e.len;t++){v[t]=l.length;let n=e.texts[t],c=e.isWordLike[t],u=e.kinds[t],d=e.starts[t];if(u===`soft-hyphen`){b(n,0,s,s,u,d,null,null),y[t]=l.length;continue}if(u===`hard-break`){b(n,0,0,0,u,d,null,null),y[t]=l.length;continue}if(u===`tab`){b(n,0,0,0,u,d,null,null),y[t]=l.length;continue}let f=L(n,a);if(u===`text`&&f.containsCJK){let e=``,s=0;for(let t of r.segment(n)){let n=t.segment;if(e.length===0){e=n,s=t.index;continue}if(Re.has(e)||Le.has(n)||Be.has(n)||i.carryCJKAfterClosingQuote&&P(n)&&$e(e)){e+=n;continue}let r=L(e,a),c=R(e,r,o);b(e,c,c,c,`text`,d+s,null,null),e=n,s=t.index}if(e.length>0){let t=L(e,a),n=R(e,t,o);b(e,n,n,n,`text`,d+s,null,null)}y[t]=l.length;continue}let p=R(n,f,o),m=u===`space`||u===`preserved-space`||u===`zero-width-break`?0:p,h=u===`space`||u===`zero-width-break`?0:p;c&&n.length>1?b(n,p,m,h,u,d,Lt(n,f,a,o),i.preferPrefixWidthsForBreakableRuns?Rt(n,f,a,o):null):b(n,p,m,h,u,d,null,null),y[t]=l.length}let x=$t(e.chunks,v,y),S=m===null?null:Ce(e.normalized,m);return _===null?{widths:l,lineEndFitAdvances:u,lineEndPaintAdvances:d,kinds:f,simpleLineWalkFastPath:p,segLevels:S,breakableWidths:h,breakablePrefixWidths:g,discretionaryHyphenWidth:s,tabStopAdvance:c,chunks:x}:{widths:l,lineEndFitAdvances:u,lineEndPaintAdvances:d,kinds:f,simpleLineWalkFastPath:p,segLevels:S,breakableWidths:h,breakablePrefixWidths:g,discretionaryHyphenWidth:s,tabStopAdvance:c,chunks:x,segments:_}}function $t(e,t,n){let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a.startSegmentIndex<t.length?t[a.startSegmentIndex]:n[n.length-1]??0,s=a.endSegmentIndex<t.length?t[a.endSegmentIndex]:n[n.length-1]??0,c=a.consumedEndSegmentIndex<t.length?t[a.consumedEndSegmentIndex]:n[n.length-1]??0;r.push({startSegmentIndex:o,endSegmentIndex:s,consumedEndSegmentIndex:c})}return r}function en(e,t,n,r){return Qt(bt(e,kt(),r?.whiteSpace),t,n)}function tn(e,t,n){return en(e,t,!0,n)}function nn(e){return e}function rn(e,t,n){let r=n.get(e);if(r!==void 0)return r;r=[];let i=Xt();for(let n of i.segment(t[e]))r.push(n.segment);return n.set(e,r),r}function an(e){let t=Yt.get(e);return t===void 0?(t=new Map,Yt.set(e,t),t):t}function on(e,t,n,r){return r>0&&e[r-1]===`soft-hyphen`&&!(t===r&&n>0)}function sn(e,t,n,r,i,a,o){let s=``,c=on(t,r,i,a);for(let o=r;o<a;o++)t[o]===`soft-hyphen`||t[o]===`hard-break`||(o===r&&i>0?s+=rn(o,e,n).slice(i).join(``):s+=e[o]);return o>0?(c&&(s+=`-`),s+=rn(a,e,n).slice(r===a?i:0,o).join(``)):c&&(s+=`-`),s}function cn(e,t,n,r,i,a,o){return{text:sn(e.segments,e.kinds,t,r,i,a,o),width:n,start:{segmentIndex:r,graphemeIndex:i},end:{segmentIndex:a,graphemeIndex:o}}}function ln(e,t,n){return cn(e,t,n.width,n.startSegmentIndex,n.startGraphemeIndex,n.endSegmentIndex,n.endGraphemeIndex)}function un(e,t,n){let r=[];if(e.widths.length===0)return{lineCount:0,height:0,lines:r};let i=an(e),a=qt(nn(e),t,t=>{r.push(ln(e,i,t))});return{lineCount:a,height:a*n,lines:r}}function dn(){Me(),Jt=null,Yt=new WeakMap,Bt()}var z=class extends n.LitElement{constructor(...e){super(...e),this.data=[],this.barWidth=4,this.barHeight=4,this.barGap=2,this.barRadius=2,this.align=`center`,this.fadeEdges=!0,this.fadeWidth=24,this.overlayFont=`14px Inter, sans-serif`,this.overlayColor=`#ffffff`,this._computedPeaks=null,this._preparedOverlayText=null}static{this.styles=n.css`
|
|
648
652
|
:host {
|
|
649
653
|
display: block;
|
|
650
654
|
width: 100%;
|
|
@@ -667,7 +671,7 @@
|
|
|
667
671
|
<div class="container" style="height: ${this.height===void 0?`100%`:typeof this.height==`number`||!isNaN(Number(this.height))?`${this.height}px`:this.height};">
|
|
668
672
|
<canvas></canvas>
|
|
669
673
|
</div>
|
|
670
|
-
`}firstUpdated(){this._resizeObserver=new ResizeObserver(()=>{this._handleResize()}),this._resizeObserver.observe(this._container)}updated(e){super.updated(e),(e.has(`data`)||e.has(`peaks`)||e.has(`barColor`)||e.has(`align`))&&this._renderWaveform()}disconnectedCallback(){super.disconnectedCallback(),this._resizeObserver&&this._resizeObserver.disconnect()}_handleResize(){if(!this._canvas||!this._container)return;let e=this._container.getBoundingClientRect()
|
|
674
|
+
`}firstUpdated(){this._resizeObserver=new ResizeObserver(()=>{this._handleResize()}),this._resizeObserver.observe(this._container)}async updated(e){super.updated(e);let t=!1;if((e.has(`overlayText`)||e.has(`overlayFont`))&&(this.overlayText?this._preparedOverlayText=tn(this.overlayText,this.overlayFont,{whiteSpace:`pre-wrap`}):this._preparedOverlayText=null,t=!0),e.has(`src`)&&this.src){this._computedPeaks=null,this._renderWaveform();try{let e=this._container?.getBoundingClientRect().width||800,t=Math.max(10,Math.floor(e/(this.barWidth+this.barGap)));this._computedPeaks=await de(this.src,t)}catch(e){console.error(`Failed to compute audio peaks for src:`,this.src,e)}}(t||e.has(`data`)||e.has(`peaks`)||e.has(`src`)||e.has(`barColor`)||e.has(`align`)||e.has(`_computedPeaks`)||e.has(`overlayColor`))&&this._renderWaveform()}disconnectedCallback(){super.disconnectedCallback(),this._resizeObserver&&this._resizeObserver.disconnect()}_handleResize(){this._renderWaveform()}_renderWaveform(){if(!this._canvas||!this._container)return;let e=this._container.getBoundingClientRect();if(e.width===0||e.height===0)return;let t=window.devicePixelRatio||1,n=Math.round(e.width*t),r=Math.round(e.height*t),i=this._canvas.getContext(`2d`);if(!i)return;this._canvas.width!==n||this._canvas.height!==r?(this._canvas.width=n,this._canvas.height=r,this._canvas.style.width=`${e.width}px`,this._canvas.style.height=`${e.height}px`,i.scale(t,t)):i.clearRect(0,0,e.width,e.height);let a=getComputedStyle(this),o=this.barColor;if(!o){let e=a.getPropertyValue(`--md-sys-color-primary`).trim(),t=a.getPropertyValue(`color`).trim();o=e||t||`#0066cc`}let s=Math.floor(e.width/(this.barWidth+this.barGap)),c=e.height/2,l=s*(this.barWidth+this.barGap)-this.barGap,u=Math.max(0,(e.width-l)/2),d=this.peaks&&this.peaks.length>0?this.peaks:this._computedPeaks&&this._computedPeaks.length>0?this._computedPeaks:this.data;for(let t=0;t<s;t++){let n=d[d.length>0?Math.floor(t/s*d.length):0]||.1,r=Math.max(this.barHeight,n*e.height*.8),a=u+t*(this.barWidth+this.barGap),l=c-r/2;this.align===`bottom`?l=e.height-r:this.align===`top`&&(l=0),i.fillStyle=o,i.globalAlpha=.6+n*.4,this.barRadius>0?(i.beginPath(),i.roundRect(a,l,this.barWidth,r,this.barRadius),i.fill()):i.fillRect(a,l,this.barWidth,r)}if(i.globalAlpha=1,this._preparedOverlayText){let t=parseInt(this.overlayFont,10)*1.5||20,{lines:n}=un(this._preparedOverlayText,e.width-20,t);i.font=this.overlayFont,i.fillStyle=this.overlayColor,i.textBaseline=`top`;for(let e=0;e<n.length;e++)i.fillText(n[e].text,10,10+e*t)}this.fadeEdges&&le(i,e.width,e.height,this.fadeWidth)}};D([(0,r.property)({type:String})],z.prototype,`src`,void 0),D([(0,r.property)({type:Array})],z.prototype,`data`,void 0),D([(0,r.property)({type:Array})],z.prototype,`peaks`,void 0),D([(0,r.property)({type:Number})],z.prototype,`barWidth`,void 0),D([(0,r.property)({type:Number})],z.prototype,`barHeight`,void 0),D([(0,r.property)({type:Number})],z.prototype,`barGap`,void 0),D([(0,r.property)({type:Number})],z.prototype,`barRadius`,void 0),D([(0,r.property)({type:String})],z.prototype,`barColor`,void 0),D([(0,r.property)({type:String})],z.prototype,`align`,void 0),D([(0,r.property)({type:Boolean})],z.prototype,`fadeEdges`,void 0),D([(0,r.property)({type:Number})],z.prototype,`fadeWidth`,void 0),D([(0,r.property)()],z.prototype,`height`,void 0),D([(0,r.property)({type:String})],z.prototype,`overlayText`,void 0),D([(0,r.property)({type:String})],z.prototype,`overlayFont`,void 0),D([(0,r.property)({type:String})],z.prototype,`overlayColor`,void 0),D([(0,r.state)()],z.prototype,`_computedPeaks`,void 0),D([(0,r.query)(`canvas`)],z.prototype,`_canvas`,void 0),D([(0,r.query)(`.container`)],z.prototype,`_container`,void 0),z=D([(0,r.customElement)(`ui-waveform`)],z);var B=class extends n.LitElement{constructor(...e){super(...e),this.speed=50,this.barCount=60,this.barWidth=4,this.barHeight=4,this.barGap=2,this.barRadius=2,this.fadeEdges=!0,this.fadeWidth=24,this.align=`center`,this.active=!0,this._animationFrameId=0,this._lastTime=0,this._bars=[],this._seed=Math.random(),this._dataIndex=0}static{this.styles=n.css`
|
|
671
675
|
:host {
|
|
672
676
|
display: block;
|
|
673
677
|
width: 100%;
|
|
@@ -691,7 +695,7 @@
|
|
|
691
695
|
<div class="container" style="height: ${this.height===void 0?`100%`:typeof this.height==`number`||!isNaN(Number(this.height))?`${this.height}px`:this.height};">
|
|
692
696
|
<canvas></canvas>
|
|
693
697
|
</div>
|
|
694
|
-
`}firstUpdated(){this._resizeObserver=new ResizeObserver(()=>{this._handleResize()}),this._resizeObserver.observe(this._container),this._canvas&&this._container&&this._populateInitialBars(),this._startAnimation()}disconnectedCallback(){super.disconnectedCallback(),this._resizeObserver&&this._resizeObserver.disconnect(),this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)}_handleResize(){if(!this._canvas||!this._container)return;let e=this._container.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._canvas.style.width=`${e.width}px`,this._canvas.style.height=`${e.height}px`;let n=this._canvas.getContext(`2d`);n&&n.scale(t,t)}_seededRandom(e){let t=Math.sin(this._seed*1e4+e*137.5)*1e4;return t-Math.floor(t)}_populateInitialBars(){let e=this._container.getBoundingClientRect(),t=this.barWidth+this.barGap,n=e.width,r=0;for(this._bars=[];n>-t;)this._bars.push({x:n,height:.2+this._seededRandom(r++)*.6}),n-=t;this._bars.reverse()}_startAnimation(){this._lastTime=performance.now();let e=t=>{if(!this._canvas)return;let n=this._canvas.getContext(`2d`);if(!n)return;let r=this._lastTime?(t-this._lastTime)/1e3:0;this._lastTime=t;let i=this.
|
|
698
|
+
`}firstUpdated(){this._resizeObserver=new ResizeObserver(()=>{this._handleResize()}),this._resizeObserver.observe(this._container),this._canvas&&this._container&&this._populateInitialBars(),this._startAnimation()}disconnectedCallback(){super.disconnectedCallback(),this._resizeObserver&&this._resizeObserver.disconnect(),this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)}_handleResize(){if(!this._canvas||!this._container)return;let e=this._container.getBoundingClientRect(),t=window.devicePixelRatio||1;this._canvas.width=e.width*t,this._canvas.height=e.height*t,this._canvas.style.width=`${e.width}px`,this._canvas.style.height=`${e.height}px`;let n=this._canvas.getContext(`2d`);n&&n.scale(t,t)}_seededRandom(e){let t=Math.sin(this._seed*1e4+e*137.5)*1e4;return t-Math.floor(t)}_populateInitialBars(){let e=this._container.getBoundingClientRect(),t=this.barWidth+this.barGap,n=e.width,r=0;for(this._bars=[];n>-t;)this._bars.push({x:n,height:.2+this._seededRandom(r++)*.6}),n-=t;this._bars.reverse()}_startAnimation(){this._lastTime=performance.now();let e=t=>{if(!this._canvas)return;let n=this._canvas.getContext(`2d`);if(!n)return;let r=this._lastTime?(t-this._lastTime)/1e3:0;this._lastTime=t;let i=window.devicePixelRatio||1,a=this._container.getBoundingClientRect();if(a.width===0||a.height===0){this._animationFrameId=requestAnimationFrame(e);return}let o=Math.round(a.width*i),s=Math.round(a.height*i);this._canvas.width!==o||this._canvas.height!==s?(this._canvas.width=o,this._canvas.height=s,this._canvas.style.width=`${a.width}px`,this._canvas.style.height=`${a.height}px`,n.scale(i,i)):n.clearRect(0,0,a.width,a.height);let c=this.barColor;c||=getComputedStyle(this).getPropertyValue(`--md-sys-color-primary`).trim()||`#0066cc`;let l=this.barWidth+this.barGap,u=this.active?this.speed:0;for(let e=0;e<this._bars.length;e++)this._bars[e].x-=u*r,this.active||(this._bars[e].height+=(.05-this._bars[e].height)*.15);for(this._bars=this._bars.filter(e=>e.x+this.barWidth>-l);this._bars.length===0||this._bars[this._bars.length-1].x<a.width;){let e=this._bars[this._bars.length-1],t=e?e.x+l:a.width,n,r=this.peaks&&this.peaks.length>0?this.peaks:this.data;if(r&&r.length>0)n=r[this._dataIndex%r.length]||.1,this._dataIndex=(this._dataIndex+1)%r.length;else if(this.analyserNode){(!this._dataArray||this._dataArray.length!==this.analyserNode.frequencyBinCount)&&(this._dataArray=new Uint8Array(this.analyserNode.frequencyBinCount)),this.analyserNode.getByteFrequencyData(this._dataArray);let e=0,t=Math.min(this._dataArray.length,50);for(let n=0;n<t;n++)e+=this._dataArray[n];let r=e/t/255;n=Math.max(.1,r**1.5*1.5)}else{let e=Date.now()/1e3,t=this._bars.length+e*.01,r=Math.sin(t*.1)*.2,i=Math.cos(t*.05)*.15,a=this._seededRandom(t)*.4;n=Math.max(.1,Math.min(.9,.3+r+i+a))}if(this._bars.push({x:t,height:n}),this._bars.length>this.barCount*2)break}let d=a.height/2;for(let e of this._bars)if(e.x<a.width&&e.x+this.barWidth>0){let t=Math.max(this.barHeight,e.height*a.height*.8),r=d-t/2;n.fillStyle=c,n.globalAlpha=.6+e.height*.4,this.barRadius>0?(n.beginPath(),n.roundRect(e.x,r,this.barWidth,t,this.barRadius),n.fill()):n.fillRect(e.x,r,this.barWidth,t)}n.globalAlpha=1,this.fadeEdges&&this.fadeWidth>0&&le(n,a.width,a.height,this.fadeWidth),this._animationFrameId=requestAnimationFrame(e)};this._animationFrameId=requestAnimationFrame(e)}};D([(0,r.property)({type:Number})],B.prototype,`speed`,void 0),D([(0,r.property)({type:Number})],B.prototype,`barCount`,void 0),D([(0,r.property)({type:Number})],B.prototype,`barWidth`,void 0),D([(0,r.property)({type:Number})],B.prototype,`barHeight`,void 0),D([(0,r.property)({type:Number})],B.prototype,`barGap`,void 0),D([(0,r.property)({type:Number})],B.prototype,`barRadius`,void 0),D([(0,r.property)({type:String})],B.prototype,`barColor`,void 0),D([(0,r.property)({type:Boolean})],B.prototype,`fadeEdges`,void 0),D([(0,r.property)({type:Number})],B.prototype,`fadeWidth`,void 0),D([(0,r.property)()],B.prototype,`height`,void 0),D([(0,r.property)({type:String})],B.prototype,`align`,void 0),D([(0,r.property)({type:Array})],B.prototype,`data`,void 0),D([(0,r.property)({type:Array})],B.prototype,`peaks`,void 0),D([(0,r.property)({attribute:!1})],B.prototype,`analyserNode`,void 0),D([(0,r.property)({type:Boolean})],B.prototype,`active`,void 0),D([(0,r.query)(`canvas`)],B.prototype,`_canvas`,void 0),D([(0,r.query)(`.container`)],B.prototype,`_container`,void 0),B=D([(0,r.customElement)(`ui-scrolling-waveform`)],B);var V=class extends n.LitElement{constructor(...e){super(...e),this.barWidth=4,this.barGap=2,this._animationFrameId=0}static{this.styles=n.css`
|
|
695
699
|
:host {
|
|
696
700
|
display: block;
|
|
697
701
|
width: 100%;
|
|
@@ -703,7 +707,7 @@
|
|
|
703
707
|
width: 100%;
|
|
704
708
|
height: 100%;
|
|
705
709
|
}
|
|
706
|
-
`}render(){return n.html`<canvas style="height: ${this.height===void 0?`100%`:typeof this.height==`number`||!isNaN(Number(this.height))?`${this.height}px`:this.height};"></canvas>`}firstUpdated(){this._startLoop()}disconnectedCallback(){super.disconnectedCallback(),cancelAnimationFrame(this._animationFrameId)}_startLoop(){let e=()=>{this._renderFrame(),this._animationFrameId=requestAnimationFrame(e)};this._animationFrameId=requestAnimationFrame(e)}_renderFrame(){if(!this._canvas||!this.playerState?.analyserNode)return;let e=this.playerState.analyserNode;this._dataArray||=new Uint8Array(e.frequencyBinCount);let t=this._canvas.getContext(`2d`);if(!t)return;let n=this.
|
|
710
|
+
`}render(){return n.html`<canvas style="height: ${this.height===void 0?`100%`:typeof this.height==`number`||!isNaN(Number(this.height))?`${this.height}px`:this.height};"></canvas>`}firstUpdated(){this._startLoop()}disconnectedCallback(){super.disconnectedCallback(),cancelAnimationFrame(this._animationFrameId)}_startLoop(){let e=()=>{this._renderFrame(),this._animationFrameId=requestAnimationFrame(e)};this._animationFrameId=requestAnimationFrame(e)}_renderFrame(){if(!this._canvas||!this.playerState?.analyserNode)return;let e=this.playerState.analyserNode;this._dataArray||=new Uint8Array(e.frequencyBinCount);let t=this._canvas.getContext(`2d`);if(!t)return;let n=this.getBoundingClientRect();if(n.width===0||n.height===0)return;let r=window.devicePixelRatio||1,i=Math.round(n.width*r),a=Math.round(n.height*r);this._canvas.width!==i||this._canvas.height!==a?(this._canvas.width=i,this._canvas.height=a,this._canvas.style.width=`${n.width}px`,this._canvas.style.height=`${n.height}px`,t.scale(r,r)):t.clearRect(0,0,n.width,n.height);let o=se(e,this._dataArray),s=this.barWidth+this.barGap,c=Math.floor(n.width/s),l=getComputedStyle(this),u=this.color;u||=l.getPropertyValue(`--md-sys-color-primary`).trim()||`#0066cc`,t.fillStyle=u;for(let e=0;e<c;e++){let r=(o[Math.floor(e/c*(o.length*.6))]||0)*n.height,i=e*s,a=n.height-r;t.fillRect(i,a,this.barWidth,r)}}};D([(0,i.consume)({context:E,subscribe:!0})],V.prototype,`playerState`,void 0),D([(0,r.property)({type:Number})],V.prototype,`barWidth`,void 0),D([(0,r.property)({type:Number})],V.prototype,`barGap`,void 0),D([(0,r.property)()],V.prototype,`height`,void 0),D([(0,r.property)({type:String})],V.prototype,`color`,void 0),D([(0,r.query)(`canvas`)],V.prototype,`_canvas`,void 0),V=D([(0,r.customElement)(`ui-spectrum-visualizer`)],V);var H=class extends n.LitElement{constructor(...e){super(...e),this.muted=!1,this.disabled=!1,this._devices=[],this._loading=!0,this._error=null,this._hasPermission=!1,this._isMenuOpen=!1,this._handleDeviceChange=()=>{this._hasPermission?this._loadDevicesWithPermission():this._loadDevicesWithoutPermission()}}static{this.styles=n.css`
|
|
707
711
|
:host {
|
|
708
712
|
display: inline-block;
|
|
709
713
|
position: relative;
|
|
@@ -864,7 +868,7 @@
|
|
|
864
868
|
</div>
|
|
865
869
|
`:``}
|
|
866
870
|
</md-menu>
|
|
867
|
-
`}_toggleMenu(){this._menuEl&&(this._menuEl.open=!this._menuEl.open,this._isMenuOpen=this._menuEl.open)}_selectDevice(e){this.value=e,this.dispatchEvent(new CustomEvent(`device-change`,{detail:{deviceId:e},bubbles:!0,composed:!0})),this._isMenuOpen&&!this.muted&&this._hasPermission&&this._startPreview()}_toggleMute(e){e.stopPropagation(),this.muted=!this.muted,this.dispatchEvent(new CustomEvent(`mute-change`,{detail:{muted:this.muted},bubbles:!0,composed:!0}))}async _loadDevicesWithoutPermission(){try{this._loading=!0,this._error=null;let e=await navigator.mediaDevices.enumerateDevices();this._parseDeviceList(e)}catch(e){this._error=e instanceof Error?e.message:`Failed to get audio devices`}finally{this._loading=!1}}async _loadDevicesWithPermission(){if(!this._loading)try{this._loading=!0,this._error=null,(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop());let e=await navigator.mediaDevices.enumerateDevices();this._parseDeviceList(e),this._hasPermission=!0,this._isMenuOpen&&!this.muted&&this._startPreview()}catch(e){this._error=e instanceof Error?e.message:`Permission denied`}finally{this._loading=!1}}_parseDeviceList(e){let t=e.filter(e=>e.kind===`audioinput`).map(e=>{let t=e.label||`Microphone`;return t=t.replace(/\s*\([^)]*\)/g,``).trim(),{deviceId:e.deviceId,label:t,groupId:e.groupId}});this._devices=t,!this.value&&t.length>0&&(this.value=t[0].deviceId,this.dispatchEvent(new CustomEvent(`device-change`,{detail:{deviceId:this.value},bubbles:!0,composed:!0})))}async _startPreview(){if(this._stopPreview(),this.value)try{this._previewStream=await navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:this.value}}}),this._previewAudioContext=new(window.AudioContext||window.webkitAudioContext),this._previewAnalyser=this._previewAudioContext.createAnalyser(),this._previewAnalyser.fftSize=256,this._previewAnalyser.smoothingTimeConstant=.8,this._previewAudioContext.createMediaStreamSource(this._previewStream).connect(this._previewAnalyser)}catch(e){console.warn(`Failed to start preview stream`,e)}}_stopPreview(){this._previewStream&&=(this._previewStream.getTracks().forEach(e=>e.stop()),void 0),this._previewAudioContext&&this._previewAudioContext.state!==`closed`&&(this._previewAudioContext.close(),this._previewAudioContext=void 0),this._previewAnalyser=void 0}};
|
|
871
|
+
`}_toggleMenu(){this._menuEl&&(this._menuEl.open=!this._menuEl.open,this._isMenuOpen=this._menuEl.open)}_selectDevice(e){this.value=e,this.dispatchEvent(new CustomEvent(`device-change`,{detail:{deviceId:e},bubbles:!0,composed:!0})),this._isMenuOpen&&!this.muted&&this._hasPermission&&this._startPreview()}_toggleMute(e){e.stopPropagation(),this.muted=!this.muted,this.dispatchEvent(new CustomEvent(`mute-change`,{detail:{muted:this.muted},bubbles:!0,composed:!0}))}async _loadDevicesWithoutPermission(){try{this._loading=!0,this._error=null;let e=await navigator.mediaDevices.enumerateDevices();this._parseDeviceList(e)}catch(e){this._error=e instanceof Error?e.message:`Failed to get audio devices`}finally{this._loading=!1}}async _loadDevicesWithPermission(){if(!this._loading)try{this._loading=!0,this._error=null,(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop());let e=await navigator.mediaDevices.enumerateDevices();this._parseDeviceList(e),this._hasPermission=!0,this._isMenuOpen&&!this.muted&&this._startPreview()}catch(e){this._error=e instanceof Error?e.message:`Permission denied`}finally{this._loading=!1}}_parseDeviceList(e){let t=e.filter(e=>e.kind===`audioinput`).map(e=>{let t=e.label||`Microphone`;return t=t.replace(/\s*\([^)]*\)/g,``).trim(),{deviceId:e.deviceId,label:t,groupId:e.groupId}});this._devices=t,!this.value&&t.length>0&&(this.value=t[0].deviceId,this.dispatchEvent(new CustomEvent(`device-change`,{detail:{deviceId:this.value},bubbles:!0,composed:!0})))}async _startPreview(){if(this._stopPreview(),this.value)try{this._previewStream=await navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:this.value}}}),this._previewAudioContext=new(window.AudioContext||window.webkitAudioContext),this._previewAnalyser=this._previewAudioContext.createAnalyser(),this._previewAnalyser.fftSize=256,this._previewAnalyser.smoothingTimeConstant=.8,this._previewAudioContext.createMediaStreamSource(this._previewStream).connect(this._previewAnalyser)}catch(e){console.warn(`Failed to start preview stream`,e)}}_stopPreview(){this._previewStream&&=(this._previewStream.getTracks().forEach(e=>e.stop()),void 0),this._previewAudioContext&&this._previewAudioContext.state!==`closed`&&(this._previewAudioContext.close(),this._previewAudioContext=void 0),this._previewAnalyser=void 0}};D([(0,r.property)({type:String})],H.prototype,`value`,void 0),D([(0,r.property)({type:Boolean})],H.prototype,`muted`,void 0),D([(0,r.property)({type:Boolean})],H.prototype,`disabled`,void 0),D([(0,r.state)()],H.prototype,`_devices`,void 0),D([(0,r.state)()],H.prototype,`_loading`,void 0),D([(0,r.state)()],H.prototype,`_error`,void 0),D([(0,r.state)()],H.prototype,`_hasPermission`,void 0),D([(0,r.state)()],H.prototype,`_isMenuOpen`,void 0),D([(0,r.state)()],H.prototype,`_previewAnalyser`,void 0),D([(0,r.query)(`md-menu`)],H.prototype,`_menuEl`,void 0),H=D([(0,r.customElement)(`ui-mic-selector`)],H);var U=class extends n.LitElement{constructor(...e){super(...e),this.voices=[],this.placeholder=`Select a voice...`,this.idKey=`voiceId`,this.titleKey=`name`,this.subtitleKey=`category`,this.previewUrlKey=`previewUrl`,this.useOrbs=!1,this.colorKey=`colors`,this._searchQuery=``}static{this.styles=n.css`
|
|
868
872
|
:host {
|
|
869
873
|
display: inline-block;
|
|
870
874
|
width: 100%;
|
|
@@ -1184,7 +1188,7 @@
|
|
|
1184
1188
|
</md-menu-item>
|
|
1185
1189
|
`)}
|
|
1186
1190
|
</md-menu>
|
|
1187
|
-
`}_toggleMenu(){this._menuEl&&(this._menuEl.open=!this._menuEl.open)}_handleMenuClosed(){this._stopPreview()}_selectVoice(e){this.value=e,this.dispatchEvent(new CustomEvent(`voice-change`,{detail:{voiceId:e},bubbles:!0,composed:!0}))}_togglePreview(e,t){e.stopPropagation(),e.preventDefault(),!(!t[this.previewUrlKey]||!this._audioEl)&&(this._previewingVoiceId===t[this.idKey]?this._stopPreview():(this._audioEl.src=t[this.previewUrlKey],this._audioEl.play().catch(console.error),this._previewingVoiceId=t[this.idKey]))}_stopPreview(){this._audioEl&&(this._audioEl.pause(),this._audioEl.currentTime=0),this._previewingVoiceId=void 0}};
|
|
1191
|
+
`}_toggleMenu(){this._menuEl&&(this._menuEl.open=!this._menuEl.open)}_handleMenuClosed(){this._stopPreview()}_selectVoice(e){this.value=e,this.dispatchEvent(new CustomEvent(`voice-change`,{detail:{voiceId:e},bubbles:!0,composed:!0}))}_togglePreview(e,t){e.stopPropagation(),e.preventDefault(),!(!t[this.previewUrlKey]||!this._audioEl)&&(this._previewingVoiceId===t[this.idKey]?this._stopPreview():(this._audioEl.src=t[this.previewUrlKey],this._audioEl.play().catch(console.error),this._previewingVoiceId=t[this.idKey]))}_stopPreview(){this._audioEl&&(this._audioEl.pause(),this._audioEl.currentTime=0),this._previewingVoiceId=void 0}};D([(0,r.property)({type:Array})],U.prototype,`voices`,void 0),D([(0,r.property)({type:String})],U.prototype,`value`,void 0),D([(0,r.property)({type:String})],U.prototype,`placeholder`,void 0),D([(0,r.property)({type:String})],U.prototype,`idKey`,void 0),D([(0,r.property)({type:String})],U.prototype,`titleKey`,void 0),D([(0,r.property)({type:String})],U.prototype,`subtitleKey`,void 0),D([(0,r.property)({type:String})],U.prototype,`previewUrlKey`,void 0),D([(0,r.property)({type:Boolean})],U.prototype,`useOrbs`,void 0),D([(0,r.property)({type:String})],U.prototype,`colorKey`,void 0),D([(0,r.state)()],U.prototype,`_searchQuery`,void 0),D([(0,r.state)()],U.prototype,`_previewingVoiceId`,void 0),D([(0,r.query)(`md-menu`)],U.prototype,`_menuEl`,void 0),D([(0,r.query)(`audio`)],U.prototype,`_audioEl`,void 0),U=D([(0,r.customElement)(`ui-voice-picker`)],U);var fn=class extends n.LitElement{constructor(...e){super(...e),this.placeholder=`Jot down some thoughts...`}static{this.styles=n.css`
|
|
1188
1192
|
:host {
|
|
1189
1193
|
display: inline-flex;
|
|
1190
1194
|
align-items: center;
|
|
@@ -1243,7 +1247,7 @@
|
|
|
1243
1247
|
barColor="var(--ui-speech-wave-color, currentColor)"
|
|
1244
1248
|
></ui-live-waveform>
|
|
1245
1249
|
</div>
|
|
1246
|
-
`}};
|
|
1250
|
+
`}};D([(0,i.consume)({context:A,subscribe:!0})],fn.prototype,`_context`,void 0),D([(0,r.property)({type:String})],fn.prototype,`placeholder`,void 0),fn=D([(0,r.customElement)(`ui-speech-preview`)],fn);var W=class extends n.LitElement{constructor(...e){super(...e),this.agentState=null,this.inputVolume=0,this.outputVolume=0,this.volumeMode=`auto`,this.seed=Math.floor(Math.random()*2**32),this._animationFrameId=0,this._animSpeed=.1,this._curIn=0,this._curOut=0,this._textureLoader=new g.TextureLoader,this._lastTime=0,this._vertexShader=`
|
|
1247
1251
|
uniform float uTime;
|
|
1248
1252
|
varying vec2 vUv;
|
|
1249
1253
|
void main() {
|
|
@@ -1407,7 +1411,7 @@ void main() {
|
|
|
1407
1411
|
width: 100%;
|
|
1408
1412
|
height: 100%;
|
|
1409
1413
|
}
|
|
1410
|
-
`}render(){return n.html`<div class="container"></div>`}firstUpdated(){this._initThree()}updated(e){e.has(`colors`)&&this._updateColors(),e.has(`seed`)&&this._updateSeed()}_updateSeed(){if(!this._mesh)return;let e=this._splitmix32(this.seed),t=new Float32Array(Array.from({length:7},()=>e()*Math.PI*2));this._mesh.material.uniforms.uOffsets.value=t}_updateColors(){if(!(!this._targetColor1||!this._targetColor2))if(this.colors&&this.colors.length===2)this._targetColor1.set(this.colors[0]),this._targetColor2.set(this.colors[1]);else{let e=getComputedStyle(this),t=e.getPropertyValue(`--md-sys-color-primary`).trim()||`#7D56F4`,n=e.getPropertyValue(`--md-sys-color-secondary`).trim()||`#205`;this._targetColor1.set(t),this._targetColor2.set(n)}}disconnectedCallback(){super.disconnectedCallback(),this._animationFrameId&&cancelAnimationFrame(this._animationFrameId),this._resizeObserver&&this._resizeObserver.disconnect(),this._renderer&&this._renderer.dispose(),this._mesh&&(this._mesh.geometry.dispose(),this._mesh.material.dispose())}async _initThree(){if(!this._container)return;this._targetColor1=new
|
|
1414
|
+
`}render(){return n.html`<div class="container"></div>`}firstUpdated(){this._initThree()}updated(e){e.has(`colors`)&&this._updateColors(),e.has(`seed`)&&this._updateSeed()}_updateSeed(){if(!this._mesh)return;let e=this._splitmix32(this.seed),t=new Float32Array(Array.from({length:7},()=>e()*Math.PI*2));this._mesh.material.uniforms.uOffsets.value=t}_updateColors(){if(!(!this._targetColor1||!this._targetColor2))if(this.colors&&this.colors.length===2)this._targetColor1.set(this.colors[0]),this._targetColor2.set(this.colors[1]);else{let e=getComputedStyle(this),t=e.getPropertyValue(`--md-sys-color-primary`).trim()||`#7D56F4`,n=e.getPropertyValue(`--md-sys-color-secondary`).trim()||`#205`;this._targetColor1.set(t),this._targetColor2.set(n)}}disconnectedCallback(){super.disconnectedCallback(),this._animationFrameId&&cancelAnimationFrame(this._animationFrameId),this._resizeObserver&&this._resizeObserver.disconnect(),this._renderer&&this._renderer.dispose(),this._mesh&&(this._mesh.geometry.dispose(),this._mesh.material.dispose())}async _initThree(){if(!this._container)return;this._targetColor1=new g.Color,this._targetColor2=new g.Color,this._updateColors();try{this._perlinNoiseTexture=await this._textureLoader.loadAsync(`https://storage.googleapis.com/eleven-public-cdn/images/perlin-noise.png`),this._perlinNoiseTexture.wrapS=g.RepeatWrapping,this._perlinNoiseTexture.wrapT=g.RepeatWrapping}catch(e){console.warn(`Failed to load perlin noise texture for orb.`,e);return}let e=this._container.clientWidth,t=this._container.clientHeight;this._scene=new g.Scene,this._camera=new g.OrthographicCamera(-5,5,5,-5,.1,10),this._camera.position.z=1,this._renderer=new g.WebGLRenderer({alpha:!0,antialias:!0,premultipliedAlpha:!0}),this._renderer.setSize(e,t),this._renderer.setPixelRatio(window.devicePixelRatio),this._container.appendChild(this._renderer.domElement);let n=this._splitmix32(this.seed),r=new Float32Array(Array.from({length:7},()=>n()*Math.PI*2)),i=document.documentElement.classList.contains(`dark`)||window.matchMedia(`(prefers-color-scheme: dark)`).matches,a={uColor1:new g.Uniform(this._targetColor1),uColor2:new g.Uniform(this._targetColor2),uOffsets:{value:r},uPerlinTexture:new g.Uniform(this._perlinNoiseTexture),uTime:new g.Uniform(0),uAnimation:new g.Uniform(.1),uInverted:new g.Uniform(i?1:0),uInputVolume:new g.Uniform(0),uOutputVolume:new g.Uniform(0),uOpacity:new g.Uniform(0)},o=new g.CircleGeometry(3.5,64),s=new g.ShaderMaterial({uniforms:a,vertexShader:this._vertexShader,fragmentShader:this._fragmentShader,transparent:!0});this._mesh=new g.Mesh(o,s),this._scene.add(this._mesh),this._resizeObserver=new ResizeObserver(()=>{this._container&&this._renderer&&this._renderer.setSize(this._container.clientWidth,this._container.clientHeight)}),this._resizeObserver.observe(this._container),this._lastTime=performance.now(),this._animate()}_animate(){if(this._animationFrameId=requestAnimationFrame(()=>this._animate()),!this._mesh||!this._renderer||!this._scene||!this._camera)return;let e=performance.now(),t=(e-this._lastTime)/1e3;this._lastTime=e;let n=this._mesh.material.uniforms;n.uTime.value+=t*.5,n.uOpacity.value<1&&(n.uOpacity.value=Math.min(1,n.uOpacity.value+t*2));let r=0,i=.3;if(this.volumeMode===`manual`)r=this._clamp01(this.inputVolume),i=this._clamp01(this.outputVolume);else{let e=n.uTime.value*2;if(this.agentState===null)r=0,i=.2;else if(this.agentState===`listening`)r=this._clamp01(.45+Math.sin(e*2.5)*.25),i=.35;else if(this.agentState===`talking`)r=this._clamp01(.7+Math.sin(e*6.5)*.25),i=this._clamp01(.85+Math.sin(e*5.5)*.15);else if(this.agentState===`thinking`)r=this._clamp01(.55+Math.sin(e*4.5)*.15),i=this._clamp01(.6+Math.sin(e*3.5)*.1);else{let t=.38+.07*Math.sin(e*.7),n=.05*Math.sin(e*2.1)*Math.sin(e*.37+1.2);r=this._clamp01(t+n),i=this._clamp01(.48+.12*Math.sin(e*1.05+.6))}}this._curIn+=(r-this._curIn)*.2,this._curOut+=(i-this._curOut)*.2;let a=.1;this.agentState===`talking`&&(a=.4),this.agentState===`thinking`&&(a=.25),this.agentState===`listening`&&(a=.15);let o=a+(1-(this._curOut-1)**2)*1.2;this._animSpeed+=(o-this._animSpeed)*.12,n.uAnimation.value+=t*this._animSpeed,n.uInputVolume.value=this._curIn,n.uOutputVolume.value=this._curOut,n.uColor1.value.lerp(this._targetColor1,.08),n.uColor2.value.lerp(this._targetColor2,.08),this._renderer.render(this._scene,this._camera)}_splitmix32(e){return function(){e|=0,e=e+2654435769|0;let t=e^e>>>16;return t=Math.imul(t,569420461),t^=t>>>15,t=Math.imul(t,1935289751),((t^=t>>>15)>>>0)/4294967296}}_clamp01(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}};D([(0,r.property)({type:Array})],W.prototype,`colors`,void 0),D([(0,r.property)({type:String})],W.prototype,`agentState`,void 0),D([(0,r.property)({type:Number})],W.prototype,`inputVolume`,void 0),D([(0,r.property)({type:Number})],W.prototype,`outputVolume`,void 0),D([(0,r.property)({type:String})],W.prototype,`volumeMode`,void 0),D([(0,r.property)({type:Number})],W.prototype,`seed`,void 0),D([(0,r.query)(`.container`)],W.prototype,`_container`,void 0),W=D([(0,r.customElement)(`ui-orb`)],W);var G=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},K=class extends n.LitElement{constructor(){super(...arguments),this.agentState=null,this.inputVolume=0,this.outputVolume=0,this.volumeMode=`auto`,this.baseHeight=.05,this.speed=1,this._animationFrameId=0,this._animSpeed=1,this._curIn=0,this._curOut=0,this._lastTime=0,this._vertexShader=`
|
|
1411
1415
|
varying vec2 vUv;
|
|
1412
1416
|
void main() {
|
|
1413
1417
|
vUv = uv;
|
|
@@ -1532,7 +1536,7 @@ void main() {
|
|
|
1532
1536
|
width: 100%;
|
|
1533
1537
|
height: 100%;
|
|
1534
1538
|
}
|
|
1535
|
-
`}render(){return n.html`<div class="container"></div>`}firstUpdated(){this._initThree()}updated(e){if(e.has(`colors`)&&this._updateColors(),this._mesh&&(e.has(`baseHeight`)&&(this._mesh.material.uniforms.uBaseHeight.value=this.baseHeight),e.has(`stops`))){let e=this.stops||[0,.5,.86];this._mesh.material.uniforms.uStop1.value=e[0],this._mesh.material.uniforms.uStop2.value=e[1],this._mesh.material.uniforms.uStop3.value=e[2]}}_updateColors(){!this._targetColor1||!this._targetColor2||!this._targetColor3||(this.colors&&this.colors.length>=3?(this._targetColor1.set(this.colors[0]),this._targetColor2.set(this.colors[1]),this._targetColor3.set(this.colors[2])):(this._targetColor1.set(`#0068FF`),this._targetColor2.set(`#0077FF`),this._targetColor3.set(`#0073FF`)))}disconnectedCallback(){super.disconnectedCallback(),this._animationFrameId&&cancelAnimationFrame(this._animationFrameId),this._resizeObserver&&this._resizeObserver.disconnect(),this._renderer&&this._renderer.dispose(),this._mesh&&(this._mesh.geometry.dispose(),this._mesh.material.dispose())}async _initThree(){if(!this._container)return;this._targetColor1=new
|
|
1539
|
+
`}render(){return n.html`<div class="container"></div>`}firstUpdated(){this._initThree()}updated(e){if(e.has(`colors`)&&this._updateColors(),this._mesh&&(e.has(`baseHeight`)&&(this._mesh.material.uniforms.uBaseHeight.value=this.baseHeight),e.has(`stops`))){let e=this.stops||[0,.5,.86];this._mesh.material.uniforms.uStop1.value=e[0],this._mesh.material.uniforms.uStop2.value=e[1],this._mesh.material.uniforms.uStop3.value=e[2]}}_updateColors(){!this._targetColor1||!this._targetColor2||!this._targetColor3||(this.colors&&this.colors.length>=3?(this._targetColor1.set(this.colors[0]),this._targetColor2.set(this.colors[1]),this._targetColor3.set(this.colors[2])):(this._targetColor1.set(`#0068FF`),this._targetColor2.set(`#0077FF`),this._targetColor3.set(`#0073FF`)))}disconnectedCallback(){super.disconnectedCallback(),this._animationFrameId&&cancelAnimationFrame(this._animationFrameId),this._resizeObserver&&this._resizeObserver.disconnect(),this._renderer&&this._renderer.dispose(),this._mesh&&(this._mesh.geometry.dispose(),this._mesh.material.dispose())}async _initThree(){if(!this._container)return;this._targetColor1=new g.Color,this._targetColor2=new g.Color,this._targetColor3=new g.Color,this._updateColors();let e=this._container.clientWidth,t=this._container.clientHeight;this._scene=new g.Scene,this._camera=new g.OrthographicCamera(-1,1,1,-1,.1,10),this._camera.position.z=1,this._renderer=new g.WebGLRenderer({alpha:!0,antialias:!0,premultipliedAlpha:!0}),this._renderer.setSize(e,t),this._renderer.setPixelRatio(window.devicePixelRatio),this._container.appendChild(this._renderer.domElement);let n=this.stops||[0,.5,.86],r={uColor1:new g.Uniform(this._targetColor1),uColor2:new g.Uniform(this._targetColor2),uColor3:new g.Uniform(this._targetColor3),uTime:new g.Uniform(0),uInputVolume:new g.Uniform(0),uOutputVolume:new g.Uniform(0),uOpacity:new g.Uniform(0),uAspect:new g.Uniform(e/t),uBaseHeight:new g.Uniform(this.baseHeight),uStop1:new g.Uniform(n[0]),uStop2:new g.Uniform(n[1]),uStop3:new g.Uniform(n[2])},i=new g.PlaneGeometry(2,2),a=new g.ShaderMaterial({uniforms:r,vertexShader:this._vertexShader,fragmentShader:this._fragmentShader,transparent:!0,blending:g.NormalBlending});this._mesh=new g.Mesh(i,a),this._scene.add(this._mesh),this._resizeObserver=new ResizeObserver(()=>{if(this._container&&this._renderer&&this._mesh){let e=this._container.clientWidth,t=this._container.clientHeight;this._renderer.setSize(e,t),this._mesh.material.uniforms.uAspect.value=e/t}}),this._resizeObserver.observe(this._container),this._lastTime=performance.now(),this._animate()}_animate(){if(this._animationFrameId=requestAnimationFrame(()=>this._animate()),!this._mesh||!this._renderer||!this._scene||!this._camera)return;let e=performance.now(),t=(e-this._lastTime)/1e3;this._lastTime=e;let n=this._mesh.material.uniforms;n.uOpacity.value<1&&(n.uOpacity.value=Math.min(1,n.uOpacity.value+t*2));let r=0,i=0;if(this.volumeMode===`manual`)r=this._clamp01(this.inputVolume),i=this._clamp01(this.outputVolume);else{let e=n.uTime.value;this.agentState===null?(r=0,i=0):this.agentState===`listening`?(r=this._clamp01(.3+Math.sin(e*2)*.15),i=0):this.agentState===`talking`?(r=0,i=this._clamp01(.6+Math.sin(e*4)*.3)):this.agentState===`thinking`?(r=0,i=this._clamp01(.2+Math.sin(e*1.5)*.1)):(r=0,i=0)}this._curIn+=(r-this._curIn)*.15,this._curOut+=(i-this._curOut)*.15;let a=this.speed;this.agentState===`talking`&&(a=this.speed*2.5),this.agentState===`thinking`&&(a=this.speed*1.5),this.agentState===`listening`&&(a=this.speed*1.2),a+=(this._curIn+this._curOut)*2*this.speed,this._animSpeed+=(a-this._animSpeed)*.1,n.uTime.value+=t*this._animSpeed,n.uInputVolume.value=this._curIn,n.uOutputVolume.value=this._curOut,n.uColor1.value.lerp(this._targetColor1,.05),n.uColor2.value.lerp(this._targetColor2,.05),this._renderer.render(this._scene,this._camera)}_clamp01(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}};G([(0,r.property)({type:Array})],K.prototype,`colors`,void 0),G([(0,r.property)({type:Array})],K.prototype,`stops`,void 0),G([(0,r.property)({type:String})],K.prototype,`agentState`,void 0),G([(0,r.property)({type:Number})],K.prototype,`inputVolume`,void 0),G([(0,r.property)({type:Number})],K.prototype,`outputVolume`,void 0),G([(0,r.property)({type:String})],K.prototype,`volumeMode`,void 0),G([(0,r.property)({type:Number})],K.prototype,`baseHeight`,void 0),G([(0,r.property)({type:Number})],K.prototype,`speed`,void 0),G([(0,r.query)(`.container`)],K.prototype,`_container`,void 0),K=G([(0,r.customElement)(`ui-moving-gradient`)],K);var pn=class extends n.LitElement{constructor(...e){super(...e),this.flipped=!1,this.axis=`y`,this.duration=`0.6s`}static{this.styles=n.css`
|
|
1536
1540
|
:host {
|
|
1537
1541
|
display: block;
|
|
1538
1542
|
perspective: 1000px;
|
|
@@ -1609,7 +1613,7 @@ void main() {
|
|
|
1609
1613
|
</div>
|
|
1610
1614
|
</div>
|
|
1611
1615
|
</div>
|
|
1612
|
-
`}toggle(){this.flipped=!this.flipped,this.dispatchEvent(new CustomEvent(`flip-change`,{detail:{flipped:this.flipped},bubbles:!0,composed:!0}))}};
|
|
1616
|
+
`}toggle(){this.flipped=!this.flipped,this.dispatchEvent(new CustomEvent(`flip-change`,{detail:{flipped:this.flipped},bubbles:!0,composed:!0}))}};D([(0,r.property)({type:Boolean,reflect:!0})],pn.prototype,`flipped`,void 0),D([(0,r.property)({type:String,reflect:!0})],pn.prototype,`axis`,void 0),D([(0,r.property)({type:String})],pn.prototype,`duration`,void 0),pn=D([(0,r.customElement)(`ui-3d-flip`)],pn);var q=class extends n.LitElement{constructor(...e){super(...e),this.header=`Queue`,this.emptyText=`No tracks in queue`}static{this.styles=n.css`
|
|
1613
1617
|
:host {
|
|
1614
1618
|
display: block;
|
|
1615
1619
|
background: var(--md-sys-color-surface-container-low, transparent);
|
|
@@ -1684,7 +1688,7 @@ void main() {
|
|
|
1684
1688
|
`)}
|
|
1685
1689
|
</md-list>
|
|
1686
1690
|
`}
|
|
1687
|
-
`}};
|
|
1691
|
+
`}};D([(0,i.consume)({context:E,subscribe:!0})],q.prototype,`playerState`,void 0),D([(0,r.property)({type:String})],q.prototype,`header`,void 0),D([(0,r.property)({type:String})],q.prototype,`emptyText`,void 0),q=D([(0,r.customElement)(`ui-playlist`)],q);var mn=class extends n.LitElement{constructor(...e){super(...e),this.title=`Component`,this.description=``,this.mode=`preview`}static{this.styles=n.css`
|
|
1688
1692
|
:host {
|
|
1689
1693
|
display: block;
|
|
1690
1694
|
border-radius: 12px;
|
|
@@ -1794,7 +1798,7 @@ void main() {
|
|
|
1794
1798
|
</div>
|
|
1795
1799
|
<pre class="code-panel"><code><slot name="code"></slot></code></pre>
|
|
1796
1800
|
</div>
|
|
1797
|
-
`}};
|
|
1801
|
+
`}};D([(0,r.property)({type:String})],mn.prototype,`title`,void 0),D([(0,r.property)({type:String})],mn.prototype,`description`,void 0),D([(0,r.property)({type:String,reflect:!0})],mn.prototype,`mode`,void 0),mn=D([(0,r.customElement)(`ui-showcase-card`)],mn);var J=class extends n.LitElement{constructor(...e){super(...e),this.state=`idle`,this.disabled=!1,this._showFeedback=!1,this._feedbackType=null}static{this.styles=n.css`
|
|
1798
1802
|
:host {
|
|
1799
1803
|
display: inline-block;
|
|
1800
1804
|
--ui-waveform-height: 24px;
|
|
@@ -1864,13 +1868,13 @@ void main() {
|
|
|
1864
1868
|
}
|
|
1865
1869
|
`}updated(e){super.updated(e);let t=this._context?.state||this.state;(e.has(`_context`)||e.has(`state`))&&(t===`success`||t===`error`)&&(this._showFeedback=!0,this._feedbackType=t,this._feedbackTimeout&&clearTimeout(this._feedbackTimeout),this._feedbackTimeout=setTimeout(()=>{this._showFeedback=!1,this._feedbackType=null,!this._context&&(this.state===`success`||this.state===`error`)&&(this.state=`idle`)},1500))}render(){let e=this._context?.state||this.state,t=e===`recording`,r=e===`processing`||e===`connecting`,i=t||r,a=this.disabled||r,o={recording:t,processing:r,success:this._feedbackType===`success`,error:this._feedbackType===`error`},s={"waveform-slot":!0,active:i},c=this._context?.analyserNode||this.analyserNode;return n.html`
|
|
1866
1870
|
<md-filled-button
|
|
1867
|
-
class=${(0,
|
|
1871
|
+
class=${(0,y.classMap)(o)}
|
|
1868
1872
|
?disabled=${a}
|
|
1869
1873
|
@click=${this._handleClick}
|
|
1870
1874
|
>
|
|
1871
1875
|
<div class="wrapper ${i?`active`:``}">
|
|
1872
1876
|
${this.label?n.html`<span>${this.label}</span>`:``}
|
|
1873
|
-
<div class=${(0,
|
|
1877
|
+
<div class=${(0,y.classMap)(s)}>
|
|
1874
1878
|
${i?n.html`
|
|
1875
1879
|
<ui-live-waveform
|
|
1876
1880
|
.active=${t}
|
|
@@ -1892,7 +1896,7 @@ void main() {
|
|
|
1892
1896
|
</div>`:``}
|
|
1893
1897
|
</div>
|
|
1894
1898
|
</md-filled-button>
|
|
1895
|
-
`}_handleClick(e){this._context&&(this._context.state===`idle`?this._context.start():this._context.state===`recording`&&this._context.stop()),this.dispatchEvent(new CustomEvent(`voice-button-click`,{bubbles:!0,composed:!0,detail:{state:this._context?.state||this.state}}))}};
|
|
1899
|
+
`}_handleClick(e){this._context&&(this._context.state===`idle`?this._context.start():this._context.state===`recording`&&this._context.stop()),this.dispatchEvent(new CustomEvent(`voice-button-click`,{bubbles:!0,composed:!0,detail:{state:this._context?.state||this.state}}))}};D([(0,i.consume)({context:A,subscribe:!0})],J.prototype,`_context`,void 0),D([(0,r.property)({type:String})],J.prototype,`state`,void 0),D([(0,r.property)({type:String})],J.prototype,`label`,void 0),D([(0,r.property)({type:String})],J.prototype,`trailing`,void 0),D([(0,r.property)({type:Boolean})],J.prototype,`disabled`,void 0),D([(0,r.property)({attribute:!1})],J.prototype,`analyserNode`,void 0),D([(0,r.state)()],J.prototype,`_showFeedback`,void 0),D([(0,r.state)()],J.prototype,`_feedbackType`,void 0),J=D([(0,r.customElement)(`ui-voice-button`)],J);var Y=class extends n.LitElement{constructor(...e){super(...e),this.disabled=!1,this._showFeedback=!1,this._feedbackType=null}static{this.styles=n.css`
|
|
1896
1900
|
:host {
|
|
1897
1901
|
display: inline-block;
|
|
1898
1902
|
}
|
|
@@ -1970,11 +1974,11 @@ void main() {
|
|
|
1970
1974
|
</div>
|
|
1971
1975
|
`:``}
|
|
1972
1976
|
</div>
|
|
1973
|
-
`}};
|
|
1977
|
+
`}};D([(0,i.consume)({context:A,subscribe:!0})],Y.prototype,`_context`,void 0),D([(0,r.property)({type:String})],Y.prototype,`label`,void 0),D([(0,r.property)({type:Boolean})],Y.prototype,`disabled`,void 0),D([(0,r.state)()],Y.prototype,`_showFeedback`,void 0),D([(0,r.state)()],Y.prototype,`_feedbackType`,void 0),Y=D([(0,r.customElement)(`ui-voice-pill`)],Y);var X=class extends n.LitElement{constructor(...e){super(...e),this._context={state:`idle`,transcript:``,partialTranscript:``,analyserNode:void 0,start:()=>this.start(),stop:()=>this.stop(),cancel:()=>this.cancel()},this.state=`idle`,this.simulation=!1,this.manual=!1,this.transcript=``,this.partialTranscript=``,this._fakeTranscript=[`I`,` am`,` recording`,` a`,` message`,` using`,` atomic`,` components...`]}static{this.styles=n.css`
|
|
1974
1978
|
:host {
|
|
1975
1979
|
display: contents;
|
|
1976
1980
|
}
|
|
1977
|
-
`}willUpdate(e){let t={};e.has(`state`)&&(t.state=this.state),e.has(`transcript`)&&(t.transcript=this.transcript),e.has(`partialTranscript`)&&(t.partialTranscript=this.partialTranscript),Object.keys(t).length>0&&this._updateContext(t)}async start(){if(this._context.state===`idle`){if(this.manual){this.dispatchEvent(new CustomEvent(`speech-request-start`,{bubbles:!0,composed:!0}));return}try{if(this._updateContext({state:`connecting`}),this.simulation)this._analyser=
|
|
1981
|
+
`}willUpdate(e){let t={};e.has(`state`)&&(t.state=this.state),e.has(`transcript`)&&(t.transcript=this.transcript),e.has(`partialTranscript`)&&(t.partialTranscript=this.partialTranscript),Object.keys(t).length>0&&this._updateContext(t)}async start(){if(this._context.state===`idle`){if(this.manual){this.dispatchEvent(new CustomEvent(`speech-request-start`,{bubbles:!0,composed:!0}));return}try{if(this._updateContext({state:`connecting`}),this.simulation)this._analyser=ae();else{let e={audio:!0};this.deviceId&&(e.audio={deviceId:{exact:this.deviceId}}),this._stream=await navigator.mediaDevices.getUserMedia(e),this._audioCtx||=new(window.AudioContext||window.webkitAudioContext);let t=this._audioCtx.createMediaStreamSource(this._stream);this._analyser=this._audioCtx.createAnalyser(),this._analyser.fftSize=256,t.connect(this._analyser)}if(this._updateContext({state:`recording`,analyserNode:this._analyser,transcript:``,partialTranscript:this.simulation?`Listening...`:``}),this.simulation){let e=0;this._transcriptInterval=setInterval(()=>{if(e<this._fakeTranscript.length){e===0&&this._updateContext({partialTranscript:``});let t=this._context.partialTranscript;this._updateContext({partialTranscript:t+this._fakeTranscript[e]}),e++}},500)}this.dispatchEvent(new CustomEvent(`speech-start`,{bubbles:!0,composed:!0,detail:{stream:this._stream}}))}catch(e){console.error(`Failed to start speech recording`,e),this._updateContext({state:`error`,error:e.message})}}}stop(){if(this._context.state===`recording`){if(this.manual){this.dispatchEvent(new CustomEvent(`speech-request-stop`,{bubbles:!0,composed:!0}));return}this._transcriptInterval&&clearInterval(this._transcriptInterval),this._cleanupStream(),this._updateContext({state:`processing`,transcript:this.simulation?this._context.partialTranscript:this.transcript,partialTranscript:``}),this.dispatchEvent(new CustomEvent(`speech-stop`,{bubbles:!0,composed:!0})),this.simulation&&setTimeout(()=>{this._context.state===`processing`&&(this._updateContext({state:`success`}),setTimeout(()=>this.cancel(),2e3))},1500)}}cancel(){this._transcriptInterval&&clearInterval(this._transcriptInterval),this._cleanupStream(),this._updateContext({state:`idle`,transcript:``,partialTranscript:``,analyserNode:void 0}),this.dispatchEvent(new CustomEvent(`speech-cancel`,{bubbles:!0,composed:!0}))}_cleanupStream(){this._stream&&=(this._stream.getTracks().forEach(e=>e.stop()),void 0)}_updateContext(e){this._context={...this._context,...e},e.state&&(this.state=e.state),this.dispatchEvent(new CustomEvent(`state-change`,{bubbles:!0,composed:!0,detail:this._context}))}render(){return n.html`<slot></slot>`}};D([(0,i.provide)({context:A}),(0,r.state)()],X.prototype,`_context`,void 0),D([(0,r.property)({type:String})],X.prototype,`state`,void 0),D([(0,r.property)({type:Boolean})],X.prototype,`simulation`,void 0),D([(0,r.property)({type:Boolean})],X.prototype,`manual`,void 0),D([(0,r.property)({type:String})],X.prototype,`transcript`,void 0),D([(0,r.property)({type:String})],X.prototype,`partialTranscript`,void 0),D([(0,r.property)({type:String})],X.prototype,`deviceId`,void 0),X=D([(0,r.customElement)(`ui-speech-provider`)],X);var Z=class extends n.LitElement{constructor(...e){super(...e),this.agentId=``,this.simulation=!1,this._keyboardOpen=!1,this._textInput=``,this._isMuted=!1}static{this.styles=n.css`
|
|
1978
1982
|
:host {
|
|
1979
1983
|
display: block;
|
|
1980
1984
|
width: 100%;
|
|
@@ -2130,7 +2134,7 @@ void main() {
|
|
|
2130
2134
|
</div>
|
|
2131
2135
|
</div>
|
|
2132
2136
|
</ui-speech-provider>
|
|
2133
|
-
`}_handleKeyDown(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),this._sendMessage())}_sendMessage(){this._textInput.trim()&&(this.dispatchEvent(new CustomEvent(`message-sent`,{detail:{message:this._textInput},bubbles:!0,composed:!0})),this._textInput=``)}_handleCallToggle(){this.dispatchEvent(new CustomEvent(`call-toggle`,{bubbles:!0,composed:!0}))}};
|
|
2137
|
+
`}_handleKeyDown(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),this._sendMessage())}_sendMessage(){this._textInput.trim()&&(this.dispatchEvent(new CustomEvent(`message-sent`,{detail:{message:this._textInput},bubbles:!0,composed:!0})),this._textInput=``)}_handleCallToggle(){this.dispatchEvent(new CustomEvent(`call-toggle`,{bubbles:!0,composed:!0}))}};D([(0,r.property)({type:String})],Z.prototype,`agentId`,void 0),D([(0,r.property)({type:Boolean})],Z.prototype,`simulation`,void 0),D([(0,r.state)()],Z.prototype,`_keyboardOpen`,void 0),D([(0,r.state)()],Z.prototype,`_textInput`,void 0),D([(0,r.state)()],Z.prototype,`_isMuted`,void 0),Z=D([(0,r.customElement)(`ui-conversation-bar`)],Z);var hn=class extends n.LitElement{constructor(...e){super(...e),this.state=`idle`}static{this.styles=n.css`
|
|
2134
2138
|
:host {
|
|
2135
2139
|
display: inline-block;
|
|
2136
2140
|
}
|
|
@@ -2154,7 +2158,7 @@ void main() {
|
|
|
2154
2158
|
|
|
2155
2159
|
${this.state===`recording`?`Recording...`:`Speak`}
|
|
2156
2160
|
</md-filled-button>
|
|
2157
|
-
`}_handleClick(){this.state=this.state===`idle`?`recording`:`idle`,this.dispatchEvent(new CustomEvent(`voice-toggle`,{bubbles:!0,composed:!0,detail:{state:this.state}}))}};
|
|
2161
|
+
`}_handleClick(){this.state=this.state===`idle`?`recording`:`idle`,this.dispatchEvent(new CustomEvent(`voice-toggle`,{bubbles:!0,composed:!0,detail:{state:this.state}}))}};D([(0,r.property)({type:String})],hn.prototype,`state`,void 0),hn=D([(0,r.customElement)(`scream-voice-button`)],hn);var gn=class extends n.LitElement{static{this.styles=n.css`
|
|
2158
2162
|
:host {
|
|
2159
2163
|
display: inline-flex;
|
|
2160
2164
|
align-items: center;
|
|
@@ -2168,7 +2172,7 @@ void main() {
|
|
|
2168
2172
|
<ui-typing-dot delay="0s"></ui-typing-dot>
|
|
2169
2173
|
<ui-typing-dot delay="0.2s"></ui-typing-dot>
|
|
2170
2174
|
<ui-typing-dot delay="0.4s"></ui-typing-dot>
|
|
2171
|
-
`}};
|
|
2175
|
+
`}};gn=D([(0,r.customElement)(`ui-typing-indicator`)],gn);var Q=class extends n.LitElement{constructor(...e){super(...e),this.direction=`inbound`,this.variant=`contained`}static{this.styles=n.css`
|
|
2172
2176
|
:host {
|
|
2173
2177
|
display: block;
|
|
2174
2178
|
margin-bottom: var(--ui-chat-item-margin-bottom, 8px);
|
|
@@ -2220,7 +2224,7 @@ void main() {
|
|
|
2220
2224
|
<slot></slot>
|
|
2221
2225
|
</ui-message-bubble>
|
|
2222
2226
|
</div>
|
|
2223
|
-
`}};
|
|
2227
|
+
`}};D([(0,r.property)({type:String})],Q.prototype,`direction`,void 0),D([(0,r.property)({type:String})],Q.prototype,`variant`,void 0),D([(0,r.property)({type:String})],Q.prototype,`avatarSrc`,void 0),D([(0,r.property)({type:String})],Q.prototype,`avatarName`,void 0),Q=D([(0,r.customElement)(`ui-chat-item`)],Q);var _n=class extends n.LitElement{constructor(...e){super(...e),this._isAtBottom=!0}static{this.styles=n.css`
|
|
2224
2228
|
:host {
|
|
2225
2229
|
display: block;
|
|
2226
2230
|
height: 100%;
|
|
@@ -2281,18 +2285,17 @@ void main() {
|
|
|
2281
2285
|
>
|
|
2282
2286
|
<md-icon>arrow_downward</md-icon>
|
|
2283
2287
|
</md-icon-button>
|
|
2284
|
-
`}};
|
|
2288
|
+
`}};D([(0,r.query)(`.scroll-container`)],_n.prototype,`_container`,void 0),D([(0,r.state)()],_n.prototype,`_isAtBottom`,void 0),_n=D([(0,r.customElement)(`ui-chat-list`)],_n);var $=class extends n.LitElement{constructor(...e){super(...e),this.src=``,this.items=[],this.autoAdvance=!0,this._animationFrameId=0,this.state={src:``,isPlaying:!1,isBuffering:!1,currentTime:0,duration:0,volume:1,muted:!1,items:[],currentIndex:-1,autoAdvance:!0,analyserNode:void 0,play:()=>this.play(),pause:()=>this.pause(),togglePlay:()=>this._togglePlay(),seek:e=>this.seek(e),reset:()=>this.reset(),setVolume:e=>this._setVolume(e),toggleMute:()=>this._toggleMute(),next:()=>this.next(),previous:()=>this.previous(),select:e=>this.select(e)}}static{this.styles=n.css`
|
|
2285
2289
|
:host {
|
|
2286
2290
|
display: contents; /* We are completely invisible, just wrapping children */
|
|
2287
2291
|
}
|
|
2288
2292
|
audio {
|
|
2289
2293
|
display: none;
|
|
2290
2294
|
}
|
|
2291
|
-
`}render(){return n.html`
|
|
2295
|
+
`}clearTextCache(){dn()}render(){return n.html`
|
|
2292
2296
|
<audio
|
|
2293
2297
|
crossorigin="anonymous"
|
|
2294
2298
|
src="${this.src}"
|
|
2295
|
-
?loop="${this.loop}"
|
|
2296
2299
|
preload="metadata"
|
|
2297
2300
|
@loadedmetadata="${this._handleLoadedMetadata}"
|
|
2298
2301
|
@ended="${this._handleEnded}"
|
|
@@ -2305,7 +2308,7 @@ void main() {
|
|
|
2305
2308
|
@error="${this._handleError}"
|
|
2306
2309
|
></audio>
|
|
2307
2310
|
<slot></slot>
|
|
2308
|
-
`}willUpdate(e){e.has(`src`)&&this._updateState({src:this.src,currentTime:0,error:void 0}),e.has(`items`)&&(this._updateState({items:this.items}),this.items.length>0&&!this.src&&this.state.currentIndex===-1&&this.select(0)),e.has(`autoAdvance`)&&this._updateState({autoAdvance:this.autoAdvance})
|
|
2311
|
+
`}willUpdate(e){e.has(`src`)&&this._updateState({src:this.src,currentTime:0,error:void 0}),e.has(`items`)&&(this._updateState({items:this.items}),this.items.length>0&&!this.src&&this.state.currentIndex===-1&&this.select(0)),e.has(`autoAdvance`)&&this._updateState({autoAdvance:this.autoAdvance})}updated(e){e.has(`src`)&&this._audioEl&&(this._audioEl.load(),this.state.isPlaying&&setTimeout(()=>{this.play()},50))}disconnectedCallback(){super.disconnectedCallback(),this._animationFrameId&&cancelAnimationFrame(this._animationFrameId),this._audioContext&&this._audioContext.state!==`closed`&&this._audioContext.close()}_updateState(e){this.state={...this.state,...e},this.dispatchEvent(new CustomEvent(`state-change`,{detail:this.state,bubbles:!0,composed:!0}))}_setupAudioContext(){if(!(this._audioContext||!this._audioEl))try{this._audioContext=new(window.AudioContext||window.webkitAudioContext),this._analyserNode=this._audioContext.createAnalyser(),this._analyserNode.fftSize=256,this._analyserNode.smoothingTimeConstant=.8,this._mediaSource=this._audioContext.createMediaElementSource(this._audioEl),this._mediaSource.connect(this._analyserNode),this._analyserNode.connect(this._audioContext.destination),this._updateState({analyserNode:this._analyserNode})}catch(e){console.warn(`Failed to set up AudioContext for visualizer:`,e)}}play(){this._audioEl.src&&(this._setupAudioContext(),this._audioContext?.state===`suspended`&&this._audioContext.resume(),this._audioEl.play().catch(e=>{console.error(`Error playing audio`,e),this._updateState({error:`Playback failed`})}))}pause(){this._audioEl&&this._audioEl.pause()}_togglePlay(){this.state.isPlaying?this.pause():this.play()}seek(e){this._audioEl&&(this._audioEl.currentTime=e,this._updateState({currentTime:e}))}reset(){this.seek(0)}_setVolume(e){this._audioEl&&(this._audioEl.volume=e,this._updateState({volume:e,muted:e===0}))}_toggleMute(){this._audioEl&&(this._audioEl.muted=!this._audioEl.muted,this._updateState({muted:this._audioEl.muted}))}next(){if(this.items.length===0)return;let e=(this.state.currentIndex+1)%this.items.length;this.select(e)}previous(){if(this.items.length===0)return;let e=(this.state.currentIndex-1+this.items.length)%this.items.length;this.select(e)}select(e){if(e>=0&&e<this.items.length){let t=this.items[e];this.src=t.src,this._updateState({currentIndex:e,src:t.src,currentTime:0,transcript:t.transcript})}}_handleLoadedMetadata(){this._updateState({duration:this._audioEl.duration})}_handleEnded(){this.autoAdvance&&this.items.length>0?this.next():(this._updateState({isPlaying:!1,currentTime:0}),this._audioEl.currentTime=0)}_handlePlaying(){this._updateState({isPlaying:!0,isBuffering:!1,error:void 0}),this._startTrackingTime()}_handlePause(){this._updateState({isPlaying:!1}),this._animationFrameId&&cancelAnimationFrame(this._animationFrameId)}_handleError(e){if(e&&e.target){let t=e.target.error;console.error(`HTML5 Audio Error:`,t?.code,t?.message)}this._updateState({error:`Error loading audio`,isPlaying:!1,isBuffering:!1})}_startTrackingTime(){let e=()=>{this._audioEl&&this.state.isPlaying&&(Math.abs(this.state.currentTime-this._audioEl.currentTime)>.05&&this._updateState({currentTime:this._audioEl.currentTime}),this._animationFrameId=requestAnimationFrame(e))};this._animationFrameId=requestAnimationFrame(e)}};D([(0,r.property)({type:String})],$.prototype,`src`,void 0),D([(0,r.property)({type:Array})],$.prototype,`items`,void 0),D([(0,r.property)({type:Boolean})],$.prototype,`autoAdvance`,void 0),D([(0,r.query)(`audio`)],$.prototype,`_audioEl`,void 0),D([(0,i.provide)({context:E}),(0,r.state)()],$.prototype,`state`,void 0),$=D([(0,r.customElement)(`ui-audio-provider`)],$);var vn=class extends n.LitElement{static{this.styles=n.css`
|
|
2309
2312
|
:host {
|
|
2310
2313
|
display: inline-block;
|
|
2311
2314
|
width: 100%;
|
|
@@ -2352,4 +2355,4 @@ void main() {
|
|
|
2352
2355
|
<ui-audio-player-error></ui-audio-player-error>
|
|
2353
2356
|
</div>
|
|
2354
2357
|
</ui-audio-provider>
|
|
2355
|
-
`}};
|
|
2358
|
+
`}};D([(0,r.property)({type:Object})],vn.prototype,`item`,void 0),vn=D([(0,r.customElement)(`ui-audio-player`)],vn),Object.defineProperty(e,`ScreamVoiceButton`,{enumerable:!0,get:function(){return hn}}),Object.defineProperty(e,`Ui3dFlip`,{enumerable:!0,get:function(){return pn}}),Object.defineProperty(e,`UiAudioNextButton`,{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,`UiAudioPlayButton`,{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,`UiAudioPlayer`,{enumerable:!0,get:function(){return vn}}),Object.defineProperty(e,`UiAudioPlayerError`,{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,`UiAudioPrevButton`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,`UiAudioProgressSlider`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,`UiAudioProvider`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,`UiAudioTimeDisplay`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,`UiAudioVolumeSlider`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,`UiChatItem`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,`UiChatList`,{enumerable:!0,get:function(){return _n}}),Object.defineProperty(e,`UiConversationBar`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,`UiLiveWaveform`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,`UiMessageBubble`,{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,`UiMicSelector`,{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,`UiMovingGradient`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(e,`UiOrb`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,`UiPlaylist`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,`UiScrollingWaveform`,{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,`UiShimmeringText`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,`UiShowcaseCard`,{enumerable:!0,get:function(){return mn}}),Object.defineProperty(e,`UiSpectrumVisualizer`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,`UiSpeechCancelButton`,{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,`UiSpeechPreview`,{enumerable:!0,get:function(){return fn}}),Object.defineProperty(e,`UiSpeechProvider`,{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,`UiSpeechRecordButton`,{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,`UiTimedText`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,`UiTypingDot`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,`UiTypingIndicator`,{enumerable:!0,get:function(){return gn}}),Object.defineProperty(e,`UiVoiceButton`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,`UiVoicePicker`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,`UiVoicePill`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,`UiVoiceWaveform`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,`UiWaveform`,{enumerable:!0,get:function(){return z}}),e.applyCanvasEdgeFade=le,e.audioPlayerContext=E,e.computeAudioPeaks=de,e.createAudioAnalyser=oe,e.createMockAnalyser=ae,e.formatAudioTime=ue,e.generateRandomAudioData=ce,e.getNormalizedFrequencyData=se,e.speechContext=A});
|