Liferay.Loader.define("@liferay/document-library-web@6.0.149/document_library/js/LanguageSelector",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/drop-down","@frontend-taglib-clay$clayui/icon","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/drop-down")),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),o=(_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e}).apply(this,arguments)}function _objectWithoutProperties(e,t){if(null==e)return{};var a,n,r=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var a,n,r={},l=Object.keys(e);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function getLanguage(e){const t=e.replaceAll("_","-");return{icon:t.toLowerCase(),text:t}}function LanguageSelector({languageIds:e,onChange:t,selectedLanguageId:a}){const[u,c]=(0,o.useState)(!1),i=getLanguage(a);return o.default.createElement(r.default,{active:u,onActiveChange:c,trigger:o.default.createElement(n.default,{displayType:"secondary",monospaced:!0},o.default.createElement("span",{className:"inline-item"},o.default.createElement(l.default,{symbol:i.icon})),o.default.createElement("span",{className:"btn-section"},i.text))},o.default.createElement(r.default.ItemList,null,e.map((e=>{const{icon:n,text:u}=getLanguage(e);return o.default.createElement(r.default.Item,{active:e===a,key:e,onClick:()=>{t(e),c(!1)}},o.default.createElement("span",{className:"inline-item inline-item-before"},o.default.createElement(l.default,{symbol:n})),u)}))))}var u=function DataEngineLanguageSelector(e){let{ddmStructureIds:t,portletNamespace:a,selectedLanguageId:n,translatedLanguageIds:r}=e,l=_objectWithoutProperties(e,["ddmStructureIds","portletNamespace","selectedLanguageId","translatedLanguageIds"]);const[u,c]=(0,o.useState)(n),[i,d]=(0,o.useState)([...new Set([...r,n])]);return(0,o.useEffect)((()=>{t.forEach((e=>{Liferay.componentReady("".concat(a,"dataEngineLayoutRenderer").concat(e)).then((e=>{const{reactComponentRef:{current:t}}=e;t&&t.updateEditingLanguageId({editingLanguageId:u})}))}))}),[a,u,t]),o.default.createElement(o.default.Fragment,null,o.default.createElement("input",{name:"".concat(a,"availableLocales"),type:"hidden",value:i.join(",")}),o.default.createElement(LanguageSelector,_extends({},l,{onChange:e=>{c(e),i.includes(e)||d([...i,e])},selectedLanguageId:u})))};t.default=u}}));
//# sourceMappingURL=LanguageSelector.js.map