/** * @licstart the following is the entire license notice for the * javascript code in this page * * copyright 2020 mozilla foundation * * licensed under the apache license, version 2.0 (the "license"); * you may not use this file except in compliance with the license. * you may obtain a copy of the license at * * http://www.apache.org/licenses/license-2.0 * * unless required by applicable law or agreed to in writing, software * distributed under the license is distributed on an "as is" basis, * without warranties or conditions of any kind, either express or implied. * see the license for the specific language governing permissions and * limitations under the license. * * @licend the above is the entire license notice for the * javascript code in this page */ (function webpackuniversalmoduledefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define("pdfjs-dist/web/pdf_viewer", [], factory); else if(typeof exports === 'object') exports["pdfjs-dist/web/pdf_viewer"] = factory(); else root["pdfjs-dist/web/pdf_viewer"] = root.pdfjsviewer = factory(); })(this, function() { return /******/ (function(modules) { // webpackbootstrap /******/ // the module cache /******/ var installedmodules = {}; /******/ /******/ // the require function /******/ function __w_pdfjs_require__(moduleid) { /******/ /******/ // check if module is in cache /******/ if(installedmodules[moduleid]) { /******/ return installedmodules[moduleid].exports; /******/ } /******/ // create a new module (and put it into the cache) /******/ var module = installedmodules[moduleid] = { /******/ i: moduleid, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // execute the module function /******/ modules[moduleid].call(module.exports, module, module.exports, __w_pdfjs_require__); /******/ /******/ // flag the module as loaded /******/ module.l = true; /******/ /******/ // return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __w_pdfjs_require__.m = modules; /******/ /******/ // expose the module cache /******/ __w_pdfjs_require__.c = installedmodules; /******/ /******/ // define getter function for harmony exports /******/ __w_pdfjs_require__.d = function(exports, name, getter) { /******/ if(!__w_pdfjs_require__.o(exports, name)) { /******/ object.defineproperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esmodule on exports /******/ __w_pdfjs_require__.r = function(exports) { /******/ if(typeof symbol !== 'undefined' && symbol.tostringtag) { /******/ object.defineproperty(exports, symbol.tostringtag, { value: 'module' }); /******/ } /******/ object.defineproperty(exports, '__esmodule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __w_pdfjs_require__.t = function(value, mode) { /******/ if(mode & 1) value = __w_pdfjs_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esmodule) return value; /******/ var ns = object.create(null); /******/ __w_pdfjs_require__.r(ns); /******/ object.defineproperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __w_pdfjs_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getdefaultexport function for compatibility with non-harmony modules /******/ __w_pdfjs_require__.n = function(module) { /******/ var getter = module && module.__esmodule ? /******/ function getdefault() { return module['default']; } : /******/ function getmoduleexports() { return module; }; /******/ __w_pdfjs_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // object.prototype.hasownproperty.call /******/ __w_pdfjs_require__.o = function(object, property) { return object.prototype.hasownproperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __w_pdfjs_require__.p = ""; /******/ /******/ /******/ // load entry module and return exports /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); object.defineproperty(exports, "annotationlayerbuilder", { enumerable: true, get: function () { return _annotation_layer_builder.annotationlayerbuilder; } }); object.defineproperty(exports, "defaultannotationlayerfactory", { enumerable: true, get: function () { return _annotation_layer_builder.defaultannotationlayerfactory; } }); object.defineproperty(exports, "defaulttextlayerfactory", { enumerable: true, get: function () { return _text_layer_builder.defaulttextlayerfactory; } }); object.defineproperty(exports, "textlayerbuilder", { enumerable: true, get: function () { return _text_layer_builder.textlayerbuilder; } }); object.defineproperty(exports, "eventbus", { enumerable: true, get: function () { return _ui_utils.eventbus; } }); object.defineproperty(exports, "nulll10n", { enumerable: true, get: function () { return _ui_utils.nulll10n; } }); object.defineproperty(exports, "progressbar", { enumerable: true, get: function () { return _ui_utils.progressbar; } }); object.defineproperty(exports, "pdflinkservice", { enumerable: true, get: function () { return _pdf_link_service.pdflinkservice; } }); object.defineproperty(exports, "simplelinkservice", { enumerable: true, get: function () { return _pdf_link_service.simplelinkservice; } }); object.defineproperty(exports, "downloadmanager", { enumerable: true, get: function () { return _download_manager.downloadmanager; } }); object.defineproperty(exports, "genericl10n", { enumerable: true, get: function () { return _genericl10n.genericl10n; } }); object.defineproperty(exports, "pdffindcontroller", { enumerable: true, get: function () { return _pdf_find_controller.pdffindcontroller; } }); object.defineproperty(exports, "pdfhistory", { enumerable: true, get: function () { return _pdf_history.pdfhistory; } }); object.defineproperty(exports, "pdfpageview", { enumerable: true, get: function () { return _pdf_page_view.pdfpageview; } }); object.defineproperty(exports, "pdfsinglepageviewer", { enumerable: true, get: function () { return _pdf_single_page_viewer.pdfsinglepageviewer; } }); object.defineproperty(exports, "pdfviewer", { enumerable: true, get: function () { return _pdf_viewer.pdfviewer; } }); var _annotation_layer_builder = __w_pdfjs_require__(1); var _text_layer_builder = __w_pdfjs_require__(5); var _ui_utils = __w_pdfjs_require__(3); var _pdf_link_service = __w_pdfjs_require__(4); var _download_manager = __w_pdfjs_require__(6); var _genericl10n = __w_pdfjs_require__(7); var _pdf_find_controller = __w_pdfjs_require__(9); var _pdf_history = __w_pdfjs_require__(11); var _pdf_page_view = __w_pdfjs_require__(12); var _pdf_single_page_viewer = __w_pdfjs_require__(15); var _pdf_viewer = __w_pdfjs_require__(17); const pdfjsversion = '2.4.0'; const pdfjsbuild = ''; (0, _ui_utils.getglobaleventbus)(true); /***/ }), /* 1 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.defaultannotationlayerfactory = exports.annotationlayerbuilder = void 0; var _pdfjslib = __w_pdfjs_require__(2); var _ui_utils = __w_pdfjs_require__(3); var _pdf_link_service = __w_pdfjs_require__(4); class annotationlayerbuilder { constructor({ pagediv, pdfpage, linkservice, downloadmanager, imageresourcespath = "", renderinteractiveforms = false, l10n = _ui_utils.nulll10n }) { this.pagediv = pagediv; this.pdfpage = pdfpage; this.linkservice = linkservice; this.downloadmanager = downloadmanager; this.imageresourcespath = imageresourcespath; this.renderinteractiveforms = renderinteractiveforms; this.l10n = l10n; this.div = null; this._cancelled = false; } render(viewport, intent = "display") { this.pdfpage.getannotations({ intent }).then(annotations => { if (this._cancelled) { return; } const parameters = { viewport: viewport.clone({ dontflip: true }), div: this.div, annotations, page: this.pdfpage, imageresourcespath: this.imageresourcespath, renderinteractiveforms: this.renderinteractiveforms, linkservice: this.linkservice, downloadmanager: this.downloadmanager }; if (this.div) { _pdfjslib.annotationlayer.update(parameters); } else { if (annotations.length === 0) { return; } this.div = document.createelement("div"); this.div.classname = "annotationlayer"; this.pagediv.appendchild(this.div); parameters.div = this.div; _pdfjslib.annotationlayer.render(parameters); this.l10n.translate(this.div); } }); } cancel() { this._cancelled = true; } hide() { if (!this.div) { return; } this.div.setattribute("hidden", "true"); } } exports.annotationlayerbuilder = annotationlayerbuilder; class defaultannotationlayerfactory { createannotationlayerbuilder(pagediv, pdfpage, imageresourcespath = "", renderinteractiveforms = false, l10n = _ui_utils.nulll10n) { return new annotationlayerbuilder({ pagediv, pdfpage, imageresourcespath, renderinteractiveforms, linkservice: new _pdf_link_service.simplelinkservice(), l10n }); } } exports.defaultannotationlayerfactory = defaultannotationlayerfactory; /***/ }), /* 2 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; let pdfjslib; if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) { pdfjslib = window["pdfjs-dist/build/pdf"]; } else { pdfjslib = require("../build/pdf.js"); } module.exports = pdfjslib; /***/ }), /* 3 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.isvalidrotation = isvalidrotation; exports.isvalidscrollmode = isvalidscrollmode; exports.isvalidspreadmode = isvalidspreadmode; exports.isportraitorientation = isportraitorientation; exports.getglobaleventbus = getglobaleventbus; exports.clamp = clamp; exports.getpdffilenamefromurl = getpdffilenamefromurl; exports.nocontextmenuhandler = nocontextmenuhandler; exports.parsequerystring = parsequerystring; exports.backtrackbeforeallvisibleelements = backtrackbeforeallvisibleelements; exports.getvisibleelements = getvisibleelements; exports.roundtodivide = roundtodivide; exports.getpagesizeinches = getpagesizeinches; exports.approximatefraction = approximatefraction; exports.getoutputscale = getoutputscale; exports.scrollintoview = scrollintoview; exports.watchscroll = watchscroll; exports.binarysearchfirstitem = binarysearchfirstitem; exports.normalizewheeleventdelta = normalizewheeleventdelta; exports.waitoneventortimeout = waitoneventortimeout; exports.movetoendofarray = movetoendofarray; exports.waitontype = exports.animationstarted = exports.progressbar = exports.eventbus = exports.nulll10n = exports.spreadmode = exports.scrollmode = exports.textlayermode = exports.renderertype = exports.presentationmodestate = exports.vertical_padding = exports.scrollbar_padding = exports.max_auto_scale = exports.unknown_scale = exports.max_scale = exports.min_scale = exports.default_scale = exports.default_scale_value = exports.css_units = exports.autoprintregexp = void 0; const css_units = 96.0 / 72.0; exports.css_units = css_units; const default_scale_value = "auto"; exports.default_scale_value = default_scale_value; const default_scale = 1.0; exports.default_scale = default_scale; const min_scale = 0.1; exports.min_scale = min_scale; const max_scale = 10.0; exports.max_scale = max_scale; const unknown_scale = 0; exports.unknown_scale = unknown_scale; const max_auto_scale = 1.25; exports.max_auto_scale = max_auto_scale; const scrollbar_padding = 40; exports.scrollbar_padding = scrollbar_padding; const vertical_padding = 5; exports.vertical_padding = vertical_padding; const presentationmodestate = { unknown: 0, normal: 1, changing: 2, fullscreen: 3 }; exports.presentationmodestate = presentationmodestate; const renderertype = { canvas: "canvas", svg: "svg" }; exports.renderertype = renderertype; const textlayermode = { disable: 0, enable: 1, enable_enhance: 2 }; exports.textlayermode = textlayermode; const scrollmode = { unknown: -1, vertical: 0, horizontal: 1, wrapped: 2 }; exports.scrollmode = scrollmode; const spreadmode = { unknown: -1, none: 0, odd: 1, even: 2 }; exports.spreadmode = spreadmode; const autoprintregexp = /\bprint\s*\(/; exports.autoprintregexp = autoprintregexp; function formatl10nvalue(text, args) { if (!args) { return text; } return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => { return name in args ? args[name] : "{{" + name + "}}"; }); } const nulll10n = { async getlanguage() { return "en-us"; }, async getdirection() { return "ltr"; }, async get(property, args, fallback) { return formatl10nvalue(fallback, args); }, async translate(element) {} }; exports.nulll10n = nulll10n; function getoutputscale(ctx) { const devicepixelratio = window.devicepixelratio || 1; const backingstoreratio = ctx.webkitbackingstorepixelratio || ctx.mozbackingstorepixelratio || ctx.msbackingstorepixelratio || ctx.obackingstorepixelratio || ctx.backingstorepixelratio || 1; const pixelratio = devicepixelratio / backingstoreratio; return { sx: pixelratio, sy: pixelratio, scaled: pixelratio !== 1 }; } function scrollintoview(element, spot, skipoverflowhiddenelements = false) { let parent = element.offsetparent; if (!parent) { console.error("offsetparent is not set -- cannot scroll"); return; } let offsety = element.offsettop + element.clienttop; let offsetx = element.offsetleft + element.clientleft; while (parent.clientheight === parent.scrollheight && parent.clientwidth === parent.scrollwidth || skipoverflowhiddenelements && getcomputedstyle(parent).overflow === "hidden") { if (parent.dataset._scaley) { offsety /= parent.dataset._scaley; offsetx /= parent.dataset._scalex; } offsety += parent.offsettop; offsetx += parent.offsetleft; parent = parent.offsetparent; if (!parent) { return; } } if (spot) { if (spot.top !== undefined) { offsety += spot.top; } if (spot.left !== undefined) { offsetx += spot.left; parent.scrollleft = offsetx; } } parent.scrolltop = offsety; } function watchscroll(viewareaelement, callback) { const debouncescroll = function (evt) { if (raf) { return; } raf = window.requestanimationframe(function viewareaelementscrolled() { raf = null; const currentx = viewareaelement.scrollleft; const lastx = state.lastx; if (currentx !== lastx) { state.right = currentx > lastx; } state.lastx = currentx; const currenty = viewareaelement.scrolltop; const lasty = state.lasty; if (currenty !== lasty) { state.down = currenty > lasty; } state.lasty = currenty; callback(state); }); }; const state = { right: true, down: true, lastx: viewareaelement.scrollleft, lasty: viewareaelement.scrolltop, _eventhandler: debouncescroll }; let raf = null; viewareaelement.addeventlistener("scroll", debouncescroll, true); return state; } function parsequerystring(query) { const parts = query.split("&"); const params = object.create(null); for (let i = 0, ii = parts.length; i < ii; ++i) { const param = parts[i].split("="); const key = param[0].tolowercase(); const value = param.length > 1 ? param[1] : null; params[decodeuricomponent(key)] = decodeuricomponent(value); } return params; } function binarysearchfirstitem(items, condition) { let minindex = 0; let maxindex = items.length - 1; if (items.length === 0 || !condition(items[maxindex])) { return items.length; } if (condition(items[minindex])) { return minindex; } while (minindex < maxindex) { const currentindex = minindex + maxindex >> 1; const currentitem = items[currentindex]; if (condition(currentitem)) { maxindex = currentindex; } else { minindex = currentindex + 1; } } return minindex; } function approximatefraction(x) { if (math.floor(x) === x) { return [x, 1]; } const xinv = 1 / x; const limit = 8; if (xinv > limit) { return [1, limit]; } else if (math.floor(xinv) === xinv) { return [1, xinv]; } const x_ = x > 1 ? xinv : x; let a = 0, b = 1, c = 1, d = 1; while (true) { const p = a + c, q = b + d; if (q > limit) { break; } if (x_ <= p / q) { c = p; d = q; } else { a = p; b = q; } } let result; if (x_ - a / b < c / d - x_) { result = x_ === x ? [a, b] : [b, a]; } else { result = x_ === x ? [c, d] : [d, c]; } return result; } function roundtodivide(x, div) { const r = x % div; return r === 0 ? x : math.round(x - r + div); } function getpagesizeinches({ view, userunit, rotate }) { const [x1, y1, x2, y2] = view; const changeorientation = rotate % 180 !== 0; const width = (x2 - x1) / 72 * userunit; const height = (y2 - y1) / 72 * userunit; return { width: changeorientation ? height : width, height: changeorientation ? width : height }; } function backtrackbeforeallvisibleelements(index, views, top) { if (index < 2) { return index; } let elt = views[index].div; let pagetop = elt.offsettop + elt.clienttop; if (pagetop >= top) { elt = views[index - 1].div; pagetop = elt.offsettop + elt.clienttop; } for (let i = index - 2; i >= 0; --i) { elt = views[i].div; if (elt.offsettop + elt.clienttop + elt.clientheight <= pagetop) { break; } index = i; } return index; } function getvisibleelements(scrollel, views, sortbyvisibility = false, horizontal = false) { const top = scrollel.scrolltop, bottom = top + scrollel.clientheight; const left = scrollel.scrollleft, right = left + scrollel.clientwidth; function iselementbottomafterviewtop(view) { const element = view.div; const elementbottom = element.offsettop + element.clienttop + element.clientheight; return elementbottom > top; } function iselementrightafterviewleft(view) { const element = view.div; const elementright = element.offsetleft + element.clientleft + element.clientwidth; return elementright > left; } const visible = [], numviews = views.length; let firstvisibleelementind = numviews === 0 ? 0 : binarysearchfirstitem(views, horizontal ? iselementrightafterviewleft : iselementbottomafterviewtop); if (firstvisibleelementind > 0 && firstvisibleelementind < numviews && !horizontal) { firstvisibleelementind = backtrackbeforeallvisibleelements(firstvisibleelementind, views, top); } let lastedge = horizontal ? right : -1; for (let i = firstvisibleelementind; i < numviews; i++) { const view = views[i], element = view.div; const currentwidth = element.offsetleft + element.clientleft; const currentheight = element.offsettop + element.clienttop; const viewwidth = element.clientwidth, viewheight = element.clientheight; const viewright = currentwidth + viewwidth; const viewbottom = currentheight + viewheight; if (lastedge === -1) { if (viewbottom >= bottom) { lastedge = viewbottom; } } else if ((horizontal ? currentwidth : currentheight) > lastedge) { break; } if (viewbottom <= top || currentheight >= bottom || viewright <= left || currentwidth >= right) { continue; } const hiddenheight = math.max(0, top - currentheight) + math.max(0, viewbottom - bottom); const hiddenwidth = math.max(0, left - currentwidth) + math.max(0, viewright - right); const percent = (viewheight - hiddenheight) * (viewwidth - hiddenwidth) * 100 / viewheight / viewwidth | 0; visible.push({ id: view.id, x: currentwidth, y: currentheight, view, percent }); } const first = visible[0], last = visible[visible.length - 1]; if (sortbyvisibility) { visible.sort(function (a, b) { const pc = a.percent - b.percent; if (math.abs(pc) > 0.001) { return -pc; } return a.id - b.id; }); } return { first, last, views: visible }; } function nocontextmenuhandler(evt) { evt.preventdefault(); } function isdataschema(url) { let i = 0; const ii = url.length; while (i < ii && url[i].trim() === "") { i++; } return url.substring(i, i + 5).tolowercase() === "data:"; } function getpdffilenamefromurl(url, defaultfilename = "document.pdf") { if (typeof url !== "string") { return defaultfilename; } if (isdataschema(url)) { console.warn("getpdffilenamefromurl: " + 'ignoring "data:" url for performance reasons.'); return defaultfilename; } const reuri = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/; const refilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i; const splituri = reuri.exec(url); let suggestedfilename = refilename.exec(splituri[1]) || refilename.exec(splituri[2]) || refilename.exec(splituri[3]); if (suggestedfilename) { suggestedfilename = suggestedfilename[0]; if (suggestedfilename.includes("%")) { try { suggestedfilename = refilename.exec(decodeuricomponent(suggestedfilename))[0]; } catch (ex) {} } } return suggestedfilename || defaultfilename; } function normalizewheeleventdelta(evt) { let delta = math.sqrt(evt.deltax * evt.deltax + evt.deltay * evt.deltay); const angle = math.atan2(evt.deltay, evt.deltax); if (-0.25 * math.pi < angle && angle < 0.75 * math.pi) { delta = -delta; } const mouse_dom_delta_pixel_mode = 0; const mouse_dom_delta_line_mode = 1; const mouse_pixels_per_line = 30; const mouse_lines_per_page = 30; if (evt.deltamode === mouse_dom_delta_pixel_mode) { delta /= mouse_pixels_per_line * mouse_lines_per_page; } else if (evt.deltamode === mouse_dom_delta_line_mode) { delta /= mouse_lines_per_page; } return delta; } function isvalidrotation(angle) { return number.isinteger(angle) && angle % 90 === 0; } function isvalidscrollmode(mode) { return number.isinteger(mode) && object.values(scrollmode).includes(mode) && mode !== scrollmode.unknown; } function isvalidspreadmode(mode) { return number.isinteger(mode) && object.values(spreadmode).includes(mode) && mode !== spreadmode.unknown; } function isportraitorientation(size) { return size.width <= size.height; } const waitontype = { event: "event", timeout: "timeout" }; exports.waitontype = waitontype; function waitoneventortimeout({ target, name, delay = 0 }) { return new promise(function (resolve, reject) { if (typeof target !== "object" || !(name && typeof name === "string") || !(number.isinteger(delay) && delay >= 0)) { throw new error("waitoneventortimeout - invalid parameters."); } function handler(type) { if (target instanceof eventbus) { target.off(name, eventhandler); } else { target.removeeventlistener(name, eventhandler); } if (timeout) { cleartimeout(timeout); } resolve(type); } const eventhandler = handler.bind(null, waitontype.event); if (target instanceof eventbus) { target.on(name, eventhandler); } else { target.addeventlistener(name, eventhandler); } const timeouthandler = handler.bind(null, waitontype.timeout); const timeout = settimeout(timeouthandler, delay); }); } const animationstarted = new promise(function (resolve) { window.requestanimationframe(resolve); }); exports.animationstarted = animationstarted; class eventbus { constructor({ dispatchtodom = false } = {}) { this._listeners = object.create(null); this._dispatchtodom = dispatchtodom === true; } on(eventname, listener) { let eventlisteners = this._listeners[eventname]; if (!eventlisteners) { eventlisteners = []; this._listeners[eventname] = eventlisteners; } eventlisteners.push(listener); } off(eventname, listener) { const eventlisteners = this._listeners[eventname]; let i; if (!eventlisteners || (i = eventlisteners.indexof(listener)) < 0) { return; } eventlisteners.splice(i, 1); } dispatch(eventname) { const eventlisteners = this._listeners[eventname]; if (!eventlisteners || eventlisteners.length === 0) { if (this._dispatchtodom) { const args = array.prototype.slice.call(arguments, 1); this._dispatchdomevent(eventname, args); } return; } const args = array.prototype.slice.call(arguments, 1); eventlisteners.slice(0).foreach(function (listener) { listener.apply(null, args); }); if (this._dispatchtodom) { this._dispatchdomevent(eventname, args); } } _dispatchdomevent(eventname, args = null) { const details = object.create(null); if (args && args.length > 0) { const obj = args[0]; for (const key in obj) { const value = obj[key]; if (key === "source") { if (value === window || value === document) { return; } continue; } details[key] = value; } } const event = document.createevent("customevent"); event.initcustomevent(eventname, true, true, details); document.dispatchevent(event); } } exports.eventbus = eventbus; let globaleventbus = null; function getglobaleventbus(dispatchtodom = false) { if (!globaleventbus) { globaleventbus = new eventbus({ dispatchtodom }); } return globaleventbus; } function clamp(v, min, max) { return math.min(math.max(v, min), max); } class progressbar { constructor(id, { height, width, units } = {}) { this.visible = true; this.div = document.queryselector(id + " .progress"); this.bar = this.div.parentnode; this.height = height || 100; this.width = width || 100; this.units = units || "%"; this.div.style.height = this.height + this.units; this.percent = 0; } _updatebar() { if (this._indeterminate) { this.div.classlist.add("indeterminate"); this.div.style.width = this.width + this.units; return; } this.div.classlist.remove("indeterminate"); const progresssize = this.width * this._percent / 100; this.div.style.width = progresssize + this.units; } get percent() { return this._percent; } set percent(val) { this._indeterminate = isnan(val); this._percent = clamp(val, 0, 100); this._updatebar(); } setwidth(viewer) { if (!viewer) { return; } const container = viewer.parentnode; const scrollbarwidth = container.offsetwidth - viewer.offsetwidth; if (scrollbarwidth > 0) { this.bar.style.width = `calc(100% - ${scrollbarwidth}px)`; } } hide() { if (!this.visible) { return; } this.visible = false; this.bar.classlist.add("hidden"); document.body.classlist.remove("loadinginprogress"); } show() { if (this.visible) { return; } this.visible = true; document.body.classlist.add("loadinginprogress"); this.bar.classlist.remove("hidden"); } } exports.progressbar = progressbar; function movetoendofarray(arr, condition) { const moved = [], len = arr.length; let write = 0; for (let read = 0; read < len; ++read) { if (condition(arr[read])) { moved.push(arr[read]); } else { arr[write] = arr[read]; ++write; } } for (let read = 0; write < len; ++read, ++write) { arr[write] = moved[read]; } } /***/ }), /* 4 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.simplelinkservice = exports.pdflinkservice = void 0; var _ui_utils = __w_pdfjs_require__(3); class pdflinkservice { constructor({ eventbus, externallinktarget = null, externallinkrel = null, externallinkenabled = true } = {}) { this.eventbus = eventbus || (0, _ui_utils.getglobaleventbus)(); this.externallinktarget = externallinktarget; this.externallinkrel = externallinkrel; this.externallinkenabled = externallinkenabled; this.baseurl = null; this.pdfdocument = null; this.pdfviewer = null; this.pdfhistory = null; this._pagesrefcache = null; } setdocument(pdfdocument, baseurl = null) { this.baseurl = baseurl; this.pdfdocument = pdfdocument; this._pagesrefcache = object.create(null); } setviewer(pdfviewer) { this.pdfviewer = pdfviewer; } sethistory(pdfhistory) { this.pdfhistory = pdfhistory; } get pagescount() { return this.pdfdocument ? this.pdfdocument.numpages : 0; } get page() { return this.pdfviewer.currentpagenumber; } set page(value) { this.pdfviewer.currentpagenumber = value; } get rotation() { return this.pdfviewer.pagesrotation; } set rotation(value) { this.pdfviewer.pagesrotation = value; } navigateto(dest) { const gotodestination = ({ nameddest, explicitdest }) => { const destref = explicitdest[0]; let pagenumber; if (destref instanceof object) { pagenumber = this._cachedpagenumber(destref); if (pagenumber === null) { this.pdfdocument.getpageindex(destref).then(pageindex => { this.cachepageref(pageindex + 1, destref); gotodestination({ nameddest, explicitdest }); }).catch(() => { console.error(`pdflinkservice.navigateto: "${destref}" is not ` + `a valid page reference, for dest="${dest}".`); }); return; } } else if (number.isinteger(destref)) { pagenumber = destref + 1; } else { console.error(`pdflinkservice.navigateto: "${destref}" is not ` + `a valid destination reference, for dest="${dest}".`); return; } if (!pagenumber || pagenumber < 1 || pagenumber > this.pagescount) { console.error(`pdflinkservice.navigateto: "${pagenumber}" is not ` + `a valid page number, for dest="${dest}".`); return; } if (this.pdfhistory) { this.pdfhistory.pushcurrentposition(); this.pdfhistory.push({ nameddest, explicitdest, pagenumber }); } this.pdfviewer.scrollpageintoview({ pagenumber, destarray: explicitdest }); }; new promise((resolve, reject) => { if (typeof dest === "string") { this.pdfdocument.getdestination(dest).then(destarray => { resolve({ nameddest: dest, explicitdest: destarray }); }); return; } resolve({ nameddest: "", explicitdest: dest }); }).then(data => { if (!array.isarray(data.explicitdest)) { console.error(`pdflinkservice.navigateto: "${data.explicitdest}" is` + ` not a valid destination array, for dest="${dest}".`); return; } gotodestination(data); }); } getdestinationhash(dest) { if (typeof dest === "string") { return this.getanchorurl("#" + escape(dest)); } if (array.isarray(dest)) { const str = json.stringify(dest); return this.getanchorurl("#" + escape(str)); } return this.getanchorurl(""); } getanchorurl(anchor) { return (this.baseurl || "") + anchor; } sethash(hash) { let pagenumber, dest; if (hash.includes("=")) { const params = (0, _ui_utils.parsequerystring)(hash); if ("search" in params) { this.eventbus.dispatch("findfromurlhash", { source: this, query: params["search"].replace(/"/g, ""), phrasesearch: params["phrase"] === "true" }); } if ("nameddest" in params) { this.navigateto(params.nameddest); return; } if ("page" in params) { pagenumber = params.page | 0 || 1; } if ("zoom" in params) { const zoomargs = params.zoom.split(","); const zoomarg = zoomargs[0]; const zoomargnumber = parsefloat(zoomarg); if (!zoomarg.includes("fit")) { dest = [null, { name: "xyz" }, zoomargs.length > 1 ? zoomargs[1] | 0 : null, zoomargs.length > 2 ? zoomargs[2] | 0 : null, zoomargnumber ? zoomargnumber / 100 : zoomarg]; } else { if (zoomarg === "fit" || zoomarg === "fitb") { dest = [null, { name: zoomarg }]; } else if (zoomarg === "fith" || zoomarg === "fitbh" || zoomarg === "fitv" || zoomarg === "fitbv") { dest = [null, { name: zoomarg }, zoomargs.length > 1 ? zoomargs[1] | 0 : null]; } else if (zoomarg === "fitr") { if (zoomargs.length !== 5) { console.error('pdflinkservice.sethash: not enough parameters for "fitr".'); } else { dest = [null, { name: zoomarg }, zoomargs[1] | 0, zoomargs[2] | 0, zoomargs[3] | 0, zoomargs[4] | 0]; } } else { console.error(`pdflinkservice.sethash: "${zoomarg}" is not ` + "a valid zoom value."); } } } if (dest) { this.pdfviewer.scrollpageintoview({ pagenumber: pagenumber || this.page, destarray: dest, allownegativeoffset: true }); } else if (pagenumber) { this.page = pagenumber; } if ("pagemode" in params) { this.eventbus.dispatch("pagemode", { source: this, mode: params.pagemode }); } } else { dest = unescape(hash); try { dest = json.parse(dest); if (!array.isarray(dest)) { dest = dest.tostring(); } } catch (ex) {} if (typeof dest === "string" || isvalidexplicitdestination(dest)) { this.navigateto(dest); return; } console.error(`pdflinkservice.sethash: "${unescape(hash)}" is not ` + "a valid destination."); } } executenamedaction(action) { switch (action) { case "goback": if (this.pdfhistory) { this.pdfhistory.back(); } break; case "goforward": if (this.pdfhistory) { this.pdfhistory.forward(); } break; case "nextpage": if (this.page < this.pagescount) { this.page++; } break; case "prevpage": if (this.page > 1) { this.page--; } break; case "lastpage": this.page = this.pagescount; break; case "firstpage": this.page = 1; break; default: break; } this.eventbus.dispatch("namedaction", { source: this, action }); } cachepageref(pagenum, pageref) { if (!pageref) { return; } const refstr = pageref.gen === 0 ? `${pageref.num}r` : `${pageref.num}r${pageref.gen}`; this._pagesrefcache[refstr] = pagenum; } _cachedpagenumber(pageref) { const refstr = pageref.gen === 0 ? `${pageref.num}r` : `${pageref.num}r${pageref.gen}`; return this._pagesrefcache && this._pagesrefcache[refstr] || null; } ispagevisible(pagenumber) { return this.pdfviewer.ispagevisible(pagenumber); } } exports.pdflinkservice = pdflinkservice; function isvalidexplicitdestination(dest) { if (!array.isarray(dest)) { return false; } const destlength = dest.length; if (destlength < 2) { return false; } const page = dest[0]; if (!(typeof page === "object" && number.isinteger(page.num) && number.isinteger(page.gen)) && !(number.isinteger(page) && page >= 0)) { return false; } const zoom = dest[1]; if (!(typeof zoom === "object" && typeof zoom.name === "string")) { return false; } let allownull = true; switch (zoom.name) { case "xyz": if (destlength !== 5) { return false; } break; case "fit": case "fitb": return destlength === 2; case "fith": case "fitbh": case "fitv": case "fitbv": if (destlength !== 3) { return false; } break; case "fitr": if (destlength !== 6) { return false; } allownull = false; break; default: return false; } for (let i = 2; i < destlength; i++) { const param = dest[i]; if (!(typeof param === "number" || allownull && param === null)) { return false; } } return true; } class simplelinkservice { constructor() { this.externallinktarget = null; this.externallinkrel = null; this.externallinkenabled = true; } get pagescount() { return 0; } get page() { return 0; } set page(value) {} get rotation() { return 0; } set rotation(value) {} navigateto(dest) {} getdestinationhash(dest) { return "#"; } getanchorurl(hash) { return "#"; } sethash(hash) {} executenamedaction(action) {} cachepageref(pagenum, pageref) {} ispagevisible(pagenumber) { return true; } } exports.simplelinkservice = simplelinkservice; /***/ }), /* 5 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.defaulttextlayerfactory = exports.textlayerbuilder = void 0; var _ui_utils = __w_pdfjs_require__(3); var _pdfjslib = __w_pdfjs_require__(2); const expand_divs_timeout = 300; class textlayerbuilder { constructor({ textlayerdiv, eventbus, pageindex, viewport, findcontroller = null, enhancetextselection = false }) { this.textlayerdiv = textlayerdiv; this.eventbus = eventbus || (0, _ui_utils.getglobaleventbus)(); this.textcontent = null; this.textcontentitemsstr = []; this.textcontentstream = null; this.renderingdone = false; this.pageidx = pageindex; this.pagenumber = this.pageidx + 1; this.matches = []; this.viewport = viewport; this.textdivs = []; this.findcontroller = findcontroller; this.textlayerrendertask = null; this.enhancetextselection = enhancetextselection; this._onupdatetextlayermatches = null; this._bindmouse(); } _finishrendering() { this.renderingdone = true; if (!this.enhancetextselection) { const endofcontent = document.createelement("div"); endofcontent.classname = "endofcontent"; this.textlayerdiv.appendchild(endofcontent); } this.eventbus.dispatch("textlayerrendered", { source: this, pagenumber: this.pagenumber, numtextdivs: this.textdivs.length }); } render(timeout = 0) { if (!(this.textcontent || this.textcontentstream) || this.renderingdone) { return; } this.cancel(); this.textdivs = []; const textlayerfrag = document.createdocumentfragment(); this.textlayerrendertask = (0, _pdfjslib.rendertextlayer)({ textcontent: this.textcontent, textcontentstream: this.textcontentstream, container: textlayerfrag, viewport: this.viewport, textdivs: this.textdivs, textcontentitemsstr: this.textcontentitemsstr, timeout, enhancetextselection: this.enhancetextselection }); this.textlayerrendertask.promise.then(() => { this.textlayerdiv.appendchild(textlayerfrag); this._finishrendering(); this._updatematches(); }, function (reason) {}); if (!this._onupdatetextlayermatches) { this._onupdatetextlayermatches = evt => { if (evt.pageindex === this.pageidx || evt.pageindex === -1) { this._updatematches(); } }; this.eventbus.on("updatetextlayermatches", this._onupdatetextlayermatches); } } cancel() { if (this.textlayerrendertask) { this.textlayerrendertask.cancel(); this.textlayerrendertask = null; } if (this._onupdatetextlayermatches) { this.eventbus.off("updatetextlayermatches", this._onupdatetextlayermatches); this._onupdatetextlayermatches = null; } } settextcontentstream(readablestream) { this.cancel(); this.textcontentstream = readablestream; } settextcontent(textcontent) { this.cancel(); this.textcontent = textcontent; } _convertmatches(matches, matcheslength) { if (!matches) { return []; } const { findcontroller, textcontentitemsstr } = this; let i = 0, iindex = 0; const end = textcontentitemsstr.length - 1; const querylen = findcontroller.state.query.length; const result = []; for (let m = 0, mm = matches.length; m < mm; m++) { let matchidx = matches[m]; while (i !== end && matchidx >= iindex + textcontentitemsstr[i].length) { iindex += textcontentitemsstr[i].length; i++; } if (i === textcontentitemsstr.length) { console.error("could not find a matching mapping"); } const match = { begin: { dividx: i, offset: matchidx - iindex } }; if (matcheslength) { matchidx += matcheslength[m]; } else { matchidx += querylen; } while (i !== end && matchidx > iindex + textcontentitemsstr[i].length) { iindex += textcontentitemsstr[i].length; i++; } match.end = { dividx: i, offset: matchidx - iindex }; result.push(match); } return result; } _rendermatches(matches) { if (matches.length === 0) { return; } const { findcontroller, pageidx, textcontentitemsstr, textdivs } = this; const isselectedpage = pageidx === findcontroller.selected.pageidx; const selectedmatchidx = findcontroller.selected.matchidx; const highlightall = findcontroller.state.highlightall; let prevend = null; const infinity = { dividx: -1, offset: undefined }; function begintext(begin, classname) { const dividx = begin.dividx; textdivs[dividx].textcontent = ""; appendtexttodiv(dividx, 0, begin.offset, classname); } function appendtexttodiv(dividx, fromoffset, tooffset, classname) { const div = textdivs[dividx]; const content = textcontentitemsstr[dividx].substring(fromoffset, tooffset); const node = document.createtextnode(content); if (classname) { const span = document.createelement("span"); span.classname = classname; span.appendchild(node); div.appendchild(span); return; } div.appendchild(node); } let i0 = selectedmatchidx, i1 = i0 + 1; if (highlightall) { i0 = 0; i1 = matches.length; } else if (!isselectedpage) { return; } for (let i = i0; i < i1; i++) { const match = matches[i]; const begin = match.begin; const end = match.end; const isselected = isselectedpage && i === selectedmatchidx; const highlightsuffix = isselected ? " selected" : ""; if (isselected) { findcontroller.scrollmatchintoview({ element: textdivs[begin.dividx], pageindex: pageidx, matchindex: selectedmatchidx }); } if (!prevend || begin.dividx !== prevend.dividx) { if (prevend !== null) { appendtexttodiv(prevend.dividx, prevend.offset, infinity.offset); } begintext(begin); } else { appendtexttodiv(prevend.dividx, prevend.offset, begin.offset); } if (begin.dividx === end.dividx) { appendtexttodiv(begin.dividx, begin.offset, end.offset, "highlight" + highlightsuffix); } else { appendtexttodiv(begin.dividx, begin.offset, infinity.offset, "highlight begin" + highlightsuffix); for (let n0 = begin.dividx + 1, n1 = end.dividx; n0 < n1; n0++) { textdivs[n0].classname = "highlight middle" + highlightsuffix; } begintext(end, "highlight end" + highlightsuffix); } prevend = end; } if (prevend) { appendtexttodiv(prevend.dividx, prevend.offset, infinity.offset); } } _updatematches() { if (!this.renderingdone) { return; } const { findcontroller, matches, pageidx, textcontentitemsstr, textdivs } = this; let cleareduntildividx = -1; for (let i = 0, ii = matches.length; i < ii; i++) { const match = matches[i]; const begin = math.max(cleareduntildividx, match.begin.dividx); for (let n = begin, end = match.end.dividx; n <= end; n++) { const div = textdivs[n]; div.textcontent = textcontentitemsstr[n]; div.classname = ""; } cleareduntildividx = match.end.dividx + 1; } if (!findcontroller || !findcontroller.highlightmatches) { return; } const pagematches = findcontroller.pagematches[pageidx] || null; const pagematcheslength = findcontroller.pagematcheslength[pageidx] || null; this.matches = this._convertmatches(pagematches, pagematcheslength); this._rendermatches(this.matches); } _bindmouse() { const div = this.textlayerdiv; let expanddivstimer = null; div.addeventlistener("mousedown", evt => { if (this.enhancetextselection && this.textlayerrendertask) { this.textlayerrendertask.expandtextdivs(true); if (expanddivstimer) { cleartimeout(expanddivstimer); expanddivstimer = null; } return; } const end = div.queryselector(".endofcontent"); if (!end) { return; } let adjusttop = evt.target !== div; adjusttop = adjusttop && window.getcomputedstyle(end).getpropertyvalue("-moz-user-select") !== "none"; if (adjusttop) { const divbounds = div.getboundingclientrect(); const r = math.max(0, (evt.pagey - divbounds.top) / divbounds.height); end.style.top = (r * 100).tofixed(2) + "%"; } end.classlist.add("active"); }); div.addeventlistener("mouseup", () => { if (this.enhancetextselection && this.textlayerrendertask) { expanddivstimer = settimeout(() => { if (this.textlayerrendertask) { this.textlayerrendertask.expandtextdivs(false); } expanddivstimer = null; }, expand_divs_timeout); return; } const end = div.queryselector(".endofcontent"); if (!end) { return; } end.style.top = ""; end.classlist.remove("active"); }); } } exports.textlayerbuilder = textlayerbuilder; class defaulttextlayerfactory { createtextlayerbuilder(textlayerdiv, pageindex, viewport, enhancetextselection = false) { return new textlayerbuilder({ textlayerdiv, pageindex, viewport, enhancetextselection }); } } exports.defaulttextlayerfactory = defaulttextlayerfactory; /***/ }), /* 6 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.downloadmanager = void 0; var _pdfjslib = __w_pdfjs_require__(2); ; const disable_create_object_url = _pdfjslib.apicompatibilityparams.disablecreateobjecturl || false; function download(bloburl, filename) { const a = document.createelement("a"); if (!a.click) { throw new error('downloadmanager: "a.click()" is not supported.'); } a.href = bloburl; a.target = "_parent"; if ("download" in a) { a.download = filename; } (document.body || document.documentelement).appendchild(a); a.click(); a.remove(); } class downloadmanager { constructor({ disablecreateobjecturl = disable_create_object_url }) { this.disablecreateobjecturl = disablecreateobjecturl; } downloadurl(url, filename) { if (!(0, _pdfjslib.createvalidabsoluteurl)(url, "http://example.com")) { return; } download(url + "#pdfjs.action=download", filename); } downloaddata(data, filename, contenttype) { if (navigator.mssaveblob) { navigator.mssaveblob(new blob([data], { type: contenttype }), filename); return; } const bloburl = (0, _pdfjslib.createobjecturl)(data, contenttype, this.disablecreateobjecturl); download(bloburl, filename); } download(blob, url, filename) { if (navigator.mssaveblob) { if (!navigator.mssaveblob(blob, filename)) { this.downloadurl(url, filename); } return; } if (this.disablecreateobjecturl) { this.downloadurl(url, filename); return; } const bloburl = url.createobjecturl(blob); download(bloburl, filename); } } exports.downloadmanager = downloadmanager; /***/ }), /* 7 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.genericl10n = void 0; __w_pdfjs_require__(8); const webl10n = document.webl10n; class genericl10n { constructor(lang) { this._lang = lang; this._ready = new promise((resolve, reject) => { webl10n.setlanguage(lang, () => { resolve(webl10n); }); }); } async getlanguage() { const l10n = await this._ready; return l10n.getlanguage(); } async getdirection() { const l10n = await this._ready; return l10n.getdirection(); } async get(property, args, fallback) { const l10n = await this._ready; return l10n.get(property, args, fallback); } async translate(element) { const l10n = await this._ready; return l10n.translate(element); } } exports.genericl10n = genericl10n; /***/ }), /* 8 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; document.webl10n = function (window, document, undefined) { var gl10ndata = {}; var gtextdata = ''; var gtextprop = 'textcontent'; var glanguage = ''; var gmacros = {}; var greadystate = 'loading'; var gasyncresourceloading = true; function getl10nresourcelinks() { return document.queryselectorall('link[type="application/l10n"]'); } function getl10ndictionary() { var script = document.queryselector('script[type="application/l10n"]'); return script ? json.parse(script.innerhtml) : null; } function gettranslatablechildren(element) { return element ? element.queryselectorall('*[data-l10n-id]') : []; } function getl10nattributes(element) { if (!element) return {}; var l10nid = element.getattribute('data-l10n-id'); var l10nargs = element.getattribute('data-l10n-args'); var args = {}; if (l10nargs) { try { args = json.parse(l10nargs); } catch (e) { console.warn('could not parse arguments for #' + l10nid); } } return { id: l10nid, args: args }; } function xhrloadtext(url, onsuccess, onfailure) { onsuccess = onsuccess || function _onsuccess(data) {}; onfailure = onfailure || function _onfailure() {}; var xhr = new xmlhttprequest(); xhr.open('get', url, gasyncresourceloading); if (xhr.overridemimetype) { xhr.overridemimetype('text/plain; charset=utf-8'); } xhr.onreadystatechange = function () { if (xhr.readystate == 4) { if (xhr.status == 200 || xhr.status === 0) { onsuccess(xhr.responsetext); } else { onfailure(); } } }; xhr.onerror = onfailure; xhr.ontimeout = onfailure; try { xhr.send(null); } catch (e) { onfailure(); } } function parseresource(href, lang, successcallback, failurecallback) { var baseurl = href.replace(/[^\/]*$/, '') || './'; function evalstring(text) { if (text.lastindexof('\\') < 0) return text; return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'"); } function parseproperties(text, parsedpropertiescallback) { var dictionary = {}; var reblank = /^\s*|\s*$/; var recomment = /^\s*#|^\s*$/; var resection = /^\s*\[(.*)\]\s*$/; var reimport = /^\s*@import\s+url\((.*)\)\s*$/i; var resplit = /^([^=\s]*)\s*=\s*(.+)$/; function parserawlines(rawtext, extendedsyntax, parsedrawlinescallback) { var entries = rawtext.replace(reblank, '').split(/[\r\n]+/); var currentlang = '*'; var genericlang = lang.split('-', 1)[0]; var skiplang = false; var match = ''; function nextentry() { while (true) { if (!entries.length) { parsedrawlinescallback(); return; } var line = entries.shift(); if (recomment.test(line)) continue; if (extendedsyntax) { match = resection.exec(line); if (match) { currentlang = match[1].tolowercase(); skiplang = currentlang !== '*' && currentlang !== lang && currentlang !== genericlang; continue; } else if (skiplang) { continue; } match = reimport.exec(line); if (match) { loadimport(baseurl + match[1], nextentry); return; } } var tmp = line.match(resplit); if (tmp && tmp.length == 3) { dictionary[tmp[1]] = evalstring(tmp[2]); } } } nextentry(); } function loadimport(url, callback) { xhrloadtext(url, function (content) { parserawlines(content, false, callback); }, function () { console.warn(url + ' not found.'); callback(); }); } parserawlines(text, true, function () { parsedpropertiescallback(dictionary); }); } xhrloadtext(href, function (response) { gtextdata += response; parseproperties(response, function (data) { for (var key in data) { var id, prop, index = key.lastindexof('.'); if (index > 0) { id = key.substring(0, index); prop = key.substring(index + 1); } else { id = key; prop = gtextprop; } if (!gl10ndata[id]) { gl10ndata[id] = {}; } gl10ndata[id][prop] = data[key]; } if (successcallback) { successcallback(); } }); }, failurecallback); } function loadlocale(lang, callback) { if (lang) { lang = lang.tolowercase(); } callback = callback || function _callback() {}; clear(); glanguage = lang; var langlinks = getl10nresourcelinks(); var langcount = langlinks.length; if (langcount === 0) { var dict = getl10ndictionary(); if (dict && dict.locales && dict.default_locale) { console.log('using the embedded json directory, early way out'); gl10ndata = dict.locales[lang]; if (!gl10ndata) { var defaultlocale = dict.default_locale.tolowercase(); for (var anycaselang in dict.locales) { anycaselang = anycaselang.tolowercase(); if (anycaselang === lang) { gl10ndata = dict.locales[lang]; break; } else if (anycaselang === defaultlocale) { gl10ndata = dict.locales[defaultlocale]; } } } callback(); } else { console.log('no resource to load, early way out'); } greadystate = 'complete'; return; } var onresourceloaded = null; var gresourcecount = 0; onresourceloaded = function () { gresourcecount++; if (gresourcecount >= langcount) { callback(); greadystate = 'complete'; } }; function l10nresourcelink(link) { var href = link.href; this.load = function (lang, callback) { parseresource(href, lang, callback, function () { console.warn(href + ' not found.'); console.warn('"' + lang + '" resource not found'); glanguage = ''; callback(); }); }; } for (var i = 0; i < langcount; i++) { var resource = new l10nresourcelink(langlinks[i]); resource.load(lang, onresourceloaded); } } function clear() { gl10ndata = {}; gtextdata = ''; glanguage = ''; } function getpluralrules(lang) { var locales2rules = { 'af': 3, 'ak': 4, 'am': 4, 'ar': 1, 'asa': 3, 'az': 0, 'be': 11, 'bem': 3, 'bez': 3, 'bg': 3, 'bh': 4, 'bm': 0, 'bn': 3, 'bo': 0, 'br': 20, 'brx': 3, 'bs': 11, 'ca': 3, 'cgg': 3, 'chr': 3, 'cs': 12, 'cy': 17, 'da': 3, 'de': 3, 'dv': 3, 'dz': 0, 'ee': 3, 'el': 3, 'en': 3, 'eo': 3, 'es': 3, 'et': 3, 'eu': 3, 'fa': 0, 'ff': 5, 'fi': 3, 'fil': 4, 'fo': 3, 'fr': 5, 'fur': 3, 'fy': 3, 'ga': 8, 'gd': 24, 'gl': 3, 'gsw': 3, 'gu': 3, 'guw': 4, 'gv': 23, 'ha': 3, 'haw': 3, 'he': 2, 'hi': 4, 'hr': 11, 'hu': 0, 'id': 0, 'ig': 0, 'ii': 0, 'is': 3, 'it': 3, 'iu': 7, 'ja': 0, 'jmc': 3, 'jv': 0, 'ka': 0, 'kab': 5, 'kaj': 3, 'kcg': 3, 'kde': 0, 'kea': 0, 'kk': 3, 'kl': 3, 'km': 0, 'kn': 0, 'ko': 0, 'ksb': 3, 'ksh': 21, 'ku': 3, 'kw': 7, 'lag': 18, 'lb': 3, 'lg': 3, 'ln': 4, 'lo': 0, 'lt': 10, 'lv': 6, 'mas': 3, 'mg': 4, 'mk': 16, 'ml': 3, 'mn': 3, 'mo': 9, 'mr': 3, 'ms': 0, 'mt': 15, 'my': 0, 'nah': 3, 'naq': 7, 'nb': 3, 'nd': 3, 'ne': 3, 'nl': 3, 'nn': 3, 'no': 3, 'nr': 3, 'nso': 4, 'ny': 3, 'nyn': 3, 'om': 3, 'or': 3, 'pa': 3, 'pap': 3, 'pl': 13, 'ps': 3, 'pt': 3, 'rm': 3, 'ro': 9, 'rof': 3, 'ru': 11, 'rwk': 3, 'sah': 0, 'saq': 3, 'se': 7, 'seh': 3, 'ses': 0, 'sg': 0, 'sh': 11, 'shi': 19, 'sk': 12, 'sl': 14, 'sma': 7, 'smi': 7, 'smj': 7, 'smn': 7, 'sms': 7, 'sn': 3, 'so': 3, 'sq': 3, 'sr': 11, 'ss': 3, 'ssy': 3, 'st': 3, 'sv': 3, 'sw': 3, 'syr': 3, 'ta': 3, 'te': 3, 'teo': 3, 'th': 0, 'ti': 4, 'tig': 3, 'tk': 3, 'tl': 4, 'tn': 3, 'to': 0, 'tr': 0, 'ts': 3, 'tzm': 22, 'uk': 11, 'ur': 3, 've': 3, 'vi': 0, 'vun': 3, 'wa': 4, 'wae': 3, 'wo': 0, 'xh': 3, 'xog': 3, 'yo': 0, 'zh': 0, 'zu': 3 }; function isin(n, list) { return list.indexof(n) !== -1; } function isbetween(n, start, end) { return start <= n && n <= end; } var pluralrules = { '0': function (n) { return 'other'; }, '1': function (n) { if (isbetween(n % 100, 3, 10)) return 'few'; if (n === 0) return 'zero'; if (isbetween(n % 100, 11, 99)) return 'many'; if (n == 2) return 'two'; if (n == 1) return 'one'; return 'other'; }, '2': function (n) { if (n !== 0 && n % 10 === 0) return 'many'; if (n == 2) return 'two'; if (n == 1) return 'one'; return 'other'; }, '3': function (n) { if (n == 1) return 'one'; return 'other'; }, '4': function (n) { if (isbetween(n, 0, 1)) return 'one'; return 'other'; }, '5': function (n) { if (isbetween(n, 0, 2) && n != 2) return 'one'; return 'other'; }, '6': function (n) { if (n === 0) return 'zero'; if (n % 10 == 1 && n % 100 != 11) return 'one'; return 'other'; }, '7': function (n) { if (n == 2) return 'two'; if (n == 1) return 'one'; return 'other'; }, '8': function (n) { if (isbetween(n, 3, 6)) return 'few'; if (isbetween(n, 7, 10)) return 'many'; if (n == 2) return 'two'; if (n == 1) return 'one'; return 'other'; }, '9': function (n) { if (n === 0 || n != 1 && isbetween(n % 100, 1, 19)) return 'few'; if (n == 1) return 'one'; return 'other'; }, '10': function (n) { if (isbetween(n % 10, 2, 9) && !isbetween(n % 100, 11, 19)) return 'few'; if (n % 10 == 1 && !isbetween(n % 100, 11, 19)) return 'one'; return 'other'; }, '11': function (n) { if (isbetween(n % 10, 2, 4) && !isbetween(n % 100, 12, 14)) return 'few'; if (n % 10 === 0 || isbetween(n % 10, 5, 9) || isbetween(n % 100, 11, 14)) return 'many'; if (n % 10 == 1 && n % 100 != 11) return 'one'; return 'other'; }, '12': function (n) { if (isbetween(n, 2, 4)) return 'few'; if (n == 1) return 'one'; return 'other'; }, '13': function (n) { if (isbetween(n % 10, 2, 4) && !isbetween(n % 100, 12, 14)) return 'few'; if (n != 1 && isbetween(n % 10, 0, 1) || isbetween(n % 10, 5, 9) || isbetween(n % 100, 12, 14)) return 'many'; if (n == 1) return 'one'; return 'other'; }, '14': function (n) { if (isbetween(n % 100, 3, 4)) return 'few'; if (n % 100 == 2) return 'two'; if (n % 100 == 1) return 'one'; return 'other'; }, '15': function (n) { if (n === 0 || isbetween(n % 100, 2, 10)) return 'few'; if (isbetween(n % 100, 11, 19)) return 'many'; if (n == 1) return 'one'; return 'other'; }, '16': function (n) { if (n % 10 == 1 && n != 11) return 'one'; return 'other'; }, '17': function (n) { if (n == 3) return 'few'; if (n === 0) return 'zero'; if (n == 6) return 'many'; if (n == 2) return 'two'; if (n == 1) return 'one'; return 'other'; }, '18': function (n) { if (n === 0) return 'zero'; if (isbetween(n, 0, 2) && n !== 0 && n != 2) return 'one'; return 'other'; }, '19': function (n) { if (isbetween(n, 2, 10)) return 'few'; if (isbetween(n, 0, 1)) return 'one'; return 'other'; }, '20': function (n) { if ((isbetween(n % 10, 3, 4) || n % 10 == 9) && !(isbetween(n % 100, 10, 19) || isbetween(n % 100, 70, 79) || isbetween(n % 100, 90, 99))) return 'few'; if (n % 1000000 === 0 && n !== 0) return 'many'; if (n % 10 == 2 && !isin(n % 100, [12, 72, 92])) return 'two'; if (n % 10 == 1 && !isin(n % 100, [11, 71, 91])) return 'one'; return 'other'; }, '21': function (n) { if (n === 0) return 'zero'; if (n == 1) return 'one'; return 'other'; }, '22': function (n) { if (isbetween(n, 0, 1) || isbetween(n, 11, 99)) return 'one'; return 'other'; }, '23': function (n) { if (isbetween(n % 10, 1, 2) || n % 20 === 0) return 'one'; return 'other'; }, '24': function (n) { if (isbetween(n, 3, 10) || isbetween(n, 13, 19)) return 'few'; if (isin(n, [2, 12])) return 'two'; if (isin(n, [1, 11])) return 'one'; return 'other'; } }; var index = locales2rules[lang.replace(/-.*$/, '')]; if (!(index in pluralrules)) { console.warn('plural form unknown for [' + lang + ']'); return function () { return 'other'; }; } return pluralrules[index]; } gmacros.plural = function (str, param, key, prop) { var n = parsefloat(param); if (isnan(n)) return str; if (prop != gtextprop) return str; if (!gmacros._pluralrules) { gmacros._pluralrules = getpluralrules(glanguage); } var index = '[' + gmacros._pluralrules(n) + ']'; if (n === 0 && key + '[zero]' in gl10ndata) { str = gl10ndata[key + '[zero]'][prop]; } else if (n == 1 && key + '[one]' in gl10ndata) { str = gl10ndata[key + '[one]'][prop]; } else if (n == 2 && key + '[two]' in gl10ndata) { str = gl10ndata[key + '[two]'][prop]; } else if (key + index in gl10ndata) { str = gl10ndata[key + index][prop]; } else if (key + '[other]' in gl10ndata) { str = gl10ndata[key + '[other]'][prop]; } return str; }; function getl10ndata(key, args, fallback) { var data = gl10ndata[key]; if (!data) { console.warn('#' + key + ' is undefined.'); if (!fallback) { return null; } data = fallback; } var rv = {}; for (var prop in data) { var str = data[prop]; str = substindexes(str, args, key, prop); str = substarguments(str, args, key); rv[prop] = str; } return rv; } function substindexes(str, args, key, prop) { var reindex = /\{\[\s*([a-za-z]+)\(([a-za-z]+)\)\s*\]\}/; var rematch = reindex.exec(str); if (!rematch || !rematch.length) return str; var macroname = rematch[1]; var paramname = rematch[2]; var param; if (args && paramname in args) { param = args[paramname]; } else if (paramname in gl10ndata) { param = gl10ndata[paramname]; } if (macroname in gmacros) { var macro = gmacros[macroname]; str = macro(str, param, key, prop); } return str; } function substarguments(str, args, key) { var reargs = /\{\{\s*(.+?)\s*\}\}/g; return str.replace(reargs, function (matched_text, arg) { if (args && arg in args) { return args[arg]; } if (arg in gl10ndata) { return gl10ndata[arg]; } console.log('argument {{' + arg + '}} for #' + key + ' is undefined.'); return matched_text; }); } function translateelement(element) { var l10n = getl10nattributes(element); if (!l10n.id) return; var data = getl10ndata(l10n.id, l10n.args); if (!data) { console.warn('#' + l10n.id + ' is undefined.'); return; } if (data[gtextprop]) { if (getchildelementcount(element) === 0) { element[gtextprop] = data[gtextprop]; } else { var children = element.childnodes; var found = false; for (var i = 0, l = children.length; i < l; i++) { if (children[i].nodetype === 3 && /\s/.test(children[i].nodevalue)) { if (found) { children[i].nodevalue = ''; } else { children[i].nodevalue = data[gtextprop]; found = true; } } } if (!found) { var textnode = document.createtextnode(data[gtextprop]); element.insertbefore(textnode, element.firstchild); } } delete data[gtextprop]; } for (var k in data) { element[k] = data[k]; } } function getchildelementcount(element) { if (element.children) { return element.children.length; } if (typeof element.childelementcount !== 'undefined') { return element.childelementcount; } var count = 0; for (var i = 0; i < element.childnodes.length; i++) { count += element.nodetype === 1 ? 1 : 0; } return count; } function translatefragment(element) { element = element || document.documentelement; var children = gettranslatablechildren(element); var elementcount = children.length; for (var i = 0; i < elementcount; i++) { translateelement(children[i]); } translateelement(element); } return { get: function (key, args, fallbackstring) { var index = key.lastindexof('.'); var prop = gtextprop; if (index > 0) { prop = key.substring(index + 1); key = key.substring(0, index); } var fallback; if (fallbackstring) { fallback = {}; fallback[prop] = fallbackstring; } var data = getl10ndata(key, args, fallback); if (data && prop in data) { return data[prop]; } return '{{' + key + '}}'; }, getdata: function () { return gl10ndata; }, gettext: function () { return gtextdata; }, getlanguage: function () { return glanguage; }, setlanguage: function (lang, callback) { loadlocale(lang, function () { if (callback) callback(); }); }, getdirection: function () { var rtllist = ['ar', 'he', 'fa', 'ps', 'ur']; var shortcode = glanguage.split('-', 1)[0]; return rtllist.indexof(shortcode) >= 0 ? 'rtl' : 'ltr'; }, translate: translatefragment, getreadystate: function () { return greadystate; }, ready: function (callback) { if (!callback) { return; } else if (greadystate == 'complete' || greadystate == 'interactive') { window.settimeout(function () { callback(); }); } else if (document.addeventlistener) { document.addeventlistener('localized', function once() { document.removeeventlistener('localized', once); callback(); }); } } }; }(window, document); /***/ }), /* 9 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.pdffindcontroller = exports.findstate = void 0; var _ui_utils = __w_pdfjs_require__(3); var _pdfjslib = __w_pdfjs_require__(2); var _pdf_find_utils = __w_pdfjs_require__(10); const findstate = { found: 0, not_found: 1, wrapped: 2, pending: 3 }; exports.findstate = findstate; const find_timeout = 250; const match_scroll_offset_top = -50; const match_scroll_offset_left = -400; const characters_to_normalize = { "\u2018": "'", "\u2019": "'", "\u201a": "'", "\u201b": "'", "\u201c": '"', "\u201d": '"', "\u201e": '"', "\u201f": '"', "\u00bc": "1/4", "\u00bd": "1/2", "\u00be": "3/4" }; let normalizationregex = null; function normalize(text) { if (!normalizationregex) { const replace = object.keys(characters_to_normalize).join(""); normalizationregex = new regexp(`[${replace}]`, "g"); } return text.replace(normalizationregex, function (ch) { return characters_to_normalize[ch]; }); } class pdffindcontroller { constructor({ linkservice, eventbus = (0, _ui_utils.getglobaleventbus)() }) { this._linkservice = linkservice; this._eventbus = eventbus; this._reset(); eventbus.on("findbarclose", this._onfindbarclose.bind(this)); } get highlightmatches() { return this._highlightmatches; } get pagematches() { return this._pagematches; } get pagematcheslength() { return this._pagematcheslength; } get selected() { return this._selected; } get state() { return this._state; } setdocument(pdfdocument) { if (this._pdfdocument) { this._reset(); } if (!pdfdocument) { return; } this._pdfdocument = pdfdocument; this._firstpagecapability.resolve(); } executecommand(cmd, state) { if (!state) { return; } const pdfdocument = this._pdfdocument; if (this._state === null || this._shoulddirtymatch(cmd, state)) { this._dirtymatch = true; } this._state = state; if (cmd !== "findhighlightallchange") { this._updateuistate(findstate.pending); } this._firstpagecapability.promise.then(() => { if (!this._pdfdocument || pdfdocument && this._pdfdocument !== pdfdocument) { return; } this._extracttext(); const findbarclosed = !this._highlightmatches; const pendingtimeout = !!this._findtimeout; if (this._findtimeout) { cleartimeout(this._findtimeout); this._findtimeout = null; } if (cmd === "find") { this._findtimeout = settimeout(() => { this._nextmatch(); this._findtimeout = null; }, find_timeout); } else if (this._dirtymatch) { this._nextmatch(); } else if (cmd === "findagain") { this._nextmatch(); if (findbarclosed && this._state.highlightall) { this._updateallpages(); } } else if (cmd === "findhighlightallchange") { if (pendingtimeout) { this._nextmatch(); } else { this._highlightmatches = true; } this._updateallpages(); } else { this._nextmatch(); } }); } scrollmatchintoview({ element = null, pageindex = -1, matchindex = -1 }) { if (!this._scrollmatches || !element) { return; } else if (matchindex === -1 || matchindex !== this._selected.matchidx) { return; } else if (pageindex === -1 || pageindex !== this._selected.pageidx) { return; } this._scrollmatches = false; const spot = { top: match_scroll_offset_top, left: match_scroll_offset_left }; (0, _ui_utils.scrollintoview)(element, spot, true); } _reset() { this._highlightmatches = false; this._scrollmatches = false; this._pdfdocument = null; this._pagematches = []; this._pagematcheslength = []; this._state = null; this._selected = { pageidx: -1, matchidx: -1 }; this._offset = { pageidx: null, matchidx: null, wrapped: false }; this._extracttextpromises = []; this._pagecontents = []; this._matchescounttotal = 0; this._pagestosearch = null; this._pendingfindmatches = object.create(null); this._resumepageidx = null; this._dirtymatch = false; cleartimeout(this._findtimeout); this._findtimeout = null; this._firstpagecapability = (0, _pdfjslib.createpromisecapability)(); } get _query() { if (this._state.query !== this._rawquery) { this._rawquery = this._state.query; this._normalizedquery = normalize(this._state.query); } return this._normalizedquery; } _shoulddirtymatch(cmd, state) { if (state.query !== this._state.query) { return true; } switch (cmd) { case "findagain": const pagenumber = this._selected.pageidx + 1; const linkservice = this._linkservice; if (pagenumber >= 1 && pagenumber <= linkservice.pagescount && pagenumber !== linkservice.page && !linkservice.ispagevisible(pagenumber)) { return true; } return false; case "findhighlightallchange": return false; } return true; } _preparematches(matcheswithlength, matches, matcheslength) { function issubterm(matcheswithlength, currentindex) { const currentelem = matcheswithlength[currentindex]; const nextelem = matcheswithlength[currentindex + 1]; if (currentindex < matcheswithlength.length - 1 && currentelem.match === nextelem.match) { currentelem.skipped = true; return true; } for (let i = currentindex - 1; i >= 0; i--) { const prevelem = matcheswithlength[i]; if (prevelem.skipped) { continue; } if (prevelem.match + prevelem.matchlength < currentelem.match) { break; } if (prevelem.match + prevelem.matchlength >= currentelem.match + currentelem.matchlength) { currentelem.skipped = true; return true; } } return false; } matcheswithlength.sort(function (a, b) { return a.match === b.match ? a.matchlength - b.matchlength : a.match - b.match; }); for (let i = 0, len = matcheswithlength.length; i < len; i++) { if (issubterm(matcheswithlength, i)) { continue; } matches.push(matcheswithlength[i].match); matcheslength.push(matcheswithlength[i].matchlength); } } _isentireword(content, startidx, length) { if (startidx > 0) { const first = content.charcodeat(startidx); const limit = content.charcodeat(startidx - 1); if ((0, _pdf_find_utils.getcharactertype)(first) === (0, _pdf_find_utils.getcharactertype)(limit)) { return false; } } const endidx = startidx + length - 1; if (endidx < content.length - 1) { const last = content.charcodeat(endidx); const limit = content.charcodeat(endidx + 1); if ((0, _pdf_find_utils.getcharactertype)(last) === (0, _pdf_find_utils.getcharactertype)(limit)) { return false; } } return true; } _calculatephrasematch(query, pageindex, pagecontent, entireword) { const matches = []; const querylen = query.length; let matchidx = -querylen; while (true) { matchidx = pagecontent.indexof(query, matchidx + querylen); if (matchidx === -1) { break; } if (entireword && !this._isentireword(pagecontent, matchidx, querylen)) { continue; } matches.push(matchidx); } this._pagematches[pageindex] = matches; } _calculatewordmatch(query, pageindex, pagecontent, entireword) { const matcheswithlength = []; const queryarray = query.match(/\s+/g); for (let i = 0, len = queryarray.length; i < len; i++) { const subquery = queryarray[i]; const subquerylen = subquery.length; let matchidx = -subquerylen; while (true) { matchidx = pagecontent.indexof(subquery, matchidx + subquerylen); if (matchidx === -1) { break; } if (entireword && !this._isentireword(pagecontent, matchidx, subquerylen)) { continue; } matcheswithlength.push({ match: matchidx, matchlength: subquerylen, skipped: false }); } } this._pagematcheslength[pageindex] = []; this._pagematches[pageindex] = []; this._preparematches(matcheswithlength, this._pagematches[pageindex], this._pagematcheslength[pageindex]); } _calculatematch(pageindex) { let pagecontent = this._pagecontents[pageindex]; let query = this._query; const { casesensitive, entireword, phrasesearch } = this._state; if (query.length === 0) { return; } if (!casesensitive) { pagecontent = pagecontent.tolowercase(); query = query.tolowercase(); } if (phrasesearch) { this._calculatephrasematch(query, pageindex, pagecontent, entireword); } else { this._calculatewordmatch(query, pageindex, pagecontent, entireword); } if (this._state.highlightall) { this._updatepage(pageindex); } if (this._resumepageidx === pageindex) { this._resumepageidx = null; this._nextpagematch(); } const pagematchescount = this._pagematches[pageindex].length; if (pagematchescount > 0) { this._matchescounttotal += pagematchescount; this._updateuiresultscount(); } } _extracttext() { if (this._extracttextpromises.length > 0) { return; } let promise = promise.resolve(); for (let i = 0, ii = this._linkservice.pagescount; i < ii; i++) { const extracttextcapability = (0, _pdfjslib.createpromisecapability)(); this._extracttextpromises[i] = extracttextcapability.promise; promise = promise.then(() => { return this._pdfdocument.getpage(i + 1).then(pdfpage => { return pdfpage.gettextcontent({ normalizewhitespace: true }); }).then(textcontent => { const textitems = textcontent.items; const strbuf = []; for (let j = 0, jj = textitems.length; j < jj; j++) { strbuf.push(textitems[j].str); } this._pagecontents[i] = normalize(strbuf.join("")); extracttextcapability.resolve(i); }, reason => { console.error(`unable to get text content for page ${i + 1}`, reason); this._pagecontents[i] = ""; extracttextcapability.resolve(i); }); }); } } _updatepage(index) { if (this._scrollmatches && this._selected.pageidx === index) { this._linkservice.page = index + 1; } this._eventbus.dispatch("updatetextlayermatches", { source: this, pageindex: index }); } _updateallpages() { this._eventbus.dispatch("updatetextlayermatches", { source: this, pageindex: -1 }); } _nextmatch() { const previous = this._state.findprevious; const currentpageindex = this._linkservice.page - 1; const numpages = this._linkservice.pagescount; this._highlightmatches = true; if (this._dirtymatch) { this._dirtymatch = false; this._selected.pageidx = this._selected.matchidx = -1; this._offset.pageidx = currentpageindex; this._offset.matchidx = null; this._offset.wrapped = false; this._resumepageidx = null; this._pagematches.length = 0; this._pagematcheslength.length = 0; this._matchescounttotal = 0; this._updateallpages(); for (let i = 0; i < numpages; i++) { if (this._pendingfindmatches[i] === true) { continue; } this._pendingfindmatches[i] = true; this._extracttextpromises[i].then(pageidx => { delete this._pendingfindmatches[pageidx]; this._calculatematch(pageidx); }); } } if (this._query === "") { this._updateuistate(findstate.found); return; } if (this._resumepageidx) { return; } const offset = this._offset; this._pagestosearch = numpages; if (offset.matchidx !== null) { const numpagematches = this._pagematches[offset.pageidx].length; if (!previous && offset.matchidx + 1 < numpagematches || previous && offset.matchidx > 0) { offset.matchidx = previous ? offset.matchidx - 1 : offset.matchidx + 1; this._updatematch(true); return; } this._advanceoffsetpage(previous); } this._nextpagematch(); } _matchesready(matches) { const offset = this._offset; const nummatches = matches.length; const previous = this._state.findprevious; if (nummatches) { offset.matchidx = previous ? nummatches - 1 : 0; this._updatematch(true); return true; } this._advanceoffsetpage(previous); if (offset.wrapped) { offset.matchidx = null; if (this._pagestosearch < 0) { this._updatematch(false); return true; } } return false; } _nextpagematch() { if (this._resumepageidx !== null) { console.error("there can only be one pending page."); } let matches = null; do { const pageidx = this._offset.pageidx; matches = this._pagematches[pageidx]; if (!matches) { this._resumepageidx = pageidx; break; } } while (!this._matchesready(matches)); } _advanceoffsetpage(previous) { const offset = this._offset; const numpages = this._linkservice.pagescount; offset.pageidx = previous ? offset.pageidx - 1 : offset.pageidx + 1; offset.matchidx = null; this._pagestosearch--; if (offset.pageidx >= numpages || offset.pageidx < 0) { offset.pageidx = previous ? numpages - 1 : 0; offset.wrapped = true; } } _updatematch(found = false) { let state = findstate.not_found; const wrapped = this._offset.wrapped; this._offset.wrapped = false; if (found) { const previouspage = this._selected.pageidx; this._selected.pageidx = this._offset.pageidx; this._selected.matchidx = this._offset.matchidx; state = wrapped ? findstate.wrapped : findstate.found; if (previouspage !== -1 && previouspage !== this._selected.pageidx) { this._updatepage(previouspage); } } this._updateuistate(state, this._state.findprevious); if (this._selected.pageidx !== -1) { this._scrollmatches = true; this._updatepage(this._selected.pageidx); } } _onfindbarclose(evt) { const pdfdocument = this._pdfdocument; this._firstpagecapability.promise.then(() => { if (!this._pdfdocument || pdfdocument && this._pdfdocument !== pdfdocument) { return; } if (this._findtimeout) { cleartimeout(this._findtimeout); this._findtimeout = null; } if (this._resumepageidx) { this._resumepageidx = null; this._dirtymatch = true; } this._updateuistate(findstate.found); this._highlightmatches = false; this._updateallpages(); }); } _requestmatchescount() { const { pageidx, matchidx } = this._selected; let current = 0, total = this._matchescounttotal; if (matchidx !== -1) { for (let i = 0; i < pageidx; i++) { current += this._pagematches[i] && this._pagematches[i].length || 0; } current += matchidx + 1; } if (current < 1 || current > total) { current = total = 0; } return { current, total }; } _updateuiresultscount() { this._eventbus.dispatch("updatefindmatchescount", { source: this, matchescount: this._requestmatchescount() }); } _updateuistate(state, previous) { this._eventbus.dispatch("updatefindcontrolstate", { source: this, state, previous, matchescount: this._requestmatchescount() }); } } exports.pdffindcontroller = pdffindcontroller; /***/ }), /* 10 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.getcharactertype = getcharactertype; exports.charactertype = void 0; const charactertype = { space: 0, alpha_letter: 1, punct: 2, han_letter: 3, katakana_letter: 4, hiragana_letter: 5, halfwidth_katakana_letter: 6, thai_letter: 7 }; exports.charactertype = charactertype; function isalphabeticalscript(charcode) { return charcode < 0x2e80; } function isascii(charcode) { return (charcode & 0xff80) === 0; } function isasciialpha(charcode) { return charcode >= 0x61 && charcode <= 0x7a || charcode >= 0x41 && charcode <= 0x5a; } function isasciidigit(charcode) { return charcode >= 0x30 && charcode <= 0x39; } function isasciispace(charcode) { return charcode === 0x20 || charcode === 0x09 || charcode === 0x0d || charcode === 0x0a; } function ishan(charcode) { return charcode >= 0x3400 && charcode <= 0x9fff || charcode >= 0xf900 && charcode <= 0xfaff; } function iskatakana(charcode) { return charcode >= 0x30a0 && charcode <= 0x30ff; } function ishiragana(charcode) { return charcode >= 0x3040 && charcode <= 0x309f; } function ishalfwidthkatakana(charcode) { return charcode >= 0xff60 && charcode <= 0xff9f; } function isthai(charcode) { return (charcode & 0xff80) === 0x0e00; } function getcharactertype(charcode) { if (isalphabeticalscript(charcode)) { if (isascii(charcode)) { if (isasciispace(charcode)) { return charactertype.space; } else if (isasciialpha(charcode) || isasciidigit(charcode) || charcode === 0x5f) { return charactertype.alpha_letter; } return charactertype.punct; } else if (isthai(charcode)) { return charactertype.thai_letter; } else if (charcode === 0xa0) { return charactertype.space; } return charactertype.alpha_letter; } if (ishan(charcode)) { return charactertype.han_letter; } else if (iskatakana(charcode)) { return charactertype.katakana_letter; } else if (ishiragana(charcode)) { return charactertype.hiragana_letter; } else if (ishalfwidthkatakana(charcode)) { return charactertype.halfwidth_katakana_letter; } return charactertype.alpha_letter; } /***/ }), /* 11 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.isdesthashesequal = isdesthashesequal; exports.isdestarraysequal = isdestarraysequal; exports.pdfhistory = void 0; var _ui_utils = __w_pdfjs_require__(3); const hash_change_timeout = 1000; const position_updated_threshold = 50; const update_viewarea_timeout = 1000; function getcurrenthash() { return document.location.hash; } class pdfhistory { constructor({ linkservice, eventbus }) { this.linkservice = linkservice; this.eventbus = eventbus || (0, _ui_utils.getglobaleventbus)(); this._initialized = false; this._fingerprint = ""; this.reset(); this._boundevents = null; this._isviewerinpresentationmode = false; this.eventbus.on("presentationmodechanged", evt => { this._isviewerinpresentationmode = evt.active || evt.switchinprogress; }); this.eventbus.on("pagesinit", () => { this._ispagesloaded = false; const onpagesloaded = evt => { this.eventbus.off("pagesloaded", onpagesloaded); this._ispagesloaded = !!evt.pagescount; }; this.eventbus.on("pagesloaded", onpagesloaded); }); } initialize({ fingerprint, resethistory = false, updateurl = false }) { if (!fingerprint || typeof fingerprint !== "string") { console.error('pdfhistory.initialize: the "fingerprint" must be a non-empty string.'); return; } if (this._initialized) { this.reset(); } const reinitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint; this._fingerprint = fingerprint; this._updateurl = updateurl === true; this._initialized = true; this._bindevents(); const state = window.history.state; this._popstateinprogress = false; this._blockhashchange = 0; this._currenthash = getcurrenthash(); this._numpositionupdates = 0; this._uid = this._maxuid = 0; this._destination = null; this._position = null; if (!this._isvalidstate(state, true) || resethistory) { const { hash, page, rotation } = this._parsecurrenthash(); if (!hash || reinitialized || resethistory) { this._pushorreplacestate(null, true); return; } this._pushorreplacestate({ hash, page, rotation }, true); return; } const destination = state.destination; this._updateinternalstate(destination, state.uid, true); if (this._uid > this._maxuid) { this._maxuid = this._uid; } if (destination.rotation !== undefined) { this._initialrotation = destination.rotation; } if (destination.dest) { this._initialbookmark = json.stringify(destination.dest); this._destination.page = null; } else if (destination.hash) { this._initialbookmark = destination.hash; } else if (destination.page) { this._initialbookmark = `page=${destination.page}`; } } reset() { if (this._initialized) { this._pagehide(); this._initialized = false; this._unbindevents(); } if (this._updateviewareatimeout) { cleartimeout(this._updateviewareatimeout); this._updateviewareatimeout = null; } this._initialbookmark = null; this._initialrotation = null; } push({ nameddest = null, explicitdest, pagenumber }) { if (!this._initialized) { return; } if (nameddest && typeof nameddest !== "string") { console.error("pdfhistory.push: " + `"${nameddest}" is not a valid nameddest parameter.`); return; } else if (!array.isarray(explicitdest)) { console.error("pdfhistory.push: " + `"${explicitdest}" is not a valid explicitdest parameter.`); return; } else if (!(number.isinteger(pagenumber) && pagenumber > 0 && pagenumber <= this.linkservice.pagescount)) { if (pagenumber !== null || this._destination) { console.error("pdfhistory.push: " + `"${pagenumber}" is not a valid pagenumber parameter.`); return; } } const hash = nameddest || json.stringify(explicitdest); if (!hash) { return; } let forcereplace = false; if (this._destination && (isdesthashesequal(this._destination.hash, hash) || isdestarraysequal(this._destination.dest, explicitdest))) { if (this._destination.page) { return; } forcereplace = true; } if (this._popstateinprogress && !forcereplace) { return; } this._pushorreplacestate({ dest: explicitdest, hash, page: pagenumber, rotation: this.linkservice.rotation }, forcereplace); if (!this._popstateinprogress) { this._popstateinprogress = true; promise.resolve().then(() => { this._popstateinprogress = false; }); } } pushcurrentposition() { if (!this._initialized || this._popstateinprogress) { return; } this._trypushcurrentposition(); } back() { if (!this._initialized || this._popstateinprogress) { return; } const state = window.history.state; if (this._isvalidstate(state) && state.uid > 0) { window.history.back(); } } forward() { if (!this._initialized || this._popstateinprogress) { return; } const state = window.history.state; if (this._isvalidstate(state) && state.uid < this._maxuid) { window.history.forward(); } } get popstateinprogress() { return this._initialized && (this._popstateinprogress || this._blockhashchange > 0); } get initialbookmark() { return this._initialized ? this._initialbookmark : null; } get initialrotation() { return this._initialized ? this._initialrotation : null; } _pushorreplacestate(destination, forcereplace = false) { const shouldreplace = forcereplace || !this._destination; const newstate = { fingerprint: this._fingerprint, uid: shouldreplace ? this._uid : this._uid + 1, destination }; this._updateinternalstate(destination, newstate.uid); let newurl; if (this._updateurl && destination && destination.hash) { const baseurl = document.location.href.split("#")[0]; if (!baseurl.startswith("file://")) { newurl = `${baseurl}#${destination.hash}`; } } if (shouldreplace) { window.history.replacestate(newstate, "", newurl); } else { this._maxuid = this._uid; window.history.pushstate(newstate, "", newurl); } } _trypushcurrentposition(temporary = false) { if (!this._position) { return; } let position = this._position; if (temporary) { position = object.assign(object.create(null), this._position); position.temporary = true; } if (!this._destination) { this._pushorreplacestate(position); return; } if (this._destination.temporary) { this._pushorreplacestate(position, true); return; } if (this._destination.hash === position.hash) { return; } if (!this._destination.page && (position_updated_threshold <= 0 || this._numpositionupdates <= position_updated_threshold)) { return; } let forcereplace = false; if (this._destination.page >= position.first && this._destination.page <= position.page) { if (this._destination.dest || !this._destination.first) { return; } forcereplace = true; } this._pushorreplacestate(position, forcereplace); } _isvalidstate(state, checkreload = false) { if (!state) { return false; } if (state.fingerprint !== this._fingerprint) { if (checkreload) { if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) { return false; } const [perfentry] = performance.getentriesbytype("navigation"); if (!perfentry || perfentry.type !== "reload") { return false; } } else { return false; } } if (!number.isinteger(state.uid) || state.uid < 0) { return false; } if (state.destination === null || typeof state.destination !== "object") { return false; } return true; } _updateinternalstate(destination, uid, removetemporary = false) { if (this._updateviewareatimeout) { cleartimeout(this._updateviewareatimeout); this._updateviewareatimeout = null; } if (removetemporary && destination && destination.temporary) { delete destination.temporary; } this._destination = destination; this._uid = uid; this._numpositionupdates = 0; } _parsecurrenthash() { const hash = unescape(getcurrenthash()).substring(1); let page = (0, _ui_utils.parsequerystring)(hash).page | 0; if (!(number.isinteger(page) && page > 0 && page <= this.linkservice.pagescount)) { page = null; } return { hash, page, rotation: this.linkservice.rotation }; } _updateviewarea({ location }) { if (this._updateviewareatimeout) { cleartimeout(this._updateviewareatimeout); this._updateviewareatimeout = null; } this._position = { hash: this._isviewerinpresentationmode ? `page=${location.pagenumber}` : location.pdfopenparams.substring(1), page: this.linkservice.page, first: location.pagenumber, rotation: location.rotation }; if (this._popstateinprogress) { return; } if (position_updated_threshold > 0 && this._ispagesloaded && this._destination && !this._destination.page) { this._numpositionupdates++; } if (update_viewarea_timeout > 0) { this._updateviewareatimeout = settimeout(() => { if (!this._popstateinprogress) { this._trypushcurrentposition(true); } this._updateviewareatimeout = null; }, update_viewarea_timeout); } } _popstate({ state }) { const newhash = getcurrenthash(), hashchanged = this._currenthash !== newhash; this._currenthash = newhash; if (!state) { this._uid++; const { hash, page, rotation } = this._parsecurrenthash(); this._pushorreplacestate({ hash, page, rotation }, true); return; } if (!this._isvalidstate(state)) { return; } this._popstateinprogress = true; if (hashchanged) { this._blockhashchange++; (0, _ui_utils.waitoneventortimeout)({ target: window, name: "hashchange", delay: hash_change_timeout }).then(() => { this._blockhashchange--; }); } const destination = state.destination; this._updateinternalstate(destination, state.uid, true); if (this._uid > this._maxuid) { this._maxuid = this._uid; } if ((0, _ui_utils.isvalidrotation)(destination.rotation)) { this.linkservice.rotation = destination.rotation; } if (destination.dest) { this.linkservice.navigateto(destination.dest); } else if (destination.hash) { this.linkservice.sethash(destination.hash); } else if (destination.page) { this.linkservice.page = destination.page; } promise.resolve().then(() => { this._popstateinprogress = false; }); } _pagehide() { if (!this._destination || this._destination.temporary) { this._trypushcurrentposition(); } } _bindevents() { if (this._boundevents) { return; } this._boundevents = { updateviewarea: this._updateviewarea.bind(this), popstate: this._popstate.bind(this), pagehide: this._pagehide.bind(this) }; this.eventbus.on("updateviewarea", this._boundevents.updateviewarea); window.addeventlistener("popstate", this._boundevents.popstate); window.addeventlistener("pagehide", this._boundevents.pagehide); } _unbindevents() { if (!this._boundevents) { return; } this.eventbus.off("updateviewarea", this._boundevents.updateviewarea); window.removeeventlistener("popstate", this._boundevents.popstate); window.removeeventlistener("pagehide", this._boundevents.pagehide); this._boundevents = null; } } exports.pdfhistory = pdfhistory; function isdesthashesequal(desthash, pushhash) { if (typeof desthash !== "string" || typeof pushhash !== "string") { return false; } if (desthash === pushhash) { return true; } const { nameddest } = (0, _ui_utils.parsequerystring)(desthash); if (nameddest === pushhash) { return true; } return false; } function isdestarraysequal(firstdest, seconddest) { function isentryequal(first, second) { if (typeof first !== typeof second) { return false; } if (array.isarray(first) || array.isarray(second)) { return false; } if (first !== null && typeof first === "object" && second !== null) { if (object.keys(first).length !== object.keys(second).length) { return false; } for (const key in first) { if (!isentryequal(first[key], second[key])) { return false; } } return true; } return first === second || number.isnan(first) && number.isnan(second); } if (!(array.isarray(firstdest) && array.isarray(seconddest))) { return false; } if (firstdest.length !== seconddest.length) { return false; } for (let i = 0, ii = firstdest.length; i < ii; i++) { if (!isentryequal(firstdest[i], seconddest[i])) { return false; } } return true; } /***/ }), /* 12 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.pdfpageview = void 0; var _ui_utils = __w_pdfjs_require__(3); var _pdfjslib = __w_pdfjs_require__(2); var _pdf_rendering_queue = __w_pdfjs_require__(13); var _viewer_compatibility = __w_pdfjs_require__(14); const max_canvas_pixels = _viewer_compatibility.viewercompatibilityparams.maxcanvaspixels || 16777216; class pdfpageview { constructor(options) { const container = options.container; const defaultviewport = options.defaultviewport; this.id = options.id; this.renderingid = "page" + this.id; this.pdfpage = null; this.pagelabel = null; this.rotation = 0; this.scale = options.scale || _ui_utils.default_scale; this.viewport = defaultviewport; this.pdfpagerotate = defaultviewport.rotation; this.hasrestrictedscaling = false; this.textlayermode = number.isinteger(options.textlayermode) ? options.textlayermode : _ui_utils.textlayermode.enable; this.imageresourcespath = options.imageresourcespath || ""; this.renderinteractiveforms = options.renderinteractiveforms || false; this.useonlycsszoom = options.useonlycsszoom || false; this.maxcanvaspixels = options.maxcanvaspixels || max_canvas_pixels; this.eventbus = options.eventbus || (0, _ui_utils.getglobaleventbus)(); this.renderingqueue = options.renderingqueue; this.textlayerfactory = options.textlayerfactory; this.annotationlayerfactory = options.annotationlayerfactory; this.renderer = options.renderer || _ui_utils.renderertype.canvas; this.enablewebgl = options.enablewebgl || false; this.l10n = options.l10n || _ui_utils.nulll10n; this.painttask = null; this.paintedviewportmap = new weakmap(); this.renderingstate = _pdf_rendering_queue.renderingstates.initial; this.resume = null; this.error = null; this.annotationlayer = null; this.textlayer = null; this.zoomlayer = null; const div = document.createelement("div"); div.classname = "page"; div.style.width = math.floor(this.viewport.width) + "px"; div.style.height = math.floor(this.viewport.height) + "px"; div.setattribute("data-page-number", this.id); this.div = div; container.appendchild(div); } setpdfpage(pdfpage) { this.pdfpage = pdfpage; this.pdfpagerotate = pdfpage.rotate; const totalrotation = (this.rotation + this.pdfpagerotate) % 360; this.viewport = pdfpage.getviewport({ scale: this.scale * _ui_utils.css_units, rotation: totalrotation }); this.stats = pdfpage.stats; this.reset(); } destroy() { this.reset(); if (this.pdfpage) { this.pdfpage.cleanup(); } } _resetzoomlayer(removefromdom = false) { if (!this.zoomlayer) { return; } const zoomlayercanvas = this.zoomlayer.firstchild; this.paintedviewportmap.delete(zoomlayercanvas); zoomlayercanvas.width = 0; zoomlayercanvas.height = 0; if (removefromdom) { this.zoomlayer.remove(); } this.zoomlayer = null; } reset(keepzoomlayer = false, keepannotations = false) { this.cancelrendering(keepannotations); this.renderingstate = _pdf_rendering_queue.renderingstates.initial; const div = this.div; div.style.width = math.floor(this.viewport.width) + "px"; div.style.height = math.floor(this.viewport.height) + "px"; const childnodes = div.childnodes; const currentzoomlayernode = keepzoomlayer && this.zoomlayer || null; const currentannotationnode = keepannotations && this.annotationlayer && this.annotationlayer.div || null; for (let i = childnodes.length - 1; i >= 0; i--) { const node = childnodes[i]; if (currentzoomlayernode === node || currentannotationnode === node) { continue; } div.removechild(node); } div.removeattribute("data-loaded"); if (currentannotationnode) { this.annotationlayer.hide(); } else if (this.annotationlayer) { this.annotationlayer.cancel(); this.annotationlayer = null; } if (!currentzoomlayernode) { if (this.canvas) { this.paintedviewportmap.delete(this.canvas); this.canvas.width = 0; this.canvas.height = 0; delete this.canvas; } this._resetzoomlayer(); } if (this.svg) { this.paintedviewportmap.delete(this.svg); delete this.svg; } this.loadingicondiv = document.createelement("div"); this.loadingicondiv.classname = "loadingicon"; div.appendchild(this.loadingicondiv); } update(scale, rotation) { this.scale = scale || this.scale; if (typeof rotation !== "undefined") { this.rotation = rotation; } const totalrotation = (this.rotation + this.pdfpagerotate) % 360; this.viewport = this.viewport.clone({ scale: this.scale * _ui_utils.css_units, rotation: totalrotation }); if (this.svg) { this.csstransform(this.svg, true); this.eventbus.dispatch("pagerendered", { source: this, pagenumber: this.id, csstransform: true, timestamp: performance.now() }); return; } let isscalingrestricted = false; if (this.canvas && this.maxcanvaspixels > 0) { const outputscale = this.outputscale; if ((math.floor(this.viewport.width) * outputscale.sx | 0) * (math.floor(this.viewport.height) * outputscale.sy | 0) > this.maxcanvaspixels) { isscalingrestricted = true; } } if (this.canvas) { if (this.useonlycsszoom || this.hasrestrictedscaling && isscalingrestricted) { this.csstransform(this.canvas, true); this.eventbus.dispatch("pagerendered", { source: this, pagenumber: this.id, csstransform: true, timestamp: performance.now() }); return; } if (!this.zoomlayer && !this.canvas.hasattribute("hidden")) { this.zoomlayer = this.canvas.parentnode; this.zoomlayer.style.position = "absolute"; } } if (this.zoomlayer) { this.csstransform(this.zoomlayer.firstchild); } this.reset(true, true); } cancelrendering(keepannotations = false) { if (this.painttask) { this.painttask.cancel(); this.painttask = null; } this.resume = null; if (this.textlayer) { this.textlayer.cancel(); this.textlayer = null; } if (!keepannotations && this.annotationlayer) { this.annotationlayer.cancel(); this.annotationlayer = null; } } csstransform(target, redrawannotations = false) { const width = this.viewport.width; const height = this.viewport.height; const div = this.div; target.style.width = target.parentnode.style.width = div.style.width = math.floor(width) + "px"; target.style.height = target.parentnode.style.height = div.style.height = math.floor(height) + "px"; const relativerotation = this.viewport.rotation - this.paintedviewportmap.get(target).rotation; const absrotation = math.abs(relativerotation); let scalex = 1, scaley = 1; if (absrotation === 90 || absrotation === 270) { scalex = height / width; scaley = width / height; } const csstransform = "rotate(" + relativerotation + "deg) " + "scale(" + scalex + "," + scaley + ")"; target.style.transform = csstransform; if (this.textlayer) { const textlayerviewport = this.textlayer.viewport; const textrelativerotation = this.viewport.rotation - textlayerviewport.rotation; const textabsrotation = math.abs(textrelativerotation); let scale = width / textlayerviewport.width; if (textabsrotation === 90 || textabsrotation === 270) { scale = width / textlayerviewport.height; } const textlayerdiv = this.textlayer.textlayerdiv; let transx, transy; switch (textabsrotation) { case 0: transx = transy = 0; break; case 90: transx = 0; transy = "-" + textlayerdiv.style.height; break; case 180: transx = "-" + textlayerdiv.style.width; transy = "-" + textlayerdiv.style.height; break; case 270: transx = "-" + textlayerdiv.style.width; transy = 0; break; default: console.error("bad rotation value."); break; } textlayerdiv.style.transform = "rotate(" + textabsrotation + "deg) " + "scale(" + scale + ", " + scale + ") " + "translate(" + transx + ", " + transy + ")"; textlayerdiv.style.transformorigin = "0% 0%"; } if (redrawannotations && this.annotationlayer) { this.annotationlayer.render(this.viewport, "display"); } } get width() { return this.viewport.width; } get height() { return this.viewport.height; } getpagepoint(x, y) { return this.viewport.converttopdfpoint(x, y); } draw() { if (this.renderingstate !== _pdf_rendering_queue.renderingstates.initial) { console.error("must be in new state before drawing"); this.reset(); } if (!this.pdfpage) { this.renderingstate = _pdf_rendering_queue.renderingstates.finished; return promise.reject(new error("page is not loaded")); } this.renderingstate = _pdf_rendering_queue.renderingstates.running; const pdfpage = this.pdfpage; const div = this.div; const canvaswrapper = document.createelement("div"); canvaswrapper.style.width = div.style.width; canvaswrapper.style.height = div.style.height; canvaswrapper.classlist.add("canvaswrapper"); if (this.annotationlayer && this.annotationlayer.div) { div.insertbefore(canvaswrapper, this.annotationlayer.div); } else { div.appendchild(canvaswrapper); } let textlayer = null; if (this.textlayermode !== _ui_utils.textlayermode.disable && this.textlayerfactory) { const textlayerdiv = document.createelement("div"); textlayerdiv.classname = "textlayer"; textlayerdiv.style.width = canvaswrapper.style.width; textlayerdiv.style.height = canvaswrapper.style.height; if (this.annotationlayer && this.annotationlayer.div) { div.insertbefore(textlayerdiv, this.annotationlayer.div); } else { div.appendchild(textlayerdiv); } textlayer = this.textlayerfactory.createtextlayerbuilder(textlayerdiv, this.id - 1, this.viewport, this.textlayermode === _ui_utils.textlayermode.enable_enhance); } this.textlayer = textlayer; let rendercontinuecallback = null; if (this.renderingqueue) { rendercontinuecallback = cont => { if (!this.renderingqueue.ishighestpriority(this)) { this.renderingstate = _pdf_rendering_queue.renderingstates.paused; this.resume = () => { this.renderingstate = _pdf_rendering_queue.renderingstates.running; cont(); }; return; } cont(); }; } const finishpainttask = async error => { if (painttask === this.painttask) { this.painttask = null; } if (error instanceof _pdfjslib.renderingcancelledexception) { this.error = null; return; } this.renderingstate = _pdf_rendering_queue.renderingstates.finished; if (this.loadingicondiv) { div.removechild(this.loadingicondiv); delete this.loadingicondiv; } this._resetzoomlayer(true); this.error = error; this.stats = pdfpage.stats; this.eventbus.dispatch("pagerendered", { source: this, pagenumber: this.id, csstransform: false, timestamp: performance.now() }); if (error) { throw error; } }; const painttask = this.renderer === _ui_utils.renderertype.svg ? this.paintonsvg(canvaswrapper) : this.paintoncanvas(canvaswrapper); painttask.onrendercontinue = rendercontinuecallback; this.painttask = painttask; const resultpromise = painttask.promise.then(function () { return finishpainttask(null).then(function () { if (textlayer) { const readablestream = pdfpage.streamtextcontent({ normalizewhitespace: true }); textlayer.settextcontentstream(readablestream); textlayer.render(); } }); }, function (reason) { return finishpainttask(reason); }); if (this.annotationlayerfactory) { if (!this.annotationlayer) { this.annotationlayer = this.annotationlayerfactory.createannotationlayerbuilder(div, pdfpage, this.imageresourcespath, this.renderinteractiveforms, this.l10n); } this.annotationlayer.render(this.viewport, "display"); } div.setattribute("data-loaded", true); this.eventbus.dispatch("pagerender", { source: this, pagenumber: this.id }); return resultpromise; } paintoncanvas(canvaswrapper) { const rendercapability = (0, _pdfjslib.createpromisecapability)(); const result = { promise: rendercapability.promise, onrendercontinue(cont) { cont(); }, cancel() { rendertask.cancel(); } }; const viewport = this.viewport; const canvas = document.createelement("canvas"); this.l10n.get("page_canvas", { page: this.id }, "page {{page}}").then(msg => { canvas.setattribute("aria-label", msg); }); canvas.setattribute("hidden", "hidden"); let iscanvashidden = true; const showcanvas = function () { if (iscanvashidden) { canvas.removeattribute("hidden"); iscanvashidden = false; } }; canvaswrapper.appendchild(canvas); this.canvas = canvas; canvas.mozopaque = true; const ctx = canvas.getcontext("2d", { alpha: false }); const outputscale = (0, _ui_utils.getoutputscale)(ctx); this.outputscale = outputscale; if (this.useonlycsszoom) { const actualsizeviewport = viewport.clone({ scale: _ui_utils.css_units }); outputscale.sx *= actualsizeviewport.width / viewport.width; outputscale.sy *= actualsizeviewport.height / viewport.height; outputscale.scaled = true; } if (this.maxcanvaspixels > 0) { const pixelsinviewport = viewport.width * viewport.height; const maxscale = math.sqrt(this.maxcanvaspixels / pixelsinviewport); if (outputscale.sx > maxscale || outputscale.sy > maxscale) { outputscale.sx = maxscale; outputscale.sy = maxscale; outputscale.scaled = true; this.hasrestrictedscaling = true; } else { this.hasrestrictedscaling = false; } } const sfx = (0, _ui_utils.approximatefraction)(outputscale.sx); const sfy = (0, _ui_utils.approximatefraction)(outputscale.sy); canvas.width = (0, _ui_utils.roundtodivide)(viewport.width * outputscale.sx, sfx[0]); canvas.height = (0, _ui_utils.roundtodivide)(viewport.height * outputscale.sy, sfy[0]); canvas.style.width = (0, _ui_utils.roundtodivide)(viewport.width, sfx[1]) + "px"; canvas.style.height = (0, _ui_utils.roundtodivide)(viewport.height, sfy[1]) + "px"; this.paintedviewportmap.set(canvas, viewport); const transform = !outputscale.scaled ? null : [outputscale.sx, 0, 0, outputscale.sy, 0, 0]; const rendercontext = { canvascontext: ctx, transform, viewport: this.viewport, enablewebgl: this.enablewebgl, renderinteractiveforms: this.renderinteractiveforms }; const rendertask = this.pdfpage.render(rendercontext); rendertask.oncontinue = function (cont) { showcanvas(); if (result.onrendercontinue) { result.onrendercontinue(cont); } else { cont(); } }; rendertask.promise.then(function () { showcanvas(); rendercapability.resolve(undefined); }, function (error) { showcanvas(); rendercapability.reject(error); }); return result; } paintonsvg(wrapper) { let cancelled = false; const ensurenotcancelled = () => { if (cancelled) { throw new _pdfjslib.renderingcancelledexception("rendering cancelled, page " + this.id, "svg"); } }; const pdfpage = this.pdfpage; const actualsizeviewport = this.viewport.clone({ scale: _ui_utils.css_units }); const promise = pdfpage.getoperatorlist().then(oplist => { ensurenotcancelled(); const svggfx = new _pdfjslib.svggraphics(pdfpage.commonobjs, pdfpage.objs); return svggfx.getsvg(oplist, actualsizeviewport).then(svg => { ensurenotcancelled(); this.svg = svg; this.paintedviewportmap.set(svg, actualsizeviewport); svg.style.width = wrapper.style.width; svg.style.height = wrapper.style.height; this.renderingstate = _pdf_rendering_queue.renderingstates.finished; wrapper.appendchild(svg); }); }); return { promise, onrendercontinue(cont) { cont(); }, cancel() { cancelled = true; } }; } setpagelabel(label) { this.pagelabel = typeof label === "string" ? label : null; if (this.pagelabel !== null) { this.div.setattribute("data-page-label", this.pagelabel); } else { this.div.removeattribute("data-page-label"); } } } exports.pdfpageview = pdfpageview; /***/ }), /* 13 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.pdfrenderingqueue = exports.renderingstates = void 0; const cleanup_timeout = 30000; const renderingstates = { initial: 0, running: 1, paused: 2, finished: 3 }; exports.renderingstates = renderingstates; class pdfrenderingqueue { constructor() { this.pdfviewer = null; this.pdfthumbnailviewer = null; this.onidle = null; this.highestprioritypage = null; this.idletimeout = null; this.printing = false; this.isthumbnailviewenabled = false; } setviewer(pdfviewer) { this.pdfviewer = pdfviewer; } setthumbnailviewer(pdfthumbnailviewer) { this.pdfthumbnailviewer = pdfthumbnailviewer; } ishighestpriority(view) { return this.highestprioritypage === view.renderingid; } renderhighestpriority(currentlyvisiblepages) { if (this.idletimeout) { cleartimeout(this.idletimeout); this.idletimeout = null; } if (this.pdfviewer.forcerendering(currentlyvisiblepages)) { return; } if (this.pdfthumbnailviewer && this.isthumbnailviewenabled) { if (this.pdfthumbnailviewer.forcerendering()) { return; } } if (this.printing) { return; } if (this.onidle) { this.idletimeout = settimeout(this.onidle.bind(this), cleanup_timeout); } } gethighestpriority(visible, views, scrolleddown) { const visibleviews = visible.views; const numvisible = visibleviews.length; if (numvisible === 0) { return null; } for (let i = 0; i < numvisible; ++i) { const view = visibleviews[i].view; if (!this.isviewfinished(view)) { return view; } } if (scrolleddown) { const nextpageindex = visible.last.id; if (views[nextpageindex] && !this.isviewfinished(views[nextpageindex])) { return views[nextpageindex]; } } else { const previouspageindex = visible.first.id - 2; if (views[previouspageindex] && !this.isviewfinished(views[previouspageindex])) { return views[previouspageindex]; } } return null; } isviewfinished(view) { return view.renderingstate === renderingstates.finished; } renderview(view) { switch (view.renderingstate) { case renderingstates.finished: return false; case renderingstates.paused: this.highestprioritypage = view.renderingid; view.resume(); break; case renderingstates.running: this.highestprioritypage = view.renderingid; break; case renderingstates.initial: this.highestprioritypage = view.renderingid; view.draw().finally(() => { this.renderhighestpriority(); }); break; } return true; } } exports.pdfrenderingqueue = pdfrenderingqueue; /***/ }), /* 14 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; const compatibilityparams = object.create(null); { const useragent = typeof navigator !== "undefined" && navigator.useragent || ""; const platform = typeof navigator !== "undefined" && navigator.platform || ""; const maxtouchpoints = typeof navigator !== "undefined" && navigator.maxtouchpoints || 1; const isandroid = /android/.test(useragent); const isios = /\b(ipad|iphone|ipod)(?=;)/.test(useragent) || platform === "macintel" && maxtouchpoints > 1; (function checkcanvassizelimitation() { if (isios || isandroid) { compatibilityparams.maxcanvaspixels = 5242880; } })(); } exports.viewercompatibilityparams = object.freeze(compatibilityparams); /***/ }), /* 15 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.pdfsinglepageviewer = void 0; var _base_viewer = __w_pdfjs_require__(16); var _pdfjslib = __w_pdfjs_require__(2); class pdfsinglepageviewer extends _base_viewer.baseviewer { constructor(options) { super(options); this.eventbus.on("pagesinit", evt => { this._ensurepageviewvisible(); }); } get _setdocumentviewerelement() { return (0, _pdfjslib.shadow)(this, "_setdocumentviewerelement", this._shadowviewer); } _resetview() { super._resetview(); this._previouspagenumber = 1; this._shadowviewer = document.createdocumentfragment(); this._updatescrolldown = null; } _ensurepageviewvisible() { const pageview = this._pages[this._currentpagenumber - 1]; const previouspageview = this._pages[this._previouspagenumber - 1]; const viewernodes = this.viewer.childnodes; switch (viewernodes.length) { case 0: this.viewer.appendchild(pageview.div); break; case 1: if (viewernodes[0] !== previouspageview.div) { throw new error("_ensurepageviewvisible: unexpected previously visible page."); } if (pageview === previouspageview) { break; } this._shadowviewer.appendchild(previouspageview.div); this.viewer.appendchild(pageview.div); this.container.scrolltop = 0; break; default: throw new error("_ensurepageviewvisible: only one page should be visible at a time."); } this._previouspagenumber = this._currentpagenumber; } _scrollupdate() { if (this._updatescrolldown) { this._updatescrolldown(); } super._scrollupdate(); } _scrollintoview({ pagediv, pagespot = null, pagenumber = null }) { if (pagenumber) { this._setcurrentpagenumber(pagenumber); } const scrolleddown = this._currentpagenumber >= this._previouspagenumber; this._ensurepageviewvisible(); this.update(); super._scrollintoview({ pagediv, pagespot, pagenumber }); this._updatescrolldown = () => { this.scroll.down = scrolleddown; this._updatescrolldown = null; }; } _getvisiblepages() { return this._getcurrentvisiblepage(); } _updatehelper(visiblepages) {} get _isscrollmodehorizontal() { return (0, _pdfjslib.shadow)(this, "_isscrollmodehorizontal", false); } _updatescrollmode() {} _updatespreadmode() {} } exports.pdfsinglepageviewer = pdfsinglepageviewer; /***/ }), /* 16 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.baseviewer = void 0; var _ui_utils = __w_pdfjs_require__(3); var _pdf_rendering_queue = __w_pdfjs_require__(13); var _annotation_layer_builder = __w_pdfjs_require__(1); var _pdfjslib = __w_pdfjs_require__(2); var _pdf_page_view = __w_pdfjs_require__(12); var _pdf_link_service = __w_pdfjs_require__(4); var _text_layer_builder = __w_pdfjs_require__(5); const default_cache_size = 10; function pdfpageviewbuffer(size) { const data = []; this.push = function (view) { const i = data.indexof(view); if (i >= 0) { data.splice(i, 1); } data.push(view); if (data.length > size) { data.shift().destroy(); } }; this.resize = function (newsize, pagestokeep) { size = newsize; if (pagestokeep) { const pageidstokeep = new set(); for (let i = 0, imax = pagestokeep.length; i < imax; ++i) { pageidstokeep.add(pagestokeep[i].id); } (0, _ui_utils.movetoendofarray)(data, function (page) { return pageidstokeep.has(page.id); }); } while (data.length > size) { data.shift().destroy(); } }; } function issamescale(oldscale, newscale) { if (newscale === oldscale) { return true; } if (math.abs(newscale - oldscale) < 1e-15) { return true; } return false; } class baseviewer { constructor(options) { if (this.constructor === baseviewer) { throw new error("cannot initialize baseviewer."); } this._name = this.constructor.name; this.container = options.container; this.viewer = options.viewer || options.container.firstelementchild; this.eventbus = options.eventbus || (0, _ui_utils.getglobaleventbus)(); this.linkservice = options.linkservice || new _pdf_link_service.simplelinkservice(); this.downloadmanager = options.downloadmanager || null; this.findcontroller = options.findcontroller || null; this.removepageborders = options.removepageborders || false; this.textlayermode = number.isinteger(options.textlayermode) ? options.textlayermode : _ui_utils.textlayermode.enable; this.imageresourcespath = options.imageresourcespath || ""; this.renderinteractiveforms = options.renderinteractiveforms || false; this.enableprintautorotate = options.enableprintautorotate || false; this.renderer = options.renderer || _ui_utils.renderertype.canvas; this.enablewebgl = options.enablewebgl || false; this.useonlycsszoom = options.useonlycsszoom || false; this.maxcanvaspixels = options.maxcanvaspixels; this.l10n = options.l10n || _ui_utils.nulll10n; this.defaultrenderingqueue = !options.renderingqueue; if (this.defaultrenderingqueue) { this.renderingqueue = new _pdf_rendering_queue.pdfrenderingqueue(); this.renderingqueue.setviewer(this); } else { this.renderingqueue = options.renderingqueue; } this.scroll = (0, _ui_utils.watchscroll)(this.container, this._scrollupdate.bind(this)); this.presentationmodestate = _ui_utils.presentationmodestate.unknown; this._onbeforedraw = this._onafterdraw = null; this._resetview(); if (this.removepageborders) { this.viewer.classlist.add("removepageborders"); } promise.resolve().then(() => { this.eventbus.dispatch("baseviewerinit", { source: this }); }); } get pagescount() { return this._pages.length; } getpageview(index) { return this._pages[index]; } get pageviewsready() { if (!this._pageviewsready) { return false; } return this._pages.every(function (pageview) { return !!(pageview && pageview.pdfpage); }); } get currentpagenumber() { return this._currentpagenumber; } set currentpagenumber(val) { if (!number.isinteger(val)) { throw new error("invalid page number."); } if (!this.pdfdocument) { return; } if (!this._setcurrentpagenumber(val, true)) { console.error(`${this._name}.currentpagenumber: "${val}" is not a valid page.`); } } _setcurrentpagenumber(val, resetcurrentpageview = false) { if (this._currentpagenumber === val) { if (resetcurrentpageview) { this._resetcurrentpageview(); } return true; } if (!(0 < val && val <= this.pagescount)) { return false; } this._currentpagenumber = val; this.eventbus.dispatch("pagechanging", { source: this, pagenumber: val, pagelabel: this._pagelabels && this._pagelabels[val - 1] }); if (resetcurrentpageview) { this._resetcurrentpageview(); } return true; } get currentpagelabel() { return this._pagelabels && this._pagelabels[this._currentpagenumber - 1]; } set currentpagelabel(val) { if (!this.pdfdocument) { return; } let page = val | 0; if (this._pagelabels) { const i = this._pagelabels.indexof(val); if (i >= 0) { page = i + 1; } } if (!this._setcurrentpagenumber(page, true)) { console.error(`${this._name}.currentpagelabel: "${val}" is not a valid page.`); } } get currentscale() { return this._currentscale !== _ui_utils.unknown_scale ? this._currentscale : _ui_utils.default_scale; } set currentscale(val) { if (isnan(val)) { throw new error("invalid numeric scale."); } if (!this.pdfdocument) { return; } this._setscale(val, false); } get currentscalevalue() { return this._currentscalevalue; } set currentscalevalue(val) { if (!this.pdfdocument) { return; } this._setscale(val, false); } get pagesrotation() { return this._pagesrotation; } set pagesrotation(rotation) { if (!(0, _ui_utils.isvalidrotation)(rotation)) { throw new error("invalid pages rotation angle."); } if (!this.pdfdocument) { return; } if (this._pagesrotation === rotation) { return; } this._pagesrotation = rotation; const pagenumber = this._currentpagenumber; for (let i = 0, ii = this._pages.length; i < ii; i++) { const pageview = this._pages[i]; pageview.update(pageview.scale, rotation); } if (this._currentscalevalue) { this._setscale(this._currentscalevalue, true); } this.eventbus.dispatch("rotationchanging", { source: this, pagesrotation: rotation, pagenumber }); if (this.defaultrenderingqueue) { this.update(); } } get _setdocumentviewerelement() { throw new error("not implemented: _setdocumentviewerelement"); } setdocument(pdfdocument) { if (this.pdfdocument) { this._cancelrendering(); this._resetview(); if (this.findcontroller) { this.findcontroller.setdocument(null); } } this.pdfdocument = pdfdocument; if (!pdfdocument) { return; } const pagescount = pdfdocument.numpages; const pagescapability = (0, _pdfjslib.createpromisecapability)(); this.pagespromise = pagescapability.promise; pagescapability.promise.then(() => { this._pageviewsready = true; this.eventbus.dispatch("pagesloaded", { source: this, pagescount }); }); const onepagerenderedcapability = (0, _pdfjslib.createpromisecapability)(); this.onepagerendered = onepagerenderedcapability.promise; const firstpagepromise = pdfdocument.getpage(1); this.firstpagepromise = firstpagepromise; this._onbeforedraw = evt => { const pageview = this._pages[evt.pagenumber - 1]; if (!pageview) { return; } this._buffer.push(pageview); }; this.eventbus.on("pagerender", this._onbeforedraw); this._onafterdraw = evt => { if (evt.csstransform || onepagerenderedcapability.settled) { return; } onepagerenderedcapability.resolve(); this.eventbus.off("pagerendered", this._onafterdraw); this._onafterdraw = null; }; this.eventbus.on("pagerendered", this._onafterdraw); firstpagepromise.then(firstpdfpage => { const scale = this.currentscale; const viewport = firstpdfpage.getviewport({ scale: scale * _ui_utils.css_units }); for (let pagenum = 1; pagenum <= pagescount; ++pagenum) { let textlayerfactory = null; if (this.textlayermode !== _ui_utils.textlayermode.disable) { textlayerfactory = this; } const pageview = new _pdf_page_view.pdfpageview({ container: this._setdocumentviewerelement, eventbus: this.eventbus, id: pagenum, scale, defaultviewport: viewport.clone(), renderingqueue: this.renderingqueue, textlayerfactory, textlayermode: this.textlayermode, annotationlayerfactory: this, imageresourcespath: this.imageresourcespath, renderinteractiveforms: this.renderinteractiveforms, renderer: this.renderer, enablewebgl: this.enablewebgl, useonlycsszoom: this.useonlycsszoom, maxcanvaspixels: this.maxcanvaspixels, l10n: this.l10n }); this._pages.push(pageview); } const firstpageview = this._pages[0]; if (firstpageview) { firstpageview.setpdfpage(firstpdfpage); this.linkservice.cachepageref(1, firstpdfpage.ref); } if (this._spreadmode !== _ui_utils.spreadmode.none) { this._updatespreadmode(); } onepagerenderedcapability.promise.then(() => { if (this.findcontroller) { this.findcontroller.setdocument(pdfdocument); } if (pdfdocument.loadingparams["disableautofetch"] || pagescount > 7500) { pagescapability.resolve(); return; } let getpagesleft = pagescount - 1; if (getpagesleft <= 0) { pagescapability.resolve(); return; } for (let pagenum = 2; pagenum <= pagescount; ++pagenum) { pdfdocument.getpage(pagenum).then(pdfpage => { const pageview = this._pages[pagenum - 1]; if (!pageview.pdfpage) { pageview.setpdfpage(pdfpage); } this.linkservice.cachepageref(pagenum, pdfpage.ref); if (--getpagesleft === 0) { pagescapability.resolve(); } }, reason => { console.error(`unable to get page ${pagenum} to initialize viewer`, reason); if (--getpagesleft === 0) { pagescapability.resolve(); } }); } }); this.eventbus.dispatch("pagesinit", { source: this }); if (this.defaultrenderingqueue) { this.update(); } }).catch(reason => { console.error("unable to initialize viewer", reason); }); } setpagelabels(labels) { if (!this.pdfdocument) { return; } if (!labels) { this._pagelabels = null; } else if (!(array.isarray(labels) && this.pdfdocument.numpages === labels.length)) { this._pagelabels = null; console.error(`${this._name}.setpagelabels: invalid page labels.`); } else { this._pagelabels = labels; } for (let i = 0, ii = this._pages.length; i < ii; i++) { const pageview = this._pages[i]; const label = this._pagelabels && this._pagelabels[i]; pageview.setpagelabel(label); } } _resetview() { this._pages = []; this._currentpagenumber = 1; this._currentscale = _ui_utils.unknown_scale; this._currentscalevalue = null; this._pagelabels = null; this._buffer = new pdfpageviewbuffer(default_cache_size); this._location = null; this._pagesrotation = 0; this._pagesrequests = new weakmap(); this._pageviewsready = false; this._scrollmode = _ui_utils.scrollmode.vertical; this._spreadmode = _ui_utils.spreadmode.none; if (this._onbeforedraw) { this.eventbus.off("pagerender", this._onbeforedraw); this._onbeforedraw = null; } if (this._onafterdraw) { this.eventbus.off("pagerendered", this._onafterdraw); this._onafterdraw = null; } this.viewer.textcontent = ""; this._updatescrollmode(); } _scrollupdate() { if (this.pagescount === 0) { return; } this.update(); } _scrollintoview({ pagediv, pagespot = null, pagenumber = null }) { (0, _ui_utils.scrollintoview)(pagediv, pagespot); } _setscaleupdatepages(newscale, newvalue, noscroll = false, preset = false) { this._currentscalevalue = newvalue.tostring(); if (issamescale(this._currentscale, newscale)) { if (preset) { this.eventbus.dispatch("scalechanging", { source: this, scale: newscale, presetvalue: newvalue }); } return; } for (let i = 0, ii = this._pages.length; i < ii; i++) { this._pages[i].update(newscale); } this._currentscale = newscale; if (!noscroll) { let page = this._currentpagenumber, dest; if (this._location && !(this.isinpresentationmode || this.ischangingpresentationmode)) { page = this._location.pagenumber; dest = [null, { name: "xyz" }, this._location.left, this._location.top, null]; } this.scrollpageintoview({ pagenumber: page, destarray: dest, allownegativeoffset: true }); } this.eventbus.dispatch("scalechanging", { source: this, scale: newscale, presetvalue: preset ? newvalue : undefined }); if (this.defaultrenderingqueue) { this.update(); } } _setscale(value, noscroll = false) { let scale = parsefloat(value); if (scale > 0) { this._setscaleupdatepages(scale, value, noscroll, false); } else { const currentpage = this._pages[this._currentpagenumber - 1]; if (!currentpage) { return; } const nopadding = this.isinpresentationmode || this.removepageborders; let hpadding = nopadding ? 0 : _ui_utils.scrollbar_padding; let vpadding = nopadding ? 0 : _ui_utils.vertical_padding; if (!nopadding && this._isscrollmodehorizontal) { [hpadding, vpadding] = [vpadding, hpadding]; } const pagewidthscale = (this.container.clientwidth - hpadding) / currentpage.width * currentpage.scale; const pageheightscale = (this.container.clientheight - vpadding) / currentpage.height * currentpage.scale; switch (value) { case "page-actual": scale = 1; break; case "page-width": scale = pagewidthscale; break; case "page-height": scale = pageheightscale; break; case "page-fit": scale = math.min(pagewidthscale, pageheightscale); break; case "auto": const horizontalscale = (0, _ui_utils.isportraitorientation)(currentpage) ? pagewidthscale : math.min(pageheightscale, pagewidthscale); scale = math.min(_ui_utils.max_auto_scale, horizontalscale); break; default: console.error(`${this._name}._setscale: "${value}" is an unknown zoom value.`); return; } this._setscaleupdatepages(scale, value, noscroll, true); } } _resetcurrentpageview() { if (this.isinpresentationmode) { this._setscale(this._currentscalevalue, true); } const pageview = this._pages[this._currentpagenumber - 1]; this._scrollintoview({ pagediv: pageview.div }); } scrollpageintoview({ pagenumber, destarray = null, allownegativeoffset = false }) { if (!this.pdfdocument) { return; } const pageview = number.isinteger(pagenumber) && this._pages[pagenumber - 1]; if (!pageview) { console.error(`${this._name}.scrollpageintoview: ` + `"${pagenumber}" is not a valid pagenumber parameter.`); return; } if (this.isinpresentationmode || !destarray) { this._setcurrentpagenumber(pagenumber, true); return; } let x = 0, y = 0; let width = 0, height = 0, widthscale, heightscale; const changeorientation = pageview.rotation % 180 !== 0; const pagewidth = (changeorientation ? pageview.height : pageview.width) / pageview.scale / _ui_utils.css_units; const pageheight = (changeorientation ? pageview.width : pageview.height) / pageview.scale / _ui_utils.css_units; let scale = 0; switch (destarray[1].name) { case "xyz": x = destarray[2]; y = destarray[3]; scale = destarray[4]; x = x !== null ? x : 0; y = y !== null ? y : pageheight; break; case "fit": case "fitb": scale = "page-fit"; break; case "fith": case "fitbh": y = destarray[2]; scale = "page-width"; if (y === null && this._location) { x = this._location.left; y = this._location.top; } break; case "fitv": case "fitbv": x = destarray[2]; width = pagewidth; height = pageheight; scale = "page-height"; break; case "fitr": x = destarray[2]; y = destarray[3]; width = destarray[4] - x; height = destarray[5] - y; const hpadding = this.removepageborders ? 0 : _ui_utils.scrollbar_padding; const vpadding = this.removepageborders ? 0 : _ui_utils.vertical_padding; widthscale = (this.container.clientwidth - hpadding) / width / _ui_utils.css_units; heightscale = (this.container.clientheight - vpadding) / height / _ui_utils.css_units; scale = math.min(math.abs(widthscale), math.abs(heightscale)); break; default: console.error(`${this._name}.scrollpageintoview: ` + `"${destarray[1].name}" is not a valid destination type.`); return; } if (scale && scale !== this._currentscale) { this.currentscalevalue = scale; } else if (this._currentscale === _ui_utils.unknown_scale) { this.currentscalevalue = _ui_utils.default_scale_value; } if (scale === "page-fit" && !destarray[4]) { this._scrollintoview({ pagediv: pageview.div, pagenumber }); return; } const boundingrect = [pageview.viewport.converttoviewportpoint(x, y), pageview.viewport.converttoviewportpoint(x + width, y + height)]; let left = math.min(boundingrect[0][0], boundingrect[1][0]); let top = math.min(boundingrect[0][1], boundingrect[1][1]); if (!allownegativeoffset) { left = math.max(left, 0); top = math.max(top, 0); } this._scrollintoview({ pagediv: pageview.div, pagespot: { left, top }, pagenumber }); } _updatelocation(firstpage) { const currentscale = this._currentscale; const currentscalevalue = this._currentscalevalue; const normalizedscalevalue = parsefloat(currentscalevalue) === currentscale ? math.round(currentscale * 10000) / 100 : currentscalevalue; const pagenumber = firstpage.id; let pdfopenparams = "#page=" + pagenumber; pdfopenparams += "&zoom=" + normalizedscalevalue; const currentpageview = this._pages[pagenumber - 1]; const container = this.container; const topleft = currentpageview.getpagepoint(container.scrollleft - firstpage.x, container.scrolltop - firstpage.y); const intleft = math.round(topleft[0]); const inttop = math.round(topleft[1]); pdfopenparams += "," + intleft + "," + inttop; this._location = { pagenumber, scale: normalizedscalevalue, top: inttop, left: intleft, rotation: this._pagesrotation, pdfopenparams }; } _updatehelper(visiblepages) { throw new error("not implemented: _updatehelper"); } update() { const visible = this._getvisiblepages(); const visiblepages = visible.views, numvisiblepages = visiblepages.length; if (numvisiblepages === 0) { return; } const newcachesize = math.max(default_cache_size, 2 * numvisiblepages + 1); this._buffer.resize(newcachesize, visiblepages); this.renderingqueue.renderhighestpriority(visible); this._updatehelper(visiblepages); this._updatelocation(visible.first); this.eventbus.dispatch("updateviewarea", { source: this, location: this._location }); } containselement(element) { return this.container.contains(element); } focus() { this.container.focus(); } get _isscrollmodehorizontal() { return this.isinpresentationmode ? false : this._scrollmode === _ui_utils.scrollmode.horizontal; } get isinpresentationmode() { return this.presentationmodestate === _ui_utils.presentationmodestate.fullscreen; } get ischangingpresentationmode() { return this.presentationmodestate === _ui_utils.presentationmodestate.changing; } get ishorizontalscrollbarenabled() { return this.isinpresentationmode ? false : this.container.scrollwidth > this.container.clientwidth; } get isverticalscrollbarenabled() { return this.isinpresentationmode ? false : this.container.scrollheight > this.container.clientheight; } _getcurrentvisiblepage() { if (!this.pagescount) { return { views: [] }; } const pageview = this._pages[this._currentpagenumber - 1]; const element = pageview.div; const view = { id: pageview.id, x: element.offsetleft + element.clientleft, y: element.offsettop + element.clienttop, view: pageview }; return { first: view, last: view, views: [view] }; } _getvisiblepages() { return (0, _ui_utils.getvisibleelements)(this.container, this._pages, true, this._isscrollmodehorizontal); } ispagevisible(pagenumber) { if (!this.pdfdocument) { return false; } if (pagenumber < 1 || pagenumber > this.pagescount) { console.error(`${this._name}.ispagevisible: "${pagenumber}" is out of bounds.`); return false; } return this._getvisiblepages().views.some(function (view) { return view.id === pagenumber; }); } cleanup() { for (let i = 0, ii = this._pages.length; i < ii; i++) { if (this._pages[i] && this._pages[i].renderingstate !== _pdf_rendering_queue.renderingstates.finished) { this._pages[i].reset(); } } } _cancelrendering() { for (let i = 0, ii = this._pages.length; i < ii; i++) { if (this._pages[i]) { this._pages[i].cancelrendering(); } } } _ensurepdfpageloaded(pageview) { if (pageview.pdfpage) { return promise.resolve(pageview.pdfpage); } if (this._pagesrequests.has(pageview)) { return this._pagesrequests.get(pageview); } const promise = this.pdfdocument.getpage(pageview.id).then(pdfpage => { if (!pageview.pdfpage) { pageview.setpdfpage(pdfpage); } this._pagesrequests.delete(pageview); return pdfpage; }).catch(reason => { console.error("unable to get page for page view", reason); this._pagesrequests.delete(pageview); }); this._pagesrequests.set(pageview, promise); return promise; } forcerendering(currentlyvisiblepages) { const visiblepages = currentlyvisiblepages || this._getvisiblepages(); const scrollahead = this._isscrollmodehorizontal ? this.scroll.right : this.scroll.down; const pageview = this.renderingqueue.gethighestpriority(visiblepages, this._pages, scrollahead); if (pageview) { this._ensurepdfpageloaded(pageview).then(() => { this.renderingqueue.renderview(pageview); }); return true; } return false; } createtextlayerbuilder(textlayerdiv, pageindex, viewport, enhancetextselection = false) { return new _text_layer_builder.textlayerbuilder({ textlayerdiv, eventbus: this.eventbus, pageindex, viewport, findcontroller: this.isinpresentationmode ? null : this.findcontroller, enhancetextselection: this.isinpresentationmode ? false : enhancetextselection }); } createannotationlayerbuilder(pagediv, pdfpage, imageresourcespath = "", renderinteractiveforms = false, l10n = _ui_utils.nulll10n) { return new _annotation_layer_builder.annotationlayerbuilder({ pagediv, pdfpage, imageresourcespath, renderinteractiveforms, linkservice: this.linkservice, downloadmanager: this.downloadmanager, l10n }); } get hasequalpagesizes() { const firstpageview = this._pages[0]; for (let i = 1, ii = this._pages.length; i < ii; ++i) { const pageview = this._pages[i]; if (pageview.width !== firstpageview.width || pageview.height !== firstpageview.height) { return false; } } return true; } getpagesoverview() { const pagesoverview = this._pages.map(function (pageview) { const viewport = pageview.pdfpage.getviewport({ scale: 1 }); return { width: viewport.width, height: viewport.height, rotation: viewport.rotation }; }); if (!this.enableprintautorotate) { return pagesoverview; } const isfirstpageportrait = (0, _ui_utils.isportraitorientation)(pagesoverview[0]); return pagesoverview.map(function (size) { if (isfirstpageportrait === (0, _ui_utils.isportraitorientation)(size)) { return size; } return { width: size.height, height: size.width, rotation: (size.rotation + 90) % 360 }; }); } get scrollmode() { return this._scrollmode; } set scrollmode(mode) { if (this._scrollmode === mode) { return; } if (!(0, _ui_utils.isvalidscrollmode)(mode)) { throw new error(`invalid scroll mode: ${mode}`); } this._scrollmode = mode; this.eventbus.dispatch("scrollmodechanged", { source: this, mode }); this._updatescrollmode(this._currentpagenumber); } _updatescrollmode(pagenumber = null) { const scrollmode = this._scrollmode, viewer = this.viewer; viewer.classlist.toggle("scrollhorizontal", scrollmode === _ui_utils.scrollmode.horizontal); viewer.classlist.toggle("scrollwrapped", scrollmode === _ui_utils.scrollmode.wrapped); if (!this.pdfdocument || !pagenumber) { return; } if (this._currentscalevalue && isnan(this._currentscalevalue)) { this._setscale(this._currentscalevalue, true); } this._setcurrentpagenumber(pagenumber, true); this.update(); } get spreadmode() { return this._spreadmode; } set spreadmode(mode) { if (this._spreadmode === mode) { return; } if (!(0, _ui_utils.isvalidspreadmode)(mode)) { throw new error(`invalid spread mode: ${mode}`); } this._spreadmode = mode; this.eventbus.dispatch("spreadmodechanged", { source: this, mode }); this._updatespreadmode(this._currentpagenumber); } _updatespreadmode(pagenumber = null) { if (!this.pdfdocument) { return; } const viewer = this.viewer, pages = this._pages; viewer.textcontent = ""; if (this._spreadmode === _ui_utils.spreadmode.none) { for (let i = 0, imax = pages.length; i < imax; ++i) { viewer.appendchild(pages[i].div); } } else { const parity = this._spreadmode - 1; let spread = null; for (let i = 0, imax = pages.length; i < imax; ++i) { if (spread === null) { spread = document.createelement("div"); spread.classname = "spread"; viewer.appendchild(spread); } else if (i % 2 === parity) { spread = spread.clonenode(false); viewer.appendchild(spread); } spread.appendchild(pages[i].div); } } if (!pagenumber) { return; } this._setcurrentpagenumber(pagenumber, true); this.update(); } } exports.baseviewer = baseviewer; /***/ }), /* 17 */ /***/ (function(module, exports, __w_pdfjs_require__) { "use strict"; object.defineproperty(exports, "__esmodule", { value: true }); exports.pdfviewer = void 0; var _base_viewer = __w_pdfjs_require__(16); var _pdfjslib = __w_pdfjs_require__(2); class pdfviewer extends _base_viewer.baseviewer { get _setdocumentviewerelement() { return (0, _pdfjslib.shadow)(this, "_setdocumentviewerelement", this.viewer); } _scrollintoview({ pagediv, pagespot = null, pagenumber = null }) { if (!pagespot && !this.isinpresentationmode) { const left = pagediv.offsetleft + pagediv.clientleft; const right = left + pagediv.clientwidth; const { scrollleft, clientwidth } = this.container; if (this._isscrollmodehorizontal || left < scrollleft || right > scrollleft + clientwidth) { pagespot = { left: 0, top: 0 }; } } super._scrollintoview({ pagediv, pagespot, pagenumber }); } _getvisiblepages() { if (this.isinpresentationmode) { return this._getcurrentvisiblepage(); } return super._getvisiblepages(); } _updatehelper(visiblepages) { if (this.isinpresentationmode) { return; } let currentid = this._currentpagenumber; let stillfullyvisible = false; for (const page of visiblepages) { if (page.percent < 100) { break; } if (page.id === currentid) { stillfullyvisible = true; break; } } if (!stillfullyvisible) { currentid = visiblepages[0].id; } this._setcurrentpagenumber(currentid); } } exports.pdfviewer = pdfviewer; /***/ }) /******/ ]); }); //# sourcemappingurl=pdf_viewer.js.map