UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

3 lines 198 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("kendo.draggable.cmn.chunk.js"),require("kendo.file-saver.cmn.chunk.js"),require("kendo.common.cmn.chunk.js"),require("kendo.pdfjs.loader.js")):"function"==typeof define&&define.amd?define(["exports","kendo.draggable.cmn.chunk.min","kendo.file-saver.cmn.chunk.min","kendo.common.cmn.chunk.min","kendo.pdfjs.loader.min"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).kendo=t.kendo||{},t.kendo._globals=t.kendo._globals||{},t.kendo._globals.PdfviewerCommonCmnChunk={}),t.kendo._globals.DraggableCmnChunk,t.kendo._globals.FileSaverCmnChunk,t.kendo._globals.CommonCmnChunk,t.kendo._globals.PdfjsLoader)}(this,(function(t,e,i,s,n){const a=(...t)=>Object.assign(...t),o=t=>t&&"object"==typeof t&&!Array.isArray(t),r=(t,...e)=>{if(!e.length)return t;const i=e.shift();if(o(t)&&o(i))for(const e in i)"__proto__"!==e&&"constructor"!==e&&(i[e]instanceof p?t[e]=i[e]:i[e]instanceof HTMLElement||"dotNetInstance"===e||(s=i[e])&&window&&window.DotNet&&window.DotNet.DotNetObject&&s instanceof DotNet.DotNetObject||i[e]&&i[e].buffer&&i[e].buffer instanceof ArrayBuffer||o(i[e])&&Object.getPrototypeOf(i[e])!==Object.prototype?t[e]=i[e]:o(i[e])?(t[e]&&o(t[e])||a(t,{[e]:{}}),r(t[e],i[e])):a(t,{[e]:i[e]}));var s;return r(t,...e)},h=t=>"string"==typeof t,l=t=>(t=>void 0!==t)(t)&&(t=>null!==t)(t),d=function(){},c=(t,e)=>{const i=(e||document).createElement("template");i.innerHTML=t.trim();const s=i.content;return s.childNodes.length>1?s.childNodes:s.firstChild},u=t=>(null==t?void 0:t.startsWith("."))?t:`.${t}`,f=()=>{let t,e;const i=new Promise((function(i,s){t=i,e=s}));return i.resolve=t,i.reject=e,i};class p{constructor(t,e){this.options={events:{}},this.element=t,this.options=e}destroy(){this.element=null}extendOptions(t){this.options=r(this.options,t)}setOptions(t){this.options=t}trigger(t,e={}){const i={defaultPrevented:!1,preventDefault:()=>{i.defaultPrevented=!0}};return this.options.events&&"function"==typeof this.options.events[t]&&this.options.events[t](a(i,e,{sender:this})),i.defaultPrevented}}const g=function(t,e,i={}){let s,n,a,o,r=0;const h=function(){r=!1===i.leading?0:(new Date).getTime(),s=void 0,o=t.apply(n,a),s||(n=a=null)};return function(){const l=(new Date).getTime();r||!1!==i.leading||(r=l);const d=e-(l-r);return n=void 0,a=arguments,d<=0||d>e?(s&&(clearTimeout(s),s=void 0),r=l,o=t.apply(n,a),s||(n=a=null)):s||!1===i.trailing||(s=window.setTimeout(h,d)),o}},m=1e3/60,v="scroll";class y extends p{constructor(t,e){super(t,e),this.options={events:{[v]:d},filter:"",panScrollThrottleDelay:m,scrollDirectionModifier:-1,scrollThrottleDelay:m},this.onElementScroll=t=>{const e=this.element;this.shouldTrackScrollEvents()&&(this.state.trackNextElementScroll?this.scrollTo(e.scrollLeft,e.scrollTop):this.state.trackNextElementScroll=!0,this.trigger(v,{originalEvent:t}))},this.onDragStart=t=>{if(this.state.dragStarted=!1,!this.shouldTrackPanEvents())return;const e=t.target||(t.originalEvent||{}).target;this.options.filter&&!((t,e)=>!(!t||!e)&&t.closest(e))(e,this.options.filter)||((t=>{t.preventDefault&&t.preventDefault(),t.originalEvent&&t.originalEvent.preventDefault()})(t),this.setState({dragStarted:!0,location:{pageX:t.pageX,pageY:t.pageY},locationDelta:{x:0,y:0}}))},this.onDrag=t=>{if(!this.shouldTrackPanEvents()||!this.state.dragStarted)return;this.calculateEventLocationDelta(t),this.setState({location:{pageX:t.pageX,pageY:t.pageY}});const e=this.options.scrollDirectionModifier,i=this.element.scrollLeft+e*this.state.locationDelta.x,s=this.element.scrollTop+e*this.state.locationDelta.y;this.scrollTo(i,s)},this.onDragEnd=()=>{},this.extendOptions(e),this.resetState(),this.bindEvents()}destroy(){this.unbindEvents()}initDraggable(){this.destroyDraggable(),this.options.panScrollThrottleDelay>0?this.throttledOnDrag=g(this.onDrag,this.options.panScrollThrottleDelay):this.throttledOnDrag=this.onDrag,this.draggable=new e.D({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=g(this.onElementScroll,this.options.scrollThrottleDelay):this.throttledOnElementScroll=this.onElementScroll,this.element.addEventListener(v,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(v,this.throttledOnElementScroll)}setState(t){this.state=Object.assign({},this.state||{},t)}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(t){this.state.locationDelta={x:t.pageX-this.state.location.pageX,y:t.pageY-this.state.location.pageY}}scrollTo(t,e,i={trackScrollEvent:!0}){i.trackScrollEvent||(this.state.trackNextElementScroll=!1),this.element.scrollLeft=t,this.element.scrollTop=e}}const E=t=>{const e=t.parentElement;t&&e&&e.replaceWith(...Array.from(e.childNodes))},w=t=>`.${t}`,b="data-char-index",S="data-match-index";class M{constructor(t){this.options={highlightClass:"k-search-highlight",highlightMarkClass:"k-search-highlight-mark",charClass:"k-text-char",textContainers:[]},this.extendOptions(t),this.resetState()}destroy(){this.clearSearch(),this.resetState()}extendOptions(t){this.options=Object.assign({},this.options,t)}setState(t){this.state=Object.assign({},this.state||{},t)}resetState(){this.setState({text:"",textNodes:[],charIndex:0,activeMatchIndex:0,matches:[]})}escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}search({text:t,matchCase:e}){const i=this.escapeRegExp(t),s=new RegExp(i,e?"g":"ig");let n;if(this.shouldTransformText()&&this.transformTextForSearch(),this.state.matches=[],this.state.activeMatchIndex=0,this.removeIndicators(),""===i)return[];for(n=s.exec(this.state.text);n;)this.state.matches.push({startOffset:n.index,endOffset:n.index+n[0].length}),n=s.exec(this.state.text);return this.highlightAllMatches(),this.addActiveMatchMark(),this.state.matches}clearSearch(){this.removeIndicators(),this.restoreOriginalText()}restoreOriginalText(){this.forEachTextContainer((t=>{Array.from(t.querySelectorAll("span:not(."+this.options.charClass+")")).forEach((t=>{t.innerHTML=t.textContent}))}))}shouldTransformText(){return!this.state.text}transformTextForSearch(){this.state.textNodes=[],this.state.charIndex=0,this.state.text="",this.forEachTextContainer((t=>{this.extractTextNodes(t)})),this.transformTextNodesForSearch(this.state.textNodes)}extractTextNodes(t){if(t.nodeType===Node.TEXT_NODE)this.state.textNodes.push(t);else for(let e=0;e<t.childNodes.length;e++)this.extractTextNodes(t.childNodes[e])}transformTextNodesForSearch(t){for(let e=0;e<t.length;e++)this.transformTextNodeForSearch(t[e])}transformTextNodeForSearch(t){const e=t.textContent;if(e.length<=0)return;this.state.text=this.state.text+e;const i=document.createElement("span");var s,n;n=i,(s=t).parentNode&&(s.parentNode.insertBefore(n,s),n.appendChild(s));const a=this.splitTextByChars(e);i.innerHTML=a,E(i.childNodes[0])}splitTextByChars(t){let e="";for(let i=0;i<t.length;i++)e+=`<span class='${this.options.charClass}' ${b}=${this.state.charIndex}>${t[i]}</span>`,this.state.charIndex++;return e}forEachTextContainer(t){for(let e=0;e<this.options.textContainers.length;e++){t(this.options.textContainers[e],e)}}highlightAllMatches(){this.state.matches.forEach(((t,e)=>{this.addMatchHighlight(t.startOffset,t.endOffset,e)}))}addMatchHighlight(t,e,i){for(let s=t;s<e;s++)this.forEachTextContainer((t=>{Array.from(t.querySelectorAll(w(`${this.options.charClass}[${b}='${s}']`))).forEach((t=>{var e;e=this.options.highlightClass,t.classList.add(e),t.setAttribute(S,i)}))}))}removeMatchHighlights(){this.forEachTextContainer((t=>{Array.from(t.querySelectorAll(w(this.options.highlightClass))).forEach((t=>{var e;e=this.options.highlightClass,t.classList.remove(e),t.removeAttribute(S)}))}))}addActiveMatchMark(){this.state.activeMatchIndex||0===this.state.activeMatchIndex?this.state.activeMatchIndex>this.state.matches.length?this.state.activeMatchIndex=this.state.matches.length:this.removeActiveMatchMark():this.state.activeMatchIndex=0;const t=document.createElement("span");t.classList.add(this.options.highlightMarkClass),this.forEachTextContainer((e=>{Array.from(e.querySelectorAll(w(this.options.charClass+"["+S+"='"+this.state.activeMatchIndex+"']"))).forEach((e=>{((t,e)=>{if(t&&t.parentNode&&e)for(t.appendChild(e);t.firstChild&&t.firstChild!==e;)e.appendChild(t.firstChild)})(e,t.cloneNode(!0))}))}))}removeActiveMatchMark(){this.forEachTextContainer((t=>{(t=>{if(t&&t.length&&!(t.length<=0))for(let e=0;e<t.length;e++)E(t[e])})(Array.from(t.querySelectorAll(w(this.options.highlightMarkClass))).flatMap((t=>Array.from(t.childNodes))))}))}removeIndicators(){this.removeActiveMatchMark(),this.removeMatchHighlights()}markNextMatch(){this.markNextMatchIndex(),this.addActiveMatchMark()}markPreviousMatch(){this.markPreviousMatchIndex(),this.addActiveMatchMark()}markNextMatchIndex(){this.moveActiveMatchIndex(1)}markPreviousMatchIndex(){this.moveActiveMatchIndex(-1)}moveActiveMatchIndex(t){this.state.activeMatchIndex+=t,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 t;return this.forEachTextContainer((e=>{const i=e.querySelector(w(this.options.highlightMarkClass));i&&(t=i)})),t}}const x=268435456,k=(t=3)=>/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/i.test(navigator.userAgent)?devicePixelRatio:devicePixelRatio*(t||3),A=t=>atob(t.replace(/^(data:application\/pdf;base64,)/gi,"")),T=function(t,e,i){const s=document.createElement(t);return e&&(s.className=e),Object.keys(i).forEach((t=>s.style[t]=i[t])),s},P=(t,e)=>{const i=t.querySelectorAll(".k-page"),s=i[0];if(s instanceof HTMLDivElement){const t=(s.offsetHeight+s.offsetTop)*Math.max(0,Math.min(e,i.length-1)),n=s.closest(".k-pdf-viewer-canvas");n&&n.scrollTo({top:t,behavior:"auto"})}},L=t=>{const e=t.querySelector(".k-pdf-viewer-canvas"),i=t.querySelector(".k-page:not(.k-blank-page)");return e&&i?Math.floor(Math.round(e.scrollTop)/Math.max(1,i.offsetHeight+i.offsetTop)+.01):0},_=(t,e)=>{const{maxWidth:i,maxHeight:n,maxArea:a}=(t=>{const e=s.d(t),i=s.a(t);return e&&e.mozilla||i&&"firefox"===i.browser})(navigator.userAgent)?{maxWidth:32767,maxHeight:32767,maxArea:124992400}:(o=navigator.userAgent,s.d(o).safari||s.a(o)&&"mobilesafari"===s.a(o).browser?{maxWidth:4194303,maxHeight:8388607,maxArea:x}:{maxWidth:65535,maxHeight:65535,maxArea:x});var o;let r=t,h=e;const l=t/e;if(t>i){r=i;h=e-(t-i)/l}if(h>n){const t=h-n;h=n,r-=t*l}const d=r*h;if(d>a){const t=Math.sqrt(a/d);r*=t,h*=t}const c=r/t;return{adjustedWidth:r!==t?Math.floor(r/2):t,adjustedHeight:h!==e?Math.floor(h/2):e,adjustRatio:1!==c?c/2:1}};function C(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{h(s.next(t))}catch(t){a(t)}}function r(t){try{h(s.throw(t))}catch(t){a(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}h((s=s.apply(t,e||[])).next())}))}Object.create;Object.create;function D(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)}function I(t,e,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(t,i):n?n.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;const N=(t,e)=>{e.classList.add(t)},O=(t,e)=>{e.classList.remove(t)},W=(t,e,i)=>Math.min(i,Math.max(e,t)),F=1.35,H=1,B=2,V="pdfjs_internal_editor_",R=3,z=9,$=2,U=3,j=9,G=16,K=20,X=1,q=2,Z=3,Y=4,J=5;function Q(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const tt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class et{static makeHexColor(t,e,i){return`${tt[t]}${tt[e]}${tt[i]}`}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}}const it="pdfjs_internal_id_";var st,nt,at,ot,rt,ht,lt,dt,ct,ut,ft,pt,gt,mt,vt,yt,Et,wt,bt,St,Mt,xt,kt,At,Tt,Pt,Lt,_t,Ct,Dt,It,Nt,Ot,Wt,Ft,Ht,Bt,Vt,Rt,zt,$t,Ut,jt,Gt,Kt,Xt,qt,Zt,Yt,Jt,Qt,te,ee,ie,se,ne,ae,oe,re;class he{constructor(t=V){st.set(this,0),this.idPrefix=V,Object.defineProperty(this,"reset",{value:()=>I(this,st,0,"f")}),this.idPrefix=t}get id(){var t,e;return`${this.idPrefix}${I(this,st,(e=D(this,st,"f"),t=e++,e),"f"),t}`}}st=new WeakMap;class le{constructor(t=128){nt.set(this,[]),at.set(this,!1),ot.set(this,void 0),rt.set(this,-1),I(this,ot,t,"f")}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(s&&t(),D(this,at,"f"))return;const r={cmd:t,undo:e,post:i,type:n};if(-1===D(this,rt,"f"))return D(this,nt,"f").length>0&&(D(this,nt,"f").length=0),I(this,rt,0,"f"),void D(this,nt,"f").push(r);if(a&&D(this,nt,"f")[D(this,rt,"f")].type===n)return o&&(r.undo=D(this,nt,"f")[D(this,rt,"f")].undo),void(D(this,nt,"f")[D(this,rt,"f")]=r);const h=D(this,rt,"f")+1;h===D(this,ot,"f")?D(this,nt,"f").splice(0,1):(I(this,rt,h,"f"),h<D(this,nt,"f").length&&D(this,nt,"f").splice(h)),D(this,nt,"f").push(r)}undo(){if(-1===D(this,rt,"f"))return;I(this,at,!0,"f");const{undo:t,post:e}=D(this,nt,"f")[D(this,rt,"f")];t(),null==e||e(),I(this,at,!1,"f"),I(this,rt,D(this,rt,"f")-1,"f")}redo(){if(D(this,rt,"f")<D(this,nt,"f").length-1){I(this,rt,D(this,rt,"f")+1,"f"),I(this,at,!0,"f");const{cmd:t,post:e}=D(this,nt,"f")[D(this,rt,"f")];t(),null==e||e(),I(this,at,!1,"f")}}hasSomethingToUndo(){return-1!==D(this,rt,"f")}hasSomethingToRedo(){return D(this,rt,"f")<D(this,nt,"f").length-1}destroy(){I(this,nt,null,"f")}}nt=new WeakMap,at=new WeakMap,ot=new WeakMap,rt=new WeakMap;class de{constructor({container:t=null,viewer:e,pdfViewer:i,eventBus:s,pdfDocument:a,highlightColors:o=""}){ht.add(this),this.pdfViewer=null,this.annotationEditorMode=n.AnnotationEditorType.NONE,this.viewParameters={},this.isShiftKeyDown=!1,this._eventBus=null,lt.set(this,new AbortController),dt.set(this,null),ct.set(this,new Map),ut.set(this,new Map),ft.set(this,null),pt.set(this,null),gt.set(this,new le),mt.set(this,0),vt.set(this,new Set),yt.set(this,null),Et.set(this,null),wt.set(this,new Set),bt.set(this,!0),St.set(this,null),Mt.set(this,null),xt.set(this,""),kt.set(this,!1),At.set(this,null),Tt.set(this,new he),Pt.set(this,!1),Lt.set(this,!1),_t.set(this,null),Ct.set(this,n.AnnotationEditorType.NONE),Dt.set(this,new Set),It.set(this,null),Nt.set(this,null),Ot.set(this,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),Wt.set(this,[0,0]),Ft.set(this,null),Ht.set(this,null),Bt.set(this,null);const r=this._signal=D(this,lt,"f").signal;I(this,Ht,t,"f"),I(this,Bt,e,"f"),this.pdfViewer=i,this._eventBus=s,this._eventBus._on("editingaction",this.onEditingAction.bind(this),{signal:r}),this._eventBus._on("pagechanging",this.onPageChanging.bind(this),{signal:r}),this._eventBus._on("scalechanging",this.onScaleChanging.bind(this),{signal:r}),this._eventBus._on("rotationchanging",this.onRotationChanging.bind(this),{signal:r}),this._eventBus._on("setpreference",this.onSetPreference.bind(this),{signal:r}),this._eventBus._on("namedaction",this.onNamedAction.bind(this),{signal:r}),D(this,ht,"m",jt).call(this),D(this,ht,"m",Jt).call(this),D(this,ht,"m",Xt).call(this),I(this,ft,a.annotationStorage,"f"),I(this,xt,o||"","f"),this.viewParameters={realScale:n.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}destroy(){var t;null===(t=D(this,lt,"f"))||void 0===t||t.abort(),I(this,lt,null,"f"),this._signal=null;for(const t of D(this,ut,"f").values())t.destroy();D(this,ut,"f").clear(),D(this,ct,"f").clear(),D(this,wt,"f").clear(),I(this,dt,null,"f"),D(this,Dt,"f").clear(),D(this,gt,"f").destroy(),D(this,St,"f")&&(clearTimeout(D(this,St,"f")),I(this,St,null,"f")),D(this,Ft,"f")&&(clearTimeout(D(this,Ft,"f")),I(this,Ft,null,"f"))}getTextLayerForAnchor(t){return t?t.closest(".textLayer")||t.closest(".k-text-layer"):null}combinedSignal(t){return AbortSignal&&AbortSignal.any?AbortSignal.any([this._signal,t.signal]):this._signal||t.signal}get direction(){return n.shadow(this,"direction",getComputedStyle(D(this,Ht,"f")).direction)}get highlightColors(){return n.shadow(this,"highlightColors",D(this,xt,"f")?new Map:null)}get highlightColorNames(){return n.shadow(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,mode:t}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t}){t}onNamedAction(t){switch(t.action){case"Print":this.triggerPrinting();break;case"SaveAs":this.downloadOrSave()}}onPageChanging({pageNumber:t}){I(this,mt,t-1,"f")}focusMainContainer(){var t;null===(t=D(this,Ht,"f"))||void 0===t||t.focus()}findParent(t,e){for(const i of D(this,ut,"f").values()){const{x:s,y:n,width:a,height:o}=i.div.getBoundingClientRect();if(t>=s&&t<=s+a&&e>=n&&e<=n+o)return i}return null}triggerPrinting(){var t;null===(t=this.pdfViewer)||void 0===t||t.printFile()}downloadOrSave(){var t,e;null===(t=this.pdfViewer)||void 0===t||t.downloadFile({fileName:null===(e=this.pdfViewer)||void 0===e?void 0:e.options.downloadFileName})}disableUserSelect(t=!1){var e;null===(e=D(this,Bt,"f"))||void 0===e||e.classList.toggle("noUserSelect",t)}addShouldRescale(t){D(this,wt,"f").add(t)}removeShouldRescale(t){D(this,wt,"f").delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*n.PixelsPerInch.PDF_TO_CSS_UNITS;for(const t of D(this,wt,"f"))t.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:a,focusOffset:o}=e,r=e.toString(),h=D(this,ht,"m",Vt).call(this,e),l=this.getTextLayerForAnchor(h),d=this.getSelectionBoxes(l);if(!d)return;e.empty();const c=D(this,ht,"m",Rt).call(this,l),u=D(this,Ct,"f")===n.AnnotationEditorType.NONE,f=()=>{null==c||c.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:i,anchorOffset:s,focusNode:a,focusOffset:o,text:r}),u&&this.showAllEditors("highlight",!0)};u?this.switchToMode(n.AnnotationEditorType.HIGHLIGHT,f):f()}showEditorToolBar(t){if(!t)return;const e=this.getMode();e!==n.AnnotationEditorType.HIGHLIGHT&&e!==n.AnnotationEditorType.FREETEXT||this._eventBus.dispatch("kendoAnnotationEditorToolBarShow",{source:this,anchor:t})}hideEditorToolBar(){this._eventBus.dispatch("kendoAnnotationEditorToolBarHide",{source:this})}addToAnnotationStorage(t){t.isEmpty()||!D(this,ft,"f")||D(this,ft,"f").has(t.id)||D(this,ft,"f").setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,D(this,kt,"f")&&(I(this,kt,!1,"f"),D(this,ht,"m",Ut).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of D(this,Dt,"f"))if(e.div.contains(t)){I(this,_t,[e,t],"f"),e._focusEventsAllowed=!1;break}}focus(){if(!D(this,_t,"f"))return;const[t,e]=D(this,_t,"f");I(this,_t,null,"f"),e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}addEditListeners(){D(this,ht,"m",Xt).call(this),D(this,ht,"m",Zt).call(this)}removeEditListeners(){D(this,ht,"m",qt).call(this),D(this,ht,"m",Yt).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of D(this,Et,"f"))if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of D(this,Et,"f"))if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){var e;if(t.preventDefault(),null===(e=D(this,dt,"f"))||void 0===e||e.commitOrRemove(),!this.hasSelection)return;const i=[];for(const t of D(this,Dt,"f")){const e=t.serialize(!0);e&&i.push(e)}0!==i.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(i))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of D(this,Et,"f"))if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const e of i){const i=s.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)D(this,ht,"m",se).call(this,e);D(this,ht,"m",oe).call(this,t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(t){}}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}setEditingState(t){t?(D(this,ht,"m",Gt).call(this),D(this,ht,"m",Zt).call(this),D(this,ht,"m",Qt).call(this,{isEditing:D(this,Ct,"f")!==n.AnnotationEditorType.NONE,isEmpty:D(this,ht,"m",ae).call(this),hasSomethingToUndo:D(this,gt,"f").hasSomethingToUndo(),hasSomethingToRedo:D(this,gt,"f").hasSomethingToRedo(),hasSelectedEditor:!1})):(D(this,ht,"m",Kt).call(this),D(this,ht,"m",Yt).call(this),D(this,ht,"m",Qt).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!D(this,Et,"f")){I(this,Et,t,"f");for(const t of D(this,Et,"f"))D(this,ht,"m",te).call(this,t.defaultPropertiesToUpdate)}}getId(){return D(this,Tt,"f").id}get currentLayer(){return D(this,ut,"f").get(D(this,mt,"f"))}getLayer(t){return D(this,ut,"f").get(t)}get currentPageIndex(){return D(this,mt,"f")}addLayer(t){D(this,ut,"f").set(t.pageIndex,t),D(this,Pt,"f")?t.enable():t.disable()}removeLayer(t){D(this,ut,"f").delete(t.pageIndex)}updateMode(t,e=null,i=!1){if(D(this,Ct,"f")!==t){if(I(this,Ct,t,"f"),t===n.AnnotationEditorType.NONE)return this.setEditingState(!1),void D(this,ht,"m",ie).call(this);this.setEditingState(!0),D(this,ht,"m",ee).call(this),this.unselectAll();for(const e of D(this,ut,"f").values())e.updateMode(t);if(e||!i){if(e)for(const t of D(this,ct,"f").values())if(t.annotationElementId===e){this.setSelected(t),t.enterInEditMode();break}}else this.addNewEditorFromKeyboard()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==D(this,Ct,"f")&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(D(this,Et,"f")){switch(t){case n.AnnotationEditorParamsType.CREATE:return void this.currentLayer.addNewEditor();case n.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:break;case n.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:I(this,Nt,D(this,Nt,"f")||new Map,"f").set(t,e),this.showAllEditors("highlight",e)}for(const i of D(this,Dt,"f"))i.updateParams(t,e);for(const i of D(this,Et,"f"))i.updateDefaultParams(t,e)}}showAllEditors(t,e){var i,s;for(const i of D(this,ct,"f").values())i.editorType===t&&i.show(e);(null===(s=null===(i=D(this,Nt,"f"))||void 0===i?void 0:i.get(n.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL))||void 0===s||s)!==e&&D(this,ht,"m",te).call(this,[[n.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(D(this,Lt,"f")!==t){I(this,Lt,t,"f");for(const e of D(this,ut,"f").values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const i of D(this,ct,"f").values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return D(this,ct,"f").get(t)}addEditor(t){D(this,ct,"f").set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(D(this,St,"f")&&clearTimeout(D(this,St,"f")),I(this,St,setTimeout((()=>{this.focusMainContainer(),I(this,St,null,"f")}),0),"f")),D(this,ct,"f").delete(t.id),this.unselect(t),t.annotationElementId&&D(this,vt,"f").has(t.annotationElementId)||null===(e=D(this,ft,"f"))||void 0===e||e.remove(t.id)}addDeletedAnnotationElement(t){D(this,vt,"f").add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return D(this,vt,"f").has(t)}removeDeletedAnnotationElement(t){D(this,vt,"f").delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){D(this,dt,"f")!==t&&(I(this,dt,t,"f"),t&&D(this,ht,"m",te).call(this,t.propertiesToUpdate))}updateUI(t){D(this,ht,"a",ne)===t&&D(this,ht,"m",te).call(this,t.propertiesToUpdate)}toggleSelected(t){if(D(this,Dt,"f").has(t))return D(this,Dt,"f").delete(t),t.unselect(),void D(this,ht,"m",Qt).call(this,{hasSelectedEditor:this.hasSelection});D(this,Dt,"f").add(t),t.select(),D(this,ht,"m",te).call(this,t.propertiesToUpdate),D(this,ht,"m",Qt).call(this,{hasSelectedEditor:!0})}setSelected(t){for(const e of D(this,Dt,"f"))e!==t&&e.unselect();D(this,Dt,"f").clear(),D(this,Dt,"f").add(t),t.select(),D(this,ht,"m",te).call(this,t.propertiesToUpdate),D(this,ht,"m",Qt).call(this,{hasSelectedEditor:!0})}isSelected(t){return D(this,Dt,"f").has(t)}get firstSelectedEditor(){return D(this,Dt,"f").values().next().value}unselect(t){t.unselect(),D(this,Dt,"f").delete(t),D(this,ht,"m",Qt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==D(this,Dt,"f").size}get isEnterHandled(){return 1===D(this,Dt,"f").size&&this.firstSelectedEditor.isEnterHandled}undo(){D(this,gt,"f").undo(),D(this,ht,"m",Qt).call(this,{hasSomethingToUndo:D(this,gt,"f").hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:D(this,ht,"m",ae).call(this)})}redo(){D(this,gt,"f").redo(),D(this,ht,"m",Qt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:D(this,gt,"f").hasSomethingToRedo(),isEmpty:D(this,ht,"m",ae).call(this)})}addCommands(t){D(this,gt,"f").add(t),D(this,ht,"m",Qt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:D(this,ht,"m",ae).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...D(this,Dt,"f")];this.addCommands({cmd:()=>{for(const e of t)e.remove()},undo:()=>{for(const e of t)D(this,ht,"m",se).call(this,e)},mustExec:!0})}commitOrRemove(){var t;null===(t=D(this,dt,"f"))||void 0===t||t.commitOrRemove()}hasSomethingToControl(){return D(this,dt,"f")||this.hasSelection}selectAll(){for(const t of D(this,Dt,"f"))t.commit();D(this,ht,"m",oe).call(this,D(this,ct,"f").values())}unselectAll(){if((!D(this,dt,"f")||(D(this,dt,"f").commitOrRemove(),D(this,Ct,"f")===n.AnnotationEditorType.NONE))&&this.hasSelection){for(const t of D(this,Dt,"f"))t.unselect();D(this,Dt,"f").clear(),D(this,ht,"m",Qt).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;D(this,Wt,"f")[0]+=t,D(this,Wt,"f")[1]+=e;const[s,n]=D(this,Wt,"f"),a=[...D(this,Dt,"f")];D(this,Ft,"f")&&clearTimeout(D(this,Ft,"f")),I(this,Ft,setTimeout((()=>{I(this,Ft,null,"f"),D(this,Wt,"f")[0]=D(this,Wt,"f")[1]=0,this.addCommands({cmd:()=>{for(const t of a)D(this,ct,"f").has(t.id)&&t.translateInPage(s,n)},undo:()=>{for(const t of a)D(this,ct,"f").has(t.id)&&t.translateInPage(-s,-n)},mustExec:!1})}),1e3),"f");for(const i of a)i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),I(this,yt,new Map,"f");for(const t of D(this,Dt,"f"))D(this,yt,"f").set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!D(this,yt,"f"))return!1;this.disableUserSelect(!1);const t=D(this,yt,"f");I(this,yt,null,"f");let e=!1;for(const[{x:i,y:s,pageIndex:n},a]of t)a.newX=i,a.newY=s,a.newPageIndex=n,e||(e=i!==a.savedX||s!==a.savedY||n!==a.savedPageIndex);if(!e)return!1;const i=(t,e,i,s)=>{if(D(this,ct,"f").has(t.id)){const n=D(this,ut,"f").get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex:a}]of t)i(e,s,n,a)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:a}]of t)i(e,s,n,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(D(this,yt,"f"))for(const i of D(this,yt,"f").keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}isActive(t){return D(this,dt,"f")===t}getActive(){return D(this,dt,"f")}getActiveEditor(){return D(this,dt,"f")}getMode(){return D(this,Ct,"f")}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,s=e.rangeCount;i<s;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(t,e,o,r)=>({x:(e-s)/a,y:1-(t+o-i)/n,width:r/a,height:o/n});break;case"180":o=(t,e,o,r)=>({x:1-(t+o-i)/n,y:1-(e+r-s)/a,width:o/n,height:r/a});break;case"270":o=(t,e,o,r)=>({x:1-(e+r-s)/a,y:(t-i)/n,width:r/a,height:o/n});break;default:o=(t,e,o,r)=>({x:(t-i)/n,y:(e-s)/a,width:o/n,height:r/a})}const r=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(!i.collapsed)for(const{x:t,y:e,width:s,height:n}of i.getClientRects())0!==s&&0!==n&&r.push(o(t,e,s,n))}return 0===r.length?null:r}addChangedExistingAnnotation({annotationElementId:t,id:e}){I(this,pt,D(this,pt,"f")||new Map,"f").set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;null===(e=D(this,pt,"f"))||void 0===e||e.delete(t)}renderAnnotationElement(t){var e;const i=null===(e=D(this,pt,"f"))||void 0===e?void 0:e.get(t.data.id);if(!i)return;const s=D(this,ft,"f").getRawValue(i);s&&(D(this,Ct,"f")!==n.AnnotationEditorType.NONE||s.hasBeenModified)&&s.renderAnnotationElement(t)}}lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ut=new WeakMap,ft=new WeakMap,pt=new WeakMap,gt=new WeakMap,mt=new WeakMap,vt=new WeakMap,yt=new WeakMap,Et=new WeakMap,wt=new WeakMap,bt=new WeakMap,St=new WeakMap,Mt=new WeakMap,xt=new WeakMap,kt=new WeakMap,At=new WeakMap,Tt=new WeakMap,Pt=new WeakMap,Lt=new WeakMap,_t=new WeakMap,Ct=new WeakMap,Dt=new WeakMap,It=new WeakMap,Nt=new WeakMap,Ot=new WeakMap,Wt=new WeakMap,Ft=new WeakMap,Ht=new WeakMap,Bt=new WeakMap,ht=new WeakSet,Vt=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Rt=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of D(this,ut,"f").values())if(e.hasTextLayer(t))return e;return null},zt=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=D(this,ht,"m",Vt).call(this,t),i=this.getTextLayerForAnchor(e);this.getSelectionBoxes(i)&&this.showEditorToolBar(e)},$t=function(){var t,e;const i=document.getSelection();if(!i||i.isCollapsed)return void(D(this,It,"f")&&(I(this,It,null,"f"),D(this,ht,"m",Qt).call(this,{hasSelectedText:!1})));const{anchorNode:s}=i;if(s===D(this,It,"f"))return;const a=D(this,ht,"m",Vt).call(this,i),o=this.getTextLayerForAnchor(a);if(o){if(null===(e=D(this,At,"f"))||void 0===e||e.hide(),I(this,It,s,"f"),D(this,ht,"m",Qt).call(this,{hasSelectedText:!0}),(D(this,Ct,"f")===n.AnnotationEditorType.HIGHLIGHT||D(this,Ct,"f")===n.AnnotationEditorType.NONE)&&(D(this,Ct,"f")===n.AnnotationEditorType.HIGHLIGHT&&this.showAllEditors("highlight",!0),!this.isShiftKeyDown)){const t=D(this,Ct,"f")===n.AnnotationEditorType.HIGHLIGHT?D(this,ht,"m",Rt).call(this,o):null;null==t||t.toggleDrawing();const e=new AbortController,i=this.combinedSignal(e),s=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),null==t||t.toggleDrawing(!0),"pointerup"===i.type&&D(this,ht,"m",Ut).call(this,"main_toolbar"))};window.removeEventListener("pointerup",s),window.addEventListener("pointerup",s,{signal:i}),window.removeEventListener("blur",s),window.addEventListener("blur",s,{signal:i})}}else D(this,It,"f")&&(null===(t=D(this,At,"f"))||void 0===t||t.hide(),I(this,It,null,"f"),D(this,ht,"m",Qt).call(this,{hasSelectedText:!1}))},Ut=function(t=""){D(this,Ct,"f")===n.AnnotationEditorType.HIGHLIGHT?this.highlightSelection(t):D(this,bt,"f")&&D(this,ht,"m",zt).call(this)},jt=function(){document.addEventListener("selectionchange",D(this,ht,"m",$t).bind(this),{signal:this._signal})},Gt=function(){if(D(this,Mt,"f"))return;I(this,Mt,new AbortController,"f");const t=this.combinedSignal(D(this,Mt,"f"));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Kt=function(){var t;null===(t=D(this,Mt,"f"))||void 0===t||t.abort(),I(this,Mt,null,"f")},Xt=function(){},qt=function(){},Zt=function(){},Yt=function(){},Jt=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Qt=function(t){if(!t)return;Object.entries(t).some((([t,e])=>D(this,Ot,"f")[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(D(this,Ot,"f"),t)}),D(this,Ct,"f")===n.AnnotationEditorType.HIGHLIGHT&&!1===t.hasSelectedEditor&&D(this,ht,"m",te).call(this,[[n.AnnotationEditorParamsType.HIGHLIGHT_FREE,!0]]))},te=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},ee=function(){if(!D(this,Pt,"f")){I(this,Pt,!0,"f");for(const t of D(this,ut,"f").values())t.enable();for(const t of D(this,ct,"f").values())t.enable()}},ie=function(){if(this.unselectAll(),D(this,Pt,"f")){I(this,Pt,!1,"f");for(const t of D(this,ut,"f").values())t.disable();for(const t of D(this,ct,"f").values())t.disable()}},se=function(t){const e=D(this,ut,"f").get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},ne=function(){let t=null;for(t of D(this,Dt,"f"));return t},ae=function(){if(0===D(this,ct,"f").size)return!0;if(1===D(this,ct,"f").size)for(const t of D(this,ct,"f").values())return t.isEmpty();return!1},oe=function(t){for(const t of D(this,Dt,"f"))t.unselect();D(this,Dt,"f").clear();for(const e of t)e.isEmpty()||(D(this,Dt,"f").add(e),e.select());D(this,ht,"m",Qt).call(this,{hasSelectedEditor:this.hasSelection})},de.TRANSLATE_SMALL=1,de.TRANSLATE_BIG=10;class ce{constructor(){re.set(this,Object.create(null))}getListeners(){return D(this,re,"f")}on(t,e,i=null){this._on(t,e,{external:!0,once:null==i?void 0:i.once,signal:null==i?void 0:i.signal})}off(t,e){this._off(t,e)}dispatch(t,e){const i=D(this,re,"f")[t];if(!i||0===i.length)return;let s;for(const{listener:n,external:a,once:o}of i.slice(0))o&&this._off(t,n),a?(s||(s=[])).push(n):n(e);if(s){for(const t of s)t(e);s=null}}_on(t,e,i=null){var s;let n=null;if((null==i?void 0:i.signal)instanceof AbortSignal){const{signal:s}=i;if(s.aborted)return;const a=()=>this._off(t,e);n=()=>s.removeEventListener("abort",a),s.addEventListener("abort",a)}((s=D(this,re,"f"))[t]||(s[t]=[])).push({listener:e,external:!0===(null==i?void 0:i.external),once:!0===(null==i?void 0:i.once),rmAbort:n})}_off(t,e){var i;const s=D(this,re,"f")[t];if(s)for(let t=0,n=s.length;t<n;t++){const n=s[t];if(n.listener===e)return null===(i=n.rmAbort)||void 0===i||i.call(n),void s.splice(t,1)}}}re=new WeakMap;const ue=0,fe=1,pe=3,ge=0,me=1,ve=1,ye=3;function Ee(t,e,i=0){let s=i,n=t.length-1;if(n<0||!e(t[n]))return t.length;if(e(t[s]))return s;for(;s<n;){const i=s+n>>1;e(t[i])?n=i:s=i+1}return s}var we,be,Se,Me,xe,ke,Ae,Te,Pe,Le,_e,Ce,De,Ie,Ne,Oe,We,Fe,He,Be,Ve,Re,ze,$e,Ue,je,Ge,Ke,Xe,qe,Ze,Ye,Je,Qe,ti,ei,ii,si,ni;class ai{constructor(){we.add(this),Se.set(this,!1),Me.set(this,null),xe.set(this,new Map),ke.set(this,new Map)}setTextMapping(t){I(this,Me,t,"f")}enable(){if(D(this,Se,"f"),!D(this,Me,"f"))throw new Error("Text divs and strings have not been set.");if(I(this,Se,!0,"f"),I(this,Me,D(this,Me,"f").slice(),"f"),D(this,Me,"f").sort(D(be,be,"m",Ae)),D(this,xe,"f").size>0){const t=D(this,Me,"f");for(const[e,i]of D(this,xe,"f")){document.getElementById(e)?D(this,we,"m",Te).call(this,e,t[i]):D(this,xe,"f").delete(e)}}for(const[t,e]of D(this,ke,"f"))this.addPointerInTextLayer(t,e);D(this,ke,"f").clear()}disable(){D(this,Se,"f")&&(D(this,ke,"f").clear(),I(this,Me,null,"f"),I(this,Se,!1,"f"))}removePointerInTextLayer(t){if(!D(this,Se,"f"))return void D(this,ke,"f").delete(t);const e=D(this,Me,"f");if(!e||0===e.length)return;const{id:i}=t,s=D(this,xe,"f").get(i);if(void 0===s)return;const n=e[s];D(this,xe,"f").delete(i);let a=n.getAttribute("aria-owns");(null==a?void 0:a.includes(i))&&(a=a.split(" ").filter((t=>t!==i)).join(" "),a?n.setAttribute("aria-owns",a):(n.removeAttribute("aria-owns"),n.setAttribute("role","presentation")))}addPointerInTextLayer(t,e){if(!t)return void console.warn("no element");const{id:i}=t;if(!i)return null;if(!D(this,Se,"f"))return D(this,ke,"f").set(t,e),null;e&&this.removePointerInTextLayer(t);const s=D(this,Me,"f");if(!s||0===s.length)return null;const n=Ee(s,(e=>D(be,be,"m",Ae).call(be,t,e)<0)),a=Math.max(0,n-1),o=s[a];D(this,we,"m",Te).call(this,i,o),D(this,xe,"f").set(i,a);const r=o.parentNode;return(null==r?void 0:r.classList.contains("markedContent"))||(null==r?void 0:r.classList.contains("k-marked-content"))?r.id:null}moveElementInDOM(t,e,i,s){const n=this.addPointerInTextLayer(i,s);if(!t.hasChildNodes())return t.append(e),n;const a=Array.from(t.children).filter((t=>t!==e));if(0===a.length)return n;const o=i||e,r=Ee(a,(t=>D(be,be,"m",Ae).call(be,o,t)<0));return 0===r?a[0].before(e):a[r-1].after(e),n}destroy(){I(this,xe,new Map,"f"),I(this,ke,new Map,"f"),I(this,Me,null,"f")}}be=ai,Se=new WeakMap,Me=new WeakMap,xe=new WeakMap,ke=new WeakMap,we=new WeakSet,Ae=function(t,e){const i=t.getBoundingClientRect(),s=e.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===s.width&&0===s.height)return-1;const n=i.y,a=i.y+i.height,o=i.y+i.height/2,r=s.y,h=s.y+s.height,l=s.y+s.height/2;if(o<=r&&l>=a)return-1;if(l<=n&&o>=h)return 1;return i.x+i.width/2-(s.x+s.width/2)},Te=function(t,e){const i=e.getAttribute("aria-owns");(null==i?void 0:i.includes(t))||e.setAttribute("aria-owns",i?`${i} ${t}`:t),e.removeAttribute("role")};class oi{constructor({pdfPage:t,accessibilityManager:e,styles:i,onAppend:s=null}){Pe.add(this),this.pdfPage=null,this.div=null,this.accessibilityManager=null,_e.set(this,null),Ce.set(this,null),this.pdfPage=t,this.accessibilityManager=e,I(this,_e,s,"f"),this.div=document.createElement("div"),this.div.tabIndex=0,this.div.classList.add("k-text-layer"),Object.keys(i).forEach((t=>this.div.style[t]=i[t]))}render(t){return C(this,arguments,void 0,(function*(t,e=null){var i,s,a;if(D(this,Ce,"f"))return D(this,Ce,"f").update({viewport:t,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),I(this,Ce,new n.TextLayer({textContentSource:this.pdfPage.streamTextContent(e||{includeMarkedContent:!1,disableNormalization:!0}),container:this.div,viewport:t}),"f");const{textDivs:o}=D(this,Ce,"f");null===(i=this.accessibilityManager)||void 0===i||i.setTextMapping(o),yield D(this,Ce,"f").render();const r=Array.from(this.div.querySelectorAll(".markedContent")||[])||[];if(r.forEach((t=>N("k-marked-content",t))),r&&r.length>0){const t=document.createElement("div");t.className="endOfContent",this.div.append(t),D(this,Pe,"m",Ne).call(this,t)}null===(s=D(this,_e,"f"))||void 0===s||s.call(this,this.div),null===(a=this.accessibilityManager)||void 0===a||a.enable()}))}hide(){this.div.hidden||(this.div.hidden=!0)}show(){this.div.hidden&&(this.div.hidden=!1)}cancel(){var t,e,i;null===(t=D(this,Ce,"f"))||void 0===t||t.cancel(),I(this,Ce,null,"f"),null===(e=this.accessibilityManager)||void 0===e||e.disable(),null===(i=this.accessibilityManager)||void 0===i||i.destroy(),D(Le,Le,"m",Oe).call(Le,this.div)}destroy(){var t,e;n.TextLayer.cleanup(),this.cancel(),this.pdfPage=null,null===(t=this.accessibilityManager)||void 0===t||t.destroy(),this.accessibilityManager=null,null===(e=this.div)||void 0===e||e.remove(),this.div=null}}function ri(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function hi(t){return Math.max(0,Math.min(255,255*t))}Le=oi,_e=new WeakMap,Ce=new WeakMap,Pe=new WeakSet,Ne=function(t){const{div:e}=this;D(Le,Le,"f",De).set(e,t),D(Le,Le,"m",We).call(Le)},Oe=function(t){var e;D(this,Le,"f",De).delete(t),0===D(this,Le,"f",De).size&&(null===(e=D(this,Le,"f",Ie))||void 0===e||e.abort(),I(this,Le,null,"f",Ie))},We=function(){},De={value:new Map},Ie={value:null};class li{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=hi(t),t,t]}static G_HTML([t]){const e=ri(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(hi)}static RGB_HTML(t){return`#${t.map(ri).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[hi(1-Math.min(1,t+s)),hi(1-Math.min(1,i+s)),hi(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,a=1-i;return["CMYK",s,n,a,Math.min(s,n,a)]}}function di(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t,10))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t,10))).slice(0,3):[0,0,0]}class ci{get _colors(){if("undefined"==typeof document)return Q(this,"_colors",ci._colorsMapping);const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,di(s))}e.remove()}(t),Q(this,"_colors",t)}convert(t){const e=di(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[t,i]of this._colors)if(i.every(((t,i)=>t===e[i])))return ci._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?et.makeHexColor(...e):t}}function ui(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}ci._colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);class fi{constructor(t){Fe.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=[],Be.set(this,0),Ve.set(this,0),this.isAttachedToDOM=!1,this.deleted=!1,Re.set(this,!1),ze.set(this,!1),$e.set(this,null),Ue.set(this,!1),je.set(this,null),Ge.set(this,!1),Ke.set(this,!1),Xe.set(this,null),qe.set(this,0),Ze.set(this,0),this._editToolbar=null,this._initialOptions=Object.create(null),this._isVisible=!0,this._uiManager=null,this._focusEventsAllowed=!0,this._l10nPromise=null,Ye.set(this,!1),Je.set(this,He._zIndex++),this.parent=t.parent,this.id=t.id||He.idManager.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,a];const[o,r]=this.parentDimensions;this.x=t.x/o,this.y=t.y/r,this.isAttachedToDOM=!1,this.deleted=!1}get x(){return D(this,Be,"f")}set x(t){I(this,Be,t,"f")}get y(){return D(this,Ve,"f")}set y(t){I(this,Ve,t,"f")}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return n.shadow(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new pi({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e,i){}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){if(t)return!1}static paste(t,e){}get propertiesToUpdate(){return[]}get _isDraggable(){return D(this,Ye,"f")}set _isDraggable(t){var e;I(this,Ye,t,"f"),null===(e=this.div)||void 0===e||e.classList.toggle("k-draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=D(this,Je,"f")}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):D(this,Fe,"m",ni).call(this),this.parent=t}focusin(t){t&&this._focusEventsAllowed&&(D(this,Ue,"f")?I(this,Ue,!1,"f"):this.parent.setSelected(this))}focusout(t){var e;if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const i=t.relatedTarget;(null==i?void 0:i.closest(`#${this.id}`))||(t.preventDefault(),(null===(e=this.parent)||void 0===e?void 0:e.isMultipleSelection)||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,a]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/a,this.fixAndSetPosition()}translate(t,e){D(this,Fe,"m",Qe).call(this,this.parentDimensions,t,e)}translateInPage(t,e){I(this,je,D(this,je,"f")||[this.x,this.y],"f"),D(this,Fe,"m",Qe).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){I(this,je,D(this,je,"f")||[this.x,this.y],"f");const[i,s]=this.parentDimensions;if(this.x+=t/i,this.y+=e/s,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this;const[o,r]=this.getBaseTranslation();n+=o,a+=r,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*a).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!D(this,je,"f")&&(D(this,je,"f")[0]!==this.x||D(this,je,"f")[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=He,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){if(void 0===t)return;const[e,i]=this.pageDimensions;let{x:s,y:n,width:a,height:o}=this;if(a*=e,o*=i,s*=e,n*=i,this._mustFixPosition)switch(t){case 0:s=Math.max(0,Math.min(e-a,s)),n=Math.max(0,Math.min(i-o,n));break;case 90:s=Math.max(0,Math.min(e-o,s)),n=Math.min(i,Math.max(a,n));break;case 180:s=Math.min(e,Math.max(a,s)),n=Math.min(i,Math.max(o,n));break;case 270:s=Math.min(e,Math.max(o,s)),n=Math.max(0,Math.min(i-a,n))}this.x=s/=e,this.y=n/=i;const[r,h]=this.getBaseTranslation();s+=r,n+=h;const{style:l}=this.div;l.left=`${(100*s).toFixed(2)}%`,l.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){return D(He,He,"m",ti).call(He,t,e,this.parentRotation)}pageTranslationToScreen(t,e){return D(He,He,"m",ti).call(He,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this,s=e*t,a=i*t;return n.FeatureTest.isCSSRoundSupported?[Math.round(s),Math.round(a)]:[s,a]}setDims(t,e){const[i,s]=this.parentDimensions;this.div.style.width=`${(100*t/i).toFixed(2)}%`,D(this,ze,"f")||(this.div.style.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){}getInitialTranslation(){return[0,0]}addEditToolbar(){var t;null===(t=this._uiManager)||void 0===t||t.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=D(this,Re,"f")?-1:0,this._isVisible||this.div.classList.add("k-hidden"),this.setInForeground(),D(this,Fe,"m",si).call(this);const[t,e]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[i,s]=this.getInitialTranslation();return this.translate(i,s),ui(this,this.div,["pointerdown"]),this.div}pointerdown(t){var e;const{isMac:i}=n.FeatureTest.platform;if(0!==t.button||t.ctrlKey&&i)t.preventDefault();else{if(I(this,Ue,!0,"f"),this._isDraggable)return null===(e=this._uiManager)||void 0===e||e.hideEditorToolBar(),void D(this,Fe,"m",ii).call(this,t);D(this,Fe,"m",ei).call(this,t)}}moveInDOM(){D(this,Xe,"f")&&clearTimeout(D(this,Xe,"f")),I(this,Xe,setTimeout((()=>{var t;I(this,Xe,null,"f"),null===(t=this.parent)||void 0===t||t.moveEditorInDOM(this)}),0),"f")}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,a]=this.pageDimensions,[o,r]=this.pageTranslation,h=t/s,l=e/s,d=this.x*n,c=this.y*a,u=this.width*n,f=this.height*a;switch(i){case 0:return[d+h+o,a-c-l-f+r,d+h+u+o,a-c-l+r];case 90:return[d+l+o,a-c+h+r,d+l+f+o,a-c+h+u+r];case 180:return[d-h-u+o,a-c+l+r,d-h+o,a-c+l+f+r];case 270:return[d-l-f+o,a-c-h-u+r,d-l+o,a-c-h+r];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,a]=t,o=n-i,r=a-s;switch(this.rotation){case 0:return[i,e-a,o,r];case 90:return[i,e-s,r,o];case 180:return[n,e-s,o,r];case 270:return[n,e-a,r,o]}}onceAdded(){}isEmpty(){return!1}enableEditMode(){I(this,Ke,!0,"f")}disableEditMode(){I(this,Ke,!1,"f")}isInEditMode(){return D(this,Ke,"f")}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){D(this,Fe,"m",si).call(this)}rotate(t){}serialize(t=!1,e=null){}static deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation;const[n,a]=s.pageDimensions,[o,r,h,l]=s.getRectInCurrentCoords(t.rect,a);return s.x=o/n,s.y=r/a,s.width=h/n,s.height=l/a,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){var t;null===(t=D(this,$e,"f"))||void 0===t||t.abort(),I(this,$e,null,"f"),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),D(this,Xe,"f")&&(clearTimeout(D(this,Xe,"f")),I(this,Xe,null,"f")),D(this,Fe,"m",ni).call(this),this.removeEditToolbar(),this.parent=null}get isResizable(){return!1}makeResizable(){}get toolbarPosition(){return null}_stopResizingWithKeyboard(){}select(){var t;null===(t=this.div)||void 0===t||t.classList.add("k-selected"),this.addEditToolbar()}unselect(){var t,e;null===(t=this.div)||void 0===t||t.classList.remove("k-selected"),(null===(e=this.div)||void 0===e?void 0:e.contains(document.activeElement))&&this._uiManager.currentLayer.div.focus({preventScroll:!0})}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return D(this,Ge,"f")}set isEditing(t){I(this,Ge,t,"f"),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){I(this,ze,!0,"f");const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(){}show(t=this._isVisible){this.div.classList.toggle("k-hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),I(this,Re,!1,"f")}disable(){this.div&&(this.div.tabIndex=-1),I(this,Re,!0,"f")}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent")||t.container.querySelector(".k-annotation-content");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("k-annotation-content",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("k-annotation-content",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e.nodeName&&(e.classList.contains("annotationContent")||e.classList.contains("k-annotation-content"))&&e.remove()}}He=fi,Be=new WeakMap,Ve=new WeakMap,Re=new WeakMap,ze=new WeakMap,$e=new WeakMap,Ue=new WeakMap,je=new WeakMap,Ge=new WeakMap,Ke=new WeakMap,Xe=new WeakMap,qe=new WeakMap,Ze=new WeakMap,Ye=new WeakMap,Je=new WeakMap,Fe=new WeakSet,Qe=function([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this.fixAndSetPosition()},ti=function(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},ei=function(t){const{isMac:e}=n.FeatureTest.platform,i=t.target.closest(".k-highlight-editor"),s=t.target.closest(".k-free-text-editor"),a=this._uiManager.getMode();a===z&&!i||a===R&&!s||(t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this))},ii=function(t){const e=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();const i=new AbortController,s=this._uiManager.combinedSignal(i);if(e){I(this,qe,t.clientX,"f"),I(this,Ze,t.clientY,"f");const e=t=>{const{clientX:e,clientY:i}=t,[s,n]=this.screenToPageTranslation(e-D(this,qe,"f"),i-D(this,Ze,"f"));I(this,qe,e,"f"),I(this,Ze,i,"f"),this._uiManager.dragSelectedEditors(s,n)};window.addEventListener("pointermove",e,{passive:!0,capture:!0,signal:s})}const n=()=>{i.abort(),e&&this.div.classList.remove("moving"),I(this,Ue,!1,"f"),this._uiManager.endDragSession()||D(this,Fe,"m",ei).call(this,t)};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})},si=function(){if(D(this,$e,"f")||!this.div)return;I(this,$e,new AbortController,"f");const t=this._uiManager.combinedSignal(D(this,$e,"f"));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},ni=function(){},fi.idManager=new he("annotation_editor_id_"),fi._borderLineWidth=-1,fi._colorManager=new ci,fi._zIndex=1,fi._telemetryTimeout=1e3;class pi extends fi{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const gi=3285377520,mi=4294901760,vi=65535;class yi{constructor(t){this.h1=null,this.h2=null,this.h1=t?4294967295&t:gi,this.h2=t?4294967295&t:gi}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,a=new Uint32Array(e.buffer,0,s);let o=0,r=0,h=this.h1,l=this.h2;const d=3432918353,c=461845907,u=11601,f=13715;for(let t=0;t<s;t++)1&t?(o=a[t],o=o*d&mi|o*u&vi,o=o<<15|o>>>17,o=o*c&mi|o*f&vi,h^=o,h=h<<13|h>>>19,h=5*h+3864292196):(r=a[t],r=r*d&mi|r*u&vi,r=r<<15|r>>>17,r=r*c&mi|r*f&vi,l^=r,l=l<<13|l>>>19,l=5*l+3864292196);switch(o=0,n){case 3:o^=e[4*s+2]<<16;case 2:o^=e[4*s+1]<<8;case 1:o^=e[4*s],o=o*d&mi|o*u&vi,o=o<<15|o>>>17,o=o*c&mi|o*f&vi,1&s?h^=o:l^=o}this.h1=h,this.h2=l}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&mi|36045*t&vi,e=4283543511*e&mi|(2950163797*(e<<16|t>>>16)&mi)>>>16,t^=e>>>1,t=444984403*t&mi|60499*t&vi,e=3301882366*e&mi|(3120437893*(e<<16|t>>>16)&mi)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}var Ei,wi,bi,Si,Mi,xi;const ki=Object.freeze({map:null,hash:"",transfer:void 0});class Ai{constructor(){Ei.add(this),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null,wi.set(this,!1),bi.set(this,null),Si.set(this,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getStorage(){return D(this,Si,"f")}getModified(){return D(this,wi,"f")}getValue(t,e){const i=D(this,Si,"f").get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return D(this,Si,"f").get(t)}remove(t){if(D(this,Si,"f").delete(t),0===D(this,Si,"f").size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of D(this,Si,"f").values())if(t instanceof fi)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=D(this,Si,"f").get(t);let s=!1;if(void 0!==i)for(const[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,D(this,Si,"f").set(t,e);s&&D(this,Ei,"m",Mi).call(this),e instanceof fi&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return D(this,Si,"f").has(t)}getAll(){return D(this,Si,"f").size>0?function(t){const e=Object.create(null);for(const[i,s]of t)e[i]=s;return e}(D(this,Si,"f")):null}setAll(t){for(const[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return D(this,Si,"f").size}resetModified(){D(this,wi,"f")&&(I(this,wi,!1,"f"),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Ti(this)}get serializable(){if(0===D(this,Si,"f").size)return ki;const t=new Map,e=new yi(null),i=[],s=Object.create(null);let n=!1;for(const[i,a]of D(this,Si,"f")){const o=a instanceof fi?a.serialize(!1,s):a;o&&(t.set(i,o),e.update(`${i}:${JSON.stringify(o)}`),n||(n=!!o.bitmap))}if(n)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:ki}get editorStats(){var t;let e=null;const i=new Map;for(const s of D(this,Si,"f").values()){if(!(s instanceof fi))continue;const n=s.telemetryFinalData;if(!n)continue;const{type:a}=n;i.has(a)||i.set(a,Object.getPrototypeOf(s).constructor),e||(e=Object.create(null));const o=e[a]||(e[a]=new Map);for(const[e,i]of Object.entries(n)){if("type"===e)continue;let s=o.get(e);s||(s=new Map,o.set(e,s));const n=null!==(t=s.get(i))&&void 0!==t?t:0;s.set(i,n+1)}}for(const[t,s]of i)e[t]=s.computeTelemetryFinalData(e[t]);return e}resetModifiedIds(){I(this,bi,null,"f")}get modifiedIds(){if(D(this,bi,"f"))return D(this,bi,"f");const t=[];for(const e of D(this,Si,"f").values())e instanceof fi&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return I(this,bi,{ids:new Set(t),hash:t.join(",")},"f")}}wi=new WeakMap,bi=new WeakMap,Si=new WeakMap,Ei=new WeakSet,Mi=function(){D(this,wi,"f")||(I(this,wi,!0,"f"),"function"==typeof this.onSetModified&&this.onSetModified())};class Ti extends Ai{constructor(t){super(),xi.set(this,void 0);const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);I(this,xi,{map:n,hash:i,transfer:s},"f")}get print(){return null}get serializable(){return D(this,xi,"f")}get modifiedIds(){return n.shadow(this,"modifiedIds",{ids:new Set,hash:""})}}var Pi,Li,_i,Ci,Di,Ii,Ni,Oi,Wi,Fi,Hi,Bi,Vi,Ri,zi,$i,Ui,ji,Gi,Ki,Xi,qi,Zi,Yi,Ji,Qi,ts,es,is,ss,ns,as,os,rs,hs,ls,ds,cs,us,fs,ps,gs,ms,vs;xi=new WeakMap;const ys=new WeakSet;function Es(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class ws{static create(t){switch(t.data.annotationType){case $:return new Ss(t);case K:switch(t.data.fieldType){case"Tx":return new xs(t);case"Btn":return t.data.radioButton?new As(t):t.data.checkBox?new ks(t):new Ts(t);case"Ch":return new Ps(t)}case U:return new Cs(t);case j:return new Ds(t);default:return new bs(t)}}}class bs{constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){Pi.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,Li.set(this,null),_i.set(this,!1),Ci.set(this,null),this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!((null==t?void 0:t.str)||(null==e?void 0:e.str)||(null==i?void 0:i.str))}get _isEditable(){return this.data.isEditable}get hasPopupData(){return bs._hasPopupData(this.data)}updateEdited(t){var e;if(!this.container)return;I(this,Li,D(this,Li,"f")||{rect:this.data.rect.slice(0)},"f");const{rect:i}=t;i&&D(this,Pi,"m",Di).call(this,i),null===(e=D(this,Ci,"f"))||void 0===e||e.popup.updateEdited(t)}resetEdited(){var t;D(this,Li,"f")&&(D(this,Pi,"m",Di).call(this,D(this,Li,"f").rect),null===(t=D(this,Ci,"f"))||void 0===t||t.popup.resetEdited(),I(this,Li,null,"f"))}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",e.id),this instanceof Ms||(a.tabIndex=0);const{style:o}=a;if(o.zIndex=(this.parent.zIndex++).toString(),e.popupRef&&a.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(a.title=e.alternativeText),e.noRotate,!e.rect||this instanceof Ls){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,a),a}const{width:r,height:h}=Es(e.rect);if(!t&&e.borderStyle.width>0){o.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;o.borderRadius=e}else if(this instanceof As){const t=`calc(${r}px * var(--scale-factor)) / calc(${h}px * var(--scale-factor))`;o.borderRadius=t}switch(e.borderStyle.style){case X:o.borderStyle="solid";break;case q:o.borderStyle="dashed";break;case Z:case Y:break;case J:o.borderBottomStyle="solid"}const s=e.borderColor||null;s?(I(this,_i,!0,"f"),o.borderColor=n.Util.makeHexColor(0|s[0],0|s[1],0|s[2])):o.borderWidth=(0).toString()}const l=n.Util.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:d,pageHeight:c,pageX:u,pageY:f}=s.rawDims;o.left=100*(l[0]-u)/d+"%",o.top=100*(l[1]-f)/c+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(o.width=100*r/d+"%",o.height=100*h/c+"%"):this.setRotation(p,a),a}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:n,height:a}=Es(this.data.rect);let o,r;t%180==0?(o=100*n/i,r=100*a/s):(o=100*a/i,r=100*n/s),e.style.width=`${o}%`,e.style.height=`${r}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],a=s.slice(1);i.target.style[e]=li[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:li[`${n}_rgb`](a)})};return n.shadow(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];null==n||n(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const a=i[s];if(a){a({detail:{[s]:n},target:t}),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[a,o,r,h]=t.subarray(2,6);if(s===a&&n===o&&e===r&&i===h)return}const{style:a}=this.container;let o;if(D(this,_i,"f")){const{borderColor:t,borderWidth:e}=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="${t}" stroke-width="${e}">`]}const r=s-e,h=n-i,{svgFactory:l}=this,d=l.createElement("svg");d.setAttribute("width",0),d.setAttribute("height",0);const c=l.createElement("defs");d.append(c);const u=l.createElement("clipPath"),f=`clippath_${this.data.id}`;u.setAttribute("id",f),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let i=2,s=t.length;i<s;i+=8){const s=t[i],a=t[i+1],d=t[i+2],c=t[i+3],f=l.createElement("rect"),p=(d-e)/r,g=(n-a)/h,m=(s-d)/r,v=(a-c)/h;f.setAttribute("x",p),f.setAttribute("y",g),f.setAttribute("width",m),f.setAttribute("height",v),u.append(f),null==o||o.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${g}" width="${m}" height="${v}"/>`)}D(this,_i,"f")&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(d),this.container.style.clipPath=`url(#${f})`}_createPopup(){}render(){}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:a}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof a?a:null,o=document.querySelector(`[data-element-id="${n}"]`);o&&!ys.has(o)||i.push({id:n,exportValue:s,domElement:o})}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&(ys.has(s)&&i.push({id:n,exportValue:t,domElement:s}))}return i}show(){var t;this.container&&(this.container.hidden=!1),null===(t=this.popup)||void 0===t||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),null===(t=this.popup)||void 0===t||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();Array.isArray(t)}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{var i,s;null===(s=null===(i=this.linkService)||void 0===i?void 0:i.eventBus)||void 0===s||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}Li=new WeakMap,_i=new WeakMap,Ci=new WeakMap,Pi=new WeakSet,Di=function(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:o,pageY:r}}}}=this;null==i||i.splice(0,4,...t);const{width:h,height:l}=Es(t);e.left=100*(t[0]-o)/n+"%",e.top=100*(a-t[3]+r)/a+"%",0===s?(e.width=100*h/n+"%",e.height=100*l/a+"%"):this.setRotation(s)};class Ss extends bs{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!(null==e?void 0:e.ignoreBorder),createQuadrilaterals:!0}),Ii.add(this),this.isTooltipOnly=!1,this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(D(this,Ii,"m",Oi).call(this,i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(D(this,Ii,"m",Wi).call(this,i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("k-link-annotation"),s&&this.container.append(i),this.container}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&D(this,Ii,"m",Ni).call(this)}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),D(this,Ii,"m",Ni).call(this)}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>{var t;return null===(t=this.linkService.eventBus)||void 0===t||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1})}t.onclick||(t.onclick=()=>!1),D(this,Ii,"m",Ni).call(this)}_bindResetFormAction(t,e){const i=t.onclick;i||(t.href=this.linkService.getAnchorUrl("")),D(this,Ii,"m",Ni).call(this),this._fieldObjects?t.onclick=()=>{var t;null==i||i();const{fields:s,refs:n,include:a}=e,o=[];if(0!==s.length||0!==n.length){const t=new Set(n);for(const e of s){const i=this._fieldObjects[e]||[];for(const{id:e}of i)t.add(e)}for(const e of Object.values(this._fieldObjects))for(const i of e)t.has(i.id)===a&&o.push(i)}else for(const t of Object.values(this._fieldObjects))o.push(...t);const r=this.annotationStorage,h=[];for(const t of o){const{id:e}=t;switch(h.push(e),t.type){case"text":{const i=t.defaultValue||"";r.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;r.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";r.setValue(e,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(ys.has(i)&&i.dispatchEvent(new Event("resetform")))}return this.enableScripting&&(null===(t=this.linkService.eventBus)||void 0===t||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}})),!1}:i||(t.onclick=()=>!1)}}Ii=new WeakSet,Ni=function(){this.container.setAttribute("data-internal-link","")},Oi=function(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>{var t;return null===(t=this.downloadManager)||void 0===t||t.openOrDownloadData(e.content,e.filename,i),!1},D(this,Ii,"m",Ni).call(this)},Wi=function(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),D(this,Ii,"m",Ni).call(this)};class Ms extends bs{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&("CANVAS"===(null===(e=t.previousSibling)||void 0===e?void 0:e.nodeName)&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return n.FeatureTest.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,(t=>{var e;null===(e=this.linkService.eventBus)||void 0===e||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(i,(t=>{var a;if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&(null===(a=this.linkService.eventBus)||void 0===a||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}}))}))}_setEventListeners(t,e,i,s){var n,a,o;for(const[r,h]of i)("Action"===h||(null===(n=this.data.actions)||void 0===n?void 0:n[h]))&&("Focus"!==h&&"Blur"!==h||e||(e={focused:!1}),this._setEventListener(t,e,r,h,s),"Focus"!==h||(null===(a=this.data.actions)||void 0===a?void 0:a.Blur)?"Blur"!==h||(null===(o=this.data.actions)||void 0===o?void 0:o.Focus)||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":n.Util.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,a=t.style;let o;const r=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(F*s))||1);o=Math.min(s,r(e/F))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);o=Math.min(s,r(t/F))}a.fontSize=`calc(${o}px * var(--scale-factor))`,a.color=n.Util.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(a.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class xs extends Ms{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=i),n.setValue(a.id,{[s]:i})}render(){var t,e;const i=this.annotationStorage,s=this.data.id;this.container.classList.add("k-text-widget-annotation");let n=null;if(this.renderForms){const a=i.getValue(s,{value:this.data.fieldValue});let o=a.value||"";const r=i.getValue(s,{charLimit:this.data.maxLen}).charLimit;r&&o.length>r&&(o=o.slice(0,r));let h=a.formattedValue||(null===(t=this.data.textContent)||void 0===t?void 0:t.join("\n"))||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const l={userValue:o,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=null!=h?h:o,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type="text",n.setAttribute("value",null!=h?h:o),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),ys.add(n),n.setAttribute("data-element-id",s),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=0,this._setRequired(n,this.data.required),r&&(n.maxLength=r),n.addEventListener("input",(t=>{i.setValue(s,{value:t.target.value}),this.setPropertyOnSiblings(n,"value",t.target.value,"value"),l.formattedValue=null})),n.addEventListener("resetform",(()=>{var t;const e=null!==(t=this.data.defaultFieldValue)&&void 0!==t?t:"";n.value=l.userValue=e,l.formattedValue=null}));let d=t=>{const{formattedValue:e}=l;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",(t=>{var e;if(l.focused)return;const{target:i}=t;l.userValue&&(i.value=l.userValue),l.lastCommittedValue=i.value,l.commitKey=1,(null===(e=this.data.actions)||void 0===e?void 0:e.Focus)||(l.focused=!0)})),n.addEventListener("updatefromsandbox",(t=>{this.showElementAndHideCanvas(t.target);const e={value(t){var e;l.userValue=null!==(e=t.detail.value)&&void 0!==e?e:"",i.setValue(s,{value:l.userValue.toString()}),t.target.value=l.userValue},formattedValue(t){const{formattedValue:e}=t.detail;l.formattedValue=e,null!=e&&t.target!==document.activeElement&&(t.target.value=e),i.setValue(s,{formattedValue:e})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:t=>{var e;const{charLimit:n}=t.detail,{target:a}=t;if(0===n)return void a.removeAttribute("maxLength");a.setAttribute("maxLength",n);let o=l.userValue;!o||o.length<=n||(o=o.slice(0,n),a.value=l.userValue=o,i.setValue(s,{value:o}),null===(e=this.linkService.eventBus)||void 0===e||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:"Keystroke",value:o,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}};this._dispatchEventFromSandbox(e,t)})),n.addEventListener("keydown",(t=>{var e;l.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(l.commitKey=3):i=2,-1===i)return;const{value:n}=t.target;l.lastCommittedValue!==n&&(l.lastCommittedValue=n,l.userValue=n,null===(e=this.linkService.eventBus)||void 0===e||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:"Keystroke",value:n,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const t=d;d=null,n.addEventListener("blur",(e=>{var i,n;if(!l.focused||!e.relatedTarget)return;(null===(i=this.data.actions)||void 0===i?void 0:i.Blur)||(l.focused=!1);const{value:a}=e.target;l.userValue=a,l.lastCommittedValue!==a&&(null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:"Keystroke",value:a,willCommit:!0,commitKey:l.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})),t(e)})),(null===(e=this.data.actions)||void 0===e?void 0:e.Keystroke)&&n.addEventListener("beforeinput",(t=>{var e;l.lastCommittedValue=null;const{data:i,target:n}=t,{value:a,selectionStart:o,selectionEnd:r}=n;let h=o,d=r;switch(t.inputType){case"deleteWordBackward":{const t=a.substring(0,o).match(/\w*[^\w]*$/);t&&(h-=t[0].length);break}case"deleteWordForward":{const t=a.substring(o).match(/^[^\w]*\w*/);t&&(d+=t[0].length);break}case"deleteContentBackward":o===r&&(h-=1);break;case"deleteContentForward":o===r&&(d+=1)}t.preventDefault(),null===(e=this.linkService.eventBus)||void 0===e||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:"Keystroke",value:a,change:i||"",willCommit:!1,selStart:h,selEnd:d}})})),this._setEventListeners(n,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(d&&n.addEventListener("blur",d),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/r;n.classList.add("comb"),n.style.letterSpacing=`calc(${t}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}}class ks extends Ms{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("k-button-widget-annotation","k-checkbox-widget-annotation");const n=document.createElement("input");return ys.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",(!0).toString()),n.setAttribute("exportValue",e.exportValue),n.tabIndex=0,n.addEventListener("change",(s=>{const{name:n,checked:a}=s.target;for(const s of this._getElementsByName(n,i)){const i=a&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:a})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{const s={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(s,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{const s={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(s,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class As extends Ms{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("k-button-widget-annotation","k-radio-button-widget-annotation");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});const n=document.createElement("input");if(ys.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",(!0).toString()),n.tabIndex=0,n.addEventListener("change",(e=>{const{name:s,checked:n}=e.target;for(const e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:n})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue})),this.enableScripting&&this.hasJSActions){const s=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{const n={value:e=>{const n=s===e.detail.value;for(const s of this._getElementsByName(e.target.name)){const e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Ts extends Ss{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();this.container.classList.add("k-button-widget-annotation","k-push-button-widget-annotation");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class Ps extends Ms{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");ys.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=0;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",(()=>{const t=this.data.defaultFieldValue;for(const e of s.options)e.selected=e.value===t}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",(!0).toString()),n=!1),s.append(e)}let a=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",(!0).toString()),t.setAttribute("selected",(!0).toString()),s.prepend(t),a=()=>{t.remove(),s.removeEventListener("input",a),a=null},s.addEventListener("input",a)}const o=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[e])):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let r=o(!1);const h=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",(i=>{const n={value(i){null==a||a();const n=i.detail.value,h=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=h.has(t.value);t.setValue(e,{value:o(!0)}),r=o(!1)},multipleSelection(){s.multiple=!0},remove(i){const n=s.options,a=i.detail.remove;if(n[a].selected=!1,s.remove(a),n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:o(!0),items:h(i)}),r=o(!1)},clear(){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),r=o(!1)},insert(i){const{index:n,displayValue:a,exportValue:l}=i.detail.insert,d=s.children[n],c=document.createElement("option");c.textContent=a,c.value=l,d?d.before(c):s.append(c),t.setValue(e,{value:o(!0),items:h(i)}),r=o(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:o(!0),items:h(i)}),r=o(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:o(!0)}),r=o(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)})),s.addEventListener("input",(i=>{var s;const n=o(!0),a=o(!1);t.setValue(e,{value:n}),i.preventDefault(),null===(s=this.linkService.eventBus)||void 0===s||s.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,change:a,changeEx:n,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):s.addEventListener("input",(function(){t.setValue(e,{value:o(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Ls extends bs{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:bs._hasPopupData(e)}),this.elements=[],this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new _s({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}),e=[];for(const i of this.elements)i.popup=t,e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>`${it}${t}`)).join(",")),this.container}}class _s{constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:a,contentsObj:o,richText:r,parent:h,rect:l,parentRect:d,open:c}){var u;Fi.add(this),this.trigger=null,Hi.set(this,D(this,Fi,"m",rs).bind(this)),Bi.set(this,D(this,Fi,"m",cs).bind(this)),Vi.set(this,D(this,Fi,"m",ds).bind(this)),Ri.set(this,D(this,Fi,"m",ls).bind(this)),zi.set(this,null),$i.set(this,null),Ui.set(this,null),ji.set(this,null),Gi.set(this,null),Ki.set(this,null),Xi.set(this,null),qi.set(this,!1),Zi.set(this,null),Yi.set(this,null),Ji.set(this,null),Qi.set(this,null),ts.set(this,null),es.set(this,null),is.set(this,!1),I(this,$i,t,"f"),I(this,ts,s,"f"),I(this,Ui,o,"f"),I(this,Qi,r,"f"),I(this,Ki,h,"f"),I(this,zi,e,"f"),I(this,Ji,l,"f"),I(this,Xi,d,"f"),I(this,Gi,i,"f"),I(this,ji,n.PDFDateString.toDateObject(a),"f"),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",D(this,Ri,"f")),t.addEventListener("mouseenter",D(this,Vi,"f")),t.addEventListener("mouseleave",D(this,Bi,"f")),t.classList.add("popupTriggerArea");for(const t of i)null===(u=t.container)||void 0===u||u.addEventListener("keydown",D(this,Hi,"f"));D(this,$i,"f").hidden=!0,c&&D(this,Fi,"m",ls).call(this),D(this,Ki,"f").popupShow.push((()=>C(this,void 0,void 0,(function*(){D(this,$i,"f").hidden&&D(this,Fi,"m",ds).call(this)}))))}render(){if(D(this,Zi,"f"))return;const t=I(this,Zi,document.createElement("div"),"f");if(t.className="popup",D(this,zi,"f")){const e=t.style.outlineColor=n.Util.makeHexColor(...D(this,zi,"f"));if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`;else{const e=.7;t.style.backgroundColor=n.Util.makeHexColor(...D(this,zi,"f").map((t=>Math.floor(e*(255-t)+t))))}}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=D(this,ts,"f")),t.append(e),D(this,ji,"f")){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),t.setAttribute("data-l10n-args",JSON.stringify({date:D(this,ji,"f").toLocaleDateString(),time:D(this,ji,"f").toLocaleTimeString()})),e.append(t)}const s=D(this,Fi,"a",ss);if(s)n.XfaLayer.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(D(this,Ui,"f"));t.append(e)}D(this,$i,"f").append(t)}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){const n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}return i}updateEdited({rect:t,popupContent:e}){var i;I(this,es,D(this,es,"f")||{contentsObj:D(this,Ui,"f"),richText:D(this,Qi,"f")},"f"),t&&I(this,Yi,null,"f"),e&&(I(this,Qi,D(this,Fi,"m",os).call(this,e),"f"),I(this,Ui,null,"f")),null===(i=D(this,Zi,"f"))||void 0===i||i.remove(),I(this,Zi,null,"f")}resetEdited(){var t,e,i;D(this,es,"f")&&(e=this,i=this,({contentsObj:{set value(t){I(e,Ui,t,"f")}}.value,richText:{set value(t){I(i,Qi,t,"f")}}.value}=D(this,es,"f")),I(this,es,null,"f"),null===(t=D(this,Zi,"f"))||void 0===t||t.remove(),I(this,Zi,null,"f"),I(this,Yi,null,"f"))}forceHide(){I(this,is,this.isVisible,"f"),D(this,is,"f")&&(D(this,$i,"f").hidden=!0)}maybeShow(){D(this,is,"f")&&(D(this,Zi,"f")||D(this,Fi,"m",ds).call(this),I(this,is,!1,"f"),D(this,$i,"f").hidden=!1)}get isVisible(){return!1===D(this,$i,"f").hidden}}Hi=new WeakMap,Bi=new WeakMap,Vi=new WeakMap,Ri=new WeakMap,zi=new WeakMap,$i=new WeakMap,Ui=new WeakMap,ji=new WeakMap,Gi=new WeakMap,Ki=new WeakMap,Xi=new WeakMap,qi=new WeakMap,Zi=new WeakMap,Yi=new WeakMap,Ji=new WeakMap,Qi=new WeakMap,ts=new WeakMap,es=new WeakMap,is=new WeakMap,Fi=new WeakSet,ss=function(){const t=D(this,Qi,"f"),e=D(this,Ui,"f");return!(null==t?void 0:t.str)||(null==e?void 0:e.str)&&e.str!==t.str?null:D(this,Qi,"f").html||null},ns=function(){var t,e,i;return(null===(i=null===(e=null===(t=D(this,Fi,"a",ss))||void 0===t?void 0:t.attributes)||void 0===e?void 0:e.style)||void 0===i?void 0:i.fontSize)||0},as=function(){var t,e,i;return(null===(i=null===(e=null===(t=D(this,Fi,"a",ss))||void 0===t?void 0:t.attributes)||void 0===e?void 0:e.style)||void 0===i?void 0:i.color)||null},os=function(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:D(this,Fi,"a",as),fontSize:D(this,Fi,"a",ns)?`calc(${D(this,Fi,"a",ns)}px * var(--scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i},rs=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&D(this,qi,"f"))&&D(this,Fi,"m",ls).call(this)},hs=function(){if(null!==D(this,Yi,"f"))return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:a}}}=D(this,Ki,"f");let o=!!D(this,Xi,"f"),r=D(this,o?Xi:Ji,"f");for(const t of D(this,Gi,"f"))if(!r||null!==n.Util.intersect(t.data.rect,r)){r=t.data.rect,o=!0;break}const h=n.Util.normalizeRect([r[0],t[3]-r[1]+t[1],r[2],t[3]-r[3]+t[1]]),l=o?r[2]-r[0]+5:0,d=h[0]+l,c=h[1];I(this,Yi,[100*(d-s)/e,100*(c-a)/i],"f");const{style:u}=D(this,$i,"f");u.left=`${D(this,Yi,"f")[0]}%`,u.top=`${D(this,Yi,"f")[1]}%`},ls=function(){I(this,qi,!D(this,qi,"f"),"f"),D(this,qi,"f")?(D(this,Fi,"m",ds).call(this),D(this,$i,"f").addEventListener("click",D(this,Ri,"f")),D(this,$i,"f").addEventListener("keydown",D(this,Hi,"f"))):(D(this,Fi,"m",cs).call(this),D(this,$i,"f").removeEventListener("click",D(this,Ri,"f")),D(this,$i,"f").removeEventListener("keydown",D(this,Hi,"f")))},ds=function(){D(this,Zi,"f")||this.render(),this.isVisible?D(this,qi,"f")&&D(this,$i,"f").classList.add("focused"):(D(this,Fi,"m",hs).call(this),D(this,$i,"f").hidden=!1,D(this,$i,"f").style.zIndex=(parseInt(D(this,$i,"f").style.zIndex,10)+1e3).toString())},cs=function(){D(this,$i,"f").classList.remove("focused"),!D(this,qi,"f")&&this.isVisible&&(D(this,$i,"f").hidden=!0,D(this,$i,"f").style.zIndex=(parseInt(D(this,$i,"f").style.zIndex,10)-1e3).toString())};class Cs extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=null,this.textPosition=null,this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=n.AnnotationEditorType.FREETEXT}render(){if(this.container.classList.add("k-free-text-annotation"),this.textContent){const t=document.createElement("div");t.classList.add("k-annotation-text-content"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return this._editOnDoubleClick(),this.container}}class Ds extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.container.classList.add("k-highlight-annotation"),this.container}}class Is{constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:a}){us.add(this),this.div=null,this.page=null,this.viewport=null,this.zIndex=null,this._annotationEditorUIManager=null,fs.set(this,null),ps.set(this,null),gs.set(this,new Map),this.div=t,I(this,fs,e,"f"),I(this,ps,i,"f"),this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=s}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return D(this,gs,"f").size>0}render(t){var e;const{annotations:i}=t,s=this.div;n.setLayerDimensions(s,this.viewport);const a=new Map,o={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new n.DOMSVGFactory,annotationStorage:t.annotationStorage||new Ai,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of i){if(t.noHTML)continue;const i=t.annotationType===G;if(i){const e=a.get(t.id);if(!e)continue;o.elements=e}else{const{width:e,height:i}=Es(t.rect);if(e<=0||i<=0)continue}o.data=t;const s=ws.create(o);if(!s.isRenderable)continue;if(!i&&t.popupRef){const e=a.get(t.popupRef);e?e.push(s):a.set(t.popupRef,[s])}const n=s.render();t.hidden&&(n.style.visibility="hidden"),D(this,us,"m",ms).call(this,n,t.id),s._isEditable&&(D(this,gs,"f").set(s.data.id,s),null===(e=this._annotationEditorUIManager)||void 0===e||e.renderAnnotationElement(s))}D(this,us,"m",vs).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,n.setLayerDimensions(e,t),D(this,us,"m",vs).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(D(this,gs,"f").values())}getEditableAnnotation(t){return D(this,gs,"f").get(t)}destroy(){var t,e;null===(t=D(this,ps,"f"))||void 0===t||t.clear(),null===(e=this.div)||void 0===e||e.remove(),this.div=null}}var Ns,Os,Ws,Fs,Hs,Bs,Vs,Rs,zs,$s,Us,js,Gs,Ks,Xs,qs,Zs,Ys,Js,Qs,tn,en,sn,nn,an,on,rn,hn,ln,dn,cn;fs=new WeakMap,ps=new WeakMap,gs=new WeakMap,us=new WeakSet,ms=function(t,e){var i;const s=t.firstChild||t;s.id=`${it}${e}`,this.div.append(t),null===(i=D(this,fs,"f"))||void 0===i||i.moveElementInDOM(this.div,t,s,!1)},vs=function(){if(!D(this,ps,"f"))return;const t=this.div;for(const[e,i]of D(this,ps,"f")){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent k-annotation-content";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")&&n.classList.contains("k-annotation-content")?n.after(i):n.before(i):s.append(i)}D(this,ps,"f").clear()};class un{constructor({pdfPage:t,eventBus:e,linkService:i=null,annotationStorage:s=null,renderForms:n=!0,annotationCanvasMap:a=null,accessibilityManager:o=null,annotationEditorUIManager:r=null,onAppend:h=null}){Ns.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,Os.set(this,null),Ws.set(this,null),this.renderForms=null,this.pdfPage=t,this.linkService=i,this.renderForms=n,this.annotationStorage=s,this._annotationCanvasMap=a,this._accessibilityManager=o,this._annotationEditorUIManager=r,I(this,Os,h,"f"),this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=(null==i?void 0:i.eventBus)||e}render(t){return C(this,arguments,void 0,(function*(t,e="display"){var i,s,n;if(this.div){if(this._cancelled||!this.annotationLayer)return;return void this.annotationLayer.update({viewport:t.clone({dontFlip:!0})})}const[a]=yield Promise.all([this.pdfPage.getAnnotations({intent:e})]);if(this._cancelled)return;if(0===a.length)return void this.hide();const o=null===(i=this.pdfPage._pageInfo)||void 0===i?void 0:i.view,r=(o[2]||0)+"px",h=(o[3]||0)+"px",l=c(`\n            <div class="k-annotation-layer"\n                 data-main-rotation="0"\n                 style="width: round(var(--scale-factor) * ${r}, 1px);\n                        height: round(var(--scale-factor) * ${h}, 1px);">\n            </div>\n        `);this.div=l,null===(s=D(this,Os,"f"))||void 0===s||s.call(this,l),this.annotationLayer=new Is({div:l,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,page:this.pdfPage,viewport:t.clone({dontFlip:!0})}),yield this.annotationLayer.render({annotations:a,renderForms:this.renderForms,linkService:this.linkService,annotationStorage:this.annotationStorage}),this.linkService.isInPresentationMode&&D(this,Ns,"m",Fs).call(this,pe),D(this,Ws,"f")||(I(this,Ws,new AbortController,"f"),null===(n=this._eventBus)||void 0===n||n._on("presentationmodechanged",(t=>{D(this,Ns,"m",Fs).call(this,t.state)}),{signal:D(this,Ws,"f").signal}))}))}cancel(){var t;this._cancelled=!0,null===(t=D(this,Ws,"f"))||void 0===t||t.abort(),I(this,Ws,null,"f")}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){var t;return!!(null===(t=this.annotationLayer)||void 0===t?void 0:t.hasEditableAnnotations())}destroy(){var t,e,i;this.cancel(),null===(t=this.annotationLayer)||void 0===t||t.destroy(),this.annotationLayer=null,null===(e=D(this,Ws,"f"))||void 0===e||e.abort(),I(this,Ws,null,"f"),null===(i=this.div)||void 0===i||i.remove(),this.div=null}}Os=new WeakMap,Ws=new WeakMap,Ns=new WeakSet,Fs=function(t){if(!this.div)return;let e=!1;switch(t){case pe:e=!0;break;case fe:break;default:return}for(const t of this.div.childNodes)t.hasAttribute("data-internal-link")||(t.inert=e)};class fn{constructor({pageIndex:t}){Hs.add(this),this.pageIndex=0,Vs.set(this,null),Rs.set(this,0),zs.set(this,new Map),$s.set(this,new Map),this.pageIndex=t}setParent(t){if(D(this,Vs,"f")){if(D(this,Vs,"f")!==t){if(D(this,zs,"f").size>0)for(const e of D(this,zs,"f").values())e.remove(),t.append(e);I(this,Vs,t,"f")}}else I(this,Vs,t,"f")}static get _svgFactory(){return n.shadow(this,"_svgFactory",new n.DOMSVGFactory)}highlight(t,e,i,s=!1){var n,a;const o=(I(this,Rs,(a=D(this,Rs,"f"),n=a++,a),"f"),n),r=D(this,Hs,"m",js).call(this,t.box);r.classList.add("k-highlight"),t.free;const h=Bs._svgFactory.createElement("defs");r.append(h);const l=Bs._svgFactory.createElement("path");h.append(l);const d=`path_p${this.pageIndex}_${o}`;l.setAttribute("id",d),l.setAttribute("d",t.toSVGPath()),s&&D(this,$s,"f").set(o,l);const c=D(this,Hs,"m",Gs).call(this,h,d),u=Bs._svgFactory.createElement("use");return r.append(u),r.setAttribute("fill",e),r.setAttribute("fill-opacity",i),u.setAttribute("href",`#${d}`),D(this,zs,"f").set(o,r),{id:o,clipPathId:`url(#${c})`}}highlightOutline(t){var e,i;const s=(I(this,Rs,(i=D(this,Rs,"f"),e=i++,i),"f"),e),n=D(this,Hs,"m",js).call(this,t.box);n.classList.add("k-highlight-outline");const a=Bs._svgFactory.createElement("defs");n.append(a);const o=Bs._svgFactory.createElement("path");a.append(o);const r=`path_p${this.pageIndex}_${s}`;let h;if(o.setAttribute("id",r),o.setAttribute("d",t.toSVGPath()),o.setAttribute("vector-effect","non-scaling-stroke"),t.free){const t=Bs._svgFactory.createElement("mask");a.append(t),h=`mask_p${this.pageIndex}_${s}`,t.setAttribute("id",h),t.setAttribute("maskUnits","objectBoundingBox");const e=Bs._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");const i=Bs._svgFactory.createElement("use");t.append(i),i.setAttribute("href",`#${r}`),i.setAttribute("stroke","none"),i.setAttribute("fill","black"),i.setAttribute("fill-rule","nonzero")}const l=Bs._svgFactory.createElement("use");n.append(l),l.setAttribute("href",`#${r}`),h&&l.setAttribute("mask",`url(#${h})`);const d=l.cloneNode();return n.append(d),D(this,zs,"f").set(s,n),s}finalizeLine(t,e){const i=D(this,$s,"f").get(t);D(this,$s,"f").delete(t),this.updateBox(t,e.box),i.setAttribute("d",e.toSVGPath())}updateLine(t,e){D(this,zs,"f").get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(t){this.remove(t),D(this,$s,"f").delete(t)}updatePath(t,e){D(this,$s,"f").get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){D(Bs,Bs,"m",Us).call(Bs,D(this,zs,"f").get(t),e)}show(t,e){D(this,zs,"f").get(t).classList.toggle("k-hidden",!e)}rotate(t,e){D(this,zs,"f").get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){D(this,zs,"f").get(t).setAttribute("fill",e)}changeOpacity(t,e){D(this,zs,"f").get(t).setAttribute("fill-opacity",e)}addClass(t,e){D(this,zs,"f").get(t).classList.add(e)}removeClass(t,e){D(this,zs,"f").get(t).classList.remove(e)}remove(t){null!==D(this,Vs,"f")&&(D(this,zs,"f").get(t).remove(),D(this,zs,"f").delete(t))}destroy(){I(this,Vs,null,"f");for(const t of D(this,zs,"f").values())t.remove();D(this,zs,"f").clear()}}Bs=fn,Vs=new WeakMap,Rs=new WeakMap,zs=new WeakMap,$s=new WeakMap,Hs=new WeakSet,Us=function(t,{x:e=0,y:i=0,width:s=1,height:n=1}={}){const{style:a}=t;a.top=100*i+"%",a.left=100*e+"%",a.width=100*s-.2+"%",a.height=100*n-.2+"%"},js=function(t){const e=Bs._svgFactory.create(1,1,!0);return D(this,Vs,"f").append(e),e.setAttribute("aria-hidden",!0),D(Bs,Bs,"m",Us).call(Bs,e,t),e},Gs=function(t,e){const i=Bs._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=Bs._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),s};class pn{constructor(t){this.pageIndex=null,this._cancelled=null,Ks.set(this,null),this.pageIndex=t.pageIndex}render(){return C(this,arguments,void 0,(function*(t="display"){"display"!==t||D(this,Ks,"f")||I(this,Ks,new fn({pageIndex:this.pageIndex}),"f")}))}cancel(){var t;D(this,Ks,"f")&&(null===(t=D(this,Ks,"f"))||void 0===t||t.destroy(),I(this,Ks,null,"f"))}setParent(t){var e;null===(e=D(this,Ks,"f"))||void 0===e||e.setParent(t)}getDrawLayer(){return D(this,Ks,"f")}destroy(){this.cancel()}}Ks=new WeakMap;const gn=/\r\n?|\n/g;class mn extends fi{constructor(t){super(Object.assign(Object.assign({},t),{name:"k-free-text-editor freeTextEditor"})),Xs.add(this),this.editorDiv=null,this.overlayDiv=null,Zs.set(this,void 0),Ys.set(this,""),Js.set(this,`${this.id}-editor`),Qs.set(this,null),tn.set(this,void 0),en.set(this,null),I(this,Zs,t.color||qs._defaultColor||fi._defaultLineColor,"f"),I(this,tn,t.fontSize||qs._defaultFontSize,"f")}static initialize(t,e){fi.initialize(t,e,{strings:["pdfjs-free-text-default-content"]});const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))||2}static updateDefaultParams(t,e){switch(t){case n.AnnotationEditorParamsType.FREETEXT_SIZE:qs._defaultFontSize=e;break;case n.AnnotationEditorParamsType.FREETEXT_COLOR:qs._defaultColor=e}}updateParams(t,e){switch(t){case n.AnnotationEditorParamsType.FREETEXT_SIZE:D(this,Xs,"m",sn).call(this,e);break;case n.AnnotationEditorParamsType.FREETEXT_COLOR:D(this,Xs,"m",nn).call(this,e)}}static get defaultPropertiesToUpdate(){return[[n.AnnotationEditorParamsType.FREETEXT_SIZE,qs._defaultFontSize],[n.AnnotationEditorParamsType.FREETEXT_COLOR,qs._defaultColor||fi._defaultLineColor]]}get propertiesToUpdate(){return[[n.AnnotationEditorParamsType.FREETEXT_SIZE,D(this,tn,"f")],[n.AnnotationEditorParamsType.FREETEXT_COLOR,D(this,Zs,"f")]]}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-qs._internalPadding*t,-(qs._internalPadding+D(this,tn,"f"))*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(n.AnnotationEditorType.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),I(this,Qs,new AbortController,"f");const t=this._uiManager.combinedSignal(D(this,Qs,"f"));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){var t;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",D(this,Js,"f")),this._isDraggable=!0,null===(t=D(this,Qs,"f"))||void 0===t||t.abort(),I(this,Qs,null,"f"),this.div.focus({preventScroll:!0}),this.isEditing=!1)}focusin(t){var e;this._focusEventsAllowed&&(null===(e=this._uiManager)||void 0===e?void 0:e.getMode())===n.AnnotationEditorType.FREETEXT&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var t;this.width||(this.enableEditMode(),this.editorDiv.focus(),(null===(t=this._initialOptions)||void 0===t?void 0:t.isCentered)&&this.center(),this._initialOptions=null)}isEmpty(){var t,e;return!this.editorDiv||""===(null===(e=null===(t=this.editorDiv)||void 0===t?void 0:t.innerText)||void 0===e?void 0:e.trim())}remove(){this.isEditing=!1,this.parent&&this.parent.setEditingState(!0),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=D(this,Ys,"f"),e=I(this,Ys,D(this,Xs,"m",an).call(this).trimEnd(),"f");if(t===e)return;const i=t=>{I(this,Ys,t,"f"),t?(D(this,Xs,"m",hn).call(this),this._uiManager.rebuild(this),D(this,Xs,"m",on).call(this)):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),D(this,Xs,"m",on).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){t&&this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.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(){var t;if(this.div)return this.div;let e,i;this.width&&(e=this.x,i=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="k-internal internal",this.editorDiv.setAttribute("id",D(this,Js,"f")),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),null===(t=this.editorDiv)||void 0===t||t.setAttribute("default-content",this._uiManager.pdfViewer.options.messages.freeTextEditorPlaceholder),this.editorDiv.contentEditable=!0;const{style:s}=this.editorDiv;if(s.fontSize=`calc(${D(this,tn,"f")}px * var(--scale-factor))`,s.color=D(this,Zs,"f"),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.div.append(this.overlayDiv),ui(this,this.div,["dblclick","keydown"]),this.width){const[t,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=D(this,en,"f");let[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);const[r,h]=this.pageDimensions,[l,d]=this.pageTranslation;let c,u;switch(this.rotation){case 0:c=e+(n[0]-l)/r,u=i+this.height-(n[1]-d)/h;break;case 90:c=e+(n[0]-l)/r,u=i-(n[1]-d)/h,[a,o]=[o,-a];break;case 180:c=e-this.width+(n[0]-l)/r,u=i-(n[1]-d)/h,[a,o]=[-a,-o];break;case 270:c=e+(n[0]-l-this.height*h)/r,u=i+(n[1]-d-this.width*r)/h,[a,o]=[-o,a]}this.setAt(c*t,u*s,a,o)}else this.setAt(e*t,i*s,this.width*t,this.height*s);D(this,Xs,"m",hn).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=D(qs,qs,"m",dn).call(qs,e.getData("text")||"").replaceAll(gn,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const a=n.getRangeAt(0);if(!s.includes("\n"))return a.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:o,startOffset:r}=a,h=[],l=[];if(o.nodeType===Node.TEXT_NODE){const t=o.parentElement;if(l.push(o.nodeValue.slice(r).replaceAll(gn,"")),t!==this.editorDiv){let e=h;for(const i of this.editorDiv.childNodes)i!==t?e.push(D(qs,qs,"m",rn).call(qs,i)):e=l}h.push(o.nodeValue.slice(0,r).replaceAll(gn,""))}else if(o===this.editorDiv){let t=h,e=0;for(const i of this.editorDiv.childNodes)e++===r&&(t=l),t.push(D(qs,qs,"m",rn).call(qs,i))}I(this,Ys,`${h.join("\n")}${s}${l.join("\n")}`,"f"),D(this,Xs,"m",hn).call(this);const d=new Range;let c=h.reduce(((t,e)=>t+e.length),0);for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}n.removeAllRanges(),n.addRange(d)}get contentDiv(){return this.editorDiv}static deserialize(t,e,i){let s=null;if(t instanceof Cs){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:a,rotation:o,id:r},textContent:h,textPosition:l,parent:{page:{pageNumber:d}}}=t;if(!h||0===h.length)return null;s=t={annotationType:n.AnnotationEditorType.FREETEXT,color:Array.from(i),fontSize:e,value:h.join("\n"),position:l,pageIndex:d-1,rect:a.slice(0),rotation:o,id:r,deleted:!1}}const a=super.deserialize(t,e,i);return I(a,tn,t.fontSize,"f"),I(a,Zs,n.Util.makeHexColor(...t.color),"f"),I(a,Ys,D(qs,qs,"m",dn).call(qs,t.value),"f"),a.annotationElementId=t.id||null,I(a,en,s,"f"),a}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const e=qs._internalPadding*this.parentScale,i=this.getRect(e,e),s=fi._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:D(this,Zs,"f")),a={annotationType:n.AnnotationEditorType.FREETEXT,color:s,fontSize:D(this,tn,"f"),value:D(this,Xs,"m",ln).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?a:this.annotationElementId&&!D(this,Xs,"m",cn).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${D(this,tn,"f")}px * var(--scale-factor))`,i.color=D(this,Zs,"f"),e.replaceChildren();for(const t of D(this,Ys,"f").split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=qs._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:D(this,Ys,"f")}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}toJSON(){return this.serialize()}}var vn,yn,En,wn,bn,Sn,Mn,xn,kn,An,Tn,Pn,Ln,_n,Cn,Dn,In,Nn,On,Wn,Fn,Hn,Bn,Vn,Rn,zn,$n,Un,jn,Gn,Kn,Xn,qn,Zn,Yn,Jn,Qn,ta,ea,ia,sa,na,aa,oa,ra,ha,la,da,ca,ua,fa,pa,ga,ma,va,ya,Ea,wa,ba,Sa,Ma,xa,ka,Aa,Ta,Pa,La,_a,Ca,Da,Ia,Na,Oa,Wa,Fa,Ha,Ba,Va,Ra,za,$a,Ua,ja,Ga,Ka,Xa,qa,Za,Ya,Ja,Qa,to,eo,io,so,no,ao,oo,ro,ho,lo,co,uo,fo,po,go,mo,vo,yo,Eo,wo,bo,So,Mo,xo,ko;qs=mn,Zs=new WeakMap,Ys=new WeakMap,Js=new WeakMap,Qs=new WeakMap,tn=new WeakMap,en=new WeakMap,Xs=new WeakSet,sn=function(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-D(this,tn,"f"))*this.parentScale),I(this,tn,t,"f"),D(this,Xs,"m",on).call(this)},i=D(this,tn,"f");this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},nn=function(t){const e=t=>{I(this,Zs,this.editorDiv.style.color=t,"f")},i=D(this,Zs,"f");this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n.AnnotationEditorParamsType.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},an=function(){const t=[];this.editorDiv.normalize();for(const e of this.editorDiv.childNodes)t.push(D(qs,qs,"m",rn).call(qs,e));return t.join("\n")},on=function(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden")||e.classList.contains("k-hidden");e.classList.remove("hidden"),e.classList.remove("k-hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("k-hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()},rn=function(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(gn,"")},hn=function(){if(this.editorDiv.replaceChildren(),D(this,Ys,"f"))for(const t of D(this,Ys,"f").split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}},ln=function(){return D(this,Ys,"f").replaceAll(" "," ")},dn=function(t){return t.replaceAll(" "," ")},cn=function(t){const{value:e,fontSize:i,color:s,pageIndex:n}=D(this,en,"f");return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some(((t,e)=>t!==s[e]))||t.pageIndex!==n},mn._freeTextDefaultContent="",mn._internalPadding=0,mn._defaultColor="#000000",mn._defaultFontSize=10,mn._type="freetext",mn._editorType=n.AnnotationEditorType.FREETEXT;class Ao{constructor(t,e=0,i=0,s=!0){vn.add(this),yn.set(this,void 0),En.set(this,[]),wn.set(this,[]);let n=1/0,a=-1/0,o=1/0,r=-1/0;const h=Math.pow(10,-4);for(const{x:i,y:s,width:l,height:d}of t){const t=Math.floor((i-e)/h)*h,c=Math.ceil((i+l+e)/h)*h,u=Math.floor((s-e)/h)*h,f=Math.ceil((s+d+e)/h)*h,p=[t,u,f,!0],g=[c,u,f,!1];D(this,En,"f").push(p,g),n=Math.min(n,t),a=Math.max(a,c),o=Math.min(o,u),r=Math.max(r,f)}const l=a-n+2*i,d=r-o+2*i,c=n-i,u=o-i,f=D(this,En,"f").at(s?-1:-2),p=[f[0],f[2]];for(const t of D(this,En,"f")){const[e,i,s]=t;t[0]=(e-c)/l,t[1]=(i-u)/d,t[2]=(s-u)/d}I(this,yn,{x:c,y:u,width:l,height:d,lastPoint:p},"f")}getOutlines(){D(this,En,"f").sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of D(this,En,"f"))e[3]?(t.push(...D(this,vn,"m",kn).call(this,e)),D(this,vn,"m",Mn).call(this,e)):(D(this,vn,"m",xn).call(this,e),t.push(...D(this,vn,"m",kn).call(this,e)));return D(this,vn,"m",bn).call(this,t)}}yn=new WeakMap,En=new WeakMap,wn=new WeakMap,vn=new WeakSet,bn=function(t){const e=[],i=new Set;for(const i of t){const[t,s,n]=i;e.push([t,s,i],[t,n,i])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,s=e.length;t<s;t+=2){const s=e[t][2],n=e[t+1][2];s.push(n),n.push(s),i.add(s),i.add(n)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,a,o,r,h]=t;i.delete(t);let l=e,d=a;for(n=[e,o],s.push(n);;){let t;if(i.has(r))t=r;else{if(!i.has(h))break;t=h}i.delete(t),[e,a,o,r,h]=t,l!==e&&(n.push(l,d,e,d===a?a:o),l=e),d=d===a?o:a}n.push(l,d)}return new Po(s,D(this,yn,"f"))},Sn=function(t){const e=D(this,wn,"f");let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,a=e[n][0];if(a===t)return n;a<t?i=n+1:s=n-1}return s+1},Mn=function([,t,e]){const i=D(this,vn,"m",Sn).call(this,t);D(this,wn,"f").splice(i,0,[t,e])},xn=function([,t,e]){const i=D(this,vn,"m",Sn).call(this,t);for(let s=i;s<D(this,wn,"f").length;s++){const[i,n]=D(this,wn,"f")[s];if(i!==t)break;if(i===t&&n===e)return void D(this,wn,"f").splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=D(this,wn,"f")[s];if(i!==t)break;if(i===t&&n===e)return void D(this,wn,"f").splice(s,1)}},kn=function(t){const[e,i,s]=t,n=[[e,i,s]],a=D(this,vn,"m",Sn).call(this,s);for(let t=0;t<a;t++){const[i,s]=D(this,wn,"f")[t];for(let t=0,a=n.length;t<a;t++){const[,o,r]=n[t];if(!(s<=o||r<=i))if(o>=i)if(r>s)n[t][1]=s;else{if(1===a)return[];n.splice(t,1),t--,a--}else n[t][2]=i,r>s&&n.push([e,s,r])}}return n};class To{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize([t,e,i,s]){}get free(){return this instanceof _o}}class Po extends To{constructor(t,e){super(),An.set(this,void 0),Tn.set(this,void 0),I(this,Tn,t,"f"),I(this,An,e,"f")}toSVGPath(){const t=[];for(const e of D(this,Tn,"f")){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const a=e[n],o=e[n+1];a===i?(t.push(`V${o}`),s=o):o===s&&(t.push(`H${a}`),i=a)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s]){const n=[],a=i-t,o=s-e;for(const e of D(this,Tn,"f")){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*a,i[n+1]=s-e[n+1]*o;n.push(i)}return n}get box(){return D(this,An,"f")}}An=new WeakMap,Tn=new WeakMap;class Lo{constructor({x:t,y:e},i,s,n,a,o=0){Pn.add(this),_n.set(this,void 0),Cn.set(this,[]),Dn.set(this,void 0),In.set(this,void 0),Nn.set(this,[]),On.set(this,new Float64Array(18)),Wn.set(this,void 0),Fn.set(this,void 0),Hn.set(this,void 0),Bn.set(this,void 0),Vn.set(this,void 0),Rn.set(this,void 0),zn.set(this,[]),I(this,_n,i,"f"),I(this,Rn,n*s,"f"),I(this,In,a,"f"),D(this,On,"f").set([NaN,NaN,NaN,NaN,t,e],6),I(this,Dn,o,"f"),I(this,Bn,D(Ln,Ln,"f",$n)*s,"f"),I(this,Hn,D(Ln,Ln,"f",jn)*s,"f"),I(this,Vn,s,"f"),D(this,zn,"f").push(t,e)}get free(){return!0}isEmpty(){return isNaN(D(this,On,"f")[8])}add({x:t,y:e}){var i;I(this,Wn,t,"f"),I(this,Fn,e,"f");const[s,n,a,o]=D(this,_n,"f");let[r,h,l,d]=D(this,On,"f").subarray(8,12);const c=t-l,u=e-d,f=Math.hypot(c,u);if(f<D(this,Hn,"f"))return!1;const p=f-D(this,Bn,"f"),g=p/f,m=g*c,v=g*u;let y=r,E=h;r=l,h=d,l+=m,d+=v,null===(i=D(this,zn,"f"))||void 0===i||i.push(t,e);const w=m/p,b=-v/p*D(this,Rn,"f"),S=w*D(this,Rn,"f");if(D(this,On,"f").set(D(this,On,"f").subarray(2,8),0),D(this,On,"f").set([l+b,d+S],4),D(this,On,"f").set(D(this,On,"f").subarray(14,18),12),D(this,On,"f").set([l-b,d-S],16),isNaN(D(this,On,"f")[6]))return 0===D(this,Nn,"f").length&&(D(this,On,"f").set([r+b,h+S],2),D(this,Nn,"f").push(NaN,NaN,NaN,NaN,(r+b-s)/a,(h+S-n)/o),D(this,On,"f").set([r-b,h-S],14),D(this,Cn,"f").push(NaN,NaN,NaN,NaN,(r-b-s)/a,(h-S-n)/o)),D(this,On,"f").set([y,E,r,h,l,d],6),!this.isEmpty();D(this,On,"f").set([y,E,r,h,l,d],6);return Math.abs(Math.atan2(E-h,y-r)-Math.atan2(v,m))<Math.PI/2?([r,h,l,d]=D(this,On,"f").subarray(2,6),D(this,Nn,"f").push(NaN,NaN,NaN,NaN,((r+l)/2-s)/a,((h+d)/2-n)/o),[r,h,y,E]=D(this,On,"f").subarray(14,18),D(this,Cn,"f").push(NaN,NaN,NaN,NaN,((y+r)/2-s)/a,((E+h)/2-n)/o),!0):([y,E,r,h,l,d]=D(this,On,"f").subarray(0,6),D(this,Nn,"f").push(((y+5*r)/6-s)/a,((E+5*h)/6-n)/o,((5*r+l)/6-s)/a,((5*h+d)/6-n)/o,((r+l)/2-s)/a,((h+d)/2-n)/o),[l,d,r,h,y,E]=D(this,On,"f").subarray(12,18),D(this,Cn,"f").push(((y+5*r)/6-s)/a,((E+5*h)/6-n)/o,((5*r+l)/6-s)/a,((5*h+d)/6-n)/o,((r+l)/2-s)/a,((h+d)/2-n)/o),!0)}toSVGPath(){if(this.isEmpty())return"";const t=D(this,Nn,"f"),e=D(this,Cn,"f"),i=D(this,On,"f").subarray(4,6),s=D(this,On,"f").subarray(16,18),[n,a,o,r]=D(this,_n,"f"),[h,l,d,c]=D(this,Pn,"m",Gn).call(this);if(isNaN(D(this,On,"f")[6])&&!this.isEmpty())return`M${(D(this,On,"f")[2]-n)/o} ${(D(this,On,"f")[3]-a)/r} L${(D(this,On,"f")[4]-n)/o} ${(D(this,On,"f")[5]-a)/r} L${h} ${l} L${d} ${c} L${(D(this,On,"f")[16]-n)/o} ${(D(this,On,"f")[17]-a)/r} L${(D(this,On,"f")[14]-n)/o} ${(D(this,On,"f")[15]-a)/r} Z`;const u=[];u.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?u.push(`L${t[e+4]} ${t[e+5]}`):u.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);u.push(`L${(i[0]-n)/o} ${(i[1]-a)/r} L${h} ${l} L${d} ${c} L${(s[0]-n)/o} ${(s[1]-a)/r}`);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?u.push(`L${e[t+4]} ${e[t+5]}`):u.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return u.push(`L${e[4]} ${e[5]} Z`),u.join(" ")}getOutlines(){var t,e;const i=D(this,Nn,"f"),s=D(this,Cn,"f"),n=D(this,On,"f"),a=n.subarray(4,6),o=n.subarray(16,18),[r,h,l,d]=D(this,_n,"f"),c=new Float64Array((null!==(e=null===(t=D(this,zn,"f"))||void 0===t?void 0:t.length)&&void 0!==e?e:0)+2);for(let t=0,e=c.length-2;t<e;t+=2)c[t]=(D(this,zn,"f")[t]-r)/l,c[t+1]=(D(this,zn,"f")[t+1]-h)/d;c[c.length-2]=(D(this,Wn,"f")-r)/l,c[c.length-1]=(D(this,Fn,"f")-h)/d;const[u,f,p,g]=D(this,Pn,"m",Gn).call(this);if(isNaN(n[6])&&!this.isEmpty()){const t=new Float64Array(36);return t.set([NaN,NaN,NaN,NaN,(n[2]-r)/l,(n[3]-h)/d,NaN,NaN,NaN,NaN,(n[4]-r)/l,(n[5]-h)/d,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,p,g,NaN,NaN,NaN,NaN,(n[16]-r)/l,(n[17]-h)/d,NaN,NaN,NaN,NaN,(n[14]-r)/l,(n[15]-h)/d],0),new _o(t,c,D(this,_n,"f"),D(this,Vn,"f"),D(this,Dn,"f"),D(this,In,"f"))}const m=new Float64Array(D(this,Nn,"f").length+24+D(this,Cn,"f").length);let v=i.length;for(let t=0;t<v;t+=2)isNaN(i[t])?m[t]=m[t+1]=NaN:(m[t]=i[t],m[t+1]=i[t+1]);m.set([NaN,NaN,NaN,NaN,(a[0]-r)/l,(a[1]-h)/d,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,p,g,NaN,NaN,NaN,NaN,(o[0]-r)/l,(o[1]-h)/d],v),v+=24;for(let t=s.length-6;t>=6;t-=6)for(let e=0;e<6;e+=2)isNaN(s[t+e])?(m[v]=m[v+1]=NaN,v+=2):(m[v]=s[t+e],m[v+1]=s[t+e+1],v+=2);return m.set([NaN,NaN,NaN,NaN,s[4],s[5]],v),new _o(m,c,D(this,_n,"f"),D(this,Vn,"f"),D(this,Dn,"f"),D(this,In,"f"))}}Ln=Lo,_n=new WeakMap,Cn=new WeakMap,Dn=new WeakMap,In=new WeakMap,Nn=new WeakMap,On=new WeakMap,Wn=new WeakMap,Fn=new WeakMap,Hn=new WeakMap,Bn=new WeakMap,Vn=new WeakMap,Rn=new WeakMap,zn=new WeakMap,Pn=new WeakSet,Gn=function(){const t=D(this,On,"f").subarray(4,6),e=D(this,On,"f").subarray(16,18),[i,s,n,a]=D(this,_n,"f");return[(D(this,Wn,"f")+(t[0]-e[0])/2-i)/n,(D(this,Fn,"f")+(t[1]-e[1])/2-s)/a,(D(this,Wn,"f")+(e[0]-t[0])/2-i)/n,(D(this,Fn,"f")+(e[1]-t[1])/2-s)/a]},Un={value:2},jn={value:D(Ln,Ln,"f",$n={value:8})+D(Ln,Ln,"f",Un)};class _o extends To{constructor(t,e,i,s,n,a){super(),Kn.add(this),Xn.set(this,void 0),qn.set(this,null),Zn.set(this,void 0),Yn.set(this,void 0),Jn.set(this,void 0),Qn.set(this,void 0),ta.set(this,void 0),I(this,ta,t,"f"),I(this,Jn,e,"f"),I(this,Xn,i,"f"),I(this,Qn,s,"f"),I(this,Zn,n,"f"),I(this,Yn,a,"f"),D(this,Kn,"m",sa).call(this,a);const{x:o,y:r,width:h,height:l}=D(this,qn,"f");for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-o)/h,t[e+1]=(t[e+1]-r)/l;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-o)/h,e[t+1]=(e[t+1]-r)/l}toSVGPath(){const t=[`M${D(this,ta,"f")[4]} ${D(this,ta,"f")[5]}`];for(let e=6,i=D(this,ta,"f").length;e<i;e+=6)isNaN(D(this,ta,"f")[e])?t.push(`L${D(this,ta,"f")[e+4]} ${D(this,ta,"f")[e+5]}`):t.push(`C${D(this,ta,"f")[e]} ${D(this,ta,"f")[e+1]} ${D(this,ta,"f")[e+2]} ${D(this,ta,"f")[e+3]} ${D(this,ta,"f")[e+4]} ${D(this,ta,"f")[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const a=i-t,o=s-e;let r,h;switch(n){case 0:r=D(this,Kn,"m",ea).call(this,D(this,ta,"f"),t,s,a,-o),h=D(this,Kn,"m",ea).call(this,D(this,Jn,"f"),t,s,a,-o);break;case 90:r=D(this,Kn,"m",ia).call(this,D(this,ta,"f"),t,e,a,o),h=D(this,Kn,"m",ia).call(this,D(this,Jn,"f"),t,e,a,o);break;case 180:r=D(this,Kn,"m",ea).call(this,D(this,ta,"f"),i,e,-a,o),h=D(this,Kn,"m",ea).call(this,D(this,Jn,"f"),i,e,-a,o);break;case 270:r=D(this,Kn,"m",ia).call(this,D(this,ta,"f"),i,s,-a,-o),h=D(this,Kn,"m",ia).call(this,D(this,Jn,"f"),i,s,-a,-o)}return{outline:Array.from(r),points:[Array.from(h)]}}get box(){return D(this,qn,"f")}getNewOutline(t,e){const{x:i,y:s,width:n,height:a}=D(this,qn,"f"),[o,r,h,l]=D(this,Xn,"f"),d=n*h,c=a*l,u=i*h+o,f=s*l+r,p=new Lo({x:D(this,Jn,"f")[0]*d+u,y:D(this,Jn,"f")[1]*c+f},D(this,Xn,"f"),D(this,Qn,"f"),t,D(this,Yn,"f"),null!=e?e:D(this,Zn,"f"));for(let t=2;t<D(this,Jn,"f").length;t+=2)p.add({x:D(this,Jn,"f")[t]*d+u,y:D(this,Jn,"f")[t+1]*c+f});return p.getOutlines()}}Xn=new WeakMap,qn=new WeakMap,Zn=new WeakMap,Yn=new WeakMap,Jn=new WeakMap,Qn=new WeakMap,ta=new WeakMap,Kn=new WeakSet,ea=function(t,e,i,s,n){const a=new Float64Array(t.length);for(let o=0,r=t.length;o<r;o+=2)a[o]=e+t[o]*s,a[o+1]=i+t[o+1]*n;return a},ia=function(t,e,i,s,n){const a=new Float64Array(t.length);for(let o=0,r=t.length;o<r;o+=2)a[o]=e+t[o+1]*s,a[o+1]=i+t[o]*n;return a},sa=function(t){const e=D(this,ta,"f");let i=e[4],s=e[5],a=i,o=s,r=i,h=s,l=i,d=s;const c=t?Math.max:Math.min;for(let t=6,u=e.length;t<u;t+=6){if(isNaN(e[t]))a=Math.min(a,e[t+4]),o=Math.min(o,e[t+5]),r=Math.max(r,e[t+4]),h=Math.max(h,e[t+5]),d<e[t+5]?(l=e[t+4],d=e[t+5]):d===e[t+5]&&(l=c(l,e[t+4]));else{const u=n.Util.bezierBoundingBox(i,s,...e.slice(t,t+6));a=Math.min(a,u[0]),o=Math.min(o,u[1]),r=Math.max(r,u[2]),h=Math.max(h,u[3]),d<u[3]?(l=u[2],d=u[3]):d===u[3]&&(l=c(l,u[2]))}i=e[t+4],s=e[t+5]}const u=a-D(this,Zn,"f"),f=o-D(this,Zn,"f"),p=r-a+2*D(this,Zn,"f"),g=h-o+2*D(this,Zn,"f");I(this,qn,{x:u,y:f,width:p,height:g,lastPoint:[l,d]},"f")};class Co extends fi{constructor(t){super(Object.assign(Object.assign({},t),{name:"k-highlight-editor"})),na.add(this),this.color="",oa.set(this,null),ra.set(this,0),ha.set(this,void 0),la.set(this,null),da.set(this,null),ca.set(this,null),ua.set(this,0),fa.set(this,null),pa.set(this,null),ga.set(this,null),ma.set(this,!1),va.set(this,null),ya.set(this,void 0),Ea.set(this,null),wa.set(this,""),ba.set(this,void 0),Sa.set(this,""),this.color=t.color||aa._defaultColor,I(this,ba,t.thickness||aa._defaultThickness,"f"),I(this,ya,t.opacity||aa._defaultOpacity,"f"),I(this,ha,t.boxes||null,"f"),I(this,Sa,t.methodOfCreation||"","f"),I(this,wa,t.text||"","f"),this._isDraggable=!1,t.highlightId>-1?(I(this,ma,!0,"f"),D(this,na,"m",xa).call(this,t),D(this,na,"m",Pa).call(this)):(I(this,oa,t.anchorNode,"f"),I(this,ra,t.anchorOffset,"f"),I(this,ca,t.focusNode,"f"),I(this,ua,t.focusOffset,"f"),D(this,na,"m",Ma).call(this),D(this,na,"m",Pa).call(this),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:D(this,ma,"f")?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:D(this,ba,"f"),methodOfCreation:D(this,Sa,"f")}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,e){var i,s,n,a;fi.initialize(t,e,{}),aa._defaultColor||(aa._defaultColor=(null===(a=null===(n=null===(s=null===(i=e.viewer)||void 0===i?void 0:i.options)||void 0===s?void 0:s.annotations)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.color)||"#ffff00")}static updateDefaultParams(t,e){switch(t){case n.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:aa._defaultColor=e;break;case n.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:aa._defaultThickness=e}}translateInPage(){}get toolbarPosition(){return D(this,va,"f")}updateParams(t,e){switch(t){case n.AnnotationEditorParamsType.HIGHLIGHT_COLOR:D(this,na,"m",ka).call(this,e);break;case n.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:D(this,na,"m",Aa).call(this,e)}}static get defaultPropertiesToUpdate(){return[[n.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR,aa._defaultColor],[n.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS,aa._defaultThickness]]}get propertiesToUpdate(){return[[n.AnnotationEditorParamsType.HIGHLIGHT_COLOR,this.color||aa._defaultColor],[n.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS,D(this,ba,"f")||aa._defaultThickness],[n.AnnotationEditorParamsType.HIGHLIGHT_FREE,D(this,ma,"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(D(this,na,"m",Da).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,D(this,na,"m",Da).call(this))}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){D(this,na,"m",Ta).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(D(this,na,"m",Pa).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e,i;let s=!1;this.parent&&!t?D(this,na,"m",Ta).call(this):t&&(D(this,na,"m",Pa).call(this,t),s=!this.parent&&((null===(e=this.div)||void 0===e?void 0:e.classList.contains("selectedEditor"))||(null===(i=this.div)||void 0===i?void 0:i.classList.contains("k-selected")))),super.setParent(t),this.show(this._isVisible),s&&this.select()}rotate(t){const{drawLayer:e}=this.parent;let i;D(this,ma,"f")?(t=(t-this.rotation+360)%360,i=D(aa,aa,"m",La).call(aa,D(this,pa,"f").box,t)):i=D(aa,aa,"m",La).call(aa,this,t),e.rotate(D(this,ga,"f"),t),e.rotate(D(this,Ea,"f"),t),e.updateBox(D(this,ga,"f"),i),e.updateBox(D(this,Ea,"f"),D(aa,aa,"m",La).call(aa,D(this,da,"f").box,t))}render(){if(this.div)return this.div;const t=super.render();D(this,wa,"f")&&(t.setAttribute("aria-label",D(this,wa,"f")),t.setAttribute("role","mark")),D(this,ma,"f")?t.classList.add("free"):this.div.addEventListener("keydown",D(this,na,"m",_a).bind(this),{signal:this._uiManager._signal});const e=I(this,fa,document.createElement("div"),"f");t.append(e),e.setAttribute("aria-hidden","true"),e.className="k-internal internal",e.style.clipPath=D(this,la,"f");const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),ui(this,D(this,fa,"f"),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.parent.drawLayer.addClass(D(this,Ea,"f"),"hovered")}pointerleave(){this.parent.drawLayer.removeClass(D(this,Ea,"f"),"hovered")}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:D(this,na,"m",Ca).call(this,!0);break;case 1:case 3:D(this,na,"m",Ca).call(this,!1)}}select(){var t,e,i;super.select(),D(this,Ea,"f")&&(null===(t=this.parent)||void 0===t||t.drawLayer.removeClass(D(this,Ea,"f"),"hovered"),null===(e=this.parent)||void 0===e||e.drawLayer.addClass(D(this,Ea,"f"),"selected"),null===(i=this.parent)||void 0===i||i.drawLayer.addClass(D(this,Ea,"f"),"k-selected"))}unselect(){var t,e;super.unselect(),D(this,Ea,"f")&&(null===(t=this.parent)||void 0===t||t.drawLayer.removeClass(D(this,Ea,"f"),"selected"),null===(e=this.parent)||void 0===e||e.drawLayer.removeClass(D(this,Ea,"f"),"k-selected"),D(this,ma,"f")||D(this,na,"m",Ca).call(this,!1))}get _mustFixPosition(){return!D(this,ma,"f")}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(D(this,ga,"f"),t),this.parent.drawLayer.show(D(this,Ea,"f"),t))}static startHighlighting(t,e,{target:i,x:s,y:a}){const{x:o,y:r,width:h,height:l}=i.getBoundingClientRect(),d=new AbortController,c=t.combinedSignal(d),u=e=>{d.abort(),D(this,aa,"m",Wa).call(this,t,e)};window.addEventListener("blur",u,{signal:c}),window.addEventListener("pointerup",u,{signal:c}),window.addEventListener("pointerdown",(t=>{t.preventDefault(),t.stopPropagation()}),{capture:!0,passive:!1,signal:c}),window.addEventListener("contextmenu",n.noContextMenu,{signal:c}),i.addEventListener("pointermove",D(this,aa,"m",Oa).bind(this,t),{signal:c}),this._freeHighlight=new Lo({x:s,y:a},[o,r,h,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0))}static deserialize(t,e,i){const s=super.deserialize(t,e,i),{rect:[a,o,r,h],color:l,quadPoints:d}=t;s.color=n.Util.makeHexColor(...l),I(s,ya,t.opacity,"f");const[c,u]=s.pageDimensions;s.width=(r-a)/c,s.height=(h-o)/u;const f=I(s,ha,[],"f");for(let t=0;t<d.length;t+=8)f.push({x:(d[4]-r)/c,y:(h-(1-d[t+5]))/u,width:(d[t+2]-d[t])/c,height:(d[t+5]-d[t+1])/u});return D(s,na,"m",Ma).call(s),s}serialize(t=!1){if(this.isEmpty()||t)return null;const e=this.getRect(0,0),i=fi._colorManager.convert(this.color);return{annotationType:n.AnnotationEditorType.HIGHLIGHT,color:i,opacity:D(this,ya,"f"),thickness:D(this,ba,"f"),quadPoints:D(this,na,"m",Ia).call(this),outlines:D(this,na,"m",Na).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:D(this,na,"m",Da).call(this),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}toJSON(){return this.serialize()}}aa=Co,oa=new WeakMap,ra=new WeakMap,ha=new WeakMap,la=new WeakMap,da=new WeakMap,ca=new WeakMap,ua=new WeakMap,fa=new WeakMap,pa=new WeakMap,ga=new WeakMap,ma=new WeakMap,va=new WeakMap,ya=new WeakMap,Ea=new WeakMap,wa=new WeakMap,ba=new WeakMap,Sa=new WeakMap,na=new WeakSet,Ma=function(){const t=new Ao(D(this,ha,"f"),.001);I(this,pa,t.getOutlines(),"f"),({x:this.x,y:this.y,width:this.width,height:this.height}=D(this,pa,"f").box);const e=new Ao(D(this,ha,"f"),.0025,.001,"ltr"===this._uiManager.direction);I(this,da,e.getOutlines(),"f");const{lastPoint:i}=D(this,da,"f").box;I(this,va,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height],"f")},xa=function({highlightOutlines:t,highlightId:e,clipPathId:i}){I(this,pa,t,"f");if(I(this,da,t.getNewOutline(D(this,ba,"f")/2+1.5,.0025),"f"),e>=0)I(this,ga,e,"f"),I(this,la,i,"f"),this.parent.drawLayer.finalizeLine(e,t),I(this,Ea,this.parent.drawLayer.highlightOutline(D(this,da,"f")),"f");else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(D(this,ga,"f"),t),this.parent.drawLayer.updateBox(D(this,ga,"f"),D(aa,aa,"m",La).call(aa,D(this,pa,"f").box,(e-this.rotation+360)%360)),this.parent.drawLayer.updateLine(D(this,Ea,"f"),D(this,da,"f")),this.parent.drawLayer.updateBox(D(this,Ea,"f"),D(aa,aa,"m",La).call(aa,D(this,da,"f").box,e))}const{x:s,y:n,width:a,height:o}=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=a,this.height=o;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=a*e/t,this.height=o*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=a,this.height=o;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=a*e/t,this.height=o*t/e;break}}const{lastPoint:r}=D(this,da,"f").box;I(this,va,[(r[0]-s)/a,(r[1]-n)/o],"f")},ka=function(t){if(!t)return;const e=t=>{var e;this.color=t,null===(e=this.parent)||void 0===e||e.drawLayer.changeColor(D(this,ga,"f"),t)},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n.AnnotationEditorParamsType.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Aa=function(t){},Ta=function(){null!==D(this,ga,"f")&&this.parent&&(this.parent.drawLayer.remove(D(this,ga,"f")),I(this,ga,null,"f"),this.parent.drawLayer.remove(D(this,Ea,"f")),I(this,Ea,null,"f"))},Pa=function(t=this.parent){var e,i;null===D(this,ga,"f")&&(e=this,i=this,({id:{set value(t){I(e,ga,t,"f")}}.value,clipPathId:{set value(t){I(i,la,t,"f")}}.value}=t.drawLayer.highlight(D(this,pa,"f"),this.color,D(this,ya,"f"))),I(this,Ea,t.drawLayer.highlightOutline(D(this,da,"f")),"f"),D(this,fa,"f")&&(D(this,fa,"f").style.clipPath=D(this,la,"f")))},La=function({x:t,y:e,width:i,height:s},n){switch(n){case 90:return{x:1-e-s,y:t,width:s,height:i};case 180:return{x:1-t-i,y:1-e-s,width:i,height:s};case 270:return{x:e,y:1-t-i,width:s,height:i}}return{x:t,y:e,width:i,height:s}},_a=function(t){},Ca=function(t){if(!D(this,oa,"f"))return;const e=window.getSelection();t?e.setPosition(D(this,oa,"f"),D(this,ra,"f")):e.setPosition(D(this,ca,"f"),D(this,ua,"f"))},Da=function(){return D(this,ma,"f")?this.rotation:0},Ia=function(){if(D(this,ma,"f"))return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=D(this,ha,"f"),a=new Float32Array(8*n.length);let o=0;for(const{x:r,y:h,width:l,height:d}of n){const n=r*t+i,c=(1-h-d)*e+s;a[o]=a[o+4]=n,a[o+1]=a[o+3]=c,a[o+2]=a[o+6]=n+l*t,a[o+5]=a[o+7]=c+d*e,o+=8}return a},Na=function(t){return D(this,pa,"f").serialize(t,D(this,na,"m",Da).call(this))},Oa=function(t,e){this._freeHighlight.add(e)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},Wa=function(t,e){this._freeHighlight.isEmpty()?t.drawLayer.removeFreeHighlight(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Co._defaultColor=null,Co._defaultOpacity=1,Co._defaultThickness=12,Co._type="highlight",Co._editorType=n.AnnotationEditorType.HIGHLIGHT,Co._freeHighlightId=-1,Co._freeHighlight=null,Co._freeHighlightClipId="";class Do{constructor({uiManager:t,pageIndex:e,div:i,accessibilityManager:s,annotationLayer:n,drawLayer:a,textLayer:o,viewport:r}){Fa.add(this),this.drawLayer=null,this.pageIndex=0,this.div=null,this.viewport=null,Ba.set(this,void 0),Va.set(this,!1),Ra.set(this,null),za.set(this,null),$a.set(this,null),Ua.set(this,new Map),ja.set(this,!1),Ga.set(this,!1),Ka.set(this,!1),Xa.set(this,null),qa.set(this,null),Za.set(this,null);const h=[...D(Ha,Ha,"f",Ya).values()];if(!Ha._initialized){Ha._initialized=!0;for(const e of h)e.initialize({},t)}t.registerEditorTypes(h),I(this,Za,t,"f"),this.pageIndex=e,this.div=i,I(this,Ba,s,"f"),I(this,Ra,n,"f"),this.viewport=r,I(this,Xa,o,"f"),this.drawLayer=a,D(this,Za,"f").addLayer(this)}hide(){this.div&&(this.div.hidden=!0)}show(){this.div&&!this.isInvisible&&(this.div.hidden=!1)}get isEmpty(){return 0===D(this,Ua,"f").size}get isInvisible(){return this.isEmpty&&D(this,Za,"f").getMode()===n.AnnotationEditorType.NONE}updateToolbar(){}updateMode(t=D(this,Za,"f").getMode()){switch(D(this,Fa,"m",io).call(this),t){case n.AnnotationEditorType.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case n.AnnotationEditorType.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case n.AnnotationEditorType.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const i of D(Ha,Ha,"f",Ya).values())e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===(null===(e=D(this,Xa,"f"))||void 0===e?void 0:e.div)}addInkEditorIfNeeded(t){if(D(this,Za,"f").getMode()!==n.AnnotationEditorType.INK)return;if(!t)for(const t of D(this,Ua,"f").values())if(t.isEmpty())return void t.setInBackground();this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){D(this,Za,"f").setEditingState(t)}addCommands(t){D(this,Za,"f").addCommands(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("k-annotation-editor-layer-disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;null===(e=D(this,Ra,"f"))||void 0===e||e.div.classList.toggle("k-annotation-editor-layer-disabled",!t)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of D(this,Ua,"f").values())e.enableEditing(),e.show(!0),e.annotationElementId&&(D(this,Za,"f").removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!D(this,Ra,"f"))return;const e=D(this,Ra,"f").getEditableAnnotations();for(const i of e){if(i.hide(),D(this,Za,"f").isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}}disable(){var t;I(this,Ka,!0,"f"),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,i=new Map;for(const s of D(this,Ua,"f").values())s.disableEditing(),s.annotationElementId&&(null===s.serialize()?(i.set(s.annotationElementId,s),null===(t=this.getEditableAnnotation(s.annotationElementId))||void 0===t||t.show(),s.remove()):e.set(s.annotationElementId,s));if(D(this,Ra,"f")){const t=D(this,Ra,"f").getEditableAnnotations();for(const s of t){const{id:t}=s.data;if(D(this,Za,"f").isDeletedAnnotationElement(t))continue;let n=i.get(t);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=e.get(t),n&&(D(this,Za,"f").addChangedExistingAnnotation(n),n.renderAnnotationElement(s),n.show(!1)),s.show())}}D(this,Fa,"m",io).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const t of D(Ha,Ha,"f",Ya).values())s.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),I(this,Ka,!1,"f")}getEditableAnnotation(t){var e;return(null===(e=D(this,Ra,"f"))||void 0===e?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){D(this,Za,"f").getActive()!==t&&D(this,Za,"f").setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(null===(t=D(this,Xa,"f"))||void 0===t?void 0:t.div)&&!D(this,qa,"f")){I(this,qa,new AbortController,"f");const t=D(this,Za,"f").combinedSignal(D(this,qa,"f"));D(this,Xa,"f").div.addEventListener("pointerdown",D(this,Fa,"m",Ja).bind(this),{signal:t})}}disableTextSelection(){var t;this.div.tabIndex=0,(null===(t=D(this,Xa,"f"))||void 0===t?void 0:t.div)&&D(this,qa,"f")&&(D(this,qa,"f").abort(),I(this,qa,null,"f"),D(this,Xa,"f").div.classList.remove("highlighting"))}enableClick(){if(D(this,za,"f"))return;I(this,za,new AbortController,"f");const t=D(this,Za,"f").combinedSignal(D(this,za,"f"));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:t})}disableClick(){var t;null===(t=D(this,za,"f"))||void 0===t||t.abort(),I(this,za,null,"f")}attach(t){D(this,Ua,"f").set(t.id,t);const{annotationElementId:e}=t;e&&D(this,Za,"f").isDeletedAnnotationElement(e)&&D(this,Za,"f").removeDeletedAnnotationElement(t)}detach(t){var e;D(this,Ua,"f").delete(t.id),null===(e=D(this,Ba,"f"))||void 0===e||e.removePointerInTextLayer(t.contentDiv),!D(this,Ka,"f")&&t.annotationElementId&&D(this,Za,"f").addDeletedAnnotationElement(t)}remove(t){this.detach(t),D(this,Za,"f").removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,D(this,Ga,"f")||this.addInkEditorIfNeeded(!1)}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(D(this,Za,"f").addDeletedAnnotationElement(t.annotationElementId),fi.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),null===(e=t.parent)||void 0===e||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),D(this,Za,"f").addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),D(this,Za,"f").addToAnnotationStorage(t)}}moveEditorInDOM(t){var e;if(!t.isAttachedToDOM)return;const{activeElement:i}=document;t.div.contains(i)&&!D(this,$a,"f")&&(t._focusEventsAllowed=!1,I(this,$a,setTimeout((()=>{I(this,$a,null,"f"),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:D(this,Za,"f")._signal}),i.focus())}),0),"f")),t._structTreeParentId=null===(e=D(this,Ba,"f"))||void 0===e?void 0:e.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return D(this,Za,"f").getId()}combinedSignal(t){return D(this,Za,"f").combinedSignal(t)}canCreateNewEmptyEditor(){var t;return null===(t=D(this,Fa,"a",Qa))||void 0===t?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){D(this,Za,"f").updateToolbar(t),D(this,Za,"f").updateMode(t);const{offsetX:i,offsetY:s}=D(this,Fa,"m",eo).call(this),n=this.getNextId(),a=D(this,Fa,"m",to).call(this,Object.assign({parent:this,id:n,x:i,y:s,uiManager:D(this,Za,"f"),isCentered:!0},e));a&&this.add(a)}deserialize(t){var e,i;return(null===(i=D(Ha,Ha,"f",Ya).get(null!==(e=t.annotationType)&&void 0!==e?e:t.annotationEditorType))||void 0===i?void 0:i.deserialize(t,this,D(this,Za,"f")))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=D(this,Fa,"m",to).call(this,Object.assign({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:D(this,Za,"f"),isCentered:e},i));return n&&this.add(n),n}addNewEditor(){this.createAndAddNewEditor(D(this,Fa,"m",eo).call(this),!0)}setSelected(t){D(this,Za,"f").setSelected(t)}toggleSelected(t){D(this,Za,"f").toggleSelected(t)}isSelected(t){return D(this,Za,"f").isSelected(t)}unselect(t){D(this,Za,"f").unselect(t)}pointerup(t){const{isMac:e}=n.FeatureTest.platform;0!==t.button||t.ctrlKey&&e||t.target===this.div&&D(this,ja,"f")&&(I(this,ja,!1,"f"),D(this,Va,"f")?D(this,Za,"f").getMode()!==n.AnnotationEditorType.STAMP?this.createAndAddNewEditor(t,!1):D(this,Za,"f").unselectAll():I(this,Va,!0,"f"))}pointerdown(t){if(D(this,Za,"f").getMode()===n.AnnotationEditorType.HIGHLIGHT&&this.enableTextSelection(),D(this,ja,"f"))return void I(this,ja,!1,"f");const{isMac:e}=n.FeatureTest.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;I(this,ja,!0,"f");const i=D(this,Za,"f").getActive();I(this,Va,!i||i.isEmpty(),"f")}findNewParent(t,e,i){const s=D(this,Za,"f").findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}destroy(){var t,e;(null===(t=D(this,Za,"f").getActive())||void 0===t?void 0:t.parent)===this&&(D(this,Za,"f").commitOrRemove(),D(this,Za,"f").setActiveEditor(null)),D(this,$a,"f")&&(clearTimeout(D(this,$a,"f")),I(this,$a,null,"f"));for(const t of D(this,Ua,"f").values())null===(e=D(this,Ba,"f"))||void 0===e||e.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,D(this,Ua,"f").clear(),D(this,Za,"f").removeLayer(this)}render({viewport:t}){this.viewport=t,n.setLayerDimensions(this.div,t);for(const t of D(this,Za,"f").getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){D(this,Za,"f").commitOrRemove(),D(this,Fa,"m",io).call(this);const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,n.setLayerDimensions(this.div,t),e!==i)for(const t of D(this,Ua,"f").values())t.rotate(i);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return D(this,Za,"f").viewParameters.realScale}}Ha=Do,Ba=new WeakMap,Va=new WeakMap,Ra=new WeakMap,za=new WeakMap,$a=new WeakMap,Ua=new WeakMap,ja=new WeakMap,Ga=new WeakMap,Ka=new WeakMap,Xa=new WeakMap,qa=new WeakMap,Za=new WeakMap,Fa=new WeakSet,Ja=function(t){D(this,Za,"f").unselectAll();const{target:e}=t;if(e===D(this,Xa,"f").div||e.classList.contains("endOfContent")&&D(this,Xa,"f").div.contains(e)){const{isMac:e}=n.FeatureTest.platform;if(0!==t.button||t.ctrlKey&&e)return;if(D(this,Za,"f").showAllEditors("highlight",!0),D(this,Za,"f").getMode()===n.AnnotationEditorType.NONE)return;D(this,Xa,"f").div.addEventListener("pointerup",(()=>{D(this,Xa,"f").div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:D(this,Za,"f")._signal}),t.preventDefault()}},Qa=function(){return D(Ha,Ha,"f",Ya).get(D(this,Za,"f").getMode())},to=function(t){const e=D(this,Fa,"a",Qa);return e?new e(t):null},eo=function(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),o=(n+Math.min(window.innerWidth,t+i))/2-t,r=(a+Math.min(window.innerHeight,e+s))/2-e,[h,l]=this.viewport.rotation%180==0?[o,r]:[r,o];return{offsetX:h,offsetY:l}},io=function(){I(this,Ga,!0,"f");for(const t of D(this,Ua,"f").values())t.isEmpty()&&t.remove();I(this,Ga,!1,"f")},Do._initialized=!1,Ya={value:new Map([mn,Co].map((t=>[t._editorType,t])))};class Io{constructor(t){this.pdfPage=null,this.annotationEditorLayer=null,this._cancelled=null,this.div=null,this.accessibilityManager=null,so.set(this,null),no.set(this,null),ao.set(this,null),oo.set(this,null),ro.set(this,null),this.pdfPage=t.pdfPage,this.accessibilityManager=t.accessibilityManager,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,I(this,ro,t.uiManager,"f"),I(this,so,t.annotationLayer||null,"f"),I(this,oo,t.textLayer||null,"f"),I(this,no,t.drawLayer||null,"f"),I(this,ao,t.onAppend||null,"f")}render(t){return C(this,arguments,void 0,(function*(t,e="display"){var i;if("display"!==e)return;if(this._cancelled)return;const s=t.clone({dontFlip:!0});if(this.div)return this.annotationEditorLayer.update({viewport:s}),void this.show();const n=this.div=document.createElement("div");n.className="k-annotation-editor-layer",n.hidden=!0,n.dir=D(this,ro,"f").direction,null===(i=D(this,ao,"f"))||void 0===i||i.call(this,n),this.annotationEditorLayer=new Do({uiManager:D(this,ro,"f"),div:n,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,viewport:s,annotationLayer:D(this,so,"f"),textLayer:D(this,oo,"f"),drawLayer:D(this,no,"f")});const a={viewport:s,div:n,annotations:null,intent:e};this.annotationEditorLayer.render(a),this.show()}))}cancel(){var t;this._cancelled=!0,this.div&&(null===(t=this.annotationEditorLayer)||void 0===t||t.destroy())}hide(){this.div&&(this.div.hidden=!0)}show(){this.div&&!this.annotationEditorLayer.isInvisible&&(this.div.hidden=!1)}destroy(){var t;null===(t=this.annotationEditorLayer)||void 0===t||t.destroy()}}so=new WeakMap,no=new WeakMap,ao=new WeakMap,oo=new WeakMap,ro=new WeakMap;const No={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return null}},Oo=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class Wo extends p{constructor(t,e){super(t,e),ho.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,lo.set(this,n.AnnotationMode.ENABLE),co.set(this,!1),uo.set(this,null),fo.set(this,null),po.set(this,ue),go.set(this,me),mo.set(this,new WeakMap),vo.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(e),this.div=t,this.viewport=this.options.viewport,this.id=this.options.id||this.options.number||1,I(this,uo,e.layerProperties||No,"f"),this.eventBus=e.eventBus,this.initScale(),this.pdfViewer=e.pdfViewer,this.pdfPage=e.pdfPage,I(this,lo,this.pdfViewer.getAnnotationMode(),"f"),this.resetState()}destroy(){var t,e,i,s,n;this.destroyTextLayer(),this.canvas&&(this.canvas.width=0,this.canvas.height=0,this.canvas.remove(),this.canvas=null),this.canvasForPrint&&(this.canvasForPrint.width=0,this.canvasForPrint.height=0,this.canvasForPrint.remove(),this.canvasForPrint=null),null===(t=this.drawLayer)||void 0===t||t.destroy(),null===(e=this.annotationLayer)||void 0===e||e.destroy(),null===(i=this.annotationEditorLayer)||void 0===i||i.destroy(),null===(s=this.div)||void 0===s||s.remove(),this.div=null,this.pdfViewer=null,null===(n=this.pdfPage)||void 0===n||n.cleanup(),this.pdfPage=null}get isEditing(){return D(this,co,"f")}get rawWidth(){var t,e;return null===(e=null===(t=this.viewport)||void 0===t?void 0:t.rawDims)||void 0===e?void 0:e.pageWidth}get rawHeight(){var t,e;return null===(e=null===(t=this.viewport)||void 0===t?void 0:t.rawDims)||void 0===e?void 0:e.pageWidth}setState(t){this.state=r(this.state||{},t)}resetState(){this.setState({})}initScale(){this.scale=this.options.zoomLevel||this.options.scale||1}createPromise(){return f()}getViewport(t={scale:1}){return this.pdfPage?this.pdfPage.getViewport(t):{width:0,height:0}}destroyTextLayer(){var t,e;null===(t=this.textLayer)||void 0===t||t.cancel(),null===(e=this.textLayer)||void 0===e||e.destroy(),this.removeTextLayer(),this.textLayer=null}removeTextLayer(){var t,e;this.textLayer&&(null===(t=this.textLayer.div)||void 0===t?void 0:t.parentNode)&&(null===(e=this.textLayer.div)||void 0===e||e.parentNode.removeChild(this.textLayer.div))}getPrintContentAsync(){const t=this.canvasForPrint,e=this.createPromise(),i=new Image,s=this.viewport.rawDims,n=Math.floor(s.pageHeight),a=Math.floor(s.pageWidth);return i.src=t.toDataURL(),i.width=a,i.height=n,i.onload=()=>{e.resolve(i)},e}loadForPrintAsync({zoomLevel:t=1.25,force:e=!1}){const i=this,s=this.createPromise(),n=this.pdfViewer.state.zoomLevel;if(this.pdfPage&&n===t&&!e)return s.resolve(i);if(this.pdfPage&&n&&(n!==t||e))return this.renderForPrintAsync().then((()=>{this.setState({isPrintingInProgress:!1}),s.resolve(i)})),s;const a=Math.max(0,this.pdfPage._pageIndex);return this.pdfViewer.state.pdfDocument.getPage(a+1).then((()=>{this.renderForPrintAsync().then((()=>{this.setState({isPrintingInProgress:!1}),s.resolve(i)}))})),s}renderForPrintAsync(){var t,e;const i=this.pdfViewer.getPrintUnits(),{canvasContext:s,canvas:a}=this.pdfViewer.createPageElements({pdfPage:this.pdfPage,zoom:1,printUnits:i});this.canvasForPrint=a,this.setState({isPrintingInProgress:!0});const o=this.pdfViewer.state.pdfDocument.getOptionalContentConfig({intent:"print"}),r={canvasContext:s,transform:[i,0,0,i,0,0],viewport:this.pdfPage.getViewport({scale:1,rotation:this.viewport.rotation}),intent:"print",annotationMode:n.AnnotationMode.ENABLE_STORAGE,optionalContentConfigPromise:o,printAnnotationStorage:null===(e=null===(t=this.pdfViewer)||void 0===t?void 0:t.annotationStorage)||void 0===e?void 0:e.print};return this.pdfPage.render(r).promise}isBlank(){return this.element&&this.element.getAttribute("data-blank")}setBlank(t){this.element&&(t?this.element.setAttribute("data-blank",(!0).toString()):this.element.removeAttribute("data-blank"))}get renderingState(){return D(this,po,"f")}setPdfPage(t){this.pdfPage=t,this.pdfPageRotate=t.rotate;const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=t.getViewport({scale:this.scale*n.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:e}),D(this,ho,"m",Eo).call(this),this.reset()}hasEditableAnnotations(){var t;return!!(null===(t=this.annotationLayer)||void 0===t?void 0:t.hasEditableAnnotations())}_resetZoomLayer(t=!1){if(!this.zoomLayer)return;const e=this.zoomLayer.firstChild;D(this,mo,"f").delete(e),e.width=0,e.height=0,t&&this.zoomLayer.remove(),this.zoomLayer=null}reset({keepZoomLayer:t=!1,keepAnnotationLayer:e=!1,keepAnnotationEditorLayer:i=!1,keepXfaLayer:s=!1,keepTextLayer:n=!1}={}){var a,o,r,h,l,d,c,u;const f=this.div;if(!f)return;const p=f.childNodes,g=t&&this.zoomLayer||null,m=e&&(null===(a=this.annotationLayer)||void 0===a?void 0:a.div)||null,v=i&&(null===(o=this.annotationEditorLayer)||void 0===o?void 0:o.div)||null,y=s&&(null===(r=this.xfaLayer)||void 0===r?void 0:r.div)||null,E=n&&(null===(h=this.textLayer)||void 0===h?void 0:h.div)||null;for(let t=p.length-1;t>=0;t--){const e=p[t];switch(e){case g:case m:case v:case y:case E:continue}e.remove();const i=D(this,vo,"f").indexOf(e);i>=0&&(D(this,vo,"f")[i]=null)}f.removeAttribute("data-loaded"),m&&(null===(l=this.annotationLayer)||void 0===l||l.hide()),v&&(null===(d=this.annotationEditorLayer)||void 0===d||d.hide()),y&&(null===(c=this.xfaLayer)||void 0===c||c.hide()),E&&(null===(u=this.textLayer)||void 0===u||u.hide()),g||(this.canvas&&(D(this,mo,"f").delete(this.canvas),this.canvas.width=0,this.canvas.height=0,delete this.canvas),this._resetZoomLayer())}toggleEditingMode(t){this.hasEditableAnnotations()&&(I(this,co,t,"f"),this.reset({keepZoomLayer:!0,keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0}))}draw(){return C(this,void 0,void 0,(function*(){const{canvasContext:t,canvas:e,canvasWrapper:i,viewport:s,pageElement:a,styles:o}=this.pdfViewer.createPageElements({pdfPage:this.pdfPage,zoom:this.pdfViewer.options.zoomLevel||1});this.isBlank()?(this.element.replaceWith(a),this.element=this.div=a,this.canvas=e):(this.element=this.div=this.element||this.div||a,this.canvas=this.canvas||e),this.options.styles=o,i.appendChild(e),this.element.appendChild(i),D(this,ho,"m",yo).call(this,i,"canvasWrapper");const{div:r,pdfPage:h}=this;if(this.textLayer||D(this,go,"f")===ge||h.isPureXfa||(this._accessibilityManager||(this._accessibilityManager=new ai),this.textLayer=new oi({styles:this.options.styles,pdfPage:h,accessibilityManager:this._accessibilityManager,onAppend:t=>{D(this,ho,"m",yo).call(this,t,"textLayer")}})),!this.annotationLayer&&D(this,lo,"f")!==n.AnnotationMode.DISABLE){const{annotationStorage:t,annotationEditorUIManager:e,linkService:i}=D(this,uo,"f");this._annotationCanvasMap||(this._annotationCanvasMap=new Map),this.annotationLayer=new un({pdfPage:h,eventBus:this.eventBus||this.pdfViewer.eventBus,annotationStorage:t,renderForms:D(this,lo,"f")===n.AnnotationMode.ENABLE_FORMS,linkService:i,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:e,onAppend:t=>{D(this,ho,"m",yo).call(this,t,"annotationLayer")}})}D(this,mo,"f").set(e,s);const l={canvasContext:t,viewport:s,annotationMode:D(this,lo,"f"),annotationCanvasMap:this._annotationCanvasMap,isEditing:D(this,co,"f")},d=this.renderTask=h.render(l),c=d.promise.then((()=>C(this,void 0,void 0,(function*(){var t;yield D(this,ho,"m",ko).call(this,d),yield D(this,ho,"m",xo).call(this),this.annotationLayer&&(yield D(this,ho,"m",bo).call(this));const{annotationEditorUIManager:e}=D(this,uo,"f");e&&(this.drawLayer||(this.drawLayer=new pn({pageIndex:this.id})),yield D(this,ho,"m",Mo).call(this),this.drawLayer.setParent(i),this.annotationEditorLayer||(this.annotationEditorLayer=new Io({uiManager:e,pdfPage:h,accessibilityManager:this._accessibilityManager,annotationLayer:null===(t=this.annotationLayer)||void 0===t?void 0:t.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:t=>{D(this,ho,"m",yo).call(this,t,"annotationEditorLayer")}})),D(this,ho,"m",So).call(this))}))),(t=>{}));return h.isPureXfa,r.setAttribute("data-loaded",!0),this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id}),c}))}}var Fo,Ho;lo=new WeakMap,co=new WeakMap,uo=new WeakMap,fo=new WeakMap,po=new WeakMap,go=new WeakMap,mo=new WeakMap,vo=new WeakMap,ho=new WeakSet,yo=function(t,e){const i=Oo.get(e),s=D(this,vo,"f")[i];if(D(this,vo,"f")[i]=t,s)s.replaceWith(t);else{for(let e=i-1;e>=0;e--){const i=D(this,vo,"f")[e];if(i)return void i.after(t)}this.div.prepend(t)}},Eo=function(){const{viewport:t}=this;if(this.pdfPage){if(D(this,fo,"f")===t.rotation)return;I(this,fo,t.rotation,"f")}this.div&&t&&n.setLayerDimensions(this.div,t,!0,!1)},wo=function(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})},bo=function(){return C(this,void 0,void 0,(function*(){let t=null;try{yield this.annotationLayer.render(this.viewport,"display")}catch(e){console.error(`#renderAnnotationLayer: "${e}".`),t=e}finally{D(this,ho,"m",wo).call(this,"annotationlayerrendered",t)}}))},So=function(){return C(this,void 0,void 0,(function*(){let t=null;try{yield this.annotationEditorLayer.render(this.viewport)}catch(e){t=e}finally{D(this,ho,"m",wo).call(this,"annotationeditorlayerrendered",t)}}))},Mo=function(){return C(this,void 0,void 0,(function*(){try{yield this.drawLayer.render("display")}catch(t){}}))},xo=function(){return C(this,void 0,void 0,(function*(){if(!this.textLayer)return;let t=null;try{yield this.textLayer.render(this.viewport)}catch(e){if(e instanceof n.AbortException)return;t=e}D(this,ho,"m",wo).call(this,"textlayerrendered",t)}))},ko=function(t){return C(this,void 0,void 0,(function*(){t===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"})}))};const Bo=0,Vo=1,Ro=2,zo=3,$o=4;class Uo{constructor({eventBus:t=null,externalLinkTarget:e=null,externalLinkRel:i=null,ignoreDestinationZoom:s=!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=t,this.externalLinkTarget=e,this.externalLinkRel=i,this._ignoreDestinationZoom=s,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null}setDocument(t,e=null){this.baseUrl=e,this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setHistory(t){this.pdfHistory=t}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return this.pdfDocument?this.pdfViewer.currentPageNumber:1}set page(t){this.pdfDocument&&(this.pdfViewer.currentPageNumber=t)}get rotation(){return this.pdfDocument?this.pdfViewer.pagesRotation:0}set rotation(t){this.pdfDocument&&(this.pdfViewer.pagesRotation=t)}get isInPresentationMode(){return!!this.pdfDocument&&this.pdfViewer.isInPresentationMode}goToDestination(t){return C(this,void 0,void 0,(function*(){if(!this.pdfDocument)return;let e,i,s;if("string"==typeof t?(e=t,i=yield this.pdfDocument.getDestination(t)):(e=null,i=yield t),!Array.isArray(i))return;const[n]=i;if(n&&"object"==typeof n){if(s=this.pdfDocument.cachedPageNumber(n),!s)try{s=(yield this.pdfDocument.getPageIndex(n))+1}catch(e){return void console.error(`goToDestination: "${n}" is not a valid page reference, for dest="${t}".`)}}else Number.isInteger(n)&&(s=n+1);!s||s<1||s>this.pagesCount?console.error(`goToDestination: "${s}" is not a valid page number, for dest="${t}".`):(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:e,explicitDest:i,pageNumber:s})),this.pdfViewer.scrollPageIntoView({pageNumber:s,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom}))}))}goToPage(t){if(!this.pdfDocument)return;const e="string"==typeof t&&this.pdfViewer.pageLabelToPageNumber(t)||0|t;Number.isInteger(e)&&e>0&&e<=this.pagesCount?(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.pushPage(e)),this.pdfViewer.scrollPageIntoView({pageNumber:e})):console.error(`PDFLinkService.goToPage: "${t}" is not a valid page.`)}addLinkAttributes(t,e,i=!1){if(!e||"string"!=typeof e)throw new Error('A valid "url" parameter must provided.');const s=i?Ro:this.externalLinkTarget,n=this.externalLinkRel;this.externalLinkEnabled?t.href=t.title=e:(t.href="",t.title=`Disabled: ${e}`,t.onclick=()=>!1);let a="";switch(s){case Bo:break;case Vo:a="_self";break;case Ro:a="_blank";break;case zo:a="_parent";break;case $o:a="_top"}t.target=a,t.rel="string"==typeof n?n:"noopener noreferrer nofollow"}getDestinationHash(t){if("string"==typeof t){if(t.length>0)return this.getAnchorUrl("#"+escape(t))}else if(Array.isArray(t)){const e=JSON.stringify(t);if(e.length>0)return this.getAnchorUrl("#"+escape(e))}return this.getAnchorUrl("")}getAnchorUrl(t){return this.baseUrl?this.baseUrl+t:t}setHash(t){if(!this.pdfDocument)return;let e,i;if(t.includes("=")){const s=function(t){const e=new Map,i=new URLSearchParams(t);for(const[t,s]of i)e.set(t.toLowerCase(),s);return e}(t);if(s.has("search")){const t=s.get("search").replaceAll('"',""),e="true"===s.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:e?t:t.match(/\S+/g)})}if(s.has("page")&&(e=0|s.get("page")||1),s.has("zoom")){const t=s.get("zoom").split(","),e=t[0],n=parseFloat(e);e.includes("Fit")?"Fit"===e||"FitB"===e?i=[null,{name:e}]:"FitH"===e||"FitBH"===e||"FitV"===e||"FitBV"===e?i=[null,{name:e},t.length>1?0|t[1]:null]:"FitR"===e?5!==t.length?console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:e},0|t[1],0|t[2],0|t[3],0|t[4]]:console.error(`PDFLinkService.setHash: "${e}" is not a valid zoom value.`):i=[null,{name:"XYZ"},t.length>1?0|t[1]:null,t.length>2?0|t[2]:null,n?n/100:e]}return i?this.pdfViewer.scrollPageIntoView({pageNumber:e||this.page,destArray:i,allowNegativeOffset:!0}):e&&(this.page=e),s.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:s.get("pagemode")}),void(s.has("nameddest")&&this.goToDestination(s.get("nameddest")))}i=unescape(t);try{i=JSON.parse(i),Array.isArray(i)||(i=i.toString())}catch(t){if(!t)return}("string"==typeof i||D(Fo,Fo,"m",Ho).call(Fo,i))&&this.goToDestination(i)}executeNamedAction(t){var e,i;if(this.pdfDocument){switch(t){case"GoBack":null===(e=this.pdfHistory)||void 0===e||e.back();break;case"GoForward":null===(i=this.pdfHistory)||void 0===i||i.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}this.eventBus.dispatch("namedaction",{source:this,action:t})}}executeSetOCGState(t){return C(this,void 0,void 0,(function*(){if(!this.pdfDocument)return;const e=this.pdfDocument,i=yield this.pdfViewer.optionalContentConfigPromise;e===this.pdfDocument&&(i.setOCGState(t),this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i))}))}}var jo,Go,Ko,Xo,qo,Zo,Yo,Jo,Qo;Fo=Uo,Ho=function(t){if(!Array.isArray(t)||t.length<2)return!1;const[e,i,...s]=t;if(!("object"==typeof e&&Number.isInteger(null==e?void 0:e.num)&&Number.isInteger(null==e?void 0:e.gen)||Number.isInteger(e)))return!1;if("object"!=typeof i||"string"!=typeof(null==i?void 0:i.name))return!1;const n=s.length;let a=!0;switch(i.name){case"XYZ":if(n<2||n>3)return!1;break;case"Fit":case"FitB":return 0===n;case"FitH":case"FitBH":case"FitV":case"FitBV":if(n>1)return!1;break;case"FitR":if(4!==n)return!1;a=!1;break;default:return!1}for(const t of s)if(!("number"==typeof t||a&&null===t))return!1;return!0},t.P=void 0,(jo=t.P||(t.P={}))[jo.TextSelection=0]="TextSelection",jo[jo.Pan=1]="Pan";const tr="error",er="zoomStart",ir="zoomEnd",sr="pageRendered",nr="pagesLoad",ar="printEnd",or="scroll",rr="annotationEditorToolBarShow",hr="annotationEditorToolBarHide",lr=1.25,dr=1e3/60;Ko=new WeakMap,Xo=new WeakMap,qo=new WeakMap,Zo=new WeakMap,Yo=new WeakMap,Go=new WeakSet,Jo=function(){const t=[],e=new Set;this.pages.forEach((t=>{e.add(t.id)}));for(const i of this.pages){const s=i;s.hasEditableAnnotations()?t.push(i):e.delete(s.id)}return 0===t.length?null:(this.drawPagesAsync(this.state.pdfPages),e)},Qo=function(t,e=null){const{div:i,id:s}=t;if(this._currentPageNumber!==s&&this._setCurrentPageNumber(s),!e&&!this.isInPresentationMode){const t=i.offsetLeft+i.clientLeft,s=t+i.clientWidth,{scrollLeft:n,clientWidth:a}=this.element;(this._scrollMode===ve||t<n||s>n+a)&&(e={left:0,top:0})}!function(t,e,i=!1){let s=t.offsetParent;if(!s)return void console.error("offsetParent is not set -- cannot scroll");let n=t.offsetTop+t.clientTop,a=t.offsetLeft+t.clientLeft;for(;s.clientHeight===s.scrollHeight&&s.clientWidth===s.scrollWidth||i&&(s.classList.contains("markedContent")||s.classList.contains("k-marked-content")||"hidden"===getComputedStyle(s).overflow);)if(n+=s.offsetTop,a+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(a+=e.left,s.scrollLeft=a)),s.scrollTop=n}(i,e)},t.D=1.25,t.S=y,t.__meta__={id:"pdfviewer-common.cmn.chunk",name:"PdfviewerCommonCmnChunk",category:"web",description:"A reusable outputed chunk of code",depends:["draggable.cmn.chunk","file-saver.cmn.chunk","common.cmn.chunk","pdfjs.loader"],hidden:!0,chunk:!0},t.a=class extends p{constructor(e,i){super(e,i),Go.add(this),this.options={pdfServiceType:"pdfjs",pdfjsSetHiddenCanvasStyles:!0,fileData:[],page:1,fileDescriptor:null,downloadFileName:"Document",minZoom:.5,maxZoom:4,zoomRate:.25,zoomLevel:lr,zoomBeforePrint:!1,zoomLevelForPrint:3,renderForms:!1,searchMatchScrollLeftOffset:0,searchMatchScrollTopOffset:-64,pageChangeScrollThreshold:.85,pageWheelThrottleDelay:200,printResolution:100,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)",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:{[sr]:d,[nr]:d,[ar]:d,[er]:d,[ir]:d,[tr]:d,[or]:d,[rr]:d,[hr]:d}},this.interactionMode=t.P.TextSelection,this.printContainer=null,this._scrollMode=ye,this.isInPresentationMode=!1,this._currentPageNumber=1,this.linkService=null,this.annotationStorage=null,this._annotationStorageModified=!1,this._hasAnnotationEditors=!1,Ko.set(this,n.AnnotationEditorType.NONE),this.annotationEditorUIManager=null,Xo.set(this,null),qo.set(this,H),Zo.set(this,null),Yo.set(this,null),this.state={},this.pdfDocument=null,this.pages=[],this.triggerError=t=>{this.trigger(tr,{error:t})},this.triggerPrintEnd=t=>{this.trigger(ar,t)},this.onPagesLoad=t=>{this.state.pdfDocument=t.pdfDoc,this.state.pdfPages=t.pdfPages,this.clearSearch(),this.initSearchService(),this.enableDocumentScrollEventsTracking(),this.triggerPagesLoad(t)},this.onDocumentScrollerScroll=t=>{const e=this.getCurrentPageIndex(),i=this.pages,s=i[e],n=i[e+1],a=i[e-1];s&&s.isBlank()&&this.drawPageAsync({pageIndex:e}),n&&n.isBlank()&&this.drawPageAsync({pageIndex:e+1}),a&&a.isBlank()&&this.drawPageAsync({pageIndex:e-1}),this.tryTriggerScroll(t)},this.tryTriggerScroll=t=>{let e=!1;const i=this.getCurrentPageIndex()+1;i!==this.state.activePageNumber&&i>=1&&i<=this.state.pdfDocument.numPages&&(e=!0,this.state.activePageNumber=i),this.shouldPreventScroll?this.shouldPreventScroll=!1:this.trigger(or,{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop,pageNumber:this.state.activePageNumber,isPageChanged:e})},this.printDocumentAsync=()=>{this.initPrintContainer();const t=this.getPagesPrintContentAsync(this.printContainer),e=f();return Promise.all(t).then((()=>{setTimeout((()=>{this.openPrintDialog(),e.resolve()}),dr)})),e},this.onDocumentWheel=t=>{if(!t.ctrlKey&&!t.metaKey)return;t.preventDefault(),t.stopPropagation();const e=(t=>{let e=0;return t.wheelDelta?e=-t.wheelDelta/120:t.detail&&(e=t.detail/3),e=e>0?Math.ceil(e):Math.floor(e),e})(t),i=e<0?1:-1,s=this.state.zoomLevel+i*this.options.zoomRate;this.triggerZoomStart({zoomLevel:s}),this.zoom({zoomLevel:s}),this.triggerZoomEnd({zoomLevel:s})},this.extendOptions(i),this.throwIfInvalidOptions(),this.wrapper=this.element,this.initEventBus(),I(this,Zo,new AbortController,"f"),this.options.renderForms&&I(this,qo,B,"f"),this.resetState(),this.bindEvents(),this.initLinkService(),this.initDocumentContainer(),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()}throwIfInvalidOptions(){if(this.options.minZoom>this.options.maxZoom)throw new Error("The min zoom should be greater than max zoom")}set annotationEditorParams({type:t,value:e}){this.annotationEditorUIManager&&this.annotationEditorUIManager.updateParams(t,e)}get annotationEditorMode(){return this.annotationEditorUIManager?D(this,Ko,"f"):n.AnnotationEditorType.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1}){if(this.annotationEditorUIManager,D(this,Ko,"f")===t)return;if(!this.isValidAnnotationEditorMode(t))return;if(!this.pdfDocument)return;n.AnnotationEditorType.STAMP;const{eventBus:s}=this,a=()=>{this.cleanupSwitchAnnotationEditorMode(),I(this,Ko,t,"f"),this.annotationEditorUIManager.updateMode(t,e,i),s.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===n.AnnotationEditorType.NONE||D(this,Ko,"f")===n.AnnotationEditorType.NONE){const e=t!==n.AnnotationEditorType.NONE;e||this.pdfDocument.annotationStorage.resetModifiedIds();for(const t of this.pages)t.toggleEditingMode(e);const i=D(this,Go,"m",Jo).call(this);if(e&&i){this.cleanupSwitchAnnotationEditorMode(),I(this,Yo,(({pageNumber:t})=>{i.delete(t),0===i.size&&I(this,Xo,setTimeout(a,0),"f")}),"f");const{signal:t}=D(this,Zo,"f");s._on("pagerendered",D(this,Yo,"f"),{signal:t})}}a()}getAnnotationMode(){return D(this,qo,"f")}getPrintUnits(){return this.options.printResolution/n.PixelsPerInch.PDF}extendOptions(t){this.options=r(this.options,t)}setOptions(t){this.options=t}bindEvents(){this.bindPagesWheel()}bindPagesWheel(){const t=this.getDocumentContainer();t&&(this.options.pageWheelThrottleDelay>0?this.throttledPagesWheel=g(this.onDocumentWheel,this.options.pageWheelThrottleDelay):this.throttledPagesWheel=this.onDocumentWheel,t.addEventListener("wheel",this.throttledPagesWheel))}unbindEvents(){this.unbindPagesWheel()}unbindPagesWheel(){const t=this.getDocumentContainer();t&&(this.throttledPagesWheel&&this.throttledPagesWheel.cancel&&this.throttledPagesWheel.cancel(),t.removeEventListener("wheel",this.throttledPagesWheel))}setState(t){this.state=r(this.state||{},t)}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 ce}destroyEventBus(){}initLinkService(){var t;this.linkService=new Uo({eventBus:this.eventBus,externalLinkTarget:Ro,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),null===(t=this.linkService)||void 0===t||t.setViewer(this)}initAnnotationEditorUIManager(){this.annotationEditorUIManager=new de({container:this.getDocumentContainer(),viewer:this.element,pdfViewer:this,pdfDocument:this.state.pdfDocument,eventBus:this.eventBus}),this.setAnnotationEditorUIManagerScale()}setAnnotationEditorUIManagerScale(){var t;null===(t=this.annotationEditorUIManager)||void 0===t||t.onScaleChanging({scale:this.options.zoomLevel})}destroyAnnotationEditorUIManager(){var t;null===(t=this.annotationEditorUIManager)||void 0===t||t.destroy(),this.annotationEditorUIManager=null}bindEventBusAnnotationsEvents(){const t=this.eventBus=this.eventBus||new ce;t._on("switchannotationeditorparams",(t=>{this.annotationEditorParams=t})),t._on("switchannotationeditormode",(e=>{this.annotationEditorUIManager.updateParams(e.type,e.value);const{mode:i,editId:s,isFromKeyboard:n}=e;this.annotationEditorUIManager.annotationEditorMode=e,this.annotationEditorUIManager.updateMode(i,s,n),t.dispatch("annotationeditormodechanged",{source:this,mode:i})})),t._on("kendoAnnotationEditorToolBarShow",(t=>{var e;if(!t)return;const i=this.annotationEditorUIManager.getMode();i!==n.AnnotationEditorType.HIGHLIGHT&&i!==n.AnnotationEditorType.FREETEXT||(i===n.AnnotationEditorType.HIGHLIGHT&&this.addHighlightAnnotation(),this.triggerAnnotationEditorToolBarShow(Object.assign(Object.assign({},t),{annotationEditorMode:i===n.AnnotationEditorType.HIGHLIGHT?"highlight":"freeText",anchor:t.anchor||(null===(e=this.annotationEditorUIManager.firstSelectedEditor)||void 0===e?void 0:e.div)})))})),t._on("kendoAnnotationEditorToolBarHide",(t=>{if(!t)return;const e=this.annotationEditorUIManager.getMode();e!==n.AnnotationEditorType.HIGHLIGHT&&e!==n.AnnotationEditorType.FREETEXT||this.triggerAnnotationEditorToolBarHide(Object.assign(Object.assign({},t),{annotationEditorMode:e===n.AnnotationEditorType.HIGHLIGHT?"highlight":"freeText"}))})),t._on("showannotationeditorui",(e=>{if(e.mode===n.AnnotationEditorType.HIGHLIGHT)t.dispatch("switchannotationeditormode",{source:this,mode:n.AnnotationEditorType.HIGHLIGHT,isFromKeyboard:!1})}))}unbindEventBusAnnotationsEvents(){}loadFile(t){const e=t.data,i={data:null,url:"",arrayBuffer:null,typedArray:null};if(e&&(e.buffer instanceof ArrayBuffer||e instanceof ArrayBuffer)?i.arrayBuffer=e.buffer||e:h(e)&&""!==e?(i.data=e,i.url=null):h(t.url)&&""!==t.url?(i.data=null,i.url=t.url):t.typedArray&&(i.typedArray=t.typedArray),t.data||t.url||t.arrayBuffer||t.typedArray){const t=Object.assign({dom:this.getPagesContainer(),zoom:this.options.zoomLevel},i);this.disableDocumentScrollEventsTracking(),this.clearDocument(),this.initEventBus(),I(this,Zo,new AbortController,"f"),this.bindEvents(),this.initLinkService(),this.initDocumentContainer(),this.loadDocument(t),this.setScaleFactor(this.options.zoomLevel)}}loadDocument(t){const e=this.getDocumentParameters(t),{zoom:i}=t;this.clearDocumentState(),n.getDocument(e).promise.then((t=>{var e;null===(e=this.linkService)||void 0===e||e.setDocument(t),this.initDocumentAnnotationStorage(t),this.initAnnotationEditorUIManager(),this.bindEventBusAnnotationsEvents();const i=[];for(let e=1;e<=t.numPages;e++)i.push(t.getPage(e));return{pagesPromises:i,pdfDoc:t}})).then((({pagesPromises:t,pdfDoc:e})=>(this.state.pagesPromises=t,this.destroyPageComponents(),this.drawPagesFromPromisesAsync(t).then((t=>{this.setHiddenCanvasStyles(),this.onPagesLoad({pdfPages:t,pdfDoc:e,zoom:i})})).catch((t=>{this.triggerError(t)}))))).catch((t=>{this.triggerError(t)})).finally((()=>{var t;null===(t=this.linkService)||void 0===t||t.setDocument(this.pdfDocument)}))}initDocumentAnnotationStorage(t){this.state.pdfDocument=t,this.pdfDocument=t,this.annotationStorage=new Ai,Object.defineProperty(Object.getPrototypeOf(this.pdfDocument._transport),"annotationStorage",{get:()=>{var t;return this.state.isPrintingInProgress?null===(t=this.annotationStorage)||void 0===t?void 0:t.print:this.annotationStorage},set:t=>{this.annotationStorage=t},configurable:!0}),this._initializeAnnotationStorageCallbacks(t)}_initializeAnnotationStorageCallbacks(t){if(t!==this.pdfDocument)return;const{annotationStorage:e}=t;e.onSetModified=()=>{this._annotationStorageModified=!0},e.onResetModified=()=>{delete this._annotationStorageModified},e.onAnnotationEditor=t=>{this._hasAnnotationEditors=!!t}}drawPagesFromPromisesAsync(t){return Promise.all(t).then((t=>C(this,void 0,void 0,(function*(){const e=yield Promise.all(this.drawPagesAsync(t));return this.appendPages(e),t}))))}drawPagesAsync(t){t=t||this.state.pdfPages;if((this.pages||[]).length>0)for(let t=0;t<this.pages.length;t++){const e=this.pages[t].getViewport({scale:this.state.zoomLevel});this.pages[t].viewport=e}else this.initPageComponents(t);const e=[];return t.map(((t,i)=>C(this,void 0,void 0,(function*(){const s=this.pages[i];if(this.options.loadOnDemand&&i>=this.options.loadOnDemandPageSize&&!s.element){const i=this.createBlankPageElements({pdfPage:t,zoom:this.state.zoomLevel});s&&!s.element&&(s.element=i.pageElement,s.setBlank(!0));const n=f();e.push(n),n.then((t=>t)),n.resolve(s.element)}else if(this.options.loadOnDemand&&s.isBlank()){const t=f();e.push(t),t.then((t=>t)),t.resolve(s.element)}else{const t=this.drawPageAsync({pageIndex:i});e.push(t),t.then((t=>t))}})))),e}createBlankPageElements({pdfPage:t,zoom:e}){const i=this.createPageElements({pdfPage:t,zoom:e});return i.canvasWrapper.appendChild(i.canvas),i.pageElement.appendChild(i.canvasWrapper),i}getDocumentParameters(t){let e={verbosity:0,isEvalSupported:!0};return"string"==typeof t.data&&""!==t.data?e.data=A(t.data):"string"==typeof t.url&&""!==t.url?e.url=t.url:t.arrayBuffer instanceof ArrayBuffer?e=t.arrayBuffer:t.typedArray&&(e=t.typedArray),e}appendPages(t){t.forEach((t=>this.appendPage(t)))}appendPage(t,e=null){const i=this.getPagesContainer();l(e)?null==i||i.insertBefore(t,i.children[e]):null==i||i.appendChild(t)}drawPageAsync({pageIndex:t=0}){var e;const i=W(t,0,Math.max(0,this.state.pdfDocument.numPages-1));return null===(e=this.pages[i])||void 0===e?void 0:e.draw().then((()=>(this.triggerPageRendered({page:this.pages[i]}),this.pages[i].element)))}createPageElements({pdfPage:t=null,zoom:e=1,printUnits:i=null}){if(e<=0)return;let s=k(this.options.renderScale);i&&(s=e||s);const n=null==t?void 0:t.getViewport({scale:s}),{adjustedWidth:a,adjustedHeight:o,adjustRatio:r}=_(n.width,n.height),h={width:`round(var(--scale-factor) * ${n.width/s}px, 1px)`,height:`round(var(--scale-factor) * ${n.height/s}px, 1px)`},l=T("div","k-page",h),d=T("canvas","",{width:"100%",height:"100%"});d.height=o,d.width=a,i&&(d.width=Math.floor(d.width*(i||1)),d.height=Math.floor(d.height*(i||1)));const u=d.getContext("2d"),f=c(`\n            <div class="${this.options.elementSelectors.pageCanvasWrapper}"></div>\n        `),p=r*s;return n.width=a,n.height=o,n.scale=p,{canvasContext:u,canvasWrapper:f,canvas:d,viewport:n,scaleNum:s,pageElement:l,styles:h}}triggerPageRendered(t){this.trigger(sr,t)}triggerPagesLoad(t){this.trigger(nr,t)}triggerZoomStart(t){this.trigger(er,t)}triggerZoomEnd(t){this.trigger(ir,t)}triggerDownload(t){return this.trigger("download",t)}triggerAnnotationEditorToolBarShow(t){this.trigger(rr,t)}triggerAnnotationEditorToolBarHide(t){this.trigger(hr,t)}clearDocument(){this.destroyEventBus(),this.unbindEvents(),this.destroySearchService(),this.destroyAnnotationEditorUIManager(),this.clearDocumentState()}clearDocumentState(){var t;this.clearPagesState(),this.state.pdfDocument=null,this.state.pdfPages=[],null===(t=this.linkService)||void 0===t||t.setDocument(null)}clearPagesState(){this.pages.forEach((t=>t.destroy())),this.clearPagesElements(),this.pages=[]}initPageComponents(t){const e=this.options.zoomLevel,i=t[0].getViewport({scale:e*n.PixelsPerInch.PDF_TO_CSS_UNITS});for(let s=1;s<=t.length;s++){const n=s-1,a=new Wo(null,{pdfViewer:this,container:this.element,eventBus:this.eventBus,id:s,scale:e,viewport:i,defaultViewport:i,textLayerMode:me,annotationMode:this.getAnnotationMode(),layerProperties:this._layerProperties});this.pages.push(a),this.pages[n].setPdfPage(t[n])}}destroyPageComponents(){this.pages.forEach((t=>t.destroy())),this.pages=[]}clearPagesElements(){const t=this.getDocumentContainer(),e=this.getPagesContainer();if(!t||!e||!this.hasDocument())return;this.getPagesElements().forEach((t=>{e.removeChild(t)}))}initDocumentContainer(){this.documentContainer||(this.documentContainer=this.getDocumentContainer(),this.initDocumentScroller(this.documentContainer))}initDocumentScroller(t){!this.documentScroller&&t&&(this.documentScroller=this.createDocumentScroller(t,{filter:u(this.options.elementSelectors.pageSelector),events:{[or]:this.onDocumentScrollerScroll}}))}createDocumentScroller(t,e){return new y(t,e)}destroyDocumentScroller(){this.documentScroller&&(this.documentScroller.destroy(),this.documentScroller=null)}enableDocumentScrollEventsTracking(){var t;null===(t=this.documentScroller)||void 0===t||t.enableScrollEventsTracking()}disableDocumentScrollEventsTracking(){var t;null===(t=this.documentScroller)||void 0===t||t.disableScrollEventsTracking()}getCurrentPageIndex(){return L(this.element)||0}downloadFile({fileName:t,saveOptions:e={}}){this.downloadDocument({options:{pdf:this.state.pdfDocument},fileName:t||this.options.downloadFileName,saveOptions:e})}downloadDocument({options:t,fileName:e="Document",saveOptions:i={}}){if(t.pdf){let s=t.pdf.getData.bind(t.pdf),n={},a={};t.pdf.annotationStorage.size>0&&(s=t.pdf.saveDocument.bind(t.pdf),n={},a=t.pdf.annotationStorage.getAll(),Object.keys(a).forEach((t=>{var e;"function"==typeof(null===(e=a[t])||void 0===e?void 0:e.toJSON)?n[t]=a[t].toJSON():n[t]=a[t]})),Object.keys(a).forEach((e=>{t.pdf.annotationStorage.remove(e)})),Object.keys(n).forEach((e=>{t.pdf.annotationStorage.setValue(e,n[e])}))),s().then((t=>new Blob([t],{type:"application/pdf"}))).then((t=>{this.triggerDownload({blob:t,fileName:e,saveOptions:i})||this.saveFile(t,e,i)})).catch((t=>{this.triggerError(t)})).finally((()=>{var e;if((null===(e=t.pdf)||void 0===e?void 0:e.annotationStorage.size)<=0)return;const i=t.pdf.annotationStorage.getAll();Object.keys(i).forEach((e=>{t.pdf.annotationStorage.remove(e)})),Object.keys(a).forEach((e=>{t.pdf.annotationStorage.setValue(e,a[e])}))}))}}saveFile(t,e,s){try{i.s(t,e,s)}catch(t){return!1}return!0}hasDocument(){return l(this.state.pdfDocument)}zoom(t){t.zoomLevel=this.calculateZoomLevel({zoomLevel:t.zoomLevel,zoomLevelType:t.zoomLevelType,currentZoom:this.options.zoomLevel}),this.options.zoomLevel=t.zoomLevel,this.state.zoomLevel=t.zoomLevel,this.eventBus.dispatch("scalechanging",{source:this,scale:this.options.zoomLevel}),this.reloadFile(this.state.pdfDocument)}calculateZoomLevel({zoomLevel:t,zoomLevelType:e,currentZoom:i}){const s=this.getDocumentContainer(),n=s.querySelector(u(this.options.elementSelectors.anyPageSelector));let a=W(t||lr,this.options.minZoom,this.options.maxZoom);if(!l(n))return a;const o=n.offsetWidth,r=n.offsetHeight;return"ActualWidth"===e||"actualWidth"===e?a=1:"FitToWidth"===e||"fitToWidth"===e?a=s.offsetWidth/(o/i):"FitToPage"!==e&&"fitToPage"!==e||(a=s.offsetHeight/(r/i)),a}reloadFile(t){const e=[];for(let i=1;i<=t.numPages;i++)e.push(t.getPage(i));this.disableDocumentScrollEventsTracking(),this.drawPagesFromPromisesAsync(e).then((e=>{this.setHiddenCanvasStyles(),this.onPagesLoad({pdfPages:e,pdfDoc:t})})).catch((t=>{this.triggerError(t)})),this.setScaleFactor(this.state.zoomLevel)}setHiddenCanvasStyles(){if(!this.options.pdfjsSetHiddenCanvasStyles)return;const t=new CSSStyleSheet;t.replaceSync(".hiddenCanvasElement {\n            position: absolute;\n            top: 0;\n            left: 0;\n            width: 0;\n            height: 0;\n            display: none;\n        }"),this.getPagesContainer().ownerDocument.adoptedStyleSheets=[t]}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(ar)}))})).catch(this.triggerError).finally((()=>{this.setState({isPrintingInProgress:!1}),this.restoreZoomLevelBeforePrint()}))):this.loadDocumentForPrintAsync({zoomLevel:this.state.zoomLevel,force:!0}).then((()=>{this.printDocumentAsync().then((()=>{this.trigger(ar)}))})).catch(this.triggerError).finally((()=>{this.setState({isPrintingInProgress:!1})})))}loadDocumentForPrintAsync({zoomLevel:t=1.25,force:e=!1}){const i=this.pages,s=[],n=f();for(let n=0;n<i.length;n++){const a=i[n].loadForPrintAsync({zoomLevel:t,force:e});s.push(a)}return Promise.all(s).then((()=>{n.resolve()})),n}getPagesPrintContentAsync(t){const e=this.pages,i=[];for(let s=0;s<e.length;s++){const n=e[s].getPrintContentAsync();n.then((e=>{const i=c("<div></div>");i.appendChild(e),t.appendChild(i)})),i.push(n)}return i}initPrintContainer(){this.printContainer=c("<div></div>")}openPrintDialog(){const t=this.pages,e=t[0].rawWidth*this.getPrintUnits(),i=t[0].rawHeight*this.getPrintUnits(),s=window.open("","","innerWidth="+e+",innerHeight="+i+"location=no,titlebar=no,toolbar=no");if(!s||!s.document)return void this.triggerError({message:this.options.messages.errorMessages.popupBlocked});s.document.body.style.margin="0",s.document.body.appendChild(this.printContainer);const n=()=>{s.removeEventListener("afterprint",n),s.close()};s.addEventListener("afterprint",n),s.focus(),s.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,currentZoom:this.state.zoomLevel})}searchText(t={text:"",matchCase:!1}){var e;this.initSearchService();return null===(e=this.searchService)||void 0===e?void 0:e.search(t)}clearSearch(){this.destroySearchService()}initSearchService(){const t=Array.from(this.wrapper.querySelectorAll(u(this.options.elementSelectors.textLayerClass))||[]);if(this.searchService){if(t.every(((t,e)=>t===this.searchService.options.textContainers[e])))return;this.destroySearchService()}this.searchService=new M({textContainers:t,highlightClass:this.options.elementSelectors.searchHighlightClass,highlightMarkClass:this.options.elementSelectors.searchHighlightMarkClass,charClass:this.options.elementSelectors.charClass})}destroySearchService(){this.searchService&&(this.searchService.destroy(),this.searchService=null)}goToNextSearchMatch(){if(!this.searchService)return;this.searchService.markNextMatch();const t=this.searchService.getActiveMatchElement();this.scrollToSearchMatch(t)}goToPreviousSearchMatch(){if(!this.searchService)return;this.searchService.markPreviousMatch();const t=this.searchService.getActiveMatchElement();this.scrollToSearchMatch(t)}getPagesContainer(){return this.element.querySelector(u(this.options.elementSelectors.pagesContainerClass))}getDocumentContainer(){return this.wrapper.querySelector(u(this.options.elementSelectors.documentContainerClass))}getPagesElements(){const t=this.getDocumentContainer();return t?(e=t.querySelectorAll(u(this.options.elementSelectors.pageSelector)),Array.from(e)):[];var e}scrollToSearchMatch(t){if(!t)return;const e=t.closest(".k-text-char"),i=e?e.closest('span[role="presentation"]'):null;if(!i)return;const s=i.closest(".k-page");if(!s)return;const n=s.offsetLeft+-1*this.documentScroller.element.offsetLeft+i.offsetLeft+this.options.searchMatchScrollLeftOffset,a=s.offsetTop+-1*this.documentScroller.element.offsetTop+i.offsetTop+this.options.searchMatchScrollTopOffset;this.documentScroller.scrollTo(n,a,{trackScrollEvent:!1})}resetInteractionMode(){this.setInteractionMode({mode:t.P.TextSelection})}setInteractionMode(e){this.interactionMode=e.mode,this.interactionMode===t.P.TextSelection?(this.disableScrollerEventsTracking(),N(this.options.elementSelectors.enabledTextSelectionClass,this.documentScroller.element),O(this.options.elementSelectors.enabledPanningClass,this.documentScroller.element)):this.interactionMode===t.P.Pan&&(this.enableScrollerEventsTracking(),O(this.options.elementSelectors.enabledTextSelectionClass,this.documentScroller.element),N(this.options.elementSelectors.enabledPanningClass,this.documentScroller.element))}enableScrollerEventsTracking(){this.documentScroller&&this.documentScroller.enablePanEventsTracking()}disableScrollerEventsTracking(){this.documentScroller&&this.documentScroller.disablePanEventsTracking()}setScaleFactor(t){this.element.style.setProperty("--scale-factor",String(t*n.PixelsPerInch.PDF_TO_CSS_UNITS))}activatePageNumber(t){const e=this.getPageByNumber(t);if(!e)return;const i=t-1;this.state.activePageNumber!==t&&(this.state.activePageNumber=t,e.isBlank()?this.drawPageAsync({pageIndex:i}).then((()=>{this.scrollToPage({pageNumber:t})})):this.scrollToPage({pageNumber:t}))}scrollToPage({pageNumber:t}){const{left:e,top:i}=this.getPageNumberScrollOffset(t);this.scrollDocument({left:e,top:i})}scrollDocument({left:t,top:e}){var i;null===(i=this.documentScroller)||void 0===i||i.scrollTo(t,e,{trackScrollEvent:!1})}getPageNumberScrollOffset(t){if(!this.getPageByNumber(t))return{left:0,top:0};return{left:0,top:this.pages.slice(0,Math.max(0,t-1)).map((t=>this.getPageScrollOffset(t))).reduce(((t,e)=>t+e),0)}}getPageScrollOffset(t){var e;const i=(null===(e=null==t?void 0:t.element)||void 0===e?void 0:e.getBoundingClientRect().height)||0,s=getComputedStyle(t.element);return i+(parseFloat(s.marginTop)||0)}getPageByNumber(t){return this.pages&&this.pages[t-1]}addHighlightAnnotation(){var t;null===(t=this.annotationEditorUIManager)||void 0===t||t.highlightSelection()}setHighlightColor(t){this.executeAnnotationCommand({commandType:n.AnnotationEditorParamsType.HIGHLIGHT_COLOR,commandValue:t})}deleteAnnotation(){var t;null===(t=this.annotationEditorUIManager)||void 0===t||t.delete()}resetAnnotationEditorMode(){this.setAnnotationEditorMode({mode:n.AnnotationEditorType.NONE,editId:null,isFromKeyboard:!1})}setAnnotationEditorMode(t){this.annotationEditorMode=t}setFreeTextColor(t){this.executeAnnotationCommand({commandType:n.AnnotationEditorParamsType.FREETEXT_COLOR,commandValue:t})}setFreeTextFontSize(t){this.executeAnnotationCommand({commandType:n.AnnotationEditorParamsType.FREETEXT_SIZE,commandValue:parseFloat(t)})}executeAnnotationCommand({commandType:t,commandValue:e}){this.eventBus.dispatch("switchannotationeditorparams",{source:this,type:t,value:e})}isValidAnnotationEditorMode(t){return Object.values(n.AnnotationEditorType).includes(t)&&t!==n.AnnotationEditorType.DISABLE}cleanupSwitchAnnotationEditorMode(){D(this,Yo,"f")&&(this.eventBus._off("pagerendered",D(this,Yo,"f")),I(this,Yo,null,"f")),null!==D(this,Xo,"f")&&(clearTimeout(D(this,Xo,"f")),I(this,Xo,null,"f"))}_getVisiblePages(){return this.pages}get _layerProperties(){const t=this;return n.shadow(this,"_layerProperties",{get annotationEditorUIManager(){return t.annotationEditorUIManager},get annotationStorage(){var e;return null===(e=t.pdfDocument)||void 0===e?void 0:e.annotationStorage},get linkService(){return t.linkService}})}scrollPageIntoView({pageNumber:t,destArray:e=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:s=!1}){if(!this.pdfDocument)return;const a=Number.isInteger(t)&&this.pages[t-1];if(!a)return;if(this.isInPresentationMode||!e)return void this._setCurrentPageNumber(t,!0);let o=0,r=0;const h=(a.rotation%180!=0?a.rawWidth:a.rawHeight)/a.scale/n.PixelsPerInch.PDF_TO_CSS_UNITS;if("XYZ"!==e[1].name)return;o=e[2],r=e[3],o=null!==o?o:0,r=null!==r?r:h;const l=[a.viewport.convertToViewportPoint(o,r),a.viewport.convertToViewportPoint(o+0,r+0)];let d=Math.min(l[0][0],l[1][0]),c=Math.min(l[0][1],l[1][1]);i||(d=Math.max(d,0),c=Math.max(c,0)),D(this,Go,"m",Qo).call(this,a,{left:d,top:c})}_setCurrentPageNumber(t,e=!1){if(this._currentPageNumber===t)return!0;if(!(0<t&&t<=this.state.pdfDocument.numPages))return!1;const i=this._currentPageNumber;return this._currentPageNumber=t,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:t,previous:i}),!0}},t.c=L,t.s=P}));
//# sourceMappingURL=kendo.pdfviewer-common.cmn.chunk.min.js.map