Liferay.Loader.define("frontend-js-web@5.0.31/liferay/DynamicSelect",["module","exports","require","./util/toggle_disabled"],(function(e,t,n){var l;window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=(l=n("./util/toggle_disabled"))&&l.__esModule?l:{default:l};function c(e,t){let n=e.indexOf('">');const l=e.substring(n);n=t.indexOf('">');const o=t.substring(n);return l<o?-1:l>o?1:0}function s(e){return function(e){return!!Array.isArray(e)||!(!e||"object"!=typeof e||"number"!=typeof e.length||e.tagName||e.scrollTo||e.document)}(e)?Array.from(e):[e]}function a(e,t,n){const l=e[t],a=document.getElementById(l.select);if(!a)return;const i=s(l.selectVal),r=[];for(!1!==l.selectNullable&&r.push('<option selected value="0"></option>'),n.forEach((e=>{const t=Liferay.Util.escapeHTML(e[l.selectId]),n=Liferay.Util.escapeHTML(e[l.selectDesc]);let o="";i.indexOf(t)>-1&&(o='selected="selected"'),r.push("<option ".concat(o,' value="').concat(t,'">').concat(n,"</option>"))})),l.selectSort&&r.sort(c);a.lastChild;)a.removeChild(a.lastChild);a.innerHTML=r.join(""),l.selectDisableOnEmpty&&(0,o.default)(a,!n.length)}function i(e){e.forEach(((t,n)=>{const l=t.select,o=document.getElementById(l),c=t.selectData;if(o){let t;o.setAttribute("data-componentType","dynamic_select"),n>0&&(t=e[n-1].selectVal),c((t=>{a(e,n,t)}),t),o.getAttribute("name")||o.setAttribute("name",l),o.addEventListener("change",(()=>{!function(e,t){if(t+1<e.length){const n=document.getElementById(e[t].select);(0,e[t+1].selectData)((n=>{a(e,t+1,n)}),n&&n.value)}}(e,n)}))}}))}class e{constructor(e){i(e)}}t.default=e}}));
//# sourceMappingURL=DynamicSelect.js.map