/*!
 * Nutrient Web SDK 1.15.0-aa66391 (https://www.nutrient.io/sdk/web)
 *
 * Copyright (c) 2016-2026 PSPDFKit GmbH. All rights reserved.
 *
 * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
 * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
 * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
 * This notice may not be removed from this file.
 *
 * PSPDFKit uses several open source third-party components: https://www.nutrient.io/legal/acknowledgements/web-acknowledgements/
 */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.NutrientViewer=t():e.NutrientViewer=t()}(globalThis,()=>(()=>{var e={45369(e,t,r){var n=r(95350),i=r(89700),s=r(73146),o=i.DEFAULT_COMPARATOR,a=i.reverseComparator;function u(e,t,r,n){for(var i,s,o=t[n];n>r&&e(o,s=t[i=n-1>>1])<0;)t[n]=s,n=i;t[n]=o}function c(e,t,r){for(var n,i=t.length,s=r,o=t[r],a=2*r+1;a<i;)(n=a+1)<i&&e(t[a],t[n])>=0&&(a=n),t[r]=t[a],a=2*(r=a)+1;t[r]=o,u(e,t,s,r)}function l(e,t,r){t.push(r),u(e,t,0,t.length-1)}function h(e,t){var r=t.pop();if(0!==t.length){var n=t[0];return t[0]=r,c(e,t,0),n}return r}function p(e,t,r){if(0===t.length)throw new Error("mnemonist/heap.replace: cannot pop an empty heap.");var n=t[0];return t[0]=r,c(e,t,0),n}function d(e,t,r){var n;return 0!==t.length&&e(t[0],r)<0&&(n=t[0],t[0]=r,r=n,c(e,t,0)),r}function f(e,t){for(var r=t.length>>1;--r>=0;)c(e,t,r)}function y(e,t){for(var r=t.length,n=0,i=new Array(r);n<r;)i[n++]=h(e,t);return i}function g(e){if(this.clear(),this.comparator=e||o,"function"!=typeof this.comparator)throw new Error("mnemonist/Heap.constructor: given comparator should be a function.")}function m(e){if(this.clear(),this.comparator=e||o,"function"!=typeof this.comparator)throw new Error("mnemonist/MaxHeap.constructor: given comparator should be a function.");this.comparator=a(this.comparator)}g.prototype.clear=function(){this.items=[],this.size=0},g.prototype.push=function(e){return l(this.comparator,this.items,e),++this.size},g.prototype.peek=function(){return this.items[0]},g.prototype.pop=function(){return 0!==this.size&&this.size--,h(this.comparator,this.items)},g.prototype.replace=function(e){return p(this.comparator,this.items,e)},g.prototype.pushpop=function(e){return d(this.comparator,this.items,e)},g.prototype.consume=function(){return this.size=0,y(this.comparator,this.items)},g.prototype.toArray=function(){return y(this.comparator,this.items.slice())},g.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,"constructor",{value:g,enumerable:!1}),e},"undefined"!=typeof Symbol&&(g.prototype[Symbol.for("nodejs.util.inspect.custom")]=g.prototype.inspect),m.prototype=g.prototype,g.from=function(e,t){var r,n=new g(t);return r=s.isArrayLike(e)?e.slice():s.toArray(e),f(n.comparator,r),n.items=r,n.size=r.length,n},m.from=function(e,t){var r,n=new m(t);return r=s.isArrayLike(e)?e.slice():s.toArray(e),f(n.comparator,r),n.items=r,n.size=r.length,n},g.siftUp=c,g.siftDown=u,g.push=l,g.pop=h,g.replace=p,g.pushpop=d,g.heapify=f,g.consume=y,g.nsmallest=function(e,t,r){2===arguments.length&&(r=t,t=e,e=o);var i,u,c,l,h=a(e),d=1/0;if(1===t){if(s.isArrayLike(r)){for(i=0,u=r.length;i<u;i++)c=r[i],(d===1/0||e(c,d)<0)&&(d=c);return(l=new r.constructor(1))[0]=d,l}return n(r,function(t){(d===1/0||e(t,d)<0)&&(d=t)}),[d]}if(s.isArrayLike(r)){if(t>=r.length)return r.slice().sort(e);for(l=r.slice(0,t),f(h,l),i=t,u=r.length;i<u;i++)h(r[i],l[0])>0&&p(h,l,r[i]);return l.sort(e)}var y=s.guessLength(r);return null!==y&&y<t&&(t=y),l=new Array(t),i=0,n(r,function(e){i<t?l[i]=e:(i===t&&f(h,l),h(e,l[0])>0&&p(h,l,e)),i++}),l.length>i&&(l.length=i),l.sort(e)},g.nlargest=function(e,t,r){2===arguments.length&&(r=t,t=e,e=o);var i,u,c,l,h=a(e),d=-1/0;if(1===t){if(s.isArrayLike(r)){for(i=0,u=r.length;i<u;i++)c=r[i],(d===-1/0||e(c,d)>0)&&(d=c);return(l=new r.constructor(1))[0]=d,l}return n(r,function(t){(d===-1/0||e(t,d)>0)&&(d=t)}),[d]}if(s.isArrayLike(r)){if(t>=r.length)return r.slice().sort(h);for(l=r.slice(0,t),f(e,l),i=t,u=r.length;i<u;i++)e(r[i],l[0])>0&&p(e,l,r[i]);return l.sort(h)}var y=s.guessLength(r);return null!==y&&y<t&&(t=y),l=new Array(t),i=0,n(r,function(r){i<t?l[i]=r:(i===t&&f(e,l),e(r,l[0])>0&&p(e,l,r)),i++}),l.length>i&&(l.length=i),l.sort(h)},g.MinHeap=g,g.MaxHeap=m,e.exports=g},89700(e,t){t.DEFAULT_COMPARATOR=function(e,t){return e<t?-1:e>t?1:0},t.DEFAULT_REVERSE_COMPARATOR=function(e,t){return e<t?1:e>t?-1:0},t.reverseComparator=function(e){return function(t,r){return e(r,t)}},t.createTupleComparator=function(e){return 2===e?function(e,t){return e[0]<t[0]?-1:e[0]>t[0]?1:e[1]<t[1]?-1:e[1]>t[1]?1:0}:function(t,r){for(var n=0;n<e;){if(t[n]<r[n])return-1;if(t[n]>r[n])return 1;n++}return 0}}},73146(e,t,r){var n=r(95350),i=r(99232);function s(e){return"number"==typeof e.length?e.length:"number"==typeof e.size?e.size:void 0}t.isArrayLike=function(e){return Array.isArray(e)||i.isTypedArray(e)},t.guessLength=s,t.toArray=function(e){var t=s(e),r="number"==typeof t?new Array(t):[],i=0;return n(e,function(e){r[i++]=e}),r},t.toArrayWithIndices=function(e){var t=s(e),r="number"==typeof t?i.getPointerArray(t):Array,o="number"==typeof t?new Array(t):[],a="number"==typeof t?new r(t):[],u=0;return n(e,function(e){o[u]=e,a[u]=u++}),[o,a]}},99232(e,t){var r=Math.pow(2,8)-1,n=Math.pow(2,16)-1,i=Math.pow(2,32)-1,s=Math.pow(2,7)-1,o=Math.pow(2,15)-1,a=Math.pow(2,31)-1;t.getPointerArray=function(e){var t=e-1;if(t<=r)return Uint8Array;if(t<=n)return Uint16Array;if(t<=i)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},t.getSignedPointerArray=function(e){var t=e-1;return t<=s?Int8Array:t<=o?Int16Array:t<=a?Int32Array:Float64Array},t.getNumberType=function(e){return e===(0|e)?-1===Math.sign(e)?e<=127&&e>=-128?Int8Array:e<=32767&&e>=-32768?Int16Array:Int32Array:e<=255?Uint8Array:e<=65535?Uint16Array:Uint32Array:Float64Array};var u={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};t.getMinimalRepresentation=function(e,r){var n,i,s,o,a,c=null,l=0;for(o=0,a=e.length;o<a;o++)s=r?r(e[o]):e[o],i=t.getNumberType(s),(n=u[i.name])>l&&(l=n,c=i);return c},t.isTypedArray=function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView(e)},t.concat=function(){var e,t,r,n=0;for(e=0,r=arguments.length;e<r;e++)n+=arguments[e].length;var i=new arguments[0].constructor(n);for(e=0,t=0;e<r;e++)i.set(arguments[e],t),t+=arguments[e].length;return i},t.indices=function(e){for(var r=new(t.getPointerArray(e))(e),n=0;n<e;n++)r[n]=n;return r}},95350(e,t,r){var n=r(63531),i=n.ARRAY_BUFFER_SUPPORT,s=n.SYMBOL_SUPPORT;e.exports=function(e,t){var r,n,o,a,u;if(!e)throw new Error("obliterator/forEach: invalid iterable.");if("function"!=typeof t)throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(e)||i&&ArrayBuffer.isView(e)||"string"==typeof e||"[object Arguments]"===e.toString())for(o=0,a=e.length;o<a;o++)t(e[o],o);else if("function"!=typeof e.forEach)if(s&&Symbol.iterator in e&&"function"!=typeof e.next&&(e=e[Symbol.iterator]()),"function"!=typeof e.next)for(n in e)e.hasOwnProperty(n)&&t(e[n],n);else for(r=e,o=0;!0!==(u=r.next()).done;)t(u.value,o),o++;else e.forEach(t)}},63531(e,t){t.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,t.SYMBOL_SUPPORT="undefined"!=typeof Symbol}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);return(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!=e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}function n(e,r,n){return(r=t(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}const i=Symbol("Comlink.proxy"),s=Symbol("Comlink.endpoint"),o=Symbol("Comlink.releaseProxy"),a=Symbol("Comlink.finalizer"),u=Symbol("Comlink.thrown"),c=e=>"object"==typeof e&&null!==e||"function"==typeof e,l=new Map([["proxy",{canHandle:e=>c(e)&&e[i],serialize(e){const{port1:t,port2:r}=new MessageChannel;return h(e,t),[r,[r]]},deserialize:e=>(e.start(),d(e))}],["throw",{canHandle:e=>c(e)&&u in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function h(e,t=globalThis,r=["*"]){t.addEventListener("message",function n(s){if(!s||!s.data)return;if(!function(e,t){for(const r of e){if(t===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(t))return!0}return!1}(r,s.origin))return void console.warn(`Invalid origin '${s.origin}' for comlink proxy`);const{id:o,type:c,path:l}=Object.assign({path:[]},s.data),d=(s.data.argumentList||[]).map(A);let f;try{const t=l.slice(0,-1).reduce((e,t)=>e[t],e),r=l.reduce((e,t)=>e[t],e);switch(c){case"GET":f=r;break;case"SET":t[l.slice(-1)[0]]=A(s.data.value),f=!0;break;case"APPLY":f=r.apply(t,d);break;case"CONSTRUCT":f=function(e){return Object.assign(e,{[i]:!0})}(new r(...d));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;h(e,r),f=function(e,t){return w.set(e,t),e}(t,[t])}break;case"RELEASE":f=void 0;break;default:return}}catch(e){f={value:e,[u]:0}}Promise.resolve(f).catch(e=>({value:e,[u]:0})).then(r=>{const[i,s]=R(r);t.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===c&&(t.removeEventListener("message",n),p(t),a in e&&"function"==typeof e[a]&&e[a]())}).catch(e=>{const[r,n]=R({value:new TypeError("Unserializable return value"),[u]:0});t.postMessage(Object.assign(Object.assign({},r),{id:o}),n)})}),t.start&&t.start()}function p(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function d(e,t){const r=new Map;return e.addEventListener("message",function(e){const{data:t}=e;if(!t||!t.id)return;const n=r.get(t.id);if(n)try{n(t)}finally{r.delete(t.id)}}),b(e,r,[],t)}function f(e){if(e)throw new Error("Proxy has been released and is not useable")}function y(e){return q(e,new Map,{type:"RELEASE"}).then(()=>{p(e)})}const g=new WeakMap,m="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(g.get(e)||0)-1;g.set(e,t),0===t&&y(e)});function b(e,t,r=[],n=function(){}){let i=!1;const a=new Proxy(n,{get(n,s){if(f(i),s===o)return()=>{!function(e){m&&m.unregister(e)}(a),y(e),t.clear(),i=!0};if("then"===s){if(0===r.length)return{then:()=>a};const n=q(e,t,{type:"GET",path:r.map(e=>e.toString())}).then(A);return n.then.bind(n)}return b(e,t,[...r,s])},set(n,s,o){f(i);const[a,u]=R(o);return q(e,t,{type:"SET",path:[...r,s].map(e=>e.toString()),value:a},u).then(A)},apply(n,o,a){f(i);const u=r[r.length-1];if(u===s)return q(e,t,{type:"ENDPOINT"}).then(A);if("bind"===u)return b(e,t,r.slice(0,-1));const[c,l]=v(a);return q(e,t,{type:"APPLY",path:r.map(e=>e.toString()),argumentList:c},l).then(A)},construct(n,s){f(i);const[o,a]=v(s);return q(e,t,{type:"CONSTRUCT",path:r.map(e=>e.toString()),argumentList:o},a).then(A)}});return function(e,t){const r=(g.get(t)||0)+1;g.set(t,r),m&&m.register(e,t,e)}(a,e),a}function v(e){const t=e.map(R);return[t.map(e=>e[0]),(r=t.map(e=>e[1]),Array.prototype.concat.apply([],r))];var r}const w=new WeakMap;function R(e){for(const[t,r]of l)if(r.canHandle(e)){const[n,i]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},i]}return[{type:"RAW",value:e},w.get(e)||[]]}function A(e){switch(e.type){case"HANDLER":return l.get(e.name).deserialize(e.value);case"RAW":return e.value}}function q(e,t,r,n){return new Promise(i=>{const s=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");t.set(s,i),e.start&&e.start(),e.postMessage(Object.assign({id:s},r),n)})}const S=function e(t){let r;return r=t instanceof Error?t:new Error(t),Object.setPrototypeOf(r,e.prototype),r};S.prototype=Object.create(Error.prototype,{name:{value:"PSPDFKitError",enumerable:!1}});const E=S;["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'].join(",");new WeakMap;var P=r(45369),C=r.n(P);class I{constructor(e,t,r){n(this,"queue",new(C())((e,t)=>e.priority-t.priority)),n(this,"queuedRequests",new Map),n(this,"activeRequests",new Map),n(this,"isProcessing",!1),n(this,"renderCallbacks",new Map),n(this,"errorCallbacks",new Map),n(this,"latestViewportUpdateId",new Map),n(this,"maxConcurrentRequests",1),n(this,"activeRequestCount",0),this.renderChannel=e,this.maxConcurrentRequests=t,this.isServer=r}static async create(e){const t=await e.isServer();return new I(e,t?4:1,t)}setCallbacks(e,t,r){this.renderCallbacks.set(e,t),this.errorCallbacks.set(e,r)}enqueue(e,t){const r=Date.now();if(0===t.length)return;let n=this.latestViewportUpdateId.get(e)??-1/0;for(const e of t)e.viewportRenderUpdateId>n&&(n=e.viewportRenderUpdateId);const i=this.latestViewportUpdateId.get(e);void 0!==i&&n>i&&this.cancelStaleRequests(e,n),this.latestViewportUpdateId.set(e,n);for(const n of t){const t=this.activeRequests.get(n.id);if(t){if(!t.cancelled)continue;this.activeRequests.delete(n.id)}const i=this.queuedRequests.get(n.id);i&&(i.cancelled=!0,this.queuedRequests.delete(n.id));const s={request:n,sessionId:e,priority:this.calculatePriority(n),timestamp:r,cancelled:!1};this.queue.push(s),this.queuedRequests.set(n.id,s)}this.isProcessing||this.startProcessing()}cancel(e,t){for(const r of t){const t=this.queuedRequests.get(r);t&&t.sessionId===e&&(t.cancelled=!0);const n=this.activeRequests.get(r);n&&n.sessionId===e&&(n.cancelled=!0)}}cancelSession(e){for(const t of this.queuedRequests.values())t.sessionId===e&&(t.cancelled=!0);for(const t of this.activeRequests.values())t.sessionId===e&&(t.cancelled=!0);this.latestViewportUpdateId.delete(e)}async startProcessing(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.size>0||this.activeRequestCount>0;){for(;this.activeRequestCount<this.maxConcurrentRequests&&this.queue.size>0;){const e=this.getNextRequest();if(!e)break;this.activeRequestCount++,this.processRequest(e).finally(()=>{this.activeRequestCount--})}await new Promise(e=>setTimeout(e,0))}this.isProcessing=!1}}getNextRequest(){for(;this.queue.size>0;){const e=this.queue.pop();if(!e)break;if(this.queuedRequests.delete(e.request.id),!e.cancelled)return this.activeRequests.set(e.request.id,e),e}return null}async processRequest(e){const t=this.collectBatch(e);if(t.length>1)return void await this.processBatch(t);const{request:r,sessionId:n}=e;try{if(e.cancelled)return;const t=await this.renderTile(r);if(e.cancelled)return;const i=this.renderCallbacks.get(n);i&&i(n,r.id,t)}catch(t){if(console.error("[SharedRenderQueue] Error processing request:",t),!e.cancelled){const e=this.errorCallbacks.get(n);e&&e(n,r.id,t)}}finally{this.activeRequests.delete(r.id)}}collectBatch(e){if(this.isServer||this.maxConcurrentRequests>1)return[e];if(!("function"==typeof this.renderChannel.renderTiles))return[e];const{request:t,sessionId:r}=e;if(t.options.disableBatch)return[e];const n=[e],i=[],s=8-n.length;for(const e of this.queuedRequests.values()){if(i.length>=s)break;e.cancelled||e.sessionId!==r||this.canBatchWith(e,t)&&i.push(e)}for(const e of i)this.queuedRequests.delete(e.request.id),this.activeRequests.set(e.request.id,e),n.push(e);return n}canBatchWith(e,t){const{sourceInfo:r,options:n,viewportRenderUpdateId:i}=t,s=e.request,o=s.options;return s.viewportRenderUpdateId===i&&s.sourceInfo.pageIndex===r.pageIndex&&s.sourceInfo.pageSize.width===r.pageSize.width&&s.sourceInfo.pageSize.height===r.pageSize.height&&o.renderForPrinting===n.renderForPrinting&&o.renderText===n.renderText&&o.renderAnnotations===n.renderAnnotations&&Boolean(o.disableBatch)===Boolean(n.disableBatch)&&(o.priority||"high")===(n.priority||"high")}async processBatch(e){const[t]=e,{sessionId:r}=t;try{const t=await this.renderTiles(e.map(e=>e.request));if(t.length!==e.length)return console.warn(`[SharedRenderQueue] renderTiles returned ${t.length} results for ${e.length} requests; falling back to per-tile rendering.`),void await Promise.all(e.map(async e=>{if(!e.cancelled)try{const t=await this.renderTile(e.request),n=this.renderCallbacks.get(r);n&&n(r,e.request.id,t)}catch(t){if(!e.cancelled){const n=this.errorCallbacks.get(r);n&&n(r,e.request.id,t)}}finally{this.activeRequests.delete(e.request.id)}}));for(let n=0;n<e.length;n++){const i=e[n],s=t[n];if(i.cancelled)continue;const o=this.renderCallbacks.get(r);o&&o(r,i.request.id,s),this.activeRequests.delete(i.request.id)}}catch(t){console.error("[SharedRenderQueue] Error processing request batch:",t);for(const n of e){if(!n.cancelled){const e=this.errorCallbacks.get(r);e&&e(r,n.request.id,t)}this.activeRequests.delete(n.request.id)}}}async renderTile(e){const{sourceInfo:t,options:r}=e,n=await this.renderChannel.render(t.pageIndex,t.pageSize,t.tileRect,{renderForPrinting:r.renderForPrinting,renderText:r.renderText,priority:r.priority||"high"});return{buffer:n,format:r.format||"bitmap",width:n.width,height:n.height}}async renderTiles(e){const{sourceInfo:t,options:r}=e[0],n=e.map(e=>e.sourceInfo.tileRect);return(await this.renderChannel.renderTiles(t.pageIndex,t.pageSize,n,{renderForPrinting:r.renderForPrinting,renderText:r.renderText,priority:r.priority||"high"})).map(e=>({buffer:e,format:r.format||"bitmap",width:e.width,height:e.height}))}calculatePriority(e){let t=0;"high"===e.options.priority&&(t-=1e3),e.targetInfo.isVisible&&(t-=500),t-=10*e.viewportRenderUpdateId;return t+=100*Math.abs(e.targetInfo.scale-e.targetInfo.targetScale),t}cancelStaleRequests(e,t){for(const[r,n]of this.queuedRequests.entries())n.sessionId===e&&n.request.viewportRenderUpdateId<t&&(n.cancelled=!0,this.queuedRequests.delete(r));for(const r of this.activeRequests.values())r.sessionId===e&&r.request.viewportRenderUpdateId<t&&(r.cancelled=!0)}}h(new class{constructor(){n(this,"sharedRenderQueue",null),n(this,"sharedRenderQueuePromise",null),n(this,"sessionCallbacks",new Map),n(this,"sessionErrors",new Map),n(this,"renderChannel",null),n(this,"sessionCounter",0),n(this,"viewportUpdateCounter",0)}async setupRenderMessageChannel(e){this.renderChannel=d(e)}async getSharedRenderQueue(){this.sharedRenderQueuePromise||(!function(e,t){if(!e)throw new E(`Assertion failed: ${t||"Condition not met"}\n\nFor further assistance, please go to: https://www.nutrient.io/support/request`)}(this.renderChannel,"Setup render channel first"),this.sharedRenderQueuePromise=I.create(this.renderChannel));const e=await this.sharedRenderQueuePromise;return this.sharedRenderQueue=e,e}async beginRenderer(e,t,r,n,i){const s=await this.getSharedRenderQueue(),o=`page-${e}-${this.sessionCounter++}`;return this.sessionCallbacks.set(o,n),this.sessionErrors.set(o,i),s.setCallbacks(o,this.handleTileReady.bind(this),this.handleTileError.bind(this)),o}async requestTiles(e,t){if(!this.sharedRenderQueue)return void console.warn("SharedRenderQueue not initialized");const r=++this.viewportUpdateCounter,n=t.map(e=>({id:e.id,viewportRenderUpdateId:r,sourceInfo:{pageIndex:e.pageIndex,pageSize:e.pageSize,tileRect:e.tileRect},targetInfo:{scale:e.mip,targetScale:e.mip,isVisible:!0,canvasRect:{left:0,top:0,width:e.tileRect.width,height:e.tileRect.height}},options:{renderAnnotations:e.options.renderAnnotations,renderText:e.options.renderText,format:"bitmap",priority:e.options.priority,disableBatch:e.options.disableBatch}}));this.sharedRenderQueue.enqueue(e,n)}async cancelTiles(e,t){this.sharedRenderQueue&&this.sharedRenderQueue.cancel(e,t)}async endRenderer(e){this.sessionCallbacks.delete(e),this.sessionErrors.delete(e),this.sharedRenderQueue?.cancelSession(e)}handleTileReady(e,t,r){const n=this.sessionCallbacks.get(e);n&&n(e,t,r)}handleTileError(e,t,r){const n=this.sessionErrors.get(e);n&&n(e,t,r)}})})(),{}})());