dwt
Version:
Dynamic Web TWAIN is a TWAIN/ICA/SANE-based scanning SDK software specifically designed for web applications running on Windows/macOS/Linux. With just a few lines of code, you can develop robust applications to scan documents from TWAIN/ICA/SANE-compatibl
1 lines • 140 kB
JavaScript
/*! 20220624 190905 */!function(){function i(t,e){return(i=Object.setPrototypeOf||function i(t,e){return t.__proto__=e,t})(t,e)}function h(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,i(t,e)}function a(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)}function O(t){if(Array.isArray(t)){for(var e=0;e<t.length;e++)for(var i=e+1;i<t.length;i++)t[e]===t[i]&&(t.splice(i,1),i--);return t}}function o(t){return"[object Object]"===Object.prototype.toString.call(t)}function l(t){return"function"==typeof t}function u(t){return"string"==typeof t}function p(t){return"number"==typeof t&&!isNaN(t)}function c(){return"ontouchstart"in document.documentElement}function r(t){return t instanceof HTMLElement||"[object ShadowRoot]"===Object.prototype.toString.call(t)}function d(t,e){if(u(e))t.style.cssText=e;else for(var i in e)t.style[i]=e[i]}function _(t,e,i,n){if(t)return t.addEventListener(e,i,n),function(){t.removeEventListener(e,i)}}function f(t,e){for(var i in t)e[i]!==undefined&&o(t[i])&&o(e[i])?f(t[i],e[i]):e[i]=t[i]}function b(t,e){for(var i in t){var n=t[i],s=e[i];s===undefined?e[i]=t[i]:u(n)&&o(s)?s.visibility=n:o(n)&&o(s)?b(t[i],e[i]):e[i]=t[i]}}function v(t){t&&t.stopPropagation?t.stopPropagation():t&&(t.cancelBubble=!0)}function P(t){t.preventDefault?t.preventDefault():t.returnValue=!1}function m(t){return""===t||t===undefined?null:document.getElementById(t)}function R(t){for(var e=t.parentNode.children,i=0;i<e.length;i++)if(e[i]===t)return i}function L(t,e,i){e===undefined?i.appendChild(t):i.insertBefore(t,e)}function g(t){var e=Math.random().toString(35).substring(2);return e.length<11&&(e+=Math.random().toString(35).substring(2)),t=Math.max(Math.min(Math.round(t),11),8),e=e.substring(0,t)}function y(){var t=window;if(t){if(t.devicePixelRatio)return t.devicePixelRatio;if(t.screen.deviceXDPI&&t.screen.logicalXDPI)return t.screen.deviceXDPI/t.screen.logicalXDPI}return 1}var e=function(t){window.Dynamsoft&&window.Dynamsoft.Lib.debug&&window.Dynamsoft.Lib.log(t)},n={windowURL:window.URL||window.webkitURL,createURL:function(t){return u(t)?t:n.createURLWithType(t).data},createURLWithType:function(t){if(u(t)||undefined===t)return{type:"string",data:t};if(t instanceof Blob)return{type:"object",data:n.createObjectURL(t)};if(t.imageData&&t.imageData instanceof Blob)return{type:"object",data:n.createObjectURL(t.imageData)};if(t.imageData){var e=Object.prototype.toString.call(t.imageData);if(/\[object \w+Array\]/.test(e))return{type:"object",data:n.createObjectURL(new Blob([t.imageData]))}}else{e=Object.prototype.toString.call(t);if(/\[object \w+Array\]/.test(e))return{type:"object",data:n.createObjectURL(new Blob([t]))}}return/data:image\/\w+;base64/.test(t)?{type:"string",data:t}:{type:"object",data:t}},createObjectURL:function(t){if(!t)return"";t=n.windowURL.createObjectURL(t);return e("createObjectURL:"+t),t},revokeObjectURL:function(t){e("revokeObjectURL:"+t),u(t)&&0==t.indexOf("blob:http")&&n.windowURL.revokeObjectURL(t)}},t="undefined"!=typeof window,N=t?window:{},w=(t&&0 in window.document.documentElement,t&&0 in N,"click"),W="touchstart",V="touchmove",Y="touchend",X="mousedown",A="mousemove",F="mouseup",H="contextmenu",Q="resize",q="click",s="mousedown",x="mousemove",C="mouseup",j="mouseover",K="mouseout",G="dblclick",$="rightclick",J="contextmenu",Z="dragstart",tt="dragmove",et="dragdone",it="keydown",nt="keyup",st="resize",rt="topPageChanged",ot="bufferChanged",at="resize",lt="removePage",ht="fileKeyUp",ut="fileListClick",ct="fileListRightClick",dt="tagKeyUp",_t="tagListClick",pt="tagListRightClick",ft="pageAreaSelected",vt="pageAreaUnselected",S="pageRendered",mt="onDocumentPointerUp",gt="onDocumentPointerMove",bt="onDocumentClick",yt="onSidebarClick",wt="onDrop",xt="_updateFocus",Ct="_canvasVisibilityChanged",I="_SetSelectedIndexes",St="_documentUp",It="_documentMove",kt="_displayedImageChanged",Mt="_onReOrderThumbnail",Bt="_changeThumbnailViewProp",Tt="_updateErrorMessage",Pt="_clearSltBox",Rt="_bindSlideComponent",Lt="_unbindSlideComponent",Et="_canvasTouchstart",Ut="_canvasTouchmove",zt="_canvasTouchend",Dt="_canvasMousedown",Ot="_canvasMouseup",Nt="_canvasMousemove",Wt="_canvasMouseOver",Vt="_canvasMouseOut",Yt="_canvasWheel",Xt="_canvasScroll",At="_canvasClick",Ft="_canvasDoubleClick",Ht="_canvasRightClick",Qt="_canvasKeyDown",qt="_canvasKeyUp",jt="_canvasDragDone",Kt="_canvasDefaultCursor",Gt="_showCanvasLoading",k="_viewerResizeUI",$t="_mouseClickUI",Jt="_viewerRightClickUI",Zt="_mouseMoveUI",te="_showLatestPage",ee="_updatePagesLayout",M="_documentPointerMoveUI",B="_documentPointerUpUI",ie="_documentKeyDownUI",ne="_documentKeyUpUI",se="_documentClickUI",re="_sideBarClickUI",oe="_sidebarStretchStartUI",ae="_fileListClickUI",le="_fileListRightClickUI",he="_fileListKeyUpUI",ue="_addNewFolderUI",ce="_directoryRefreshUI",de="_fileSelectedUI",_e="_tagListClickUI",pe="tagListRightClickUI",fe="_tagKeyUpUI",ve="_addNewTagUI",me="_tagRefreshUI",ge="_tagSelectedUI",be="_openDefaultTagUI",ye="_imageSelectedUI",we="_thumbnailChangedUI",xe="_updateThbItem",Ce="_updateThumbnailPropUI",Se="_scrollToUI",Ie="_setViewModeUI",T="_mergeDisplayedUidsUi",ke="_pagerBlurUI",Me="_pagerChangedUI",Be="_setScrollerSizeUI",Te="_changeCanvasCursorUI",Pe="_tabChangedUI",Re="_tabListClickUI",Le="_closeSaveSettingBoxUI",Ee="_customButtonClickUI",Ue="_gotoPage",ze={code:80030,message:"The metadata is not exist."},De=function(){function t(t){this._clickItem=null,this._clickTimer=null,this._rightClickItem=null,this._rightClickTimer=null,this._mouseDownItem=null,this._startX=0,this._startY=0,this._mouseUpItem=null,this._evtList=[],this.onClick=null,this.onRightClick=null,this.onDoubleClick=null,this.onPointDown=null,this.onPointMove=null,this.onPointUp=null,this.onPointOver=null,this.onPointOut=null,this._element=t,this._registerEvents()}var e=t.prototype;return e._registerEvents=function(){var n=this,t=this._element,i=c(),e="mousedown",s="mousemove",r="mouseup";i&&(e="touchstart",s="touchmove",r="touchend",i=!0),e=_(t,e,function(t){var e=n._packageEvent(t);n._mouseDownItem=n.getTarget(t),n._startX=e.clientX,n._startY=e.clientY,null!=(t=n.onPointDown)&&t.call(n,e),i?n._rightClickTimer=setTimeout(function(){var t;null!=(t=n.onRightClick)&&t.call(n,e),n._mouseDownItem=null},500):2===e.button&&(n._rightClickItem=n.getTarget(e))},{passive:!1}),this._evtList.push(e),e=_(t,s,function(t){var t=n._packageEvent(t),e=(null!=(e=n.onPointMove)&&e.call(n,t),Math.abs(t.clientX-n._startX)),t=Math.abs(t.clientY-n._startY);(5<e||5<t)&&(clearTimeout(n._rightClickTimer),c()&&(n._mouseDownItem=null))},{passive:!1}),this._evtList.push(e),e=_(t,r,function(t){var e,t=n._packageEvent(t);n._mouseUpItem=n.getTarget(t),null!=(e=n.onPointUp)&&e.call(n,t),clearTimeout(n._rightClickTimer),n.getTarget(t)===n._rightClickItem&&2===t.button?null!=(e=n.onRightClick)&&e.call(n,t):n._mouseDownItem===n._mouseUpItem&&n._clickHandler(t),n._rightClickItem=null}),this._evtList.push(e),e=_(t,"mouseover",function(t){var e,i;c()||((i=t.fromElement)===undefined&&(i=t.relatedTarget),(e=t.toElement)===undefined&&(e=t.target),n.getTarget(t,i)!==n.getTarget(t,e)&&null!=(i=n.onPointOver)&&i.call(n,t))}),this._evtList.push(e),e=_(t,"mouseout",function(t){var e,i;c()||((i=t.fromElement)===undefined&&(i=t.target),(e=t.toElement)===undefined&&(e=t.relatedTarget),n.getTarget(t,i)!==n.getTarget(t,e)&&null!=(i=n.onPointOut)&&i.call(n,t))}),this._evtList.push(e)},e._unregisterEvents=function(){this._evtList.forEach(function(t){l(t)&&t()}),this._evtList.splice(0)},e._clickHandler=function(t){var e=this,i=this._packageEvent(t);clearTimeout(this._clickTimer),this.getTarget(t)===this._clickItem?(this._clickItem=null,setTimeout(function(){var t;null!=(t=e.onDoubleClick)&&t.call(e,i)})):this._mouseDownItem===this._mouseUpItem&&(this._clickItem=this.getTarget(i),setTimeout(function(){var t;null!=(t=e.onClick)&&t.call(e,i)})),this._mouseDownItem=null,this._mouseUpItem=null,this._clickTimer=setTimeout(function(){e._clickItem=null},500)},e._packageEvent=function(t){var e,i,n=null==(e=t.changedTouches)?void 0:e[0];if(!n)return t;for(i in n)t[i]===undefined&&(t[i]=n[i]);return t},e.getTarget=function(t,e){return e!==undefined?e:t.target},e.dispose=function(){this._unregisterEvents(),this._element=null,this._clickItem=null,this._clickTimer=null,this._rightClickItem=null,this._rightClickTimer=null,this._mouseDownItem=null,this._mouseUpItem=null,this.onClick=null,this.onRightClick=null,this.onDoubleClick=null,this.onPointDown=null,this.onPointMove=null,this.onPointUp=null,this.onPointOver=null,this.onPointOut=null},t}(),E=function(){function t(t){this._evtIds=[],this._oPub=null,this._bDisposePub=!1,t?this._oPub=t:(this._oPub=new Oe,this._bDisposePub=!0)}var e=t.prototype;return e.getPublishSubscribe=function(){return this._oPub},e._on=function(t,e){e=this._oPub.on(t,e);this.push(t,e)},e._emit=function(t){for(var e,i=arguments.length,n=new Array(1<i?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];null!=(e=this._oPub)&&e.emit.apply(e,[t].concat(n))},e._off=function(t,e){var i;null!=(i=this._oPub)&&i.off(t,e)},e._offById=function(t,e){var i;null!=(i=this._oPub)&&i.offById(t,e)},e.push=function(t,e){this._evtIds.push({name:t,id:e})},e.dispose=function(){if(this._oPub){for(var t=this._evtIds.length,e=0;e<t;e++){var i=this._evtIds[e];this._oPub.offById(i.name,i.id)}this._bDisposePub&&this._oPub&&this._oPub.dispose()}this._oPub=null},t}(),Oe=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){this._events[t]||(this._events[t]=[]);var i=g(10);return this._events[t].push({fn:e,evtId:i}),i},e.emit=function(t){var e=this._events[t];if(!e||0===e.length)return!1;for(var i=e.length,n=arguments.length,s=new Array(1<n?n-1:0),r=1;r<n;r++)s[r-1]=arguments[r];for(var o,a=0;a<i;a++)null!=(o=e[a])&&(o=o.fn).call.apply(o,[null].concat(s))},e.emitEx=function(t){var i=this._events[t];if(!i||0===i.length)return Promise.resolve(!0);for(var e=i.length,n=Promise.resolve(!0),s=arguments.length,r=new Array(1<s?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];if(1===i.length)return(t=null==(t=i[0])?void 0:(t=t.fn).call.apply(t,[null].concat(r)))instanceof Promise?t:n;for(var a=function a(t){var e=null==(t=i[t])?void 0:(t=t.fn).call.apply(t,[null].concat(r));e instanceof Promise&&(n=n.then(function(){return e}))},l=0;l<e;l++)a(l);return n},e.off=function(t,e){var i=this._events[t];if(!i)return!1;if(e)for(var n=i.length-1;0<=n;n--){var s=i[n];s&&s.fn===e&&i.splice(n,1),s=null}else i&&(i.length=0)},e.offById=function(t,e){var i=this._events[t];if(!i)return!1;if(e)for(var n=i.length-1;0<=n;n--){var s=i[n];if(s&&s.evtId===e){i.splice(n,1);break}s=null}else i&&(i.length=0)},e.dispose=function(){for(var t=Object.keys(this._events),e=0,i=t.length;e<i;e++){var n=t[e],n=this._events[n];n&&n.splice(0),n=null}this._events={}},t}(),Ne=function(a){function t(t,e,i){e=a.call(this,e)||this;return e.useMyEvent=!0,e._unbindList=[],e._customCanvas=null,e._viewerContainer=null,e._postfix=t,e._viewerContainer=i,e}h(t,a);var e=t.prototype;return e.uiEventInit=function(){var i=this,n=function n(t){var e,t="#"+t+i._postfix;return null==(e=i._viewerContainer)||null==(e=e.el)?void 0:e.querySelector(t)},t=w,e=A,s=F,r=("ontouchend"in document.documentElement&&(e=V,s=Y),this._unbindList),o=_(window,Q,function(e,i){var n=this,s=0,r=null;return function(){var t=+new Date;t-s<i?(clearTimeout(r),r=setTimeout(function(){s=t,e.apply(n)},i)):(s=t,e.apply(n))}}.call(this,this._viewerResize,40)),e=(r.push(o),o=_(window,"load",function(t){i._viewerResize(t)}),r.push(o),o=_(document,e,function(t){i._documentMouseMove(t)}),r.push(o),o=_(document,s,function(t){i._documentMouseUp(t)}),r.push(o),o=_(window,"message",function(t){"up"===t.data.type&&i._documentMouseUp()}),r.push(o),o=_(document,w,function(t){i._documentClick(t)}),r.push(o),o=_(document,"keydown",function(t){a.prototype._emit.call(i,ie,t)}),r.push(o),o=_(document,"keyup",function(t){a.prototype._emit.call(i,ne,t)}),r.push(o),this._viewerContainer.el),s=(o=_(e,"dragstart",function(){return!1}),r.push(o),o=_(e,t,function(t){i._viewerClick(t)}),r.push(o),o=_(e,H,function(t){i._viewerRightClick(t)}),r.push(o),o=_(e,"dragover",function(t){P(t)}),r.push(o),o=_(e,"drop",function(t){i._dropFile(t)}),r.push(o),o=_(n("navChange"),t,function(t){i._setSelectedSidetype(t)}),r.push(o),o=_(n("besides"),t,function(t){i._sidebarClick(t)}),r.push(o),o=_(n("stretchBar"),X,function(t){i._sidebarStretchStart(t)}),r.push(o),o=_(n("defaultTag"),t,function(){i._openDefaultTag()}),r.push(o),o=_(n("treeLists"),t,function(t){i._fileListClick(t)}),r.push(o),o=_(n("treeLists"),H,function(t){i._fileListRightClick(t)}),r.push(o),o=_(n("treeLists"),"keyup",function(t){i._fileListKeyUp(t)}),r.push(o),o=_(n("addFolder"),w,function(t){i._addNewFolder(t)}),r.push(o),o=_(n("tagLists"),t,function(t){i._tagListClick(t)}),r.push(o),o=_(n("tagLists"),H,function(t){i._tagListRightClick(t)}),r.push(o),o=_(n("tagLists"),"keyup",function(t){i._tagListKeyUp(t)}),r.push(o),o=_(n("addTag"),t,function(t){i._addNewTag(t)}),r.push(o),n("canvasEventLayer")),e=(o=_(s,"touchstart",function(t){i._canvasTouchStart(t)},{passive:!1}),r.push(o),o=_(s,"mousedown",function(t){i._canvasMouseDown(t)}),r.push(o),o=_(s,"touchmove",function(t){i._canvasTouchMove(t)},{passive:!1}),r.push(o),o=_(s,"mousemove",function(t){i._canvasMouseMove(t)}),r.push(o),o=_(s,"touchend",function(t){i._canvasTouchEnd(t)}),r.push(o),o=_(s,"mouseup",function(t){i._canvasMouseUp(t)}),r.push(o),o=_(s,"wheel",function(t){i._canvasWheel(t)},{passive:!1}),r.push(o),o=_(s,"click",function(t){v(t)}),r.push(o),new De(n("canvasEventLayer")));e.onClick=function(t){a.prototype._emit.call(i,At,t)},e.onRightClick=function(t){a.prototype._emit.call(i,Ht,t)},e.onDoubleClick=function(t){a.prototype._emit.call(i,Ft,t)},e.onPointOver=function(t){a.prototype._emit.call(i,Wt,t)},e.onPointOut=function(t){a.prototype._emit.call(i,Vt,t)},this._customCanvas=e,e=null,o=_(n("canvasScroll"),"scroll",function(t){i._canvasScroll(t)}),r.push(o),o=_(n("tabList"),t,function(t){i._tabListClick(t)}),r.push(o),o=_(n("pagerInput"),"blur",function(t){i._pagerBlur(t)}),r.push(o),o=_(n("pagerInput"),"keyup",function(t){13===t.keyCode&&t.target.blur()}),r.push(o)},e.unbindEvents=function(){this._unbindList.forEach(function(t){l(t)&&t()}),this._unbindList=[],this._customCanvas&&(this._customCanvas.dispose(),this._customCanvas=null)},e._viewerResize=function(t){a.prototype._emit.call(this,k,t)},e._documentMouseUp=function(t){a.prototype._emit.call(this,B,t),a.prototype._emit.call(this,St,t),a.prototype._emit.call(this,mt,t)},e._documentMouseMove=function(t){a.prototype._emit.call(this,M,t),a.prototype._emit.call(this,It,t),a.prototype._emit.call(this,gt,t)},e._documentClick=function(t){a.prototype._emit.call(this,se,t),a.prototype._emit.call(this,bt,t)},e._viewerClick=function(t){a.prototype._emit.call(this,$t,t)},e._viewerRightClick=function(t){P(t),a.prototype._emit.call(this,Jt,t)},e._viewerMove=function(t){a.prototype._emit.call(this,Zt,t)},e._dropFile=function(t){P(t),a.prototype._emit.call(this,wt,t)},e._setSelectedSidetype=function(t){},e._sidebarClick=function(t){v(t),a.prototype._emit.call(this,re),a.prototype._emit.call(this,yt)},e._sidebarStretchStart=function(t){a.prototype._emit.call(this,oe,t)},e._openDefaultTag=function(){a.prototype._emit.call(this,be)},e._fileListClick=function(t){a.prototype._emit.call(this,ae,t),a.prototype._emit.call(this,ut,t)},e._fileListRightClick=function(t){a.prototype._emit.call(this,le,t),a.prototype._emit.call(this,ct,t)},e._fileListKeyUp=function(t){a.prototype._emit.call(this,he,t),a.prototype._emit.call(this,ht,t)},e._addNewFolder=function(t){a.prototype._emit.call(this,ue,t)},e._tagListClick=function(t){a.prototype._emit.call(this,_e,t),a.prototype._emit.call(this,_t,t)},e._tagListRightClick=function(t){a.prototype._emit.call(this,pe,t),a.prototype._emit.call(this,pt,t)},e._tagListKeyUp=function(t){a.prototype._emit.call(this,fe,t),a.prototype._emit.call(this,dt,t)},e._addNewTag=function(t){a.prototype._emit.call(this,ve,t)},e._canvasTouchStart=function(t){a.prototype._emit.call(this,Et,t)},e._canvasTouchMove=function(t){a.prototype._emit.call(this,Ut,t)},e._canvasTouchEnd=function(t){a.prototype._emit.call(this,zt,t)},e._canvasMouseDown=function(t){a.prototype._emit.call(this,Dt,t)},e._canvasMouseMove=function(t){a.prototype._emit.call(this,Nt,t)},e._canvasMouseUp=function(t){a.prototype._emit.call(this,Ot,t)},e._canvasWheel=function(t){a.prototype._emit.call(this,Yt,t)},e._canvasScroll=function(t){a.prototype._emit.call(this,Xt,t)},e._tabListClick=function(t){a.prototype._emit.call(this,Re,t)},e._pagerBlur=function(t){a.prototype._emit.call(this,ke,t)},e.dispose=function(){a.prototype.dispose.call(this),this.unbindEvents()},t}(E),t=function(){function t(t,e,i){this._pubsub=null,this.element=null,this.containerEl=null,this.location="",this.visibility=!0,this.cssStyle="",this.tagName="div",this.name="",this._postfix=t,this._pubsub=i,this.element=this._createElement(e)}var e=t.prototype;return e.bindElement=function(t,e){e=this._createElement(e);return this.containerEl=t,!!e&&(t.appendChild(e),!0)},e.setAttributes=function(t){return!!o(t)&&(this._initConfig(t),this._updateAttributes(),!0)},e._createElement=function(t){this.element&&(null!=(i=this.containerEl)&&null!=(e=i.removeChild)&&e.call(i,this.element),this.element=null),this._initConfig(t);var e,i=document.createElement(this.tagName);return this._updateAttributes(i),i},e._initConfig=function(t){if(!o(t))return!1;for(var e in t)t[e]!==undefined&&(this[e]=t[e]);return!0},e._updateAttributes=function(t){return!!(t=r(t)?t:this.element)&&(t.className=this.visibility?"":" dvs-disabled",this.name&&t.classList.add("dvs-"+this.name),this.cssStyle&&t.classList.add(this.cssStyle),this.name&&(t.id="".concat(this.name+this._postfix)),this.sequence!==undefined&&("string"==typeof(t=null==(t=t)?void 0:t.style).msFlexOrder?t.msFlexOrder=this.sequence:t.order=this.sequence),!0)},t}(),U=function(n){function t(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return n.call.apply(n,[this].concat(e))||this}return h(t,n),t}(t),We=function(n){function t(t,e,i){t=n.call(this,t,e,i)||this;return t.groups={},t}return h(t,n),t}(t),Ve=function(n){function t(t,e,i){t=n.call(this,t,e,i)||this;return t.buttons={},t._setGroupClass(),t}return h(t,n),t.prototype._setGroupClass=function(){var t;null!=(t=this.element)&&t.classList.add("dvs-groupType")},t}(t),z=function(n){function t(t,e,i){t=n.call(this,t,e,i)||this;return t.onButtonClick="",t.iconClass="",t.text="",t.title="",t}return h(t,n),t.prototype._updateAttributes=function(t){var e=this;if(!(t=r(t)?t:this.element))return!1;t.className="ds-dvs-ui-iconfont dvs-".concat(this.name," ").concat(this.cssStyle||""," ").concat(this.iconClass||""," ").concat(this.visibility?"":"dvs-nodisplay").trim(),t.id="".concat(this.name+this._postfix),this.text&&u(this.text)&&("input"===this.tagName?t.value=this.text||"":((i=document.createElement("span")).innerText=this.text||"",t.appendChild(i)));var i=null==(i=t)?void 0:i.style;return"string"==typeof i.msFlexOrder?i.msFlexOrder=this.sequence:i.order=this.sequence,this.title&&(t.title=this.title),this.onButtonClick?t.onclick=function(t){e.onButtonClick&&e._pubsub.emit(Ee,e.onButtonClick,t)}:t.onclick=null,!0},t}(t),Ye=function(){function t(t){var e=t.el,i=t.sequence,n=t.isFull,s=t.pubsub,t=t.container;this.uid="",this.element=null,this.sequence=0,this.isFull=!1,this._visibility=!0,this.uid=g(11),this.element=e,this.sequence=i,this._pubsub=s,this.isFull=n,this._container=t,this._bindElement()}var e=t.prototype;return e.show=function(){var t;return!this._visibility&&(this._visibility=!0,null!=(t=this.element)&&null!=(t=t.classList)&&t.remove("dvs-nodisplay"),this._pubsub.emit(k),!0)},e.hide=function(){var t;return!!this._visibility&&(this._visibility=!1,null!=(t=this.element)&&null!=(t=t.classList)&&t.add("dvs-nodisplay"),this._pubsub.emit(k),!0)},e.dispose=function(){var t,e;for(e in null==(t=this.element)||null!=(t=t.parentNode)&&t.removeChild(this.element),this._pubsub.emit(k),this)delete this[e];return!0},e._bindElement=function(){var t=this._container;if(!t)return!1;var e=this.element;this.isFull?e.classList.add("dvs-upper-full"):e.classList.remove("dvs-upper-full"),e.style.order=String(this.sequence),e.style.msFlexOrder=String(this.sequence),e.classList.add("dvs-customElement"),this._visibility||e.classList.add("dvs-nodisplay"),t.appendChild(e),this._container=null,this._pubsub.emit(k)},t}(),Xe=function(s){function t(t){var e=t.postfix,i=t.container,n=t.uiConfig,t=t.pubsub,t=s.call(this,t)||this;return t._postfix="",t.uiConfig=null,t._assembledConfig={},t._customElements={},t.contentContainer=null,t.viewerContainer=null,t._postfix=e,t.uiConfig=n,t.viewerContainer={el:t.initUi(i)},t}h(t,s);var e=t.prototype;return e._myQueryById=function(t){var e;return null==(e=this.viewerContainer)||null==(e=e.el)?void 0:e.querySelector("#"+t)},e.initUi=function(t,e){if(e){if(!o(e))return null;b(e,this.uiConfig)}if(!r(t=u(t)?document.getElementById(t):t))return null;e=this._assembleConfig(this.uiConfig),this._assembledConfig=e,e=new U(this._postfix,{name:"WebViewer"});return this._createContainers({header:{},body:{sidebar:{},showImageArea:{content:{topMenu:{},tabList:{},middle:{asideMenu:{},container:{viewPort:{canvasWrapper:{canvasEventLayer:{},loadingLayer:{loadingImage:"img"}},canvasScroll:{scrollInner:{}}},videoContainer:{videoImage:"img"},innerThumbnail:{}}},bottomMenu:{}}}},hiddenBox:{}},e.element),t.appendChild(e.element),e.element},e._createContainers=function(t,e){for(var i in t){var n,s=null,r=t[i];(s="sidebar"===i?this._initSidebar():"hiddenBox"===i?this._initHiddenBox():this._assembledConfig[i]?null==(n=this._initToolbarItem(this._assembledConfig[i]))?void 0:n.element:new U(this._postfix,{name:i,tagName:u(r)?r:undefined,visibility:this.uiConfig.toolbars[i]===undefined||this.uiConfig.toolbars[i]}).element)&&(o(t[i])&&this._createContainers(r,s),e.appendChild(s))}return!0},e._initToolbarItem=function(t){if(!t.visibility)return null;var e,i=new We(this._postfix,t,this._oPub);for(e in t.groups){var n=t.groups[e],n=(n.name||(n.name=e),this._initGroupItem(n));n&&i.element.appendChild(n.element)}return i},e._initGroupItem=function(t){if(!1===t.visibility)return null;t.visibility=!0;var e,i=new Ve(this._postfix,t,this._oPub);for(e in t.buttons){var n=t.buttons[e],n=(n.name||(n.name=e),this._initButtonItem(n));n&&n.forEach(function(t){i.element.appendChild(t.element)})}var s=new z(this._postfix,{name:"showBefore",visibility:!0,location:i.name,tagName:"SPAN",iconClass:"ds-dvs-ui-move_right dvs-nodisplay"},this._oPub),r=new z(this._postfix,{name:"showAfter",visibility:!0,location:i.name,tagName:"SPAN",iconClass:"ds-dvs-ui-move_left dvs-nodisplay"},this._oPub);return i.element.appendChild(s.element),i.element.appendChild(r.element),i},e._initButtonItem=function(e){var i,t,n,s=this;if(!1!==e.visibility)return e.visibility=!0,i=this.uiConfig.tipsConfig,"pagination"===e.name?(t=[{name:"pagerInput",sequence:e.sequence,tagName:"input",text:"0"},{name:"pageBreak",sequence:e.sequence,tagName:"p",text:""},{name:"pagerLabel",sequence:e.sequence,tagName:"label",text:"0"}],n=[],t.forEach(function(t){n.push(new z(s._postfix,{visibility:e.visibility,name:t.name,sequence:t.sequence,location:e.location,text:t.text||"",tagName:t.tagName,title:i[e.name]}))}),n):(f({title:i[e.name]},e),[new z(this._postfix,e,this._oPub)])},e._assembleConfig=function(t){var e,i,n,s,r={},o={},a=t.toolbars,l=t.groups,h=t.buttons;for(e in a){var u=Boolean(a[e]);r[e]={name:e,visibility:u,groups:(null==(u=a[e])?void 0:u.groups)||{}}}for(i in l)o[i]=l[i];for(n in h){var c,d=h[n],_=d.location,p=o[_];p?(p.buttons=p.buttons||{},b(((c={})[n]=d,c),p.buttons)):this._emit(Tt,{code:80024,message:"The group ".concat(_," is not exist.")})}for(s in o){var f,v=o[s],m=v.location,g=r[m];g?b(((f={})[s]=v,f),g.groups):this._emit(Tt,{code:80024,message:"The toolbar ".concat(m," is not exist.")})}return r},e._initSidebar=function(){var t=this.uiConfig,e=0,i=t.tree&&t.tree.visibility,n=t.tag&&t.tag.visibility;if(!i&&!n)return null;var s=new U(this._postfix,{name:"sidebar",visibility:t.showSidebar&&(i||n)}),r="",o='<ul id="navChange'.concat(this._postfix,'" class="dvs-navChange">'),a='<ul id="paneShow'.concat(this._postfix,'" class="dvs-paneShow">');return o+='<li id="DirctoryTreeNav'.concat(this._postfix,'" sidetype="tree" class="dvs-DirctoryTreeNav').concat(0===e?" dvs-activeTab":""," ").concat(i?"":"dvs-disabled",'">\n <div class="ds-dvs-ui-iconfont ').concat(t.tree.iconClass,'"></div>\n </li>'),a+='<li id="DirctoryTree'.concat(this._postfix,'" sidetype="tree" class="dvs-DirctoryTree').concat(e?" dvs-nodisplay":""," ").concat(i?"":"dvs-disabled",'">\n <ul id="treeLists').concat(this._postfix,'" class="dvs-treeLists"></ul>\n <div id=\'addFolderBox').concat(this._postfix,"' class='dvs-addFolderBox'>\n <div id='addFolder").concat(this._postfix,"' class='dvs-addFolder'>Add folder</div>\n </div>\n </li>\n "),i&&e++,o+='<li id="TagsNav'.concat(this._postfix,'" sidetype="tag" class="dvs-TagsNav').concat(0===e?" dvs-activeTab":""," ").concat(n?"":"dvs-disabled",' ">\n <div class="ds-dvs-ui-iconfont ').concat(t.tag.iconClass,'"></div>\n </li>'),a+='<li id="Tags'.concat(this._postfix,'" sidetype="tag" class="dvs-Tags').concat(e?" dvs-nodisplay":""," ").concat(n?"":"dvs-disabled",'">\n \n <ul id="tagLists').concat(this._postfix,'" class="dvs-tagLists"></ul>\n <div id=\'addTagBox').concat(this._postfix,"' class='dvs-addTagBox'>\n <div id='addTag").concat(this._postfix,"' class='dvs-addTag'>Add tag</div>\n </div>\n </li>"),n&&e++,r=(r+=(o+="</ul>")+(a+="</ul>"))+'<div id="stretchBar'.concat(this._postfix,'" class="dvs-stretchBar"></div>'),s.element.innerHTML=r,s.element},e._initHiddenBox=function(){this.uiConfig;return new U(this._postfix,{name:"hiddenBox"}).element},e.bindContent=function(t){var e=this._myQueryById("content"+this._postfix),i=this._myQueryById("header"+this._postfix);if(!t||!i||!e)return!1;var n=document.createElement("div");return n.setAttribute("style","display:flex;flex-direction:column;width:100%;height:100%;"),n.id="contentContainer"+this._postfix,n.appendChild(i),n.appendChild(e),t.appendChild(n),this.contentContainer=n,!0},e.unbindContent=function(t){void 0===t&&(t=!1);var t=null==(t=this.viewerContainer)?void 0:t.el,e=this.contentContainer;if(!t||!e)return!1;var i=e.querySelector("#content"+this._postfix),n=e.querySelector("#header"+this._postfix),s=this._myQueryById("showImageArea"+this._postfix);return n&&L(n,t.children[0],t),s&&i&&s.appendChild(i),e&&e.parentNode&&e.parentNode.removeChild(e),!(this.contentContainer=null)},e.createCustomElement=function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=!1),!r(t=u(t)?document.getElementById(t):t))return null;t=new Ye({el:t,sequence:e,isFull:i,pubsub:this._oPub,container:this._myQueryById("container"+this._postfix)}),e=t.uid;return this._customElements[e]=t},e.removeAllCustomElements=function(){for(var t in this._customElements)this._customElements[t].element=null,this._customElements[t]=null;this._customElements=null},e.dispose=function(){s.prototype.dispose.call(this),this.uiConfig=null,this._assembledConfig=null;for(var t=Object.keys(this._customElements),e=0,i=t.length;e<i;e++){var n=t[e],n=this._customElements[n];n&&n.dispose(),n=null}this._customElements=null,this.contentContainer=null,this.viewerContainer&&(this.viewerContainer.el=null),this.viewerContainer=null},t}(E);function Ae(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Fe(t,e,i){e&&Ae(t.prototype,e),i&&Ae(t,i),Object.defineProperty(t,"prototype",{writable:!1})}var He=function(){function t(t,e){this.useWorker=!0,this.workers_archive=[],this.taskUid=null,this.useWorker=t,this.cores=2,this.workerBlobURL=e}var e=t.prototype;return e.resize=function(t,e,i,n,s,r){return this.useWorker?this.resizeWithWorker(t,e,i,n,s,r):this.resizeWithoutWorker(t,n,s,r)},e.resizeWithoutWorker=function(t,e,i,D){for(var n=t.width,s=t.height,r=(e=Math.round(e),s/(i=Math.round(i))),o=t.getContext("2d"),a=[],l=2*Math.ceil(s/this.cores/2),h=[],u=-1,c=0;c<this.cores;c++){var d,_=u+1;s<=_||(u=_+l-1,u=Math.min(u,s-1),d=l,d=Math.min(l,s-_),a[c]={},a[c].source=o.getImageData(0,_,n,l),a[c].target=!0,a[c].start_y=Math.ceil(_/r),a[c].height=d,_={width_source:n,height_source:a[c].height,width:e,height:Math.ceil(a[c].height/r),core:c,source:a[c].source.data.buffer||a[c].source.data},h[c]=_)}for(var p=h.length,f=[],v=0;v<p;v++){for(var m=h[v],O=m.core,g=m.width_source,b=m.height_source,y=m.width,w=m.height,x=g/y,C=b/w,N=Math.ceil(x/2),W=Math.ceil(C/2),S=new Uint8ClampedArray(m.source),m=(S.length,y*w*4),V=new ArrayBuffer(m),I=new Uint8ClampedArray(V,0,m),k=0;k<w;k++)for(var M=0;M<y;M++){for(var B=4*(M+k*y),T=0,P=0,Y=0,X=0,A=0,F=0,H=0,Q=k*C,q=Math.floor(M*x),j=Math.ceil((M+1)*x),K=Math.floor(k*C),G=Math.ceil((k+1)*C),j=Math.min(j,g),G=Math.min(G,b),R=K;R<G;R++)for(var $=Math.abs(Q-R)/W,J=M*x,Z=$*$,L=q;L<j;L++){var E=Math.abs(J-L)/N,E=Math.sqrt(Z+E*E);1<=E||(H+=(T=2*E*E*E-3*E*E+1)*S[3+(E=4*(L+R*g))],Y+=T,X+=(T=S[3+E]<255?T*S[3+E]/250:T)*S[E],A+=T*S[1+E],F+=T*S[2+E],P+=T)}I[B]=X/P,I[1+B]=A/P,I[2+B]=F/P,I[3+B]=H/Y}f.push({core:O,target:I})}for(var U=0;U<p;U++){var tt=f[U],et=Math.ceil(a[U].height/r);if(a[U].target=o.createImageData(e,et),a[U].target.data.set)a[U].target.data.set(tt.target);else for(var it=a[U].target.data.length,z=0;z<it;z++)a[U].target.data[z]=tt.target[z]}return Promise.resolve(a)},e.resizeWithWorker=function(t,e,i,l,n,s){for(var h=this,r=Math.floor(e),o=Math.floor(i),a=(l=Math.round(l),o/(n=Math.round(n))),u=t.getContext("2d"),c=[],d=2*Math.ceil(o/this.cores/2),_=-1,p=0;p<this.cores;p++){var f,v,m=_+1;o<=m||(_=m+d-1,_=Math.min(_,o-1),f=d,f=Math.min(d,o-m),c[p]={},c[p].source=u.getImageData(0,m,r,d),c[p].target=!0,v=Math.ceil(m/a),c[p].start_y=v,c[p].height=f,c[p].height_part=Math.ceil((m+f)/a)-v)}t=u=null;for(var g=[],b=function b(t){if(c[t]==undefined)return"continue";var a=new Worker(h.workerBlobURL),e=new Promise(function(r,o){a.onmessage=function(t){a.terminate(),a.onmessage=null,a.onerror=null,a=null,t.data.taskUid!==h.taskUid&&o(!1);var e=t.data.core,i=c[e].height_part;if(c[e].target=document.createElement("canvas").getContext("2d").createImageData(l,i),c[e].target.data.set)c[e].target.data.set(t.data.target);else for(var n=c[e].target.data.length,s=0;s<n;s++)c[e].target.data[s]=t.data.target[s];r(e)},a.onerror=function(t){a.terminate(),a.onmessage=null,a.onerror=null,a=null,o(t)}}),e=(g.push(e),{width_source:r,height_source:c[t].height,width:l,height:c[t].height_part,core:t,source:c[t].source.data.buffer||c[t].source.data,taskUid:s});try{a.postMessage(e,[e.source])}catch(i){a.postMessage(e)}},y=0;y<this.cores;y++)b(y);return Promise.all(g).then(function(t){return Promise.resolve(c)}).catch(function(t){return Promise.reject(t)})},t}(),Qe=function(_){function t(t,e,i,n,s,r,o){e=_.call(this,e)||this;return e._canvasItem=null,e.renderImg=null,e.imgSrc=null,e.uid="",e.tags=[],e.optimization=!1,e._dataStore=null,e._showPageNumber=!1,e._showCheckbox=!1,e._currentPage=-1,e._isSelected=!1,e.currentPage=-1,e.isSelected=!1,e._latestState={currentPage:-1,_showPageNumber:!1,_showCheckbox:!1,isSelected:!1,checkbox:{},pageNumber:{}},e.allowCrossOrigin=!0,e.fitRatio=0,e._canvasWidth=0,e._canvasHeight=0,e._rectArr=[],e.checkbox={visibility:"hidden",width:"",height:"",minWidth:0,maxWidth:1e4,minHeight:0,maxHeight:1e4,background:"#fff",borderWidth:0,borderRadius:0,borderColor:"#000",opacity:1,left:0,top:0,right:"",bottom:"",checkMarkColor:"#000",checkMarkLineWidth:1,lineCap:"butt",lineJoin:"miter"},e.pageNumber={visibility:"hidden",width:"",height:"",minWidth:0,maxWidth:1e4,minHeight:0,maxHeight:1e4,background:"#fff",borderWidth:0,borderRadius:0,borderColor:"#000",opacity:1,color:"#000",fontSize:12,fontFamily:"sans-serif",textAlign:"center",textBaseline:"middle",left:"",top:"",right:"",bottom:""},e.workBlobURL=null,e.optimizeImage=!0,e.workerTimer=null,e.workBlobURL=r,e.hermite=new He(!0,e.workBlobURL),e.optimizeImage=o,document.documentMode===undefined&&!c()||(e.optimizeImage=!1),e._dataStore=i,t&&e.init(t),e.updateCheckboxConfig(n),e.updatePageNumberConfig(s),e}h(t,_);var e=t.prototype;return e.setOptimizeImage=function(t){this.optimizeImage!==t&&(this.optimizeImage=t)},e.updateCheckboxConfig=function(t){Object.assign(this.checkbox,t)},e.updatePageNumberConfig=function(t){Object.assign(this.pageNumber,t)},e.init=function(t){for(var e in t)e!==undefined&&t[e]&&(this[e]=t[e]);this.renderImg=null},e.updateData=function(t){var e=t.data,i=t.tags,t=t.optimization;e!==this.imgSrc&&(this.imgSrc=e,this.renderImg&&(this.renderImg.onload=null),this.renderImg=null,this.tags=i,this.optimization=t)},e.emptyPage=function(){this.renderImg&&(this.renderImg.onload=null),this.renderImg=null,this._canvasItem&&(this._canvasItem.width=1,this._canvasItem.height=1,this._canvasItem.getContext("2d").clearRect(0,0,1,1),this._canvasItem.width=0,this._canvasItem.height=0)},e.dispose=function(){_.prototype.dispose.call(this),this.emptyPage(),this.imgSrc=null,this._canvasItem=null},e.render=function(t){var e=this;if(void 0===t&&(t=!0),!this._canvasItem||this._canvasItem.clientWidth<=0||this._canvasItem.clientHeight<=0)return!1;if(this.renderImg)this.renderImg.complete&&(this.renderImg.onload=null,this._renderImage(t));else{if(!this.imgSrc)return this._clearCanvas(),!1;var i=this.renderImg||new Image,n=(this.allowCrossOrigin&&(i.crossOrigin="anonymous"),this.width),s=this.height,r=this.dpr,o=this._dataStore.getMid(this.uid),a=o.tempWidth,o=o.tempHeight;a&&o&&(r=Math.min(n/r/a,s/r/o,1),n=Math.floor(r*a),s=Math.floor(r*o)),i.src=this.imgSrc,i.onload=function(){e._renderImage(t),i.onload=null},this.renderImg=i}},e._renderImage=function(t){var r,e,o,a,l,h,u=this,c=(void 0===t&&(t=!0),this.renderImg),d=this._canvasItem;c&&d&&((r=d.getContext("2d"))&&(e=this._calDrawImagePos(c),o=e.left,a=e.top,l=e.width,h=e.height,r.save(),r.clearRect(0,0,d.width,d.height),r.drawImage(c,o,a,l,h),r.restore(),this._renderPageNumber(),this._renderCheckbox(),this.drawRect(),this.workerTimer&&clearTimeout(this.workerTimer),this.optimizeImage&&this.hermite&&(this.workerTimer=setTimeout(function(){var t=document.createElement("canvas"),e=(t.id="optimizeMinImage_".concat(u.uid),t.getContext("2d")),i=c.naturalWidth,n=c.naturalHeight,s=g(11);t.width=i,t.height=n,e.drawImage(c,0,0),u.hermite.taskUid=s,u.hermite.resize(t,i,n,l,h,s).then(function(t){r.save(),r.clearRect(0,0,d.width,d.height),t.forEach(function(t){var e=Math.round(o),i=Math.round(t.start_y+a);r.putImageData(t.target,e,i)}),r.restore(),u._renderPageNumber(),u._renderCheckbox(),u.drawRect()}).catch(function(t){})},100)),t&&_.prototype._emit.call(this,S,this._currentPage-1)))},e._calDrawImagePos=function(t){var e=t.naturalWidth,t=t.naturalHeight,i={left:0,top:0,width:0,height:0};if(this.width<=0||this.height<=0)return i;var n,s,r,o,a=this.dpr;return this.optimization||(s=this.width,r=this.height,null!=(n=this._dataStore.getMid(this.uid))&&n.tempWidth&&null!=n&&n.tempHeight&&(o=Math.min(s/a/n.tempWidth,r/a/n.tempHeight,1),s=Math.floor(o*n.tempWidth),r=Math.floor(o*n.tempHeight)),o=Math.max(e/s,t/r),e/=this.fitRatio=o,t/=o),i={left:Math.floor((this.width-e*a)/2),top:Math.floor((this.height-t*a)/2),width:Math.floor(e*a),height:Math.floor(t*a)}},e._renderPageNumber=function(){var t=this.renderImg,e=this._canvasItem,i=this.pageNumber;t&&e&&"visible"===i.visibility&&(t=this._normalizeStyle(i),(e=e.getContext("2d")).save(),e.globalAlpha=i.opacity,this._renderOutlinePath(e,t,"out"),e.clip(),this._renderOutlinePath(e,t,"in"),this._renderBackground(e,i),this._renderOutlinePath(e,t,"center"),this._renderBorder(e,t,i),this._renderText(String(this._currentPage),e,t,i),e.restore())},e._renderCheckbox=function(){var t=this.renderImg,e=this._canvasItem,i=this.checkbox;t&&e&&"visible"===i.visibility&&(t=this._normalizeStyle(i),(e=e.getContext("2d")).save(),e.globalAlpha=i.opacity,this._renderOutlinePath(e,t,"out"),e.clip(),this._renderOutlinePath(e,t,"in"),this._renderBackground(e,i),this._renderOutlinePath(e,t,"center"),this._renderBorder(e,t,i),this._isSelected&&this._renderCheckMark(e,t,i),e.restore())},e._normalizeStyle=function(t){var e=this.width,i=this.height,n=t.width,s=t.height,r=t.left,o=t.top,a=t.right,l=t.bottom,h=t.translateX,u=t.translateY,c=t.borderRadius,d=t.borderWidth,_=t.fontSize,t=t.checkMarkLineWidth,e=(p(d=this._normalizeToPixel(d,0))||(d=0),_!==undefined&&p(_=this._normalizeToPixel(_,0))||(_=0),t!==undefined&&p(t=this._normalizeToPixel(t,0))||(t=0),n=this._normalizeToPixel(n,e),s=this._normalizeToPixel(s,i),r=this._normalizeToPixel(r,e),o=this._normalizeToPixel(o,i),a=this._normalizeToPixel(a,e),l=this._normalizeToPixel(l,i),(n=p(n)?n:p(r)&&p(a)?e-r-a:0)<2*d&&(n=2*d),(s=p(s)?s:p(l)&&p(o)?i-o-l:0)<2*d&&(s=2*d),p(a)&&!p(r)&&(r=e-n-a),p(l)&&!p(o)&&(o=i-s-l),p(r)||(r=0),p(o)||(o=0),h=this._normalizeToPixel(h,n),u=this._normalizeToPixel(u,s),p(h)&&(r+=h),p(u)&&(o+=u),this._normalizeToPixel(c,n)),a=this._normalizeToPixel(c,s);return p(e)&&p(a)?(e=Math.max(0,Math.min(e,n/2)),a=Math.max(0,Math.min(a,s/2)),p(c)&&(a=e=Math.min(e,a))):a=e=0,{left:r,top:o,width:n,height:s,borderRadiusX:e,borderRadiusY:a,borderWidth:d,fontSize:_,checkMarkLineWidth:t}},e._normalizeToPixel=function(t,e){if(p(t))return t*this.dpr;if(u(t)){if(!(t=t.trim()).length)return t;var i=t.match(/^-?\d+\.?\d?%$/);if(i)return parseFloat(i[0])/100*e;i=t.match(/^-?\d+\.?\d?px$/);if(i)return parseFloat(i[0])*this.dpr}return""},e._renderText=function(t,e,i,n){var s=i.left,r=i.top,o=i.width,a=i.height,i=i.fontSize,l=n.color,h=n.fontFamily,u=n.textAlign,n=n.textBaseline;e.textAlign=u,e.textBaseline=n,e.fillStyle=l,e.font="".concat(i,"px ").concat(h),e.fillText(t,s+o/2,r+a/2+i/8,o)},e._renderCheckMark=function(t,e,i){var n=e.left,s=e.top,r=e.width,o=e.height,a=e.borderWidth,e=e.checkMarkLineWidth,l=i.checkMarkColor,h=i.lineCap,i=i.lineJoin,u=Math.max(Math.min(r-2*a,o-2*a),0);0!==u&&(r<o?(n+=a,s=s+a+(o-r)/2):(n=n+a+(r-o)/2,s+=a),t.beginPath(),t.moveTo(n+.15*u,s+.5*u),t.lineTo(n+.4*u,s+.8*u),t.lineTo(n+.85*u,s+.2*u),t.lineCap=h,t.lineJoin=i,t.lineWidth=e,t.strokeStyle=l,t.stroke())},e._renderBackground=function(t,e){e=e.background;e&&(t.fillStyle=e,t.fill())},e._renderOutlinePath=function(t,e,i){var n=e.left,s=e.top,r=e.width,o=e.height,a=e.borderWidth,l=e.borderRadiusX,e=e.borderRadiusY,h=0,u=("center"===(i=void 0===i?"out":i)?h=a/2:"in"===i&&(h=a),[{x:n+l,y:s+e,start:Math.PI,end:3*Math.PI/2},{x:n+r-l,y:s+e,start:3*Math.PI/2,end:2*Math.PI},{x:n+r-l,y:s+o-e,start:0,end:Math.PI/2},{x:n+l,y:s+o-e,start:Math.PI/2,end:Math.PI}]),c=Math.max(l-h,0),d=Math.max(e-h,0);if(t.beginPath(),t.ellipse)for(var _=0;_<4;_++){var p=u[_],f=p.x,v=p.y,m=p.start,p=p.end;t.ellipse(f,v,c,d,0,m,p)}else t.rect(n,s,r,o);t.closePath()},e._renderBorder=function(t,e,i){i=i.borderColor,e=e.borderWidth;e&&(t.strokeStyle=i,t.lineWidth=e,t.stroke())},e._clearCanvas=function(){var t;!this._canvasItem||(t=this._canvasItem.getContext("2d"))&&t.clearRect(0,0,this._canvasItem.width,this._canvasItem.height)},e.setLatestState=function(t){this._latestState=t},e._setCanvasWidth=function(t){this._canvasItem&&(this._canvasWidth=t,this._canvasItem.width=t)},e._setCanvasHeight=function(t){this._canvasItem&&(this._canvasHeight=t,this._canvasItem.height=t)},e.resizeCanvasSize=function(t){void 0===t&&(t=!1);var e=this._canvasItem;if(!e||!this.renderImg&&!this.imgSrc)return!1;var i,n=e.clientWidth*this.dpr,e=e.clientHeight*this.dpr;return!(n<=0||e<=0)&&(i=this._checkIfRenderPageOrBox(),!(Math.abs(n-this.width)<=2&&Math.abs(e-this.height)<=2&&this.renderImg&&!i)&&(this.width!==n&&(this.width=n),this.height!==e&&(this.height=e),t&&-1===this.imgSrc.indexOf("blob:")&&(this.renderImg=null),void this.render()))},e._checkIfRenderPageOrBox=function(){var t,e=!1;for(t in this._latestState){var i=this["_"+t],n=this._latestState[t];if(!this.isEqual(i,n))switch(this["_"+t]=n,t){case"currentPage":"visible"===this.pageNumber.visibility&&(e=!0);break;case"isSelected":"visible"===this.checkbox.visibility&&(e=!0);break;default:e=!0}}return e},e.isEqual=function(t,e){if(o(t)){if(!o(e))return!1;for(var i=Object.keys(e),n=0,s=i.length;n<s;n++){var r=i[n];if(t[r]!==e[r])return!1}return!0}return t===e},e.setRect=function(t){this._rectArr=t},e.drawRect=function(){var t=this._rectArr;if(0!==t.length&&this.renderImg){var e=this._dataStore.getMid(this.uid);if(null!=e&&e.tempWidth&&null!=e&&e.tempHeight&&this._canvasItem)for(var i=this._canvasItem.getContext("2d"),n=this.dpr,s=e.tempWidth/this.renderImg.naturalWidth,r=0;r<t.length;r++){for(var o=t[r],a=o.cropBoxStyle,l=a.ctrlBorderWidth,h=a.ctrlBackground,u=a.ctrlBorderColor,c=a.ctrlBorderRadius,d=a.ctrlWidth,_=a.ctrlHeight,p=a.borderColor,f=a.borderWidth,v=a.invalidBorderColor,m=a.invalidCtrlBorderColor,g=a.background,b=a.dashLine,a=a.enableConcaveBorderColor,y=o.probePoints.slice(0,8),w=o.midpoints.slice(0,8),x=0;x<4;x++){var C=this._transformRect(y[2*x]/s,y[2*x+1]/s),S=this._transformRect(w[2*x]/s,w[2*x+1]/s);y[2*x]=C.x,y[2*x+1]=C.y,w[2*x]=S.x,w[2*x+1]=S.y}i.save();try{i.setLineDash(b.map(function(t){return t*n}))}catch(B){}i.fillStyle=g,i.lineWidth=f*n,a&&!o.isConvex?i.strokeStyle=v:i.strokeStyle=p,i.beginPath(),i.moveTo(y[0],y[1]),i.lineTo(y[2],y[3]),i.lineTo(y[4],y[5]),i.lineTo(y[6],y[7]),i.closePath(),i.stroke(),i.restore(),i.lineWidth=l*n,i.fillStyle=h,a&&!o.isConvex?i.strokeStyle=m:i.strokeStyle=u;for(var I=Math.min(c,d/2)*n,k=Math.min(c,_/2)*n,M=0;M<4;M++)this._drawRoundedRectangle(i,{x:y[2*M],y:y[2*M+1],width:d*n,height:_*n,radiusX:I,radiusY:k}),i.stroke(),""!==h&&i.fill(),this._drawRoundedRectangle(i,{x:w[2*M],y:w[2*M+1],width:d*n,height:_*n,radiusX:I,radiusY:k}),i.stroke(),""!==h&&i.fill()}}},e._transformRect=function(t,e){var i=this.renderImg,n=i.naturalWidth,i=i.naturalHeight,s=this.fitRatio;return{x:this.width/2+(t-n/2)/s*this.dpr,y:this.height/2+(e-i/2)/s*this.dpr}},e._drawRoundedRectangle=function(t,e){var i=e.width,n=e.height,s=e.radiusX,r=e.radiusY,o=e.x,e=e.y,a=[{x:o-i/2+s,y:e-n/2+r,start:Math.PI,end:3*Math.PI/2},{x:o+i/2-s,y:e-n/2+r,start:3*Math.PI/2,end:2*Math.PI},{x:o+i/2-s,y:e+n/2-r,start:0,end:Math.PI/2},{x:o-i/2+s,y:e+n/2-r,start:Math.PI/2,end:Math.PI}];if(t.beginPath(),t.ellipse)for(var l=0;l<4;l++){var h=a[l];t.ellipse(h.x,h.y,s,r,0,h.start,h.end)}else t.rect(o-i/2,e-n/2,i,n);t.closePath()},Fe(t,[{key:"dpr",get:y},{key:"width",get:function(){return this._canvasItem?this._canvasItem.width:0},set:function(t){this._setCanvasWidth(t)}},{key:"height",get:function(){return this._canvasItem?this._canvasItem.height:0},set:function(t){this._setCanvasHeight(t)}}]),t}(E),D=function(){function t(t){void 0===t&&(t=[]),this.array=[],this.array=O(t)}var e=t.prototype;return e.add=function(t){return!~this.array.indexOf(t)&&(this.array.push(t),!0)},e.delete=function(t){t=this.array.indexOf(t);return-1<t&&(this.array.splice(t,1),!0)},e.concat=function(t){return O(this.array.concat(t))},e.equal=function(t){if(t.length!==this.array.length)return!1;if(!t.length)return!0;for(var e=0;e<this.array.length;e++)if(this.array[e]!==t[e])return!1;return!0},t}(),qe=function(o){function t(t,e,i,n,s,r){e=o.call(this,e)||this;return e.uid="",e._pubSub=null,e._viewerContainer=null,e._postfix="",e._thumbnailElement=null,e._dataStore=null,e.isInner=!1,e._iObserver=null,e._customThumbnailEvent=null,e._size=180,e._mouseShape="pointer",e._scrollDirection="vertical",e._sequence=0,e._location="horizontal",e._showThumbnail=!0,e._showPageNumber=!1,e._pageNumberConfig={},e._checkboxConfig={},e._optimizeImage=!0,e._showRemoveBtn=!1,e._fullThumbnail=!1,e._multipleMode=!1,e.allowPageDragging=!0,e._allowResizing=!1,e.allowHover=!0,e.allowKeyboardControl=!0,e.autoChangeIndex=!1,e.rows=1,e.columns=1,e._background="rgba(67,66,70,1)",e._border="1px solid rgba(27,27,29,1)",e._pageBackground="rgba(0,0,0,0)",e._pageBorder="1px solid rgba(128,128,128,1)",e._selectedPageBackground="rgba(127,133,251,1)",e._selectedPageBorder="1px solid rgba(255,0,0,1)",e.hoverPageBackground="rgba(196,250,248,1)",e.hoverPageBorder="1px solid rgba(255,255,0,1)",e.placeholderBackground="rgba(255,192,203,1)",e._pageMargin=10,e._pageMarginNumber=0,e._currentPageMargin=-1,e.isDrag=!1,e.ifDragMoves=!1,e._dragTimer=null,e._dragStart=!1,e.needClick=!0,e.thumbMoveOption={napX:0,napY:0,clickX:0,clickY:0,target:null},e._stretchItem=null,e._isStretching=!1,e._isCrop=!1,e._topImageIndex=-1,e._prtScrollOnce=!1,e._calculateTopIndex=-1,e._showUids=new D,e._showIndexes=new D,e._renderIndexes=new D,e._renderUids=new D,e._tempThumbnailSize={width:1,height:1},e._splitTimer=null,e.selectedIndexes=[],e.currentIndex=-1,e._thumbnailCanvas=[],e._uidTbCanvas={},e._eventList={},e._renderTimer=null,e.isDragUp=!1,e.cropBoxStyle={borderWidth:1,borderColor:"#000",invalidBorderColor:"#000",dashLine:[4,2],background:"",ctrlBorderWidth:1,ctrlBorderRadius:0,ctrlBorderColor:"#000",invalidCtrlBorderColor:"#000",ctrlBackground:"",ctrlWidth:8,ctrlHeight:8,enableConcaveBorderColor:!1},e.workBlobURL=null,e._viewerContainer=i,e._postfix=n,e._dataStore=s,e.workBlobURL=r,Object.assign(e.cropBoxStyle,t.cropBoxStyle||{}),e._thumbnailInit(t),e}h(t,o);var e=t.prototype;return e._thumbnailInit=function(t){this._initThumbnailUi(t.uid),this._initThumbnailConfig(t),this._initIntersectionObserver(),this._bindSelfEvents(),this._bindUiEvent()},e._initThumbnailConfig=function(t){for(var e in this._pubSub=new E(t.pubsub),t)"pubsub"!==(e=e.replace("canvas",""))&&(this[e]=t[e])},e._initThumbnailUi=function(t){var e=new U(t,{name:"Thumbnail"}),i="horizontal"===this.location?"":"dvs-nodisplay",n="vertical"===this.location?"":"dvs-nodisplay";e.element.innerHTML="\n <div id='stretchBarLeft".concat(t,"' class='dvs-stretchBar dvs-stretchLeft ").concat(i,"'></div>\n <div id='stretchBarTop").concat(t,"' class='dvs-stretchBar dvs-stretchTop ").concat(n,"'></div>\n <div id='stretchBarRight").concat(t,"' class='dvs-stretchBar dvs-stretchRight ").concat(i,"'></div>\n <div id='stretchBarBottom").concat(t,"' class='dvs-stretchBar dvs-stretchBottom ").concat(n,"'></div>\n <ul id=\"thumbLists").concat(t,'" class="dvs-thumbLists"></ul>\n '),this._thumbnailElement=e.element},e._initIntersectionObserver=function(){var t,e=this;window.IntersectionObserver&&this._thumbnailElement&&(t=new IntersectionObserver(function(t){e._handleObservePages(t)},{root:this._thumbnailElement.querySelector(".dvs-thumbLists")}),this._iObserver=t)},e._bindSelfEvents=function(){var t,e,i=this,n=((t={})[Ce]=this._updateProps,t[Se]=this.scrollTo,t[Ie]=this.setViewMode,t);for(e in this._eventList=n)this._pubSub._on(e,n[e].bind(this));o.prototype._on.call(this,M,this._documentMouseMove.bind(this)),o.prototype._on.call(this,B,this._documentMouseUp.bind(this)),o.prototype._on.call(this,ot,function(t){"remove"===t.action&&(i._prtScrollOnce=!0)})},e._bindUiEvent=function(){var t,i=this,e=this._thumbnailElement;e&&((t=new De(e)).onPointDown=function(t){i._thumbnailDragStart(t),i._thumbnailPointerDown(t)},t.onPointMove=function(t){i._thumbnailDragMove(t),i._thumbnailPointerMove(t)},t.onPointUp=function(t){i._thumbnailPointerUp(t)},t.onClick=function(t){i._thumbnailClick(t)},t.onRightClick=function(t){i._thumbnailRightClick(t)},t.onDoubleClick=function(t){i._thumbnailDoubleClick(t)},t.onPointOver=function(t){i._thumbnailMouseOver(t)},t.onPointOut=function(t){i._thumbnailMouseOut(t)},t.getTarget=function(t,e){return e!==undefined?i.getImageItem(e):i.getImageItem(t)},this._customThumbnailEvent=t,_(e.querySelector(".dvs-thumbLists"),"scroll",function(){i._thumbnailScroll()}),_(e,c()?"touchstart":"mousedown",function(t){i._thumbnailStretchStart(t)},{passive:!1}),_(e,"click",function(t){o.prototype._emit.call(i,xt,{viewerId:i._postfix.replace("-",""),thumbnailId:i.uid}),v(t)}))},e.unbindEvents=function(){var t;if(null!=(t=this._customThumbnailEvent)&&t.dispose(),this._customThumbnailEvent=null,this._pubSub)for(var e in this._eventList)this._pubSub._off(e)},e.unbindUi=function(){this.unbindEvents();var t,e=this._thumbnailCanvas;if(e)for(var i=0;i<e.length;i++){var n=e[i];n&&n.dispose()}this._thumbnailCanvas=null,this._viewerContainer=null,(this._stretchItem=null)!=(t=this._iObserver)&&t.disconnect(),(this._iObserver=null)!=(t=this._thumbnailElement)&&null!=(t=t.parentElement)&&t.removeChild(this._thumbnailElement),this._thumbnailElement=null},e.updateContent=function(t){this._patch(t=void 0===t?[]:t),this._updateElements(),this.renderCanvas()},e.updatePageItem=function(t){var e=this._thumbnailCanvas;if(e)for(var i=0;i<e.length;i++){var n=e[i];if(n.uid===t.uid){n.updateData(t),-1!==this._renderUids.array.indexOf(t.uid)&&n.resizeCanvasSize(this.isInner&&1===this.rows&&1===this.columns);break}}},e.renderCanvas=function(){var r=this;this._renderTimer&&clearTimeout(this._renderTimer),this._renderTimer=setTimeout(function(){if(r._thumbnailCanvas)for(var t=r.selectedIndexes,e=r._renderUids.array,i=r._thumbnailCanvas.length,n=0;n<i;n++){var s=r._thumbnailCanvas[n];-1<e.indexOf(s.uid)?(s.setLatestState({currentPage:n+1,isSelected:-1!==t.indexOf(n),showPageNumber:"visible"===r.pageNumber.visibility,showCheckbox:"visible"===r.checkbox.visibility,checkbox:Object.assign({},r.checkbox),pageNumber:Object.assign({},r.pageNumber)}),s.resizeCanvasSize(1===r.rows&&1===r.columns&&r.isInner)):null!=s&&s.emptyPage()}},100)},e.keydownCallBack=function(t){this.selectImageByKey(t),this._pubSub._emit(it,t)},e.keyupCallBack=function(t){this._pubSub._emit(nt,t)},e.selectImageByKey=function(t){if(this.allowKeyboardControl&&this._thumbnailCanvas.length){var e=this.selectedIndexes.slice().pop(),i=this.rows,n=t