@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
62 lines • 255 kB
JavaScript
/* @license */
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("kendo.mobile.scroller.min.js"),require("kendo.toolbar.min.js"),require("kendo.pager.min.js"),require("kendo.combobox.min.js"),require("kendo.textbox.min.js"),require("kendo.core.min.js"),require("kendo.drawing.min.js"),require("kendo.upload.min.js"),require("kendo.dialog.min.js"),require("kendo.window.min.js"),require("kendo.binder.min.js"),require("kendo.numerictextbox.min.js"),require("kendo.dropdownlist.min.js"),require("kendo.icons.min.js"),require("kendo.draganddrop.min.js"),require("kendo.form.min.js"),require("kendo.colorpicker.min.js")):typeof define==`function`&&define.amd?define([`exports`,`kendo.mobile.scroller.min`,`kendo.toolbar.min`,`kendo.pager.min`,`kendo.combobox.min`,`kendo.textbox.min`,`kendo.core.min`,`kendo.drawing.min`,`kendo.upload.min`,`kendo.dialog.min`,`kendo.window.min`,`kendo.binder.min`,`kendo.numerictextbox.min`,`kendo.dropdownlist.min`,`kendo.icons.min`,`kendo.draganddrop.min`,`kendo.form.min`,`kendo.colorpicker.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Pdfviewer={}),e.kendo._globals.MobileScroller,e.kendo._globals.Toolbar,e.kendo._globals.Pager,e.kendo._globals.Combobox,e.kendo._globals.Textbox,e.kendo._globals.Core,e.kendo._globals.Drawing,e.kendo._globals.Upload,e.kendo._globals.Dialog,e.kendo._globals.Window,e.kendo._globals.Binder,e.kendo._globals.Numerictextbox,e.kendo._globals.Dropdownlist,e.kendo._globals.Icons,e.kendo._globals.Draganddrop,e.kendo._globals.Form,e.kendo._globals.Colorpicker))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,ee,g){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),(function(e,t){var n=window.kendo,r=e.extend;r(n,{pdfviewer:{dpl:{processor:n.Class.extend({init:function(e,t){var n=this;n.options=e,n.read=e.read,n.upload=e.upload,n.download=e.download,n.viewer=t},fetchDocument:function(){var t=this,r=e.Deferred(),i=t.viewer.options.messages.errorMessages;return t.read?(e.ajax({type:t.read.type,url:t.read.url,dataType:t.read.dataType,success:function(e){typeof e!=`string`&&(e=n.stringify(e)),r.resolve(JSON.parse(e))},error:function(e){t.viewer._triggerError({error:e.responseText,message:i.parseError})}}),r):r.resolve()},fetchPageData:function(t){var n=this,r=e.Deferred(),i=n.viewer.document.pages[t-1],a={};return a[n.read.pageField]=t,i.geometries.length?r.resolve(i):e.ajax({type:n.read.type,url:n.read.url,data:a,success:function(e){r.resolve(JSON.parse(e))},error:function(e){n.viewer._triggerError({error:e.responseText,message:n.viewer.options.messages.errorMessages.parseError})}}),r},downloadFile:function(e){window.location=this.download.url+`?file=`+e},fromJSON:function(e){var t=this.viewer;t._clearPages(),t.document=e,t.document.total=t.document.pages.length,t._renderPages(),t.resize(!0),t.activatePage(1)}})}}})})(window.kendo.jQuery);function te(){return window.pdfjsLib?!window.pdfjsLib?.GlobalWorkerOptions?.workerSrc&&!window.pdfjsWorker?(console?.error(`The pdf.worker.mjs script is not loaded. The PDF.JS library will not work correctly.
Either load the script:
<script src="https://unpkg.com/pdfjs-dist@5.6.205/build/pdf.worker.mjs" type="module"><\/script>
Or set it to the GlobalWorkerOptions.workerSrc property:
<script type="module">
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@5.6.205/build/pdf.worker.mjs';
<\/script>`),!1):!0:(console?.error(`PDF.JS library is required. Make sure that it is properly loaded <script src="https://unpkg.com/pdfjs-dist@5.6.205/build/pdf.mjs" type="module"><\/script>`),!1)}kendo.pdfviewer.pdfjs={lib:window.pdfjsLib},(function(e,t){var n=kendo.Class,r=e.extend,i=JSON.parse,a=kendo.ui.progress,n=kendo.Class,o=`open`,s=n.extend({init:function(e){this.viewer=e,this.errorMessages=this.viewer.options.messages.errorMessages,this.upload=this.viewer.processor&&this.viewer.processor.upload},_initUpload:function(t,n){var i=r({select:this._onSelect.bind(this),success:this._onSuccess.bind(this),error:this._onError.bind(this),complete:this._onComplete.bind(this),showFileList:!1,multiple:!1,validation:{allowedExtensions:[`.pdf`]}},n||{});return this.upload&&r(i,{async:{saveUrl:this.upload.url,autoUpload:!0,saveField:this.upload.saveField}}),(t||e(`<input name="files" accept=".pdf" type="file" />`)).kendoUpload(i).getKendoUpload()},_onComplete:function(){a(this.viewer.pageContainer,!1)},_onSuccess:function(t){var n=i(t.response);e.isPlainObject(n)?this.viewer.processor.fromJSON(n):this.viewer._triggerError({error:n,message:this.errorMessages.parseError})},_onError:function(e){this.viewer._triggerError({error:e.XMLHttpRequest.responseText,message:this.errorMessages.notSupported})},_onSelect:function(e){var t=this,n=e.files[0];if(a(t.viewer.pageContainer,!0),!(t.viewer.trigger(o,{file:n})||t.upload)){if(n.extension.toLowerCase()!==`.pdf`){t.viewer._triggerError({error:n,message:t.errorMessages.notSupported});return}var r=new FileReader;r.onload=function(e){var n=e.target.result;let r=t.viewer._isDPLProcessor()?n:{data:n};t.viewer.fromFile(r)},r.onerror=function(){t.viewer._triggerError({error:n,message:t.errorMessages.parseError})},r.readAsArrayBuffer(n.rawFile)}}});r(kendo.pdfviewer,{UploadHelper:s})})(window.kendo.jQuery),(function(e,t){var n=e.extend,r=e.noop,i=kendo.drawing,a=i.Group,o=i.Surface,s=`render`,c=kendo.Class,l=kendo.pdfviewer.UploadHelper,u={Path:`path`,MultiPath:`multipath`,Rect:`rect`,Image:`image`,Text:`text`},d=e=>`<div class="k-page k-blank-page">
<div id="${e}" class="k-external-dropzone">
<div class="k-dropzone-inner">
<span class="k-dropzone-icon k-icon k-svg-icon k-icon-xxxl k-svg-i-upload">
<svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<path d="M32 384v96h448v-96H32zm192-64h64V192h96L256 32 128 192h96v128z"></path>
</svg>
</span>
<span class="k-dropzone-hint">Drag and drop files here to upload</span>
</div>
</div>
<input name="files" accept=".pdf" type="file" ref-pdfviewer-blank-page-upload>
</div>`,f=c.extend({init:function(t,n){this.viewer=n,this.processor=t.processor,this.options=t,this.pageNumber=t.number,this.element=e(`<div class='k-page' />`),this.element.attr(kendo.attr(`number`),this.pageNumber),this._updatePageSize(t),this.width=t.width,this.height=t.height},resize:function(e){var t=this.element;this._updatePageSize({width:Math.min(t.width()*e,this.width),height:Math.min(t.height()*e,this.height)})},_updatePageSize:function(e){typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`?(this._pageStyleId||(this._pageStyleId=kendo.guid(),this.element[0].setAttribute(kendo.attr(`page-id`),this._pageStyleId),this._sheet=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets||[],this._sheet]),this._sheet&&this._sheet.replaceSync(`[`+kendo.attr(`page-id`)+`="`+this._pageStyleId+`"] { width: `+e.width+`px; height: `+e.height+`px; }`)):this.element.width(e.width).height(e.height)},destroy:function(){this._sheet&&=(document.adoptedStyleSheets=Array.from(document.adoptedStyleSheets||[]).filter(e=>e!==this._sheet),null),kendo.destroy(this.element)},render:r}),p=f.extend({init:function(t,n){this.viewer=n,this.options=t,this._externalDropZoneId=`${n.element.attr(`id`)}-external-dropzone`,this.element=e(d(this._externalDropZoneId)),this._uploadHelper=new l(n)},_initUpload:function(){this._upload=this._uploadHelper._initUpload(this.element.find(`input[ref-pdfviewer-blank-page-upload]`),{dropZone:`#${this._externalDropZoneId}`,showFileList:!1,async:{autoUpload:!1,saveUrl:`save`}})},resize:r,_updatePageSize:r,destroy:function(){this._upload&&this._upload.destroy(),kendo.destroy(this.element)},render:r}),m=f.extend({draw:function(){var e=this,t=e.options.geometries;e.group=new a,e.surface.draw(e.group),e._drawGeometries(t),e.viewer.trigger(s,{page:this}),kendo.ui.progress(e.element,!1)},load:function(){var e=this;e.loaded||!e.processor||(e.processor.fetchPageData(e.pageNumber).then(function(t){e.options=t,e._initSurface(),e.draw()}),e.loaded=!0)},_initSurface:function(){var e={width:this.element.width(),height:this.element.height()},t=n({width:this.width,height:this.height},this.viewer.options.view);this.surface=new o(this.element,t),this._updatePageSize(e)},_drawGeometries:function(e){var t=this,n;if(e)for(var r=0;r<=e.length;r++){var i=e[r];if(i){switch(i.type){case u.Path:case u.MultiPath:n=t._drawPath(i);break;case u.Rect:n=t._drawRect(i);break;case u.Image:n=t._drawImage(i);break;case u.Text:n=t._drawText(i);break;default:n=null;break}n&&t.group.append(n)}}},_drawRect:function(e){var t=new kendo.geometry.Rect(e.point,e.size);return new i.Rect(t,{transform:this._getMatrix(e.transform),fill:e.fillOptions,stroke:e.strokeOptions})},_drawImage:function(e){var t=new kendo.geometry.Rect(e.point,e.size);return new i.Image(e.src,t,{transform:this._getMatrix(e.transform)})},_drawText:function(e){var t={transform:this._getMatrix(e.transform),stroke:e.strokeOptions,fill:e.fillOptions,font:e.font};return new kendo.drawing.Text(e.content,e.point,t)},_drawPath:function(e){for(var t={transform:this._getMatrix(e.transform),stroke:e.strokeOptions,fill:e.fillOptions},n=new i.MultiPath(t),r=0;r<e.paths.length;r++){var a=e.paths[r];if(!a.segments)return;n.moveTo.apply(n,a.point);for(var o=0;o<a.segments.length;o++){var s=a.segments[o];(s.points.length===1?n.lineTo:n.curveTo).apply(n,s.points)}a.closed&&n.close()}return n},_getMatrix:function(e){return new kendo.geometry.Matrix(...e)}});n(kendo.pdfviewer.dpl,{geometryTypes:u,Page:m}),n(kendo.pdfviewer,{BlankPage:p})})(window.kendo.jQuery);let ne=e=>{e.deleteAnnotation()},re=(e,t)=>{e.setHighlightColor(t)},ie=(e,t)=>{e.setFreeTextColor(t)},ae=(e,t)=>{e.setFreeTextFontSize(t)},oe=(e,t)=>{e.interactionMode!==t.mode&&e.setInteractionMode({mode:t.mode}),e.setAnnotationEditorMode(t)},se=e=>{e.resetAnnotationEditorMode()},ce=(e,t)=>{e.setInteractionMode({mode:t})},le=(e,t)=>n=>t(e(n)),_=(e,t,n)=>e.addEventListener&&e.addEventListener(t,n),v=(e,t,n)=>e&&e.removeEventListener&&e.removeEventListener(t,n),ue=()=>{},de=e=>e.preventDefault(),fe=/touch/;function pe(e){return e.type.match(fe)?{pageX:e.changedTouches[0].pageX,pageY:e.changedTouches[0].pageY,clientX:e.changedTouches[0].clientX,clientY:e.changedTouches[0].clientY,type:e.type,originalEvent:e,isTouch:!0}:{pageX:e.pageX,pageY:e.pageY,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY,type:e.type,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,originalEvent:e}}var me=class e{static supportPointerEvent(){return typeof window<`u`&&window.PointerEvent}get document(){return this._element?this._element.ownerDocument:document}constructor({press:e=ue,drag:t=ue,release:n=ue,mouseOnly:r=!1}){this._pressHandler=le(pe,e),this._dragHandler=le(pe,t),this._releaseHandler=le(pe,n),this._ignoreMouse=!1,this._mouseOnly=r,this._touchstart=e=>{e.touches.length===1&&this._pressHandler(e)},this._touchmove=e=>{e.touches.length===1&&this._dragHandler(e)},this._touchend=e=>{e.touches.length===0&&e.changedTouches.length===1&&(this._releaseHandler(e),this._ignoreMouse=!0,setTimeout(this._restoreMouse,2e3))},this._restoreMouse=()=>{this._ignoreMouse=!1},this._mousedown=e=>{let{which:t}=e;t&&t>1||this._ignoreMouse||(_(this.document,`mousemove`,this._mousemove),_(this.document,`mouseup`,this._mouseup),this._pressHandler(e))},this._mousemove=e=>{this._dragHandler(e)},this._mouseup=e=>{v(this.document,`mousemove`,this._mousemove),v(this.document,`mouseup`,this._mouseup),this._releaseHandler(e)},this._pointerdown=e=>{e.isPrimary&&e.button===0&&(_(this.document,`pointermove`,this._pointermove),_(this.document,`pointerup`,this._pointerup),_(this.document,`pointercancel`,this._pointerup),_(this.document,`contextmenu`,de),this._pressHandler(e))},this._pointermove=e=>{e.isPrimary&&this._dragHandler(e)},this._pointerup=e=>{e.isPrimary&&(v(this.document,`pointermove`,this._pointermove),v(this.document,`pointerup`,this._pointerup),v(this.document,`pointercancel`,this._pointerup),v(this.document,`contextmenu`,de),this._releaseHandler(e))}}cancelDrag(){v(this.document,`pointermove`,this._pointermove),v(this.document,`pointerup`,this._pointerup),v(this.document,`pointercancel`,this._pointerup)}bindTo(e){e!==this._element&&(this._element&&this._unbindFromCurrent(),this._element=e,this._bindToCurrent())}_bindToCurrent(){let e=this._element;if(this._usePointers()){_(e,`pointerdown`,this._pointerdown);return}_(e,`mousedown`,this._mousedown),this._mouseOnly||(_(e,`touchstart`,this._touchstart),_(e,`touchmove`,this._touchmove),_(e,`touchend`,this._touchend))}_unbindFromCurrent(){let e=this._element;if(this._usePointers()){v(e,`pointerdown`,this._pointerdown),v(this.document,`pointermove`,this._pointermove),v(this.document,`pointerup`,this._pointerup),v(this.document,`contextmenu`,de),v(this.document,`pointercancel`,this._pointerup);return}v(e,`mousedown`,this._mousedown),this._mouseOnly||(v(e,`touchstart`,this._touchstart),v(e,`touchmove`,this._touchmove),v(e,`touchend`,this._touchend))}_usePointers(){return!this._mouseOnly&&e.supportPointerEvent()}update({press:e=ue,drag:t=ue,release:n=ue,mouseOnly:r=!1}){this._pressHandler=le(pe,e),this._dragHandler=le(pe,t),this._releaseHandler=le(pe,n),this._mouseOnly=r}destroy(){this._unbindFromCurrent(),this._element=null}};me.default=me;let he=(...e)=>Object.assign(...e),ge=e=>e&&typeof e==`object`&&!Array.isArray(e),_e=e=>e instanceof HTMLElement,ve=e=>e&&window&&window.DotNet&&window.DotNet.DotNetObject&&e instanceof DotNet.DotNetObject,ye=(e,...t)=>{if(!t.length)return e;let n=t.shift();if(ge(e)&&ge(n))for(let t in n)t!==`__proto__`&&t!==`constructor`&&(n[t]&&n[t].__isComponent||_e(n[t])||t===`dotNetInstance`||ve(n[t])||n[t]&&n[t].buffer&&n[t].buffer instanceof ArrayBuffer||ge(n[t])&&Object.getPrototypeOf(n[t])!==Object.prototype?e[t]=n[t]:ge(n[t])?((!e[t]||!ge(e[t]))&&he(e,{[t]:{}}),ye(e[t],n[t])):he(e,{[t]:n[t]}));return ye(e,...t)},be=e=>typeof e==`function`,xe=e=>typeof e==`string`,Se=e=>Array.from(e),Ce=e=>e!==void 0,we=e=>e!==null,Te=e=>Ce(e)&&we(e),Ee=function(){},De=(e,t)=>{let n=(t||document).createElement(`template`);n.innerHTML=e.trim();let r=n.content;return r.childNodes.length>1?r.childNodes:r.firstChild},Oe=e=>e?.startsWith(`.`)?e:`.${e}`,ke=e=>{let t=0;return e.wheelDelta?t=-e.wheelDelta/120:e.detail&&(t=e.detail/3),t=t>0?Math.ceil(t):Math.floor(t),t},Ae=()=>{let e,t,n=new Promise(function(n,r){e=n,t=r});return n.resolve=e,n.reject=t,n};var je=class{constructor(e,t){this.__isComponent=!0,this.options={events:{}},this.element=e,this.options=t}destroy(){this.element=null}extendOptions(e){this.options=ye(this.options,e)}setOptions(e){this.options=e}trigger(e,t={}){let n={defaultPrevented:!1,preventDefault:()=>{n.defaultPrevented=!0}};return this.options.events&&be(this.options.events[e])&&this.options.events[e](he(n,t,{sender:this})),n.defaultPrevented}};let Me=function(e,t,n={}){let r,i,a,o,s=0,c=function(){s=n.leading===!1?0:new Date().getTime(),r=void 0,o=e.apply(i,a),r||(i=a=null)};return function(){let l=new Date().getTime();!s&&n.leading===!1&&(s=l);let u=t-(l-s);return i=void 0,a=arguments,u<=0||u>t?(r&&=(clearTimeout(r),void 0),s=l,o=e.apply(i,a),r||(i=a=null)):!r&&n.trailing!==!1&&(r=window.setTimeout(c,u)),o}},Ne=e=>{e.preventDefault&&e.preventDefault(),e.originalEvent&&e.originalEvent.preventDefault()},Pe=(e,t)=>!e||!t?!1:e.closest(t),Fe=1e3/60,Ie=`scroll`;var Le=class extends je{constructor(e,t){super(e,t),this.options={events:{[Ie]:Ee},filter:``,panScrollThrottleDelay:Fe,scrollDirectionModifier:-1,scrollThrottleDelay:Fe},this.onElementScroll=e=>{let t=this.element;this.shouldTrackScrollEvents()&&(this.state.trackNextElementScroll?this.scrollTo(t.scrollLeft,t.scrollTop):this.state.trackNextElementScroll=!0,this.trigger(Ie,{originalEvent:e}))},this.onDragStart=e=>{if(this.state.dragStarted=!1,!this.shouldTrackPanEvents())return;let t=e.target||(e.originalEvent||{}).target;this.options.filter&&!Pe(t,this.options.filter)||(Ne(e),this.setState({dragStarted:!0,location:{pageX:e.pageX,pageY:e.pageY},locationDelta:{x:0,y:0}}))},this.onDrag=e=>{if(!this.shouldTrackPanEvents()||!this.state.dragStarted)return;this.calculateEventLocationDelta(e),this.setState({location:{pageX:e.pageX,pageY:e.pageY}});let t=this.options.scrollDirectionModifier,n=this.element.scrollLeft+t*this.state.locationDelta.x,r=this.element.scrollTop+t*this.state.locationDelta.y;this.scrollTo(n,r)},this.onDragEnd=()=>{},this.extendOptions(t),this.resetState(),this.bindEvents()}destroy(){this.unbindEvents()}initDraggable(){this.destroyDraggable(),this.options.panScrollThrottleDelay>0?this.throttledOnDrag=Me(this.onDrag,this.options.panScrollThrottleDelay):this.throttledOnDrag=this.onDrag,this.draggable=new me({mouseOnly:!1,press:this.onDragStart,drag:this.throttledOnDrag,release:this.onDragEnd}),this.draggable.bindTo(this.element)}destroyDraggable(){this.draggable&&this.draggable.destroy&&(this.draggable.destroy(),this.throttledOnDrag&&this.throttledOnDrag.cancel&&(this.throttledOnDrag.cancel(),this.throttledOnDrag=null))}bindEvents(){this.bindDraggableEvents(),this.bindElementScroll()}bindDraggableEvents(){this.initDraggable()}bindElementScroll(){this.options.scrollThrottleDelay>0?this.throttledOnElementScroll=Me(this.onElementScroll,this.options.scrollThrottleDelay):this.throttledOnElementScroll=this.onElementScroll,this.element.addEventListener(Ie,this.throttledOnElementScroll)}unbindEvents(){this.unbindElementScroll(),this.unbindDraggableEvents()}unbindDraggableEvents(){this.destroyDraggable()}unbindElementScroll(){this.throttledOnElementScroll&&this.throttledOnElementScroll.cancel&&(this.throttledOnElementScroll.cancel(),this.throttledOnElementScroll=null),this.element.removeEventListener(Ie,this.throttledOnElementScroll)}setState(e){this.state=Object.assign({},this.state||{},e)}resetState(){this.setState({trackPanEvents:!1,trackScrollEvents:!1,trackNextElementScroll:!1,location:{pageX:0,pageY:0},locationDelta:{x:0,y:0}})}enablePanEventsTracking(){this.state.trackPanEvents=!0,this.bindDraggableEvents()}disablePanEventsTracking(){this.unbindDraggableEvents(),this.state.trackPanEvents=!1}shouldTrackPanEvents(){return this.state.trackPanEvents}enableScrollEventsTracking(){this.state.trackScrollEvents=!0,this.unbindElementScroll(),this.bindElementScroll()}disableScrollEventsTracking(){this.unbindElementScroll(),this.state.trackScrollEvents=!1}shouldTrackScrollEvents(){return this.state.trackScrollEvents}calculateEventLocationDelta(e){this.state.locationDelta={x:e.pageX-this.state.location.pageX,y:e.pageY-this.state.location.pageY}}scrollTo(e,t,n={trackScrollEvent:!0}){n.trackScrollEvent||(this.state.trackNextElementScroll=!1),this.element.scrollLeft=e,this.element.scrollTop=t}};let Re=e=>{let t=e.parentElement;!e||!t||t.replaceWith(...Array.from(t.childNodes))},ze=e=>{if(!(!e||!e.length||e.length<=0))for(let t=0;t<e.length;t++)Re(e[t])},Be=(e,t)=>{e.parentNode&&(e.parentNode.insertBefore(t,e),t.appendChild(e))},Ve=(e,t)=>{if(!(!e||!e.parentNode||!t))for(e.appendChild(t);e.firstChild&&e.firstChild!==t;)t.appendChild(e.firstChild)},He=(e,t)=>{t.classList.add(e)},Ue=(e,t)=>{t.classList.remove(e)},We=e=>`.${e}`,Ge=`data-char-index`,Ke=`data-match-index`;var qe=class{constructor(e){this.options={highlightClass:`k-search-highlight`,highlightMarkClass:`k-search-highlight-mark`,charClass:`k-text-char`,textContainers:[]},this.extendOptions(e),this.resetState()}destroy(){this.clearSearch(),this.resetState()}extendOptions(e){this.options=Object.assign({},this.options,e)}setState(e){this.state=Object.assign({},this.state||{},e)}resetState(){this.setState({text:``,textNodes:[],charIndex:0,activeMatchIndex:0,matches:[]})}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}search({text:e,matchCase:t}){let n=this.escapeRegExp(e),r=new RegExp(n,t?`g`:`ig`),i;if(this.shouldTransformText()&&this.transformTextForSearch(),this.state.matches=[],this.state.activeMatchIndex=0,this.removeIndicators(),n===``)return[];for(i=r.exec(this.state.text);i;)this.state.matches.push({startOffset:i.index,endOffset:i.index+i[0].length}),i=r.exec(this.state.text);return this.highlightAllMatches(),this.addActiveMatchMark(),this.state.matches}clearSearch(){this.removeIndicators(),this.restoreOriginalText()}restoreOriginalText(){this.forEachTextContainer(e=>{Array.from(e.querySelectorAll(`span:not(.`+this.options.charClass+`)`)).forEach(e=>{let t=e.textContent;Se(e.childNodes).forEach(t=>{e.removeChild(t)});let n=e.ownerDocument.createTextNode(t);e.appendChild(n)})})}shouldTransformText(){return!this.state.text}transformTextForSearch(){this.state.textNodes=[],this.state.charIndex=0,this.state.text=``,this.forEachTextContainer(e=>{this.extractTextNodes(e)}),this.transformTextNodesForSearch(this.state.textNodes)}extractTextNodes(e){if(e.nodeType===Node.TEXT_NODE)this.state.textNodes.push(e);else for(let t=0;t<e.childNodes.length;t++)this.extractTextNodes(e.childNodes[t])}transformTextNodesForSearch(e){for(let t=0;t<e.length;t++)this.transformTextNodeForSearch(e[t])}transformTextNodeForSearch(e){let t=e.textContent;if(t.length<=0)return;this.state.text=this.state.text+t;let n=document.createElement(`span`);Be(e,n),e.textContent=``,this.splitTextByChars(t).forEach(e=>{n.appendChild(e)}),Re(n.childNodes[0])}splitTextByChars(e){let t=[];for(let n=0;n<e.length;n++){let r=document.createElement(`span`);He(this.options.charClass,r),r.setAttribute(`${Ge}`,`${this.state.charIndex}`),r.textContent=e[n],t.push(r),this.state.charIndex++}return t}forEachTextContainer(e){for(let t=0;t<this.options.textContainers.length;t++){let n=this.options.textContainers[t];e(n,t)}}highlightAllMatches(){this.state.matches.forEach((e,t)=>{this.addMatchHighlight(e.startOffset,e.endOffset,t)})}addMatchHighlight(e,t,n){for(let r=e;r<t;r++)this.forEachTextContainer(e=>{Array.from(e.querySelectorAll(We(`${this.options.charClass}[${Ge}='${r}']`))).forEach(e=>{He(this.options.highlightClass,e),e.setAttribute(Ke,n)})})}removeMatchHighlights(){this.forEachTextContainer(e=>{Array.from(e.querySelectorAll(We(this.options.highlightClass))).forEach(e=>{Ue(this.options.highlightClass,e),e.removeAttribute(Ke)})})}addActiveMatchMark(){!this.state.activeMatchIndex&&this.state.activeMatchIndex!==0?this.state.activeMatchIndex=0:this.state.activeMatchIndex>this.state.matches.length?this.state.activeMatchIndex=this.state.matches.length:this.removeActiveMatchMark();let e=document.createElement(`span`);e.classList.add(this.options.highlightMarkClass),this.forEachTextContainer(t=>{Array.from(t.querySelectorAll(We(this.options.charClass+`[data-match-index='`+this.state.activeMatchIndex+`']`))).forEach(t=>{Ve(t,e.cloneNode(!0))})})}removeActiveMatchMark(){this.forEachTextContainer(e=>{let t=Array.from(e.querySelectorAll(We(this.options.highlightMarkClass))).flatMap(e=>Array.from(e.childNodes));ze(t)})}removeIndicators(){this.removeActiveMatchMark(),this.removeMatchHighlights()}markNextMatch(){this.markNextMatchIndex(),this.addActiveMatchMark()}markPreviousMatch(){this.markPreviousMatchIndex(),this.addActiveMatchMark()}markNextMatchIndex(){this.moveActiveMatchIndex(1)}markPreviousMatchIndex(){this.moveActiveMatchIndex(-1)}moveActiveMatchIndex(e){this.state.activeMatchIndex+=e,this.state.activeMatchIndex<0?this.state.activeMatchIndex=Math.max(this.state.matches.length-1,0):this.state.activeMatchIndex>this.state.matches.length-1&&(this.state.activeMatchIndex=0)}getActiveMatchElement(){let e;return this.forEachTextContainer(t=>{let n=t.querySelector(We(this.options.highlightMarkClass));n&&(e=n)}),e}};function Je(e,t,n={}){let r=$e;if(n.forceProxy&&!n.proxyURL)throw Error(`No proxyURL is set, but forceProxy is true`);n.forceProxy||(Xe()&&(r=Qe),navigator.msSaveBlob&&(r=Ze)),r(e,t,n)}let Ye=()=>document.createElement(`a`),Xe=()=>`download`in Ye();function Ze(e,t){let n=e;if(typeof e==`string`){let t=e.split(`;base64,`),r=t[0],i=atob(t[1]),a=new Uint8Array(i.length);for(let e=0;e<i.length;e++)a[e]=i.charCodeAt(e);n=new Blob([a.buffer],{type:r})}navigator.msSaveBlob(n,t)}function Qe(e,t){let n=e;window.Blob&&e instanceof Blob&&(n=URL.createObjectURL(e));let r=Ye();r.download=t,r.href=n;let i=document.createEvent(`MouseEvents`);i.initMouseEvent(`click`,!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),r.dispatchEvent(i),setTimeout(()=>URL.revokeObjectURL(n))}function $e(e,t,n){if(!n.proxyURL)return;let r=document.createElement(`form`);r.setAttribute(`action`,n.proxyURL),r.setAttribute(`method`,`POST`),r.setAttribute(`target`,n.proxyTarget||`_self`);let i=n.proxyData||{};i.fileName=t;let a=e.split(`;base64,`);i.contentType=a[0].replace(`data:`,``),i.base64=a[1];for(let e in i)if(Object.prototype.hasOwnProperty.call(i,e)){let t=document.createElement(`input`);t.setAttribute(`type`,`hidden`),t.setAttribute(`name`,e),t.setAttribute(`value`,i[e]),r.appendChild(t)}document.body.appendChild(r),r.submit(),document.body.removeChild(r)}String.fromCharCode;let et=()=>typeof window<`u`,tt={wp:/(Windows Phone(?: OS)?)\s(\d+)\.(\d+(\.\d+)?)/,fire:/(Silk)\/(\d+)\.(\d+(\.\d+)?)/,android:/(Android|Android.*(?:Opera|Firefox).*?\/)\s*(\d+)(\.(\d+(\.\d+)?))?/,iphone:/(iPhone|iPod).*OS\s+(\d+)[\._]([\d\._]+)/,ipad:/(iPad).*OS\s+(\d+)[\._]([\d_]+)/,meego:/(MeeGo).+NokiaBrowser\/(\d+)\.([\d\._]+)/,webos:/(webOS)\/(\d+)\.(\d+(\.\d+)?)/,blackberry:/(BlackBerry|BB10).*?Version\/(\d+)\.(\d+(\.\d+)?)/,playbook:/(PlayBook).*?Tablet\s*OS\s*(\d+)\.(\d+(\.\d+)?)/,windows:/(MSIE)\s+(\d+)\.(\d+(\.\d+)?)/,tizen:/(tizen).*?Version\/(\d+)\.(\d+(\.\d+)?)/i,sailfish:/(sailfish).*rv:(\d+)\.(\d+(\.\d+)?).*firefox/i,ffos:/(Mobile).*rv:(\d+)\.(\d+(\.\d+)?).*Firefox/},nt={ios:/^i(phone|pad|pod)$/i,android:/^android|fire$/i,blackberry:/^blackberry|playbook/i,windows:/windows/,wp:/wp/,flat:/sailfish|ffos|tizen/i,meego:/meego/},rt={edge:/(edge)[ \/]([\w.]+)/i,webkit:/(chrome)[ \/]([\w.]+)/i,safari:/(webkit)[ \/]([\w.]+)/i,opera:/(opera)(?:.*version|)[ \/]([\w.]+)/i,msie:/(msie\s|trident.*? rv:)([\w.]+)/i,mozilla:/(mozilla)(?:.*? rv:([\w.]+)|)/i},it={omini:/Opera\sMini/i,omobile:/Opera\sMobi/i,firefox:/Firefox|Fennec/i,mobilesafari:/version\/.*safari/i,ie:/MSIE|Windows\sPhone/i,chrome:/chrome|crios/i,webkit:/webkit/i},at=(e,t,n)=>{for(let n in t)if(t.hasOwnProperty(n)&&t[n].test(e))return n;return n===void 0?e:n},ot=e=>{let t,n=[];for(let r in tt)if(tt.hasOwnProperty(r)){if(n=e.match(tt[r]),!n)continue;if(r===`windows`&&`plugins`in window.navigator)return null;let i={};return i.device=r,i.browser=at(e,it,`default`),i.name=at(r,nt),i[i.name]=!0,i.majorVersion=n[2],i.minorVersion=n[3]?n[3].replace(`_`,`.`):`.0`,t=i.minorVersion.replace(`.`,``).substr(0,2),i.flatVersion=i.majorVersion+t+Array(3-(t.length<3?t.length:2)).join(`0`),i.cordova=!0,i.appMode=window.navigator.standalone||/file|local|wmapp/.test(window.location.protocol)||i.cordova,i}return null},st=e=>{let t=null,n=[];for(let r in rt)if(rt.hasOwnProperty(r)&&(n=e.match(rt[r]),n)){t={},t[r]=!0,t[n[1].toLowerCase().split(` `)[0].split(`/`)[0]]=!0,t.version=parseInt(document.documentMode||n[2],10);break}return t},ct=et()&&window.navigator?window.navigator.userAgent:null,lt=ct?st(ct):null;ct&&ot(ct),et()&&`ontouchstart`in window,lt&&!lt.chrome&&window.MSPointerEvent,lt&&!lt.chrome&&window.PointerEvent;let ut={};ut.undefined=e=>e;let dt={};dt.undefined=e=>e;let{shadow:ft,AnnotationEditorType:y,FeatureTest:pt,setLayerDimensions:mt,AnnotationEditorParamsType:b,PixelsPerInch:ht,DOMSVGFactory:gt,PDFDateString:_t,Util:vt,XfaLayer:yt,getDocument:bt,AnnotationMode:xt,AbortException:St,TextLayer:Ct,fetchData:wt,noContextMenu:Tt,PDFDocumentProxy:Et}=window.pdfjsLib||{AnnotationEditorType:{DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15}},Dt=null,Ot=0,kt=0,At={},jt=`data-kpv-sid`,Mt=!1,Nt=new Set,Pt=new WeakMap,Ft=new WeakMap,It=new WeakMap;function Lt(e){return e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase())}function Rt(){if(typeof document>`u`||typeof CSSStyleSheet>`u`)return!1;try{return new CSSStyleSheet,!0}catch{return!1}}function zt(){return Rt()?(Dt||(Dt=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets||[],Dt]),Dt):null}function Bt(){Dt&&Dt.replaceSync(Object.values(At).join(`
`))}function Vt(e,t,n){let r=n||`data-kpv-sid-`+ ++Ot;if(!zt())return Object.keys(t).forEach(n=>e.style[n]=t[n]),r;e.setAttribute(jt,r);let i=`[${jt}="${r}"]`,a=Object.keys(t).map(e=>`${Lt(e)}: ${t[e]}`).join(`; `);return At[r]=`${i} { ${a} }`,Bt(),r}function Ht(e,t,n){let r=n||`data-kpv-sid-`+ ++Ot;if(!zt())return Object.keys(t).forEach(n=>e.style.setProperty(n,t[n])),r;e.setAttribute(jt,r);let i=`[${jt}="${r}"]`,a=Object.keys(t).map(e=>`${e}: ${t[e]}`).join(`; `);return At[r]=`${i} { ${a} }`,Bt(),r}function Ut(){let e=[];for(let t of Object.keys(At))document.querySelector(`[data-kpv-sid="${t}"]`)||e.push(t);for(let t of e)delete At[t];e.length>0&&Bt()}function Wt(e,t,n){let r=Ft.get(e);if(!r){r={};let t=e.getAttribute(jt);if(t&&At[t]){let n=At[t],i=n.indexOf(`{`),a=n.lastIndexOf(`}`);i>=0&&a>i&&n.substring(i+1,a).split(`;`).forEach(e=>{let t=e.indexOf(`:`);if(t>0){let n=e.substring(0,t).trim(),i=e.substring(t+1).trim();n&&(r[n]=i)}}),Pt.set(e,t)}Ft.set(e,r)}if(n===``||n==null?delete r[t]:r[t]=n,!(++kt&31))for(let e of Object.keys(At))document.querySelector(`[data-kpv-sid="${e}"]`)||delete At[e];let i=Pt.get(e),a={},o={};Object.keys(r).forEach(e=>{e.startsWith(`--`)?a[e]=r[e]:o[e]=r[e]});let s=[].concat(Object.keys(o).map(e=>`${Lt(e)}: ${o[e]}`),Object.keys(a).map(e=>`${e}: ${a[e]}`)).join(`; `),c=i||`data-kpv-sid-`+ ++Ot;if(!zt()){Object.keys(o).forEach(t=>e.style[t]=o[t]),Object.keys(a).forEach(t=>e.style.setProperty(t,a[t]));return}e.setAttribute(jt,c),At[c]=`[${jt}="${c}"] { ${s} }`,Bt(),i||Pt.set(e,c)}function Gt(e){if(!e||!e.nodeType)return!1;for(let t of Nt)if(t===e||t.contains&&t.contains(e))return!0;return!1}function Kt(e){if(e&&Nt.add(e),Mt||typeof HTMLElement>`u`)return;let t=Object.getOwnPropertyDescriptor(HTMLElement.prototype,`style`)||Object.getOwnPropertyDescriptor(Element.prototype,`style`);if(!t||!t.get)return;Mt=!0;let n=t.get;Object.defineProperty(HTMLElement.prototype,"style",{configurable:!0,enumerable:t.enumerable,get(){let e=n.call(this);if(!Gt(this))return e;let t=It.get(e);if(t)return t;let r=this;return t=new Proxy(e,{set(e,t,n){return typeof t==`string`?(t===`cssText`||Wt(r,t,n),!0):(e[t]=n,!0)},get(e,t){if(t===`setProperty`)return(e,t,n)=>{Wt(r,e,n===`important`?`${t} !important`:t)};if(t===`removeProperty`)return e=>{let t=Ft.get(r),n=t?t[e]:``;return Wt(r,e,``),n||``};if(t===`getPropertyValue`)return e=>{let t=Ft.get(r);return t&&t[e]?t[e]:``};if(typeof t==`string`){let e=Ft.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}let n=e[t];return typeof n==`function`?n.bind(e):n}}),It.set(e,t),t}})}function qt(e){e&&Nt.delete(e)}let Jt=(e,t)=>{t.classList.add(e)},Yt=(e,t)=>{t.classList.remove(e)},Xt=function(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n&&Object.keys(n).length>0&&Vt(r,n),r},Zt=(e,t)=>{let n=e.querySelectorAll(`.k-page`),r=n[0];if(r instanceof HTMLDivElement){let e=(r.offsetHeight+r.offsetTop)*Math.max(0,Math.min(t,n.length-1)),i=r.closest(`.k-pdf-viewer-canvas`);i&&i.scrollTo({top:e,behavior:`auto`})}};var Qt=class{constructor(e,t,n,r,i,a){this.container=e,this.viewport=t,this.zoom=i,this.annotation=n,this.pdfDoc=r,this.rootElement=a}destroy(){}};(class extends Qt{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.onLinkClick=e=>{let t=e.target.getAttribute(`href`);t&&t.indexOf(`#`)===0&&(this.navigateToDestination(t),e.preventDefault())},this.linkElement=null,this.renderAnnotation(),this.bindEvents()}destroy(){this.unbindEvents()}bindEvents(){this.linkElement.addEventListener(`click`,this.onLinkClick)}unbindEvents(){this.linkElement.removeEventListener(`click`,this.onLinkClick)}navigateToDestination(e){let t=e.split(`#`)[1];this.pdfDoc.getDestination(t).then(e=>{this.pdfDoc.getPageIndex(e[0]).then(e=>this.goToPage(e))})}goToPage(e){Zt(this.rootElement,e)}renderAnnotation(){let e=this.annotation,t=this.viewport,n=e.rect,r=[[n[0],n[1]],[n[2],n[3]]],i=t.rawDims.pageHeight,a=Math.min(r[0][0],r[1][0])*this.zoom,o=(i-Math.max(r[0][1],r[1][1]))*this.zoom,s=(r[1][0]-r[0][0])*this.zoom,c=(r[1][1]-r[0][1])*this.zoom,l=e.url||e.dest&&`#${encodeURI(e.dest)}`,u=Xt(`span`,``,{position:`absolute`,left:a+`pt`,top:o+`pt`}),d=this.linkElement=Xt(`a`,``,{width:s+`pt`,height:c+`pt`,display:`inline-block`,pointerEvents:`auto`});d.setAttribute(`href`,l),u.append(d),this.container.append(u)}});let $t=65535,en=268435456,tn=32767,nn=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/i.test(navigator.userAgent),rn=e=>st(e).safari||ot(e)&&ot(e).browser===`mobilesafari`,an=e=>{let t=st(e),n=ot(e);return t&&t.mozilla||n&&n.browser===`firefox`},on=1.25,sn=(e=3)=>nn()?devicePixelRatio:devicePixelRatio*(e||3),cn=e=>atob(e.replace(/^(data:application\/pdf;base64,)/gi,``)),ln=e=>{let t=e.querySelector(`.k-pdf-viewer-canvas`),n=e.querySelector(`.k-page:not(.k-blank-page)`);return t&&n?Math.floor(Math.round(t.scrollTop)/Math.max(1,n.offsetHeight+n.offsetTop)+.01):0},un=(e,t)=>{let{maxWidth:n,maxHeight:r,maxArea:i}=an(navigator.userAgent)?{maxWidth:tn,maxHeight:tn,maxArea:124992400}:rn(navigator.userAgent)?{maxWidth:4194303,maxHeight:8388607,maxArea:en}:{maxWidth:$t,maxHeight:$t,maxArea:en},a=e,o=t,s=e/t;if(e>n&&(a=n,o=t-(e-n)/s),o>r){let e=(o-r)*s;o=r,a-=e}let c=a*o;if(c>i){let e=Math.sqrt(i/c);a*=e,o*=e}let l=a/e;return{adjustedWidth:a===e?e:Math.floor(a/2),adjustedHeight:o===t?t:Math.floor(o/2),adjustRatio:l===1?1:l/2}},dn=e=>{let t=!1,n=new CSSStyleSheet;n.replaceSync(`.kendo-pdfviewer-common { } .hiddenCanvasElement {
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
display: none;
}`),!(!e||!e.adoptedStyleSheets)&&(e.adoptedStyleSheets.forEach(e=>{if(e.cssRules.length>0){let n=e.cssRules[0];n instanceof CSSStyleRule&&n.selectorText.indexOf(`.kendo-pdfviewer-common`)===0&&(t=!0)}}),t||e.adoptedStyleSheets.push(n))};var fn=function(e,t){return fn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},fn(e,t)},pn=function(){return pn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},pn.apply(this,arguments)};function x(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function mn(e){return this instanceof mn?(this.v=e,this):new mn(e)}var hn=function(e){return hn=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},hn(e)};function S(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function C(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}let gn=(e,t,n)=>Math.min(n,Math.max(t,e)),_n=1.35,vn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},yn=`pdfjs_internal_editor_`,bn={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},xn={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},Sn={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};function Cn(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}function wn(e){let t=Object.create(null);for(let[n,r]of e)t[n]=r;return t}let Tn=Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,`0`));var En=class{static makeHexColor(e,t,n){return`${Tn[e]}${Tn[t]}${Tn[n]}`}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}};let Dn=`pdfjs_internal_id_`;var On,kn=class{constructor(e=yn){On.set(this,0),this.idPrefix=yn,Object.defineProperty(this,"reset",{value:()=>C(this,On,0,`f`)}),this.idPrefix=e}get id(){var e,t;return`${this.idPrefix}${C(this,On,(t=S(this,On,`f`),e=t++,t),`f`),e}`}};On=new WeakMap;var w,An,jn,T,Mn=class{constructor(e=128){w.set(this,[]),An.set(this,!1),jn.set(this,void 0),T.set(this,-1),C(this,jn,e,`f`)}add({cmd:e,undo:t,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(r&&e(),S(this,An,`f`))return;let s={cmd:e,undo:t,post:n,type:i};if(S(this,T,`f`)===-1){S(this,w,`f`).length>0&&(S(this,w,`f`).length=0),C(this,T,0,`f`),S(this,w,`f`).push(s);return}if(a&&S(this,w,`f`)[S(this,T,`f`)].type===i){o&&(s.undo=S(this,w,`f`)[S(this,T,`f`)].undo),S(this,w,`f`)[S(this,T,`f`)]=s;return}let c=S(this,T,`f`)+1;c===S(this,jn,`f`)?S(this,w,`f`).splice(0,1):(C(this,T,c,`f`),c<S(this,w,`f`).length&&S(this,w,`f`).splice(c)),S(this,w,`f`).push(s)}undo(){if(S(this,T,`f`)===-1)return;C(this,An,!0,`f`);let{undo:e,post:t}=S(this,w,`f`)[S(this,T,`f`)];e(),t?.(),C(this,An,!1,`f`),C(this,T,S(this,T,`f`)-1,`f`)}redo(){if(S(this,T,`f`)<S(this,w,`f`).length-1){C(this,T,S(this,T,`f`)+1,`f`),C(this,An,!0,`f`);let{cmd:e,post:t}=S(this,w,`f`)[S(this,T,`f`)];e(),t?.(),C(this,An,!1,`f`)}}hasSomethingToUndo(){return S(this,T,`f`)!==-1}hasSomethingToRedo(){return S(this,T,`f`)<S(this,w,`f`).length-1}destroy(){C(this,w,null,`f`)}};w=new WeakMap,An=new WeakMap,jn=new WeakMap,T=new WeakMap;var E,Nn,D,O,k,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,A,j,Qn,$n,er,tr,nr,rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,M,vr,yr,br,xr,Sr,Cr,wr,Tr=class{constructor({container:e=null,viewer:t,pdfViewer:n,eventBus:r,pdfDocument:i,highlightColors:a=``}){E.add(this),this.pdfViewer=null,this.annotationEditorMode=y.NONE,this.viewParameters={},this.isShiftKeyDown=!1,this._eventBus=null,Nn.set(this,new AbortController),D.set(this,null),O.set(this,new Map),k.set(this,new Map),Pn.set(this,null),Fn.set(this,null),In.set(this,new Mn),Ln.set(this,0),Rn.set(this,new Set),zn.set(this,null),Bn.set(this,null),Vn.set(this,new Set),Hn.set(this,!0),Un.set(this,null),Wn.set(this,null),Gn.set(this,``),Kn.set(this,!1),qn.set(this,null),Jn.set(this,new kn),Yn.set(this,!1),Xn.set(this,!1),Zn.set(this,null),A.set(this,y.NONE),j.set(this,new Set),Qn.set(this,null),$n.set(this,null),er.set(this,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),tr.set(this,[0,0]),nr.set(this,null),rr.set(this,null),ir.set(this,null);let o=this._signal=S(this,Nn,`f`).signal;C(this,rr,e,`f`),C(this,ir,t,`f`),this.pdfViewer=n,this._eventBus=r,this._eventBus._on(`editingaction`,this.onEditingAction.bind(this),{signal:o}),this._eventBus._on(`pagechanging`,this.onPageChanging.bind(this),{signal:o}),this._eventBus._on(`scalechanging`,this.onScaleChanging.bind(this),{signal:o}),this._eventBus._on(`rotationchanging`,this.onRotationChanging.bind(this),{signal:o}),this._eventBus._on(`setpreference`,this.onSetPreference.bind(this),{signal:o}),this._eventBus._on(`namedaction`,this.onNamedAction.bind(this),{signal:o}),S(this,E,`m`,ur).call(this),S(this,E,`m`,_r).call(this),S(this,E,`m`,pr).call(this),C(this,Pn,i.annotationStorage,`f`),C(this,Gn,a||``,`f`),this.viewParameters={realScale:ht.PDF_TO_CSS_UNITS,rotation:0}}destroy(){S(this,Nn,`f`)?.abort(),C(this,Nn,null,`f`),this._signal=null;for(let e of S(this,k,`f`).values())e.destroy();S(this,k,`f`).clear(),S(this,O,`f`).clear(),S(this,Vn,`f`).clear(),C(this,D,null,`f`),S(this,j,`f`).clear(),S(this,In,`f`).destroy(),S(this,Un,`f`)&&(clearTimeout(S(this,Un,`f`)),C(this,Un,null,`f`)),S(this,nr,`f`)&&(clearTimeout(S(this,nr,`f`)),C(this,nr,null,`f`))}getTextLayerForAnchor(e){return e?e.closest(`.textLayer`)||e.closest(`.k-text-layer`):null}combinedSignal(e){return AbortSignal&&AbortSignal.any?AbortSignal.any([this._signal,e.signal]):this._signal||e.signal}get direction(){return ft(this,`direction`,getComputedStyle(S(this,rr,`f`)).direction)}get highlightColors(){return ft(this,`highlightColors`,S(this,Gn,`f`)?new Map:null)}get highlightColorNames(){return ft(this,`highlightColorNames`,this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}switchToMode(e,t){this._eventBus.on(`annotationeditormodechanged`,t,{once:!0,signal:this._signal,mode:e}),this._eventBus.dispatch(`showannotationeditorui`,{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch(`setpreference`,{source:this,name:e,value:t})}onSetPreference({name:e}){switch(e){case`enableNewAltTextWhenAddingImage`:break;default:break}}onNamedAction(e){switch(e.action){case`Print`:this.triggerPrinting();break;case`SaveAs`:this.downloadOrSave();break}}onPageChanging({pageNumber:e}){C(this,Ln,e-1,`f`)}focusMainContainer(){S(this,rr,`f`)?.focus()}findParent(e,t){for(let n of S(this,k,`f`).values()){let{x:r,y:i,width:a,height:o}=n.div.getBoundingClientRect();if(e>=r&&e<=r+a&&t>=i&&t<=i+o)return n}return null}triggerPrinting(){this.pdfViewer?.printFile()}downloadOrSave(){this.pdfViewer?.downloadFile({fileName:this.pdfViewer?.options.downloadFileName})}disableUserSelect(e=!1){S(this,ir,`f`)?.classList.toggle(`noUserSelect`,e)}addShouldRescale(e){S(this,Vn,`f`).add(e)}removeShouldRescale(e){S(this,Vn,`f`).delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*ht.PDF_TO_CSS_UNITS;for(let e of S(this,Vn,`f`))e.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e=``){let t=document.getSelection();if(!t||t.isCollapsed)return;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=t,o=t.toString(),s=S(this,E,`m`,ar).call(this,t),c=this.getTextLayerForAnchor(s),l=this.getSelectionBoxes(c);if(!l)return;t.empty();let u=S(this,E,`m`,or).call(this,c),d=S(this,A,`f`)===y.NONE,f=()=>{u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:l,anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a,text:o}),d&&this.showAllEditors(`highlight`,!0)};if(d){this.switchToMode(y.HIGHLIGHT,f);return}f()}showEditorToolBar(e){if(!e)return;let t=this.getMode();(t===y.HIGHLIGHT||t===y.FREETEXT)&&this._eventBus.dispatch(`kendoAnnotationEditorToolBarShow`,{source:this,anchor:e})}hideEditorToolBar(){this._eventBus.dispatch(`kendoAnnotationEditorToolBarHide`,{source:this})}addToAnnotationStorage(e){!e.isEmpty()&&S(this,Pn,`f`)&&!S(this,Pn,`f`).has(e.id)&&S(this,Pn,`f`).setValue(e.id,e)}blur(){if(this.isShiftKeyDown=!1,S(this,Kn,`f`)&&(C(this,Kn,!1,`f`),S(this,E,`m`,lr).call(this,`main_toolbar`)),!this.hasSelection)return;let{activeElement:e}=document;for(let t of S(this,j,`f`))if(t.div.contains(e)){C(this,Zn,[t,e],`f`),t._focusEventsAllowed=!1;break}}focus(){if(!S(this,Zn,`f`))return;let[e,t]=S(this,Zn,`f`);C(this,Zn,null,`f`),t.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}addEditListeners(){S(this,E,`m`,pr).call(this),S(this,E,`m`,hr).call(this)}removeEditListeners(){S(this,E,`m`,mr).call(this),S(this,E,`m`,gr).call(this)}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of S(this,Bn,`f`))if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect=`copy`,e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of S(this,Bn,`f`))if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),S(this,D,`f`)?.commitOrRemove(),!this.hasSelection)return;let t=[];for(let e of S(this,j,`f`)){let n=e.serialize(!0);n&&t.push(n)}t.length!==0&&e.clipboardData.setData(`application/pdfjs`,JSON.stringify(t))}cut(e){this.copy(e),this.delete()}paste(e){e.preventDefault();let{clipboardData:t}=e;for(let e of t.items)for(let t of S(this,Bn,`f`))if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}let n=t.getData(`application/pdfjs`);if(!n)return;try{n=JSON.parse(n)}catch{return}if(!Array.isArray(n))return;this.unselectAll();let r=this.currentLayer;try{let e=[];for(let t of n){let n=r.deserialize(t);if(!n)return;e.push(n)}this.addCommands({cmd:()=>{for(let t of e)S(this,E,`m`,xr).call(this,t);S(this,E,`m`,wr).call(this,e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch{}}onEditingAction({name:e}){switch(e){case`undo`:case`redo`:case`delete`:case`selectAll`:this[e]();break;case`highlightSelection`:this.highlightSelection(`context_menu`);break;default:break}}setEditingState(e){e?(S(this,E,`m`,dr).call(this),S(this,E,`m`,hr).call(this),S(this,E,`m`,M).call(this,{isEditing:S(this,A,`f`)!==y.NONE,isEmpty:S(this,E,`m`,Cr).call(this),hasSomethingToUndo:S(this,In,`f`).hasSomethingToUndo(),hasSomethingToRedo:S(this,In,`f`).hasSomethingToRedo(),hasSelectedEditor:!1})):(S(this,E,`m`,fr).call(this),S(this,E,`m`,gr).call(this),S(this,E,`m`,M).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!S(this,Bn,`f`)){C(this,Bn,e,`f`);for(let e of S(this,Bn,`f`))S(this,E,`m`,vr).call(this,e.defaultPropertiesToUpdate)}}getId(){return S(this,Jn,`f`).id}get currentLayer(){return S(this,k,`f`).get(S(this,Ln,`f`))}getLayer(e){return S(this,k,`f`).get(e)}get currentPageIndex(){return S(this,Ln,`f`)}addLayer(e){S(this,k,`f`).set(e.pageIndex,e),S(this,Yn,`f`)?e.enable():e.disable()}removeLayer(e){S(this,k,`f`).delete(e.pageIndex)}updateMode(e,t=null,n=!1){if(S(this,A,`f`)!==e){if(C(this,A,e,`f`),e===y.NONE){this.setEditingState(!1),S(this,E,`m`,br).call(this);return}this.setEditingState(!0),S(this,E,`m`,yr).call(this),this.unselectAll();for(let t of S(this,k,`f`).values())t.updateMode(e);if(!t&&n){this.addNewEditorFromKeyboard();return}if(t){for(let e of S(this,O,`f`).values())if(e.annotationElementId===t){this.setSelected(e),e.enterInEditMode();break}}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==S(this,A,`f`)&&this._eventBus.dispatch(`switchannotationeditormode`,{source:this,mode:e})}updateParams(e,t){if(S(this,Bn,`f`)){switch(e){case b.CREATE:this.currentLayer.addNewEditor();return;case b.HIGHLIGHT_COLOR:break;case b.HIGHLIGHT_SHOW_ALL:C(this,$n,S(this,$n,`f`)||new Map,`f`).set(e,t),this.showAllEditors(`highlight`,t);break;default:break}for(let n of S(this,j,`f`))n.updateParams(e,t);for(let n of S(this,Bn,`f`))n.updateDefaultParams(e,t)}}showAllEditors(e,t){for(let n of S(this,O,`f`).values())n.editorType===e&&n.show(t);(S(this,$n,`f`)?.get(b.HIGHLIGHT_SHOW_ALL)??!0)!==t&&S(this,E,`m`,vr).call(this,[[b.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(S(this,Xn,`f`)!==e){C(this,Xn,e,`f`);for(let t of S(this,k,`f`).values())e?t.disableClick():t.enableClick(),t.div.classList.toggle(`waiting`,e)}}getEditors(e){let t=[];for(let n of S(this,O,`f`).values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return S(this,O,`f`).get(e)}addEditor(e){S(this,O,`f`).set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(S(this,Un,`f`)&&clearTimeout(S(this,Un,`f`)),C(this,Un,setTimeout(()=>{this.focusMainContainer(),C(this,Un,null,`f`)},0),`f`)),S(this,O,`f`).delete(e.id),this.unselect(e),(!e.annotationElementId||!S(this,Rn,`f`).has(e.annotationElementId))&&S(this,Pn,`f`)?.remove(e.id)}addDeletedAnnotationElement(e){S(this,Rn,`f`).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return S(this,Rn,`f`).has(e)}removeDeletedAnnotationElement(e){S(this,Rn,`f`).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){S(this,D,`f`)!==e&&(C(this,D,e,`f`),e&&S(this,E,`m`,vr).call(this,e.propertiesToUpdate))}updateUI(e){S(this,E,`a`,Sr)===e&&S(this,E,`m`,vr).call(this,e.propertiesToUpdate)}toggleSelected(e){if(S(this,j,`f`).has(e)){S(this,j,`f`).delete(e),e.unselect(),S(this,E,`m`,M).call(this,{hasSelectedEditor:this.hasSelection});return}S(this,j,`f`).add(e),e.select(),S(this,E,`m`,vr).call(this,e.propertiesToUpdate),S(this,E,`m`,M).call(this,{hasSelectedEditor:!0})}setSelected(e){for(let t of S(this,j,`f`))t!==e&&t.unselect();S(this,j,`f`).clear(),S(this,j,`f`).add(e),e.select(),S(this,E,`m`,vr).call(this,e.propertiesToUpdate),S(this,E,`m`,M).call(this,{hasSelectedEditor:!0})}isSelected(e){return S(this,j,`f`).has(e)}get firstSelectedEditor(){return S(this,j,`f`).values().next().value}unselect(e){e.unselect(),S(this,j,`f`).delete(e),S(this,E,`m`,M).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return S(this,j,`f`).size!==0}get isEnterHandled(){return S(this,j,`f`).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){S(this,In,`f`).undo(),S(this,E,`m`,M).call(this,{hasSomethingToUndo:S(this,In,`f`).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:S(this,E,`m`,Cr).call(this)})}redo(){S(this,In,`f`).redo(),S(this,E,`m`,M).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:S(this,In,`f`).hasSomethingToRedo(),isEmpty:S(this,E,`m`,Cr).call(this)})}addCommands(e){S(this,In,`f`).add(e),S(this,E,`m`,M).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:S(this,E,`m`,Cr).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;let e=[...S(this,j,`f`)];this.addCommands({cmd:()=>{for(let t of e)t.remove()},undo:()=>{for(let t of e)S(this,E,`m`,xr).call(this,t)},mustExec:!0})}commitOrRemove(){S(this,D,`f`)?.commitOrRemove()}hasSomethingToControl(){return S(this,D,`f`)||this.hasSelection}selectAll(){for(let e of S(this,j,`f`))e.commit();S(this,E,`m`,wr).call(this,S(this,O,`f`).values())}unselectAll(){if(!(S(this,D,`f`)&&(S(this,D,`f`).commitOrRemove(),S(this,A,`f`)!==y.NONE))&&this.hasSelection){for(let e of S(this,j,`f`))e.unselect();S(this,j,`f`).clear(),S(this,E,`m`,M).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;S(this,tr,`f`)[0]+=e,S(this,tr,`f`)[1]+=t;let[r,i]=S(this,tr,`f`),a=[...S(this,j,`f`)];S(this,nr,`f`)&&clearTimeout(S(this,nr,`f`)),C(this,nr,setTimeout(()=>{C(this,nr,null,`f`),S(this,tr,`f`)[0]=S(this,tr,`f`)[1]=0,this.addCommands({cmd:()=>{for(let e of a)S(this,O,`f`).has(e.id)&&e.translateInPage(r,i)},undo:()=>{for(let e of a)S(this,O,`f`).has(e.id)&&e.translateInPage(-r,-i)},mustExec:!1})},1e3),`f`);for(let n of a)n.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),C(this,zn,new Map,`f`);for(let e of S(this,j,`f`))S(this,zn,`f`).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!S(this,zn,`f`))return!1;this.disableUserSelect(!1);let e=S(this,zn,`f`);C(this,zn,null,`f`);let t=!1;for(let[{x:n,y:r,pageIndex:i},a]of e)a.newX=n,a.newY=r,a.newPageIndex=i,t||=n!==a.savedX||r!==a.savedY||i!==a.savedPageIndex;if(!t)return!1;let n=(e,t,n,r)=>{if(S(this,O,`f`).has(e.id)){let i=S(this,k,`f`).get(r);i?e._setParentAndPosition(i,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:r,newY:i,newPageIndex:a}]of e)n(t,r,i,a)},undo:()=>{for(let[t,{savedX:r,savedY:i,savedPageIndex:a}]of e)n(t,r,i,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(S(this,zn,`f`))for(let n of S(this,zn,`f`).keys())n.drag(e,t)}rebuild(e){if(e.parent===null){let t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}isActive(e){return S(this,D,`f`)===e}getActive(){return S(this,D,`f`)}getActiveEditor(){return S(this,D,`f`)}getMode(){return S(this,A,`f`)}getSelectionBoxes(e){if(!e)return null;let t=document.getSelection();for(let n=0,r=t.rangeCount;n<r;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;let{x:n,y:r,width:i,height:a}=e.getBoundingClientRect(),o;switch(e.getAttribute(`data-main-rotation`)){case`90`:o=(e,t,o,s)=>({x:(t-r)/a,y:1-(e+o-n)/i,width:s/a,height:o/i});break;case`180`:o=(e,t,o,s)=>({x:1-(e+o-n)/i,y:1-(t+s-r)/a,width:o/i,height:s/a});break;case`270`:o=(e,t,o,s)=>({x:1-(t+s-r)/a,y:(e-n)/i,width:s/a,height:o/i});break;default:o=(e,t,o,s)=>({x:(e-n)/i,y:(t-r)/a,width:o/i,height:s/a});break}let s=[];for(let e=0,n=t.rangeCount;e<n;e++){let n=t.getRangeAt(e);if(!n.collapsed)for(let{x:e,y:t,width:r,height:i}of n.getClientRects())r!==0&&i!==0&&s.push(o(e,t,r,i))}return s.length===0?null:s}addChangedExistingAnnotation({annotationElementId:e,id:t}){C(this,Fn,S(this,Fn,`f`)||new Map,`f`).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){S(this,Fn,`f`)?.delete(e)}renderAnnotationElement(e){let t=S(this,Fn,`f`)?.get(e.data.id);if(!t)return;let n=S(this,Pn,`f`).getRawValue(t);n&&(S(this,A,`f`)===y.NONE&&!n.hasBeenModified||n.renderAnnotationElement(e))}};Nn=new WeakMap,D=new WeakMap,O=new WeakMap,k=new WeakMap,Pn=new WeakMap,Fn=new WeakMap,In=new WeakMap,Ln=new WeakMap,Rn=new WeakMap,zn=new WeakMap,Bn=new WeakMap,Vn=new WeakMap,Hn=new WeakMap,Un=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,Kn=new WeakMap,qn=new WeakMap,Jn=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,Zn=new WeakMap,A=new WeakMap,j=new WeakMap,Qn=new WeakMap,$n=new WeakMap,er=new WeakMap,tr=new WeakMap,nr=new WeakMap,rr=new WeakMap,ir=new WeakMap,E=new WeakSet,ar=function({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e},or=function(e){let{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(let t of S(this,k,`f`).values())if(t.hasTextLayer(e))return t;return null},sr=function(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=S(this,E,`m`,ar).call(this,e),n=this.getTextLayerForAnchor(t);this.getSelectionBoxes(n)&&this.showEditorToolBar(t)},cr=function(){let e=document.getSelection();if(!e||e.isCollapsed){S(this,Qn,`f`)&&(C(this,Qn,null,`f`),S(this,E,`m`,M).call(this,{hasSelectedText:!1}));return}let{anchorNode:t}=e;if(t===S(this,Qn,`f`))return;let n=S(this,E,`m`,ar).call(this,e),r=this.getTextLayerForAnchor(n);if(!r){S(this,Qn,`f`)&&(S(this,qn,`f`)?.hide(),C(this,Qn,null,`f`),S(this,E,`m`,M).call(this,{hasSelectedText:!1}));return}if(S(this,qn,`f`)?.hide(),C(this,Qn,t,`f`),S(this,E,`m`,M).call(this,{hasSelectedText:!0}),(S(this,A,`f`)===y.HIGHLIGHT||S(this,A,`f`)===y.NONE)&&(S(this,A,`f`)===y.HIGHLIGHT&&this.showAllEditors(`highlight`,!0),!this.isShiftKeyDown)){let e=S(this,A,`f`)===y.HIGHLIGHT?S(this,E,`m`,or).call(this,r):null;e?.toggleDrawing();let t=new AbortController,n=this.combinedSignal(t),i=n=>{(n.type!==`pointerup`||n.button===0)&&(t.abort(),e?.toggleDrawing(!0),n.type===`pointerup`&&S(this,E,`m`,lr).call(this,`main_toolbar`))};window.removeEventListener(`pointerup`,i),window.addEventListener(`pointerup`,i,{signal:n}),window.removeEventListener(`blur`,i),window.addEventListener(`blur`,i,{signal:n})}},lr=function(e=``){S(this,A,`f`)===y.HIGHLIGHT?this.highlightSelection(e):S(this,Hn,`f`)&&S(this,E,`m`,sr).call(this)},ur=function(){document.addEventListener(`selectionchange`,S(this,E,`m`,cr).bind(this),{signal:this._signal})},dr=function(){if(S(this,Wn,`f`))return;C(this,Wn,new AbortController,`f`);let e=this.combinedSignal(S(this,Wn,`f`));window.addEventListener(`focus`,this.focus.bind(this),{signal:e}),window.addEventListener(`blur`,this.blur.bind(this),{signal:e})},fr=function(){S(this,Wn,`f`)?.abort(),C(this,Wn,null,`f`)},pr=function(){},mr=function(){},hr=function(){},gr=function(){},_r=function(){let e=this._signal;document.addEventListener(`dragover`,this.dragOver.bind(this),{signal:e}),document.addEventListener(`drop`,this.drop.bind(this),{signal:e})},M=function(e){e&&Object.entries(e).some(([e,t])=>S(this,er,`f`)[e]!==t)&&(this._eventBus.dispatch(`annotationeditorstateschanged`,{source:this,details:Object.assign(S(this,er,`f`),e)}),S(this,A,`f`)===y.HIGHLIGHT&&e.hasSelectedEditor===!1&&S(this,E,`m`,vr).call(this,[[b.HIGHLIGHT_FREE,!0]]))},vr=function(e){this._eventBus.dispatch(`annotationeditorparamschanged`,{source:this,details:e})},yr=function(){if(!S(this,Yn,`f`)){C(this,Yn,!0,`f`);for(let e of S(this,k,`f`).values())e.enable();for(let e of S(this,O,`f`).values())e.enable()}},br=function(){if(this.unselectAll(),S(this,Yn,`f`)){C(this,Yn,!1,`f`);for(let e of S(this,k,`f`).values())e.disable();for(let e of S(this,O,`f`).values())e.disable()}},xr=function(e){let t=S(this,k,`f`).get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))},Sr=function(){let e=null;for(e of S(this,j,`f`));return e},Cr=function(){if(S(this,O,`f`).size===0)return!0;if(S(this,O,`f`).size===1)for(let e of S(this,O,`f`).values())return e.isEmpty();return!1},wr=function(e){for(let e of S(this,j,`f`))e.unselect();S(this,j,`f`).clear();for(let t of e)t.isEmpty()||(S(this,j,`f`).add(t),t.select());S(this,E,`m`,M).call(this,{hasSelectedEditor:this.hasSelection})},Tr.TRANSLATE_SMALL=1,Tr.TRANSLATE_BIG=10;var Er,Dr=class{constructor(){Er.set(this,Object.create(null))}getListeners(){return S(this,Er,`f`)}on(e,t,n=null){this._on(e,t,{external:!0,once:n?.once,signal:n?.signal})}off(e,t){this._off(e,t)}dispatch(e,t){let n=S(this,Er,`f`)[e];if(!n||n.length===0)return;let r;for(let{listener:i,external:a,once:o}of n.slice(0)){if(o&&this._off(e,i),a){(r||=[]).push(i);continue}i(t)}if(r){for(let e of r)e(t);r=null}}_on(e,t,n=null){var r;let i=null;if(n?.signal instanceof AbortSignal){let{signal:r}=n;if(r.aborted)return;let a=()=>this._off(e,t);i=()=>r.removeEventListener(`abort`,a),r.addEventListener(`abort`,a)}((r=S(this,Er,`f`))[e]||(r[e]=[])).push({listener:t,external:n?.external===!0,once:n?.once===!0,rmAbort:i})}_off(e,t){let n=S(this,Er,`f`)[e];if(n)for(let e=0,r=n.length;e<r;e++){let r=n[e];if(r.listener===t){r.rmAbort?.call(r),n.splice(e,1);return}}}};Er=new WeakMap;let Or={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},kr={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},Ar={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2},jr={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3};function Mr(e,t,n=!1){let r=e.offsetParent;if(!r){console.error(`offsetParent is not set -- cannot scroll`);return}let i=e.offsetTop+e.clientTop,a=e.offsetLeft+e.clientLeft;for(;r.clientHeight===r.scrollHeight&&r.clientWidth===r.scrollWidth||n&&(r.classList.contains(`markedContent`)||r.classList.contains(`k-marked-content`)||getComputedStyle(r).overflow===`hidden`);)if(i+=r.offsetTop,a+=r.offsetLeft,r=r.offsetParent,!r)return;t&&(t.top!==void 0&&(i+=t.top),t.left!==void 0&&(a+=t.left,r.scrollLeft=a)),r.scrollTop=i}function Nr(e){let t=new Map,n=new URLSearchParams(e);for(let[e,r]of n)t.set(e.toLowerCase(),r);return t}function Pr(e,t,n=0){let r=n,i=e.length-1;if(i<0||!t(e[i]))return e.length;if(t(e[r]))return r;for(;r<i;){let n=r+i>>1,a=e[n];t(a)?i=n:r=n+1}return r}var Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur=class{constructor(){Fr.add(this),Lr.set(this,!1),Rr.set(this,null),zr.set(this,new Map),Br.set(this,new Map)}setTextMapping(e){C(this,Rr,e,`f`)}enable(){if(S(this,Lr,`f`),!S(this,Rr,`f`))throw Error(`Text divs and strings have not been set.`);if(C(this,Lr,!0,`f`),C(this,Rr,S(this,Rr,`f`).slice(),`f`),S(this,Rr,`f`).sort(S(Ir,Ir,`m`,Vr)),S(this,zr,`f`).size>0){let e=S(this,Rr,`f`);for(let[t,n]of S(this,zr,`f`)){if(!document.getElementById(t)){S(this,zr,`f`).delete(t);continue}S(this,Fr,`m`,Hr).call(this,t,e[n])}}for(let[e,t]of S(this,Br,`f`))this.addPointerInTextLayer(e,t);S(this,Br,`f`).clear()}disable(){S(this,Lr,`f`)&&(S(this,Br,`f`).clear(),C(this,Rr,null,`f`),C(this,Lr,!1,`f`))}removePointerInTextLayer(e){if(!S(this,Lr,`f`)){S(this,Br,`f`).delete(e);return}let t=S(this,Rr,`f`);if(!t||t.length===0)return;let{id:n}=e,r=S(this,zr,`f`).get(n);if(r===void 0)return;let i=t[r];S(this,zr,`f`).delete(n);let a=i.getAttribute(`aria-owns`);a?.includes(n)&&(a=a.split(` `).filter(e=>e!==n).join(` `),a?i.setAttribute(`aria-owns`,a):(i.removeAttribute(`aria-owns`),i.setAttribute(`role`,`presentation`)))}addPointerInTextLayer(e,t){if(!e){console.warn(`no element`);return}let{id:n}=e;if(!n)return null;if(!S(this,Lr,`f`))return S(this,Br,`f`).set(e,t),null;t&&this.removePointerInTextLayer(e);let r=S(this,Rr,`f`);if(!r||r.length===0)return null;let i=Pr(r,t=>S(Ir,Ir,`m`,Vr).call(Ir,e,t)<0),a=Math.max(0,i-1),o=r[a];S(this,Fr,`m`,Hr).call(this,n,o),S(this,zr,`f`).set(n,a);let s=o.parentNode;return s?.classList.contains(`markedContent`)||s?.classList.contains(`k-marked-content`)?s.id:null}moveElementInDOM(e,t,n,r){let i=this.addPointerInTextLayer(n,r);if(!e.hasChildNodes())return e.append(t),i;let a=Array.from(e.children).filter(e=>e!==t);if(a.length===0)return i;let o=n||t,s=Pr(a,e=>S(Ir,Ir,`m`,Vr).call(Ir,o,e)<0);return s===0?a[0].before(t):a[s-1].after(t),i}destroy(){C(this,zr,new Map,`f`),C(this,Br,new Map,`f`),C(this,Rr,null,`f`)}};Ir=Ur,Lr=new WeakMap,Rr=new WeakMap,zr=new WeakMap,Br=new WeakMap,Fr=new WeakSet,Vr=function(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();if(n.width===0&&n.height===0)return 1;if(r.width===0&&r.height===0)return-1;let i=n.y,a=n.y+n.height,o=n.y+n.height/2,s=r.y,c=r.y+r.height,l=r.y+r.height/2;return o<=s&&l>=a?-1:l<=i&&o>=c?1:n.x+n.width/2-(r.x+r.width/2)},Hr=function(e,t){let n=t.getAttribute(`aria-owns`);n?.includes(e)||t.setAttribute(`aria-owns`,n?`${n} ${e}`:e),t.removeAttribute(`role`)};var Wr,N,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr=class{constructor({pdfPage:e,accessibilityManager:t,styles:n,onAppend:r=null}){Wr.add(this),this.pdfPage=null,this.div=null,this.accessibilityManager=null,Gr.set(this,null),Kr.set(this,null),this.pdfPage=e,this.accessibilityManager=t,C(this,Gr,r,`f`),this.div=document.createElement(`div`),this.div.tabIndex=0,this.div.classList.add(`k-text-layer`),n&&Object.keys(n).length>0&&Vt(this.div,n)}render(e){return x(this,arguments,void 0,function*(e,t=null){if(S(this,Kr,`f`)){S(this,Kr,`f`).update({viewport:e,onBefore:this.hide.bind(this)}),this.show();return}this.cancel(),C(this,Kr,new Ct({textContentSource:this.pdfPage.streamTextContent(t||{includeMarkedContent:!1,disableNormalization:!0}),container:this.div,viewport:e}),`f`);let{textDivs:n}=S(this,Kr,`f`);this.accessibilityManager?.setTextMapping(n),yield S(this,Kr,`f`).render();let r=Array.from(this.div.querySelectorAll(`.markedContent`)||[])||[];if(r.forEach(e=>Jt(`k-marked-content`,e)),r&&r.length>0){let e=document.createElement(`div`);e.className=`endOfContent`,this.div.append(e),S(this,Wr,`m`,Yr).call(this,e)}S(this,Gr,`f`)?.call(this,this.div),this.accessibilityManager?.enable()})}hide(){this.div.hidden||(this.div.hidden=!0)}show(){this.div.hidden&&(this.div.hidden=!1)}cancel(){S(this,Kr,`f`)?.cancel(),C(this,Kr,null,`f`),this.accessibilityManager?.disable(),this.accessibilityManager?.destroy(),S(N,N,`m`,Xr).call(N,this.div)}destroy(){Ct.cleanup(),this.cancel(),this.pdfPage=null,this.accessibilityManager?.destroy(),this.accessibilityManager=null,this.div?.remove(),this.div=null}};N=Qr,Gr=new WeakMap,Kr=new WeakMap,Wr=new WeakSet,Yr=function(e){let{div:t}=this;S(N,N,`f`,qr).set(t,e),S(N,N,`m`,Zr).call(N)},Xr=function(e){S(this,N,`f`,qr).delete(e),S(this,N,`f`,qr).size===0&&(S(this,N,`f`,Jr)?.abort(),C(this,N,null,`f`,Jr))},Zr=function(){},qr={value:new Map},Jr={value:null};function $r(e){return Math.floor(Math.max(0,Math.min(1,e))*255).toString(16).padStart(2,`0`)}function ei(e){return Math.max(0,Math.min(255,255*e))}var ti=class{static CMYK_G([e,t,n,r]){return[`G`,1-Math.min(1,.3*e+.59*n+.11*t+r)]}static G_CMYK([e]){return[`CMYK`,0,0,0,1-e]}static G_RGB([e]){return[`RGB`,e,e,e]}static G_rgb([e]){return e=ei(e),[e,e,e]}static G_HTML([e]){let t=$r(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return[`G`,.3*e+.59*t+.11*n]}static RGB_rgb(e){return e.map(ei)}static RGB_HTML(e){return`#${e.map($r).join(``)}`}static T_HTML(){return`#00000000`}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,r]){return[`RGB`,1-Math.min(1,e+r),1-Math.min(1,n+r),1-Math.min(1,t+r)]}static CMYK_rgb([e,t,n,r]){return[ei(1-Math.min(1,e+r)),ei(1-Math.min(1,n+r)),ei(1-Math.min(1,t+r))]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){let r=1-e,i=1-t,a=1-n;return[`CMYK`,r,i,a,Math.min(r,i,a)]}};function ni(e){if(e.startsWith(`#`)){let t=parseInt(e.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return e.startsWith(`rgb(`)?e.slice(4,-1).split(`,`).map(e=>parseInt(e,10)):e.startsWith(`rgba(`)?e.slice(5,-1).split(`,`).map(e=>parseInt(e,10)).slice(0,3):[0,0,0]}function ri(e){let t=document.createElement(`span`);t.style.visibility=`hidden`,document.body.append(t);for(let n of e.keys()){t.style.color=n;let r=window.getComputedStyle(t).color;e.set(n,ni(r))}t.remove()}var ii=class e{get _colors(){if(typeof document>`u`)return Cn(this,`_colors`,e._colorsMapping);let t=new Map([[`CanvasText`,null],[`Canvas`,null]]);return ri(t),Cn(this,`_colors`,t)}convert(t){let n=ni(t);if(!window.matchMedia(`(forced-colors: active)`).matches)return n;for(let[t,r]of this._colors)if(r.every((e,t)=>e===n[t]))return e._colorsMapping.get(t);return n}getHexCode(e){let t=this._colors.get(e);return t?En.makeHexColor(...t):e}};ii._colorsMapping=new Map([[`CanvasText`,[0,0,0]],[`Canvas`,[255,255,255]]]);function ai(e,t,n){for(let r of n)t.addEventListener(r,e[r].bind(e))}var oi,si,ci,li,ui,di,fi,pi,mi,hi,gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti,Ei,Di,P=class{constructor(e){oi.add(this),this.parent=null,this.id=null,this.width=null,this.height=null,this.pageIndex=0,this.name=``,this.div=null,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._structTreeParentId=null,this.rotation=0,this.pageRotation=0,this.pageDimensions=[],this.pageTranslation=[],ci.set(this,0),li.set(this,0),this.isAttachedToDOM=!1,this.deleted=!1,ui.set(this,!1),di.set(this,!1),fi.set(this,null),pi.set(this,!1),mi.set(this,null),hi.set(this,!1),gi.set(this,!1),_i.set(this,null),vi.set(this,0),yi.set(this,0),this._editToolbar=null,this._initialOptions=Object.create(null),this._isVisible=!0,this._uiManager=null,this._focusEventsAllowed=!0,this._l10nPromise=null,bi.set(this,!1),xi.set(this,si._zIndex++),this.parent=e.parent,this.id=e.id||si.idManager.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;let{rotation:t,rawDims:{pageWidth:n,pageHeight:r,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,r],this.pageTranslation=[i,a];let[o,s]=this.parentDimensions;this.x=e.x/o,this.y=e.y/s,this.isAttachedToDOM=!1,this.deleted=!1}get x(){return S(this,ci,`f`)}set x(e){C(this,ci,e,`f`)}get y(){return S(this,li,`f`)}set y(e){C(this,li,e,`f`)}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return ft(this,`_defaultLineColor`,this._colorManager.getHexCode(`CanvasText`))}static deleteAnnotationElement(e){let t=new Oi({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t,n){}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){if(e)return!1}static paste(e,t){}get propertiesToUpdate(){return[]}get _isDraggable(){return S(this,bi,`f`)}set _isDraggable(e){C(this,bi,e,`f`),this.div?.classList.toggle(`k-draggable`,e)}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=S(this,xi,`f`)}setParent(e){e===null?S(this,oi,`m`,Di).call(this):(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){e&&this._focusEventsAllowed&&(S(this,pi,`f`)?C(this,pi,!1,`f`):this.parent.setSelected(this))}focusout(e){!this._focusEventsAllowed||!this.isAttachedToDOM||e.relatedTarget?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,r){let[i,a]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(e+n)/i,this.y=(t+r)/a,this.fixAndSetPosition()}translate(e,t){S(this,oi,`m`,Si).call(this,this.parentDimensions,e,t)}translateInPage(e,t){C(this,mi,S(this,mi,`f`)||[this.x,this.y],`f`),S(this,oi,`m`,Si).call(this,this.pageDimensions,e,t),this.div.scrollIntoView({block:`nearest`})}drag(e,t){C(this,mi,S(this,mi,`f`)||[this.x,this.y],`f`);let[n,r]=this.parentDimensions;if(this.x+=e/n,this.y+=t/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:i,y:a}=this,[o,s]=this.getBaseTranslation();i+=o,a+=s,this.div.style.left=`${(100*i).toFixed(2)}%`,this.div.style.top=`${(100*a).toFixed(2)}%`,this.div.scrollIntoView({block:`nearest`})}get _hasBeenMoved(){return!!S(this,mi,`f`)&&(S(this,mi,`f`)[0]!==this.x||S(this,mi,`f`)[1]!==this.y)}getBaseTranslation(){let[e,t]=this.parentDimensions,{_borderLineWidth:n}=si,r=n/e,i=n/t;switch(this.rotation){case 90:return[-r,i];case 180:return[r,i];case 270:return[r,-i];default:return[-r,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){if(e===void 0)return;let[t,n]=this.pageDimensions,{x:r,y:i,width:a,height:o}=this;if(a*=t,o*=n,r*=t,i*=n,this._mustFixPosition)switch(e){case 0:r=Math.max(0,Math.min(t-a,r)),i=Math.max(0,Math.min(n-o,i));break;case 90:r=Math.max(0,Math.min(t-o,r)),i=Math.min(n,Math.max(a,i));break;case 180:r=Math.min(t,Math.max(a,r)),i=Math.min(n,Math.max(o,i));break;case 270:r=Math.min(t,Math.max(o,r)),i=Math.max(0,Math.min(n-a,i));break;default:break}this.x=r/=t,this.y=i/=n;let[s,c]=this.getBaseTranslation();r+=s,i+=c;let{style:l}=this.div;l.left=`${(100*r).toFixed(2)}%`,l.top=`${(100*i).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,t){return S(si,si,`m`,Ci).call(si,e,t,this.parentRotation)}pageTranslationToScreen(e,t){return S(si,si,`m`,Ci).call(si,e,t,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,n]}=this,r=t*e,i=n*e;return pt.isCSSRoundSupported?[Math.round(r),Math.round(i)]:[r,i]}setDims(e,t){let[n,r]=this.parentDimensions;this.div.style.width=`${(100*e/n).toFixed(2)}%`,S(this,di,`f`)||(this.div.style.height=`${(100*t/r).toFixed(2)}%`)}fixDims(){}getInitialTranslation(){return[0,0]}addEditToolbar(){this._uiManager?.showEditorToolBar(this.div)}removeEditToolbar(){this._uiManager.hideEditorToolBar()}getClientDimensions(){return this.div.getBoundingClientRect()}render(){this.div=document.createElement(`div`),this.div.setAttribute(`data-editor-rotation`,(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute(`id`,this.id),this.div.tabIndex=S(this,ui,`f`)?-1:0,this._isVisible||this.div.classList.add(`k-hidden`),this.setInForeground(),S(this,oi,`m`,Ei).call(this);let[e,t]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`);let[n,r]=this.getInitialTranslation();return this.translate(n,r),ai(this,this.div,[`pointerdown`]),this.div}pointerdown(e){let{isMac:t}=pt.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(C(this,pi,!0,`f`),this._isDraggable){this._uiManager?.hideEditorToolBar(),S(this,oi,`m`,Ti).call(this,e);return}S(this,oi,`m`,wi).call(this,e)}moveInDOM(){S(this,_i,`f`)&&clearTimeout(S(this,_i,`f`)),C(this,_i,setTimeout(()=>{C(this,_i,null,`f`),this.parent?.moveEditorInDOM(this)},0),`f`)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition()}getRect(e,t,n=this.rotation){let r=this.parentScale,[i,a]=this.pageDimensions,[o,s]=this.pageTranslation,c=e/r,l=t/r,u=this.x*i,d=this.y*a,f=this.width*i,p=this.height*a;switch(n){case 0:return[u+c+o,a-d-l-p+s,u+c+f+o,a-d-l+s];case 90:return[u+l+o,a-d+c+s,u+l+p+o,a-d+c+f+s];case 180:return[u-c-f+o,a-d+l+s,u-c+o,a-d+l+p+s];case 270:return[u-l-p+o,a-d-c-f+s,u-l+o,a-d-c+s];default:throw Error(`Invalid rotation`)}}getRectInCurrentCoords(e,t){let[n,r,i,a]=e,o=i-n,s=a-r;switch(this.rotation){case 0:return[n,t-a,o,s];case 90:return[n,t-r,s,o];case 180:return[i,t-r,o,s];case 270:return[i,t-a,s,o];default:break}}onceAdded(){}isEmpty(){return!1}enableEditMode(){C(this,gi,!0,`f`)}disableEditMode(){C(this,gi,!1,`f`)}isInEditMode(){return S(this,gi,`f`)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){S(this,oi,`m`,Ei).call(this)}rotate(e){}serialize(e=!1,t=null){}static deserialize(e,t,n){let r=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});r.rotation=e.rotation;let[i,a]=r.pageDimensions,[o,s,c,l]=r.getRectInCurrentCoords(e.rect,a);return r.x=o/i,r.y=s/a,r.width=c/i,r.height=l/a,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){S(this,fi,`f`)?.abort(),C(this,fi,null,`f`),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),S(this,_i,`f`)&&(clearTimeout(S(this,_i,`f`)),C(this,_i,null,`f`)),S(this,oi,`m`,Di).call(this),this.removeEditToolbar(),this.parent=null}get isResizable(){return!1}makeResizable(){}get toolbarPosition(){return null}_stopResizingWithKeyboard(){}select(){this.div?.classList.add(`k-selected`),this.addEditToolbar()}unselect(){this.div?.classList.remove(`k-selected`),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0})}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return S(this,hi,`f`)}set isEditing(e){C(this,hi,e,`f`),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){C(this,di,!0,`f`);let n=e/t,{style:r}=this.div;r.aspectRatio=n,r.height=`auto`}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:`added`}}get telemetryFinalData(){return null}_reportTelemetry(){}show(e=this._isVisible){this.div.classList.toggle(`k-hidden`,!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),C(this,ui,!1,`f`)}disable(){this.div&&(this.div.tabIndex=-1),C(this,ui,!0,`f`)}renderAnnotationElement(e){let t=e.container.querySelector(`.annotationContent`)||e.container.querySelector(`.k-annotation-content`);if(!t)t=document.createElement(`div`),t.classList.add(`k-annotation-content`,this.editorType),e.container.prepend(t);else if(t.nodeName===`CANVAS`){let e=t;t=document.createElement(`div`),t.classList.add(`k-annotation-content`,this.editorType),e.before(t)}return t}resetAnnotationElement(e){let{firstChild:t}=e.container;t.nodeName===`DIV`&&(t.classList.contains(`annotationContent`)||t.classList.contains(`k-annotation-content`))&&t.remove()}};si=P,ci=new WeakMap,li=new WeakMap,ui=new WeakMap,di=new WeakMap,fi=new WeakMap,pi=new WeakMap,mi=new WeakMap,hi=new WeakMap,gi=new WeakMap,_i=new WeakMap,vi=new WeakMap,yi=new WeakMap,bi=new WeakMap,xi=new WeakMap,oi=new WeakSet,Si=function([e,t],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/e,this.y+=r/t,this.fixAndSetPosition()},Ci=function(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}},wi=function(e){let{isMac:t}=pt.platform,n=e.target.closest(`.k-highlight-editor`),r=e.target.closest(`.k-free-text-editor`),i=this._uiManager.getMode();i===bn.HIGHLIGHT&&!n||i===bn.FREETEXT&&!r||(e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this))},Ti=function(e){let t=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let n=new AbortController,r=this._uiManager.combinedSignal(n);t&&(C(this,vi,e.clientX,`f`),C(this,yi,e.clientY,`f`),window.addEventListener(`pointermove`,e=>{let{clientX:t,clientY:n}=e,[r,i]=this.screenToPageTranslation(t-S(this,vi,`f`),n-S(this,yi,`f`));C(this,vi,t,`f`),C(this,yi,n,`f`),this._uiManager.dragSelectedEditors(r,i)},{passive:!0,capture:!0,signal:r}));let i=()=>{n.abort(),t&&this.div.classList.remove(`moving`),C(this,pi,!1,`f`),this._uiManager.endDragSession()||S(this,oi,`m`,wi).call(this,e)};window.addEventListener(`pointerup`,i,{signal:r}),window.addEventListener(`blur`,i,{signal:r})},Ei=function(){if(S(this,fi,`f`)||!this.div)return;C(this,fi,new AbortController,`f`);let e=this._uiManager.combinedSignal(S(this,fi,`f`));this.div.addEventListener(`focusin`,this.focusin.bind(this),{signal:e}),this.div.addEventListener(`focusout`,this.focusout.bind(this),{signal:e})},Di=function(){},P.idManager=new kn(`annotation_editor_id_`),P._borderLineWidth=-1,P._colorManager=new ii,P._zIndex=1,P._telemetryTimeout=1e3;var Oi=class extends P{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}};let ki=3285377520,F=4294901760,Ai=65535;var ji=class{constructor(e){this.h1=null,this.h2=null,this.h1=e?e&4294967295:ki,this.h2=e?e&4294967295:ki}update(e){let t,n;if(typeof e==`string`){t=new Uint8Array(e.length*2),n=0;for(let r=0,i=e.length;r<i;r++){let i=e.charCodeAt(r);i<=255?t[n++]=i:(t[n++]=i>>>8,t[n++]=i&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),n=t.byteLength;else throw Error(`Invalid data format, must be a string or TypedArray.`);let r=n>>2,i=n-r*4,a=new Uint32Array(t.buffer,0,r),o=0,s=0,c=this.h1,l=this.h2,u=3432918353,d=461845907,f=11601,p=13715;for(let e=0;e<r;e++)e&1?(o=a[e],o=o*u&F|o*f&Ai,o=o<<15|o>>>17,o=o*d&F|o*p&Ai,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(s=a[e],s=s*u&F|s*f&Ai,s=s<<15|s>>>17,s=s*d&F|s*p&Ai,l^=s,l=l<<13|l>>>19,l=l*5+3864292196);switch(o=0,i){case 3:o^=t[r*4+2]<<16;case 2:o^=t[r*4+1]<<8;case 1:o^=t[r*4],o=o*u&F|o*f&Ai,o=o<<15|o>>>17,o=o*d&F|o*p&Ai,r&1?c^=o:l^=o;break;default:break}this.h1=c,this.h2=l}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&F|e*36045&Ai,t=t*4283543511&F|((t<<16|e>>>16)*2950163797&F)>>>16,e^=t>>>1,e=e*444984403&F|e*60499&Ai,t=t*3301882366&F|((t<<16|e>>>16)*3120437893&F)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}},Mi,Ni,Pi,I,Fi,Ii;let Li=Object.freeze({map:null,hash:``,transfer:void 0});var Ri=class{constructor(){Mi.add(this),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null,Ni.set(this,!1),Pi.set(this,null),I.set(this,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getStorage(){return S(this,I,`f`)}getModified(){return S(this,Ni,`f`)}getValue(e,t){let n=S(this,I,`f`).get(e);return n===void 0?t:Object.assign(t,n)}getRawValue(e){return S(this,I,`f`).get(e)}remove(e){if(S(this,I,`f`).delete(e),S(this,I,`f`).size===0&&this.resetModified(),typeof this.onAnnotationEditor==`function`){for(let e of S(this,I,`f`).values())if(e instanceof P)return;this.onAnnotationEditor(null)}}setValue(e,t){let n=S(this,I,`f`).get(e),r=!1;if(n!==void 0)for(let[e,i]of Object.entries(t))n[e]!==i&&(r=!0,n[e]=i);else r=!0,S(this,I,`f`).set(e,t);r&&S(this,Mi,`m`,Fi).call(this),t instanceof P&&typeof this.onAnnotationEditor==`function`&&this.onAnnotationEditor(t.constructor._type)}has(e){return S(this,I,`f`).has(e)}getAll(){return S(this,I,`f`).size>0?wn(S(this,I,`f`)):null}setAll(e){for(let[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return S(this,I,`f`).size}resetModified(){S(this,Ni,`f`)&&(C(this,Ni,!1,`f`),typeof this.onResetModified==`function`&&this.onResetModified())}get print(){return new zi(this)}get serializable(){if(S(this,I,`f`).size===0)return Li;let e=new Map,t=new ji(null),n=[],r=Object.create(null),i=!1;for(let[n,a]of S(this,I,`f`)){let o=a instanceof P?a.serialize(!1,r):a;o&&(e.set(n,o),t.update(`${n}:${JSON.stringify(o)}`),i||=!!o.bitmap)}if(i)for(let t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:Li}get editorStats(){let e=null,t=new Map;for(let n of S(this,I,`f`).values()){if(!(n instanceof P))continue;let r=n.telemetryFinalData;if(!r)continue;let{type:i}=r;t.has(i)||t.set(i,Object.getPrototypeOf(n).constructor),e||=Object.create(null);let a=e[i]||(e[i]=new Map);for(let[e,t]of Object.entries(r)){if(e===`type`)continue;let n=a.get(e);n||(n=new Map,a.set(e,n));let r=n.get(t)??0;n.set(t,r+1)}}for(let[n,r]of t)e[n]=r.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){C(this,Pi,null,`f`)}get modifiedIds(){if(S(this,Pi,`f`))return S(this,Pi,`f`);let e=[];for(let t of S(this,I,`f`).values())!(t instanceof P)||!t.annotationElementId||!t.serialize()||e.push(t.annotationElementId);return C(this,Pi,{ids:new Set(e),hash:e.join(`,`)},`f`)}};Ni=new WeakMap,Pi=new WeakMap,I=new WeakMap,Mi=new WeakSet,Fi=function(){S(this,Ni,`f`)||(C(this,Ni,!0,`f`),typeof this.onSetModified==`function`&&this.onSetModified())};var zi=class extends Ri{constructor(e){super(),Ii.set(this,void 0);let{map:t,hash:n,transfer:r}=e.serializable,i=structuredClone(t,r?{transfer:r}:null);C(this,Ii,{map:i,hash:n,transfer:r},`f`)}get print(){return null}get serializable(){return S(this,Ii,`f`)}get modifiedIds(){return ft(this,`modifiedIds`,{ids:new Set,hash:``})}};Ii=new WeakMap;var Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,L,Yi,Xi,Zi,Qi,$i,R,ea,ta,na,ra,ia,aa,oa,sa,ca,la,ua,da,fa,pa,ma,ha,ga,_a,va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da;let Oa=new WeakSet;function ka(e){return{width:e[2]-e[0],height:e[3]-e[1]}}var Aa=class{static create(e){switch(e.data.annotationType){case xn.LINK:return new Ma(e);case xn.WIDGET:switch(e.data.fieldType){case`Tx`:return new Pa(e);case`Btn`:return e.data.radioButton?new Ia(e):e.data.checkBox?new Fa(e):new La(e);case`Ch`:return new Ra(e);default:break}case xn.FREETEXT:return new Va(e);case xn.HIGHLIGHT:return new Ha(e);default:return new ja(e)}}},ja=class e{constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!1}={}){Bi.add(this),this.isRenderable=null,this.data=null,this.layer=null,this.linkService=null,this.downloadManager=null,this.imageResourcesPath=null,this.renderForms=null,this.svgFactory=null,this.annotationStorage=null,this.enableScripting=null,this.hasJSActions=null,this._fieldObjects=null,this.parent=null,this.container=null,this.popup=null,this.annotationEditorType=null,Vi.set(this,null),Hi.set(this,!1),Ui.set(this,null),this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(n)),r&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:n}){return!!(e?.str||t?.str||n?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return e._hasPopupData(this.data)}updateEdited(e){if(!this.container)return;C(this,Vi,S(this,Vi,`f`)||{rect:this.data.rect.slice(0)},`f`);let{rect:t}=e;t&&S(this,Bi,`m`,Wi).call(this,t),S(this,Ui,`f`)?.popup.updateEdited(e)}resetEdited(){S(this,Vi,`f`)&&(S(this,Bi,`m`,Wi).call(this,S(this,Vi,`f`).rect),S(this,Ui,`f`)?.popup.resetEdited(),C(this,Vi,null,`f`))}_createContainer(e){let{data:t,parent:{page:n,viewport:r}}=this,i=document.createElement(`section`);i.setAttribute(`data-annotation-id`,t.id),this instanceof Na||(i.tabIndex=0);let{style:a}=i;if(a.zIndex=(this.parent.zIndex++).toString(),t.popupRef&&i.setAttribute(`aria-haspopup`,`dialog`),t.alternativeText&&(i.title=t.alternativeText),t.noRotate,!t.rect||this instanceof za){let{rotation:e}=t;return!t.hasOwnCanvas&&e!==0&&this.setRotation(e,i),i}let{width:o,height:s}=ka(t.rect);if(!e&&t.borderStyle.width>0){a.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;switch(e>0||n>0?a.borderRadius=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`:this instanceof Ia&&(a.borderRadius=`calc(${o}px * var(--scale-factor)) / calc(${s}px * var(--scale-factor))`),t.borderStyle.style){case Sn.SOLID:a.borderStyle=`solid`;break;case Sn.DASHED:a.borderStyle=`dashed`;break;case Sn.BEVELED:break;case Sn.INSET:break;case Sn.UNDERLINE:a.borderBottomStyle=`solid`;break;default:break}let r=t.borderColor||null;r?(C(this,Hi,!0,`f`),a.borderColor=vt.makeHexColor(r[0]|0,r[1]|0,r[2]|0)):a.borderWidth=`0`}let c=vt.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]),{pageWidth:l,pageHeight:u,pageX:d,pageY:f}=r.rawDims;a.left=`${100*(c[0]-d)/l}%`,a.top=`${100*(c[1]-f)/u}%`;let{rotation:p}=t;return t.hasOwnCanvas||p===0?(a.width=`${100*o/l}%`,a.height=`${100*s/u}%`):this.setRotation(p,i),i}setRotation(e,t=this.container){if(!this.data.rect)return;let{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims,{width:i,height:a}=ka(this.data.rect),o,s;e%180==0?(o=100*i/n,s=100*a/r):(o=100*a/n,s=100*i/r),t.style.width=`${o}%`,t.style.height=`${s}%`,t.setAttribute(`data-main-rotation`,(360-e)%360)}get _commonActions(){let e=(e,t,n)=>{let r=n.detail[e],i=r[0],a=r.slice(1);n.target.style[t]=ti[`${i}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[t]:ti[`${i}_rgb`](a)})};return ft(this,`_commonActions`,{display:e=>{let{display:t}=e.detail,n=t%2==1;this.container.style.visibility=n?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:t===1||t===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:t}=e.detail;this.container.style.visibility=t?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e(`bgColor`,`backgroundColor`,t)},fillColor:t=>{e(`fillColor`,`backgroundColor`,t)},fgColor:t=>{e(`fgColor`,`color`,t)},textColor:t=>{e(`textColor`,`color`,t)},borderColor:t=>{e(`borderColor`,`borderColor`,t)},strokeColor:t=>{e(`strokeColor`,`borderColor`,t)},rotation:e=>{let t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){let n=this._commonActions;for(let r of Object.keys(t.detail))(e[r]||n[r])?.(t)}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let n=this._commonActions;for(let[r,i]of Object.entries(t)){let a=n[r];a&&(a({detail:{[r]:i},target:e}),delete t[r])}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[t,n,r,i]=this.data.rect.map(e=>Math.fround(e));if(e.length===8){let[a,o,s,c]=e.subarray(2,6);if(r===a&&i===o&&t===s&&n===c)return}let{style:a}=this.container,o;if(S(this,Hi,`f`)){let{borderColor:e,borderWidth:t}=a;a.borderWidth=0,o=[`url('data:image/svg+xml;utf8,`,`<svg xmlns="http://www.w3.org/2000/svg"`,` preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${e}" stroke-width="${t}">`]}let s=r-t,c=i-n,{svgFactory:l}=this,u=l.createElement(`svg`);u.setAttribute(`width`,0),u.setAttribute(`height`,0);let d=l.createElement(`defs`);u.append(d);let f=l.createElement(`clipPath`),p=`clippath_${this.data.id}`;f.setAttribute(`id`,p),f.setAttribute(`clipPathUnits`,`objectBoundingBox`),d.append(f);for(let n=2,r=e.length;n<r;n+=8){let r=e[n],a=e[n+1],u=e[n+2],d=e[n+3],p=l.createElement(`rect`),m=(u-t)/s,h=(i-a)/c,ee=(r-u)/s,g=(a-d)/c;p.setAttribute(`x`,m),p.setAttribute(`y`,h),p.setAttribute(`width`,ee),p.setAttribute(`height`,g),f.append(p),o?.push(`<rect vector-effect="non-scaling-stroke" x="${m}" y="${h}" width="${ee}" height="${g}"/>`)}S(this,Hi,`f`)&&(o.push(`</g></svg>')`),a.backgroundImage=o.join(``)),this.container.append(u),this.container.style.clipPath=`url(#${p})`}_createPopup(){}render(){}_getElementsByName(e,t=null){let n=[];if(this._fieldObjects){let r=this._fieldObjects[e];if(r)for(let{page:e,id:i,exportValues:a}of r){if(e===-1||i===t)continue;let r=typeof a==`string`?a:null,o=document.querySelector(`[data-element-id="${i}"]`);o&&!Oa.has(o)||n.push({id:i,exportValue:r,domElement:o})}return n}for(let r of document.getElementsByName(e)){let{exportValue:e}=r,i=r.getAttribute(`data-element-id`);i!==t&&Oa.has(r)&&n.push({id:i,exportValue:e,domElement:r})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){this.getElementsToTriggerPopup()}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener(`dblclick`,()=>{(this.linkService?.eventBus)?.dispatch(`switchannotationeditormode`,{source:this,mode:e,editId:t})})}_setRequired(e,t){t?e.setAttribute(`required`,!0):e.removeAttribute(`required`),e.setAttribute(`aria-required`,t)}};Vi=new WeakMap,Hi=new WeakMap,Ui=new WeakMap,Bi=new WeakSet,Wi=function(e){let{container:{style:t},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:o,pageY:s}}}}=this;n?.splice(0,4,...e);let{width:c,height:l}=ka(e);t.left=`${100*(e[0]-o)/i}%`,t.top=`${100*(a-e[3]+s)/a}%`,r===0?(t.width=`${100*c/i}%`,t.height=`${100*l/a}%`):this.setRotation(r)};var Ma=class extends ja{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0}),Gi.add(this),this.isTooltipOnly=!1,this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,n=document.createElement(`a`);n.setAttribute(`data-element-id`,e.id);let r=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action),r=!0):e.attachment?(S(this,Gi,`m`,qi).call(this,n,e.attachment,e.attachmentDest),r=!0):e.setOCGState?(S(this,Gi,`m`,Ji).call(this,n,e.setOCGState),r=!0):e.dest?(this._bindLink(n,e.dest),r=!0):(e.actions&&(e.actions.Action||e.actions[`Mouse Up`]||e.actions[`Mouse Down`])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,``),r=!0)),this.container.classList.add(`k-link-annotation`),r&&this.container.append(n),this.container}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||t===``)&&S(this,Gi,`m`,Ki).call(this)}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),S(this,Gi,`m`,Ki).call(this)}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl(``);let n=new Map([[`Action`,`onclick`],[`Mouse Up`,`onmouseup`],[`Mouse Down`,`onmousedown`]]);for(let r of Object.keys(t.actions)){let i=n.get(r);i&&(e[i]=()=>(this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t.id,name:r}}),!1))}e.onclick||=()=>!1,S(this,Gi,`m`,Ki).call(this)}_bindResetFormAction(e,t){let n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl(``)),S(this,Gi,`m`,Ki).call(this),!this._fieldObjects){n||(e.onclick=()=>!1);return}e.onclick=()=>{n?.();let{fields:e,refs:r,include:i}=t,a=[];if(e.length!==0||r.length!==0){let t=new Set(r);for(let n of e){let e=this._fieldObjects[n]||[];for(let{id:n}of e)t.add(n)}for(let e of Object.values(this._fieldObjects))for(let n of e)t.has(n.id)===i&&a.push(n)}else for(let e of Object.values(this._fieldObjects))a.push(...e);let o=this.annotationStorage,s=[];for(let e of a){let{id:t}=e;switch(s.push(t),e.type){case`text`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}case`checkbox`:case`radiobutton`:{let n=e.defaultValue===e.exportValues;o.setValue(t,{value:n});break}case`combobox`:case`listbox`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}default:continue}let n=document.querySelector(`[data-element-id="${t}"]`);n&&Oa.has(n)&&n.dispatchEvent(new Event(`resetform`))}return this.enableScripting&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:`app`,ids:s,name:`ResetForm`}}),!1}}};Gi=new WeakSet,Ki=function(){this.container.setAttribute(`data-internal-link`,``)},qi=function(e,t,n=null){e.href=this.linkService.getAnchorUrl(``),t.description&&(e.title=t.description),e.onclick=()=>(this.downloadManager?.openOrDownloadData(t.content,t.filename,n),!1),S(this,Gi,`m`,Ki).call(this)},Ji=function(e,t){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),S(this,Gi,`m`,Ki).call(this)};var Na=class extends ja{render(){return this.container}showElementAndHideCanvas(e){this.data.hasOwnCanvas&&(e.previousSibling?.nodeName===`CANVAS`&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return pt.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,r,i){n.includes(`mouse`)?e.addEventListener(n,e=>{this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})}):e.addEventListener(n,e=>{if(n===`blur`){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if(n===`focus`){if(t.focused)return;t.focused=!0}i&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e)}})})}_setEventListeners(e,t,n,r){for(let[i,a]of n)(a===`Action`||this.data.actions?.[a])&&((a===`Focus`||a===`Blur`)&&(t||={focused:!1}),this._setEventListener(e,t,i,a,r),a===`Focus`&&!this.data.actions?.Blur?this._setEventListener(e,t,`blur`,`Blur`,null):a===`Blur`&&!this.data.actions?.Focus&&this._setEventListener(e,t,`focus`,`Focus`,null))}_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?`transparent`:vt.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){let t=[`left`,`center`,`right`],{fontColor:n}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||9,i=e.style,a,o=e=>Math.round(10*e)/10;if(this.data.multiLine){let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(1.35*r))||1);a=Math.min(r,o(t/_n))}else{let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(r,o(e/_n))}i.fontSize=`calc(${a}px * var(--scale-factor))`,i.color=vt.makeHexColor(n[0],n[1],n[2]),this.data.textAlignment!==null&&(i.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute(`required`,!0):e.removeAttribute(`required`),e.setAttribute(`aria-required`,t)}},Pa=class extends Na{constructor(e){let t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,n,r){let i=this.annotationStorage;for(let a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[t]=n),i.setValue(a.id,{[r]:n})}render(){let e=this.annotationStorage,t=this.data.id;this.container.classList.add(`k-text-widget-annotation`);let n=null;if(this.renderForms){let r=e.getValue(t,{value:this.data.fieldValue}),i=r.value||``,a=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;a&&i.length>a&&(i=i.slice(0,a));let o=r.formattedValue||this.data.textContent?.join(`
`)||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,``));let s={userValue:i,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement(`textarea`),n.textContent=o??i,this.data.doNotScroll&&(n.style.overflowY=`hidden`)):(n=document.createElement(`input`),n.type=`text`,n.setAttribute(`value`,o??i),this.data.doNotScroll&&(n.style.overflowX=`hidden`)),this.data.hasOwnCanvas&&(n.hidden=!0),Oa.add(n),n.setAttribute(`data-element-id`,t),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=0,this._setRequired(n,this.data.required),a&&(n.maxLength=a),n.addEventListener(`input`,r=>{e.setValue(t,{value:r.target.value}),this.setPropertyOnSiblings(n,`value`,r.target.value,`value`),s.formattedValue=null}),n.addEventListener(`resetform`,()=>{let e=this.data.defaultFieldValue??``;n.value=s.userValue=e,s.formattedValue=null});let c=e=>{let{formattedValue:t}=s;t!=null&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener(`focus`,e=>{if(s.focused)return;let{target:t}=e;s.userValue&&(t.value=s.userValue),s.lastCommittedValue=t.value,s.commitKey=1,this.data.actions?.Focus||(s.focused=!0)}),n.addEventListener(`updatefromsandbox`,n=>{this.showElementAndHideCanvas(n.target),this._dispatchEventFromSandbox({value(n){s.userValue=n.detail.value??``,e.setValue(t,{value:s.userValue.toString()}),n.target.value=s.userValue},formattedValue(n){let{formattedValue:r}=n.detail;s.formattedValue=r,r!=null&&n.target!==document.activeElement&&(n.target.value=r),e.setValue(t,{formattedValue:r})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:n=>{let{charLimit:r}=n.detail,{target:i}=n;if(r===0){i.removeAttribute(`maxLength`);return}i.setAttribute(`maxLength`,r);let a=s.userValue;!a||a.length<=r||(a=a.slice(0,r),i.value=s.userValue=a,e.setValue(t,{value:a}),this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:a,willCommit:!0,commitKey:1,selStart:i.selectionStart,selEnd:i.selectionEnd}}))}},n)}),n.addEventListener(`keydown`,e=>{s.commitKey=1;let n=-1;if(e.key===`Escape`?n=0:e.key===`Enter`&&!this.data.multiLine?n=2:e.key===`Tab`&&(s.commitKey=3),n===-1)return;let{value:r}=e.target;s.lastCommittedValue!==r&&(s.lastCommittedValue=r,s.userValue=r,this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:r,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))});let r=c;c=null,n.addEventListener(`blur`,e=>{if(!s.focused||!e.relatedTarget)return;this.data.actions?.Blur||(s.focused=!1);let{value:n}=e.target;s.userValue=n,s.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:n,willCommit:!0,commitKey:s.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}),r(e)}),this.data.actions?.Keystroke&&n.addEventListener(`beforeinput`,e=>{s.lastCommittedValue=null;let{data:n,target:r}=e,{value:i,selectionStart:a,selectionEnd:o}=r,c=a,l=o;switch(e.inputType){case`deleteWordBackward`:{let e=i.substring(0,a).match(/\w*[^\w]*$/);e&&(c-=e[0].length);break}case`deleteWordForward`:{let e=i.substring(a).match(/^[^\w]*\w*/);e&&(l+=e[0].length);break}case`deleteContentBackward`:a===o&&--c;break;case`deleteContentForward`:a===o&&(l+=1);break;default:break}e.preventDefault(),this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:i,change:n||``,willCommit:!1,selStart:c,selEnd:l}})}),this._setEventListeners(n,s,[[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.value)}if(c&&n.addEventListener(`blur`,c),this.data.comb){let e=(this.data.rect[2]-this.data.rect[0])/a;n.classList.add(`comb`),n.style.letterSpacing=`calc(${e}px * var(--scale-factor) - 1ch)`}}else n=document.createElement(`div`),n.textContent=this.data.fieldValue,n.style.verticalAlign=`middle`,n.style.display=`table-cell`,this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}},Fa=class extends Na{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,n=t.id,r=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;typeof r==`string`&&(r=r!==`Off`,e.setValue(n,{value:r})),this.container.classList.add(`k-button-widget-annotation`,`k-checkbox-widget-annotation`);let i=document.createElement(`input`);return Oa.add(i),i.setAttribute(`data-element-id`,n),i.disabled=t.readOnly,this._setRequired(i,this.data.required),i.type=`checkbox`,i.name=t.fieldName,r&&i.setAttribute(`checked`,`true`),i.setAttribute(`exportValue`,t.exportValue),i.tabIndex=0,i.addEventListener(`change`,r=>{let{name:i,checked:a}=r.target;for(let r of this._getElementsByName(i,n)){let n=a&&r.exportValue===t.exportValue;r.domElement&&(r.domElement.checked=n),e.setValue(r.id,{value:n})}e.setValue(n,{value:a})}),i.addEventListener(`resetform`,e=>{let n=t.defaultFieldValue||`Off`;e.target.checked=n===t.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value(t){t.target.checked=t.detail.value!==`Off`,e.setValue(n,{value:t.target.checked})}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)),this.enableScripting&&this.hasJSActions&&(i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value(t){t.target.checked=t.detail.value!==`Off`,e.setValue(n,{value:t.target.checked})}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},Ia=class extends Na{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add(`k-button-widget-annotation`,`k-radio-button-widget-annotation`);let e=this.annotationStorage,t=this.data,n=t.id,r=e.getValue(n,{value:t.fieldValue===t.buttonValue}).value;if(typeof r==`string`&&(r=r!==t.buttonValue,e.setValue(n,{value:r})),r)for(let r of this._getElementsByName(t.fieldName,n))e.setValue(r.id,{value:!1});let i=document.createElement(`input`);if(Oa.add(i),i.setAttribute(`data-element-id`,n),i.disabled=t.readOnly,this._setRequired(i,this.data.required),i.type=`radio`,i.name=t.fieldName,r&&i.setAttribute(`checked`,`true`),i.tabIndex=0,i.addEventListener(`change`,t=>{let{name:r,checked:i}=t.target;for(let t of this._getElementsByName(r,n))e.setValue(t.id,{value:!1});e.setValue(n,{value:i})}),i.addEventListener(`resetform`,e=>{let n=t.defaultFieldValue;e.target.checked=n!=null&&n===t.buttonValue}),this.enableScripting&&this.hasJSActions){let r=t.buttonValue;i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value:t=>{let i=r===t.detail.value;for(let r of this._getElementsByName(t.target.name)){let t=i&&r.id===n;r.domElement&&(r.domElement.checked=t),e.setValue(r.id,{value:t})}}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)}return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},La=class extends Ma{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();this.container.classList.add(`k-button-widget-annotation`,`k-push-button-widget-annotation`);let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener(`updatefromsandbox`,e=>{this._dispatchEventFromSandbox({},e)})),e}},Ra=class extends Na{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add(`choiceWidgetAnnotation`);let e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),r=document.createElement(`select`);Oa.add(r),r.setAttribute(`data-element-id`,t),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=0;let i=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener(`resetform`,()=>{let e=this.data.defaultFieldValue;for(let t of r.options)t.selected=t.value===e});for(let e of this.data.options){let t=document.createElement(`option`);t.textContent=e.displayValue,t.value=e.exportValue,n.value.includes(e.exportValue)&&(t.setAttribute(`selected`,`true`),i=!1),r.append(t)}let a=null;if(i){let e=document.createElement(`option`);e.value=` `,e.setAttribute(`hidden`,`true`),e.setAttribute(`selected`,`true`),r.prepend(e),a=()=>{e.remove(),r.removeEventListener(`input`,a),a=null},r.addEventListener(`input`,a)}let o=e=>{let t=e?`value`:`textContent`,{options:n,multiple:i}=r;return i?Array.prototype.filter.call(n,e=>e.selected).map(e=>e[t]):n.selectedIndex===-1?null:n[n.selectedIndex][t]},s=o(!1),c=e=>{let t=e.target.options;return Array.prototype.map.call(t,e=>({displayValue:e.textContent,exportValue:e.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener(`updatefromsandbox`,n=>{this._dispatchEventFromSandbox({value(n){a?.();let i=n.detail.value,c=new Set(Array.isArray(i)?i:[i]);for(let e of r.options)e.selected=c.has(e.value);e.setValue(t,{value:o(!0)}),s=o(!1)},multipleSelection(){r.multiple=!0},remove(n){let i=r.options,a=n.detail.remove;i[a].selected=!1,r.remove(a),i.length>0&&Array.prototype.findIndex.call(i,e=>e.selected)===-1&&(i[0].selected=!0),e.setValue(t,{value:o(!0),items:c(n)}),s=o(!1)},clear(){for(;r.length!==0;)r.remove(0);e.setValue(t,{value:null,items:[]}),s=o(!1)},insert(n){let{index:i,displayValue:a,exportValue:l}=n.detail.insert,u=r.children[i],d=document.createElement(`option`);d.textContent=a,d.value=l,u?u.before(d):r.append(d),e.setValue(t,{value:o(!0),items:c(n)}),s=o(!1)},items(n){let{items:i}=n.detail;for(;r.length!==0;)r.remove(0);for(let e of i){let{displayValue:t,exportValue:n}=e,i=document.createElement(`option`);i.textContent=t,i.value=n,r.append(i)}r.options.length>0&&(r.options[0].selected=!0),e.setValue(t,{value:o(!0),items:c(n)}),s=o(!1)},indices(n){let r=new Set(n.detail.indices);for(let e of n.target.options)e.selected=r.has(e.index);e.setValue(t,{value:o(!0)}),s=o(!1)},editable(e){e.target.disabled=!e.detail.editable}},n)}),r.addEventListener(`input`,n=>{let r=o(!0),i=o(!1);e.setValue(t,{value:r}),n.preventDefault(),this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:s,change:i,changeEx:r,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,null,[[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`],[`input`,`Action`],[`input`,`Validate`]],e=>e.target.value)):r.addEventListener(`input`,function(){e.setValue(t,{value:o(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}},za=class extends ja{constructor(e){let{data:t,elements:n}=e;super(e,{isRenderable:ja._hasPopupData(t)}),this.elements=[],this.elements=n,this.popup=null}render(){this.container.classList.add(`popupAnnotation`);let e=this.popup=new Ba({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(let n of this.elements)n.popup=e,t.push(n.data.id),n.addHighlightArea();return this.container.setAttribute(`aria-controls`,t.map(e=>`${Dn}${e}`).join(`,`)),this.container}},Ba=class{constructor({container:e,color:t,elements:n,titleObj:r,modificationDate:i,contentsObj:a,richText:o,parent:s,rect:c,parentRect:l,open:u}){L.add(this),this.trigger=null,Yi.set(this,S(this,L,`m`,_a).bind(this)),Xi.set(this,S(this,L,`m`,xa).bind(this)),Zi.set(this,S(this,L,`m`,ba).bind(this)),Qi.set(this,S(this,L,`m`,ya).bind(this)),$i.set(this,null),R.set(this,null),ea.set(this,null),ta.set(this,null),na.set(this,null),ra.set(this,null),ia.set(this,null),aa.set(this,!1),oa.set(this,null),sa.set(this,null),ca.set(this,null),la.set(this,null),ua.set(this,null),da.set(this,null),fa.set(this,!1),C(this,R,e,`f`),C(this,ua,r,`f`),C(this,ea,a,`f`),C(this,la,o,`f`),C(this,ra,s,`f`),C(this,$i,t,`f`),C(this,ca,c,`f`),C(this,ia,l,`f`),C(this,na,n,`f`),C(this,ta,_t.toDateObject(i),`f`),this.trigger=n.flatMap(e=>e.getElementsToTriggerPopup());for(let e of this.trigger)e.addEventListener(`click`,S(this,Qi,`f`)),e.addEventListener(`mouseenter`,S(this,Zi,`f`)),e.addEventListener(`mouseleave`,S(this,Xi,`f`)),e.classList.add(`popupTriggerArea`);for(let e of n)e.container?.addEventListener(`keydown`,S(this,Yi,`f`));S(this,R,`f`).hidden=!0,u&&S(this,L,`m`,ya).call(this),S(this,ra,`f`).popupShow.push(()=>x(this,void 0,void 0,function*(){S(this,R,`f`).hidden&&S(this,L,`m`,ba).call(this)}))}render(){if(S(this,oa,`f`))return;let e=C(this,oa,document.createElement(`div`),`f`);if(e.className=`popup`,S(this,$i,`f`)){let t=e.style.outlineColor=vt.makeHexColor(...S(this,$i,`f`));CSS.supports(`background-color`,`color-mix(in srgb, red 30%, white)`)?e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`:e.style.backgroundColor=vt.makeHexColor(...S(this,$i,`f`).map(e=>Math.floor(.7*(255-e)+e)))}let t=document.createElement(`span`);t.className=`header`;let n=document.createElement(`h1`);if(t.append(n),{dir:n.dir,str:n.textContent}=S(this,ua,`f`),e.append(t),S(this,ta,`f`)){let e=document.createElement(`span`);e.classList.add(`popupDate`),e.setAttribute(`data-l10n-id`,`pdfjs-annotation-date-string`),e.setAttribute(`data-l10n-args`,JSON.stringify({date:S(this,ta,`f`).toLocaleDateString(),time:S(this,ta,`f`).toLocaleTimeString()})),t.append(e)}let r=S(this,L,`a`,pa);if(r)yt.render({xfaHtml:r,intent:`richText`,div:e}),e.lastChild.classList.add(`richText`,`popupContent`);else{let t=this._formatContents(S(this,ea,`f`));e.append(t)}S(this,R,`f`).append(e)}_formatContents({str:e,dir:t}){let n=document.createElement(`p`);n.classList.add(`popupContent`),n.dir=t;let r=e.split(/(?:\r\n?|\n)/);for(let e=0,t=r.length;e<t;++e){let i=r[e];n.append(document.createTextNode(i)),e<t-1&&n.append(document.createElement(`br`))}return n}updateEdited({rect:e,popupContent:t}){C(this,da,S(this,da,`f`)||{contentsObj:S(this,ea,`f`),richText:S(this,la,`f`)},`f`),e&&C(this,sa,null,`f`),t&&(C(this,la,S(this,L,`m`,ga).call(this,t),`f`),C(this,ea,null,`f`)),S(this,oa,`f`)?.remove(),C(this,oa,null,`f`)}resetEdited(){var e,t;S(this,da,`f`)&&(e=this,t=this,{contentsObj:{set value(t){C(e,ea,t,`f`)}}.value,richText:{set value(e){C(t,la,e,`f`)}}.value}=S(this,da,`f`),C(this,da,null,`f`),S(this,oa,`f`)?.remove(),C(this,oa,null,`f`),C(this,sa,null,`f`))}forceHide(){C(this,fa,this.isVisible,`f`),S(this,fa,`f`)&&(S(this,R,`f`).hidden=!0)}maybeShow(){S(this,fa,`f`)&&(S(this,oa,`f`)||S(this,L,`m`,ba).call(this),C(this,fa,!1,`f`),S(this,R,`f`).hidden=!1)}get isVisible(){return S(this,R,`f`).hidden===!1}};Yi=new WeakMap,Xi=new WeakMap,Zi=new WeakMap,Qi=new WeakMap,$i=new WeakMap,R=new WeakMap,ea=new WeakMap,ta=new WeakMap,na=new WeakMap,ra=new WeakMap,ia=new WeakMap,aa=new WeakMap,oa=new WeakMap,sa=new WeakMap,ca=new WeakMap,la=new WeakMap,ua=new WeakMap,da=new WeakMap,fa=new WeakMap,L=new WeakSet,pa=function(){let e=S(this,la,`f`),t=S(this,ea,`f`);return e?.str&&(!t?.str||t.str===e.str)&&S(this,la,`f`).html||null},ma=function(){return S(this,L,`a`,pa)?.attributes?.style?.fontSize||0},ha=function(){return S(this,L,`a`,pa)?.attributes?.style?.color||null},ga=function(e){let t=[],n={str:e,html:{name:`div`,attributes:{dir:`auto`},children:[{name:`p`,children:t}]}},r={style:{color:S(this,L,`a`,ha),fontSize:S(this,L,`a`,ma)?`calc(${S(this,L,`a`,ma)}px * var(--scale-factor))`:``}};for(let n of e.split(`
`))t.push({name:`span`,value:n,attributes:r});return n},_a=function(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key===`Enter`||e.key===`Escape`&&S(this,aa,`f`))&&S(this,L,`m`,ya).call(this)},va=function(){if(S(this,sa,`f`)!==null)return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:r,pageY:i}}}=S(this,ra,`f`),a=!!S(this,ia,`f`),o=a?S(this,ia,`f`):S(this,ca,`f`);for(let e of S(this,na,`f`))if(!o||vt.intersect(e.data.rect,o)!==null){o=e.data.rect,a=!0;break}let s=vt.normalizeRect([o[0],e[3]-o[1]+e[1],o[2],e[3]-o[3]+e[1]]),c=a?o[2]-o[0]+5:0,l=s[0]+c,u=s[1];C(this,sa,[100*(l-r)/t,100*(u-i)/n],`f`);let{style:d}=S(this,R,`f`);d.left=`${S(this,sa,`f`)[0]}%`,d.top=`${S(this,sa,`f`)[1]}%`},ya=function(){C(this,aa,!S(this,aa,`f`),`f`),S(this,aa,`f`)?(S(this,L,`m`,ba).call(this),S(this,R,`f`).addEventListener(`click`,S(this,Qi,`f`)),S(this,R,`f`).addEventListener(`keydown`,S(this,Yi,`f`))):(S(this,L,`m`,xa).call(this),S(this,R,`f`).removeEventListener(`click`,S(this,Qi,`f`)),S(this,R,`f`).removeEventListener(`keydown`,S(this,Yi,`f`)))},ba=function(){S(this,oa,`f`)||this.render(),this.isVisible?S(this,aa,`f`)&&S(this,R,`f`).classList.add(`focused`):(S(this,L,`m`,va).call(this),S(this,R,`f`).hidden=!1,S(this,R,`f`).style.zIndex=(parseInt(S(this,R,`f`).style.zIndex,10)+1e3).toString())},xa=function(){S(this,R,`f`).classList.remove(`focused`),!(S(this,aa,`f`)||!this.isVisible)&&(S(this,R,`f`).hidden=!0,S(this,R,`f`).style.zIndex=(parseInt(S(this,R,`f`).style.zIndex,10)-1e3).toString())};var Va=class extends ja{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=null,this.textPosition=null,this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=y.FREETEXT}render(){if(this.container.classList.add(`k-free-text-annotation`),this.textContent){let e=document.createElement(`div`);e.classList.add(`k-annotation-text-content`),e.setAttribute(`role`,`comment`);for(let t of this.textContent){let n=document.createElement(`span`);n.textContent=t,e.append(n)}this.container.append(e)}return this._editOnDoubleClick(),this.container}},Ha=class extends ja{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.container.classList.add(`k-highlight-annotation`),this.container}},Ua=class{constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,annotationEditorUIManager:r,page:i,viewport:a}){Sa.add(this),this.div=null,this.page=null,this.viewport=null,this.zIndex=null,this._annotationEditorUIManager=null,Ca.set(this,null),wa.set(this,null),Ta.set(this,new Map),this.div=e,C(this,Ca,t,`f`),C(this,wa,n,`f`),this.page=i,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=r}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return S(this,Ta,`f`).size>0}render(e){let{annotations:t}=e,n=this.div;mt(n,this.viewport);let r=new Map,i={data:null,layer:n,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||``,renderForms:e.renderForms!==!1,svgFactory:new gt,annotationStorage:e.annotationStorage||new Ri,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(let e of t){if(e.noHTML)continue;let t=e.annotationType===xn.POPUP;if(t){let t=r.get(e.id);if(!t)continue;i.elements=t}else{let{width:t,height:n}=ka(e.rect);if(t<=0||n<=0)continue}i.data=e;let n=Aa.create(i);if(!n.isRenderable)continue;if(!t&&e.popupRef){let t=r.get(e.popupRef);t?t.push(n):r.set(e.popupRef,[n])}let a=n.render();e.hidden&&(a.style.visibility=`hidden`),S(this,Sa,`m`,Ea).call(this,a,e.id),n._isEditable&&(S(this,Ta,`f`).set(n.data.id,n),this._annotationEditorUIManager?.renderAnnotationElement(n))}S(this,Sa,`m`,Da).call(this)}update({viewport:e}){let t=this.div;this.viewport=e,mt(t,e),S(this,Sa,`m`,Da).call(this),t.hidden=!1}getEditableAnnotations(){return Array.from(S(this,Ta,`f`).values())}getEditableAnnotation(e){return S(this,Ta,`f`).get(e)}destroy(){S(this,wa,`f`)?.clear(),this.div?.remove(),this.div=null}};Ca=new WeakMap,wa=new WeakMap,Ta=new WeakMap,Sa=new WeakSet,Ea=function(e,t){let n=e.firstChild||e;n.id=`${Dn}${t}`,this.div.append(e),S(this,Ca,`f`)?.moveElementInDOM(this.div,e,n,!1)},Da=function(){if(!S(this,wa,`f`))return;let e=this.div;for(let[t,n]of S(this,wa,`f`)){let r=e.querySelector(`[data-annotation-id="${t}"]`);if(!r)continue;n.className=`annotationContent k-annotation-content`;let{firstChild:i}=r;i?i.nodeName===`CANVAS`?i.replaceWith(n):!i.classList.contains(`annotationContent`)||!i.classList.contains(`k-annotation-content`)?i.before(n):i.after(n):r.append(n)}S(this,wa,`f`).clear()};var Wa,Ga,Ka,qa,Ja=class{constructor({pdfPage:e,eventBus:t,linkService:n=null,annotationStorage:r=null,renderForms:i=!0,annotationCanvasMap:a=null,accessibilityManager:o=null,annotationEditorUIManager:s=null,onAppend:c=null}){Wa.add(this),this.annotationLayer=null,this.pdfPage=null,this.linkService=null,this.annotationStorage=null,this._annotationCanvasMap=null,this._annotationEditorUIManager=null,this.div=null,this._cancelled=null,this._eventBus=null,this._accessibilityManager=null,Ga.set(this,null),Ka.set(this,null),this.renderForms=null,this.pdfPage=e,this.linkService=n,this.renderForms=i,this.annotationStorage=r,this._annotationCanvasMap=a,this._accessibilityManager=o,this._annotationEditorUIManager=s,C(this,Ga,c,`f`),this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=n?.eventBus||t}render(e){return x(this,arguments,void 0,function*(e,t=`display`){if(this.div){if(this._cancelled||!this.annotationLayer)return;this.annotationLayer.update({viewport:e.clone({dontFlip:!0})});return}let[n]=yield Promise.all([this.pdfPage.getAnnotations({intent:t})]);if(this._cancelled)return;if(n.length===0){this.hide();return}let r=this.pdfPage._pageInfo?.view,i=(r[2]||0)+`px`,a=(r[3]||0)+`px`,o=De(`<div class="k-annotation-layer" data-main-rotation="0"></div>`);Vt(o,{width:`round(var(--scale-factor) * ${i}, 1px)`,height:`round(var(--scale-factor) * ${a}, 1px)`}),this.div=o,S(this,Ga,`f`)?.call(this,o),this.annotationLayer=new Ua({div:o,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,page:this.pdfPage,viewport:e.clone({dontFlip:!0})}),yield this.annotationLayer.render({annotations:n,renderForms:this.renderForms,linkService:this.linkService,annotationStorage:this.annotationStorage}),this.linkService.isInPresentationMode&&S(this,Wa,`m`,qa).call(this,kr.FULLSCREEN),S(this,Ka,`f`)||(C(this,Ka,new AbortController,`f`),this._eventBus?._on(`presentationmodechanged`,e=>{S(this,Wa,`m`,qa).call(this,e.state)},{signal:S(this,Ka,`f`).signal}))})}cancel(){this._cancelled=!0,S(this,Ka,`f`)?.abort(),C(this,Ka,null,`f`)}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}destroy(){this.cancel(),this.annotationLayer?.destroy(),this.annotationLayer=null,S(this,Ka,`f`)?.abort(),C(this,Ka,null,`f`),this.div?.remove(),this.div=null}};Ga=new WeakMap,Ka=new WeakMap,Wa=new WeakSet,qa=function(e){if(!this.div)return;let t=!1;switch(e){case kr.FULLSCREEN:t=!0;break;case kr.NORMAL:break;default:return}for(let e of this.div.childNodes)e.hasAttribute(`data-internal-link`)||(e.inert=t)};var Ya,z,Xa,Za,B,Qa,$a,eo,to,no=class{constructor({pageIndex:e}){Ya.add(this),this.pageIndex=0,Xa.set(this,null),Za.set(this,0),B.set(this,new Map),Qa.set(this,new Map),this.pageIndex=e}setParent(e){if(!S(this,Xa,`f`)){C(this,Xa,e,`f`);return}if(S(this,Xa,`f`)!==e){if(S(this,B,`f`).size>0)for(let t of S(this,B,`f`).values())t.remove(),e.append(t);C(this,Xa,e,`f`)}}static get _svgFactory(){return ft(this,`_svgFactory`,new gt)}highlight(e,t,n,r=!1){var i,a;let o=(C(this,Za,(a=S(this,Za,`f`),i=a++,a),`f`),i),s=S(this,Ya,`m`,eo).call(this,e.box);s.classList.add(`k-highlight`),e.free;let c=z._svgFactory.createElement(`defs`);s.append(c);let l=z._svgFactory.createElement(`path`);c.append(l);let u=`path_p${this.pageIndex}_${o}`;l.setAttribute(`id`,u),l.setAttribute(`d`,e.toSVGPath()),r&&S(this,Qa,`f`).set(o,l);let d=S(this,Ya,`m`,to).call(this,c,u),f=z._svgFactory.createElement(`use`);return s.append(f),s.setAttribute(`fill`,t),s.setAttribute(`fill-opacity`,n),f.setAttribute(`href`,`#${u}`),S(this,B,`f`).set(o,s),{id:o,clipPathId:`url(#${d})`}}highlightOutline(e){var t,n;let r=(C(this,Za,(n=S(this,Za,`f`),t=n++,n),`f`),t),i=S(this,Ya,`m`,eo).call(this,e.box);i.classList.add(`k-highlight-outline`);let a=z._svgFactory.createElement(`defs`);i.append(a);let o=z._svgFactory.createElement(`path`);a.append(o);let s=`path_p${this.pageIndex}_${r}`;o.setAttribute(`id`,s),o.setAttribute(`d`,e.toSVGPath()),o.setAttribute(`vector-effect`,`non-scaling-stroke`);let c;if(e.free){let e=z._svgFactory.createElement(`mask`);a.append(e),c=`mask_p${this.pageIndex}_${r}`,e.setAttribute(`id`,c),e.setAttribute(`maskUnits`,`objectBoundingBox`);let t=z._svgFactory.createElement(`rect`);e.append(t),t.setAttribute(`width`,`1`),t.setAttribute(`height`,`1`),t.setAttribute(`fill`,`white`);let n=z._svgFactory.createElement(`use`);e.append(n),n.setAttribute(`href`,`#${s}`),n.setAttribute(`stroke`,`none`),n.setAttribute(`fill`,`black`),n.setAttribute(`fill-rule`,`nonzero`)}let l=z._svgFactory.createElement(`use`);i.append(l),l.setAttribute(`href`,`#${s}`),c&&l.setAttribute(`mask`,`url(#${c})`);let u=l.cloneNode();return i.append(u),S(this,B,`f`).set(r,i),r}finalizeLine(e,t){let n=S(this,Qa,`f`).get(e);S(this,Qa,`f`).delete(e),this.updateBox(e,t.box),n.setAttribute(`d`,t.toSVGPath())}updateLine(e,t){S(this,B,`f`).get(e).firstChild.firstChild.setAttribute(`d`,t.toSVGPath())}removeFreeHighlight(e){this.remove(e),S(this,Qa,`f`).delete(e)}updatePath(e,t){S(this,Qa,`f`).get(e).setAttribute(`d`,t.toSVGPath())}updateBox(e,t){S(z,z,`m`,$a).call(z,S(this,B,`f`).get(e),t)}show(e,t){S(this,B,`f`).get(e).classList.toggle(`k-hidden`,!t)}rotate(e,t){S(this,B,`f`).get(e).setAttribute(`data-main-rotation`,t)}changeColor(e,t){S(this,B,`f`).get(e).setAttribute(`fill`,t)}changeOpacity(e,t){S(this,B,`f`).get(e).setAttribute(`fill-opacity`,t)}addClass(e,t){S(this,B,`f`).get(e).classList.add(t)}removeClass(e,t){S(this,B,`f`).get(e).classList.remove(t)}remove(e){S(this,Xa,`f`)!==null&&(S(this,B,`f`).get(e).remove(),S(this,B,`f`).delete(e))}destroy(){C(this,Xa,null,`f`);for(let e of S(this,B,`f`).values())e.remove();S(this,B,`f`).clear()}};z=no,Xa=new WeakMap,Za=new WeakMap,B=new WeakMap,Qa=new WeakMap,Ya=new WeakSet,$a=function(e,{x:t=0,y:n=0,width:r=1,height:i=1}={}){let{style:a}=e;a.top=`${100*n}%`,a.left=`${100*t}%`,a.width=`${100*r-.2}%`,a.height=`${100*i-.2}%`},eo=function(e){let t=z._svgFactory.create(1,1,!0);return S(this,Xa,`f`).append(t),t.setAttribute(`aria-hidden`,!0),S(z,z,`m`,$a).call(z,t,e),t},to=function(e,t){let n=z._svgFactory.createElement(`clipPath`);e.append(n);let r=`clip_${t}`;n.setAttribute(`id`,r),n.setAttribute(`clipPathUnits`,`objectBoundingBox`);let i=z._svgFactory.createElement(`use`);return n.append(i),i.setAttribute(`href`,`#${t}`),r};var ro,io=class{constructor(e){this.pageIndex=null,this._cancelled=null,ro.set(this,null),this.pageIndex=e.pageIndex}render(){return x(this,arguments,void 0,function*(e=`display`){e!==`display`||S(this,ro,`f`)||C(this,ro,new no({pageIndex:this.pageIndex}),`f`)})}cancel(){S(this,ro,`f`)&&(S(this,ro,`f`)?.destroy(),C(this,ro,null,`f`))}setParent(e){S(this,ro,`f`)?.setParent(e)}getDrawLayer(){return S(this,ro,`f`)}destroy(){this.cancel()}};ro=new WeakMap;var V,H,ao,U,oo,so,W,co,lo,uo,fo,po,mo,ho,go,_o,vo;let yo=/\r\n?|\n/g;var bo=class extends P{constructor(e){super(Object.assign(Object.assign({},e),{name:`k-free-text-editor freeTextEditor`})),V.add(this),this.editorDiv=null,this.overlayDiv=null,ao.set(this,void 0),U.set(this,``),oo.set(this,`${this.id}-editor`),so.set(this,null),W.set(this,void 0),co.set(this,null),C(this,ao,e.color||H._defaultColor||P._defaultLineColor,`f`),C(this,W,e.fontSize||H._defaultFontSize,`f`)}static initialize(e,t){P.initialize(e,t,{strings:[`pdfjs-free-text-default-content`]});let n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue(`--freetext-padding`))||2}static updateDefaultParams(e,t){switch(e){case b.FREETEXT_SIZE:H._defaultFontSize=t;break;case b.FREETEXT_COLOR:H._defaultColor=t;break;default:break}}updateParams(e,t){switch(e){case b.FREETEXT_SIZE:S(this,V,`m`,lo).call(this,t);break;case b.FREETEXT_COLOR:S(this,V,`m`,uo).call(this,t);break;default:break}}static get defaultPropertiesToUpdate(){return[[b.FREETEXT_SIZE,H._defaultFontSize],[b.FREETEXT_COLOR,H._defaultColor||P._defaultLineColor]]}get propertiesToUpdate(){return[[b.FREETEXT_SIZE,S(this,W,`f`)],[b.FREETEXT_COLOR,S(this,ao,`f`)]]}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){let e=this.parentScale;return[-H._internalPadding*e,-(H._internalPadding+S(this,W,`f`))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(y.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove(`enabled`),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute(`aria-activedescendant`),C(this,so,new AbortController,`f`);let e=this._uiManager.combinedSignal(S(this,so,`f`));this.editorDiv.addEventListener(`keydown`,this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener(`focus`,this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener(`blur`,this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener(`input`,this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener(`paste`,this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.editorDiv.contentEditable=!1,this.div.setAttribute(`aria-activedescendant`,S(this,oo,`f`)),this._isDraggable=!0,S(this,so,`f`)?.abort(),C(this,so,null,`f`),this.div.focus({preventScroll:!0}),this.isEditing=!1)}focusin(e){this._focusEventsAllowed&&this._uiManager?.getMode()===y.FREETEXT&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){this.width||(this.enableEditMode(),this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||(this.editorDiv?.innerText)?.trim()===``}remove(){this.isEditing=!1,this.parent&&this.parent.setEditingState(!0),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=S(this,U,`f`),t=C(this,U,S(this,V,`m`,fo).call(this).trimEnd(),`f`);if(e===t)return;let n=e=>{if(C(this,U,e,`f`),!e){this.remove();return}S(this,V,`m`,ho).call(this),this._uiManager.rebuild(this),S(this,V,`m`,po).call(this)};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),S(this,V,`m`,po).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){e&&this.enterInEditMode()}keydown(e){e.target===this.div&&e.key===`Enter`&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(){}editorDivFocus(){this.isEditing=!0}editorDivBlur(){this.isEditing=!1}editorDivInput(){}disableEditing(){this.editorDiv.setAttribute(`role`,`comment`),this.editorDiv.removeAttribute(`aria-multiline`)}enableEditing(){this.editorDiv.setAttribute(`role`,`textbox`),this.editorDiv.setAttribute(`aria-multiline`,!0)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement(`div`),this.editorDiv.className=`k-internal internal`,this.editorDiv.setAttribute(`id`,S(this,oo,`f`)),this.editorDiv.setAttribute(`data-l10n-id`,`pdfjs-free-text`),this.enableEditing(),this.editorDiv?.setAttribute(`default-content`,this._uiManager.pdfViewer.options.messages.freeTextEditorPlaceholder),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${S(this,W,`f`)}px * var(--scale-factor))`,n.color=S(this,ao,`f`),this.div.append(this.editorDiv),this.overlayDiv=document.createElement(`div`),this.div.append(this.overlayDiv),ai(this,this.div,[`dblclick`,`keydown`]),this.width){let[n,r]=this.parentDimensions;if(this.annotationElementId){let{position:i}=S(this,co,`f`),[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);let[s,c]=this.pageDimensions,[l,u]=this.pageTranslation,d,f;switch(this.rotation){case 0:d=e+(i[0]-l)/s,f=t+this.height-(i[1]-u)/c;break;case 90:d=e+(i[0]-l)/s,f=t-(i[1]-u)/c,[a,o]=[o,-a];break;case 180:d=e-this.width+(i[0]-l)/s,f=t-(i[1]-u)/c,[a,o]=[-a,-o];break;case 270:d=e+(i[0]-l-this.height*c)/s,f=t+(i[1]-u-this.width*s)/c,[a,o]=[-o,a];break;default:break}this.setAt(d*n,f*r,a,o)}else this.setAt(e*n,t*r,this.width*n,this.height*r);S(this,V,`m`,ho).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){let t=e.clipboardData||window.clipboardData,{types:n}=t;if(n.length===1&&n[0]===`text/plain`)return;e.preventDefault();let r=S(H,H,`m`,_o).call(H,t.getData(`text`)||``).replaceAll(yo,`
`);if(!r)return;let i=window.getSelection();if(!i.rangeCount)return;this.editorDiv.normalize(),i.deleteFromDocument();let a=i.getRangeAt(0);if(!r.includes(`
`)){a.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),i.collapseToStart();return}let{startContainer:o,startOffset:s}=a,c=[],l=[];if(o.nodeType===Node.TEXT_NODE){let e=o.parentElement;if(l.push(o.nodeValue.slice(s).replaceAll(yo,``)),e!==this.editorDiv){let t=c;for(let n of this.editorDiv.childNodes){if(n===e){t=l;continue}t.push(S(H,H,`m`,mo).call(H,n))}}c.push(o.nodeValue.slice(0,s).replaceAll(yo,``))}else if(o===this.editorDiv){let e=c,t=0;for(let n of this.editorDiv.childNodes)t++===s&&(e=l),e.push(S(H,H,`m`,mo).call(H,n))}C(this,U,`${c.join(`
`)}${r}${l.join(`
`)}`,`f`),S(this,V,`m`,ho).call(this);let u=new Range,d=c.reduce((e,t)=>e+t.length,0);for(let{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){let t=e.nodeValue.length;if(d<=t){u.setStart(e,d),u.setEnd(e,d);break}d-=t}i.removeAllRanges(),i.addRange(u)}get contentDiv(){return this.editorDiv}static deserialize(e,t,n){let r=null;if(e instanceof Va){let{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:i,rotation:a,id:o},textContent:s,textPosition:c,parent:{page:{pageNumber:l}}}=e;if(!s||s.length===0)return null;r=e={annotationType:y.FREETEXT,color:Array.from(n),fontSize:t,value:s.join(`
`),position:c,pageIndex:l-1,rect:i.slice(0),rotation:a,id:o,deleted:!1}}let i=super.deserialize(e,t,n);return C(i,W,e.fontSize,`f`),C(i,ao,vt.makeHexColor(...e.color),`f`),C(i,U,S(H,H,`m`,_o).call(H,e.value),`f`),i.annotationElementId=e.id||null,C(i,co,r,`f`),i}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};let t=H._internalPadding*this.parentScale,n=this.getRect(t,t),r=P._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:S(this,ao,`f`)),i={annotationType:y.FREETEXT,color:r,fontSize:S(this,W,`f`),value:S(this,V,`m`,go).call(this),pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?i:this.annotationElementId&&!S(this,V,`m`,vo).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){let t=super.renderAnnotationElement(e);if(this.deleted)return t;let{style:n}=t;n.fontSize=`calc(${S(this,W,`f`)}px * var(--scale-factor))`,n.color=S(this,ao,`f`),t.replaceChildren();for(let e of S(this,U,`f`).split(`
`)){let n=document.createElement(`div`);n.append(e?document.createTextNode(e):document.createElement(`br`)),t.append(n)}let r=H._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(r,r),popupContent:S(this,U,`f`)}),t}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}toJSON(){return this.serialize()}};H=bo,ao=new WeakMap,U=new WeakMap,oo=new WeakMap,so=new WeakMap,W=new WeakMap,co=new WeakMap,V=new WeakSet,lo=function(e){let t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-S(this,W,`f`))*this.parentScale),C(this,W,e,`f`),S(this,V,`m`,po).call(this)},n=S(this,W,`f`);this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:b.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},uo=function(e){let t=e=>{C(this,ao,this.editorDiv.style.color=e,`f`)},n=S(this,ao,`f`);this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:b.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},fo=function(){let e=[];this.editorDiv.normalize();for(let t of this.editorDiv.childNodes)e.push(S(H,H,`m`,mo).call(H,t));return e.join(`
`)},po=function(){let[e,t]=this.parentDimensions,n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{let{currentLayer:e,div:t}=this,r=t.style.display,i=t.classList.contains(`hidden`)||t.classList.contains(`k-hidden`);t.classList.remove(`hidden`),t.classList.remove(`k-hidden`),t.style.display=`hidden`,e.div.append(this.div),n=t.getBoundingClientRect(),t.remove(),t.style.display=r,t.classList.toggle(`k-hidden`,i)}this.rotation%180==this.parentRotation%180?(this.width=n.width/e,this.height=n.height/t):(this.width=n.height/e,this.height=n.width/t),this.fixAndSetPosition()},mo=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(yo,``)},ho=function(){if(this.editorDiv.replaceChildren(),S(this,U,`f`))for(let e of S(this,U,`f`).split(`
`)){let t=document.createElement(`div`);t.append(e?document.createTextNode(e):document.createElement(`br`)),this.editorDiv.append(t)}},go=function(){return S(this,U,`f`).replaceAll(`\xA0`,` `)},_o=function(e){return e.replaceAll(` `,`\xA0`)},vo=function(e){let{value:t,fontSize:n,color:r,pageIndex:i}=S(this,co,`f`);return this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some((e,t)=>e!==r[t])||e.pageIndex!==i},bo._freeTextDefaultContent=``,bo._internalPadding=0,bo._defaultColor=`#000000`,bo._defaultFontSize=10,bo._type=`freetext`,bo._editorType=y.FREETEXT;var xo,So,Co,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro,G,zo,Bo,Vo,Ho,Uo,Wo,Go,Ko,qo,Jo,Yo,Xo,Zo,Qo,$o,es,ts,ns,K,rs,is,as,os=class{constructor(e,t=0,n=0,r=!0){xo.add(this),So.set(this,void 0),Co.set(this,[]),wo.set(this,[]);let i=1/0,a=-1/0,o=1/0,s=-1/0,c=10**-4;for(let{x:n,y:r,width:l,height:u}of e){let e=Math.floor((n-t)/c)*c,d=Math.ceil((n+l+t)/c)*c,f=Math.floor((r-t)/c)*c,p=Math.ceil((r+u+t)/c)*c,m=[e,f,p,!0],h=[d,f,p,!1];S(this,Co,`f`).push(m,h),i=Math.min(i,e),a=Math.max(a,d),o=Math.min(o,f),s=Math.max(s,p)}let l=a-i+2*n,u=s-o+2*n,d=i-n,f=o-n,p=S(this,Co,`f`).at(r?-1:-2),m=[p[0],p[2]];for(let e of S(this,Co,`f`)){let[t,n,r]=e;e[0]=(t-d)/l,e[1]=(n-f)/u,e[2]=(r-f)/u}C(this,So,{x:d,y:f,width:l,height:u,lastPoint:m},`f`)}getOutlines(){S(this,Co,`f`).sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let e=[];for(let t of S(this,Co,`f`))t[3]?(e.push(...S(this,xo,`m`,ko).call(this,t)),S(this,xo,`m`,Do).call(this,t)):(S(this,xo,`m`,Oo).call(this,t),e.push(...S(this,xo,`m`,ko).call(this,t)));return S(this,xo,`m`,To).call(this,e)}};So=new WeakMap,Co=new WeakMap,wo=new WeakMap,xo=new WeakSet,To=function(e){let t=[],n=new Set;for(let n of e){let[e,r,i]=n;t.push([e,r,n],[e,i,n])}t.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,r=t.length;e<r;e+=2){let r=t[e][2],i=t[e+1][2];r.push(i),i.push(r),n.add(r),n.add(i)}let r=[],i;for(;n.size>0;){let e=n.values().next().value,[t,a,o,s,c]=e;n.delete(e);let l=t,u=a;for(i=[t,o],r.push(i);;){let e;if(n.has(s))e=s;else if(n.has(c))e=c;else break;n.delete(e),[t,a,o,s,c]=e,l!==t&&(i.push(l,u,t,u===a?a:o),l=t),u=u===a?o:a}i.push(l,u)}return new cs(r,S(this,So,`f`))},Eo=function(e){let t=S(this,wo,`f`),n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i][0];if(a===e)return i;a<e?n=i+1:r=i-1}return r+1},Do=function([,e,t]){let n=S(this,xo,`m`,Eo).call(this,e);S(this,wo,`f`).splice(n,0,[e,t])},Oo=function([,e,t]){let n=S(this,xo,`m`,Eo).call(this,e);for(let r=n;r<S(this,wo,`f`).length;r++){let[n,i]=S(this,wo,`f`)[r];if(n!==e)break;if(n===e&&i===t){S(this,wo,`f`).splice(r,1);return}}for(let r=n-1;r>=0;r--){let[n,i]=S(this,wo,`f`)[r];if(n!==e)break;if(n===e&&i===t){S(this,wo,`f`).splice(r,1);return}}},ko=function(e){let[t,n,r]=e,i=[[t,n,r]],a=S(this,xo,`m`,Eo).call(this,r);for(let e=0;e<a;e++){let[n,r]=S(this,wo,`f`)[e];for(let e=0,a=i.length;e<a;e++){let[,o,s]=i[e];if(!(r<=o||s<=n)){if(o>=n){if(s>r)i[e][1]=r;else{if(a===1)return[];i.splice(e,1),e--,a--}continue}i[e][2]=n,s>r&&i.push([t,r,s])}}}return i};var ss=class{toSVGPath(){throw Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw Error("Abstract getter `box` must be implemented.")}serialize([e,t,n,r]){}get free(){return this instanceof us}},cs=class extends ss{constructor(e,t){super(),Ao.set(this,void 0),jo.set(this,void 0),C(this,jo,e,`f`),C(this,Ao,t,`f`)}toSVGPath(){let e=[];for(let t of S(this,jo,`f`)){let[n,r]=t;e.push(`M${n} ${r}`);for(let i=2;i<t.length;i+=2){let a=t[i],o=t[i+1];a===n?(e.push(`V${o}`),r=o):o===r&&(e.push(`H${a}`),n=a)}e.push(`Z`)}return e.join(` `)}serialize([e,t,n,r]){let i=[],a=n-e,o=r-t;for(let t of S(this,jo,`f`)){let n=Array(t.length);for(let i=0;i<t.length;i+=2)n[i]=e+t[i]*a,n[i+1]=r-t[i+1]*o;i.push(n)}return i}get box(){return S(this,Ao,`f`)}};Ao=new WeakMap,jo=new WeakMap;var ls=class{constructor({x:e,y:t},n,r,i,a,o=0){Mo.add(this),Po.set(this,void 0),Fo.set(this,[]),Io.set(this,void 0),Lo.set(this,void 0),Ro.set(this,[]),G.set(this,new Float64Array(18)),zo.set(this,void 0),Bo.set(this,void 0),Vo.set(this,void 0),Ho.set(this,void 0),Uo.set(this,void 0),Wo.set(this,void 0),Go.set(this,[]),C(this,Po,n,`f`),C(this,Wo,i*r,`f`),C(this,Lo,a,`f`),S(this,G,`f`).set([NaN,NaN,NaN,NaN,e,t],6),C(this,Io,o,`f`),C(this,Ho,S(No,No,`f`,Ko)*r,`f`),C(this,Vo,S(No,No,`f`,Jo)*r,`f`),C(this,Uo,r,`f`),S(this,Go,`f`).push(e,t)}get free(){return!0}isEmpty(){return isNaN(S(this,G,`f`)[8])}add({x:e,y:t}){C(this,zo,e,`f`),C(this,Bo,t,`f`);let[n,r,i,a]=S(this,Po,`f`),[o,s,c,l]=S(this,G,`f`).subarray(8,12),u=e-c,d=t-l,f=Math.hypot(u,d);if(f<S(this,Vo,`f`))return!1;let p=f-S(this,Ho,`f`),m=p/f,h=m*u,ee=m*d,g=o,te=s;o=c,s=l,c+=h,l+=ee,S(this,Go,`f`)?.push(e,t);let ne=-ee/p,re=h/p,ie=ne*S(this,Wo,`f`),ae=re*S(this,Wo,`f`);return S(this,G,`f`).set(S(this,G,`f`).subarray(2,8),0),S(this,G,`f`).set([c+ie,l+ae],4),S(this,G,`f`).set(S(this,G,`f`).subarray(14,18),12),S(this,G,`f`).set([c-ie,l-ae],16),isNaN(S(this,G,`f`)[6])?(S(this,Ro,`f`).length===0&&(S(this,G,`f`).set([o+ie,s+ae],2),S(this,Ro,`f`).push(NaN,NaN,NaN,NaN,(o+ie-n)/i,(s+ae-r)/a),S(this,G,`f`).set([o-ie,s-ae],14),S(this,Fo,`f`).push(NaN,NaN,NaN,NaN,(o-ie-n)/i,(s-ae-r)/a)),S(this,G,`f`).set([g,te,o,s,c,l],6),!this.isEmpty()):(S(this,G,`f`).set([g,te,o,s,c,l],6),Math.abs(Math.atan2(te-s,g-o)-Math.atan2(ee,h))<Math.PI/2?([o,s,c,l]=S(this,G,`f`).subarray(2,6),S(this,Ro,`f`).push(NaN,NaN,NaN,NaN,((o+c)/2-n)/i,((s+l)/2-r)/a),[o,s,g,te]=S(this,G,`f`).subarray(14,18),S(this,Fo,`f`).push(NaN,NaN,NaN,NaN,((g+o)/2-n)/i,((te+s)/2-r)/a),!0):([g,te,o,s,c,l]=S(this,G,`f`).subarray(0,6),S(this,Ro,`f`).push(((g+5*o)/6-n)/i,((te+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a),[c,l,o,s,g,te]=S(this,G,`f`).subarray(12,18),S(this,Fo,`f`).push(((g+5*o)/6-n)/i,((te+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a),!0))}toSVGPath(){if(this.isEmpty())return``;let e=S(this,Ro,`f`),t=S(this,Fo,`f`),n=S(this,G,`f`).subarray(4,6),r=S(this,G,`f`).subarray(16,18),[i,a,o,s]=S(this,Po,`f`),[c,l,u,d]=S(this,Mo,`m`,Yo).call(this);if(isNaN(S(this,G,`f`)[6])&&!this.isEmpty())return`M${(S(this,G,`f`)[2]-i)/o} ${(S(this,G,`f`)[3]-a)/s} L${(S(this,G,`f`)[4]-i)/o} ${(S(this,G,`f`)[5]-a)/s} L${c} ${l} L${u} ${d} L${(S(this,G,`f`)[16]-i)/o} ${(S(this,G,`f`)[17]-a)/s} L${(S(this,G,`f`)[14]-i)/o} ${(S(this,G,`f`)[15]-a)/s} Z`;let f=[];f.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?f.push(`L${e[t+4]} ${e[t+5]}`):f.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);f.push(`L${(n[0]-i)/o} ${(n[1]-a)/s} L${c} ${l} L${u} ${d} L${(r[0]-i)/o} ${(r[1]-a)/s}`);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?f.push(`L${t[e+4]} ${t[e+5]}`):f.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);return f.push(`L${t[4]} ${t[5]} Z`),f.join(` `)}getOutlines(){let e=S(this,Ro,`f`),t=S(this,Fo,`f`),n=S(this,G,`f`),r=n.subarray(4,6),i=n.subarray(16,18),[a,o,s,c]=S(this,Po,`f`),l=new Float64Array((S(this,Go,`f`)?.length??0)+2);for(let e=0,t=l.length-2;e<t;e+=2)l[e]=(S(this,Go,`f`)[e]-a)/s,l[e+1]=(S(this,Go,`f`)[e+1]-o)/c;l[l.length-2]=(S(this,zo,`f`)-a)/s,l[l.length-1]=(S(this,Bo,`f`)-o)/c;let[u,d,f,p]=S(this,Mo,`m`,Yo).call(this);if(isNaN(n[6])&&!this.isEmpty()){let e=new Float64Array(36);return e.set([NaN,NaN,NaN,NaN,(n[2]-a)/s,(n[3]-o)/c,NaN,NaN,NaN,NaN,(n[4]-a)/s,(n[5]-o)/c,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,f,p,NaN,NaN,NaN,NaN,(n[16]-a)/s,(n[17]-o)/c,NaN,NaN,NaN,NaN,(n[14]-a)/s,(n[15]-o)/c],0),new us(e,l,S(this,Po,`f`),S(this,Uo,`f`),S(this,Io,`f`),S(this,Lo,`f`))}let m=new Float64Array(S(this,Ro,`f`).length+24+S(this,Fo,`f`).length),h=e.length;for(let t=0;t<h;t+=2){if(isNaN(e[t])){m[t]=m[t+1]=NaN;continue}m[t]=e[t],m[t+1]=e[t+1]}m.set([NaN,NaN,NaN,NaN,(r[0]-a)/s,(r[1]-o)/c,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,f,p,NaN,NaN,NaN,NaN,(i[0]-a)/s,(i[1]-o)/c],h),h+=24;for(let e=t.length-6;e>=6;e-=6)for(let n=0;n<6;n+=2){if(isNaN(t[e+n])){m[h]=m[h+1]=NaN,h+=2;continue}m[h]=t[e+n],m[h+1]=t[e+n+1],h+=2}return m.set([NaN,NaN,NaN,NaN,t[4],t[5]],h),new us(m,l,S(this,Po,`f`),S(this,Uo,`f`),S(this,Io,`f`),S(this,Lo,`f`))}};No=ls,Po=new WeakMap,Fo=new WeakMap,Io=new WeakMap,Lo=new WeakMap,Ro=new WeakMap,G=new WeakMap,zo=new WeakMap,Bo=new WeakMap,Vo=new WeakMap,Ho=new WeakMap,Uo=new WeakMap,Wo=new WeakMap,Go=new WeakMap,Mo=new WeakSet,Yo=function(){let e=S(this,G,`f`).subarray(4,6),t=S(this,G,`f`).subarray(16,18),[n,r,i,a]=S(this,Po,`f`);return[(S(this,zo,`f`)+(e[0]-t[0])/2-n)/i,(S(this,Bo,`f`)+(e[1]-t[1])/2-r)/a,(S(this,zo,`f`)+(t[0]-e[0])/2-n)/i,(S(this,Bo,`f`)+(t[1]-e[1])/2-r)/a]},Ko={value:8},qo={value:2},Jo={value:S(No,No,`f`,Ko)+S(No,No,`f`,qo)};var us=class extends ss{constructor(e,t,n,r,i,a){super(),Xo.add(this),Zo.set(this,void 0),Qo.set(this,null),$o.set(this,void 0),es.set(this,void 0),ts.set(this,void 0),ns.set(this,void 0),K.set(this,void 0),C(this,K,e,`f`),C(this,ts,t,`f`),C(this,Zo,n,`f`),C(this,ns,r,`f`),C(this,$o,i,`f`),C(this,es,a,`f`),S(this,Xo,`m`,as).call(this,a);let{x:o,y:s,width:c,height:l}=S(this,Qo,`f`);for(let t=0,n=e.length;t<n;t+=2)e[t]=(e[t]-o)/c,e[t+1]=(e[t+1]-s)/l;for(let e=0,n=t.length;e<n;e+=2)t[e]=(t[e]-o)/c,t[e+1]=(t[e+1]-s)/l}toSVGPath(){let e=[`M${S(this,K,`f`)[4]} ${S(this,K,`f`)[5]}`];for(let t=6,n=S(this,K,`f`).length;t<n;t+=6){if(isNaN(S(this,K,`f`)[t])){e.push(`L${S(this,K,`f`)[t+4]} ${S(this,K,`f`)[t+5]}`);continue}e.push(`C${S(this,K,`f`)[t]} ${S(this,K,`f`)[t+1]} ${S(this,K,`f`)[t+2]} ${S(this,K,`f`)[t+3]} ${S(this,K,`f`)[t+4]} ${S(this,K,`f`)[t+5]}`)}return e.push(`Z`),e.join(` `)}serialize([e,t,n,r],i){let a=n-e,o=r-t,s,c;switch(i){case 0:s=S(this,Xo,`m`,rs).call(this,S(this,K,`f`),e,r,a,-o),c=S(this,Xo,`m`,rs).call(this,S(this,ts,`f`),e,r,a,-o);break;case 90:s=S(this,Xo,`m`,is).call(this,S(this,K,`f`),e,t,a,o),c=S(this,Xo,`m`,is).call(this,S(this,ts,`f`),e,t,a,o);break;case 180:s=S(this,Xo,`m`,rs).call(this,S(this,K,`f`),n,t,-a,o),c=S(this,Xo,`m`,rs).call(this,S(this,ts,`f`),n,t,-a,o);break;case 270:s=S(this,Xo,`m`,is).call(this,S(this,K,`f`),n,r,-a,-o),c=S(this,Xo,`m`,is).call(this,S(this,ts,`f`),n,r,-a,-o);break;default:break}return{outline:Array.from(s),points:[Array.from(c)]}}get box(){return S(this,Qo,`f`)}getNewOutline(e,t){let{x:n,y:r,width:i,height:a}=S(this,Qo,`f`),[o,s,c,l]=S(this,Zo,`f`),u=i*c,d=a*l,f=n*c+o,p=r*l+s,m=new ls({x:S(this,ts,`f`)[0]*u+f,y:S(this,ts,`f`)[1]*d+p},S(this,Zo,`f`),S(this,ns,`f`),e,S(this,es,`f`),t??S(this,$o,`f`));for(let e=2;e<S(this,ts,`f`).length;e+=2)m.add({x:S(this,ts,`f`)[e]*u+f,y:S(this,ts,`f`)[e+1]*d+p});return m.getOutlines()}};Zo=new WeakMap,Qo=new WeakMap,$o=new WeakMap,es=new WeakMap,ts=new WeakMap,ns=new WeakMap,K=new WeakMap,Xo=new WeakSet,rs=function(e,t,n,r,i){let a=new Float64Array(e.length);for(let o=0,s=e.length;o<s;o+=2)a[o]=t+e[o]*r,a[o+1]=n+e[o+1]*i;return a},is=function(e,t,n,r,i){let a=new Float64Array(e.length);for(let o=0,s=e.length;o<s;o+=2)a[o]=t+e[o+1]*r,a[o+1]=n+e[o]*i;return a},as=function(e){let t=S(this,K,`f`),n=t[4],r=t[5],i=n,a=r,o=n,s=r,c=n,l=r,u=e?Math.max:Math.min;for(let e=6,d=t.length;e<d;e+=6){if(isNaN(t[e]))i=Math.min(i,t[e+4]),a=Math.min(a,t[e+5]),o=Math.max(o,t[e+4]),s=Math.max(s,t[e+5]),l<t[e+5]?(c=t[e+4],l=t[e+5]):l===t[e+5]&&(c=u(c,t[e+4]));else{let d=vt.bezierBoundingBox(n,r,...t.slice(e,e+6));i=Math.min(i,d[0]),a=Math.min(a,d[1]),o=Math.max(o,d[2]),s=Math.max(s,d[3]),l<d[3]?(c=d[2],l=d[3]):l===d[3]&&(c=u(c,d[2]))}n=t[e+4],r=t[e+5]}let d=i-S(this,$o,`f`),f=a-S(this,$o,`f`),p=o-i+2*S(this,$o,`f`),m=s-a+2*S(this,$o,`f`);C(this,Qo,{x:d,y:f,width:p,height:m,lastPoint:[c,l]},`f`)};var q,J,ds,fs,ps,ms,hs,gs,_s,vs,ys,Y,bs,xs,Ss,X,Cs,ws,Ts,Es,Ds,Os,ks,As,js,Ms,Ns,Ps,Fs,Is,Ls,Rs,zs,Bs=class extends P{constructor(e){super(Object.assign(Object.assign({},e),{name:`k-highlight-editor`})),q.add(this),this.color=``,ds.set(this,null),fs.set(this,0),ps.set(this,void 0),ms.set(this,null),hs.set(this,null),gs.set(this,null),_s.set(this,0),vs.set(this,null),ys.set(this,null),Y.set(this,null),bs.set(this,!1),xs.set(this,null),Ss.set(this,void 0),X.set(this,null),Cs.set(this,``),ws.set(this,void 0),Ts.set(this,``),this.color=e.color||J._defaultColor,C(this,ws,e.thickness||J._defaultThickness,`f`),C(this,Ss,e.opacity||J._defaultOpacity,`f`),C(this,ps,e.boxes||null,`f`),C(this,Ts,e.methodOfCreation||``,`f`),C(this,Cs,e.text||``,`f`),this._isDraggable=!1,e.highlightId>-1?(C(this,bs,!0,`f`),S(this,q,`m`,Ds).call(this,e),S(this,q,`m`,js).call(this)):(C(this,ds,e.anchorNode,`f`),C(this,fs,e.anchorOffset,`f`),C(this,gs,e.focusNode,`f`),C(this,_s,e.focusOffset,`f`),S(this,q,`m`,Es).call(this),S(this,q,`m`,js).call(this),this.rotate(this.rotation))}get telemetryInitialData(){return{action:`added`,type:S(this,bs,`f`)?`free_highlight`:`highlight`,color:this._uiManager.highlightColorNames.get(this.color),thickness:S(this,ws,`f`),methodOfCreation:S(this,Ts,`f`)}}get telemetryFinalData(){return{type:`highlight`,color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get(`color`).size}}static initialize(e,t){P.initialize(e,t,{}),J._defaultColor||=t.viewer?.options?.annotations?.highlight?.color||`#ffff00`}static updateDefaultParams(e,t){switch(e){case b.HIGHLIGHT_COLOR:J._defaultColor=t;break;case b.HIGHLIGHT_THICKNESS:J._defaultThickness=t;break;default:break}}translateInPage(){}get toolbarPosition(){return S(this,xs,`f`)}updateParams(e,t){switch(e){case b.HIGHLIGHT_COLOR:S(this,q,`m`,Os).call(this,t);break;case b.HIGHLIGHT_THICKNESS:S(this,q,`m`,ks).call(this,t);break;default:break}}static get defaultPropertiesToUpdate(){return[[b.HIGHLIGHT_COLOR,J._defaultColor],[b.HIGHLIGHT_THICKNESS,J._defaultThickness]]}get propertiesToUpdate(){return[[b.HIGHLIGHT_COLOR,this.color||J._defaultColor],[b.HIGHLIGHT_THICKNESS,S(this,ws,`f`)||J._defaultThickness],[b.HIGHLIGHT_FREE,S(this,bs,`f`)]]}disableEditing(){super.disableEditing(),this.div.classList.toggle(`k-highlight-editor-disabled`,!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle(`k-highlight-editor-disabled`,!1)}fixAndSetPosition(){return super.fixAndSetPosition(S(this,q,`m`,Fs).call(this))}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,S(this,q,`m`,Fs).call(this))}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){S(this,q,`m`,As).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(S(this,q,`m`,js).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?S(this,q,`m`,As).call(this):e&&(S(this,q,`m`,js).call(this,e),t=!this.parent&&(this.div?.classList.contains(`selectedEditor`)||this.div?.classList.contains(`k-selected`))),super.setParent(e),this.show(this._isVisible),t&&this.select()}rotate(e){let{drawLayer:t}=this.parent,n;S(this,bs,`f`)?(e=(e-this.rotation+360)%360,n=S(J,J,`m`,Ms).call(J,S(this,ys,`f`).box,e)):n=S(J,J,`m`,Ms).call(J,this,e),t.rotate(S(this,Y,`f`),e),t.rotate(S(this,X,`f`),e),t.updateBox(S(this,Y,`f`),n),t.updateBox(S(this,X,`f`),S(J,J,`m`,Ms).call(J,S(this,hs,`f`).box,e))}render(){if(this.div)return this.div;let e=super.render();S(this,Cs,`f`)&&(e.setAttribute(`aria-label`,S(this,Cs,`f`)),e.setAttribute(`role`,`mark`)),S(this,bs,`f`)?e.classList.add(`free`):this.div.addEventListener(`keydown`,S(this,q,`m`,Ns).bind(this),{signal:this._uiManager._signal});let t=C(this,vs,document.createElement(`div`),`f`);e.append(t),t.setAttribute(`aria-hidden`,`true`),t.className=`k-internal internal`,t.style.clipPath=S(this,ms,`f`);let[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),ai(this,S(this,vs,`f`),[`pointerover`,`pointerleave`]),this.enableEditing(),e}pointerover(){this.parent.drawLayer.addClass(S(this,X,`f`),`hovered`)}pointerleave(){this.parent.drawLayer.removeClass(S(this,X,`f`),`hovered`)}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:S(this,q,`m`,Ps).call(this,!0);break;case 1:case 3:S(this,q,`m`,Ps).call(this,!1);break;default:break}}select(){super.select(),S(this,X,`f`)&&(this.parent?.drawLayer.removeClass(S(this,X,`f`),`hovered`),this.parent?.drawLayer.addClass(S(this,X,`f`),`selected`),this.parent?.drawLayer.addClass(S(this,X,`f`),`k-selected`))}unselect(){super.unselect(),S(this,X,`f`)&&(this.parent?.drawLayer.removeClass(S(this,X,`f`),`selected`),this.parent?.drawLayer.removeClass(S(this,X,`f`),`k-selected`),S(this,bs,`f`)||S(this,q,`m`,Ps).call(this,!1))}get _mustFixPosition(){return!S(this,bs,`f`)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(S(this,Y,`f`),e),this.parent.drawLayer.show(S(this,X,`f`),e))}static startHighlighting(e,t,{target:n,x:r,y:i}){let{x:a,y:o,width:s,height:c}=n.getBoundingClientRect(),l=new AbortController,u=e.combinedSignal(l),d=e=>{e.preventDefault(),e.stopPropagation()},f=t=>{l.abort(),S(this,J,`m`,zs).call(this,e,t)};window.addEventListener(`blur`,f,{signal:u}),window.addEventListener(`pointerup`,f,{signal:u}),window.addEventListener(`pointerdown`,d,{capture:!0,passive:!1,signal:u}),window.addEventListener(`contextmenu`,Tt,{signal:u}),n.addEventListener(`pointermove`,S(this,J,`m`,Rs).bind(this,e),{signal:u}),this._freeHighlight=new ls({x:r,y:i},[a,o,s,c],e.scale,this._defaultThickness/2,t,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static deserialize(e,t,n){let r=super.deserialize(e,t,n),{rect:[i,a,o,s],color:c,quadPoints:l}=e;r.color=vt.makeHexColor(...c),C(r,Ss,e.opacity,`f`);let[u,d]=r.pageDimensions;r.width=(o-i)/u,r.height=(s-a)/d;let f=C(r,ps,[],`f`);for(let e=0;e<l.length;e+=8)f.push({x:(l[4]-o)/u,y:(s-(1-l[e+5]))/d,width:(l[e+2]-l[e])/u,height:(l[e+5]-l[e+1])/d});return S(r,q,`m`,Es).call(r),r}serialize(e=!1){if(this.isEmpty()||e)return null;let t=this.getRect(0,0),n=P._colorManager.convert(this.color);return{annotationType:y.HIGHLIGHT,color:n,opacity:S(this,Ss,`f`),thickness:S(this,ws,`f`),quadPoints:S(this,q,`m`,Is).call(this),outlines:S(this,q,`m`,Ls).call(this,t),pageIndex:this.pageIndex,rect:t,rotation:S(this,q,`m`,Fs).call(this),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}toJSON(){return this.serialize()}};J=Bs,ds=new WeakMap,fs=new WeakMap,ps=new WeakMap,ms=new WeakMap,hs=new WeakMap,gs=new WeakMap,_s=new WeakMap,vs=new WeakMap,ys=new WeakMap,Y=new WeakMap,bs=new WeakMap,xs=new WeakMap,Ss=new WeakMap,X=new WeakMap,Cs=new WeakMap,ws=new WeakMap,Ts=new WeakMap,q=new WeakSet,Es=function(){let e=new os(S(this,ps,`f`),.001);C(this,ys,e.getOutlines(),`f`),{x:this.x,y:this.y,width:this.width,height:this.height}=S(this,ys,`f`).box;let t=new os(S(this,ps,`f`),.0025,.001,this._uiManager.direction===`ltr`);C(this,hs,t.getOutlines(),`f`);let{lastPoint:n}=S(this,hs,`f`).box;C(this,xs,[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height],`f`)},Ds=function({highlightOutlines:e,highlightId:t,clipPathId:n}){if(C(this,ys,e,`f`),C(this,hs,e.getNewOutline(S(this,ws,`f`)/2+1.5,.0025),`f`),t>=0)C(this,Y,t,`f`),C(this,ms,n,`f`),this.parent.drawLayer.finalizeLine(t,e),C(this,X,this.parent.drawLayer.highlightOutline(S(this,hs,`f`)),`f`);else if(this.parent){let t=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(S(this,Y,`f`),e),this.parent.drawLayer.updateBox(S(this,Y,`f`),S(J,J,`m`,Ms).call(J,S(this,ys,`f`).box,(t-this.rotation+360)%360)),this.parent.drawLayer.updateLine(S(this,X,`f`),S(this,hs,`f`)),this.parent.drawLayer.updateBox(S(this,X,`f`),S(J,J,`m`,Ms).call(J,S(this,hs,`f`).box,t))}let{x:r,y:i,width:a,height:o}=e.box;switch(this.rotation){case 0:this.x=r,this.y=i,this.width=a,this.height=o;break;case 90:{let[e,t]=this.parentDimensions;this.x=i,this.y=1-r,this.width=a*t/e,this.height=o*e/t;break}case 180:this.x=1-r,this.y=1-i,this.width=a,this.height=o;break;case 270:{let[e,t]=this.parentDimensions;this.x=1-i,this.y=r,this.width=a*t/e,this.height=o*e/t;break}default:break}let{lastPoint:s}=S(this,hs,`f`).box;C(this,xs,[(s[0]-r)/a,(s[1]-i)/o],`f`)},Os=function(e){if(!e)return;let t=e=>{this.color=e,this.parent?.drawLayer.changeColor(S(this,Y,`f`),e)},n=this.color;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:b.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},ks=function(e){},As=function(){S(this,Y,`f`)===null||!this.parent||(this.parent.drawLayer.remove(S(this,Y,`f`)),C(this,Y,null,`f`),this.parent.drawLayer.remove(S(this,X,`f`)),C(this,X,null,`f`))},js=function(e=this.parent){var t,n;S(this,Y,`f`)===null&&(t=this,n=this,{id:{set value(e){C(t,Y,e,`f`)}}.value,clipPathId:{set value(e){C(n,ms,e,`f`)}}.value}=e.drawLayer.highlight(S(this,ys,`f`),this.color,S(this,Ss,`f`)),C(this,X,e.drawLayer.highlightOutline(S(this,hs,`f`)),`f`),S(this,vs,`f`)&&(S(this,vs,`f`).style.clipPath=S(this,ms,`f`)))},Ms=function({x:e,y:t,width:n,height:r},i){switch(i){case 90:return{x:1-t-r,y:e,width:r,height:n};case 180:return{x:1-e-n,y:1-t-r,width:n,height:r};case 270:return{x:t,y:1-e-n,width:r,height:n};default:break}return{x:e,y:t,width:n,height:r}},Ns=function(e){},Ps=function(e){if(!S(this,ds,`f`))return;let t=window.getSelection();e?t.setPosition(S(this,ds,`f`),S(this,fs,`f`)):t.setPosition(S(this,gs,`f`),S(this,_s,`f`))},Fs=function(){return S(this,bs,`f`)?this.rotation:0},Is=function(){if(S(this,bs,`f`))return null;let[e,t]=this.pageDimensions,[n,r]=this.pageTranslation,i=S(this,ps,`f`),a=new Float32Array(i.length*8),o=0;for(let{x:s,y:c,width:l,height:u}of i){let i=s*e+n,d=(1-c-u)*t+r;a[o]=a[o+4]=i,a[o+1]=a[o+3]=d,a[o+2]=a[o+6]=i+l*e,a[o+5]=a[o+7]=d+u*t,o+=8}return a},Ls=function(e){return S(this,ys,`f`).serialize(e,S(this,q,`m`,Fs).call(this))},Rs=function(e,t){this._freeHighlight.add(t)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},zs=function(e,t){this._freeHighlight.isEmpty()?e.drawLayer.removeFreeHighlight(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:`main_toolbar`}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=``},Bs._defaultColor=null,Bs._defaultOpacity=1,Bs._defaultThickness=12,Bs._type=`highlight`,Bs._editorType=y.HIGHLIGHT,Bs._freeHighlightId=-1,Bs._freeHighlight=null,Bs._freeHighlightClipId=``;var Vs,Z,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs,Q,$s,ec,tc,nc,rc,ic,ac=class{constructor({uiManager:e,pageIndex:t,div:n,accessibilityManager:r,annotationLayer:i,drawLayer:a,textLayer:o,viewport:s}){Vs.add(this),this.drawLayer=null,this.pageIndex=0,this.div=null,this.viewport=null,Hs.set(this,void 0),Us.set(this,!1),Ws.set(this,null),Gs.set(this,null),Ks.set(this,null),qs.set(this,new Map),Js.set(this,!1),Ys.set(this,!1),Xs.set(this,!1),Zs.set(this,null),Qs.set(this,null),Q.set(this,null);let c=[...S(Z,Z,`f`,$s).values()];if(!Z._initialized){Z._initialized=!0;for(let t of c)t.initialize({},e)}e.registerEditorTypes(c),C(this,Q,e,`f`),this.pageIndex=t,this.div=n,C(this,Hs,r,`f`),C(this,Ws,i,`f`),this.viewport=s,C(this,Zs,o,`f`),this.drawLayer=a,S(this,Q,`f`).addLayer(this)}hide(){this.div&&(this.div.hidden=!0)}show(){!this.div||this.isInvisible||(this.div.hidden=!1)}get isEmpty(){return S(this,qs,`f`).size===0}get isInvisible(){return this.isEmpty&&S(this,Q,`f`).getMode()===y.NONE}updateToolbar(){}updateMode(e=S(this,Q,`f`).getMode()){switch(S(this,Vs,`m`,ic).call(this),e){case y.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case y.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case y.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:t}=this.div;for(let n of S(Z,Z,`f`,$s).values())t.toggle(`${n._type}Editing`,e===n._editorType);this.div.hidden=!1}hasTextLayer(e){return e===S(this,Zs,`f`)?.div}addInkEditorIfNeeded(e){if(S(this,Q,`f`).getMode()===y.INK){if(!e){for(let e of S(this,qs,`f`).values())if(e.isEmpty()){e.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(e){S(this,Q,`f`).setEditingState(e)}addCommands(e){S(this,Q,`f`).addCommands(e)}toggleDrawing(e=!1){this.div.classList.toggle(`drawing`,!e)}togglePointerEvents(e=!1){this.div.classList.toggle(`k-annotation-editor-layer-disabled`,!e)}toggleAnnotationLayerPointerEvents(e=!1){S(this,Ws,`f`)?.div.classList.toggle(`k-annotation-editor-layer-disabled`,!e)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);let e=new Set;for(let t of S(this,qs,`f`).values())t.enableEditing(),t.show(!0),t.annotationElementId&&(S(this,Q,`f`).removeChangedExistingAnnotation(t),e.add(t.annotationElementId));if(!S(this,Ws,`f`))return;let t=S(this,Ws,`f`).getEditableAnnotations();for(let n of t){if(n.hide(),S(this,Q,`f`).isDeletedAnnotationElement(n.data.id)||e.has(n.data.id))continue;let t=this.deserialize(n);t&&(this.addOrRebuild(t),t.enableEditing())}}disable(){C(this,Xs,!0,`f`),this.div.tabIndex=-1,this.togglePointerEvents(!1);let e=new Map,t=new Map;for(let n of S(this,qs,`f`).values())if(n.disableEditing(),n.annotationElementId){if(n.serialize()!==null){e.set(n.annotationElementId,n);continue}else t.set(n.annotationElementId,n);this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()}if(S(this,Ws,`f`)){let n=S(this,Ws,`f`).getEditableAnnotations();for(let r of n){let{id:n}=r.data;if(S(this,Q,`f`).isDeletedAnnotationElement(n))continue;let i=t.get(n);if(i){i.resetAnnotationElement(r),i.show(!1),r.show();continue}i=e.get(n),i&&(S(this,Q,`f`).addChangedExistingAnnotation(i),i.renderAnnotationElement(r),i.show(!1)),r.show()}}S(this,Vs,`m`,ic).call(this),this.isEmpty&&(this.div.hidden=!0);let{classList:n}=this.div;for(let e of S(Z,Z,`f`,$s).values())n.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),C(this,Xs,!1,`f`)}getEditableAnnotation(e){return S(this,Ws,`f`)?.getEditableAnnotation(e)||null}setActiveEditor(e){S(this,Q,`f`).getActive()!==e&&S(this,Q,`f`).setActiveEditor(e)}enableTextSelection(){if(this.div.tabIndex=-1,S(this,Zs,`f`)?.div&&!S(this,Qs,`f`)){C(this,Qs,new AbortController,`f`);let e=S(this,Q,`f`).combinedSignal(S(this,Qs,`f`));S(this,Zs,`f`).div.addEventListener(`pointerdown`,S(this,Vs,`m`,ec).bind(this),{signal:e})}}disableTextSelection(){this.div.tabIndex=0,S(this,Zs,`f`)?.div&&S(this,Qs,`f`)&&(S(this,Qs,`f`).abort(),C(this,Qs,null,`f`),S(this,Zs,`f`).div.classList.remove(`highlighting`))}enableClick(){if(S(this,Gs,`f`))return;C(this,Gs,new AbortController,`f`);let e=S(this,Q,`f`).combinedSignal(S(this,Gs,`f`));this.div.addEventListener(`pointerdown`,this.pointerdown.bind(this),{signal:e}),this.div.addEventListener(`pointerup`,this.pointerup.bind(this),{signal:e})}disableClick(){S(this,Gs,`f`)?.abort(),C(this,Gs,null,`f`)}attach(e){S(this,qs,`f`).set(e.id,e);let{annotationElementId:t}=e;t&&S(this,Q,`f`).isDeletedAnnotationElement(t)&&S(this,Q,`f`).removeDeletedAnnotationElement(e)}detach(e){S(this,qs,`f`).delete(e.id),S(this,Hs,`f`)?.removePointerInTextLayer(e.contentDiv),!S(this,Xs,`f`)&&e.annotationElementId&&S(this,Q,`f`).addDeletedAnnotationElement(e)}remove(e){this.detach(e),S(this,Q,`f`).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1,S(this,Ys,`f`)||this.addInkEditorIfNeeded(!1)}changeParent(e){e.parent!==this&&(e.parent&&e.annotationElementId&&(S(this,Q,`f`).addDeletedAnnotationElement(e.annotationElementId),P.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),e.parent?.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(!(e.parent===this&&e.isAttachedToDOM)){if(this.changeParent(e),S(this,Q,`f`).addEditor(e),this.attach(e),!e.isAttachedToDOM){let t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(),S(this,Q,`f`).addToAnnotationStorage(e)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;let{activeElement:t}=document;e.div.contains(t)&&!S(this,Ks,`f`)&&(e._focusEventsAllowed=!1,C(this,Ks,setTimeout(()=>{C(this,Ks,null,`f`),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:S(this,Q,`f`)._signal}),t.focus())},0),`f`)),e._structTreeParentId=S(this,Hs,`f`)?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||=this,e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getNextId(){return S(this,Q,`f`).getId()}combinedSignal(e){return S(this,Q,`f`).combinedSignal(e)}canCreateNewEmptyEditor(){return S(this,Vs,`a`,tc)?.canCreateNewEmptyEditor()}pasteEditor(e,t){S(this,Q,`f`).updateToolbar(e),S(this,Q,`f`).updateMode(e);let{offsetX:n,offsetY:r}=S(this,Vs,`m`,rc).call(this),i=this.getNextId(),a=S(this,Vs,`m`,nc).call(this,Object.assign({parent:this,id:i,x:n,y:r,uiManager:S(this,Q,`f`),isCentered:!0},t));a&&this.add(a)}deserialize(e){return S(Z,Z,`f`,$s).get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,S(this,Q,`f`))||null}createAndAddNewEditor(e,t,n={}){let r=this.getNextId(),i=S(this,Vs,`m`,nc).call(this,Object.assign({parent:this,id:r,x:e.offsetX,y:e.offsetY,uiManager:S(this,Q,`f`),isCentered:t},n));return i&&this.add(i),i}addNewEditor(){this.createAndAddNewEditor(S(this,Vs,`m`,rc).call(this),!0)}setSelected(e){S(this,Q,`f`).setSelected(e)}toggleSelected(e){S(this,Q,`f`).toggleSelected(e)}isSelected(e){return S(this,Q,`f`).isSelected(e)}unselect(e){S(this,Q,`f`).unselect(e)}pointerup(e){let{isMac:t}=pt.platform;if(!(e.button!==0||e.ctrlKey&&t)&&e.target===this.div&&S(this,Js,`f`)){if(C(this,Js,!1,`f`),!S(this,Us,`f`)){C(this,Us,!0,`f`);return}if(S(this,Q,`f`).getMode()===y.STAMP){S(this,Q,`f`).unselectAll();return}this.createAndAddNewEditor(e,!1)}}pointerdown(e){if(S(this,Q,`f`).getMode()===y.HIGHLIGHT&&this.enableTextSelection(),S(this,Js,`f`)){C(this,Js,!1,`f`);return}let{isMac:t}=pt.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div)return;C(this,Js,!0,`f`);let n=S(this,Q,`f`).getActive();C(this,Us,!n||n.isEmpty(),`f`)}findNewParent(e,t,n){let r=S(this,Q,`f`).findParent(t,n);return r===null||r===this?!1:(r.changeParent(e),!0)}destroy(){S(this,Q,`f`).getActive()?.parent===this&&(S(this,Q,`f`).commitOrRemove(),S(this,Q,`f`).setActiveEditor(null)),S(this,Ks,`f`)&&(clearTimeout(S(this,Ks,`f`)),C(this,Ks,null,`f`));for(let e of S(this,qs,`f`).values())S(this,Hs,`f`)?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,S(this,qs,`f`).clear(),S(this,Q,`f`).removeLayer(this)}render({viewport:e}){this.viewport=e,mt(this.div,e);for(let e of S(this,Q,`f`).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:e}){S(this,Q,`f`).commitOrRemove(),S(this,Vs,`m`,ic).call(this);let t=this.viewport.rotation,n=e.rotation;if(this.viewport=e,mt(this.div,e),t!==n)for(let e of S(this,qs,`f`).values())e.rotate(n);this.addInkEditorIfNeeded(!1)}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return S(this,Q,`f`).viewParameters.realScale}};Z=ac,Hs=new WeakMap,Us=new WeakMap,Ws=new WeakMap,Gs=new WeakMap,Ks=new WeakMap,qs=new WeakMap,Js=new WeakMap,Ys=new WeakMap,Xs=new WeakMap,Zs=new WeakMap,Qs=new WeakMap,Q=new WeakMap,Vs=new WeakSet,ec=function(e){S(this,Q,`f`).unselectAll();let{target:t}=e;if(t===S(this,Zs,`f`).div||t.classList.contains(`endOfContent`)&&S(this,Zs,`f`).div.contains(t)){let{isMac:t}=pt.platform;if(e.button!==0||e.ctrlKey&&t||(S(this,Q,`f`).showAllEditors(`highlight`,!0),S(this,Q,`f`).getMode()===y.NONE))return;S(this,Zs,`f`).div.addEventListener(`pointerup`,()=>{S(this,Zs,`f`).div.classList.remove(`free`),this.toggleDrawing(!0)},{once:!0,signal:S(this,Q,`f`)._signal}),e.preventDefault()}},tc=function(){return S(Z,Z,`f`,$s).get(S(this,Q,`f`).getMode())},nc=function(e){let t=S(this,Vs,`a`,tc);return t?new t(e):null},rc=function(){let{x:e,y:t,width:n,height:r}=this.div.getBoundingClientRect(),i=Math.max(0,e),a=Math.max(0,t),o=Math.min(window.innerWidth,e+n),s=Math.min(window.innerHeight,t+r),c=(i+o)/2-e,l=(a+s)/2-t,[u,d]=this.viewport.rotation%180==0?[c,l]:[l,c];return{offsetX:u,offsetY:d}},ic=function(){C(this,Ys,!0,`f`);for(let e of S(this,qs,`f`).values())e.isEmpty()&&e.remove();C(this,Ys,!1,`f`)},ac._initialized=!1,$s={value:new Map([bo,Bs].map(e=>[e._editorType,e]))};var oc,sc,cc,lc,uc,dc=class{constructor(e){this.pdfPage=null,this.annotationEditorLayer=null,this._cancelled=null,this.div=null,this.accessibilityManager=null,oc.set(this,null),sc.set(this,null),cc.set(this,null),lc.set(this,null),uc.set(this,null),this.pdfPage=e.pdfPage,this.accessibilityManager=e.accessibilityManager,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,C(this,uc,e.uiManager,`f`),C(this,oc,e.annotationLayer||null,`f`),C(this,lc,e.textLayer||null,`f`),C(this,sc,e.drawLayer||null,`f`),C(this,cc,e.onAppend||null,`f`)}render(e){return x(this,arguments,void 0,function*(e,t=`display`){if(t!==`display`||this._cancelled)return;let n=e.clone({dontFlip:!0});if(this.div){this.annotationEditorLayer.update({viewport:n}),this.show();return}let r=this.div=document.createElement(`div`);r.className=`k-annotation-editor-layer`,r.hidden=!0,r.dir=S(this,uc,`f`).direction,S(this,cc,`f`)?.call(this,r),this.annotationEditorLayer=new ac({uiManager:S(this,uc,`f`),div:r,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,viewport:n,annotationLayer:S(this,oc,`f`),textLayer:S(this,lc,`f`),drawLayer:S(this,sc,`f`)});let i={viewport:n,div:r,annotations:null,intent:t};this.annotationEditorLayer.render(i),this.show()})}cancel(){this._cancelled=!0,this.div&&this.annotationEditorLayer?.destroy()}hide(){this.div&&(this.div.hidden=!0)}show(){!this.div||this.annotationEditorLayer.isInvisible||(this.div.hidden=!1)}destroy(){this.annotationEditorLayer?.destroy()}};oc=new WeakMap,sc=new WeakMap,cc=new WeakMap,lc=new WeakMap,uc=new WeakMap;var $,fc,pc,mc,hc,gc,_c,vc,yc,bc,xc,Sc,Cc,wc,Tc,Ec,Dc;let Oc={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return null}},kc=new Map([[`canvasWrapper`,0],[`textLayer`,1],[`annotationLayer`,2],[`annotationEditorLayer`,3],[`xfaLayer`,3]]);var Ac=class extends je{constructor(e,t){super(e,t),$.add(this),this.eventBus=null,this.zoomLayer=null,this.div=null,this.viewport=null,this.id=1,this._accessibilityManager=null,this._annotationCanvasMap=new Map,this.renderTask=null,this.pdfPageRotate=null,this.rotation=null,this.scale=null,this.pdfViewer=null,this.xfaLayer=null,fc.set(this,xt.ENABLE),pc.set(this,!1),mc.set(this,null),hc.set(this,null),gc.set(this,Or.INITIAL),_c.set(this,Ar.ENABLE),vc.set(this,new WeakMap),yc.set(this,[null,null,null,null]),this.textLayer=null,this.textLayerBuilder=null,this.textAccessibilityManager=null,this.annotationLayer=null,this.drawLayer=null,this.annotationEditorLayer=null,this.options={},this.state={},this.pdfPage=null,this.extendOptions(t),this.div=e,this.viewport=this.options.viewport,this.id=this.options.id||this.options.number||1,C(this,mc,t.layerProperties||Oc,`f`),this.eventBus=t.eventBus,this.initScale(),this.pdfViewer=t.pdfViewer,this.pdfPage=t.pdfPage,C(this,fc,this.pdfViewer.getAnnotationMode(),`f`),this.resetState()}destroy(){this.destroyTextLayer(),this.canvas&&=(this.canvas.width=0,this.canvas.height=0,this.canvas.remove(),null),this.canvasForPrint&&=(this.canvasForPrint.width=0,this.canvasForPrint.height=0,this.canvasForPrint.remove(),null),this.drawLayer?.destroy(),this.annotationLayer?.destroy(),this.annotationEditorLayer?.destroy(),this.div?.remove(),this.div=null,this.pdfViewer=null,this.pdfPage?.cleanup(),this.pdfPage=null}get isEditing(){return S(this,pc,`f`)}get rawWidth(){return this.viewport?.rawDims?.pageWidth}get rawHeight(){return this.viewport?.rawDims?.pageHeight}setState(e){this.state=ye(this.state||{},e)}resetState(){this.setState({})}initScale(){this.scale=this.options.zoomLevel||this.options.scale||1}createPromise(){return Ae()}getViewport(e={scale:1}){return this.pdfPage?this.pdfPage.getViewport(e):{width:0,height:0}}destroyTextLayer(){this.textLayer?.cancel(),this.textLayer?.destroy(),this.removeTextLayer(),this.textLayer=null}removeTextLayer(){this.textLayer&&this.textLayer.div?.parentNode&&this.textLayer.div?.parentNode.removeChild(this.textLayer.div)}getPrintContentAsync(){let e=this.canvasForPrint,t=this.createPromise(),n=new Image,r=e.height/this.pdfViewer.getPrintScale()*this.pdfViewer.getPdfToCssUnits(),i=e.width/this.pdfViewer.getPrintScale()*this.pdfViewer.getPdfToCssUnits();return n.src=e.toDataURL(),n.width=i,n.height=r,n.onload=()=>{t.resolve(n)},t}loadForPrintAsync({zoomLevel:e=1.25,force:t=!1}){let n=this,r=this.createPromise(),i=this.pdfViewer.state.zoomLevel;if(this.pdfPage&&i===e&&!t)return r.resolve(n);if(this.pdfPage&&i&&(i!==e||t))return this.renderForPrintAsync().then(()=>{this.setState({isPrintingInProgress:!1}),r.resolve(n)}),r;let a=Math.max(0,this.pdfPage._pageIndex);return this.pdfViewer.state.pdfDocument.getPage(a+1).then(()=>{this.renderForPrintAsync().then(()=>{this.setState({isPrintingInProgress:!1}),r.resolve(n)})}),r}renderForPrintAsync(){let e=this.pdfViewer.getPrintUnits(),{canvasContext:t,canvas:n,viewport:r}=this.pdfViewer.createPageElements({pdfPage:this.pdfPage,printUnits:e});this.canvasForPrint=n,this.setState({isPrintingInProgress:!0});let i=this.pdfViewer.state.pdfDocument.getOptionalContentConfig({intent:`print`}),a={canvasContext:t,viewport:r,intent:`print`,annotationMode:xt.ENABLE_STORAGE,optionalContentConfigPromise:i,printAnnotationStorage:this.pdfViewer?.annotationStorage?.print};return this.pdfPage.render(a).promise}isBlank(){return this.element&&this.element.getAttribute(`data-blank`)}setBlank(e){this.element&&(e?this.element.setAttribute(`data-blank`,`true`):this.element.removeAttribute(`data-blank`))}get renderingState(){return S(this,gc,`f`)}setPdfPage(e){this.pdfPage=e,this.pdfPageRotate=e.rotate;let t=(this.rotation+this.pdfPageRotate)%360;this.viewport=e.getViewport({scale:this.scale*ht.PDF_TO_CSS_UNITS,rotation:t}),S(this,$,`m`,xc).call(this),this.reset()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}_resetZoomLayer(e=!1){if(!this.zoomLayer)return;let t=this.zoomLayer.firstChild;S(this,vc,`f`).delete(t),t.width=0,t.height=0,e&&this.zoomLayer.remove(),this.zoomLayer=null}reset({keepZoomLayer:e=!1,keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:n=!1,keepXfaLayer:r=!1,keepTextLayer:i=!1}={}){let a=this.div;if(!a)return;let o=a.childNodes,s=e&&this.zoomLayer||null,c=t&&this.annotationLayer?.div||null,l=n&&this.annotationEditorLayer?.div||null,u=r&&this.xfaLayer?.div||null,d=i&&this.textLayer?.div||null;for(let e=o.length-1;e>=0;e--){let t=o[e];switch(t){case s:case c:case l:case u:case d:continue;default:break}t.remove();let n=S(this,yc,`f`).indexOf(t);n>=0&&(S(this,yc,`f`)[n]=null)}a.removeAttribute(`data-loaded`),c&&this.annotationLayer?.hide(),l&&this.annotationEditorLayer?.hide(),u&&this.xfaLayer?.hide(),d&&this.textLayer?.hide(),s||(this.canvas&&(S(this,vc,`f`).delete(this.canvas),this.canvas.width=0,this.canvas.height=0,delete this.canvas),this._resetZoomLayer())}toggleEditingMode(e){this.hasEditableAnnotations()&&(C(this,pc,e,`f`),this.reset({keepZoomLayer:!0,keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0}))}draw(){return x(this,void 0,void 0,function*(){let{canvasContext:e,canvas:t,canvasWrapper:n,viewport:r,pageElement:i,styles:a}=this.pdfViewer.createPageElements({pdfPage:this.pdfPage,zoom:this.pdfViewer.options.zoomLevel||1});this.isBlank()?(this.element.replaceWith(i),this.element=this.div=i,this.canvas=t):(this.element=this.div=this.element||this.div||i,this.canvas=this.canvas||t),this.options.styles=a,n.appendChild(t),this.element.appendChild(n),S(this,$,`m`,bc).call(this,n,`canvasWrapper`);let{div:o,pdfPage:s}=this;if(!this.textLayer&&S(this,_c,`f`)!==Ar.DISABLE&&!s.isPureXfa&&(this._accessibilityManager||=new Ur,this.textLayer=new Qr({styles:this.options.styles,pdfPage:s,accessibilityManager:this._accessibilityManager,onAppend:e=>{S(this,$,`m`,bc).call(this,e,`textLayer`)}})),!this.annotationLayer&&S(this,fc,`f`)!==xt.DISABLE){let{annotationStorage:e,annotationEditorUIManager:t,linkService:n}=S(this,mc,`f`);this._annotationCanvasMap||=new Map,this.annotationLayer=new Ja({pdfPage:s,eventBus:this.eventBus||this.pdfViewer.eventBus,annotationStorage:e,renderForms:S(this,fc,`f`)===xt.ENABLE_FORMS,linkService:n,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:t,onAppend:e=>{S(this,$,`m`,bc).call(this,e,`annotationLayer`)}})}S(this,vc,`f`).set(t,r);let c={canvasContext:e,viewport:r,canvas:t,annotationMode:S(this,fc,`f`),annotationCanvasMap:this._annotationCanvasMap,isEditing:S(this,pc,`f`)},l=this.renderTask=s.render(c),u=l.promise.then(()=>x(this,void 0,void 0,function*(){yield S(this,$,`m`,Dc).call(this,l),yield S(this,$,`m`,Ec).call(this),this.annotationLayer&&(yield S(this,$,`m`,Cc).call(this));let{annotationEditorUIManager:e}=S(this,mc,`f`);e&&(this.drawLayer||=new io({pageIndex:this.id}),yield S(this,$,`m`,Tc).call(this),this.drawLayer.setParent(n),this.annotationEditorLayer||=new dc({uiManager:e,pdfPage:s,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:e=>{S(this,$,`m`,bc).call(this,e,`annotationEditorLayer`)}}),S(this,$,`m`,wc).call(this))}),e=>{});return s.isPureXfa,o.setAttribute(`data-loaded`,!0),this.eventBus.dispatch(`pagerender`,{source:this,pageNumber:this.id}),u})}};fc=new WeakMap,pc=new WeakMap,mc=new WeakMap,hc=new WeakMap,gc=new WeakMap,_c=new WeakMap,vc=new WeakMap,yc=new WeakMap,$=new WeakSet,bc=function(e,t){let n=kc.get(t),r=S(this,yc,`f`)[n];if(S(this,yc,`f`)[n]=e,r){r.replaceWith(e);return}for(let t=n-1;t>=0;t--){let n=S(this,yc,`f`)[t];if(n){n.after(e);return}}this.div.prepend(e)},xc=function(){let{viewport:e}=this;if(this.pdfPage){if(S(this,hc,`f`)===e.rotation)return;C(this,hc,e.rotation,`f`)}!this.div||!e||mt(this.div,e,!0,!1)},Sc=function(e,t){this.eventBus.dispatch(e,{source:this,pageNumber:this.id,error:t})},Cc=function(){return x(this,void 0,void 0,function*(){let e=null;try{yield this.annotationLayer.render(this.viewport,`display`)}catch(t){console.error(`#renderAnnotationLayer: "${t}".`),e=t}finally{S(this,$,`m`,Sc).call(this,`annotationlayerrendered`,e)}})},wc=function(){return x(this,void 0,void 0,function*(){let e=null;try{yield this.annotationEditorLayer.render(this.viewport)}catch(t){e=t}finally{S(this,$,`m`,Sc).call(this,`annotationeditorlayerrendered`,e)}})},Tc=function(){return x(this,void 0,void 0,function*(){try{yield this.drawLayer.render(`display`)}catch{}})},Ec=function(){return x(this,void 0,void 0,function*(){if(!this.textLayer)return;let e=null;try{yield this.textLayer.render(this.viewport)}catch(t){if(t instanceof St)return;e=t}S(this,$,`m`,Sc).call(this,`textlayerrendered`,e)})},Dc=function(e){return x(this,void 0,void 0,function*(){e===this.renderTask&&(this.renderTask=null),this._resetZoomLayer(!0),this.eventBus.dispatch(`pagerendered`,{source:this,pageNumber:this.id,cssTransform:!1,timestamp:performance.now(),error:`page render error`})})};var jc,Mc;let Nc={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};var Pc=class{constructor({eventBus:e=null,externalLinkTarget:t=null,externalLinkRel:n=null,ignoreDestinationZoom:r=!1}={}){this.eventBus=null,this.externalLinkTarget=null,this.externalLinkRel=null,this._ignoreDestinationZoom=null,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null,this.externalLinkEnabled=!0,this.eventBus=e,this.externalLinkTarget=t,this.externalLinkRel=n,this._ignoreDestinationZoom=r,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null}setDocument(e,t=null){this.baseUrl=t,this.pdfDocument=e}setViewer(e){this.pdfViewer=e}setHistory(e){this.pdfHistory=e}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return this.pdfDocument?this.pdfViewer.currentPageNumber:1}set page(e){this.pdfDocument&&(this.pdfViewer.currentPageNumber=e)}get rotation(){return this.pdfDocument?this.pdfViewer.pagesRotation:0}set rotation(e){this.pdfDocument&&(this.pdfViewer.pagesRotation=e)}get isInPresentationMode(){return this.pdfDocument?this.pdfViewer.isInPresentationMode:!1}goToDestination(e){return x(this,void 0,void 0,function*(){if(!this.pdfDocument)return;let t,n,r;if(typeof e==`string`?(t=e,n=yield this.pdfDocument.getDestination(e)):(t=null,n=yield e),!Array.isArray(n))return;let[i]=n;if(i&&typeof i==`object`){if(r=this.pdfDocument.cachedPageNumber(i),!r)try{r=(yield this.pdfDocument.getPageIndex(i))+1}catch{console.error(`goToDestination: "${i}" is not a valid page reference, for dest="${e}".`);return}}else Number.isInteger(i)&&(r=i+1);if(!r||r<1||r>this.pagesCount){console.error(`goToDestination: "${r}" is not a valid page number, for dest="${e}".`);return}this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:t,explicitDest:n,pageNumber:r})),this.pdfViewer.scrollPageIntoView({pageNumber:r,destArray:n,ignoreDestinationZoom:this._ignoreDestinationZoom})})}goToPage(e){if(!this.pdfDocument)return;let t=typeof e==`string`&&this.pdfViewer.pageLabelToPageNumber(e)||e|0;if(!(Number.isInteger(t)&&t>0&&t<=this.pagesCount)){console.error(`PDFLinkService.goToPage: "${e}" is not a valid page.`);return}this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.pushPage(t)),this.pdfViewer.scrollPageIntoView({pageNumber:t})}addLinkAttributes(e,t,n=!1){if(!t||typeof t!=`string`)throw Error(`A valid "url" parameter must provided.`);let r=n?Nc.BLANK:this.externalLinkTarget,i=this.externalLinkRel;this.externalLinkEnabled?e.href=e.title=t:(e.href=``,e.title=`Disabled: ${t}`,e.onclick=()=>!1);let a=``;switch(r){case Nc.NONE:break;case Nc.SELF:a=`_self`;break;case Nc.BLANK:a=`_blank`;break;case Nc.PARENT:a=`_parent`;break;case Nc.TOP:a=`_top`;break;default:break}e.target=a,e.rel=typeof i==`string`?i:`noopener noreferrer nofollow`}getDestinationHash(e){if(typeof e==`string`){if(e.length>0)return this.getAnchorUrl(`#`+escape(e))}else if(Array.isArray(e)){let t=JSON.stringify(e);if(t.length>0)return this.getAnchorUrl(`#`+escape(t))}return this.getAnchorUrl(``)}getAnchorUrl(e){return this.baseUrl?this.baseUrl+e:e}setHash(e){if(!this.pdfDocument)return;let t,n;if(e.includes(`=`)){let r=Nr(e);if(r.has(`search`)){let e=r.get(`search`).replaceAll(`"`,``),t=r.get(`phrase`)===`true`;this.eventBus.dispatch(`findfromurlhash`,{source:this,query:t?e:e.match(/\S+/g)})}if(r.has(`page`)&&(t=r.get(`page`)|0||1),r.has(`zoom`)){let e=r.get(`zoom`).split(`,`),t=e[0],i=parseFloat(t);t.includes(`Fit`)?t===`Fit`||t===`FitB`?n=[null,{name:t}]:t===`FitH`||t===`FitBH`||t===`FitV`||t===`FitBV`?n=[null,{name:t},e.length>1?e[1]|0:null]:t===`FitR`?e.length===5?n=[null,{name:t},e[1]|0,e[2]|0,e[3]|0,e[4]|0]:console.error(`PDFLinkService.setHash: Not enough parameters for "FitR".`):console.error(`PDFLinkService.setHash: "${t}" is not a valid zoom value.`):n=[null,{name:`XYZ`},e.length>1?e[1]|0:null,e.length>2?e[2]|0:null,i?i/100:t]}n?this.pdfViewer.scrollPageIntoView({pageNumber:t||this.page,destArray:n,allowNegativeOffset:!0}):t&&(this.page=t),r.has(`pagemode`)&&this.eventBus.dispatch(`pagemode`,{source:this,mode:r.get(`pagemode`)}),r.has(`nameddest`)&&this.goToDestination(r.get(`nameddest`));return}n=unescape(e);try{n=JSON.parse(n),Array.isArray(n)||(n=n.toString())}catch(e){if(!e)return}(typeof n==`string`||S(jc,jc,`m`,Mc).call(jc,n))&&this.goToDestination(n)}executeNamedAction(e){if(this.pdfDocument){switch(e){case`GoBack`:this.pdfHistory?.back();break;case`GoForward`:this.pdfHistory?.forward();break;case`NextPage`:this.pdfViewer.nextPage();break;case`PrevPage`:this.pdfViewer.previousPage();break;case`LastPage`:this.page=this.pagesCount;break;case`FirstPage`:this.page=1;break;default:break}this.eventBus.dispatch(`namedaction`,{source:this,action:e})}}executeSetOCGState(e){return x(this,void 0,void 0,function*(){if(!this.pdfDocument)return;let t=this.pdfDocument,n=yield this.pdfViewer.optionalContentConfigPromise;t===this.pdfDocument&&(n.setOCGState(e),this.pdfViewer.optionalContentConfigPromise=Promise.resolve(n))})}};jc=Pc,Mc=function(e){if(!Array.isArray(e)||e.length<2)return!1;let[t,n,...r]=e;if(!(typeof t==`object`&&Number.isInteger(t?.num)&&Number.isInteger(t?.gen))&&!Number.isInteger(t)||typeof n!=`object`||typeof n?.name!=`string`)return!1;let i=r.length,a=!0;switch(n.name){case`XYZ`:if(i<2||i>3)return!1;break;case`Fit`:case`FitB`:return i===0;case`FitH`:case`FitBH`:case`FitV`:case`FitBV`:if(i>1)return!1;break;case`FitR`:if(i!==4)return!1;a=!1;break;default:return!1}for(let e of r)if(!(typeof e==`number`||a&&e===null))return!1;return!0};var Fc;(function(e){e[e.TextSelection=0]=`TextSelection`,e[e.Pan=1]=`Pan`})(Fc||={});var Ic,Lc,Rc,zc,Bc,Vc,Hc,Uc;let Wc=`error`,Gc=`zoomStart`,Kc=`zoomEnd`,qc=`pageRendered`,Jc=`pagesLoad`,Yc=`printEnd`,Xc=`scroll`,Zc=`annotationEditorToolBarShow`,Qc=`annotationEditorToolBarHide`,$c=1.25;var el=class extends je{constructor(e,t){super(e,t),Ic.add(this),this.options={pdfServiceType:`pdfjs`,pdfjsSetHiddenCanvasStyles:!0,fileData:[],page:1,fileDescriptor:null,downloadFileName:`Document`,minZoom:.5,maxZoom:4,zoomRate:.25,zoomLevel:$c,pinchToZoom:!0,zoomBeforePrint:!1,zoomLevelForPrint:3,renderForms:!1,searchMatchScrollLeftOffset:0,searchMatchScrollTopOffset:-64,pageChangeScrollThreshold:.85,pageWheelThrottleDelay:200,printScale:3,renderScale:3,loadOnDemand:!1,loadOnDemandPageSize:2,messages:{freeTextEditorPlaceholder:`Start typing`,errorMessages:{parseError:`PDF file fails to process.`,notFound:`File is not found.`,popupBlocked:`Popup is blocked.`}},annotations:{highlight:{color:`#ffff00`}},elementSelectors:{pageSelector:`k-page:not(.k-blank-page)`,blankPageSelector:`k-page.k-blank-page`,anyPageSelector:`k-page`,pagesContainerClass:`k-pdf-viewer-pages`,pageCanvasWrapper:`k-canvas-wrapper`,documentContainerClass:`k-pdf-viewer-canvas`,textLayerClass:`k-text-layer`,searchHighlightClass:`k-search-highlight`,searchHighlightMarkClass:`k-search-highlight-mark`,charClass:`k-text-char`,textElementSelector:`span[role='presentation']`,renderedPageSelector:`k-page[data-page-number]`,enabledTextSelectionClass:`k-enable-text-select`,enabledPanningClass:`k-enable-panning`},events:{[qc]:Ee,[Jc]:Ee,[Yc]:Ee,[Gc]:Ee,[Kc]:Ee,[Wc]:Ee,[Xc]:Ee,[Zc]:Ee,[Qc]:Ee}},this.interactionMode=Fc.TextSelection,this.printContainer=null,this._scrollMode=jr.PAGE,this.isInPresentationMode=!1,this._currentPageNumber=1,this.linkService=null,this.annotationStorage=null,this._annotationStorageModified=!1,this._hasAnnotationEditors=!1,Lc.set(this,y.NONE),this.annotationEditorUIManager=null,Rc.set(this,null),zc.set(this,vn.ENABLE),Bc.set(this,null),Vc.set(this,null),this.state={},this.pdfDocument=null,this.pages=[],this._isCtrlKeyDown=!1,this._isPinching=!1,this._touchInfo=null,this._wheelUnusedFactor=1,this._touchUnusedFactor=1,this._pendingPinchFactor=1,this._pinchAC=null,this.triggerError=e=>{this.trigger(Wc,{error:e})},this.triggerPrintEnd=e=>{this.trigger(Yc,e)},this.onPagesLoad=e=>{this.state.pdfDocument=e.pdfDoc,this.state.pdfPages=e.pdfPages,this.clearSearch(),this.initSearchService(),this.enableDocumentScrollEventsTracking(),this.triggerPagesLoad(e)},this.onDocumentScrollerScroll=e=>{let t=this.getCurrentPageIndex(),n=this.pages,r=n[t],i=n[t+1],a=n[t-1];r&&r.isBlank()&&this.drawPageAsync({pageIndex:t}),i&&i.isBlank()&&this.drawPageAsync({pageIndex:t+1}),a&&a.isBlank()&&this.drawPageAsync({pageIndex:t-1}),this.tryTriggerScroll(e)},this.tryTriggerScroll=e=>{let t=!1,n=this.getCurrentPageIndex()+1;n!==this.state.activePageNumber&&n>=1&&n<=this.state.pdfDocument.numPages&&(t=!0,this.state.activePageNumber=n),this.shouldPreventScroll?this.shouldPreventScroll=!1:this.trigger(Xc,{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop,pageNumber:this.state.activePageNumber,isPageChanged:t})},this.printDocumentAsync=()=>{this.initPrintContainer();let e=this.getPagesPrintContentAsync(this.printContainer),t=Ae();return Promise.all(e).then(()=>{setTimeout(()=>{this.openPrintDialog(),t.resolve()},16.666666666666668)}),t},this.onDocumentWheel=e=>{if(!e.ctrlKey&&!e.metaKey)return;if(e.preventDefault(),e.stopPropagation(),this.options.pinchToZoom&&this._isTrackpadPinch(e)){let t=Math.exp(-e.deltaY/100),n=this._accumulateFactor(this.state.zoomLevel,t,`_wheelUnusedFactor`);if(n===1)return;let r=this.state.zoomLevel*n;this.triggerZoomStart({zoomLevel:r}),this.zoom({zoomLevel:r}),this.triggerZoomEnd({zoomLevel:r});return}let t=ke(e)<0?1:-1,n=this.state.zoomLevel+t*this.options.zoomRate;this.triggerZoomStart({zoomLevel:n}),this.zoom({zoomLevel:n}),this.triggerZoomEnd({zoomLevel:n})},this._onKeyDown=e=>{e.key===`Control`&&(this._isCtrlKeyDown=!0)},this._onKeyUp=e=>{e.key===`Control`&&(this._isCtrlKeyDown=!1)},this._onGestureEvent=e=>{e.preventDefault()},this._onTouchStart=e=>{if(!this.options.pinchToZoom||e.touches.length!==2)return;e.preventDefault();let t=e.touches[0],n=e.touches[1];this._touchInfo={touch0X:t.screenX,touch0Y:t.screenY,touch1X:n.screenX,touch1Y:n.screenY},this._pendingPinchFactor=1,this._touchUnusedFactor=1;let r=this.getDocumentContainer();if(!r)return;let i=this._pinchAC?.signal;r.addEventListener(`touchmove`,this._onTouchMove,{passive:!1,signal:i}),r.addEventListener(`touchend`,this._onTouchEnd,{signal:i}),r.addEventListener(`touchcancel`,this._onTouchEnd,{signal:i})},this._onTouchMove=e=>{if(!this._touchInfo||e.touches.length!==2)return;e.preventDefault(),e.stopPropagation();let t=e.touches[0],n=e.touches[1],r=this._touchInfo.touch1X-this._touchInfo.touch0X,i=this._touchInfo.touch1Y-this._touchInfo.touch0Y,a=n.screenX-t.screenX,o=n.screenY-t.screenY,s=Math.hypot(r,i)||1,c=Math.hypot(a,o)||1;Math.abs(s-c)<=this._minTouchDistanceToPinch||(this._isPinching||(this._isPinching=!0,this.disableScrollerEventsTracking(),this.triggerZoomStart({zoomLevel:this.state.zoomLevel})),this._applyPinchTransform(s,c),this._touchInfo={touch0X:t.screenX,touch0Y:t.screenY,touch1X:n.screenX,touch1Y:n.screenY})},this._onTouchEnd=e=>{if(e.touches.length>=2)return;let t=this.getDocumentContainer();if(t&&(t.removeEventListener(`touchmove`,this._onTouchMove),t.removeEventListener(`touchend`,this._onTouchEnd),t.removeEventListener(`touchcancel`,this._onTouchEnd)),this._isPinching){this._clearPinchTransform();let e=gn(this.state.zoomLevel*this._pendingPinchFactor,this.options.minZoom,this.options.maxZoom);this.zoom({zoomLevel:e}),this.triggerZoomEnd({zoomLevel:e}),this.enableScrollerEventsTracking()}this._resetPinchState()},Kt(e),this.extendOptions(t),this.throwIfInvalidOptions(),this.wrapper=this.element,this.initEventBus(),C(this,Bc,new AbortController,`f`),this.options.renderForms&&C(this,zc,vn.ENABLE_FORMS,`f`),this.resetState(),this.bindEvents(),this.initLinkService(),this.initDocumentContainer(),this.setHiddenCanvasStyles(),this.loadFile(this.options.fileDescriptor||{data:this.options.fileData,page:this.options.page})}destroy(){this.destroyEventBus(),this.unbindEvents(),this.clearDocument(),this.destroySearchService(),this.destroyAnnotationEditorUIManager(),this.destroyDocumentScroller(),Ut(),qt(this.element)}throwIfInvalidOptions(){if(this.options.minZoom>this.options.maxZoom)throw Error(`The min zoom should be greater than max zoom`)}set annotationEditorParams({type:e,value:t}){this.annotationEditorUIManager&&this.annotationEditorUIManager.updateParams(e,t)}get annotationEditorMode(){return this.annotationEditorUIManager?S(this,Lc,`f`):y.DISABLE}set annotationEditorMode({mode:e,editId:t=null,isFromKeyboard:n=!1}){if(this.annotationEditorUIManager,S(this,Lc,`f`)===e||!this.isValidAnnotationEditorMode(e)||!this.pdfDocument)return;y.STAMP;let{eventBus:r}=this,i=()=>{this.cleanupSwitchAnnotationEditorMode(),C(this,Lc,e,`f`),this.annotationEditorUIManager.updateMode(e,t,n),r.dispatch(`annotationeditormodechanged`,{source:this,mode:e})};if(e===y.NONE||S(this,Lc,`f`)===y.NONE){let t=e!==y.NONE;t||this.pdfDocument.annotationStorage.resetModifiedIds();for(let e of this.pages)e.toggleEditingMode(t);let n=S(this,Ic,`m`,Hc).call(this);if(t&&n){this.cleanupSwitchAnnotationEditorMode(),C(this,Vc,({pageNumber:e})=>{n.delete(e),n.size===0&&C(this,Rc,setTimeout(i,0),`f`)},`f`);let{signal:e}=S(this,Bc,`f`);r._on(`pagerendered`,S(this,Vc,`f`),{signal:e})}}i()}getAnnotationMode(){return S(this,zc,`f`)}getPrintUnits(){return this.getPrintScale()}getPdfToCssUnits(){return ht.PDF_TO_CSS_UNITS}getPrintScale(){return this.getPrintResolution()/ht.PDF}getPrintResolution(){return 100*this.options.printScale}getRenderScale(){return sn(this.options.renderScale)}extendOptions(e){this.options=ye(this.options,e)}setOptions(e){this.options=e}bindEvents(){this.bindPagesWheel(),this.bindPinchToZoomEvents()}bindPagesWheel(){let e=this.getDocumentContainer();e&&(this.options.pageWheelThrottleDelay>0?this.throttledPagesWheel=Me(this.onDocumentWheel,this.options.pageWheelThrottleDelay):this.throttledPagesWheel=this.onDocumentWheel,e.addEventListener(`wheel`,this.throttledPagesWheel))}unbindEvents(){this.unbindPagesWheel(),this.unbindPinchToZoomEvents()}unbindPagesWheel(){let e=this.getDocumentContainer();e&&(this.throttledPagesWheel&&this.throttledPagesWheel.cancel&&this.throttledPagesWheel.cancel(),e.removeEventListener(`wheel`,this.throttledPagesWheel))}setState(e){this.state=ye(this.state||{},e)}resetState(){this.setState({activePageNumber:1,visiblePagesCount:1,pagePromises:[],downloadFilePromise:null,pdfDocument:null,zoomLevel:this.options.zoomLevel,zoomLevelType:this.options.zoomLevelType,zoomLevelBeforePrint:null})}initEventBus(){this.eventBus=new Dr}destroyEventBus(){}initLinkService(){this.linkService=new Pc({eventBus:this.eventBus,externalLinkTarget:Nc.BLANK,externalLinkRel:`noopener noreferrer nofollow`,ignoreDestinationZoom:!1}),this.linkService?.setViewer(this)}initAnnotationEditorUIManager(){this.annotationEditorUIManager=new Tr({container:this.getDocumentContainer(),viewer:this.element,pdfViewer:this,pdfDocument:this.state.pdfDocument,eventBus:this.eventBus}),this.setAnnotationEditorUIManagerScale()}setAnnotationEditorUIManagerScale(){this.annotationEditorUIManager?.onScaleChanging({scale:this.options.zoomLevel})}destroyAnnotationEditorUIManager(){this.annotationEditorUIManager?.destroy(),this.annotationEditorUIManager=null}bindEventBusAnnotationsEvents(){let e=this.eventBus=this.eventBus||new Dr;e._on(`switchannotationeditorparams`,e=>{this.annotationEditorParams=e}),e._on(`switchannotationeditormode`,t=>{this.annotationEditorUIManager.updateParams(t.type,t.value);let{mode:n,editId:r,isFromKeyboard:i}=t;this.annotationEditorUIManager.annotationEditorMode=t,this.annotationEditorUIManager.updateMode(n,r,i),e.dispatch(`annotationeditormodechanged`,{source:this,mode:n})}),e._on(`kendoAnnotationEditorToolBarShow`,e=>{if(!e)return;let t=this.annotationEditorUIManager.getMode();(t===y.HIGHLIGHT||t===y.FREETEXT)&&(t===y.HIGHLIGHT&&this.addHighlightAnnotation(),this.triggerAnnotationEditorToolBarShow(Object.assign(Object.assign({},e),{annotationEditorMode:t===y.HIGHLIGHT?`highlight`:`freeText`,anchor:e.anchor||this.annotationEditorUIManager.firstSelectedEditor?.div})))}),e._on(`kendoAnnotationEditorToolBarHide`,e=>{if(!e)return;let t=this.annotationEditorUIManager.getMode();(t===y.HIGHLIGHT||t===y.FREETEXT)&&this.triggerAnnotationEditorToolBarHide(Object.assign(Object.assign({},e),{annotationEditorMode:t===y.HIGHLIGHT?`highlight`:`freeText`}))}),e._on(`showannotationeditorui`,t=>{switch(t.mode){case y.HIGHLIGHT:e.dispatch(`switchannotationeditormode`,{source:this,mode:y.HIGHLIGHT,isFromKeyboard:!1});break;default:break}})}unbindEventBusAnnotationsEvents(){}loadFile(e){let t=e.data,n={data:null,url:``,arrayBuffer:null,typedArray:null};if(t&&(t.buffer instanceof ArrayBuffer||t instanceof ArrayBuffer)?n.arrayBuffer=t.buffer||t:xe(t)&&t!==``?(n.data=t,n.url=null):xe(e.url)&&e.url!==``?(n.data=null,n.url=e.url):e.typedArray&&(n.typedArray=e.typedArray),e.data||e.url||e.arrayBuffer||e.typedArray){let e=Object.assign({dom:this.getPagesContainer(),zoom:this.options.zoomLevel},n);this.disableDocumentScrollEventsTracking(),this.clearDocument(),this.initEventBus(),C(this,Bc,new AbortController,`f`),this.bindEvents(),this.initLinkService(),this.initDocumentContainer(),this.loadDocument(e)}}loadDocument(e){let t=this.getDocumentParameters(e),{zoom:n}=e;this.clearDocumentState(),bt(t).promise.then(e=>{this.linkService?.setDocument(e),this.initDocumentAnnotationStorage(e),this.initAnnotationEditorUIManager(),this.bindEventBusAnnotationsEvents();let t=[];for(let n=1;n<=e.numPages;n++)t.push(e.getPage(n));return{pagesPromises:t,pdfDoc:e}}).then(({pagesPromises:e,pdfDoc:t})=>(this.state.pagesPromises=e,this.destroyPageComponents(),this.drawPagesFromPromisesAsync(e).then(e=>{this.onPagesLoad({pdfPages:e,pdfDoc:t,zoom:n})}).catch(e=>{this.triggerError(e)}))).catch(e=>{this.triggerError(e)}).finally(()=>{this.setScaleFactor(this.options.zoomLevel),this.linkService?.setDocument(this.pdfDocument)})}initDocumentAnnotationStorage(e){this.state.pdfDocument=e,this.pdfDocument=e,this.annotationStorage=new Ri,Object.defineProperty(Object.getPrototypeOf(this.pdfDocument._transport),"annotationStorage",{get:()=>this.state.isPrintingInProgress?this.annotationStorage?.print:this.annotationStorage,set:e=>{this.annotationStorage=e},configurable:!0}),this._initializeAnnotationStorageCallbacks(e)}_initializeAnnotationStorageCallbacks(e){if(e!==this.pdfDocument)return;let{annotationStorage:t}=e;t.onSetModified=()=>{this._annotationStorageModified=!0},t.onResetModified=()=>{delete this._annotationStorageModified},t.onAnnotationEditor=e=>{this._hasAnnotationEditors=!!e}}drawPagesFromPromisesAsync(e){return Promise.all(e).then(e=>x(this,void 0,void 0,function*(){let t=yield Promise.all(this.drawPagesAsync(e));return this.appendPages(t),e}))}drawPagesAsync(e){if(e||=this.state.pdfPages,(this.pages||[]).length>0){if(this.options.zoomLevelType){let e=this.calculateZoomLevel({zoomLevel:this.options.zoomLevel,zoomLevelType:this.options.zoomLevelType,pdfPage:this.state.pdfPages?.[0]});this.options.zoomLevel=e,this.state.zoomLevel=e}for(let e=0;e<this.pages.length;e++)this.pages[e].viewport=this.pages[e].getViewport({scale:this.state.zoomLevel*ht.PDF_TO_CSS_UNITS})}else{if(this.options.zoomLevelType&&e.length>0){let t=this.calculateZoomLevel({zoomLevel:this.options.zoomLevel,zoomLevelType:this.options.zoomLevelType,pdfPage:e[0]});this.options.zoomLevel=t,this.state.zoomLevel=t}this.initPageComponents(e)}let t=[];return e.map((e,n)=>x(this,void 0,void 0,function*(){let r=this.pages[n];if(this.options.loadOnDemand&&n>=this.options.loadOnDemandPageSize&&!r.element){let n=this.createBlankPageElements({pdfPage:e,zoom:this.state.zoomLevel});r&&!r.element&&(r.element=n.pageElement,r.setBlank(!0));let i=Ae();t.push(i),i.then(e=>e),i.resolve(r.element)}else if(this.options.loadOnDemand&&r.isBlank()){let e=Ae();t.push(e),e.then(e=>e),e.resolve(r.element)}else{let e=this.drawPageAsync({pageIndex:n});t.push(e),e.then(e=>e)}})),t}createBlankPageElements({pdfPage:e,zoom:t}){let n=this.createPageElements({pdfPage:e,zoom:t});return n.canvasWrapper.appendChild(n.canvas),n.pageElement.appendChild(n.canvasWrapper),n}getDocumentParameters(e){let t={verbosity:0,isEvalSupported:!0};return typeof e.data==`string`&&e.data!==``?t.data=cn(e.data):typeof e.url==`string`&&e.url!==``?t.url=e.url:e.arrayBuffer instanceof ArrayBuffer?t=e.arrayBuffer:e.typedArray&&(t=e.typedArray),t}appendPages(e){e.forEach(e=>this.appendPage(e))}appendPage(e,t=null){let n=this.getPagesContainer();Te(t)?n?.insertBefore(e,n.children[t]):n?.appendChild(e)}drawPageAsync({pageIndex:e=0}){let t=gn(e,0,Math.max(0,this.state.pdfDocument.numPages-1));return this.pages[t]?.draw().then(()=>(this.triggerPageRendered({page:this.pages[t]}),this.pages[t].element))}createPageElements({pdfPage:e=null,zoom:t=1,printUnits:n=null}){if(t<=0)return;let r=this.getRenderScale();n&&(r=this.getPrintScale());let i=e?.getViewport({scale:r}),{adjustedWidth:a,adjustedHeight:o,adjustRatio:s}=un(i.width,i.height),c={width:`round(var(--scale-factor) * ${i.width/r}px, 1px)`,height:`round(var(--scale-factor) * ${i.height/r}px, 1px)`},l=Xt(`div`,`k-page`,c),u=Xt(`canvas`,``,{});u.height=o,u.width=a,n?Vt(u,{width:`${i.width/r}px`,height:`${i.height/r}px`}):Vt(u,{width:`100%`,height:`100%`});let d=u.getContext(`2d`);n&&(d.imageSmoothingEnabled=!1);let f=De(`
<div class="${this.options.elementSelectors.pageCanvasWrapper}"></div>
`),p=s*r;return i.width=a,i.height=o,i.scale=p,{canvasContext:d,canvasWrapper:f,canvas:u,viewport:i,scaleNum:r,pageElement:l,styles:c}}triggerPageRendered(e){this.trigger(qc,e)}triggerPagesLoad(e){this.trigger(Jc,e)}triggerZoomStart(e){this.trigger(Gc,e)}triggerZoomEnd(e){this.trigger(Kc,e)}triggerDownload(e){return this.trigger(`download`,e)}triggerAnnotationEditorToolBarShow(e){this.trigger(Zc,e)}triggerAnnotationEditorToolBarHide(e){this.trigger(Qc,e)}clearDocument(){this.destroyEventBus(),this.unbindEvents(),this.destroySearchService(),this.destroyAnnotationEditorUIManager(),this.clearDocumentState(),Ut()}clearDocumentState(){this.clearPagesState(),this.state.pdfDocument=null,this.state.pdfPages=[],this.linkService?.setDocument(null)}clearPagesState(){this.pages.forEach(e=>e.destroy()),this.clearPagesElements(),this.pages=[]}initPageComponents(e){let t=this.options.zoomLevel,n=e[0].getViewport({scale:t*ht.PDF_TO_CSS_UNITS});for(let r=1;r<=e.length;r++){let i=r-1,a=new Ac(null,{pdfViewer:this,container:this.element,eventBus:this.eventBus,id:r,scale:t,viewport:n,defaultViewport:n,textLayerMode:Ar.ENABLE,annotationMode:this.getAnnotationMode(),layerProperties:this._layerProperties});this.pages.push(a),this.pages[i].setPdfPage(e[i])}}destroyPageComponents(){this.pages.forEach(e=>e.destroy()),this.pages=[]}clearPagesElements(){let e=this.getDocumentContainer(),t=this.getPagesContainer();!e||!t||!this.hasDocument()||this.getPagesElements().forEach(e=>{t.removeChild(e)})}initDocumentContainer(){this.documentContainer||(this.documentContainer=this.getDocumentContainer(),this.initDocumentScroller(this.documentContainer))}initDocumentScroller(e){this.documentScroller||!e||(this.documentScroller=this.createDocumentScroller(e,{filter:Oe(this.options.elementSelectors.pageSelector),events:{[Xc]:this.onDocumentScrollerScroll}}))}createDocumentScroller(e,t){return new Le(e,t)}destroyDocumentScroller(){this.documentScroller&&=(this.documentScroller.destroy(),null)}enableDocumentScrollEventsTracking(){this.documentScroller?.enableScrollEventsTracking()}disableDocumentScrollEventsTracking(){this.documentScroller?.disableScrollEventsTracking()}getCurrentPageIndex(){return ln(this.element)||0}downloadFile({fileName:e,saveOptions:t={}}){this.downloadDocument({options:{pdf:this.state.pdfDocument},fileName:e||this.options.downloadFileName,saveOptions:t})}downloadDocument({options:e,fileName:t=`Document`,saveOptions:n={}}){e.pdf&&this.extractPdfData(e).then(e=>{if(e)return new Blob([e],{type:`application/pdf`})}).then(e=>{e&&!this.triggerDownload({blob:e,fileName:t,saveOptions:n})&&this.saveFile(e,t,n)}).catch(e=>{this.triggerError(e)})}getFileAsByteArray(){return this.extractPdfData({pdf:this.state.pdfDocument})}extractPdfData(e){if(!e.pdf)return Promise.resolve(null);let t=e.pdf.getData.bind(e.pdf),n={},r={};return e.pdf.annotationStorage.size>0&&(t=e.pdf.saveDocument.bind(e.pdf),n={},r=e.pdf.annotationStorage.getAll(),Object.keys(r).forEach(e=>{typeof r[e]?.toJSON==`function`?n[e]=r[e].toJSON():n[e]=r[e]}),Object.keys(r).forEach(t=>{e.pdf.annotationStorage.remove(t)}),Object.keys(n).forEach(t=>{e.pdf.annotationStorage.setValue(t,n[t])})),t().then(e=>e).catch(e=>(this.triggerError(e),null)).finally(()=>{if(e.pdf?.annotationStorage.size<=0)return;let t=e.pdf.annotationStorage.getAll();Object.keys(t).forEach(t=>{e.pdf.annotationStorage.remove(t)}),Object.keys(r).forEach(t=>{e.pdf.annotationStorage.setValue(t,r[t])})})}saveFile(e,t,n){try{Je(e,t,n)}catch{return!1}return!0}hasDocument(){return Te(this.state.pdfDocument)}zoom(e){!Te(e.zoomLevelType)&&Te(e.zoomLevel)&&(this.options.zoomLevelType=``,this.state.zoomLevelType=``);let t=this.calculateZoomLevel({zoomLevel:e.zoomLevel,zoomLevelType:e.zoomLevelType,pdfPage:this.state.pdfPages?.[0]});this.options.zoomLevel=t,this.state.zoomLevel=t,this.eventBus.dispatch(`scalechanging`,{source:this,scale:t}),this.reloadFile(this.state.pdfDocument)}calculateZoomLevel({zoomLevel:e,zoomLevelType:t,pdfPage:n}){let r=this.getDocumentContainer(),i=gn(e||$c,this.options.minZoom,this.options.maxZoom);if(!Te(r)||!Te(n))return i;let a=ht.PDF_TO_CSS_UNITS,o=n.getViewport({scale:1}),s=o?.width*a,c=o?.height*a,l=r.clientWidth/s,u=r.clientHeight/c;return t===`ActualWidth`||t===`actualWidth`?i=1:t===`FitToWidth`||t===`fitToWidth`?i=l:(t===`FitToPage`||t===`fitToPage`)&&(i=Math.min(l,u)),(!isFinite(i)||i===0)&&(i=$c),i}reloadFile(e){let t=[];for(let n=1;n<=e.numPages;n++)t.push(e.getPage(n));this.disableDocumentScrollEventsTracking(),this.drawPagesFromPromisesAsync(t).then(t=>{this.onPagesLoad({pdfPages:t,pdfDoc:e})}).catch(e=>{this.triggerError(e)}).finally(()=>{this.setScaleFactor(this.state.zoomLevel)})}setHiddenCanvasStyles(){this.options.pdfjsSetHiddenCanvasStyles&&dn(this.getPagesContainer().ownerDocument)}printFile(){this.hasDocument()&&(this.setState({isPrintingInProgress:!0}),this.options.zoomBeforePrint?(this.cacheZoomLevelBeforePrint(),this.loadDocumentForPrintAsync({zoomLevel:this.options.zoomLevelBeforePrint,force:!0}).then(()=>{this.printDocumentAsync().then(()=>{this.trigger(Yc)})}).catch(this.triggerError).finally(()=>{this.setState({isPrintingInProgress:!1}),this.restoreZoomLevelBeforePrint()})):this.loadDocumentForPrintAsync({zoomLevel:this.state.zoomLevel,force:!0}).then(()=>{this.printDocumentAsync().then(()=>{this.trigger(Yc)})}).catch(this.triggerError).finally(()=>{this.setState({isPrintingInProgress:!1})}))}loadDocumentForPrintAsync({zoomLevel:e=$c,force:t=!1}){let n=this.pages,r=[],i=Ae();for(let i=0;i<n.length;i++){let a=n[i].loadForPrintAsync({zoomLevel:e,force:t});r.push(a)}return Promise.all(r).then(()=>{i.resolve()}),i}getPagesPrintContentAsync(e){let t=this.pages,n=[];for(let r=0;r<t.length;r++){let i=t[r].getPrintContentAsync();i.then(t=>{let n=De(`<div></div>`);n.appendChild(t),e.appendChild(n)}),n.push(i)}return n}initPrintContainer(){this.printContainer=De(`<div></div>`)}openPrintDialog(){let e=this.pages,t=e[0].rawWidth*this.getPdfToCssUnits(),n=e[0].rawHeight*this.getPdfToCssUnits(),r=window.open(``,``,`innerWidth=`+t+`,innerHeight=`+n+`location=no,titlebar=no,toolbar=no`);if(!r||!r.document){this.triggerError({message:this.options.messages.errorMessages.popupBlocked});return}r.document.body.style.margin=`0`,r.document.body.appendChild(this.printContainer);let i=()=>{r.removeEventListener(`afterprint`,i),r.close()};r.addEventListener(`afterprint`,i),r.focus(),r.print()}cacheZoomLevelBeforePrint(){this.setState({zoomLevelBeforePrint:this.state.zoomLevel})}restoreZoomLevelBeforePrint(){this.state.zoomLevelBeforePrint!==this.state.zoomLevel&&this.zoom({zoomLevel:this.state.zoomLevelBeforePrint,zoomLevelType:this.state.zoomLevelType})}searchText(e={text:``,matchCase:!1}){return this.initSearchService(),this.searchService?.search(e)}clearSearch(){this.destroySearchService()}initSearchService(){let e=Array.from(this.wrapper.querySelectorAll(Oe(this.options.elementSelectors.textLayerClass))||[]);if(this.searchService){if(e.every((e,t)=>e===this.searchService.options.textContainers[t]))return;this.destroySearchService()}this.searchService=new qe({textContainers:e,highlightClass:this.options.elementSelectors.searchHighlightClass,highlightMarkClass:this.options.elementSelectors.searchHighlightMarkClass,charClass:this.options.elementSelectors.charClass})}destroySearchService(){this.searchService&&=(this.searchService.destroy(),null)}goToNextSearchMatch(){if(!this.searchService)return;this.searchService.markNextMatch();let e=this.searchService.getActiveMatchElement();this.scrollToSearchMatch(e)}goToPreviousSearchMatch(){if(!this.searchService)return;this.searchService.markPreviousMatch();let e=this.searchService.getActiveMatchElement();this.scrollToSearchMatch(e)}getPagesContainer(){return this.element.querySelector(Oe(this.options.elementSelectors.pagesContainerClass))}getDocumentContainer(){return this.wrapper.querySelector(Oe(this.options.elementSelectors.documentContainerClass))}getPagesElements(){let e=this.getDocumentContainer();return e?Se(e.querySelectorAll(Oe(this.options.elementSelectors.pageSelector))):[]}scrollToSearchMatch(e){if(!e)return;let t=e.closest(`.k-text-char`),n=t?t.closest(`span[role="presentation"]`):null;if(!n)return;let r=n.closest(`.k-page`);if(!r)return;let i=r.offsetLeft+-1*this.documentScroller.element.offsetLeft+n.offsetLeft+this.options.searchMatchScrollLeftOffset,a=r.offsetTop+-1*this.documentScroller.element.offsetTop+n.offsetTop+this.options.searchMatchScrollTopOffset;this.documentScroller.scrollTo(i,a,{trackScrollEvent:!1})}resetInteractionMode(){this.setInteractionMode({mode:Fc.TextSelection})}setInteractionMode(e){this.interactionMode=e.mode,this.interactionMode===Fc.TextSelection?(this.disableScrollerEventsTracking(),Jt(this.options.elementSelectors.enabledTextSelectionClass,this.documentScroller.element),Yt(this.options.elementSelectors.enabledPanningClass,this.documentScroller.element)):this.interactionMode===Fc.Pan&&(this.enableScrollerEventsTracking(),Yt(this.options.elementSelectors.enabledTextSelectionClass,this.documentScroller.element),Jt(this.options.elementSelectors.enabledPanningClass,this.documentScroller.element))}enableScrollerEventsTracking(){this.documentScroller&&this.documentScroller.enablePanEventsTracking()}disableScrollerEventsTracking(){this.documentScroller&&this.documentScroller.disablePanEventsTracking()}setScaleFactor(e){Ht(this.element,{"--scale-factor":String(e*ht.PDF_TO_CSS_UNITS),"--total-scale-factor":String(e*ht.PDF_TO_CSS_UNITS),"--scale-round-x":`1px`,"--scale-round-y":`1px`},this.element.getAttribute(`data-kpv-sid`)||void 0)}_isTrackpadPinch(e){if(this._isCtrlKeyDown||e.deltaMode!==WheelEvent.DOM_DELTA_PIXEL||e.deltaX!==0)return!1;let t=Math.exp(-e.deltaY/100);return!(Math.abs(t-1)>=.05)}_accumulateFactor(e,t,n){if(t===1)return 1;(this[n]>1&&t<1||this[n]<1&&t>1)&&(this[n]=1);let r=Math.floor(e*t*this[n]*100)/(100*e);return this[n]=t/(r||t),r||1}bindPinchToZoomEvents(){if(!this.options.pinchToZoom)return;document.addEventListener(`keydown`,this._onKeyDown),document.addEventListener(`keyup`,this._onKeyUp);let e=this.getDocumentContainer();if(!e)return;this._pinchAC=new AbortController;let t=this._pinchAC.signal;e.style.touchAction=`none`,e.addEventListener(`touchstart`,this._onTouchStart,{passive:!1,signal:t}),e.addEventListener(`gesturestart`,this._onGestureEvent,{signal:t}),e.addEventListener(`gesturechange`,this._onGestureEvent,{signal:t})}unbindPinchToZoomEvents(){document.removeEventListener(`keydown`,this._onKeyDown),document.removeEventListener(`keyup`,this._onKeyUp),this._isCtrlKeyDown=!1;let e=this.getDocumentContainer();e&&(e.style.touchAction=``),this._pinchAC&&=(this._pinchAC.abort(),null),this._resetPinchState()}_resetPinchState(){this._isPinching=!1,this._touchInfo=null,this._touchUnusedFactor=1,this._wheelUnusedFactor=1,this._pendingPinchFactor=1}get _minTouchDistanceToPinch(){return 32/(window.devicePixelRatio||1)}_applyPinchTransform(e,t){let n=t/e,r=this._accumulateFactor(this.state.zoomLevel,n,`_touchUnusedFactor`);this._pendingPinchFactor*=r;let i=this.state.zoomLevel*this._pendingPinchFactor,a=gn(i,this.options.minZoom,this.options.maxZoom)/this.state.zoomLevel,o=this.getPagesContainer();o&&(o.style.transform=`scale(${a})`,o.style.transformOrigin=`center top`)}_clearPinchTransform(){let e=this.getPagesContainer();e&&(e.style.transform=``,e.style.transformOrigin=``)}activatePageNumber(e){let t=this.getPageByNumber(e);if(!t)return;let n=e-1;this.state.activePageNumber!==e&&(this.state.activePageNumber=e,t.isBlank()?this.drawPageAsync({pageIndex:n}).then(()=>{this.scrollToPage({pageNumber:e})}):this.scrollToPage({pageNumber:e}))}scrollToPage({pageNumber:e}){let{left:t,top:n}=this.getPageNumberScrollOffset(e);this.scrollDocument({left:t,top:n})}scrollDocument({left:e,top:t}){this.documentScroller?.scrollTo(e,t,{trackScrollEvent:!1})}getPageNumberScrollOffset(e){return this.getPageByNumber(e)?{left:0,top:this.pages.slice(0,Math.max(0,e-1)).map(e=>this.getPageScrollOffset(e)).reduce((e,t)=>e+t,0)}:{left:0,top:0}}getPageScrollOffset(e){let t=(e?.element)?.getBoundingClientRect().height||0,n=getComputedStyle(e.element);return t+(parseFloat(n.marginTop)||0)}getPageByNumber(e){return this.pages&&this.pages[e-1]}addHighlightAnnotation(){this.annotationEditorUIManager?.highlightSelection()}setHighlightColor(e){this.executeAnnotationCommand({commandType:b.HIGHLIGHT_COLOR,commandValue:e})}deleteAnnotation(){this.annotationEditorUIManager?.delete()}resetAnnotationEditorMode(){this.setAnnotationEditorMode({mode:y.NONE,editId:null,isFromKeyboard:!1})}setAnnotationEditorMode(e){this.annotationEditorMode=e}setAnnotationMode(e){C(this,zc,e,`f`)}setEditAnnotationMode(){C(this,zc,vn.ENABLE_FORMS,`f`)}resetAnnotationMode(){C(this,zc,vn.ENABLE,`f`)}setFreeTextColor(e){this.executeAnnotationCommand({commandType:b.FREETEXT_COLOR,commandValue:e})}setFreeTextFontSize(e){this.executeAnnotationCommand({commandType:b.FREETEXT_SIZE,commandValue:parseFloat(e)})}executeAnnotationCommand({commandType:e,commandValue:t}){this.eventBus.dispatch(`switchannotationeditorparams`,{source:this,type:e,value:t})}isValidAnnotationEditorMode(e){return Object.values(y).includes(e)&&e!==y.DISABLE}cleanupSwitchAnnotationEditorMode(){S(this,Vc,`f`)&&(this.eventBus._off(`pagerendered`,S(this,Vc,`f`)),C(this,Vc,null,`f`)),S(this,Rc,`f`)!==null&&(clearTimeout(S(this,Rc,`f`)),C(this,Rc,null,`f`))}_getVisiblePages(){return this.pages}get _layerProperties(){let e=this;return ft(this,`_layerProperties`,{get annotationEditorUIManager(){return e.annotationEditorUIManager},get annotationStorage(){return e.pdfDocument?.annotationStorage},get linkService(){return e.linkService}})}scrollPageIntoView({pageNumber:e,destArray:t=null,allowNegativeOffset:n=!1,ignoreDestinationZoom:r=!1}){if(!this.pdfDocument)return;let i=Number.isInteger(e)&&this.pages[e-1];if(!i)return;if(i.isBlank()){this.drawPageAsync({pageIndex:e-1}).then(()=>{this.scrollPageIntoView({pageNumber:e,destArray:t,allowNegativeOffset:n,ignoreDestinationZoom:r})});return}if(this.isInPresentationMode||!t){this._setCurrentPageNumber(e,!0);return}let a=0,o=0,s=(i.rotation%180==0?i.rawHeight:i.rawWidth)/i.scale/ht.PDF_TO_CSS_UNITS;switch(t[1].name){case`XYZ`:a=t[2],o=t[3],a=a===null?0:a,o=o===null?s:o;break;default:return}let c=[i.viewport.convertToViewportPoint(a,o),i.viewport.convertToViewportPoint(a+0,o+0)],l=Math.min(c[0][0],c[1][0]),u=Math.min(c[0][1],c[1][1]);n||(l=Math.max(l,0),u=Math.max(u,0)),S(this,Ic,`m`,Uc).call(this,i,{left:l,top:u})}_setCurrentPageNumber(e,t=!1){if(this._currentPageNumber===e)return!0;if(!(0<e&&e<=this.state.pdfDocument.numPages))return!1;let n=this._currentPageNumber;return this._currentPageNumber=e,this.eventBus.dispatch(`pagechanging`,{source:this,pageNumber:e,previous:n}),!0}};Lc=new WeakMap,Rc=new WeakMap,zc=new WeakMap,Bc=new WeakMap,Vc=new WeakMap,Ic=new WeakSet,Hc=function(){let e=[],t=new Set;this.pages.forEach(e=>{t.add(e.id)});for(let n of this.pages){let r=n;if(!r.hasEditableAnnotations()){t.delete(r.id);continue}e.push(n)}return e.length===0?null:(this.drawPagesAsync(this.state.pdfPages),t)},Uc=function(e,t=null){let{div:n,id:r}=e;if(this._currentPageNumber!==r&&this._setCurrentPageNumber(r),!t&&!this.isInPresentationMode){let e=n.offsetLeft+n.clientLeft,r=e+n.clientWidth,{scrollLeft:i,clientWidth:a}=this.element;(this._scrollMode===jr.HORIZONTAL||e<i||r>i+a)&&(t={left:0,top:0})}Mr(n,t)};let tl=jQuery,nl={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9};var rl=class{constructor(e){this.viewer=e,this.widget=e.pdfViewerCommon,this.init()}init(){let e=this.element=tl(`<div></div>`);e.insertAfter(this.viewer.toolbar.element);let t=this.toolbar=new kendo.ui.ToolBar(e,{fillMode:`flat`,tools:[{name:`highlight`,command:`highlight`,icon:`highlight`,type:`button`,togglable:!0,showText:`overflow`,group:`annotations`,fillMode:`flat`},{type:`separator`},{name:`freeText`,command:`freeText`,icon:`free-text`,type:`button`,togglable:!0,showText:`overflow`,group:`annotations`,fillMode:`flat`},{type:`spacer`},{name:`close`,command:`close`,icon:`x`,type:`button`,showText:`overflow`,fillMode:`flat`}],parentMessages:{highlight:`Highlight`,freeText:`Free text`,close:`Close`}});t.bind(`click`,this.onToolbarClick.bind(this)),t.bind(`toggle`,this.onToolbarClick.bind(this))}onToolbarClick(e){let t=this.widget,n=tl(e.target).data(`command`),r=this.viewer.toolbar;switch(n){case`close`:this.destroy(),r.element.find(`[tabindex=0]`).trigger(`focus`);break;case`highlight`:oe(t,{interactionMode:Fc.TextSelection,mode:nl.HIGHLIGHT});break;case`freeText`:oe(t,{interactionMode:Fc.TextSelection,mode:nl.FREETEXT});break}}destroy(){this.toolbar&&(this.viewer.toolbar.toggle(`[title='Annotations']`,!1),this.toolbar.unbind(`click`),this.toolbar.unbind(`toggle`),this.toolbar.destroy(),this.toolbar=null,this.element.remove(),this.element=null,this.viewer.annotationsToolbar=null,se(this.widget))}};(function(e,t){var n=window.kendo,r=e.extend,i=n.ui.progress,a=n.Class,o=n.pdfviewer.UploadHelper,s=`zoomStart`,c=`zoomEnd`,l=a.extend({init:function(e){this.options=e,this.viewer=e.viewer,this.errorMessages=this.viewer.options.messages.errorMessages}}),u=l.extend({init:function(e){l.fn.init.call(this,e),this._uploadHelper=new o(this.viewer)},exec:function(){this.viewer._upload=this.viewer._upload||this._uploadHelper._initUpload(),this.viewer._upload.element.click()}}),d=l.extend({exec:function(){var e=this.options.value,t=this.viewer,n,r;if(isNaN(e))switch(n=t._pageNum,r=t.document.total||t.document.numPages,e){case`first`:e=1;break;case`prev`:e=n>1?n-1:1;break;case`next`:e=n<r?n+1:r;break;case`last`:e=r;break}else e=Number(e);t.activatePage(e,!1)}}),f=l.extend({exec:function(){let e=this;if(!e.viewer.document){e.viewer._triggerError({message:e.errorMessages.notFound});return}let t=e.viewer.document.info&&e.viewer.document.info.title||e.viewer.options.messages.defaultFileName;e.viewer._isDPLProcessor()?e.viewer.processor.downloadFile(t):e.viewer.pdfViewerCommon.downloadFile({fileName:t})}}),p=l.extend({init:function(t){t=e.extend(t,this.options),l.fn.init.call(this,t)},exec:function(){var e=this.viewer._saveDialog||this._initDialog();e._updateModel({pagesCount:this.viewer.document&&this.viewer.document.total||1,page:this.viewer.options.page}),e.open()},apply:function(e){var t=e.extension;t===`.png`?this.viewer.exportImage(e):t===`.svg`&&this.viewer.exportSVG(e)},_initDialog:function(){return this.viewer._saveDialog=new n.pdfviewer.dialogs.ExportAsDialog({apply:this.apply.bind(this),pagesCount:this.viewer.document&&this.viewer.document.total||1,messages:this.viewer.options.messages}),this.viewer._saveDialog}}),m=l.extend({exec:function(){let e=this.viewer;e.toolbar.enable(e.toolbar.element.find(`[data-command=AnnotationsCommand]`),!0),ce(e.pdfViewerCommon,Fc.TextSelection)}}),h=l.extend({exec:function(){let e=this.viewer;e.toolbar.enable(e.toolbar.element.find(`[data-command=AnnotationsCommand]`),!1),e.annotationsToolbar&&e.annotationsToolbar.destroy(),se(e.pdfViewerCommon),ce(e.pdfViewerCommon,Fc.Pan)}});let ee=l.extend({init:function(e){let t=this;t.viewer=e.viewer,t.viewer.searchDialog||(t.viewer.searchDialog=new n.pdfviewer.dialogs.SearchDialog({pageContainer:t.viewer.pageContainerWrapper,position:{top:t.viewer.pageContainer.offset().top,left:t.viewer.pageContainer.offset().left},messages:t.viewer.options.messages.dialogs.search,open:t._open.bind(t),next:t._next.bind(t),prev:t._prev.bind(t),close:t._close.bind(t)})),l.fn.init.call(t,e)},exec:function(){this.viewer.searchDialog.open()},_open:function(){let e=this;e.changeHandler=e._change.bind(e),e.viewer.searchDialog.searchModel.bind(`change`,e.changeHandler)},_close:function(){let e=this;e.viewer.pdfViewerCommon.clearSearch(),e.viewer.toolbar.element.find(`[tabindex=0]`).trigger(`focus`),e.viewer.searchDialog.searchModel.unbind(`change`,e.changeHandler),e.matches=[],e.matchIndex=null,e._updateSearchModel()},_change:function(e){let t=this,n=t.viewer.searchDialog.searchModel.searchText,r=t.viewer.searchDialog.searchModel.matchCase;(e.field===`searchText`||e.field===`matchCase`)&&(t.matches=t.viewer.pdfViewerCommon.searchText({text:n,matchCase:r}),t.matchIndex=+!!t.matches.length,t._updateSearchModel())},_next:function(){let e=this;e.viewer.pdfViewerCommon.goToNextSearchMatch(),e.matchIndex=e.matchIndex+1>e.matches.length?1:e.matchIndex+1,e._updateSearchModel()},_prev:function(){let e=this;e.viewer.pdfViewerCommon.goToPreviousSearchMatch(),e.matchIndex=e.matchIndex-1<1?e.matches.length:e.matchIndex-1,e._updateSearchModel()},_updateSearchModel:function(){let e=this,t=e.viewer.searchDialog.searchModel;e.matches&&e.matches.length?(t.set(`matches`,e.matches.length),t.set(`matchIndex`,e.matchIndex)):(t.set(`searchText`,``),t.set(`matches`,0),t.set(`matchIndex`,0))},_closeDialog:function(){this.viewer.searchDialog.close()}});var g=l.extend({exec:function(){let e=this,n=e._calculateZoom();if(n===t)return;let r=n.zoomLevel;e.viewer.zoomScale!==n.zoomLevel&&(e.viewer._preventRenderEvent=!0,e.viewer._currentPage=e.viewer.pdfViewerCommon.getCurrentPageIndex()+1,e.viewer.pdfViewerCommon.zoom({zoomLevel:n.zoomLevel,zoomLevelType:n.zoomLevelType}),r=e.viewer.pdfViewerCommon.options.zoomLevel,e._triggerZoomEnd(r)),e.viewer.zoomScale=r},_calculateZoom:function(){var e=this.options,t=this.viewer,r=t.options,i=e.value||e.scale,a=i,o=``,c;if(t._allowResize=!1,t._autoFit=!1,e.zoomIn?a=i=t.zoomScale+r.zoomRate:e.zoomOut?a=i=t.zoomScale-r.zoomRate:i===`auto`?(t._allowResize=!0,a=t._autoZoomScale):typeof i==`string`&&!n.parseFloat(i)?o=i:i&&i.toString().match(/^[0-9]+%?$/)?(i=parseInt(i.replace(`%`,``),10)/100,a=i):c=isNaN(i),c||=i<r.zoomMin||i>r.zoomMax,!(c||t.trigger(s,{scale:i})))return e.updateComboBox&&t.toolbar&&t._updateZoomComboBox(i),{zoomLevel:a,zoomLevelType:o}},_triggerZoomEnd:function(e){this.viewer.trigger(c,{scale:e})}}),te=l.extend({init:function(e){l.fn.init.call(this,e)},exec:function(){let e=this;if(!e.viewer.document){e.viewer._triggerError({message:this.errorMessages.notFound});return}i(e.viewer.pageContainerWrapper,!0),setTimeout(()=>{e.viewer.pdfViewerCommon.printFile()},100)}});let ne=l.extend({init:function(e){l.fn.init.call(this,e)},exec:function(){let e=this.viewer;e.annotationsToolbar?e.annotationsToolbar.destroy():e.annotationsToolbar=new rl(e)}});r(n.pdfviewer,{OpenCommand:u,PageChangeCommand:d,DownloadCommand:f,EnableSelectionCommand:m,EnablePanCommand:h,ExportCommand:p,PrintCommand:te,OpenSearchCommand:ee,ZoomCommand:g,AnnotationsCommand:ne})})(window.kendo.jQuery),(function(e,t){var n=window.kendo,r=n.htmlEncode,i=e.extend,a=n.Class,o=n.ui.Draggable,s=n._outerWidth,c={svg:`.svg`,png:`.png`},l=n.keys,u=a.extend({init:function(t){this.options=i(t,{actions:[{text:t.messages.dialogs.okText}]}),this._dialog=e(`<div />`).kendoDialog(this.options).getKendoDialog()},open:function(){this._dialog.center().open()}}),d=a.extend({init:function(e){return this.options=i(e,this.options,{fileFormats:[{description:e.messages.dialogs.exportAsDialog.png,extension:c.png},{description:e.messages.dialogs.exportAsDialog.svg,extension:c.svg}],title:e.messages.dialogs.exportAsDialog.title,open:function(){this.center()}}),this._initializeDialog(),this},options:{extension:c.png,autoFocus:!0,resizable:!1,modal:{preventScroll:!0},width:`90%`,maxWidth:520,template:({messages:e,total:t})=>`<div class='k-edit-label'><label>${r(e.exportAsDialog.labels.fileName)}:</label></div><div class='k-edit-field'><span class='k-textbox k-input'><input class='k-input-inner' data-bind='value: name' /></span></div><div><div class='k-edit-label'><label>${r(e.exportAsDialog.labels.saveAsType)}:</label></div><div class='k-edit-field'><select data-role='dropdownlist' class='k-file-format' data-text-field='description' data-value-field='extension' data-bind='value: extension, source: fileFormats'></select></div></div><div class='k-edit-label'><label>${r(e.exportAsDialog.labels.page)}:</label></div><div class='k-edit-field'><input data-role='numerictextbox' data-format='n0' data-min='1' data-max='${r(t)}' data-bind='value: page' /></div><div class='k-actions'><button class='k-button k-button-primary' data-bind='click: apply'><span class='k-button-text'>${r(e.save)}</span></button><button class='k-button' data-bind='click: close'><span class='k-button-text'>${r(e.cancel)}</span></button></div>`},_updateModel:function(e){e.pagesCount&&this.viewModel.set(`pagesCount`,e.pagesCount),e.page&&this.viewModel.set(`page`,e.page)},_initializeDialog:function(){var t=this,r=t.options,i=r.messages.dialogs,a=e(`<div class='k-pdf-viewer-window k-action-window k-popup-edit-form' />`).append(n.template(r.template)({total:r.pagesCount,messages:i})).kendoWindow(r).getKendoWindow();return t.viewModel=n.observable({title:i.exportAsDialog.title,name:i.exportAsDialog.defaultFileName,extension:r.extension,fileFormats:r.fileFormats,pagesCount:r.pagesCount,page:1,apply:t.apply.bind(this),close:function(){a.close()}}),t._dialog=a,n.bind(a.element,t.viewModel),a},open:function(){this._dialog.center().open()},apply:function(){this._dialog.close(),this.options.apply({fileName:this.viewModel.name+this.viewModel.extension,extension:this.viewModel.extension,page:this.viewModel.page})},destroy:function(){this._dialog&&this._dialog.destroy()}}),f=a.extend({init:function(e){var t=this;t.options=i({},e,t.options)},options:{resizable:!1,template:({messages:e})=>`<div class="k-search-panel k-pos-sticky k-top-center"><button aria-label='${r(e.dragHandle)}' class='k-button k-button-flat k-icon-button k-search-dialog-draghandle'>${n.ui.icon({icon:`handle-drag`,iconClass:`k-button-icon`})}</button><span class='k-textbox k-input'><input class='k-search-dialog-input k-input-inner' data-bind='value: boundValue, events: { keyup: onKeyup, input: onInput }' aria-label='${r(e.inputLabel)}' title='${r(e.inputLabel)}' /><span class='k-input-suffix'><button class='k-button k-button-flat k-icon-button k-match-case-button k-match-case-button' data-bind='css: {k-selected: matchCase}, click: matchCaseClick' aria-label='${r(e.matchCase)}' title='${r(e.matchCase)}'>${n.ui.icon({icon:`convert-lowercase`,iconClass:`k-button-icon`})}</button></span></span><span class='k-search-matches'><span data-bind='text: matchIndex'></span> ${r(e.of)} <span data-bind='text: matches'></span></span><button class='k-button k-button-flat k-icon-button' data-bind='click: prev' aria-label='${r(e.previous)}' title='${r(e.previous)}'>${n.ui.icon({icon:`arrow-up`,iconClass:`k-button-icon`})}</button><button class='k-button k-button-flat k-icon-button' data-bind='click: next' aria-label='${r(e.next)}' title='${r(e.next)}'>${n.ui.icon({icon:`arrow-down`,iconClass:`k-button-icon`})}</button><button class='k-button k-button-flat k-icon-button' data-bind='click: close' aria-label='${r(e.close)}' title='${r(e.close)}'>${n.ui.icon({icon:`x`,iconClass:`k-button-icon`})}</button></div>`},open:function(){var e=this;e.dialog||e._initializeDialog(),e.options.open(),e._showSearchDialog()},close:function(){var e=this;e.options.close(),e._hideSearchDialog()},_showSearchDialog:function(){var e=this;e.dialog.css(`left`,`${e.options.pageContainer.innerWidth()/2-s(e.dialog,!0)/2}px`),e.dialog.kendoStop().kendoAnimate({effects:{zoom:{direction:`in`},fade:{direction:`in`}},duration:350,complete:function(t){e.dialog.find(`.k-search-dialog-input`).trigger(`focus`)}})},_hideSearchDialog:function(){this.dialog.kendoStop().kendoAnimate({effects:{zoom:{direction:`out`,properties:{scale:.7}},fade:{direction:`out`}},duration:350,hide:!0})},_initializeDialog:function(){var t=this,r=e(n.template(t.options.template)({messages:t.options.messages}));t.options.pageContainer.prepend(r),t.dialog=r,t._draggable=new o(r,{filter:`.k-search-dialog-draghandle`,axis:`x`,dragstart:function(e){var r=t.dialog,i=t.options.pageContainer;if(r.startPosition={left:e.x.client-n.getOffset(r,`position`).left},!i)return null;i._innerWidth=i.innerWidth(),parseInt(i._innerWidth,10)>i[0].clientWidth&&(i._innerWidth-=n.support.scrollbar()),r.maxLeft=i._innerWidth-s(r,!0)},drag:function(e){var n=t.dialog,r={},i=e.x.client-n.startPosition.left;i&&isNaN(i)&&i.toString().indexOf(`px`)<0?r.left=i:r.left=Math.max(Math.min(parseInt(i,10),parseInt(n.maxLeft,10)),0),n.css(r)}}),t._draggable.userEvents.stopPropagation=!1,t.searchModel=n.observable({boundValue:``,searchText:``,matchCase:!1,matchIndex:0,matches:0,matchCaseClick:function(){this.set(`matchCase`,!this.matchCase)},next:t.options.next,prev:t.options.prev,close:function(){this.set(`boundValue`,``),t.close()},onKeyup:function(e){var t=e.keyCode,n=e.shiftKey?this.prev:this.next;t===l.ENTER?(n(),e.preventDefault()):t==l.ESC&&this.close()},onInput:function(e){this.set(`searchText`,e.target.value)}}),n.bind(r,t.searchModel)}});i(n.pdfviewer,{dialogs:{ErrorDialog:u,ExportAsDialog:d,SearchDialog:f}})})(window.kendo.jQuery);let il=jQuery;var al=class{constructor(e,t,n){this.viewer=e,this.widget=e.pdfViewerCommon,this.anchor=t,this.editor=n,this.popupOpenHandler=this.onPopupOpen.bind(this),this.init()}init(){let e=this.anchor,t=il(`<div data-uid="${kendo.guid()}"></div>`);this.popup=new kendo.ui.Popup(il(`<div class="k-pdf-viewer-annotation-editor-toolbar"></div>`),{anchor:e}),this.popup.element.html(t),(this.popupToolbar=new kendo.ui.ToolBar(t,{fillMode:`flat`,tools:[{name:`palette`,command:`palette`,icon:`palette`,type:`button`,showText:`overflow`,fillMode:`flat`},{name:`remove`,command:`remove`,icon:`trash`,type:`button`,showText:`overflow`,fillMode:`flat`}],parentMessages:{palette:`Palette`,remove:`Remove`}})).bind(`click`,this.onAnnotationPopupToolbarClick.bind(this)),this.popup.open()}initEditor(){}onAnnotationPopupToolbarClick(e){let t=this.widget;switch(il(e.target).data(`command`)){case`palette`:this.initEditor();break;case`remove`:ne(t),this.destroyPopup();break;default:break}}onPopupOpen(){this.flatColorPicker._view._hueSlider.resize(),this.flatColorPicker._view._opacitySlider.resize()}anchorExists(){return document.getElementById(this.anchor.id)}destroyPopup(){this.popup&&=(this.popup.destroy(),null)}destroyEditor(){this.editorPopup&&=(this.editorPopup.destroy(),null)}destroy(){this.popupToolbar&&=(this.popupToolbar.unbind(`click`),this.popupToolbar.unbind(`toggle`),this.popupToolbar.destroy(),null),this.destroyPopup()}},ol=class extends al{constructor(e,t,n){super(e,t,n)}initEditor(){let e=this.anchor;if(!this.anchorExists()){this.destroy();return}this.destroyEditor(),this.editorPopup=new kendo.ui.Popup(il(`
<div class="k-pdf-viewer-annotation-editor">
<span class="k-column-menu-group-header">
<span class="k-column-menu-group-header-text">Color</span>
</span>
<div ref-annotation-editor-flat-color-picker></div>
</div>
`),{anchor:e,activate:this.popupOpenHandler}),this.initFlatColorPicker(),this.editorPopup.open(),this.destroy()}initFlatColorPicker(){this.flatColorPicker=new kendo.ui.FlatColorPicker(this.editorPopup.element.find(`[ref-annotation-editor-flat-color-picker]`),{format:`rgb`,opacity:!0,change:e=>re(this.widget,e.value)})}onPopupOpen(){let e=this.editor.color;super.onPopupOpen(),this.flatColorPicker.value(e)}},sl=class extends al{constructor(e,t,n){super(e,t,n)}initEditor(){let e=this.anchor;if(!this.anchorExists()){this.destroy();return}this.destroyEditor(),this.editorPopup=new kendo.ui.Popup(il(`
<div class="k-pdf-viewer-annotation-editor">
<span class="k-column-menu-group-header">
<span class="k-column-menu-group-header-text">Text style</span>
</span>
<form ref-annotation-text-editor-popup-form></form>
<span class="k-column-menu-group-header">
<span class="k-column-menu-group-header-text">Color</span>
</span>
<div ref-annotation-editor-flat-color-picker></div>
</div>
`),{anchor:e,activate:this.popupOpenHandler}),this.initFontSizeForm(),this.initFlatColorPicker(),this.editorPopup.open(),this.destroy()}initFontSizeForm(){let e=this.editor.propertiesToUpdate[0][1],t=[8,9,10,11,12,13,14,16,20,22,24,26,28,36,48,72];this.fontSizeForm=new kendo.ui.Form(il(`[ref-annotation-text-editor-popup-form]`),{buttonsTemplate:()=>``,formData:{fontSize:e},layout:`grid`,grid:{cols:3},items:[{field:`fontSize`,label:`Font size`,editor:`DropDownList`,colSpan:1,editorOptions:{fillMode:`flat`,dataSource:t,change:e=>{let t=parseFloat(e.sender.value());ae(this.widget,t),this.editor.editorDiv&&this.editor.editorDiv.style.setProperty(`font-size`,`calc(`+t+`px * var(--scale-factor))`,`important`)}}}]}),this.fontSizeForm.element.find(`.k-form-buttons`).remove()}initFlatColorPicker(){this.flatColorPicker=new kendo.ui.FlatColorPicker(this.editorPopup.element.find(`[ref-annotation-editor-flat-color-picker]`),{format:`rgb`,opacity:!0,change:e=>{ie(this.widget,e.value),this.editor.editorDiv&&this.editor.editorDiv.style.setProperty(`color`,e.value,`important`)}})}onPopupOpen(){let e=this.editor.propertiesToUpdate[1][1];super.onPopupOpen(),this.flatColorPicker.value(e)}};let cl={id:`pdfviewer`,name:`PDFViewer`,category:`web`,description:`PDFViewer to display pdfs in the browser`,depends:[`core`,`window`,`dialog`,`toolbar`,`draganddrop`,`upload`,`combobox`,`drawing`,`binder`,`dropdownlist`,`numerictextbox`,`textbox`,`pager`,`form`,`colorpicker`]};(function(e,t){var n=`.kendoPDFViewer`,r=window.kendo,i=r.ui,a=e.extend,o=r.drawing,s=e.extend({PLUS:187,MINUS:189,ZERO:48,NUMPAD_ZERO:96},r.keys),c,l=r.pdfviewer.BlankPage,u=i.Widget,d=r.ui.progress,f=`scroll`,p=`render`,m=`open`,h=`error`,ee=`keydown`+n;``+n+n;var g=`update`,ne=`pagechange`,re=`zoomStart`,ie=`zoomEnd`,ae=`kendoKeydown`,oe=`ZoomCommand`,le=`#ffffff`,_=`tabindex`,v=`click`,ue=`change`,de=`toggle`,fe=`k-disabled`,pe={pdfjs:`pdfjs`,dpl:`dpl`},me={viewer:`k-pdf-viewer`,scroller:`k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto`,enableTextSelection:`k-enable-text-select`,enablePanning:`k-enable-panning`,highlightClass:`k-search-highlight`,highlightMarkClass:`k-search-highlight-mark`,charClass:`k-text-char`},he={auto:`auto`,actual:`ActualWidth`,fitToWidth:`FitToWidth`,fitToPage:`FitToPage`},ge=u.extend({init:function(e,t){var n=this;u.fn.init.call(n,e,r.deepExtend({},this.options,t)),n._processMessages(),n._wrapper(),n.options.toolbar&&n._renderToolbar(),n._initProcessor(t||{}),n._renderPageContainer(),n._isDPLProcessor()?n._loadDPLDocument():n._loadPdfJSDocument(),r.notify(n,r.ui),n._showWatermarkOverlay&&n._showWatermarkOverlay(n.wrapper[0]),u.fn.endInit.call(n)},events:[p,m,h,re,ie,ae],options:{name:`PDFViewer`,view:{type:`canvas`},pdfjsProcessing:{file:null,renderForms:!1,loadOnDemand:!0},dplProcessing:{read:{url:null,type:`GET`,dataType:`json`,pageField:`pageNumber`},upload:{url:null,saveField:`file`},download:{url:null},loadOnDemand:!1},toolbar:{items:[],contextMenu:!1},width:1e3,height:1200,page:1,defaultPageSize:{width:794,height:1123},scale:null,zoomMin:.5,zoomMax:4,zoomRate:.25,messages:{defaultFileName:`Document`,toolbar:{zoom:{zoomLevel:`zoom level`,zoomOut:`Zoom Out`,zoomIn:`Zoom In`,actualWidth:`Actual Width`,autoWidth:`Automatic Width`,fitToWidth:`Fit to Width`,fitToPage:`Fit to Page`},contextMenu:`Menu`,open:`Open`,exportAs:`Export`,download:`Download`,print:`Print`,toggleSelection:`Enable Selection`,togglePan:`Enable Panning`,search:`Search`,annotations:`Annotations`},errorMessages:{notSupported:`Only pdf files allowed.`,parseError:`PDF file fails to process.`,notFound:`File is not found.`,popupBlocked:`Popup is blocked.`},dialogs:{exportAsDialog:{title:`Export...`,defaultFileName:`Document`,pdf:`Portable Document Format (.pdf)`,png:`Portable Network Graphics (.png)`,svg:`Scalable Vector Graphics (.svg)`,labels:{fileName:`File name`,saveAsType:`Save as`,page:`Page`}},okText:`OK`,save:`Save`,cancel:`Cancel`,search:{inputLabel:`Search Text`,matchCase:`Match Case`,next:`Next Match`,previous:`Previous Match`,close:`Close`,of:`of`,dragHandle:`Drag search`}}}},defaultTools:{contextMenu:{type:`dropDownButton`,name:`contextMenu`,showText:`overflow`,id:`pdfviewer-toolbar-context-menu`,overflow:`never`,icon:`menu`,fillMode:`flat`,menuButtons:[{id:`open`,text:`Open`,icon:`folder-open`,attributes:{"data-command":`OpenCommand`}},{id:`download`,text:`Download`,icon:`download`,attributes:{"data-command":`DownloadCommand`},enable:!1},{id:`print`,text:`Print`,icon:`print`,attributes:{"data-command":`PrintCommand`},enable:!1}]},separator:{type:`separator`},pager:{type:`component`,name:`pager`,overflow:`never`,component:`Pager`,element:`<div></div>`,componentOptions:{navigatable:!0,_isToolbarItem:!0}},spacer:{type:`spacer`},zoomInOut:{type:`buttonGroup`,fillMode:`flat`,buttons:[{type:`button`,icon:`zoom-out`,name:`zoomOut`,command:`ZoomCommand`,showText:`overflow`,options:`{ "zoomOut": true, "updateComboBox": true }`,fillMode:`flat`},{type:`button`,icon:`zoom-in`,name:`zoomIn`,command:`ZoomCommand`,showText:`overflow`,options:`{ "zoomIn": true, "updateComboBox": true }`,fillMode:`flat`}]},zoom:{type:`component`,name:`zoom`,command:`ZoomCommand`,overflow:`never`,component:`ComboBox`,data:[50,100,150,200,300,400],componentOptions:{enable:!1,dataTextField:`text`,dataValueField:`percent`,valuePrimitive:!0,clearOnEscape:!1,commandOn:`change`,fillMode:`flat`}},toggleSelection:{type:`buttonGroup`,fillMode:`flat`,buttons:[{togglable:!0,command:`EnableSelectionCommand`,icon:`pointer`,showText:`overflow`,name:`toggleSelection`,group:`toggle-pan`,fillMode:`flat`},{togglable:!0,command:`EnablePanCommand`,icon:`hand`,showText:`overflow`,name:`togglePan`,group:`toggle-pan`,selected:!0,fillMode:`flat`}]},spacer2:{type:`spacer`},search:{type:`button`,command:`OpenSearchCommand`,icon:`search`,name:`search`,showText:`overflow`,enable:!1,fillMode:`flat`},open:{type:`button`,showText:`overflow`,name:`open`,icon:`folder-open`,command:`OpenCommand`,fillMode:`flat`},download:{type:`button`,showText:`overflow`,name:`download`,icon:`download`,command:`DownloadCommand`,enable:!1,fillMode:`flat`},print:{type:`button`,showText:`overflow`,name:`print`,icon:`print`,command:`PrintCommand`,enable:!1,fillMode:`flat`},annotations:{togglable:!0,type:`button`,showText:`overflow`,name:`annotations`,icon:`edit-annotations`,command:`AnnotationsCommand`,enable:!1,fillMode:`flat`}},exportAsTool:{exportAs:{type:`button`,showText:`overflow`,name:`exportAs`,icon:`image-export`,command:`ExportCommand`,fillMode:`flat`}},_processMessages:function(){var t=this.options.messages.toolbar.zoom;e.isPlainObject(t)&&(this.options.messages.toolbar=e.extend({},this.options.messages.toolbar,t),this.options.messages.toolbar.zoom=t.zoomLevel||this.options.messages.toolbar.zoom)},_wrapper:function(){var e=this,t=e.options;e.wrapper=e.element,e.wrapper.width(t.width).height(t.height).addClass(me.viewer).on(ee,e,e._keydown.bind(e)),e._allowResize=e.options.scale===null,e._autoZoomScale=on,e.zoomScale=e.options.scale||e._autoZoomScale,e._resizeHandler=r.onResize(function(){e.resize()}),e._pageNum=e.options.page},_keydown:function(e){var t=[s.PLUS,s.NUMPAD_PLUS],n=[s.MINUS,s.NUMPAD_MINUS],r=[s.ZERO,s.NUMPAD_ZERO],i=!1,a={command:oe,options:{updateComboBox:!0}};!e.ctrlKey||this._blankPage||this.processingLib===pe.dpl||(t.includes(e.keyCode)?(a.options.zoomIn=!0,i=!0):n.includes(e.keyCode)?(a.options.zoomOut=!0,i=!0):r.includes(e.keyCode)&&(a.options.value=on,i=!0),i&&(this.execute(a),e.preventDefault()))},_handlePageChangeEvent:function(e){let t=this;t._pageChangeFromScroll||(this.activatePage(e.index,!1),t._showPagerInputLabels()),delete t._pageChangeFromScroll},_showPagerInputLabels:function(){let t=this.pager.element.find(`.k-pager-input`).children();if(t){let n=t.eq(0).add(t.eq(2));e(n).is(`:visible`)||n.show()}},_resizePager:function(){let e=this;if(!e.pager||!e.pager.options.responsive)return;let t=r._outerWidth(e.pager.element),n=Array.from(e.toolbar.element.children(`:not(.k-hidden):not(:has(.k-pager))`)),i=r._outerWidth(e.element),a=0,o=Number(e.toolbar.element.css(`gap`).replace(/(em|ex|%|px|cm|mm|in|pt|pc|ch|rem|vh|vw|vmin|vmax)$/,``));if(n.length>0){let e=0;for(let t=0;t<n.length;t++)e+=r._outerWidth(n[t])+o;e&&(a=e)}let s=e.pager.element.find(`.k-pager-nav`);if(t+a+o>i)for(var c=s.length-1;c>=0;c--)s.eq(c).addClass(`k-hidden`);if(t+a+o<i){let t=e.pager.element.find(`.k-hidden:not(.k-input-validation-icon)`);for(var c=0;c<t.length;c++)t.eq(c).removeClass(`k-hidden`)}e.pager.options.input&&e._showPagerInputLabels()},_initProcessor:function(e){var t=this,n=e.dplProcessing?t.options.dplProcessing:t.options.pdfjsProcessing;t.processingLib=e.dplProcessing?pe.dpl:pe.pdfjs,t._isDPLProcessor()?(t.processor=new r.pdfviewer[t.processingLib].processor(n,t),c=r.pdfviewer[t.processingLib].Page):te()},_isDPLProcessor:function(){return this.processingLib===pe.dpl},_hasPagerTool:function(e){let t=!1,n;for(let r=0;r<e.length;r++){let i=e[r];if(typeof i==`string`?(t=i.toLowerCase()===`pager`,n=r):i.type?(t=i.type.toLowerCase()===`pager`,n=r):i.name&&(t=i.name.toLowerCase()===`pager`,t&&delete i.name,n=r),t)break}return{hasPager:t,index:n}},_renderToolbar:function(){var t=this,n=t.options,i=a({},n.toolbar),o=i.items&&i.items.length?i.items:Object.keys(t.defaultTools);if(t.options.pdfjsProcessing.renderForms&&!i.items.length){let[e,n]=[...t.defaultTools.toggleSelection.buttons];e.selected=!0,n.selected=!1}let{hasPager:s,index:c}=t._hasPagerTool(o);if(o=t._processTools(o),s){let r=t.options.messages.toolbar.pager;r&&r.of&&(r.of=`${r.of} {0}`,r.pages&&(r.of=r.of+` `+r.pages,delete r.pages)),t.defaultTools.pager.componentOptions.messages=r,n.messages.toolbar.pager=`Pager`;let i=t.defaultTools.pager.componentOptions;typeof o[c]!=`string`&&(t.defaultTools.pager.componentOptions=e.extend(o[c],i),o[c]=t.defaultTools.pager)}i={defaultTools:e.extend({},t.defaultTools,t.exportAsTool),parentMessages:n.messages.toolbar,tools:o,resizable:!0,fillMode:`flat`,overflow:i.overflow};var l=e(`<div />`);return l.appendTo(t.element),t.toolbar=new r.ui.ToolBar(l,i),t.options.toolbar=t.toolbar.options,t.toolbar.bind(de,t._toolbarClick.bind(t)),t.toolbar.bind(v,t._toolbarClick.bind(t)),t.toolbar.bind(ue,t._toolbarClick.bind(t)),i.contextMenu&&t.toolbar.element.find(`[data-role=dropdownbutton]`).on(v,t._toolbarClick.bind(t)),s&&(t.pager=t.toolbar.element.find(`.k-pager`),t.pager.length>0&&(t.pager=t.pager.data(`kendoPager`)),t.pager.bind(ue,t._handlePageChangeEvent.bind(t))),t.bind({update:t._updateToolbar.bind(t)}),t.toolbar},_processTools:function(t){var n=this,r=n.options.toolbar,i=n.options.messages.toolbar;if(t=t.flatMap(t=>{if(t===`zoom`&&(t=n.defaultTools.zoom),t.name===`zoom`){t=e.extend({},n.defaultTools.zoom,t);var r=[{percent:he.auto,text:i.autoWidth},{percent:he.actual,text:i.actualWidth},{percent:he.fitToWidth,text:i.fitToWidth},{percent:he.fitToPage,text:i.fitToPage}],a=t.data.map(e=>({percent:e,text:e+`%`})),o=n.options.scale?n.options.scale*100+`%`:`auto`;r=r.concat(a),t.componentOptions.dataSource=r,t.componentOptions.value=o}return t}),r.contextMenu)t=t.filter(e=>e!==`open`&&e!==`download`&&e!==`print`);else{let e=t.findIndex(e=>e===`contextMenu`);e!==-1&&t.splice(e,1);let n=t.findIndex(e=>e===`separator`);n!==-1&&t.splice(n,1)}return t},_updateToolbar:function(e){var t={page:e.page||1,total:e.total||1},n=this.toolbar,r=n.element,i=r.find(`[data-command=ZoomCommand][data-role=combobox]`).data(`kendoComboBox`),a=r.find(`.k-focus`);a.length===0&&(a=r.find(`[tabindex=0]`).first(),a.length===0&&(a=n._getAllItems().first())),i&&(i.enable(!e.isBlank),e.action===`zoom`&&this._updateZoomComboBox(e.zoom)),(e.action===`pagechange`&&e.updatePager!==!1||e.isBlank)&&this.pager&&(e.updatePager&&(t.updatePager=!0),e.pageChangeFromScroll&&(t.pageChangeFromScroll=!0),this._updatePager(t)),this._updateOnBlank(e.isBlank),n._resetTabIndex(a)},_updateOnBlank:function(t){let n=this.toolbar,r=n.element,i=e(`#pdfviewer-toolbar-context-menu_buttonmenu`),a=r.find(`[data-command='DownloadCommand']`),o=r.find(`[data-command='PrintCommand']`);i.length&&(a=i.find(`[data-command='DownloadCommand']`),o=i.find(`[data-command='PrintCommand']`)),n.enable(r.find(`[data-command=EnableSelectionCommand]`).parent(),!t),n.enable(r.find(`button[data-command=ZoomCommand]`).parent(),!t),n.enable(r.find(`[data-command='OpenSearchCommand']`),!t),n.enable(a,!t),n.enable(o,!t)},_updatePager:function(e){let t=this;if(e.updatePager){let n=t.processingLib===`dpl`?t.document&&t.document.pages?t.document.pages:[]:t.pages??[],i=new r.data.DataSource({data:n??[],pageSize:1,page:e.page});t.pager.setDataSource(i),t._resizePager()}else t.pager.page()!==e.page&&(e.pageChangeFromScroll&&(t._pageChangeFromScroll=!0),t.pager.page(e.page));t._showPagerInputLabels(),t._togglePagerDisabledClass()},_togglePagerDisabledClass:function(){let e=this.pager;e.totalPages()<=1?e.element.addClass(fe):e.element.hasClass(fe)&&e.element.removeClass(fe)},_updateZoomComboBox:function(e){var t=e===he.auto||e===he.actual||e===he.fitToPage||e===he.fitToWidth,n=this.toolbar.element.find(`[data-command=ZoomCommand][data-role=combobox]`).data(`kendoComboBox`);t||(e=Math.round(e*100)+`%`),n&&n.value(e)},_toolbarClick:function(t){let n=e(t.target),r=n.data(`command`),i=n.data(`options`);!r&&!i&&(n=e(t.currentTarget),r=n.data(`command`),i=n.data(`options`)),i=a({},{value:n.val()},i),r&&this.execute({command:r,options:i})},_initErrorDialog:function(e){var t=this;return t._errorDialog||=(e=a(e,{messages:t.options.messages}),new r.pdfviewer.dialogs.ErrorDialog(e)._dialog),t._errorDialog},_renderPageContainer:function(){var t=this;t.pageContainer||(t.pageContainerWrapper=e(`<div />`),t.pageContainerWrapper.addClass(me.scroller),t.pageContainer=e(`<div class="k-pdf-viewer-pages" />`),t.pageContainer.attr(_,0),t.pageContainerWrapper.append(t.pageContainer),t.wrapper.append(t.pageContainerWrapper))},_triggerError:function(e){var t=this._initErrorDialog();a(e,{dialog:t}),this.pageContainer&&d(this.pageContainer,!1),!this.trigger(h,e)&&t.open().content(e.message)},_renderPages:function(){var e=this,t=e.document,n;if(e.pages=[],!t||!t.total){e._renderBlankPage();return}n=t.pages;for(var r=1;r<=t.total;r++){var i,o={processor:e.processor,number:r};n&&n.length&&(o=a(o,n[r-1])),i=new c(o,e),e.pages.push(i),e.pageContainer.append(i.element)}e.pdfScroller&&e.pdfScroller.enablePanEventsTracking(),e._attachContainerEvents(),e._getVisiblePagesCount(),e._updatePager({updatePager:!0})},_renderBlankPage:function(){this._blankPage=new l(this.options.defaultPageSize,this),this.pageContainer.append(this._blankPage.element),this._blankPage._initUpload(),this.trigger(g,{isBlank:!0})},_removeBlankPage:function(){this._blankPage&&=(this._blankPage.destroy(),this._blankPage.element.remove(),null)},_resize:function(){var e=this,t,n;if(e._allowResize){if(!e.pages||!e.pages.length){e._blankPage&&(n=t/e._blankPage.element.width(),e._blankPage.resize(n));return}e.toolbar&&e.toolbar.resize(!0),e._resizeHandler&&clearTimeout(e._resizeHandler),e._resizeHandler=setTimeout(e._resizePages.bind(e),100)}},_resizePages:function(){let t=this,n=t.pageContainer[0].clientWidth,r=t.pdfViewerCommon?.getPagesElements(),i=0;if(t.pages.forEach(function(t){let a=t.element?t.element.width():e(r[t._pageIndex]).width(),o=n/a;o>i&&(i=o)}),t._autoFit){t.zoom(t._autoFit,!0);return}i=Math.min(Math.max(i,t.options.zoomMin),on),i!=t.zoomScale&&(t.zoom(i,!0),t.zoomScale=i,t._allowResize=!0),t.pager&&t.pager.element&&t._resizePager()},_attachContainerEvents:function(){let e=this;e.pageContainer.addClass(me.enablePanning),e.pageContainerWrapper.bind(f,e._scroll.bind(e))},_scroll:function(e){var t=this,n=t.pageContainerWrapper.height(),r=t.pages.length,i=t._pageNum,a=i-1,o=i,s;if(t._preventScroll||!r){t._preventScroll=!1;return}t._scrollingStarted=!0;let c=ln(t.element[0]);if(t.pages[a],o=i+c-a,i!==o&&o>=1&&o<=r){if(s=t.pages[o-1].element,s.offset().top>n)return;t._pageNum=o,t._loadVisiblePages(),t.trigger(g,{action:ne,page:o,total:r,pageChangeFromScroll:!0})}},zoom:function(e,t){var n=this;if(!n._isDPLProcessor())return e?n.execute({command:oe,options:{value:e,updateComboBox:!t}}):n.zoomScale},execute:function(e){var t=a({viewer:this},e.options);return new r.pdfviewer[e.command](t).exec()},_loadDPLDocument:function(){var e=this,t=e.options.page;d(e.pageContainer,!0),e.processor.fetchDocument().done(function(n){e._clearPages(),e.document=n,e._renderPages(),e.resize(!0),n&&(t=t>=1&&t<=n.total?t:1,e.activatePage(t,!0)),e.pdfScroller&&e.pdfScroller.destroy(),e.pdfScroller=new Le(e.pageContainer[0].parentNode,{filter:`.k-page`,events:{}}),e.pdfScroller.enablePanEventsTracking(),d(e.pageContainer,!1)})},_loadPdfJSDocument:function(e){let t=this,n=t.options,r=n.page,i;if(i=e||n.pdfjsProcessing.file,!i){t._renderBlankPage();return}typeof i==`string`?i={url:i}:i instanceof ArrayBuffer&&(i={data:i}),t._removeBlankPage(),d(t.pageContainer,!0),t.pdfViewerCommon=new el(t.element[0],{loadOnDemand:t.options.pdfjsProcessing.loadOnDemand,loadOnDemandPageSize:1,zoomLevel:t.zoomScale,renderForms:t.options.pdfjsProcessing.renderForms,fileDescriptor:i,events:{pagesLoad:e=>{t.document=e.pdfDoc,t.pages=e.pdfPages,t.options.pdfjsProcessing.renderForms?ce(t.pdfViewerCommon,0):ce(t.pdfViewerCommon,1),t.activatePage(r,!0),t.trigger(g),t._currentPage>-1&&(t.pdfViewerCommon.scrollToPage({pageNumber:t._currentPage}),t._currentPage=null),d(t.pageContainer,!1)},pageRendered:e=>{t._preventRenderEvent||t.trigger(p,{page:e.page.pdfPage}),t._setPageNumberAttributes(),t._preventRenderEvent=!1},zoomStart:e=>{t._currentPage=t.pdfViewerCommon.getCurrentPageIndex()+1},zoomEnd:e=>{t.zoomScale=e.zoomLevel,t._updateZoomComboBox(e.zoomLevel),t.trigger(ie,{scale:e.zoomLevel})},printEnd:e=>{d(t.pageContainerWrapper,!1)},scroll:e=>{e.isPageChanged&&t.trigger(g,{action:ne,page:e.pageNumber,total:t.pages.length,pageChangeFromScroll:!0})},error:e=>{t._triggerError({error:e.message,message:t.options.messages.errorMessages.parseError})},annotationEditorToolBarShow:t.onAnnotationEditorToolBarShow.bind(t)}})},_enablePanning:function(){this.pdfViewerCommon.documentScroller.enablePanEventsTracking()},_disablePanning:function(){this.pdfViewerCommon.documentScroller.disablePanEventsTracking()},_setPageNumberAttributes:function(){this.pageContainer.find(`.k-page`).each((t,n)=>{e(n).attr(r.attr(`number`),t+1)})},loadPage:function(e){let t=this,n=t.pages&&t.pages[e-1];if(n)return t._isDPLProcessor()?n.load(t.zoomScale):Promise.resolve()},activatePage:function(e,t){let n=this;n.pages&&n.pages[e-1]&&(n._pageNum=e,n._isDPLProcessor()?(n._loadVisiblePages(),n._scrollToActivatedPage(e,t)):(n.pdfViewerCommon.activatePageNumber(e),n.trigger(g,{action:ne,page:e,total:n.pages.length,updatePager:t})))},_scrollToActivatedPage:function(e,t){let n=this,r=n.pageContainerWrapper;n._preventScroll=!0,Zt(r[0],e-1),n.trigger(g,{action:ne,page:e,total:n.pages.length,updatePager:t})},_getVisiblePagesCount:function(){for(var e=this,t=0,n=0,r=e._isDPLProcessor()?e.pageContainerWrapper[0].clientHeight:e.pageContainer[0].clientHeight,i=0;t<=r&&i<e.pages.length;)t+=e.pages[i].element.height(),n++,i++;e._visiblePagesCount=n},_loadVisiblePages:function(){var e=this.pages&&this.pages.length,t=Math.max(this._pageNum-this._visiblePagesCount,1),n=Math.min(this._pageNum+this._visiblePagesCount,e);this._visiblePages=this.pages.slice(t-1,n);for(var r=t;r<=n;r++)this.loadPage(r)},_loadAllPages:function(){let e=this.pages&&this.pages.length,t=[];for(var n=0;n<=e;n++)t.push(this.loadPage(n));return t},fromFile:function(t){let n=this;if(n._isDPLProcessor())n.zoomScale=n.options.scale||1.25,n.zoom(n.zoomScale,!0),n.trigger(g,{action:`zoom`,zoom:n.options.scale||`auto`}),n.processor._updateDocument(t),n._loadDPLDocument();else if(n.pdfViewerCommon){n.annotationsToolbar?.destroy(),se(n.pdfViewerCommon),n.toolbar.toggle(`[title='Annotations']`,!1),n.toolbar.toggle(`[title='Enable Selection']`,!1),n.toolbar.toggle(`[title='Enable Panning']`,!0);let r=e.isPlainObject(t)?t:{url:t};n.pdfViewerCommon.loadFile(r)}else n._loadPdfJSDocument(t)},exportImage:function(e){var t=this,n=e.page,i=t.pages[n-1]||t._blankPage,a=new o.Group;i.load();var s=r.drawing.Path.fromRect(new r.geometry.Rect([0,0],[i.width,i.height]),{fill:{color:le},stroke:null});d(t.pageContainer,!0),a.append(s,i.group),o.exportImage(a).done(function(n){d(t.pageContainer,!1),r.saveAs({dataURI:n,fileName:e.fileName,proxyURL:e.proxyURL||``,forceProxy:e.forceProxy,proxyTarget:e.proxyTarget})})},exportSVG:function(e){var t=this,n=e.page,i=t.pages[n-1]||t._blankPage;d(t.pageContainer,!0),i.load(),o.exportSVG(i.group).done(function(n){d(t.pageContainer,!1),r.saveAs({dataURI:n,fileName:e.fileName,proxyURL:e.proxyURL||``,forceProxy:e.forceProxy,proxyTarget:e.proxyTarget})})},setOptions:function(t){var n=this;(t.pdfjsProcessing||t.dplProcessing)&&n._initProcessor(t||{}),t=e.extend(n.options,t),u.fn.setOptions.call(n,t),t.page&&(n._pageNum=t.page,n.activatePage(t.page,!1)),t.width&&n.element.width(t.width),t.height&&n.element.height(t.height)},destroy:function(){this._resizeHandler&&r.unbindResize(this._resizeHandler),this._errorDialog&&this._errorDialog.destroy(),this._saveDialog&&this._saveDialog.destroy(),this._upload&&this._upload.destroy(),this.pager&&this.pager.destroy(),this.toolbar&&=(this.toolbar.unbind(),this.toolbar.destroy(),null),this.pages&&this.pages.length&&this._isDPLProcessor()&&(this.pages.forEach(function(e){e.destroy()}),this.pages=[]),this.pdfScroller&&this.pdfScroller.destroy(),this.pageContainer.off(n),this.pageContainerWrapper.off(n),u.fn.destroy.call(this)},_clearPages:function(){this.pages=[],this.document=null,this._pageNum=1,this.pageContainer.off(n),this.pageContainer.empty(),this.pdfScroller&&this.pdfScroller.destroy()},onAnnotationEditorToolBarShow:function(e){let t=this,n=e.annotationEditorMode,r=e.anchor,i=t.annotationPopup?.popup,a=e.source.firstSelectedEditor;if(!(i&&i.visible()&&!i._closing&&n===`freeText`))switch(t.annotationPopup&&=(t.annotationPopup.destroy(),t.annotationPopup.destroyEditor(),null),n){case`highlight`:t.annotationPopup=new ol(t,r,a);break;case`freeText`:t.annotationPopup=new sl(t,r,a);break}}});i.plugin(ge)})(window.kendo.jQuery);var ll=kendo;e.__meta__=cl,e.default=ll});
//# sourceMappingURL=kendo.pdfviewer.min.js.map