import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useState,memo,useCallback,useMemo}from"react";import{useAtomValue}from"jotai";import{SimpleEnums}from"./SimpleEnums";import{DescriptionEnums}from"./DescriptionEnums";import{globalOptionsAtom}from"../../jotai/store";function getEnums(e){return Array.isArray(e)&&e||Object.entries(e||{}).map((([e,t])=>({value:e,description:t})))}function EnumValuesComponent({values:e,type:t}){const[o,m]=useState(!0),{maxDisplayedEnumValues:n}=useAtomValue(globalOptionsAtom),s=useCallback((()=>{m(!o)}),[o]),r=!Array.isArray(e),u=getEnums(e),l=useMemo((()=>o&&n?u.slice(0,n):u),[u,o,n]);if(!u.length)return null;const a=!!n&&u.length>n,i=n?o?`+${u.length-n} more`:"Hide":"";return _jsx(_Fragment,{children:r?_jsx(DescriptionEnums,{enums:l,toggle:s,showToggleButton:a,toggleButtonText:i,type:t}):_jsx(SimpleEnums,{enums:l,type:t,toggle:s,toggleButtonText:i,showToggleButton:a})})}export const EnumValues=memo(EnumValuesComponent);
//# sourceMappingURL=EnumValues.js.map