function b(e){const s=e.match(/^(.+?\.(?:eth|gwei))(.*)$/i);return s?{host:s[1],path:s[2]}:{host:e,path:""}}function m(e,s){if(e.textContent="",!s)return;const{host:o,path:a}=b(s),r=document.createElement("span");if(r.className="u-host",r.textContent=o,e.appendChild(r),a){const c=document.createElement("span");c.className="u-path",c.textContent=a,e.appendChild(c)}}function v(e,s){e.setAttribute("contenteditable","plaintext-only"),e.setAttribute("spellcheck","false"),e.setAttribute("role","textbox"),e.setAttribute("aria-label","ENS address"),s.placeholder&&e.setAttribute("data-placeholder",s.placeholder);const o=()=>{const t=s.shadowRoot;return t?.getSelection?t.getSelection()??null:window.getSelection()},a=()=>e.textContent??"",r=()=>{const t=o();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!e.contains(n.endContainer))return null;const l=n.cloneRange();return l.selectNodeContents(e),l.setEnd(n.endContainer,n.endOffset),l.toString().length},c=t=>{const n=o();if(!n)return;const l=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let d=t,u=null,g=0,f;for(;f=l.nextNode();){const h=f.length;if(d<=h){u=f,g=d;break}d-=h}const i=document.createRange();u?i.setStart(u,g):(i.selectNodeContents(e),i.collapse(!1)),i.collapse(!0),n.removeAllRanges(),n.addRange(i)},C=()=>{const t=r();m(e,a()),t!=null&&c(t)};e.addEventListener("input",C),e.addEventListener("keydown",t=>{t.key==="Enter"?(t.preventDefault(),s.onSubmit(a())):t.key==="Escape"&&(t.preventDefault(),s.onEscape?.())}),e.addEventListener("paste",t=>{const n=t.clipboardData?.getData("text/plain");n!=null&&(t.preventDefault(),document.execCommand("insertText",!1,n))});const p={element:e,setValue(t){m(e,t)},getValue(){return a()},selectAll(){const t=o();if(!t)return;const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)},shake(){e.classList.remove("shake"),e.offsetWidth,e.classList.add("shake"),setTimeout(()=>e.classList.remove("shake"),450)}};return e.addEventListener("focus",()=>{setTimeout(()=>p.selectAll(),0)}),p}export{m as c,v as s};
//# sourceMappingURL=chunk-BT7H_Nq3.js.map
