"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EnumValues=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),jotai_1=require("jotai"),SimpleEnums_1=require("./SimpleEnums"),DescriptionEnums_1=require("./DescriptionEnums"),store_1=require("../../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[r,s]=(0,react_1.useState)(!0),{maxDisplayedEnumValues:n}=(0,jotai_1.useAtomValue)(store_1.globalOptionsAtom),u=(0,react_1.useCallback)((()=>{s(!r)}),[r]),o=!Array.isArray(e),i=getEnums(e),m=(0,react_1.useMemo)((()=>r&&n?i.slice(0,n):i),[i,r,n]);if(!i.length)return null;const a=!!n&&i.length>n,l=n?r?`+${i.length-n} more`:"Hide":"";return(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:o?(0,jsx_runtime_1.jsx)(DescriptionEnums_1.DescriptionEnums,{enums:m,toggle:u,showToggleButton:a,toggleButtonText:l,type:t}):(0,jsx_runtime_1.jsx)(SimpleEnums_1.SimpleEnums,{enums:m,type:t,toggle:u,toggleButtonText:l,showToggleButton:a})})}exports.EnumValues=(0,react_1.memo)(EnumValuesComponent);
//# sourceMappingURL=EnumValues.js.map