import{m as x}from"./BGlfPyXw.js";import{d as k,r as h,aZ as H,x as m,y as v,z as K,a5 as R,a9 as M,v as f,a8 as P,B as C,a1 as V,a2 as D,ad as I}from"./D3l4Cb4m.js";import{_ as U}from"./BrmPz7i0.js";const F={relative:"","z-9":"","h-full":"","text-3.5":""},G={text:"black/26",absolute:"","z--1":""},O={key:0,absolute:"","inset-0":"","z-99":"","cursor-not-allowed":""},X=k({__name:"input",props:{placeholder:{default:""},disabled:{type:Boolean,default:!1}},emits:["enter","input"],setup(w,{expose:g,emit:p}){const s=w,c=p;g({onSetEmoji:L,onGetValue:$,onSetText:S}),window.envConfig.VITE_PUBLIC_URL;const{emojiCodec:u}=x(),n=h(),o=h(""),r=h();H(()=>{var e,t,l,d;s.disabled?((e=n.value)==null||e.blur(),(t=n.value)==null||t.removeAttribute("contenteditable"),y()):((l=n.value)==null||l.focus(),(d=n.value)==null||d.setAttribute("contenteditable",!0))});function E(e){var t;o.value=(t=e.target)==null?void 0:t.innerHTML,c("input",o.value)}function B(e){e.preventDefault(),navigator.clipboard.readText().then(t=>{_(t)})}function _(e,t="text"){var d;const l=window.getSelection();if(l&&l.rangeCount>0){const a=l.getRangeAt(0);a.deleteContents();let i;if(t==="text")i=document.createTextNode(e);else if(t==="img")i=document.createElement("img"),i.src=e;else if(t==="br"){i=document.createElement("br");const b=a.cloneRange();b.selectNodeContents(n.value),b.setEnd(a.endContainer,a.endOffset);const z=n.value.innerHTML.toString().search(/<br\s*\/?>$/)!==-1;b.toString()===n.value.textContent&&!z&&a.insertNode(document.createElement("br"))}else return;a.insertNode(i),a.setStartAfter(i),a.setEndAfter(i),l.removeAllRanges(),l.addRange(a),a.collapse(!0),o.value=(d=n.value)==null?void 0:d.innerHTML,c("input",o.value)}}function L(e){var t;document.activeElement!==n.value&&((t=n.value)==null||t.focus(),A()),_(e,"img")}function S(e){n.value.innerHTML=e,o.value=e}function T(){const e=window.getSelection();e&&e.rangeCount>0&&(r.value=e.getRangeAt(0).cloneRange())}function A(){if(!r.value)return!1;const e=window.getSelection();e==null||e.removeAllRanges(),e==null||e.addRange(r.value),r.value=null}function $(e=!0){if(!e)return o.value;let t=o.value.replace(/<br\s*\/?>+$/g,"");return t=u(t),y(),t}function y(){o.value="",n.value&&(n.value.innerHTML="")}function j(e){e.key==="Enter"&&(e.preventDefault(),e.ctrlKey||e.metaKey||e.shiftKey||e.altKey?_("","br"):N())}function N(){c("enter")}return(e,t)=>(f(),m("div",F,[v("div",G,K(R(o)?"":s.placeholder),1),s.disabled?(f(),m("div",O)):M("",!0),v("div",{ref_key:"editor",ref:n,contenteditable:"","box-border":"","h-full":"","w-full":"","resize-none":"","overflow-auto":"","outline-none":"",spellcheck:"false",class:"[&_img]:inline-block [&_img]:w-6 [&_img]:align-middle",onInput:E,onPaste:B,onBlur:T,onKeydown:j},null,544)]))}}),Z={grid:"","grid-cols-10":"","h-40":"","gap-1.5":"","p-2":"","overflow-y-scroll":"",class:"cv-scrollbar-small"},q=["src","onClick"],Y=k({__name:"emoji",emits:["change"],setup(w,{emit:g}){const p=g,{emojis:s}=x();function c(u){p("change",u)}return(u,n)=>{const o=U;return f(),P(o,{trigger:"click",arrow:!1,placement:"topLeft","overlay-inner-style":{padding:0}},{content:C(()=>[v("div",Z,[(f(!0),m(V,null,D(R(s),r=>(f(),m("img",{key:r,"h-6":"","w-6":"","cursor-pointer":"",src:r,onClick:E=>c(r)},null,8,q))),128))])]),default:C(()=>[v("i",I({"i-clarity:happy-face-line":"","text-3.5":"","cv-primary-hover":""},u.$attrs),null,16)]),_:1})}}});export{X as _,Y as a};
