import e from"@babel/runtime/helpers/defineProperty";import{jsx as t,jsxs as r,Fragment as n}from"react/jsx-runtime";import{Menu as o}from"../../../Menu/Menu.js";import{PACKAGE_LABELS as s}from"../../../../constants/appPackages.js";import{TextEndTruncated as i}from"../../../TextEndTruncated/TextEndTruncated.js";import{Text as a}from"../../../Text/Text.js";import{VersionSelectTestIds as c,formatVersionText as l}from"./VersionSelect.constants.js";var u;function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?p(Object(n),!0).forEach((function(r){e(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var f=(e(u={},s.PROD,"Stable Release"),e(u,s.BETA,"Beta"),e(u,s.DEV,"Dev"),u),b=function(e){var n=e.pkg,s=e.testId,c=e.onChange,u=f[n.label||""];return t(o.Item,{testId:s,onClick:function(){return c(n)},disabled:"failure"===n.status,children:r(i,{children:[u&&"".concat(u," "),l(n.package_code_version||"")," ",t(a,{color:"T6",size:"inherit",children:n.notes})]})})},h=function(i){var a=i.packages,l=i.onChange;if(!a||0===a.length)return t(o.Item,{disabled:!0,children:"No available versions found"});var u=Object.values(s),p=a.filter((function(e){var t=e.label;return t&&u.includes(t)})).reduce((function(t,r){return d(d({},t),{},e({},r.label||"",r))}),{}),f=a.filter((function(e){var t=e.label;return!t||!u.includes(t)}));return r(n,{children:[Object.keys(p).length>0&&r(o.Group,{label:"Labeled Versions (When selected always shows current Stable Release, Beta or Dev version)",children:[p[s.PROD]&&t(b,{pkg:p[s.PROD],onChange:l,testId:c.StableVersionItemTestId}),p[s.BETA]&&t(b,{pkg:p[s.BETA],onChange:l,testId:c.BetaVersionItemTestId}),p[s.DEV]&&t(b,{pkg:p[s.DEV],onChange:l,testId:c.DevVersionItemTestId})]}),f.length>0&&t(o.Group,{label:"Other versions (App will always show selected version until version is deleted)",children:f.map((function(e){return t(b,{testId:"".concat(c.AppVersionItemTestId,"_").concat(e.id),pkg:e,onChange:l},e.id)}))})]})};export{h as MenuItems};
//# sourceMappingURL=MenuItems.js.map
