'use client';
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),C=require("react"),k=require("framer-motion"),y=require("../../hooks/use-theme.cjs"),_=require("../../hooks/use-config.cjs"),F=e=>e&&e.__esModule?e:{default:e},r=F(C);function p({error:e,fieldName:a,immediate:s=!1,className:n="",icon:i,showMultiple:l=!1,variant:o="default",size:u="md"}){const{getColorValue:m}=y.useTheme(),{components:d}=_.useConfig(),c=d.FieldError;if(c)return t.jsx(c,{error:e,fieldName:a,immediate:s,className:n,icon:i,showMultiple:l,variant:o,size:u});const f=r.default.useMemo(()=>e?Array.isArray(e)?e.filter(Boolean):[e]:[],[e]);if(f.length===0)return null;const h=l?f:f.slice(0,1),j={sm:"text-xs",md:"text-sm",lg:"text-base"},v={default:"mt-1",inline:"ml-2 inline-block",tooltip:"absolute z-10 mt-1"},E={initial:{opacity:0,y:-10,height:0},animate:{opacity:1,y:0,height:"auto",transition:{duration:.2,ease:"easeOut"}},exit:{opacity:0,y:-10,height:0,transition:{duration:.15,ease:"easeIn"}}},x=i||t.jsx("svg",{className:"w-4 h-4 shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})});return t.jsx(k.AnimatePresence,{mode:"wait",children:h.length>0&&t.jsxs(k.motion.div,{initial:s?"animate":"initial",animate:"animate",exit:"exit",variants:E,className:`
            flex items-start gap-1
            text-danger-600 dark:text-danger-400
            ${j[u]}
            ${v[o]}
            ${n}
          `.trim(),role:"alert","aria-live":"polite","aria-relevant":"all",children:[x&&t.jsx("span",{className:"text-danger-500 dark:text-danger-400 mt-0.5",children:x}),t.jsx("div",{className:"flex-1 min-w-0",children:h.map((b,g)=>t.jsx("div",{className:g>0?"mt-1":"",children:t.jsx("span",{className:"block text-inherit break-words",children:b})},`${a}-error-${g}`))})]})})}function M(e){const[a,s]=r.default.useState(null),[n,i]=r.default.useState(!1),l=r.default.useMemo(()=>n&&!!a,[n,a]),o=r.default.useCallback(()=>{s(null)},[]),u=r.default.useCallback(c=>{s(c)},[]),m=r.default.useCallback(()=>{i(!0)},[]),d=r.default.useCallback(()=>{s(null),i(!1)},[]);return{error:a,showError:l,touched:n,setError:u,clearError:o,touch:m,reset:d,fieldName:e}}var q=p;exports.FieldError=p;exports.default=q;exports.useFieldError=M;
//# sourceMappingURL=field-error.cjs.map
