import{d as p,aP as v,aQ as _,h as d,p as O,B as y,bA as h,o as g,c as k,n as A,bL as N}from"./index-CLaD8_x-.js";import{u as c}from"./queue-BK-P0Xgt.js";const Y=p({__name:"BasicTextarea",props:{modelValue:{default:""},modelModifiers:{}},emits:v(["submit"],["update:modelValue"]),setup(n,{emit:o}){const t=o,a=_(n,"modelValue"),e=d(),i=d({height:"auto",overflowY:"hidden"});function l(s){s.target instanceof HTMLTextAreaElement&&(s.target.style.height="auto",s.target.style.height=`${s.target.scrollHeight}px`)}function M(s){var r,u;if(s.target instanceof HTMLTextAreaElement)if(s.code==="Enter"&&s.shiftKey){s.preventDefault();const E=(r=s.target)==null?void 0:r.selectionStart,T=(u=s.target)==null?void 0:u.selectionEnd;a.value=`${a.value.substring(0,E)} ${a.value.substring(T)}`,i.value.height="0",N().then(()=>{e.value&&(e.value.selectionStart=e.value.selectionEnd=E+1,i.value.height=`${e.value.scrollHeight}px`)})}else s.code==="Enter"&&(s.preventDefault(),t("submit",a.value))}return O(()=>{e.value&&(i.value.height=`${e.value.scrollHeight}px`)}),(s,r)=>y((g(),k("textarea",{ref_key:"textareaRef",ref:e,"onUpdate:modelValue":r[0]||(r[0]=u=>a.value=u),style:A(i.value),onInput:l,onKeydown:M},null,36)),[[h,a.value]])}});var m=(n=>(n.Happy="<|EMOTE_HAPPY|>",n.Sad="<|EMOTE_SAD|>",n.Angry="<|EMOTE_ANGRY|>",n.Think="<|EMOTE_THINK|>",n.Surprise="<|EMOTE_SURPRISE|>",n.Awkward="<|EMOTE_AWKWARD|>",n.Question="<|EMOTE_QUESTION|>",n))(m||{});const f=Object.values(m),S="Tap",w="EmotionSad",D="Tap@Body",R="FlickDown",I="Flick",x="Flick",H="Flick@Body",Q={"<|EMOTE_HAPPY|>":S,"<|EMOTE_SAD|>":w,"<|EMOTE_ANGRY|>":D,"<|EMOTE_THINK|>":I,"<|EMOTE_SURPRISE|>":x,"<|EMOTE_AWKWARD|>":R,"<|EMOTE_QUESTION|>":H},U={"<|EMOTE_HAPPY|>":"happy","<|EMOTE_SAD|>":"sad","<|EMOTE_ANGRY|>":"angry","<|EMOTE_THINK|>":void 0,"<|EMOTE_SURPRISE|>":"surprised","<|EMOTE_AWKWARD|>":void 0,"<|EMOTE_QUESTION|>":void 0},b="<|llm_inference_end|>";function B(n){function o(t){for(const a of f)if(t.includes(a))return{ok:!0,emotion:a};return{ok:!1,emotion:""}}return c({handlers:[async t=>{if(f.includes(t.data)){t.emit("emotion",t.data),await n.add(t.data);return}{const{ok:a,emotion:e}=o(t.data);a&&(t.emit("emotion",e),await n.add(e))}}]})}function L(){function n(t){if(!/<\|DELAY:\d+\|>/i.test(t))return{ok:!1,delay:0};const a=/<\|DELAY:(\d+)\|>/i.exec(t),e=a==null?void 0:a[1];if(!e)return{ok:!1,delay:0};const i=Number.parseFloat(e);return i<=0||Number.isNaN(i)?{ok:!0,delay:0}:{ok:!0,delay:i}}function o(t){return new Promise(a=>setTimeout(a,t))}return c({handlers:[async t=>{const{ok:a,delay:e}=n(t.data);a&&(t.emit("delay",e),await o(e*1e3))}]})}function V(n){const o=d("");return c({handlers:[async t=>{if(t.data===b){const e=o.value.trim();e&&await n.add(e),o.value="";return}const a=/[.?!]/;for(o.value+=t.data;o.value;){const e=a.exec(o.value);if(!e||typeof e.index>"u")break;const i=o.value.slice(0,e.index+1),l=o.value.slice(e.index+1);await n.add(i),o.value=l}}]})}export{x as E,Y as _,w as a,D as b,S as c,R as d,H as e,I as f,f as g,B as h,L as i,U as j,Q as k,b as l,V as u};