import{B as e,Bt as t,Ct as n,F as r,L as i,N as a,Nt as o,Pt as s,R as c,Vt as l,X as u,Y as d,_t as f,a as p,at as m,bt as h,ft as g,g as _,it as v,o as y,ot as b,pt as x,u as S,vt as C}from"./BT3KAag_.js";import"./t62M88qj.js";import"./BZnJ8tbJ.js";import{t as w}from"./DPNVpxC52.js";import{t as T}from"./DZzqmhRV2.js";var E=e(`<title> </title>`),D=e(`<svg><!><path d="M23,14v3A7,7,0,0,1,9,17V14H7v3a9,9,0,0,0,8,8.94V28H11v2H21V28H17V25.94A9,9,0,0,0,25,17V14Z"></path><path d="M16,22a5,5,0,0,0,5-5V7A5,5,0,0,0,11,7V17A5,5,0,0,0,16,22Z"></path></svg>`);function O(e,n){let c=p(n,[`children`,`$$slots`,`$$events`,`$$legacy`]),h=p(c,[`size`,`title`]);s(n,!1);let x=f(),w=f(),T=y(n,`size`,8,16),O=y(n,`title`,8,void 0);v(()=>(d(c),d(O())),()=>{C(x,c[`aria-label`]||c[`aria-labelledby`]||O())}),v(()=>(u(x),d(c)),()=>{C(w,{"aria-hidden":u(x)?void 0:!0,role:u(x)?`img`:void 0,focusable:Number(c.tabindex)===0?!0:void 0})}),m(),S();var k=D();_(k,()=>({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,fill:`currentColor`,preserveAspectRatio:`xMidYMid meet`,width:T(),height:T(),...u(w),...h}));var A=g(k),j=e=>{var t=E(),n=g(t,!0);l(t),b(()=>r(n,O())),i(e,t)};a(A,e=>{O()&&e(j)}),t(2),l(k),i(e,k),o()}function k(e,t){s(t,!0);let r=y(t,`size`,3,16),l=y(t,`disabled`,3,!1),d=y(t,`class`,3,``),f=n(()=>t.dictation.listening?`Stop dictation`:`Dictate`);var p=c(),m=x(p),h=e=>{{let o=n(()=>t.dictation.listening?`mic-listening`:``),s=n(d);w(e,{variant:`ghost`,size:`icon`,get class(){return`mic-btn ${u(o)??``} ${u(s)??``}`},get title(){return u(f)},get"aria-label"(){return u(f)},get"aria-pressed"(){return t.dictation.listening},get disabled(){return l()},onclick:()=>t.dictation.toggle(),children:(e,n)=>{var o=c(),s=x(o),l=e=>{O(e,{get size(){return r()}})},u=e=>{T(e,{get size(){return r()}})};a(s,e=>{t.dictation.listening?e(l):e(u,-1)}),i(e,o)},$$slots:{default:!0}})}};a(m,e=>{t.dictation.supported&&e(h)}),i(e,p),o()}function A(e,t){if(typeof CSS<`u`&&CSS.supports?.(`field-sizing`,`content`))return{};let n=()=>{e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`};return n(),e.addEventListener(`input`,n),{update(){n()},destroy(){e.removeEventListener(`input`,n)}}}function j(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function M(e,t){return t?e?/\s$/.test(e)?e+t:e+` `+t:t:e}function N(e){let t=j(),n=h(!1),r=h(``),i=h(null),a=null,o=``,s=``;function c(){e.setValue(M(o,M(s,u(r))))}function l(){if(!t||u(n))return;C(i,null);let l=new t,d=typeof document<`u`?document.documentElement.lang:``;l.lang=e.lang||d||`en-US`,l.continuous=!0,l.interimResults=!0,l.maxAlternatives=1,o=e.getValue(),s=``,C(r,``),l.onresult=e=>{let t=``;for(let n=e.resultIndex;n<e.results.length;n++){let r=e.results[n],i=r[0]?.transcript??``;r.isFinal?s=M(s,i.trim()):t+=i}C(r,t,!0),c()},l.onerror=e=>{C(i,e.error,!0)},l.onend=()=>{C(r,``),c(),C(n,!1),a=null},a=l;try{l.start(),C(n,!0)}catch{a=null}}function d(){a&&a.stop()}return{get supported(){return t!==null},get listening(){return u(n)},get interim(){return u(r)},get error(){return u(i)},toggle(){u(n)?d():l()},stop:d}}export{A as n,k as r,N as t};