@latex-kit/sign-web 0.0.0-stage → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +46 -2
- package/dist/assets/index-CMd3KXBu.css +1 -0
- package/dist/assets/index-miAI7zRO.js +54 -0
- package/dist/assets/pdf.worker.min-yatZIOMy.mjs +21 -0
- package/dist/index.html +13 -0
- package/package.json +41 -3
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function e(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(r){if(r.ep)return;r.ep=!0;const a=e(r);fetch(r.href,a)}})();var Ja={exports:{}},gs={},tl={exports:{}},St={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Lh;function Fp(){if(Lh)return St;Lh=1;var g=Symbol.for("react.element"),t=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),v=Symbol.iterator;function y(k){return k===null||typeof k!="object"?null:(k=v&&k[v]||k["@@iterator"],typeof k=="function"?k:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},A=Object.assign,S={};function E(k,D,rt){this.props=k,this.context=D,this.refs=S,this.updater=rt||w}E.prototype.isReactComponent={},E.prototype.setState=function(k,D){if(typeof k!="object"&&typeof k!="function"&&k!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,k,D,"setState")},E.prototype.forceUpdate=function(k){this.updater.enqueueForceUpdate(this,k,"forceUpdate")};function x(){}x.prototype=E.prototype;function M(k,D,rt){this.props=k,this.context=D,this.refs=S,this.updater=rt||w}var I=M.prototype=new x;I.constructor=M,A(I,E.prototype),I.isPureReactComponent=!0;var N=Array.isArray,O=Object.prototype.hasOwnProperty,H={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function G(k,D,rt){var J,wt={},dt=null,ut=null;if(D!=null)for(J in D.ref!==void 0&&(ut=D.ref),D.key!==void 0&&(dt=""+D.key),D)O.call(D,J)&&!F.hasOwnProperty(J)&&(wt[J]=D[J]);var Et=arguments.length-2;if(Et===1)wt.children=rt;else if(1<Et){for(var Mt=Array(Et),he=0;he<Et;he++)Mt[he]=arguments[he+2];wt.children=Mt}if(k&&k.defaultProps)for(J in Et=k.defaultProps,Et)wt[J]===void 0&&(wt[J]=Et[J]);return{$$typeof:g,type:k,key:dt,ref:ut,props:wt,_owner:H.current}}function Y(k,D){return{$$typeof:g,type:k.type,key:D,ref:k.ref,props:k.props,_owner:k._owner}}function $(k){return typeof k=="object"&&k!==null&&k.$$typeof===g}function V(k){var D={"=":"=0",":":"=2"};return"$"+k.replace(/[=:]/g,function(rt){return D[rt]})}var at=/\/+/g;function mt(k,D){return typeof k=="object"&&k!==null&&k.key!=null?V(""+k.key):D.toString(36)}function yt(k,D,rt,J,wt){var dt=typeof k;(dt==="undefined"||dt==="boolean")&&(k=null);var ut=!1;if(k===null)ut=!0;else switch(dt){case"string":case"number":ut=!0;break;case"object":switch(k.$$typeof){case g:case t:ut=!0}}if(ut)return ut=k,wt=wt(ut),k=J===""?"."+mt(ut,0):J,N(wt)?(rt="",k!=null&&(rt=k.replace(at,"$&/")+"/"),yt(wt,D,rt,"",function(he){return he})):wt!=null&&($(wt)&&(wt=Y(wt,rt+(!wt.key||ut&&ut.key===wt.key?"":(""+wt.key).replace(at,"$&/")+"/")+k)),D.push(wt)),1;if(ut=0,J=J===""?".":J+":",N(k))for(var Et=0;Et<k.length;Et++){dt=k[Et];var Mt=J+mt(dt,Et);ut+=yt(dt,D,rt,Mt,wt)}else if(Mt=y(k),typeof Mt=="function")for(k=Mt.call(k),Et=0;!(dt=k.next()).done;)dt=dt.value,Mt=J+mt(dt,Et++),ut+=yt(dt,D,rt,Mt,wt);else if(dt==="object")throw D=String(k),Error("Objects are not valid as a React child (found: "+(D==="[object Object]"?"object with keys {"+Object.keys(k).join(", ")+"}":D)+"). If you meant to render a collection of children, use an array instead.");return ut}function kt(k,D,rt){if(k==null)return k;var J=[],wt=0;return yt(k,J,"","",function(dt){return D.call(rt,dt,wt++)}),J}function K(k){if(k._status===-1){var D=k._result;D=D(),D.then(function(rt){(k._status===0||k._status===-1)&&(k._status=1,k._result=rt)},function(rt){(k._status===0||k._status===-1)&&(k._status=2,k._result=rt)}),k._status===-1&&(k._status=0,k._result=D)}if(k._status===1)return k._result.default;throw k._result}var Q={current:null},q={transition:null},it={ReactCurrentDispatcher:Q,ReactCurrentBatchConfig:q,ReactCurrentOwner:H};function z(){throw Error("act(...) is not supported in production builds of React.")}return St.Children={map:kt,forEach:function(k,D,rt){kt(k,function(){D.apply(this,arguments)},rt)},count:function(k){var D=0;return kt(k,function(){D++}),D},toArray:function(k){return kt(k,function(D){return D})||[]},only:function(k){if(!$(k))throw Error("React.Children.only expected to receive a single React element child.");return k}},St.Component=E,St.Fragment=e,St.Profiler=r,St.PureComponent=M,St.StrictMode=s,St.Suspense=h,St.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=it,St.act=z,St.cloneElement=function(k,D,rt){if(k==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+k+".");var J=A({},k.props),wt=k.key,dt=k.ref,ut=k._owner;if(D!=null){if(D.ref!==void 0&&(dt=D.ref,ut=H.current),D.key!==void 0&&(wt=""+D.key),k.type&&k.type.defaultProps)var Et=k.type.defaultProps;for(Mt in D)O.call(D,Mt)&&!F.hasOwnProperty(Mt)&&(J[Mt]=D[Mt]===void 0&&Et!==void 0?Et[Mt]:D[Mt])}var Mt=arguments.length-2;if(Mt===1)J.children=rt;else if(1<Mt){Et=Array(Mt);for(var he=0;he<Mt;he++)Et[he]=arguments[he+2];J.children=Et}return{$$typeof:g,type:k.type,key:wt,ref:dt,props:J,_owner:ut}},St.createContext=function(k){return k={$$typeof:l,_currentValue:k,_currentValue2:k,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},k.Provider={$$typeof:a,_context:k},k.Consumer=k},St.createElement=G,St.createFactory=function(k){var D=G.bind(null,k);return D.type=k,D},St.createRef=function(){return{current:null}},St.forwardRef=function(k){return{$$typeof:u,render:k}},St.isValidElement=$,St.lazy=function(k){return{$$typeof:f,_payload:{_status:-1,_result:k},_init:K}},St.memo=function(k,D){return{$$typeof:p,type:k,compare:D===void 0?null:D}},St.startTransition=function(k){var D=q.transition;q.transition={};try{k()}finally{q.transition=D}},St.unstable_act=z,St.useCallback=function(k,D){return Q.current.useCallback(k,D)},St.useContext=function(k){return Q.current.useContext(k)},St.useDebugValue=function(){},St.useDeferredValue=function(k){return Q.current.useDeferredValue(k)},St.useEffect=function(k,D){return Q.current.useEffect(k,D)},St.useId=function(){return Q.current.useId()},St.useImperativeHandle=function(k,D,rt){return Q.current.useImperativeHandle(k,D,rt)},St.useInsertionEffect=function(k,D){return Q.current.useInsertionEffect(k,D)},St.useLayoutEffect=function(k,D){return Q.current.useLayoutEffect(k,D)},St.useMemo=function(k,D){return Q.current.useMemo(k,D)},St.useReducer=function(k,D,rt){return Q.current.useReducer(k,D,rt)},St.useRef=function(k){return Q.current.useRef(k)},St.useState=function(k){return Q.current.useState(k)},St.useSyncExternalStore=function(k,D,rt){return Q.current.useSyncExternalStore(k,D,rt)},St.useTransition=function(){return Q.current.useTransition()},St.version="18.3.1",St}var Ih;function Al(){return Ih||(Ih=1,tl.exports=Fp()),tl.exports}/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.production.min.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var Nh;function Op(){if(Nh)return gs;Nh=1;var g=Al(),t=Symbol.for("react.element"),e=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,r=g.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function l(u,h,p){var f,v={},y=null,w=null;p!==void 0&&(y=""+p),h.key!==void 0&&(y=""+h.key),h.ref!==void 0&&(w=h.ref);for(f in h)s.call(h,f)&&!a.hasOwnProperty(f)&&(v[f]=h[f]);if(u&&u.defaultProps)for(f in h=u.defaultProps,h)v[f]===void 0&&(v[f]=h[f]);return{$$typeof:t,type:u,key:y,ref:w,props:v,_owner:r.current}}return gs.Fragment=e,gs.jsx=l,gs.jsxs=l,gs}var Dh;function zp(){return Dh||(Dh=1,Ja.exports=Op()),Ja.exports}var W=zp(),Br={},el={exports:{}},Se={},nl={exports:{}},il={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.min.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/var Fh;function jp(){return Fh||(Fh=1,(function(g){function t(q,it){var z=q.length;q.push(it);t:for(;0<z;){var k=z-1>>>1,D=q[k];if(0<r(D,it))q[k]=it,q[z]=D,z=k;else break t}}function e(q){return q.length===0?null:q[0]}function s(q){if(q.length===0)return null;var it=q[0],z=q.pop();if(z!==it){q[0]=z;t:for(var k=0,D=q.length,rt=D>>>1;k<rt;){var J=2*(k+1)-1,wt=q[J],dt=J+1,ut=q[dt];if(0>r(wt,z))dt<D&&0>r(ut,wt)?(q[k]=ut,q[dt]=z,k=dt):(q[k]=wt,q[J]=z,k=J);else if(dt<D&&0>r(ut,z))q[k]=ut,q[dt]=z,k=dt;else break t}}return it}function r(q,it){var z=q.sortIndex-it.sortIndex;return z!==0?z:q.id-it.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;g.unstable_now=function(){return a.now()}}else{var l=Date,u=l.now();g.unstable_now=function(){return l.now()-u}}var h=[],p=[],f=1,v=null,y=3,w=!1,A=!1,S=!1,E=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function I(q){for(var it=e(p);it!==null;){if(it.callback===null)s(p);else if(it.startTime<=q)s(p),it.sortIndex=it.expirationTime,t(h,it);else break;it=e(p)}}function N(q){if(S=!1,I(q),!A)if(e(h)!==null)A=!0,K(O);else{var it=e(p);it!==null&&Q(N,it.startTime-q)}}function O(q,it){A=!1,S&&(S=!1,x(G),G=-1),w=!0;var z=y;try{for(I(it),v=e(h);v!==null&&(!(v.expirationTime>it)||q&&!V());){var k=v.callback;if(typeof k=="function"){v.callback=null,y=v.priorityLevel;var D=k(v.expirationTime<=it);it=g.unstable_now(),typeof D=="function"?v.callback=D:v===e(h)&&s(h),I(it)}else s(h);v=e(h)}if(v!==null)var rt=!0;else{var J=e(p);J!==null&&Q(N,J.startTime-it),rt=!1}return rt}finally{v=null,y=z,w=!1}}var H=!1,F=null,G=-1,Y=5,$=-1;function V(){return!(g.unstable_now()-$<Y)}function at(){if(F!==null){var q=g.unstable_now();$=q;var it=!0;try{it=F(!0,q)}finally{it?mt():(H=!1,F=null)}}else H=!1}var mt;if(typeof M=="function")mt=function(){M(at)};else if(typeof MessageChannel<"u"){var yt=new MessageChannel,kt=yt.port2;yt.port1.onmessage=at,mt=function(){kt.postMessage(null)}}else mt=function(){E(at,0)};function K(q){F=q,H||(H=!0,mt())}function Q(q,it){G=E(function(){q(g.unstable_now())},it)}g.unstable_IdlePriority=5,g.unstable_ImmediatePriority=1,g.unstable_LowPriority=4,g.unstable_NormalPriority=3,g.unstable_Profiling=null,g.unstable_UserBlockingPriority=2,g.unstable_cancelCallback=function(q){q.callback=null},g.unstable_continueExecution=function(){A||w||(A=!0,K(O))},g.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Y=0<q?Math.floor(1e3/q):5},g.unstable_getCurrentPriorityLevel=function(){return y},g.unstable_getFirstCallbackNode=function(){return e(h)},g.unstable_next=function(q){switch(y){case 1:case 2:case 3:var it=3;break;default:it=y}var z=y;y=it;try{return q()}finally{y=z}},g.unstable_pauseExecution=function(){},g.unstable_requestPaint=function(){},g.unstable_runWithPriority=function(q,it){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var z=y;y=q;try{return it()}finally{y=z}},g.unstable_scheduleCallback=function(q,it,z){var k=g.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?k+z:k):z=k,q){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=z+D,q={id:f++,callback:it,priorityLevel:q,startTime:z,expirationTime:D,sortIndex:-1},z>k?(q.sortIndex=z,t(p,q),e(h)===null&&q===e(p)&&(S?(x(G),G=-1):S=!0,Q(N,z-k))):(q.sortIndex=D,t(h,q),A||w||(A=!0,K(O))),q},g.unstable_shouldYield=V,g.unstable_wrapCallback=function(q){var it=y;return function(){var z=y;y=it;try{return q.apply(this,arguments)}finally{y=z}}}})(il)),il}var Oh;function Bp(){return Oh||(Oh=1,nl.exports=jp()),nl.exports}/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.min.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var zh;function Hp(){if(zh)return Se;zh=1;var g=Al(),t=Bp();function e(n){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+n,o=1;o<arguments.length;o++)i+="&args[]="+encodeURIComponent(arguments[o]);return"Minified React error #"+n+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,r={};function a(n,i){l(n,i),l(n+"Capture",i)}function l(n,i){for(r[n]=i,n=0;n<i.length;n++)s.add(i[n])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,p=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},v={};function y(n){return h.call(v,n)?!0:h.call(f,n)?!1:p.test(n)?v[n]=!0:(f[n]=!0,!1)}function w(n,i,o,c){if(o!==null&&o.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return c?!1:o!==null?!o.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function A(n,i,o,c){if(i===null||typeof i>"u"||w(n,i,o,c))return!0;if(c)return!1;if(o!==null)switch(o.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function S(n,i,o,c,d,m,_){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=c,this.attributeNamespace=d,this.mustUseProperty=o,this.propertyName=n,this.type=i,this.sanitizeURL=m,this.removeEmptyString=_}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){E[n]=new S(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var i=n[0];E[i]=new S(i,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){E[n]=new S(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){E[n]=new S(n,2,!1,n,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){E[n]=new S(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){E[n]=new S(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){E[n]=new S(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){E[n]=new S(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){E[n]=new S(n,5,!1,n.toLowerCase(),null,!1,!1)});var x=/[\-:]([a-z])/g;function M(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var i=n.replace(x,M);E[i]=new S(i,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var i=n.replace(x,M);E[i]=new S(i,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var i=n.replace(x,M);E[i]=new S(i,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){E[n]=new S(n,1,!1,n.toLowerCase(),null,!1,!1)}),E.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){E[n]=new S(n,1,!1,n.toLowerCase(),null,!0,!0)});function I(n,i,o,c){var d=E.hasOwnProperty(i)?E[i]:null;(d!==null?d.type!==0:c||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(A(i,o,d,c)&&(o=null),c||d===null?y(i)&&(o===null?n.removeAttribute(i):n.setAttribute(i,""+o)):d.mustUseProperty?n[d.propertyName]=o===null?d.type===3?!1:"":o:(i=d.attributeName,c=d.attributeNamespace,o===null?n.removeAttribute(i):(d=d.type,o=d===3||d===4&&o===!0?"":""+o,c?n.setAttributeNS(c,i,o):n.setAttribute(i,o))))}var N=g.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,O=Symbol.for("react.element"),H=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),Y=Symbol.for("react.profiler"),$=Symbol.for("react.provider"),V=Symbol.for("react.context"),at=Symbol.for("react.forward_ref"),mt=Symbol.for("react.suspense"),yt=Symbol.for("react.suspense_list"),kt=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),Q=Symbol.for("react.offscreen"),q=Symbol.iterator;function it(n){return n===null||typeof n!="object"?null:(n=q&&n[q]||n["@@iterator"],typeof n=="function"?n:null)}var z=Object.assign,k;function D(n){if(k===void 0)try{throw Error()}catch(o){var i=o.stack.trim().match(/\n( *(at )?)/);k=i&&i[1]||""}return`
|
|
34
|
+
`+k+n}var rt=!1;function J(n,i){if(!n||rt)return"";rt=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(L){var c=L}Reflect.construct(n,[],i)}else{try{i.call()}catch(L){c=L}n.call(i.prototype)}else{try{throw Error()}catch(L){c=L}n()}}catch(L){if(L&&c&&typeof L.stack=="string"){for(var d=L.stack.split(`
|
|
35
|
+
`),m=c.stack.split(`
|
|
36
|
+
`),_=d.length-1,b=m.length-1;1<=_&&0<=b&&d[_]!==m[b];)b--;for(;1<=_&&0<=b;_--,b--)if(d[_]!==m[b]){if(_!==1||b!==1)do if(_--,b--,0>b||d[_]!==m[b]){var C=`
|
|
37
|
+
`+d[_].replace(" at new "," at ");return n.displayName&&C.includes("<anonymous>")&&(C=C.replace("<anonymous>",n.displayName)),C}while(1<=_&&0<=b);break}}}finally{rt=!1,Error.prepareStackTrace=o}return(n=n?n.displayName||n.name:"")?D(n):""}function wt(n){switch(n.tag){case 5:return D(n.type);case 16:return D("Lazy");case 13:return D("Suspense");case 19:return D("SuspenseList");case 0:case 2:case 15:return n=J(n.type,!1),n;case 11:return n=J(n.type.render,!1),n;case 1:return n=J(n.type,!0),n;default:return""}}function dt(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case F:return"Fragment";case H:return"Portal";case Y:return"Profiler";case G:return"StrictMode";case mt:return"Suspense";case yt:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case V:return(n.displayName||"Context")+".Consumer";case $:return(n._context.displayName||"Context")+".Provider";case at:var i=n.render;return n=n.displayName,n||(n=i.displayName||i.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case kt:return i=n.displayName||null,i!==null?i:dt(n.type)||"Memo";case K:i=n._payload,n=n._init;try{return dt(n(i))}catch{}}return null}function ut(n){var i=n.type;switch(n.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=i.render,n=n.displayName||n.name||"",i.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return dt(i);case 8:return i===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function Et(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Mt(n){var i=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function he(n){var i=Mt(n)?"checked":"value",o=Object.getOwnPropertyDescriptor(n.constructor.prototype,i),c=""+n[i];if(!n.hasOwnProperty(i)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,m=o.set;return Object.defineProperty(n,i,{configurable:!0,get:function(){return d.call(this)},set:function(_){c=""+_,m.call(this,_)}}),Object.defineProperty(n,i,{enumerable:o.enumerable}),{getValue:function(){return c},setValue:function(_){c=""+_},stopTracking:function(){n._valueTracker=null,delete n[i]}}}}function Rs(n){n._valueTracker||(n._valueTracker=he(n))}function zl(n){if(!n)return!1;var i=n._valueTracker;if(!i)return!0;var o=i.getValue(),c="";return n&&(c=Mt(n)?n.checked?"true":"false":n.value),n=c,n!==o?(i.setValue(n),!0):!1}function Ms(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function ro(n,i){var o=i.checked;return z({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??n._wrapperState.initialChecked})}function jl(n,i){var o=i.defaultValue==null?"":i.defaultValue,c=i.checked!=null?i.checked:i.defaultChecked;o=Et(i.value!=null?i.value:o),n._wrapperState={initialChecked:c,initialValue:o,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function Bl(n,i){i=i.checked,i!=null&&I(n,"checked",i,!1)}function oo(n,i){Bl(n,i);var o=Et(i.value),c=i.type;if(o!=null)c==="number"?(o===0&&n.value===""||n.value!=o)&&(n.value=""+o):n.value!==""+o&&(n.value=""+o);else if(c==="submit"||c==="reset"){n.removeAttribute("value");return}i.hasOwnProperty("value")?ao(n,i.type,o):i.hasOwnProperty("defaultValue")&&ao(n,i.type,Et(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(n.defaultChecked=!!i.defaultChecked)}function Hl(n,i,o){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var c=i.type;if(!(c!=="submit"&&c!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+n._wrapperState.initialValue,o||i===n.value||(n.value=i),n.defaultValue=i}o=n.name,o!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,o!==""&&(n.name=o)}function ao(n,i,o){(i!=="number"||Ms(n.ownerDocument)!==n)&&(o==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+o&&(n.defaultValue=""+o))}var Ri=Array.isArray;function ei(n,i,o,c){if(n=n.options,i){i={};for(var d=0;d<o.length;d++)i["$"+o[d]]=!0;for(o=0;o<n.length;o++)d=i.hasOwnProperty("$"+n[o].value),n[o].selected!==d&&(n[o].selected=d),d&&c&&(n[o].defaultSelected=!0)}else{for(o=""+Et(o),i=null,d=0;d<n.length;d++){if(n[d].value===o){n[d].selected=!0,c&&(n[d].defaultSelected=!0);return}i!==null||n[d].disabled||(i=n[d])}i!==null&&(i.selected=!0)}}function lo(n,i){if(i.dangerouslySetInnerHTML!=null)throw Error(e(91));return z({},i,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function Ul(n,i){var o=i.value;if(o==null){if(o=i.children,i=i.defaultValue,o!=null){if(i!=null)throw Error(e(92));if(Ri(o)){if(1<o.length)throw Error(e(93));o=o[0]}i=o}i==null&&(i=""),o=i}n._wrapperState={initialValue:Et(o)}}function $l(n,i){var o=Et(i.value),c=Et(i.defaultValue);o!=null&&(o=""+o,o!==n.value&&(n.value=o),i.defaultValue==null&&n.defaultValue!==o&&(n.defaultValue=o)),c!=null&&(n.defaultValue=""+c)}function Wl(n){var i=n.textContent;i===n._wrapperState.initialValue&&i!==""&&i!==null&&(n.value=i)}function Vl(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function uo(n,i){return n==null||n==="http://www.w3.org/1999/xhtml"?Vl(i):n==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var Ls,Gl=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,o,c,d){MSApp.execUnsafeLocalFunction(function(){return n(i,o,c,d)})}:n})(function(n,i){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=i;else{for(Ls=Ls||document.createElement("div"),Ls.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=Ls.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;i.firstChild;)n.appendChild(i.firstChild)}});function Mi(n,i){if(i){var o=n.firstChild;if(o&&o===n.lastChild&&o.nodeType===3){o.nodeValue=i;return}}n.textContent=i}var Li={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},jd=["Webkit","ms","Moz","O"];Object.keys(Li).forEach(function(n){jd.forEach(function(i){i=i+n.charAt(0).toUpperCase()+n.substring(1),Li[i]=Li[n]})});function Xl(n,i,o){return i==null||typeof i=="boolean"||i===""?"":o||typeof i!="number"||i===0||Li.hasOwnProperty(n)&&Li[n]?(""+i).trim():i+"px"}function ql(n,i){n=n.style;for(var o in i)if(i.hasOwnProperty(o)){var c=o.indexOf("--")===0,d=Xl(o,i[o],c);o==="float"&&(o="cssFloat"),c?n.setProperty(o,d):n[o]=d}}var Bd=z({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function co(n,i){if(i){if(Bd[n]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(e(137,n));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(e(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(e(61))}if(i.style!=null&&typeof i.style!="object")throw Error(e(62))}}function ho(n,i){if(n.indexOf("-")===-1)return typeof i.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var fo=null;function po(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var go=null,ni=null,ii=null;function Yl(n){if(n=ts(n)){if(typeof go!="function")throw Error(e(280));var i=n.stateNode;i&&(i=er(i),go(n.stateNode,n.type,i))}}function Kl(n){ni?ii?ii.push(n):ii=[n]:ni=n}function Ql(){if(ni){var n=ni,i=ii;if(ii=ni=null,Yl(n),i)for(n=0;n<i.length;n++)Yl(i[n])}}function Zl(n,i){return n(i)}function Jl(){}var mo=!1;function tu(n,i,o){if(mo)return n(i,o);mo=!0;try{return Zl(n,i,o)}finally{mo=!1,(ni!==null||ii!==null)&&(Jl(),Ql())}}function Ii(n,i){var o=n.stateNode;if(o===null)return null;var c=er(o);if(c===null)return null;o=c[i];t:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(n=n.type,c=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!c;break t;default:n=!1}if(n)return null;if(o&&typeof o!="function")throw Error(e(231,i,typeof o));return o}var vo=!1;if(u)try{var Ni={};Object.defineProperty(Ni,"passive",{get:function(){vo=!0}}),window.addEventListener("test",Ni,Ni),window.removeEventListener("test",Ni,Ni)}catch{vo=!1}function Hd(n,i,o,c,d,m,_,b,C){var L=Array.prototype.slice.call(arguments,3);try{i.apply(o,L)}catch(B){this.onError(B)}}var Di=!1,Is=null,Ns=!1,yo=null,Ud={onError:function(n){Di=!0,Is=n}};function $d(n,i,o,c,d,m,_,b,C){Di=!1,Is=null,Hd.apply(Ud,arguments)}function Wd(n,i,o,c,d,m,_,b,C){if($d.apply(this,arguments),Di){if(Di){var L=Is;Di=!1,Is=null}else throw Error(e(198));Ns||(Ns=!0,yo=L)}}function zn(n){var i=n,o=n;if(n.alternate)for(;i.return;)i=i.return;else{n=i;do i=n,(i.flags&4098)!==0&&(o=i.return),n=i.return;while(n)}return i.tag===3?o:null}function eu(n){if(n.tag===13){var i=n.memoizedState;if(i===null&&(n=n.alternate,n!==null&&(i=n.memoizedState)),i!==null)return i.dehydrated}return null}function nu(n){if(zn(n)!==n)throw Error(e(188))}function Vd(n){var i=n.alternate;if(!i){if(i=zn(n),i===null)throw Error(e(188));return i!==n?null:n}for(var o=n,c=i;;){var d=o.return;if(d===null)break;var m=d.alternate;if(m===null){if(c=d.return,c!==null){o=c;continue}break}if(d.child===m.child){for(m=d.child;m;){if(m===o)return nu(d),n;if(m===c)return nu(d),i;m=m.sibling}throw Error(e(188))}if(o.return!==c.return)o=d,c=m;else{for(var _=!1,b=d.child;b;){if(b===o){_=!0,o=d,c=m;break}if(b===c){_=!0,c=d,o=m;break}b=b.sibling}if(!_){for(b=m.child;b;){if(b===o){_=!0,o=m,c=d;break}if(b===c){_=!0,c=m,o=d;break}b=b.sibling}if(!_)throw Error(e(189))}}if(o.alternate!==c)throw Error(e(190))}if(o.tag!==3)throw Error(e(188));return o.stateNode.current===o?n:i}function iu(n){return n=Vd(n),n!==null?su(n):null}function su(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var i=su(n);if(i!==null)return i;n=n.sibling}return null}var ru=t.unstable_scheduleCallback,ou=t.unstable_cancelCallback,Gd=t.unstable_shouldYield,Xd=t.unstable_requestPaint,Ht=t.unstable_now,qd=t.unstable_getCurrentPriorityLevel,wo=t.unstable_ImmediatePriority,au=t.unstable_UserBlockingPriority,Ds=t.unstable_NormalPriority,Yd=t.unstable_LowPriority,lu=t.unstable_IdlePriority,Fs=null,Ye=null;function Kd(n){if(Ye&&typeof Ye.onCommitFiberRoot=="function")try{Ye.onCommitFiberRoot(Fs,n,void 0,(n.current.flags&128)===128)}catch{}}var Be=Math.clz32?Math.clz32:Jd,Qd=Math.log,Zd=Math.LN2;function Jd(n){return n>>>=0,n===0?32:31-(Qd(n)/Zd|0)|0}var Os=64,zs=4194304;function Fi(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function js(n,i){var o=n.pendingLanes;if(o===0)return 0;var c=0,d=n.suspendedLanes,m=n.pingedLanes,_=o&268435455;if(_!==0){var b=_&~d;b!==0?c=Fi(b):(m&=_,m!==0&&(c=Fi(m)))}else _=o&~d,_!==0?c=Fi(_):m!==0&&(c=Fi(m));if(c===0)return 0;if(i!==0&&i!==c&&(i&d)===0&&(d=c&-c,m=i&-i,d>=m||d===16&&(m&4194240)!==0))return i;if((c&4)!==0&&(c|=o&16),i=n.entangledLanes,i!==0)for(n=n.entanglements,i&=c;0<i;)o=31-Be(i),d=1<<o,c|=n[o],i&=~d;return c}function tf(n,i){switch(n){case 1:case 2:case 4:return i+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ef(n,i){for(var o=n.suspendedLanes,c=n.pingedLanes,d=n.expirationTimes,m=n.pendingLanes;0<m;){var _=31-Be(m),b=1<<_,C=d[_];C===-1?((b&o)===0||(b&c)!==0)&&(d[_]=tf(b,i)):C<=i&&(n.expiredLanes|=b),m&=~b}}function _o(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function uu(){var n=Os;return Os<<=1,(Os&4194240)===0&&(Os=64),n}function Ao(n){for(var i=[],o=0;31>o;o++)i.push(n);return i}function Oi(n,i,o){n.pendingLanes|=i,i!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,i=31-Be(i),n[i]=o}function nf(n,i){var o=n.pendingLanes&~i;n.pendingLanes=i,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=i,n.mutableReadLanes&=i,n.entangledLanes&=i,i=n.entanglements;var c=n.eventTimes;for(n=n.expirationTimes;0<o;){var d=31-Be(o),m=1<<d;i[d]=0,c[d]=-1,n[d]=-1,o&=~m}}function So(n,i){var o=n.entangledLanes|=i;for(n=n.entanglements;o;){var c=31-Be(o),d=1<<c;d&i|n[c]&i&&(n[c]|=i),o&=~d}}var Rt=0;function cu(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var hu,bo,du,fu,pu,Eo=!1,Bs=[],pn=null,gn=null,mn=null,zi=new Map,ji=new Map,vn=[],sf="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function gu(n,i){switch(n){case"focusin":case"focusout":pn=null;break;case"dragenter":case"dragleave":gn=null;break;case"mouseover":case"mouseout":mn=null;break;case"pointerover":case"pointerout":zi.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":ji.delete(i.pointerId)}}function Bi(n,i,o,c,d,m){return n===null||n.nativeEvent!==m?(n={blockedOn:i,domEventName:o,eventSystemFlags:c,nativeEvent:m,targetContainers:[d]},i!==null&&(i=ts(i),i!==null&&bo(i)),n):(n.eventSystemFlags|=c,i=n.targetContainers,d!==null&&i.indexOf(d)===-1&&i.push(d),n)}function rf(n,i,o,c,d){switch(i){case"focusin":return pn=Bi(pn,n,i,o,c,d),!0;case"dragenter":return gn=Bi(gn,n,i,o,c,d),!0;case"mouseover":return mn=Bi(mn,n,i,o,c,d),!0;case"pointerover":var m=d.pointerId;return zi.set(m,Bi(zi.get(m)||null,n,i,o,c,d)),!0;case"gotpointercapture":return m=d.pointerId,ji.set(m,Bi(ji.get(m)||null,n,i,o,c,d)),!0}return!1}function mu(n){var i=jn(n.target);if(i!==null){var o=zn(i);if(o!==null){if(i=o.tag,i===13){if(i=eu(o),i!==null){n.blockedOn=i,pu(n.priority,function(){du(o)});return}}else if(i===3&&o.stateNode.current.memoizedState.isDehydrated){n.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Hs(n){if(n.blockedOn!==null)return!1;for(var i=n.targetContainers;0<i.length;){var o=Co(n.domEventName,n.eventSystemFlags,i[0],n.nativeEvent);if(o===null){o=n.nativeEvent;var c=new o.constructor(o.type,o);fo=c,o.target.dispatchEvent(c),fo=null}else return i=ts(o),i!==null&&bo(i),n.blockedOn=o,!1;i.shift()}return!0}function vu(n,i,o){Hs(n)&&o.delete(i)}function of(){Eo=!1,pn!==null&&Hs(pn)&&(pn=null),gn!==null&&Hs(gn)&&(gn=null),mn!==null&&Hs(mn)&&(mn=null),zi.forEach(vu),ji.forEach(vu)}function Hi(n,i){n.blockedOn===i&&(n.blockedOn=null,Eo||(Eo=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,of)))}function Ui(n){function i(d){return Hi(d,n)}if(0<Bs.length){Hi(Bs[0],n);for(var o=1;o<Bs.length;o++){var c=Bs[o];c.blockedOn===n&&(c.blockedOn=null)}}for(pn!==null&&Hi(pn,n),gn!==null&&Hi(gn,n),mn!==null&&Hi(mn,n),zi.forEach(i),ji.forEach(i),o=0;o<vn.length;o++)c=vn[o],c.blockedOn===n&&(c.blockedOn=null);for(;0<vn.length&&(o=vn[0],o.blockedOn===null);)mu(o),o.blockedOn===null&&vn.shift()}var si=N.ReactCurrentBatchConfig,Us=!0;function af(n,i,o,c){var d=Rt,m=si.transition;si.transition=null;try{Rt=1,xo(n,i,o,c)}finally{Rt=d,si.transition=m}}function lf(n,i,o,c){var d=Rt,m=si.transition;si.transition=null;try{Rt=4,xo(n,i,o,c)}finally{Rt=d,si.transition=m}}function xo(n,i,o,c){if(Us){var d=Co(n,i,o,c);if(d===null)$o(n,i,c,$s,o),gu(n,c);else if(rf(d,n,i,o,c))c.stopPropagation();else if(gu(n,c),i&4&&-1<sf.indexOf(n)){for(;d!==null;){var m=ts(d);if(m!==null&&hu(m),m=Co(n,i,o,c),m===null&&$o(n,i,c,$s,o),m===d)break;d=m}d!==null&&c.stopPropagation()}else $o(n,i,c,null,o)}}var $s=null;function Co(n,i,o,c){if($s=null,n=po(c),n=jn(n),n!==null)if(i=zn(n),i===null)n=null;else if(o=i.tag,o===13){if(n=eu(i),n!==null)return n;n=null}else if(o===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;n=null}else i!==n&&(n=null);return $s=n,null}function yu(n){switch(n){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(qd()){case wo:return 1;case au:return 4;case Ds:case Yd:return 16;case lu:return 536870912;default:return 16}default:return 16}}var yn=null,ko=null,Ws=null;function wu(){if(Ws)return Ws;var n,i=ko,o=i.length,c,d="value"in yn?yn.value:yn.textContent,m=d.length;for(n=0;n<o&&i[n]===d[n];n++);var _=o-n;for(c=1;c<=_&&i[o-c]===d[m-c];c++);return Ws=d.slice(n,1<c?1-c:void 0)}function Vs(n){var i=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&i===13&&(n=13)):n=i,n===10&&(n=13),32<=n||n===13?n:0}function Gs(){return!0}function _u(){return!1}function Ce(n){function i(o,c,d,m,_){this._reactName=o,this._targetInst=d,this.type=c,this.nativeEvent=m,this.target=_,this.currentTarget=null;for(var b in n)n.hasOwnProperty(b)&&(o=n[b],this[b]=o?o(m):m[b]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?Gs:_u,this.isPropagationStopped=_u,this}return z(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=Gs)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=Gs)},persist:function(){},isPersistent:Gs}),i}var ri={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},To=Ce(ri),$i=z({},ri,{view:0,detail:0}),uf=Ce($i),Po,Ro,Wi,Xs=z({},$i,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Lo,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==Wi&&(Wi&&n.type==="mousemove"?(Po=n.screenX-Wi.screenX,Ro=n.screenY-Wi.screenY):Ro=Po=0,Wi=n),Po)},movementY:function(n){return"movementY"in n?n.movementY:Ro}}),Au=Ce(Xs),cf=z({},Xs,{dataTransfer:0}),hf=Ce(cf),df=z({},$i,{relatedTarget:0}),Mo=Ce(df),ff=z({},ri,{animationName:0,elapsedTime:0,pseudoElement:0}),pf=Ce(ff),gf=z({},ri,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),mf=Ce(gf),vf=z({},ri,{data:0}),Su=Ce(vf),yf={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},wf={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},_f={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Af(n){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(n):(n=_f[n])?!!i[n]:!1}function Lo(){return Af}var Sf=z({},$i,{key:function(n){if(n.key){var i=yf[n.key]||n.key;if(i!=="Unidentified")return i}return n.type==="keypress"?(n=Vs(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?wf[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Lo,charCode:function(n){return n.type==="keypress"?Vs(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Vs(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),bf=Ce(Sf),Ef=z({},Xs,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),bu=Ce(Ef),xf=z({},$i,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Lo}),Cf=Ce(xf),kf=z({},ri,{propertyName:0,elapsedTime:0,pseudoElement:0}),Tf=Ce(kf),Pf=z({},Xs,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),Rf=Ce(Pf),Mf=[9,13,27,32],Io=u&&"CompositionEvent"in window,Vi=null;u&&"documentMode"in document&&(Vi=document.documentMode);var Lf=u&&"TextEvent"in window&&!Vi,Eu=u&&(!Io||Vi&&8<Vi&&11>=Vi),xu=" ",Cu=!1;function ku(n,i){switch(n){case"keyup":return Mf.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Tu(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var oi=!1;function If(n,i){switch(n){case"compositionend":return Tu(i);case"keypress":return i.which!==32?null:(Cu=!0,xu);case"textInput":return n=i.data,n===xu&&Cu?null:n;default:return null}}function Nf(n,i){if(oi)return n==="compositionend"||!Io&&ku(n,i)?(n=wu(),Ws=ko=yn=null,oi=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return Eu&&i.locale!=="ko"?null:i.data;default:return null}}var Df={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Pu(n){var i=n&&n.nodeName&&n.nodeName.toLowerCase();return i==="input"?!!Df[n.type]:i==="textarea"}function Ru(n,i,o,c){Kl(c),i=Zs(i,"onChange"),0<i.length&&(o=new To("onChange","change",null,o,c),n.push({event:o,listeners:i}))}var Gi=null,Xi=null;function Ff(n){qu(n,0)}function qs(n){var i=hi(n);if(zl(i))return n}function Of(n,i){if(n==="change")return i}var Mu=!1;if(u){var No;if(u){var Do="oninput"in document;if(!Do){var Lu=document.createElement("div");Lu.setAttribute("oninput","return;"),Do=typeof Lu.oninput=="function"}No=Do}else No=!1;Mu=No&&(!document.documentMode||9<document.documentMode)}function Iu(){Gi&&(Gi.detachEvent("onpropertychange",Nu),Xi=Gi=null)}function Nu(n){if(n.propertyName==="value"&&qs(Xi)){var i=[];Ru(i,Xi,n,po(n)),tu(Ff,i)}}function zf(n,i,o){n==="focusin"?(Iu(),Gi=i,Xi=o,Gi.attachEvent("onpropertychange",Nu)):n==="focusout"&&Iu()}function jf(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return qs(Xi)}function Bf(n,i){if(n==="click")return qs(i)}function Hf(n,i){if(n==="input"||n==="change")return qs(i)}function Uf(n,i){return n===i&&(n!==0||1/n===1/i)||n!==n&&i!==i}var He=typeof Object.is=="function"?Object.is:Uf;function qi(n,i){if(He(n,i))return!0;if(typeof n!="object"||n===null||typeof i!="object"||i===null)return!1;var o=Object.keys(n),c=Object.keys(i);if(o.length!==c.length)return!1;for(c=0;c<o.length;c++){var d=o[c];if(!h.call(i,d)||!He(n[d],i[d]))return!1}return!0}function Du(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Fu(n,i){var o=Du(n);n=0;for(var c;o;){if(o.nodeType===3){if(c=n+o.textContent.length,n<=i&&c>=i)return{node:o,offset:i-n};n=c}t:{for(;o;){if(o.nextSibling){o=o.nextSibling;break t}o=o.parentNode}o=void 0}o=Du(o)}}function Ou(n,i){return n&&i?n===i?!0:n&&n.nodeType===3?!1:i&&i.nodeType===3?Ou(n,i.parentNode):"contains"in n?n.contains(i):n.compareDocumentPosition?!!(n.compareDocumentPosition(i)&16):!1:!1}function zu(){for(var n=window,i=Ms();i instanceof n.HTMLIFrameElement;){try{var o=typeof i.contentWindow.location.href=="string"}catch{o=!1}if(o)n=i.contentWindow;else break;i=Ms(n.document)}return i}function Fo(n){var i=n&&n.nodeName&&n.nodeName.toLowerCase();return i&&(i==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||i==="textarea"||n.contentEditable==="true")}function $f(n){var i=zu(),o=n.focusedElem,c=n.selectionRange;if(i!==o&&o&&o.ownerDocument&&Ou(o.ownerDocument.documentElement,o)){if(c!==null&&Fo(o)){if(i=c.start,n=c.end,n===void 0&&(n=i),"selectionStart"in o)o.selectionStart=i,o.selectionEnd=Math.min(n,o.value.length);else if(n=(i=o.ownerDocument||document)&&i.defaultView||window,n.getSelection){n=n.getSelection();var d=o.textContent.length,m=Math.min(c.start,d);c=c.end===void 0?m:Math.min(c.end,d),!n.extend&&m>c&&(d=c,c=m,m=d),d=Fu(o,m);var _=Fu(o,c);d&&_&&(n.rangeCount!==1||n.anchorNode!==d.node||n.anchorOffset!==d.offset||n.focusNode!==_.node||n.focusOffset!==_.offset)&&(i=i.createRange(),i.setStart(d.node,d.offset),n.removeAllRanges(),m>c?(n.addRange(i),n.extend(_.node,_.offset)):(i.setEnd(_.node,_.offset),n.addRange(i)))}}for(i=[],n=o;n=n.parentNode;)n.nodeType===1&&i.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o<i.length;o++)n=i[o],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var Wf=u&&"documentMode"in document&&11>=document.documentMode,ai=null,Oo=null,Yi=null,zo=!1;function ju(n,i,o){var c=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;zo||ai==null||ai!==Ms(c)||(c=ai,"selectionStart"in c&&Fo(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Yi&&qi(Yi,c)||(Yi=c,c=Zs(Oo,"onSelect"),0<c.length&&(i=new To("onSelect","select",null,i,o),n.push({event:i,listeners:c}),i.target=ai)))}function Ys(n,i){var o={};return o[n.toLowerCase()]=i.toLowerCase(),o["Webkit"+n]="webkit"+i,o["Moz"+n]="moz"+i,o}var li={animationend:Ys("Animation","AnimationEnd"),animationiteration:Ys("Animation","AnimationIteration"),animationstart:Ys("Animation","AnimationStart"),transitionend:Ys("Transition","TransitionEnd")},jo={},Bu={};u&&(Bu=document.createElement("div").style,"AnimationEvent"in window||(delete li.animationend.animation,delete li.animationiteration.animation,delete li.animationstart.animation),"TransitionEvent"in window||delete li.transitionend.transition);function Ks(n){if(jo[n])return jo[n];if(!li[n])return n;var i=li[n],o;for(o in i)if(i.hasOwnProperty(o)&&o in Bu)return jo[n]=i[o];return n}var Hu=Ks("animationend"),Uu=Ks("animationiteration"),$u=Ks("animationstart"),Wu=Ks("transitionend"),Vu=new Map,Gu="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function wn(n,i){Vu.set(n,i),a(i,[n])}for(var Bo=0;Bo<Gu.length;Bo++){var Ho=Gu[Bo],Vf=Ho.toLowerCase(),Gf=Ho[0].toUpperCase()+Ho.slice(1);wn(Vf,"on"+Gf)}wn(Hu,"onAnimationEnd"),wn(Uu,"onAnimationIteration"),wn($u,"onAnimationStart"),wn("dblclick","onDoubleClick"),wn("focusin","onFocus"),wn("focusout","onBlur"),wn(Wu,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ki="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Xf=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ki));function Xu(n,i,o){var c=n.type||"unknown-event";n.currentTarget=o,Wd(c,i,void 0,n),n.currentTarget=null}function qu(n,i){i=(i&4)!==0;for(var o=0;o<n.length;o++){var c=n[o],d=c.event;c=c.listeners;t:{var m=void 0;if(i)for(var _=c.length-1;0<=_;_--){var b=c[_],C=b.instance,L=b.currentTarget;if(b=b.listener,C!==m&&d.isPropagationStopped())break t;Xu(d,b,L),m=C}else for(_=0;_<c.length;_++){if(b=c[_],C=b.instance,L=b.currentTarget,b=b.listener,C!==m&&d.isPropagationStopped())break t;Xu(d,b,L),m=C}}}if(Ns)throw n=yo,Ns=!1,yo=null,n}function Nt(n,i){var o=i[Yo];o===void 0&&(o=i[Yo]=new Set);var c=n+"__bubble";o.has(c)||(Yu(i,n,2,!1),o.add(c))}function Uo(n,i,o){var c=0;i&&(c|=4),Yu(o,n,c,i)}var Qs="_reactListening"+Math.random().toString(36).slice(2);function Qi(n){if(!n[Qs]){n[Qs]=!0,s.forEach(function(o){o!=="selectionchange"&&(Xf.has(o)||Uo(o,!1,n),Uo(o,!0,n))});var i=n.nodeType===9?n:n.ownerDocument;i===null||i[Qs]||(i[Qs]=!0,Uo("selectionchange",!1,i))}}function Yu(n,i,o,c){switch(yu(i)){case 1:var d=af;break;case 4:d=lf;break;default:d=xo}o=d.bind(null,i,o,n),d=void 0,!vo||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(d=!0),c?d!==void 0?n.addEventListener(i,o,{capture:!0,passive:d}):n.addEventListener(i,o,!0):d!==void 0?n.addEventListener(i,o,{passive:d}):n.addEventListener(i,o,!1)}function $o(n,i,o,c,d){var m=c;if((i&1)===0&&(i&2)===0&&c!==null)t:for(;;){if(c===null)return;var _=c.tag;if(_===3||_===4){var b=c.stateNode.containerInfo;if(b===d||b.nodeType===8&&b.parentNode===d)break;if(_===4)for(_=c.return;_!==null;){var C=_.tag;if((C===3||C===4)&&(C=_.stateNode.containerInfo,C===d||C.nodeType===8&&C.parentNode===d))return;_=_.return}for(;b!==null;){if(_=jn(b),_===null)return;if(C=_.tag,C===5||C===6){c=m=_;continue t}b=b.parentNode}}c=c.return}tu(function(){var L=m,B=po(o),U=[];t:{var j=Vu.get(n);if(j!==void 0){var Z=To,nt=n;switch(n){case"keypress":if(Vs(o)===0)break t;case"keydown":case"keyup":Z=bf;break;case"focusin":nt="focus",Z=Mo;break;case"focusout":nt="blur",Z=Mo;break;case"beforeblur":case"afterblur":Z=Mo;break;case"click":if(o.button===2)break t;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Z=Au;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=hf;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=Cf;break;case Hu:case Uu:case $u:Z=pf;break;case Wu:Z=Tf;break;case"scroll":Z=uf;break;case"wheel":Z=Rf;break;case"copy":case"cut":case"paste":Z=mf;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=bu}var st=(i&4)!==0,Ut=!st&&n==="scroll",P=st?j!==null?j+"Capture":null:j;st=[];for(var T=L,R;T!==null;){R=T;var X=R.stateNode;if(R.tag===5&&X!==null&&(R=X,P!==null&&(X=Ii(T,P),X!=null&&st.push(Zi(T,X,R)))),Ut)break;T=T.return}0<st.length&&(j=new Z(j,nt,null,o,B),U.push({event:j,listeners:st}))}}if((i&7)===0){t:{if(j=n==="mouseover"||n==="pointerover",Z=n==="mouseout"||n==="pointerout",j&&o!==fo&&(nt=o.relatedTarget||o.fromElement)&&(jn(nt)||nt[sn]))break t;if((Z||j)&&(j=B.window===B?B:(j=B.ownerDocument)?j.defaultView||j.parentWindow:window,Z?(nt=o.relatedTarget||o.toElement,Z=L,nt=nt?jn(nt):null,nt!==null&&(Ut=zn(nt),nt!==Ut||nt.tag!==5&&nt.tag!==6)&&(nt=null)):(Z=null,nt=L),Z!==nt)){if(st=Au,X="onMouseLeave",P="onMouseEnter",T="mouse",(n==="pointerout"||n==="pointerover")&&(st=bu,X="onPointerLeave",P="onPointerEnter",T="pointer"),Ut=Z==null?j:hi(Z),R=nt==null?j:hi(nt),j=new st(X,T+"leave",Z,o,B),j.target=Ut,j.relatedTarget=R,X=null,jn(B)===L&&(st=new st(P,T+"enter",nt,o,B),st.target=R,st.relatedTarget=Ut,X=st),Ut=X,Z&&nt)e:{for(st=Z,P=nt,T=0,R=st;R;R=ui(R))T++;for(R=0,X=P;X;X=ui(X))R++;for(;0<T-R;)st=ui(st),T--;for(;0<R-T;)P=ui(P),R--;for(;T--;){if(st===P||P!==null&&st===P.alternate)break e;st=ui(st),P=ui(P)}st=null}else st=null;Z!==null&&Ku(U,j,Z,st,!1),nt!==null&&Ut!==null&&Ku(U,Ut,nt,st,!0)}}t:{if(j=L?hi(L):window,Z=j.nodeName&&j.nodeName.toLowerCase(),Z==="select"||Z==="input"&&j.type==="file")var ot=Of;else if(Pu(j))if(Mu)ot=Hf;else{ot=jf;var ct=zf}else(Z=j.nodeName)&&Z.toLowerCase()==="input"&&(j.type==="checkbox"||j.type==="radio")&&(ot=Bf);if(ot&&(ot=ot(n,L))){Ru(U,ot,o,B);break t}ct&&ct(n,j,L),n==="focusout"&&(ct=j._wrapperState)&&ct.controlled&&j.type==="number"&&ao(j,"number",j.value)}switch(ct=L?hi(L):window,n){case"focusin":(Pu(ct)||ct.contentEditable==="true")&&(ai=ct,Oo=L,Yi=null);break;case"focusout":Yi=Oo=ai=null;break;case"mousedown":zo=!0;break;case"contextmenu":case"mouseup":case"dragend":zo=!1,ju(U,o,B);break;case"selectionchange":if(Wf)break;case"keydown":case"keyup":ju(U,o,B)}var ht;if(Io)t:{switch(n){case"compositionstart":var gt="onCompositionStart";break t;case"compositionend":gt="onCompositionEnd";break t;case"compositionupdate":gt="onCompositionUpdate";break t}gt=void 0}else oi?ku(n,o)&&(gt="onCompositionEnd"):n==="keydown"&&o.keyCode===229&&(gt="onCompositionStart");gt&&(Eu&&o.locale!=="ko"&&(oi||gt!=="onCompositionStart"?gt==="onCompositionEnd"&&oi&&(ht=wu()):(yn=B,ko="value"in yn?yn.value:yn.textContent,oi=!0)),ct=Zs(L,gt),0<ct.length&&(gt=new Su(gt,n,null,o,B),U.push({event:gt,listeners:ct}),ht?gt.data=ht:(ht=Tu(o),ht!==null&&(gt.data=ht)))),(ht=Lf?If(n,o):Nf(n,o))&&(L=Zs(L,"onBeforeInput"),0<L.length&&(B=new Su("onBeforeInput","beforeinput",null,o,B),U.push({event:B,listeners:L}),B.data=ht))}qu(U,i)})}function Zi(n,i,o){return{instance:n,listener:i,currentTarget:o}}function Zs(n,i){for(var o=i+"Capture",c=[];n!==null;){var d=n,m=d.stateNode;d.tag===5&&m!==null&&(d=m,m=Ii(n,o),m!=null&&c.unshift(Zi(n,m,d)),m=Ii(n,i),m!=null&&c.push(Zi(n,m,d))),n=n.return}return c}function ui(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function Ku(n,i,o,c,d){for(var m=i._reactName,_=[];o!==null&&o!==c;){var b=o,C=b.alternate,L=b.stateNode;if(C!==null&&C===c)break;b.tag===5&&L!==null&&(b=L,d?(C=Ii(o,m),C!=null&&_.unshift(Zi(o,C,b))):d||(C=Ii(o,m),C!=null&&_.push(Zi(o,C,b)))),o=o.return}_.length!==0&&n.push({event:i,listeners:_})}var qf=/\r\n?/g,Yf=/\u0000|\uFFFD/g;function Qu(n){return(typeof n=="string"?n:""+n).replace(qf,`
|
|
38
|
+
`).replace(Yf,"")}function Js(n,i,o){if(i=Qu(i),Qu(n)!==i&&o)throw Error(e(425))}function tr(){}var Wo=null,Vo=null;function Go(n,i){return n==="textarea"||n==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Xo=typeof setTimeout=="function"?setTimeout:void 0,Kf=typeof clearTimeout=="function"?clearTimeout:void 0,Zu=typeof Promise=="function"?Promise:void 0,Qf=typeof queueMicrotask=="function"?queueMicrotask:typeof Zu<"u"?function(n){return Zu.resolve(null).then(n).catch(Zf)}:Xo;function Zf(n){setTimeout(function(){throw n})}function qo(n,i){var o=i,c=0;do{var d=o.nextSibling;if(n.removeChild(o),d&&d.nodeType===8)if(o=d.data,o==="/$"){if(c===0){n.removeChild(d),Ui(i);return}c--}else o!=="$"&&o!=="$?"&&o!=="$!"||c++;o=d}while(o);Ui(i)}function _n(n){for(;n!=null;n=n.nextSibling){var i=n.nodeType;if(i===1||i===3)break;if(i===8){if(i=n.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return n}function Ju(n){n=n.previousSibling;for(var i=0;n;){if(n.nodeType===8){var o=n.data;if(o==="$"||o==="$!"||o==="$?"){if(i===0)return n;i--}else o==="/$"&&i++}n=n.previousSibling}return null}var ci=Math.random().toString(36).slice(2),Ke="__reactFiber$"+ci,Ji="__reactProps$"+ci,sn="__reactContainer$"+ci,Yo="__reactEvents$"+ci,Jf="__reactListeners$"+ci,tp="__reactHandles$"+ci;function jn(n){var i=n[Ke];if(i)return i;for(var o=n.parentNode;o;){if(i=o[sn]||o[Ke]){if(o=i.alternate,i.child!==null||o!==null&&o.child!==null)for(n=Ju(n);n!==null;){if(o=n[Ke])return o;n=Ju(n)}return i}n=o,o=n.parentNode}return null}function ts(n){return n=n[Ke]||n[sn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function hi(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(e(33))}function er(n){return n[Ji]||null}var Ko=[],di=-1;function An(n){return{current:n}}function Dt(n){0>di||(n.current=Ko[di],Ko[di]=null,di--)}function It(n,i){di++,Ko[di]=n.current,n.current=i}var Sn={},se=An(Sn),ve=An(!1),Bn=Sn;function fi(n,i){var o=n.type.contextTypes;if(!o)return Sn;var c=n.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===i)return c.__reactInternalMemoizedMaskedChildContext;var d={},m;for(m in o)d[m]=i[m];return c&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=i,n.__reactInternalMemoizedMaskedChildContext=d),d}function ye(n){return n=n.childContextTypes,n!=null}function nr(){Dt(ve),Dt(se)}function tc(n,i,o){if(se.current!==Sn)throw Error(e(168));It(se,i),It(ve,o)}function ec(n,i,o){var c=n.stateNode;if(i=i.childContextTypes,typeof c.getChildContext!="function")return o;c=c.getChildContext();for(var d in c)if(!(d in i))throw Error(e(108,ut(n)||"Unknown",d));return z({},o,c)}function ir(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Sn,Bn=se.current,It(se,n),It(ve,ve.current),!0}function nc(n,i,o){var c=n.stateNode;if(!c)throw Error(e(169));o?(n=ec(n,i,Bn),c.__reactInternalMemoizedMergedChildContext=n,Dt(ve),Dt(se),It(se,n)):Dt(ve),It(ve,o)}var rn=null,sr=!1,Qo=!1;function ic(n){rn===null?rn=[n]:rn.push(n)}function ep(n){sr=!0,ic(n)}function bn(){if(!Qo&&rn!==null){Qo=!0;var n=0,i=Rt;try{var o=rn;for(Rt=1;n<o.length;n++){var c=o[n];do c=c(!0);while(c!==null)}rn=null,sr=!1}catch(d){throw rn!==null&&(rn=rn.slice(n+1)),ru(wo,bn),d}finally{Rt=i,Qo=!1}}return null}var pi=[],gi=0,rr=null,or=0,Le=[],Ie=0,Hn=null,on=1,an="";function Un(n,i){pi[gi++]=or,pi[gi++]=rr,rr=n,or=i}function sc(n,i,o){Le[Ie++]=on,Le[Ie++]=an,Le[Ie++]=Hn,Hn=n;var c=on;n=an;var d=32-Be(c)-1;c&=~(1<<d),o+=1;var m=32-Be(i)+d;if(30<m){var _=d-d%5;m=(c&(1<<_)-1).toString(32),c>>=_,d-=_,on=1<<32-Be(i)+d|o<<d|c,an=m+n}else on=1<<m|o<<d|c,an=n}function Zo(n){n.return!==null&&(Un(n,1),sc(n,1,0))}function Jo(n){for(;n===rr;)rr=pi[--gi],pi[gi]=null,or=pi[--gi],pi[gi]=null;for(;n===Hn;)Hn=Le[--Ie],Le[Ie]=null,an=Le[--Ie],Le[Ie]=null,on=Le[--Ie],Le[Ie]=null}var ke=null,Te=null,Ft=!1,Ue=null;function rc(n,i){var o=Oe(5,null,null,0);o.elementType="DELETED",o.stateNode=i,o.return=n,i=n.deletions,i===null?(n.deletions=[o],n.flags|=16):i.push(o)}function oc(n,i){switch(n.tag){case 5:var o=n.type;return i=i.nodeType!==1||o.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(n.stateNode=i,ke=n,Te=_n(i.firstChild),!0):!1;case 6:return i=n.pendingProps===""||i.nodeType!==3?null:i,i!==null?(n.stateNode=i,ke=n,Te=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(o=Hn!==null?{id:on,overflow:an}:null,n.memoizedState={dehydrated:i,treeContext:o,retryLane:1073741824},o=Oe(18,null,null,0),o.stateNode=i,o.return=n,n.child=o,ke=n,Te=null,!0):!1;default:return!1}}function ta(n){return(n.mode&1)!==0&&(n.flags&128)===0}function ea(n){if(Ft){var i=Te;if(i){var o=i;if(!oc(n,i)){if(ta(n))throw Error(e(418));i=_n(o.nextSibling);var c=ke;i&&oc(n,i)?rc(c,o):(n.flags=n.flags&-4097|2,Ft=!1,ke=n)}}else{if(ta(n))throw Error(e(418));n.flags=n.flags&-4097|2,Ft=!1,ke=n}}}function ac(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;ke=n}function ar(n){if(n!==ke)return!1;if(!Ft)return ac(n),Ft=!0,!1;var i;if((i=n.tag!==3)&&!(i=n.tag!==5)&&(i=n.type,i=i!=="head"&&i!=="body"&&!Go(n.type,n.memoizedProps)),i&&(i=Te)){if(ta(n))throw lc(),Error(e(418));for(;i;)rc(n,i),i=_n(i.nextSibling)}if(ac(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(e(317));t:{for(n=n.nextSibling,i=0;n;){if(n.nodeType===8){var o=n.data;if(o==="/$"){if(i===0){Te=_n(n.nextSibling);break t}i--}else o!=="$"&&o!=="$!"&&o!=="$?"||i++}n=n.nextSibling}Te=null}}else Te=ke?_n(n.stateNode.nextSibling):null;return!0}function lc(){for(var n=Te;n;)n=_n(n.nextSibling)}function mi(){Te=ke=null,Ft=!1}function na(n){Ue===null?Ue=[n]:Ue.push(n)}var np=N.ReactCurrentBatchConfig;function es(n,i,o){if(n=o.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(o._owner){if(o=o._owner,o){if(o.tag!==1)throw Error(e(309));var c=o.stateNode}if(!c)throw Error(e(147,n));var d=c,m=""+n;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===m?i.ref:(i=function(_){var b=d.refs;_===null?delete b[m]:b[m]=_},i._stringRef=m,i)}if(typeof n!="string")throw Error(e(284));if(!o._owner)throw Error(e(290,n))}return n}function lr(n,i){throw n=Object.prototype.toString.call(i),Error(e(31,n==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":n))}function uc(n){var i=n._init;return i(n._payload)}function cc(n){function i(P,T){if(n){var R=P.deletions;R===null?(P.deletions=[T],P.flags|=16):R.push(T)}}function o(P,T){if(!n)return null;for(;T!==null;)i(P,T),T=T.sibling;return null}function c(P,T){for(P=new Map;T!==null;)T.key!==null?P.set(T.key,T):P.set(T.index,T),T=T.sibling;return P}function d(P,T){return P=Mn(P,T),P.index=0,P.sibling=null,P}function m(P,T,R){return P.index=R,n?(R=P.alternate,R!==null?(R=R.index,R<T?(P.flags|=2,T):R):(P.flags|=2,T)):(P.flags|=1048576,T)}function _(P){return n&&P.alternate===null&&(P.flags|=2),P}function b(P,T,R,X){return T===null||T.tag!==6?(T=Xa(R,P.mode,X),T.return=P,T):(T=d(T,R),T.return=P,T)}function C(P,T,R,X){var ot=R.type;return ot===F?B(P,T,R.props.children,X,R.key):T!==null&&(T.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===K&&uc(ot)===T.type)?(X=d(T,R.props),X.ref=es(P,T,R),X.return=P,X):(X=Lr(R.type,R.key,R.props,null,P.mode,X),X.ref=es(P,T,R),X.return=P,X)}function L(P,T,R,X){return T===null||T.tag!==4||T.stateNode.containerInfo!==R.containerInfo||T.stateNode.implementation!==R.implementation?(T=qa(R,P.mode,X),T.return=P,T):(T=d(T,R.children||[]),T.return=P,T)}function B(P,T,R,X,ot){return T===null||T.tag!==7?(T=Kn(R,P.mode,X,ot),T.return=P,T):(T=d(T,R),T.return=P,T)}function U(P,T,R){if(typeof T=="string"&&T!==""||typeof T=="number")return T=Xa(""+T,P.mode,R),T.return=P,T;if(typeof T=="object"&&T!==null){switch(T.$$typeof){case O:return R=Lr(T.type,T.key,T.props,null,P.mode,R),R.ref=es(P,null,T),R.return=P,R;case H:return T=qa(T,P.mode,R),T.return=P,T;case K:var X=T._init;return U(P,X(T._payload),R)}if(Ri(T)||it(T))return T=Kn(T,P.mode,R,null),T.return=P,T;lr(P,T)}return null}function j(P,T,R,X){var ot=T!==null?T.key:null;if(typeof R=="string"&&R!==""||typeof R=="number")return ot!==null?null:b(P,T,""+R,X);if(typeof R=="object"&&R!==null){switch(R.$$typeof){case O:return R.key===ot?C(P,T,R,X):null;case H:return R.key===ot?L(P,T,R,X):null;case K:return ot=R._init,j(P,T,ot(R._payload),X)}if(Ri(R)||it(R))return ot!==null?null:B(P,T,R,X,null);lr(P,R)}return null}function Z(P,T,R,X,ot){if(typeof X=="string"&&X!==""||typeof X=="number")return P=P.get(R)||null,b(T,P,""+X,ot);if(typeof X=="object"&&X!==null){switch(X.$$typeof){case O:return P=P.get(X.key===null?R:X.key)||null,C(T,P,X,ot);case H:return P=P.get(X.key===null?R:X.key)||null,L(T,P,X,ot);case K:var ct=X._init;return Z(P,T,R,ct(X._payload),ot)}if(Ri(X)||it(X))return P=P.get(R)||null,B(T,P,X,ot,null);lr(T,X)}return null}function nt(P,T,R,X){for(var ot=null,ct=null,ht=T,gt=T=0,te=null;ht!==null&><R.length;gt++){ht.index>gt?(te=ht,ht=null):te=ht.sibling;var Tt=j(P,ht,R[gt],X);if(Tt===null){ht===null&&(ht=te);break}n&&ht&&Tt.alternate===null&&i(P,ht),T=m(Tt,T,gt),ct===null?ot=Tt:ct.sibling=Tt,ct=Tt,ht=te}if(gt===R.length)return o(P,ht),Ft&&Un(P,gt),ot;if(ht===null){for(;gt<R.length;gt++)ht=U(P,R[gt],X),ht!==null&&(T=m(ht,T,gt),ct===null?ot=ht:ct.sibling=ht,ct=ht);return Ft&&Un(P,gt),ot}for(ht=c(P,ht);gt<R.length;gt++)te=Z(ht,P,gt,R[gt],X),te!==null&&(n&&te.alternate!==null&&ht.delete(te.key===null?gt:te.key),T=m(te,T,gt),ct===null?ot=te:ct.sibling=te,ct=te);return n&&ht.forEach(function(Ln){return i(P,Ln)}),Ft&&Un(P,gt),ot}function st(P,T,R,X){var ot=it(R);if(typeof ot!="function")throw Error(e(150));if(R=ot.call(R),R==null)throw Error(e(151));for(var ct=ot=null,ht=T,gt=T=0,te=null,Tt=R.next();ht!==null&&!Tt.done;gt++,Tt=R.next()){ht.index>gt?(te=ht,ht=null):te=ht.sibling;var Ln=j(P,ht,Tt.value,X);if(Ln===null){ht===null&&(ht=te);break}n&&ht&&Ln.alternate===null&&i(P,ht),T=m(Ln,T,gt),ct===null?ot=Ln:ct.sibling=Ln,ct=Ln,ht=te}if(Tt.done)return o(P,ht),Ft&&Un(P,gt),ot;if(ht===null){for(;!Tt.done;gt++,Tt=R.next())Tt=U(P,Tt.value,X),Tt!==null&&(T=m(Tt,T,gt),ct===null?ot=Tt:ct.sibling=Tt,ct=Tt);return Ft&&Un(P,gt),ot}for(ht=c(P,ht);!Tt.done;gt++,Tt=R.next())Tt=Z(ht,P,gt,Tt.value,X),Tt!==null&&(n&&Tt.alternate!==null&&ht.delete(Tt.key===null?gt:Tt.key),T=m(Tt,T,gt),ct===null?ot=Tt:ct.sibling=Tt,ct=Tt);return n&&ht.forEach(function(Dp){return i(P,Dp)}),Ft&&Un(P,gt),ot}function Ut(P,T,R,X){if(typeof R=="object"&&R!==null&&R.type===F&&R.key===null&&(R=R.props.children),typeof R=="object"&&R!==null){switch(R.$$typeof){case O:t:{for(var ot=R.key,ct=T;ct!==null;){if(ct.key===ot){if(ot=R.type,ot===F){if(ct.tag===7){o(P,ct.sibling),T=d(ct,R.props.children),T.return=P,P=T;break t}}else if(ct.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===K&&uc(ot)===ct.type){o(P,ct.sibling),T=d(ct,R.props),T.ref=es(P,ct,R),T.return=P,P=T;break t}o(P,ct);break}else i(P,ct);ct=ct.sibling}R.type===F?(T=Kn(R.props.children,P.mode,X,R.key),T.return=P,P=T):(X=Lr(R.type,R.key,R.props,null,P.mode,X),X.ref=es(P,T,R),X.return=P,P=X)}return _(P);case H:t:{for(ct=R.key;T!==null;){if(T.key===ct)if(T.tag===4&&T.stateNode.containerInfo===R.containerInfo&&T.stateNode.implementation===R.implementation){o(P,T.sibling),T=d(T,R.children||[]),T.return=P,P=T;break t}else{o(P,T);break}else i(P,T);T=T.sibling}T=qa(R,P.mode,X),T.return=P,P=T}return _(P);case K:return ct=R._init,Ut(P,T,ct(R._payload),X)}if(Ri(R))return nt(P,T,R,X);if(it(R))return st(P,T,R,X);lr(P,R)}return typeof R=="string"&&R!==""||typeof R=="number"?(R=""+R,T!==null&&T.tag===6?(o(P,T.sibling),T=d(T,R),T.return=P,P=T):(o(P,T),T=Xa(R,P.mode,X),T.return=P,P=T),_(P)):o(P,T)}return Ut}var vi=cc(!0),hc=cc(!1),ur=An(null),cr=null,yi=null,ia=null;function sa(){ia=yi=cr=null}function ra(n){var i=ur.current;Dt(ur),n._currentValue=i}function oa(n,i,o){for(;n!==null;){var c=n.alternate;if((n.childLanes&i)!==i?(n.childLanes|=i,c!==null&&(c.childLanes|=i)):c!==null&&(c.childLanes&i)!==i&&(c.childLanes|=i),n===o)break;n=n.return}}function wi(n,i){cr=n,ia=yi=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&i)!==0&&(we=!0),n.firstContext=null)}function Ne(n){var i=n._currentValue;if(ia!==n)if(n={context:n,memoizedValue:i,next:null},yi===null){if(cr===null)throw Error(e(308));yi=n,cr.dependencies={lanes:0,firstContext:n}}else yi=yi.next=n;return i}var $n=null;function aa(n){$n===null?$n=[n]:$n.push(n)}function dc(n,i,o,c){var d=i.interleaved;return d===null?(o.next=o,aa(i)):(o.next=d.next,d.next=o),i.interleaved=o,ln(n,c)}function ln(n,i){n.lanes|=i;var o=n.alternate;for(o!==null&&(o.lanes|=i),o=n,n=n.return;n!==null;)n.childLanes|=i,o=n.alternate,o!==null&&(o.childLanes|=i),o=n,n=n.return;return o.tag===3?o.stateNode:null}var En=!1;function la(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function fc(n,i){n=n.updateQueue,i.updateQueue===n&&(i.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function un(n,i){return{eventTime:n,lane:i,tag:0,payload:null,callback:null,next:null}}function xn(n,i,o){var c=n.updateQueue;if(c===null)return null;if(c=c.shared,(Ct&2)!==0){var d=c.pending;return d===null?i.next=i:(i.next=d.next,d.next=i),c.pending=i,ln(n,o)}return d=c.interleaved,d===null?(i.next=i,aa(c)):(i.next=d.next,d.next=i),c.interleaved=i,ln(n,o)}function hr(n,i,o){if(i=i.updateQueue,i!==null&&(i=i.shared,(o&4194240)!==0)){var c=i.lanes;c&=n.pendingLanes,o|=c,i.lanes=o,So(n,o)}}function pc(n,i){var o=n.updateQueue,c=n.alternate;if(c!==null&&(c=c.updateQueue,o===c)){var d=null,m=null;if(o=o.firstBaseUpdate,o!==null){do{var _={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};m===null?d=m=_:m=m.next=_,o=o.next}while(o!==null);m===null?d=m=i:m=m.next=i}else d=m=i;o={baseState:c.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:c.shared,effects:c.effects},n.updateQueue=o;return}n=o.lastBaseUpdate,n===null?o.firstBaseUpdate=i:n.next=i,o.lastBaseUpdate=i}function dr(n,i,o,c){var d=n.updateQueue;En=!1;var m=d.firstBaseUpdate,_=d.lastBaseUpdate,b=d.shared.pending;if(b!==null){d.shared.pending=null;var C=b,L=C.next;C.next=null,_===null?m=L:_.next=L,_=C;var B=n.alternate;B!==null&&(B=B.updateQueue,b=B.lastBaseUpdate,b!==_&&(b===null?B.firstBaseUpdate=L:b.next=L,B.lastBaseUpdate=C))}if(m!==null){var U=d.baseState;_=0,B=L=C=null,b=m;do{var j=b.lane,Z=b.eventTime;if((c&j)===j){B!==null&&(B=B.next={eventTime:Z,lane:0,tag:b.tag,payload:b.payload,callback:b.callback,next:null});t:{var nt=n,st=b;switch(j=i,Z=o,st.tag){case 1:if(nt=st.payload,typeof nt=="function"){U=nt.call(Z,U,j);break t}U=nt;break t;case 3:nt.flags=nt.flags&-65537|128;case 0:if(nt=st.payload,j=typeof nt=="function"?nt.call(Z,U,j):nt,j==null)break t;U=z({},U,j);break t;case 2:En=!0}}b.callback!==null&&b.lane!==0&&(n.flags|=64,j=d.effects,j===null?d.effects=[b]:j.push(b))}else Z={eventTime:Z,lane:j,tag:b.tag,payload:b.payload,callback:b.callback,next:null},B===null?(L=B=Z,C=U):B=B.next=Z,_|=j;if(b=b.next,b===null){if(b=d.shared.pending,b===null)break;j=b,b=j.next,j.next=null,d.lastBaseUpdate=j,d.shared.pending=null}}while(!0);if(B===null&&(C=U),d.baseState=C,d.firstBaseUpdate=L,d.lastBaseUpdate=B,i=d.shared.interleaved,i!==null){d=i;do _|=d.lane,d=d.next;while(d!==i)}else m===null&&(d.shared.lanes=0);Gn|=_,n.lanes=_,n.memoizedState=U}}function gc(n,i,o){if(n=i.effects,i.effects=null,n!==null)for(i=0;i<n.length;i++){var c=n[i],d=c.callback;if(d!==null){if(c.callback=null,c=o,typeof d!="function")throw Error(e(191,d));d.call(c)}}}var ns={},Qe=An(ns),is=An(ns),ss=An(ns);function Wn(n){if(n===ns)throw Error(e(174));return n}function ua(n,i){switch(It(ss,i),It(is,n),It(Qe,ns),n=i.nodeType,n){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:uo(null,"");break;default:n=n===8?i.parentNode:i,i=n.namespaceURI||null,n=n.tagName,i=uo(i,n)}Dt(Qe),It(Qe,i)}function _i(){Dt(Qe),Dt(is),Dt(ss)}function mc(n){Wn(ss.current);var i=Wn(Qe.current),o=uo(i,n.type);i!==o&&(It(is,n),It(Qe,o))}function ca(n){is.current===n&&(Dt(Qe),Dt(is))}var zt=An(0);function fr(n){for(var i=n;i!==null;){if(i.tag===13){var o=i.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||o.data==="$?"||o.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var ha=[];function da(){for(var n=0;n<ha.length;n++)ha[n]._workInProgressVersionPrimary=null;ha.length=0}var pr=N.ReactCurrentDispatcher,fa=N.ReactCurrentBatchConfig,Vn=0,jt=null,qt=null,Zt=null,gr=!1,rs=!1,os=0,ip=0;function re(){throw Error(e(321))}function pa(n,i){if(i===null)return!1;for(var o=0;o<i.length&&o<n.length;o++)if(!He(n[o],i[o]))return!1;return!0}function ga(n,i,o,c,d,m){if(Vn=m,jt=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,pr.current=n===null||n.memoizedState===null?ap:lp,n=o(c,d),rs){m=0;do{if(rs=!1,os=0,25<=m)throw Error(e(301));m+=1,Zt=qt=null,i.updateQueue=null,pr.current=up,n=o(c,d)}while(rs)}if(pr.current=yr,i=qt!==null&&qt.next!==null,Vn=0,Zt=qt=jt=null,gr=!1,i)throw Error(e(300));return n}function ma(){var n=os!==0;return os=0,n}function Ze(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Zt===null?jt.memoizedState=Zt=n:Zt=Zt.next=n,Zt}function De(){if(qt===null){var n=jt.alternate;n=n!==null?n.memoizedState:null}else n=qt.next;var i=Zt===null?jt.memoizedState:Zt.next;if(i!==null)Zt=i,qt=n;else{if(n===null)throw Error(e(310));qt=n,n={memoizedState:qt.memoizedState,baseState:qt.baseState,baseQueue:qt.baseQueue,queue:qt.queue,next:null},Zt===null?jt.memoizedState=Zt=n:Zt=Zt.next=n}return Zt}function as(n,i){return typeof i=="function"?i(n):i}function va(n){var i=De(),o=i.queue;if(o===null)throw Error(e(311));o.lastRenderedReducer=n;var c=qt,d=c.baseQueue,m=o.pending;if(m!==null){if(d!==null){var _=d.next;d.next=m.next,m.next=_}c.baseQueue=d=m,o.pending=null}if(d!==null){m=d.next,c=c.baseState;var b=_=null,C=null,L=m;do{var B=L.lane;if((Vn&B)===B)C!==null&&(C=C.next={lane:0,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),c=L.hasEagerState?L.eagerState:n(c,L.action);else{var U={lane:B,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null};C===null?(b=C=U,_=c):C=C.next=U,jt.lanes|=B,Gn|=B}L=L.next}while(L!==null&&L!==m);C===null?_=c:C.next=b,He(c,i.memoizedState)||(we=!0),i.memoizedState=c,i.baseState=_,i.baseQueue=C,o.lastRenderedState=c}if(n=o.interleaved,n!==null){d=n;do m=d.lane,jt.lanes|=m,Gn|=m,d=d.next;while(d!==n)}else d===null&&(o.lanes=0);return[i.memoizedState,o.dispatch]}function ya(n){var i=De(),o=i.queue;if(o===null)throw Error(e(311));o.lastRenderedReducer=n;var c=o.dispatch,d=o.pending,m=i.memoizedState;if(d!==null){o.pending=null;var _=d=d.next;do m=n(m,_.action),_=_.next;while(_!==d);He(m,i.memoizedState)||(we=!0),i.memoizedState=m,i.baseQueue===null&&(i.baseState=m),o.lastRenderedState=m}return[m,c]}function vc(){}function yc(n,i){var o=jt,c=De(),d=i(),m=!He(c.memoizedState,d);if(m&&(c.memoizedState=d,we=!0),c=c.queue,wa(Ac.bind(null,o,c,n),[n]),c.getSnapshot!==i||m||Zt!==null&&Zt.memoizedState.tag&1){if(o.flags|=2048,ls(9,_c.bind(null,o,c,d,i),void 0,null),Jt===null)throw Error(e(349));(Vn&30)!==0||wc(o,i,d)}return d}function wc(n,i,o){n.flags|=16384,n={getSnapshot:i,value:o},i=jt.updateQueue,i===null?(i={lastEffect:null,stores:null},jt.updateQueue=i,i.stores=[n]):(o=i.stores,o===null?i.stores=[n]:o.push(n))}function _c(n,i,o,c){i.value=o,i.getSnapshot=c,Sc(i)&&bc(n)}function Ac(n,i,o){return o(function(){Sc(i)&&bc(n)})}function Sc(n){var i=n.getSnapshot;n=n.value;try{var o=i();return!He(n,o)}catch{return!0}}function bc(n){var i=ln(n,1);i!==null&&Ge(i,n,1,-1)}function Ec(n){var i=Ze();return typeof n=="function"&&(n=n()),i.memoizedState=i.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:as,lastRenderedState:n},i.queue=n,n=n.dispatch=op.bind(null,jt,n),[i.memoizedState,n]}function ls(n,i,o,c){return n={tag:n,create:i,destroy:o,deps:c,next:null},i=jt.updateQueue,i===null?(i={lastEffect:null,stores:null},jt.updateQueue=i,i.lastEffect=n.next=n):(o=i.lastEffect,o===null?i.lastEffect=n.next=n:(c=o.next,o.next=n,n.next=c,i.lastEffect=n)),n}function xc(){return De().memoizedState}function mr(n,i,o,c){var d=Ze();jt.flags|=n,d.memoizedState=ls(1|i,o,void 0,c===void 0?null:c)}function vr(n,i,o,c){var d=De();c=c===void 0?null:c;var m=void 0;if(qt!==null){var _=qt.memoizedState;if(m=_.destroy,c!==null&&pa(c,_.deps)){d.memoizedState=ls(i,o,m,c);return}}jt.flags|=n,d.memoizedState=ls(1|i,o,m,c)}function Cc(n,i){return mr(8390656,8,n,i)}function wa(n,i){return vr(2048,8,n,i)}function kc(n,i){return vr(4,2,n,i)}function Tc(n,i){return vr(4,4,n,i)}function Pc(n,i){if(typeof i=="function")return n=n(),i(n),function(){i(null)};if(i!=null)return n=n(),i.current=n,function(){i.current=null}}function Rc(n,i,o){return o=o!=null?o.concat([n]):null,vr(4,4,Pc.bind(null,i,n),o)}function _a(){}function Mc(n,i){var o=De();i=i===void 0?null:i;var c=o.memoizedState;return c!==null&&i!==null&&pa(i,c[1])?c[0]:(o.memoizedState=[n,i],n)}function Lc(n,i){var o=De();i=i===void 0?null:i;var c=o.memoizedState;return c!==null&&i!==null&&pa(i,c[1])?c[0]:(n=n(),o.memoizedState=[n,i],n)}function Ic(n,i,o){return(Vn&21)===0?(n.baseState&&(n.baseState=!1,we=!0),n.memoizedState=o):(He(o,i)||(o=uu(),jt.lanes|=o,Gn|=o,n.baseState=!0),i)}function sp(n,i){var o=Rt;Rt=o!==0&&4>o?o:4,n(!0);var c=fa.transition;fa.transition={};try{n(!1),i()}finally{Rt=o,fa.transition=c}}function Nc(){return De().memoizedState}function rp(n,i,o){var c=Pn(n);if(o={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null},Dc(n))Fc(i,o);else if(o=dc(n,i,o,c),o!==null){var d=fe();Ge(o,n,c,d),Oc(o,i,c)}}function op(n,i,o){var c=Pn(n),d={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null};if(Dc(n))Fc(i,d);else{var m=n.alternate;if(n.lanes===0&&(m===null||m.lanes===0)&&(m=i.lastRenderedReducer,m!==null))try{var _=i.lastRenderedState,b=m(_,o);if(d.hasEagerState=!0,d.eagerState=b,He(b,_)){var C=i.interleaved;C===null?(d.next=d,aa(i)):(d.next=C.next,C.next=d),i.interleaved=d;return}}catch{}finally{}o=dc(n,i,d,c),o!==null&&(d=fe(),Ge(o,n,c,d),Oc(o,i,c))}}function Dc(n){var i=n.alternate;return n===jt||i!==null&&i===jt}function Fc(n,i){rs=gr=!0;var o=n.pending;o===null?i.next=i:(i.next=o.next,o.next=i),n.pending=i}function Oc(n,i,o){if((o&4194240)!==0){var c=i.lanes;c&=n.pendingLanes,o|=c,i.lanes=o,So(n,o)}}var yr={readContext:Ne,useCallback:re,useContext:re,useEffect:re,useImperativeHandle:re,useInsertionEffect:re,useLayoutEffect:re,useMemo:re,useReducer:re,useRef:re,useState:re,useDebugValue:re,useDeferredValue:re,useTransition:re,useMutableSource:re,useSyncExternalStore:re,useId:re,unstable_isNewReconciler:!1},ap={readContext:Ne,useCallback:function(n,i){return Ze().memoizedState=[n,i===void 0?null:i],n},useContext:Ne,useEffect:Cc,useImperativeHandle:function(n,i,o){return o=o!=null?o.concat([n]):null,mr(4194308,4,Pc.bind(null,i,n),o)},useLayoutEffect:function(n,i){return mr(4194308,4,n,i)},useInsertionEffect:function(n,i){return mr(4,2,n,i)},useMemo:function(n,i){var o=Ze();return i=i===void 0?null:i,n=n(),o.memoizedState=[n,i],n},useReducer:function(n,i,o){var c=Ze();return i=o!==void 0?o(i):i,c.memoizedState=c.baseState=i,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:i},c.queue=n,n=n.dispatch=rp.bind(null,jt,n),[c.memoizedState,n]},useRef:function(n){var i=Ze();return n={current:n},i.memoizedState=n},useState:Ec,useDebugValue:_a,useDeferredValue:function(n){return Ze().memoizedState=n},useTransition:function(){var n=Ec(!1),i=n[0];return n=sp.bind(null,n[1]),Ze().memoizedState=n,[i,n]},useMutableSource:function(){},useSyncExternalStore:function(n,i,o){var c=jt,d=Ze();if(Ft){if(o===void 0)throw Error(e(407));o=o()}else{if(o=i(),Jt===null)throw Error(e(349));(Vn&30)!==0||wc(c,i,o)}d.memoizedState=o;var m={value:o,getSnapshot:i};return d.queue=m,Cc(Ac.bind(null,c,m,n),[n]),c.flags|=2048,ls(9,_c.bind(null,c,m,o,i),void 0,null),o},useId:function(){var n=Ze(),i=Jt.identifierPrefix;if(Ft){var o=an,c=on;o=(c&~(1<<32-Be(c)-1)).toString(32)+o,i=":"+i+"R"+o,o=os++,0<o&&(i+="H"+o.toString(32)),i+=":"}else o=ip++,i=":"+i+"r"+o.toString(32)+":";return n.memoizedState=i},unstable_isNewReconciler:!1},lp={readContext:Ne,useCallback:Mc,useContext:Ne,useEffect:wa,useImperativeHandle:Rc,useInsertionEffect:kc,useLayoutEffect:Tc,useMemo:Lc,useReducer:va,useRef:xc,useState:function(){return va(as)},useDebugValue:_a,useDeferredValue:function(n){var i=De();return Ic(i,qt.memoizedState,n)},useTransition:function(){var n=va(as)[0],i=De().memoizedState;return[n,i]},useMutableSource:vc,useSyncExternalStore:yc,useId:Nc,unstable_isNewReconciler:!1},up={readContext:Ne,useCallback:Mc,useContext:Ne,useEffect:wa,useImperativeHandle:Rc,useInsertionEffect:kc,useLayoutEffect:Tc,useMemo:Lc,useReducer:ya,useRef:xc,useState:function(){return ya(as)},useDebugValue:_a,useDeferredValue:function(n){var i=De();return qt===null?i.memoizedState=n:Ic(i,qt.memoizedState,n)},useTransition:function(){var n=ya(as)[0],i=De().memoizedState;return[n,i]},useMutableSource:vc,useSyncExternalStore:yc,useId:Nc,unstable_isNewReconciler:!1};function $e(n,i){if(n&&n.defaultProps){i=z({},i),n=n.defaultProps;for(var o in n)i[o]===void 0&&(i[o]=n[o]);return i}return i}function Aa(n,i,o,c){i=n.memoizedState,o=o(c,i),o=o==null?i:z({},i,o),n.memoizedState=o,n.lanes===0&&(n.updateQueue.baseState=o)}var wr={isMounted:function(n){return(n=n._reactInternals)?zn(n)===n:!1},enqueueSetState:function(n,i,o){n=n._reactInternals;var c=fe(),d=Pn(n),m=un(c,d);m.payload=i,o!=null&&(m.callback=o),i=xn(n,m,d),i!==null&&(Ge(i,n,d,c),hr(i,n,d))},enqueueReplaceState:function(n,i,o){n=n._reactInternals;var c=fe(),d=Pn(n),m=un(c,d);m.tag=1,m.payload=i,o!=null&&(m.callback=o),i=xn(n,m,d),i!==null&&(Ge(i,n,d,c),hr(i,n,d))},enqueueForceUpdate:function(n,i){n=n._reactInternals;var o=fe(),c=Pn(n),d=un(o,c);d.tag=2,i!=null&&(d.callback=i),i=xn(n,d,c),i!==null&&(Ge(i,n,c,o),hr(i,n,c))}};function zc(n,i,o,c,d,m,_){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(c,m,_):i.prototype&&i.prototype.isPureReactComponent?!qi(o,c)||!qi(d,m):!0}function jc(n,i,o){var c=!1,d=Sn,m=i.contextType;return typeof m=="object"&&m!==null?m=Ne(m):(d=ye(i)?Bn:se.current,c=i.contextTypes,m=(c=c!=null)?fi(n,d):Sn),i=new i(o,m),n.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=wr,n.stateNode=i,i._reactInternals=n,c&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=d,n.__reactInternalMemoizedMaskedChildContext=m),i}function Bc(n,i,o,c){n=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(o,c),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(o,c),i.state!==n&&wr.enqueueReplaceState(i,i.state,null)}function Sa(n,i,o,c){var d=n.stateNode;d.props=o,d.state=n.memoizedState,d.refs={},la(n);var m=i.contextType;typeof m=="object"&&m!==null?d.context=Ne(m):(m=ye(i)?Bn:se.current,d.context=fi(n,m)),d.state=n.memoizedState,m=i.getDerivedStateFromProps,typeof m=="function"&&(Aa(n,i,m,o),d.state=n.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(i=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),i!==d.state&&wr.enqueueReplaceState(d,d.state,null),dr(n,o,d,c),d.state=n.memoizedState),typeof d.componentDidMount=="function"&&(n.flags|=4194308)}function Ai(n,i){try{var o="",c=i;do o+=wt(c),c=c.return;while(c);var d=o}catch(m){d=`
|
|
39
|
+
Error generating stack: `+m.message+`
|
|
40
|
+
`+m.stack}return{value:n,source:i,stack:d,digest:null}}function ba(n,i,o){return{value:n,source:null,stack:o??null,digest:i??null}}function Ea(n,i){try{console.error(i.value)}catch(o){setTimeout(function(){throw o})}}var cp=typeof WeakMap=="function"?WeakMap:Map;function Hc(n,i,o){o=un(-1,o),o.tag=3,o.payload={element:null};var c=i.value;return o.callback=function(){Cr||(Cr=!0,ja=c),Ea(n,i)},o}function Uc(n,i,o){o=un(-1,o),o.tag=3;var c=n.type.getDerivedStateFromError;if(typeof c=="function"){var d=i.value;o.payload=function(){return c(d)},o.callback=function(){Ea(n,i)}}var m=n.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(o.callback=function(){Ea(n,i),typeof c!="function"&&(kn===null?kn=new Set([this]):kn.add(this));var _=i.stack;this.componentDidCatch(i.value,{componentStack:_!==null?_:""})}),o}function $c(n,i,o){var c=n.pingCache;if(c===null){c=n.pingCache=new cp;var d=new Set;c.set(i,d)}else d=c.get(i),d===void 0&&(d=new Set,c.set(i,d));d.has(o)||(d.add(o),n=Ep.bind(null,n,i,o),i.then(n,n))}function Wc(n){do{var i;if((i=n.tag===13)&&(i=n.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return n;n=n.return}while(n!==null);return null}function Vc(n,i,o,c,d){return(n.mode&1)===0?(n===i?n.flags|=65536:(n.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(i=un(-1,1),i.tag=2,xn(o,i,1))),o.lanes|=1),n):(n.flags|=65536,n.lanes=d,n)}var hp=N.ReactCurrentOwner,we=!1;function de(n,i,o,c){i.child=n===null?hc(i,null,o,c):vi(i,n.child,o,c)}function Gc(n,i,o,c,d){o=o.render;var m=i.ref;return wi(i,d),c=ga(n,i,o,c,m,d),o=ma(),n!==null&&!we?(i.updateQueue=n.updateQueue,i.flags&=-2053,n.lanes&=~d,cn(n,i,d)):(Ft&&o&&Zo(i),i.flags|=1,de(n,i,c,d),i.child)}function Xc(n,i,o,c,d){if(n===null){var m=o.type;return typeof m=="function"&&!Ga(m)&&m.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(i.tag=15,i.type=m,qc(n,i,m,c,d)):(n=Lr(o.type,null,c,i,i.mode,d),n.ref=i.ref,n.return=i,i.child=n)}if(m=n.child,(n.lanes&d)===0){var _=m.memoizedProps;if(o=o.compare,o=o!==null?o:qi,o(_,c)&&n.ref===i.ref)return cn(n,i,d)}return i.flags|=1,n=Mn(m,c),n.ref=i.ref,n.return=i,i.child=n}function qc(n,i,o,c,d){if(n!==null){var m=n.memoizedProps;if(qi(m,c)&&n.ref===i.ref)if(we=!1,i.pendingProps=c=m,(n.lanes&d)!==0)(n.flags&131072)!==0&&(we=!0);else return i.lanes=n.lanes,cn(n,i,d)}return xa(n,i,o,c,d)}function Yc(n,i,o){var c=i.pendingProps,d=c.children,m=n!==null?n.memoizedState:null;if(c.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},It(bi,Pe),Pe|=o;else{if((o&1073741824)===0)return n=m!==null?m.baseLanes|o:o,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:n,cachePool:null,transitions:null},i.updateQueue=null,It(bi,Pe),Pe|=n,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=m!==null?m.baseLanes:o,It(bi,Pe),Pe|=c}else m!==null?(c=m.baseLanes|o,i.memoizedState=null):c=o,It(bi,Pe),Pe|=c;return de(n,i,d,o),i.child}function Kc(n,i){var o=i.ref;(n===null&&o!==null||n!==null&&n.ref!==o)&&(i.flags|=512,i.flags|=2097152)}function xa(n,i,o,c,d){var m=ye(o)?Bn:se.current;return m=fi(i,m),wi(i,d),o=ga(n,i,o,c,m,d),c=ma(),n!==null&&!we?(i.updateQueue=n.updateQueue,i.flags&=-2053,n.lanes&=~d,cn(n,i,d)):(Ft&&c&&Zo(i),i.flags|=1,de(n,i,o,d),i.child)}function Qc(n,i,o,c,d){if(ye(o)){var m=!0;ir(i)}else m=!1;if(wi(i,d),i.stateNode===null)Ar(n,i),jc(i,o,c),Sa(i,o,c,d),c=!0;else if(n===null){var _=i.stateNode,b=i.memoizedProps;_.props=b;var C=_.context,L=o.contextType;typeof L=="object"&&L!==null?L=Ne(L):(L=ye(o)?Bn:se.current,L=fi(i,L));var B=o.getDerivedStateFromProps,U=typeof B=="function"||typeof _.getSnapshotBeforeUpdate=="function";U||typeof _.UNSAFE_componentWillReceiveProps!="function"&&typeof _.componentWillReceiveProps!="function"||(b!==c||C!==L)&&Bc(i,_,c,L),En=!1;var j=i.memoizedState;_.state=j,dr(i,c,_,d),C=i.memoizedState,b!==c||j!==C||ve.current||En?(typeof B=="function"&&(Aa(i,o,B,c),C=i.memoizedState),(b=En||zc(i,o,b,c,j,C,L))?(U||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount()),typeof _.componentDidMount=="function"&&(i.flags|=4194308)):(typeof _.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=c,i.memoizedState=C),_.props=c,_.state=C,_.context=L,c=b):(typeof _.componentDidMount=="function"&&(i.flags|=4194308),c=!1)}else{_=i.stateNode,fc(n,i),b=i.memoizedProps,L=i.type===i.elementType?b:$e(i.type,b),_.props=L,U=i.pendingProps,j=_.context,C=o.contextType,typeof C=="object"&&C!==null?C=Ne(C):(C=ye(o)?Bn:se.current,C=fi(i,C));var Z=o.getDerivedStateFromProps;(B=typeof Z=="function"||typeof _.getSnapshotBeforeUpdate=="function")||typeof _.UNSAFE_componentWillReceiveProps!="function"&&typeof _.componentWillReceiveProps!="function"||(b!==U||j!==C)&&Bc(i,_,c,C),En=!1,j=i.memoizedState,_.state=j,dr(i,c,_,d);var nt=i.memoizedState;b!==U||j!==nt||ve.current||En?(typeof Z=="function"&&(Aa(i,o,Z,c),nt=i.memoizedState),(L=En||zc(i,o,L,c,j,nt,C)||!1)?(B||typeof _.UNSAFE_componentWillUpdate!="function"&&typeof _.componentWillUpdate!="function"||(typeof _.componentWillUpdate=="function"&&_.componentWillUpdate(c,nt,C),typeof _.UNSAFE_componentWillUpdate=="function"&&_.UNSAFE_componentWillUpdate(c,nt,C)),typeof _.componentDidUpdate=="function"&&(i.flags|=4),typeof _.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof _.componentDidUpdate!="function"||b===n.memoizedProps&&j===n.memoizedState||(i.flags|=4),typeof _.getSnapshotBeforeUpdate!="function"||b===n.memoizedProps&&j===n.memoizedState||(i.flags|=1024),i.memoizedProps=c,i.memoizedState=nt),_.props=c,_.state=nt,_.context=C,c=L):(typeof _.componentDidUpdate!="function"||b===n.memoizedProps&&j===n.memoizedState||(i.flags|=4),typeof _.getSnapshotBeforeUpdate!="function"||b===n.memoizedProps&&j===n.memoizedState||(i.flags|=1024),c=!1)}return Ca(n,i,o,c,m,d)}function Ca(n,i,o,c,d,m){Kc(n,i);var _=(i.flags&128)!==0;if(!c&&!_)return d&&nc(i,o,!1),cn(n,i,m);c=i.stateNode,hp.current=i;var b=_&&typeof o.getDerivedStateFromError!="function"?null:c.render();return i.flags|=1,n!==null&&_?(i.child=vi(i,n.child,null,m),i.child=vi(i,null,b,m)):de(n,i,b,m),i.memoizedState=c.state,d&&nc(i,o,!0),i.child}function Zc(n){var i=n.stateNode;i.pendingContext?tc(n,i.pendingContext,i.pendingContext!==i.context):i.context&&tc(n,i.context,!1),ua(n,i.containerInfo)}function Jc(n,i,o,c,d){return mi(),na(d),i.flags|=256,de(n,i,o,c),i.child}var ka={dehydrated:null,treeContext:null,retryLane:0};function Ta(n){return{baseLanes:n,cachePool:null,transitions:null}}function th(n,i,o){var c=i.pendingProps,d=zt.current,m=!1,_=(i.flags&128)!==0,b;if((b=_)||(b=n!==null&&n.memoizedState===null?!1:(d&2)!==0),b?(m=!0,i.flags&=-129):(n===null||n.memoizedState!==null)&&(d|=1),It(zt,d&1),n===null)return ea(i),n=i.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((i.mode&1)===0?i.lanes=1:n.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(_=c.children,n=c.fallback,m?(c=i.mode,m=i.child,_={mode:"hidden",children:_},(c&1)===0&&m!==null?(m.childLanes=0,m.pendingProps=_):m=Ir(_,c,0,null),n=Kn(n,c,o,null),m.return=i,n.return=i,m.sibling=n,i.child=m,i.child.memoizedState=Ta(o),i.memoizedState=ka,n):Pa(i,_));if(d=n.memoizedState,d!==null&&(b=d.dehydrated,b!==null))return dp(n,i,_,c,b,d,o);if(m){m=c.fallback,_=i.mode,d=n.child,b=d.sibling;var C={mode:"hidden",children:c.children};return(_&1)===0&&i.child!==d?(c=i.child,c.childLanes=0,c.pendingProps=C,i.deletions=null):(c=Mn(d,C),c.subtreeFlags=d.subtreeFlags&14680064),b!==null?m=Mn(b,m):(m=Kn(m,_,o,null),m.flags|=2),m.return=i,c.return=i,c.sibling=m,i.child=c,c=m,m=i.child,_=n.child.memoizedState,_=_===null?Ta(o):{baseLanes:_.baseLanes|o,cachePool:null,transitions:_.transitions},m.memoizedState=_,m.childLanes=n.childLanes&~o,i.memoizedState=ka,c}return m=n.child,n=m.sibling,c=Mn(m,{mode:"visible",children:c.children}),(i.mode&1)===0&&(c.lanes=o),c.return=i,c.sibling=null,n!==null&&(o=i.deletions,o===null?(i.deletions=[n],i.flags|=16):o.push(n)),i.child=c,i.memoizedState=null,c}function Pa(n,i){return i=Ir({mode:"visible",children:i},n.mode,0,null),i.return=n,n.child=i}function _r(n,i,o,c){return c!==null&&na(c),vi(i,n.child,null,o),n=Pa(i,i.pendingProps.children),n.flags|=2,i.memoizedState=null,n}function dp(n,i,o,c,d,m,_){if(o)return i.flags&256?(i.flags&=-257,c=ba(Error(e(422))),_r(n,i,_,c)):i.memoizedState!==null?(i.child=n.child,i.flags|=128,null):(m=c.fallback,d=i.mode,c=Ir({mode:"visible",children:c.children},d,0,null),m=Kn(m,d,_,null),m.flags|=2,c.return=i,m.return=i,c.sibling=m,i.child=c,(i.mode&1)!==0&&vi(i,n.child,null,_),i.child.memoizedState=Ta(_),i.memoizedState=ka,m);if((i.mode&1)===0)return _r(n,i,_,null);if(d.data==="$!"){if(c=d.nextSibling&&d.nextSibling.dataset,c)var b=c.dgst;return c=b,m=Error(e(419)),c=ba(m,c,void 0),_r(n,i,_,c)}if(b=(_&n.childLanes)!==0,we||b){if(c=Jt,c!==null){switch(_&-_){case 4:d=2;break;case 16:d=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(c.suspendedLanes|_))!==0?0:d,d!==0&&d!==m.retryLane&&(m.retryLane=d,ln(n,d),Ge(c,n,d,-1))}return Va(),c=ba(Error(e(421))),_r(n,i,_,c)}return d.data==="$?"?(i.flags|=128,i.child=n.child,i=xp.bind(null,n),d._reactRetry=i,null):(n=m.treeContext,Te=_n(d.nextSibling),ke=i,Ft=!0,Ue=null,n!==null&&(Le[Ie++]=on,Le[Ie++]=an,Le[Ie++]=Hn,on=n.id,an=n.overflow,Hn=i),i=Pa(i,c.children),i.flags|=4096,i)}function eh(n,i,o){n.lanes|=i;var c=n.alternate;c!==null&&(c.lanes|=i),oa(n.return,i,o)}function Ra(n,i,o,c,d){var m=n.memoizedState;m===null?n.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:c,tail:o,tailMode:d}:(m.isBackwards=i,m.rendering=null,m.renderingStartTime=0,m.last=c,m.tail=o,m.tailMode=d)}function nh(n,i,o){var c=i.pendingProps,d=c.revealOrder,m=c.tail;if(de(n,i,c.children,o),c=zt.current,(c&2)!==0)c=c&1|2,i.flags|=128;else{if(n!==null&&(n.flags&128)!==0)t:for(n=i.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&eh(n,o,i);else if(n.tag===19)eh(n,o,i);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break t;for(;n.sibling===null;){if(n.return===null||n.return===i)break t;n=n.return}n.sibling.return=n.return,n=n.sibling}c&=1}if(It(zt,c),(i.mode&1)===0)i.memoizedState=null;else switch(d){case"forwards":for(o=i.child,d=null;o!==null;)n=o.alternate,n!==null&&fr(n)===null&&(d=o),o=o.sibling;o=d,o===null?(d=i.child,i.child=null):(d=o.sibling,o.sibling=null),Ra(i,!1,d,o,m);break;case"backwards":for(o=null,d=i.child,i.child=null;d!==null;){if(n=d.alternate,n!==null&&fr(n)===null){i.child=d;break}n=d.sibling,d.sibling=o,o=d,d=n}Ra(i,!0,o,null,m);break;case"together":Ra(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function Ar(n,i){(i.mode&1)===0&&n!==null&&(n.alternate=null,i.alternate=null,i.flags|=2)}function cn(n,i,o){if(n!==null&&(i.dependencies=n.dependencies),Gn|=i.lanes,(o&i.childLanes)===0)return null;if(n!==null&&i.child!==n.child)throw Error(e(153));if(i.child!==null){for(n=i.child,o=Mn(n,n.pendingProps),i.child=o,o.return=i;n.sibling!==null;)n=n.sibling,o=o.sibling=Mn(n,n.pendingProps),o.return=i;o.sibling=null}return i.child}function fp(n,i,o){switch(i.tag){case 3:Zc(i),mi();break;case 5:mc(i);break;case 1:ye(i.type)&&ir(i);break;case 4:ua(i,i.stateNode.containerInfo);break;case 10:var c=i.type._context,d=i.memoizedProps.value;It(ur,c._currentValue),c._currentValue=d;break;case 13:if(c=i.memoizedState,c!==null)return c.dehydrated!==null?(It(zt,zt.current&1),i.flags|=128,null):(o&i.child.childLanes)!==0?th(n,i,o):(It(zt,zt.current&1),n=cn(n,i,o),n!==null?n.sibling:null);It(zt,zt.current&1);break;case 19:if(c=(o&i.childLanes)!==0,(n.flags&128)!==0){if(c)return nh(n,i,o);i.flags|=128}if(d=i.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),It(zt,zt.current),c)break;return null;case 22:case 23:return i.lanes=0,Yc(n,i,o)}return cn(n,i,o)}var ih,Ma,sh,rh;ih=function(n,i){for(var o=i.child;o!==null;){if(o.tag===5||o.tag===6)n.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},Ma=function(){},sh=function(n,i,o,c){var d=n.memoizedProps;if(d!==c){n=i.stateNode,Wn(Qe.current);var m=null;switch(o){case"input":d=ro(n,d),c=ro(n,c),m=[];break;case"select":d=z({},d,{value:void 0}),c=z({},c,{value:void 0}),m=[];break;case"textarea":d=lo(n,d),c=lo(n,c),m=[];break;default:typeof d.onClick!="function"&&typeof c.onClick=="function"&&(n.onclick=tr)}co(o,c);var _;o=null;for(L in d)if(!c.hasOwnProperty(L)&&d.hasOwnProperty(L)&&d[L]!=null)if(L==="style"){var b=d[L];for(_ in b)b.hasOwnProperty(_)&&(o||(o={}),o[_]="")}else L!=="dangerouslySetInnerHTML"&&L!=="children"&&L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&L!=="autoFocus"&&(r.hasOwnProperty(L)?m||(m=[]):(m=m||[]).push(L,null));for(L in c){var C=c[L];if(b=d?.[L],c.hasOwnProperty(L)&&C!==b&&(C!=null||b!=null))if(L==="style")if(b){for(_ in b)!b.hasOwnProperty(_)||C&&C.hasOwnProperty(_)||(o||(o={}),o[_]="");for(_ in C)C.hasOwnProperty(_)&&b[_]!==C[_]&&(o||(o={}),o[_]=C[_])}else o||(m||(m=[]),m.push(L,o)),o=C;else L==="dangerouslySetInnerHTML"?(C=C?C.__html:void 0,b=b?b.__html:void 0,C!=null&&b!==C&&(m=m||[]).push(L,C)):L==="children"?typeof C!="string"&&typeof C!="number"||(m=m||[]).push(L,""+C):L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&(r.hasOwnProperty(L)?(C!=null&&L==="onScroll"&&Nt("scroll",n),m||b===C||(m=[])):(m=m||[]).push(L,C))}o&&(m=m||[]).push("style",o);var L=m;(i.updateQueue=L)&&(i.flags|=4)}},rh=function(n,i,o,c){o!==c&&(i.flags|=4)};function us(n,i){if(!Ft)switch(n.tailMode){case"hidden":i=n.tail;for(var o=null;i!==null;)i.alternate!==null&&(o=i),i=i.sibling;o===null?n.tail=null:o.sibling=null;break;case"collapsed":o=n.tail;for(var c=null;o!==null;)o.alternate!==null&&(c=o),o=o.sibling;c===null?i||n.tail===null?n.tail=null:n.tail.sibling=null:c.sibling=null}}function oe(n){var i=n.alternate!==null&&n.alternate.child===n.child,o=0,c=0;if(i)for(var d=n.child;d!==null;)o|=d.lanes|d.childLanes,c|=d.subtreeFlags&14680064,c|=d.flags&14680064,d.return=n,d=d.sibling;else for(d=n.child;d!==null;)o|=d.lanes|d.childLanes,c|=d.subtreeFlags,c|=d.flags,d.return=n,d=d.sibling;return n.subtreeFlags|=c,n.childLanes=o,i}function pp(n,i,o){var c=i.pendingProps;switch(Jo(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return oe(i),null;case 1:return ye(i.type)&&nr(),oe(i),null;case 3:return c=i.stateNode,_i(),Dt(ve),Dt(se),da(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(n===null||n.child===null)&&(ar(i)?i.flags|=4:n===null||n.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Ue!==null&&(Ua(Ue),Ue=null))),Ma(n,i),oe(i),null;case 5:ca(i);var d=Wn(ss.current);if(o=i.type,n!==null&&i.stateNode!=null)sh(n,i,o,c,d),n.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!c){if(i.stateNode===null)throw Error(e(166));return oe(i),null}if(n=Wn(Qe.current),ar(i)){c=i.stateNode,o=i.type;var m=i.memoizedProps;switch(c[Ke]=i,c[Ji]=m,n=(i.mode&1)!==0,o){case"dialog":Nt("cancel",c),Nt("close",c);break;case"iframe":case"object":case"embed":Nt("load",c);break;case"video":case"audio":for(d=0;d<Ki.length;d++)Nt(Ki[d],c);break;case"source":Nt("error",c);break;case"img":case"image":case"link":Nt("error",c),Nt("load",c);break;case"details":Nt("toggle",c);break;case"input":jl(c,m),Nt("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!m.multiple},Nt("invalid",c);break;case"textarea":Ul(c,m),Nt("invalid",c)}co(o,m),d=null;for(var _ in m)if(m.hasOwnProperty(_)){var b=m[_];_==="children"?typeof b=="string"?c.textContent!==b&&(m.suppressHydrationWarning!==!0&&Js(c.textContent,b,n),d=["children",b]):typeof b=="number"&&c.textContent!==""+b&&(m.suppressHydrationWarning!==!0&&Js(c.textContent,b,n),d=["children",""+b]):r.hasOwnProperty(_)&&b!=null&&_==="onScroll"&&Nt("scroll",c)}switch(o){case"input":Rs(c),Hl(c,m,!0);break;case"textarea":Rs(c),Wl(c);break;case"select":case"option":break;default:typeof m.onClick=="function"&&(c.onclick=tr)}c=d,i.updateQueue=c,c!==null&&(i.flags|=4)}else{_=d.nodeType===9?d:d.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=Vl(o)),n==="http://www.w3.org/1999/xhtml"?o==="script"?(n=_.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof c.is=="string"?n=_.createElement(o,{is:c.is}):(n=_.createElement(o),o==="select"&&(_=n,c.multiple?_.multiple=!0:c.size&&(_.size=c.size))):n=_.createElementNS(n,o),n[Ke]=i,n[Ji]=c,ih(n,i,!1,!1),i.stateNode=n;t:{switch(_=ho(o,c),o){case"dialog":Nt("cancel",n),Nt("close",n),d=c;break;case"iframe":case"object":case"embed":Nt("load",n),d=c;break;case"video":case"audio":for(d=0;d<Ki.length;d++)Nt(Ki[d],n);d=c;break;case"source":Nt("error",n),d=c;break;case"img":case"image":case"link":Nt("error",n),Nt("load",n),d=c;break;case"details":Nt("toggle",n),d=c;break;case"input":jl(n,c),d=ro(n,c),Nt("invalid",n);break;case"option":d=c;break;case"select":n._wrapperState={wasMultiple:!!c.multiple},d=z({},c,{value:void 0}),Nt("invalid",n);break;case"textarea":Ul(n,c),d=lo(n,c),Nt("invalid",n);break;default:d=c}co(o,d),b=d;for(m in b)if(b.hasOwnProperty(m)){var C=b[m];m==="style"?ql(n,C):m==="dangerouslySetInnerHTML"?(C=C?C.__html:void 0,C!=null&&Gl(n,C)):m==="children"?typeof C=="string"?(o!=="textarea"||C!=="")&&Mi(n,C):typeof C=="number"&&Mi(n,""+C):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(r.hasOwnProperty(m)?C!=null&&m==="onScroll"&&Nt("scroll",n):C!=null&&I(n,m,C,_))}switch(o){case"input":Rs(n),Hl(n,c,!1);break;case"textarea":Rs(n),Wl(n);break;case"option":c.value!=null&&n.setAttribute("value",""+Et(c.value));break;case"select":n.multiple=!!c.multiple,m=c.value,m!=null?ei(n,!!c.multiple,m,!1):c.defaultValue!=null&&ei(n,!!c.multiple,c.defaultValue,!0);break;default:typeof d.onClick=="function"&&(n.onclick=tr)}switch(o){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break t;case"img":c=!0;break t;default:c=!1}}c&&(i.flags|=4)}i.ref!==null&&(i.flags|=512,i.flags|=2097152)}return oe(i),null;case 6:if(n&&i.stateNode!=null)rh(n,i,n.memoizedProps,c);else{if(typeof c!="string"&&i.stateNode===null)throw Error(e(166));if(o=Wn(ss.current),Wn(Qe.current),ar(i)){if(c=i.stateNode,o=i.memoizedProps,c[Ke]=i,(m=c.nodeValue!==o)&&(n=ke,n!==null))switch(n.tag){case 3:Js(c.nodeValue,o,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&Js(c.nodeValue,o,(n.mode&1)!==0)}m&&(i.flags|=4)}else c=(o.nodeType===9?o:o.ownerDocument).createTextNode(c),c[Ke]=i,i.stateNode=c}return oe(i),null;case 13:if(Dt(zt),c=i.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(Ft&&Te!==null&&(i.mode&1)!==0&&(i.flags&128)===0)lc(),mi(),i.flags|=98560,m=!1;else if(m=ar(i),c!==null&&c.dehydrated!==null){if(n===null){if(!m)throw Error(e(318));if(m=i.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(e(317));m[Ke]=i}else mi(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;oe(i),m=!1}else Ue!==null&&(Ua(Ue),Ue=null),m=!0;if(!m)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=o,i):(c=c!==null,c!==(n!==null&&n.memoizedState!==null)&&c&&(i.child.flags|=8192,(i.mode&1)!==0&&(n===null||(zt.current&1)!==0?Yt===0&&(Yt=3):Va())),i.updateQueue!==null&&(i.flags|=4),oe(i),null);case 4:return _i(),Ma(n,i),n===null&&Qi(i.stateNode.containerInfo),oe(i),null;case 10:return ra(i.type._context),oe(i),null;case 17:return ye(i.type)&&nr(),oe(i),null;case 19:if(Dt(zt),m=i.memoizedState,m===null)return oe(i),null;if(c=(i.flags&128)!==0,_=m.rendering,_===null)if(c)us(m,!1);else{if(Yt!==0||n!==null&&(n.flags&128)!==0)for(n=i.child;n!==null;){if(_=fr(n),_!==null){for(i.flags|=128,us(m,!1),c=_.updateQueue,c!==null&&(i.updateQueue=c,i.flags|=4),i.subtreeFlags=0,c=o,o=i.child;o!==null;)m=o,n=c,m.flags&=14680066,_=m.alternate,_===null?(m.childLanes=0,m.lanes=n,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=_.childLanes,m.lanes=_.lanes,m.child=_.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=_.memoizedProps,m.memoizedState=_.memoizedState,m.updateQueue=_.updateQueue,m.type=_.type,n=_.dependencies,m.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),o=o.sibling;return It(zt,zt.current&1|2),i.child}n=n.sibling}m.tail!==null&&Ht()>Ei&&(i.flags|=128,c=!0,us(m,!1),i.lanes=4194304)}else{if(!c)if(n=fr(_),n!==null){if(i.flags|=128,c=!0,o=n.updateQueue,o!==null&&(i.updateQueue=o,i.flags|=4),us(m,!0),m.tail===null&&m.tailMode==="hidden"&&!_.alternate&&!Ft)return oe(i),null}else 2*Ht()-m.renderingStartTime>Ei&&o!==1073741824&&(i.flags|=128,c=!0,us(m,!1),i.lanes=4194304);m.isBackwards?(_.sibling=i.child,i.child=_):(o=m.last,o!==null?o.sibling=_:i.child=_,m.last=_)}return m.tail!==null?(i=m.tail,m.rendering=i,m.tail=i.sibling,m.renderingStartTime=Ht(),i.sibling=null,o=zt.current,It(zt,c?o&1|2:o&1),i):(oe(i),null);case 22:case 23:return Wa(),c=i.memoizedState!==null,n!==null&&n.memoizedState!==null!==c&&(i.flags|=8192),c&&(i.mode&1)!==0?(Pe&1073741824)!==0&&(oe(i),i.subtreeFlags&6&&(i.flags|=8192)):oe(i),null;case 24:return null;case 25:return null}throw Error(e(156,i.tag))}function gp(n,i){switch(Jo(i),i.tag){case 1:return ye(i.type)&&nr(),n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 3:return _i(),Dt(ve),Dt(se),da(),n=i.flags,(n&65536)!==0&&(n&128)===0?(i.flags=n&-65537|128,i):null;case 5:return ca(i),null;case 13:if(Dt(zt),n=i.memoizedState,n!==null&&n.dehydrated!==null){if(i.alternate===null)throw Error(e(340));mi()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 19:return Dt(zt),null;case 4:return _i(),null;case 10:return ra(i.type._context),null;case 22:case 23:return Wa(),null;case 24:return null;default:return null}}var Sr=!1,ae=!1,mp=typeof WeakSet=="function"?WeakSet:Set,tt=null;function Si(n,i){var o=n.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(c){Bt(n,i,c)}else o.current=null}function La(n,i,o){try{o()}catch(c){Bt(n,i,c)}}var oh=!1;function vp(n,i){if(Wo=Us,n=zu(),Fo(n)){if("selectionStart"in n)var o={start:n.selectionStart,end:n.selectionEnd};else t:{o=(o=n.ownerDocument)&&o.defaultView||window;var c=o.getSelection&&o.getSelection();if(c&&c.rangeCount!==0){o=c.anchorNode;var d=c.anchorOffset,m=c.focusNode;c=c.focusOffset;try{o.nodeType,m.nodeType}catch{o=null;break t}var _=0,b=-1,C=-1,L=0,B=0,U=n,j=null;e:for(;;){for(var Z;U!==o||d!==0&&U.nodeType!==3||(b=_+d),U!==m||c!==0&&U.nodeType!==3||(C=_+c),U.nodeType===3&&(_+=U.nodeValue.length),(Z=U.firstChild)!==null;)j=U,U=Z;for(;;){if(U===n)break e;if(j===o&&++L===d&&(b=_),j===m&&++B===c&&(C=_),(Z=U.nextSibling)!==null)break;U=j,j=U.parentNode}U=Z}o=b===-1||C===-1?null:{start:b,end:C}}else o=null}o=o||{start:0,end:0}}else o=null;for(Vo={focusedElem:n,selectionRange:o},Us=!1,tt=i;tt!==null;)if(i=tt,n=i.child,(i.subtreeFlags&1028)!==0&&n!==null)n.return=i,tt=n;else for(;tt!==null;){i=tt;try{var nt=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(nt!==null){var st=nt.memoizedProps,Ut=nt.memoizedState,P=i.stateNode,T=P.getSnapshotBeforeUpdate(i.elementType===i.type?st:$e(i.type,st),Ut);P.__reactInternalSnapshotBeforeUpdate=T}break;case 3:var R=i.stateNode.containerInfo;R.nodeType===1?R.textContent="":R.nodeType===9&&R.documentElement&&R.removeChild(R.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(e(163))}}catch(X){Bt(i,i.return,X)}if(n=i.sibling,n!==null){n.return=i.return,tt=n;break}tt=i.return}return nt=oh,oh=!1,nt}function cs(n,i,o){var c=i.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var d=c=c.next;do{if((d.tag&n)===n){var m=d.destroy;d.destroy=void 0,m!==void 0&&La(i,o,m)}d=d.next}while(d!==c)}}function br(n,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var o=i=i.next;do{if((o.tag&n)===n){var c=o.create;o.destroy=c()}o=o.next}while(o!==i)}}function Ia(n){var i=n.ref;if(i!==null){var o=n.stateNode;switch(n.tag){case 5:n=o;break;default:n=o}typeof i=="function"?i(n):i.current=n}}function ah(n){var i=n.alternate;i!==null&&(n.alternate=null,ah(i)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(i=n.stateNode,i!==null&&(delete i[Ke],delete i[Ji],delete i[Yo],delete i[Jf],delete i[tp])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function lh(n){return n.tag===5||n.tag===3||n.tag===4}function uh(n){t:for(;;){for(;n.sibling===null;){if(n.return===null||lh(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue t;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Na(n,i,o){var c=n.tag;if(c===5||c===6)n=n.stateNode,i?o.nodeType===8?o.parentNode.insertBefore(n,i):o.insertBefore(n,i):(o.nodeType===8?(i=o.parentNode,i.insertBefore(n,o)):(i=o,i.appendChild(n)),o=o._reactRootContainer,o!=null||i.onclick!==null||(i.onclick=tr));else if(c!==4&&(n=n.child,n!==null))for(Na(n,i,o),n=n.sibling;n!==null;)Na(n,i,o),n=n.sibling}function Da(n,i,o){var c=n.tag;if(c===5||c===6)n=n.stateNode,i?o.insertBefore(n,i):o.appendChild(n);else if(c!==4&&(n=n.child,n!==null))for(Da(n,i,o),n=n.sibling;n!==null;)Da(n,i,o),n=n.sibling}var ne=null,We=!1;function Cn(n,i,o){for(o=o.child;o!==null;)ch(n,i,o),o=o.sibling}function ch(n,i,o){if(Ye&&typeof Ye.onCommitFiberUnmount=="function")try{Ye.onCommitFiberUnmount(Fs,o)}catch{}switch(o.tag){case 5:ae||Si(o,i);case 6:var c=ne,d=We;ne=null,Cn(n,i,o),ne=c,We=d,ne!==null&&(We?(n=ne,o=o.stateNode,n.nodeType===8?n.parentNode.removeChild(o):n.removeChild(o)):ne.removeChild(o.stateNode));break;case 18:ne!==null&&(We?(n=ne,o=o.stateNode,n.nodeType===8?qo(n.parentNode,o):n.nodeType===1&&qo(n,o),Ui(n)):qo(ne,o.stateNode));break;case 4:c=ne,d=We,ne=o.stateNode.containerInfo,We=!0,Cn(n,i,o),ne=c,We=d;break;case 0:case 11:case 14:case 15:if(!ae&&(c=o.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){d=c=c.next;do{var m=d,_=m.destroy;m=m.tag,_!==void 0&&((m&2)!==0||(m&4)!==0)&&La(o,i,_),d=d.next}while(d!==c)}Cn(n,i,o);break;case 1:if(!ae&&(Si(o,i),c=o.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=o.memoizedProps,c.state=o.memoizedState,c.componentWillUnmount()}catch(b){Bt(o,i,b)}Cn(n,i,o);break;case 21:Cn(n,i,o);break;case 22:o.mode&1?(ae=(c=ae)||o.memoizedState!==null,Cn(n,i,o),ae=c):Cn(n,i,o);break;default:Cn(n,i,o)}}function hh(n){var i=n.updateQueue;if(i!==null){n.updateQueue=null;var o=n.stateNode;o===null&&(o=n.stateNode=new mp),i.forEach(function(c){var d=Cp.bind(null,n,c);o.has(c)||(o.add(c),c.then(d,d))})}}function Ve(n,i){var o=i.deletions;if(o!==null)for(var c=0;c<o.length;c++){var d=o[c];try{var m=n,_=i,b=_;t:for(;b!==null;){switch(b.tag){case 5:ne=b.stateNode,We=!1;break t;case 3:ne=b.stateNode.containerInfo,We=!0;break t;case 4:ne=b.stateNode.containerInfo,We=!0;break t}b=b.return}if(ne===null)throw Error(e(160));ch(m,_,d),ne=null,We=!1;var C=d.alternate;C!==null&&(C.return=null),d.return=null}catch(L){Bt(d,i,L)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)dh(i,n),i=i.sibling}function dh(n,i){var o=n.alternate,c=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Ve(i,n),Je(n),c&4){try{cs(3,n,n.return),br(3,n)}catch(st){Bt(n,n.return,st)}try{cs(5,n,n.return)}catch(st){Bt(n,n.return,st)}}break;case 1:Ve(i,n),Je(n),c&512&&o!==null&&Si(o,o.return);break;case 5:if(Ve(i,n),Je(n),c&512&&o!==null&&Si(o,o.return),n.flags&32){var d=n.stateNode;try{Mi(d,"")}catch(st){Bt(n,n.return,st)}}if(c&4&&(d=n.stateNode,d!=null)){var m=n.memoizedProps,_=o!==null?o.memoizedProps:m,b=n.type,C=n.updateQueue;if(n.updateQueue=null,C!==null)try{b==="input"&&m.type==="radio"&&m.name!=null&&Bl(d,m),ho(b,_);var L=ho(b,m);for(_=0;_<C.length;_+=2){var B=C[_],U=C[_+1];B==="style"?ql(d,U):B==="dangerouslySetInnerHTML"?Gl(d,U):B==="children"?Mi(d,U):I(d,B,U,L)}switch(b){case"input":oo(d,m);break;case"textarea":$l(d,m);break;case"select":var j=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!m.multiple;var Z=m.value;Z!=null?ei(d,!!m.multiple,Z,!1):j!==!!m.multiple&&(m.defaultValue!=null?ei(d,!!m.multiple,m.defaultValue,!0):ei(d,!!m.multiple,m.multiple?[]:"",!1))}d[Ji]=m}catch(st){Bt(n,n.return,st)}}break;case 6:if(Ve(i,n),Je(n),c&4){if(n.stateNode===null)throw Error(e(162));d=n.stateNode,m=n.memoizedProps;try{d.nodeValue=m}catch(st){Bt(n,n.return,st)}}break;case 3:if(Ve(i,n),Je(n),c&4&&o!==null&&o.memoizedState.isDehydrated)try{Ui(i.containerInfo)}catch(st){Bt(n,n.return,st)}break;case 4:Ve(i,n),Je(n);break;case 13:Ve(i,n),Je(n),d=n.child,d.flags&8192&&(m=d.memoizedState!==null,d.stateNode.isHidden=m,!m||d.alternate!==null&&d.alternate.memoizedState!==null||(za=Ht())),c&4&&hh(n);break;case 22:if(B=o!==null&&o.memoizedState!==null,n.mode&1?(ae=(L=ae)||B,Ve(i,n),ae=L):Ve(i,n),Je(n),c&8192){if(L=n.memoizedState!==null,(n.stateNode.isHidden=L)&&!B&&(n.mode&1)!==0)for(tt=n,B=n.child;B!==null;){for(U=tt=B;tt!==null;){switch(j=tt,Z=j.child,j.tag){case 0:case 11:case 14:case 15:cs(4,j,j.return);break;case 1:Si(j,j.return);var nt=j.stateNode;if(typeof nt.componentWillUnmount=="function"){c=j,o=j.return;try{i=c,nt.props=i.memoizedProps,nt.state=i.memoizedState,nt.componentWillUnmount()}catch(st){Bt(c,o,st)}}break;case 5:Si(j,j.return);break;case 22:if(j.memoizedState!==null){gh(U);continue}}Z!==null?(Z.return=j,tt=Z):gh(U)}B=B.sibling}t:for(B=null,U=n;;){if(U.tag===5){if(B===null){B=U;try{d=U.stateNode,L?(m=d.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none"):(b=U.stateNode,C=U.memoizedProps.style,_=C!=null&&C.hasOwnProperty("display")?C.display:null,b.style.display=Xl("display",_))}catch(st){Bt(n,n.return,st)}}}else if(U.tag===6){if(B===null)try{U.stateNode.nodeValue=L?"":U.memoizedProps}catch(st){Bt(n,n.return,st)}}else if((U.tag!==22&&U.tag!==23||U.memoizedState===null||U===n)&&U.child!==null){U.child.return=U,U=U.child;continue}if(U===n)break t;for(;U.sibling===null;){if(U.return===null||U.return===n)break t;B===U&&(B=null),U=U.return}B===U&&(B=null),U.sibling.return=U.return,U=U.sibling}}break;case 19:Ve(i,n),Je(n),c&4&&hh(n);break;case 21:break;default:Ve(i,n),Je(n)}}function Je(n){var i=n.flags;if(i&2){try{t:{for(var o=n.return;o!==null;){if(lh(o)){var c=o;break t}o=o.return}throw Error(e(160))}switch(c.tag){case 5:var d=c.stateNode;c.flags&32&&(Mi(d,""),c.flags&=-33);var m=uh(n);Da(n,m,d);break;case 3:case 4:var _=c.stateNode.containerInfo,b=uh(n);Na(n,b,_);break;default:throw Error(e(161))}}catch(C){Bt(n,n.return,C)}n.flags&=-3}i&4096&&(n.flags&=-4097)}function yp(n,i,o){tt=n,fh(n)}function fh(n,i,o){for(var c=(n.mode&1)!==0;tt!==null;){var d=tt,m=d.child;if(d.tag===22&&c){var _=d.memoizedState!==null||Sr;if(!_){var b=d.alternate,C=b!==null&&b.memoizedState!==null||ae;b=Sr;var L=ae;if(Sr=_,(ae=C)&&!L)for(tt=d;tt!==null;)_=tt,C=_.child,_.tag===22&&_.memoizedState!==null?mh(d):C!==null?(C.return=_,tt=C):mh(d);for(;m!==null;)tt=m,fh(m),m=m.sibling;tt=d,Sr=b,ae=L}ph(n)}else(d.subtreeFlags&8772)!==0&&m!==null?(m.return=d,tt=m):ph(n)}}function ph(n){for(;tt!==null;){var i=tt;if((i.flags&8772)!==0){var o=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:ae||br(5,i);break;case 1:var c=i.stateNode;if(i.flags&4&&!ae)if(o===null)c.componentDidMount();else{var d=i.elementType===i.type?o.memoizedProps:$e(i.type,o.memoizedProps);c.componentDidUpdate(d,o.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var m=i.updateQueue;m!==null&&gc(i,m,c);break;case 3:var _=i.updateQueue;if(_!==null){if(o=null,i.child!==null)switch(i.child.tag){case 5:o=i.child.stateNode;break;case 1:o=i.child.stateNode}gc(i,_,o)}break;case 5:var b=i.stateNode;if(o===null&&i.flags&4){o=b;var C=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":C.autoFocus&&o.focus();break;case"img":C.src&&(o.src=C.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var L=i.alternate;if(L!==null){var B=L.memoizedState;if(B!==null){var U=B.dehydrated;U!==null&&Ui(U)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(e(163))}ae||i.flags&512&&Ia(i)}catch(j){Bt(i,i.return,j)}}if(i===n){tt=null;break}if(o=i.sibling,o!==null){o.return=i.return,tt=o;break}tt=i.return}}function gh(n){for(;tt!==null;){var i=tt;if(i===n){tt=null;break}var o=i.sibling;if(o!==null){o.return=i.return,tt=o;break}tt=i.return}}function mh(n){for(;tt!==null;){var i=tt;try{switch(i.tag){case 0:case 11:case 15:var o=i.return;try{br(4,i)}catch(C){Bt(i,o,C)}break;case 1:var c=i.stateNode;if(typeof c.componentDidMount=="function"){var d=i.return;try{c.componentDidMount()}catch(C){Bt(i,d,C)}}var m=i.return;try{Ia(i)}catch(C){Bt(i,m,C)}break;case 5:var _=i.return;try{Ia(i)}catch(C){Bt(i,_,C)}}}catch(C){Bt(i,i.return,C)}if(i===n){tt=null;break}var b=i.sibling;if(b!==null){b.return=i.return,tt=b;break}tt=i.return}}var wp=Math.ceil,Er=N.ReactCurrentDispatcher,Fa=N.ReactCurrentOwner,Fe=N.ReactCurrentBatchConfig,Ct=0,Jt=null,Vt=null,ie=0,Pe=0,bi=An(0),Yt=0,hs=null,Gn=0,xr=0,Oa=0,ds=null,_e=null,za=0,Ei=1/0,hn=null,Cr=!1,ja=null,kn=null,kr=!1,Tn=null,Tr=0,fs=0,Ba=null,Pr=-1,Rr=0;function fe(){return(Ct&6)!==0?Ht():Pr!==-1?Pr:Pr=Ht()}function Pn(n){return(n.mode&1)===0?1:(Ct&2)!==0&&ie!==0?ie&-ie:np.transition!==null?(Rr===0&&(Rr=uu()),Rr):(n=Rt,n!==0||(n=window.event,n=n===void 0?16:yu(n.type)),n)}function Ge(n,i,o,c){if(50<fs)throw fs=0,Ba=null,Error(e(185));Oi(n,o,c),((Ct&2)===0||n!==Jt)&&(n===Jt&&((Ct&2)===0&&(xr|=o),Yt===4&&Rn(n,ie)),Ae(n,c),o===1&&Ct===0&&(i.mode&1)===0&&(Ei=Ht()+500,sr&&bn()))}function Ae(n,i){var o=n.callbackNode;ef(n,i);var c=js(n,n===Jt?ie:0);if(c===0)o!==null&&ou(o),n.callbackNode=null,n.callbackPriority=0;else if(i=c&-c,n.callbackPriority!==i){if(o!=null&&ou(o),i===1)n.tag===0?ep(yh.bind(null,n)):ic(yh.bind(null,n)),Qf(function(){(Ct&6)===0&&bn()}),o=null;else{switch(cu(c)){case 1:o=wo;break;case 4:o=au;break;case 16:o=Ds;break;case 536870912:o=lu;break;default:o=Ds}o=Ch(o,vh.bind(null,n))}n.callbackPriority=i,n.callbackNode=o}}function vh(n,i){if(Pr=-1,Rr=0,(Ct&6)!==0)throw Error(e(327));var o=n.callbackNode;if(xi()&&n.callbackNode!==o)return null;var c=js(n,n===Jt?ie:0);if(c===0)return null;if((c&30)!==0||(c&n.expiredLanes)!==0||i)i=Mr(n,c);else{i=c;var d=Ct;Ct|=2;var m=_h();(Jt!==n||ie!==i)&&(hn=null,Ei=Ht()+500,qn(n,i));do try{Sp();break}catch(b){wh(n,b)}while(!0);sa(),Er.current=m,Ct=d,Vt!==null?i=0:(Jt=null,ie=0,i=Yt)}if(i!==0){if(i===2&&(d=_o(n),d!==0&&(c=d,i=Ha(n,d))),i===1)throw o=hs,qn(n,0),Rn(n,c),Ae(n,Ht()),o;if(i===6)Rn(n,c);else{if(d=n.current.alternate,(c&30)===0&&!_p(d)&&(i=Mr(n,c),i===2&&(m=_o(n),m!==0&&(c=m,i=Ha(n,m))),i===1))throw o=hs,qn(n,0),Rn(n,c),Ae(n,Ht()),o;switch(n.finishedWork=d,n.finishedLanes=c,i){case 0:case 1:throw Error(e(345));case 2:Yn(n,_e,hn);break;case 3:if(Rn(n,c),(c&130023424)===c&&(i=za+500-Ht(),10<i)){if(js(n,0)!==0)break;if(d=n.suspendedLanes,(d&c)!==c){fe(),n.pingedLanes|=n.suspendedLanes&d;break}n.timeoutHandle=Xo(Yn.bind(null,n,_e,hn),i);break}Yn(n,_e,hn);break;case 4:if(Rn(n,c),(c&4194240)===c)break;for(i=n.eventTimes,d=-1;0<c;){var _=31-Be(c);m=1<<_,_=i[_],_>d&&(d=_),c&=~m}if(c=d,c=Ht()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*wp(c/1960))-c,10<c){n.timeoutHandle=Xo(Yn.bind(null,n,_e,hn),c);break}Yn(n,_e,hn);break;case 5:Yn(n,_e,hn);break;default:throw Error(e(329))}}}return Ae(n,Ht()),n.callbackNode===o?vh.bind(null,n):null}function Ha(n,i){var o=ds;return n.current.memoizedState.isDehydrated&&(qn(n,i).flags|=256),n=Mr(n,i),n!==2&&(i=_e,_e=o,i!==null&&Ua(i)),n}function Ua(n){_e===null?_e=n:_e.push.apply(_e,n)}function _p(n){for(var i=n;;){if(i.flags&16384){var o=i.updateQueue;if(o!==null&&(o=o.stores,o!==null))for(var c=0;c<o.length;c++){var d=o[c],m=d.getSnapshot;d=d.value;try{if(!He(m(),d))return!1}catch{return!1}}}if(o=i.child,i.subtreeFlags&16384&&o!==null)o.return=i,i=o;else{if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function Rn(n,i){for(i&=~Oa,i&=~xr,n.suspendedLanes|=i,n.pingedLanes&=~i,n=n.expirationTimes;0<i;){var o=31-Be(i),c=1<<o;n[o]=-1,i&=~c}}function yh(n){if((Ct&6)!==0)throw Error(e(327));xi();var i=js(n,0);if((i&1)===0)return Ae(n,Ht()),null;var o=Mr(n,i);if(n.tag!==0&&o===2){var c=_o(n);c!==0&&(i=c,o=Ha(n,c))}if(o===1)throw o=hs,qn(n,0),Rn(n,i),Ae(n,Ht()),o;if(o===6)throw Error(e(345));return n.finishedWork=n.current.alternate,n.finishedLanes=i,Yn(n,_e,hn),Ae(n,Ht()),null}function $a(n,i){var o=Ct;Ct|=1;try{return n(i)}finally{Ct=o,Ct===0&&(Ei=Ht()+500,sr&&bn())}}function Xn(n){Tn!==null&&Tn.tag===0&&(Ct&6)===0&&xi();var i=Ct;Ct|=1;var o=Fe.transition,c=Rt;try{if(Fe.transition=null,Rt=1,n)return n()}finally{Rt=c,Fe.transition=o,Ct=i,(Ct&6)===0&&bn()}}function Wa(){Pe=bi.current,Dt(bi)}function qn(n,i){n.finishedWork=null,n.finishedLanes=0;var o=n.timeoutHandle;if(o!==-1&&(n.timeoutHandle=-1,Kf(o)),Vt!==null)for(o=Vt.return;o!==null;){var c=o;switch(Jo(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&nr();break;case 3:_i(),Dt(ve),Dt(se),da();break;case 5:ca(c);break;case 4:_i();break;case 13:Dt(zt);break;case 19:Dt(zt);break;case 10:ra(c.type._context);break;case 22:case 23:Wa()}o=o.return}if(Jt=n,Vt=n=Mn(n.current,null),ie=Pe=i,Yt=0,hs=null,Oa=xr=Gn=0,_e=ds=null,$n!==null){for(i=0;i<$n.length;i++)if(o=$n[i],c=o.interleaved,c!==null){o.interleaved=null;var d=c.next,m=o.pending;if(m!==null){var _=m.next;m.next=d,c.next=_}o.pending=c}$n=null}return n}function wh(n,i){do{var o=Vt;try{if(sa(),pr.current=yr,gr){for(var c=jt.memoizedState;c!==null;){var d=c.queue;d!==null&&(d.pending=null),c=c.next}gr=!1}if(Vn=0,Zt=qt=jt=null,rs=!1,os=0,Fa.current=null,o===null||o.return===null){Yt=1,hs=i,Vt=null;break}t:{var m=n,_=o.return,b=o,C=i;if(i=ie,b.flags|=32768,C!==null&&typeof C=="object"&&typeof C.then=="function"){var L=C,B=b,U=B.tag;if((B.mode&1)===0&&(U===0||U===11||U===15)){var j=B.alternate;j?(B.updateQueue=j.updateQueue,B.memoizedState=j.memoizedState,B.lanes=j.lanes):(B.updateQueue=null,B.memoizedState=null)}var Z=Wc(_);if(Z!==null){Z.flags&=-257,Vc(Z,_,b,m,i),Z.mode&1&&$c(m,L,i),i=Z,C=L;var nt=i.updateQueue;if(nt===null){var st=new Set;st.add(C),i.updateQueue=st}else nt.add(C);break t}else{if((i&1)===0){$c(m,L,i),Va();break t}C=Error(e(426))}}else if(Ft&&b.mode&1){var Ut=Wc(_);if(Ut!==null){(Ut.flags&65536)===0&&(Ut.flags|=256),Vc(Ut,_,b,m,i),na(Ai(C,b));break t}}m=C=Ai(C,b),Yt!==4&&(Yt=2),ds===null?ds=[m]:ds.push(m),m=_;do{switch(m.tag){case 3:m.flags|=65536,i&=-i,m.lanes|=i;var P=Hc(m,C,i);pc(m,P);break t;case 1:b=C;var T=m.type,R=m.stateNode;if((m.flags&128)===0&&(typeof T.getDerivedStateFromError=="function"||R!==null&&typeof R.componentDidCatch=="function"&&(kn===null||!kn.has(R)))){m.flags|=65536,i&=-i,m.lanes|=i;var X=Uc(m,b,i);pc(m,X);break t}}m=m.return}while(m!==null)}Sh(o)}catch(ot){i=ot,Vt===o&&o!==null&&(Vt=o=o.return);continue}break}while(!0)}function _h(){var n=Er.current;return Er.current=yr,n===null?yr:n}function Va(){(Yt===0||Yt===3||Yt===2)&&(Yt=4),Jt===null||(Gn&268435455)===0&&(xr&268435455)===0||Rn(Jt,ie)}function Mr(n,i){var o=Ct;Ct|=2;var c=_h();(Jt!==n||ie!==i)&&(hn=null,qn(n,i));do try{Ap();break}catch(d){wh(n,d)}while(!0);if(sa(),Ct=o,Er.current=c,Vt!==null)throw Error(e(261));return Jt=null,ie=0,Yt}function Ap(){for(;Vt!==null;)Ah(Vt)}function Sp(){for(;Vt!==null&&!Gd();)Ah(Vt)}function Ah(n){var i=xh(n.alternate,n,Pe);n.memoizedProps=n.pendingProps,i===null?Sh(n):Vt=i,Fa.current=null}function Sh(n){var i=n;do{var o=i.alternate;if(n=i.return,(i.flags&32768)===0){if(o=pp(o,i,Pe),o!==null){Vt=o;return}}else{if(o=gp(o,i),o!==null){o.flags&=32767,Vt=o;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{Yt=6,Vt=null;return}}if(i=i.sibling,i!==null){Vt=i;return}Vt=i=n}while(i!==null);Yt===0&&(Yt=5)}function Yn(n,i,o){var c=Rt,d=Fe.transition;try{Fe.transition=null,Rt=1,bp(n,i,o,c)}finally{Fe.transition=d,Rt=c}return null}function bp(n,i,o,c){do xi();while(Tn!==null);if((Ct&6)!==0)throw Error(e(327));o=n.finishedWork;var d=n.finishedLanes;if(o===null)return null;if(n.finishedWork=null,n.finishedLanes=0,o===n.current)throw Error(e(177));n.callbackNode=null,n.callbackPriority=0;var m=o.lanes|o.childLanes;if(nf(n,m),n===Jt&&(Vt=Jt=null,ie=0),(o.subtreeFlags&2064)===0&&(o.flags&2064)===0||kr||(kr=!0,Ch(Ds,function(){return xi(),null})),m=(o.flags&15990)!==0,(o.subtreeFlags&15990)!==0||m){m=Fe.transition,Fe.transition=null;var _=Rt;Rt=1;var b=Ct;Ct|=4,Fa.current=null,vp(n,o),dh(o,n),$f(Vo),Us=!!Wo,Vo=Wo=null,n.current=o,yp(o),Xd(),Ct=b,Rt=_,Fe.transition=m}else n.current=o;if(kr&&(kr=!1,Tn=n,Tr=d),m=n.pendingLanes,m===0&&(kn=null),Kd(o.stateNode),Ae(n,Ht()),i!==null)for(c=n.onRecoverableError,o=0;o<i.length;o++)d=i[o],c(d.value,{componentStack:d.stack,digest:d.digest});if(Cr)throw Cr=!1,n=ja,ja=null,n;return(Tr&1)!==0&&n.tag!==0&&xi(),m=n.pendingLanes,(m&1)!==0?n===Ba?fs++:(fs=0,Ba=n):fs=0,bn(),null}function xi(){if(Tn!==null){var n=cu(Tr),i=Fe.transition,o=Rt;try{if(Fe.transition=null,Rt=16>n?16:n,Tn===null)var c=!1;else{if(n=Tn,Tn=null,Tr=0,(Ct&6)!==0)throw Error(e(331));var d=Ct;for(Ct|=4,tt=n.current;tt!==null;){var m=tt,_=m.child;if((tt.flags&16)!==0){var b=m.deletions;if(b!==null){for(var C=0;C<b.length;C++){var L=b[C];for(tt=L;tt!==null;){var B=tt;switch(B.tag){case 0:case 11:case 15:cs(8,B,m)}var U=B.child;if(U!==null)U.return=B,tt=U;else for(;tt!==null;){B=tt;var j=B.sibling,Z=B.return;if(ah(B),B===L){tt=null;break}if(j!==null){j.return=Z,tt=j;break}tt=Z}}}var nt=m.alternate;if(nt!==null){var st=nt.child;if(st!==null){nt.child=null;do{var Ut=st.sibling;st.sibling=null,st=Ut}while(st!==null)}}tt=m}}if((m.subtreeFlags&2064)!==0&&_!==null)_.return=m,tt=_;else t:for(;tt!==null;){if(m=tt,(m.flags&2048)!==0)switch(m.tag){case 0:case 11:case 15:cs(9,m,m.return)}var P=m.sibling;if(P!==null){P.return=m.return,tt=P;break t}tt=m.return}}var T=n.current;for(tt=T;tt!==null;){_=tt;var R=_.child;if((_.subtreeFlags&2064)!==0&&R!==null)R.return=_,tt=R;else t:for(_=T;tt!==null;){if(b=tt,(b.flags&2048)!==0)try{switch(b.tag){case 0:case 11:case 15:br(9,b)}}catch(ot){Bt(b,b.return,ot)}if(b===_){tt=null;break t}var X=b.sibling;if(X!==null){X.return=b.return,tt=X;break t}tt=b.return}}if(Ct=d,bn(),Ye&&typeof Ye.onPostCommitFiberRoot=="function")try{Ye.onPostCommitFiberRoot(Fs,n)}catch{}c=!0}return c}finally{Rt=o,Fe.transition=i}}return!1}function bh(n,i,o){i=Ai(o,i),i=Hc(n,i,1),n=xn(n,i,1),i=fe(),n!==null&&(Oi(n,1,i),Ae(n,i))}function Bt(n,i,o){if(n.tag===3)bh(n,n,o);else for(;i!==null;){if(i.tag===3){bh(i,n,o);break}else if(i.tag===1){var c=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(kn===null||!kn.has(c))){n=Ai(o,n),n=Uc(i,n,1),i=xn(i,n,1),n=fe(),i!==null&&(Oi(i,1,n),Ae(i,n));break}}i=i.return}}function Ep(n,i,o){var c=n.pingCache;c!==null&&c.delete(i),i=fe(),n.pingedLanes|=n.suspendedLanes&o,Jt===n&&(ie&o)===o&&(Yt===4||Yt===3&&(ie&130023424)===ie&&500>Ht()-za?qn(n,0):Oa|=o),Ae(n,i)}function Eh(n,i){i===0&&((n.mode&1)===0?i=1:(i=zs,zs<<=1,(zs&130023424)===0&&(zs=4194304)));var o=fe();n=ln(n,i),n!==null&&(Oi(n,i,o),Ae(n,o))}function xp(n){var i=n.memoizedState,o=0;i!==null&&(o=i.retryLane),Eh(n,o)}function Cp(n,i){var o=0;switch(n.tag){case 13:var c=n.stateNode,d=n.memoizedState;d!==null&&(o=d.retryLane);break;case 19:c=n.stateNode;break;default:throw Error(e(314))}c!==null&&c.delete(i),Eh(n,o)}var xh;xh=function(n,i,o){if(n!==null)if(n.memoizedProps!==i.pendingProps||ve.current)we=!0;else{if((n.lanes&o)===0&&(i.flags&128)===0)return we=!1,fp(n,i,o);we=(n.flags&131072)!==0}else we=!1,Ft&&(i.flags&1048576)!==0&&sc(i,or,i.index);switch(i.lanes=0,i.tag){case 2:var c=i.type;Ar(n,i),n=i.pendingProps;var d=fi(i,se.current);wi(i,o),d=ga(null,i,c,n,d,o);var m=ma();return i.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,ye(c)?(m=!0,ir(i)):m=!1,i.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,la(i),d.updater=wr,i.stateNode=d,d._reactInternals=i,Sa(i,c,n,o),i=Ca(null,i,c,!0,m,o)):(i.tag=0,Ft&&m&&Zo(i),de(null,i,d,o),i=i.child),i;case 16:c=i.elementType;t:{switch(Ar(n,i),n=i.pendingProps,d=c._init,c=d(c._payload),i.type=c,d=i.tag=Tp(c),n=$e(c,n),d){case 0:i=xa(null,i,c,n,o);break t;case 1:i=Qc(null,i,c,n,o);break t;case 11:i=Gc(null,i,c,n,o);break t;case 14:i=Xc(null,i,c,$e(c.type,n),o);break t}throw Error(e(306,c,""))}return i;case 0:return c=i.type,d=i.pendingProps,d=i.elementType===c?d:$e(c,d),xa(n,i,c,d,o);case 1:return c=i.type,d=i.pendingProps,d=i.elementType===c?d:$e(c,d),Qc(n,i,c,d,o);case 3:t:{if(Zc(i),n===null)throw Error(e(387));c=i.pendingProps,m=i.memoizedState,d=m.element,fc(n,i),dr(i,c,null,o);var _=i.memoizedState;if(c=_.element,m.isDehydrated)if(m={element:c,isDehydrated:!1,cache:_.cache,pendingSuspenseBoundaries:_.pendingSuspenseBoundaries,transitions:_.transitions},i.updateQueue.baseState=m,i.memoizedState=m,i.flags&256){d=Ai(Error(e(423)),i),i=Jc(n,i,c,o,d);break t}else if(c!==d){d=Ai(Error(e(424)),i),i=Jc(n,i,c,o,d);break t}else for(Te=_n(i.stateNode.containerInfo.firstChild),ke=i,Ft=!0,Ue=null,o=hc(i,null,c,o),i.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(mi(),c===d){i=cn(n,i,o);break t}de(n,i,c,o)}i=i.child}return i;case 5:return mc(i),n===null&&ea(i),c=i.type,d=i.pendingProps,m=n!==null?n.memoizedProps:null,_=d.children,Go(c,d)?_=null:m!==null&&Go(c,m)&&(i.flags|=32),Kc(n,i),de(n,i,_,o),i.child;case 6:return n===null&&ea(i),null;case 13:return th(n,i,o);case 4:return ua(i,i.stateNode.containerInfo),c=i.pendingProps,n===null?i.child=vi(i,null,c,o):de(n,i,c,o),i.child;case 11:return c=i.type,d=i.pendingProps,d=i.elementType===c?d:$e(c,d),Gc(n,i,c,d,o);case 7:return de(n,i,i.pendingProps,o),i.child;case 8:return de(n,i,i.pendingProps.children,o),i.child;case 12:return de(n,i,i.pendingProps.children,o),i.child;case 10:t:{if(c=i.type._context,d=i.pendingProps,m=i.memoizedProps,_=d.value,It(ur,c._currentValue),c._currentValue=_,m!==null)if(He(m.value,_)){if(m.children===d.children&&!ve.current){i=cn(n,i,o);break t}}else for(m=i.child,m!==null&&(m.return=i);m!==null;){var b=m.dependencies;if(b!==null){_=m.child;for(var C=b.firstContext;C!==null;){if(C.context===c){if(m.tag===1){C=un(-1,o&-o),C.tag=2;var L=m.updateQueue;if(L!==null){L=L.shared;var B=L.pending;B===null?C.next=C:(C.next=B.next,B.next=C),L.pending=C}}m.lanes|=o,C=m.alternate,C!==null&&(C.lanes|=o),oa(m.return,o,i),b.lanes|=o;break}C=C.next}}else if(m.tag===10)_=m.type===i.type?null:m.child;else if(m.tag===18){if(_=m.return,_===null)throw Error(e(341));_.lanes|=o,b=_.alternate,b!==null&&(b.lanes|=o),oa(_,o,i),_=m.sibling}else _=m.child;if(_!==null)_.return=m;else for(_=m;_!==null;){if(_===i){_=null;break}if(m=_.sibling,m!==null){m.return=_.return,_=m;break}_=_.return}m=_}de(n,i,d.children,o),i=i.child}return i;case 9:return d=i.type,c=i.pendingProps.children,wi(i,o),d=Ne(d),c=c(d),i.flags|=1,de(n,i,c,o),i.child;case 14:return c=i.type,d=$e(c,i.pendingProps),d=$e(c.type,d),Xc(n,i,c,d,o);case 15:return qc(n,i,i.type,i.pendingProps,o);case 17:return c=i.type,d=i.pendingProps,d=i.elementType===c?d:$e(c,d),Ar(n,i),i.tag=1,ye(c)?(n=!0,ir(i)):n=!1,wi(i,o),jc(i,c,d),Sa(i,c,d,o),Ca(null,i,c,!0,n,o);case 19:return nh(n,i,o);case 22:return Yc(n,i,o)}throw Error(e(156,i.tag))};function Ch(n,i){return ru(n,i)}function kp(n,i,o,c){this.tag=n,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Oe(n,i,o,c){return new kp(n,i,o,c)}function Ga(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Tp(n){if(typeof n=="function")return Ga(n)?1:0;if(n!=null){if(n=n.$$typeof,n===at)return 11;if(n===kt)return 14}return 2}function Mn(n,i){var o=n.alternate;return o===null?(o=Oe(n.tag,i,n.key,n.mode),o.elementType=n.elementType,o.type=n.type,o.stateNode=n.stateNode,o.alternate=n,n.alternate=o):(o.pendingProps=i,o.type=n.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=n.flags&14680064,o.childLanes=n.childLanes,o.lanes=n.lanes,o.child=n.child,o.memoizedProps=n.memoizedProps,o.memoizedState=n.memoizedState,o.updateQueue=n.updateQueue,i=n.dependencies,o.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},o.sibling=n.sibling,o.index=n.index,o.ref=n.ref,o}function Lr(n,i,o,c,d,m){var _=2;if(c=n,typeof n=="function")Ga(n)&&(_=1);else if(typeof n=="string")_=5;else t:switch(n){case F:return Kn(o.children,d,m,i);case G:_=8,d|=8;break;case Y:return n=Oe(12,o,i,d|2),n.elementType=Y,n.lanes=m,n;case mt:return n=Oe(13,o,i,d),n.elementType=mt,n.lanes=m,n;case yt:return n=Oe(19,o,i,d),n.elementType=yt,n.lanes=m,n;case Q:return Ir(o,d,m,i);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case $:_=10;break t;case V:_=9;break t;case at:_=11;break t;case kt:_=14;break t;case K:_=16,c=null;break t}throw Error(e(130,n==null?n:typeof n,""))}return i=Oe(_,o,i,d),i.elementType=n,i.type=c,i.lanes=m,i}function Kn(n,i,o,c){return n=Oe(7,n,c,i),n.lanes=o,n}function Ir(n,i,o,c){return n=Oe(22,n,c,i),n.elementType=Q,n.lanes=o,n.stateNode={isHidden:!1},n}function Xa(n,i,o){return n=Oe(6,n,null,i),n.lanes=o,n}function qa(n,i,o){return i=Oe(4,n.children!==null?n.children:[],n.key,i),i.lanes=o,i.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},i}function Pp(n,i,o,c,d){this.tag=i,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ao(0),this.expirationTimes=Ao(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ao(0),this.identifierPrefix=c,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function Ya(n,i,o,c,d,m,_,b,C){return n=new Pp(n,i,o,b,C),i===1?(i=1,m===!0&&(i|=8)):i=0,m=Oe(3,null,null,i),n.current=m,m.stateNode=n,m.memoizedState={element:c,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},la(m),n}function Rp(n,i,o){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:H,key:c==null?null:""+c,children:n,containerInfo:i,implementation:o}}function kh(n){if(!n)return Sn;n=n._reactInternals;t:{if(zn(n)!==n||n.tag!==1)throw Error(e(170));var i=n;do{switch(i.tag){case 3:i=i.stateNode.context;break t;case 1:if(ye(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break t}}i=i.return}while(i!==null);throw Error(e(171))}if(n.tag===1){var o=n.type;if(ye(o))return ec(n,o,i)}return i}function Th(n,i,o,c,d,m,_,b,C){return n=Ya(o,c,!0,n,d,m,_,b,C),n.context=kh(null),o=n.current,c=fe(),d=Pn(o),m=un(c,d),m.callback=i??null,xn(o,m,d),n.current.lanes=d,Oi(n,d,c),Ae(n,c),n}function Nr(n,i,o,c){var d=i.current,m=fe(),_=Pn(d);return o=kh(o),i.context===null?i.context=o:i.pendingContext=o,i=un(m,_),i.payload={element:n},c=c===void 0?null:c,c!==null&&(i.callback=c),n=xn(d,i,_),n!==null&&(Ge(n,d,_,m),hr(n,d,_)),_}function Dr(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function Ph(n,i){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var o=n.retryLane;n.retryLane=o!==0&&o<i?o:i}}function Ka(n,i){Ph(n,i),(n=n.alternate)&&Ph(n,i)}function Mp(){return null}var Rh=typeof reportError=="function"?reportError:function(n){console.error(n)};function Qa(n){this._internalRoot=n}Fr.prototype.render=Qa.prototype.render=function(n){var i=this._internalRoot;if(i===null)throw Error(e(409));Nr(n,i,null,null)},Fr.prototype.unmount=Qa.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var i=n.containerInfo;Xn(function(){Nr(null,n,null,null)}),i[sn]=null}};function Fr(n){this._internalRoot=n}Fr.prototype.unstable_scheduleHydration=function(n){if(n){var i=fu();n={blockedOn:null,target:n,priority:i};for(var o=0;o<vn.length&&i!==0&&i<vn[o].priority;o++);vn.splice(o,0,n),o===0&&mu(n)}};function Za(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function Or(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Mh(){}function Lp(n,i,o,c,d){if(d){if(typeof c=="function"){var m=c;c=function(){var L=Dr(_);m.call(L)}}var _=Th(i,c,n,0,null,!1,!1,"",Mh);return n._reactRootContainer=_,n[sn]=_.current,Qi(n.nodeType===8?n.parentNode:n),Xn(),_}for(;d=n.lastChild;)n.removeChild(d);if(typeof c=="function"){var b=c;c=function(){var L=Dr(C);b.call(L)}}var C=Ya(n,0,!1,null,null,!1,!1,"",Mh);return n._reactRootContainer=C,n[sn]=C.current,Qi(n.nodeType===8?n.parentNode:n),Xn(function(){Nr(i,C,o,c)}),C}function zr(n,i,o,c,d){var m=o._reactRootContainer;if(m){var _=m;if(typeof d=="function"){var b=d;d=function(){var C=Dr(_);b.call(C)}}Nr(i,_,n,d)}else _=Lp(o,i,n,d,c);return Dr(_)}hu=function(n){switch(n.tag){case 3:var i=n.stateNode;if(i.current.memoizedState.isDehydrated){var o=Fi(i.pendingLanes);o!==0&&(So(i,o|1),Ae(i,Ht()),(Ct&6)===0&&(Ei=Ht()+500,bn()))}break;case 13:Xn(function(){var c=ln(n,1);if(c!==null){var d=fe();Ge(c,n,1,d)}}),Ka(n,1)}},bo=function(n){if(n.tag===13){var i=ln(n,134217728);if(i!==null){var o=fe();Ge(i,n,134217728,o)}Ka(n,134217728)}},du=function(n){if(n.tag===13){var i=Pn(n),o=ln(n,i);if(o!==null){var c=fe();Ge(o,n,i,c)}Ka(n,i)}},fu=function(){return Rt},pu=function(n,i){var o=Rt;try{return Rt=n,i()}finally{Rt=o}},go=function(n,i,o){switch(i){case"input":if(oo(n,o),i=o.name,o.type==="radio"&&i!=null){for(o=n;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<o.length;i++){var c=o[i];if(c!==n&&c.form===n.form){var d=er(c);if(!d)throw Error(e(90));zl(c),oo(c,d)}}}break;case"textarea":$l(n,o);break;case"select":i=o.value,i!=null&&ei(n,!!o.multiple,i,!1)}},Zl=$a,Jl=Xn;var Ip={usingClientEntryPoint:!1,Events:[ts,hi,er,Kl,Ql,$a]},ps={findFiberByHostInstance:jn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Np={bundleType:ps.bundleType,version:ps.version,rendererPackageName:ps.rendererPackageName,rendererConfig:ps.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:N.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=iu(n),n===null?null:n.stateNode},findFiberByHostInstance:ps.findFiberByHostInstance||Mp,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var jr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!jr.isDisabled&&jr.supportsFiber)try{Fs=jr.inject(Np),Ye=jr}catch{}}return Se.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Ip,Se.createPortal=function(n,i){var o=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Za(i))throw Error(e(200));return Rp(n,i,null,o)},Se.createRoot=function(n,i){if(!Za(n))throw Error(e(299));var o=!1,c="",d=Rh;return i!=null&&(i.unstable_strictMode===!0&&(o=!0),i.identifierPrefix!==void 0&&(c=i.identifierPrefix),i.onRecoverableError!==void 0&&(d=i.onRecoverableError)),i=Ya(n,1,!1,null,null,o,!1,c,d),n[sn]=i.current,Qi(n.nodeType===8?n.parentNode:n),new Qa(i)},Se.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var i=n._reactInternals;if(i===void 0)throw typeof n.render=="function"?Error(e(188)):(n=Object.keys(n).join(","),Error(e(268,n)));return n=iu(i),n=n===null?null:n.stateNode,n},Se.flushSync=function(n){return Xn(n)},Se.hydrate=function(n,i,o){if(!Or(i))throw Error(e(200));return zr(null,n,i,!0,o)},Se.hydrateRoot=function(n,i,o){if(!Za(n))throw Error(e(405));var c=o!=null&&o.hydratedSources||null,d=!1,m="",_=Rh;if(o!=null&&(o.unstable_strictMode===!0&&(d=!0),o.identifierPrefix!==void 0&&(m=o.identifierPrefix),o.onRecoverableError!==void 0&&(_=o.onRecoverableError)),i=Th(i,null,n,1,o??null,d,!1,m,_),n[sn]=i.current,Qi(n),c)for(n=0;n<c.length;n++)o=c[n],d=o._getVersion,d=d(o._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[o,d]:i.mutableSourceEagerHydrationData.push(o,d);return new Fr(i)},Se.render=function(n,i,o){if(!Or(i))throw Error(e(200));return zr(null,n,i,!1,o)},Se.unmountComponentAtNode=function(n){if(!Or(n))throw Error(e(40));return n._reactRootContainer?(Xn(function(){zr(null,null,n,!1,function(){n._reactRootContainer=null,n[sn]=null})}),!0):!1},Se.unstable_batchedUpdates=$a,Se.unstable_renderSubtreeIntoContainer=function(n,i,o,c){if(!Or(o))throw Error(e(200));if(n==null||n._reactInternals===void 0)throw Error(e(38));return zr(n,i,o,!1,c)},Se.version="18.3.1-next-f1338f8080-20240426",Se}var jh;function Up(){if(jh)return el.exports;jh=1;function g(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(g)}catch(t){console.error(t)}}return g(),el.exports=Hp(),el.exports}var Bh;function $p(){if(Bh)return Br;Bh=1;var g=Up();return Br.createRoot=g.createRoot,Br.hydrateRoot=g.hydrateRoot,Br}var Wp=$p(),Pt=Al(),Ss={};Ss.d=(g,t)=>{for(var e in t)Ss.o(t,e)&&!Ss.o(g,e)&&Object.defineProperty(g,e,{enumerable:!0,get:t[e]})};Ss.o=(g,t)=>Object.prototype.hasOwnProperty.call(g,t);var vt=globalThis.pdfjsLib={};Ss.d(vt,{AbortException:()=>Dn,AnnotationEditorLayer:()=>fn,AnnotationEditorParamsType:()=>xt,AnnotationEditorType:()=>_t,AnnotationEditorUIManager:()=>Fn,AnnotationLayer:()=>jm,AnnotationMode:()=>In,ColorPicker:()=>je,DOMSVGFactory:()=>Il,DrawLayer:()=>pe,FeatureTest:()=>me,GlobalWorkerOptions:()=>Es,ImageKind:()=>Vr,InvalidPDFException:()=>fl,MissingPDFException:()=>xs,OPS:()=>Xe,OutputScale:()=>pl,PDFDataRangeTransport:()=>Cd,PDFDateString:()=>cd,PDFWorker:()=>ee,PasswordResponses:()=>qp,PermissionFlag:()=>Xp,PixelsPerInch:()=>Pi,RenderingCancelledException:()=>El,TextLayer:()=>ge,TouchManager:()=>eo,UnexpectedResponseException:()=>Gr,Util:()=>lt,VerbosityLevel:()=>Yr,XfaLayer:()=>Td,build:()=>wm,createValidAbsoluteUrl:()=>Zp,fetchData:()=>Jr,getDocument:()=>cm,getFilenameFromUrl:()=>ag,getPdfFilenameFromUrl:()=>lg,getXfaPageViewport:()=>ug,isDataScheme:()=>to,isPdfFile:()=>xl,noContextMenu:()=>qe,normalizeUnicode:()=>sg,setLayerDimensions:()=>Zn,shadow:()=>bt,stopEvent:()=>Me,version:()=>ym});const ce=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),ld=[1,0,0,1,0,0],dl=[.001,0,0,.001,0,0],Vp=1e7,sl=1.35,Re={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},In={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Gp="pdfjs_internal_editor_",_t={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},xt={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},Xp={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},le={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Vr={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Kt={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,WIDGET:20},ms={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Yr={ERRORS:0,WARNINGS:1,INFOS:5},Xe={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},qp={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Kr=Yr.WARNINGS;function Yp(g){Number.isInteger(g)&&(Kr=g)}function Kp(){return Kr}function Qr(g){Kr>=Yr.INFOS&&console.log(`Info: ${g}`)}function At(g){Kr>=Yr.WARNINGS&&console.log(`Warning: ${g}`)}function Lt(g){throw new Error(g)}function Xt(g,t){g||Lt(t)}function Qp(g){switch(g?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Zp(g,t=null,e=null){if(!g)return null;try{if(e&&typeof g=="string"&&(e.addDefaultProtocol&&g.startsWith("www.")&&g.match(/\./g)?.length>=2&&(g=`http://${g}`),e.tryConvertEncoding))try{g=ig(g)}catch{}const s=t?new URL(g,t):new URL(g);if(Qp(s))return s}catch{}return null}function bt(g,t,e,s=!1){return Object.defineProperty(g,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const On=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class Hh extends On{constructor(t,e){super(t,"PasswordException"),this.code=e}}class rl extends On{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class fl extends On{constructor(t){super(t,"InvalidPDFException")}}class xs extends On{constructor(t){super(t,"MissingPDFException")}}class Gr extends On{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class Jp extends On{constructor(t){super(t,"FormatError")}}class Dn extends On{constructor(t){super(t,"AbortException")}}function ud(g){(typeof g!="object"||g?.length===void 0)&&Lt("Invalid argument for bytesToString");const t=g.length,e=8192;if(t<e)return String.fromCharCode.apply(null,g);const s=[];for(let r=0;r<t;r+=e){const a=Math.min(r+e,t),l=g.subarray(r,a);s.push(String.fromCharCode.apply(null,l))}return s.join("")}function Zr(g){typeof g!="string"&&Lt("Invalid argument for stringToBytes");const t=g.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=g.charCodeAt(s)&255;return e}function tg(g){return String.fromCharCode(g>>24&255,g>>16&255,g>>8&255,g&255)}function Sl(g){const t=Object.create(null);for(const[e,s]of g)t[e]=s;return t}function eg(){const g=new Uint8Array(4);return g[0]=1,new Uint32Array(g.buffer,0,1)[0]===1}function ng(){try{return new Function(""),!0}catch{return!1}}class me{static get isLittleEndian(){return bt(this,"isLittleEndian",eg())}static get isEvalSupported(){return bt(this,"isEvalSupported",ng())}static get isOffscreenCanvasSupported(){return bt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return bt(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?bt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof navigator?.userAgent=="string"&&navigator.userAgent.includes("Firefox")}):bt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return bt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const ol=Array.from(Array(256).keys(),g=>g.toString(16).padStart(2,"0"));class lt{static makeHexColor(t,e,s){return`#${ol[t]}${ol[e]}${ol[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){const s=t[0]*e[0]+t[1]*e[2]+e[4],r=t[0]*e[1]+t[1]*e[3]+e[5];return[s,r]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2],r=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,a=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s;return[r,a]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),r=this.applyTransform(t.slice(2,4),e),a=this.applyTransform([t[0],t[3]],e),l=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],r[0],a[0],l[0]),Math.min(s[1],r[1],a[1],l[1]),Math.max(s[0],r[0],a[0],l[0]),Math.max(s[1],r[1],a[1],l[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],r=t[0]*e[1]+t[1]*e[3],a=t[2]*e[0]+t[3]*e[2],l=t[2]*e[1]+t[3]*e[3],u=(s+l)/2,h=Math.sqrt((s+l)**2-4*(s*l-a*r))/2,p=u+h||1,f=u-h||1;return[Math.sqrt(p),Math.sqrt(f)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),r=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>r)return null;const a=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),l=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return a>l?null:[s,a,r,l]}static#t(t,e,s,r,a,l,u,h,p,f){if(p<=0||p>=1)return;const v=1-p,y=p*p,w=y*p,A=v*(v*(v*t+3*p*e)+3*y*s)+w*r,S=v*(v*(v*a+3*p*l)+3*y*u)+w*h;f[0]=Math.min(f[0],A),f[1]=Math.min(f[1],S),f[2]=Math.max(f[2],A),f[3]=Math.max(f[3],S)}static#e(t,e,s,r,a,l,u,h,p,f,v,y){if(Math.abs(p)<1e-12){Math.abs(f)>=1e-12&&this.#t(t,e,s,r,a,l,u,h,-v/f,y);return}const w=f**2-4*v*p;if(w<0)return;const A=Math.sqrt(w),S=2*p;this.#t(t,e,s,r,a,l,u,h,(-f+A)/S,y),this.#t(t,e,s,r,a,l,u,h,(-f-A)/S,y)}static bezierBoundingBox(t,e,s,r,a,l,u,h,p){return p?(p[0]=Math.min(p[0],t,u),p[1]=Math.min(p[1],e,h),p[2]=Math.max(p[2],t,u),p[3]=Math.max(p[3],e,h)):p=[Math.min(t,u),Math.min(e,h),Math.max(t,u),Math.max(e,h)],this.#e(t,s,a,u,e,r,l,h,3*(-t+3*(s-a)+u),6*(t-2*s+a),3*(s-t),p),this.#e(t,s,a,u,e,r,l,h,3*(-e+3*(r-l)+h),6*(e-2*r+l),3*(r-e),p),p}}function ig(g){return decodeURIComponent(escape(g))}let al=null,Uh=null;function sg(g){return al||(al=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,Uh=new Map([["ſt","ſt"]])),g.replaceAll(al,(t,e,s)=>e?e.normalize("NFKC"):Uh.get(s))}function rg(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const g=new Uint8Array(32);return crypto.getRandomValues(g),ud(g)}const bl="pdfjs_internal_id_";function og(g){return Uint8Array.prototype.toBase64?g.toBase64():btoa(ud(g))}typeof Promise.try!="function"&&(Promise.try=function(g,...t){return new Promise(e=>{e(g(...t))})});const dn="http://www.w3.org/2000/svg";class Pi{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Jr(g,t="text"){if(_s(g,document.baseURI)){const e=await fetch(g);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const r=new XMLHttpRequest;r.open("GET",g,!0),r.responseType=t,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(r.status===200||r.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(r.response);return}e(r.responseText);return}s(new Error(r.statusText))}},r.send(null)})}class ks{constructor({viewBox:t,userUnit:e,scale:s,rotation:r,offsetX:a=0,offsetY:l=0,dontFlip:u=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=r,this.offsetX=a,this.offsetY=l,s*=e;const h=(t[2]+t[0])/2,p=(t[3]+t[1])/2;let f,v,y,w;switch(r%=360,r<0&&(r+=360),r){case 180:f=-1,v=0,y=0,w=1;break;case 90:f=0,v=1,y=1,w=0;break;case 270:f=0,v=-1,y=-1,w=0;break;case 0:f=1,v=0,y=0,w=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}u&&(y=-y,w=-w);let A,S,E,x;f===0?(A=Math.abs(p-t[1])*s+a,S=Math.abs(h-t[0])*s+l,E=(t[3]-t[1])*s,x=(t[2]-t[0])*s):(A=Math.abs(h-t[0])*s+a,S=Math.abs(p-t[1])*s+l,E=(t[2]-t[0])*s,x=(t[3]-t[1])*s),this.transform=[f*s,v*s,y*s,w*s,A-f*s*h-y*s*p,S-v*s*h-w*s*p],this.width=E,this.height=x}get rawDims(){const{userUnit:t,viewBox:e}=this,s=e.map(r=>r*t);return bt(this,"rawDims",{pageWidth:s[2]-s[0],pageHeight:s[3]-s[1],pageX:s[0],pageY:s[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:r=this.offsetY,dontFlip:a=!1}={}){return new ks({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:r,dontFlip:a})}convertToViewportPoint(t,e){return lt.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=lt.applyTransform([t[0],t[1]],this.transform),s=lt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return lt.applyInverseTransform([t,e],this.transform)}}class El extends On{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function to(g){const t=g.length;let e=0;for(;e<t&&g[e].trim()==="";)e++;return g.substring(e,e+5).toLowerCase()==="data:"}function xl(g){return typeof g=="string"&&/\.pdf$/i.test(g)}function ag(g){return[g]=g.split(/[#?]/,1),g.substring(g.lastIndexOf("/")+1)}function lg(g,t="document.pdf"){if(typeof g!="string")return t;if(to(g))return At('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,r=e.exec(g);let a=s.exec(r[1])||s.exec(r[2])||s.exec(r[3]);if(a&&(a=a[0],a.includes("%")))try{a=s.exec(decodeURIComponent(a))[0]}catch{}return a||t}class $h{started=Object.create(null);times=[];time(t){t in this.started&&At(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||At(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:r,end:a}of this.times)t.push(`${s.padEnd(e)} ${a-r}ms
|
|
41
|
+
`);return t.join("")}}function _s(g,t){try{const{protocol:e}=t?new URL(g,t):new URL(g);return e==="http:"||e==="https:"}catch{return!1}}function qe(g){g.preventDefault()}function Me(g){g.preventDefault(),g.stopPropagation()}class cd{static#t;static toDateObject(t){if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#t.exec(t);if(!e)return null;const s=parseInt(e[1],10);let r=parseInt(e[2],10);r=r>=1&&r<=12?r-1:0;let a=parseInt(e[3],10);a=a>=1&&a<=31?a:1;let l=parseInt(e[4],10);l=l>=0&&l<=23?l:0;let u=parseInt(e[5],10);u=u>=0&&u<=59?u:0;let h=parseInt(e[6],10);h=h>=0&&h<=59?h:0;const p=e[7]||"Z";let f=parseInt(e[8],10);f=f>=0&&f<=23?f:0;let v=parseInt(e[9],10)||0;return v=v>=0&&v<=59?v:0,p==="-"?(l+=f,u+=v):p==="+"&&(l-=f,u-=v),new Date(Date.UTC(s,r,a,l,u,h))}}function ug(g,{scale:t=1,rotation:e=0}){const{width:s,height:r}=g.attributes.style,a=[0,0,parseInt(s),parseInt(r)];return new ks({viewBox:a,userUnit:1,scale:t,rotation:e})}function Cl(g){if(g.startsWith("#")){const t=parseInt(g.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return g.startsWith("rgb(")?g.slice(4,-1).split(",").map(t=>parseInt(t)):g.startsWith("rgba(")?g.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(At(`Not a valid color format: "${g}"`),[0,0,0])}function cg(g){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of g.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;g.set(e,Cl(s))}t.remove()}function Ot(g){const{a:t,b:e,c:s,d:r,e:a,f:l}=g.getTransform();return[t,e,s,r,a,l]}function tn(g){const{a:t,b:e,c:s,d:r,e:a,f:l}=g.getTransform().invertSelf();return[t,e,s,r,a,l]}function Zn(g,t,e=!1,s=!0){if(t instanceof ks){const{pageWidth:r,pageHeight:a}=t.rawDims,{style:l}=g,u=me.isCSSRoundSupported,h=`var(--scale-factor) * ${r}px`,p=`var(--scale-factor) * ${a}px`,f=u?`round(down, ${h}, var(--scale-round-x, 1px))`:`calc(${h})`,v=u?`round(down, ${p}, var(--scale-round-y, 1px))`:`calc(${p})`;!e||t.rotation%180===0?(l.width=f,l.height=v):(l.width=v,l.height=f)}s&&g.setAttribute("data-main-rotation",t.rotation)}class pl{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}}class bs{#t=null;#e=null;#n;#i=null;#r=null;static#s=null;constructor(t){this.#n=t,bs.#s||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){const t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#n._uiManager._signal;t.addEventListener("contextmenu",qe,{signal:e}),t.addEventListener("pointerdown",bs.#l,{signal:e});const s=this.#i=document.createElement("div");s.className="buttons",t.append(s);const r=this.#n.toolbarPosition;if(r){const{style:a}=t,l=this.#n._uiManager.direction==="ltr"?1-r[0]:r[0];a.insetInlineEnd=`${100*l}%`,a.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#t}static#l(t){t.stopPropagation()}#a(t){this.#n._focusEventsAllowed=!1,Me(t)}#c(t){this.#n._focusEventsAllowed=!0,Me(t)}#u(t){const e=this.#n._uiManager._signal;t.addEventListener("focusin",this.#a.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",qe,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#r?.shown()}#d(){const{editorType:t,_uiManager:e}=this.#n,s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",bs.#s[t]),this.#u(s),s.addEventListener("click",r=>{e.delete()},{signal:e._signal}),this.#i.append(s)}get#h(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#u(e),this.#i.prepend(e,this.#h),this.#r=t}addColorPicker(t){this.#e=t;const e=t.renderButton();this.#u(e),this.#i.prepend(e,this.#h)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class hg{#t=null;#e=null;#n;constructor(t){this.#n=t}#i(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",qe,{signal:this.#n._signal});const e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#s(),t}#r(t,e){let s=0,r=0;for(const a of t){const l=a.y+a.height;if(l<s)continue;const u=a.x+(e?a.width:0);if(l>s){r=u,s=l;continue}e?u>r&&(r=u):u<r&&(r=u)}return[e?1-r:r,s]}show(t,e,s){const[r,a]=this.#r(e,s),{style:l}=this.#e||=this.#i();t.append(this.#e),l.insetInlineEnd=`${100*r}%`,l.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#s(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const s=this.#n._signal;t.addEventListener("contextmenu",qe,{signal:s}),t.addEventListener("click",()=>{this.#n.highlightSelection("floating_button")},{signal:s}),this.#t.append(t)}}function Xr(g,t,e){for(const s of e)t.addEventListener(s,g[s].bind(g))}class dg{#t=0;get id(){return`${Gp}${this.#t++}`}}class kl{#t=rg();#e=0;#n=null;static get _isSVGFittingCanvas(){const t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),r=new Image;r.src=t;const a=r.decode().then(()=>(s.drawImage(r,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return bt(this,"_isSVGFittingCanvas",a)}async#i(t,e){this.#n||=new Map;let s=this.#n.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let r;if(typeof e=="string"?(s.url=e,r=await Jr(e,"blob")):e instanceof File?r=s.file=e:e instanceof Blob&&(r=e),r.type==="image/svg+xml"){const a=kl._isSVGFittingCanvas,l=new FileReader,u=new Image,h=new Promise((p,f)=>{u.onload=()=>{s.bitmap=u,s.isSvg=!0,p()},l.onload=async()=>{const v=s.svgUrl=l.result;u.src=await a?`${v}#svgView(preserveAspectRatio(none))`:v},u.onerror=l.onerror=f});l.readAsDataURL(r),await h}else s.bitmap=await createImageBitmap(r);s.refCounter=1}catch(r){At(r),s=null}return this.#n.set(t,s),s&&this.#n.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:r,type:a}=t;return this.#i(`${e}_${s}_${r}_${a}`,t)}async getFromUrl(t){return this.#i(t,t)}async getFromBlob(t,e){const s=await e;return this.#i(t,s)}async getFromId(t){this.#n||=new Map;const e=this.#n.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#n||=new Map;let s=this.#n.get(t);if(s?.bitmap)return s.refCounter+=1,s;const r=new OffscreenCanvas(e.width,e.height);return r.getContext("2d").drawImage(e,0,0),s={bitmap:r.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#n.set(t,s),this.#n.set(s.id,s),s}getSvgUrl(t){const e=this.#n.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#n||=new Map;const e=this.#n.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class fg{#t=[];#e=!1;#n;#i=-1;constructor(t=128){this.#n=t}add({cmd:t,undo:e,post:s,mustExec:r,type:a=NaN,overwriteIfSameType:l=!1,keepUndo:u=!1}){if(r&&t(),this.#e)return;const h={cmd:t,undo:e,post:s,type:a};if(this.#i===-1){this.#t.length>0&&(this.#t.length=0),this.#i=0,this.#t.push(h);return}if(l&&this.#t[this.#i].type===a){u&&(h.undo=this.#t[this.#i].undo),this.#t[this.#i]=h;return}const p=this.#i+1;p===this.#n?this.#t.splice(0,1):(this.#i=p,p<this.#t.length&&this.#t.splice(p)),this.#t.push(h)}undo(){if(this.#i===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1,this.#i-=1}redo(){if(this.#i<this.#t.length-1){this.#i+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#i!==-1}hasSomethingToRedo(){return this.#i<this.#t.length-1}cleanType(t){if(this.#i!==-1){for(let e=this.#i;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#i-e),this.#i=e;return}this.#t.length=0,this.#i=-1}}destroy(){this.#t=null}}class Ts{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=me.platform;for(const[s,r,a={}]of t)for(const l of s){const u=l.startsWith("mac+");e&&u?(this.callbacks.set(l.slice(4),{callback:r,options:a}),this.allKeys.add(l.split("+").at(-1))):!e&&!u&&(this.callbacks.set(l,{callback:r,options:a}),this.allKeys.add(l.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(this.#t(e));if(!s)return;const{callback:r,options:{bubbles:a=!1,args:l=[],checker:u=null}}=s;u&&!u(t,e)||(r.bind(t,...l,e)(),a||Me(e))}}class Tl{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return cg(t),bt(this,"_colors",t)}convert(t){const e=Cl(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,r]of this._colors)if(r.every((a,l)=>a===e[l]))return Tl._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?lt.makeHexColor(...e):t}}class Fn{#t=new AbortController;#e=null;#n=new Map;#i=new Map;#r=null;#s=null;#l=null;#a=new fg;#c=null;#u=null;#d=0;#h=new Set;#f=null;#o=null;#p=new Set;_editorUndoBar=null;#m=!1;#g=!1;#v=!1;#_=null;#y=null;#A=null;#b=null;#x=!1;#k=null;#P=new dg;#S=!1;#T=!1;#C=null;#M=null;#N=null;#F=null;#E=_t.NONE;#w=new Set;#I=null;#H=null;#U=null;#$={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#O=[0,0];#D=null;#z=null;#W=null;#L=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=Fn.prototype,e=l=>l.#z.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&l.hasSomethingToControl(),s=(l,{target:u})=>{if(u instanceof HTMLInputElement){const{type:h}=u;return h!=="text"&&h!=="number"}return!0},r=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return bt(this,"_keyboardManager",new Ts([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(l,{target:u})=>!(u instanceof HTMLButtonElement)&&l.#z.contains(u)&&!l.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(l,{target:u})=>!(u instanceof HTMLButtonElement)&&l.#z.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-a,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[a,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-a],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,a],checker:e}]]))}constructor(t,e,s,r,a,l,u,h,p,f,v,y,w){const A=this._signal=this.#t.signal;this.#z=t,this.#W=e,this.#r=s,this._eventBus=r,r._on("editingaction",this.onEditingAction.bind(this),{signal:A}),r._on("pagechanging",this.onPageChanging.bind(this),{signal:A}),r._on("scalechanging",this.onScaleChanging.bind(this),{signal:A}),r._on("rotationchanging",this.onRotationChanging.bind(this),{signal:A}),r._on("setpreference",this.onSetPreference.bind(this),{signal:A}),r._on("switchannotationeditorparams",S=>this.updateParams(S.type,S.value),{signal:A}),this.#et(),this.#rt(),this.#q(),this.#s=a.annotationStorage,this.#_=a.filterFactory,this.#H=l,this.#b=u||null,this.#m=h,this.#g=p,this.#v=f,this.#F=v||null,this.viewParameters={realScale:Pi.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=y||null,this._supportsPinchToZoom=w!==!1}destroy(){this.#L?.resolve(),this.#L=null,this.#t?.abort(),this.#t=null,this._signal=null;for(const t of this.#i.values())t.destroy();this.#i.clear(),this.#n.clear(),this.#p.clear(),this.#e=null,this.#w.clear(),this.#a.destroy(),this.#r?.destroy(),this.#k?.hide(),this.#k=null,this.#y&&(clearTimeout(this.#y),this.#y=null),this.#D&&(clearTimeout(this.#D),this.#D=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#F}get useNewAltTextFlow(){return this.#g}get useNewAltTextWhenAddingImage(){return this.#v}get hcmFilter(){return bt(this,"hcmFilter",this.#H?this.#_.addHCMFilter(this.#H.foreground,this.#H.background):"none")}get direction(){return bt(this,"direction",getComputedStyle(this.#z).direction)}get highlightColors(){return bt(this,"highlightColors",this.#b?new Map(this.#b.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return bt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#u=t}setMainHighlightColorPicker(t){this.#N=t}editAltText(t,e=!1){this.#r?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":this.#v=e;break}}onPageChanging({pageNumber:t}){this.#d=t-1}focusMainContainer(){this.#z.focus()}findParent(t,e){for(const s of this.#i.values()){const{x:r,y:a,width:l,height:u}=s.div.getBoundingClientRect();if(t>=r&&t<=r+l&&e>=a&&e<=a+u)return s}return null}disableUserSelect(t=!1){this.#W.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#p.add(t)}removeShouldRescale(t){this.#p.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Pi.PDF_TO_CSS_UNITS;for(const e of this.#p)e.onScaleChanging();this.#u?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#j({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#X(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of this.#i.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:r,focusNode:a,focusOffset:l}=e,u=e.toString(),p=this.#j(e).closest(".textLayer"),f=this.getSelectionBoxes(p);if(!f)return;e.empty();const v=this.#X(p),y=this.#E===_t.NONE,w=()=>{v?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:f,anchorNode:s,anchorOffset:r,focusNode:a,focusOffset:l,text:u}),y&&this.showAllEditors("highlight",!0,!0)};if(y){this.switchToMode(_t.HIGHLIGHT,w);return}w()}#J(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=this.#j(t).closest(".textLayer"),r=this.getSelectionBoxes(s);r&&(this.#k||=new hg(this),this.#k.show(s,r,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#s&&!this.#s.has(t.id)&&this.#s.setValue(t.id,t)}#tt(){const t=document.getSelection();if(!t||t.isCollapsed){this.#I&&(this.#k?.hide(),this.#I=null,this.#R({hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===this.#I)return;const r=this.#j(t).closest(".textLayer");if(!r){this.#I&&(this.#k?.hide(),this.#I=null,this.#R({hasSelectedText:!1}));return}if(this.#k?.hide(),this.#I=e,this.#R({hasSelectedText:!0}),!(this.#E!==_t.HIGHLIGHT&&this.#E!==_t.NONE)&&(this.#E===_t.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#x=this.isShiftKeyDown,!this.isShiftKeyDown)){const a=this.#E===_t.HIGHLIGHT?this.#X(r):null;a?.toggleDrawing();const l=new AbortController,u=this.combinedSignal(l),h=p=>{p.type==="pointerup"&&p.button!==0||(l.abort(),a?.toggleDrawing(!0),p.type==="pointerup"&&this.#G("main_toolbar"))};window.addEventListener("pointerup",h,{signal:u}),window.addEventListener("blur",h,{signal:u})}}#G(t=""){this.#E===_t.HIGHLIGHT?this.highlightSelection(t):this.#m&&this.#J()}#et(){document.addEventListener("selectionchange",this.#tt.bind(this),{signal:this._signal})}#nt(){if(this.#A)return;this.#A=new AbortController;const t=this.combinedSignal(this.#A);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#it(){this.#A?.abort(),this.#A=null}blur(){if(this.isShiftKeyDown=!1,this.#x&&(this.#x=!1,this.#G("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#w)if(e.div.contains(t)){this.#M=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#M)return;const[t,e]=this.#M;this.#M=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#q(){if(this.#C)return;this.#C=new AbortController;const t=this.combinedSignal(this.#C);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#st(){this.#C?.abort(),this.#C=null}#Y(){if(this.#c)return;this.#c=new AbortController;const t=this.combinedSignal(this.#c);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#K(){this.#c?.abort(),this.#c=null}#rt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#q(),this.#Y()}removeEditListeners(){this.#st(),this.#K()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#o)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#o)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of this.#w){const r=s.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const a of e.items)for(const l of this.#o)if(l.isHandlingMimeForPasting(a.type)){l.paste(a,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(a){At(`paste: "${a.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const r=this.currentLayer;try{const a=[];for(const h of s){const p=await r.deserialize(h);if(!p)return;a.push(p)}const l=()=>{for(const h of a)this.#Q(h);this.#Z(a)},u=()=>{for(const h of a)h.remove()};this.addCommands({cmd:l,undo:u,mustExec:!0})}catch(a){At(`paste: "${a.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#E!==_t.NONE&&!this.isEditorHandlingKeyboard&&Fn._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#x&&(this.#x=!1,this.#G("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}#R(t){Object.entries(t).some(([s,r])=>this.#$[s]!==r)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#$,t)}),this.#E===_t.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#B([[xt.HIGHLIGHT_FREE,!0]]))}#B(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#nt(),this.#Y(),this.#R({isEditing:this.#E!==_t.NONE,isEmpty:this.#V(),hasSomethingToUndo:this.#a.hasSomethingToUndo(),hasSomethingToRedo:this.#a.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#it(),this.#K(),this.#R({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#o){this.#o=t;for(const e of this.#o)this.#B(e.defaultPropertiesToUpdate)}}getId(){return this.#P.id}get currentLayer(){return this.#i.get(this.#d)}getLayer(t){return this.#i.get(t)}get currentPageIndex(){return this.#d}addLayer(t){this.#i.set(t.pageIndex,t),this.#S?t.enable():t.disable()}removeLayer(t){this.#i.delete(t.pageIndex)}async updateMode(t,e=null,s=!1){if(this.#E!==t&&!(this.#L&&(await this.#L.promise,!this.#L))){if(this.#L=Promise.withResolvers(),this.#E=t,t===_t.NONE){this.setEditingState(!1),this.#at(),this._editorUndoBar?.hide(),this.#L.resolve();return}this.setEditingState(!0),await this.#ot(),this.unselectAll();for(const r of this.#i.values())r.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),this.#L.resolve();return}for(const r of this.#n.values())r.annotationElementId===e?(this.setSelected(r),r.enterInEditMode()):r.unselect();this.#L.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#E&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#o){switch(t){case xt.CREATE:this.currentLayer.addNewEditor();return;case xt.HIGHLIGHT_DEFAULT_COLOR:this.#N?.updateColor(e);break;case xt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#U||=new Map).set(t,e),this.showAllEditors("highlight",e);break}for(const s of this.#w)s.updateParams(t,e);for(const s of this.#o)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const a of this.#n.values())a.editorType===t&&a.show(e);(this.#U?.get(xt.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#B([[xt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#T!==t){this.#T=t;for(const e of this.#i.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#ot(){if(!this.#S){this.#S=!0;const t=[];for(const e of this.#i.values())t.push(e.enable());await Promise.all(t);for(const e of this.#n.values())e.enable()}}#at(){if(this.unselectAll(),this.#S){this.#S=!1;for(const t of this.#i.values())t.disable();for(const t of this.#n.values())t.disable()}}getEditors(t){const e=[];for(const s of this.#n.values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return this.#n.get(t)}addEditor(t){this.#n.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.focusMainContainer(),this.#y=null},0)),this.#n.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#h.has(t.annotationElementId))&&this.#s?.remove(t.id)}addDeletedAnnotationElement(t){this.#h.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#h.has(t)}removeDeletedAnnotationElement(t){this.#h.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Q(t){const e=this.#i.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#B(t.propertiesToUpdate))}get#lt(){let t=null;for(t of this.#w);return t}updateUI(t){this.#lt===t&&this.#B(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#B(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#w.has(t)){this.#w.delete(t),t.unselect(),this.#R({hasSelectedEditor:this.hasSelection});return}this.#w.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}setSelected(t){this.#u?.commitOrRemove();for(const e of this.#w)e!==t&&e.unselect();this.#w.clear(),this.#w.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}isSelected(t){return this.#w.has(t)}get firstSelectedEditor(){return this.#w.values().next().value}unselect(t){t.unselect(),this.#w.delete(t),this.#R({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#w.size!==0}get isEnterHandled(){return this.#w.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#a.undo(),this.#R({hasSomethingToUndo:this.#a.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#V()}),this._editorUndoBar?.hide()}redo(){this.#a.redo(),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:this.#a.hasSomethingToRedo(),isEmpty:this.#V()})}addCommands(t){this.#a.add(t),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#V()})}cleanUndoStack(t){this.#a.cleanType(t)}#V(){if(this.#n.size===0)return!0;if(this.#n.size===1)for(const t of this.#n.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#w],s=()=>{this._editorUndoBar?.show(r,e.length===1?e[0].editorType:e.length);for(const a of e)a.remove()},r=()=>{for(const a of e)this.#Q(a)};this.addCommands({cmd:s,undo:r,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#Z(t){for(const e of this.#w)e.unselect();this.#w.clear();for(const e of t)e.isEmpty()||(this.#w.add(e),e.select());this.#R({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#w)t.commit();this.#Z(this.#n.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#E!==_t.NONE))&&!this.#u?.commitOrRemove()&&this.hasSelection){for(const t of this.#w)t.unselect();this.#w.clear(),this.#R({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#O[0]+=t,this.#O[1]+=e;const[r,a]=this.#O,l=[...this.#w],u=1e3;this.#D&&clearTimeout(this.#D),this.#D=setTimeout(()=>{this.#D=null,this.#O[0]=this.#O[1]=0,this.addCommands({cmd:()=>{for(const h of l)this.#n.has(h.id)&&h.translateInPage(r,a)},undo:()=>{for(const h of l)this.#n.has(h.id)&&h.translateInPage(-r,-a)},mustExec:!1})},u);for(const h of l)h.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(const t of this.#w)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);const t=this.#f;this.#f=null;let e=!1;for(const[{x:r,y:a,pageIndex:l},u]of t)u.newX=r,u.newY=a,u.newPageIndex=l,e||=r!==u.savedX||a!==u.savedY||l!==u.savedPageIndex;if(!e)return!1;const s=(r,a,l,u)=>{if(this.#n.has(r.id)){const h=this.#i.get(u);h?r._setParentAndPosition(h,a,l):(r.pageIndex=u,r.x=a,r.y=l)}};return this.addCommands({cmd:()=>{for(const[r,{newX:a,newY:l,newPageIndex:u}]of t)s(r,a,l,u)},undo:()=>{for(const[r,{savedX:a,savedY:l,savedPageIndex:u}]of t)s(r,a,l,u)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(const s of this.#f.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#w.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#E}get imageManager(){return bt(this,"imageManager",new kl)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let p=0,f=e.rangeCount;p<f;p++)if(!t.contains(e.getRangeAt(p).commonAncestorContainer))return null;const{x:s,y:r,width:a,height:l}=t.getBoundingClientRect();let u;switch(t.getAttribute("data-main-rotation")){case"90":u=(p,f,v,y)=>({x:(f-r)/l,y:1-(p+v-s)/a,width:y/l,height:v/a});break;case"180":u=(p,f,v,y)=>({x:1-(p+v-s)/a,y:1-(f+y-r)/l,width:v/a,height:y/l});break;case"270":u=(p,f,v,y)=>({x:1-(f+y-r)/l,y:(p-s)/a,width:y/l,height:v/a});break;default:u=(p,f,v,y)=>({x:(p-s)/a,y:(f-r)/l,width:v/a,height:y/l});break}const h=[];for(let p=0,f=e.rangeCount;p<f;p++){const v=e.getRangeAt(p);if(!v.collapsed)for(const{x:y,y:w,width:A,height:S}of v.getClientRects())A===0||S===0||h.push(u(y,w,A,S))}return h.length===0?null:h}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#l||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#l?.delete(t)}renderAnnotationElement(t){const e=this.#l?.get(t.data.id);if(!e)return;const s=this.#s.getRawValue(e);s&&(this.#E===_t.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}}class nn{#t=null;#e=!1;#n=null;#i=null;#r=null;#s=null;#l=!1;#a=null;#c=null;#u=null;#d=null;#h=!1;static#f=null;static _l10n=null;constructor(t){this.#c=t,this.#h=t._uiManager.useNewAltTextFlow,nn.#f||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){nn._l10n??=t}async render(){const t=this.#n=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#i=document.createElement("span");t.append(e),this.#h?(t.classList.add("new"),t.setAttribute("data-l10n-id",nn.#f.missing),e.setAttribute("data-l10n-id",nn.#f["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=this.#c._uiManager._signal;t.addEventListener("contextmenu",qe,{signal:s}),t.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:s});const r=a=>{a.preventDefault(),this.#c._uiManager.editAltText(this.#c),this.#h&&this.#c._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#o}})};return t.addEventListener("click",r,{capture:!0,signal:s}),t.addEventListener("keydown",a=>{a.target===t&&a.key==="Enter"&&(this.#l=!0,r(a))},{signal:s}),await this.#p(),t}get#o(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#n&&(this.#n.focus({focusVisible:this.#l}),this.#l=!1)}isEmpty(){return this.#h?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#h?this.#t!==null||!!this.#u:this.isEmpty()}get guessedText(){return this.#u}async setGuessedText(t){this.#t===null&&(this.#u=t,this.#d=await nn._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#p())}toggleAltTextBadge(t=!1){if(!this.#h||this.#t){this.#a?.remove(),this.#a=null;return}if(!this.#a){const e=this.#a=document.createElement("div");e.className="noAltTextBadge",this.#c.div.append(e)}this.#a.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#u===e&&(e=this.#d),{altText:e,decorative:this.#e,guessedText:this.#u,textWithDisclaimer:this.#d}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:r,cancel:a=!1}){s&&(this.#u=s,this.#d=r),!(this.#t===t&&this.#e===e)&&(a||(this.#t=t,this.#e=e),this.#p())}toggle(t=!1){this.#n&&(!t&&this.#s&&(clearTimeout(this.#s),this.#s=null),this.#n.disabled=!t)}shown(){this.#c._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#o}})}destroy(){this.#n?.remove(),this.#n=null,this.#i=null,this.#r=null,this.#a?.remove(),this.#a=null}async#p(){const t=this.#n;if(!t)return;if(this.#h){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",nn.#f[this.#o]),this.#i?.setAttribute("data-l10n-id",nn.#f[`${this.#o}-label`]),!this.#t){this.#r?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#r?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#r;if(!e){this.#r=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#c.id}`;const r=100,a=this.#c._uiManager._signal;a.addEventListener("abort",()=>{clearTimeout(this.#s),this.#s=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#s=setTimeout(()=>{this.#s=null,this.#r.classList.add("show"),this.#c._reportTelemetry({action:"alt_text_tooltip"})},r)},{signal:a}),t.addEventListener("mouseleave",()=>{this.#s&&(clearTimeout(this.#s),this.#s=null),this.#r?.classList.remove("show")},{signal:a})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#c.getImageForAltText()?.setAttribute("aria-describedby",e.id)}}class eo{#t;#e=!1;#n=null;#i;#r;#s;#l;#a;#c=null;#u;#d=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:r=null,onPinching:a=null,onPinchEnd:l=null,signal:u}){this.#t=t,this.#n=s,this.#i=e,this.#r=r,this.#s=a,this.#l=l,this.#u=new AbortController,this.#a=AbortSignal.any([u,this.#u.signal]),t.addEventListener("touchstart",this.#h.bind(this),{passive:!1,signal:this.#a})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return bt(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#h(t){if(this.#i?.()||t.touches.length<2)return;if(!this.#d){this.#d=new AbortController;const r=AbortSignal.any([this.#a,this.#d.signal]),a=this.#t,l={signal:r,passive:!1};a.addEventListener("touchmove",this.#f.bind(this),l),a.addEventListener("touchend",this.#o.bind(this),l),a.addEventListener("touchcancel",this.#o.bind(this),l),this.#r?.()}if(Me(t),t.touches.length!==2||this.#n?.()){this.#c=null;return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),this.#c={touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY}}#f(t){if(!this.#c||t.touches.length!==2)return;let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:r,screenY:a}=e,{screenX:l,screenY:u}=s,h=this.#c,{touch0X:p,touch0Y:f,touch1X:v,touch1Y:y}=h,w=v-p,A=y-f,S=l-r,E=u-a,x=Math.hypot(S,E)||1,M=Math.hypot(w,A)||1;if(!this.#e&&Math.abs(M-x)<=eo.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(h.touch0X=r,h.touch0Y=a,h.touch1X=l,h.touch1Y=u,t.preventDefault(),!this.#e){this.#e=!0;return}const I=[(r+l)/2,(a+u)/2];this.#s?.(I,M,x)}#o(t){this.#d.abort(),this.#d=null,this.#l?.(),this.#c&&(t.preventDefault(),this.#c=null,this.#e=!1)}destroy(){this.#u?.abort(),this.#u=null}}class pt{#t=null;#e=null;#n=null;#i=!1;#r=null;#s="";#l=!1;#a=null;#c=null;#u=null;#d=null;#h="";#f=!1;#o=null;#p=!1;#m=!1;#g=!1;#v=null;#_=0;#y=0;#A=null;#b=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#x=!1;#k=pt._zIndex++;static _borderLineWidth=-1;static _colorManager=new Tl;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=pt.prototype._resizeWithKeyboard,e=Fn.TRANSLATE_SMALL,s=Fn.TRANSLATE_BIG;return bt(this,"_resizerKeyboardManager",new Ts([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],pt.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:s,pageHeight:r,pageX:a,pageY:l}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,r],this.pageTranslation=[a,l];const[u,h]=this.parentDimensions;this.x=t.x/u,this.y=t.y/h,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return bt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new pg({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(pt._l10n??=t,pt._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),pt._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);pt._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Lt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#x}set _isDraggable(t){this.#x=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#k}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#j(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,r){const[a,l]=this.parentDimensions;[s,r]=this.screenToPageTranslation(s,r),this.x=(t+s)/a,this.y=(e+r)/l,this.fixAndSetPosition()}#P([t,e],s,r){[s,r]=this.screenToPageTranslation(s,r),this.x+=s/t,this.y+=r/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#P(this.parentDimensions,t,e)}translateInPage(t,e){this.#o||=[this.x,this.y,this.width,this.height],this.#P(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#o||=[this.x,this.y,this.width,this.height];const{div:s,parentDimensions:[r,a]}=this;if(this.x+=t/r,this.y+=e/a,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:v,y}=this.div.getBoundingClientRect();this.parent.findNewParent(this,v,y)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:l,y:u}=this;const[h,p]=this.getBaseTranslation();l+=h,u+=p;const{style:f}=s;f.left=`${(100*l).toFixed(2)}%`,f.top=`${(100*u).toFixed(2)}%`,this._onTranslating(l,u),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#o&&(this.#o[0]!==this.x||this.#o[1]!==this.y)}get _hasBeenResized(){return!!this.#o&&(this.#o[2]!==this.width||this.#o[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=pt,r=s/t,a=s/e;switch(this.rotation){case 90:return[-r,a];case 180:return[r,a];case 270:return[r,-a];default:return[-r,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,r]}=this;let{x:a,y:l,width:u,height:h}=this;if(u*=s,h*=r,a*=s,l*=r,this._mustFixPosition)switch(t){case 0:a=Math.max(0,Math.min(s-u,a)),l=Math.max(0,Math.min(r-h,l));break;case 90:a=Math.max(0,Math.min(s-h,a)),l=Math.min(r,Math.max(u,l));break;case 180:a=Math.min(s,Math.max(u,a)),l=Math.min(r,Math.max(h,l));break;case 270:a=Math.min(s,Math.max(h,a)),l=Math.max(0,Math.min(r-u,l));break}this.x=a/=s,this.y=l/=r;const[p,f]=this.getBaseTranslation();a+=p,l+=f,e.left=`${(100*a).toFixed(2)}%`,e.top=`${(100*l).toFixed(2)}%`,this.moveInDOM()}static#S(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return pt.#S(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return pt.#S(t,e,360-this.parentRotation)}#T(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(t,e){const[s,r]=this.parentDimensions,{style:a}=this.div;a.width=`${(100*t/s).toFixed(2)}%`,this.#l||(a.height=`${(100*e/r).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,r=s.endsWith("%"),a=!this.#l&&e.endsWith("%");if(r&&a)return;const[l,u]=this.parentDimensions;r||(t.width=`${(100*parseFloat(s)/l).toFixed(2)}%`),!this.#l&&!a&&(t.height=`${(100*parseFloat(e)/u).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#C(){if(this.#a)return;this.#a=document.createElement("div"),this.#a.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const r=document.createElement("div");this.#a.append(r),r.classList.add("resizer",s),r.setAttribute("data-resizer-name",s),r.addEventListener("pointerdown",this.#M.bind(this,s),{signal:e}),r.addEventListener("contextmenu",qe,{signal:e}),r.tabIndex=-1}this.div.prepend(this.#a)}#M(t,e){e.preventDefault();const{isMac:s}=me.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#n?.toggle(!1);const r=this._isDraggable;this._isDraggable=!1,this.#c=[e.screenX,e.screenY];const a=new AbortController,l=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#E.bind(this,t),{passive:!0,capture:!0,signal:l}),window.addEventListener("touchmove",Me,{passive:!1,signal:l}),window.addEventListener("contextmenu",qe,{signal:l}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const u=this.parent.div.style.cursor,h=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const p=()=>{a.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=u,this.div.style.cursor=h,this.#F()};window.addEventListener("pointerup",p,{signal:l}),window.addEventListener("blur",p,{signal:l})}#N(t,e,s,r){this.width=s,this.height=r,this.x=t,this.y=e;const[a,l]=this.parentDimensions;this.setDims(a*s,l*r),this.fixAndSetPosition(),this._onResized()}_onResized(){}#F(){if(!this.#u)return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:r}=this.#u;this.#u=null;const a=this.x,l=this.y,u=this.width,h=this.height;a===t&&l===e&&u===s&&h===r||this.addCommands({cmd:this.#N.bind(this,a,l,u,h),undo:this.#N.bind(this,t,e,s,r),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#E(t,e){const[s,r]=this.parentDimensions,a=this.x,l=this.y,u=this.width,h=this.height,p=pt.MIN_SIZE/s,f=pt.MIN_SIZE/r,v=this.#T(this.rotation),y=(K,Q)=>[v[0]*K+v[2]*Q,v[1]*K+v[3]*Q],w=this.#T(360-this.rotation),A=(K,Q)=>[w[0]*K+w[2]*Q,w[1]*K+w[3]*Q];let S,E,x=!1,M=!1;switch(t){case"topLeft":x=!0,S=(K,Q)=>[0,0],E=(K,Q)=>[K,Q];break;case"topMiddle":S=(K,Q)=>[K/2,0],E=(K,Q)=>[K/2,Q];break;case"topRight":x=!0,S=(K,Q)=>[K,0],E=(K,Q)=>[0,Q];break;case"middleRight":M=!0,S=(K,Q)=>[K,Q/2],E=(K,Q)=>[0,Q/2];break;case"bottomRight":x=!0,S=(K,Q)=>[K,Q],E=(K,Q)=>[0,0];break;case"bottomMiddle":S=(K,Q)=>[K/2,Q],E=(K,Q)=>[K/2,0];break;case"bottomLeft":x=!0,S=(K,Q)=>[0,Q],E=(K,Q)=>[K,0];break;case"middleLeft":M=!0,S=(K,Q)=>[0,Q/2],E=(K,Q)=>[K,Q/2];break}const I=S(u,h),N=E(u,h);let O=y(...N);const H=pt._round(a+O[0]),F=pt._round(l+O[1]);let G=1,Y=1,$,V;if(e.fromKeyboard)({deltaX:$,deltaY:V}=e);else{const{screenX:K,screenY:Q}=e,[q,it]=this.#c;[$,V]=this.screenToPageTranslation(K-q,Q-it),this.#c[0]=K,this.#c[1]=Q}if([$,V]=A($/s,V/r),x){const K=Math.hypot(u,h);G=Y=Math.max(Math.min(Math.hypot(N[0]-I[0]-$,N[1]-I[1]-V)/K,1/u,1/h),p/u,f/h)}else M?G=Math.max(p,Math.min(1,Math.abs(N[0]-I[0]-$)))/u:Y=Math.max(f,Math.min(1,Math.abs(N[1]-I[1]-V)))/h;const at=pt._round(u*G),mt=pt._round(h*Y);O=y(...E(at,mt));const yt=H-O[0],kt=F-O[1];this.#o||=[this.x,this.y,this.width,this.height],this.width=at,this.height=mt,this.x=yt,this.y=kt,this.setDims(s*at,r*mt),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}async addEditToolbar(){return this._editToolbar||this.#m?this._editToolbar:(this._editToolbar=new bs(this),this.div.append(this._editToolbar.render()),this.#n&&await this._editToolbar.addAltText(this.#n),this._editToolbar)}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#n?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#n||(nn.initialize(pt._l10n),this.#n=new nn(this),this.#t&&(this.#n.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#n?.data}set altTextData(t){this.#n&&(this.#n.data=t)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(t){await this.#n?.setGuessedText(t)}serializeAltText(t){return this.#n?.serialize(t)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#i?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#O();const[t,e]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[s,r]=this.getInitialTranslation();return this.translate(s,r),Xr(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#b||=new eo({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#w.bind(this),onPinching:this.#I.bind(this),onPinchEnd:this.#H.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#w(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#I(t,e,s){let a=.7*(s/e)+1-.7;if(a===1)return;const l=this.#T(this.rotation),u=(H,F)=>[l[0]*H+l[2]*F,l[1]*H+l[3]*F],[h,p]=this.parentDimensions,f=this.x,v=this.y,y=this.width,w=this.height,A=pt.MIN_SIZE/h,S=pt.MIN_SIZE/p;a=Math.max(Math.min(a,1/y,1/w),A/y,S/w);const E=pt._round(y*a),x=pt._round(w*a);if(E===y&&x===w)return;this.#o||=[f,v,y,w];const M=u(y/2,w/2),I=pt._round(f+M[0]),N=pt._round(v+M[1]),O=u(E/2,x/2);this.x=I-O[0],this.y=N-O[1],this.width=E,this.height=x,this.setDims(h*E,p*x),this.fixAndSetPosition(),this._onResizing()}#H(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#F()}pointerdown(t){const{isMac:e}=me.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#f=!0,this._isDraggable){this.#$(t);return}this.#U(t)}get isSelected(){return this._uiManager.isSelected(this)}#U(t){const{isMac:e}=me.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#$(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const r=new AbortController,a=this._uiManager.combinedSignal(r),l={capture:!0,passive:!1,signal:a},u=p=>{r.abort(),this.#r=null,this.#f=!1,this._uiManager.endDragSession()||this.#U(p),s&&this._onStopDragging()};e&&(this.#_=t.clientX,this.#y=t.clientY,this.#r=t.pointerId,this.#s=t.pointerType,window.addEventListener("pointermove",p=>{s||(s=!0,this._onStartDragging());const{clientX:f,clientY:v,pointerId:y}=p;if(y!==this.#r){Me(p);return}const[w,A]=this.screenToPageTranslation(f-this.#_,v-this.#y);this.#_=f,this.#y=v,this._uiManager.dragSelectedEditors(w,A)},l),window.addEventListener("touchmove",Me,l),window.addEventListener("pointerdown",p=>{p.pointerType===this.#s&&(this.#b||p.isPrimary)&&u(p),Me(p)},l));const h=p=>{if(!this.#r||this.#r===p.pointerId){u(p);return}Me(p)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#v&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const r=this.parentScale,[a,l]=this.pageDimensions,[u,h]=this.pageTranslation,p=t/r,f=e/r,v=this.x*a,y=this.y*l,w=this.width*a,A=this.height*l;switch(s){case 0:return[v+p+u,l-y-f-A+h,v+p+w+u,l-y-f+h];case 90:return[v+f+u,l-y+p+h,v+f+A+u,l-y+p+w+h];case 180:return[v-p-w+u,l-y+f+h,v-p+u,l-y+f+A+h];case 270:return[v-f-A+u,l-y-p-w+h,v-f+u,l-y-p+h];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,r,a,l]=t,u=a-s,h=l-r;switch(this.rotation){case 0:return[s,e-l,u,h];case 90:return[s,e-r,h,u];case 180:return[a,e-r,u,h];case 270:return[a,e-l,h,u];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:r}=this.getClientDimensions(),{innerHeight:a,innerWidth:l}=window;return e<l&&r>0&&t<a&&s>0}#O(){if(this.#d||!this.div)return;this.#d=new AbortController;const t=this._uiManager.combinedSignal(this.#d);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#O()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){Lt("An editor must be serializable")}static async deserialize(t,e,s){const r=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});r.rotation=t.rotation,r.#t=t.accessibilityData;const[a,l]=r.pageDimensions,[u,h,p,f]=r.getRectInCurrentCoords(t.rect,l);return r.x=u/a,r.y=h/l,r.width=p/a,r.height=f/l,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#d?.abort(),this.#d=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#v&&(clearTimeout(this.#v),this.#v=null),this.#j(),this.removeEditToolbar(),this.#A){for(const t of this.#A.values())clearTimeout(t);this.#A=null}this.parent=null,this.#b?.destroy(),this.#b=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#C(),this.#a.classList.remove("hidden"),Xr(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#a.children;if(!this.#e){this.#e=Array.from(e);const l=this.#D.bind(this),u=this.#z.bind(this),h=this._uiManager._signal;for(const p of this.#e){const f=p.getAttribute("data-resizer-name");p.setAttribute("role","spinbutton"),p.addEventListener("keydown",l,{signal:h}),p.addEventListener("blur",u,{signal:h}),p.addEventListener("focus",this.#W.bind(this,f),{signal:h}),p.setAttribute("data-l10n-id",pt._l10nResizer[f])}}const s=this.#e[0];let r=0;for(const l of e){if(l===s)break;r++}const a=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(a!==r){if(a<r)for(let u=0;u<r-a;u++)this.#a.append(this.#a.firstChild);else if(a>r)for(let u=0;u<a-r;u++)this.#a.firstChild.before(this.#a.lastChild);let l=0;for(const u of e){const p=this.#e[l++].getAttribute("data-resizer-name");u.setAttribute("data-l10n-id",pt._l10nResizer[p])}}this.#L(0),this.#g=!0,this.#a.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#D(t){pt._resizerKeyboardManager.exec(this,t)}#z(t){this.#g&&t.relatedTarget?.parentNode!==this.#a&&this.#j()}#W(t){this.#h=this.#g?t:""}#L(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#g&&this.#E(this.#h,{deltaX:t,deltaY:e,fromKeyboard:!0})}#j(){this.#g=!1,this.#L(-1),this.#F()}_stopResizingWithKeyboard(){this.#j(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}unselect(){this.#a?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#l=!0;const s=t/e,{style:r}=this.div;r.aspectRatio=s,r.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#A||=new Map;const{action:s}=t;let r=this.#A.get(s);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),this.#A.delete(s),this.#A.size===0&&(this.#A=null)},pt._telemetryTimeout),this.#A.set(s,r);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#i=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#i=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class pg extends pt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Wh=3285377520,ze=4294901760,en=65535;class hd{constructor(t){this.h1=t?t&4294967295:Wh,this.h2=t?t&4294967295:Wh}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let S=0,E=t.length;S<E;S++){const x=t.charCodeAt(S);x<=255?e[s++]=x:(e[s++]=x>>>8,e[s++]=x&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const r=s>>2,a=s-r*4,l=new Uint32Array(e.buffer,0,r);let u=0,h=0,p=this.h1,f=this.h2;const v=3432918353,y=461845907,w=v&en,A=y&en;for(let S=0;S<r;S++)S&1?(u=l[S],u=u*v&ze|u*w&en,u=u<<15|u>>>17,u=u*y&ze|u*A&en,p^=u,p=p<<13|p>>>19,p=p*5+3864292196):(h=l[S],h=h*v&ze|h*w&en,h=h<<15|h>>>17,h=h*y&ze|h*A&en,f^=h,f=f<<13|f>>>19,f=f*5+3864292196);switch(u=0,a){case 3:u^=e[r*4+2]<<16;case 2:u^=e[r*4+1]<<8;case 1:u^=e[r*4],u=u*v&ze|u*w&en,u=u<<15|u>>>17,u=u*y&ze|u*A&en,r&1?p^=u:f^=u}this.h1=p,this.h2=f}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&ze|t*36045&en,e=e*4283543511&ze|((e<<16|t>>>16)*2950163797&ze)>>>16,t^=e>>>1,t=t*444984403&ze|t*60499&en,e=e*3301882366&ze|((e<<16|t>>>16)*3120437893&ze)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const gl=Object.freeze({map:null,hash:"",transfer:void 0});class Pl{#t=!1;#e=null;#n=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=this.#n.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#n.get(t)}remove(t){if(this.#n.delete(t),this.#n.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of this.#n.values())if(e instanceof pt)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=this.#n.get(t);let r=!1;if(s!==void 0)for(const[a,l]of Object.entries(e))s[a]!==l&&(r=!0,s[a]=l);else r=!0,this.#n.set(t,e);r&&this.#i(),e instanceof pt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#n.has(t)}getAll(){return this.#n.size>0?Sl(this.#n):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return this.#n.size}#i(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new dd(this)}get serializable(){if(this.#n.size===0)return gl;const t=new Map,e=new hd,s=[],r=Object.create(null);let a=!1;for(const[l,u]of this.#n){const h=u instanceof pt?u.serialize(!1,r):u;h&&(t.set(l,h),e.update(`${l}:${JSON.stringify(h)}`),a||=!!h.bitmap)}if(a)for(const l of t.values())l.bitmap&&s.push(l.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:gl}get editorStats(){let t=null;const e=new Map;for(const s of this.#n.values()){if(!(s instanceof pt))continue;const r=s.telemetryFinalData;if(!r)continue;const{type:a}=r;e.has(a)||e.set(a,Object.getPrototypeOf(s).constructor),t||=Object.create(null);const l=t[a]||=new Map;for(const[u,h]of Object.entries(r)){if(u==="type")continue;let p=l.get(u);p||(p=new Map,l.set(u,p));const f=p.get(h)??0;p.set(h,f+1)}}for(const[s,r]of e)t[s]=r.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){this.#e=null}get modifiedIds(){if(this.#e)return this.#e;const t=[];for(const e of this.#n.values())!(e instanceof pt)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return this.#e={ids:new Set(t),hash:t.join(",")}}}class dd extends Pl{#t;constructor(t){super();const{map:e,hash:s,transfer:r}=t.serializable,a=structuredClone(e,r?{transfer:r}:null);this.#t={map:a,hash:s,transfer:r}}get print(){Lt("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return bt(this,"modifiedIds",{ids:new Set,hash:""})}}class gg{#t=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#t.has(t.loadedName))){if(Xt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:r,style:a}=t,l=new FontFace(s,r,a);this.addNativeFontFace(l);try{await l.load(),this.#t.add(s),e?.(t)}catch{At(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(l)}return}Lt("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(r){throw At(`Failed to load font '${s.family}': '${r}'.`),t.disableFontFace=!0,r}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const r=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,r)})}}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return bt(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(ce||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),bt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(Xt(!r.done,"completeRequest() cannot be called twice."),r.done=!0;s.length>0&&s[0].done;){const a=s.shift();setTimeout(a.callback,0)}}const{loadingRequests:s}=this,r={done:!1,complete:e,callback:t};return s.push(r),r}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return bt(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(N,O){return N.charCodeAt(O)<<24|N.charCodeAt(O+1)<<16|N.charCodeAt(O+2)<<8|N.charCodeAt(O+3)&255}function r(N,O,H,F){const G=N.substring(0,O),Y=N.substring(O+H);return G+F+Y}let a,l;const u=this._document.createElement("canvas");u.width=1,u.height=1;const h=u.getContext("2d");let p=0;function f(N,O){if(++p>30){At("Load test font never loaded."),O();return}if(h.font="30px "+N,h.fillText(".",0,20),h.getImageData(0,0,1,1).data[3]>0){O();return}setTimeout(f.bind(null,N,O))}const v=`lt${Date.now()}${this.loadTestFontId++}`;let y=this._loadTestFont;y=r(y,976,v.length,v);const A=16,S=1482184792;let E=s(y,A);for(a=0,l=v.length-3;a<l;a+=4)E=E-S+s(v,a)|0;a<v.length&&(E=E-S+s(v+"XXX",a)|0),y=r(y,A,4,tg(E));const x=`url(data:font/opentype;base64,${btoa(y)});`,M=`@font-face {font-family:"${v}";src:${x}}`;this.insertRule(M);const I=this._document.createElement("div");I.style.visibility="hidden",I.style.width=I.style.height="10px",I.style.position="absolute",I.style.top=I.style.left="0px";for(const N of[t.loadedName,v]){const O=this._document.createElement("span");O.textContent="Hi",O.style.fontFamily=N,I.append(O)}this._document.body.append(I),f(v,()=>{I.remove(),e.complete()})}}class mg{constructor(t,{disableFontFace:e=!1,fontExtraProperties:s=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(const a in t)this[a]=t[a];this.disableFontFace=e===!0,this.fontExtraProperties=s===!0,this._inspectFont=r}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${og(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let r;try{r=t.get(s)}catch(l){At(`getPathGenerator - ignoring character: "${l}".`)}const a=new Path2D(r||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=a}}const Hr={DATA:1,ERROR:2},Gt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Vh(){}function Ee(g){if(g instanceof Dn||g instanceof fl||g instanceof xs||g instanceof Hh||g instanceof Gr||g instanceof rl)return g;switch(g instanceof Error||typeof g=="object"&&g!==null||Lt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),g.name){case"AbortException":return new Dn(g.message);case"InvalidPDFException":return new fl(g.message);case"MissingPDFException":return new xs(g.message);case"PasswordException":return new Hh(g.message,g.code);case"UnexpectedResponseException":return new Gr(g.message,g.status);case"UnknownErrorException":return new rl(g.message,g.details)}return new rl(g.message,g.toString())}class As{#t=new AbortController;constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#i(t);return}if(t.callback){const s=t.callbackId,r=this.callbackCapabilities[s];if(!r)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===Hr.DATA)r.resolve(t.data);else if(t.callback===Hr.ERROR)r.reject(Ee(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,r=t.sourceName,a=this.comObj;Promise.try(e,t.data).then(function(l){a.postMessage({sourceName:s,targetName:r,callback:Hr.DATA,callbackId:t.callbackId,data:l})},function(l){a.postMessage({sourceName:s,targetName:r,callback:Hr.ERROR,callbackId:t.callbackId,reason:Ee(l)})});return}if(t.streamId){this.#n(t);return}e(t.data)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const r=this.callbackId++,a=Promise.withResolvers();this.callbackCapabilities[r]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:r,data:e},s)}catch(l){a.reject(l)}return a.promise}sendWithStream(t,e,s,r){const a=this.streamId++,l=this.sourceName,u=this.targetName,h=this.comObj;return new ReadableStream({start:p=>{const f=Promise.withResolvers();return this.streamControllers[a]={controller:p,startCall:f,pullCall:null,cancelCall:null,isClosed:!1},h.postMessage({sourceName:l,targetName:u,action:t,streamId:a,data:e,desiredSize:p.desiredSize},r),f.promise},pull:p=>{const f=Promise.withResolvers();return this.streamControllers[a].pullCall=f,h.postMessage({sourceName:l,targetName:u,stream:Gt.PULL,streamId:a,desiredSize:p.desiredSize}),f.promise},cancel:p=>{Xt(p instanceof Error,"cancel must have a valid reason");const f=Promise.withResolvers();return this.streamControllers[a].cancelCall=f,this.streamControllers[a].isClosed=!0,h.postMessage({sourceName:l,targetName:u,stream:Gt.CANCEL,streamId:a,reason:Ee(p)}),f.promise}},s)}#n(t){const e=t.streamId,s=this.sourceName,r=t.sourceName,a=this.comObj,l=this,u=this.actionHandler[t.action],h={enqueue(p,f=1,v){if(this.isCancelled)return;const y=this.desiredSize;this.desiredSize-=f,y>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:s,targetName:r,stream:Gt.ENQUEUE,streamId:e,chunk:p},v)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:s,targetName:r,stream:Gt.CLOSE,streamId:e}),delete l.streamSinks[e])},error(p){Xt(p instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,a.postMessage({sourceName:s,targetName:r,stream:Gt.ERROR,streamId:e,reason:Ee(p)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};h.sinkCapability.resolve(),h.ready=h.sinkCapability.promise,this.streamSinks[e]=h,Promise.try(u,t.data,h).then(function(){a.postMessage({sourceName:s,targetName:r,stream:Gt.START_COMPLETE,streamId:e,success:!0})},function(p){a.postMessage({sourceName:s,targetName:r,stream:Gt.START_COMPLETE,streamId:e,reason:Ee(p)})})}#i(t){const e=t.streamId,s=this.sourceName,r=t.sourceName,a=this.comObj,l=this.streamControllers[e],u=this.streamSinks[e];switch(t.stream){case Gt.START_COMPLETE:t.success?l.startCall.resolve():l.startCall.reject(Ee(t.reason));break;case Gt.PULL_COMPLETE:t.success?l.pullCall.resolve():l.pullCall.reject(Ee(t.reason));break;case Gt.PULL:if(!u){a.postMessage({sourceName:s,targetName:r,stream:Gt.PULL_COMPLETE,streamId:e,success:!0});break}u.desiredSize<=0&&t.desiredSize>0&&u.sinkCapability.resolve(),u.desiredSize=t.desiredSize,Promise.try(u.onPull||Vh).then(function(){a.postMessage({sourceName:s,targetName:r,stream:Gt.PULL_COMPLETE,streamId:e,success:!0})},function(p){a.postMessage({sourceName:s,targetName:r,stream:Gt.PULL_COMPLETE,streamId:e,reason:Ee(p)})});break;case Gt.ENQUEUE:if(Xt(l,"enqueue should have stream controller"),l.isClosed)break;l.controller.enqueue(t.chunk);break;case Gt.CLOSE:if(Xt(l,"close should have stream controller"),l.isClosed)break;l.isClosed=!0,l.controller.close(),this.#r(l,e);break;case Gt.ERROR:Xt(l,"error should have stream controller"),l.controller.error(Ee(t.reason)),this.#r(l,e);break;case Gt.CANCEL_COMPLETE:t.success?l.cancelCall.resolve():l.cancelCall.reject(Ee(t.reason)),this.#r(l,e);break;case Gt.CANCEL:if(!u)break;const h=Ee(t.reason);Promise.try(u.onCancel||Vh,h).then(function(){a.postMessage({sourceName:s,targetName:r,stream:Gt.CANCEL_COMPLETE,streamId:e,success:!0})},function(p){a.postMessage({sourceName:s,targetName:r,stream:Gt.CANCEL_COMPLETE,streamId:e,reason:Ee(p)})}),u.sinkCapability.reject(h),u.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#r(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}}class fd{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Lt("Abstract method `_createCanvas` called.")}}class vg extends fd{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class pd{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){Lt("Abstract method `_fetch` called.")}}class gd extends pd{async _fetch(t){const e=await Jr(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Zr(e)}}class md{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,r,a){return"none"}destroy(t=!1){}}class yg extends md{#t;#e;#n;#i;#r;#s;#l=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#i=t,this.#r=e}get#a(){return this.#e||=new Map}get#c(){return this.#s||=new Map}get#u(){if(!this.#n){const t=this.#r.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const s=this.#r.createElementNS(dn,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#n=this.#r.createElementNS(dn,"defs"),t.append(s),s.append(this.#n),this.#r.body.append(t)}return this.#n}#d(t){if(t.length===1){const h=t[0],p=new Array(256);for(let v=0;v<256;v++)p[v]=h[v]/255;const f=p.join(",");return[f,f,f]}const[e,s,r]=t,a=new Array(256),l=new Array(256),u=new Array(256);for(let h=0;h<256;h++)a[h]=e[h]/255,l[h]=s[h]/255,u[h]=r[h]/255;return[a.join(","),l.join(","),u.join(",")]}#h(t){if(this.#t===void 0){this.#t="";const e=this.#r.URL;e!==this.#r.baseURI&&(to(e)?At('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=e.split("#",1)[0])}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#a.get(t);if(e)return e;const[s,r,a]=this.#d(t),l=t.length===1?s:`${s}${r}${a}`;if(e=this.#a.get(l),e)return this.#a.set(t,e),e;const u=`g_${this.#i}_transfer_map_${this.#l++}`,h=this.#h(u);this.#a.set(t,h),this.#a.set(l,h);const p=this.#p(u);return this.#g(s,r,a,p),h}addHCMFilter(t,e){const s=`${t}-${e}`,r="base";let a=this.#c.get(r);if(a?.key===s||(a?(a.filter?.remove(),a.key=s,a.url="none",a.filter=null):(a={key:s,url:"none",filter:null},this.#c.set(r,a)),!t||!e))return a.url;const l=this.#_(t);t=lt.makeHexColor(...l);const u=this.#_(e);if(e=lt.makeHexColor(...u),this.#u.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return a.url;const h=new Array(256);for(let w=0;w<=255;w++){const A=w/255;h[w]=A<=.03928?A/12.92:((A+.055)/1.055)**2.4}const p=h.join(","),f=`g_${this.#i}_hcm_filter`,v=a.filter=this.#p(f);this.#g(p,p,p,v),this.#o(v);const y=(w,A)=>{const S=l[w]/255,E=u[w]/255,x=new Array(A+1);for(let M=0;M<=A;M++)x[M]=S+M/A*(E-S);return x.join(",")};return this.#g(y(0,5),y(1,5),y(2,5),v),a.url=this.#h(f),a.url}addAlphaFilter(t){let e=this.#a.get(t);if(e)return e;const[s]=this.#d([t]),r=`alpha_${s}`;if(e=this.#a.get(r),e)return this.#a.set(t,e),e;const a=`g_${this.#i}_alpha_map_${this.#l++}`,l=this.#h(a);this.#a.set(t,l),this.#a.set(r,l);const u=this.#p(a);return this.#v(s,u),l}addLuminosityFilter(t){let e=this.#a.get(t||"luminosity");if(e)return e;let s,r;if(t?([s]=this.#d([t]),r=`luminosity_${s}`):r="luminosity",e=this.#a.get(r),e)return this.#a.set(t,e),e;const a=`g_${this.#i}_luminosity_map_${this.#l++}`,l=this.#h(a);this.#a.set(t,l),this.#a.set(r,l);const u=this.#p(a);return this.#f(u),t&&this.#v(s,u),l}addHighlightHCMFilter(t,e,s,r,a){const l=`${e}-${s}-${r}-${a}`;let u=this.#c.get(t);if(u?.key===l||(u?(u.filter?.remove(),u.key=l,u.url="none",u.filter=null):(u={key:l,url:"none",filter:null},this.#c.set(t,u)),!e||!s))return u.url;const[h,p]=[e,s].map(this.#_.bind(this));let f=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),v=Math.round(.2126*p[0]+.7152*p[1]+.0722*p[2]),[y,w]=[r,a].map(this.#_.bind(this));v<f&&([f,v,y,w]=[v,f,w,y]),this.#u.style.color="";const A=(x,M,I)=>{const N=new Array(256),O=(v-f)/I,H=x/255,F=(M-x)/(255*I);let G=0;for(let Y=0;Y<=I;Y++){const $=Math.round(f+Y*O),V=H+Y*F;for(let at=G;at<=$;at++)N[at]=V;G=$+1}for(let Y=G;Y<256;Y++)N[Y]=N[G-1];return N.join(",")},S=`g_${this.#i}_hcm_${t}_filter`,E=u.filter=this.#p(S);return this.#o(E),this.#g(A(y[0],w[0],5),A(y[1],w[1],5),A(y[2],w[2],5),E),u.url=this.#h(S),u.url}destroy(t=!1){t&&this.#s?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#e?.clear(),this.#e=null,this.#s?.clear(),this.#s=null,this.#l=0)}#f(t){const e=this.#r.createElementNS(dn,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#o(t){const e=this.#r.createElementNS(dn,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#p(t){const e=this.#r.createElementNS(dn,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#u.append(e),e}#m(t,e,s){const r=this.#r.createElementNS(dn,e);r.setAttribute("type","discrete"),r.setAttribute("tableValues",s),t.append(r)}#g(t,e,s,r){const a=this.#r.createElementNS(dn,"feComponentTransfer");r.append(a),this.#m(a,"feFuncR",t),this.#m(a,"feFuncG",e),this.#m(a,"feFuncB",s)}#v(t,e){const s=this.#r.createElementNS(dn,"feComponentTransfer");e.append(s),this.#m(s,"feFuncA",t)}#_(t){return this.#u.style.color=t,Cl(getComputedStyle(this.#u).getPropertyValue("color"))}}class vd{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){Lt("Abstract method `_fetch` called.")}}class yd extends vd{async _fetch(t){const e=await Jr(t,"arraybuffer");return new Uint8Array(e)}}ce&&At("Please use the `legacy` build in Node.js environments.");async function wd(g){const e=await process.getBuiltinModule("fs").promises.readFile(g);return new Uint8Array(e)}class wg extends md{}class _g extends fd{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class Ag extends pd{async _fetch(t){return wd(t)}}class Sg extends vd{async _fetch(t){return wd(t)}}const ue={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function ml(g,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],e,s),g.clip(r)}class Rl{getPattern(){Lt("Abstract method `getPattern` called.")}}class bg extends Rl{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,r){let a;if(r===ue.STROKE||r===ue.FILL){const l=e.current.getClippedPathBoundingBox(r,Ot(t))||[0,0,0,0],u=Math.ceil(l[2]-l[0])||1,h=Math.ceil(l[3]-l[1])||1,p=e.cachedCanvases.getCanvas("pattern",u,h),f=p.context;f.clearRect(0,0,f.canvas.width,f.canvas.height),f.beginPath(),f.rect(0,0,f.canvas.width,f.canvas.height),f.translate(-l[0],-l[1]),s=lt.transform(s,[1,0,0,1,l[0],l[1]]),f.transform(...e.baseTransform),this.matrix&&f.transform(...this.matrix),ml(f,this._bbox),f.fillStyle=this._createGradient(f),f.fill(),a=t.createPattern(p.canvas,"no-repeat");const v=new DOMMatrix(s);a.setTransform(v)}else ml(t,this._bbox),a=this._createGradient(t);return a}}function ll(g,t,e,s,r,a,l,u){const h=t.coords,p=t.colors,f=g.data,v=g.width*4;let y;h[e+1]>h[s+1]&&(y=e,e=s,s=y,y=a,a=l,l=y),h[s+1]>h[r+1]&&(y=s,s=r,r=y,y=l,l=u,u=y),h[e+1]>h[s+1]&&(y=e,e=s,s=y,y=a,a=l,l=y);const w=(h[e]+t.offsetX)*t.scaleX,A=(h[e+1]+t.offsetY)*t.scaleY,S=(h[s]+t.offsetX)*t.scaleX,E=(h[s+1]+t.offsetY)*t.scaleY,x=(h[r]+t.offsetX)*t.scaleX,M=(h[r+1]+t.offsetY)*t.scaleY;if(A>=M)return;const I=p[a],N=p[a+1],O=p[a+2],H=p[l],F=p[l+1],G=p[l+2],Y=p[u],$=p[u+1],V=p[u+2],at=Math.round(A),mt=Math.round(M);let yt,kt,K,Q,q,it,z,k;for(let D=at;D<=mt;D++){if(D<E){const ut=D<A?0:(A-D)/(A-E);yt=w-(w-S)*ut,kt=I-(I-H)*ut,K=N-(N-F)*ut,Q=O-(O-G)*ut}else{let ut;D>M?ut=1:E===M?ut=0:ut=(E-D)/(E-M),yt=S-(S-x)*ut,kt=H-(H-Y)*ut,K=F-(F-$)*ut,Q=G-(G-V)*ut}let rt;D<A?rt=0:D>M?rt=1:rt=(A-D)/(A-M),q=w-(w-x)*rt,it=I-(I-Y)*rt,z=N-(N-$)*rt,k=O-(O-V)*rt;const J=Math.round(Math.min(yt,q)),wt=Math.round(Math.max(yt,q));let dt=v*D+J*4;for(let ut=J;ut<=wt;ut++)rt=(yt-ut)/(yt-q),rt<0?rt=0:rt>1&&(rt=1),f[dt++]=kt-(kt-it)*rt|0,f[dt++]=K-(K-z)*rt|0,f[dt++]=Q-(Q-k)*rt|0,f[dt++]=255}}function Eg(g,t,e){const s=t.coords,r=t.colors;let a,l;switch(t.type){case"lattice":const u=t.verticesPerRow,h=Math.floor(s.length/u)-1,p=u-1;for(a=0;a<h;a++){let f=a*u;for(let v=0;v<p;v++,f++)ll(g,e,s[f],s[f+1],s[f+u],r[f],r[f+1],r[f+u]),ll(g,e,s[f+u+1],s[f+1],s[f+u],r[f+u+1],r[f+1],r[f+u])}break;case"triangles":for(a=0,l=s.length;a<l;a+=3)ll(g,e,s[a],s[a+1],s[a+2],r[a],r[a+1],r[a+2]);break;default:throw new Error("illegal figure")}}class xg extends Rl{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,s){const u=Math.floor(this._bounds[0]),h=Math.floor(this._bounds[1]),p=Math.ceil(this._bounds[2])-u,f=Math.ceil(this._bounds[3])-h,v=Math.min(Math.ceil(Math.abs(p*t[0]*1.1)),3e3),y=Math.min(Math.ceil(Math.abs(f*t[1]*1.1)),3e3),w=p/v,A=f/y,S={coords:this._coords,colors:this._colors,offsetX:-u,offsetY:-h,scaleX:1/w,scaleY:1/A},E=v+4,x=y+4,M=s.getCanvas("mesh",E,x),I=M.context,N=I.createImageData(v,y);if(e){const H=N.data;for(let F=0,G=H.length;F<G;F+=4)H[F]=e[0],H[F+1]=e[1],H[F+2]=e[2],H[F+3]=255}for(const H of this._figures)Eg(N,H,S);return I.putImageData(N,2,2),{canvas:M.canvas,offsetX:u-2*w,offsetY:h-2*A,scaleX:w,scaleY:A}}getPattern(t,e,s,r){ml(t,this._bbox);let a;if(r===ue.SHADING)a=lt.singularValueDecompose2dScale(Ot(t));else if(a=lt.singularValueDecompose2dScale(e.baseTransform),this.matrix){const u=lt.singularValueDecompose2dScale(this.matrix);a=[a[0]*u[0],a[1]*u[1]]}const l=this._createMeshCanvas(a,r===ue.SHADING?null:this._background,e.cachedCanvases);return r!==ue.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(l.offsetX,l.offsetY),t.scale(l.scaleX,l.scaleY),t.createPattern(l.canvas,"no-repeat")}}class Cg extends Rl{getPattern(){return"hotpink"}}function kg(g){switch(g[0]){case"RadialAxial":return new bg(g);case"Mesh":return new xg(g);case"Dummy":return new Cg}throw new Error(`Unknown IR type: ${g[0]}`)}const Gh={COLORED:1,UNCOLORED:2};class Ml{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,r,a){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=s,this.canvasGraphicsFactory=r,this.baseTransform=a}createPatternCanvas(t){const{bbox:e,operatorList:s,paintType:r,tilingType:a,color:l,canvasGraphicsFactory:u}=this;let{xstep:h,ystep:p}=this;h=Math.abs(h),p=Math.abs(p),Qr("TilingType: "+a);const f=e[0],v=e[1],y=e[2],w=e[3],A=y-f,S=w-v,E=lt.singularValueDecompose2dScale(this.matrix),x=lt.singularValueDecompose2dScale(this.baseTransform),M=E[0]*x[0],I=E[1]*x[1];let N=A,O=S,H=!1,F=!1;const G=Math.ceil(h*M),Y=Math.ceil(p*I),$=Math.ceil(A*M),V=Math.ceil(S*I);G>=$?N=h:H=!0,Y>=V?O=p:F=!0;const at=this.getSizeAndScale(N,this.ctx.canvas.width,M),mt=this.getSizeAndScale(O,this.ctx.canvas.height,I),yt=t.cachedCanvases.getCanvas("pattern",at.size,mt.size),kt=yt.context,K=u.createCanvasGraphics(kt);if(K.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(K,r,l),kt.translate(-at.scale*f,-mt.scale*v),K.transform(at.scale,0,0,mt.scale,0,0),kt.save(),this.clipBbox(K,f,v,y,w),K.baseTransform=Ot(K.ctx),K.executeOperatorList(s),K.endDrawing(),kt.restore(),H||F){const Q=yt.canvas;H&&(N=h),F&&(O=p);const q=this.getSizeAndScale(N,this.ctx.canvas.width,M),it=this.getSizeAndScale(O,this.ctx.canvas.height,I),z=q.size,k=it.size,D=t.cachedCanvases.getCanvas("pattern-workaround",z,k),rt=D.context,J=H?Math.floor(A/h):0,wt=F?Math.floor(S/p):0;for(let dt=0;dt<=J;dt++)for(let ut=0;ut<=wt;ut++)rt.drawImage(Q,z*dt,k*ut,z,k,0,0,z,k);return{canvas:D.canvas,scaleX:q.scale,scaleY:it.scale,offsetX:f,offsetY:v}}return{canvas:yt.canvas,scaleX:at.scale,scaleY:mt.scale,offsetX:f,offsetY:v}}getSizeAndScale(t,e,s){const r=Math.max(Ml.MAX_PATTERN_SIZE,e);let a=Math.ceil(t*s);return a>=r?a=r:s=a/t,{scale:s,size:a}}clipBbox(t,e,s,r,a){const l=r-e,u=a-s;t.ctx.rect(e,s,l,u),t.current.updateRectMinMax(Ot(t.ctx),[e,s,r,a]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const r=t.ctx,a=t.current;switch(e){case Gh.COLORED:const l=this.ctx;r.fillStyle=l.fillStyle,r.strokeStyle=l.strokeStyle,a.fillColor=l.fillStyle,a.strokeColor=l.strokeStyle;break;case Gh.UNCOLORED:const u=lt.makeHexColor(s[0],s[1],s[2]);r.fillStyle=u,r.strokeStyle=u,a.fillColor=u,a.strokeColor=u;break;default:throw new Jp(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,r){let a=s;r!==ue.SHADING&&(a=lt.transform(a,e.baseTransform),this.matrix&&(a=lt.transform(a,this.matrix)));const l=this.createPatternCanvas(e);let u=new DOMMatrix(a);u=u.translate(l.offsetX,l.offsetY),u=u.scale(1/l.scaleX,1/l.scaleY);const h=t.createPattern(l.canvas,"repeat");return h.setTransform(u),h}}function Tg({src:g,srcPos:t=0,dest:e,width:s,height:r,nonBlackColor:a=4294967295,inverseDecode:l=!1}){const u=me.isLittleEndian?4278190080:255,[h,p]=l?[a,u]:[u,a],f=s>>3,v=s&7,y=g.length;e=new Uint32Array(e.buffer);let w=0;for(let A=0;A<r;A++){for(const E=t+f;t<E;t++){const x=t<y?g[t]:255;e[w++]=x&128?p:h,e[w++]=x&64?p:h,e[w++]=x&32?p:h,e[w++]=x&16?p:h,e[w++]=x&8?p:h,e[w++]=x&4?p:h,e[w++]=x&2?p:h,e[w++]=x&1?p:h}if(v===0)continue;const S=t<y?g[t++]:255;for(let E=0;E<v;E++)e[w++]=S&1<<7-E?p:h}return{srcPos:t,destPos:w}}const Xh=16,qh=100,Pg=15,Yh=10,Kh=1e3,xe=16;function Rg(g,t){if(g._removeMirroring)throw new Error("Context is already forwarding operations.");g.__originalSave=g.save,g.__originalRestore=g.restore,g.__originalRotate=g.rotate,g.__originalScale=g.scale,g.__originalTranslate=g.translate,g.__originalTransform=g.transform,g.__originalSetTransform=g.setTransform,g.__originalResetTransform=g.resetTransform,g.__originalClip=g.clip,g.__originalMoveTo=g.moveTo,g.__originalLineTo=g.lineTo,g.__originalBezierCurveTo=g.bezierCurveTo,g.__originalRect=g.rect,g.__originalClosePath=g.closePath,g.__originalBeginPath=g.beginPath,g._removeMirroring=()=>{g.save=g.__originalSave,g.restore=g.__originalRestore,g.rotate=g.__originalRotate,g.scale=g.__originalScale,g.translate=g.__originalTranslate,g.transform=g.__originalTransform,g.setTransform=g.__originalSetTransform,g.resetTransform=g.__originalResetTransform,g.clip=g.__originalClip,g.moveTo=g.__originalMoveTo,g.lineTo=g.__originalLineTo,g.bezierCurveTo=g.__originalBezierCurveTo,g.rect=g.__originalRect,g.closePath=g.__originalClosePath,g.beginPath=g.__originalBeginPath,delete g._removeMirroring},g.save=function(){t.save(),this.__originalSave()},g.restore=function(){t.restore(),this.__originalRestore()},g.translate=function(s,r){t.translate(s,r),this.__originalTranslate(s,r)},g.scale=function(s,r){t.scale(s,r),this.__originalScale(s,r)},g.transform=function(s,r,a,l,u,h){t.transform(s,r,a,l,u,h),this.__originalTransform(s,r,a,l,u,h)},g.setTransform=function(s,r,a,l,u,h){t.setTransform(s,r,a,l,u,h),this.__originalSetTransform(s,r,a,l,u,h)},g.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},g.rotate=function(s){t.rotate(s),this.__originalRotate(s)},g.clip=function(s){t.clip(s),this.__originalClip(s)},g.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},g.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},g.bezierCurveTo=function(e,s,r,a,l,u){t.bezierCurveTo(e,s,r,a,l,u),this.__originalBezierCurveTo(e,s,r,a,l,u)},g.rect=function(e,s,r,a){t.rect(e,s,r,a),this.__originalRect(e,s,r,a)},g.closePath=function(){t.closePath(),this.__originalClosePath()},g.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class Mg{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let r;return this.cache[t]!==void 0?(r=this.cache[t],this.canvasFactory.reset(r,e,s)):(r=this.canvasFactory.create(e,s),this.cache[t]=r),r}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Ur(g,t,e,s,r,a,l,u,h,p){const[f,v,y,w,A,S]=Ot(g);if(v===0&&y===0){const M=l*f+A,I=Math.round(M),N=u*w+S,O=Math.round(N),H=(l+h)*f+A,F=Math.abs(Math.round(H)-I)||1,G=(u+p)*w+S,Y=Math.abs(Math.round(G)-O)||1;return g.setTransform(Math.sign(f),0,0,Math.sign(w),I,O),g.drawImage(t,e,s,r,a,0,0,F,Y),g.setTransform(f,v,y,w,A,S),[F,Y]}if(f===0&&w===0){const M=u*y+A,I=Math.round(M),N=l*v+S,O=Math.round(N),H=(u+p)*y+A,F=Math.abs(Math.round(H)-I)||1,G=(l+h)*v+S,Y=Math.abs(Math.round(G)-O)||1;return g.setTransform(0,Math.sign(v),Math.sign(y),0,I,O),g.drawImage(t,e,s,r,a,0,0,Y,F),g.setTransform(f,v,y,w,A,S),[Y,F]}g.drawImage(t,e,s,r,a,l,u,h,p);const E=Math.hypot(f,v),x=Math.hypot(y,w);return[E*h,x*p]}function Lg(g){const{width:t,height:e}=g;if(t>Kh||e>Kh)return null;const s=1e3,r=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=t+1;let l=new Uint8Array(a*(e+1)),u,h,p;const f=t+7&-8;let v=new Uint8Array(f*e),y=0;for(const x of g.data){let M=128;for(;M>0;)v[y++]=x&M?0:255,M>>=1}let w=0;for(y=0,v[y]!==0&&(l[0]=1,++w),h=1;h<t;h++)v[y]!==v[y+1]&&(l[h]=v[y]?2:1,++w),y++;for(v[y]!==0&&(l[h]=2,++w),u=1;u<e;u++){y=u*f,p=u*a,v[y-f]!==v[y]&&(l[p]=v[y]?1:8,++w);let x=(v[y]?4:0)+(v[y-f]?8:0);for(h=1;h<t;h++)x=(x>>2)+(v[y+1]?4:0)+(v[y-f+1]?8:0),r[x]&&(l[p+h]=r[x],++w),y++;if(v[y-f]!==v[y]&&(l[p+h]=v[y]?2:4,++w),w>s)return null}for(y=f*(e-1),p=u*a,v[y]!==0&&(l[p]=8,++w),h=1;h<t;h++)v[y]!==v[y+1]&&(l[p+h]=v[y]?4:8,++w),y++;if(v[y]!==0&&(l[p+h]=4,++w),w>s)return null;const A=new Int32Array([0,a,-1,0,-a,0,0,0,1]),S=new Path2D;for(u=0;w&&u<=e;u++){let x=u*a;const M=x+t;for(;x<M&&!l[x];)x++;if(x===M)continue;S.moveTo(x%a,u);const I=x;let N=l[x];do{const O=A[N];do x+=O;while(!l[x]);const H=l[x];H!==5&&H!==10?(N=H,l[x]=0):(N=H&51*N>>4,l[x]&=N>>2|N<<2),S.lineTo(x%a,x/a|0),l[x]||--w}while(I!==x);--u}return v=null,l=null,function(x){x.save(),x.scale(1/t,-1/e),x.translate(0,-e),x.fill(S),x.beginPath(),x.restore()}}class Qh{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=ld,this.textMatrixScale=1,this.fontMatrix=dl,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=le.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,s){[e,s]=lt.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){const s=lt.applyTransform(e,t),r=lt.applyTransform(e.slice(2),t),a=lt.applyTransform([e[0],e[3]],t),l=lt.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],r[0],a[0],l[0]),this.minY=Math.min(this.minY,s[1],r[1],a[1],l[1]),this.maxX=Math.max(this.maxX,s[0],r[0],a[0],l[0]),this.maxY=Math.max(this.maxY,s[1],r[1],a[1],l[1])}updateScalingPathMinMax(t,e){lt.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,s,r,a,l,u,h,p,f){const v=lt.bezierBoundingBox(e,s,r,a,l,u,h,p,f);f||this.updateRectMinMax(t,v)}getPathBoundingBox(t=ue.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===ue.STROKE){e||Lt("Stroke bounding box must include transform.");const r=lt.singularValueDecompose2dScale(e),a=r[0]*this.lineWidth/2,l=r[1]*this.lineWidth/2;s[0]-=a,s[1]-=l,s[2]+=a,s[3]+=l}return s}updateClipFromPath(){const t=lt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=ue.FILL,e=null){return lt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Zh(g,t){if(t instanceof ImageData){g.putImageData(t,0,0);return}const e=t.height,s=t.width,r=e%xe,a=(e-r)/xe,l=r===0?a:a+1,u=g.createImageData(s,xe);let h=0,p;const f=t.data,v=u.data;let y,w,A,S;if(t.kind===Vr.GRAYSCALE_1BPP){const E=f.byteLength,x=new Uint32Array(v.buffer,0,v.byteLength>>2),M=x.length,I=s+7>>3,N=4294967295,O=me.isLittleEndian?4278190080:255;for(y=0;y<l;y++){for(A=y<a?xe:r,p=0,w=0;w<A;w++){const H=E-h;let F=0;const G=H>I?s:H*8-7,Y=G&-8;let $=0,V=0;for(;F<Y;F+=8)V=f[h++],x[p++]=V&128?N:O,x[p++]=V&64?N:O,x[p++]=V&32?N:O,x[p++]=V&16?N:O,x[p++]=V&8?N:O,x[p++]=V&4?N:O,x[p++]=V&2?N:O,x[p++]=V&1?N:O;for(;F<G;F++)$===0&&(V=f[h++],$=128),x[p++]=V&$?N:O,$>>=1}for(;p<M;)x[p++]=0;g.putImageData(u,0,y*xe)}}else if(t.kind===Vr.RGBA_32BPP){for(w=0,S=s*xe*4,y=0;y<a;y++)v.set(f.subarray(h,h+S)),h+=S,g.putImageData(u,0,w),w+=xe;y<l&&(S=s*r*4,v.set(f.subarray(h,h+S)),g.putImageData(u,0,w))}else if(t.kind===Vr.RGB_24BPP)for(A=xe,S=s*A,y=0;y<l;y++){for(y>=a&&(A=r,S=s*A),p=0,w=S;w--;)v[p++]=f[h++],v[p++]=f[h++],v[p++]=f[h++],v[p++]=255;g.putImageData(u,0,y*xe)}else throw new Error(`bad image kind: ${t.kind}`)}function Jh(g,t){if(t.bitmap){g.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,r=e%xe,a=(e-r)/xe,l=r===0?a:a+1,u=g.createImageData(s,xe);let h=0;const p=t.data,f=u.data;for(let v=0;v<l;v++){const y=v<a?xe:r;({srcPos:h}=Tg({src:p,srcPos:h,dest:f,width:s,height:y,nonBlackColor:0})),g.putImageData(u,0,v*xe)}}function vs(g,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)g[s]!==void 0&&(t[s]=g[s]);g.setLineDash!==void 0&&(t.setLineDash(g.getLineDash()),t.lineDashOffset=g.lineDashOffset)}function $r(g){if(g.strokeStyle=g.fillStyle="#000000",g.fillRule="nonzero",g.globalAlpha=1,g.lineWidth=1,g.lineCap="butt",g.lineJoin="miter",g.miterLimit=10,g.globalCompositeOperation="source-over",g.font="10px sans-serif",g.setLineDash!==void 0&&(g.setLineDash([]),g.lineDashOffset=0),!ce){const{filter:t}=g;t!=="none"&&t!==""&&(g.filter="none")}}function td(g,t){if(t)return!0;const e=lt.singularValueDecompose2dScale(g);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*Pi.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const Ig=["butt","round","square"],Ng=["miter","round","bevel"],Dg={},ed={};class Ti{constructor(t,e,s,r,a,{optionalContentConfig:l,markedContentStack:u=null},h,p){this.ctx=t,this.current=new Qh(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=r,this.filterFactory=a,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=u||[],this.optionalContentConfig=l,this.cachedCanvases=new Mg(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=h,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=p,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:r=null}){const a=this.ctx.canvas.width,l=this.ctx.canvas.height,u=this.ctx.fillStyle;if(this.ctx.fillStyle=r||"#ffffff",this.ctx.fillRect(0,0,a,l),this.ctx.fillStyle=u,s){const h=this.cachedCanvases.getCanvas("transparent",a,l);this.compositeCtx=this.ctx,this.transparentCanvas=h.canvas,this.ctx=h.context,this.ctx.save(),this.ctx.transform(...Ot(this.compositeCtx))}this.ctx.save(),$r(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=Ot(this.ctx)}executeOperatorList(t,e,s,r){const a=t.argsArray,l=t.fnArray;let u=e||0;const h=a.length;if(h===u)return u;const p=h-u>Yh&&typeof s=="function",f=p?Date.now()+Pg:0;let v=0;const y=this.commonObjs,w=this.objs;let A;for(;;){if(r!==void 0&&u===r.nextBreakPoint)return r.breakIt(u,s),u;if(A=l[u],A!==Xe.dependency)this[A].apply(this,a[u]);else for(const S of a[u]){const E=S.startsWith("g_")?y:w;if(!E.has(S))return E.get(S,s),u}if(u++,u===h)return u;if(p&&++v>Yh){if(Date.now()>f)return s(),u;v=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const s=t.width??t.displayWidth,r=t.height??t.displayHeight;let a=Math.max(Math.hypot(e[0],e[1]),1),l=Math.max(Math.hypot(e[2],e[3]),1),u=s,h=r,p="prescale1",f,v;for(;a>2&&u>1||l>2&&h>1;){let y=u,w=h;a>2&&u>1&&(y=u>=16384?Math.floor(u/2)-1||1:Math.ceil(u/2),a/=u/y),l>2&&h>1&&(w=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,l/=h/w),f=this.cachedCanvases.getCanvas(p,y,w),v=f.context,v.clearRect(0,0,y,w),v.drawImage(t,0,0,u,h,0,0,y,w),t=f.canvas,u=y,h=w,p=p==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:u,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:r}=t,a=this.current.fillColor,l=this.current.patternFill,u=Ot(e);let h,p,f,v;if((t.bitmap||t.data)&&t.count>1){const G=t.bitmap||t.data.buffer;p=JSON.stringify(l?u:[u.slice(0,4),a]),h=this._cachedBitmapsMap.get(G),h||(h=new Map,this._cachedBitmapsMap.set(G,h));const Y=h.get(p);if(Y&&!l){const $=Math.round(Math.min(u[0],u[2])+u[4]),V=Math.round(Math.min(u[1],u[3])+u[5]);return{canvas:Y,offsetX:$,offsetY:V}}f=Y}f||(v=this.cachedCanvases.getCanvas("maskCanvas",s,r),Jh(v.context,t));let y=lt.transform(u,[1/s,0,0,-1/r,0,0]);y=lt.transform(y,[1,0,0,1,0,-r]);const[w,A,S,E]=lt.getAxialAlignedBoundingBox([0,0,s,r],y),x=Math.round(S-w)||1,M=Math.round(E-A)||1,I=this.cachedCanvases.getCanvas("fillCanvas",x,M),N=I.context,O=w,H=A;N.translate(-O,-H),N.transform(...y),f||(f=this._scaleImage(v.canvas,tn(N)),f=f.img,h&&l&&h.set(p,f)),N.imageSmoothingEnabled=td(Ot(N),t.interpolate),Ur(N,f,0,0,f.width,f.height,0,0,s,r),N.globalCompositeOperation="source-in";const F=lt.transform(tn(N),[1,0,0,1,-O,-H]);return N.fillStyle=l?a.getPattern(e,this,F,ue.FILL):a,N.fillRect(0,0,s,r),h&&!l&&(this.cachedCanvases.delete("fillCanvas"),h.set(p,I.canvas)),{canvas:I.canvas,offsetX:Math.round(O),offsetY:Math.round(H)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Ig[t]}setLineJoin(t){this.ctx.lineJoin=Ng[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=r.context;const a=this.ctx;a.setTransform(...Ot(this.suspendedCtx)),vs(this.suspendedCtx,a),Rg(a,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),vs(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,s,r){const a=r[0],l=r[1],u=r[2]-a,h=r[3]-l;u===0||h===0||(this.genericComposeSMask(e.context,s,u,h,e.subtype,e.backdrop,e.transferMap,a,l,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,r,a,l,u,h,p,f,v){let y=t.canvas,w=h-f,A=p-v;if(l){const E=lt.makeHexColor(...l);if(w<0||A<0||w+s>y.width||A+r>y.height){const x=this.cachedCanvases.getCanvas("maskExtension",s,r),M=x.context;M.drawImage(y,-w,-A),M.globalCompositeOperation="destination-atop",M.fillStyle=E,M.fillRect(0,0,s,r),M.globalCompositeOperation="source-over",y=x.canvas,w=A=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const x=new Path2D;x.rect(w,A,s,r),t.clip(x),t.globalCompositeOperation="destination-atop",t.fillStyle=E,t.fillRect(w,A,s,r),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),a==="Alpha"&&u?e.filter=this.filterFactory.addAlphaFilter(u):a==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(u));const S=new Path2D;S.rect(h,p,s,r),e.clip(S),e.globalCompositeOperation="destination-in",e.drawImage(y,w,A,s,r,h,p,s,r),e.restore()}save(){this.inSMaskMode?(vs(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),vs(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,r,a,l){this.ctx.transform(t,e,s,r,a,l),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const r=this.ctx,a=this.current;let l=a.x,u=a.y,h,p;const f=Ot(r),v=f[0]===0&&f[3]===0||f[1]===0&&f[2]===0,y=v?s.slice(0):null;for(let w=0,A=0,S=t.length;w<S;w++)switch(t[w]|0){case Xe.rectangle:l=e[A++],u=e[A++];const E=e[A++],x=e[A++],M=l+E,I=u+x;r.moveTo(l,u),E===0||x===0?r.lineTo(M,I):(r.lineTo(M,u),r.lineTo(M,I),r.lineTo(l,I)),v||a.updateRectMinMax(f,[l,u,M,I]),r.closePath();break;case Xe.moveTo:l=e[A++],u=e[A++],r.moveTo(l,u),v||a.updatePathMinMax(f,l,u);break;case Xe.lineTo:l=e[A++],u=e[A++],r.lineTo(l,u),v||a.updatePathMinMax(f,l,u);break;case Xe.curveTo:h=l,p=u,l=e[A+4],u=e[A+5],r.bezierCurveTo(e[A],e[A+1],e[A+2],e[A+3],l,u),a.updateCurvePathMinMax(f,h,p,e[A],e[A+1],e[A+2],e[A+3],l,u,y),A+=6;break;case Xe.curveTo2:h=l,p=u,r.bezierCurveTo(l,u,e[A],e[A+1],e[A+2],e[A+3]),a.updateCurvePathMinMax(f,h,p,l,u,e[A],e[A+1],e[A+2],e[A+3],y),l=e[A+2],u=e[A+3],A+=4;break;case Xe.curveTo3:h=l,p=u,l=e[A+2],u=e[A+3],r.bezierCurveTo(e[A],e[A+1],l,u,l,u),a.updateCurvePathMinMax(f,h,p,e[A],e[A+1],l,u,l,u,y),A+=4;break;case Xe.closePath:r.closePath();break}v&&a.updateScalingPathMinMax(f,y),a.setCurrentPoint(l,u)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&s?.getPattern?(e.save(),e.strokeStyle=s.getPattern(e,this,tn(e),ue.STROKE),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,s=this.current.fillColor,r=this.current.patternFill;let a=!1;r&&(e.save(),e.fillStyle=s.getPattern(e,this,tn(e),ue.FILL),a=!0);const l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),a&&e.restore(),t&&this.consumePath(l)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Dg}eoClip(){this.pendingClip=ed}beginText(){this.current.textMatrix=ld,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(t===void 0){e.beginPath();return}const s=new Path2D,r=e.getTransform().invertSelf();for(const{transform:a,x:l,y:u,fontSize:h,path:p}of t)s.addPath(p,new DOMMatrix(a).preMultiplySelf(r).translate(l,u).scale(h,-h));e.clip(s),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const s=this.commonObjs.get(t),r=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(r.fontMatrix=s.fontMatrix||dl,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&At("Invalid font matrix for font "+t),e<0?(e=-e,r.fontDirection=-1):r.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;const a=s.loadedName||"sans-serif",l=s.systemFontInfo?.css||`"${a}", ${s.fallbackName}`;let u="normal";s.black?u="900":s.bold&&(u="bold");const h=s.italic?"italic":"normal";let p=e;e<Xh?p=Xh:e>qh&&(p=qh),this.current.fontSizeScale=e/p,this.ctx.font=`${h} ${u} ${p}px ${l}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,r,a,l){this.current.textMatrix=[t,e,s,r,a,l],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#n(t,e,s){const r=new Path2D;return r.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),r}paintChar(t,e,s,r,a){const l=this.ctx,u=this.current,h=u.font,p=u.textRenderingMode,f=u.fontSize/u.fontSizeScale,v=p&le.FILL_STROKE_MASK,y=!!(p&le.ADD_TO_PATH_FLAG),w=u.patternFill&&!h.missingFile,A=u.patternStroke&&!h.missingFile;let S;if((h.disableFontFace||y||w||A)&&(S=h.getPathGenerator(this.commonObjs,t)),h.disableFontFace||w||A){if(l.save(),l.translate(e,s),l.scale(f,-f),v===le.FILL||v===le.FILL_STROKE)if(r){const E=l.getTransform();l.setTransform(...r),l.fill(this.#n(S,E,r))}else l.fill(S);if(v===le.STROKE||v===le.FILL_STROKE)if(a){const E=l.getTransform();l.setTransform(...a),l.stroke(this.#n(S,E,a))}else l.lineWidth/=f,l.stroke(S);l.restore()}else(v===le.FILL||v===le.FILL_STROKE)&&l.fillText(t,e,s),(v===le.STROKE||v===le.FILL_STROKE)&&l.strokeText(t,e,s);y&&(this.pendingTextPaths||=[]).push({transform:Ot(l),x:e,y:s,fontSize:f,path:S})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let r=3;r<e.length;r+=4)if(e[r]>0&&e[r]<255){s=!0;break}return bt(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const r=e.fontSize;if(r===0)return;const a=this.ctx,l=e.fontSizeScale,u=e.charSpacing,h=e.wordSpacing,p=e.fontDirection,f=e.textHScale*p,v=t.length,y=s.vertical,w=y?1:-1,A=s.defaultVMetrics,S=r*e.fontMatrix[0],E=e.textRenderingMode===le.FILL&&!s.disableFontFace&&!e.patternFill;a.save(),a.transform(...e.textMatrix),a.translate(e.x,e.y+e.textRise),p>0?a.scale(f,-1):a.scale(f,1);let x,M;if(e.patternFill){a.save();const F=e.fillColor.getPattern(a,this,tn(a),ue.FILL);x=Ot(a),a.restore(),a.fillStyle=F}if(e.patternStroke){a.save();const F=e.strokeColor.getPattern(a,this,tn(a),ue.STROKE);M=Ot(a),a.restore(),a.strokeStyle=F}let I=e.lineWidth;const N=e.textMatrixScale;if(N===0||I===0){const F=e.textRenderingMode&le.FILL_STROKE_MASK;(F===le.STROKE||F===le.FILL_STROKE)&&(I=this.getSinglePixelWidth())}else I/=N;if(l!==1&&(a.scale(l,l),I/=l),a.lineWidth=I,s.isInvalidPDFjsFont){const F=[];let G=0;for(const Y of t)F.push(Y.unicode),G+=Y.width;a.fillText(F.join(""),0,0),e.x+=G*S*f,a.restore(),this.compose();return}let O=0,H;for(H=0;H<v;++H){const F=t[H];if(typeof F=="number"){O+=w*F*r/1e3;continue}let G=!1;const Y=(F.isSpace?h:0)+u,$=F.fontChar,V=F.accent;let at,mt,yt=F.width;if(y){const K=F.vmetric||A,Q=-(F.vmetric?K[1]:yt*.5)*S,q=K[2]*S;yt=K?-K[0]:yt,at=Q/l,mt=(O+q)/l}else at=O/l,mt=0;if(s.remeasure&&yt>0){const K=a.measureText($).width*1e3/r*l;if(yt<K&&this.isFontSubpixelAAEnabled){const Q=yt/K;G=!0,a.save(),a.scale(Q,1),at/=Q}else yt!==K&&(at+=(yt-K)/2e3*r/l)}if(this.contentVisible&&(F.isInFont||s.missingFile)){if(E&&!V)a.fillText($,at,mt);else if(this.paintChar($,at,mt,x,M),V){const K=at+r*V.offset.x/l,Q=mt-r*V.offset.y/l;this.paintChar(V.fontChar,K,Q,x,M)}}const kt=y?yt*S-Y*p:yt*S+Y*p;O+=kt,G&&a.restore()}y?e.y-=O:e.x+=O*f,a.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,r=s.font,a=s.fontSize,l=s.fontDirection,u=r.vertical?1:-1,h=s.charSpacing,p=s.wordSpacing,f=s.textHScale*l,v=s.fontMatrix||dl,y=t.length,w=s.textRenderingMode===le.INVISIBLE;let A,S,E,x;if(!(w||a===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(f,l),A=0;A<y;++A){if(S=t[A],typeof S=="number"){x=u*S*a/1e3,this.ctx.translate(x,0),s.x+=x*f;continue}const M=(S.isSpace?p:0)+h,I=r.charProcOperatorList[S.operatorListId];if(!I){At(`Type3 character "${S.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=S,this.save(),e.scale(a,a),e.transform(...v),this.executeOperatorList(I),this.restore()),E=lt.applyTransform([S.width,0],v)[0]*a+M,e.translate(E,0),s.x+=E*f}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,r,a,l){this.ctx.rect(s,r,a-s,l-r),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],r=this.baseTransform||Ot(this.ctx),a={createCanvasGraphics:l=>new Ti(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ml(t,s,this.ctx,a,r)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){this.ctx.strokeStyle=this.current.strokeColor=lt.makeHexColor(t,e,s),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,s){this.ctx.fillStyle=this.current.fillColor=lt.makeHexColor(t,e,s),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=kg(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,tn(e),ue.SHADING);const r=tn(e);if(r){const{width:a,height:l}=e.canvas,[u,h,p,f]=lt.getAxialAlignedBoundingBox([0,0,a,l],r);this.ctx.fillRect(u,h,p-u,f-h)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Lt("Should not call beginInlineImage")}beginImageData(){Lt("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Ot(this.ctx),e)){const s=e[2]-e[0],r=e[3]-e[1];this.ctx.rect(e[0],e[1],s,r),this.current.updateRectMinMax(Ot(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||Qr("TODO: Support non-isolated groups."),t.knockout&&At("Knockout groups not supported.");const s=Ot(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let r=lt.getAxialAlignedBoundingBox(t.bbox,Ot(e));const a=[0,0,e.canvas.width,e.canvas.height];r=lt.intersect(r,a)||[0,0,0,0];const l=Math.floor(r[0]),u=Math.floor(r[1]),h=Math.max(Math.ceil(r[2])-l,1),p=Math.max(Math.ceil(r[3])-u,1);this.current.startNewPathAndClipBox([0,0,h,p]);let f="groupAt"+this.groupLevel;t.smask&&(f+="_smask_"+this.smaskCounter++%2);const v=this.cachedCanvases.getCanvas(f,h,p),y=v.context;y.translate(-l,-u),y.transform(...s),t.smask?this.smaskStack.push({canvas:v.canvas,context:y,offsetX:l,offsetY:u,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(l,u),e.save()),vs(e,y),this.ctx=y,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const r=Ot(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...r);const a=lt.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],r);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(a)}}beginAnnotation(t,e,s,r,a){if(this.#t(),$r(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const l=e[2]-e[0],u=e[3]-e[1];if(a&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=l,e[3]=u;const[h,p]=lt.singularValueDecompose2dScale(Ot(this.ctx)),{viewportScale:f}=this,v=Math.ceil(l*this.outputScaleX*f),y=Math.ceil(u*this.outputScaleY*f);this.annotationCanvas=this.canvasFactory.create(v,y);const{canvas:w,context:A}=this.annotationCanvas;this.annotationCanvasMap.set(t,w),this.annotationCanvas.savedCtx=this.ctx,this.ctx=A,this.ctx.save(),this.ctx.setTransform(h,0,0,-p,0,u*p),$r(this.ctx)}else $r(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],l,u),this.ctx.clip(),this.ctx.beginPath()}this.current=new Qh(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;t=this.getObject(t.data,t),t.count=e;const s=this.ctx,r=this.processingType3;if(r&&(r.compiled===void 0&&(r.compiled=Lg(t)),r.compiled)){r.compiled(s);return}const a=this._createMaskCanvas(t),l=a.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(l,a.offsetX,a.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,r=0,a,l){if(!this.contentVisible)return;t=this.getObject(t.data,t);const u=this.ctx;u.save();const h=Ot(u);u.transform(e,s,r,a,0,0);const p=this._createMaskCanvas(t);u.setTransform(1,0,0,1,p.offsetX-h[4],p.offsetY-h[5]);for(let f=0,v=l.length;f<v;f+=2){const y=lt.transform(h,[e,s,r,a,l[f],l[f+1]]),[w,A]=lt.applyTransform([0,0],y);u.drawImage(p.canvas,w,A)}u.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,r=this.current.patternFill;for(const a of t){const{data:l,width:u,height:h,transform:p}=a,f=this.cachedCanvases.getCanvas("maskCanvas",u,h),v=f.context;v.save();const y=this.getObject(l,a);Jh(v,y),v.globalCompositeOperation="source-in",v.fillStyle=r?s.getPattern(v,this,tn(e),ue.FILL):s,v.fillRect(0,0,u,h),v.restore(),e.save(),e.transform(...p),e.scale(1,-1),Ur(e,f.canvas,0,0,u,h,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);if(!e){At("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,r){if(!this.contentVisible)return;const a=this.getObject(t);if(!a){At("Dependent image isn't ready yet");return}const l=a.width,u=a.height,h=[];for(let p=0,f=r.length;p<f;p+=2)h.push({transform:[e,0,0,s,r[p],r[p+1]],x:0,y:0,w:l,h:u});this.paintInlineImageXObjectGroup(a,h)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:r}=t,a=this.cachedCanvases.getCanvas("inlineImage",s,r),l=a.context;return l.filter=this.current.transferMaps,l.drawImage(e,0,0),l.filter="none",a.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,r=this.ctx;if(this.save(),!ce){const{filter:u}=r;u!=="none"&&u!==""&&(r.filter="none")}r.scale(1/e,-1/s);let a;if(t.bitmap)a=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)a=t;else{const h=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Zh(h,t),a=this.applyTransferMapsToCanvas(h)}const l=this._scaleImage(a,tn(r));r.imageSmoothingEnabled=td(Ot(r),t.interpolate),Ur(r,l.img,0,0,l.paintWidth,l.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let r;if(t.bitmap)r=t.bitmap;else{const a=t.width,l=t.height,h=this.cachedCanvases.getCanvas("inlineImage",a,l).context;Zh(h,t),r=this.applyTransferMapsToCanvas(h)}for(const a of e)s.save(),s.transform(...a.transform),s.scale(1,-1),Ur(s,r,a.x,a.y,a.w,a.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const s=this.ctx;this.pendingClip&&(e||(this.pendingClip===ed?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Ot(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),r=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,r)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:r,d:a}=this.ctx.getTransform();let l,u;if(s===0&&r===0){const h=Math.abs(e),p=Math.abs(a);if(h===p)if(t===0)l=u=1/h;else{const f=h*t;l=u=f<1?1/f:1}else if(t===0)l=1/h,u=1/p;else{const f=h*t,v=p*t;l=f<1?1/f:1,u=v<1?1/v:1}}else{const h=Math.abs(e*a-s*r),p=Math.hypot(e,s),f=Math.hypot(r,a);if(t===0)l=f/h,u=p/h;else{const v=t*h;l=f>v?f/v:1,u=p>v?p/v:1}}this._cachedScaleForStroking[0]=l,this._cachedScaleForStroking[1]=u}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[r,a]=this.getScaleForStroking();if(e.lineWidth=s||1,r===1&&a===1){e.stroke();return}const l=e.getLineDash();if(t&&e.save(),e.scale(r,a),l.length>0){const u=Math.max(r,a);e.setLineDash(l.map(h=>h/u)),e.lineDashOffset/=u}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const g in Xe)Ti.prototype[g]!==void 0&&(Ti.prototype[Xe[g]]=Ti.prototype[g]);class Es{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}}class Fg{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}getAll(){return Sl(this.#t)}has(t){return this.#t.has(t)}}const Ci=Symbol("INTERNAL");class Og{#t=!1;#e=!1;#n=!1;#i=!0;constructor(t,{name:e,intent:s,usage:r,rbGroups:a}){this.#t=!!(t&Re.DISPLAY),this.#e=!!(t&Re.PRINT),this.name=e,this.intent=s,this.usage=r,this.rbGroups=a}get visible(){if(this.#n)return this.#i;if(!this.#i)return!1;const{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==Ci&&Lt("Internal method `_setVisible` called."),this.#n=s,this.#i=e}}class zg{#t=null;#e=new Map;#n=null;#i=null;constructor(t,e=Re.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#i=t.order;for(const s of t.groups)this.#e.set(s.id,new Og(e,s));if(t.baseState==="OFF")for(const s of this.#e.values())s._setVisible(Ci,!1);for(const s of t.on)this.#e.get(s)._setVisible(Ci,!0);for(const s of t.off)this.#e.get(s)._setVisible(Ci,!1);this.#n=this.getHash()}}#r(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let r=1;r<e;r++){const a=t[r];let l;if(Array.isArray(a))l=this.#r(a);else if(this.#e.has(a))l=this.#e.get(a).visible;else return At(`Optional content group not found: ${a}`),!0;switch(s){case"And":if(!l)return!1;break;case"Or":if(l)return!0;break;case"Not":return!l;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return Qr("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(At(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#r(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#e.has(e))return At(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#e.has(e))return At(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#e.has(e))return At(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#e.has(e))return At(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return At(`Unknown optional content policy ${t.policy}.`),!0}return At(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){const r=this.#e.get(t);if(!r){At(`Optional content group not found: ${t}`);return}if(s&&e&&r.rbGroups.length)for(const a of r.rbGroups)for(const l of a)l!==t&&this.#e.get(l)?._setVisible(Ci,!1,!0);r._setVisible(Ci,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(const r of t){switch(r){case"ON":case"OFF":case"Toggle":s=r;continue}const a=this.#e.get(r);if(a)switch(s){case"ON":this.setVisibility(r,!0,e);break;case"OFF":this.setVisibility(r,!1,e);break;case"Toggle":this.setVisibility(r,!a.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#n===null||this.getHash()===this.#n}getOrder(){return this.#e.size?this.#i?this.#i.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?Sl(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new hd;for(const[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}}class jg{constructor(t,{disableRange:e=!1,disableStream:s=!1}){Xt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:r,initialData:a,progressiveDone:l,contentDispositionFilename:u}=t;if(this._queuedChunks=[],this._progressiveDone=l,this._contentDispositionFilename=u,a?.length>0){const h=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(h)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((h,p)=>{this._onReceiveData({begin:h,chunk:p})}),t.addProgressListener((h,p)=>{this._onProgress({loaded:h,total:p})}),t.addProgressiveReadListener(h=>{this._onReceiveData({chunk:h})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const r=this._rangeReaders.some(function(a){return a._begin!==t?!1:(a._enqueue(s),!0)});Xt(r,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){Xt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Bg(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Hg(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Bg{constructor(t,e,s=!1,r=null){this._stream=t,this._done=s||!1,this._filename=xl(r)?r:null,this._queuedChunks=e||[],this._loaded=0;for(const a of this._queuedChunks)this._loaded+=a.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Hg{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Ug(g){let t=!0,e=s("filename\\*","i").exec(g);if(e){e=e[1];let f=u(e);return f=unescape(f),f=h(f),f=p(f),a(f)}if(e=l(g),e){const f=p(e);return a(f)}if(e=s("filename","i").exec(g),e){e=e[1];let f=u(e);return f=p(f),a(f)}function s(f,v){return new RegExp("(?:^|;)\\s*"+f+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',v)}function r(f,v){if(f){if(!/^[\x00-\xFF]+$/.test(v))return v;try{const y=new TextDecoder(f,{fatal:!0}),w=Zr(v);v=y.decode(w),t=!1}catch{}}return v}function a(f){return t&&/[\x80-\xff]/.test(f)&&(f=r("utf-8",f),t&&(f=r("iso-8859-1",f))),f}function l(f){const v=[];let y;const w=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(y=w.exec(f))!==null;){let[,S,E,x]=y;if(S=parseInt(S,10),S in v){if(S===0)break;continue}v[S]=[E,x]}const A=[];for(let S=0;S<v.length&&S in v;++S){let[E,x]=v[S];x=u(x),E&&(x=unescape(x),S===0&&(x=h(x))),A.push(x)}return A.join("")}function u(f){if(f.startsWith('"')){const v=f.slice(1).split('\\"');for(let y=0;y<v.length;++y){const w=v[y].indexOf('"');w!==-1&&(v[y]=v[y].slice(0,w),v.length=y+1),v[y]=v[y].replaceAll(/\\(.)/g,"$1")}f=v.join('"')}return f}function h(f){const v=f.indexOf("'");if(v===-1)return f;const y=f.slice(0,v),A=f.slice(v+1).replace(/^[^']*'/,"");return r(y,A)}function p(f){return!f.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(f)?f:f.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(v,y,w,A){if(w==="q"||w==="Q")return A=A.replaceAll("_"," "),A=A.replaceAll(/=([0-9a-fA-F]{2})/g,function(S,E){return String.fromCharCode(parseInt(E,16))}),r(y,A);try{A=atob(A)}catch{}return r(y,A)})}return""}function _d(g,t){const e=new Headers;if(!g||!t||typeof t!="object")return e;for(const s in t){const r=t[s];r!==void 0&&e.append(s,r)}return e}function no(g){try{return new URL(g).origin}catch{}return null}function Ad({responseHeaders:g,isHttp:t,rangeChunkSize:e,disableRange:s}){const r={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(g.get("Content-Length"),10);return!Number.isInteger(a)||(r.suggestedLength=a,a<=2*e)||s||!t||g.get("Accept-Ranges")!=="bytes"||(g.get("Content-Encoding")||"identity")!=="identity"||(r.allowRangeRequests=!0),r}function Sd(g){const t=g.get("Content-Disposition");if(t){let e=Ug(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(xl(e))return e}return null}function io(g,t){return g===404||g===0&&t.startsWith("file:")?new xs('Missing PDF "'+t+'".'):new Gr(`Unexpected server response (${g}) while retrieving PDF "${t}".`,g)}function bd(g){return g===200||g===206}function Ed(g,t,e){return{method:"GET",headers:g,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function xd(g){return g instanceof Uint8Array?g.buffer:g instanceof ArrayBuffer?g:(At(`getArrayBuffer - unexpected data format: ${g}`),new Uint8Array(g).buffer)}class nd{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=_d(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Xt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new $g(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Wg(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class $g{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const s=new Headers(t.headers),r=e.url;fetch(r,Ed(s,this._withCredentials,this._abortController)).then(a=>{if(t._responseOrigin=no(a.url),!bd(a.status))throw io(a.status,r);this._reader=a.body.getReader(),this._headersCapability.resolve();const l=a.headers,{allowRangeRequests:u,suggestedLength:h}=Ad({responseHeaders:l,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=u,this._contentLength=h||this._contentLength,this._filename=Sd(l),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Dn("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:xd(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Wg{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const r=t.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;const a=new Headers(t.headers);a.append("Range",`bytes=${e}-${s-1}`);const l=r.url;fetch(l,Ed(a,this._withCredentials,this._abortController)).then(u=>{const h=no(u.url);if(h!==t._responseOrigin)throw new Error(`Expected range response-origin "${h}" to match "${t._responseOrigin}".`);if(!bd(u.status))throw io(u.status,l);this._readCapability.resolve(),this._reader=u.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:xd(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}const ul=200,cl=206;function Vg(g){const t=g.response;return typeof t!="string"?t:Zr(t).buffer}class Gg{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:s}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=_d(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,r=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[a,l]of this.headers)e.setRequestHeader(a,l);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),r.expectedStatus=cl):r.expectedStatus=ul,e.responseType="arraybuffer",Xt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),r.onHeadersReceived=t.onHeadersReceived,r.onDone=t.onDone,r.onError=t.onError,r.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){const s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const r=s.xhr;if(r.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),r.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],r.status===0&&this.isHttp){s.onError(r.status);return}const a=r.status||ul;if(!(a===ul&&s.expectedStatus===cl)&&a!==s.expectedStatus){s.onError(r.status);return}const u=Vg(r);if(a===cl){const h=r.getResponseHeader("Content-Range"),p=/bytes (\d+)-(\d+)\/(\d+)/.exec(h);p?s.onDone({begin:parseInt(p[1],10),chunk:u}):(At('Missing or invalid "Content-Range" header.'),s.onError(0))}else u?s.onDone({begin:0,chunk:u}):s.onError(r.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Xg{constructor(t){this._source=t,this._manager=new Gg(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return Xt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new qg(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Yg(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class qg{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=no(e.responseURL);const s=e.getAllResponseHeaders(),r=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(u=>{const[h,...p]=u.split(": ");return[h,p.join(": ")]}):[]),{allowRangeRequests:a,suggestedLength:l}=Ad({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});a&&(this._isRangeSupported=!0),this._contentLength=l||this._contentLength,this._filename=Sd(r),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=io(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Yg{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=no(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=io(t,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Kg=/^[a-z][a-z0-9\-+.]+:/i;function Qg(g){if(Kg.test(g))return new URL(g);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(g))}class Zg{constructor(t){this.source=t,this.url=Qg(t.url),Xt(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Xt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Jg(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new tm(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Jg{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(r=>{this._contentLength=r.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},r=>{r.code==="ENOENT"&&(r=new xs(`Missing PDF "${this._url}".`)),this._storedError=r,this._headersCapability.reject(r)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Dn("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class tm{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const r=t.source;this._isStreamingSupported=!r.disableStream;const a=process.getBuiltinModule("fs");this._setReadableStream(a.createReadStream(this._url,{start:e,end:s-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const em=1e5,be=30,nm=.8;class ge{#t=Promise.withResolvers();#e=null;#n=!1;#i=!!globalThis.FontInspector?.enabled;#r=null;#s=null;#l=0;#a=0;#c=null;#u=null;#d=0;#h=0;#f=Object.create(null);#o=[];#p=null;#m=[];#g=new WeakMap;#v=null;static#_=new Map;static#y=new Map;static#A=new WeakMap;static#b=null;static#x=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream)this.#p=t;else if(typeof t=="object")this.#p=new ReadableStream({start(h){h.enqueue(t),h.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#u=e,this.#h=s.scale*(globalThis.devicePixelRatio||1),this.#d=s.rotation,this.#s={div:null,properties:null,ctx:null};const{pageWidth:r,pageHeight:a,pageX:l,pageY:u}=s.rawDims;this.#v=[1,0,0,-1,-l,u+a],this.#a=r,this.#l=a,ge.#M(),Zn(e,s),this.#t.promise.finally(()=>{ge.#x.delete(this),this.#s=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=me.platform;return bt(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{this.#c.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#r??=e.lang,Object.assign(this.#f,e.styles),this.#k(e.items),t()},this.#t.reject)};return this.#c=this.#p.getReader(),ge.#x.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){const s=t.scale*(globalThis.devicePixelRatio||1),r=t.rotation;if(r!==this.#d&&(e?.(),this.#d=r,Zn(this.#u,{rotation:r})),s!==this.#h){e?.(),this.#h=s;const a={div:null,properties:null,ctx:ge.#T(this.#r)};for(const l of this.#m)a.properties=this.#g.get(l),a.div=l,this.#S(a)}}cancel(){const t=new Dn("TextLayer task cancelled.");this.#c?.cancel(t).catch(()=>{}),this.#c=null,this.#t.reject(t)}get textDivs(){return this.#m}get textContentItemsStr(){return this.#o}#k(t){if(this.#n)return;this.#s.ctx??=ge.#T(this.#r);const e=this.#m,s=this.#o;for(const r of t){if(e.length>em){At("Ignoring additional textDivs for performance reasons."),this.#n=!0;return}if(r.str===void 0){if(r.type==="beginMarkedContentProps"||r.type==="beginMarkedContent"){const a=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),r.id!==null&&this.#e.setAttribute("id",`${r.id}`),a.append(this.#e)}else r.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}s.push(r.str),this.#P(r)}}#P(t){const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#m.push(e);const r=lt.transform(this.#v,t.transform);let a=Math.atan2(r[1],r[0]);const l=this.#f[t.fontName];l.vertical&&(a+=Math.PI/2);let u=this.#i&&l.fontSubstitution||l.fontFamily;u=ge.fontFamilyMap.get(u)||u;const h=Math.hypot(r[2],r[3]),p=h*ge.#N(u,this.#r);let f,v;a===0?(f=r[4],v=r[5]-p):(f=r[4]+p*Math.sin(a),v=r[5]-p*Math.cos(a));const y="calc(var(--scale-factor)*",w=e.style;this.#e===this.#u?(w.left=`${(100*f/this.#a).toFixed(2)}%`,w.top=`${(100*v/this.#l).toFixed(2)}%`):(w.left=`${y}${f.toFixed(2)}px)`,w.top=`${y}${v.toFixed(2)}px)`),w.fontSize=`${y}${(ge.#b*h).toFixed(2)}px)`,w.fontFamily=u,s.fontSize=h,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#i&&(e.dataset.fontName=l.fontSubstitutionLoadedName||t.fontName),a!==0&&(s.angle=a*(180/Math.PI));let A=!1;if(t.str.length>1)A=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const S=Math.abs(t.transform[0]),E=Math.abs(t.transform[3]);S!==E&&Math.max(S,E)/Math.min(S,E)>1.5&&(A=!0)}if(A&&(s.canvasWidth=l.vertical?t.height:t.width),this.#g.set(e,s),this.#s.div=e,this.#s.properties=s,this.#S(this.#s),s.hasText&&this.#e.append(e),s.hasEOL){const S=document.createElement("br");S.setAttribute("role","presentation"),this.#e.append(S)}}#S(t){const{div:e,properties:s,ctx:r}=t,{style:a}=e;let l="";if(ge.#b>1&&(l=`scale(${1/ge.#b})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:u}=a,{canvasWidth:h,fontSize:p}=s;ge.#C(r,p*this.#h,u);const{width:f}=r.measureText(e.textContent);f>0&&(l=`scaleX(${h*this.#h/f}) ${l}`)}s.angle!==0&&(l=`rotate(${s.angle}deg) ${l}`),l.length>0&&(a.transform=l)}static cleanup(){if(!(this.#x.size>0)){this.#_.clear();for(const{canvas:t}of this.#y.values())t.remove();this.#y.clear()}}static#T(t=null){let e=this.#y.get(t||="");if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#y.set(t,e),this.#A.set(e,{size:0,family:""})}return e}static#C(t,e,s){const r=this.#A.get(t);e===r.size&&s===r.family||(t.font=`${e}px ${s}`,r.size=e,r.family=s)}static#M(){if(this.#b!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#b=t.getBoundingClientRect().height,t.remove()}static#N(t,e){const s=this.#_.get(t);if(s)return s;const r=this.#T(e);r.canvas.width=r.canvas.height=be,this.#C(r,be,t);const a=r.measureText("");let l=a.fontBoundingBoxAscent,u=Math.abs(a.fontBoundingBoxDescent);if(l){const f=l/(l+u);return this.#_.set(t,f),r.canvas.width=r.canvas.height=0,f}r.strokeStyle="red",r.clearRect(0,0,be,be),r.strokeText("g",0,0);let h=r.getImageData(0,0,be,be).data;u=0;for(let f=h.length-1-3;f>=0;f-=4)if(h[f]>0){u=Math.ceil(f/4/be);break}r.clearRect(0,0,be,be),r.strokeText("A",0,be),h=r.getImageData(0,0,be,be).data,l=0;for(let f=0,v=h.length;f<v;f+=4)if(h[f]>0){l=be-Math.floor(f/4/be);break}r.canvas.width=r.canvas.height=0;const p=l?l/(l+u):nm;return this.#_.set(t,p),p}}class Cs{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function r(a){if(!a)return;let l=null;const u=a.name;if(u==="#text")l=a.value;else if(Cs.shouldBuildText(u))a?.attributes?.textContent?l=a.attributes.textContent:a.value&&(l=a.value);else return;if(l!==null&&e.push({str:l}),!!a.children)for(const h of a.children)r(h)}return r(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const im=65536,sm=100,rm=5e3,om=ce?_g:vg,am=ce?Ag:gd,lm=ce?wg:yg,um=ce?Sg:yd;function cm(g={}){typeof g=="string"||g instanceof URL?g={url:g}:(g instanceof ArrayBuffer||ArrayBuffer.isView(g))&&(g={data:g});const t=new Ll,{docId:e}=t,s=g.url?hm(g.url):null,r=g.data?dm(g.data):null,a=g.httpHeaders||null,l=g.withCredentials===!0,u=g.password??null,h=g.range instanceof Cd?g.range:null,p=Number.isInteger(g.rangeChunkSize)&&g.rangeChunkSize>0?g.rangeChunkSize:im;let f=g.worker instanceof ee?g.worker:null;const v=g.verbosity,y=typeof g.docBaseUrl=="string"&&!to(g.docBaseUrl)?g.docBaseUrl:null,w=typeof g.cMapUrl=="string"?g.cMapUrl:null,A=g.cMapPacked!==!1,S=g.CMapReaderFactory||am,E=typeof g.standardFontDataUrl=="string"?g.standardFontDataUrl:null,x=g.StandardFontDataFactory||um,M=g.stopAtErrors!==!0,I=Number.isInteger(g.maxImageSize)&&g.maxImageSize>-1?g.maxImageSize:-1,N=g.isEvalSupported!==!1,O=typeof g.isOffscreenCanvasSupported=="boolean"?g.isOffscreenCanvasSupported:!ce,H=typeof g.isImageDecoderSupported=="boolean"?g.isImageDecoderSupported:!ce&&(me.platform.isFirefox||!globalThis.chrome),F=Number.isInteger(g.canvasMaxAreaInBytes)?g.canvasMaxAreaInBytes:-1,G=typeof g.disableFontFace=="boolean"?g.disableFontFace:ce,Y=g.fontExtraProperties===!0,$=g.enableXfa===!0,V=g.ownerDocument||globalThis.document,at=g.disableRange===!0,mt=g.disableStream===!0,yt=g.disableAutoFetch===!0,kt=g.pdfBug===!0,K=g.CanvasFactory||om,Q=g.FilterFactory||lm,q=g.enableHWA===!0,it=h?h.length:g.length??NaN,z=typeof g.useSystemFonts=="boolean"?g.useSystemFonts:!ce&&!G,k=typeof g.useWorkerFetch=="boolean"?g.useWorkerFetch:S===gd&&x===yd&&w&&E&&_s(w,document.baseURI)&&_s(E,document.baseURI),D=null;Yp(v);const rt={canvasFactory:new K({ownerDocument:V,enableHWA:q}),filterFactory:new Q({docId:e,ownerDocument:V}),cMapReaderFactory:k?null:new S({baseUrl:w,isCompressed:A}),standardFontDataFactory:k?null:new x({baseUrl:E})};if(!f){const dt={verbosity:v,port:Es.workerPort};f=dt.port?ee.fromPort(dt):new ee(dt),t._worker=f}const J={docId:e,apiVersion:"4.10.38",data:r,password:u,disableAutoFetch:yt,rangeChunkSize:p,length:it,docBaseUrl:y,enableXfa:$,evaluatorOptions:{maxImageSize:I,disableFontFace:G,ignoreErrors:M,isEvalSupported:N,isOffscreenCanvasSupported:O,isImageDecoderSupported:H,canvasMaxAreaInBytes:F,fontExtraProperties:Y,useSystemFonts:z,cMapUrl:k?w:null,standardFontDataUrl:k?E:null}},wt={disableFontFace:G,fontExtraProperties:Y,ownerDocument:V,pdfBug:kt,styleElement:D,loadingParams:{disableAutoFetch:yt,enableXfa:$}};return f.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(f.destroyed)throw new Error("Worker was destroyed");const dt=f.messageHandler.sendWithPromise("GetDocRequest",J,r?[r.buffer]:null);let ut;if(h)ut=new jg(h,{disableRange:at,disableStream:mt});else if(!r){if(!s)throw new Error("getDocument - no `url` parameter provided.");let Et;if(ce)if(_s(s)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");Et=nd}else Et=Zg;else Et=_s(s)?nd:Xg;ut=new Et({url:s,length:it,httpHeaders:a,withCredentials:l,rangeChunkSize:p,disableRange:at,disableStream:mt})}return dt.then(Et=>{if(t.destroyed)throw new Error("Loading aborted");if(f.destroyed)throw new Error("Worker was destroyed");const Mt=new As(e,Et,f.port),he=new mm(Mt,t,ut,wt,rt);t._transport=he,Mt.send("Ready",null)})}).catch(t._capability.reject),t}function hm(g){if(g instanceof URL)return g.href;try{return new URL(g,window.location).href}catch{if(ce&&typeof g=="string")return g}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function dm(g){if(ce&&typeof Buffer<"u"&&g instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(g instanceof Uint8Array&&g.byteLength===g.buffer.byteLength)return g;if(typeof g=="string")return Zr(g);if(g instanceof ArrayBuffer||ArrayBuffer.isView(g)||typeof g=="object"&&!isNaN(g?.length))return new Uint8Array(g);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function id(g){return typeof g=="object"&&Number.isInteger(g?.num)&&g.num>=0&&Number.isInteger(g?.gen)&&g.gen>=0}class Ll{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${Ll.#t++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}}class Cd{constructor(t,e,s=!1,r=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=r,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){Lt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class fm{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return bt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class pm{#t=null;#e=!1;constructor(t,e,s,r=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=r?new $h:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new kd,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:r=0,dontFlip:a=!1}={}){return new ks({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:r,dontFlip:a})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return bt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:r=In.ENABLE,transform:a=null,background:l=null,optionalContentConfigPromise:u=null,annotationCanvasMap:h=null,pageColors:p=null,printAnnotationStorage:f=null,isEditing:v=!1}){this._stats?.time("Overall");const y=this._transport.getRenderingIntent(s,r,f,v),{renderingIntent:w,cacheKey:A}=y;this.#e=!1,this.#i(),u||=this._transport.getOptionalContentConfig(w);let S=this._intentStates.get(A);S||(S=Object.create(null),this._intentStates.set(A,S)),S.streamReaderCancelTimeout&&(clearTimeout(S.streamReaderCancelTimeout),S.streamReaderCancelTimeout=null);const E=!!(w&Re.PRINT);S.displayReadyCapability||(S.displayReadyCapability=Promise.withResolvers(),S.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(y));const x=N=>{S.renderTasks.delete(M),(this._maybeCleanupAfterRender||E)&&(this.#e=!0),this.#n(!E),N?(M.capability.reject(N),this._abortOperatorList({intentState:S,reason:N instanceof Error?N:new Error(N)})):M.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},M=new ki({callback:x,params:{canvasContext:t,viewport:e,transform:a,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:S.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!E,pdfBug:this._pdfBug,pageColors:p});(S.renderTasks||=new Set).add(M);const I=M.task;return Promise.all([S.displayReadyCapability.promise,u]).then(([N,O])=>{if(this.destroyed){x();return}if(this._stats?.time("Rendering"),!(O.renderingIntent&w))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");M.initializeGraphics({transparency:N,optionalContentConfig:O}),M.operatorListChanged()}).catch(x),I}getOperatorList({intent:t="display",annotationMode:e=In.ENABLE,printAnnotationStorage:s=null,isEditing:r=!1}={}){function a(){u.operatorList.lastChunk&&(u.opListReadCapability.resolve(u.operatorList),u.renderTasks.delete(h))}const l=this._transport.getRenderingIntent(t,e,s,r,!0);let u=this._intentStates.get(l.cacheKey);u||(u=Object.create(null),this._intentStates.set(l.cacheKey,u));let h;return u.opListReadCapability||(h=Object.create(null),h.operatorListChanged=a,u.opListReadCapability=Promise.withResolvers(),(u.renderTasks||=new Set).add(h),u.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(l)),u.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(r){return r.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>Cs.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,r){function a(){l.read().then(function({value:h,done:p}){if(p){s(u);return}u.lang??=h.lang,Object.assign(u.styles,h.styles),u.items.push(...h.items),a()},r)}const l=e.getReader(),u={items:[],styles:Object.create(null),lang:null};a()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this.#e=!1,this.#i(),Promise.all(t)}cleanup(t=!1){this.#e=!0;const e=this.#n(!1);return t&&e&&(this._stats&&=new $h),e}#n(t=!1){if(this.#i(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#n(!1)},rm),!1;for(const{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#i(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,r=t.length;s<r;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#n(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:r}){const{map:a,transfer:l}=s,h=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:a,modifiedIds:r},l).getReader(),p=this._intentStates.get(e);p.streamReader=h;const f=()=>{h.read().then(({value:v,done:y})=>{if(y){p.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(v,p),f())},v=>{if(p.streamReader=null,!this._transport.destroyed){if(p.operatorList){p.operatorList.lastChunk=!0;for(const y of p.renderTasks)y.operatorListChanged();this.#n(!0)}if(p.displayReadyCapability)p.displayReadyCapability.reject(v);else if(p.opListReadCapability)p.opListReadCapability.reject(v);else throw v}})};f()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof El){let r=sm;e.extraDelay>0&&e.extraDelay<1e3&&(r+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},r);return}}if(t.streamReader.cancel(new Dn(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[r,a]of this._intentStates)if(a===t){this._intentStates.delete(r);break}this.cleanup()}}}get stats(){return this._stats}}class gm{#t=new Map;#e=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const[r]of this.#t)r.call(this,s)})}addEventListener(t,e,s=null){let r=null;if(s?.signal instanceof AbortSignal){const{signal:a}=s;if(a.aborted){At("LoopbackPort - cannot use an `aborted` signal.");return}const l=()=>this.removeEventListener(t,e);r=()=>a.removeEventListener("abort",l),a.addEventListener("abort",l)}this.#t.set(e,r)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(const[,t]of this.#t)t?.();this.#t.clear()}}class ee{static#t=0;static#e=!1;static#n;static{ce&&(this.#e=!0,Es.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let s;try{if(s=new URL(t),!s.origin||s.origin==="null")return!1}catch{return!1}const r=new URL(e,s);return s.origin===r.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:s=Kp()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(ee.#n?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(ee.#n||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}#i(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new As("main","worker",t),this._messageHandler.on("ready",function(){}),this.#i()}_initialize(){if(ee.#e||ee.#r){this._setupFakeWorker();return}let{workerSrc:t}=ee;try{ee._isSameOrigin(window.location.href,t)||(t=ee._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new As("main","worker",e),r=()=>{a.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;e.addEventListener("error",()=>{this._webWorker||r()},{signal:a.signal}),s.on("test",u=>{if(a.abort(),this.destroyed||!u){r();return}this._messageHandler=s,this._port=e,this._webWorker=e,this.#i()}),s.on("ready",u=>{if(a.abort(),this.destroyed){r();return}try{l()}catch{this._setupFakeWorker()}});const l=()=>{const u=new Uint8Array;s.send("test",u,[u.buffer])};l();return}catch{Qr("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){ee.#e||(At("Setting up fake worker."),ee.#e=!0),ee._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new gm;this._port=e;const s=`fake${ee.#t++}`,r=new As(s+"_worker",s,e);t.setup(r,e),this._messageHandler=new As(s,s+"_worker",e),this.#i()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,ee.#n?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#n?.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new ee(t)}static get workerSrc(){if(Es.workerSrc)return Es.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#r(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return bt(this,"_setupFakeWorkerGlobal",(async()=>this.#r?this.#r:(await import(this.workerSrc)).WorkerMessageHandler)())}}class mm{#t=new Map;#e=new Map;#n=new Map;#i=new Map;#r=null;constructor(t,e,s,r,a){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new kd,this.fontLoader=new gg({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=a.canvasFactory,this.filterFactory=a.filterFactory,this.cMapReaderFactory=a.cMapReaderFactory,this.standardFontDataFactory=a.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#s(t,e=null){const s=this.#t.get(t);if(s)return s;const r=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,r),r}get annotationStorage(){return bt(this,"annotationStorage",new Pl)}getRenderingIntent(t,e=In.ENABLE,s=null,r=!1,a=!1){let l=Re.DISPLAY,u=gl;switch(t){case"any":l=Re.ANY;break;case"display":break;case"print":l=Re.PRINT;break;default:At(`getRenderingIntent - invalid intent: ${t}`)}const h=l&Re.PRINT&&s instanceof dd?s:this.annotationStorage;switch(e){case In.DISABLE:l+=Re.ANNOTATIONS_DISABLE;break;case In.ENABLE:break;case In.ENABLE_FORMS:l+=Re.ANNOTATIONS_FORMS;break;case In.ENABLE_STORAGE:l+=Re.ANNOTATIONS_STORAGE,u=h.serializable;break;default:At(`getRenderingIntent - invalid annotationMode: ${e}`)}r&&(l+=Re.IS_EDITING),a&&(l+=Re.OPLIST);const{ids:p,hash:f}=h.modifiedIds,v=[l,u.hash,f];return{renderingIntent:l,cacheKey:v.join("_"),annotationStorageSerializable:u,modifiedIds:p}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#r?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of this.#e.values())t.push(s._destroy());this.#e.clear(),this.#n.clear(),this.#i.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),ge.cleanup(),this._networkStream?.cancelAllRequests(new Dn("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,r)=>{Xt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=a=>{this._lastProgress={loaded:a.loaded,total:a.total}},r.onPull=()=>{this._fullReader.read().then(function({value:a,done:l}){if(l){r.close();return}Xt(a instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{r.error(a)})},r.onCancel=a=>{this._fullReader.cancel(a),r.ready.catch(l=>{if(!this.destroyed)throw l})}}),t.on("ReaderHeadersReady",async s=>{await this._fullReader.headersReady;const{isStreamingSupported:r,isRangeSupported:a,contentLength:l}=this._fullReader;return(!r||!a)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=u=>{e.onProgress?.({loaded:u.loaded,total:u.total})}),{isStreamingSupported:r,isRangeSupported:a,contentLength:l}}),t.on("GetRangeReader",(s,r)=>{Xt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const a=this._networkStream.getRangeReader(s.begin,s.end);if(!a){r.close();return}r.onPull=()=>{a.read().then(function({value:l,done:u}){if(u){r.close();return}Xt(l instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(l),1,[l])}).catch(l=>{r.error(l)})},r.onCancel=l=>{a.cancel(l),r.ready.catch(u=>{if(!this.destroyed)throw u})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new fm(s,this))}),t.on("DocException",s=>{e._capability.reject(Ee(s))}),t.on("PasswordRequest",s=>{this.#r=Promise.withResolvers();try{if(!e.onPassword)throw Ee(s);const r=a=>{a instanceof Error?this.#r.reject(a):this.#r.resolve({password:a})};e.onPassword(r,s.code)}catch(r){this.#r.reject(r)}return this.#r.promise}),t.on("DataLoaded",s=>{e.onProgress?.({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;this.#e.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,r,a])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(r){case"Font":const{disableFontFace:l,fontExtraProperties:u,pdfBug:h}=this._params;if("error"in a){const y=a.error;At(`Error during font loading: ${y}`),this.commonObjs.resolve(s,y);break}const p=h&&globalThis.FontInspector?.enabled?(y,w)=>globalThis.FontInspector.fontAdded(y,w):null,f=new mg(a,{disableFontFace:l,fontExtraProperties:u,inspectFont:p});this.fontLoader.bind(f).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!u&&f.data&&(f.data=null),this.commonObjs.resolve(s,f)});break;case"CopyLocalImage":const{imageRef:v}=a;Xt(v,"The imageRef must be defined.");for(const y of this.#e.values())for(const[,w]of y.objs)if(w?.ref===v)return w.dataLen?(this.commonObjs.resolve(s,structuredClone(w)),w.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,a);break;default:throw new Error(`Got unknown common object type ${r}`)}return null}),t.on("obj",([s,r,a,l])=>{if(this.destroyed)return;const u=this.#e.get(r);if(!u.objs.has(s)){if(u._intentStates.size===0){l?.bitmap?.close();return}switch(a){case"Image":u.objs.resolve(s,l),l?.dataLen>Vp&&(u._maybeCleanupAfterRender=!0);break;case"Pattern":u.objs.resolve(s,l);break;default:throw new Error(`Got unknown object type ${a}`)}}}),t.on("DocProgress",s=>{this.destroyed||e.onProgress?.({loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(s)}),t.on("FetchStandardFontData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&At("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.#n.get(e);if(s)return s;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&this.#i.set(a.refStr,t);const l=new pm(e,a,this,this._params.pdfBug);return this.#e.set(e,l),l});return this.#n.set(e,r),r}getPageIndex(t){return id(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#s("GetFieldObjects")}hasJSActions(){return this.#s("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#s("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#s("GetOptionalContentConfig").then(e=>new zg(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#t.get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(r=>({info:r[0],metadata:r[1]?new Fg(r[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),ge.cleanup()}}cachedPageNumber(t){if(!id(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#i.get(e)??null}}const ys=Symbol("INITIAL_DATA");class kd{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:ys}}get(t,e=null){if(e){const r=this.#e(t);return r.promise.then(()=>e(r.data)),null}const s=this.#t[t];if(!s||s.data===ys)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=this.#t[t];return!!e&&e.data!==ys}delete(t){const e=this.#t[t];return!e||e.data===ys?!1:(delete this.#t[t],!0)}resolve(t,e=null){const s=this.#e(t);s.data=e,s.resolve()}clear(){for(const t in this.#t){const{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(const t in this.#t){const{data:e}=this.#t[t];e!==ys&&(yield[t,e])}}}class vm{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}}class ki{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:r,annotationCanvasMap:a,operatorList:l,pageIndex:u,canvasFactory:h,filterFactory:p,useRequestAnimationFrame:f=!1,pdfBug:v=!1,pageColors:y=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=r,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=l,this._pageIndex=u,this.canvasFactory=h,this.filterFactory=p,this._pdfBug=v,this.pageColors=y,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=f===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new vm(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(ki.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");ki.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:r,transform:a,background:l}=this.params;this.gfx=new Ti(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:r,transparency:t,background:l}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),ki.#e.delete(this._canvas),this.callback(t||new El(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),ki.#e.delete(this._canvas),this.callback())))}}const ym="4.10.38",wm="f9bea397f";function sd(g){return Math.floor(Math.max(0,Math.min(1,g))*255).toString(16).padStart(2,"0")}function ws(g){return Math.max(0,Math.min(255,255*g))}class rd{static CMYK_G([t,e,s,r]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+r)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=ws(t),[t,t,t]}static G_HTML([t]){const e=sd(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(ws)}static RGB_HTML(t){return`#${t.map(sd).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,r]){return["RGB",1-Math.min(1,t+r),1-Math.min(1,s+r),1-Math.min(1,e+r)]}static CMYK_rgb([t,e,s,r]){return[ws(1-Math.min(1,t+r)),ws(1-Math.min(1,s+r)),ws(1-Math.min(1,e+r))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const r=1-t,a=1-e,l=1-s,u=Math.min(r,a,l);return["CMYK",r,a,l,u]}}class _m{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const r=this._createSVG("svg:svg");return r.setAttribute("version","1.1"),s||(r.setAttribute("width",`${t}px`),r.setAttribute("height",`${e}px`)),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("viewBox",`0 0 ${t} ${e}`),r}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Lt("Abstract method `_createSVG` called.")}}class Il extends _m{_createSVG(t){return document.createElementNS(dn,t)}}class Td{static setupStorage(t,e,s,r,a){const l=r.getValue(e,{value:null});switch(s.name){case"textarea":if(l.value!==null&&(t.textContent=l.value),a==="print")break;t.addEventListener("input",u=>{r.setValue(e,{value:u.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(l.value===s.attributes.xfaOn?t.setAttribute("checked",!0):l.value===s.attributes.xfaOff&&t.removeAttribute("checked"),a==="print")break;t.addEventListener("change",u=>{r.setValue(e,{value:u.target.checked?u.target.getAttribute("xfaOn"):u.target.getAttribute("xfaOff")})})}else{if(l.value!==null&&t.setAttribute("value",l.value),a==="print")break;t.addEventListener("input",u=>{r.setValue(e,{value:u.target.value})})}break;case"select":if(l.value!==null){t.setAttribute("value",l.value);for(const u of s.children)u.attributes.value===l.value?u.attributes.selected=!0:u.attributes.hasOwnProperty("selected")&&delete u.attributes.selected}t.addEventListener("input",u=>{const h=u.target.options,p=h.selectedIndex===-1?"":h[h.selectedIndex].value;r.setValue(e,{value:p})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:r,linkService:a}){const{attributes:l}=e,u=t instanceof HTMLAnchorElement;l.type==="radio"&&(l.name=`${l.name}-${r}`);for(const[h,p]of Object.entries(l))if(p!=null)switch(h){case"class":p.length&&t.setAttribute(h,p.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",p);break;case"style":Object.assign(t.style,p);break;case"textContent":t.textContent=p;break;default:(!u||h!=="href"&&h!=="newWindow")&&t.setAttribute(h,p)}u&&a.addLinkAttributes(t,l.href,l.newWindow),s&&l.dataId&&this.setupStorage(t,l.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,r=t.xfaHtml,a=t.intent||"display",l=document.createElement(r.name);r.attributes&&this.setAttributes({html:l,element:r,intent:a,linkService:s});const u=a!=="richText",h=t.div;if(h.append(l),t.viewport){const v=`matrix(${t.viewport.transform.join(",")})`;h.style.transform=v}u&&h.setAttribute("class","xfaLayer xfaFont");const p=[];if(r.children.length===0){if(r.value){const v=document.createTextNode(r.value);l.append(v),u&&Cs.shouldBuildText(r.name)&&p.push(v)}return{textDivs:p}}const f=[[r,-1,l]];for(;f.length>0;){const[v,y,w]=f.at(-1);if(y+1===v.children.length){f.pop();continue}const A=v.children[++f.at(-1)[1]];if(A===null)continue;const{name:S}=A;if(S==="#text"){const x=document.createTextNode(A.value);p.push(x),w.append(x);continue}const E=A?.attributes?.xmlns?document.createElementNS(A.attributes.xmlns,S):document.createElement(S);if(w.append(E),A.attributes&&this.setAttributes({html:E,element:A,storage:e,intent:a,linkService:s}),A.children?.length>0)f.push([A,-1,E]);else if(A.value){const x=document.createTextNode(A.value);u&&Cs.shouldBuildText(S)&&p.push(x),E.append(x)}}for(const v of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))v.setAttribute("readOnly",!0);return{textDivs:p}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Ps=1e3,Am=9,Jn=new WeakSet;function Nn(g){return{width:g[2]-g[0],height:g[3]-g[1]}}class Sm{static create(t){switch(t.data.annotationType){case Kt.LINK:return new Pd(t);case Kt.TEXT:return new bm(t);case Kt.WIDGET:switch(t.data.fieldType){case"Tx":return new Em(t);case"Btn":return t.data.radioButton?new Rd(t):t.data.checkBox?new Cm(t):new km(t);case"Ch":return new Tm(t);case"Sig":return new xm(t)}return new ti(t);case Kt.POPUP:return new vl(t);case Kt.FREETEXT:return new Md(t);case Kt.LINE:return new Rm(t);case Kt.SQUARE:return new Mm(t);case Kt.CIRCLE:return new Lm(t);case Kt.POLYLINE:return new Ld(t);case Kt.CARET:return new Nm(t);case Kt.INK:return new Nl(t);case Kt.POLYGON:return new Im(t);case Kt.HIGHLIGHT:return new Id(t);case Kt.UNDERLINE:return new Dm(t);case Kt.SQUIGGLY:return new Fm(t);case Kt.STRIKEOUT:return new Om(t);case Kt.STAMP:return new Nd(t);case Kt.FILEATTACHMENT:return new zm(t);default:return new Wt(t)}}}class Wt{#t=null;#e=!1;#n=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:r=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),r&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t?.str||e?.str||s?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Wt._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#i(e),this.#n?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#i(this.#t.rect),this.#n?.popup.resetEdited(),this.#t=null)}#i(t){const{container:{style:e},data:{rect:s,rotation:r},parent:{viewport:{rawDims:{pageWidth:a,pageHeight:l,pageX:u,pageY:h}}}}=this;s?.splice(0,4,...t);const{width:p,height:f}=Nn(t);e.left=`${100*(t[0]-u)/a}%`,e.top=`${100*(l-t[3]+h)/l}%`,r===0?(e.width=`${100*p/a}%`,e.height=`${100*f/l}%`):this.setRotation(r)}_createContainer(t){const{data:e,parent:{page:s,viewport:r}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",e.id),this instanceof ti||(a.tabIndex=Ps);const{style:l}=a;if(l.zIndex=this.parent.zIndex++,e.alternativeText&&(a.title=e.alternativeText),e.noRotate&&a.classList.add("norotate"),!e.rect||this instanceof vl){const{rotation:S}=e;return!e.hasOwnCanvas&&S!==0&&this.setRotation(S,a),a}const{width:u,height:h}=Nn(e.rect);if(!t&&e.borderStyle.width>0){l.borderWidth=`${e.borderStyle.width}px`;const S=e.borderStyle.horizontalCornerRadius,E=e.borderStyle.verticalCornerRadius;if(S>0||E>0){const M=`calc(${S}px * var(--scale-factor)) / calc(${E}px * var(--scale-factor))`;l.borderRadius=M}else if(this instanceof Rd){const M=`calc(${u}px * var(--scale-factor)) / calc(${h}px * var(--scale-factor))`;l.borderRadius=M}switch(e.borderStyle.style){case ms.SOLID:l.borderStyle="solid";break;case ms.DASHED:l.borderStyle="dashed";break;case ms.BEVELED:At("Unimplemented border style: beveled");break;case ms.INSET:At("Unimplemented border style: inset");break;case ms.UNDERLINE:l.borderBottomStyle="solid";break}const x=e.borderColor||null;x?(this.#e=!0,l.borderColor=lt.makeHexColor(x[0]|0,x[1]|0,x[2]|0)):l.borderWidth=0}const p=lt.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:f,pageHeight:v,pageX:y,pageY:w}=r.rawDims;l.left=`${100*(p[0]-y)/f}%`,l.top=`${100*(p[1]-w)/v}%`;const{rotation:A}=e;return e.hasOwnCanvas||A===0?(l.width=`${100*u/f}%`,l.height=`${100*h/v}%`):this.setRotation(A,a),a}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:r}=this.parent.viewport.rawDims,{width:a,height:l}=Nn(this.data.rect);let u,h;t%180===0?(u=100*a/s,h=100*l/r):(u=100*l/s,h=100*a/r),e.style.width=`${u}%`,e.style.height=`${h}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,r)=>{const a=r.detail[e],l=a[0],u=a.slice(1);r.target.style[s]=rd[`${l}_HTML`](u),this.annotationStorage.setValue(this.data.id,{[s]:rd[`${l}_rgb`](u)})};return bt(this,"_commonActions",{display:e=>{const{display:s}=e.detail,r=s%2===1;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:r,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const r of Object.keys(e.detail))(t[r]||s[r])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[r,a]of Object.entries(e)){const l=s[r];if(l){const u={detail:{[r]:a},target:t};l(u),delete e[r]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,r,a]=this.data.rect.map(S=>Math.fround(S));if(t.length===8){const[S,E,x,M]=t.subarray(2,6);if(r===S&&a===E&&e===x&&s===M)return}const{style:l}=this.container;let u;if(this.#e){const{borderColor:S,borderWidth:E}=l;l.borderWidth=0,u=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${S}" stroke-width="${E}">`],this.container.classList.add("hasBorder")}const h=r-e,p=a-s,{svgFactory:f}=this,v=f.createElement("svg");v.classList.add("quadrilateralsContainer"),v.setAttribute("width",0),v.setAttribute("height",0);const y=f.createElement("defs");v.append(y);const w=f.createElement("clipPath"),A=`clippath_${this.data.id}`;w.setAttribute("id",A),w.setAttribute("clipPathUnits","objectBoundingBox"),y.append(w);for(let S=2,E=t.length;S<E;S+=8){const x=t[S],M=t[S+1],I=t[S+2],N=t[S+3],O=f.createElement("rect"),H=(I-e)/h,F=(a-M)/p,G=(x-I)/h,Y=(M-N)/p;O.setAttribute("x",H),O.setAttribute("y",F),O.setAttribute("width",G),O.setAttribute("height",Y),w.append(O),u?.push(`<rect vector-effect="non-scaling-stroke" x="${H}" y="${F}" width="${G}" height="${Y}"/>`)}this.#e&&(u.push("</g></svg>')"),l.backgroundImage=u.join("")),this.container.append(v),this.container.style.clipPath=`url(#${A})`}_createPopup(){const{data:t}=this,e=this.#n=new vl({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){Lt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const r=this._fieldObjects[t];if(r)for(const{page:a,id:l,exportValues:u}of r){if(a===-1||l===e)continue;const h=typeof u=="string"?u:null,p=document.querySelector(`[data-element-id="${l}"]`);if(p&&!Jn.has(p)){At(`_getElementsByName - element not allowed: ${l}`);continue}s.push({id:l,exportValue:h,domElement:p})}return s}for(const r of document.getElementsByName(t)){const{exportValue:a}=r,l=r.getAttribute("data-element-id");l!==e&&Jn.has(r)&&s.push({id:l,exportValue:a,domElement:r})}return s}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}}class Pd extends Wt{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let r=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),r=!0):t.action?(this._bindNamedAction(s,t.action),r=!0):t.attachment?(this.#e(s,t.attachment,t.attachmentDest),r=!0):t.setOCGState?(this.#n(s,t.setOCGState),r=!0):t.dest?(this._bindLink(s,t.dest),r=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),r=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(s,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(s),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&this.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,s=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#t()}#n(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(e.actions)){const a=s.get(r);a&&(t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:r}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){At('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1);return}t.onclick=()=>{s?.();const{fields:r,refs:a,include:l}=e,u=[];if(r.length!==0||a.length!==0){const f=new Set(a);for(const v of r){const y=this._fieldObjects[v]||[];for(const{id:w}of y)f.add(w)}for(const v of Object.values(this._fieldObjects))for(const y of v)f.has(y.id)===l&&u.push(y)}else for(const f of Object.values(this._fieldObjects))u.push(...f);const h=this.annotationStorage,p=[];for(const f of u){const{id:v}=f;switch(p.push(v),f.type){case"text":{const w=f.defaultValue||"";h.setValue(v,{value:w});break}case"checkbox":case"radiobutton":{const w=f.defaultValue===f.exportValues;h.setValue(v,{value:w});break}case"combobox":case"listbox":{const w=f.defaultValue||"";h.setValue(v,{value:w});break}default:continue}const y=document.querySelector(`[data-element-id="${v}"]`);if(y){if(!Jn.has(y)){At(`_bindResetFormAction - element not allowed: ${v}`);continue}}else continue;y.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:p,name:"ResetForm"}}),!1}}}class bm extends Wt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class ti extends Wt{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return me.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,r,a){s.includes("mouse")?t.addEventListener(s,l=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:a(l),shift:l.shiftKey,modifier:this._getKeyModifier(l)}})}):t.addEventListener(s,l=>{if(s==="blur"){if(!e.focused||!l.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}a&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:a(l)}})})}_setEventListeners(t,e,s,r){for(const[a,l]of s)(l==="Action"||this.data.actions?.[l])&&((l==="Focus"||l==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,a,l,r),l==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):l==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":lt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||Am,a=t.style;let l;const u=2,h=p=>Math.round(10*p)/10;if(this.data.multiLine){const p=Math.abs(this.data.rect[3]-this.data.rect[1]-u),f=Math.round(p/(sl*r))||1,v=p/f;l=Math.min(r,h(v/sl))}else{const p=Math.abs(this.data.rect[3]-this.data.rect[1]-u);l=Math.min(r,h(p/sl))}a.fontSize=`calc(${l}px * var(--scale-factor))`,a.color=lt.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(a.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Em extends ti{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,r){const a=this.annotationStorage;for(const l of this._getElementsByName(t.name,t.id))l.domElement&&(l.domElement[e]=s),a.setValue(l.id,{[r]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const r=t.getValue(e,{value:this.data.fieldValue});let a=r.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&a.length>l&&(a=a.slice(0,l));let u=r.formattedValue||this.data.textContent?.join(`
|
|
42
|
+
`)||null;u&&this.data.comb&&(u=u.replaceAll(/\s+/g,""));const h={userValue:a,formattedValue:u,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=u??a,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",u??a),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Jn.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=Ps,this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",f=>{t.setValue(e,{value:f.target.value}),this.setPropertyOnSiblings(s,"value",f.target.value,"value"),h.formattedValue=null}),s.addEventListener("resetform",f=>{const v=this.data.defaultFieldValue??"";s.value=h.userValue=v,h.formattedValue=null});let p=f=>{const{formattedValue:v}=h;v!=null&&(f.target.value=v),f.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",v=>{if(h.focused)return;const{target:y}=v;h.userValue&&(y.value=h.userValue),h.lastCommittedValue=y.value,h.commitKey=1,this.data.actions?.Focus||(h.focused=!0)}),s.addEventListener("updatefromsandbox",v=>{this.showElementAndHideCanvas(v.target);const y={value(w){h.userValue=w.detail.value??"",t.setValue(e,{value:h.userValue.toString()}),w.target.value=h.userValue},formattedValue(w){const{formattedValue:A}=w.detail;h.formattedValue=A,A!=null&&w.target!==document.activeElement&&(w.target.value=A),t.setValue(e,{formattedValue:A})},selRange(w){w.target.setSelectionRange(...w.detail.selRange)},charLimit:w=>{const{charLimit:A}=w.detail,{target:S}=w;if(A===0){S.removeAttribute("maxLength");return}S.setAttribute("maxLength",A);let E=h.userValue;!E||E.length<=A||(E=E.slice(0,A),S.value=h.userValue=E,t.setValue(e,{value:E}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,willCommit:!0,commitKey:1,selStart:S.selectionStart,selEnd:S.selectionEnd}}))}};this._dispatchEventFromSandbox(y,v)}),s.addEventListener("keydown",v=>{h.commitKey=1;let y=-1;if(v.key==="Escape"?y=0:v.key==="Enter"&&!this.data.multiLine?y=2:v.key==="Tab"&&(h.commitKey=3),y===-1)return;const{value:w}=v.target;h.lastCommittedValue!==w&&(h.lastCommittedValue=w,h.userValue=w,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:w,willCommit:!0,commitKey:y,selStart:v.target.selectionStart,selEnd:v.target.selectionEnd}}))});const f=p;p=null,s.addEventListener("blur",v=>{if(!h.focused||!v.relatedTarget)return;this.data.actions?.Blur||(h.focused=!1);const{value:y}=v.target;h.userValue=y,h.lastCommittedValue!==y&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:y,willCommit:!0,commitKey:h.commitKey,selStart:v.target.selectionStart,selEnd:v.target.selectionEnd}}),f(v)}),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",v=>{h.lastCommittedValue=null;const{data:y,target:w}=v,{value:A,selectionStart:S,selectionEnd:E}=w;let x=S,M=E;switch(v.inputType){case"deleteWordBackward":{const I=A.substring(0,S).match(/\w*[^\w]*$/);I&&(x-=I[0].length);break}case"deleteWordForward":{const I=A.substring(S).match(/^[^\w]*\w*/);I&&(M+=I[0].length);break}case"deleteContentBackward":S===E&&(x-=1);break;case"deleteContentForward":S===E&&(M+=1);break}v.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,change:y||"",willCommit:!1,selStart:x,selEnd:M}})}),this._setEventListeners(s,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],v=>v.target.value)}if(p&&s.addEventListener("blur",p),this.data.comb){const v=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${v}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class xm extends ti{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Cm extends ti{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let r=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof r=="string"&&(r=r!=="Off",t.setValue(s,{value:r})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const a=document.createElement("input");return Jn.add(a),a.setAttribute("data-element-id",s),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="checkbox",a.name=e.fieldName,r&&a.setAttribute("checked",!0),a.setAttribute("exportValue",e.exportValue),a.tabIndex=Ps,a.addEventListener("change",l=>{const{name:u,checked:h}=l.target;for(const p of this._getElementsByName(u,s)){const f=h&&p.exportValue===e.exportValue;p.domElement&&(p.domElement.checked=f),t.setValue(p.id,{value:f})}t.setValue(s,{value:h})}),a.addEventListener("resetform",l=>{const u=e.defaultFieldValue||"Off";l.target.checked=u===e.exportValue}),this.enableScripting&&this.hasJSActions&&(a.addEventListener("updatefromsandbox",l=>{const u={value(h){h.target.checked=h.detail.value!=="Off",t.setValue(s,{value:h.target.checked})}};this._dispatchEventFromSandbox(u,l)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],l=>l.target.checked)),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class Rd extends ti{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let r=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof r=="string"&&(r=r!==e.buttonValue,t.setValue(s,{value:r})),r)for(const l of this._getElementsByName(e.fieldName,s))t.setValue(l.id,{value:!1});const a=document.createElement("input");if(Jn.add(a),a.setAttribute("data-element-id",s),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=e.fieldName,r&&a.setAttribute("checked",!0),a.tabIndex=Ps,a.addEventListener("change",l=>{const{name:u,checked:h}=l.target;for(const p of this._getElementsByName(u,s))t.setValue(p.id,{value:!1});t.setValue(s,{value:h})}),a.addEventListener("resetform",l=>{const u=e.defaultFieldValue;l.target.checked=u!=null&&u===e.buttonValue}),this.enableScripting&&this.hasJSActions){const l=e.buttonValue;a.addEventListener("updatefromsandbox",u=>{const h={value:p=>{const f=l===p.detail.value;for(const v of this._getElementsByName(p.target.name)){const y=f&&v.id===s;v.domElement&&(v.domElement.checked=y),t.setValue(v.id,{value:y})}}};this._dispatchEventFromSandbox(h,u)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],u=>u.target.checked)}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class km extends Pd{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class Tm extends ti{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),r=document.createElement("select");Jn.add(r),r.setAttribute("data-element-id",e),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=Ps;let a=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener("resetform",f=>{const v=this.data.defaultFieldValue;for(const y of r.options)y.selected=y.value===v});for(const f of this.data.options){const v=document.createElement("option");v.textContent=f.displayValue,v.value=f.exportValue,s.value.includes(f.exportValue)&&(v.setAttribute("selected",!0),a=!1),r.append(v)}let l=null;if(a){const f=document.createElement("option");f.value=" ",f.setAttribute("hidden",!0),f.setAttribute("selected",!0),r.prepend(f),l=()=>{f.remove(),r.removeEventListener("input",l),l=null},r.addEventListener("input",l)}const u=f=>{const v=f?"value":"textContent",{options:y,multiple:w}=r;return w?Array.prototype.filter.call(y,A=>A.selected).map(A=>A[v]):y.selectedIndex===-1?null:y[y.selectedIndex][v]};let h=u(!1);const p=f=>{const v=f.target.options;return Array.prototype.map.call(v,y=>({displayValue:y.textContent,exportValue:y.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener("updatefromsandbox",f=>{const v={value(y){l?.();const w=y.detail.value,A=new Set(Array.isArray(w)?w:[w]);for(const S of r.options)S.selected=A.has(S.value);t.setValue(e,{value:u(!0)}),h=u(!1)},multipleSelection(y){r.multiple=!0},remove(y){const w=r.options,A=y.detail.remove;w[A].selected=!1,r.remove(A),w.length>0&&Array.prototype.findIndex.call(w,E=>E.selected)===-1&&(w[0].selected=!0),t.setValue(e,{value:u(!0),items:p(y)}),h=u(!1)},clear(y){for(;r.length!==0;)r.remove(0);t.setValue(e,{value:null,items:[]}),h=u(!1)},insert(y){const{index:w,displayValue:A,exportValue:S}=y.detail.insert,E=r.children[w],x=document.createElement("option");x.textContent=A,x.value=S,E?E.before(x):r.append(x),t.setValue(e,{value:u(!0),items:p(y)}),h=u(!1)},items(y){const{items:w}=y.detail;for(;r.length!==0;)r.remove(0);for(const A of w){const{displayValue:S,exportValue:E}=A,x=document.createElement("option");x.textContent=S,x.value=E,r.append(x)}r.options.length>0&&(r.options[0].selected=!0),t.setValue(e,{value:u(!0),items:p(y)}),h=u(!1)},indices(y){const w=new Set(y.detail.indices);for(const A of y.target.options)A.selected=w.has(A.index);t.setValue(e,{value:u(!0)}),h=u(!1)},editable(y){y.target.disabled=!y.detail.editable}};this._dispatchEventFromSandbox(v,f)}),r.addEventListener("input",f=>{const v=u(!0),y=u(!1);t.setValue(e,{value:v}),f.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:h,change:y,changeEx:v,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],f=>f.target.value)):r.addEventListener("input",function(f){t.setValue(e,{value:u(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class vl extends Wt{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:Wt._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Pm({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const s of this.elements)s.popup=t,s.container.ariaHasPopup="dialog",e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(s=>`${bl}${s}`).join(",")),this.container}}class Pm{#t=this.#k.bind(this);#e=this.#C.bind(this);#n=this.#T.bind(this);#i=this.#S.bind(this);#r=null;#s=null;#l=null;#a=null;#c=null;#u=null;#d=null;#h=!1;#f=null;#o=null;#p=null;#m=null;#g=null;#v=null;#_=!1;constructor({container:t,color:e,elements:s,titleObj:r,modificationDate:a,contentsObj:l,richText:u,parent:h,rect:p,parentRect:f,open:v}){this.#s=t,this.#g=r,this.#l=l,this.#m=u,this.#u=h,this.#r=e,this.#p=p,this.#d=f,this.#c=s,this.#a=cd.toDateObject(a),this.trigger=s.flatMap(y=>y.getElementsToTriggerPopup());for(const y of this.trigger)y.addEventListener("click",this.#i),y.addEventListener("mouseenter",this.#n),y.addEventListener("mouseleave",this.#e),y.classList.add("popupTriggerArea");for(const y of s)y.container?.addEventListener("keydown",this.#t);this.#s.hidden=!0,v&&this.#S()}render(){if(this.#f)return;const t=this.#f=document.createElement("div");if(t.className="popup",this.#r){const a=t.style.outlineColor=lt.makeHexColor(...this.#r);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${a} 30%, white)`:t.style.backgroundColor=lt.makeHexColor(...this.#r.map(u=>Math.floor(.7*(255-u)+u)))}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=this.#g,t.append(e),this.#a){const a=document.createElement("span");a.classList.add("popupDate"),a.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),a.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#a.valueOf()})),e.append(a)}const r=this.#y;if(r)Td.render({xfaHtml:r,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const a=this._formatContents(this.#l);t.append(a)}this.#s.append(t)}get#y(){const t=this.#m,e=this.#l;return t?.str&&(!e?.str||e.str===t.str)&&this.#m.html||null}get#A(){return this.#y?.attributes?.style?.fontSize||0}get#b(){return this.#y?.attributes?.style?.color||null}#x(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},r={style:{color:this.#b,fontSize:this.#A?`calc(${this.#A}px * var(--scale-factor))`:""}};for(const a of t.split(`
|
|
43
|
+
`))e.push({name:"span",value:a,attributes:r});return s}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;const r=t.split(/(?:\r\n?|\n)/);for(let a=0,l=r.length;a<l;++a){const u=r[a];s.append(document.createTextNode(u)),a<l-1&&s.append(document.createElement("br"))}return s}#k(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#h)&&this.#S()}updateEdited({rect:t,popupContent:e}){this.#v||={contentsObj:this.#l,richText:this.#m},t&&(this.#o=null),e&&(this.#m=this.#x(e),this.#l=null),this.#f?.remove(),this.#f=null}resetEdited(){this.#v&&({contentsObj:this.#l,richText:this.#m}=this.#v,this.#v=null,this.#f?.remove(),this.#f=null,this.#o=null)}#P(){if(this.#o!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:r,pageY:a}}}=this.#u;let l=!!this.#d,u=l?this.#d:this.#p;for(const A of this.#c)if(!u||lt.intersect(A.data.rect,u)!==null){u=A.data.rect,l=!0;break}const h=lt.normalizeRect([u[0],t[3]-u[1]+t[1],u[2],t[3]-u[3]+t[1]]),f=l?u[2]-u[0]+5:0,v=h[0]+f,y=h[1];this.#o=[100*(v-r)/e,100*(y-a)/s];const{style:w}=this.#s;w.left=`${this.#o[0]}%`,w.top=`${this.#o[1]}%`}#S(){this.#h=!this.#h,this.#h?(this.#T(),this.#s.addEventListener("click",this.#i),this.#s.addEventListener("keydown",this.#t)):(this.#C(),this.#s.removeEventListener("click",this.#i),this.#s.removeEventListener("keydown",this.#t))}#T(){this.#f||this.render(),this.isVisible?this.#h&&this.#s.classList.add("focused"):(this.#P(),this.#s.hidden=!1,this.#s.style.zIndex=parseInt(this.#s.style.zIndex)+1e3)}#C(){this.#s.classList.remove("focused"),!(this.#h||!this.isVisible)&&(this.#s.hidden=!0,this.#s.style.zIndex=parseInt(this.#s.style.zIndex)-1e3)}forceHide(){this.#_=this.isVisible,this.#_&&(this.#s.hidden=!0)}maybeShow(){this.#_&&(this.#f||this.#T(),this.#_=!1,this.#s.hidden=!1)}get isVisible(){return this.#s.hidden===!1}}class Md extends Wt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=_t.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Rm extends Wt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:s}=Nn(t.rect),r=this.svgFactory.create(e,s,!0),a=this.#t=this.svgFactory.createElement("svg:line");return a.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),a.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),a.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),a.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),a.setAttribute("stroke-width",t.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Mm extends Wt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:s}=Nn(t.rect),r=this.svgFactory.create(e,s,!0),a=t.borderStyle.width,l=this.#t=this.svgFactory.createElement("svg:rect");return l.setAttribute("x",a/2),l.setAttribute("y",a/2),l.setAttribute("width",e-a),l.setAttribute("height",s-a),l.setAttribute("stroke-width",a||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Lm extends Wt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:s}=Nn(t.rect),r=this.svgFactory.create(e,s,!0),a=t.borderStyle.width,l=this.#t=this.svgFactory.createElement("svg:ellipse");return l.setAttribute("cx",e/2),l.setAttribute("cy",s/2),l.setAttribute("rx",e/2-a/2),l.setAttribute("ry",s/2-a/2),l.setAttribute("stroke-width",a||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ld extends Wt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:s,popupRef:r}}=this;if(!e)return this.container;const{width:a,height:l}=Nn(t),u=this.svgFactory.create(a,l,!0);let h=[];for(let f=0,v=e.length;f<v;f+=2){const y=e[f]-t[0],w=t[3]-e[f+1];h.push(`${y},${w}`)}h=h.join(" ");const p=this.#t=this.svgFactory.createElement(this.svgElementName);return p.setAttribute("points",h),p.setAttribute("stroke-width",s.width||1),p.setAttribute("stroke","transparent"),p.setAttribute("fill","transparent"),u.append(p),this.container.append(u),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Im extends Ld{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Nm extends Wt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Nl extends Wt{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?_t.HIGHLIGHT:_t.INK}#n(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:s,borderStyle:r,popupRef:a}}=this,{transform:l,width:u,height:h}=this.#n(e,t),p=this.svgFactory.create(u,h,!0),f=this.#t=this.svgFactory.createElement("svg:g");p.append(f),f.setAttribute("stroke-width",r.width||1),f.setAttribute("stroke-linecap","round"),f.setAttribute("stroke-linejoin","round"),f.setAttribute("stroke-miterlimit",10),f.setAttribute("stroke","transparent"),f.setAttribute("fill","transparent"),f.setAttribute("transform",l);for(let v=0,y=s.length;v<y;v++){const w=this.svgFactory.createElement(this.svgElementName);this.#e.push(w),w.setAttribute("points",s[v].join(",")),f.append(w)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(p),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:s,rect:r}=t,a=this.#t;if(e>=0&&a.setAttribute("stroke-width",e||1),s)for(let l=0,u=this.#e.length;l<u;l++)this.#e[l].setAttribute("points",s[l].join(","));if(r){const{transform:l,width:u,height:h}=this.#n(this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${u} ${h}`),a.setAttribute("transform",l)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class Id extends Wt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=_t.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Dm extends Wt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class Fm extends Wt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Om extends Wt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class Nd extends Wt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=_t.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class zm extends Wt{#t=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let s;e.hasAppearance||e.fillAlpha===0?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;const{isMac:r}=me.platform;return t.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class jm{#t=null;#e=null;#n=new Map;#i=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:r,page:a,viewport:l,structTreeLayer:u}){this.div=t,this.#t=e,this.#e=s,this.#i=u||null,this.page=a,this.viewport=l,this.zIndex=0,this._annotationEditorUIManager=r}hasEditableAnnotations(){return this.#n.size>0}async#r(t,e){const s=t.firstChild||t,r=s.id=`${bl}${e}`,a=await this.#i?.getAriaAttributes(r);if(a)for(const[l,u]of a)s.setAttribute(l,u);this.div.append(t),this.#t?.moveElementInDOM(this.div,t,s,!1)}async render(t){const{annotations:e}=t,s=this.div;Zn(s,this.viewport);const r=new Map,a={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Il,annotationStorage:t.annotationStorage||new Pl,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const l of e){if(l.noHTML)continue;const u=l.annotationType===Kt.POPUP;if(u){const f=r.get(l.id);if(!f)continue;a.elements=f}else{const{width:f,height:v}=Nn(l.rect);if(f<=0||v<=0)continue}a.data=l;const h=Sm.create(a);if(!h.isRenderable)continue;if(!u&&l.popupRef){const f=r.get(l.popupRef);f?f.push(h):r.set(l.popupRef,[h])}const p=h.render();l.hidden&&(p.style.visibility="hidden"),await this.#r(p,l.id),h._isEditable&&(this.#n.set(h.data.id,h),this._annotationEditorUIManager?.renderAnnotationElement(h))}this.#s()}update({viewport:t}){const e=this.div;this.viewport=t,Zn(e,{rotation:t.rotation}),this.#s(),e.hidden=!1}#s(){if(!this.#e)return;const t=this.div;for(const[e,s]of this.#e){const r=t.querySelector(`[data-annotation-id="${e}"]`);if(!r)continue;s.className="annotationContent";const{firstChild:a}=r;a?a.nodeName==="CANVAS"?a.replaceWith(s):a.classList.contains("annotationContent")?a.after(s):a.before(s):r.append(s)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#n.values())}getEditableAnnotation(t){return this.#n.get(t)}}const Wr=/\r\n?|\n/g;class Qt extends pt{#t;#e="";#n=`${this.id}-editor`;#i=null;#r;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=Qt.prototype,e=a=>a.isEmpty(),s=Fn.TRANSLATE_SMALL,r=Fn.TRANSLATE_BIG;return bt(this,"_keyboardManager",new Ts([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,r],checker:e}]]))}static _type="freetext";static _editorType=_t.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#t=t.color||Qt._defaultColor||pt._defaultLineColor,this.#r=t.fontSize||Qt._defaultFontSize}static initialize(t,e){pt.initialize(t,e);const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case xt.FREETEXT_SIZE:Qt._defaultFontSize=e;break;case xt.FREETEXT_COLOR:Qt._defaultColor=e;break}}updateParams(t,e){switch(t){case xt.FREETEXT_SIZE:this.#s(e);break;case xt.FREETEXT_COLOR:this.#l(e);break}}static get defaultPropertiesToUpdate(){return[[xt.FREETEXT_SIZE,Qt._defaultFontSize],[xt.FREETEXT_COLOR,Qt._defaultColor||pt._defaultLineColor]]}get propertiesToUpdate(){return[[xt.FREETEXT_SIZE,this.#r],[xt.FREETEXT_COLOR,this.#t]]}#s(t){const e=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--scale-factor))`,this.translate(0,-(r-this.#r)*this.parentScale),this.#r=r,this.#c()},s=this.#r;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:xt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#l(t){const e=r=>{this.#t=this.editorDiv.style.color=r},s=this.#t;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:xt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-Qt._internalPadding*t,-(Qt._internalPadding+this.#r)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(_t.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#i=new AbortController;const t=this._uiManager.combinedSignal(this.#i);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#n),this._isDraggable=!0,this.#i?.abort(),this.#i=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#a(){const t=[];this.editorDiv.normalize();let e=null;for(const s of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&s.nodeName==="BR"||(t.push(Qt.#u(s)),e=s);return t.join(`
|
|
44
|
+
`)}#c(){const[t,e]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:r,div:a}=this,l=a.style.display,u=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.div.append(this.div),s=a.getBoundingClientRect(),a.remove(),a.style.display=l,a.classList.toggle("hidden",u)}this.rotation%180===this.parentRotation%180?(this.width=s.width/t,this.height=s.height/e):(this.width=s.height/t,this.height=s.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#e,e=this.#e=this.#a().trimEnd();if(t===e)return;const s=r=>{if(this.#e=r,!r){this.remove();return}this.#d(),this._uiManager.rebuild(this),this.#c()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#c()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Qt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#n),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:s}=this.editorDiv;if(s.fontSize=`calc(${this.#r}px * var(--scale-factor))`,s.color=this.#t,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Xr(this,this.div,["dblclick","keydown"]),this.width){const[r,a]=this.parentDimensions;if(this.annotationElementId){const{position:l}=this._initialData;let[u,h]=this.getInitialTranslation();[u,h]=this.pageTranslationToScreen(u,h);const[p,f]=this.pageDimensions,[v,y]=this.pageTranslation;let w,A;switch(this.rotation){case 0:w=t+(l[0]-v)/p,A=e+this.height-(l[1]-y)/f;break;case 90:w=t+(l[0]-v)/p,A=e-(l[1]-y)/f,[u,h]=[h,-u];break;case 180:w=t-this.width+(l[0]-v)/p,A=e-(l[1]-y)/f,[u,h]=[-u,-h];break;case 270:w=t+(l[0]-v-this.height*f)/p,A=e+(l[1]-y-this.width*p)/f,[u,h]=[-h,u];break}this.setAt(w*r,A*a,u,h)}else this.setAt(t*r,e*a,this.width*r,this.height*a);this.#d(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#u(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Wr,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();const r=Qt.#f(e.getData("text")||"").replaceAll(Wr,`
|
|
45
|
+
`);if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const l=a.getRangeAt(0);if(!r.includes(`
|
|
46
|
+
`)){l.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:u,startOffset:h}=l,p=[],f=[];if(u.nodeType===Node.TEXT_NODE){const w=u.parentElement;if(f.push(u.nodeValue.slice(h).replaceAll(Wr,"")),w!==this.editorDiv){let A=p;for(const S of this.editorDiv.childNodes){if(S===w){A=f;continue}A.push(Qt.#u(S))}}p.push(u.nodeValue.slice(0,h).replaceAll(Wr,""))}else if(u===this.editorDiv){let w=p,A=0;for(const S of this.editorDiv.childNodes)A++===h&&(w=f),w.push(Qt.#u(S))}this.#e=`${p.join(`
|
|
47
|
+
`)}${r}${f.join(`
|
|
48
|
+
`)}`,this.#d();const v=new Range;let y=p.reduce((w,A)=>w+A.length,0);for(const{firstChild:w}of this.editorDiv.childNodes)if(w.nodeType===Node.TEXT_NODE){const A=w.nodeValue.length;if(y<=A){v.setStart(w,y),v.setEnd(w,y);break}y-=A}a.removeAllRanges(),a.addRange(v)}#d(){if(this.editorDiv.replaceChildren(),!!this.#e)for(const t of this.#e.split(`
|
|
49
|
+
`)){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#h(){return this.#e.replaceAll(" "," ")}static#f(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,s){let r=null;if(t instanceof Md){const{data:{defaultAppearanceData:{fontSize:l,fontColor:u},rect:h,rotation:p,id:f,popupRef:v},textContent:y,textPosition:w,parent:{page:{pageNumber:A}}}=t;if(!y||y.length===0)return null;r=t={annotationType:_t.FREETEXT,color:Array.from(u),fontSize:l,value:y.join(`
|
|
50
|
+
`),position:w,pageIndex:A-1,rect:h.slice(0),rotation:p,id:f,deleted:!1,popupRef:v}}const a=await super.deserialize(t,e,s);return a.#r=t.fontSize,a.#t=lt.makeHexColor(...t.color),a.#e=Qt.#f(t.value),a.annotationElementId=t.id||null,a._initialData=r,a}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=Qt._internalPadding*this.parentScale,s=this.getRect(e,e),r=pt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#t),a={annotationType:_t.FREETEXT,color:r,fontSize:this.#r,value:this.#h(),pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?a:this.annotationElementId&&!this.#o(a)?null:(a.id=this.annotationElementId,a)}#o(t){const{value:e,fontSize:s,color:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((l,u)=>l!==r[u])||t.pageIndex!==a}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:s}=e;s.fontSize=`calc(${this.#r}px * var(--scale-factor))`,s.color=this.#t,e.replaceChildren();for(const a of this.#e.split(`
|
|
51
|
+
`)){const l=document.createElement("div");l.append(a?document.createTextNode(a):document.createElement("br")),e.append(l)}const r=Qt._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(r,r),popupContent:this.#e}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class et{static PRECISION=1e-4;toSVGPath(){Lt("Abstract method `toSVGPath` must be implemented.")}get box(){Lt("Abstract getter `box` must be implemented.")}serialize(t,e){Lt("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,r,a,l){l||=new Float32Array(t.length);for(let u=0,h=t.length;u<h;u+=2)l[u]=e+t[u]*r,l[u+1]=s+t[u+1]*a;return l}static _rescaleAndSwap(t,e,s,r,a,l){l||=new Float32Array(t.length);for(let u=0,h=t.length;u<h;u+=2)l[u]=e+t[u+1]*r,l[u+1]=s+t[u]*a;return l}static _translate(t,e,s,r){r||=new Float32Array(t.length);for(let a=0,l=t.length;a<l;a+=2)r[a]=e+t[a],r[a+1]=s+t[a+1];return r}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,r,a){switch(a){case 90:return[1-e/s,t/r];case 180:return[1-t/s,1-e/r];case 270:return[e/s,1-t/r];default:return[t/s,e/r]}}static _normalizePagePoint(t,e,s){switch(s){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,s,r,a,l){return[(t+5*s)/6,(e+5*r)/6,(5*s+a)/6,(5*r+l)/6,(s+a)/2,(r+l)/2]}}class Qn{#t;#e=[];#n;#i;#r=[];#s=new Float32Array(18);#l;#a;#c;#u;#d;#h;#f=[];static#o=8;static#p=2;static#m=Qn.#o+Qn.#p;constructor({x:t,y:e},s,r,a,l,u=0){this.#t=s,this.#h=a*r,this.#i=l,this.#s.set([NaN,NaN,NaN,NaN,t,e],6),this.#n=u,this.#u=Qn.#o*r,this.#c=Qn.#m*r,this.#d=r,this.#f.push(t,e)}isEmpty(){return isNaN(this.#s[8])}#g(){const t=this.#s.subarray(4,6),e=this.#s.subarray(16,18),[s,r,a,l]=this.#t;return[(this.#l+(t[0]-e[0])/2-s)/a,(this.#a+(t[1]-e[1])/2-r)/l,(this.#l+(e[0]-t[0])/2-s)/a,(this.#a+(e[1]-t[1])/2-r)/l]}add({x:t,y:e}){this.#l=t,this.#a=e;const[s,r,a,l]=this.#t;let[u,h,p,f]=this.#s.subarray(8,12);const v=t-p,y=e-f,w=Math.hypot(v,y);if(w<this.#c)return!1;const A=w-this.#u,S=A/w,E=S*v,x=S*y;let M=u,I=h;u=p,h=f,p+=E,f+=x,this.#f?.push(t,e);const N=-x/A,O=E/A,H=N*this.#h,F=O*this.#h;return this.#s.set(this.#s.subarray(2,8),0),this.#s.set([p+H,f+F],4),this.#s.set(this.#s.subarray(14,18),12),this.#s.set([p-H,f-F],16),isNaN(this.#s[6])?(this.#r.length===0&&(this.#s.set([u+H,h+F],2),this.#r.push(NaN,NaN,NaN,NaN,(u+H-s)/a,(h+F-r)/l),this.#s.set([u-H,h-F],14),this.#e.push(NaN,NaN,NaN,NaN,(u-H-s)/a,(h-F-r)/l)),this.#s.set([M,I,u,h,p,f],6),!this.isEmpty()):(this.#s.set([M,I,u,h,p,f],6),Math.abs(Math.atan2(I-h,M-u)-Math.atan2(x,E))<Math.PI/2?([u,h,p,f]=this.#s.subarray(2,6),this.#r.push(NaN,NaN,NaN,NaN,((u+p)/2-s)/a,((h+f)/2-r)/l),[u,h,M,I]=this.#s.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((M+u)/2-s)/a,((I+h)/2-r)/l),!0):([M,I,u,h,p,f]=this.#s.subarray(0,6),this.#r.push(((M+5*u)/6-s)/a,((I+5*h)/6-r)/l,((5*u+p)/6-s)/a,((5*h+f)/6-r)/l,((u+p)/2-s)/a,((h+f)/2-r)/l),[p,f,u,h,M,I]=this.#s.subarray(12,18),this.#e.push(((M+5*u)/6-s)/a,((I+5*h)/6-r)/l,((5*u+p)/6-s)/a,((5*h+f)/6-r)/l,((u+p)/2-s)/a,((h+f)/2-r)/l),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#r,e=this.#e;if(isNaN(this.#s[6])&&!this.isEmpty())return this.#v();const s=[];s.push(`M${t[4]} ${t[5]}`);for(let r=6;r<t.length;r+=6)isNaN(t[r])?s.push(`L${t[r+4]} ${t[r+5]}`):s.push(`C${t[r]} ${t[r+1]} ${t[r+2]} ${t[r+3]} ${t[r+4]} ${t[r+5]}`);this.#y(s);for(let r=e.length-6;r>=6;r-=6)isNaN(e[r])?s.push(`L${e[r+4]} ${e[r+5]}`):s.push(`C${e[r]} ${e[r+1]} ${e[r+2]} ${e[r+3]} ${e[r+4]} ${e[r+5]}`);return this.#_(s),s.join(" ")}#v(){const[t,e,s,r]=this.#t,[a,l,u,h]=this.#g();return`M${(this.#s[2]-t)/s} ${(this.#s[3]-e)/r} L${(this.#s[4]-t)/s} ${(this.#s[5]-e)/r} L${a} ${l} L${u} ${h} L${(this.#s[16]-t)/s} ${(this.#s[17]-e)/r} L${(this.#s[14]-t)/s} ${(this.#s[15]-e)/r} Z`}#_(t){const e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#y(t){const[e,s,r,a]=this.#t,l=this.#s.subarray(4,6),u=this.#s.subarray(16,18),[h,p,f,v]=this.#g();t.push(`L${(l[0]-e)/r} ${(l[1]-s)/a} L${h} ${p} L${f} ${v} L${(u[0]-e)/r} ${(u[1]-s)/a}`)}newFreeDrawOutline(t,e,s,r,a,l){return new Dd(t,e,s,r,a,l)}getOutlines(){const t=this.#r,e=this.#e,s=this.#s,[r,a,l,u]=this.#t,h=new Float32Array((this.#f?.length??0)+2);for(let v=0,y=h.length-2;v<y;v+=2)h[v]=(this.#f[v]-r)/l,h[v+1]=(this.#f[v+1]-a)/u;if(h[h.length-2]=(this.#l-r)/l,h[h.length-1]=(this.#a-a)/u,isNaN(s[6])&&!this.isEmpty())return this.#A(h);const p=new Float32Array(this.#r.length+24+this.#e.length);let f=t.length;for(let v=0;v<f;v+=2){if(isNaN(t[v])){p[v]=p[v+1]=NaN;continue}p[v]=t[v],p[v+1]=t[v+1]}f=this.#x(p,f);for(let v=e.length-6;v>=6;v-=6)for(let y=0;y<6;y+=2){if(isNaN(e[v+y])){p[f]=p[f+1]=NaN,f+=2;continue}p[f]=e[v+y],p[f+1]=e[v+y+1],f+=2}return this.#b(p,f),this.newFreeDrawOutline(p,h,this.#t,this.#d,this.#n,this.#i)}#A(t){const e=this.#s,[s,r,a,l]=this.#t,[u,h,p,f]=this.#g(),v=new Float32Array(36);return v.set([NaN,NaN,NaN,NaN,(e[2]-s)/a,(e[3]-r)/l,NaN,NaN,NaN,NaN,(e[4]-s)/a,(e[5]-r)/l,NaN,NaN,NaN,NaN,u,h,NaN,NaN,NaN,NaN,p,f,NaN,NaN,NaN,NaN,(e[16]-s)/a,(e[17]-r)/l,NaN,NaN,NaN,NaN,(e[14]-s)/a,(e[15]-r)/l],0),this.newFreeDrawOutline(v,t,this.#t,this.#d,this.#n,this.#i)}#b(t,e){const s=this.#e;return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6}#x(t,e){const s=this.#s.subarray(4,6),r=this.#s.subarray(16,18),[a,l,u,h]=this.#t,[p,f,v,y]=this.#g();return t.set([NaN,NaN,NaN,NaN,(s[0]-a)/u,(s[1]-l)/h,NaN,NaN,NaN,NaN,p,f,NaN,NaN,NaN,NaN,v,y,NaN,NaN,NaN,NaN,(r[0]-a)/u,(r[1]-l)/h],e),e+=24}}class Dd extends et{#t;#e=new Float32Array(4);#n;#i;#r;#s;#l;constructor(t,e,s,r,a,l){super(),this.#l=t,this.#r=e,this.#t=s,this.#s=r,this.#n=a,this.#i=l,this.lastPoint=[NaN,NaN],this.#a(l);const[u,h,p,f]=this.#e;for(let v=0,y=t.length;v<y;v+=2)t[v]=(t[v]-u)/p,t[v+1]=(t[v+1]-h)/f;for(let v=0,y=e.length;v<y;v+=2)e[v]=(e[v]-u)/p,e[v+1]=(e[v+1]-h)/f}toSVGPath(){const t=[`M${this.#l[4]} ${this.#l[5]}`];for(let e=6,s=this.#l.length;e<s;e+=6){if(isNaN(this.#l[e])){t.push(`L${this.#l[e+4]} ${this.#l[e+5]}`);continue}t.push(`C${this.#l[e]} ${this.#l[e+1]} ${this.#l[e+2]} ${this.#l[e+3]} ${this.#l[e+4]} ${this.#l[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,r],a){const l=s-t,u=r-e;let h,p;switch(a){case 0:h=et._rescale(this.#l,t,r,l,-u),p=et._rescale(this.#r,t,r,l,-u);break;case 90:h=et._rescaleAndSwap(this.#l,t,e,l,u),p=et._rescaleAndSwap(this.#r,t,e,l,u);break;case 180:h=et._rescale(this.#l,s,e,-l,u),p=et._rescale(this.#r,s,e,-l,u);break;case 270:h=et._rescaleAndSwap(this.#l,s,r,-l,-u),p=et._rescaleAndSwap(this.#r,s,r,-l,-u);break}return{outline:Array.from(h),points:[Array.from(p)]}}#a(t){const e=this.#l;let s=e[4],r=e[5],a=s,l=r,u=s,h=r,p=s,f=r;const v=t?Math.max:Math.min;for(let w=6,A=e.length;w<A;w+=6){if(isNaN(e[w]))a=Math.min(a,e[w+4]),l=Math.min(l,e[w+5]),u=Math.max(u,e[w+4]),h=Math.max(h,e[w+5]),f<e[w+5]?(p=e[w+4],f=e[w+5]):f===e[w+5]&&(p=v(p,e[w+4]));else{const S=lt.bezierBoundingBox(s,r,...e.slice(w,w+6));a=Math.min(a,S[0]),l=Math.min(l,S[1]),u=Math.max(u,S[2]),h=Math.max(h,S[3]),f<S[3]?(p=S[2],f=S[3]):f===S[3]&&(p=v(p,S[2]))}s=e[w+4],r=e[w+5]}const y=this.#e;y[0]=a-this.#n,y[1]=l-this.#n,y[2]=u-a+2*this.#n,y[3]=h-l+2*this.#n,this.lastPoint=[p,f]}get box(){return this.#e}newOutliner(t,e,s,r,a,l=0){return new Qn(t,e,s,r,a,l)}getNewOutline(t,e){const[s,r,a,l]=this.#e,[u,h,p,f]=this.#t,v=a*p,y=l*f,w=s*p+u,A=r*f+h,S=this.newOutliner({x:this.#r[0]*v+w,y:this.#r[1]*y+A},this.#t,this.#s,t,this.#i,e??this.#n);for(let E=2;E<this.#r.length;E+=2)S.add({x:this.#r[E]*v+w,y:this.#r[E+1]*y+A});return S.getOutlines()}}class yl{#t;#e;#n=[];#i=[];constructor(t,e=0,s=0,r=!0){let a=1/0,l=-1/0,u=1/0,h=-1/0;const p=10**-4;for(const{x:E,y:x,width:M,height:I}of t){const N=Math.floor((E-e)/p)*p,O=Math.ceil((E+M+e)/p)*p,H=Math.floor((x-e)/p)*p,F=Math.ceil((x+I+e)/p)*p,G=[N,H,F,!0],Y=[O,H,F,!1];this.#n.push(G,Y),a=Math.min(a,N),l=Math.max(l,O),u=Math.min(u,H),h=Math.max(h,F)}const f=l-a+2*s,v=h-u+2*s,y=a-s,w=u-s,A=this.#n.at(r?-1:-2),S=[A[0],A[2]];for(const E of this.#n){const[x,M,I]=E;E[0]=(x-y)/f,E[1]=(M-w)/v,E[2]=(I-w)/v}this.#t=new Float32Array([y,w,f,v]),this.#e=S}getOutlines(){this.#n.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of this.#n)e[3]?(t.push(...this.#c(e)),this.#l(e)):(this.#a(e),t.push(...this.#c(e)));return this.#r(t)}#r(t){const e=[],s=new Set;for(const l of t){const[u,h,p]=l;e.push([u,h,l],[u,p,l])}e.sort((l,u)=>l[1]-u[1]||l[0]-u[0]);for(let l=0,u=e.length;l<u;l+=2){const h=e[l][2],p=e[l+1][2];h.push(p),p.push(h),s.add(h),s.add(p)}const r=[];let a;for(;s.size>0;){const l=s.values().next().value;let[u,h,p,f,v]=l;s.delete(l);let y=u,w=h;for(a=[u,p],r.push(a);;){let A;if(s.has(f))A=f;else if(s.has(v))A=v;else break;s.delete(A),[u,h,p,f,v]=A,y!==u&&(a.push(y,w,u,w===h?h:p),y=u),w=w===h?p:h}a.push(y,w)}return new Bm(r,this.#t,this.#e)}#s(t){const e=this.#i;let s=0,r=e.length-1;for(;s<=r;){const a=s+r>>1,l=e[a][0];if(l===t)return a;l<t?s=a+1:r=a-1}return r+1}#l([,t,e]){const s=this.#s(t);this.#i.splice(s,0,[t,e])}#a([,t,e]){const s=this.#s(t);for(let r=s;r<this.#i.length;r++){const[a,l]=this.#i[r];if(a!==t)break;if(a===t&&l===e){this.#i.splice(r,1);return}}for(let r=s-1;r>=0;r--){const[a,l]=this.#i[r];if(a!==t)break;if(a===t&&l===e){this.#i.splice(r,1);return}}}#c(t){const[e,s,r]=t,a=[[e,s,r]],l=this.#s(r);for(let u=0;u<l;u++){const[h,p]=this.#i[u];for(let f=0,v=a.length;f<v;f++){const[,y,w]=a[f];if(!(p<=y||w<=h)){if(y>=h){if(w>p)a[f][1]=p;else{if(v===1)return[];a.splice(f,1),f--,v--}continue}a[f][2]=h,w>p&&a.push([e,p,w])}}}return a}}class Bm extends et{#t;#e;constructor(t,e,s){super(),this.#e=t,this.#t=e,this.lastPoint=s}toSVGPath(){const t=[];for(const e of this.#e){let[s,r]=e;t.push(`M${s} ${r}`);for(let a=2;a<e.length;a+=2){const l=e[a],u=e[a+1];l===s?(t.push(`V${u}`),r=u):u===r&&(t.push(`H${l}`),s=l)}t.push("Z")}return t.join(" ")}serialize([t,e,s,r],a){const l=[],u=s-t,h=r-e;for(const p of this.#e){const f=new Array(p.length);for(let v=0;v<p.length;v+=2)f[v]=t+p[v]*u,f[v+1]=r-p[v+1]*h;l.push(f)}return l}get box(){return this.#t}get classNamesForOutlining(){return["highlightOutline"]}}class wl extends Qn{newFreeDrawOutline(t,e,s,r,a,l){return new Hm(t,e,s,r,a,l)}}class Hm extends Dd{newOutliner(t,e,s,r,a,l=0){return new wl(t,e,s,r,a,l)}}class je{#t=null;#e=null;#n;#i=null;#r=!1;#s=!1;#l=null;#a;#c=null;#u=null;#d;static#h=null;static get _keyboardManager(){return bt(this,"_keyboardManager",new Ts([[["Escape","mac+Escape"],je.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],je.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],je.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],je.prototype._moveToPrevious],[["Home","mac+Home"],je.prototype._moveToBeginning],[["End","mac+End"],je.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#s=!1,this.#d=xt.HIGHLIGHT_COLOR,this.#l=t):(this.#s=!0,this.#d=xt.HIGHLIGHT_DEFAULT_COLOR),this.#u=t?._uiManager||e,this.#a=this.#u._eventBus,this.#n=t?.color||this.#u?.highlightColors.values().next().value||"#FFFF98",je.#h||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const t=this.#t=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#u._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#p.bind(this),{signal:e});const s=this.#e=document.createElement("span");return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=this.#n,t.append(s),t}renderMainDropdown(){const t=this.#i=this.#f();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#f(){const t=document.createElement("div"),e=this.#u._signal;t.addEventListener("contextmenu",qe,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,r]of this.#u.highlightColors){const a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",r),a.title=s,a.setAttribute("data-l10n-id",je.#h[s]);const l=document.createElement("span");a.append(l),l.className="swatch",l.style.backgroundColor=r,a.setAttribute("aria-selected",r===this.#n),a.addEventListener("click",this.#o.bind(this,r),{signal:e}),t.append(a)}return t.addEventListener("keydown",this.#p.bind(this),{signal:e}),t}#o(t,e){e.stopPropagation(),this.#a.dispatch("switchannotationeditorparams",{source:this,type:this.#d,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}const e=t.target.getAttribute("data-color");e&&this.#o(e,t)}_moveToNext(t){if(!this.#v){this.#m(t);return}if(t.target===this.#t){this.#i.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#i?.firstChild||t.target===this.#t){this.#v&&this._hideDropdownFromKeyboard();return}this.#v||this.#m(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#v){this.#m(t);return}this.#i.firstChild?.focus()}_moveToEnd(t){if(!this.#v){this.#m(t);return}this.#i.lastChild?.focus()}#p(t){je._keyboardManager.exec(this,t)}#m(t){if(this.#v){this.hideDropdown();return}if(this.#r=t.detail===0,this.#c||(this.#c=new AbortController,window.addEventListener("pointerdown",this.#g.bind(this),{signal:this.#u.combinedSignal(this.#c)})),this.#i){this.#i.classList.remove("hidden");return}const e=this.#i=this.#f();this.#t.append(e)}#g(t){this.#i?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#i?.classList.add("hidden"),this.#c?.abort(),this.#c=null}get#v(){return this.#i&&!this.#i.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#s){if(!this.#v){this.#l?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#r})}}updateColor(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#i)return;const e=this.#u.highlightColors.values();for(const s of this.#i.children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#i?.remove(),this.#i=null}}class $t extends pt{#t=null;#e=0;#n;#i=null;#r=null;#s=null;#l=null;#a=0;#c=null;#u=null;#d=null;#h=!1;#f=null;#o;#p=null;#m="";#g;#v="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=_t.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=$t.prototype;return bt(this,"_keyboardManager",new Ts([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||$t._defaultColor,this.#g=t.thickness||$t._defaultThickness,this.#o=t.opacity||$t._defaultOpacity,this.#n=t.boxes||null,this.#v=t.methodOfCreation||"",this.#m=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#h=!0,this.#y(t),this.#P()):this.#n&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#l=t.focusNode,this.#a=t.focusOffset,this.#_(),this.#P(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#h?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#g,methodOfCreation:this.#v}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#_(){const t=new yl(this.#n,.001);this.#u=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#u.box;const e=new yl(this.#n,.0025,.001,this._uiManager.direction==="ltr");this.#s=e.getOutlines();const{lastPoint:s}=this.#s;this.#f=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#y({highlightOutlines:t,highlightId:e,clipPathId:s}){this.#u=t;const r=1.5;if(this.#s=t.getNewOutline(this.#g/2+r,.0025),e>=0)this.#d=e,this.#i=s,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#p=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#s.box,path:{d:this.#s.toSVGPath()}},!0);else if(this.parent){const f=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#d,{bbox:$t.#S(this.#u.box,(f-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#p,{bbox:$t.#S(this.#s.box,f),path:{d:this.#s.toSVGPath()}})}const[a,l,u,h]=t.box;switch(this.rotation){case 0:this.x=a,this.y=l,this.width=u,this.height=h;break;case 90:{const[f,v]=this.parentDimensions;this.x=l,this.y=1-a,this.width=u*v/f,this.height=h*f/v;break}case 180:this.x=1-a,this.y=1-l,this.width=u,this.height=h;break;case 270:{const[f,v]=this.parentDimensions;this.x=1-l,this.y=a,this.width=u*v/f,this.height=h*f/v;break}}const{lastPoint:p}=this.#s;this.#f=[(p[0]-a)/u,(p[1]-l)/h]}static initialize(t,e){pt.initialize(t,e),$t._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case xt.HIGHLIGHT_DEFAULT_COLOR:$t._defaultColor=e;break;case xt.HIGHLIGHT_THICKNESS:$t._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#f}updateParams(t,e){switch(t){case xt.HIGHLIGHT_COLOR:this.#A(e);break;case xt.HIGHLIGHT_THICKNESS:this.#b(e);break}}static get defaultPropertiesToUpdate(){return[[xt.HIGHLIGHT_DEFAULT_COLOR,$t._defaultColor],[xt.HIGHLIGHT_THICKNESS,$t._defaultThickness]]}get propertiesToUpdate(){return[[xt.HIGHLIGHT_COLOR,this.color||$t._defaultColor],[xt.HIGHLIGHT_THICKNESS,this.#g||$t._defaultThickness],[xt.HIGHLIGHT_FREE,this.#h]]}#A(t){const e=(a,l)=>{this.color=a,this.#o=l,this.parent?.drawLayer.updateProperties(this.#d,{root:{fill:a,"fill-opacity":l}}),this.#r?.updateColor(a)},s=this.color,r=this.#o;this.addCommands({cmd:e.bind(this,t,$t._defaultOpacity),undo:e.bind(this,s,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:xt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#b(t){const e=this.#g,s=r=>{this.#g=r,this.#x(r)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:xt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#r=new je({editor:this}),t.addColorPicker(this.#r)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#M())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#M())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#k(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#P(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#k():t&&(this.#P(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#x(t){if(!this.#h)return;this.#y({highlightOutlines:this.#u.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)}#k(){this.#d===null||!this.parent||(this.parent.drawLayer.remove(this.#d),this.#d=null,this.parent.drawLayer.remove(this.#p),this.#p=null)}#P(t=this.parent){this.#d===null&&({id:this.#d,clipPathId:this.#i}=t.drawLayer.draw({bbox:this.#u.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#o},rootClass:{highlight:!0,free:this.#h},path:{d:this.#u.toSVGPath()}},!1,!0),this.#p=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#h},bbox:this.#s.box,path:{d:this.#s.toSVGPath()}},this.#h),this.#c&&(this.#c.style.clipPath=this.#i))}static#S([t,e,s,r],a){switch(a){case 90:return[1-e-r,t,r,s];case 180:return[1-t-s,1-e-r,s,r];case 270:return[e,1-t-s,r,s]}return[t,e,s,r]}rotate(t){const{drawLayer:e}=this.parent;let s;this.#h?(t=(t-this.rotation+360)%360,s=$t.#S(this.#u.box,t)):s=$t.#S([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#d,{bbox:s,root:{"data-main-rotation":t}}),e.updateProperties(this.#p,{bbox:$t.#S(this.#s.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#m&&(t.setAttribute("aria-label",this.#m),t.setAttribute("role","mark")),this.#h?t.classList.add("free"):this.div.addEventListener("keydown",this.#T.bind(this),{signal:this._uiManager._signal});const e=this.#c=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#i;const[s,r]=this.parentDimensions;return this.setDims(this.width*s,this.height*r),Xr(this,this.#c,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1}})}#T(t){$t._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#C(!0);break;case 1:case 3:this.#C(!1);break}}#C(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#l,this.#a)}select(){super.select(),this.#p&&this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#p&&(this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{selected:!1}}),this.#h||this.#C(!1))}get _mustFixPosition(){return!this.#h}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#d,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#p,{rootClass:{hidden:!t}}))}#M(){return this.#h?this.rotation:0}#N(){if(this.#h)return null;const[t,e]=this.pageDimensions,[s,r]=this.pageTranslation,a=this.#n,l=new Float32Array(a.length*8);let u=0;for(const{x:h,y:p,width:f,height:v}of a){const y=h*t+s,w=(1-p)*e+r;l[u]=l[u+4]=y,l[u+1]=l[u+3]=w,l[u+2]=l[u+6]=y+f*t,l[u+5]=l[u+7]=w-v*e,u+=8}return l}#F(t){return this.#u.serialize(t,this.#M())}static startHighlighting(t,e,{target:s,x:r,y:a}){const{x:l,y:u,width:h,height:p}=s.getBoundingClientRect(),f=new AbortController,v=t.combinedSignal(f),y=w=>{f.abort(),this.#w(t,w)};window.addEventListener("blur",y,{signal:v}),window.addEventListener("pointerup",y,{signal:v}),window.addEventListener("pointerdown",Me,{capture:!0,passive:!1,signal:v}),window.addEventListener("contextmenu",qe,{signal:v}),s.addEventListener("pointermove",this.#E.bind(this,t),{signal:v}),this._freeHighlight=new wl({x:r,y:a},[l,u,h,p],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#E(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#w(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,s){let r=null;if(t instanceof Id){const{data:{quadPoints:A,rect:S,rotation:E,id:x,color:M,opacity:I,popupRef:N},parent:{page:{pageNumber:O}}}=t;r=t={annotationType:_t.HIGHLIGHT,color:Array.from(M),opacity:I,quadPoints:A,boxes:null,pageIndex:O-1,rect:S.slice(0),rotation:E,id:x,deleted:!1,popupRef:N}}else if(t instanceof Nl){const{data:{inkLists:A,rect:S,rotation:E,id:x,color:M,borderStyle:{rawWidth:I},popupRef:N},parent:{page:{pageNumber:O}}}=t;r=t={annotationType:_t.HIGHLIGHT,color:Array.from(M),thickness:I,inkLists:A,boxes:null,pageIndex:O-1,rect:S.slice(0),rotation:E,id:x,deleted:!1,popupRef:N}}const{color:a,quadPoints:l,inkLists:u,opacity:h}=t,p=await super.deserialize(t,e,s);p.color=lt.makeHexColor(...a),p.#o=h||1,u&&(p.#g=t.thickness),p.annotationElementId=t.id||null,p._initialData=r;const[f,v]=p.pageDimensions,[y,w]=p.pageTranslation;if(l){const A=p.#n=[];for(let S=0;S<l.length;S+=8)A.push({x:(l[S]-y)/f,y:1-(l[S+1]-w)/v,width:(l[S+2]-l[S])/f,height:(l[S+1]-l[S+5])/v});p.#_(),p.#P(),p.rotate(p.rotation)}else if(u){p.#h=!0;const A=u[0],S={x:A[0]-y,y:v-(A[1]-w)},E=new wl(S,[0,0,f,v],1,p.#g/2,!0,.001);for(let I=0,N=A.length;I<N;I+=2)S.x=A[I]-y,S.y=v-(A[I+1]-w),E.add(S);const{id:x,clipPathId:M}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:p.color,"fill-opacity":p._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:E.toSVGPath()}},!0,!0);p.#y({highlightOutlines:E.getOutlines(),highlightId:x,clipPathId:M}),p.#P()}return p}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),s=pt._colorManager.convert(this.color),r={annotationType:_t.HIGHLIGHT,color:s,opacity:this.#o,thickness:this.#g,quadPoints:this.#N(),outlines:this.#F(e),pageIndex:this.pageIndex,rect:e,rotation:this.#M(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#I(r)?null:(r.id=this.annotationElementId,r)}#I(t){const{color:e}=this._initialData;return t.color.some((s,r)=>s!==e[r])}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class Um{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))this.updateProperty(e,s)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){const t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){Lt("Not implemented")}}class ft extends pt{#t=null;#e;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#n=null;static#i=null;static#r=null;static#s=NaN;static#l=null;static#a=null;static#c=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,t.drawOutlines&&(this.#u(t),this.#f())}#u({drawOutlines:t,drawId:e,drawingOptions:s}){this.#t=t,this._drawingOptions||=s,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#d(t,this.parent),this.#m(t.box)}#d(t,e){const{id:s}=e.drawLayer.draw(ft._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return s}static _mergeSVGProperties(t,e){const s=new Set(Object.keys(t));for(const[r,a]of Object.entries(e))s.has(r)?Object.assign(t[r],a):t[r]=a;return t}static getDefaultDrawingOptions(t){Lt("Not implemented")}static get typesMap(){Lt("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const s=this.typesMap.get(t);s&&this._defaultDrawingOptions.updateProperty(s,e),this._currentParent&&(ft.#n.updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const s=this.constructor.typesMap.get(t);s&&this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[s,r]of this.typesMap)t.push([s,e[r]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[s,r]of this.constructor.typesMap)t.push([s,e[r]]);return t}_updateProperty(t,e,s){const r=this._drawingOptions,a=r[e],l=u=>{r.updateProperty(e,u);const h=this.#t.updateProperty(e,u);h&&this.#m(h),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties())};this.addCommands({cmd:l.bind(this,s),undo:l.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,ft._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#p()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,ft._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#p()),{bbox:this.#g()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,ft._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#g()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#h(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#f(),this.#m(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#h()):t&&(this._uiManager.addShouldRescale(this),this.#f(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#h(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#f(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#d(this.#t,t)}}#o([t,e,s,r]){const{parentDimensions:[a,l],rotation:u}=this;switch(u){case 90:return[e,1-t,s*(l/a),r*(a/l)];case 180:return[1-t,1-e,s,r];case 270:return[1-e,t,s*(l/a),r*(a/l)];default:return[t,e,s,r]}}#p(){const{x:t,y:e,width:s,height:r,parentDimensions:[a,l],rotation:u}=this;switch(u){case 90:return[1-e,t,s*(a/l),r*(l/a)];case 180:return[1-t,1-e,s,r];case 270:return[e,1-t,s*(a/l),r*(l/a)];default:return[t,e,s,r]}}#m(t){if([this.x,this.y,this.width,this.height]=this.#o(t),this.div){this.fixAndSetPosition();const[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)}this._onResized()}#g(){const{x:t,y:e,width:s,height:r,rotation:a,parentRotation:l,parentDimensions:[u,h]}=this;switch((a*4+l)/90){case 1:return[1-e-r,t,r,s];case 2:return[1-t-s,1-e-r,s,r];case 3:return[e,1-t-s,r,s];case 4:return[t,e-s*(u/h),r*(h/u),s*(u/h)];case 5:return[1-e,t,s*(u/h),r*(h/u)];case 6:return[1-t-r*(h/u),1-e,r*(h/u),s*(u/h)];case 7:return[e-s*(u/h),1-t-r*(h/u),s*(u/h),r*(h/u)];case 8:return[t-s,e-r,s,r];case 9:return[1-e,t-s,r,s];case 10:return[1-t,1-e,s,r];case 11:return[e-r,1-t,r,s];case 12:return[t-r*(h/u),e,r*(h/u),s*(u/h)];case 13:return[1-e-s*(u/h),t-r*(h/u),s*(u/h),r*(h/u)];case 14:return[1-t,1-e-s*(u/h),r*(h/u),s*(u/h)];case 15:return[e,1-t,s*(u/h),r*(h/u)];default:return[t,e,s,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,ft._mergeSVGProperties({bbox:this.#g()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#m(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const t=super.render();t.classList.add("draw");const e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";const[s,r]=this.parentDimensions;return this.setDims(this.width*s,this.height*r),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,s,r,a){Lt("Not implemented")}static startDrawing(t,e,s,r){const{target:a,offsetX:l,offsetY:u,pointerId:h,pointerType:p}=r;if(ft.#l&&ft.#l!==p)return;const{viewport:{rotation:f}}=t,{width:v,height:y}=a.getBoundingClientRect(),w=ft.#i=new AbortController,A=t.combinedSignal(w);if(ft.#s||=h,ft.#l??=p,window.addEventListener("pointerup",S=>{ft.#s===S.pointerId?this._endDraw(S):ft.#a?.delete(S.pointerId)},{signal:A}),window.addEventListener("pointercancel",S=>{ft.#s===S.pointerId?this._currentParent.endDrawingSession():ft.#a?.delete(S.pointerId)},{signal:A}),window.addEventListener("pointerdown",S=>{ft.#l===S.pointerType&&((ft.#a||=new Set).add(S.pointerId),ft.#n.isCancellable()&&(ft.#n.removeLastElement(),ft.#n.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:A}),window.addEventListener("contextmenu",qe,{signal:A}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:A}),a.addEventListener("touchmove",S=>{S.timeStamp===ft.#c&&Me(S)},{signal:A}),t.toggleDrawing(),e._editorUndoBar?.hide(),ft.#n){t.drawLayer.updateProperties(this._currentDrawId,ft.#n.startNew(l,u,v,y,f));return}e.updateUIForDefaultProperties(this),ft.#n=this.createDrawerInstance(l,u,v,y,f),ft.#r=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(ft.#r.toSVGProperties(),ft.#n.defaultSVGProperties),!0,!1)}static _drawMove(t){if(ft.#c=-1,!ft.#n)return;const{offsetX:e,offsetY:s,pointerId:r}=t;if(ft.#s===r){if(ft.#a?.size>=1){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,ft.#n.add(e,s)),ft.#c=t.timeStamp,Me(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,ft.#n=null,ft.#r=null,ft.#l=null,ft.#c=NaN),ft.#i&&(ft.#i.abort(),ft.#i=null,ft.#s=NaN,ft.#a=null)}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,ft.#n.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const s=ft.#n,r=this._currentDrawId,a=s.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(r,s.setLastElement(a))},undo:()=>{e.drawLayer.updateProperties(r,s.removeLastElement())},mustExec:!1,type:xt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(xt.DRAW_STEP),!ft.#n.isEmpty()){const{pageDimensions:[s,r],scale:a}=e,l=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:ft.#n.getOutlines(s*a,r*a,a,this._INNER_MARGIN),drawingOptions:ft.#r,mustBeCommitted:!t});return this._cleanup(!0),l}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,r,a,l){Lt("Not implemented")}static async deserialize(t,e,s){const{rawDims:{pageWidth:r,pageHeight:a,pageX:l,pageY:u}}=e.viewport,h=this.deserializeDraw(l,u,r,a,this._INNER_MARGIN,t),p=await super.deserialize(t,e,s);return p.createDrawingOptions(t),p.#u({drawOutlines:h}),p.#f(),p.onScaleChanging(),p.rotate(),p}serializeDraw(t){const[e,s]=this.pageTranslation,[r,a]=this.pageDimensions;return this.#t.serialize([e,s,r,a],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class $m{#t=new Float64Array(6);#e;#n;#i;#r;#s;#l="";#a=0;#c=new so;#u;#d;constructor(t,e,s,r,a,l){this.#u=s,this.#d=r,this.#i=a,this.#r=l,[t,e]=this.#h(t,e);const u=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#s=[t,e],this.#n=[{line:u,points:this.#s}],this.#t.set(u,0)}updateProperty(t,e){t==="stroke-width"&&(this.#r=e)}#h(t,e){return et._normalizePoint(t,e,this.#u,this.#d,this.#i)}isEmpty(){return!this.#n||this.#n.length===0}isCancellable(){return this.#s.length<=10}add(t,e){[t,e]=this.#h(t,e);const[s,r,a,l]=this.#t.subarray(2,6),u=t-a,h=e-l;return Math.hypot(this.#u*u,this.#d*h)<=2?null:(this.#s.push(t,e),isNaN(s)?(this.#t.set([a,l,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([s,r,a,l,t,e],0),this.#e.push(...et.createBezierPoints(s,r,a,l,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(this.#s.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,r,a){this.#u=s,this.#d=r,this.#i=a,[t,e]=this.#h(t,e);const l=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#s=[t,e];const u=this.#n.at(-1);return u&&(u.line=new Float32Array(u.line),u.points=new Float32Array(u.points)),this.#n.push({line:l,points:this.#s}),this.#t.set(l,0),this.#a=0,this.toSVGPath(),null}getLastElement(){return this.#n.at(-1)}setLastElement(t){return this.#n?(this.#n.push(t),this.#e=t.line,this.#s=t.points,this.#a=0,{path:{d:this.toSVGPath()}}):this.#c.setLastElement(t)}removeLastElement(){if(!this.#n)return this.#c.removeLastElement();this.#n.pop(),this.#l="";for(let t=0,e=this.#n.length;t<e;t++){const{line:s,points:r}=this.#n[t];this.#e=s,this.#s=r,this.#a=0,this.toSVGPath()}return{path:{d:this.#l}}}toSVGPath(){const t=et.svgRound(this.#e[4]),e=et.svgRound(this.#e[5]);if(this.#s.length===2)return this.#l=`${this.#l} M ${t} ${e} Z`,this.#l;if(this.#s.length<=6){const r=this.#l.lastIndexOf("M");this.#l=`${this.#l.slice(0,r)} M ${t} ${e}`,this.#a=6}if(this.#s.length===4){const r=et.svgRound(this.#e[10]),a=et.svgRound(this.#e[11]);return this.#l=`${this.#l} L ${r} ${a}`,this.#a=12,this.#l}const s=[];this.#a===0&&(s.push(`M ${t} ${e}`),this.#a=6);for(let r=this.#a,a=this.#e.length;r<a;r+=6){const[l,u,h,p,f,v]=this.#e.slice(r,r+6).map(et.svgRound);s.push(`C${l} ${u} ${h} ${p} ${f} ${v}`)}return this.#l+=s.join(" "),this.#a=this.#e.length,this.#l}getOutlines(t,e,s,r){const a=this.#n.at(-1);return a.line=new Float32Array(a.line),a.points=new Float32Array(a.points),this.#c.build(this.#n,t,e,s,this.#i,this.#r,r),this.#t=null,this.#e=null,this.#n=null,this.#l=null,this.#c}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class so extends et{#t;#e=0;#n;#i;#r;#s;#l;#a;#c;build(t,e,s,r,a,l,u){this.#r=e,this.#s=s,this.#l=r,this.#a=a,this.#c=l,this.#n=u??0,this.#i=t,this.#h()}setLastElement(t){return this.#i.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#i.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#i){if(t.push(`M${et.svgRound(e[4])} ${et.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12){t.push(`L${et.svgRound(e[10])} ${et.svgRound(e[11])}`);continue}for(let s=6,r=e.length;s<r;s+=6){const[a,l,u,h,p,f]=e.subarray(s,s+6).map(et.svgRound);t.push(`C${a} ${l} ${u} ${h} ${p} ${f}`)}}return t.join("")}serialize([t,e,s,r],a){const l=[],u=[],[h,p,f,v]=this.#d();let y,w,A,S,E,x,M,I,N;switch(this.#a){case 0:N=et._rescale,y=t,w=e+r,A=s,S=-r,E=t+h*s,x=e+(1-p-v)*r,M=t+(h+f)*s,I=e+(1-p)*r;break;case 90:N=et._rescaleAndSwap,y=t,w=e,A=s,S=r,E=t+p*s,x=e+h*r,M=t+(p+v)*s,I=e+(h+f)*r;break;case 180:N=et._rescale,y=t+s,w=e,A=-s,S=r,E=t+(1-h-f)*s,x=e+p*r,M=t+(1-h)*s,I=e+(p+v)*r;break;case 270:N=et._rescaleAndSwap,y=t+s,w=e+r,A=-s,S=-r,E=t+(1-p-v)*s,x=e+(1-h-f)*r,M=t+(1-p)*s,I=e+(1-h)*r;break}for(const{line:O,points:H}of this.#i)l.push(N(O,y,w,A,S,a?new Array(O.length):null)),u.push(N(H,y,w,A,S,a?new Array(H.length):null));return{lines:l,points:u,rect:[E,x,M,I]}}static deserialize(t,e,s,r,a,{paths:{lines:l,points:u},rotation:h,thickness:p}){const f=[];let v,y,w,A,S;switch(h){case 0:S=et._rescale,v=-t/s,y=e/r+1,w=1/s,A=-1/r;break;case 90:S=et._rescaleAndSwap,v=-e/r,y=-t/s,w=1/r,A=1/s;break;case 180:S=et._rescale,v=t/s+1,y=-e/r,w=-1/s,A=1/r;break;case 270:S=et._rescaleAndSwap,v=e/r+1,y=t/s+1,w=-1/r,A=-1/s;break}if(!l){l=[];for(const x of u){const M=x.length;if(M===2){l.push(new Float32Array([NaN,NaN,NaN,NaN,x[0],x[1]]));continue}if(M===4){l.push(new Float32Array([NaN,NaN,NaN,NaN,x[0],x[1],NaN,NaN,NaN,NaN,x[2],x[3]]));continue}const I=new Float32Array(3*(M-2));l.push(I);let[N,O,H,F]=x.subarray(0,4);I.set([NaN,NaN,NaN,NaN,N,O],0);for(let G=4;G<M;G+=2){const Y=x[G],$=x[G+1];I.set(et.createBezierPoints(N,O,H,F,Y,$),(G-2)*3),[N,O,H,F]=[H,F,Y,$]}}}for(let x=0,M=l.length;x<M;x++)f.push({line:S(l[x].map(I=>I??NaN),v,y,w,A),points:S(u[x].map(I=>I??NaN),v,y,w,A)});const E=new so;return E.build(f,s,r,1,h,p,a),E}#u(t=this.#c){const e=this.#n+t/2*this.#l;return this.#a%180===0?[e/this.#r,e/this.#s]:[e/this.#s,e/this.#r]}#d(){const[t,e,s,r]=this.#t,[a,l]=this.#u(0);return[t+a,e+l,s-2*a,r-2*l]}#h(){const t=this.#t=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:r}of this.#i){if(r.length<=12){for(let u=4,h=r.length;u<h;u+=6){const[p,f]=r.subarray(u,u+2);t[0]=Math.min(t[0],p),t[1]=Math.min(t[1],f),t[2]=Math.max(t[2],p),t[3]=Math.max(t[3],f)}continue}let a=r[4],l=r[5];for(let u=6,h=r.length;u<h;u+=6){const[p,f,v,y,w,A]=r.subarray(u,u+6);lt.bezierBoundingBox(a,l,p,f,v,y,w,A,t),a=w,l=A}}const[e,s]=this.#u();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-s)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+s)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){const[e,s]=this.#u();this.#c=t;const[r,a]=this.#u(),[l,u]=[r-e,a-s],h=this.#t;return h[0]-=l,h[1]-=u,h[2]+=2*l,h[3]+=2*u,h}updateParentDimensions([t,e],s){const[r,a]=this.#u();this.#r=t,this.#s=e,this.#l=s;const[l,u]=this.#u(),h=l-r,p=u-a,f=this.#t;return f[0]-=h,f[1]-=p,f[2]+=2*h,f[3]+=2*p,f}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(et.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${et.svgRound(t)} ${et.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#t;let s=0,r=0,a=0,l=0,u=0,h=0;switch(this.#e){case 90:r=e/t,a=-t/e,u=t;break;case 180:s=-1,l=-1,u=t,h=e;break;case 270:r=-e/t,a=t/e,h=e;break;default:return""}return`matrix(${s} ${r} ${a} ${l} ${et.svgRound(u)} ${et.svgRound(h)})`}getPathResizingSVGProperties([t,e,s,r]){const[a,l]=this.#u(),[u,h,p,f]=this.#t;if(Math.abs(p-a)<=et.PRECISION||Math.abs(f-l)<=et.PRECISION){const S=t+s/2-(u+p/2),E=e+r/2-(h+f/2);return{path:{"transform-origin":`${et.svgRound(t)} ${et.svgRound(e)}`,transform:`${this.rotationTransform} translate(${S} ${E})`}}}const v=(s-2*a)/(p-2*a),y=(r-2*l)/(f-2*l),w=p/s,A=f/r;return{path:{"transform-origin":`${et.svgRound(u)} ${et.svgRound(h)}`,transform:`${this.rotationTransform} scale(${w} ${A}) translate(${et.svgRound(a)} ${et.svgRound(l)}) scale(${v} ${y}) translate(${et.svgRound(-a)} ${et.svgRound(-l)})`}}}getPathResizedSVGProperties([t,e,s,r]){const[a,l]=this.#u(),u=this.#t,[h,p,f,v]=u;if(u[0]=t,u[1]=e,u[2]=s,u[3]=r,Math.abs(f-a)<=et.PRECISION||Math.abs(v-l)<=et.PRECISION){const E=t+s/2-(h+f/2),x=e+r/2-(p+v/2);for(const{line:M,points:I}of this.#i)et._translate(M,E,x,M),et._translate(I,E,x,I);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${et.svgRound(t)} ${et.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const y=(s-2*a)/(f-2*a),w=(r-2*l)/(v-2*l),A=-y*(h+a)+t+a,S=-w*(p+l)+e+l;if(y!==1||w!==1||A!==0||S!==0)for(const{line:E,points:x}of this.#i)et._rescale(E,A,S,y,w,E),et._rescale(x,A,S,y,w,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${et.svgRound(t)} ${et.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){const[r,a]=s,l=this.#t,u=t-l[0],h=e-l[1];if(this.#r===r&&this.#s===a)for(const{line:p,points:f}of this.#i)et._translate(p,u,h,p),et._translate(f,u,h,f);else{const p=this.#r/r,f=this.#s/a;this.#r=r,this.#s=a;for(const{line:v,points:y}of this.#i)et._rescale(v,u,h,p,f,v),et._rescale(y,u,h,p,f,y);l[2]*=p,l[3]*=f}return l[0]=t,l[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${et.svgRound(t)} ${et.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${et.svgRound(t[0])} ${et.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Dl extends Um{#t;constructor(t){super(),this.#t=t,super.updateProperties({fill:"none",stroke:pt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this.#t.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Dl(this.#t);return t.updateAll(this),t}}class Fl extends ft{static _type="ink";static _editorType=_t.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){pt.initialize(t,e),this._defaultDrawingOptions=new Dl(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return bt(this,"typesMap",new Map([[xt.INK_THICKNESS,"stroke-width"],[xt.INK_COLOR,"stroke"],[xt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,s,r,a){return new $m(t,e,s,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,r,a,l){return so.deserialize(t,e,s,r,a,l)}static async deserialize(t,e,s){let r=null;if(t instanceof Nl){const{data:{inkLists:l,rect:u,rotation:h,id:p,color:f,opacity:v,borderStyle:{rawWidth:y},popupRef:w},parent:{page:{pageNumber:A}}}=t;r=t={annotationType:_t.INK,color:Array.from(f),thickness:y,opacity:v,paths:{points:l},boxes:null,pageIndex:A-1,rect:u.slice(0),rotation:h,id:p,deleted:!1,popupRef:w}}const a=await super.deserialize(t,e,s);return a.annotationElementId=t.id||null,a._initialData=r,a}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:s}=this;e.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:s}){this._drawingOptions=Fl.getDefaultDrawingOptions({stroke:lt.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:s,rect:r}=this.serializeDraw(t),{_drawingOptions:{stroke:a,"stroke-opacity":l,"stroke-width":u}}=this,h={annotationType:_t.INK,color:pt._colorManager.convert(a),opacity:l,thickness:u,paths:{lines:e,points:s},pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?h:this.annotationElementId&&!this.#t(h)?null:(h.id=this.annotationElementId,h)}#t(t){const{color:e,thickness:s,opacity:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((l,u)=>l!==e[u])||t.thickness!==s||t.opacity!==r||t.pageIndex!==a}renderAnnotationElement(t){const{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class Ol extends pt{#t=null;#e=null;#n=null;#i=null;#r=null;#s="";#l=null;#a=null;#c=!1;#u=!1;static _type="stamp";static _editorType=_t.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#i=t.bitmapUrl,this.#r=t.bitmapFile}static initialize(t,e){pt.initialize(t,e)}static get supportedTypes(){return bt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(e=>`image/${e}`))}static get supportedTypesStr(){return bt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(_t.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#d(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#c=t.isSvg),t.file&&(this.#s=t.file.name),this.#o()}#h(){if(this.#n=null,this._uiManager.enableWaiting(!1),!!this.#l){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:a,height:l}=t||this.copyCanvas(null,null,!0).imageData,u=await s.guess({name:"altText",request:{data:r,width:a,height:l,channels:r.length/(a*l)}});if(!u)throw new Error("No response from the AI service.");if(u.error)throw new Error("Error from the AI service.");if(u.cancel)return null;if(!u.output)throw new Error("No valid response from the AI service.");const h=u.output;return await this.setGuessedAltText(h),e&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}#f(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#d(s,!0)).finally(()=>this.#h());return}if(this.#i){const s=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromUrl(s).then(r=>this.#d(r)).finally(()=>this.#h());return}if(this.#r){const s=this.#r;this.#r=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromFile(s).then(r=>this.#d(r)).finally(()=>this.#h());return}const t=document.createElement("input");t.type="file",t.accept=Ol.supportedTypesStr;const e=this._uiManager._signal;this.#n=new Promise(s=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(r)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#h()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#l?.remove(),this.#l=null,this.#a&&(clearTimeout(this.#a),this.#a=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#f();return}super.rebuild(),this.div!==null&&(this.#e&&this.#l===null&&this.#f(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#n||this.#t||this.#i||this.#r||this.#e)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#t?this.#o():this.#f(),this.width&&!this.annotationElementId){const[s,r]=this.parentDimensions;this.setAt(t*s,e*r,this.width*s,this.height*r)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#a!==null&&clearTimeout(this.#a);const t=200;this.#a=setTimeout(()=>{this.#a=null,this.#m()},t)}#o(){const{div:t}=this;let{width:e,height:s}=this.#t;const[r,a]=this.pageDimensions,l=.75;if(this.width)e=this.width*r,s=this.height*a;else if(e>l*r||s>l*a){const f=Math.min(l*r/e,l*a/s);e*=f,s*=f}const[u,h]=this.parentDimensions;this.setDims(e*u/r,s*h/a),this._uiManager.enableWaiting(!1);const p=this.#l=document.createElement("canvas");p.setAttribute("role","img"),this.addContainer(p),this.width=e/r,this.height=s/a,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#m(),this.#u||(this.parent.addUndoableEditor(this),this.#u=!0),this._reportTelemetry({action:"inserted_image"}),this.#s&&p.setAttribute("aria-label",this.#s)}copyCanvas(t,e,s=!1){t||(t=224);const{width:r,height:a}=this.#t,l=new pl;let u=this.#t,h=r,p=a,f=null;if(e){if(r>e||a>e){const H=Math.min(e/r,e/a);h=Math.floor(r*H),p=Math.floor(a*H)}f=document.createElement("canvas");const y=f.width=Math.ceil(h*l.sx),w=f.height=Math.ceil(p*l.sy);this.#c||(u=this.#p(y,w));const A=f.getContext("2d");A.filter=this._uiManager.hcmFilter;let S="white",E="#cfcfd8";this._uiManager.hcmFilter!=="none"?E="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(S="#8f8f9d",E="#42414d");const x=15,M=x*l.sx,I=x*l.sy,N=new OffscreenCanvas(M*2,I*2),O=N.getContext("2d");O.fillStyle=S,O.fillRect(0,0,M*2,I*2),O.fillStyle=E,O.fillRect(0,0,M,I),O.fillRect(M,I,M,I),A.fillStyle=A.createPattern(N,"repeat"),A.fillRect(0,0,y,w),A.drawImage(u,0,0,u.width,u.height,0,0,y,w)}let v=null;if(s){let y,w;if(l.symmetric&&u.width<t&&u.height<t)y=u.width,w=u.height;else if(u=this.#t,r>t||a>t){const E=Math.min(t/r,t/a);y=Math.floor(r*E),w=Math.floor(a*E),this.#c||(u=this.#p(y,w))}const S=new OffscreenCanvas(y,w).getContext("2d",{willReadFrequently:!0});S.drawImage(u,0,0,u.width,u.height,0,0,y,w),v={width:y,height:w,data:S.getImageData(0,0,y,w).data}}return{canvas:f,width:h,height:p,imageData:v}}#p(t,e){const{width:s,height:r}=this.#t;let a=s,l=r,u=this.#t;for(;a>2*t||l>2*e;){const h=a,p=l;a>2*t&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),l>2*e&&(l=l>=16384?Math.floor(l/2)-1:Math.ceil(l/2));const f=new OffscreenCanvas(a,l);f.getContext("2d").drawImage(u,0,0,h,p,0,0,a,l),u=f.transferToImageBitmap()}return u}#m(){const[t,e]=this.parentDimensions,{width:s,height:r}=this,a=new pl,l=Math.ceil(s*t*a.sx),u=Math.ceil(r*e*a.sy),h=this.#l;if(!h||h.width===l&&h.height===u)return;h.width=l,h.height=u;const p=this.#c?this.#t:this.#p(l,u),f=h.getContext("2d");f.filter=this._uiManager.hcmFilter,f.drawImage(p,0,0,p.width,p.height,0,0,l,u)}getImageForAltText(){return this.#l}#g(t){if(t){if(this.#c){const r=this._uiManager.imageManager.getSvgUrl(this.#e);if(r)return r}const e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#c){const[e,s]=this.pageDimensions,r=Math.round(this.width*e*Pi.PDF_TO_CSS_UNITS),a=Math.round(this.height*s*Pi.PDF_TO_CSS_UNITS),l=new OffscreenCanvas(r,a);return l.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,r,a),l.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,s){let r=null;if(t instanceof Nd){const{data:{rect:A,rotation:S,id:E,structParent:x,popupRef:M},container:I,parent:{page:{pageNumber:N}}}=t,O=I.querySelector("canvas"),H=s.imageManager.getFromCanvas(I.id,O);O.remove();const F=(await e._structTree.getAriaAttributes(`${bl}${E}`))?.get("aria-label")||"";r=t={annotationType:_t.STAMP,bitmapId:H.id,bitmap:H.bitmap,pageIndex:N-1,rect:A.slice(0),rotation:S,id:E,deleted:!1,accessibilityData:{decorative:!1,altText:F},isSvg:!1,structParent:x,popupRef:M}}const a=await super.deserialize(t,e,s),{rect:l,bitmap:u,bitmapUrl:h,bitmapId:p,isSvg:f,accessibilityData:v}=t;p&&s.imageManager.isValidId(p)?(a.#e=p,u&&(a.#t=u)):a.#i=h,a.#c=f;const[y,w]=a.pageDimensions;return a.width=(l[2]-l[0])/y,a.height=(l[3]-l[1])/w,a.annotationElementId=t.id||null,v&&(a.altTextData=v),a._initialData=r,a.#u=!!r,a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s={annotationType:_t.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#c,structTreeParentId:this._structTreeParentId};if(t)return s.bitmapUrl=this.#g(!0),s.accessibilityData=this.serializeAltText(!0),s;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(s.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const u=this.#v(s);if(u.isSame)return null;u.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1}if(s.id=this.annotationElementId,e===null)return s;e.stamps||=new Map;const l=this.#c?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:l,serialized:s}),s.bitmap=this.#g(!1);else if(this.#c){const u=e.stamps.get(this.#e);l>u.area&&(u.area=l,u.serialized.bitmap.close(),u.serialized.bitmap=this.#g(!1))}return s}#v(t){const{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,r=t.pageIndex===e,a=(t.accessibilityData?.alt||"")===s;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}class fn{#t;#e=!1;#n=null;#i=null;#r=null;#s=new Map;#l=!1;#a=!1;#c=!1;#u=null;#d=null;#h=null;#f=null;#o;static _initialized=!1;static#p=new Map([Qt,Fl,Ol,$t].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:r,accessibilityManager:a,annotationLayer:l,drawLayer:u,textLayer:h,viewport:p,l10n:f}){const v=[...fn.#p.values()];if(!fn._initialized){fn._initialized=!0;for(const y of v)y.initialize(f,t)}t.registerEditorTypes(v),this.#o=t,this.pageIndex=e,this.div=s,this.#t=a,this.#n=l,this.viewport=p,this.#h=h,this.drawLayer=u,this._structTree=r,this.#o.addLayer(this)}get isEmpty(){return this.#s.size===0}get isInvisible(){return this.isEmpty&&this.#o.getMode()===_t.NONE}updateToolbar(t){this.#o.updateToolbar(t)}updateMode(t=this.#o.getMode()){switch(this.#y(),t){case _t.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case _t.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case _t.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of fn.#p.values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#h?.div}setEditingState(t){this.#o.setEditingState(t)}addCommands(t){this.#o.addCommands(t)}cleanUndoStack(t){this.#o.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#n?.div.classList.toggle("disabled",!t)}async enable(){this.#c=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of this.#s.values())s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#o.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!this.#n){this.#c=!1;return}const e=this.#n.getEditableAnnotations();for(const s of e){if(s.hide(),this.#o.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const r=await this.deserialize(s);r&&(this.addOrRebuild(r),r.enableEditing())}this.#c=!1}disable(){this.#a=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const r of this.#s.values())if(r.disableEditing(),!!r.annotationElementId){if(r.serialize()!==null){t.set(r.annotationElementId,r);continue}else e.set(r.annotationElementId,r);this.getEditableAnnotation(r.annotationElementId)?.show(),r.remove()}if(this.#n){const r=this.#n.getEditableAnnotations();for(const a of r){const{id:l}=a.data;if(this.#o.isDeletedAnnotationElement(l))continue;let u=e.get(l);if(u){u.resetAnnotationElement(a),u.show(!1),a.show();continue}u=t.get(l),u&&(this.#o.addChangedExistingAnnotation(u),u.renderAnnotationElement(a)&&u.show(!1)),a.show()}}this.#y(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of fn.#p.values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#a=!1}getEditableAnnotation(t){return this.#n?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#o.getActive()!==t&&this.#o.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#h?.div&&!this.#f){this.#f=new AbortController;const t=this.#o.combinedSignal(this.#f);this.#h.div.addEventListener("pointerdown",this.#m.bind(this),{signal:t}),this.#h.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#h?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#h.div.classList.remove("highlighting"))}#m(t){this.#o.unselectAll();const{target:e}=t;if(e===this.#h.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&this.#h.div.contains(e)){const{isMac:s}=me.platform;if(t.button!==0||t.ctrlKey&&s)return;this.#o.showAllEditors("highlight",!0,!0),this.#h.div.classList.add("free"),this.toggleDrawing(),$t.startHighlighting(this,this.#o.direction==="ltr",{target:this.#h.div,x:t.x,y:t.y}),this.#h.div.addEventListener("pointerup",()=>{this.#h.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#o._signal}),t.preventDefault()}}enableClick(){if(this.#i)return;this.#i=new AbortController;const t=this.#o.combinedSignal(this.#i);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#i?.abort(),this.#i=null}attach(t){this.#s.set(t.id,t);const{annotationElementId:e}=t;e&&this.#o.isDeletedAnnotationElement(e)&&this.#o.removeDeletedAnnotationElement(t)}detach(t){this.#s.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#a&&t.annotationElementId&&this.#o.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#o.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#o.addDeletedAnnotationElement(t.annotationElementId),pt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),this.#o.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#c),this.#o.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#r&&(t._focusEventsAllowed=!1,this.#r=setTimeout(()=>{this.#r=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#o._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return this.#o.getId()}get#g(){return fn.#p.get(this.#o.getMode())}combinedSignal(t){return this.#o.combinedSignal(t)}#v(t){const e=this.#g;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#g?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#o.updateToolbar(t),this.#o.updateMode(t);const{offsetX:s,offsetY:r}=this.#_(),a=this.getNextId(),l=this.#v({parent:this,id:a,x:s,y:r,uiManager:this.#o,isCentered:!0,...e});l&&this.add(l)}async deserialize(t){return await fn.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#o)||null}createAndAddNewEditor(t,e,s={}){const r=this.getNextId(),a=this.#v({parent:this,id:r,x:t.offsetX,y:t.offsetY,uiManager:this.#o,isCentered:e,...s});return a&&this.add(a),a}#_(){const{x:t,y:e,width:s,height:r}=this.div.getBoundingClientRect(),a=Math.max(0,t),l=Math.max(0,e),u=Math.min(window.innerWidth,t+s),h=Math.min(window.innerHeight,e+r),p=(a+u)/2-t,f=(l+h)/2-e,[v,y]=this.viewport.rotation%180===0?[p,f]:[f,p];return{offsetX:v,offsetY:y}}addNewEditor(){this.createAndAddNewEditor(this.#_(),!0)}setSelected(t){this.#o.setSelected(t)}toggleSelected(t){this.#o.toggleSelected(t)}unselect(t){this.#o.unselect(t)}pointerup(t){const{isMac:e}=me.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&this.#l&&(this.#l=!1,!(this.#g?.isDrawer&&this.#g.supportMultipleDrawings))){if(!this.#e){this.#e=!0;return}if(this.#o.getMode()===_t.STAMP){this.#o.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#o.getMode()===_t.HIGHLIGHT&&this.enableTextSelection(),this.#l){this.#l=!1;return}const{isMac:e}=me.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#l=!0,this.#g?.isDrawer){this.startDrawingSession(t);return}const s=this.#o.getActive();this.#e=!s||s.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#u){this.#g.startDrawing(this,this.#o,!1,t);return}this.#o.setCurrentDrawingSession(this),this.#u=new AbortController;const e=this.#o.combinedSignal(this.#u);this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(this.#d=null,this.commitOrRemove())},{signal:e}),this.#g.startDrawing(this,this.#o,!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&(this.#d=e);return}this.#d&&setTimeout(()=>{this.#d?.focus(),this.#d=null},0)}endDrawingSession(t=!1){return this.#u?(this.#o.setCurrentDrawingSession(null),this.#u.abort(),this.#u=null,this.#d=null,this.#g.endDrawing(t)):null}findNewParent(t,e,s){const r=this.#o.findParent(e,s);return r===null||r===this?!1:(r.changeParent(t),!0)}commitOrRemove(){return this.#u?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#u&&this.#g.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#o.getActive()?.parent===this&&(this.#o.commitOrRemove(),this.#o.setActiveEditor(null)),this.#r&&(clearTimeout(this.#r),this.#r=null);for(const t of this.#s.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#s.clear(),this.#o.removeLayer(this)}#y(){for(const t of this.#s.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,Zn(this.div,t);for(const e of this.#o.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#o.commitOrRemove(),this.#y();const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Zn(this.div,{rotation:s}),e!==s)for(const r of this.#s.values())r.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#o.viewParameters.realScale}}class pe{#t=null;#e=0;#n=new Map;#i=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#t){this.#t=t;return}if(this.#t!==t){if(this.#n.size>0)for(const e of this.#n.values())e.remove(),t.append(e);this.#t=t}}static get _svgFactory(){return bt(this,"_svgFactory",new Il)}static#r(t,[e,s,r,a]){const{style:l}=t;l.top=`${100*s}%`,l.left=`${100*e}%`,l.width=`${100*r}%`,l.height=`${100*a}%`}#s(){const t=pe._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden",!0),t}#l(t,e){const s=pe._svgFactory.createElement("clipPath");t.append(s);const r=`clip_${e}`;s.setAttribute("id",r),s.setAttribute("clipPathUnits","objectBoundingBox");const a=pe._svgFactory.createElement("use");return s.append(a),a.setAttribute("href",`#${e}`),a.classList.add("clip"),r}#a(t,e){for(const[s,r]of Object.entries(e))r===null?t.removeAttribute(s):t.setAttribute(s,r)}draw(t,e=!1,s=!1){const r=this.#e++,a=this.#s(),l=pe._svgFactory.createElement("defs");a.append(l);const u=pe._svgFactory.createElement("path");l.append(u);const h=`path_p${this.pageIndex}_${r}`;u.setAttribute("id",h),u.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#i.set(r,u);const p=s?this.#l(l,h):null,f=pe._svgFactory.createElement("use");return a.append(f),f.setAttribute("href",`#${h}`),this.updateProperties(a,t),this.#n.set(r,a),{id:r,clipPathId:`url(#${p})`}}drawOutline(t,e){const s=this.#e++,r=this.#s(),a=pe._svgFactory.createElement("defs");r.append(a);const l=pe._svgFactory.createElement("path");a.append(l);const u=`path_p${this.pageIndex}_${s}`;l.setAttribute("id",u),l.setAttribute("vector-effect","non-scaling-stroke");let h;if(e){const v=pe._svgFactory.createElement("mask");a.append(v),h=`mask_p${this.pageIndex}_${s}`,v.setAttribute("id",h),v.setAttribute("maskUnits","objectBoundingBox");const y=pe._svgFactory.createElement("rect");v.append(y),y.setAttribute("width","1"),y.setAttribute("height","1"),y.setAttribute("fill","white");const w=pe._svgFactory.createElement("use");v.append(w),w.setAttribute("href",`#${u}`),w.setAttribute("stroke","none"),w.setAttribute("fill","black"),w.setAttribute("fill-rule","nonzero"),w.classList.add("mask")}const p=pe._svgFactory.createElement("use");r.append(p),p.setAttribute("href",`#${u}`),h&&p.setAttribute("mask",`url(#${h})`);const f=p.cloneNode();return r.append(f),p.classList.add("mainOutline"),f.classList.add("secondaryOutline"),this.updateProperties(r,t),this.#n.set(s,r),s}finalizeDraw(t,e){this.#i.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:s,bbox:r,rootClass:a,path:l}=e,u=typeof t=="number"?this.#n.get(t):t;if(u){if(s&&this.#a(u,s),r&&pe.#r(u,r),a){const{classList:h}=u;for(const[p,f]of Object.entries(a))h.toggle(p,f)}if(l){const p=u.firstChild.firstChild;this.#a(p,l)}}}updateParent(t,e){if(e===this)return;const s=this.#n.get(t);s&&(e.#t.append(s),this.#n.delete(t),e.#n.set(t,s))}remove(t){this.#i.delete(t),this.#t!==null&&(this.#n.get(t).remove(),this.#n.delete(t))}destroy(){this.#t=null;for(const t of this.#n.values())t.remove();this.#n.clear(),this.#i.clear()}}globalThis.pdfjsTestingUtils={HighlightOutliner:yl};vt.AbortException;vt.AnnotationEditorLayer;vt.AnnotationEditorParamsType;vt.AnnotationEditorType;vt.AnnotationEditorUIManager;vt.AnnotationLayer;vt.AnnotationMode;vt.ColorPicker;vt.DOMSVGFactory;vt.DrawLayer;vt.FeatureTest;var Wm=vt.GlobalWorkerOptions;vt.ImageKind;vt.InvalidPDFException;vt.MissingPDFException;vt.OPS;vt.OutputScale;vt.PDFDataRangeTransport;vt.PDFDateString;vt.PDFWorker;vt.PasswordResponses;vt.PermissionFlag;vt.PixelsPerInch;vt.RenderingCancelledException;vt.TextLayer;vt.TouchManager;vt.UnexpectedResponseException;vt.Util;vt.VerbosityLevel;vt.XfaLayer;vt.build;vt.createValidAbsoluteUrl;vt.fetchData;var Vm=vt.getDocument;vt.getFilenameFromUrl;vt.getPdfFilenameFromUrl;vt.getXfaPageViewport;vt.isDataScheme;vt.isPdfFile;vt.noContextMenu;vt.normalizeUnicode;vt.setLayerDimensions;vt.shadow;vt.stopEvent;vt.version;const Gm="/assets/pdf.worker.min-yatZIOMy.mjs";Wm.workerSrc=Gm;function Fd(g,t){const[e,s]=Pt.useState([]);return Pt.useEffect(()=>{if(!g)return;let r=!1;return Vm(g).promise.then(async a=>{const l=[];for(let u=1;u<=a.numPages;u++)l.push(await a.getPage(u));r||s(l)}),()=>{r=!0}},[t]),e}function Od({page:g,children:t,...e}){const s=Pt.useRef(null),r=g.getViewport({scale:1}),a=Math.min(1.5,(Math.min(window.innerWidth,1e3)-32)/r.width);return Pt.useEffect(()=>{const l=g.getViewport({scale:a*devicePixelRatio}),u=s.current;u.width=l.width,u.height=l.height;const h=g.render({canvasContext:u.getContext("2d"),viewport:l});return h.promise.catch(()=>{}),()=>h.cancel()},[g,a]),W.jsxs("div",{className:"page",style:{width:r.width*a,height:r.height*a},...e,children:[W.jsx("canvas",{ref:s,style:{width:"100%",height:"100%"}}),t(a,r.height)]})}const hl={signature:[198,24],date:[198,24],initials:[60,24],text:[198,20]};function Xm({id:g}){const t=(F="")=>`/api/place/${g}${F}`,[e,s]=Pt.useState(null),[r,a]=Pt.useState([]),[l,u]=Pt.useState(null),[h,p]=Pt.useState("signature"),[f,v]=Pt.useState("signer1"),[y,w]=Pt.useState(null),[A,S]=Pt.useState(null),E=Pt.useRef(null);Pt.useEffect(()=>{fetch(t()).then(async F=>{const G=await F.json();if(!F.ok)return S(G.error);s(G),a(G.fields.map((Y,$)=>({...Y,id:$+1})))})},[]);const x=Fd(e&&{url:t("/pdf")},e?.title),M=(F,G)=>a(Y=>Y.map($=>$.id===F?{...$,...G}:$)),I=F=>{a(G=>G.filter(Y=>Y.id!==F)),u(null)};if(Pt.useEffect(()=>{const F=G=>{(G.key==="Delete"||G.key==="Backspace")&&l&&!/INPUT|SELECT/.test(document.activeElement?.tagName??"")&&I(l),G.key==="Escape"&&u(null)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[l]),A)return W.jsxs("main",{className:"note",children:[W.jsx("h1",{children:"Can't open this PDF"}),W.jsx("p",{children:A})]});if(!e)return W.jsx("main",{className:"note",children:W.jsx("p",{children:"Loading…"})});const N=async()=>{const F=await fetch(t(),{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({fields:r.map(({id:Y,...$})=>$)})}),G=await F.json();w(F.ok?`Saved ${G.saved} ${G.saved===1?"field":"fields"} to ${G.file}`:G.error)},O=(F,G,Y,$)=>{const V=G.getBoundingClientRect();return{x:(F.clientX-V.left)/Y,y:$-(F.clientY-V.top)/Y}},H=[...new Set(r.map(F=>F.who))];return W.jsxs(W.Fragment,{children:[W.jsxs("header",{className:"bar",children:[W.jsxs("div",{children:[W.jsx("strong",{children:e.title}),W.jsx("span",{className:"who",children:"Drag on a page to draw a field. Click a field to change it."})]}),W.jsxs("div",{className:"row",children:[W.jsxs("label",{className:"pick",children:["New field ",W.jsx("select",{value:h,onChange:F=>p(F.target.value),children:e.types.map(F=>W.jsx("option",{children:F},F))})]}),W.jsxs("label",{className:"pick",children:["for ",W.jsx("input",{list:"roles",value:f,onChange:F=>v(F.target.value.replace(/[^\w-]/g,"")),size:10})]}),W.jsx("datalist",{id:"roles",children:H.map(F=>W.jsx("option",{value:F},F))}),W.jsxs("button",{className:"button",onClick:N,children:["Save ",r.length," ",r.length===1?"field":"fields"]})]})]}),y&&W.jsx("p",{className:"status ok",children:y}),W.jsx("main",{className:"pages",children:x.map((F,G)=>W.jsx(Od,{page:F,onPointerDown:Y=>{if(Y.target.closest(".box, .popover"))return;const $=Y.currentTarget,V=$.offsetWidth/F.getViewport({scale:1}).width,at=F.getViewport({scale:1}).height,mt=O(Y,$,V,at),yt=Math.max(0,...r.map(kt=>kt.id))+1;a(kt=>[...kt,{id:yt,type:h,who:f||"signer1",page:G+1,x:mt.x,y:mt.y-hl[h][1],width:hl[h][0],height:hl[h][1]}]),u(yt),E.current={kind:"draw",fid:yt,el:$,scale:V,height:at,start:mt},$.setPointerCapture(Y.pointerId)},onPointerMove:Y=>{const $=E.current;if(!$)return;const V=O(Y,$.el,$.scale,$.height);if($.kind==="draw"){if(Math.abs(V.x-$.start.x)<6&&Math.abs(V.y-$.start.y)<6)return;M($.fid,{x:Math.min(V.x,$.start.x),y:Math.min(V.y,$.start.y),width:Math.abs(V.x-$.start.x),height:Math.abs(V.y-$.start.y)})}else if($.field&&$.kind==="move")M($.fid,{x:$.field.x+V.x-$.start.x,y:$.field.y+V.y-$.start.y});else if($.field){const at=Math.max(10,$.field.height-(V.y-$.start.y));M($.fid,{width:Math.max(12,$.field.width+V.x-$.start.x),height:at,y:$.field.y+$.field.height-at})}},onPointerUp:()=>{E.current=null},children:(Y,$)=>r.filter(V=>V.page===G+1).map(V=>W.jsxs("div",{children:[W.jsxs("div",{className:`box placed ${V.id===l?"selected":""}`,style:{left:V.x*Y,top:($-V.y-V.height)*Y,width:V.width*Y,height:V.height*Y},onPointerDown:at=>{const mt=at.currentTarget.closest(".page");u(V.id),E.current={kind:at.target.classList.contains("grip")?"resize":"move",fid:V.id,field:V,el:mt,scale:Y,height:$,start:O(at,mt,Y,$)},mt.setPointerCapture(at.pointerId)},children:[V.label||V.type," · ",V.who,W.jsx("span",{className:"grip"})]}),V.id===l&&W.jsxs("div",{className:"popover",style:{left:V.x*Y,top:($-V.y)*Y+6},children:[W.jsx("select",{value:V.type,onChange:at=>M(V.id,{type:at.target.value}),children:e.types.map(at=>W.jsx("option",{children:at},at))}),W.jsx("input",{list:"roles",value:V.who,onChange:at=>M(V.id,{who:at.target.value.replace(/[^\w-]/g,"")}),size:10,"aria-label":"Who fills this field"}),V.type==="text"&&W.jsx("input",{value:V.label||"",onChange:at=>M(V.id,{label:at.target.value}),size:12,placeholder:"Label","aria-label":"What to type here"}),W.jsx("button",{onClick:()=>I(V.id),children:"Delete"})]})]},V.id))},G))})]})}/*!
|
|
52
|
+
* Signature Pad v5.1.7 | https://github.com/szimek/signature_pad
|
|
53
|
+
* (c) 2026 Szymon Nowak | Released under the MIT license
|
|
54
|
+
*/var qr=class{x;y;pressure;time;constructor(g,t,e,s){if(isNaN(g)||isNaN(t))throw new Error(`Point is invalid: (${g}, ${t})`);this.x=+g,this.y=+t,this.pressure=e||0,this.time=s||Date.now()}distanceTo(g){return Math.sqrt(Math.pow(this.x-g.x,2)+Math.pow(this.y-g.y,2))}equals(g){return this.x===g.x&&this.y===g.y&&this.pressure===g.pressure&&this.time===g.time}velocityFrom(g){return this.time!==g.time?this.distanceTo(g)/(this.time-g.time):0}},qm=class zd{static fromPoints(t,e){const s=this.calculateControlPoints(t[0],t[1],t[2]).c2,r=this.calculateControlPoints(t[1],t[2],t[3]).c1;return new zd(t[1],s,r,t[2],e.start,e.end)}static calculateControlPoints(t,e,s){const r=t.x-e.x,a=t.y-e.y,l=e.x-s.x,u=e.y-s.y,h={x:(t.x+e.x)/2,y:(t.y+e.y)/2},p={x:(e.x+s.x)/2,y:(e.y+s.y)/2},f=Math.sqrt(r*r+a*a),v=Math.sqrt(l*l+u*u),y=h.x-p.x,w=h.y-p.y,A=f+v==0?0:v/(f+v),S={x:p.x+y*A,y:p.y+w*A},E=e.x-S.x,x=e.y-S.y;return{c1:new qr(h.x+E,h.y+x),c2:new qr(p.x+E,p.y+x)}}startPoint;control2;control1;endPoint;startWidth;endWidth;constructor(t,e,s,r,a,l){this.startPoint=t,this.control2=e,this.control1=s,this.endPoint=r,this.startWidth=a,this.endWidth=l}length(){let e=0,s,r;for(let a=0;a<=10;a+=1){const l=a/10,u=this.point(l,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),h=this.point(l,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(a>0){const p=u-s,f=h-r;e+=Math.sqrt(p*p+f*f)}s=u,r=h}return e}point(t,e,s,r,a){return e*(1-t)*(1-t)*(1-t)+3*s*(1-t)*(1-t)*t+3*r*(1-t)*t*t+a*t*t*t}},Ym=class{_et;constructor(){try{const g=typeof window<"u"&&window.EventTarget?window.EventTarget:EventTarget;this._et=new g}catch{this._et=document}}addEventListener(g,t,e){this._et.addEventListener(g,t,e)}dispatchEvent(g){return this._et.dispatchEvent(g)}removeEventListener(g,t,e){this._et.removeEventListener(g,t,e)}};function Km(g,t=250){let e=0,s=null,r,a,l;const u=()=>{e=Date.now(),s=null,r=g.apply(a,l),s||(a=null,l=[])};return function(...p){const f=Date.now(),v=t-(f-e);return a=this,l=p,v<=0||v>t?(s&&(clearTimeout(s),s=null),e=f,r=g.apply(a,l),s||(a=null,l=[])):s||(s=window.setTimeout(u,v)),r}}var Qm=class _l extends Ym{dotSize;minWidth;maxWidth;penColor;minDistance;velocityFilterWeight;compositeOperation;backgroundColor;throttle;canvasContextOptions;canvas;_ctx;_drawingStroke=!1;_isEmpty=!0;_dataUrl;_dataUrlOptions;_lastPoints=[];_data=[];_lastVelocity=0;_lastWidth=0;_strokeMoveUpdate;_strokePointerId;constructor(t,e={}){super(),this.canvas=t,this.velocityFilterWeight=e.velocityFilterWeight??.7,this.minWidth=e.minWidth||.5,this.maxWidth=e.maxWidth||2.5,this.throttle=e.throttle??16,this.minDistance=e.minDistance??5,this.dotSize=e.dotSize||0,this.penColor=e.penColor||"black",this.backgroundColor=e.backgroundColor||"rgba(0,0,0,0)",this.compositeOperation=e.compositeOperation||"source-over",this.canvasContextOptions=e.canvasContextOptions??{},this._strokeMoveUpdate=this.throttle?Km(_l.prototype._strokeUpdate,this.throttle):_l.prototype._strokeUpdate,this._handleMouseDown=this._handleMouseDown.bind(this),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this._handleTouchStart=this._handleTouchStart.bind(this),this._handleTouchMove=this._handleTouchMove.bind(this),this._handleTouchEnd=this._handleTouchEnd.bind(this),this._handlePointerDown=this._handlePointerDown.bind(this),this._handlePointerMove=this._handlePointerMove.bind(this),this._handlePointerUp=this._handlePointerUp.bind(this),this._handlePointerCancel=this._handlePointerCancel.bind(this),this._handleTouchCancel=this._handleTouchCancel.bind(this),this._ctx=t.getContext("2d",this.canvasContextOptions),this.clear(),this.on()}clear(){const{_ctx:t,canvas:e}=this;t.fillStyle=this.backgroundColor,t.clearRect(0,0,e.width,e.height),t.fillRect(0,0,e.width,e.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0,this._dataUrl=void 0,this._dataUrlOptions=void 0,this._drawingStroke||(this._strokePointerId=void 0)}redraw(){const t=this._data,e=this._dataUrl,s=this._dataUrlOptions;this.clear(),e&&this.fromDataURL(e,s),this.fromData(t,{clear:!1})}fromDataURL(t,e={}){return new Promise((s,r)=>{const a=new Image,l=e.ratio||window.devicePixelRatio||1,u=e.width||this.canvas.width/l,h=e.height||this.canvas.height/l,p=e.xOffset||0,f=e.yOffset||0;this._reset(this._getPointGroupOptions()),a.onload=()=>{this._ctx.drawImage(a,p,f,u,h),s()},a.onerror=v=>{r(v)},a.crossOrigin="anonymous",a.src=t,this._isEmpty=!1,this._dataUrl=t,this._dataUrlOptions={...e}})}toDataURL(t="image/png",e){switch(t){case"image/svg+xml":return typeof e!="object"&&(e=void 0),`data:image/svg+xml;base64,${btoa(this.toSVG(e))}`;default:return typeof e!="number"&&(e=void 0),this.canvas.toDataURL(t,e)}}on(){this.canvas.style.touchAction="none",this.canvas.style.msTouchAction="none",this.canvas.style.userSelect="none",this.canvas.style.webkitUserSelect="none";const t=/Macintosh/.test(navigator.userAgent)&&"ontouchstart"in document;window.PointerEvent&&!t?this._handlePointerEvents():(this._handleMouseEvents(),"ontouchstart"in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction="auto",this.canvas.style.msTouchAction="auto",this.canvas.style.userSelect="auto",this.canvas.style.webkitUserSelect="auto",this.canvas.removeEventListener("pointerdown",this._handlePointerDown),this.canvas.removeEventListener("mousedown",this._handleMouseDown),this.canvas.removeEventListener("touchstart",this._handleTouchStart),this._removeMoveUpEventListeners()}_getListenerFunctions(){const t=window.document===this.canvas.ownerDocument?window:this.canvas.ownerDocument.defaultView??this.canvas.ownerDocument;return{addEventListener:t.addEventListener.bind(t),removeEventListener:t.removeEventListener.bind(t)}}_removeMoveUpEventListeners(){const{removeEventListener:t}=this._getListenerFunctions();t("pointermove",this._handlePointerMove),t("pointerup",this._handlePointerUp),t("pointercancel",this._handlePointerCancel),t("mousemove",this._handleMouseMove),t("mouseup",this._handleMouseUp),t("touchmove",this._handleTouchMove),t("touchend",this._handleTouchEnd),t("touchcancel",this._handleTouchCancel)}isEmpty(){return this._isEmpty}fromData(t,{clear:e=!0}={}){e&&this.clear(),this._fromData(t,this._drawCurve.bind(this),this._drawDot.bind(this),this._drawLine.bind(this)),this._data=this._data.concat(t)}toData(){return this._data}_isLeftButtonPressed(t,e){return e?t.buttons===1:(t.buttons&1)===1}_pointerEventToSignatureEvent(t){return{event:t,type:t.type,x:t.clientX,y:t.clientY,pressure:"pressure"in t?t.pressure:0}}_touchEventToSignatureEvent(t){const e=t.changedTouches[0];return{event:t,type:t.type,x:e.clientX,y:e.clientY,pressure:e.force}}_handleMouseDown(t){!this._isLeftButtonPressed(t,!0)||this._drawingStroke||this._strokeBegin(this._pointerEventToSignatureEvent(t))}_handleMouseMove(t){if(!this._isLeftButtonPressed(t,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(t),!1);return}this._strokeMoveUpdate(this._pointerEventToSignatureEvent(t))}_handleMouseUp(t){this._isLeftButtonPressed(t)||this._strokeEnd(this._pointerEventToSignatureEvent(t))}_handleTouchStart(t){t.targetTouches.length!==1||this._drawingStroke||(t.cancelable&&t.preventDefault(),this._strokeBegin(this._touchEventToSignatureEvent(t)))}_handleTouchMove(t){if(t.targetTouches.length===1){if(t.cancelable&&t.preventDefault(),!this._drawingStroke){this._strokeEnd(this._touchEventToSignatureEvent(t),!1);return}this._strokeMoveUpdate(this._touchEventToSignatureEvent(t))}}_handleTouchEnd(t){t.targetTouches.length===0&&(t.cancelable&&t.preventDefault(),this._strokeEnd(this._touchEventToSignatureEvent(t)))}_handlePointerCancel(t){this._allowPointerId(t)&&(t.preventDefault(),this._strokeEnd(this._pointerEventToSignatureEvent(t),!1))}_handleTouchCancel(t){t.cancelable&&t.preventDefault(),this._strokeEnd(this._touchEventToSignatureEvent(t),!1)}_getPointerId(t){return t.persistentDeviceId||t.pointerId}_allowPointerId(t,e=!1){return typeof this._strokePointerId>"u"?e:this._getPointerId(t)===this._strokePointerId}_handlePointerDown(t){this._drawingStroke||!this._isLeftButtonPressed(t)||!this._allowPointerId(t,!0)||(this._strokePointerId=this._getPointerId(t),t.preventDefault(),this._strokeBegin(this._pointerEventToSignatureEvent(t)),this._drawingStroke||(this._strokePointerId=void 0))}_handlePointerMove(t){if(this._allowPointerId(t)){if(!this._isLeftButtonPressed(t,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(t),!1);return}t.preventDefault(),this._strokeMoveUpdate(this._pointerEventToSignatureEvent(t))}}_handlePointerUp(t){this._isLeftButtonPressed(t)||!this._allowPointerId(t)||(t.preventDefault(),this._strokeEnd(this._pointerEventToSignatureEvent(t)))}_getPointGroupOptions(t){return{penColor:t&&"penColor"in t?t.penColor:this.penColor,dotSize:t&&"dotSize"in t?t.dotSize:this.dotSize,minWidth:t&&"minWidth"in t?t.minWidth:this.minWidth,maxWidth:t&&"maxWidth"in t?t.maxWidth:this.maxWidth,velocityFilterWeight:t&&"velocityFilterWeight"in t?t.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:t&&"compositeOperation"in t?t.compositeOperation:this.compositeOperation}}_strokeBegin(t){if(!this.dispatchEvent(new CustomEvent("beginStroke",{detail:t,cancelable:!0})))return;const{addEventListener:s}=this._getListenerFunctions();switch(t.event.type){case"mousedown":s("mousemove",this._handleMouseMove,{passive:!1}),s("mouseup",this._handleMouseUp,{passive:!1});break;case"touchstart":s("touchmove",this._handleTouchMove,{passive:!1}),s("touchend",this._handleTouchEnd,{passive:!1}),s("touchcancel",this._handleTouchCancel,{passive:!1});break;case"pointerdown":s("pointermove",this._handlePointerMove,{passive:!1}),s("pointerup",this._handlePointerUp,{passive:!1}),s("pointercancel",this._handlePointerCancel,{passive:!1});break}this._drawingStroke=!0;const r=this._getPointGroupOptions(),a={...r,points:[]};this._data.push(a),this._reset(r),this._strokeUpdate(t)}_strokeUpdate(t){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(t);return}this.dispatchEvent(new CustomEvent("beforeUpdateStroke",{detail:t}));const e=this._createPoint(t.x,t.y,t.pressure),s=this._data[this._data.length-1],r=s.points,a=r.length>0&&r[r.length-1],l=a?e.distanceTo(a)<=this.minDistance:!1,u=this._getPointGroupOptions(s);if(!a||!(a&&l)){const h=this._addPoint(e,u);a?h&&this._drawCurve(h,u):this._drawDot(e,u),r.push({time:e.time,x:e.x,y:e.y,pressure:e.pressure})}this.dispatchEvent(new CustomEvent("afterUpdateStroke",{detail:t}))}_strokeEnd(t,e=!0){this._removeMoveUpEventListeners(),this._drawingStroke&&(e&&this._strokeUpdate(t),this._drawingStroke=!1,this._strokePointerId=void 0,this.dispatchEvent(new CustomEvent("endStroke",{detail:t})))}_handlePointerEvents(){this._drawingStroke=!1,this._strokePointerId=void 0,this.canvas.addEventListener("pointerdown",this._handlePointerDown,{passive:!1})}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener("mousedown",this._handleMouseDown,{passive:!1})}_handleTouchEvents(){this.canvas.addEventListener("touchstart",this._handleTouchStart,{passive:!1})}_reset(t){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(t.minWidth+t.maxWidth)/2,this._ctx.fillStyle=t.penColor,this._ctx.globalCompositeOperation=t.compositeOperation}_createPoint(t,e,s){const r=this.canvas.getBoundingClientRect();return new qr(t-r.left,e-r.top,s,new Date().getTime())}_addPoint(t,e){const{_lastPoints:s}=this;if(s.push(t),s.length>2){s.length===3&&s.unshift(s[0]);const r=this._calculateCurveWidths(s[1],s[2],e),a=qm.fromPoints(s,r);return s.shift(),a}return null}_calculateCurveWidths(t,e,s){const r=s.velocityFilterWeight*e.velocityFrom(t)+(1-s.velocityFilterWeight)*this._lastVelocity,a=this._strokeWidth(r,s),l={end:a,start:this._lastWidth};return this._lastVelocity=r,this._lastWidth=a,l}_strokeWidth(t,e){return Math.max(e.maxWidth/(t+1),e.minWidth)}_drawCurveSegment(t,e,s){const r=this._ctx;r.moveTo(t,e),r.arc(t,e,s,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(t,e){const s=this._ctx,r=t.endWidth-t.startWidth,a=Math.ceil(t.length())*2;s.beginPath(),s.fillStyle=e.penColor;for(let l=0;l<a;l+=1){const u=l/a,h=u*u,p=h*u,f=1-u,v=f*f,y=v*f;let w=y*t.startPoint.x;w+=3*v*u*t.control1.x,w+=3*f*h*t.control2.x,w+=p*t.endPoint.x;let A=y*t.startPoint.y;A+=3*v*u*t.control1.y,A+=3*f*h*t.control2.y,A+=p*t.endPoint.y;const S=Math.min(t.startWidth+p*r,e.maxWidth);this._drawCurveSegment(w,A,S)}s.closePath(),s.fill()}_getDotSize(t){return t.dotSize>0?t.dotSize:(t.minWidth+t.maxWidth)/2}_drawDot(t,e){const s=this._ctx,r=this._getDotSize(e);s.beginPath(),this._drawCurveSegment(t.x,t.y,r),s.closePath(),s.fillStyle=e.penColor,s.fill()}_drawLine(t,e,s){const r=this._ctx;r.save(),r.beginPath(),r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.lineWidth=this._getDotSize(s)*2,r.lineCap="round",r.strokeStyle=s.penColor,r.stroke(),r.restore(),this._isEmpty=!1}_fromData(t,e,s,r){for(const a of t){const{points:l}=a,u=this._getPointGroupOptions(a);if(l.length>2)for(let h=0;h<l.length;h+=1){const p=l[h],f=new qr(p.x,p.y,p.pressure,p.time);h===0&&this._reset(u);const v=this._addPoint(f,u);v&&e(v,u)}else l.length===2?(this._reset(u),r(l[0],l[1],u)):(this._reset(u),s(l[0],u))}}toSVG({includeBackgroundColor:t=!1,includeDataUrl:e=!1}={}){const s=this._data,r=Math.max(window.devicePixelRatio||1,1),a=0,l=0,u=this.canvas.width/r,h=this.canvas.height/r,p=document.createElementNS("http://www.w3.org/2000/svg","svg");if(p.setAttribute("xmlns","http://www.w3.org/2000/svg"),p.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),p.setAttribute("viewBox",`${a} ${l} ${u} ${h}`),p.setAttribute("width",u.toString()),p.setAttribute("height",h.toString()),t&&this.backgroundColor){const f=document.createElement("rect");f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.setAttribute("fill",this.backgroundColor),p.appendChild(f)}if(e&&this._dataUrl){const f=this._dataUrlOptions?.ratio||window.devicePixelRatio||1,v=this._dataUrlOptions?.width||this.canvas.width/f,y=this._dataUrlOptions?.height||this.canvas.height/f,w=this._dataUrlOptions?.xOffset||0,A=this._dataUrlOptions?.yOffset||0,S=document.createElement("image");S.setAttribute("x",w.toString()),S.setAttribute("y",A.toString()),S.setAttribute("width",v.toString()),S.setAttribute("height",y.toString()),S.setAttribute("preserveAspectRatio","none"),S.setAttribute("href",this._dataUrl),p.appendChild(S)}return this._fromData(s,(f,{penColor:v})=>{const y=document.createElement("path");if(!isNaN(f.control1.x)&&!isNaN(f.control1.y)&&!isNaN(f.control2.x)&&!isNaN(f.control2.y)){const w=`M ${f.startPoint.x.toFixed(3)},${f.startPoint.y.toFixed(3)} C ${f.control1.x.toFixed(3)},${f.control1.y.toFixed(3)} ${f.control2.x.toFixed(3)},${f.control2.y.toFixed(3)} ${f.endPoint.x.toFixed(3)},${f.endPoint.y.toFixed(3)}`;y.setAttribute("d",w),y.setAttribute("stroke-width",(f.endWidth*2.25).toFixed(3)),y.setAttribute("stroke",v),y.setAttribute("fill","none"),y.setAttribute("stroke-linecap","round"),p.appendChild(y)}},(f,{penColor:v,dotSize:y,minWidth:w,maxWidth:A})=>{const S=document.createElement("circle"),E=y>0?y:(w+A)/2;S.setAttribute("r",E.toString()),S.setAttribute("cx",f.x.toString()),S.setAttribute("cy",f.y.toString()),S.setAttribute("fill",v),p.appendChild(S)},(f,v,y)=>{const w=document.createElement("line");w.setAttribute("x1",f.x.toString()),w.setAttribute("y1",f.y.toString()),w.setAttribute("x2",v.x.toString()),w.setAttribute("y2",v.y.toString()),w.setAttribute("stroke",y.penColor),w.setAttribute("stroke-width",(this._getDotSize(y)*2).toString()),w.setAttribute("stroke-linecap","round"),p.appendChild(w)}),p.outerHTML}};function od(g){const{width:t,height:e}=g,s=g.getContext("2d").getImageData(0,0,t,e).data;let r=t,a=e,l=-1,u=-1;for(let f=0;f<e;f++)for(let v=0;v<t;v++)s[(f*t+v)*4+3]>8&&(v<r&&(r=v),v>l&&(l=v),f<a&&(a=f),f>u&&(u=f));if(l<0)return null;const h=4,p=document.createElement("canvas");return p.width=l-r+1+h*2,p.height=u-a+1+h*2,p.getContext("2d").drawImage(g,r,a,l-r+1,u-a+1,h,h,l-r+1,u-a+1),p.toDataURL("image/png")}function Zm({name:g,onDone:t,onCancel:e}){const s=Pt.useRef(null),r=Pt.useRef(null),[a,l]=Pt.useState("draw"),[u,h]=Pt.useState(g);Pt.useEffect(()=>{const f=s.current;return f.width=f.offsetWidth*devicePixelRatio,f.height=f.offsetHeight*devicePixelRatio,f.getContext("2d").scale(devicePixelRatio,devicePixelRatio),r.current=new Qm(f,{penColor:"#0a2a6b"}),()=>r.current?.off()},[a]);const p=()=>{if(a==="draw")return!r.current||r.current.isEmpty()?void 0:t(od(s.current));if(!u.trim())return;const f=document.createElement("canvas");f.width=900,f.height=220;const v=f.getContext("2d");v.fillStyle="#0a2a6b",v.font='italic 110px "Snell Roundhand", "Brush Script MT", "Segoe Script", cursive',v.textBaseline="middle",v.fillText(u.trim(),20,115,860),t(od(f))};return W.jsx("div",{className:"veil",onClick:e,children:W.jsxs("div",{className:"dialog",onClick:f=>f.stopPropagation(),children:[W.jsxs("div",{className:"tabs",children:[W.jsx("button",{className:a==="draw"?"on":"",onClick:()=>l("draw"),children:"Draw"}),W.jsx("button",{className:a==="type"?"on":"",onClick:()=>l("type"),children:"Type"})]}),a==="draw"?W.jsx("canvas",{ref:s,className:"pad"}):W.jsxs(W.Fragment,{children:[W.jsx("canvas",{ref:s,hidden:!0}),W.jsx("input",{className:"typed",value:u,onChange:f=>h(f.target.value),autoFocus:!0})]}),W.jsxs("div",{className:"actions",children:[a==="draw"&&W.jsx("button",{onClick:()=>r.current?.clear(),children:"Clear"}),W.jsx("button",{onClick:e,children:"Cancel"}),W.jsx("button",{className:"button",onClick:p,children:"Use this signature"})]})]})})}const Jm=()=>new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"});function tv(){return new Promise(g=>{if(!navigator.geolocation)return g({declined:"unsupported"});navigator.geolocation.getCurrentPosition(t=>g({latitude:t.coords.latitude,longitude:t.coords.longitude,accuracy:t.coords.accuracy}),t=>g({declined:t.code===1?"denied":t.code===3?"timeout":"unavailable"}),{timeout:1e4,maximumAge:6e4})})}function ev({token:g}){const t=(z="")=>`/api/sign/${g}${z}`,[e,s]=Pt.useState(""),[r,a]=Pt.useState(null),[l,u]=Pt.useState({needCode:!0,message:null}),[h,p]=Pt.useState(null),[f,v]=Pt.useState(null),[y,w]=Pt.useState(!1),[A,S]=Pt.useState(!1),[E,x]=Pt.useState({}),[M,I]=Pt.useState(null),[N,O]=Pt.useState(!1),[H,F]=Pt.useState(!1),[G,Y]=Pt.useState(0),$=async(z="",k={})=>{const D=await fetch(t(z),{...k,headers:{"x-access-code":e,...k.body?{"content-type":"application/json"}:{}}});return{ok:D.ok,status:D.status,data:D.headers.get("content-type")?.includes("json")?await D.json():await D.blob()}},V=async z=>{z?.preventDefault();const k=await $().catch(()=>null);if(!k)return p("Could not reach the signing server.");if(k.ok)return u({needCode:!1}),a(k.data);if(k.data.needCode&&k.status===401)return u({needCode:!0,message:e?k.data.error:null});p(k.data.error)},at=Fd(r&&{url:`${t("/pdf")}?v=${G}`,httpHeaders:{"x-access-code":e}},`${r?.title}-${G}`);if(h)return W.jsxs("main",{className:"note",children:[W.jsx("h1",{children:"Can't open this document"}),W.jsx("p",{children:h})]});if(H)return W.jsxs("main",{className:"note",children:[W.jsx("h1",{children:"You declined to sign"}),W.jsx("p",{children:"The sender has been told. Nobody can sign this document now."})]});if(l.needCode)return W.jsxs("main",{className:"note",children:[W.jsx("h1",{children:"Enter your access code"}),W.jsx("p",{children:"The sender gave you a 6-digit code separately from this link."}),W.jsxs("form",{onSubmit:V,children:[W.jsx("input",{className:"code",inputMode:"numeric",autoComplete:"one-time-code",maxLength:6,value:e,onChange:z=>s(z.target.value.replace(/\D/g,"")),autoFocus:!0}),W.jsx("button",{className:"button",disabled:e.length!==6,children:"Open document"})]}),l.message&&W.jsx("p",{className:"bad",children:l.message})]});if(!r)return W.jsx("main",{className:"note",children:W.jsx("p",{children:"Loading…"})});const mt=!!r.signer.signedAt,yt=r.fields.filter(z=>z.type==="text"||z.type==="initials"),kt=r.fields.some(z=>z.type==="signature"||z.type==="date"),K=(f||!kt)&&yt.every(z=>(E[z.index]||"").trim()),Q=async()=>{I("Checking your location…");const z=await tv();I("Signing…");const k=await $("",{method:"POST",body:JSON.stringify({signaturePng:f,agreed:A,termsVersion:r.terms.version,location:z,values:E})});if(I(null),!k.ok)return p(k.data.error);a(k.data),Y(D=>D+1)},q=async()=>{const z=window.prompt("Decline to sign? Nobody will be able to sign this document afterwards. You can say why:");if(z===null)return;const k=await $("/decline",{method:"POST",body:JSON.stringify({reason:z})});k.ok?F(!0):p(k.data.error)},it=async()=>{const z=await $("/pdf"),k=Object.assign(document.createElement("a"),{href:URL.createObjectURL(z.data),download:`${r.title}.pdf`});k.click(),URL.revokeObjectURL(k.href)};return W.jsxs(W.Fragment,{children:[W.jsxs("header",{className:"bar",children:[W.jsxs("div",{children:[W.jsx("strong",{children:r.title}),W.jsxs("span",{className:"who",children:["Signing as ",r.signer.name," (",r.signer.who,")"]})]}),W.jsxs("div",{className:"row",children:[W.jsxs("button",{className:"plain",onClick:it,children:["Download ",r.completed?"signed copy":"a copy"]}),!mt&&W.jsx("button",{className:"plain",onClick:q,children:"Decline"}),!mt&&W.jsx("button",{className:"button",disabled:!K||!!M,onClick:()=>O(!0),children:M||"Finish signing"})]})]}),mt?W.jsxs("p",{className:"status ok",children:["You signed this document."," ",r.completed?"Everyone has signed; the last page is the signing certificate.":`Still waiting for: ${r.others.filter(z=>!z.signed).map(z=>z.name).join(", ")}.`]}):W.jsx("p",{className:"status hint",children:"Fill in every yellow box, then Finish signing."}),W.jsx("main",{className:"pages",children:at.map((z,k)=>W.jsx(Od,{page:z,children:(D,rt)=>!mt&&r.fields.filter(J=>J.page===k+1).map(J=>{const wt={left:J.x*D,top:(rt-J.y-J.height)*D,width:J.width*D,height:J.height*D};return J.type==="text"||J.type==="initials"?W.jsx("input",{className:`box typed-in ${J.type} ${E[J.index]?"filled":""}`,style:{...wt,fontSize:Math.min(15,J.height*D*.6)},placeholder:J.label||(J.type==="initials"?"Initials":"Type here"),maxLength:J.type==="initials"?6:200,value:E[J.index]||"",onChange:dt=>x(ut=>({...ut,[J.index]:dt.target.value}))},J.index):W.jsx("button",{className:`box ${J.type} ${f?"filled":""}`,style:wt,onClick:()=>J.type!=="date"&&w(!0),children:J.type==="date"?f?Jm():"Date":f?W.jsx("img",{src:f,alt:"Your signature"}):"Sign here"},J.index)})},`${G}-${k}`))}),N&&W.jsx("div",{className:"veil",onClick:()=>O(!1),children:W.jsxs("div",{className:"dialog terms",role:"dialog","aria-modal":"true","aria-label":"Signing terms",onClick:z=>z.stopPropagation(),children:[W.jsx("h2",{children:"Before you sign"}),W.jsx("ul",{children:r.terms.text.map((z,k)=>W.jsx("li",{children:z},k))}),W.jsxs("label",{children:[W.jsx("input",{type:"checkbox",checked:A,onChange:z=>S(z.target.checked)})," I agree to these terms."]}),W.jsx("p",{className:"hint",children:"Next, your browser will ask to share your location. You can say no and still sign; that is recorded too."}),W.jsxs("div",{className:"actions",children:[W.jsx("button",{onClick:()=>O(!1),children:"Back"}),W.jsx("button",{className:"button",disabled:!A,onClick:()=>{O(!1),Q()},children:"Agree and sign"})]})]})}),y&&W.jsx(Zm,{name:r.signer.name,onCancel:()=>w(!1),onDone:z=>{z&&v(z),w(!1)}})]})}const[nv,ad]=location.pathname.split("/").filter(Boolean);Wp.createRoot(document.getElementById("root")).render(nv==="place"?W.jsx(Xm,{id:ad}):W.jsx(ev,{token:ad}));
|