/*!
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("../../events.js");var n=function(n){t.inherits(r,n);var a=t.createSuper(r);function r(e){var i;return t.classCallCheck(this,r),(i=a.call(this,e)).ratio=1,i.interval=null,i._preloadMark={},i}return t.createClass(r,[{key:"afterCreate",value:function(){var t=this;this.usable&&this.initThumbnail(),this.on([i.DURATION_CHANGE],function(){var e=t.config,i=e.pic_num,n=e.interval;t.usable&&(t.interval=n>0?n:Math.round(1e3*t.player.duration/i)/1e3)})}},{key:"setConfig",value:function(t){var e=this;if(t){var i=Object.keys(t);i.length<1||(i.forEach(function(i){e.config[i]=t[i]}),this.usable&&this.initThumbnail())}}},{key:"usable",get:function(){var t=this.config,e=t.urls,i=t.pic_num;return e&&e.length>0&&i>0}},{key:"initThumbnail",value:function(){var t=this.config,e=t.width,i=t.height,n=t.pic_num,a=t.interval;this.ratio=e/i*100,this.interval=a||Math.round(this.player.duration/n),this._preloadMark={}}},{key:"getUrlByIndex",value:function(t){return t>=0&&t<this.config.urls.length?this.config.urls[t]:""}},{key:"preload",value:function(t){var i=this;if(!this._preloadMark[t]){var n=this.config.urls,a=n.length,r=[];t>0&&r.push(t-1),r.push(t),t>0&&t<a-1&&r.push(t+1),r.map(function(t){!i._preloadMark[t]&&t>=0&&t<a&&(i._preloadMark[t]=1,e.default.preloadImg(n[t],function(){i._preloadMark[t]=2}))})}}},{key:"getPosition",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=this.config,a=n.pic_num,r=n.row,l=n.col,u=n.width,o=n.height;this.interval=Math.round(this.player.duration/a);var h=Math.ceil(t/this.interval),s=(h=h>a?a:h)<r*l?0:Math.ceil(h/(r*l))-1,c=h-s*(l*r),g=c>0?Math.ceil(c/l)-1:0,d=c>0?c-g*l-1:0,f=0,v=0;e&&i?e/i<u/o?f=(v=i)*(u/o):v=(f=e)/(u/o):i?e||(f=(v=i||o)*(u/o)):v=(f=e||u)/(u/o);var p=this.getUrlByIndex(s);return{urlIndex:s,rowIndex:g,colIndex:d,url:p,height:v,width:f,style:{backgroundImage:"url(".concat(p,")"),backgroundSize:"".concat(f*l,"px auto"),backgroundPosition:"-".concat(d*f,"px -").concat(g*v,"px"),width:"".concat(f,"px"),height:"".concat(v,"px")}}}},{key:"update",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",r=this.config,l=r.pic_num,u=r.urls;if(!(l<=0)&&u&&0!==u.length){var o=this.getPosition(e,i,n);this.preload(o.urlIndex),Object.keys(o.style).map(function(e){t.style[e]=o.style[e]}),Object.keys(a).map(function(e){t.style[e]=a[e]})}}},{key:"changeConfig",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setConfig(t)}},{key:"createThumbnail",value:function(t,i){var n=e.default.createDom("xg-thumbnail","",{},"thumbnail ".concat(i));return t&&t.appendChild(n),n}}],[{key:"pluginName",get:function(){return"thumbnail"}},{key:"defaultConfig",get:function(){return{isShow:!1,urls:[],pic_num:0,col:0,row:0,height:90,width:160,scale:1,className:"",hidePortrait:!1}}}]),r}(require("../../plugin/plugin.js").default);exports.default=n;