diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/ocrz-app.js b/SGGL/FineUIPro.Web/HJGL/DataImport/ocrz-app.js index 52f3d71d..e1a63d7e 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/ocrz-app.js +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/ocrz-app.js @@ -61,7 +61,7 @@ var e3e=Object.defineProperty;var rR=Mn=>{throw TypeError(Mn)};var t3e=(Mn,In,Qt * vue-router v4.6.4 * (c) 2025 Eduardo San Martin Morote * @license MIT - */let oge=()=>location.protocol+"//"+location.host;function Y7(e,t){const{pathname:n,search:s,hash:a}=t,o=e.indexOf("#");if(o>-1){let r=a.includes(e.slice(o))?e.slice(o).length:1,i=a.slice(r);return i[0]!=="/"&&(i="/"+i),V7(i,"")}return V7(n,e)+s+a}function rge(e,t,n,s){let a=[],o=[],r=null;const i=({state:h})=>{const p=Y7(e,location),v=n.value,m=t.value;let g=0;if(h){if(n.value=p,t.value=h,r&&r===v){r=null;return}g=m?h.position-m.position:0}else s(p);a.forEach(b=>{b(n.value,v,{delta:g,type:z8.pop,direction:g?g>0?H8.forward:H8.back:H8.unknown})})};function l(){r=n.value}function c(h){a.push(h);const p=()=>{const v=a.indexOf(h);v>-1&&a.splice(v,1)};return o.push(p),p}function u(){if(document.visibilityState==="hidden"){const{history:h}=window;if(!h.state)return;h.replaceState(Rn({},h.state,{scroll:q1()}),"")}}function d(){for(const h of o)h();o=[],window.removeEventListener("popstate",i),window.removeEventListener("pagehide",u),document.removeEventListener("visibilitychange",u)}return window.addEventListener("popstate",i),window.addEventListener("pagehide",u),document.addEventListener("visibilitychange",u),{pauseListeners:l,listen:c,destroy:d}}function X7(e,t,n,s=!1,a=!1){return{back:e,current:t,forward:n,replaced:s,position:window.history.length,scroll:a?q1():null}}function ige(e){const{history:t,location:n}=window,s={value:Y7(e,n)},a={value:t.state};a.value||o(s.value,{back:null,current:s.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function o(l,c,u){const d=e.indexOf("#"),h=d>-1?(n.host&&document.querySelector("base")?e:e.slice(d))+l:oge()+e+l;try{t[u?"replaceState":"pushState"](c,"",h),a.value=c}catch(p){console.error(p),n[u?"replace":"assign"](h)}}function r(l,c){o(l,Rn({},t.state,X7(a.value.back,l,a.value.forward,!0),c,{position:a.value.position}),!0),s.value=l}function i(l,c){const u=Rn({},a.value,t.state,{forward:l,scroll:q1()});o(u.current,u,!0),o(l,Rn({},X7(s.value,l,null),{position:u.position+1},c),!1),s.value=l}return{location:s,state:a,push:i,replace:r}}function lge(e){e=K2e(e);const t=ige(e),n=rge(e,t.state,t.location,t.replace);function s(o,r=!0){r||n.pauseListeners(),history.go(o)}const a=Rn({location:"",base:e,go:s,createHref:q2e.bind(null,e)},t,n);return Object.defineProperty(a,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(a,"state",{enumerable:!0,get:()=>t.state.value}),a}function cge(e){return e=location.host?e||location.pathname+location.search:"",e.includes("#")||(e+="#"),lge(e)}let Wu=function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.Group=2]="Group",e}({});var Rs=function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.ParamRegExp=2]="ParamRegExp",e[e.ParamRegExpEnd=3]="ParamRegExpEnd",e[e.EscapeNext=4]="EscapeNext",e}(Rs||{});const uge={type:Wu.Static,value:""},dge=/[a-zA-Z0-9_]/;function fge(e){if(!e)return[[]];if(e==="/")return[[uge]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(p){throw new Error(`ERR (${n})/"${c}": ${p}`)}let n=Rs.Static,s=n;const a=[];let o;function r(){o&&a.push(o),o=[]}let i=0,l,c="",u="";function d(){c&&(n===Rs.Static?o.push({type:Wu.Static,value:c}):n===Rs.Param||n===Rs.ParamRegExp||n===Rs.ParamRegExpEnd?(o.length>1&&(l==="*"||l==="+")&&t(`A repeatable param (${c}) must be alone in its segment. eg: '/:ids+.`),o.push({type:Wu.Param,value:c,regexp:u,repeatable:l==="*"||l==="+",optional:l==="*"||l==="?"})):t("Invalid state to consume buffer"),c="")}function h(){c+=l}for(;it.length?t.length===1&&t[0]===Oa.Static+Oa.Segment?1:-1:0}function Z7(e,t){let n=0;const s=e.score,a=t.score;for(;n0&&t[t.length-1]<0}const gge={strict:!1,end:!0,sensitive:!1};function bge(e,t,n){const s=vge(fge(e.path),n),a=Rn(s,{record:e,parent:t,children:[],alias:[]});return t&&!a.record.aliasOf==!t.record.aliasOf&&t.children.push(a),a}function yge(e,t){const n=[],s=new Map;t=L7(gge,t);function a(d){return s.get(d)}function o(d,h,p){const v=!p,m=tP(d);m.aliasOf=p&&p.record;const g=L7(t,d),b=[m];if("alias"in d){const _=typeof d.alias=="string"?[d.alias]:d.alias;for(const x of _)b.push(tP(Rn({},m,{components:p?p.record.components:m.components,path:x,aliasOf:p?p.record:m})))}let C,w;for(const _ of b){const{path:x}=_;if(h&&x[0]!=="/"){const k=h.record.path,T=k[k.length-1]==="/"?"":"/";_.path=h.record.path+(x&&T+x)}if(C=bge(_,h,g),p?p.alias.push(C):(w=w||C,w!==C&&w.alias.push(C),v&&d.name&&!nP(C)&&r(d.name)),sP(C)&&l(C),m.children){const k=m.children;for(let T=0;T{r(w)}:gv}function r(d){if(j7(d)){const h=s.get(d);h&&(s.delete(d),n.splice(n.indexOf(h),1),h.children.forEach(r),h.alias.forEach(r))}else{const h=n.indexOf(d);h>-1&&(n.splice(h,1),d.record.name&&s.delete(d.record.name),d.children.forEach(r),d.alias.forEach(r))}}function i(){return n}function l(d){const h=Cge(d,n);n.splice(h,0,d),d.record.name&&!nP(d)&&s.set(d.record.name,d)}function c(d,h){let p,v={},m,g;if("name"in d&&d.name){if(p=s.get(d.name),!p)throw dh(hs.MATCHER_NOT_FOUND,{location:d});g=p.record.name,v=Rn(eP(h.params,p.keys.filter(w=>!w.optional).concat(p.parent?p.parent.keys.filter(w=>w.optional):[]).map(w=>w.name)),d.params&&eP(d.params,p.keys.map(w=>w.name))),m=p.stringify(v)}else if(d.path!=null)m=d.path,p=n.find(w=>w.re.test(m)),p&&(v=p.parse(m),g=p.record.name);else{if(p=h.name?s.get(h.name):n.find(w=>w.re.test(h.path)),!p)throw dh(hs.MATCHER_NOT_FOUND,{location:d,currentLocation:h});g=p.record.name,v=Rn({},h.params,d.params),m=p.stringify(v)}const b=[];let C=p;for(;C;)b.unshift(C.record),C=C.parent;return{name:g,path:m,params:v,matched:b,meta:_ge(b)}}e.forEach(d=>o(d));function u(){n.length=0,s.clear()}return{addRoute:o,resolve:c,removeRoute:r,clearRoutes:u,getRoutes:i,getRecordMatcher:a}}function eP(e,t){const n={};for(const s of t)s in e&&(n[s]=e[s]);return n}function tP(e){const t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:wge(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,"mods",{value:{}}),t}function wge(e){const t={},n=e.props||!1;if("component"in e)t.default=n;else for(const s in e.components)t[s]=typeof n=="object"?n[s]:n;return t}function nP(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function _ge(e){return e.reduce((t,n)=>Rn(t,n.meta),{})}function Cge(e,t){let n=0,s=t.length;for(;n!==s;){const o=n+s>>1;Z7(e,t[o])<0?s=o:n=o+1}const a=Sge(e);return a&&(s=t.lastIndexOf(a,s-1)),s}function Sge(e){let t=e;for(;t=t.parent;)if(sP(t)&&Z7(e,t)===0)return t}function sP({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function aP(e){const t=Ke(G1),n=Ke(G7),s=E(()=>{const l=f(e.to);return t.resolve(l)}),a=E(()=>{const{matched:l}=s.value,{length:c}=l,u=l[c-1],d=n.matched;if(!u||!d.length)return-1;const h=d.findIndex(uh.bind(null,u));if(h>-1)return h;const p=oP(l[c-2]);return c>1&&oP(u)===p&&d[d.length-1].path!==p?d.findIndex(uh.bind(null,l[c-2])):h}),o=E(()=>a.value>-1&&Age(n.params,s.value.params)),r=E(()=>a.value>-1&&a.value===n.matched.length-1&&z7(n.params,s.value.params));function i(l={}){if(Ege(l)){const c=t[f(e.replace)?"replace":"push"](f(e.to)).catch(gv);return e.viewTransition&&typeof document<"u"&&"startViewTransition"in document&&document.startViewTransition(()=>c),c}return Promise.resolve()}return{route:s,href:E(()=>s.value.href),isActive:o,isExactActive:r,navigate:i}}function xge(e){return e.length===1?e[0]:e}const kge=j({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"},viewTransition:Boolean},useLink:aP,setup(e,{slots:t}){const n=Yt(aP(e)),{options:s}=Ke(G1),a=E(()=>({[rP(e.activeClass,s.linkActiveClass,"router-link-active")]:n.isActive,[rP(e.exactActiveClass,s.linkExactActiveClass,"router-link-exact-active")]:n.isExactActive}));return()=>{const o=t.default&&xge(t.default(n));return e.custom?o:ut("a",{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:a.value},o)}}});function Ege(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function Age(e,t){for(const n in t){const s=t[n],a=e[n];if(typeof s=="string"){if(s!==a)return!1}else if(!Cr(a)||a.length!==s.length||s.some((o,r)=>o.valueOf()!==a[r].valueOf()))return!1}return!0}function oP(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const rP=(e,t,n)=>e??t??n,Tge=j({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:n}){const s=Ke(j8),a=E(()=>e.route||s.value),o=Ke(q7,0),r=E(()=>{let c=f(o);const{matched:u}=a.value;let d;for(;(d=u[c])&&!d.components;)c++;return c}),i=E(()=>a.value.matched[r.value]);Nt(q7,E(()=>r.value+1)),Nt(sge,i),Nt(j8,a);const l=F();return be(()=>[l.value,i.value,e.name],([c,u,d],[h,p,v])=>{u&&(u.instances[d]=c,p&&p!==u&&c&&c===h&&(u.leaveGuards.size||(u.leaveGuards=p.leaveGuards),u.updateGuards.size||(u.updateGuards=p.updateGuards))),c&&u&&(!p||!uh(u,p)||!h)&&(u.enterCallbacks[d]||[]).forEach(m=>m(c))},{flush:"post"}),()=>{const c=a.value,u=e.name,d=i.value,h=d&&d.components[u];if(!h)return iP(n.default,{Component:h,route:c});const p=d.props[u],v=p?p===!0?c.params:typeof p=="function"?p(c):p:null,g=ut(h,Rn({},v,t,{onVnodeUnmounted:b=>{b.component.isUnmounted&&(d.instances[u]=null)},ref:l}));return iP(n.default,{Component:g,route:c})||g}}});function iP(e,t){if(!e)return null;const n=e(t);return n.length===1?n[0]:n}const Mge=Tge;function Pge(e){const t=yge(e.routes,e),n=e.parseQuery||tge,s=e.stringifyQuery||U7,a=e.history,o=yv(),r=yv(),i=yv(),l=bn(bc);let c=bc;ch&&e.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const u=D8.bind(null,te=>""+te),d=D8.bind(null,F2e),h=D8.bind(null,bv);function p(te,fe){let ve,ce;return j7(te)?(ve=t.getRecordMatcher(te),ce=fe):ce=te,t.addRoute(ce,ve)}function v(te){const fe=t.getRecordMatcher(te);fe&&t.removeRoute(fe)}function m(){return t.getRoutes().map(te=>te.record)}function g(te){return!!t.getRecordMatcher(te)}function b(te,fe){if(fe=Rn({},fe||l.value),typeof te=="string"){const de=V8(n,te,fe.path),ye=t.resolve({path:de.path},fe),_e=a.createHref(de.fullPath);return Rn(de,ye,{params:h(ye.params),hash:bv(de.hash),redirectedFrom:void 0,href:_e})}let ve;if(te.path!=null)ve=Rn({},te,{path:V8(n,te.path,fe.path).path});else{const de=Rn({},te.params);for(const ye in de)de[ye]==null&&delete de[ye];ve=Rn({},te,{params:d(de)}),fe.params=d(fe.params)}const ce=t.resolve(ve,fe),Z=te.hash||"";ce.params=u(h(ce.params));const H=z2e(s,Rn({},te,{hash:N2e(Z),path:ce.path})),ae=a.createHref(H);return Rn({fullPath:H,hash:Z,query:s===U7?nge(te.query):te.query||{}},ce,{redirectedFrom:void 0,href:ae})}function C(te){return typeof te=="string"?V8(n,te,l.value.path):Rn({},te)}function w(te,fe){if(c!==te)return dh(hs.NAVIGATION_CANCELLED,{from:fe,to:te})}function _(te){return T(te)}function x(te){return _(Rn(C(te),{replace:!0}))}function k(te,fe){const ve=te.matched[te.matched.length-1];if(ve&&ve.redirect){const{redirect:ce}=ve;let Z=typeof ce=="function"?ce(te,fe):ce;return typeof Z=="string"&&(Z=Z.includes("?")||Z.includes("#")?Z=C(Z):{path:Z},Z.params={}),Rn({query:te.query,hash:te.hash,params:Z.path!=null?{}:te.params},Z)}}function T(te,fe){const ve=c=b(te),ce=l.value,Z=te.state,H=te.force,ae=te.replace===!0,de=k(ve,ce);if(de)return T(Rn(C(de),{state:typeof de=="object"?Rn({},Z,de.state):Z,force:H,replace:ae}),fe||ve);const ye=ve;ye.redirectedFrom=fe;let _e;return!H&&H2e(s,ce,ve)&&(_e=dh(hs.NAVIGATION_DUPLICATED,{to:ye,from:ce}),q(ce,ce,!0,!1)),(_e?Promise.resolve(_e):R(ye,ce)).catch(Se=>ul(Se)?ul(Se,hs.NAVIGATION_GUARD_REDIRECT)?Se:z(Se):N(Se,ye,ce)).then(Se=>{if(Se){if(ul(Se,hs.NAVIGATION_GUARD_REDIRECT))return T(Rn({replace:ae},C(Se.to),{state:typeof Se.to=="object"?Rn({},Z,Se.to.state):Z,force:H}),fe||ye)}else Se=M(ye,ce,!0,ae,Z);return $(ye,ce,Se),Se})}function I(te,fe){const ve=w(te,fe);return ve?Promise.reject(ve):Promise.resolve()}function O(te){const fe=ee.values().next().value;return fe&&typeof fe.runWithContext=="function"?fe.runWithContext(te):te()}function R(te,fe){let ve;const[ce,Z,H]=age(te,fe);ve=K8(ce.reverse(),"beforeRouteLeave",te,fe);for(const de of ce)de.leaveGuards.forEach(ye=>{ve.push(yc(ye,te,fe))});const ae=I.bind(null,te,fe);return ve.push(ae),pe(ve).then(()=>{ve=[];for(const de of o.list())ve.push(yc(de,te,fe));return ve.push(ae),pe(ve)}).then(()=>{ve=K8(Z,"beforeRouteUpdate",te,fe);for(const de of Z)de.updateGuards.forEach(ye=>{ve.push(yc(ye,te,fe))});return ve.push(ae),pe(ve)}).then(()=>{ve=[];for(const de of H)if(de.beforeEnter)if(Cr(de.beforeEnter))for(const ye of de.beforeEnter)ve.push(yc(ye,te,fe));else ve.push(yc(de.beforeEnter,te,fe));return ve.push(ae),pe(ve)}).then(()=>(te.matched.forEach(de=>de.enterCallbacks={}),ve=K8(H,"beforeRouteEnter",te,fe,O),ve.push(ae),pe(ve))).then(()=>{ve=[];for(const de of r.list())ve.push(yc(de,te,fe));return ve.push(ae),pe(ve)}).catch(de=>ul(de,hs.NAVIGATION_CANCELLED)?de:Promise.reject(de))}function $(te,fe,ve){i.list().forEach(ce=>O(()=>ce(te,fe,ve)))}function M(te,fe,ve,ce,Z){const H=w(te,fe);if(H)return H;const ae=fe===bc,de=ch?history.state:{};ve&&(ce||ae?a.replace(te.fullPath,Rn({scroll:ae&&de&&de.scroll},Z)):a.push(te.fullPath,Z)),l.value=te,q(te,fe,ve,ae),z()}let B;function U(){B||(B=a.listen((te,fe,ve)=>{if(!se.listening)return;const ce=b(te),Z=k(ce,se.currentRoute.value);if(Z){T(Rn(Z,{replace:!0,force:!0}),ce).catch(gv);return}c=ce;const H=l.value;ch&&X2e(W7(H.fullPath,ve.delta),q1()),R(ce,H).catch(ae=>ul(ae,hs.NAVIGATION_ABORTED|hs.NAVIGATION_CANCELLED)?ae:ul(ae,hs.NAVIGATION_GUARD_REDIRECT)?(T(Rn(C(ae.to),{force:!0}),ce).then(de=>{ul(de,hs.NAVIGATION_ABORTED|hs.NAVIGATION_DUPLICATED)&&!ve.delta&&ve.type===z8.pop&&a.go(-1,!1)}).catch(gv),Promise.reject()):(ve.delta&&a.go(-ve.delta,!1),N(ae,ce,H))).then(ae=>{ae=ae||M(ce,H,!1),ae&&(ve.delta&&!ul(ae,hs.NAVIGATION_CANCELLED)?a.go(-ve.delta,!1):ve.type===z8.pop&&ul(ae,hs.NAVIGATION_ABORTED|hs.NAVIGATION_DUPLICATED)&&a.go(-1,!1)),$(ce,H,ae)}).catch(gv)}))}let J=yv(),Y=yv(),L;function N(te,fe,ve){z(te);const ce=Y.list();return ce.length?ce.forEach(Z=>Z(te,fe,ve)):console.error(te),Promise.reject(te)}function V(){return L&&l.value!==bc?Promise.resolve():new Promise((te,fe)=>{J.add([te,fe])})}function z(te){return L||(L=!te,U(),J.list().forEach(([fe,ve])=>te?ve(te):fe()),J.reset()),te}function q(te,fe,ve,ce){const{scrollBehavior:Z}=e;if(!ch||!Z)return Promise.resolve();const H=!ve&&J2e(W7(te.fullPath,0))||(ce||!ve)&&history.state&&history.state.scroll||null;return ze().then(()=>Z(te,fe,H)).then(ae=>ae&&Y2e(ae)).catch(ae=>N(ae,te,fe))}const Q=te=>a.go(te);let K;const ee=new Set,se={currentRoute:l,listening:!0,addRoute:p,removeRoute:v,clearRoutes:t.clearRoutes,hasRoute:g,getRoutes:m,resolve:b,options:e,push:_,replace:x,go:Q,back:()=>Q(-1),forward:()=>Q(1),beforeEach:o.add,beforeResolve:r.add,afterEach:i.add,onError:Y.add,isReady:V,install(te){te.component("RouterLink",kge),te.component("RouterView",Mge),te.config.globalProperties.$router=se,Object.defineProperty(te.config.globalProperties,"$route",{enumerable:!0,get:()=>f(l)}),ch&&!K&&l.value===bc&&(K=!0,_(a.location).catch(ce=>{}));const fe={};for(const ce in bc)Object.defineProperty(fe,ce,{get:()=>l.value[ce],enumerable:!0});te.provide(G1,se),te.provide(G7,L2(fe)),te.provide(j8,l);const ve=te.unmount;ee.add(te),te.unmount=function(){ee.delete(te),ee.size<1&&(c=bc,B&&B(),B=null,l.value=bc,K=!1,L=!1),ve()}}};function pe(te){return te.reduce((fe,ve)=>fe.then(()=>O(ve)),Promise.resolve())}return se}function lP(){return Ke(G1)}const Rge={class:"card-title"},Ige={class:"batch-area"},Oge={class:"batch-input-row"},Lge={key:0,class:"batch-preview"},Nge={class:"batch-summary"},$ge={class:"batch-limit-row"},Dge={key:0,class:"batch-more-hint"},Fge={key:1,class:"batch-empty"},Bge={class:"option-row"},Vge={class:"mode-hint"},zge={class:"option-row"},Hge={class:"option-row"},Wge={class:"submit-row"},jge=cl({__name:"FileUpload",emits:["submit"],setup(e,{emit:t}){const n=t,s=F("file"),a=F([]),o=F(null),r=F(""),i=F(["excel","json"]),l=F("drawing"),c=F(!0),u=F(null),d=F(null),h=F(null),p=F([]),v=F(200),m=E(()=>p.value.slice(0,v.value).map(O=>({name:O.webkitRelativePath||O.name,size:g(O.size),raw:O})));function g(O){return O<1024?`${O} B`:O<1024*1024?`${(O/1024).toFixed(1)} KB`:`${(O/(1024*1024)).toFixed(1)} MB`}function b(){var O;(O=d.value)==null||O.click()}function C(){var O;(O=h.value)==null||O.click()}function w(O){const R=Array.from(O.target.files||[]).filter($=>$.name.toLowerCase().endsWith(".pdf"));if(!R.length){ts.warning("未找到 PDF 文件");return}p.value=R,v.value=R.length,O.target.value=""}function _(){p.value=[],v.value=200}const x=E(()=>i.value.length===0?!1:s.value==="file"?!!o.value:s.value==="url"?r.value.trim().startsWith("http"):s.value==="batch"?p.value.length>0:!1);function k(O){o.value=O.raw,a.value=[O]}function T(){ts.warning("只能上传一个 PDF 文件,请先移除后再添加")}function I(){if(x.value){if(s.value==="batch"){const O=p.value.slice(0,v.value);n("submit",{file:null,url:null,files:O,formats:i.value,mode:l.value,autoCorrect:c.value,maxConcurrent:40,batch:!0});return}n("submit",{file:s.value==="file"?o.value:null,url:s.value==="url"?r.value.trim():null,files:null,formats:i.value,mode:l.value,autoCorrect:c.value,maxConcurrent:40,batch:!1})}}return(O,R)=>{const $=Ge("Upload"),M=Ge("el-icon"),B=Ge("UploadFilled"),U=Ge("el-upload"),J=Ge("el-tab-pane"),Y=Ge("Link"),L=Ge("el-input"),N=Ge("el-button"),V=Ge("el-tag"),z=Ge("el-input-number"),q=Ge("el-table-column"),Q=Ge("el-table"),K=Ge("el-tabs"),ee=Ge("el-radio-button"),se=Ge("el-radio-group"),pe=Ge("el-switch"),te=Ge("Grid"),fe=Ge("el-checkbox"),ve=Ge("DataLine"),ce=Ge("el-checkbox-group"),Z=Ge("el-card");return S(),le(Z,{class:"upload-card",shadow:"never"},{header:X(()=>[A("div",Rge,[W(M,null,{default:X(()=>[W($)]),_:1}),R[7]||(R[7]=A("span",null,"上传 PDF 文件",-1))])]),default:X(()=>[W(K,{modelValue:s.value,"onUpdate:modelValue":R[3]||(R[3]=H=>s.value=H),class:"upload-tabs"},{default:X(()=>[W(J,{label:"本地上传",name:"file"},{default:X(()=>[W(U,{ref_key:"uploadRef",ref:u,class:"drop-area",drag:"","auto-upload":!1,accept:".pdf",limit:1,"on-change":k,"on-exceed":T,"file-list":a.value},{tip:X(()=>[...R[8]||(R[8]=[A("div",{class:"upload-tip"},"支持单个 PDF 文件,最大 500MB",-1)])]),default:X(()=>[W(M,{class:"upload-icon"},{default:X(()=>[W(B)]),_:1}),R[9]||(R[9]=A("div",{class:"upload-text"},[je("拖拽 PDF 文件到此处,或 "),A("em",null,"点击选择")],-1))]),_:1},8,["file-list"])]),_:1}),W(J,{label:"网络 URL",name:"url"},{default:X(()=>[W(L,{modelValue:r.value,"onUpdate:modelValue":R[0]||(R[0]=H=>r.value=H),placeholder:"输入 PDF 文件的网络地址,例如 https://example.com/file.pdf",clearable:"",size:"large"},{prepend:X(()=>[W(M,null,{default:X(()=>[W(Y)]),_:1})]),_:1},8,["modelValue"])]),_:1}),W(J,{label:"批量解析",name:"batch"},{default:X(()=>[A("div",Ige,[A("div",Oge,[W(N,{icon:f(Ag),onClick:b},{default:X(()=>[...R[10]||(R[10]=[je(" 选择文件夹 ",-1)])]),_:1},8,["icon"]),W(N,{icon:f(Yx),onClick:C},{default:X(()=>[...R[11]||(R[11]=[je(" 选择多个文件 ",-1)])]),_:1},8,["icon"]),A("input",{ref_key:"folderInputRef",ref:d,type:"file",accept:".pdf",webkitdirectory:"",multiple:"",style:{display:"none"},onChange:w},null,544),A("input",{ref_key:"multiInputRef",ref:h,type:"file",accept:".pdf",multiple:"",style:{display:"none"},onChange:w},null,544)]),p.value.length?(S(),P("div",Lge,[A("div",Nge,[W(V,{type:"success"},{default:X(()=>[je(" 共检测到 "+ge(p.value.length)+" 个 PDF 文件 ",1)]),_:1}),p.value.length>v.value?(S(),le(V,{key:0,type:"warning"},{default:X(()=>[je(" 当前限制解析前 "+ge(v.value)+" 个 ",1)]),_:1})):ie("",!0),A("div",$ge,[R[13]||(R[13]=A("span",{class:"option-label"},"解析数量:",-1)),W(z,{modelValue:v.value,"onUpdate:modelValue":R[1]||(R[1]=H=>v.value=H),min:1,max:p.value.length,size:"small",step:10,style:{width:"120px"}},null,8,["modelValue","max"]),W(N,{size:"small",text:"",onClick:R[2]||(R[2]=H=>v.value=p.value.length)},{default:X(()=>[...R[12]||(R[12]=[je("全部",-1)])]),_:1})])]),W(Q,{data:m.value,size:"small","max-height":"200",class:"batch-table","highlight-current-row":""},{default:X(()=>[W(q,{type:"index",width:"50",label:"#"}),W(q,{prop:"name",label:"文件名","show-overflow-tooltip":""}),W(q,{prop:"size",label:"大小",width:"90",align:"right"})]),_:1},8,["data"]),p.value.length>v.value?(S(),P("div",Dge," ... 还有 "+ge(p.value.length-v.value)+" 个文件未显示(超出解析数量限制) ",1)):ie("",!0),W(N,{size:"small",text:"",type:"danger",onClick:_,class:"batch-clear-btn"},{default:X(()=>[...R[14]||(R[14]=[je("清除",-1)])]),_:1})])):(S(),P("div",Fge,[W(M,{size:"40",color:"#c0c4cc"},{default:X(()=>[W(f(Ag))]),_:1}),R[15]||(R[15]=A("p",null,"选择包含 PDF 的文件夹,或直接选择多个 PDF 文件",-1)),R[16]||(R[16]=A("p",{class:"batch-hint"},"支持 100+ 文件批量处理,逐文件顺序解析",-1))]))])]),_:1})]),_:1},8,["modelValue"]),A("div",Bge,[R[19]||(R[19]=A("span",{class:"option-label"},"识别模式:",-1)),W(se,{modelValue:l.value,"onUpdate:modelValue":R[4]||(R[4]=H=>l.value=H),size:"small"},{default:X(()=>[W(ee,{value:"drawing"},{default:X(()=>[...R[17]||(R[17]=[je("图纸模式",-1)])]),_:1}),W(ee,{value:"auto"},{default:X(()=>[...R[18]||(R[18]=[je("自动识别",-1)])]),_:1})]),_:1},8,["modelValue"]),A("span",Vge,ge(l.value==="drawing"?"管道轴测图:每页均为图纸,复用第1页区域配置,40并发高速识别":"VL 自动分类:图纸页专项裁剪,文字页通用识别,40并发"),1)]),A("div",zge,[R[20]||(R[20]=A("span",{class:"option-label"},"自动纠错:",-1)),W(pe,{modelValue:c.value,"onUpdate:modelValue":R[5]||(R[5]=H=>c.value=H),"active-text":"启用","inactive-text":"关闭"},null,8,["modelValue"]),R[21]||(R[21]=A("span",{class:"mode-hint"},"识别完成后调用 LLM 对结果进行连续性校验与自动修正",-1))]),A("div",Hge,[R[24]||(R[24]=A("span",{class:"option-label"},"导出格式:",-1)),W(ce,{modelValue:i.value,"onUpdate:modelValue":R[6]||(R[6]=H=>i.value=H)},{default:X(()=>[W(fe,{value:"excel",label:"excel"},{default:X(()=>[W(M,null,{default:X(()=>[W(te)]),_:1}),R[22]||(R[22]=je(" Excel ",-1))]),_:1}),W(fe,{value:"json",label:"json"},{default:X(()=>[W(M,null,{default:X(()=>[W(ve)]),_:1}),R[23]||(R[23]=je(" JSON ",-1))]),_:1})]),_:1},8,["modelValue"])]),A("div",Wge,[W(N,{type:"primary",size:"large",disabled:!x.value,icon:s.value==="batch"?f(Vy):f(s9),onClick:I},{default:X(()=>[je(ge(s.value==="batch"?`批量解析 ${Math.min(v.value,p.value.length)} 个文件`:"开始识别"),1)]),_:1},8,["disabled","icon"])])]),_:1})}}},[["__scopeId","data-v-a0c75cf1"]]),Y1="http://47.104.102.122:8000/api/ocr";function Kge(e,t=["excel","json"],n,s="drawing",a=!0,o=null){const r=new FormData;r.append("file",e),r.append("export_formats",t.join(",")),r.append("pdf_mode",s),r.append("auto_correct",a?"true":"false"),o&&r.append("max_concurrent",String(o));const i=new AbortController;return fetch(`${Y1}/upload`,{method:"POST",body:r,signal:i.signal}).then(l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);return U8(l,n)}).catch(l=>{l.name!=="AbortError"&&n({type:"error",data:{message:l.message}})}),()=>i.abort()}function Uge(e,t=["excel","json"],n,s="drawing",a=!0){const o=new AbortController;return fetch(`${Y1}/url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e,export_formats:t,pdf_mode:s,auto_correct:a}),signal:o.signal}).then(r=>{if(!r.ok)throw new Error(`HTTP ${r.status}`);return U8(r,n)}).catch(r=>{r.name!=="AbortError"&&n({type:"error",data:{message:r.message}})}),()=>o.abort()}async function U8(e,t){const n=e.body.getReader(),s=new TextDecoder;let a="";for(;;){const{done:o,value:r}=await n.read();if(o)break;a+=s.decode(r,{stream:!0});const i=a.split(` + */let oge=()=>location.protocol+"//"+location.host;function Y7(e,t){const{pathname:n,search:s,hash:a}=t,o=e.indexOf("#");if(o>-1){let r=a.includes(e.slice(o))?e.slice(o).length:1,i=a.slice(r);return i[0]!=="/"&&(i="/"+i),V7(i,"")}return V7(n,e)+s+a}function rge(e,t,n,s){let a=[],o=[],r=null;const i=({state:h})=>{const p=Y7(e,location),v=n.value,m=t.value;let g=0;if(h){if(n.value=p,t.value=h,r&&r===v){r=null;return}g=m?h.position-m.position:0}else s(p);a.forEach(b=>{b(n.value,v,{delta:g,type:z8.pop,direction:g?g>0?H8.forward:H8.back:H8.unknown})})};function l(){r=n.value}function c(h){a.push(h);const p=()=>{const v=a.indexOf(h);v>-1&&a.splice(v,1)};return o.push(p),p}function u(){if(document.visibilityState==="hidden"){const{history:h}=window;if(!h.state)return;h.replaceState(Rn({},h.state,{scroll:q1()}),"")}}function d(){for(const h of o)h();o=[],window.removeEventListener("popstate",i),window.removeEventListener("pagehide",u),document.removeEventListener("visibilitychange",u)}return window.addEventListener("popstate",i),window.addEventListener("pagehide",u),document.addEventListener("visibilitychange",u),{pauseListeners:l,listen:c,destroy:d}}function X7(e,t,n,s=!1,a=!1){return{back:e,current:t,forward:n,replaced:s,position:window.history.length,scroll:a?q1():null}}function ige(e){const{history:t,location:n}=window,s={value:Y7(e,n)},a={value:t.state};a.value||o(s.value,{back:null,current:s.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function o(l,c,u){const d=e.indexOf("#"),h=d>-1?(n.host&&document.querySelector("base")?e:e.slice(d))+l:oge()+e+l;try{t[u?"replaceState":"pushState"](c,"",h),a.value=c}catch(p){console.error(p),n[u?"replace":"assign"](h)}}function r(l,c){o(l,Rn({},t.state,X7(a.value.back,l,a.value.forward,!0),c,{position:a.value.position}),!0),s.value=l}function i(l,c){const u=Rn({},a.value,t.state,{forward:l,scroll:q1()});o(u.current,u,!0),o(l,Rn({},X7(s.value,l,null),{position:u.position+1},c),!1),s.value=l}return{location:s,state:a,push:i,replace:r}}function lge(e){e=K2e(e);const t=ige(e),n=rge(e,t.state,t.location,t.replace);function s(o,r=!0){r||n.pauseListeners(),history.go(o)}const a=Rn({location:"",base:e,go:s,createHref:q2e.bind(null,e)},t,n);return Object.defineProperty(a,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(a,"state",{enumerable:!0,get:()=>t.state.value}),a}function cge(e){return e=location.host?e||location.pathname+location.search:"",e.includes("#")||(e+="#"),lge(e)}let Wu=function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.Group=2]="Group",e}({});var Rs=function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.ParamRegExp=2]="ParamRegExp",e[e.ParamRegExpEnd=3]="ParamRegExpEnd",e[e.EscapeNext=4]="EscapeNext",e}(Rs||{});const uge={type:Wu.Static,value:""},dge=/[a-zA-Z0-9_]/;function fge(e){if(!e)return[[]];if(e==="/")return[[uge]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(p){throw new Error(`ERR (${n})/"${c}": ${p}`)}let n=Rs.Static,s=n;const a=[];let o;function r(){o&&a.push(o),o=[]}let i=0,l,c="",u="";function d(){c&&(n===Rs.Static?o.push({type:Wu.Static,value:c}):n===Rs.Param||n===Rs.ParamRegExp||n===Rs.ParamRegExpEnd?(o.length>1&&(l==="*"||l==="+")&&t(`A repeatable param (${c}) must be alone in its segment. eg: '/:ids+.`),o.push({type:Wu.Param,value:c,regexp:u,repeatable:l==="*"||l==="+",optional:l==="*"||l==="?"})):t("Invalid state to consume buffer"),c="")}function h(){c+=l}for(;it.length?t.length===1&&t[0]===Oa.Static+Oa.Segment?1:-1:0}function Z7(e,t){let n=0;const s=e.score,a=t.score;for(;n0&&t[t.length-1]<0}const gge={strict:!1,end:!0,sensitive:!1};function bge(e,t,n){const s=vge(fge(e.path),n),a=Rn(s,{record:e,parent:t,children:[],alias:[]});return t&&!a.record.aliasOf==!t.record.aliasOf&&t.children.push(a),a}function yge(e,t){const n=[],s=new Map;t=L7(gge,t);function a(d){return s.get(d)}function o(d,h,p){const v=!p,m=tP(d);m.aliasOf=p&&p.record;const g=L7(t,d),b=[m];if("alias"in d){const _=typeof d.alias=="string"?[d.alias]:d.alias;for(const x of _)b.push(tP(Rn({},m,{components:p?p.record.components:m.components,path:x,aliasOf:p?p.record:m})))}let C,w;for(const _ of b){const{path:x}=_;if(h&&x[0]!=="/"){const k=h.record.path,T=k[k.length-1]==="/"?"":"/";_.path=h.record.path+(x&&T+x)}if(C=bge(_,h,g),p?p.alias.push(C):(w=w||C,w!==C&&w.alias.push(C),v&&d.name&&!nP(C)&&r(d.name)),sP(C)&&l(C),m.children){const k=m.children;for(let T=0;T{r(w)}:gv}function r(d){if(j7(d)){const h=s.get(d);h&&(s.delete(d),n.splice(n.indexOf(h),1),h.children.forEach(r),h.alias.forEach(r))}else{const h=n.indexOf(d);h>-1&&(n.splice(h,1),d.record.name&&s.delete(d.record.name),d.children.forEach(r),d.alias.forEach(r))}}function i(){return n}function l(d){const h=Cge(d,n);n.splice(h,0,d),d.record.name&&!nP(d)&&s.set(d.record.name,d)}function c(d,h){let p,v={},m,g;if("name"in d&&d.name){if(p=s.get(d.name),!p)throw dh(hs.MATCHER_NOT_FOUND,{location:d});g=p.record.name,v=Rn(eP(h.params,p.keys.filter(w=>!w.optional).concat(p.parent?p.parent.keys.filter(w=>w.optional):[]).map(w=>w.name)),d.params&&eP(d.params,p.keys.map(w=>w.name))),m=p.stringify(v)}else if(d.path!=null)m=d.path,p=n.find(w=>w.re.test(m)),p&&(v=p.parse(m),g=p.record.name);else{if(p=h.name?s.get(h.name):n.find(w=>w.re.test(h.path)),!p)throw dh(hs.MATCHER_NOT_FOUND,{location:d,currentLocation:h});g=p.record.name,v=Rn({},h.params,d.params),m=p.stringify(v)}const b=[];let C=p;for(;C;)b.unshift(C.record),C=C.parent;return{name:g,path:m,params:v,matched:b,meta:_ge(b)}}e.forEach(d=>o(d));function u(){n.length=0,s.clear()}return{addRoute:o,resolve:c,removeRoute:r,clearRoutes:u,getRoutes:i,getRecordMatcher:a}}function eP(e,t){const n={};for(const s of t)s in e&&(n[s]=e[s]);return n}function tP(e){const t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:wge(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,"mods",{value:{}}),t}function wge(e){const t={},n=e.props||!1;if("component"in e)t.default=n;else for(const s in e.components)t[s]=typeof n=="object"?n[s]:n;return t}function nP(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function _ge(e){return e.reduce((t,n)=>Rn(t,n.meta),{})}function Cge(e,t){let n=0,s=t.length;for(;n!==s;){const o=n+s>>1;Z7(e,t[o])<0?s=o:n=o+1}const a=Sge(e);return a&&(s=t.lastIndexOf(a,s-1)),s}function Sge(e){let t=e;for(;t=t.parent;)if(sP(t)&&Z7(e,t)===0)return t}function sP({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function aP(e){const t=Ke(G1),n=Ke(G7),s=E(()=>{const l=f(e.to);return t.resolve(l)}),a=E(()=>{const{matched:l}=s.value,{length:c}=l,u=l[c-1],d=n.matched;if(!u||!d.length)return-1;const h=d.findIndex(uh.bind(null,u));if(h>-1)return h;const p=oP(l[c-2]);return c>1&&oP(u)===p&&d[d.length-1].path!==p?d.findIndex(uh.bind(null,l[c-2])):h}),o=E(()=>a.value>-1&&Age(n.params,s.value.params)),r=E(()=>a.value>-1&&a.value===n.matched.length-1&&z7(n.params,s.value.params));function i(l={}){if(Ege(l)){const c=t[f(e.replace)?"replace":"push"](f(e.to)).catch(gv);return e.viewTransition&&typeof document<"u"&&"startViewTransition"in document&&document.startViewTransition(()=>c),c}return Promise.resolve()}return{route:s,href:E(()=>s.value.href),isActive:o,isExactActive:r,navigate:i}}function xge(e){return e.length===1?e[0]:e}const kge=j({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"},viewTransition:Boolean},useLink:aP,setup(e,{slots:t}){const n=Yt(aP(e)),{options:s}=Ke(G1),a=E(()=>({[rP(e.activeClass,s.linkActiveClass,"router-link-active")]:n.isActive,[rP(e.exactActiveClass,s.linkExactActiveClass,"router-link-exact-active")]:n.isExactActive}));return()=>{const o=t.default&&xge(t.default(n));return e.custom?o:ut("a",{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:a.value},o)}}});function Ege(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function Age(e,t){for(const n in t){const s=t[n],a=e[n];if(typeof s=="string"){if(s!==a)return!1}else if(!Cr(a)||a.length!==s.length||s.some((o,r)=>o.valueOf()!==a[r].valueOf()))return!1}return!0}function oP(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const rP=(e,t,n)=>e??t??n,Tge=j({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:n}){const s=Ke(j8),a=E(()=>e.route||s.value),o=Ke(q7,0),r=E(()=>{let c=f(o);const{matched:u}=a.value;let d;for(;(d=u[c])&&!d.components;)c++;return c}),i=E(()=>a.value.matched[r.value]);Nt(q7,E(()=>r.value+1)),Nt(sge,i),Nt(j8,a);const l=F();return be(()=>[l.value,i.value,e.name],([c,u,d],[h,p,v])=>{u&&(u.instances[d]=c,p&&p!==u&&c&&c===h&&(u.leaveGuards.size||(u.leaveGuards=p.leaveGuards),u.updateGuards.size||(u.updateGuards=p.updateGuards))),c&&u&&(!p||!uh(u,p)||!h)&&(u.enterCallbacks[d]||[]).forEach(m=>m(c))},{flush:"post"}),()=>{const c=a.value,u=e.name,d=i.value,h=d&&d.components[u];if(!h)return iP(n.default,{Component:h,route:c});const p=d.props[u],v=p?p===!0?c.params:typeof p=="function"?p(c):p:null,g=ut(h,Rn({},v,t,{onVnodeUnmounted:b=>{b.component.isUnmounted&&(d.instances[u]=null)},ref:l}));return iP(n.default,{Component:g,route:c})||g}}});function iP(e,t){if(!e)return null;const n=e(t);return n.length===1?n[0]:n}const Mge=Tge;function Pge(e){const t=yge(e.routes,e),n=e.parseQuery||tge,s=e.stringifyQuery||U7,a=e.history,o=yv(),r=yv(),i=yv(),l=bn(bc);let c=bc;ch&&e.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const u=D8.bind(null,te=>""+te),d=D8.bind(null,F2e),h=D8.bind(null,bv);function p(te,fe){let ve,ce;return j7(te)?(ve=t.getRecordMatcher(te),ce=fe):ce=te,t.addRoute(ce,ve)}function v(te){const fe=t.getRecordMatcher(te);fe&&t.removeRoute(fe)}function m(){return t.getRoutes().map(te=>te.record)}function g(te){return!!t.getRecordMatcher(te)}function b(te,fe){if(fe=Rn({},fe||l.value),typeof te=="string"){const de=V8(n,te,fe.path),ye=t.resolve({path:de.path},fe),_e=a.createHref(de.fullPath);return Rn(de,ye,{params:h(ye.params),hash:bv(de.hash),redirectedFrom:void 0,href:_e})}let ve;if(te.path!=null)ve=Rn({},te,{path:V8(n,te.path,fe.path).path});else{const de=Rn({},te.params);for(const ye in de)de[ye]==null&&delete de[ye];ve=Rn({},te,{params:d(de)}),fe.params=d(fe.params)}const ce=t.resolve(ve,fe),Z=te.hash||"";ce.params=u(h(ce.params));const H=z2e(s,Rn({},te,{hash:N2e(Z),path:ce.path})),ae=a.createHref(H);return Rn({fullPath:H,hash:Z,query:s===U7?nge(te.query):te.query||{}},ce,{redirectedFrom:void 0,href:ae})}function C(te){return typeof te=="string"?V8(n,te,l.value.path):Rn({},te)}function w(te,fe){if(c!==te)return dh(hs.NAVIGATION_CANCELLED,{from:fe,to:te})}function _(te){return T(te)}function x(te){return _(Rn(C(te),{replace:!0}))}function k(te,fe){const ve=te.matched[te.matched.length-1];if(ve&&ve.redirect){const{redirect:ce}=ve;let Z=typeof ce=="function"?ce(te,fe):ce;return typeof Z=="string"&&(Z=Z.includes("?")||Z.includes("#")?Z=C(Z):{path:Z},Z.params={}),Rn({query:te.query,hash:te.hash,params:Z.path!=null?{}:te.params},Z)}}function T(te,fe){const ve=c=b(te),ce=l.value,Z=te.state,H=te.force,ae=te.replace===!0,de=k(ve,ce);if(de)return T(Rn(C(de),{state:typeof de=="object"?Rn({},Z,de.state):Z,force:H,replace:ae}),fe||ve);const ye=ve;ye.redirectedFrom=fe;let _e;return!H&&H2e(s,ce,ve)&&(_e=dh(hs.NAVIGATION_DUPLICATED,{to:ye,from:ce}),q(ce,ce,!0,!1)),(_e?Promise.resolve(_e):R(ye,ce)).catch(Se=>ul(Se)?ul(Se,hs.NAVIGATION_GUARD_REDIRECT)?Se:z(Se):N(Se,ye,ce)).then(Se=>{if(Se){if(ul(Se,hs.NAVIGATION_GUARD_REDIRECT))return T(Rn({replace:ae},C(Se.to),{state:typeof Se.to=="object"?Rn({},Z,Se.to.state):Z,force:H}),fe||ye)}else Se=M(ye,ce,!0,ae,Z);return $(ye,ce,Se),Se})}function I(te,fe){const ve=w(te,fe);return ve?Promise.reject(ve):Promise.resolve()}function O(te){const fe=ee.values().next().value;return fe&&typeof fe.runWithContext=="function"?fe.runWithContext(te):te()}function R(te,fe){let ve;const[ce,Z,H]=age(te,fe);ve=K8(ce.reverse(),"beforeRouteLeave",te,fe);for(const de of ce)de.leaveGuards.forEach(ye=>{ve.push(yc(ye,te,fe))});const ae=I.bind(null,te,fe);return ve.push(ae),pe(ve).then(()=>{ve=[];for(const de of o.list())ve.push(yc(de,te,fe));return ve.push(ae),pe(ve)}).then(()=>{ve=K8(Z,"beforeRouteUpdate",te,fe);for(const de of Z)de.updateGuards.forEach(ye=>{ve.push(yc(ye,te,fe))});return ve.push(ae),pe(ve)}).then(()=>{ve=[];for(const de of H)if(de.beforeEnter)if(Cr(de.beforeEnter))for(const ye of de.beforeEnter)ve.push(yc(ye,te,fe));else ve.push(yc(de.beforeEnter,te,fe));return ve.push(ae),pe(ve)}).then(()=>(te.matched.forEach(de=>de.enterCallbacks={}),ve=K8(H,"beforeRouteEnter",te,fe,O),ve.push(ae),pe(ve))).then(()=>{ve=[];for(const de of r.list())ve.push(yc(de,te,fe));return ve.push(ae),pe(ve)}).catch(de=>ul(de,hs.NAVIGATION_CANCELLED)?de:Promise.reject(de))}function $(te,fe,ve){i.list().forEach(ce=>O(()=>ce(te,fe,ve)))}function M(te,fe,ve,ce,Z){const H=w(te,fe);if(H)return H;const ae=fe===bc,de=ch?history.state:{};ve&&(ce||ae?a.replace(te.fullPath,Rn({scroll:ae&&de&&de.scroll},Z)):a.push(te.fullPath,Z)),l.value=te,q(te,fe,ve,ae),z()}let B;function U(){B||(B=a.listen((te,fe,ve)=>{if(!se.listening)return;const ce=b(te),Z=k(ce,se.currentRoute.value);if(Z){T(Rn(Z,{replace:!0,force:!0}),ce).catch(gv);return}c=ce;const H=l.value;ch&&X2e(W7(H.fullPath,ve.delta),q1()),R(ce,H).catch(ae=>ul(ae,hs.NAVIGATION_ABORTED|hs.NAVIGATION_CANCELLED)?ae:ul(ae,hs.NAVIGATION_GUARD_REDIRECT)?(T(Rn(C(ae.to),{force:!0}),ce).then(de=>{ul(de,hs.NAVIGATION_ABORTED|hs.NAVIGATION_DUPLICATED)&&!ve.delta&&ve.type===z8.pop&&a.go(-1,!1)}).catch(gv),Promise.reject()):(ve.delta&&a.go(-ve.delta,!1),N(ae,ce,H))).then(ae=>{ae=ae||M(ce,H,!1),ae&&(ve.delta&&!ul(ae,hs.NAVIGATION_CANCELLED)?a.go(-ve.delta,!1):ve.type===z8.pop&&ul(ae,hs.NAVIGATION_ABORTED|hs.NAVIGATION_DUPLICATED)&&a.go(-1,!1)),$(ce,H,ae)}).catch(gv)}))}let J=yv(),Y=yv(),L;function N(te,fe,ve){z(te);const ce=Y.list();return ce.length?ce.forEach(Z=>Z(te,fe,ve)):console.error(te),Promise.reject(te)}function V(){return L&&l.value!==bc?Promise.resolve():new Promise((te,fe)=>{J.add([te,fe])})}function z(te){return L||(L=!te,U(),J.list().forEach(([fe,ve])=>te?ve(te):fe()),J.reset()),te}function q(te,fe,ve,ce){const{scrollBehavior:Z}=e;if(!ch||!Z)return Promise.resolve();const H=!ve&&J2e(W7(te.fullPath,0))||(ce||!ve)&&history.state&&history.state.scroll||null;return ze().then(()=>Z(te,fe,H)).then(ae=>ae&&Y2e(ae)).catch(ae=>N(ae,te,fe))}const Q=te=>a.go(te);let K;const ee=new Set,se={currentRoute:l,listening:!0,addRoute:p,removeRoute:v,clearRoutes:t.clearRoutes,hasRoute:g,getRoutes:m,resolve:b,options:e,push:_,replace:x,go:Q,back:()=>Q(-1),forward:()=>Q(1),beforeEach:o.add,beforeResolve:r.add,afterEach:i.add,onError:Y.add,isReady:V,install(te){te.component("RouterLink",kge),te.component("RouterView",Mge),te.config.globalProperties.$router=se,Object.defineProperty(te.config.globalProperties,"$route",{enumerable:!0,get:()=>f(l)}),ch&&!K&&l.value===bc&&(K=!0,_(a.location).catch(ce=>{}));const fe={};for(const ce in bc)Object.defineProperty(fe,ce,{get:()=>l.value[ce],enumerable:!0});te.provide(G1,se),te.provide(G7,L2(fe)),te.provide(j8,l);const ve=te.unmount;ee.add(te),te.unmount=function(){ee.delete(te),ee.size<1&&(c=bc,B&&B(),B=null,l.value=bc,K=!1,L=!1),ve()}}};function pe(te){return te.reduce((fe,ve)=>fe.then(()=>O(ve)),Promise.resolve())}return se}function lP(){return Ke(G1)}const Rge={class:"card-title"},Ige={class:"batch-area"},Oge={class:"batch-input-row"},Lge={key:0,class:"batch-preview"},Nge={class:"batch-summary"},$ge={class:"batch-limit-row"},Dge={key:0,class:"batch-more-hint"},Fge={key:1,class:"batch-empty"},Bge={class:"option-row"},Vge={class:"mode-hint"},zge={class:"option-row"},Hge={class:"option-row"},Wge={class:"submit-row"},jge=cl({__name:"FileUpload",emits:["submit"],setup(e,{emit:t}){const n=t,s=F("file"),a=F([]),o=F(null),r=F(""),i=F(["excel","json"]),l=F("drawing"),c=F(!0),u=F(null),d=F(null),h=F(null),p=F([]),v=F(200),m=E(()=>p.value.slice(0,v.value).map(O=>({name:O.webkitRelativePath||O.name,size:g(O.size),raw:O})));function g(O){return O<1024?`${O} B`:O<1024*1024?`${(O/1024).toFixed(1)} KB`:`${(O/(1024*1024)).toFixed(1)} MB`}function b(){var O;(O=d.value)==null||O.click()}function C(){var O;(O=h.value)==null||O.click()}function w(O){const R=Array.from(O.target.files||[]).filter($=>$.name.toLowerCase().endsWith(".pdf"));if(!R.length){ts.warning("未找到 PDF 文件");return}p.value=R,v.value=R.length,O.target.value=""}function _(){p.value=[],v.value=200}const x=E(()=>i.value.length===0?!1:s.value==="file"?!!o.value:s.value==="url"?r.value.trim().startsWith("http"):s.value==="batch"?p.value.length>0:!1);function k(O){o.value=O.raw,a.value=[O]}function T(){ts.warning("只能上传一个 PDF 文件,请先移除后再添加")}function I(){if(x.value){if(s.value==="batch"){const O=p.value.slice(0,v.value);n("submit",{file:null,url:null,files:O,formats:i.value,mode:l.value,autoCorrect:c.value,maxConcurrent:40,batch:!0});return}n("submit",{file:s.value==="file"?o.value:null,url:s.value==="url"?r.value.trim():null,files:null,formats:i.value,mode:l.value,autoCorrect:c.value,maxConcurrent:40,batch:!1})}}return(O,R)=>{const $=Ge("Upload"),M=Ge("el-icon"),B=Ge("UploadFilled"),U=Ge("el-upload"),J=Ge("el-tab-pane"),Y=Ge("Link"),L=Ge("el-input"),N=Ge("el-button"),V=Ge("el-tag"),z=Ge("el-input-number"),q=Ge("el-table-column"),Q=Ge("el-table"),K=Ge("el-tabs"),ee=Ge("el-radio-button"),se=Ge("el-radio-group"),pe=Ge("el-switch"),te=Ge("Grid"),fe=Ge("el-checkbox"),ve=Ge("DataLine"),ce=Ge("el-checkbox-group"),Z=Ge("el-card");return S(),le(Z,{class:"upload-card",shadow:"never"},{header:X(()=>[A("div",Rge,[W(M,null,{default:X(()=>[W($)]),_:1}),R[7]||(R[7]=A("span",null,"上传 PDF 文件",-1))])]),default:X(()=>[W(K,{modelValue:s.value,"onUpdate:modelValue":R[3]||(R[3]=H=>s.value=H),class:"upload-tabs"},{default:X(()=>[W(J,{label:"本地上传",name:"file"},{default:X(()=>[W(U,{ref_key:"uploadRef",ref:u,class:"drop-area",drag:"","auto-upload":!1,accept:".pdf",limit:1,"on-change":k,"on-exceed":T,"file-list":a.value},{tip:X(()=>[...R[8]||(R[8]=[A("div",{class:"upload-tip"},"支持单个 PDF 文件,最大 500MB",-1)])]),default:X(()=>[W(M,{class:"upload-icon"},{default:X(()=>[W(B)]),_:1}),R[9]||(R[9]=A("div",{class:"upload-text"},[je("拖拽 PDF 文件到此处,或 "),A("em",null,"点击选择")],-1))]),_:1},8,["file-list"])]),_:1}),W(J,{label:"网络 URL",name:"url"},{default:X(()=>[W(L,{modelValue:r.value,"onUpdate:modelValue":R[0]||(R[0]=H=>r.value=H),placeholder:"输入 PDF 文件的网络地址,例如 https://example.com/file.pdf",clearable:"",size:"large"},{prepend:X(()=>[W(M,null,{default:X(()=>[W(Y)]),_:1})]),_:1},8,["modelValue"])]),_:1}),W(J,{label:"批量解析",name:"batch"},{default:X(()=>[A("div",Ige,[A("div",Oge,[W(N,{icon:f(Ag),onClick:b},{default:X(()=>[...R[10]||(R[10]=[je(" 选择文件夹 ",-1)])]),_:1},8,["icon"]),W(N,{icon:f(Yx),onClick:C},{default:X(()=>[...R[11]||(R[11]=[je(" 选择多个文件 ",-1)])]),_:1},8,["icon"]),A("input",{ref_key:"folderInputRef",ref:d,type:"file",accept:".pdf",webkitdirectory:"",multiple:"",style:{display:"none"},onChange:w},null,544),A("input",{ref_key:"multiInputRef",ref:h,type:"file",accept:".pdf",multiple:"",style:{display:"none"},onChange:w},null,544)]),p.value.length?(S(),P("div",Lge,[A("div",Nge,[W(V,{type:"success"},{default:X(()=>[je(" 共检测到 "+ge(p.value.length)+" 个 PDF 文件 ",1)]),_:1}),p.value.length>v.value?(S(),le(V,{key:0,type:"warning"},{default:X(()=>[je(" 当前限制解析前 "+ge(v.value)+" 个 ",1)]),_:1})):ie("",!0),A("div",$ge,[R[13]||(R[13]=A("span",{class:"option-label"},"解析数量:",-1)),W(z,{modelValue:v.value,"onUpdate:modelValue":R[1]||(R[1]=H=>v.value=H),min:1,max:p.value.length,size:"small",step:10,style:{width:"120px"}},null,8,["modelValue","max"]),W(N,{size:"small",text:"",onClick:R[2]||(R[2]=H=>v.value=p.value.length)},{default:X(()=>[...R[12]||(R[12]=[je("全部",-1)])]),_:1})])]),W(Q,{data:m.value,size:"small","max-height":"200",class:"batch-table","highlight-current-row":""},{default:X(()=>[W(q,{type:"index",width:"50",label:"#"}),W(q,{prop:"name",label:"文件名","show-overflow-tooltip":""}),W(q,{prop:"size",label:"大小",width:"90",align:"right"})]),_:1},8,["data"]),p.value.length>v.value?(S(),P("div",Dge," ... 还有 "+ge(p.value.length-v.value)+" 个文件未显示(超出解析数量限制) ",1)):ie("",!0),W(N,{size:"small",text:"",type:"danger",onClick:_,class:"batch-clear-btn"},{default:X(()=>[...R[14]||(R[14]=[je("清除",-1)])]),_:1})])):(S(),P("div",Fge,[W(M,{size:"40",color:"#c0c4cc"},{default:X(()=>[W(f(Ag))]),_:1}),R[15]||(R[15]=A("p",null,"选择包含 PDF 的文件夹,或直接选择多个 PDF 文件",-1)),R[16]||(R[16]=A("p",{class:"batch-hint"},"支持 100+ 文件批量处理,逐文件顺序解析",-1))]))])]),_:1})]),_:1},8,["modelValue"]),A("div",Bge,[R[19]||(R[19]=A("span",{class:"option-label"},"识别模式:",-1)),W(se,{modelValue:l.value,"onUpdate:modelValue":R[4]||(R[4]=H=>l.value=H),size:"small"},{default:X(()=>[W(ee,{value:"drawing"},{default:X(()=>[...R[17]||(R[17]=[je("图纸模式",-1)])]),_:1}),W(ee,{value:"auto"},{default:X(()=>[...R[18]||(R[18]=[je("自动识别",-1)])]),_:1})]),_:1},8,["modelValue"]),A("span",Vge,ge(l.value==="drawing"?"管道轴测图:每页均为图纸,复用第1页区域配置,40并发高速识别":"VL 自动分类:图纸页专项裁剪,文字页通用识别,40并发"),1)]),A("div",zge,[R[20]||(R[20]=A("span",{class:"option-label"},"自动纠错:",-1)),W(pe,{modelValue:c.value,"onUpdate:modelValue":R[5]||(R[5]=H=>c.value=H),"active-text":"启用","inactive-text":"关闭"},null,8,["modelValue"]),R[21]||(R[21]=A("span",{class:"mode-hint"},"识别完成后调用 LLM 对结果进行连续性校验与自动修正",-1))]),A("div",Hge,[R[24]||(R[24]=A("span",{class:"option-label"},"导出格式:",-1)),W(ce,{modelValue:i.value,"onUpdate:modelValue":R[6]||(R[6]=H=>i.value=H)},{default:X(()=>[W(fe,{value:"excel",label:"excel"},{default:X(()=>[W(M,null,{default:X(()=>[W(te)]),_:1}),R[22]||(R[22]=je(" Excel ",-1))]),_:1}),W(fe,{value:"json",label:"json"},{default:X(()=>[W(M,null,{default:X(()=>[W(ve)]),_:1}),R[23]||(R[23]=je(" JSON ",-1))]),_:1})]),_:1},8,["modelValue"])]),A("div",Wge,[W(N,{type:"primary",size:"large",disabled:!x.value,icon:s.value==="batch"?f(Vy):f(s9),onClick:I},{default:X(()=>[je(ge(s.value==="batch"?`批量解析 ${Math.min(v.value,p.value.length)} 个文件`:"开始识别"),1)]),_:1},8,["disabled","icon"])])]),_:1})}}},[["__scopeId","data-v-a0c75cf1"]]),Y1="http://localhost:8000/api/ocr";function Kge(e,t=["excel","json"],n,s="drawing",a=!0,o=null){const r=new FormData;r.append("file",e),r.append("export_formats",t.join(",")),r.append("pdf_mode",s),r.append("auto_correct",a?"true":"false"),o&&r.append("max_concurrent",String(o));const i=new AbortController;return fetch(`${Y1}/upload`,{method:"POST",body:r,signal:i.signal}).then(l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);return U8(l,n)}).catch(l=>{l.name!=="AbortError"&&n({type:"error",data:{message:l.message}})}),()=>i.abort()}function Uge(e,t=["excel","json"],n,s="drawing",a=!0){const o=new AbortController;return fetch(`${Y1}/url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e,export_formats:t,pdf_mode:s,auto_correct:a}),signal:o.signal}).then(r=>{if(!r.ok)throw new Error(`HTTP ${r.status}`);return U8(r,n)}).catch(r=>{r.name!=="AbortError"&&n({type:"error",data:{message:r.message}})}),()=>o.abort()}async function U8(e,t){const n=e.body.getReader(),s=new TextDecoder;let a="";for(;;){const{done:o,value:r}=await n.read();if(o)break;a+=s.decode(r,{stream:!0});const i=a.split(` `);a=i.pop()??"";for(const l of i)if(l.startsWith("data: "))try{const c=JSON.parse(l.slice(6));t(c)}catch{}}}function X1(e,t){return`${Y1}/download/${e}/${t}`}function qge(e,t=["excel","json"],n,s="drawing",a=!0,o=null){const r=new FormData;for(const l of e)r.append("files",l);r.append("export_formats",t.join(",")),r.append("pdf_mode",s),r.append("auto_correct",a?"true":"false"),o&&r.append("max_concurrent",String(o));const i=new AbortController;return fetch(`${Y1}/batch`,{method:"POST",body:r,signal:i.signal}).then(l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);return U8(l,n)}).catch(l=>{l.name!=="AbortError"&&n({type:"error",data:{message:l.message}})}),()=>i.abort()}const Gge={class:"panel-header"},Yge={class:"panel-title"},Xge={class:"panel-actions"},Jge={key:0,class:"overall-progress"},Zge={class:"progress-label"},Qge={key:0,class:"current-file"},e1e={key:0,class:"current-msg"},t1e={key:1,class:"summary-row"},n1e={key:1,class:"row-msg"},s1e={key:2,class:"text-danger"},a1e={key:3,class:"text-success"},o1e=cl({__name:"BatchResultPanel",props:{batchEvents:{type:Array,default:()=>[]},batchDone:{type:Boolean,default:!1},mergedSessionId:{type:String,default:""},outputFiles:{type:Object,default:()=>({})},totalFiles:{type:Number,default:0}},emits:["reset"],setup(e,{emit:t}){const n=e,s=t,a=F({});be(()=>n.batchEvents,w=>{for(const _ of w)o(_)},{deep:!0});function o(w){const{type:_,data:x}=w;if(_==="file_start")a.value[x.filename]={filename:x.filename,status:"processing",pages:0,message:"准备中...",percent:0,sessionId:null,error:null,success:!1};else if(_==="file_progress"){const k=a.value[x.filename];k&&(k.message=x.message||k.message,x.percent!=null&&(k.percent=x.percent))}else _==="file_done"?a.value[x.filename]={filename:x.filename,status:"done",pages:x.pages||0,message:"",percent:100,sessionId:x.session_id,error:null,success:!0}:_==="file_error"&&(a.value[x.filename]={filename:x.filename,status:"error",pages:0,message:"",percent:0,sessionId:null,error:x.error,success:!1})}const r=E(()=>Object.values(a.value)),i=E(()=>r.value.filter(w=>w.status==="done"||w.status==="error").length),l=E(()=>r.value.filter(w=>w.status==="done").length),c=E(()=>r.value.filter(w=>w.status==="error").length),u=E(()=>r.value.reduce((w,_)=>w+(_.pages||0),0)),d=E(()=>n.totalFiles?Math.round(i.value/n.totalFiles*100):0),h=E(()=>r.value.find(w=>w.status==="processing")),p=E(()=>{var w;return((w=h.value)==null?void 0:w.filename)||""}),v=E(()=>{var w;return((w=h.value)==null?void 0:w.message)||""}),m=E(()=>{var w;return!!((w=n.outputFiles)!=null&&w.excel)}),g=E(()=>{var w;return!!((w=n.outputFiles)!=null&&w.json)});function b(w){const _=X1(n.mergedSessionId,w),x=document.createElement("a");x.href=_,x.download=w,document.body.appendChild(x),x.click(),document.body.removeChild(x)}function C(w,_,x){const k=X1(w,_),T=_.endsWith(".xlsx")?".xlsx":".json",I=x?x.replace(/\.pdf$/i,"")+T:_,O=document.createElement("a");O.href=k,O.download=I,document.body.appendChild(O),O.click(),document.body.removeChild(O)}return(w,_)=>{const x=Ge("el-icon"),k=Ge("el-tag"),T=Ge("el-button"),I=Ge("el-progress"),O=Ge("el-statistic"),R=Ge("el-table-column"),$=Ge("el-table"),M=Ge("el-card");return S(),le(M,{class:"batch-result-card",shadow:"never"},{header:X(()=>[A("div",Gge,[A("div",Yge,[W(x,null,{default:X(()=>[W(f(Vy))]),_:1}),_[3]||(_[3]=A("span",null,"批量解析结果",-1)),e.batchDone?(S(),le(k,{key:0,type:"success",size:"small"},{default:X(()=>[je(" 完成 "+ge(l.value)+"/"+ge(e.totalFiles),1)]),_:1})):ie("",!0),c.value>0?(S(),le(k,{key:1,type:"danger",size:"small"},{default:X(()=>[je(" 失败 "+ge(c.value),1)]),_:1})):ie("",!0)]),A("div",Xge,[e.mergedSessionId?(S(),P(He,{key:0},[m.value?(S(),le(T,{key:0,type:"primary",size:"small",icon:f(Qi),onClick:_[0]||(_[0]=B=>b("result.xlsx"))},{default:X(()=>[..._[4]||(_[4]=[je("下载合并 Excel",-1)])]),_:1},8,["icon"])):ie("",!0),g.value?(S(),le(T,{key:1,size:"small",icon:f(Qi),onClick:_[1]||(_[1]=B=>b("result.json"))},{default:X(()=>[..._[5]||(_[5]=[je("下载合并 JSON",-1)])]),_:1},8,["icon"])):ie("",!0)],64)):ie("",!0),W(T,{size:"small",plain:"",onClick:_[2]||(_[2]=B=>s("reset"))},{default:X(()=>[..._[6]||(_[6]=[je("重新开始",-1)])]),_:1})])])]),default:X(()=>[e.batchDone?ie("",!0):(S(),P("div",Jge,[A("div",Zge,[je(" 已完成 "+ge(i.value)+" / "+ge(e.totalFiles)+" 个文件 ",1),p.value?(S(),P("span",Qge," — 正在处理:"+ge(p.value),1)):ie("",!0)]),W(I,{percentage:d.value,"stroke-width":10,striped:"","striped-flow":"",duration:10,status:""},null,8,["percentage"]),v.value?(S(),P("div",e1e,ge(v.value),1)):ie("",!0)])),e.batchDone?(S(),P("div",t1e,[W(O,{title:"总文件数",value:e.totalFiles},null,8,["value"]),W(O,{title:"成功解析",value:l.value,"value-style":"color:#67c23a"},null,8,["value"]),W(O,{title:"失败文件",value:c.value,"value-style":"color:#f56c6c"},null,8,["value"]),W(O,{title:"合计页数",value:u.value},null,8,["value"])])):ie("",!0),W($,{data:r.value,size:"small",class:"file-table","max-height":"420",stripe:""},{default:X(()=>[W(R,{type:"index",width:"55",label:"#",align:"center"}),W(R,{label:"文件名","min-width":"220","show-overflow-tooltip":""},{default:X(({row:B})=>[A("span",{class:D(B.success?"":"text-danger")},ge(B.filename),3)]),_:1}),W(R,{label:"状态",width:"110",align:"center"},{default:X(({row:B})=>[B.status==="done"?(S(),le(k,{key:0,type:"success",size:"small"},{default:X(()=>[W(x,null,{default:X(()=>[W(f(xp))]),_:1}),_[7]||(_[7]=je(" 完成 ",-1))]),_:1})):B.status==="error"?(S(),le(k,{key:1,type:"danger",size:"small"},{default:X(()=>[W(x,null,{default:X(()=>[W(f(Do))]),_:1}),_[8]||(_[8]=je(" 失败 ",-1))]),_:1})):B.status==="processing"?(S(),le(k,{key:2,type:"warning",size:"small"},{default:X(()=>[W(x,null,{default:X(()=>[W(f(Fs))]),_:1}),_[9]||(_[9]=je(" 处理中 ",-1))]),_:1})):(S(),le(k,{key:3,type:"info",size:"small"},{default:X(()=>[..._[10]||(_[10]=[je("等待",-1)])]),_:1}))]),_:1}),W(R,{label:"页数",width:"70",align:"center",prop:"pages"}),W(R,{label:"进度/错误信息","min-width":"260","show-overflow-tooltip":""},{default:X(({row:B})=>[B.status==="processing"&&B.percent!=null?(S(),le(I,{key:0,percentage:B.percent,"stroke-width":6,striped:"","striped-flow":"",duration:8,class:"row-progress"},null,8,["percentage"])):B.status==="processing"?(S(),P("span",n1e,ge(B.message),1)):B.status==="error"?(S(),P("span",s1e,ge(B.error),1)):B.status==="done"?(S(),P("span",a1e,"识别完成")):ie("",!0)]),_:1}),W(R,{label:"下载",width:"80",align:"center"},{default:X(({row:B})=>[B.sessionId?(S(),le(T,{key:0,size:"small",text:"",type:"primary",icon:f(Qi),title:"下载 Excel",onClick:U=>C(B.sessionId,"result.xlsx",B.filename)},null,8,["icon","onClick"])):ie("",!0)]),_:1})]),_:1},8,["data"])]),_:1})}}},[["__scopeId","data-v-d95acc72"]]),r1e={class:"card-title"},i1e={key:0,class:"page-indicator"},l1e={class:"log-time"},c1e=cl({__name:"ProgressTracker",props:{logs:{type:Array,default:()=>[]},percent:{type:Number,default:0},totalPages:{type:Number,default:0},currentPage:{type:Number,default:0}},setup(e){const t=e,n=F(null),s=Date.now(),a=[{color:"#409EFF",percentage:40},{color:"#67C23A",percentage:80},{color:"#E6A23C",percentage:100}];function o(r){return`[${Math.round((Date.now()-s)/1e3)}s]`}return be(()=>t.logs.length,async()=>{await ze(),n.value&&(n.value.scrollTop=n.value.scrollHeight)}),(r,i)=>{const l=Ge("Loading"),c=Ge("el-icon"),u=Ge("el-progress"),d=Ge("el-card");return S(),le(d,{class:"progress-card",shadow:"never"},{header:X(()=>[A("div",r1e,[W(c,{class:"spin"},{default:X(()=>[W(l)]),_:1}),i[0]||(i[0]=A("span",null,"正在处理中...",-1)),e.totalPages>0?(S(),P("span",i1e," 第 "+ge(e.currentPage)+" / "+ge(e.totalPages)+" 页 ",1)):ie("",!0)])]),default:X(()=>[W(u,{percentage:e.percent,"stroke-width":14,color:a,class:"main-progress"},null,8,["percentage"]),A("div",{class:"log-container",ref_key:"logContainer",ref:n},[(S(!0),P(He,null,Et(e.logs,(h,p)=>(S(),P("div",{key:p,class:D(["log-item",{"log-success":h.includes("✓")||h.includes("✅"),"log-error":h.includes("❌")}])},[A("span",l1e,ge(o(p)),1),je(" "+ge(h),1)],2))),128))],512)]),_:1})}}},[["__scopeId","data-v-673aebf7"]]),u1e={class:"flagged-cell"},d1e={key:1},f1e={class:"row-count"},h1e={key:1,class:"raw-text"},p1e=cl({__name:"Parts3Table",props:{data:{type:[Object,null],default:null}},setup(e){const t=e,n=new Set(["_flags","_corrections"]),s={seq_no:"序号",category:"类别",description:"材料描述",size:"SIZE",code:"材料代号",qty:"数量",pipe_no:"管道号",unit:"单位",material:"材质",remark:"备注",spec:"公称直径"},a={llm_suspicious:"LLM标记可疑,需人工复核",llm_corrected:"LLM已修正",rule_corrected:"规则已修正",seq_gap:"序号不连续",seq_dup:"序号重复",desc_overflow:"描述溢出到规格列",size_invalid:"规格字段异常",size_outlier:"规格偏离本页主导尺寸",qty_invalid:"数量字段异常",cell_overlap:"单元格数值重叠(叠印)",desc_num_tail:"描述末尾残留尺寸数字",size_num_prefix:"尺寸前缀数字粘连"},o=E(()=>{if(!t.data)return[];const d=t.data;return d.rows&&Array.isArray(d.rows)?d.rows:d.data&&Array.isArray(d.data)?d.data:d.items&&Array.isArray(d.items)?d.items:[]}),r=E(()=>{if(o.value.length===0)return[];const d=new Set;return o.value.slice(0,5).forEach(h=>Object.keys(h).forEach(p=>d.add(p))),Array.from(d).filter(h=>!n.has(h))}),i=E(()=>t.data&&t.data.raw_text||"");function l(d){return s[d]||d}function c(d,h){var g,b;const p=(g=d._flags)==null?void 0:g[h],v=a[p]||p||"",m=(b=d._corrections)==null?void 0:b[h];return m!=null?`[已修正] 原值:${m} ${v}`:`[${v}]`}function u({row:d,column:h}){if(!d._flags)return{};const p=h.property,v=d._flags[p];return v?new Set(["llm_corrected","rule_corrected"]).has(v)?{backgroundColor:"#FFB347",color:"#000",fontWeight:"bold"}:{backgroundColor:"#ADD8E6",color:"#000",fontWeight:"bold"}:{}}return(d,h)=>{const p=Ge("el-tooltip"),v=Ge("el-table-column"),m=Ge("el-table"),g=Ge("el-empty");return S(),P("div",null,[o.value.length>0?(S(),P(He,{key:0},[W(m,{data:o.value,border:"",stripe:"",size:"small",style:{width:"100%"},"max-height":500,"cell-style":u},{default:X(()=>[(S(!0),P(He,null,Et(r.value,b=>(S(),le(v,{key:b,prop:b,label:l(b),"min-width":"100"},{default:X(({row:C})=>[C._flags&&C._flags[b]?(S(),le(p,{key:0,content:c(C,b),placement:"top","show-after":300},{default:X(()=>[A("span",u1e,ge(C[b]),1)]),_:2},1032,["content"])):(S(),P("span",d1e,ge(C[b]),1))]),_:2},1032,["prop","label"]))),128))]),_:1},8,["data"]),A("div",f1e,"共 "+ge(o.value.length)+" 行",1)],64)):i.value?(S(),P("pre",h1e,ge(i.value),1)):(S(),le(g,{key:2,description:"暂无识别数据","image-size":60}))])}}},[["__scopeId","data-v-bfa225df"]]),v1e={key:1,class:"raw-text"},cP=cl({__name:"MetaInfo",props:{data:{type:[Object,null],default:null}},setup(e){const t=e,n=E(()=>!t.data||typeof t.data!="object"?[]:Object.entries(t.data).filter(([a])=>a!=="raw_text"&&a!=="parse_error"&&a!=="part").filter(([,a])=>a!=null).map(([a,o])=>({key:a,value:String(o)}))),s=E(()=>{var a;return((a=t.data)==null?void 0:a.raw_text)||""});return(a,o)=>{const r=Ge("el-descriptions-item"),i=Ge("el-descriptions"),l=Ge("el-empty");return S(),P("div",null,[n.value.length>0?(S(),le(i,{key:0,column:1,border:"",size:"small"},{default:X(()=>[(S(!0),P(He,null,Et(n.value,({key:c,value:u})=>(S(),le(r,{key:c,label:c},{default:X(()=>[je(ge(u),1)]),_:2},1032,["label"]))),128))]),_:1})):s.value?(S(),P("pre",v1e,ge(s.value),1)):(S(),le(l,{key:2,description:"暂无数据","image-size":50}))])}}},[["__scopeId","data-v-9250db36"]]),m1e={class:"toolbar"},g1e={class:"result-summary"},b1e={key:0,class:"token-hint"},y1e={class:"btn-group"},w1e={key:0},_1e={key:1},C1e={key:0,style:{color:"#e6a23c"}},S1e={key:0,class:"reason-tags"},x1e={key:2,class:"page-detail"},uP=cl({__name:"ResultPanel",props:{pagesData:{type:Array,default:()=>[]},sessionId:{type:String,default:""},outputFiles:{type:Object,default:()=>({})},outputFilenames:{type:Object,default:()=>({})},tokenUsage:{type:Object,default:null},pdfName:{type:String,default:""},correctionSummary:{type:Object,default:null}},emits:["reset"],setup(e,{emit:t}){const n=e,s=t,a=F("1"),o=E(()=>{const c=parseInt(a.value);return n.pagesData.find(u=>u.page===c)||n.pagesData[0]});function r(c){const u=c==="excel"?".xlsx":".json",d=n.outputFilenames[c]||`result${u}`,h=X1(n.sessionId,d),p=document.createElement("a");p.href=h,p.download=d,document.body.appendChild(p),p.click(),document.body.removeChild(p)}const i={llm_suspicious:"LLM标记可疑",llm_corrected:"LLM已修正",rule_corrected:"规则已修正",seq_gap:"序号不连续",seq_dup:"序号重复",desc_overflow:"描述溢出到规格列",size_invalid:"规格字段异常",size_outlier:"规格偏离主导尺寸",qty_invalid:"数量字段异常",cell_overlap:"数值重叠(两格合并)",desc_num_tail:"描述末尾残留尺寸数字",size_num_prefix:"尺寸前缀数字粘连",pressure_oob:"压力值超范围",cross_inconsist:"跨页参数不一致"};function l(c){return i[c]||c}return(c,u)=>{const d=Ge("CircleCheck"),h=Ge("el-icon"),p=Ge("el-button"),v=Ge("el-card"),m=Ge("el-tag"),g=Ge("el-alert"),b=Ge("el-tab-pane"),C=Ge("el-tabs"),w=Ge("el-col"),_=Ge("el-row");return S(),P("div",null,[W(v,{class:"toolbar-card",shadow:"never"},{default:X(()=>[A("div",m1e,[A("div",g1e,[W(h,{color:"#67C23A",size:"20"},{default:X(()=>[W(d)]),_:1}),A("span",null,[u[4]||(u[4]=je("识别完成,共处理 ",-1)),A("strong",null,ge(e.pagesData.length),1),u[5]||(u[5]=je(" 页",-1))]),e.tokenUsage?(S(),P("span",b1e," · "+ge(e.tokenUsage.total_tokens.toLocaleString())+" tokens  ¥"+ge(e.tokenUsage.cost_cny),1)):ie("",!0)]),A("div",y1e,[e.sessionId?(S(),le(p,{key:0,type:"success",icon:f(Qi),onClick:u[0]||(u[0]=x=>r("excel"))},{default:X(()=>[...u[6]||(u[6]=[je(" 下载 Excel ",-1)])]),_:1},8,["icon"])):ie("",!0),e.sessionId?(S(),le(p,{key:1,type:"info",icon:f(Qi),onClick:u[1]||(u[1]=x=>r("json"))},{default:X(()=>[...u[7]||(u[7]=[je(" 下载 JSON ",-1)])]),_:1},8,["icon"])):ie("",!0),W(p,{icon:f(Tg),onClick:u[2]||(u[2]=x=>s("reset"))},{default:X(()=>[...u[8]||(u[8]=[je(" 重新识别 ",-1)])]),_:1},8,["icon"])])])]),_:1}),e.correctionSummary?(S(),le(g,{key:0,class:"correction-alert",closable:!0,"show-icon":"",type:e.correctionSummary.flagged_rows>0?e.correctionSummary.corrected_rows>0?"warning":"error":"success"},{title:X(()=>[e.correctionSummary.flagged_rows===0?(S(),P("span",w1e,"OCR 校验通过,未发现异常")):(S(),P("span",_1e,[u[9]||(u[9]=je(" 发现 ",-1)),A("strong",null,ge(e.correctionSummary.flagged_rows),1),u[10]||(u[10]=je(" 行存疑内容,已自动修正 ",-1)),A("strong",null,ge(e.correctionSummary.corrected_rows),1),u[11]||(u[11]=je(" 行 ",-1)),e.correctionSummary.flagged_rows>e.correctionSummary.corrected_rows?(S(),P("span",C1e,"(剩余 "+ge(e.correctionSummary.flagged_rows-e.correctionSummary.corrected_rows)+" 行已在 Excel 中标红)",1)):ie("",!0)]))]),default:X(()=>[e.correctionSummary.reasons&&Object.keys(e.correctionSummary.reasons).length?(S(),P("div",S1e,[(S(!0),P(He,null,Et(e.correctionSummary.reasons,(x,k)=>(S(),le(m,{key:k,size:"small",type:k==="llm_corrected"||k==="rule_corrected"?"success":k==="llm_suspicious"?"danger":"warning",class:"reason-tag"},{default:X(()=>[je(ge(l(k))+"×"+ge(x),1)]),_:2},1032,["type"]))),128))])):ie("",!0)]),_:1},8,["type"])):ie("",!0),e.pagesData.length>1?(S(),le(C,{key:1,modelValue:a.value,"onUpdate:modelValue":u[3]||(u[3]=x=>a.value=x),class:"page-tabs"},{default:X(()=>[(S(!0),P(He,null,Et(e.pagesData,x=>(S(),le(b,{key:x.page,label:`第 ${x.page} 页`,name:String(x.page)},null,8,["label","name"]))),128))]),_:1},8,["modelValue"])):ie("",!0),o.value?(S(),P("div",x1e,[W(v,{shadow:"never",class:"part-card parts3-card"},{header:X(()=>[...u[12]||(u[12]=[A("span",{class:"part-label parts3-label"},"⭐ 材料明细(Parts 3)",-1)])]),default:X(()=>[W(p1e,{data:o.value.parts3},null,8,["data"])]),_:1}),W(_,{gutter:16,class:"meta-row"},{default:X(()=>[W(w,{span:12},{default:X(()=>[W(v,{shadow:"never",class:"part-card"},{header:X(()=>[...u[13]||(u[13]=[A("span",{class:"part-label"},"标题栏(Parts 1)",-1)])]),default:X(()=>[W(cP,{data:o.value.parts1},null,8,["data"])]),_:1})]),_:1}),W(w,{span:12},{default:X(()=>[W(v,{shadow:"never",class:"part-card"},{header:X(()=>[...u[14]||(u[14]=[A("span",{class:"part-label"},"附属信息(Parts 2)",-1)])]),default:X(()=>[W(cP,{data:o.value.parts2},null,8,["data"])]),_:1})]),_:1})]),_:1})])):ie("",!0)])}}},[["__scopeId","data-v-7ae18195"]]),k1e={class:"toolbar"},E1e={class:"result-summary"},A1e={key:0,class:"token-hint"},T1e={class:"btn-group"},M1e={key:1,class:"page-content"},P1e={class:"table-header"},R1e={key:0,class:"table-title"},I1e={class:"para-label"},O1e={key:0,class:"para-title"},L1e={class:"para-text"},dP=cl({__name:"GeneralResultPanel",props:{pagesData:{type:Array,default:()=>[]},sessionId:{type:String,default:""},outputFiles:{type:Object,default:()=>({})},outputFilenames:{type:Object,default:()=>({})},tokenUsage:{type:Object,default:null},pdfName:{type:String,default:""}},emits:["reset"],setup(e,{emit:t}){const n=e,s=t,a=F("1"),o=E(()=>{const d=parseInt(a.value);return n.pagesData.find(h=>h.page===d)||n.pagesData[0]}),r=E(()=>n.pagesData.reduce((d,h)=>{var p;return d+(((p=h.tables)==null?void 0:p.length)||0)},0)),i=E(()=>n.pagesData.reduce((d,h)=>{var p;return d+(((p=h.paragraphs)==null?void 0:p.length)||0)},0));function l(d){return(d.rows||[]).map(h=>{const p={};return(h||[]).forEach((v,m)=>{p[String(m)]=v}),p})}function c(d){const h=d.headers||[];return h.length?h:((d.rows||[])[0]||[]).map((v,m)=>`列${m+1}`)}function u(d){const h=d==="excel"?".xlsx":".json",p=n.outputFilenames[d]||`result${h}`,v=X1(n.sessionId,p),m=document.createElement("a");m.href=v,m.download=p,document.body.appendChild(m),m.click(),document.body.removeChild(m)}return(d,h)=>{var T,I,O,R;const p=Ge("CircleCheck"),v=Ge("el-icon"),m=Ge("el-button"),g=Ge("el-card"),b=Ge("el-tab-pane"),C=Ge("el-tabs"),w=Ge("el-empty"),_=Ge("el-tag"),x=Ge("el-table-column"),k=Ge("el-table");return S(),P("div",null,[W(g,{class:"toolbar-card",shadow:"never"},{default:X(()=>[A("div",k1e,[A("div",E1e,[W(v,{color:"#67C23A",size:"20"},{default:X(()=>[W(p)]),_:1}),A("span",null,[h[4]||(h[4]=je("通用识别完成,共 ",-1)),A("strong",null,ge(e.pagesData.length),1),h[5]||(h[5]=je(" 页  ·  ",-1)),A("strong",null,ge(r.value),1),h[6]||(h[6]=je(" 张表格  ·  ",-1)),A("strong",null,ge(i.value),1),h[7]||(h[7]=je(" 段文字",-1))]),e.tokenUsage?(S(),P("span",A1e," · "+ge(e.tokenUsage.total_tokens.toLocaleString())+" tokens  ¥"+ge(e.tokenUsage.cost_cny),1)):ie("",!0)]),A("div",T1e,[e.sessionId?(S(),le(m,{key:0,type:"success",icon:f(Qi),onClick:h[0]||(h[0]=$=>u("excel"))},{default:X(()=>[...h[8]||(h[8]=[je("下载 Excel",-1)])]),_:1},8,["icon"])):ie("",!0),e.sessionId?(S(),le(m,{key:1,type:"info",icon:f(Qi),onClick:h[1]||(h[1]=$=>u("json"))},{default:X(()=>[...h[9]||(h[9]=[je("下载 JSON",-1)])]),_:1},8,["icon"])):ie("",!0),W(m,{icon:f(Tg),onClick:h[2]||(h[2]=$=>s("reset"))},{default:X(()=>[...h[10]||(h[10]=[je("重新识别",-1)])]),_:1},8,["icon"])])])]),_:1}),e.pagesData.length>1?(S(),le(C,{key:0,modelValue:a.value,"onUpdate:modelValue":h[3]||(h[3]=$=>a.value=$),class:"page-tabs"},{default:X(()=>[(S(!0),P(He,null,Et(e.pagesData,$=>(S(),le(b,{key:$.page,label:`第 ${$.page} 页`,name:String($.page)},null,8,["label","name"]))),128))]),_:1},8,["modelValue"])):ie("",!0),o.value?(S(),P("div",M1e,[!((T=o.value.tables)!=null&&T.length)&&!((I=o.value.paragraphs)!=null&&I.length)?(S(),le(w,{key:0,description:"本页未识别到表格或文字","image-size":80})):ie("",!0),(O=o.value.tables)!=null&&O.length?(S(!0),P(He,{key:1},Et(o.value.tables,($,M)=>(S(),le(g,{key:M,class:"table-card",shadow:"never"},{header:X(()=>[A("div",P1e,[W(_,{size:"small",type:"warning"},{default:X(()=>[je("表格 "+ge(M+1),1)]),_:2},1024),$.title?(S(),P("span",R1e,ge($.title),1)):ie("",!0)])]),default:X(()=>[W(k,{data:l($),size:"small",border:"",stripe:"",style:{width:"100%"},"max-height":"400"},{default:X(()=>[(S(!0),P(He,null,Et(c($),(B,U)=>(S(),le(x,{key:U,label:B,prop:String(U),"min-width":"120","show-overflow-tooltip":""},null,8,["label","prop"]))),128))]),_:2},1032,["data"])]),_:2},1024))),128)):ie("",!0),(R=o.value.paragraphs)!=null&&R.length?(S(),le(g,{key:2,class:"para-card",shadow:"never"},{header:X(()=>[A("span",I1e,"📝 段落文字("+ge(o.value.paragraphs.length)+" 段)",1)]),default:X(()=>[(S(!0),P(He,null,Et(o.value.paragraphs,($,M)=>(S(),P("div",{key:M,class:"para-item"},[$.title?(S(),P("div",O1e,ge($.title),1)):ie("",!0),A("pre",L1e,ge($.text),1)]))),128))]),_:1})):ie("",!0)])):ie("",!0)])}}},[["__scopeId","data-v-5cd76fd5"]]),N1e={class:"ocr-app"},$1e={class:"header-inner"},D1e={class:"header-actions"},F1e={class:"auto-section-title"},B1e={class:"auto-section-title"},V1e={__name:"App",setup(e){const t=lP();function n(){window.open("/docs","_blank")}const s=F(!1),a=F(!1),o=F(""),r=F([]),i=F(0),l=F(0),c=F(0),u=F([]),d=F(""),h=F({}),p=F(null),v=F("drawing"),m=F(""),g=F(null),b=F({}),C=F(!1),w=F(!1),_=F(!1),x=F([]),k=F(0),T=F(""),I=F({}),O=E(()=>u.value.filter(L=>L.page_type==="drawing")),R=E(()=>u.value.filter(L=>L.page_type==="table"||L.page_type==="text"));let $=null;function M({file:L,url:N,files:V,formats:z,mode:q,autoCorrect:Q,maxConcurrent:K,batch:ee}){Y(),v.value=q||"drawing";const se=K||null;if(ee&&V&&V.length){C.value=!0,w.value=!0,k.value=V.length,x.value=[],$=qge(V,z,U,v.value,Q!==!1,se);return}s.value=!0,L&&(m.value=L.name.replace(/\.pdf$/i,""));const pe=te=>{B(te)};L?$=Kge(L,z,pe,v.value,Q!==!1,se):N&&($=Uge(N,z,pe,v.value,Q!==!1))}function B(L){const{type:N,data:V}=L;N==="progress"&&(r.value.push(V.message),V.percent!=null&&(i.value=V.percent),V.total_pages&&(l.value=V.total_pages),V.current_page&&(c.value=V.current_page)),N==="page_done"&&(v.value==="drawing"&&u.value.push(V.result),c.value=V.page,r.value.push(`✓ 第 ${V.page} 页识别完成`)),N==="done"&&(i.value=100,d.value=V.session_id,h.value=V.output_files||{},p.value=V.token_usage||null,g.value=V.correction_summary?{flagged_rows:0,corrected_rows:0,reasons:{},...V.correction_summary}:{flagged_rows:0,corrected_rows:0,reasons:{}},b.value=V.output_filenames||{},v.value==="drawing"&&Array.isArray(V.pages_data)&&(u.value=V.pages_data),(V.pdf_mode==="general"||V.pdf_mode==="auto")&&Array.isArray(V.pages_data)&&(u.value=V.pages_data),p.value&&(p.value.total_tokens!=null&&p.value.drawing_ocr==null?r.value.push(`📊 Token: 输入 ${p.value.prompt_tokens} / 输出 ${p.value.completion_tokens},费用 ¥${p.value.cost_cny}`):p.value.total_tokens!=null&&r.value.push(`📊 Token 合计 ${p.value.total_tokens}(分类+检测+OCR)`)),r.value.push("✅ 全部处理完成!"),s.value=!1,a.value=!0),N==="error"&&(o.value=V.message,s.value=!1,r.value.push(`❌ 错误:${V.message}`))}function U(L){x.value=[...x.value,L];const{type:N,data:V}=L;N==="batch_done"&&(T.value=V.merged_session_id||"",I.value=V.output_files||{},w.value=!1,_.value=!0),N==="error"&&(o.value=V.message,w.value=!1)}function J(){Y()}function Y(){$&&($(),$=null),s.value=!1,a.value=!1,o.value="",r.value=[],i.value=0,l.value=0,c.value=0,u.value=[],d.value="",h.value={},p.value=null,g.value=null,b.value={},v.value="auto",m.value="",C.value=!1,w.value=!1,_.value=!1,x.value=[],k.value=0,T.value="",I.value={}}return(L,N)=>{const V=Ge("Document"),z=Ge("el-icon"),q=Ge("el-button"),Q=Ge("el-header"),K=Ge("el-alert"),ee=Ge("el-main");return S(),P("div",N1e,[W(Q,{class:"app-header"},{default:X(()=>[A("div",$1e,[W(z,{size:"28",class:"logo-icon"},{default:X(()=>[W(V)]),_:1}),N[2]||(N[2]=A("span",{class:"title"},"Ai辅助单线图自动提取材料表",-1)),N[3]||(N[3]=A("span",{class:"subtitle"},"单线图 PDF 智能识别与材料表生成",-1))]),A("div",D1e,[W(q,{size:"small",plain:"",class:"manual-btn",onClick:N[0]||(N[0]=se=>f(t).push("/Manual"))},{default:X(()=>[W(z,null,{default:X(()=>[W(f(kg))]),_:1}),N[4]||(N[4]=je(" 手动模式 ",-1))]),_:1}),W(q,{size:"small",plain:"",class:"swagger-btn",onClick:n},{default:X(()=>[...N[5]||(N[5]=[je("API Docs",-1)])]),_:1})])]),_:1}),W(ee,{class:"app-main"},{default:X(()=>[!s.value&&!a.value&&!C.value?(S(),le(jge,{key:0,onSubmit:M})):ie("",!0),C.value?(S(),le(o1e,{key:1,"batch-events":x.value,"batch-done":_.value,"merged-session-id":T.value,"output-files":I.value,"total-files":k.value,onReset:J},null,8,["batch-events","batch-done","merged-session-id","output-files","total-files"])):ie("",!0),s.value?(S(),le(c1e,{key:2,logs:r.value,percent:i.value,"total-pages":l.value,"current-page":c.value},null,8,["logs","percent","total-pages","current-page"])):ie("",!0),a.value&&v.value==="drawing"?(S(),le(uP,{key:3,"pages-data":u.value,"session-id":d.value,"output-files":h.value,"output-filenames":b.value,"token-usage":p.value,"pdf-name":m.value,"correction-summary":g.value,onReset:J},null,8,["pages-data","session-id","output-files","output-filenames","token-usage","pdf-name","correction-summary"])):ie("",!0),a.value&&v.value==="general"?(S(),le(dP,{key:4,"pages-data":u.value,"session-id":d.value,"output-files":h.value,"output-filenames":b.value,"token-usage":p.value,"pdf-name":m.value,onReset:J},null,8,["pages-data","session-id","output-files","output-filenames","token-usage","pdf-name"])):ie("",!0),a.value&&v.value==="auto"?(S(),P(He,{key:5},[O.value.length?(S(),P(He,{key:0},[A("div",F1e,"📐 图纸类页面("+ge(O.value.length)+" 页)",1),W(uP,{"pages-data":O.value,"session-id":d.value,"output-files":h.value,"output-filenames":b.value,"token-usage":null,"pdf-name":m.value,"correction-summary":g.value,onReset:J},null,8,["pages-data","session-id","output-files","output-filenames","pdf-name","correction-summary"])],64)):ie("",!0),R.value.length?(S(),P(He,{key:1},[A("div",B1e,"📄 文字/表格类页面("+ge(R.value.length)+" 页)",1),W(dP,{"pages-data":R.value,"session-id":d.value,"output-files":h.value,"output-filenames":b.value,"token-usage":p.value,"pdf-name":m.value,onReset:J},null,8,["pages-data","session-id","output-files","output-filenames","token-usage","pdf-name"])],64)):ie("",!0)],64)):ie("",!0),o.value?(S(),le(K,{key:6,title:o.value,type:"error","show-icon":"",class:"mt-4",onClose:N[1]||(N[1]=se=>o.value="")},null,8,["title"])):ie("",!0)]),_:1}),N[6]||(N[6]=A("footer",{class:"app-footer"},"© 2025 合肥诺必达信息技术有限公司 · 版权所有",-1))])}}};var wv={};wv.d=(e,t)=>{for(var n in t)wv.o(t,n)&&!wv.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},wv.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var nn=globalThis.pdfjsLib={};wv.d(nn,{AbortException:()=>Cc,AnnotationEditorLayer:()=>Mw,AnnotationEditorParamsType:()=>_n,AnnotationEditorType:()=>dn,AnnotationEditorUIManager:()=>Ku,AnnotationLayer:()=>N4e,AnnotationMode:()=>wc,ColorPicker:()=>vb,DOMSVGFactory:()=>yw,DrawLayer:()=>Pw,FeatureTest:()=>La,GlobalWorkerOptions:()=>fl,ImageKind:()=>J1,InvalidPDFException:()=>X8,MissingPDFException:()=>Cv,OPS:()=>Sr,OutputScale:()=>ow,PDFDataRangeTransport:()=>UP,PDFDateString:()=>sw,PDFWorker:()=>ph,PasswordResponses:()=>j1e,PermissionFlag:()=>W1e,PixelsPerInch:()=>Sc,RenderingCancelledException:()=>tw,TextLayer:()=>Tv,TouchManager:()=>ib,UnexpectedResponseException:()=>tb,Util:()=>zt,VerbosityLevel:()=>Z1,XfaLayer:()=>XP,build:()=>v4e,createValidAbsoluteUrl:()=>G1e,fetchData:()=>sb,getDocument:()=>r4e,getFilenameFromUrl:()=>sbe,getPdfFilenameFromUrl:()=>abe,getXfaPageViewport:()=>obe,isDataScheme:()=>ab,isPdfFile:()=>nw,noContextMenu:()=>xr,normalizeUnicode:()=>ebe,setLayerDimensions:()=>ju,shadow:()=>mn,stopEvent:()=>go,version:()=>p4e});const ma=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),fP=[1,0,0,1,0,0],q8=[.001,0,0,.001,0,0],z1e=1e7,G8=1.35,mo={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},wc={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},H1e="pdfjs_internal_editor_",dn={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},_n={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},W1e={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},ga={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},J1={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Is={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},_v={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Z1={ERRORS:0,WARNINGS:1,INFOS:5},Sr={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},j1e={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Q1=Z1.WARNINGS;function K1e(e){Number.isInteger(e)&&(Q1=e)}function U1e(){return Q1}function eb(e){Q1>=Z1.INFOS&&console.log(`Info: ${e}`)}function fn(e){Q1>=Z1.WARNINGS&&console.log(`Warning: ${e}`)}function Hn(e){throw new Error(e)}function Ss(e,t){e||Hn(t)}function q1e(e){switch(e==null?void 0:e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function G1e(e,t=null,n=null){if(!e)return null;try{if(n&&typeof e=="string"){if(n.addDefaultProtocol&&e.startsWith("www.")){const a=e.match(/\./g);(a==null?void 0:a.length)>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=Q1e(e)}catch{}}const s=t?new URL(e,t):new URL(e);if(q1e(s))return s}catch{}return null}function mn(e,t,n,s=!1){return Object.defineProperty(e,t,{value:n,enumerable:!s,configurable:!0,writable:!1}),n}const _c=function(){function t(n,s){this.message=n,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class hP extends _c{constructor(t,n){super(t,"PasswordException"),this.code=n}}class Y8 extends _c{constructor(t,n){super(t,"UnknownErrorException"),this.details=n}}class X8 extends _c{constructor(t){super(t,"InvalidPDFException")}}class Cv extends _c{constructor(t){super(t,"MissingPDFException")}}class tb extends _c{constructor(t,n){super(t,"UnexpectedResponseException"),this.status=n}}class Y1e extends _c{constructor(t){super(t,"FormatError")}}class Cc extends _c{constructor(t){super(t,"AbortException")}}function pP(e){(typeof e!="object"||(e==null?void 0:e.length)===void 0)&&Hn("Invalid argument for bytesToString");const t=e.length,n=8192;if(t>24&255,e>>16&255,e>>8&255,e&255)}function J8(e){const t=Object.create(null);for(const[n,s]of e)t[n]=s;return t}function J1e(){const e=new Uint8Array(4);return e[0]=1,new Uint32Array(e.buffer,0,1)[0]===1}function Z1e(){try{return new Function(""),!0}catch{return!1}}class La{static get isLittleEndian(){return mn(this,"isLittleEndian",J1e())}static get isEvalSupported(){return mn(this,"isEvalSupported",Z1e())}static get isOffscreenCanvasSupported(){return mn(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return mn(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?mn(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof(navigator==null?void 0:navigator.userAgent)=="string"&&navigator.userAgent.includes("Firefox")}):mn(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,n;return mn(this,"isCSSRoundSupported",(n=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:n.call(t,"width: round(1.5px, 1px)"))}}const Z8=Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,"0"));class zt{static makeHexColor(t,n,s){return`#${Z8[t]}${Z8[n]}${Z8[s]}`}static scaleMinMax(t,n){let s;t[0]?(t[0]<0&&(s=n[0],n[0]=n[2],n[2]=s),n[0]*=t[0],n[2]*=t[0],t[3]<0&&(s=n[1],n[1]=n[3],n[3]=s),n[1]*=t[3],n[3]*=t[3]):(s=n[0],n[0]=n[1],n[1]=s,s=n[2],n[2]=n[3],n[3]=s,t[1]<0&&(s=n[1],n[1]=n[3],n[3]=s),n[1]*=t[1],n[3]*=t[1],t[2]<0&&(s=n[0],n[0]=n[2],n[2]=s),n[0]*=t[2],n[2]*=t[2]),n[0]+=t[4],n[1]+=t[5],n[2]+=t[4],n[3]+=t[5]}static transform(t,n){return[t[0]*n[0]+t[2]*n[1],t[1]*n[0]+t[3]*n[1],t[0]*n[2]+t[2]*n[3],t[1]*n[2]+t[3]*n[3],t[0]*n[4]+t[2]*n[5]+t[4],t[1]*n[4]+t[3]*n[5]+t[5]]}static applyTransform(t,n){const s=t[0]*n[0]+t[1]*n[2]+n[4],a=t[0]*n[1]+t[1]*n[3]+n[5];return[s,a]}static applyInverseTransform(t,n){const s=n[0]*n[3]-n[1]*n[2],a=(t[0]*n[3]-t[1]*n[2]+n[2]*n[5]-n[4]*n[3])/s,o=(-t[0]*n[1]+t[1]*n[0]+n[4]*n[1]-n[5]*n[0])/s;return[a,o]}static getAxialAlignedBoundingBox(t,n){const s=this.applyTransform(t,n),a=this.applyTransform(t.slice(2,4),n),o=this.applyTransform([t[0],t[3]],n),r=this.applyTransform([t[2],t[1]],n);return[Math.min(s[0],a[0],o[0],r[0]),Math.min(s[1],a[1],o[1],r[1]),Math.max(s[0],a[0],o[0],r[0]),Math.max(s[1],a[1],o[1],r[1])]}static inverseTransform(t){const n=t[0]*t[3]-t[1]*t[2];return[t[3]/n,-t[1]/n,-t[2]/n,t[0]/n,(t[2]*t[5]-t[4]*t[3])/n,(t[4]*t[1]-t[5]*t[0])/n]}static singularValueDecompose2dScale(t){const n=[t[0],t[2],t[1],t[3]],s=t[0]*n[0]+t[1]*n[2],a=t[0]*n[1]+t[1]*n[3],o=t[2]*n[0]+t[3]*n[2],r=t[2]*n[1]+t[3]*n[3],i=(s+r)/2,l=Math.sqrt((s+r)**2-4*(s*r-o*a))/2,c=i+l||1,u=i-l||1;return[Math.sqrt(c),Math.sqrt(u)]}static normalizeRect(t){const n=t.slice(0);return t[0]>t[2]&&(n[0]=t[2],n[2]=t[0]),t[1]>t[3]&&(n[1]=t[3],n[3]=t[1]),n}static intersect(t,n){const s=Math.max(Math.min(t[0],t[2]),Math.min(n[0],n[2])),a=Math.min(Math.max(t[0],t[2]),Math.max(n[0],n[2]));if(s>a)return null;const o=Math.max(Math.min(t[1],t[3]),Math.min(n[1],n[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(n[1],n[3]));return o>r?null:[s,o,a,r]}static bezierBoundingBox(t,n,s,a,o,r,i,l,c){return c?(c[0]=Math.min(c[0],t,i),c[1]=Math.min(c[1],n,l),c[2]=Math.max(c[2],t,i),c[3]=Math.max(c[3],n,l)):c=[Math.min(t,i),Math.min(n,l),Math.max(t,i),Math.max(n,l)],oe(this,hl,Bw).call(this,t,s,o,i,n,a,r,l,3*(-t+3*(s-o)+i),6*(t-2*s+o),3*(s-t),c),oe(this,hl,Bw).call(this,t,s,o,i,n,a,r,l,3*(-n+3*(a-r)+l),6*(n-2*a+r),3*(a-n),c),c}}hl=new WeakSet,Bb=function(t,n,s,a,o,r,i,l,c,u){if(c<=0||c>=1)return;const d=1-c,h=c*c,p=h*c,v=d*(d*(d*t+3*c*n)+3*h*s)+p*a,m=d*(d*(d*o+3*c*r)+3*h*i)+p*l;u[0]=Math.min(u[0],v),u[1]=Math.min(u[1],m),u[2]=Math.max(u[2],v),u[3]=Math.max(u[3],m)},Bw=function(t,n,s,a,o,r,i,l,c,u,d,h){if(Math.abs(c)<1e-12){Math.abs(u)>=1e-12&&oe(this,hl,Bb).call(this,t,n,s,a,o,r,i,l,-d/u,h);return}const p=u**2-4*d*c;if(p<0)return;const v=Math.sqrt(p),m=2*c;oe(this,hl,Bb).call(this,t,n,s,a,o,r,i,l,(-u+v)/m,h),oe(this,hl,Bb).call(this,t,n,s,a,o,r,i,l,(-u-v)/m,h)},ne(zt,hl);function Q1e(e){return decodeURIComponent(escape(e))}let Q8=null,vP=null;function ebe(e){return Q8||(Q8=/([\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,vP=new Map([["ſt","ſt"]])),e.replaceAll(Q8,(t,n,s)=>n?n.normalize("NFKC"):vP.get(s))}function tbe(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=new Uint8Array(32);return crypto.getRandomValues(e),pP(e)}const ew="pdfjs_internal_id_";function nbe(e){return Uint8Array.prototype.toBase64?e.toBase64():btoa(pP(e))}typeof Promise.try!="function"&&(Promise.try=function(e,...t){return new Promise(n=>{n(e(...t))})});const dl="http://www.w3.org/2000/svg",Gu=class Gu{};Ut(Gu,"CSS",96),Ut(Gu,"PDF",72),Ut(Gu,"PDF_TO_CSS_UNITS",Gu.CSS/Gu.PDF);let Sc=Gu;async function sb(e,t="text"){if(xv(e,document.baseURI)){const n=await fetch(e);if(!n.ok)throw new Error(n.statusText);switch(t){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"json":return n.json()}return n.text()}return new Promise((n,s)=>{const a=new XMLHttpRequest;a.open("GET",e,!0),a.responseType=t,a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE){if(a.status===200||a.status===0){switch(t){case"arraybuffer":case"blob":case"json":n(a.response);return}n(a.responseText);return}s(new Error(a.statusText))}},a.send(null)})}class Sv{constructor({viewBox:t,userUnit:n,scale:s,rotation:a,offsetX:o=0,offsetY:r=0,dontFlip:i=!1}){this.viewBox=t,this.userUnit=n,this.scale=s,this.rotation=a,this.offsetX=o,this.offsetY=r,s*=n;const l=(t[2]+t[0])/2,c=(t[3]+t[1])/2;let u,d,h,p;switch(a%=360,a<0&&(a+=360),a){case 180:u=-1,d=0,h=0,p=1;break;case 90:u=0,d=1,h=1,p=0;break;case 270:u=0,d=-1,h=-1,p=0;break;case 0:u=1,d=0,h=0,p=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}i&&(h=-h,p=-p);let v,m,g,b;u===0?(v=Math.abs(c-t[1])*s+o,m=Math.abs(l-t[0])*s+r,g=(t[3]-t[1])*s,b=(t[2]-t[0])*s):(v=Math.abs(l-t[0])*s+o,m=Math.abs(c-t[1])*s+r,g=(t[2]-t[0])*s,b=(t[3]-t[1])*s),this.transform=[u*s,d*s,h*s,p*s,v-u*s*l-h*s*c,m-d*s*l-p*s*c],this.width=g,this.height=b}get rawDims(){const{userUnit:t,viewBox:n}=this,s=n.map(a=>a*t);return mn(this,"rawDims",{pageWidth:s[2]-s[0],pageHeight:s[3]-s[1],pageX:s[0],pageY:s[1]})}clone({scale:t=this.scale,rotation:n=this.rotation,offsetX:s=this.offsetX,offsetY:a=this.offsetY,dontFlip:o=!1}={}){return new Sv({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:n,offsetX:s,offsetY:a,dontFlip:o})}convertToViewportPoint(t,n){return zt.applyTransform([t,n],this.transform)}convertToViewportRectangle(t){const n=zt.applyTransform([t[0],t[1]],this.transform),s=zt.applyTransform([t[2],t[3]],this.transform);return[n[0],n[1],s[0],s[1]]}convertToPdfPoint(t,n){return zt.applyInverseTransform([t,n],this.transform)}}class tw extends _c{constructor(t,n=0){super(t,"RenderingCancelledException"),this.extraDelay=n}}function ab(e){const t=e.length;let n=0;for(;n=1&&a<=12?a-1:0;let o=parseInt(n[3],10);o=o>=1&&o<=31?o:1;let r=parseInt(n[4],10);r=r>=0&&r<=23?r:0;let i=parseInt(n[5],10);i=i>=0&&i<=59?i:0;let l=parseInt(n[6],10);l=l>=0&&l<=59?l:0;const c=n[7]||"Z";let u=parseInt(n[8],10);u=u>=0&&u<=23?u:0;let d=parseInt(n[9],10)||0;return d=d>=0&&d<=59?d:0,c==="-"?(r+=u,i+=d):c==="+"&&(r-=u,i-=d),new Date(Date.UTC(s,a,o,r,i,l))}}Ov=new WeakMap,ne(sw,Ov);function obe(e,{scale:t=1,rotation:n=0}){const{width:s,height:a}=e.attributes.style,o=[0,0,parseInt(s),parseInt(a)];return new Sv({viewBox:o,userUnit:1,scale:t,rotation:n})}function aw(e){if(e.startsWith("#")){const t=parseInt(e.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return e.startsWith("rgb(")?e.slice(4,-1).split(",").map(t=>parseInt(t)):e.startsWith("rgba(")?e.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(fn(`Not a valid color format: "${e}"`),[0,0,0])}function rbe(e){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const n of e.keys()){t.style.color=n;const s=window.getComputedStyle(t).color;e.set(n,aw(s))}t.remove()}function ns(e){const{a:t,b:n,c:s,d:a,e:o,f:r}=e.getTransform();return[t,n,s,a,o,r]}function di(e){const{a:t,b:n,c:s,d:a,e:o,f:r}=e.getTransform().invertSelf();return[t,n,s,a,o,r]}function ju(e,t,n=!1,s=!0){if(t instanceof Sv){const{pageWidth:a,pageHeight:o}=t.rawDims,{style:r}=e,i=La.isCSSRoundSupported,l=`var(--scale-factor) * ${a}px`,c=`var(--scale-factor) * ${o}px`,u=i?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,d=i?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!n||t.rotation%180===0?(r.width=u,r.height=d):(r.width=d,r.height=u)}s&&e.setAttribute("data-main-rotation",t.rotation)}class ow{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}}const pl=class pl{constructor(t){ne(this,Na);ne(this,kc,null);ne(this,Yu,null);ne(this,kr);ne(this,Xu,null);ne(this,Lv,null);G(this,kr,t),y(pl,Nv)||G(pl,Nv,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=G(this,kc,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const n=y(this,kr)._uiManager._signal;t.addEventListener("contextmenu",xr,{signal:n}),t.addEventListener("pointerdown",oe(pl,yb,iR),{signal:n});const s=G(this,Xu,document.createElement("div"));s.className="buttons",t.append(s);const a=y(this,kr).toolbarPosition;if(a){const{style:o}=t,r=y(this,kr)._uiManager.direction==="ltr"?1-a[0]:a[0];o.insetInlineEnd=`${100*r}%`,o.top=`calc(${100*a[1]}% + var(--editor-toolbar-vert-offset))`}return oe(this,Na,uR).call(this),t}get div(){return y(this,kc)}hide(){var t;y(this,kc).classList.add("hidden"),(t=y(this,Yu))==null||t.hideDropdown()}show(){var t;y(this,kc).classList.remove("hidden"),(t=y(this,Lv))==null||t.shown()}async addAltText(t){const n=await t.render();oe(this,Na,Vb).call(this,n),y(this,Xu).prepend(n,y(this,Na,Vw)),G(this,Lv,t)}addColorPicker(t){G(this,Yu,t);const n=t.renderButton();oe(this,Na,Vb).call(this,n),y(this,Xu).prepend(n,y(this,Na,Vw))}remove(){var t;y(this,kc).remove(),(t=y(this,Yu))==null||t.destroy(),G(this,Yu,null)}};kc=new WeakMap,Yu=new WeakMap,kr=new WeakMap,Xu=new WeakMap,Lv=new WeakMap,Nv=new WeakMap,yb=new WeakSet,iR=function(t){t.stopPropagation()},Na=new WeakSet,lR=function(t){y(this,kr)._focusEventsAllowed=!1,go(t)},cR=function(t){y(this,kr)._focusEventsAllowed=!0,go(t)},Vb=function(t){const n=y(this,kr)._uiManager._signal;t.addEventListener("focusin",oe(this,Na,lR).bind(this),{capture:!0,signal:n}),t.addEventListener("focusout",oe(this,Na,cR).bind(this),{capture:!0,signal:n}),t.addEventListener("contextmenu",xr,{signal:n})},uR=function(){const{editorType:t,_uiManager:n}=y(this,kr),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",y(pl,Nv)[t]),oe(this,Na,Vb).call(this,s),s.addEventListener("click",a=>{n.delete()},{signal:n._signal}),y(this,Xu).append(s)},Vw=function(){const t=document.createElement("div");return t.className="divider",t},ne(pl,yb),ne(pl,Nv,null);let rw=pl;class ibe{constructor(t){ne(this,Ec);ne(this,$v,null);ne(this,Ju,null);ne(this,Zu);G(this,Zu,t)}show(t,n,s){const[a,o]=oe(this,Ec,fR).call(this,n,s),{style:r}=y(this,Ju)||G(this,Ju,oe(this,Ec,dR).call(this));t.append(y(this,Ju)),r.insetInlineEnd=`${100*a}%`,r.top=`calc(${100*o}% + var(--editor-toolbar-vert-offset))`}hide(){y(this,Ju).remove()}}$v=new WeakMap,Ju=new WeakMap,Zu=new WeakMap,Ec=new WeakSet,dR=function(){const t=G(this,Ju,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",xr,{signal:y(this,Zu)._signal});const n=G(this,$v,document.createElement("div"));return n.className="buttons",t.append(n),oe(this,Ec,hR).call(this),t},fR=function(t,n){let s=0,a=0;for(const o of t){const r=o.y+o.height;if(rs){a=i,s=r;continue}n?i>a&&(a=i):i{y(this,Zu).highlightSelection("floating_button")},{signal:s}),y(this,$v).append(t)};function ob(e,t,n){for(const s of n)t.addEventListener(s,e[s].bind(e))}class lbe{constructor(){ne(this,wb,0)}get id(){return`${H1e}${za(this,wb)._++}`}}wb=new WeakMap;const Rw=class Rw{constructor(){ne(this,mh);ne(this,vh,tbe());ne(this,Dv,0);ne(this,ya,null)}static get _isSVGFittingCanvas(){const t='data:image/svg+xml;charset=UTF-8,',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),a=new Image;a.src=t;const o=a.decode().then(()=>(s.drawImage(a,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return mn(this,"_isSVGFittingCanvas",o)}async getFromFile(t){const{lastModified:n,name:s,size:a,type:o}=t;return oe(this,mh,zb).call(this,`${n}_${s}_${a}_${o}`,t)}async getFromUrl(t){return oe(this,mh,zb).call(this,t,t)}async getFromBlob(t,n){const s=await n;return oe(this,mh,zb).call(this,t,s)}async getFromId(t){y(this,ya)||G(this,ya,new Map);const n=y(this,ya).get(t);if(!n)return null;if(n.bitmap)return n.refCounter+=1,n;if(n.file)return this.getFromFile(n.file);if(n.blobPromise){const{blobPromise:s}=n;return delete n.blobPromise,this.getFromBlob(n.id,s)}return this.getFromUrl(n.url)}getFromCanvas(t,n){y(this,ya)||G(this,ya,new Map);let s=y(this,ya).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const a=new OffscreenCanvas(n.width,n.height);return a.getContext("2d").drawImage(n,0,0),s={bitmap:a.transferToImageBitmap(),id:`image_${y(this,vh)}_${za(this,Dv)._++}`,refCounter:1,isSvg:!1},y(this,ya).set(t,s),y(this,ya).set(s.id,s),s}getSvgUrl(t){const n=y(this,ya).get(t);return n!=null&&n.isSvg?n.svgUrl:null}deleteId(t){var a;y(this,ya)||G(this,ya,new Map);const n=y(this,ya).get(t);if(!n||(n.refCounter-=1,n.refCounter!==0))return;const{bitmap:s}=n;if(!n.url&&!n.file){const o=new OffscreenCanvas(s.width,s.height);o.getContext("bitmaprenderer").transferFromImageBitmap(s),n.blobPromise=o.convertToBlob()}(a=s.close)==null||a.call(s),n.bitmap=null}isValidId(t){return t.startsWith(`image_${y(this,vh)}_`)}};vh=new WeakMap,Dv=new WeakMap,ya=new WeakMap,mh=new WeakSet,zb=async function(t,n){y(this,ya)||G(this,ya,new Map);let s=y(this,ya).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${y(this,vh)}_${za(this,Dv)._++}`,refCounter:0,isSvg:!1});let a;if(typeof n=="string"?(s.url=n,a=await sb(n,"blob")):n instanceof File?a=s.file=n:n instanceof Blob&&(a=n),a.type==="image/svg+xml"){const o=Rw._isSVGFittingCanvas,r=new FileReader,i=new Image,l=new Promise((c,u)=>{i.onload=()=>{s.bitmap=i,s.isSvg=!0,c()},r.onload=async()=>{const d=s.svgUrl=r.result;i.src=await o?`${d}#svgView(preserveAspectRatio(none))`:d},i.onerror=r.onerror=u});r.readAsDataURL(a),await l}else s.bitmap=await createImageBitmap(a);s.refCounter=1}catch(a){fn(a),s=null}return y(this,ya).set(t,s),s&&y(this,ya).set(s.id,s),s};let iw=Rw;class cbe{constructor(t=128){ne(this,ms,[]);ne(this,Ac,!1);ne(this,Fv);ne(this,ls,-1);G(this,Fv,t)}add({cmd:t,undo:n,post:s,mustExec:a,type:o=NaN,overwriteIfSameType:r=!1,keepUndo:i=!1}){if(a&&t(),y(this,Ac))return;const l={cmd:t,undo:n,post:s,type:o};if(y(this,ls)===-1){y(this,ms).length>0&&(y(this,ms).length=0),G(this,ls,0),y(this,ms).push(l);return}if(r&&y(this,ms)[y(this,ls)].type===o){i&&(l.undo=y(this,ms)[y(this,ls)].undo),y(this,ms)[y(this,ls)]=l;return}const c=y(this,ls)+1;c===y(this,Fv)?y(this,ms).splice(0,1):(G(this,ls,c),c=0;n--)if(y(this,ms)[n].type!==t){y(this,ms).splice(n+1,y(this,ls)-n),G(this,ls,n);return}y(this,ms).length=0,G(this,ls,-1)}}destroy(){G(this,ms,null)}}ms=new WeakMap,Ac=new WeakMap,Fv=new WeakMap,ls=new WeakMap;class kv{constructor(t){ne(this,_b);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:n}=La.platform;for(const[s,a,o={}]of t)for(const r of s){const i=r.startsWith("mac+");n&&i?(this.callbacks.set(r.slice(4),{callback:a,options:o}),this.allKeys.add(r.split("+").at(-1))):!n&&!i&&(this.callbacks.set(r,{callback:a,options:o}),this.allKeys.add(r.split("+").at(-1)))}}exec(t,n){if(!this.allKeys.has(n.key))return;const s=this.callbacks.get(oe(this,_b,pR).call(this,n));if(!s)return;const{callback:a,options:{bubbles:o=!1,args:r=[],checker:i=null}}=s;i&&!i(t,n)||(a.bind(t,...r,n)(),o||go(n))}}_b=new WeakSet,pR=function(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 n=this.buffer.join("+");return this.buffer.length=0,n};const Cb=class Cb{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return rbe(t),mn(this,"_colors",t)}convert(t){const n=aw(t);if(!window.matchMedia("(forced-colors: active)").matches)return n;for(const[s,a]of this._colors)if(a.every((o,r)=>o===n[r]))return Cb._colorsMapping.get(s);return n}getHexCode(t){const n=this._colors.get(t);return n?zt.makeHexColor(...n):t}};Ut(Cb,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let lw=Cb;const Sh=class Sh{constructor(t,n,s,a,o,r,i,l,c,u,d,h,p){ne(this,xt);ne(this,gh,new AbortController);ne(this,bo,null);ne(this,Os,new Map);ne(this,Js,new Map);ne(this,bh,null);ne(this,vl,null);ne(this,yh,null);ne(this,jo,new cbe);ne(this,Tc,null);ne(this,Qu,null);ne(this,wh,0);ne(this,ed,new Set);ne(this,hi,null);ne(this,Er,null);ne(this,td,new Set);Ut(this,"_editorUndoBar",null);ne(this,Bv,!1);ne(this,Vv,!1);ne(this,_h,!1);ne(this,zv,null);ne(this,pi,null);ne(this,Mc,null);ne(this,Ch,null);ne(this,Pc,!1);ne(this,vi,null);ne(this,Sb,new lbe);ne(this,Rc,!1);ne(this,Hv,!1);ne(this,Ic,null);ne(this,nd,null);ne(this,Wv,null);ne(this,jv,null);ne(this,zs,dn.NONE);ne(this,$n,new Set);ne(this,ml,null);ne(this,sd,null);ne(this,Kv,null);ne(this,Uv,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});ne(this,Oc,[0,0]);ne(this,mi,null);ne(this,gl,null);ne(this,qv,null);ne(this,Ko,null);const v=this._signal=y(this,gh).signal;G(this,gl,t),G(this,qv,n),G(this,bh,s),this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:v}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:v}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:v}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:v}),a._on("setpreference",this.onSetPreference.bind(this),{signal:v}),a._on("switchannotationeditorparams",m=>this.updateParams(m.type,m.value),{signal:v}),oe(this,xt,gR).call(this),oe(this,xt,_R).call(this),oe(this,xt,Hw).call(this),G(this,vl,o.annotationStorage),G(this,zv,o.filterFactory),G(this,sd,r),G(this,Ch,i||null),G(this,Bv,l),G(this,Vv,c),G(this,_h,u),G(this,jv,d||null),this.viewParameters={realScale:Sc.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=h||null,this._supportsPinchToZoom=p!==!1}static get _keyboardManager(){const t=Sh.prototype,n=r=>y(r,gl).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:i})=>{if(i instanceof HTMLInputElement){const{type:l}=i;return l!=="text"&&l!=="number"}return!0},a=this.TRANSLATE_SMALL,o=this.TRANSLATE_BIG;return mn(this,"_keyboardManager",new kv([[["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:(r,{target:i})=>!(i instanceof HTMLButtonElement)&&y(r,gl).contains(i)&&!r.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(r,{target:i})=>!(i instanceof HTMLButtonElement)&&y(r,gl).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-a,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-o,0],checker:n}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[a,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[o,0],checker:n}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-a],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-o],checker:n}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,a],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,o],checker:n}]]))}destroy(){var t,n,s,a,o;(t=y(this,Ko))==null||t.resolve(),G(this,Ko,null),(n=y(this,gh))==null||n.abort(),G(this,gh,null),this._signal=null;for(const r of y(this,Js).values())r.destroy();y(this,Js).clear(),y(this,Os).clear(),y(this,td).clear(),G(this,bo,null),y(this,$n).clear(),y(this,jo).destroy(),(s=y(this,bh))==null||s.destroy(),(a=y(this,vi))==null||a.hide(),G(this,vi,null),y(this,pi)&&(clearTimeout(y(this,pi)),G(this,pi,null)),y(this,mi)&&(clearTimeout(y(this,mi)),G(this,mi,null)),(o=this._editorUndoBar)==null||o.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return y(this,jv)}get useNewAltTextFlow(){return y(this,Vv)}get useNewAltTextWhenAddingImage(){return y(this,_h)}get hcmFilter(){return mn(this,"hcmFilter",y(this,sd)?y(this,zv).addHCMFilter(y(this,sd).foreground,y(this,sd).background):"none")}get direction(){return mn(this,"direction",getComputedStyle(y(this,gl)).direction)}get highlightColors(){return mn(this,"highlightColors",y(this,Ch)?new Map(y(this,Ch).split(",").map(t=>t.split("=").map(n=>n.trim()))):null)}get highlightColorNames(){return mn(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),G(this,Qu,t)}setMainHighlightColorPicker(t){G(this,Wv,t)}editAltText(t,n=!1){var s;(s=y(this,bh))==null||s.editAltText(this,t,n)}switchToMode(t,n){this._eventBus.on("annotationeditormodechanged",n,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,n){this._eventBus.dispatch("setpreference",{source:this,name:t,value:n})}onSetPreference({name:t,value:n}){switch(t){case"enableNewAltTextWhenAddingImage":G(this,_h,n);break}}onPageChanging({pageNumber:t}){G(this,wh,t-1)}focusMainContainer(){y(this,gl).focus()}findParent(t,n){for(const s of y(this,Js).values()){const{x:a,y:o,width:r,height:i}=s.div.getBoundingClientRect();if(t>=a&&t<=a+r&&n>=o&&n<=o+i)return s}return null}disableUserSelect(t=!1){y(this,qv).classList.toggle("noUserSelect",t)}addShouldRescale(t){y(this,td).add(t)}removeShouldRescale(t){y(this,td).delete(t)}onScaleChanging({scale:t}){var n;this.commitOrRemove(),this.viewParameters.realScale=t*Sc.PDF_TO_CSS_UNITS;for(const s of y(this,td))s.onScaleChanging();(n=y(this,Qu))==null||n.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const n=document.getSelection();if(!n||n.isCollapsed)return;const{anchorNode:s,anchorOffset:a,focusNode:o,focusOffset:r}=n,i=n.toString(),c=oe(this,xt,Hb).call(this,n).closest(".textLayer"),u=this.getSelectionBoxes(c);if(!u)return;n.empty();const d=oe(this,xt,zw).call(this,c),h=y(this,zs)===dn.NONE,p=()=>{d==null||d.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:u,anchorNode:s,anchorOffset:a,focusNode:o,focusOffset:r,text:i}),h&&this.showAllEditors("highlight",!0,!0)};if(h){this.switchToMode(dn.HIGHLIGHT,p);return}p()}addToAnnotationStorage(t){!t.isEmpty()&&y(this,vl)&&!y(this,vl).has(t.id)&&y(this,vl).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,y(this,Pc)&&(G(this,Pc,!1),oe(this,xt,Wb).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const n of y(this,$n))if(n.div.contains(t)){G(this,nd,[n,t]),n._focusEventsAllowed=!1;break}}focus(){if(!y(this,nd))return;const[t,n]=y(this,nd);G(this,nd,null),n.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),n.focus()}addEditListeners(){oe(this,xt,Hw).call(this),oe(this,xt,Ww).call(this)}removeEditListeners(){oe(this,xt,wR).call(this),oe(this,xt,jw).call(this)}dragOver(t){for(const{type:n}of t.dataTransfer.items)for(const s of y(this,Er))if(s.isHandlingMimeForPasting(n)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const n of t.dataTransfer.items)for(const s of y(this,Er))if(s.isHandlingMimeForPasting(n.type)){s.paste(n,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=y(this,bo))==null||s.commitOrRemove(),!this.hasSelection)return;const n=[];for(const a of y(this,$n)){const o=a.serialize(!0);o&&n.push(o)}n.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(n))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:n}=t;for(const o of n.items)for(const r of y(this,Er))if(r.isHandlingMimeForPasting(o.type)){r.paste(o,this.currentLayer);return}let s=n.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(o){fn(`paste: "${o.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const a=this.currentLayer;try{const o=[];for(const l of s){const c=await a.deserialize(l);if(!c)return;o.push(c)}const r=()=>{for(const l of o)oe(this,xt,Kw).call(this,l);oe(this,xt,Uw).call(this,o)},i=()=>{for(const l of o)l.remove()};this.addCommands({cmd:r,undo:i,mustExec:!0})}catch(o){fn(`paste: "${o.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),y(this,zs)!==dn.NONE&&!this.isEditorHandlingKeyboard&&Sh._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,y(this,Pc)&&(G(this,Pc,!1),oe(this,xt,Wb).call(this,"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}}setEditingState(t){t?(oe(this,xt,bR).call(this),oe(this,xt,Ww).call(this),oe(this,xt,Ha).call(this,{isEditing:y(this,zs)!==dn.NONE,isEmpty:oe(this,xt,c2).call(this),hasSomethingToUndo:y(this,jo).hasSomethingToUndo(),hasSomethingToRedo:y(this,jo).hasSomethingToRedo(),hasSelectedEditor:!1})):(oe(this,xt,yR).call(this),oe(this,xt,jw).call(this),oe(this,xt,Ha).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!y(this,Er)){G(this,Er,t);for(const n of y(this,Er))oe(this,xt,Ul).call(this,n.defaultPropertiesToUpdate)}}getId(){return y(this,Sb).id}get currentLayer(){return y(this,Js).get(y(this,wh))}getLayer(t){return y(this,Js).get(t)}get currentPageIndex(){return y(this,wh)}addLayer(t){y(this,Js).set(t.pageIndex,t),y(this,Rc)?t.enable():t.disable()}removeLayer(t){y(this,Js).delete(t.pageIndex)}async updateMode(t,n=null,s=!1){var a;if(y(this,zs)!==t&&!(y(this,Ko)&&(await y(this,Ko).promise,!y(this,Ko)))){if(G(this,Ko,Promise.withResolvers()),G(this,zs,t),t===dn.NONE){this.setEditingState(!1),oe(this,xt,SR).call(this),(a=this._editorUndoBar)==null||a.hide(),y(this,Ko).resolve();return}this.setEditingState(!0),await oe(this,xt,CR).call(this),this.unselectAll();for(const o of y(this,Js).values())o.updateMode(t);if(!n){s&&this.addNewEditorFromKeyboard(),y(this,Ko).resolve();return}for(const o of y(this,Os).values())o.annotationElementId===n?(this.setSelected(o),o.enterInEditMode()):o.unselect();y(this,Ko).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==y(this,zs)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,n){var s;if(y(this,Er)){switch(t){case _n.CREATE:this.currentLayer.addNewEditor();return;case _n.HIGHLIGHT_DEFAULT_COLOR:(s=y(this,Wv))==null||s.updateColor(n);break;case _n.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(y(this,Kv)||G(this,Kv,new Map)).set(t,n),this.showAllEditors("highlight",n);break}for(const a of y(this,$n))a.updateParams(t,n);for(const a of y(this,Er))a.updateDefaultParams(t,n)}}showAllEditors(t,n,s=!1){var o;for(const r of y(this,Os).values())r.editorType===t&&r.show(n);(((o=y(this,Kv))==null?void 0:o.get(_n.HIGHLIGHT_SHOW_ALL))??!0)!==n&&oe(this,xt,Ul).call(this,[[_n.HIGHLIGHT_SHOW_ALL,n]])}enableWaiting(t=!1){if(y(this,Hv)!==t){G(this,Hv,t);for(const n of y(this,Js).values())t?n.disableClick():n.enableClick(),n.div.classList.toggle("waiting",t)}}getEditors(t){const n=[];for(const s of y(this,Os).values())s.pageIndex===t&&n.push(s);return n}getEditor(t){return y(this,Os).get(t)}addEditor(t){y(this,Os).set(t.id,t)}removeEditor(t){var n;t.div.contains(document.activeElement)&&(y(this,pi)&&clearTimeout(y(this,pi)),G(this,pi,setTimeout(()=>{this.focusMainContainer(),G(this,pi,null)},0))),y(this,Os).delete(t.id),this.unselect(t),(!t.annotationElementId||!y(this,ed).has(t.annotationElementId))&&((n=y(this,vl))==null||n.remove(t.id))}addDeletedAnnotationElement(t){y(this,ed).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return y(this,ed).has(t)}removeDeletedAnnotationElement(t){y(this,ed).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){y(this,bo)!==t&&(G(this,bo,t),t&&oe(this,xt,Ul).call(this,t.propertiesToUpdate))}updateUI(t){y(this,xt,xR)===t&&oe(this,xt,Ul).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){oe(this,xt,Ul).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(y(this,$n).has(t)){y(this,$n).delete(t),t.unselect(),oe(this,xt,Ha).call(this,{hasSelectedEditor:this.hasSelection});return}y(this,$n).add(t),t.select(),oe(this,xt,Ul).call(this,t.propertiesToUpdate),oe(this,xt,Ha).call(this,{hasSelectedEditor:!0})}setSelected(t){var n;(n=y(this,Qu))==null||n.commitOrRemove();for(const s of y(this,$n))s!==t&&s.unselect();y(this,$n).clear(),y(this,$n).add(t),t.select(),oe(this,xt,Ul).call(this,t.propertiesToUpdate),oe(this,xt,Ha).call(this,{hasSelectedEditor:!0})}isSelected(t){return y(this,$n).has(t)}get firstSelectedEditor(){return y(this,$n).values().next().value}unselect(t){t.unselect(),y(this,$n).delete(t),oe(this,xt,Ha).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return y(this,$n).size!==0}get isEnterHandled(){return y(this,$n).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;y(this,jo).undo(),oe(this,xt,Ha).call(this,{hasSomethingToUndo:y(this,jo).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:oe(this,xt,c2).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){y(this,jo).redo(),oe(this,xt,Ha).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:y(this,jo).hasSomethingToRedo(),isEmpty:oe(this,xt,c2).call(this)})}addCommands(t){y(this,jo).add(t),oe(this,xt,Ha).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:oe(this,xt,c2).call(this)})}cleanUndoStack(t){y(this,jo).cleanType(t)}delete(){var o;this.commitOrRemove();const t=(o=this.currentLayer)==null?void 0:o.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const n=t?[t]:[...y(this,$n)],s=()=>{var r;(r=this._editorUndoBar)==null||r.show(a,n.length===1?n[0].editorType:n.length);for(const i of n)i.remove()},a=()=>{for(const r of n)oe(this,xt,Kw).call(this,r)};this.addCommands({cmd:s,undo:a,mustExec:!0})}commitOrRemove(){var t;(t=y(this,bo))==null||t.commitOrRemove()}hasSomethingToControl(){return y(this,bo)||this.hasSelection}selectAll(){for(const t of y(this,$n))t.commit();oe(this,xt,Uw).call(this,y(this,Os).values())}unselectAll(){var t;if(!(y(this,bo)&&(y(this,bo).commitOrRemove(),y(this,zs)!==dn.NONE))&&!((t=y(this,Qu))!=null&&t.commitOrRemove())&&this.hasSelection){for(const n of y(this,$n))n.unselect();y(this,$n).clear(),oe(this,xt,Ha).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,n,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;y(this,Oc)[0]+=t,y(this,Oc)[1]+=n;const[a,o]=y(this,Oc),r=[...y(this,$n)],i=1e3;y(this,mi)&&clearTimeout(y(this,mi)),G(this,mi,setTimeout(()=>{G(this,mi,null),y(this,Oc)[0]=y(this,Oc)[1]=0,this.addCommands({cmd:()=>{for(const l of r)y(this,Os).has(l.id)&&l.translateInPage(a,o)},undo:()=>{for(const l of r)y(this,Os).has(l.id)&&l.translateInPage(-a,-o)},mustExec:!1})},i));for(const l of r)l.translateInPage(t,n)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),G(this,hi,new Map);for(const t of y(this,$n))y(this,hi).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!y(this,hi))return!1;this.disableUserSelect(!1);const t=y(this,hi);G(this,hi,null);let n=!1;for(const[{x:a,y:o,pageIndex:r},i]of t)i.newX=a,i.newY=o,i.newPageIndex=r,n||(n=a!==i.savedX||o!==i.savedY||r!==i.savedPageIndex);if(!n)return!1;const s=(a,o,r,i)=>{if(y(this,Os).has(a.id)){const l=y(this,Js).get(i);l?a._setParentAndPosition(l,o,r):(a.pageIndex=i,a.x=o,a.y=r)}};return this.addCommands({cmd:()=>{for(const[a,{newX:o,newY:r,newPageIndex:i}]of t)s(a,o,r,i)},undo:()=>{for(const[a,{savedX:o,savedY:r,savedPageIndex:i}]of t)s(a,o,r,i)},mustExec:!0}),!0}dragSelectedEditors(t,n){if(y(this,hi))for(const s of y(this,hi).keys())s.drag(t,n)}rebuild(t){if(t.parent===null){const n=this.getLayer(t.pageIndex);n?(n.changeParent(t),n.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||y(this,$n).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return y(this,bo)===t}getActive(){return y(this,bo)}getMode(){return y(this,zs)}get imageManager(){return mn(this,"imageManager",new iw)}getSelectionBoxes(t){if(!t)return null;const n=document.getSelection();for(let c=0,u=n.rangeCount;c({x:(u-a)/r,y:1-(c+d-s)/o,width:h/r,height:d/o});break;case"180":i=(c,u,d,h)=>({x:1-(c+d-s)/o,y:1-(u+h-a)/r,width:d/o,height:h/r});break;case"270":i=(c,u,d,h)=>({x:1-(u+h-a)/r,y:(c-s)/o,width:h/r,height:d/o});break;default:i=(c,u,d,h)=>({x:(c-s)/o,y:(u-a)/r,width:d/o,height:h/r});break}const l=[];for(let c=0,u=n.rangeCount;c{h.type==="pointerup"&&h.button!==0||(c.abort(),l==null||l.toggleDrawing(!0),h.type==="pointerup"&&oe(this,xt,Wb).call(this,"main_toolbar"))};window.addEventListener("pointerup",d,{signal:u}),window.addEventListener("blur",d,{signal:u})}},Wb=function(t=""){y(this,zs)===dn.HIGHLIGHT?this.highlightSelection(t):y(this,Bv)&&oe(this,xt,vR).call(this)},gR=function(){document.addEventListener("selectionchange",oe(this,xt,mR).bind(this),{signal:this._signal})},bR=function(){if(y(this,Mc))return;G(this,Mc,new AbortController);const t=this.combinedSignal(y(this,Mc));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},yR=function(){var t;(t=y(this,Mc))==null||t.abort(),G(this,Mc,null)},Hw=function(){if(y(this,Ic))return;G(this,Ic,new AbortController);const t=this.combinedSignal(y(this,Ic));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},wR=function(){var t;(t=y(this,Ic))==null||t.abort(),G(this,Ic,null)},Ww=function(){if(y(this,Tc))return;G(this,Tc,new AbortController);const t=this.combinedSignal(y(this,Tc));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})},jw=function(){var t;(t=y(this,Tc))==null||t.abort(),G(this,Tc,null)},_R=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Ha=function(t){Object.entries(t).some(([s,a])=>y(this,Uv)[s]!==a)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(y(this,Uv),t)}),y(this,zs)===dn.HIGHLIGHT&&t.hasSelectedEditor===!1&&oe(this,xt,Ul).call(this,[[_n.HIGHLIGHT_FREE,!0]]))},Ul=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},CR=async function(){if(!y(this,Rc)){G(this,Rc,!0);const t=[];for(const n of y(this,Js).values())t.push(n.enable());await Promise.all(t);for(const n of y(this,Os).values())n.enable()}},SR=function(){if(this.unselectAll(),y(this,Rc)){G(this,Rc,!1);for(const t of y(this,Js).values())t.disable();for(const t of y(this,Os).values())t.disable()}},Kw=function(t){const n=y(this,Js).get(t.pageIndex);n?n.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},xR=function(){let t=null;for(t of y(this,$n));return t},c2=function(){if(y(this,Os).size===0)return!0;if(y(this,Os).size===1)for(const t of y(this,Os).values())return t.isEmpty();return!1},Uw=function(t){for(const n of y(this,$n))n.unselect();y(this,$n).clear();for(const n of t)n.isEmpty()||(y(this,$n).add(n),n.select());oe(this,xt,Ha).call(this,{hasSelectedEditor:this.hasSelection})},Ut(Sh,"TRANSLATE_SMALL",1),Ut(Sh,"TRANSLATE_BIG",10);let Ku=Sh;const $a=class $a{constructor(t){ne(this,Tr);ne(this,Hs,null);ne(this,gi,!1);ne(this,Ar,null);ne(this,xh,null);ne(this,bi,null);ne(this,yo,null);ne(this,kh,!1);ne(this,yi,null);ne(this,to,null);ne(this,bl,null);ne(this,ad,null);ne(this,wi,!1);G(this,to,t),G(this,wi,t._uiManager.useNewAltTextFlow),y($a,Lc)||G($a,Lc,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){$a._l10n??($a._l10n=t)}async render(){const t=G(this,Ar,document.createElement("button"));t.className="altText",t.tabIndex="0";const n=G(this,xh,document.createElement("span"));t.append(n),y(this,wi)?(t.classList.add("new"),t.setAttribute("data-l10n-id",y($a,Lc).missing),n.setAttribute("data-l10n-id",y($a,Lc)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=y(this,to)._uiManager._signal;t.addEventListener("contextmenu",xr,{signal:s}),t.addEventListener("pointerdown",o=>o.stopPropagation(),{signal:s});const a=o=>{o.preventDefault(),y(this,to)._uiManager.editAltText(y(this,to)),y(this,wi)&&y(this,to)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:y(this,Tr,u2)}})};return t.addEventListener("click",a,{capture:!0,signal:s}),t.addEventListener("keydown",o=>{o.target===t&&o.key==="Enter"&&(G(this,kh,!0),a(o))},{signal:s}),await oe(this,Tr,jb).call(this),t}finish(){y(this,Ar)&&(y(this,Ar).focus({focusVisible:y(this,kh)}),G(this,kh,!1))}isEmpty(){return y(this,wi)?y(this,Hs)===null:!y(this,Hs)&&!y(this,gi)}hasData(){return y(this,wi)?y(this,Hs)!==null||!!y(this,bl):this.isEmpty()}get guessedText(){return y(this,bl)}async setGuessedText(t){y(this,Hs)===null&&(G(this,bl,t),G(this,ad,await $a._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),oe(this,Tr,jb).call(this))}toggleAltTextBadge(t=!1){var n;if(!y(this,wi)||y(this,Hs)){(n=y(this,yi))==null||n.remove(),G(this,yi,null);return}if(!y(this,yi)){const s=G(this,yi,document.createElement("div"));s.className="noAltTextBadge",y(this,to).div.append(s)}y(this,yi).classList.toggle("hidden",!t)}serialize(t){let n=y(this,Hs);return!t&&y(this,bl)===n&&(n=y(this,ad)),{altText:n,decorative:y(this,gi),guessedText:y(this,bl),textWithDisclaimer:y(this,ad)}}get data(){return{altText:y(this,Hs),decorative:y(this,gi)}}set data({altText:t,decorative:n,guessedText:s,textWithDisclaimer:a,cancel:o=!1}){s&&(G(this,bl,s),G(this,ad,a)),!(y(this,Hs)===t&&y(this,gi)===n)&&(o||(G(this,Hs,t),G(this,gi,n)),oe(this,Tr,jb).call(this))}toggle(t=!1){y(this,Ar)&&(!t&&y(this,yo)&&(clearTimeout(y(this,yo)),G(this,yo,null)),y(this,Ar).disabled=!t)}shown(){y(this,to)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:y(this,Tr,u2)}})}destroy(){var t,n;(t=y(this,Ar))==null||t.remove(),G(this,Ar,null),G(this,xh,null),G(this,bi,null),(n=y(this,yi))==null||n.remove(),G(this,yi,null)}};Hs=new WeakMap,gi=new WeakMap,Ar=new WeakMap,xh=new WeakMap,bi=new WeakMap,yo=new WeakMap,kh=new WeakMap,yi=new WeakMap,to=new WeakMap,bl=new WeakMap,ad=new WeakMap,wi=new WeakMap,Lc=new WeakMap,Tr=new WeakSet,u2=function(){return y(this,Hs)&&"added"||y(this,Hs)===null&&this.guessedText&&"review"||"missing"},jb=async function(){var a,o,r;const t=y(this,Ar);if(!t)return;if(y(this,wi)){if(t.classList.toggle("done",!!y(this,Hs)),t.setAttribute("data-l10n-id",y($a,Lc)[y(this,Tr,u2)]),(a=y(this,xh))==null||a.setAttribute("data-l10n-id",y($a,Lc)[`${y(this,Tr,u2)}-label`]),!y(this,Hs)){(o=y(this,bi))==null||o.remove();return}}else{if(!y(this,Hs)&&!y(this,gi)){t.classList.remove("done"),(r=y(this,bi))==null||r.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let n=y(this,bi);if(!n){G(this,bi,n=document.createElement("span")),n.className="tooltip",n.setAttribute("role","tooltip"),n.id=`alt-text-tooltip-${y(this,to).id}`;const i=100,l=y(this,to)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(y(this,yo)),G(this,yo,null)},{once:!0}),t.addEventListener("mouseenter",()=>{G(this,yo,setTimeout(()=>{G(this,yo,null),y(this,bi).classList.add("show"),y(this,to)._reportTelemetry({action:"alt_text_tooltip"})},i))},{signal:l}),t.addEventListener("mouseleave",()=>{var c;y(this,yo)&&(clearTimeout(y(this,yo)),G(this,yo,null)),(c=y(this,bi))==null||c.classList.remove("show")},{signal:l})}y(this,gi)?n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(n.removeAttribute("data-l10n-id"),n.textContent=y(this,Hs)),n.parentNode||t.append(n);const s=y(this,to).getImageForAltText();s==null||s.setAttribute("aria-describedby",n.id)},ne($a,Lc,null),Ut($a,"_l10n",null);let rb=$a;const Iw=class Iw{constructor({container:t,isPinchingDisabled:n=null,isPinchingStopped:s=null,onPinchStart:a=null,onPinching:o=null,onPinchEnd:r=null,signal:i}){ne(this,wl);ne(this,Gv);ne(this,od,!1);ne(this,Yv,null);ne(this,Xv);ne(this,Jv);ne(this,Zv);ne(this,Qv);ne(this,Eh);ne(this,yl,null);ne(this,rd);ne(this,Nc,null);G(this,Gv,t),G(this,Yv,s),G(this,Xv,n),G(this,Jv,a),G(this,Zv,o),G(this,Qv,r),G(this,rd,new AbortController),G(this,Eh,AbortSignal.any([i,y(this,rd).signal])),t.addEventListener("touchstart",oe(this,wl,kR).bind(this),{passive:!1,signal:y(this,Eh)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return mn(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}destroy(){var t;(t=y(this,rd))==null||t.abort(),G(this,rd,null)}};Gv=new WeakMap,od=new WeakMap,Yv=new WeakMap,Xv=new WeakMap,Jv=new WeakMap,Zv=new WeakMap,Qv=new WeakMap,Eh=new WeakMap,yl=new WeakMap,rd=new WeakMap,Nc=new WeakMap,wl=new WeakSet,kR=function(t){var a,o,r;if((a=y(this,Xv))!=null&&a.call(this)||t.touches.length<2)return;if(!y(this,Nc)){G(this,Nc,new AbortController);const i=AbortSignal.any([y(this,Eh),y(this,Nc).signal]),l=y(this,Gv),c={signal:i,passive:!1};l.addEventListener("touchmove",oe(this,wl,ER).bind(this),c),l.addEventListener("touchend",oe(this,wl,qw).bind(this),c),l.addEventListener("touchcancel",oe(this,wl,qw).bind(this),c),(o=y(this,Jv))==null||o.call(this)}if(go(t),t.touches.length!==2||(r=y(this,Yv))!=null&&r.call(this)){G(this,yl,null);return}let[n,s]=t.touches;n.identifier>s.identifier&&([n,s]=[s,n]),G(this,yl,{touch0X:n.screenX,touch0Y:n.screenY,touch1X:s.screenX,touch1Y:s.screenY})},ER=function(t){var _;if(!y(this,yl)||t.touches.length!==2)return;let[n,s]=t.touches;n.identifier>s.identifier&&([n,s]=[s,n]);const{screenX:a,screenY:o}=n,{screenX:r,screenY:i}=s,l=y(this,yl),{touch0X:c,touch0Y:u,touch1X:d,touch1Y:h}=l,p=d-c,v=h-u,m=r-a,g=i-o,b=Math.hypot(m,g)||1,C=Math.hypot(p,v)||1;if(!y(this,od)&&Math.abs(C-b)<=Iw.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=a,l.touch0Y=o,l.touch1X=r,l.touch1Y=i,t.preventDefault(),!y(this,od)){G(this,od,!0);return}const w=[(a+r)/2,(o+i)/2];(_=y(this,Zv))==null||_.call(this,w,C,b)},qw=function(t){var n;y(this,Nc).abort(),G(this,Nc,null),(n=y(this,Qv))==null||n.call(this),y(this,yl)&&(t.preventDefault(),G(this,yl,null),G(this,od,!1))};let ib=Iw;const hn=class hn{constructor(t){ne(this,Kt);ne(this,id,null);ne(this,Mr,null);ne(this,Jn,null);ne(this,Ah,!1);ne(this,$c,null);ne(this,em,"");ne(this,ld,!1);ne(this,Zs,null);ne(this,cd,null);ne(this,_l,null);ne(this,Dc,null);ne(this,tm,"");ne(this,ud,!1);ne(this,wo,null);ne(this,nm,!1);ne(this,dd,!1);ne(this,Cl,!1);ne(this,_i,null);ne(this,Th,0);ne(this,Mh,0);ne(this,Uo,null);ne(this,fd,null);Ut(this,"_editToolbar",null);Ut(this,"_initialOptions",Object.create(null));Ut(this,"_initialData",null);Ut(this,"_isVisible",!0);Ut(this,"_uiManager",null);Ut(this,"_focusEventsAllowed",!0);ne(this,sm,!1);ne(this,xb,hn._zIndex++);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:n,rawDims:{pageWidth:s,pageHeight:a,pageX:o,pageY:r}}=this.parent.viewport;this.rotation=n,this.pageRotation=(360+n-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,a],this.pageTranslation=[o,r];const[i,l]=this.parentDimensions;this.x=t.x/i,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=hn.prototype._resizeWithKeyboard,n=Ku.TRANSLATE_SMALL,s=Ku.TRANSLATE_BIG;return mn(this,"_resizerKeyboardManager",new kv([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-n,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[n,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-n]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,n]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],hn.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return mn(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const n=new ube({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});n.annotationElementId=t.annotationElementId,n.deleted=!0,n._uiManager.addToAnnotationStorage(n)}static initialize(t,n){if(hn._l10n??(hn._l10n=t),hn._l10nResizer||(hn._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"})),hn._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);hn._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,n){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,n){Hn("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return y(this,sm)}set _isDraggable(t){var n;G(this,sm,t),(n=this.div)==null||n.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,n]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*n/(t*2),this.y+=this.width*t/(n*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*n/(t*2),this.y-=this.width*t/(n*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=y(this,xb)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):oe(this,Kt,d2).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(y(this,ud)?G(this,ud,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const n=t.relatedTarget;n!=null&&n.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,n,s,a){const[o,r]=this.parentDimensions;[s,a]=this.screenToPageTranslation(s,a),this.x=(t+s)/o,this.y=(n+a)/r,this.fixAndSetPosition()}translate(t,n){oe(this,Kt,Gw).call(this,this.parentDimensions,t,n)}translateInPage(t,n){y(this,wo)||G(this,wo,[this.x,this.y,this.width,this.height]),oe(this,Kt,Gw).call(this,this.pageDimensions,t,n),this.div.scrollIntoView({block:"nearest"})}drag(t,n){y(this,wo)||G(this,wo,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[a,o]}=this;if(this.x+=t/a,this.y+=n/o,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:h}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,h)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:i}=this;const[l,c]=this.getBaseTranslation();r+=l,i+=c;const{style:u}=s;u.left=`${(100*r).toFixed(2)}%`,u.top=`${(100*i).toFixed(2)}%`,this._onTranslating(r,i),s.scrollIntoView({block:"nearest"})}_onTranslating(t,n){}_onTranslated(t,n){}get _hasBeenMoved(){return!!y(this,wo)&&(y(this,wo)[0]!==this.x||y(this,wo)[1]!==this.y)}get _hasBeenResized(){return!!y(this,wo)&&(y(this,wo)[2]!==this.width||y(this,wo)[3]!==this.height)}getBaseTranslation(){const[t,n]=this.parentDimensions,{_borderLineWidth:s}=hn,a=s/t,o=s/n;switch(this.rotation){case 90:return[-a,o];case 180:return[a,o];case 270:return[a,-o];default:return[-a,-o]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:n},pageDimensions:[s,a]}=this;let{x:o,y:r,width:i,height:l}=this;if(i*=s,l*=a,o*=s,r*=a,this._mustFixPosition)switch(t){case 0:o=Math.max(0,Math.min(s-i,o)),r=Math.max(0,Math.min(a-l,r));break;case 90:o=Math.max(0,Math.min(s-l,o)),r=Math.min(a,Math.max(i,r));break;case 180:o=Math.min(s,Math.max(i,o)),r=Math.min(a,Math.max(l,r));break;case 270:o=Math.min(s,Math.max(l,o)),r=Math.max(0,Math.min(a-i,r));break}this.x=o/=s,this.y=r/=a;const[c,u]=this.getBaseTranslation();o+=c,r+=u,n.left=`${(100*o).toFixed(2)}%`,n.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,n){var s;return oe(s=hn,am,Yw).call(s,t,n,this.parentRotation)}pageTranslationToScreen(t,n){var s;return oe(s=hn,am,Yw).call(s,t,n,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[n,s]}=this;return[n*t,s*t]}setDims(t,n){const[s,a]=this.parentDimensions,{style:o}=this.div;o.width=`${(100*t/s).toFixed(2)}%`,y(this,ld)||(o.height=`${(100*n/a).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:n,width:s}=t,a=s.endsWith("%"),o=!y(this,ld)&&n.endsWith("%");if(a&&o)return;const[r,i]=this.parentDimensions;a||(t.width=`${(100*parseFloat(s)/r).toFixed(2)}%`),!y(this,ld)&&!o&&(t.height=`${(100*parseFloat(n)/i).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=y(this,Jn))==null||t.finish()}async addEditToolbar(){return this._editToolbar||y(this,dd)?this._editToolbar:(this._editToolbar=new rw(this),this.div.append(this._editToolbar.render()),y(this,Jn)&&await this._editToolbar.addAltText(y(this,Jn)),this._editToolbar)}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=y(this,Jn))==null||t.destroy())}addContainer(t){var s;const n=(s=this._editToolbar)==null?void 0:s.div;n?n.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){y(this,Jn)||(rb.initialize(hn._l10n),G(this,Jn,new rb(this)),y(this,id)&&(y(this,Jn).data=y(this,id),G(this,id,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=y(this,Jn))==null?void 0:t.data}set altTextData(t){y(this,Jn)&&(y(this,Jn).data=t)}get guessedAltText(){var t;return(t=y(this,Jn))==null?void 0:t.guessedText}async setGuessedAltText(t){var n;await((n=y(this,Jn))==null?void 0:n.setGuessedText(t))}serializeAltText(t){var n;return(n=y(this,Jn))==null?void 0:n.serialize(t)}hasAltText(){return!!y(this,Jn)&&!y(this,Jn).isEmpty()}hasAltTextData(){var t;return((t=y(this,Jn))==null?void 0:t.hasData())??!1}render(){var o;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=y(this,Ah)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),oe(this,Kt,Qw).call(this);const[t,n]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*n/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/n).toFixed(2)}%`);const[s,a]=this.getInitialTranslation();return this.translate(s,a),ob(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(y(this,fd)||G(this,fd,new ib({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:oe(this,Kt,MR).bind(this),onPinching:oe(this,Kt,PR).bind(this),onPinchEnd:oe(this,Kt,RR).bind(this),signal:this._uiManager._signal}))),(o=this._uiManager._editorUndoBar)==null||o.hide(),this.div}pointerdown(t){const{isMac:n}=La.platform;if(t.button!==0||t.ctrlKey&&n){t.preventDefault();return}if(G(this,ud,!0),this._isDraggable){oe(this,Kt,IR).call(this,t);return}oe(this,Kt,Zw).call(this,t)}get isSelected(){return this._uiManager.isSelected(this)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){y(this,_i)&&clearTimeout(y(this,_i)),G(this,_i,setTimeout(()=>{var t;G(this,_i,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,n,s){t.changeParent(this),this.x=n,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,n,s=this.rotation){const a=this.parentScale,[o,r]=this.pageDimensions,[i,l]=this.pageTranslation,c=t/a,u=n/a,d=this.x*o,h=this.y*r,p=this.width*o,v=this.height*r;switch(s){case 0:return[d+c+i,r-h-u-v+l,d+c+p+i,r-h-u+l];case 90:return[d+u+i,r-h+c+l,d+u+v+i,r-h+c+p+l];case 180:return[d-c-p+i,r-h+u+l,d-c+i,r-h+u+v+l];case 270:return[d-u-v+i,r-h-c-p+l,d-u+i,r-h-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,n){const[s,a,o,r]=t,i=o-s,l=r-a;switch(this.rotation){case 0:return[s,n-r,i,l];case 90:return[s,n-a,l,i];case 180:return[o,n-a,i,l];case 270:return[o,n-r,l,i];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){G(this,dd,!0)}disableEditMode(){G(this,dd,!1)}isInEditMode(){return y(this,dd)}shouldGetKeyboardEvents(){return y(this,Cl)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:n,bottom:s,right:a}=this.getClientDimensions(),{innerHeight:o,innerWidth:r}=window;return n0&&t0}rebuild(){oe(this,Kt,Qw).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,n=null){Hn("An editor must be serializable")}static async deserialize(t,n,s){const a=new this.prototype.constructor({parent:n,id:n.getNextId(),uiManager:s});a.rotation=t.rotation,G(a,id,t.accessibilityData);const[o,r]=a.pageDimensions,[i,l,c,u]=a.getRectInCurrentCoords(t.rect,r);return a.x=i/o,a.y=l/r,a.width=c/o,a.height=u/r,a}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,n;if((t=y(this,Dc))==null||t.abort(),G(this,Dc,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),y(this,_i)&&(clearTimeout(y(this,_i)),G(this,_i,null)),oe(this,Kt,d2).call(this),this.removeEditToolbar(),y(this,Uo)){for(const s of y(this,Uo).values())clearTimeout(s);G(this,Uo,null)}this.parent=null,(n=y(this,fd))==null||n.destroy(),G(this,fd,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(oe(this,Kt,AR).call(this),y(this,Zs).classList.remove("hidden"),ob(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),G(this,_l,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const n=y(this,Zs).children;if(!y(this,Mr)){G(this,Mr,Array.from(n));const r=oe(this,Kt,OR).bind(this),i=oe(this,Kt,LR).bind(this),l=this._uiManager._signal;for(const c of y(this,Mr)){const u=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",r,{signal:l}),c.addEventListener("blur",i,{signal:l}),c.addEventListener("focus",oe(this,Kt,NR).bind(this,u),{signal:l}),c.setAttribute("data-l10n-id",hn._l10nResizer[u])}}const s=y(this,Mr)[0];let a=0;for(const r of n){if(r===s)break;a++}const o=(360-this.rotation+this.parentRotation)%360/90*(y(this,Mr).length/4);if(o!==a){if(oa)for(let i=0;i{var a,o;(a=this.div)!=null&&a.classList.contains("selectedEditor")&&((o=this._editToolbar)==null||o.show())});return}(n=this._editToolbar)==null||n.show(),(s=y(this,Jn))==null||s.toggleAltTextBadge(!1)}unselect(){var t,n,s,a,o;(t=y(this,Zs))==null||t.classList.add("hidden"),(n=this.div)==null||n.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(a=this._editToolbar)==null||a.hide(),(o=y(this,Jn))==null||o.toggleAltTextBadge(!0)}updateParams(t,n){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return y(this,nm)}set isEditing(t){G(this,nm,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,n){G(this,ld,!0);const s=t/n,{style:a}=this.div;a.aspectRatio=s,a.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,n=!1){if(n){y(this,Uo)||G(this,Uo,new Map);const{action:s}=t;let a=y(this,Uo).get(s);a&&clearTimeout(a),a=setTimeout(()=>{this._reportTelemetry(t),y(this,Uo).delete(s),y(this,Uo).size===0&&G(this,Uo,null)},hn._telemetryTimeout),y(this,Uo).set(s,a);return}t.type||(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),G(this,Ah,!1)}disable(){this.div&&(this.div.tabIndex=-1),G(this,Ah,!0)}renderAnnotationElement(t){let n=t.container.querySelector(".annotationContent");if(!n)n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),t.container.prepend(n);else if(n.nodeName==="CANVAS"){const s=n;n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),s.before(n)}return n}resetAnnotationElement(t){const{firstChild:n}=t.container;(n==null?void 0:n.nodeName)==="DIV"&&n.classList.contains("annotationContent")&&n.remove()}};id=new WeakMap,Mr=new WeakMap,Jn=new WeakMap,Ah=new WeakMap,$c=new WeakMap,em=new WeakMap,ld=new WeakMap,Zs=new WeakMap,cd=new WeakMap,_l=new WeakMap,Dc=new WeakMap,tm=new WeakMap,ud=new WeakMap,wo=new WeakMap,nm=new WeakMap,dd=new WeakMap,Cl=new WeakMap,_i=new WeakMap,Th=new WeakMap,Mh=new WeakMap,Uo=new WeakMap,fd=new WeakMap,sm=new WeakMap,xb=new WeakMap,Kt=new WeakSet,Gw=function([t,n],s,a){[s,a]=this.screenToPageTranslation(s,a),this.x+=s/t,this.y+=a/n,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},am=new WeakSet,Yw=function(t,n,s){switch(s){case 90:return[n,-t];case 180:return[-t,-n];case 270:return[-n,t];default:return[t,n]}},Kb=function(t){switch(t){case 90:{const[n,s]=this.pageDimensions;return[0,-n/s,s/n,0]}case 180:return[-1,0,0,-1];case 270:{const[n,s]=this.pageDimensions;return[0,n/s,-s/n,0]}default:return[1,0,0,1]}},AR=function(){if(y(this,Zs))return;G(this,Zs,document.createElement("div")),y(this,Zs).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],n=this._uiManager._signal;for(const s of t){const a=document.createElement("div");y(this,Zs).append(a),a.classList.add("resizer",s),a.setAttribute("data-resizer-name",s),a.addEventListener("pointerdown",oe(this,Kt,TR).bind(this,s),{signal:n}),a.addEventListener("contextmenu",xr,{signal:n}),a.tabIndex=-1}this.div.prepend(y(this,Zs))},TR=function(t,n){var u;n.preventDefault();const{isMac:s}=La.platform;if(n.button!==0||n.ctrlKey&&s)return;(u=y(this,Jn))==null||u.toggle(!1);const a=this._isDraggable;this._isDraggable=!1,G(this,cd,[n.screenX,n.screenY]);const o=new AbortController,r=this._uiManager.combinedSignal(o);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",oe(this,Kt,Jw).bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",go,{passive:!1,signal:r}),window.addEventListener("contextmenu",xr,{signal:r}),G(this,_l,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const i=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(n.target).cursor;const c=()=>{var d;o.abort(),this.parent.togglePointerEvents(!0),(d=y(this,Jn))==null||d.toggle(!0),this._isDraggable=a,this.parent.div.style.cursor=i,this.div.style.cursor=l,oe(this,Kt,Ub).call(this)};window.addEventListener("pointerup",c,{signal:r}),window.addEventListener("blur",c,{signal:r})},Xw=function(t,n,s,a){this.width=s,this.height=a,this.x=t,this.y=n;const[o,r]=this.parentDimensions;this.setDims(o*s,r*a),this.fixAndSetPosition(),this._onResized()},Ub=function(){if(!y(this,_l))return;const{savedX:t,savedY:n,savedWidth:s,savedHeight:a}=y(this,_l);G(this,_l,null);const o=this.x,r=this.y,i=this.width,l=this.height;o===t&&r===n&&i===s&&l===a||this.addCommands({cmd:oe(this,Kt,Xw).bind(this,o,r,i,l),undo:oe(this,Kt,Xw).bind(this,t,n,s,a),mustExec:!0})},Jw=function(t,n){const[s,a]=this.parentDimensions,o=this.x,r=this.y,i=this.width,l=this.height,c=hn.MIN_SIZE/s,u=hn.MIN_SIZE/a,d=oe(this,Kt,Kb).call(this,this.rotation),h=(Y,L)=>[d[0]*Y+d[2]*L,d[1]*Y+d[3]*L],p=oe(this,Kt,Kb).call(this,360-this.rotation),v=(Y,L)=>[p[0]*Y+p[2]*L,p[1]*Y+p[3]*L];let m,g,b=!1,C=!1;switch(t){case"topLeft":b=!0,m=(Y,L)=>[0,0],g=(Y,L)=>[Y,L];break;case"topMiddle":m=(Y,L)=>[Y/2,0],g=(Y,L)=>[Y/2,L];break;case"topRight":b=!0,m=(Y,L)=>[Y,0],g=(Y,L)=>[0,L];break;case"middleRight":C=!0,m=(Y,L)=>[Y,L/2],g=(Y,L)=>[0,L/2];break;case"bottomRight":b=!0,m=(Y,L)=>[Y,L],g=(Y,L)=>[0,0];break;case"bottomMiddle":m=(Y,L)=>[Y/2,L],g=(Y,L)=>[Y/2,0];break;case"bottomLeft":b=!0,m=(Y,L)=>[0,L],g=(Y,L)=>[Y,0];break;case"middleLeft":C=!0,m=(Y,L)=>[0,L/2],g=(Y,L)=>[Y,L/2];break}const w=m(i,l),_=g(i,l);let x=h(..._);const k=hn._round(o+x[0]),T=hn._round(r+x[1]);let I=1,O=1,R,$;if(n.fromKeyboard)({deltaX:R,deltaY:$}=n);else{const{screenX:Y,screenY:L}=n,[N,V]=y(this,cd);[R,$]=this.screenToPageTranslation(Y-N,L-V),y(this,cd)[0]=Y,y(this,cd)[1]=L}if([R,$]=v(R/s,$/a),b){const Y=Math.hypot(i,l);I=O=Math.max(Math.min(Math.hypot(_[0]-w[0]-R,_[1]-w[1]-$)/Y,1/i,1/l),c/i,u/l)}else C?I=Math.max(c,Math.min(1,Math.abs(_[0]-w[0]-R)))/i:O=Math.max(u,Math.min(1,Math.abs(_[1]-w[1]-$)))/l;const M=hn._round(i*I),B=hn._round(l*O);x=h(...g(M,B));const U=k-x[0],J=T-x[1];y(this,wo)||G(this,wo,[this.x,this.y,this.width,this.height]),this.width=M,this.height=B,this.x=U,this.y=J,this.setDims(s*M,a*B),this.fixAndSetPosition(),this._onResizing()},MR=function(){var t;G(this,_l,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=y(this,Jn))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},PR=function(t,n,s){let o=.7*(s/n)+1-.7;if(o===1)return;const r=oe(this,Kt,Kb).call(this,this.rotation),i=(k,T)=>[r[0]*k+r[2]*T,r[1]*k+r[3]*T],[l,c]=this.parentDimensions,u=this.x,d=this.y,h=this.width,p=this.height,v=hn.MIN_SIZE/l,m=hn.MIN_SIZE/c;o=Math.max(Math.min(o,1/h,1/p),v/h,m/p);const g=hn._round(h*o),b=hn._round(p*o);if(g===h&&b===p)return;y(this,wo)||G(this,wo,[u,d,h,p]);const C=i(h/2,p/2),w=hn._round(u+C[0]),_=hn._round(d+C[1]),x=i(g/2,b/2);this.x=w-x[0],this.y=_-x[1],this.width=g,this.height=b,this.setDims(l*g,c*b),this.fixAndSetPosition(),this._onResizing()},RR=function(){var t;(t=y(this,Jn))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),oe(this,Kt,Ub).call(this)},Zw=function(t){const{isMac:n}=La.platform;t.ctrlKey&&!n||t.shiftKey||t.metaKey&&n?this.parent.toggleSelected(this):this.parent.setSelected(this)},IR=function(t){const{isSelected:n}=this;this._uiManager.setUpDragSession();let s=!1;const a=new AbortController,o=this._uiManager.combinedSignal(a),r={capture:!0,passive:!1,signal:o},i=c=>{a.abort(),G(this,$c,null),G(this,ud,!1),this._uiManager.endDragSession()||oe(this,Kt,Zw).call(this,c),s&&this._onStopDragging()};n&&(G(this,Th,t.clientX),G(this,Mh,t.clientY),G(this,$c,t.pointerId),G(this,em,t.pointerType),window.addEventListener("pointermove",c=>{s||(s=!0,this._onStartDragging());const{clientX:u,clientY:d,pointerId:h}=c;if(h!==y(this,$c)){go(c);return}const[p,v]=this.screenToPageTranslation(u-y(this,Th),d-y(this,Mh));G(this,Th,u),G(this,Mh,d),this._uiManager.dragSelectedEditors(p,v)},r),window.addEventListener("touchmove",go,r),window.addEventListener("pointerdown",c=>{c.pointerType===y(this,em)&&(y(this,fd)||c.isPrimary)&&i(c),go(c)},r));const l=c=>{if(!y(this,$c)||y(this,$c)===c.pointerId){i(c);return}go(c)};window.addEventListener("pointerup",l,{signal:o}),window.addEventListener("blur",l,{signal:o})},Qw=function(){if(y(this,Dc)||!this.div)return;G(this,Dc,new AbortController);const t=this._uiManager.combinedSignal(y(this,Dc));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},OR=function(t){hn._resizerKeyboardManager.exec(this,t)},LR=function(t){var n;y(this,Cl)&&((n=t.relatedTarget)==null?void 0:n.parentNode)!==y(this,Zs)&&oe(this,Kt,d2).call(this)},NR=function(t){G(this,tm,y(this,Cl)?t:"")},e_=function(t){if(y(this,Mr))for(const n of y(this,Mr))n.tabIndex=t},d2=function(){G(this,Cl,!1),oe(this,Kt,e_).call(this,-1),oe(this,Kt,Ub).call(this)},ne(hn,am),Ut(hn,"_l10n",null),Ut(hn,"_l10nResizer",null),Ut(hn,"_borderLineWidth",-1),Ut(hn,"_colorManager",new lw),Ut(hn,"_zIndex",1),Ut(hn,"_telemetryTimeout",1e3);let is=hn;class ube extends is{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const gP=3285377520,Wo=4294901760,fi=65535;class bP{constructor(t){this.h1=t?t&4294967295:gP,this.h2=t?t&4294967295:gP}update(t){let n,s;if(typeof t=="string"){n=new Uint8Array(t.length*2),s=0;for(let m=0,g=t.length;m>>8,n[s++]=b&255)}}else if(ArrayBuffer.isView(t))n=t.slice(),s=n.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const a=s>>2,o=s-a*4,r=new Uint32Array(n.buffer,0,a);let i=0,l=0,c=this.h1,u=this.h2;const d=3432918353,h=461845907,p=d&fi,v=h&fi;for(let m=0;m>>17,i=i*h&Wo|i*v&fi,c^=i,c=c<<13|c>>>19,c=c*5+3864292196):(l=r[m],l=l*d&Wo|l*p&fi,l=l<<15|l>>>17,l=l*h&Wo|l*v&fi,u^=l,u=u<<13|u>>>19,u=u*5+3864292196);switch(i=0,o){case 3:i^=n[a*4+2]<<16;case 2:i^=n[a*4+1]<<8;case 1:i^=n[a*4],i=i*d&Wo|i*p&fi,i=i<<15|i>>>17,i=i*h&Wo|i*v&fi,a&1?c^=i:u^=i}this.h1=c,this.h2=u}hexdigest(){let t=this.h1,n=this.h2;return t^=n>>>1,t=t*3981806797&Wo|t*36045&fi,n=n*4283543511&Wo|((n<<16|t>>>16)*2950163797&Wo)>>>16,t^=n>>>1,t=t*444984403&Wo|t*60499&fi,n=n*3301882366&Wo|((n<<16|t>>>16)*3120437893&Wo)>>>16,t^=n>>>1,(t>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")}}const cw=Object.freeze({map:null,hash:"",transfer:void 0});class uw{constructor(){ne(this,kb);ne(this,hd,!1);ne(this,pd,null);ne(this,Ws,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,n){const s=y(this,Ws).get(t);return s===void 0?n:Object.assign(n,s)}getRawValue(t){return y(this,Ws).get(t)}remove(t){if(y(this,Ws).delete(t),y(this,Ws).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const n of y(this,Ws).values())if(n instanceof is)return;this.onAnnotationEditor(null)}}setValue(t,n){const s=y(this,Ws).get(t);let a=!1;if(s!==void 0)for(const[o,r]of Object.entries(n))s[o]!==r&&(a=!0,s[o]=r);else a=!0,y(this,Ws).set(t,n);a&&oe(this,kb,$R).call(this),n instanceof is&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(n.constructor._type)}has(t){return y(this,Ws).has(t)}getAll(){return y(this,Ws).size>0?J8(y(this,Ws)):null}setAll(t){for(const[n,s]of Object.entries(t))this.setValue(n,s)}get size(){return y(this,Ws).size}resetModified(){y(this,hd)&&(G(this,hd,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new yP(this)}get serializable(){if(y(this,Ws).size===0)return cw;const t=new Map,n=new bP,s=[],a=Object.create(null);let o=!1;for(const[r,i]of y(this,Ws)){const l=i instanceof is?i.serialize(!1,a):i;l&&(t.set(r,l),n.update(`${r}:${JSON.stringify(l)}`),o||(o=!!l.bitmap))}if(o)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:n.hexdigest(),transfer:s}:cw}get editorStats(){let t=null;const n=new Map;for(const s of y(this,Ws).values()){if(!(s instanceof is))continue;const a=s.telemetryFinalData;if(!a)continue;const{type:o}=a;n.has(o)||n.set(o,Object.getPrototypeOf(s).constructor),t||(t=Object.create(null));const r=t[o]||(t[o]=new Map);for(const[i,l]of Object.entries(a)){if(i==="type")continue;let c=r.get(i);c||(c=new Map,r.set(i,c));const u=c.get(l)??0;c.set(l,u+1)}}for(const[s,a]of n)t[s]=a.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){G(this,pd,null)}get modifiedIds(){if(y(this,pd))return y(this,pd);const t=[];for(const n of y(this,Ws).values())!(n instanceof is)||!n.annotationElementId||!n.serialize()||t.push(n.annotationElementId);return G(this,pd,{ids:new Set(t),hash:t.join(",")})}}hd=new WeakMap,pd=new WeakMap,Ws=new WeakMap,kb=new WeakSet,$R=function(){y(this,hd)||(G(this,hd,!0),typeof this.onSetModified=="function"&&this.onSetModified())};class yP extends uw{constructor(n){super();ne(this,om);const{map:s,hash:a,transfer:o}=n.serializable,r=structuredClone(s,o?{transfer:o}:null);G(this,om,{map:r,hash:a,transfer:o})}get print(){Hn("Should not call PrintAnnotationStorage.print")}get serializable(){return y(this,om)}get modifiedIds(){return mn(this,"modifiedIds",{ids:new Set,hash:""})}}om=new WeakMap;class dbe{constructor({ownerDocument:t=globalThis.document,styleElement:n=null}){ne(this,Ph,new Set);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 n=this.styleElement.sheet;n.insertRule(t,n.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),y(this,Ph).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:n}){if(!(!t||y(this,Ph).has(t.loadedName))){if(Ss(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:a,style:o}=t,r=new FontFace(s,a,o);this.addNativeFontFace(r);try{await r.load(),y(this,Ph).add(s),n==null||n(t)}catch{fn(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}Hn("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(a){throw fn(`Failed to load font '${s.family}': '${a}'.`),t.disableFontFace=!0,a}}return}const n=t.createFontFaceRule();if(n){if(this.insertRule(n),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const a=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,a)})}}get isFontLoadingAPISupported(){var n;const t=!!((n=this._document)!=null&&n.fonts);return mn(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(ma||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),mn(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function n(){for(Ss(!a.done,"completeRequest() cannot be called twice."),a.done=!0;s.length>0&&s[0].done;){const o=s.shift();setTimeout(o.callback,0)}}const{loadingRequests:s}=this,a={done:!1,complete:n,callback:t};return s.push(a),a}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return mn(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,n){function s(_,x){return _.charCodeAt(x)<<24|_.charCodeAt(x+1)<<16|_.charCodeAt(x+2)<<8|_.charCodeAt(x+3)&255}function a(_,x,k,T){const I=_.substring(0,x),O=_.substring(x+k);return I+T+O}let o,r;const i=this._document.createElement("canvas");i.width=1,i.height=1;const l=i.getContext("2d");let c=0;function u(_,x){if(++c>30){fn("Load test font never loaded."),x();return}if(l.font="30px "+_,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){x();return}setTimeout(u.bind(null,_,x))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let h=this._loadTestFont;h=a(h,976,d.length,d);const v=16,m=1482184792;let g=s(h,v);for(o=0,r=d.length-3;o{w.remove(),n.complete()})}}Ph=new WeakMap;class fbe{constructor(t,{disableFontFace:n=!1,fontExtraProperties:s=!1,inspectFont:a=null}){this.compiledGlyphs=Object.create(null);for(const o in t)this[o]=t[o];this.disableFontFace=n===!0,this.fontExtraProperties=s===!0,this._inspectFont=a}createNativeFontFace(){var n;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(n=this._inspectFont)==null||n.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${nbe(this.data)});`;let n;if(!this.cssFontInfo)n=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let a=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(a+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${a}src:${t}}`}return(s=this._inspectFont)==null||s.call(this,this,t),n}getPathGenerator(t,n){if(this.compiledGlyphs[n]!==void 0)return this.compiledGlyphs[n];const s=this.loadedName+"_path_"+n;let a;try{a=t.get(s)}catch(r){fn(`getPathGenerator - ignoring character: "${r}".`)}const o=new Path2D(a||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[n]=o}}const lb={DATA:1,ERROR:2},xs={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function wP(){}function Za(e){if(e instanceof Cc||e instanceof X8||e instanceof Cv||e instanceof hP||e instanceof tb||e instanceof Y8)return e;switch(e instanceof Error||typeof e=="object"&&e!==null||Hn('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),e.name){case"AbortException":return new Cc(e.message);case"InvalidPDFException":return new X8(e.message);case"MissingPDFException":return new Cv(e.message);case"PasswordException":return new hP(e.message,e.code);case"UnexpectedResponseException":return new tb(e.message,e.status);case"UnknownErrorException":return new Y8(e.message,e.details)}return new Y8(e.message,e.toString())}class Ev{constructor(t,n,s){ne(this,qo);ne(this,Rh,new AbortController);this.sourceName=t,this.targetName=n,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",oe(this,qo,DR).bind(this),{signal:y(this,Rh).signal})}on(t,n){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=n}send(t,n,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:n},s)}sendWithPromise(t,n,s){const a=this.callbackId++,o=Promise.withResolvers();this.callbackCapabilities[a]=o;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:a,data:n},s)}catch(r){o.reject(r)}return o.promise}sendWithStream(t,n,s,a){const o=this.streamId++,r=this.sourceName,i=this.targetName,l=this.comObj;return new ReadableStream({start:c=>{const u=Promise.withResolvers();return this.streamControllers[o]={controller:c,startCall:u,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:r,targetName:i,action:t,streamId:o,data:n,desiredSize:c.desiredSize},a),u.promise},pull:c=>{const u=Promise.withResolvers();return this.streamControllers[o].pullCall=u,l.postMessage({sourceName:r,targetName:i,stream:xs.PULL,streamId:o,desiredSize:c.desiredSize}),u.promise},cancel:c=>{Ss(c instanceof Error,"cancel must have a valid reason");const u=Promise.withResolvers();return this.streamControllers[o].cancelCall=u,this.streamControllers[o].isClosed=!0,l.postMessage({sourceName:r,targetName:i,stream:xs.CANCEL,streamId:o,reason:Za(c)}),u.promise}},s)}destroy(){var t;(t=y(this,Rh))==null||t.abort(),G(this,Rh,null)}}Rh=new WeakMap,qo=new WeakSet,DR=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){oe(this,qo,BR).call(this,t);return}if(t.callback){const s=t.callbackId,a=this.callbackCapabilities[s];if(!a)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===lb.DATA)a.resolve(t.data);else if(t.callback===lb.ERROR)a.reject(Za(t.reason));else throw new Error("Unexpected callback case");return}const n=this.actionHandler[t.action];if(!n)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,a=t.sourceName,o=this.comObj;Promise.try(n,t.data).then(function(r){o.postMessage({sourceName:s,targetName:a,callback:lb.DATA,callbackId:t.callbackId,data:r})},function(r){o.postMessage({sourceName:s,targetName:a,callback:lb.ERROR,callbackId:t.callbackId,reason:Za(r)})});return}if(t.streamId){oe(this,qo,FR).call(this,t);return}n(t.data)},FR=function(t){const n=t.streamId,s=this.sourceName,a=t.sourceName,o=this.comObj,r=this,i=this.actionHandler[t.action],l={enqueue(c,u=1,d){if(this.isCancelled)return;const h=this.desiredSize;this.desiredSize-=u,h>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),o.postMessage({sourceName:s,targetName:a,stream:xs.ENQUEUE,streamId:n,chunk:c},d)},close(){this.isCancelled||(this.isCancelled=!0,o.postMessage({sourceName:s,targetName:a,stream:xs.CLOSE,streamId:n}),delete r.streamSinks[n])},error(c){Ss(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,o.postMessage({sourceName:s,targetName:a,stream:xs.ERROR,streamId:n,reason:Za(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[n]=l,Promise.try(i,t.data,l).then(function(){o.postMessage({sourceName:s,targetName:a,stream:xs.START_COMPLETE,streamId:n,success:!0})},function(c){o.postMessage({sourceName:s,targetName:a,stream:xs.START_COMPLETE,streamId:n,reason:Za(c)})})},BR=function(t){const n=t.streamId,s=this.sourceName,a=t.sourceName,o=this.comObj,r=this.streamControllers[n],i=this.streamSinks[n];switch(t.stream){case xs.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(Za(t.reason));break;case xs.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(Za(t.reason));break;case xs.PULL:if(!i){o.postMessage({sourceName:s,targetName:a,stream:xs.PULL_COMPLETE,streamId:n,success:!0});break}i.desiredSize<=0&&t.desiredSize>0&&i.sinkCapability.resolve(),i.desiredSize=t.desiredSize,Promise.try(i.onPull||wP).then(function(){o.postMessage({sourceName:s,targetName:a,stream:xs.PULL_COMPLETE,streamId:n,success:!0})},function(c){o.postMessage({sourceName:s,targetName:a,stream:xs.PULL_COMPLETE,streamId:n,reason:Za(c)})});break;case xs.ENQUEUE:if(Ss(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case xs.CLOSE:if(Ss(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),oe(this,qo,qb).call(this,r,n);break;case xs.ERROR:Ss(r,"error should have stream controller"),r.controller.error(Za(t.reason)),oe(this,qo,qb).call(this,r,n);break;case xs.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(Za(t.reason)),oe(this,qo,qb).call(this,r,n);break;case xs.CANCEL:if(!i)break;const l=Za(t.reason);Promise.try(i.onCancel||wP,l).then(function(){o.postMessage({sourceName:s,targetName:a,stream:xs.CANCEL_COMPLETE,streamId:n,success:!0})},function(c){o.postMessage({sourceName:s,targetName:a,stream:xs.CANCEL_COMPLETE,streamId:n,reason:Za(c)})}),i.sinkCapability.reject(l),i.isCancelled=!0,delete this.streamSinks[n];break;default:throw new Error("Unexpected stream case")}},qb=async function(t,n){var s,a,o;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(a=t.pullCall)==null?void 0:a.promise,(o=t.cancelCall)==null?void 0:o.promise]),delete this.streamControllers[n]};class _P{constructor({enableHWA:t=!1}){ne(this,rm,!1);G(this,rm,t)}create(t,n){if(t<=0||n<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,n);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!y(this,rm)})}}reset(t,n,s){if(!t.canvas)throw new Error("Canvas is not specified");if(n<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=n,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,n){Hn("Abstract method `_createCanvas` called.")}}rm=new WeakMap;class hbe extends _P{constructor({ownerDocument:t=globalThis.document,enableHWA:n=!1}){super({enableHWA:n}),this._document=t}_createCanvas(t,n){const s=this._document.createElement("canvas");return s.width=t,s.height=n,s}}class CP{constructor({baseUrl:t=null,isCompressed:n=!0}){this.baseUrl=t,this.isCompressed=n}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 n=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(n).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${n}`)})}async _fetch(t){Hn("Abstract method `_fetch` called.")}}class SP extends CP{async _fetch(t){const n=await sb(t,this.isCompressed?"arraybuffer":"text");return n instanceof ArrayBuffer?new Uint8Array(n):nb(n)}}class xP{addFilter(t){return"none"}addHCMFilter(t,n){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,n,s,a,o){return"none"}destroy(t=!1){}}class pbe extends xP{constructor({docId:n,ownerDocument:s=globalThis.document}){super();ne(this,It);ne(this,vd);ne(this,Ih);ne(this,Sl);ne(this,xl);ne(this,wa);ne(this,md);ne(this,gd,0);G(this,xl,n),G(this,wa,s)}addFilter(n){if(!n)return"none";let s=y(this,It,xa).get(n);if(s)return s;const[a,o,r]=oe(this,It,Gb).call(this,n),i=n.length===1?a:`${a}${o}${r}`;if(s=y(this,It,xa).get(i),s)return y(this,It,xa).set(n,s),s;const l=`g_${y(this,xl)}_transfer_map_${za(this,gd)._++}`,c=oe(this,It,k0).call(this,l);y(this,It,xa).set(n,c),y(this,It,xa).set(i,c);const u=oe(this,It,E0).call(this,l);return oe(this,It,p2).call(this,a,o,r,u),c}addHCMFilter(n,s){var v;const a=`${n}-${s}`,o="base";let r=y(this,It,f2).get(o);if((r==null?void 0:r.key)===a||(r?((v=r.filter)==null||v.remove(),r.key=a,r.url="none",r.filter=null):(r={key:a,url:"none",filter:null},y(this,It,f2).set(o,r)),!n||!s))return r.url;const i=oe(this,It,v2).call(this,n);n=zt.makeHexColor(...i);const l=oe(this,It,v2).call(this,s);if(s=zt.makeHexColor(...l),y(this,It,x0).style.color="",n==="#000000"&&s==="#ffffff"||n===s)return r.url;const c=new Array(256);for(let m=0;m<=255;m++){const g=m/255;c[m]=g<=.03928?g/12.92:((g+.055)/1.055)**2.4}const u=c.join(","),d=`g_${y(this,xl)}_hcm_filter`,h=r.filter=oe(this,It,E0).call(this,d);oe(this,It,p2).call(this,u,u,u,h),oe(this,It,t_).call(this,h);const p=(m,g)=>{const b=i[m]/255,C=l[m]/255,w=new Array(g+1);for(let _=0;_<=g;_++)w[_]=b+_/g*(C-b);return w.join(",")};return oe(this,It,p2).call(this,p(0,5),p(1,5),p(2,5),h),r.url=oe(this,It,k0).call(this,d),r.url}addAlphaFilter(n){let s=y(this,It,xa).get(n);if(s)return s;const[a]=oe(this,It,Gb).call(this,[n]),o=`alpha_${a}`;if(s=y(this,It,xa).get(o),s)return y(this,It,xa).set(n,s),s;const r=`g_${y(this,xl)}_alpha_map_${za(this,gd)._++}`,i=oe(this,It,k0).call(this,r);y(this,It,xa).set(n,i),y(this,It,xa).set(o,i);const l=oe(this,It,E0).call(this,r);return oe(this,It,n_).call(this,a,l),i}addLuminosityFilter(n){let s=y(this,It,xa).get(n||"luminosity");if(s)return s;let a,o;if(n?([a]=oe(this,It,Gb).call(this,[n]),o=`luminosity_${a}`):o="luminosity",s=y(this,It,xa).get(o),s)return y(this,It,xa).set(n,s),s;const r=`g_${y(this,xl)}_luminosity_map_${za(this,gd)._++}`,i=oe(this,It,k0).call(this,r);y(this,It,xa).set(n,i),y(this,It,xa).set(o,i);const l=oe(this,It,E0).call(this,r);return oe(this,It,VR).call(this,l),n&&oe(this,It,n_).call(this,a,l),i}addHighlightHCMFilter(n,s,a,o,r){var C;const i=`${s}-${a}-${o}-${r}`;let l=y(this,It,f2).get(n);if((l==null?void 0:l.key)===i||(l?((C=l.filter)==null||C.remove(),l.key=i,l.url="none",l.filter=null):(l={key:i,url:"none",filter:null},y(this,It,f2).set(n,l)),!s||!a))return l.url;const[c,u]=[s,a].map(oe(this,It,v2).bind(this));let d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),h=Math.round(.2126*u[0]+.7152*u[1]+.0722*u[2]),[p,v]=[o,r].map(oe(this,It,v2).bind(this));h{const k=new Array(256),T=(h-d)/x,I=w/255,O=(_-w)/(255*x);let R=0;for(let $=0;$<=x;$++){const M=Math.round(d+$*T),B=I+$*O;for(let U=R;U<=M;U++)k[U]=B;R=M+1}for(let $=R;$<256;$++)k[$]=k[R-1];return k.join(",")},g=`g_${y(this,xl)}_hcm_${n}_filter`,b=l.filter=oe(this,It,E0).call(this,g);return oe(this,It,t_).call(this,b),oe(this,It,p2).call(this,m(p[0],v[0],5),m(p[1],v[1],5),m(p[2],v[2],5),b),l.url=oe(this,It,k0).call(this,g),l.url}destroy(n=!1){var s,a,o,r;n&&((s=y(this,md))!=null&&s.size)||((a=y(this,Sl))==null||a.parentNode.parentNode.remove(),G(this,Sl,null),(o=y(this,Ih))==null||o.clear(),G(this,Ih,null),(r=y(this,md))==null||r.clear(),G(this,md,null),G(this,gd,0))}}vd=new WeakMap,Ih=new WeakMap,Sl=new WeakMap,xl=new WeakMap,wa=new WeakMap,md=new WeakMap,gd=new WeakMap,It=new WeakSet,xa=function(){return y(this,Ih)||G(this,Ih,new Map)},f2=function(){return y(this,md)||G(this,md,new Map)},x0=function(){if(!y(this,Sl)){const n=y(this,wa).createElement("div"),{style:s}=n;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const a=y(this,wa).createElementNS(dl,"svg");a.setAttribute("width",0),a.setAttribute("height",0),G(this,Sl,y(this,wa).createElementNS(dl,"defs")),n.append(a),a.append(y(this,Sl)),y(this,wa).body.append(n)}return y(this,Sl)},Gb=function(n){if(n.length===1){const c=n[0],u=new Array(256);for(let h=0;h<256;h++)u[h]=c[h]/255;const d=u.join(",");return[d,d,d]}const[s,a,o]=n,r=new Array(256),i=new Array(256),l=new Array(256);for(let c=0;c<256;c++)r[c]=s[c]/255,i[c]=a[c]/255,l[c]=o[c]/255;return[r.join(","),i.join(","),l.join(",")]},k0=function(n){if(y(this,vd)===void 0){G(this,vd,"");const s=y(this,wa).URL;s!==y(this,wa).baseURI&&(ab(s)?fn('#createUrl: ignore "data:"-URL for performance reasons.'):G(this,vd,s.split("#",1)[0]))}return`url(${y(this,vd)}#${n})`},VR=function(n){const s=y(this,wa).createElementNS(dl,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),n.append(s)},t_=function(n){const s=y(this,wa).createElementNS(dl,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),n.append(s)},E0=function(n){const s=y(this,wa).createElementNS(dl,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",n),y(this,It,x0).append(s),s},h2=function(n,s,a){const o=y(this,wa).createElementNS(dl,s);o.setAttribute("type","discrete"),o.setAttribute("tableValues",a),n.append(o)},p2=function(n,s,a,o){const r=y(this,wa).createElementNS(dl,"feComponentTransfer");o.append(r),oe(this,It,h2).call(this,r,"feFuncR",n),oe(this,It,h2).call(this,r,"feFuncG",s),oe(this,It,h2).call(this,r,"feFuncB",a)},n_=function(n,s){const a=y(this,wa).createElementNS(dl,"feComponentTransfer");s.append(a),oe(this,It,h2).call(this,a,"feFuncA",n)},v2=function(n){return y(this,It,x0).style.color=n,aw(getComputedStyle(y(this,It,x0)).getPropertyValue("color"))};class kP{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 n=`${this.baseUrl}${t}`;return this._fetch(n).catch(s=>{throw new Error(`Unable to load font data at: ${n}`)})}async _fetch(t){Hn("Abstract method `_fetch` called.")}}class EP extends kP{async _fetch(t){const n=await sb(t,"arraybuffer");return new Uint8Array(n)}}ma&&fn("Please use the `legacy` build in Node.js environments.");async function AP(e){const n=await process.getBuiltinModule("fs").promises.readFile(e);return new Uint8Array(n)}class vbe extends xP{}class mbe extends _P{_createCanvas(t,n){return process.getBuiltinModule("module").createRequire(Mn&&Mn.tagName.toUpperCase()==="SCRIPT"&&Mn.src||new URL("ocrz-app.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,n)}}class gbe extends CP{async _fetch(t){return AP(t)}}class bbe extends kP{async _fetch(t){return AP(t)}}const ba={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function dw(e,t){if(!t)return;const n=t[2]-t[0],s=t[3]-t[1],a=new Path2D;a.rect(t[0],t[1],n,s),e.clip(a)}class fw{getPattern(){Hn("Abstract method `getPattern` called.")}}class ybe extends fw{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 n;this._type==="axial"?n=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(n=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)n.addColorStop(s[0],s[1]);return n}getPattern(t,n,s,a){let o;if(a===ba.STROKE||a===ba.FILL){const r=n.current.getClippedPathBoundingBox(a,ns(t))||[0,0,0,0],i=Math.ceil(r[2]-r[0])||1,l=Math.ceil(r[3]-r[1])||1,c=n.cachedCanvases.getCanvas("pattern",i,l),u=c.context;u.clearRect(0,0,u.canvas.width,u.canvas.height),u.beginPath(),u.rect(0,0,u.canvas.width,u.canvas.height),u.translate(-r[0],-r[1]),s=zt.transform(s,[1,0,0,1,r[0],r[1]]),u.transform(...n.baseTransform),this.matrix&&u.transform(...this.matrix),dw(u,this._bbox),u.fillStyle=this._createGradient(u),u.fill(),o=t.createPattern(c.canvas,"no-repeat");const d=new DOMMatrix(s);o.setTransform(d)}else dw(t,this._bbox),o=this._createGradient(t);return o}}function hw(e,t,n,s,a,o,r,i){const l=t.coords,c=t.colors,u=e.data,d=e.width*4;let h;l[n+1]>l[s+1]&&(h=n,n=s,s=h,h=o,o=r,r=h),l[s+1]>l[a+1]&&(h=s,s=a,a=h,h=r,r=i,i=h),l[n+1]>l[s+1]&&(h=n,n=s,s=h,h=o,o=r,r=h);const p=(l[n]+t.offsetX)*t.scaleX,v=(l[n+1]+t.offsetY)*t.scaleY,m=(l[s]+t.offsetX)*t.scaleX,g=(l[s+1]+t.offsetY)*t.scaleY,b=(l[a]+t.offsetX)*t.scaleX,C=(l[a+1]+t.offsetY)*t.scaleY;if(v>=C)return;const w=c[o],_=c[o+1],x=c[o+2],k=c[r],T=c[r+1],I=c[r+2],O=c[i],R=c[i+1],$=c[i+2],M=Math.round(v),B=Math.round(C);let U,J,Y,L,N,V,z,q;for(let Q=M;Q<=B;Q++){if(QC?te=1:g===C?te=0:te=(g-Q)/(g-C),U=m-(m-b)*te,J=k-(k-O)*te,Y=T-(T-R)*te,L=I-(I-$)*te}let K;QC?K=1:K=(v-Q)/(v-C),N=p-(p-b)*K,V=w-(w-O)*K,z=_-(_-R)*K,q=x-(x-$)*K;const ee=Math.round(Math.min(U,N)),se=Math.round(Math.max(U,N));let pe=d*Q+ee*4;for(let te=ee;te<=se;te++)K=(U-te)/(U-N),K<0?K=0:K>1&&(K=1),u[pe++]=J-(J-V)*K|0,u[pe++]=Y-(Y-z)*K|0,u[pe++]=L-(L-q)*K|0,u[pe++]=255}}function wbe(e,t,n){const s=t.coords,a=t.colors;let o,r;switch(t.type){case"lattice":const i=t.verticesPerRow,l=Math.floor(s.length/i)-1,c=i-1;for(o=0;o=R?_=l:k=!0,O>=$?x=c:T=!0;const M=this.getSizeAndScale(_,this.ctx.canvas.width,C),B=this.getSizeAndScale(x,this.ctx.canvas.height,w),U=t.cachedCanvases.getCanvas("pattern",M.size,B.size),J=U.context,Y=i.createCanvasGraphics(J);if(Y.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(Y,a,r),J.translate(-M.scale*u,-B.scale*d),Y.transform(M.scale,0,0,B.scale,0,0),J.save(),this.clipBbox(Y,u,d,h,p),Y.baseTransform=ns(Y.ctx),Y.executeOperatorList(s),Y.endDrawing(),J.restore(),k||T){const L=U.canvas;k&&(_=l),T&&(x=c);const N=this.getSizeAndScale(_,this.ctx.canvas.width,C),V=this.getSizeAndScale(x,this.ctx.canvas.height,w),z=N.size,q=V.size,Q=t.cachedCanvases.getCanvas("pattern-workaround",z,q),K=Q.context,ee=k?Math.floor(v/l):0,se=T?Math.floor(m/c):0;for(let pe=0;pe<=ee;pe++)for(let te=0;te<=se;te++)K.drawImage(L,z*pe,q*te,z,q,0,0,z,q);return{canvas:Q.canvas,scaleX:N.scale,scaleY:V.scale,offsetX:u,offsetY:d}}return{canvas:U.canvas,scaleX:M.scale,scaleY:B.scale,offsetX:u,offsetY:d}}getSizeAndScale(t,n,s){const a=Math.max(Eb.MAX_PATTERN_SIZE,n);let o=Math.ceil(t*s);return o>=a?o=a:s=o/t,{scale:s,size:o}}clipBbox(t,n,s,a,o){const r=a-n,i=o-s;t.ctx.rect(n,s,r,i),t.current.updateRectMinMax(ns(t.ctx),[n,s,a,o]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,n,s){const a=t.ctx,o=t.current;switch(n){case TP.COLORED:const r=this.ctx;a.fillStyle=r.fillStyle,a.strokeStyle=r.strokeStyle,o.fillColor=r.fillStyle,o.strokeColor=r.strokeStyle;break;case TP.UNCOLORED:const i=zt.makeHexColor(s[0],s[1],s[2]);a.fillStyle=i,a.strokeStyle=i,o.fillColor=i,o.strokeColor=i;break;default:throw new Y1e(`Unsupported paint type: ${n}`)}}getPattern(t,n,s,a){let o=s;a!==ba.SHADING&&(o=zt.transform(o,n.baseTransform),this.matrix&&(o=zt.transform(o,this.matrix)));const r=this.createPatternCanvas(n);let i=new DOMMatrix(o);i=i.translate(r.offsetX,r.offsetY),i=i.scale(1/r.scaleX,1/r.scaleY);const l=t.createPattern(r.canvas,"repeat");return l.setTransform(i),l}};Ut(Eb,"MAX_PATTERN_SIZE",3e3);let pw=Eb;function xbe({src:e,srcPos:t=0,dest:n,width:s,height:a,nonBlackColor:o=4294967295,inverseDecode:r=!1}){const i=La.isLittleEndian?4278190080:255,[l,c]=r?[o,i]:[i,o],u=s>>3,d=s&7,h=e.length;n=new Uint32Array(n.buffer);let p=0;for(let v=0;v{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(s,a){t.translate(s,a),this.__originalTranslate(s,a)},e.scale=function(s,a){t.scale(s,a),this.__originalScale(s,a)},e.transform=function(s,a,o,r,i,l){t.transform(s,a,o,r,i,l),this.__originalTransform(s,a,o,r,i,l)},e.setTransform=function(s,a,o,r,i,l){t.setTransform(s,a,o,r,i,l),this.__originalSetTransform(s,a,o,r,i,l)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(s){t.rotate(s),this.__originalRotate(s)},e.clip=function(s){t.clip(s),this.__originalClip(s)},e.moveTo=function(n,s){t.moveTo(n,s),this.__originalMoveTo(n,s)},e.lineTo=function(n,s){t.lineTo(n,s),this.__originalLineTo(n,s)},e.bezierCurveTo=function(n,s,a,o,r,i){t.bezierCurveTo(n,s,a,o,r,i),this.__originalBezierCurveTo(n,s,a,o,r,i)},e.rect=function(n,s,a,o){t.rect(n,s,a,o),this.__originalRect(n,s,a,o)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class Abe{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,n,s){let a;return this.cache[t]!==void 0?(a=this.cache[t],this.canvasFactory.reset(a,n,s)):(a=this.canvasFactory.create(n,s),this.cache[t]=a),a}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const n=this.cache[t];this.canvasFactory.destroy(n),delete this.cache[t]}}}function cb(e,t,n,s,a,o,r,i,l,c){const[u,d,h,p,v,m]=ns(e);if(d===0&&h===0){const C=r*u+v,w=Math.round(C),_=i*p+m,x=Math.round(_),k=(r+l)*u+v,T=Math.abs(Math.round(k)-w)||1,I=(i+c)*p+m,O=Math.abs(Math.round(I)-x)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(p),w,x),e.drawImage(t,n,s,a,o,0,0,T,O),e.setTransform(u,d,h,p,v,m),[T,O]}if(u===0&&p===0){const C=i*h+v,w=Math.round(C),_=r*d+m,x=Math.round(_),k=(i+c)*h+v,T=Math.abs(Math.round(k)-w)||1,I=(r+l)*d+m,O=Math.abs(Math.round(I)-x)||1;return e.setTransform(0,Math.sign(d),Math.sign(h),0,w,x),e.drawImage(t,n,s,a,o,0,0,O,T),e.setTransform(u,d,h,p,v,m),[O,T]}e.drawImage(t,n,s,a,o,r,i,l,c);const g=Math.hypot(u,d),b=Math.hypot(h,p);return[g*l,b*c]}function Tbe(e){const{width:t,height:n}=e;if(t>IP||n>IP)return null;const s=1e3,a=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=t+1;let r=new Uint8Array(o*(n+1)),i,l,c;const u=t+7&-8;let d=new Uint8Array(u*n),h=0;for(const b of e.data){let C=128;for(;C>0;)d[h++]=b&C?0:255,C>>=1}let p=0;for(h=0,d[h]!==0&&(r[0]=1,++p),l=1;l>2)+(d[h+1]?4:0)+(d[h-u+1]?8:0),a[b]&&(r[c+l]=a[b],++p),h++;if(d[h-u]!==d[h]&&(r[c+l]=d[h]?2:4,++p),p>s)return null}for(h=u*(n-1),c=i*o,d[h]!==0&&(r[c]=8,++p),l=1;ls)return null;const v=new Int32Array([0,o,-1,0,-o,0,0,0,1]),m=new Path2D;for(i=0;p&&i<=n;i++){let b=i*o;const C=b+t;for(;b>4,r[b]&=_>>2|_<<2),m.lineTo(b%o,b/o|0),r[b]||--p}while(w!==b);--i}return d=null,r=null,function(b){b.save(),b.scale(1/t,-1/n),b.translate(0,-n),b.fill(m),b.beginPath(),b.restore()}}class OP{constructor(t,n){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=fP,this.textMatrixScale=1,this.fontMatrix=q8,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=ga.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,n])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,n){this.x=t,this.y=n}updatePathMinMax(t,n,s){[n,s]=zt.applyTransform([n,s],t),this.minX=Math.min(this.minX,n),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,n),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,n){const s=zt.applyTransform(n,t),a=zt.applyTransform(n.slice(2),t),o=zt.applyTransform([n[0],n[3]],t),r=zt.applyTransform([n[2],n[1]],t);this.minX=Math.min(this.minX,s[0],a[0],o[0],r[0]),this.minY=Math.min(this.minY,s[1],a[1],o[1],r[1]),this.maxX=Math.max(this.maxX,s[0],a[0],o[0],r[0]),this.maxY=Math.max(this.maxY,s[1],a[1],o[1],r[1])}updateScalingPathMinMax(t,n){zt.scaleMinMax(t,n),this.minX=Math.min(this.minX,n[0]),this.minY=Math.min(this.minY,n[1]),this.maxX=Math.max(this.maxX,n[2]),this.maxY=Math.max(this.maxY,n[3])}updateCurvePathMinMax(t,n,s,a,o,r,i,l,c,u){const d=zt.bezierBoundingBox(n,s,a,o,r,i,l,c,u);u||this.updateRectMinMax(t,d)}getPathBoundingBox(t=ba.FILL,n=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===ba.STROKE){n||Hn("Stroke bounding box must include transform.");const a=zt.singularValueDecompose2dScale(n),o=a[0]*this.lineWidth/2,r=a[1]*this.lineWidth/2;s[0]-=o,s[1]-=r,s[2]+=o,s[3]+=r}return s}updateClipFromPath(){const t=zt.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=ba.FILL,n=null){return zt.intersect(this.clipBox,this.getPathBoundingBox(t,n))}}function LP(e,t){if(t instanceof ImageData){e.putImageData(t,0,0);return}const n=t.height,s=t.width,a=n%Qa,o=(n-a)/Qa,r=a===0?o:o+1,i=e.createImageData(s,Qa);let l=0,c;const u=t.data,d=i.data;let h,p,v,m;if(t.kind===J1.GRAYSCALE_1BPP){const g=u.byteLength,b=new Uint32Array(d.buffer,0,d.byteLength>>2),C=b.length,w=s+7>>3,_=4294967295,x=La.isLittleEndian?4278190080:255;for(h=0;hw?s:k*8-7,O=I&-8;let R=0,$=0;for(;T>=1}for(;c=o&&(v=a,m=s*v),c=0,p=m;p--;)d[c++]=u[l++],d[c++]=u[l++],d[c++]=u[l++],d[c++]=255;e.putImageData(i,0,h*Qa)}else throw new Error(`bad image kind: ${t.kind}`)}function NP(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}const n=t.height,s=t.width,a=n%Qa,o=(n-a)/Qa,r=a===0?o:o+1,i=e.createImageData(s,Qa);let l=0;const c=t.data,u=i.data;for(let d=0;dRP&&typeof s=="function",u=c?Date.now()+kbe:0;let d=0;const h=this.commonObjs,p=this.objs;let v;for(;;){if(a!==void 0&&i===a.nextBreakPoint)return a.breakIt(i,s),i;if(v=r[i],v!==Sr.dependency)this[v].apply(this,o[i]);else for(const m of o[i]){const g=m.startsWith("g_")?h:p;if(!g.has(m))return g.get(m,s),i}if(i++,i===l)return i;if(c&&++d>RP){if(Date.now()>u)return s(),i;d=0}}}endDrawing(){oe(this,Pr,s_).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const n of t.values())typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&(n.width=n.height=0);t.clear()}this._cachedBitmapsMap.clear(),oe(this,Pr,a_).call(this)}_scaleImage(t,n){const s=t.width??t.displayWidth,a=t.height??t.displayHeight;let o=Math.max(Math.hypot(n[0],n[1]),1),r=Math.max(Math.hypot(n[2],n[3]),1),i=s,l=a,c="prescale1",u,d;for(;o>2&&i>1||r>2&&l>1;){let h=i,p=l;o>2&&i>1&&(h=i>=16384?Math.floor(i/2)-1||1:Math.ceil(i/2),o/=i/h),r>2&&l>1&&(p=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,r/=l/p),u=this.cachedCanvases.getCanvas(c,h,p),d=u.context,d.clearRect(0,0,h,p),d.drawImage(t,0,0,i,l,0,0,h,p),t=u.canvas,i=h,l=p,c=c==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:i,paintHeight:l}}_createMaskCanvas(t){const n=this.ctx,{width:s,height:a}=t,o=this.current.fillColor,r=this.current.patternFill,i=ns(n);let l,c,u,d;if((t.bitmap||t.data)&&t.count>1){const I=t.bitmap||t.data.buffer;c=JSON.stringify(r?i:[i.slice(0,4),o]),l=this._cachedBitmapsMap.get(I),l||(l=new Map,this._cachedBitmapsMap.set(I,l));const O=l.get(c);if(O&&!r){const R=Math.round(Math.min(i[0],i[2])+i[4]),$=Math.round(Math.min(i[1],i[3])+i[5]);return{canvas:O,offsetX:R,offsetY:$}}u=O}u||(d=this.cachedCanvases.getCanvas("maskCanvas",s,a),NP(d.context,t));let h=zt.transform(i,[1/s,0,0,-1/a,0,0]);h=zt.transform(h,[1,0,0,1,0,-a]);const[p,v,m,g]=zt.getAxialAlignedBoundingBox([0,0,s,a],h),b=Math.round(m-p)||1,C=Math.round(g-v)||1,w=this.cachedCanvases.getCanvas("fillCanvas",b,C),_=w.context,x=p,k=v;_.translate(-x,-k),_.transform(...h),u||(u=this._scaleImage(d.canvas,di(_)),u=u.img,l&&r&&l.set(c,u)),_.imageSmoothingEnabled=$P(ns(_),t.interpolate),cb(_,u,0,0,u.width,u.height,0,0,s,a),_.globalCompositeOperation="source-in";const T=zt.transform(di(_),[1,0,0,1,-x,-k]);return _.fillStyle=r?o.getPattern(n,this,T,ba.FILL):o,_.fillRect(0,0,s,a),l&&!r&&(this.cachedCanvases.delete("fillCanvas"),l.set(c,w.canvas)),{canvas:w.canvas,offsetX:Math.round(x),offsetY:Math.round(k)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Mbe[t]}setLineJoin(t){this.ctx.lineJoin=Pbe[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,n){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=n)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[n,s]of t)switch(n){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,n=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,a=this.cachedCanvases.getCanvas(s,t,n);this.suspendedCtx=this.ctx,this.ctx=a.context;const o=this.ctx;o.setTransform(...ns(this.suspendedCtx)),Av(this.suspendedCtx,o),Ebe(o,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(),Av(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 n=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,n,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,n,s,a){const o=a[0],r=a[1],i=a[2]-o,l=a[3]-r;i===0||l===0||(this.genericComposeSMask(n.context,s,i,l,n.subtype,n.backdrop,n.transferMap,o,r,n.offsetX,n.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,n,s,a,o,r,i,l,c,u,d){let h=t.canvas,p=l-u,v=c-d;if(r){const g=zt.makeHexColor(...r);if(p<0||v<0||p+s>h.width||v+a>h.height){const b=this.cachedCanvases.getCanvas("maskExtension",s,a),C=b.context;C.drawImage(h,-p,-v),C.globalCompositeOperation="destination-atop",C.fillStyle=g,C.fillRect(0,0,s,a),C.globalCompositeOperation="source-over",h=b.canvas,p=v=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const b=new Path2D;b.rect(p,v,s,a),t.clip(b),t.globalCompositeOperation="destination-atop",t.fillStyle=g,t.fillRect(p,v,s,a),t.restore()}}n.save(),n.globalAlpha=1,n.setTransform(1,0,0,1,0,0),o==="Alpha"&&i?n.filter=this.filterFactory.addAlphaFilter(i):o==="Luminosity"&&(n.filter=this.filterFactory.addLuminosityFilter(i));const m=new Path2D;m.rect(l,c,s,a),n.clip(m),n.globalCompositeOperation="destination-in",n.drawImage(h,p,v,s,a,l,c,s,a),n.restore()}save(){this.inSMaskMode?(Av(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(),Av(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,n,s,a,o,r){this.ctx.transform(t,n,s,a,o,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,n,s){const a=this.ctx,o=this.current;let r=o.x,i=o.y,l,c;const u=ns(a),d=u[0]===0&&u[3]===0||u[1]===0&&u[2]===0,h=d?s.slice(0):null;for(let p=0,v=0,m=t.length;pPP&&(c=PP),this.current.fontSizeScale=n/c,this.ctx.font=`${l} ${i} ${c}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,n){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=n}setLeadingMoveText(t,n){this.setLeading(-n),this.moveText(t,n)}setTextMatrix(t,n,s,a,o,r){this.current.textMatrix=[t,n,s,a,o,r],this.current.textMatrixScale=Math.hypot(t,n),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,n,s,a,o){const r=this.ctx,i=this.current,l=i.font,c=i.textRenderingMode,u=i.fontSize/i.fontSizeScale,d=c&ga.FILL_STROKE_MASK,h=!!(c&ga.ADD_TO_PATH_FLAG),p=i.patternFill&&!l.missingFile,v=i.patternStroke&&!l.missingFile;let m;if((l.disableFontFace||h||p||v)&&(m=l.getPathGenerator(this.commonObjs,t)),l.disableFontFace||p||v){if(r.save(),r.translate(n,s),r.scale(u,-u),d===ga.FILL||d===ga.FILL_STROKE)if(a){const g=r.getTransform();r.setTransform(...a),r.fill(oe(this,Pr,o_).call(this,m,g,a))}else r.fill(m);if(d===ga.STROKE||d===ga.FILL_STROKE)if(o){const g=r.getTransform();r.setTransform(...o),r.stroke(oe(this,Pr,o_).call(this,m,g,o))}else r.lineWidth/=u,r.stroke(m);r.restore()}else(d===ga.FILL||d===ga.FILL_STROKE)&&r.fillText(t,n,s),(d===ga.STROKE||d===ga.FILL_STROKE)&&r.strokeText(t,n,s);h&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:ns(r),x:n,y:s,fontSize:u,path:m})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const n=t.getImageData(0,0,10,10).data;let s=!1;for(let a=3;a0&&n[a]<255){s=!0;break}return mn(this,"isFontSubpixelAAEnabled",s)}showText(t){const n=this.current,s=n.font;if(s.isType3Font)return this.showType3Text(t);const a=n.fontSize;if(a===0)return;const o=this.ctx,r=n.fontSizeScale,i=n.charSpacing,l=n.wordSpacing,c=n.fontDirection,u=n.textHScale*c,d=t.length,h=s.vertical,p=h?1:-1,v=s.defaultVMetrics,m=a*n.fontMatrix[0],g=n.textRenderingMode===ga.FILL&&!s.disableFontFace&&!n.patternFill;o.save(),o.transform(...n.textMatrix),o.translate(n.x,n.y+n.textRise),c>0?o.scale(u,-1):o.scale(u,1);let b,C;if(n.patternFill){o.save();const T=n.fillColor.getPattern(o,this,di(o),ba.FILL);b=ns(o),o.restore(),o.fillStyle=T}if(n.patternStroke){o.save();const T=n.strokeColor.getPattern(o,this,di(o),ba.STROKE);C=ns(o),o.restore(),o.strokeStyle=T}let w=n.lineWidth;const _=n.textMatrixScale;if(_===0||w===0){const T=n.textRenderingMode&ga.FILL_STROKE_MASK;(T===ga.STROKE||T===ga.FILL_STROKE)&&(w=this.getSinglePixelWidth())}else w/=_;if(r!==1&&(o.scale(r,r),w/=r),o.lineWidth=w,s.isInvalidPDFjsFont){const T=[];let I=0;for(const O of t)T.push(O.unicode),I+=O.width;o.fillText(T.join(""),0,0),n.x+=I*m*u,o.restore(),this.compose();return}let x=0,k;for(k=0;k0){const Y=o.measureText(R).width*1e3/a*r;if(Unew Ow(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};n=new pw(t,s,this.ctx,o,a)}else n=this._getPattern(t[1],t[2]);return n}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,n,s){this.ctx.strokeStyle=this.current.strokeColor=zt.makeHexColor(t,n,s),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,n,s){this.ctx.fillStyle=this.current.fillColor=zt.makeHexColor(t,n,s),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,n=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=Sbe(this.getObject(t)),this.cachedPatterns.set(t,s)),n&&(s.matrix=n),s}shadingFill(t){if(!this.contentVisible)return;const n=this.ctx;this.save();const s=this._getPattern(t);n.fillStyle=s.getPattern(n,this,di(n),ba.SHADING);const a=di(n);if(a){const{width:o,height:r}=n.canvas,[i,l,c,u]=zt.getAxialAlignedBoundingBox([0,0,o,r],a);this.ctx.fillRect(i,l,c-i,u-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Hn("Should not call beginInlineImage")}beginImageData(){Hn("Should not call beginImageData")}paintFormXObjectBegin(t,n){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=ns(this.ctx),n)){const s=n[2]-n[0],a=n[3]-n[1];this.ctx.rect(n[0],n[1],s,a),this.current.updateRectMinMax(ns(this.ctx),n),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 n=this.ctx;t.isolated||eb("TODO: Support non-isolated groups."),t.knockout&&fn("Knockout groups not supported.");const s=ns(n);if(t.matrix&&n.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let a=zt.getAxialAlignedBoundingBox(t.bbox,ns(n));const o=[0,0,n.canvas.width,n.canvas.height];a=zt.intersect(a,o)||[0,0,0,0];const r=Math.floor(a[0]),i=Math.floor(a[1]),l=Math.max(Math.ceil(a[2])-r,1),c=Math.max(Math.ceil(a[3])-i,1);this.current.startNewPathAndClipBox([0,0,l,c]);let u="groupAt"+this.groupLevel;t.smask&&(u+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(u,l,c),h=d.context;h.translate(-r,-i),h.transform(...s),t.smask?this.smaskStack.push({canvas:d.canvas,context:h,offsetX:r,offsetY:i,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(n.setTransform(1,0,0,1,0,0),n.translate(r,i),n.save()),Av(n,h),this.ctx=h,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(n),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const n=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 a=ns(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...a);const o=zt.getAxialAlignedBoundingBox([0,0,n.canvas.width,n.canvas.height],a);this.ctx.drawImage(n.canvas,0,0),this.ctx.restore(),this.compose(o)}}beginAnnotation(t,n,s,a,o){if(oe(this,Pr,s_).call(this),ub(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),n){const r=n[2]-n[0],i=n[3]-n[1];if(o&&this.annotationCanvasMap){s=s.slice(),s[4]-=n[0],s[5]-=n[1],n=n.slice(),n[0]=n[1]=0,n[2]=r,n[3]=i;const[l,c]=zt.singularValueDecompose2dScale(ns(this.ctx)),{viewportScale:u}=this,d=Math.ceil(r*this.outputScaleX*u),h=Math.ceil(i*this.outputScaleY*u);this.annotationCanvas=this.canvasFactory.create(d,h);const{canvas:p,context:v}=this.annotationCanvas;this.annotationCanvasMap.set(t,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=v,this.ctx.save(),this.ctx.setTransform(l,0,0,-c,0,i*c),ub(this.ctx)}else ub(this.ctx),this.endPath(),this.ctx.rect(n[0],n[1],r,i),this.ctx.clip(),this.ctx.beginPath()}this.current=new OP(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...a)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),oe(this,Pr,a_).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const n=t.count;t=this.getObject(t.data,t),t.count=n;const s=this.ctx,a=this.processingType3;if(a&&(a.compiled===void 0&&(a.compiled=Tbe(t)),a.compiled)){a.compiled(s);return}const o=this._createMaskCanvas(t),r=o.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,o.offsetX,o.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,n,s=0,a=0,o,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const i=this.ctx;i.save();const l=ns(i);i.transform(n,s,a,o,0,0);const c=this._createMaskCanvas(t);i.setTransform(1,0,0,1,c.offsetX-l[4],c.offsetY-l[5]);for(let u=0,d=r.length;ud?u/d:1,i=c>d?c/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=i}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:n}=this,{lineWidth:s}=this.current,[a,o]=this.getScaleForStroking();if(n.lineWidth=s||1,a===1&&o===1){n.stroke();return}const r=n.getLineDash();if(t&&n.save(),n.scale(a,o),r.length>0){const i=Math.max(a,o);n.setLineDash(r.map(l=>l/i)),n.lineDashOffset/=i}n.stroke(),t&&n.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};Pr=new WeakSet,s_=function(){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)},a_=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const n=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=n}}},o_=function(t,n,s){const a=new Path2D;return a.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(n)),a};let fh=Ow;for(const e in Sr)fh.prototype[e]!==void 0&&(fh.prototype[Sr[e]]=fh.prototype[e]);class fl{static get workerPort(){return y(this,im)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");G(this,im,t)}static get workerSrc(){return y(this,lm)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");G(this,lm,t)}}im=new WeakMap,lm=new WeakMap,ne(fl,im,null),ne(fl,lm,"");class Ibe{constructor({parsedData:t,rawData:n}){ne(this,bd);ne(this,cm);G(this,bd,t),G(this,cm,n)}getRaw(){return y(this,cm)}get(t){return y(this,bd).get(t)??null}getAll(){return J8(y(this,bd))}has(t){return y(this,bd).has(t)}}bd=new WeakMap,cm=new WeakMap;const hh=Symbol("INTERNAL");class Obe{constructor(t,{name:n,intent:s,usage:a,rbGroups:o}){ne(this,um,!1);ne(this,dm,!1);ne(this,fm,!1);ne(this,Oh,!0);G(this,um,!!(t&mo.DISPLAY)),G(this,dm,!!(t&mo.PRINT)),this.name=n,this.intent=s,this.usage=a,this.rbGroups=o}get visible(){if(y(this,fm))return y(this,Oh);if(!y(this,Oh))return!1;const{print:t,view:n}=this.usage;return y(this,um)?(n==null?void 0:n.viewState)!=="OFF":y(this,dm)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,n,s=!1){t!==hh&&Hn("Internal method `_setVisible` called."),G(this,fm,s),G(this,Oh,n)}}um=new WeakMap,dm=new WeakMap,fm=new WeakMap,Oh=new WeakMap;class Lbe{constructor(t,n=mo.DISPLAY){ne(this,hm);ne(this,Fc,null);ne(this,Dn,new Map);ne(this,Lh,null);ne(this,Nh,null);if(this.renderingIntent=n,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,G(this,Nh,t.order);for(const s of t.groups)y(this,Dn).set(s.id,new Obe(n,s));if(t.baseState==="OFF")for(const s of y(this,Dn).values())s._setVisible(hh,!1);for(const s of t.on)y(this,Dn).get(s)._setVisible(hh,!0);for(const s of t.off)y(this,Dn).get(s)._setVisible(hh,!1);G(this,Lh,this.getHash())}}isVisible(t){if(y(this,Dn).size===0)return!0;if(!t)return eb("Optional content group not defined."),!0;if(t.type==="OCG")return y(this,Dn).has(t.id)?y(this,Dn).get(t.id).visible:(fn(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return oe(this,hm,r_).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const n of t.ids){if(!y(this,Dn).has(n))return fn(`Optional content group not found: ${n}`),!0;if(y(this,Dn).get(n).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const n of t.ids){if(!y(this,Dn).has(n))return fn(`Optional content group not found: ${n}`),!0;if(!y(this,Dn).get(n).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const n of t.ids){if(!y(this,Dn).has(n))return fn(`Optional content group not found: ${n}`),!0;if(!y(this,Dn).get(n).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const n of t.ids){if(!y(this,Dn).has(n))return fn(`Optional content group not found: ${n}`),!0;if(y(this,Dn).get(n).visible)return!1}return!0}return fn(`Unknown optional content policy ${t.policy}.`),!0}return fn(`Unknown group type ${t.type}.`),!0}setVisibility(t,n=!0,s=!0){var o;const a=y(this,Dn).get(t);if(!a){fn(`Optional content group not found: ${t}`);return}if(s&&n&&a.rbGroups.length)for(const r of a.rbGroups)for(const i of r)i!==t&&((o=y(this,Dn).get(i))==null||o._setVisible(hh,!1,!0));a._setVisible(hh,!!n,!0),G(this,Fc,null)}setOCGState({state:t,preserveRB:n}){let s;for(const a of t){switch(a){case"ON":case"OFF":case"Toggle":s=a;continue}const o=y(this,Dn).get(a);if(o)switch(s){case"ON":this.setVisibility(a,!0,n);break;case"OFF":this.setVisibility(a,!1,n);break;case"Toggle":this.setVisibility(a,!o.visible,n);break}}G(this,Fc,null)}get hasInitialVisibility(){return y(this,Lh)===null||this.getHash()===y(this,Lh)}getOrder(){return y(this,Dn).size?y(this,Nh)?y(this,Nh).slice():[...y(this,Dn).keys()]:null}getGroups(){return y(this,Dn).size>0?J8(y(this,Dn)):null}getGroup(t){return y(this,Dn).get(t)||null}getHash(){if(y(this,Fc)!==null)return y(this,Fc);const t=new bP;for(const[n,s]of y(this,Dn))t.update(`${n}:${s.visible}`);return G(this,Fc,t.hexdigest())}}Fc=new WeakMap,Dn=new WeakMap,Lh=new WeakMap,Nh=new WeakMap,hm=new WeakSet,r_=function(t){const n=t.length;if(n<2)return!0;const s=t[0];for(let a=1;a0){const l=o instanceof Uint8Array&&o.byteLength===o.buffer.byteLength?o.buffer:new Uint8Array(o).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!n,this._contentLength=a,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((l,c)=>{this._onReceiveData({begin:l,chunk:c})}),t.addProgressListener((l,c)=>{this._onProgress({loaded:l,total:c})}),t.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:n}){const s=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const a=this._rangeReaders.some(function(o){return o._begin!==t?!1:(o._enqueue(s),!0)});Ss(a,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var n,s,a,o;t.total===void 0?(s=(n=this._rangeReaders[0])==null?void 0:n.onProgress)==null||s.call(n,{loaded:t.loaded}):(o=(a=this._fullRequestReader)==null?void 0:a.onProgress)==null||o.call(a,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const n=this._rangeReaders.indexOf(t);n>=0&&this._rangeReaders.splice(n,1)}getFullReader(){Ss(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new $be(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,n){if(n<=this._progressiveDataLength)return null;const s=new Dbe(this,t,n);return this._pdfDataRangeTransport.requestDataRange(t,n),this._rangeReaders.push(s),s}cancelAllRequests(t){var n;(n=this._fullRequestReader)==null||n.cancel(t);for(const s of this._rangeReaders.slice(0))s.cancel(t);this._pdfDataRangeTransport.abort()}}class $be{constructor(t,n,s=!1,a=null){this._stream=t,this._done=s||!1,this._filename=nw(a)?a:null,this._queuedChunks=n||[],this._loaded=0;for(const o of this._queuedChunks)this._loaded+=o.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 n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Dbe{constructor(t,n,s){this._stream=t,this._begin=n,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 n=this._queuedChunk;return this._queuedChunk=null,{value:n,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 n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Fbe(e){let t=!0,n=s("filename\\*","i").exec(e);if(n){n=n[1];let u=i(n);return u=unescape(u),u=l(u),u=c(u),o(u)}if(n=r(e),n){const u=c(n);return o(u)}if(n=s("filename","i").exec(e),n){n=n[1];let u=i(n);return u=c(u),o(u)}function s(u,d){return new RegExp("(?:^|;)\\s*"+u+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function a(u,d){if(u){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const h=new TextDecoder(u,{fatal:!0}),p=nb(d);d=h.decode(p),t=!1}catch{}}return d}function o(u){return t&&/[\x80-\xff]/.test(u)&&(u=a("utf-8",u),t&&(u=a("iso-8859-1",u))),u}function r(u){const d=[];let h;const p=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(h=p.exec(u))!==null;){let[,m,g,b]=h;if(m=parseInt(m,10),m in d){if(m===0)break;continue}d[m]=[g,b]}const v=[];for(let m=0;m{if(t._responseOrigin=db(o.url),!zP(o.status))throw fb(o.status,a);this._reader=o.body.getReader(),this._headersCapability.resolve();const r=o.headers,{allowRangeRequests:i,suggestedLength:l}=BP({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=l||this._contentLength,this._filename=VP(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Cc("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(){var s;await this._headersCapability.promise;const{value:t,done:n}=await this._reader.read();return n?{value:t,done:n}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:WP(t),done:!1})}cancel(t){var n;(n=this._reader)==null||n.cancel(t),this._abortController.abort()}}class Vbe{constructor(t,n,s){this._stream=t,this._reader=null,this._loaded=0;const a=t.source;this._withCredentials=a.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!a.disableStream,this._abortController=new AbortController;const o=new Headers(t.headers);o.append("Range",`bytes=${n}-${s-1}`);const r=a.url;fetch(r,HP(o,this._withCredentials,this._abortController)).then(i=>{const l=db(i.url);if(l!==t._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${t._responseOrigin}".`);if(!zP(i.status))throw fb(i.status,r);this._readCapability.resolve(),this._reader=i.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:t,done:n}=await this._reader.read();return n?{value:t,done:n}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:WP(t),done:!1})}cancel(t){var n;(n=this._reader)==null||n.cancel(t),this._abortController.abort()}}const vw=200,mw=206;function zbe(e){const t=e.response;return typeof t!="string"?t:nb(t).buffer}class Hbe{constructor({url:t,httpHeaders:n,withCredentials:s}){Ut(this,"_responseOrigin",null);this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=FP(this.isHttp,n),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const n=new XMLHttpRequest,s=this.currXhrId++,a=this.pendingRequests[s]={xhr:n};n.open("GET",this.url),n.withCredentials=this.withCredentials;for(const[o,r]of this.headers)n.setRequestHeader(o,r);return this.isHttp&&"begin"in t&&"end"in t?(n.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),a.expectedStatus=mw):a.expectedStatus=vw,n.responseType="arraybuffer",Ss(t.onError,"Expected `onError` callback to be provided."),n.onerror=()=>{t.onError(n.status)},n.onreadystatechange=this.onStateChange.bind(this,s),n.onprogress=this.onProgress.bind(this,s),a.onHeadersReceived=t.onHeadersReceived,a.onDone=t.onDone,a.onError=t.onError,a.onProgress=t.onProgress,n.send(null),s}onProgress(t,n){var a;const s=this.pendingRequests[t];s&&((a=s.onProgress)==null||a.call(s,n))}onStateChange(t,n){const s=this.pendingRequests[t];if(!s)return;const a=s.xhr;if(a.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),a.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],a.status===0&&this.isHttp){s.onError(a.status);return}const o=a.status||vw;if(!(o===vw&&s.expectedStatus===mw)&&o!==s.expectedStatus){s.onError(a.status);return}const i=zbe(a);if(o===mw){const l=a.getResponseHeader("Content-Range"),c=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);c?s.onDone({begin:parseInt(c[1],10),chunk:i}):(fn('Missing or invalid "Content-Range" header.'),s.onError(0))}else i?s.onDone({begin:0,chunk:i}):s.onError(a.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const n=this.pendingRequests[t].xhr;delete this.pendingRequests[t],n.abort()}}class Wbe{constructor(t){this._source=t,this._manager=new Hbe(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const n=this._rangeRequestReaders.indexOf(t);n>=0&&this._rangeRequestReaders.splice(n,1)}getFullReader(){return Ss(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new jbe(this._manager,this._source),this._fullRequestReader}getRangeReader(t,n){const s=new Kbe(this._manager,t,n);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var n;(n=this._fullRequestReader)==null||n.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class jbe{constructor(t,n){this._manager=t,this._url=n.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=n.disableRange||!1,this._contentLength=n.length,this._rangeChunkSize=n.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,n=this._manager.getRequestXhr(t);this._manager._responseOrigin=db(n.responseURL);const s=n.getAllResponseHeaders(),a=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(i=>{const[l,...c]=i.split(": ");return[l,c.join(": ")]}):[]),{allowRangeRequests:o,suggestedLength:r}=BP({responseHeaders:a,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});o&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=VP(a),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 n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=fb(t,this._url),this._headersCapability.reject(this._storedError);for(const n of this._requests)n.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var n;(n=this.onProgress)==null||n.call(this,{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 n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Kbe{constructor(t,n,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:n,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(){var n;const t=db((n=this._manager.getRequestXhr(this._requestId))==null?void 0:n.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const n=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:n,done:!1}):this._queuedChunk=n,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??(this._storedError=fb(t,this._url));for(const n of this._requests)n.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var n;this.isStreamingSupported||(n=this.onProgress)==null||n.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const n=this._queuedChunk;return this._queuedChunk=null,{value:n,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 n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Ube=/^[a-z][a-z0-9\-+.]+:/i;function qbe(e){if(Ube.test(e))return new URL(e);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(e))}class Gbe{constructor(t){this.source=t,this.url=qbe(t.url),Ss(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return Ss(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Ybe(this),this._fullRequestReader}getRangeReader(t,n){if(n<=this._progressiveDataLength)return null;const s=new Xbe(this,t,n);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var n;(n=this._fullRequestReader)==null||n.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class Ybe{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const n=t.source;this._contentLength=n.length,this._loaded=0,this._filename=null,this._disableRange=n.disableRange||!1,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!n.disableStream,this._isRangeSupported=!n.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(a=>{this._contentLength=a.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},a=>{a.code==="ENOENT"&&(a=new Cv(`Missing PDF "${this._url}".`)),this._storedError=a,this._headersCapability.reject(a)})}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(){var s;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,(s=this.onProgress)==null||s.call(this,{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",n=>{this._error(n)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Cc("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Xbe{constructor(t,n,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 a=t.source;this._isStreamingSupported=!a.disableStream;const o=process.getBuiltinModule("fs");this._setReadableStream(o.createReadStream(this._url,{start:n,end:s-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;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,(s=this.onProgress)==null||s.call(this,{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",n=>{this._error(n)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Jbe=1e5,eo=30,Zbe=.8,Ls=class Ls{constructor({textContentSource:t,container:n,viewport:s}){ne(this,El);ne(this,Bc,Promise.withResolvers());ne(this,no,null);ne(this,pm,!1);ne(this,vm,!!((oR=globalThis.FontInspector)!=null&&oR.enabled));ne(this,yd,null);ne(this,kl,null);ne(this,mm,0);ne(this,gm,0);ne(this,wd,null);ne(this,$h,null);ne(this,Dh,0);ne(this,Vc,0);ne(this,Fh,Object.create(null));ne(this,bm,[]);ne(this,Bh,null);ne(this,_d,[]);ne(this,ym,new WeakMap);ne(this,wm,null);var l;if(t instanceof ReadableStream)G(this,Bh,t);else if(typeof t=="object")G(this,Bh,new ReadableStream({start(c){c.enqueue(t),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');G(this,no,G(this,$h,n)),G(this,Vc,s.scale*(globalThis.devicePixelRatio||1)),G(this,Dh,s.rotation),G(this,kl,{div:null,properties:null,ctx:null});const{pageWidth:a,pageHeight:o,pageX:r,pageY:i}=s.rawDims;G(this,wm,[1,0,0,-1,-r,i+o]),G(this,gm,a),G(this,mm,o),oe(l=Ls,_o,WR).call(l),ju(n,s),y(this,Bc).promise.finally(()=>{y(Ls,Vh).delete(this),G(this,kl,null),G(this,Fh,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:n}=La.platform;return mn(this,"fontFamilyMap",new Map([["sans-serif",`${t&&n?"Calibri, ":""}sans-serif`],["monospace",`${t&&n?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{y(this,wd).read().then(({value:n,done:s})=>{if(s){y(this,Bc).resolve();return}y(this,yd)??G(this,yd,n.lang),Object.assign(y(this,Fh),n.styles),oe(this,El,zR).call(this,n.items),t()},y(this,Bc).reject)};return G(this,wd,y(this,Bh).getReader()),y(Ls,Vh).add(this),t(),y(this,Bc).promise}update({viewport:t,onBefore:n=null}){var o;const s=t.scale*(globalThis.devicePixelRatio||1),a=t.rotation;if(a!==y(this,Dh)&&(n==null||n(),G(this,Dh,a),ju(y(this,$h),{rotation:a})),s!==y(this,Vc)){n==null||n(),G(this,Vc,s);const r={div:null,properties:null,ctx:oe(o=Ls,_o,Yb).call(o,y(this,yd))};for(const i of y(this,_d))r.properties=y(this,ym).get(i),r.div=i,oe(this,El,i_).call(this,r)}}cancel(){var n;const t=new Cc("TextLayer task cancelled.");(n=y(this,wd))==null||n.cancel(t).catch(()=>{}),G(this,wd,null),y(this,Bc).reject(t)}get textDivs(){return y(this,_d)}get textContentItemsStr(){return y(this,bm)}static cleanup(){if(!(y(this,Vh).size>0)){y(this,Cd).clear();for(const{canvas:t}of y(this,Sd).values())t.remove();y(this,Sd).clear()}}};Bc=new WeakMap,no=new WeakMap,pm=new WeakMap,vm=new WeakMap,yd=new WeakMap,kl=new WeakMap,mm=new WeakMap,gm=new WeakMap,wd=new WeakMap,$h=new WeakMap,Dh=new WeakMap,Vc=new WeakMap,Fh=new WeakMap,bm=new WeakMap,Bh=new WeakMap,_d=new WeakMap,ym=new WeakMap,wm=new WeakMap,Cd=new WeakMap,Sd=new WeakMap,_m=new WeakMap,zc=new WeakMap,Vh=new WeakMap,El=new WeakSet,zR=function(t){var a,o;if(y(this,pm))return;(o=y(this,kl)).ctx??(o.ctx=oe(a=Ls,_o,Yb).call(a,y(this,yd)));const n=y(this,_d),s=y(this,bm);for(const r of t){if(n.length>Jbe){fn("Ignoring additional textDivs for performance reasons."),G(this,pm,!0);return}if(r.str===void 0){if(r.type==="beginMarkedContentProps"||r.type==="beginMarkedContent"){const i=y(this,no);G(this,no,document.createElement("span")),y(this,no).classList.add("markedContent"),r.id!==null&&y(this,no).setAttribute("id",`${r.id}`),i.append(y(this,no))}else r.type==="endMarkedContent"&&G(this,no,y(this,no).parentNode);continue}s.push(r.str),oe(this,El,HR).call(this,r)}},HR=function(t){var m;const n=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};y(this,_d).push(n);const a=zt.transform(y(this,wm),t.transform);let o=Math.atan2(a[1],a[0]);const r=y(this,Fh)[t.fontName];r.vertical&&(o+=Math.PI/2);let i=y(this,vm)&&r.fontSubstitution||r.fontFamily;i=Ls.fontFamilyMap.get(i)||i;const l=Math.hypot(a[2],a[3]),c=l*oe(m=Ls,_o,jR).call(m,i,y(this,yd));let u,d;o===0?(u=a[4],d=a[5]-c):(u=a[4]+c*Math.sin(o),d=a[5]-c*Math.cos(o));const h="calc(var(--scale-factor)*",p=n.style;y(this,no)===y(this,$h)?(p.left=`${(100*u/y(this,gm)).toFixed(2)}%`,p.top=`${(100*d/y(this,mm)).toFixed(2)}%`):(p.left=`${h}${u.toFixed(2)}px)`,p.top=`${h}${d.toFixed(2)}px)`),p.fontSize=`${h}${(y(Ls,zc)*l).toFixed(2)}px)`,p.fontFamily=i,s.fontSize=l,n.setAttribute("role","presentation"),n.textContent=t.str,n.dir=t.dir,y(this,vm)&&(n.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),o!==0&&(s.angle=o*(180/Math.PI));let v=!1;if(t.str.length>1)v=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const g=Math.abs(t.transform[0]),b=Math.abs(t.transform[3]);g!==b&&Math.max(g,b)/Math.min(g,b)>1.5&&(v=!0)}if(v&&(s.canvasWidth=r.vertical?t.height:t.width),y(this,ym).set(n,s),y(this,kl).div=n,y(this,kl).properties=s,oe(this,El,i_).call(this,y(this,kl)),s.hasText&&y(this,no).append(n),s.hasEOL){const g=document.createElement("br");g.setAttribute("role","presentation"),y(this,no).append(g)}},i_=function(t){var i;const{div:n,properties:s,ctx:a}=t,{style:o}=n;let r="";if(y(Ls,zc)>1&&(r=`scale(${1/y(Ls,zc)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=o,{canvasWidth:c,fontSize:u}=s;oe(i=Ls,_o,l_).call(i,a,u*y(this,Vc),l);const{width:d}=a.measureText(n.textContent);d>0&&(r=`scaleX(${c*y(this,Vc)/d}) ${r}`)}s.angle!==0&&(r=`rotate(${s.angle}deg) ${r}`),r.length>0&&(o.transform=r)},_o=new WeakSet,Yb=function(t=null){let n=y(this,Sd).get(t||(t=""));if(!n){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),n=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),y(this,Sd).set(t,n),y(this,_m).set(n,{size:0,family:""})}return n},l_=function(t,n,s){const a=y(this,_m).get(t);n===a.size&&s===a.family||(t.font=`${n}px ${s}`,a.size=n,a.family=s)},WR=function(){if(y(this,zc)!==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),G(this,zc,t.getBoundingClientRect().height),t.remove()},jR=function(t,n){const s=y(this,Cd).get(t);if(s)return s;const a=oe(this,_o,Yb).call(this,n);a.canvas.width=a.canvas.height=eo,oe(this,_o,l_).call(this,a,eo,t);const o=a.measureText("");let r=o.fontBoundingBoxAscent,i=Math.abs(o.fontBoundingBoxDescent);if(r){const u=r/(r+i);return y(this,Cd).set(t,u),a.canvas.width=a.canvas.height=0,u}a.strokeStyle="red",a.clearRect(0,0,eo,eo),a.strokeText("g",0,0);let l=a.getImageData(0,0,eo,eo).data;i=0;for(let u=l.length-1-3;u>=0;u-=4)if(l[u]>0){i=Math.ceil(u/4/eo);break}a.clearRect(0,0,eo,eo),a.strokeText("A",0,eo),l=a.getImageData(0,0,eo,eo).data,r=0;for(let u=0,d=l.length;u0){r=eo-Math.floor(u/4/eo);break}a.canvas.width=a.canvas.height=0;const c=r?r/(r+i):Zbe;return y(this,Cd).set(t,c),c},ne(Ls,_o),ne(Ls,Cd,new Map),ne(Ls,Sd,new Map),ne(Ls,_m,new WeakMap),ne(Ls,zc,null),ne(Ls,Vh,new Set);let Tv=Ls;class Mv{static textContent(t){const n=[],s={items:n,styles:Object.create(null)};function a(o){var l;if(!o)return;let r=null;const i=o.name;if(i==="#text")r=o.value;else if(Mv.shouldBuildText(i))(l=o==null?void 0:o.attributes)!=null&&l.textContent?r=o.attributes.textContent:o.value&&(r=o.value);else return;if(r!==null&&n.push({str:r}),!!o.children)for(const c of o.children)a(c)}return a(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const Qbe=65536,e4e=100,t4e=5e3,n4e=ma?mbe:hbe,s4e=ma?gbe:SP,a4e=ma?vbe:pbe,o4e=ma?bbe:EP;function r4e(e={}){typeof e=="string"||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t=new gw,{docId:n}=t,s=e.url?i4e(e.url):null,a=e.data?l4e(e.data):null,o=e.httpHeaders||null,r=e.withCredentials===!0,i=e.password??null,l=e.range instanceof UP?e.range:null,c=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:Qbe;let u=e.worker instanceof ph?e.worker:null;const d=e.verbosity,h=typeof e.docBaseUrl=="string"&&!ab(e.docBaseUrl)?e.docBaseUrl:null,p=typeof e.cMapUrl=="string"?e.cMapUrl:null,v=e.cMapPacked!==!1,m=e.CMapReaderFactory||s4e,g=typeof e.standardFontDataUrl=="string"?e.standardFontDataUrl:null,b=e.StandardFontDataFactory||o4e,C=e.stopAtErrors!==!0,w=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,_=e.isEvalSupported!==!1,x=typeof e.isOffscreenCanvasSupported=="boolean"?e.isOffscreenCanvasSupported:!ma,k=typeof e.isImageDecoderSupported=="boolean"?e.isImageDecoderSupported:!ma&&(La.platform.isFirefox||!globalThis.chrome),T=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,I=typeof e.disableFontFace=="boolean"?e.disableFontFace:ma,O=e.fontExtraProperties===!0,R=e.enableXfa===!0,$=e.ownerDocument||globalThis.document,M=e.disableRange===!0,B=e.disableStream===!0,U=e.disableAutoFetch===!0,J=e.pdfBug===!0,Y=e.CanvasFactory||n4e,L=e.FilterFactory||a4e,N=e.enableHWA===!0,V=l?l.length:e.length??NaN,z=typeof e.useSystemFonts=="boolean"?e.useSystemFonts:!ma&&!I,q=typeof e.useWorkerFetch=="boolean"?e.useWorkerFetch:m===SP&&b===EP&&p&&g&&xv(p,document.baseURI)&&xv(g,document.baseURI),Q=null;K1e(d);const K={canvasFactory:new Y({ownerDocument:$,enableHWA:N}),filterFactory:new L({docId:n,ownerDocument:$}),cMapReaderFactory:q?null:new m({baseUrl:p,isCompressed:v}),standardFontDataFactory:q?null:new b({baseUrl:g})};if(!u){const pe={verbosity:d,port:fl.workerPort};u=pe.port?ph.fromPort(pe):new ph(pe),t._worker=u}const ee={docId:n,apiVersion:"4.10.38",data:a,password:i,disableAutoFetch:U,rangeChunkSize:c,length:V,docBaseUrl:h,enableXfa:R,evaluatorOptions:{maxImageSize:w,disableFontFace:I,ignoreErrors:C,isEvalSupported:_,isOffscreenCanvasSupported:x,isImageDecoderSupported:k,canvasMaxAreaInBytes:T,fontExtraProperties:O,useSystemFonts:z,cMapUrl:q?p:null,standardFontDataUrl:q?g:null}},se={disableFontFace:I,fontExtraProperties:O,ownerDocument:$,pdfBug:J,styleElement:Q,loadingParams:{disableAutoFetch:U,enableXfa:R}};return u.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const pe=u.messageHandler.sendWithPromise("GetDocRequest",ee,a?[a.buffer]:null);let te;if(l)te=new Nbe(l,{disableRange:M,disableStream:B});else if(!a){if(!s)throw new Error("getDocument - no `url` parameter provided.");let fe;if(ma)if(xv(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`.");fe=jP}else fe=Gbe;else fe=xv(s)?jP:Wbe;te=new fe({url:s,length:V,httpHeaders:o,withCredentials:r,rangeChunkSize:c,disableRange:M,disableStream:B})}return pe.then(fe=>{if(t.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const ve=new Ev(n,fe,u.port),ce=new f4e(ve,t,te,se,K);t._transport=ce,ve.send("Ready",null)})}).catch(t._capability.reject),t}function i4e(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(ma&&typeof e=="string")return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function l4e(e){if(ma&&typeof Buffer<"u"&&e instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if(typeof e=="string")return nb(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e=="object"&&!isNaN(e==null?void 0:e.length))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function KP(e){return typeof e=="object"&&Number.isInteger(e==null?void 0:e.num)&&e.num>=0&&Number.isInteger(e==null?void 0:e.gen)&&e.gen>=0}const Tb=class Tb{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${za(Tb,Ab)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var t,n,s,a;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((n=this._transport)==null?void 0:n.destroy())}catch(o){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,o}this._transport=null,(a=this._worker)==null||a.destroy(),this._worker=null}};Ab=new WeakMap,ne(Tb,Ab,0);let gw=Tb;class UP{constructor(t,n,s=!1,a=null){this.length=t,this.initialData=n,this.progressiveDone=s,this.contentDispositionFilename=a,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,n){for(const s of this._rangeListeners)s(t,n)}onDataProgress(t,n){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(t,n)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const n of this._progressiveReadListeners)n(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,n){Hn("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class c4e{constructor(t,n){this._pdfInfo=t,this._transport=n}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 mn(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:n}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(n)}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 u4e{constructor(t,n,s,a=!1){ne(this,Go);ne(this,Hc,null);ne(this,Al,!1);this._pageIndex=t,this._pageInfo=n,this._transport=s,this._stats=a?new mP:null,this._pdfBug=a,this.commonObjs=s.commonObjs,this.objs=new qP,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:n=this.rotate,offsetX:s=0,offsetY:a=0,dontFlip:o=!1}={}){return new Sv({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:n,offsetX:s,offsetY:a,dontFlip:o})}getAnnotations({intent:t="display"}={}){const{renderingIntent:n}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,n)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return mn(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,viewport:n,intent:s="display",annotationMode:a=wc.ENABLE,transform:o=null,background:r=null,optionalContentConfigPromise:i=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:u=null,isEditing:d=!1}){var _,x;(_=this._stats)==null||_.time("Overall");const h=this._transport.getRenderingIntent(s,a,u,d),{renderingIntent:p,cacheKey:v}=h;G(this,Al,!1),oe(this,Go,Xb).call(this),i||(i=this._transport.getOptionalContentConfig(p));let m=this._intentStates.get(v);m||(m=Object.create(null),this._intentStates.set(v,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);const g=!!(p&mo.PRINT);m.displayReadyCapability||(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(x=this._stats)==null||x.time("Page Request"),this._pumpOperatorList(h));const b=k=>{var T;m.renderTasks.delete(C),(this._maybeCleanupAfterRender||g)&&G(this,Al,!0),oe(this,Go,A0).call(this,!g),k?(C.capability.reject(k),this._abortOperatorList({intentState:m,reason:k instanceof Error?k:new Error(k)})):C.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(T=globalThis.Stats)!=null&&T.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},C=new bw({callback:b,params:{canvasContext:t,viewport:n,transform:o,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!g,pdfBug:this._pdfBug,pageColors:c});(m.renderTasks||(m.renderTasks=new Set)).add(C);const w=C.task;return Promise.all([m.displayReadyCapability.promise,i]).then(([k,T])=>{var I;if(this.destroyed){b();return}if((I=this._stats)==null||I.time("Rendering"),!(T.renderingIntent&p))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");C.initializeGraphics({transparency:k,optionalContentConfig:T}),C.operatorListChanged()}).catch(b),w}getOperatorList({intent:t="display",annotationMode:n=wc.ENABLE,printAnnotationStorage:s=null,isEditing:a=!1}={}){var c;function o(){i.operatorList.lastChunk&&(i.opListReadCapability.resolve(i.operatorList),i.renderTasks.delete(l))}const r=this._transport.getRenderingIntent(t,n,s,a,!0);let i=this._intentStates.get(r.cacheKey);i||(i=Object.create(null),this._intentStates.set(r.cacheKey,i));let l;return i.opListReadCapability||(l=Object.create(null),l.operatorListChanged=o,i.opListReadCapability=Promise.withResolvers(),(i.renderTasks||(i.renderTasks=new Set)).add(l),i.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(r)),i.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:n=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:n===!0},{highWaterMark:100,size(a){return a.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>Mv.textContent(s));const n=this.streamTextContent(t);return new Promise(function(s,a){function o(){r.read().then(function({value:l,done:c}){if(c){s(i);return}i.lang??(i.lang=l.lang),Object.assign(i.styles,l.styles),i.items.push(...l.items),o()},a)}const r=n.getReader(),i={items:[],styles:Object.create(null),lang:null};o()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const n of this._intentStates.values())if(this._abortOperatorList({intentState:n,reason:new Error("Page was destroyed."),force:!0}),!n.opListReadCapability)for(const s of n.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),G(this,Al,!1),oe(this,Go,Xb).call(this),Promise.all(t)}cleanup(t=!1){G(this,Al,!0);const n=oe(this,Go,A0).call(this,!1);return t&&n&&this._stats&&(this._stats=new mP),n}_startRenderPage(t,n){var a,o;const s=this._intentStates.get(n);s&&((a=this._stats)==null||a.timeEnd("Page Request"),(o=s.displayReadyCapability)==null||o.resolve(t))}_renderPageChunk(t,n){for(let s=0,a=t.length;s{l.read().then(({value:d,done:h})=>{if(h){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,c),u())},d=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const h of c.renderTasks)h.operatorListChanged();oe(this,Go,A0).call(this,!0)}if(c.displayReadyCapability)c.displayReadyCapability.reject(d);else if(c.opListReadCapability)c.opListReadCapability.reject(d);else throw d}})};u()}_abortOperatorList({intentState:t,reason:n,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(n instanceof tw){let a=e4e;n.extraDelay>0&&n.extraDelay<1e3&&(a+=n.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:n,force:!0})},a);return}}if(t.streamReader.cancel(new Cc(n.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[a,o]of this._intentStates)if(o===t){this._intentStates.delete(a);break}this.cleanup()}}}get stats(){return this._stats}}Hc=new WeakMap,Al=new WeakMap,Go=new WeakSet,A0=function(t=!1){if(oe(this,Go,Xb).call(this),!y(this,Al)||this.destroyed)return!1;if(t)return G(this,Hc,setTimeout(()=>{G(this,Hc,null),oe(this,Go,A0).call(this,!1)},t4e)),!1;for(const{renderTasks:n,operatorList:s}of this._intentStates.values())if(n.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),G(this,Al,!1),!0},Xb=function(){y(this,Hc)&&(clearTimeout(y(this,Hc)),G(this,Hc,null))};class d4e{constructor(){ne(this,Tl,new Map);ne(this,Mb,Promise.resolve())}postMessage(t,n){const s={data:structuredClone(t,n?{transfer:n}:null)};y(this,Mb).then(()=>{for(const[a]of y(this,Tl))a.call(this,s)})}addEventListener(t,n,s=null){let a=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:o}=s;if(o.aborted){fn("LoopbackPort - cannot use an `aborted` signal.");return}const r=()=>this.removeEventListener(t,n);a=()=>o.removeEventListener("abort",r),o.addEventListener("abort",r)}y(this,Tl).set(n,a)}removeEventListener(t,n){const s=y(this,Tl).get(n);s==null||s(),y(this,Tl).delete(n)}terminate(){for(const[,t]of y(this,Tl))t==null||t();y(this,Tl).clear()}}Tl=new WeakMap,Mb=new WeakMap;const ss=class ss{constructor({name:t=null,port:n=null,verbosity:s=U1e()}={}){ne(this,zh);var a;if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,n){if((a=y(ss,kd))!=null&&a.has(n))throw new Error("Cannot use more than one PDFWorker per port.");(y(ss,kd)||G(ss,kd,new WeakMap)).set(n,this),this._initializeFromPort(n);return}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Ev("main","worker",t),this._messageHandler.on("ready",function(){}),oe(this,zh,Jb).call(this)}_initialize(){if(y(ss,xd)||y(ss,Hh,Zb)){this._setupFakeWorker();return}let{workerSrc:t}=ss;try{ss._isSameOrigin(window.location.href,t)||(t=ss._createCDNWrapper(new URL(t,window.location).href));const n=new Worker(t,{type:"module"}),s=new Ev("main","worker",n),a=()=>{o.abort(),s.destroy(),n.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},o=new AbortController;n.addEventListener("error",()=>{this._webWorker||a()},{signal:o.signal}),s.on("test",i=>{if(o.abort(),this.destroyed||!i){a();return}this._messageHandler=s,this._port=n,this._webWorker=n,oe(this,zh,Jb).call(this)}),s.on("ready",i=>{if(o.abort(),this.destroyed){a();return}try{r()}catch{this._setupFakeWorker()}});const r=()=>{const i=new Uint8Array;s.send("test",i,[i.buffer])};r();return}catch{eb("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){y(ss,xd)||(fn("Setting up fake worker."),G(ss,xd,!0)),ss._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const n=new d4e;this._port=n;const s=`fake${za(ss,Pb)._++}`,a=new Ev(s+"_worker",s,n);t.setup(a,n),this._messageHandler=new Ev(s,s+"_worker",n),oe(this,zh,Jb).call(this)}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){var t,n,s;this.destroyed=!0,(t=this._webWorker)==null||t.terminate(),this._webWorker=null,(n=y(ss,kd))==null||n.delete(this._port),this._port=null,(s=this._messageHandler)==null||s.destroy(),this._messageHandler=null}static fromPort(t){var s;if(!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const n=(s=y(this,kd))==null?void 0:s.get(t.port);if(n){if(n._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new ss(t)}static get workerSrc(){if(fl.workerSrc)return fl.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return mn(this,"_setupFakeWorkerGlobal",(async()=>y(this,Hh,Zb)?y(this,Hh,Zb):(await import(this.workerSrc)).WorkerMessageHandler)())}};Pb=new WeakMap,xd=new WeakMap,kd=new WeakMap,zh=new WeakSet,Jb=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Hh=new WeakSet,Zb=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},ne(ss,Hh),ne(ss,Pb,0),ne(ss,xd,!1),ne(ss,kd),ma&&(G(ss,xd,!0),fl.workerSrc||(fl.workerSrc="./pdf.worker.mjs")),ss._isSameOrigin=(t,n)=>{let s;try{if(s=new URL(t),!s.origin||s.origin==="null")return!1}catch{return!1}const a=new URL(n,s);return s.origin===a.origin},ss._createCDNWrapper=t=>{const n=`await import("${t}");`;return URL.createObjectURL(new Blob([n],{type:"text/javascript"}))};let ph=ss;class f4e{constructor(t,n,s,a,o){ne(this,Ed);ne(this,Ml,new Map);ne(this,Ci,new Map);ne(this,Wh,new Map);ne(this,jh,new Map);ne(this,Pl,null);this.messageHandler=t,this.loadingTask=n,this.commonObjs=new qP,this.fontLoader=new dbe({ownerDocument:a.ownerDocument,styleElement:a.styleElement}),this.loadingParams=a.loadingParams,this._params=a,this.canvasFactory=o.canvasFactory,this.filterFactory=o.filterFactory,this.cMapReaderFactory=o.cMapReaderFactory,this.standardFontDataFactory=o.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return mn(this,"annotationStorage",new uw)}getRenderingIntent(t,n=wc.ENABLE,s=null,a=!1,o=!1){let r=mo.DISPLAY,i=cw;switch(t){case"any":r=mo.ANY;break;case"display":break;case"print":r=mo.PRINT;break;default:fn(`getRenderingIntent - invalid intent: ${t}`)}const l=r&mo.PRINT&&s instanceof yP?s:this.annotationStorage;switch(n){case wc.DISABLE:r+=mo.ANNOTATIONS_DISABLE;break;case wc.ENABLE:break;case wc.ENABLE_FORMS:r+=mo.ANNOTATIONS_FORMS;break;case wc.ENABLE_STORAGE:r+=mo.ANNOTATIONS_STORAGE,i=l.serializable;break;default:fn(`getRenderingIntent - invalid annotationMode: ${n}`)}a&&(r+=mo.IS_EDITING),o&&(r+=mo.OPLIST);const{ids:c,hash:u}=l.modifiedIds,d=[r,i.hash,u];return{renderingIntent:r,cacheKey:d.join("_"),annotationStorageSerializable:i,modifiedIds:c}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=y(this,Pl))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const a of y(this,Ci).values())t.push(a._destroy());y(this,Ci).clear(),y(this,Wh).clear(),y(this,jh).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const n=this.messageHandler.sendWithPromise("Terminate",null);return t.push(n),Promise.all(t).then(()=>{var a,o;this.commonObjs.clear(),this.fontLoader.clear(),y(this,Ml).clear(),this.filterFactory.destroy(),Tv.cleanup(),(a=this._networkStream)==null||a.cancelAllRequests(new Cc("Worker was terminated.")),(o=this.messageHandler)==null||o.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:n}=this;t.on("GetReader",(s,a)=>{Ss(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=o=>{this._lastProgress={loaded:o.loaded,total:o.total}},a.onPull=()=>{this._fullReader.read().then(function({value:o,done:r}){if(r){a.close();return}Ss(o instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),a.enqueue(new Uint8Array(o),1,[o])}).catch(o=>{a.error(o)})},a.onCancel=o=>{this._fullReader.cancel(o),a.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",async s=>{var i;await this._fullReader.headersReady;const{isStreamingSupported:a,isRangeSupported:o,contentLength:r}=this._fullReader;return(!a||!o)&&(this._lastProgress&&((i=n.onProgress)==null||i.call(n,this._lastProgress)),this._fullReader.onProgress=l=>{var c;(c=n.onProgress)==null||c.call(n,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:a,isRangeSupported:o,contentLength:r}}),t.on("GetRangeReader",(s,a)=>{Ss(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const o=this._networkStream.getRangeReader(s.begin,s.end);if(!o){a.close();return}a.onPull=()=>{o.read().then(function({value:r,done:i}){if(i){a.close();return}Ss(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),a.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{a.error(r)})},a.onCancel=r=>{o.cancel(r),a.ready.catch(i=>{if(!this.destroyed)throw i})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,n._capability.resolve(new c4e(s,this))}),t.on("DocException",s=>{n._capability.reject(Za(s))}),t.on("PasswordRequest",s=>{G(this,Pl,Promise.withResolvers());try{if(!n.onPassword)throw Za(s);const a=o=>{o instanceof Error?y(this,Pl).reject(o):y(this,Pl).resolve({password:o})};n.onPassword(a,s.code)}catch(a){y(this,Pl).reject(a)}return y(this,Pl).promise}),t.on("DataLoaded",s=>{var a;(a=n.onProgress)==null||a.call(n,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;y(this,Ci).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,a,o])=>{var r;if(this.destroyed||this.commonObjs.has(s))return null;switch(a){case"Font":const{disableFontFace:i,fontExtraProperties:l,pdfBug:c}=this._params;if("error"in o){const p=o.error;fn(`Error during font loading: ${p}`),this.commonObjs.resolve(s,p);break}const u=c&&((r=globalThis.FontInspector)!=null&&r.enabled)?(p,v)=>globalThis.FontInspector.fontAdded(p,v):null,d=new fbe(o,{disableFontFace:i,fontExtraProperties:l,inspectFont:u});this.fontLoader.bind(d).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!l&&d.data&&(d.data=null),this.commonObjs.resolve(s,d)});break;case"CopyLocalImage":const{imageRef:h}=o;Ss(h,"The imageRef must be defined.");for(const p of y(this,Ci).values())for(const[,v]of p.objs)if((v==null?void 0:v.ref)===h)return v.dataLen?(this.commonObjs.resolve(s,structuredClone(v)),v.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,o);break;default:throw new Error(`Got unknown common object type ${a}`)}return null}),t.on("obj",([s,a,o,r])=>{var l;if(this.destroyed)return;const i=y(this,Ci).get(a);if(!i.objs.has(s)){if(i._intentStates.size===0){(l=r==null?void 0:r.bitmap)==null||l.close();return}switch(o){case"Image":i.objs.resolve(s,r),(r==null?void 0:r.dataLen)>z1e&&(i._maybeCleanupAfterRender=!0);break;case"Pattern":i.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${o}`)}}}),t.on("DocProgress",s=>{var a;this.destroyed||(a=n.onProgress)==null||a.call(n,{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(){var s;this.annotationStorage.size<=0&&fn("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:n}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((s=this._fullReader)==null?void 0:s.filename)??null},n).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const n=t-1,s=y(this,Wh).get(n);if(s)return s;const a=this.messageHandler.sendWithPromise("GetPage",{pageIndex:n}).then(o=>{if(this.destroyed)throw new Error("Transport destroyed");o.refStr&&y(this,jh).set(o.refStr,t);const r=new u4e(n,o,this,this._params.pdfBug);return y(this,Ci).set(n,r),r});return y(this,Wh).set(n,a),a}getPageIndex(t){return KP(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,n){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:n})}getFieldObjects(){return oe(this,Ed,m2).call(this,"GetFieldObjects")}hasJSActions(){return oe(this,Ed,m2).call(this,"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 oe(this,Ed,m2).call(this,"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 oe(this,Ed,m2).call(this,"GetOptionalContentConfig").then(n=>new Lbe(n,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",n=y(this,Ml).get(t);if(n)return n;const s=this.messageHandler.sendWithPromise(t,null).then(a=>{var o,r;return{info:a[0],metadata:a[1]?new Ibe(a[1]):null,contentDispositionFilename:((o=this._fullReader)==null?void 0:o.filename)??null,contentLength:((r=this._fullReader)==null?void 0:r.contentLength)??null}});return y(this,Ml).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 n of y(this,Ci).values())if(!n.cleanup())throw new Error(`startCleanup: Page ${n.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),y(this,Ml).clear(),this.filterFactory.destroy(!0),Tv.cleanup()}}cachedPageNumber(t){if(!KP(t))return null;const n=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return y(this,jh).get(n)??null}}Ml=new WeakMap,Ci=new WeakMap,Wh=new WeakMap,jh=new WeakMap,Pl=new WeakMap,Ed=new WeakSet,m2=function(t,n=null){const s=y(this,Ml).get(t);if(s)return s;const a=this.messageHandler.sendWithPromise(t,n);return y(this,Ml).set(t,a),a};const Pv=Symbol("INITIAL_DATA");class qP{constructor(){ne(this,Cm);ne(this,Co,Object.create(null))}get(t,n=null){if(n){const a=oe(this,Cm,c_).call(this,t);return a.promise.then(()=>n(a.data)),null}const s=y(this,Co)[t];if(!s||s.data===Pv)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const n=y(this,Co)[t];return!!n&&n.data!==Pv}delete(t){const n=y(this,Co)[t];return!n||n.data===Pv?!1:(delete y(this,Co)[t],!0)}resolve(t,n=null){const s=oe(this,Cm,c_).call(this,t);s.data=n,s.resolve()}clear(){var t;for(const n in y(this,Co)){const{data:s}=y(this,Co)[n];(t=s==null?void 0:s.bitmap)==null||t.close()}G(this,Co,Object.create(null))}*[Symbol.iterator](){for(const t in y(this,Co)){const{data:n}=y(this,Co)[t];n!==Pv&&(yield[t,n])}}}Co=new WeakMap,Cm=new WeakSet,c_=function(t){var n;return(n=y(this,Co))[t]||(n[t]={...Promise.withResolvers(),data:Pv})};class h4e{constructor(t){ne(this,Wc,null);G(this,Wc,t),this.onContinue=null}get promise(){return y(this,Wc).capability.promise}cancel(t=0){y(this,Wc).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=y(this,Wc).operatorList;if(!t)return!1;const{annotationCanvasMap:n}=y(this,Wc);return t.form||t.canvas&&(n==null?void 0:n.size)>0}}Wc=new WeakMap;const Td=class Td{constructor({callback:t,params:n,objs:s,commonObjs:a,annotationCanvasMap:o,operatorList:r,pageIndex:i,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:u=!1,pdfBug:d=!1,pageColors:h=null}){ne(this,jc,null);this.callback=t,this.params=n,this.objs=s,this.commonObjs=a,this.annotationCanvasMap=o,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=i,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=d,this.pageColors=h,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=u===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new h4e(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=n.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:n}){var i,l;if(this.cancelled)return;if(this._canvas){if(y(Td,Ad).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.");y(Td,Ad).add(this._canvas)}this._pdfBug&&((i=globalThis.StepperManager)!=null&&i.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:a,transform:o,background:r}=this.params;this.gfx=new fh(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:n},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:o,viewport:a,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(l=this.graphicsReadyCallback)==null||l.call(this)}cancel(t=null,n=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),y(this,jc)&&(window.cancelAnimationFrame(y(this,jc)),G(this,jc,null)),y(Td,Ad).delete(this._canvas),this.callback(t||new tw(`Rendering cancelled, page ${this._pageIndex+1}`,n))}operatorListChanged(){var t;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.stepper)==null||t.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?G(this,jc,window.requestAnimationFrame(()=>{G(this,jc,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(),y(Td,Ad).delete(this._canvas),this.callback())))}};jc=new WeakMap,Ad=new WeakMap,ne(Td,Ad,new WeakSet);let bw=Td;const p4e="4.10.38",v4e="f9bea397f";function GP(e){return Math.floor(Math.max(0,Math.min(1,e))*255).toString(16).padStart(2,"0")}function Rv(e){return Math.max(0,Math.min(255,255*e))}class YP{static CMYK_G([t,n,s,a]){return["G",1-Math.min(1,.3*t+.59*s+.11*n+a)]}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=Rv(t),[t,t,t]}static G_HTML([t]){const n=GP(t);return`#${n}${n}${n}`}static RGB_G([t,n,s]){return["G",.3*t+.59*n+.11*s]}static RGB_rgb(t){return t.map(Rv)}static RGB_HTML(t){return`#${t.map(GP).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,n,s,a]){return["RGB",1-Math.min(1,t+a),1-Math.min(1,s+a),1-Math.min(1,n+a)]}static CMYK_rgb([t,n,s,a]){return[Rv(1-Math.min(1,t+a)),Rv(1-Math.min(1,s+a)),Rv(1-Math.min(1,n+a))]}static CMYK_HTML(t){const n=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(n)}static RGB_CMYK([t,n,s]){const a=1-t,o=1-n,r=1-s,i=Math.min(a,o,r);return["CMYK",a,o,r,i]}}class m4e{create(t,n,s=!1){if(t<=0||n<=0)throw new Error("Invalid SVG dimensions");const a=this._createSVG("svg:svg");return a.setAttribute("version","1.1"),s||(a.setAttribute("width",`${t}px`),a.setAttribute("height",`${n}px`)),a.setAttribute("preserveAspectRatio","none"),a.setAttribute("viewBox",`0 0 ${t} ${n}`),a}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Hn("Abstract method `_createSVG` called.")}}class yw extends m4e{_createSVG(t){return document.createElementNS(dl,t)}}class XP{static setupStorage(t,n,s,a,o){const r=a.getValue(n,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),o==="print")break;t.addEventListener("input",i=>{a.setValue(n,{value:i.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),o==="print")break;t.addEventListener("change",i=>{a.setValue(n,{value:i.target.checked?i.target.getAttribute("xfaOn"):i.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),o==="print")break;t.addEventListener("input",i=>{a.setValue(n,{value:i.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const i of s.children)i.attributes.value===r.value?i.attributes.selected=!0:i.attributes.hasOwnProperty("selected")&&delete i.attributes.selected}t.addEventListener("input",i=>{const l=i.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;a.setValue(n,{value:c})});break}}static setAttributes({html:t,element:n,storage:s=null,intent:a,linkService:o}){const{attributes:r}=n,i=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${a}`);for(const[l,c]of Object.entries(r))if(c!=null)switch(l){case"class":c.length&&t.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!i||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,c)}i&&o.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,n,s)}static render(t){var d,h;const n=t.annotationStorage,s=t.linkService,a=t.xfaHtml,o=t.intent||"display",r=document.createElement(a.name);a.attributes&&this.setAttributes({html:r,element:a,intent:o,linkService:s});const i=o!=="richText",l=t.div;if(l.append(r),t.viewport){const p=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=p}i&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(a.children.length===0){if(a.value){const p=document.createTextNode(a.value);r.append(p),i&&Mv.shouldBuildText(a.name)&&c.push(p)}return{textDivs:c}}const u=[[a,-1,r]];for(;u.length>0;){const[p,v,m]=u.at(-1);if(v+1===p.children.length){u.pop();continue}const g=p.children[++u.at(-1)[1]];if(g===null)continue;const{name:b}=g;if(b==="#text"){const w=document.createTextNode(g.value);c.push(w),m.append(w);continue}const C=(d=g==null?void 0:g.attributes)!=null&&d.xmlns?document.createElementNS(g.attributes.xmlns,b):document.createElement(b);if(m.append(C),g.attributes&&this.setAttributes({html:C,element:g,storage:n,intent:o,linkService:s}),((h=g.children)==null?void 0:h.length)>0)u.push([g,-1,C]);else if(g.value){const w=document.createTextNode(g.value);i&&Mv.shouldBuildText(b)&&c.push(w),C.append(w)}}for(const p of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))p.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const n=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=n,t.div.hidden=!1}}const Iv=1e3,g4e=9,Uu=new WeakSet;function xc(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class b4e{static create(t){switch(t.data.annotationType){case Is.LINK:return new JP(t);case Is.TEXT:return new y4e(t);case Is.WIDGET:switch(t.data.fieldType){case"Tx":return new w4e(t);case"Btn":return t.data.radioButton?new ZP(t):t.data.checkBox?new C4e(t):new S4e(t);case"Ch":return new x4e(t);case"Sig":return new _4e(t)}return new qu(t);case Is.POPUP:return new ww(t);case Is.FREETEXT:return new QP(t);case Is.LINE:return new E4e(t);case Is.SQUARE:return new A4e(t);case Is.CIRCLE:return new T4e(t);case Is.POLYLINE:return new eR(t);case Is.CARET:return new P4e(t);case Is.INK:return new _w(t);case Is.POLYGON:return new M4e(t);case Is.HIGHLIGHT:return new tR(t);case Is.UNDERLINE:return new R4e(t);case Is.SQUIGGLY:return new I4e(t);case Is.STRIKEOUT:return new O4e(t);case Is.STAMP:return new nR(t);case Is.FILEATTACHMENT:return new L4e(t);default:return new vs(t)}}}const Lw=class Lw{constructor(t,{isRenderable:n=!1,ignoreBorder:s=!1,createQuadrilaterals:a=!1}={}){ne(this,Sm);ne(this,Md,null);ne(this,Kh,!1);ne(this,Uh,null);this.isRenderable=n,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,n&&(this.container=this._createContainer(s)),a&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:n,richText:s}){return!!(t!=null&&t.str||n!=null&&n.str||s!=null&&s.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Lw._hasPopupData(this.data)}updateEdited(t){var s;if(!this.container)return;y(this,Md)||G(this,Md,{rect:this.data.rect.slice(0)});const{rect:n}=t;n&&oe(this,Sm,u_).call(this,n),(s=y(this,Uh))==null||s.popup.updateEdited(t)}resetEdited(){var t;y(this,Md)&&(oe(this,Sm,u_).call(this,y(this,Md).rect),(t=y(this,Uh))==null||t.popup.resetEdited(),G(this,Md,null))}_createContainer(t){const{data:n,parent:{page:s,viewport:a}}=this,o=document.createElement("section");o.setAttribute("data-annotation-id",n.id),this instanceof qu||(o.tabIndex=Iv);const{style:r}=o;if(r.zIndex=this.parent.zIndex++,n.alternativeText&&(o.title=n.alternativeText),n.noRotate&&o.classList.add("norotate"),!n.rect||this instanceof ww){const{rotation:m}=n;return!n.hasOwnCanvas&&m!==0&&this.setRotation(m,o),o}const{width:i,height:l}=xc(n.rect);if(!t&&n.borderStyle.width>0){r.borderWidth=`${n.borderStyle.width}px`;const m=n.borderStyle.horizontalCornerRadius,g=n.borderStyle.verticalCornerRadius;if(m>0||g>0){const C=`calc(${m}px * var(--scale-factor)) / calc(${g}px * var(--scale-factor))`;r.borderRadius=C}else if(this instanceof ZP){const C=`calc(${i}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;r.borderRadius=C}switch(n.borderStyle.style){case _v.SOLID:r.borderStyle="solid";break;case _v.DASHED:r.borderStyle="dashed";break;case _v.BEVELED:fn("Unimplemented border style: beveled");break;case _v.INSET:fn("Unimplemented border style: inset");break;case _v.UNDERLINE:r.borderBottomStyle="solid";break}const b=n.borderColor||null;b?(G(this,Kh,!0),r.borderColor=zt.makeHexColor(b[0]|0,b[1]|0,b[2]|0)):r.borderWidth=0}const c=zt.normalizeRect([n.rect[0],s.view[3]-n.rect[1]+s.view[1],n.rect[2],s.view[3]-n.rect[3]+s.view[1]]),{pageWidth:u,pageHeight:d,pageX:h,pageY:p}=a.rawDims;r.left=`${100*(c[0]-h)/u}%`,r.top=`${100*(c[1]-p)/d}%`;const{rotation:v}=n;return n.hasOwnCanvas||v===0?(r.width=`${100*i/u}%`,r.height=`${100*l/d}%`):this.setRotation(v,o),o}setRotation(t,n=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:a}=this.parent.viewport.rawDims,{width:o,height:r}=xc(this.data.rect);let i,l;t%180===0?(i=100*o/s,l=100*r/a):(i=100*r/s,l=100*o/a),n.style.width=`${i}%`,n.style.height=`${l}%`,n.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(n,s,a)=>{const o=a.detail[n],r=o[0],i=o.slice(1);a.target.style[s]=YP[`${r}_HTML`](i),this.annotationStorage.setValue(this.data.id,{[s]:YP[`${r}_rgb`](i)})};return mn(this,"_commonActions",{display:n=>{const{display:s}=n.detail,a=s%2===1;this.container.style.visibility=a?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:a,noPrint:s===1||s===2})},print:n=>{this.annotationStorage.setValue(this.data.id,{noPrint:!n.detail.print})},hidden:n=>{const{hidden:s}=n.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:n=>{setTimeout(()=>n.target.focus({preventScroll:!1}),0)},userName:n=>{n.target.title=n.detail.userName},readonly:n=>{n.target.disabled=n.detail.readonly},required:n=>{this._setRequired(n.target,n.detail.required)},bgColor:n=>{t("bgColor","backgroundColor",n)},fillColor:n=>{t("fillColor","backgroundColor",n)},fgColor:n=>{t("fgColor","color",n)},textColor:n=>{t("textColor","color",n)},borderColor:n=>{t("borderColor","borderColor",n)},strokeColor:n=>{t("strokeColor","borderColor",n)},rotation:n=>{const s=n.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,n){const s=this._commonActions;for(const a of Object.keys(n.detail)){const o=t[a]||s[a];o==null||o(n)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const n=this.annotationStorage.getRawValue(this.data.id);if(!n)return;const s=this._commonActions;for(const[a,o]of Object.entries(n)){const r=s[a];if(r){const i={detail:{[a]:o},target:t};r(i),delete n[a]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[n,s,a,o]=this.data.rect.map(m=>Math.fround(m));if(t.length===8){const[m,g,b,C]=t.subarray(2,6);if(a===m&&o===g&&n===b&&s===C)return}const{style:r}=this.container;let i;if(y(this,Kh)){const{borderColor:m,borderWidth:g}=r;r.borderWidth=0,i=["url('data:image/svg+xml;utf8,",'',``],this.container.classList.add("hasBorder")}const l=a-n,c=o-s,{svgFactory:u}=this,d=u.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const h=u.createElement("defs");d.append(h);const p=u.createElement("clipPath"),v=`clippath_${this.data.id}`;p.setAttribute("id",v),p.setAttribute("clipPathUnits","objectBoundingBox"),h.append(p);for(let m=2,g=t.length;m`)}y(this,Kh)&&(i.push("')"),r.backgroundImage=i.join("")),this.container.append(d),this.container.style.clipPath=`url(#${v})`}_createPopup(){const{data:t}=this,n=G(this,Uh,new ww({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(n.render())}render(){Hn("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,n=null){const s=[];if(this._fieldObjects){const a=this._fieldObjects[t];if(a)for(const{page:o,id:r,exportValues:i}of a){if(o===-1||r===n)continue;const l=typeof i=="string"?i:null,c=document.querySelector(`[data-element-id="${r}"]`);if(c&&!Uu.has(c)){fn(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:l,domElement:c})}return s}for(const a of document.getElementsByName(t)){const{exportValue:o}=a,r=a.getAttribute("data-element-id");r!==n&&Uu.has(a)&&s.push({id:r,exportValue:o,domElement:a})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const n of t)n.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:n}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:n})})}};Md=new WeakMap,Kh=new WeakMap,Uh=new WeakMap,Sm=new WeakSet,u_=function(t){const{container:{style:n},data:{rect:s,rotation:a},parent:{viewport:{rawDims:{pageWidth:o,pageHeight:r,pageX:i,pageY:l}}}}=this;s==null||s.splice(0,4,...t);const{width:c,height:u}=xc(t);n.left=`${100*(t[0]-i)/o}%`,n.top=`${100*(r-t[3]+l)/r}%`,a===0?(n.width=`${100*c/o}%`,n.height=`${100*u/r}%`):this.setRotation(a)};let vs=Lw;class JP extends vs{constructor(n,s=null){super(n,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});ne(this,So);this.isTooltipOnly=n.data.isTooltipOnly}render(){const{data:n,linkService:s}=this,a=document.createElement("a");a.setAttribute("data-element-id",n.id);let o=!1;return n.url?(s.addLinkAttributes(a,n.url,n.newWindow),o=!0):n.action?(this._bindNamedAction(a,n.action),o=!0):n.attachment?(oe(this,So,KR).call(this,a,n.attachment,n.attachmentDest),o=!0):n.setOCGState?(oe(this,So,UR).call(this,a,n.setOCGState),o=!0):n.dest?(this._bindLink(a,n.dest),o=!0):(n.actions&&(n.actions.Action||n.actions["Mouse Up"]||n.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(a,n),o=!0),n.resetForm?(this._bindResetFormAction(a,n.resetForm),o=!0):this.isTooltipOnly&&!o&&(this._bindLink(a,""),o=!0)),this.container.classList.add("linkAnnotation"),o&&this.container.append(a),this.container}_bindLink(n,s){n.href=this.linkService.getDestinationHash(s),n.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&oe(this,So,nf).call(this)}_bindNamedAction(n,s){n.href=this.linkService.getAnchorUrl(""),n.onclick=()=>(this.linkService.executeNamedAction(s),!1),oe(this,So,nf).call(this)}_bindJSAction(n,s){n.href=this.linkService.getAnchorUrl("");const a=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const o of Object.keys(s.actions)){const r=a.get(o);r&&(n[r]=()=>{var i;return(i=this.linkService.eventBus)==null||i.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:o}}),!1})}n.onclick||(n.onclick=()=>!1),oe(this,So,nf).call(this)}_bindResetFormAction(n,s){const a=n.onclick;if(a||(n.href=this.linkService.getAnchorUrl("")),oe(this,So,nf).call(this),!this._fieldObjects){fn('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),a||(n.onclick=()=>!1);return}n.onclick=()=>{var d;a==null||a();const{fields:o,refs:r,include:i}=s,l=[];if(o.length!==0||r.length!==0){const h=new Set(r);for(const p of o){const v=this._fieldObjects[p]||[];for(const{id:m}of v)h.add(m)}for(const p of Object.values(this._fieldObjects))for(const v of p)h.has(v.id)===i&&l.push(v)}else for(const h of Object.values(this._fieldObjects))l.push(...h);const c=this.annotationStorage,u=[];for(const h of l){const{id:p}=h;switch(u.push(p),h.type){case"text":{const m=h.defaultValue||"";c.setValue(p,{value:m});break}case"checkbox":case"radiobutton":{const m=h.defaultValue===h.exportValues;c.setValue(p,{value:m});break}case"combobox":case"listbox":{const m=h.defaultValue||"";c.setValue(p,{value:m});break}default:continue}const v=document.querySelector(`[data-element-id="${p}"]`);if(v){if(!Uu.has(v)){fn(`_bindResetFormAction - element not allowed: ${p}`);continue}}else continue;v.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:u,name:"ResetForm"}})),!1}}}So=new WeakSet,nf=function(){this.container.setAttribute("data-internal-link","")},KR=function(n,s,a=null){n.href=this.linkService.getAnchorUrl(""),s.description&&(n.title=s.description),n.onclick=()=>{var o;return(o=this.downloadManager)==null||o.openOrDownloadData(s.content,s.filename,a),!1},oe(this,So,nf).call(this)},UR=function(n,s){n.href=this.linkService.getAnchorUrl(""),n.onclick=()=>(this.linkService.executeSetOCGState(s),!1),oe(this,So,nf).call(this)};class y4e extends vs{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 qu extends vs{render(){return this.container}showElementAndHideCanvas(t){var n;this.data.hasOwnCanvas&&(((n=t.previousSibling)==null?void 0:n.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return La.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,n,s,a,o){s.includes("mouse")?t.addEventListener(s,r=>{var i;(i=this.linkService.eventBus)==null||i.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:o(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(s,r=>{var i;if(s==="blur"){if(!n.focused||!r.relatedTarget)return;n.focused=!1}else if(s==="focus"){if(n.focused)return;n.focused=!0}o&&((i=this.linkService.eventBus)==null||i.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:o(r)}}))})}_setEventListeners(t,n,s,a){var o,r,i;for(const[l,c]of s)(c==="Action"||(o=this.data.actions)!=null&&o[c])&&((c==="Focus"||c==="Blur")&&(n||(n={focused:!1})),this._setEventListener(t,n,l,c,a),c==="Focus"&&!((r=this.data.actions)!=null&&r.Blur)?this._setEventListener(t,n,"blur","Blur",null):c==="Blur"&&!((i=this.data.actions)!=null&&i.Focus)&&this._setEventListener(t,n,"focus","Focus",null))}_setBackgroundColor(t){const n=this.data.backgroundColor||null;t.style.backgroundColor=n===null?"transparent":zt.makeHexColor(n[0],n[1],n[2])}_setTextStyle(t){const n=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,a=this.data.defaultAppearanceData.fontSize||g4e,o=t.style;let r;const i=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-i),u=Math.round(c/(G8*a))||1,d=c/u;r=Math.min(a,l(d/G8))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-i);r=Math.min(a,l(c/G8))}o.fontSize=`calc(${r}px * var(--scale-factor))`,o.color=zt.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(o.textAlign=n[this.data.textAlignment])}_setRequired(t,n){n?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",n)}}class w4e extends qu{constructor(t){const n=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:n})}setPropertyOnSiblings(t,n,s,a){const o=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[n]=s),o.setValue(r.id,{[a]:s})}render(){var a,o;const t=this.annotationStorage,n=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const r=t.getValue(n,{value:this.data.fieldValue});let i=r.value||"";const l=t.getValue(n,{charLimit:this.data.maxLen}).charLimit;l&&i.length>l&&(i=i.slice(0,l));let c=r.formattedValue||((a=this.data.textContent)==null?void 0:a.join(` @@ -74,7 +74,7 @@ ${v}`:`[${v}]`}function u({row:d,column:h}){if(!d._flags)return{};const p=h.prop `),position:m,pageIndex:g-1,rect:u.slice(0),rotation:d,id:h,deleted:!1,popupRef:p}}const r=await super.deserialize(n,s,a);return G(r,ko,n.fontSize),G(r,Ir,zt.makeHexColor(...n.color)),G(r,xo,oe(i=Un,Nl,m_).call(i,n.value)),r.annotationElementId=n.id||null,r._initialData=o,r}serialize(n=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=Un._internalPadding*this.parentScale,a=this.getRect(s,s),o=is._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:y(this,Ir)),r={annotationType:dn.FREETEXT,color:o,fontSize:y(this,ko),value:oe(this,ks,tI).call(this),pageIndex:this.pageIndex,rect:a,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return n?r:this.annotationElementId&&!oe(this,ks,nI).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(n){const s=super.renderAnnotationElement(n);if(this.deleted)return s;const{style:a}=s;a.fontSize=`calc(${y(this,ko)}px * var(--scale-factor))`,a.color=y(this,Ir),s.replaceChildren();for(const r of y(this,xo).split(` `)){const i=document.createElement("div");i.append(r?document.createTextNode(r):document.createElement("br")),s.append(i)}const o=Un._internalPadding*this.parentScale;return n.updateEdited({rect:this.getRect(o,o),popupContent:y(this,xo)}),s}resetAnnotationElement(n){super.resetAnnotationElement(n),n.resetEdited()}};Ir=new WeakMap,xo=new WeakMap,Fm=new WeakMap,Dd=new WeakMap,ko=new WeakMap,ks=new WeakSet,ZR=function(n){const s=o=>{this.editorDiv.style.fontSize=`calc(${o}px * var(--scale-factor))`,this.translate(0,-(o-y(this,ko))*this.parentScale),G(this,ko,o),oe(this,ks,n4).call(this)},a=y(this,ko);this.addCommands({cmd:s.bind(this,n),undo:s.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_n.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},QR=function(n){const s=o=>{G(this,Ir,this.editorDiv.style.color=o)},a=y(this,Ir);this.addCommands({cmd:s.bind(this,n),undo:s.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_n.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},eI=function(){var a;const n=[];this.editorDiv.normalize();let s=null;for(const o of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&o.nodeName==="BR"||(n.push(oe(a=Un,Nl,s4).call(a,o)),s=o);return n.join(` `)},n4=function(){const[n,s]=this.parentDimensions;let a;if(this.isAttachedToDOM)a=this.div.getBoundingClientRect();else{const{currentLayer:o,div:r}=this,i=r.style.display,l=r.classList.contains("hidden");r.classList.remove("hidden"),r.style.display="hidden",o.div.append(this.div),a=r.getBoundingClientRect(),r.remove(),r.style.display=i,r.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=a.width/n,this.height=a.height/s):(this.width=a.height/n,this.height=a.width/s),this.fixAndSetPosition()},Nl=new WeakSet,s4=function(n){return(n.nodeType===Node.TEXT_NODE?n.nodeValue:n.innerText).replaceAll(hb,"")},a4=function(){if(this.editorDiv.replaceChildren(),!!y(this,xo))for(const n of y(this,xo).split(` -`)){const s=document.createElement("div");s.append(n?document.createTextNode(n):document.createElement("br")),this.editorDiv.append(s)}},tI=function(){return y(this,xo).replaceAll(" "," ")},m_=function(n){return n.replaceAll(" "," ")},nI=function(n){const{value:s,fontSize:a,color:o,pageIndex:r}=this._initialData;return this._hasBeenMoved||n.value!==s||n.fontSize!==a||n.color.some((i,l)=>i!==o[l])||n.pageIndex!==r},ne(Un,Nl),Ut(Un,"_freeTextDefaultContent",""),Ut(Un,"_internalPadding",0),Ut(Un,"_defaultColor",null),Ut(Un,"_defaultFontSize",10),Ut(Un,"_type","freetext"),Ut(Un,"_editorType",dn.FREETEXT);let Cw=Un;class Lt{toSVGPath(){Hn("Abstract method `toSVGPath` must be implemented.")}get box(){Hn("Abstract getter `box` must be implemented.")}serialize(t,n){Hn("Abstract method `serialize` must be implemented.")}static _rescale(t,n,s,a,o,r){r||(r=new Float32Array(t.length));for(let i=0,l=t.length;i=6;a-=6)isNaN(n[a])?s.push(`L${n[a+4]} ${n[a+5]}`):s.push(`C${n[a]} ${n[a+1]} ${n[a+2]} ${n[a+3]} ${n[a+4]} ${n[a+5]}`);return oe(this,Ns,aI).call(this,s),s.join(" ")}newFreeDrawOutline(t,n,s,a,o,r){return new sR(t,n,s,a,o,r)}getOutlines(){var d;const t=y(this,Si),n=y(this,Or),s=y(this,gn),[a,o,r,i]=y(this,Eo),l=new Float32Array((((d=y(this,Kc))==null?void 0:d.length)??0)+2);for(let h=0,p=l.length-2;h=6;h-=6)for(let p=0;p<6;p+=2){if(isNaN(n[h+p])){c[u]=c[u+1]=NaN,u+=2;continue}c[u]=n[h+p],c[u+1]=n[h+p+1],u+=2}return oe(this,Ns,iI).call(this,c,u),this.newFreeDrawOutline(c,l,y(this,Eo),y(this,Qh),y(this,Jh),y(this,Zh))}};Eo=new WeakMap,Or=new WeakMap,Jh=new WeakMap,Zh=new WeakMap,Si=new WeakMap,gn=new WeakMap,Fd=new WeakMap,Bd=new WeakMap,Bm=new WeakMap,Vm=new WeakMap,Qh=new WeakMap,e0=new WeakMap,Kc=new WeakMap,zm=new WeakMap,Ob=new WeakMap,Lb=new WeakMap,Ns=new WeakSet,g2=function(){const t=y(this,gn).subarray(4,6),n=y(this,gn).subarray(16,18),[s,a,o,r]=y(this,Eo);return[(y(this,Fd)+(t[0]-n[0])/2-s)/o,(y(this,Bd)+(t[1]-n[1])/2-a)/r,(y(this,Fd)+(n[0]-t[0])/2-s)/o,(y(this,Bd)+(n[1]-t[1])/2-a)/r]},sI=function(){const[t,n,s,a]=y(this,Eo),[o,r,i,l]=oe(this,Ns,g2).call(this);return`M${(y(this,gn)[2]-t)/s} ${(y(this,gn)[3]-n)/a} L${(y(this,gn)[4]-t)/s} ${(y(this,gn)[5]-n)/a} L${o} ${r} L${i} ${l} L${(y(this,gn)[16]-t)/s} ${(y(this,gn)[17]-n)/a} L${(y(this,gn)[14]-t)/s} ${(y(this,gn)[15]-n)/a} Z`},aI=function(t){const n=y(this,Or);t.push(`L${n[4]} ${n[5]} Z`)},oI=function(t){const[n,s,a,o]=y(this,Eo),r=y(this,gn).subarray(4,6),i=y(this,gn).subarray(16,18),[l,c,u,d]=oe(this,Ns,g2).call(this);t.push(`L${(r[0]-n)/a} ${(r[1]-s)/o} L${l} ${c} L${u} ${d} L${(i[0]-n)/a} ${(i[1]-s)/o}`)},rI=function(t){const n=y(this,gn),[s,a,o,r]=y(this,Eo),[i,l,c,u]=oe(this,Ns,g2).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(n[2]-s)/o,(n[3]-a)/r,NaN,NaN,NaN,NaN,(n[4]-s)/o,(n[5]-a)/r,NaN,NaN,NaN,NaN,i,l,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,(n[16]-s)/o,(n[17]-a)/r,NaN,NaN,NaN,NaN,(n[14]-s)/o,(n[15]-a)/r],0),this.newFreeDrawOutline(d,t,y(this,Eo),y(this,Qh),y(this,Jh),y(this,Zh))},iI=function(t,n){const s=y(this,Or);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],n),n+=6},lI=function(t,n){const s=y(this,gn).subarray(4,6),a=y(this,gn).subarray(16,18),[o,r,i,l]=y(this,Eo),[c,u,d,h]=oe(this,Ns,g2).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-o)/i,(s[1]-r)/l,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,d,h,NaN,NaN,NaN,NaN,(a[0]-o)/i,(a[1]-r)/l],n),n+=24},ne($l,zm,8),ne($l,Ob,2),ne($l,Lb,y($l,zm)+y($l,Ob));let pb=$l;class sR extends Lt{constructor(n,s,a,o,r,i){super();ne(this,Nb);ne(this,t0);ne(this,Vd,new Float32Array(4));ne(this,Dl);ne(this,Hm);ne(this,Ao);ne(this,Wm);ne(this,gs);G(this,gs,n),G(this,Ao,s),G(this,t0,a),G(this,Wm,o),G(this,Dl,r),G(this,Hm,i),this.lastPoint=[NaN,NaN],oe(this,Nb,cI).call(this,i);const[l,c,u,d]=y(this,Vd);for(let h=0,p=n.length;hn[0]-s[0]||n[1]-s[1]||n[2]-s[2]);const t=[];for(const n of y(this,Uc))n[3]?(t.push(...oe(this,Da,g_).call(this,n)),oe(this,Da,dI).call(this,n)):(oe(this,Da,fI).call(this,n),t.push(...oe(this,Da,g_).call(this,n)));return oe(this,Da,uI).call(this,t)}}jm=new WeakMap,Km=new WeakMap,Uc=new WeakMap,Lr=new WeakMap,Da=new WeakSet,uI=function(t){const n=[],s=new Set;for(const r of t){const[i,l,c]=r;n.push([i,l,r],[i,c,r])}n.sort((r,i)=>r[1]-i[1]||r[0]-i[0]);for(let r=0,i=n.length;r0;){const r=s.values().next().value;let[i,l,c,u,d]=r;s.delete(r);let h=i,p=l;for(o=[i,c],a.push(o);;){let v;if(s.has(u))v=u;else if(s.has(d))v=d;else break;s.delete(v),[i,l,c,u,d]=v,h!==i&&(o.push(h,p,i,p===l?l:c),h=i),p=p===l?c:l}o.push(h,p)}return new $4e(a,y(this,jm),y(this,Km))},o4=function(t){const n=y(this,Lr);let s=0,a=n.length-1;for(;s<=a;){const o=s+a>>1,r=n[o][0];if(r===t)return o;r=0;a--){const[o,r]=y(this,Lr)[a];if(o!==t)break;if(o===t&&r===n){y(this,Lr).splice(a,1);return}}},g_=function(t){const[n,s,a]=t,o=[[n,s,a]],r=oe(this,Da,o4).call(this,a);for(let i=0;i=l){if(p>c)o[u][1]=c;else{if(d===1)return[];o.splice(u,1),u--,d--}continue}o[u][2]=l,p>c&&o.push([n,c,p])}}}return o};class $4e extends Lt{constructor(n,s,a){super();ne(this,Um);ne(this,n0);G(this,n0,n),G(this,Um,s),this.lastPoint=a}toSVGPath(){const n=[];for(const s of y(this,n0)){let[a,o]=s;n.push(`M${a} ${o}`);for(let r=2;r-1?(G(this,Qs,!0),oe(this,cn,r4).call(this,n),oe(this,cn,af).call(this)):y(this,Fl)&&(G(this,r0,n.anchorNode),G(this,Jm,n.anchorOffset),G(this,Zm,n.focusNode),G(this,Qm,n.focusOffset),oe(this,cn,__).call(this),oe(this,cn,af).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const n=Tn.prototype;return mn(this,"_keyboardManager",new kv([[["ArrowLeft","mac+ArrowLeft"],n._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],n._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],n._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],n._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:y(this,Qs)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:y(this,Xo),methodOfCreation:y(this,e2)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(n){return{numberOfColors:n.get("color").size}}static initialize(n,s){var a;is.initialize(n,s),Tn._defaultColor||(Tn._defaultColor=((a=s.highlightColors)==null?void 0:a.values().next().value)||"#fff066")}static updateDefaultParams(n,s){switch(n){case _n.HIGHLIGHT_DEFAULT_COLOR:Tn._defaultColor=s;break;case _n.HIGHLIGHT_THICKNESS:Tn._defaultThickness=s;break}}translateInPage(n,s){}get toolbarPosition(){return y(this,l0)}updateParams(n,s){switch(n){case _n.HIGHLIGHT_COLOR:oe(this,cn,pI).call(this,s);break;case _n.HIGHLIGHT_THICKNESS:oe(this,cn,vI).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[_n.HIGHLIGHT_DEFAULT_COLOR,Tn._defaultColor],[_n.HIGHLIGHT_THICKNESS,Tn._defaultThickness]]}get propertiesToUpdate(){return[[_n.HIGHLIGHT_COLOR,this.color||Tn._defaultColor],[_n.HIGHLIGHT_THICKNESS,y(this,Xo)||Tn._defaultThickness],[_n.HIGHLIGHT_FREE,y(this,Qs)]]}async addEditToolbar(){const n=await super.addEditToolbar();return n?(this._uiManager.highlightColors&&(G(this,i0,new vb({editor:this})),n.addColorPicker(y(this,i0))),n):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(oe(this,cn,b2).call(this))}getBaseTranslation(){return[0,0]}getRect(n,s){return super.getRect(n,s,oe(this,cn,b2).call(this))}onceAdded(n){this.annotationElementId||this.parent.addUndoableEditor(this),n&&this.div.focus()}remove(){oe(this,cn,C_).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(oe(this,cn,af).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(n){var a;let s=!1;this.parent&&!n?oe(this,cn,C_).call(this):n&&(oe(this,cn,af).call(this,n),s=!this.parent&&((a=this.div)==null?void 0:a.classList.contains("selectedEditor"))),super.setParent(n),this.show(this._isVisible),s&&this.select()}rotate(n){var o,r,i;const{drawLayer:s}=this.parent;let a;y(this,Qs)?(n=(n-this.rotation+360)%360,a=oe(o=Tn,Jo,T0).call(o,y(this,Yo).box,n)):a=oe(r=Tn,Jo,T0).call(r,[this.x,this.y,this.width,this.height],n),s.updateProperties(y(this,To),{bbox:a,root:{"data-main-rotation":n}}),s.updateProperties(y(this,_a),{bbox:oe(i=Tn,Jo,T0).call(i,y(this,ao).box,n),root:{"data-main-rotation":n}})}render(){if(this.div)return this.div;const n=super.render();y(this,c0)&&(n.setAttribute("aria-label",y(this,c0)),n.setAttribute("role","mark")),y(this,Qs)?n.classList.add("free"):this.div.addEventListener("keydown",oe(this,cn,gI).bind(this),{signal:this._uiManager._signal});const s=G(this,Wd,document.createElement("div"));n.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=y(this,Hd);const[a,o]=this.parentDimensions;return this.setDims(this.width*a,this.height*o),ob(this,y(this,Wd),["pointerover","pointerleave"]),this.enableEditing(),n}pointerover(){var n;this.isSelected||(n=this.parent)==null||n.drawLayer.updateProperties(y(this,_a),{rootClass:{hovered:!0}})}pointerleave(){var n;this.isSelected||(n=this.parent)==null||n.drawLayer.updateProperties(y(this,_a),{rootClass:{hovered:!1}})}_moveCaret(n){switch(this.parent.unselect(this),n){case 0:case 2:oe(this,cn,i4).call(this,!0);break;case 1:case 3:oe(this,cn,i4).call(this,!1);break}}select(){var n;super.select(),y(this,_a)&&((n=this.parent)==null||n.drawLayer.updateProperties(y(this,_a),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var n;super.unselect(),y(this,_a)&&((n=this.parent)==null||n.drawLayer.updateProperties(y(this,_a),{rootClass:{selected:!1}}),y(this,Qs)||oe(this,cn,i4).call(this,!1))}get _mustFixPosition(){return!y(this,Qs)}show(n=this._isVisible){super.show(n),this.parent&&(this.parent.drawLayer.updateProperties(y(this,To),{rootClass:{hidden:!n}}),this.parent.drawLayer.updateProperties(y(this,_a),{rootClass:{hidden:!n}}))}static startHighlighting(n,s,{target:a,x:o,y:r}){const{x:i,y:l,width:c,height:u}=a.getBoundingClientRect(),d=new AbortController,h=n.combinedSignal(d),p=v=>{d.abort(),oe(this,Jo,_I).call(this,n,v)};window.addEventListener("blur",p,{signal:h}),window.addEventListener("pointerup",p,{signal:h}),window.addEventListener("pointerdown",go,{capture:!0,passive:!1,signal:h}),window.addEventListener("contextmenu",xr,{signal:h}),a.addEventListener("pointermove",oe(this,Jo,wI).bind(this,n),{signal:h}),this._freeHighlight=new xw({x:o,y:r},[i,l,c,u],n.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=n.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 async deserialize(n,s,a){var m,g,b,C;let o=null;if(n instanceof tR){const{data:{quadPoints:w,rect:_,rotation:x,id:k,color:T,opacity:I,popupRef:O},parent:{page:{pageNumber:R}}}=n;o=n={annotationType:dn.HIGHLIGHT,color:Array.from(T),opacity:I,quadPoints:w,boxes:null,pageIndex:R-1,rect:_.slice(0),rotation:x,id:k,deleted:!1,popupRef:O}}else if(n instanceof _w){const{data:{inkLists:w,rect:_,rotation:x,id:k,color:T,borderStyle:{rawWidth:I},popupRef:O},parent:{page:{pageNumber:R}}}=n;o=n={annotationType:dn.HIGHLIGHT,color:Array.from(T),thickness:I,inkLists:w,boxes:null,pageIndex:R-1,rect:_.slice(0),rotation:x,id:k,deleted:!1,popupRef:O}}const{color:r,quadPoints:i,inkLists:l,opacity:c}=n,u=await super.deserialize(n,s,a);u.color=zt.makeHexColor(...r),G(u,Bl,c||1),l&&G(u,Xo,n.thickness),u.annotationElementId=n.id||null,u._initialData=o;const[d,h]=u.pageDimensions,[p,v]=u.pageTranslation;if(i){const w=G(u,Fl,[]);for(let _=0;_=0)G(this,To,s),G(this,Hd,a),this.parent.drawLayer.finalizeDraw(s,{bbox:n.box,path:{d:n.toSVGPath()}}),G(this,_a,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:y(this,ao).box,path:{d:y(this,ao).toSVGPath()}},!0));else if(this.parent){const p=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(y(this,To),{bbox:oe(d=Tn,Jo,T0).call(d,y(this,Yo).box,(p-this.rotation+360)%360),path:{d:n.toSVGPath()}}),this.parent.drawLayer.updateProperties(y(this,_a),{bbox:oe(h=Tn,Jo,T0).call(h,y(this,ao).box,p),path:{d:y(this,ao).toSVGPath()}})}const[r,i,l,c]=n.box;switch(this.rotation){case 0:this.x=r,this.y=i,this.width=l,this.height=c;break;case 90:{const[p,v]=this.parentDimensions;this.x=i,this.y=1-r,this.width=l*v/p,this.height=c*p/v;break}case 180:this.x=1-r,this.y=1-i,this.width=l,this.height=c;break;case 270:{const[p,v]=this.parentDimensions;this.x=1-i,this.y=r,this.width=l*v/p,this.height=c*p/v;break}}const{lastPoint:u}=y(this,ao);G(this,l0,[(u[0]-r)/l,(u[1]-i)/c])},pI=function(n){const s=(r,i)=>{var l,c;this.color=r,G(this,Bl,i),(l=this.parent)==null||l.drawLayer.updateProperties(y(this,To),{root:{fill:r,"fill-opacity":i}}),(c=y(this,i0))==null||c.updateColor(r)},a=this.color,o=y(this,Bl);this.addCommands({cmd:s.bind(this,n,Tn._defaultOpacity),undo:s.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_n.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(n)},!0)},vI=function(n){const s=y(this,Xo),a=o=>{G(this,Xo,o),oe(this,cn,mI).call(this,o)};this.addCommands({cmd:a.bind(this,n),undo:a.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_n.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:n},!0)},mI=function(n){if(!y(this,Qs))return;oe(this,cn,r4).call(this,{highlightOutlines:y(this,Yo).getNewOutline(n/2)}),this.fixAndSetPosition();const[s,a]=this.parentDimensions;this.setDims(this.width*s,this.height*a)},C_=function(){y(this,To)===null||!this.parent||(this.parent.drawLayer.remove(y(this,To)),G(this,To,null),this.parent.drawLayer.remove(y(this,_a)),G(this,_a,null))},af=function(n=this.parent){y(this,To)===null&&({id:za(this,To)._,clipPathId:za(this,Hd)._}=n.drawLayer.draw({bbox:y(this,Yo).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":y(this,Bl)},rootClass:{highlight:!0,free:y(this,Qs)},path:{d:y(this,Yo).toSVGPath()}},!1,!0),G(this,_a,n.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:y(this,Qs)},bbox:y(this,ao).box,path:{d:y(this,ao).toSVGPath()}},y(this,Qs))),y(this,Wd)&&(y(this,Wd).style.clipPath=y(this,Hd)))},Jo=new WeakSet,T0=function([n,s,a,o],r){switch(r){case 90:return[1-s-o,n,o,a];case 180:return[1-n-a,1-s-o,a,o];case 270:return[s,1-n-a,o,a]}return[n,s,a,o]},gI=function(n){Tn._keyboardManager.exec(this,n)},i4=function(n){if(!y(this,r0))return;const s=window.getSelection();n?s.setPosition(y(this,r0),y(this,Jm)):s.setPosition(y(this,Zm),y(this,Qm))},b2=function(){return y(this,Qs)?this.rotation:0},bI=function(){if(y(this,Qs))return null;const[n,s]=this.pageDimensions,[a,o]=this.pageTranslation,r=y(this,Fl),i=new Float32Array(r.length*8);let l=0;for(const{x:c,y:u,width:d,height:h}of r){const p=c*n+a,v=(1-u)*s+o;i[l]=i[l+4]=p,i[l+1]=i[l+3]=v,i[l+2]=i[l+6]=p+d*n,i[l+5]=i[l+7]=v-h*s,l+=8}return i},yI=function(n){return y(this,Yo).serialize(n,oe(this,cn,b2).call(this))},wI=function(n,s){this._freeHighlight.add(s)&&n.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},_I=function(n,s){this._freeHighlight.isEmpty()?n.drawLayer.remove(this._freeHighlightId):n.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},CI=function(n){const{color:s}=this._initialData;return n.color.some((a,o)=>a!==s[o])},ne(Tn,Jo),Ut(Tn,"_defaultColor",null),Ut(Tn,"_defaultOpacity",1),Ut(Tn,"_defaultThickness",12),Ut(Tn,"_type","highlight"),Ut(Tn,"_editorType",dn.HIGHLIGHT),Ut(Tn,"_freeHighlightId",-1),Ut(Tn,"_freeHighlight",null),Ut(Tn,"_freeHighlightClipId","");let mb=Tn;class F4e{constructor(){ne(this,jd,Object.create(null))}updateProperty(t,n){this[t]=n,this.updateSVGProperty(t,n)}updateProperties(t){if(t)for(const[n,s]of Object.entries(t))this.updateProperty(n,s)}updateSVGProperty(t,n){y(this,jd)[t]=n}toSVGProperties(){const t=y(this,jd);return G(this,jd,Object.create(null)),{root:t}}reset(){G(this,jd,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){Hn("Not implemented")}}jd=new WeakMap;const $t=class $t extends is{constructor(n){super(n);ne(this,Sn);ne(this,Mo,null);ne(this,u0);Ut(this,"_drawId",null);G(this,u0,n.mustBeCommitted||!1),n.drawOutlines&&(oe(this,Sn,S_).call(this,n),oe(this,Sn,y2).call(this))}static _mergeSVGProperties(n,s){const a=new Set(Object.keys(n));for(const[o,r]of Object.entries(s))a.has(o)?Object.assign(n[o],r):n[o]=r;return n}static getDefaultDrawingOptions(n){Hn("Not implemented")}static get typesMap(){Hn("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(n,s){const a=this.typesMap.get(n);a&&this._defaultDrawingOptions.updateProperty(a,s),this._currentParent&&(y($t,js).updateProperty(a,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(n,s){const a=this.constructor.typesMap.get(n);a&&this._updateProperty(n,a,s)}static get defaultPropertiesToUpdate(){const n=[],s=this._defaultDrawingOptions;for(const[a,o]of this.typesMap)n.push([a,s[o]]);return n}get propertiesToUpdate(){const n=[],{_drawingOptions:s}=this;for(const[a,o]of this.constructor.typesMap)n.push([a,s[o]]);return n}_updateProperty(n,s,a){const o=this._drawingOptions,r=o[s],i=l=>{var u;o.updateProperty(s,l);const c=y(this,Mo).updateProperty(s,l);c&&oe(this,Sn,w2).call(this,c),(u=this.parent)==null||u.drawLayer.updateProperties(this._drawId,o.toSVGProperties())};this.addCommands({cmd:i.bind(this,a),undo:i.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,$t._mergeSVGProperties(y(this,Mo).getPathResizingSVGProperties(oe(this,Sn,l4).call(this)),{bbox:oe(this,Sn,M0).call(this)}))}_onResized(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,$t._mergeSVGProperties(y(this,Mo).getPathResizedSVGProperties(oe(this,Sn,l4).call(this)),{bbox:oe(this,Sn,M0).call(this)}))}_onTranslating(n,s){var a;(a=this.parent)==null||a.drawLayer.updateProperties(this._drawId,{bbox:oe(this,Sn,M0).call(this,n,s)})}_onTranslated(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,$t._mergeSVGProperties(y(this,Mo).getPathTranslatedSVGProperties(oe(this,Sn,l4).call(this),this.parentDimensions),{bbox:oe(this,Sn,M0).call(this)}))}_onStartDragging(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var n;(n=this.parent)==null||n.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(n){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,y(this,u0)&&(G(this,u0,!1),this.commit(),this.parent.setSelected(this),n&&this.isOnScreen&&this.div.focus())}remove(){oe(this,Sn,k_).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(oe(this,Sn,y2).call(this),oe(this,Sn,w2).call(this,y(this,Mo).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(n){var a;let s=!1;this.parent&&!n?(this._uiManager.removeShouldRescale(this),oe(this,Sn,k_).call(this)):n&&(this._uiManager.addShouldRescale(this),oe(this,Sn,y2).call(this,n),s=!this.parent&&((a=this.div)==null?void 0:a.classList.contains("selectedEditor"))),super.setParent(n),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,$t._mergeSVGProperties({bbox:oe(this,Sn,M0).call(this)},y(this,Mo).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&oe(this,Sn,w2).call(this,y(this,Mo).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const n=super.render();n.classList.add("draw");const s=document.createElement("div");n.append(s),s.setAttribute("aria-hidden","true"),s.className="internal";const[a,o]=this.parentDimensions;return this.setDims(this.width*a,this.height*o),this._uiManager.addShouldRescale(this),this.disableEditing(),n}static createDrawerInstance(n,s,a,o,r){Hn("Not implemented")}static startDrawing(n,s,a,o){var g;const{target:r,offsetX:i,offsetY:l,pointerId:c,pointerType:u}=o;if(y($t,Yc)&&y($t,Yc)!==u)return;const{viewport:{rotation:d}}=n,{width:h,height:p}=r.getBoundingClientRect(),v=G($t,Kd,new AbortController),m=n.combinedSignal(v);if(y($t,Gc)||G($t,Gc,c),y($t,Yc)??G($t,Yc,u),window.addEventListener("pointerup",b=>{var C;y($t,Gc)===b.pointerId?this._endDraw(b):(C=y($t,Xc))==null||C.delete(b.pointerId)},{signal:m}),window.addEventListener("pointercancel",b=>{var C;y($t,Gc)===b.pointerId?this._currentParent.endDrawingSession():(C=y($t,Xc))==null||C.delete(b.pointerId)},{signal:m}),window.addEventListener("pointerdown",b=>{y($t,Yc)===b.pointerType&&((y($t,Xc)||G($t,Xc,new Set)).add(b.pointerId),y($t,js).isCancellable()&&(y($t,js).removeLastElement(),y($t,js).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",xr,{signal:m}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:m}),r.addEventListener("touchmove",b=>{b.timeStamp===y($t,qd)&&go(b)},{signal:m}),n.toggleDrawing(),(g=s._editorUndoBar)==null||g.hide(),y($t,js)){n.drawLayer.updateProperties(this._currentDrawId,y($t,js).startNew(i,l,h,p,d));return}s.updateUIForDefaultProperties(this),G($t,js,this.createDrawerInstance(i,l,h,p,d)),G($t,Ud,this.getDefaultDrawingOptions()),this._currentParent=n,{id:this._currentDrawId}=n.drawLayer.draw(this._mergeSVGProperties(y($t,Ud).toSVGProperties(),y($t,js).defaultSVGProperties),!0,!1)}static _drawMove(n){var r;if(G($t,qd,-1),!y($t,js))return;const{offsetX:s,offsetY:a,pointerId:o}=n;if(y($t,Gc)===o){if(((r=y($t,Xc))==null?void 0:r.size)>=1){this._endDraw(n);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,y($t,js).add(s,a)),G($t,qd,n.timeStamp),go(n)}}static _cleanup(n){n&&(this._currentDrawId=-1,this._currentParent=null,G($t,js,null),G($t,Ud,null),G($t,Yc,null),G($t,qd,NaN)),y($t,Kd)&&(y($t,Kd).abort(),G($t,Kd,null),G($t,Gc,NaN),G($t,Xc,null))}static _endDraw(n){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),n&&s.drawLayer.updateProperties(this._currentDrawId,y($t,js).end(n.offsetX,n.offsetY)),this.supportMultipleDrawings){const a=y($t,js),o=this._currentDrawId,r=a.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(o,a.setLastElement(r))},undo:()=>{s.drawLayer.updateProperties(o,a.removeLastElement())},mustExec:!1,type:_n.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(n){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(_n.DRAW_STEP),!y($t,js).isEmpty()){const{pageDimensions:[a,o],scale:r}=s,i=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:y($t,js).getOutlines(a*r,o*r,r,this._INNER_MARGIN),drawingOptions:y($t,Ud),mustBeCommitted:!n});return this._cleanup(!0),i}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(n){}static deserializeDraw(n,s,a,o,r,i){Hn("Not implemented")}static async deserialize(n,s,a){var d,h;const{rawDims:{pageWidth:o,pageHeight:r,pageX:i,pageY:l}}=s.viewport,c=this.deserializeDraw(i,l,o,r,this._INNER_MARGIN,n),u=await super.deserialize(n,s,a);return u.createDrawingOptions(n),oe(d=u,Sn,S_).call(d,{drawOutlines:c}),oe(h=u,Sn,y2).call(h),u.onScaleChanging(),u.rotate(),u}serializeDraw(n){const[s,a]=this.pageTranslation,[o,r]=this.pageDimensions;return y(this,Mo).serialize([s,a,o,r],n)}renderAnnotationElement(n){return n.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};Mo=new WeakMap,u0=new WeakMap,js=new WeakMap,Kd=new WeakMap,Ud=new WeakMap,Gc=new WeakMap,Yc=new WeakMap,Xc=new WeakMap,qd=new WeakMap,Sn=new WeakSet,S_=function({drawOutlines:n,drawId:s,drawingOptions:a}){G(this,Mo,n),this._drawingOptions||(this._drawingOptions=a),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,n.defaultProperties)):this._drawId=oe(this,Sn,x_).call(this,n,this.parent),oe(this,Sn,w2).call(this,n.box)},x_=function(n,s){const{id:a}=s.drawLayer.draw($t._mergeSVGProperties(this._drawingOptions.toSVGProperties(),n.defaultSVGProperties),!1,!1);return a},k_=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},y2=function(n=this.parent){if(!(this._drawId!==null&&this.parent===n)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,n.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=oe(this,Sn,x_).call(this,y(this,Mo),n)}},SI=function([n,s,a,o]){const{parentDimensions:[r,i],rotation:l}=this;switch(l){case 90:return[s,1-n,a*(i/r),o*(r/i)];case 180:return[1-n,1-s,a,o];case 270:return[1-s,n,a*(i/r),o*(r/i)];default:return[n,s,a,o]}},l4=function(){const{x:n,y:s,width:a,height:o,parentDimensions:[r,i],rotation:l}=this;switch(l){case 90:return[1-s,n,a*(r/i),o*(i/r)];case 180:return[1-n,1-s,a,o];case 270:return[s,1-n,a*(r/i),o*(i/r)];default:return[n,s,a,o]}},w2=function(n){if([this.x,this.y,this.width,this.height]=oe(this,Sn,SI).call(this,n),this.div){this.fixAndSetPosition();const[s,a]=this.parentDimensions;this.setDims(this.width*s,this.height*a)}this._onResized()},M0=function(){const{x:n,y:s,width:a,height:o,rotation:r,parentRotation:i,parentDimensions:[l,c]}=this;switch((r*4+i)/90){case 1:return[1-s-o,n,o,a];case 2:return[1-n-a,1-s-o,a,o];case 3:return[s,1-n-a,o,a];case 4:return[n,s-a*(l/c),o*(c/l),a*(l/c)];case 5:return[1-s,n,a*(l/c),o*(c/l)];case 6:return[1-n-o*(c/l),1-s,o*(c/l),a*(l/c)];case 7:return[s-a*(l/c),1-n-o*(c/l),a*(l/c),o*(c/l)];case 8:return[n-a,s-o,a,o];case 9:return[1-s,n-a,o,a];case 10:return[1-n,1-s,a,o];case 11:return[s-o,1-n,o,a];case 12:return[n-o*(c/l),s,o*(c/l),a*(l/c)];case 13:return[1-s-a*(l/c),n-o*(c/l),a*(l/c),o*(c/l)];case 14:return[1-n,1-s-a*(l/c),o*(c/l),a*(l/c)];case 15:return[s,1-n,a*(l/c),o*(c/l)];default:return[n,s,a,o]}},Ut($t,"_currentDrawId",-1),Ut($t,"_currentParent",null),ne($t,js,null),ne($t,Kd,null),ne($t,Ud,null),ne($t,Gc,NaN),ne($t,Yc,null),ne($t,Xc,null),ne($t,qd,NaN),Ut($t,"_INNER_MARGIN",3);let kw=$t;class B4e{constructor(t,n,s,a,o,r){ne(this,f0);ne(this,xi,new Float64Array(6));ne(this,Ks);ne(this,Us);ne(this,Gd);ne(this,d0);ne(this,Fa);ne(this,ea,"");ne(this,Zo,0);ne(this,Yd,new gb);ne(this,Xd);ne(this,Jd);G(this,Xd,s),G(this,Jd,a),G(this,Gd,o),G(this,d0,r),[t,n]=oe(this,f0,c4).call(this,t,n);const i=G(this,Ks,[NaN,NaN,NaN,NaN,t,n]);G(this,Fa,[t,n]),G(this,Us,[{line:i,points:y(this,Fa)}]),y(this,xi).set(i,0)}updateProperty(t,n){t==="stroke-width"&&G(this,d0,n)}isEmpty(){return!y(this,Us)||y(this,Us).length===0}isCancellable(){return y(this,Fa).length<=10}add(t,n){[t,n]=oe(this,f0,c4).call(this,t,n);const[s,a,o,r]=y(this,xi).subarray(2,6),i=t-o,l=n-r;return Math.hypot(y(this,Xd)*i,y(this,Jd)*l)<=2?null:(y(this,Fa).push(t,n),isNaN(s)?(y(this,xi).set([o,r,t,n],2),y(this,Ks).push(NaN,NaN,NaN,NaN,t,n),{path:{d:this.toSVGPath()}}):(isNaN(y(this,xi)[0])&&y(this,Ks).splice(6,6),y(this,xi).set([s,a,o,r,t,n],0),y(this,Ks).push(...Lt.createBezierPoints(s,a,o,r,t,n)),{path:{d:this.toSVGPath()}}))}end(t,n){const s=this.add(t,n);return s||(y(this,Fa).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,n,s,a,o){G(this,Xd,s),G(this,Jd,a),G(this,Gd,o),[t,n]=oe(this,f0,c4).call(this,t,n);const r=G(this,Ks,[NaN,NaN,NaN,NaN,t,n]);G(this,Fa,[t,n]);const i=y(this,Us).at(-1);return i&&(i.line=new Float32Array(i.line),i.points=new Float32Array(i.points)),y(this,Us).push({line:r,points:y(this,Fa)}),y(this,xi).set(r,0),G(this,Zo,0),this.toSVGPath(),null}getLastElement(){return y(this,Us).at(-1)}setLastElement(t){return y(this,Us)?(y(this,Us).push(t),G(this,Ks,t.line),G(this,Fa,t.points),G(this,Zo,0),{path:{d:this.toSVGPath()}}):y(this,Yd).setLastElement(t)}removeLastElement(){if(!y(this,Us))return y(this,Yd).removeLastElement();y(this,Us).pop(),G(this,ea,"");for(let t=0,n=y(this,Us).length;t_??NaN),h,p,v,m),points:g(l[C].map(_=>_??NaN),h,p,v,m)});const b=new Nw;return b.build(d,a,o,1,c,u,r),b}get box(){return y(this,Ba)}updateProperty(n,s){return n==="stroke-width"?oe(this,ta,EI).call(this,s):null}updateParentDimensions([n,s],a){const[o,r]=oe(this,ta,ql).call(this);G(this,ki,n),G(this,Ei,s),G(this,h0,a);const[i,l]=oe(this,ta,ql).call(this),c=i-o,u=l-r,d=y(this,Ba);return d[0]-=c,d[1]-=u,d[2]+=2*c,d[3]+=2*u,d}updateRotation(n){return G(this,t2,n),{path:{transform:this.rotationTransform}}}get viewBox(){return y(this,Ba).map(Lt.svgRound).join(" ")}get defaultProperties(){const[n,s]=y(this,Ba);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Lt.svgRound(n)} ${Lt.svgRound(s)}`}}}get rotationTransform(){const[,,n,s]=y(this,Ba);let a=0,o=0,r=0,i=0,l=0,c=0;switch(y(this,t2)){case 90:o=s/n,r=-n/s,l=n;break;case 180:a=-1,i=-1,l=n,c=s;break;case 270:o=-s/n,r=n/s,c=s;break;default:return""}return`matrix(${a} ${o} ${r} ${i} ${Lt.svgRound(l)} ${Lt.svgRound(c)})`}getPathResizingSVGProperties([n,s,a,o]){const[r,i]=oe(this,ta,ql).call(this),[l,c,u,d]=y(this,Ba);if(Math.abs(u-r)<=Lt.PRECISION||Math.abs(d-i)<=Lt.PRECISION){const g=n+a/2-(l+u/2),b=s+o/2-(c+d/2);return{path:{"transform-origin":`${Lt.svgRound(n)} ${Lt.svgRound(s)}`,transform:`${this.rotationTransform} translate(${g} ${b})`}}}const h=(a-2*r)/(u-2*r),p=(o-2*i)/(d-2*i),v=u/a,m=d/o;return{path:{"transform-origin":`${Lt.svgRound(l)} ${Lt.svgRound(c)}`,transform:`${this.rotationTransform} scale(${v} ${m}) translate(${Lt.svgRound(r)} ${Lt.svgRound(i)}) scale(${h} ${p}) translate(${Lt.svgRound(-r)} ${Lt.svgRound(-i)})`}}}getPathResizedSVGProperties([n,s,a,o]){const[r,i]=oe(this,ta,ql).call(this),l=y(this,Ba),[c,u,d,h]=l;if(l[0]=n,l[1]=s,l[2]=a,l[3]=o,Math.abs(d-r)<=Lt.PRECISION||Math.abs(h-i)<=Lt.PRECISION){const b=n+a/2-(c+d/2),C=s+o/2-(u+h/2);for(const{line:w,points:_}of y(this,Po))Lt._translate(w,b,C,w),Lt._translate(_,b,C,_);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Lt.svgRound(n)} ${Lt.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const p=(a-2*r)/(d-2*r),v=(o-2*i)/(h-2*i),m=-p*(c+r)+n+r,g=-v*(u+i)+s+i;if(p!==1||v!==1||m!==0||g!==0)for(const{line:b,points:C}of y(this,Po))Lt._rescale(b,m,g,p,v,b),Lt._rescale(C,m,g,p,v,C);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Lt.svgRound(n)} ${Lt.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([n,s],a){const[o,r]=a,i=y(this,Ba),l=n-i[0],c=s-i[1];if(y(this,ki)===o&&y(this,Ei)===r)for(const{line:u,points:d}of y(this,Po))Lt._translate(u,l,c,u),Lt._translate(d,l,c,d);else{const u=y(this,ki)/o,d=y(this,Ei)/r;G(this,ki,o),G(this,Ei,r);for(const{line:h,points:p}of y(this,Po))Lt._rescale(h,l,c,u,d,h),Lt._rescale(p,l,c,u,d,p);i[2]*=u,i[3]*=d}return i[0]=n,i[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Lt.svgRound(n)} ${Lt.svgRound(s)}`}}}get defaultSVGProperties(){const n=y(this,Ba);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Lt.svgRound(n[0])} ${Lt.svgRound(n[1])}`,transform:this.rotationTransform||null},bbox:n}}};Ba=new WeakMap,t2=new WeakMap,n2=new WeakMap,Po=new WeakMap,ki=new WeakMap,Ei=new WeakMap,h0=new WeakMap,p0=new WeakMap,v0=new WeakMap,ta=new WeakSet,ql=function(n=y(this,v0)){const s=y(this,n2)+n/2*y(this,h0);return y(this,p0)%180===0?[s/y(this,ki),s/y(this,Ei)]:[s/y(this,Ei),s/y(this,ki)]},xI=function(){const[n,s,a,o]=y(this,Ba),[r,i]=oe(this,ta,ql).call(this,0);return[n+r,s+i,a-2*r,o-2*i]},kI=function(){const n=G(this,Ba,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:o}of y(this,Po)){if(o.length<=12){for(let l=4,c=o.length;li!==s[l])||n.thickness!==a||n.opacity!==o||n.pageIndex!==r},Ut(g0,"_type","ink"),Ut(g0,"_editorType",dn.INK),Ut(g0,"_defaultDrawingOptions",null);let Aw=g0;const s2=class s2 extends is{constructor(n){super({...n,name:"stampEditor"});ne(this,An);ne(this,cs,null);ne(this,na,null);ne(this,Jc,null);ne(this,Vl,null);ne(this,Zc,null);ne(this,b0,"");ne(this,Ai,null);ne(this,Ti,null);ne(this,Ro,!1);ne(this,y0,!1);G(this,Vl,n.bitmapUrl),G(this,Zc,n.bitmapFile)}static initialize(n,s){is.initialize(n,s)}static get supportedTypes(){return mn(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(s=>`image/${s}`))}static get supportedTypesStr(){return mn(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(n){return this.supportedTypes.includes(n)}static paste(n,s){s.pasteEditor(dn.STAMP,{bitmapFile:n.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var n;return{type:"stamp",hasAltText:!!((n=this.altTextData)!=null&&n.altText)}}static computeTelemetryFinalData(n){const s=n.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(n=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:a}=this._uiManager;if(!a)throw new Error("No ML.");if(!await a.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:o,width:r,height:i}=n||this.copyCanvas(null,null,!0).imageData,l=await a.guess({name:"altText",request:{data:o,width:r,height:i,channels:o.length/(r*i)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const c=l.output;return await this.setGuessedAltText(c),s&&!this.hasAltTextData()&&(this.altTextData={alt:c,decorative:!1}),c}remove(){var n;y(this,na)&&(G(this,cs,null),this._uiManager.imageManager.deleteId(y(this,na)),(n=y(this,Ai))==null||n.remove(),G(this,Ai,null),y(this,Ti)&&(clearTimeout(y(this,Ti)),G(this,Ti,null))),super.remove()}rebuild(){if(!this.parent){y(this,na)&&oe(this,An,u4).call(this);return}super.rebuild(),this.div!==null&&(y(this,na)&&y(this,Ai)===null&&oe(this,An,u4).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(n){this._isDraggable=!0,n&&this.div.focus()}isEmpty(){return!(y(this,Jc)||y(this,cs)||y(this,Vl)||y(this,Zc)||y(this,na))}get isResizable(){return!0}render(){if(this.div)return this.div;let n,s;if(this.width&&(n=this.x,s=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),y(this,cs)?oe(this,An,E_).call(this):oe(this,An,u4).call(this),this.width&&!this.annotationElementId){const[a,o]=this.parentDimensions;this.setAt(n*a,s*o,this.width*a,this.height*o)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;y(this,Ti)!==null&&clearTimeout(y(this,Ti)),G(this,Ti,setTimeout(()=>{G(this,Ti,null),oe(this,An,A_).call(this)},200))}copyCanvas(n,s,a=!1){var p;n||(n=224);const{width:o,height:r}=y(this,cs),i=new ow;let l=y(this,cs),c=o,u=r,d=null;if(s){if(o>s||r>s){const I=Math.min(s/o,s/r);c=Math.floor(o*I),u=Math.floor(r*I)}d=document.createElement("canvas");const v=d.width=Math.ceil(c*i.sx),m=d.height=Math.ceil(u*i.sy);y(this,Ro)||(l=oe(this,An,d4).call(this,v,m));const g=d.getContext("2d");g.filter=this._uiManager.hcmFilter;let b="white",C="#cfcfd8";this._uiManager.hcmFilter!=="none"?C="black":(p=window.matchMedia)!=null&&p.call(window,"(prefers-color-scheme: dark)").matches&&(b="#8f8f9d",C="#42414d");const w=15,_=w*i.sx,x=w*i.sy,k=new OffscreenCanvas(_*2,x*2),T=k.getContext("2d");T.fillStyle=b,T.fillRect(0,0,_*2,x*2),T.fillStyle=C,T.fillRect(0,0,_,x),T.fillRect(_,x,_,x),g.fillStyle=g.createPattern(k,"repeat"),g.fillRect(0,0,v,m),g.drawImage(l,0,0,l.width,l.height,0,0,v,m)}let h=null;if(a){let v,m;if(i.symmetric&&l.widthn||r>n){const C=Math.min(n/o,n/r);v=Math.floor(o*C),m=Math.floor(r*C),y(this,Ro)||(l=oe(this,An,d4).call(this,v,m))}const b=new OffscreenCanvas(v,m).getContext("2d",{willReadFrequently:!0});b.drawImage(l,0,0,l.width,l.height,0,0,v,m),h={width:v,height:m,data:b.getImageData(0,0,v,m).data}}return{canvas:d,width:c,height:u,imageData:h}}getImageForAltText(){return y(this,Ai)}static async deserialize(n,s,a){var m;let o=null;if(n instanceof nR){const{data:{rect:g,rotation:b,id:C,structParent:w,popupRef:_},container:x,parent:{page:{pageNumber:k}}}=n,T=x.querySelector("canvas"),I=a.imageManager.getFromCanvas(x.id,T);T.remove();const O=((m=await s._structTree.getAriaAttributes(`${ew}${C}`))==null?void 0:m.get("aria-label"))||"";o=n={annotationType:dn.STAMP,bitmapId:I.id,bitmap:I.bitmap,pageIndex:k-1,rect:g.slice(0),rotation:b,id:C,deleted:!1,accessibilityData:{decorative:!1,altText:O},isSvg:!1,structParent:w,popupRef:_}}const r=await super.deserialize(n,s,a),{rect:i,bitmap:l,bitmapUrl:c,bitmapId:u,isSvg:d,accessibilityData:h}=n;u&&a.imageManager.isValidId(u)?(G(r,na,u),l&&G(r,cs,l)):G(r,Vl,c),G(r,Ro,d);const[p,v]=r.pageDimensions;return r.width=(i[2]-i[0])/p,r.height=(i[3]-i[1])/v,r.annotationElementId=n.id||null,h&&(r.altTextData=h),r._initialData=o,G(r,y0,!!o),r}serialize(n=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const a={annotationType:dn.STAMP,bitmapId:y(this,na),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:y(this,Ro),structTreeParentId:this._structTreeParentId};if(n)return a.bitmapUrl=oe(this,An,f4).call(this,!0),a.accessibilityData=this.serializeAltText(!0),a;const{decorative:o,altText:r}=this.serializeAltText(!1);if(!o&&r&&(a.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){const l=oe(this,An,TI).call(this,a);if(l.isSame)return null;l.isSameAltText?delete a.accessibilityData:a.accessibilityData.structParent=this._initialData.structParent??-1}if(a.id=this.annotationElementId,s===null)return a;s.stamps||(s.stamps=new Map);const i=y(this,Ro)?(a.rect[2]-a.rect[0])*(a.rect[3]-a.rect[1]):null;if(!s.stamps.has(y(this,na)))s.stamps.set(y(this,na),{area:i,serialized:a}),a.bitmap=oe(this,An,f4).call(this,!1);else if(y(this,Ro)){const l=s.stamps.get(y(this,na));i>l.area&&(l.area=i,l.serialized.bitmap.close(),l.serialized.bitmap=oe(this,An,f4).call(this,!1))}return a}renderAnnotationElement(n){return n.updateEdited({rect:this.getRect(0,0)}),null}};cs=new WeakMap,na=new WeakMap,Jc=new WeakMap,Vl=new WeakMap,Zc=new WeakMap,b0=new WeakMap,Ai=new WeakMap,Ti=new WeakMap,Ro=new WeakMap,y0=new WeakMap,An=new WeakSet,_2=function(n,s=!1){if(!n){this.remove();return}G(this,cs,n.bitmap),s||(G(this,na,n.id),G(this,Ro,n.isSvg)),n.file&&G(this,b0,n.file.name),oe(this,An,E_).call(this)},C2=function(){if(G(this,Jc,null),this._uiManager.enableWaiting(!1),!!y(this,Ai)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&y(this,cs)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&y(this,cs)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},u4=function(){if(y(this,na)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(y(this,na)).then(a=>oe(this,An,_2).call(this,a,!0)).finally(()=>oe(this,An,C2).call(this));return}if(y(this,Vl)){const a=y(this,Vl);G(this,Vl,null),this._uiManager.enableWaiting(!0),G(this,Jc,this._uiManager.imageManager.getFromUrl(a).then(o=>oe(this,An,_2).call(this,o)).finally(()=>oe(this,An,C2).call(this)));return}if(y(this,Zc)){const a=y(this,Zc);G(this,Zc,null),this._uiManager.enableWaiting(!0),G(this,Jc,this._uiManager.imageManager.getFromFile(a).then(o=>oe(this,An,_2).call(this,o)).finally(()=>oe(this,An,C2).call(this)));return}const n=document.createElement("input");n.type="file",n.accept=s2.supportedTypesStr;const s=this._uiManager._signal;G(this,Jc,new Promise(a=>{n.addEventListener("change",async()=>{if(!n.files||n.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const o=await this._uiManager.imageManager.getFromFile(n.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),oe(this,An,_2).call(this,o)}a()},{signal:s}),n.addEventListener("cancel",()=>{this.remove(),a()},{signal:s})}).finally(()=>oe(this,An,C2).call(this))),n.click()},E_=function(){var d;const{div:n}=this;let{width:s,height:a}=y(this,cs);const[o,r]=this.pageDimensions,i=.75;if(this.width)s=this.width*o,a=this.height*r;else if(s>i*o||a>i*r){const h=Math.min(i*o/s,i*r/a);s*=h,a*=h}const[l,c]=this.parentDimensions;this.setDims(s*l/o,a*c/r),this._uiManager.enableWaiting(!1);const u=G(this,Ai,document.createElement("canvas"));u.setAttribute("role","img"),this.addContainer(u),this.width=s/o,this.height=a/r,(d=this._initialOptions)!=null&&d.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(n.hidden=!1),oe(this,An,A_).call(this),y(this,y0)||(this.parent.addUndoableEditor(this),G(this,y0,!0)),this._reportTelemetry({action:"inserted_image"}),y(this,b0)&&u.setAttribute("aria-label",y(this,b0))},d4=function(n,s){const{width:a,height:o}=y(this,cs);let r=a,i=o,l=y(this,cs);for(;r>2*n||i>2*s;){const c=r,u=i;r>2*n&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),i>2*s&&(i=i>=16384?Math.floor(i/2)-1:Math.ceil(i/2));const d=new OffscreenCanvas(r,i);d.getContext("2d").drawImage(l,0,0,c,u,0,0,r,i),l=d.transferToImageBitmap()}return l},A_=function(){const[n,s]=this.parentDimensions,{width:a,height:o}=this,r=new ow,i=Math.ceil(a*n*r.sx),l=Math.ceil(o*s*r.sy),c=y(this,Ai);if(!c||c.width===i&&c.height===l)return;c.width=i,c.height=l;const u=y(this,Ro)?y(this,cs):oe(this,An,d4).call(this,i,l),d=c.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(u,0,0,u.width,u.height,0,0,i,l)},f4=function(n){if(n){if(y(this,Ro)){const o=this._uiManager.imageManager.getSvgUrl(y(this,na));if(o)return o}const s=document.createElement("canvas");return{width:s.width,height:s.height}=y(this,cs),s.getContext("2d").drawImage(y(this,cs),0,0),s.toDataURL()}if(y(this,Ro)){const[s,a]=this.pageDimensions,o=Math.round(this.width*s*Sc.PDF_TO_CSS_UNITS),r=Math.round(this.height*a*Sc.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(o,r);return i.getContext("2d").drawImage(y(this,cs),0,0,y(this,cs).width,y(this,cs).height,0,0,o,r),i.transferToImageBitmap()}return structuredClone(y(this,cs))},TI=function(n){var i;const{pageIndex:s,accessibilityData:{altText:a}}=this._initialData,o=n.pageIndex===s,r=(((i=n.accessibilityData)==null?void 0:i.alt)||"")===a;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&o&&r,isSameAltText:r}},Ut(s2,"_type","stamp"),Ut(s2,"_editorType",dn.STAMP);let Tw=s2;const Fr=class Fr{constructor({uiManager:t,pageIndex:n,div:s,structTreeLayer:a,accessibilityManager:o,annotationLayer:r,drawLayer:i,textLayer:l,viewport:c,l10n:u}){ne(this,as);ne(this,Zd);ne(this,w0,!1);ne(this,Mi,null);ne(this,Qc,null);ne(this,zl,null);ne(this,Qo,new Map);ne(this,eu,!1);ne(this,_0,!1);ne(this,Qd,!1);ne(this,Dr,null);ne(this,Hl,null);ne(this,Ca,null);ne(this,Wl,null);ne(this,Vt);const d=[...y(Fr,tu).values()];if(!Fr._initialized){Fr._initialized=!0;for(const h of d)h.initialize(u,t)}t.registerEditorTypes(d),G(this,Vt,t),this.pageIndex=n,this.div=s,G(this,Zd,o),G(this,Mi,r),this.viewport=c,G(this,Ca,l),this.drawLayer=i,this._structTree=a,y(this,Vt).addLayer(this)}get isEmpty(){return y(this,Qo).size===0}get isInvisible(){return this.isEmpty&&y(this,Vt).getMode()===dn.NONE}updateToolbar(t){y(this,Vt).updateToolbar(t)}updateMode(t=y(this,Vt).getMode()){switch(oe(this,as,h4).call(this),t){case dn.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case dn.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case dn.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:n}=this.div;for(const s of y(Fr,tu).values())n.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var n;return t===((n=y(this,Ca))==null?void 0:n.div)}setEditingState(t){y(this,Vt).setEditingState(t)}addCommands(t){y(this,Vt).addCommands(t)}cleanUndoStack(t){y(this,Vt).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var n;(n=y(this,Mi))==null||n.div.classList.toggle("disabled",!t)}async enable(){G(this,Qd,!0),this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of y(this,Qo).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(y(this,Vt).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!y(this,Mi)){G(this,Qd,!1);return}const n=y(this,Mi).getEditableAnnotations();for(const s of n){if(s.hide(),y(this,Vt).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const a=await this.deserialize(s);a&&(this.addOrRebuild(a),a.enableEditing())}G(this,Qd,!1)}disable(){var a;G(this,_0,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,n=new Map;for(const o of y(this,Qo).values())if(o.disableEditing(),!!o.annotationElementId){if(o.serialize()!==null){t.set(o.annotationElementId,o);continue}else n.set(o.annotationElementId,o);(a=this.getEditableAnnotation(o.annotationElementId))==null||a.show(),o.remove()}if(y(this,Mi)){const o=y(this,Mi).getEditableAnnotations();for(const r of o){const{id:i}=r.data;if(y(this,Vt).isDeletedAnnotationElement(i))continue;let l=n.get(i);if(l){l.resetAnnotationElement(r),l.show(!1),r.show();continue}l=t.get(i),l&&(y(this,Vt).addChangedExistingAnnotation(l),l.renderAnnotationElement(r)&&l.show(!1)),r.show()}}oe(this,as,h4).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const o of y(Fr,tu).values())s.remove(`${o._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),G(this,_0,!1)}getEditableAnnotation(t){var n;return((n=y(this,Mi))==null?void 0:n.getEditableAnnotation(t))||null}setActiveEditor(t){y(this,Vt).getActive()!==t&&y(this,Vt).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=y(this,Ca))!=null&&t.div&&!y(this,Wl)){G(this,Wl,new AbortController);const n=y(this,Vt).combinedSignal(y(this,Wl));y(this,Ca).div.addEventListener("pointerdown",oe(this,as,MI).bind(this),{signal:n}),y(this,Ca).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=y(this,Ca))!=null&&t.div&&y(this,Wl)&&(y(this,Wl).abort(),G(this,Wl,null),y(this,Ca).div.classList.remove("highlighting"))}enableClick(){if(y(this,Qc))return;G(this,Qc,new AbortController);const t=y(this,Vt).combinedSignal(y(this,Qc));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const n=this.pointerup.bind(this);this.div.addEventListener("pointerup",n,{signal:t}),this.div.addEventListener("pointercancel",n,{signal:t})}disableClick(){var t;(t=y(this,Qc))==null||t.abort(),G(this,Qc,null)}attach(t){y(this,Qo).set(t.id,t);const{annotationElementId:n}=t;n&&y(this,Vt).isDeletedAnnotationElement(n)&&y(this,Vt).removeDeletedAnnotationElement(t)}detach(t){var n;y(this,Qo).delete(t.id),(n=y(this,Zd))==null||n.removePointerInTextLayer(t.contentDiv),!y(this,_0)&&t.annotationElementId&&y(this,Vt).addDeletedAnnotationElement(t)}remove(t){this.detach(t),y(this,Vt).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var n;t.parent!==this&&(t.parent&&t.annotationElementId&&(y(this,Vt).addDeletedAnnotationElement(t.annotationElementId),is.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(n=t.parent)==null||n.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),y(this,Vt).addEditor(t),this.attach(t),!t.isAttachedToDOM){const n=t.render();this.div.append(n),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!y(this,Qd)),y(this,Vt).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:n}=document;t.div.contains(n)&&!y(this,zl)&&(t._focusEventsAllowed=!1,G(this,zl,setTimeout(()=>{G(this,zl,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:y(this,Vt)._signal}),n.focus())},0))),t._structTreeParentId=(s=y(this,Zd))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const n=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:n,undo:s,mustExec:!1})}getNextId(){return y(this,Vt).getId()}combinedSignal(t){return y(this,Vt).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=y(this,as,Oi))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,n){y(this,Vt).updateToolbar(t),y(this,Vt).updateMode(t);const{offsetX:s,offsetY:a}=oe(this,as,M_).call(this),o=this.getNextId(),r=oe(this,as,T_).call(this,{parent:this,id:o,x:s,y:a,uiManager:y(this,Vt),isCentered:!0,...n});r&&this.add(r)}async deserialize(t){var n;return await((n=y(Fr,tu).get(t.annotationType??t.annotationEditorType))==null?void 0:n.deserialize(t,this,y(this,Vt)))||null}createAndAddNewEditor(t,n,s={}){const a=this.getNextId(),o=oe(this,as,T_).call(this,{parent:this,id:a,x:t.offsetX,y:t.offsetY,uiManager:y(this,Vt),isCentered:n,...s});return o&&this.add(o),o}addNewEditor(){this.createAndAddNewEditor(oe(this,as,M_).call(this),!0)}setSelected(t){y(this,Vt).setSelected(t)}toggleSelected(t){y(this,Vt).toggleSelected(t)}unselect(t){y(this,Vt).unselect(t)}pointerup(t){var s;const{isMac:n}=La.platform;if(!(t.button!==0||t.ctrlKey&&n)&&t.target===this.div&&y(this,eu)&&(G(this,eu,!1),!((s=y(this,as,Oi))!=null&&s.isDrawer&&y(this,as,Oi).supportMultipleDrawings))){if(!y(this,w0)){G(this,w0,!0);return}if(y(this,Vt).getMode()===dn.STAMP){y(this,Vt).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){var a;if(y(this,Vt).getMode()===dn.HIGHLIGHT&&this.enableTextSelection(),y(this,eu)){G(this,eu,!1);return}const{isMac:n}=La.platform;if(t.button!==0||t.ctrlKey&&n||t.target!==this.div)return;if(G(this,eu,!0),(a=y(this,as,Oi))!=null&&a.isDrawer){this.startDrawingSession(t);return}const s=y(this,Vt).getActive();G(this,w0,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus(),y(this,Dr)){y(this,as,Oi).startDrawing(this,y(this,Vt),!1,t);return}y(this,Vt).setCurrentDrawingSession(this),G(this,Dr,new AbortController);const n=y(this,Vt).combinedSignal(y(this,Dr));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(G(this,Hl,null),this.commitOrRemove())},{signal:n}),y(this,as,Oi).startDrawing(this,y(this,Vt),!1,t)}pause(t){if(t){const{activeElement:n}=document;this.div.contains(n)&&G(this,Hl,n);return}y(this,Hl)&&setTimeout(()=>{var n;(n=y(this,Hl))==null||n.focus(),G(this,Hl,null)},0)}endDrawingSession(t=!1){return y(this,Dr)?(y(this,Vt).setCurrentDrawingSession(null),y(this,Dr).abort(),G(this,Dr,null),G(this,Hl,null),y(this,as,Oi).endDrawing(t)):null}findNewParent(t,n,s){const a=y(this,Vt).findParent(n,s);return a===null||a===this?!1:(a.changeParent(t),!0)}commitOrRemove(){return y(this,Dr)?(this.endDrawingSession(),!0):!1}onScaleChanging(){y(this,Dr)&&y(this,as,Oi).onScaleChangingWhenDrawing(this)}destroy(){var t,n;this.commitOrRemove(),((t=y(this,Vt).getActive())==null?void 0:t.parent)===this&&(y(this,Vt).commitOrRemove(),y(this,Vt).setActiveEditor(null)),y(this,zl)&&(clearTimeout(y(this,zl)),G(this,zl,null));for(const s of y(this,Qo).values())(n=y(this,Zd))==null||n.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,y(this,Qo).clear(),y(this,Vt).removeLayer(this)}render({viewport:t}){this.viewport=t,ju(this.div,t);for(const n of y(this,Vt).getEditors(this.pageIndex))this.add(n),n.rebuild();this.updateMode()}update({viewport:t}){y(this,Vt).commitOrRemove(),oe(this,as,h4).call(this);const n=this.viewport.rotation,s=t.rotation;if(this.viewport=t,ju(this.div,{rotation:s}),n!==s)for(const a of y(this,Qo).values())a.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:n}=this.viewport.rawDims;return[t,n]}get scale(){return y(this,Vt).viewParameters.realScale}};Zd=new WeakMap,w0=new WeakMap,Mi=new WeakMap,Qc=new WeakMap,zl=new WeakMap,Qo=new WeakMap,eu=new WeakMap,_0=new WeakMap,Qd=new WeakMap,Dr=new WeakMap,Hl=new WeakMap,Ca=new WeakMap,Wl=new WeakMap,Vt=new WeakMap,tu=new WeakMap,as=new WeakSet,MI=function(t){y(this,Vt).unselectAll();const{target:n}=t;if(n===y(this,Ca).div||(n.getAttribute("role")==="img"||n.classList.contains("endOfContent"))&&y(this,Ca).div.contains(n)){const{isMac:s}=La.platform;if(t.button!==0||t.ctrlKey&&s)return;y(this,Vt).showAllEditors("highlight",!0,!0),y(this,Ca).div.classList.add("free"),this.toggleDrawing(),mb.startHighlighting(this,y(this,Vt).direction==="ltr",{target:y(this,Ca).div,x:t.x,y:t.y}),y(this,Ca).div.addEventListener("pointerup",()=>{y(this,Ca).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:y(this,Vt)._signal}),t.preventDefault()}},Oi=function(){return y(Fr,tu).get(y(this,Vt).getMode())},T_=function(t){const n=y(this,as,Oi);return n?new n.prototype.constructor(t):null},M_=function(){const{x:t,y:n,width:s,height:a}=this.div.getBoundingClientRect(),o=Math.max(0,t),r=Math.max(0,n),i=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,n+a),c=(o+i)/2-t,u=(r+l)/2-n,[d,h]=this.viewport.rotation%180===0?[c,u]:[u,c];return{offsetX:d,offsetY:h}},h4=function(){for(const t of y(this,Qo).values())t.isEmpty()&&t.remove()},Ut(Fr,"_initialized",!1),ne(Fr,tu,new Map([Cw,Aw,Tw,mb].map(t=>[t._editorType,t])));let Mw=Fr;const Sa=class Sa{constructor({pageIndex:t}){ne(this,Pi);ne(this,Br,null);ne(this,a2,0);ne(this,Va,new Map);ne(this,ef,new Map);this.pageIndex=t}setParent(t){if(!y(this,Br)){G(this,Br,t);return}if(y(this,Br)!==t){if(y(this,Va).size>0)for(const n of y(this,Va).values())n.remove(),t.append(n);G(this,Br,t)}}static get _svgFactory(){return mn(this,"_svgFactory",new yw)}draw(t,n=!1,s=!1){const a=za(this,a2)._++,o=oe(this,Pi,P_).call(this),r=Sa._svgFactory.createElement("defs");o.append(r);const i=Sa._svgFactory.createElement("path");r.append(i);const l=`path_p${this.pageIndex}_${a}`;i.setAttribute("id",l),i.setAttribute("vector-effect","non-scaling-stroke"),n&&y(this,ef).set(a,i);const c=s?oe(this,Pi,RI).call(this,r,l):null,u=Sa._svgFactory.createElement("use");return o.append(u),u.setAttribute("href",`#${l}`),this.updateProperties(o,t),y(this,Va).set(a,o),{id:a,clipPathId:`url(#${c})`}}drawOutline(t,n){const s=za(this,a2)._++,a=oe(this,Pi,P_).call(this),o=Sa._svgFactory.createElement("defs");a.append(o);const r=Sa._svgFactory.createElement("path");o.append(r);const i=`path_p${this.pageIndex}_${s}`;r.setAttribute("id",i),r.setAttribute("vector-effect","non-scaling-stroke");let l;if(n){const d=Sa._svgFactory.createElement("mask");o.append(d),l=`mask_p${this.pageIndex}_${s}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const h=Sa._svgFactory.createElement("rect");d.append(h),h.setAttribute("width","1"),h.setAttribute("height","1"),h.setAttribute("fill","white");const p=Sa._svgFactory.createElement("use");d.append(p),p.setAttribute("href",`#${i}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}const c=Sa._svgFactory.createElement("use");a.append(c),c.setAttribute("href",`#${i}`),l&&c.setAttribute("mask",`url(#${l})`);const u=c.cloneNode();return a.append(u),c.classList.add("mainOutline"),u.classList.add("secondaryOutline"),this.updateProperties(a,t),y(this,Va).set(s,a),s}finalizeDraw(t,n){y(this,ef).delete(t),this.updateProperties(t,n)}updateProperties(t,n){var l;if(!n)return;const{root:s,bbox:a,rootClass:o,path:r}=n,i=typeof t=="number"?y(this,Va).get(t):t;if(i){if(s&&oe(this,Pi,R_).call(this,i,s),a&&oe(l=Sa,Db,PI).call(l,i,a),o){const{classList:c}=i;for(const[u,d]of Object.entries(o))c.toggle(u,d)}if(r){const u=i.firstChild.firstChild;oe(this,Pi,R_).call(this,u,r)}}}updateParent(t,n){if(n===this)return;const s=y(this,Va).get(t);s&&(y(n,Br).append(s),y(this,Va).delete(t),y(n,Va).set(t,s))}remove(t){y(this,ef).delete(t),y(this,Br)!==null&&(y(this,Va).get(t).remove(),y(this,Va).delete(t))}destroy(){G(this,Br,null);for(const t of y(this,Va).values())t.remove();y(this,Va).clear(),y(this,ef).clear()}};Br=new WeakMap,a2=new WeakMap,Va=new WeakMap,ef=new WeakMap,Db=new WeakSet,PI=function(t,[n,s,a,o]){const{style:r}=t;r.top=`${100*s}%`,r.left=`${100*n}%`,r.width=`${100*a}%`,r.height=`${100*o}%`},Pi=new WeakSet,P_=function(){const t=Sa._svgFactory.create(1,1,!0);return y(this,Br).append(t),t.setAttribute("aria-hidden",!0),t},RI=function(t,n){const s=Sa._svgFactory.createElement("clipPath");t.append(s);const a=`clip_${n}`;s.setAttribute("id",a),s.setAttribute("clipPathUnits","objectBoundingBox");const o=Sa._svgFactory.createElement("use");return s.append(o),o.setAttribute("href",`#${n}`),o.classList.add("clip"),a},R_=function(t,n){for(const[s,a]of Object.entries(n))a===null?t.removeAttribute(s):t.setAttribute(s,a)},ne(Sa,Db);let Pw=Sa;globalThis.pdfjsTestingUtils={HighlightOutliner:Sw},nn.AbortException,nn.AnnotationEditorLayer,nn.AnnotationEditorParamsType,nn.AnnotationEditorType,nn.AnnotationEditorUIManager,nn.AnnotationLayer,nn.AnnotationMode,nn.ColorPicker,nn.DOMSVGFactory,nn.DrawLayer,nn.FeatureTest;var V4e=nn.GlobalWorkerOptions;nn.ImageKind,nn.InvalidPDFException,nn.MissingPDFException,nn.OPS,nn.OutputScale,nn.PDFDataRangeTransport,nn.PDFDateString,nn.PDFWorker,nn.PasswordResponses,nn.PermissionFlag,nn.PixelsPerInch,nn.RenderingCancelledException,nn.TextLayer,nn.TouchManager,nn.UnexpectedResponseException,nn.Util,nn.VerbosityLevel,nn.XfaLayer,nn.build,nn.createValidAbsoluteUrl,nn.fetchData;var z4e=nn.getDocument;nn.getFilenameFromUrl,nn.getPdfFilenameFromUrl,nn.getXfaPageViewport,nn.isDataScheme,nn.isPdfFile,nn.noContextMenu,nn.normalizeUnicode,nn.setLayerDimensions,nn.shadow,nn.stopEvent,nn.version;const H4e=""+new URL("assets/pdf.worker.min-yatZIOMy.mjs",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href,W4e={class:"manual-wrap"},j4e={class:"sidebar"},K4e={class:"es-text",style:{display:"none"}},U4e={class:"sb-section"},q4e={class:"sb-title"},G4e={key:0,class:"sb-section sb-range-row"},Y4e={class:"range-check"},X4e={class:"range-inline"},J4e=["max","disabled"],Z4e=["min","max"],Q4e={key:1,class:"sb-section"},eye={class:"sb-title"},tye={style:{display:"flex",gap:"6px"}},nye={key:2,class:"sb-section"},sye={class:"mode-inline-row"},aye={class:"sb-title mode-inline-title"},oye={class:"mode-inline-check"},rye={key:3,class:"sb-section"},iye={class:"sb-title"},lye={class:"region-type-btns"},cye=["onClick"],uye={class:"rt-badge"},dye={key:4,class:"sb-section sb-regions"},fye={class:"sb-title"},hye={class:"region-list"},pye=["onClick"],vye={class:"ri-top"},mye={class:"ri-badge"},gye={class:"ri-label"},bye={class:"ri-page"},yye={class:"ri-status"},wye={key:0,class:"ri-tokens"},_ye={key:0,class:"ri-preview"},Cye={key:5,class:"sb-section sb-actions"},Sye={key:0,class:"vl-progress-wrap"},xye={class:"vl-progress-label"},kye={key:0},Eye={key:1,class:"vl-done"},Aye={key:6,class:"sb-section sb-export"},Tye={class:"sb-title"},Mye={style:{display:"flex",gap:"8px"}},Pye={class:"sb-footer"},Rye={class:"viewer"},Iye={key:0,class:"viewer-nav"},Oye={class:"el-button-group"},Lye={class:"nav-label"},Nye={class:"nav-type-indicator"},$ye={class:"el-button-group el-button-group--small"},Dye={class:"zoom-bar"},Fye={class:"zoom-pct"},Bye={key:1,class:"viewer-empty"},Vye={class:"img-inner"},zye={key:0,class:"page-loading"},Hye=["data-mode"],Wye={key:0,class:"result-panel"},jye={class:"rp-header"},Kye={class:"rp-title"},Uye={key:0,class:"rp-tokens"},qye={class:"rp-text"},aR="ocrz_region_presets",Gye=[{path:"/",redirect:"/Manual"},{path:"/Auto",component:V1e},{path:"/Manual",component:cl({__name:"ManualOCR",setup(e){V4e.workerSrc=H4e;const t=lP(),n="http://47.104.102.122:8000";function s(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,me=>{const he=typeof crypto<"u"&&crypto.getRandomValues?crypto.getRandomValues(new Uint8Array(1)):null,Re=he?(he[0]&255)%16:Math.random()*16|0;return(me==="x"?Re:Re&3|8).toString(16)})}const a=[{name:"陕化建图纸识别",data:[{type:"A",page:0,xr:.6780016792611251,yr:.0344418052256532,wr:.3140218303946264,hr:.6033254156769596},{type:"B",page:0,xr:.28337531486146095,yr:.7838479809976246,wr:.26448362720403024,hr:.19596199524940616},{type:"C",page:0,xr:.9147774979009236,yr:.8931116389548693,wr:.022670025188916875,hr:.021377672209026127},{type:"C",page:0,xr:.9534005037783375,yr:.8978622327790974,wr:.026028547439126783,hr:.023752969121140142},{type:"C",page:0,xr:.7619647355163728,yr:.7921615201900237,wr:.16960537363560033,hr:.026128266033254157},{type:"D",page:0,xr:.6788413098236776,yr:.6520190023752969,wr:.3089840470193115,hr:.08432304038004751}]}];function o(){const me=JSON.parse(localStorage.getItem(aR)||"[]"),he=[...a];for(const Re of me){const it=he.findIndex(qe=>qe.name===Re.name);it>=0?he[it]=Re:he.push(Re)}return he}const r=F(o()),i=F("");function l(){const me=window.prompt("请输入预设名称:",i.value||"");if(!me||!me.trim())return;const he=me.trim(),Re=M.value.map(qe=>({type:qe.type,page:qe.page,xr:qe.xr,yr:qe.yr,wr:qe.wr,hr:qe.hr,region_code:qe.region_code||""})),it=r.value.findIndex(qe=>qe.name===he);it>=0?r.value[it]={name:he,data:Re}:r.value.push({name:he,data:Re}),localStorage.setItem(aR,JSON.stringify(r.value)),i.value=he,ts.success(`预设「${he}」已保存(${Re.length} 个区域)`)}function c(){const me=r.value.find(ft=>ft.name===i.value);if(!me)return;const he=Array.isArray(me.data)?me.data:[];if(!he.length){ts.warning(`预设「${me.name}」没有可用区域`);return}const Re=[...new Set(he.map(ft=>Number.isFinite(ft.page)?ft.page:0))].sort((ft,ke)=>ft-ke),it=Re.length?Re[0]:0,qe=k.value-it;let lt=[];if(T.value&&x.value>0&&Re.length===1)for(let ft=k.value;ft0?lt=he.map(ft=>({...ft,page:(Number.isFinite(ft.page)?ft.page:0)+qe})).filter(ft=>ft.page>=0&&ft.page({...ft,page:Number.isFinite(ft.page)?ft.page:0}));const vt=new Map,Ft=ft=>{vt.has(ft)||vt.set(ft,new Set);const ke=vt.get(ft);let tt=1;for(;ke.has(`C${tt}`);)tt+=1;const Ne=`C${tt}`;return ke.add(Ne),Ne};M.value=lt.map(ft=>{const ke=Number.isFinite(ft.page)?ft.page:0,tt={...ft,page:ke,id:s(),status:"pending",text:null,tokens:null};return tt.type==="C"&&(tt.region_code?(vt.has(ke)||vt.set(ke,new Set),vt.get(ke).add(tt.region_code)):tt.region_code=Ft(ke)),tt}),B.value=null,ze(()=>ot()),ts.success(`已载入预设「${me.name}」(${M.value.length} 个区域)`)}const u=[{key:"A",label:"材料区域",color:"#2563eb"},{key:"B",label:"图纸信息",color:"#d97706"},{key:"C",label:"其他",color:"#059669"},{key:"D",label:"管长表",color:"#7c3aed"}],d=me=>{var he;return((he=u.find(Re=>Re.key===me))==null?void 0:he.color)??"#6b7280"},h=me=>{var he;return((he=u.find(Re=>Re.key===me))==null?void 0:he.label)??me};function p(me){if(!me)return"";if(me.type!=="C")return me.type;if(me.region_code)return me.region_code;const Re=M.value.filter(it=>it.type==="C").findIndex(it=>it.id===me.id);return Re>=0?`C${Re+1}`:"C"}function v(me){return me?me.type==="C"?`${p(me)} ${h(me.type)}`:h(me.type):""}function m(me){if(me!=="C")return"";const he=new Set(M.value.filter(it=>it.type==="C"&&it.region_code).map(it=>it.region_code));let Re=1;for(;he.has(`C${Re}`);)Re+=1;return`C${Re}`}const g=F("file"),b=F(null),C=F(""),w=F(!1),_=F(""),x=F(0),k=F(0),T=F(!1),I=bn(null),O=F(!1);let R=null;const $=F("A"),M=F([]),B=F(null),U=F(!0),J=F(!1),Y=F(""),L=F(!1),N=F(0),V=F(0),z=F(!0),q=F(1),Q=F(1),K=F(null),ee=F(null),se=F(null),pe=F(null),te=[.25,.5,.75,1,1.25,1.5,2,3],fe=F(1);function ve(){const me=te.find(he=>he>fe.value+.01);me&&(fe.value=me)}function ce(){const me=[...te].reverse().find(he=>heg.value==="file"?!!b.value:C.value.startsWith("http")),We=E(()=>M.value.filter(me=>me.status==="pending").length),nt=E(()=>M.value.filter(me=>me.status==="recognizing").length),dt=E(()=>M.value.filter(me=>me.type==="A"&&me.status==="pending").length),Fe=E(()=>M.value.filter(me=>me.status==="done")),Be=E(()=>M.value.find(me=>me.id===B.value)||null),et=E(()=>N.value>0?Math.round(V.value/N.value*100):0);be([z,k],()=>{z.value&&(q.value=k.value+1)}),be(x,me=>{me>0&&(Q.value=me),z.value&&(q.value=k.value+1)}),be(q,me=>{const he=Q.value;me<1?q.value=1:me>he&&(q.value=he)}),be(Q,me=>{const he=x.value||1;mehe&&(Q.value=he)});function Wt(me,he){if(!Array.isArray(me)||!me.length)return[];const Re=Math.max(0,(he||1)-1);return me.map(it=>{const qe=Number.isFinite(it.page)?Math.min(Math.max(it.page,0),Re):0;return{id:it.id||s(),type:it.type,page:qe,xr:it.xr,yr:it.yr,wr:it.wr,hr:it.hr,status:"pending",text:"",boxes:[],tokens:null,rows:[],parts1:{},b_table_rows:[],d_rows:[]}})}let qt=null;Pt(async()=>{try{const Re=await(await fetch(`${n}/api/manual/engine-info`)).json();H.value=Re.status==="ready"?"ready":"error",ae.value=Re.error||Re.engine||""}catch(he){H.value="error",ae.value=he.message}const me=document.getElementById("hdpdfurl2");if(me&&me.value&&me.value.trim()&&(C.value=me.value.trim(),g.value="url",await gt()),me){let he=me.value;qt=setInterval(async()=>{const Re=me.value?me.value.trim():"";Re&&Re!==he&&(he=Re,C.value=Re,g.value="url",await gt())},2e3)}});async function ct(me){b.value=me.raw,await gt(),pe.value&&pe.value.clearFiles()}async function gt(){w.value=!0;const me=M.value.map(Re=>({id:Re.id,type:Re.type,page:Re.page,xr:Re.xr,yr:Re.yr,wr:Re.wr,hr:Re.hr})),he=B.value;try{let Re,it=null;if(g.value==="file"){it=await b.value.arrayBuffer();const lt=new FormData;lt.append("file",b.value),lt.append("is_shj",U.value?"true":"false"),Re=await fetch(`${n}/api/manual/upload`,{method:"POST",body:lt})}else Re=await fetch(`${n}/api/manual/upload-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:C.value.trim(),is_shj:!!U.value})});if(!Re.ok){const lt=await Re.json().catch(()=>({}));throw new Error(lt.detail||`HTTP ${Re.status}`)}const qe=await Re.json();if(_.value&&fetch(`${n}/api/manual/session/${_.value}`,{method:"DELETE"}).catch(()=>{}),_.value=qe.session_id,x.value=qe.total_pages,k.value=0,M.value=Wt(me,qe.total_pages),B.value=M.value.some(lt=>lt.id===he)?he:null,T.value=!0,fe.value=1,!it){const lt=await fetch(`${n}/api/manual/pdf/${qe.session_id}`);if(!lt.ok)throw new Error(`获取 PDF 字节失败 HTTP ${lt.status}`);it=await lt.arrayBuffer()}await xe(it),ts.success(`PDF 加载成功,共 ${qe.total_pages} 页`)}catch(Re){ts.error(`加载失败:${Re.message}`)}finally{w.value=!1}}function Ot(me){me<0||me>=x.value||(k.value=me)}be(k,me=>{rt(),Ue(me)}),be([k,M],async()=>{T.value&&(await ze(),ot())},{deep:!0}),be(De,me=>{me==="draw"&&ee.value&&(ee.value.style.cursor="")}),be(fe,()=>{T.value&&I.value&&Ue(k.value)});async function xe(me){try{const he=z4e({data:me,cMapUrl:"/pdfjs-cmaps/",cMapPacked:!0});I.value=await he.promise,Ue(0)}catch(he){ts.error(`PDF.js 加载失败:${he.message}`)}}async function Ue(me){if(I.value){R&&(R.cancel(),R=null),O.value=!0;try{const he=await I.value.getPage(me+1),Re=window.devicePixelRatio||1,it=he.getViewport({scale:fe.value*Re}),qe=se.value;qe.width=it.width,qe.height=it.height,qe.style.width=it.width/Re+"px",qe.style.height=it.height/Re+"px";const lt=qe.getContext("2d");R=he.render({canvasContext:lt,viewport:it}),await R.promise,R=null,Ye()}catch(he){(he==null?void 0:he.name)!=="RenderingCancelledException"&&ts.error(`页面渲染失败:${he.message}`)}finally{O.value=!1}}}let we=null;function Ye(){const me=se.value,he=ee.value;if(!me||!he)return;const Re=me.offsetWidth,it=me.offsetHeight;Re===0||it===0||((he.width!==Re||he.height!==it)&&(he.width=Re,he.height=it),ot(),we||(we=new ResizeObserver(()=>Ye())),we.disconnect(),we.observe(me))}window.addEventListener("resize",()=>{T.value&&Ye()});function At(me){const he=ee.value.getBoundingClientRect();return{x:me.clientX-he.left,y:me.clientY-he.top}}function Jt(me){$e.value&&(K.value.scrollLeft=Ce.value-me.clientX,K.value.scrollTop=Oe.value-me.clientY)}function Cn(){$e.value&&($e.value=!1,ee.value&&(ee.value.style.cursor=""),window.removeEventListener("mousemove",Jt),window.removeEventListener("mouseup",Cn))}function xn(me){if(!de.value)return;const{x:he,y:Re}=At(me);Se.value=he,Le.value=Re,ot()}function Ve(me){if(!de.value)return;const{x:he,y:Re}=At(me);de.value=!1,window.removeEventListener("mousemove",xn),window.removeEventListener("mouseup",Ve);const it=ee.value,qe=it.width,lt=it.height,vt=Ii=>Math.max(0,Math.min(qe,Ii)),Ft=Ii=>Math.max(0,Math.min(lt,Ii)),ft=vt(he),ke=Ft(Re),tt=vt(ye.value),Ne=Ft(_e.value),St=Math.min(tt,ft),qn=Math.min(Ne,ke),Zn=Math.abs(ft-tt),Ri=Math.abs(ke-Ne);Zn>8&&Ri>8&&M.value.push({id:s(),type:$.value,region_code:m($.value),page:k.value,xr:St/qe,yr:qn/lt,wr:Zn/qe,hr:Ri/lt,cx:St,cy:qn,cw:Zn,ch:Ri,status:"pending",text:"",boxes:[],tokens:null,rows:[],parts1:{},b_table_rows:[],d_rows:[]}),rt(),ot()}function st(me){me.preventDefault();const{x:he,y:Re}=At(me);De.value==="draw"?(de.value=!0,ye.value=he,_e.value=Re,Se.value=he,Le.value=Re,window.addEventListener("mousemove",xn),window.addEventListener("mouseup",Ve)):De.value==="pan"&&($e.value=!0,Ce.value=me.clientX+K.value.scrollLeft,Oe.value=me.clientY+K.value.scrollTop,ee.value.style.cursor="grabbing",window.addEventListener("mousemove",Jt),window.addEventListener("mouseup",Cn))}function _t(me){}function kn(me){}function Zt(){}function rt(){de.value=!1,ye.value=0,_e.value=0,Se.value=0,Le.value=0}function ot(){const me=ee.value;if(!me)return;const he=me.getContext("2d");he.clearRect(0,0,me.width,me.height);const Re=me.width,it=me.height;for(const qe of M.value){if(qe.page!==k.value)continue;const lt=qe.xr*Re,vt=qe.yr*it,Ft=qe.wr*Re,ft=qe.hr*it,ke=d(qe.type),tt=qe.id===B.value;he.strokeStyle=ke,he.lineWidth=tt?3:2,he.setLineDash(qe.status==="pending"?[5,3]:[]),he.strokeRect(lt,vt,Ft,ft),he.fillStyle=ke+"18",he.fillRect(lt,vt,Ft,ft);const Ne=qe.type==="C"?`${p(qe)} ${h(qe.type)}`:`${qe.type} ${h(qe.type)}`;he.font="bold 12px sans-serif";const St=he.measureText(Ne).width+10;he.fillStyle=ke,he.fillRect(lt,vt-18,St,18),he.fillStyle="#fff",he.fillText(Ne,lt+5,vt-4)}if(de.value){const qe=Math.min(ye.value,Se.value),lt=Math.min(_e.value,Le.value),vt=Math.abs(Se.value-ye.value),Ft=Math.abs(Le.value-_e.value),ft=d($.value);he.strokeStyle=ft,he.lineWidth=2,he.setLineDash([4,3]),he.strokeRect(qe,lt,vt,Ft),he.fillStyle=ft+"15",he.fillRect(qe,lt,vt,Ft)}}function Rt(me){B.value=me.id,me.page!==k.value?Ot(me.page):ot()}function Es(me){M.value=M.value.filter(he=>he.id!==me),B.value===me&&(B.value=null),ot()}function sa(){M.value=[],B.value=null,ot()}async function Io(){var vt;const me=M.value.find(Ft=>Ft.type==="A");if(!me)return;M.value.filter(Ft=>Ft.type==="A"&&Ft.status==="pending").forEach(Ft=>{Ft.status="recognizing"});const he=q.value-1,Re=Q.value-1,it=Re-he+1;L.value=!0,N.value=it,V.value=0;const qe=Math.max(800,Math.round(3500*Math.ceil(it/10)/it)),lt=setInterval(()=>{V.value({}));throw new Error(Ne.detail||`HTTP ${Ft.status}`)}const ft=await Ft.json();V.value=N.value;const ke=(vt=ft.usage)!=null&&vt.total_tokens?Math.round(ft.usage.total_tokens/(ft.total_pages||1)):null;for(const Ne of ft.results){let St=M.value.find(Zn=>Zn.type==="A"&&Zn.page===Ne.page_index);St||(St={id:s(),type:"A",page:Ne.page_index,xr:me.xr,yr:me.yr,wr:me.wr,hr:me.hr,cx:me.cx,cy:me.cy,cw:me.cw,ch:me.ch,status:"pending",text:"",boxes:[],tokens:null,rows:[],b_table_rows:[]},M.value.push(St));const qn=Ne.rows||[];St.rows=qn,St.tokens=ke,St.text=qn.length?qn.map(Zn=>[Zn.seq_no??"",Zn.category??"",Zn.description??"",Zn.nominal_dia_mm??"",Zn.qty??""].filter(Ii=>Ii!=="").join(" | ")).join(` +`)){const s=document.createElement("div");s.append(n?document.createTextNode(n):document.createElement("br")),this.editorDiv.append(s)}},tI=function(){return y(this,xo).replaceAll(" "," ")},m_=function(n){return n.replaceAll(" "," ")},nI=function(n){const{value:s,fontSize:a,color:o,pageIndex:r}=this._initialData;return this._hasBeenMoved||n.value!==s||n.fontSize!==a||n.color.some((i,l)=>i!==o[l])||n.pageIndex!==r},ne(Un,Nl),Ut(Un,"_freeTextDefaultContent",""),Ut(Un,"_internalPadding",0),Ut(Un,"_defaultColor",null),Ut(Un,"_defaultFontSize",10),Ut(Un,"_type","freetext"),Ut(Un,"_editorType",dn.FREETEXT);let Cw=Un;class Lt{toSVGPath(){Hn("Abstract method `toSVGPath` must be implemented.")}get box(){Hn("Abstract getter `box` must be implemented.")}serialize(t,n){Hn("Abstract method `serialize` must be implemented.")}static _rescale(t,n,s,a,o,r){r||(r=new Float32Array(t.length));for(let i=0,l=t.length;i=6;a-=6)isNaN(n[a])?s.push(`L${n[a+4]} ${n[a+5]}`):s.push(`C${n[a]} ${n[a+1]} ${n[a+2]} ${n[a+3]} ${n[a+4]} ${n[a+5]}`);return oe(this,Ns,aI).call(this,s),s.join(" ")}newFreeDrawOutline(t,n,s,a,o,r){return new sR(t,n,s,a,o,r)}getOutlines(){var d;const t=y(this,Si),n=y(this,Or),s=y(this,gn),[a,o,r,i]=y(this,Eo),l=new Float32Array((((d=y(this,Kc))==null?void 0:d.length)??0)+2);for(let h=0,p=l.length-2;h=6;h-=6)for(let p=0;p<6;p+=2){if(isNaN(n[h+p])){c[u]=c[u+1]=NaN,u+=2;continue}c[u]=n[h+p],c[u+1]=n[h+p+1],u+=2}return oe(this,Ns,iI).call(this,c,u),this.newFreeDrawOutline(c,l,y(this,Eo),y(this,Qh),y(this,Jh),y(this,Zh))}};Eo=new WeakMap,Or=new WeakMap,Jh=new WeakMap,Zh=new WeakMap,Si=new WeakMap,gn=new WeakMap,Fd=new WeakMap,Bd=new WeakMap,Bm=new WeakMap,Vm=new WeakMap,Qh=new WeakMap,e0=new WeakMap,Kc=new WeakMap,zm=new WeakMap,Ob=new WeakMap,Lb=new WeakMap,Ns=new WeakSet,g2=function(){const t=y(this,gn).subarray(4,6),n=y(this,gn).subarray(16,18),[s,a,o,r]=y(this,Eo);return[(y(this,Fd)+(t[0]-n[0])/2-s)/o,(y(this,Bd)+(t[1]-n[1])/2-a)/r,(y(this,Fd)+(n[0]-t[0])/2-s)/o,(y(this,Bd)+(n[1]-t[1])/2-a)/r]},sI=function(){const[t,n,s,a]=y(this,Eo),[o,r,i,l]=oe(this,Ns,g2).call(this);return`M${(y(this,gn)[2]-t)/s} ${(y(this,gn)[3]-n)/a} L${(y(this,gn)[4]-t)/s} ${(y(this,gn)[5]-n)/a} L${o} ${r} L${i} ${l} L${(y(this,gn)[16]-t)/s} ${(y(this,gn)[17]-n)/a} L${(y(this,gn)[14]-t)/s} ${(y(this,gn)[15]-n)/a} Z`},aI=function(t){const n=y(this,Or);t.push(`L${n[4]} ${n[5]} Z`)},oI=function(t){const[n,s,a,o]=y(this,Eo),r=y(this,gn).subarray(4,6),i=y(this,gn).subarray(16,18),[l,c,u,d]=oe(this,Ns,g2).call(this);t.push(`L${(r[0]-n)/a} ${(r[1]-s)/o} L${l} ${c} L${u} ${d} L${(i[0]-n)/a} ${(i[1]-s)/o}`)},rI=function(t){const n=y(this,gn),[s,a,o,r]=y(this,Eo),[i,l,c,u]=oe(this,Ns,g2).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(n[2]-s)/o,(n[3]-a)/r,NaN,NaN,NaN,NaN,(n[4]-s)/o,(n[5]-a)/r,NaN,NaN,NaN,NaN,i,l,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,(n[16]-s)/o,(n[17]-a)/r,NaN,NaN,NaN,NaN,(n[14]-s)/o,(n[15]-a)/r],0),this.newFreeDrawOutline(d,t,y(this,Eo),y(this,Qh),y(this,Jh),y(this,Zh))},iI=function(t,n){const s=y(this,Or);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],n),n+=6},lI=function(t,n){const s=y(this,gn).subarray(4,6),a=y(this,gn).subarray(16,18),[o,r,i,l]=y(this,Eo),[c,u,d,h]=oe(this,Ns,g2).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-o)/i,(s[1]-r)/l,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,d,h,NaN,NaN,NaN,NaN,(a[0]-o)/i,(a[1]-r)/l],n),n+=24},ne($l,zm,8),ne($l,Ob,2),ne($l,Lb,y($l,zm)+y($l,Ob));let pb=$l;class sR extends Lt{constructor(n,s,a,o,r,i){super();ne(this,Nb);ne(this,t0);ne(this,Vd,new Float32Array(4));ne(this,Dl);ne(this,Hm);ne(this,Ao);ne(this,Wm);ne(this,gs);G(this,gs,n),G(this,Ao,s),G(this,t0,a),G(this,Wm,o),G(this,Dl,r),G(this,Hm,i),this.lastPoint=[NaN,NaN],oe(this,Nb,cI).call(this,i);const[l,c,u,d]=y(this,Vd);for(let h=0,p=n.length;hn[0]-s[0]||n[1]-s[1]||n[2]-s[2]);const t=[];for(const n of y(this,Uc))n[3]?(t.push(...oe(this,Da,g_).call(this,n)),oe(this,Da,dI).call(this,n)):(oe(this,Da,fI).call(this,n),t.push(...oe(this,Da,g_).call(this,n)));return oe(this,Da,uI).call(this,t)}}jm=new WeakMap,Km=new WeakMap,Uc=new WeakMap,Lr=new WeakMap,Da=new WeakSet,uI=function(t){const n=[],s=new Set;for(const r of t){const[i,l,c]=r;n.push([i,l,r],[i,c,r])}n.sort((r,i)=>r[1]-i[1]||r[0]-i[0]);for(let r=0,i=n.length;r0;){const r=s.values().next().value;let[i,l,c,u,d]=r;s.delete(r);let h=i,p=l;for(o=[i,c],a.push(o);;){let v;if(s.has(u))v=u;else if(s.has(d))v=d;else break;s.delete(v),[i,l,c,u,d]=v,h!==i&&(o.push(h,p,i,p===l?l:c),h=i),p=p===l?c:l}o.push(h,p)}return new $4e(a,y(this,jm),y(this,Km))},o4=function(t){const n=y(this,Lr);let s=0,a=n.length-1;for(;s<=a;){const o=s+a>>1,r=n[o][0];if(r===t)return o;r=0;a--){const[o,r]=y(this,Lr)[a];if(o!==t)break;if(o===t&&r===n){y(this,Lr).splice(a,1);return}}},g_=function(t){const[n,s,a]=t,o=[[n,s,a]],r=oe(this,Da,o4).call(this,a);for(let i=0;i=l){if(p>c)o[u][1]=c;else{if(d===1)return[];o.splice(u,1),u--,d--}continue}o[u][2]=l,p>c&&o.push([n,c,p])}}}return o};class $4e extends Lt{constructor(n,s,a){super();ne(this,Um);ne(this,n0);G(this,n0,n),G(this,Um,s),this.lastPoint=a}toSVGPath(){const n=[];for(const s of y(this,n0)){let[a,o]=s;n.push(`M${a} ${o}`);for(let r=2;r-1?(G(this,Qs,!0),oe(this,cn,r4).call(this,n),oe(this,cn,af).call(this)):y(this,Fl)&&(G(this,r0,n.anchorNode),G(this,Jm,n.anchorOffset),G(this,Zm,n.focusNode),G(this,Qm,n.focusOffset),oe(this,cn,__).call(this),oe(this,cn,af).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const n=Tn.prototype;return mn(this,"_keyboardManager",new kv([[["ArrowLeft","mac+ArrowLeft"],n._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],n._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],n._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],n._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:y(this,Qs)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:y(this,Xo),methodOfCreation:y(this,e2)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(n){return{numberOfColors:n.get("color").size}}static initialize(n,s){var a;is.initialize(n,s),Tn._defaultColor||(Tn._defaultColor=((a=s.highlightColors)==null?void 0:a.values().next().value)||"#fff066")}static updateDefaultParams(n,s){switch(n){case _n.HIGHLIGHT_DEFAULT_COLOR:Tn._defaultColor=s;break;case _n.HIGHLIGHT_THICKNESS:Tn._defaultThickness=s;break}}translateInPage(n,s){}get toolbarPosition(){return y(this,l0)}updateParams(n,s){switch(n){case _n.HIGHLIGHT_COLOR:oe(this,cn,pI).call(this,s);break;case _n.HIGHLIGHT_THICKNESS:oe(this,cn,vI).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[_n.HIGHLIGHT_DEFAULT_COLOR,Tn._defaultColor],[_n.HIGHLIGHT_THICKNESS,Tn._defaultThickness]]}get propertiesToUpdate(){return[[_n.HIGHLIGHT_COLOR,this.color||Tn._defaultColor],[_n.HIGHLIGHT_THICKNESS,y(this,Xo)||Tn._defaultThickness],[_n.HIGHLIGHT_FREE,y(this,Qs)]]}async addEditToolbar(){const n=await super.addEditToolbar();return n?(this._uiManager.highlightColors&&(G(this,i0,new vb({editor:this})),n.addColorPicker(y(this,i0))),n):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(oe(this,cn,b2).call(this))}getBaseTranslation(){return[0,0]}getRect(n,s){return super.getRect(n,s,oe(this,cn,b2).call(this))}onceAdded(n){this.annotationElementId||this.parent.addUndoableEditor(this),n&&this.div.focus()}remove(){oe(this,cn,C_).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(oe(this,cn,af).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(n){var a;let s=!1;this.parent&&!n?oe(this,cn,C_).call(this):n&&(oe(this,cn,af).call(this,n),s=!this.parent&&((a=this.div)==null?void 0:a.classList.contains("selectedEditor"))),super.setParent(n),this.show(this._isVisible),s&&this.select()}rotate(n){var o,r,i;const{drawLayer:s}=this.parent;let a;y(this,Qs)?(n=(n-this.rotation+360)%360,a=oe(o=Tn,Jo,T0).call(o,y(this,Yo).box,n)):a=oe(r=Tn,Jo,T0).call(r,[this.x,this.y,this.width,this.height],n),s.updateProperties(y(this,To),{bbox:a,root:{"data-main-rotation":n}}),s.updateProperties(y(this,_a),{bbox:oe(i=Tn,Jo,T0).call(i,y(this,ao).box,n),root:{"data-main-rotation":n}})}render(){if(this.div)return this.div;const n=super.render();y(this,c0)&&(n.setAttribute("aria-label",y(this,c0)),n.setAttribute("role","mark")),y(this,Qs)?n.classList.add("free"):this.div.addEventListener("keydown",oe(this,cn,gI).bind(this),{signal:this._uiManager._signal});const s=G(this,Wd,document.createElement("div"));n.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=y(this,Hd);const[a,o]=this.parentDimensions;return this.setDims(this.width*a,this.height*o),ob(this,y(this,Wd),["pointerover","pointerleave"]),this.enableEditing(),n}pointerover(){var n;this.isSelected||(n=this.parent)==null||n.drawLayer.updateProperties(y(this,_a),{rootClass:{hovered:!0}})}pointerleave(){var n;this.isSelected||(n=this.parent)==null||n.drawLayer.updateProperties(y(this,_a),{rootClass:{hovered:!1}})}_moveCaret(n){switch(this.parent.unselect(this),n){case 0:case 2:oe(this,cn,i4).call(this,!0);break;case 1:case 3:oe(this,cn,i4).call(this,!1);break}}select(){var n;super.select(),y(this,_a)&&((n=this.parent)==null||n.drawLayer.updateProperties(y(this,_a),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var n;super.unselect(),y(this,_a)&&((n=this.parent)==null||n.drawLayer.updateProperties(y(this,_a),{rootClass:{selected:!1}}),y(this,Qs)||oe(this,cn,i4).call(this,!1))}get _mustFixPosition(){return!y(this,Qs)}show(n=this._isVisible){super.show(n),this.parent&&(this.parent.drawLayer.updateProperties(y(this,To),{rootClass:{hidden:!n}}),this.parent.drawLayer.updateProperties(y(this,_a),{rootClass:{hidden:!n}}))}static startHighlighting(n,s,{target:a,x:o,y:r}){const{x:i,y:l,width:c,height:u}=a.getBoundingClientRect(),d=new AbortController,h=n.combinedSignal(d),p=v=>{d.abort(),oe(this,Jo,_I).call(this,n,v)};window.addEventListener("blur",p,{signal:h}),window.addEventListener("pointerup",p,{signal:h}),window.addEventListener("pointerdown",go,{capture:!0,passive:!1,signal:h}),window.addEventListener("contextmenu",xr,{signal:h}),a.addEventListener("pointermove",oe(this,Jo,wI).bind(this,n),{signal:h}),this._freeHighlight=new xw({x:o,y:r},[i,l,c,u],n.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=n.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 async deserialize(n,s,a){var m,g,b,C;let o=null;if(n instanceof tR){const{data:{quadPoints:w,rect:_,rotation:x,id:k,color:T,opacity:I,popupRef:O},parent:{page:{pageNumber:R}}}=n;o=n={annotationType:dn.HIGHLIGHT,color:Array.from(T),opacity:I,quadPoints:w,boxes:null,pageIndex:R-1,rect:_.slice(0),rotation:x,id:k,deleted:!1,popupRef:O}}else if(n instanceof _w){const{data:{inkLists:w,rect:_,rotation:x,id:k,color:T,borderStyle:{rawWidth:I},popupRef:O},parent:{page:{pageNumber:R}}}=n;o=n={annotationType:dn.HIGHLIGHT,color:Array.from(T),thickness:I,inkLists:w,boxes:null,pageIndex:R-1,rect:_.slice(0),rotation:x,id:k,deleted:!1,popupRef:O}}const{color:r,quadPoints:i,inkLists:l,opacity:c}=n,u=await super.deserialize(n,s,a);u.color=zt.makeHexColor(...r),G(u,Bl,c||1),l&&G(u,Xo,n.thickness),u.annotationElementId=n.id||null,u._initialData=o;const[d,h]=u.pageDimensions,[p,v]=u.pageTranslation;if(i){const w=G(u,Fl,[]);for(let _=0;_=0)G(this,To,s),G(this,Hd,a),this.parent.drawLayer.finalizeDraw(s,{bbox:n.box,path:{d:n.toSVGPath()}}),G(this,_a,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:y(this,ao).box,path:{d:y(this,ao).toSVGPath()}},!0));else if(this.parent){const p=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(y(this,To),{bbox:oe(d=Tn,Jo,T0).call(d,y(this,Yo).box,(p-this.rotation+360)%360),path:{d:n.toSVGPath()}}),this.parent.drawLayer.updateProperties(y(this,_a),{bbox:oe(h=Tn,Jo,T0).call(h,y(this,ao).box,p),path:{d:y(this,ao).toSVGPath()}})}const[r,i,l,c]=n.box;switch(this.rotation){case 0:this.x=r,this.y=i,this.width=l,this.height=c;break;case 90:{const[p,v]=this.parentDimensions;this.x=i,this.y=1-r,this.width=l*v/p,this.height=c*p/v;break}case 180:this.x=1-r,this.y=1-i,this.width=l,this.height=c;break;case 270:{const[p,v]=this.parentDimensions;this.x=1-i,this.y=r,this.width=l*v/p,this.height=c*p/v;break}}const{lastPoint:u}=y(this,ao);G(this,l0,[(u[0]-r)/l,(u[1]-i)/c])},pI=function(n){const s=(r,i)=>{var l,c;this.color=r,G(this,Bl,i),(l=this.parent)==null||l.drawLayer.updateProperties(y(this,To),{root:{fill:r,"fill-opacity":i}}),(c=y(this,i0))==null||c.updateColor(r)},a=this.color,o=y(this,Bl);this.addCommands({cmd:s.bind(this,n,Tn._defaultOpacity),undo:s.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_n.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(n)},!0)},vI=function(n){const s=y(this,Xo),a=o=>{G(this,Xo,o),oe(this,cn,mI).call(this,o)};this.addCommands({cmd:a.bind(this,n),undo:a.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:_n.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:n},!0)},mI=function(n){if(!y(this,Qs))return;oe(this,cn,r4).call(this,{highlightOutlines:y(this,Yo).getNewOutline(n/2)}),this.fixAndSetPosition();const[s,a]=this.parentDimensions;this.setDims(this.width*s,this.height*a)},C_=function(){y(this,To)===null||!this.parent||(this.parent.drawLayer.remove(y(this,To)),G(this,To,null),this.parent.drawLayer.remove(y(this,_a)),G(this,_a,null))},af=function(n=this.parent){y(this,To)===null&&({id:za(this,To)._,clipPathId:za(this,Hd)._}=n.drawLayer.draw({bbox:y(this,Yo).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":y(this,Bl)},rootClass:{highlight:!0,free:y(this,Qs)},path:{d:y(this,Yo).toSVGPath()}},!1,!0),G(this,_a,n.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:y(this,Qs)},bbox:y(this,ao).box,path:{d:y(this,ao).toSVGPath()}},y(this,Qs))),y(this,Wd)&&(y(this,Wd).style.clipPath=y(this,Hd)))},Jo=new WeakSet,T0=function([n,s,a,o],r){switch(r){case 90:return[1-s-o,n,o,a];case 180:return[1-n-a,1-s-o,a,o];case 270:return[s,1-n-a,o,a]}return[n,s,a,o]},gI=function(n){Tn._keyboardManager.exec(this,n)},i4=function(n){if(!y(this,r0))return;const s=window.getSelection();n?s.setPosition(y(this,r0),y(this,Jm)):s.setPosition(y(this,Zm),y(this,Qm))},b2=function(){return y(this,Qs)?this.rotation:0},bI=function(){if(y(this,Qs))return null;const[n,s]=this.pageDimensions,[a,o]=this.pageTranslation,r=y(this,Fl),i=new Float32Array(r.length*8);let l=0;for(const{x:c,y:u,width:d,height:h}of r){const p=c*n+a,v=(1-u)*s+o;i[l]=i[l+4]=p,i[l+1]=i[l+3]=v,i[l+2]=i[l+6]=p+d*n,i[l+5]=i[l+7]=v-h*s,l+=8}return i},yI=function(n){return y(this,Yo).serialize(n,oe(this,cn,b2).call(this))},wI=function(n,s){this._freeHighlight.add(s)&&n.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},_I=function(n,s){this._freeHighlight.isEmpty()?n.drawLayer.remove(this._freeHighlightId):n.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},CI=function(n){const{color:s}=this._initialData;return n.color.some((a,o)=>a!==s[o])},ne(Tn,Jo),Ut(Tn,"_defaultColor",null),Ut(Tn,"_defaultOpacity",1),Ut(Tn,"_defaultThickness",12),Ut(Tn,"_type","highlight"),Ut(Tn,"_editorType",dn.HIGHLIGHT),Ut(Tn,"_freeHighlightId",-1),Ut(Tn,"_freeHighlight",null),Ut(Tn,"_freeHighlightClipId","");let mb=Tn;class F4e{constructor(){ne(this,jd,Object.create(null))}updateProperty(t,n){this[t]=n,this.updateSVGProperty(t,n)}updateProperties(t){if(t)for(const[n,s]of Object.entries(t))this.updateProperty(n,s)}updateSVGProperty(t,n){y(this,jd)[t]=n}toSVGProperties(){const t=y(this,jd);return G(this,jd,Object.create(null)),{root:t}}reset(){G(this,jd,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){Hn("Not implemented")}}jd=new WeakMap;const $t=class $t extends is{constructor(n){super(n);ne(this,Sn);ne(this,Mo,null);ne(this,u0);Ut(this,"_drawId",null);G(this,u0,n.mustBeCommitted||!1),n.drawOutlines&&(oe(this,Sn,S_).call(this,n),oe(this,Sn,y2).call(this))}static _mergeSVGProperties(n,s){const a=new Set(Object.keys(n));for(const[o,r]of Object.entries(s))a.has(o)?Object.assign(n[o],r):n[o]=r;return n}static getDefaultDrawingOptions(n){Hn("Not implemented")}static get typesMap(){Hn("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(n,s){const a=this.typesMap.get(n);a&&this._defaultDrawingOptions.updateProperty(a,s),this._currentParent&&(y($t,js).updateProperty(a,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(n,s){const a=this.constructor.typesMap.get(n);a&&this._updateProperty(n,a,s)}static get defaultPropertiesToUpdate(){const n=[],s=this._defaultDrawingOptions;for(const[a,o]of this.typesMap)n.push([a,s[o]]);return n}get propertiesToUpdate(){const n=[],{_drawingOptions:s}=this;for(const[a,o]of this.constructor.typesMap)n.push([a,s[o]]);return n}_updateProperty(n,s,a){const o=this._drawingOptions,r=o[s],i=l=>{var u;o.updateProperty(s,l);const c=y(this,Mo).updateProperty(s,l);c&&oe(this,Sn,w2).call(this,c),(u=this.parent)==null||u.drawLayer.updateProperties(this._drawId,o.toSVGProperties())};this.addCommands({cmd:i.bind(this,a),undo:i.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,$t._mergeSVGProperties(y(this,Mo).getPathResizingSVGProperties(oe(this,Sn,l4).call(this)),{bbox:oe(this,Sn,M0).call(this)}))}_onResized(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,$t._mergeSVGProperties(y(this,Mo).getPathResizedSVGProperties(oe(this,Sn,l4).call(this)),{bbox:oe(this,Sn,M0).call(this)}))}_onTranslating(n,s){var a;(a=this.parent)==null||a.drawLayer.updateProperties(this._drawId,{bbox:oe(this,Sn,M0).call(this,n,s)})}_onTranslated(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,$t._mergeSVGProperties(y(this,Mo).getPathTranslatedSVGProperties(oe(this,Sn,l4).call(this),this.parentDimensions),{bbox:oe(this,Sn,M0).call(this)}))}_onStartDragging(){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var n;(n=this.parent)==null||n.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(n){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,y(this,u0)&&(G(this,u0,!1),this.commit(),this.parent.setSelected(this),n&&this.isOnScreen&&this.div.focus())}remove(){oe(this,Sn,k_).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(oe(this,Sn,y2).call(this),oe(this,Sn,w2).call(this,y(this,Mo).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(n){var a;let s=!1;this.parent&&!n?(this._uiManager.removeShouldRescale(this),oe(this,Sn,k_).call(this)):n&&(this._uiManager.addShouldRescale(this),oe(this,Sn,y2).call(this,n),s=!this.parent&&((a=this.div)==null?void 0:a.classList.contains("selectedEditor"))),super.setParent(n),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,$t._mergeSVGProperties({bbox:oe(this,Sn,M0).call(this)},y(this,Mo).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&oe(this,Sn,w2).call(this,y(this,Mo).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const n=super.render();n.classList.add("draw");const s=document.createElement("div");n.append(s),s.setAttribute("aria-hidden","true"),s.className="internal";const[a,o]=this.parentDimensions;return this.setDims(this.width*a,this.height*o),this._uiManager.addShouldRescale(this),this.disableEditing(),n}static createDrawerInstance(n,s,a,o,r){Hn("Not implemented")}static startDrawing(n,s,a,o){var g;const{target:r,offsetX:i,offsetY:l,pointerId:c,pointerType:u}=o;if(y($t,Yc)&&y($t,Yc)!==u)return;const{viewport:{rotation:d}}=n,{width:h,height:p}=r.getBoundingClientRect(),v=G($t,Kd,new AbortController),m=n.combinedSignal(v);if(y($t,Gc)||G($t,Gc,c),y($t,Yc)??G($t,Yc,u),window.addEventListener("pointerup",b=>{var C;y($t,Gc)===b.pointerId?this._endDraw(b):(C=y($t,Xc))==null||C.delete(b.pointerId)},{signal:m}),window.addEventListener("pointercancel",b=>{var C;y($t,Gc)===b.pointerId?this._currentParent.endDrawingSession():(C=y($t,Xc))==null||C.delete(b.pointerId)},{signal:m}),window.addEventListener("pointerdown",b=>{y($t,Yc)===b.pointerType&&((y($t,Xc)||G($t,Xc,new Set)).add(b.pointerId),y($t,js).isCancellable()&&(y($t,js).removeLastElement(),y($t,js).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",xr,{signal:m}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:m}),r.addEventListener("touchmove",b=>{b.timeStamp===y($t,qd)&&go(b)},{signal:m}),n.toggleDrawing(),(g=s._editorUndoBar)==null||g.hide(),y($t,js)){n.drawLayer.updateProperties(this._currentDrawId,y($t,js).startNew(i,l,h,p,d));return}s.updateUIForDefaultProperties(this),G($t,js,this.createDrawerInstance(i,l,h,p,d)),G($t,Ud,this.getDefaultDrawingOptions()),this._currentParent=n,{id:this._currentDrawId}=n.drawLayer.draw(this._mergeSVGProperties(y($t,Ud).toSVGProperties(),y($t,js).defaultSVGProperties),!0,!1)}static _drawMove(n){var r;if(G($t,qd,-1),!y($t,js))return;const{offsetX:s,offsetY:a,pointerId:o}=n;if(y($t,Gc)===o){if(((r=y($t,Xc))==null?void 0:r.size)>=1){this._endDraw(n);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,y($t,js).add(s,a)),G($t,qd,n.timeStamp),go(n)}}static _cleanup(n){n&&(this._currentDrawId=-1,this._currentParent=null,G($t,js,null),G($t,Ud,null),G($t,Yc,null),G($t,qd,NaN)),y($t,Kd)&&(y($t,Kd).abort(),G($t,Kd,null),G($t,Gc,NaN),G($t,Xc,null))}static _endDraw(n){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),n&&s.drawLayer.updateProperties(this._currentDrawId,y($t,js).end(n.offsetX,n.offsetY)),this.supportMultipleDrawings){const a=y($t,js),o=this._currentDrawId,r=a.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(o,a.setLastElement(r))},undo:()=>{s.drawLayer.updateProperties(o,a.removeLastElement())},mustExec:!1,type:_n.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(n){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(_n.DRAW_STEP),!y($t,js).isEmpty()){const{pageDimensions:[a,o],scale:r}=s,i=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:y($t,js).getOutlines(a*r,o*r,r,this._INNER_MARGIN),drawingOptions:y($t,Ud),mustBeCommitted:!n});return this._cleanup(!0),i}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(n){}static deserializeDraw(n,s,a,o,r,i){Hn("Not implemented")}static async deserialize(n,s,a){var d,h;const{rawDims:{pageWidth:o,pageHeight:r,pageX:i,pageY:l}}=s.viewport,c=this.deserializeDraw(i,l,o,r,this._INNER_MARGIN,n),u=await super.deserialize(n,s,a);return u.createDrawingOptions(n),oe(d=u,Sn,S_).call(d,{drawOutlines:c}),oe(h=u,Sn,y2).call(h),u.onScaleChanging(),u.rotate(),u}serializeDraw(n){const[s,a]=this.pageTranslation,[o,r]=this.pageDimensions;return y(this,Mo).serialize([s,a,o,r],n)}renderAnnotationElement(n){return n.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};Mo=new WeakMap,u0=new WeakMap,js=new WeakMap,Kd=new WeakMap,Ud=new WeakMap,Gc=new WeakMap,Yc=new WeakMap,Xc=new WeakMap,qd=new WeakMap,Sn=new WeakSet,S_=function({drawOutlines:n,drawId:s,drawingOptions:a}){G(this,Mo,n),this._drawingOptions||(this._drawingOptions=a),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,n.defaultProperties)):this._drawId=oe(this,Sn,x_).call(this,n,this.parent),oe(this,Sn,w2).call(this,n.box)},x_=function(n,s){const{id:a}=s.drawLayer.draw($t._mergeSVGProperties(this._drawingOptions.toSVGProperties(),n.defaultSVGProperties),!1,!1);return a},k_=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},y2=function(n=this.parent){if(!(this._drawId!==null&&this.parent===n)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,n.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=oe(this,Sn,x_).call(this,y(this,Mo),n)}},SI=function([n,s,a,o]){const{parentDimensions:[r,i],rotation:l}=this;switch(l){case 90:return[s,1-n,a*(i/r),o*(r/i)];case 180:return[1-n,1-s,a,o];case 270:return[1-s,n,a*(i/r),o*(r/i)];default:return[n,s,a,o]}},l4=function(){const{x:n,y:s,width:a,height:o,parentDimensions:[r,i],rotation:l}=this;switch(l){case 90:return[1-s,n,a*(r/i),o*(i/r)];case 180:return[1-n,1-s,a,o];case 270:return[s,1-n,a*(r/i),o*(i/r)];default:return[n,s,a,o]}},w2=function(n){if([this.x,this.y,this.width,this.height]=oe(this,Sn,SI).call(this,n),this.div){this.fixAndSetPosition();const[s,a]=this.parentDimensions;this.setDims(this.width*s,this.height*a)}this._onResized()},M0=function(){const{x:n,y:s,width:a,height:o,rotation:r,parentRotation:i,parentDimensions:[l,c]}=this;switch((r*4+i)/90){case 1:return[1-s-o,n,o,a];case 2:return[1-n-a,1-s-o,a,o];case 3:return[s,1-n-a,o,a];case 4:return[n,s-a*(l/c),o*(c/l),a*(l/c)];case 5:return[1-s,n,a*(l/c),o*(c/l)];case 6:return[1-n-o*(c/l),1-s,o*(c/l),a*(l/c)];case 7:return[s-a*(l/c),1-n-o*(c/l),a*(l/c),o*(c/l)];case 8:return[n-a,s-o,a,o];case 9:return[1-s,n-a,o,a];case 10:return[1-n,1-s,a,o];case 11:return[s-o,1-n,o,a];case 12:return[n-o*(c/l),s,o*(c/l),a*(l/c)];case 13:return[1-s-a*(l/c),n-o*(c/l),a*(l/c),o*(c/l)];case 14:return[1-n,1-s-a*(l/c),o*(c/l),a*(l/c)];case 15:return[s,1-n,a*(l/c),o*(c/l)];default:return[n,s,a,o]}},Ut($t,"_currentDrawId",-1),Ut($t,"_currentParent",null),ne($t,js,null),ne($t,Kd,null),ne($t,Ud,null),ne($t,Gc,NaN),ne($t,Yc,null),ne($t,Xc,null),ne($t,qd,NaN),Ut($t,"_INNER_MARGIN",3);let kw=$t;class B4e{constructor(t,n,s,a,o,r){ne(this,f0);ne(this,xi,new Float64Array(6));ne(this,Ks);ne(this,Us);ne(this,Gd);ne(this,d0);ne(this,Fa);ne(this,ea,"");ne(this,Zo,0);ne(this,Yd,new gb);ne(this,Xd);ne(this,Jd);G(this,Xd,s),G(this,Jd,a),G(this,Gd,o),G(this,d0,r),[t,n]=oe(this,f0,c4).call(this,t,n);const i=G(this,Ks,[NaN,NaN,NaN,NaN,t,n]);G(this,Fa,[t,n]),G(this,Us,[{line:i,points:y(this,Fa)}]),y(this,xi).set(i,0)}updateProperty(t,n){t==="stroke-width"&&G(this,d0,n)}isEmpty(){return!y(this,Us)||y(this,Us).length===0}isCancellable(){return y(this,Fa).length<=10}add(t,n){[t,n]=oe(this,f0,c4).call(this,t,n);const[s,a,o,r]=y(this,xi).subarray(2,6),i=t-o,l=n-r;return Math.hypot(y(this,Xd)*i,y(this,Jd)*l)<=2?null:(y(this,Fa).push(t,n),isNaN(s)?(y(this,xi).set([o,r,t,n],2),y(this,Ks).push(NaN,NaN,NaN,NaN,t,n),{path:{d:this.toSVGPath()}}):(isNaN(y(this,xi)[0])&&y(this,Ks).splice(6,6),y(this,xi).set([s,a,o,r,t,n],0),y(this,Ks).push(...Lt.createBezierPoints(s,a,o,r,t,n)),{path:{d:this.toSVGPath()}}))}end(t,n){const s=this.add(t,n);return s||(y(this,Fa).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,n,s,a,o){G(this,Xd,s),G(this,Jd,a),G(this,Gd,o),[t,n]=oe(this,f0,c4).call(this,t,n);const r=G(this,Ks,[NaN,NaN,NaN,NaN,t,n]);G(this,Fa,[t,n]);const i=y(this,Us).at(-1);return i&&(i.line=new Float32Array(i.line),i.points=new Float32Array(i.points)),y(this,Us).push({line:r,points:y(this,Fa)}),y(this,xi).set(r,0),G(this,Zo,0),this.toSVGPath(),null}getLastElement(){return y(this,Us).at(-1)}setLastElement(t){return y(this,Us)?(y(this,Us).push(t),G(this,Ks,t.line),G(this,Fa,t.points),G(this,Zo,0),{path:{d:this.toSVGPath()}}):y(this,Yd).setLastElement(t)}removeLastElement(){if(!y(this,Us))return y(this,Yd).removeLastElement();y(this,Us).pop(),G(this,ea,"");for(let t=0,n=y(this,Us).length;t_??NaN),h,p,v,m),points:g(l[C].map(_=>_??NaN),h,p,v,m)});const b=new Nw;return b.build(d,a,o,1,c,u,r),b}get box(){return y(this,Ba)}updateProperty(n,s){return n==="stroke-width"?oe(this,ta,EI).call(this,s):null}updateParentDimensions([n,s],a){const[o,r]=oe(this,ta,ql).call(this);G(this,ki,n),G(this,Ei,s),G(this,h0,a);const[i,l]=oe(this,ta,ql).call(this),c=i-o,u=l-r,d=y(this,Ba);return d[0]-=c,d[1]-=u,d[2]+=2*c,d[3]+=2*u,d}updateRotation(n){return G(this,t2,n),{path:{transform:this.rotationTransform}}}get viewBox(){return y(this,Ba).map(Lt.svgRound).join(" ")}get defaultProperties(){const[n,s]=y(this,Ba);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Lt.svgRound(n)} ${Lt.svgRound(s)}`}}}get rotationTransform(){const[,,n,s]=y(this,Ba);let a=0,o=0,r=0,i=0,l=0,c=0;switch(y(this,t2)){case 90:o=s/n,r=-n/s,l=n;break;case 180:a=-1,i=-1,l=n,c=s;break;case 270:o=-s/n,r=n/s,c=s;break;default:return""}return`matrix(${a} ${o} ${r} ${i} ${Lt.svgRound(l)} ${Lt.svgRound(c)})`}getPathResizingSVGProperties([n,s,a,o]){const[r,i]=oe(this,ta,ql).call(this),[l,c,u,d]=y(this,Ba);if(Math.abs(u-r)<=Lt.PRECISION||Math.abs(d-i)<=Lt.PRECISION){const g=n+a/2-(l+u/2),b=s+o/2-(c+d/2);return{path:{"transform-origin":`${Lt.svgRound(n)} ${Lt.svgRound(s)}`,transform:`${this.rotationTransform} translate(${g} ${b})`}}}const h=(a-2*r)/(u-2*r),p=(o-2*i)/(d-2*i),v=u/a,m=d/o;return{path:{"transform-origin":`${Lt.svgRound(l)} ${Lt.svgRound(c)}`,transform:`${this.rotationTransform} scale(${v} ${m}) translate(${Lt.svgRound(r)} ${Lt.svgRound(i)}) scale(${h} ${p}) translate(${Lt.svgRound(-r)} ${Lt.svgRound(-i)})`}}}getPathResizedSVGProperties([n,s,a,o]){const[r,i]=oe(this,ta,ql).call(this),l=y(this,Ba),[c,u,d,h]=l;if(l[0]=n,l[1]=s,l[2]=a,l[3]=o,Math.abs(d-r)<=Lt.PRECISION||Math.abs(h-i)<=Lt.PRECISION){const b=n+a/2-(c+d/2),C=s+o/2-(u+h/2);for(const{line:w,points:_}of y(this,Po))Lt._translate(w,b,C,w),Lt._translate(_,b,C,_);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Lt.svgRound(n)} ${Lt.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const p=(a-2*r)/(d-2*r),v=(o-2*i)/(h-2*i),m=-p*(c+r)+n+r,g=-v*(u+i)+s+i;if(p!==1||v!==1||m!==0||g!==0)for(const{line:b,points:C}of y(this,Po))Lt._rescale(b,m,g,p,v,b),Lt._rescale(C,m,g,p,v,C);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Lt.svgRound(n)} ${Lt.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([n,s],a){const[o,r]=a,i=y(this,Ba),l=n-i[0],c=s-i[1];if(y(this,ki)===o&&y(this,Ei)===r)for(const{line:u,points:d}of y(this,Po))Lt._translate(u,l,c,u),Lt._translate(d,l,c,d);else{const u=y(this,ki)/o,d=y(this,Ei)/r;G(this,ki,o),G(this,Ei,r);for(const{line:h,points:p}of y(this,Po))Lt._rescale(h,l,c,u,d,h),Lt._rescale(p,l,c,u,d,p);i[2]*=u,i[3]*=d}return i[0]=n,i[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Lt.svgRound(n)} ${Lt.svgRound(s)}`}}}get defaultSVGProperties(){const n=y(this,Ba);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Lt.svgRound(n[0])} ${Lt.svgRound(n[1])}`,transform:this.rotationTransform||null},bbox:n}}};Ba=new WeakMap,t2=new WeakMap,n2=new WeakMap,Po=new WeakMap,ki=new WeakMap,Ei=new WeakMap,h0=new WeakMap,p0=new WeakMap,v0=new WeakMap,ta=new WeakSet,ql=function(n=y(this,v0)){const s=y(this,n2)+n/2*y(this,h0);return y(this,p0)%180===0?[s/y(this,ki),s/y(this,Ei)]:[s/y(this,Ei),s/y(this,ki)]},xI=function(){const[n,s,a,o]=y(this,Ba),[r,i]=oe(this,ta,ql).call(this,0);return[n+r,s+i,a-2*r,o-2*i]},kI=function(){const n=G(this,Ba,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:o}of y(this,Po)){if(o.length<=12){for(let l=4,c=o.length;li!==s[l])||n.thickness!==a||n.opacity!==o||n.pageIndex!==r},Ut(g0,"_type","ink"),Ut(g0,"_editorType",dn.INK),Ut(g0,"_defaultDrawingOptions",null);let Aw=g0;const s2=class s2 extends is{constructor(n){super({...n,name:"stampEditor"});ne(this,An);ne(this,cs,null);ne(this,na,null);ne(this,Jc,null);ne(this,Vl,null);ne(this,Zc,null);ne(this,b0,"");ne(this,Ai,null);ne(this,Ti,null);ne(this,Ro,!1);ne(this,y0,!1);G(this,Vl,n.bitmapUrl),G(this,Zc,n.bitmapFile)}static initialize(n,s){is.initialize(n,s)}static get supportedTypes(){return mn(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(s=>`image/${s}`))}static get supportedTypesStr(){return mn(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(n){return this.supportedTypes.includes(n)}static paste(n,s){s.pasteEditor(dn.STAMP,{bitmapFile:n.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var n;return{type:"stamp",hasAltText:!!((n=this.altTextData)!=null&&n.altText)}}static computeTelemetryFinalData(n){const s=n.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(n=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:a}=this._uiManager;if(!a)throw new Error("No ML.");if(!await a.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:o,width:r,height:i}=n||this.copyCanvas(null,null,!0).imageData,l=await a.guess({name:"altText",request:{data:o,width:r,height:i,channels:o.length/(r*i)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const c=l.output;return await this.setGuessedAltText(c),s&&!this.hasAltTextData()&&(this.altTextData={alt:c,decorative:!1}),c}remove(){var n;y(this,na)&&(G(this,cs,null),this._uiManager.imageManager.deleteId(y(this,na)),(n=y(this,Ai))==null||n.remove(),G(this,Ai,null),y(this,Ti)&&(clearTimeout(y(this,Ti)),G(this,Ti,null))),super.remove()}rebuild(){if(!this.parent){y(this,na)&&oe(this,An,u4).call(this);return}super.rebuild(),this.div!==null&&(y(this,na)&&y(this,Ai)===null&&oe(this,An,u4).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(n){this._isDraggable=!0,n&&this.div.focus()}isEmpty(){return!(y(this,Jc)||y(this,cs)||y(this,Vl)||y(this,Zc)||y(this,na))}get isResizable(){return!0}render(){if(this.div)return this.div;let n,s;if(this.width&&(n=this.x,s=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),y(this,cs)?oe(this,An,E_).call(this):oe(this,An,u4).call(this),this.width&&!this.annotationElementId){const[a,o]=this.parentDimensions;this.setAt(n*a,s*o,this.width*a,this.height*o)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;y(this,Ti)!==null&&clearTimeout(y(this,Ti)),G(this,Ti,setTimeout(()=>{G(this,Ti,null),oe(this,An,A_).call(this)},200))}copyCanvas(n,s,a=!1){var p;n||(n=224);const{width:o,height:r}=y(this,cs),i=new ow;let l=y(this,cs),c=o,u=r,d=null;if(s){if(o>s||r>s){const I=Math.min(s/o,s/r);c=Math.floor(o*I),u=Math.floor(r*I)}d=document.createElement("canvas");const v=d.width=Math.ceil(c*i.sx),m=d.height=Math.ceil(u*i.sy);y(this,Ro)||(l=oe(this,An,d4).call(this,v,m));const g=d.getContext("2d");g.filter=this._uiManager.hcmFilter;let b="white",C="#cfcfd8";this._uiManager.hcmFilter!=="none"?C="black":(p=window.matchMedia)!=null&&p.call(window,"(prefers-color-scheme: dark)").matches&&(b="#8f8f9d",C="#42414d");const w=15,_=w*i.sx,x=w*i.sy,k=new OffscreenCanvas(_*2,x*2),T=k.getContext("2d");T.fillStyle=b,T.fillRect(0,0,_*2,x*2),T.fillStyle=C,T.fillRect(0,0,_,x),T.fillRect(_,x,_,x),g.fillStyle=g.createPattern(k,"repeat"),g.fillRect(0,0,v,m),g.drawImage(l,0,0,l.width,l.height,0,0,v,m)}let h=null;if(a){let v,m;if(i.symmetric&&l.widthn||r>n){const C=Math.min(n/o,n/r);v=Math.floor(o*C),m=Math.floor(r*C),y(this,Ro)||(l=oe(this,An,d4).call(this,v,m))}const b=new OffscreenCanvas(v,m).getContext("2d",{willReadFrequently:!0});b.drawImage(l,0,0,l.width,l.height,0,0,v,m),h={width:v,height:m,data:b.getImageData(0,0,v,m).data}}return{canvas:d,width:c,height:u,imageData:h}}getImageForAltText(){return y(this,Ai)}static async deserialize(n,s,a){var m;let o=null;if(n instanceof nR){const{data:{rect:g,rotation:b,id:C,structParent:w,popupRef:_},container:x,parent:{page:{pageNumber:k}}}=n,T=x.querySelector("canvas"),I=a.imageManager.getFromCanvas(x.id,T);T.remove();const O=((m=await s._structTree.getAriaAttributes(`${ew}${C}`))==null?void 0:m.get("aria-label"))||"";o=n={annotationType:dn.STAMP,bitmapId:I.id,bitmap:I.bitmap,pageIndex:k-1,rect:g.slice(0),rotation:b,id:C,deleted:!1,accessibilityData:{decorative:!1,altText:O},isSvg:!1,structParent:w,popupRef:_}}const r=await super.deserialize(n,s,a),{rect:i,bitmap:l,bitmapUrl:c,bitmapId:u,isSvg:d,accessibilityData:h}=n;u&&a.imageManager.isValidId(u)?(G(r,na,u),l&&G(r,cs,l)):G(r,Vl,c),G(r,Ro,d);const[p,v]=r.pageDimensions;return r.width=(i[2]-i[0])/p,r.height=(i[3]-i[1])/v,r.annotationElementId=n.id||null,h&&(r.altTextData=h),r._initialData=o,G(r,y0,!!o),r}serialize(n=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const a={annotationType:dn.STAMP,bitmapId:y(this,na),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:y(this,Ro),structTreeParentId:this._structTreeParentId};if(n)return a.bitmapUrl=oe(this,An,f4).call(this,!0),a.accessibilityData=this.serializeAltText(!0),a;const{decorative:o,altText:r}=this.serializeAltText(!1);if(!o&&r&&(a.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){const l=oe(this,An,TI).call(this,a);if(l.isSame)return null;l.isSameAltText?delete a.accessibilityData:a.accessibilityData.structParent=this._initialData.structParent??-1}if(a.id=this.annotationElementId,s===null)return a;s.stamps||(s.stamps=new Map);const i=y(this,Ro)?(a.rect[2]-a.rect[0])*(a.rect[3]-a.rect[1]):null;if(!s.stamps.has(y(this,na)))s.stamps.set(y(this,na),{area:i,serialized:a}),a.bitmap=oe(this,An,f4).call(this,!1);else if(y(this,Ro)){const l=s.stamps.get(y(this,na));i>l.area&&(l.area=i,l.serialized.bitmap.close(),l.serialized.bitmap=oe(this,An,f4).call(this,!1))}return a}renderAnnotationElement(n){return n.updateEdited({rect:this.getRect(0,0)}),null}};cs=new WeakMap,na=new WeakMap,Jc=new WeakMap,Vl=new WeakMap,Zc=new WeakMap,b0=new WeakMap,Ai=new WeakMap,Ti=new WeakMap,Ro=new WeakMap,y0=new WeakMap,An=new WeakSet,_2=function(n,s=!1){if(!n){this.remove();return}G(this,cs,n.bitmap),s||(G(this,na,n.id),G(this,Ro,n.isSvg)),n.file&&G(this,b0,n.file.name),oe(this,An,E_).call(this)},C2=function(){if(G(this,Jc,null),this._uiManager.enableWaiting(!1),!!y(this,Ai)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&y(this,cs)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&y(this,cs)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},u4=function(){if(y(this,na)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(y(this,na)).then(a=>oe(this,An,_2).call(this,a,!0)).finally(()=>oe(this,An,C2).call(this));return}if(y(this,Vl)){const a=y(this,Vl);G(this,Vl,null),this._uiManager.enableWaiting(!0),G(this,Jc,this._uiManager.imageManager.getFromUrl(a).then(o=>oe(this,An,_2).call(this,o)).finally(()=>oe(this,An,C2).call(this)));return}if(y(this,Zc)){const a=y(this,Zc);G(this,Zc,null),this._uiManager.enableWaiting(!0),G(this,Jc,this._uiManager.imageManager.getFromFile(a).then(o=>oe(this,An,_2).call(this,o)).finally(()=>oe(this,An,C2).call(this)));return}const n=document.createElement("input");n.type="file",n.accept=s2.supportedTypesStr;const s=this._uiManager._signal;G(this,Jc,new Promise(a=>{n.addEventListener("change",async()=>{if(!n.files||n.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const o=await this._uiManager.imageManager.getFromFile(n.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),oe(this,An,_2).call(this,o)}a()},{signal:s}),n.addEventListener("cancel",()=>{this.remove(),a()},{signal:s})}).finally(()=>oe(this,An,C2).call(this))),n.click()},E_=function(){var d;const{div:n}=this;let{width:s,height:a}=y(this,cs);const[o,r]=this.pageDimensions,i=.75;if(this.width)s=this.width*o,a=this.height*r;else if(s>i*o||a>i*r){const h=Math.min(i*o/s,i*r/a);s*=h,a*=h}const[l,c]=this.parentDimensions;this.setDims(s*l/o,a*c/r),this._uiManager.enableWaiting(!1);const u=G(this,Ai,document.createElement("canvas"));u.setAttribute("role","img"),this.addContainer(u),this.width=s/o,this.height=a/r,(d=this._initialOptions)!=null&&d.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(n.hidden=!1),oe(this,An,A_).call(this),y(this,y0)||(this.parent.addUndoableEditor(this),G(this,y0,!0)),this._reportTelemetry({action:"inserted_image"}),y(this,b0)&&u.setAttribute("aria-label",y(this,b0))},d4=function(n,s){const{width:a,height:o}=y(this,cs);let r=a,i=o,l=y(this,cs);for(;r>2*n||i>2*s;){const c=r,u=i;r>2*n&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),i>2*s&&(i=i>=16384?Math.floor(i/2)-1:Math.ceil(i/2));const d=new OffscreenCanvas(r,i);d.getContext("2d").drawImage(l,0,0,c,u,0,0,r,i),l=d.transferToImageBitmap()}return l},A_=function(){const[n,s]=this.parentDimensions,{width:a,height:o}=this,r=new ow,i=Math.ceil(a*n*r.sx),l=Math.ceil(o*s*r.sy),c=y(this,Ai);if(!c||c.width===i&&c.height===l)return;c.width=i,c.height=l;const u=y(this,Ro)?y(this,cs):oe(this,An,d4).call(this,i,l),d=c.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(u,0,0,u.width,u.height,0,0,i,l)},f4=function(n){if(n){if(y(this,Ro)){const o=this._uiManager.imageManager.getSvgUrl(y(this,na));if(o)return o}const s=document.createElement("canvas");return{width:s.width,height:s.height}=y(this,cs),s.getContext("2d").drawImage(y(this,cs),0,0),s.toDataURL()}if(y(this,Ro)){const[s,a]=this.pageDimensions,o=Math.round(this.width*s*Sc.PDF_TO_CSS_UNITS),r=Math.round(this.height*a*Sc.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(o,r);return i.getContext("2d").drawImage(y(this,cs),0,0,y(this,cs).width,y(this,cs).height,0,0,o,r),i.transferToImageBitmap()}return structuredClone(y(this,cs))},TI=function(n){var i;const{pageIndex:s,accessibilityData:{altText:a}}=this._initialData,o=n.pageIndex===s,r=(((i=n.accessibilityData)==null?void 0:i.alt)||"")===a;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&o&&r,isSameAltText:r}},Ut(s2,"_type","stamp"),Ut(s2,"_editorType",dn.STAMP);let Tw=s2;const Fr=class Fr{constructor({uiManager:t,pageIndex:n,div:s,structTreeLayer:a,accessibilityManager:o,annotationLayer:r,drawLayer:i,textLayer:l,viewport:c,l10n:u}){ne(this,as);ne(this,Zd);ne(this,w0,!1);ne(this,Mi,null);ne(this,Qc,null);ne(this,zl,null);ne(this,Qo,new Map);ne(this,eu,!1);ne(this,_0,!1);ne(this,Qd,!1);ne(this,Dr,null);ne(this,Hl,null);ne(this,Ca,null);ne(this,Wl,null);ne(this,Vt);const d=[...y(Fr,tu).values()];if(!Fr._initialized){Fr._initialized=!0;for(const h of d)h.initialize(u,t)}t.registerEditorTypes(d),G(this,Vt,t),this.pageIndex=n,this.div=s,G(this,Zd,o),G(this,Mi,r),this.viewport=c,G(this,Ca,l),this.drawLayer=i,this._structTree=a,y(this,Vt).addLayer(this)}get isEmpty(){return y(this,Qo).size===0}get isInvisible(){return this.isEmpty&&y(this,Vt).getMode()===dn.NONE}updateToolbar(t){y(this,Vt).updateToolbar(t)}updateMode(t=y(this,Vt).getMode()){switch(oe(this,as,h4).call(this),t){case dn.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case dn.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case dn.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:n}=this.div;for(const s of y(Fr,tu).values())n.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var n;return t===((n=y(this,Ca))==null?void 0:n.div)}setEditingState(t){y(this,Vt).setEditingState(t)}addCommands(t){y(this,Vt).addCommands(t)}cleanUndoStack(t){y(this,Vt).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var n;(n=y(this,Mi))==null||n.div.classList.toggle("disabled",!t)}async enable(){G(this,Qd,!0),this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of y(this,Qo).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(y(this,Vt).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!y(this,Mi)){G(this,Qd,!1);return}const n=y(this,Mi).getEditableAnnotations();for(const s of n){if(s.hide(),y(this,Vt).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const a=await this.deserialize(s);a&&(this.addOrRebuild(a),a.enableEditing())}G(this,Qd,!1)}disable(){var a;G(this,_0,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,n=new Map;for(const o of y(this,Qo).values())if(o.disableEditing(),!!o.annotationElementId){if(o.serialize()!==null){t.set(o.annotationElementId,o);continue}else n.set(o.annotationElementId,o);(a=this.getEditableAnnotation(o.annotationElementId))==null||a.show(),o.remove()}if(y(this,Mi)){const o=y(this,Mi).getEditableAnnotations();for(const r of o){const{id:i}=r.data;if(y(this,Vt).isDeletedAnnotationElement(i))continue;let l=n.get(i);if(l){l.resetAnnotationElement(r),l.show(!1),r.show();continue}l=t.get(i),l&&(y(this,Vt).addChangedExistingAnnotation(l),l.renderAnnotationElement(r)&&l.show(!1)),r.show()}}oe(this,as,h4).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const o of y(Fr,tu).values())s.remove(`${o._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),G(this,_0,!1)}getEditableAnnotation(t){var n;return((n=y(this,Mi))==null?void 0:n.getEditableAnnotation(t))||null}setActiveEditor(t){y(this,Vt).getActive()!==t&&y(this,Vt).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=y(this,Ca))!=null&&t.div&&!y(this,Wl)){G(this,Wl,new AbortController);const n=y(this,Vt).combinedSignal(y(this,Wl));y(this,Ca).div.addEventListener("pointerdown",oe(this,as,MI).bind(this),{signal:n}),y(this,Ca).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=y(this,Ca))!=null&&t.div&&y(this,Wl)&&(y(this,Wl).abort(),G(this,Wl,null),y(this,Ca).div.classList.remove("highlighting"))}enableClick(){if(y(this,Qc))return;G(this,Qc,new AbortController);const t=y(this,Vt).combinedSignal(y(this,Qc));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const n=this.pointerup.bind(this);this.div.addEventListener("pointerup",n,{signal:t}),this.div.addEventListener("pointercancel",n,{signal:t})}disableClick(){var t;(t=y(this,Qc))==null||t.abort(),G(this,Qc,null)}attach(t){y(this,Qo).set(t.id,t);const{annotationElementId:n}=t;n&&y(this,Vt).isDeletedAnnotationElement(n)&&y(this,Vt).removeDeletedAnnotationElement(t)}detach(t){var n;y(this,Qo).delete(t.id),(n=y(this,Zd))==null||n.removePointerInTextLayer(t.contentDiv),!y(this,_0)&&t.annotationElementId&&y(this,Vt).addDeletedAnnotationElement(t)}remove(t){this.detach(t),y(this,Vt).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var n;t.parent!==this&&(t.parent&&t.annotationElementId&&(y(this,Vt).addDeletedAnnotationElement(t.annotationElementId),is.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(n=t.parent)==null||n.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),y(this,Vt).addEditor(t),this.attach(t),!t.isAttachedToDOM){const n=t.render();this.div.append(n),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!y(this,Qd)),y(this,Vt).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:n}=document;t.div.contains(n)&&!y(this,zl)&&(t._focusEventsAllowed=!1,G(this,zl,setTimeout(()=>{G(this,zl,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:y(this,Vt)._signal}),n.focus())},0))),t._structTreeParentId=(s=y(this,Zd))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const n=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:n,undo:s,mustExec:!1})}getNextId(){return y(this,Vt).getId()}combinedSignal(t){return y(this,Vt).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=y(this,as,Oi))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,n){y(this,Vt).updateToolbar(t),y(this,Vt).updateMode(t);const{offsetX:s,offsetY:a}=oe(this,as,M_).call(this),o=this.getNextId(),r=oe(this,as,T_).call(this,{parent:this,id:o,x:s,y:a,uiManager:y(this,Vt),isCentered:!0,...n});r&&this.add(r)}async deserialize(t){var n;return await((n=y(Fr,tu).get(t.annotationType??t.annotationEditorType))==null?void 0:n.deserialize(t,this,y(this,Vt)))||null}createAndAddNewEditor(t,n,s={}){const a=this.getNextId(),o=oe(this,as,T_).call(this,{parent:this,id:a,x:t.offsetX,y:t.offsetY,uiManager:y(this,Vt),isCentered:n,...s});return o&&this.add(o),o}addNewEditor(){this.createAndAddNewEditor(oe(this,as,M_).call(this),!0)}setSelected(t){y(this,Vt).setSelected(t)}toggleSelected(t){y(this,Vt).toggleSelected(t)}unselect(t){y(this,Vt).unselect(t)}pointerup(t){var s;const{isMac:n}=La.platform;if(!(t.button!==0||t.ctrlKey&&n)&&t.target===this.div&&y(this,eu)&&(G(this,eu,!1),!((s=y(this,as,Oi))!=null&&s.isDrawer&&y(this,as,Oi).supportMultipleDrawings))){if(!y(this,w0)){G(this,w0,!0);return}if(y(this,Vt).getMode()===dn.STAMP){y(this,Vt).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){var a;if(y(this,Vt).getMode()===dn.HIGHLIGHT&&this.enableTextSelection(),y(this,eu)){G(this,eu,!1);return}const{isMac:n}=La.platform;if(t.button!==0||t.ctrlKey&&n||t.target!==this.div)return;if(G(this,eu,!0),(a=y(this,as,Oi))!=null&&a.isDrawer){this.startDrawingSession(t);return}const s=y(this,Vt).getActive();G(this,w0,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus(),y(this,Dr)){y(this,as,Oi).startDrawing(this,y(this,Vt),!1,t);return}y(this,Vt).setCurrentDrawingSession(this),G(this,Dr,new AbortController);const n=y(this,Vt).combinedSignal(y(this,Dr));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(G(this,Hl,null),this.commitOrRemove())},{signal:n}),y(this,as,Oi).startDrawing(this,y(this,Vt),!1,t)}pause(t){if(t){const{activeElement:n}=document;this.div.contains(n)&&G(this,Hl,n);return}y(this,Hl)&&setTimeout(()=>{var n;(n=y(this,Hl))==null||n.focus(),G(this,Hl,null)},0)}endDrawingSession(t=!1){return y(this,Dr)?(y(this,Vt).setCurrentDrawingSession(null),y(this,Dr).abort(),G(this,Dr,null),G(this,Hl,null),y(this,as,Oi).endDrawing(t)):null}findNewParent(t,n,s){const a=y(this,Vt).findParent(n,s);return a===null||a===this?!1:(a.changeParent(t),!0)}commitOrRemove(){return y(this,Dr)?(this.endDrawingSession(),!0):!1}onScaleChanging(){y(this,Dr)&&y(this,as,Oi).onScaleChangingWhenDrawing(this)}destroy(){var t,n;this.commitOrRemove(),((t=y(this,Vt).getActive())==null?void 0:t.parent)===this&&(y(this,Vt).commitOrRemove(),y(this,Vt).setActiveEditor(null)),y(this,zl)&&(clearTimeout(y(this,zl)),G(this,zl,null));for(const s of y(this,Qo).values())(n=y(this,Zd))==null||n.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,y(this,Qo).clear(),y(this,Vt).removeLayer(this)}render({viewport:t}){this.viewport=t,ju(this.div,t);for(const n of y(this,Vt).getEditors(this.pageIndex))this.add(n),n.rebuild();this.updateMode()}update({viewport:t}){y(this,Vt).commitOrRemove(),oe(this,as,h4).call(this);const n=this.viewport.rotation,s=t.rotation;if(this.viewport=t,ju(this.div,{rotation:s}),n!==s)for(const a of y(this,Qo).values())a.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:n}=this.viewport.rawDims;return[t,n]}get scale(){return y(this,Vt).viewParameters.realScale}};Zd=new WeakMap,w0=new WeakMap,Mi=new WeakMap,Qc=new WeakMap,zl=new WeakMap,Qo=new WeakMap,eu=new WeakMap,_0=new WeakMap,Qd=new WeakMap,Dr=new WeakMap,Hl=new WeakMap,Ca=new WeakMap,Wl=new WeakMap,Vt=new WeakMap,tu=new WeakMap,as=new WeakSet,MI=function(t){y(this,Vt).unselectAll();const{target:n}=t;if(n===y(this,Ca).div||(n.getAttribute("role")==="img"||n.classList.contains("endOfContent"))&&y(this,Ca).div.contains(n)){const{isMac:s}=La.platform;if(t.button!==0||t.ctrlKey&&s)return;y(this,Vt).showAllEditors("highlight",!0,!0),y(this,Ca).div.classList.add("free"),this.toggleDrawing(),mb.startHighlighting(this,y(this,Vt).direction==="ltr",{target:y(this,Ca).div,x:t.x,y:t.y}),y(this,Ca).div.addEventListener("pointerup",()=>{y(this,Ca).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:y(this,Vt)._signal}),t.preventDefault()}},Oi=function(){return y(Fr,tu).get(y(this,Vt).getMode())},T_=function(t){const n=y(this,as,Oi);return n?new n.prototype.constructor(t):null},M_=function(){const{x:t,y:n,width:s,height:a}=this.div.getBoundingClientRect(),o=Math.max(0,t),r=Math.max(0,n),i=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,n+a),c=(o+i)/2-t,u=(r+l)/2-n,[d,h]=this.viewport.rotation%180===0?[c,u]:[u,c];return{offsetX:d,offsetY:h}},h4=function(){for(const t of y(this,Qo).values())t.isEmpty()&&t.remove()},Ut(Fr,"_initialized",!1),ne(Fr,tu,new Map([Cw,Aw,Tw,mb].map(t=>[t._editorType,t])));let Mw=Fr;const Sa=class Sa{constructor({pageIndex:t}){ne(this,Pi);ne(this,Br,null);ne(this,a2,0);ne(this,Va,new Map);ne(this,ef,new Map);this.pageIndex=t}setParent(t){if(!y(this,Br)){G(this,Br,t);return}if(y(this,Br)!==t){if(y(this,Va).size>0)for(const n of y(this,Va).values())n.remove(),t.append(n);G(this,Br,t)}}static get _svgFactory(){return mn(this,"_svgFactory",new yw)}draw(t,n=!1,s=!1){const a=za(this,a2)._++,o=oe(this,Pi,P_).call(this),r=Sa._svgFactory.createElement("defs");o.append(r);const i=Sa._svgFactory.createElement("path");r.append(i);const l=`path_p${this.pageIndex}_${a}`;i.setAttribute("id",l),i.setAttribute("vector-effect","non-scaling-stroke"),n&&y(this,ef).set(a,i);const c=s?oe(this,Pi,RI).call(this,r,l):null,u=Sa._svgFactory.createElement("use");return o.append(u),u.setAttribute("href",`#${l}`),this.updateProperties(o,t),y(this,Va).set(a,o),{id:a,clipPathId:`url(#${c})`}}drawOutline(t,n){const s=za(this,a2)._++,a=oe(this,Pi,P_).call(this),o=Sa._svgFactory.createElement("defs");a.append(o);const r=Sa._svgFactory.createElement("path");o.append(r);const i=`path_p${this.pageIndex}_${s}`;r.setAttribute("id",i),r.setAttribute("vector-effect","non-scaling-stroke");let l;if(n){const d=Sa._svgFactory.createElement("mask");o.append(d),l=`mask_p${this.pageIndex}_${s}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const h=Sa._svgFactory.createElement("rect");d.append(h),h.setAttribute("width","1"),h.setAttribute("height","1"),h.setAttribute("fill","white");const p=Sa._svgFactory.createElement("use");d.append(p),p.setAttribute("href",`#${i}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}const c=Sa._svgFactory.createElement("use");a.append(c),c.setAttribute("href",`#${i}`),l&&c.setAttribute("mask",`url(#${l})`);const u=c.cloneNode();return a.append(u),c.classList.add("mainOutline"),u.classList.add("secondaryOutline"),this.updateProperties(a,t),y(this,Va).set(s,a),s}finalizeDraw(t,n){y(this,ef).delete(t),this.updateProperties(t,n)}updateProperties(t,n){var l;if(!n)return;const{root:s,bbox:a,rootClass:o,path:r}=n,i=typeof t=="number"?y(this,Va).get(t):t;if(i){if(s&&oe(this,Pi,R_).call(this,i,s),a&&oe(l=Sa,Db,PI).call(l,i,a),o){const{classList:c}=i;for(const[u,d]of Object.entries(o))c.toggle(u,d)}if(r){const u=i.firstChild.firstChild;oe(this,Pi,R_).call(this,u,r)}}}updateParent(t,n){if(n===this)return;const s=y(this,Va).get(t);s&&(y(n,Br).append(s),y(this,Va).delete(t),y(n,Va).set(t,s))}remove(t){y(this,ef).delete(t),y(this,Br)!==null&&(y(this,Va).get(t).remove(),y(this,Va).delete(t))}destroy(){G(this,Br,null);for(const t of y(this,Va).values())t.remove();y(this,Va).clear(),y(this,ef).clear()}};Br=new WeakMap,a2=new WeakMap,Va=new WeakMap,ef=new WeakMap,Db=new WeakSet,PI=function(t,[n,s,a,o]){const{style:r}=t;r.top=`${100*s}%`,r.left=`${100*n}%`,r.width=`${100*a}%`,r.height=`${100*o}%`},Pi=new WeakSet,P_=function(){const t=Sa._svgFactory.create(1,1,!0);return y(this,Br).append(t),t.setAttribute("aria-hidden",!0),t},RI=function(t,n){const s=Sa._svgFactory.createElement("clipPath");t.append(s);const a=`clip_${n}`;s.setAttribute("id",a),s.setAttribute("clipPathUnits","objectBoundingBox");const o=Sa._svgFactory.createElement("use");return s.append(o),o.setAttribute("href",`#${n}`),o.classList.add("clip"),a},R_=function(t,n){for(const[s,a]of Object.entries(n))a===null?t.removeAttribute(s):t.setAttribute(s,a)},ne(Sa,Db);let Pw=Sa;globalThis.pdfjsTestingUtils={HighlightOutliner:Sw},nn.AbortException,nn.AnnotationEditorLayer,nn.AnnotationEditorParamsType,nn.AnnotationEditorType,nn.AnnotationEditorUIManager,nn.AnnotationLayer,nn.AnnotationMode,nn.ColorPicker,nn.DOMSVGFactory,nn.DrawLayer,nn.FeatureTest;var V4e=nn.GlobalWorkerOptions;nn.ImageKind,nn.InvalidPDFException,nn.MissingPDFException,nn.OPS,nn.OutputScale,nn.PDFDataRangeTransport,nn.PDFDateString,nn.PDFWorker,nn.PasswordResponses,nn.PermissionFlag,nn.PixelsPerInch,nn.RenderingCancelledException,nn.TextLayer,nn.TouchManager,nn.UnexpectedResponseException,nn.Util,nn.VerbosityLevel,nn.XfaLayer,nn.build,nn.createValidAbsoluteUrl,nn.fetchData;var z4e=nn.getDocument;nn.getFilenameFromUrl,nn.getPdfFilenameFromUrl,nn.getXfaPageViewport,nn.isDataScheme,nn.isPdfFile,nn.noContextMenu,nn.normalizeUnicode,nn.setLayerDimensions,nn.shadow,nn.stopEvent,nn.version;const H4e=""+new URL("assets/pdf.worker.min-yatZIOMy.mjs",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href,W4e={class:"manual-wrap"},j4e={class:"sidebar"},K4e={class:"es-text",style:{display:"none"}},U4e={class:"sb-section"},q4e={class:"sb-title"},G4e={key:0,class:"sb-section sb-range-row"},Y4e={class:"range-check"},X4e={class:"range-inline"},J4e=["max","disabled"],Z4e=["min","max"],Q4e={key:1,class:"sb-section"},eye={class:"sb-title"},tye={style:{display:"flex",gap:"6px"}},nye={key:2,class:"sb-section"},sye={class:"mode-inline-row"},aye={class:"sb-title mode-inline-title"},oye={class:"mode-inline-check"},rye={key:3,class:"sb-section"},iye={class:"sb-title"},lye={class:"region-type-btns"},cye=["onClick"],uye={class:"rt-badge"},dye={key:4,class:"sb-section sb-regions"},fye={class:"sb-title"},hye={class:"region-list"},pye=["onClick"],vye={class:"ri-top"},mye={class:"ri-badge"},gye={class:"ri-label"},bye={class:"ri-page"},yye={class:"ri-status"},wye={key:0,class:"ri-tokens"},_ye={key:0,class:"ri-preview"},Cye={key:5,class:"sb-section sb-actions"},Sye={key:0,class:"vl-progress-wrap"},xye={class:"vl-progress-label"},kye={key:0},Eye={key:1,class:"vl-done"},Aye={key:6,class:"sb-section sb-export"},Tye={class:"sb-title"},Mye={style:{display:"flex",gap:"8px"}},Pye={class:"sb-footer"},Rye={class:"viewer"},Iye={key:0,class:"viewer-nav"},Oye={class:"el-button-group"},Lye={class:"nav-label"},Nye={class:"nav-type-indicator"},$ye={class:"el-button-group el-button-group--small"},Dye={class:"zoom-bar"},Fye={class:"zoom-pct"},Bye={key:1,class:"viewer-empty"},Vye={class:"img-inner"},zye={key:0,class:"page-loading"},Hye=["data-mode"],Wye={key:0,class:"result-panel"},jye={class:"rp-header"},Kye={class:"rp-title"},Uye={key:0,class:"rp-tokens"},qye={class:"rp-text"},aR="ocrz_region_presets",Gye=[{path:"/",redirect:"/Manual"},{path:"/Auto",component:V1e},{path:"/Manual",component:cl({__name:"ManualOCR",setup(e){V4e.workerSrc=H4e;const t=lP(),n="http://localhost:8000";function s(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,me=>{const he=typeof crypto<"u"&&crypto.getRandomValues?crypto.getRandomValues(new Uint8Array(1)):null,Re=he?(he[0]&255)%16:Math.random()*16|0;return(me==="x"?Re:Re&3|8).toString(16)})}const a=[{name:"陕化建图纸识别",data:[{type:"A",page:0,xr:.6780016792611251,yr:.0344418052256532,wr:.3140218303946264,hr:.6033254156769596},{type:"B",page:0,xr:.28337531486146095,yr:.7838479809976246,wr:.26448362720403024,hr:.19596199524940616},{type:"C",page:0,xr:.9147774979009236,yr:.8931116389548693,wr:.022670025188916875,hr:.021377672209026127},{type:"C",page:0,xr:.9534005037783375,yr:.8978622327790974,wr:.026028547439126783,hr:.023752969121140142},{type:"C",page:0,xr:.7619647355163728,yr:.7921615201900237,wr:.16960537363560033,hr:.026128266033254157},{type:"D",page:0,xr:.6788413098236776,yr:.6520190023752969,wr:.3089840470193115,hr:.08432304038004751}]}];function o(){const me=JSON.parse(localStorage.getItem(aR)||"[]"),he=[...a];for(const Re of me){const it=he.findIndex(qe=>qe.name===Re.name);it>=0?he[it]=Re:he.push(Re)}return he}const r=F(o()),i=F("");function l(){const me=window.prompt("请输入预设名称:",i.value||"");if(!me||!me.trim())return;const he=me.trim(),Re=M.value.map(qe=>({type:qe.type,page:qe.page,xr:qe.xr,yr:qe.yr,wr:qe.wr,hr:qe.hr,region_code:qe.region_code||""})),it=r.value.findIndex(qe=>qe.name===he);it>=0?r.value[it]={name:he,data:Re}:r.value.push({name:he,data:Re}),localStorage.setItem(aR,JSON.stringify(r.value)),i.value=he,ts.success(`预设「${he}」已保存(${Re.length} 个区域)`)}function c(){const me=r.value.find(ft=>ft.name===i.value);if(!me)return;const he=Array.isArray(me.data)?me.data:[];if(!he.length){ts.warning(`预设「${me.name}」没有可用区域`);return}const Re=[...new Set(he.map(ft=>Number.isFinite(ft.page)?ft.page:0))].sort((ft,ke)=>ft-ke),it=Re.length?Re[0]:0,qe=k.value-it;let lt=[];if(T.value&&x.value>0&&Re.length===1)for(let ft=k.value;ft0?lt=he.map(ft=>({...ft,page:(Number.isFinite(ft.page)?ft.page:0)+qe})).filter(ft=>ft.page>=0&&ft.page({...ft,page:Number.isFinite(ft.page)?ft.page:0}));const vt=new Map,Ft=ft=>{vt.has(ft)||vt.set(ft,new Set);const ke=vt.get(ft);let tt=1;for(;ke.has(`C${tt}`);)tt+=1;const Ne=`C${tt}`;return ke.add(Ne),Ne};M.value=lt.map(ft=>{const ke=Number.isFinite(ft.page)?ft.page:0,tt={...ft,page:ke,id:s(),status:"pending",text:null,tokens:null};return tt.type==="C"&&(tt.region_code?(vt.has(ke)||vt.set(ke,new Set),vt.get(ke).add(tt.region_code)):tt.region_code=Ft(ke)),tt}),B.value=null,ze(()=>ot()),ts.success(`已载入预设「${me.name}」(${M.value.length} 个区域)`)}const u=[{key:"A",label:"材料区域",color:"#2563eb"},{key:"B",label:"图纸信息",color:"#d97706"},{key:"C",label:"其他",color:"#059669"},{key:"D",label:"管长表",color:"#7c3aed"}],d=me=>{var he;return((he=u.find(Re=>Re.key===me))==null?void 0:he.color)??"#6b7280"},h=me=>{var he;return((he=u.find(Re=>Re.key===me))==null?void 0:he.label)??me};function p(me){if(!me)return"";if(me.type!=="C")return me.type;if(me.region_code)return me.region_code;const Re=M.value.filter(it=>it.type==="C").findIndex(it=>it.id===me.id);return Re>=0?`C${Re+1}`:"C"}function v(me){return me?me.type==="C"?`${p(me)} ${h(me.type)}`:h(me.type):""}function m(me){if(me!=="C")return"";const he=new Set(M.value.filter(it=>it.type==="C"&&it.region_code).map(it=>it.region_code));let Re=1;for(;he.has(`C${Re}`);)Re+=1;return`C${Re}`}const g=F("file"),b=F(null),C=F(""),w=F(!1),_=F(""),x=F(0),k=F(0),T=F(!1),I=bn(null),O=F(!1);let R=null;const $=F("A"),M=F([]),B=F(null),U=F(!0),J=F(!1),Y=F(""),L=F(!1),N=F(0),V=F(0),z=F(!0),q=F(1),Q=F(1),K=F(null),ee=F(null),se=F(null),pe=F(null),te=[.25,.5,.75,1,1.25,1.5,2,3],fe=F(1);function ve(){const me=te.find(he=>he>fe.value+.01);me&&(fe.value=me)}function ce(){const me=[...te].reverse().find(he=>heg.value==="file"?!!b.value:C.value.startsWith("http")),We=E(()=>M.value.filter(me=>me.status==="pending").length),nt=E(()=>M.value.filter(me=>me.status==="recognizing").length),dt=E(()=>M.value.filter(me=>me.type==="A"&&me.status==="pending").length),Fe=E(()=>M.value.filter(me=>me.status==="done")),Be=E(()=>M.value.find(me=>me.id===B.value)||null),et=E(()=>N.value>0?Math.round(V.value/N.value*100):0);be([z,k],()=>{z.value&&(q.value=k.value+1)}),be(x,me=>{me>0&&(Q.value=me),z.value&&(q.value=k.value+1)}),be(q,me=>{const he=Q.value;me<1?q.value=1:me>he&&(q.value=he)}),be(Q,me=>{const he=x.value||1;mehe&&(Q.value=he)});function Wt(me,he){if(!Array.isArray(me)||!me.length)return[];const Re=Math.max(0,(he||1)-1);return me.map(it=>{const qe=Number.isFinite(it.page)?Math.min(Math.max(it.page,0),Re):0;return{id:it.id||s(),type:it.type,page:qe,xr:it.xr,yr:it.yr,wr:it.wr,hr:it.hr,status:"pending",text:"",boxes:[],tokens:null,rows:[],parts1:{},b_table_rows:[],d_rows:[]}})}let qt=null;Pt(async()=>{try{const Re=await(await fetch(`${n}/api/manual/engine-info`)).json();H.value=Re.status==="ready"?"ready":"error",ae.value=Re.error||Re.engine||""}catch(he){H.value="error",ae.value=he.message}const me=document.getElementById("hdpdfurl2");if(me&&me.value&&me.value.trim()&&(C.value=me.value.trim(),g.value="url",await gt()),me){let he=me.value;qt=setInterval(async()=>{const Re=me.value?me.value.trim():"";Re&&Re!==he&&(he=Re,C.value=Re,g.value="url",await gt())},2e3)}});async function ct(me){b.value=me.raw,await gt(),pe.value&&pe.value.clearFiles()}async function gt(){w.value=!0;const me=M.value.map(Re=>({id:Re.id,type:Re.type,page:Re.page,xr:Re.xr,yr:Re.yr,wr:Re.wr,hr:Re.hr})),he=B.value;try{let Re,it=null;if(g.value==="file"){it=await b.value.arrayBuffer();const lt=new FormData;lt.append("file",b.value),lt.append("is_shj",U.value?"true":"false"),Re=await fetch(`${n}/api/manual/upload`,{method:"POST",body:lt})}else Re=await fetch(`${n}/api/manual/upload-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:C.value.trim(),is_shj:!!U.value})});if(!Re.ok){const lt=await Re.json().catch(()=>({}));throw new Error(lt.detail||`HTTP ${Re.status}`)}const qe=await Re.json();if(_.value&&fetch(`${n}/api/manual/session/${_.value}`,{method:"DELETE"}).catch(()=>{}),_.value=qe.session_id,x.value=qe.total_pages,k.value=0,M.value=Wt(me,qe.total_pages),B.value=M.value.some(lt=>lt.id===he)?he:null,T.value=!0,fe.value=1,!it){const lt=await fetch(`${n}/api/manual/pdf/${qe.session_id}`);if(!lt.ok)throw new Error(`获取 PDF 字节失败 HTTP ${lt.status}`);it=await lt.arrayBuffer()}await xe(it),ts.success(`PDF 加载成功,共 ${qe.total_pages} 页`)}catch(Re){ts.error(`加载失败:${Re.message}`)}finally{w.value=!1}}function Ot(me){me<0||me>=x.value||(k.value=me)}be(k,me=>{rt(),Ue(me)}),be([k,M],async()=>{T.value&&(await ze(),ot())},{deep:!0}),be(De,me=>{me==="draw"&&ee.value&&(ee.value.style.cursor="")}),be(fe,()=>{T.value&&I.value&&Ue(k.value)});async function xe(me){try{const he=z4e({data:me,cMapUrl:"/pdfjs-cmaps/",cMapPacked:!0});I.value=await he.promise,Ue(0)}catch(he){ts.error(`PDF.js 加载失败:${he.message}`)}}async function Ue(me){if(I.value){R&&(R.cancel(),R=null),O.value=!0;try{const he=await I.value.getPage(me+1),Re=window.devicePixelRatio||1,it=he.getViewport({scale:fe.value*Re}),qe=se.value;qe.width=it.width,qe.height=it.height,qe.style.width=it.width/Re+"px",qe.style.height=it.height/Re+"px";const lt=qe.getContext("2d");R=he.render({canvasContext:lt,viewport:it}),await R.promise,R=null,Ye()}catch(he){(he==null?void 0:he.name)!=="RenderingCancelledException"&&ts.error(`页面渲染失败:${he.message}`)}finally{O.value=!1}}}let we=null;function Ye(){const me=se.value,he=ee.value;if(!me||!he)return;const Re=me.offsetWidth,it=me.offsetHeight;Re===0||it===0||((he.width!==Re||he.height!==it)&&(he.width=Re,he.height=it),ot(),we||(we=new ResizeObserver(()=>Ye())),we.disconnect(),we.observe(me))}window.addEventListener("resize",()=>{T.value&&Ye()});function At(me){const he=ee.value.getBoundingClientRect();return{x:me.clientX-he.left,y:me.clientY-he.top}}function Jt(me){$e.value&&(K.value.scrollLeft=Ce.value-me.clientX,K.value.scrollTop=Oe.value-me.clientY)}function Cn(){$e.value&&($e.value=!1,ee.value&&(ee.value.style.cursor=""),window.removeEventListener("mousemove",Jt),window.removeEventListener("mouseup",Cn))}function xn(me){if(!de.value)return;const{x:he,y:Re}=At(me);Se.value=he,Le.value=Re,ot()}function Ve(me){if(!de.value)return;const{x:he,y:Re}=At(me);de.value=!1,window.removeEventListener("mousemove",xn),window.removeEventListener("mouseup",Ve);const it=ee.value,qe=it.width,lt=it.height,vt=Ii=>Math.max(0,Math.min(qe,Ii)),Ft=Ii=>Math.max(0,Math.min(lt,Ii)),ft=vt(he),ke=Ft(Re),tt=vt(ye.value),Ne=Ft(_e.value),St=Math.min(tt,ft),qn=Math.min(Ne,ke),Zn=Math.abs(ft-tt),Ri=Math.abs(ke-Ne);Zn>8&&Ri>8&&M.value.push({id:s(),type:$.value,region_code:m($.value),page:k.value,xr:St/qe,yr:qn/lt,wr:Zn/qe,hr:Ri/lt,cx:St,cy:qn,cw:Zn,ch:Ri,status:"pending",text:"",boxes:[],tokens:null,rows:[],parts1:{},b_table_rows:[],d_rows:[]}),rt(),ot()}function st(me){me.preventDefault();const{x:he,y:Re}=At(me);De.value==="draw"?(de.value=!0,ye.value=he,_e.value=Re,Se.value=he,Le.value=Re,window.addEventListener("mousemove",xn),window.addEventListener("mouseup",Ve)):De.value==="pan"&&($e.value=!0,Ce.value=me.clientX+K.value.scrollLeft,Oe.value=me.clientY+K.value.scrollTop,ee.value.style.cursor="grabbing",window.addEventListener("mousemove",Jt),window.addEventListener("mouseup",Cn))}function _t(me){}function kn(me){}function Zt(){}function rt(){de.value=!1,ye.value=0,_e.value=0,Se.value=0,Le.value=0}function ot(){const me=ee.value;if(!me)return;const he=me.getContext("2d");he.clearRect(0,0,me.width,me.height);const Re=me.width,it=me.height;for(const qe of M.value){if(qe.page!==k.value)continue;const lt=qe.xr*Re,vt=qe.yr*it,Ft=qe.wr*Re,ft=qe.hr*it,ke=d(qe.type),tt=qe.id===B.value;he.strokeStyle=ke,he.lineWidth=tt?3:2,he.setLineDash(qe.status==="pending"?[5,3]:[]),he.strokeRect(lt,vt,Ft,ft),he.fillStyle=ke+"18",he.fillRect(lt,vt,Ft,ft);const Ne=qe.type==="C"?`${p(qe)} ${h(qe.type)}`:`${qe.type} ${h(qe.type)}`;he.font="bold 12px sans-serif";const St=he.measureText(Ne).width+10;he.fillStyle=ke,he.fillRect(lt,vt-18,St,18),he.fillStyle="#fff",he.fillText(Ne,lt+5,vt-4)}if(de.value){const qe=Math.min(ye.value,Se.value),lt=Math.min(_e.value,Le.value),vt=Math.abs(Se.value-ye.value),Ft=Math.abs(Le.value-_e.value),ft=d($.value);he.strokeStyle=ft,he.lineWidth=2,he.setLineDash([4,3]),he.strokeRect(qe,lt,vt,Ft),he.fillStyle=ft+"15",he.fillRect(qe,lt,vt,Ft)}}function Rt(me){B.value=me.id,me.page!==k.value?Ot(me.page):ot()}function Es(me){M.value=M.value.filter(he=>he.id!==me),B.value===me&&(B.value=null),ot()}function sa(){M.value=[],B.value=null,ot()}async function Io(){var vt;const me=M.value.find(Ft=>Ft.type==="A");if(!me)return;M.value.filter(Ft=>Ft.type==="A"&&Ft.status==="pending").forEach(Ft=>{Ft.status="recognizing"});const he=q.value-1,Re=Q.value-1,it=Re-he+1;L.value=!0,N.value=it,V.value=0;const qe=Math.max(800,Math.round(3500*Math.ceil(it/10)/it)),lt=setInterval(()=>{V.value({}));throw new Error(Ne.detail||`HTTP ${Ft.status}`)}const ft=await Ft.json();V.value=N.value;const ke=(vt=ft.usage)!=null&&vt.total_tokens?Math.round(ft.usage.total_tokens/(ft.total_pages||1)):null;for(const Ne of ft.results){let St=M.value.find(Zn=>Zn.type==="A"&&Zn.page===Ne.page_index);St||(St={id:s(),type:"A",page:Ne.page_index,xr:me.xr,yr:me.yr,wr:me.wr,hr:me.hr,cx:me.cx,cy:me.cy,cw:me.cw,ch:me.ch,status:"pending",text:"",boxes:[],tokens:null,rows:[],b_table_rows:[]},M.value.push(St));const qn=Ne.rows||[];St.rows=qn,St.tokens=ke,St.text=qn.length?qn.map(Zn=>[Zn.seq_no??"",Zn.category??"",Zn.description??"",Zn.nominal_dia_mm??"",Zn.qty??""].filter(Ii=>Ii!=="").join(" | ")).join(` `):"(该页无材料明细行)",St.status=Ne._validation_failed?"error":"done"}const tt=ft.results.filter(Ne=>Ne._validation_failed).length;tt>0?ts.warning(`VL 识别完成,${ft.total_pages} 页中 ${tt} 页校验未通过(内容可能为空)`):ts.success(`VL 识别完成,共 ${ft.total_pages} 页`)}catch(Ft){clearInterval(lt),M.value.filter(ft=>ft.type==="A").forEach(ft=>{ft.status==="recognizing"&&(ft.status="error")}),ts.error(`VL 识别失败:${Ft.message}`)}finally{L.value=!1}}function C0(me){return!Array.isArray(me)||!me.length?"":me.map(he=>{const Re=String((he==null?void 0:he.name)||"").trim(),it=String((he==null?void 0:he.value)||"").trim();return!Re&&!it?null:`${Re}: ${it}`}).filter(Boolean).join(` `)}function jl(me){if(!Array.isArray(me))return"";const he=me.find(Re=>{const it=String((Re==null?void 0:Re.name)||"").toLowerCase();return it.includes("pipeline")||it.includes("line")||it.includes("管段")||it.includes("管线")});return String((he==null?void 0:he.value)||"").trim()}function S0(me){return!Array.isArray(me)||!me.length?"":me.map(he=>{const Re=(he==null?void 0:he.group_index)??"",it=(he==null?void 0:he.pos_no)??"",qe=(he==null?void 0:he.length_mm)??"",lt=(he==null?void 0:he.dn)??"";return`组${Re} | ${it} | ${qe} | ${lt}`}).join(` `)}async function Vr(){var it;const me=M.value.find(qe=>qe.type==="B");if(!me)return;M.value.filter(qe=>qe.type==="B"&&qe.status==="pending").forEach(qe=>{qe.status="recognizing"});const he=q.value-1,Re=Q.value-1;try{const qe=await fetch(`${n}/api/manual/ocr-all-pages-vl-b-ru`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:_.value,x_ratio:me.xr,y_ratio:me.yr,w_ratio:me.wr,h_ratio:me.hr,concurrency:5,start_page:he,end_page:Re})});if(!qe.ok){const Ft=await qe.json().catch(()=>({}));throw new Error(Ft.detail||`HTTP ${qe.status}`)}const lt=await qe.json(),vt=(it=lt.usage)!=null&&it.total_tokens?Math.round(lt.usage.total_tokens/(lt.total_pages||1)):null;for(const Ft of lt.results){let ft=M.value.find(tt=>tt.type==="B"&&tt.page===Ft.page_index);ft||(ft={id:s(),type:"B",page:Ft.page_index,xr:me.xr,yr:me.yr,wr:me.wr,hr:me.hr,cx:me.cx,cy:me.cy,cw:me.cw,ch:me.ch,status:"pending",text:"",boxes:[],tokens:null,parts1:{},b_table_rows:[]},M.value.push(ft));const ke=Ft.table_rows||[];ft.b_table_rows=Array.isArray(ke)?ke:[],ft.parts1={},ft.text=C0(ft.b_table_rows),ft.tokens=vt,ft.status=Ft.parse_error||!ft.text?"error":"done"}}catch(qe){M.value.filter(lt=>lt.type==="B"&<.status==="recognizing").forEach(lt=>{lt.status="error"}),ts.error(`管线号 VL 识别失败:${qe.message}`)}}function o2(){var me,he,Re,it,qe;for(const lt of M.value.filter(vt=>vt.type==="B"&&vt.status==="done")){const vt=((he=(me=lt.parts1)==null?void 0:me.pipeline_id)==null?void 0:he.trim())||jl(lt.b_table_rows)||((it=(Re=lt.text)==null?void 0:Re.split(`