/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../_virtual/_rollupPluginBabelHelpers.js"),e=require("../../utils/util.js"),i=require("../../plugin/plugin.js");var s=function(){function s(o){t.classCallCheck(this,s),this.config=o.config,this.parent=o.root,this.root=e.default.createDom("ul","",{},"xg-options-list xg-list-slide-scroll ".concat(this.config.className)),o.root.appendChild(this.root);var l=this.config.maxHeight;l&&this.setStyle({maxHeight:l}),this.onItemClick=this.onItemClick.bind(this),this.renderItemList();var a="touch"===this.config.domEventType?"touchend":"click";this._delegates=i.default.delegate.call(this,this.root,"li",a,this.onItemClick)}return t.createClass(s,[{key:"renderItemList",value:function(t){var i=this,s=this.config,o=this.root;t?s.data=t:t=s.data,s.style&&Object.keys(s.style).map(function(t){o.style[t]=s[t]}),t.length>0&&(this.attrKeys=Object.keys(t[0])),this.root.innerHTML="",t.map(function(t,s){var o=t.selected?"option-item selected":"option-item";t["data-index"]=s,i.root.appendChild(e.default.createDom("li","<span>".concat(t.showText,"</span>"),t,o))})}},{key:"onItemClick",value:function(t){t.delegateTarget||(t.delegateTarget=t.target);var i=t.delegateTarget;if(i&&e.default.hasClass(i,"selected"))return!1;var s="function"==typeof this.config.onItemClick?this.config.onItemClick:null,o=this.root.querySelector(".selected");e.default.addClass(i,"selected"),o&&e.default.removeClass(o,"selected"),s(t,{from:o?this.getAttrObj(o,this.attrKeys):null,to:this.getAttrObj(i,this.attrKeys)})}},{key:"getAttrObj",value:function(t,e){if(!t||!e)return{};var i={};e.map(function(e){i[e]=t.getAttribute(e)});var s=t.getAttribute("data-index");return s&&(i.index=Number(s)),i}},{key:"show",value:function(){e.default.removeClass(this.root,"hide"),e.default.addClass(this.root,"active")}},{key:"hide",value:function(){e.default.removeClass(this.root,"active"),e.default.addClass(this.root,"hide")}},{key:"setStyle",value:function(t){var e=this;Object.keys(t).forEach(function(i){e.root.style[i]=t[i]})}},{key:"destroy",value:function(){this._delegates&&(this._delegates.map(function(t){t.destroy&&t.destroy()}),this._delegates=null),this.root.innerHTML=null,this.parent.removeChild(this.root),this.root=null}}]),s}();exports.default=s;