import{createVNode as l,Fragment as f}from"vue";import{QuestionCircleOutlined as V}from"@antsoo-lib/icons";import b from"../_util/classNames.mjs";import j from"../grid/Col.mjs";import{useLocaleReceiver as w}from"../locale/LocaleReceiver.mjs";import B from"../locale/en_US.mjs";import M from"../tooltip/index.mjs";import{useInjectForm as O}from"./context.mjs";const C=(a,{slots:i,emit:d,attrs:v})=>{const{prefixCls:e,htmlFor:$,labelCol:g,labelAlign:L,colon:m,required:s,requiredMark:c}={...a,...v},[F]=w("Form"),o=a.label??i.label?.();if(!o)return null;const{vertical:N,labelAlign:h,labelCol:x,labelWrap:A,colon:k}=O(),p=g||x?.value||{},q=L||h?.value,r=`${e}-item-label`,y=b(r,q==="left"&&`${r}-left`,p.class,{[`${r}-wrap`]:!!A.value});let t=o;const u=m===!0||k?.value!==!1&&m!==!1;if(u&&!N.value&&typeof o=="string"&&o.trim()!==""&&(t=o.replace(/[:|：]\s*$/,"")),a.tooltip||i.tooltip){const n=l("span",{class:`${e}-item-tooltip`},[l(M,{title:a.tooltip},{default:()=>[l(V,null,null)]})]);t=l(f,null,[t,i.tooltip?i.tooltip?.({class:`${e}-item-tooltip`}):n])}c==="optional"&&!s&&(t=l(f,null,[t,l("span",{class:`${e}-item-optional`},[F.value?.optional||B.Form?.optional])]));const I=b({[`${e}-item-required`]:s,[`${e}-item-required-mark-optional`]:c==="optional",[`${e}-item-no-colon`]:!u});return l(j,{...p,class:y},{default:()=>[l("label",{for:$,class:I,title:typeof o=="string"?o:"",onClick:n=>d("click",n)},[t])]})};C.displayName="FormItemLabel";C.inheritAttrs=!1;export{C as default};
