!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("openstack-uicore-foundation",[],t):"object"==typeof exports?exports["openstack-uicore-foundation"]=t():e["openstack-uicore-foundation"]=t()}(this,(()=>(()=>{"use strict";var e={418:(e,t,a)=>{a.d(t,{default:()=>o});var r=a(6689),l=a.n(r);const o=({children:e,replaceNewLine:t=!1,className:a=""})=>l().createElement("span",{className:a,dangerouslySetInnerHTML:{__html:t?null==e?void 0:e.replace(/\n/g,"<br />"):e}})},3838:e=>{e.exports=require("@babel/runtime/helpers/objectWithoutProperties")},6471:e=>{e.exports=require("awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css")},4656:e=>{e.exports=require("i18n-react/dist/i18n-react")},580:e=>{e.exports=require("prop-types")},6689:e=>{e.exports=require("react")}},t={};function a(r){var l=t[r];if(void 0!==l)return l.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,a),o.exports}(()=>{a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t}})(),(()=>{a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}})(),(()=>{a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var r={};return(()=>{a.r(r),a.d(r,{default:()=>d});var e=a(3838),t=a.n(e),l=a(580),o=a.n(l),n=a(6689),s=a.n(n),i=a(4656),c=a.n(i),p=a(418);a(6471);const h=["onChange","value","className","options","id","children","error","disabled","name","ariaLabelledBy"];class d extends s().Component{constructor(e){super(e);let t=!!e.value&&e.value.find((t=>!e.options.map((e=>e.value)).includes(t)));this.state={otherChecked:!!t},this.handleChange=this.handleChange.bind(this),this.handleOtherCBChange=this.handleOtherCBChange.bind(this)}handleChange(e){let t=this.props.options.map((e=>e.value)),a=this.props.value?[...this.props.value]:[];if("checkbox"===e.target.type)if(e.target.checked){const t=isNaN(e.target.value)?e.target.value:parseInt(e.target.value);a.push(t)}else a=a.filter((t=>t!=e.target.value));else a=a.filter((e=>t.includes(e))),a.push(e.target.value);let r={target:{id:this.props.id,value:a,type:"checkboxlist"}};this.props.onChange(r)}handleOtherCBChange(e){this.setState({otherChecked:e.target.checked})}render(){let e,a=this.props,{onChange:r,value:l,className:o,options:n,id:i,children:d,error:u,disabled:m,name:b,ariaLabelledBy:f}=a,{otherChecked:v}=(t()(a,h),this.state),g=this.props.hasOwnProperty("inline"),y=this.props.hasOwnProperty("html"),x=this.props.hasOwnProperty("allowOther"),k=!!l&&l.find((e=>!n.map((e=>e.value)).includes(e))),C=this.props.hasOwnProperty("error")&&""!==u,N=this.props.hasOwnProperty("disabled")&&1==m;return e=g?{paddingLeft:"22px",marginLeft:"20px",float:"left"}:{paddingLeft:"22px",marginTop:"7px"},s().createElement("div",{id:`chl_wrapper_${i}`,"aria-labelledby":f},s().createElement("div",{className:"checkboxes-div"+(C?" error":"")},n.map((t=>{let a=!!l&&l.includes(t.value);return s().createElement("div",{className:"form-check abc-checkbox",key:"radio_key_"+t.value,style:e},s().createElement("input",{type:"checkbox",id:`cb_${i}_${t.value}`,name:b||i,checked:a,disabled:N,onChange:this.handleChange,className:"form-check-input",value:t.value}),s().createElement("label",{className:"form-check-label",htmlFor:`cb_${i}_${t.value}`},y&&s().createElement(p.default,null,t.label),!y&&t.label))})),x&&s().createElement("div",{className:"form-check abc-checkbox",style:e},s().createElement("input",{type:"checkbox",id:"cb_other"+i,checked:v,disabled:N,onChange:this.handleOtherCBChange,className:"form-check-input",value:"other"}),s().createElement("label",{className:"form-check-label",htmlFor:"cb_other"+i},c().translate("general.other"))),x&&v&&s().createElement("div",{style:{paddingLeft:"22px",width:"50%"}},s().createElement("input",{className:"form-control",disabled:N,onChange:this.handleChange,value:k}))),C&&s().createElement("p",{className:"error-label"},u))}}d.defaultProps={ariaLabelledBy:null},d.propTypes={id:o().string.isRequired}})(),r})()));
//# sourceMappingURL=checkbox-list.js.map