/*!
 * KoliBri - The accessible HTML-Standard
 */
"use strict";const prop_validators=require("./prop.validators-96dfedce.js"),common=require("./common-1ab929ac.js"),tslib_es6=require("./tslib.es6-5e301284.js"),clsx=require("./clsx-dd4d6dd1.js"),index=require("./index-07fcbac9.js"),Alert=require("./Alert-d3173bbc.js");function transformObjectProperties(r){return Object.entries(r).reduce(((r,[e,s])=>{const t=e.startsWith("_")?e.slice(1):e;return Object.assign(Object.assign({},r),{[t]:s})}),{})}const validateMsg=(r,e)=>{prop_validators.objectObjectHandler(e,(()=>{try{e=prop_validators.parseJson(e)}catch(r){}prop_validators.watchValidator(r,"_msg",(r=>common.isObject(r)&&"string"==typeof(null==r?void 0:r._description)),new Set(["MsgPropType"]),e,{defaultValue:{_description:"",_type:"error"}})}))};function isMsgEmpty(r){return!r||"error"===r._type&&!r._description}function convertMsgToInternMsg(r){if(r&&!isMsgEmpty(r))return transformObjectProperties(r)}function checkHasError(r,e){return Boolean((null==r?void 0:r.description)&&(null==r?void 0:r.description.length)>0)&&(!0===e||"error"!==(null==r?void 0:r.type))}const FormFieldMsgFc=r=>{var{alert:e,msg:s,hideMsg:t,id:o,class:i}=r,c=tslib_es6.__rest(r,["alert","msg","hideMsg","id","class"]);return index.h(Alert.KolAlertFc,Object.assign({id:`${o}-msg`,alert:e,type:"error",class:clsx.clsx("kol-form-field__msg",{"visually-hidden":!0===t},i)},s,c,{"aria-hidden":"true"}),(null==s?void 0:s.description)||void 0)},KolFormFieldMsgFc=FormFieldMsgFc;exports.KolFormFieldMsgFc=KolFormFieldMsgFc,exports.checkHasError=checkHasError,exports.convertMsgToInternMsg=convertMsgToInternMsg,exports.validateMsg=validateMsg;