@copio/sdk 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +204 -2
  2. package/css/container.css +177 -0
  3. package/css/cropper.css +306 -0
  4. package/css/main.css +139 -0
  5. package/css/reset.css +204 -0
  6. package/css/shoelace.css +485 -0
  7. package/css/utils.css +689 -0
  8. package/dist/adapters/image/canvas2d-adapter.js +2 -0
  9. package/dist/adapters/image/canvas2d-adapter.js.map +7 -0
  10. package/dist/adapters/image/index.js +2 -0
  11. package/dist/adapters/image/index.js.map +7 -0
  12. package/dist/adapters/image/null-image-processor-adapter.js +2 -0
  13. package/dist/adapters/image/null-image-processor-adapter.js.map +7 -0
  14. package/dist/adapters/index.js +2 -0
  15. package/dist/adapters/index.js.map +7 -0
  16. package/dist/adapters/indexeddb-adapter.js +2 -0
  17. package/dist/adapters/indexeddb-adapter.js.map +7 -0
  18. package/dist/adapters/memory-adapter.js +2 -0
  19. package/dist/adapters/memory-adapter.js.map +7 -0
  20. package/dist/adapters/ocr/index.js +2 -0
  21. package/dist/adapters/ocr/index.js.map +7 -0
  22. package/dist/adapters/ocr/null-ocr-adapter.js +2 -0
  23. package/dist/adapters/ocr/null-ocr-adapter.js.map +7 -0
  24. package/dist/adapters/ocr/tesseract-wasm-adapter.js +2 -0
  25. package/dist/adapters/ocr/tesseract-wasm-adapter.js.map +7 -0
  26. package/dist/adapters/pdf/index.js +2 -0
  27. package/dist/adapters/pdf/index.js.map +7 -0
  28. package/dist/adapters/pdf/null-pdf-adapter.js +2 -0
  29. package/dist/adapters/pdf/null-pdf-adapter.js.map +7 -0
  30. package/dist/adapters/pdf/pdfkit-adapter.js +2 -0
  31. package/dist/adapters/pdf/pdfkit-adapter.js.map +7 -0
  32. package/dist/adapters/storage/index.js +2 -0
  33. package/dist/adapters/storage/index.js.map +7 -0
  34. package/dist/adapters/storage/indexeddb-adapter.js +2 -0
  35. package/dist/adapters/storage/indexeddb-adapter.js.map +7 -0
  36. package/dist/adapters/storage/memory-adapter.js +2 -0
  37. package/dist/adapters/storage/memory-adapter.js.map +7 -0
  38. package/dist/adapters/sync/index.js +2 -0
  39. package/dist/adapters/sync/index.js.map +7 -0
  40. package/dist/adapters/sync/null-sync-adapter.js +2 -0
  41. package/dist/adapters/sync/null-sync-adapter.js.map +7 -0
  42. package/dist/adapters/sync/peerjs-adapter.js +2 -0
  43. package/dist/adapters/sync/peerjs-adapter.js.map +7 -0
  44. package/dist/canvas-FAXPLPXN.js +2 -0
  45. package/dist/cdn.js +2770 -0
  46. package/dist/chunk-36F637QU.js +2 -0
  47. package/dist/chunk-4C666HHU.js +2 -0
  48. package/dist/chunk-4GEMGDRU.js +1 -0
  49. package/dist/chunk-4JPEWIT4.js +2 -0
  50. package/dist/chunk-A5G52Q2W.js +2 -0
  51. package/dist/chunk-B2EK6INF.js +2 -0
  52. package/dist/chunk-B5BEYYR2.js +8 -0
  53. package/dist/chunk-B7HT2X67.js +2 -0
  54. package/dist/chunk-BKZEOOH4.js +2 -0
  55. package/dist/chunk-CWCS22CQ.js +1 -0
  56. package/dist/chunk-DGGK5KEX.js +2 -0
  57. package/dist/chunk-E7JYVRJA.js +2 -0
  58. package/dist/chunk-G65H4ZTJ.js +2 -0
  59. package/dist/chunk-HN3336JN.js +2 -0
  60. package/dist/chunk-IUBYFIV6.js +12 -0
  61. package/dist/chunk-K6YP7EET.js +8 -0
  62. package/dist/chunk-K7RTGT3Q.js +2601 -0
  63. package/dist/chunk-KIMVF5UG.js +2 -0
  64. package/dist/chunk-LI54F6PA.js +2 -0
  65. package/dist/chunk-N4R55VRR.js +2 -0
  66. package/dist/chunk-N7Q34F2P.js +4 -0
  67. package/dist/chunk-OI4WCW7E.js +2 -0
  68. package/dist/chunk-PUJYN435.js +1 -0
  69. package/dist/chunk-PVNRK4OH.js +2 -0
  70. package/dist/chunk-QPUCXOOR.js +2 -0
  71. package/dist/chunk-SH4P4XSZ.js +2 -0
  72. package/dist/chunk-UCV3MQ6I.js +33 -0
  73. package/dist/chunk-V2FP4EEH.js +2 -0
  74. package/dist/chunk-V6E2SSSW.js +1 -0
  75. package/dist/chunk-XEN5VKAV.js +19 -0
  76. package/dist/chunk-YHLOPPXM.js +2 -0
  77. package/dist/core.js +2 -0
  78. package/dist/custom-elements.json +4779 -0
  79. package/dist/export.js +2 -0
  80. package/dist/fs-HJ6WWW73.js +2 -0
  81. package/dist/http-FKJJMT2N.js +2 -0
  82. package/dist/https-MUBFLDZM.js +2 -0
  83. package/dist/index.js +99 -0
  84. package/dist/ocr.js +2 -0
  85. package/dist/path2d-QWN6DFCC.js +2 -0
  86. package/dist/scanner.js +2631 -0
  87. package/dist/sync.js +2 -0
  88. package/dist/types/js/adapters/image/canvas2d-adapter.d.ts +42 -0
  89. package/dist/types/js/adapters/image/image-processor-port.d.ts +41 -0
  90. package/dist/types/js/adapters/image/index.d.ts +3 -0
  91. package/dist/types/js/adapters/image/null-image-processor-adapter.d.ts +13 -0
  92. package/dist/types/js/adapters/ocr/index.d.ts +3 -0
  93. package/dist/types/js/adapters/ocr/null-ocr-adapter.d.ts +39 -0
  94. package/dist/types/js/adapters/ocr/ocr-port.d.ts +139 -0
  95. package/dist/types/js/adapters/ocr/tesseract-wasm-adapter.d.ts +40 -0
  96. package/dist/types/js/adapters/pdf/index.d.ts +3 -0
  97. package/dist/types/js/adapters/pdf/null-pdf-adapter.d.ts +23 -0
  98. package/dist/types/js/adapters/pdf/pdf-port.d.ts +21 -0
  99. package/dist/types/js/adapters/pdf/pdfkit-adapter.d.ts +16 -0
  100. package/dist/types/js/adapters/storage/index.d.ts +22 -0
  101. package/dist/types/js/adapters/storage/indexeddb-adapter.d.ts +109 -0
  102. package/dist/types/js/adapters/storage/memory-adapter.d.ts +101 -0
  103. package/dist/types/js/adapters/storage/storage-port.d.ts +113 -0
  104. package/dist/types/js/adapters/sync/index.d.ts +3 -0
  105. package/dist/types/js/adapters/sync/null-sync-adapter.d.ts +14 -0
  106. package/dist/types/js/adapters/sync/peerjs-adapter.d.ts +16 -0
  107. package/dist/types/js/adapters/sync/sync-port.d.ts +18 -0
  108. package/dist/types/js/components/copio-header.d.ts +19 -0
  109. package/dist/types/js/components/copio-loader.d.ts +6 -0
  110. package/dist/types/js/core/store.d.ts +2 -0
  111. package/dist/types/js/routes/add-edit/copio-add-edit-dialog.d.ts +9 -0
  112. package/dist/types/js/routes/doc/copio-carousel.d.ts +43 -0
  113. package/dist/types/js/routes/doc/copio-images.d.ts +37 -0
  114. package/dist/types/js/routes/home/copio-row.d.ts +49 -0
  115. package/dist/types/js/routes/ocr/copio-doc-ocr-dialog.d.ts +97 -0
  116. package/dist/types/js/routes/sync/copio-sync-dialog.d.ts +13 -0
  117. package/dist/types/js/services/doc-repository.d.ts +233 -0
  118. package/dist/types/js/services/export-utils.d.ts +42 -0
  119. package/dist/types/js/services/ice-servers.d.ts +1 -0
  120. package/dist/types/js/services/notify.d.ts +82 -0
  121. package/dist/types/js/services/ocr-service.d.ts +64 -0
  122. package/dist/types/js/services/sync-service.d.ts +11 -0
  123. package/dist/types/js/styles/cropper-styles.d.ts +5 -0
  124. package/dist/types/js/utils/module-loader.d.ts +76 -0
  125. package/dist/types/js/utils/pdf-utils.d.ts +7 -0
  126. package/dist/types/js/utils/utils.d.ts +54 -0
  127. package/dist/types/sdk/cdn.d.ts +7 -0
  128. package/dist/types/sdk/core.d.ts +310 -0
  129. package/dist/types/sdk/elements.d.ts +25 -0
  130. package/dist/types/sdk/events.d.ts +227 -0
  131. package/dist/types/sdk/index.d.ts +37 -0
  132. package/dist/types/sdk/license.d.ts +12 -0
  133. package/dist/types/sdk/models.d.ts +174 -0
  134. package/dist/types/sdk/scanner.d.ts +68 -0
  135. package/dist/types/sdk/styles.d.ts +21 -0
  136. package/dist/types/sdk/sync.d.ts +7 -0
  137. package/dist/types/sdk/version.d.ts +2 -0
  138. package/dist/url-ABJ6S2Y6.js +2 -0
  139. package/package.json +73 -4
  140. package/sdk/cdn.js +13 -0
  141. package/sdk/core.js +961 -0
  142. package/sdk/events.js +99 -0
  143. package/sdk/index.js +137 -0
  144. package/sdk/license.js +28 -0
  145. package/sdk/models.js +177 -0
  146. package/sdk/scanner.js +1597 -0
  147. package/sdk/styles.js +1236 -0
  148. package/sdk/sync.js +12 -0
  149. package/sdk/version.js +7 -0
@@ -0,0 +1,2631 @@
1
+ /* @copio/sdk <copio-scanner> Web Component bundle */
2
+ var dh=Object.defineProperty;var Qi=(s,t,e)=>()=>{if(e)throw e[0];try{return s&&(t=s(s=0)),t}catch(i){throw e=[i],i}};var Zi=(s,t)=>{for(var e in t)dh(s,e,{get:t[e],enumerable:!0})};var ho={};Zi(ho,{Path2D:()=>Wd,createCanvas:()=>Gd,default:()=>Vd});var Vd,Gd,Wd,uo=Qi(()=>{Vd={},Gd=()=>null,Wd=globalThis.Path2D||class{}});var Pc={};Zi(Pc,{Path2D:()=>Kd,createCanvas:()=>Xd,default:()=>qd});var qd,Xd,Kd,Dc=Qi(()=>{qd={},Xd=()=>null,Kd=globalThis.Path2D||class{}});var Ic={};Zi(Ic,{Path2D:()=>Qd,createCanvas:()=>Jd,default:()=>Yd});var Yd,Jd,Qd,Mc=Qi(()=>{Yd={},Jd=()=>null,Qd=globalThis.Path2D||class{}});var Rc={};Zi(Rc,{Path2D:()=>eu,createCanvas:()=>tu,default:()=>Zd});var Zd,tu,eu,Lc=Qi(()=>{Zd={},tu=()=>null,eu=globalThis.Path2D||class{}});var Fc={};Zi(Fc,{Path2D:()=>nu,createCanvas:()=>su,default:()=>iu});var iu,su,nu,Oc=Qi(()=>{iu={},su=()=>null,nu=globalThis.Path2D||class{}});var Nc={};Zi(Nc,{Path2D:()=>ou,createCanvas:()=>au,default:()=>ru});var ru,au,ou,Bc=Qi(()=>{ru={},au=()=>null,ou=globalThis.Path2D||class{}});var xi=class{async init(){throw new Error("StoragePort.init() must be implemented by adapter")}async listDocs(){throw new Error("StoragePort.listDocs() must be implemented by adapter")}async getDoc(t){throw new Error("StoragePort.getDoc() must be implemented by adapter")}async saveDoc(t,e){throw new Error("StoragePort.saveDoc() must be implemented by adapter")}async deleteDoc(t){throw new Error("StoragePort.deleteDoc() must be implemented by adapter")}async savePage(t,e,i){throw new Error("StoragePort.savePage() must be implemented by adapter")}async getPage(t,e){throw new Error("StoragePort.getPage() must be implemented by adapter")}async deletePage(t,e){throw new Error("StoragePort.deletePage() must be implemented by adapter")}subscribe(t){return()=>{}}};var ts=class extends xi{#t=new Map;#e=new Map;#i=new Set;constructor(){super()}async init(){return{kind:"memory",persistent:!1}}listDocsSync(){return Array.from(this.#t.values()).map(t=>({id:t.id,name:t.name,pages:Array.isArray(t.pages)?[...t.pages]:[]}))}async listDocs(){return this.listDocsSync()}getDocSync(t){let e=this.#t.get(t);return e?{id:e.id,name:e.name,pages:Array.isArray(e.pages)?[...e.pages]:[]}:null}async getDoc(t){return this.getDocSync(t)}async saveDoc(t,e){if(!t)throw new Error("Cannot save document without an ID");let i=[];if(Array.isArray(e.pages))i=[...e.pages];else if(typeof e.pages=="string")try{i=JSON.parse(e.pages)}catch{i=[]}this.#t.set(t,{id:t,name:e.name||"",pages:i}),this.#n()}async deleteDoc(t){this.#t.delete(t);let e=`${t}/`;for(let i of this.#e.keys())i.startsWith(e)&&this.#e.delete(i);this.#n()}async savePage(t,e,i){this.#e.set(`${t}/${e}`,i);let n=this.#t.get(t);if(n){let o=n.pages.findIndex(h=>h.id===e);if(o>=0)typeof i=="object"&&i!==null&&!(i instanceof Blob)?n.pages[o]={...n.pages[o],...i}:n.pages[o]={...n.pages[o],src:i};else{let h=typeof i=="object"&&i!==null&&!(i instanceof Blob)?{id:e,...i}:{id:e,src:i};n.pages.push(h)}}this.#n()}async getPage(t,e){if(this.#e.has(`${t}/${e}`))return this.#e.get(`${t}/${e}`);let i=this.#t.get(t);if(i){let n=i.pages.find(o=>o.id===e);if(n)return n.src??n}return null}async deletePage(t,e){this.#e.delete(`${t}/${e}`);let i=this.#t.get(t);i&&(i.pages=i.pages.filter(n=>n.id!==e)),this.#n()}subscribe(t){return this.#i.add(t),()=>{this.#i.delete(t)}}clear(){this.#t.clear(),this.#e.clear(),this.#n()}#n(){for(let t of this.#i)try{t()}catch(e){console.error("Error in MemoryStorageAdapter subscriber:",e)}}};var di=s=>typeof s;var tl=di(""),uh=di(!0),el=di(0),ph=di(di),On="type",Ai="default",aa="Listener",Wo="Result",oa="add",Si="Has",Ns="Ids",hi="Table",qo=hi+"s",fh=hi+Ns,ns="Row",il=ns+"Count",sl=ns+Ns,gh="Sorted"+ns+Ns,Ls="Cell",$n=Ls+Ns,Hn="Value",Xo=Hn+"s",mh=Hn+Ns,Ot=s=>""+s;var bh=(s,t="",e)=>s.split(t,e),la=globalThis,Wn=Math,ta=Wn.max,ea=Wn.min,vh=Wn.floor,nl=isFinite,St=s=>s==null,Nt=(s,t,e)=>St(s)?e?.():t(s),rl=s=>s==tl||s==uh,yh=s=>di(s)==tl,Ue=s=>di(s)==ph,rs=s=>Array.isArray(s),ca=(s,t,e)=>s.slice(t,e),Ee=s=>s.length,al=()=>{};var ia=async(s,t,e)=>{try{return await s()}catch(i){t?.(i)}},ha=(s,t)=>s.includes(t),zn=(s,t)=>s.every(t),ol=(s,t)=>Ee(s)===Ee(t)&&zn(s,((e,i)=>t[i]===e)),Ko=(s,t)=>zn(s,((e,i)=>i==0||t(s[i-1],e)<=0)),da=(s,t)=>s.sort(t),ye=(s,t)=>s.forEach(t),Ci=(s,t)=>s.map(t),Yo=s=>ll(s,((t,e)=>t+e),0),Fs=s=>Ee(s)==0,ll=(s,t,e)=>s.reduce(t,e),ve=(s,...t)=>s.push(...t),Jo=s=>s.pop(),cl=s=>s.shift(),is=s=>{let t=di(s);return rl(t)||t==el&&nl(s)?t:void 0};var jn=(s,t,e,i,n)=>St(n)?s.delCell(t,e,i,!0):s.setCell(t,e,i,n),ua=(s,t,e)=>St(e)?s.delValue(t):s.setValue(t,e),ma=s=>t=>ll(as(t),((e,i)=>e+s(i)),0),os=s=>s?.size??0,ki=ma(os),Xe=ma(ki),sa=ma(Xe),$t=(s,t)=>s?.has(t)??!1,yt=s=>St(s)||os(s)==0,as=s=>[...s?.values()??[]],ss=s=>s.clear(),vt=(s,t)=>s?.forEach(t),He=(s,t)=>s?.delete(t),ui=Object,Qo=s=>ui.getPrototypeOf(s),wh=ui.isFrozen,hl=ui.entries,Vn=s=>!St(s)&&Nt(Qo(s),(t=>t==ui.prototype||St(Qo(t))),(()=>!0)),xh=ui.keys,ls=ui.freeze,Ah=(s=[])=>ui.fromEntries(s),Rs=(s,t)=>t in s,dl=(s,t)=>(delete s[t],s),Sh=(s,t)=>ye(hl(s),(([e,i])=>t(i,e))),qe=(s,t)=>Ah(((e,i)=>Ci(hl(e),(([n,o])=>i(o,n))))(s,((e,i)=>[i,t(e,i)]))),$e=s=>Vn(s)&&(t=>Ee(xh(t)))(s)==0;var li=(s,t,e,i=0)=>St(s)||!Vn(s)||!i&&$e(s)||wh(s)?(e?.(),!1):(Sh(s,((n,o)=>{t(n,o)||dl(s,o)})),!!i||!$e(s)),ft=s=>new Map(s),_i=s=>[...s?.keys()??[]],ht=(s,t)=>s?.get(t),Xt=(s,t)=>vt(s,((e,i)=>t(i,e))),bt=(s,t,e)=>St(e)?(He(s,t),s):s?.set(t,e),Ut=(s,t,e,i)=>($t(s,t)?i?.(ht(s,t)):bt(s,t,e()),ht(s,t)),Ei=(s,t,e,i=bt)=>(qe(t,((n,o)=>e(s,o,n))),Xt(s,(n=>Rs(t,n)?0:i(s,n))),s),be=(s,t,e,i)=>{let n={};return vt(s,((o,h)=>{if(!e?.(o,h)){let u=t?t(o,h):o;i?.(u)||(n[h]=u)}})),n},pa=(s,t,e)=>be(s,(i=>be(i,t,e)),yt,$e),Nn=(s,t,e)=>be(s,(i=>pa(i,t,e)),yt,$e),ci=(s,t)=>{let e=ft();return vt(s,((i,n)=>e.set(n,t?.(i)??i))),e},fa=s=>ci(s,ci),na=s=>ci(s,fa),Os=(s,t,e,i,n=0)=>Nt((e?Ut:ht)(s,t[n],n>Ee(t)-2?e:ft),(o=>{if(n>Ee(t)-2)return i?.(o)&&bt(s,t[n]),o;let h=Os(o,t,e,i,n+1);return yt(o)&&bt(s,t[n]),h})),Kt=s=>new Set(rs(s)||St(s)?s:[s]),zt=(s,t)=>s?.add(t),qn=(s,t,e,i,n)=>{let o=s.hasRow,h=ft(),u=ft(),g=ft(),v=ft(),p=ft(),a=ft(),f=(y,r,...l)=>{let m=Ut(a,y,Kt);return ye(l,(x=>zt(m,x)&&r&&s.callListener(x))),l},A=(y,...r)=>Nt(ht(a,y),(l=>{ye(Fs(r)?as(l):r,(m=>{s.delListener(m),He(l,m)})),yt(l)&&bt(a,y)})),_=(y,r)=>{bt(h,y,r),$t(u,y)||(bt(u,y,t()),bt(v,y,ft()),bt(p,y,ft()),n(g))},d=y=>{bt(h,y),bt(u,y),bt(v,y),bt(p,y),A(y),n(g)};return[()=>s,()=>_i(h),y=>Xt(u,y),y=>$t(u,y),y=>ht(h,y),y=>ht(u,y),(y,r)=>bt(u,y,r),_,(y,r,l,m,x)=>{_(y,r);let D=ft(),E=ft(),M=ht(v,y),N=ht(p,y),H=K=>{let it=j=>s.getCell(r,K,j),ot=ht(M,K),X=o(r,K)?e(m(it,K)):void 0;if(ot===X||rs(ot)&&rs(X)&&ol(ot,X)||bt(D,K,[ot,X]),!St(x)){let j=ht(N,K),G=o(r,K)?x(it,K):void 0;j!=G&&bt(E,K,G)}},z=K=>{l((()=>{vt(D,(([,it],ot)=>bt(M,ot,it))),vt(E,((it,ot)=>bt(N,ot,it)))}),D,E,M,N,K),ss(D),ss(E)};Xt(M,H),s.hasTable(r)&&ye(s.getRowIds(r),(K=>{$t(M,K)||H(K)})),z(!0),A(y),f(y,0,s.addRowListener(r,null,((K,it,ot)=>H(ot))),s.addTableListener(r,(()=>z())))},d,y=>i(y,g),()=>Xt(a,d),f,A]},Gn=(s,t)=>yh(s)?e=>e(s):s??(()=>t??""),Bs=(s,t)=>{let e=new WeakMap;return i=>{e.has(i)||e.set(i,s(i));let n=e.get(i);return t?.(n),n}},Eh=/^\d+$/,ul=()=>{let s=[],t=0;return[e=>(e?cl(s):null)??""+t++,e=>{Eh.test(e)&&Ee(s)<1e3&&ve(s,e)}]},Us=s=>{let t,[e,i]=ul(),n=ft();return[(o,h,u,g=[],v=()=>[])=>{t??=s();let p=e(1);return bt(n,p,[o,h,u,g,v]),zt(Os(h,u??[""],Kt),p),p},(o,h,...u)=>ye(((g,v=[""])=>{let p=[],a=(f,A)=>A==Ee(v)?ve(p,f):v[A]===null?vt(f,(_=>a(_,A+1))):ye([v[A],null],(_=>a(ht(f,_),A+1)));return a(g,0),p})(o,h),(g=>vt(g,(v=>ht(n,v)[0](t,...h??[],...u))))),o=>Nt(ht(n,o),(([,h,u])=>(Os(h,u??[""],void 0,(g=>(He(g,o),yt(g)?1:0))),bt(n,o),i(o),u))),o=>Nt(ht(n,o),(([h,,u=[],g,v])=>{let p=(...a)=>{let f=Ee(a);f==Ee(u)?h(t,...a,...v(a)):St(u[f])?ye(g[f]?.(...a)??[],(A=>p(...a,A))):p(...a,u[f])};p()}))]},Bu=Bs((s=>{let t,e,i,n=100,o=ft(),h=ft(),u=1,g=ft(),v=ft(),[p,a,f]=Us((()=>G)),A=ft(),_=ft(),d=[],y=[],r=(Y,et)=>{u=0,s.transaction((()=>{let[rt,ct]=ht(A,et);vt(rt,((st,W)=>vt(st,((w,T)=>vt(w,((R,c)=>jn(s,W,T,c,R[Y]))))))),vt(ct,((st,W)=>ua(s,W,st[Y])))})),u=1},l=Y=>{bt(A,Y),bt(_,Y),a(v,[Y])},m=(Y,et)=>ye(((rt,ct)=>rt.splice(0,ct))(Y,et??Ee(Y)),l),x=()=>m(d,Ee(d)-n),D=()=>Nt(t,(()=>{ve(d,t),x(),m(y),t=void 0,i=1})),E=()=>{t=Jo(d),i=1},M,N,H=(Y="")=>(St(t)&&(t=""+e++,bt(A,t,[o,h]),X(t,Y),o=ft(),h=ft(),i=1),t),z=()=>{Fs(d)||(((Y,...et)=>{Y.unshift(...et)})(y,H()),r(0,t),t=Jo(d),i=1)},K=()=>{Fs(y)||(ve(d,t),t=cl(y),r(1,t),i=1)},it=()=>{i&&(a(g),i=0)},ot=Y=>{let et=H(Y);return it(),et},X=(Y,et)=>(j(Y)&&ht(_,Y)!==et&&(bt(_,Y,et),a(v,[Y])),G),j=Y=>$t(A,Y),G={setSize:Y=>(n=Y,x(),G),addCheckpoint:ot,setCheckpoint:X,getStore:()=>s,getCheckpointIds:()=>[[...d],t,[...y]],forEachCheckpoint:Y=>Xt(_,Y),hasCheckpoint:j,getCheckpoint:Y=>ht(_,Y),goBackward:()=>(z(),it(),G),goForward:()=>(K(),it(),G),goTo:Y=>{let et=ha(d,Y)?z:ha(y,Y)?K:null;for(;!St(et)&&Y!=t;)et();return it(),G},addCheckpointIdsListener:Y=>p(Y,g),addCheckpointListener:(Y,et)=>p(et,v,[Y]),delListener:Y=>(f(Y),G),clear:()=>(m(d),m(y),St(t)||l(t),t=void 0,e=0,ot(),G),clearForward:()=>(Fs(y)||(m(y),a(g)),G),destroy:()=>{s.delListener(M),s.delListener(N)},getListenerStats:()=>({checkpointIds:ki(g),checkpoint:ki(v)}),_registerListeners:()=>{M=s.addCellListener(null,null,null,((Y,et,rt,ct,st,W)=>{if(u){D();let w=Ut(o,et,ft),T=Ut(w,rt,ft),R=Ut(T,ct,(()=>[W,void 0]));R[1]=st,R[0]===st&&yt(bt(T,ct))&&yt(bt(w,rt))&&yt(bt(o,et))&&E(),it()}})),N=s.addValueListener(null,((Y,et,rt,ct)=>{if(u){D();let st=Ut(h,et,(()=>[ct,void 0]));st[1]=rt,st[0]===rt&&yt(bt(h,et))&&E(),it()}}))}};return ls(G.clear())}),(s=>s._registerListeners())),_h=bh("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"),Uu=ft(Ci(_h,((s,t)=>[s,t])));var $u=la.crypto?s=>la.crypto.getRandomValues(s):s=>Ci(s,(()=>vh(256*Wn.random())));var Ch=JSON.stringify,ra=JSON.parse,es=s=>Ch(s,((t,e)=>{return i=Map,e instanceof i?ui.fromEntries([...e]):e;var i})),Hu=new la.TextEncoder;var zu=2**36,ju=2**30,Vu=2**24,Gu=2**18;var pl=(s,t)=>(s??0)<(t??0)?-1:1,Wu=Bs((s=>{let t=ft(),e=ft(),[i,n,o]=Us((()=>l)),[h,u,g,v,p,a,f,,A,_,d,y]=qn(s,ft,(m=>St(m)?"":rs(m)?Ci(m,Ot):Ot(m)),i,n),r=(m,x,D)=>{let E=p(m);vt(D,((M,N)=>x(N,(H=>vt(M,(z=>H(z,(K=>s.forEachCell(E,z,K)))))))))},l={setIndexDefinition:(m,x,D,E,M,N=pl)=>{let H=St(M)?void 0:([z],[K])=>M(z,K);return A(m,x,((z,K,it,ot,X,j)=>{let G=0,Y=Kt(),et=Kt(),rt=a(m);if(vt(K,(([ct,st],W)=>{let w=Kt(ct),T=Kt(st);vt(w,(R=>He(T,R)?He(w,R):0)),vt(w,(R=>{zt(Y,R),Nt(ht(rt,R),(c=>{He(c,W),yt(c)&&(bt(rt,R),G=1)}))})),vt(T,(R=>{zt(Y,R),$t(rt,R)||(bt(rt,R,Kt()),G=1),zt(ht(rt,R),W),St(E)||zt(et,R)}))})),z(),yt(X)||(j?Xt(rt,(ct=>zt(et,ct))):Xt(it,(ct=>Nt(ht(ot,ct),(st=>ye(rs(st)?st:[st],(W=>zt(et,W))))))),vt(et,(ct=>{let st=(w,T)=>N(ht(X,w),ht(X,T),ct),W=[...ht(rt,ct)];Ko(W,st)||(bt(rt,ct,Kt(da(W,st))),zt(Y,ct))}))),(G||j)&&!St(H)){let ct=[...rt];Ko(ct,H)||(f(m,ft(da(ct,H))),G=1)}G&&n(t,[m]),vt(Y,(ct=>n(e,[m,ct])))}),Gn(D),Nt(E,Gn)),l},delIndexDefinition:m=>(_(m),l),getStore:h,getIndexIds:u,forEachIndex:m=>g(((x,D)=>m(x,(E=>r(x,E,D))))),forEachSlice:(m,x)=>r(m,x,a(m)),hasIndex:v,hasSlice:(m,x)=>$t(a(m),x),getTableId:p,getSliceIds:m=>_i(a(m)),getSliceRowIds:(m,x)=>as(ht(a(m),x)),addIndexIdsListener:d,addSliceIdsListener:(m,x)=>i(x,t,[m]),addSliceRowIdsListener:(m,x,D)=>i(D,e,[m,x]),delListener:m=>(o(m),l),destroy:y,getListenerStats:()=>({sliceIds:ki(t),sliceRowIds:Xe(e)})};return ls(l)}));var Bn=s=>[s,s],Gt=(s,t=ki)=>t(s[0])+t(s[1]),Wt=()=>[ft(),ft()],Zo=s=>[...s],Un=([s,t])=>s===t,Ms=(s,t,e)=>bt(s,t,ht(s,t)==-e?void 0:e),$s=()=>{let s,t,e=!1,i=!1,n=0,o=[],h=ft(),u=ft(),g=ft(),v=ft(),p=ft(),a=ft(),f=ft(),A=ft(),_=ft(),d=ft(),y=ft(),r=ft(),l=ft(),m=ft(),x=Kt(),D=ft(),E=ft(),M=ft(),N=ft(),H=Wt(),z=Wt(),K=Wt(),it=Wt(),ot=Wt(),X=Wt(),j=Wt(),G=Wt(),Y=Wt(),et=Wt(),rt=Wt(),ct=Wt(),st=Wt(),W=Wt(),w=Wt(),T=Wt(),R=Wt(),c=Wt(),b=Wt(),C=Wt(),k=Wt(),O=Wt(),I=ft(),S=Wt(),[L,$,U,P]=Us((()=>ce)),F=B=>{if(!li(B,((J,at)=>ha([On,Ai],at))))return!1;let q=B[On];return!(!rl(q)&&q!=el)&&(is(B[Ai])!=q&&dl(B,Ai),!0)},V=rs,Q=(B,q)=>(!s||$t(y,q)||Ne(q))&&li(B,((J,at)=>Z(q,at,J)),(()=>Ne(q))),Z=(B,q,J,at)=>li(at?J:dt(J,B,q),((ut,mt)=>Nt(tt(B,q,mt,ut),(At=>(J[mt]=At,!0)),(()=>!1))),(()=>Ne(B,q))),tt=(B,q,J,at)=>s?Nt(ht(ht(y,B),J),(ut=>is(at)!=ut[On]?Ne(B,q,J,at,ut[Ai]):at),(()=>Ne(B,q,J,at))):St(is(at))?Ne(B,q,J,at):at,nt=(B,q)=>li(q?B:lt(B),((J,at)=>Nt(pt(at,J),(ut=>(B[at]=ut,!0)),(()=>!1))),(()=>wi())),pt=(B,q)=>t?Nt(ht(l,B),(J=>is(q)!=J[On]?wi(B,q,J[Ai]):q),(()=>wi(B,q))):St(is(q))?wi(B,q):q,dt=(B,q,J)=>(Nt(ht(r,q),(([at,ut])=>{vt(at,((mt,At)=>{Rs(B,At)||(B[At]=mt)})),vt(ut,(mt=>{Rs(B,mt)||Ne(q,J,mt)}))})),B),lt=B=>(t&&(vt(m,((q,J)=>{Rs(B,J)||(B[J]=q)})),vt(x,(q=>{Rs(B,q)||wi(q)}))),B),wt=B=>Ei(y,B,((q,J,at)=>{let ut=ft(),mt=Kt();Ei(Ut(y,J,ft),at,((At,Pt,It)=>{bt(At,Pt,It),Nt(It[Ai],(We=>bt(ut,Pt,We)),(()=>zt(mt,Pt)))})),bt(r,J,[ut,mt])}),((q,J)=>{bt(y,J),bt(r,J)})),Tt=B=>Ei(l,B,((q,J,at)=>{bt(l,J,at),Nt(at[Ai],(ut=>bt(m,J,ut)),(()=>zt(x,J)))}),((q,J)=>{bt(l,J),bt(m,J),He(x,J)})),xt=B=>$e(B)?Mn():Dn(B),Dt=B=>Ei(M,B,((q,J,at)=>Mt(J,at)),((q,J)=>si(J))),Mt=(B,q)=>Ei(Ut(M,B,(()=>(ri(B,1),bt(D,B,ul()),bt(E,B,ft()),ft()))),q,((J,at,ut)=>Bt(B,J,at,ut)),((J,at)=>ni(B,J,at))),Bt=(B,q,J,at,ut)=>Ei(Ut(q,J,(()=>(Xi(B,J,1),ft()))),at,((mt,At,Pt)=>Ht(B,J,mt,At,Pt)),((mt,At)=>ae(B,q,J,mt,At,ut))),Ht=(B,q,J,at,ut)=>{$t(J,at)||Ie(B,q,at,1);let mt=ht(J,at);ut!==mt&&(te(B,q,at,mt,ut),bt(J,at,ut))},le=(B,q,J,at,ut)=>Nt(ht(q,J),(mt=>Ht(B,J,mt,at,ut)),(()=>Bt(B,q,J,dt({[at]:ut},B,J)))),Ae=B=>$e(B)?Rn():In(B),Oe=B=>Ei(N,B,((q,J,at)=>ke(J,at)),((q,J)=>ie(J))),ke=(B,q)=>{$t(N,B)||An(B,1);let J=ht(N,B);q!==J&&(Ki(B,J,q),bt(N,B,q))},De=B=>ht(M,B)??Mt(B,{}),si=B=>Mt(B,{}),ni=(B,q,J)=>{let[,at]=ht(D,B);at(J),Bt(B,q,J,{},!0)},ae=(B,q,J,at,ut,mt)=>{let At=ht(ht(r,B)?.[0],ut);if(!St(At)&&!mt)return Ht(B,J,at,ut,At);let Pt=It=>{te(B,J,It,ht(at,It)),Ie(B,J,It,-1),bt(at,It)};St(At)?Pt(ut):Xt(at,Pt),yt(at)&&(Xi(B,J,-1),yt(bt(q,J))&&(ri(B,-1),bt(M,B),bt(D,B),bt(E,B)))},ie=B=>{let q=ht(m,B);if(!St(q))return ke(B,q);Ki(B,ht(N,B)),An(B,-1),bt(N,B)},ri=(B,q)=>Ms(h,B,q),Xi=(B,q,J)=>Ms(Ut(v,B,ft),q,J)&&bt(g,B,Ut(g,B,(()=>0))+J),Ie=(B,q,J,at)=>{let ut=ht(E,B),mt=ht(ut,J)??0;(mt==0&&at==1||mt==1&&at==-1)&&Ms(Ut(u,B,ft),J,at),bt(ut,J,mt!=-at?mt+at:null),Ms(Ut(Ut(p,B,ft),q,ft),J,at)},te=(B,q,J,at,ut)=>{Ut(Ut(Ut(a,B,ft),q,ft),J,(()=>[at,0]))[1]=ut,o[3]?.(B,q,J,ut)},An=(B,q)=>Ms(f,B,q),Ki=(B,q,J)=>{Ut(A,B,(()=>[q,0]))[1]=J,o[4]?.(B,J)},Ne=(B,q,J,at,ut)=>(ve(Ut(Ut(Ut(_,B,ft),q,ft),J,(()=>[])),at),ut),wi=(B,q,J)=>(ve(Ut(d,B,(()=>[])),q),J),Be=(B,q,J)=>Nt(ht(ht(ht(a,B),q),J),(([at,ut])=>[!0,at,ut]),(()=>[!1,...Bn(Cn(B,q,J))])),Sn=B=>Nt(ht(A,B),(([q,J])=>[!0,q,J]),(()=>[!1,...Bn(kn(B))])),Yi=B=>yt(_)||yt(T[B])?0:vt(B?na(_):_,((q,J)=>vt(q,((at,ut)=>vt(at,((mt,At)=>$(T[B],[J,ut,At],mt))))))),ai=B=>yt(d)||yt(R[B])?0:vt(B?ci(d):d,((q,J)=>$(R[B],[J],q))),ue=(B,q,J,at)=>{if(!yt(B))return $(q,at,(()=>be(B))),Xt(B,((ut,mt)=>$(J,[...at??[],ut],mt==1))),1},En=B=>{let q=Tn();q!=e&&$(H[B],void 0,q);let J=yt(et[B]),at=yt(st[B])&&yt(W[B])&&yt(Y[B])&&yt(rt[B])&&yt(X[B])&&yt(j[B])&&yt(G[B])&&J&&yt(K[B])&&yt(it[B]),ut=yt(w[B])&&yt(ct[B])&&yt(ot[B])&&yt(z[B]);if(!at||!ut){let mt=B?[ci(h),fa(u),ci(g),fa(v),na(p),na(a)]:[h,u,g,v,p,a];if(!at){ue(mt[0],K[B],it[B]),vt(mt[1],((Pt,It)=>ue(Pt,X[B],j[B],[It]))),vt(mt[2],((Pt,It)=>{Pt!=0&&$(G[B],[It],Io(It))}));let At=Kt();vt(mt[3],((Pt,It)=>{ue(Pt,Y[B],rt[B],[It])&&!J&&($(et[B],[It,null]),zt(At,It))})),J||vt(mt[5],((Pt,It)=>{if(!$t(At,It)){let We=Kt();vt(Pt,(oi=>vt(oi,(([Ln,Fn],Is)=>Fn!==Ln?zt(We,Is):He(oi,Is))))),vt(We,(oi=>$(et[B],[It,oi])))}})),vt(mt[4],((Pt,It)=>vt(Pt,((We,oi)=>ue(We,st[B],W[B],[It,oi])))))}if(!ut){let At;vt(mt[5],((Pt,It)=>{let We;vt(Pt,((oi,Ln)=>{let Fn;vt(oi,(([Is,Go],hh)=>{Go!==Is&&($(w[B],[It,Ln,hh],Go,Is,Be),At=We=Fn=1)})),Fn&&$(ct[B],[It,Ln],Be)})),We&&$(ot[B],[It],Be)})),At&&$(z[B],void 0,Be)}}},To=B=>{let q=Pn();q!=i&&$(c[B],void 0,q);let J=yt(C[B])&&yt(k[B]),at=yt(O[B])&&yt(b[B]);if(!J||!at){let ut=B?[ci(f),ci(A)]:[f,A];if(J||ue(ut[0],C[B],k[B]),!at){let mt;vt(ut[1],(([At,Pt],It)=>{Pt!==At&&($(O[B],[It],Pt,At,Sn),mt=1)})),mt&&$(b[B],void 0,Sn)}}},Vt=(B,...q)=>(Zr((()=>B(...Ci(q,Ot)))),ce),Po=(B,q,J,at,ut)=>{let mt=_n(B,q,...J);return L((()=>{let At=_n(B,q,...J);ol(At,mt)||(mt=At,at(ce,B,q,...J,mt))}),et[ut?1:0],[B,q],[Se])},Xr=()=>Nn(M),Se=()=>_i(M),Do=B=>_i(ht(E,Ot(B))),Io=B=>os(ht(M,Ot(B))),Ji=B=>_i(ht(M,Ot(B))),_n=(B,q,J,at=0,ut)=>{return Vn(B)?_n(B.tableId,B.cellId,B.descending,B.offset,B.limit):Ci(ca(da((mt=ht(M,Ot(B)),At=(Pt,It)=>[St(q)?It:ht(Pt,Ot(q)),It],Ci([...mt?.entries()??[]],(([Pt,It])=>At(It,Pt)))),(([Pt],[It])=>pl(Pt,It)*(J?-1:1))),at,St(ut)?ut:at+ut),(([,Pt])=>Pt));var mt,At},Kr=(B,q)=>_i(ht(ht(M,Ot(B)),Ot(q))),Cn=(B,q,J)=>ht(ht(ht(M,Ot(B)),Ot(q)),Ot(J)),Yr=()=>be(N),Jr=()=>_i(N),kn=B=>ht(N,Ot(B)),Tn=()=>!yt(M),Mo=B=>$t(M,Ot(B)),Ro=(B,q)=>$t(ht(E,Ot(B)),Ot(q)),Lo=(B,q)=>$t(ht(M,Ot(B)),Ot(q)),Fo=(B,q,J)=>$t(ht(ht(M,Ot(B)),Ot(q)),Ot(J)),Pn=()=>!yt(N),Oo=B=>$t(N,Ot(B)),Dn=B=>Vt((()=>(q=>li(q,Q,Ne))(B)?Dt(B):0)),In=B=>Vt((()=>nt(B)?Oe(B):0)),No=B=>(ia((()=>xt(ra(B)))),ce),Bo=B=>Vt((()=>{if((s=li(B,(q=>li(q,F))))&&(wt(B),!yt(M))){let q=Xr();Mn(),Dn(q)}})),Uo=B=>Vt((()=>{if(t=(q=>li(q,F))(B)){let q=Yr();Qr(),Rn(),t=!0,Tt(B),In(q)}})),Mn=()=>Vt((()=>Dt({}))),$o=B=>Vt((q=>$t(M,q)?si(q):0),B),Ho=(B,q)=>Vt(((J,at)=>Nt(ht(M,J),(ut=>$t(ut,at)?ni(J,ut,at):0))),B,q),Rn=()=>Vt((()=>Oe({}))),zo=()=>Vt((()=>{wt({}),s=!1})),Qr=()=>Vt((()=>{Tt({}),t=!1})),Zr=(B,q)=>{if(n!=-1){jo();let J=B();return Vo(q),J}},jo=()=>(n!=-1&&n++,n==1&&(o[0]?.(),$(I)),ce),Vo=B=>(n>0&&(n--,n==0&&(n=1,Yi(1),yt(a)||En(1),ai(1),yt(A)||To(1),B?.(ce)&&(vt(a,((q,J)=>vt(q,((at,ut)=>vt(at,(([mt],At)=>jn(ce,J,ut,At,mt))))))),ss(a),vt(A,(([q],J)=>ua(ce,J,q))),ss(A)),$(S[0],void 0),n=-1,Yi(0),yt(a)||En(0),ai(0),yt(A)||To(0),o[1]?.(),$(S[1],void 0),o[2]?.(),n=0,e=Tn(),i=Pn(),ye([h,u,g,v,p,a,_,f,A,d],ss))),ce),ce={getContent:()=>[Xr(),Yr()],getTables:Xr,getTableIds:Se,getTable:B=>pa(ht(M,Ot(B))),getTableCellIds:Do,getRowCount:Io,getRowIds:Ji,getSortedRowIds:_n,getRow:(B,q)=>be(ht(ht(M,Ot(B)),Ot(q))),getCellIds:Kr,getCell:Cn,getValues:Yr,getValueIds:Jr,getValue:kn,hasTables:Tn,hasTable:Mo,hasTableCell:Ro,hasRow:Lo,hasCell:Fo,hasValues:Pn,hasValue:Oo,getTablesJson:()=>es(M),getValuesJson:()=>es(N),getJson:()=>es([M,N]),getTablesSchemaJson:()=>es(y),getValuesSchemaJson:()=>es(l),getSchemaJson:()=>es([y,l]),hasTablesSchema:()=>s,hasValuesSchema:()=>t,setContent:B=>Vt((()=>{let q=Ue(B)?B():B;V(q)&&(([J,at])=>{($e(J)?Mn:Dn)(J),($e(at)?Rn:In)(at)})(q)})),setTables:Dn,setTable:(B,q)=>Vt((J=>Q(q,J)?Mt(J,q):0),B),setRow:(B,q,J)=>Vt(((at,ut)=>Z(at,ut,J)?Bt(at,De(at),ut,J):0),B,q),addRow:(B,q,J=!0)=>Zr((()=>{let at;return Z(B,at,q)&&(B=Ot(B),Bt(B,De(B),at=((ut,mt)=>{let[At]=ht(D,ut),Pt;do Pt=At(mt);while($t(ht(M,ut),Pt));return Pt})(B,J?1:0),q)),at})),setPartialRow:(B,q,J)=>Vt(((at,ut)=>{if(Z(at,ut,J,1)){let mt=De(at);qe(J,((At,Pt)=>le(at,mt,ut,Pt,At)))}}),B,q),setCell:(B,q,J,at)=>Vt(((ut,mt,At)=>Nt(tt(ut,mt,At,Ue(at)?at(Cn(ut,mt,At)):at),(Pt=>le(ut,De(ut),mt,At,Pt)))),B,q,J),setValues:In,setPartialValues:B=>Vt((()=>nt(B,1)?qe(B,((q,J)=>ke(J,q))):0)),setValue:(B,q)=>Vt((J=>Nt(pt(J,Ue(q)?q(kn(J)):q),(at=>ke(J,at)))),B),applyChanges:B=>Vt((()=>{qe(B[0],((q,J)=>St(q)?$o(J):qe(q,((at,ut)=>St(at)?Ho(J,ut):qe(at,((mt,At)=>jn(ce,J,ut,At,mt))))))),qe(B[1],((q,J)=>ua(ce,J,q)))})),setTablesJson:No,setValuesJson:B=>(ia((()=>Ae(ra(B)))),ce),setJson:B=>Vt((()=>ia((()=>{let[q,J]=ra(B);xt(q),Ae(J)}),(()=>No(B))))),setTablesSchema:Bo,setValuesSchema:Uo,setSchema:(B,q)=>Vt((()=>{Bo(B),Uo(q)})),delTables:Mn,delTable:$o,delRow:Ho,delCell:(B,q,J,at)=>Vt(((ut,mt,At)=>Nt(ht(M,ut),(Pt=>Nt(ht(Pt,mt),(It=>$t(It,At)?ae(ut,Pt,mt,It,At,at):0))))),B,q,J),delValues:Rn,delValue:B=>Vt((q=>$t(N,q)?ie(q):0),B),delTablesSchema:zo,delValuesSchema:Qr,delSchema:()=>Vt((()=>{zo(),Qr()})),transaction:Zr,startTransaction:jo,getTransactionChanges:()=>[be(a,((B,q)=>ht(h,q)===-1?void 0:be(B,((J,at)=>ht(ht(v,q),at)===-1?void 0:be(J,(([,ut])=>ut),(ut=>Un(ut)))),yt,$e)),yt,$e),be(A,(([,B])=>B),(B=>Un(B))),1],getTransactionLog:()=>[!yt(a),!yt(A),Nn(a,Zo,Un),Nn(_),be(A,Zo,Un),be(d),be(h),pa(v),Nn(p),be(f)],finishTransaction:Vo,forEachTable:B=>vt(M,((q,J)=>B(J,(at=>vt(q,((ut,mt)=>at(mt,(At=>Xt(ut,At))))))))),forEachTableCell:(B,q)=>Xt(ht(E,Ot(B)),q),forEachRow:(B,q)=>vt(ht(M,Ot(B)),((J,at)=>q(at,(ut=>Xt(J,ut))))),forEachCell:(B,q,J)=>Xt(ht(ht(M,Ot(B)),Ot(q)),J),forEachValue:B=>Xt(N,B),addSortedRowIdsListener:(B,q,J,at,ut,mt,At)=>Vn(B)?Po(B.tableId,B.cellId,[B.descending??!1,B.offset??0,B.limit],q,J):Po(B,q,[J,at,ut],mt,At),addStartTransactionListener:B=>L(B,I),addWillFinishTransactionListener:B=>L(B,S[0]),addDidFinishTransactionListener:B=>L(B,S[1]),callListener:B=>(P(B),ce),delListener:B=>(U(B),ce),getListenerStats:()=>({hasTables:Gt(H),tables:Gt(z),tableIds:Gt(K),hasTable:Gt(it),table:Gt(ot),tableCellIds:Gt(X),hasTableCell:Gt(j,Xe),rowCount:Gt(G),rowIds:Gt(Y),sortedRowIds:Gt(et),hasRow:Gt(rt,Xe),row:Gt(ct,Xe),cellIds:Gt(st,Xe),hasCell:Gt(W,sa),cell:Gt(w,sa),invalidCell:Gt(T,sa),hasValues:Gt(c),values:Gt(b),valueIds:Gt(C),hasValue:Gt(k),value:Gt(O),invalidValue:Gt(R),transaction:ki(I)+Gt(S)}),isMergeable:()=>!1,createStore:$s,addListener:L,callListeners:$,setInternalListeners:(B,q,J,at,ut)=>o=[B,q,J,at,ut]};return qe({[Si+qo]:[0,H,[],()=>[Tn()]],[qo]:[0,z],[fh]:[0,K],[Si+hi]:[1,it,[Se],B=>[Mo(...B)]],[hi]:[1,ot,[Se]],[hi+$n]:[1,X,[Se]],[Si+hi+Ls]:[2,j,[Se,Do],B=>[Ro(...B)]],[il]:[1,G,[Se]],[sl]:[1,Y,[Se]],[Si+ns]:[2,rt,[Se,Ji],B=>[Lo(...B)]],[ns]:[2,ct,[Se,Ji]],[$n]:[2,st,[Se,Ji]],[Si+Ls]:[3,W,[Se,Ji,Kr],B=>[Fo(...B)]],[Ls]:[3,w,[Se,Ji,Kr],B=>Bn(Cn(...B))],InvalidCell:[3,T],[Si+Xo]:[0,c,[],()=>[Pn()]],[Xo]:[0,b],[mh]:[0,C],[Si+Hn]:[1,k,[Jr],B=>[Oo(...B)]],[Hn]:[1,O,[Jr],B=>Bn(kn(B[0]))],InvalidValue:[1,R]},(([B,q,J,at],ut)=>{ce[oa+ut+aa]=(...mt)=>L(mt[B],q[mt[B+1]?1:0],B>0?ca(mt,0,B):void 0,J,at)})),ls(ce)};var ga=ft([["avg",[(s,t)=>Yo(s)/t,(s,t,e)=>s+(t-s)/(e+1),(s,t,e)=>s+(s-t)/(e-1),(s,t,e,i)=>s+(t-e)/i]],["max",[s=>ta(...s),(s,t)=>ta(t,s),(s,t)=>t==s?void 0:s,(s,t,e)=>e==s?void 0:ta(t,s)]],["min",[s=>ea(...s),(s,t)=>ea(t,s),(s,t)=>t==s?void 0:s,(s,t,e)=>e==s?void 0:ea(t,s)]],["sum",[s=>Yo(s),(s,t)=>s+t,(s,t)=>s-t,(s,t,e)=>s-e+t]]]),fl=(s,t,e,i,n,o=!1)=>{if(yt(e))return;let[h,u,g,v]=n;return o||=St(s),vt(i,(([p,a])=>{o||(s=St(p)?u?.(s,a,t++):St(a)?g?.(s,p,t--):v?.(s,a,p,t),o||=St(s))})),o?h(as(e),os(e)):s},qu=Bs((s=>{let t=ft(),[e,i,n]=Us((()=>y)),[o,h,u,g,v,p,a,,f,A,_,d]=qn(s,al,(r=>isNaN(r)||St(r)||r===!0||r===!1||r===""?void 0:1*r),e,i),y={setMetricDefinition:(r,l,m,x,D,E,M)=>{let N=Ue(m)?[m,D,E,M]:ht(ga,m)??ht(ga,"sum");return f(r,l,((H,z,K,it,ot,X)=>{let j=p(r),G=os(it);X||=St(j),H();let Y=fl(j,G,it,z,N,X);nl(Y)||(Y=void 0),Y!=j&&(a(r,Y),i(t,[r],Y,j))}),Gn(x,1)),y},delMetricDefinition:r=>(A(r),y),getStore:o,getMetricIds:h,forEachMetric:u,hasMetric:g,getTableId:v,getMetric:p,addMetricIdsListener:_,addMetricListener:(r,l)=>e(l,t,[r]),delListener:r=>(n(r),y),destroy:d,getListenerStats:()=>({metric:ki(t)})};return ls(y)})),Xu=Bs((s=>{let t=s.createStore,e=t(),i=t(),n=ft(),{addListener:o,callListeners:h,delListener:u}=i,[g,v,p,a,f,,,A,,_,d,y,r,l]=qn(s,(()=>!0),al,o,h),m=(M,N,...H)=>ye(H,(z=>zt(Ut(Ut(n,N,ft),M,Kt),z))),x=M=>{Nt(ht(n,M),(N=>{Xt(N,((H,z)=>vt(z,(K=>H.delListener(K))))),ss(N)})),ye([i,e],(N=>N.delTable(M)))},D=(M,N,H)=>m(N,M,N.addStartTransactionListener(H.startTransaction),N.addDidFinishTransactionListener((()=>H.finishTransaction()))),E={setQueryDefinition:(M,N,H)=>{A(M,N),x(M);let z=[],K=[[null,[N,null,null,[],ft()]]],it=[],ot=[],X=[];H({select:(st,W)=>{let w=Ue(st)?[Ee(z)+"",st]:[St(W)?st:W,T=>T(st,W)];return ve(z,w),{as:T=>w[0]=T}},join:(st,W,w)=>{let T=St(w)||Ue(W)?null:W,R=St(T)?W:w,c=[st,[st,T,Ue(R)?R:b=>b(R),[],ft()]];return ve(K,c),{as:b=>c[0]=b}},where:(st,W,w)=>ve(it,Ue(st)?st:St(w)?T=>T(st)===W:T=>T(st,W)===w),group:(st,W,w,T,R)=>{let c=[st,[st,Ue(W)?[W,w,T,R]:ht(ga,W)??[(b,C)=>C]]];return ve(ot,c),{as:b=>c[0]=b}},having:(st,W)=>ve(X,Ue(st)?st:w=>w(st)===W)});let j=ft(z);if(yt(j))return E;let G=ft(K);Xt(G,((st,[,W])=>Nt(ht(G,W),(({3:w})=>St(st)?0:ve(w,st)))));let Y=ft(ot),et=e;if(yt(Y)&&Fs(X))et=i;else{D(M,et,i);let st=ft();Xt(Y,((R,[c,b])=>zt(Ut(st,c,Kt),[R,b])));let W=Kt();Xt(j,(R=>$t(st,R)?0:zt(W,R)));let w=ft(),T=(R,c,b,C)=>Nt(R,(([k,O,I,S])=>{Xt(c,((L,[$])=>{let U=Ut(k,L,ft),P=ht(U,b),F=C?void 0:$;if(P!==F){let V=Kt([[P,F]]),Q=os(U);bt(U,b,F),vt(ht(st,L),(([Z,tt])=>{let nt=fl(S[Z],Q,U,V,tt);S[Z]=St(is(nt))?null:nt}))}})),yt(O)||!zn(X,(L=>L(($=>S[$]))))?i.delRow(M,I):St(I)?R[2]=i.addRow(M,S):i.setRow(M,I,S)}));m(et,M,et.addRowListener(M,null,((R,c,b,C)=>{let k=[],O=[],I=ft(),S=et.hasRow(M,b),L=!S;vt(W,($=>{let[U,P,F]=C(M,b,$);ve(k,P),ve(O,F),L||=U})),Xt(st,($=>{let[U,,P]=C(M,b,$);(L||U)&&bt(I,$,[P])})),L&&T(Os(w,k,void 0,(([,$])=>(He($,b),yt($)))),I,b,1),S&&T(Os(w,O,(()=>{let $={};return vt(W,(U=>$[U]=et.getCell(M,b,U))),[ft(),Kt(),void 0,$]}),(([,$])=>{zt($,b)})),I,b)})))}D(M,s,et);let rt=(st,W,w,T)=>{let R=c=>s.getCell(W,w,c);ye(T,(c=>{let[b,,C,k,O]=ht(G,c),I=C?.(R,st),[S,L]=ht(O,st)??[];I!=S&&(St(L)||l(M,L),bt(O,st,St(I)?null:[I,...r(M,1,s.addRowListener(b,I,(()=>rt(st,b,I,k))))]))})),(c=>{let b=(C,k)=>s.getCell(...St(k)?[N,c,C]:C===N?[N,c,k]:[ht(G,C)?.[0],ht(ht(G,C)?.[4],c)?.[0],k]);et.transaction((()=>zn(it,(C=>C(b)))?Xt(j,((C,k)=>jn(et,M,c,C,k(b,c)))):et.delRow(M,c)))})(st)},{3:ct}=ht(G,null);return et.transaction((()=>r(M,1,s.addRowListener(N,null,((st,W,w)=>{s.hasRow(N,w)?rt(w,N,w,ct):(et.delRow(M,w),vt(G,(({4:T})=>Nt(ht(T,w),(([,R])=>{l(M,R),bt(T,w)})))))}))))),E},delQueryDefinition:M=>(x(M),_(M),E),getStore:g,getQueryIds:v,forEachQuery:p,hasQuery:a,getTableId:f,addQueryIdsListener:M=>d((()=>M(E))),delListener:M=>(u(M),E),destroy:y,getListenerStats:()=>{let{tables:M,tableIds:N,transaction:H,...z}=i.getListenerStats();return z}};return qe({[hi]:[1,1],[hi+$n]:[0,1],[il]:[0,1],[sl]:[0,1],[gh]:[0,5],[ns]:[1,2],[$n]:[0,2],[Ls]:[1,3]},(([M,N],H)=>{ye(M?["get","has","forEach"]:["get"],(z=>E[z+Wo+H]=(...K)=>i[z+H](...K))),E[oa+Wo+H+aa]=(...z)=>i[oa+H+aa](...ca(z,0,N),((K,...it)=>z[N](E,...it)),!0)})),ls(E)})),Ku=Bs((s=>{let t=ft(),e=ft(),i=ft(),n=ft(),[o,h,u]=Us((()=>D)),[g,v,p,a,f,A,,,_,d,y,r]=qn(s,(()=>[ft(),ft(),ft(),ft()]),(E=>St(E)?void 0:E+""),o,h),l=(E,M,N)=>Nt(A(E),(([H,,z])=>{if(!$t(z,M)){let K=Kt();if(f(E)!=x(E))zt(K,M);else{let it=M;for(;!St(it)&&!$t(K,it);)zt(K,it),it=ht(H,it)}if(N)return K;bt(z,M,K)}return ht(z,M)})),m=(E,M)=>Nt(A(E),(([,,N])=>bt(N,M))),x=E=>ht(t,E),D={setRelationshipDefinition:(E,M,N,H)=>(bt(t,E,N),_(E,M,((z,K)=>{let it=Kt(),ot=Kt(),X=Kt(),[j,G]=A(E);vt(K,(([Y,et],rt)=>{St(Y)||(zt(ot,Y),Nt(ht(G,Y),(ct=>{He(ct,rt),yt(ct)&&bt(G,Y)}))),St(et)||(zt(ot,et),$t(G,et)||bt(G,et,Kt()),zt(ht(G,et),rt)),zt(it,rt),bt(j,rt,et),Xt(ht(n,E),(ct=>{$t(l(E,ct),rt)&&zt(X,ct)}))})),z(),vt(it,(Y=>h(e,[E,Y]))),vt(ot,(Y=>h(i,[E,Y]))),vt(X,(Y=>{m(E,Y),h(n,[E,Y])}))}),Gn(H)),D),delRelationshipDefinition:E=>(bt(t,E),d(E),D),getStore:g,getRelationshipIds:v,forEachRelationship:E=>p((M=>E(M,(N=>s.forEachRow(f(M),N))))),hasRelationship:a,getLocalTableId:f,getRemoteTableId:x,getRemoteRowId:(E,M)=>ht(A(E)?.[0],M),getLocalRowIds:(E,M)=>as(ht(A(E)?.[1],M)),getLinkedRowIds:(E,M)=>St(A(E))?[M]:as(l(E,M,!0)),addRelationshipIdsListener:y,addRemoteRowIdListener:(E,M,N)=>o(N,e,[E,M]),addLocalRowIdsListener:(E,M,N)=>o(N,i,[E,M]),addLinkedRowIdsListener:(E,M,N)=>(l(E,M),o(N,n,[E,M])),delListener:E=>(m(...u(E)??[]),D),destroy:r,getListenerStats:()=>({remoteRowId:Xe(e),localRowIds:Xe(i),linkedRowIds:Xe(n)})};return ls(D)}));var bl=Promise,kh=globalThis,gl=kh.window,Th=1e3,Ph=(s,t,e)=>setInterval(s,t*Th),Dh=clearInterval,ze=s=>s==null,Qn=(s,t,e)=>ze(s)?e?.():t(s),va=s=>Array.isArray(s),Pi=s=>s.length,Ih=(s,t)=>s.test(t),vl=s=>new bl(s),yl=async s=>bl.all(s),wl=s=>{throw new Error(s)},Ti=async(s,t,e)=>{try{return await s()}catch(i){t?.(i)}},ya=(s,t)=>s.forEach(t),Hs=(s,t)=>s.map(t),Mh=(s,t)=>s.splice(0,t),Zn=(s,...t)=>s.push(...t),xl=s=>s.shift(),cs=Object,ml=s=>cs.getPrototypeOf(s),Rh=cs.entries,Lh=s=>!ze(s)&&Qn(ml(s),t=>t==cs.prototype||ze(ml(t)),()=>!0),Fh=cs.keys,Oh=cs.freeze,Nh=(s=[])=>cs.fromEntries(s),Bh=(s,t)=>t in s,Uh=(s,t)=>Hs(Rh(s),([e,i])=>t(i,e)),$h=s=>Pi(Fh(s)),Xn=s=>Lh(s)&&$h(s)==0,Hh=s=>s?.size??0,zh=(s,t)=>s?.has(t)??!1,Al=s=>ze(s)||Hh(s)==0,Sl=(s,t)=>s?.forEach(t),El=(s,t)=>s?.delete(t),zs=s=>new Map(s),Me=(s,t)=>s?.get(t),Di=(s,t,e)=>ze(e)?(El(s,t),s):s?.set(t,e),wa=(s,t,e,i)=>(zh(s,t)?i?.(Me(s,t)):Di(s,t,e()),Me(s,t)),xa=(s,t,e,i,n=0)=>Qn((e?wa:Me)(s,t[n],n>Pi(t)-2?e:zs),o=>{if(n>Pi(t)-2)return i?.(o)&&Di(s,t[n]),o;let h=xa(o,t,e,i,n+1);return Al(o)&&Di(s,t[n]),h}),jh=/^\d+$/,Vh=()=>{let s=[],t=0;return[e=>(e?xl(s):null)??""+t++,e=>{Ih(jh,e)&&Pi(s)<1e3&&Zn(s,e)}]},Gh=s=>new Set(va(s)||ze(s)?s:[s]),Wh=(s,t)=>s?.add(t),qh=(s,t=[""])=>{let e=[],i=(n,o)=>o==Pi(t)?Zn(e,n):t[o]===null?Sl(n,h=>i(h,o+1)):ya([t[o],null],h=>i(Me(n,h),o+1));return i(s,0),e},Xh=s=>{let t,[e,i]=Vh(),n=zs();return[(o,h,u,g=[],v=()=>[])=>{t??=s();let p=e(1);return Di(n,p,[o,h,u,g,v]),Wh(xa(h,u??[""],Gh),p),p},(o,h,...u)=>ya(qh(o,h),g=>Sl(g,v=>Me(n,v)[0](t,...h??[],...u))),o=>Qn(Me(n,o),([,h,u])=>(xa(h,u??[""],void 0,g=>(El(g,o),Al(g)?1:0)),Di(n,o),i(o),u)),o=>Qn(Me(n,o),([h,,u=[],g,v])=>{let p=(...a)=>{let f=Pi(a);f==Pi(u)?h(t,...a,...v(a)):ze(u[f])?ya(g[f]?.(...a)??[],A=>p(...a,A)):p(...a,u[f])};p()})]},Kn=zs(),Yn=zs(),Kh=(s=1,t,e)=>s!=1&&t.isMergeable()?[1,t.getMergeableContent,()=>t.getTransactionMergeableChanges(!e),([[i],[n]])=>!Xn(i)||!Xn(n),t.setDefaultContent]:s!=2?[0,t.getContent,t.getTransactionChanges,([i,n])=>!Xn(i)||!Xn(n),t.setContent]:wl("Store type not supported by this Persister"),Yh=(s,t,e,i,n,o,h,u={},g=0,v=[])=>{let p=0,a=0,f=0,A,_,d;wa(Kn,v,()=>0),wa(Yn,v,()=>[]);let y=zs(),[r,l,m,x,D]=Kh(h,s,g),[E,M,N]=Xh(()=>c),H=b=>{b!=p&&(p=b,M(y,void 0,p))},z=async()=>{if(!Me(Kn,v)){for(Di(Kn,v,1);!ze(A=xl(Me(Yn,v)));)await Ti(A,o);Di(Kn,v,0)}},K=b=>{(r&&va(b?.[0])?b?.[2]===1?s.applyMergeableChanges:s.setMergeableContent:b?.[2]===1?s.applyChanges:s.setContent)(b)},it=async b=>(p!=2&&(H(1),a++,await R(async()=>{await Ti(async()=>{let C=await t();va(C)?K(C):b?D(b):wl(`Content is not an array: ${C}`)},()=>{b&&D(b)}),H(0)})),c),ot=async b=>(X(),await it(b),await Ti(async()=>_=await i(async(C,k)=>{k||C?p!=2&&(H(1),a++,K(k??C),H(0)):await it()}),o),c),X=async()=>(_&&(await Ti(()=>n(_),o),_=void 0),c),j=()=>!ze(_),G=async b=>(p!=1&&(H(2),f++,await R(async()=>{await Ti(()=>e(l,b),o),H(0)})),c),Y=async()=>(et(),await G(),d=s.addDidFinishTransactionListener(()=>{let b=m();x(b)&&G(b)}),c),et=async()=>(d&&(s.delListener(d),d=void 0),c),rt=()=>!ze(d),ct=async(b,C=!1)=>{let[k,O]=C?[Y,ot]:[ot,Y];return await k(b),await O(b),c},st=async(b=!1)=>{let[C,k]=b?[et,X]:[X,et];return await C(),await k(),c},W=()=>p,w=b=>E(b,y),T=b=>(N(b),s),R=async(...b)=>(Zn(Me(Yn,v),...b),await z(),c),c={load:it,startAutoLoad:ot,stopAutoLoad:X,isAutoLoading:j,save:G,startAutoSave:Y,stopAutoSave:et,isAutoSaving:rt,startAutoPersisting:ct,stopAutoPersisting:st,getStatus:W,addStatusListener:w,delListener:T,schedule:R,getStore:()=>s,destroy:()=>(Mh(Me(Yn,v)),st()),getStats:()=>({loads:a,saves:f}),...u};return Oh(c)},ba=["t","v"],Jh={keyPath:"k"},Qh=async(s,t)=>{let e=Uh(t,(i,n)=>Jn(s,"put",{k:n,v:i}));Hs(await Jn(s,"getAllKeys"),i=>Bh(t,i)?0:Zn(e,Jn(s,"delete",i))),await yl(e)},Jn=async(s,t,e)=>vl((i,n)=>{let o=s[t](e);o.onsuccess=()=>i(o.result),o.onerror=()=>n(`objectStore.${t} error`)}),tr=(s,t,e=1,i)=>{let n=async(o,h=[],u=0)=>vl((g,v)=>{let p=(gl?gl.indexedDB:indexedDB).open(t,u?2:void 0);p.onupgradeneeded=()=>u&&Hs(ba,a=>Ti(()=>p.result.createObjectStore(a,Jh))),p.onsuccess=()=>Ti(async()=>{let a=p.result.transaction(ba,"readwrite"),f=await yl(Hs(ba,(A,_)=>o(a.objectStore(A),h[_])));p.result.close(),g(f)},a=>{p.result.close(),v(a)}),p.onerror=()=>v("indexedDB.open error")});return Yh(s,async()=>await n(async o=>Nh(Hs(await Jn(o,"getAll"),({k:h,v:u})=>[h,u]))),o=>n((h,u)=>Qh(h,u),o(),1),o=>Ph(o,e),o=>Dh(o),i,1,{getDbName:()=>t})};var er=$s();er.setTable("docs",{});var ir=tr(er,"copio-db");ir.startAutoLoad();ir.startAutoSave();var js=class extends xi{#t=null;#e=null;#i="copio-db";#n=!1;constructor(t={}){super(),t.dbName&&t.dbName!=="copio-db"?(this.#i=t.dbName,this.#t=t.store||$s(),this.#t.setTable("docs",{}),this.#e=t.persister||tr(this.#t,this.#i),this.#n=!0):(this.#t=t.store||er,this.#e=t.persister||ir,this.#i="copio-db")}get store(){return this.#t}get persister(){return this.#e}async init(){return this.#n?(await this.#e.load(),this.#e.startAutoLoad(),this.#e.startAutoSave()):await this.#e.load(),{kind:"indexeddb",persistent:!0}}listDocsSync(){let t=this.#t.getTable("docs");return Object.entries(t||{}).map(([e,i])=>({id:e,name:i.name||"",pages:this.#r(i.pages)}))}async listDocs(){return this.listDocsSync()}getDocSync(t){if(!this.#t.hasRow("docs",t))return null;let e=this.#t.getRow("docs",t);return{id:t,name:e.name||"",pages:this.#r(e.pages)}}async getDoc(t){return this.getDocSync(t)}async saveDoc(t,e){if(!t)throw new Error("Cannot save document without an ID");let i=Array.isArray(e.pages)?e.pages:this.#r(e.pages);this.#t.setRow("docs",t,{name:e.name||"",pages:JSON.stringify(i)})}async deleteDoc(t){this.#t.delRow("docs",t)}async savePage(t,e,i){let n=await this.getDoc(t);if(!n)throw new Error(`Document ${t} not found`);let o=n.pages.findIndex(h=>h.id===e);if(o>=0)typeof i=="object"&&i!==null&&!(i instanceof Blob)?n.pages[o]={...n.pages[o],...i}:n.pages[o]={...n.pages[o],src:i};else{let h=typeof i=="object"&&i!==null&&!(i instanceof Blob)?{id:e,...i}:{id:e,src:i};n.pages.push(h)}await this.saveDoc(t,n)}async getPage(t,e){let i=await this.getDoc(t);if(!i)return null;let n=i.pages.find(o=>o.id===e);return n?n.src??n:null}async deletePage(t,e){let i=await this.getDoc(t);i&&(i.pages=i.pages.filter(n=>n.id!==e),await this.saveDoc(t,i))}subscribe(t){let e=this.#t.addTableListener("docs",t);return()=>{this.#t.delListener(e)}}#r(t){if(Array.isArray(t))return t;if(typeof t=="string")try{return JSON.parse(t)}catch{return[]}return[]}};function sr(s={}){return s.forceMemory?new ts:typeof indexedDB<"u"?new js(s):new ts}function Ft(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}var Fa=typeof self<"u"?self:global,Xs=typeof navigator<"u",Zh=Xs&&typeof HTMLImageElement>"u",_l=!(typeof global>"u"||typeof process>"u"||!process.versions||!process.versions.node),Oa=Fa.Buffer,nr=Fa.BigInt,Na=!!Oa,rr=s=>Nl(s)?void 0:s,td=s=>s!==void 0;function Nl(s){return s===void 0||(s instanceof Map?s.size===0:Object.values(s).filter(td).length===0)}function ee(s){let t=new Error(s);throw delete t.stack,t}function Bl(s){return(s=(function(t){for(;t.endsWith("\0");)t=t.slice(0,-1);return t})(s).trim())===""?void 0:s}function Cl(s){let t=(function(e){let i=0;return e.ifd0.enabled&&(i+=1024),e.exif.enabled&&(i+=2048),e.makerNote&&(i+=2048),e.userComment&&(i+=1024),e.gps.enabled&&(i+=512),e.interop.enabled&&(i+=100),e.ifd1.enabled&&(i+=1024),i+2048})(s);return s.jfif.enabled&&(t+=50),s.xmp.enabled&&(t+=2e4),s.iptc.enabled&&(t+=14e3),s.icc.enabled&&(t+=6e3),t}var _a=s=>String.fromCharCode.apply(null,s),kl=typeof TextDecoder<"u"?new TextDecoder("utf-8"):void 0;function Ul(s){return kl?kl.decode(s):Na?Buffer.from(s).toString("utf8"):decodeURIComponent(escape(_a(s)))}var Je=class s{static from(t,e){return t instanceof this&&t.le===e?t:new s(t,void 0,void 0,e)}constructor(t,e=0,i,n){if(typeof n=="boolean"&&(this.le=n),Array.isArray(t)&&(t=new Uint8Array(t)),t===0)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){i===void 0&&(i=t.byteLength-e);let o=new DataView(t,e,i);this._swapDataView(o)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof s){i===void 0&&(i=t.byteLength-e),(e+=t.byteOffset)+i>t.byteOffset+t.byteLength&&ee("Creating view outside of available memory in ArrayBuffer");let o=new DataView(t.buffer,e,i);this._swapDataView(o)}else if(typeof t=="number"){let o=new DataView(new ArrayBuffer(t));this._swapDataView(o)}else ee("Invalid input argument for BufferView: "+t)}_swapArrayBuffer(t){this._swapDataView(new DataView(t))}_swapBuffer(t){this._swapDataView(new DataView(t.buffer,t.byteOffset,t.byteLength))}_swapDataView(t){this.dataView=t,this.buffer=t.buffer,this.byteOffset=t.byteOffset,this.byteLength=t.byteLength}_lengthToEnd(t){return this.byteLength-t}set(t,e,i=s){return t instanceof DataView||t instanceof s?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),t instanceof Uint8Array||ee("BufferView.set(): Invalid data argument."),this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new s(this,t,e)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(t,e){return new Uint8Array(this.buffer,this.byteOffset+t,e)}getString(t=0,e=this.byteLength){return Ul(this.getUint8Array(t,e))}getLatin1String(t=0,e=this.byteLength){let i=this.getUint8Array(t,e);return _a(i)}getUnicodeString(t=0,e=this.byteLength){let i=[];for(let n=0;n<e&&t+n<this.byteLength;n+=2)i.push(this.getUint16(t+n));return _a(i)}getInt8(t){return this.dataView.getInt8(t)}getUint8(t){return this.dataView.getUint8(t)}getInt16(t,e=this.le){return this.dataView.getInt16(t,e)}getInt32(t,e=this.le){return this.dataView.getInt32(t,e)}getUint16(t,e=this.le){return this.dataView.getUint16(t,e)}getUint32(t,e=this.le){return this.dataView.getUint32(t,e)}getFloat32(t,e=this.le){return this.dataView.getFloat32(t,e)}getFloat64(t,e=this.le){return this.dataView.getFloat64(t,e)}getFloat(t,e=this.le){return this.dataView.getFloat32(t,e)}getDouble(t,e=this.le){return this.dataView.getFloat64(t,e)}getUintBytes(t,e,i){switch(e){case 1:return this.getUint8(t,i);case 2:return this.getUint16(t,i);case 4:return this.getUint32(t,i);case 8:return this.getUint64&&this.getUint64(t,i)}}getUint(t,e,i){switch(e){case 8:return this.getUint8(t,i);case 16:return this.getUint16(t,i);case 32:return this.getUint32(t,i);case 64:return this.getUint64&&this.getUint64(t,i)}}toString(t){return this.dataView.toString(t,this.constructor.name)}ensureChunk(){}};function Ca(s,t){ee(`${s} '${t}' was not loaded, try using full build of exifr.`)}var Ks=class extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||Ca(this.kind,t),e&&(t in e||(function(i,n){ee(`Unknown ${i} '${n}'.`)})(this.kind,t),e[t].enabled||Ca(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}},Ni=new Ks("file parser"),fe=new Ks("segment parser"),Bi=new Ks("file reader"),$l=Fa.fetch;function Tl(s,t){return(e=s).startsWith("data:")||e.length>1e4?Ta(s,t,"base64"):_l&&s.includes("://")?ka(s,t,"url",us):_l?Ta(s,t,"fs"):Xs?ka(s,t,"url",us):void ee("Invalid input argument");var e}async function ka(s,t,e,i){return Bi.has(e)?Ta(s,t,e):i?(async function(n,o){let h=await o(n);return new Je(h)})(s,i):void ee(`Parser ${e} is not loaded`)}async function Ta(s,t,e){let i=new(Bi.get(e))(s,t);return await i.read(),i}var us=s=>$l(s).then((t=>t.arrayBuffer())),ps=s=>new Promise(((t,e)=>{let i=new FileReader;i.onloadend=()=>t(i.result||new ArrayBuffer),i.onerror=e,i.readAsArrayBuffer(s)})),Pa=class extends Map{get tagKeys(){return this.allKeys||(this.allKeys=Array.from(this.keys())),this.allKeys}get tagValues(){return this.allValues||(this.allValues=Array.from(this.values())),this.allValues}};function Re(s,t,e){let i=new Pa;for(let[n,o]of e)i.set(n,o);if(Array.isArray(t))for(let n of t)s.set(n,i);else s.set(t,i);return i}function Ba(s,t,e){let i,n=s.get(t);for(i of e)n.set(i[0],i[1])}var Ye=new Map,gs=new Map,Oi=new Map,Mi=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],Ys=["jfif","xmp","icc","iptc","ihdr"],fs=["tiff",...Ys],Jt=["ifd0","ifd1","exif","gps","interop"],Ri=[...fs,...Jt],Li=["makerNote","userComment"],Js=["translateKeys","translateValues","reviveValues","multiSegment"],Fi=[...Js,"sanitize","mergeOutput","silentErrors"],ar=class{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}},Ii=class extends ar{get needed(){return this.enabled||this.deps.size>0}constructor(t,e,i,n){if(super(),Ft(this,"enabled",!1),Ft(this,"skip",new Set),Ft(this,"pick",new Set),Ft(this,"deps",new Set),Ft(this,"translateKeys",!1),Ft(this,"translateValues",!1),Ft(this,"reviveValues",!1),this.key=t,this.enabled=e,this.parse=this.enabled,this.applyInheritables(n),this.canBeFiltered=Jt.includes(t),this.canBeFiltered&&(this.dict=Ye.get(t)),i!==void 0)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if(typeof i=="object"){if(this.enabled=!0,this.parse=i.parse!==!1,this.canBeFiltered){let{pick:o,skip:h}=i;o&&o.length>0&&this.translateTagSet(o,this.pick),h&&h.length>0&&this.translateTagSet(h,this.skip)}this.applyInheritables(i)}else i===!0||i===!1?this.parse=this.enabled=i:ee(`Invalid options argument: ${i}`)}applyInheritables(t){let e,i;for(e of Js)i=t[e],i!==void 0&&(this[e]=i)}translateTagSet(t,e){if(this.dict){let i,n,{tagKeys:o,tagValues:h}=this.dict;for(i of t)typeof i=="string"?(n=h.indexOf(i),n===-1&&(n=o.indexOf(Number(i))),n!==-1&&e.add(Number(o[n]))):e.add(i)}else for(let i of t)e.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,or(this.pick,this.deps)):this.enabled&&this.pick.size>0&&or(this.pick,this.deps)}},pe={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,ihdr:void 0,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},Pl=new Map,pi=class extends ar{static useCached(t){let e=Pl.get(t);return e!==void 0||(e=new this(t),Pl.set(t,e)),e}constructor(t){super(),t===!0?this.setupFromTrue():t===void 0?this.setupFromUndefined():Array.isArray(t)?this.setupFromArray(t):typeof t=="object"?this.setupFromObject(t):ee(`Invalid options argument ${t}`),this.firstChunkSize===void 0&&(this.firstChunkSize=Xs?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of Mi)this[t]=pe[t];for(t of Fi)this[t]=pe[t];for(t of Li)this[t]=pe[t];for(t of Ri)this[t]=new Ii(t,pe[t],void 0,this)}setupFromTrue(){let t;for(t of Mi)this[t]=pe[t];for(t of Fi)this[t]=pe[t];for(t of Li)this[t]=!0;for(t of Ri)this[t]=new Ii(t,!0,void 0,this)}setupFromArray(t){let e;for(e of Mi)this[e]=pe[e];for(e of Fi)this[e]=pe[e];for(e of Li)this[e]=pe[e];for(e of Ri)this[e]=new Ii(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,Jt)}setupFromObject(t){let e;for(e of(Jt.ifd0=Jt.ifd0||Jt.image,Jt.ifd1=Jt.ifd1||Jt.thumbnail,Object.assign(this,t),Mi))this[e]=Aa(t[e],pe[e]);for(e of Fi)this[e]=Aa(t[e],pe[e]);for(e of Li)this[e]=Aa(t[e],pe[e]);for(e of fs)this[e]=new Ii(e,pe[e],t[e],this);for(e of Jt)this[e]=new Ii(e,pe[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,Jt,Ri),t.tiff===!0?this.batchEnableWithBool(Jt,!0):t.tiff===!1?this.batchEnableWithUserValue(Jt,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,Jt):typeof t.tiff=="object"&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,Jt)}batchEnableWithBool(t,e){for(let i of t)this[i].enabled=e}batchEnableWithUserValue(t,e){for(let i of t){let n=e[i];this[i].enabled=n!==!1&&n!==void 0}}setupGlobalFilters(t,e,i,n=i){if(t&&t.length){for(let h of n)this[h].enabled=!1;let o=Dl(t,i);for(let[h,u]of o)or(this[h].pick,u),this[h].enabled=!0}else if(e&&e.length){let o=Dl(e,i);for(let[h,u]of o)or(this[h].skip,u)}}filterNestedSegmentTags(){let{ifd0:t,exif:e,xmp:i,iptc:n,icc:o}=this;this.makerNote?e.deps.add(37500):e.skip.add(37500),this.userComment?e.deps.add(37510):e.skip.add(37510),i.enabled||t.skip.add(700),n.enabled||t.skip.add(33723),o.enabled||t.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:t,exif:e,gps:i,interop:n}=this;n.needed&&(e.deps.add(40965),t.deps.add(40965)),e.needed&&t.deps.add(34665),i.needed&&t.deps.add(34853),this.tiff.enabled=Jt.some((o=>this[o].enabled===!0))||this.makerNote||this.userComment;for(let o of Jt)this[o].finalizeFilters()}get onlyTiff(){return!Ys.map((t=>this[t].enabled)).some((t=>t===!0))&&this.tiff.enabled}checkLoadedPlugins(){for(let t of fs)this[t].enabled&&!fe.has(t)&&Ca("segment parser",t)}};function Dl(s,t){let e,i,n,o,h=[];for(n of t){for(o of(e=Ye.get(n),i=[],e))(s.includes(o[0])||s.includes(o[1]))&&i.push(o[0]);i.length&&h.push([n,i])}return h}function Aa(s,t){return s!==void 0?s:t!==void 0?t:void 0}function or(s,t){for(let e of t)s.add(e)}Ft(pi,"default",pe);var Qe=class{constructor(t){Ft(this,"parsers",{}),Ft(this,"output",{}),Ft(this,"errors",[]),Ft(this,"pushToErrors",(e=>this.errors.push(e))),this.options=pi.useCached(t)}async read(t){this.file=await(function(e,i){return typeof e=="string"?Tl(e,i):Xs&&!Zh&&e instanceof HTMLImageElement?Tl(e.src,i):e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView?new Je(e):Xs&&e instanceof Blob?ka(e,i,"blob",ps):void ee("Invalid input argument")})(t,this.options)}setup(){if(this.fileParser)return;let{file:t}=this,e=t.getUint16(0);for(let[i,n]of Ni)if(n.canHandle(t,e))return this.fileParser=new n(this.options,this.file,this.parsers),t[i]=!0;this.file.close&&this.file.close(),ee("Unknown file format")}async parse(){let{output:t,errors:e}=this;return this.setup(),this.options.silentErrors?(await this.executeParsers().catch(this.pushToErrors),e.push(...this.fileParser.errors)):await this.executeParsers(),this.file.close&&this.file.close(),this.options.silentErrors&&e.length>0&&(t.errors=e),rr(t)}async executeParsers(){let{output:t}=this;await this.fileParser.parse();let e=Object.values(this.parsers).map((async i=>{let n=await i.parse();i.assignToOutput(t,n)}));this.options.silentErrors&&(e=e.map((i=>i.catch(this.pushToErrors)))),await Promise.all(e)}async extractThumbnail(){this.setup();let{options:t,file:e}=this,i=fe.get("tiff",t);var n;if(e.tiff?n={start:0,type:"tiff"}:e.jpeg&&(n=await this.fileParser.getOrFindSegment("tiff")),n===void 0)return;let o=await this.fileParser.ensureSegmentChunk(n),h=this.parsers.tiff=new i(o,t,e),u=await h.extractThumbnail();return e.close&&e.close(),u}};async function Ua(s,t){let e=new Qe(t);return await e.read(s),e.parse()}var ed=Object.freeze({__proto__:null,parse:Ua,Exifr:Qe,fileParsers:Ni,segmentParsers:fe,fileReaders:Bi,tagKeys:Ye,tagValues:gs,tagRevivers:Oi,createDictionary:Re,extendDictionary:Ba,fetchUrlAsArrayBuffer:us,readBlobAsArrayBuffer:ps,chunkedProps:Mi,otherSegments:Ys,segments:fs,tiffBlocks:Jt,segmentsAndBlocks:Ri,tiffExtractables:Li,inheritables:Js,allFormatters:Fi,Options:pi}),lr=class{constructor(t,e,i){Ft(this,"errors",[]),Ft(this,"ensureSegmentChunk",(async n=>{let o=n.start,h=n.size||65536;if(this.file.chunked)if(this.file.available(o,h))n.chunk=this.file.subarray(o,h);else try{n.chunk=await this.file.readChunk(o,h)}catch(u){ee(`Couldn't read segment: ${JSON.stringify(n)}. ${u.message}`)}else this.file.byteLength>o+h?n.chunk=this.file.subarray(o,h):n.size===void 0?n.chunk=this.file.subarray(o):ee("Segment unreachable: "+JSON.stringify(n));return n.chunk})),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=e,this.parsers=i}injectSegment(t,e){this.options[t].enabled&&this.createParser(t,e)}createParser(t,e){let i=new(fe.get(t))(e,this.options,this.file);return this.parsers[t]=i}createParsers(t){for(let e of t){let{type:i,chunk:n}=e,o=this.options[i];if(o&&o.enabled){let h=this.parsers[i];h&&h.append||h||this.createParser(i,n)}}}async readSegments(t){let e=t.map(this.ensureSegmentChunk);await Promise.all(e)}},Ke=class{static findPosition(t,e){let i=t.getUint16(e+2)+2,n=typeof this.headerLength=="function"?this.headerLength(t,e,i):this.headerLength,o=e+n,h=i-n;return{offset:e,length:i,headerLength:n,start:o,size:h,end:o+h}}static parse(t,e={}){return new this(t,new pi({[this.type]:e}),t).parse()}normalizeInput(t){return t instanceof Je?t:new Je(t)}constructor(t,e={},i){Ft(this,"errors",[]),Ft(this,"raw",new Map),Ft(this,"handleError",(n=>{if(!this.options.silentErrors)throw n;this.errors.push(n.message)})),this.chunk=this.normalizeInput(t),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=e,this.localOptions=e[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(t,e){let i=Oi.get(e),n=gs.get(e),o=Ye.get(e),h=this.options[e],u=h.reviveValues&&!!i,g=h.translateValues&&!!n,v=h.translateKeys&&!!o,p={};for(let[a,f]of t)u&&i.has(a)?f=i.get(a)(f):g&&n.has(a)&&(f=this.translateValue(f,n.get(a))),v&&o.has(a)&&(a=o.get(a)||a),p[a]=f;return p}translateValue(t,e){return e[t]||e.DEFAULT||t}assignToOutput(t,e){this.assignObjectToOutput(t,this.constructor.type,e)}assignObjectToOutput(t,e,i){if(this.globalOptions.mergeOutput)return Object.assign(t,i);t[e]?Object.assign(t[e],i):t[e]=i}};Ft(Ke,"headerLength",4),Ft(Ke,"type",void 0),Ft(Ke,"multiSegment",!1),Ft(Ke,"canHandle",(()=>!1));function id(s){return s===192||s===194||s===196||s===219||s===221||s===218||s===254}function sd(s){return s>=224&&s<=239}function nd(s,t,e){for(let[i,n]of fe)if(n.canHandle(s,t,e))return i}var cr=class extends lr{constructor(...t){super(...t),Ft(this,"appSegments",[]),Ft(this,"jpegSegments",[]),Ft(this,"unknownSegments",[])}static canHandle(t,e){return e===65496}async parse(){await this.findAppSegments(),await this.readSegments(this.appSegments),this.mergeMultiSegments(),this.createParsers(this.mergedAppSegments||this.appSegments)}setupSegmentFinderArgs(t){t===!0?(this.findAll=!0,this.wanted=new Set(fe.keyList())):(t=t===void 0?fe.keyList().filter((e=>this.options[e].enabled)):t.filter((e=>this.options[e].enabled&&fe.has(e))),this.findAll=!1,this.remaining=new Set(t),this.wanted=new Set(t)),this.unfinishedMultiSegment=!1}async findAppSegments(t=0,e){this.setupSegmentFinderArgs(e);let{file:i,findAll:n,wanted:o,remaining:h}=this;if(!n&&this.file.chunked&&(n=Array.from(o).some((u=>{let g=fe.get(u),v=this.options[u];return g.multiSegment&&v.multiSegment})),n&&await this.file.readWhole()),t=this.findAppSegmentsInRange(t,i.byteLength),!this.options.onlyTiff&&i.chunked){let u=!1;for(;h.size>0&&!u&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:g}=i,v=this.appSegments.some((p=>!this.file.available(p.offset||p.start,p.length||p.size)));if(u=t>g&&!v?!await i.readNextChunk(t):!await i.readNextChunk(g),(t=this.findAppSegmentsInRange(t,i.byteLength))===void 0)return}}}findAppSegmentsInRange(t,e){e-=2;let i,n,o,h,u,g,{file:v,findAll:p,wanted:a,remaining:f,options:A}=this;for(;t<e;t++)if(v.getUint8(t)===255){if(i=v.getUint8(t+1),sd(i)){if(n=v.getUint16(t+2),o=nd(v,t,n),o&&a.has(o)&&(h=fe.get(o),u=h.findPosition(v,t),g=A[o],u.type=o,this.appSegments.push(u),!p&&(h.multiSegment&&g.multiSegment?(this.unfinishedMultiSegment=u.chunkNumber<u.chunkCount,this.unfinishedMultiSegment||f.delete(o)):f.delete(o),f.size===0)))break;A.recordUnknownSegments&&(u=Ke.findPosition(v,t),u.marker=i,this.unknownSegments.push(u)),t+=n+1}else if(id(i)){if(n=v.getUint16(t+2),i===218&&A.stopAfterSos!==!1)return;A.recordJpegSegments&&this.jpegSegments.push({offset:t,length:n,marker:i}),t+=n+1}}return t}mergeMultiSegments(){if(!this.appSegments.some((e=>e.multiSegment)))return;let t=(function(e,i){let n,o,h,u=new Map;for(let g=0;g<e.length;g++)n=e[g],o=n[i],u.has(o)?h=u.get(o):u.set(o,h=[]),h.push(n);return Array.from(u)})(this.appSegments,"type");this.mergedAppSegments=t.map((([e,i])=>{let n=fe.get(e,this.options);return n.handleMultiSegments?{type:e,chunk:n.handleMultiSegments(i)}:i[0]}))}getSegment(t){return this.appSegments.find((e=>e.type===t))}async getOrFindSegment(t){let e=this.getSegment(t);return e===void 0&&(await this.findAppSegments(0,[t]),e=this.getSegment(t)),e}};Ft(cr,"type","jpeg"),Ni.set("jpeg",cr);var rd=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4],Da=class extends Ke{parseHeader(){var t=this.chunk.getUint16();t===18761?this.le=!0:t===19789&&(this.le=!1),this.chunk.le=this.le,this.headerParsed=!0}parseTags(t,e,i=new Map){let{pick:n,skip:o}=this.options[e];n=new Set(n);let h=n.size>0,u=o.size===0,g=this.chunk.getUint16(t);t+=2;for(let v=0;v<g;v++){let p=this.chunk.getUint16(t);if(h){if(n.has(p)&&(i.set(p,this.parseTag(t,p,e)),n.delete(p),n.size===0))break}else!u&&o.has(p)||i.set(p,this.parseTag(t,p,e));t+=12}return i}parseTag(t,e,i){let{chunk:n}=this,o=n.getUint16(t+2),h=n.getUint32(t+4),u=rd[o];if(u*h<=4?t+=8:t=n.getUint32(t+8),(o<1||o>13)&&ee(`Invalid TIFF value type. block: ${i.toUpperCase()}, tag: ${e.toString(16)}, type: ${o}, offset ${t}`),t>n.byteLength&&ee(`Invalid TIFF value offset. block: ${i.toUpperCase()}, tag: ${e.toString(16)}, type: ${o}, offset ${t} is outside of chunk size ${n.byteLength}`),o===1)return n.getUint8Array(t,h);if(o===2)return Bl(n.getString(t,h));if(o===7)return n.getUint8Array(t,h);if(h===1)return this.parseTagValue(o,t);{let g=new((function(p){switch(p){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}})(o))(h),v=u;for(let p=0;p<h;p++)g[p]=this.parseTagValue(o,t),t+=v;return g}}parseTagValue(t,e){let{chunk:i}=this;switch(t){case 1:return i.getUint8(e);case 3:return i.getUint16(e);case 4:return i.getUint32(e);case 5:return i.getUint32(e)/i.getUint32(e+4);case 6:return i.getInt8(e);case 8:return i.getInt16(e);case 9:return i.getInt32(e);case 10:return i.getInt32(e)/i.getInt32(e+4);case 11:return i.getFloat(e);case 12:return i.getDouble(e);case 13:return i.getUint32(e);default:ee(`Invalid tiff type ${t}`)}}},Gs=class extends Da{static canHandle(t,e){return t.getUint8(e+1)===225&&t.getUint32(e+4)===1165519206&&t.getUint16(e+8)===0}async parse(){this.parseHeader();let{options:t}=this;return t.ifd0.enabled&&await this.parseIfd0Block(),t.exif.enabled&&await this.safeParse("parseExifBlock"),t.gps.enabled&&await this.safeParse("parseGpsBlock"),t.interop.enabled&&await this.safeParse("parseInteropBlock"),t.ifd1.enabled&&await this.safeParse("parseThumbnailBlock"),this.createOutput()}safeParse(t){let e=this[t]();return e.catch!==void 0&&(e=e.catch(this.handleError)),e}findIfd0Offset(){this.ifd0Offset===void 0&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(this.ifd1Offset===void 0){this.findIfd0Offset();let t=this.chunk.getUint16(this.ifd0Offset),e=this.ifd0Offset+2+12*t;this.ifd1Offset=this.chunk.getUint32(e)}}parseBlock(t,e){let i=new Map;return this[e]=i,this.parseTags(t,e,i),i}async parseIfd0Block(){if(this.ifd0)return;let{file:t}=this;this.findIfd0Offset(),this.ifd0Offset<8&&ee("Malformed EXIF data"),!t.chunked&&this.ifd0Offset>t.byteLength&&ee(`IFD0 offset points to outside of file.
3
+ this.ifd0Offset: ${this.ifd0Offset}, file.byteLength: ${t.byteLength}`),t.tiff&&await t.ensureChunk(this.ifd0Offset,Cl(this.options));let e=this.parseBlock(this.ifd0Offset,"ifd0");return e.size!==0?(this.exifOffset=e.get(34665),this.interopOffset=e.get(40965),this.gpsOffset=e.get(34853),this.xmp=e.get(700),this.iptc=e.get(33723),this.icc=e.get(34675),this.options.sanitize&&(e.delete(34665),e.delete(40965),e.delete(34853),e.delete(700),e.delete(33723),e.delete(34675)),e):void 0}async parseExifBlock(){if(this.exif||(this.ifd0||await this.parseIfd0Block(),this.exifOffset===void 0))return;this.file.tiff&&await this.file.ensureChunk(this.exifOffset,Cl(this.options));let t=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=t.get(40965)),this.makerNote=t.get(37500),this.userComment=t.get(37510),this.options.sanitize&&(t.delete(40965),t.delete(37500),t.delete(37510)),this.unpack(t,41728),this.unpack(t,41729),t}unpack(t,e){let i=t.get(e);i&&i.length===1&&t.set(e,i[0])}async parseGpsBlock(){if(this.gps||(this.ifd0||await this.parseIfd0Block(),this.gpsOffset===void 0))return;let t=this.parseBlock(this.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",Il(...t.get(2),t.get(1))),t.set("longitude",Il(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),this.interopOffset!==void 0||this.exif||await this.parseExifBlock(),this.interopOffset!==void 0))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(t=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||t))return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),this.ifd1}async extractThumbnail(){if(this.headerParsed||this.parseHeader(),this.ifd1Parsed||await this.parseThumbnailBlock(!0),this.ifd1===void 0)return;let t=this.ifd1.get(513),e=this.ifd1.get(514);return this.chunk.getUint8Array(t,e)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let t,e,i,n={};for(e of Jt)if(t=this[e],!Nl(t))if(i=this.canTranslate?this.translateBlock(t,e):Object.fromEntries(t),this.options.mergeOutput){if(e==="ifd1")continue;Object.assign(n,i)}else n[e]=i;return this.makerNote&&(n.makerNote=this.makerNote),this.userComment&&(n.userComment=this.userComment),n}assignToOutput(t,e){if(this.globalOptions.mergeOutput)Object.assign(t,e);else for(let[i,n]of Object.entries(e))this.assignObjectToOutput(t,i,n)}};function Il(s,t,e,i){var n=s+t/60+e/3600;return i!=="S"&&i!=="W"||(n*=-1),n}Ft(Gs,"type","tiff"),Ft(Gs,"headerLength",10),fe.set("tiff",Gs);var ad=Object.freeze({__proto__:null,default:ed,Exifr:Qe,fileParsers:Ni,segmentParsers:fe,fileReaders:Bi,tagKeys:Ye,tagValues:gs,tagRevivers:Oi,createDictionary:Re,extendDictionary:Ba,fetchUrlAsArrayBuffer:us,readBlobAsArrayBuffer:ps,chunkedProps:Mi,otherSegments:Ys,segments:fs,tiffBlocks:Jt,segmentsAndBlocks:Ri,tiffExtractables:Li,inheritables:Js,allFormatters:Fi,Options:pi,parse:Ua}),$a={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Hl=Object.assign({},$a,{firstChunkSize:4e4,gps:[1,2,3,4]});async function od(s){let t=new Qe(Hl);await t.read(s);let e=await t.parse();if(e&&e.gps){let{latitude:i,longitude:n}=e.gps;return{latitude:i,longitude:n}}}var zl=Object.assign({},$a,{tiff:!1,ifd1:!0,mergeOutput:!1});async function ld(s){let t=new Qe(zl);await t.read(s);let e=await t.extractThumbnail();return e&&Na?Oa.from(e):e}async function cd(s){let t=await this.thumbnail(s);if(t!==void 0){let e=new Blob([t]);return URL.createObjectURL(e)}}var jl=Object.assign({},$a,{firstChunkSize:4e4,ifd0:[274]});async function Vl(s){let t=new Qe(jl);await t.read(s);let e=await t.parse();if(e&&e.ifd0)return e.ifd0[274]}var Gl=Object.freeze({1:{dimensionSwapped:!1,scaleX:1,scaleY:1,deg:0,rad:0},2:{dimensionSwapped:!1,scaleX:-1,scaleY:1,deg:0,rad:0},3:{dimensionSwapped:!1,scaleX:1,scaleY:1,deg:180,rad:180*Math.PI/180},4:{dimensionSwapped:!1,scaleX:-1,scaleY:1,deg:180,rad:180*Math.PI/180},5:{dimensionSwapped:!0,scaleX:1,scaleY:-1,deg:90,rad:90*Math.PI/180},6:{dimensionSwapped:!0,scaleX:1,scaleY:1,deg:90,rad:90*Math.PI/180},7:{dimensionSwapped:!0,scaleX:1,scaleY:-1,deg:270,rad:270*Math.PI/180},8:{dimensionSwapped:!0,scaleX:1,scaleY:1,deg:270,rad:270*Math.PI/180}}),hs=!0,ds=!0;if(typeof navigator=="object"){let s=navigator.userAgent;if(s.includes("iPad")||s.includes("iPhone")){let t=s.match(/OS (\d+)_(\d+)/);if(t){let[,e,i]=t;hs=Number(e)+.1*Number(i)<13.4,ds=!1}}else if(s.includes("OS X 10")){let[,t]=s.match(/OS X 10[_.](\d+)/);hs=ds=Number(t)<15}if(s.includes("Chrome/")){let[,t]=s.match(/Chrome\/(\d+)/);hs=ds=Number(t)<81}else if(s.includes("Firefox/")){let[,t]=s.match(/Firefox\/(\d+)/);hs=ds=Number(t)<77}}async function hd(s){let t=await Vl(s);return Object.assign({canvas:hs,css:ds},Gl[t])}var Ia=class extends Je{constructor(...t){super(...t),Ft(this,"ranges",new Ma),this.byteLength!==0&&this.ranges.add(0,this.byteLength)}_tryExtend(t,e,i){if(t===0&&this.byteLength===0&&i){let n=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(n)}else{let n=t+e;if(n>this.byteLength){let{dataView:o}=this._extend(n);this._swapDataView(o)}}}_extend(t){let e;e=Na?Oa.allocUnsafe(t):new Uint8Array(t);let i=new DataView(e.buffer,e.byteOffset,e.byteLength);return e.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:e,dataView:i}}subarray(t,e,i=!1){return e=e||this._lengthToEnd(t),i&&this._tryExtend(t,e),this.ranges.add(t,e),super.subarray(t,e)}set(t,e,i=!1){i&&this._tryExtend(e,t.byteLength,t);let n=super.set(t,e);return this.ranges.add(e,n.byteLength),n}async ensureChunk(t,e){this.chunked&&(this.ranges.available(t,e)||await this.readChunk(t,e))}available(t,e){return this.ranges.available(t,e)}},Ma=class{constructor(){Ft(this,"list",[])}get length(){return this.list.length}add(t,e,i=0){let n=t+e,o=this.list.filter((h=>Ml(t,h.offset,n)||Ml(t,h.end,n)));if(o.length>0){t=Math.min(t,...o.map((u=>u.offset))),n=Math.max(n,...o.map((u=>u.end))),e=n-t;let h=o.shift();h.offset=t,h.length=e,h.end=n,this.list=this.list.filter((u=>!o.includes(u)))}else this.list.push({offset:t,length:e,end:n})}available(t,e){let i=t+e;return this.list.some((n=>n.offset<=t&&i<=n.end))}};function Ml(s,t,e){return s<=t&&t<=e}var hr=class extends Ia{constructor(t,e){super(0),Ft(this,"chunksRead",0),this.input=t,this.options=e}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(t=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let e=this.options.chunkSize,i=await this.readChunk(t,e);return!!i&&i.byteLength===e}async readChunk(t,e){if(this.chunksRead++,(e=this.safeWrapAddress(t,e))!==0)return this._readChunk(t,e)}safeWrapAddress(t,e){return this.size!==void 0&&t+e>this.size?Math.max(0,this.size-t):e}get nextChunkOffset(){if(this.ranges.list.length!==0)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return this.size!==void 0&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}};Bi.set("blob",class extends hr{async readWhole(){this.chunked=!1;let s=await ps(this.input);this._swapArrayBuffer(s)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(s,t){let e=t?s+t:void 0,i=this.input.slice(s,e),n=await ps(i);return this.set(n,s,!0)}});var dd=Object.freeze({__proto__:null,default:ad,Exifr:Qe,fileParsers:Ni,segmentParsers:fe,fileReaders:Bi,tagKeys:Ye,tagValues:gs,tagRevivers:Oi,createDictionary:Re,extendDictionary:Ba,fetchUrlAsArrayBuffer:us,readBlobAsArrayBuffer:ps,chunkedProps:Mi,otherSegments:Ys,segments:fs,tiffBlocks:Jt,segmentsAndBlocks:Ri,tiffExtractables:Li,inheritables:Js,allFormatters:Fi,Options:pi,parse:Ua,gpsOnlyOptions:Hl,gps:od,thumbnailOnlyOptions:zl,thumbnail:ld,thumbnailUrl:cd,orientationOnlyOptions:jl,orientation:Vl,rotations:Gl,get rotateCanvas(){return hs},get rotateCss(){return ds},rotation:hd});Bi.set("url",class extends hr{async readWhole(){this.chunked=!1;let s=await us(this.input);s instanceof ArrayBuffer?this._swapArrayBuffer(s):s instanceof Uint8Array&&this._swapBuffer(s)}async _readChunk(s,t){let e=t?s+t-1:void 0,i=this.options.httpHeaders||{};(s||e)&&(i.range=`bytes=${[s,e].join("-")}`);let n=await $l(this.input,{headers:i}),o=await n.arrayBuffer(),h=o.byteLength;if(n.status!==416)return h!==t&&(this.size=s+h),this.set(o,s,!0)}});Je.prototype.getUint64=function(s){let t=this.getUint32(s),e=this.getUint32(s+4);return t<1048575?t<<32|e:typeof nr!==void 0?(console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),nr(t)<<nr(32)|nr(e)):void ee("Trying to read 64b value but JS can only handle 53b numbers.")};var Ra=class extends lr{parseBoxes(t=0){let e=[];for(;t<this.file.byteLength-4;){let i=this.parseBoxHead(t);if(e.push(i),i.length===0)break;t+=i.length}return e}parseSubBoxes(t){t.boxes=this.parseBoxes(t.start)}findBox(t,e){return t.boxes===void 0&&this.parseSubBoxes(t),t.boxes.find((i=>i.kind===e))}parseBoxHead(t){let e=this.file.getUint32(t),i=this.file.getString(t+4,4),n=t+8;return e===1&&(e=this.file.getUint64(t+8),n+=8),{offset:t,length:e,kind:i,start:n}}parseBoxFullHead(t){if(t.version!==void 0)return;let e=this.file.getUint32(t.start);t.version=e>>24,t.start+=4}},dr=class extends Ra{static canHandle(t,e){if(e!==0)return!1;let i=t.getUint16(2);if(i>50)return!1;let n=16,o=[];for(;n<i;)o.push(t.getString(n,4)),n+=4;return o.includes(this.type)}async parse(){let t=this.file.getUint32(0),e=this.parseBoxHead(t);for(;e.kind!=="meta";)t+=e.length,await this.file.ensureChunk(t,16),e=this.parseBoxHead(t);await this.file.ensureChunk(e.offset,e.length),this.parseBoxFullHead(e),this.parseSubBoxes(e),this.options.icc.enabled&&await this.findIcc(e),this.options.tiff.enabled&&await this.findExif(e)}async registerSegment(t,e,i){await this.file.ensureChunk(e,i);let n=this.file.subarray(e,i);this.createParser(t,n)}async findIcc(t){let e=this.findBox(t,"iprp");if(e===void 0)return;let i=this.findBox(e,"ipco");if(i===void 0)return;let n=this.findBox(i,"colr");n!==void 0&&await this.registerSegment("icc",n.offset+12,n.length)}async findExif(t){let e=this.findBox(t,"iinf");if(e===void 0)return;let i=this.findBox(t,"iloc");if(i===void 0)return;let n=this.findExifLocIdInIinf(e),o=this.findExtentInIloc(i,n);if(o===void 0)return;let[h,u]=o;await this.file.ensureChunk(h,u);let g=4+this.file.getUint32(h);h+=g,u-=g,await this.registerSegment("tiff",h,u)}findExifLocIdInIinf(t){this.parseBoxFullHead(t);let e,i,n,o,h=t.start,u=this.file.getUint16(h);for(h+=2;u--;){if(e=this.parseBoxHead(h),this.parseBoxFullHead(e),i=e.start,e.version>=2&&(n=e.version===3?4:2,o=this.file.getString(i+n+2,4),o==="Exif"))return this.file.getUintBytes(i,n);h+=e.length}}get8bits(t){let e=this.file.getUint8(t);return[e>>4,15&e]}findExtentInIloc(t,e){this.parseBoxFullHead(t);let i=t.start,[n,o]=this.get8bits(i++),[h,u]=this.get8bits(i++),g=t.version===2?4:2,v=t.version===1||t.version===2?2:0,p=u+n+o,a=t.version===2?4:2,f=this.file.getUintBytes(i,a);for(i+=a;f--;){let A=this.file.getUintBytes(i,g);i+=g+v+2+h;let _=this.file.getUint16(i);if(i+=2,A===e)return _>1&&console.warn(`ILOC box has more than one extent but we're only processing one
4
+ Please create an issue at https://github.com/MikeKovarik/exifr with this file`),[this.file.getUintBytes(i+u,n),this.file.getUintBytes(i+u+n,o)];i+=_*p}}},ur=class extends dr{};Ft(ur,"type","heic");var pr=class extends dr{};Ft(pr,"type","avif"),Ni.set("heic",ur),Ni.set("avif",pr),Re(Ye,["ifd0","ifd1"],[[256,"ImageWidth"],[257,"ImageHeight"],[258,"BitsPerSample"],[259,"Compression"],[262,"PhotometricInterpretation"],[270,"ImageDescription"],[271,"Make"],[272,"Model"],[273,"StripOffsets"],[274,"Orientation"],[277,"SamplesPerPixel"],[278,"RowsPerStrip"],[279,"StripByteCounts"],[282,"XResolution"],[283,"YResolution"],[284,"PlanarConfiguration"],[296,"ResolutionUnit"],[301,"TransferFunction"],[305,"Software"],[306,"ModifyDate"],[315,"Artist"],[316,"HostComputer"],[317,"Predictor"],[318,"WhitePoint"],[319,"PrimaryChromaticities"],[513,"ThumbnailOffset"],[514,"ThumbnailLength"],[529,"YCbCrCoefficients"],[530,"YCbCrSubSampling"],[531,"YCbCrPositioning"],[532,"ReferenceBlackWhite"],[700,"ApplicationNotes"],[33432,"Copyright"],[33723,"IPTC"],[34665,"ExifIFD"],[34675,"ICC"],[34853,"GpsIFD"],[330,"SubIFD"],[40965,"InteropIFD"],[40091,"XPTitle"],[40092,"XPComment"],[40093,"XPAuthor"],[40094,"XPKeywords"],[40095,"XPSubject"]]),Re(Ye,"exif",[[33434,"ExposureTime"],[33437,"FNumber"],[34850,"ExposureProgram"],[34852,"SpectralSensitivity"],[34855,"ISO"],[34858,"TimeZoneOffset"],[34859,"SelfTimerMode"],[34864,"SensitivityType"],[34865,"StandardOutputSensitivity"],[34866,"RecommendedExposureIndex"],[34867,"ISOSpeed"],[34868,"ISOSpeedLatitudeyyy"],[34869,"ISOSpeedLatitudezzz"],[36864,"ExifVersion"],[36867,"DateTimeOriginal"],[36868,"CreateDate"],[36873,"GooglePlusUploadCode"],[36880,"OffsetTime"],[36881,"OffsetTimeOriginal"],[36882,"OffsetTimeDigitized"],[37121,"ComponentsConfiguration"],[37122,"CompressedBitsPerPixel"],[37377,"ShutterSpeedValue"],[37378,"ApertureValue"],[37379,"BrightnessValue"],[37380,"ExposureCompensation"],[37381,"MaxApertureValue"],[37382,"SubjectDistance"],[37383,"MeteringMode"],[37384,"LightSource"],[37385,"Flash"],[37386,"FocalLength"],[37393,"ImageNumber"],[37394,"SecurityClassification"],[37395,"ImageHistory"],[37396,"SubjectArea"],[37500,"MakerNote"],[37510,"UserComment"],[37520,"SubSecTime"],[37521,"SubSecTimeOriginal"],[37522,"SubSecTimeDigitized"],[37888,"AmbientTemperature"],[37889,"Humidity"],[37890,"Pressure"],[37891,"WaterDepth"],[37892,"Acceleration"],[37893,"CameraElevationAngle"],[40960,"FlashpixVersion"],[40961,"ColorSpace"],[40962,"ExifImageWidth"],[40963,"ExifImageHeight"],[40964,"RelatedSoundFile"],[41483,"FlashEnergy"],[41486,"FocalPlaneXResolution"],[41487,"FocalPlaneYResolution"],[41488,"FocalPlaneResolutionUnit"],[41492,"SubjectLocation"],[41493,"ExposureIndex"],[41495,"SensingMethod"],[41728,"FileSource"],[41729,"SceneType"],[41730,"CFAPattern"],[41985,"CustomRendered"],[41986,"ExposureMode"],[41987,"WhiteBalance"],[41988,"DigitalZoomRatio"],[41989,"FocalLengthIn35mmFormat"],[41990,"SceneCaptureType"],[41991,"GainControl"],[41992,"Contrast"],[41993,"Saturation"],[41994,"Sharpness"],[41996,"SubjectDistanceRange"],[42016,"ImageUniqueID"],[42032,"OwnerName"],[42033,"SerialNumber"],[42034,"LensInfo"],[42035,"LensMake"],[42036,"LensModel"],[42037,"LensSerialNumber"],[42080,"CompositeImage"],[42081,"CompositeImageCount"],[42082,"CompositeImageExposureTimes"],[42240,"Gamma"],[59932,"Padding"],[59933,"OffsetSchema"],[65e3,"OwnerName"],[65001,"SerialNumber"],[65002,"Lens"],[65100,"RawFile"],[65101,"Converter"],[65102,"WhiteBalance"],[65105,"Exposure"],[65106,"Shadows"],[65107,"Brightness"],[65108,"Contrast"],[65109,"Saturation"],[65110,"Sharpness"],[65111,"Smoothness"],[65112,"MoireFilter"],[40965,"InteropIFD"]]),Re(Ye,"gps",[[0,"GPSVersionID"],[1,"GPSLatitudeRef"],[2,"GPSLatitude"],[3,"GPSLongitudeRef"],[4,"GPSLongitude"],[5,"GPSAltitudeRef"],[6,"GPSAltitude"],[7,"GPSTimeStamp"],[8,"GPSSatellites"],[9,"GPSStatus"],[10,"GPSMeasureMode"],[11,"GPSDOP"],[12,"GPSSpeedRef"],[13,"GPSSpeed"],[14,"GPSTrackRef"],[15,"GPSTrack"],[16,"GPSImgDirectionRef"],[17,"GPSImgDirection"],[18,"GPSMapDatum"],[19,"GPSDestLatitudeRef"],[20,"GPSDestLatitude"],[21,"GPSDestLongitudeRef"],[22,"GPSDestLongitude"],[23,"GPSDestBearingRef"],[24,"GPSDestBearing"],[25,"GPSDestDistanceRef"],[26,"GPSDestDistance"],[27,"GPSProcessingMethod"],[28,"GPSAreaInformation"],[29,"GPSDateStamp"],[30,"GPSDifferential"],[31,"GPSHPositioningError"]]),Re(gs,["ifd0","ifd1"],[[274,{1:"Horizontal (normal)",2:"Mirror horizontal",3:"Rotate 180",4:"Mirror vertical",5:"Mirror horizontal and rotate 270 CW",6:"Rotate 90 CW",7:"Mirror horizontal and rotate 90 CW",8:"Rotate 270 CW"}],[296,{1:"None",2:"inches",3:"cm"}]]);var Ws=Re(gs,"exif",[[34850,{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"}],[37121,{0:"-",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}],[37383,{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"}],[37384,{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"}],[37385,{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"}],[41495,{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"}],[41728,{1:"Film Scanner",2:"Reflection Print Scanner",3:"Digital Camera"}],[41729,{1:"Directly photographed"}],[41985,{0:"Normal",1:"Custom",2:"HDR (no original saved)",3:"HDR (original saved)",4:"Original (for HDR)",6:"Panorama",7:"Portrait HDR",8:"Portrait"}],[41986,{0:"Auto",1:"Manual",2:"Auto bracket"}],[41987,{0:"Auto",1:"Manual"}],[41990,{0:"Standard",1:"Landscape",2:"Portrait",3:"Night",4:"Other"}],[41991,{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"}],[41996,{0:"Unknown",1:"Macro",2:"Close",3:"Distant"}],[42080,{0:"Unknown",1:"Not a Composite Image",2:"General Composite Image",3:"Composite Image Captured While Shooting"}]]),Rl={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};Ws.set(37392,Rl),Ws.set(41488,Rl);var Sa={0:"Normal",1:"Low",2:"High"};function Ll(s){return typeof s=="object"&&s.length!==void 0?s[0]:s}function Fl(s){let t=Array.from(s).slice(1);return t[1]>15&&(t=t.map((e=>String.fromCharCode(e)))),t[2]!=="0"&&t[2]!==0||t.pop(),t.join(".")}function Ea(s){if(typeof s=="string"){var[t,e,i,n,o,h]=s.trim().split(/[-: ]/g).map(Number),u=new Date(t,e-1,i);return Number.isNaN(n)||Number.isNaN(o)||Number.isNaN(h)||(u.setHours(n),u.setMinutes(o),u.setSeconds(h)),Number.isNaN(+u)?s:u}}function Vs(s){if(typeof s=="string")return s;let t=[];if(s[1]===0&&s[s.length-1]===0)for(let e=0;e<s.length;e+=2)t.push(Ol(s[e+1],s[e]));else for(let e=0;e<s.length;e+=2)t.push(Ol(s[e],s[e+1]));return Bl(String.fromCodePoint(...t))}function Ol(s,t){return s<<8|t}Ws.set(41992,Sa),Ws.set(41993,Sa),Ws.set(41994,Sa),Re(Oi,["ifd0","ifd1"],[[50827,function(s){return typeof s!="string"?Ul(s):s}],[306,Ea],[40091,Vs],[40092,Vs],[40093,Vs],[40094,Vs],[40095,Vs]]),Re(Oi,"exif",[[40960,Fl],[36864,Fl],[36867,Ea],[36868,Ea],[40962,Ll],[40963,Ll]]),Re(Oi,"gps",[[0,s=>Array.from(s).join(".")],[7,s=>Array.from(s).join(":")]]);var qs=class extends Ke{static canHandle(t,e){return t.getUint8(e+1)===225&&t.getUint32(e+4)===1752462448&&t.getString(e+4,20)==="http://ns.adobe.com/"}static headerLength(t,e){return t.getString(e+4,34)==="http://ns.adobe.com/xmp/extension/"?79:33}static findPosition(t,e){let i=super.findPosition(t,e);return i.multiSegment=i.extended=i.headerLength===79,i.multiSegment?(i.chunkCount=t.getUint8(e+72),i.chunkNumber=t.getUint8(e+76),t.getUint8(e+77)!==0&&i.chunkNumber++):(i.chunkCount=1/0,i.chunkNumber=-1),i}static handleMultiSegments(t){return t.map((e=>e.chunk.getString())).join("")}normalizeInput(t){return typeof t=="string"?t:Je.from(t).getString()}parse(t=this.chunk){if(!this.localOptions.parse)return t;t=(function(o){let h={},u={};for(let g of Kl)h[g]=[],u[g]=0;return o.replace(gd,((g,v,p)=>{if(v==="<"){let a=++u[p];return h[p].push(a),`${g}#${a}`}return`${g}#${h[p].pop()}`}))})(t);let e=fr.findAll(t,"rdf","Description");e.length===0&&e.push(new fr("rdf","Description",void 0,t));let i,n={};for(let o of e)for(let h of o.properties)i=fd(h.ns,n),Wl(h,i);return(function(o){let h;for(let u in o)h=o[u]=rr(o[u]),h===void 0&&delete o[u];return rr(o)})(n)}assignToOutput(t,e){if(this.localOptions.parse)for(let[i,n]of Object.entries(e))switch(i){case"tiff":this.assignObjectToOutput(t,"ifd0",n);break;case"exif":this.assignObjectToOutput(t,"exif",n);break;case"xmlns":break;default:this.assignObjectToOutput(t,i,n)}else t.xmp=e}};Ft(qs,"type","xmp"),Ft(qs,"multiSegment",!0),fe.set("xmp",qs);var La=class s{static findAll(t){return ql(t,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(s.unpackMatch)}static unpackMatch(t){let e=t[1],i=t[2],n=t[3].slice(1,-1);return n=Xl(n),new s(e,i,n)}constructor(t,e,i){this.ns=t,this.name=e,this.value=i}serialize(){return this.value}},fr=class s{static findAll(t,e,i){if(e!==void 0||i!==void 0){e=e||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var n=new RegExp(`<(${e}):(${i})(#\\d+)?((\\s+?[\\w\\d-:]+=("[^"]*"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)`,"gm")}else n=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return ql(t,n).map(s.unpackMatch)}static unpackMatch(t){let e=t[1],i=t[2],n=t[4],o=t[8];return new s(e,i,n,o)}constructor(t,e,i,n){this.ns=t,this.name=e,this.attrString=i,this.innerXml=n,this.attrs=La.findAll(i),this.children=s.findAll(n),this.value=this.children.length===0?Xl(n):void 0,this.properties=[...this.attrs,...this.children]}get isPrimitive(){return this.value!==void 0&&this.attrs.length===0&&this.children.length===0}get isListContainer(){return this.children.length===1&&this.children[0].isList}get isList(){let{ns:t,name:e}=this;return t==="rdf"&&(e==="Seq"||e==="Bag"||e==="Alt")}get isListItem(){return this.ns==="rdf"&&this.name==="li"}serialize(){if(this.properties.length===0&&this.value===void 0)return;if(this.isPrimitive)return this.value;if(this.isListContainer)return this.children[0].serialize();if(this.isList)return pd(this.children.map(ud));if(this.isListItem&&this.children.length===1&&this.attrs.length===0)return this.children[0].serialize();let t={};for(let e of this.properties)Wl(e,t);return this.value!==void 0&&(t.value=this.value),rr(t)}};function Wl(s,t){let e=s.serialize();e!==void 0&&(t[s.name]=e)}var ud=s=>s.serialize(),pd=s=>s.length===1?s[0]:s,fd=(s,t)=>t[s]?t[s]:t[s]={};function ql(s,t){let e,i=[];if(!s)return i;for(;(e=t.exec(s))!==null;)i.push(e);return i}function Xl(s){if((function(i){return i==null||i==="null"||i==="undefined"||i===""||i.trim()===""})(s))return;let t=Number(s);if(!Number.isNaN(t))return t;let e=s.toLowerCase();return e==="true"||e!=="false"&&s.trim()}var Kl=["rdf:li","rdf:Seq","rdf:Bag","rdf:Alt","rdf:Description"],gd=new RegExp(`(<|\\/)(${Kl.join("|")})`,"g"),Yl=dd;async function gr(s){try{return await Yl.parse(s)||null}catch{return null}}function Te(){return Array.from(crypto.getRandomValues(new Uint8Array(16)),s=>s.toString(16).padStart(2,"0")).join("")}async function mr(s){if(typeof createImageBitmap>"u"||typeof document>"u"){if(s&&typeof s.arrayBuffer=="function"){let u=await s.arrayBuffer(),g=globalThis.Buffer,v=typeof g<"u"?g.from(u).toString("base64"):btoa(String.fromCharCode(...new Uint8Array(u)));return`data:${s.type||"image/png"};base64,${v}`}if(typeof s=="string")return s}let t=await createImageBitmap(s),n=Math.min(1,1654/t.width,2339/t.height);if(n===1&&(s.type==="image/jpeg"||s.type==="image/jpg"||s.type==="image/png"||s.type==="image/webp"))return t.close(),new Promise((u,g)=>{let v=new FileReader;v.onload=()=>u(v.result),v.onerror=g,v.readAsDataURL(s)});let o=document.createElement("canvas");o.width=Math.round(t.width*n),o.height=Math.round(t.height*n),o.getContext("2d").drawImage(t,0,0,o.width,o.height),t.close();let h=s.type==="image/png"?"image/png":"image/jpeg";return o.toDataURL(h,h==="image/png"?void 0:.82)}function Jl(s,t=21,e=.2,i=128){let{data:n,width:o,height:h}=s,u=o+1,g=new Float64Array((o+1)*(h+1)),v=new Float64Array((o+1)*(h+1)),p=new Uint8Array(o*h);for(let f=0;f<h;f++){let A=0,_=0,d=f*o,y=(f+1)*u,r=f*u;for(let l=0;l<o;l++){let m=(d+l)*4,x=n[m]*77+n[m+1]*150+n[m+2]*29>>8;p[d+l]=x,A+=x,_+=x*x,g[y+l+1]=g[r+l+1]+A,v[y+l+1]=v[r+l+1]+_}}let a=Math.floor(t/2);for(let f=0;f<h;f++){let A=Math.max(0,f-a),_=Math.min(h-1,f+a),d=A*u,y=(_+1)*u;for(let r=0;r<o;r++){let l=Math.max(0,r-a),m=Math.min(o-1,r+a),x=(m-l+1)*(_-A+1),D=g[y+m+1]-g[d+m+1]-g[y+l]+g[d+l],E=v[y+m+1]-v[d+m+1]-v[y+l]+v[d+l],M=D/x,N=Math.max(0,E/x-M*M),H=Math.sqrt(N),z=M*(1+e*(H/i-1)),K=f*o+r,it=p[K]<z?0:255,ot=K*4;n[ot]=it,n[ot+1]=it,n[ot+2]=it}}return s}function je(s){if(!s||typeof s!="object")return{crop:null,rotation:0,filter:"none"};let t=s.crop&&typeof s.crop=="object"&&s.crop.width>0&&s.crop.height>0?{x:Math.round(s.crop.x||0),y:Math.round(s.crop.y||0),width:Math.round(s.crop.width),height:Math.round(s.crop.height)}:null,e=(Math.round(s.rotation||0)%360+360)%360,i=s.filter==="bw"?"bw":"none";return{crop:t,rotation:e,filter:i}}function Ha(s){if(!s)return!1;let t=je(s);return!!(t.crop||t.rotation!==0||t.filter!=="none")}function ms(s,t){let e=je(t),i=s.naturalWidth||s.width||0,n=s.naturalHeight||s.height||0,o=document.createElement("canvas"),h=i,u=n,g=0,v=0;e.crop&&(g=Math.max(0,Math.min(e.crop.x,i)),v=Math.max(0,Math.min(e.crop.y,n)),h=Math.max(1,Math.min(e.crop.width,i-g)),u=Math.max(1,Math.min(e.crop.height,n-v))),o.width=h,o.height=u,o.getContext("2d").drawImage(s,g,v,h,u,0,0,h,u);let a=o;if(e.rotation!==0){let f=e.rotation,A=document.createElement("canvas");f===90||f===270?(A.width=a.height,A.height=a.width):(A.width=a.width,A.height=a.height);let _=A.getContext("2d");_.translate(A.width/2,A.height/2),_.rotate(f*Math.PI/180),_.drawImage(a,-a.width/2,-a.height/2),a=A}if(e.filter==="bw"){let f=a.getContext("2d"),A=f.getImageData(0,0,a.width,a.height);Jl(A),f.putImageData(A,0,0)}return a}function br(s,t){if(!s)return Promise.resolve("");let e=je(t);return Ha(e)?new Promise((i,n)=>{let o=new Image;o.onload=()=>{try{let h=s.startsWith("data:image/png"),u=h?"image/png":"image/jpeg",g=ms(o,e);i(g.toDataURL(u,h?void 0:.82))}catch(h){n(h)}},o.onerror=n,o.src=s}):Promise.resolve(s)}var bs=class{#t=null;#e=new Map;#i=new Map;constructor(t=sr()){this.#t=t}get adapter(){return this.#t}get store(){return this.#t?.store??null}async init(){return this.#t.init()}listDocsSync(){return typeof this.#t.listDocsSync=="function"?this.#t.listDocsSync().map(e=>{let i=this.#s(e.pages);return{id:e.id,name:e.name||"",pageCount:i.length,pages:i}}):[]}async listDocs(){return(await this.#t.listDocs()).map(e=>{let i=this.#s(e.pages);return{id:e.id,name:e.name||"",pageCount:i.length,pages:i}})}getDocSync(t){if(!t)return null;if(typeof this.#t.getDocSync=="function"){let n=this.#t.getDocSync(t);return n?{id:n.id,name:n.name||"",pages:this.#s(n.pages)}:null}let i=this.listDocsSync().find(n=>n.id===t);return i?{id:i.id,name:i.name,pages:i.pages||[]}:null}async getDoc(t){return this.getDocSync(t)}async createDoc(t="Untitled Document",e=[]){let i=Te(),n=this.#s(e),o={id:i,name:t||"Untitled Document",pages:n};return await this.#t.saveDoc(i,o),o}async saveDoc(t,e){if(!t)throw new Error("Cannot save document without an ID");let i=this.#s(e.pages);await this.#t.saveDoc(t,{id:t,name:e.name||"",pages:i})}async renameDoc(t,e){let i=await this.getDoc(t);if(!i)throw new Error(`Document "${t}" not found`);i.name=e,await this.saveDoc(t,i)}async deleteDoc(t,{soft:e=!0,timeoutMs:i=5e3}={}){if(!t)return;let n=this.getDocSync(t);if(n){if(this.#n(t),await this.#t.deleteDoc(t),e&&i>0){let o=setTimeout(async()=>{this.#e.delete(t)},i);this.#e.set(t,{doc:n,timerId:o})}return{id:t,name:n.name,undo:()=>this.undoDeleteDoc(t)}}}#n(t){if(this.#e.has(t)){let e=this.#e.get(t);clearTimeout(e.timerId),this.#e.delete(t)}}async undoDeleteDoc(t){let e=this.#e.get(t);return e?(clearTimeout(e.timerId),this.#e.delete(t),await this.#t.saveDoc(t,e.doc),e.doc):null}isSoftDeletedDoc(t){return this.#e.has(t)}async addPages(t,e){let i=await this.getDoc(t);if(!i)throw new Error(`Document "${t}" not found`);let n=Array.isArray(e)?e:[e];i.pages.push(...n),await this.saveDoc(t,i)}async updatePage(t,e,i){let n=await this.getDoc(t);if(!n)throw new Error(`Document "${t}" not found`);let o=n.pages.findIndex(h=>h.id===e);if(o===-1)throw new Error(`Page "${e}" not found in document "${t}"`);n.pages[o]={...n.pages[o],...i},await this.saveDoc(t,n)}async reorderPages(t,e){let i=await this.getDoc(t);if(!i)throw new Error(`Document "${t}" not found`);let n=new Map(i.pages.map(h=>[h.id,h])),o=[];for(let h of e)n.has(h)&&(o.push(n.get(h)),n.delete(h));for(let h of n.values())o.push(h);i.pages=o,await this.saveDoc(t,i)}async deletePage(t,e,{soft:i=!0,timeoutMs:n=5e3}={}){let o=await this.getDoc(t);if(!o)throw new Error(`Document "${t}" not found`);let h=o.pages.findIndex(p=>p.id===e);if(h===-1)return;let[u]=o.pages.splice(h,1);await this.saveDoc(t,o);let g=`${t}:${e}`;if(this.#r(g),!i||n<=0){if(typeof this.#t.deletePage=="function")try{await this.#t.deletePage(t,e)}catch(p){console.warn("[DocRepository] Adapter deletePage error:",p)}return}let v=setTimeout(async()=>{if(this.#i.delete(g),typeof this.#t.deletePage=="function")try{await this.#t.deletePage(t,e)}catch(p){console.warn("[DocRepository] Adapter deletePage error:",p)}},n);return this.#i.set(g,{docId:t,pageId:e,page:u,index:h,timerId:v}),{docId:t,pageId:e,undo:()=>this.undoDeletePage(t,e)}}#r(t){if(this.#i.has(t)){let e=this.#i.get(t);clearTimeout(e.timerId),this.#i.delete(t)}}async undoDeletePage(t,e){let i=`${t}:${e}`,n=this.#i.get(i);if(!n)return null;clearTimeout(n.timerId),this.#i.delete(i);let o=await this.getDoc(t);if(!o)return null;let h=Math.min(n.index,o.pages.length);return o.pages.splice(h,0,n.page),await this.saveDoc(t,o),n.page}isSoftDeletedPage(t,e){return this.#i.has(`${t}:${e}`)}subscribe(t){return this.#t.subscribe(t)}async getAllDocs(){let t=await this.listDocs(),e={};for(let i of t)e[i.id]=i;return e}async exportAll(){let t=await this.listDocs(),e={};for(let i of t)e[i.id]={name:i.name,pages:JSON.stringify(i.pages)};return e}async importDocs(t){let e=0;for(let[i,n]of Object.entries(t||{})){await this.getDoc(i)||e++;let h=this.#s(n.pages);await this.saveDoc(i,{name:n.name||"",pages:h})}return e}#s(t){if(Array.isArray(t))return[...t];if(typeof t=="string")try{return JSON.parse(t)}catch{return[]}return[]}},md=new bs;var za=".";function Ql(){return za}function Qs(s){typeof s=="string"&&(za=s.replace(/\/+$/,"")||".")}function ja(s){if(!s)return"";if(/^(https?:|\/\/|data:|blob:)/i.test(s))return s;let t=s.replace(/^\/+/,""),e=za;return!e||e==="."?t:`${e}/${t}`}var vr=new Map;function Zl(s,t){let e=t();if(e)return Promise.resolve(e);if(vr.has(s))return vr.get(s);let i=new Promise((n,o)=>{if(typeof document>"u"){o(new Error(`Cannot load script "${s}" in an environment without DOM document.`));return}let h=ja(s),u=document.querySelector(`script[src="${h}"], script[src="${s}"]`);if(u){if(t()){n(t());return}u.addEventListener("load",()=>n(t()),{once:!0}),u.addEventListener("error",()=>o(new Error(`Failed to load "${s}": Network error`)),{once:!0});return}let g=document.createElement("script");g.src=h,g.async=!0,g.onload=()=>{let v=t();n(v)},g.onerror=()=>{vr.delete(s),g.remove(),o(new Error(`Failed to load script "${s}": Network error`))},document.head.appendChild(g)});return vr.set(s,i),i}async function tc(){return Zl("js/lib/cropper.js",()=>window.Cropper)}async function ec(){return Zl("js/lib/marked.min.js",()=>window.marked)}var yr=class{async recognizeImageText(t,e={}){throw new Error("OcrPort.recognizeImageText() must be implemented by adapter")}async recognizeDocumentPages(t,e={}){throw new Error("OcrPort.recognizeDocumentPages() must be implemented by adapter")}async getOcrWorker(t="eng",e=null){throw new Error("OcrPort.getOcrWorker() must be implemented by adapter")}async terminateOcrWorker(){throw new Error("OcrPort.terminateOcrWorker() must be implemented by adapter")}};var Ze=class extends yr{async recognizeImageText(t,e={}){let i=new Error('Feature "ocr" is disabled or OCR module not opted in');throw i.code="FEATURE_DISABLED",i}async recognizeDocumentPages(t,e={}){let i=new Error('Feature "ocr" is disabled or OCR module not opted in');throw i.code="FEATURE_DISABLED",i}async getOcrWorker(){return null}async terminateOcrWorker(){}};var wr=class{async exportDocumentAsPdf(t,e,i={}){throw new Error("PdfPort.exportDocumentAsPdf() must be implemented by adapter")}async renderPdfPagesToDataUrls(t){throw new Error("PdfPort.renderPdfPagesToDataUrls() must be implemented by adapter")}};var Ui=class extends wr{async exportDocumentAsPdf(t,e,i={}){let n=new Error('Feature "pdf" is disabled or PDF module not opted in');throw n.code="FEATURE_DISABLED",n}async renderPdfPagesToDataUrls(t){return[]}};var $i=class{async renderEdits(t,e){throw new Error("ImageProcessorPort.renderEdits() must be implemented by adapter")}async crop(t,e){throw new Error("ImageProcessorPort.crop() must be implemented by adapter")}async rotate(t,e){throw new Error("ImageProcessorPort.rotate() must be implemented by adapter")}async applyFilter(t,e){throw new Error("ImageProcessorPort.applyFilter() must be implemented by adapter")}};function bd(s){return new Promise((t,e)=>{let i=new Image;i.onload=()=>t(i),i.onerror=e,i.src=s})}var Zs=class extends $i{async renderEdits(t,e={}){if(!t)return"";if(typeof document>"u")return t;try{let i=await bd(t),n={...e};return e?.crop&&"w"in e.crop&&(n.crop={x:Math.round((e.crop.x||0)*i.naturalWidth),y:Math.round((e.crop.y||0)*i.naturalHeight),width:Math.round((e.crop.w||1)*i.naturalWidth),height:Math.round((e.crop.h||1)*i.naturalHeight)}),e?.rotate!==void 0&&(n.rotation=e.rotate),ms(i,n).toDataURL("image/jpeg",.92)}catch{return t}}async crop(t,e){return this.renderEdits(t,{crop:e})}async rotate(t,e){return this.renderEdits(t,{rotate:e})}async applyFilter(t,e){return this.renderEdits(t,{filter:e})}};var tn=class extends $i{async renderEdits(t,e){return t}async crop(t,e){return t}async rotate(t,e){return t}async applyFilter(t,e){return t}};function ic(s={}){let t=s&&s.crop&&typeof s.crop=="object"?{x:Math.max(0,Math.min(1,Number(s.crop.x)||0)),y:Math.max(0,Math.min(1,Number(s.crop.y)||0)),w:Math.max(0,Math.min(1,Number(s.crop.w)||1)),h:Math.max(0,Math.min(1,Number(s.crop.h)||1))}:null,e=0;if(s&&s.rotate!==void 0){let n=(Math.round(Number(s.rotate)/90)*90%360+360)%360;(n===90||n===180||n===270)&&(e=n)}let i=s&&s.filter==="bw"?"bw":"none";return{crop:t,rotate:e,filter:i}}var se={PAGE_ADDED:"copio:page-added",PAGE_REMOVED:"copio:page-removed",PAGES_CHANGED:"copio:pages-changed",SCAN_COMPLETE:"copio:scan-complete",EXPORT_PROGRESS:"copio:export-progress",EXPORT_COMPLETE:"copio:export-complete",OCR_COMPLETE:"copio:ocr-complete",SYNC_CONNECTED:"copio:sync-connected",ERROR:"copio:error"};function sc(s,t,e={}){let i=new CustomEvent(t,{bubbles:!0,composed:!0,cancelable:!0,detail:e});return s&&typeof s.dispatchEvent=="function"&&s.dispatchEvent(i),i}var Wa=["crop","rotate","filter","ocr","export","sync"],Va=["pdf","zip","png","jpg"],Ga=["eng"],nc={};function vs(s){return nc[s]?nc[s]:typeof globalThis<"u"&&globalThis.__copio_services__?.[s]?globalThis.__copio_services__[s]:null}function vd(s){return s?s instanceof Set?new Set(s):Array.isArray(s)?new Set(s.map(t=>String(t).trim().toLowerCase()).filter(Boolean)):typeof s=="string"?new Set(s.split(/[\s,]+/).map(t=>t.trim().toLowerCase()).filter(Boolean)):new Set(Wa):new Set(Wa)}function xr(s,t){return s?Array.isArray(s)?s.map(e=>String(e).trim().toLowerCase()).filter(Boolean):typeof s=="string"?s.split(/[\s,]+/).map(e=>e.trim().toLowerCase()).filter(Boolean):[...t]:[...t]}var en=class{#t=new Set(Wa);#e=[...Va];#i=[...Ga];#n=0;#r="";#s=null;#a=null;#c={};#o=!0;#d=!0;#p=null;#u=new Map;#l=new Map;constructor(t={}){this.#s=t.storage||sr(t),this.#a=t.repository||new bs(this.#s),t.services&&(this.#c={...t.services}),t.imageProcessor?(this.#p=t.imageProcessor,this.#c.imageProcessor=t.imageProcessor):this.getService("imageProcessor")?this.#p=this.getService("imageProcessor"):typeof document<"u"?this.#p=new Zs:this.#p=new tn,t.features!==void 0&&this.setFeatures(t.features),t.exportFormats!==void 0&&(this.#e=xr(t.exportFormats,Va)),t.ocrLanguages!==void 0&&(this.#i=xr(t.ocrLanguages,Ga)),t.maxPages!==void 0&&(this.#n=Math.max(0,Number(t.maxPages)||0)),t.assetBase!==void 0&&Qs(t.assetBase),t.licenseKey!==void 0&&(this.#r=String(t.licenseKey||"")),t.ocr!==void 0?this.ocr=!!t.ocr:t.features!==void 0&&!this.hasFeature("ocr")&&(this.ocr=!1),t.pdf!==void 0?this.pdf=!!t.pdf:t.exportFormats!==void 0&&!this.#e.includes("pdf")&&(this.pdf=!1)}async init(){return this.#s.init()}setService(t,e){this.#c[t]=e}getService(t){return this.#c[t]||vs(t)}hasFeature(t){return t?this.#t.has(String(t).trim().toLowerCase()):!1}get features(){return Array.from(this.#t)}setFeatures(t){this.#t=vd(t),this.hasFeature("ocr")?(this.#o=!0,this.getService("ocr")instanceof Ze&&this.setService("ocr",vs("ocr"))):(this.#o=!1,this.setService("ocr",new Ze))}enableFeature(t){if(t){let e=String(t).trim().toLowerCase();this.#t.add(e),e==="ocr"&&(this.#o=!0,this.getService("ocr")instanceof Ze&&this.setService("ocr",vs("ocr")))}}disableFeature(t){if(t){let e=String(t).trim().toLowerCase();this.#t.delete(e),e==="ocr"&&(this.#o=!1,this.setService("ocr",new Ze))}}get ocr(){return this.#o&&this.hasFeature("ocr")}set ocr(t){this.#o=!!t,this.#o?(this.enableFeature("ocr"),this.getService("ocr")instanceof Ze&&this.setService("ocr",vs("ocr"))):(this.disableFeature("ocr"),this.setService("ocr",new Ze))}get pdf(){return this.#d&&this.#e.includes("pdf")}set pdf(t){this.#d=!!t,this.#d?(this.#e.includes("pdf")||this.#e.push("pdf"),this.getService("pdf")instanceof Ui&&this.setService("pdf",vs("pdf"))):(this.#e=this.#e.filter(e=>e!=="pdf"),this.setService("pdf",new Ui))}get exportFormats(){return[...this.#e]}set exportFormats(t){this.#e=xr(t,Va),this.#e.includes("pdf")?(this.#d=!0,this.getService("pdf")instanceof Ui&&this.setService("pdf",vs("pdf"))):(this.#d=!1,this.setService("pdf",new Ui))}get ocrLanguages(){return[...this.#i]}set ocrLanguages(t){this.#i=xr(t,Ga)}get maxPages(){return this.#n}set maxPages(t){this.#n=Math.max(0,Number(t)||0)}get assetBase(){return Ql()}set assetBase(t){Qs(t)}get licenseKey(){return this.#r}set licenseKey(t){this.#r=String(t||"")}get storage(){return this.#s}setStorage(t){t&&(this.#s=t,this.#a=new bs(this.#s))}#f(t,e){this.#u.has(t)||this.#u.set(t,[]);let i=this.#u.get(t);i.push(e),i.length>50&&i.shift(),this.#l.has(t)&&(this.#l.get(t).length=0)}get imageProcessor(){return this.#p}setImageProcessor(t){t&&(this.#p=t,this.setService("imageProcessor",t))}get docs(){return this.#a}async listDocuments(){return this.#a.listDocs()}async getDocument(t){return this.#a.getDoc(t)}async createDocument(t,e){return this.#a.createDoc(t,e)}async deleteDocument(t,e={}){return this.#a.deleteDoc(t,e)}async undoDeleteDocument(t){return this.#a.undoDeleteDoc(t)}async renameDocument(t,e){return this.#a.renameDoc(t,e)}async addPages(t,e){return this.#a.addPages(t,e)}async deletePage(t,e,i={}){return this.#f(t,{type:"delete",pageId:e}),this.#a.deletePage(t,e,i)}async undoDeletePage(t,e){return this.#a.undoDeletePage(t,e)}async updatePage(t,e,i){return this.#a.updatePage(t,e,i)}async reorderPages(t,e){let i=await this.getDocument(t),n=i?.pages?i.pages.map(o=>o.id):[];return this.#f(t,{type:"reorder",priorOrder:n,newOrder:[...e]}),this.#a.reorderPages(t,e)}async#g(t){if(t)return t;let e=await this.listDocuments();return e.length>0?e[0].id:null}async applyEdit(t,e,i){let n=await this.#g(t),o=n?await this.getDocument(n):null;if(!o||!o.pages)throw new Error(`Document with ID "${n||t}" not found`);let h=o.pages.find(f=>f.id===e);if(!h)throw new Error(`Page with ID "${e}" not found in document "${n}"`);let u={...h.edits||{crop:null,rotate:0,filter:"none"}},g=h.src,v=ic({...u,...i}),p=h.originalSrc||h.src,a=p;return this.#p&&(a=await this.#p.renderEdits(p,v)),await this.updatePage(n,e,{originalSrc:p,src:a,edits:v}),this.#f(n,{type:"edit",pageId:e,priorEdits:u,priorSrc:g,newEdits:v,newSrc:a}),{...h,originalSrc:p,src:a,edits:v}}async undo(t){let e=await this.#g(t),i=e?this.#u.get(e):null;if(!i||i.length===0)return null;let n=i.pop();return this.#l.has(e)||this.#l.set(e,[]),this.#l.get(e).push(n),n.type==="edit"?(await this.updatePage(e,n.pageId,{edits:n.priorEdits,src:n.priorSrc}),{type:"edit",pageId:n.pageId,restoredEdits:n.priorEdits}):n.type==="delete"?(await this.undoDeletePage(e,n.pageId),{type:"delete",pageId:n.pageId}):n.type==="reorder"?(await this.#a.reorderPages(e,n.priorOrder),{type:"reorder",priorOrder:n.priorOrder}):n}async redo(t){let e=await this.#g(t),i=e?this.#l.get(e):null;if(!i||i.length===0)return null;let n=i.pop();return this.#u.has(e)||this.#u.set(e,[]),this.#u.get(e).push(n),n.type==="edit"?(await this.updatePage(e,n.pageId,{edits:n.newEdits,src:n.newSrc}),{type:"edit",pageId:n.pageId,appliedEdits:n.newEdits}):n.type==="delete"?(await this.deletePage(e,n.pageId),{type:"delete",pageId:n.pageId}):n.type==="reorder"?(await this.reorderPages(e,n.newOrder),{type:"reorder",newOrder:n.newOrder}):n}subscribe(t){return this.#a.subscribe(t)}async addFiles(t,e=null){if(!t||t.length===0)return[];let i=Array.from(t),n=[];for(let h of i)if(h.type==="application/pdf"){let u=this.getService("pdf");if(u&&typeof u.renderPdfPagesToDataUrls=="function"){let g=await u.renderPdfPagesToDataUrls(h);for(let v of g)n.push({id:Te(),src:v,originalSrc:v,edits:{crop:null,rotation:0,filter:"none"},type:"image",name:h.name||"PDF Page"})}else console.warn("PDF import service (PdfPort) not registered. Skipping PDF file.")}else if(h.type&&h.type.startsWith("image/")){let u=await mr(h),g=null;try{g=await gr(h)}catch{}n.push({id:Te(),src:u,originalSrc:u,edits:{crop:null,rotation:0,filter:"none"},type:"image",name:h.name||"Captured Image",orientation:g})}if(n.length===0)return[];let o=e;if(o)await this.getDocument(o)||await this.#a.saveDoc(o,{name:"Scanned Document",pages:[]});else{let h=await this.listDocuments();h.length>0?o=h[0].id:o=(await this.createDocument("Scanned Document",[])).id}if(this.#n>0){let h=(await this.getDocument(o))?.pages||[],u=Math.max(0,this.#n-h.length);if(u<=0)throw new Error(`Maximum page limit (${this.#n}) reached`);n.splice(u)}return await this.addPages(o,n),n}async getPages(t=null){let e=t;if(!e){let n=await this.listDocuments();if(n.length===0)return[];e=n[0].id}return(await this.getDocument(e))?.pages||[]}async clear(t=null){let e=t;if(!e){let n=await this.listDocuments();if(n.length===0)return;e=n[0].id}let i=await this.getDocument(e);if(!(!i||!i.pages))for(let n of i.pages)await this.deletePage(e,n.id)}async#h(t){if(Array.isArray(t))return{docName:"document",pages:t,docId:null};if(typeof t=="string"){let i=await this.getDocument(t);return{docName:i?.name||"document",pages:i?.pages||[],docId:t}}let e=await this.listDocuments();if(e.length>0){let i=await this.getDocument(e[0].id);return{docName:i?.name||"document",pages:i?.pages||[],docId:e[0].id}}return{docName:"document",pages:[],docId:null}}async exportPdf(t,e={}){if(!this.hasFeature("export")){let h=new Error('Feature "export" is disabled');throw Object.assign(h,{code:"FEATURE_DISABLED"}),h}if(!this.#d||!this.#e.includes("pdf")){let h=new Error('Feature "pdf" is disabled');throw Object.assign(h,{code:"FEATURE_DISABLED"}),h}let{docName:i,pages:n}=await this.#h(t),o=this.getService("pdf")||this.getService("export");if(!o||typeof o.exportDocumentAsPdf!="function")throw new Error("Export service (PdfPort) is not registered. Import @copio/sdk or register an exportService.");return o.exportDocumentAsPdf(i,n,{download:!1,showProgress:!1,...e})}async exportZip(t,e={}){if(!this.hasFeature("export")){let h=new Error('Feature "export" is disabled');throw Object.assign(h,{code:"FEATURE_DISABLED"}),h}let{docName:i,pages:n}=await this.#h(t),o=this.getService("export");if(!o||typeof o.exportDocumentAsImages!="function")throw new Error("Export service is not registered. Import @copio/sdk or register an exportService.");return o.exportDocumentAsImages(i,n,{download:!1,showProgress:!1,...e})}async runOcr(t,e=null,i={}){if(!this.#o||!this.hasFeature("ocr")){let v=new Error('Feature "ocr" is disabled');throw Object.assign(v,{code:"FEATURE_DISABLED"}),v}let{pages:n}=await this.#h(t),o=n;e&&(o=n.filter(v=>v.id===e));let h=this.getService("ocr");if(!h||typeof h.recognizeDocumentPages!="function")throw new Error("OCR service (OcrPort) is not registered. Import @copio/sdk or register an ocrService.");let u=i.lang||this.#i[0]||"eng",g=await h.recognizeDocumentPages(o,{lang:u,...i});return{text:g.combinedText,...g}}async sync(t={}){if(!this.hasFeature("sync")){let i=new Error('Feature "sync" is disabled');throw Object.assign(i,{code:"FEATURE_DISABLED"}),i}let e=this.getService("sync");if(!e)throw new Error("Sync service (SyncPort) is not registered. Import @copio/sdk or register a syncService.");return new e(this.#a,t.onStateChange)}};function rc(s,t){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(s,n).enumerable})),e.push.apply(e,i)}return e}function Ge(s){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?rc(Object(e),!0).forEach(function(i){yd(s,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):rc(Object(e)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(e,i))})}return s}function Cr(s){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Cr=function(t){return typeof t}:Cr=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cr(s)}function yd(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}function ei(){return ei=Object.assign||function(s){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(s[i]=e[i])}return s},ei.apply(this,arguments)}function wd(s,t){if(s==null)return{};var e={},i=Object.keys(s),n,o;for(o=0;o<i.length;o++)n=i[o],!(t.indexOf(n)>=0)&&(e[n]=s[n]);return e}function xd(s,t){if(s==null)return{};var e=wd(s,t),i,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(n=0;n<o.length;n++)i=o[n],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(s,i)&&(e[i]=s[i])}return e}var Ad="1.15.6";function ti(s){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(s)}var ii=ti(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),dn=ti(/Edge/i),ac=ti(/firefox/i),an=ti(/safari/i)&&!ti(/chrome/i)&&!ti(/android/i),ao=ti(/iP(ad|od|hone)/i),fc=ti(/chrome/i)&&ti(/android/i),gc={capture:!1,passive:!1};function Lt(s,t,e){s.addEventListener(t,e,!ii&&gc)}function Rt(s,t,e){s.removeEventListener(t,e,!ii&&gc)}function Ir(s,t){if(t){if(t[0]===">"&&(t=t.substring(1)),s)try{if(s.matches)return s.matches(t);if(s.msMatchesSelector)return s.msMatchesSelector(t);if(s.webkitMatchesSelector)return s.webkitMatchesSelector(t)}catch{return!1}return!1}}function mc(s){return s.host&&s!==document&&s.host.nodeType?s.host:s.parentNode}function Fe(s,t,e,i){if(s){e=e||document;do{if(t!=null&&(t[0]===">"?s.parentNode===e&&Ir(s,t):Ir(s,t))||i&&s===e)return s;if(s===e)break}while(s=mc(s))}return null}var oc=/\s+/g;function _e(s,t,e){if(s&&t)if(s.classList)s.classList[e?"add":"remove"](t);else{var i=(" "+s.className+" ").replace(oc," ").replace(" "+t+" "," ");s.className=(i+(e?" "+t:"")).replace(oc," ")}}function Et(s,t,e){var i=s&&s.style;if(i){if(e===void 0)return document.defaultView&&document.defaultView.getComputedStyle?e=document.defaultView.getComputedStyle(s,""):s.currentStyle&&(e=s.currentStyle),t===void 0?e:e[t];!(t in i)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),i[t]=e+(typeof e=="string"?"":"px")}}function Ss(s,t){var e="";if(typeof s=="string")e=s;else do{var i=Et(s,"transform");i&&i!=="none"&&(e=i+" "+e)}while(!t&&(s=s.parentNode));var n=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return n&&new n(e)}function bc(s,t,e){if(s){var i=s.getElementsByTagName(t),n=0,o=i.length;if(e)for(;n<o;n++)e(i[n],n);return i}return[]}function Ve(){var s=document.scrollingElement;return s||document.documentElement}function Zt(s,t,e,i,n){if(!(!s.getBoundingClientRect&&s!==window)){var o,h,u,g,v,p,a;if(s!==window&&s.parentNode&&s!==Ve()?(o=s.getBoundingClientRect(),h=o.top,u=o.left,g=o.bottom,v=o.right,p=o.height,a=o.width):(h=0,u=0,g=window.innerHeight,v=window.innerWidth,p=window.innerHeight,a=window.innerWidth),(t||e)&&s!==window&&(n=n||s.parentNode,!ii))do if(n&&n.getBoundingClientRect&&(Et(n,"transform")!=="none"||e&&Et(n,"position")!=="static")){var f=n.getBoundingClientRect();h-=f.top+parseInt(Et(n,"border-top-width")),u-=f.left+parseInt(Et(n,"border-left-width")),g=h+o.height,v=u+o.width;break}while(n=n.parentNode);if(i&&s!==window){var A=Ss(n||s),_=A&&A.a,d=A&&A.d;A&&(h/=d,u/=_,a/=_,p/=d,g=h+p,v=u+a)}return{top:h,left:u,bottom:g,right:v,width:a,height:p}}}function lc(s,t,e){for(var i=mi(s,!0),n=Zt(s)[t];i;){var o=Zt(i)[e],h=void 0;if(e==="top"||e==="left"?h=n>=o:h=n<=o,!h)return i;if(i===Ve())break;i=mi(i,!1)}return!1}function Es(s,t,e,i){for(var n=0,o=0,h=s.children;o<h.length;){if(h[o].style.display!=="none"&&h[o]!==_t.ghost&&(i||h[o]!==_t.dragged)&&Fe(h[o],e.draggable,s,!1)){if(n===t)return h[o];n++}o++}return null}function oo(s,t){for(var e=s.lastElementChild;e&&(e===_t.ghost||Et(e,"display")==="none"||t&&!Ir(e,t));)e=e.previousElementSibling;return e||null}function Pe(s,t){var e=0;if(!s||!s.parentNode)return-1;for(;s=s.previousElementSibling;)s.nodeName.toUpperCase()!=="TEMPLATE"&&s!==_t.clone&&(!t||Ir(s,t))&&e++;return e}function cc(s){var t=0,e=0,i=Ve();if(s)do{var n=Ss(s),o=n.a,h=n.d;t+=s.scrollLeft*o,e+=s.scrollTop*h}while(s!==i&&(s=s.parentNode));return[t,e]}function Sd(s,t){for(var e in s)if(s.hasOwnProperty(e)){for(var i in t)if(t.hasOwnProperty(i)&&t[i]===s[e][i])return Number(e)}return-1}function mi(s,t){if(!s||!s.getBoundingClientRect)return Ve();var e=s,i=!1;do if(e.clientWidth<e.scrollWidth||e.clientHeight<e.scrollHeight){var n=Et(e);if(e.clientWidth<e.scrollWidth&&(n.overflowX=="auto"||n.overflowX=="scroll")||e.clientHeight<e.scrollHeight&&(n.overflowY=="auto"||n.overflowY=="scroll")){if(!e.getBoundingClientRect||e===document.body)return Ve();if(i||t)return e;i=!0}}while(e=e.parentNode);return Ve()}function Ed(s,t){if(s&&t)for(var e in t)t.hasOwnProperty(e)&&(s[e]=t[e]);return s}function qa(s,t){return Math.round(s.top)===Math.round(t.top)&&Math.round(s.left)===Math.round(t.left)&&Math.round(s.height)===Math.round(t.height)&&Math.round(s.width)===Math.round(t.width)}var on;function vc(s,t){return function(){if(!on){var e=arguments,i=this;e.length===1?s.call(i,e[0]):s.apply(i,e),on=setTimeout(function(){on=void 0},t)}}}function _d(){clearTimeout(on),on=void 0}function yc(s,t,e){s.scrollLeft+=t,s.scrollTop+=e}function wc(s){var t=window.Polymer,e=window.jQuery||window.Zepto;return t&&t.dom?t.dom(s).cloneNode(!0):e?e(s).clone(!0)[0]:s.cloneNode(!0)}function xc(s,t,e){var i={};return Array.from(s.children).forEach(function(n){var o,h,u,g;if(!(!Fe(n,t.draggable,s,!1)||n.animated||n===e)){var v=Zt(n);i.left=Math.min((o=i.left)!==null&&o!==void 0?o:1/0,v.left),i.top=Math.min((h=i.top)!==null&&h!==void 0?h:1/0,v.top),i.right=Math.max((u=i.right)!==null&&u!==void 0?u:-1/0,v.right),i.bottom=Math.max((g=i.bottom)!==null&&g!==void 0?g:-1/0,v.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var xe="Sortable"+new Date().getTime();function Cd(){var s=[],t;return{captureAnimationState:function(){if(s=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(n){if(!(Et(n,"display")==="none"||n===_t.ghost)){s.push({target:n,rect:Zt(n)});var o=Ge({},s[s.length-1].rect);if(n.thisAnimationDuration){var h=Ss(n,!0);h&&(o.top-=h.f,o.left-=h.e)}n.fromRect=o}})}},addAnimationState:function(i){s.push(i)},removeAnimationState:function(i){s.splice(Sd(s,{target:i}),1)},animateAll:function(i){var n=this;if(!this.options.animation){clearTimeout(t),typeof i=="function"&&i();return}var o=!1,h=0;s.forEach(function(u){var g=0,v=u.target,p=v.fromRect,a=Zt(v),f=v.prevFromRect,A=v.prevToRect,_=u.rect,d=Ss(v,!0);d&&(a.top-=d.f,a.left-=d.e),v.toRect=a,v.thisAnimationDuration&&qa(f,a)&&!qa(p,a)&&(_.top-a.top)/(_.left-a.left)===(p.top-a.top)/(p.left-a.left)&&(g=Td(_,f,A,n.options)),qa(a,p)||(v.prevFromRect=p,v.prevToRect=a,g||(g=n.options.animation),n.animate(v,_,a,g)),g&&(o=!0,h=Math.max(h,g),clearTimeout(v.animationResetTimer),v.animationResetTimer=setTimeout(function(){v.animationTime=0,v.prevFromRect=null,v.fromRect=null,v.prevToRect=null,v.thisAnimationDuration=null},g),v.thisAnimationDuration=g)}),clearTimeout(t),o?t=setTimeout(function(){typeof i=="function"&&i()},h):typeof i=="function"&&i(),s=[]},animate:function(i,n,o,h){if(h){Et(i,"transition",""),Et(i,"transform","");var u=Ss(this.el),g=u&&u.a,v=u&&u.d,p=(n.left-o.left)/(g||1),a=(n.top-o.top)/(v||1);i.animatingX=!!p,i.animatingY=!!a,Et(i,"transform","translate3d("+p+"px,"+a+"px,0)"),this.forRepaintDummy=kd(i),Et(i,"transition","transform "+h+"ms"+(this.options.easing?" "+this.options.easing:"")),Et(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){Et(i,"transition",""),Et(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},h)}}}}function kd(s){return s.offsetWidth}function Td(s,t,e,i){return Math.sqrt(Math.pow(t.top-s.top,2)+Math.pow(t.left-s.left,2))/Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))*i.animation}var ys=[],Xa={initializeByDefault:!0},un={mount:function(t){for(var e in Xa)Xa.hasOwnProperty(e)&&!(e in t)&&(t[e]=Xa[e]);ys.forEach(function(i){if(i.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}),ys.push(t)},pluginEvent:function(t,e,i){var n=this;this.eventCanceled=!1,i.cancel=function(){n.eventCanceled=!0};var o=t+"Global";ys.forEach(function(h){e[h.pluginName]&&(e[h.pluginName][o]&&e[h.pluginName][o](Ge({sortable:e},i)),e.options[h.pluginName]&&e[h.pluginName][t]&&e[h.pluginName][t](Ge({sortable:e},i)))})},initializePlugins:function(t,e,i,n){ys.forEach(function(u){var g=u.pluginName;if(!(!t.options[g]&&!u.initializeByDefault)){var v=new u(t,e,t.options);v.sortable=t,v.options=t.options,t[g]=v,ei(i,v.defaults)}});for(var o in t.options)if(t.options.hasOwnProperty(o)){var h=this.modifyOption(t,o,t.options[o]);typeof h<"u"&&(t.options[o]=h)}},getEventProperties:function(t,e){var i={};return ys.forEach(function(n){typeof n.eventProperties=="function"&&ei(i,n.eventProperties.call(e[n.pluginName],t))}),i},modifyOption:function(t,e,i){var n;return ys.forEach(function(o){t[o.pluginName]&&o.optionListeners&&typeof o.optionListeners[e]=="function"&&(n=o.optionListeners[e].call(t[o.pluginName],i))}),n}};function Pd(s){var t=s.sortable,e=s.rootEl,i=s.name,n=s.targetEl,o=s.cloneEl,h=s.toEl,u=s.fromEl,g=s.oldIndex,v=s.newIndex,p=s.oldDraggableIndex,a=s.newDraggableIndex,f=s.originalEvent,A=s.putSortable,_=s.extraEventProperties;if(t=t||e&&e[xe],!!t){var d,y=t.options,r="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!ii&&!dn?d=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(d=document.createEvent("Event"),d.initEvent(i,!0,!0)),d.to=h||e,d.from=u||e,d.item=n||e,d.clone=o,d.oldIndex=g,d.newIndex=v,d.oldDraggableIndex=p,d.newDraggableIndex=a,d.originalEvent=f,d.pullMode=A?A.lastPutMode:void 0;var l=Ge(Ge({},_),un.getEventProperties(i,t));for(var m in l)d[m]=l[m];e&&e.dispatchEvent(d),y[r]&&y[r].call(t,d)}}var Dd=["evt"],we=function(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=i.evt,o=xd(i,Dd);un.pluginEvent.bind(_t)(t,e,Ge({dragEl:gt,parentEl:Yt,ghostEl:kt,rootEl:jt,nextEl:ji,lastDownEl:kr,cloneEl:qt,cloneHidden:gi,dragStarted:sn,putSortable:oe,activeSortable:_t.active,originalEvent:n,oldIndex:As,oldDraggableIndex:ln,newIndex:Ce,newDraggableIndex:fi,hideGhostForTarget:_c,unhideGhostForTarget:Cc,cloneNowHidden:function(){gi=!0},cloneNowShown:function(){gi=!1},dispatchSortableEvent:function(u){ge({sortable:e,name:u,originalEvent:n})}},o))};function ge(s){Pd(Ge({putSortable:oe,cloneEl:qt,targetEl:gt,rootEl:jt,oldIndex:As,oldDraggableIndex:ln,newIndex:Ce,newDraggableIndex:fi},s))}var gt,Yt,kt,jt,ji,kr,qt,gi,As,Ce,ln,fi,Ar,oe,xs=!1,Mr=!1,Rr=[],Hi,Le,Ka,Ya,hc,dc,sn,ws,cn,hn=!1,Sr=!1,Tr,he,Ja=[],io=!1,Lr=[],Or=typeof document<"u",Er=ao,uc=dn||ii?"cssFloat":"float",Id=Or&&!fc&&!ao&&"draggable"in document.createElement("div"),Ac=(function(){if(Or){if(ii)return!1;var s=document.createElement("x");return s.style.cssText="pointer-events:auto",s.style.pointerEvents==="auto"}})(),Sc=function(t,e){var i=Et(t),n=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),o=Es(t,0,e),h=Es(t,1,e),u=o&&Et(o),g=h&&Et(h),v=u&&parseInt(u.marginLeft)+parseInt(u.marginRight)+Zt(o).width,p=g&&parseInt(g.marginLeft)+parseInt(g.marginRight)+Zt(h).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&u.float&&u.float!=="none"){var a=u.float==="left"?"left":"right";return h&&(g.clear==="both"||g.clear===a)?"vertical":"horizontal"}return o&&(u.display==="block"||u.display==="flex"||u.display==="table"||u.display==="grid"||v>=n&&i[uc]==="none"||h&&i[uc]==="none"&&v+p>n)?"vertical":"horizontal"},Md=function(t,e,i){var n=i?t.left:t.top,o=i?t.right:t.bottom,h=i?t.width:t.height,u=i?e.left:e.top,g=i?e.right:e.bottom,v=i?e.width:e.height;return n===u||o===g||n+h/2===u+v/2},Rd=function(t,e){var i;return Rr.some(function(n){var o=n[xe].options.emptyInsertThreshold;if(!(!o||oo(n))){var h=Zt(n),u=t>=h.left-o&&t<=h.right+o,g=e>=h.top-o&&e<=h.bottom+o;if(u&&g)return i=n}}),i},Ec=function(t){function e(o,h){return function(u,g,v,p){var a=u.options.group.name&&g.options.group.name&&u.options.group.name===g.options.group.name;if(o==null&&(h||a))return!0;if(o==null||o===!1)return!1;if(h&&o==="clone")return o;if(typeof o=="function")return e(o(u,g,v,p),h)(u,g,v,p);var f=(h?u:g).options.group.name;return o===!0||typeof o=="string"&&o===f||o.join&&o.indexOf(f)>-1}}var i={},n=t.group;(!n||Cr(n)!="object")&&(n={name:n}),i.name=n.name,i.checkPull=e(n.pull,!0),i.checkPut=e(n.put),i.revertClone=n.revertClone,t.group=i},_c=function(){!Ac&&kt&&Et(kt,"display","none")},Cc=function(){!Ac&&kt&&Et(kt,"display","")};Or&&!fc&&document.addEventListener("click",function(s){if(Mr)return s.preventDefault(),s.stopPropagation&&s.stopPropagation(),s.stopImmediatePropagation&&s.stopImmediatePropagation(),Mr=!1,!1},!0);var zi=function(t){if(gt){t=t.touches?t.touches[0]:t;var e=Rd(t.clientX,t.clientY);if(e){var i={};for(var n in t)t.hasOwnProperty(n)&&(i[n]=t[n]);i.target=i.rootEl=e,i.preventDefault=void 0,i.stopPropagation=void 0,e[xe]._onDragOver(i)}}},Ld=function(t){gt&&gt.parentNode[xe]._isOutsideThisEl(t.target)};function _t(s,t){if(!(s&&s.nodeType&&s.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(s));this.el=s,this.options=t=ei({},t),s[xe]=this;var e={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(s.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Sc(s,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(h,u){h.setData("Text",u.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:_t.supportPointer!==!1&&"PointerEvent"in window&&(!an||ao),emptyInsertThreshold:5};un.initializePlugins(this,s,e);for(var i in e)!(i in t)&&(t[i]=e[i]);Ec(t);for(var n in this)n.charAt(0)==="_"&&typeof this[n]=="function"&&(this[n]=this[n].bind(this));this.nativeDraggable=t.forceFallback?!1:Id,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?Lt(s,"pointerdown",this._onTapStart):(Lt(s,"mousedown",this._onTapStart),Lt(s,"touchstart",this._onTapStart)),this.nativeDraggable&&(Lt(s,"dragover",this),Lt(s,"dragenter",this)),Rr.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),ei(this,Cd())}_t.prototype={constructor:_t,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(ws=null)},_getDirection:function(t,e){return typeof this.options.direction=="function"?this.options.direction.call(this,t,e,gt):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,i=this.el,n=this.options,o=n.preventOnFilter,h=t.type,u=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,g=(u||t).target,v=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||g,p=n.filter;if(zd(i),!gt&&!(/mousedown|pointerdown/.test(h)&&t.button!==0||n.disabled)&&!v.isContentEditable&&!(!this.nativeDraggable&&an&&g&&g.tagName.toUpperCase()==="SELECT")&&(g=Fe(g,n.draggable,i,!1),!(g&&g.animated)&&kr!==g)){if(As=Pe(g),ln=Pe(g,n.draggable),typeof p=="function"){if(p.call(this,t,g,this)){ge({sortable:e,rootEl:v,name:"filter",targetEl:g,toEl:i,fromEl:i}),we("filter",e,{evt:t}),o&&t.preventDefault();return}}else if(p&&(p=p.split(",").some(function(a){if(a=Fe(v,a.trim(),i,!1),a)return ge({sortable:e,rootEl:a,name:"filter",targetEl:g,fromEl:i,toEl:i}),we("filter",e,{evt:t}),!0}),p)){o&&t.preventDefault();return}n.handle&&!Fe(v,n.handle,i,!1)||this._prepareDragStart(t,u,g)}}},_prepareDragStart:function(t,e,i){var n=this,o=n.el,h=n.options,u=o.ownerDocument,g;if(i&&!gt&&i.parentNode===o){var v=Zt(i);if(jt=o,gt=i,Yt=gt.parentNode,ji=gt.nextSibling,kr=i,Ar=h.group,_t.dragged=gt,Hi={target:gt,clientX:(e||t).clientX,clientY:(e||t).clientY},hc=Hi.clientX-v.left,dc=Hi.clientY-v.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,gt.style["will-change"]="all",g=function(){if(we("delayEnded",n,{evt:t}),_t.eventCanceled){n._onDrop();return}n._disableDelayedDragEvents(),!ac&&n.nativeDraggable&&(gt.draggable=!0),n._triggerDragStart(t,e),ge({sortable:n,name:"choose",originalEvent:t}),_e(gt,h.chosenClass,!0)},h.ignore.split(",").forEach(function(p){bc(gt,p.trim(),Qa)}),Lt(u,"dragover",zi),Lt(u,"mousemove",zi),Lt(u,"touchmove",zi),h.supportPointer?(Lt(u,"pointerup",n._onDrop),!this.nativeDraggable&&Lt(u,"pointercancel",n._onDrop)):(Lt(u,"mouseup",n._onDrop),Lt(u,"touchend",n._onDrop),Lt(u,"touchcancel",n._onDrop)),ac&&this.nativeDraggable&&(this.options.touchStartThreshold=4,gt.draggable=!0),we("delayStart",this,{evt:t}),h.delay&&(!h.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(dn||ii))){if(_t.eventCanceled){this._onDrop();return}h.supportPointer?(Lt(u,"pointerup",n._disableDelayedDrag),Lt(u,"pointercancel",n._disableDelayedDrag)):(Lt(u,"mouseup",n._disableDelayedDrag),Lt(u,"touchend",n._disableDelayedDrag),Lt(u,"touchcancel",n._disableDelayedDrag)),Lt(u,"mousemove",n._delayedDragTouchMoveHandler),Lt(u,"touchmove",n._delayedDragTouchMoveHandler),h.supportPointer&&Lt(u,"pointermove",n._delayedDragTouchMoveHandler),n._dragStartTimer=setTimeout(g,h.delay)}else g()}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){gt&&Qa(gt),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;Rt(t,"mouseup",this._disableDelayedDrag),Rt(t,"touchend",this._disableDelayedDrag),Rt(t,"touchcancel",this._disableDelayedDrag),Rt(t,"pointerup",this._disableDelayedDrag),Rt(t,"pointercancel",this._disableDelayedDrag),Rt(t,"mousemove",this._delayedDragTouchMoveHandler),Rt(t,"touchmove",this._delayedDragTouchMoveHandler),Rt(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t,!this.nativeDraggable||e?this.options.supportPointer?Lt(document,"pointermove",this._onTouchMove):e?Lt(document,"touchmove",this._onTouchMove):Lt(document,"mousemove",this._onTouchMove):(Lt(gt,"dragend",this),Lt(jt,"dragstart",this._onDragStart));try{document.selection?Pr(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(xs=!1,jt&&gt){we("dragStarted",this,{evt:e}),this.nativeDraggable&&Lt(document,"dragover",Ld);var i=this.options;!t&&_e(gt,i.dragClass,!1),_e(gt,i.ghostClass,!0),_t.active=this,t&&this._appendGhost(),ge({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(Le){this._lastX=Le.clientX,this._lastY=Le.clientY,_c();for(var t=document.elementFromPoint(Le.clientX,Le.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(Le.clientX,Le.clientY),t!==e);)e=t;if(gt.parentNode[xe]._isOutsideThisEl(t),e)do{if(e[xe]){var i=void 0;if(i=e[xe]._onDragOver({clientX:Le.clientX,clientY:Le.clientY,target:t,rootEl:e}),i&&!this.options.dragoverBubble)break}t=e}while(e=mc(e));Cc()}},_onTouchMove:function(t){if(Hi){var e=this.options,i=e.fallbackTolerance,n=e.fallbackOffset,o=t.touches?t.touches[0]:t,h=kt&&Ss(kt,!0),u=kt&&h&&h.a,g=kt&&h&&h.d,v=Er&&he&&cc(he),p=(o.clientX-Hi.clientX+n.x)/(u||1)+(v?v[0]-Ja[0]:0)/(u||1),a=(o.clientY-Hi.clientY+n.y)/(g||1)+(v?v[1]-Ja[1]:0)/(g||1);if(!_t.active&&!xs){if(i&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<i)return;this._onDragStart(t,!0)}if(kt){h?(h.e+=p-(Ka||0),h.f+=a-(Ya||0)):h={a:1,b:0,c:0,d:1,e:p,f:a};var f="matrix(".concat(h.a,",").concat(h.b,",").concat(h.c,",").concat(h.d,",").concat(h.e,",").concat(h.f,")");Et(kt,"webkitTransform",f),Et(kt,"mozTransform",f),Et(kt,"msTransform",f),Et(kt,"transform",f),Ka=p,Ya=a,Le=o}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!kt){var t=this.options.fallbackOnBody?document.body:jt,e=Zt(gt,!0,Er,!0,t),i=this.options;if(Er){for(he=t;Et(he,"position")==="static"&&Et(he,"transform")==="none"&&he!==document;)he=he.parentNode;he!==document.body&&he!==document.documentElement?(he===document&&(he=Ve()),e.top+=he.scrollTop,e.left+=he.scrollLeft):he=Ve(),Ja=cc(he)}kt=gt.cloneNode(!0),_e(kt,i.ghostClass,!1),_e(kt,i.fallbackClass,!0),_e(kt,i.dragClass,!0),Et(kt,"transition",""),Et(kt,"transform",""),Et(kt,"box-sizing","border-box"),Et(kt,"margin",0),Et(kt,"top",e.top),Et(kt,"left",e.left),Et(kt,"width",e.width),Et(kt,"height",e.height),Et(kt,"opacity","0.8"),Et(kt,"position",Er?"absolute":"fixed"),Et(kt,"zIndex","100000"),Et(kt,"pointerEvents","none"),_t.ghost=kt,t.appendChild(kt),Et(kt,"transform-origin",hc/parseInt(kt.style.width)*100+"% "+dc/parseInt(kt.style.height)*100+"%")}},_onDragStart:function(t,e){var i=this,n=t.dataTransfer,o=i.options;if(we("dragStart",this,{evt:t}),_t.eventCanceled){this._onDrop();return}we("setupClone",this),_t.eventCanceled||(qt=wc(gt),qt.removeAttribute("id"),qt.draggable=!1,qt.style["will-change"]="",this._hideClone(),_e(qt,this.options.chosenClass,!1),_t.clone=qt),i.cloneId=Pr(function(){we("clone",i),!_t.eventCanceled&&(i.options.removeCloneOnHide||jt.insertBefore(qt,gt),i._hideClone(),ge({sortable:i,name:"clone"}))}),!e&&_e(gt,o.dragClass,!0),e?(Mr=!0,i._loopId=setInterval(i._emulateDragOver,50)):(Rt(document,"mouseup",i._onDrop),Rt(document,"touchend",i._onDrop),Rt(document,"touchcancel",i._onDrop),n&&(n.effectAllowed="move",o.setData&&o.setData.call(i,n,gt)),Lt(document,"drop",i),Et(gt,"transform","translateZ(0)")),xs=!0,i._dragStartId=Pr(i._dragStarted.bind(i,e,t)),Lt(document,"selectstart",i),sn=!0,window.getSelection().removeAllRanges(),an&&Et(document.body,"user-select","none")},_onDragOver:function(t){var e=this.el,i=t.target,n,o,h,u=this.options,g=u.group,v=_t.active,p=Ar===g,a=u.sort,f=oe||v,A,_=this,d=!1;if(io)return;function y(et,rt){we(et,_,Ge({evt:t,isOwner:p,axis:A?"vertical":"horizontal",revert:h,dragRect:n,targetRect:o,canSort:a,fromSortable:f,target:i,completed:l,onMove:function(st,W){return _r(jt,e,gt,n,st,Zt(st),t,W)},changed:m},rt))}function r(){y("dragOverAnimationCapture"),_.captureAnimationState(),_!==f&&f.captureAnimationState()}function l(et){return y("dragOverCompleted",{insertion:et}),et&&(p?v._hideClone():v._showClone(_),_!==f&&(_e(gt,oe?oe.options.ghostClass:v.options.ghostClass,!1),_e(gt,u.ghostClass,!0)),oe!==_&&_!==_t.active?oe=_:_===_t.active&&oe&&(oe=null),f===_&&(_._ignoreWhileAnimating=i),_.animateAll(function(){y("dragOverAnimationComplete"),_._ignoreWhileAnimating=null}),_!==f&&(f.animateAll(),f._ignoreWhileAnimating=null)),(i===gt&&!gt.animated||i===e&&!i.animated)&&(ws=null),!u.dragoverBubble&&!t.rootEl&&i!==document&&(gt.parentNode[xe]._isOutsideThisEl(t.target),!et&&zi(t)),!u.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),d=!0}function m(){Ce=Pe(gt),fi=Pe(gt,u.draggable),ge({sortable:_,name:"change",toEl:e,newIndex:Ce,newDraggableIndex:fi,originalEvent:t})}if(t.preventDefault!==void 0&&t.cancelable&&t.preventDefault(),i=Fe(i,u.draggable,e,!0),y("dragOver"),_t.eventCanceled)return d;if(gt.contains(t.target)||i.animated&&i.animatingX&&i.animatingY||_._ignoreWhileAnimating===i)return l(!1);if(Mr=!1,v&&!u.disabled&&(p?a||(h=Yt!==jt):oe===this||(this.lastPutMode=Ar.checkPull(this,v,gt,t))&&g.checkPut(this,v,gt,t))){if(A=this._getDirection(t,i)==="vertical",n=Zt(gt),y("dragOverValid"),_t.eventCanceled)return d;if(h)return Yt=jt,r(),this._hideClone(),y("revert"),_t.eventCanceled||(ji?jt.insertBefore(gt,ji):jt.appendChild(gt)),l(!0);var x=oo(e,u.draggable);if(!x||Bd(t,A,this)&&!x.animated){if(x===gt)return l(!1);if(x&&e===t.target&&(i=x),i&&(o=Zt(i)),_r(jt,e,gt,n,i,o,t,!!i)!==!1)return r(),x&&x.nextSibling?e.insertBefore(gt,x.nextSibling):e.appendChild(gt),Yt=e,m(),l(!0)}else if(x&&Nd(t,A,this)){var D=Es(e,0,u,!0);if(D===gt)return l(!1);if(i=D,o=Zt(i),_r(jt,e,gt,n,i,o,t,!1)!==!1)return r(),e.insertBefore(gt,D),Yt=e,m(),l(!0)}else if(i.parentNode===e){o=Zt(i);var E=0,M,N=gt.parentNode!==e,H=!Md(gt.animated&&gt.toRect||n,i.animated&&i.toRect||o,A),z=A?"top":"left",K=lc(i,"top","top")||lc(gt,"top","top"),it=K?K.scrollTop:void 0;ws!==i&&(M=o[z],hn=!1,Sr=!H&&u.invertSwap||N),E=Ud(t,i,o,A,H?1:u.swapThreshold,u.invertedSwapThreshold==null?u.swapThreshold:u.invertedSwapThreshold,Sr,ws===i);var ot;if(E!==0){var X=Pe(gt);do X-=E,ot=Yt.children[X];while(ot&&(Et(ot,"display")==="none"||ot===kt))}if(E===0||ot===i)return l(!1);ws=i,cn=E;var j=i.nextElementSibling,G=!1;G=E===1;var Y=_r(jt,e,gt,n,i,o,t,G);if(Y!==!1)return(Y===1||Y===-1)&&(G=Y===1),io=!0,setTimeout(Od,30),r(),G&&!j?e.appendChild(gt):i.parentNode.insertBefore(gt,G?j:i),K&&yc(K,0,it-K.scrollTop),Yt=gt.parentNode,M!==void 0&&!Sr&&(Tr=Math.abs(M-Zt(i)[z])),m(),l(!0)}if(e.contains(gt))return l(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Rt(document,"mousemove",this._onTouchMove),Rt(document,"touchmove",this._onTouchMove),Rt(document,"pointermove",this._onTouchMove),Rt(document,"dragover",zi),Rt(document,"mousemove",zi),Rt(document,"touchmove",zi)},_offUpEvents:function(){var t=this.el.ownerDocument;Rt(t,"mouseup",this._onDrop),Rt(t,"touchend",this._onDrop),Rt(t,"pointerup",this._onDrop),Rt(t,"pointercancel",this._onDrop),Rt(t,"touchcancel",this._onDrop),Rt(document,"selectstart",this)},_onDrop:function(t){var e=this.el,i=this.options;if(Ce=Pe(gt),fi=Pe(gt,i.draggable),we("drop",this,{evt:t}),Yt=gt&&gt.parentNode,Ce=Pe(gt),fi=Pe(gt,i.draggable),_t.eventCanceled){this._nulling();return}xs=!1,Sr=!1,hn=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),so(this.cloneId),so(this._dragStartId),this.nativeDraggable&&(Rt(document,"drop",this),Rt(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),an&&Et(document.body,"user-select",""),Et(gt,"transform",""),t&&(sn&&(t.cancelable&&t.preventDefault(),!i.dropBubble&&t.stopPropagation()),kt&&kt.parentNode&&kt.parentNode.removeChild(kt),(jt===Yt||oe&&oe.lastPutMode!=="clone")&&qt&&qt.parentNode&&qt.parentNode.removeChild(qt),gt&&(this.nativeDraggable&&Rt(gt,"dragend",this),Qa(gt),gt.style["will-change"]="",sn&&!xs&&_e(gt,oe?oe.options.ghostClass:this.options.ghostClass,!1),_e(gt,this.options.chosenClass,!1),ge({sortable:this,name:"unchoose",toEl:Yt,newIndex:null,newDraggableIndex:null,originalEvent:t}),jt!==Yt?(Ce>=0&&(ge({rootEl:Yt,name:"add",toEl:Yt,fromEl:jt,originalEvent:t}),ge({sortable:this,name:"remove",toEl:Yt,originalEvent:t}),ge({rootEl:Yt,name:"sort",toEl:Yt,fromEl:jt,originalEvent:t}),ge({sortable:this,name:"sort",toEl:Yt,originalEvent:t})),oe&&oe.save()):Ce!==As&&Ce>=0&&(ge({sortable:this,name:"update",toEl:Yt,originalEvent:t}),ge({sortable:this,name:"sort",toEl:Yt,originalEvent:t})),_t.active&&((Ce==null||Ce===-1)&&(Ce=As,fi=ln),ge({sortable:this,name:"end",toEl:Yt,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){we("nulling",this),jt=gt=Yt=kt=ji=qt=kr=gi=Hi=Le=sn=Ce=fi=As=ln=ws=cn=oe=Ar=_t.dragged=_t.ghost=_t.clone=_t.active=null,Lr.forEach(function(t){t.checked=!0}),Lr.length=Ka=Ya=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":gt&&(this._onDragOver(t),Fd(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,i=this.el.children,n=0,o=i.length,h=this.options;n<o;n++)e=i[n],Fe(e,h.draggable,this.el,!1)&&t.push(e.getAttribute(h.dataIdAttr)||Hd(e));return t},sort:function(t,e){var i={},n=this.el;this.toArray().forEach(function(o,h){var u=n.children[h];Fe(u,this.options.draggable,n,!1)&&(i[o]=u)},this),e&&this.captureAnimationState(),t.forEach(function(o){i[o]&&(n.removeChild(i[o]),n.appendChild(i[o]))}),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return Fe(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var i=this.options;if(e===void 0)return i[t];var n=un.modifyOption(this,t,e);typeof n<"u"?i[t]=n:i[t]=e,t==="group"&&Ec(i)},destroy:function(){we("destroy",this);var t=this.el;t[xe]=null,Rt(t,"mousedown",this._onTapStart),Rt(t,"touchstart",this._onTapStart),Rt(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(Rt(t,"dragover",this),Rt(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(e){e.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Rr.splice(Rr.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!gi){if(we("hideClone",this),_t.eventCanceled)return;Et(qt,"display","none"),this.options.removeCloneOnHide&&qt.parentNode&&qt.parentNode.removeChild(qt),gi=!0}},_showClone:function(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(gi){if(we("showClone",this),_t.eventCanceled)return;gt.parentNode==jt&&!this.options.group.revertClone?jt.insertBefore(qt,gt):ji?jt.insertBefore(qt,ji):jt.appendChild(qt),this.options.group.revertClone&&this.animate(gt,qt),Et(qt,"display",""),gi=!1}}};function Fd(s){s.dataTransfer&&(s.dataTransfer.dropEffect="move"),s.cancelable&&s.preventDefault()}function _r(s,t,e,i,n,o,h,u){var g,v=s[xe],p=v.options.onMove,a;return window.CustomEvent&&!ii&&!dn?g=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(g=document.createEvent("Event"),g.initEvent("move",!0,!0)),g.to=t,g.from=s,g.dragged=e,g.draggedRect=i,g.related=n||t,g.relatedRect=o||Zt(t),g.willInsertAfter=u,g.originalEvent=h,s.dispatchEvent(g),p&&(a=p.call(v,g,h)),a}function Qa(s){s.draggable=!1}function Od(){io=!1}function Nd(s,t,e){var i=Zt(Es(e.el,0,e.options,!0)),n=xc(e.el,e.options,kt),o=10;return t?s.clientX<n.left-o||s.clientY<i.top&&s.clientX<i.right:s.clientY<n.top-o||s.clientY<i.bottom&&s.clientX<i.left}function Bd(s,t,e){var i=Zt(oo(e.el,e.options.draggable)),n=xc(e.el,e.options,kt),o=10;return t?s.clientX>n.right+o||s.clientY>i.bottom&&s.clientX>i.left:s.clientY>n.bottom+o||s.clientX>i.right&&s.clientY>i.top}function Ud(s,t,e,i,n,o,h,u){var g=i?s.clientY:s.clientX,v=i?e.height:e.width,p=i?e.top:e.left,a=i?e.bottom:e.right,f=!1;if(!h){if(u&&Tr<v*n){if(!hn&&(cn===1?g>p+v*o/2:g<a-v*o/2)&&(hn=!0),hn)f=!0;else if(cn===1?g<p+Tr:g>a-Tr)return-cn}else if(g>p+v*(1-n)/2&&g<a-v*(1-n)/2)return $d(t)}return f=f||h,f&&(g<p+v*o/2||g>a-v*o/2)?g>p+v/2?1:-1:0}function $d(s){return Pe(gt)<Pe(s)?1:-1}function Hd(s){for(var t=s.tagName+s.className+s.src+s.href+s.textContent,e=t.length,i=0;e--;)i+=t.charCodeAt(e);return i.toString(36)}function zd(s){Lr.length=0;for(var t=s.getElementsByTagName("input"),e=t.length;e--;){var i=t[e];i.checked&&Lr.push(i)}}function Pr(s){return setTimeout(s,0)}function so(s){return clearTimeout(s)}Or&&Lt(document,"touchmove",function(s){(_t.active||xs)&&s.cancelable&&s.preventDefault()});_t.utils={on:Lt,off:Rt,css:Et,find:bc,is:function(t,e){return!!Fe(t,e,t,!1)},extend:Ed,throttle:vc,closest:Fe,toggleClass:_e,clone:wc,index:Pe,nextTick:Pr,cancelNextTick:so,detectDirection:Sc,getChild:Es,expando:xe};_t.get=function(s){return s[xe]};_t.mount=function(){for(var s=arguments.length,t=new Array(s),e=0;e<s;e++)t[e]=arguments[e];t[0].constructor===Array&&(t=t[0]),t.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(_t.utils=Ge(Ge({},_t.utils),i.utils)),un.mount(i)})};_t.create=function(s,t){return new _t(s,t)};_t.version=Ad;var Qt=[],nn,no,ro=!1,Za,to,Fr,rn;function jd(){function s(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this))}return s.prototype={dragStarted:function(e){var i=e.originalEvent;this.sortable.nativeDraggable?Lt(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Lt(document,"pointermove",this._handleFallbackAutoScroll):i.touches?Lt(document,"touchmove",this._handleFallbackAutoScroll):Lt(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(e){var i=e.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?Rt(document,"dragover",this._handleAutoScroll):(Rt(document,"pointermove",this._handleFallbackAutoScroll),Rt(document,"touchmove",this._handleFallbackAutoScroll),Rt(document,"mousemove",this._handleFallbackAutoScroll)),pc(),Dr(),_d()},nulling:function(){Fr=no=nn=ro=rn=Za=to=null,Qt.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(e,i){var n=this,o=(e.touches?e.touches[0]:e).clientX,h=(e.touches?e.touches[0]:e).clientY,u=document.elementFromPoint(o,h);if(Fr=e,i||this.options.forceAutoScrollFallback||dn||ii||an){eo(e,this.options,u,i);var g=mi(u,!0);ro&&(!rn||o!==Za||h!==to)&&(rn&&pc(),rn=setInterval(function(){var v=mi(document.elementFromPoint(o,h),!0);v!==g&&(g=v,Dr()),eo(e,n.options,v,i)},10),Za=o,to=h)}else{if(!this.options.bubbleScroll||mi(u,!0)===Ve()){Dr();return}eo(e,this.options,mi(u,!1),!1)}}},ei(s,{pluginName:"scroll",initializeByDefault:!0})}function Dr(){Qt.forEach(function(s){clearInterval(s.pid)}),Qt=[]}function pc(){clearInterval(rn)}var eo=vc(function(s,t,e,i){if(t.scroll){var n=(s.touches?s.touches[0]:s).clientX,o=(s.touches?s.touches[0]:s).clientY,h=t.scrollSensitivity,u=t.scrollSpeed,g=Ve(),v=!1,p;no!==e&&(no=e,Dr(),nn=t.scroll,p=t.scrollFn,nn===!0&&(nn=mi(e,!0)));var a=0,f=nn;do{var A=f,_=Zt(A),d=_.top,y=_.bottom,r=_.left,l=_.right,m=_.width,x=_.height,D=void 0,E=void 0,M=A.scrollWidth,N=A.scrollHeight,H=Et(A),z=A.scrollLeft,K=A.scrollTop;A===g?(D=m<M&&(H.overflowX==="auto"||H.overflowX==="scroll"||H.overflowX==="visible"),E=x<N&&(H.overflowY==="auto"||H.overflowY==="scroll"||H.overflowY==="visible")):(D=m<M&&(H.overflowX==="auto"||H.overflowX==="scroll"),E=x<N&&(H.overflowY==="auto"||H.overflowY==="scroll"));var it=D&&(Math.abs(l-n)<=h&&z+m<M)-(Math.abs(r-n)<=h&&!!z),ot=E&&(Math.abs(y-o)<=h&&K+x<N)-(Math.abs(d-o)<=h&&!!K);if(!Qt[a])for(var X=0;X<=a;X++)Qt[X]||(Qt[X]={});(Qt[a].vx!=it||Qt[a].vy!=ot||Qt[a].el!==A)&&(Qt[a].el=A,Qt[a].vx=it,Qt[a].vy=ot,clearInterval(Qt[a].pid),(it!=0||ot!=0)&&(v=!0,Qt[a].pid=setInterval(function(){i&&this.layer===0&&_t.active._onTouchMove(Fr);var j=Qt[this.layer].vy?Qt[this.layer].vy*u:0,G=Qt[this.layer].vx?Qt[this.layer].vx*u:0;typeof p=="function"&&p.call(_t.dragged.parentNode[xe],G,j,s,Fr,Qt[this.layer].el)!=="continue"||yc(Qt[this.layer].el,G,j)}.bind({layer:a}),24))),a++}while(t.bubbleScroll&&f!==g&&(f=mi(f,!1)));ro=v}},30),kc=function(t){var e=t.originalEvent,i=t.putSortable,n=t.dragEl,o=t.activeSortable,h=t.dispatchSortableEvent,u=t.hideGhostForTarget,g=t.unhideGhostForTarget;if(e){var v=i||o;u();var p=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,a=document.elementFromPoint(p.clientX,p.clientY);g(),v&&!v.el.contains(a)&&(h("spill"),this.onSpill({dragEl:n,putSortable:i}))}};function lo(){}lo.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){var e=t.dragEl,i=t.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var n=Es(this.sortable.el,this.startIndex,this.options);n?this.sortable.el.insertBefore(e,n):this.sortable.el.appendChild(e),this.sortable.animateAll(),i&&i.animateAll()},drop:kc};ei(lo,{pluginName:"revertOnSpill"});function co(){}co.prototype={onSpill:function(t){var e=t.dragEl,i=t.putSortable,n=i||this.sortable;n.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),n.animateAll()},drop:kc};ei(co,{pluginName:"removeOnSpill"});_t.mount(new jd);_t.mount(co,lo);var Tc=_t;var _s,pn,fn,Nr,lu={976:(s,t,e)=>{e.d(t,{AnnotationLayer:()=>T,FreeTextAnnotationElement:()=>z,InkAnnotationElement:()=>Y,StampAnnotationElement:()=>W});var i=e(292),n=e(419),o=e(792);function h(R){return Math.floor(255*Math.max(0,Math.min(1,R))).toString(16).padStart(2,"0")}function u(R){return Math.max(0,Math.min(255,255*R))}class g{static CMYK_G([c,b,C,k]){return["G",1-Math.min(1,.3*c+.59*C+.11*b+k)]}static G_CMYK([c]){return["CMYK",0,0,0,1-c]}static G_RGB([c]){return["RGB",c,c,c]}static G_rgb([c]){return[c=u(c),c,c]}static G_HTML([c]){let b=h(c);return`#${b}${b}${b}`}static RGB_G([c,b,C]){return["G",.3*c+.59*b+.11*C]}static RGB_rgb(c){return c.map(u)}static RGB_HTML(c){return`#${c.map(h).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([c,b,C,k]){return["RGB",1-Math.min(1,c+k),1-Math.min(1,C+k),1-Math.min(1,b+k)]}static CMYK_rgb([c,b,C,k]){return[u(1-Math.min(1,c+k)),u(1-Math.min(1,C+k)),u(1-Math.min(1,b+k))]}static CMYK_HTML(c){let b=this.CMYK_RGB(c).slice(1);return this.RGB_HTML(b)}static RGB_CMYK([c,b,C]){let k=1-c,O=1-b,I=1-C;return["CMYK",k,O,I,Math.min(k,O,I)]}}var v=e(284);let p=1e3,a=new WeakSet;function f(R){return{width:R[2]-R[0],height:R[3]-R[1]}}class A{static create(c){switch(c.data.annotationType){case i.AnnotationType.LINK:return new d(c);case i.AnnotationType.TEXT:return new y(c);case i.AnnotationType.WIDGET:switch(c.data.fieldType){case"Tx":return new l(c);case"Btn":return c.data.radioButton?new D(c):c.data.checkBox?new x(c):new E(c);case"Ch":return new M(c);case"Sig":return new m(c)}return new r(c);case i.AnnotationType.POPUP:return new N(c);case i.AnnotationType.FREETEXT:return new z(c);case i.AnnotationType.LINE:return new K(c);case i.AnnotationType.SQUARE:return new it(c);case i.AnnotationType.CIRCLE:return new ot(c);case i.AnnotationType.POLYLINE:return new X(c);case i.AnnotationType.CARET:return new G(c);case i.AnnotationType.INK:return new Y(c);case i.AnnotationType.POLYGON:return new j(c);case i.AnnotationType.HIGHLIGHT:return new et(c);case i.AnnotationType.UNDERLINE:return new rt(c);case i.AnnotationType.SQUIGGLY:return new ct(c);case i.AnnotationType.STRIKEOUT:return new st(c);case i.AnnotationType.STAMP:return new W(c);case i.AnnotationType.FILEATTACHMENT:return new w(c);default:return new _(c)}}}class _{#t=!1;constructor(c,{isRenderable:b=!1,ignoreBorder:C=!1,createQuadrilaterals:k=!1}={}){this.isRenderable=b,this.data=c.data,this.layer=c.layer,this.linkService=c.linkService,this.downloadManager=c.downloadManager,this.imageResourcesPath=c.imageResourcesPath,this.renderForms=c.renderForms,this.svgFactory=c.svgFactory,this.annotationStorage=c.annotationStorage,this.enableScripting=c.enableScripting,this.hasJSActions=c.hasJSActions,this._fieldObjects=c.fieldObjects,this.parent=c.parent,b&&(this.container=this._createContainer(C)),k&&this._createQuadrilaterals()}static _hasPopupData({titleObj:c,contentsObj:b,richText:C}){return!!(c?.str||b?.str||C?.str)}get hasPopupData(){return _._hasPopupData(this.data)}_createContainer(c){let{data:b,parent:{page:C,viewport:k}}=this,O=document.createElement("section");O.setAttribute("data-annotation-id",b.id),this instanceof r||(O.tabIndex=p),O.style.zIndex=this.parent.zIndex++,b.popupRef&&O.setAttribute("aria-haspopup","dialog"),b.alternativeText&&(O.title=b.alternativeText),b.noRotate&&O.classList.add("norotate");let{pageWidth:I,pageHeight:S,pageX:L,pageY:$}=k.rawDims;if(!b.rect||this instanceof N){let{rotation:Q}=b;return b.hasOwnCanvas||Q===0||this.setRotation(Q,O),O}let{width:U,height:P}=f(b.rect),F=i.Util.normalizeRect([b.rect[0],C.view[3]-b.rect[1]+C.view[1],b.rect[2],C.view[3]-b.rect[3]+C.view[1]]);if(!c&&b.borderStyle.width>0){O.style.borderWidth=`${b.borderStyle.width}px`;let Q=b.borderStyle.horizontalCornerRadius,Z=b.borderStyle.verticalCornerRadius;if(Q>0||Z>0){let nt=`calc(${Q}px * var(--scale-factor)) / calc(${Z}px * var(--scale-factor))`;O.style.borderRadius=nt}else if(this instanceof D){let nt=`calc(${U}px * var(--scale-factor)) / calc(${P}px * var(--scale-factor))`;O.style.borderRadius=nt}switch(b.borderStyle.style){case i.AnnotationBorderStyleType.SOLID:O.style.borderStyle="solid";break;case i.AnnotationBorderStyleType.DASHED:O.style.borderStyle="dashed";break;case i.AnnotationBorderStyleType.BEVELED:(0,i.warn)("Unimplemented border style: beveled");break;case i.AnnotationBorderStyleType.INSET:(0,i.warn)("Unimplemented border style: inset");break;case i.AnnotationBorderStyleType.UNDERLINE:O.style.borderBottomStyle="solid"}let tt=b.borderColor||null;tt?(this.#t=!0,O.style.borderColor=i.Util.makeHexColor(0|tt[0],0|tt[1],0|tt[2])):O.style.borderWidth=0}O.style.left=100*(F[0]-L)/I+"%",O.style.top=100*(F[1]-$)/S+"%";let{rotation:V}=b;return b.hasOwnCanvas||V===0?(O.style.width=100*U/I+"%",O.style.height=100*P/S+"%"):this.setRotation(V,O),O}setRotation(c,b=this.container){if(!this.data.rect)return;let{pageWidth:C,pageHeight:k}=this.parent.viewport.rawDims,{width:O,height:I}=f(this.data.rect),S,L;c%180==0?(S=100*O/C,L=100*I/k):(S=100*I/C,L=100*O/k),b.style.width=`${S}%`,b.style.height=`${L}%`,b.setAttribute("data-main-rotation",(360-c)%360)}get _commonActions(){let c=(b,C,k)=>{let O=k.detail[b],I=O[0],S=O.slice(1);k.target.style[C]=g[`${I}_HTML`](S),this.annotationStorage.setValue(this.data.id,{[C]:g[`${I}_rgb`](S)})};return(0,i.shadow)(this,"_commonActions",{display:b=>{let{display:C}=b.detail,k=C%2==1;this.container.style.visibility=k?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:k,noPrint:C===1||C===2})},print:b=>{this.annotationStorage.setValue(this.data.id,{noPrint:!b.detail.print})},hidden:b=>{let{hidden:C}=b.detail;this.container.style.visibility=C?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:C,noView:C})},focus:b=>{setTimeout((()=>b.target.focus({preventScroll:!1})),0)},userName:b=>{b.target.title=b.detail.userName},readonly:b=>{b.target.disabled=b.detail.readonly},required:b=>{this._setRequired(b.target,b.detail.required)},bgColor:b=>{c("bgColor","backgroundColor",b)},fillColor:b=>{c("fillColor","backgroundColor",b)},fgColor:b=>{c("fgColor","color",b)},textColor:b=>{c("textColor","color",b)},borderColor:b=>{c("borderColor","borderColor",b)},strokeColor:b=>{c("strokeColor","borderColor",b)},rotation:b=>{let C=b.detail.rotation;this.setRotation(C),this.annotationStorage.setValue(this.data.id,{rotation:C})}})}_dispatchEventFromSandbox(c,b){let C=this._commonActions;for(let k of Object.keys(b.detail))(c[k]||C[k])?.(b)}_setDefaultPropertiesFromJS(c){if(!this.enableScripting)return;let b=this.annotationStorage.getRawValue(this.data.id);if(!b)return;let C=this._commonActions;for(let[k,O]of Object.entries(b)){let I=C[k];I&&(I({detail:{[k]:O},target:c}),delete b[k])}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:c}=this.data;if(!c)return;let[b,C,k,O]=this.data.rect;if(c.length===1){let[,{x:Z,y:tt},{x:nt,y:pt}]=c[0];if(k===Z&&O===tt&&b===nt&&C===pt)return}let{style:I}=this.container,S;if(this.#t){let{borderColor:Z,borderWidth:tt}=I;I.borderWidth=0,S=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${Z}" stroke-width="${tt}">`],this.container.classList.add("hasBorder")}let L=k-b,$=O-C,{svgFactory:U}=this,P=U.createElement("svg");P.classList.add("quadrilateralsContainer"),P.setAttribute("width",0),P.setAttribute("height",0);let F=U.createElement("defs");P.append(F);let V=U.createElement("clipPath"),Q=`clippath_${this.data.id}`;V.setAttribute("id",Q),V.setAttribute("clipPathUnits","objectBoundingBox"),F.append(V);for(let[,{x:Z,y:tt},{x:nt,y:pt}]of c){let dt=U.createElement("rect"),lt=(nt-b)/L,wt=(O-tt)/$,Tt=(Z-nt)/L,xt=(tt-pt)/$;dt.setAttribute("x",lt),dt.setAttribute("y",wt),dt.setAttribute("width",Tt),dt.setAttribute("height",xt),V.append(dt),S?.push(`<rect vector-effect="non-scaling-stroke" x="${lt}" y="${wt}" width="${Tt}" height="${xt}"/>`)}this.#t&&(S.push("</g></svg>')"),I.backgroundImage=S.join("")),this.container.append(P),this.container.style.clipPath=`url(#${Q})`}_createPopup(){let{container:c,data:b}=this;c.setAttribute("aria-haspopup","dialog");let C=new N({data:{color:b.color,titleObj:b.titleObj,modificationDate:b.modificationDate,contentsObj:b.contentsObj,richText:b.richText,parentRect:b.rect,borderStyle:0,id:`popup_${b.id}`,rotation:b.rotation},parent:this.parent,elements:[this]});this.parent.div.append(C.render())}render(){(0,i.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(c,b=null){let C=[];if(this._fieldObjects){let k=this._fieldObjects[c];if(k)for(let{page:O,id:I,exportValues:S}of k){if(O===-1||I===b)continue;let L=typeof S=="string"?S:null,$=document.querySelector(`[data-element-id="${I}"]`);!$||a.has($)?C.push({id:I,exportValue:L,domElement:$}):(0,i.warn)(`_getElementsByName - element not allowed: ${I}`)}return C}for(let k of document.getElementsByName(c)){let{exportValue:O}=k,I=k.getAttribute("data-element-id");I!==b&&a.has(k)&&C.push({id:I,exportValue:O,domElement:k})}return C}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let c=this.getElementsToTriggerPopup();if(Array.isArray(c))for(let b of c)b.classList.add("highlightArea");else c.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:c,data:{id:b}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:c,editId:b})}))}}class d extends _{constructor(c,b=null){super(c,{isRenderable:!0,ignoreBorder:!!b?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=c.data.isTooltipOnly}render(){let{data:c,linkService:b}=this,C=document.createElement("a");C.setAttribute("data-element-id",c.id);let k=!1;return c.url?(b.addLinkAttributes(C,c.url,c.newWindow),k=!0):c.action?(this._bindNamedAction(C,c.action),k=!0):c.attachment?(this.#e(C,c.attachment,c.attachmentDest),k=!0):c.setOCGState?(this.#i(C,c.setOCGState),k=!0):c.dest?(this._bindLink(C,c.dest),k=!0):(c.actions&&(c.actions.Action||c.actions["Mouse Up"]||c.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(C,c),k=!0),c.resetForm?(this._bindResetFormAction(C,c.resetForm),k=!0):this.isTooltipOnly&&!k&&(this._bindLink(C,""),k=!0)),this.container.classList.add("linkAnnotation"),k&&this.container.append(C),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(c,b){c.href=this.linkService.getDestinationHash(b),c.onclick=()=>(b&&this.linkService.goToDestination(b),!1),(b||b==="")&&this.#t()}_bindNamedAction(c,b){c.href=this.linkService.getAnchorUrl(""),c.onclick=()=>(this.linkService.executeNamedAction(b),!1),this.#t()}#e(c,b,C=null){c.href=this.linkService.getAnchorUrl(""),c.onclick=()=>(this.downloadManager?.openOrDownloadData(b.content,b.filename,C),!1),this.#t()}#i(c,b){c.href=this.linkService.getAnchorUrl(""),c.onclick=()=>(this.linkService.executeSetOCGState(b),!1),this.#t()}_bindJSAction(c,b){c.href=this.linkService.getAnchorUrl("");let C=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let k of Object.keys(b.actions)){let O=C.get(k);O&&(c[O]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:b.id,name:k}}),!1))}c.onclick||(c.onclick=()=>!1),this.#t()}_bindResetFormAction(c,b){let C=c.onclick;C||(c.href=this.linkService.getAnchorUrl("")),this.#t(),this._fieldObjects?c.onclick=()=>{C?.();let{fields:k,refs:O,include:I}=b,S=[];if(k.length!==0||O.length!==0){let U=new Set(O);for(let P of k){let F=this._fieldObjects[P]||[];for(let{id:V}of F)U.add(V)}for(let P of Object.values(this._fieldObjects))for(let F of P)U.has(F.id)===I&&S.push(F)}else for(let U of Object.values(this._fieldObjects))S.push(...U);let L=this.annotationStorage,$=[];for(let U of S){let{id:P}=U;switch($.push(P),U.type){case"text":{let V=U.defaultValue||"";L.setValue(P,{value:V});break}case"checkbox":case"radiobutton":{let V=U.defaultValue===U.exportValues;L.setValue(P,{value:V});break}case"combobox":case"listbox":{let V=U.defaultValue||"";L.setValue(P,{value:V});break}default:continue}let F=document.querySelector(`[data-element-id="${P}"]`);F&&(a.has(F)?F.dispatchEvent(new Event("resetform")):(0,i.warn)(`_bindResetFormAction - element not allowed: ${P}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:$,name:"ResetForm"}}),!1}:((0,i.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),C||(c.onclick=()=>!1))}}class y extends _{constructor(c){super(c,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let c=document.createElement("img");return c.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",c.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),c.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(c),this.container}}class r extends _{render(){return this.container}showElementAndHideCanvas(c){this.data.hasOwnCanvas&&(c.previousSibling?.nodeName==="CANVAS"&&(c.previousSibling.hidden=!0),c.hidden=!1)}_getKeyModifier(c){return i.FeatureTest.platform.isMac?c.metaKey:c.ctrlKey}_setEventListener(c,b,C,k,O){C.includes("mouse")?c.addEventListener(C,(I=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:k,value:O(I),shift:I.shiftKey,modifier:this._getKeyModifier(I)}})})):c.addEventListener(C,(I=>{if(C==="blur"){if(!b.focused||!I.relatedTarget)return;b.focused=!1}else if(C==="focus"){if(b.focused)return;b.focused=!0}O&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:k,value:O(I)}})}))}_setEventListeners(c,b,C,k){for(let[O,I]of C)(I==="Action"||this.data.actions?.[I])&&(I!=="Focus"&&I!=="Blur"||(b||={focused:!1}),this._setEventListener(c,b,O,I,k),I!=="Focus"||this.data.actions?.Blur?I!=="Blur"||this.data.actions?.Focus||this._setEventListener(c,b,"focus","Focus",null):this._setEventListener(c,b,"blur","Blur",null))}_setBackgroundColor(c){let b=this.data.backgroundColor||null;c.style.backgroundColor=b===null?"transparent":i.Util.makeHexColor(b[0],b[1],b[2])}_setTextStyle(c){let b=["left","center","right"],{fontColor:C}=this.data.defaultAppearanceData,k=this.data.defaultAppearanceData.fontSize||9,O=c.style,I,S=L=>Math.round(10*L)/10;if(this.data.multiLine){let L=Math.abs(this.data.rect[3]-this.data.rect[1]-2),$=L/(Math.round(L/(i.LINE_FACTOR*k))||1);I=Math.min(k,S($/i.LINE_FACTOR))}else{let L=Math.abs(this.data.rect[3]-this.data.rect[1]-2);I=Math.min(k,S(L/i.LINE_FACTOR))}O.fontSize=`calc(${I}px * var(--scale-factor))`,O.color=i.Util.makeHexColor(C[0],C[1],C[2]),this.data.textAlignment!==null&&(O.textAlign=b[this.data.textAlignment])}_setRequired(c,b){b?c.setAttribute("required",!0):c.removeAttribute("required"),c.setAttribute("aria-required",b)}}class l extends r{constructor(c){super(c,{isRenderable:c.renderForms||c.data.hasOwnCanvas||!c.data.hasAppearance&&!!c.data.fieldValue})}setPropertyOnSiblings(c,b,C,k){let O=this.annotationStorage;for(let I of this._getElementsByName(c.name,c.id))I.domElement&&(I.domElement[b]=C),O.setValue(I.id,{[k]:C})}render(){let c=this.annotationStorage,b=this.data.id;this.container.classList.add("textWidgetAnnotation");let C=null;if(this.renderForms){let k=c.getValue(b,{value:this.data.fieldValue}),O=k.value||"",I=c.getValue(b,{charLimit:this.data.maxLen}).charLimit;I&&O.length>I&&(O=O.slice(0,I));let S=k.formattedValue||this.data.textContent?.join(`
5
+ `)||null;S&&this.data.comb&&(S=S.replaceAll(/\s+/g,""));let L={userValue:O,formattedValue:S,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(C=document.createElement("textarea"),C.textContent=S??O,this.data.doNotScroll&&(C.style.overflowY="hidden")):(C=document.createElement("input"),C.type="text",C.setAttribute("value",S??O),this.data.doNotScroll&&(C.style.overflowX="hidden")),this.data.hasOwnCanvas&&(C.hidden=!0),a.add(C),C.setAttribute("data-element-id",b),C.disabled=this.data.readOnly,C.name=this.data.fieldName,C.tabIndex=p,this._setRequired(C,this.data.required),I&&(C.maxLength=I),C.addEventListener("input",(U=>{c.setValue(b,{value:U.target.value}),this.setPropertyOnSiblings(C,"value",U.target.value,"value"),L.formattedValue=null})),C.addEventListener("resetform",(U=>{let P=this.data.defaultFieldValue??"";C.value=L.userValue=P,L.formattedValue=null}));let $=U=>{let{formattedValue:P}=L;P!=null&&(U.target.value=P),U.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){C.addEventListener("focus",(P=>{if(L.focused)return;let{target:F}=P;L.userValue&&(F.value=L.userValue),L.lastCommittedValue=F.value,L.commitKey=1,this.data.actions?.Focus||(L.focused=!0)})),C.addEventListener("updatefromsandbox",(P=>{this.showElementAndHideCanvas(P.target);let F={value(V){L.userValue=V.detail.value??"",c.setValue(b,{value:L.userValue.toString()}),V.target.value=L.userValue},formattedValue(V){let{formattedValue:Q}=V.detail;L.formattedValue=Q,Q!=null&&V.target!==document.activeElement&&(V.target.value=Q),c.setValue(b,{formattedValue:Q})},selRange(V){V.target.setSelectionRange(...V.detail.selRange)},charLimit:V=>{let{charLimit:Q}=V.detail,{target:Z}=V;if(Q===0){Z.removeAttribute("maxLength");return}Z.setAttribute("maxLength",Q);let tt=L.userValue;tt&&!(tt.length<=Q)&&(tt=tt.slice(0,Q),Z.value=L.userValue=tt,c.setValue(b,{value:tt}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:b,name:"Keystroke",value:tt,willCommit:!0,commitKey:1,selStart:Z.selectionStart,selEnd:Z.selectionEnd}}))}};this._dispatchEventFromSandbox(F,P)})),C.addEventListener("keydown",(P=>{L.commitKey=1;let F=-1;if(P.key==="Escape"?F=0:P.key!=="Enter"||this.data.multiLine?P.key==="Tab"&&(L.commitKey=3):F=2,F===-1)return;let{value:V}=P.target;L.lastCommittedValue!==V&&(L.lastCommittedValue=V,L.userValue=V,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:b,name:"Keystroke",value:V,willCommit:!0,commitKey:F,selStart:P.target.selectionStart,selEnd:P.target.selectionEnd}}))}));let U=$;$=null,C.addEventListener("blur",(P=>{if(!L.focused||!P.relatedTarget)return;this.data.actions?.Blur||(L.focused=!1);let{value:F}=P.target;L.userValue=F,L.lastCommittedValue!==F&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:b,name:"Keystroke",value:F,willCommit:!0,commitKey:L.commitKey,selStart:P.target.selectionStart,selEnd:P.target.selectionEnd}}),U(P)})),this.data.actions?.Keystroke&&C.addEventListener("beforeinput",(P=>{L.lastCommittedValue=null;let{data:F,target:V}=P,{value:Q,selectionStart:Z,selectionEnd:tt}=V,nt=Z,pt=tt;switch(P.inputType){case"deleteWordBackward":{let dt=Q.substring(0,Z).match(/\w*[^\w]*$/);dt&&(nt-=dt[0].length);break}case"deleteWordForward":{let dt=Q.substring(Z).match(/^[^\w]*\w*/);dt&&(pt+=dt[0].length);break}case"deleteContentBackward":Z===tt&&(nt-=1);break;case"deleteContentForward":Z===tt&&(pt+=1)}P.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:b,name:"Keystroke",value:Q,change:F||"",willCommit:!1,selStart:nt,selEnd:pt}})})),this._setEventListeners(C,L,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(P=>P.target.value))}if($&&C.addEventListener("blur",$),this.data.comb){let U=(this.data.rect[2]-this.data.rect[0])/I;C.classList.add("comb"),C.style.letterSpacing=`calc(${U}px * var(--scale-factor) - 1ch)`}}else C=document.createElement("div"),C.textContent=this.data.fieldValue,C.style.verticalAlign="middle",C.style.display="table-cell",this.data.hasOwnCanvas&&(C.hidden=!0);return this._setTextStyle(C),this._setBackgroundColor(C),this._setDefaultPropertiesFromJS(C),this.container.append(C),this.container}}class m extends r{constructor(c){super(c,{isRenderable:!!c.data.hasOwnCanvas})}}class x extends r{constructor(c){super(c,{isRenderable:c.renderForms})}render(){let c=this.annotationStorage,b=this.data,C=b.id,k=c.getValue(C,{value:b.exportValue===b.fieldValue}).value;typeof k=="string"&&(k=k!=="Off",c.setValue(C,{value:k})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let O=document.createElement("input");return a.add(O),O.setAttribute("data-element-id",C),O.disabled=b.readOnly,this._setRequired(O,this.data.required),O.type="checkbox",O.name=b.fieldName,k&&O.setAttribute("checked",!0),O.setAttribute("exportValue",b.exportValue),O.tabIndex=p,O.addEventListener("change",(I=>{let{name:S,checked:L}=I.target;for(let $ of this._getElementsByName(S,C)){let U=L&&$.exportValue===b.exportValue;$.domElement&&($.domElement.checked=U),c.setValue($.id,{value:U})}c.setValue(C,{value:L})})),O.addEventListener("resetform",(I=>{let S=b.defaultFieldValue||"Off";I.target.checked=S===b.exportValue})),this.enableScripting&&this.hasJSActions&&(O.addEventListener("updatefromsandbox",(I=>{let S={value(L){L.target.checked=L.detail.value!=="Off",c.setValue(C,{value:L.target.checked})}};this._dispatchEventFromSandbox(S,I)})),this._setEventListeners(O,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(I=>I.target.checked))),this._setBackgroundColor(O),this._setDefaultPropertiesFromJS(O),this.container.append(O),this.container}}class D extends r{constructor(c){super(c,{isRenderable:c.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let c=this.annotationStorage,b=this.data,C=b.id,k=c.getValue(C,{value:b.fieldValue===b.buttonValue}).value;if(typeof k=="string"&&(k=k!==b.buttonValue,c.setValue(C,{value:k})),k)for(let I of this._getElementsByName(b.fieldName,C))c.setValue(I.id,{value:!1});let O=document.createElement("input");if(a.add(O),O.setAttribute("data-element-id",C),O.disabled=b.readOnly,this._setRequired(O,this.data.required),O.type="radio",O.name=b.fieldName,k&&O.setAttribute("checked",!0),O.tabIndex=p,O.addEventListener("change",(I=>{let{name:S,checked:L}=I.target;for(let $ of this._getElementsByName(S,C))c.setValue($.id,{value:!1});c.setValue(C,{value:L})})),O.addEventListener("resetform",(I=>{let S=b.defaultFieldValue;I.target.checked=S!=null&&S===b.buttonValue})),this.enableScripting&&this.hasJSActions){let I=b.buttonValue;O.addEventListener("updatefromsandbox",(S=>{let L={value:$=>{let U=I===$.detail.value;for(let P of this._getElementsByName($.target.name)){let F=U&&P.id===C;P.domElement&&(P.domElement.checked=F),c.setValue(P.id,{value:F})}}};this._dispatchEventFromSandbox(L,S)})),this._setEventListeners(O,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(S=>S.target.checked))}return this._setBackgroundColor(O),this._setDefaultPropertiesFromJS(O),this.container.append(O),this.container}}class E extends d{constructor(c){super(c,{ignoreBorder:c.data.hasAppearance})}render(){let c=super.render();c.classList.add("buttonWidgetAnnotation","pushButton");let b=c.lastChild;return this.enableScripting&&this.hasJSActions&&b&&(this._setDefaultPropertiesFromJS(b),b.addEventListener("updatefromsandbox",(C=>{this._dispatchEventFromSandbox({},C)}))),c}}class M extends r{constructor(c){super(c,{isRenderable:c.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let c=this.annotationStorage,b=this.data.id,C=c.getValue(b,{value:this.data.fieldValue}),k=document.createElement("select");a.add(k),k.setAttribute("data-element-id",b),k.disabled=this.data.readOnly,this._setRequired(k,this.data.required),k.name=this.data.fieldName,k.tabIndex=p;let O=this.data.combo&&this.data.options.length>0;this.data.combo||(k.size=this.data.options.length,this.data.multiSelect&&(k.multiple=!0)),k.addEventListener("resetform",(U=>{let P=this.data.defaultFieldValue;for(let F of k.options)F.selected=F.value===P}));for(let U of this.data.options){let P=document.createElement("option");P.textContent=U.displayValue,P.value=U.exportValue,C.value.includes(U.exportValue)&&(P.setAttribute("selected",!0),O=!1),k.append(P)}let I=null;if(O){let U=document.createElement("option");U.value=" ",U.setAttribute("hidden",!0),U.setAttribute("selected",!0),k.prepend(U),I=()=>{U.remove(),k.removeEventListener("input",I),I=null},k.addEventListener("input",I)}let S=U=>{let P=U?"value":"textContent",{options:F,multiple:V}=k;return V?Array.prototype.filter.call(F,(Q=>Q.selected)).map((Q=>Q[P])):F.selectedIndex===-1?null:F[F.selectedIndex][P]},L=S(!1),$=U=>{let P=U.target.options;return Array.prototype.map.call(P,(F=>({displayValue:F.textContent,exportValue:F.value})))};return this.enableScripting&&this.hasJSActions?(k.addEventListener("updatefromsandbox",(U=>{let P={value(F){I?.();let V=F.detail.value,Q=new Set(Array.isArray(V)?V:[V]);for(let Z of k.options)Z.selected=Q.has(Z.value);c.setValue(b,{value:S(!0)}),L=S(!1)},multipleSelection(F){k.multiple=!0},remove(F){let V=k.options,Q=F.detail.remove;V[Q].selected=!1,k.remove(Q),V.length>0&&Array.prototype.findIndex.call(V,(Z=>Z.selected))===-1&&(V[0].selected=!0),c.setValue(b,{value:S(!0),items:$(F)}),L=S(!1)},clear(F){for(;k.length!==0;)k.remove(0);c.setValue(b,{value:null,items:[]}),L=S(!1)},insert(F){let{index:V,displayValue:Q,exportValue:Z}=F.detail.insert,tt=k.children[V],nt=document.createElement("option");nt.textContent=Q,nt.value=Z,tt?tt.before(nt):k.append(nt),c.setValue(b,{value:S(!0),items:$(F)}),L=S(!1)},items(F){let{items:V}=F.detail;for(;k.length!==0;)k.remove(0);for(let Q of V){let{displayValue:Z,exportValue:tt}=Q,nt=document.createElement("option");nt.textContent=Z,nt.value=tt,k.append(nt)}k.options.length>0&&(k.options[0].selected=!0),c.setValue(b,{value:S(!0),items:$(F)}),L=S(!1)},indices(F){let V=new Set(F.detail.indices);for(let Q of F.target.options)Q.selected=V.has(Q.index);c.setValue(b,{value:S(!0)}),L=S(!1)},editable(F){F.target.disabled=!F.detail.editable}};this._dispatchEventFromSandbox(P,U)})),k.addEventListener("input",(U=>{let P=S(!0);c.setValue(b,{value:P}),U.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:b,name:"Keystroke",value:L,changeEx:P,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(k,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(U=>U.target.value))):k.addEventListener("input",(function(U){c.setValue(b,{value:S(!0)})})),this.data.combo&&this._setTextStyle(k),this._setBackgroundColor(k),this._setDefaultPropertiesFromJS(k),this.container.append(k),this.container}}class N extends _{constructor(c){let{data:b,elements:C}=c;super(c,{isRenderable:_._hasPopupData(b)}),this.elements=C}render(){this.container.classList.add("popupAnnotation");let c=new H({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),b=[];for(let C of this.elements)C.popup=c,b.push(C.data.id),C.addHighlightArea();return this.container.setAttribute("aria-controls",b.map((C=>`${i.AnnotationPrefix}${C}`)).join(",")),this.container}}class H{#t=this.#m.bind(this);#e=this.#_.bind(this);#i=this.#S.bind(this);#n=this.#v.bind(this);#r=null;#s=null;#a=null;#c=null;#o=null;#d=null;#p=null;#u=!1;#l=null;#f=null;#g=null;#h=null;#b=!1;constructor({container:c,color:b,elements:C,titleObj:k,modificationDate:O,contentsObj:I,richText:S,parent:L,rect:$,parentRect:U,open:P}){this.#s=c,this.#h=k,this.#a=I,this.#g=S,this.#d=L,this.#r=b,this.#f=$,this.#p=U,this.#o=C,this.#c=n.PDFDateString.toDateObject(O),this.trigger=C.flatMap((F=>F.getElementsToTriggerPopup()));for(let F of this.trigger)F.addEventListener("click",this.#n),F.addEventListener("mouseenter",this.#i),F.addEventListener("mouseleave",this.#e),F.classList.add("popupTriggerArea");for(let F of C)F.container?.addEventListener("keydown",this.#t);this.#s.hidden=!0,P&&this.#v()}render(){if(this.#l)return;let{page:{view:c},viewport:{rawDims:{pageWidth:b,pageHeight:C,pageX:k,pageY:O}}}=this.#d,I=this.#l=document.createElement("div");if(I.className="popup",this.#r){let pt=I.style.outlineColor=i.Util.makeHexColor(...this.#r);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?I.style.backgroundColor=`color-mix(in srgb, ${pt} 30%, white)`:I.style.backgroundColor=i.Util.makeHexColor(...this.#r.map((lt=>Math.floor(.7*(255-lt)+lt))))}let S=document.createElement("span");S.className="header";let L=document.createElement("h1");if(S.append(L),{dir:L.dir,str:L.textContent}=this.#h,I.append(S),this.#c){let pt=document.createElement("span");pt.classList.add("popupDate"),pt.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),pt.setAttribute("data-l10n-args",JSON.stringify({date:this.#c.toLocaleDateString(),time:this.#c.toLocaleTimeString()})),S.append(pt)}let $=this.#a,U=this.#g;if(!U?.str||$?.str&&$.str!==U.str){let pt=this._formatContents($);I.append(pt)}else v.XfaLayer.render({xfaHtml:U.html,intent:"richText",div:I}),I.lastChild.classList.add("richText","popupContent");let P=!!this.#p,F=P?this.#p:this.#f;for(let pt of this.#o)if(!F||i.Util.intersect(pt.data.rect,F)!==null){F=pt.data.rect,P=!0;break}let V=i.Util.normalizeRect([F[0],c[3]-F[1]+c[1],F[2],c[3]-F[3]+c[1]]),Q=P?F[2]-F[0]+5:0,Z=V[0]+Q,tt=V[1],{style:nt}=this.#s;nt.left=100*(Z-k)/b+"%",nt.top=100*(tt-O)/C+"%",this.#s.append(I)}_formatContents({str:c,dir:b}){let C=document.createElement("p");C.classList.add("popupContent"),C.dir=b;let k=c.split(/(?:\r\n?|\n)/);for(let O=0,I=k.length;O<I;++O){let S=k[O];C.append(document.createTextNode(S)),O<I-1&&C.append(document.createElement("br"))}return C}#m(c){c.altKey||c.shiftKey||c.ctrlKey||c.metaKey||(c.key==="Enter"||c.key==="Escape"&&this.#u)&&this.#v()}#v(){this.#u=!this.#u,this.#u?(this.#S(),this.#s.addEventListener("click",this.#n),this.#s.addEventListener("keydown",this.#t)):(this.#_(),this.#s.removeEventListener("click",this.#n),this.#s.removeEventListener("keydown",this.#t))}#S(){this.#l||this.render(),this.isVisible?this.#u&&this.#s.classList.add("focused"):(this.#s.hidden=!1,this.#s.style.zIndex=parseInt(this.#s.style.zIndex)+1e3)}#_(){this.#s.classList.remove("focused"),!this.#u&&this.isVisible&&(this.#s.hidden=!0,this.#s.style.zIndex=parseInt(this.#s.style.zIndex)-1e3)}forceHide(){this.#b=this.isVisible,this.#b&&(this.#s.hidden=!0)}maybeShow(){this.#b&&(this.#b=!1,this.#s.hidden=!1)}get isVisible(){return this.#s.hidden===!1}}class z extends _{constructor(c){super(c,{isRenderable:!0,ignoreBorder:!0}),this.textContent=c.data.textContent,this.textPosition=c.data.textPosition,this.annotationEditorType=i.AnnotationEditorType.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let c=document.createElement("div");c.classList.add("annotationTextContent"),c.setAttribute("role","comment");for(let b of this.textContent){let C=document.createElement("span");C.textContent=b,c.append(C)}this.container.append(c)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}get _isEditable(){return this.data.hasOwnCanvas}}class K extends _{#t=null;constructor(c){super(c,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let c=this.data,{width:b,height:C}=f(c.rect),k=this.svgFactory.create(b,C,!0),O=this.#t=this.svgFactory.createElement("svg:line");return O.setAttribute("x1",c.rect[2]-c.lineCoordinates[0]),O.setAttribute("y1",c.rect[3]-c.lineCoordinates[1]),O.setAttribute("x2",c.rect[2]-c.lineCoordinates[2]),O.setAttribute("y2",c.rect[3]-c.lineCoordinates[3]),O.setAttribute("stroke-width",c.borderStyle.width||1),O.setAttribute("stroke","transparent"),O.setAttribute("fill","transparent"),k.append(O),this.container.append(k),!c.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class it extends _{#t=null;constructor(c){super(c,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let c=this.data,{width:b,height:C}=f(c.rect),k=this.svgFactory.create(b,C,!0),O=c.borderStyle.width,I=this.#t=this.svgFactory.createElement("svg:rect");return I.setAttribute("x",O/2),I.setAttribute("y",O/2),I.setAttribute("width",b-O),I.setAttribute("height",C-O),I.setAttribute("stroke-width",O||1),I.setAttribute("stroke","transparent"),I.setAttribute("fill","transparent"),k.append(I),this.container.append(k),!c.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class ot extends _{#t=null;constructor(c){super(c,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let c=this.data,{width:b,height:C}=f(c.rect),k=this.svgFactory.create(b,C,!0),O=c.borderStyle.width,I=this.#t=this.svgFactory.createElement("svg:ellipse");return I.setAttribute("cx",b/2),I.setAttribute("cy",C/2),I.setAttribute("rx",b/2-O/2),I.setAttribute("ry",C/2-O/2),I.setAttribute("stroke-width",O||1),I.setAttribute("stroke","transparent"),I.setAttribute("fill","transparent"),k.append(I),this.container.append(k),!c.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class X extends _{#t=null;constructor(c){super(c,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let c=this.data,{width:b,height:C}=f(c.rect),k=this.svgFactory.create(b,C,!0),O=[];for(let S of c.vertices){let L=S.x-c.rect[0],$=c.rect[3]-S.y;O.push(L+","+$)}O=O.join(" ");let I=this.#t=this.svgFactory.createElement(this.svgElementName);return I.setAttribute("points",O),I.setAttribute("stroke-width",c.borderStyle.width||1),I.setAttribute("stroke","transparent"),I.setAttribute("fill","transparent"),k.append(I),this.container.append(k),!c.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class j extends X{constructor(c){super(c),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class G extends _{constructor(c){super(c,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Y extends _{#t=[];constructor(c){super(c,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=i.AnnotationEditorType.INK}render(){this.container.classList.add(this.containerClassName);let c=this.data,{width:b,height:C}=f(c.rect),k=this.svgFactory.create(b,C,!0);for(let O of c.inkLists){let I=[];for(let L of O){let $=L.x-c.rect[0],U=c.rect[3]-L.y;I.push(`${$},${U}`)}I=I.join(" ");let S=this.svgFactory.createElement(this.svgElementName);this.#t.push(S),S.setAttribute("points",I),S.setAttribute("stroke-width",c.borderStyle.width||1),S.setAttribute("stroke","transparent"),S.setAttribute("fill","transparent"),!c.popupRef&&this.hasPopupData&&this._createPopup(),k.append(S)}return this.container.append(k),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class et extends _{constructor(c){super(c,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}class rt extends _{constructor(c){super(c,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class ct extends _{constructor(c){super(c,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class st extends _{constructor(c){super(c,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class W extends _{constructor(c){super(c,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class w extends _{#t=null;constructor(c){super(c,{isRenderable:!0});let{filename:b,content:C}=this.data.file;this.filename=(0,n.getFilenameFromUrl)(b,!0),this.content=C,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,filename:b,content:C})}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:c,data:b}=this,C;b.hasAppearance||b.fillAlpha===0?C=document.createElement("div"):(C=document.createElement("img"),C.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(b.name)?"paperclip":"pushpin"}.svg`,b.fillAlpha&&b.fillAlpha<1&&(C.style=`filter: opacity(${Math.round(100*b.fillAlpha)}%);`)),C.addEventListener("dblclick",this.#e.bind(this)),this.#t=C;let{isMac:k}=i.FeatureTest.platform;return c.addEventListener("keydown",(O=>{O.key==="Enter"&&(k?O.metaKey:O.ctrlKey)&&this.#e()})),!b.popupRef&&this.hasPopupData?this._createPopup():C.classList.add("popupTriggerArea"),c.append(C),c}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class T{#t=null;#e=null;#i=new Map;constructor({div:c,accessibilityManager:b,annotationCanvasMap:C,page:k,viewport:O}){this.div=c,this.#t=b,this.#e=C,this.page=k,this.viewport=O,this.zIndex=0}#n(c,b){let C=c.firstChild||c;C.id=`${i.AnnotationPrefix}${b}`,this.div.append(c),this.#t?.moveElementInDOM(this.div,c,C,!1)}async render(c){let{annotations:b}=c,C=this.div;(0,n.setLayerDimensions)(C,this.viewport);let k=new Map,O={data:null,layer:C,linkService:c.linkService,downloadManager:c.downloadManager,imageResourcesPath:c.imageResourcesPath||"",renderForms:c.renderForms!==!1,svgFactory:new n.DOMSVGFactory,annotationStorage:c.annotationStorage||new o.AnnotationStorage,enableScripting:c.enableScripting===!0,hasJSActions:c.hasJSActions,fieldObjects:c.fieldObjects,parent:this,elements:null};for(let I of b){if(I.noHTML)continue;let S=I.annotationType===i.AnnotationType.POPUP;if(S){let U=k.get(I.id);if(!U)continue;O.elements=U}else{let{width:U,height:P}=f(I.rect);if(U<=0||P<=0)continue}O.data=I;let L=A.create(O);if(!L.isRenderable)continue;if(!S&&I.popupRef){let U=k.get(I.popupRef);U?U.push(L):k.set(I.popupRef,[L])}L.annotationEditorType>0&&this.#i.set(L.data.id,L);let $=L.render();I.hidden&&($.style.visibility="hidden"),this.#n($,I.id)}this.#r()}update({viewport:c}){let b=this.div;this.viewport=c,(0,n.setLayerDimensions)(b,{rotation:c.rotation}),this.#r(),b.hidden=!1}#r(){if(!this.#e)return;let c=this.div;for(let[b,C]of this.#e){let k=c.querySelector(`[data-annotation-id="${b}"]`);if(!k)continue;let{firstChild:O}=k;O?O.nodeName==="CANVAS"?O.replaceWith(C):O.before(C):k.append(C)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#i.values())}getEditableAnnotation(c){return this.#i.get(c)}}},792:(s,t,e)=>{e.d(t,{AnnotationStorage:()=>u,PrintAnnotationStorage:()=>g,SerializableEmpty:()=>h});var i=e(292),n=e(310),o=e(651);let h=Object.freeze({map:null,hash:"",transfer:void 0});class u{#t=!1;#e=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(p,a){let f=this.#e.get(p);return f===void 0?a:Object.assign(a,f)}getRawValue(p){return this.#e.get(p)}remove(p){if(this.#e.delete(p),this.#e.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(let a of this.#e.values())if(a instanceof n.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(p,a){let f=this.#e.get(p),A=!1;if(f!==void 0)for(let[_,d]of Object.entries(a))f[_]!==d&&(A=!0,f[_]=d);else A=!0,this.#e.set(p,a);A&&this.#i(),a instanceof n.AnnotationEditor&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(a.constructor._type)}has(p){return this.#e.has(p)}getAll(){return this.#e.size>0?(0,i.objectFromMap)(this.#e):null}setAll(p){for(let[a,f]of Object.entries(p))this.setValue(a,f)}get size(){return this.#e.size}#i(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new g(this)}get serializable(){if(this.#e.size===0)return h;let p=new Map,a=new o.MurmurHash3_64,f=[],A=Object.create(null),_=!1;for(let[d,y]of this.#e){let r=y instanceof n.AnnotationEditor?y.serialize(!1,A):y;r&&(p.set(d,r),a.update(`${d}:${JSON.stringify(r)}`),_||=!!r.bitmap)}if(_)for(let d of p.values())d.bitmap&&f.push(d.bitmap);return p.size>0?{map:p,hash:a.hexdigest(),transfer:f}:h}get editorStats(){let p=null,a=new Map;for(let f of this.#e.values()){if(!(f instanceof n.AnnotationEditor))continue;let A=f.telemetryFinalData;if(!A)continue;let{type:_}=A;a.has(_)||a.set(_,Object.getPrototypeOf(f).constructor),p||=Object.create(null);let d=p[_]||=new Map;for(let[y,r]of Object.entries(A)){if(y==="type")continue;let l=d.get(y);l||(l=new Map,d.set(y,l));let m=l.get(r)??0;l.set(r,m+1)}}for(let[f,A]of a)p[f]=A.computeTelemetryFinalData(p[f]);return p}}class g extends u{#t;constructor(p){super();let{map:a,hash:f,transfer:A}=p.serializable,_=structuredClone(a,A?{transfer:A}:null);this.#t={map:_,hash:f,transfer:A}}get print(){(0,i.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}}},831:(s,t,e)=>{e.a(s,(async(i,n)=>{try{let ot=function(I){if(typeof I=="string"||I instanceof URL?I={url:I}:(I instanceof ArrayBuffer||ArrayBuffer.isView(I))&&(I={data:I}),typeof I!="object")throw new Error("Invalid parameter in getDocument, need parameter object.");if(!I.url&&!I.data&&!I.range)throw new Error("Invalid parameter object: need either .data, .range or .url");let S=new Y,{docId:L}=S,$=I.url?j(I.url):null,U=I.data?G(I.data):null,P=I.httpHeaders||null,F=I.withCredentials===!0,V=I.password??null,Q=I.range instanceof et?I.range:null,Z=Number.isInteger(I.rangeChunkSize)&&I.rangeChunkSize>0?I.rangeChunkSize:E,tt=I.worker instanceof w?I.worker:null,nt=I.verbosity,pt=typeof I.docBaseUrl!="string"||(0,u.isDataScheme)(I.docBaseUrl)?null:I.docBaseUrl,dt=typeof I.cMapUrl=="string"?I.cMapUrl:null,lt=I.cMapPacked!==!1,wt=I.CMapReaderFactory||z,Tt=typeof I.standardFontDataUrl=="string"?I.standardFontDataUrl:null,xt=I.StandardFontDataFactory||it,Dt=I.stopAtErrors!==!0,Mt=Number.isInteger(I.maxImageSize)&&I.maxImageSize>-1?I.maxImageSize:-1,Bt=I.isEvalSupported!==!1,Ht=typeof I.isOffscreenCanvasSupported=="boolean"?I.isOffscreenCanvasSupported:!o.isNodeJS,le=Number.isInteger(I.canvasMaxAreaInBytes)?I.canvasMaxAreaInBytes:-1,Ae=typeof I.disableFontFace=="boolean"?I.disableFontFace:o.isNodeJS,Oe=I.fontExtraProperties===!0,ke=I.enableXfa===!0,De=I.ownerDocument||globalThis.document,si=I.disableRange===!0,ni=I.disableStream===!0,ae=I.disableAutoFetch===!0,ie=I.pdfBug===!0,ri=Q?Q.length:I.length??NaN,Xi=typeof I.useSystemFonts=="boolean"?I.useSystemFonts:!o.isNodeJS&&!Ae,Ie=typeof I.useWorkerFetch=="boolean"?I.useWorkerFetch:wt===u.DOMCMapReaderFactory&&xt===u.DOMStandardFontDataFactory&&dt&&Tt&&(0,u.isValidFetchUrl)(dt,document.baseURI)&&(0,u.isValidFetchUrl)(Tt,document.baseURI),te=I.canvasFactory||new H({ownerDocument:De}),An=I.filterFactory||new K({docId:L,ownerDocument:De});(0,o.setVerbosityLevel)(nt);let Ki={canvasFactory:te,filterFactory:An};if(Ie||(Ki.cMapReaderFactory=new wt({baseUrl:dt,isCompressed:lt}),Ki.standardFontDataFactory=new xt({baseUrl:Tt})),!tt){let Be={verbosity:nt,port:f.GlobalWorkerOptions.workerPort};tt=Be.port?w.fromPort(Be):new w(Be),S._worker=tt}let Ne={docId:L,apiVersion:"4.1.392",data:U,password:V,disableAutoFetch:ae,rangeChunkSize:Z,length:ri,docBaseUrl:pt,enableXfa:ke,evaluatorOptions:{maxImageSize:Mt,disableFontFace:Ae,ignoreErrors:Dt,isEvalSupported:Bt,isOffscreenCanvasSupported:Ht,canvasMaxAreaInBytes:le,fontExtraProperties:Oe,useSystemFonts:Xi,cMapUrl:Ie?dt:null,standardFontDataUrl:Ie?Tt:null}},wi={ignoreErrors:Dt,isEvalSupported:Bt,disableFontFace:Ae,fontExtraProperties:Oe,enableXfa:ke,ownerDocument:De,disableAutoFetch:ae,pdfBug:ie,styleElement:null};return tt.promise.then((function(){if(S.destroyed)throw new Error("Loading aborted");let Be=X(tt,Ne),Sn=new Promise((function(Yi){let ai;Q?ai=new y.PDFDataTransportStream(Q,{disableRange:si,disableStream:ni}):U||(ai=(ue=>o.isNodeJS?(function(){return typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype})()&&(0,u.isValidFetchUrl)(ue.url)?new r.PDFFetchStream(ue):new m.PDFNodeStream(ue):(0,u.isValidFetchUrl)(ue.url)?new r.PDFFetchStream(ue):new l.PDFNetworkStream(ue))({url:$,length:ri,httpHeaders:P,withCredentials:F,rangeChunkSize:Z,disableRange:si,disableStream:ni})),Yi(ai)}));return Promise.all([Be,Sn]).then((function([Yi,ai]){if(S.destroyed)throw new Error("Loading aborted");let ue=new A.MessageHandler(L,Yi,tt.port),En=new T(ue,S,ai,wi,Ki);S._transport=En,ue.send("Ready",null)}))})).catch(S._capability.reject),S},j=function(I){if(I instanceof URL)return I.href;try{return new URL(I,window.location).href}catch{if(o.isNodeJS&&typeof I=="string")return I}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")},G=function(I){if(o.isNodeJS&&typeof Buffer<"u"&&I instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(I instanceof Uint8Array&&I.byteLength===I.buffer.byteLength)return I;if(typeof I=="string")return(0,o.stringToBytes)(I);if(I instanceof ArrayBuffer||ArrayBuffer.isView(I)||typeof I=="object"&&!isNaN(I?.length))return new Uint8Array(I);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")};e.d(t,{PDFDataRangeTransport:()=>et,PDFWorker:()=>w,build:()=>O,getDocument:()=>ot,version:()=>k});var o=e(292),h=e(792),u=e(419),g=e(10),v=e(573),p=e(923),a=e(814),f=e(164),A=e(178),_=e(62),d=e(626),y=e(585),r=e(94),l=e(457),m=e(786),x=e(50),D=i([v,m]);[v,m]=D.then?(await D)():D;let E=65536,M=100,N=5e3,H=o.isNodeJS?v.NodeCanvasFactory:u.DOMCanvasFactory,z=o.isNodeJS?v.NodeCMapReaderFactory:u.DOMCMapReaderFactory,K=o.isNodeJS?v.NodeFilterFactory:u.DOMFilterFactory,it=o.isNodeJS?v.NodeStandardFontDataFactory:u.DOMStandardFontDataFactory;async function X(I,S){if(I.destroyed)throw new Error("Worker was destroyed");let L=await I.messageHandler.sendWithPromise("GetDocRequest",S,S.data?[S.data.buffer]:null);if(I.destroyed)throw new Error("Worker was destroyed");return L}class Y{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+Y.#t++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(S){throw this._worker?.port&&delete this._worker._pendingDestroy,S}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}class et{constructor(S,L,$=!1,U=null){this.length=S,this.initialData=L,this.progressiveDone=$,this.contentDispositionFilename=U,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(S){this._rangeListeners.push(S)}addProgressListener(S){this._progressListeners.push(S)}addProgressiveReadListener(S){this._progressiveReadListeners.push(S)}addProgressiveDoneListener(S){this._progressiveDoneListeners.push(S)}onDataRange(S,L){for(let $ of this._rangeListeners)$(S,L)}onDataProgress(S,L){this._readyCapability.promise.then((()=>{for(let $ of this._progressListeners)$(S,L)}))}onDataProgressiveRead(S){this._readyCapability.promise.then((()=>{for(let L of this._progressiveReadListeners)L(S)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(let S of this._progressiveDoneListeners)S()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(S,L){(0,o.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class rt{constructor(S,L){this._pdfInfo=S,this._transport=L}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return(0,o.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(S){return this._transport.getPage(S)}getPageIndex(S){return this._transport.getPageIndex(S)}getDestinations(){return this._transport.getDestinations()}getDestination(S){return this._transport.getDestination(S)}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:S="display"}={}){let{renderingIntent:L}=this._transport.getRenderingIntent(S);return this._transport.getOptionalContentConfig(L)}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(S=!1){return this._transport.startCleanup(S||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}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 ct{#t=null;#e=!1;constructor(S,L,$,U=!1){this._pageIndex=S,this._pageInfo=L,this._transport=$,this._stats=U?new u.StatTimer:null,this._pdfBug=U,this.commonObjs=$.commonObjs,this.objs=new c,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:S,rotation:L=this.rotate,offsetX:$=0,offsetY:U=0,dontFlip:P=!1}={}){return new u.PageViewport({viewBox:this.view,scale:S,rotation:L,offsetX:$,offsetY:U,dontFlip:P})}getAnnotations({intent:S="display"}={}){let{renderingIntent:L}=this._transport.getRenderingIntent(S);return this._transport.getAnnotations(this._pageIndex,L)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return(0,o.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:S,viewport:L,intent:$="display",annotationMode:U=o.AnnotationMode.ENABLE,transform:P=null,background:F=null,optionalContentConfigPromise:V=null,annotationCanvasMap:Q=null,pageColors:Z=null,printAnnotationStorage:tt=null}){this._stats?.time("Overall");let nt=this._transport.getRenderingIntent($,U,tt),{renderingIntent:pt,cacheKey:dt}=nt;this.#e=!1,this.#n(),V||=this._transport.getOptionalContentConfig(pt);let lt=this._intentStates.get(dt);lt||(lt=Object.create(null),this._intentStates.set(dt,lt)),lt.streamReaderCancelTimeout&&(clearTimeout(lt.streamReaderCancelTimeout),lt.streamReaderCancelTimeout=null);let wt=!!(pt&o.RenderingIntentFlag.PRINT);lt.displayReadyCapability||(lt.displayReadyCapability=Promise.withResolvers(),lt.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(nt));let Tt=Mt=>{lt.renderTasks.delete(xt),(this._maybeCleanupAfterRender||wt)&&(this.#e=!0),this.#i(!wt),Mt?(xt.capability.reject(Mt),this._abortOperatorList({intentState:lt,reason:Mt instanceof Error?Mt:new Error(Mt)})):xt.capability.resolve(),this._stats?.timeEnd("Rendering"),this._stats?.timeEnd("Overall")},xt=new C({callback:Tt,params:{canvasContext:S,viewport:L,transform:P,background:F},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:Q,operatorList:lt.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!wt,pdfBug:this._pdfBug,pageColors:Z});(lt.renderTasks||=new Set).add(xt);let Dt=xt.task;return Promise.all([lt.displayReadyCapability.promise,V]).then((([Mt,Bt])=>{if(this.destroyed)Tt();else{if(this._stats?.time("Rendering"),!(Bt.renderingIntent&pt))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");xt.initializeGraphics({transparency:Mt,optionalContentConfig:Bt}),xt.operatorListChanged()}})).catch(Tt),Dt}getOperatorList({intent:S="display",annotationMode:L=o.AnnotationMode.ENABLE,printAnnotationStorage:$=null}={}){let U=this._transport.getRenderingIntent(S,L,$,!0),P,F=this._intentStates.get(U.cacheKey);return F||(F=Object.create(null),this._intentStates.set(U.cacheKey,F)),F.opListReadCapability||(P=Object.create(null),P.operatorListChanged=function(){F.operatorList.lastChunk&&(F.opListReadCapability.resolve(F.operatorList),F.renderTasks.delete(P))},F.opListReadCapability=Promise.withResolvers(),(F.renderTasks||=new Set).add(P),F.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(U)),F.opListReadCapability.promise}streamTextContent({includeMarkedContent:S=!1,disableNormalization:L=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:S===!0,disableNormalization:L===!0},{highWaterMark:100,size:$=>$.items.length})}getTextContent(S={}){if(this._transport._htmlForXfa)return this.getXfa().then(($=>x.XfaText.textContent($)));let L=this.streamTextContent(S);return new Promise((function($,U){let P=L.getReader(),F={items:[],styles:Object.create(null)};(function V(){P.read().then((function({value:Q,done:Z}){Z?$(F):(Object.assign(F.styles,Q.styles),F.items.push(...Q.items),V())}),U)})()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let S=[];for(let L of this._intentStates.values())if(this._abortOperatorList({intentState:L,reason:new Error("Page was destroyed."),force:!0}),!L.opListReadCapability)for(let $ of L.renderTasks)S.push($.completed),$.cancel();return this.objs.clear(),this.#e=!1,this.#n(),Promise.all(S)}cleanup(S=!1){this.#e=!0;let L=this.#i(!1);return S&&L&&(this._stats&&=new u.StatTimer),L}#i(S=!1){if(this.#n(),!this.#e||this.destroyed)return!1;if(S)return this.#t=setTimeout((()=>{this.#t=null,this.#i(!1)}),N),!1;for(let{renderTasks:L,operatorList:$}of this._intentStates.values())if(L.size>0||!$.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#n(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(S,L){let $=this._intentStates.get(L);$&&(this._stats?.timeEnd("Page Request"),$.displayReadyCapability?.resolve(S))}_renderPageChunk(S,L){for(let $=0,U=S.length;$<U;$++)L.operatorList.fnArray.push(S.fnArray[$]),L.operatorList.argsArray.push(S.argsArray[$]);L.operatorList.lastChunk=S.lastChunk,L.operatorList.separateAnnots=S.separateAnnots;for(let $ of L.renderTasks)$.operatorListChanged();S.lastChunk&&this.#i(!0)}_pumpOperatorList({renderingIntent:S,cacheKey:L,annotationStorageSerializable:$}){let{map:U,transfer:P}=$,F=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:S,cacheKey:L,annotationStorage:U},P).getReader(),V=this._intentStates.get(L);V.streamReader=F;let Q=()=>{F.read().then((({value:Z,done:tt})=>{tt?V.streamReader=null:this._transport.destroyed||(this._renderPageChunk(Z,V),Q())}),(Z=>{if(V.streamReader=null,!this._transport.destroyed){if(V.operatorList){V.operatorList.lastChunk=!0;for(let tt of V.renderTasks)tt.operatorListChanged();this.#i(!0)}if(V.displayReadyCapability)V.displayReadyCapability.reject(Z);else{if(!V.opListReadCapability)throw Z;V.opListReadCapability.reject(Z)}}}))};Q()}_abortOperatorList({intentState:S,reason:L,force:$=!1}){if(S.streamReader){if(S.streamReaderCancelTimeout&&(clearTimeout(S.streamReaderCancelTimeout),S.streamReaderCancelTimeout=null),!$){if(S.renderTasks.size>0)return;if(L instanceof u.RenderingCancelledException){let U=M;L.extraDelay>0&&L.extraDelay<1e3&&(U+=L.extraDelay),S.streamReaderCancelTimeout=setTimeout((()=>{S.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:S,reason:L,force:!0})}),U);return}}if(S.streamReader.cancel(new o.AbortException(L.message)).catch((()=>{})),S.streamReader=null,!this._transport.destroyed){for(let[U,P]of this._intentStates)if(P===S){this._intentStates.delete(U);break}this.cleanup()}}}get stats(){return this._stats}}class st{#t=new Set;#e=Promise.resolve();postMessage(S,L){let $={data:structuredClone(S,L?{transfer:L}:null)};this.#e.then((()=>{for(let U of this.#t)U.call(this,$)}))}addEventListener(S,L){this.#t.add(L)}removeEventListener(S,L){this.#t.delete(L)}terminate(){this.#t.clear()}}let W={isWorkerDisabled:!1,fakeWorkerId:0};o.isNodeJS&&(W.isWorkerDisabled=!0,f.GlobalWorkerOptions.workerSrc||="./pdf.worker.mjs"),W.isSameOrigin=function(I,S){let L;try{if(L=new URL(I),!L.origin||L.origin==="null")return!1}catch{return!1}let $=new URL(S,L);return L.origin===$.origin},W.createCDNWrapper=function(I){let S=`await import("${I}");`;return URL.createObjectURL(new Blob([S],{type:"text/javascript"}))};class w{static#t;constructor({name:S=null,port:L=null,verbosity:$=(0,o.getVerbosityLevel)()}={}){if(this.name=S,this.destroyed=!1,this.verbosity=$,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,L){if(w.#t?.has(L))throw new Error("Cannot use more than one PDFWorker per port.");(w.#t||=new WeakMap).set(L,this),this._initializeFromPort(L)}else this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(S){this._port=S,this._messageHandler=new A.MessageHandler("main","worker",S),this._messageHandler.on("ready",(function(){})),this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}_initialize(){if(!W.isWorkerDisabled&&!w.#e){let{workerSrc:S}=w;try{W.isSameOrigin(window.location.href,S)||(S=W.createCDNWrapper(new URL(S,window.location).href));let L=new Worker(S,{type:"module"}),$=new A.MessageHandler("main","worker",L),U=()=>{L.removeEventListener("error",P),$.destroy(),L.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},P=()=>{this._webWorker||U()};L.addEventListener("error",P),$.on("test",(V=>{L.removeEventListener("error",P),this.destroyed?U():V?(this._messageHandler=$,this._port=L,this._webWorker=L,this._readyCapability.resolve(),$.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),$.destroy(),L.terminate())})),$.on("ready",(V=>{if(L.removeEventListener("error",P),this.destroyed)U();else try{F()}catch{this._setupFakeWorker()}}));let F=()=>{let V=new Uint8Array;$.send("test",V,[V.buffer])};F();return}catch{(0,o.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){W.isWorkerDisabled||((0,o.warn)("Setting up fake worker."),W.isWorkerDisabled=!0),w._setupFakeWorkerGlobal.then((S=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}let L=new st;this._port=L;let $="fake"+W.fakeWorkerId++,U=new A.MessageHandler($+"_worker",$,L);S.setup(U,L);let P=new A.MessageHandler($,$+"_worker",L);this._messageHandler=P,this._readyCapability.resolve(),P.send("configure",{verbosity:this.verbosity})})).catch((S=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${S.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),w.#t?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(S){if(!S?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");let L=this.#t?.get(S.port);if(L){if(L._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return L}return new w(S)}static get workerSrc(){if(f.GlobalWorkerOptions.workerSrc)return f.GlobalWorkerOptions.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#e(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return(0,o.shadow)(this,"_setupFakeWorkerGlobal",(async()=>this.#e?this.#e:(await import(this.workerSrc)).WorkerMessageHandler)())}}class T{#t=new Map;#e=new Map;#i=new Map;#n=null;constructor(S,L,$,U,P){this.messageHandler=S,this.loadingTask=L,this.commonObjs=new c,this.fontLoader=new g.FontLoader({ownerDocument:U.ownerDocument,styleElement:U.styleElement}),this._params=U,this.canvasFactory=P.canvasFactory,this.filterFactory=P.filterFactory,this.cMapReaderFactory=P.cMapReaderFactory,this.standardFontDataFactory=P.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=$,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#r(S,L=null){let $=this.#t.get(S);if($)return $;let U=this.messageHandler.sendWithPromise(S,L);return this.#t.set(S,U),U}get annotationStorage(){return(0,o.shadow)(this,"annotationStorage",new h.AnnotationStorage)}getRenderingIntent(S,L=o.AnnotationMode.ENABLE,$=null,U=!1){let P=o.RenderingIntentFlag.DISPLAY,F=h.SerializableEmpty;switch(S){case"any":P=o.RenderingIntentFlag.ANY;break;case"display":break;case"print":P=o.RenderingIntentFlag.PRINT;break;default:(0,o.warn)(`getRenderingIntent - invalid intent: ${S}`)}switch(L){case o.AnnotationMode.DISABLE:P+=o.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case o.AnnotationMode.ENABLE:break;case o.AnnotationMode.ENABLE_FORMS:P+=o.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case o.AnnotationMode.ENABLE_STORAGE:P+=o.RenderingIntentFlag.ANNOTATIONS_STORAGE,F=(P&o.RenderingIntentFlag.PRINT&&$ instanceof h.PrintAnnotationStorage?$:this.annotationStorage).serializable;break;default:(0,o.warn)(`getRenderingIntent - invalid annotationMode: ${L}`)}return U&&(P+=o.RenderingIntentFlag.OPLIST),{renderingIntent:P,cacheKey:`${P}_${F.hash}`,annotationStorageSerializable:F}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#n?.reject(new Error("Worker was destroyed during onPassword callback"));let S=[];for(let $ of this.#e.values())S.push($._destroy());this.#e.clear(),this.#i.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let L=this.messageHandler.sendWithPromise("Terminate",null);return S.push(L),Promise.all(S).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),(0,a.cleanupTextLayer)(),this._networkStream?.cancelAllRequests(new o.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:S,loadingTask:L}=this;S.on("GetReader",(($,U)=>{(0,o.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=P=>{this._lastProgress={loaded:P.loaded,total:P.total}},U.onPull=()=>{this._fullReader.read().then((function({value:P,done:F}){F?U.close():((0,o.assert)(P instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),U.enqueue(new Uint8Array(P),1,[P]))})).catch((P=>{U.error(P)}))},U.onCancel=P=>{this._fullReader.cancel(P),U.ready.catch((F=>{if(!this.destroyed)throw F}))}})),S.on("ReaderHeadersReady",($=>{let U=Promise.withResolvers(),P=this._fullReader;return P.headersReady.then((()=>{(!P.isStreamingSupported||!P.isRangeSupported)&&(this._lastProgress&&L.onProgress?.(this._lastProgress),P.onProgress=F=>{L.onProgress?.({loaded:F.loaded,total:F.total})}),U.resolve({isStreamingSupported:P.isStreamingSupported,isRangeSupported:P.isRangeSupported,contentLength:P.contentLength})}),U.reject),U.promise})),S.on("GetRangeReader",(($,U)=>{(0,o.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let P=this._networkStream.getRangeReader($.begin,$.end);P?(U.onPull=()=>{P.read().then((function({value:F,done:V}){V?U.close():((0,o.assert)(F instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),U.enqueue(new Uint8Array(F),1,[F]))})).catch((F=>{U.error(F)}))},U.onCancel=F=>{P.cancel(F),U.ready.catch((V=>{if(!this.destroyed)throw V}))}):U.close()})),S.on("GetDoc",(({pdfInfo:$})=>{this._numPages=$.numPages,this._htmlForXfa=$.htmlForXfa,delete $.htmlForXfa,L._capability.resolve(new rt($,this))})),S.on("DocException",(function($){let U;switch($.name){case"PasswordException":U=new o.PasswordException($.message,$.code);break;case"InvalidPDFException":U=new o.InvalidPDFException($.message);break;case"MissingPDFException":U=new o.MissingPDFException($.message);break;case"UnexpectedResponseException":U=new o.UnexpectedResponseException($.message,$.status);break;case"UnknownErrorException":U=new o.UnknownErrorException($.message,$.details);break;default:(0,o.unreachable)("DocException - expected a valid Error.")}L._capability.reject(U)})),S.on("PasswordRequest",($=>{if(this.#n=Promise.withResolvers(),L.onPassword){let U=P=>{P instanceof Error?this.#n.reject(P):this.#n.resolve({password:P})};try{L.onPassword(U,$.code)}catch(P){this.#n.reject(P)}}else this.#n.reject(new o.PasswordException($.message,$.code));return this.#n.promise})),S.on("DataLoaded",($=>{L.onProgress?.({loaded:$.length,total:$.length}),this.downloadInfoCapability.resolve($)})),S.on("StartRenderPage",($=>{this.destroyed||this.#e.get($.pageIndex)._startRenderPage($.transparency,$.cacheKey)})),S.on("commonobj",(([$,U,P])=>{if(this.destroyed||this.commonObjs.has($))return null;switch(U){case"Font":let F=this._params;if("error"in P){let tt=P.error;(0,o.warn)(`Error during font loading: ${tt}`),this.commonObjs.resolve($,tt);break}let V=F.pdfBug&&globalThis.FontInspector?.enabled?(tt,nt)=>globalThis.FontInspector.fontAdded(tt,nt):null,Q=new g.FontFaceObject(P,{isEvalSupported:F.isEvalSupported,disableFontFace:F.disableFontFace,ignoreErrors:F.ignoreErrors,inspectFont:V});this.fontLoader.bind(Q).catch((()=>S.sendWithPromise("FontFallback",{id:$}))).finally((()=>{!F.fontExtraProperties&&Q.data&&(Q.data=null),this.commonObjs.resolve($,Q)}));break;case"CopyLocalImage":let{imageRef:Z}=P;(0,o.assert)(Z,"The imageRef must be defined.");for(let tt of this.#e.values())for(let[,nt]of tt.objs)if(nt.ref===Z)return nt.dataLen?(this.commonObjs.resolve($,structuredClone(nt)),nt.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve($,P);break;default:throw new Error(`Got unknown common object type ${U}`)}return null})),S.on("obj",(([$,U,P,F])=>{if(this.destroyed)return;let V=this.#e.get(U);if(!V.objs.has($))if(V._intentStates.size!==0)switch(P){case"Image":V.objs.resolve($,F),F?.dataLen>o.MAX_IMAGE_SIZE_TO_CACHE&&(V._maybeCleanupAfterRender=!0);break;case"Pattern":V.objs.resolve($,F);break;default:throw new Error(`Got unknown object type ${P}`)}else F?.bitmap?.close()})),S.on("DocProgress",($=>{this.destroyed||L.onProgress?.({loaded:$.loaded,total:$.total})})),S.on("FetchBuiltInCMap",($=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch($):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.")))),S.on("FetchStandardFontData",($=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch($):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&(0,o.warn)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:S,transfer:L}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:S,filename:this._fullReader?.filename??null},L).finally((()=>{this.annotationStorage.resetModified()}))}getPage(S){if(!Number.isInteger(S)||S<=0||S>this._numPages)return Promise.reject(new Error("Invalid page request."));let L=S-1,$=this.#i.get(L);if($)return $;let U=this.messageHandler.sendWithPromise("GetPage",{pageIndex:L}).then((P=>{if(this.destroyed)throw new Error("Transport destroyed");let F=new ct(L,P,this,this._params.pdfBug);return this.#e.set(L,F),F}));return this.#i.set(L,U),U}getPageIndex(S){return typeof S!="object"||S===null||!Number.isInteger(S.num)||S.num<0||!Number.isInteger(S.gen)||S.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:S.num,gen:S.gen})}getAnnotations(S,L){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:S,intent:L})}getFieldObjects(){return this.#r("GetFieldObjects")}hasJSActions(){return this.#r("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(S){return typeof S!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:S})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#r("GetDocJSActions")}getPageJSActions(S){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:S})}getStructTree(S){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:S})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(S){return this.#r("GetOptionalContentConfig").then((L=>new d.OptionalContentConfig(L,S)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let S="GetMetadata",L=this.#t.get(S);if(L)return L;let $=this.messageHandler.sendWithPromise(S,null).then((U=>({info:U[0],metadata:U[1]?new _.Metadata(U[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#t.set(S,$),$}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(S=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(let L of this.#e.values())if(!L.cleanup())throw new Error(`startCleanup: Page ${L.pageNumber} is currently rendering.`);this.commonObjs.clear(),S||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),(0,a.cleanupTextLayer)()}}get loadingParams(){let{disableAutoFetch:S,enableXfa:L}=this._params;return(0,o.shadow)(this,"loadingParams",{disableAutoFetch:S,enableXfa:L})}}let R=Symbol("INITIAL_DATA");class c{#t=Object.create(null);#e(S){return this.#t[S]||={...Promise.withResolvers(),data:R}}get(S,L=null){if(L){let U=this.#e(S);return U.promise.then((()=>L(U.data))),null}let $=this.#t[S];if(!$||$.data===R)throw new Error(`Requesting object that isn't resolved yet ${S}.`);return $.data}has(S){let L=this.#t[S];return!!L&&L.data!==R}resolve(S,L=null){let $=this.#e(S);$.data=L,$.resolve()}clear(){for(let S in this.#t){let{data:L}=this.#t[S];L?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(let S in this.#t){let{data:L}=this.#t[S];L!==R&&(yield[S,L])}}}class b{#t=null;constructor(S){this.#t=S,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(S=0){this.#t.cancel(null,S)}get separateAnnots(){let{separateAnnots:S}=this.#t.operatorList;if(!S)return!1;let{annotationCanvasMap:L}=this.#t;return S.form||S.canvas&&L?.size>0}}class C{static#t=new WeakSet;constructor({callback:S,params:L,objs:$,commonObjs:U,annotationCanvasMap:P,operatorList:F,pageIndex:V,canvasFactory:Q,filterFactory:Z,useRequestAnimationFrame:tt=!1,pdfBug:nt=!1,pageColors:pt=null}){this.callback=S,this.params=L,this.objs=$,this.commonObjs=U,this.annotationCanvasMap=P,this.operatorListIdx=null,this.operatorList=F,this._pageIndex=V,this.canvasFactory=Q,this.filterFactory=Z,this._pdfBug=nt,this.pageColors=pt,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=tt===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new b(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=L.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:S=!1,optionalContentConfig:L}){if(this.cancelled)return;if(this._canvas){if(C.#t.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.");C.#t.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:$,viewport:U,transform:P,background:F}=this.params;this.gfx=new p.CanvasGraphics($,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:L},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:P,viewport:U,transparency:S,background:F}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(S=null,L=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),C.#t.delete(this._canvas),this.callback(S||new u.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,L))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame((()=>{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(),C.#t.delete(this._canvas),this.callback())))}}let k="4.1.392",O="fcb76a78d";n()}catch(E){n(E)}}))},583:(s,t,e)=>{e.d(t,{BaseCMapReaderFactory:()=>h,BaseCanvasFactory:()=>o,BaseFilterFactory:()=>n,BaseSVGFactory:()=>g,BaseStandardFontDataFactory:()=>u});var i=e(292);class n{constructor(){this.constructor===n&&(0,i.unreachable)("Cannot initialize BaseFilterFactory.")}addFilter(p){return"none"}addHCMFilter(p,a){return"none"}addHighlightHCMFilter(p,a,f,A,_){return"none"}destroy(p=!1){}}class o{constructor(){this.constructor===o&&(0,i.unreachable)("Cannot initialize BaseCanvasFactory.")}create(p,a){if(p<=0||a<=0)throw new Error("Invalid canvas size");let f=this._createCanvas(p,a);return{canvas:f,context:f.getContext("2d")}}reset(p,a,f){if(!p.canvas)throw new Error("Canvas is not specified");if(a<=0||f<=0)throw new Error("Invalid canvas size");p.canvas.width=a,p.canvas.height=f}destroy(p){if(!p.canvas)throw new Error("Canvas is not specified");p.canvas.width=0,p.canvas.height=0,p.canvas=null,p.context=null}_createCanvas(p,a){(0,i.unreachable)("Abstract method `_createCanvas` called.")}}class h{constructor({baseUrl:p=null,isCompressed:a=!0}){this.constructor===h&&(0,i.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=p,this.isCompressed=a}async fetch({name:p}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!p)throw new Error("CMap name must be specified.");let a=this.baseUrl+p+(this.isCompressed?".bcmap":""),f=this.isCompressed?i.CMapCompressionType.BINARY:i.CMapCompressionType.NONE;return this._fetchData(a,f).catch((A=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${a}`)}))}_fetchData(p,a){(0,i.unreachable)("Abstract method `_fetchData` called.")}}class u{constructor({baseUrl:p=null}){this.constructor===u&&(0,i.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=p}async fetch({filename:p}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!p)throw new Error("Font filename must be specified.");let a=`${this.baseUrl}${p}`;return this._fetchData(a).catch((f=>{throw new Error(`Unable to load font data at: ${a}`)}))}_fetchData(p){(0,i.unreachable)("Abstract method `_fetchData` called.")}}class g{constructor(){this.constructor===g&&(0,i.unreachable)("Cannot initialize BaseSVGFactory.")}create(p,a,f=!1){if(p<=0||a<=0)throw new Error("Invalid SVG dimensions");let A=this._createSVG("svg:svg");return A.setAttribute("version","1.1"),f||(A.setAttribute("width",`${p}px`),A.setAttribute("height",`${a}px`)),A.setAttribute("preserveAspectRatio","none"),A.setAttribute("viewBox",`0 0 ${p} ${a}`),A}createElement(p){if(typeof p!="string")throw new Error("Invalid SVG element type");return this._createSVG(p)}_createSVG(p){(0,i.unreachable)("Abstract method `_createSVG` called.")}}},923:(s,t,e)=>{e.d(t,{CanvasGraphics:()=>st});var i=e(292),n=e(419);let o="Fill",h="Stroke",u="Shading";function g(W,w){if(!w)return;let T=w[2]-w[0],R=w[3]-w[1],c=new Path2D;c.rect(w[0],w[1],T,R),W.clip(c)}class v{constructor(){this.constructor===v&&(0,i.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,i.unreachable)("Abstract method `getPattern` called.")}}class p extends v{constructor(w){super(),this._type=w[1],this._bbox=w[2],this._colorStops=w[3],this._p0=w[4],this._p1=w[5],this._r0=w[6],this._r1=w[7],this.matrix=null}_createGradient(w){let T;this._type==="axial"?T=w.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(T=w.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let R of this._colorStops)T.addColorStop(R[0],R[1]);return T}getPattern(w,T,R,c){let b;if(c===h||c===o){let C=T.current.getClippedPathBoundingBox(c,(0,n.getCurrentTransform)(w))||[0,0,0,0],k=Math.ceil(C[2]-C[0])||1,O=Math.ceil(C[3]-C[1])||1,I=T.cachedCanvases.getCanvas("pattern",k,O,!0),S=I.context;S.clearRect(0,0,S.canvas.width,S.canvas.height),S.beginPath(),S.rect(0,0,S.canvas.width,S.canvas.height),S.translate(-C[0],-C[1]),R=i.Util.transform(R,[1,0,0,1,C[0],C[1]]),S.transform(...T.baseTransform),this.matrix&&S.transform(...this.matrix),g(S,this._bbox),S.fillStyle=this._createGradient(S),S.fill(),b=w.createPattern(I.canvas,"no-repeat");let L=new DOMMatrix(R);b.setTransform(L)}else g(w,this._bbox),b=this._createGradient(w);return b}}function a(W,w,T,R,c,b,C,k){let O=w.coords,I=w.colors,S=W.data,L=4*W.width,$;O[T+1]>O[R+1]&&($=T,T=R,R=$,$=b,b=C,C=$),O[R+1]>O[c+1]&&($=R,R=c,c=$,$=C,C=k,k=$),O[T+1]>O[R+1]&&($=T,T=R,R=$,$=b,b=C,C=$);let U=(O[T]+w.offsetX)*w.scaleX,P=(O[T+1]+w.offsetY)*w.scaleY,F=(O[R]+w.offsetX)*w.scaleX,V=(O[R+1]+w.offsetY)*w.scaleY,Q=(O[c]+w.offsetX)*w.scaleX,Z=(O[c+1]+w.offsetY)*w.scaleY;if(P>=Z)return;let tt=I[b],nt=I[b+1],pt=I[b+2],dt=I[C],lt=I[C+1],wt=I[C+2],Tt=I[k],xt=I[k+1],Dt=I[k+2],Mt=Math.round(P),Bt=Math.round(Z),Ht,le,Ae,Oe,ke,De,si,ni;for(let ae=Mt;ae<=Bt;ae++){if(ae<V){let te=ae<P?0:(P-ae)/(P-V);Ht=U-(U-F)*te,le=tt-(tt-dt)*te,Ae=nt-(nt-lt)*te,Oe=pt-(pt-wt)*te}else{let te;te=ae>Z?1:V===Z?0:(V-ae)/(V-Z),Ht=F-(F-Q)*te,le=dt-(dt-Tt)*te,Ae=lt-(lt-xt)*te,Oe=wt-(wt-Dt)*te}let ie;ie=ae<P?0:ae>Z?1:(P-ae)/(P-Z),ke=U-(U-Q)*ie,De=tt-(tt-Tt)*ie,si=nt-(nt-xt)*ie,ni=pt-(pt-Dt)*ie;let ri=Math.round(Math.min(Ht,ke)),Xi=Math.round(Math.max(Ht,ke)),Ie=L*ae+4*ri;for(let te=ri;te<=Xi;te++)ie=(Ht-te)/(Ht-ke),ie<0?ie=0:ie>1&&(ie=1),S[Ie++]=le-(le-De)*ie|0,S[Ie++]=Ae-(Ae-si)*ie|0,S[Ie++]=Oe-(Oe-ni)*ie|0,S[Ie++]=255}}function f(W,w,T){let R=w.coords,c=w.colors,b,C;switch(w.type){case"lattice":let k=w.verticesPerRow,O=Math.floor(R.length/k)-1,I=k-1;for(b=0;b<O;b++){let S=b*k;for(let L=0;L<I;L++,S++)a(W,T,R[S],R[S+1],R[S+k],c[S],c[S+1],c[S+k]),a(W,T,R[S+k+1],R[S+1],R[S+k],c[S+k+1],c[S+1],c[S+k])}break;case"triangles":for(b=0,C=R.length;b<C;b+=3)a(W,T,R[b],R[b+1],R[b+2],c[b],c[b+1],c[b+2]);break;default:throw new Error("illegal figure")}}class A extends v{constructor(w){super(),this._coords=w[2],this._colors=w[3],this._figures=w[4],this._bounds=w[5],this._bbox=w[7],this._background=w[8],this.matrix=null}_createMeshCanvas(w,T,R){let c=Math.floor(this._bounds[0]),b=Math.floor(this._bounds[1]),C=Math.ceil(this._bounds[2])-c,k=Math.ceil(this._bounds[3])-b,O=Math.min(Math.ceil(Math.abs(C*w[0]*1.1)),3e3),I=Math.min(Math.ceil(Math.abs(k*w[1]*1.1)),3e3),S=C/O,L=k/I,$={coords:this._coords,colors:this._colors,offsetX:-c,offsetY:-b,scaleX:1/S,scaleY:1/L},U=O+4,P=I+4,F=R.getCanvas("mesh",U,P,!1),V=F.context,Q=V.createImageData(O,I);if(T){let Z=Q.data;for(let tt=0,nt=Z.length;tt<nt;tt+=4)Z[tt]=T[0],Z[tt+1]=T[1],Z[tt+2]=T[2],Z[tt+3]=255}for(let Z of this._figures)f(Q,Z,$);return V.putImageData(Q,2,2),{canvas:F.canvas,offsetX:c-2*S,offsetY:b-2*L,scaleX:S,scaleY:L}}getPattern(w,T,R,c){g(w,this._bbox);let b;if(c===u)b=i.Util.singularValueDecompose2dScale((0,n.getCurrentTransform)(w));else if(b=i.Util.singularValueDecompose2dScale(T.baseTransform),this.matrix){let k=i.Util.singularValueDecompose2dScale(this.matrix);b=[b[0]*k[0],b[1]*k[1]]}let C=this._createMeshCanvas(b,c===u?null:this._background,T.cachedCanvases);return c!==u&&(w.setTransform(...T.baseTransform),this.matrix&&w.transform(...this.matrix)),w.translate(C.offsetX,C.offsetY),w.scale(C.scaleX,C.scaleY),w.createPattern(C.canvas,"no-repeat")}}class _ extends v{getPattern(){return"hotpink"}}let d=1,y=2;class r{static MAX_PATTERN_SIZE=3e3;constructor(w,T,R,c,b){this.operatorList=w[2],this.matrix=w[3]||[1,0,0,1,0,0],this.bbox=w[4],this.xstep=w[5],this.ystep=w[6],this.paintType=w[7],this.tilingType=w[8],this.color=T,this.ctx=R,this.canvasGraphicsFactory=c,this.baseTransform=b}createPatternCanvas(w){let T=this.operatorList,R=this.bbox,c=this.xstep,b=this.ystep,C=this.paintType,k=this.tilingType,O=this.color,I=this.canvasGraphicsFactory;(0,i.info)("TilingType: "+k);let S=R[0],L=R[1],$=R[2],U=R[3],P=i.Util.singularValueDecompose2dScale(this.matrix),F=i.Util.singularValueDecompose2dScale(this.baseTransform),V=[P[0]*F[0],P[1]*F[1]],Q=this.getSizeAndScale(c,this.ctx.canvas.width,V[0]),Z=this.getSizeAndScale(b,this.ctx.canvas.height,V[1]),tt=w.cachedCanvases.getCanvas("pattern",Q.size,Z.size,!0),nt=tt.context,pt=I.createCanvasGraphics(nt);pt.groupLevel=w.groupLevel,this.setFillAndStrokeStyleToContext(pt,C,O);let dt=S,lt=L,wt=$,Tt=U;return S<0&&(dt=0,wt+=Math.abs(S)),L<0&&(lt=0,Tt+=Math.abs(L)),nt.translate(-Q.scale*dt,-Z.scale*lt),pt.transform(Q.scale,0,0,Z.scale,0,0),nt.save(),this.clipBbox(pt,dt,lt,wt,Tt),pt.baseTransform=(0,n.getCurrentTransform)(pt.ctx),pt.executeOperatorList(T),pt.endDrawing(),{canvas:tt.canvas,scaleX:Q.scale,scaleY:Z.scale,offsetX:dt,offsetY:lt}}getSizeAndScale(w,T,R){w=Math.abs(w);let c=Math.max(r.MAX_PATTERN_SIZE,T),b=Math.ceil(w*R);return b>=c?b=c:R=b/w,{scale:R,size:b}}clipBbox(w,T,R,c,b){let C=c-T,k=b-R;w.ctx.rect(T,R,C,k),w.current.updateRectMinMax((0,n.getCurrentTransform)(w.ctx),[T,R,c,b]),w.clip(),w.endPath()}setFillAndStrokeStyleToContext(w,T,R){let c=w.ctx,b=w.current;switch(T){case d:let C=this.ctx;c.fillStyle=C.fillStyle,c.strokeStyle=C.strokeStyle,b.fillColor=C.fillStyle,b.strokeColor=C.strokeStyle;break;case y:let k=i.Util.makeHexColor(R[0],R[1],R[2]);c.fillStyle=k,c.strokeStyle=k,b.fillColor=k,b.strokeColor=k;break;default:throw new i.FormatError(`Unsupported paint type: ${T}`)}}getPattern(w,T,R,c){let b=R;c!==u&&(b=i.Util.transform(b,T.baseTransform),this.matrix&&(b=i.Util.transform(b,this.matrix)));let C=this.createPatternCanvas(T),k=new DOMMatrix(b);k=k.translate(C.offsetX,C.offsetY),k=k.scale(1/C.scaleX,1/C.scaleY);let O=w.createPattern(C.canvas,"repeat");return O.setTransform(k),O}}function l({src:W,srcPos:w=0,dest:T,width:R,height:c,nonBlackColor:b=4294967295,inverseDecode:C=!1}){let k=i.FeatureTest.isLittleEndian?4278190080:255,[O,I]=C?[b,k]:[k,b],S=R>>3,L=7&R,$=W.length;T=new Uint32Array(T.buffer);let U=0;for(let P=0;P<c;P++){for(let V=w+S;w<V;w++){let Q=w<$?W[w]:255;T[U++]=128&Q?I:O,T[U++]=64&Q?I:O,T[U++]=32&Q?I:O,T[U++]=16&Q?I:O,T[U++]=8&Q?I:O,T[U++]=4&Q?I:O,T[U++]=2&Q?I:O,T[U++]=1&Q?I:O}if(L===0)continue;let F=w<$?W[w++]:255;for(let V=0;V<L;V++)T[U++]=F&1<<7-V?I:O}return{srcPos:w,destPos:U}}let m=4096,x=16;class D{constructor(w){this.canvasFactory=w,this.cache=Object.create(null)}getCanvas(w,T,R){let c;return this.cache[w]!==void 0?(c=this.cache[w],this.canvasFactory.reset(c,T,R)):(c=this.canvasFactory.create(T,R),this.cache[w]=c),c}delete(w){delete this.cache[w]}clear(){for(let w in this.cache){let T=this.cache[w];this.canvasFactory.destroy(T),delete this.cache[w]}}}function E(W,w,T,R,c,b,C,k,O,I){let[S,L,$,U,P,F]=(0,n.getCurrentTransform)(W);if(L===0&&$===0){let V=C*S+P,Q=Math.round(V),Z=k*U+F,tt=Math.round(Z),nt=(C+O)*S+P,pt=Math.abs(Math.round(nt)-Q)||1,dt=(k+I)*U+F,lt=Math.abs(Math.round(dt)-tt)||1;return W.setTransform(Math.sign(S),0,0,Math.sign(U),Q,tt),W.drawImage(w,T,R,c,b,0,0,pt,lt),W.setTransform(S,L,$,U,P,F),[pt,lt]}if(S===0&&U===0){let V=k*$+P,Q=Math.round(V),Z=C*L+F,tt=Math.round(Z),nt=(k+I)*$+P,pt=Math.abs(Math.round(nt)-Q)||1,dt=(C+O)*L+F,lt=Math.abs(Math.round(dt)-tt)||1;return W.setTransform(0,Math.sign(L),Math.sign($),0,Q,tt),W.drawImage(w,T,R,c,b,0,0,lt,pt),W.setTransform(S,L,$,U,P,F),[lt,pt]}return W.drawImage(w,T,R,c,b,C,k,O,I),[Math.hypot(S,L)*O,Math.hypot($,U)*I]}class M{constructor(w,T){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=i.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=i.FONT_IDENTITY_MATRIX,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=i.TextRenderingMode.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,w,T])}clone(){let w=Object.create(this);return w.clipBox=this.clipBox.slice(),w}setCurrentPoint(w,T){this.x=w,this.y=T}updatePathMinMax(w,T,R){[T,R]=i.Util.applyTransform([T,R],w),this.minX=Math.min(this.minX,T),this.minY=Math.min(this.minY,R),this.maxX=Math.max(this.maxX,T),this.maxY=Math.max(this.maxY,R)}updateRectMinMax(w,T){let R=i.Util.applyTransform(T,w),c=i.Util.applyTransform(T.slice(2),w),b=i.Util.applyTransform([T[0],T[3]],w),C=i.Util.applyTransform([T[2],T[1]],w);this.minX=Math.min(this.minX,R[0],c[0],b[0],C[0]),this.minY=Math.min(this.minY,R[1],c[1],b[1],C[1]),this.maxX=Math.max(this.maxX,R[0],c[0],b[0],C[0]),this.maxY=Math.max(this.maxY,R[1],c[1],b[1],C[1])}updateScalingPathMinMax(w,T){i.Util.scaleMinMax(w,T),this.minX=Math.min(this.minX,T[0]),this.minY=Math.min(this.minY,T[1]),this.maxX=Math.max(this.maxX,T[2]),this.maxY=Math.max(this.maxY,T[3])}updateCurvePathMinMax(w,T,R,c,b,C,k,O,I,S){let L=i.Util.bezierBoundingBox(T,R,c,b,C,k,O,I,S);S||this.updateRectMinMax(w,L)}getPathBoundingBox(w=o,T=null){let R=[this.minX,this.minY,this.maxX,this.maxY];if(w===h){T||(0,i.unreachable)("Stroke bounding box must include transform.");let c=i.Util.singularValueDecompose2dScale(T),b=c[0]*this.lineWidth/2,C=c[1]*this.lineWidth/2;R[0]-=b,R[1]-=C,R[2]+=b,R[3]+=C}return R}updateClipFromPath(){let w=i.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(w||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(w){this.clipBox=w,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(w=o,T=null){return i.Util.intersect(this.clipBox,this.getPathBoundingBox(w,T))}}function N(W,w){if(typeof ImageData<"u"&&w instanceof ImageData){W.putImageData(w,0,0);return}let T=w.height,R=w.width,c=T%x,b=(T-c)/x,C=c===0?b:b+1,k=W.createImageData(R,x),O,I=0,S=w.data,L=k.data,$,U,P,F;if(w.kind===i.ImageKind.GRAYSCALE_1BPP){let V=S.byteLength,Q=new Uint32Array(L.buffer,0,L.byteLength>>2),Z=Q.length,tt=R+7>>3,nt=4294967295,pt=i.FeatureTest.isLittleEndian?4278190080:255;for($=0;$<C;$++){for(P=$<b?x:c,O=0,U=0;U<P;U++){let dt=V-I,lt=0,wt=dt>tt?R:8*dt-7,Tt=-8&wt,xt=0,Dt=0;for(;lt<Tt;lt+=8)Dt=S[I++],Q[O++]=128&Dt?nt:pt,Q[O++]=64&Dt?nt:pt,Q[O++]=32&Dt?nt:pt,Q[O++]=16&Dt?nt:pt,Q[O++]=8&Dt?nt:pt,Q[O++]=4&Dt?nt:pt,Q[O++]=2&Dt?nt:pt,Q[O++]=1&Dt?nt:pt;for(;lt<wt;lt++)xt===0&&(Dt=S[I++],xt=128),Q[O++]=Dt&xt?nt:pt,xt>>=1}for(;O<Z;)Q[O++]=0;W.putImageData(k,0,$*x)}}else if(w.kind===i.ImageKind.RGBA_32BPP){for(U=0,F=R*x*4,$=0;$<b;$++)L.set(S.subarray(I,I+F)),I+=F,W.putImageData(k,0,U),U+=x;$<C&&(F=R*c*4,L.set(S.subarray(I,I+F)),W.putImageData(k,0,U))}else{if(w.kind!==i.ImageKind.RGB_24BPP)throw new Error(`bad image kind: ${w.kind}`);for(P=x,F=R*P,$=0;$<C;$++){for($>=b&&(P=c,F=R*P),O=0,U=F;U--;)L[O++]=S[I++],L[O++]=S[I++],L[O++]=S[I++],L[O++]=255;W.putImageData(k,0,$*x)}}}function H(W,w){if(w.bitmap){W.drawImage(w.bitmap,0,0);return}let T=w.height,R=w.width,c=T%x,b=(T-c)/x,C=c===0?b:b+1,k=W.createImageData(R,x),O=0,I=w.data,S=k.data;for(let L=0;L<C;L++){let $=L<b?x:c;({srcPos:O}=l({src:I,srcPos:O,dest:S,width:R,height:$,nonBlackColor:0})),W.putImageData(k,0,L*x)}}function z(W,w){let T=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let R of T)W[R]!==void 0&&(w[R]=W[R]);W.setLineDash!==void 0&&(w.setLineDash(W.getLineDash()),w.lineDashOffset=W.lineDashOffset)}function K(W){if(W.strokeStyle=W.fillStyle="#000000",W.fillRule="nonzero",W.globalAlpha=1,W.lineWidth=1,W.lineCap="butt",W.lineJoin="miter",W.miterLimit=10,W.globalCompositeOperation="source-over",W.font="10px sans-serif",W.setLineDash!==void 0&&(W.setLineDash([]),W.lineDashOffset=0),!i.isNodeJS){let{filter:w}=W;w!=="none"&&w!==""&&(W.filter="none")}}function it(W,w,T,R){let c=W.length;for(let b=3;b<c;b+=4){let C=W[b];if(C===0)W[b-3]=w,W[b-2]=T,W[b-1]=R;else if(C<255){let k=255-C;W[b-3]=W[b-3]*C+w*k>>8,W[b-2]=W[b-2]*C+T*k>>8,W[b-1]=W[b-1]*C+R*k>>8}}}function ot(W,w,T){let R=W.length;for(let c=3;c<R;c+=4){let b=T?T[W[c]]:W[c];w[c]=w[c]*b*.00392156862745098|0}}function X(W,w,T){let R=W.length;for(let c=3;c<R;c+=4){let b=77*W[c-3]+152*W[c-2]+28*W[c-1];w[c]=T?w[c]*T[b>>8]>>8:w[c]*b>>16}}function j(W,w,T,R){let c=R[0],b=R[1],C=R[2]-c,k=R[3]-b;C!==0&&k!==0&&((function(I,S,L,$,U,P,F,V,Q,Z,tt){let nt=!!P,pt=nt?P[0]:0,dt=nt?P[1]:0,lt=nt?P[2]:0,wt=U==="Luminosity"?X:ot,Tt=Math.min($,Math.ceil(1048576/L));for(let xt=0;xt<$;xt+=Tt){let Dt=Math.min(Tt,$-xt),Mt=I.getImageData(V-Z,xt+(Q-tt),L,Dt),Bt=S.getImageData(V,xt+Q,L,Dt);nt&&it(Mt.data,pt,dt,lt),wt(Mt.data,Bt.data,F),S.putImageData(Bt,V,xt+Q)}})(w.context,T,C,k,w.subtype,w.backdrop,w.transferMap,c,b,w.offsetX,w.offsetY),W.save(),W.globalAlpha=1,W.globalCompositeOperation="source-over",W.setTransform(1,0,0,1,0,0),W.drawImage(T.canvas,0,0),W.restore())}function G(W,w){let T=i.Util.singularValueDecompose2dScale(W);T[0]=Math.fround(T[0]),T[1]=Math.fround(T[1]);let R=Math.fround((globalThis.devicePixelRatio||1)*n.PixelsPerInch.PDF_TO_CSS_UNITS);return w!==void 0?w:T[0]<=R||T[1]<=R}let Y=["butt","round","square"],et=["miter","round","bevel"],rt={},ct={};class st{constructor(w,T,R,c,b,{optionalContentConfig:C,markedContentStack:k=null},O,I){this.ctx=w,this.current=new M(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=T,this.objs=R,this.canvasFactory=c,this.filterFactory=b,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=k||[],this.optionalContentConfig=C,this.cachedCanvases=new D(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=O,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=I,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(w,T=null){return typeof w=="string"?w.startsWith("g_")?this.commonObjs.get(w):this.objs.get(w):T}beginDrawing({transform:w,viewport:T,transparency:R=!1,background:c=null}){let b=this.ctx.canvas.width,C=this.ctx.canvas.height,k=this.ctx.fillStyle;if(this.ctx.fillStyle=c||"#ffffff",this.ctx.fillRect(0,0,b,C),this.ctx.fillStyle=k,R){let O=this.cachedCanvases.getCanvas("transparent",b,C);this.compositeCtx=this.ctx,this.transparentCanvas=O.canvas,this.ctx=O.context,this.ctx.save(),this.ctx.transform(...(0,n.getCurrentTransform)(this.compositeCtx))}this.ctx.save(),K(this.ctx),w&&(this.ctx.transform(...w),this.outputScaleX=w[0],this.outputScaleY=w[0]),this.ctx.transform(...T.transform),this.viewportScale=T.scale,this.baseTransform=(0,n.getCurrentTransform)(this.ctx)}executeOperatorList(w,T,R,c){let b=w.argsArray,C=w.fnArray,k=T||0,O=b.length;if(O===k)return k;let I=O-k>10&&typeof R=="function",S=I?Date.now()+15:0,L=0,$=this.commonObjs,U=this.objs,P;for(;;){if(c!==void 0&&k===c.nextBreakPoint)return c.breakIt(k,R),k;if(P=C[k],P!==i.OPS.dependency)this[P].apply(this,b[k]);else for(let F of b[k]){let V=F.startsWith("g_")?$:U;if(!V.has(F))return V.get(F,R),k}if(k++,k===O)return k;if(I&&++L>10){if(Date.now()>S)return R(),k;L=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let w of this._cachedBitmapsMap.values()){for(let T of w.values())typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement&&(T.width=T.height=0);w.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){let w=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(w!=="none"){let T=this.ctx.filter;this.ctx.filter=w,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=T}}}_scaleImage(w,T){let R=w.width,c=w.height,b,C,k=Math.max(Math.hypot(T[0],T[1]),1),O=Math.max(Math.hypot(T[2],T[3]),1),I=R,S=c,L="prescale1";for(;k>2&&I>1||O>2&&S>1;){let $=I,U=S;k>2&&I>1&&($=I>=16384?Math.floor(I/2)-1||1:Math.ceil(I/2),k/=I/$),O>2&&S>1&&(U=S>=16384?Math.floor(S/2)-1||1:Math.ceil(S)/2,O/=S/U),b=this.cachedCanvases.getCanvas(L,$,U),C=b.context,C.clearRect(0,0,$,U),C.drawImage(w,0,0,I,S,0,0,$,U),w=b.canvas,I=$,S=U,L=L==="prescale1"?"prescale2":"prescale1"}return{img:w,paintWidth:I,paintHeight:S}}_createMaskCanvas(w){let T=this.ctx,{width:R,height:c}=w,b=this.current.fillColor,C=this.current.patternFill,k=(0,n.getCurrentTransform)(T),O,I,S,L;if((w.bitmap||w.data)&&w.count>1){let wt=w.bitmap||w.data.buffer;I=JSON.stringify(C?k:[k.slice(0,4),b]),O=this._cachedBitmapsMap.get(wt),O||(O=new Map,this._cachedBitmapsMap.set(wt,O));let Tt=O.get(I);if(Tt&&!C)return{canvas:Tt,offsetX:Math.round(Math.min(k[0],k[2])+k[4]),offsetY:Math.round(Math.min(k[1],k[3])+k[5])};S=Tt}S||(L=this.cachedCanvases.getCanvas("maskCanvas",R,c),H(L.context,w));let $=i.Util.transform(k,[1/R,0,0,-1/c,0,0]);$=i.Util.transform($,[1,0,0,1,0,-c]);let[U,P,F,V]=i.Util.getAxialAlignedBoundingBox([0,0,R,c],$),Q=Math.round(F-U)||1,Z=Math.round(V-P)||1,tt=this.cachedCanvases.getCanvas("fillCanvas",Q,Z),nt=tt.context,pt=U,dt=P;nt.translate(-pt,-dt),nt.transform(...$),S||(S=this._scaleImage(L.canvas,(0,n.getCurrentTransformInverse)(nt)),S=S.img,O&&C&&O.set(I,S)),nt.imageSmoothingEnabled=G((0,n.getCurrentTransform)(nt),w.interpolate),E(nt,S,0,0,S.width,S.height,0,0,R,c),nt.globalCompositeOperation="source-in";let lt=i.Util.transform((0,n.getCurrentTransformInverse)(nt),[1,0,0,1,-pt,-dt]);return nt.fillStyle=C?b.getPattern(T,this,lt,o):b,nt.fillRect(0,0,R,c),O&&!C&&(this.cachedCanvases.delete("fillCanvas"),O.set(I,tt.canvas)),{canvas:tt.canvas,offsetX:Math.round(pt),offsetY:Math.round(dt)}}setLineWidth(w){w!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=w,this.ctx.lineWidth=w}setLineCap(w){this.ctx.lineCap=Y[w]}setLineJoin(w){this.ctx.lineJoin=et[w]}setMiterLimit(w){this.ctx.miterLimit=w}setDash(w,T){let R=this.ctx;R.setLineDash!==void 0&&(R.setLineDash(w),R.lineDashOffset=T)}setRenderingIntent(w){}setFlatness(w){}setGState(w){for(let[T,R]of w)switch(T){case"LW":this.setLineWidth(R);break;case"LC":this.setLineCap(R);break;case"LJ":this.setLineJoin(R);break;case"ML":this.setMiterLimit(R);break;case"D":this.setDash(R[0],R[1]);break;case"RI":this.setRenderingIntent(R);break;case"FL":this.setFlatness(R);break;case"Font":this.setFont(R[0],R[1]);break;case"CA":this.current.strokeAlpha=R;break;case"ca":this.current.fillAlpha=R,this.ctx.globalAlpha=R;break;case"BM":this.ctx.globalCompositeOperation=R;break;case"SMask":this.current.activeSMask=R?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(R)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let w=this.inSMaskMode;this.current.activeSMask&&!w?this.beginSMaskMode():!this.current.activeSMask&&w&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");let w=this.ctx.canvas.width,T=this.ctx.canvas.height,R="smaskGroupAt"+this.groupLevel,c=this.cachedCanvases.getCanvas(R,w,T);this.suspendedCtx=this.ctx,this.ctx=c.context;let b=this.ctx;b.setTransform(...(0,n.getCurrentTransform)(this.suspendedCtx)),z(this.suspendedCtx,b),(function(k,O){if(k._removeMirroring)throw new Error("Context is already forwarding operations.");k.__originalSave=k.save,k.__originalRestore=k.restore,k.__originalRotate=k.rotate,k.__originalScale=k.scale,k.__originalTranslate=k.translate,k.__originalTransform=k.transform,k.__originalSetTransform=k.setTransform,k.__originalResetTransform=k.resetTransform,k.__originalClip=k.clip,k.__originalMoveTo=k.moveTo,k.__originalLineTo=k.lineTo,k.__originalBezierCurveTo=k.bezierCurveTo,k.__originalRect=k.rect,k.__originalClosePath=k.closePath,k.__originalBeginPath=k.beginPath,k._removeMirroring=()=>{k.save=k.__originalSave,k.restore=k.__originalRestore,k.rotate=k.__originalRotate,k.scale=k.__originalScale,k.translate=k.__originalTranslate,k.transform=k.__originalTransform,k.setTransform=k.__originalSetTransform,k.resetTransform=k.__originalResetTransform,k.clip=k.__originalClip,k.moveTo=k.__originalMoveTo,k.lineTo=k.__originalLineTo,k.bezierCurveTo=k.__originalBezierCurveTo,k.rect=k.__originalRect,k.closePath=k.__originalClosePath,k.beginPath=k.__originalBeginPath,delete k._removeMirroring},k.save=function(){O.save(),this.__originalSave()},k.restore=function(){O.restore(),this.__originalRestore()},k.translate=function(S,L){O.translate(S,L),this.__originalTranslate(S,L)},k.scale=function(S,L){O.scale(S,L),this.__originalScale(S,L)},k.transform=function(S,L,$,U,P,F){O.transform(S,L,$,U,P,F),this.__originalTransform(S,L,$,U,P,F)},k.setTransform=function(S,L,$,U,P,F){O.setTransform(S,L,$,U,P,F),this.__originalSetTransform(S,L,$,U,P,F)},k.resetTransform=function(){O.resetTransform(),this.__originalResetTransform()},k.rotate=function(S){O.rotate(S),this.__originalRotate(S)},k.clip=function(S){O.clip(S),this.__originalClip(S)},k.moveTo=function(I,S){O.moveTo(I,S),this.__originalMoveTo(I,S)},k.lineTo=function(I,S){O.lineTo(I,S),this.__originalLineTo(I,S)},k.bezierCurveTo=function(I,S,L,$,U,P){O.bezierCurveTo(I,S,L,$,U,P),this.__originalBezierCurveTo(I,S,L,$,U,P)},k.rect=function(I,S,L,$){O.rect(I,S,L,$),this.__originalRect(I,S,L,$)},k.closePath=function(){O.closePath(),this.__originalClosePath()},k.beginPath=function(){O.beginPath(),this.__originalBeginPath()}})(b,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(),z(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(w){if(!this.current.activeSMask)return;w?(w[0]=Math.floor(w[0]),w[1]=Math.floor(w[1]),w[2]=Math.ceil(w[2]),w[3]=Math.ceil(w[3])):w=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let T=this.current.activeSMask;j(this.suspendedCtx,T,this.ctx,w),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()}save(){this.inSMaskMode?(z(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let w=this.current;this.stateStack.push(w),this.current=w.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),z(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(w,T,R,c,b,C){this.ctx.transform(w,T,R,c,b,C),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(w,T,R){let c=this.ctx,b=this.current,C,k,O=b.x,I=b.y,S=(0,n.getCurrentTransform)(c),L=S[0]===0&&S[3]===0||S[1]===0&&S[2]===0,$=L?R.slice(0):null;for(let U=0,P=0,F=w.length;U<F;U++)switch(0|w[U]){case i.OPS.rectangle:O=T[P++],I=T[P++];let V=T[P++],Q=T[P++],Z=O+V,tt=I+Q;c.moveTo(O,I),V===0||Q===0?c.lineTo(Z,tt):(c.lineTo(Z,I),c.lineTo(Z,tt),c.lineTo(O,tt)),L||b.updateRectMinMax(S,[O,I,Z,tt]),c.closePath();break;case i.OPS.moveTo:O=T[P++],I=T[P++],c.moveTo(O,I),L||b.updatePathMinMax(S,O,I);break;case i.OPS.lineTo:O=T[P++],I=T[P++],c.lineTo(O,I),L||b.updatePathMinMax(S,O,I);break;case i.OPS.curveTo:C=O,k=I,O=T[P+4],I=T[P+5],c.bezierCurveTo(T[P],T[P+1],T[P+2],T[P+3],O,I),b.updateCurvePathMinMax(S,C,k,T[P],T[P+1],T[P+2],T[P+3],O,I,$),P+=6;break;case i.OPS.curveTo2:C=O,k=I,c.bezierCurveTo(O,I,T[P],T[P+1],T[P+2],T[P+3]),b.updateCurvePathMinMax(S,C,k,O,I,T[P],T[P+1],T[P+2],T[P+3],$),O=T[P+2],I=T[P+3],P+=4;break;case i.OPS.curveTo3:C=O,k=I,O=T[P+2],I=T[P+3],c.bezierCurveTo(T[P],T[P+1],O,I,O,I),b.updateCurvePathMinMax(S,C,k,T[P],T[P+1],O,I,O,I,$),P+=4;break;case i.OPS.closePath:c.closePath()}L&&b.updateScalingPathMinMax(S,$),b.setCurrentPoint(O,I)}closePath(){this.ctx.closePath()}stroke(w=!0){let T=this.ctx,R=this.current.strokeColor;T.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof R=="object"&&R?.getPattern?(T.save(),T.strokeStyle=R.getPattern(T,this,(0,n.getCurrentTransformInverse)(T),h),this.rescaleAndStroke(!1),T.restore()):this.rescaleAndStroke(!0)),w&&this.consumePath(this.current.getClippedPathBoundingBox()),T.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(w=!0){let T=this.ctx,R=this.current.fillColor,c=!1;this.current.patternFill&&(T.save(),T.fillStyle=R.getPattern(T,this,(0,n.getCurrentTransformInverse)(T),o),c=!0);let b=this.current.getClippedPathBoundingBox();this.contentVisible&&b!==null&&(this.pendingEOFill?(T.fill("evenodd"),this.pendingEOFill=!1):T.fill()),c&&T.restore(),w&&this.consumePath(b)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=rt}eoClip(){this.pendingClip=ct}beginText(){this.current.textMatrix=i.IDENTITY_MATRIX,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let w=this.pendingTextPaths,T=this.ctx;if(w!==void 0){T.save(),T.beginPath();for(let R of w)T.setTransform(...R.transform),T.translate(R.x,R.y),R.addToPath(T,R.fontSize);T.restore(),T.clip(),T.beginPath(),delete this.pendingTextPaths}else T.beginPath()}setCharSpacing(w){this.current.charSpacing=w}setWordSpacing(w){this.current.wordSpacing=w}setHScale(w){this.current.textHScale=w/100}setLeading(w){this.current.leading=-w}setFont(w,T){let R=this.commonObjs.get(w),c=this.current;if(!R)throw new Error(`Can't find font for ${w}`);if(c.fontMatrix=R.fontMatrix||i.FONT_IDENTITY_MATRIX,c.fontMatrix[0]!==0&&c.fontMatrix[3]!==0||(0,i.warn)("Invalid font matrix for font "+w),T<0?(T=-T,c.fontDirection=-1):c.fontDirection=1,this.current.font=R,this.current.fontSize=T,R.isType3Font)return;let b=R.loadedName||"sans-serif",C=R.systemFontInfo?.css||`"${b}", ${R.fallbackName}`,k="normal";R.black?k="900":R.bold&&(k="bold");let O=R.italic?"italic":"normal",I=T;T<16?I=16:T>100&&(I=100),this.current.fontSizeScale=T/I,this.ctx.font=`${O} ${k} ${I}px ${C}`}setTextRenderingMode(w){this.current.textRenderingMode=w}setTextRise(w){this.current.textRise=w}moveText(w,T){this.current.x=this.current.lineX+=w,this.current.y=this.current.lineY+=T}setLeadingMoveText(w,T){this.setLeading(-T),this.moveText(w,T)}setTextMatrix(w,T,R,c,b,C){this.current.textMatrix=[w,T,R,c,b,C],this.current.textMatrixScale=Math.hypot(w,T),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(w,T,R,c){let b=this.ctx,C=this.current,k=C.font,O=C.textRenderingMode,I=C.fontSize/C.fontSizeScale,S=O&i.TextRenderingMode.FILL_STROKE_MASK,L=!!(O&i.TextRenderingMode.ADD_TO_PATH_FLAG),$=C.patternFill&&!k.missingFile,U;(k.disableFontFace||L||$)&&(U=k.getPathGenerator(this.commonObjs,w)),k.disableFontFace||$?(b.save(),b.translate(T,R),b.beginPath(),U(b,I),c&&b.setTransform(...c),S!==i.TextRenderingMode.FILL&&S!==i.TextRenderingMode.FILL_STROKE||b.fill(),S!==i.TextRenderingMode.STROKE&&S!==i.TextRenderingMode.FILL_STROKE||b.stroke(),b.restore()):(S!==i.TextRenderingMode.FILL&&S!==i.TextRenderingMode.FILL_STROKE||b.fillText(w,T,R),S!==i.TextRenderingMode.STROKE&&S!==i.TextRenderingMode.FILL_STROKE||b.strokeText(w,T,R)),L&&(this.pendingTextPaths||=[]).push({transform:(0,n.getCurrentTransform)(b),x:T,y:R,fontSize:I,addToPath:U})}get isFontSubpixelAAEnabled(){let{context:w}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);w.scale(1.5,1),w.fillText("I",0,10);let T=w.getImageData(0,0,10,10).data,R=!1;for(let c=3;c<T.length;c+=4)if(T[c]>0&&T[c]<255){R=!0;break}return(0,i.shadow)(this,"isFontSubpixelAAEnabled",R)}showText(w){let T=this.current,R=T.font;if(R.isType3Font)return this.showType3Text(w);let c=T.fontSize;if(c===0)return;let b=this.ctx,C=T.fontSizeScale,k=T.charSpacing,O=T.wordSpacing,I=T.fontDirection,S=T.textHScale*I,L=w.length,$=R.vertical,U=$?1:-1,P=R.defaultVMetrics,F=c*T.fontMatrix[0],V=T.textRenderingMode===i.TextRenderingMode.FILL&&!R.disableFontFace&&!T.patternFill;b.save(),b.transform(...T.textMatrix),b.translate(T.x,T.y+T.textRise),I>0?b.scale(S,-1):b.scale(S,1);let Q;if(T.patternFill){b.save();let dt=T.fillColor.getPattern(b,this,(0,n.getCurrentTransformInverse)(b),o);Q=(0,n.getCurrentTransform)(b),b.restore(),b.fillStyle=dt}let Z=T.lineWidth,tt=T.textMatrixScale;if(tt===0||Z===0){let dt=T.textRenderingMode&i.TextRenderingMode.FILL_STROKE_MASK;dt!==i.TextRenderingMode.STROKE&&dt!==i.TextRenderingMode.FILL_STROKE||(Z=this.getSinglePixelWidth())}else Z/=tt;if(C!==1&&(b.scale(C,C),Z/=C),b.lineWidth=Z,R.isInvalidPDFjsFont){let dt=[],lt=0;for(let wt of w)dt.push(wt.unicode),lt+=wt.width;b.fillText(dt.join(""),0,0),T.x+=lt*F*S,b.restore(),this.compose();return}let nt,pt=0;for(nt=0;nt<L;++nt){let dt=w[nt];if(typeof dt=="number"){pt+=U*dt*c/1e3;continue}let lt=!1,wt=(dt.isSpace?O:0)+k,Tt=dt.fontChar,xt=dt.accent,Dt,Mt,Bt=dt.width;if($){let Ht=dt.vmetric||P,le=-(dt.vmetric?Ht[1]:.5*Bt)*F,Ae=Ht[2]*F;Bt=Ht?-Ht[0]:Bt,Dt=le/C,Mt=(pt+Ae)/C}else Dt=pt/C,Mt=0;if(R.remeasure&&Bt>0){let Ht=1e3*b.measureText(Tt).width/c*C;if(Bt<Ht&&this.isFontSubpixelAAEnabled){let le=Bt/Ht;lt=!0,b.save(),b.scale(le,1),Dt/=le}else Bt!==Ht&&(Dt+=(Bt-Ht)/2e3*c/C)}if(this.contentVisible&&(dt.isInFont||R.missingFile)){if(V&&!xt)b.fillText(Tt,Dt,Mt);else if(this.paintChar(Tt,Dt,Mt,Q),xt){let Ht=Dt+c*xt.offset.x/C,le=Mt-c*xt.offset.y/C;this.paintChar(xt.fontChar,Ht,le,Q)}}pt+=$?Bt*F-wt*I:Bt*F+wt*I,lt&&b.restore()}$?T.y-=pt:T.x+=pt*S,b.restore(),this.compose()}showType3Text(w){let T=this.ctx,R=this.current,c=R.font,b=R.fontSize,C=R.fontDirection,k=c.vertical?1:-1,O=R.charSpacing,I=R.wordSpacing,S=R.textHScale*C,L=R.fontMatrix||i.FONT_IDENTITY_MATRIX,$=w.length,U,P,F,V;if(R.textRenderingMode!==i.TextRenderingMode.INVISIBLE&&b!==0){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,T.save(),T.transform(...R.textMatrix),T.translate(R.x,R.y),T.scale(S,C),U=0;U<$;++U){if(P=w[U],typeof P=="number"){V=k*P*b/1e3,this.ctx.translate(V,0),R.x+=V*S;continue}let Q=(P.isSpace?I:0)+O,Z=c.charProcOperatorList[P.operatorListId];if(!Z){(0,i.warn)(`Type3 character "${P.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=P,this.save(),T.scale(b,b),T.transform(...L),this.executeOperatorList(Z),this.restore()),F=i.Util.applyTransform([P.width,0],L)[0]*b+Q,T.translate(F,0),R.x+=F*S}T.restore(),this.processingType3=null}}setCharWidth(w,T){}setCharWidthAndBounds(w,T,R,c,b,C){this.ctx.rect(R,c,b-R,C-c),this.ctx.clip(),this.endPath()}getColorN_Pattern(w){let T;if(w[0]==="TilingPattern"){let R=w[1],c=this.baseTransform||(0,n.getCurrentTransform)(this.ctx),b={createCanvasGraphics:C=>new st(C,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};T=new r(w,R,this.ctx,b,c)}else T=this._getPattern(w[1],w[2]);return T}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(w,T,R){let c=i.Util.makeHexColor(w,T,R);this.ctx.strokeStyle=c,this.current.strokeColor=c}setFillRGBColor(w,T,R){let c=i.Util.makeHexColor(w,T,R);this.ctx.fillStyle=c,this.current.fillColor=c,this.current.patternFill=!1}_getPattern(w,T=null){let R;return this.cachedPatterns.has(w)?R=this.cachedPatterns.get(w):(R=(function(b){switch(b[0]){case"RadialAxial":return new p(b);case"Mesh":return new A(b);case"Dummy":return new _}throw new Error(`Unknown IR type: ${b[0]}`)})(this.getObject(w)),this.cachedPatterns.set(w,R)),T&&(R.matrix=T),R}shadingFill(w){if(!this.contentVisible)return;let T=this.ctx;this.save();let R=this._getPattern(w);T.fillStyle=R.getPattern(T,this,(0,n.getCurrentTransformInverse)(T),u);let c=(0,n.getCurrentTransformInverse)(T);if(c){let{width:b,height:C}=T.canvas,[k,O,I,S]=i.Util.getAxialAlignedBoundingBox([0,0,b,C],c);this.ctx.fillRect(k,O,I-k,S-O)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,i.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,i.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(w,T){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(w)&&w.length===6&&this.transform(...w),this.baseTransform=(0,n.getCurrentTransform)(this.ctx),T)){let R=T[2]-T[0],c=T[3]-T[1];this.ctx.rect(T[0],T[1],R,c),this.current.updateRectMinMax((0,n.getCurrentTransform)(this.ctx),T),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(w){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let T=this.ctx;w.isolated||(0,i.info)("TODO: Support non-isolated groups."),w.knockout&&(0,i.warn)("Knockout groups not supported.");let R=(0,n.getCurrentTransform)(T);if(w.matrix&&T.transform(...w.matrix),!w.bbox)throw new Error("Bounding box is required.");let c=i.Util.getAxialAlignedBoundingBox(w.bbox,(0,n.getCurrentTransform)(T)),b=[0,0,T.canvas.width,T.canvas.height];c=i.Util.intersect(c,b)||[0,0,0,0];let C=Math.floor(c[0]),k=Math.floor(c[1]),O=Math.max(Math.ceil(c[2])-C,1),I=Math.max(Math.ceil(c[3])-k,1),S=1,L=1;O>m&&(S=O/m,O=m),I>m&&(L=I/m,I=m),this.current.startNewPathAndClipBox([0,0,O,I]);let $="groupAt"+this.groupLevel;w.smask&&($+="_smask_"+this.smaskCounter++%2);let U=this.cachedCanvases.getCanvas($,O,I),P=U.context;P.scale(1/S,1/L),P.translate(-C,-k),P.transform(...R),w.smask?this.smaskStack.push({canvas:U.canvas,context:P,offsetX:C,offsetY:k,scaleX:S,scaleY:L,subtype:w.smask.subtype,backdrop:w.smask.backdrop,transferMap:w.smask.transferMap||null,startTransformInverse:null}):(T.setTransform(1,0,0,1,0,0),T.translate(C,k),T.scale(S,L),T.save()),z(T,P),this.ctx=P,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(T),this.groupLevel++}endGroup(w){if(!this.contentVisible)return;this.groupLevel--;let T=this.ctx,R=this.groupStack.pop();if(this.ctx=R,this.ctx.imageSmoothingEnabled=!1,w.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let c=(0,n.getCurrentTransform)(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...c);let b=i.Util.getAxialAlignedBoundingBox([0,0,T.canvas.width,T.canvas.height],c);this.ctx.drawImage(T.canvas,0,0),this.ctx.restore(),this.compose(b)}}beginAnnotation(w,T,R,c,b){if(this.#t(),K(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),Array.isArray(T)&&T.length===4){let C=T[2]-T[0],k=T[3]-T[1];if(b&&this.annotationCanvasMap){(R=R.slice())[4]-=T[0],R[5]-=T[1],(T=T.slice())[0]=T[1]=0,T[2]=C,T[3]=k;let[O,I]=i.Util.singularValueDecompose2dScale((0,n.getCurrentTransform)(this.ctx)),{viewportScale:S}=this,L=Math.ceil(C*this.outputScaleX*S),$=Math.ceil(k*this.outputScaleY*S);this.annotationCanvas=this.canvasFactory.create(L,$);let{canvas:U,context:P}=this.annotationCanvas;this.annotationCanvasMap.set(w,U),this.annotationCanvas.savedCtx=this.ctx,this.ctx=P,this.ctx.save(),this.ctx.setTransform(O,0,0,-I,0,k*I),K(this.ctx)}else K(this.ctx),this.ctx.rect(T[0],T[1],C,k),this.ctx.clip(),this.endPath()}this.current=new M(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...R),this.transform(...c)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(w){if(!this.contentVisible)return;let T=w.count;(w=this.getObject(w.data,w)).count=T;let R=this.ctx,c=this.processingType3;if(c&&(c.compiled===void 0&&(c.compiled=(function(O){let{width:I,height:S}=O;if(I>1e3||S>1e3)return null;let L=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),$=I+1,U,P,F,V=new Uint8Array($*(S+1)),Q=I+7&-8,Z=new Uint8Array(Q*S),tt=0;for(let lt of O.data){let wt=128;for(;wt>0;)Z[tt++]=lt&wt?0:255,wt>>=1}let nt=0;for(tt=0,Z[tt]!==0&&(V[0]=1,++nt),P=1;P<I;P++)Z[tt]!==Z[tt+1]&&(V[P]=Z[tt]?2:1,++nt),tt++;for(Z[tt]!==0&&(V[P]=2,++nt),U=1;U<S;U++){tt=U*Q,F=U*$,Z[tt-Q]!==Z[tt]&&(V[F]=Z[tt]?1:8,++nt);let lt=(Z[tt]?4:0)+(Z[tt-Q]?8:0);for(P=1;P<I;P++)lt=(lt>>2)+(Z[tt+1]?4:0)+(Z[tt-Q+1]?8:0),L[lt]&&(V[F+P]=L[lt],++nt),tt++;if(Z[tt-Q]!==Z[tt]&&(V[F+P]=Z[tt]?2:4,++nt),nt>1e3)return null}for(tt=Q*(S-1),F=U*$,Z[tt]!==0&&(V[F]=8,++nt),P=1;P<I;P++)Z[tt]!==Z[tt+1]&&(V[F+P]=Z[tt]?4:8,++nt),tt++;if(Z[tt]!==0&&(V[F+P]=4,++nt),nt>1e3)return null;let pt=new Int32Array([0,$,-1,0,-$,0,0,0,1]),dt=new Path2D;for(U=0;nt&&U<=S;U++){let lt=U*$,wt=lt+I;for(;lt<wt&&!V[lt];)lt++;if(lt===wt)continue;dt.moveTo(lt%$,U);let Tt=lt,xt=V[lt];do{let Dt=pt[xt];do lt+=Dt;while(!V[lt]);let Mt=V[lt];Mt!==5&&Mt!==10?(xt=Mt,V[lt]=0):(xt=Mt&51*xt>>4,V[lt]&=xt>>2|xt<<2),dt.lineTo(lt%$,lt/$|0),V[lt]||--nt}while(Tt!==lt);--U}return Z=null,V=null,function(lt){lt.save(),lt.scale(1/I,-1/S),lt.translate(0,-S),lt.fill(dt),lt.beginPath(),lt.restore()}})(w)),c.compiled)){c.compiled(R);return}let b=this._createMaskCanvas(w),C=b.canvas;R.save(),R.setTransform(1,0,0,1,0,0),R.drawImage(C,b.offsetX,b.offsetY),R.restore(),this.compose()}paintImageMaskXObjectRepeat(w,T,R=0,c=0,b,C){if(!this.contentVisible)return;w=this.getObject(w.data,w);let k=this.ctx;k.save();let O=(0,n.getCurrentTransform)(k);k.transform(T,R,c,b,0,0);let I=this._createMaskCanvas(w);k.setTransform(1,0,0,1,I.offsetX-O[4],I.offsetY-O[5]);for(let S=0,L=C.length;S<L;S+=2){let $=i.Util.transform(O,[T,R,c,b,C[S],C[S+1]]),[U,P]=i.Util.applyTransform([0,0],$);k.drawImage(I.canvas,U,P)}k.restore(),this.compose()}paintImageMaskXObjectGroup(w){if(!this.contentVisible)return;let T=this.ctx,R=this.current.fillColor,c=this.current.patternFill;for(let b of w){let{data:C,width:k,height:O,transform:I}=b,S=this.cachedCanvases.getCanvas("maskCanvas",k,O),L=S.context;L.save(),H(L,this.getObject(C,b)),L.globalCompositeOperation="source-in",L.fillStyle=c?R.getPattern(L,this,(0,n.getCurrentTransformInverse)(T),o):R,L.fillRect(0,0,k,O),L.restore(),T.save(),T.transform(...I),T.scale(1,-1),E(T,S.canvas,0,0,k,O,0,-1,1,1),T.restore()}this.compose()}paintImageXObject(w){if(!this.contentVisible)return;let T=this.getObject(w);T?this.paintInlineImageXObject(T):(0,i.warn)("Dependent image isn't ready yet")}paintImageXObjectRepeat(w,T,R,c){if(!this.contentVisible)return;let b=this.getObject(w);if(!b){(0,i.warn)("Dependent image isn't ready yet");return}let C=b.width,k=b.height,O=[];for(let I=0,S=c.length;I<S;I+=2)O.push({transform:[T,0,0,R,c[I],c[I+1]],x:0,y:0,w:C,h:k});this.paintInlineImageXObjectGroup(b,O)}applyTransferMapsToCanvas(w){return this.current.transferMaps!=="none"&&(w.filter=this.current.transferMaps,w.drawImage(w.canvas,0,0),w.filter="none"),w.canvas}applyTransferMapsToBitmap(w){if(this.current.transferMaps==="none")return w.bitmap;let{bitmap:T,width:R,height:c}=w,b=this.cachedCanvases.getCanvas("inlineImage",R,c),C=b.context;return C.filter=this.current.transferMaps,C.drawImage(T,0,0),C.filter="none",b.canvas}paintInlineImageXObject(w){if(!this.contentVisible)return;let T=w.width,R=w.height,c=this.ctx;if(this.save(),!i.isNodeJS){let{filter:k}=c;k!=="none"&&k!==""&&(c.filter="none")}c.scale(1/T,-1/R);let b;if(w.bitmap)b=this.applyTransferMapsToBitmap(w);else if(typeof HTMLElement=="function"&&w instanceof HTMLElement||!w.data)b=w;else{let k=this.cachedCanvases.getCanvas("inlineImage",T,R).context;N(k,w),b=this.applyTransferMapsToCanvas(k)}let C=this._scaleImage(b,(0,n.getCurrentTransformInverse)(c));c.imageSmoothingEnabled=G((0,n.getCurrentTransform)(c),w.interpolate),E(c,C.img,0,0,C.paintWidth,C.paintHeight,0,-R,T,R),this.compose(),this.restore()}paintInlineImageXObjectGroup(w,T){if(!this.contentVisible)return;let R=this.ctx,c;if(w.bitmap)c=w.bitmap;else{let b=w.width,C=w.height,k=this.cachedCanvases.getCanvas("inlineImage",b,C).context;N(k,w),c=this.applyTransferMapsToCanvas(k)}for(let b of T)R.save(),R.transform(...b.transform),R.scale(1,-1),E(R,c,b.x,b.y,b.w,b.h,0,-1,1,1),R.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(w){}markPointProps(w,T){}beginMarkedContent(w){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(w,T){w==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(T)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(w){let T=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(w);let R=this.ctx;this.pendingClip&&(T||(this.pendingClip===ct?R.clip("evenodd"):R.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),R.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let w=(0,n.getCurrentTransform)(this.ctx);if(w[1]===0&&w[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(w[0]),Math.abs(w[3]));else{let T=Math.abs(w[0]*w[3]-w[2]*w[1]),R=Math.hypot(w[0],w[2]),c=Math.hypot(w[1],w[3]);this._cachedGetSinglePixelWidth=Math.max(R,c)/T}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:w}=this.current,{a:T,b:R,c,d:b}=this.ctx.getTransform(),C,k;if(R===0&&c===0){let O=Math.abs(T),I=Math.abs(b);if(O===I)if(w===0)C=k=1/O;else{let S=O*w;C=k=S<1?1/S:1}else if(w===0)C=1/O,k=1/I;else{let S=O*w,L=I*w;C=S<1?1/S:1,k=L<1?1/L:1}}else{let O=Math.abs(T*b-R*c),I=Math.hypot(T,R),S=Math.hypot(c,b);if(w===0)C=S/O,k=I/O;else{let L=w*O;C=S>L?S/L:1,k=I>L?I/L:1}}this._cachedScaleForStroking[0]=C,this._cachedScaleForStroking[1]=k}return this._cachedScaleForStroking}rescaleAndStroke(w){let{ctx:T}=this,{lineWidth:R}=this.current,[c,b]=this.getScaleForStroking();if(T.lineWidth=R||1,c===1&&b===1){T.stroke();return}let C=T.getLineDash();if(w&&T.save(),T.scale(c,b),C.length>0){let k=Math.max(c,b);T.setLineDash(C.map((O=>O/k))),T.lineDashOffset/=k}T.stroke(),w&&T.restore()}isContentVisible(){for(let w=this.markedContentStack.length-1;w>=0;w--)if(!this.markedContentStack[w].visible)return!1;return!0}}for(let W in i.OPS)st.prototype[W]!==void 0&&(st.prototype[i.OPS[W]]=st.prototype[W])},419:(s,t,e)=>{e.d(t,{DOMCMapReaderFactory:()=>p,DOMCanvasFactory:()=>g,DOMFilterFactory:()=>u,DOMSVGFactory:()=>f,DOMStandardFontDataFactory:()=>a,PDFDateString:()=>M,PageViewport:()=>A,PixelsPerInch:()=>h,RenderingCancelledException:()=>_,StatTimer:()=>m,fetchData:()=>v,getColorValues:()=>z,getCurrentTransform:()=>K,getCurrentTransformInverse:()=>it,getFilenameFromUrl:()=>r,getPdfFilenameFromUrl:()=>l,getRGB:()=>H,getXfaPageViewport:()=>N,isDataScheme:()=>d,isPdfFile:()=>y,isValidFetchUrl:()=>x,noContextMenu:()=>D,setLayerDimensions:()=>ot});var i=e(583),n=e(292);let o="http://www.w3.org/2000/svg";class h{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}class u extends i.BaseFilterFactory{#t;#e;#i;#n;#r;#s=0;constructor({docId:j,ownerDocument:G=globalThis.document}={}){super(),this.#i=j,this.#n=G}get#a(){return this.#t||=new Map}get#c(){return this.#r||=new Map}get#o(){if(!this.#e){let j=this.#n.createElement("div"),{style:G}=j;G.visibility="hidden",G.contain="strict",G.width=G.height=0,G.position="absolute",G.top=G.left=0,G.zIndex=-1;let Y=this.#n.createElementNS(o,"svg");Y.setAttribute("width",0),Y.setAttribute("height",0),this.#e=this.#n.createElementNS(o,"defs"),j.append(Y),Y.append(this.#e),this.#n.body.append(j)}return this.#e}addFilter(j){if(!j)return"none";let G,Y,et,rt,ct=this.#a.get(j);if(ct)return ct;if(j.length===1){let T=j[0],R=new Array(256);for(let c=0;c<256;c++)R[c]=T[c]/255;rt=G=Y=et=R.join(",")}else{let[T,R,c]=j,b=new Array(256),C=new Array(256),k=new Array(256);for(let O=0;O<256;O++)b[O]=T[O]/255,C[O]=R[O]/255,k[O]=c[O]/255;G=b.join(","),Y=C.join(","),et=k.join(","),rt=`${G}${Y}${et}`}if(ct=this.#a.get(rt),ct)return this.#a.set(j,ct),ct;let st=`g_${this.#i}_transfer_map_${this.#s++}`,W=`url(#${st})`;this.#a.set(j,W),this.#a.set(rt,W);let w=this.#p(st);return this.#l(G,Y,et,w),W}addHCMFilter(j,G){let Y=`${j}-${G}`,et="base",rt=this.#c.get(et);if(rt?.key===Y||(rt?(rt.filter?.remove(),rt.key=Y,rt.url="none",rt.filter=null):(rt={key:Y,url:"none",filter:null},this.#c.set(et,rt)),!j||!G))return rt.url;let ct=this.#f(j);j=n.Util.makeHexColor(...ct);let st=this.#f(G);if(G=n.Util.makeHexColor(...st),this.#o.style.color="",j==="#000000"&&G==="#ffffff"||j===G)return rt.url;let W=new Array(256);for(let b=0;b<=255;b++){let C=b/255;W[b]=C<=.03928?C/12.92:((C+.055)/1.055)**2.4}let w=W.join(","),T=`g_${this.#i}_hcm_filter`,R=rt.filter=this.#p(T);this.#l(w,w,w,R),this.#d(R);let c=(b,C)=>{let k=ct[b]/255,O=st[b]/255,I=new Array(C+1);for(let S=0;S<=C;S++)I[S]=k+S/C*(O-k);return I.join(",")};return this.#l(c(0,5),c(1,5),c(2,5),R),rt.url=`url(#${T})`,rt.url}addHighlightHCMFilter(j,G,Y,et,rt){let ct=`${G}-${Y}-${et}-${rt}`,st=this.#c.get(j);if(st?.key===ct||(st?(st.filter?.remove(),st.key=ct,st.url="none",st.filter=null):(st={key:ct,url:"none",filter:null},this.#c.set(j,st)),!G||!Y))return st.url;let[W,w]=[G,Y].map(this.#f.bind(this)),T=Math.round(.2126*W[0]+.7152*W[1]+.0722*W[2]),R=Math.round(.2126*w[0]+.7152*w[1]+.0722*w[2]),[c,b]=[et,rt].map(this.#f.bind(this));R<T&&([T,R,c,b]=[R,T,b,c]),this.#o.style.color="";let C=(I,S,L)=>{let $=new Array(256),U=(R-T)/L,P=I/255,F=(S-I)/(255*L),V=0;for(let Q=0;Q<=L;Q++){let Z=Math.round(T+Q*U),tt=P+Q*F;for(let nt=V;nt<=Z;nt++)$[nt]=tt;V=Z+1}for(let Q=V;Q<256;Q++)$[Q]=$[V-1];return $.join(",")},k=`g_${this.#i}_hcm_${j}_filter`,O=st.filter=this.#p(k);return this.#d(O),this.#l(C(c[0],b[0],5),C(c[1],b[1],5),C(c[2],b[2],5),O),st.url=`url(#${k})`,st.url}destroy(j=!1){(!j||this.#c.size===0)&&(this.#e&&(this.#e.parentNode.parentNode.remove(),this.#e=null),this.#t&&(this.#t.clear(),this.#t=null),this.#s=0)}#d(j){let G=this.#n.createElementNS(o,"feColorMatrix");G.setAttribute("type","matrix"),G.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"),j.append(G)}#p(j){let G=this.#n.createElementNS(o,"filter");return G.setAttribute("color-interpolation-filters","sRGB"),G.setAttribute("id",j),this.#o.append(G),G}#u(j,G,Y){let et=this.#n.createElementNS(o,G);et.setAttribute("type","discrete"),et.setAttribute("tableValues",Y),j.append(et)}#l(j,G,Y,et){let rt=this.#n.createElementNS(o,"feComponentTransfer");et.append(rt),this.#u(rt,"feFuncR",j),this.#u(rt,"feFuncG",G),this.#u(rt,"feFuncB",Y)}#f(j){return this.#o.style.color=j,H(getComputedStyle(this.#o).getPropertyValue("color"))}}class g extends i.BaseCanvasFactory{constructor({ownerDocument:j=globalThis.document}={}){super(),this._document=j}_createCanvas(j,G){let Y=this._document.createElement("canvas");return Y.width=j,Y.height=G,Y}}async function v(X,j="text"){if(x(X,document.baseURI)){let G=await fetch(X);if(!G.ok)throw new Error(G.statusText);switch(j){case"arraybuffer":return G.arrayBuffer();case"blob":return G.blob();case"json":return G.json()}return G.text()}return new Promise(((G,Y)=>{let et=new XMLHttpRequest;et.open("GET",X,!0),et.responseType=j,et.onreadystatechange=()=>{if(et.readyState===XMLHttpRequest.DONE)if(et.status!==200&&et.status!==0)Y(new Error(et.statusText));else{switch(j){case"arraybuffer":case"blob":case"json":G(et.response);return}G(et.responseText)}},et.send(null)}))}class p extends i.BaseCMapReaderFactory{_fetchData(j,G){return v(j,this.isCompressed?"arraybuffer":"text").then((Y=>({cMapData:Y instanceof ArrayBuffer?new Uint8Array(Y):(0,n.stringToBytes)(Y),compressionType:G})))}}class a extends i.BaseStandardFontDataFactory{_fetchData(j){return v(j,"arraybuffer").then((G=>new Uint8Array(G)))}}class f extends i.BaseSVGFactory{_createSVG(j){return document.createElementNS(o,j)}}class A{constructor({viewBox:j,scale:G,rotation:Y,offsetX:et=0,offsetY:rt=0,dontFlip:ct=!1}){this.viewBox=j,this.scale=G,this.rotation=Y,this.offsetX=et,this.offsetY=rt;let st=(j[2]+j[0])/2,W=(j[3]+j[1])/2,w,T,R,c,b,C,k,O;switch((Y%=360)<0&&(Y+=360),Y){case 180:w=-1,T=0,R=0,c=1;break;case 90:w=0,T=1,R=1,c=0;break;case 270:w=0,T=-1,R=-1,c=0;break;case 0:w=1,T=0,R=0,c=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}ct&&(R=-R,c=-c),w===0?(b=Math.abs(W-j[1])*G+et,C=Math.abs(st-j[0])*G+rt,k=(j[3]-j[1])*G,O=(j[2]-j[0])*G):(b=Math.abs(st-j[0])*G+et,C=Math.abs(W-j[1])*G+rt,k=(j[2]-j[0])*G,O=(j[3]-j[1])*G),this.transform=[w*G,T*G,R*G,c*G,b-w*G*st-R*G*W,C-T*G*st-c*G*W],this.width=k,this.height=O}get rawDims(){let{viewBox:j}=this;return(0,n.shadow)(this,"rawDims",{pageWidth:j[2]-j[0],pageHeight:j[3]-j[1],pageX:j[0],pageY:j[1]})}clone({scale:j=this.scale,rotation:G=this.rotation,offsetX:Y=this.offsetX,offsetY:et=this.offsetY,dontFlip:rt=!1}={}){return new A({viewBox:this.viewBox.slice(),scale:j,rotation:G,offsetX:Y,offsetY:et,dontFlip:rt})}convertToViewportPoint(j,G){return n.Util.applyTransform([j,G],this.transform)}convertToViewportRectangle(j){let G=n.Util.applyTransform([j[0],j[1]],this.transform),Y=n.Util.applyTransform([j[2],j[3]],this.transform);return[G[0],G[1],Y[0],Y[1]]}convertToPdfPoint(j,G){return n.Util.applyInverseTransform([j,G],this.transform)}}class _ extends n.BaseException{constructor(j,G=0){super(j,"RenderingCancelledException"),this.extraDelay=G}}function d(X){let j=X.length,G=0;for(;G<j&&X[G].trim()==="";)G++;return X.substring(G,G+5).toLowerCase()==="data:"}function y(X){return typeof X=="string"&&/\.pdf$/i.test(X)}function r(X,j=!1){return j||([X]=X.split(/[#?]/,1)),X.substring(X.lastIndexOf("/")+1)}function l(X,j="document.pdf"){if(typeof X!="string")return j;if(d(X))return(0,n.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),j;let G=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,Y=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(X),et=G.exec(Y[1])||G.exec(Y[2])||G.exec(Y[3]);if(et&&(et=et[0],et.includes("%")))try{et=G.exec(decodeURIComponent(et))[0]}catch{}return et||j}class m{started=Object.create(null);times=[];time(j){j in this.started&&(0,n.warn)(`Timer is already running for ${j}`),this.started[j]=Date.now()}timeEnd(j){j in this.started||(0,n.warn)(`Timer has not been started for ${j}`),this.times.push({name:j,start:this.started[j],end:Date.now()}),delete this.started[j]}toString(){let j=[],G=0;for(let{name:Y}of this.times)G=Math.max(Y.length,G);for(let{name:Y,start:et,end:rt}of this.times)j.push(`${Y.padEnd(G)} ${rt-et}ms
6
+ `);return j.join("")}}function x(X,j){try{let{protocol:G}=j?new URL(X,j):new URL(X);return G==="http:"||G==="https:"}catch{return!1}}function D(X){X.preventDefault()}let E;class M{static toDateObject(j){if(!j||typeof j!="string")return null;E||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let G=E.exec(j);if(!G)return null;let Y=parseInt(G[1],10),et=parseInt(G[2],10);et=et>=1&&et<=12?et-1:0;let rt=parseInt(G[3],10);rt=rt>=1&&rt<=31?rt:1;let ct=parseInt(G[4],10);ct=ct>=0&&ct<=23?ct:0;let st=parseInt(G[5],10);st=st>=0&&st<=59?st:0;let W=parseInt(G[6],10);W=W>=0&&W<=59?W:0;let w=G[7]||"Z",T=parseInt(G[8],10);T=T>=0&&T<=23?T:0;let R=parseInt(G[9],10)||0;return R=R>=0&&R<=59?R:0,w==="-"?(ct+=T,st+=R):w==="+"&&(ct-=T,st-=R),new Date(Date.UTC(Y,et,rt,ct,st,W))}}function N(X,{scale:j=1,rotation:G=0}){let{width:Y,height:et}=X.attributes.style,rt=[0,0,parseInt(Y),parseInt(et)];return new A({viewBox:rt,scale:j,rotation:G})}function H(X){if(X.startsWith("#")){let j=parseInt(X.slice(1),16);return[(16711680&j)>>16,(65280&j)>>8,255&j]}return X.startsWith("rgb(")?X.slice(4,-1).split(",").map((j=>parseInt(j))):X.startsWith("rgba(")?X.slice(5,-1).split(",").map((j=>parseInt(j))).slice(0,3):((0,n.warn)(`Not a valid color format: "${X}"`),[0,0,0])}function z(X){let j=document.createElement("span");j.style.visibility="hidden",document.body.append(j);for(let G of X.keys()){j.style.color=G;let Y=window.getComputedStyle(j).color;X.set(G,H(Y))}j.remove()}function K(X){let{a:j,b:G,c:Y,d:et,e:rt,f:ct}=X.getTransform();return[j,G,Y,et,rt,ct]}function it(X){let{a:j,b:G,c:Y,d:et,e:rt,f:ct}=X.getTransform().invertSelf();return[j,G,Y,et,rt,ct]}function ot(X,j,G=!1,Y=!0){if(j instanceof A){let{pageWidth:et,pageHeight:rt}=j.rawDims,{style:ct}=X,st=n.FeatureTest.isCSSRoundSupported,W=`var(--scale-factor) * ${et}px`,w=`var(--scale-factor) * ${rt}px`,T=st?`round(${W}, 1px)`:`calc(${W})`,R=st?`round(${w}, 1px)`:`calc(${w})`;G&&j.rotation%180!=0?(ct.width=R,ct.height=T):(ct.width=T,ct.height=R)}Y&&X.setAttribute("data-main-rotation",j.rotation)}},47:(s,t,e)=>{e.d(t,{DrawLayer:()=>o});var i=e(419),n=e(292);class o{#t=null;#e=0;#i=new Map;#n=new Map;constructor({pageIndex:u}){this.pageIndex=u}setParent(u){if(this.#t){if(this.#t!==u){if(this.#i.size>0)for(let g of this.#i.values())g.remove(),u.append(g);this.#t=u}}else this.#t=u}static get _svgFactory(){return(0,n.shadow)(this,"_svgFactory",new i.DOMSVGFactory)}static#r(u,{x:g=0,y:v=0,width:p=1,height:a=1}={}){let{style:f}=u;f.top=100*v+"%",f.left=100*g+"%",f.width=100*p+"%",f.height=100*a+"%"}#s(u){let g=o._svgFactory.create(1,1,!0);return this.#t.append(g),g.setAttribute("aria-hidden",!0),o.#r(g,u),g}#a(u,g){let v=o._svgFactory.createElement("clipPath");u.append(v);let p=`clip_${g}`;v.setAttribute("id",p),v.setAttribute("clipPathUnits","objectBoundingBox");let a=o._svgFactory.createElement("use");return v.append(a),a.setAttribute("href",`#${g}`),a.classList.add("clip"),p}highlight(u,g,v,p=!1){let a=this.#e++,f=this.#s(u.box);f.classList.add("highlight"),u.free&&f.classList.add("free");let A=o._svgFactory.createElement("defs");f.append(A);let _=o._svgFactory.createElement("path");A.append(_);let d=`path_p${this.pageIndex}_${a}`;_.setAttribute("id",d),_.setAttribute("d",u.toSVGPath()),p&&this.#n.set(a,_);let y=this.#a(A,d),r=o._svgFactory.createElement("use");return f.append(r),f.setAttribute("fill",g),f.setAttribute("fill-opacity",v),r.setAttribute("href",`#${d}`),this.#i.set(a,f),{id:a,clipPathId:`url(#${y})`}}highlightOutline(u){let g=this.#e++,v=this.#s(u.box);v.classList.add("highlightOutline");let p=o._svgFactory.createElement("defs");v.append(p);let a=o._svgFactory.createElement("path");p.append(a);let f=`path_p${this.pageIndex}_${g}`;a.setAttribute("id",f),a.setAttribute("d",u.toSVGPath()),a.setAttribute("vector-effect","non-scaling-stroke");let A;if(u.free){v.classList.add("free");let y=o._svgFactory.createElement("mask");p.append(y),A=`mask_p${this.pageIndex}_${g}`,y.setAttribute("id",A),y.setAttribute("maskUnits","objectBoundingBox");let r=o._svgFactory.createElement("rect");y.append(r),r.setAttribute("width","1"),r.setAttribute("height","1"),r.setAttribute("fill","white");let l=o._svgFactory.createElement("use");y.append(l),l.setAttribute("href",`#${f}`),l.setAttribute("stroke","none"),l.setAttribute("fill","black"),l.setAttribute("fill-rule","nonzero"),l.classList.add("mask")}let _=o._svgFactory.createElement("use");v.append(_),_.setAttribute("href",`#${f}`),A&&_.setAttribute("mask",`url(#${A})`);let d=_.cloneNode();return v.append(d),_.classList.add("mainOutline"),d.classList.add("secondaryOutline"),this.#i.set(g,v),g}finalizeLine(u,g){let v=this.#n.get(u);this.#n.delete(u),this.updateBox(u,g.box),v.setAttribute("d",g.toSVGPath())}updateLine(u,g){this.#i.get(u).firstChild.firstChild.setAttribute("d",g.toSVGPath())}removeFreeHighlight(u){this.remove(u),this.#n.delete(u)}updatePath(u,g){this.#n.get(u).setAttribute("d",g.toSVGPath())}updateBox(u,g){o.#r(this.#i.get(u),g)}show(u,g){this.#i.get(u).classList.toggle("hidden",!g)}rotate(u,g){this.#i.get(u).setAttribute("data-main-rotation",g)}changeColor(u,g){this.#i.get(u).setAttribute("fill",g)}changeOpacity(u,g){this.#i.get(u).setAttribute("fill-opacity",g)}addClass(u,g){this.#i.get(u).classList.add(g)}removeClass(u,g){this.#i.get(u).classList.remove(g)}remove(u){this.#t!==null&&(this.#i.get(u).remove(),this.#i.delete(u))}destroy(){this.#t=null;for(let u of this.#i.values())u.remove();this.#i.clear()}}},731:(s,t,e)=>{e.d(t,{AnnotationEditorLayer:()=>d});var i=e(292),n=e(310),o=e(830),h=e(976);let u=/\r\n?|\n/g;class g extends n.AnnotationEditor{#t=this.editorDivBlur.bind(this);#e=this.editorDivFocus.bind(this);#i=this.editorDivInput.bind(this);#n=this.editorDivKeydown.bind(this);#r=this.editorDivPaste.bind(this);#s;#a="";#c=`${this.id}-editor`;#o;#d=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let r=g.prototype,l=D=>D.isEmpty(),m=o.AnnotationEditorUIManager.TRANSLATE_SMALL,x=o.AnnotationEditorUIManager.TRANSLATE_BIG;return(0,i.shadow)(this,"_keyboardManager",new o.KeyboardManager([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],r.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],r.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],r._translateEmpty,{args:[-m,0],checker:l}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],r._translateEmpty,{args:[-x,0],checker:l}],[["ArrowRight","mac+ArrowRight"],r._translateEmpty,{args:[m,0],checker:l}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],r._translateEmpty,{args:[x,0],checker:l}],[["ArrowUp","mac+ArrowUp"],r._translateEmpty,{args:[0,-m],checker:l}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],r._translateEmpty,{args:[0,-x],checker:l}],[["ArrowDown","mac+ArrowDown"],r._translateEmpty,{args:[0,m],checker:l}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],r._translateEmpty,{args:[0,x],checker:l}]]))}static _type="freetext";static _editorType=i.AnnotationEditorType.FREETEXT;constructor(r){super({...r,name:"freeTextEditor"}),this.#s=r.color||g._defaultColor||n.AnnotationEditor._defaultLineColor,this.#o=r.fontSize||g._defaultFontSize}static initialize(r,l){n.AnnotationEditor.initialize(r,l,{strings:["pdfjs-free-text-default-content"]});let m=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(m.getPropertyValue("--freetext-padding"))}static updateDefaultParams(r,l){switch(r){case i.AnnotationEditorParamsType.FREETEXT_SIZE:g._defaultFontSize=l;break;case i.AnnotationEditorParamsType.FREETEXT_COLOR:g._defaultColor=l}}updateParams(r,l){switch(r){case i.AnnotationEditorParamsType.FREETEXT_SIZE:this.#p(l);break;case i.AnnotationEditorParamsType.FREETEXT_COLOR:this.#u(l)}}static get defaultPropertiesToUpdate(){return[[i.AnnotationEditorParamsType.FREETEXT_SIZE,g._defaultFontSize],[i.AnnotationEditorParamsType.FREETEXT_COLOR,g._defaultColor||n.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[i.AnnotationEditorParamsType.FREETEXT_SIZE,this.#o],[i.AnnotationEditorParamsType.FREETEXT_COLOR,this.#s]]}#p(r){let l=x=>{this.editorDiv.style.fontSize=`calc(${x}px * var(--scale-factor))`,this.translate(0,-(x-this.#o)*this.parentScale),this.#o=x,this.#f()},m=this.#o;this.addCommands({cmd:l.bind(this,r),undo:l.bind(this,m),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#u(r){let l=x=>{this.#s=this.editorDiv.style.color=x},m=this.#s;this.addCommands({cmd:l.bind(this,r),undo:l.bind(this,m),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(r,l){this._uiManager.translateSelectedEditors(r,l,!0)}getInitialTranslation(){let r=this.parentScale;return[-g._internalPadding*r,-(g._internalPadding+this.#o)*r]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){this.isInEditMode()||(this.parent.setEditingState(!1),this.parent.updateToolbar(i.AnnotationEditorType.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.editorDiv.addEventListener("keydown",this.#n),this.editorDiv.addEventListener("focus",this.#e),this.editorDiv.addEventListener("blur",this.#t),this.editorDiv.addEventListener("input",this.#i),this.editorDiv.addEventListener("paste",this.#r))}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#c),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",this.#n),this.editorDiv.removeEventListener("focus",this.#e),this.editorDiv.removeEventListener("blur",this.#t),this.editorDiv.removeEventListener("input",this.#i),this.editorDiv.removeEventListener("paste",this.#r),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(r){this._focusEventsAllowed&&(super.focusin(r),r.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){this.width||(this.enableEditMode(),this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#l(){let r=[];this.editorDiv.normalize();for(let l of this.editorDiv.childNodes)r.push(g.#g(l));return r.join(`
7
+ `)}#f(){let[r,l]=this.parentDimensions,m;if(this.isAttachedToDOM)m=this.div.getBoundingClientRect();else{let{currentLayer:x,div:D}=this,E=D.style.display;D.style.display="hidden",x.div.append(this.div),m=D.getBoundingClientRect(),D.remove(),D.style.display=E}this.rotation%180==this.parentRotation%180?(this.width=m.width/r,this.height=m.height/l):(this.width=m.height/r,this.height=m.width/l),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let r=this.#a,l=this.#a=this.#l().trimEnd();if(r===l)return;let m=x=>{this.#a=x,x?(this.#h(),this._uiManager.rebuild(this),this.#f()):this.remove()};this.addCommands({cmd:()=>{m(l)},undo:()=>{m(r)},mustExec:!1}),this.#f()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(r){this.enterInEditMode()}keydown(r){r.target===this.div&&r.key==="Enter"&&(this.enterInEditMode(),r.preventDefault())}editorDivKeydown(r){g._keyboardManager.exec(this,r)}editorDivFocus(r){this.isEditing=!0}editorDivBlur(r){this.isEditing=!1}editorDivInput(r){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let r,l;this.width&&(r=this.x,l=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#c),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),n.AnnotationEditor._l10nPromise.get("pdfjs-free-text-default-content").then((x=>this.editorDiv?.setAttribute("default-content",x))),this.editorDiv.contentEditable=!0;let{style:m}=this.editorDiv;if(m.fontSize=`calc(${this.#o}px * var(--scale-factor))`,m.color=this.#s,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),(0,o.bindEvents)(this,this.div,["dblclick","keydown"]),this.width){let[x,D]=this.parentDimensions;if(this.annotationElementId){let{position:E}=this.#d,[M,N]=this.getInitialTranslation();[M,N]=this.pageTranslationToScreen(M,N);let[H,z]=this.pageDimensions,[K,it]=this.pageTranslation,ot,X;switch(this.rotation){case 0:ot=r+(E[0]-K)/H,X=l+this.height-(E[1]-it)/z;break;case 90:ot=r+(E[0]-K)/H,X=l-(E[1]-it)/z,[M,N]=[N,-M];break;case 180:ot=r-this.width+(E[0]-K)/H,X=l-(E[1]-it)/z,[M,N]=[-M,-N];break;case 270:ot=r+(E[0]-K-this.height*z)/H,X=l+(E[1]-it-this.width*H)/z,[M,N]=[-N,M]}this.setAt(ot*x,X*D,M,N)}else this.setAt(r*x,l*D,this.width*x,this.height*D);this.#h(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#g(r){return(r.nodeType===Node.TEXT_NODE?r.nodeValue:r.innerText).replaceAll(u,"")}editorDivPaste(r){let l=r.clipboardData||window.clipboardData,{types:m}=l;if(m.length===1&&m[0]==="text/plain")return;r.preventDefault();let x=g.#m(l.getData("text")||"").replaceAll(u,`
8
+ `);if(!x)return;let D=window.getSelection();if(!D.rangeCount)return;this.editorDiv.normalize(),D.deleteFromDocument();let E=D.getRangeAt(0);if(!x.includes(`
9
+ `)){E.insertNode(document.createTextNode(x)),this.editorDiv.normalize(),D.collapseToStart();return}let{startContainer:M,startOffset:N}=E,H=[],z=[];if(M.nodeType===Node.TEXT_NODE){let ot=M.parentElement;if(z.push(M.nodeValue.slice(N).replaceAll(u,"")),ot!==this.editorDiv){let X=H;for(let j of this.editorDiv.childNodes)j!==ot?X.push(g.#g(j)):X=z}H.push(M.nodeValue.slice(0,N).replaceAll(u,""))}else if(M===this.editorDiv){let ot=H,X=0;for(let j of this.editorDiv.childNodes)X++===N&&(ot=z),ot.push(g.#g(j))}this.#a=`${H.join(`
10
+ `)}${x}${z.join(`
11
+ `)}`,this.#h();let K=new Range,it=H.reduce(((ot,X)=>ot+X.length),0);for(let{firstChild:ot}of this.editorDiv.childNodes)if(ot.nodeType===Node.TEXT_NODE){let X=ot.nodeValue.length;if(it<=X){K.setStart(ot,it),K.setEnd(ot,it);break}it-=X}D.removeAllRanges(),D.addRange(K)}#h(){if(this.editorDiv.replaceChildren(),this.#a)for(let r of this.#a.split(`
12
+ `)){let l=document.createElement("div");l.append(r?document.createTextNode(r):document.createElement("br")),this.editorDiv.append(l)}}#b(){return this.#a.replaceAll("\xA0"," ")}static#m(r){return r.replaceAll(" ","\xA0")}get contentDiv(){return this.editorDiv}static deserialize(r,l,m){let x=null;if(r instanceof h.FreeTextAnnotationElement){let{data:{defaultAppearanceData:{fontSize:E,fontColor:M},rect:N,rotation:H,id:z},textContent:K,textPosition:it,parent:{page:{pageNumber:ot}}}=r;if(!K||K.length===0)return null;x=r={annotationType:i.AnnotationEditorType.FREETEXT,color:Array.from(M),fontSize:E,value:K.join(`
13
+ `),position:it,pageIndex:ot-1,rect:N,rotation:H,id:z,deleted:!1}}let D=super.deserialize(r,l,m);return D.#o=r.fontSize,D.#s=i.Util.makeHexColor(...r.color),D.#a=g.#m(r.value),D.annotationElementId=r.id||null,D.#d=x,D}serialize(r=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};let l=g._internalPadding*this.parentScale,m=this.getRect(l,l),x=n.AnnotationEditor._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#s),D={annotationType:i.AnnotationEditorType.FREETEXT,color:x,fontSize:this.#o,value:this.#b(),pageIndex:this.pageIndex,rect:m,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return r?D:this.annotationElementId&&!this.#v(D)?null:(D.id=this.annotationElementId,D)}#v(r){let{value:l,fontSize:m,color:x,pageIndex:D}=this.#d;return this._hasBeenMoved||r.value!==l||r.fontSize!==m||r.color.some(((E,M)=>E!==x[M]))||r.pageIndex!==D}}var v=e(61),p=e(259),a=e(419);class f extends n.AnnotationEditor{#t=null;#e=0;#i;#n=null;#r=null;#s=null;#a=null;#c=0;#o=null;#d=null;#p=null;#u=!1;#l=this.#C.bind(this);#f=null;#g;#h=null;#b="";#m;#v="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _l10nPromise;static _type="highlight";static _editorType=i.AnnotationEditorType.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let r=f.prototype;return(0,i.shadow)(this,"_keyboardManager",new o.KeyboardManager([[["ArrowLeft","mac+ArrowLeft"],r._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],r._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],r._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],r._moveCaret,{args:[3]}]]))}constructor(r){super({...r,name:"highlightEditor"}),this.color=r.color||f._defaultColor,this.#m=r.thickness||f._defaultThickness,this.#g=r.opacity||f._defaultOpacity,this.#i=r.boxes||null,this.#v=r.methodOfCreation||"",this.#b=r.text||"",this._isDraggable=!1,r.highlightId>-1?(this.#u=!0,this.#_(r),this.#E()):(this.#t=r.anchorNode,this.#e=r.anchorOffset,this.#a=r.focusNode,this.#c=r.focusOffset,this.#S(),this.#E(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#u?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#m,methodOfCreation:this.#v}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(r){return{numberOfColors:r.get("color").size}}#S(){let r=new v.Outliner(this.#i,.001);this.#d=r.getOutlines(),{x:this.x,y:this.y,width:this.width,height:this.height}=this.#d.box;let l=new v.Outliner(this.#i,.0025,.001,this._uiManager.direction==="ltr");this.#s=l.getOutlines();let{lastPoint:m}=this.#s.box;this.#f=[(m[0]-this.x)/this.width,(m[1]-this.y)/this.height]}#_({highlightOutlines:r,highlightId:l,clipPathId:m}){if(this.#d=r,this.#s=r.getNewOutline(this.#m/2+1.5,.0025),l>=0)this.#p=l,this.#n=m,this.parent.drawLayer.finalizeLine(l,r),this.#h=this.parent.drawLayer.highlightOutline(this.#s);else if(this.parent){let H=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#p,r),this.parent.drawLayer.updateBox(this.#p,f.#A(this.#d.box,(H-this.rotation+360)%360)),this.parent.drawLayer.updateLine(this.#h,this.#s),this.parent.drawLayer.updateBox(this.#h,f.#A(this.#s.box,H))}let{x,y:D,width:E,height:M}=r.box;switch(this.rotation){case 0:this.x=x,this.y=D,this.width=E,this.height=M;break;case 90:{let[H,z]=this.parentDimensions;this.x=D,this.y=1-x,this.width=E*z/H,this.height=M*H/z;break}case 180:this.x=1-x,this.y=1-D,this.width=E,this.height=M;break;case 270:{let[H,z]=this.parentDimensions;this.x=1-D,this.y=x,this.width=E*z/H,this.height=M*H/z;break}}let{lastPoint:N}=this.#s.box;this.#f=[(N[0]-x)/E,(N[1]-D)/M]}static initialize(r,l){n.AnnotationEditor.initialize(r,l),f._defaultColor||=l.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(r,l){switch(r){case i.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:f._defaultColor=l;break;case i.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:f._defaultThickness=l}}translateInPage(r,l){}get toolbarPosition(){return this.#f}updateParams(r,l){switch(r){case i.AnnotationEditorParamsType.HIGHLIGHT_COLOR:this.#I(l);break;case i.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:this.#w(l)}}static get defaultPropertiesToUpdate(){return[[i.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR,f._defaultColor],[i.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS,f._defaultThickness]]}get propertiesToUpdate(){return[[i.AnnotationEditorParamsType.HIGHLIGHT_COLOR,this.color||f._defaultColor],[i.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS,this.#m||f._defaultThickness],[i.AnnotationEditorParamsType.HIGHLIGHT_FREE,this.#u]]}#I(r){let l=x=>{this.color=x,this.parent?.drawLayer.changeColor(this.#p,x),this.#r?.updateColor(x)},m=this.color;this.addCommands({cmd:l.bind(this,r),undo:l.bind(this,m),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(r)},!0)}#w(r){let l=this.#m,m=x=>{this.#m=x,this.#x(x)};this.addCommands({cmd:m.bind(this,r),undo:m.bind(this,l),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:r},!0)}async addEditToolbar(){let r=await super.addEditToolbar();return r?(this._uiManager.highlightColors&&(this.#r=new p.ColorPicker({editor:this}),r.addColorPicker(this.#r)),r):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#k())}getBaseTranslation(){return[0,0]}getRect(r,l){return super.getRect(r,l,this.#k())}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#y(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#E(),this.isAttachedToDOM||this.parent.add(this)))}setParent(r){let l=!1;this.parent&&!r?this.#y():r&&(this.#E(r),l=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(r),this.show(this._isVisible),l&&this.select()}#x(r){if(!this.#u)return;this.#_({highlightOutlines:this.#d.getNewOutline(r/2)}),this.fixAndSetPosition();let[l,m]=this.parentDimensions;this.setDims(this.width*l,this.height*m)}#y(){this.#p!==null&&this.parent&&(this.parent.drawLayer.remove(this.#p),this.#p=null,this.parent.drawLayer.remove(this.#h),this.#h=null)}#E(r=this.parent){this.#p===null&&({id:this.#p,clipPathId:this.#n}=r.drawLayer.highlight(this.#d,this.color,this.#g),this.#h=r.drawLayer.highlightOutline(this.#s),this.#o&&(this.#o.style.clipPath=this.#n))}static#A({x:r,y:l,width:m,height:x},D){switch(D){case 90:return{x:1-l-x,y:r,width:x,height:m};case 180:return{x:1-r-m,y:1-l-x,width:m,height:x};case 270:return{x:l,y:1-r-m,width:x,height:m}}return{x:r,y:l,width:m,height:x}}rotate(r){let{drawLayer:l}=this.parent,m;this.#u?(r=(r-this.rotation+360)%360,m=f.#A(this.#d.box,r)):m=f.#A(this,r),l.rotate(this.#p,r),l.rotate(this.#h,r),l.updateBox(this.#p,m),l.updateBox(this.#h,f.#A(this.#s.box,r))}render(){if(this.div)return this.div;let r=super.render();this.#b&&(r.setAttribute("aria-label",this.#b),r.setAttribute("role","mark")),this.#u?r.classList.add("free"):this.div.addEventListener("keydown",this.#l);let l=this.#o=document.createElement("div");r.append(l),l.setAttribute("aria-hidden","true"),l.className="internal",l.style.clipPath=this.#n;let[m,x]=this.parentDimensions;return this.setDims(this.width*m,this.height*x),(0,o.bindEvents)(this,this.#o,["pointerover","pointerleave"]),this.enableEditing(),r}pointerover(){this.parent.drawLayer.addClass(this.#h,"hovered")}pointerleave(){this.parent.drawLayer.removeClass(this.#h,"hovered")}#C(r){f._keyboardManager.exec(this,r)}_moveCaret(r){switch(this.parent.unselect(this),r){case 0:case 2:this.#T(!0);break;case 1:case 3:this.#T(!1)}}#T(r){if(!this.#t)return;let l=window.getSelection();r?l.setPosition(this.#t,this.#e):l.setPosition(this.#a,this.#c)}select(){super.select(),this.#h&&(this.parent?.drawLayer.removeClass(this.#h,"hovered"),this.parent?.drawLayer.addClass(this.#h,"selected"))}unselect(){super.unselect(),this.#h&&(this.parent?.drawLayer.removeClass(this.#h,"selected"),this.#u||this.#T(!1))}get _mustFixPosition(){return!this.#u}show(r=this._isVisible){super.show(r),this.parent&&(this.parent.drawLayer.show(this.#p,r),this.parent.drawLayer.show(this.#h,r))}#k(){return this.#u?this.rotation:0}#M(){if(this.#u)return null;let[r,l]=this.pageDimensions,m=this.#i,x=new Array(8*m.length),D=0;for(let{x:E,y:M,width:N,height:H}of m){let z=E*r,K=(1-M-H)*l;x[D]=x[D+4]=z,x[D+1]=x[D+3]=K,x[D+2]=x[D+6]=z+N*r,x[D+5]=x[D+7]=K+H*l,D+=8}return x}#P(r){return this.#d.serialize(r,this.#k())}static startHighlighting(r,l,{target:m,x,y:D}){let{x:E,y:M,width:N,height:H}=m.getBoundingClientRect(),z=X=>{this.#L(r,X)},K={capture:!0,passive:!1},it=X=>{X.preventDefault(),X.stopPropagation()},ot=X=>{m.removeEventListener("pointermove",z),window.removeEventListener("blur",ot),window.removeEventListener("pointerup",ot),window.removeEventListener("pointerdown",it,K),window.removeEventListener("contextmenu",a.noContextMenu),this.#R(r,X)};window.addEventListener("blur",ot),window.addEventListener("pointerup",ot),window.addEventListener("pointerdown",it,K),window.addEventListener("contextmenu",a.noContextMenu),m.addEventListener("pointermove",z),this._freeHighlight=new v.FreeOutliner({x,y:D},[E,M,N,H],r.scale,this._defaultThickness/2,l,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=r.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static#L(r,l){this._freeHighlight.add(l)&&r.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static#R(r,l){this._freeHighlight.isEmpty()?r.drawLayer.removeFreeHighlight(this._freeHighlightId):r.createAndAddNewEditor(l,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static deserialize(r,l,m){let x=super.deserialize(r,l,m),{rect:[D,E,M,N],color:H,quadPoints:z}=r;x.color=i.Util.makeHexColor(...H),x.#g=r.opacity;let[K,it]=x.pageDimensions;x.width=(M-D)/K,x.height=(N-E)/it;let ot=x.#i=[];for(let X=0;X<z.length;X+=8)ot.push({x:(z[4]-M)/K,y:(N-(1-z[X+5]))/it,width:(z[X+2]-z[X])/K,height:(z[X+5]-z[X+1])/it});return x.#S(),x}serialize(r=!1){if(this.isEmpty()||r)return null;let l=this.getRect(0,0),m=n.AnnotationEditor._colorManager.convert(this.color);return{annotationType:i.AnnotationEditorType.HIGHLIGHT,color:m,opacity:this.#g,thickness:this.#m,quadPoints:this.#M(),outlines:this.#P(l),pageIndex:this.pageIndex,rect:l,rotation:this.#k(),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}}class A extends n.AnnotationEditor{#t=0;#e=0;#i=this.canvasPointermove.bind(this);#n=this.canvasPointerleave.bind(this);#r=this.canvasPointerup.bind(this);#s=this.canvasPointerdown.bind(this);#a=null;#c=new Path2D;#o=!1;#d=!1;#p=!1;#u=null;#l=0;#f=0;#g=null;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=1;static _type="ink";static _editorType=i.AnnotationEditorType.INK;constructor(r){super({...r,name:"inkEditor"}),this.color=r.color||null,this.thickness=r.thickness||null,this.opacity=r.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(r,l){n.AnnotationEditor.initialize(r,l)}static updateDefaultParams(r,l){switch(r){case i.AnnotationEditorParamsType.INK_THICKNESS:A._defaultThickness=l;break;case i.AnnotationEditorParamsType.INK_COLOR:A._defaultColor=l;break;case i.AnnotationEditorParamsType.INK_OPACITY:A._defaultOpacity=l/100}}updateParams(r,l){switch(r){case i.AnnotationEditorParamsType.INK_THICKNESS:this.#h(l);break;case i.AnnotationEditorParamsType.INK_COLOR:this.#b(l);break;case i.AnnotationEditorParamsType.INK_OPACITY:this.#m(l)}}static get defaultPropertiesToUpdate(){return[[i.AnnotationEditorParamsType.INK_THICKNESS,A._defaultThickness],[i.AnnotationEditorParamsType.INK_COLOR,A._defaultColor||n.AnnotationEditor._defaultLineColor],[i.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*A._defaultOpacity)]]}get propertiesToUpdate(){return[[i.AnnotationEditorParamsType.INK_THICKNESS,this.thickness||A._defaultThickness],[i.AnnotationEditorParamsType.INK_COLOR,this.color||A._defaultColor||n.AnnotationEditor._defaultLineColor],[i.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*(this.opacity??A._defaultOpacity))]]}#h(r){let l=x=>{this.thickness=x,this.#N()},m=this.thickness;this.addCommands({cmd:l.bind(this,r),undo:l.bind(this,m),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#b(r){let l=x=>{this.color=x,this.#C()},m=this.color;this.addCommands({cmd:l.bind(this,r),undo:l.bind(this,m),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#m(r){let l=x=>{this.opacity=x,this.#C()};r/=100;let m=this.opacity;this.addCommands({cmd:l.bind(this,r),undo:l.bind(this,m),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(this.#k(),this.#M()),this.isAttachedToDOM||(this.parent.add(this),this.#P()),this.#N()))}remove(){this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#a&&(clearTimeout(this.#a),this.#a=null),this.#u.disconnect(),this.#u=null,super.remove())}setParent(r){!this.parent&&r?this._uiManager.removeShouldRescale(this):this.parent&&r===null&&this._uiManager.addShouldRescale(this),super.setParent(r)}onScaleChanging(){let[r,l]=this.parentDimensions,m=this.width*r,x=this.height*l;this.setDimensions(m,x)}enableEditMode(){!this.#o&&this.canvas!==null&&(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",this.#s))}disableEditMode(){this.isInEditMode()&&this.canvas!==null&&(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",this.#s))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}#v(){let{parentRotation:r,parentDimensions:[l,m]}=this;switch(r){case 90:return[0,m,m,l];case 180:return[l,m,l,m];case 270:return[l,0,m,l];default:return[0,0,l,m]}}#S(){let{ctx:r,color:l,opacity:m,thickness:x,parentScale:D,scaleFactor:E}=this;r.lineWidth=x*D/E,r.lineCap="round",r.lineJoin="round",r.miterLimit=10,r.strokeStyle=`${l}${(0,o.opacityToHex)(m)}`}#_(r,l){this.canvas.addEventListener("contextmenu",a.noContextMenu),this.canvas.addEventListener("pointerleave",this.#n),this.canvas.addEventListener("pointermove",this.#i),this.canvas.addEventListener("pointerup",this.#r),this.canvas.removeEventListener("pointerdown",this.#s),this.isEditing=!0,this.#p||(this.#p=!0,this.#P(),this.thickness||=A._defaultThickness,this.color||=A._defaultColor||n.AnnotationEditor._defaultLineColor,this.opacity??=A._defaultOpacity),this.currentPath.push([r,l]),this.#d=!1,this.#S(),this.#g=()=>{this.#y(),this.#g&&window.requestAnimationFrame(this.#g)},window.requestAnimationFrame(this.#g)}#I(r,l){let[m,x]=this.currentPath.at(-1);if(this.currentPath.length>1&&r===m&&l===x)return;let D=this.currentPath,E=this.#c;D.push([r,l]),this.#d=!0,D.length<=2?(E.moveTo(...D[0]),E.lineTo(r,l)):(D.length===3&&(this.#c=E=new Path2D,E.moveTo(...D[0])),this.#E(E,...D.at(-3),...D.at(-2),r,l))}#w(){if(this.currentPath.length===0)return;let r=this.currentPath.at(-1);this.#c.lineTo(...r)}#x(r,l){this.#g=null,r=Math.min(Math.max(r,0),this.canvas.width),l=Math.min(Math.max(l,0),this.canvas.height),this.#I(r,l),this.#w();let m;if(this.currentPath.length!==1)m=this.#A();else{let E=[r,l];m=[[E,E.slice(),E.slice(),E]]}let x=this.#c,D=this.currentPath;this.currentPath=[],this.#c=new Path2D,this.addCommands({cmd:()=>{this.allRawPaths.push(D),this.paths.push(m),this.bezierPath2D.push(x),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(this.#k(),this.#M()),this.#N())},mustExec:!0})}#y(){if(!this.#d)return;this.#d=!1;let r=Math.ceil(this.thickness*this.parentScale),l=this.currentPath.slice(-3),m=l.map((E=>E[0])),x=l.map((E=>E[1])),{ctx:D}=(Math.min(...m),Math.max(...m),Math.min(...x),Math.max(...x),this);D.save(),D.clearRect(0,0,this.canvas.width,this.canvas.height);for(let E of this.bezierPath2D)D.stroke(E);D.stroke(this.#c),D.restore()}#E(r,l,m,x,D,E,M){let N=(l+x)/2,H=(m+D)/2,z=(x+E)/2,K=(D+M)/2;r.bezierCurveTo(N+2*(x-N)/3,H+2*(D-H)/3,z+2*(x-z)/3,K+2*(D-K)/3,z,K)}#A(){let r=this.currentPath;if(r.length<=2)return[[r[0],r[0],r.at(-1),r.at(-1)]];let l=[],m,[x,D]=r[0];for(m=1;m<r.length-2;m++){let[it,ot]=r[m],[X,j]=r[m+1],G=(it+X)/2,Y=(ot+j)/2,et=[x+2*(it-x)/3,D+2*(ot-D)/3],rt=[G+2*(it-G)/3,Y+2*(ot-Y)/3];l.push([[x,D],et,rt,[G,Y]]),[x,D]=[G,Y]}let[E,M]=r[m],[N,H]=r[m+1],z=[x+2*(E-x)/3,D+2*(M-D)/3],K=[N+2*(E-N)/3,H+2*(M-H)/3];return l.push([[x,D],z,K,[N,H]]),l}#C(){if(this.isEmpty()){this.#R();return}this.#S();let{canvas:r,ctx:l}=this;l.setTransform(1,0,0,1,0,0),l.clearRect(0,0,r.width,r.height),this.#R();for(let m of this.bezierPath2D)l.stroke(m)}commit(){this.#o||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),this.#o=!0,this.div.classList.add("disabled"),this.#N(!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(r){this._focusEventsAllowed&&(super.focusin(r),this.enableEditMode())}canvasPointerdown(r){r.button===0&&this.isInEditMode()&&!this.#o&&(this.setInForeground(),r.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),this.#_(r.offsetX,r.offsetY))}canvasPointermove(r){r.preventDefault(),this.#I(r.offsetX,r.offsetY)}canvasPointerup(r){r.preventDefault(),this.#T(r)}canvasPointerleave(r){this.#T(r)}#T(r){this.canvas.removeEventListener("pointerleave",this.#n),this.canvas.removeEventListener("pointermove",this.#i),this.canvas.removeEventListener("pointerup",this.#r),this.canvas.addEventListener("pointerdown",this.#s),this.#a&&clearTimeout(this.#a),this.#a=setTimeout((()=>{this.#a=null,this.canvas.removeEventListener("contextmenu",a.noContextMenu)}),10),this.#x(r.offsetX,r.offsetY),this.addToAnnotationStorage(),this.setInBackground()}#k(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")}#M(){this.#u=new ResizeObserver((r=>{let l=r[0].contentRect;l.width&&l.height&&this.setDimensions(l.width,l.height)})),this.#u.observe(this.div)}get isResizable(){return!this.isEmpty()&&this.#o}render(){if(this.div)return this.div;let r,l;this.width&&(r=this.x,l=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");let[m,x,D,E]=this.#v();if(this.setAt(m,x,0,0),this.setDims(D,E),this.#k(),this.width){let[M,N]=this.parentDimensions;this.setAspectRatio(this.width*M,this.height*N),this.setAt(r*M,l*N,this.width*M,this.height*N),this.#p=!0,this.#P(),this.setDims(this.width*M,this.height*N),this.#C(),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return this.#M(),this.div}#P(){if(!this.#p)return;let[r,l]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*r),this.canvas.height=Math.ceil(this.height*l),this.#R()}setDimensions(r,l){let m=Math.round(r),x=Math.round(l);if(this.#l===m&&this.#f===x)return;this.#l=m,this.#f=x,this.canvas.style.visibility="hidden";let[D,E]=this.parentDimensions;this.width=r/D,this.height=l/E,this.fixAndSetPosition(),this.#o&&this.#L(r,l),this.#P(),this.#C(),this.canvas.style.visibility="visible",this.fixDims()}#L(r,l){let m=this.#$(),x=(r-m)/this.#e,D=(l-m)/this.#t;this.scaleFactor=Math.min(x,D)}#R(){let r=this.#$()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+r,this.translationY*this.scaleFactor+r)}static#F(r){let l=new Path2D;for(let m=0,x=r.length;m<x;m++){let[D,E,M,N]=r[m];m===0&&l.moveTo(...D),l.bezierCurveTo(E[0],E[1],M[0],M[1],N[0],N[1])}return l}static#O(r,l,m){let[x,D,E,M]=l;switch(m){case 0:for(let N=0,H=r.length;N<H;N+=2)r[N]+=x,r[N+1]=M-r[N+1];break;case 90:for(let N=0,H=r.length;N<H;N+=2){let z=r[N];r[N]=r[N+1]+x,r[N+1]=z+D}break;case 180:for(let N=0,H=r.length;N<H;N+=2)r[N]=E-r[N],r[N+1]+=D;break;case 270:for(let N=0,H=r.length;N<H;N+=2){let z=r[N];r[N]=E-r[N+1],r[N+1]=M-z}break;default:throw new Error("Invalid rotation")}return r}static#V(r,l,m){let[x,D,E,M]=l;switch(m){case 0:for(let N=0,H=r.length;N<H;N+=2)r[N]-=x,r[N+1]=M-r[N+1];break;case 90:for(let N=0,H=r.length;N<H;N+=2){let z=r[N];r[N]=r[N+1]-D,r[N+1]=z-x}break;case 180:for(let N=0,H=r.length;N<H;N+=2)r[N]=E-r[N],r[N+1]-=D;break;case 270:for(let N=0,H=r.length;N<H;N+=2){let z=r[N];r[N]=M-r[N+1],r[N+1]=E-z}break;default:throw new Error("Invalid rotation")}return r}#G(r,l,m,x){let D=[],E=this.thickness/2,M=r*l+E,N=r*m+E;for(let H of this.paths){let z=[],K=[];for(let it=0,ot=H.length;it<ot;it++){let[X,j,G,Y]=H[it];if(X[0]===Y[0]&&X[1]===Y[1]&&ot===1){let c=r*X[0]+M,b=r*X[1]+N;z.push(c,b),K.push(c,b);break}let et=r*X[0]+M,rt=r*X[1]+N,ct=r*j[0]+M,st=r*j[1]+N,W=r*G[0]+M,w=r*G[1]+N,T=r*Y[0]+M,R=r*Y[1]+N;it===0&&(z.push(et,rt),K.push(et,rt)),z.push(ct,st,W,w,T,R),K.push(ct,st),it===ot-1&&K.push(T,R)}D.push({bezier:A.#O(z,x,this.rotation),points:A.#O(K,x,this.rotation)})}return D}#z(){let r=1/0,l=-1/0,m=1/0,x=-1/0;for(let D of this.paths)for(let[E,M,N,H]of D){let z=i.Util.bezierBoundingBox(...E,...M,...N,...H);r=Math.min(r,z[0]),m=Math.min(m,z[1]),l=Math.max(l,z[2]),x=Math.max(x,z[3])}return[r,m,l,x]}#$(){return this.#o?Math.ceil(this.thickness*this.parentScale):0}#N(r=!1){if(this.isEmpty())return;if(!this.#o){this.#C();return}let l=this.#z(),m=this.#$();this.#e=Math.max(n.AnnotationEditor.MIN_SIZE,l[2]-l[0]),this.#t=Math.max(n.AnnotationEditor.MIN_SIZE,l[3]-l[1]);let x=Math.ceil(m+this.#e*this.scaleFactor),D=Math.ceil(m+this.#t*this.scaleFactor),[E,M]=this.parentDimensions;this.width=x/E,this.height=D/M,this.setAspectRatio(x,D);let N=this.translationX,H=this.translationY;this.translationX=-l[0],this.translationY=-l[1],this.#P(),this.#C(),this.#l=x,this.#f=D,this.setDims(x,D);let z=r?m/this.scaleFactor/2:0;this.translate(N-this.translationX-z,H-this.translationY-z)}static deserialize(r,l,m){if(r instanceof h.InkAnnotationElement)return null;let x=super.deserialize(r,l,m);x.thickness=r.thickness,x.color=i.Util.makeHexColor(...r.color),x.opacity=r.opacity;let[D,E]=x.pageDimensions,M=x.width*D,N=x.height*E,H=x.parentScale,z=r.thickness/2;x.#o=!0,x.#l=Math.round(M),x.#f=Math.round(N);let{paths:K,rect:it,rotation:ot}=r;for(let{bezier:j}of K){j=A.#V(j,it,ot);let G=[];x.paths.push(G);let Y=H*(j[0]-z),et=H*(j[1]-z);for(let ct=2,st=j.length;ct<st;ct+=6){let W=H*(j[ct]-z),w=H*(j[ct+1]-z),T=H*(j[ct+2]-z),R=H*(j[ct+3]-z),c=H*(j[ct+4]-z),b=H*(j[ct+5]-z);G.push([[Y,et],[W,w],[T,R],[c,b]]),Y=c,et=b}let rt=this.#F(G);x.bezierPath2D.push(rt)}let X=x.#z();return x.#e=Math.max(n.AnnotationEditor.MIN_SIZE,X[2]-X[0]),x.#t=Math.max(n.AnnotationEditor.MIN_SIZE,X[3]-X[1]),x.#L(M,N),x}serialize(){if(this.isEmpty())return null;let r=this.getRect(0,0),l=n.AnnotationEditor._colorManager.convert(this.ctx.strokeStyle);return{annotationType:i.AnnotationEditorType.INK,color:l,thickness:this.thickness,opacity:this.opacity,paths:this.#G(this.scaleFactor/this.parentScale,this.translationX,this.translationY,r),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}}class _ extends n.AnnotationEditor{#t=null;#e=null;#i=null;#n=null;#r=null;#s="";#a=null;#c=null;#o=null;#d=!1;#p=!1;static _type="stamp";static _editorType=i.AnnotationEditorType.STAMP;constructor(r){super({...r,name:"stampEditor"}),this.#n=r.bitmapUrl,this.#r=r.bitmapFile}static initialize(r,l){n.AnnotationEditor.initialize(r,l)}static get supportedTypes(){return(0,i.shadow)(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((r=>`image/${r}`)))}static get supportedTypesStr(){return(0,i.shadow)(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(r){return this.supportedTypes.includes(r)}static paste(r,l){l.pasteEditor(i.AnnotationEditorType.STAMP,{bitmapFile:r.getAsFile()})}#u(r,l=!1){r?(this.#t=r.bitmap,l||(this.#e=r.id,this.#d=r.isSvg),r.file&&(this.#s=r.file.name),this.#g()):this.remove()}#l(){this.#i=null,this._uiManager.enableWaiting(!1),this.#a&&this.div.focus()}#f(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then((l=>this.#u(l,!0))).finally((()=>this.#l()));return}if(this.#n){let l=this.#n;this.#n=null,this._uiManager.enableWaiting(!0),this.#i=this._uiManager.imageManager.getFromUrl(l).then((m=>this.#u(m))).finally((()=>this.#l()));return}if(this.#r){let l=this.#r;this.#r=null,this._uiManager.enableWaiting(!0),this.#i=this._uiManager.imageManager.getFromFile(l).then((m=>this.#u(m))).finally((()=>this.#l()));return}let r=document.createElement("input");r.type="file",r.accept=_.supportedTypesStr,this.#i=new Promise((l=>{r.addEventListener("change",(async()=>{if(r.files&&r.files.length!==0){this._uiManager.enableWaiting(!0);let m=await this._uiManager.imageManager.getFromFile(r.files[0]);this.#u(m)}else this.remove();l()})),r.addEventListener("cancel",(()=>{this.remove(),l()}))})).finally((()=>this.#l())),r.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#a?.remove(),this.#a=null,this.#c?.disconnect(),this.#c=null,this.#o&&(clearTimeout(this.#o),this.#o=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),this.div!==null&&(this.#e&&this.#a===null&&this.#f(),this.isAttachedToDOM||this.parent.add(this))):this.#e&&this.#f()}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#i||this.#t||this.#n||this.#r||this.#e)}get isResizable(){return!0}render(){if(this.div)return this.div;let r,l;if(this.width&&(r=this.x,l=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),this.#t?this.#g():this.#f(),this.width){let[m,x]=this.parentDimensions;this.setAt(r*m,l*x,this.width*m,this.height*x)}return this.div}#g(){let{div:r}=this,{width:l,height:m}=this.#t,[x,D]=this.pageDimensions,E=.75;if(this.width)l=this.width*x,m=this.height*D;else if(l>E*x||m>E*D){let z=Math.min(E*x/l,E*D/m);l*=z,m*=z}let[M,N]=this.parentDimensions;this.setDims(l*M/x,m*N/D),this._uiManager.enableWaiting(!1);let H=this.#a=document.createElement("canvas");r.append(H),r.hidden=!1,this.#m(l,m),this.#S(),this.#p||(this.parent.addUndoableEditor(this),this.#p=!0),this._reportTelemetry({action:"inserted_image"}),this.#s&&H.setAttribute("aria-label",this.#s)}#h(r,l){let[m,x]=this.parentDimensions;this.width=r/m,this.height=l/x,this.setDims(r,l),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this.#o!==null&&clearTimeout(this.#o),this.#o=setTimeout((()=>{this.#o=null,this.#m(r,l)}),200)}#b(r,l){let{width:m,height:x}=this.#t,D=m,E=x,M=this.#t;for(;D>2*r||E>2*l;){let N=D,H=E;D>2*r&&(D=D>=16384?Math.floor(D/2)-1:Math.ceil(D/2)),E>2*l&&(E=E>=16384?Math.floor(E/2)-1:Math.ceil(E/2));let z=new OffscreenCanvas(D,E);z.getContext("2d").drawImage(M,0,0,N,H,0,0,D,E),M=z.transferToImageBitmap()}return M}#m(r,l){r=Math.ceil(r),l=Math.ceil(l);let m=this.#a;if(!m||m.width===r&&m.height===l)return;m.width=r,m.height=l;let x=this.#d?this.#t:this.#b(r,l);if(this._uiManager.hasMLManager&&!this.hasAltText()){let E=new OffscreenCanvas(r,l);E.getContext("2d").drawImage(x,0,0,x.width,x.height,0,0,r,l),E.convertToBlob().then((M=>{let N=new FileReader;N.onload=()=>{let H=N.result;this._uiManager.mlGuess({service:"image-to-text",request:{imageData:H}}).then((z=>{let K=z?.output||"";this.parent&&K&&!this.hasAltText()&&(this.altTextData={altText:K,decorative:!1})}))},N.readAsDataURL(M)}))}let D=m.getContext("2d");D.filter=this._uiManager.hcmFilter,D.drawImage(x,0,0,x.width,x.height,0,0,r,l)}getImageForAltText(){return this.#a}#v(r){if(r){if(this.#d){let m=this._uiManager.imageManager.getSvgUrl(this.#e);if(m)return m}let l=document.createElement("canvas");return{width:l.width,height:l.height}=this.#t,l.getContext("2d").drawImage(this.#t,0,0),l.toDataURL()}if(this.#d){let[l,m]=this.pageDimensions,x=Math.round(this.width*l*a.PixelsPerInch.PDF_TO_CSS_UNITS),D=Math.round(this.height*m*a.PixelsPerInch.PDF_TO_CSS_UNITS),E=new OffscreenCanvas(x,D);return E.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,x,D),E.transferToImageBitmap()}return structuredClone(this.#t)}#S(){this.#c=new ResizeObserver((r=>{let l=r[0].contentRect;l.width&&l.height&&this.#h(l.width,l.height)})),this.#c.observe(this.div)}static deserialize(r,l,m){if(r instanceof h.StampAnnotationElement)return null;let x=super.deserialize(r,l,m),{rect:D,bitmapUrl:E,bitmapId:M,isSvg:N,accessibilityData:H}=r;M&&m.imageManager.isValidId(M)?x.#e=M:x.#n=E,x.#d=N;let[z,K]=x.pageDimensions;return x.width=(D[2]-D[0])/z,x.height=(D[3]-D[1])/K,H&&(x.altTextData=H),x}serialize(r=!1,l=null){if(this.isEmpty())return null;let m={annotationType:i.AnnotationEditorType.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#d,structTreeParentId:this._structTreeParentId};if(r)return m.bitmapUrl=this.#v(!0),m.accessibilityData=this.altTextData,m;let{decorative:x,altText:D}=this.altTextData;if(!x&&D&&(m.accessibilityData={type:"Figure",alt:D}),l===null)return m;l.stamps||=new Map;let E=this.#d?(m.rect[2]-m.rect[0])*(m.rect[3]-m.rect[1]):null;if(l.stamps.has(this.#e)){if(this.#d){let M=l.stamps.get(this.#e);E>M.area&&(M.area=E,M.serialized.bitmap.close(),M.serialized.bitmap=this.#v(!1))}}else l.stamps.set(this.#e,{area:E,serialized:m}),m.bitmap=this.#v(!1);return m}}class d{#t;#e=!1;#i=null;#n=null;#r=null;#s=null;#a=null;#c=new Map;#o=!1;#d=!1;#p=!1;#u=null;#l;static _initialized=!1;static#f=new Map([g,A,_,f].map((r=>[r._editorType,r])));constructor({uiManager:r,pageIndex:l,div:m,accessibilityManager:x,annotationLayer:D,drawLayer:E,textLayer:M,viewport:N,l10n:H}){let z=[...d.#f.values()];if(!d._initialized){d._initialized=!0;for(let K of z)K.initialize(H,r)}r.registerEditorTypes(z),this.#l=r,this.pageIndex=l,this.div=m,this.#t=x,this.#i=D,this.viewport=N,this.#u=M,this.drawLayer=E,this.#l.addLayer(this)}get isEmpty(){return this.#c.size===0}get isInvisible(){return this.isEmpty&&this.#l.getMode()===i.AnnotationEditorType.NONE}updateToolbar(r){this.#l.updateToolbar(r)}updateMode(r=this.#l.getMode()){switch(this.#v(),r){case i.AnnotationEditorType.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case i.AnnotationEditorType.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case i.AnnotationEditorType.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:l}=this.div;for(let m of d.#f.values())l.toggle(`${m._type}Editing`,r===m._editorType);this.div.hidden=!1}hasTextLayer(r){return r===this.#u?.div}addInkEditorIfNeeded(r){if(this.#l.getMode()===i.AnnotationEditorType.INK){if(!r){for(let l of this.#c.values())if(l.isEmpty()){l.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(r){this.#l.setEditingState(r)}addCommands(r){this.#l.addCommands(r)}togglePointerEvents(r=!1){this.div.classList.toggle("disabled",!r)}toggleAnnotationLayerPointerEvents(r=!1){this.#i?.div.classList.toggle("disabled",!r)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);let r=new Set;for(let m of this.#c.values())m.enableEditing(),m.annotationElementId&&r.add(m.annotationElementId);if(!this.#i)return;let l=this.#i.getEditableAnnotations();for(let m of l){if(m.hide(),this.#l.isDeletedAnnotationElement(m.data.id)||r.has(m.data.id))continue;let x=this.deserialize(m);x&&(this.addOrRebuild(x),x.enableEditing())}}disable(){this.#p=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let r=new Set;for(let m of this.#c.values())m.disableEditing(),m.annotationElementId&&m.serialize()===null?(this.getEditableAnnotation(m.annotationElementId)?.show(),m.remove()):r.add(m.annotationElementId);if(this.#i){let m=this.#i.getEditableAnnotations();for(let x of m){let{id:D}=x.data;r.has(D)||this.#l.isDeletedAnnotationElement(D)||x.show()}}this.#v(),this.isEmpty&&(this.div.hidden=!0);let{classList:l}=this.div;for(let m of d.#f.values())l.remove(`${m._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#p=!1}getEditableAnnotation(r){return this.#i?.getEditableAnnotation(r)||null}setActiveEditor(r){this.#l.getActive()!==r&&this.#l.setActiveEditor(r)}enableTextSelection(){this.div.tabIndex=-1,this.#u?.div&&!this.#s&&(this.#s=this.#g.bind(this),this.#u.div.addEventListener("pointerdown",this.#s),this.#u.div.classList.add("highlighting"))}disableTextSelection(){this.div.tabIndex=0,this.#u?.div&&this.#s&&(this.#u.div.removeEventListener("pointerdown",this.#s),this.#s=null,this.#u.div.classList.remove("highlighting"))}#g(r){if(this.#l.unselectAll(),r.target===this.#u.div){let{isMac:l}=i.FeatureTest.platform;if(r.button!==0||r.ctrlKey&&l)return;this.#l.showAllEditors("highlight",!0,!0),this.#u.div.classList.add("free"),f.startHighlighting(this,this.#l.direction==="ltr",r),this.#u.div.addEventListener("pointerup",(()=>{this.#u.div.classList.remove("free")}),{once:!0}),r.preventDefault()}}enableClick(){this.#r||(this.#r=this.pointerdown.bind(this),this.#n=this.pointerup.bind(this),this.div.addEventListener("pointerdown",this.#r),this.div.addEventListener("pointerup",this.#n))}disableClick(){this.#r&&(this.div.removeEventListener("pointerdown",this.#r),this.div.removeEventListener("pointerup",this.#n),this.#r=null,this.#n=null)}attach(r){this.#c.set(r.id,r);let{annotationElementId:l}=r;l&&this.#l.isDeletedAnnotationElement(l)&&this.#l.removeDeletedAnnotationElement(r)}detach(r){this.#c.delete(r.id),this.#t?.removePointerInTextLayer(r.contentDiv),!this.#p&&r.annotationElementId&&this.#l.addDeletedAnnotationElement(r)}remove(r){this.detach(r),this.#l.removeEditor(r),r.div.remove(),r.isAttachedToDOM=!1,this.#d||this.addInkEditorIfNeeded(!1)}changeParent(r){r.parent!==this&&(r.annotationElementId&&(this.#l.addDeletedAnnotationElement(r.annotationElementId),n.AnnotationEditor.deleteAnnotationElement(r),r.annotationElementId=null),this.attach(r),r.parent?.detach(r),r.setParent(this),r.div&&r.isAttachedToDOM&&(r.div.remove(),this.div.append(r.div)))}add(r){if(r.parent!==this||!r.isAttachedToDOM){if(this.changeParent(r),this.#l.addEditor(r),this.attach(r),!r.isAttachedToDOM){let l=r.render();this.div.append(l),r.isAttachedToDOM=!0}r.fixAndSetPosition(),r.onceAdded(),this.#l.addToAnnotationStorage(r),r._reportTelemetry(r.telemetryInitialData)}}moveEditorInDOM(r){if(!r.isAttachedToDOM)return;let{activeElement:l}=document;r.div.contains(l)&&!this.#a&&(r._focusEventsAllowed=!1,this.#a=setTimeout((()=>{this.#a=null,r.div.contains(document.activeElement)?r._focusEventsAllowed=!0:(r.div.addEventListener("focusin",(()=>{r._focusEventsAllowed=!0}),{once:!0}),l.focus())}),0)),r._structTreeParentId=this.#t?.moveElementInDOM(this.div,r.div,r.contentDiv,!0)}addOrRebuild(r){r.needsToBeRebuilt()?(r.parent||=this,r.rebuild(),r.show()):this.add(r)}addUndoableEditor(r){this.addCommands({cmd:()=>r._uiManager.rebuild(r),undo:()=>{r.remove()},mustExec:!1})}getNextId(){return this.#l.getId()}get#h(){return d.#f.get(this.#l.getMode())}#b(r){let l=this.#h;return l?new l.prototype.constructor(r):null}canCreateNewEmptyEditor(){return this.#h?.canCreateNewEmptyEditor()}pasteEditor(r,l){this.#l.updateToolbar(r),this.#l.updateMode(r);let{offsetX:m,offsetY:x}=this.#m(),D=this.getNextId(),E=this.#b({parent:this,id:D,x:m,y:x,uiManager:this.#l,isCentered:!0,...l});E&&this.add(E)}deserialize(r){return d.#f.get(r.annotationType??r.annotationEditorType)?.deserialize(r,this,this.#l)||null}createAndAddNewEditor(r,l,m={}){let x=this.getNextId(),D=this.#b({parent:this,id:x,x:r.offsetX,y:r.offsetY,uiManager:this.#l,isCentered:l,...m});return D&&this.add(D),D}#m(){let{x:r,y:l,width:m,height:x}=this.div.getBoundingClientRect(),D=Math.max(0,r),E=Math.max(0,l),M=(D+Math.min(window.innerWidth,r+m))/2-r,N=(E+Math.min(window.innerHeight,l+x))/2-l,[H,z]=this.viewport.rotation%180==0?[M,N]:[N,M];return{offsetX:H,offsetY:z}}addNewEditor(){this.createAndAddNewEditor(this.#m(),!0)}setSelected(r){this.#l.setSelected(r)}toggleSelected(r){this.#l.toggleSelected(r)}isSelected(r){return this.#l.isSelected(r)}unselect(r){this.#l.unselect(r)}pointerup(r){let{isMac:l}=i.FeatureTest.platform;!(r.button!==0||r.ctrlKey&&l)&&r.target===this.div&&this.#o&&(this.#o=!1,this.#e?this.#l.getMode()!==i.AnnotationEditorType.STAMP?this.createAndAddNewEditor(r,!1):this.#l.unselectAll():this.#e=!0)}pointerdown(r){if(this.#l.getMode()===i.AnnotationEditorType.HIGHLIGHT&&this.enableTextSelection(),this.#o){this.#o=!1;return}let{isMac:l}=i.FeatureTest.platform;if(r.button!==0||r.ctrlKey&&l||r.target!==this.div)return;this.#o=!0;let m=this.#l.getActive();this.#e=!m||m.isEmpty()}findNewParent(r,l,m){let x=this.#l.findParent(l,m);return x===null||x===this?!1:(x.changeParent(r),!0)}destroy(){this.#l.getActive()?.parent===this&&(this.#l.commitOrRemove(),this.#l.setActiveEditor(null)),this.#a&&(clearTimeout(this.#a),this.#a=null);for(let r of this.#c.values())this.#t?.removePointerInTextLayer(r.contentDiv),r.setParent(null),r.isAttachedToDOM=!1,r.div.remove();this.div=null,this.#c.clear(),this.#l.removeLayer(this)}#v(){this.#d=!0;for(let r of this.#c.values())r.isEmpty()&&r.remove();this.#d=!1}render({viewport:r}){this.viewport=r,(0,a.setLayerDimensions)(this.div,r);for(let l of this.#l.getEditors(this.pageIndex))this.add(l),l.rebuild();this.updateMode()}update({viewport:r}){this.#l.commitOrRemove(),this.#v();let l=this.viewport.rotation,m=r.rotation;if(this.viewport=r,(0,a.setLayerDimensions)(this.div,{rotation:m}),l!==m)for(let x of this.#c.values())x.rotate(m);this.addInkEditorIfNeeded(!1)}get pageDimensions(){let{pageWidth:r,pageHeight:l}=this.viewport.rawDims;return[r,l]}get scale(){return this.#l.viewParameters.realScale}}},259:(s,t,e)=>{e.d(t,{ColorPicker:()=>h});var i=e(292),n=e(830),o=e(419);class h{#t=this.#g.bind(this);#e=this.#b.bind(this);#i=null;#n=null;#r;#s=null;#a=!1;#c=!1;#o=null;#d;#p=null;#u;static get _keyboardManager(){return(0,i.shadow)(this,"_keyboardManager",new n.KeyboardManager([[["Escape","mac+Escape"],h.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],h.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],h.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],h.prototype._moveToPrevious],[["Home","mac+Home"],h.prototype._moveToBeginning],[["End","mac+End"],h.prototype._moveToEnd]]))}constructor({editor:g=null,uiManager:v=null}){g?(this.#c=!1,this.#u=i.AnnotationEditorParamsType.HIGHLIGHT_COLOR,this.#o=g):(this.#c=!0,this.#u=i.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR),this.#p=g?._uiManager||v,this.#d=this.#p._eventBus,this.#r=g?.color||this.#p?.highlightColors.values().next().value||"#FFFF98"}renderButton(){let g=this.#i=document.createElement("button");g.className="colorPicker",g.tabIndex="0",g.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),g.setAttribute("aria-haspopup",!0),g.addEventListener("click",this.#h.bind(this)),g.addEventListener("keydown",this.#t);let v=this.#n=document.createElement("span");return v.className="swatch",v.setAttribute("aria-hidden",!0),v.style.backgroundColor=this.#r,g.append(v),g}renderMainDropdown(){let g=this.#s=this.#l();return g.setAttribute("aria-orientation","horizontal"),g.setAttribute("aria-labelledby","highlightColorPickerLabel"),g}#l(){let g=document.createElement("div");g.addEventListener("contextmenu",o.noContextMenu),g.className="dropdown",g.role="listbox",g.setAttribute("aria-multiselectable",!1),g.setAttribute("aria-orientation","vertical"),g.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(let[v,p]of this.#p.highlightColors){let a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",p),a.title=v,a.setAttribute("data-l10n-id",`pdfjs-editor-colorpicker-${v}`);let f=document.createElement("span");a.append(f),f.className="swatch",f.style.backgroundColor=p,a.setAttribute("aria-selected",p===this.#r),a.addEventListener("click",this.#f.bind(this,p)),g.append(a)}return g.addEventListener("keydown",this.#t),g}#f(g,v){v.stopPropagation(),this.#d.dispatch("switchannotationeditorparams",{source:this,type:this.#u,value:g})}_colorSelectFromKeyboard(g){if(g.target===this.#i){this.#h(g);return}let v=g.target.getAttribute("data-color");v&&this.#f(v,g)}_moveToNext(g){this.#m?g.target!==this.#i?g.target.nextSibling?.focus():this.#s.firstChild?.focus():this.#h(g)}_moveToPrevious(g){g.target!==this.#s?.firstChild&&g.target!==this.#i?(this.#m||this.#h(g),g.target.previousSibling?.focus()):this.#m&&this._hideDropdownFromKeyboard()}_moveToBeginning(g){this.#m?this.#s.firstChild?.focus():this.#h(g)}_moveToEnd(g){this.#m?this.#s.lastChild?.focus():this.#h(g)}#g(g){h._keyboardManager.exec(this,g)}#h(g){if(this.#m){this.hideDropdown();return}if(this.#a=g.detail===0,window.addEventListener("pointerdown",this.#e),this.#s){this.#s.classList.remove("hidden");return}let v=this.#s=this.#l();this.#i.append(v)}#b(g){this.#s?.contains(g.target)||this.hideDropdown()}hideDropdown(){this.#s?.classList.add("hidden"),window.removeEventListener("pointerdown",this.#e)}get#m(){return this.#s&&!this.#s.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#c||(this.#m?(this.hideDropdown(),this.#i.focus({preventScroll:!0,focusVisible:this.#a})):this.#o?.unselect())}updateColor(g){if(this.#n&&(this.#n.style.backgroundColor=g),!this.#s)return;let v=this.#p.highlightColors.values();for(let p of this.#s.children)p.setAttribute("aria-selected",v.next().value===g)}destroy(){this.#i?.remove(),this.#i=null,this.#n=null,this.#s?.remove(),this.#s=null}}},310:(s,t,e)=>{e.d(t,{AnnotationEditor:()=>g});var i=e(830),n=e(292),o=e(419);class h{#t="";#e=!1;#i=null;#n=null;#r=null;#s=!1;#a=null;static _l10nPromise=null;constructor(a){this.#a=a}static initialize(a){h._l10nPromise||=a}async render(){let a=this.#i=document.createElement("button");a.className="altText";let f=await h._l10nPromise.get("pdfjs-editor-alt-text-button-label");a.textContent=f,a.setAttribute("aria-label",f),a.tabIndex="0",a.addEventListener("contextmenu",o.noContextMenu),a.addEventListener("pointerdown",(_=>_.stopPropagation()));let A=_=>{_.preventDefault(),this.#a._uiManager.editAltText(this.#a)};return a.addEventListener("click",A,{capture:!0}),a.addEventListener("keydown",(_=>{_.target===a&&_.key==="Enter"&&(this.#s=!0,A(_))})),await this.#c(),a}finish(){this.#i&&(this.#i.focus({focusVisible:this.#s}),this.#s=!1)}isEmpty(){return!this.#t&&!this.#e}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:a,decorative:f}){(this.#t!==a||this.#e!==f)&&(this.#t=a,this.#e=f,this.#c())}toggle(a=!1){this.#i&&(!a&&this.#r&&(clearTimeout(this.#r),this.#r=null),this.#i.disabled=!a)}destroy(){this.#i?.remove(),this.#i=null,this.#n=null}async#c(){let a=this.#i;if(!a)return;if(!this.#t&&!this.#e){a.classList.remove("done"),this.#n?.remove();return}a.classList.add("done"),h._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then((_=>{a.setAttribute("aria-label",_)}));let f=this.#n;if(!f){this.#n=f=document.createElement("span"),f.className="tooltip",f.setAttribute("role","tooltip");let _=f.id=`alt-text-tooltip-${this.#a.id}`;a.setAttribute("aria-describedby",_);let d=100;a.addEventListener("mouseenter",(()=>{this.#r=setTimeout((()=>{this.#r=null,this.#n.classList.add("show"),this.#a._reportTelemetry({action:"alt_text_tooltip"})}),d)})),a.addEventListener("mouseleave",(()=>{this.#r&&(clearTimeout(this.#r),this.#r=null),this.#n?.classList.remove("show")}))}f.innerText=this.#e?await h._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#t,f.parentNode||a.append(f),this.#a.getImageForAltText()?.setAttribute("aria-describedby",f.id)}}var u=e(362);class g{#t=null;#e=null;#i=!1;#n=!1;#r=null;#s=null;#a=this.focusin.bind(this);#c=this.focusout.bind(this);#o=null;#d="";#p=!1;#u=null;#l=!1;#f=!1;#g=!1;#h=null;#b=0;#m=0;#v=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#S=!1;#_=g._zIndex++;static _borderLineWidth=-1;static _colorManager=new i.ColorManager;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let a=g.prototype._resizeWithKeyboard,f=i.AnnotationEditorUIManager.TRANSLATE_SMALL,A=i.AnnotationEditorUIManager.TRANSLATE_BIG;return(0,n.shadow)(this,"_resizerKeyboardManager",new i.KeyboardManager([[["ArrowLeft","mac+ArrowLeft"],a,{args:[-f,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],a,{args:[-A,0]}],[["ArrowRight","mac+ArrowRight"],a,{args:[f,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],a,{args:[A,0]}],[["ArrowUp","mac+ArrowUp"],a,{args:[0,-f]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],a,{args:[0,-A]}],[["ArrowDown","mac+ArrowDown"],a,{args:[0,f]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],a,{args:[0,A]}],[["Escape","mac+Escape"],g.prototype._stopResizingWithKeyboard]]))}constructor(a){this.constructor===g&&(0,n.unreachable)("Cannot initialize AnnotationEditor."),this.parent=a.parent,this.id=a.id,this.width=this.height=null,this.pageIndex=a.parent.pageIndex,this.name=a.name,this.div=null,this._uiManager=a.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=a.isCentered,this._structTreeParentId=null;let{rotation:f,rawDims:{pageWidth:A,pageHeight:_,pageX:d,pageY:y}}=this.parent.viewport;this.rotation=f,this.pageRotation=(360+f-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[A,_],this.pageTranslation=[d,y];let[r,l]=this.parentDimensions;this.x=a.x/r,this.y=a.y/l,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return(0,n.shadow)(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(a){let f=new v({id:a.parent.getNextId(),parent:a.parent,uiManager:a._uiManager});f.annotationElementId=a.annotationElementId,f.deleted=!0,f._uiManager.addToAnnotationStorage(f)}static initialize(a,f,A){if(g._l10nPromise||=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map((d=>[d,a.get(d.replaceAll(/([A-Z])/g,(y=>`-${y.toLowerCase()}`)))]))),A?.strings)for(let d of A.strings)g._l10nPromise.set(d,a.get(d));if(g._borderLineWidth!==-1)return;let _=getComputedStyle(document.documentElement);g._borderLineWidth=parseFloat(_.getPropertyValue("--outline-width"))||0}static updateDefaultParams(a,f){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(a){return!1}static paste(a,f){(0,n.unreachable)("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#S}set _isDraggable(a){this.#S=a,this.div?.classList.toggle("draggable",a)}get isEnterHandled(){return!0}center(){let[a,f]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*f/(2*a),this.y+=this.width*a/(2*f);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*f/(2*a),this.y-=this.width*a/(2*f);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(a){this._uiManager.addCommands(a)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#_}setParent(a){a!==null?(this.pageIndex=a.pageIndex,this.pageDimensions=a.pageDimensions):this.#F(),this.parent=a}focusin(a){this._focusEventsAllowed&&(this.#p?this.#p=!1:this.parent.setSelected(this))}focusout(a){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;a.relatedTarget?.closest(`#${this.id}`)||(a.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(a,f,A,_){let[d,y]=this.parentDimensions;[A,_]=this.screenToPageTranslation(A,_),this.x=(a+A)/d,this.y=(f+_)/y,this.fixAndSetPosition()}#I([a,f],A,_){[A,_]=this.screenToPageTranslation(A,_),this.x+=A/a,this.y+=_/f,this.fixAndSetPosition()}translate(a,f){this.#I(this.parentDimensions,a,f)}translateInPage(a,f){this.#u||=[this.x,this.y],this.#I(this.pageDimensions,a,f),this.div.scrollIntoView({block:"nearest"})}drag(a,f){this.#u||=[this.x,this.y];let[A,_]=this.parentDimensions;if(this.x+=a/A,this.y+=f/_,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:m,y:x}=this.div.getBoundingClientRect();this.parent.findNewParent(this,m,x)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:d,y}=this,[r,l]=this.getBaseTranslation();d+=r,y+=l,this.div.style.left=`${(100*d).toFixed(2)}%`,this.div.style.top=`${(100*y).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#u&&(this.#u[0]!==this.x||this.#u[1]!==this.y)}getBaseTranslation(){let[a,f]=this.parentDimensions,{_borderLineWidth:A}=g,_=A/a,d=A/f;switch(this.rotation){case 90:return[-_,d];case 180:return[_,d];case 270:return[_,-d];default:return[-_,-d]}}get _mustFixPosition(){return!0}fixAndSetPosition(a=this.rotation){let[f,A]=this.pageDimensions,{x:_,y:d,width:y,height:r}=this;if(y*=f,r*=A,_*=f,d*=A,this._mustFixPosition)switch(a){case 0:_=Math.max(0,Math.min(f-y,_)),d=Math.max(0,Math.min(A-r,d));break;case 90:_=Math.max(0,Math.min(f-r,_)),d=Math.min(A,Math.max(y,d));break;case 180:_=Math.min(f,Math.max(y,_)),d=Math.min(A,Math.max(r,d));break;case 270:_=Math.min(f,Math.max(r,_)),d=Math.max(0,Math.min(A-y,d))}this.x=_/=f,this.y=d/=A;let[l,m]=this.getBaseTranslation();_+=l,d+=m;let{style:x}=this.div;x.left=`${(100*_).toFixed(2)}%`,x.top=`${(100*d).toFixed(2)}%`,this.moveInDOM()}static#w(a,f,A){switch(A){case 90:return[f,-a];case 180:return[-a,-f];case 270:return[-f,a];default:return[a,f]}}screenToPageTranslation(a,f){return g.#w(a,f,this.parentRotation)}pageTranslationToScreen(a,f){return g.#w(a,f,360-this.parentRotation)}#x(a){switch(a){case 90:{let[f,A]=this.pageDimensions;return[0,-f/A,A/f,0]}case 180:return[-1,0,0,-1];case 270:{let[f,A]=this.pageDimensions;return[0,f/A,-A/f,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:a,pageDimensions:[f,A]}=this,_=f*a,d=A*a;return n.FeatureTest.isCSSRoundSupported?[Math.round(_),Math.round(d)]:[_,d]}setDims(a,f){let[A,_]=this.parentDimensions;this.div.style.width=`${(100*a/A).toFixed(2)}%`,this.#n||(this.div.style.height=`${(100*f/_).toFixed(2)}%`)}fixDims(){let{style:a}=this.div,{height:f,width:A}=a,_=A.endsWith("%"),d=!this.#n&&f.endsWith("%");if(_&&d)return;let[y,r]=this.parentDimensions;_||(a.width=`${(100*parseFloat(A)/y).toFixed(2)}%`),this.#n||d||(a.height=`${(100*parseFloat(f)/r).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#y(){if(this.#r)return;this.#r=document.createElement("div"),this.#r.classList.add("resizers");let a=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"];for(let f of a){let A=document.createElement("div");this.#r.append(A),A.classList.add("resizer",f),A.setAttribute("data-resizer-name",f),A.addEventListener("pointerdown",this.#E.bind(this,f)),A.addEventListener("contextmenu",o.noContextMenu),A.tabIndex=-1}this.div.prepend(this.#r)}#E(a,f){f.preventDefault();let{isMac:A}=n.FeatureTest.platform;if(f.button!==0||f.ctrlKey&&A)return;this.#e?.toggle(!1);let _=this.#C.bind(this,a),d=this._isDraggable;this._isDraggable=!1;let y={passive:!0,capture:!0};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",_,y);let r=this.x,l=this.y,m=this.width,x=this.height,D=this.parent.div.style.cursor,E=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(f.target).cursor;let M=()=>{this.parent.togglePointerEvents(!0),this.#e?.toggle(!0),this._isDraggable=d,window.removeEventListener("pointerup",M),window.removeEventListener("blur",M),window.removeEventListener("pointermove",_,y),this.parent.div.style.cursor=D,this.div.style.cursor=E,this.#A(r,l,m,x)};window.addEventListener("pointerup",M),window.addEventListener("blur",M)}#A(a,f,A,_){let d=this.x,y=this.y,r=this.width,l=this.height;d===a&&y===f&&r===A&&l===_||this.addCommands({cmd:()=>{this.width=r,this.height=l,this.x=d,this.y=y;let[m,x]=this.parentDimensions;this.setDims(m*r,x*l),this.fixAndSetPosition()},undo:()=>{this.width=A,this.height=_,this.x=a,this.y=f;let[m,x]=this.parentDimensions;this.setDims(m*A,x*_),this.fixAndSetPosition()},mustExec:!0})}#C(a,f){let[A,_]=this.parentDimensions,d=this.x,y=this.y,r=this.width,l=this.height,m=g.MIN_SIZE/A,x=g.MIN_SIZE/_,D=C=>Math.round(1e4*C)/1e4,E=this.#x(this.rotation),M=(C,k)=>[E[0]*C+E[2]*k,E[1]*C+E[3]*k],N=this.#x(360-this.rotation),H,z,K=!1,it=!1;switch(a){case"topLeft":K=!0,H=(C,k)=>[0,0],z=(C,k)=>[C,k];break;case"topMiddle":H=(C,k)=>[C/2,0],z=(C,k)=>[C/2,k];break;case"topRight":K=!0,H=(C,k)=>[C,0],z=(C,k)=>[0,k];break;case"middleRight":it=!0,H=(C,k)=>[C,k/2],z=(C,k)=>[0,k/2];break;case"bottomRight":K=!0,H=(C,k)=>[C,k],z=(C,k)=>[0,0];break;case"bottomMiddle":H=(C,k)=>[C/2,k],z=(C,k)=>[C/2,0];break;case"bottomLeft":K=!0,H=(C,k)=>[0,k],z=(C,k)=>[C,0];break;case"middleLeft":it=!0,H=(C,k)=>[0,k/2],z=(C,k)=>[C,k/2]}let ot=H(r,l),X=z(r,l),j=M(...X),G=D(d+j[0]),Y=D(y+j[1]),et=1,rt=1,[ct,st]=this.screenToPageTranslation(f.movementX,f.movementY);[ct,st]=(W=ct/A,w=st/_,[N[0]*W+N[2]*w,N[1]*W+N[3]*w]);var W,w;if(K){let C=Math.hypot(r,l);et=rt=Math.max(Math.min(Math.hypot(X[0]-ot[0]-ct,X[1]-ot[1]-st)/C,1/r,1/l),m/r,x/l)}else it?et=Math.max(m,Math.min(1,Math.abs(X[0]-ot[0]-ct)))/r:rt=Math.max(x,Math.min(1,Math.abs(X[1]-ot[1]-st)))/l;let T=D(r*et),R=D(l*rt);j=M(...z(T,R));let c=G-j[0],b=Y-j[1];this.width=T,this.height=R,this.x=c,this.y=b,this.setDims(A*T,_*R),this.fixAndSetPosition()}altTextFinish(){this.#e?.finish()}async addEditToolbar(){return this.#o||this.#f?this.#o:(this.#o=new u.EditorToolbar(this),this.div.append(this.#o.render()),this.#e&&this.#o.addAltTextButton(await this.#e.render()),this.#o)}removeEditToolbar(){this.#o&&(this.#o.remove(),this.#o=null,this.#e?.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#e||(h.initialize(g._l10nPromise),this.#e=new h(this),await this.addEditToolbar())}get altTextData(){return this.#e?.data}set altTextData(a){this.#e&&(this.#e.data=a)}hasAltText(){return!this.#e?.isEmpty()}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#i?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.div.addEventListener("focusin",this.#a),this.div.addEventListener("focusout",this.#c);let[a,f]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*f/a).toFixed(2)}%`,this.div.style.maxHeight=`${(100*a/f).toFixed(2)}%`);let[A,_]=this.getInitialTranslation();return this.translate(A,_),(0,i.bindEvents)(this,this.div,["pointerdown"]),this.div}pointerdown(a){let{isMac:f}=n.FeatureTest.platform;a.button!==0||a.ctrlKey&&f?a.preventDefault():(this.#p=!0,this._isDraggable?this.#k(a):this.#T(a))}#T(a){let{isMac:f}=n.FeatureTest.platform;a.ctrlKey&&!f||a.shiftKey||a.metaKey&&f?this.parent.toggleSelected(this):this.parent.setSelected(this)}#k(a){let f=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let A,_;f&&(this.div.classList.add("moving"),A={passive:!0,capture:!0},this.#b=a.clientX,this.#m=a.clientY,_=y=>{let{clientX:r,clientY:l}=y,[m,x]=this.screenToPageTranslation(r-this.#b,l-this.#m);this.#b=r,this.#m=l,this._uiManager.dragSelectedEditors(m,x)},window.addEventListener("pointermove",_,A));let d=()=>{window.removeEventListener("pointerup",d),window.removeEventListener("blur",d),f&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",_,A)),this.#p=!1,this._uiManager.endDragSession()||this.#T(a)};window.addEventListener("pointerup",d),window.addEventListener("blur",d)}moveInDOM(){this.#h&&clearTimeout(this.#h),this.#h=setTimeout((()=>{this.#h=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(a,f,A){a.changeParent(this),this.x=f,this.y=A,this.fixAndSetPosition()}getRect(a,f,A=this.rotation){let _=this.parentScale,[d,y]=this.pageDimensions,[r,l]=this.pageTranslation,m=a/_,x=f/_,D=this.x*d,E=this.y*y,M=this.width*d,N=this.height*y;switch(A){case 0:return[D+m+r,y-E-x-N+l,D+m+M+r,y-E-x+l];case 90:return[D+x+r,y-E+m+l,D+x+N+r,y-E+m+M+l];case 180:return[D-m-M+r,y-E+x+l,D-m+r,y-E+x+N+l];case 270:return[D-x-N+r,y-E-m-M+l,D-x+r,y-E-m+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(a,f){let[A,_,d,y]=a,r=d-A,l=y-_;switch(this.rotation){case 0:return[A,f-y,r,l];case 90:return[A,f-_,l,r];case 180:return[d,f-_,r,l];case 270:return[d,f-y,l,r];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#f=!0}disableEditMode(){this.#f=!1}isInEditMode(){return this.#f}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){this.div?.addEventListener("focusin",this.#a),this.div?.addEventListener("focusout",this.#c)}rotate(a){}serialize(a=!1,f=null){(0,n.unreachable)("An editor must be serializable")}static deserialize(a,f,A){let _=new this.prototype.constructor({parent:f,id:f.getNextId(),uiManager:A});_.rotation=a.rotation;let[d,y]=_.pageDimensions,[r,l,m,x]=_.getRectInCurrentCoords(a.rect,y);return _.x=r/d,_.y=l/y,_.width=m/d,_.height=x/y,_}remove(){if(this.div.removeEventListener("focusin",this.#a),this.div.removeEventListener("focusout",this.#c),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#h&&(clearTimeout(this.#h),this.#h=null),this.#F(),this.removeEditToolbar(),this.#v){for(let a of this.#v.values())clearTimeout(a);this.#v=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#y(),this.#r.classList.remove("hidden"),(0,i.bindEvents)(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(a){if(!this.isResizable||a.target!==this.div||a.key!=="Enter")return;this._uiManager.setSelected(this),this.#s={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let f=this.#r.children;if(!this.#t){this.#t=Array.from(f);let y=this.#M.bind(this),r=this.#P.bind(this);for(let l of this.#t){let m=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",y),l.addEventListener("blur",r),l.addEventListener("focus",this.#L.bind(this,m)),g._l10nPromise.get(`pdfjs-editor-resizer-label-${m}`).then((x=>l.setAttribute("aria-label",x)))}}let A=this.#t[0],_=0;for(let y of f){if(y===A)break;_++}let d=(360-this.rotation+this.parentRotation)%360/90*(this.#t.length/4);if(d!==_){if(d<_)for(let r=0;r<_-d;r++)this.#r.append(this.#r.firstChild);else if(d>_)for(let r=0;r<d-_;r++)this.#r.firstChild.before(this.#r.lastChild);let y=0;for(let r of f){let l=this.#t[y++].getAttribute("data-resizer-name");g._l10nPromise.get(`pdfjs-editor-resizer-label-${l}`).then((m=>r.setAttribute("aria-label",m)))}}this.#R(0),this.#g=!0,this.#r.firstChild.focus({focusVisible:!0}),a.preventDefault(),a.stopImmediatePropagation()}#M(a){g._resizerKeyboardManager.exec(this,a)}#P(a){this.#g&&a.relatedTarget?.parentNode!==this.#r&&this.#F()}#L(a){this.#d=this.#g?a:""}#R(a){if(this.#t)for(let f of this.#t)f.tabIndex=a}_resizeWithKeyboard(a,f){this.#g&&this.#C(this.#d,{movementX:a,movementY:f})}#F(){if(this.#g=!1,this.#R(-1),this.#s){let{savedX:a,savedY:f,savedWidth:A,savedHeight:_}=this.#s;this.#A(a,f,A,_),this.#s=null}}_stopResizingWithKeyboard(){this.#F(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this.#o?this.#o?.show():this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this.#o?.show()}))}unselect(){this.#r?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this.#o?.hide()}updateParams(a,f){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#l}set isEditing(a){this.#l=a,this.parent&&(a?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(a,f){this.#n=!0;let A=a/f,{style:_}=this.div;_.aspectRatio=A,_.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(a,f=!1){if(f){this.#v||=new Map;let{action:A}=a,_=this.#v.get(A);_&&clearTimeout(_),_=setTimeout((()=>{this._reportTelemetry(a),this.#v.delete(A),this.#v.size===0&&(this.#v=null)}),g._telemetryTimeout),this.#v.set(A,_)}else a.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:a}})}show(a=this._isVisible){this.div.classList.toggle("hidden",!a),this._isVisible=a}enable(){this.div&&(this.div.tabIndex=0),this.#i=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#i=!0}}class v extends g{constructor(a){super(a),this.annotationElementId=a.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}},61:(s,t,e)=>{e.d(t,{FreeOutliner:()=>u,Outliner:()=>n});var i=e(292);class n{#t;#e=[];#i=[];constructor(p,a=0,f=0,A=!0){let _=1/0,d=-1/0,y=1/0,r=-1/0,l=10**-4;for(let{x:H,y:z,width:K,height:it}of p){let ot=Math.floor((H-a)/l)*l,X=Math.ceil((H+K+a)/l)*l,j=Math.floor((z-a)/l)*l,G=Math.ceil((z+it+a)/l)*l,Y=[ot,j,G,!0],et=[X,j,G,!1];this.#e.push(Y,et),_=Math.min(_,ot),d=Math.max(d,X),y=Math.min(y,j),r=Math.max(r,G)}let m=d-_+2*f,x=r-y+2*f,D=_-f,E=y-f,M=this.#e.at(A?-1:-2),N=[M[0],M[2]];for(let H of this.#e){let[z,K,it]=H;H[0]=(z-D)/m,H[1]=(K-E)/x,H[2]=(it-E)/x}this.#t={x:D,y:E,width:m,height:x,lastPoint:N}}getOutlines(){this.#e.sort(((a,f)=>a[0]-f[0]||a[1]-f[1]||a[2]-f[2]));let p=[];for(let a of this.#e)a[3]?(p.push(...this.#c(a)),this.#s(a)):(this.#a(a),p.push(...this.#c(a)));return this.#n(p)}#n(p){let a=[],f=new Set;for(let d of p){let[y,r,l]=d;a.push([y,r,d],[y,l,d])}a.sort(((d,y)=>d[1]-y[1]||d[0]-y[0]));for(let d=0,y=a.length;d<y;d+=2){let r=a[d][2],l=a[d+1][2];r.push(l),l.push(r),f.add(r),f.add(l)}let A=[],_;for(;f.size>0;){let d=f.values().next().value,[y,r,l,m,x]=d;f.delete(d);let D=y,E=r;for(_=[y,l],A.push(_);;){let M;if(f.has(m))M=m;else{if(!f.has(x))break;M=x}f.delete(M),[y,r,l,m,x]=M,D!==y&&(_.push(D,E,y,E===r?r:l),D=y),E=E===r?l:r}_.push(D,E)}return new h(A,this.#t)}#r(p){let a=this.#i,f=0,A=a.length-1;for(;f<=A;){let _=f+A>>1,d=a[_][0];if(d===p)return _;d<p?f=_+1:A=_-1}return A+1}#s([,p,a]){let f=this.#r(p);this.#i.splice(f,0,[p,a])}#a([,p,a]){let f=this.#r(p);for(let A=f;A<this.#i.length;A++){let[_,d]=this.#i[A];if(_!==p)break;if(_===p&&d===a){this.#i.splice(A,1);return}}for(let A=f-1;A>=0;A--){let[_,d]=this.#i[A];if(_!==p)break;if(_===p&&d===a){this.#i.splice(A,1);return}}}#c(p){let[a,f,A]=p,_=[[a,f,A]],d=this.#r(A);for(let y=0;y<d;y++){let[r,l]=this.#i[y];for(let m=0,x=_.length;m<x;m++){let[,D,E]=_[m];if(!(l<=D||E<=r))if(D>=r)if(E>l)_[m][1]=l;else{if(x===1)return[];_.splice(m,1),m--,x--}else _[m][2]=r,E>l&&_.push([a,l,E])}}return _}}class o{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(p,a){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof g}}class h extends o{#t;#e;constructor(p,a){super(),this.#e=p,this.#t=a}toSVGPath(){let p=[];for(let a of this.#e){let[f,A]=a;p.push(`M${f} ${A}`);for(let _=2;_<a.length;_+=2){let d=a[_],y=a[_+1];d===f?(p.push(`V${y}`),A=y):y===A&&(p.push(`H${d}`),f=d)}p.push("Z")}return p.join(" ")}serialize([p,a,f,A],_){let d=[],y=f-p,r=A-a;for(let l of this.#e){let m=new Array(l.length);for(let x=0;x<l.length;x+=2)m[x]=p+l[x]*y,m[x+1]=A-l[x+1]*r;d.push(m)}return d}get box(){return this.#t}}class u{#t;#e=[];#i;#n;#r=[];#s=new Float64Array(18);#a;#c;#o;#d;#p;#u;#l=[];static#f=8;static#g=2;static#h=u.#f+u.#g;constructor({x:p,y:a},f,A,_,d,y=0){this.#t=f,this.#u=_*A,this.#n=d,this.#s.set([NaN,NaN,NaN,NaN,p,a],6),this.#i=y,this.#d=u.#f*A,this.#o=u.#h*A,this.#p=A,this.#l.push(p,a)}get free(){return!0}isEmpty(){return isNaN(this.#s[8])}#b(){let p=this.#s.subarray(4,6),a=this.#s.subarray(16,18),[f,A,_,d]=this.#t;return[(this.#a+(p[0]-a[0])/2-f)/_,(this.#c+(p[1]-a[1])/2-A)/d,(this.#a+(a[0]-p[0])/2-f)/_,(this.#c+(a[1]-p[1])/2-A)/d]}add({x:p,y:a}){this.#a=p,this.#c=a;let[f,A,_,d]=this.#t,[y,r,l,m]=this.#s.subarray(8,12),x=p-l,D=a-m,E=Math.hypot(x,D);if(E<this.#o)return!1;let M=E-this.#d,N=M/E,H=N*x,z=N*D,K=y,it=r;y=l,r=m,l+=H,m+=z,this.#l?.push(p,a);let ot=H/M,X=-z/M*this.#u,j=ot*this.#u;return this.#s.set(this.#s.subarray(2,8),0),this.#s.set([l+X,m+j],4),this.#s.set(this.#s.subarray(14,18),12),this.#s.set([l-X,m-j],16),isNaN(this.#s[6])?(this.#r.length===0&&(this.#s.set([y+X,r+j],2),this.#r.push(NaN,NaN,NaN,NaN,(y+X-f)/_,(r+j-A)/d),this.#s.set([y-X,r-j],14),this.#e.push(NaN,NaN,NaN,NaN,(y-X-f)/_,(r-j-A)/d)),this.#s.set([K,it,y,r,l,m],6),!this.isEmpty()):(this.#s.set([K,it,y,r,l,m],6),Math.abs(Math.atan2(it-r,K-y)-Math.atan2(z,H))<Math.PI/2?([y,r,l,m]=this.#s.subarray(2,6),this.#r.push(NaN,NaN,NaN,NaN,((y+l)/2-f)/_,((r+m)/2-A)/d),[y,r,K,it]=this.#s.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((K+y)/2-f)/_,((it+r)/2-A)/d),!0):([K,it,y,r,l,m]=this.#s.subarray(0,6),this.#r.push(((K+5*y)/6-f)/_,((it+5*r)/6-A)/d,((5*y+l)/6-f)/_,((5*r+m)/6-A)/d,((y+l)/2-f)/_,((r+m)/2-A)/d),[l,m,y,r,K,it]=this.#s.subarray(12,18),this.#e.push(((K+5*y)/6-f)/_,((it+5*r)/6-A)/d,((5*y+l)/6-f)/_,((5*r+m)/6-A)/d,((y+l)/2-f)/_,((r+m)/2-A)/d),!0))}toSVGPath(){if(this.isEmpty())return"";let p=this.#r,a=this.#e,f=this.#s.subarray(4,6),A=this.#s.subarray(16,18),[_,d,y,r]=this.#t,[l,m,x,D]=this.#b();if(isNaN(this.#s[6])&&!this.isEmpty())return`M${(this.#s[2]-_)/y} ${(this.#s[3]-d)/r} L${(this.#s[4]-_)/y} ${(this.#s[5]-d)/r} L${l} ${m} L${x} ${D} L${(this.#s[16]-_)/y} ${(this.#s[17]-d)/r} L${(this.#s[14]-_)/y} ${(this.#s[15]-d)/r} Z`;let E=[];E.push(`M${p[4]} ${p[5]}`);for(let M=6;M<p.length;M+=6)isNaN(p[M])?E.push(`L${p[M+4]} ${p[M+5]}`):E.push(`C${p[M]} ${p[M+1]} ${p[M+2]} ${p[M+3]} ${p[M+4]} ${p[M+5]}`);E.push(`L${(f[0]-_)/y} ${(f[1]-d)/r} L${l} ${m} L${x} ${D} L${(A[0]-_)/y} ${(A[1]-d)/r}`);for(let M=a.length-6;M>=6;M-=6)isNaN(a[M])?E.push(`L${a[M+4]} ${a[M+5]}`):E.push(`C${a[M]} ${a[M+1]} ${a[M+2]} ${a[M+3]} ${a[M+4]} ${a[M+5]}`);return E.push(`L${a[4]} ${a[5]} Z`),E.join(" ")}getOutlines(){let p=this.#r,a=this.#e,f=this.#s,A=f.subarray(4,6),_=f.subarray(16,18),[d,y,r,l]=this.#t,m=new Float64Array((this.#l?.length??0)+2);for(let z=0,K=m.length-2;z<K;z+=2)m[z]=(this.#l[z]-d)/r,m[z+1]=(this.#l[z+1]-y)/l;m[m.length-2]=(this.#a-d)/r,m[m.length-1]=(this.#c-y)/l;let[x,D,E,M]=this.#b();if(isNaN(f[6])&&!this.isEmpty()){let z=new Float64Array(36);return z.set([NaN,NaN,NaN,NaN,(f[2]-d)/r,(f[3]-y)/l,NaN,NaN,NaN,NaN,(f[4]-d)/r,(f[5]-y)/l,NaN,NaN,NaN,NaN,x,D,NaN,NaN,NaN,NaN,E,M,NaN,NaN,NaN,NaN,(f[16]-d)/r,(f[17]-y)/l,NaN,NaN,NaN,NaN,(f[14]-d)/r,(f[15]-y)/l],0),new g(z,m,this.#t,this.#p,this.#i,this.#n)}let N=new Float64Array(this.#r.length+24+this.#e.length),H=p.length;for(let z=0;z<H;z+=2)isNaN(p[z])?N[z]=N[z+1]=NaN:(N[z]=p[z],N[z+1]=p[z+1]);N.set([NaN,NaN,NaN,NaN,(A[0]-d)/r,(A[1]-y)/l,NaN,NaN,NaN,NaN,x,D,NaN,NaN,NaN,NaN,E,M,NaN,NaN,NaN,NaN,(_[0]-d)/r,(_[1]-y)/l],H),H+=24;for(let z=a.length-6;z>=6;z-=6)for(let K=0;K<6;K+=2)isNaN(a[z+K])?(N[H]=N[H+1]=NaN,H+=2):(N[H]=a[z+K],N[H+1]=a[z+K+1],H+=2);return N.set([NaN,NaN,NaN,NaN,a[4],a[5]],H),new g(N,m,this.#t,this.#p,this.#i,this.#n)}}class g extends o{#t;#e=null;#i;#n;#r;#s;#a;constructor(p,a,f,A,_,d){super(),this.#a=p,this.#r=a,this.#t=f,this.#s=A,this.#i=_,this.#n=d,this.#d(d);let{x:y,y:r,width:l,height:m}=this.#e;for(let x=0,D=p.length;x<D;x+=2)p[x]=(p[x]-y)/l,p[x+1]=(p[x+1]-r)/m;for(let x=0,D=a.length;x<D;x+=2)a[x]=(a[x]-y)/l,a[x+1]=(a[x+1]-r)/m}toSVGPath(){let p=[`M${this.#a[4]} ${this.#a[5]}`];for(let a=6,f=this.#a.length;a<f;a+=6)isNaN(this.#a[a])?p.push(`L${this.#a[a+4]} ${this.#a[a+5]}`):p.push(`C${this.#a[a]} ${this.#a[a+1]} ${this.#a[a+2]} ${this.#a[a+3]} ${this.#a[a+4]} ${this.#a[a+5]}`);return p.push("Z"),p.join(" ")}serialize([p,a,f,A],_){let d=f-p,y=A-a,r,l;switch(_){case 0:r=this.#c(this.#a,p,A,d,-y),l=this.#c(this.#r,p,A,d,-y);break;case 90:r=this.#o(this.#a,p,a,d,y),l=this.#o(this.#r,p,a,d,y);break;case 180:r=this.#c(this.#a,f,a,-d,y),l=this.#c(this.#r,f,a,-d,y);break;case 270:r=this.#o(this.#a,f,A,-d,-y),l=this.#o(this.#r,f,A,-d,-y)}return{outline:Array.from(r),points:[Array.from(l)]}}#c(p,a,f,A,_){let d=new Float64Array(p.length);for(let y=0,r=p.length;y<r;y+=2)d[y]=a+p[y]*A,d[y+1]=f+p[y+1]*_;return d}#o(p,a,f,A,_){let d=new Float64Array(p.length);for(let y=0,r=p.length;y<r;y+=2)d[y]=a+p[y+1]*A,d[y+1]=f+p[y]*_;return d}#d(p){let a=this.#a,f=a[4],A=a[5],_=f,d=A,y=f,r=A,l=f,m=A,x=p?Math.max:Math.min;for(let H=6,z=a.length;H<z;H+=6){if(isNaN(a[H]))_=Math.min(_,a[H+4]),d=Math.min(d,a[H+5]),y=Math.max(y,a[H+4]),r=Math.max(r,a[H+5]),m<a[H+5]?(l=a[H+4],m=a[H+5]):m===a[H+5]&&(l=x(l,a[H+4]));else{let K=i.Util.bezierBoundingBox(f,A,...a.slice(H,H+6));_=Math.min(_,K[0]),d=Math.min(d,K[1]),y=Math.max(y,K[2]),r=Math.max(r,K[3]),m<K[3]?(l=K[2],m=K[3]):m===K[3]&&(l=x(l,K[2]))}f=a[H+4],A=a[H+5]}let D=_-this.#i,E=d-this.#i,M=y-_+2*this.#i,N=r-d+2*this.#i;this.#e={x:D,y:E,width:M,height:N,lastPoint:[l,m]}}get box(){return this.#e}getNewOutline(p,a){let{x:f,y:A,width:_,height:d}=this.#e,[y,r,l,m]=this.#t,x=_*l,D=d*m,E=f*l+y,M=A*m+r,N=new u({x:this.#r[0]*x+E,y:this.#r[1]*D+M},this.#t,this.#s,p,this.#n,a??this.#i);for(let H=2;H<this.#r.length;H+=2)N.add({x:this.#r[H]*x+E,y:this.#r[H+1]*D+M});return N.getOutlines()}}},362:(s,t,e)=>{e.d(t,{EditorToolbar:()=>n,HighlightToolbar:()=>o});var i=e(419);class n{#t=null;#e=null;#i;#n=null;constructor(u){this.#i=u}render(){let u=this.#t=document.createElement("div");u.className="editToolbar",u.setAttribute("role","toolbar"),u.addEventListener("contextmenu",i.noContextMenu),u.addEventListener("pointerdown",n.#r);let g=this.#n=document.createElement("div");g.className="buttons",u.append(g);let v=this.#i.toolbarPosition;if(v){let{style:p}=u,a=this.#i._uiManager.direction==="ltr"?1-v[0]:v[0];p.insetInlineEnd=100*a+"%",p.top=`calc(${100*v[1]}% + var(--editor-toolbar-vert-offset))`}return this.#o(),u}static#r(u){u.stopPropagation()}#s(u){this.#i._focusEventsAllowed=!1,u.preventDefault(),u.stopPropagation()}#a(u){this.#i._focusEventsAllowed=!0,u.preventDefault(),u.stopPropagation()}#c(u){u.addEventListener("focusin",this.#s.bind(this),{capture:!0}),u.addEventListener("focusout",this.#a.bind(this),{capture:!0}),u.addEventListener("contextmenu",i.noContextMenu)}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden")}#o(){let u=document.createElement("button");u.className="delete",u.tabIndex=0,u.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#i.editorType}-button`),this.#c(u),u.addEventListener("click",(g=>{this.#i._uiManager.delete()})),this.#n.append(u)}get#d(){let u=document.createElement("div");return u.className="divider",u}addAltTextButton(u){this.#c(u),this.#n.prepend(u,this.#d)}addColorPicker(u){this.#e=u;let g=u.renderButton();this.#c(g),this.#n.prepend(g,this.#d)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class o{#t=null;#e=null;#i;constructor(u){this.#i=u}#n(){let u=this.#e=document.createElement("div");u.className="editToolbar",u.setAttribute("role","toolbar"),u.addEventListener("contextmenu",i.noContextMenu);let g=this.#t=document.createElement("div");return g.className="buttons",u.append(g),this.#s(),u}#r(u,g){let v=0,p=0;for(let a of u){let f=a.y+a.height;if(f<v)continue;let A=a.x+(g?a.width:0);f>v?(p=A,v=f):g?A>p&&(p=A):A<p&&(p=A)}return[g?1-p:p,v]}show(u,g,v){let[p,a]=this.#r(g,v),{style:f}=this.#e||=this.#n();u.append(this.#e),f.insetInlineEnd=100*p+"%",f.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#s(){let u=document.createElement("button");u.className="highlightButton",u.tabIndex=0,u.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");let g=document.createElement("span");u.append(g),g.className="visuallyHidden",g.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label"),u.addEventListener("contextmenu",i.noContextMenu),u.addEventListener("click",(()=>{this.#i.highlightSelection("floating_button")})),this.#t.append(u)}}},830:(s,t,e)=>{e.d(t,{AnnotationEditorUIManager:()=>A,ColorManager:()=>f,KeyboardManager:()=>a,bindEvents:()=>h,opacityToHex:()=>u});var i=e(292),n=e(419),o=e(362);function h(_,d,y){for(let r of y)d.addEventListener(r,_[r].bind(_))}function u(_){return Math.round(Math.min(255,Math.max(1,255*_))).toString(16).padStart(2,"0")}class g{#t=0;constructor(){}get id(){return`${i.AnnotationEditorPrefix}${this.#t++}`}}class v{#t=(0,i.getUuid)();#e=0;#i=null;static get _isSVGFittingCanvas(){let d=new OffscreenCanvas(1,3).getContext("2d"),y=new Image;y.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';let r=y.decode().then((()=>(d.drawImage(y,0,0,1,1,0,0,1,3),new Uint32Array(d.getImageData(0,0,1,1).data.buffer)[0]===0)));return(0,i.shadow)(this,"_isSVGFittingCanvas",r)}async#n(d,y){this.#i||=new Map;let r=this.#i.get(d);if(r===null)return null;if(r?.bitmap)return r.refCounter+=1,r;try{r||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let l;if(typeof y=="string"?(r.url=y,l=await(0,n.fetchData)(y,"blob")):l=r.file=y,l.type==="image/svg+xml"){let m=v._isSVGFittingCanvas,x=new FileReader,D=new Image,E=new Promise(((M,N)=>{D.onload=()=>{r.bitmap=D,r.isSvg=!0,M()},x.onload=async()=>{let H=r.svgUrl=x.result;D.src=await m?`${H}#svgView(preserveAspectRatio(none))`:H},D.onerror=x.onerror=N}));x.readAsDataURL(l),await E}else r.bitmap=await createImageBitmap(l);r.refCounter=1}catch(l){console.error(l),r=null}return this.#i.set(d,r),r&&this.#i.set(r.id,r),r}async getFromFile(d){let{lastModified:y,name:r,size:l,type:m}=d;return this.#n(`${y}_${r}_${l}_${m}`,d)}async getFromUrl(d){return this.#n(d,d)}async getFromId(d){this.#i||=new Map;let y=this.#i.get(d);return y?y.bitmap?(y.refCounter+=1,y):y.file?this.getFromFile(y.file):this.getFromUrl(y.url):null}getSvgUrl(d){let y=this.#i.get(d);return y?.isSvg?y.svgUrl:null}deleteId(d){this.#i||=new Map;let y=this.#i.get(d);y&&(y.refCounter-=1,y.refCounter===0&&(y.bitmap=null))}isValidId(d){return d.startsWith(`image_${this.#t}_`)}}class p{#t=[];#e=!1;#i;#n=-1;constructor(d=128){this.#i=d}add({cmd:d,undo:y,post:r,mustExec:l,type:m=NaN,overwriteIfSameType:x=!1,keepUndo:D=!1}){if(l&&d(),this.#e)return;let E={cmd:d,undo:y,post:r,type:m};if(this.#n===-1){this.#t.length>0&&(this.#t.length=0),this.#n=0,this.#t.push(E);return}if(x&&this.#t[this.#n].type===m){D&&(E.undo=this.#t[this.#n].undo),this.#t[this.#n]=E;return}let M=this.#n+1;M===this.#i?this.#t.splice(0,1):(this.#n=M,M<this.#t.length&&this.#t.splice(M)),this.#t.push(E)}undo(){if(this.#n===-1)return;this.#e=!0;let{undo:d,post:y}=this.#t[this.#n];d(),y?.(),this.#e=!1,this.#n-=1}redo(){if(this.#n<this.#t.length-1){this.#n+=1,this.#e=!0;let{cmd:d,post:y}=this.#t[this.#n];d(),y?.(),this.#e=!1}}hasSomethingToUndo(){return this.#n!==-1}hasSomethingToRedo(){return this.#n<this.#t.length-1}destroy(){this.#t=null}}class a{constructor(d){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:y}=i.FeatureTest.platform;for(let[r,l,m={}]of d)for(let x of r){let D=x.startsWith("mac+");y&&D?(this.callbacks.set(x.slice(4),{callback:l,options:m}),this.allKeys.add(x.split("+").at(-1))):!y&&!D&&(this.callbacks.set(x,{callback:l,options:m}),this.allKeys.add(x.split("+").at(-1)))}}#t(d){d.altKey&&this.buffer.push("alt"),d.ctrlKey&&this.buffer.push("ctrl"),d.metaKey&&this.buffer.push("meta"),d.shiftKey&&this.buffer.push("shift"),this.buffer.push(d.key);let y=this.buffer.join("+");return this.buffer.length=0,y}exec(d,y){if(!this.allKeys.has(y.key))return;let r=this.callbacks.get(this.#t(y));if(!r)return;let{callback:l,options:{bubbles:m=!1,args:x=[],checker:D=null}}=r;(!D||D(d,y))&&(l.bind(d,...x,y)(),m||(y.stopPropagation(),y.preventDefault()))}}class f{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let d=new Map([["CanvasText",null],["Canvas",null]]);return(0,n.getColorValues)(d),(0,i.shadow)(this,"_colors",d)}convert(d){let y=(0,n.getRGB)(d);if(!window.matchMedia("(forced-colors: active)").matches)return y;for(let[r,l]of this._colors)if(l.every(((m,x)=>m===y[x])))return f._colorsMapping.get(r);return y}getHexCode(d){let y=this._colors.get(d);return y?i.Util.makeHexColor(...y):d}}class A{#t=null;#e=new Map;#i=new Map;#n=null;#r=null;#s=new p;#a=0;#c=new Set;#o=null;#d=null;#p=new Set;#u=!1;#l=null;#f=null;#g=null;#h=!1;#b=null;#m=new g;#v=!1;#S=!1;#_=null;#I=null;#w=null;#x=i.AnnotationEditorType.NONE;#y=new Set;#E=null;#A=null;#C=null;#T=this.blur.bind(this);#k=this.focus.bind(this);#M=this.copy.bind(this);#P=this.cut.bind(this);#L=this.paste.bind(this);#R=this.keydown.bind(this);#F=this.keyup.bind(this);#O=this.onEditingAction.bind(this);#V=this.onPageChanging.bind(this);#G=this.onScaleChanging.bind(this);#z=this.#nt.bind(this);#$=this.onRotationChanging.bind(this);#N={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#j=[0,0];#B=null;#H=null;#K=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let d=A.prototype,y=x=>x.#H.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&x.hasSomethingToControl(),r=(x,{target:D})=>{if(D instanceof HTMLInputElement){let{type:E}=D;return E!=="text"&&E!=="number"}return!0},l=this.TRANSLATE_SMALL,m=this.TRANSLATE_BIG;return(0,i.shadow)(this,"_keyboardManager",new a([[["ctrl+a","mac+meta+a"],d.selectAll,{checker:r}],[["ctrl+z","mac+meta+z"],d.undo,{checker:r}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],d.redo,{checker:r}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],d.delete,{checker:r}],[["Enter","mac+Enter"],d.addNewEditorFromKeyboard,{checker:(x,{target:D})=>!(D instanceof HTMLButtonElement)&&x.#H.contains(D)&&!x.isEnterHandled}],[[" ","mac+ "],d.addNewEditorFromKeyboard,{checker:(x,{target:D})=>!(D instanceof HTMLButtonElement)&&x.#H.contains(document.activeElement)}],[["Escape","mac+Escape"],d.unselectAll],[["ArrowLeft","mac+ArrowLeft"],d.translateSelectedEditors,{args:[-l,0],checker:y}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],d.translateSelectedEditors,{args:[-m,0],checker:y}],[["ArrowRight","mac+ArrowRight"],d.translateSelectedEditors,{args:[l,0],checker:y}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],d.translateSelectedEditors,{args:[m,0],checker:y}],[["ArrowUp","mac+ArrowUp"],d.translateSelectedEditors,{args:[0,-l],checker:y}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],d.translateSelectedEditors,{args:[0,-m],checker:y}],[["ArrowDown","mac+ArrowDown"],d.translateSelectedEditors,{args:[0,l],checker:y}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],d.translateSelectedEditors,{args:[0,m],checker:y}]]))}constructor(d,y,r,l,m,x,D,E,M){this.#H=d,this.#K=y,this.#n=r,this._eventBus=l,this._eventBus._on("editingaction",this.#O),this._eventBus._on("pagechanging",this.#V),this._eventBus._on("scalechanging",this.#G),this._eventBus._on("rotationchanging",this.#$),this.#rt(),this.#J(),this.#r=m.annotationStorage,this.#l=m.filterFactory,this.#A=x,this.#g=D||null,this.#u=E,this.#w=M||null,this.viewParameters={realScale:n.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){this.#Q(),this.#Y(),this._eventBus._off("editingaction",this.#O),this._eventBus._off("pagechanging",this.#V),this._eventBus._off("scalechanging",this.#G),this._eventBus._off("rotationchanging",this.#$);for(let d of this.#i.values())d.destroy();this.#i.clear(),this.#e.clear(),this.#p.clear(),this.#t=null,this.#y.clear(),this.#s.destroy(),this.#n?.destroy(),this.#b?.hide(),this.#b=null,this.#f&&(clearTimeout(this.#f),this.#f=null),this.#B&&(clearTimeout(this.#B),this.#B=null),this.#at()}async mlGuess(d){return this.#w?.guess(d)||null}get hasMLManager(){return!!this.#w}get hcmFilter(){return(0,i.shadow)(this,"hcmFilter",this.#A?this.#l.addHCMFilter(this.#A.foreground,this.#A.background):"none")}get direction(){return(0,i.shadow)(this,"direction",getComputedStyle(this.#H).direction)}get highlightColors(){return(0,i.shadow)(this,"highlightColors",this.#g?new Map(this.#g.split(",").map((d=>d.split("=").map((y=>y.trim()))))):null)}get highlightColorNames(){return(0,i.shadow)(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(d=>d.reverse()))):null)}setMainHighlightColorPicker(d){this.#I=d}editAltText(d){this.#n?.editAltText(this,d)}onPageChanging({pageNumber:d}){this.#a=d-1}focusMainContainer(){this.#H.focus()}findParent(d,y){for(let r of this.#i.values()){let{x:l,y:m,width:x,height:D}=r.div.getBoundingClientRect();if(d>=l&&d<=l+x&&y>=m&&y<=m+D)return r}return null}disableUserSelect(d=!1){this.#K.classList.toggle("noUserSelect",d)}addShouldRescale(d){this.#p.add(d)}removeShouldRescale(d){this.#p.delete(d)}onScaleChanging({scale:d}){this.commitOrRemove(),this.viewParameters.realScale=d*n.PixelsPerInch.PDF_TO_CSS_UNITS;for(let y of this.#p)y.onScaleChanging()}onRotationChanging({pagesRotation:d}){this.commitOrRemove(),this.viewParameters.rotation=d}#q({anchorNode:d}){return d.nodeType===Node.TEXT_NODE?d.parentElement:d}highlightSelection(d=""){let y=document.getSelection();if(!y||y.isCollapsed)return;let{anchorNode:r,anchorOffset:l,focusNode:m,focusOffset:x}=y,D=y.toString(),E=this.#q(y).closest(".textLayer"),M=this.getSelectionBoxes(E);if(M){y.empty(),this.#x===i.AnnotationEditorType.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:i.AnnotationEditorType.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(let N of this.#i.values())if(N.hasTextLayer(E)){N.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:d,boxes:M,anchorNode:r,anchorOffset:l,focusNode:m,focusOffset:x,text:D});break}}}#st(){let d=document.getSelection();if(!d||d.isCollapsed)return;let y=this.#q(d).closest(".textLayer"),r=this.getSelectionBoxes(y);r&&(this.#b||=new o.HighlightToolbar(this),this.#b.show(y,r,this.direction==="ltr"))}addToAnnotationStorage(d){d.isEmpty()||!this.#r||this.#r.has(d.id)||this.#r.setValue(d.id,d)}#nt(){let d=document.getSelection();if(!d||d.isCollapsed){this.#E&&(this.#b?.hide(),this.#E=null,this.#D({hasSelectedText:!1}));return}let{anchorNode:y}=d;if(y!==this.#E)if(this.#q(d).closest(".textLayer")){if(this.#b?.hide(),this.#E=y,this.#D({hasSelectedText:!0}),(this.#x===i.AnnotationEditorType.HIGHLIGHT||this.#x===i.AnnotationEditorType.NONE)&&(this.#x===i.AnnotationEditorType.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#h=this.isShiftKeyDown,!this.isShiftKeyDown)){let r=l=>{(l.type!=="pointerup"||l.button===0)&&(window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),l.type==="pointerup"&&this.#X("main_toolbar"))};window.addEventListener("pointerup",r),window.addEventListener("blur",r)}}else this.#E&&(this.#b?.hide(),this.#E=null,this.#D({hasSelectedText:!1}))}#X(d=""){this.#x===i.AnnotationEditorType.HIGHLIGHT?this.highlightSelection(d):this.#u&&this.#st()}#rt(){document.addEventListener("selectionchange",this.#z)}#at(){document.removeEventListener("selectionchange",this.#z)}#ot(){window.addEventListener("focus",this.#k),window.addEventListener("blur",this.#T)}#Y(){window.removeEventListener("focus",this.#k),window.removeEventListener("blur",this.#T)}blur(){if(this.isShiftKeyDown=!1,this.#h&&(this.#h=!1,this.#X("main_toolbar")),!this.hasSelection)return;let{activeElement:d}=document;for(let y of this.#y)if(y.div.contains(d)){this.#_=[y,d],y._focusEventsAllowed=!1;break}}focus(){if(!this.#_)return;let[d,y]=this.#_;this.#_=null,y.addEventListener("focusin",(()=>{d._focusEventsAllowed=!0}),{once:!0}),y.focus()}#J(){window.addEventListener("keydown",this.#R),window.addEventListener("keyup",this.#F)}#Q(){window.removeEventListener("keydown",this.#R),window.removeEventListener("keyup",this.#F)}#Z(){document.addEventListener("copy",this.#M),document.addEventListener("cut",this.#P),document.addEventListener("paste",this.#L)}#tt(){document.removeEventListener("copy",this.#M),document.removeEventListener("cut",this.#P),document.removeEventListener("paste",this.#L)}addEditListeners(){this.#J(),this.#Z()}removeEditListeners(){this.#Q(),this.#tt()}copy(d){if(d.preventDefault(),this.#t?.commitOrRemove(),!this.hasSelection)return;let y=[];for(let r of this.#y){let l=r.serialize(!0);l&&y.push(l)}y.length!==0&&d.clipboardData.setData("application/pdfjs",JSON.stringify(y))}cut(d){this.copy(d),this.delete()}paste(d){d.preventDefault();let{clipboardData:y}=d;for(let m of y.items)for(let x of this.#d)if(x.isHandlingMimeForPasting(m.type)){x.paste(m,this.currentLayer);return}let r=y.getData("application/pdfjs");if(!r)return;try{r=JSON.parse(r)}catch(m){(0,i.warn)(`paste: "${m.message}".`);return}if(!Array.isArray(r))return;this.unselectAll();let l=this.currentLayer;try{let m=[];for(let E of r){let M=l.deserialize(E);if(!M)return;m.push(M)}let x=()=>{for(let E of m)this.#et(E);this.#it(m)},D=()=>{for(let E of m)E.remove()};this.addCommands({cmd:x,undo:D,mustExec:!0})}catch(m){(0,i.warn)(`paste: "${m.message}".`)}}keydown(d){this.isShiftKeyDown||d.key!=="Shift"||(this.isShiftKeyDown=!0),this.#x===i.AnnotationEditorType.NONE||this.isEditorHandlingKeyboard||A._keyboardManager.exec(this,d)}keyup(d){this.isShiftKeyDown&&d.key==="Shift"&&(this.isShiftKeyDown=!1,this.#h&&(this.#h=!1,this.#X("main_toolbar")))}onEditingAction({name:d}){switch(d){case"undo":case"redo":case"delete":case"selectAll":this[d]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#D(d){Object.entries(d).some((([y,r])=>this.#N[y]!==r))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#N,d)}),this.#x===i.AnnotationEditorType.HIGHLIGHT&&d.hasSelectedEditor===!1&&this.#U([[i.AnnotationEditorParamsType.HIGHLIGHT_FREE,!0]]))}#U(d){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:d})}setEditingState(d){d?(this.#ot(),this.#Z(),this.#D({isEditing:this.#x!==i.AnnotationEditorType.NONE,isEmpty:this.#W(),hasSomethingToUndo:this.#s.hasSomethingToUndo(),hasSomethingToRedo:this.#s.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Y(),this.#tt(),this.#D({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(d){if(!this.#d){this.#d=d;for(let y of this.#d)this.#U(y.defaultPropertiesToUpdate)}}getId(){return this.#m.id}get currentLayer(){return this.#i.get(this.#a)}getLayer(d){return this.#i.get(d)}get currentPageIndex(){return this.#a}addLayer(d){this.#i.set(d.pageIndex,d),this.#v?d.enable():d.disable()}removeLayer(d){this.#i.delete(d.pageIndex)}updateMode(d,y=null,r=!1){if(this.#x!==d)if(this.#x=d,d!==i.AnnotationEditorType.NONE){this.setEditingState(!0),this.#lt(),this.unselectAll();for(let l of this.#i.values())l.updateMode(d);if(y||!r){if(y){for(let l of this.#e.values())if(l.annotationElementId===y){this.setSelected(l),l.enterInEditMode();break}}}else this.addNewEditorFromKeyboard()}else this.setEditingState(!1),this.#ct()}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(d){d!==this.#x&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:d})}updateParams(d,y){if(this.#d){switch(d){case i.AnnotationEditorParamsType.CREATE:this.currentLayer.addNewEditor();return;case i.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:this.#I?.updateColor(y);break;case i.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#C||=new Map).set(d,y),this.showAllEditors("highlight",y)}for(let r of this.#y)r.updateParams(d,y);for(let r of this.#d)r.updateDefaultParams(d,y)}}showAllEditors(d,y,r=!1){for(let l of this.#e.values())l.editorType===d&&l.show(y);(this.#C?.get(i.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL)??!0)!==y&&this.#U([[i.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL,y]])}enableWaiting(d=!1){if(this.#S!==d){this.#S=d;for(let y of this.#i.values())d?y.disableClick():y.enableClick(),y.div.classList.toggle("waiting",d)}}#lt(){if(!this.#v){this.#v=!0;for(let d of this.#i.values())d.enable();for(let d of this.#e.values())d.enable()}}#ct(){if(this.unselectAll(),this.#v){this.#v=!1;for(let d of this.#i.values())d.disable();for(let d of this.#e.values())d.disable()}}getEditors(d){let y=[];for(let r of this.#e.values())r.pageIndex===d&&y.push(r);return y}getEditor(d){return this.#e.get(d)}addEditor(d){this.#e.set(d.id,d)}removeEditor(d){d.div.contains(document.activeElement)&&(this.#f&&clearTimeout(this.#f),this.#f=setTimeout((()=>{this.focusMainContainer(),this.#f=null}),0)),this.#e.delete(d.id),this.unselect(d),d.annotationElementId&&this.#c.has(d.annotationElementId)||this.#r?.remove(d.id)}addDeletedAnnotationElement(d){this.#c.add(d.annotationElementId),d.deleted=!0}isDeletedAnnotationElement(d){return this.#c.has(d)}removeDeletedAnnotationElement(d){this.#c.delete(d.annotationElementId),d.deleted=!1}#et(d){let y=this.#i.get(d.pageIndex);y?y.addOrRebuild(d):(this.addEditor(d),this.addToAnnotationStorage(d))}setActiveEditor(d){this.#t!==d&&(this.#t=d,d&&this.#U(d.propertiesToUpdate))}get#ht(){let d=null;for(d of this.#y);return d}updateUI(d){this.#ht===d&&this.#U(d.propertiesToUpdate)}toggleSelected(d){this.#y.has(d)?(this.#y.delete(d),d.unselect(),this.#D({hasSelectedEditor:this.hasSelection})):(this.#y.add(d),d.select(),this.#U(d.propertiesToUpdate),this.#D({hasSelectedEditor:!0}))}setSelected(d){for(let y of this.#y)y!==d&&y.unselect();this.#y.clear(),this.#y.add(d),d.select(),this.#U(d.propertiesToUpdate),this.#D({hasSelectedEditor:!0})}isSelected(d){return this.#y.has(d)}get firstSelectedEditor(){return this.#y.values().next().value}unselect(d){d.unselect(),this.#y.delete(d),this.#D({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#y.size!==0}get isEnterHandled(){return this.#y.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#s.undo(),this.#D({hasSomethingToUndo:this.#s.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#W()})}redo(){this.#s.redo(),this.#D({hasSomethingToUndo:!0,hasSomethingToRedo:this.#s.hasSomethingToRedo(),isEmpty:this.#W()})}addCommands(d){this.#s.add(d),this.#D({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#W()})}#W(){if(this.#e.size===0)return!0;if(this.#e.size===1)for(let d of this.#e.values())return d.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;let d=[...this.#y];this.addCommands({cmd:()=>{for(let y of d)y.remove()},undo:()=>{for(let y of d)this.#et(y)},mustExec:!0})}commitOrRemove(){this.#t?.commitOrRemove()}hasSomethingToControl(){return this.#t||this.hasSelection}#it(d){for(let y of this.#y)y.unselect();this.#y.clear();for(let y of d)y.isEmpty()||(this.#y.add(y),y.select());this.#D({hasSelectedEditor:this.hasSelection})}selectAll(){for(let d of this.#y)d.commit();this.#it(this.#e.values())}unselectAll(){if(!(this.#t&&(this.#t.commitOrRemove(),this.#x!==i.AnnotationEditorType.NONE))&&this.hasSelection){for(let d of this.#y)d.unselect();this.#y.clear(),this.#D({hasSelectedEditor:!1})}}translateSelectedEditors(d,y,r=!1){if(r||this.commitOrRemove(),!this.hasSelection)return;this.#j[0]+=d,this.#j[1]+=y;let[l,m]=this.#j,x=[...this.#y];this.#B&&clearTimeout(this.#B),this.#B=setTimeout((()=>{this.#B=null,this.#j[0]=this.#j[1]=0,this.addCommands({cmd:()=>{for(let D of x)this.#e.has(D.id)&&D.translateInPage(l,m)},undo:()=>{for(let D of x)this.#e.has(D.id)&&D.translateInPage(-l,-m)},mustExec:!1})}),1e3);for(let D of x)D.translateInPage(d,y)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#o=new Map;for(let d of this.#y)this.#o.set(d,{savedX:d.x,savedY:d.y,savedPageIndex:d.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#o)return!1;this.disableUserSelect(!1);let d=this.#o;this.#o=null;let y=!1;for(let[{x:l,y:m,pageIndex:x},D]of d)D.newX=l,D.newY=m,D.newPageIndex=x,y||=l!==D.savedX||m!==D.savedY||x!==D.savedPageIndex;if(!y)return!1;let r=(l,m,x,D)=>{if(this.#e.has(l.id)){let E=this.#i.get(D);E?l._setParentAndPosition(E,m,x):(l.pageIndex=D,l.x=m,l.y=x)}};return this.addCommands({cmd:()=>{for(let[l,{newX:m,newY:x,newPageIndex:D}]of d)r(l,m,x,D)},undo:()=>{for(let[l,{savedX:m,savedY:x,savedPageIndex:D}]of d)r(l,m,x,D)},mustExec:!0}),!0}dragSelectedEditors(d,y){if(this.#o)for(let r of this.#o.keys())r.drag(d,y)}rebuild(d){if(d.parent===null){let y=this.getLayer(d.pageIndex);y?(y.changeParent(d),y.addOrRebuild(d)):(this.addEditor(d),this.addToAnnotationStorage(d),d.rebuild())}else d.parent.addOrRebuild(d)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#y.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(d){return this.#t===d}getActive(){return this.#t}getMode(){return this.#x}get imageManager(){return(0,i.shadow)(this,"imageManager",new v)}getSelectionBoxes(d){if(!d)return null;let y=document.getSelection();for(let M=0,N=y.rangeCount;M<N;M++)if(!d.contains(y.getRangeAt(M).commonAncestorContainer))return null;let{x:r,y:l,width:m,height:x}=d.getBoundingClientRect(),D;switch(d.getAttribute("data-main-rotation")){case"90":D=(M,N,H,z)=>({x:(N-l)/x,y:1-(M+H-r)/m,width:z/x,height:H/m});break;case"180":D=(M,N,H,z)=>({x:1-(M+H-r)/m,y:1-(N+z-l)/x,width:H/m,height:z/x});break;case"270":D=(M,N,H,z)=>({x:1-(N+z-l)/x,y:(M-r)/m,width:z/x,height:H/m});break;default:D=(M,N,H,z)=>({x:(M-r)/m,y:(N-l)/x,width:H/m,height:z/x})}let E=[];for(let M=0,N=y.rangeCount;M<N;M++){let H=y.getRangeAt(M);if(!H.collapsed)for(let{x:z,y:K,width:it,height:ot}of H.getClientRects())it!==0&&ot!==0&&E.push(D(z,K,it,ot))}return E.length===0?null:E}}},94:(s,t,e)=>{e.d(t,{PDFFetchStream:()=>g});var i=e(292),n=e(490);function o(a,f,A){return{method:"GET",headers:a,signal:A.signal,mode:"cors",credentials:f?"include":"same-origin",redirect:"follow"}}function h(a){let f=new Headers;for(let A in a){let _=a[A];_!==void 0&&f.append(A,_)}return f}function u(a){return a instanceof Uint8Array?a.buffer:a instanceof ArrayBuffer?a:((0,i.warn)(`getArrayBuffer - unexpected data format: ${a}`),new Uint8Array(a).buffer)}class g{constructor(f){this.source=f,this.isHttp=/^https?:/i.test(f.url),this.httpHeaders=this.isHttp&&f.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new v(this),this._fullRequestReader}getRangeReader(f,A){if(A<=this._progressiveDataLength)return null;let _=new p(this,f,A);return this._rangeRequestReaders.push(_),_}cancelAllRequests(f){this._fullRequestReader?.cancel(f);for(let A of this._rangeRequestReaders.slice(0))A.cancel(f)}}class v{constructor(f){this._stream=f,this._reader=null,this._loaded=0,this._filename=null;let A=f.source;this._withCredentials=A.withCredentials||!1,this._contentLength=A.length,this._headersCapability=Promise.withResolvers(),this._disableRange=A.disableRange||!1,this._rangeChunkSize=A.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!A.disableStream,this._isRangeSupported=!A.disableRange,this._headers=h(this._stream.httpHeaders);let _=A.url;fetch(_,o(this._headers,this._withCredentials,this._abortController)).then((d=>{if(!(0,n.validateResponseStatus)(d.status))throw(0,n.createResponseStatusError)(d.status,_);this._reader=d.body.getReader(),this._headersCapability.resolve();let y=m=>d.headers.get(m),{allowRangeRequests:r,suggestedLength:l}=(0,n.validateRangeRequestCapabilities)({getResponseHeader:y,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=l||this._contentLength,this._filename=(0,n.extractFilenameFromHeader)(y),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new i.AbortException("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;let{value:f,done:A}=await this._reader.read();return A?{value:f,done:A}:(this._loaded+=f.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:u(f),done:!1})}cancel(f){this._reader?.cancel(f),this._abortController.abort()}}class p{constructor(f,A,_){this._stream=f,this._reader=null,this._loaded=0;let d=f.source;this._withCredentials=d.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!d.disableStream,this._abortController=new AbortController,this._headers=h(this._stream.httpHeaders),this._headers.append("Range",`bytes=${A}-${_-1}`);let y=d.url;fetch(y,o(this._headers,this._withCredentials,this._abortController)).then((r=>{if(!(0,n.validateResponseStatus)(r.status))throw(0,n.createResponseStatusError)(r.status,y);this._readCapability.resolve(),this._reader=r.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:f,done:A}=await this._reader.read();return A?{value:f,done:A}:(this._loaded+=f.byteLength,this.onProgress?.({loaded:this._loaded}),{value:u(f),done:!1})}cancel(f){this._reader?.cancel(f),this._abortController.abort()}}},10:(s,t,e)=>{e.d(t,{FontFaceObject:()=>o,FontLoader:()=>n});var i=e(292);class n{#t=new Set;constructor({ownerDocument:u=globalThis.document,styleElement:g=null}){this._document=u,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(u){this.nativeFontFaces.add(u),this._document.fonts.add(u)}removeNativeFontFace(u){this.nativeFontFaces.delete(u),this._document.fonts.delete(u)}insertRule(u){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let g=this.styleElement.sheet;g.insertRule(u,g.cssRules.length)}clear(){for(let u of this.nativeFontFaces)this._document.fonts.delete(u);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:u,_inspectFont:g}){if(u&&!this.#t.has(u.loadedName))if((0,i.assert)(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:v,src:p,style:a}=u,f=new FontFace(v,p,a);this.addNativeFontFace(f);try{await f.load(),this.#t.add(v),g?.(u)}catch{(0,i.warn)(`Cannot load system font: ${u.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(f)}}else(0,i.unreachable)("Not implemented: loadSystemFont without the Font Loading API.")}async bind(u){if(u.attached||u.missingFile&&!u.systemFontInfo)return;if(u.attached=!0,u.systemFontInfo){await this.loadSystemFont(u);return}if(this.isFontLoadingAPISupported){let v=u.createNativeFontFace();if(v){this.addNativeFontFace(v);try{await v.loaded}catch(p){throw(0,i.warn)(`Failed to load font '${v.family}': '${p}'.`),u.disableFontFace=!0,p}}return}let g=u.createFontFaceRule();if(g){if(this.insertRule(g),this.isSyncFontLoadingSupported)return;await new Promise((v=>{let p=this._queueLoadingCallback(v);this._prepareFontLoadEvent(u,p)}))}}get isFontLoadingAPISupported(){let u=!!this._document?.fonts;return(0,i.shadow)(this,"isFontLoadingAPISupported",u)}get isSyncFontLoadingSupported(){let u=!1;return(i.isNodeJS||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(u=!0),(0,i.shadow)(this,"isSyncFontLoadingSupported",u)}_queueLoadingCallback(u){let{loadingRequests:g}=this,v={done:!1,complete:function(){for((0,i.assert)(!v.done,"completeRequest() cannot be called twice."),v.done=!0;g.length>0&&g[0].done;){let a=g.shift();setTimeout(a.callback,0)}},callback:u};return g.push(v),v}get _loadTestFont(){let u=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return(0,i.shadow)(this,"_loadTestFont",u)}_prepareFontLoadEvent(u,g){function v(E,M){return E.charCodeAt(M)<<24|E.charCodeAt(M+1)<<16|E.charCodeAt(M+2)<<8|255&E.charCodeAt(M+3)}function p(E,M,N,H){return E.substring(0,M)+H+E.substring(M+N)}let a,f,A=this._document.createElement("canvas");A.width=1,A.height=1;let _=A.getContext("2d"),d=0,y=`lt${Date.now()}${this.loadTestFontId++}`,r=this._loadTestFont;r=p(r,976,y.length,y);let l=1482184792,m=v(r,16);for(a=0,f=y.length-3;a<f;a+=4)m=m-l+v(y,a)|0;a<y.length&&(m=m-l+v(y+"XXX",a)|0),r=p(r,16,4,(0,i.string32)(m));let x=`@font-face {font-family:"${y}";src:${`url(data:font/opentype;base64,${btoa(r)});`}}`;this.insertRule(x);let D=this._document.createElement("div");D.style.visibility="hidden",D.style.width=D.style.height="10px",D.style.position="absolute",D.style.top=D.style.left="0px";for(let E of[u.loadedName,y]){let M=this._document.createElement("span");M.textContent="Hi",M.style.fontFamily=E,D.append(M)}this._document.body.append(D),(function E(M,N){if(++d>30){(0,i.warn)("Load test font never loaded."),N();return}_.font="30px "+M,_.fillText(".",0,20),_.getImageData(0,0,1,1).data[3]>0?N():setTimeout(E.bind(null,M,N))})(y,(()=>{D.remove(),g.complete()}))}}class o{constructor(u,{isEvalSupported:g=!0,disableFontFace:v=!1,ignoreErrors:p=!1,inspectFont:a=null}){this.compiledGlyphs=Object.create(null);for(let f in u)this[f]=u[f];this.isEvalSupported=g!==!1,this.disableFontFace=v===!0,this.ignoreErrors=p===!0,this._inspectFont=a}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let u;if(this.cssFontInfo){let g={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(g.style=`oblique ${this.cssFontInfo.italicAngle}deg`),u=new FontFace(this.cssFontInfo.fontFamily,this.data,g)}else u=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),u}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let u=(0,i.bytesToString)(this.data),g=`url(data:${this.mimetype};base64,${btoa(u)});`,v;if(this.cssFontInfo){let p=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(p+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),v=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${p}src:${g}}`}else v=`@font-face {font-family:"${this.loadedName}";src:${g}}`;return this._inspectFont?.(this,g),v}getPathGenerator(u,g){if(this.compiledGlyphs[g]!==void 0)return this.compiledGlyphs[g];let v;try{v=u.get(this.loadedName+"_path_"+g)}catch(p){if(!this.ignoreErrors)throw p;return(0,i.warn)(`getPathGenerator - ignoring character: "${p}".`),this.compiledGlyphs[g]=function(a,f){}}if(this.isEvalSupported&&i.FeatureTest.isEvalSupported){let p=[];for(let a of v){let f=a.args!==void 0?a.args.join(","):"";p.push("c.",a.cmd,"(",f,`);
14
+ `)}return this.compiledGlyphs[g]=new Function("c","size",p.join(""))}return this.compiledGlyphs[g]=function(p,a){for(let f of v)f.cmd==="scale"&&(f.args=[a,-a]),p[f.cmd].apply(p,f.args)}}}},62:(s,t,e)=>{e.d(t,{Metadata:()=>n});var i=e(292);class n{#t;#e;constructor({parsedData:h,rawData:u}){this.#t=h,this.#e=u}getRaw(){return this.#e}get(h){return this.#t.get(h)??null}getAll(){return(0,i.objectFromMap)(this.#t)}has(h){return this.#t.has(h)}}},457:(s,t,e)=>{e.d(t,{PDFNetworkStream:()=>h});var i=e(292),n=e(490);class o{constructor(p,a={}){this.url=p,this.isHttp=/^https?:/i.test(p),this.httpHeaders=this.isHttp&&a.httpHeaders||Object.create(null),this.withCredentials=a.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(p,a,f){let A={begin:p,end:a};for(let _ in f)A[_]=f[_];return this.request(A)}requestFull(p){return this.request(p)}request(p){let a=new XMLHttpRequest,f=this.currXhrId++,A=this.pendingRequests[f]={xhr:a};a.open("GET",this.url),a.withCredentials=this.withCredentials;for(let _ in this.httpHeaders){let d=this.httpHeaders[_];d!==void 0&&a.setRequestHeader(_,d)}return this.isHttp&&"begin"in p&&"end"in p?(a.setRequestHeader("Range",`bytes=${p.begin}-${p.end-1}`),A.expectedStatus=206):A.expectedStatus=200,a.responseType="arraybuffer",p.onError&&(a.onerror=function(_){p.onError(a.status)}),a.onreadystatechange=this.onStateChange.bind(this,f),a.onprogress=this.onProgress.bind(this,f),A.onHeadersReceived=p.onHeadersReceived,A.onDone=p.onDone,A.onError=p.onError,A.onProgress=p.onProgress,a.send(null),f}onProgress(p,a){let f=this.pendingRequests[p];f&&f.onProgress?.(a)}onStateChange(p,a){let f=this.pendingRequests[p];if(!f)return;let A=f.xhr;if(A.readyState>=2&&f.onHeadersReceived&&(f.onHeadersReceived(),delete f.onHeadersReceived),A.readyState!==4||!(p in this.pendingRequests))return;if(delete this.pendingRequests[p],A.status===0&&this.isHttp){f.onError?.(A.status);return}let _=A.status||200;if(!(_===200&&f.expectedStatus===206)&&_!==f.expectedStatus){f.onError?.(A.status);return}let d=(function(r){let l=r.response;return typeof l!="string"?l:(0,i.stringToBytes)(l).buffer})(A);if(_===206){let y=A.getResponseHeader("Content-Range"),r=/bytes (\d+)-(\d+)\/(\d+)/.exec(y);f.onDone({begin:parseInt(r[1],10),chunk:d})}else d?f.onDone({begin:0,chunk:d}):f.onError?.(A.status)}getRequestXhr(p){return this.pendingRequests[p].xhr}isPendingRequest(p){return p in this.pendingRequests}abortRequest(p){let a=this.pendingRequests[p].xhr;delete this.pendingRequests[p],a.abort()}}class h{constructor(p){this._source=p,this._manager=new o(p.url,{httpHeaders:p.httpHeaders,withCredentials:p.withCredentials}),this._rangeChunkSize=p.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(p){let a=this._rangeRequestReaders.indexOf(p);a>=0&&this._rangeRequestReaders.splice(a,1)}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new u(this._manager,this._source),this._fullRequestReader}getRangeReader(p,a){let f=new g(this._manager,p,a);return f.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(f),f}cancelAllRequests(p){this._fullRequestReader?.cancel(p);for(let a of this._rangeRequestReaders.slice(0))a.cancel(p)}}class u{constructor(p,a){this._manager=p;let f={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=a.url,this._fullRequestId=p.requestFull(f),this._headersReceivedCapability=Promise.withResolvers(),this._disableRange=a.disableRange||!1,this._contentLength=a.length,this._rangeChunkSize=a.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(){let p=this._fullRequestId,a=this._manager.getRequestXhr(p),f=d=>a.getResponseHeader(d),{allowRangeRequests:A,suggestedLength:_}=(0,n.validateRangeRequestCapabilities)({getResponseHeader:f,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});A&&(this._isRangeSupported=!0),this._contentLength=_||this._contentLength,this._filename=(0,n.extractFilenameFromHeader)(f),this._isRangeSupported&&this._manager.abortRequest(p),this._headersReceivedCapability.resolve()}_onDone(p){if(p&&(this._requests.length>0?this._requests.shift().resolve({value:p.chunk,done:!1}):this._cachedChunks.push(p.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let a of this._requests)a.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(p){this._storedError=(0,n.createResponseStatusError)(p,this._url),this._headersReceivedCapability.reject(this._storedError);for(let a of this._requests)a.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(p){this.onProgress?.({loaded:p.loaded,total:p.lengthComputable?p.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._headersReceivedCapability.promise}async read(){if(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};let p=Promise.withResolvers();return this._requests.push(p),p.promise}cancel(p){this._done=!0,this._headersReceivedCapability.reject(p);for(let a of this._requests)a.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class g{constructor(p,a,f){this._manager=p;let A={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=p.url,this._requestId=p.requestRange(a,f,A),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(p){let a=p.chunk;this._requests.length>0?this._requests.shift().resolve({value:a,done:!1}):this._queuedChunk=a,this._done=!0;for(let f of this._requests)f.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(p){this._storedError=(0,n.createResponseStatusError)(p,this._url);for(let a of this._requests)a.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(p){this.isStreamingSupported||this.onProgress?.({loaded:p.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let a=this._queuedChunk;return this._queuedChunk=null,{value:a,done:!1}}if(this._done)return{value:void 0,done:!0};let p=Promise.withResolvers();return this._requests.push(p),p.promise}cancel(p){this._done=!0;for(let a of this._requests)a.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}},490:(s,t,e)=>{e.d(t,{createResponseStatusError:()=>u,extractFilenameFromHeader:()=>h,validateRangeRequestCapabilities:()=>o,validateResponseStatus:()=>g});var i=e(292),n=e(419);function o({getResponseHeader:v,isHttp:p,rangeChunkSize:a,disableRange:f}){let A={allowRangeRequests:!1,suggestedLength:void 0},_=parseInt(v("Content-Length"),10);return!Number.isInteger(_)||(A.suggestedLength=_,_<=2*a)||f||!p||v("Accept-Ranges")!=="bytes"||(v("Content-Encoding")||"identity")!=="identity"||(A.allowRangeRequests=!0),A}function h(v){let p=v("Content-Disposition");if(p){let a=(function(A){let _=!0,d=y("filename\\*","i").exec(A);if(d){d=d[1];let E=m(d);return E=unescape(E),E=x(E),E=D(E),l(E)}if(d=(function(M){let N=[],H,z=y("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(H=z.exec(M))!==null;){let[,it,ot,X]=H;if(it=parseInt(it,10),it in N){if(it===0)break}else N[it]=[ot,X]}let K=[];for(let it=0;it<N.length&&it in N;++it){let[ot,X]=N[it];X=m(X),ot&&(X=unescape(X),it===0&&(X=x(X))),K.push(X)}return K.join("")})(A),d)return l(D(d));if(d=y("filename","i").exec(A),d){d=d[1];let E=m(d);return E=D(E),l(E)}function y(E,M){return new RegExp("(?:^|;)\\s*"+E+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',M)}function r(E,M){if(E){if(!/^[\x00-\xFF]+$/.test(M))return M;try{let N=new TextDecoder(E,{fatal:!0}),H=(0,i.stringToBytes)(M);M=N.decode(H),_=!1}catch{}}return M}function l(E){return _&&/[\x80-\xff]/.test(E)&&(E=r("utf-8",E),_&&(E=r("iso-8859-1",E))),E}function m(E){if(E.startsWith('"')){let M=E.slice(1).split('\\"');for(let N=0;N<M.length;++N){let H=M[N].indexOf('"');H!==-1&&(M[N]=M[N].slice(0,H),M.length=N+1),M[N]=M[N].replaceAll(/\\(.)/g,"$1")}E=M.join('"')}return E}function x(E){let M=E.indexOf("'");return M===-1?E:r(E.slice(0,M),E.slice(M+1).replace(/^[^']*'/,""))}function D(E){return!E.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(E)?E:E.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(M,N,H,z){if(H==="q"||H==="Q")return r(N,z=(z=z.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(K,it){return String.fromCharCode(parseInt(it,16))})));try{z=atob(z)}catch{}return r(N,z)}))}return""})(p);if(a.includes("%"))try{a=decodeURIComponent(a)}catch{}if((0,n.isPdfFile)(a))return a}return null}function u(v,p){return v===404||v===0&&p.startsWith("file:")?new i.MissingPDFException('Missing PDF "'+p+'".'):new i.UnexpectedResponseException(`Unexpected server response (${v}) while retrieving PDF "${p}".`,v)}function g(v){return v===200||v===206}},786:(s,t,e)=>{e.a(s,(async(i,n)=>{try{let f=function(D){let E=p.parse(D);return E.protocol==="file:"||E.host?E:/^[a-z]:[/\\]/i.test(D)?p.parse(`file:///${D}`):(E.host||(E.protocol="file:"),E)},y=function(D,E){return{protocol:D.protocol,auth:D.auth,host:D.hostname,port:D.port,path:D.path,method:"GET",headers:E}};e.d(t,{PDFNodeStream:()=>A});var o=e(292),h=e(490);let u,g,v,p;o.isNodeJS&&(u=await Promise.resolve().then(()=>(uo(),ho)),g=await Promise.resolve().then(()=>(Dc(),Pc)),v=await Promise.resolve().then(()=>(Mc(),Ic)),p=await Promise.resolve().then(()=>(Lc(),Rc)));let a=/^file:\/\/\/[a-zA-Z]:\//;class A{constructor(E){this.source=E,this.url=f(E.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&E.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return(0,o.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new m(this):new r(this),this._fullRequestReader}getRangeReader(E,M){if(M<=this._progressiveDataLength)return null;let N=this.isFsUrl?new x(this,E,M):new l(this,E,M);return this._rangeRequestReaders.push(N),N}cancelAllRequests(E){this._fullRequestReader?.cancel(E);for(let M of this._rangeRequestReaders.slice(0))M.cancel(E)}}class _{constructor(E){this._url=E.url,this._done=!1,this._storedError=null,this.onProgress=null;let M=E.source;this._contentLength=M.length,this._loaded=0,this._filename=null,this._disableRange=M.disableRange||!1,this._rangeChunkSize=M.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!M.disableStream,this._isRangeSupported=!M.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let E=this._readableStream.read();return E===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=E.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(E).buffer,done:!1})}cancel(E){this._readableStream?this._readableStream.destroy(E):this._error(E)}_error(E){this._storedError=E,this._readCapability.resolve()}_setReadableStream(E){this._readableStream=E,E.on("readable",(()=>{this._readCapability.resolve()})),E.on("end",(()=>{E.destroy(),this._done=!0,this._readCapability.resolve()})),E.on("error",(M=>{this._error(M)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new o.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class d{constructor(E){this._url=E.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let M=E.source;this._isStreamingSupported=!M.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let E=this._readableStream.read();return E===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=E.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(E).buffer,done:!1})}cancel(E){this._readableStream?this._readableStream.destroy(E):this._error(E)}_error(E){this._storedError=E,this._readCapability.resolve()}_setReadableStream(E){this._readableStream=E,E.on("readable",(()=>{this._readCapability.resolve()})),E.on("end",(()=>{E.destroy(),this._done=!0,this._readCapability.resolve()})),E.on("error",(M=>{this._error(M)})),this._storedError&&this._readableStream.destroy(this._storedError)}}class r extends _{constructor(E){super(E);let M=N=>{if(N.statusCode===404){let it=new o.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=it,this._headersCapability.reject(it);return}this._headersCapability.resolve(),this._setReadableStream(N);let H=it=>this._readableStream.headers[it.toLowerCase()],{allowRangeRequests:z,suggestedLength:K}=(0,h.validateRangeRequestCapabilities)({getResponseHeader:H,isHttp:E.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=z,this._contentLength=K||this._contentLength,this._filename=(0,h.extractFilenameFromHeader)(H)};this._request=null,this._url.protocol==="http:"?this._request=g.request(y(this._url,E.httpHeaders),M):this._request=v.request(y(this._url,E.httpHeaders),M),this._request.on("error",(N=>{this._storedError=N,this._headersCapability.reject(N)})),this._request.end()}}class l extends d{constructor(E,M,N){super(E),this._httpHeaders={};for(let z in E.httpHeaders){let K=E.httpHeaders[z];K!==void 0&&(this._httpHeaders[z]=K)}this._httpHeaders.Range=`bytes=${M}-${N-1}`;let H=z=>{if(z.statusCode!==404)this._setReadableStream(z);else{let K=new o.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=K}};this._request=null,this._url.protocol==="http:"?this._request=g.request(y(this._url,this._httpHeaders),H):this._request=v.request(y(this._url,this._httpHeaders),H),this._request.on("error",(z=>{this._storedError=z})),this._request.end()}}class m extends _{constructor(E){super(E);let M=decodeURIComponent(this._url.path);a.test(this._url.href)&&(M=M.replace(/^\//,"")),u.promises.lstat(M).then((N=>{this._contentLength=N.size,this._setReadableStream(u.createReadStream(M)),this._headersCapability.resolve()}),(N=>{N.code==="ENOENT"&&(N=new o.MissingPDFException(`Missing PDF "${M}".`)),this._storedError=N,this._headersCapability.reject(N)}))}}class x extends d{constructor(E,M,N){super(E);let H=decodeURIComponent(this._url.path);a.test(this._url.href)&&(H=H.replace(/^\//,"")),this._setReadableStream(u.createReadStream(H,{start:M,end:N-1}))}}n()}catch(u){n(u)}}),1)},573:(s,t,e)=>{e.a(s,(async(i,n)=>{try{e.d(t,{NodeCMapReaderFactory:()=>f,NodeCanvasFactory:()=>a,NodeFilterFactory:()=>p,NodeStandardFontDataFactory:()=>A});var o=e(583);let h,u,g;if(e(292).isNodeJS){h=await Promise.resolve().then(()=>(uo(),ho));try{u=await Promise.resolve().then(()=>(Oc(),Fc))}catch{}try{g=await Promise.resolve().then(()=>(Bc(),Nc))}catch{}}let v=function(_){return h.promises.readFile(_).then((d=>new Uint8Array(d)))};class p extends o.BaseFilterFactory{}class a extends o.BaseCanvasFactory{_createCanvas(d,y){return u.createCanvas(d,y)}}class f extends o.BaseCMapReaderFactory{_fetchData(d,y){return v(d).then((r=>({cMapData:r,compressionType:y})))}}class A extends o.BaseStandardFontDataFactory{_fetchData(d){return v(d)}}n()}catch(h){n(h)}}),1)},626:(s,t,e)=>{e.d(t,{OptionalContentConfig:()=>u});var i=e(292),n=e(651);let o=Symbol("INTERNAL");class h{#t=!1;#e=!1;#i=!1;#n=!0;constructor(v,{name:p,intent:a,usage:f}){this.#t=!!(v&i.RenderingIntentFlag.DISPLAY),this.#e=!!(v&i.RenderingIntentFlag.PRINT),this.name=p,this.intent=a,this.usage=f}get visible(){if(this.#i)return this.#n;if(!this.#n)return!1;let{print:v,view:p}=this.usage;return this.#t?p?.viewState!=="OFF":!this.#e||v?.printState!=="OFF"}_setVisible(v,p,a=!1){v!==o&&(0,i.unreachable)("Internal method `_setVisible` called."),this.#i=a,this.#n=p}}class u{#t=null;#e=new Map;#i=null;#n=null;constructor(v,p=i.RenderingIntentFlag.DISPLAY){if(this.renderingIntent=p,this.name=null,this.creator=null,v!==null){this.name=v.name,this.creator=v.creator,this.#n=v.order;for(let a of v.groups)this.#e.set(a.id,new h(p,a));if(v.baseState==="OFF")for(let a of this.#e.values())a._setVisible(o,!1);for(let a of v.on)this.#e.get(a)._setVisible(o,!0);for(let a of v.off)this.#e.get(a)._setVisible(o,!1);this.#i=this.getHash()}}#r(v){let p=v.length;if(p<2)return!0;let a=v[0];for(let f=1;f<p;f++){let A=v[f],_;if(Array.isArray(A))_=this.#r(A);else{if(!this.#e.has(A))return(0,i.warn)(`Optional content group not found: ${A}`),!0;_=this.#e.get(A).visible}switch(a){case"And":if(!_)return!1;break;case"Or":if(_)return!0;break;case"Not":return!_;default:return!0}}return a==="And"}isVisible(v){if(this.#e.size===0)return!0;if(!v)return(0,i.info)("Optional content group not defined."),!0;if(v.type==="OCG")return this.#e.has(v.id)?this.#e.get(v.id).visible:((0,i.warn)(`Optional content group not found: ${v.id}`),!0);if(v.type==="OCMD"){if(v.expression)return this.#r(v.expression);if(!v.policy||v.policy==="AnyOn"){for(let p of v.ids){if(!this.#e.has(p))return(0,i.warn)(`Optional content group not found: ${p}`),!0;if(this.#e.get(p).visible)return!0}return!1}if(v.policy==="AllOn"){for(let p of v.ids){if(!this.#e.has(p))return(0,i.warn)(`Optional content group not found: ${p}`),!0;if(!this.#e.get(p).visible)return!1}return!0}if(v.policy==="AnyOff"){for(let p of v.ids){if(!this.#e.has(p))return(0,i.warn)(`Optional content group not found: ${p}`),!0;if(!this.#e.get(p).visible)return!0}return!1}if(v.policy==="AllOff"){for(let p of v.ids){if(!this.#e.has(p))return(0,i.warn)(`Optional content group not found: ${p}`),!0;if(this.#e.get(p).visible)return!1}return!0}return(0,i.warn)(`Unknown optional content policy ${v.policy}.`),!0}return(0,i.warn)(`Unknown group type ${v.type}.`),!0}setVisibility(v,p=!0){let a=this.#e.get(v);a?(a._setVisible(o,!!p,!0),this.#t=null):(0,i.warn)(`Optional content group not found: ${v}`)}setOCGState({state:v,preserveRB:p}){let a;for(let f of v){switch(f){case"ON":case"OFF":case"Toggle":a=f;continue}let A=this.#e.get(f);if(A)switch(a){case"ON":A._setVisible(o,!0);break;case"OFF":A._setVisible(o,!1);break;case"Toggle":A._setVisible(o,!A.visible)}}this.#t=null}get hasInitialVisibility(){return this.#i===null||this.getHash()===this.#i}getOrder(){return this.#e.size?this.#n?this.#n.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?(0,i.objectFromMap)(this.#e):null}getGroup(v){return this.#e.get(v)||null}getHash(){if(this.#t!==null)return this.#t;let v=new n.MurmurHash3_64;for(let[p,a]of this.#e)v.update(`${p}:${a.visible}`);return this.#t=v.hexdigest()}}},814:(s,t,e)=>{e.d(t,{cleanupTextLayer:()=>p,renderTextLayer:()=>_,updateTextLayer:()=>d});var i=e(292),n=e(419);let o=30,h=.8,u=new Map,g=null;function v(){if(!g){let y=document.createElement("canvas");y.className="hiddenCanvasElement",document.body.append(y),g=y.getContext("2d",{alpha:!1})}return g}function p(){g?.canvas.remove(),g=null}function a(y,r,l){let m=document.createElement("span"),x={angle:0,canvasWidth:0,hasText:r.str!=="",hasEOL:r.hasEOL,fontSize:0};y._textDivs.push(m);let D=i.Util.transform(y._transform,r.transform),E=Math.atan2(D[1],D[0]),M=l[r.fontName];M.vertical&&(E+=Math.PI/2);let N=y._fontInspectorEnabled&&M.fontSubstitution||M.fontFamily,H=Math.hypot(D[2],D[3]),z=H*(function(Y){let et=u.get(Y);if(et)return et;let rt=v(),ct=rt.font;rt.canvas.width=rt.canvas.height=o,rt.font=`${o}px ${Y}`;let st=rt.measureText(""),W=st.fontBoundingBoxAscent,w=Math.abs(st.fontBoundingBoxDescent);if(W){let R=W/(W+w);return u.set(Y,R),rt.canvas.width=rt.canvas.height=0,rt.font=ct,R}rt.strokeStyle="red",rt.clearRect(0,0,o,o),rt.strokeText("g",0,0);let T=rt.getImageData(0,0,o,o).data;w=0;for(let R=T.length-1-3;R>=0;R-=4)if(T[R]>0){w=Math.ceil(R/4/o);break}rt.clearRect(0,0,o,o),rt.strokeText("A",0,o),T=rt.getImageData(0,0,o,o).data,W=0;for(let R=0,c=T.length;R<c;R+=4)if(T[R]>0){W=o-Math.floor(R/4/o);break}if(rt.canvas.width=rt.canvas.height=0,rt.font=ct,W){let R=W/(W+w);return u.set(Y,R),R}return u.set(Y,h),h})(N),K,it;E===0?(K=D[4],it=D[5]-z):(K=D[4]+z*Math.sin(E),it=D[5]-z*Math.cos(E));let ot="calc(var(--scale-factor)*",X=m.style;y._container===y._rootContainer?(X.left=`${(100*K/y._pageWidth).toFixed(2)}%`,X.top=`${(100*it/y._pageHeight).toFixed(2)}%`):(X.left=`${ot}${K.toFixed(2)}px)`,X.top=`${ot}${it.toFixed(2)}px)`),X.fontSize=`${ot}${H.toFixed(2)}px)`,X.fontFamily=N,x.fontSize=H,m.setAttribute("role","presentation"),m.textContent=r.str,m.dir=r.dir,y._fontInspectorEnabled&&(m.dataset.fontName=M.fontSubstitutionLoadedName||r.fontName),E!==0&&(x.angle=E*(180/Math.PI));let j=!1;if(r.str.length>1)j=!0;else if(r.str!==" "&&r.transform[0]!==r.transform[3]){let G=Math.abs(r.transform[0]),Y=Math.abs(r.transform[3]);G!==Y&&Math.max(G,Y)/Math.min(G,Y)>1.5&&(j=!0)}j&&(x.canvasWidth=M.vertical?r.height:r.width),y._textDivProperties.set(m,x),y._isReadableStream&&y._layoutText(m)}function f(y){let{div:r,scale:l,properties:m,ctx:x,prevFontSize:D,prevFontFamily:E}=y,{style:M}=r,N="";if(m.canvasWidth!==0&&m.hasText){let{fontFamily:H}=M,{canvasWidth:z,fontSize:K}=m;(D!==K||E!==H)&&(x.font=`${K*l}px ${H}`,y.prevFontSize=K,y.prevFontFamily=H);let{width:it}=x.measureText(r.textContent);it>0&&(N=`scaleX(${z*l/it})`)}m.angle!==0&&(N=`rotate(${m.angle}deg) ${N}`),N.length>0&&(M.transform=N)}class A{constructor({textContentSource:r,container:l,viewport:m,textDivs:x,textDivProperties:D,textContentItemsStr:E}){this._textContentSource=r,this._isReadableStream=r instanceof ReadableStream,this._container=this._rootContainer=l,this._textDivs=x||[],this._textContentItemsStr=E||[],this._fontInspectorEnabled=!!globalThis.FontInspector?.enabled,this._reader=null,this._textDivProperties=D||new WeakMap,this._canceled=!1,this._capability=Promise.withResolvers(),this._layoutTextParams={prevFontSize:null,prevFontFamily:null,div:null,scale:m.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:v()};let{pageWidth:M,pageHeight:N,pageX:H,pageY:z}=m.rawDims;this._transform=[1,0,0,-1,-H,z+N],this._pageWidth=M,this._pageHeight=N,(0,n.setLayerDimensions)(l,m),this._capability.promise.finally((()=>{this._layoutTextParams=null})).catch((()=>{}))}get promise(){return this._capability.promise}cancel(){this._canceled=!0,this._reader&&(this._reader.cancel(new i.AbortException("TextLayer task cancelled.")).catch((()=>{})),this._reader=null),this._capability.reject(new i.AbortException("TextLayer task cancelled."))}_processItems(r,l){for(let m of r)if(m.str!==void 0)this._textContentItemsStr.push(m.str),a(this,m,l);else if(m.type==="beginMarkedContentProps"||m.type==="beginMarkedContent"){let x=this._container;this._container=document.createElement("span"),this._container.classList.add("markedContent"),m.id!==null&&this._container.setAttribute("id",`${m.id}`),x.append(this._container)}else m.type==="endMarkedContent"&&(this._container=this._container.parentNode)}_layoutText(r){let l=this._layoutTextParams.properties=this._textDivProperties.get(r);if(this._layoutTextParams.div=r,f(this._layoutTextParams),l.hasText&&this._container.append(r),l.hasEOL){let m=document.createElement("br");m.setAttribute("role","presentation"),this._container.append(m)}}_render(){let{promise:r,resolve:l,reject:m}=Promise.withResolvers(),x=Object.create(null);if(this._isReadableStream){let D=()=>{this._reader.read().then((({value:E,done:M})=>{M?l():(Object.assign(x,E.styles),this._processItems(E.items,x),D())}),m)};this._reader=this._textContentSource.getReader(),D()}else{if(!this._textContentSource)throw new Error('No "textContentSource" parameter specified.');{let{items:D,styles:E}=this._textContentSource;this._processItems(D,E),l()}}r.then((()=>{x=null,(function(E){if(E._canceled)return;let M=E._textDivs,N=E._capability;if(M.length>1e5)N.resolve();else{if(!E._isReadableStream)for(let H of M)E._layoutText(H);N.resolve()}})(this)}),this._capability.reject)}}function _(y){let r=new A(y);return r._render(),r}function d({container:y,viewport:r,textDivs:l,textDivProperties:m,mustRotate:x=!0,mustRescale:D=!0}){if(x&&(0,n.setLayerDimensions)(y,{rotation:r.rotation}),D){let E=v(),M={prevFontSize:null,prevFontFamily:null,div:null,scale:r.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:E};for(let N of l)M.properties=m.get(N),M.div=N,f(M)}}},585:(s,t,e)=>{e.d(t,{PDFDataTransportStream:()=>o});var i=e(292),n=e(419);class o{constructor(v,{disableRange:p=!1,disableStream:a=!1}){(0,i.assert)(v,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:f,initialData:A,progressiveDone:_,contentDispositionFilename:d}=v;if(this._queuedChunks=[],this._progressiveDone=_,this._contentDispositionFilename=d,A?.length>0){let y=A instanceof Uint8Array&&A.byteLength===A.buffer.byteLength?A.buffer:new Uint8Array(A).buffer;this._queuedChunks.push(y)}this._pdfDataRangeTransport=v,this._isStreamingSupported=!a,this._isRangeSupported=!p,this._contentLength=f,this._fullRequestReader=null,this._rangeReaders=[],v.addRangeListener(((y,r)=>{this._onReceiveData({begin:y,chunk:r})})),v.addProgressListener(((y,r)=>{this._onProgress({loaded:y,total:r})})),v.addProgressiveReadListener((y=>{this._onReceiveData({chunk:y})})),v.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),v.transportReady()}_onReceiveData({begin:v,chunk:p}){let a=p instanceof Uint8Array&&p.byteLength===p.buffer.byteLength?p.buffer:new Uint8Array(p).buffer;if(v===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(a):this._queuedChunks.push(a);else{let f=this._rangeReaders.some((function(A){return A._begin!==v?!1:(A._enqueue(a),!0)}));(0,i.assert)(f,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(v){v.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:v.loaded}):this._fullRequestReader?.onProgress?.({loaded:v.loaded,total:v.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(v){let p=this._rangeReaders.indexOf(v);p>=0&&this._rangeReaders.splice(p,1)}getFullReader(){(0,i.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let v=this._queuedChunks;return this._queuedChunks=null,new h(this,v,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(v,p){if(p<=this._progressiveDataLength)return null;let a=new u(this,v,p);return this._pdfDataRangeTransport.requestDataRange(v,p),this._rangeReaders.push(a),a}cancelAllRequests(v){this._fullRequestReader?.cancel(v);for(let p of this._rangeReaders.slice(0))p.cancel(v);this._pdfDataRangeTransport.abort()}}class h{constructor(v,p,a=!1,f=null){this._stream=v,this._done=a||!1,this._filename=(0,n.isPdfFile)(f)?f:null,this._queuedChunks=p||[],this._loaded=0;for(let A of this._queuedChunks)this._loaded+=A.byteLength;this._requests=[],this._headersReady=Promise.resolve(),v._fullRequestReader=this,this.onProgress=null}_enqueue(v){this._done||(this._requests.length>0?this._requests.shift().resolve({value:v,done:!1}):this._queuedChunks.push(v),this._loaded+=v.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};let v=Promise.withResolvers();return this._requests.push(v),v.promise}cancel(v){this._done=!0;for(let p of this._requests)p.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class u{constructor(v,p,a){this._stream=v,this._begin=p,this._end=a,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(v){if(!this._done){if(this._requests.length===0)this._queuedChunk=v;else{this._requests.shift().resolve({value:v,done:!1});for(let p of this._requests)p.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){let p=this._queuedChunk;return this._queuedChunk=null,{value:p,done:!1}}if(this._done)return{value:void 0,done:!0};let v=Promise.withResolvers();return this._requests.push(v),v.promise}cancel(v){this._done=!0;for(let p of this._requests)p.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}},164:(s,t,e)=>{e.d(t,{GlobalWorkerOptions:()=>i});class i{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(o){if(!(typeof Worker<"u"&&o instanceof Worker)&&o!==null)throw new Error("Invalid `workerPort` type.");this.#t=o}static get workerSrc(){return this.#e}static set workerSrc(o){if(typeof o!="string")throw new Error("Invalid `workerSrc` type.");this.#e=o}}},284:(s,t,e)=>{e.d(t,{XfaLayer:()=>n});var i=e(50);class n{static setupStorage(h,u,g,v,p){let a=v.getValue(u,{value:null});switch(g.name){case"textarea":if(a.value!==null&&(h.textContent=a.value),p==="print")break;h.addEventListener("input",(f=>{v.setValue(u,{value:f.target.value})}));break;case"input":if(g.attributes.type==="radio"||g.attributes.type==="checkbox"){if(a.value===g.attributes.xfaOn?h.setAttribute("checked",!0):a.value===g.attributes.xfaOff&&h.removeAttribute("checked"),p==="print")break;h.addEventListener("change",(f=>{v.setValue(u,{value:f.target.checked?f.target.getAttribute("xfaOn"):f.target.getAttribute("xfaOff")})}))}else{if(a.value!==null&&h.setAttribute("value",a.value),p==="print")break;h.addEventListener("input",(f=>{v.setValue(u,{value:f.target.value})}))}break;case"select":if(a.value!==null){h.setAttribute("value",a.value);for(let f of g.children)f.attributes.value===a.value?f.attributes.selected=!0:f.attributes.hasOwnProperty("selected")&&delete f.attributes.selected}h.addEventListener("input",(f=>{let A=f.target.options,_=A.selectedIndex===-1?"":A[A.selectedIndex].value;v.setValue(u,{value:_})}))}}static setAttributes({html:h,element:u,storage:g=null,intent:v,linkService:p}){let{attributes:a}=u,f=h instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${v}`);for(let[A,_]of Object.entries(a))if(_!=null)switch(A){case"class":_.length&&h.setAttribute(A,_.join(" "));break;case"dataId":break;case"id":h.setAttribute("data-element-id",_);break;case"style":Object.assign(h.style,_);break;case"textContent":h.textContent=_;break;default:(!f||A!=="href"&&A!=="newWindow")&&h.setAttribute(A,_)}f&&p.addLinkAttributes(h,a.href,a.newWindow),g&&a.dataId&&this.setupStorage(h,a.dataId,u,g)}static render(h){let u=h.annotationStorage,g=h.linkService,v=h.xfaHtml,p=h.intent||"display",a=document.createElement(v.name);v.attributes&&this.setAttributes({html:a,element:v,intent:p,linkService:g});let f=p!=="richText",A=h.div;if(A.append(a),h.viewport){let y=`matrix(${h.viewport.transform.join(",")})`;A.style.transform=y}f&&A.setAttribute("class","xfaLayer xfaFont");let _=[];if(v.children.length===0){if(v.value){let y=document.createTextNode(v.value);a.append(y),f&&i.XfaText.shouldBuildText(v.name)&&_.push(y)}return{textDivs:_}}let d=[[v,-1,a]];for(;d.length>0;){let[y,r,l]=d.at(-1);if(r+1===y.children.length){d.pop();continue}let m=y.children[++d.at(-1)[1]];if(m===null)continue;let{name:x}=m;if(x==="#text"){let E=document.createTextNode(m.value);_.push(E),l.append(E);continue}let D=m?.attributes?.xmlns?document.createElementNS(m.attributes.xmlns,x):document.createElement(x);if(l.append(D),m.attributes&&this.setAttributes({html:D,element:m,storage:u,intent:p,linkService:g}),m.children?.length>0)d.push([m,-1,D]);else if(m.value){let E=document.createTextNode(m.value);f&&i.XfaText.shouldBuildText(x)&&_.push(E),D.append(E)}}for(let y of A.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))y.setAttribute("readOnly",!0);return{textDivs:_}}static update(h){let u=`matrix(${h.viewport.transform.join(",")})`;h.div.style.transform=u,h.div.hidden=!1}}},50:(s,t,e)=>{e.d(t,{XfaText:()=>i});class i{static textContent(o){let h=[],u={items:h,styles:Object.create(null)};return(function g(v){if(!v)return;let p=null,a=v.name;if(a==="#text")p=v.value;else{if(!i.shouldBuildText(a))return;v?.attributes?.textContent?p=v.attributes.textContent:v.value&&(p=v.value)}if(p!==null&&h.push({str:p}),v.children)for(let f of v.children)g(f)})(o),u}static shouldBuildText(o){return!(o==="textarea"||o==="input"||o==="option"||o==="select")}}},228:(s,t,e)=>{e.a(s,(async(i,n)=>{try{e.d(t,{AbortException:()=>o.AbortException,AnnotationEditorLayer:()=>v.AnnotationEditorLayer,AnnotationEditorParamsType:()=>o.AnnotationEditorParamsType,AnnotationEditorType:()=>o.AnnotationEditorType,AnnotationEditorUIManager:()=>p.AnnotationEditorUIManager,AnnotationLayer:()=>a.AnnotationLayer,AnnotationMode:()=>o.AnnotationMode,CMapCompressionType:()=>o.CMapCompressionType,ColorPicker:()=>f.ColorPicker,DOMSVGFactory:()=>u.DOMSVGFactory,DrawLayer:()=>A.DrawLayer,FeatureTest:()=>o.FeatureTest,GlobalWorkerOptions:()=>_.GlobalWorkerOptions,ImageKind:()=>o.ImageKind,InvalidPDFException:()=>o.InvalidPDFException,MissingPDFException:()=>o.MissingPDFException,OPS:()=>o.OPS,Outliner:()=>d.Outliner,PDFDataRangeTransport:()=>h.PDFDataRangeTransport,PDFDateString:()=>u.PDFDateString,PDFWorker:()=>h.PDFWorker,PasswordResponses:()=>o.PasswordResponses,PermissionFlag:()=>o.PermissionFlag,PixelsPerInch:()=>u.PixelsPerInch,RenderingCancelledException:()=>u.RenderingCancelledException,UnexpectedResponseException:()=>o.UnexpectedResponseException,Util:()=>o.Util,VerbosityLevel:()=>o.VerbosityLevel,XfaLayer:()=>y.XfaLayer,build:()=>h.build,createValidAbsoluteUrl:()=>o.createValidAbsoluteUrl,fetchData:()=>u.fetchData,getDocument:()=>h.getDocument,getFilenameFromUrl:()=>u.getFilenameFromUrl,getPdfFilenameFromUrl:()=>u.getPdfFilenameFromUrl,getXfaPageViewport:()=>u.getXfaPageViewport,isDataScheme:()=>u.isDataScheme,isPdfFile:()=>u.isPdfFile,noContextMenu:()=>u.noContextMenu,normalizeUnicode:()=>o.normalizeUnicode,renderTextLayer:()=>g.renderTextLayer,setLayerDimensions:()=>u.setLayerDimensions,shadow:()=>o.shadow,updateTextLayer:()=>g.updateTextLayer,version:()=>h.version});var o=e(292),h=e(831),u=e(419),g=e(814),v=e(731),p=e(830),a=e(976),f=e(259),A=e(47),_=e(164),d=e(61),y=e(284),r=i([h]);h=(r.then?(await r)():r)[0],n()}catch(l){n(l)}}))},178:(s,t,e)=>{e.d(t,{MessageHandler:()=>d});var i=e(292);let n=1,o=2,h=1,u=2,g=3,v=4,p=5,a=6,f=7,A=8;function _(y){switch(y instanceof Error||typeof y=="object"&&y!==null||(0,i.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),y.name){case"AbortException":return new i.AbortException(y.message);case"MissingPDFException":return new i.MissingPDFException(y.message);case"PasswordException":return new i.PasswordException(y.message,y.code);case"UnexpectedResponseException":return new i.UnexpectedResponseException(y.message,y.status);case"UnknownErrorException":return new i.UnknownErrorException(y.message,y.details);default:return new i.UnknownErrorException(y.message,y.toString())}}class d{constructor(r,l,m){this.sourceName=r,this.targetName=l,this.comObj=m,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),this._onComObjOnMessage=x=>{let D=x.data;if(D.targetName!==this.sourceName)return;if(D.stream){this.#e(D);return}if(D.callback){let M=D.callbackId,N=this.callbackCapabilities[M];if(!N)throw new Error(`Cannot resolve callback ${M}`);if(delete this.callbackCapabilities[M],D.callback===n)N.resolve(D.data);else{if(D.callback!==o)throw new Error("Unexpected callback case");N.reject(_(D.reason))}return}let E=this.actionHandler[D.action];if(!E)throw new Error(`Unknown action from worker: ${D.action}`);if(D.callbackId){let M=this.sourceName,N=D.sourceName;new Promise((function(H){H(E(D.data))})).then((function(H){m.postMessage({sourceName:M,targetName:N,callback:n,callbackId:D.callbackId,data:H})}),(function(H){m.postMessage({sourceName:M,targetName:N,callback:o,callbackId:D.callbackId,reason:_(H)})}))}else D.streamId?this.#t(D):E(D.data)},m.addEventListener("message",this._onComObjOnMessage)}on(r,l){let m=this.actionHandler;if(m[r])throw new Error(`There is already an actionName called "${r}"`);m[r]=l}send(r,l,m){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:r,data:l},m)}sendWithPromise(r,l,m){let x=this.callbackId++,D=Promise.withResolvers();this.callbackCapabilities[x]=D;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:r,callbackId:x,data:l},m)}catch(E){D.reject(E)}return D.promise}sendWithStream(r,l,m,x){let D=this.streamId++,E=this.sourceName,M=this.targetName,N=this.comObj;return new ReadableStream({start:H=>{let z=Promise.withResolvers();return this.streamControllers[D]={controller:H,startCall:z,pullCall:null,cancelCall:null,isClosed:!1},N.postMessage({sourceName:E,targetName:M,action:r,streamId:D,data:l,desiredSize:H.desiredSize},x),z.promise},pull:H=>{let z=Promise.withResolvers();return this.streamControllers[D].pullCall=z,N.postMessage({sourceName:E,targetName:M,stream:a,streamId:D,desiredSize:H.desiredSize}),z.promise},cancel:H=>{(0,i.assert)(H instanceof Error,"cancel must have a valid reason");let z=Promise.withResolvers();return this.streamControllers[D].cancelCall=z,this.streamControllers[D].isClosed=!0,N.postMessage({sourceName:E,targetName:M,stream:h,streamId:D,reason:_(H)}),z.promise}},m)}#t(r){let l=r.streamId,m=this.sourceName,x=r.sourceName,D=this.comObj,E=this,M=this.actionHandler[r.action],N={enqueue(H,z=1,K){if(this.isCancelled)return;let it=this.desiredSize;this.desiredSize-=z,it>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),D.postMessage({sourceName:m,targetName:x,stream:v,streamId:l,chunk:H},K)},close(){this.isCancelled||(this.isCancelled=!0,D.postMessage({sourceName:m,targetName:x,stream:g,streamId:l}),delete E.streamSinks[l])},error(H){(0,i.assert)(H instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,D.postMessage({sourceName:m,targetName:x,stream:p,streamId:l,reason:_(H)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:r.desiredSize,ready:null};N.sinkCapability.resolve(),N.ready=N.sinkCapability.promise,this.streamSinks[l]=N,new Promise((function(H){H(M(r.data,N))})).then((function(){D.postMessage({sourceName:m,targetName:x,stream:A,streamId:l,success:!0})}),(function(H){D.postMessage({sourceName:m,targetName:x,stream:A,streamId:l,reason:_(H)})}))}#e(r){let l=r.streamId,m=this.sourceName,x=r.sourceName,D=this.comObj,E=this.streamControllers[l],M=this.streamSinks[l];switch(r.stream){case A:r.success?E.startCall.resolve():E.startCall.reject(_(r.reason));break;case f:r.success?E.pullCall.resolve():E.pullCall.reject(_(r.reason));break;case a:if(!M){D.postMessage({sourceName:m,targetName:x,stream:f,streamId:l,success:!0});break}M.desiredSize<=0&&r.desiredSize>0&&M.sinkCapability.resolve(),M.desiredSize=r.desiredSize,new Promise((function(N){N(M.onPull?.())})).then((function(){D.postMessage({sourceName:m,targetName:x,stream:f,streamId:l,success:!0})}),(function(N){D.postMessage({sourceName:m,targetName:x,stream:f,streamId:l,reason:_(N)})}));break;case v:if((0,i.assert)(E,"enqueue should have stream controller"),E.isClosed)break;E.controller.enqueue(r.chunk);break;case g:if((0,i.assert)(E,"close should have stream controller"),E.isClosed)break;E.isClosed=!0,E.controller.close(),this.#i(E,l);break;case p:(0,i.assert)(E,"error should have stream controller"),E.controller.error(_(r.reason)),this.#i(E,l);break;case u:r.success?E.cancelCall.resolve():E.cancelCall.reject(_(r.reason)),this.#i(E,l);break;case h:if(!M)break;new Promise((function(N){N(M.onCancel?.(_(r.reason)))})).then((function(){D.postMessage({sourceName:m,targetName:x,stream:u,streamId:l,success:!0})}),(function(N){D.postMessage({sourceName:m,targetName:x,stream:u,streamId:l,reason:_(N)})})),M.sinkCapability.reject(_(r.reason)),M.isCancelled=!0,delete this.streamSinks[l];break;default:throw new Error("Unexpected stream case")}}async#i(r,l){await Promise.allSettled([r.startCall?.promise,r.pullCall?.promise,r.cancelCall?.promise]),delete this.streamControllers[l]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}},651:(s,t,e)=>{e.d(t,{MurmurHash3_64:()=>h});let i=3285377520,n=4294901760,o=65535;class h{constructor(g){this.h1=g?4294967295&g:i,this.h2=g?4294967295&g:i}update(g){let v,p;if(typeof g=="string"){v=new Uint8Array(2*g.length),p=0;for(let E=0,M=g.length;E<M;E++){let N=g.charCodeAt(E);N<=255?v[p++]=N:(v[p++]=N>>>8,v[p++]=255&N)}}else{if(!ArrayBuffer.isView(g))throw new Error("Invalid data format, must be a string or TypedArray.");v=g.slice(),p=v.byteLength}let a=p>>2,f=p-4*a,A=new Uint32Array(v.buffer,0,a),_=0,d=0,y=this.h1,r=this.h2,l=3432918353,m=461845907,x=11601,D=13715;for(let E=0;E<a;E++)1&E?(_=A[E],_=_*l&n|_*x&o,_=_<<15|_>>>17,_=_*m&n|_*D&o,y^=_,y=y<<13|y>>>19,y=5*y+3864292196):(d=A[E],d=d*l&n|d*x&o,d=d<<15|d>>>17,d=d*m&n|d*D&o,r^=d,r=r<<13|r>>>19,r=5*r+3864292196);switch(_=0,f){case 3:_^=v[4*a+2]<<16;case 2:_^=v[4*a+1]<<8;case 1:_^=v[4*a],_=_*l&n|_*x&o,_=_<<15|_>>>17,_=_*m&n|_*D&o,1&a?y^=_:r^=_}this.h1=y,this.h2=r}hexdigest(){let g=this.h1,v=this.h2;return g^=v>>>1,g=3981806797*g&n|36045*g&o,v=4283543511*v&n|(2950163797*(v<<16|g>>>16)&n)>>>16,g^=v>>>1,g=444984403*g&n|60499*g&o,v=3301882366*v&n|(3120437893*(v<<16|g>>>16)&n)>>>16,g^=v>>>1,(g>>>0).toString(16).padStart(8,"0")+(v>>>0).toString(16).padStart(8,"0")}}},292:(s,t,e)=>{e.d(t,{AbortException:()=>W,AnnotationBorderStyleType:()=>r,AnnotationEditorParamsType:()=>f,AnnotationEditorPrefix:()=>p,AnnotationEditorType:()=>a,AnnotationMode:()=>v,AnnotationPrefix:()=>$,AnnotationType:()=>y,BaseException:()=>j,CMapCompressionType:()=>m,FONT_IDENTITY_MATRIX:()=>o,FeatureTest:()=>b,FormatError:()=>st,IDENTITY_MATRIX:()=>n,ImageKind:()=>d,InvalidPDFException:()=>et,LINE_FACTOR:()=>u,MAX_IMAGE_SIZE_TO_CACHE:()=>h,MissingPDFException:()=>rt,OPS:()=>x,PasswordException:()=>G,PasswordResponses:()=>D,PermissionFlag:()=>A,RenderingIntentFlag:()=>g,TextRenderingMode:()=>_,UnexpectedResponseException:()=>ct,UnknownErrorException:()=>Y,Util:()=>k,VerbosityLevel:()=>l,assert:()=>it,bytesToString:()=>w,createValidAbsoluteUrl:()=>ot,getUuid:()=>L,getVerbosityLevel:()=>N,info:()=>H,isNodeJS:()=>i,normalizeUnicode:()=>S,objectFromMap:()=>c,setVerbosityLevel:()=>M,shadow:()=>X,string32:()=>R,stringToBytes:()=>T,unreachable:()=>K,warn:()=>z});let i=!(typeof process!="object"||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&process.type!=="browser"),n=[1,0,0,1,0,0],o=[.001,0,0,.001,0,0],h=1e7,u=1.35,g={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},v={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},p="pdfjs_internal_editor_",a={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},f={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},A={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},_={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},d={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},y={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,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},r={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},l={ERRORS:0,WARNINGS:1,INFOS:5},m={NONE:0,BINARY:1},x={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},D={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},E=l.WARNINGS;function M(U){Number.isInteger(U)&&(E=U)}function N(){return E}function H(U){E>=l.INFOS&&console.log(`Info: ${U}`)}function z(U){E>=l.WARNINGS&&console.log(`Warning: ${U}`)}function K(U){throw new Error(U)}function it(U,P){U||K(P)}function ot(U,P=null,F=null){if(!U)return null;try{if(F&&typeof U=="string"&&(F.addDefaultProtocol&&U.startsWith("www.")&&U.match(/\./g)?.length>=2&&(U=`http://${U}`),F.tryConvertEncoding))try{U=(function(Z){return decodeURIComponent(escape(Z))})(U)}catch{}let V=P?new URL(U,P):new URL(U);if((function(Z){switch(Z?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}})(V))return V}catch{}return null}function X(U,P,F,V=!1){return Object.defineProperty(U,P,{value:F,enumerable:!V,configurable:!0,writable:!1}),F}let j=(function(){function P(F,V){this.constructor===P&&K("Cannot initialize BaseException."),this.message=F,this.name=V}return P.prototype=new Error,P.constructor=P,P})();class G extends j{constructor(P,F){super(P,"PasswordException"),this.code=F}}class Y extends j{constructor(P,F){super(P,"UnknownErrorException"),this.details=F}}class et extends j{constructor(P){super(P,"InvalidPDFException")}}class rt extends j{constructor(P){super(P,"MissingPDFException")}}class ct extends j{constructor(P,F){super(P,"UnexpectedResponseException"),this.status=F}}class st extends j{constructor(P){super(P,"FormatError")}}class W extends j{constructor(P){super(P,"AbortException")}}function w(U){typeof U=="object"&&U?.length!==void 0||K("Invalid argument for bytesToString");let P=U.length,F=8192;if(P<F)return String.fromCharCode.apply(null,U);let V=[];for(let Q=0;Q<P;Q+=F){let Z=Math.min(Q+F,P),tt=U.subarray(Q,Z);V.push(String.fromCharCode.apply(null,tt))}return V.join("")}function T(U){typeof U!="string"&&K("Invalid argument for stringToBytes");let P=U.length,F=new Uint8Array(P);for(let V=0;V<P;++V)F[V]=255&U.charCodeAt(V);return F}function R(U){return String.fromCharCode(U>>24&255,U>>16&255,U>>8&255,255&U)}function c(U){let P=Object.create(null);for(let[F,V]of U)P[F]=V;return P}class b{static get isLittleEndian(){return X(this,"isLittleEndian",(function(){let F=new Uint8Array(4);return F[0]=1,new Uint32Array(F.buffer,0,1)[0]===1})())}static get isEvalSupported(){return X(this,"isEvalSupported",(function(){try{return new Function(""),!0}catch{return!1}})())}static get isOffscreenCanvasSupported(){return X(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?X(this,"platform",{isMac:navigator.platform.includes("Mac")}):X(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){return X(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}let C=Array.from(Array(256).keys(),(U=>U.toString(16).padStart(2,"0")));class k{static makeHexColor(P,F,V){return`#${C[P]}${C[F]}${C[V]}`}static scaleMinMax(P,F){let V;P[0]?(P[0]<0&&(V=F[0],F[0]=F[2],F[2]=V),F[0]*=P[0],F[2]*=P[0],P[3]<0&&(V=F[1],F[1]=F[3],F[3]=V),F[1]*=P[3],F[3]*=P[3]):(V=F[0],F[0]=F[1],F[1]=V,V=F[2],F[2]=F[3],F[3]=V,P[1]<0&&(V=F[1],F[1]=F[3],F[3]=V),F[1]*=P[1],F[3]*=P[1],P[2]<0&&(V=F[0],F[0]=F[2],F[2]=V),F[0]*=P[2],F[2]*=P[2]),F[0]+=P[4],F[1]+=P[5],F[2]+=P[4],F[3]+=P[5]}static transform(P,F){return[P[0]*F[0]+P[2]*F[1],P[1]*F[0]+P[3]*F[1],P[0]*F[2]+P[2]*F[3],P[1]*F[2]+P[3]*F[3],P[0]*F[4]+P[2]*F[5]+P[4],P[1]*F[4]+P[3]*F[5]+P[5]]}static applyTransform(P,F){return[P[0]*F[0]+P[1]*F[2]+F[4],P[0]*F[1]+P[1]*F[3]+F[5]]}static applyInverseTransform(P,F){let V=F[0]*F[3]-F[1]*F[2];return[(P[0]*F[3]-P[1]*F[2]+F[2]*F[5]-F[4]*F[3])/V,(-P[0]*F[1]+P[1]*F[0]+F[4]*F[1]-F[5]*F[0])/V]}static getAxialAlignedBoundingBox(P,F){let V=this.applyTransform(P,F),Q=this.applyTransform(P.slice(2,4),F),Z=this.applyTransform([P[0],P[3]],F),tt=this.applyTransform([P[2],P[1]],F);return[Math.min(V[0],Q[0],Z[0],tt[0]),Math.min(V[1],Q[1],Z[1],tt[1]),Math.max(V[0],Q[0],Z[0],tt[0]),Math.max(V[1],Q[1],Z[1],tt[1])]}static inverseTransform(P){let F=P[0]*P[3]-P[1]*P[2];return[P[3]/F,-P[1]/F,-P[2]/F,P[0]/F,(P[2]*P[5]-P[4]*P[3])/F,(P[4]*P[1]-P[5]*P[0])/F]}static singularValueDecompose2dScale(P){let F=[P[0],P[2],P[1],P[3]],V=P[0]*F[0]+P[1]*F[2],Q=P[0]*F[1]+P[1]*F[3],Z=P[2]*F[0]+P[3]*F[2],tt=P[2]*F[1]+P[3]*F[3],nt=(V+tt)/2,pt=Math.sqrt((V+tt)**2-4*(V*tt-Z*Q))/2,dt=nt+pt||1,lt=nt-pt||1;return[Math.sqrt(dt),Math.sqrt(lt)]}static normalizeRect(P){let F=P.slice(0);return P[0]>P[2]&&(F[0]=P[2],F[2]=P[0]),P[1]>P[3]&&(F[1]=P[3],F[3]=P[1]),F}static intersect(P,F){let V=Math.max(Math.min(P[0],P[2]),Math.min(F[0],F[2])),Q=Math.min(Math.max(P[0],P[2]),Math.max(F[0],F[2]));if(V>Q)return null;let Z=Math.max(Math.min(P[1],P[3]),Math.min(F[1],F[3])),tt=Math.min(Math.max(P[1],P[3]),Math.max(F[1],F[3]));return Z>tt?null:[V,Z,Q,tt]}static#t(P,F,V,Q,Z,tt,nt,pt,dt,lt){if(dt<=0||dt>=1)return;let wt=1-dt,Tt=dt*dt,xt=Tt*dt,Dt=wt*(wt*(wt*P+3*dt*F)+3*Tt*V)+xt*Q,Mt=wt*(wt*(wt*Z+3*dt*tt)+3*Tt*nt)+xt*pt;lt[0]=Math.min(lt[0],Dt),lt[1]=Math.min(lt[1],Mt),lt[2]=Math.max(lt[2],Dt),lt[3]=Math.max(lt[3],Mt)}static#e(P,F,V,Q,Z,tt,nt,pt,dt,lt,wt,Tt){if(Math.abs(dt)<1e-12){Math.abs(lt)>=1e-12&&this.#t(P,F,V,Q,Z,tt,nt,pt,-wt/lt,Tt);return}let xt=lt**2-4*wt*dt;if(xt<0)return;let Dt=Math.sqrt(xt),Mt=2*dt;this.#t(P,F,V,Q,Z,tt,nt,pt,(-lt+Dt)/Mt,Tt),this.#t(P,F,V,Q,Z,tt,nt,pt,(-lt-Dt)/Mt,Tt)}static bezierBoundingBox(P,F,V,Q,Z,tt,nt,pt,dt){return dt?(dt[0]=Math.min(dt[0],P,nt),dt[1]=Math.min(dt[1],F,pt),dt[2]=Math.max(dt[2],P,nt),dt[3]=Math.max(dt[3],F,pt)):dt=[Math.min(P,nt),Math.min(F,pt),Math.max(P,nt),Math.max(F,pt)],this.#e(P,V,Z,nt,F,Q,tt,pt,3*(3*(V-Z)-P+nt),6*(P-2*V+Z),3*(V-P),dt),this.#e(P,V,Z,nt,F,Q,tt,pt,3*(3*(Q-tt)-F+pt),6*(F-2*Q+tt),3*(Q-F),dt),dt}}let O=null,I=null;function S(U){return O||(O=/([\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,I=new Map([["\uFB05","\u017Ft"]])),U.replaceAll(O,((P,F,V)=>F?F.normalize("NFKC"):I.get(V)))}function L(){if(typeof crypto<"u"&&typeof crypto?.randomUUID=="function")return crypto.randomUUID();let U=new Uint8Array(32);if(typeof crypto<"u"&&typeof crypto?.getRandomValues=="function")crypto.getRandomValues(U);else for(let P=0;P<32;P++)U[P]=Math.floor(255*Math.random());return w(U)}let $="pdfjs_internal_id_"}},Uc={};function Vi(s){var t=Uc[s];if(t!==void 0)return t.exports;var e=Uc[s]={exports:{}};return lu[s](e,e.exports,Vi),e.exports}_s=typeof Symbol=="function"?Symbol("webpack queues"):"__webpack_queues__",pn=typeof Symbol=="function"?Symbol("webpack exports"):"__webpack_exports__",fn=typeof Symbol=="function"?Symbol("webpack error"):"__webpack_error__",Nr=s=>{s&&s.d<1&&(s.d=1,s.forEach((t=>t.r--)),s.forEach((t=>t.r--?t.r++:t())))},Vi.a=(s,t,e)=>{var i;e&&((i=[]).d=-1);var n,o,h,u=new Set,g=s.exports,v=new Promise(((p,a)=>{h=a,o=p}));v[pn]=g,v[_s]=p=>(i&&p(i),u.forEach(p),v.catch((a=>{}))),s.exports=v,t((p=>{n=(_=>_.map((d=>{if(d!==null&&typeof d=="object"){if(d[_s])return d;if(d.then){var y=[];y.d=0,d.then((m=>{r[pn]=m,Nr(y)}),(m=>{r[fn]=m,Nr(y)}));var r={};return r[_s]=m=>m(y),r}}var l={};return l[_s]=m=>{},l[pn]=d,l})))(p);var a,f=()=>n.map((_=>{if(_[fn])throw _[fn];return _[pn]})),A=new Promise((_=>{(a=()=>_(f)).r=0;var d=y=>y!==i&&!u.has(y)&&(u.add(y),y&&!y.d&&(a.r++,y.push(a)));n.map((y=>y[_s](d)))}));return a.r?A:f()}),(p=>(p?h(v[fn]=p):o(g),Nr(i)))),i&&i.d<0&&(i.d=0)};Vi.d=(s,t)=>{for(var e in t)Vi.o(t,e)&&!Vi.o(s,e)&&Object.defineProperty(s,e,{enumerable:!0,get:t[e]})};Vi.o=(s,t)=>Object.prototype.hasOwnProperty.call(s,t);var Ct=Vi(228),rf=(Ct=globalThis.pdfjsLib=await(globalThis.pdfjsLibPromise=Ct)).AbortException,af=Ct.AnnotationEditorLayer,of=Ct.AnnotationEditorParamsType,lf=Ct.AnnotationEditorType,cf=Ct.AnnotationEditorUIManager,hf=Ct.AnnotationLayer,df=Ct.AnnotationMode,uf=Ct.CMapCompressionType,pf=Ct.ColorPicker,ff=Ct.DOMSVGFactory,gf=Ct.DrawLayer,mf=Ct.FeatureTest,$c=Ct.GlobalWorkerOptions,bf=Ct.ImageKind,vf=Ct.InvalidPDFException,yf=Ct.MissingPDFException,wf=Ct.OPS,xf=Ct.Outliner,Af=Ct.PDFDataRangeTransport,Sf=Ct.PDFDateString,Ef=Ct.PDFWorker,_f=Ct.PasswordResponses,Cf=Ct.PermissionFlag,kf=Ct.PixelsPerInch,Tf=Ct.RenderingCancelledException,Pf=Ct.UnexpectedResponseException,Df=Ct.Util,If=Ct.VerbosityLevel,Mf=Ct.XfaLayer,Rf=Ct.build,Lf=Ct.createValidAbsoluteUrl,Ff=Ct.fetchData,Hc=Ct.getDocument,Of=Ct.getFilenameFromUrl,Nf=Ct.getPdfFilenameFromUrl,Bf=Ct.getXfaPageViewport,Uf=Ct.isDataScheme,$f=Ct.isPdfFile,Hf=Ct.noContextMenu,zf=Ct.normalizeUnicode,jf=Ct.renderTextLayer,Vf=Ct.setLayerDimensions,Gf=Ct.shadow,Wf=Ct.updateTextLayer,qf=Ct.version;$c.workerSrc=ja("js/lib/pdf.worker.min.mjs");async function zc(s,t=2){let e=await Hc({data:s}).promise,i=[];for(let n=1;n<=e.numPages;n++){let o=await e.getPage(n),h=o.getViewport({scale:t}),u=document.createElement("canvas"),g=u.getContext("2d");u.width=h.width,u.height=h.height,await o.render({canvasContext:g,viewport:h}).promise,i.push(u.toDataURL("image/jpeg",.82))}return i}var Gc=null,jc={success:{slVariant:"success",defaultIcon:"check-circle",defaultDuration:3e3},error:{slVariant:"danger",defaultIcon:"exclamation-octagon",defaultDuration:5e3},danger:{slVariant:"danger",defaultIcon:"exclamation-octagon",defaultDuration:5e3},warning:{slVariant:"warning",defaultIcon:"exclamation-triangle",defaultDuration:4e3},info:{slVariant:"primary",defaultIcon:"info-circle",defaultDuration:4e3},primary:{slVariant:"primary",defaultIcon:"info-circle",defaultDuration:4e3},neutral:{slVariant:"neutral",defaultIcon:"info-circle",defaultDuration:4e3}};function Cs(s){Gc=s||null}function ks(){return Gc||(typeof document<"u"?document.body:null)}function hu(){let t=customElements.get("sl-alert")?.toastStack;t&&t.querySelectorAll("sl-alert").forEach(i=>{typeof i.hide=="function"&&i.hide()})}async function Vc(s,t={}){let e={};if(typeof s=="string"||s instanceof HTMLElement?e={message:s,...t}:s&&typeof s=="object"&&(e={...s,...t}),typeof customElements<"u"&&!customElements.get("sl-alert")&&await Promise.race([customElements.whenDefined("sl-alert"),new Promise(a=>setTimeout(a,200))]),typeof customElements>"u"||!customElements.get("sl-alert"))return null;let i=customElements.get("sl-alert"),n=e.variant||"info",o=jc[n]||jc.info,h=e.container||ks();if(i?.toastStack&&h){let a=i.toastStack;a.parentElement!==h&&h.appendChild(a),h!==document.body?(a.style.position="absolute",a.style.width="auto",a.style.maxWidth="calc(100% - 24px)",a.style.left="12px",a.style.right="12px",a.style.insetInlineStart="12px",a.style.insetInlineEnd="12px",e.position==="top"?(a.style.top="12px",a.style.bottom="auto"):(a.style.top="auto",a.style.bottom="16px"),a.style.maxHeight="100%",a.style.overflow="auto"):(a.style.position="",a.style.width="",a.style.left="",a.style.right="",a.style.top="",a.style.bottom="",a.style.insetInlineStart="",a.style.insetInlineEnd="",a.style.maxHeight="",a.style.maxWidth="",a.style.overflow="")}let u=document.createElement("sl-alert");u.variant=o.slVariant,u.closable=e.closable!==!1,u.duration=e.duration!==void 0?e.duration:o.defaultDuration;let g=e.icon!==void 0?e.icon:o.defaultIcon;if(g){let a=document.createElement("sl-icon");a.slot="icon",a.name=g,u.appendChild(a)}let v=document.createElement("span");if(e.message instanceof HTMLElement?v.appendChild(e.message):e.html?v.innerHTML=e.message||"":v.textContent=e.message||"",e.action){let a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.justifyContent="space-between",a.style.gap="0.75rem",a.style.width="100%",v.style.flex="1",a.appendChild(v);let f=document.createElement("sl-button");f.size="small",f.variant=e.action.variant||"text",f.textContent=e.action.text||"Action",f.style.color="inherit",f.style.fontWeight="600",f.style.padding="0",f.addEventListener("click",A=>{A.preventDefault(),A.stopPropagation(),typeof e.action.onClick=="function"&&e.action.onClick(A,u),e.action.autoClose!==!1&&u.hide()}),a.appendChild(f),u.appendChild(a)}else u.appendChild(v);let p=u.toast();return u.toastPromise=p,u}function du(s,t={}){return me.show({message:s,variant:"success",...t})}function uu(s,t={}){return me.show({message:s,variant:"error",...t})}function pu(s,t={}){return me.show({message:s,variant:"warning",...t})}function fu(s,t={}){return me.show({message:s,variant:"info",...t})}function gu(s,t,e={}){return me.show({message:s,variant:e?.variant||"primary",icon:e?.icon!==void 0?e.icon:"arrow-counterclockwise",duration:e?.duration!==void 0?e.duration:5e3,closable:e?.closable!==!1,action:{text:e?.actionText||"Undo",onClick:(i,n)=>{typeof t=="function"&&t(i,n)},autoClose:!0},...e})}async function mu(s,t={}){let e={};if(typeof s=="string"?e={message:s,...t}:s&&typeof s=="object"&&(e={...s,...t}),typeof customElements<"u"&&(!customElements.get("sl-alert")||!customElements.get("sl-progress-bar"))&&await Promise.race([Promise.all([customElements.whenDefined("sl-alert"),customElements.whenDefined("sl-progress-bar")]),new Promise(d=>setTimeout(d,200))]),typeof customElements>"u"||!customElements.get("sl-alert"))return{alert:null,progressBar:null,update(){},close(){}};let i=e.container||ks(),n=document.createElement("sl-alert");n.variant=e.variant||"primary",n.closable=e.closable===!0,n.duration=1/0;let o=e.icon!==void 0?e.icon:"arrow-down-circle";if(o){let d=document.createElement("sl-icon");d.slot="icon",d.name=o,n.appendChild(d)}let h=document.createElement("div");h.className="notify-progress-wrapper",h.style.display="flex",h.style.flexDirection="column",h.style.gap="0.35rem",h.style.minWidth="220px";let u=document.createElement("div");u.style.display="flex",u.style.justifyContent="space-between",u.style.alignItems="center",u.style.gap="0.5rem";let g=document.createElement("span");g.className="notify-progress-message",g.style.fontWeight="500",g.style.fontSize="0.9rem",g.textContent=e.message||"Processing...",u.appendChild(g);let v=document.createElement("span");v.className="notify-progress-status",v.style.fontSize="0.78rem",v.style.color="#64748b",v.style.fontWeight="600";let p=e.done!==void 0?e.done:0,a=e.total!==void 0?e.total:0;a>0?v.textContent=`${p} / ${a}`:e.value!==void 0&&(v.textContent=`${e.value}%`),u.appendChild(v),h.appendChild(u);let f=document.createElement("sl-progress-bar");a>0?f.value=Math.round(p/a*100):e.value!==void 0?f.value=e.value:f.indeterminate=!0,h.appendChild(f),n.appendChild(h);let A=customElements.get("sl-alert");if(A?.toastStack&&i){let d=A.toastStack;d.parentElement!==i&&i.appendChild(d)}return n.toast(),{alert:n,progressBar:f,update({done:d,total:y,value:r,message:l}={}){if(l!==void 0&&(g.textContent=l),y!==void 0&&d!==void 0){f.indeterminate=!1;let m=Math.min(100,Math.max(0,Math.round(d/Math.max(y,1)*100)));f.value=m,v.textContent=`${d} / ${y}`}else r!==void 0&&(f.indeterminate=!1,f.value=Math.min(100,Math.max(0,r)),v.textContent=`${Math.round(f.value)}%`)},close(){typeof n.hide=="function"&&n.hide()}}}var me=Object.assign(function(s,t){return Vc(s,t)},{show:Vc,success:du,error:uu,warning:pu,info:fu,undo:gu,progress:mu,clear:hu,setContainer:Cs,getContainer:ks});var Wc=`
15
+ .cropper-container {
16
+ direction: ltr;
17
+ font-size: 0;
18
+ line-height: 0;
19
+ position: relative;
20
+ -ms-touch-action: none;
21
+ touch-action: none;
22
+ -webkit-user-select: none;
23
+ -moz-user-select: none;
24
+ -ms-user-select: none;
25
+ user-select: none;
26
+ }
27
+
28
+ .cropper-container img {
29
+ display: block;
30
+ height: 100%;
31
+ image-orientation: 0deg;
32
+ max-height: none !important;
33
+ max-width: none !important;
34
+ min-height: 0 !important;
35
+ min-width: 0 !important;
36
+ width: 100%;
37
+ }
38
+
39
+ .cropper-wrap-box,
40
+ .cropper-canvas,
41
+ .cropper-drag-box,
42
+ .cropper-crop-box,
43
+ .cropper-modal {
44
+ bottom: 0;
45
+ left: 0;
46
+ position: absolute;
47
+ right: 0;
48
+ top: 0;
49
+ }
50
+
51
+ .cropper-wrap-box,
52
+ .cropper-canvas {
53
+ overflow: hidden;
54
+ }
55
+
56
+ .cropper-drag-box {
57
+ background-color: #fff;
58
+ opacity: 0;
59
+ }
60
+
61
+ .cropper-modal {
62
+ background-color: #000;
63
+ opacity: 0.5;
64
+ }
65
+
66
+ .cropper-view-box {
67
+ display: block;
68
+ height: 100%;
69
+ outline-color: rgba(51, 153, 255, 0.75);
70
+ outline: 1px solid #39f;
71
+ overflow: hidden;
72
+ width: 100%;
73
+ }
74
+
75
+ .cropper-dashed {
76
+ border: 0 dashed #eee;
77
+ display: block;
78
+ opacity: 0.5;
79
+ position: absolute;
80
+ }
81
+
82
+ .cropper-dashed.dashed-h {
83
+ border-bottom-width: 1px;
84
+ border-top-width: 1px;
85
+ height: 33.33333%;
86
+ left: 0;
87
+ top: 33.33333%;
88
+ width: 100%;
89
+ }
90
+
91
+ .cropper-dashed.dashed-v {
92
+ border-left-width: 1px;
93
+ border-right-width: 1px;
94
+ height: 100%;
95
+ left: 33.33333%;
96
+ top: 0;
97
+ width: 33.33333%;
98
+ }
99
+
100
+ .cropper-center {
101
+ display: block;
102
+ height: 0;
103
+ left: 50%;
104
+ opacity: 0.75;
105
+ position: absolute;
106
+ top: 50%;
107
+ width: 0;
108
+ }
109
+
110
+ .cropper-center:before,
111
+ .cropper-center:after {
112
+ background-color: #eee;
113
+ content: ' ';
114
+ display: block;
115
+ position: absolute;
116
+ }
117
+
118
+ .cropper-center:before {
119
+ height: 1px;
120
+ left: -3px;
121
+ top: 0;
122
+ width: 7px;
123
+ }
124
+
125
+ .cropper-center:after {
126
+ height: 7px;
127
+ left: 0;
128
+ top: -3px;
129
+ width: 1px;
130
+ }
131
+
132
+ .cropper-face,
133
+ .cropper-line,
134
+ .cropper-point {
135
+ display: block;
136
+ height: 100%;
137
+ opacity: 0.1;
138
+ position: absolute;
139
+ width: 100%;
140
+ }
141
+
142
+ .cropper-face {
143
+ background-color: #fff;
144
+ left: 0;
145
+ top: 0;
146
+ }
147
+
148
+ .cropper-line {
149
+ background-color: #39f;
150
+ }
151
+
152
+ .cropper-line.line-e {
153
+ cursor: ew-resize;
154
+ right: -3px;
155
+ top: 0;
156
+ width: 5px;
157
+ }
158
+
159
+ .cropper-line.line-n {
160
+ cursor: ns-resize;
161
+ height: 5px;
162
+ left: 0;
163
+ top: -3px;
164
+ }
165
+
166
+ .cropper-line.line-w {
167
+ cursor: ew-resize;
168
+ left: -3px;
169
+ top: 0;
170
+ width: 5px;
171
+ }
172
+
173
+ .cropper-line.line-s {
174
+ bottom: -3px;
175
+ cursor: ns-resize;
176
+ height: 5px;
177
+ left: 0;
178
+ }
179
+
180
+ .cropper-point {
181
+ width: var(--copio-crop-handle-hit, 48px);
182
+ height: var(--copio-crop-handle-hit, 48px);
183
+ min-width: 44px;
184
+ min-height: 44px;
185
+ background-color: transparent;
186
+ opacity: 1;
187
+ display: flex;
188
+ align-items: center;
189
+ justify-content: center;
190
+ box-sizing: border-box;
191
+ touch-action: none;
192
+ z-index: 10;
193
+ }
194
+
195
+ .cropper-point::after {
196
+ content: '';
197
+ display: block;
198
+ width: var(--copio-crop-handle-visual, 16px);
199
+ height: var(--copio-crop-handle-visual, 16px);
200
+ border-radius: 50%;
201
+ background-color: var(--copio-color-primary, #38bdf8);
202
+ border: 2.5px solid #ffffff;
203
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
204
+ transition: transform 120ms ease;
205
+ box-sizing: border-box;
206
+ }
207
+
208
+ .cropper-point:hover::after,
209
+ .cropper-point:active::after {
210
+ transform: scale(1.25);
211
+ background-color: var(--copio-color-success, #22c55e);
212
+ }
213
+
214
+ .cropper-point.point-e {
215
+ cursor: ew-resize;
216
+ margin-top: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
217
+ right: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
218
+ top: 50%;
219
+ }
220
+
221
+ .cropper-point.point-n {
222
+ cursor: ns-resize;
223
+ left: 50%;
224
+ margin-left: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
225
+ top: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
226
+ }
227
+
228
+ .cropper-point.point-w {
229
+ cursor: ew-resize;
230
+ left: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
231
+ margin-top: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
232
+ top: 50%;
233
+ }
234
+
235
+ .cropper-point.point-s {
236
+ bottom: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
237
+ cursor: s-resize;
238
+ left: 50%;
239
+ margin-left: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
240
+ }
241
+
242
+ .cropper-point.point-ne {
243
+ cursor: nesw-resize;
244
+ right: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
245
+ top: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
246
+ }
247
+
248
+ .cropper-point.point-nw {
249
+ cursor: nwse-resize;
250
+ left: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
251
+ top: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
252
+ }
253
+
254
+ .cropper-point.point-sw {
255
+ bottom: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
256
+ cursor: nesw-resize;
257
+ left: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
258
+ }
259
+
260
+ .cropper-point.point-se {
261
+ bottom: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
262
+ cursor: nwse-resize;
263
+ right: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
264
+ }
265
+
266
+ .cropper-invisible {
267
+ opacity: 0;
268
+ }
269
+
270
+ .cropper-bg {
271
+ background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC');
272
+ }
273
+
274
+ .cropper-hide {
275
+ display: block;
276
+ height: 0;
277
+ position: absolute;
278
+ width: 0;
279
+ }
280
+
281
+ .cropper-hidden {
282
+ display: none !important;
283
+ }
284
+
285
+ .cropper-move {
286
+ cursor: move;
287
+ }
288
+
289
+ .cropper-crop {
290
+ cursor: crosshair;
291
+ }
292
+
293
+ .cropper-disabled .cropper-drag-box,
294
+ .cropper-disabled .cropper-face,
295
+ .cropper-disabled .cropper-line,
296
+ .cropper-disabled .cropper-point {
297
+ cursor: not-allowed;
298
+ }
299
+ `;var Br=class extends HTMLElement{#t=[];#e=null;#i=null;#n=null;#r=null;#s=!1;#a=null;#c=new Set;#o=null;#d=!0;#p=!0;constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.#s||(this.#g(),this.#s=!0),this.#h()}disconnectedCallback(){if(this.#i){try{this.#i.destroy()}catch(i){console.warn("Error destroying Sortable:",i)}this.#i=null}if(this.#e){try{this.#e.destroy()}catch(i){console.warn("Error destroying Cropper:",i)}this.#e=null}this.#n=null,this.#r=null,this.stopCamera(),this.#f(),this.#a&&(this.#a.abort(),this.#a=null);let t=this.shadowRoot.querySelector(".file-input"),e=this.shadowRoot.querySelector(".camera-input");t&&(t.onchange=null),e&&(e.onchange=null),this.#s=!1}setCameraStream(t){this.stopCamera(),this.#o=t||null}stopCamera(){if(this.#o){try{(typeof this.#o.getTracks=="function"?this.#o.getTracks():[]).forEach(e=>{typeof e.stop=="function"&&e.stop()})}catch(t){console.warn("Error stopping camera tracks:",t)}this.#o=null}}#u(t){return t&&typeof t=="string"&&t.startsWith("blob:")&&this.#c.add(t),t}#l(t){if(this.#c.has(t)){try{URL.revokeObjectURL(t)}catch{}this.#c.delete(t)}}#f(){for(let t of this.#c)try{URL.revokeObjectURL(t)}catch{}this.#c.clear()}#g(){let t=`
300
+ <style>
301
+ ${Wc}
302
+ </style>
303
+ <style>
304
+ .container {
305
+ display: grid;
306
+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
307
+ gap: 0.75rem;
308
+ max-width: 100%;
309
+ min-height: 140px;
310
+ padding: 0.5rem;
311
+ border-radius: 8px;
312
+ border: 2px dashed transparent;
313
+ box-sizing: border-box;
314
+ transition: border-color 0.2s, background-color 0.2s;
315
+ }
316
+ .container.drag-over {
317
+ border-color: #3b82f6;
318
+ background-color: rgba(59, 130, 246, 0.08);
319
+ box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.2);
320
+ }
321
+ @container copio-scanner (max-width: 400px) {
322
+ .container {
323
+ grid-template-columns: repeat(2, 1fr);
324
+ gap: 0.5rem;
325
+ padding: 0.25rem;
326
+ }
327
+ }
328
+ @container copio-scanner (min-width: 401px) and (max-width: 767px) {
329
+ .container {
330
+ grid-template-columns: repeat(3, 1fr);
331
+ gap: 0.75rem;
332
+ }
333
+ }
334
+ @container copio-scanner (min-width: 768px) {
335
+ .container {
336
+ grid-template-columns: repeat(4, 1fr);
337
+ gap: 1rem;
338
+ }
339
+ }
340
+ /* Fallbacks if container queries are unsupported or outside named container */
341
+ @supports not (container-type: size) {
342
+ @media (min-width: 640px) {
343
+ .container {
344
+ grid-template-columns: repeat(3, 1fr);
345
+ }
346
+ }
347
+ @media (min-width: 1024px) {
348
+ .container {
349
+ grid-template-columns: repeat(4, 1fr);
350
+ }
351
+ }
352
+ }
353
+ .image-wrapper {
354
+ cursor: grab;
355
+ position: relative;
356
+ user-select: none;
357
+ -webkit-user-select: none;
358
+ width: 100%;
359
+ aspect-ratio: 1;
360
+ }
361
+ .image-wrapper:active {
362
+ cursor: grabbing;
363
+ }
364
+ .image-wrapper.dragging {
365
+ opacity: 0.4;
366
+ cursor: grabbing;
367
+ }
368
+ .image-wrapper.sortable-ghost {
369
+ opacity: 0.2;
370
+ }
371
+ .image-menu {
372
+ position: absolute;
373
+ top: 4px;
374
+ right: 4px;
375
+ }
376
+ img {
377
+ width: 100%;
378
+ height: 100%;
379
+ object-fit: cover;
380
+ border: 1px solid #ccc;
381
+ border-radius: 4px;
382
+ display: block;
383
+ }
384
+ #crop-image {
385
+ max-width: 100%;
386
+ max-height: 100%;
387
+ display: block;
388
+ }
389
+ .crop-wrapper {
390
+ width: 100%;
391
+ height: 360px;
392
+ max-height: min(50vh, 380px);
393
+ min-height: 200px;
394
+ position: relative;
395
+ display: flex;
396
+ align-items: center;
397
+ justify-content: center;
398
+ overflow: visible;
399
+ box-sizing: border-box;
400
+ margin-bottom: 0.5rem;
401
+ }
402
+ sl-dialog::part(base) {
403
+ position: absolute;
404
+ }
405
+ sl-dialog::part(overlay) {
406
+ position: absolute;
407
+ }
408
+ sl-dialog::part(panel) {
409
+ max-width: calc(100% - 20px);
410
+ max-height: calc(100% - 20px);
411
+ }
412
+ .crop-dialog::part(panel) {
413
+ max-width: min(94%, 560px);
414
+ max-height: calc(100% - 16px);
415
+ display: flex;
416
+ flex-direction: column;
417
+ }
418
+ .crop-dialog::part(body) {
419
+ padding: 24px;
420
+ overflow: hidden;
421
+ display: flex;
422
+ align-items: center;
423
+ justify-content: center;
424
+ flex: 1 1 auto;
425
+ min-height: 0;
426
+ }
427
+ @container copio-scanner (max-width: 400px) {
428
+ .crop-wrapper {
429
+ height: 240px;
430
+ max-height: 42cqh;
431
+ min-height: 160px;
432
+ }
433
+ .crop-dialog::part(panel) {
434
+ max-width: calc(100% - 12px);
435
+ max-height: calc(100% - 12px);
436
+ }
437
+ .crop-dialog::part(body) {
438
+ padding: 16px;
439
+ }
440
+ .crop-dialog::part(header) {
441
+ padding: 0.5rem 0.75rem;
442
+ }
443
+ .crop-dialog::part(footer) {
444
+ padding: 0.5rem 0.75rem;
445
+ }
446
+ }
447
+ .markdown-card {
448
+ width: 100%;
449
+ height: 100%;
450
+ border: 1px solid #334155;
451
+ border-radius: 4px;
452
+ background: #0f172a;
453
+ color: #f8fafc;
454
+ padding: 10px;
455
+ box-sizing: border-box;
456
+ font-family: monospace;
457
+ font-size: 0.72rem;
458
+ overflow: hidden;
459
+ display: flex;
460
+ flex-direction: column;
461
+ }
462
+ .markdown-card-header {
463
+ display: flex;
464
+ align-items: center;
465
+ gap: 4px;
466
+ font-weight: bold;
467
+ font-size: 0.75rem;
468
+ color: #38bdf8;
469
+ margin-bottom: 6px;
470
+ white-space: nowrap;
471
+ overflow: hidden;
472
+ text-overflow: ellipsis;
473
+ }
474
+ .markdown-card-body {
475
+ flex: 1;
476
+ opacity: 0.8;
477
+ word-break: break-word;
478
+ overflow: hidden;
479
+ line-height: 1.35;
480
+ }
481
+ button.add-btn {
482
+ width: 100%;
483
+ aspect-ratio: 1;
484
+ font-size: 1.6rem;
485
+ border: 2px dashed #888;
486
+ border-radius: 4px;
487
+ background: none;
488
+ cursor: pointer;
489
+ display: flex;
490
+ align-items: center;
491
+ justify-content: center;
492
+ color: #64748b;
493
+ transition: border-color 0.15s, color 0.15s, background-color 0.15s;
494
+ }
495
+ button.add-btn:hover {
496
+ border-color: #3b82f6;
497
+ color: #3b82f6;
498
+ background-color: rgba(59, 130, 246, 0.04);
499
+ }
500
+ dialog {
501
+ border: none;
502
+ border-radius: 6px;
503
+ padding: 1rem;
504
+ }
505
+ dialog::backdrop {
506
+ background: rgba(0, 0, 0, 0.3);
507
+ }
508
+ </style>
509
+ `;this.shadowRoot.innerHTML=`
510
+ ${t}
511
+ <div class="container"></div>
512
+
513
+ <input type="file" class="file-input" accept="image/*,application/pdf,.md,.markdown,text/plain" multiple style="display: none">
514
+ <input type="file" class="camera-input" accept="image/*" capture="environment" style="display: none">
515
+
516
+ <sl-dialog label="Edit Markdown Text" class="text-dialog" style="--width: min(92%, 560px)">
517
+ <div style="margin-bottom: 1rem;">
518
+ <sl-textarea class="text-editor" rows="12" placeholder="Enter markdown content..."></sl-textarea>
519
+ </div>
520
+ <sl-button slot="footer" variant="default" class="cancel-text">Cancel</sl-button>
521
+ <sl-button slot="footer" variant="primary" class="apply-text">Save Text</sl-button>
522
+ </sl-dialog>
523
+
524
+ <sl-dialog label="Image Data" class="data-dialog">
525
+ <div class="exif-data" style="font-size: 0.85rem; line-height: 1.6;"></div>
526
+ <sl-button slot="footer" variant="primary" class="close-data">Close</sl-button>
527
+ </sl-dialog>
528
+
529
+ <sl-dialog label="Crop Image" class="crop-dialog" style="--width: min(94%, 560px)">
530
+ <div class="crop-wrapper">
531
+ <img id="crop-image" />
532
+ </div>
533
+ <sl-button slot="footer" variant="default" class="cancel-crop">Cancel</sl-button>
534
+ <sl-button slot="footer" variant="primary" class="apply-crop">Apply</sl-button>
535
+ </sl-dialog>
536
+ `,this.#a&&this.#a.abort(),this.#a=new AbortController;let{signal:e}=this.#a,i=this.shadowRoot.querySelector(".close-data");i&&i.addEventListener("click",()=>{this.shadowRoot.querySelector(".data-dialog")?.hide()},{signal:e});let n=this.shadowRoot.querySelector(".file-input"),o=this.shadowRoot.querySelector(".camera-input"),h=!1,u=async x=>{if(h)return;let D=Array.from(x.target?.files||[]);if(D.length!==0){h=!0;try{await this.addFiles(D)}finally{x.target&&(x.target.value=""),h=!1}}};n&&(n.onchange=u,n.addEventListener("change",u,{signal:e})),o&&(o.onchange=u,o.addEventListener("change",u,{signal:e}));let g=0,v=x=>{let D=x.dataTransfer;if(!D)return!1;if(!D.types||D.types.length===0)return!0;let E=Array.from(D.types);return E.includes("Files")||E.some(M=>M.startsWith("image/")||M.startsWith("public.")||M.includes("pdf")||M.includes("file")||M==="text/uri-list")},p=x=>{v(x)&&(x.preventDefault(),g++,_.classList.add("drag-over"))},a=x=>{v(x)&&(x.preventDefault(),x.stopPropagation(),x.dataTransfer&&(x.dataTransfer.dropEffect="copy"),_.classList.add("drag-over"))},f=()=>{g--,g<=0&&(g=0,_.classList.remove("drag-over"))},A=async x=>{g=0,_.classList.remove("drag-over"),x.preventDefault(),x.stopPropagation();let D=[];if(x.dataTransfer?.files?.length>0)D=Array.from(x.dataTransfer.files);else if(x.dataTransfer?.items?.length>0){for(let E of x.dataTransfer.items)if(E.kind==="file"){let M=E.getAsFile();M&&D.push(M)}}else x.detail?.files&&(D=Array.from(x.detail.files));D.length>0&&await this.addFiles(D)},_=this.shadowRoot.querySelector(".container");_&&(_.addEventListener("dragenter",p,{signal:e}),_.addEventListener("dragover",a,{signal:e}),_.addEventListener("dragleave",f,{signal:e}),_.addEventListener("drop",A,{signal:e}),_.addEventListener("dragend",()=>{g=0,_.classList.remove("drag-over")},{signal:e}),_.addEventListener("click",x=>{x.target===_&&n?.click()},{signal:e}));let d=this.shadowRoot.querySelector(".cancel-crop"),y=this.shadowRoot.querySelector(".apply-crop"),r=this.shadowRoot.querySelector(".cancel-text"),l=this.shadowRoot.querySelector(".apply-text");d&&d.addEventListener("click",()=>this.closeCropDialog(),{signal:e}),y&&y.addEventListener("click",()=>this.applyCrop(),{signal:e}),r&&r.addEventListener("click",()=>this.closeTextDialog(),{signal:e}),l&&l.addEventListener("click",()=>this.applyTextEdit(),{signal:e});let m=this.shadowRoot.querySelector(".crop-dialog");m&&m.addEventListener("sl-hide",()=>{this.#e&&(this.#e.destroy(),this.#e=null),this.#n=null},{signal:e})}#h(){let t=this.shadowRoot.querySelector(".container");if(!t)return;let e=this.#t.map((h,u)=>{if(h.type==="markdown"){let p=h.name||"Markdown Note",a=(h.content||"").slice(0,120);return`
537
+ <div class="image-wrapper" data-index="${u}">
538
+ <div class="markdown-card">
539
+ <div class="markdown-card-header">
540
+ <sl-icon name="file-earmark-text"></sl-icon> ${p}
541
+ </div>
542
+ <div class="markdown-card-body">${a}</div>
543
+ </div>
544
+ <sl-dropdown class="image-menu" data-index="${u}">
545
+ <sl-button slot="trigger" variant="default" size="small" circle>
546
+ <sl-icon name="three-dots-vertical"></sl-icon>
547
+ </sl-button>
548
+ <sl-menu>
549
+ <sl-menu-item value="edittext">Edit Text</sl-menu-item>
550
+ <sl-menu-item value="download">Download Markdown</sl-menu-item>
551
+ <sl-divider></sl-divider>
552
+ <sl-menu-item value="delete">Delete</sl-menu-item>
553
+ </sl-menu>
554
+ </sl-dropdown>
555
+ </div>
556
+ `}let g=Ha(h.edits),v=h.edits?.filter==="bw";return`
557
+ <div class="image-wrapper" data-index="${u}">
558
+ <img src="${h.src}" draggable="false">
559
+ <sl-dropdown class="image-menu" data-index="${u}">
560
+ <sl-button slot="trigger" variant="default" size="small" circle>
561
+ <sl-icon name="three-dots-vertical"></sl-icon>
562
+ </sl-button>
563
+ <sl-menu>
564
+ ${this.ocr!==!1?`
565
+ <sl-menu-item value="ocr">
566
+ <sl-icon slot="prefix" name="card-text"></sl-icon> Extract Text
567
+ </sl-menu-item>
568
+ <sl-divider></sl-divider>
569
+ `:""}
570
+ <sl-menu-item value="crop">Crop</sl-menu-item>
571
+ <sl-menu-item value="rotate">Rotate</sl-menu-item>
572
+ <sl-menu-item value="threshold">
573
+ <sl-icon slot="prefix" name="${v?"check-lg":"circle"}"></sl-icon>
574
+ ${v?"Remove Black &amp; White":"Black &amp; White"}
575
+ </sl-menu-item>
576
+ <sl-menu-item value="reset" ?disabled=${!g}>
577
+ <sl-icon slot="prefix" name="arrow-counterclockwise"></sl-icon>
578
+ Reset to Original
579
+ </sl-menu-item>
580
+ <sl-menu-item value="showdata">Show Data</sl-menu-item>
581
+ <sl-menu-item value="download">Download Image</sl-menu-item>
582
+ <sl-divider></sl-divider>
583
+ <sl-menu-item value="delete">Delete</sl-menu-item>
584
+ </sl-menu>
585
+ </sl-dropdown>
586
+ </div>
587
+ `}).join("");t.innerHTML=`
588
+ ${e}
589
+ <button class="add-btn add-image-btn" title="Add image, PDF, or Markdown" aria-label="Add image or PDF">
590
+ <sl-icon name="plus-lg"></sl-icon>
591
+ </button>
592
+ <button class="add-btn add-camera-btn" title="Capture from camera" aria-label="Capture from camera">
593
+ <sl-icon name="camera"></sl-icon>
594
+ </button>
595
+ <button class="add-btn add-note-btn" title="New blank note" aria-label="New blank note">
596
+ <sl-icon name="file-earmark-plus"></sl-icon>
597
+ </button>
598
+ `;let i=t.querySelector(".add-image-btn");i&&(i.onclick=()=>{this.shadowRoot.querySelector(".file-input").click()});let n=t.querySelector(".add-camera-btn");n&&(n.onclick=()=>{this.shadowRoot.querySelector(".camera-input").click()});let o=t.querySelector(".add-note-btn");o&&(o.onclick=()=>{this.addBlankNote()}),t.querySelectorAll(".image-menu").forEach(h=>{h.querySelector("sl-menu").addEventListener("sl-select",g=>{g.stopPropagation();let v=parseInt(h.dataset.index),p=g.detail.item.value;if(p==="ocr")h.hide(),this.dispatchEvent(new CustomEvent("copio:ocr-page",{bubbles:!0,composed:!0,detail:{page:this.#t[v],pageIndex:v}}));else if(p==="crop")h.hide(),this.openCropDialog(v);else if(p==="rotate")this.rotateImage(v);else if(p==="threshold")this.thresholdImage(v);else if(p==="reset")h.hide(),this.resetImage(v);else if(p==="showdata")h.hide(),this.showImageData(v);else if(p==="edittext")h.hide(),this.openTextDialog(v);else if(p==="download")this.downloadImage(v);else if(p==="delete"){let[a]=this.#t.splice(v,1);this.#h();let f=a.name||(a.type==="markdown"?"Markdown Note":`Page ${v+1}`);me.undo(`Deleted ${f}`,()=>{this.#t.splice(v,0,a),this.#h(),me.success(`Restored ${f}`)},{duration:5e3})}})}),this.#b(t)}#b(t){if(this.#i){try{this.#i.destroy()}catch(e){console.warn("Error destroying Sortable:",e)}this.#i=null}this.#i=Tc.create(t,{animation:150,draggable:".image-wrapper",chosenClass:"dragging",ghostClass:"sortable-ghost",filter:"sl-dropdown",preventOnFilter:!1,delay:150,delayOnTouchOnly:!0,touchStartThreshold:5,onEnd:e=>{if(e.to!==t)return;let i=e.oldDraggableIndex,n=e.newDraggableIndex;if(i===n)return;let o=this.#t[i];this.#t.splice(i,1),this.#t.splice(n,0,o),this.#h()}})}async openCropDialog(t){this.#n=t;let e=this.#t[t];if(!e||e.type==="markdown")return;let i=this.shadowRoot.querySelector(".crop-dialog"),n=this.shadowRoot.querySelector("#crop-image");e.originalSrc=e.originalSrc||e.src,e.edits=je(e.edits),n.src=e.originalSrc,i.show();let o=await tc(),h=e.edits?.crop,u=()=>{this.#e&&this.#e.destroy(),this.#e=new o(n,{viewMode:1,autoCropArea:.88,responsive:!0,ready:()=>{if(h)try{if(h.width>0&&h.height>0)this.#e.setData({x:h.x,y:h.y,width:h.width,height:h.height});else if(h.normalized&&h.normalized.w>0){let g=this.#e.getImageData();this.#e.setData({x:Math.round(h.normalized.x*g.naturalWidth),y:Math.round(h.normalized.y*g.naturalHeight),width:Math.round(h.normalized.w*g.naturalWidth),height:Math.round(h.normalized.h*g.naturalHeight)})}else if(typeof h.w=="number"&&h.w>0){let g=this.#e.getImageData();this.#e.setData({x:Math.round(h.x*g.naturalWidth),y:Math.round(h.y*g.naturalHeight),width:Math.round(h.w*g.naturalWidth),height:Math.round(h.h*g.naturalHeight)})}}catch(g){console.warn("Failed restoring prior crop box:",g)}}})};n.onload=u,n.complete&&n.naturalWidth>0&&!this.#e&&u()}closeCropDialog(){let t=this.shadowRoot.querySelector(".crop-dialog"),e=this.shadowRoot.querySelector("#crop-image");if(e&&(e.onload=null),this.#e){try{this.#e.destroy()}catch(i){console.warn("Error destroying Cropper:",i)}this.#e=null}this.#n=null,t?.hide()}applyCrop(){if(this.#e&&this.#n!==null){let t=this.#t[this.#n];if(!t)return;t.originalSrc=t.originalSrc||t.src||"";let e=this.#e.getData(!0),i=this.#e.getImageData(),n=i?.naturalWidth||1,o=i?.naturalHeight||1,h=Math.max(0,Math.min(1,e.x/n)),u=Math.max(0,Math.min(1,e.y/o)),g=Math.max(0,Math.min(1,e.width/n)),v=Math.max(0,Math.min(1,e.height/o));t.edits={...je(t.edits),crop:{x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height),normalized:{x:Number(h.toFixed(4)),y:Number(u.toFixed(4)),w:Number(g.toFixed(4)),h:Number(v.toFixed(4))}}};let p=this.#e.getCroppedCanvas();if(p){let a=ms(p,{crop:null,rotation:t.edits.rotation,filter:t.edits.filter}),f=t.originalSrc.startsWith("data:image/png"),A=f?"image/png":"image/jpeg";t.src=a.toDataURL(A,f?void 0:.82)}this.#h(),this.closeCropDialog()}}async rotateImage(t){let e=this.#t[t];!e||e.type==="markdown"||(e.originalSrc=e.originalSrc||e.src,e.edits={...je(e.edits),rotation:((e.edits?.rotation||0)+90)%360},e.src=await br(e.originalSrc,e.edits),this.#h())}async thresholdImage(t){let e=this.#t[t];if(!e||e.type==="markdown")return;e.originalSrc=e.originalSrc||e.src;let i=e.edits?.filter==="bw";e.edits={...je(e.edits),filter:i?"none":"bw"},e.src=await br(e.originalSrc,e.edits),this.#h(),i?me.info("Restored color (removed B&W filter)"):me.success("Applied B&W threshold filter")}resetImage(t){let e=this.#t[t];!e||e.type==="markdown"||(e.edits={crop:null,rotation:0,filter:"none"},e.src=e.originalSrc||e.src,this.#h(),me.success("Reset page to original"))}addBlankNote(){let t={id:Te(),type:"markdown",name:"New Note",content:""};this.#t.push(t),this.#h(),this.openTextDialog(this.#t.length-1)}downloadImage(t){let e=this.#t[t];if(!e)return;if(e.type==="markdown"){let h=new Blob([e.content||""],{type:"text/markdown;charset=utf-8"}),u=this.#u(URL.createObjectURL(h)),g=document.createElement("a"),v=e.name||`document-${t+1}.md`;g.href=u,g.download=v,g.click(),this.#l(u),me.success(`Downloaded "${v}"`);return}if(!e.src)return;let i="jpg";if(e.src.startsWith("data:")){let h=e.src.match(/^data:(image\/[a-zA-Z+]+);base64,/);h&&h[1].includes("png")&&(i="png")}let n=document.createElement("a"),o=`image-${t+1}.${i}`;n.href=e.src,n.download=o,n.click(),me.success(`Downloaded "${o}"`)}openTextDialog(t){this.#r=t;let e=this.shadowRoot.querySelector(".text-dialog"),i=this.shadowRoot.querySelector(".text-editor");i.value=this.#t[t].content||"",e.label=this.#t[t].name||"Note",e.show()}applyTextEdit(){if(this.#r!==null&&this.#t[this.#r]){let t=this.shadowRoot.querySelector(".text-editor");this.#t[this.#r].content=t.value,this.#h(),this.closeTextDialog()}}closeTextDialog(){let t=this.shadowRoot.querySelector(".text-dialog");this.#r=null,t.hide()}showImageData(t){let{src:e,exif:i}=this.#t[t],n=this.shadowRoot.querySelector(`img[src="${e}"]`),o=[];if(o.push(`<strong>Dimensions:</strong> ${n?`${n.naturalWidth} \xD7 ${n.naturalHeight}`:"unknown"}`),i){let h=new Set(["MakerNote","UserComment","FlashPixVersion","ExifVersion","ComponentsConfiguration","SceneType","thumbnail"]);for(let[u,g]of Object.entries(i)){if(h.has(u)||g===void 0||g===null)continue;let v=g instanceof Array?g.join(", "):String(g);v.length>200||o.push(`<strong>${u}:</strong> ${v}`)}}else o.push("<em>No EXIF data available</em>");this.shadowRoot.querySelector(".exif-data").innerHTML=o.join("<br>"),this.shadowRoot.querySelector(".data-dialog").show()}async pdfToImages(t){let e=await t.arrayBuffer();return(await zc(e)).map(n=>({id:Te(),src:n,originalSrc:n,edits:{crop:null,rotation:0,filter:"none"}}))}async addFiles(t){if(!t||t.length===0)return;let e=[];try{for(let n of t)if(n.type==="application/pdf"){let o=await this.pdfToImages(n);e.push(...o)}else if(n.name?.endsWith(".md")||n.name?.endsWith(".markdown")||n.type==="text/markdown"||n.type==="text/plain"){let o=await n.text();e.push({id:Te(),type:"markdown",name:n.name,content:o})}else{let[o,h]=await Promise.all([mr(n),gr(n)]);e.push({id:Te(),src:o,originalSrc:o,edits:{crop:null,rotation:0,filter:"none"},exif:h})}this.#t.push(...e),this.#h();let i=e.length;me.success(`Imported ${i} page${i!==1?"s":""}`)}catch(i){console.error("Failed to import files:",i),me.error("Failed to import files")}}get ocr(){return this.#d!==!1}set ocr(t){this.#d=!!t,this.#s&&this.#h()}get pdf(){return this.#p!==!1}set pdf(t){this.#p=!!t,this.#s&&this.#h()}get images(){return this.#t}set images(t){let e=Array.isArray(t)?t:[];this.#t=e.map(i=>!i||i.type==="markdown"?i:{...i,originalSrc:i.originalSrc||i.src||"",edits:je(i.edits)}),this.#s&&this.#h()}};customElements.define("copio-images",Br);var Ur=globalThis,wo=Ur.ShadowRoot&&(Ur.ShadyCSS===void 0||Ur.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,xo=Symbol(),qc=new WeakMap,$r=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==xo)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.i,e=this.t;if(wo&&t===void 0){let i=e!==void 0&&e.length===1;i&&(t=qc.get(e)),t===void 0&&((this.i=t=new CSSStyleSheet).replaceSync(this.cssText),i&&qc.set(e,t))}return t}toString(){return this.cssText}},bu=s=>new $r(typeof s=="string"?s:s+"",void 0,xo),yi=(s,...t)=>{let e=s.length===1?s[0]:t.reduce(((i,n,o)=>i+(h=>{if(h._$cssResult$===!0)return h.cssText;if(typeof h=="number")return h;throw Error("Value passed to 'css' function must be a 'css' function result: "+h+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+s[o+1]),s[0]);return new $r(e,s,xo)},vu=(s,t)=>{if(wo)s.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of t){let i=document.createElement("style"),n=Ur.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}},Xc=wo?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(let i of t.cssRules)e+=i.cssText;return bu(e)})(s):s,{is:yu,defineProperty:wu,getOwnPropertyDescriptor:xu,getOwnPropertyNames:Au,getOwnPropertySymbols:Su,getPrototypeOf:Eu}=Object,zr=globalThis,Kc=zr.trustedTypes,_u=Kc?Kc.emptyScript:"",Cu=zr.reactiveElementPolyfillSupport,mn=(s,t)=>s,fo={toAttribute(s,t){switch(t){case Boolean:s=s?_u:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},sh=(s,t)=>!yu(s,t),Yc={attribute:!0,type:String,converter:fo,reflect:!1,useDefault:!1,hasChanged:sh};Symbol.metadata??=Symbol("metadata"),zr.litPropertyMetadata??=new WeakMap;var bi=class extends HTMLElement{static addInitializer(t){this.o(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this.u&&[...this.u.keys()]}static createProperty(t,e=Yc){if(e.state&&(e.attribute=!1),this.o(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let i=Symbol(),n=this.getPropertyDescriptor(t,i,e);n!==void 0&&wu(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){let{get:n,set:o}=xu(this.prototype,t)??{get(){return this[e]},set(h){this[e]=h}};return{get:n,set(h){let u=n?.call(this);o?.call(this,h),this.requestUpdate(t,u,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Yc}static o(){if(this.hasOwnProperty(mn("elementProperties")))return;let t=Eu(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(mn("finalized")))return;if(this.finalized=!0,this.o(),this.hasOwnProperty(mn("properties"))){let e=this.properties,i=[...Au(e),...Su(e)];for(let n of i)this.createProperty(n,e[n])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[i,n]of e)this.elementProperties.set(i,n)}this.u=new Map;for(let[e,i]of this.elementProperties){let n=this.p(e,i);n!==void 0&&this.u.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let i=new Set(t.flat(1/0).reverse());for(let n of i)e.unshift(Xc(n))}else t!==void 0&&e.push(Xc(t));return e}static p(t,e){let i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this.v=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this.m=null,this._()}_(){this.S=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this.$(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this.P??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this.P?.delete(t)}$(){let t=new Map,e=this.constructor.elementProperties;for(let i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this.v=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return vu(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this.P?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this.P?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}C(t,e){let i=this.constructor.elementProperties.get(t),n=this.constructor.p(t,i);if(n!==void 0&&i.reflect===!0){let o=(i.converter?.toAttribute!==void 0?i.converter:fo).toAttribute(e,i.type);this.m=t,o==null?this.removeAttribute(n):this.setAttribute(n,o),this.m=null}}_$AK(t,e){let i=this.constructor,n=i.u.get(t);if(n!==void 0&&this.m!==n){let o=i.getPropertyOptions(n),h=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:fo;this.m=n;let u=h.fromAttribute(e,o.type);this[n]=u??this.T?.get(n)??u,this.m=null}}requestUpdate(t,e,i){if(t!==void 0){let n=this.constructor,o=this[t];if(i??=n.getPropertyOptions(t),!((i.hasChanged??sh)(o,e)||i.useDefault&&i.reflect&&o===this.T?.get(t)&&!this.hasAttribute(n.p(t,i))))return;this.M(t,e,i)}this.isUpdatePending===!1&&(this.S=this.k())}M(t,e,{useDefault:i,reflect:n,wrapped:o},h){i&&!(this.T??=new Map).has(t)&&(this.T.set(t,h??e??this[t]),o!==!0||h!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),n===!0&&this.m!==t&&(this.A??=new Set).add(t))}async k(){this.isUpdatePending=!0;try{await this.S}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this.v){for(let[n,o]of this.v)this[n]=o;this.v=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[n,o]of i){let{wrapped:h}=o,u=this[n];h!==!0||this._$AL.has(n)||u===void 0||this.M(n,void 0,o,u)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this.P?.forEach((i=>i.hostUpdate?.())),this.update(e)):this.U()}catch(i){throw t=!1,this.U(),i}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this.P?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}U(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this.S}shouldUpdate(t){return!0}update(t){this.A&&=this.A.forEach((e=>this.C(e,this[e]))),this.U()}updated(t){}firstUpdated(t){}};bi.elementStyles=[],bi.shadowRootOptions={mode:"open"},bi[mn("elementProperties")]=new Map,bi[mn("finalized")]=new Map,Cu?.({ReactiveElement:bi}),(zr.reactiveElementVersions??=[]).push("2.1.1");var Ao=globalThis,Hr=Ao.trustedTypes,Jc=Hr?Hr.createPolicy("lit-html",{createHTML:s=>s}):void 0,nh="$lit$",vi=`lit$${Math.random().toFixed(9).slice(2)}$`,rh="?"+vi,ku=`<${rh}>`,qi=document,bn=()=>qi.createComment(""),vn=s=>s===null||typeof s!="object"&&typeof s!="function",So=Array.isArray,Tu=s=>So(s)||typeof s?.[Symbol.iterator]=="function",po=`[
599
+ \f\r]`,gn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Qc=/-->/g,Zc=/>/g,Gi=RegExp(`>|${po}(?:([^\\s"'>=/]+)(${po}*=${po}*(?:[^
600
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),th=/'/g,eh=/"/g,ah=/^(?:script|style|textarea|title)$/i,Eo=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),re=Eo(1),rg=Eo(2),ag=Eo(3),Ts=Symbol.for("lit-noChange"),ne=Symbol.for("lit-nothing"),ih=new WeakMap,Wi=qi.createTreeWalker(qi,129);function oh(s,t){if(!So(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Jc!==void 0?Jc.createHTML(t):t}var Pu=(s,t)=>{let e=s.length-1,i=[],n,o=t===2?"<svg>":t===3?"<math>":"",h=gn;for(let u=0;u<e;u++){let g=s[u],v,p,a=-1,f=0;for(;f<g.length&&(h.lastIndex=f,p=h.exec(g),p!==null);)f=h.lastIndex,h===gn?p[1]==="!--"?h=Qc:p[1]!==void 0?h=Zc:p[2]!==void 0?(ah.test(p[2])&&(n=RegExp("</"+p[2],"g")),h=Gi):p[3]!==void 0&&(h=Gi):h===Gi?p[0]===">"?(h=n??gn,a=-1):p[1]===void 0?a=-2:(a=h.lastIndex-p[2].length,v=p[1],h=p[3]===void 0?Gi:p[3]==='"'?eh:th):h===eh||h===th?h=Gi:h===Qc||h===Zc?h=gn:(h=Gi,n=void 0);let A=h===Gi&&s[u+1].startsWith("/>")?" ":"";o+=h===gn?g+ku:a>=0?(i.push(v),g.slice(0,a)+nh+g.slice(a)+vi+A):g+vi+(a===-2?u:A)}return[oh(s,o+(s[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]},yn=class s{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,h=0,u=t.length-1,g=this.parts,[v,p]=Pu(t,e);if(this.el=s.createElement(v,i),Wi.currentNode=this.el.content,e===2||e===3){let a=this.el.content.firstChild;a.replaceWith(...a.childNodes)}for(;(n=Wi.nextNode())!==null&&g.length<u;){if(n.nodeType===1){if(n.hasAttributes())for(let a of n.getAttributeNames())if(a.endsWith(nh)){let f=p[h++],A=n.getAttribute(a).split(vi),_=/([.?@])?(.*)/.exec(f);g.push({type:1,index:o,name:_[2],strings:A,ctor:_[1]==="."?mo:_[1]==="?"?bo:_[1]==="@"?vo:Ds}),n.removeAttribute(a)}else a.startsWith(vi)&&(g.push({type:6,index:o}),n.removeAttribute(a));if(ah.test(n.tagName)){let a=n.textContent.split(vi),f=a.length-1;if(f>0){n.textContent=Hr?Hr.emptyScript:"";for(let A=0;A<f;A++)n.append(a[A],bn()),Wi.nextNode(),g.push({type:2,index:++o});n.append(a[f],bn())}}}else if(n.nodeType===8)if(n.data===rh)g.push({type:2,index:o});else{let a=-1;for(;(a=n.data.indexOf(vi,a+1))!==-1;)g.push({type:7,index:o}),a+=vi.length-1}o++}}static createElement(t,e){let i=qi.createElement("template");return i.innerHTML=t,i}};function Ps(s,t,e=s,i){if(t===Ts)return t;let n=i!==void 0?e.N?.[i]:e.O,o=vn(t)?void 0:t._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),o===void 0?n=void 0:(n=new o(s),n._$AT(s,e,i)),i!==void 0?(e.N??=[])[i]=n:e.O=n),n!==void 0&&(t=Ps(s,n._$AS(s,t.values),n,i)),t}var go=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}R(t){let{el:{content:e},parts:i}=this._$AD,n=(t?.creationScope??qi).importNode(e,!0);Wi.currentNode=n;let o=Wi.nextNode(),h=0,u=0,g=i[0];for(;g!==void 0;){if(h===g.index){let v;g.type===2?v=new wn(o,o.nextSibling,this,t):g.type===1?v=new g.ctor(o,g.name,g.strings,this,t):g.type===6&&(v=new yo(o,this,t)),this._$AV.push(v),g=i[++u]}h!==g?.index&&(o=Wi.nextNode(),h++)}return Wi.currentNode=qi,n}V(t){let e=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},wn=class s{get _$AU(){return this._$AM?._$AU??this.D}constructor(t,e,i,n){this.type=2,this._$AH=ne,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=n,this.D=n?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Ps(this,t,e),vn(t)?t===ne||t==null||t===""?(this._$AH!==ne&&this._$AR(),this._$AH=ne):t!==this._$AH&&t!==Ts&&this.L(t):t._$litType$!==void 0?this.j(t):t.nodeType!==void 0?this.I(t):Tu(t)?this.H(t):this.L(t)}B(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}I(t){this._$AH!==t&&(this._$AR(),this._$AH=this.B(t))}L(t){this._$AH!==ne&&vn(this._$AH)?this._$AA.nextSibling.data=t:this.I(qi.createTextNode(t)),this._$AH=t}j(t){let{values:e,_$litType$:i}=t,n=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=yn.createElement(oh(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.V(e);else{let o=new go(n,this),h=o.R(this.options);o.V(e),this.I(h),this._$AH=o}}_$AC(t){let e=ih.get(t.strings);return e===void 0&&ih.set(t.strings,e=new yn(t)),e}H(t){So(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,i,n=0;for(let o of t)n===e.length?e.push(i=new s(this.B(bn()),this.B(bn()),this,this.options)):i=e[n],i._$AI(o),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){let i=t.nextSibling;t.remove(),t=i}}setConnected(t){this._$AM===void 0&&(this.D=t,this._$AP?.(t))}},Ds=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,n,o){this.type=1,this._$AH=ne,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ne}_$AI(t,e=this,i,n){let o=this.strings,h=!1;if(o===void 0)t=Ps(this,t,e,0),h=!vn(t)||t!==this._$AH&&t!==Ts,h&&(this._$AH=t);else{let u=t,g,v;for(t=o[0],g=0;g<o.length-1;g++)v=Ps(this,u[i+g],e,g),v===Ts&&(v=this._$AH[g]),h||=!vn(v)||v!==this._$AH[g],v===ne?t=ne:t!==ne&&(t+=(v??"")+o[g+1]),this._$AH[g]=v}h&&!n&&this.W(t)}W(t){t===ne?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},mo=class extends Ds{constructor(){super(...arguments),this.type=3}W(t){this.element[this.name]=t===ne?void 0:t}},bo=class extends Ds{constructor(){super(...arguments),this.type=4}W(t){this.element.toggleAttribute(this.name,!!t&&t!==ne)}},vo=class extends Ds{constructor(t,e,i,n,o){super(t,e,i,n,o),this.type=5}_$AI(t,e=this){if((t=Ps(this,t,e,0)??ne)===Ts)return;let i=this._$AH,n=t===ne&&i!==ne||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==ne&&(i===ne||n);n&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},yo=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Ps(this,t)}};var Du=Ao.litHtmlPolyfillSupport;Du?.(yn,wn),(Ao.litHtmlVersions??=[]).push("3.3.1");var Iu=(s,t,e)=>{let i=e?.renderBefore??t,n=i._$litPart$;if(n===void 0){let o=e?.renderBefore??null;i._$litPart$=n=new wn(t.insertBefore(bn(),o),o,void 0,e??{})}return n._$AI(s),n},_o=globalThis;var de=class extends bi{constructor(){super(...arguments),this.renderOptions={host:this},this.rt=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this.rt=Iu(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this.rt?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this.rt?.setConnected(!1)}render(){return Ts}};de._$litElement$=!0,de.finalized=!0,_o.litElementHydrateSupport?.({LitElement:de});var Mu=_o.litElementPolyfillSupport;Mu?.({LitElement:de});(_o.litElementVersions??=[]).push("4.2.1");var jr=class extends de{disconnectedCallback(){super.disconnectedCallback(),this.activeSlideIndex=0}updated(t){super.updated(t),t.has("images")&&Array.isArray(this.images)&&this.images.some(e=>e.type==="markdown")&&(!window.marked||!window.marked.parse)&&ec().then(()=>this.requestUpdate())}static properties={docId:{type:String},docName:{type:String},images:{type:Array},activeSlideIndex:{type:Number,state:!0},ocr:{type:Boolean},pdf:{type:Boolean}};get hasImages(){return(this.images||[]).some(t=>t.type!=="markdown"&&!!t.src)}get hasMarkdown(){return(this.images||[]).some(t=>t.type==="markdown")}get pageCount(){return(this.images||[]).length}static styles=yi`
601
+ :host {
602
+ display: block;
603
+ position: absolute;
604
+ top: 0;
605
+ left: 0;
606
+ right: 0;
607
+ bottom: 0;
608
+ width: 100%;
609
+ height: 100%;
610
+ z-index: 10;
611
+ overflow: hidden;
612
+ background: #000;
613
+ box-sizing: border-box;
614
+ }
615
+ sl-carousel {
616
+ position: absolute;
617
+ top: 0;
618
+ padding-top: 16px;
619
+ background: white;
620
+ z-index: 4;
621
+ height: 100%;
622
+ width: 100%;
623
+ }
624
+ sl-carousel-item {
625
+ height: 100%;
626
+ }
627
+ .item {
628
+ width: 100%;
629
+ height: 100%;
630
+ background-repeat: no-repeat;
631
+ background-size: contain;
632
+ background-position: center;
633
+ }
634
+ .top-bar {
635
+ position: absolute;
636
+ top: 0;
637
+ left: 0;
638
+ right: 0;
639
+ height: 56px;
640
+ z-index: 10;
641
+ display: flex;
642
+ align-items: center;
643
+ justify-content: space-between;
644
+ padding: 0 16px;
645
+ background: linear-gradient(to bottom, rgba(15, 23, 42, 0.85) 0%, rgba(15, 23, 42, 0.3) 80%, transparent 100%);
646
+ pointer-events: none;
647
+ box-sizing: border-box;
648
+ }
649
+ .top-bar > * {
650
+ pointer-events: auto;
651
+ }
652
+ .top-bar-left {
653
+ display: flex;
654
+ align-items: center;
655
+ gap: 10px;
656
+ min-width: 0;
657
+ }
658
+ .top-bar-right {
659
+ display: flex;
660
+ align-items: center;
661
+ gap: 8px;
662
+ }
663
+ .back {
664
+ font-size: 26px;
665
+ cursor: pointer;
666
+ appearance: none;
667
+ background: rgba(15, 23, 42, 0.6);
668
+ border: 1px solid rgba(255, 255, 255, 0.2);
669
+ border-radius: 8px;
670
+ color: white;
671
+ width: 36px;
672
+ height: 36px;
673
+ display: flex;
674
+ align-items: center;
675
+ justify-content: center;
676
+ transition: background 0.15s;
677
+ }
678
+ .back:hover {
679
+ background: rgba(15, 23, 42, 0.9);
680
+ }
681
+ .doc-heading {
682
+ color: #f8fafc;
683
+ font-size: 1.05rem;
684
+ font-weight: 600;
685
+ white-space: nowrap;
686
+ overflow: hidden;
687
+ text-overflow: ellipsis;
688
+ max-width: 240px;
689
+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
690
+ }
691
+ .ocr-btn, .export-btn {
692
+ background: rgba(15, 23, 42, 0.75);
693
+ backdrop-filter: blur(8px);
694
+ color: white;
695
+ border: 1px solid rgba(255, 255, 255, 0.2);
696
+ border-radius: 8px;
697
+ padding: 6px 12px;
698
+ height: 36px;
699
+ font-size: 13px;
700
+ display: flex;
701
+ align-items: center;
702
+ gap: 6px;
703
+ cursor: pointer;
704
+ transition: background 0.15s, border-color 0.15s;
705
+ box-sizing: border-box;
706
+ }
707
+ .ocr-btn:hover, .export-btn:hover {
708
+ background: rgba(15, 23, 42, 0.95);
709
+ border-color: rgba(255, 255, 255, 0.4);
710
+ }
711
+ .markdown-container {
712
+ width: 100%;
713
+ height: 100%;
714
+ box-sizing: border-box;
715
+ padding: 60px 24px 24px 24px;
716
+ overflow-y: auto;
717
+ background: #151f2a;
718
+ color: #f8fafc;
719
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
720
+ line-height: 1.6;
721
+ }
722
+ .markdown-body {
723
+ max-width: 800px;
724
+ margin: 0 auto;
725
+ }
726
+ .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
727
+ color: #f1f5f9;
728
+ margin-top: 1.5em;
729
+ margin-bottom: 0.5em;
730
+ font-weight: 600;
731
+ line-height: 1.25;
732
+ border-bottom: 1px solid rgba(255,255,255,0.1);
733
+ padding-bottom: 0.3em;
734
+ }
735
+ .markdown-body h1 { font-size: 2em; }
736
+ .markdown-body h2 { font-size: 1.5em; }
737
+ .markdown-body h3 { font-size: 1.25em; }
738
+ .markdown-body p { margin-top: 0; margin-bottom: 1em; }
739
+ .markdown-body ul, .markdown-body ol { padding-left: 2em; margin-bottom: 1em; }
740
+ .markdown-body li { margin-bottom: 0.3em; }
741
+ .markdown-body code {
742
+ background: rgba(255,255,255,0.1);
743
+ padding: 0.2em 0.4em;
744
+ border-radius: 4px;
745
+ font-family: monospace;
746
+ font-size: 0.9em;
747
+ }
748
+ .markdown-body pre {
749
+ background: #0f172a;
750
+ padding: 1em;
751
+ border-radius: 8px;
752
+ overflow-x: auto;
753
+ border: 1px solid rgba(255,255,255,0.1);
754
+ }
755
+ .markdown-body pre code { background: none; padding: 0; }
756
+ .markdown-body blockquote {
757
+ border-left: 4px solid #38bdf8;
758
+ margin: 1em 0;
759
+ padding-left: 1em;
760
+ color: #cbd5e1;
761
+ font-style: italic;
762
+ }
763
+ .markdown-body table {
764
+ border-collapse: collapse;
765
+ width: 100%;
766
+ margin-bottom: 1em;
767
+ }
768
+ .markdown-body th, .markdown-body td {
769
+ border: 1px solid rgba(255,255,255,0.15);
770
+ padding: 8px 12px;
771
+ text-align: left;
772
+ }
773
+ .markdown-body th {
774
+ background: rgba(255,255,255,0.1);
775
+ }
776
+ .markdown-body img {
777
+ max-width: 100%;
778
+ height: auto;
779
+ border-radius: 6px;
780
+ }
781
+ `;constructor(){super(),this.docId="",this.docName="",this.images=[],this.activeSlideIndex=0,this.ocr=!0,this.pdf=!0}handleBackClick(){this.dispatchEvent(new CustomEvent("dialog:close",{bubbles:!0,composed:!1}))}handleOcrClick(){let t=this.images[this.activeSlideIndex];!t||t.type==="markdown"||!t.src||this.dispatchEvent(new CustomEvent("copio:ocr-page",{bubbles:!0,composed:!0,detail:{page:t,pageIndex:this.activeSlideIndex}}))}handleExportSelect(t){if(t.detail?.item?.disabled)return;let e=t.detail?.item?.value,i={docId:this.docId,docName:this.docName,pages:this.images};e==="pdf"?this.dispatchEvent(new CustomEvent("doc:download-pdf",{bubbles:!0,composed:!1,detail:i})):e==="images"?this.dispatchEvent(new CustomEvent("doc:download-images",{bubbles:!0,composed:!1,detail:i})):e==="markdown"&&this.dispatchEvent(new CustomEvent("doc:download-markdown",{bubbles:!0,composed:!1,detail:i}))}handleSlideChange(t){this.activeSlideIndex=t.detail?.index||0}renderItem(t){if(t.type==="markdown"){let e=t.content||"",i=window.marked&&window.marked.parse?window.marked.parse(e):e;return re`
782
+ <sl-carousel-item data-id="${t.id}">
783
+ <div class="markdown-container">
784
+ <div class="markdown-body" .innerHTML=${i}></div>
785
+ </div>
786
+ </sl-carousel-item>
787
+ `}return re`
788
+ <sl-carousel-item data-id="${t.id}">
789
+ <div class="item" style="background-image: url('${t.src}')"></div>
790
+ </sl-carousel-item>
791
+ `}render(){let t=this.images[this.activeSlideIndex],e=this.ocr!==!1&&t&&t.type!=="markdown"&&!!t.src;return re`
792
+ <div class="top-bar">
793
+ <div class="top-bar-left">
794
+ <button class="back" @click=${this.handleBackClick} aria-label="Back">←</button>
795
+ <span class="doc-heading">${this.docName||"Document"}</span>
796
+ </div>
797
+
798
+ <div class="top-bar-right">
799
+ ${e?re`
800
+ <button class="ocr-btn" @click=${this.handleOcrClick} aria-label="Extract text">
801
+ <sl-icon name="card-text"></sl-icon>
802
+ <span>Extract Text</span>
803
+ </button>
804
+ `:""}
805
+
806
+ <sl-dropdown>
807
+ <button slot="trigger" class="export-btn" aria-label="Export document">
808
+ <sl-icon name="box-arrow-up"></sl-icon>
809
+ <span>Export</span>
810
+ <sl-icon name="chevron-down" style="font-size: 0.75rem;"></sl-icon>
811
+ </button>
812
+ <sl-menu @sl-select=${this.handleExportSelect}>
813
+ ${this.pdf!==!1?re`
814
+ <sl-menu-item value="pdf" ?disabled=${this.pageCount===0}>
815
+ <sl-icon slot="prefix" name="file-earmark-pdf"></sl-icon>
816
+ Download as PDF
817
+ </sl-menu-item>
818
+ `:""}
819
+ <sl-menu-item value="images" ?disabled=${this.pageCount===0}>
820
+ <sl-icon slot="prefix" name="images"></sl-icon>
821
+ Download as Images (ZIP)
822
+ </sl-menu-item>
823
+ <sl-menu-item value="markdown" ?disabled=${!this.hasMarkdown}>
824
+ <sl-icon slot="prefix" name="markdown"></sl-icon>
825
+ Download as Markdown
826
+ </sl-menu-item>
827
+ </sl-menu>
828
+ </sl-dropdown>
829
+ </div>
830
+ </div>
831
+
832
+ <sl-carousel
833
+ class="sl-carousel"
834
+ orientation="vertical"
835
+ @sl-slide-change=${this.handleSlideChange}
836
+ >
837
+ ${this.images.map(i=>this.renderItem(i))}
838
+ </sl-carousel>
839
+ `}};customElements.define("copio-carousel",jr);var Vr=class extends de{createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback(),this.#t()}#t=()=>{let t=this.querySelector(".dialog-add-edit-input-name"),e=this.querySelector(".dialog-name-error");if(e&&(e.style.display="none"),t&&(t.classList.remove("input-invalid"),t.style.removeProperty("--sl-input-border-color"),t.style.removeProperty("--sl-input-border-color-focus"),typeof t.setCustomValidity=="function"))try{t.setCustomValidity("")}catch{}};#e=t=>{t.target?.value?.trim()&&this.#t()};#i=t=>{if(t.target!==t.currentTarget)return;this.#t();let e=this.querySelector(".dialog-add-edit-input-id"),i=this.querySelector(".dialog-add-edit-input-name"),n=this.querySelector("copio-images");e&&(e.value=""),i&&(i.value=""),n&&(n.images=[]),this.dispatchEvent(new CustomEvent("dialog:close",{bubbles:!0,composed:!1}))};#n=t=>{if(t.key!=="Enter"||this.querySelector("sl-dialog[open]"))return;if(t.target?.classList?.contains("dialog-add-edit-input-name")){t.preventDefault(),this.#r();return}let e=t.target?.tagName;e==="TEXTAREA"||e==="SL-TEXTAREA"||e==="INPUT"||e==="SL-INPUT"||t.target?.tagName==="SL-BUTTON"||t.target?.tagName==="BUTTON"||(t.preventDefault(),this.#r())};async open(){await this.updateComplete,this.#t();let t=this.querySelector(".dialog-add-edit");t&&(await t.show(),this.querySelector(".dialog-add-edit-input-name")?.focus())}async openEdit(t,e,i){await this.updateComplete,this.#t();let n=this.querySelector(".dialog-add-edit");if(!n)return;let o=this.querySelector(".dialog-add-edit-input-id"),h=this.querySelector(".dialog-add-edit-input-name"),u=this.querySelector("copio-images");o.value=t,h.value=e,await customElements.whenDefined("copio-images"),u.images=i.map(({id:g,src:v,originalSrc:p,edits:a,exif:f,type:A,name:_,content:d})=>({id:g,src:v,originalSrc:p||v,edits:a||{crop:null,rotation:0,filter:"none"},exif:f,type:A,name:_,content:d})),n.open||(await n.show(),h.focus())}#r=()=>{let t=this.querySelector(".dialog-add-edit-input-id"),e=this.querySelector(".dialog-add-edit-input-name"),i=this.querySelector(".dialog-name-error"),n=this.querySelector("copio-images"),o=e?.value?.trim();if(!o){i&&(i.style.display="block"),e&&(e.classList.add("input-invalid"),e.style.setProperty("--sl-input-border-color","#ef4444"),e.style.setProperty("--sl-input-border-color-focus","#ef4444"),typeof e.setCustomValidity=="function"&&(e.setCustomValidity("Please enter a document name"),e.reportValidity?.()),e.focus());return}let h=(n?.images||[]).map(({id:g,src:v,originalSrc:p,edits:a,exif:f,type:A,name:_,content:d})=>({id:g,src:v,originalSrc:p||v,edits:a||{crop:null,rotation:0,filter:"none"},exif:f,type:A,name:_,content:d})),u=t?.value||Te();this.dispatchEvent(new CustomEvent("dialog:save",{bubbles:!0,composed:!1,detail:{id:u,name:o,pages:h}})),this.querySelector(".dialog-add-edit")?.hide()};render(){return re`
840
+ <sl-dialog
841
+ label="Add / Edit"
842
+ class="dialog-add-edit"
843
+ style="--width: min(94%, 640px)"
844
+ @sl-after-hide=${this.#i}
845
+ @keydown=${this.#n}
846
+ >
847
+ <div style="min-height: min(65cqh, 420px); min-height: 350px;">
848
+ <sl-input
849
+ disabled
850
+ class="dialog-add-edit-input-id"
851
+ placeholder="id"
852
+ style="display: none"
853
+ ></sl-input>
854
+ <div class="dialog-name-field" style="max-width: 300px">
855
+ <sl-input
856
+ class="dialog-add-edit-input-name"
857
+ placeholder="Enter name of document or image"
858
+ @sl-input=${this.#e}
859
+ ></sl-input>
860
+ <div
861
+ class="dialog-name-error"
862
+ style="color: #ef4444; font-size: 0.8rem; margin-top: 4px; display: none;"
863
+ >
864
+ Please enter a document name
865
+ </div>
866
+ </div>
867
+
868
+ <copio-images
869
+ style="display: block; margin-top: 1.5rem"
870
+ ></copio-images>
871
+
872
+ <br />
873
+
874
+ <sl-button
875
+ class="dialog-add-edit-savebtn"
876
+ style="width: 100%; margin-top: auto;"
877
+ slot="footer"
878
+ variant="primary"
879
+ @click=${this.#r}
880
+ >Save</sl-button
881
+ >
882
+ </div>
883
+ </sl-dialog>
884
+ `}};customElements.define("copio-add-edit-dialog",Vr);var Gr=class extends de{static properties={name:{type:String},pages:{type:Array},isRenaming:{type:Boolean,state:!0},renameValue:{type:String,state:!0},ocr:{type:Boolean},pdf:{type:Boolean}};constructor(){super(),this.name="",this.pages=[],this.isRenaming=!1,this.renameValue="",this.ocr=!0,this.pdf=!0}get hasImages(){return(this.pages||[]).some(t=>t.type!=="markdown"&&!!t.src)}get hasMarkdown(){return(this.pages||[]).some(t=>t.type==="markdown")}get pageCount(){return(this.pages||[]).length}static styles=yi`
885
+ .wrapper {
886
+ margin-left: auto;
887
+ margin-right: auto;
888
+ display: flex;
889
+ justify-content: space-between;
890
+ align-items: center;
891
+ max-width: 768px;
892
+ padding: 10px 12px;
893
+ border-bottom: 1px solid #e2e8f0;
894
+ cursor: pointer;
895
+ user-select: none;
896
+ }
897
+ .inner {
898
+ display: flex;
899
+ align-items: center;
900
+ flex: 1;
901
+ min-width: 0;
902
+ }
903
+ .titles {
904
+ display: flex;
905
+ flex-direction: column;
906
+ margin-left: 12px;
907
+ padding: 2px 0;
908
+ flex: 1;
909
+ min-width: 0;
910
+ }
911
+ .doc-title {
912
+ font-weight: 600;
913
+ font-size: 0.95rem;
914
+ color: #151f2a;
915
+ white-space: nowrap;
916
+ overflow: hidden;
917
+ text-overflow: ellipsis;
918
+ line-height: 1.3;
919
+ }
920
+ .doc-page-count {
921
+ font-size: 0.8rem;
922
+ color: #64748b;
923
+ margin-top: 2px;
924
+ }
925
+ .rename-container {
926
+ display: flex;
927
+ align-items: center;
928
+ gap: 6px;
929
+ width: 100%;
930
+ max-width: 320px;
931
+ }
932
+ .rename-container sl-input {
933
+ flex: 1;
934
+ }
935
+ button {
936
+ appearance: none;
937
+ border: none;
938
+ color: black;
939
+ padding: 3px 4px 3px 7px;
940
+ background: white;
941
+ cursor: pointer;
942
+ }
943
+ `;#t(t){this.isRenaming||t.target.closest("sl-dropdown")||t.target.closest(".rename-container")||this.handleView()}#e(t){if(t.detail?.item?.disabled)return;let e=t.detail?.item?.value;e==="delete"&&this.handleDelete(),e==="rename"&&this.startRename(),e==="edit"&&this.handleEdit(),e==="extract-ocr"&&this.handleExtractOcr(),e==="download"&&this.handleDownload(),e==="download-images"&&this.handleDownloadImages(),e==="download-markdown"&&this.handleDownloadMarkdown()}startRename(t){t&&(t.preventDefault(),t.stopPropagation()),this.renameValue=this.name||"",this.isRenaming=!0,this.updateComplete.then(()=>{let e=this.shadowRoot.querySelector(".rename-input");e&&(e.focus(),typeof e.select=="function"&&e.select())})}cancelRename(t){t&&(t.preventDefault(),t.stopPropagation()),this.isRenaming=!1,this.renameValue=this.name||""}commitRename(t){t&&(t.preventDefault(),t.stopPropagation());let e=(this.renameValue||"").trim();if(!e){this.cancelRename();return}if(e!==this.name){let i={id:this.getAttribute("id"),name:e};this.dispatchEvent(new CustomEvent("doc:rename",{bubbles:!0,composed:!1,detail:i})),this.name=e}this.isRenaming=!1}handleRenameKeyDown(t){t.key==="Enter"?(t.preventDefault(),this.commitRename()):t.key==="Escape"&&(t.preventDefault(),this.cancelRename())}handleExtractOcr(){let t={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:extract-ocr",{bubbles:!0,composed:!1,detail:t}))}handleView(){let t={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:view",{bubbles:!0,composed:!1,detail:t}))}handleDelete(){let t={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:delete",{bubbles:!0,composed:!1,detail:t}))}handleEdit(){let t={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:edit",{bubbles:!0,composed:!1,detail:t}))}handleDownload(){let t={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:download",{bubbles:!0,composed:!1,detail:t}))}handleDownloadImages(){let t={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:download-images",{bubbles:!0,composed:!1,detail:t}))}handleDownloadMarkdown(){let t={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:download-markdown",{bubbles:!0,composed:!1,detail:t}))}render(){return re`
944
+ <div class="wrapper" @click=${this.#t}>
945
+ <div class="inner">
946
+ <sl-avatar label="Document icon">
947
+ <sl-icon slot="icon" name="file-earmark-text"></sl-icon>
948
+ </sl-avatar>
949
+
950
+ <div class="titles">
951
+ ${this.isRenaming?re`
952
+ <div class="rename-container" @click=${t=>t.stopPropagation()}>
953
+ <sl-input
954
+ class="rename-input"
955
+ size="small"
956
+ .value=${this.renameValue}
957
+ @sl-input=${t=>this.renameValue=t.target.value}
958
+ @keydown=${this.handleRenameKeyDown}
959
+ ></sl-input>
960
+ <sl-icon-button
961
+ name="check-lg"
962
+ label="Save rename"
963
+ @click=${this.commitRename}
964
+ ></sl-icon-button>
965
+ <sl-icon-button
966
+ name="x-lg"
967
+ label="Cancel rename"
968
+ @click=${this.cancelRename}
969
+ ></sl-icon-button>
970
+ </div>
971
+ `:re`
972
+ <div class="doc-title">${this.name||"Untitled Document"}</div>
973
+ <div class="doc-page-count">
974
+ ${this.pageCount} ${this.pageCount===1?"page":"pages"}
975
+ </div>
976
+ `}
977
+ </div>
978
+ </div>
979
+
980
+ <sl-dropdown>
981
+ <sl-button slot="trigger" variant="default" size="small" circle>
982
+ <sl-icon name="three-dots-vertical"></sl-icon>
983
+ </sl-button>
984
+ <sl-menu @sl-select=${this.#e}>
985
+ <sl-menu-item value="edit">
986
+ <sl-icon slot="prefix" name="sliders"></sl-icon>
987
+ Edit
988
+ </sl-menu-item>
989
+ <sl-menu-item value="rename">
990
+ <sl-icon slot="prefix" name="pencil"></sl-icon>
991
+ Rename
992
+ </sl-menu-item>
993
+ ${this.ocr!==!1?re`
994
+ <sl-menu-item
995
+ value="extract-ocr"
996
+ ?disabled=${!this.hasImages}
997
+ title=${this.hasImages?"Extract text with OCR":"No image pages in document"}
998
+ >
999
+ <sl-icon slot="prefix" name="card-text"></sl-icon>
1000
+ Extract All Text (OCR)
1001
+ </sl-menu-item>
1002
+ `:""}
1003
+ <sl-divider></sl-divider>
1004
+ ${this.pdf!==!1?re`
1005
+ <sl-menu-item
1006
+ value="download"
1007
+ ?disabled=${this.pageCount===0}
1008
+ title=${this.pageCount===0?"Document is empty":"Download as PDF"}
1009
+ >
1010
+ <sl-icon slot="prefix" name="file-earmark-pdf"></sl-icon>
1011
+ Download as PDF
1012
+ </sl-menu-item>
1013
+ `:""}
1014
+ <sl-menu-item
1015
+ value="download-images"
1016
+ ?disabled=${this.pageCount===0}
1017
+ title=${this.pageCount===0?"Document is empty":"Download as Images"}
1018
+ >
1019
+ <sl-icon slot="prefix" name="images"></sl-icon>
1020
+ Download as Images
1021
+ </sl-menu-item>
1022
+ <sl-menu-item
1023
+ value="download-markdown"
1024
+ ?disabled=${!this.hasMarkdown}
1025
+ title=${this.hasMarkdown?"Download as Markdown":"No markdown notes in document"}
1026
+ >
1027
+ <sl-icon slot="prefix" name="markdown"></sl-icon>
1028
+ Download as Markdown
1029
+ </sl-menu-item>
1030
+ <sl-divider></sl-divider>
1031
+ <sl-menu-item value="delete">
1032
+ <sl-icon slot="prefix" name="trash"></sl-icon>
1033
+ Delete
1034
+ </sl-menu-item>
1035
+ </sl-menu>
1036
+ </sl-dropdown>
1037
+ </div>
1038
+ `}};customElements.define("copio-row",Gr);var Wr=class extends de{static styles=yi`
1039
+ header {
1040
+ background-color: #151f2a;
1041
+ color: white;
1042
+ display: flex;
1043
+ align-items: center;
1044
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
1045
+ padding: 8px;
1046
+ }
1047
+ .header-left,
1048
+ .header-right {
1049
+ flex: 1;
1050
+ display: flex;
1051
+ align-items: center;
1052
+ }
1053
+ .header-right {
1054
+ justify-content: flex-end;
1055
+ }
1056
+ h1 {
1057
+ font-size: 24px;
1058
+ margin: 0;
1059
+ }
1060
+ sl-icon-button::part(base) {
1061
+ min-width: 44px;
1062
+ min-height: 44px;
1063
+ display: inline-flex;
1064
+ align-items: center;
1065
+ justify-content: center;
1066
+ }
1067
+ `;static properties={_storageEstimate:{state:!0},_isPersisted:{state:!0}};async connectedCallback(){super.connectedCallback(),await this.#t()}disconnectedCallback(){super.disconnectedCallback()}async#t(){navigator.storage&&(navigator.storage.persisted&&(this._isPersisted=await navigator.storage.persisted()),navigator.storage.estimate&&(this._storageEstimate=await navigator.storage.estimate()))}_formatBytes(t){if(t==null)return"Unknown";if(t===0)return"0 B";let e=1024,i=["B","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(e));return parseFloat((t/Math.pow(e,n)).toFixed(1))+" "+i[n]}#e(t){if(t.detail.item.value==="link-device"){this.dispatchEvent(new CustomEvent("header:link-device",{bubbles:!0,composed:!1}));return}t.detail.item.value==="clear-cache"&&this.dispatchEvent(new CustomEvent("header:clear-cache",{bubbles:!0,composed:!1}))}render(){return re`
1068
+ <header>
1069
+ <div class="header-left">
1070
+ <sl-dropdown @sl-show=${this.#t}>
1071
+ <sl-icon-button
1072
+ slot="trigger"
1073
+ name="list"
1074
+ label="Menu"
1075
+ style="font-size: 1.5rem; color: white;"
1076
+ ></sl-icon-button>
1077
+ <sl-menu @sl-select=${this.#e}>
1078
+ <sl-menu-item value="link-device">Link another device</sl-menu-item>
1079
+ <sl-menu-item value="clear-cache">Clear cache &amp; update</sl-menu-item>
1080
+ <sl-divider></sl-divider>
1081
+ <sl-menu-item disabled>
1082
+ Storage: ${this._formatBytes(this._storageEstimate?.usage)}
1083
+ (${this._isPersisted?"Persisted":"Volatile"})
1084
+ </sl-menu-item>
1085
+ </sl-menu>
1086
+ </sl-dropdown>
1087
+ </div>
1088
+ <h1>COPIO</h1>
1089
+ <div class="header-right"></div>
1090
+ </header>
1091
+ `}};customElements.define("copio-header",Wr);var qr=class extends de{disconnectedCallback(){super.disconnectedCallback()}static styles=yi`
1092
+ .lds-roller {
1093
+ display: inline-block;
1094
+ position: relative;
1095
+ width: 80px;
1096
+ height: 80px;
1097
+ }
1098
+ .lds-roller div {
1099
+ animation: lds-roller 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
1100
+ transform-origin: 40px 40px;
1101
+ }
1102
+ .lds-roller div:after {
1103
+ content: ' ';
1104
+ display: block;
1105
+ position: absolute;
1106
+ width: 7px;
1107
+ height: 7px;
1108
+ border-radius: 50%;
1109
+ background: #fff;
1110
+ margin: -4px 0 0 -4px;
1111
+ }
1112
+ .lds-roller div:nth-child(1) {
1113
+ animation-delay: -0.036s;
1114
+ }
1115
+ .lds-roller div:nth-child(1):after {
1116
+ top: 63px;
1117
+ left: 63px;
1118
+ }
1119
+ .lds-roller div:nth-child(2) {
1120
+ animation-delay: -0.072s;
1121
+ }
1122
+ .lds-roller div:nth-child(2):after {
1123
+ top: 68px;
1124
+ left: 56px;
1125
+ }
1126
+ .lds-roller div:nth-child(3) {
1127
+ animation-delay: -0.108s;
1128
+ }
1129
+ .lds-roller div:nth-child(3):after {
1130
+ top: 71px;
1131
+ left: 48px;
1132
+ }
1133
+ .lds-roller div:nth-child(4) {
1134
+ animation-delay: -0.144s;
1135
+ }
1136
+ .lds-roller div:nth-child(4):after {
1137
+ top: 72px;
1138
+ left: 40px;
1139
+ }
1140
+ .lds-roller div:nth-child(5) {
1141
+ animation-delay: -0.18s;
1142
+ }
1143
+ .lds-roller div:nth-child(5):after {
1144
+ top: 71px;
1145
+ left: 32px;
1146
+ }
1147
+ .lds-roller div:nth-child(6) {
1148
+ animation-delay: -0.216s;
1149
+ }
1150
+ .lds-roller div:nth-child(6):after {
1151
+ top: 68px;
1152
+ left: 24px;
1153
+ }
1154
+ .lds-roller div:nth-child(7) {
1155
+ animation-delay: -0.252s;
1156
+ }
1157
+ .lds-roller div:nth-child(7):after {
1158
+ top: 63px;
1159
+ left: 17px;
1160
+ }
1161
+ .lds-roller div:nth-child(8) {
1162
+ animation-delay: -0.288s;
1163
+ }
1164
+ .lds-roller div:nth-child(8):after {
1165
+ top: 56px;
1166
+ left: 12px;
1167
+ }
1168
+ @keyframes lds-roller {
1169
+ 0% {
1170
+ transform: rotate(0deg);
1171
+ }
1172
+ 100% {
1173
+ transform: rotate(360deg);
1174
+ }
1175
+ }
1176
+ `;render(){return re`
1177
+ <div
1178
+ style="
1179
+ background: #151f2a;
1180
+ width: 100%;
1181
+ position: absolute;
1182
+ z-index: 5;
1183
+ height: 100%;
1184
+ margin: 0;
1185
+ padding: 0;
1186
+ top: 0;
1187
+ left: 0;
1188
+ "
1189
+ >
1190
+ <img
1191
+ src="copio.svg"
1192
+ style="
1193
+ position: absolute;
1194
+ top: 50%;
1195
+ left: 50%;
1196
+ transform: translate(-50%, -50%);
1197
+ opacity: 0.3;
1198
+ z-index: 1;
1199
+ max-width: 320px;
1200
+ "
1201
+ />
1202
+ <div
1203
+ class="lds-roller"
1204
+ style="
1205
+ position: absolute;
1206
+ top: calc(50% + -50px);
1207
+ left: 50%;
1208
+ transform: translate(-50%) scale(1);
1209
+ opacity: 0.5;
1210
+ "
1211
+ >
1212
+ <div></div>
1213
+ <div></div>
1214
+ <div></div>
1215
+ <div></div>
1216
+ <div></div>
1217
+ <div></div>
1218
+ <div></div>
1219
+ <div></div>
1220
+ </div>
1221
+ </div>
1222
+ `}};customElements.define("copio-loader",qr);var Co=`
1223
+ :host {
1224
+ all: initial;
1225
+ display: block;
1226
+ position: relative;
1227
+ width: 100%;
1228
+ height: 100%;
1229
+ min-height: 200px;
1230
+ container-type: size;
1231
+ container-name: copio-scanner;
1232
+ overflow: hidden;
1233
+ contain: layout;
1234
+ box-sizing: border-box;
1235
+ text-align: left;
1236
+ direction: ltr;
1237
+ -webkit-font-smoothing: antialiased;
1238
+ -moz-osx-font-smoothing: grayscale;
1239
+ --copio-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1240
+ --copio-font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
1241
+ --copio-color-bg: #0b0f17;
1242
+ --copio-color-surface: #131b26;
1243
+ --copio-color-surface-elevated: #1c2736;
1244
+ --copio-color-surface-overlay: rgba(15, 22, 32, 0.88);
1245
+ --copio-color-stage-bg: #070a0f;
1246
+ --copio-color-text: #f1f5f9;
1247
+ --copio-color-text-muted: #94a3b8;
1248
+ --copio-color-text-inverse: #090d14;
1249
+ --copio-color-primary: #38bdf8;
1250
+ --copio-color-primary-hover: #7dd3fc;
1251
+ --copio-color-primary-contrast: #06131f;
1252
+ --copio-color-success: #22c55e;
1253
+ --copio-color-warning: #f59e0b;
1254
+ --copio-color-danger: #ef4444;
1255
+ --copio-color-border: rgba(148, 163, 184, 0.18);
1256
+ --copio-color-border-strong: rgba(148, 163, 184, 0.34);
1257
+ --copio-focus-ring: 0 0 0 2px #0b0f17, 0 0 0 4px #38bdf8;
1258
+ --copio-radius-sm: 6px;
1259
+ --copio-radius-md: 10px;
1260
+ --copio-radius-lg: 14px;
1261
+ --copio-radius-pill: 9999px;
1262
+ --copio-spacing-xs: 4px;
1263
+ --copio-spacing-sm: 8px;
1264
+ --copio-spacing-md: 12px;
1265
+ --copio-spacing-lg: 16px;
1266
+ --copio-spacing-xl: 24px;
1267
+ --copio-touch-target-min: 44px;
1268
+ --copio-crop-handle-hit: 48px;
1269
+ --copio-crop-handle-visual: 16px;
1270
+ --copio-shadow-elevated: 0 12px 32px -4px rgba(0, 0, 0, 0.55);
1271
+ --copio-transition-fast: 150ms cubic-bezier(0.22, 1, 0.36, 1);
1272
+ --copio-transition-normal: 240ms cubic-bezier(0.22, 1, 0.36, 1);
1273
+ --sl-font-sans: var(--copio-font-family);
1274
+ --sl-font-mono: var(--copio-font-mono);
1275
+ --sl-color-primary-50: #f0f9ff;
1276
+ --sl-color-primary-100: #e0f2fe;
1277
+ --sl-color-primary-200: #bae6fd;
1278
+ --sl-color-primary-300: #7dd3fc;
1279
+ --sl-color-primary-400: #38bdf8;
1280
+ --sl-color-primary-500: #0ea5e9;
1281
+ --sl-color-primary-600: var(--copio-color-primary);
1282
+ --sl-color-primary-700: #0369a1;
1283
+ --sl-color-primary-800: #075985;
1284
+ --sl-color-primary-900: #0c4a6e;
1285
+ --sl-color-primary-950: #082f49;
1286
+ font-family: var(--copio-font-family);
1287
+ font-size: 14px;
1288
+ line-height: 1.5;
1289
+ color: var(--copio-color-text);
1290
+ background-color: var(--copio-color-bg);
1291
+ color-scheme: dark;
1292
+ }
1293
+
1294
+ :host([theme="dark"]),
1295
+ :host(.copio-theme-dark),
1296
+ :host-context([data-theme="dark"]),
1297
+ :host-context(.sl-theme-dark),
1298
+ :host-context(.theme-dark) {
1299
+ color-scheme: dark;
1300
+ }
1301
+
1302
+ /* Light Theme Override */
1303
+ :host([theme="light"]),
1304
+ :host(.copio-theme-light),
1305
+ :host-context([data-theme="light"]),
1306
+ :host-context(.sl-theme-light),
1307
+ :host-context(.theme-light) {
1308
+ --copio-color-bg: #f8fafc;
1309
+ --copio-color-surface: #ffffff;
1310
+ --copio-color-surface-elevated: #f1f5f9;
1311
+ --copio-color-surface-overlay: rgba(255, 255, 255, 0.92);
1312
+ --copio-color-stage-bg: #1e293b;
1313
+ --copio-color-text: #0f172a;
1314
+ --copio-color-text-muted: #475569;
1315
+ --copio-color-text-inverse: #ffffff;
1316
+ --copio-color-primary: #0284c7;
1317
+ --copio-color-primary-hover: #0369a1;
1318
+ --copio-color-primary-contrast: #ffffff;
1319
+ --copio-color-success: #16a34a;
1320
+ --copio-color-warning: #d97706;
1321
+ --copio-color-danger: #dc2626;
1322
+ --copio-color-border: rgba(15, 23, 42, 0.12);
1323
+ --copio-color-border-strong: rgba(15, 23, 42, 0.26);
1324
+ --copio-focus-ring: 0 0 0 2px #ffffff, 0 0 0 4px #0284c7;
1325
+ --copio-radius-sm: 6px;
1326
+ --copio-radius-md: 10px;
1327
+ --copio-radius-lg: 14px;
1328
+ --copio-shadow-elevated: 0 12px 28px -4px rgba(15, 23, 42, 0.18);
1329
+ color-scheme: light;
1330
+ }
1331
+
1332
+ /* Brand Theme Override (Emerald) */
1333
+ :host([theme="brand"]),
1334
+ :host(.copio-theme-brand),
1335
+ :host-context([data-theme="brand"]),
1336
+ :host-context(.theme-brand) {
1337
+ --copio-color-bg: #0f111a;
1338
+ --copio-color-surface: #181b28;
1339
+ --copio-color-surface-elevated: #23273a;
1340
+ --copio-color-surface-overlay: rgba(24, 27, 40, 0.90);
1341
+ --copio-color-stage-bg: #090a10;
1342
+ --copio-color-text: #f8fafc;
1343
+ --copio-color-text-muted: #9ca3af;
1344
+ --copio-color-text-inverse: #ffffff;
1345
+ --copio-color-primary: #10b981;
1346
+ --copio-color-primary-hover: #34d399;
1347
+ --copio-color-primary-contrast: #042f2e;
1348
+ --copio-color-success: #10b981;
1349
+ --copio-color-warning: #f59e0b;
1350
+ --copio-color-danger: #ef4444;
1351
+ --copio-color-border: rgba(16, 185, 129, 0.22);
1352
+ --copio-color-border-strong: rgba(16, 185, 129, 0.42);
1353
+ --copio-focus-ring: 0 0 0 2px #0f111a, 0 0 0 4px #10b981;
1354
+ --copio-radius-sm: 4px;
1355
+ --copio-radius-md: 8px;
1356
+ --copio-radius-lg: 12px;
1357
+ --copio-shadow-elevated: 0 12px 32px -4px rgba(0, 0, 0, 0.65);
1358
+ color-scheme: dark;
1359
+ }
1360
+
1361
+ /* Auto Theme: follows prefers-color-scheme when theme is auto */
1362
+ @media (prefers-color-scheme: light) {
1363
+ :host([theme="auto"]),
1364
+ :host(.copio-theme-auto) {
1365
+ --copio-color-bg: #f8fafc;
1366
+ --copio-color-surface: #ffffff;
1367
+ --copio-color-surface-elevated: #f1f5f9;
1368
+ --copio-color-surface-overlay: rgba(255, 255, 255, 0.92);
1369
+ --copio-color-stage-bg: #1e293b;
1370
+ --copio-color-text: #0f172a;
1371
+ --copio-color-text-muted: #475569;
1372
+ --copio-color-text-inverse: #ffffff;
1373
+ --copio-color-primary: #0284c7;
1374
+ --copio-color-primary-hover: #0369a1;
1375
+ --copio-color-primary-contrast: #ffffff;
1376
+ --copio-color-success: #16a34a;
1377
+ --copio-color-warning: #d97706;
1378
+ --copio-color-danger: #dc2626;
1379
+ --copio-color-border: rgba(15, 23, 42, 0.12);
1380
+ --copio-color-border-strong: rgba(15, 23, 42, 0.26);
1381
+ --copio-focus-ring: 0 0 0 2px #ffffff, 0 0 0 4px #0284c7;
1382
+ --copio-radius-sm: 6px;
1383
+ --copio-radius-md: 10px;
1384
+ --copio-radius-lg: 14px;
1385
+ --copio-shadow-elevated: 0 12px 28px -4px rgba(15, 23, 42, 0.18);
1386
+ color-scheme: light;
1387
+ }
1388
+ }
1389
+
1390
+ /* ==========================================================================
1391
+ 2. INTERNAL ELEMENT RESET (Scoped to Shadow DOM)
1392
+ ========================================================================== */
1393
+ *, *::before, *::after {
1394
+ box-sizing: border-box;
1395
+ }
1396
+
1397
+ ::slotted(*) {
1398
+ box-sizing: border-box;
1399
+ }
1400
+
1401
+ /* ==========================================================================
1402
+ 3. ROOT CONTAINER & COMPONENT SHELL
1403
+ ========================================================================== */
1404
+ .copio-scanner-container {
1405
+ width: 100%;
1406
+ height: 100%;
1407
+ position: relative;
1408
+ display: flex;
1409
+ flex-direction: column;
1410
+ overflow: hidden;
1411
+ box-sizing: border-box;
1412
+ container-type: size;
1413
+ container-name: copio-scanner;
1414
+ contain: layout;
1415
+ background: var(--copio-color-bg);
1416
+ color: var(--copio-color-text);
1417
+ font-family: var(--copio-font-family);
1418
+ font-size: 14px;
1419
+ line-height: 1.5;
1420
+ text-align: left;
1421
+ direction: ltr;
1422
+ user-select: none;
1423
+ }
1424
+
1425
+ /* Header (Shadow Part: header) */
1426
+ .copio-header {
1427
+ display: flex;
1428
+ align-items: center;
1429
+ justify-content: space-between;
1430
+ gap: var(--copio-spacing-sm);
1431
+ padding: var(--copio-spacing-sm) var(--copio-spacing-md);
1432
+ background: var(--copio-color-surface);
1433
+ border-bottom: 1px solid var(--copio-color-border);
1434
+ min-height: 52px;
1435
+ flex-shrink: 0;
1436
+ z-index: 5;
1437
+ box-sizing: border-box;
1438
+ }
1439
+
1440
+ .copio-header-left {
1441
+ display: flex;
1442
+ align-items: center;
1443
+ gap: var(--copio-spacing-sm);
1444
+ min-width: 0;
1445
+ }
1446
+
1447
+ .copio-mode-badge {
1448
+ display: inline-flex;
1449
+ align-items: center;
1450
+ gap: 5px;
1451
+ font-size: 11px;
1452
+ font-weight: 600;
1453
+ padding: 4px 8px;
1454
+ border-radius: var(--copio-radius-pill);
1455
+ background: var(--copio-color-surface-elevated);
1456
+ color: var(--copio-color-primary);
1457
+ border: 1px solid var(--copio-color-border);
1458
+ white-space: nowrap;
1459
+ }
1460
+
1461
+ .copio-title-group {
1462
+ display: flex;
1463
+ flex-direction: column;
1464
+ min-width: 0;
1465
+ }
1466
+
1467
+ .copio-title {
1468
+ font-size: 13px;
1469
+ font-weight: 600;
1470
+ color: var(--copio-color-text);
1471
+ margin: 0;
1472
+ white-space: nowrap;
1473
+ overflow: hidden;
1474
+ text-overflow: ellipsis;
1475
+ }
1476
+
1477
+ .copio-subtitle {
1478
+ font-size: 11px;
1479
+ color: var(--copio-color-text-muted);
1480
+ margin: 0;
1481
+ white-space: nowrap;
1482
+ overflow: hidden;
1483
+ text-overflow: ellipsis;
1484
+ }
1485
+
1486
+ .copio-header-actions {
1487
+ display: flex;
1488
+ align-items: center;
1489
+ gap: 6px;
1490
+ flex-shrink: 0;
1491
+ }
1492
+
1493
+ /* Interactive Stage Switcher Pill (Viewfinder vs Workbench) */
1494
+ .copio-stage-tabs {
1495
+ display: inline-flex;
1496
+ background: var(--copio-color-bg);
1497
+ padding: 2px;
1498
+ border-radius: var(--copio-radius-md);
1499
+ border: 1px solid var(--copio-color-border);
1500
+ }
1501
+
1502
+ .copio-stage-tab {
1503
+ appearance: none;
1504
+ border: none;
1505
+ background: transparent;
1506
+ color: var(--copio-color-text-muted);
1507
+ font-family: inherit;
1508
+ font-size: 11px;
1509
+ font-weight: 600;
1510
+ padding: 6px 10px;
1511
+ min-height: var(--copio-touch-target-min);
1512
+ min-width: var(--copio-touch-target-min);
1513
+ border-radius: var(--copio-radius-sm);
1514
+ cursor: pointer;
1515
+ display: inline-flex;
1516
+ align-items: center;
1517
+ justify-content: center;
1518
+ transition: background var(--copio-transition-fast), color var(--copio-transition-fast);
1519
+ }
1520
+
1521
+ .copio-stage-tab[aria-selected="true"] {
1522
+ background: var(--copio-color-surface-elevated);
1523
+ color: var(--copio-color-text);
1524
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
1525
+ }
1526
+
1527
+ /* Touch-Safe Interactive Buttons (>=44px touch invariant) */
1528
+ .copio-btn {
1529
+ appearance: none;
1530
+ border: 1px solid var(--copio-color-border);
1531
+ background: var(--copio-color-surface-elevated);
1532
+ color: var(--copio-color-text);
1533
+ font-family: inherit;
1534
+ font-size: 13px;
1535
+ font-weight: 600;
1536
+ min-height: var(--copio-touch-target-min);
1537
+ min-width: var(--copio-touch-target-min);
1538
+ padding: 0 12px;
1539
+ border-radius: var(--copio-radius-md);
1540
+ display: inline-flex;
1541
+ align-items: center;
1542
+ justify-content: center;
1543
+ gap: 7px;
1544
+ cursor: pointer;
1545
+ transition: all var(--copio-transition-fast);
1546
+ white-space: nowrap;
1547
+ text-decoration: none;
1548
+ box-sizing: border-box;
1549
+ }
1550
+
1551
+ .copio-btn:hover {
1552
+ background: var(--copio-color-primary-hover);
1553
+ color: var(--copio-color-primary-contrast);
1554
+ border-color: var(--copio-color-primary);
1555
+ }
1556
+
1557
+ .copio-btn-primary {
1558
+ background: var(--copio-color-primary);
1559
+ color: var(--copio-color-primary-contrast);
1560
+ border-color: var(--copio-color-primary);
1561
+ }
1562
+
1563
+ .copio-btn-danger {
1564
+ background: rgba(239, 68, 68, 0.15);
1565
+ color: var(--copio-color-danger);
1566
+ border-color: rgba(239, 68, 68, 0.35);
1567
+ }
1568
+
1569
+ .copio-btn-danger:hover {
1570
+ background: var(--copio-color-danger);
1571
+ color: #fff;
1572
+ }
1573
+
1574
+ /* Viewfinder (Shadow Part: viewfinder) */
1575
+ .copio-viewfinder,
1576
+ .copio-viewfinder-stage {
1577
+ position: relative;
1578
+ flex: 1 1 auto;
1579
+ display: flex;
1580
+ flex-direction: column;
1581
+ justify-content: space-between;
1582
+ background: var(--copio-color-stage-bg);
1583
+ overflow: hidden;
1584
+ min-height: 0;
1585
+ width: 100%;
1586
+ }
1587
+
1588
+ .copio-viewfinder-feed,
1589
+ .copio-camera-feed {
1590
+ position: absolute;
1591
+ inset: 0;
1592
+ display: flex;
1593
+ align-items: center;
1594
+ justify-content: center;
1595
+ padding: 56px 20px 104px 20px;
1596
+ background: radial-gradient(circle at 50% 45%, #1e293b 0%, #090d14 75%);
1597
+ }
1598
+
1599
+ /* Framing Guide Overlay (receipt | card | a4 | auto) */
1600
+ .copio-framing-guide {
1601
+ position: relative;
1602
+ display: flex;
1603
+ align-items: center;
1604
+ justify-content: center;
1605
+ max-width: 100%;
1606
+ max-height: 100%;
1607
+ border: 1.5px dashed rgba(56, 189, 248, 0.55);
1608
+ border-radius: 12px;
1609
+ box-shadow: 0 0 0 9999px rgba(4, 7, 12, 0.52);
1610
+ transition: all var(--copio-transition-normal);
1611
+ overflow: hidden;
1612
+ }
1613
+
1614
+ .copio-framing-guide[data-aspect="receipt"] {
1615
+ aspect-ratio: 1 / 2.1;
1616
+ height: 100%;
1617
+ }
1618
+
1619
+ .copio-framing-guide[data-aspect="card"] {
1620
+ aspect-ratio: 1.586 / 1;
1621
+ width: 92%;
1622
+ max-height: 82%;
1623
+ }
1624
+
1625
+ .copio-framing-guide[data-aspect="a4"] {
1626
+ aspect-ratio: 1 / 1.414;
1627
+ height: 96%;
1628
+ }
1629
+
1630
+ .copio-framing-guide[data-aspect="auto"] {
1631
+ width: 94%;
1632
+ height: 94%;
1633
+ }
1634
+
1635
+ /* Corner Targeting Brackets */
1636
+ .copio-corner {
1637
+ position: absolute;
1638
+ width: 22px;
1639
+ height: 22px;
1640
+ border-color: var(--copio-color-primary);
1641
+ border-style: solid;
1642
+ border-width: 0;
1643
+ pointer-events: none;
1644
+ z-index: 2;
1645
+ }
1646
+ .copio-corner.tl { top: 6px; left: 6px; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 6px; }
1647
+ .copio-corner.tr { top: 6px; right: 6px; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 6px; }
1648
+ .copio-corner.bl { bottom: 6px; left: 6px; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 6px; }
1649
+ .copio-corner.br { bottom: 6px; right: 6px; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 6px; }
1650
+
1651
+ .copio-edge-quad {
1652
+ position: absolute;
1653
+ inset: 12px;
1654
+ border: 1px solid rgba(56, 189, 248, 0.28);
1655
+ border-radius: 8px;
1656
+ background: rgba(56, 189, 248, 0.04);
1657
+ pointer-events: none;
1658
+ z-index: 1;
1659
+ }
1660
+
1661
+ .copio-camera-placeholder {
1662
+ position: relative;
1663
+ z-index: 2;
1664
+ display: flex;
1665
+ flex-direction: column;
1666
+ align-items: center;
1667
+ justify-content: center;
1668
+ gap: 8px;
1669
+ padding: 16px;
1670
+ text-align: center;
1671
+ color: var(--copio-color-text-muted);
1672
+ font-size: 12px;
1673
+ font-weight: 500;
1674
+ }
1675
+
1676
+ .copio-status-dot {
1677
+ width: 7px;
1678
+ height: 7px;
1679
+ border-radius: 50%;
1680
+ background: var(--copio-color-primary);
1681
+ box-shadow: 0 0 8px var(--copio-color-primary);
1682
+ flex-shrink: 0;
1683
+ }
1684
+
1685
+ /* Top Viewfinder HUD Overlay (Step Pill + Privacy Assurance Badge) */
1686
+ .copio-viewfinder-hud-top {
1687
+ position: relative;
1688
+ z-index: 3;
1689
+ display: flex;
1690
+ align-items: center;
1691
+ justify-content: space-between;
1692
+ gap: 8px;
1693
+ padding: 10px 14px;
1694
+ background: linear-gradient(to bottom, rgba(7, 10, 15, 0.85), transparent);
1695
+ }
1696
+
1697
+ .copio-step-pill {
1698
+ display: inline-flex;
1699
+ align-items: center;
1700
+ gap: 6px;
1701
+ padding: 5px 12px;
1702
+ border-radius: var(--copio-radius-pill);
1703
+ background: rgba(15, 23, 42, 0.88);
1704
+ border: 1px solid rgba(56, 189, 248, 0.45);
1705
+ color: #f8fafc;
1706
+ font-size: 12px;
1707
+ font-weight: 600;
1708
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
1709
+ }
1710
+
1711
+ .copio-privacy-pill {
1712
+ display: inline-flex;
1713
+ align-items: center;
1714
+ gap: 5px;
1715
+ padding: 4px 9px;
1716
+ border-radius: var(--copio-radius-pill);
1717
+ background: rgba(22, 101, 52, 0.35);
1718
+ border: 1px solid rgba(34, 197, 94, 0.4);
1719
+ color: #86efac;
1720
+ font-size: 11px;
1721
+ font-weight: 500;
1722
+ }
1723
+
1724
+ /* Shutter Dock (Shadow Part: shutter-dock) */
1725
+ .copio-shutter-dock {
1726
+ position: relative;
1727
+ z-index: 3;
1728
+ display: flex;
1729
+ align-items: center;
1730
+ justify-content: space-between;
1731
+ gap: 12px;
1732
+ padding: 12px 16px;
1733
+ background: var(--copio-color-surface);
1734
+ border-top: 1px solid var(--copio-color-border);
1735
+ min-height: 84px;
1736
+ flex-shrink: 0;
1737
+ }
1738
+
1739
+ .copio-shutter-side {
1740
+ flex: 1;
1741
+ display: flex;
1742
+ align-items: center;
1743
+ }
1744
+
1745
+ .copio-shutter-side.right {
1746
+ justify-content: flex-end;
1747
+ }
1748
+
1749
+ .copio-shutter-btn {
1750
+ appearance: none;
1751
+ width: 64px;
1752
+ height: 64px;
1753
+ border-radius: var(--copio-radius-pill);
1754
+ border: 4px solid var(--copio-color-primary);
1755
+ background: transparent;
1756
+ padding: 4px;
1757
+ cursor: pointer;
1758
+ display: inline-flex;
1759
+ align-items: center;
1760
+ justify-content: center;
1761
+ transition: transform var(--copio-transition-fast), border-color 150ms ease;
1762
+ flex-shrink: 0;
1763
+ }
1764
+
1765
+ .copio-shutter-btn:hover {
1766
+ transform: scale(1.04);
1767
+ }
1768
+
1769
+ .copio-shutter-btn:active {
1770
+ transform: scale(0.94);
1771
+ }
1772
+
1773
+ .copio-shutter-btn-inner,
1774
+ .copio-shutter-inner {
1775
+ width: 100%;
1776
+ height: 100%;
1777
+ border-radius: var(--copio-radius-pill);
1778
+ background: var(--copio-color-primary);
1779
+ display: flex;
1780
+ align-items: center;
1781
+ justify-content: center;
1782
+ color: var(--copio-color-primary-contrast);
1783
+ transition: transform var(--copio-transition-fast);
1784
+ }
1785
+
1786
+ .copio-shutter-btn:active .copio-shutter-btn-inner,
1787
+ .copio-shutter-btn:active .copio-shutter-inner {
1788
+ transform: scale(0.88);
1789
+ }
1790
+
1791
+ /* Stacking Thumbnail Counter Pill in Viewfinder */
1792
+ .copio-stack-pill {
1793
+ display: inline-flex;
1794
+ align-items: center;
1795
+ gap: 8px;
1796
+ min-height: var(--copio-touch-target-min);
1797
+ padding: 4px 12px 4px 6px;
1798
+ border-radius: var(--copio-radius-md);
1799
+ background: var(--copio-color-surface-elevated);
1800
+ border: 1px solid var(--copio-color-primary);
1801
+ color: var(--copio-color-text);
1802
+ font-size: 12px;
1803
+ font-weight: 600;
1804
+ cursor: pointer;
1805
+ }
1806
+
1807
+ .copio-stack-thumb {
1808
+ width: 30px;
1809
+ height: 36px;
1810
+ border-radius: 4px;
1811
+ object-fit: cover;
1812
+ border: 1px solid rgba(255, 255, 255, 0.35);
1813
+ background: #000;
1814
+ }
1815
+
1816
+ /* Workbench & Filmstrip (Shadow Part: workbench) */
1817
+ .copio-workbench,
1818
+ .copio-workbench-stage {
1819
+ position: relative;
1820
+ flex: 1 1 auto;
1821
+ display: flex;
1822
+ flex-direction: column;
1823
+ background: var(--copio-color-bg);
1824
+ overflow: hidden;
1825
+ min-height: 0;
1826
+ width: 100%;
1827
+ }
1828
+
1829
+ .copio-workbench-main {
1830
+ flex: 1;
1831
+ display: flex;
1832
+ flex-direction: column;
1833
+ min-height: 0;
1834
+ width: 100%;
1835
+ overflow: hidden;
1836
+ }
1837
+
1838
+ .copio-stage-canvas,
1839
+ .copio-canvas-viewport {
1840
+ position: relative;
1841
+ flex: 1 1 auto;
1842
+ display: flex;
1843
+ flex-direction: column;
1844
+ align-items: center;
1845
+ justify-content: center;
1846
+ overflow: hidden;
1847
+ padding: 16px 20px 44px 20px;
1848
+ background: var(--copio-color-stage-bg);
1849
+ min-height: 180px;
1850
+ }
1851
+
1852
+ .copio-canvas-viewport.has-card-switcher {
1853
+ padding-top: 66px;
1854
+ }
1855
+
1856
+ .copio-canvas-viewport.is-cropping {
1857
+ padding: 74px 26px 26px 26px;
1858
+ }
1859
+
1860
+ /* Card Side Switcher */
1861
+ .copio-card-side-switcher {
1862
+ position: absolute;
1863
+ top: 8px;
1864
+ left: 50%;
1865
+ transform: translateX(-50%);
1866
+ z-index: 6;
1867
+ display: inline-flex;
1868
+ gap: 4px;
1869
+ padding: 3px;
1870
+ background: var(--copio-color-surface-overlay, rgba(15, 22, 32, 0.88));
1871
+ border: 1px solid var(--copio-color-border-strong);
1872
+ border-radius: var(--copio-radius-pill);
1873
+ backdrop-filter: blur(8px);
1874
+ }
1875
+
1876
+ .copio-side-pill {
1877
+ appearance: none;
1878
+ border: none;
1879
+ background: transparent;
1880
+ color: var(--copio-color-text-muted);
1881
+ font-family: inherit;
1882
+ font-size: 11px;
1883
+ font-weight: 600;
1884
+ padding: 6px 12px;
1885
+ min-height: var(--copio-touch-target-min);
1886
+ min-width: var(--copio-touch-target-min);
1887
+ border-radius: var(--copio-radius-pill);
1888
+ cursor: pointer;
1889
+ display: inline-flex;
1890
+ align-items: center;
1891
+ justify-content: center;
1892
+ }
1893
+
1894
+ .copio-side-pill[aria-selected="true"] {
1895
+ background: var(--copio-color-primary);
1896
+ color: var(--copio-color-primary-contrast);
1897
+ }
1898
+
1899
+ .copio-stage-figure,
1900
+ .copio-canvas-wrapper {
1901
+ position: relative;
1902
+ display: flex;
1903
+ align-items: center;
1904
+ justify-content: center;
1905
+ max-width: 100%;
1906
+ max-height: 100%;
1907
+ }
1908
+
1909
+ .copio-stage-canvas img,
1910
+ .copio-stage-img,
1911
+ .copio-stage-image {
1912
+ display: block;
1913
+ max-width: 100%;
1914
+ max-height: 100%;
1915
+ width: auto;
1916
+ height: auto;
1917
+ object-fit: contain;
1918
+ box-shadow: var(--copio-shadow-elevated);
1919
+ border-radius: var(--copio-radius-sm);
1920
+ user-select: none;
1921
+ }
1922
+
1923
+ .copio-crop-layer {
1924
+ position: absolute;
1925
+ inset: 0;
1926
+ width: 100%;
1927
+ height: 100%;
1928
+ overflow: hidden;
1929
+ z-index: 8;
1930
+ touch-action: none;
1931
+ }
1932
+
1933
+ .copio-crop-box {
1934
+ position: absolute;
1935
+ border: 2px solid var(--copio-color-primary);
1936
+ box-shadow: 0 0 0 9999px rgba(5, 8, 14, 0.68);
1937
+ cursor: move;
1938
+ touch-action: none;
1939
+ box-sizing: border-box;
1940
+ }
1941
+
1942
+ /* Rule-of-thirds crop grid */
1943
+ .copio-crop-grid {
1944
+ position: absolute;
1945
+ inset: 0;
1946
+ pointer-events: none;
1947
+ background-image:
1948
+ linear-gradient(to right, rgba(56, 189, 248, 0.28) 1px, transparent 1px),
1949
+ linear-gradient(to bottom, rgba(56, 189, 248, 0.28) 1px, transparent 1px);
1950
+ background-size: 33.333% 33.333%;
1951
+ }
1952
+
1953
+ /* 48px x 48px Touch Target Handles (exceeds 44px requirement) */
1954
+ .copio-crop-handle {
1955
+ position: absolute;
1956
+ width: var(--copio-crop-handle-hit);
1957
+ height: var(--copio-crop-handle-hit);
1958
+ min-width: 44px;
1959
+ min-height: 44px;
1960
+ display: flex;
1961
+ align-items: center;
1962
+ justify-content: center;
1963
+ z-index: 10;
1964
+ touch-action: none;
1965
+ box-sizing: border-box;
1966
+ }
1967
+
1968
+ .copio-crop-handle::after {
1969
+ content: '';
1970
+ width: var(--copio-crop-handle-visual);
1971
+ height: var(--copio-crop-handle-visual);
1972
+ border-radius: 50%;
1973
+ background: var(--copio-color-primary);
1974
+ border: 2.5px solid #ffffff;
1975
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
1976
+ transition: transform 120ms ease;
1977
+ box-sizing: border-box;
1978
+ }
1979
+
1980
+ .copio-crop-handle:hover::after,
1981
+ .copio-crop-handle:active::after {
1982
+ transform: scale(1.25);
1983
+ background: var(--copio-color-success, #22c55e);
1984
+ }
1985
+
1986
+ .copio-crop-handle.nw { top: -24px; left: -24px; cursor: nwse-resize; }
1987
+ .copio-crop-handle.ne { top: -24px; right: -24px; cursor: nesw-resize; }
1988
+ .copio-crop-handle.sw { bottom: -24px; left: -24px; cursor: nesw-resize; }
1989
+ .copio-crop-handle.se { bottom: -24px; right: -24px; cursor: nwse-resize; }
1990
+ .copio-crop-handle.n, .copio-crop-handle.edge-n { top: -24px; left: calc(50% - 24px); cursor: ns-resize; }
1991
+ .copio-crop-handle.s, .copio-crop-handle.edge-s { bottom: -24px; left: calc(50% - 24px); cursor: ns-resize; }
1992
+ .copio-crop-handle.w, .copio-crop-handle.edge-w { left: -24px; top: calc(50% - 24px); cursor: ew-resize; }
1993
+ .copio-crop-handle.e, .copio-crop-handle.edge-e { right: -24px; top: calc(50% - 24px); cursor: ew-resize; }
1994
+
1995
+ /* Filmstrip & Reorder Tray */
1996
+ .copio-filmstrip,
1997
+ .copio-filmstrip-bar {
1998
+ display: flex;
1999
+ align-items: center;
2000
+ gap: 8px;
2001
+ padding: 8px 12px;
2002
+ background: var(--copio-color-surface);
2003
+ border-top: 1px solid var(--copio-color-border);
2004
+ overflow-x: auto;
2005
+ min-height: 80px;
2006
+ flex-shrink: 0;
2007
+ }
2008
+
2009
+ .copio-filmstrip-scroll {
2010
+ display: flex;
2011
+ align-items: center;
2012
+ gap: 8px;
2013
+ }
2014
+
2015
+ .copio-filmstrip-item {
2016
+ display: flex;
2017
+ flex-direction: column;
2018
+ align-items: center;
2019
+ gap: 4px;
2020
+ flex-shrink: 0;
2021
+ }
2022
+
2023
+ .copio-thumb-container {
2024
+ position: relative;
2025
+ width: 56px;
2026
+ height: 70px;
2027
+ border-radius: var(--copio-radius-sm);
2028
+ overflow: hidden;
2029
+ background: #000;
2030
+ border: 2px solid var(--copio-color-border);
2031
+ cursor: pointer;
2032
+ transition: all var(--copio-transition-fast);
2033
+ }
2034
+
2035
+ .copio-filmstrip-item.is-active .copio-thumb-container {
2036
+ border-color: var(--copio-color-primary);
2037
+ box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
2038
+ }
2039
+
2040
+ .copio-thumb-num {
2041
+ position: absolute;
2042
+ bottom: 3px;
2043
+ right: 3px;
2044
+ min-width: 16px;
2045
+ height: 16px;
2046
+ padding: 0 4px;
2047
+ border-radius: 999px;
2048
+ background: rgba(15, 23, 42, 0.85);
2049
+ color: #f8fafc;
2050
+ font-size: 10px;
2051
+ font-weight: 700;
2052
+ display: inline-flex;
2053
+ align-items: center;
2054
+ justify-content: center;
2055
+ }
2056
+
2057
+ .copio-thumb-reorder {
2058
+ display: flex;
2059
+ align-items: center;
2060
+ gap: 4px;
2061
+ }
2062
+
2063
+ .copio-reorder-btn {
2064
+ appearance: none;
2065
+ border: 1px solid var(--copio-color-border);
2066
+ background: var(--copio-color-surface-elevated);
2067
+ color: var(--copio-color-text-muted);
2068
+ border-radius: 4px;
2069
+ font-size: 9px;
2070
+ padding: 2px 5px;
2071
+ cursor: pointer;
2072
+ }
2073
+
2074
+ .copio-reorder-btn:disabled {
2075
+ opacity: 0.35;
2076
+ cursor: not-allowed;
2077
+ }
2078
+
2079
+ .copio-thumb-img {
2080
+ width: 100%;
2081
+ height: 100%;
2082
+ object-fit: cover;
2083
+ }
2084
+
2085
+ /* Edit Action Toolbar & Primary Completion Dock */
2086
+ .copio-toolbar,
2087
+ .copio-controls-dock {
2088
+ display: flex;
2089
+ flex-direction: column;
2090
+ gap: 8px;
2091
+ padding: 10px 12px;
2092
+ background: var(--copio-color-surface);
2093
+ border-top: 1px solid var(--copio-color-border);
2094
+ min-height: 56px;
2095
+ flex-shrink: 0;
2096
+ z-index: 6;
2097
+ }
2098
+
2099
+ .copio-edit-toolbar,
2100
+ .copio-toolbar-tools {
2101
+ display: flex;
2102
+ flex-wrap: wrap;
2103
+ align-items: center;
2104
+ gap: 6px;
2105
+ width: 100%;
2106
+ }
2107
+
2108
+ .copio-toolbar-tools .copio-tool-btn {
2109
+ flex: 1 1 56px;
2110
+ }
2111
+
2112
+ .copio-toolbar-actions {
2113
+ display: flex;
2114
+ align-items: center;
2115
+ gap: 8px;
2116
+ width: 100%;
2117
+ }
2118
+
2119
+ .copio-toolbar-actions .copio-btn-primary {
2120
+ width: 100%;
2121
+ }
2122
+
2123
+ .copio-tool-btn {
2124
+ appearance: none;
2125
+ border: 1px solid var(--copio-color-border);
2126
+ background: var(--copio-color-surface-elevated);
2127
+ color: var(--copio-color-text);
2128
+ font-family: inherit;
2129
+ font-size: 11px;
2130
+ font-weight: 600;
2131
+ min-height: var(--copio-touch-target-min);
2132
+ min-width: var(--copio-touch-target-min);
2133
+ padding: 4px 6px;
2134
+ border-radius: var(--copio-radius-md);
2135
+ display: flex;
2136
+ flex-direction: column;
2137
+ align-items: center;
2138
+ justify-content: center;
2139
+ gap: 3px;
2140
+ cursor: pointer;
2141
+ transition: all var(--copio-transition-fast);
2142
+ }
2143
+
2144
+ .copio-tool-btn:hover:not(:disabled) {
2145
+ border-color: var(--copio-color-border-strong);
2146
+ background: rgba(255, 255, 255, 0.06);
2147
+ }
2148
+
2149
+ .copio-tool-btn[aria-pressed="true"] {
2150
+ background: rgba(56, 189, 248, 0.16);
2151
+ color: var(--copio-color-primary);
2152
+ border-color: var(--copio-color-primary);
2153
+ }
2154
+
2155
+ .copio-tool-btn.danger {
2156
+ color: #fca5a5;
2157
+ }
2158
+
2159
+ .copio-tool-btn.danger:hover:not(:disabled) {
2160
+ background: rgba(239, 68, 68, 0.16);
2161
+ border-color: rgba(239, 68, 68, 0.45);
2162
+ }
2163
+
2164
+ .copio-toast-region {
2165
+ position: absolute;
2166
+ bottom: 124px;
2167
+ left: 12px;
2168
+ right: 12px;
2169
+ z-index: 30;
2170
+ display: flex;
2171
+ flex-direction: column;
2172
+ gap: 8px;
2173
+ pointer-events: none;
2174
+ }
2175
+
2176
+ .copio-toast {
2177
+ pointer-events: auto;
2178
+ display: flex;
2179
+ align-items: center;
2180
+ justify-content: space-between;
2181
+ gap: 10px;
2182
+ padding: 8px 12px;
2183
+ border-radius: var(--copio-radius-md);
2184
+ background: #0f172a;
2185
+ color: #f8fafc;
2186
+ border: 1px solid var(--copio-color-primary);
2187
+ box-shadow: var(--copio-shadow-elevated);
2188
+ font-size: 12px;
2189
+ font-weight: 500;
2190
+ position: relative;
2191
+ overflow: hidden;
2192
+ }
2193
+
2194
+ .copio-toast-progress {
2195
+ position: absolute;
2196
+ bottom: 0;
2197
+ left: 0;
2198
+ height: 3px;
2199
+ background: var(--copio-color-primary);
2200
+ transition: width 100ms linear;
2201
+ }
2202
+
2203
+ .copio-toast-undo-btn,
2204
+ .copio-btn-toast-undo {
2205
+ appearance: none;
2206
+ border: 1px solid rgba(56, 189, 248, 0.45);
2207
+ background: rgba(56, 189, 248, 0.16);
2208
+ color: #38bdf8;
2209
+ font-family: inherit;
2210
+ font-size: 12px;
2211
+ font-weight: 700;
2212
+ min-height: var(--copio-touch-target-min);
2213
+ min-width: var(--copio-touch-target-min);
2214
+ padding: 0 12px;
2215
+ border-radius: var(--copio-radius-sm);
2216
+ cursor: pointer;
2217
+ flex-shrink: 0;
2218
+ }
2219
+
2220
+ .copio-ocr-content {
2221
+ display: flex;
2222
+ flex-direction: column;
2223
+ gap: 8px;
2224
+ }
2225
+
2226
+ .copio-ocr-text {
2227
+ margin: 0;
2228
+ padding: 10px;
2229
+ max-height: 180px;
2230
+ overflow: auto;
2231
+ background: var(--copio-color-bg);
2232
+ color: var(--copio-color-text);
2233
+ border: 1px solid var(--copio-color-border);
2234
+ border-radius: var(--copio-radius-sm);
2235
+ font-family: var(--copio-font-mono);
2236
+ font-size: 11px;
2237
+ line-height: 1.5;
2238
+ white-space: pre-wrap;
2239
+ }
2240
+
2241
+ .copio-ocr-meta {
2242
+ font-size: 11px;
2243
+ color: var(--copio-color-text-muted);
2244
+ }
2245
+
2246
+ /* Slide-up OCR Extraction Sheet */
2247
+ .copio-ocr-sheet {
2248
+ position: absolute;
2249
+ inset: auto 0 0 0;
2250
+ max-height: 78%;
2251
+ background: var(--copio-color-surface);
2252
+ border-top: 1px solid var(--copio-color-primary);
2253
+ border-radius: 16px 16px 0 0;
2254
+ box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.65);
2255
+ z-index: 25;
2256
+ display: flex;
2257
+ flex-direction: column;
2258
+ padding: 14px;
2259
+ gap: 10px;
2260
+ }
2261
+
2262
+ .copio-ocr-header {
2263
+ display: flex;
2264
+ align-items: center;
2265
+ justify-content: space-between;
2266
+ gap: 8px;
2267
+ }
2268
+
2269
+ .copio-ocr-textarea {
2270
+ width: 100%;
2271
+ min-height: 130px;
2272
+ flex: 1;
2273
+ resize: none;
2274
+ background: var(--copio-color-bg);
2275
+ color: var(--copio-color-text);
2276
+ border: 1px solid var(--copio-color-border);
2277
+ border-radius: var(--copio-radius-sm);
2278
+ padding: 10px;
2279
+ font-family: var(--copio-font-mono);
2280
+ font-size: 11px;
2281
+ line-height: 1.5;
2282
+ }
2283
+
2284
+ /* Container-Scoped Toast Stack */
2285
+ .sl-toast-stack,
2286
+ .copio-toast-stack-scoped {
2287
+ position: absolute !important;
2288
+ top: auto !important;
2289
+ bottom: 0 !important;
2290
+ left: 0 !important;
2291
+ right: 0 !important;
2292
+ width: 100% !important;
2293
+ max-width: 100% !important;
2294
+ padding: var(--copio-spacing-md) !important;
2295
+ box-sizing: border-box !important;
2296
+ z-index: 1000 !important;
2297
+ pointer-events: none;
2298
+ }
2299
+
2300
+ .sl-toast-stack sl-alert,
2301
+ .copio-toast-stack-scoped sl-alert {
2302
+ pointer-events: auto;
2303
+ margin-top: var(--copio-spacing-sm);
2304
+ }
2305
+
2306
+ /* ==========================================================================
2307
+ 4. @container BREAKPOINTS (Strictly Container Queries)
2308
+ ========================================================================== */
2309
+
2310
+ @container copio-scanner (max-width: 400px) {
2311
+ .copio-header {
2312
+ padding: 6px 10px;
2313
+ min-height: 52px;
2314
+ }
2315
+ .copio-header-left {
2316
+ flex-direction: column;
2317
+ align-items: flex-start;
2318
+ gap: 2px;
2319
+ }
2320
+ .copio-mode-badge {
2321
+ font-size: 10px;
2322
+ padding: 2px 6px;
2323
+ }
2324
+ .copio-subtitle {
2325
+ display: none;
2326
+ }
2327
+ .copio-filmstrip,
2328
+ .copio-filmstrip-bar {
2329
+ gap: 6px;
2330
+ padding: 6px 8px;
2331
+ }
2332
+ .copio-tool-btn {
2333
+ font-size: 10px;
2334
+ padding: 3px 4px;
2335
+ }
2336
+ .copio-btn {
2337
+ padding: 0 8px;
2338
+ font-size: 12px;
2339
+ }
2340
+ }
2341
+
2342
+ @container copio-scanner (min-width: 401px) and (max-width: 767px) {
2343
+ .copio-header {
2344
+ padding: var(--copio-spacing-sm) var(--copio-spacing-md);
2345
+ }
2346
+ .copio-tool-btn {
2347
+ flex-direction: row;
2348
+ font-size: 12px;
2349
+ gap: 6px;
2350
+ }
2351
+ }
2352
+
2353
+ @container copio-scanner (min-width: 768px) {
2354
+ .copio-header {
2355
+ padding: var(--copio-spacing-md) var(--copio-spacing-lg);
2356
+ }
2357
+ .copio-workbench-main {
2358
+ flex-direction: row;
2359
+ }
2360
+ .copio-filmstrip,
2361
+ .copio-filmstrip-bar {
2362
+ order: -1;
2363
+ flex-direction: column;
2364
+ width: 168px;
2365
+ height: 100%;
2366
+ border-top: none;
2367
+ border-right: 1px solid var(--copio-color-border);
2368
+ overflow-y: auto;
2369
+ overflow-x: hidden;
2370
+ padding: 12px;
2371
+ }
2372
+ .copio-filmstrip-scroll {
2373
+ flex-direction: column;
2374
+ width: 100%;
2375
+ }
2376
+ .copio-thumb-container {
2377
+ width: 112px;
2378
+ height: 84px;
2379
+ }
2380
+ .copio-toolbar,
2381
+ .copio-controls-dock {
2382
+ flex-direction: row;
2383
+ align-items: center;
2384
+ justify-content: space-between;
2385
+ }
2386
+ .copio-toolbar-tools {
2387
+ width: auto;
2388
+ flex: 1;
2389
+ }
2390
+ .copio-toolbar-actions {
2391
+ width: auto;
2392
+ min-width: 200px;
2393
+ }
2394
+ }
2395
+ `,xn=null;function lh(){if(xn)return xn;if(typeof CSSStyleSheet<"u"&&typeof Document<"u"&&"adoptedStyleSheets"in Document.prototype&&"replaceSync"in CSSStyleSheet.prototype)try{return xn=new CSSStyleSheet,xn.replaceSync(Co),xn}catch{return null}return null}function ch(s){if(!s)return;let t=lh();if(t&&"adoptedStyleSheets"in s){let e=s.adoptedStyleSheets||[];e.includes(t)||(s.adoptedStyleSheets=[...e,t])}else if(!s.querySelector("style[data-copio-encapsulated-styles]")){let e=document.createElement("style");e.setAttribute("data-copio-encapsulated-styles",""),e.textContent=Co,s.appendChild(e)}}var Ru=typeof HTMLElement<"u"?HTMLElement:class{},ko=class extends Ru{#t=null;#e=null;#i=null;#n=!1;#r="viewfinder";#s=0;#a=0;#c=!1;#o=!1;#d=null;#p=null;#u=0;#l=null;#f=null;#g=null;onShutter=null;get#h(){return this.docId?this.docId:(this.#f||(this.#f=`doc_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`),this.#f)}static get observedAttributes(){return["mode","aspect","stage","doc-id","features","export-formats","ocr-languages","max-pages","asset-base","license-key","theme","ocr","pdf"]}constructor(){super(),typeof this.attachShadow=="function"&&this.attachShadow({mode:"open"}),this.#b()}#b(){let t={storage:this.#e};typeof this.getAttribute=="function"&&(this.hasAttribute("features")&&(t.features=this.getAttribute("features")),this.hasAttribute("export-formats")&&(t.exportFormats=this.getAttribute("export-formats")),this.hasAttribute("ocr-languages")&&(t.ocrLanguages=this.getAttribute("ocr-languages")),this.hasAttribute("max-pages")&&(t.maxPages=this.getAttribute("max-pages")),this.hasAttribute("asset-base")&&(t.assetBase=this.getAttribute("asset-base")),this.hasAttribute("license-key")&&(t.licenseKey=this.getAttribute("license-key")),this.hasAttribute("ocr")&&(t.ocr=this.getAttribute("ocr")!=="false"),this.hasAttribute("pdf")&&(t.pdf=this.getAttribute("pdf")!=="false")),this.#t=new en(t)}connectedCallback(){this.shadowRoot&&(ch(this.shadowRoot),this.#v()),typeof Cs=="function"&&typeof document<"u"&&ks()===document.body&&Cs(this.shadowRoot?.querySelector(".copio-scanner-container")||this),this.#t&&(this.#i=this.#t.subscribe(async()=>{let t=await this.getPages();this.dispatch(se.PAGES_CHANGED,{pages:t,docId:this.docId}),this.#w()})),this.hasAttribute&&this.hasAttribute("asset-base")&&Qs(this.getAttribute("asset-base")),this.#m(),this.#w()}disconnectedCallback(){if(this.#A(),typeof this.#i=="function"&&(this.#i(),this.#i=null),this.#p&&(clearInterval(this.#p),this.#p=null),typeof Cs=="function"&&typeof document<"u"){let t=this.shadowRoot?.querySelector(".copio-scanner-container")||this;ks()===t&&Cs(null)}}attributeChangedCallback(t,e,i){if(!(e===i||!this.#t))switch(t){case"features":this.#t.setFeatures(i),this.#m();break;case"export-formats":this.#t.exportFormats=i,this.#m();break;case"ocr-languages":this.#t.ocrLanguages=i;break;case"asset-base":this.#t.assetBase=i;break;case"license-key":this.#t.licenseKey=i;break;case"ocr":this.#t.ocr=i!=="false",this.#m();break;case"pdf":this.#t.pdf=i!=="false",this.#m();break;case"stage":if(i==="viewfinder"||i==="workbench"){this.#r=i;let n=this.shadowRoot;if(n){let o=n.getElementById("viewfinder-section"),h=n.getElementById("workbench-section");o&&h&&(o.style.display=i==="viewfinder"?"flex":"none",h.style.display=i==="workbench"?"flex":"none")}this.#w()}break;case"max-pages":this.#t.maxPages=i,this.#w();break;case"mode":case"aspect":case"theme":this.#w();break}}#m(){if(typeof this.querySelectorAll!="function")return;let t=[];this.shadowRoot&&t.push(this.shadowRoot),t.push(this);for(let e of t){let i=e.querySelectorAll("copio-carousel, copio-row, copio-images");for(let n of i)"ocr"in n&&(n.ocr=this.ocrEnabled),"pdf"in n&&(n.pdf=this.pdf)}}#v(){if(!this.shadowRoot||this.shadowRoot.innerHTML)return;let t="Align Document Inside Frame";this.aspect==="card"?t="Step 1 of 2: Capture Front of ID Card":this.mode==="batch"&&(t="Batch Capture \xB7 Page 1"),this.shadowRoot.innerHTML=`
2396
+ <div class="copio-scanner-container copio-scanner-host" part="scanner-root">
2397
+ <header class="copio-header" part="header">
2398
+ <div class="copio-header-left">
2399
+ <span class="copio-mode-badge" id="mode-badge">${(this.mode||"single").toUpperCase()}</span>
2400
+ <div class="copio-title-group">
2401
+ <h2 class="copio-title" id="header-title">Copio Scanner</h2>
2402
+ <p class="copio-subtitle" id="header-subtitle">Non-destructive mobile document scanner</p>
2403
+ </div>
2404
+ </div>
2405
+ <div class="copio-header-actions" part="header-actions">
2406
+ <div class="copio-stage-tabs" role="tablist" aria-label="Scanner Stage">
2407
+ <button type="button" class="copio-stage-tab" id="tab-viewfinder" role="tab" aria-selected="true">Camera</button>
2408
+ <button type="button" class="copio-stage-tab" id="tab-workbench" role="tab" aria-selected="false">Workbench</button>
2409
+ </div>
2410
+ <slot name="header-actions"></slot>
2411
+ </div>
2412
+ </header>
2413
+
2414
+ <!-- Viewfinder Stage -->
2415
+ <div class="copio-viewfinder copio-viewfinder-stage" part="viewfinder" id="viewfinder-section">
2416
+ <div class="copio-viewfinder-hud-top">
2417
+ <div class="copio-step-pill" id="step-pill">
2418
+ <span class="copio-status-dot"></span>
2419
+ <span id="step-pill-text">${t}</span>
2420
+ </div>
2421
+ <div class="copio-privacy-pill" title="100% Local On-Device Processing">
2422
+ <span>\u{1F512} 100% Local</span>
2423
+ </div>
2424
+ </div>
2425
+
2426
+ <div class="copio-camera-feed" id="camera-feed">
2427
+ <video id="camera-video" autoplay playsinline muted style="display:none; position:absolute; inset:0; width:100%; height:100%; object-fit:cover; z-index:0;"></video>
2428
+ <slot name="viewfinder">
2429
+ <div class="copio-framing-guide" id="framing-guide" data-aspect="${this.aspect}">
2430
+ <span class="copio-corner tl"></span>
2431
+ <span class="copio-corner tr"></span>
2432
+ <span class="copio-corner bl"></span>
2433
+ <span class="copio-corner br"></span>
2434
+ <div class="copio-edge-quad"></div>
2435
+ <div class="copio-camera-placeholder">
2436
+ <svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
2437
+ <path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/>
2438
+ <circle cx="12" cy="13" r="4"/>
2439
+ </svg>
2440
+ <span>Position document within guide lines</span>
2441
+ </div>
2442
+ </div>
2443
+ </slot>
2444
+ </div>
2445
+
2446
+ <div class="copio-shutter-dock" part="shutter-dock">
2447
+ <div class="copio-shutter-side left">
2448
+ <button type="button" class="copio-btn copio-btn-secondary" id="btn-import-file" title="Import image from file">
2449
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2450
+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
2451
+ <polyline points="17 8 12 3 7 8"/>
2452
+ <line x1="12" y1="3" x2="12" y2="15"/>
2453
+ </svg>
2454
+ <span>Import</span>
2455
+ </button>
2456
+ </div>
2457
+
2458
+ <slot name="shutter-dock">
2459
+ <button type="button" class="copio-shutter-btn" id="btn-shutter" aria-label="Capture page">
2460
+ <span class="copio-shutter-btn-inner"></span>
2461
+ </button>
2462
+ </slot>
2463
+
2464
+ <div class="copio-shutter-side right">
2465
+ <button type="button" class="copio-stack-pill" id="btn-review" title="Review pages" style="display:none;">
2466
+ <span id="review-pill-text">Review (0) \u2192</span>
2467
+ </button>
2468
+ </div>
2469
+ </div>
2470
+ </div>
2471
+
2472
+ <!-- Workbench Stage -->
2473
+ <div class="copio-workbench copio-workbench-stage" part="workbench" id="workbench-section" style="display: none;">
2474
+ <div class="copio-workbench-main">
2475
+ <div class="copio-canvas-viewport" id="canvas-viewport">
2476
+ <div class="copio-card-side-switcher" id="card-side-switcher" style="display:none;" role="tablist" aria-label="Card side switcher">
2477
+ <button type="button" role="tab" class="copio-side-pill active" id="btn-card-front" aria-selected="true">1. Front Side</button>
2478
+ <button type="button" role="tab" class="copio-side-pill" id="btn-card-back" aria-selected="false">2. Back Side</button>
2479
+ </div>
2480
+
2481
+ <div class="copio-canvas-wrapper" id="canvas-wrapper">
2482
+ <img id="stage-img" class="copio-stage-image" alt="Active document page" />
2483
+ </div>
2484
+ </div>
2485
+
2486
+ <!-- Filmstrip Tray -->
2487
+ <div class="copio-filmstrip" id="filmstrip-tray" part="filmstrip">
2488
+ <div class="copio-filmstrip-scroll" id="filmstrip-scroll">
2489
+ <slot name="filmstrip"></slot>
2490
+ </div>
2491
+ </div>
2492
+ </div>
2493
+
2494
+ <!-- Bottom Action Toolbar -->
2495
+ <footer class="copio-toolbar" part="toolbar" id="workbench-toolbar">
2496
+ <div class="copio-toolbar-tools">
2497
+ <button type="button" class="copio-tool-btn" id="btn-retake" title="Retake page">
2498
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2499
+ <path d="M23 4v6h-6M1 20v-6h6"/>
2500
+ <path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>
2501
+ </svg>
2502
+ <span>Retake</span>
2503
+ </button>
2504
+
2505
+ <button type="button" class="copio-tool-btn" id="btn-crop" title="Adjust crop">
2506
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2507
+ <path d="M6 2v14a2 2 0 0 0 2 2h14"/>
2508
+ <path d="M18 22V8a2 2 0 0 0-2-2H2"/>
2509
+ </svg>
2510
+ <span id="crop-btn-label">Crop</span>
2511
+ </button>
2512
+
2513
+ <button type="button" class="copio-tool-btn" id="btn-rotate" title="Rotate 90\xB0">
2514
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2515
+ <path d="M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38l5.67-5.67"/>
2516
+ </svg>
2517
+ <span>Rotate</span>
2518
+ </button>
2519
+
2520
+ <button type="button" class="copio-tool-btn" id="btn-filter-bw" title="Toggle B&W filter">
2521
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2522
+ <circle cx="12" cy="12" r="10"/>
2523
+ <path d="M12 2a10 10 0 0 1 0 20z" fill="currentColor"/>
2524
+ </svg>
2525
+ <span>B&W</span>
2526
+ </button>
2527
+
2528
+ <button type="button" class="copio-tool-btn" id="btn-ocr" title="Recognize text">
2529
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2530
+ <path d="M4 7V4h16v3M9 20h6M12 4v16"/>
2531
+ </svg>
2532
+ <span>OCR</span>
2533
+ </button>
2534
+
2535
+ <button type="button" class="copio-tool-btn copio-btn-danger" id="btn-delete" title="Delete active page">
2536
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2537
+ <polyline points="3 6 5 6 21 6"/>
2538
+ <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
2539
+ </svg>
2540
+ <span>Delete</span>
2541
+ </button>
2542
+ </div>
2543
+
2544
+ <div class="copio-toolbar-actions">
2545
+ <slot name="toolbar">
2546
+ <button type="button" class="copio-btn copio-btn-primary" id="btn-primary-complete">
2547
+ \u2713 Use Photo
2548
+ </button>
2549
+ </slot>
2550
+ </div>
2551
+ </footer>
2552
+
2553
+ <!-- Scoped OCR Slide-out / Bottom Sheet -->
2554
+ <div class="copio-ocr-sheet" id="ocr-sheet" style="display:none;" part="ocr-sheet">
2555
+ <div class="copio-ocr-header">
2556
+ <strong class="copio-ocr-title">Text Recognition (OCR)</strong>
2557
+ <button type="button" class="copio-btn copio-btn-secondary" id="btn-close-ocr">\u2715</button>
2558
+ </div>
2559
+ <div class="copio-ocr-body" id="ocr-body">
2560
+ <p class="copio-ocr-placeholder">Select text or extract full page data...</p>
2561
+ </div>
2562
+ </div>
2563
+
2564
+ <!-- Container-scoped Toast Region (5s undo) -->
2565
+ <div class="copio-toast-region" id="toast-region" aria-live="polite"></div>
2566
+ </div>
2567
+
2568
+ <!-- Hidden input for file picker fallback -->
2569
+ <input type="file" id="internal-file-input" accept="image/*" style="display: none;" />
2570
+ <slot></slot>
2571
+ </div>
2572
+ `,this.#S()}#S(){let t=this.shadowRoot;if(!t)return;t.getElementById("tab-viewfinder")?.addEventListener("click",()=>{this.stage="viewfinder"}),t.getElementById("tab-workbench")?.addEventListener("click",()=>{this.stage="workbench"});let e=t.getElementById("internal-file-input");t.getElementById("btn-import-file")?.addEventListener("click",()=>{e?.click()}),e?.addEventListener("change",async i=>{let n=i.target;n.files&&n.files.length>0&&(await this.addFiles(n.files),n.value="")}),t.getElementById("btn-shutter")?.addEventListener("click",async()=>{await this.#C()}),t.getElementById("btn-review")?.addEventListener("click",()=>{this.stage="workbench"}),t.getElementById("btn-retake")?.addEventListener("click",()=>{this.#c=!0,this.#o=!1,this.stage="viewfinder"}),t.getElementById("btn-rotate")?.addEventListener("click",async()=>{await this.#T()}),t.getElementById("btn-filter-bw")?.addEventListener("click",async()=>{await this.#k()}),t.getElementById("btn-crop")?.addEventListener("click",async()=>{await this.#M()}),t.getElementById("btn-delete")?.addEventListener("click",async()=>{await this.#P()}),t.getElementById("btn-ocr")?.addEventListener("click",async()=>{await this.#R()}),t.getElementById("btn-close-ocr")?.addEventListener("click",()=>{this.#F()}),t.getElementById("btn-primary-complete")?.addEventListener("click",async()=>{await this.#O()}),t.getElementById("btn-card-front")?.addEventListener("click",()=>{this.#s=0,this.#w()}),t.getElementById("btn-card-back")?.addEventListener("click",()=>{this.#s=1,this.#w()}),this.#_()}#_(){let t=this.shadowRoot;if(!t)return;let e=t.getElementById("crop-box"),i=t.querySelectorAll(".copio-crop-handle");if(!e||i.length===0)return;let n=null,o=!1,h=0,u=0,g=null,v=f=>{let A=f.target.closest(".copio-crop-handle");if(A)n=A.getAttribute("data-handle"),o=!1;else if(f.target===e||f.target.classList.contains("copio-crop-grid"))n=null,o=!0;else return;f.preventDefault(),f.stopPropagation(),h=f.clientX,u=f.clientY,g=this.#d?{...this.#d}:{x:.05,y:.05,w:.9,h:.9},window.addEventListener("pointermove",p),window.addEventListener("pointerup",a)},p=f=>{if(!n&&!o||!g)return;let _=(t.getElementById("canvas-wrapper")||t.getElementById("canvas-viewport"))?.getBoundingClientRect()||{width:300,height:400},d=(f.clientX-h)/Math.max(_.width,1),y=(f.clientY-u)/Math.max(_.height,1),{x:r,y:l,w:m,h:x}=g;if(o)r=Math.min(Math.max(0,r+d),1-m),l=Math.min(Math.max(0,l+y),1-x);else if(n){if(n.includes("w")){let D=Math.min(Math.max(0,r+d),r+m-.1);m+=r-D,r=D}if(n.includes("e")&&(m=Math.min(Math.max(.1,m+d),1-r)),n.includes("n")){let D=Math.min(Math.max(0,l+y),l+x-.1);x+=l-D,l=D}n.includes("s")&&(x=Math.min(Math.max(.1,x+y),1-l))}this.#d={x:r,y:l,w:m,h:x},this.#I()},a=()=>{n=null,o=!1,g=null,window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",a)};e.addEventListener("pointerdown",v),i.forEach(f=>{f.addEventListener("pointerdown",v)})}#I(){let t=this.shadowRoot;if(!t||!this.#d)return;let e=t.getElementById("crop-box");e&&(e.style.left=`${(this.#d.x*100).toFixed(1)}%`,e.style.top=`${(this.#d.y*100).toFixed(1)}%`,e.style.width=`${(this.#d.w*100).toFixed(1)}%`,e.style.height=`${(this.#d.h*100).toFixed(1)}%`)}async#w(){if(this.shadowRoot)return this.#l?this.#l:(this.#l=(async()=>{try{await Promise.resolve(),await this.#x()}finally{this.#l=null}})(),this.#l)}async#x(){if(this.shadowRoot)try{let t=await this.getPages();this.#a=t.length;let e=this.shadowRoot,i=e.getElementById("mode-badge");i&&(i.textContent=(this.mode||"single").toUpperCase());let n=e.getElementById("tab-viewfinder"),o=e.getElementById("tab-workbench");n&&n.setAttribute("aria-selected",String(this.#r==="viewfinder")),o&&o.setAttribute("aria-selected",String(this.#r==="workbench"));let h=e.getElementById("viewfinder-section"),u=e.getElementById("workbench-section");h&&u&&(this.#r==="viewfinder"?(h.style.display="flex",u.style.display="none"):(h.style.display="none",u.style.display="flex"));let g=e.getElementById("framing-guide");g&&g.setAttribute("data-aspect",this.aspect||"auto");let v=e.getElementById("step-pill-text");v&&(this.#g?v.textContent="Camera Active \xB7 Tap Shutter to Snap":this.aspect==="card"&&this.maxPages===2?v.textContent=t.length===0?"Step 1 of 2: Capture Front of ID Card":"Step 2 of 2: Capture Back of ID Card":this.aspect==="card"?v.textContent="Align Card Inside Frame":this.mode==="batch"?v.textContent=`Batch Capture \xB7 Page ${t.length+1}`:v.textContent="Align Document Inside Frame");let p=e.getElementById("btn-ocr");p&&(p.style.display=this.ocrEnabled&&this.hasFeature("ocr")?"":"none");let a=e.getElementById("btn-review"),f=e.getElementById("review-pill-text");if(a&&f&&(t.length>0?(a.style.display="inline-flex",f.textContent=`Review (${t.length}) \u2192`):a.style.display="none"),t.length===0){this.#r==="workbench"&&(this.stage="viewfinder");return}this.#s>=t.length&&(this.#s=Math.max(0,t.length-1));let A=t[this.#s],_=e.getElementById("card-side-switcher");if(_){let m=this.aspect==="card"&&this.maxPages===2;_.style.display=m?"flex":"none";let x=e.getElementById("btn-card-front"),D=e.getElementById("btn-card-back");x&&(x.classList.toggle("active",this.#s===0),x.setAttribute("aria-selected",String(this.#s===0))),D&&(D.classList.toggle("active",this.#s===1),D.setAttribute("aria-selected",String(this.#s===1)))}let d=e.getElementById("stage-img");d&&(d.src=this.#o?A.originalSrc||A.src||"":A.src||A.originalSrc||"");let y=e.getElementById("crop-layer");if(this.#o){if(!y){let m=e.getElementById("canvas-wrapper");y=document.createElement("div"),y.className="copio-crop-layer",y.id="crop-layer",y.innerHTML=`
2573
+ <div class="copio-crop-box" id="crop-box">
2574
+ <div class="copio-crop-grid"></div>
2575
+ <span class="copio-crop-handle nw" data-handle="nw"></span>
2576
+ <span class="copio-crop-handle ne" data-handle="ne"></span>
2577
+ <span class="copio-crop-handle se" data-handle="se"></span>
2578
+ <span class="copio-crop-handle sw" data-handle="sw"></span>
2579
+ <span class="copio-crop-handle n edge-n" data-handle="n"></span>
2580
+ <span class="copio-crop-handle e edge-e" data-handle="e"></span>
2581
+ <span class="copio-crop-handle s edge-s" data-handle="s"></span>
2582
+ <span class="copio-crop-handle w edge-w" data-handle="w"></span>
2583
+ </div>
2584
+ `,m?.appendChild(y),this.#_()}y.style.display="block",this.#d=A.edits?.crop||{x:.05,y:.05,w:.9,h:.9},this.#I()}else y&&y.remove();let r=e.getElementById("crop-btn-label");r&&(r.textContent=this.#o?"Apply":"Crop");let l=e.getElementById("btn-primary-complete");l&&(this.aspect==="card"&&this.maxPages===2&&t.length===1?l.textContent="Next: Capture Back (Step 2/2) \u2192":this.aspect==="card"&&t.length>=2?l.textContent="\u2713 Complete ID Scan (2 Sides)":this.mode==="batch"?l.textContent=`\u2713 Complete Scan (${t.length} Pages)`:l.textContent="\u2713 Use Photo"),this.#y(t)}catch{}}#y(t){let e=this.shadowRoot;if(!e)return;let i=e.getElementById("filmstrip-scroll");i&&(i.innerHTML="",t.forEach((n,o)=>{let h=document.createElement("div");h.className=`copio-filmstrip-item ${o===this.#s?"is-active":""}`,h.setAttribute("data-index",String(o)),h.innerHTML=`
2585
+ <div class="copio-thumb-container">
2586
+ <img src="${n.src||n.originalSrc}" alt="Page ${o+1}" class="copio-thumb-img" />
2587
+ <span class="copio-thumb-num">${o+1}</span>
2588
+ </div>
2589
+ ${this.mode==="batch"?`
2590
+ <div class="copio-thumb-reorder">
2591
+ <button type="button" class="copio-reorder-btn move-left" title="Move Left" ${o===0?"disabled":""}>\u25C0</button>
2592
+ <button type="button" class="copio-reorder-btn move-right" title="Move Right" ${o===t.length-1?"disabled":""}>\u25B6</button>
2593
+ </div>
2594
+ `:""}
2595
+ `,h.querySelector(".copio-thumb-container")?.addEventListener("click",()=>{this.#s=o,this.#o=!1,this.#w()}),this.mode==="batch"&&(h.querySelector(".move-left")?.addEventListener("click",async u=>{u.stopPropagation(),await this.#E(o,o-1)}),h.querySelector(".move-right")?.addEventListener("click",async u=>{u.stopPropagation(),await this.#E(o,o+1)})),i.appendChild(h)}))}async#E(t,e){let i=await this.getPages();if(e<0||e>=i.length||t===e)return;let n=i.map(h=>h.id),[o]=n.splice(t,1);n.splice(e,0,o),await this.#t.reorderPages(this.#h,n),this.#s=e,this.#w()}#A(){this.#g&&(this.#g.getTracks().forEach(n=>n.stop()),this.#g=null);let t=this.shadowRoot,e=t?.getElementById("camera-video");e&&(e.srcObject=null,e.style.display="none");let i=t?.querySelector(".copio-camera-placeholder");i&&(i.style.display="")}async#C(){if(typeof this.onShutter=="function"&&await this.onShutter()!==!1)return;let t=this.shadowRoot,e=t?.getElementById("camera-video");if(this.#g&&e&&e.readyState>=2){let o=document.createElement("canvas");o.width=e.videoWidth||1280,o.height=e.videoHeight||720;let h=o.getContext("2d");if(h){h.drawImage(e,0,0,o.width,o.height);let u=await new Promise(g=>o.toBlob(g,"image/jpeg",.92));if(u){this.#A();let g=new File([u],`capture_${Date.now()}.jpg`,{type:"image/jpeg"});await this.addFiles([g]);return}}}if(!(typeof navigator<"u"&&navigator.webdriver===!0)&&typeof navigator<"u"&&navigator.mediaDevices?.getUserMedia&&e)try{this.#g=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"},width:{ideal:1920},height:{ideal:1080}},audio:!1}),e.srcObject=this.#g,e.style.display="block",await e.play();let o=t?.querySelector(".copio-camera-placeholder");o&&(o.style.display="none");let h=t?.getElementById("step-pill-text");h&&(h.textContent="Camera Active \xB7 Tap Shutter to Snap");return}catch{}let n=t?.getElementById("internal-file-input");n&&typeof n.click=="function"&&n.click()}async#T(){let e=(await this.getPages())[this.#s];if(!e)return;let n=((e.edits?.rotate||0)+90)%360;await this.#t.applyEdit(this.#h,e.id,{rotate:n}),await this.#w()}async#k(){let e=(await this.getPages())[this.#s];if(!e)return;let n=(e.edits?.filter||"none")==="bw"?"none":"bw";await this.#t.applyEdit(this.#h,e.id,{filter:n}),await this.#w()}async#M(){let e=(await this.getPages())[this.#s];if(e){if(this.#o){this.#o=!1;let i=this.#d;this.#d=null,i&&await this.#t.applyEdit(this.#h,e.id,{crop:i})}else this.#o=!0;await this.#w()}}async#P(){let t=await this.getPages(),e=t[this.#s];if(!e)return;let i=e.id;await this.#t.deletePage(this.#h,i),this.dispatch(se.PAGE_REMOVED,{pageId:i,docId:this.docId}),this.#s>=t.length-1&&(this.#s=Math.max(0,t.length-2)),this.#L(),await this.#w()}#L(){let t=this.shadowRoot;if(!t)return;let e=t.getElementById("toast-region");if(!e)return;this.#p&&clearInterval(this.#p),this.#u=5;let i=()=>{e.innerHTML=`
2596
+ <div class="copio-toast copio-toast-undo">
2597
+ <span>Page deleted</span>
2598
+ <button type="button" class="copio-btn-toast-undo" id="btn-toast-undo">
2599
+ Undo (${this.#u}s)
2600
+ </button>
2601
+ </div>
2602
+ `,t.getElementById("btn-toast-undo")?.addEventListener("click",async()=>{clearInterval(this.#p),this.#p=null,e.innerHTML="",await this.#t.undo(this.#h),await this.#w()})};i(),this.#p=setInterval(()=>{this.#u-=1,this.#u<=0?(clearInterval(this.#p),this.#p=null,e.innerHTML=""):i()},1e3)}async#R(){let t=this.shadowRoot;if(!t)return;let e=t.getElementById("ocr-sheet"),i=t.getElementById("ocr-body");if(!(!e||!i)){e.style.display="block",i.innerHTML='<p class="copio-ocr-loading">Recognizing text...</p>';try{let o=(await this.getPages())[this.#s],h=await this.ocr(o?.id||null),u=h.averageConfidence||0,g=u<=1&&u>0?Math.round(u*100):Math.round(u);i.innerHTML=`
2603
+ <div class="copio-ocr-content">
2604
+ <pre class="copio-ocr-text">${h.text||"No text detected."}</pre>
2605
+ <div class="copio-ocr-meta">
2606
+ <span>Confidence: ${g}%</span>
2607
+ </div>
2608
+ </div>
2609
+ `}catch(n){i.innerHTML=`<p class="copio-ocr-error">OCR recognition failed: ${n.message}</p>`}}}#F(){let t=this.shadowRoot;if(!t)return;let e=t.getElementById("ocr-sheet");e&&(e.style.display="none")}async#O(){if(this.aspect==="card"&&this.maxPages===2&&this.#a===1){this.stage="viewfinder";return}let t=await this.getPages();if(this.aspect==="card"&&this.maxPages===2&&t.length===1){this.stage="viewfinder";return}let e=t.map((n,o)=>({id:n.id,pageNumber:o+1,label:n.label||`Page ${o+1}`,originalSrc:n.originalSrc,src:n.src,originalPreserved:!0,dimensions:{width:n.width||0,height:n.height||0},edits:n.edits||{crop:{x:0,y:0,w:1,h:1},rotate:0,filter:"none"},ocrText:n.ocrText||null,blob:n.blob||null})),i={mode:this.mode,aspect:this.aspect,docId:this.docId,pageCount:e.length,pages:e};this.mode==="single"&&(i.page=e[0]||null,this.maxPages>1&&(i.maxPages=this.maxPages)),this.dispatch(se.SCAN_COMPLETE,i)}get theme(){return typeof this.getAttribute=="function"&&this.getAttribute("theme")||"dark"}set theme(t){typeof this.setAttribute=="function"&&(t?this.setAttribute("theme",t):this.removeAttribute("theme"))}get mode(){return typeof this.getAttribute=="function"&&this.getAttribute("mode")||"document"}set mode(t){typeof this.setAttribute=="function"&&this.setAttribute("mode",t)}get aspect(){return typeof this.getAttribute=="function"&&this.getAttribute("aspect")||"auto"}set aspect(t){typeof this.setAttribute=="function"&&this.setAttribute("aspect",t)}get stage(){return this.#r}set stage(t){if(t==="viewfinder"||t==="workbench"){this.#r=t,typeof this.setAttribute=="function"&&this.getAttribute("stage")!==t&&this.setAttribute("stage",t);let e=this.shadowRoot;if(e){let i=e.getElementById("viewfinder-section"),n=e.getElementById("workbench-section");i&&n&&(i.style.display=t==="viewfinder"?"flex":"none",n.style.display=t==="workbench"?"flex":"none")}this.#w()}}get docId(){return typeof this.getAttribute=="function"?this.getAttribute("doc-id"):null}set docId(t){typeof this.setAttribute=="function"&&(t?this.setAttribute("doc-id",t):this.removeAttribute("doc-id"))}async rotateActivePage(){return this.#T()}async toggleActivePageBw(){return this.#k()}async toggleCropMode(){return this.#M()}async deleteActivePageWithUndo(){return this.#P()}get features(){return this.#t?this.#t.features:[]}set features(t){if(typeof this.setAttribute=="function"){let e=Array.isArray(t)?t.join(" "):String(t||"");this.setAttribute("features",e)}this.#t&&this.#t.setFeatures(t)}hasFeature(t){return this.#t?this.#t.hasFeature(t):!1}get ocrEnabled(){return this.#t?this.#t.ocr:!0}set ocrEnabled(t){let e=!!t;typeof this.setAttribute=="function"&&this.setAttribute("ocr",e?"true":"false"),this.#t&&(this.#t.ocr=e),this.#m()}get pdf(){return this.#t?this.#t.pdf:!0}set pdf(t){let e=!!t;typeof this.setAttribute=="function"&&this.setAttribute("pdf",e?"true":"false"),this.#t&&(this.#t.pdf=e),this.#m()}get exportFormats(){return this.#t?this.#t.exportFormats:[]}set exportFormats(t){if(typeof this.setAttribute=="function"){let e=Array.isArray(t)?t.join(","):String(t||"");this.setAttribute("export-formats",e)}this.#t&&(this.#t.exportFormats=t)}get ocrLanguages(){return this.#t?this.#t.ocrLanguages:[]}set ocrLanguages(t){if(typeof this.setAttribute=="function"){let e=Array.isArray(t)?t.join(","):String(t||"");this.setAttribute("ocr-languages",e)}this.#t&&(this.#t.ocrLanguages=t)}get maxPages(){return this.#t?this.#t.maxPages:0}set maxPages(t){typeof this.setAttribute=="function"&&this.setAttribute("max-pages",String(t)),this.#t&&(this.#t.maxPages=t)}get assetBase(){return this.#t?this.#t.assetBase:""}set assetBase(t){typeof this.setAttribute=="function"&&this.setAttribute("asset-base",String(t||"")),this.#t&&(this.#t.assetBase=t)}get licenseKey(){return this.#t?this.#t.licenseKey:""}set licenseKey(t){typeof this.setAttribute=="function"&&this.setAttribute("license-key",String(t||"")),this.#t&&(this.#t.licenseKey=t)}get storage(){return this.#e}set storage(t){this.#e=t,this.#t&&this.#t.setStorage(t)}get engine(){return this.#t}set engine(t){t instanceof en&&(this.#t=t)}dispatch(t,e={}){return sc(this,t,e)}async open(){this.#n=!0,typeof this.focus=="function"&&this.focus()}async close(){this.#n=!1,this.#A()}get isOpen(){return this.#n}async capture(){return new Promise(t=>{let e=document.createElement("input");e.type="file",e.accept="image/*",e.capture="environment",e.style.display="none",e.onchange=async()=>{try{if(e.files&&e.files.length>0){let i=await this.addFiles([e.files[0]]);t(i[0]||null)}else t(null)}catch(i){this.dispatch(se.ERROR,{code:"CAPTURE_FAILED",message:i.message,error:i}),t(null)}finally{e.remove()}},e.onerror=()=>{e.remove(),t(null)},document.body.appendChild(e),e.click()})}async addFiles(t){try{let e=await this.getPages(),i=null;if(e.length>0){if(this.mode==="single"&&this.maxPages<=1)await this.#t.clear(this.#h);else if(this.#c||this.maxPages>0&&e.length>=this.maxPages){let h=Math.min(this.#s,e.length-1),u=e[h];u&&(i=h,await this.#t.deletePage(this.#h,u.id))}}this.#c=!1;let n=await this.#t.addFiles(t,this.#h);for(let h=0;h<n.length;h++)this.dispatch(se.PAGE_ADDED,{page:n[h],pageNumber:h+1,docId:this.docId,source:"file"});let o=await this.getPages();if(i!==null&&n.length===1&&i<o.length-1){let h=o.map(g=>g.id),u=h.pop();u&&(h.splice(i,0,u),await this.#t.reorderPages(this.#h,h),o=await this.getPages())}return this.#a=o.length,n.length>0&&(this.#s=i!==null?Math.min(i,Math.max(0,o.length-1)):Math.max(0,o.length-1),this.mode==="single"&&(this.#r="workbench",typeof this.setAttribute=="function"&&this.getAttribute("stage")!=="workbench"&&this.setAttribute("stage","workbench"))),this.dispatch(se.PAGES_CHANGED,{pages:o,docId:this.docId}),this.mode==="single"&&n.length>0&&this.maxPages<=1&&this.dispatch(se.SCAN_COMPLETE,{mode:this.mode,aspect:this.aspect,docId:this.docId,pages:o,page:o[o.length-1]||null,pageCount:o.length}),await this.#w(),n}catch(e){throw this.dispatch(se.ERROR,{code:e.code||"ADD_FILES_FAILED",message:e.message,error:e}),e}}async getPages(){return this.#t.getPages(this.#h)}async clear(){this.#A(),this.#s=0,this.#a=0,this.#c=!1,this.#o=!1,await this.#t.clear(this.#h),this.dispatch(se.PAGES_CHANGED,{pages:[],docId:this.docId}),await this.#w()}async exportPdf(t={}){try{let e=await this.#t.exportPdf(this.#h,t);return this.dispatch(se.EXPORT_COMPLETE,{type:"pdf",format:"pdf",blob:e,docId:this.docId}),e}catch(e){throw this.dispatch(se.ERROR,{code:e.code||"EXPORT_FAILED",message:e.message,error:e}),e}}async exportZip(t={}){try{let e=await this.#t.exportZip(this.#h,t);return this.dispatch(se.EXPORT_COMPLETE,{type:"zip",format:"zip",blob:e,docId:this.docId}),e}catch(e){throw this.dispatch(se.ERROR,{code:e.code||"EXPORT_FAILED",message:e.message,error:e}),e}}async ocr(t=null,e={}){try{let i=await this.#t.runOcr(this.#h,t,e);return this.dispatch(se.OCR_COMPLETE,{text:i.text,pages:i.pagesResults,averageConfidence:i.averageConfidence,docId:this.docId,pageId:t}),i}catch(i){throw this.dispatch(se.ERROR,{code:i.code||"OCR_FAILED",message:i.message,error:i}),i}}async runOcr(t=null,e={}){return this.ocr(t,e)}async sync(t={}){try{return await this.#t.sync({onStateChange:i=>{i&&(i.step==="connected"||i.step==="syncing")&&this.dispatch(se.SYNC_CONNECTED,{peerId:i.peerId,mode:i.mode}),t.onStateChange&&t.onStateChange(i)}})}catch(e){throw this.dispatch(se.ERROR,{code:e.code||"SYNC_FAILED",message:e.message,error:e}),e}}};typeof customElements<"u"&&!customElements.get("copio-scanner")&&customElements.define("copio-scanner",ko);export{se as COPIO_EVENTS,Vr as CopioAddEditDialog,jr as CopioCarousel,Wr as CopioHeader,Br as CopioImages,qr as CopioLoader,Gr as CopioRow,ko as CopioScanner,ch as adoptScannerStyles,sc as dispatchCopioEvent,lh as getScannerStyleSheet,Co as scannerCss};
2610
+ /**!
2611
+ * Sortable 1.15.6
2612
+ * @author RubaXa <trash@rubaxa.org>
2613
+ * @author owenm <owen23355@gmail.com>
2614
+ * @license MIT
2615
+ */
2616
+ /**
2617
+ * @license
2618
+ * Copyright 2019 Google LLC
2619
+ * SPDX-License-Identifier: BSD-3-Clause
2620
+ */
2621
+ /**
2622
+ * @license
2623
+ * Copyright 2017 Google LLC
2624
+ * SPDX-License-Identifier: BSD-3-Clause
2625
+ */
2626
+ /**
2627
+ * @license
2628
+ * Copyright 2022 Google LLC
2629
+ * SPDX-License-Identifier: BSD-3-Clause
2630
+ */
2631
+ //# sourceMappingURL=scanner.js.map