Liferay.Loader.define("@liferay/document-library-web@6.0.135/document_library/js/LocaleChangedHandler.es",["module","exports","require","frontend-js-web"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.default=a.LocaleChangedHandler=void 0;var n=t("frontend-js-web");class LocaleChangedHandler{constructor({contentTitle:e,defaultLanguageId:a,namespace:t}){this.contentTitle=e,this.defaultLanguageId=a,this.namespace=t,this.attachLocaleChangedEventListener()}attachLocaleChangedEventListener(){this._defaultLocaleChangedHandler=Liferay.after("inputLocalized:defaultLocaleChanged",this._onDefaultLocaleChange.bind(this)),this._localeChangedHandler=Liferay.after("inputLocalized:localeChanged",this._onLocaleChange.bind(this))}detachLocaleChangedEventListener(){this._defaultLocaleChangedHandler.detach(),this._localeChangedHandler.detach()}_onDefaultLocaleChange(e){e.item&&(this.defaultLanguageId=e.item.getAttribute("data-value"))}_onLocaleChange(e){const a=e.item.getAttribute("data-value");this._selectedLanguageId=a,a&&(this._updateLocalizableInput(this.contentTitle,this.defaultLanguageId,a),this._updateLanguageIdInput(a))}_updateLanguageIdInput(e){document.getElementById(this.namespace+"languageId").value=e}_updateLocalizableInput(e,a,t){const d=Liferay.component(this.namespace+e);if(d){if(""===d.getValue(t)){const e=d.getValue(a),l=n.AOP.before((()=>n.AOP.prevent()),d,"updateInputLanguage");d.selectFlag(t),d.updateInput(e),setTimeout((()=>{l.detach()}),400)}}}}a.LocaleChangedHandler=LocaleChangedHandler;var d=LocaleChangedHandler;a.default=d}}));
//# sourceMappingURL=LocaleChangedHandler.es.js.map