/**
 * @licstart The following is the entire license notice for the
 * JavaScript code in this page
 *
 * Copyright 2023 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
 */

/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/ 
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ 	// define getter functions for harmony exports
/******/ 	__webpack_require__.d = (exports, definition) => {
/******/ 		for(var key in definition) {
/******/ 			if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 				Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 			}
/******/ 		}
/******/ 	};
/******/ })();
/******/ 
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ 	__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/ 
/************************************************************************/
var __webpack_exports__ = globalThis.pdfjsSandbox = {};

// EXPORTS
__webpack_require__.d(__webpack_exports__, {
  QuickJSSandbox: () => (/* binding */ QuickJSSandbox)
});

;// CONCATENATED MODULE: ./external/quickjs/quickjs-eval.js
var Module=(()=>{var _scriptDir=typeof document!=='undefined'&&document.currentScript?document.currentScript.src:undefined;return function(Module){Module=Module||{};var c;c||(c=typeof Module!=='undefined'?Module:{});var h,n;c.ready=new Promise(function(a,b){h=a;n=b;});var r=Object.assign({},c),t="";"undefined"!=typeof document&&document.currentScript&&(t=document.currentScript.src);_scriptDir&&(t=_scriptDir);0!==t.indexOf("blob:")?t=t.substr(0,t.replace(/[?#].*/,"").lastIndexOf("/")+1):t="";var aa=c.print||console.log.bind(console),u=c.printErr||console.warn.bind(console);Object.assign(c,r);r=null;var v;c.wasmBinary&&(v=c.wasmBinary);var noExitRuntime=c.noExitRuntime||!0;"object"!=typeof WebAssembly&&w("no native wasm support detected");var x,y=!1;function z(a,b,d,e){var f={string:function(l){var p=0;if(null!==l&&void 0!==l&&0!==l){var S=(l.length<<2)+1;p=A(S);B(l,C,p,S);}return p;},array:function(l){var p=A(l.length);D.set(l,p);return p;}};a=c["_"+a];var g=[],k=0;if(e)for(var m=0;m<e.length;m++){var q=f[d[m]];q?(0===k&&(k=E()),g[m]=q(e[m])):g[m]=e[m];}d=a.apply(null,g);return d=function(l){0!==k&&F(k);return"string"===b?G(l):"boolean"===b?!!l:l;}(d);}var H="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function I(a,b){for(var d=b+NaN,e=b;a[e]&&!(e>=d);)++e;if(16<e-b&&a.buffer&&H)return H.decode(a.subarray(b,e));for(d="";b<e;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))d+=String.fromCharCode((f&31)<<6|g);else{var k=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|k:(f&7)<<18|g<<12|k<<6|a[b++]&63;65536>f?d+=String.fromCharCode(f):(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023));}}else d+=String.fromCharCode(f);}return d;}function G(a){return a?I(C,a):"";}function B(a,b,d,e){if(0<e){e=d+e-1;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var k=a.charCodeAt(++f);g=65536+((g&1023)<<10)|k&1023;}if(127>=g){if(d>=e)break;b[d++]=g;}else{if(2047>=g){if(d+1>=e)break;b[d++]=192|g>>6;}else{if(65535>=g){if(d+2>=e)break;b[d++]=224|g>>12;}else{if(d+3>=e)break;b[d++]=240|g>>18;b[d++]=128|g>>12&63;}b[d++]=128|g>>6&63;}b[d++]=128|g&63;}}b[d]=0;}}function J(a){for(var b=0,d=0;d<a.length;++d){var e=a.charCodeAt(d);55296<=e&&57343>=e&&(e=65536+((e&1023)<<10)|a.charCodeAt(++d)&1023);127>=e?++b:b=2047>=e?b+2:65535>=e?b+3:b+4;}return b;}function K(a){var b=J(a)+1,d=L(b);d&&B(a,D,d,b);return d;}var M,D,C,N;function ba(){var a=x.buffer;M=a;c.HEAP8=D=new Int8Array(a);c.HEAP16=new Int16Array(a);c.HEAP32=N=new Int32Array(a);c.HEAPU8=C=new Uint8Array(a);c.HEAPU16=new Uint16Array(a);c.HEAPU32=new Uint32Array(a);c.HEAPF32=new Float32Array(a);c.HEAPF64=new Float64Array(a);}var O,ca=[],da=[],ea=[];function fa(){var a=c.preRun.shift();ca.unshift(a);}var P=0,Q=null,R=null;function w(a){if(c.onAbort)c.onAbort(a);a="Aborted("+a+")";u(a);y=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");n(a);throw a;}function T(a){return a.startsWith("data:application/octet-stream;base64,");}var U;U="data:application/octet-stream;base64,[encoded data, 500660 characters]";if(!T(U)){var ha=U;U=c.locateFile?c.locateFile(ha,t):t+ha;}function ia(){var a=U;try{if(a==U&&v)return new Uint8Array(v);if(T(a))try{var b=ja(a.slice(37)),d=new Uint8Array(b.length);for(a=0;a<b.length;++a)d[a]=b.charCodeAt(a);var e=d;}catch(g){throw Error("Converting base64 string to bytes failed.");}else e=void 0;var f=e;if(f)return f;throw"both async and sync fetching of the wasm failed";}catch(g){w(g);}}function ka(){return v||"function"!=typeof fetch?Promise.resolve().then(function(){return ia();}):fetch(U,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+U+"'";return a.arrayBuffer();}).catch(function(){return ia();});}function V(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(c);else{var d=b.C;"number"==typeof d?void 0===b.A?O.get(d)():O.get(d)(b.A):d(void 0===b.A?null:b.A);}}}function la(a,b,d){function e(q){return(q=q.toTimeString().match(/\(([A-Za-z ]+)\)$/))?q[1]:"GMT";}var f=new Date().getFullYear(),g=new Date(f,0,1),k=new Date(f,6,1);f=g.getTimezoneOffset();var m=k.getTimezoneOffset();N[a>>2]=60*Math.max(f,m);N[b>>2]=Number(f!=m);a=e(g);b=e(k);a=K(a);b=K(b);m<f?(N[d>>2]=a,N[d+4>>2]=b):(N[d>>2]=b,N[d+4>>2]=a);}function W(a,b,d){W.B||(W.B=!0,la(a,b,d));}function X(a){var b=J(a)+1,d=L(b);B(a,C,d,b);return d;}function ma(){}var na=[null,[],[]];ma=(a,b,d)=>{a=G(a);b=null!==b?JSON.parse(G(b)):[];try{const e=c.externalCall(a,b);return e?X(e):null;}catch(e){return c.HEAPU8[d]=1,X(e.message);}};var ja="function"==typeof atob?atob:function(a){var b="",d=0;a=a.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));var k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));e=e<<2|f>>4;f=(f&15)<<4|g>>2;var m=(g&3)<<6|k;b+=String.fromCharCode(e);64!==g&&(b+=String.fromCharCode(f));64!==k&&(b+=String.fromCharCode(m));}while(d<a.length);return b;},oa={a:function(a,b,d,e){w("Assertion failed: "+G(a)+", at: "+[b?G(b):"unknown filename",d,e?G(e):"unknown function"]);},d:function(){return Date.now();},e:function(a,b){a=new Date(1E3*N[a>>2]);N[b>>2]=a.getSeconds();N[b+4>>2]=a.getMinutes();N[b+8>>2]=a.getHours();N[b+12>>2]=a.getDate();N[b+16>>2]=a.getMonth();N[b+20>>2]=a.getFullYear()-1900;N[b+24>>2]=a.getDay();var d=new Date(a.getFullYear(),0,1);N[b+28>>2]=(a.getTime()-d.getTime())/864E5|0;N[b+36>>2]=-(60*a.getTimezoneOffset());var e=new Date(a.getFullYear(),6,1).getTimezoneOffset();d=d.getTimezoneOffset();N[b+32>>2]=(e!=d&&a.getTimezoneOffset()==Math.min(d,e))|0;},f:W,b:function(){w("");},h:ma,g:function(a,b){a=G(a);let d;try{d=window.JSON.parse(a);}catch(e){d=a;}0!==b?window.alert(a):window.console.log("DUMP",d);},j:function(a){var b=C.length;a>>>=0;if(2147483648<a)return!1;for(var d=1;4>=d;d*=2){var e=b*(1+.2/d);e=Math.min(e,a+100663296);var f=Math;e=Math.max(a,e);f=f.min.call(f,2147483648,e+(65536-e%65536)%65536);a:{try{x.grow(f-M.byteLength+65535>>>16);ba();var g=1;break a;}catch(k){}g=void 0;}if(g)return!0;}return!1;},c:function(a,b,d,e){for(var f=0,g=0;g<d;g++){var k=N[b>>2],m=N[b+4>>2];b+=8;for(var q=0;q<m;q++){var l=C[k+q],p=na[a];0===l||10===l?((1===a?aa:u)(I(p,0)),p.length=0):p.push(l);}f+=m;}N[e>>2]=f;return 0;},k:function(a){a=G(a);window.console.log(a);},i:function(a){a=G(a);return Date.parse(a);},l:function(a,b,d,e){a=G(a);b=G(b);d=G(d);d=`Quickjs -- ${a}: ${b}\n${d}`;0!==e?window.alert(d):window.console.error(d);}};(function(){function a(f){c.asm=f.exports;x=c.asm.m;ba();O=c.asm.v;da.unshift(c.asm.n);P--;c.monitorRunDependencies&&c.monitorRunDependencies(P);0==P&&(null!==Q&&(clearInterval(Q),Q=null),R&&(f=R,R=null,f()));}function b(f){a(f.instance);}function d(f){return ka().then(function(g){return WebAssembly.instantiate(g,e);}).then(function(g){return g;}).then(f,function(g){u("failed to asynchronously prepare wasm: "+g);w(g);});}var e={a:oa};P++;c.monitorRunDependencies&&c.monitorRunDependencies(P);if(c.instantiateWasm)try{return c.instantiateWasm(e,a);}catch(f){return u("Module.instantiateWasm callback failed with error: "+f),!1;}(function(){return v||"function"!=typeof WebAssembly.instantiateStreaming||T(U)||"function"!=typeof fetch?d(b):fetch(U,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(b,function(g){u("wasm streaming compile failed: "+g);u("falling back to ArrayBuffer instantiation");return d(b);});});})().catch(n);return{};})();c.___wasm_call_ctors=function(){return(c.___wasm_call_ctors=c.asm.n).apply(null,arguments);};c._evalInSandbox=function(){return(c._evalInSandbox=c.asm.o).apply(null,arguments);};c._nukeSandbox=function(){return(c._nukeSandbox=c.asm.p).apply(null,arguments);};c._init=function(){return(c._init=c.asm.q).apply(null,arguments);};c._commFun=function(){return(c._commFun=c.asm.r).apply(null,arguments);};c._dumpMemoryUse=function(){return(c._dumpMemoryUse=c.asm.s).apply(null,arguments);};var L=c._malloc=function(){return(L=c._malloc=c.asm.t).apply(null,arguments);};c._free=function(){return(c._free=c.asm.u).apply(null,arguments);};var E=c.stackSave=function(){return(E=c.stackSave=c.asm.w).apply(null,arguments);},F=c.stackRestore=function(){return(F=c.stackRestore=c.asm.x).apply(null,arguments);},A=c.stackAlloc=function(){return(A=c.stackAlloc=c.asm.y).apply(null,arguments);};c.ccall=z;c.cwrap=function(a,b,d,e){d=d||[];var f=d.every(function(g){return"number"===g;});return"string"!==b&&f&&!e?c["_"+a]:function(){return z(a,b,d,arguments,e);};};c.stringToNewUTF8=X;var Y;R=function pa(){Y||Z();Y||(R=pa);};function Z(){function a(){if(!Y&&(Y=!0,c.calledRun=!0,!y)){V(da);h(c);if(c.onRuntimeInitialized)c.onRuntimeInitialized();if(c.postRun)for("function"==typeof c.postRun&&(c.postRun=[c.postRun]);c.postRun.length;){var b=c.postRun.shift();ea.unshift(b);}V(ea);}}if(!(0<P)){if(c.preRun)for("function"==typeof c.preRun&&(c.preRun=[c.preRun]);c.preRun.length;)fa();V(ca);0<P||(c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("");},1);a();},1)):a());}}c.run=Z;if(c.preInit)for("function"==typeof c.preInit&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();Z();return Module.ready;};})();/* harmony default export */ const quickjs_eval = (Module);
;// CONCATENATED MODULE: ./src/pdf.sandbox.external.js
class SandboxSupportBase {
  constructor(win) {
    this.win = win;
    this.timeoutIds = new Map();
    this.commFun = null;
  }
  destroy() {
    this.commFun = null;
    for (const id of this.timeoutIds.values()) {
      this.win.clearTimeout(id);
    }
    this.timeoutIds = null;
  }
  exportValueToSandbox(val) {
    throw new Error("Not implemented");
  }
  importValueFromSandbox(val) {
    throw new Error("Not implemented");
  }
  createErrorForSandbox(errorMessage) {
    throw new Error("Not implemented");
  }
  callSandboxFunction(name, args) {
    try {
      args = this.exportValueToSandbox(args);
      this.commFun(name, args);
    } catch (e) {
      this.win.console.error(e);
    }
  }
  createSandboxExternals() {
    const externals = {
      setTimeout: (callbackId, nMilliseconds) => {
        if (typeof callbackId !== "number" || typeof nMilliseconds !== "number") {
          return;
        }
        if (callbackId === 0) {
          this.win.clearTimeout(this.timeoutIds.get(callbackId));
        }
        const id = this.win.setTimeout(() => {
          this.timeoutIds.delete(callbackId);
          this.callSandboxFunction("timeoutCb", {
            callbackId,
            interval: false
          });
        }, nMilliseconds);
        this.timeoutIds.set(callbackId, id);
      },
      clearTimeout: callbackId => {
        this.win.clearTimeout(this.timeoutIds.get(callbackId));
        this.timeoutIds.delete(callbackId);
      },
      setInterval: (callbackId, nMilliseconds) => {
        if (typeof callbackId !== "number" || typeof nMilliseconds !== "number") {
          return;
        }
        const id = this.win.setInterval(() => {
          this.callSandboxFunction("timeoutCb", {
            callbackId,
            interval: true
          });
        }, nMilliseconds);
        this.timeoutIds.set(callbackId, id);
      },
      clearInterval: callbackId => {
        this.win.clearInterval(this.timeoutIds.get(callbackId));
        this.timeoutIds.delete(callbackId);
      },
      alert: cMsg => {
        if (typeof cMsg !== "string") {
          return;
        }
        this.win.alert(cMsg);
      },
      confirm: cMsg => {
        if (typeof cMsg !== "string") {
          return false;
        }
        return this.win.confirm(cMsg);
      },
      prompt: (cQuestion, cDefault) => {
        if (typeof cQuestion !== "string" || typeof cDefault !== "string") {
          return null;
        }
        return this.win.prompt(cQuestion, cDefault);
      },
      parseURL: cUrl => {
        const url = new this.win.URL(cUrl);
        const props = ["hash", "host", "hostname", "href", "origin", "password", "pathname", "port", "protocol", "search", "searchParams", "username"];
        return Object.fromEntries(props.map(name => [name, url[name].toString()]));
      },
      send: data => {
        if (!data) {
          return;
        }
        const event = new this.win.CustomEvent("updatefromsandbox", {
          detail: this.importValueFromSandbox(data)
        });
        this.win.dispatchEvent(event);
      }
    };
    Object.setPrototypeOf(externals, null);
    return (name, args) => {
      try {
        const result = externals[name](...args);
        return this.exportValueToSandbox(result);
      } catch (error) {
        throw this.createErrorForSandbox(error?.toString() ?? "");
      }
    };
  }
}
;// CONCATENATED MODULE: ./src/pdf.sandbox.js


const pdfjsVersion = '4.0.379';
const pdfjsBuild = '9e14d04fd';
class SandboxSupport extends SandboxSupportBase {
  exportValueToSandbox(val) {
    return JSON.stringify(val);
  }
  importValueFromSandbox(val) {
    return val;
  }
  createErrorForSandbox(errorMessage) {
    return new Error(errorMessage);
  }
}
class Sandbox {
  constructor(win, module) {
    this.support = new SandboxSupport(win, this);
    module.externalCall = this.support.createSandboxExternals();
    this._module = module;
    this._alertOnError = 0;
  }
  create(data) {
    const code = ['var __webpack_exports__ = globalThis.pdfjsSandbox = {};\n\n;// CONCATENATED MODULE: ./src/scripting_api/constants.js\nconst Border = Object.freeze({\n  s: "solid",\n  d: "dashed",\n  b: "beveled",\n  i: "inset",\n  u: "underline"\n});\nconst Cursor = Object.freeze({\n  visible: 0,\n  hidden: 1,\n  delay: 2\n});\nconst Display = Object.freeze({\n  visible: 0,\n  hidden: 1,\n  noPrint: 2,\n  noView: 3\n});\nconst Font = Object.freeze({\n  Times: "Times-Roman",\n  TimesB: "Times-Bold",\n  TimesI: "Times-Italic",\n  TimesBI: "Times-BoldItalic",\n  Helv: "Helvetica",\n  HelvB: "Helvetica-Bold",\n  HelvI: "Helvetica-Oblique",\n  HelvBI: "Helvetica-BoldOblique",\n  Cour: "Courier",\n  CourB: "Courier-Bold",\n  CourI: "Courier-Oblique",\n  CourBI: "Courier-BoldOblique",\n  Symbol: "Symbol",\n  ZapfD: "ZapfDingbats",\n  KaGo: "HeiseiKakuGo-W5-UniJIS-UCS2-H",\n  KaMi: "HeiseiMin-W3-UniJIS-UCS2-H"\n});\nconst Highlight = Object.freeze({\n  n: "none",\n  i: "invert",\n  p: "push",\n  o: "outline"\n});\nconst Position = Object.freeze({\n  textOnly: 0,\n  iconOnly: 1,\n  iconTextV: 2,\n  textIconV: 3,\n  iconTextH: 4,\n  textIconH: 5,\n  overlay: 6\n});\nconst ScaleHow = Object.freeze({\n  proportional: 0,\n  anamorphic: 1\n});\nconst ScaleWhen = Object.freeze({\n  always: 0,\n  never: 1,\n  tooBig: 2,\n  tooSmall: 3\n});\nconst Style = Object.freeze({\n  ch: "check",\n  cr: "cross",\n  di: "diamond",\n  ci: "circle",\n  st: "star",\n  sq: "square"\n});\nconst Trans = Object.freeze({\n  blindsH: "BlindsHorizontal",\n  blindsV: "BlindsVertical",\n  boxI: "BoxIn",\n  boxO: "BoxOut",\n  dissolve: "Dissolve",\n  glitterD: "GlitterDown",\n  glitterR: "GlitterRight",\n  glitterRD: "GlitterRightDown",\n  random: "Random",\n  replace: "Replace",\n  splitHI: "SplitHorizontalIn",\n  splitHO: "SplitHorizontalOut",\n  splitVI: "SplitVerticalIn",\n  splitVO: "SplitVerticalOut",\n  wipeD: "WipeDown",\n  wipeL: "WipeLeft",\n  wipeR: "WipeRight",\n  wipeU: "WipeUp"\n});\nconst ZoomType = Object.freeze({\n  none: "NoVary",\n  fitP: "FitPage",\n  fitW: "FitWidth",\n  fitH: "FitHeight",\n  fitV: "FitVisibleWidth",\n  pref: "Preferred",\n  refW: "ReflowWidth"\n});\nconst GlobalConstants = Object.freeze({\n  IDS_GREATER_THAN: "Invalid value: must be greater than or equal to % s.",\n  IDS_GT_AND_LT: "Invalid value: must be greater than or equal to % s " + "and less than or equal to % s.",\n  IDS_LESS_THAN: "Invalid value: must be less than or equal to % s.",\n  IDS_INVALID_MONTH: "** Invalid **",\n  IDS_INVALID_DATE: "Invalid date / time: please ensure that the date / time exists.Field",\n  IDS_INVALID_DATE2: " should match format ",\n  IDS_INVALID_VALUE: "The value entered does not match the format of the field",\n  IDS_AM: "am",\n  IDS_PM: "pm",\n  IDS_MONTH_INFO: "January[1] February[2] March[3] April[4] May[5] " + "June[6] July[7] August[8] September[9] October[10] " + "November[11] December[12] Sept[9] Jan[1] Feb[2] Mar[3] " + "Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov[11] Dec[12]",\n  IDS_STARTUP_CONSOLE_MSG: "** ^ _ ^ **",\n  RE_NUMBER_ENTRY_DOT_SEP: ["[+-]?\\\\d*\\\\.?\\\\d*"],\n  RE_NUMBER_COMMIT_DOT_SEP: ["[+-]?\\\\d+(\\\\.\\\\d+)?", "[+-]?\\\\.\\\\d+", "[+-]?\\\\d+\\\\."],\n  RE_NUMBER_ENTRY_COMMA_SEP: ["[+-]?\\\\d*,?\\\\d*"],\n  RE_NUMBER_COMMIT_COMMA_SEP: ["[+-]?\\\\d+([.,]\\\\d+)?", "[+-]?[.,]\\\\d+", "[+-]?\\\\d+[.,]"],\n  RE_ZIP_ENTRY: ["\\\\d{0,5}"],\n  RE_ZIP_COMMIT: ["\\\\d{5}"],\n  RE_ZIP4_ENTRY: ["\\\\d{0,5}(\\\\.|[- ])?\\\\d{0,4}"],\n  RE_ZIP4_COMMIT: ["\\\\d{5}(\\\\.|[- ])?\\\\d{4}"],\n  RE_PHONE_ENTRY: ["\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,4}", "\\\\(\\\\d{0,3}", "\\\\(\\\\d{0,3}\\\\)(\\\\.|[- ])?\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,4}", "\\\\(\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,4}", "\\\\d{0,3}\\\\)(\\\\.|[- ])?\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,4}", "011(\\\\.|[- \\\\d])*"],\n  RE_PHONE_COMMIT: ["\\\\d{3}(\\\\.|[- ])?\\\\d{4}", "\\\\d{3}(\\\\.|[- ])?\\\\d{3}(\\\\.|[- ])?\\\\d{4}", "\\\\(\\\\d{3}\\\\)(\\\\.|[- ])?\\\\d{3}(\\\\.|[- ])?\\\\d{4}", "011(\\\\.|[- \\\\d])*"],\n  RE_SSN_ENTRY: ["\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,2}(\\\\.|[- ])?\\\\d{0,4}"],\n  RE_SSN_COMMIT: ["\\\\d{3}(\\\\.|[- ])?\\\\d{2}(\\\\.|[- ])?\\\\d{4}"]\n});\n\n;// CONCATENATED MODULE: ./src/scripting_api/common.js\nconst FieldType = {\n  none: 0,\n  number: 1,\n  percent: 2,\n  date: 3,\n  time: 4\n};\nfunction createActionsMap(actions) {\n  const actionsMap = new Map();\n  if (actions) {\n    for (const [eventType, actionsForEvent] of Object.entries(actions)) {\n      actionsMap.set(eventType, actionsForEvent);\n    }\n  }\n  return actionsMap;\n}\nfunction getFieldType(actions) {\n  let format = actions.get("Format");\n  if (!format) {\n    return FieldType.none;\n  }\n  format = format[0];\n  format = format.trim();\n  if (format.startsWith("AFNumber_")) {\n    return FieldType.number;\n  }\n  if (format.startsWith("AFPercent_")) {\n    return FieldType.percent;\n  }\n  if (format.startsWith("AFDate_")) {\n    return FieldType.date;\n  }\n  if (format.startsWith("AFTime_")) {\n    return FieldType.time;\n  }\n  return FieldType.none;\n}\n\n;// CONCATENATED MODULE: ./src/shared/scripting_utils.js\nfunction makeColorComp(n) {\n  return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");\n}\nfunction scaleAndClamp(x) {\n  return Math.max(0, Math.min(255, 255 * x));\n}\nclass ColorConverters {\n  static CMYK_G([c, y, m, k]) {\n    return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];\n  }\n  static G_CMYK([g]) {\n    return ["CMYK", 0, 0, 0, 1 - g];\n  }\n  static G_RGB([g]) {\n    return ["RGB", g, g, g];\n  }\n  static G_rgb([g]) {\n    g = scaleAndClamp(g);\n    return [g, g, g];\n  }\n  static G_HTML([g]) {\n    const G = makeColorComp(g);\n    return `#${G}${G}${G}`;\n  }\n  static RGB_G([r, g, b]) {\n    return ["G", 0.3 * r + 0.59 * g + 0.11 * b];\n  }\n  static RGB_rgb(color) {\n    return color.map(scaleAndClamp);\n  }\n  static RGB_HTML(color) {\n    return `#${color.map(makeColorComp).join("")}`;\n  }\n  static T_HTML() {\n    return "#00000000";\n  }\n  static T_rgb() {\n    return [null];\n  }\n  static CMYK_RGB([c, y, m, k]) {\n    return ["RGB", 1 - Math.min(1, c + k), 1 - Math.min(1, m + k), 1 - Math.min(1, y + k)];\n  }\n  static CMYK_rgb([c, y, m, k]) {\n    return [scaleAndClamp(1 - Math.min(1, c + k)), scaleAndClamp(1 - Math.min(1, m + k)), scaleAndClamp(1 - Math.min(1, y + k))];\n  }\n  static CMYK_HTML(components) {\n    const rgb = this.CMYK_RGB(components).slice(1);\n    return this.RGB_HTML(rgb);\n  }\n  static RGB_CMYK([r, g, b]) {\n    const c = 1 - r;\n    const m = 1 - g;\n    const y = 1 - b;\n    const k = Math.min(c, m, y);\n    return ["CMYK", c, m, y, k];\n  }\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/pdf_object.js\nclass PDFObject {\n  constructor(data) {\n    this._expandos = Object.create(null);\n    this._send = data.send || null;\n    this._id = data.id || null;\n  }\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/color.js\n\n\nclass Color extends PDFObject {\n  constructor() {\n    super({});\n    this.transparent = ["T"];\n    this.black = ["G", 0];\n    this.white = ["G", 1];\n    this.red = ["RGB", 1, 0, 0];\n    this.green = ["RGB", 0, 1, 0];\n    this.blue = ["RGB", 0, 0, 1];\n    this.cyan = ["CMYK", 1, 0, 0, 0];\n    this.magenta = ["CMYK", 0, 1, 0, 0];\n    this.yellow = ["CMYK", 0, 0, 1, 0];\n    this.dkGray = ["G", 0.25];\n    this.gray = ["G", 0.5];\n    this.ltGray = ["G", 0.75];\n  }\n  static _isValidSpace(cColorSpace) {\n    return typeof cColorSpace === "string" && (cColorSpace === "T" || cColorSpace === "G" || cColorSpace === "RGB" || cColorSpace === "CMYK");\n  }\n  static _isValidColor(colorArray) {\n    if (!Array.isArray(colorArray) || colorArray.length === 0) {\n      return false;\n    }\n    const space = colorArray[0];\n    if (!Color._isValidSpace(space)) {\n      return false;\n    }\n    switch (space) {\n      case "T":\n        if (colorArray.length !== 1) {\n          return false;\n        }\n        break;\n      case "G":\n        if (colorArray.length !== 2) {\n          return false;\n        }\n        break;\n      case "RGB":\n        if (colorArray.length !== 4) {\n          return false;\n        }\n        break;\n      case "CMYK":\n        if (colorArray.length !== 5) {\n          return false;\n        }\n        break;\n      default:\n        return false;\n    }\n    return colorArray.slice(1).every(c => typeof c === "number" && c >= 0 && c <= 1);\n  }\n  static _getCorrectColor(colorArray) {\n    return Color._isValidColor(colorArray) ? colorArray : ["G", 0];\n  }\n  convert(colorArray, cColorSpace) {\n    if (!Color._isValidSpace(cColorSpace)) {\n      return this.black;\n    }\n    if (cColorSpace === "T") {\n      return ["T"];\n    }\n    colorArray = Color._getCorrectColor(colorArray);\n    if (colorArray[0] === cColorSpace) {\n      return colorArray;\n    }\n    if (colorArray[0] === "T") {\n      return this.convert(this.black, cColorSpace);\n    }\n    return ColorConverters[`${colorArray[0]}_${cColorSpace}`](colorArray.slice(1));\n  }\n  equal(colorArray1, colorArray2) {\n    colorArray1 = Color._getCorrectColor(colorArray1);\n    colorArray2 = Color._getCorrectColor(colorArray2);\n    if (colorArray1[0] === "T" || colorArray2[0] === "T") {\n      return colorArray1[0] === "T" && colorArray2[0] === "T";\n    }\n    if (colorArray1[0] !== colorArray2[0]) {\n      colorArray2 = this.convert(colorArray2, colorArray1[0]);\n    }\n    return colorArray1.slice(1).every((c, i) => c === colorArray2[i + 1]);\n  }\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/field.js\n\n\n\nclass Field extends PDFObject {\n  constructor(data) {\n    super(data);\n    this.alignment = data.alignment || "left";\n    this.borderStyle = data.borderStyle || "";\n    this.buttonAlignX = data.buttonAlignX || 50;\n    this.buttonAlignY = data.buttonAlignY || 50;\n    this.buttonFitBounds = data.buttonFitBounds;\n    this.buttonPosition = data.buttonPosition;\n    this.buttonScaleHow = data.buttonScaleHow;\n    this.ButtonScaleWhen = data.buttonScaleWhen;\n    this.calcOrderIndex = data.calcOrderIndex;\n    this.comb = data.comb;\n    this.commitOnSelChange = data.commitOnSelChange;\n    this.currentValueIndices = data.currentValueIndices;\n    this.defaultStyle = data.defaultStyle;\n    this.defaultValue = data.defaultValue;\n    this.doNotScroll = data.doNotScroll;\n    this.doNotSpellCheck = data.doNotSpellCheck;\n    this.delay = data.delay;\n    this.display = data.display;\n    this.doc = data.doc.wrapped;\n    this.editable = data.editable;\n    this.exportValues = data.exportValues;\n    this.fileSelect = data.fileSelect;\n    this.hidden = data.hidden;\n    this.highlight = data.highlight;\n    this.lineWidth = data.lineWidth;\n    this.multiline = data.multiline;\n    this.multipleSelection = !!data.multipleSelection;\n    this.name = data.name;\n    this.password = data.password;\n    this.print = data.print;\n    this.radiosInUnison = data.radiosInUnison;\n    this.readonly = data.readonly;\n    this.rect = data.rect;\n    this.required = data.required;\n    this.richText = data.richText;\n    this.richValue = data.richValue;\n    this.style = data.style;\n    this.submitName = data.submitName;\n    this.textFont = data.textFont;\n    this.textSize = data.textSize;\n    this.type = data.type;\n    this.userName = data.userName;\n    this._actions = createActionsMap(data.actions);\n    this._browseForFileToSubmit = data.browseForFileToSubmit || null;\n    this._buttonCaption = null;\n    this._buttonIcon = null;\n    this._charLimit = data.charLimit;\n    this._children = null;\n    this._currentValueIndices = data.currentValueIndices || 0;\n    this._document = data.doc;\n    this._fieldPath = data.fieldPath;\n    this._fillColor = data.fillColor || ["T"];\n    this._isChoice = Array.isArray(data.items);\n    this._items = data.items || [];\n    this._hasValue = data.hasOwnProperty("value");\n    this._page = data.page || 0;\n    this._strokeColor = data.strokeColor || ["G", 0];\n    this._textColor = data.textColor || ["G", 0];\n    this._value = null;\n    this._kidIds = data.kidIds || null;\n    this._fieldType = getFieldType(this._actions);\n    this._siblings = data.siblings || null;\n    this._rotation = data.rotation || 0;\n    this._globalEval = data.globalEval;\n    this._appObjects = data.appObjects;\n    this.value = data.value || "";\n  }\n  get currentValueIndices() {\n    if (!this._isChoice) {\n      return 0;\n    }\n    return this._currentValueIndices;\n  }\n  set currentValueIndices(indices) {\n    if (!this._isChoice) {\n      return;\n    }\n    if (!Array.isArray(indices)) {\n      indices = [indices];\n    }\n    if (!indices.every(i => typeof i === "number" && Number.isInteger(i) && i >= 0 && i < this.numItems)) {\n      return;\n    }\n    indices.sort();\n    if (this.multipleSelection) {\n      this._currentValueIndices = indices;\n      this._value = [];\n      indices.forEach(i => {\n        this._value.push(this._items[i].displayValue);\n      });\n    } else if (indices.length > 0) {\n      indices = indices.splice(1, indices.length - 1);\n      this._currentValueIndices = indices[0];\n      this._value = this._items[this._currentValueIndices];\n    }\n    this._send({\n      id: this._id,\n      indices\n    });\n  }\n  get fillColor() {\n    return this._fillColor;\n  }\n  set fillColor(color) {\n    if (Color._isValidColor(color)) {\n      this._fillColor = color;\n    }\n  }\n  get bgColor() {\n    return this.fillColor;\n  }\n  set bgColor(color) {\n    this.fillColor = color;\n  }\n  get charLimit() {\n    return this._charLimit;\n  }\n  set charLimit(limit) {\n    if (typeof limit !== "number") {\n      throw new Error("Invalid argument value");\n    }\n    this._charLimit = Math.max(0, Math.floor(limit));\n  }\n  get numItems() {\n    if (!this._isChoice) {\n      throw new Error("Not a choice widget");\n    }\n    return this._items.length;\n  }\n  set numItems(_) {\n    throw new Error("field.numItems is read-only");\n  }\n  get strokeColor() {\n    return this._strokeColor;\n  }\n  set strokeColor(color) {\n    if (Color._isValidColor(color)) {\n      this._strokeColor = color;\n    }\n  }\n  get borderColor() {\n    return this.strokeColor;\n  }\n  set borderColor(color) {\n    this.strokeColor = color;\n  }\n  get page() {\n    return this._page;\n  }\n  set page(_) {\n    throw new Error("field.page is read-only");\n  }\n  get rotation() {\n    return this._rotation;\n  }\n  set rotation(angle) {\n    angle = Math.floor(angle);\n    if (angle % 90 !== 0) {\n      throw new Error("Invalid rotation: must be a multiple of 90");\n    }\n    angle %= 360;\n    if (angle < 0) {\n      angle += 360;\n    }\n    this._rotation = angle;\n  }\n  get textColor() {\n    return this._textColor;\n  }\n  set textColor(color) {\n    if (Color._isValidColor(color)) {\n      this._textColor = color;\n    }\n  }\n  get fgColor() {\n    return this.textColor;\n  }\n  set fgColor(color) {\n    this.textColor = color;\n  }\n  get value() {\n    return this._value;\n  }\n  set value(value) {\n    if (this._isChoice) {\n      this._setChoiceValue(value);\n      return;\n    }\n    if (value === "" || typeof value !== "string" || this._fieldType >= FieldType.date) {\n      this._originalValue = undefined;\n      this._value = value;\n      return;\n    }\n    this._originalValue = value;\n    const _value = value.trim().replace(",", ".");\n    this._value = !isNaN(_value) ? parseFloat(_value) : value;\n  }\n  _getValue() {\n    return this._originalValue ?? this.value;\n  }\n  _setChoiceValue(value) {\n    if (this.multipleSelection) {\n      if (!Array.isArray(value)) {\n        value = [value];\n      }\n      const values = new Set(value);\n      if (Array.isArray(this._currentValueIndices)) {\n        this._currentValueIndices.length = 0;\n        this._value.length = 0;\n      } else {\n        this._currentValueIndices = [];\n        this._value = [];\n      }\n      this._items.forEach((item, i) => {\n        if (values.has(item.exportValue)) {\n          this._currentValueIndices.push(i);\n          this._value.push(item.exportValue);\n        }\n      });\n    } else {\n      if (Array.isArray(value)) {\n        value = value[0];\n      }\n      const index = this._items.findIndex(({\n        exportValue\n      }) => value === exportValue);\n      if (index !== -1) {\n        this._currentValueIndices = index;\n        this._value = this._items[index].exportValue;\n      }\n    }\n  }\n  get valueAsString() {\n    return (this._value ?? "").toString();\n  }\n  set valueAsString(_) {}\n  browseForFileToSubmit() {\n    if (this._browseForFileToSubmit) {\n      this._browseForFileToSubmit();\n    }\n  }\n  buttonGetCaption(nFace = 0) {\n    if (this._buttonCaption) {\n      return this._buttonCaption[nFace];\n    }\n    return "";\n  }\n  buttonGetIcon(nFace = 0) {\n    if (this._buttonIcon) {\n      return this._buttonIcon[nFace];\n    }\n    return null;\n  }\n  buttonImportIcon(cPath = null, nPave = 0) {}\n  buttonSetCaption(cCaption, nFace = 0) {\n    if (!this._buttonCaption) {\n      this._buttonCaption = ["", "", ""];\n    }\n    this._buttonCaption[nFace] = cCaption;\n  }\n  buttonSetIcon(oIcon, nFace = 0) {\n    if (!this._buttonIcon) {\n      this._buttonIcon = [null, null, null];\n    }\n    this._buttonIcon[nFace] = oIcon;\n  }\n  checkThisBox(nWidget, bCheckIt = true) {}\n  clearItems() {\n    if (!this._isChoice) {\n      throw new Error("Not a choice widget");\n    }\n    this._items = [];\n    this._send({\n      id: this._id,\n      clear: null\n    });\n  }\n  deleteItemAt(nIdx = null) {\n    if (!this._isChoice) {\n      throw new Error("Not a choice widget");\n    }\n    if (!this.numItems) {\n      return;\n    }\n    if (nIdx === null) {\n      nIdx = Array.isArray(this._currentValueIndices) ? this._currentValueIndices[0] : this._currentValueIndices;\n      nIdx ||= 0;\n    }\n    if (nIdx < 0 || nIdx >= this.numItems) {\n      nIdx = this.numItems - 1;\n    }\n    this._items.splice(nIdx, 1);\n    if (Array.isArray(this._currentValueIndices)) {\n      let index = this._currentValueIndices.findIndex(i => i >= nIdx);\n      if (index !== -1) {\n        if (this._currentValueIndices[index] === nIdx) {\n          this._currentValueIndices.splice(index, 1);\n        }\n        for (const ii = this._currentValueIndices.length; index < ii; index++) {\n          --this._currentValueIndices[index];\n        }\n      }\n    } else if (this._currentValueIndices === nIdx) {\n      this._currentValueIndices = this.numItems > 0 ? 0 : -1;\n    } else if (this._currentValueIndices > nIdx) {\n      --this._currentValueIndices;\n    }\n    this._send({\n      id: this._id,\n      remove: nIdx\n    });\n  }\n  getItemAt(nIdx = -1, bExportValue = false) {\n    if (!this._isChoice) {\n      throw new Error("Not a choice widget");\n    }\n    if (nIdx < 0 || nIdx >= this.numItems) {\n      nIdx = this.numItems - 1;\n    }\n    const item = this._items[nIdx];\n    return bExportValue ? item.exportValue : item.displayValue;\n  }\n  getArray() {\n    if (this._kidIds) {\n      const array = [];\n      const fillArrayWithKids = kidIds => {\n        for (const id of kidIds) {\n          const obj = this._appObjects[id];\n          if (!obj) {\n            continue;\n          }\n          if (obj.obj._hasValue) {\n            array.push(obj.wrapped);\n          }\n          if (obj.obj._kidIds) {\n            fillArrayWithKids(obj.obj._kidIds);\n          }\n        }\n      };\n      fillArrayWithKids(this._kidIds);\n      return array;\n    }\n    if (this._children === null) {\n      this._children = this._document.obj._getTerminalChildren(this._fieldPath);\n    }\n    return this._children;\n  }\n  getLock() {\n    return undefined;\n  }\n  isBoxChecked(nWidget) {\n    return false;\n  }\n  isDefaultChecked(nWidget) {\n    return false;\n  }\n  insertItemAt(cName, cExport = undefined, nIdx = 0) {\n    if (!this._isChoice) {\n      throw new Error("Not a choice widget");\n    }\n    if (!cName) {\n      return;\n    }\n    if (nIdx < 0 || nIdx > this.numItems) {\n      nIdx = this.numItems;\n    }\n    if (this._items.some(({\n      displayValue\n    }) => displayValue === cName)) {\n      return;\n    }\n    if (cExport === undefined) {\n      cExport = cName;\n    }\n    const data = {\n      displayValue: cName,\n      exportValue: cExport\n    };\n    this._items.splice(nIdx, 0, data);\n    if (Array.isArray(this._currentValueIndices)) {\n      let index = this._currentValueIndices.findIndex(i => i >= nIdx);\n      if (index !== -1) {\n        for (const ii = this._currentValueIndices.length; index < ii; index++) {\n          ++this._currentValueIndices[index];\n        }\n      }\n    } else if (this._currentValueIndices >= nIdx) {\n      ++this._currentValueIndices;\n    }\n    this._send({\n      id: this._id,\n      insert: {\n        index: nIdx,\n        ...data\n      }\n    });\n  }\n  setAction(cTrigger, cScript) {\n    if (typeof cTrigger !== "string" || typeof cScript !== "string") {\n      return;\n    }\n    if (!(cTrigger in this._actions)) {\n      this._actions[cTrigger] = [];\n    }\n    this._actions[cTrigger].push(cScript);\n  }\n  setFocus() {\n    this._send({\n      id: this._id,\n      focus: true\n    });\n  }\n  setItems(oArray) {\n    if (!this._isChoice) {\n      throw new Error("Not a choice widget");\n    }\n    this._items.length = 0;\n    for (const element of oArray) {\n      let displayValue, exportValue;\n      if (Array.isArray(element)) {\n        displayValue = element[0]?.toString() || "";\n        exportValue = element[1]?.toString() || "";\n      } else {\n        displayValue = exportValue = element?.toString() || "";\n      }\n      this._items.push({\n        displayValue,\n        exportValue\n      });\n    }\n    this._currentValueIndices = 0;\n    this._send({\n      id: this._id,\n      items: this._items\n    });\n  }\n  setLock() {}\n  signatureGetModifications() {}\n  signatureGetSeedValue() {}\n  signatureInfo() {}\n  signatureSetSeedValue() {}\n  signatureSign() {}\n  signatureValidate() {}\n  _isButton() {\n    return false;\n  }\n  _reset() {\n    this.value = this.defaultValue;\n  }\n  _runActions(event) {\n    const eventName = event.name;\n    if (!this._actions.has(eventName)) {\n      return false;\n    }\n    const actions = this._actions.get(eventName);\n    try {\n      for (const action of actions) {\n        this._globalEval(action);\n      }\n    } catch (error) {\n      event.rc = false;\n      throw error;\n    }\n    return true;\n  }\n}\nclass RadioButtonField extends Field {\n  constructor(otherButtons, data) {\n    super(data);\n    this.exportValues = [this.exportValues];\n    this._radioIds = [this._id];\n    this._radioActions = [this._actions];\n    for (const radioData of otherButtons) {\n      this.exportValues.push(radioData.exportValues);\n      this._radioIds.push(radioData.id);\n      this._radioActions.push(createActionsMap(radioData.actions));\n      if (this._value === radioData.exportValues) {\n        this._id = radioData.id;\n      }\n    }\n    this._hasBeenInitialized = true;\n    this._value = data.value || "";\n  }\n  get value() {\n    return this._value;\n  }\n  set value(value) {\n    if (!this._hasBeenInitialized) {\n      return;\n    }\n    if (value === null || value === undefined) {\n      this._value = "";\n    }\n    const i = this.exportValues.indexOf(value);\n    if (0 <= i && i < this._radioIds.length) {\n      this._id = this._radioIds[i];\n      this._value = value;\n    } else if (value === "Off" && this._radioIds.length === 2) {\n      const nextI = (1 + this._radioIds.indexOf(this._id)) % 2;\n      this._id = this._radioIds[nextI];\n      this._value = this.exportValues[nextI];\n    }\n  }\n  checkThisBox(nWidget, bCheckIt = true) {\n    if (nWidget < 0 || nWidget >= this._radioIds.length || !bCheckIt) {\n      return;\n    }\n    this._id = this._radioIds[nWidget];\n    this._value = this.exportValues[nWidget];\n    this._send({\n      id: this._id,\n      value: this._value\n    });\n  }\n  isBoxChecked(nWidget) {\n    return nWidget >= 0 && nWidget < this._radioIds.length && this._id === this._radioIds[nWidget];\n  }\n  isDefaultChecked(nWidget) {\n    return nWidget >= 0 && nWidget < this.exportValues.length && this.defaultValue === this.exportValues[nWidget];\n  }\n  _getExportValue(state) {\n    const i = this._radioIds.indexOf(this._id);\n    return this.exportValues[i];\n  }\n  _runActions(event) {\n    const i = this._radioIds.indexOf(this._id);\n    this._actions = this._radioActions[i];\n    return super._runActions(event);\n  }\n  _isButton() {\n    return true;\n  }\n}\nclass CheckboxField extends RadioButtonField {\n  get value() {\n    return this._value;\n  }\n  set value(value) {\n    if (!value || value === "Off") {\n      this._value = "Off";\n    } else {\n      super.value = value;\n    }\n  }\n  _getExportValue(state) {\n    return state ? super._getExportValue(state) : "Off";\n  }\n  isBoxChecked(nWidget) {\n    if (this._value === "Off") {\n      return false;\n    }\n    return super.isBoxChecked(nWidget);\n  }\n  isDefaultChecked(nWidget) {\n    if (this.defaultValue === "Off") {\n      return this._value === "Off";\n    }\n    return super.isDefaultChecked(nWidget);\n  }\n  checkThisBox(nWidget, bCheckIt = true) {\n    if (nWidget < 0 || nWidget >= this._radioIds.length) {\n      return;\n    }\n    this._id = this._radioIds[nWidget];\n    this._value = bCheckIt ? this.exportValues[nWidget] : "Off";\n    this._send({\n      id: this._id,\n      value: this._value\n    });\n  }\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/aform.js\n\nclass AForm {\n  constructor(document, app, util, color) {\n    this._document = document;\n    this._app = app;\n    this._util = util;\n    this._color = color;\n    this._dateFormats = ["m/d", "m/d/yy", "mm/dd/yy", "mm/yy", "d-mmm", "d-mmm-yy", "dd-mmm-yy", "yy-mm-dd", "mmm-yy", "mmmm-yy", "mmm d, yyyy", "mmmm d, yyyy", "m/d/yy h:MM tt", "m/d/yy HH:MM"];\n    this._timeFormats = ["HH:MM", "h:MM tt", "HH:MM:ss", "h:MM:ss tt"];\n    this._dateActionsCache = new Map();\n    this._emailRegex = new RegExp("^[a-zA-Z0-9.!#$%&\'*+\\\\/=?^_`{|}~-]+" + "@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?" + "(?:\\\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$");\n  }\n  _mkTargetName(event) {\n    return event.target ? `[ ${event.target.name} ]` : "";\n  }\n  _tryToGuessDate(cFormat, cDate) {\n    let actions = this._dateActionsCache.get(cFormat);\n    if (!actions) {\n      actions = [];\n      this._dateActionsCache.set(cFormat, actions);\n      cFormat.replaceAll(/(d+)|(m+)|(y+)|(H+)|(M+)|(s+)/g, function (match, d, m, y, H, M, s) {\n        if (d) {\n          actions.push((n, date) => {\n            if (n >= 1 && n <= 31) {\n              date.setDate(n);\n              return true;\n            }\n            return false;\n          });\n        } else if (m) {\n          actions.push((n, date) => {\n            if (n >= 1 && n <= 12) {\n              date.setMonth(n - 1);\n              return true;\n            }\n            return false;\n          });\n        } else if (y) {\n          actions.push((n, date) => {\n            if (n < 50) {\n              n += 2000;\n            } else if (n < 100) {\n              n += 1900;\n            }\n            date.setYear(n);\n            return true;\n          });\n        } else if (H) {\n          actions.push((n, date) => {\n            if (n >= 0 && n <= 23) {\n              date.setHours(n);\n              return true;\n            }\n            return false;\n          });\n        } else if (M) {\n          actions.push((n, date) => {\n            if (n >= 0 && n <= 59) {\n              date.setMinutes(n);\n              return true;\n            }\n            return false;\n          });\n        } else if (s) {\n          actions.push((n, date) => {\n            if (n >= 0 && n <= 59) {\n              date.setSeconds(n);\n              return true;\n            }\n            return false;\n          });\n        }\n        return "";\n      });\n    }\n    const number = /\\d+/g;\n    let i = 0;\n    let array;\n    const date = new Date();\n    while ((array = number.exec(cDate)) !== null) {\n      if (i < actions.length) {\n        if (!actions[i++](parseInt(array[0]), date)) {\n          return null;\n        }\n      } else {\n        break;\n      }\n    }\n    if (i === 0) {\n      return null;\n    }\n    return date;\n  }\n  _parseDate(cFormat, cDate) {\n    let date = null;\n    try {\n      date = this._util.scand(cFormat, cDate);\n    } catch {}\n    if (!date) {\n      date = Date.parse(cDate);\n      date = isNaN(date) ? this._tryToGuessDate(cFormat, cDate) : new Date(date);\n    }\n    return date;\n  }\n  AFMergeChange(event = globalThis.event) {\n    if (event.willCommit) {\n      return event.value.toString();\n    }\n    return this._app._eventDispatcher.mergeChange(event);\n  }\n  AFParseDateEx(cString, cOrder) {\n    return this._parseDate(cOrder, cString);\n  }\n  AFExtractNums(str) {\n    if (typeof str === "number") {\n      return [str];\n    }\n    if (!str || typeof str !== "string") {\n      return null;\n    }\n    const first = str.charAt(0);\n    if (first === "." || first === ",") {\n      str = `0${str}`;\n    }\n    const numbers = str.match(/(\\d+)/g);\n    if (numbers.length === 0) {\n      return null;\n    }\n    return numbers;\n  }\n  AFMakeNumber(str) {\n    if (typeof str === "number") {\n      return str;\n    }\n    if (typeof str !== "string") {\n      return null;\n    }\n    str = str.trim().replace(",", ".");\n    const number = parseFloat(str);\n    if (isNaN(number) || !isFinite(number)) {\n      return null;\n    }\n    return number;\n  }\n  AFMakeArrayFromList(string) {\n    if (typeof string === "string") {\n      return string.split(/, ?/g);\n    }\n    return string;\n  }\n  AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend) {\n    const event = globalThis.event;\n    if (!event.value) {\n      return;\n    }\n    let value = this.AFMakeNumber(event.value);\n    if (value === null) {\n      event.value = "";\n      return;\n    }\n    const sign = Math.sign(value);\n    const buf = [];\n    let hasParen = false;\n    if (sign === -1 && bCurrencyPrepend && negStyle === 0) {\n      buf.push("-");\n    }\n    if ((negStyle === 2 || negStyle === 3) && sign === -1) {\n      buf.push("(");\n      hasParen = true;\n    }\n    if (bCurrencyPrepend) {\n      buf.push(strCurrency);\n    }\n    sepStyle = Math.min(Math.max(0, Math.floor(sepStyle)), 4);\n    buf.push("%,", sepStyle, ".", nDec.toString(), "f");\n    if (!bCurrencyPrepend) {\n      buf.push(strCurrency);\n    }\n    if (hasParen) {\n      buf.push(")");\n    }\n    if (negStyle === 1 || negStyle === 3) {\n      event.target.textColor = sign === 1 ? this._color.black : this._color.red;\n    }\n    if ((negStyle !== 0 || bCurrencyPrepend) && sign === -1) {\n      value = -value;\n    }\n    const formatStr = buf.join("");\n    event.value = this._util.printf(formatStr, value);\n  }\n  AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, bCurrencyPrepend) {\n    const event = globalThis.event;\n    let value = this.AFMergeChange(event);\n    if (!value) {\n      return;\n    }\n    value = value.trim();\n    let pattern;\n    if (sepStyle > 1) {\n      pattern = event.willCommit ? /^[+-]?(\\d+(,\\d*)?|,\\d+)$/ : /^[+-]?\\d*,?\\d*$/;\n    } else {\n      pattern = event.willCommit ? /^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)$/ : /^[+-]?\\d*\\.?\\d*$/;\n    }\n    if (!pattern.test(value)) {\n      if (event.willCommit) {\n        const err = `${GlobalConstants.IDS_INVALID_VALUE} ${this._mkTargetName(event)}`;\n        this._app.alert(err);\n      }\n      event.rc = false;\n    }\n    if (event.willCommit && sepStyle > 1) {\n      event.value = parseFloat(value.replace(",", "."));\n    }\n  }\n  AFPercent_Format(nDec, sepStyle, percentPrepend = false) {\n    if (typeof nDec !== "number") {\n      return;\n    }\n    if (typeof sepStyle !== "number") {\n      return;\n    }\n    if (nDec < 0) {\n      throw new Error("Invalid nDec value in AFPercent_Format");\n    }\n    const event = globalThis.event;\n    if (nDec > 512) {\n      event.value = "%";\n      return;\n    }\n    nDec = Math.floor(nDec);\n    sepStyle = Math.min(Math.max(0, Math.floor(sepStyle)), 4);\n    let value = this.AFMakeNumber(event.value);\n    if (value === null) {\n      event.value = "%";\n      return;\n    }\n    const formatStr = `%,${sepStyle}.${nDec}f`;\n    value = this._util.printf(formatStr, value * 100);\n    event.value = percentPrepend ? `%${value}` : `${value}%`;\n  }\n  AFPercent_Keystroke(nDec, sepStyle) {\n    this.AFNumber_Keystroke(nDec, sepStyle, 0, 0, "", true);\n  }\n  AFDate_FormatEx(cFormat) {\n    const event = globalThis.event;\n    const value = event.value;\n    if (!value) {\n      return;\n    }\n    const date = this._parseDate(cFormat, value);\n    if (date !== null) {\n      event.value = this._util.printd(cFormat, date);\n    }\n  }\n  AFDate_Format(pdf) {\n    if (pdf >= 0 && pdf < this._dateFormats.length) {\n      this.AFDate_FormatEx(this._dateFormats[pdf]);\n    }\n  }\n  AFDate_KeystrokeEx(cFormat) {\n    const event = globalThis.event;\n    if (!event.willCommit) {\n      return;\n    }\n    const value = this.AFMergeChange(event);\n    if (!value) {\n      return;\n    }\n    if (this._parseDate(cFormat, value) === null) {\n      const invalid = GlobalConstants.IDS_INVALID_DATE;\n      const invalid2 = GlobalConstants.IDS_INVALID_DATE2;\n      const err = `${invalid} ${this._mkTargetName(event)}${invalid2}${cFormat}`;\n      this._app.alert(err);\n      event.rc = false;\n    }\n  }\n  AFDate_Keystroke(pdf) {\n    if (pdf >= 0 && pdf < this._dateFormats.length) {\n      this.AFDate_KeystrokeEx(this._dateFormats[pdf]);\n    }\n  }\n  AFRange_Validate(bGreaterThan, nGreaterThan, bLessThan, nLessThan) {\n    const event = globalThis.event;\n    if (!event.value) {\n      return;\n    }\n    const value = this.AFMakeNumber(event.value);\n    if (value === null) {\n      return;\n    }\n    bGreaterThan = !!bGreaterThan;\n    bLessThan = !!bLessThan;\n    if (bGreaterThan) {\n      nGreaterThan = this.AFMakeNumber(nGreaterThan);\n      if (nGreaterThan === null) {\n        return;\n      }\n    }\n    if (bLessThan) {\n      nLessThan = this.AFMakeNumber(nLessThan);\n      if (nLessThan === null) {\n        return;\n      }\n    }\n    let err = "";\n    if (bGreaterThan && bLessThan) {\n      if (value < nGreaterThan || value > nLessThan) {\n        err = this._util.printf(GlobalConstants.IDS_GT_AND_LT, nGreaterThan, nLessThan);\n      }\n    } else if (bGreaterThan) {\n      if (value < nGreaterThan) {\n        err = this._util.printf(GlobalConstants.IDS_GREATER_THAN, nGreaterThan);\n      }\n    } else if (value > nLessThan) {\n      err = this._util.printf(GlobalConstants.IDS_LESS_THAN, nLessThan);\n    }\n    if (err) {\n      this._app.alert(err);\n      event.rc = false;\n    }\n  }\n  AFSimple(cFunction, nValue1, nValue2) {\n    const value1 = this.AFMakeNumber(nValue1);\n    if (value1 === null) {\n      throw new Error("Invalid nValue1 in AFSimple");\n    }\n    const value2 = this.AFMakeNumber(nValue2);\n    if (value2 === null) {\n      throw new Error("Invalid nValue2 in AFSimple");\n    }\n    switch (cFunction) {\n      case "AVG":\n        return (value1 + value2) / 2;\n      case "SUM":\n        return value1 + value2;\n      case "PRD":\n        return value1 * value2;\n      case "MIN":\n        return Math.min(value1, value2);\n      case "MAX":\n        return Math.max(value1, value2);\n    }\n    throw new Error("Invalid cFunction in AFSimple");\n  }\n  AFSimple_Calculate(cFunction, cFields) {\n    const actions = {\n      AVG: args => args.reduce((acc, value) => acc + value, 0) / args.length,\n      SUM: args => args.reduce((acc, value) => acc + value, 0),\n      PRD: args => args.reduce((acc, value) => acc * value, 1),\n      MIN: args => args.reduce((acc, value) => Math.min(acc, value), Number.MAX_VALUE),\n      MAX: args => args.reduce((acc, value) => Math.max(acc, value), Number.MIN_VALUE)\n    };\n    if (!(cFunction in actions)) {\n      throw new TypeError("Invalid function in AFSimple_Calculate");\n    }\n    const event = globalThis.event;\n    const values = [];\n    cFields = this.AFMakeArrayFromList(cFields);\n    for (const cField of cFields) {\n      const field = this._document.getField(cField);\n      if (!field) {\n        continue;\n      }\n      for (const child of field.getArray()) {\n        const number = this.AFMakeNumber(child.value);\n        if (number !== null) {\n          values.push(number);\n        }\n      }\n    }\n    if (values.length === 0) {\n      event.value = cFunction === "PRD" ? 1 : 0;\n      return;\n    }\n    const res = actions[cFunction](values);\n    event.value = Math.round(1e6 * res) / 1e6;\n  }\n  AFSpecial_Format(psf) {\n    const event = globalThis.event;\n    if (!event.value) {\n      return;\n    }\n    psf = this.AFMakeNumber(psf);\n    let formatStr;\n    switch (psf) {\n      case 0:\n        formatStr = "99999";\n        break;\n      case 1:\n        formatStr = "99999-9999";\n        break;\n      case 2:\n        formatStr = this._util.printx("9999999999", event.value).length >= 10 ? "(999) 999-9999" : "999-9999";\n        break;\n      case 3:\n        formatStr = "999-99-9999";\n        break;\n      default:\n        throw new Error("Invalid psf in AFSpecial_Format");\n    }\n    event.value = this._util.printx(formatStr, event.value);\n  }\n  AFSpecial_KeystrokeEx(cMask) {\n    if (!cMask) {\n      return;\n    }\n    const event = globalThis.event;\n    const value = this.AFMergeChange(event);\n    if (!value) {\n      return;\n    }\n    const checkers = new Map([["9", char => char >= "0" && char <= "9"], ["A", char => "a" <= char && char <= "z" || "A" <= char && char <= "Z"], ["O", char => "a" <= char && char <= "z" || "A" <= char && char <= "Z" || "0" <= char && char <= "9"], ["X", char => true]]);\n    function _checkValidity(_value, _cMask) {\n      for (let i = 0, ii = _value.length; i < ii; i++) {\n        const mask = _cMask.charAt(i);\n        const char = _value.charAt(i);\n        const checker = checkers.get(mask);\n        if (checker) {\n          if (!checker(char)) {\n            return false;\n          }\n        } else if (mask !== char) {\n          return false;\n        }\n      }\n      return true;\n    }\n    const err = `${GlobalConstants.IDS_INVALID_VALUE} = "${cMask}"`;\n    if (value.length > cMask.length) {\n      this._app.alert(err);\n      event.rc = false;\n      return;\n    }\n    if (event.willCommit) {\n      if (value.length < cMask.length) {\n        this._app.alert(err);\n        event.rc = false;\n        return;\n      }\n      if (!_checkValidity(value, cMask)) {\n        this._app.alert(err);\n        event.rc = false;\n        return;\n      }\n      event.value += cMask.substring(value.length);\n      return;\n    }\n    if (value.length < cMask.length) {\n      cMask = cMask.substring(0, value.length);\n    }\n    if (!_checkValidity(value, cMask)) {\n      this._app.alert(err);\n      event.rc = false;\n    }\n  }\n  AFSpecial_Keystroke(psf) {\n    const event = globalThis.event;\n    psf = this.AFMakeNumber(psf);\n    let formatStr;\n    switch (psf) {\n      case 0:\n        formatStr = "99999";\n        break;\n      case 1:\n        formatStr = "99999-9999";\n        break;\n      case 2:\n        const value = this.AFMergeChange(event);\n        formatStr = value.length > 8 || value.startsWith("(") ? "(999) 999-9999" : "999-9999";\n        break;\n      case 3:\n        formatStr = "999-99-9999";\n        break;\n      default:\n        throw new Error("Invalid psf in AFSpecial_Keystroke");\n    }\n    this.AFSpecial_KeystrokeEx(formatStr);\n  }\n  AFTime_FormatEx(cFormat) {\n    this.AFDate_FormatEx(cFormat);\n  }\n  AFTime_Format(pdf) {\n    if (pdf >= 0 && pdf < this._timeFormats.length) {\n      this.AFDate_FormatEx(this._timeFormats[pdf]);\n    }\n  }\n  AFTime_KeystrokeEx(cFormat) {\n    this.AFDate_KeystrokeEx(cFormat);\n  }\n  AFTime_Keystroke(pdf) {\n    if (pdf >= 0 && pdf < this._timeFormats.length) {\n      this.AFDate_KeystrokeEx(this._timeFormats[pdf]);\n    }\n  }\n  eMailValidate(str) {\n    return this._emailRegex.test(str);\n  }\n  AFExactMatch(rePatterns, str) {\n    if (rePatterns instanceof RegExp) {\n      return str.match(rePatterns)?.[0] === str || 0;\n    }\n    return rePatterns.findIndex(re => str.match(re)?.[0] === str) + 1;\n  }\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/app_utils.js\nconst VIEWER_TYPE = "PDF.js";\nconst VIEWER_VARIATION = "Full";\nconst VIEWER_VERSION = 21.00720099;\nconst FORMS_VERSION = 21.00720099;\nconst USERACTIVATION_CALLBACKID = 0;\nconst USERACTIVATION_MAXTIME_VALIDITY = 5000;\nfunction serializeError(error) {\n  const value = `${error.toString()}\\n${error.stack}`;\n  return {\n    command: "error",\n    value\n  };\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/event.js\n\nclass Event {\n  constructor(data) {\n    this.change = data.change || "";\n    this.changeEx = data.changeEx || null;\n    this.commitKey = data.commitKey || 0;\n    this.fieldFull = data.fieldFull || false;\n    this.keyDown = data.keyDown || false;\n    this.modifier = data.modifier || false;\n    this.name = data.name;\n    this.rc = true;\n    this.richChange = data.richChange || [];\n    this.richChangeEx = data.richChangeEx || [];\n    this.richValue = data.richValue || [];\n    this.selEnd = data.selEnd ?? -1;\n    this.selStart = data.selStart ?? -1;\n    this.shift = data.shift || false;\n    this.source = data.source || null;\n    this.target = data.target || null;\n    this.targetName = "";\n    this.type = "Field";\n    this.value = data.value || "";\n    this.willCommit = data.willCommit || false;\n  }\n}\nclass EventDispatcher {\n  constructor(document, calculationOrder, objects, externalCall) {\n    this._document = document;\n    this._calculationOrder = calculationOrder;\n    this._objects = objects;\n    this._externalCall = externalCall;\n    this._document.obj._eventDispatcher = this;\n    this._isCalculating = false;\n  }\n  mergeChange(event) {\n    let value = event.value;\n    if (Array.isArray(value)) {\n      return value;\n    }\n    if (typeof value !== "string") {\n      value = value.toString();\n    }\n    const prefix = event.selStart >= 0 ? value.substring(0, event.selStart) : "";\n    const postfix = event.selEnd >= 0 && event.selEnd <= value.length ? value.substring(event.selEnd) : "";\n    return `${prefix}${event.change}${postfix}`;\n  }\n  userActivation() {\n    this._document.obj._userActivation = true;\n    this._externalCall("setTimeout", [USERACTIVATION_CALLBACKID, USERACTIVATION_MAXTIME_VALIDITY]);\n  }\n  dispatch(baseEvent) {\n    const id = baseEvent.id;\n    if (!(id in this._objects)) {\n      let event;\n      if (id === "doc" || id === "page") {\n        event = globalThis.event = new Event(baseEvent);\n        event.source = event.target = this._document.wrapped;\n        event.name = baseEvent.name;\n      }\n      if (id === "doc") {\n        const eventName = event.name;\n        if (eventName === "Open") {\n          this.userActivation();\n          this._document.obj._initActions();\n          this.formatAll();\n        }\n        if (!["DidPrint", "DidSave", "WillPrint", "WillSave"].includes(eventName)) {\n          this.userActivation();\n        }\n        this._document.obj._dispatchDocEvent(event.name);\n      } else if (id === "page") {\n        this.userActivation();\n        this._document.obj._dispatchPageEvent(event.name, baseEvent.actions, baseEvent.pageNumber);\n      } else if (id === "app" && baseEvent.name === "ResetForm") {\n        this.userActivation();\n        for (const fieldId of baseEvent.ids) {\n          const obj = this._objects[fieldId];\n          obj?.obj._reset();\n        }\n      }\n      return;\n    }\n    const name = baseEvent.name;\n    const source = this._objects[id];\n    const event = globalThis.event = new Event(baseEvent);\n    let savedChange;\n    this.userActivation();\n    if (source.obj._isButton()) {\n      source.obj._id = id;\n      event.value = source.obj._getExportValue(event.value);\n      if (name === "Action") {\n        source.obj._value = event.value;\n      }\n    }\n    switch (name) {\n      case "Keystroke":\n        savedChange = {\n          value: event.value,\n          changeEx: event.changeEx,\n          change: event.change,\n          selStart: event.selStart,\n          selEnd: event.selEnd\n        };\n        break;\n      case "Blur":\n      case "Focus":\n        Object.defineProperty(event, "value", {\n          configurable: false,\n          writable: false,\n          enumerable: true,\n          value: event.value\n        });\n        break;\n      case "Validate":\n        this.runValidation(source, event);\n        return;\n      case "Action":\n        this.runActions(source, source, event, name);\n        this.runCalculate(source, event);\n        return;\n    }\n    this.runActions(source, source, event, name);\n    if (name !== "Keystroke") {\n      return;\n    }\n    if (event.rc) {\n      if (event.willCommit) {\n        this.runValidation(source, event);\n      } else {\n        if (source.obj._isChoice) {\n          source.obj.value = savedChange.changeEx;\n          source.obj._send({\n            id: source.obj._id,\n            siblings: source.obj._siblings,\n            value: source.obj.value\n          });\n          return;\n        }\n        const value = source.obj.value = this.mergeChange(event);\n        let selStart, selEnd;\n        if (event.selStart !== savedChange.selStart || event.selEnd !== savedChange.selEnd) {\n          selStart = event.selStart;\n          selEnd = event.selEnd;\n        } else {\n          selEnd = selStart = savedChange.selStart + event.change.length;\n        }\n        source.obj._send({\n          id: source.obj._id,\n          siblings: source.obj._siblings,\n          value,\n          selRange: [selStart, selEnd]\n        });\n      }\n    } else if (!event.willCommit) {\n      source.obj._send({\n        id: source.obj._id,\n        siblings: source.obj._siblings,\n        value: savedChange.value,\n        selRange: [savedChange.selStart, savedChange.selEnd]\n      });\n    } else {\n      source.obj._send({\n        id: source.obj._id,\n        siblings: source.obj._siblings,\n        value: "",\n        formattedValue: null,\n        selRange: [0, 0]\n      });\n    }\n  }\n  formatAll() {\n    const event = globalThis.event = new Event({});\n    for (const source of Object.values(this._objects)) {\n      event.value = source.obj.value;\n      this.runActions(source, source, event, "Format");\n    }\n  }\n  runValidation(source, event) {\n    const didValidateRun = this.runActions(source, source, event, "Validate");\n    if (event.rc) {\n      source.obj.value = event.value;\n      this.runCalculate(source, event);\n      const savedValue = source.obj._getValue();\n      event.value = source.obj.value;\n      let formattedValue = null;\n      if (this.runActions(source, source, event, "Format")) {\n        formattedValue = event.value?.toString?.();\n      }\n      source.obj._send({\n        id: source.obj._id,\n        siblings: source.obj._siblings,\n        value: savedValue,\n        formattedValue\n      });\n      event.value = savedValue;\n    } else if (didValidateRun) {\n      source.obj._send({\n        id: source.obj._id,\n        siblings: source.obj._siblings,\n        value: "",\n        formattedValue: null,\n        selRange: [0, 0],\n        focus: true\n      });\n    }\n  }\n  runActions(source, target, event, eventName) {\n    event.source = source.wrapped;\n    event.target = target.wrapped;\n    event.name = eventName;\n    event.targetName = target.obj.name;\n    event.rc = true;\n    return target.obj._runActions(event);\n  }\n  calculateNow() {\n    if (!this._calculationOrder || this._isCalculating || !this._document.obj.calculate) {\n      return;\n    }\n    this._isCalculating = true;\n    const first = this._calculationOrder[0];\n    const source = this._objects[first];\n    globalThis.event = new Event({});\n    try {\n      this.runCalculate(source, globalThis.event);\n    } catch (error) {\n      this._isCalculating = false;\n      throw error;\n    }\n    this._isCalculating = false;\n  }\n  runCalculate(source, event) {\n    if (!this._calculationOrder || !this._document.obj.calculate) {\n      return;\n    }\n    for (const targetId of this._calculationOrder) {\n      if (!(targetId in this._objects)) {\n        continue;\n      }\n      if (!this._document.obj.calculate) {\n        break;\n      }\n      event.value = null;\n      const target = this._objects[targetId];\n      let savedValue = target.obj.value;\n      this.runActions(source, target, event, "Calculate");\n      if (!event.rc) {\n        continue;\n      }\n      if (event.value !== null) {\n        target.obj.value = event.value;\n      }\n      event.value = target.obj.value;\n      this.runActions(target, target, event, "Validate");\n      if (!event.rc) {\n        if (target.obj.value !== savedValue) {\n          target.wrapped.value = savedValue;\n        }\n        continue;\n      }\n      savedValue = event.value = target.obj.value;\n      let formattedValue = null;\n      if (this.runActions(target, target, event, "Format")) {\n        formattedValue = event.value?.toString?.();\n      }\n      target.obj._send({\n        id: target.obj._id,\n        siblings: target.obj._siblings,\n        value: savedValue,\n        formattedValue\n      });\n    }\n  }\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/fullscreen.js\n\n\nclass FullScreen extends PDFObject {\n  constructor(data) {\n    super(data);\n    this._backgroundColor = [];\n    this._clickAdvances = true;\n    this._cursor = Cursor.hidden;\n    this._defaultTransition = "";\n    this._escapeExits = true;\n    this._isFullScreen = true;\n    this._loop = false;\n    this._timeDelay = 3600;\n    this._usePageTiming = false;\n    this._useTimer = false;\n  }\n  get backgroundColor() {\n    return this._backgroundColor;\n  }\n  set backgroundColor(_) {}\n  get clickAdvances() {\n    return this._clickAdvances;\n  }\n  set clickAdvances(_) {}\n  get cursor() {\n    return this._cursor;\n  }\n  set cursor(_) {}\n  get defaultTransition() {\n    return this._defaultTransition;\n  }\n  set defaultTransition(_) {}\n  get escapeExits() {\n    return this._escapeExits;\n  }\n  set escapeExits(_) {}\n  get isFullScreen() {\n    return this._isFullScreen;\n  }\n  set isFullScreen(_) {}\n  get loop() {\n    return this._loop;\n  }\n  set loop(_) {}\n  get timeDelay() {\n    return this._timeDelay;\n  }\n  set timeDelay(_) {}\n  get transitions() {\n    return ["Replace", "WipeRight", "WipeLeft", "WipeDown", "WipeUp", "SplitHorizontalIn", "SplitHorizontalOut", "SplitVerticalIn", "SplitVerticalOut", "BlindsHorizontal", "BlindsVertical", "BoxIn", "BoxOut", "GlitterRight", "GlitterDown", "GlitterRightDown", "Dissolve", "Random"];\n  }\n  set transitions(_) {\n    throw new Error("fullscreen.transitions is read-only");\n  }\n  get usePageTiming() {\n    return this._usePageTiming;\n  }\n  set usePageTiming(_) {}\n  get useTimer() {\n    return this._useTimer;\n  }\n  set useTimer(_) {}\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/thermometer.js\n\nclass Thermometer extends PDFObject {\n  constructor(data) {\n    super(data);\n    this._cancelled = false;\n    this._duration = 100;\n    this._text = "";\n    this._value = 0;\n  }\n  get cancelled() {\n    return this._cancelled;\n  }\n  set cancelled(_) {\n    throw new Error("thermometer.cancelled is read-only");\n  }\n  get duration() {\n    return this._duration;\n  }\n  set duration(val) {\n    this._duration = val;\n  }\n  get text() {\n    return this._text;\n  }\n  set text(val) {\n    this._text = val;\n  }\n  get value() {\n    return this._value;\n  }\n  set value(val) {\n    this._value = val;\n  }\n  begin() {}\n  end() {}\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/app.js\n\n\n\n\n\n\nclass App extends PDFObject {\n  constructor(data) {\n    super(data);\n    this._constants = null;\n    this._focusRect = true;\n    this._fs = null;\n    this._language = App._getLanguage(data.language);\n    this._openInPlace = false;\n    this._platform = App._getPlatform(data.platform);\n    this._runtimeHighlight = false;\n    this._runtimeHighlightColor = ["T"];\n    this._thermometer = null;\n    this._toolbar = false;\n    this._document = data._document;\n    this._proxyHandler = data.proxyHandler;\n    this._objects = Object.create(null);\n    this._eventDispatcher = new EventDispatcher(this._document, data.calculationOrder, this._objects, data.externalCall);\n    this._timeoutIds = new WeakMap();\n    if (typeof FinalizationRegistry !== "undefined") {\n      this._timeoutIdsRegistry = new FinalizationRegistry(this._cleanTimeout.bind(this));\n    } else {\n      this._timeoutIdsRegistry = null;\n    }\n    this._timeoutCallbackIds = new Map();\n    this._timeoutCallbackId = USERACTIVATION_CALLBACKID + 1;\n    this._globalEval = data.globalEval;\n    this._externalCall = data.externalCall;\n  }\n  _dispatchEvent(pdfEvent) {\n    this._eventDispatcher.dispatch(pdfEvent);\n  }\n  _registerTimeoutCallback(cExpr) {\n    const id = this._timeoutCallbackId++;\n    this._timeoutCallbackIds.set(id, cExpr);\n    return id;\n  }\n  _unregisterTimeoutCallback(id) {\n    this._timeoutCallbackIds.delete(id);\n  }\n  _evalCallback({\n    callbackId,\n    interval\n  }) {\n    if (callbackId === USERACTIVATION_CALLBACKID) {\n      this._document.obj._userActivation = false;\n      return;\n    }\n    const expr = this._timeoutCallbackIds.get(callbackId);\n    if (!interval) {\n      this._unregisterTimeoutCallback(callbackId);\n    }\n    if (expr) {\n      this._globalEval(expr);\n    }\n  }\n  _registerTimeout(callbackId, interval) {\n    const timeout = Object.create(null);\n    const id = {\n      callbackId,\n      interval\n    };\n    this._timeoutIds.set(timeout, id);\n    this._timeoutIdsRegistry?.register(timeout, id);\n    return timeout;\n  }\n  _unregisterTimeout(timeout) {\n    this._timeoutIdsRegistry?.unregister(timeout);\n    const data = this._timeoutIds.get(timeout);\n    if (!data) {\n      return;\n    }\n    this._timeoutIds.delete(timeout);\n    this._cleanTimeout(data);\n  }\n  _cleanTimeout({\n    callbackId,\n    interval\n  }) {\n    this._unregisterTimeoutCallback(callbackId);\n    if (interval) {\n      this._externalCall("clearInterval", [callbackId]);\n    } else {\n      this._externalCall("clearTimeout", [callbackId]);\n    }\n  }\n  static _getPlatform(platform) {\n    if (typeof platform === "string") {\n      platform = platform.toLowerCase();\n      if (platform.includes("win")) {\n        return "WIN";\n      } else if (platform.includes("mac")) {\n        return "MAC";\n      }\n    }\n    return "UNIX";\n  }\n  static _getLanguage(language) {\n    const [main, sub] = language.toLowerCase().split(/[-_]/);\n    switch (main) {\n      case "zh":\n        if (sub === "cn" || sub === "sg") {\n          return "CHS";\n        }\n        return "CHT";\n      case "da":\n        return "DAN";\n      case "de":\n        return "DEU";\n      case "es":\n        return "ESP";\n      case "fr":\n        return "FRA";\n      case "it":\n        return "ITA";\n      case "ko":\n        return "KOR";\n      case "ja":\n        return "JPN";\n      case "nl":\n        return "NLD";\n      case "no":\n        return "NOR";\n      case "pt":\n        if (sub === "br") {\n          return "PTB";\n        }\n        return "ENU";\n      case "fi":\n        return "SUO";\n      case "SV":\n        return "SVE";\n      default:\n        return "ENU";\n    }\n  }\n  get activeDocs() {\n    return [this._document.wrapped];\n  }\n  set activeDocs(_) {\n    throw new Error("app.activeDocs is read-only");\n  }\n  get calculate() {\n    return this._document.obj.calculate;\n  }\n  set calculate(calculate) {\n    this._document.obj.calculate = calculate;\n  }\n  get constants() {\n    if (!this._constants) {\n      this._constants = Object.freeze({\n        align: Object.freeze({\n          left: 0,\n          center: 1,\n          right: 2,\n          top: 3,\n          bottom: 4\n        })\n      });\n    }\n    return this._constants;\n  }\n  set constants(_) {\n    throw new Error("app.constants is read-only");\n  }\n  get focusRect() {\n    return this._focusRect;\n  }\n  set focusRect(val) {\n    this._focusRect = val;\n  }\n  get formsVersion() {\n    return FORMS_VERSION;\n  }\n  set formsVersion(_) {\n    throw new Error("app.formsVersion is read-only");\n  }\n  get fromPDFConverters() {\n    return [];\n  }\n  set fromPDFConverters(_) {\n    throw new Error("app.fromPDFConverters is read-only");\n  }\n  get fs() {\n    if (this._fs === null) {\n      this._fs = new Proxy(new FullScreen({\n        send: this._send\n      }), this._proxyHandler);\n    }\n    return this._fs;\n  }\n  set fs(_) {\n    throw new Error("app.fs is read-only");\n  }\n  get language() {\n    return this._language;\n  }\n  set language(_) {\n    throw new Error("app.language is read-only");\n  }\n  get media() {\n    return undefined;\n  }\n  set media(_) {\n    throw new Error("app.media is read-only");\n  }\n  get monitors() {\n    return [];\n  }\n  set monitors(_) {\n    throw new Error("app.monitors is read-only");\n  }\n  get numPlugins() {\n    return 0;\n  }\n  set numPlugins(_) {\n    throw new Error("app.numPlugins is read-only");\n  }\n  get openInPlace() {\n    return this._openInPlace;\n  }\n  set openInPlace(val) {\n    this._openInPlace = val;\n  }\n  get platform() {\n    return this._platform;\n  }\n  set platform(_) {\n    throw new Error("app.platform is read-only");\n  }\n  get plugins() {\n    return [];\n  }\n  set plugins(_) {\n    throw new Error("app.plugins is read-only");\n  }\n  get printColorProfiles() {\n    return [];\n  }\n  set printColorProfiles(_) {\n    throw new Error("app.printColorProfiles is read-only");\n  }\n  get printerNames() {\n    return [];\n  }\n  set printerNames(_) {\n    throw new Error("app.printerNames is read-only");\n  }\n  get runtimeHighlight() {\n    return this._runtimeHighlight;\n  }\n  set runtimeHighlight(val) {\n    this._runtimeHighlight = val;\n  }\n  get runtimeHighlightColor() {\n    return this._runtimeHighlightColor;\n  }\n  set runtimeHighlightColor(val) {\n    if (Color._isValidColor(val)) {\n      this._runtimeHighlightColor = val;\n    }\n  }\n  get thermometer() {\n    if (this._thermometer === null) {\n      this._thermometer = new Proxy(new Thermometer({\n        send: this._send\n      }), this._proxyHandler);\n    }\n    return this._thermometer;\n  }\n  set thermometer(_) {\n    throw new Error("app.thermometer is read-only");\n  }\n  get toolbar() {\n    return this._toolbar;\n  }\n  set toolbar(val) {\n    this._toolbar = val;\n  }\n  get toolbarHorizontal() {\n    return this.toolbar;\n  }\n  set toolbarHorizontal(value) {\n    this.toolbar = value;\n  }\n  get toolbarVertical() {\n    return this.toolbar;\n  }\n  set toolbarVertical(value) {\n    this.toolbar = value;\n  }\n  get viewerType() {\n    return VIEWER_TYPE;\n  }\n  set viewerType(_) {\n    throw new Error("app.viewerType is read-only");\n  }\n  get viewerVariation() {\n    return VIEWER_VARIATION;\n  }\n  set viewerVariation(_) {\n    throw new Error("app.viewerVariation is read-only");\n  }\n  get viewerVersion() {\n    return VIEWER_VERSION;\n  }\n  set viewerVersion(_) {\n    throw new Error("app.viewerVersion is read-only");\n  }\n  addMenuItem() {}\n  addSubMenu() {}\n  addToolButton() {}\n  alert(cMsg, nIcon = 0, nType = 0, cTitle = "PDF.js", oDoc = null, oCheckbox = null) {\n    if (!this._document.obj._userActivation) {\n      return 0;\n    }\n    this._document.obj._userActivation = false;\n    if (cMsg && typeof cMsg === "object") {\n      nType = cMsg.nType;\n      cMsg = cMsg.cMsg;\n    }\n    cMsg = (cMsg || "").toString();\n    nType = typeof nType !== "number" || isNaN(nType) || nType < 0 || nType > 3 ? 0 : nType;\n    if (nType >= 2) {\n      return this._externalCall("confirm", [cMsg]) ? 4 : 3;\n    }\n    this._externalCall("alert", [cMsg]);\n    return 1;\n  }\n  beep() {}\n  beginPriv() {}\n  browseForDoc() {}\n  clearInterval(oInterval) {\n    this._unregisterTimeout(oInterval);\n  }\n  clearTimeOut(oTime) {\n    this._unregisterTimeout(oTime);\n  }\n  endPriv() {}\n  execDialog() {}\n  execMenuItem(item) {\n    if (!this._document.obj._userActivation) {\n      return;\n    }\n    this._document.obj._userActivation = false;\n    switch (item) {\n      case "SaveAs":\n        if (this._document.obj._disableSaving) {\n          return;\n        }\n        this._send({\n          command: item\n        });\n        break;\n      case "FirstPage":\n      case "LastPage":\n      case "NextPage":\n      case "PrevPage":\n      case "ZoomViewIn":\n      case "ZoomViewOut":\n        this._send({\n          command: item\n        });\n        break;\n      case "FitPage":\n        this._send({\n          command: "zoom",\n          value: "page-fit"\n        });\n        break;\n      case "Print":\n        if (this._document.obj._disablePrinting) {\n          return;\n        }\n        this._send({\n          command: "print"\n        });\n        break;\n    }\n  }\n  getNthPlugInName() {}\n  getPath() {}\n  goBack() {}\n  goForward() {}\n  hideMenuItem() {}\n  hideToolbarButton() {}\n  launchURL() {}\n  listMenuItems() {}\n  listToolbarButtons() {}\n  loadPolicyFile() {}\n  mailGetAddrs() {}\n  mailMsg() {}\n  newDoc() {}\n  newCollection() {}\n  newFDF() {}\n  openDoc() {}\n  openFDF() {}\n  popUpMenu() {}\n  popUpMenuEx() {}\n  removeToolButton() {}\n  response(cQuestion, cTitle = "", cDefault = "", bPassword = "", cLabel = "") {\n    if (cQuestion && typeof cQuestion === "object") {\n      cDefault = cQuestion.cDefault;\n      cQuestion = cQuestion.cQuestion;\n    }\n    cQuestion = (cQuestion || "").toString();\n    cDefault = (cDefault || "").toString();\n    return this._externalCall("prompt", [cQuestion, cDefault || ""]);\n  }\n  setInterval(cExpr, nMilliseconds = 0) {\n    if (cExpr && typeof cExpr === "object") {\n      nMilliseconds = cExpr.nMilliseconds || 0;\n      cExpr = cExpr.cExpr;\n    }\n    if (typeof cExpr !== "string") {\n      throw new TypeError("First argument of app.setInterval must be a string");\n    }\n    if (typeof nMilliseconds !== "number") {\n      throw new TypeError("Second argument of app.setInterval must be a number");\n    }\n    const callbackId = this._registerTimeoutCallback(cExpr);\n    this._externalCall("setInterval", [callbackId, nMilliseconds]);\n    return this._registerTimeout(callbackId, true);\n  }\n  setTimeOut(cExpr, nMilliseconds = 0) {\n    if (cExpr && typeof cExpr === "object") {\n      nMilliseconds = cExpr.nMilliseconds || 0;\n      cExpr = cExpr.cExpr;\n    }\n    if (typeof cExpr !== "string") {\n      throw new TypeError("First argument of app.setTimeOut must be a string");\n    }\n    if (typeof nMilliseconds !== "number") {\n      throw new TypeError("Second argument of app.setTimeOut must be a number");\n    }\n    const callbackId = this._registerTimeoutCallback(cExpr);\n    this._externalCall("setTimeout", [callbackId, nMilliseconds]);\n    return this._registerTimeout(callbackId, false);\n  }\n  trustedFunction() {}\n  trustPropagatorFunction() {}\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/console.js\n\nclass Console extends PDFObject {\n  clear() {\n    this._send({\n      id: "clear"\n    });\n  }\n  hide() {}\n  println(msg) {\n    if (typeof msg === "string") {\n      this._send({\n        command: "println",\n        value: "PDF.js Console:: " + msg\n      });\n    }\n  }\n  show() {}\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/print_params.js\nclass PrintParams {\n  constructor(data) {\n    this.binaryOk = true;\n    this.bitmapDPI = 150;\n    this.booklet = {\n      binding: 0,\n      duplexMode: 0,\n      subsetFrom: 0,\n      subsetTo: -1\n    };\n    this.colorOverride = 0;\n    this.colorProfile = "";\n    this.constants = Object.freeze({\n      bookletBindings: Object.freeze({\n        Left: 0,\n        Right: 1,\n        LeftTall: 2,\n        RightTall: 3\n      }),\n      bookletDuplexMode: Object.freeze({\n        BothSides: 0,\n        FrontSideOnly: 1,\n        BasicSideOnly: 2\n      }),\n      colorOverrides: Object.freeze({\n        auto: 0,\n        gray: 1,\n        mono: 2\n      }),\n      fontPolicies: Object.freeze({\n        everyPage: 0,\n        jobStart: 1,\n        pageRange: 2\n      }),\n      handling: Object.freeze({\n        none: 0,\n        fit: 1,\n        shrink: 2,\n        tileAll: 3,\n        tileLarge: 4,\n        nUp: 5,\n        booklet: 6\n      }),\n      interactionLevel: Object.freeze({\n        automatic: 0,\n        full: 1,\n        silent: 2\n      }),\n      nUpPageOrders: Object.freeze({\n        Horizontal: 0,\n        HorizontalReversed: 1,\n        Vertical: 2\n      }),\n      printContents: Object.freeze({\n        doc: 0,\n        docAndComments: 1,\n        formFieldsOnly: 2\n      }),\n      flagValues: Object.freeze({\n        applyOverPrint: 1,\n        applySoftProofSettings: 1 << 1,\n        applyWorkingColorSpaces: 1 << 2,\n        emitHalftones: 1 << 3,\n        emitPostScriptXObjects: 1 << 4,\n        emitFormsAsPSForms: 1 << 5,\n        maxJP2KRes: 1 << 6,\n        setPageSize: 1 << 7,\n        suppressBG: 1 << 8,\n        suppressCenter: 1 << 9,\n        suppressCJKFontSubst: 1 << 10,\n        suppressCropClip: 1 << 1,\n        suppressRotate: 1 << 12,\n        suppressTransfer: 1 << 13,\n        suppressUCR: 1 << 14,\n        useTrapAnnots: 1 << 15,\n        usePrintersMarks: 1 << 16\n      }),\n      rasterFlagValues: Object.freeze({\n        textToOutline: 1,\n        strokesToOutline: 1 << 1,\n        allowComplexClip: 1 << 2,\n        preserveOverprint: 1 << 3\n      }),\n      subsets: Object.freeze({\n        all: 0,\n        even: 1,\n        odd: 2\n      }),\n      tileMarks: Object.freeze({\n        none: 0,\n        west: 1,\n        east: 2\n      }),\n      usages: Object.freeze({\n        auto: 0,\n        use: 1,\n        noUse: 2\n      })\n    });\n    this.downloadFarEastFonts = false;\n    this.fileName = "";\n    this.firstPage = 0;\n    this.flags = 0;\n    this.fontPolicy = 0;\n    this.gradientDPI = 150;\n    this.interactive = 1;\n    this.lastPage = data.lastPage;\n    this.npUpAutoRotate = false;\n    this.npUpNumPagesH = 2;\n    this.npUpNumPagesV = 2;\n    this.npUpPageBorder = false;\n    this.npUpPageOrder = 0;\n    this.pageHandling = 0;\n    this.pageSubset = 0;\n    this.printAsImage = false;\n    this.printContent = 0;\n    this.printerName = "";\n    this.psLevel = 0;\n    this.rasterFlags = 0;\n    this.reversePages = false;\n    this.tileLabel = false;\n    this.tileMark = 0;\n    this.tileOverlap = 0;\n    this.tileScale = 1.0;\n    this.transparencyLevel = 75;\n    this.usePrinterCRD = 0;\n    this.useT1Conversion = 0;\n  }\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/doc.js\n\n\n\n\n\nconst DOC_EXTERNAL = false;\nclass InfoProxyHandler {\n  static get(obj, prop) {\n    return obj[prop.toLowerCase()];\n  }\n  static set(obj, prop, value) {\n    throw new Error(`doc.info.${prop} is read-only`);\n  }\n}\nclass Doc extends PDFObject {\n  constructor(data) {\n    super(data);\n    this._expandos = globalThis;\n    this._baseURL = data.baseURL || "";\n    this._calculate = true;\n    this._delay = false;\n    this._dirty = false;\n    this._disclosed = false;\n    this._media = undefined;\n    this._metadata = data.metadata || "";\n    this._noautocomplete = undefined;\n    this._nocache = undefined;\n    this._spellDictionaryOrder = [];\n    this._spellLanguageOrder = [];\n    this._printParams = null;\n    this._fields = new Map();\n    this._fieldNames = [];\n    this._event = null;\n    this._author = data.Author || "";\n    this._creator = data.Creator || "";\n    this._creationDate = this._getDate(data.CreationDate) || null;\n    this._docID = data.docID || ["", ""];\n    this._documentFileName = data.filename || "";\n    this._filesize = data.filesize || 0;\n    this._keywords = data.Keywords || "";\n    this._layout = data.layout || "";\n    this._modDate = this._getDate(data.ModDate) || null;\n    this._numFields = 0;\n    this._numPages = data.numPages || 1;\n    this._pageNum = data.pageNum || 0;\n    this._producer = data.Producer || "";\n    this._securityHandler = data.EncryptFilterName || null;\n    this._subject = data.Subject || "";\n    this._title = data.Title || "";\n    this._URL = data.URL || "";\n    this._info = new Proxy({\n      title: this._title,\n      author: this._author,\n      authors: data.authors || [this._author],\n      subject: this._subject,\n      keywords: this._keywords,\n      creator: this._creator,\n      producer: this._producer,\n      creationdate: this._creationDate,\n      moddate: this._modDate,\n      trapped: data.Trapped || "Unknown"\n    }, InfoProxyHandler);\n    this._zoomType = ZoomType.none;\n    this._zoom = data.zoom || 100;\n    this._actions = createActionsMap(data.actions);\n    this._globalEval = data.globalEval;\n    this._pageActions = new Map();\n    this._userActivation = false;\n    this._disablePrinting = false;\n    this._disableSaving = false;\n  }\n  _initActions() {\n    const dontRun = new Set(["WillClose", "WillSave", "DidSave", "WillPrint", "DidPrint", "OpenAction"]);\n    this._disableSaving = true;\n    for (const actionName of this._actions.keys()) {\n      if (!dontRun.has(actionName)) {\n        this._runActions(actionName);\n      }\n    }\n    this._runActions("OpenAction");\n    this._disableSaving = false;\n  }\n  _dispatchDocEvent(name) {\n    switch (name) {\n      case "Open":\n        this._disableSaving = true;\n        this._runActions("OpenAction");\n        this._disableSaving = false;\n        break;\n      case "WillPrint":\n        this._disablePrinting = true;\n        try {\n          this._runActions(name);\n        } catch (error) {\n          this._send(serializeError(error));\n        }\n        this._send({\n          command: "WillPrintFinished"\n        });\n        this._disablePrinting = false;\n        break;\n      case "WillSave":\n        this._disableSaving = true;\n        this._runActions(name);\n        this._disableSaving = false;\n        break;\n      default:\n        this._runActions(name);\n    }\n  }\n  _dispatchPageEvent(name, actions, pageNumber) {\n    if (name === "PageOpen") {\n      if (!this._pageActions.has(pageNumber)) {\n        this._pageActions.set(pageNumber, createActionsMap(actions));\n      }\n      this._pageNum = pageNumber - 1;\n    }\n    actions = this._pageActions.get(pageNumber)?.get(name);\n    if (actions) {\n      for (const action of actions) {\n        this._globalEval(action);\n      }\n    }\n  }\n  _runActions(name) {\n    const actions = this._actions.get(name);\n    if (actions) {\n      for (const action of actions) {\n        this._globalEval(action);\n      }\n    }\n  }\n  _addField(name, field) {\n    this._fields.set(name, field);\n    this._fieldNames.push(name);\n    this._numFields++;\n  }\n  _getDate(date) {\n    if (!date || date.length < 15 || !date.startsWith("D:")) {\n      return date;\n    }\n    date = date.substring(2);\n    const year = date.substring(0, 4);\n    const month = date.substring(4, 6);\n    const day = date.substring(6, 8);\n    const hour = date.substring(8, 10);\n    const minute = date.substring(10, 12);\n    const o = date.charAt(12);\n    let second, offsetPos;\n    if (o === "Z" || o === "+" || o === "-") {\n      second = "00";\n      offsetPos = 12;\n    } else {\n      second = date.substring(12, 14);\n      offsetPos = 14;\n    }\n    const offset = date.substring(offsetPos).replaceAll("\'", "");\n    return new Date(`${year}-${month}-${day}T${hour}:${minute}:${second}${offset}`);\n  }\n  get author() {\n    return this._author;\n  }\n  set author(_) {\n    throw new Error("doc.author is read-only");\n  }\n  get baseURL() {\n    return this._baseURL;\n  }\n  set baseURL(baseURL) {\n    this._baseURL = baseURL;\n  }\n  get bookmarkRoot() {\n    return undefined;\n  }\n  set bookmarkRoot(_) {\n    throw new Error("doc.bookmarkRoot is read-only");\n  }\n  get calculate() {\n    return this._calculate;\n  }\n  set calculate(calculate) {\n    this._calculate = calculate;\n  }\n  get creator() {\n    return this._creator;\n  }\n  set creator(_) {\n    throw new Error("doc.creator is read-only");\n  }\n  get dataObjects() {\n    return [];\n  }\n  set dataObjects(_) {\n    throw new Error("doc.dataObjects is read-only");\n  }\n  get delay() {\n    return this._delay;\n  }\n  set delay(delay) {\n    this._delay = delay;\n  }\n  get dirty() {\n    return this._dirty;\n  }\n  set dirty(dirty) {\n    this._dirty = dirty;\n  }\n  get disclosed() {\n    return this._disclosed;\n  }\n  set disclosed(disclosed) {\n    this._disclosed = disclosed;\n  }\n  get docID() {\n    return this._docID;\n  }\n  set docID(_) {\n    throw new Error("doc.docID is read-only");\n  }\n  get documentFileName() {\n    return this._documentFileName;\n  }\n  set documentFileName(_) {\n    throw new Error("doc.documentFileName is read-only");\n  }\n  get dynamicXFAForm() {\n    return false;\n  }\n  set dynamicXFAForm(_) {\n    throw new Error("doc.dynamicXFAForm is read-only");\n  }\n  get external() {\n    return DOC_EXTERNAL;\n  }\n  set external(_) {\n    throw new Error("doc.external is read-only");\n  }\n  get filesize() {\n    return this._filesize;\n  }\n  set filesize(_) {\n    throw new Error("doc.filesize is read-only");\n  }\n  get hidden() {\n    return false;\n  }\n  set hidden(_) {\n    throw new Error("doc.hidden is read-only");\n  }\n  get hostContainer() {\n    return undefined;\n  }\n  set hostContainer(_) {\n    throw new Error("doc.hostContainer is read-only");\n  }\n  get icons() {\n    return undefined;\n  }\n  set icons(_) {\n    throw new Error("doc.icons is read-only");\n  }\n  get info() {\n    return this._info;\n  }\n  set info(_) {\n    throw new Error("doc.info is read-only");\n  }\n  get innerAppWindowRect() {\n    return [0, 0, 0, 0];\n  }\n  set innerAppWindowRect(_) {\n    throw new Error("doc.innerAppWindowRect is read-only");\n  }\n  get innerDocWindowRect() {\n    return [0, 0, 0, 0];\n  }\n  set innerDocWindowRect(_) {\n    throw new Error("doc.innerDocWindowRect is read-only");\n  }\n  get isModal() {\n    return false;\n  }\n  set isModal(_) {\n    throw new Error("doc.isModal is read-only");\n  }\n  get keywords() {\n    return this._keywords;\n  }\n  set keywords(_) {\n    throw new Error("doc.keywords is read-only");\n  }\n  get layout() {\n    return this._layout;\n  }\n  set layout(value) {\n    if (!this._userActivation) {\n      return;\n    }\n    this._userActivation = false;\n    if (typeof value !== "string") {\n      return;\n    }\n    if (value !== "SinglePage" && value !== "OneColumn" && value !== "TwoColumnLeft" && value !== "TwoPageLeft" && value !== "TwoColumnRight" && value !== "TwoPageRight") {\n      value = "SinglePage";\n    }\n    this._send({\n      command: "layout",\n      value\n    });\n    this._layout = value;\n  }\n  get media() {\n    return this._media;\n  }\n  set media(media) {\n    this._media = media;\n  }\n  get metadata() {\n    return this._metadata;\n  }\n  set metadata(metadata) {\n    this._metadata = metadata;\n  }\n  get modDate() {\n    return this._modDate;\n  }\n  set modDate(_) {\n    throw new Error("doc.modDate is read-only");\n  }\n  get mouseX() {\n    return 0;\n  }\n  set mouseX(_) {\n    throw new Error("doc.mouseX is read-only");\n  }\n  get mouseY() {\n    return 0;\n  }\n  set mouseY(_) {\n    throw new Error("doc.mouseY is read-only");\n  }\n  get noautocomplete() {\n    return this._noautocomplete;\n  }\n  set noautocomplete(noautocomplete) {\n    this._noautocomplete = noautocomplete;\n  }\n  get nocache() {\n    return this._nocache;\n  }\n  set nocache(nocache) {\n    this._nocache = nocache;\n  }\n  get numFields() {\n    return this._numFields;\n  }\n  set numFields(_) {\n    throw new Error("doc.numFields is read-only");\n  }\n  get numPages() {\n    return this._numPages;\n  }\n  set numPages(_) {\n    throw new Error("doc.numPages is read-only");\n  }\n  get numTemplates() {\n    return 0;\n  }\n  set numTemplates(_) {\n    throw new Error("doc.numTemplates is read-only");\n  }\n  get outerAppWindowRect() {\n    return [0, 0, 0, 0];\n  }\n  set outerAppWindowRect(_) {\n    throw new Error("doc.outerAppWindowRect is read-only");\n  }\n  get outerDocWindowRect() {\n    return [0, 0, 0, 0];\n  }\n  set outerDocWindowRect(_) {\n    throw new Error("doc.outerDocWindowRect is read-only");\n  }\n  get pageNum() {\n    return this._pageNum;\n  }\n  set pageNum(value) {\n    if (!this._userActivation) {\n      return;\n    }\n    this._userActivation = false;\n    if (typeof value !== "number" || value < 0 || value >= this._numPages) {\n      return;\n    }\n    this._send({\n      command: "page-num",\n      value\n    });\n    this._pageNum = value;\n  }\n  get pageWindowRect() {\n    return [0, 0, 0, 0];\n  }\n  set pageWindowRect(_) {\n    throw new Error("doc.pageWindowRect is read-only");\n  }\n  get path() {\n    return "";\n  }\n  set path(_) {\n    throw new Error("doc.path is read-only");\n  }\n  get permStatusReady() {\n    return true;\n  }\n  set permStatusReady(_) {\n    throw new Error("doc.permStatusReady is read-only");\n  }\n  get producer() {\n    return this._producer;\n  }\n  set producer(_) {\n    throw new Error("doc.producer is read-only");\n  }\n  get requiresFullSave() {\n    return false;\n  }\n  set requiresFullSave(_) {\n    throw new Error("doc.requiresFullSave is read-only");\n  }\n  get securityHandler() {\n    return this._securityHandler;\n  }\n  set securityHandler(_) {\n    throw new Error("doc.securityHandler is read-only");\n  }\n  get selectedAnnots() {\n    return [];\n  }\n  set selectedAnnots(_) {\n    throw new Error("doc.selectedAnnots is read-only");\n  }\n  get sounds() {\n    return [];\n  }\n  set sounds(_) {\n    throw new Error("doc.sounds is read-only");\n  }\n  get spellDictionaryOrder() {\n    return this._spellDictionaryOrder;\n  }\n  set spellDictionaryOrder(spellDictionaryOrder) {\n    this._spellDictionaryOrder = spellDictionaryOrder;\n  }\n  get spellLanguageOrder() {\n    return this._spellLanguageOrder;\n  }\n  set spellLanguageOrder(spellLanguageOrder) {\n    this._spellLanguageOrder = spellLanguageOrder;\n  }\n  get subject() {\n    return this._subject;\n  }\n  set subject(_) {\n    throw new Error("doc.subject is read-only");\n  }\n  get templates() {\n    return [];\n  }\n  set templates(_) {\n    throw new Error("doc.templates is read-only");\n  }\n  get title() {\n    return this._title;\n  }\n  set title(_) {\n    throw new Error("doc.title is read-only");\n  }\n  get URL() {\n    return this._URL;\n  }\n  set URL(_) {\n    throw new Error("doc.URL is read-only");\n  }\n  get viewState() {\n    return undefined;\n  }\n  set viewState(_) {\n    throw new Error("doc.viewState is read-only");\n  }\n  get xfa() {\n    return this._xfa;\n  }\n  set xfa(_) {\n    throw new Error("doc.xfa is read-only");\n  }\n  get XFAForeground() {\n    return false;\n  }\n  set XFAForeground(_) {\n    throw new Error("doc.XFAForeground is read-only");\n  }\n  get zoomType() {\n    return this._zoomType;\n  }\n  set zoomType(type) {\n    if (!this._userActivation) {\n      return;\n    }\n    this._userActivation = false;\n    if (typeof type !== "string") {\n      return;\n    }\n    switch (type) {\n      case ZoomType.none:\n        this._send({\n          command: "zoom",\n          value: 1\n        });\n        break;\n      case ZoomType.fitP:\n        this._send({\n          command: "zoom",\n          value: "page-fit"\n        });\n        break;\n      case ZoomType.fitW:\n        this._send({\n          command: "zoom",\n          value: "page-width"\n        });\n        break;\n      case ZoomType.fitH:\n        this._send({\n          command: "zoom",\n          value: "page-height"\n        });\n        break;\n      case ZoomType.fitV:\n        this._send({\n          command: "zoom",\n          value: "auto"\n        });\n        break;\n      case ZoomType.pref:\n      case ZoomType.refW:\n        break;\n      default:\n        return;\n    }\n    this._zoomType = type;\n  }\n  get zoom() {\n    return this._zoom;\n  }\n  set zoom(value) {\n    if (!this._userActivation) {\n      return;\n    }\n    this._userActivation = false;\n    if (typeof value !== "number" || value < 8.33 || value > 6400) {\n      return;\n    }\n    this._send({\n      command: "zoom",\n      value: value / 100\n    });\n  }\n  addAnnot() {}\n  addField() {}\n  addIcon() {}\n  addLink() {}\n  addRecipientListCryptFilter() {}\n  addRequirement() {}\n  addScript() {}\n  addThumbnails() {}\n  addWatermarkFromFile() {}\n  addWatermarkFromText() {}\n  addWeblinks() {}\n  bringToFront() {}\n  calculateNow() {\n    this._eventDispatcher.calculateNow();\n  }\n  closeDoc() {}\n  colorConvertPage() {}\n  createDataObject() {}\n  createTemplate() {}\n  deletePages() {}\n  deleteSound() {}\n  embedDocAsDataObject() {}\n  embedOutputIntent() {}\n  encryptForRecipients() {}\n  encryptUsingPolicy() {}\n  exportAsFDF() {}\n  exportAsFDFStr() {}\n  exportAsText() {}\n  exportAsXFDF() {}\n  exportAsXFDFStr() {}\n  exportDataObject() {}\n  exportXFAData() {}\n  extractPages() {}\n  flattenPages() {}\n  getAnnot() {}\n  getAnnots() {}\n  getAnnot3D() {}\n  getAnnots3D() {}\n  getColorConvertAction() {}\n  getDataObject() {}\n  getDataObjectContents() {}\n  _getField(cName) {\n    if (cName && typeof cName === "object") {\n      cName = cName.cName;\n    }\n    if (typeof cName !== "string") {\n      throw new TypeError("Invalid field name: must be a string");\n    }\n    const searchedField = this._fields.get(cName);\n    if (searchedField) {\n      return searchedField;\n    }\n    const parts = cName.split("#");\n    let childIndex = NaN;\n    if (parts.length === 2) {\n      childIndex = Math.floor(parseFloat(parts[1]));\n      cName = parts[0];\n    }\n    for (const [name, field] of this._fields.entries()) {\n      if (name.endsWith(cName)) {\n        if (!isNaN(childIndex)) {\n          const children = this._getChildren(name);\n          if (childIndex < 0 || childIndex >= children.length) {\n            childIndex = 0;\n          }\n          if (childIndex < children.length) {\n            this._fields.set(cName, children[childIndex]);\n            return children[childIndex];\n          }\n        }\n        this._fields.set(cName, field);\n        return field;\n      }\n    }\n    return null;\n  }\n  getField(cName) {\n    const field = this._getField(cName);\n    if (!field) {\n      return null;\n    }\n    return field.wrapped;\n  }\n  _getChildren(fieldName) {\n    const len = fieldName.length;\n    const children = [];\n    const pattern = /^\\.[^.]+$/;\n    for (const [name, field] of this._fields.entries()) {\n      if (name.startsWith(fieldName)) {\n        const finalPart = name.slice(len);\n        if (pattern.test(finalPart)) {\n          children.push(field);\n        }\n      }\n    }\n    return children;\n  }\n  _getTerminalChildren(fieldName) {\n    const children = [];\n    const len = fieldName.length;\n    for (const [name, field] of this._fields.entries()) {\n      if (name.startsWith(fieldName)) {\n        const finalPart = name.slice(len);\n        if (field.obj._hasValue && (finalPart === "" || finalPart.startsWith("."))) {\n          children.push(field.wrapped);\n        }\n      }\n    }\n    return children;\n  }\n  getIcon() {}\n  getLegalWarnings() {}\n  getLinks() {}\n  getNthFieldName(nIndex) {\n    if (nIndex && typeof nIndex === "object") {\n      nIndex = nIndex.nIndex;\n    }\n    if (typeof nIndex !== "number") {\n      throw new TypeError("Invalid field index: must be a number");\n    }\n    if (0 <= nIndex && nIndex < this.numFields) {\n      return this._fieldNames[Math.trunc(nIndex)];\n    }\n    return null;\n  }\n  getNthTemplate() {\n    return null;\n  }\n  getOCGs() {}\n  getOCGOrder() {}\n  getPageBox() {}\n  getPageLabel() {}\n  getPageNthWord() {}\n  getPageNthWordQuads() {}\n  getPageNumWords() {}\n  getPageRotation() {}\n  getPageTransition() {}\n  getPrintParams() {\n    return this._printParams ||= new PrintParams({\n      lastPage: this._numPages - 1\n    });\n  }\n  getSound() {}\n  getTemplate() {}\n  getURL() {}\n  gotoNamedDest() {}\n  importAnFDF() {}\n  importAnXFDF() {}\n  importDataObject() {}\n  importIcon() {}\n  importSound() {}\n  importTextData() {}\n  importXFAData() {}\n  insertPages() {}\n  mailDoc() {}\n  mailForm() {}\n  movePage() {}\n  newPage() {}\n  openDataObject() {}\n  print(bUI = true, nStart = 0, nEnd = -1, bSilent = false, bShrinkToFit = false, bPrintAsImage = false, bReverse = false, bAnnotations = true, printParams = null) {\n    if (this._disablePrinting || !this._userActivation) {\n      return;\n    }\n    this._userActivation = false;\n    if (bUI && typeof bUI === "object") {\n      nStart = bUI.nStart;\n      nEnd = bUI.nEnd;\n      bSilent = bUI.bSilent;\n      bShrinkToFit = bUI.bShrinkToFit;\n      bPrintAsImage = bUI.bPrintAsImage;\n      bReverse = bUI.bReverse;\n      bAnnotations = bUI.bAnnotations;\n      printParams = bUI.printParams;\n      bUI = bUI.bUI;\n    }\n    if (printParams) {\n      nStart = printParams.firstPage;\n      nEnd = printParams.lastPage;\n    }\n    nStart = typeof nStart === "number" ? Math.max(0, Math.trunc(nStart)) : 0;\n    nEnd = typeof nEnd === "number" ? Math.max(0, Math.trunc(nEnd)) : -1;\n    this._send({\n      command: "print",\n      start: nStart,\n      end: nEnd\n    });\n  }\n  removeDataObject() {}\n  removeField() {}\n  removeIcon() {}\n  removeLinks() {}\n  removeRequirement() {}\n  removeScript() {}\n  removeTemplate() {}\n  removeThumbnails() {}\n  removeWeblinks() {}\n  replacePages() {}\n  resetForm(aFields = null) {\n    if (aFields && typeof aFields === "object" && !Array.isArray(aFields)) {\n      aFields = aFields.aFields;\n    }\n    if (aFields && !Array.isArray(aFields)) {\n      aFields = [aFields];\n    }\n    let mustCalculate = false;\n    let fieldsToReset;\n    if (aFields) {\n      fieldsToReset = [];\n      for (const fieldName of aFields) {\n        if (!fieldName) {\n          continue;\n        }\n        if (typeof fieldName !== "string") {\n          fieldsToReset = null;\n          break;\n        }\n        const field = this._getField(fieldName);\n        if (!field) {\n          continue;\n        }\n        fieldsToReset.push(field);\n        mustCalculate = true;\n      }\n    }\n    if (!fieldsToReset) {\n      fieldsToReset = this._fields.values();\n      mustCalculate = this._fields.size !== 0;\n    }\n    for (const field of fieldsToReset) {\n      field.obj.value = field.obj.defaultValue;\n      this._send({\n        id: field.obj._id,\n        siblings: field.obj._siblings,\n        value: field.obj.defaultValue,\n        formattedValue: null,\n        selRange: [0, 0]\n      });\n    }\n    if (mustCalculate) {\n      this.calculateNow();\n    }\n  }\n  saveAs() {}\n  scroll() {}\n  selectPageNthWord() {}\n  setAction() {}\n  setDataObjectContents() {}\n  setOCGOrder() {}\n  setPageAction() {}\n  setPageBoxes() {}\n  setPageLabels() {}\n  setPageRotations() {}\n  setPageTabOrder() {}\n  setPageTransitions() {}\n  spawnPageFromTemplate() {}\n  submitForm() {}\n  syncAnnotScan() {}\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/proxy.js\nclass ProxyHandler {\n  constructor() {\n    this.nosend = new Set(["delay"]);\n  }\n  get(obj, prop) {\n    if (prop in obj._expandos) {\n      const val = obj._expandos[prop];\n      if (typeof val === "function") {\n        return val.bind(obj);\n      }\n      return val;\n    }\n    if (typeof prop === "string" && !prop.startsWith("_") && prop in obj) {\n      const val = obj[prop];\n      if (typeof val === "function") {\n        return val.bind(obj);\n      }\n      return val;\n    }\n    return undefined;\n  }\n  set(obj, prop, value) {\n    if (obj._kidIds) {\n      obj._kidIds.forEach(id => {\n        obj._appObjects[id].wrapped[prop] = value;\n      });\n    }\n    if (typeof prop === "string" && !prop.startsWith("_") && prop in obj) {\n      const old = obj[prop];\n      obj[prop] = value;\n      if (!this.nosend.has(prop) && obj._send && obj._id !== null && typeof old !== "function") {\n        const data = {\n          id: obj._id\n        };\n        data[prop] = prop === "value" ? obj._getValue() : obj[prop];\n        if (!obj._siblings) {\n          obj._send(data);\n        } else {\n          data.siblings = obj._siblings;\n          obj._send(data);\n        }\n      }\n    } else {\n      obj._expandos[prop] = value;\n    }\n    return true;\n  }\n  has(obj, prop) {\n    return prop in obj._expandos || typeof prop === "string" && !prop.startsWith("_") && prop in obj;\n  }\n  getPrototypeOf(obj) {\n    return null;\n  }\n  setPrototypeOf(obj, proto) {\n    return false;\n  }\n  isExtensible(obj) {\n    return true;\n  }\n  preventExtensions(obj) {\n    return false;\n  }\n  getOwnPropertyDescriptor(obj, prop) {\n    if (prop in obj._expandos) {\n      return {\n        configurable: true,\n        enumerable: true,\n        value: obj._expandos[prop]\n      };\n    }\n    if (typeof prop === "string" && !prop.startsWith("_") && prop in obj) {\n      return {\n        configurable: true,\n        enumerable: true,\n        value: obj[prop]\n      };\n    }\n    return undefined;\n  }\n  defineProperty(obj, key, descriptor) {\n    Object.defineProperty(obj._expandos, key, descriptor);\n    return true;\n  }\n  deleteProperty(obj, prop) {\n    if (prop in obj._expandos) {\n      delete obj._expandos[prop];\n    }\n  }\n  ownKeys(obj) {\n    const fromExpandos = Reflect.ownKeys(obj._expandos);\n    const fromObj = Reflect.ownKeys(obj).filter(k => !k.startsWith("_"));\n    return fromExpandos.concat(fromObj);\n  }\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/util.js\n\nclass Util extends PDFObject {\n  constructor(data) {\n    super(data);\n    this._scandCache = new Map();\n    this._months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];\n    this._days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];\n    this.MILLISECONDS_IN_DAY = 86400000;\n    this.MILLISECONDS_IN_WEEK = 604800000;\n    this._externalCall = data.externalCall;\n  }\n  printf(...args) {\n    if (args.length === 0) {\n      throw new Error("Invalid number of params in printf");\n    }\n    if (typeof args[0] !== "string") {\n      throw new TypeError("First argument of printf must be a string");\n    }\n    const pattern = /%(,[0-4])?([+ 0#]+)?(\\d+)?(\\.\\d+)?(.)/g;\n    const PLUS = 1;\n    const SPACE = 2;\n    const ZERO = 4;\n    const HASH = 8;\n    let i = 0;\n    return args[0].replaceAll(pattern, function (match, nDecSep, cFlags, nWidth, nPrecision, cConvChar) {\n      if (cConvChar !== "d" && cConvChar !== "f" && cConvChar !== "s" && cConvChar !== "x") {\n        const buf = ["%"];\n        for (const str of [nDecSep, cFlags, nWidth, nPrecision, cConvChar]) {\n          if (str) {\n            buf.push(str);\n          }\n        }\n        return buf.join("");\n      }\n      i++;\n      if (i === args.length) {\n        throw new Error("Not enough arguments in printf");\n      }\n      const arg = args[i];\n      if (cConvChar === "s") {\n        return arg.toString();\n      }\n      let flags = 0;\n      if (cFlags) {\n        for (const flag of cFlags) {\n          switch (flag) {\n            case "+":\n              flags |= PLUS;\n              break;\n            case " ":\n              flags |= SPACE;\n              break;\n            case "0":\n              flags |= ZERO;\n              break;\n            case "#":\n              flags |= HASH;\n              break;\n          }\n        }\n      }\n      cFlags = flags;\n      if (nWidth) {\n        nWidth = parseInt(nWidth);\n      }\n      let intPart = Math.trunc(arg);\n      if (cConvChar === "x") {\n        let hex = Math.abs(intPart).toString(16).toUpperCase();\n        if (nWidth !== undefined) {\n          hex = hex.padStart(nWidth, cFlags & ZERO ? "0" : " ");\n        }\n        if (cFlags & HASH) {\n          hex = `0x${hex}`;\n        }\n        return hex;\n      }\n      if (nPrecision) {\n        nPrecision = parseInt(nPrecision.substring(1));\n      }\n      nDecSep = nDecSep ? nDecSep.substring(1) : "0";\n      const separators = {\n        0: [",", "."],\n        1: ["", "."],\n        2: [".", ","],\n        3: ["", ","],\n        4: ["\'", "."]\n      };\n      const [thousandSep, decimalSep] = separators[nDecSep];\n      let decPart = "";\n      if (cConvChar === "f") {\n        decPart = nPrecision !== undefined ? Math.abs(arg - intPart).toFixed(nPrecision) : Math.abs(arg - intPart).toString();\n        if (decPart.length > 2) {\n          decPart = `${decimalSep}${decPart.substring(2)}`;\n        } else {\n          if (decPart === "1") {\n            intPart += Math.sign(arg);\n          }\n          decPart = cFlags & HASH ? "." : "";\n        }\n      }\n      let sign = "";\n      if (intPart < 0) {\n        sign = "-";\n        intPart = -intPart;\n      } else if (cFlags & PLUS) {\n        sign = "+";\n      } else if (cFlags & SPACE) {\n        sign = " ";\n      }\n      if (thousandSep && intPart >= 1000) {\n        const buf = [];\n        while (true) {\n          buf.push((intPart % 1000).toString().padStart(3, "0"));\n          intPart = Math.trunc(intPart / 1000);\n          if (intPart < 1000) {\n            buf.push(intPart.toString());\n            break;\n          }\n        }\n        intPart = buf.reverse().join(thousandSep);\n      } else {\n        intPart = intPart.toString();\n      }\n      let n = `${intPart}${decPart}`;\n      if (nWidth !== undefined) {\n        n = n.padStart(nWidth - sign.length, cFlags & ZERO ? "0" : " ");\n      }\n      return `${sign}${n}`;\n    });\n  }\n  iconStreamFromIcon() {}\n  printd(cFormat, oDate) {\n    switch (cFormat) {\n      case 0:\n        return this.printd("D:yyyymmddHHMMss", oDate);\n      case 1:\n        return this.printd("yyyy.mm.dd HH:MM:ss", oDate);\n      case 2:\n        return this.printd("m/d/yy h:MM:ss tt", oDate);\n    }\n    const handlers = {\n      mmmm: data => {\n        return this._months[data.month];\n      },\n      mmm: data => {\n        return this._months[data.month].substring(0, 3);\n      },\n      mm: data => {\n        return (data.month + 1).toString().padStart(2, "0");\n      },\n      m: data => {\n        return (data.month + 1).toString();\n      },\n      dddd: data => {\n        return this._days[data.dayOfWeek];\n      },\n      ddd: data => {\n        return this._days[data.dayOfWeek].substring(0, 3);\n      },\n      dd: data => {\n        return data.day.toString().padStart(2, "0");\n      },\n      d: data => {\n        return data.day.toString();\n      },\n      yyyy: data => {\n        return data.year.toString();\n      },\n      yy: data => {\n        return (data.year % 100).toString().padStart(2, "0");\n      },\n      HH: data => {\n        return data.hours.toString().padStart(2, "0");\n      },\n      H: data => {\n        return data.hours.toString();\n      },\n      hh: data => {\n        return (1 + (data.hours + 11) % 12).toString().padStart(2, "0");\n      },\n      h: data => {\n        return (1 + (data.hours + 11) % 12).toString();\n      },\n      MM: data => {\n        return data.minutes.toString().padStart(2, "0");\n      },\n      M: data => {\n        return data.minutes.toString();\n      },\n      ss: data => {\n        return data.seconds.toString().padStart(2, "0");\n      },\n      s: data => {\n        return data.seconds.toString();\n      },\n      tt: data => {\n        return data.hours < 12 ? "am" : "pm";\n      },\n      t: data => {\n        return data.hours < 12 ? "a" : "p";\n      }\n    };\n    const data = {\n      year: oDate.getFullYear(),\n      month: oDate.getMonth(),\n      day: oDate.getDate(),\n      dayOfWeek: oDate.getDay(),\n      hours: oDate.getHours(),\n      minutes: oDate.getMinutes(),\n      seconds: oDate.getSeconds()\n    };\n    const patterns = /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t|\\\\.)/g;\n    return cFormat.replaceAll(patterns, function (match, pattern) {\n      if (pattern in handlers) {\n        return handlers[pattern](data);\n      }\n      return pattern.charCodeAt(1);\n    });\n  }\n  printx(cFormat, cSource) {\n    cSource = (cSource ?? "").toString();\n    const handlers = [x => x, x => x.toUpperCase(), x => x.toLowerCase()];\n    const buf = [];\n    let i = 0;\n    const ii = cSource.length;\n    let currCase = handlers[0];\n    let escaped = false;\n    for (const command of cFormat) {\n      if (escaped) {\n        buf.push(command);\n        escaped = false;\n        continue;\n      }\n      if (i >= ii) {\n        break;\n      }\n      switch (command) {\n        case "?":\n          buf.push(currCase(cSource.charAt(i++)));\n          break;\n        case "X":\n          while (i < ii) {\n            const char = cSource.charAt(i++);\n            if ("a" <= char && char <= "z" || "A" <= char && char <= "Z" || "0" <= char && char <= "9") {\n              buf.push(currCase(char));\n              break;\n            }\n          }\n          break;\n        case "A":\n          while (i < ii) {\n            const char = cSource.charAt(i++);\n            if ("a" <= char && char <= "z" || "A" <= char && char <= "Z") {\n              buf.push(currCase(char));\n              break;\n            }\n          }\n          break;\n        case "9":\n          while (i < ii) {\n            const char = cSource.charAt(i++);\n            if ("0" <= char && char <= "9") {\n              buf.push(char);\n              break;\n            }\n          }\n          break;\n        case "*":\n          while (i < ii) {\n            buf.push(currCase(cSource.charAt(i++)));\n          }\n          break;\n        case "\\\\":\n          escaped = true;\n          break;\n        case ">":\n          currCase = handlers[1];\n          break;\n        case "<":\n          currCase = handlers[2];\n          break;\n        case "=":\n          currCase = handlers[0];\n          break;\n        default:\n          buf.push(command);\n      }\n    }\n    return buf.join("");\n  }\n  scand(cFormat, cDate) {\n    if (typeof cDate !== "string") {\n      return new Date(cDate);\n    }\n    if (cDate === "") {\n      return new Date();\n    }\n    switch (cFormat) {\n      case 0:\n        return this.scand("D:yyyymmddHHMMss", cDate);\n      case 1:\n        return this.scand("yyyy.mm.dd HH:MM:ss", cDate);\n      case 2:\n        return this.scand("m/d/yy h:MM:ss tt", cDate);\n    }\n    if (!this._scandCache.has(cFormat)) {\n      const months = this._months;\n      const days = this._days;\n      const handlers = {\n        mmmm: {\n          pattern: `(${months.join("|")})`,\n          action: (value, data) => {\n            data.month = months.indexOf(value);\n          }\n        },\n        mmm: {\n          pattern: `(${months.map(month => month.substring(0, 3)).join("|")})`,\n          action: (value, data) => {\n            data.month = months.findIndex(month => month.substring(0, 3) === value);\n          }\n        },\n        mm: {\n          pattern: `(\\\\d{2})`,\n          action: (value, data) => {\n            data.month = parseInt(value) - 1;\n          }\n        },\n        m: {\n          pattern: `(\\\\d{1,2})`,\n          action: (value, data) => {\n            data.month = parseInt(value) - 1;\n          }\n        },\n        dddd: {\n          pattern: `(${days.join("|")})`,\n          action: (value, data) => {\n            data.day = days.indexOf(value);\n          }\n        },\n        ddd: {\n          pattern: `(${days.map(day => day.substring(0, 3)).join("|")})`,\n          action: (value, data) => {\n            data.day = days.findIndex(day => day.substring(0, 3) === value);\n          }\n        },\n        dd: {\n          pattern: "(\\\\d{2})",\n          action: (value, data) => {\n            data.day = parseInt(value);\n          }\n        },\n        d: {\n          pattern: "(\\\\d{1,2})",\n          action: (value, data) => {\n            data.day = parseInt(value);\n          }\n        },\n        yyyy: {\n          pattern: "(\\\\d{4})",\n          action: (value, data) => {\n            data.year = parseInt(value);\n          }\n        },\n        yy: {\n          pattern: "(\\\\d{2})",\n          action: (value, data) => {\n            data.year = 2000 + parseInt(value);\n          }\n        },\n        HH: {\n          pattern: "(\\\\d{2})",\n          action: (value, data) => {\n            data.hours = parseInt(value);\n          }\n        },\n        H: {\n          pattern: "(\\\\d{1,2})",\n          action: (value, data) => {\n            data.hours = parseInt(value);\n          }\n        },\n        hh: {\n          pattern: "(\\\\d{2})",\n          action: (value, data) => {\n            data.hours = parseInt(value);\n          }\n        },\n        h: {\n          pattern: "(\\\\d{1,2})",\n          action: (value, data) => {\n            data.hours = parseInt(value);\n          }\n        },\n        MM: {\n          pattern: "(\\\\d{2})",\n          action: (value, data) => {\n            data.minutes = parseInt(value);\n          }\n        },\n        M: {\n          pattern: "(\\\\d{1,2})",\n          action: (value, data) => {\n            data.minutes = parseInt(value);\n          }\n        },\n        ss: {\n          pattern: "(\\\\d{2})",\n          action: (value, data) => {\n            data.seconds = parseInt(value);\n          }\n        },\n        s: {\n          pattern: "(\\\\d{1,2})",\n          action: (value, data) => {\n            data.seconds = parseInt(value);\n          }\n        },\n        tt: {\n          pattern: "([aApP][mM])",\n          action: (value, data) => {\n            const char = value.charAt(0);\n            data.am = char === "a" || char === "A";\n          }\n        },\n        t: {\n          pattern: "([aApP])",\n          action: (value, data) => {\n            data.am = value === "a" || value === "A";\n          }\n        }\n      };\n      const escapedFormat = cFormat.replaceAll(/[.*+\\-?^${}()|[\\]\\\\]/g, "\\\\$&");\n      const patterns = /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t)/g;\n      const actions = [];\n      const re = escapedFormat.replaceAll(patterns, function (match, patternElement) {\n        const {\n          pattern,\n          action\n        } = handlers[patternElement];\n        actions.push(action);\n        return pattern;\n      });\n      this._scandCache.set(cFormat, [re, actions]);\n    }\n    const [re, actions] = this._scandCache.get(cFormat);\n    const matches = new RegExp(`^${re}$`, "g").exec(cDate);\n    if (!matches || matches.length !== actions.length + 1) {\n      return null;\n    }\n    const data = {\n      year: 2000,\n      month: 0,\n      day: 1,\n      hours: 0,\n      minutes: 0,\n      seconds: 0,\n      am: null\n    };\n    actions.forEach((action, i) => action(matches[i + 1], data));\n    if (data.am !== null) {\n      data.hours = data.hours % 12 + (data.am ? 0 : 12);\n    }\n    return new Date(data.year, data.month, data.day, data.hours, data.minutes, data.seconds);\n  }\n  spansToXML() {}\n  stringFromStream() {}\n  xmlToSpans() {}\n}\n\n;// CONCATENATED MODULE: ./src/scripting_api/initialization.js\n\n\n\n\n\n\n\n\n\n\nfunction initSandbox(params) {\n  delete globalThis.pdfjsScripting;\n  const externalCall = globalThis.callExternalFunction;\n  delete globalThis.callExternalFunction;\n  const globalEval = code => globalThis.eval(code);\n  const send = data => externalCall("send", [data]);\n  const proxyHandler = new ProxyHandler();\n  const {\n    data\n  } = params;\n  const doc = new Doc({\n    send,\n    globalEval,\n    ...data.docInfo\n  });\n  const _document = {\n    obj: doc,\n    wrapped: new Proxy(doc, proxyHandler)\n  };\n  const app = new App({\n    send,\n    globalEval,\n    externalCall,\n    _document,\n    calculationOrder: data.calculationOrder,\n    proxyHandler,\n    ...data.appInfo\n  });\n  const util = new Util({\n    externalCall\n  });\n  const appObjects = app._objects;\n  if (data.objects) {\n    const annotations = [];\n    for (const [name, objs] of Object.entries(data.objects)) {\n      annotations.length = 0;\n      let container = null;\n      for (const obj of objs) {\n        if (obj.type !== "") {\n          annotations.push(obj);\n        } else {\n          container = obj;\n        }\n      }\n      let obj = container;\n      if (annotations.length > 0) {\n        obj = annotations[0];\n        obj.send = send;\n      }\n      obj.globalEval = globalEval;\n      obj.doc = _document;\n      obj.fieldPath = name;\n      obj.appObjects = appObjects;\n      let field;\n      switch (obj.type) {\n        case "radiobutton":\n          {\n            const otherButtons = annotations.slice(1);\n            field = new RadioButtonField(otherButtons, obj);\n            break;\n          }\n        case "checkbox":\n          {\n            const otherButtons = annotations.slice(1);\n            field = new CheckboxField(otherButtons, obj);\n            break;\n          }\n        case "text":\n          if (annotations.length <= 1) {\n            field = new Field(obj);\n            break;\n          }\n          obj.siblings = annotations.map(x => x.id).slice(1);\n          field = new Field(obj);\n          break;\n        default:\n          field = new Field(obj);\n      }\n      const wrapped = new Proxy(field, proxyHandler);\n      const _object = {\n        obj: field,\n        wrapped\n      };\n      doc._addField(name, _object);\n      for (const object of objs) {\n        appObjects[object.id] = _object;\n      }\n      if (container) {\n        appObjects[container.id] = _object;\n      }\n    }\n  }\n  const color = new Color();\n  globalThis.event = null;\n  globalThis.global = Object.create(null);\n  globalThis.app = new Proxy(app, proxyHandler);\n  globalThis.color = new Proxy(color, proxyHandler);\n  globalThis.console = new Proxy(new Console({\n    send\n  }), proxyHandler);\n  globalThis.util = new Proxy(util, proxyHandler);\n  globalThis.border = Border;\n  globalThis.cursor = Cursor;\n  globalThis.display = Display;\n  globalThis.font = Font;\n  globalThis.highlight = Highlight;\n  globalThis.position = Position;\n  globalThis.scaleHow = ScaleHow;\n  globalThis.scaleWhen = ScaleWhen;\n  globalThis.style = Style;\n  globalThis.trans = Trans;\n  globalThis.zoomtype = ZoomType;\n  globalThis.ADBE = {\n    Reader_Value_Asked: true,\n    Viewer_Value_Asked: true\n  };\n  const aform = new AForm(doc, app, util, color);\n  for (const name of Object.getOwnPropertyNames(AForm.prototype)) {\n    if (name !== "constructor" && !name.startsWith("_")) {\n      globalThis[name] = aform[name].bind(aform);\n    }\n  }\n  for (const [name, value] of Object.entries(GlobalConstants)) {\n    Object.defineProperty(globalThis, name, {\n      value,\n      writable: false\n    });\n  }\n  Object.defineProperties(globalThis, {\n    ColorConvert: {\n      value: color.convert.bind(color),\n      writable: true\n    },\n    ColorEqual: {\n      value: color.equal.bind(color),\n      writable: true\n    }\n  });\n  const properties = Object.create(null);\n  for (const name of Object.getOwnPropertyNames(Doc.prototype)) {\n    if (name === "constructor" || name.startsWith("_")) {\n      continue;\n    }\n    const descriptor = Object.getOwnPropertyDescriptor(Doc.prototype, name);\n    if (descriptor.get) {\n      properties[name] = {\n        get: descriptor.get.bind(doc),\n        set: descriptor.set.bind(doc)\n      };\n    } else {\n      properties[name] = {\n        value: Doc.prototype[name].bind(doc)\n      };\n    }\n  }\n  Object.defineProperties(globalThis, properties);\n  const functions = {\n    dispatchEvent: app._dispatchEvent.bind(app),\n    timeoutCb: app._evalCallback.bind(app)\n  };\n  return (name, args) => {\n    try {\n      functions[name](args);\n    } catch (error) {\n      send(serializeError(error));\n    }\n  };\n}\n\n;// CONCATENATED MODULE: ./src/pdf.scripting.js\n\nconst pdfjsVersion = \'4.0.379\';\nconst pdfjsBuild = \'9e14d04fd\';\nglobalThis.pdfjsScripting = {\n  initSandbox: initSandbox\n};\n'];
    code.push("delete dump;");
    let success = false;
    let buf = 0;
    try {
      const sandboxData = JSON.stringify(data);
      code.push(`pdfjsScripting.initSandbox({ data: ${sandboxData} })`);
      buf = this._module.stringToNewUTF8(code.join("\n"));
      success = !!this._module.ccall("init", "number", ["number", "number"], [buf, this._alertOnError]);
    } catch (error) {
      console.error(error);
    } finally {
      if (buf) {
        this._module.ccall("free", "number", ["number"], [buf]);
      }
    }
    if (success) {
      this.support.commFun = this._module.cwrap("commFun", null, ["string", "string"]);
    } else {
      this.nukeSandbox();
      throw new Error("Cannot start sandbox");
    }
  }
  dispatchEvent(event) {
    this.support?.callSandboxFunction("dispatchEvent", event);
  }
  dumpMemoryUse() {
    this._module?.ccall("dumpMemoryUse", null, []);
  }
  nukeSandbox() {
    if (this._module !== null) {
      this.support.destroy();
      this.support = null;
      this._module.ccall("nukeSandbox", null, []);
      this._module = null;
    }
  }
  evalForTesting(code, key) {
    throw new Error("Not implemented: evalForTesting");
  }
}
function QuickJSSandbox() {
  return quickjs_eval().then(module => {
    return new Sandbox(window, module);
  });
}

var __webpack_exports__QuickJSSandbox = __webpack_exports__.QuickJSSandbox;
export { __webpack_exports__QuickJSSandbox as QuickJSSandbox };

//# sourceMappingURL=pdf.sandbox.mjs.map