import{defineProperty as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as o,jsx as n}from"react/jsx-runtime";import{forwardRef as a,useRef as t,useEffect as i}from"react";import r from"../../hooks/useMergeRefs.js";import s from"../../hooks/useDebounceEvent/index.js";import{NOOP as l}from"../../utils/function-utils.js";import u from"../IconButton/IconButton.js";import c from"../Icon/Icons/components/CloseSmall.js";import d from"classnames";import m from"./Textarea.module.scss.js";var v=a((function(a,v){var p,f=a.placeholder,h=void 0===f?"":f,C=a.autoComplete,g=void 0===C?"off":C,b=a.initialValue,j=a.value,x=a.onChange,I=a.onBlur,F=void 0===I?l:I,S=a.onFocus,y=void 0===S?l:S,L=a.onKeyDown,N=void 0===L?l:L,O=a.onChangeCapture,R=a.debounceRate,k=void 0===R?0:R,w=a.autoFocus,B=void 0!==w&&w,D=a.disabled,V=void 0!==D&&D,_=a.readonly,q=void 0!==_&&_,z=a.setRef,A=void 0===z?l:z,E=a.trim,T=void 0!==E&&E,K=a.id,P=void 0===K?"textarea":K,H=a.required,M=void 0!==H&&H,W=a.name,Y=a.cols,G=a.rows,J=a.maxLenght,Q=void 0===J?1200:J,U=a.minLenght,X=a.onInvalid,Z=a.onInvalidCapture,$=a.onSelect,ee=a.onSelectCapture,oe=a.hint,ne=a.validation,ae=void 0===ne?null:ne,te=a.resize,ie=void 0!==te&&te,re=a.showLetterCount,se=t(null),le=s({delay:k,onChange:x,initialStateValue:j,trim:T}),ue=le.inputValue,ce=le.onEventChanged,de=le.clearValue,me=r({refs:[v,se,A]});return i((function(){if(se.current&&B){var e=requestAnimationFrame((function(){return se.current.focus()}));return function(){return cancelAnimationFrame(e)}}}),[se,B]),o("div",Object.assign({className:d(m.mainWrapper,(p={},e(p,m.status_error,ae&&"error"===ae.status),e(p,m.status_success,ae&&"success"===ae.status),e(p,m.disabled,!0===V),e(p,m.noResize,!1===ie),p))},{children:[V?n("div",{children:"Disabled"}):re&&o("label",Object.assign({htmlFor:P,className:m.labelTop},{children:[ue?ue.length:0,"/",Q]})),ue&&n("div",Object.assign({className:m.clearIcon},{children:n(u,{size:"xxs",ariaLabel:"Remove",hideTooltip:!0,icon:c,onClick:de,kind:u.kinds.SECONDARY})})),n("textarea",{ref:me,id:P,className:m.textarea,value:ue,placeholder:h,autoComplete:g,autoFocus:B,defaultValue:b,cols:Y,rows:G,disabled:V,maxLength:Q,minLength:U,name:W,onBlur:F,onFocus:y,onKeyDown:N,onChange:ce,onChangeCapture:O,onInvalid:X,onInvalidCapture:Z,onSelect:$,onSelectCapture:ee,readOnly:q,required:M}),oe&&n("div",Object.assign({className:m.hint},{children:oe}))]}))}));export{v as default};
