import{C as B,r as l,u as N,P as T,a as _,O as s,q as p,c as I,T as C}from"./index-BsAdyuxG.js";import{K as f}from"./keyfilter.esm-Bp4LdhxN.js";function y(){return y=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)({}).hasOwnProperty.call(o,r)&&(n[r]=o[r])}return n},y.apply(null,arguments)}function u(n){"@babel/helpers - typeof";return u=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(n)}function F(n,t){if(u(n)!="object"||!n)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var r=o.call(n,t||"default");if(u(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function M(n){var t=F(n,"string");return u(t)=="symbol"?t:t+""}function R(n,t,o){return(t=M(t))in n?Object.defineProperty(n,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[t]=o,n}var U={root:function(t){var o=t.props,r=t.isFilled,e=t.context;return I("p-inputtext p-component",{"p-disabled":o.disabled,"p-filled":r,"p-invalid":o.invalid,"p-variant-filled":o.variant?o.variant==="filled":e&&e.inputStyle==="filled"})}},c=B.extend({defaultProps:{__TYPE:"InputText",__parentMetadata:null,children:void 0,className:null,invalid:!1,variant:null,keyfilter:null,onBeforeInput:null,onInput:null,onKeyDown:null,onPaste:null,tooltip:null,tooltipOptions:null,validateOnly:!1,iconPosition:null},css:{classes:U}});function g(n,t){var o=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),o.push.apply(o,r)}return o}function x(n){for(var t=1;t<arguments.length;t++){var o=arguments[t]!=null?arguments[t]:{};t%2?g(Object(o),!0).forEach(function(r){R(n,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):g(Object(o)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(o,r))})}return n}var H=l.memo(l.forwardRef(function(n,t){var o=N(),r=l.useContext(T),e=c.getProps(n,r),d=c.setMetaData(x(x({props:e},e.__parentMetadata),{},{context:{disabled:e.disabled,iconPosition:e.iconPosition}})),P=d.ptm,j=d.cx,w=d.isUnstyled;_(c.css.styles,w,{name:"inputtext",styled:!0});var i=l.useRef(t),E=function(a){e.onKeyDown&&e.onKeyDown(a),e.keyfilter&&f.onKeyPress(a,e.keyfilter,e.validateOnly)},D=function(a){e.onBeforeInput&&e.onBeforeInput(a),e.keyfilter&&f.onBeforeInput(a,e.keyfilter,e.validateOnly)},S=function(a){var b=a.target,O=!0;e.keyfilter&&e.validateOnly&&(O=f.validate(a,e.keyfilter)),e.onInput&&e.onInput(a,O),s.isNotEmpty(b.value)?p.addClass(b,"p-filled"):p.removeClass(b,"p-filled")},h=function(a){e.onPaste&&e.onPaste(a),e.keyfilter&&f.onPaste(a,e.keyfilter,e.validateOnly)};l.useEffect(function(){s.combinedRefs(i,t)},[i,t]);var m=l.useMemo(function(){return s.isNotEmpty(e.value)||s.isNotEmpty(e.defaultValue)},[e.value,e.defaultValue]),K=s.isNotEmpty(e.tooltip);l.useEffect(function(){m?p.addClass(i.current,"p-filled"):p.removeClass(i.current,"p-filled")},[e.disabled,m]);var k=o({className:I(e.className,j("root",{context:r,isFilled:m})),onBeforeInput:D,onInput:S,onKeyDown:E,onPaste:h},c.getOtherProps(e),P("root"));return l.createElement(l.Fragment,null,l.createElement("input",y({ref:i},k)),K&&l.createElement(C,y({target:i,content:e.tooltip,pt:P("tooltip")},e.tooltipOptions)))}));H.displayName="InputText";export{H as I};
