"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("primereact/utils"),o=require("primereact/tooltip"),n=require("primereact/ripple");function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=r(t);function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var o=0;o0&&this.props.offLabel&&this.props.offLabel.length>0}},{key:"hasIcon",value:function(){return this.props.onIcon&&this.props.onIcon.length>0&&this.props.offIcon&&this.props.offIcon.length>0}},{key:"getLabel",value:function(){return this.hasLabel()?this.props.checked?this.props.onLabel:this.props.offLabel:" "}},{key:"componentDidMount",value:function(){this.props.tooltip&&this.renderTooltip()}},{key:"componentDidUpdate",value:function(t){t.tooltip===this.props.tooltip&&t.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(d({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip())}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=o.tip({target:this.container,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"render",value:function(){var t=this,o=e.classNames("p-button p-togglebutton p-component",{"p-button-icon-only":this.hasIcon()&&!this.hasLabel(),"p-highlight":this.props.checked,"p-disabled":this.props.disabled},this.props.className),r=null,p=this.hasIcon(),s=this.getLabel(),l=this.props.checked?this.props.onIcon:this.props.offIcon;return p&&(r=e.classNames("p-button-icon p-c",{"p-button-icon-left":"left"===this.props.iconPos&&s,"p-button-icon-right":"right"===this.props.iconPos&&s})),i.default.createElement("div",{ref:function(e){return t.container=e},id:this.props.id,className:o,style:this.props.style,onClick:this.toggle,onFocus:this.props.onFocus,onBlur:this.props.onBlur,onKeyDown:this.onKeyDown,tabIndex:!this.props.disabled&&this.props.tabIndex,"aria-labelledby":this.props.ariaLabelledBy},p&&e.IconUtils.getJSXIcon(l,{className:r},{props:this.props}),i.default.createElement("span",{className:"p-button-label"},s),i.default.createElement(n.Ripple,null))}}])&&s(b.prototype,y),v&&s(b,v),Object.defineProperty(b,"prototype",{writable:!1}),O}();b(v,"defaultProps",{id:null,onIcon:null,offIcon:null,onLabel:"Yes",offLabel:"No",iconPos:"left",style:null,className:null,checked:!1,tabIndex:0,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,onChange:null,onFocus:null,onBlur:null}),exports.ToggleButton=v;