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