/*!
 * Custom elements for Nanopore-Digital Web applications
 */
import{h as l}from"./renderer-DpNDfhNy.js";const r=({label:r,hasLabelSlot:a,controlId:e,labelId:o,floatLabel:t,placeholder:s,alwaysShowPlaceholder:c,hideLabel:n,hasValue:i,rtl:_,showCharCount:m,maxlength:d,charCount:h})=>{if(r||a)return t?l("label",{class:"form-ctrl__float-label",htmlFor:e,id:o},l("slot",{name:"label"},r),m&&l("span",{class:"form-ctrl__label-charcount"},d?` ${h}/${d}`:` ${h}`)):l("label",{class:{"form-ctrl__label":!0,"visually-hide":n},htmlFor:e,id:o},l("div",{class:"form-ctrl__label-wrap"},s&&c&&i&&_&&l("span",{class:"form-ctrl__label-placeholder"},s," / "),l("span",{class:"form-ctrl__labeltext"},l("slot",{name:"label"},r)),s&&c&&i&&!_&&l("span",{class:"form-ctrl__label-placeholder"}," / ",s)),m&&l("span",{class:"form-ctrl__label-charcount"},d?d-h+" left":h+" characters"))},a=(a,e)=>{const{rtl:o,floatLabel:t,label:s,moreId:c,helperEndId:n,type:i,hasHelperSlot:_,showInlineError:m,errorMessage:d,hasHelperEndSlot:h}=a;return l("div",{class:{"form-ctrl":!0,"has-label":null!==s&&!t,"has-float-label":null!==s&&t,"has-helper-end":h,rtl:o,[a.class]:!!a.class}},l("div",{class:"form-ctrl__wrapper"},t?"":r({...a}),l("div",{class:{"form-ctrl__input":!0,"form-ctrl__textarea":"textarea"===i}},t&&r({...a,rtl:o}),e),(m||_)&&l("div",{class:"form-ctrl__more",id:c},m&&l("div",{class:"form-ctrl__error","aria-live":"polite"},d),l("div",{class:"form-ctrl__helper"},l("slot",{name:"helper"})))),h&&l("div",{class:"form-ctrl__helper-end",id:n},l("slot",{name:"helper-end"})))},e=(r,a)=>{const{ref:e,onClearText:o,clearControl:t,readonly:s,disabled:c,control:n,endSlot:i,endValueSlot:_,startSlot:m,showInlineError:d}=r,h=()=>{n.setFocus()};return l("div",{class:"form-ctrl__input-wrap",ref:l=>{e&&e(l)}},l("span",{class:"form-ctrl__slot-start"},l("slot",{name:"start"}),m),a,t&&!s&&!c&&l("button",{type:"button",class:"icon form-ctrl__clear-btn",tabindex:"-1",onTouchStart:o,onMouseDown:o},l("nano-icon",{name:"light/xmark",role:"img",ariaLabel:"Clear content"})),d&&l("div",{onClick:h,class:"form-ctrl__validation-icon"},l("nano-icon",{name:"solid/circle-xmark",class:"form-ctrl__error-icon"}),l("nano-icon",{name:"solid/circle-check",class:"form-ctrl__success-icon"})),l("span",{class:"form-ctrl__slot-value-end",onClick:h},l("slot",{name:"value-end"}),_),l("span",{class:"form-ctrl__slot-end"},l("slot",{name:"end"}),i))};export{a as F,e as a}