"use client";var O=Object.create;var h=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var D=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports);var K=(t,n,a,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of R(n))!k.call(t,e)&&e!==a&&h(t,e,{get:()=>n[e],enumerable:!(s=P(n,e))||s.enumerable});return t};var U=(t,n,a)=>(a=t!=null?O(j(t)):{},K(n||!t||!t.__esModule?h(a,"default",{value:t,enumerable:!0}):a,t));var E=D((W,m)=>{(function(){"use strict";var t={}.hasOwnProperty;function n(){for(var e="",o=0;o<arguments.length;o++){var u=arguments[o];u&&(e=s(e,a(u)))}return e}function a(e){if(typeof e=="string"||typeof e=="number")return e;if(typeof e!="object")return"";if(Array.isArray(e))return n.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var o="";for(var u in e)t.call(e,u)&&e[u]&&(o=s(o,u));return o}function s(e,o){return o?e?e+" "+o:e+o:e}typeof m<"u"&&m.exports?(n.default=n,m.exports=n):typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("classnames",[],function(){return n}):window.classNames=n})()});import T from"react";var p=U(E());import i,{useState as x}from"react";import{useEffect as A,useRef as q}from"react";function b(t){let n=q(null);return A(()=>{t&&(typeof t=="function"?t(n.current):t.current=n.current)},[n,t]),n}var I=i.forwardRef(function({label:n,clearable:a=!0,errorMessage:s,onChange:e,onValueChange:o,onEnter:u,...l},c){let f=b(c),[d,C]=x(g(l.value)),[w,y]=x(!1);function g(r){return r!==""&&r!==void 0}function F(r){let v=r.currentTarget.value;f.current&&(f.current.value=v),e?.(r),o?.(v),C(g(r.target.value))}function H(r){l.onFocus?.(r),y(!0)}function N(r){l.onBlur?.(r),y(!1)}function M(r){l.onKeyDown?.(r),r.key==="Enter"&&u?.(r.currentTarget.value)}function V(){L("")}function L(r){if(!f.current)return;Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set?.call(f.current,r);let B=new Event("input",{bubbles:!0});f.current.dispatchEvent(B)}let S=a&&d&&!l.disabled&&!l.readOnly;return i.createElement("div",{className:(0,p.default)("leaf-input-container","leaf-text-input",{filled:d,focused:w,error:!!s,disabled:l.disabled})},i.createElement("div",{className:"leaf-label-area"},n&&i.createElement("label",{className:"leaf-label"},n)),i.createElement("div",{className:(0,p.default)("leaf-input-area")},i.createElement("input",{...l,className:(0,p.default)("leaf-input",{clearable:a},l.className),ref:f,onChange:F,onFocus:H,onBlur:N,onKeyDown:M}),S&&i.createElement("button",{type:"button",className:"leaf-clear-button",onClick:V,tabIndex:-1})),i.createElement("div",{className:"leaf-extra-area"},s&&i.createElement("p",{className:(0,p.default)("leaf-error-message","leaf-desc")},s)))});import{Controller as z}from"react-hook-form";function G(t){let{name:n,rules:a,defaultValue:s,control:e,shouldUnregister:o,...u}=t,l={name:n,rules:a,defaultValue:s,shouldUnregister:o};return e&&(l.control=e),T.createElement(z,{...l,render:({field:c,fieldState:f})=>T.createElement(I,{...u,name:c.name,value:c.value,ref:c.ref,onValueChange:d=>{c.onChange(d),u.onValueChange?.(d)},onBlur:d=>{c.onBlur(),u.onBlur?.(d)},errorMessage:f.error?.message})})}export{G as default};
/*! Bundled license information:

classnames/index.js:
  (*!
  	Copyright (c) 2018 Jed Watson.
  	Licensed under the MIT License (MIT), see
  	http://jedwatson.github.io/classnames
  *)
*/
