agentroam-runtime-darwin-arm64 0.2.0-preview.18 → 0.2.0-preview.21

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/manifest.json +1 -1
  2. package/package.json +15 -5
  3. package/runtime/.next/BUILD_ID +1 -1
  4. package/runtime/.next/app-build-manifest.json +12 -5
  5. package/runtime/.next/app-path-routes-manifest.json +1 -1
  6. package/runtime/.next/build-manifest.json +3 -3
  7. package/runtime/.next/prerender-manifest.json +1 -1
  8. package/runtime/.next/required-server-files.json +1 -1
  9. package/runtime/.next/server/app/_not-found/page.js +1 -1
  10. package/runtime/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  11. package/runtime/.next/server/app/_not-found.html +1 -1
  12. package/runtime/.next/server/app/_not-found.rsc +1 -1
  13. package/runtime/.next/server/app/api/agent/abort/route.js +1 -1
  14. package/runtime/.next/server/app/api/agent/answer/route.js +1 -1
  15. package/runtime/.next/server/app/api/agent/harness/status/route.js +1 -1
  16. package/runtime/.next/server/app/api/agent/model/route.js +1 -1
  17. package/runtime/.next/server/app/api/agent/models/route.js +1 -1
  18. package/runtime/.next/server/app/api/agent/run/route.js +1 -1
  19. package/runtime/.next/server/app/api/agent/runtime-health/route.js +1 -1
  20. package/runtime/.next/server/app/api/agent/steer/route.js +1 -1
  21. package/runtime/.next/server/app/api/agent/stream/route.js +2 -2
  22. package/runtime/.next/server/app/api/agent-workspaces/[workspaceId]/sessions/route.js +1 -1
  23. package/runtime/.next/server/app/api/agent-workspaces/route.js +1 -1
  24. package/runtime/.next/server/app/api/auth/verify/route.js +1 -1
  25. package/runtime/.next/server/app/api/business/route.js +1 -1
  26. package/runtime/.next/server/app/api/mcp/connect/route.js +1 -1
  27. package/runtime/.next/server/app/api/mcp/disconnect/route.js +1 -1
  28. package/runtime/.next/server/app/api/mcp/servers/route.js +1 -1
  29. package/runtime/.next/server/app/api/memory/[key]/route.js +1 -1
  30. package/runtime/.next/server/app/api/memory/route.js +1 -1
  31. package/runtime/.next/server/app/api/plugins/load/route.js +1 -1
  32. package/runtime/.next/server/app/api/projects/[id]/route.js +1 -1
  33. package/runtime/.next/server/app/api/projects/check/route.js +1 -1
  34. package/runtime/.next/server/app/api/projects/directories/route.js +1 -1
  35. package/runtime/.next/server/app/api/projects/roots/route.js +1 -1
  36. package/runtime/.next/server/app/api/projects/route.js +1 -1
  37. package/runtime/.next/server/app/api/remote-tools/register/route.js +1 -1
  38. package/runtime/.next/server/app/api/sessions/[id]/changes/route.js +2 -2
  39. package/runtime/.next/server/app/api/sessions/[id]/fork/route.js +1 -1
  40. package/runtime/.next/server/app/api/sessions/[id]/goals/route.js +1 -1
  41. package/runtime/.next/server/app/api/sessions/[id]/handoff/route.js +1 -1
  42. package/runtime/.next/server/app/api/sessions/[id]/query-index/route.js +1 -1
  43. package/runtime/.next/server/app/api/sessions/[id]/release/route.js +1 -1
  44. package/runtime/.next/server/app/api/sessions/[id]/route.js +1 -1
  45. package/runtime/.next/server/app/api/sessions/[id]/tool-result/route.js +1 -1
  46. package/runtime/.next/server/app/api/sessions/route.js +1 -1
  47. package/runtime/.next/server/app/api/settings/route.js +1 -1
  48. package/runtime/.next/server/app/api/skills/route.js +1 -1
  49. package/runtime/.next/server/app/api/tools/route.js +1 -1
  50. package/runtime/.next/server/app/api/update/check/route.js +1 -1
  51. package/runtime/.next/server/app/api/update/install/route.js +1 -1
  52. package/runtime/.next/server/app/api/update/status/route.js +1 -1
  53. package/runtime/.next/server/app/api/web-auth/login/route.js +1 -1
  54. package/runtime/.next/server/app/api/web-auth/logout/route.js +1 -1
  55. package/runtime/.next/server/app/api/web-auth/revoke-all/route.js +1 -1
  56. package/runtime/.next/server/app/api/web-auth/setup/route.js +1 -1
  57. package/runtime/.next/server/app/api/web-auth/status/route.js +1 -1
  58. package/runtime/.next/server/app/api/web-console/bootstrap/route.js +1 -1
  59. package/runtime/.next/server/app/api/web-console/device-state/route.js +1 -1
  60. package/runtime/.next/server/app/api/web-console/history/route.js +1 -1
  61. package/runtime/.next/server/app/api/web-console/preferences/route.js +1 -1
  62. package/runtime/.next/server/app/web/page.js +2 -2
  63. package/runtime/.next/server/app/web/page_client-reference-manifest.js +1 -1
  64. package/runtime/.next/server/app/web.html +1 -1
  65. package/runtime/.next/server/app/web.rsc +5 -4
  66. package/runtime/.next/server/app-paths-manifest.json +21 -21
  67. package/runtime/.next/server/chunks/1322.js +1 -1
  68. package/runtime/.next/server/chunks/5303.js +1 -1
  69. package/runtime/.next/server/middleware-build-manifest.js +1 -1
  70. package/runtime/.next/server/pages/404.html +1 -1
  71. package/runtime/.next/server/pages/500.html +1 -1
  72. package/runtime/.next/server/pages-manifest.json +1 -1
  73. package/runtime/.next/server/server-reference-manifest.json +1 -1
  74. package/runtime/.next/static/chunks/184-af5bc14575fc8ebd.js +1 -0
  75. package/runtime/.next/static/chunks/app/web/error-9b5f82c29dc27335.js +1 -0
  76. package/runtime/.next/static/chunks/app/web/page-16895961b998f8df.js +1 -0
  77. package/runtime/.next/static/chunks/main-app-e3fd18ce9c4c0d03.js +1 -0
  78. package/runtime/lib/remote-control/remote-authorization.mjs +10 -1
  79. package/runtime/public/pwa/install.js +13 -22
  80. package/runtime/webapp/dist/assets/{App-Cw8L8wC7.js → App-Cso_5v1O.js} +88 -88
  81. package/runtime/webapp/dist/assets/{abnfDiagram-VCTEODGH-Bg_eN6Uv.js → abnfDiagram-VCTEODGH-BNxk5qEZ.js} +1 -1
  82. package/runtime/webapp/dist/assets/{arc-D7EZUTYf.js → arc-7MQbjMvc.js} +1 -1
  83. package/runtime/webapp/dist/assets/{architectureDiagram-5GKGNRK7-CojKcKSu.js → architectureDiagram-5GKGNRK7-Dhg4Rz1D.js} +1 -1
  84. package/runtime/webapp/dist/assets/{blockDiagram-I7D4REHJ-CWvJsOF0.js → blockDiagram-I7D4REHJ-DeJHr92S.js} +1 -1
  85. package/runtime/webapp/dist/assets/{c4Diagram-7LVT6UL2-nV-pwRr3.js → c4Diagram-7LVT6UL2-RA8xRbEK.js} +1 -1
  86. package/runtime/webapp/dist/assets/channel-AsHr5ZE0.js +1 -0
  87. package/runtime/webapp/dist/assets/{chunk-2Q5K7J3B-CQMSdvan.js → chunk-2Q5K7J3B-CzoEDy2v.js} +1 -1
  88. package/runtime/webapp/dist/assets/{chunk-5VM5RSS4-CyPwsJdN.js → chunk-5VM5RSS4-IasmnKPT.js} +1 -1
  89. package/runtime/webapp/dist/assets/{chunk-F27PBJKO-BueUBSMW.js → chunk-F27PBJKO-ClQmWB2a.js} +1 -1
  90. package/runtime/webapp/dist/assets/{chunk-IMKFNOWR-C2nlrSd6.js → chunk-IMKFNOWR-BeWBx5Wn.js} +1 -1
  91. package/runtime/webapp/dist/assets/{chunk-JWPE2WC7-DoizkjHx.js → chunk-JWPE2WC7-TcEEZ4Dp.js} +1 -1
  92. package/runtime/webapp/dist/assets/{chunk-POPQ4Y6H-wV3SsdPC.js → chunk-POPQ4Y6H-DuWXzzSb.js} +1 -1
  93. package/runtime/webapp/dist/assets/{chunk-SVP7TREG-BTKM6mUi.js → chunk-SVP7TREG-D2X9Pa1W.js} +1 -1
  94. package/runtime/webapp/dist/assets/{chunk-TICWLB2K-BVyu_n-l.js → chunk-TICWLB2K-D_-XYQ_R.js} +1 -1
  95. package/runtime/webapp/dist/assets/{chunk-XXDRQBXY-BxBcrq_G.js → chunk-XXDRQBXY-B2mHmyk9.js} +1 -1
  96. package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-BZj1pbnq.js +1 -0
  97. package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-BZj1pbnq.js +1 -0
  98. package/runtime/webapp/dist/assets/{cose-bilkent-JH36ORCC-CmSWdE8s.js → cose-bilkent-JH36ORCC-OmMALi3i.js} +1 -1
  99. package/runtime/webapp/dist/assets/{cynefin-OW5HDTMX-4UYNDbpH.js → cynefin-OW5HDTMX-BVhxjnGZ.js} +1 -1
  100. package/runtime/webapp/dist/assets/{cynefinDiagram-5FMLGOSQ-DWPfEH4m.js → cynefinDiagram-5FMLGOSQ-8EafeZWa.js} +1 -1
  101. package/runtime/webapp/dist/assets/{dagre-GXQ25YYZ-BnOO9dS8.js → dagre-GXQ25YYZ-BlMjveyN.js} +1 -1
  102. package/runtime/webapp/dist/assets/{diagram-S7CK7UJ4-IZGwV0zi.js → diagram-S7CK7UJ4-BTgDeYAz.js} +1 -1
  103. package/runtime/webapp/dist/assets/{diagram-UQ7AKVKN-wjm8SGpf.js → diagram-UQ7AKVKN-9m-QUpEs.js} +1 -1
  104. package/runtime/webapp/dist/assets/{diagram-VSXAHHWV-A736veTs.js → diagram-VSXAHHWV-BYWenf8W.js} +1 -1
  105. package/runtime/webapp/dist/assets/{diagram-VX7I27RA-ClwQvx5m.js → diagram-VX7I27RA-DQ-PRQyX.js} +1 -1
  106. package/runtime/webapp/dist/assets/{diagram-Z3DM3KII-D0w23tWA.js → diagram-Z3DM3KII-BFCpyvaL.js} +1 -1
  107. package/runtime/webapp/dist/assets/{ebnfDiagram-PWID7BFC-C8N7udLX.js → ebnfDiagram-PWID7BFC-Ds9oV_wz.js} +1 -1
  108. package/runtime/webapp/dist/assets/{erDiagram-RLTQ6QDP-BC_WrTjy.js → erDiagram-RLTQ6QDP-ncaaStop.js} +1 -1
  109. package/runtime/webapp/dist/assets/{flowDiagram-HODETNUW-DO2Qz6ib.js → flowDiagram-HODETNUW-wL7U3M2L.js} +1 -1
  110. package/runtime/webapp/dist/assets/{ganttDiagram-EL5Y4UJY-B7HvpfYu.js → ganttDiagram-EL5Y4UJY-CVZIk8qz.js} +1 -1
  111. package/runtime/webapp/dist/assets/{gitGraphDiagram-WWUBYQGX-BICChxf4.js → gitGraphDiagram-WWUBYQGX-CGjtUEFY.js} +1 -1
  112. package/runtime/webapp/dist/assets/{index-L45sK1jq.js → index-CixxJ3A7.js} +10 -10
  113. package/runtime/webapp/dist/assets/{infoDiagram-27XIBGKW-8l5101Lb.js → infoDiagram-27XIBGKW-BqTzY6Bv.js} +1 -1
  114. package/runtime/webapp/dist/assets/{ishikawaDiagram-5VMMS53U-D3lFwKs2.js → ishikawaDiagram-5VMMS53U-9AARy1zU.js} +1 -1
  115. package/runtime/webapp/dist/assets/{journeyDiagram-3NMN7TZE-BTT5ioCW.js → journeyDiagram-3NMN7TZE-D3w-levY.js} +1 -1
  116. package/runtime/webapp/dist/assets/{kanban-definition-UXKFOSKX-BX0zN23Y.js → kanban-definition-UXKFOSKX-CNvdBbcg.js} +1 -1
  117. package/runtime/webapp/dist/assets/{layout-skaxD18E.js → layout-l0aDluv6.js} +1 -1
  118. package/runtime/webapp/dist/assets/{linear-AqiGk0aW.js → linear-BlLgYv8s.js} +1 -1
  119. package/runtime/webapp/dist/assets/{mermaid.core-ObuekRdQ.js → mermaid.core-UNYsT27K.js} +5 -5
  120. package/runtime/webapp/dist/assets/{mindmap-definition-YA3MSWOX-BeCFHs0Q.js → mindmap-definition-YA3MSWOX-BiVsBQL9.js} +1 -1
  121. package/runtime/webapp/dist/assets/{pegDiagram-XKGWAZYB-BdcgW_1f.js → pegDiagram-XKGWAZYB-kr19ZOFB.js} +1 -1
  122. package/runtime/webapp/dist/assets/{pieDiagram-E7YTZNPT-DB5hvWc4.js → pieDiagram-E7YTZNPT-BKWCGLlM.js} +1 -1
  123. package/runtime/webapp/dist/assets/{quadrantDiagram-AXDQQJYC-Uoy-iP5j.js → quadrantDiagram-AXDQQJYC-B1oUT2Jo.js} +1 -1
  124. package/runtime/webapp/dist/assets/{railroadDiagram-O6MQD6OU-B-NE_ork.js → railroadDiagram-O6MQD6OU-HSe2vXxQ.js} +1 -1
  125. package/runtime/webapp/dist/assets/{requirementDiagram-BXWQKSXE-GNATcJFG.js → requirementDiagram-BXWQKSXE-Cy8adj_C.js} +1 -1
  126. package/runtime/webapp/dist/assets/{sankeyDiagram-P5KCCOFB-CGP4i5_d.js → sankeyDiagram-P5KCCOFB-tnBEmP5l.js} +1 -1
  127. package/runtime/webapp/dist/assets/{sequenceDiagram-WJ2MYXX4-CPaA2NKl.js → sequenceDiagram-WJ2MYXX4-DvOTKmyz.js} +1 -1
  128. package/runtime/webapp/dist/assets/{sizeCapture-INFHLROL-Dq6l7UUp.js → sizeCapture-INFHLROL-Da7A6hqr.js} +1 -1
  129. package/runtime/webapp/dist/assets/{stateDiagram-D77RDMKH-DdYExWyT.js → stateDiagram-D77RDMKH-BU17k_M-.js} +1 -1
  130. package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-BROH63Ny.js +1 -0
  131. package/runtime/webapp/dist/assets/{swimlanes-42K2YHIH-B1INdUc5.js → swimlanes-42K2YHIH-DZZPRxnW.js} +1 -1
  132. package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-B4lr9wuD.js +8 -0
  133. package/runtime/webapp/dist/assets/{timeline-definition-24CTP7MA-BSbIV3mK.js → timeline-definition-24CTP7MA-26Xh93Et.js} +1 -1
  134. package/runtime/webapp/dist/assets/{vennDiagram-4TSXK5OY-TUjGvs6U.js → vennDiagram-4TSXK5OY-Q4-BkJH1.js} +1 -1
  135. package/runtime/webapp/dist/assets/{wardleyDiagram-VM6X3IG4-uLCXlSnY.js → wardleyDiagram-VM6X3IG4-DlUP-PlT.js} +1 -1
  136. package/runtime/webapp/dist/assets/{web-D1VZM26_.js → web-DWyw2SAG.js} +1 -1
  137. package/runtime/webapp/dist/assets/{web-Bco3fxtw.js → web-ueoOhAeL.js} +1 -1
  138. package/runtime/webapp/dist/assets/{xychartDiagram-S5SC5T6Z-DSMuNEjI.js → xychartDiagram-S5SC5T6Z-BQZRjKtR.js} +1 -1
  139. package/runtime/webapp/dist/index.html +1 -1
  140. package/runtime/.next/static/chunks/352-036cf2a50d494a80.js +0 -1
  141. package/runtime/.next/static/chunks/app/web/page-2a6915891068e1e9.js +0 -1
  142. package/runtime/.next/static/chunks/main-app-850b97b5519f3c0b.js +0 -1
  143. package/runtime/webapp/dist/assets/channel-LcjIawtf.js +0 -1
  144. package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-BZN1BdvJ.js +0 -1
  145. package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-BZN1BdvJ.js +0 -1
  146. package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-QqTtFkaB.js +0 -1
  147. package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-IxMgdHeE.js +0 -8
  148. /package/runtime/.next/static/{g_vhm-FWXnuaGRgliyUYE → 6OR2fRy79-A-DrqiN3FNa}/_buildManifest.js +0 -0
  149. /package/runtime/.next/static/{g_vhm-FWXnuaGRgliyUYE → 6OR2fRy79-A-DrqiN3FNa}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./App-Cw8L8wC7.js","./App-CMOzoP5A.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./App-Cso_5v1O.js","./App-CMOzoP5A.css"])))=>i.map(i=>d[i]);
2
2
  (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))l(c);new MutationObserver(c=>{for(const f of c)if(f.type==="childList")for(const p of f.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&l(p)}).observe(document,{childList:!0,subtree:!0});function i(c){const f={};return c.integrity&&(f.integrity=c.integrity),c.referrerPolicy&&(f.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?f.credentials="include":c.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function l(c){if(c.ep)return;c.ep=!0;const f=i(c);fetch(c.href,f)}})();const og="modulepreload",ag=function(e,t){return new URL(e,t).href},p1={},qu=function(t,i,l){let c=Promise.resolve();if(i&&i.length>0){const p=document.getElementsByTagName("link"),w=document.querySelector("meta[property=csp-nonce]"),C=(w==null?void 0:w.nonce)||(w==null?void 0:w.getAttribute("nonce"));c=Promise.allSettled(i.map(m=>{if(m=ag(m,l),m in p1)return;p1[m]=!0;const _=m.endsWith(".css"),v=_?'[rel="stylesheet"]':"";if(l)for(let M=p.length-1;M>=0;M--){const P=p[M];if(P.href===m&&(!_||P.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${m}"]${v}`))return;const R=document.createElement("link");if(R.rel=_?"stylesheet":og,_||(R.as="script"),R.crossOrigin="",R.href=m,C&&R.setAttribute("nonce",C),document.head.appendChild(R),_)return new Promise((M,P)=>{R.addEventListener("load",M),R.addEventListener("error",()=>P(Error(`Unable to preload CSS for ${m}`)))})}))}function f(p){const w=new Event("vite:preloadError",{cancelable:!0});if(w.payload=p,window.dispatchEvent(w),!w.defaultPrevented)throw p}return c.then(p=>{for(const w of p||[])w.status==="rejected"&&f(w.reason);return t().catch(f)})};var ls=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function J0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ef={exports:{}},Ia={},tf={exports:{}},Ae={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -15,7 +15,7 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./App-Cw8L8wC7.js","./
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var Sg=Ct,Ig=Symbol.for("react.element"),_g=Symbol.for("react.fragment"),Tg=Object.prototype.hasOwnProperty,Ng=Sg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Rg={key:!0,ref:!0,__self:!0,__source:!0};function ff(e,t,i){var l,c={},f=null,p=null;i!==void 0&&(f=""+i),t.key!==void 0&&(f=""+t.key),t.ref!==void 0&&(p=t.ref);for(l in t)Tg.call(t,l)&&!Rg.hasOwnProperty(l)&&(c[l]=t[l]);if(e&&e.defaultProps)for(l in t=e.defaultProps,t)c[l]===void 0&&(c[l]=t[l]);return{$$typeof:Ig,type:e,key:f,ref:p,props:c,_owner:Ng.current}}Ia.Fragment=_g;Ia.jsx=ff;Ia.jsxs=ff;ef.exports=Ia;var ue=ef.exports;const bg=Ct.createContext(null);function Og(){const[e,t]=Ct.useState(null),[i,l]=Ct.useState(!1),[c,f]=Ct.useState(!1),[p,w]=Ct.useState(""),C=["127.0.0.1","localhost","[::1]"].includes(location.hostname),m=!/Android|iPhone|iPad|iPod/i.test(navigator.userAgent);if(Ct.useEffect(()=>{if(!m||!C)return;let v=!0;const R=async()=>{try{const P=await fetch("/api/remote-authorization",{credentials:"same-origin",cache:"no-store"});if(!P.ok)return;const B=await P.json();v&&t(B)}catch{}};R();const M=setInterval(R,2e3);return()=>{v=!1,clearInterval(M)}},[m,C]),!m)return null;if(!C)return ue.jsxs("div",{style:{position:"relative",marginLeft:12},children:[ue.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>l(!i),"aria-expanded":i,"aria-label":"远程授权",title:"远程授权",children:ue.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[ue.jsx("path",{d:"M12 22s8-4 8-11V5l-8-3-8 3v6c0 7 8 11 8 11Z"}),ue.jsx("path",{d:"m9 12 2 2 4-4"})]})}),i&&ue.jsxs("section",{"aria-label":"远程授权设置",style:{position:"absolute",top:40,left:0,width:"min(370px, 70vw)",zIndex:30,padding:18,borderRadius:12,background:"var(--bg-surface, white)",border:"1px solid var(--border-default)",boxShadow:"0 10px 40px #0003",fontSize:13},children:[ue.jsx("strong",{children:"远程授权"}),ue.jsx("p",{style:{lineHeight:1.6},children:"请在运行 CLI 的电脑上打开本机页面,完成配对后设置屏幕录制和辅助功能权限。"}),ue.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",style:{padding:"10px 16px",background:"var(--accent, #5264ff)",color:"#fff",borderRadius:8},onClick:()=>window.open(`http://127.0.0.1:${location.port||"3000"}/web`,"_blank","noopener,noreferrer"),children:"打开本机授权页面"}),ue.jsx("p",{style:{lineHeight:1.6},children:"如果你正在另一台电脑上查看,请到运行 CLI 的电脑操作。授权完成后,可回到当前页面查看画面。"})]})]});if(!(e!=null&&e.local))return null;const _=async(v,R)=>{f(!0),w("");try{const M=await fetch("/api/remote-authorization",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({action:v,permission:R})}),P=await M.json();if(!M.ok)throw new Error(P.error||"操作失败");t(P)}catch(M){w(M instanceof Error?M.message:"操作失败")}finally{f(!1)}};return ue.jsxs("div",{style:{position:"relative",marginLeft:12},children:[ue.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>l(!i),"aria-expanded":i,"aria-label":"远程授权",title:"远程授权",children:ue.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[ue.jsx("path",{d:"M12 22s8-4 8-11V5l-8-3-8 3v6c0 7 8 11 8 11Z"}),ue.jsx("path",{d:"m9 12 2 2 4-4"})]})}),i&&ue.jsxs("section",{"aria-label":"远程授权设置",style:{position:"absolute",top:40,left:0,width:"min(370px, 70vw)",zIndex:30,padding:18,borderRadius:12,background:"var(--bg-surface, white)",color:"var(--text-primary)",border:"1px solid var(--border-default)",boxShadow:"0 10px 40px #0003",fontSize:13},children:[ue.jsx("strong",{children:"远程授权"}),ue.jsx("p",{style:{lineHeight:1.6,margin:"10px 0"},children:"在系统设置中允许「AgentRoam Remote Desktop」。屏幕录制用于手机查看,辅助功能用于鼠标键盘控制。"}),e.supported?e.installed?ue.jsxs(ue.Fragment,{children:[["screen","accessibility"].map(v=>ue.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,margin:"12px 0"},children:[ue.jsxs("span",{children:[v==="screen"?"屏幕录制":"辅助功能",":",e[v]?"已授权":"待授权"]}),ue.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",disabled:c,onClick:()=>void _("authorize",v),children:"去授权"})]},v)),ue.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:[ue.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",disabled:c,onClick:()=>void _(e.enabled?"disable":"enable"),children:e.enabled?"停止共享":"开启共享"}),ue.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",disabled:c,onClick:()=>void _("recheck"),children:"重新检测"}),ue.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",disabled:c,onClick:()=>void _("restart"),children:"重启授权组件"})]}),ue.jsx("p",{role:"status",style:{marginTop:12},children:e.online?"共享已开启,已配对手机可在直播列表选择本机桌面。":e.enabled?"等待系统授权或首帧画面…":"尚未开启共享。"}),ue.jsx("p",{style:{fontSize:12,lineHeight:1.6},children:"授权后会自动继续。系统要求重新打开应用时,点击“重启授权组件”。"})]}):ue.jsx("p",{children:"当前 CLI 未包含远程授权组件,请升级 CLI。"}):ue.jsx("p",{children:"目前支持 macOS 14 及以上的 Apple Silicon 电脑。"}),(p||e.error)&&ue.jsx("p",{role:"alert",style:{color:"var(--danger, #c33)"},children:p||e.error})]})]})}var df={exports:{}},ln={},hf={exports:{}},gf={};/**
18
+ */var Sg=Ct,Ig=Symbol.for("react.element"),_g=Symbol.for("react.fragment"),Tg=Object.prototype.hasOwnProperty,Ng=Sg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Rg={key:!0,ref:!0,__self:!0,__source:!0};function ff(e,t,i){var l,c={},f=null,p=null;i!==void 0&&(f=""+i),t.key!==void 0&&(f=""+t.key),t.ref!==void 0&&(p=t.ref);for(l in t)Tg.call(t,l)&&!Rg.hasOwnProperty(l)&&(c[l]=t[l]);if(e&&e.defaultProps)for(l in t=e.defaultProps,t)c[l]===void 0&&(c[l]=t[l]);return{$$typeof:Ig,type:e,key:f,ref:p,props:c,_owner:Ng.current}}Ia.Fragment=_g;Ia.jsx=ff;Ia.jsxs=ff;ef.exports=Ia;var ae=ef.exports;const bg=Ct.createContext(null);function Og(){const[e,t]=Ct.useState(null),[i,l]=Ct.useState(!1),[c,f]=Ct.useState(!1),[p,w]=Ct.useState(""),C=["127.0.0.1","localhost","[::1]"].includes(location.hostname),m=!/Android|iPhone|iPad|iPod/i.test(navigator.userAgent);if(Ct.useEffect(()=>{let v=!0;const R=async()=>{try{const P=await fetch(m&&C?"/api/remote-authorization":"/api/remote-authorization/status",{credentials:"same-origin",cache:"no-store"});if(!P.ok)return;const B=await P.json();v&&t(B)}catch{}};R();const M=setInterval(R,2e3);return()=>{v=!1,clearInterval(M)}},[m,C]),!m){if(!e||e.online&&e.accessibility)return null;const v=e.supported?e.installed?e.enabled?!e.screen||!e.accessibility?"电脑的远程桌面授权尚未完成。":"电脑桌面正在连接,请稍候。":"电脑尚未开启桌面共享,请在电脑上完成授权并开启共享。":"电脑缺少远程桌面组件,请在电脑上升级 CLI。":"这台电脑暂不支持远程桌面。";return ae.jsxs("div",{className:"remote-desktop-guidance",role:"status",style:{maxWidth:"100%",fontSize:12,lineHeight:1.6,overflowWrap:"anywhere"},children:[ae.jsx("strong",{children:v}),e.supported&&e.installed&&(!e.enabled||!e.screen||!e.accessibility)&&ae.jsxs("details",{children:[ae.jsx("summary",{children:"如何在电脑上授权"}),ae.jsx("p",{children:"在运行 CLI 的电脑上,打开安装提示中的“远程桌面授权地址”,完成配对后点击“远程授权”(盾牌图标)。"}),ae.jsx("p",{children:"在系统设置中为 AgentRoam Remote Desktop 授予“屏幕录制”和“辅助功能”权限,然后点击“开启共享”。完成后此处会自动更新。"})]})]})}if(!C)return ae.jsxs("div",{style:{position:"relative",marginLeft:12},children:[ae.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>l(!i),"aria-expanded":i,"aria-label":"远程授权",title:"远程授权",children:ae.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[ae.jsx("path",{d:"M12 22s8-4 8-11V5l-8-3-8 3v6c0 7 8 11 8 11Z"}),ae.jsx("path",{d:"m9 12 2 2 4-4"})]})}),i&&ae.jsxs("section",{"aria-label":"远程授权设置",style:{position:"absolute",top:40,left:0,width:"min(370px, 70vw)",zIndex:30,padding:18,borderRadius:12,background:"var(--bg-surface, white)",border:"1px solid var(--border-default)",boxShadow:"0 10px 40px #0003",fontSize:13},children:[ae.jsx("strong",{children:"远程授权"}),ae.jsx("p",{style:{lineHeight:1.6},children:"请在运行 CLI 的电脑上打开本机页面,完成配对后设置屏幕录制和辅助功能权限。"}),ae.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",style:{padding:"10px 16px",background:"var(--accent, #5264ff)",color:"#fff",borderRadius:8},onClick:()=>window.open(`http://127.0.0.1:${location.port||"3000"}/web`,"_blank","noopener,noreferrer"),children:"打开本机授权页面"}),ae.jsx("p",{style:{lineHeight:1.6},children:"如果你正在另一台电脑上查看,请到运行 CLI 的电脑操作。授权完成后,可回到当前页面查看画面。"})]})]});if(!(e!=null&&e.local))return null;const _=async(v,R)=>{f(!0),w("");try{const M=await fetch("/api/remote-authorization",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({action:v,permission:R})}),P=await M.json();if(!M.ok)throw new Error(P.error||"操作失败");t(P)}catch(M){w(M instanceof Error?M.message:"操作失败")}finally{f(!1)}};return ae.jsxs("div",{style:{position:"relative",marginLeft:12},children:[ae.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>l(!i),"aria-expanded":i,"aria-label":"远程授权",title:"远程授权",children:ae.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[ae.jsx("path",{d:"M12 22s8-4 8-11V5l-8-3-8 3v6c0 7 8 11 8 11Z"}),ae.jsx("path",{d:"m9 12 2 2 4-4"})]})}),i&&ae.jsxs("section",{"aria-label":"远程授权设置",style:{position:"absolute",top:40,left:0,width:"min(370px, 70vw)",zIndex:30,padding:18,borderRadius:12,background:"var(--bg-surface, white)",color:"var(--text-primary)",border:"1px solid var(--border-default)",boxShadow:"0 10px 40px #0003",fontSize:13},children:[ae.jsx("strong",{children:"远程授权"}),ae.jsx("p",{style:{lineHeight:1.6,margin:"10px 0"},children:"在系统设置中允许「AgentRoam Remote Desktop」。屏幕录制用于手机查看,辅助功能用于鼠标键盘控制。"}),e.supported?e.installed?ae.jsxs(ae.Fragment,{children:[["screen","accessibility"].map(v=>ae.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,margin:"12px 0"},children:[ae.jsxs("span",{children:[v==="screen"?"屏幕录制":"辅助功能",":",e[v]?"已授权":"待授权"]}),ae.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",disabled:c,onClick:()=>void _("authorize",v),children:"去授权"})]},v)),ae.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:[ae.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",disabled:c,onClick:()=>void _(e.enabled?"disable":"enable"),children:e.enabled?"停止共享":"开启共享"}),ae.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",disabled:c,onClick:()=>void _("recheck"),children:"重新检测"}),ae.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",disabled:c,onClick:()=>void _("restart"),children:"重启授权组件"})]}),ae.jsx("p",{role:"status",style:{marginTop:12},children:e.online?"共享已开启,已配对手机可在直播列表选择本机桌面。":e.enabled?"等待系统授权或首帧画面…":"尚未开启共享。"}),ae.jsx("p",{style:{fontSize:12,lineHeight:1.6},children:"授权后会自动继续。系统要求重新打开应用时,点击“重启授权组件”。"})]}):ae.jsx("p",{children:"当前 CLI 未包含远程授权组件,请升级 CLI。"}):ae.jsx("p",{children:"目前支持 macOS 14 及以上的 Apple Silicon 电脑。"}),(p||e.error)&&ae.jsx("p",{role:"alert",style:{color:"var(--danger, #c33)"},children:p||e.error})]})]})}var df={exports:{}},ln={},hf={exports:{}},gf={};/**
19
19
  * @license React
20
20
  * scheduler.production.min.js
21
21
  *
@@ -23,7 +23,7 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./App-Cw8L8wC7.js","./
23
23
  *
24
24
  * This source code is licensed under the MIT license found in the
25
25
  * LICENSE file in the root directory of this source tree.
26
- */(function(e){function t(ee,de){var pe=ee.length;ee.push(de);e:for(;0<pe;){var Ge=pe-1>>>1,Ie=ee[Ge];if(0<c(Ie,de))ee[Ge]=de,ee[pe]=Ie,pe=Ge;else break e}}function i(ee){return ee.length===0?null:ee[0]}function l(ee){if(ee.length===0)return null;var de=ee[0],pe=ee.pop();if(pe!==de){ee[0]=pe;e:for(var Ge=0,Ie=ee.length,cn=Ie>>>1;Ge<cn;){var Ke=2*(Ge+1)-1,kr=ee[Ke],ae=Ke+1,ir=ee[ae];if(0>c(kr,pe))ae<Ie&&0>c(ir,kr)?(ee[Ge]=ir,ee[ae]=pe,Ge=ae):(ee[Ge]=kr,ee[Ke]=pe,Ge=Ke);else if(ae<Ie&&0>c(ir,pe))ee[Ge]=ir,ee[ae]=pe,Ge=ae;else break e}}return de}function c(ee,de){var pe=ee.sortIndex-de.sortIndex;return pe!==0?pe:ee.id-de.id}if(typeof performance=="object"&&typeof performance.now=="function"){var f=performance;e.unstable_now=function(){return f.now()}}else{var p=Date,w=p.now();e.unstable_now=function(){return p.now()-w}}var C=[],m=[],_=1,v=null,R=3,M=!1,P=!1,B=!1,K=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(ee){for(var de=i(m);de!==null;){if(de.callback===null)l(m);else if(de.startTime<=ee)l(m),de.sortIndex=de.expirationTime,t(C,de);else break;de=i(m)}}function G(ee){if(B=!1,N(ee),!P)if(i(C)!==null)P=!0,tt(H);else{var de=i(m);de!==null&&xe(G,de.startTime-ee)}}function H(ee,de){P=!1,B&&(B=!1,O(X),X=-1),M=!0;var pe=R;try{for(N(de),v=i(C);v!==null&&(!(v.expirationTime>de)||ee&&!Ee());){var Ge=v.callback;if(typeof Ge=="function"){v.callback=null,R=v.priorityLevel;var Ie=Ge(v.expirationTime<=de);de=e.unstable_now(),typeof Ie=="function"?v.callback=Ie:v===i(C)&&l(C),N(de)}else l(C);v=i(C)}if(v!==null)var cn=!0;else{var Ke=i(m);Ke!==null&&xe(G,Ke.startTime-de),cn=!1}return cn}finally{v=null,R=pe,M=!1}}var U=!1,k=null,X=-1,V=5,se=-1;function Ee(){return!(e.unstable_now()-se<V)}function ie(){if(k!==null){var ee=e.unstable_now();se=ee;var de=!0;try{de=k(!0,ee)}finally{de?ge():(U=!1,k=null)}}else U=!1}var ge;if(typeof T=="function")ge=function(){T(ie)};else if(typeof MessageChannel<"u"){var _e=new MessageChannel,j=_e.port2;_e.port1.onmessage=ie,ge=function(){j.postMessage(null)}}else ge=function(){K(ie,0)};function tt(ee){k=ee,U||(U=!0,ge())}function xe(ee,de){X=K(function(){ee(e.unstable_now())},de)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(ee){ee.callback=null},e.unstable_continueExecution=function(){P||M||(P=!0,tt(H))},e.unstable_forceFrameRate=function(ee){0>ee||125<ee?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V=0<ee?Math.floor(1e3/ee):5},e.unstable_getCurrentPriorityLevel=function(){return R},e.unstable_getFirstCallbackNode=function(){return i(C)},e.unstable_next=function(ee){switch(R){case 1:case 2:case 3:var de=3;break;default:de=R}var pe=R;R=de;try{return ee()}finally{R=pe}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(ee,de){switch(ee){case 1:case 2:case 3:case 4:case 5:break;default:ee=3}var pe=R;R=ee;try{return de()}finally{R=pe}},e.unstable_scheduleCallback=function(ee,de,pe){var Ge=e.unstable_now();switch(typeof pe=="object"&&pe!==null?(pe=pe.delay,pe=typeof pe=="number"&&0<pe?Ge+pe:Ge):pe=Ge,ee){case 1:var Ie=-1;break;case 2:Ie=250;break;case 5:Ie=1073741823;break;case 4:Ie=1e4;break;default:Ie=5e3}return Ie=pe+Ie,ee={id:_++,callback:de,priorityLevel:ee,startTime:pe,expirationTime:Ie,sortIndex:-1},pe>Ge?(ee.sortIndex=pe,t(m,ee),i(C)===null&&ee===i(m)&&(B?(O(X),X=-1):B=!0,xe(G,pe-Ge))):(ee.sortIndex=Ie,t(C,ee),P||M||(P=!0,tt(H))),ee},e.unstable_shouldYield=Ee,e.unstable_wrapCallback=function(ee){var de=R;return function(){var pe=R;R=de;try{return ee.apply(this,arguments)}finally{R=pe}}}})(gf);hf.exports=gf;var Dg=hf.exports;/**
26
+ */(function(e){function t(ee,de){var pe=ee.length;ee.push(de);e:for(;0<pe;){var Ge=pe-1>>>1,Ie=ee[Ge];if(0<c(Ie,de))ee[Ge]=de,ee[pe]=Ie,pe=Ge;else break e}}function i(ee){return ee.length===0?null:ee[0]}function l(ee){if(ee.length===0)return null;var de=ee[0],pe=ee.pop();if(pe!==de){ee[0]=pe;e:for(var Ge=0,Ie=ee.length,cn=Ie>>>1;Ge<cn;){var Ke=2*(Ge+1)-1,kr=ee[Ke],le=Ke+1,ir=ee[le];if(0>c(kr,pe))le<Ie&&0>c(ir,kr)?(ee[Ge]=ir,ee[le]=pe,Ge=le):(ee[Ge]=kr,ee[Ke]=pe,Ge=Ke);else if(le<Ie&&0>c(ir,pe))ee[Ge]=ir,ee[le]=pe,Ge=le;else break e}}return de}function c(ee,de){var pe=ee.sortIndex-de.sortIndex;return pe!==0?pe:ee.id-de.id}if(typeof performance=="object"&&typeof performance.now=="function"){var f=performance;e.unstable_now=function(){return f.now()}}else{var p=Date,w=p.now();e.unstable_now=function(){return p.now()-w}}var C=[],m=[],_=1,v=null,R=3,M=!1,P=!1,B=!1,K=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(ee){for(var de=i(m);de!==null;){if(de.callback===null)l(m);else if(de.startTime<=ee)l(m),de.sortIndex=de.expirationTime,t(C,de);else break;de=i(m)}}function G(ee){if(B=!1,N(ee),!P)if(i(C)!==null)P=!0,tt(H);else{var de=i(m);de!==null&&xe(G,de.startTime-ee)}}function H(ee,de){P=!1,B&&(B=!1,O(X),X=-1),M=!0;var pe=R;try{for(N(de),v=i(C);v!==null&&(!(v.expirationTime>de)||ee&&!Ee());){var Ge=v.callback;if(typeof Ge=="function"){v.callback=null,R=v.priorityLevel;var Ie=Ge(v.expirationTime<=de);de=e.unstable_now(),typeof Ie=="function"?v.callback=Ie:v===i(C)&&l(C),N(de)}else l(C);v=i(C)}if(v!==null)var cn=!0;else{var Ke=i(m);Ke!==null&&xe(G,Ke.startTime-de),cn=!1}return cn}finally{v=null,R=pe,M=!1}}var U=!1,k=null,X=-1,V=5,se=-1;function Ee(){return!(e.unstable_now()-se<V)}function ie(){if(k!==null){var ee=e.unstable_now();se=ee;var de=!0;try{de=k(!0,ee)}finally{de?ge():(U=!1,k=null)}}else U=!1}var ge;if(typeof T=="function")ge=function(){T(ie)};else if(typeof MessageChannel<"u"){var _e=new MessageChannel,j=_e.port2;_e.port1.onmessage=ie,ge=function(){j.postMessage(null)}}else ge=function(){K(ie,0)};function tt(ee){k=ee,U||(U=!0,ge())}function xe(ee,de){X=K(function(){ee(e.unstable_now())},de)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(ee){ee.callback=null},e.unstable_continueExecution=function(){P||M||(P=!0,tt(H))},e.unstable_forceFrameRate=function(ee){0>ee||125<ee?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V=0<ee?Math.floor(1e3/ee):5},e.unstable_getCurrentPriorityLevel=function(){return R},e.unstable_getFirstCallbackNode=function(){return i(C)},e.unstable_next=function(ee){switch(R){case 1:case 2:case 3:var de=3;break;default:de=R}var pe=R;R=de;try{return ee()}finally{R=pe}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(ee,de){switch(ee){case 1:case 2:case 3:case 4:case 5:break;default:ee=3}var pe=R;R=ee;try{return de()}finally{R=pe}},e.unstable_scheduleCallback=function(ee,de,pe){var Ge=e.unstable_now();switch(typeof pe=="object"&&pe!==null?(pe=pe.delay,pe=typeof pe=="number"&&0<pe?Ge+pe:Ge):pe=Ge,ee){case 1:var Ie=-1;break;case 2:Ie=250;break;case 5:Ie=1073741823;break;case 4:Ie=1e4;break;default:Ie=5e3}return Ie=pe+Ie,ee={id:_++,callback:de,priorityLevel:ee,startTime:pe,expirationTime:Ie,sortIndex:-1},pe>Ge?(ee.sortIndex=pe,t(m,ee),i(C)===null&&ee===i(m)&&(B?(O(X),X=-1):B=!0,xe(G,pe-Ge))):(ee.sortIndex=Ie,t(C,ee),P||M||(P=!0,tt(H))),ee},e.unstable_shouldYield=Ee,e.unstable_wrapCallback=function(ee){var de=R;return function(){var pe=R;R=de;try{return ee.apply(this,arguments)}finally{R=pe}}}})(gf);hf.exports=gf;var Dg=hf.exports;/**
27
27
  * @license React
28
28
  * react-dom.production.min.js
29
29
  *
@@ -56,14 +56,14 @@ Error generating stack: `+f.message+`
56
56
  *
57
57
  * This source code is licensed under the MIT license found in the
58
58
  * LICENSE file in the root directory of this source tree.
59
- */var za=Ct,cx=ux;function fx(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var dx=typeof Object.is=="function"?Object.is:fx,hx=cx.useSyncExternalStore,gx=za.useRef,px=za.useEffect,xx=za.useMemo,mx=za.useDebugValue;ph.useSyncExternalStoreWithSelector=function(e,t,i,l,c){var f=gx(null);if(f.current===null){var p={hasValue:!1,value:null};f.current=p}else p=f.current;f=xx(function(){function C(M){if(!m){if(m=!0,_=M,M=l(M),c!==void 0&&p.hasValue){var P=p.value;if(c(P,M))return v=P}return v=M}if(P=v,dx(_,M))return P;var B=l(M);return c!==void 0&&c(P,B)?(_=M,P):(_=M,v=B)}var m=!1,_,v,R=i===void 0?null:i;return[function(){return C(t())},R===null?void 0:function(){return C(R())}]},[t,i,l,c]);var w=hx(e,f[0],f[1]);return px(function(){p.hasValue=!0,p.value=w},[w]),mx(w),w};gh.exports=ph;var wx=gh.exports;const yx=J0(wx),wh={},{useDebugValue:Ex}=vg,{useSyncExternalStoreWithSelector:Cx}=yx;let N0=!1;const Ax=e=>e;function vx(e,t=Ax,i){(wh?"production":void 0)!=="production"&&i&&!N0&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),N0=!0);const l=Cx(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,i);return Ex(l),l}const R0=e=>{(wh?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?Jp(e):e,i=(l,c)=>vx(t,l,c);return Object.assign(i,t),i},Sx=e=>e?R0(e):R0,Ix={};function _x(e,t){let i;try{i=e()}catch{return}return{getItem:c=>{var f;const p=C=>C===null?null:JSON.parse(C,void 0),w=(f=i.getItem(c))!=null?f:null;return w instanceof Promise?w.then(p):p(w)},setItem:(c,f)=>i.setItem(c,JSON.stringify(f,void 0)),removeItem:c=>i.removeItem(c)}}const qs=e=>t=>{try{const i=e(t);return i instanceof Promise?i:{then(l){return qs(l)(i)},catch(l){return this}}}catch(i){return{then(l){return this},catch(l){return qs(l)(i)}}}},Tx=(e,t)=>(i,l,c)=>{let f={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:K=>K,version:0,merge:(K,O)=>({...O,...K}),...t},p=!1;const w=new Set,C=new Set;let m;try{m=f.getStorage()}catch{}if(!m)return e((...K)=>{console.warn(`[zustand persist middleware] Unable to update item '${f.name}', the given storage is currently unavailable.`),i(...K)},l,c);const _=qs(f.serialize),v=()=>{const K=f.partialize({...l()});let O;const T=_({state:K,version:f.version}).then(N=>m.setItem(f.name,N)).catch(N=>{O=N});if(O)throw O;return T},R=c.setState;c.setState=(K,O)=>{R(K,O),v()};const M=e((...K)=>{i(...K),v()},l,c);let P;const B=()=>{var K;if(!m)return;p=!1,w.forEach(T=>T(l()));const O=((K=f.onRehydrateStorage)==null?void 0:K.call(f,l()))||void 0;return qs(m.getItem.bind(m))(f.name).then(T=>{if(T)return f.deserialize(T)}).then(T=>{if(T)if(typeof T.version=="number"&&T.version!==f.version){if(f.migrate)return f.migrate(T.state,T.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return T.state}).then(T=>{var N;return P=f.merge(T,(N=l())!=null?N:M),i(P,!0),v()}).then(()=>{O==null||O(P,void 0),p=!0,C.forEach(T=>T(P))}).catch(T=>{O==null||O(void 0,T)})};return c.persist={setOptions:K=>{f={...f,...K},K.getStorage&&(m=K.getStorage())},clearStorage:()=>{m==null||m.removeItem(f.name)},getOptions:()=>f,rehydrate:()=>B(),hasHydrated:()=>p,onHydrate:K=>(w.add(K),()=>{w.delete(K)}),onFinishHydration:K=>(C.add(K),()=>{C.delete(K)})},B(),P||M},Nx=(e,t)=>(i,l,c)=>{let f={storage:_x(()=>localStorage),partialize:B=>B,version:0,merge:(B,K)=>({...K,...B}),...t},p=!1;const w=new Set,C=new Set;let m=f.storage;if(!m)return e((...B)=>{console.warn(`[zustand persist middleware] Unable to update item '${f.name}', the given storage is currently unavailable.`),i(...B)},l,c);const _=()=>{const B=f.partialize({...l()});return m.setItem(f.name,{state:B,version:f.version})},v=c.setState;c.setState=(B,K)=>{v(B,K),_()};const R=e((...B)=>{i(...B),_()},l,c);c.getInitialState=()=>R;let M;const P=()=>{var B,K;if(!m)return;p=!1,w.forEach(T=>{var N;return T((N=l())!=null?N:R)});const O=((K=f.onRehydrateStorage)==null?void 0:K.call(f,(B=l())!=null?B:R))||void 0;return qs(m.getItem.bind(m))(f.name).then(T=>{if(T)if(typeof T.version=="number"&&T.version!==f.version){if(f.migrate)return[!0,f.migrate(T.state,T.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,T.state];return[!1,void 0]}).then(T=>{var N;const[G,H]=T;if(M=f.merge(H,(N=l())!=null?N:R),i(M,!0),G)return _()}).then(()=>{O==null||O(M,void 0),M=l(),p=!0,C.forEach(T=>T(M))}).catch(T=>{O==null||O(void 0,T)})};return c.persist={setOptions:B=>{f={...f,...B},B.storage&&(m=B.storage)},clearStorage:()=>{m==null||m.removeItem(f.name)},getOptions:()=>f,rehydrate:()=>P(),hasHydrated:()=>p,onHydrate:B=>(w.add(B),()=>{w.delete(B)}),onFinishHydration:B=>(C.add(B),()=>{C.delete(B)})},f.skipHydration||P(),M||R},Rx=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((Ix?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),Tx(e,t)):Nx(e,t),bx=Rx;function Ox(){return typeof document<"u"&&document.body.dataset.webShell==="1"}function yh(){return typeof navigator>"u"?!1:Ox()||!/Electron\//i.test(navigator.userAgent)}function iw(e=900){const[t,i]=Ct.useState(()=>typeof window<"u"&&window.innerWidth<e);return Ct.useEffect(()=>{const l=window.matchMedia(`(max-width: ${e-1}px)`),c=f=>i(f.matches);return i(l.matches),l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[e]),t}const sw=[{id:"pearl",label:"珍珠白",preview:["#f5f6fa","#4f6ef7"]},{id:"scifi",label:"科幻霓虹",preview:["#050a14","#22d3ee"]},{id:"noir",label:"暗夜黑",preview:["#0f1115","#a78bfa"]}],ow=[{id:"standard",label:"标准",description:"侧边栏 + 对话区"},{id:"focus",label:"专注",description:"隐藏侧边栏,居中沉浸对话"},{id:"compact",label:"紧凑",description:"更小间距与字号,信息密度优先"}],Eh=4;function Ch(e){return Array.isArray(e)?[...new Set(e.filter(t=>typeof t=="string"&&t.length>0))]:[]}function Dx(e,t){const i=e??{};return{...i.skin!==void 0?{skin:i.skin}:{},...i.layout!==void 0?{layout:i.layout}:{},...i.autoSpeak!==void 0?{autoSpeak:i.autoSpeak}:{},...i.wakeEnabled!==void 0?{wakeEnabled:i.wakeEnabled}:{},...i.wakeWord!==void 0?{wakeWord:i.wakeWord}:{},...i.runningFirst!==void 0?{runningFirst:i.runningFirst}:{},pinnedSessionIds:Ch(i.pinnedSessionIds),...t<Eh&&yh()?{wakeEnabled:!1}:{}}}function Mx(e=yh()){return!e}const kx=Sx()(bx(e=>({skin:"pearl",layout:"standard",autoSpeak:!1,wakeEnabled:Mx(),wakeWord:"小智",runningFirst:!1,pinnedSessionIds:[],setSkin:t=>e({skin:t}),setLayout:t=>e({layout:t}),setAutoSpeak:t=>e({autoSpeak:t}),setWakeEnabled:t=>e({wakeEnabled:t}),setWakeWord:t=>e({wakeWord:t}),setRunningFirst:t=>e({runningFirst:t}),togglePinnedSession:t=>e(i=>({pinnedSessionIds:i.pinnedSessionIds.includes(t)?i.pinnedSessionIds.filter(l=>l!==t):Ch([...i.pinnedSessionIds,t])})),removePinnedSessions:t=>e(i=>{const l=new Set(t);return{pinnedSessionIds:i.pinnedSessionIds.filter(c=>!l.has(c))}})}),{name:"agent-ui-prefs",version:Eh,migrate:Dx})),Px="agent-web-shell:skin:v1",Bx=["pearl","scifi","noir"];function Lx(){if(window.parent===window)return()=>{};const e=t=>{if(t.origin!==window.location.origin||t.source!==window.parent)return;const i=t.data;!i||typeof i!="object"||i.type!==Px||typeof i.skin!="string"||!Bx.includes(i.skin)||kx.getState().setSkin(i.skin)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}const Fx="agentroam:open-browser-live",Ux="agent-web-shell:open-browser-live:v1";function Wx(){if(window.parent===window)return()=>{};const e=t=>{if(t.origin!==window.location.origin||t.source!==window.parent)return;const i=t.data;!i||typeof i!="object"||i.type!==Ux||window.dispatchEvent(new CustomEvent(Fx))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}const zx="agent-webapp:ready:v1";function Vx(){window.parent!==window&&window.parent.postMessage({type:zx},window.location.origin)}const Hx="agent-webapp:project-request:v1",jx="agent-web-shell:project-response:v1",Gx=["project:list","project:get","project:create","project:rename","project:delete","project:roots","project:directories","project:check"];new Set(Gx);function Xx(e){if(!e||typeof e!="object")return null;const t=e;return t.type!==jx||!Number.isSafeInteger(t.id)||Number(t.id)<1||typeof t.ok!="boolean"||!t.ok&&typeof t.error!="string"?null:t}class Yx{constructor(t=window,i=15e3){this.context=t,this.timeoutMs=i,this.sequence=0,this.pending=new Map,this.onMessage=l=>{if(l.origin!==this.context.location.origin||l.source!==this.context.parent)return;const c=Xx(l.data);if(!c)return;const f=this.pending.get(c.id);f&&(this.pending.delete(c.id),clearTimeout(f.timer),c.ok?f.resolve(c.result):f.reject(Object.assign(new Error(c.error||"项目操作失败"),{code:c.code})))},this.context.addEventListener("message",this.onMessage)}request(t,i={}){if(this.context.parent===this.context)return Promise.reject(Object.assign(new Error("请从 AgentRoam Web 控制台打开项目"),{code:"WEB_SHELL_REQUIRED"}));const l=++this.sequence;return new Promise((c,f)=>{const p=setTimeout(()=>{this.pending.delete(l),f(Object.assign(new Error("项目操作超时"),{code:"WEB_SHELL_TIMEOUT"}))},this.timeoutMs);this.pending.set(l,{resolve:c,reject:f,timer:p}),this.context.parent.postMessage({type:Hx,id:l,method:t,payload:i},this.context.location.origin)})}dispose(){this.context.removeEventListener("message",this.onMessage);for(const t of this.pending.values())clearTimeout(t.timer),t.reject(Object.assign(new Error("项目桥已关闭"),{code:"WEB_SHELL_CLOSED"}));this.pending.clear()}}const Zx="agent-webapp:browser-request:v1",Kx="agent-web-shell:browser-response:v1",Qx="agent-web-shell:browser-event:v1",qx="agent-web-shell:browser-frame:v1",$x=["browser:list","browser:watch","browser:unwatch","browser:takeover","browser:return","browser:input","browser:set-display","browser:ping","browser:webrtc"];new Set($x);function Jx(e){if(!e||typeof e!="object")return null;const t=e;return t.type!==Kx||!Number.isSafeInteger(t.id)||Number(t.id)<1||typeof t.ok!="boolean"||!t.ok&&typeof t.error!="string"?null:t}function em(e){if(!e||typeof e!="object")return null;const t=e;if(t.type!==Qx||!t.event||typeof t.event!="object")return null;const i=t.event;return typeof i.type!="string"||!i.type.startsWith("browser:")?null:t}function tm(e){if(!e||typeof e!="object")return null;const t=e;return t.type!==qx||!Number.isSafeInteger(t.channelId)||Number(t.channelId)<1||!Number.isSafeInteger(t.sequence)||Number(t.sequence)<0||!(t.data instanceof ArrayBuffer)?null:t}class nm{constructor(t=window,i=15e3){this.context=t,this.timeoutMs=i,this.sequence=0,this.pending=new Map,this.listeners=new Set,this.sessionsByChannel=new Map,this.pendingFramesByChannel=new Map,this.onMessage=l=>{var C;if(l.origin!==this.context.location.origin||l.source!==this.context.parent)return;const c=tm(l.data);if(c){const m=this.sessionsByChannel.get(c.channelId);if(!m){this.pendingFramesByChannel.set(c.channelId,c);return}this.emitBinaryFrame(c,m);return}const f=em(l.data);if(f){for(const m of this.listeners)m(f.event);return}const p=Jx(l.data);if(!p)return;const w=this.pending.get(p.id);if(w)if(this.pending.delete(p.id),clearTimeout(w.timer),p.ok){if(w.method==="browser:watch"&&p.result&&typeof p.result=="object"){const m=p.result;if(Number.isSafeInteger(m.channelId)&&typeof((C=m.session)==null?void 0:C.id)=="string"){const _=Number(m.channelId);this.sessionsByChannel.set(_,m.session.id);const v=this.pendingFramesByChannel.get(_);v&&(this.pendingFramesByChannel.delete(_),this.emitBinaryFrame(v,m.session.id))}}w.resolve(p.result)}else w.reject(Object.assign(new Error(p.error||"浏览器操作失败"),{code:p.code}))},this.context.addEventListener("message",this.onMessage)}emitBinaryFrame(t,i){for(const l of this.listeners)l({type:"browser:frame",sessionId:i,sequence:t.sequence,data:t.data,mime:"image/jpeg",timestamp:Date.now()})}request(t,i={}){if(this.context.parent===this.context)return Promise.reject(Object.assign(new Error("请从 AgentRoam Web 控制台打开浏览器直播"),{code:"WEB_SHELL_REQUIRED"}));const l=++this.sequence;return new Promise((c,f)=>{const p=setTimeout(()=>{this.pending.delete(l),f(Object.assign(new Error("浏览器操作超时"),{code:"WEB_SHELL_TIMEOUT"}))},this.timeoutMs);this.pending.set(l,{resolve:c,reject:f,timer:p,method:t}),this.context.parent.postMessage({type:Zx,id:l,method:t,payload:i},this.context.location.origin)})}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}dispose(){this.context.removeEventListener("message",this.onMessage);for(const t of this.pending.values())clearTimeout(t.timer),t.reject(Object.assign(new Error("浏览器桥已关闭"),{code:"WEB_SHELL_CLOSED"}));this.pending.clear(),this.listeners.clear(),this.sessionsByChannel.clear(),this.pendingFramesByChannel.clear()}}class br{constructor(t){this.url=t}static parse(t){const i=t.trim();if(!i)return null;const l=/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(i)?i:`http://${i}`;let c;try{c=new URL(l)}catch{return null}return c.protocol!=="http:"&&c.protocol!=="https:"||!c.hostname?null:new br(`${c.protocol}//${c.host}`)}toString(){return this.url}api(t){return`${this.url}${t.startsWith("/")?t:`/${t}`}`}}class rm{constructor(t,i,l){this.environment=t,this.storage=i,this.probe=l}async planStartup(){if(!this.environment.isNativeApp())return{mode:"same-origin"};const t=this.launchEndpoint();if(t)return{mode:"ready",endpoint:t};const i=this.storage.load();if(i){const l=await this.probe.probe(i);return l.ok?{mode:"ready",endpoint:i}:{mode:"setup",endpoint:i,failure:l.reason}}return{mode:"setup",endpoint:null}}async connect(t){const i=br.parse(t);if(!i)return{ok:!1,reason:"地址无效,请输入 http(s)://host:port 形式的服务器地址"};const l=await this.probe.probe(i);return l.ok?(this.storage.save(i),{ok:!0,endpoint:i}):{ok:!1,reason:`无法连接服务器:${l.reason}`}}disconnect(){this.storage.clear()}launchEndpoint(){const t=this.environment.launchServerUrl();return t?br.parse(t):null}}function b0(){return window.Capacitor??null}class im{isNativeApp(){var t,i;return((i=(t=b0())==null?void 0:t.isNativePlatform)==null?void 0:i.call(t))??!1}platform(){var i,l;const t=(l=(i=b0())==null?void 0:i.getPlatform)==null?void 0:l.call(i);return t==="ios"||t==="android"?t:"web"}launchServerUrl(){const t=new URLSearchParams(window.location.search).get("server");return t&&t.trim()?t.trim():null}}const Ul="webapp.mobile.serverEndpoint.v1";class O0{load(){try{const t=localStorage.getItem(Ul);return t?br.parse(t):null}catch{return null}}save(t){localStorage.setItem(Ul,t.toString())}clear(){localStorage.removeItem(Ul)}}const sm=6e3;class om{constructor(t=(...i)=>fetch(...i)){this.transport=t}async probe(t,i=sm){const l=new AbortController,c=setTimeout(()=>l.abort(),i);try{const f=await this.transport(t.api("/api/agent/model"),{method:"GET",cache:"no-store",signal:l.signal});return f.ok?{ok:!0,modelId:(await f.json()).modelId??null}:{ok:!1,reason:f.status===401?"此 App 尚未授权,请扫描电脑上的授权二维码。":f.status===423?"电脑已锁定远程访问,请先在电脑上解锁。":`HTTP ${f.status}`}}catch(f){return{ok:!1,reason:f instanceof DOMException&&f.name==="AbortError"?"连接超时":am(f)}}finally{clearTimeout(c)}}}function am(e){return(e instanceof Error?e.message:String(e))||"网络错误"}function lm({service:e,savedEndpoint:t,initialFailure:i,onConnected:l,onScan:c}){const[f,p]=Ct.useState((t==null?void 0:t.toString())??""),[w,C]=Ct.useState(i??""),[m,_]=Ct.useState(!1);async function v(){if(!(m||!c)){_(!0),C("");try{const M=await c();M&&l(M)}catch(M){C(M instanceof Error?M.message:"扫码连接失败,请重试。")}finally{_(!1)}}}async function R(){if(!m){_(!0),C("");try{const M=await e.connect(f);M.ok?l(M.endpoint):C(M.reason)}catch{C("连接失败,请检查网络或重新扫码授权。")}finally{_(!1)}}}return ue.jsx("div",{style:Wn.page,children:ue.jsxs("div",{style:Wn.card,children:[ue.jsx("div",{style:Wn.icon,children:"🛰️"}),ue.jsx("h1",{style:Wn.title,children:"连接服务器"}),c?ue.jsxs(ue.Fragment,{children:[ue.jsx("p",{style:Wn.hint,children:"扫描电脑终端上的授权二维码,直接连接,无需再次确认。"}),ue.jsx("button",{type:"button",style:{...Wn.button,marginBottom:20},disabled:m,onClick:()=>void v(),children:m?"正在连接…":"扫码连接"})]}):null,ue.jsx("p",{style:Wn.hint,children:"也可以输入已授权的服务器地址。使用局域网地址时,手机与电脑需在同一网络。"}),ue.jsx("input",{style:Wn.input,value:f,inputMode:"url",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,placeholder:"http://192.168.1.10:3000",onChange:M=>p(M.target.value),onKeyDown:M=>{M.key==="Enter"&&R()}}),w?ue.jsx("p",{style:Wn.error,children:w}):null,ue.jsx("button",{style:{...Wn.button,opacity:m||!f.trim()?.6:1},disabled:m,onClick:()=>void R(),children:m?"正在连接…":"连接"})]})})}const Wn={page:{minHeight:"100dvh",display:"flex",alignItems:"center",justifyContent:"center",background:"#f5f6fa",padding:24,boxSizing:"border-box"},card:{width:"100%",maxWidth:420,background:"#fff",borderRadius:16,padding:"32px 24px",boxShadow:"0 8px 32px rgba(0,0,0,0.08)",textAlign:"center"},icon:{fontSize:40,marginBottom:8},title:{fontSize:20,margin:"0 0 8px",color:"#1c1e26"},hint:{fontSize:13,lineHeight:1.6,color:"#6b7280",margin:"0 0 20px"},input:{width:"100%",boxSizing:"border-box",padding:"12px 14px",fontSize:16,borderRadius:10,border:"1px solid #d6d9e0",outline:"none",marginBottom:12},error:{fontSize:13,color:"#dc2626",margin:"0 0 12px",textAlign:"left"},button:{width:"100%",padding:"12px 0",fontSize:16,fontWeight:600,color:"#fff",background:"#4f6ef7",border:"none",borderRadius:10,cursor:"pointer"}};/*! Capacitor: https://capacitorjs.com/ - MIT License */var Xi;(function(e){e.Unimplemented="UNIMPLEMENTED",e.Unavailable="UNAVAILABLE"})(Xi||(Xi={}));class Wl extends Error{constructor(t,i,l){super(t),this.message=t,this.code=i,this.data=l}}const um=e=>{var t,i;return e!=null&&e.androidBridge?"android":!((i=(t=e==null?void 0:e.webkit)===null||t===void 0?void 0:t.messageHandlers)===null||i===void 0)&&i.bridge?"ios":"web"},cm=e=>{const t=e.CapacitorCustomPlatform||null,i=e.Capacitor||{},l=i.Plugins=i.Plugins||{},c=()=>t!==null?t.name:um(e),f=()=>c()!=="web",p=v=>{const R=m.get(v);return!!(R!=null&&R.platforms.has(c())||w(v))},w=v=>{var R;return(R=i.PluginHeaders)===null||R===void 0?void 0:R.find(M=>M.name===v)},C=v=>e.console.error(v),m=new Map,_=(v,R={})=>{const M=m.get(v);if(M)return console.warn(`Capacitor plugin "${v}" already registered. Cannot register plugins twice.`),M.proxy;const P=c(),B=w(v);let K;const O=async()=>(!K&&P in R?K=typeof R[P]=="function"?K=await R[P]():K=R[P]:t!==null&&!K&&"web"in R&&(K=typeof R.web=="function"?K=await R.web():K=R.web),K),T=(X,V)=>{var se,Ee;if(B){const ie=B==null?void 0:B.methods.find(ge=>V===ge.name);if(ie)return ie.rtype==="promise"?ge=>i.nativePromise(v,V.toString(),ge):(ge,_e)=>i.nativeCallback(v,V.toString(),ge,_e);if(X)return(se=X[V])===null||se===void 0?void 0:se.bind(X)}else{if(X)return(Ee=X[V])===null||Ee===void 0?void 0:Ee.bind(X);throw new Wl(`"${v}" plugin is not implemented on ${P}`,Xi.Unimplemented)}},N=X=>{let V;const se=(...Ee)=>{const ie=O().then(ge=>{const _e=T(ge,X);if(_e){const j=_e(...Ee);return V=j==null?void 0:j.remove,j}else throw new Wl(`"${v}.${X}()" is not implemented on ${P}`,Xi.Unimplemented)});return X==="addListener"&&(ie.remove=async()=>V()),ie};return se.toString=()=>`${X.toString()}() { [capacitor code] }`,Object.defineProperty(se,"name",{value:X,writable:!1,configurable:!1}),se},G=N("addListener"),H=N("removeListener"),U=(X,V)=>{const se=G({eventName:X},V),Ee=async()=>{const ge=await se;H({eventName:X,callbackId:ge},V)},ie=new Promise(ge=>se.then(()=>ge({remove:Ee})));return ie.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await Ee()},ie},k=new Proxy({},{get(X,V){switch(V){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return B?U:G;case"removeListener":return H;default:return N(V)}}});return l[v]=k,m.set(v,{name:v,proxy:k,platforms:new Set([...Object.keys(R),...B?[P]:[]])}),k};return i.convertFileSrc||(i.convertFileSrc=v=>v),i.getPlatform=c,i.handleError=C,i.isNativePlatform=f,i.isPluginAvailable=p,i.registerPlugin=_,i.Exception=Wl,i.DEBUG=!!i.DEBUG,i.isLoggingEnabled=!!i.isLoggingEnabled,i},fm=e=>e.Capacitor=cm(e),$s=fm(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Va=$s.registerPlugin;class Ah{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(t,i){let l=!1;this.listeners[t]||(this.listeners[t]=[],l=!0),this.listeners[t].push(i);const f=this.windowListeners[t];f&&!f.registered&&this.addWindowListener(f),l&&this.sendRetainedArgumentsForEvent(t);const p=async()=>this.removeListener(t,i);return Promise.resolve({remove:p})}async removeAllListeners(){this.listeners={};for(const t in this.windowListeners)this.removeWindowListener(this.windowListeners[t]);this.windowListeners={}}notifyListeners(t,i,l){const c=this.listeners[t];if(!c){if(l){let f=this.retainedEventArguments[t];f||(f=[]),f.push(i),this.retainedEventArguments[t]=f}return}c.forEach(f=>f(i))}hasListeners(t){var i;return!!(!((i=this.listeners[t])===null||i===void 0)&&i.length)}registerWindowListener(t,i){this.windowListeners[i]={registered:!1,windowEventName:t,pluginEventName:i,handler:l=>{this.notifyListeners(i,l)}}}unimplemented(t="not implemented"){return new $s.Exception(t,Xi.Unimplemented)}unavailable(t="not available"){return new $s.Exception(t,Xi.Unavailable)}async removeListener(t,i){const l=this.listeners[t];if(!l)return;const c=l.indexOf(i);this.listeners[t].splice(c,1),this.listeners[t].length||this.removeWindowListener(this.windowListeners[t])}addWindowListener(t){window.addEventListener(t.windowEventName,t.handler),t.registered=!0}removeWindowListener(t){t&&(window.removeEventListener(t.windowEventName,t.handler),t.registered=!1)}sendRetainedArgumentsForEvent(t){const i=this.retainedEventArguments[t];i&&(delete this.retainedEventArguments[t],i.forEach(l=>{this.notifyListeners(t,l)}))}}const D0=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),M0=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class dm extends Ah{async getCookies(){const t=document.cookie,i={};return t.split(";").forEach(l=>{if(l.length<=0)return;let[c,f]=l.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");c=M0(c).trim(),f=M0(f).trim(),i[c]=f}),i}async setCookie(t){try{const i=D0(t.key),l=D0(t.value),c=t.expires?`; expires=${t.expires.replace("expires=","")}`:"",f=(t.path||"/").replace("path=",""),p=t.url!=null&&t.url.length>0?`domain=${t.url}`:"";document.cookie=`${i}=${l||""}${c}; path=${f}; ${p};`}catch(i){return Promise.reject(i)}}async deleteCookie(t){try{document.cookie=`${t.key}=; Max-Age=0`}catch(i){return Promise.reject(i)}}async clearCookies(){try{const t=document.cookie.split(";")||[];for(const i of t)document.cookie=i.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(t){return Promise.reject(t)}}async clearAllCookies(){try{await this.clearCookies()}catch(t){return Promise.reject(t)}}}Va("CapacitorCookies",{web:()=>new dm});const hm=async e=>new Promise((t,i)=>{const l=new FileReader;l.onload=()=>{const c=l.result;t(c.indexOf(",")>=0?c.split(",")[1]:c)},l.onerror=c=>i(c),l.readAsDataURL(e)}),gm=(e={})=>{const t=Object.keys(e);return Object.keys(e).map(c=>c.toLocaleLowerCase()).reduce((c,f,p)=>(c[f]=e[t[p]],c),{})},pm=(e,t=!0)=>e?Object.entries(e).reduce((l,c)=>{const[f,p]=c;let w,C;return Array.isArray(p)?(C="",p.forEach(m=>{w=t?encodeURIComponent(m):m,C+=`${f}=${w}&`}),C.slice(0,-1)):(w=t?encodeURIComponent(p):p,C=`${f}=${w}`),`${l}&${C}`},"").substr(1):null,xm=(e,t={})=>{const i=Object.assign({method:e.method||"GET",headers:e.headers},t),c=gm(e.headers)["content-type"]||"";if(typeof e.data=="string")i.body=e.data;else if(c.includes("application/x-www-form-urlencoded")){const f=new URLSearchParams;for(const[p,w]of Object.entries(e.data||{}))f.set(p,w);i.body=f.toString()}else if(c.includes("multipart/form-data")||e.data instanceof FormData){const f=new FormData;if(e.data instanceof FormData)e.data.forEach((w,C)=>{f.append(C,w)});else for(const w of Object.keys(e.data))f.append(w,e.data[w]);i.body=f;const p=new Headers(i.headers);p.delete("content-type"),i.headers=p}else(c.includes("application/json")||typeof e.data=="object")&&(i.body=JSON.stringify(e.data));return i};class mm extends Ah{async request(t){const i=xm(t,t.webFetchExtra),l=pm(t.params,t.shouldEncodeUrlParams),c=l?`${t.url}?${l}`:t.url,f=await fetch(c,i),p=f.headers.get("content-type")||"";let{responseType:w="text"}=f.ok?t:{};p.includes("application/json")&&(w="json");let C,m;switch(w){case"arraybuffer":case"blob":m=await f.blob(),C=await hm(m);break;case"json":C=await f.json();break;case"document":case"text":default:C=await f.text()}const _={};return f.headers.forEach((v,R)=>{_[R]=v}),{data:C,headers:_,status:f.status,url:f.url}}async get(t){return this.request(Object.assign(Object.assign({},t),{method:"GET"}))}async post(t){return this.request(Object.assign(Object.assign({},t),{method:"POST"}))}async put(t){return this.request(Object.assign(Object.assign({},t),{method:"PUT"}))}async patch(t){return this.request(Object.assign(Object.assign({},t),{method:"PATCH"}))}async delete(t){return this.request(Object.assign(Object.assign({},t),{method:"DELETE"}))}}Va("CapacitorHttp",{web:()=>new mm});var te;(function(e){e[e.QR_CODE=0]="QR_CODE",e[e.AZTEC=1]="AZTEC",e[e.CODABAR=2]="CODABAR",e[e.CODE_39=3]="CODE_39",e[e.CODE_93=4]="CODE_93",e[e.CODE_128=5]="CODE_128",e[e.DATA_MATRIX=6]="DATA_MATRIX",e[e.MAXICODE=7]="MAXICODE",e[e.ITF=8]="ITF",e[e.EAN_13=9]="EAN_13",e[e.EAN_8=10]="EAN_8",e[e.PDF_417=11]="PDF_417",e[e.RSS_14=12]="RSS_14",e[e.RSS_EXPANDED=13]="RSS_EXPANDED",e[e.UPC_A=14]="UPC_A",e[e.UPC_E=15]="UPC_E",e[e.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(te||(te={}));var k0=new Map([[te.QR_CODE,"QR_CODE"],[te.AZTEC,"AZTEC"],[te.CODABAR,"CODABAR"],[te.CODE_39,"CODE_39"],[te.CODE_93,"CODE_93"],[te.CODE_128,"CODE_128"],[te.DATA_MATRIX,"DATA_MATRIX"],[te.MAXICODE,"MAXICODE"],[te.ITF,"ITF"],[te.EAN_13,"EAN_13"],[te.EAN_8,"EAN_8"],[te.PDF_417,"PDF_417"],[te.RSS_14,"RSS_14"],[te.RSS_EXPANDED,"RSS_EXPANDED"],[te.UPC_A,"UPC_A"],[te.UPC_E,"UPC_E"],[te.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),P0;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.URL=1]="URL"})(P0||(P0={}));function wm(e){return Object.values(te).includes(e)}var Ca;(function(e){e[e.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",e[e.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(Ca||(Ca={}));var ym=function(){function e(){}return e.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",e.SCAN_DEFAULT_FPS=2,e.DEFAULT_DISABLE_FLIP=!1,e.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,e.DEFAULT_SUPPORTED_SCAN_TYPE=[Ca.SCAN_TYPE_CAMERA,Ca.SCAN_TYPE_FILE],e}(),vh=function(){function e(t,i){this.format=t,this.formatName=i}return e.prototype.toString=function(){return this.formatName},e.create=function(t){if(!k0.has(t))throw"".concat(t," not in html5QrcodeSupportedFormatsTextMap");return new e(t,k0.get(t))},e}(),B0=function(){function e(){}return e.createFromText=function(t){var i={text:t};return{decodedText:t,result:i}},e.createFromQrcodeResult=function(t){return{decodedText:t.text,result:t}},e}(),Bu;(function(e){e[e.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",e[e.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",e[e.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(Bu||(Bu={}));var Em=function(){function e(){}return e.createFrom=function(t){return{errorMessage:t,type:Bu.UNKWOWN_ERROR}},e}(),Cm=function(){function e(t){this.verbose=t}return e.prototype.log=function(t){this.verbose&&console.log(t)},e.prototype.warn=function(t){this.verbose&&console.warn(t)},e.prototype.logError=function(t,i){(this.verbose||i===!0)&&console.error(t)},e.prototype.logErrors=function(t){if(t.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(t)},e}();function Xn(e){return typeof e>"u"||e===null}var Ri=function(){function e(){}return e.codeParseError=function(t){return"QR code parse error, error = ".concat(t)},e.errorGettingUserMedia=function(t){return"Error getting userMedia, error = ".concat(t)},e.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},e.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},e.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},e.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},e.scannerPaused=function(){return"Scanner paused"},e}(),Sh=function(){function e(){}return e.isMediaStreamConstraintsValid=function(t,i){if(typeof t!="object"){var l=typeof t;return i.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(l,"."),!0),!1}for(var c=["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"],f=new Set(c),p=Object.keys(t),w=0,C=p;w<C.length;w++){var m=C[w];if(f.has(m))return i.logError("".concat(m," is not supported videoConstaints."),!0),!1}return!0},e}(),Lu={exports:{}};(function(e,t){(function(i,l){l(t)})(ls,function(i){function l(y){return y==null}var c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,n){y.__proto__=n}||function(y,n){for(var r in n)n.hasOwnProperty(r)&&(y[r]=n[r])};function f(y,n){c(y,n);function r(){this.constructor=y}y.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}function p(y,n){var r=Object.setPrototypeOf;r?r(y,n):y.__proto__=n}function w(y,n){n===void 0&&(n=y.constructor);var r=Error.captureStackTrace;r&&r(y,n)}var C=function(y){f(n,y);function n(r){var s=this.constructor,o=y.call(this,r)||this;return Object.defineProperty(o,"name",{value:s.name,enumerable:!1}),p(o,s.prototype),w(o),o}return n}(Error);class m extends C{constructor(n=void 0){super(n),this.message=n}getKind(){return this.constructor.kind}}m.kind="Exception";class _ extends m{}_.kind="ArgumentException";class v extends m{}v.kind="IllegalArgumentException";class R{constructor(n){if(this.binarizer=n,n===null)throw new v("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(n,r){return this.binarizer.getBlackRow(n,r)}getBlackMatrix(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(n,r,s,o){const a=this.binarizer.getLuminanceSource().crop(n,r,s,o);return new R(this.binarizer.createBinarizer(a))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){const n=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new R(this.binarizer.createBinarizer(n))}rotateCounterClockwise45(){const n=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new R(this.binarizer.createBinarizer(n))}toString(){try{return this.getBlackMatrix().toString()}catch{return""}}}class M extends m{static getChecksumInstance(){return new M}}M.kind="ChecksumException";class P{constructor(n){this.source=n}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class B{static arraycopy(n,r,s,o,a){for(;a--;)s[o++]=n[r++]}static currentTimeMillis(){return Date.now()}}class K extends m{}K.kind="IndexOutOfBoundsException";class O extends K{constructor(n=void 0,r=void 0){super(r),this.index=n,this.message=r}}O.kind="ArrayIndexOutOfBoundsException";class T{static fill(n,r){for(let s=0,o=n.length;s<o;s++)n[s]=r}static fillWithin(n,r,s,o){T.rangeCheck(n.length,r,s);for(let a=r;a<s;a++)n[a]=o}static rangeCheck(n,r,s){if(r>s)throw new v("fromIndex("+r+") > toIndex("+s+")");if(r<0)throw new O(r);if(s>n)throw new O(s)}static asList(...n){return n}static create(n,r,s){return Array.from({length:n}).map(a=>Array.from({length:r}).fill(s))}static createInt32Array(n,r,s){return Array.from({length:n}).map(a=>Int32Array.from({length:r}).fill(s))}static equals(n,r){if(!n||!r||!n.length||!r.length||n.length!==r.length)return!1;for(let s=0,o=n.length;s<o;s++)if(n[s]!==r[s])return!1;return!0}static hashCode(n){if(n===null)return 0;let r=1;for(const s of n)r=31*r+s;return r}static fillUint8Array(n,r){for(let s=0;s!==n.length;s++)n[s]=r}static copyOf(n,r){return n.slice(0,r)}static copyOfUint8Array(n,r){if(n.length<=r){const s=new Uint8Array(r);return s.set(n),s}return n.slice(0,r)}static copyOfRange(n,r,s){const o=s-r,a=new Int32Array(o);return B.arraycopy(n,r,a,0,o),a}static binarySearch(n,r,s){s===void 0&&(s=T.numberComparator);let o=0,a=n.length-1;for(;o<=a;){const u=a+o>>1,d=s(r,n[u]);if(d>0)o=u+1;else if(d<0)a=u-1;else return u}return-o-1}static numberComparator(n,r){return n-r}}class N{static numberOfTrailingZeros(n){let r;if(n===0)return 32;let s=31;return r=n<<16,r!==0&&(s-=16,n=r),r=n<<8,r!==0&&(s-=8,n=r),r=n<<4,r!==0&&(s-=4,n=r),r=n<<2,r!==0&&(s-=2,n=r),s-(n<<1>>>31)}static numberOfLeadingZeros(n){if(n===0)return 32;let r=1;return n>>>16||(r+=16,n<<=16),n>>>24||(r+=8,n<<=8),n>>>28||(r+=4,n<<=4),n>>>30||(r+=2,n<<=2),r-=n>>>31,r}static toHexString(n){return n.toString(16)}static toBinaryString(n){return String(parseInt(String(n),2))}static bitCount(n){return n=n-(n>>>1&1431655765),n=(n&858993459)+(n>>>2&858993459),n=n+(n>>>4)&252645135,n=n+(n>>>8),n=n+(n>>>16),n&63}static truncDivision(n,r){return Math.trunc(n/r)}static parseInt(n,r=void 0){return parseInt(n,r)}}N.MIN_VALUE_32_BITS=-2147483648,N.MAX_VALUE=Number.MAX_SAFE_INTEGER;class G{constructor(n,r){n===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=n,r==null?this.bits=G.makeArray(n):this.bits=r)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(n){if(n>this.bits.length*32){const r=G.makeArray(n);B.arraycopy(this.bits,0,r,0,this.bits.length),this.bits=r}}get(n){return(this.bits[Math.floor(n/32)]&1<<(n&31))!==0}set(n){this.bits[Math.floor(n/32)]|=1<<(n&31)}flip(n){this.bits[Math.floor(n/32)]^=1<<(n&31)}getNextSet(n){const r=this.size;if(n>=r)return r;const s=this.bits;let o=Math.floor(n/32),a=s[o];a&=~((1<<(n&31))-1);const u=s.length;for(;a===0;){if(++o===u)return r;a=s[o]}const d=o*32+N.numberOfTrailingZeros(a);return d>r?r:d}getNextUnset(n){const r=this.size;if(n>=r)return r;const s=this.bits;let o=Math.floor(n/32),a=~s[o];a&=~((1<<(n&31))-1);const u=s.length;for(;a===0;){if(++o===u)return r;a=~s[o]}const d=o*32+N.numberOfTrailingZeros(a);return d>r?r:d}setBulk(n,r){this.bits[Math.floor(n/32)]=r}setRange(n,r){if(r<n||n<0||r>this.size)throw new v;if(r===n)return;r--;const s=Math.floor(n/32),o=Math.floor(r/32),a=this.bits;for(let u=s;u<=o;u++){const d=u>s?0:n&31,g=(2<<(u<o?31:r&31))-(1<<d);a[u]|=g}}clear(){const n=this.bits.length,r=this.bits;for(let s=0;s<n;s++)r[s]=0}isRange(n,r,s){if(r<n||n<0||r>this.size)throw new v;if(r===n)return!0;r--;const o=Math.floor(n/32),a=Math.floor(r/32),u=this.bits;for(let d=o;d<=a;d++){const h=d>o?0:n&31,x=(2<<(d<a?31:r&31))-(1<<h)&4294967295;if((u[d]&x)!==(s?x:0))return!1}return!0}appendBit(n){this.ensureCapacity(this.size+1),n&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++}appendBits(n,r){if(r<0||r>32)throw new v("Num bits must be between 0 and 32");this.ensureCapacity(this.size+r);for(let s=r;s>0;s--)this.appendBit((n>>s-1&1)===1)}appendBitArray(n){const r=n.size;this.ensureCapacity(this.size+r);for(let s=0;s<r;s++)this.appendBit(n.get(s))}xor(n){if(this.size!==n.size)throw new v("Sizes don't match");const r=this.bits;for(let s=0,o=r.length;s<o;s++)r[s]^=n.bits[s]}toBytes(n,r,s,o){for(let a=0;a<o;a++){let u=0;for(let d=0;d<8;d++)this.get(n)&&(u|=1<<7-d),n++;r[s+a]=u}}getBitArray(){return this.bits}reverse(){const n=new Int32Array(this.bits.length),r=Math.floor((this.size-1)/32),s=r+1,o=this.bits;for(let a=0;a<s;a++){let u=o[a];u=u>>1&1431655765|(u&1431655765)<<1,u=u>>2&858993459|(u&858993459)<<2,u=u>>4&252645135|(u&252645135)<<4,u=u>>8&16711935|(u&16711935)<<8,u=u>>16&65535|(u&65535)<<16,n[r-a]=u}if(this.size!==s*32){const a=s*32-this.size;let u=n[0]>>>a;for(let d=1;d<s;d++){const h=n[d];u|=h<<32-a,n[d-1]=u,u=h>>>a}n[s-1]=u}this.bits=n}static makeArray(n){return new Int32Array(Math.floor((n+31)/32))}equals(n){if(!(n instanceof G))return!1;const r=n;return this.size===r.size&&T.equals(this.bits,r.bits)}hashCode(){return 31*this.size+T.hashCode(this.bits)}toString(){let n="";for(let r=0,s=this.size;r<s;r++)r&7||(n+=" "),n+=this.get(r)?"X":".";return n}clone(){return new G(this.size,this.bits.slice())}}var H;(function(y){y[y.OTHER=0]="OTHER",y[y.PURE_BARCODE=1]="PURE_BARCODE",y[y.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",y[y.TRY_HARDER=3]="TRY_HARDER",y[y.CHARACTER_SET=4]="CHARACTER_SET",y[y.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",y[y.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",y[y.ASSUME_GS1=7]="ASSUME_GS1",y[y.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",y[y.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",y[y.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(H||(H={}));var U=H;class k extends m{static getFormatInstance(){return new k}}k.kind="FormatException";var X;(function(y){y[y.Cp437=0]="Cp437",y[y.ISO8859_1=1]="ISO8859_1",y[y.ISO8859_2=2]="ISO8859_2",y[y.ISO8859_3=3]="ISO8859_3",y[y.ISO8859_4=4]="ISO8859_4",y[y.ISO8859_5=5]="ISO8859_5",y[y.ISO8859_6=6]="ISO8859_6",y[y.ISO8859_7=7]="ISO8859_7",y[y.ISO8859_8=8]="ISO8859_8",y[y.ISO8859_9=9]="ISO8859_9",y[y.ISO8859_10=10]="ISO8859_10",y[y.ISO8859_11=11]="ISO8859_11",y[y.ISO8859_13=12]="ISO8859_13",y[y.ISO8859_14=13]="ISO8859_14",y[y.ISO8859_15=14]="ISO8859_15",y[y.ISO8859_16=15]="ISO8859_16",y[y.SJIS=16]="SJIS",y[y.Cp1250=17]="Cp1250",y[y.Cp1251=18]="Cp1251",y[y.Cp1252=19]="Cp1252",y[y.Cp1256=20]="Cp1256",y[y.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",y[y.UTF8=22]="UTF8",y[y.ASCII=23]="ASCII",y[y.Big5=24]="Big5",y[y.GB18030=25]="GB18030",y[y.EUC_KR=26]="EUC_KR"})(X||(X={}));class V{constructor(n,r,s,...o){this.valueIdentifier=n,this.name=s,typeof r=="number"?this.values=Int32Array.from([r]):this.values=r,this.otherEncodingNames=o,V.VALUE_IDENTIFIER_TO_ECI.set(n,this),V.NAME_TO_ECI.set(s,this);const a=this.values;for(let u=0,d=a.length;u!==d;u++){const h=a[u];V.VALUES_TO_ECI.set(h,this)}for(const u of o)V.NAME_TO_ECI.set(u,this)}getValueIdentifier(){return this.valueIdentifier}getName(){return this.name}getValue(){return this.values[0]}static getCharacterSetECIByValue(n){if(n<0||n>=900)throw new k("incorect value");const r=V.VALUES_TO_ECI.get(n);if(r===void 0)throw new k("incorect value");return r}static getCharacterSetECIByName(n){const r=V.NAME_TO_ECI.get(n);if(r===void 0)throw new k("incorect value");return r}equals(n){if(!(n instanceof V))return!1;const r=n;return this.getName()===r.getName()}}V.VALUE_IDENTIFIER_TO_ECI=new Map,V.VALUES_TO_ECI=new Map,V.NAME_TO_ECI=new Map,V.Cp437=new V(X.Cp437,Int32Array.from([0,2]),"Cp437"),V.ISO8859_1=new V(X.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),V.ISO8859_2=new V(X.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),V.ISO8859_3=new V(X.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),V.ISO8859_4=new V(X.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),V.ISO8859_5=new V(X.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),V.ISO8859_6=new V(X.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),V.ISO8859_7=new V(X.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),V.ISO8859_8=new V(X.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),V.ISO8859_9=new V(X.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),V.ISO8859_10=new V(X.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),V.ISO8859_11=new V(X.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),V.ISO8859_13=new V(X.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),V.ISO8859_14=new V(X.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),V.ISO8859_15=new V(X.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),V.ISO8859_16=new V(X.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),V.SJIS=new V(X.SJIS,20,"SJIS","Shift_JIS"),V.Cp1250=new V(X.Cp1250,21,"Cp1250","windows-1250"),V.Cp1251=new V(X.Cp1251,22,"Cp1251","windows-1251"),V.Cp1252=new V(X.Cp1252,23,"Cp1252","windows-1252"),V.Cp1256=new V(X.Cp1256,24,"Cp1256","windows-1256"),V.UnicodeBigUnmarked=new V(X.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),V.UTF8=new V(X.UTF8,26,"UTF8","UTF-8"),V.ASCII=new V(X.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),V.Big5=new V(X.Big5,28,"Big5"),V.GB18030=new V(X.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),V.EUC_KR=new V(X.EUC_KR,30,"EUC_KR","EUC-KR");class se extends m{}se.kind="UnsupportedOperationException";class Ee{static decode(n,r){const s=this.encodingName(r);return this.customDecoder?this.customDecoder(n,s):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(s)?this.decodeFallback(n,s):new TextDecoder(s).decode(n)}static shouldDecodeOnFallback(n){return!Ee.isBrowser()&&n==="ISO-8859-1"}static encode(n,r){const s=this.encodingName(r);return this.customEncoder?this.customEncoder(n,s):typeof TextEncoder>"u"?this.encodeFallback(n):new TextEncoder().encode(n)}static isBrowser(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"}static encodingName(n){return typeof n=="string"?n:n.getName()}static encodingCharacterSet(n){return n instanceof V?n:V.getCharacterSetECIByName(n)}static decodeFallback(n,r){const s=this.encodingCharacterSet(r);if(Ee.isDecodeFallbackSupported(s)){let o="";for(let a=0,u=n.length;a<u;a++){let d=n[a].toString(16);d.length<2&&(d="0"+d),o+="%"+d}return decodeURIComponent(o)}if(s.equals(V.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(n.buffer));throw new se(`Encoding ${this.encodingName(r)} not supported by fallback.`)}static isDecodeFallbackSupported(n){return n.equals(V.UTF8)||n.equals(V.ISO8859_1)||n.equals(V.ASCII)}static encodeFallback(n){const s=btoa(unescape(encodeURIComponent(n))).split(""),o=[];for(let a=0;a<s.length;a++)o.push(s[a].charCodeAt(0));return new Uint8Array(o)}}class ie{static castAsNonUtf8Char(n,r=null){const s=r?r.getName():this.ISO88591;return Ee.decode(new Uint8Array([n]),s)}static guessEncoding(n,r){if(r!=null&&r.get(U.CHARACTER_SET)!==void 0)return r.get(U.CHARACTER_SET).toString();const s=n.length;let o=!0,a=!0,u=!0,d=0,h=0,g=0,x=0,E=0,A=0,I=0,b=0,D=0,L=0,z=0;const q=n.length>3&&n[0]===239&&n[1]===187&&n[2]===191;for(let $=0;$<s&&(o||a||u);$++){const Z=n[$]&255;u&&(d>0?Z&128?d--:u=!1:Z&128&&(Z&64?(d++,Z&32?(d++,Z&16?(d++,Z&8?u=!1:x++):g++):h++):u=!1)),o&&(Z>127&&Z<160?o=!1:Z>159&&(Z<192||Z===215||Z===247)&&z++),a&&(E>0?Z<64||Z===127||Z>252?a=!1:E--:Z===128||Z===160||Z>239?a=!1:Z>160&&Z<224?(A++,b=0,I++,I>D&&(D=I)):Z>127?(E++,I=0,b++,b>L&&(L=b)):(I=0,b=0))}return u&&d>0&&(u=!1),a&&E>0&&(a=!1),u&&(q||h+g+x>0)?ie.UTF8:a&&(ie.ASSUME_SHIFT_JIS||D>=3||L>=3)?ie.SHIFT_JIS:o&&a?D===2&&A===2||z*10>=s?ie.SHIFT_JIS:ie.ISO88591:o?ie.ISO88591:a?ie.SHIFT_JIS:u?ie.UTF8:ie.PLATFORM_DEFAULT_ENCODING}static format(n,...r){let s=-1;function o(u,d,h,g,x,E){if(u==="%%")return"%";if(r[++s]===void 0)return;u=g?parseInt(g.substr(1)):void 0;let A=x?parseInt(x.substr(1)):void 0,I;switch(E){case"s":I=r[s];break;case"c":I=r[s][0];break;case"f":I=parseFloat(r[s]).toFixed(u);break;case"p":I=parseFloat(r[s]).toPrecision(u);break;case"e":I=parseFloat(r[s]).toExponential(u);break;case"x":I=parseInt(r[s]).toString(A||16);break;case"d":I=parseFloat(parseInt(r[s],A||10).toPrecision(u)).toFixed(0);break}I=typeof I=="object"?JSON.stringify(I):(+I).toString(A);let b=parseInt(h),D=h&&h[0]+""=="0"?"0":" ";for(;I.length<b;)I=d!==void 0?I+D:D+I;return I}let a=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return n.replace(a,o)}static getBytes(n,r){return Ee.encode(n,r)}static getCharCode(n,r=0){return n.charCodeAt(r)}static getCharAt(n){return String.fromCharCode(n)}}ie.SHIFT_JIS=V.SJIS.getName(),ie.GB2312="GB2312",ie.ISO88591=V.ISO8859_1.getName(),ie.EUC_JP="EUC_JP",ie.UTF8=V.UTF8.getName(),ie.PLATFORM_DEFAULT_ENCODING=ie.UTF8,ie.ASSUME_SHIFT_JIS=!1;class ge{constructor(n=""){this.value=n}enableDecoding(n){return this.encoding=n,this}append(n){return typeof n=="string"?this.value+=n.toString():this.encoding?this.value+=ie.castAsNonUtf8Char(n,this.encoding):this.value+=String.fromCharCode(n),this}appendChars(n,r,s){for(let o=r;r<r+s;o++)this.append(n[o]);return this}length(){return this.value.length}charAt(n){return this.value.charAt(n)}deleteCharAt(n){this.value=this.value.substr(0,n)+this.value.substring(n+1)}setCharAt(n,r){this.value=this.value.substr(0,n)+r+this.value.substr(n+1)}substring(n,r){return this.value.substring(n,r)}setLengthToZero(){this.value=""}toString(){return this.value}insert(n,r){this.value=this.value.substr(0,n)+r+this.value.substr(n+r.length)}}class _e{constructor(n,r,s,o){if(this.width=n,this.height=r,this.rowSize=s,this.bits=o,r==null&&(r=n),this.height=r,n<1||r<1)throw new v("Both dimensions must be greater than 0");s==null&&(s=Math.floor((n+31)/32)),this.rowSize=s,o==null&&(this.bits=new Int32Array(this.rowSize*this.height))}static parseFromBooleanArray(n){const r=n.length,s=n[0].length,o=new _e(s,r);for(let a=0;a<r;a++){const u=n[a];for(let d=0;d<s;d++)u[d]&&o.set(d,a)}return o}static parseFromString(n,r,s){if(n===null)throw new v("stringRepresentation cannot be null");const o=new Array(n.length);let a=0,u=0,d=-1,h=0,g=0;for(;g<n.length;)if(n.charAt(g)===`
59
+ */var za=Ct,cx=ux;function fx(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var dx=typeof Object.is=="function"?Object.is:fx,hx=cx.useSyncExternalStore,gx=za.useRef,px=za.useEffect,xx=za.useMemo,mx=za.useDebugValue;ph.useSyncExternalStoreWithSelector=function(e,t,i,l,c){var f=gx(null);if(f.current===null){var p={hasValue:!1,value:null};f.current=p}else p=f.current;f=xx(function(){function C(M){if(!m){if(m=!0,_=M,M=l(M),c!==void 0&&p.hasValue){var P=p.value;if(c(P,M))return v=P}return v=M}if(P=v,dx(_,M))return P;var B=l(M);return c!==void 0&&c(P,B)?(_=M,P):(_=M,v=B)}var m=!1,_,v,R=i===void 0?null:i;return[function(){return C(t())},R===null?void 0:function(){return C(R())}]},[t,i,l,c]);var w=hx(e,f[0],f[1]);return px(function(){p.hasValue=!0,p.value=w},[w]),mx(w),w};gh.exports=ph;var wx=gh.exports;const yx=J0(wx),wh={},{useDebugValue:Ex}=vg,{useSyncExternalStoreWithSelector:Cx}=yx;let N0=!1;const Ax=e=>e;function vx(e,t=Ax,i){(wh?"production":void 0)!=="production"&&i&&!N0&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),N0=!0);const l=Cx(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,i);return Ex(l),l}const R0=e=>{(wh?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?Jp(e):e,i=(l,c)=>vx(t,l,c);return Object.assign(i,t),i},Sx=e=>e?R0(e):R0,Ix={};function _x(e,t){let i;try{i=e()}catch{return}return{getItem:c=>{var f;const p=C=>C===null?null:JSON.parse(C,void 0),w=(f=i.getItem(c))!=null?f:null;return w instanceof Promise?w.then(p):p(w)},setItem:(c,f)=>i.setItem(c,JSON.stringify(f,void 0)),removeItem:c=>i.removeItem(c)}}const qs=e=>t=>{try{const i=e(t);return i instanceof Promise?i:{then(l){return qs(l)(i)},catch(l){return this}}}catch(i){return{then(l){return this},catch(l){return qs(l)(i)}}}},Tx=(e,t)=>(i,l,c)=>{let f={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:K=>K,version:0,merge:(K,O)=>({...O,...K}),...t},p=!1;const w=new Set,C=new Set;let m;try{m=f.getStorage()}catch{}if(!m)return e((...K)=>{console.warn(`[zustand persist middleware] Unable to update item '${f.name}', the given storage is currently unavailable.`),i(...K)},l,c);const _=qs(f.serialize),v=()=>{const K=f.partialize({...l()});let O;const T=_({state:K,version:f.version}).then(N=>m.setItem(f.name,N)).catch(N=>{O=N});if(O)throw O;return T},R=c.setState;c.setState=(K,O)=>{R(K,O),v()};const M=e((...K)=>{i(...K),v()},l,c);let P;const B=()=>{var K;if(!m)return;p=!1,w.forEach(T=>T(l()));const O=((K=f.onRehydrateStorage)==null?void 0:K.call(f,l()))||void 0;return qs(m.getItem.bind(m))(f.name).then(T=>{if(T)return f.deserialize(T)}).then(T=>{if(T)if(typeof T.version=="number"&&T.version!==f.version){if(f.migrate)return f.migrate(T.state,T.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return T.state}).then(T=>{var N;return P=f.merge(T,(N=l())!=null?N:M),i(P,!0),v()}).then(()=>{O==null||O(P,void 0),p=!0,C.forEach(T=>T(P))}).catch(T=>{O==null||O(void 0,T)})};return c.persist={setOptions:K=>{f={...f,...K},K.getStorage&&(m=K.getStorage())},clearStorage:()=>{m==null||m.removeItem(f.name)},getOptions:()=>f,rehydrate:()=>B(),hasHydrated:()=>p,onHydrate:K=>(w.add(K),()=>{w.delete(K)}),onFinishHydration:K=>(C.add(K),()=>{C.delete(K)})},B(),P||M},Nx=(e,t)=>(i,l,c)=>{let f={storage:_x(()=>localStorage),partialize:B=>B,version:0,merge:(B,K)=>({...K,...B}),...t},p=!1;const w=new Set,C=new Set;let m=f.storage;if(!m)return e((...B)=>{console.warn(`[zustand persist middleware] Unable to update item '${f.name}', the given storage is currently unavailable.`),i(...B)},l,c);const _=()=>{const B=f.partialize({...l()});return m.setItem(f.name,{state:B,version:f.version})},v=c.setState;c.setState=(B,K)=>{v(B,K),_()};const R=e((...B)=>{i(...B),_()},l,c);c.getInitialState=()=>R;let M;const P=()=>{var B,K;if(!m)return;p=!1,w.forEach(T=>{var N;return T((N=l())!=null?N:R)});const O=((K=f.onRehydrateStorage)==null?void 0:K.call(f,(B=l())!=null?B:R))||void 0;return qs(m.getItem.bind(m))(f.name).then(T=>{if(T)if(typeof T.version=="number"&&T.version!==f.version){if(f.migrate)return[!0,f.migrate(T.state,T.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,T.state];return[!1,void 0]}).then(T=>{var N;const[G,H]=T;if(M=f.merge(H,(N=l())!=null?N:R),i(M,!0),G)return _()}).then(()=>{O==null||O(M,void 0),M=l(),p=!0,C.forEach(T=>T(M))}).catch(T=>{O==null||O(void 0,T)})};return c.persist={setOptions:B=>{f={...f,...B},B.storage&&(m=B.storage)},clearStorage:()=>{m==null||m.removeItem(f.name)},getOptions:()=>f,rehydrate:()=>P(),hasHydrated:()=>p,onHydrate:B=>(w.add(B),()=>{w.delete(B)}),onFinishHydration:B=>(C.add(B),()=>{C.delete(B)})},f.skipHydration||P(),M||R},Rx=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((Ix?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),Tx(e,t)):Nx(e,t),bx=Rx;function Ox(){return typeof document<"u"&&document.body.dataset.webShell==="1"}function yh(){return typeof navigator>"u"?!1:Ox()||!/Electron\//i.test(navigator.userAgent)}function iw(e=900){const[t,i]=Ct.useState(()=>typeof window<"u"&&window.innerWidth<e);return Ct.useEffect(()=>{const l=window.matchMedia(`(max-width: ${e-1}px)`),c=f=>i(f.matches);return i(l.matches),l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[e]),t}const sw=[{id:"pearl",label:"珍珠白",preview:["#f5f6fa","#4f6ef7"]},{id:"scifi",label:"科幻霓虹",preview:["#050a14","#22d3ee"]},{id:"noir",label:"暗夜黑",preview:["#0f1115","#a78bfa"]}],ow=[{id:"standard",label:"标准",description:"侧边栏 + 对话区"},{id:"focus",label:"专注",description:"隐藏侧边栏,居中沉浸对话"},{id:"compact",label:"紧凑",description:"更小间距与字号,信息密度优先"}],Eh=4;function Ch(e){return Array.isArray(e)?[...new Set(e.filter(t=>typeof t=="string"&&t.length>0))]:[]}function Dx(e,t){const i=e??{};return{...i.skin!==void 0?{skin:i.skin}:{},...i.layout!==void 0?{layout:i.layout}:{},...i.autoSpeak!==void 0?{autoSpeak:i.autoSpeak}:{},...i.wakeEnabled!==void 0?{wakeEnabled:i.wakeEnabled}:{},...i.wakeWord!==void 0?{wakeWord:i.wakeWord}:{},...i.runningFirst!==void 0?{runningFirst:i.runningFirst}:{},pinnedSessionIds:Ch(i.pinnedSessionIds),...t<Eh&&yh()?{wakeEnabled:!1}:{}}}function Mx(e=yh()){return!e}const kx=Sx()(bx(e=>({skin:"pearl",layout:"standard",autoSpeak:!1,wakeEnabled:Mx(),wakeWord:"小智",runningFirst:!1,pinnedSessionIds:[],setSkin:t=>e({skin:t}),setLayout:t=>e({layout:t}),setAutoSpeak:t=>e({autoSpeak:t}),setWakeEnabled:t=>e({wakeEnabled:t}),setWakeWord:t=>e({wakeWord:t}),setRunningFirst:t=>e({runningFirst:t}),togglePinnedSession:t=>e(i=>({pinnedSessionIds:i.pinnedSessionIds.includes(t)?i.pinnedSessionIds.filter(l=>l!==t):Ch([...i.pinnedSessionIds,t])})),removePinnedSessions:t=>e(i=>{const l=new Set(t);return{pinnedSessionIds:i.pinnedSessionIds.filter(c=>!l.has(c))}})}),{name:"agent-ui-prefs",version:Eh,migrate:Dx})),Px="agent-web-shell:skin:v1",Bx=["pearl","scifi","noir"];function Lx(){if(window.parent===window)return()=>{};const e=t=>{if(t.origin!==window.location.origin||t.source!==window.parent)return;const i=t.data;!i||typeof i!="object"||i.type!==Px||typeof i.skin!="string"||!Bx.includes(i.skin)||kx.getState().setSkin(i.skin)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}const Fx="agentroam:open-browser-live",Ux="agent-web-shell:open-browser-live:v1";function Wx(){if(window.parent===window)return()=>{};const e=t=>{if(t.origin!==window.location.origin||t.source!==window.parent)return;const i=t.data;!i||typeof i!="object"||i.type!==Ux||window.dispatchEvent(new CustomEvent(Fx))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}const zx="agent-webapp:ready:v1";function Vx(){window.parent!==window&&window.parent.postMessage({type:zx},window.location.origin)}const Hx="agent-webapp:project-request:v1",jx="agent-web-shell:project-response:v1",Gx=["project:list","project:get","project:create","project:rename","project:delete","project:roots","project:directories","project:check"];new Set(Gx);function Xx(e){if(!e||typeof e!="object")return null;const t=e;return t.type!==jx||!Number.isSafeInteger(t.id)||Number(t.id)<1||typeof t.ok!="boolean"||!t.ok&&typeof t.error!="string"?null:t}class Yx{constructor(t=window,i=15e3){this.context=t,this.timeoutMs=i,this.sequence=0,this.pending=new Map,this.onMessage=l=>{if(l.origin!==this.context.location.origin||l.source!==this.context.parent)return;const c=Xx(l.data);if(!c)return;const f=this.pending.get(c.id);f&&(this.pending.delete(c.id),clearTimeout(f.timer),c.ok?f.resolve(c.result):f.reject(Object.assign(new Error(c.error||"项目操作失败"),{code:c.code})))},this.context.addEventListener("message",this.onMessage)}request(t,i={}){if(this.context.parent===this.context)return Promise.reject(Object.assign(new Error("请从 AgentRoam Web 控制台打开项目"),{code:"WEB_SHELL_REQUIRED"}));const l=++this.sequence;return new Promise((c,f)=>{const p=setTimeout(()=>{this.pending.delete(l),f(Object.assign(new Error("项目操作超时"),{code:"WEB_SHELL_TIMEOUT"}))},this.timeoutMs);this.pending.set(l,{resolve:c,reject:f,timer:p}),this.context.parent.postMessage({type:Hx,id:l,method:t,payload:i},this.context.location.origin)})}dispose(){this.context.removeEventListener("message",this.onMessage);for(const t of this.pending.values())clearTimeout(t.timer),t.reject(Object.assign(new Error("项目桥已关闭"),{code:"WEB_SHELL_CLOSED"}));this.pending.clear()}}const Zx="agent-webapp:browser-request:v1",Kx="agent-web-shell:browser-response:v1",Qx="agent-web-shell:browser-event:v1",qx="agent-web-shell:browser-frame:v1",$x=["browser:list","browser:watch","browser:unwatch","browser:takeover","browser:return","browser:input","browser:set-display","browser:ping","browser:webrtc"];new Set($x);function Jx(e){if(!e||typeof e!="object")return null;const t=e;return t.type!==Kx||!Number.isSafeInteger(t.id)||Number(t.id)<1||typeof t.ok!="boolean"||!t.ok&&typeof t.error!="string"?null:t}function em(e){if(!e||typeof e!="object")return null;const t=e;if(t.type!==Qx||!t.event||typeof t.event!="object")return null;const i=t.event;return typeof i.type!="string"||!i.type.startsWith("browser:")?null:t}function tm(e){if(!e||typeof e!="object")return null;const t=e;return t.type!==qx||!Number.isSafeInteger(t.channelId)||Number(t.channelId)<1||!Number.isSafeInteger(t.sequence)||Number(t.sequence)<0||!(t.data instanceof ArrayBuffer)?null:t}class nm{constructor(t=window,i=15e3){this.context=t,this.timeoutMs=i,this.sequence=0,this.pending=new Map,this.listeners=new Set,this.sessionsByChannel=new Map,this.pendingFramesByChannel=new Map,this.onMessage=l=>{var C;if(l.origin!==this.context.location.origin||l.source!==this.context.parent)return;const c=tm(l.data);if(c){const m=this.sessionsByChannel.get(c.channelId);if(!m){this.pendingFramesByChannel.set(c.channelId,c);return}this.emitBinaryFrame(c,m);return}const f=em(l.data);if(f){for(const m of this.listeners)m(f.event);return}const p=Jx(l.data);if(!p)return;const w=this.pending.get(p.id);if(w)if(this.pending.delete(p.id),clearTimeout(w.timer),p.ok){if(w.method==="browser:watch"&&p.result&&typeof p.result=="object"){const m=p.result;if(Number.isSafeInteger(m.channelId)&&typeof((C=m.session)==null?void 0:C.id)=="string"){const _=Number(m.channelId);this.sessionsByChannel.set(_,m.session.id);const v=this.pendingFramesByChannel.get(_);v&&(this.pendingFramesByChannel.delete(_),this.emitBinaryFrame(v,m.session.id))}}w.resolve(p.result)}else w.reject(Object.assign(new Error(p.error||"浏览器操作失败"),{code:p.code}))},this.context.addEventListener("message",this.onMessage)}emitBinaryFrame(t,i){for(const l of this.listeners)l({type:"browser:frame",sessionId:i,sequence:t.sequence,data:t.data,mime:"image/jpeg",timestamp:Date.now()})}request(t,i={}){if(this.context.parent===this.context)return Promise.reject(Object.assign(new Error("请从 AgentRoam Web 控制台打开浏览器直播"),{code:"WEB_SHELL_REQUIRED"}));const l=++this.sequence;return new Promise((c,f)=>{const p=setTimeout(()=>{this.pending.delete(l),f(Object.assign(new Error("浏览器操作超时"),{code:"WEB_SHELL_TIMEOUT"}))},this.timeoutMs);this.pending.set(l,{resolve:c,reject:f,timer:p,method:t}),this.context.parent.postMessage({type:Zx,id:l,method:t,payload:i},this.context.location.origin)})}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}dispose(){this.context.removeEventListener("message",this.onMessage);for(const t of this.pending.values())clearTimeout(t.timer),t.reject(Object.assign(new Error("浏览器桥已关闭"),{code:"WEB_SHELL_CLOSED"}));this.pending.clear(),this.listeners.clear(),this.sessionsByChannel.clear(),this.pendingFramesByChannel.clear()}}class br{constructor(t){this.url=t}static parse(t){const i=t.trim();if(!i)return null;const l=/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(i)?i:`http://${i}`;let c;try{c=new URL(l)}catch{return null}return c.protocol!=="http:"&&c.protocol!=="https:"||!c.hostname?null:new br(`${c.protocol}//${c.host}`)}toString(){return this.url}api(t){return`${this.url}${t.startsWith("/")?t:`/${t}`}`}}class rm{constructor(t,i,l){this.environment=t,this.storage=i,this.probe=l}async planStartup(){if(!this.environment.isNativeApp())return{mode:"same-origin"};const t=this.launchEndpoint();if(t)return{mode:"ready",endpoint:t};const i=this.storage.load();if(i){const l=await this.probe.probe(i);return l.ok?{mode:"ready",endpoint:i}:{mode:"setup",endpoint:i,failure:l.reason}}return{mode:"setup",endpoint:null}}async connect(t){const i=br.parse(t);if(!i)return{ok:!1,reason:"地址无效,请输入 http(s)://host:port 形式的服务器地址"};const l=await this.probe.probe(i);return l.ok?(this.storage.save(i),{ok:!0,endpoint:i}):{ok:!1,reason:`无法连接服务器:${l.reason}`}}disconnect(){this.storage.clear()}launchEndpoint(){const t=this.environment.launchServerUrl();return t?br.parse(t):null}}function b0(){return window.Capacitor??null}class im{isNativeApp(){var t,i;return((i=(t=b0())==null?void 0:t.isNativePlatform)==null?void 0:i.call(t))??!1}platform(){var i,l;const t=(l=(i=b0())==null?void 0:i.getPlatform)==null?void 0:l.call(i);return t==="ios"||t==="android"?t:"web"}launchServerUrl(){const t=new URLSearchParams(window.location.search).get("server");return t&&t.trim()?t.trim():null}}const Ul="webapp.mobile.serverEndpoint.v1";class O0{load(){try{const t=localStorage.getItem(Ul);return t?br.parse(t):null}catch{return null}}save(t){localStorage.setItem(Ul,t.toString())}clear(){localStorage.removeItem(Ul)}}const sm=6e3;class om{constructor(t=(...i)=>fetch(...i)){this.transport=t}async probe(t,i=sm){const l=new AbortController,c=setTimeout(()=>l.abort(),i);try{const f=await this.transport(t.api("/api/agent/model"),{method:"GET",cache:"no-store",signal:l.signal});return f.ok?{ok:!0,modelId:(await f.json()).modelId??null}:{ok:!1,reason:f.status===401?"此 App 尚未授权,请扫描电脑上的授权二维码。":f.status===423?"电脑已锁定远程访问,请先在电脑上解锁。":`HTTP ${f.status}`}}catch(f){return{ok:!1,reason:f instanceof DOMException&&f.name==="AbortError"?"连接超时":am(f)}}finally{clearTimeout(c)}}}function am(e){return(e instanceof Error?e.message:String(e))||"网络错误"}function lm({service:e,savedEndpoint:t,initialFailure:i,onConnected:l,onScan:c}){const[f,p]=Ct.useState((t==null?void 0:t.toString())??""),[w,C]=Ct.useState(i??""),[m,_]=Ct.useState(!1);async function v(){if(!(m||!c)){_(!0),C("");try{const M=await c();M&&l(M)}catch(M){C(M instanceof Error?M.message:"扫码连接失败,请重试。")}finally{_(!1)}}}async function R(){if(!m){_(!0),C("");try{const M=await e.connect(f);M.ok?l(M.endpoint):C(M.reason)}catch{C("连接失败,请检查网络或重新扫码授权。")}finally{_(!1)}}}return ae.jsx("div",{style:Wn.page,children:ae.jsxs("div",{style:Wn.card,children:[ae.jsx("div",{style:Wn.icon,children:"🛰️"}),ae.jsx("h1",{style:Wn.title,children:"连接服务器"}),c?ae.jsxs(ae.Fragment,{children:[ae.jsx("p",{style:Wn.hint,children:"扫描电脑终端上的授权二维码,直接连接,无需再次确认。"}),ae.jsx("button",{type:"button",style:{...Wn.button,marginBottom:20},disabled:m,onClick:()=>void v(),children:m?"正在连接…":"扫码连接"})]}):null,ae.jsx("p",{style:Wn.hint,children:"也可以输入已授权的服务器地址。使用局域网地址时,手机与电脑需在同一网络。"}),ae.jsx("input",{style:Wn.input,value:f,inputMode:"url",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,placeholder:"http://192.168.1.10:3000",onChange:M=>p(M.target.value),onKeyDown:M=>{M.key==="Enter"&&R()}}),w?ae.jsx("p",{style:Wn.error,children:w}):null,ae.jsx("button",{style:{...Wn.button,opacity:m||!f.trim()?.6:1},disabled:m,onClick:()=>void R(),children:m?"正在连接…":"连接"})]})})}const Wn={page:{minHeight:"100dvh",display:"flex",alignItems:"center",justifyContent:"center",background:"#f5f6fa",padding:24,boxSizing:"border-box"},card:{width:"100%",maxWidth:420,background:"#fff",borderRadius:16,padding:"32px 24px",boxShadow:"0 8px 32px rgba(0,0,0,0.08)",textAlign:"center"},icon:{fontSize:40,marginBottom:8},title:{fontSize:20,margin:"0 0 8px",color:"#1c1e26"},hint:{fontSize:13,lineHeight:1.6,color:"#6b7280",margin:"0 0 20px"},input:{width:"100%",boxSizing:"border-box",padding:"12px 14px",fontSize:16,borderRadius:10,border:"1px solid #d6d9e0",outline:"none",marginBottom:12},error:{fontSize:13,color:"#dc2626",margin:"0 0 12px",textAlign:"left"},button:{width:"100%",padding:"12px 0",fontSize:16,fontWeight:600,color:"#fff",background:"#4f6ef7",border:"none",borderRadius:10,cursor:"pointer"}};/*! Capacitor: https://capacitorjs.com/ - MIT License */var Xi;(function(e){e.Unimplemented="UNIMPLEMENTED",e.Unavailable="UNAVAILABLE"})(Xi||(Xi={}));class Wl extends Error{constructor(t,i,l){super(t),this.message=t,this.code=i,this.data=l}}const um=e=>{var t,i;return e!=null&&e.androidBridge?"android":!((i=(t=e==null?void 0:e.webkit)===null||t===void 0?void 0:t.messageHandlers)===null||i===void 0)&&i.bridge?"ios":"web"},cm=e=>{const t=e.CapacitorCustomPlatform||null,i=e.Capacitor||{},l=i.Plugins=i.Plugins||{},c=()=>t!==null?t.name:um(e),f=()=>c()!=="web",p=v=>{const R=m.get(v);return!!(R!=null&&R.platforms.has(c())||w(v))},w=v=>{var R;return(R=i.PluginHeaders)===null||R===void 0?void 0:R.find(M=>M.name===v)},C=v=>e.console.error(v),m=new Map,_=(v,R={})=>{const M=m.get(v);if(M)return console.warn(`Capacitor plugin "${v}" already registered. Cannot register plugins twice.`),M.proxy;const P=c(),B=w(v);let K;const O=async()=>(!K&&P in R?K=typeof R[P]=="function"?K=await R[P]():K=R[P]:t!==null&&!K&&"web"in R&&(K=typeof R.web=="function"?K=await R.web():K=R.web),K),T=(X,V)=>{var se,Ee;if(B){const ie=B==null?void 0:B.methods.find(ge=>V===ge.name);if(ie)return ie.rtype==="promise"?ge=>i.nativePromise(v,V.toString(),ge):(ge,_e)=>i.nativeCallback(v,V.toString(),ge,_e);if(X)return(se=X[V])===null||se===void 0?void 0:se.bind(X)}else{if(X)return(Ee=X[V])===null||Ee===void 0?void 0:Ee.bind(X);throw new Wl(`"${v}" plugin is not implemented on ${P}`,Xi.Unimplemented)}},N=X=>{let V;const se=(...Ee)=>{const ie=O().then(ge=>{const _e=T(ge,X);if(_e){const j=_e(...Ee);return V=j==null?void 0:j.remove,j}else throw new Wl(`"${v}.${X}()" is not implemented on ${P}`,Xi.Unimplemented)});return X==="addListener"&&(ie.remove=async()=>V()),ie};return se.toString=()=>`${X.toString()}() { [capacitor code] }`,Object.defineProperty(se,"name",{value:X,writable:!1,configurable:!1}),se},G=N("addListener"),H=N("removeListener"),U=(X,V)=>{const se=G({eventName:X},V),Ee=async()=>{const ge=await se;H({eventName:X,callbackId:ge},V)},ie=new Promise(ge=>se.then(()=>ge({remove:Ee})));return ie.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await Ee()},ie},k=new Proxy({},{get(X,V){switch(V){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return B?U:G;case"removeListener":return H;default:return N(V)}}});return l[v]=k,m.set(v,{name:v,proxy:k,platforms:new Set([...Object.keys(R),...B?[P]:[]])}),k};return i.convertFileSrc||(i.convertFileSrc=v=>v),i.getPlatform=c,i.handleError=C,i.isNativePlatform=f,i.isPluginAvailable=p,i.registerPlugin=_,i.Exception=Wl,i.DEBUG=!!i.DEBUG,i.isLoggingEnabled=!!i.isLoggingEnabled,i},fm=e=>e.Capacitor=cm(e),$s=fm(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Va=$s.registerPlugin;class Ah{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(t,i){let l=!1;this.listeners[t]||(this.listeners[t]=[],l=!0),this.listeners[t].push(i);const f=this.windowListeners[t];f&&!f.registered&&this.addWindowListener(f),l&&this.sendRetainedArgumentsForEvent(t);const p=async()=>this.removeListener(t,i);return Promise.resolve({remove:p})}async removeAllListeners(){this.listeners={};for(const t in this.windowListeners)this.removeWindowListener(this.windowListeners[t]);this.windowListeners={}}notifyListeners(t,i,l){const c=this.listeners[t];if(!c){if(l){let f=this.retainedEventArguments[t];f||(f=[]),f.push(i),this.retainedEventArguments[t]=f}return}c.forEach(f=>f(i))}hasListeners(t){var i;return!!(!((i=this.listeners[t])===null||i===void 0)&&i.length)}registerWindowListener(t,i){this.windowListeners[i]={registered:!1,windowEventName:t,pluginEventName:i,handler:l=>{this.notifyListeners(i,l)}}}unimplemented(t="not implemented"){return new $s.Exception(t,Xi.Unimplemented)}unavailable(t="not available"){return new $s.Exception(t,Xi.Unavailable)}async removeListener(t,i){const l=this.listeners[t];if(!l)return;const c=l.indexOf(i);this.listeners[t].splice(c,1),this.listeners[t].length||this.removeWindowListener(this.windowListeners[t])}addWindowListener(t){window.addEventListener(t.windowEventName,t.handler),t.registered=!0}removeWindowListener(t){t&&(window.removeEventListener(t.windowEventName,t.handler),t.registered=!1)}sendRetainedArgumentsForEvent(t){const i=this.retainedEventArguments[t];i&&(delete this.retainedEventArguments[t],i.forEach(l=>{this.notifyListeners(t,l)}))}}const D0=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),M0=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class dm extends Ah{async getCookies(){const t=document.cookie,i={};return t.split(";").forEach(l=>{if(l.length<=0)return;let[c,f]=l.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");c=M0(c).trim(),f=M0(f).trim(),i[c]=f}),i}async setCookie(t){try{const i=D0(t.key),l=D0(t.value),c=t.expires?`; expires=${t.expires.replace("expires=","")}`:"",f=(t.path||"/").replace("path=",""),p=t.url!=null&&t.url.length>0?`domain=${t.url}`:"";document.cookie=`${i}=${l||""}${c}; path=${f}; ${p};`}catch(i){return Promise.reject(i)}}async deleteCookie(t){try{document.cookie=`${t.key}=; Max-Age=0`}catch(i){return Promise.reject(i)}}async clearCookies(){try{const t=document.cookie.split(";")||[];for(const i of t)document.cookie=i.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(t){return Promise.reject(t)}}async clearAllCookies(){try{await this.clearCookies()}catch(t){return Promise.reject(t)}}}Va("CapacitorCookies",{web:()=>new dm});const hm=async e=>new Promise((t,i)=>{const l=new FileReader;l.onload=()=>{const c=l.result;t(c.indexOf(",")>=0?c.split(",")[1]:c)},l.onerror=c=>i(c),l.readAsDataURL(e)}),gm=(e={})=>{const t=Object.keys(e);return Object.keys(e).map(c=>c.toLocaleLowerCase()).reduce((c,f,p)=>(c[f]=e[t[p]],c),{})},pm=(e,t=!0)=>e?Object.entries(e).reduce((l,c)=>{const[f,p]=c;let w,C;return Array.isArray(p)?(C="",p.forEach(m=>{w=t?encodeURIComponent(m):m,C+=`${f}=${w}&`}),C.slice(0,-1)):(w=t?encodeURIComponent(p):p,C=`${f}=${w}`),`${l}&${C}`},"").substr(1):null,xm=(e,t={})=>{const i=Object.assign({method:e.method||"GET",headers:e.headers},t),c=gm(e.headers)["content-type"]||"";if(typeof e.data=="string")i.body=e.data;else if(c.includes("application/x-www-form-urlencoded")){const f=new URLSearchParams;for(const[p,w]of Object.entries(e.data||{}))f.set(p,w);i.body=f.toString()}else if(c.includes("multipart/form-data")||e.data instanceof FormData){const f=new FormData;if(e.data instanceof FormData)e.data.forEach((w,C)=>{f.append(C,w)});else for(const w of Object.keys(e.data))f.append(w,e.data[w]);i.body=f;const p=new Headers(i.headers);p.delete("content-type"),i.headers=p}else(c.includes("application/json")||typeof e.data=="object")&&(i.body=JSON.stringify(e.data));return i};class mm extends Ah{async request(t){const i=xm(t,t.webFetchExtra),l=pm(t.params,t.shouldEncodeUrlParams),c=l?`${t.url}?${l}`:t.url,f=await fetch(c,i),p=f.headers.get("content-type")||"";let{responseType:w="text"}=f.ok?t:{};p.includes("application/json")&&(w="json");let C,m;switch(w){case"arraybuffer":case"blob":m=await f.blob(),C=await hm(m);break;case"json":C=await f.json();break;case"document":case"text":default:C=await f.text()}const _={};return f.headers.forEach((v,R)=>{_[R]=v}),{data:C,headers:_,status:f.status,url:f.url}}async get(t){return this.request(Object.assign(Object.assign({},t),{method:"GET"}))}async post(t){return this.request(Object.assign(Object.assign({},t),{method:"POST"}))}async put(t){return this.request(Object.assign(Object.assign({},t),{method:"PUT"}))}async patch(t){return this.request(Object.assign(Object.assign({},t),{method:"PATCH"}))}async delete(t){return this.request(Object.assign(Object.assign({},t),{method:"DELETE"}))}}Va("CapacitorHttp",{web:()=>new mm});var te;(function(e){e[e.QR_CODE=0]="QR_CODE",e[e.AZTEC=1]="AZTEC",e[e.CODABAR=2]="CODABAR",e[e.CODE_39=3]="CODE_39",e[e.CODE_93=4]="CODE_93",e[e.CODE_128=5]="CODE_128",e[e.DATA_MATRIX=6]="DATA_MATRIX",e[e.MAXICODE=7]="MAXICODE",e[e.ITF=8]="ITF",e[e.EAN_13=9]="EAN_13",e[e.EAN_8=10]="EAN_8",e[e.PDF_417=11]="PDF_417",e[e.RSS_14=12]="RSS_14",e[e.RSS_EXPANDED=13]="RSS_EXPANDED",e[e.UPC_A=14]="UPC_A",e[e.UPC_E=15]="UPC_E",e[e.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(te||(te={}));var k0=new Map([[te.QR_CODE,"QR_CODE"],[te.AZTEC,"AZTEC"],[te.CODABAR,"CODABAR"],[te.CODE_39,"CODE_39"],[te.CODE_93,"CODE_93"],[te.CODE_128,"CODE_128"],[te.DATA_MATRIX,"DATA_MATRIX"],[te.MAXICODE,"MAXICODE"],[te.ITF,"ITF"],[te.EAN_13,"EAN_13"],[te.EAN_8,"EAN_8"],[te.PDF_417,"PDF_417"],[te.RSS_14,"RSS_14"],[te.RSS_EXPANDED,"RSS_EXPANDED"],[te.UPC_A,"UPC_A"],[te.UPC_E,"UPC_E"],[te.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),P0;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.URL=1]="URL"})(P0||(P0={}));function wm(e){return Object.values(te).includes(e)}var Ca;(function(e){e[e.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",e[e.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(Ca||(Ca={}));var ym=function(){function e(){}return e.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",e.SCAN_DEFAULT_FPS=2,e.DEFAULT_DISABLE_FLIP=!1,e.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,e.DEFAULT_SUPPORTED_SCAN_TYPE=[Ca.SCAN_TYPE_CAMERA,Ca.SCAN_TYPE_FILE],e}(),vh=function(){function e(t,i){this.format=t,this.formatName=i}return e.prototype.toString=function(){return this.formatName},e.create=function(t){if(!k0.has(t))throw"".concat(t," not in html5QrcodeSupportedFormatsTextMap");return new e(t,k0.get(t))},e}(),B0=function(){function e(){}return e.createFromText=function(t){var i={text:t};return{decodedText:t,result:i}},e.createFromQrcodeResult=function(t){return{decodedText:t.text,result:t}},e}(),Bu;(function(e){e[e.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",e[e.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",e[e.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(Bu||(Bu={}));var Em=function(){function e(){}return e.createFrom=function(t){return{errorMessage:t,type:Bu.UNKWOWN_ERROR}},e}(),Cm=function(){function e(t){this.verbose=t}return e.prototype.log=function(t){this.verbose&&console.log(t)},e.prototype.warn=function(t){this.verbose&&console.warn(t)},e.prototype.logError=function(t,i){(this.verbose||i===!0)&&console.error(t)},e.prototype.logErrors=function(t){if(t.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(t)},e}();function Xn(e){return typeof e>"u"||e===null}var Ri=function(){function e(){}return e.codeParseError=function(t){return"QR code parse error, error = ".concat(t)},e.errorGettingUserMedia=function(t){return"Error getting userMedia, error = ".concat(t)},e.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},e.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},e.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},e.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},e.scannerPaused=function(){return"Scanner paused"},e}(),Sh=function(){function e(){}return e.isMediaStreamConstraintsValid=function(t,i){if(typeof t!="object"){var l=typeof t;return i.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(l,"."),!0),!1}for(var c=["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"],f=new Set(c),p=Object.keys(t),w=0,C=p;w<C.length;w++){var m=C[w];if(f.has(m))return i.logError("".concat(m," is not supported videoConstaints."),!0),!1}return!0},e}(),Lu={exports:{}};(function(e,t){(function(i,l){l(t)})(ls,function(i){function l(y){return y==null}var c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,n){y.__proto__=n}||function(y,n){for(var r in n)n.hasOwnProperty(r)&&(y[r]=n[r])};function f(y,n){c(y,n);function r(){this.constructor=y}y.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}function p(y,n){var r=Object.setPrototypeOf;r?r(y,n):y.__proto__=n}function w(y,n){n===void 0&&(n=y.constructor);var r=Error.captureStackTrace;r&&r(y,n)}var C=function(y){f(n,y);function n(r){var s=this.constructor,o=y.call(this,r)||this;return Object.defineProperty(o,"name",{value:s.name,enumerable:!1}),p(o,s.prototype),w(o),o}return n}(Error);class m extends C{constructor(n=void 0){super(n),this.message=n}getKind(){return this.constructor.kind}}m.kind="Exception";class _ extends m{}_.kind="ArgumentException";class v extends m{}v.kind="IllegalArgumentException";class R{constructor(n){if(this.binarizer=n,n===null)throw new v("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(n,r){return this.binarizer.getBlackRow(n,r)}getBlackMatrix(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(n,r,s,o){const a=this.binarizer.getLuminanceSource().crop(n,r,s,o);return new R(this.binarizer.createBinarizer(a))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){const n=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new R(this.binarizer.createBinarizer(n))}rotateCounterClockwise45(){const n=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new R(this.binarizer.createBinarizer(n))}toString(){try{return this.getBlackMatrix().toString()}catch{return""}}}class M extends m{static getChecksumInstance(){return new M}}M.kind="ChecksumException";class P{constructor(n){this.source=n}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class B{static arraycopy(n,r,s,o,a){for(;a--;)s[o++]=n[r++]}static currentTimeMillis(){return Date.now()}}class K extends m{}K.kind="IndexOutOfBoundsException";class O extends K{constructor(n=void 0,r=void 0){super(r),this.index=n,this.message=r}}O.kind="ArrayIndexOutOfBoundsException";class T{static fill(n,r){for(let s=0,o=n.length;s<o;s++)n[s]=r}static fillWithin(n,r,s,o){T.rangeCheck(n.length,r,s);for(let a=r;a<s;a++)n[a]=o}static rangeCheck(n,r,s){if(r>s)throw new v("fromIndex("+r+") > toIndex("+s+")");if(r<0)throw new O(r);if(s>n)throw new O(s)}static asList(...n){return n}static create(n,r,s){return Array.from({length:n}).map(a=>Array.from({length:r}).fill(s))}static createInt32Array(n,r,s){return Array.from({length:n}).map(a=>Int32Array.from({length:r}).fill(s))}static equals(n,r){if(!n||!r||!n.length||!r.length||n.length!==r.length)return!1;for(let s=0,o=n.length;s<o;s++)if(n[s]!==r[s])return!1;return!0}static hashCode(n){if(n===null)return 0;let r=1;for(const s of n)r=31*r+s;return r}static fillUint8Array(n,r){for(let s=0;s!==n.length;s++)n[s]=r}static copyOf(n,r){return n.slice(0,r)}static copyOfUint8Array(n,r){if(n.length<=r){const s=new Uint8Array(r);return s.set(n),s}return n.slice(0,r)}static copyOfRange(n,r,s){const o=s-r,a=new Int32Array(o);return B.arraycopy(n,r,a,0,o),a}static binarySearch(n,r,s){s===void 0&&(s=T.numberComparator);let o=0,a=n.length-1;for(;o<=a;){const u=a+o>>1,d=s(r,n[u]);if(d>0)o=u+1;else if(d<0)a=u-1;else return u}return-o-1}static numberComparator(n,r){return n-r}}class N{static numberOfTrailingZeros(n){let r;if(n===0)return 32;let s=31;return r=n<<16,r!==0&&(s-=16,n=r),r=n<<8,r!==0&&(s-=8,n=r),r=n<<4,r!==0&&(s-=4,n=r),r=n<<2,r!==0&&(s-=2,n=r),s-(n<<1>>>31)}static numberOfLeadingZeros(n){if(n===0)return 32;let r=1;return n>>>16||(r+=16,n<<=16),n>>>24||(r+=8,n<<=8),n>>>28||(r+=4,n<<=4),n>>>30||(r+=2,n<<=2),r-=n>>>31,r}static toHexString(n){return n.toString(16)}static toBinaryString(n){return String(parseInt(String(n),2))}static bitCount(n){return n=n-(n>>>1&1431655765),n=(n&858993459)+(n>>>2&858993459),n=n+(n>>>4)&252645135,n=n+(n>>>8),n=n+(n>>>16),n&63}static truncDivision(n,r){return Math.trunc(n/r)}static parseInt(n,r=void 0){return parseInt(n,r)}}N.MIN_VALUE_32_BITS=-2147483648,N.MAX_VALUE=Number.MAX_SAFE_INTEGER;class G{constructor(n,r){n===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=n,r==null?this.bits=G.makeArray(n):this.bits=r)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(n){if(n>this.bits.length*32){const r=G.makeArray(n);B.arraycopy(this.bits,0,r,0,this.bits.length),this.bits=r}}get(n){return(this.bits[Math.floor(n/32)]&1<<(n&31))!==0}set(n){this.bits[Math.floor(n/32)]|=1<<(n&31)}flip(n){this.bits[Math.floor(n/32)]^=1<<(n&31)}getNextSet(n){const r=this.size;if(n>=r)return r;const s=this.bits;let o=Math.floor(n/32),a=s[o];a&=~((1<<(n&31))-1);const u=s.length;for(;a===0;){if(++o===u)return r;a=s[o]}const d=o*32+N.numberOfTrailingZeros(a);return d>r?r:d}getNextUnset(n){const r=this.size;if(n>=r)return r;const s=this.bits;let o=Math.floor(n/32),a=~s[o];a&=~((1<<(n&31))-1);const u=s.length;for(;a===0;){if(++o===u)return r;a=~s[o]}const d=o*32+N.numberOfTrailingZeros(a);return d>r?r:d}setBulk(n,r){this.bits[Math.floor(n/32)]=r}setRange(n,r){if(r<n||n<0||r>this.size)throw new v;if(r===n)return;r--;const s=Math.floor(n/32),o=Math.floor(r/32),a=this.bits;for(let u=s;u<=o;u++){const d=u>s?0:n&31,g=(2<<(u<o?31:r&31))-(1<<d);a[u]|=g}}clear(){const n=this.bits.length,r=this.bits;for(let s=0;s<n;s++)r[s]=0}isRange(n,r,s){if(r<n||n<0||r>this.size)throw new v;if(r===n)return!0;r--;const o=Math.floor(n/32),a=Math.floor(r/32),u=this.bits;for(let d=o;d<=a;d++){const h=d>o?0:n&31,x=(2<<(d<a?31:r&31))-(1<<h)&4294967295;if((u[d]&x)!==(s?x:0))return!1}return!0}appendBit(n){this.ensureCapacity(this.size+1),n&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++}appendBits(n,r){if(r<0||r>32)throw new v("Num bits must be between 0 and 32");this.ensureCapacity(this.size+r);for(let s=r;s>0;s--)this.appendBit((n>>s-1&1)===1)}appendBitArray(n){const r=n.size;this.ensureCapacity(this.size+r);for(let s=0;s<r;s++)this.appendBit(n.get(s))}xor(n){if(this.size!==n.size)throw new v("Sizes don't match");const r=this.bits;for(let s=0,o=r.length;s<o;s++)r[s]^=n.bits[s]}toBytes(n,r,s,o){for(let a=0;a<o;a++){let u=0;for(let d=0;d<8;d++)this.get(n)&&(u|=1<<7-d),n++;r[s+a]=u}}getBitArray(){return this.bits}reverse(){const n=new Int32Array(this.bits.length),r=Math.floor((this.size-1)/32),s=r+1,o=this.bits;for(let a=0;a<s;a++){let u=o[a];u=u>>1&1431655765|(u&1431655765)<<1,u=u>>2&858993459|(u&858993459)<<2,u=u>>4&252645135|(u&252645135)<<4,u=u>>8&16711935|(u&16711935)<<8,u=u>>16&65535|(u&65535)<<16,n[r-a]=u}if(this.size!==s*32){const a=s*32-this.size;let u=n[0]>>>a;for(let d=1;d<s;d++){const h=n[d];u|=h<<32-a,n[d-1]=u,u=h>>>a}n[s-1]=u}this.bits=n}static makeArray(n){return new Int32Array(Math.floor((n+31)/32))}equals(n){if(!(n instanceof G))return!1;const r=n;return this.size===r.size&&T.equals(this.bits,r.bits)}hashCode(){return 31*this.size+T.hashCode(this.bits)}toString(){let n="";for(let r=0,s=this.size;r<s;r++)r&7||(n+=" "),n+=this.get(r)?"X":".";return n}clone(){return new G(this.size,this.bits.slice())}}var H;(function(y){y[y.OTHER=0]="OTHER",y[y.PURE_BARCODE=1]="PURE_BARCODE",y[y.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",y[y.TRY_HARDER=3]="TRY_HARDER",y[y.CHARACTER_SET=4]="CHARACTER_SET",y[y.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",y[y.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",y[y.ASSUME_GS1=7]="ASSUME_GS1",y[y.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",y[y.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",y[y.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(H||(H={}));var U=H;class k extends m{static getFormatInstance(){return new k}}k.kind="FormatException";var X;(function(y){y[y.Cp437=0]="Cp437",y[y.ISO8859_1=1]="ISO8859_1",y[y.ISO8859_2=2]="ISO8859_2",y[y.ISO8859_3=3]="ISO8859_3",y[y.ISO8859_4=4]="ISO8859_4",y[y.ISO8859_5=5]="ISO8859_5",y[y.ISO8859_6=6]="ISO8859_6",y[y.ISO8859_7=7]="ISO8859_7",y[y.ISO8859_8=8]="ISO8859_8",y[y.ISO8859_9=9]="ISO8859_9",y[y.ISO8859_10=10]="ISO8859_10",y[y.ISO8859_11=11]="ISO8859_11",y[y.ISO8859_13=12]="ISO8859_13",y[y.ISO8859_14=13]="ISO8859_14",y[y.ISO8859_15=14]="ISO8859_15",y[y.ISO8859_16=15]="ISO8859_16",y[y.SJIS=16]="SJIS",y[y.Cp1250=17]="Cp1250",y[y.Cp1251=18]="Cp1251",y[y.Cp1252=19]="Cp1252",y[y.Cp1256=20]="Cp1256",y[y.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",y[y.UTF8=22]="UTF8",y[y.ASCII=23]="ASCII",y[y.Big5=24]="Big5",y[y.GB18030=25]="GB18030",y[y.EUC_KR=26]="EUC_KR"})(X||(X={}));class V{constructor(n,r,s,...o){this.valueIdentifier=n,this.name=s,typeof r=="number"?this.values=Int32Array.from([r]):this.values=r,this.otherEncodingNames=o,V.VALUE_IDENTIFIER_TO_ECI.set(n,this),V.NAME_TO_ECI.set(s,this);const a=this.values;for(let u=0,d=a.length;u!==d;u++){const h=a[u];V.VALUES_TO_ECI.set(h,this)}for(const u of o)V.NAME_TO_ECI.set(u,this)}getValueIdentifier(){return this.valueIdentifier}getName(){return this.name}getValue(){return this.values[0]}static getCharacterSetECIByValue(n){if(n<0||n>=900)throw new k("incorect value");const r=V.VALUES_TO_ECI.get(n);if(r===void 0)throw new k("incorect value");return r}static getCharacterSetECIByName(n){const r=V.NAME_TO_ECI.get(n);if(r===void 0)throw new k("incorect value");return r}equals(n){if(!(n instanceof V))return!1;const r=n;return this.getName()===r.getName()}}V.VALUE_IDENTIFIER_TO_ECI=new Map,V.VALUES_TO_ECI=new Map,V.NAME_TO_ECI=new Map,V.Cp437=new V(X.Cp437,Int32Array.from([0,2]),"Cp437"),V.ISO8859_1=new V(X.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),V.ISO8859_2=new V(X.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),V.ISO8859_3=new V(X.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),V.ISO8859_4=new V(X.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),V.ISO8859_5=new V(X.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),V.ISO8859_6=new V(X.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),V.ISO8859_7=new V(X.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),V.ISO8859_8=new V(X.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),V.ISO8859_9=new V(X.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),V.ISO8859_10=new V(X.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),V.ISO8859_11=new V(X.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),V.ISO8859_13=new V(X.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),V.ISO8859_14=new V(X.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),V.ISO8859_15=new V(X.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),V.ISO8859_16=new V(X.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),V.SJIS=new V(X.SJIS,20,"SJIS","Shift_JIS"),V.Cp1250=new V(X.Cp1250,21,"Cp1250","windows-1250"),V.Cp1251=new V(X.Cp1251,22,"Cp1251","windows-1251"),V.Cp1252=new V(X.Cp1252,23,"Cp1252","windows-1252"),V.Cp1256=new V(X.Cp1256,24,"Cp1256","windows-1256"),V.UnicodeBigUnmarked=new V(X.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),V.UTF8=new V(X.UTF8,26,"UTF8","UTF-8"),V.ASCII=new V(X.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),V.Big5=new V(X.Big5,28,"Big5"),V.GB18030=new V(X.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),V.EUC_KR=new V(X.EUC_KR,30,"EUC_KR","EUC-KR");class se extends m{}se.kind="UnsupportedOperationException";class Ee{static decode(n,r){const s=this.encodingName(r);return this.customDecoder?this.customDecoder(n,s):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(s)?this.decodeFallback(n,s):new TextDecoder(s).decode(n)}static shouldDecodeOnFallback(n){return!Ee.isBrowser()&&n==="ISO-8859-1"}static encode(n,r){const s=this.encodingName(r);return this.customEncoder?this.customEncoder(n,s):typeof TextEncoder>"u"?this.encodeFallback(n):new TextEncoder().encode(n)}static isBrowser(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"}static encodingName(n){return typeof n=="string"?n:n.getName()}static encodingCharacterSet(n){return n instanceof V?n:V.getCharacterSetECIByName(n)}static decodeFallback(n,r){const s=this.encodingCharacterSet(r);if(Ee.isDecodeFallbackSupported(s)){let o="";for(let a=0,u=n.length;a<u;a++){let d=n[a].toString(16);d.length<2&&(d="0"+d),o+="%"+d}return decodeURIComponent(o)}if(s.equals(V.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(n.buffer));throw new se(`Encoding ${this.encodingName(r)} not supported by fallback.`)}static isDecodeFallbackSupported(n){return n.equals(V.UTF8)||n.equals(V.ISO8859_1)||n.equals(V.ASCII)}static encodeFallback(n){const s=btoa(unescape(encodeURIComponent(n))).split(""),o=[];for(let a=0;a<s.length;a++)o.push(s[a].charCodeAt(0));return new Uint8Array(o)}}class ie{static castAsNonUtf8Char(n,r=null){const s=r?r.getName():this.ISO88591;return Ee.decode(new Uint8Array([n]),s)}static guessEncoding(n,r){if(r!=null&&r.get(U.CHARACTER_SET)!==void 0)return r.get(U.CHARACTER_SET).toString();const s=n.length;let o=!0,a=!0,u=!0,d=0,h=0,g=0,x=0,E=0,A=0,I=0,b=0,D=0,L=0,z=0;const q=n.length>3&&n[0]===239&&n[1]===187&&n[2]===191;for(let $=0;$<s&&(o||a||u);$++){const Z=n[$]&255;u&&(d>0?Z&128?d--:u=!1:Z&128&&(Z&64?(d++,Z&32?(d++,Z&16?(d++,Z&8?u=!1:x++):g++):h++):u=!1)),o&&(Z>127&&Z<160?o=!1:Z>159&&(Z<192||Z===215||Z===247)&&z++),a&&(E>0?Z<64||Z===127||Z>252?a=!1:E--:Z===128||Z===160||Z>239?a=!1:Z>160&&Z<224?(A++,b=0,I++,I>D&&(D=I)):Z>127?(E++,I=0,b++,b>L&&(L=b)):(I=0,b=0))}return u&&d>0&&(u=!1),a&&E>0&&(a=!1),u&&(q||h+g+x>0)?ie.UTF8:a&&(ie.ASSUME_SHIFT_JIS||D>=3||L>=3)?ie.SHIFT_JIS:o&&a?D===2&&A===2||z*10>=s?ie.SHIFT_JIS:ie.ISO88591:o?ie.ISO88591:a?ie.SHIFT_JIS:u?ie.UTF8:ie.PLATFORM_DEFAULT_ENCODING}static format(n,...r){let s=-1;function o(u,d,h,g,x,E){if(u==="%%")return"%";if(r[++s]===void 0)return;u=g?parseInt(g.substr(1)):void 0;let A=x?parseInt(x.substr(1)):void 0,I;switch(E){case"s":I=r[s];break;case"c":I=r[s][0];break;case"f":I=parseFloat(r[s]).toFixed(u);break;case"p":I=parseFloat(r[s]).toPrecision(u);break;case"e":I=parseFloat(r[s]).toExponential(u);break;case"x":I=parseInt(r[s]).toString(A||16);break;case"d":I=parseFloat(parseInt(r[s],A||10).toPrecision(u)).toFixed(0);break}I=typeof I=="object"?JSON.stringify(I):(+I).toString(A);let b=parseInt(h),D=h&&h[0]+""=="0"?"0":" ";for(;I.length<b;)I=d!==void 0?I+D:D+I;return I}let a=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return n.replace(a,o)}static getBytes(n,r){return Ee.encode(n,r)}static getCharCode(n,r=0){return n.charCodeAt(r)}static getCharAt(n){return String.fromCharCode(n)}}ie.SHIFT_JIS=V.SJIS.getName(),ie.GB2312="GB2312",ie.ISO88591=V.ISO8859_1.getName(),ie.EUC_JP="EUC_JP",ie.UTF8=V.UTF8.getName(),ie.PLATFORM_DEFAULT_ENCODING=ie.UTF8,ie.ASSUME_SHIFT_JIS=!1;class ge{constructor(n=""){this.value=n}enableDecoding(n){return this.encoding=n,this}append(n){return typeof n=="string"?this.value+=n.toString():this.encoding?this.value+=ie.castAsNonUtf8Char(n,this.encoding):this.value+=String.fromCharCode(n),this}appendChars(n,r,s){for(let o=r;r<r+s;o++)this.append(n[o]);return this}length(){return this.value.length}charAt(n){return this.value.charAt(n)}deleteCharAt(n){this.value=this.value.substr(0,n)+this.value.substring(n+1)}setCharAt(n,r){this.value=this.value.substr(0,n)+r+this.value.substr(n+1)}substring(n,r){return this.value.substring(n,r)}setLengthToZero(){this.value=""}toString(){return this.value}insert(n,r){this.value=this.value.substr(0,n)+r+this.value.substr(n+r.length)}}class _e{constructor(n,r,s,o){if(this.width=n,this.height=r,this.rowSize=s,this.bits=o,r==null&&(r=n),this.height=r,n<1||r<1)throw new v("Both dimensions must be greater than 0");s==null&&(s=Math.floor((n+31)/32)),this.rowSize=s,o==null&&(this.bits=new Int32Array(this.rowSize*this.height))}static parseFromBooleanArray(n){const r=n.length,s=n[0].length,o=new _e(s,r);for(let a=0;a<r;a++){const u=n[a];for(let d=0;d<s;d++)u[d]&&o.set(d,a)}return o}static parseFromString(n,r,s){if(n===null)throw new v("stringRepresentation cannot be null");const o=new Array(n.length);let a=0,u=0,d=-1,h=0,g=0;for(;g<n.length;)if(n.charAt(g)===`
60
60
  `||n.charAt(g)==="\r"){if(a>u){if(d===-1)d=a-u;else if(a-u!==d)throw new v("row lengths do not match");u=a,h++}g++}else if(n.substring(g,g+r.length)===r)g+=r.length,o[a]=!0,a++;else if(n.substring(g,g+s.length)===s)g+=s.length,o[a]=!1,a++;else throw new v("illegal character encountered: "+n.substring(g));if(a>u){if(d===-1)d=a-u;else if(a-u!==d)throw new v("row lengths do not match");h++}const x=new _e(d,h);for(let E=0;E<a;E++)o[E]&&x.set(Math.floor(E%d),Math.floor(E/d));return x}get(n,r){const s=r*this.rowSize+Math.floor(n/32);return(this.bits[s]>>>(n&31)&1)!==0}set(n,r){const s=r*this.rowSize+Math.floor(n/32);this.bits[s]|=1<<(n&31)&4294967295}unset(n,r){const s=r*this.rowSize+Math.floor(n/32);this.bits[s]&=~(1<<(n&31)&4294967295)}flip(n,r){const s=r*this.rowSize+Math.floor(n/32);this.bits[s]^=1<<(n&31)&4294967295}xor(n){if(this.width!==n.getWidth()||this.height!==n.getHeight()||this.rowSize!==n.getRowSize())throw new v("input matrix dimensions do not match");const r=new G(Math.floor(this.width/32)+1),s=this.rowSize,o=this.bits;for(let a=0,u=this.height;a<u;a++){const d=a*s,h=n.getRow(a,r).getBitArray();for(let g=0;g<s;g++)o[d+g]^=h[g]}}clear(){const n=this.bits,r=n.length;for(let s=0;s<r;s++)n[s]=0}setRegion(n,r,s,o){if(r<0||n<0)throw new v("Left and top must be nonnegative");if(o<1||s<1)throw new v("Height and width must be at least 1");const a=n+s,u=r+o;if(u>this.height||a>this.width)throw new v("The region must fit inside the matrix");const d=this.rowSize,h=this.bits;for(let g=r;g<u;g++){const x=g*d;for(let E=n;E<a;E++)h[x+Math.floor(E/32)]|=1<<(E&31)&4294967295}}getRow(n,r){r==null||r.getSize()<this.width?r=new G(this.width):r.clear();const s=this.rowSize,o=this.bits,a=n*s;for(let u=0;u<s;u++)r.setBulk(u*32,o[a+u]);return r}setRow(n,r){B.arraycopy(r.getBitArray(),0,this.bits,n*this.rowSize,this.rowSize)}rotate180(){const n=this.getWidth(),r=this.getHeight();let s=new G(n),o=new G(n);for(let a=0,u=Math.floor((r+1)/2);a<u;a++)s=this.getRow(a,s),o=this.getRow(r-1-a,o),s.reverse(),o.reverse(),this.setRow(a,o),this.setRow(r-1-a,s)}getEnclosingRectangle(){const n=this.width,r=this.height,s=this.rowSize,o=this.bits;let a=n,u=r,d=-1,h=-1;for(let g=0;g<r;g++)for(let x=0;x<s;x++){const E=o[g*s+x];if(E!==0){if(g<u&&(u=g),g>h&&(h=g),x*32<a){let A=0;for(;!(E<<31-A&4294967295);)A++;x*32+A<a&&(a=x*32+A)}if(x*32+31>d){let A=31;for(;!(E>>>A);)A--;x*32+A>d&&(d=x*32+A)}}}return d<a||h<u?null:Int32Array.from([a,u,d-a+1,h-u+1])}getTopLeftOnBit(){const n=this.rowSize,r=this.bits;let s=0;for(;s<r.length&&r[s]===0;)s++;if(s===r.length)return null;const o=s/n;let a=s%n*32;const u=r[s];let d=0;for(;!(u<<31-d&4294967295);)d++;return a+=d,Int32Array.from([a,o])}getBottomRightOnBit(){const n=this.rowSize,r=this.bits;let s=r.length-1;for(;s>=0&&r[s]===0;)s--;if(s<0)return null;const o=Math.floor(s/n);let a=Math.floor(s%n)*32;const u=r[s];let d=31;for(;!(u>>>d);)d--;return a+=d,Int32Array.from([a,o])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(n){if(!(n instanceof _e))return!1;const r=n;return this.width===r.width&&this.height===r.height&&this.rowSize===r.rowSize&&T.equals(this.bits,r.bits)}hashCode(){let n=this.width;return n=31*n+this.width,n=31*n+this.height,n=31*n+this.rowSize,n=31*n+T.hashCode(this.bits),n}toString(n="X ",r=" ",s=`
61
61
  `){return this.buildToString(n,r,s)}buildToString(n,r,s){let o=new ge;for(let a=0,u=this.height;a<u;a++){for(let d=0,h=this.width;d<h;d++)o.append(this.get(d,a)?n:r);o.append(s)}return o.toString()}clone(){return new _e(this.width,this.height,this.rowSize,this.bits.slice())}}class j extends m{static getNotFoundInstance(){return new j}}j.kind="NotFoundException";class tt extends P{constructor(n){super(n),this.luminances=tt.EMPTY,this.buckets=new Int32Array(tt.LUMINANCE_BUCKETS)}getBlackRow(n,r){const s=this.getLuminanceSource(),o=s.getWidth();r==null||r.getSize()<o?r=new G(o):r.clear(),this.initArrays(o);const a=s.getRow(n,this.luminances),u=this.buckets;for(let h=0;h<o;h++)u[(a[h]&255)>>tt.LUMINANCE_SHIFT]++;const d=tt.estimateBlackPoint(u);if(o<3)for(let h=0;h<o;h++)(a[h]&255)<d&&r.set(h);else{let h=a[0]&255,g=a[1]&255;for(let x=1;x<o-1;x++){const E=a[x+1]&255;(g*4-h-E)/2<d&&r.set(x),h=g,g=E}}return r}getBlackMatrix(){const n=this.getLuminanceSource(),r=n.getWidth(),s=n.getHeight(),o=new _e(r,s);this.initArrays(r);const a=this.buckets;for(let h=1;h<5;h++){const g=Math.floor(s*h/5),x=n.getRow(g,this.luminances),E=Math.floor(r*4/5);for(let A=Math.floor(r/5);A<E;A++){const I=x[A]&255;a[I>>tt.LUMINANCE_SHIFT]++}}const u=tt.estimateBlackPoint(a),d=n.getMatrix();for(let h=0;h<s;h++){const g=h*r;for(let x=0;x<r;x++)(d[g+x]&255)<u&&o.set(x,h)}return o}createBinarizer(n){return new tt(n)}initArrays(n){this.luminances.length<n&&(this.luminances=new Uint8ClampedArray(n));const r=this.buckets;for(let s=0;s<tt.LUMINANCE_BUCKETS;s++)r[s]=0}static estimateBlackPoint(n){const r=n.length;let s=0,o=0,a=0;for(let x=0;x<r;x++)n[x]>a&&(o=x,a=n[x]),n[x]>s&&(s=n[x]);let u=0,d=0;for(let x=0;x<r;x++){const E=x-o,A=n[x]*E*E;A>d&&(u=x,d=A)}if(o>u){const x=o;o=u,u=x}if(u-o<=r/16)throw new j;let h=u-1,g=-1;for(let x=u-1;x>o;x--){const E=x-o,A=E*E*(u-x)*(s-n[x]);A>g&&(h=x,g=A)}return h<<tt.LUMINANCE_SHIFT}}tt.LUMINANCE_BITS=5,tt.LUMINANCE_SHIFT=8-tt.LUMINANCE_BITS,tt.LUMINANCE_BUCKETS=1<<tt.LUMINANCE_BITS,tt.EMPTY=Uint8ClampedArray.from([0]);class xe extends tt{constructor(n){super(n),this.matrix=null}getBlackMatrix(){if(this.matrix!==null)return this.matrix;const n=this.getLuminanceSource(),r=n.getWidth(),s=n.getHeight();if(r>=xe.MINIMUM_DIMENSION&&s>=xe.MINIMUM_DIMENSION){const o=n.getMatrix();let a=r>>xe.BLOCK_SIZE_POWER;r&xe.BLOCK_SIZE_MASK&&a++;let u=s>>xe.BLOCK_SIZE_POWER;s&xe.BLOCK_SIZE_MASK&&u++;const d=xe.calculateBlackPoints(o,a,u,r,s),h=new _e(r,s);xe.calculateThresholdForBlock(o,a,u,r,s,d,h),this.matrix=h}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(n){return new xe(n)}static calculateThresholdForBlock(n,r,s,o,a,u,d){const h=a-xe.BLOCK_SIZE,g=o-xe.BLOCK_SIZE;for(let x=0;x<s;x++){let E=x<<xe.BLOCK_SIZE_POWER;E>h&&(E=h);const A=xe.cap(x,2,s-3);for(let I=0;I<r;I++){let b=I<<xe.BLOCK_SIZE_POWER;b>g&&(b=g);const D=xe.cap(I,2,r-3);let L=0;for(let q=-2;q<=2;q++){const $=u[A+q];L+=$[D-2]+$[D-1]+$[D]+$[D+1]+$[D+2]}const z=L/25;xe.thresholdBlock(n,b,E,z,o,d)}}}static cap(n,r,s){return n<r?r:n>s?s:n}static thresholdBlock(n,r,s,o,a,u){for(let d=0,h=s*a+r;d<xe.BLOCK_SIZE;d++,h+=a)for(let g=0;g<xe.BLOCK_SIZE;g++)(n[h+g]&255)<=o&&u.set(r+g,s+d)}static calculateBlackPoints(n,r,s,o,a){const u=a-xe.BLOCK_SIZE,d=o-xe.BLOCK_SIZE,h=new Array(s);for(let g=0;g<s;g++){h[g]=new Int32Array(r);let x=g<<xe.BLOCK_SIZE_POWER;x>u&&(x=u);for(let E=0;E<r;E++){let A=E<<xe.BLOCK_SIZE_POWER;A>d&&(A=d);let I=0,b=255,D=0;for(let z=0,q=x*o+A;z<xe.BLOCK_SIZE;z++,q+=o){for(let $=0;$<xe.BLOCK_SIZE;$++){const Z=n[q+$]&255;I+=Z,Z<b&&(b=Z),Z>D&&(D=Z)}if(D-b>xe.MIN_DYNAMIC_RANGE)for(z++,q+=o;z<xe.BLOCK_SIZE;z++,q+=o)for(let $=0;$<xe.BLOCK_SIZE;$++)I+=n[q+$]&255}let L=I>>xe.BLOCK_SIZE_POWER*2;if(D-b<=xe.MIN_DYNAMIC_RANGE&&(L=b/2,g>0&&E>0)){const z=(h[g-1][E]+2*h[g][E-1]+h[g-1][E-1])/4;b<z&&(L=z)}h[g][E]=L}}return h}}xe.BLOCK_SIZE_POWER=3,xe.BLOCK_SIZE=1<<xe.BLOCK_SIZE_POWER,xe.BLOCK_SIZE_MASK=xe.BLOCK_SIZE-1,xe.MINIMUM_DIMENSION=xe.BLOCK_SIZE*5,xe.MIN_DYNAMIC_RANGE=24;class ee{constructor(n,r){this.width=n,this.height=r}getWidth(){return this.width}getHeight(){return this.height}isCropSupported(){return!1}crop(n,r,s,o){throw new se("This luminance source does not support cropping.")}isRotateSupported(){return!1}rotateCounterClockwise(){throw new se("This luminance source does not support rotation by 90 degrees.")}rotateCounterClockwise45(){throw new se("This luminance source does not support rotation by 45 degrees.")}toString(){const n=new Uint8ClampedArray(this.width);let r=new ge;for(let s=0;s<this.height;s++){const o=this.getRow(s,n);for(let a=0;a<this.width;a++){const u=o[a]&255;let d;u<64?d="#":u<128?d="+":u<192?d=".":d=" ",r.append(d)}r.append(`
62
- `)}return r.toString()}}class de extends ee{constructor(n){super(n.getWidth(),n.getHeight()),this.delegate=n}getRow(n,r){const s=this.delegate.getRow(n,r),o=this.getWidth();for(let a=0;a<o;a++)s[a]=255-(s[a]&255);return s}getMatrix(){const n=this.delegate.getMatrix(),r=this.getWidth()*this.getHeight(),s=new Uint8ClampedArray(r);for(let o=0;o<r;o++)s[o]=255-(n[o]&255);return s}isCropSupported(){return this.delegate.isCropSupported()}crop(n,r,s,o){return new de(this.delegate.crop(n,r,s,o))}isRotateSupported(){return this.delegate.isRotateSupported()}invert(){return this.delegate}rotateCounterClockwise(){return new de(this.delegate.rotateCounterClockwise())}rotateCounterClockwise45(){return new de(this.delegate.rotateCounterClockwise45())}}class pe extends ee{constructor(n){super(n.width,n.height),this.canvas=n,this.tempCanvasElement=null,this.buffer=pe.makeBufferFromCanvasImageData(n)}static makeBufferFromCanvasImageData(n){const r=n.getContext("2d").getImageData(0,0,n.width,n.height);return pe.toGrayscaleBuffer(r.data,n.width,n.height)}static toGrayscaleBuffer(n,r,s){const o=new Uint8ClampedArray(r*s);for(let a=0,u=0,d=n.length;a<d;a+=4,u++){let h;if(n[a+3]===0)h=255;else{const x=n[a],E=n[a+1],A=n[a+2];h=306*x+601*E+117*A+512>>10}o[u]=h}return o}getRow(n,r){if(n<0||n>=this.getHeight())throw new v("Requested row is outside the image: "+n);const s=this.getWidth(),o=n*s;return r===null?r=this.buffer.slice(o,o+s):(r.length<s&&(r=new Uint8ClampedArray(s)),r.set(this.buffer.slice(o,o+s))),r}getMatrix(){return this.buffer}isCropSupported(){return!0}crop(n,r,s,o){return super.crop(n,r,s,o),this}isRotateSupported(){return!0}rotateCounterClockwise(){return this.rotate(-90),this}rotateCounterClockwise45(){return this.rotate(-45),this}getTempCanvasElement(){if(this.tempCanvasElement===null){const n=this.canvas.ownerDocument.createElement("canvas");n.width=this.canvas.width,n.height=this.canvas.height,this.tempCanvasElement=n}return this.tempCanvasElement}rotate(n){const r=this.getTempCanvasElement(),s=r.getContext("2d"),o=n*pe.DEGREE_TO_RADIANS,a=this.canvas.width,u=this.canvas.height,d=Math.ceil(Math.abs(Math.cos(o))*a+Math.abs(Math.sin(o))*u),h=Math.ceil(Math.abs(Math.sin(o))*a+Math.abs(Math.cos(o))*u);return r.width=d,r.height=h,s.translate(d/2,h/2),s.rotate(o),s.drawImage(this.canvas,a/-2,u/-2),this.buffer=pe.makeBufferFromCanvasImageData(r),this}invert(){return new de(this)}}pe.DEGREE_TO_RADIANS=Math.PI/180;class Ge{constructor(n,r,s){this.deviceId=n,this.label=r,this.kind="videoinput",this.groupId=s||void 0}toJSON(){return{kind:this.kind,groupId:this.groupId,deviceId:this.deviceId,label:this.label}}}var Ie=(globalThis||ls||self||window||void 0)&&(globalThis||ls||self||window||void 0).__awaiter||function(y,n,r,s){function o(a){return a instanceof r?a:new r(function(u){u(a)})}return new(r||(r=Promise))(function(a,u){function d(x){try{g(s.next(x))}catch(E){u(E)}}function h(x){try{g(s.throw(x))}catch(E){u(E)}}function g(x){x.done?a(x.value):o(x.value).then(d,h)}g((s=s.apply(y,n||[])).next())})};class cn{constructor(n,r=500,s){this.reader=n,this.timeBetweenScansMillis=r,this._hints=s,this._stopContinuousDecode=!1,this._stopAsyncDecode=!1,this._timeBetweenDecodingAttempts=0}get hasNavigator(){return typeof navigator<"u"}get isMediaDevicesSuported(){return this.hasNavigator&&!!navigator.mediaDevices}get canEnumerateDevices(){return!!(this.isMediaDevicesSuported&&navigator.mediaDevices.enumerateDevices)}get timeBetweenDecodingAttempts(){return this._timeBetweenDecodingAttempts}set timeBetweenDecodingAttempts(n){this._timeBetweenDecodingAttempts=n<0?0:n}set hints(n){this._hints=n||null}get hints(){return this._hints}listVideoInputDevices(){return Ie(this,void 0,void 0,function*(){if(!this.hasNavigator)throw new Error("Can't enumerate devices, navigator is not present.");if(!this.canEnumerateDevices)throw new Error("Can't enumerate devices, method not supported.");const n=yield navigator.mediaDevices.enumerateDevices(),r=[];for(const s of n){const o=s.kind==="video"?"videoinput":s.kind;if(o!=="videoinput")continue;const a=s.deviceId||s.id,u=s.label||`Video device ${r.length+1}`,d=s.groupId,h={deviceId:a,label:u,kind:o,groupId:d};r.push(h)}return r})}getVideoInputDevices(){return Ie(this,void 0,void 0,function*(){return(yield this.listVideoInputDevices()).map(r=>new Ge(r.deviceId,r.label))})}findDeviceById(n){return Ie(this,void 0,void 0,function*(){const r=yield this.listVideoInputDevices();return r?r.find(s=>s.deviceId===n):null})}decodeFromInputVideoDevice(n,r){return Ie(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(n,r)})}decodeOnceFromVideoDevice(n,r){return Ie(this,void 0,void 0,function*(){this.reset();let s;n?s={deviceId:{exact:n}}:s={facingMode:"environment"};const o={video:s};return yield this.decodeOnceFromConstraints(o,r)})}decodeOnceFromConstraints(n,r){return Ie(this,void 0,void 0,function*(){const s=yield navigator.mediaDevices.getUserMedia(n);return yield this.decodeOnceFromStream(s,r)})}decodeOnceFromStream(n,r){return Ie(this,void 0,void 0,function*(){this.reset();const s=yield this.attachStreamToVideo(n,r);return yield this.decodeOnce(s)})}decodeFromInputVideoDeviceContinuously(n,r,s){return Ie(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(n,r,s)})}decodeFromVideoDevice(n,r,s){return Ie(this,void 0,void 0,function*(){let o;n?o={deviceId:{exact:n}}:o={facingMode:"environment"};const a={video:o};return yield this.decodeFromConstraints(a,r,s)})}decodeFromConstraints(n,r,s){return Ie(this,void 0,void 0,function*(){const o=yield navigator.mediaDevices.getUserMedia(n);return yield this.decodeFromStream(o,r,s)})}decodeFromStream(n,r,s){return Ie(this,void 0,void 0,function*(){this.reset();const o=yield this.attachStreamToVideo(n,r);return yield this.decodeContinuously(o,s)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(n,r){return Ie(this,void 0,void 0,function*(){const s=this.prepareVideoElement(r);return this.addVideoSource(s,n),this.videoElement=s,this.stream=n,yield this.playVideoOnLoadAsync(s),s})}playVideoOnLoadAsync(n){return new Promise((r,s)=>this.playVideoOnLoad(n,()=>r()))}playVideoOnLoad(n,r){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(n),n.addEventListener("ended",this.videoEndedListener),n.addEventListener("canplay",this.videoCanPlayListener),n.addEventListener("playing",r),this.tryPlayVideo(n)}isVideoPlaying(n){return n.currentTime>0&&!n.paused&&!n.ended&&n.readyState>2}tryPlayVideo(n){return Ie(this,void 0,void 0,function*(){if(this.isVideoPlaying(n)){console.warn("Trying to play video that is already playing.");return}try{yield n.play()}catch{console.warn("It was not possible to play the video.")}})}getMediaElement(n,r){const s=document.getElementById(n);if(!s)throw new _(`element with id '${n}' not found`);if(s.nodeName.toLowerCase()!==r.toLowerCase())throw new _(`element with id '${n}' must be an ${r} element`);return s}decodeFromImage(n,r){if(!n&&!r)throw new _("either imageElement with a src set or an url must be provided");return r&&!n?this.decodeFromImageUrl(r):this.decodeFromImageElement(n)}decodeFromVideo(n,r){if(!n&&!r)throw new _("Either an element with a src set or an URL must be provided");return r&&!n?this.decodeFromVideoUrl(r):this.decodeFromVideoElement(n)}decodeFromVideoContinuously(n,r,s){if(n===void 0&&r===void 0)throw new _("Either an element with a src set or an URL must be provided");return r&&!n?this.decodeFromVideoUrlContinuously(r,s):this.decodeFromVideoElementContinuously(n,s)}decodeFromImageElement(n){if(!n)throw new _("An image element must be provided.");this.reset();const r=this.prepareImageElement(n);this.imageElement=r;let s;return this.isImageLoaded(r)?s=this.decodeOnce(r,!1,!0):s=this._decodeOnLoadImage(r),s}decodeFromVideoElement(n){const r=this._decodeFromVideoElementSetup(n);return this._decodeOnLoadVideo(r)}decodeFromVideoElementContinuously(n,r){const s=this._decodeFromVideoElementSetup(n);return this._decodeOnLoadVideoContinuously(s,r)}_decodeFromVideoElementSetup(n){if(!n)throw new _("A video element must be provided.");this.reset();const r=this.prepareVideoElement(n);return this.videoElement=r,r}decodeFromImageUrl(n){if(!n)throw new _("An URL must be provided.");this.reset();const r=this.prepareImageElement();this.imageElement=r;const s=this._decodeOnLoadImage(r);return r.src=n,s}decodeFromVideoUrl(n){if(!n)throw new _("An URL must be provided.");this.reset();const r=this.prepareVideoElement(),s=this.decodeFromVideoElement(r);return r.src=n,s}decodeFromVideoUrlContinuously(n,r){if(!n)throw new _("An URL must be provided.");this.reset();const s=this.prepareVideoElement(),o=this.decodeFromVideoElementContinuously(s,r);return s.src=n,o}_decodeOnLoadImage(n){return new Promise((r,s)=>{this.imageLoadedListener=()=>this.decodeOnce(n,!1,!0).then(r,s),n.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(n){return Ie(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(n),yield this.decodeOnce(n)})}_decodeOnLoadVideoContinuously(n,r){return Ie(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(n),this.decodeContinuously(n,r)})}isImageLoaded(n){return!(!n.complete||n.naturalWidth===0)}prepareImageElement(n){let r;return typeof n>"u"&&(r=document.createElement("img"),r.width=200,r.height=200),typeof n=="string"&&(r=this.getMediaElement(n,"img")),n instanceof HTMLImageElement&&(r=n),r}prepareVideoElement(n){let r;return!n&&typeof document<"u"&&(r=document.createElement("video"),r.width=200,r.height=200),typeof n=="string"&&(r=this.getMediaElement(n,"video")),n instanceof HTMLVideoElement&&(r=n),r.setAttribute("autoplay","true"),r.setAttribute("muted","true"),r.setAttribute("playsinline","true"),r}decodeOnce(n,r=!0,s=!0){this._stopAsyncDecode=!1;const o=(a,u)=>{if(this._stopAsyncDecode){u(new j("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{const d=this.decode(n);a(d)}catch(d){const h=r&&d instanceof j,x=(d instanceof M||d instanceof k)&&s;if(h||x)return setTimeout(o,this._timeBetweenDecodingAttempts,a,u);u(d)}};return new Promise((a,u)=>o(a,u))}decodeContinuously(n,r){this._stopContinuousDecode=!1;const s=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{const o=this.decode(n);r(o,null),setTimeout(s,this.timeBetweenScansMillis)}catch(o){r(null,o);const a=o instanceof M||o instanceof k,u=o instanceof j;(a||u)&&setTimeout(s,this._timeBetweenDecodingAttempts)}};s()}decode(n){const r=this.createBinaryBitmap(n);return this.decodeBitmap(r)}_isHTMLVideoElement(n){return n.videoWidth!==0}drawFrameOnCanvas(n,r,s){r||(r={sx:0,sy:0,sWidth:n.videoWidth,sHeight:n.videoHeight,dx:0,dy:0,dWidth:n.videoWidth,dHeight:n.videoHeight}),s||(s=this.captureCanvasContext),s.drawImage(n,r.sx,r.sy,r.sWidth,r.sHeight,r.dx,r.dy,r.dWidth,r.dHeight)}drawImageOnCanvas(n,r,s=this.captureCanvasContext){r||(r={sx:0,sy:0,sWidth:n.naturalWidth,sHeight:n.naturalHeight,dx:0,dy:0,dWidth:n.naturalWidth,dHeight:n.naturalHeight}),s||(s=this.captureCanvasContext),s.drawImage(n,r.sx,r.sy,r.sWidth,r.sHeight,r.dx,r.dy,r.dWidth,r.dHeight)}createBinaryBitmap(n){this.getCaptureCanvasContext(n),this._isHTMLVideoElement(n)?this.drawFrameOnCanvas(n):this.drawImageOnCanvas(n);const r=this.getCaptureCanvas(n),s=new pe(r),o=new xe(s);return new R(o)}getCaptureCanvasContext(n){if(!this.captureCanvasContext){const s=this.getCaptureCanvas(n).getContext("2d");this.captureCanvasContext=s}return this.captureCanvasContext}getCaptureCanvas(n){if(!this.captureCanvas){const r=this.createCaptureCanvas(n);this.captureCanvas=r}return this.captureCanvas}decodeBitmap(n){return this.reader.decode(n,this._hints)}createCaptureCanvas(n){if(typeof document>"u")return this._destroyCaptureCanvas(),null;const r=document.createElement("canvas");let s,o;return typeof n<"u"&&(n instanceof HTMLVideoElement?(s=n.videoWidth,o=n.videoHeight):n instanceof HTMLImageElement&&(s=n.naturalWidth||n.width,o=n.naturalHeight||n.height)),r.style.width=s+"px",r.style.height=o+"px",r.width=s,r.height=o,r}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(n=>n.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(n,r){try{n.srcObject=r}catch{n.src=URL.createObjectURL(r)}}cleanVideoSource(n){try{n.srcObject=null}catch{n.src=""}this.videoElement.removeAttribute("src")}}class Ke{constructor(n,r,s=r==null?0:8*r.length,o,a,u=B.currentTimeMillis()){this.text=n,this.rawBytes=r,this.numBits=s,this.resultPoints=o,this.format=a,this.timestamp=u,this.text=n,this.rawBytes=r,s==null?this.numBits=r==null?0:8*r.length:this.numBits=s,this.resultPoints=o,this.format=a,this.resultMetadata=null,u==null?this.timestamp=B.currentTimeMillis():this.timestamp=u}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(n,r){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(n,r)}putAllMetadata(n){n!==null&&(this.resultMetadata===null?this.resultMetadata=n:this.resultMetadata=new Map(n))}addResultPoints(n){const r=this.resultPoints;if(r===null)this.resultPoints=n;else if(n!==null&&n.length>0){const s=new Array(r.length+n.length);B.arraycopy(r,0,s,0,r.length),B.arraycopy(n,0,s,r.length,n.length),this.resultPoints=s}}getTimestamp(){return this.timestamp}toString(){return this.text}}var kr;(function(y){y[y.AZTEC=0]="AZTEC",y[y.CODABAR=1]="CODABAR",y[y.CODE_39=2]="CODE_39",y[y.CODE_93=3]="CODE_93",y[y.CODE_128=4]="CODE_128",y[y.DATA_MATRIX=5]="DATA_MATRIX",y[y.EAN_8=6]="EAN_8",y[y.EAN_13=7]="EAN_13",y[y.ITF=8]="ITF",y[y.MAXICODE=9]="MAXICODE",y[y.PDF_417=10]="PDF_417",y[y.QR_CODE=11]="QR_CODE",y[y.RSS_14=12]="RSS_14",y[y.RSS_EXPANDED=13]="RSS_EXPANDED",y[y.UPC_A=14]="UPC_A",y[y.UPC_E=15]="UPC_E",y[y.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(kr||(kr={}));var ae=kr,ir;(function(y){y[y.OTHER=0]="OTHER",y[y.ORIENTATION=1]="ORIENTATION",y[y.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",y[y.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",y[y.ISSUE_NUMBER=4]="ISSUE_NUMBER",y[y.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",y[y.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",y[y.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",y[y.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",y[y.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",y[y.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(ir||(ir={}));var mt=ir;class Qi{constructor(n,r,s,o,a=-1,u=-1){this.rawBytes=n,this.text=r,this.byteSegments=s,this.ecLevel=o,this.structuredAppendSequenceNumber=a,this.structuredAppendParity=u,this.numBits=n==null?0:8*n.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(n){this.numBits=n}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(n){this.errorsCorrected=n}getErasures(){return this.erasures}setErasures(n){this.erasures=n}getOther(){return this.other}setOther(n){this.other=n}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class qi{exp(n){return this.expTable[n]}log(n){if(n===0)throw new v;return this.logTable[n]}static addOrSubtract(n,r){return n^r}}class Ht{constructor(n,r){if(r.length===0)throw new v;this.field=n;const s=r.length;if(s>1&&r[0]===0){let o=1;for(;o<s&&r[o]===0;)o++;o===s?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(s-o),B.arraycopy(r,o,this.coefficients,0,this.coefficients.length))}else this.coefficients=r}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(n){return this.coefficients[this.coefficients.length-1-n]}evaluateAt(n){if(n===0)return this.getCoefficient(0);const r=this.coefficients;let s;if(n===1){s=0;for(let u=0,d=r.length;u!==d;u++){const h=r[u];s=qi.addOrSubtract(s,h)}return s}s=r[0];const o=r.length,a=this.field;for(let u=1;u<o;u++)s=qi.addOrSubtract(a.multiply(n,s),r[u]);return s}addOrSubtract(n){if(!this.field.equals(n.field))throw new v("GenericGFPolys do not have same GenericGF field");if(this.isZero())return n;if(n.isZero())return this;let r=this.coefficients,s=n.coefficients;if(r.length>s.length){const u=r;r=s,s=u}let o=new Int32Array(s.length);const a=s.length-r.length;B.arraycopy(s,0,o,0,a);for(let u=a;u<s.length;u++)o[u]=qi.addOrSubtract(r[u-a],s[u]);return new Ht(this.field,o)}multiply(n){if(!this.field.equals(n.field))throw new v("GenericGFPolys do not have same GenericGF field");if(this.isZero()||n.isZero())return this.field.getZero();const r=this.coefficients,s=r.length,o=n.coefficients,a=o.length,u=new Int32Array(s+a-1),d=this.field;for(let h=0;h<s;h++){const g=r[h];for(let x=0;x<a;x++)u[h+x]=qi.addOrSubtract(u[h+x],d.multiply(g,o[x]))}return new Ht(d,u)}multiplyScalar(n){if(n===0)return this.field.getZero();if(n===1)return this;const r=this.coefficients.length,s=this.field,o=new Int32Array(r),a=this.coefficients;for(let u=0;u<r;u++)o[u]=s.multiply(a[u],n);return new Ht(s,o)}multiplyByMonomial(n,r){if(n<0)throw new v;if(r===0)return this.field.getZero();const s=this.coefficients,o=s.length,a=new Int32Array(o+n),u=this.field;for(let d=0;d<o;d++)a[d]=u.multiply(s[d],r);return new Ht(u,a)}divide(n){if(!this.field.equals(n.field))throw new v("GenericGFPolys do not have same GenericGF field");if(n.isZero())throw new v("Divide by 0");const r=this.field;let s=r.getZero(),o=this;const a=n.getCoefficient(n.getDegree()),u=r.inverse(a);for(;o.getDegree()>=n.getDegree()&&!o.isZero();){const d=o.getDegree()-n.getDegree(),h=r.multiply(o.getCoefficient(o.getDegree()),u),g=n.multiplyByMonomial(d,h),x=r.buildMonomial(d,h);s=s.addOrSubtract(x),o=o.addOrSubtract(g)}return[s,o]}toString(){let n="";for(let r=this.getDegree();r>=0;r--){let s=this.getCoefficient(r);if(s!==0){if(s<0?(n+=" - ",s=-s):n.length>0&&(n+=" + "),r===0||s!==1){const o=this.field.log(s);o===0?n+="1":o===1?n+="a":(n+="a^",n+=o)}r!==0&&(r===1?n+="x":(n+="x^",n+=r))}}return n}}class io extends m{}io.kind="ArithmeticException";class be extends qi{constructor(n,r,s){super(),this.primitive=n,this.size=r,this.generatorBase=s;const o=new Int32Array(r);let a=1;for(let d=0;d<r;d++)o[d]=a,a*=2,a>=r&&(a^=n,a&=r-1);this.expTable=o;const u=new Int32Array(r);for(let d=0;d<r-1;d++)u[o[d]]=d;this.logTable=u,this.zero=new Ht(this,Int32Array.from([0])),this.one=new Ht(this,Int32Array.from([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(n,r){if(n<0)throw new v;if(r===0)return this.zero;const s=new Int32Array(n+1);return s[0]=r,new Ht(this,s)}inverse(n){if(n===0)throw new io;return this.expTable[this.size-this.logTable[n]-1]}multiply(n,r){return n===0||r===0?0:this.expTable[(this.logTable[n]+this.logTable[r])%(this.size-1)]}getSize(){return this.size}getGeneratorBase(){return this.generatorBase}toString(){return"GF(0x"+N.toHexString(this.primitive)+","+this.size+")"}equals(n){return n===this}}be.AZTEC_DATA_12=new be(4201,4096,1),be.AZTEC_DATA_10=new be(1033,1024,1),be.AZTEC_DATA_6=new be(67,64,1),be.AZTEC_PARAM=new be(19,16,1),be.QR_CODE_FIELD_256=new be(285,256,0),be.DATA_MATRIX_FIELD_256=new be(301,256,1),be.AZTEC_DATA_8=be.DATA_MATRIX_FIELD_256,be.MAXICODE_FIELD_64=be.AZTEC_DATA_6;class ri extends m{}ri.kind="ReedSolomonException";class Dn extends m{}Dn.kind="IllegalStateException";class $i{constructor(n){this.field=n}decode(n,r){const s=this.field,o=new Ht(s,n),a=new Int32Array(r);let u=!0;for(let I=0;I<r;I++){const b=o.evaluateAt(s.exp(I+s.getGeneratorBase()));a[a.length-1-I]=b,b!==0&&(u=!1)}if(u)return;const d=new Ht(s,a),h=this.runEuclideanAlgorithm(s.buildMonomial(r,1),d,r),g=h[0],x=h[1],E=this.findErrorLocations(g),A=this.findErrorMagnitudes(x,E);for(let I=0;I<E.length;I++){const b=n.length-1-s.log(E[I]);if(b<0)throw new ri("Bad error location");n[b]=be.addOrSubtract(n[b],A[I])}}runEuclideanAlgorithm(n,r,s){if(n.getDegree()<r.getDegree()){const I=n;n=r,r=I}const o=this.field;let a=n,u=r,d=o.getZero(),h=o.getOne();for(;u.getDegree()>=(s/2|0);){let I=a,b=d;if(a=u,d=h,a.isZero())throw new ri("r_{i-1} was zero");u=I;let D=o.getZero();const L=a.getCoefficient(a.getDegree()),z=o.inverse(L);for(;u.getDegree()>=a.getDegree()&&!u.isZero();){const q=u.getDegree()-a.getDegree(),$=o.multiply(u.getCoefficient(u.getDegree()),z);D=D.addOrSubtract(o.buildMonomial(q,$)),u=u.addOrSubtract(a.multiplyByMonomial(q,$))}if(h=D.multiply(d).addOrSubtract(b),u.getDegree()>=a.getDegree())throw new Dn("Division algorithm failed to reduce polynomial?")}const g=h.getCoefficient(0);if(g===0)throw new ri("sigmaTilde(0) was zero");const x=o.inverse(g),E=h.multiplyScalar(x),A=u.multiplyScalar(x);return[E,A]}findErrorLocations(n){const r=n.getDegree();if(r===1)return Int32Array.from([n.getCoefficient(1)]);const s=new Int32Array(r);let o=0;const a=this.field;for(let u=1;u<a.getSize()&&o<r;u++)n.evaluateAt(u)===0&&(s[o]=a.inverse(u),o++);if(o!==r)throw new ri("Error locator degree does not match number of roots");return s}findErrorMagnitudes(n,r){const s=r.length,o=new Int32Array(s),a=this.field;for(let u=0;u<s;u++){const d=a.inverse(r[u]);let h=1;for(let g=0;g<s;g++)if(u!==g){const x=a.multiply(r[g],d),E=x&1?x&-2:x|1;h=a.multiply(h,E)}o[u]=a.multiply(n.evaluateAt(d),a.inverse(h)),a.getGeneratorBase()!==0&&(o[u]=a.multiply(o[u],d))}return o}}var vt;(function(y){y[y.UPPER=0]="UPPER",y[y.LOWER=1]="LOWER",y[y.MIXED=2]="MIXED",y[y.DIGIT=3]="DIGIT",y[y.PUNCT=4]="PUNCT",y[y.BINARY=5]="BINARY"})(vt||(vt={}));class Ue{decode(n){this.ddata=n;let r=n.getBits(),s=this.extractBits(r),o=this.correctBits(s),a=Ue.convertBoolArrayToByteArray(o),u=Ue.getEncodedData(o),d=new Qi(a,u,null,null);return d.setNumBits(o.length),d}static highLevelDecode(n){return this.getEncodedData(n)}static getEncodedData(n){let r=n.length,s=vt.UPPER,o=vt.UPPER,a="",u=0;for(;u<r;)if(o===vt.BINARY){if(r-u<5)break;let d=Ue.readCode(n,u,5);if(u+=5,d===0){if(r-u<11)break;d=Ue.readCode(n,u,11)+31,u+=11}for(let h=0;h<d;h++){if(r-u<8){u=r;break}const g=Ue.readCode(n,u,8);a+=ie.castAsNonUtf8Char(g),u+=8}o=s}else{let d=o===vt.DIGIT?4:5;if(r-u<d)break;let h=Ue.readCode(n,u,d);u+=d;let g=Ue.getCharacter(o,h);g.startsWith("CTRL_")?(s=o,o=Ue.getTable(g.charAt(5)),g.charAt(6)==="L"&&(s=o)):(a+=g,o=s)}return a}static getTable(n){switch(n){case"L":return vt.LOWER;case"P":return vt.PUNCT;case"M":return vt.MIXED;case"D":return vt.DIGIT;case"B":return vt.BINARY;case"U":default:return vt.UPPER}}static getCharacter(n,r){switch(n){case vt.UPPER:return Ue.UPPER_TABLE[r];case vt.LOWER:return Ue.LOWER_TABLE[r];case vt.MIXED:return Ue.MIXED_TABLE[r];case vt.PUNCT:return Ue.PUNCT_TABLE[r];case vt.DIGIT:return Ue.DIGIT_TABLE[r];default:throw new Dn("Bad table")}}correctBits(n){let r,s;this.ddata.getNbLayers()<=2?(s=6,r=be.AZTEC_DATA_6):this.ddata.getNbLayers()<=8?(s=8,r=be.AZTEC_DATA_8):this.ddata.getNbLayers()<=22?(s=10,r=be.AZTEC_DATA_10):(s=12,r=be.AZTEC_DATA_12);let o=this.ddata.getNbDatablocks(),a=n.length/s;if(a<o)throw new k;let u=n.length%s,d=new Int32Array(a);for(let A=0;A<a;A++,u+=s)d[A]=Ue.readCode(n,u,s);try{new $i(r).decode(d,a-o)}catch(A){throw new k(A)}let h=(1<<s)-1,g=0;for(let A=0;A<o;A++){let I=d[A];if(I===0||I===h)throw new k;(I===1||I===h-1)&&g++}let x=new Array(o*s-g),E=0;for(let A=0;A<o;A++){let I=d[A];if(I===1||I===h-1)x.fill(I>1,E,E+s-1),E+=s-1;else for(let b=s-1;b>=0;--b)x[E++]=(I&1<<b)!==0}return x}extractBits(n){let r=this.ddata.isCompact(),s=this.ddata.getNbLayers(),o=(r?11:14)+s*4,a=new Int32Array(o),u=new Array(this.totalBitsInLayer(s,r));if(r)for(let d=0;d<a.length;d++)a[d]=d;else{let d=o+1+2*N.truncDivision(N.truncDivision(o,2)-1,15),h=o/2,g=N.truncDivision(d,2);for(let x=0;x<h;x++){let E=x+N.truncDivision(x,15);a[h-x-1]=g-E-1,a[h+x]=g+E+1}}for(let d=0,h=0;d<s;d++){let g=(s-d)*4+(r?9:12),x=d*2,E=o-1-x;for(let A=0;A<g;A++){let I=A*2;for(let b=0;b<2;b++)u[h+I+b]=n.get(a[x+b],a[x+A]),u[h+2*g+I+b]=n.get(a[x+A],a[E-b]),u[h+4*g+I+b]=n.get(a[E-b],a[E-A]),u[h+6*g+I+b]=n.get(a[E-A],a[x+b])}h+=g*8}return u}static readCode(n,r,s){let o=0;for(let a=r;a<r+s;a++)o<<=1,n[a]&&(o|=1);return o}static readByte(n,r){let s=n.length-r;return s>=8?Ue.readCode(n,r,8):Ue.readCode(n,r,s)<<8-s}static convertBoolArrayToByteArray(n){let r=new Uint8Array((n.length+7)/8);for(let s=0;s<r.length;s++)r[s]=Ue.readByte(n,8*s);return r}totalBitsInLayer(n,r){return((r?88:112)+16*n)*n}}Ue.UPPER_TABLE=["CTRL_PS"," ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","CTRL_LL","CTRL_ML","CTRL_DL","CTRL_BS"],Ue.LOWER_TABLE=["CTRL_PS"," ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","CTRL_US","CTRL_ML","CTRL_DL","CTRL_BS"],Ue.MIXED_TABLE=["CTRL_PS"," ","\\1","\\2","\\3","\\4","\\5","\\6","\\7","\b"," ",`
62
+ `)}return r.toString()}}class de extends ee{constructor(n){super(n.getWidth(),n.getHeight()),this.delegate=n}getRow(n,r){const s=this.delegate.getRow(n,r),o=this.getWidth();for(let a=0;a<o;a++)s[a]=255-(s[a]&255);return s}getMatrix(){const n=this.delegate.getMatrix(),r=this.getWidth()*this.getHeight(),s=new Uint8ClampedArray(r);for(let o=0;o<r;o++)s[o]=255-(n[o]&255);return s}isCropSupported(){return this.delegate.isCropSupported()}crop(n,r,s,o){return new de(this.delegate.crop(n,r,s,o))}isRotateSupported(){return this.delegate.isRotateSupported()}invert(){return this.delegate}rotateCounterClockwise(){return new de(this.delegate.rotateCounterClockwise())}rotateCounterClockwise45(){return new de(this.delegate.rotateCounterClockwise45())}}class pe extends ee{constructor(n){super(n.width,n.height),this.canvas=n,this.tempCanvasElement=null,this.buffer=pe.makeBufferFromCanvasImageData(n)}static makeBufferFromCanvasImageData(n){const r=n.getContext("2d").getImageData(0,0,n.width,n.height);return pe.toGrayscaleBuffer(r.data,n.width,n.height)}static toGrayscaleBuffer(n,r,s){const o=new Uint8ClampedArray(r*s);for(let a=0,u=0,d=n.length;a<d;a+=4,u++){let h;if(n[a+3]===0)h=255;else{const x=n[a],E=n[a+1],A=n[a+2];h=306*x+601*E+117*A+512>>10}o[u]=h}return o}getRow(n,r){if(n<0||n>=this.getHeight())throw new v("Requested row is outside the image: "+n);const s=this.getWidth(),o=n*s;return r===null?r=this.buffer.slice(o,o+s):(r.length<s&&(r=new Uint8ClampedArray(s)),r.set(this.buffer.slice(o,o+s))),r}getMatrix(){return this.buffer}isCropSupported(){return!0}crop(n,r,s,o){return super.crop(n,r,s,o),this}isRotateSupported(){return!0}rotateCounterClockwise(){return this.rotate(-90),this}rotateCounterClockwise45(){return this.rotate(-45),this}getTempCanvasElement(){if(this.tempCanvasElement===null){const n=this.canvas.ownerDocument.createElement("canvas");n.width=this.canvas.width,n.height=this.canvas.height,this.tempCanvasElement=n}return this.tempCanvasElement}rotate(n){const r=this.getTempCanvasElement(),s=r.getContext("2d"),o=n*pe.DEGREE_TO_RADIANS,a=this.canvas.width,u=this.canvas.height,d=Math.ceil(Math.abs(Math.cos(o))*a+Math.abs(Math.sin(o))*u),h=Math.ceil(Math.abs(Math.sin(o))*a+Math.abs(Math.cos(o))*u);return r.width=d,r.height=h,s.translate(d/2,h/2),s.rotate(o),s.drawImage(this.canvas,a/-2,u/-2),this.buffer=pe.makeBufferFromCanvasImageData(r),this}invert(){return new de(this)}}pe.DEGREE_TO_RADIANS=Math.PI/180;class Ge{constructor(n,r,s){this.deviceId=n,this.label=r,this.kind="videoinput",this.groupId=s||void 0}toJSON(){return{kind:this.kind,groupId:this.groupId,deviceId:this.deviceId,label:this.label}}}var Ie=(globalThis||ls||self||window||void 0)&&(globalThis||ls||self||window||void 0).__awaiter||function(y,n,r,s){function o(a){return a instanceof r?a:new r(function(u){u(a)})}return new(r||(r=Promise))(function(a,u){function d(x){try{g(s.next(x))}catch(E){u(E)}}function h(x){try{g(s.throw(x))}catch(E){u(E)}}function g(x){x.done?a(x.value):o(x.value).then(d,h)}g((s=s.apply(y,n||[])).next())})};class cn{constructor(n,r=500,s){this.reader=n,this.timeBetweenScansMillis=r,this._hints=s,this._stopContinuousDecode=!1,this._stopAsyncDecode=!1,this._timeBetweenDecodingAttempts=0}get hasNavigator(){return typeof navigator<"u"}get isMediaDevicesSuported(){return this.hasNavigator&&!!navigator.mediaDevices}get canEnumerateDevices(){return!!(this.isMediaDevicesSuported&&navigator.mediaDevices.enumerateDevices)}get timeBetweenDecodingAttempts(){return this._timeBetweenDecodingAttempts}set timeBetweenDecodingAttempts(n){this._timeBetweenDecodingAttempts=n<0?0:n}set hints(n){this._hints=n||null}get hints(){return this._hints}listVideoInputDevices(){return Ie(this,void 0,void 0,function*(){if(!this.hasNavigator)throw new Error("Can't enumerate devices, navigator is not present.");if(!this.canEnumerateDevices)throw new Error("Can't enumerate devices, method not supported.");const n=yield navigator.mediaDevices.enumerateDevices(),r=[];for(const s of n){const o=s.kind==="video"?"videoinput":s.kind;if(o!=="videoinput")continue;const a=s.deviceId||s.id,u=s.label||`Video device ${r.length+1}`,d=s.groupId,h={deviceId:a,label:u,kind:o,groupId:d};r.push(h)}return r})}getVideoInputDevices(){return Ie(this,void 0,void 0,function*(){return(yield this.listVideoInputDevices()).map(r=>new Ge(r.deviceId,r.label))})}findDeviceById(n){return Ie(this,void 0,void 0,function*(){const r=yield this.listVideoInputDevices();return r?r.find(s=>s.deviceId===n):null})}decodeFromInputVideoDevice(n,r){return Ie(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(n,r)})}decodeOnceFromVideoDevice(n,r){return Ie(this,void 0,void 0,function*(){this.reset();let s;n?s={deviceId:{exact:n}}:s={facingMode:"environment"};const o={video:s};return yield this.decodeOnceFromConstraints(o,r)})}decodeOnceFromConstraints(n,r){return Ie(this,void 0,void 0,function*(){const s=yield navigator.mediaDevices.getUserMedia(n);return yield this.decodeOnceFromStream(s,r)})}decodeOnceFromStream(n,r){return Ie(this,void 0,void 0,function*(){this.reset();const s=yield this.attachStreamToVideo(n,r);return yield this.decodeOnce(s)})}decodeFromInputVideoDeviceContinuously(n,r,s){return Ie(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(n,r,s)})}decodeFromVideoDevice(n,r,s){return Ie(this,void 0,void 0,function*(){let o;n?o={deviceId:{exact:n}}:o={facingMode:"environment"};const a={video:o};return yield this.decodeFromConstraints(a,r,s)})}decodeFromConstraints(n,r,s){return Ie(this,void 0,void 0,function*(){const o=yield navigator.mediaDevices.getUserMedia(n);return yield this.decodeFromStream(o,r,s)})}decodeFromStream(n,r,s){return Ie(this,void 0,void 0,function*(){this.reset();const o=yield this.attachStreamToVideo(n,r);return yield this.decodeContinuously(o,s)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(n,r){return Ie(this,void 0,void 0,function*(){const s=this.prepareVideoElement(r);return this.addVideoSource(s,n),this.videoElement=s,this.stream=n,yield this.playVideoOnLoadAsync(s),s})}playVideoOnLoadAsync(n){return new Promise((r,s)=>this.playVideoOnLoad(n,()=>r()))}playVideoOnLoad(n,r){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(n),n.addEventListener("ended",this.videoEndedListener),n.addEventListener("canplay",this.videoCanPlayListener),n.addEventListener("playing",r),this.tryPlayVideo(n)}isVideoPlaying(n){return n.currentTime>0&&!n.paused&&!n.ended&&n.readyState>2}tryPlayVideo(n){return Ie(this,void 0,void 0,function*(){if(this.isVideoPlaying(n)){console.warn("Trying to play video that is already playing.");return}try{yield n.play()}catch{console.warn("It was not possible to play the video.")}})}getMediaElement(n,r){const s=document.getElementById(n);if(!s)throw new _(`element with id '${n}' not found`);if(s.nodeName.toLowerCase()!==r.toLowerCase())throw new _(`element with id '${n}' must be an ${r} element`);return s}decodeFromImage(n,r){if(!n&&!r)throw new _("either imageElement with a src set or an url must be provided");return r&&!n?this.decodeFromImageUrl(r):this.decodeFromImageElement(n)}decodeFromVideo(n,r){if(!n&&!r)throw new _("Either an element with a src set or an URL must be provided");return r&&!n?this.decodeFromVideoUrl(r):this.decodeFromVideoElement(n)}decodeFromVideoContinuously(n,r,s){if(n===void 0&&r===void 0)throw new _("Either an element with a src set or an URL must be provided");return r&&!n?this.decodeFromVideoUrlContinuously(r,s):this.decodeFromVideoElementContinuously(n,s)}decodeFromImageElement(n){if(!n)throw new _("An image element must be provided.");this.reset();const r=this.prepareImageElement(n);this.imageElement=r;let s;return this.isImageLoaded(r)?s=this.decodeOnce(r,!1,!0):s=this._decodeOnLoadImage(r),s}decodeFromVideoElement(n){const r=this._decodeFromVideoElementSetup(n);return this._decodeOnLoadVideo(r)}decodeFromVideoElementContinuously(n,r){const s=this._decodeFromVideoElementSetup(n);return this._decodeOnLoadVideoContinuously(s,r)}_decodeFromVideoElementSetup(n){if(!n)throw new _("A video element must be provided.");this.reset();const r=this.prepareVideoElement(n);return this.videoElement=r,r}decodeFromImageUrl(n){if(!n)throw new _("An URL must be provided.");this.reset();const r=this.prepareImageElement();this.imageElement=r;const s=this._decodeOnLoadImage(r);return r.src=n,s}decodeFromVideoUrl(n){if(!n)throw new _("An URL must be provided.");this.reset();const r=this.prepareVideoElement(),s=this.decodeFromVideoElement(r);return r.src=n,s}decodeFromVideoUrlContinuously(n,r){if(!n)throw new _("An URL must be provided.");this.reset();const s=this.prepareVideoElement(),o=this.decodeFromVideoElementContinuously(s,r);return s.src=n,o}_decodeOnLoadImage(n){return new Promise((r,s)=>{this.imageLoadedListener=()=>this.decodeOnce(n,!1,!0).then(r,s),n.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(n){return Ie(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(n),yield this.decodeOnce(n)})}_decodeOnLoadVideoContinuously(n,r){return Ie(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(n),this.decodeContinuously(n,r)})}isImageLoaded(n){return!(!n.complete||n.naturalWidth===0)}prepareImageElement(n){let r;return typeof n>"u"&&(r=document.createElement("img"),r.width=200,r.height=200),typeof n=="string"&&(r=this.getMediaElement(n,"img")),n instanceof HTMLImageElement&&(r=n),r}prepareVideoElement(n){let r;return!n&&typeof document<"u"&&(r=document.createElement("video"),r.width=200,r.height=200),typeof n=="string"&&(r=this.getMediaElement(n,"video")),n instanceof HTMLVideoElement&&(r=n),r.setAttribute("autoplay","true"),r.setAttribute("muted","true"),r.setAttribute("playsinline","true"),r}decodeOnce(n,r=!0,s=!0){this._stopAsyncDecode=!1;const o=(a,u)=>{if(this._stopAsyncDecode){u(new j("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{const d=this.decode(n);a(d)}catch(d){const h=r&&d instanceof j,x=(d instanceof M||d instanceof k)&&s;if(h||x)return setTimeout(o,this._timeBetweenDecodingAttempts,a,u);u(d)}};return new Promise((a,u)=>o(a,u))}decodeContinuously(n,r){this._stopContinuousDecode=!1;const s=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{const o=this.decode(n);r(o,null),setTimeout(s,this.timeBetweenScansMillis)}catch(o){r(null,o);const a=o instanceof M||o instanceof k,u=o instanceof j;(a||u)&&setTimeout(s,this._timeBetweenDecodingAttempts)}};s()}decode(n){const r=this.createBinaryBitmap(n);return this.decodeBitmap(r)}_isHTMLVideoElement(n){return n.videoWidth!==0}drawFrameOnCanvas(n,r,s){r||(r={sx:0,sy:0,sWidth:n.videoWidth,sHeight:n.videoHeight,dx:0,dy:0,dWidth:n.videoWidth,dHeight:n.videoHeight}),s||(s=this.captureCanvasContext),s.drawImage(n,r.sx,r.sy,r.sWidth,r.sHeight,r.dx,r.dy,r.dWidth,r.dHeight)}drawImageOnCanvas(n,r,s=this.captureCanvasContext){r||(r={sx:0,sy:0,sWidth:n.naturalWidth,sHeight:n.naturalHeight,dx:0,dy:0,dWidth:n.naturalWidth,dHeight:n.naturalHeight}),s||(s=this.captureCanvasContext),s.drawImage(n,r.sx,r.sy,r.sWidth,r.sHeight,r.dx,r.dy,r.dWidth,r.dHeight)}createBinaryBitmap(n){this.getCaptureCanvasContext(n),this._isHTMLVideoElement(n)?this.drawFrameOnCanvas(n):this.drawImageOnCanvas(n);const r=this.getCaptureCanvas(n),s=new pe(r),o=new xe(s);return new R(o)}getCaptureCanvasContext(n){if(!this.captureCanvasContext){const s=this.getCaptureCanvas(n).getContext("2d");this.captureCanvasContext=s}return this.captureCanvasContext}getCaptureCanvas(n){if(!this.captureCanvas){const r=this.createCaptureCanvas(n);this.captureCanvas=r}return this.captureCanvas}decodeBitmap(n){return this.reader.decode(n,this._hints)}createCaptureCanvas(n){if(typeof document>"u")return this._destroyCaptureCanvas(),null;const r=document.createElement("canvas");let s,o;return typeof n<"u"&&(n instanceof HTMLVideoElement?(s=n.videoWidth,o=n.videoHeight):n instanceof HTMLImageElement&&(s=n.naturalWidth||n.width,o=n.naturalHeight||n.height)),r.style.width=s+"px",r.style.height=o+"px",r.width=s,r.height=o,r}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(n=>n.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(n,r){try{n.srcObject=r}catch{n.src=URL.createObjectURL(r)}}cleanVideoSource(n){try{n.srcObject=null}catch{n.src=""}this.videoElement.removeAttribute("src")}}class Ke{constructor(n,r,s=r==null?0:8*r.length,o,a,u=B.currentTimeMillis()){this.text=n,this.rawBytes=r,this.numBits=s,this.resultPoints=o,this.format=a,this.timestamp=u,this.text=n,this.rawBytes=r,s==null?this.numBits=r==null?0:8*r.length:this.numBits=s,this.resultPoints=o,this.format=a,this.resultMetadata=null,u==null?this.timestamp=B.currentTimeMillis():this.timestamp=u}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(n,r){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(n,r)}putAllMetadata(n){n!==null&&(this.resultMetadata===null?this.resultMetadata=n:this.resultMetadata=new Map(n))}addResultPoints(n){const r=this.resultPoints;if(r===null)this.resultPoints=n;else if(n!==null&&n.length>0){const s=new Array(r.length+n.length);B.arraycopy(r,0,s,0,r.length),B.arraycopy(n,0,s,r.length,n.length),this.resultPoints=s}}getTimestamp(){return this.timestamp}toString(){return this.text}}var kr;(function(y){y[y.AZTEC=0]="AZTEC",y[y.CODABAR=1]="CODABAR",y[y.CODE_39=2]="CODE_39",y[y.CODE_93=3]="CODE_93",y[y.CODE_128=4]="CODE_128",y[y.DATA_MATRIX=5]="DATA_MATRIX",y[y.EAN_8=6]="EAN_8",y[y.EAN_13=7]="EAN_13",y[y.ITF=8]="ITF",y[y.MAXICODE=9]="MAXICODE",y[y.PDF_417=10]="PDF_417",y[y.QR_CODE=11]="QR_CODE",y[y.RSS_14=12]="RSS_14",y[y.RSS_EXPANDED=13]="RSS_EXPANDED",y[y.UPC_A=14]="UPC_A",y[y.UPC_E=15]="UPC_E",y[y.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(kr||(kr={}));var le=kr,ir;(function(y){y[y.OTHER=0]="OTHER",y[y.ORIENTATION=1]="ORIENTATION",y[y.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",y[y.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",y[y.ISSUE_NUMBER=4]="ISSUE_NUMBER",y[y.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",y[y.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",y[y.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",y[y.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",y[y.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",y[y.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(ir||(ir={}));var mt=ir;class Qi{constructor(n,r,s,o,a=-1,u=-1){this.rawBytes=n,this.text=r,this.byteSegments=s,this.ecLevel=o,this.structuredAppendSequenceNumber=a,this.structuredAppendParity=u,this.numBits=n==null?0:8*n.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(n){this.numBits=n}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(n){this.errorsCorrected=n}getErasures(){return this.erasures}setErasures(n){this.erasures=n}getOther(){return this.other}setOther(n){this.other=n}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class qi{exp(n){return this.expTable[n]}log(n){if(n===0)throw new v;return this.logTable[n]}static addOrSubtract(n,r){return n^r}}class Ht{constructor(n,r){if(r.length===0)throw new v;this.field=n;const s=r.length;if(s>1&&r[0]===0){let o=1;for(;o<s&&r[o]===0;)o++;o===s?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(s-o),B.arraycopy(r,o,this.coefficients,0,this.coefficients.length))}else this.coefficients=r}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(n){return this.coefficients[this.coefficients.length-1-n]}evaluateAt(n){if(n===0)return this.getCoefficient(0);const r=this.coefficients;let s;if(n===1){s=0;for(let u=0,d=r.length;u!==d;u++){const h=r[u];s=qi.addOrSubtract(s,h)}return s}s=r[0];const o=r.length,a=this.field;for(let u=1;u<o;u++)s=qi.addOrSubtract(a.multiply(n,s),r[u]);return s}addOrSubtract(n){if(!this.field.equals(n.field))throw new v("GenericGFPolys do not have same GenericGF field");if(this.isZero())return n;if(n.isZero())return this;let r=this.coefficients,s=n.coefficients;if(r.length>s.length){const u=r;r=s,s=u}let o=new Int32Array(s.length);const a=s.length-r.length;B.arraycopy(s,0,o,0,a);for(let u=a;u<s.length;u++)o[u]=qi.addOrSubtract(r[u-a],s[u]);return new Ht(this.field,o)}multiply(n){if(!this.field.equals(n.field))throw new v("GenericGFPolys do not have same GenericGF field");if(this.isZero()||n.isZero())return this.field.getZero();const r=this.coefficients,s=r.length,o=n.coefficients,a=o.length,u=new Int32Array(s+a-1),d=this.field;for(let h=0;h<s;h++){const g=r[h];for(let x=0;x<a;x++)u[h+x]=qi.addOrSubtract(u[h+x],d.multiply(g,o[x]))}return new Ht(d,u)}multiplyScalar(n){if(n===0)return this.field.getZero();if(n===1)return this;const r=this.coefficients.length,s=this.field,o=new Int32Array(r),a=this.coefficients;for(let u=0;u<r;u++)o[u]=s.multiply(a[u],n);return new Ht(s,o)}multiplyByMonomial(n,r){if(n<0)throw new v;if(r===0)return this.field.getZero();const s=this.coefficients,o=s.length,a=new Int32Array(o+n),u=this.field;for(let d=0;d<o;d++)a[d]=u.multiply(s[d],r);return new Ht(u,a)}divide(n){if(!this.field.equals(n.field))throw new v("GenericGFPolys do not have same GenericGF field");if(n.isZero())throw new v("Divide by 0");const r=this.field;let s=r.getZero(),o=this;const a=n.getCoefficient(n.getDegree()),u=r.inverse(a);for(;o.getDegree()>=n.getDegree()&&!o.isZero();){const d=o.getDegree()-n.getDegree(),h=r.multiply(o.getCoefficient(o.getDegree()),u),g=n.multiplyByMonomial(d,h),x=r.buildMonomial(d,h);s=s.addOrSubtract(x),o=o.addOrSubtract(g)}return[s,o]}toString(){let n="";for(let r=this.getDegree();r>=0;r--){let s=this.getCoefficient(r);if(s!==0){if(s<0?(n+=" - ",s=-s):n.length>0&&(n+=" + "),r===0||s!==1){const o=this.field.log(s);o===0?n+="1":o===1?n+="a":(n+="a^",n+=o)}r!==0&&(r===1?n+="x":(n+="x^",n+=r))}}return n}}class io extends m{}io.kind="ArithmeticException";class be extends qi{constructor(n,r,s){super(),this.primitive=n,this.size=r,this.generatorBase=s;const o=new Int32Array(r);let a=1;for(let d=0;d<r;d++)o[d]=a,a*=2,a>=r&&(a^=n,a&=r-1);this.expTable=o;const u=new Int32Array(r);for(let d=0;d<r-1;d++)u[o[d]]=d;this.logTable=u,this.zero=new Ht(this,Int32Array.from([0])),this.one=new Ht(this,Int32Array.from([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(n,r){if(n<0)throw new v;if(r===0)return this.zero;const s=new Int32Array(n+1);return s[0]=r,new Ht(this,s)}inverse(n){if(n===0)throw new io;return this.expTable[this.size-this.logTable[n]-1]}multiply(n,r){return n===0||r===0?0:this.expTable[(this.logTable[n]+this.logTable[r])%(this.size-1)]}getSize(){return this.size}getGeneratorBase(){return this.generatorBase}toString(){return"GF(0x"+N.toHexString(this.primitive)+","+this.size+")"}equals(n){return n===this}}be.AZTEC_DATA_12=new be(4201,4096,1),be.AZTEC_DATA_10=new be(1033,1024,1),be.AZTEC_DATA_6=new be(67,64,1),be.AZTEC_PARAM=new be(19,16,1),be.QR_CODE_FIELD_256=new be(285,256,0),be.DATA_MATRIX_FIELD_256=new be(301,256,1),be.AZTEC_DATA_8=be.DATA_MATRIX_FIELD_256,be.MAXICODE_FIELD_64=be.AZTEC_DATA_6;class ri extends m{}ri.kind="ReedSolomonException";class Dn extends m{}Dn.kind="IllegalStateException";class $i{constructor(n){this.field=n}decode(n,r){const s=this.field,o=new Ht(s,n),a=new Int32Array(r);let u=!0;for(let I=0;I<r;I++){const b=o.evaluateAt(s.exp(I+s.getGeneratorBase()));a[a.length-1-I]=b,b!==0&&(u=!1)}if(u)return;const d=new Ht(s,a),h=this.runEuclideanAlgorithm(s.buildMonomial(r,1),d,r),g=h[0],x=h[1],E=this.findErrorLocations(g),A=this.findErrorMagnitudes(x,E);for(let I=0;I<E.length;I++){const b=n.length-1-s.log(E[I]);if(b<0)throw new ri("Bad error location");n[b]=be.addOrSubtract(n[b],A[I])}}runEuclideanAlgorithm(n,r,s){if(n.getDegree()<r.getDegree()){const I=n;n=r,r=I}const o=this.field;let a=n,u=r,d=o.getZero(),h=o.getOne();for(;u.getDegree()>=(s/2|0);){let I=a,b=d;if(a=u,d=h,a.isZero())throw new ri("r_{i-1} was zero");u=I;let D=o.getZero();const L=a.getCoefficient(a.getDegree()),z=o.inverse(L);for(;u.getDegree()>=a.getDegree()&&!u.isZero();){const q=u.getDegree()-a.getDegree(),$=o.multiply(u.getCoefficient(u.getDegree()),z);D=D.addOrSubtract(o.buildMonomial(q,$)),u=u.addOrSubtract(a.multiplyByMonomial(q,$))}if(h=D.multiply(d).addOrSubtract(b),u.getDegree()>=a.getDegree())throw new Dn("Division algorithm failed to reduce polynomial?")}const g=h.getCoefficient(0);if(g===0)throw new ri("sigmaTilde(0) was zero");const x=o.inverse(g),E=h.multiplyScalar(x),A=u.multiplyScalar(x);return[E,A]}findErrorLocations(n){const r=n.getDegree();if(r===1)return Int32Array.from([n.getCoefficient(1)]);const s=new Int32Array(r);let o=0;const a=this.field;for(let u=1;u<a.getSize()&&o<r;u++)n.evaluateAt(u)===0&&(s[o]=a.inverse(u),o++);if(o!==r)throw new ri("Error locator degree does not match number of roots");return s}findErrorMagnitudes(n,r){const s=r.length,o=new Int32Array(s),a=this.field;for(let u=0;u<s;u++){const d=a.inverse(r[u]);let h=1;for(let g=0;g<s;g++)if(u!==g){const x=a.multiply(r[g],d),E=x&1?x&-2:x|1;h=a.multiply(h,E)}o[u]=a.multiply(n.evaluateAt(d),a.inverse(h)),a.getGeneratorBase()!==0&&(o[u]=a.multiply(o[u],d))}return o}}var vt;(function(y){y[y.UPPER=0]="UPPER",y[y.LOWER=1]="LOWER",y[y.MIXED=2]="MIXED",y[y.DIGIT=3]="DIGIT",y[y.PUNCT=4]="PUNCT",y[y.BINARY=5]="BINARY"})(vt||(vt={}));class Ue{decode(n){this.ddata=n;let r=n.getBits(),s=this.extractBits(r),o=this.correctBits(s),a=Ue.convertBoolArrayToByteArray(o),u=Ue.getEncodedData(o),d=new Qi(a,u,null,null);return d.setNumBits(o.length),d}static highLevelDecode(n){return this.getEncodedData(n)}static getEncodedData(n){let r=n.length,s=vt.UPPER,o=vt.UPPER,a="",u=0;for(;u<r;)if(o===vt.BINARY){if(r-u<5)break;let d=Ue.readCode(n,u,5);if(u+=5,d===0){if(r-u<11)break;d=Ue.readCode(n,u,11)+31,u+=11}for(let h=0;h<d;h++){if(r-u<8){u=r;break}const g=Ue.readCode(n,u,8);a+=ie.castAsNonUtf8Char(g),u+=8}o=s}else{let d=o===vt.DIGIT?4:5;if(r-u<d)break;let h=Ue.readCode(n,u,d);u+=d;let g=Ue.getCharacter(o,h);g.startsWith("CTRL_")?(s=o,o=Ue.getTable(g.charAt(5)),g.charAt(6)==="L"&&(s=o)):(a+=g,o=s)}return a}static getTable(n){switch(n){case"L":return vt.LOWER;case"P":return vt.PUNCT;case"M":return vt.MIXED;case"D":return vt.DIGIT;case"B":return vt.BINARY;case"U":default:return vt.UPPER}}static getCharacter(n,r){switch(n){case vt.UPPER:return Ue.UPPER_TABLE[r];case vt.LOWER:return Ue.LOWER_TABLE[r];case vt.MIXED:return Ue.MIXED_TABLE[r];case vt.PUNCT:return Ue.PUNCT_TABLE[r];case vt.DIGIT:return Ue.DIGIT_TABLE[r];default:throw new Dn("Bad table")}}correctBits(n){let r,s;this.ddata.getNbLayers()<=2?(s=6,r=be.AZTEC_DATA_6):this.ddata.getNbLayers()<=8?(s=8,r=be.AZTEC_DATA_8):this.ddata.getNbLayers()<=22?(s=10,r=be.AZTEC_DATA_10):(s=12,r=be.AZTEC_DATA_12);let o=this.ddata.getNbDatablocks(),a=n.length/s;if(a<o)throw new k;let u=n.length%s,d=new Int32Array(a);for(let A=0;A<a;A++,u+=s)d[A]=Ue.readCode(n,u,s);try{new $i(r).decode(d,a-o)}catch(A){throw new k(A)}let h=(1<<s)-1,g=0;for(let A=0;A<o;A++){let I=d[A];if(I===0||I===h)throw new k;(I===1||I===h-1)&&g++}let x=new Array(o*s-g),E=0;for(let A=0;A<o;A++){let I=d[A];if(I===1||I===h-1)x.fill(I>1,E,E+s-1),E+=s-1;else for(let b=s-1;b>=0;--b)x[E++]=(I&1<<b)!==0}return x}extractBits(n){let r=this.ddata.isCompact(),s=this.ddata.getNbLayers(),o=(r?11:14)+s*4,a=new Int32Array(o),u=new Array(this.totalBitsInLayer(s,r));if(r)for(let d=0;d<a.length;d++)a[d]=d;else{let d=o+1+2*N.truncDivision(N.truncDivision(o,2)-1,15),h=o/2,g=N.truncDivision(d,2);for(let x=0;x<h;x++){let E=x+N.truncDivision(x,15);a[h-x-1]=g-E-1,a[h+x]=g+E+1}}for(let d=0,h=0;d<s;d++){let g=(s-d)*4+(r?9:12),x=d*2,E=o-1-x;for(let A=0;A<g;A++){let I=A*2;for(let b=0;b<2;b++)u[h+I+b]=n.get(a[x+b],a[x+A]),u[h+2*g+I+b]=n.get(a[x+A],a[E-b]),u[h+4*g+I+b]=n.get(a[E-b],a[E-A]),u[h+6*g+I+b]=n.get(a[E-A],a[x+b])}h+=g*8}return u}static readCode(n,r,s){let o=0;for(let a=r;a<r+s;a++)o<<=1,n[a]&&(o|=1);return o}static readByte(n,r){let s=n.length-r;return s>=8?Ue.readCode(n,r,8):Ue.readCode(n,r,s)<<8-s}static convertBoolArrayToByteArray(n){let r=new Uint8Array((n.length+7)/8);for(let s=0;s<r.length;s++)r[s]=Ue.readByte(n,8*s);return r}totalBitsInLayer(n,r){return((r?88:112)+16*n)*n}}Ue.UPPER_TABLE=["CTRL_PS"," ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","CTRL_LL","CTRL_ML","CTRL_DL","CTRL_BS"],Ue.LOWER_TABLE=["CTRL_PS"," ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","CTRL_US","CTRL_ML","CTRL_DL","CTRL_BS"],Ue.MIXED_TABLE=["CTRL_PS"," ","\\1","\\2","\\3","\\4","\\5","\\6","\\7","\b"," ",`
63
63
  `,"\\13","\f","\r","\\33","\\34","\\35","\\36","\\37","@","\\","^","_","`","|","~","\\177","CTRL_LL","CTRL_UL","CTRL_PL","CTRL_BS"],Ue.PUNCT_TABLE=["","\r",`\r
64
- `,". ",", ",": ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}","CTRL_UL"],Ue.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class Te{constructor(){}static round(n){return n===NaN?0:n<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:n>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:n+(n<0?-.5:.5)|0}static distance(n,r,s,o){const a=n-s,u=r-o;return Math.sqrt(a*a+u*u)}static sum(n){let r=0;for(let s=0,o=n.length;s!==o;s++){const a=n[s];r+=a}return r}}class so{static floatToIntBits(n){return n}}so.MAX_VALUE=Number.MAX_SAFE_INTEGER;class oe{constructor(n,r){this.x=n,this.y=r}getX(){return this.x}getY(){return this.y}equals(n){if(n instanceof oe){const r=n;return this.x===r.x&&this.y===r.y}return!1}hashCode(){return 31*so.floatToIntBits(this.x)+so.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(n){const r=this.distance(n[0],n[1]),s=this.distance(n[1],n[2]),o=this.distance(n[0],n[2]);let a,u,d;if(s>=r&&s>=o?(u=n[0],a=n[1],d=n[2]):o>=s&&o>=r?(u=n[1],a=n[0],d=n[2]):(u=n[2],a=n[0],d=n[1]),this.crossProductZ(a,u,d)<0){const h=a;a=d,d=h}n[0]=a,n[1]=u,n[2]=d}static distance(n,r){return Te.distance(n.x,n.y,r.x,r.y)}static crossProductZ(n,r,s){const o=r.x,a=r.y;return(s.x-o)*(n.y-a)-(s.y-a)*(n.x-o)}}class oo{constructor(n,r){this.bits=n,this.points=r}getBits(){return this.bits}getPoints(){return this.points}}class Kc extends oo{constructor(n,r,s,o,a){super(n,r),this.compact=s,this.nbDatablocks=o,this.nbLayers=a}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class Gn{constructor(n,r,s,o){this.image=n,this.height=n.getHeight(),this.width=n.getWidth(),r==null&&(r=Gn.INIT_SIZE),s==null&&(s=n.getWidth()/2|0),o==null&&(o=n.getHeight()/2|0);const a=r/2|0;if(this.leftInit=s-a,this.rightInit=s+a,this.upInit=o-a,this.downInit=o+a,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new j}detect(){let n=this.leftInit,r=this.rightInit,s=this.upInit,o=this.downInit,a=!1,u=!0,d=!1,h=!1,g=!1,x=!1,E=!1;const A=this.width,I=this.height;for(;u;){u=!1;let b=!0;for(;(b||!h)&&r<A;)b=this.containsBlackPoint(s,o,r,!1),b?(r++,u=!0,h=!0):h||r++;if(r>=A){a=!0;break}let D=!0;for(;(D||!g)&&o<I;)D=this.containsBlackPoint(n,r,o,!0),D?(o++,u=!0,g=!0):g||o++;if(o>=I){a=!0;break}let L=!0;for(;(L||!x)&&n>=0;)L=this.containsBlackPoint(s,o,n,!1),L?(n--,u=!0,x=!0):x||n--;if(n<0){a=!0;break}let z=!0;for(;(z||!E)&&s>=0;)z=this.containsBlackPoint(n,r,s,!0),z?(s--,u=!0,E=!0):E||s--;if(s<0){a=!0;break}u&&(d=!0)}if(!a&&d){const b=r-n;let D=null;for(let $=1;D===null&&$<b;$++)D=this.getBlackPointOnSegment(n,o-$,n+$,o);if(D==null)throw new j;let L=null;for(let $=1;L===null&&$<b;$++)L=this.getBlackPointOnSegment(n,s+$,n+$,s);if(L==null)throw new j;let z=null;for(let $=1;z===null&&$<b;$++)z=this.getBlackPointOnSegment(r,s+$,r-$,s);if(z==null)throw new j;let q=null;for(let $=1;q===null&&$<b;$++)q=this.getBlackPointOnSegment(r,o-$,r-$,o);if(q==null)throw new j;return this.centerEdges(q,D,z,L)}else throw new j}getBlackPointOnSegment(n,r,s,o){const a=Te.round(Te.distance(n,r,s,o)),u=(s-n)/a,d=(o-r)/a,h=this.image;for(let g=0;g<a;g++){const x=Te.round(n+g*u),E=Te.round(r+g*d);if(h.get(x,E))return new oe(x,E)}return null}centerEdges(n,r,s,o){const a=n.getX(),u=n.getY(),d=r.getX(),h=r.getY(),g=s.getX(),x=s.getY(),E=o.getX(),A=o.getY(),I=Gn.CORR;return a<this.width/2?[new oe(E-I,A+I),new oe(d+I,h+I),new oe(g-I,x-I),new oe(a+I,u-I)]:[new oe(E+I,A+I),new oe(d+I,h-I),new oe(g-I,x+I),new oe(a-I,u-I)]}containsBlackPoint(n,r,s,o){const a=this.image;if(o){for(let u=n;u<=r;u++)if(a.get(u,s))return!0}else for(let u=n;u<=r;u++)if(a.get(s,u))return!0;return!1}}Gn.INIT_SIZE=10,Gn.CORR=1;class Ha{static checkAndNudgePoints(n,r){const s=n.getWidth(),o=n.getHeight();let a=!0;for(let u=0;u<r.length&&a;u+=2){const d=Math.floor(r[u]),h=Math.floor(r[u+1]);if(d<-1||d>s||h<-1||h>o)throw new j;a=!1,d===-1?(r[u]=0,a=!0):d===s&&(r[u]=s-1,a=!0),h===-1?(r[u+1]=0,a=!0):h===o&&(r[u+1]=o-1,a=!0)}a=!0;for(let u=r.length-2;u>=0&&a;u-=2){const d=Math.floor(r[u]),h=Math.floor(r[u+1]);if(d<-1||d>s||h<-1||h>o)throw new j;a=!1,d===-1?(r[u]=0,a=!0):d===s&&(r[u]=s-1,a=!0),h===-1?(r[u+1]=0,a=!0):h===o&&(r[u+1]=o-1,a=!0)}}}class Cn{constructor(n,r,s,o,a,u,d,h,g){this.a11=n,this.a21=r,this.a31=s,this.a12=o,this.a22=a,this.a32=u,this.a13=d,this.a23=h,this.a33=g}static quadrilateralToQuadrilateral(n,r,s,o,a,u,d,h,g,x,E,A,I,b,D,L){const z=Cn.quadrilateralToSquare(n,r,s,o,a,u,d,h);return Cn.squareToQuadrilateral(g,x,E,A,I,b,D,L).times(z)}transformPoints(n){const r=n.length,s=this.a11,o=this.a12,a=this.a13,u=this.a21,d=this.a22,h=this.a23,g=this.a31,x=this.a32,E=this.a33;for(let A=0;A<r;A+=2){const I=n[A],b=n[A+1],D=a*I+h*b+E;n[A]=(s*I+u*b+g)/D,n[A+1]=(o*I+d*b+x)/D}}transformPointsWithValues(n,r){const s=this.a11,o=this.a12,a=this.a13,u=this.a21,d=this.a22,h=this.a23,g=this.a31,x=this.a32,E=this.a33,A=n.length;for(let I=0;I<A;I++){const b=n[I],D=r[I],L=a*b+h*D+E;n[I]=(s*b+u*D+g)/L,r[I]=(o*b+d*D+x)/L}}static squareToQuadrilateral(n,r,s,o,a,u,d,h){const g=n-s+a-d,x=r-o+u-h;if(g===0&&x===0)return new Cn(s-n,a-s,n,o-r,u-o,r,0,0,1);{const E=s-a,A=d-a,I=o-u,b=h-u,D=E*b-A*I,L=(g*b-A*x)/D,z=(E*x-g*I)/D;return new Cn(s-n+L*s,d-n+z*d,n,o-r+L*o,h-r+z*h,r,L,z,1)}}static quadrilateralToSquare(n,r,s,o,a,u,d,h){return Cn.squareToQuadrilateral(n,r,s,o,a,u,d,h).buildAdjoint()}buildAdjoint(){return new Cn(this.a22*this.a33-this.a23*this.a32,this.a23*this.a31-this.a21*this.a33,this.a21*this.a32-this.a22*this.a31,this.a13*this.a32-this.a12*this.a33,this.a11*this.a33-this.a13*this.a31,this.a12*this.a31-this.a11*this.a32,this.a12*this.a23-this.a13*this.a22,this.a13*this.a21-this.a11*this.a23,this.a11*this.a22-this.a12*this.a21)}times(n){return new Cn(this.a11*n.a11+this.a21*n.a12+this.a31*n.a13,this.a11*n.a21+this.a21*n.a22+this.a31*n.a23,this.a11*n.a31+this.a21*n.a32+this.a31*n.a33,this.a12*n.a11+this.a22*n.a12+this.a32*n.a13,this.a12*n.a21+this.a22*n.a22+this.a32*n.a23,this.a12*n.a31+this.a22*n.a32+this.a32*n.a33,this.a13*n.a11+this.a23*n.a12+this.a33*n.a13,this.a13*n.a21+this.a23*n.a22+this.a33*n.a23,this.a13*n.a31+this.a23*n.a32+this.a33*n.a33)}}class Qc extends Ha{sampleGrid(n,r,s,o,a,u,d,h,g,x,E,A,I,b,D,L,z,q,$){const Z=Cn.quadrilateralToQuadrilateral(o,a,u,d,h,g,x,E,A,I,b,D,L,z,q,$);return this.sampleGridWithTransform(n,r,s,Z)}sampleGridWithTransform(n,r,s,o){if(r<=0||s<=0)throw new j;const a=new _e(r,s),u=new Float32Array(2*r);for(let d=0;d<s;d++){const h=u.length,g=d+.5;for(let x=0;x<h;x+=2)u[x]=x/2+.5,u[x+1]=g;o.transformPoints(u),Ha.checkAndNudgePoints(n,u);try{for(let x=0;x<h;x+=2)n.get(Math.floor(u[x]),Math.floor(u[x+1]))&&a.set(x/2,d)}catch{throw new j}}return a}}class sr{static setGridSampler(n){sr.gridSampler=n}static getInstance(){return sr.gridSampler}}sr.gridSampler=new Qc;class Lt{constructor(n,r){this.x=n,this.y=r}toResultPoint(){return new oe(this.getX(),this.getY())}getX(){return this.x}getY(){return this.y}}class qc{constructor(n){this.EXPECTED_CORNER_BITS=new Int32Array([3808,476,2107,1799]),this.image=n}detect(){return this.detectMirror(!1)}detectMirror(n){let r=this.getMatrixCenter(),s=this.getBullsEyeCorners(r);if(n){let u=s[0];s[0]=s[2],s[2]=u}this.extractParameters(s);let o=this.sampleGrid(this.image,s[this.shift%4],s[(this.shift+1)%4],s[(this.shift+2)%4],s[(this.shift+3)%4]),a=this.getMatrixCornerPoints(s);return new Kc(o,a,this.compact,this.nbDataBlocks,this.nbLayers)}extractParameters(n){if(!this.isValidPoint(n[0])||!this.isValidPoint(n[1])||!this.isValidPoint(n[2])||!this.isValidPoint(n[3]))throw new j;let r=2*this.nbCenterLayers,s=new Int32Array([this.sampleLine(n[0],n[1],r),this.sampleLine(n[1],n[2],r),this.sampleLine(n[2],n[3],r),this.sampleLine(n[3],n[0],r)]);this.shift=this.getRotation(s,r);let o=0;for(let u=0;u<4;u++){let d=s[(this.shift+u)%4];this.compact?(o<<=7,o+=d>>1&127):(o<<=10,o+=(d>>2&992)+(d>>1&31))}let a=this.getCorrectedParameterData(o,this.compact);this.compact?(this.nbLayers=(a>>6)+1,this.nbDataBlocks=(a&63)+1):(this.nbLayers=(a>>11)+1,this.nbDataBlocks=(a&2047)+1)}getRotation(n,r){let s=0;n.forEach((o,a,u)=>{let d=(o>>r-2<<1)+(o&1);s=(s<<3)+d}),s=((s&1)<<11)+(s>>1);for(let o=0;o<4;o++)if(N.bitCount(s^this.EXPECTED_CORNER_BITS[o])<=2)return o;throw new j}getCorrectedParameterData(n,r){let s,o;r?(s=7,o=2):(s=10,o=4);let a=s-o,u=new Int32Array(s);for(let h=s-1;h>=0;--h)u[h]=n&15,n>>=4;try{new $i(be.AZTEC_PARAM).decode(u,a)}catch{throw new j}let d=0;for(let h=0;h<o;h++)d=(d<<4)+u[h];return d}getBullsEyeCorners(n){let r=n,s=n,o=n,a=n,u=!0;for(this.nbCenterLayers=1;this.nbCenterLayers<9;this.nbCenterLayers++){let E=this.getFirstDifferent(r,u,1,-1),A=this.getFirstDifferent(s,u,1,1),I=this.getFirstDifferent(o,u,-1,1),b=this.getFirstDifferent(a,u,-1,-1);if(this.nbCenterLayers>2){let D=this.distancePoint(b,E)*this.nbCenterLayers/(this.distancePoint(a,r)*(this.nbCenterLayers+2));if(D<.75||D>1.25||!this.isWhiteOrBlackRectangle(E,A,I,b))break}r=E,s=A,o=I,a=b,u=!u}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new j;this.compact=this.nbCenterLayers===5;let d=new oe(r.getX()+.5,r.getY()-.5),h=new oe(s.getX()+.5,s.getY()+.5),g=new oe(o.getX()-.5,o.getY()+.5),x=new oe(a.getX()-.5,a.getY()-.5);return this.expandSquare([d,h,g,x],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let n,r,s,o;try{let d=new Gn(this.image).detect();n=d[0],r=d[1],s=d[2],o=d[3]}catch{let h=this.image.getWidth()/2,g=this.image.getHeight()/2;n=this.getFirstDifferent(new Lt(h+7,g-7),!1,1,-1).toResultPoint(),r=this.getFirstDifferent(new Lt(h+7,g+7),!1,1,1).toResultPoint(),s=this.getFirstDifferent(new Lt(h-7,g+7),!1,-1,1).toResultPoint(),o=this.getFirstDifferent(new Lt(h-7,g-7),!1,-1,-1).toResultPoint()}let a=Te.round((n.getX()+o.getX()+r.getX()+s.getX())/4),u=Te.round((n.getY()+o.getY()+r.getY()+s.getY())/4);try{let d=new Gn(this.image,15,a,u).detect();n=d[0],r=d[1],s=d[2],o=d[3]}catch{n=this.getFirstDifferent(new Lt(a+7,u-7),!1,1,-1).toResultPoint(),r=this.getFirstDifferent(new Lt(a+7,u+7),!1,1,1).toResultPoint(),s=this.getFirstDifferent(new Lt(a-7,u+7),!1,-1,1).toResultPoint(),o=this.getFirstDifferent(new Lt(a-7,u-7),!1,-1,-1).toResultPoint()}return a=Te.round((n.getX()+o.getX()+r.getX()+s.getX())/4),u=Te.round((n.getY()+o.getY()+r.getY()+s.getY())/4),new Lt(a,u)}getMatrixCornerPoints(n){return this.expandSquare(n,2*this.nbCenterLayers,this.getDimension())}sampleGrid(n,r,s,o,a){let u=sr.getInstance(),d=this.getDimension(),h=d/2-this.nbCenterLayers,g=d/2+this.nbCenterLayers;return u.sampleGrid(n,d,d,h,h,g,h,g,g,h,g,r.getX(),r.getY(),s.getX(),s.getY(),o.getX(),o.getY(),a.getX(),a.getY())}sampleLine(n,r,s){let o=0,a=this.distanceResultPoint(n,r),u=a/s,d=n.getX(),h=n.getY(),g=u*(r.getX()-n.getX())/a,x=u*(r.getY()-n.getY())/a;for(let E=0;E<s;E++)this.image.get(Te.round(d+E*g),Te.round(h+E*x))&&(o|=1<<s-E-1);return o}isWhiteOrBlackRectangle(n,r,s,o){let a=3;n=new Lt(n.getX()-a,n.getY()+a),r=new Lt(r.getX()-a,r.getY()-a),s=new Lt(s.getX()+a,s.getY()-a),o=new Lt(o.getX()+a,o.getY()+a);let u=this.getColor(o,n);if(u===0)return!1;let d=this.getColor(n,r);return d!==u||(d=this.getColor(r,s),d!==u)?!1:(d=this.getColor(s,o),d===u)}getColor(n,r){let s=this.distancePoint(n,r),o=(r.getX()-n.getX())/s,a=(r.getY()-n.getY())/s,u=0,d=n.getX(),h=n.getY(),g=this.image.get(n.getX(),n.getY()),x=Math.ceil(s);for(let A=0;A<x;A++)d+=o,h+=a,this.image.get(Te.round(d),Te.round(h))!==g&&u++;let E=u/s;return E>.1&&E<.9?0:E<=.1===g?1:-1}getFirstDifferent(n,r,s,o){let a=n.getX()+s,u=n.getY()+o;for(;this.isValid(a,u)&&this.image.get(a,u)===r;)a+=s,u+=o;for(a-=s,u-=o;this.isValid(a,u)&&this.image.get(a,u)===r;)a+=s;for(a-=s;this.isValid(a,u)&&this.image.get(a,u)===r;)u+=o;return u-=o,new Lt(a,u)}expandSquare(n,r,s){let o=s/(2*r),a=n[0].getX()-n[2].getX(),u=n[0].getY()-n[2].getY(),d=(n[0].getX()+n[2].getX())/2,h=(n[0].getY()+n[2].getY())/2,g=new oe(d+o*a,h+o*u),x=new oe(d-o*a,h-o*u);a=n[1].getX()-n[3].getX(),u=n[1].getY()-n[3].getY(),d=(n[1].getX()+n[3].getX())/2,h=(n[1].getY()+n[3].getY())/2;let E=new oe(d+o*a,h+o*u),A=new oe(d-o*a,h-o*u);return[g,E,x,A]}isValid(n,r){return n>=0&&n<this.image.getWidth()&&r>0&&r<this.image.getHeight()}isValidPoint(n){let r=Te.round(n.getX()),s=Te.round(n.getY());return this.isValid(r,s)}distancePoint(n,r){return Te.distance(n.getX(),n.getY(),r.getX(),r.getY())}distanceResultPoint(n,r){return Te.distance(n.getX(),n.getY(),r.getX(),r.getY())}getDimension(){return this.compact?4*this.nbLayers+11:this.nbLayers<=4?4*this.nbLayers+15:4*this.nbLayers+2*(N.truncDivision(this.nbLayers-4,8)+1)+15}}class ao{decode(n,r=null){let s=null,o=new qc(n.getBlackMatrix()),a=null,u=null;try{let x=o.detectMirror(!1);a=x.getPoints(),this.reportFoundResultPoints(r,a),u=new Ue().decode(x)}catch(x){s=x}if(u==null)try{let x=o.detectMirror(!0);a=x.getPoints(),this.reportFoundResultPoints(r,a),u=new Ue().decode(x)}catch(x){throw s??x}let d=new Ke(u.getText(),u.getRawBytes(),u.getNumBits(),a,ae.AZTEC,B.currentTimeMillis()),h=u.getByteSegments();h!=null&&d.putMetadata(mt.BYTE_SEGMENTS,h);let g=u.getECLevel();return g!=null&&d.putMetadata(mt.ERROR_CORRECTION_LEVEL,g),d}reportFoundResultPoints(n,r){if(n!=null){let s=n.get(U.NEED_RESULT_POINT_CALLBACK);s!=null&&r.forEach((o,a,u)=>{s.foundPossibleResultPoint(o)})}}reset(){}}class Rh extends cn{constructor(n=500){super(new ao,n)}}class ut{decode(n,r){try{return this.doDecode(n,r)}catch{if(r&&r.get(U.TRY_HARDER)===!0&&n.isRotateSupported()){const a=n.rotateCounterClockwise(),u=this.doDecode(a,r),d=u.getResultMetadata();let h=270;d!==null&&d.get(mt.ORIENTATION)===!0&&(h=h+d.get(mt.ORIENTATION)%360),u.putMetadata(mt.ORIENTATION,h);const g=u.getResultPoints();if(g!==null){const x=a.getHeight();for(let E=0;E<g.length;E++)g[E]=new oe(x-g[E].getY()-1,g[E].getX())}return u}else throw new j}}reset(){}doDecode(n,r){const s=n.getWidth(),o=n.getHeight();let a=new G(s);const u=r&&r.get(U.TRY_HARDER)===!0,d=Math.max(1,o>>(u?8:5));let h;u?h=o:h=15;const g=Math.trunc(o/2);for(let x=0;x<h;x++){const E=Math.trunc((x+1)/2),A=(x&1)===0,I=g+d*(A?E:-E);if(I<0||I>=o)break;try{a=n.getBlackRow(I,a)}catch{continue}for(let b=0;b<2;b++){if(b===1&&(a.reverse(),r&&r.get(U.NEED_RESULT_POINT_CALLBACK)===!0)){const D=new Map;r.forEach((L,z)=>D.set(z,L)),D.delete(U.NEED_RESULT_POINT_CALLBACK),r=D}try{const D=this.decodeRow(I,a,r);if(b===1){D.putMetadata(mt.ORIENTATION,180);const L=D.getResultPoints();L!==null&&(L[0]=new oe(s-L[0].getX()-1,L[0].getY()),L[1]=new oe(s-L[1].getX()-1,L[1].getY()))}return D}catch{}}}throw new j}static recordPattern(n,r,s){const o=s.length;for(let g=0;g<o;g++)s[g]=0;const a=n.getSize();if(r>=a)throw new j;let u=!n.get(r),d=0,h=r;for(;h<a;){if(n.get(h)!==u)s[d]++;else{if(++d===o)break;s[d]=1,u=!u}h++}if(!(d===o||d===o-1&&h===a))throw new j}static recordPatternInReverse(n,r,s){let o=s.length,a=n.get(r);for(;r>0&&o>=0;)n.get(--r)!==a&&(o--,a=!a);if(o>=0)throw new j;ut.recordPattern(n,r+1,s)}static patternMatchVariance(n,r,s){const o=n.length;let a=0,u=0;for(let g=0;g<o;g++)a+=n[g],u+=r[g];if(a<u)return Number.POSITIVE_INFINITY;const d=a/u;s*=d;let h=0;for(let g=0;g<o;g++){const x=n[g],E=r[g]*d,A=x>E?x-E:E-x;if(A>s)return Number.POSITIVE_INFINITY;h+=A}return h/a}}class J extends ut{static findStartPattern(n){const r=n.getSize(),s=n.getNextSet(0);let o=0,a=Int32Array.from([0,0,0,0,0,0]),u=s,d=!1;const h=6;for(let g=s;g<r;g++)if(n.get(g)!==d)a[o]++;else{if(o===h-1){let x=J.MAX_AVG_VARIANCE,E=-1;for(let A=J.CODE_START_A;A<=J.CODE_START_C;A++){const I=ut.patternMatchVariance(a,J.CODE_PATTERNS[A],J.MAX_INDIVIDUAL_VARIANCE);I<x&&(x=I,E=A)}if(E>=0&&n.isRange(Math.max(0,u-(g-u)/2),u,!1))return Int32Array.from([u,g,E]);u+=a[0]+a[1],a=a.slice(2,a.length-1),a[o-1]=0,a[o]=0,o--}else o++;a[o]=1,d=!d}throw new j}static decodeCode(n,r,s){ut.recordPattern(n,s,r);let o=J.MAX_AVG_VARIANCE,a=-1;for(let u=0;u<J.CODE_PATTERNS.length;u++){const d=J.CODE_PATTERNS[u],h=this.patternMatchVariance(r,d,J.MAX_INDIVIDUAL_VARIANCE);h<o&&(o=h,a=u)}if(a>=0)return a;throw new j}decodeRow(n,r,s){const o=s&&s.get(U.ASSUME_GS1)===!0,a=J.findStartPattern(r),u=a[2];let d=0;const h=new Uint8Array(20);h[d++]=u;let g;switch(u){case J.CODE_START_A:g=J.CODE_CODE_A;break;case J.CODE_START_B:g=J.CODE_CODE_B;break;case J.CODE_START_C:g=J.CODE_CODE_C;break;default:throw new k}let x=!1,E=!1,A="",I=a[0],b=a[1];const D=Int32Array.from([0,0,0,0,0,0]);let L=0,z=0,q=u,$=0,Z=!0,ve=!1,me=!1;for(;!x;){const di=E;switch(E=!1,L=z,z=J.decodeCode(r,D,b),h[d++]=z,z!==J.CODE_STOP&&(Z=!0),z!==J.CODE_STOP&&($++,q+=$*z),I=b,b+=D.reduce((ig,sg)=>ig+sg,0),z){case J.CODE_START_A:case J.CODE_START_B:case J.CODE_START_C:throw new k}switch(g){case J.CODE_CODE_A:if(z<64)me===ve?A+=String.fromCharCode(32+z):A+=String.fromCharCode(32+z+128),me=!1;else if(z<96)me===ve?A+=String.fromCharCode(z-64):A+=String.fromCharCode(z+64),me=!1;else switch(z!==J.CODE_STOP&&(Z=!1),z){case J.CODE_FNC_1:o&&(A.length===0?A+="]C1":A+="");break;case J.CODE_FNC_2:case J.CODE_FNC_3:break;case J.CODE_FNC_4_A:!ve&&me?(ve=!0,me=!1):ve&&me?(ve=!1,me=!1):me=!0;break;case J.CODE_SHIFT:E=!0,g=J.CODE_CODE_B;break;case J.CODE_CODE_B:g=J.CODE_CODE_B;break;case J.CODE_CODE_C:g=J.CODE_CODE_C;break;case J.CODE_STOP:x=!0;break}break;case J.CODE_CODE_B:if(z<96)me===ve?A+=String.fromCharCode(32+z):A+=String.fromCharCode(32+z+128),me=!1;else switch(z!==J.CODE_STOP&&(Z=!1),z){case J.CODE_FNC_1:o&&(A.length===0?A+="]C1":A+="");break;case J.CODE_FNC_2:case J.CODE_FNC_3:break;case J.CODE_FNC_4_B:!ve&&me?(ve=!0,me=!1):ve&&me?(ve=!1,me=!1):me=!0;break;case J.CODE_SHIFT:E=!0,g=J.CODE_CODE_A;break;case J.CODE_CODE_A:g=J.CODE_CODE_A;break;case J.CODE_CODE_C:g=J.CODE_CODE_C;break;case J.CODE_STOP:x=!0;break}break;case J.CODE_CODE_C:if(z<100)z<10&&(A+="0"),A+=z;else switch(z!==J.CODE_STOP&&(Z=!1),z){case J.CODE_FNC_1:o&&(A.length===0?A+="]C1":A+="");break;case J.CODE_CODE_A:g=J.CODE_CODE_A;break;case J.CODE_CODE_B:g=J.CODE_CODE_B;break;case J.CODE_STOP:x=!0;break}break}di&&(g=g===J.CODE_CODE_A?J.CODE_CODE_B:J.CODE_CODE_A)}const Yt=b-I;if(b=r.getNextUnset(b),!r.isRange(b,Math.min(r.getSize(),b+(b-I)/2),!1))throw new j;if(q-=$*L,q%103!==L)throw new M;const vn=A.length;if(vn===0)throw new j;vn>0&&Z&&(g===J.CODE_CODE_C?A=A.substring(0,vn-2):A=A.substring(0,vn-1));const Zt=(a[1]+a[0])/2,Fe=I+Yt/2,_t=h.length,tn=new Uint8Array(_t);for(let di=0;di<_t;di++)tn[di]=h[di];const fi=[new oe(Zt,n),new oe(Fe,n)];return new Ke(A,tn,0,fi,ae.CODE_128,new Date().getTime())}}J.CODE_PATTERNS=[Int32Array.from([2,1,2,2,2,2]),Int32Array.from([2,2,2,1,2,2]),Int32Array.from([2,2,2,2,2,1]),Int32Array.from([1,2,1,2,2,3]),Int32Array.from([1,2,1,3,2,2]),Int32Array.from([1,3,1,2,2,2]),Int32Array.from([1,2,2,2,1,3]),Int32Array.from([1,2,2,3,1,2]),Int32Array.from([1,3,2,2,1,2]),Int32Array.from([2,2,1,2,1,3]),Int32Array.from([2,2,1,3,1,2]),Int32Array.from([2,3,1,2,1,2]),Int32Array.from([1,1,2,2,3,2]),Int32Array.from([1,2,2,1,3,2]),Int32Array.from([1,2,2,2,3,1]),Int32Array.from([1,1,3,2,2,2]),Int32Array.from([1,2,3,1,2,2]),Int32Array.from([1,2,3,2,2,1]),Int32Array.from([2,2,3,2,1,1]),Int32Array.from([2,2,1,1,3,2]),Int32Array.from([2,2,1,2,3,1]),Int32Array.from([2,1,3,2,1,2]),Int32Array.from([2,2,3,1,1,2]),Int32Array.from([3,1,2,1,3,1]),Int32Array.from([3,1,1,2,2,2]),Int32Array.from([3,2,1,1,2,2]),Int32Array.from([3,2,1,2,2,1]),Int32Array.from([3,1,2,2,1,2]),Int32Array.from([3,2,2,1,1,2]),Int32Array.from([3,2,2,2,1,1]),Int32Array.from([2,1,2,1,2,3]),Int32Array.from([2,1,2,3,2,1]),Int32Array.from([2,3,2,1,2,1]),Int32Array.from([1,1,1,3,2,3]),Int32Array.from([1,3,1,1,2,3]),Int32Array.from([1,3,1,3,2,1]),Int32Array.from([1,1,2,3,1,3]),Int32Array.from([1,3,2,1,1,3]),Int32Array.from([1,3,2,3,1,1]),Int32Array.from([2,1,1,3,1,3]),Int32Array.from([2,3,1,1,1,3]),Int32Array.from([2,3,1,3,1,1]),Int32Array.from([1,1,2,1,3,3]),Int32Array.from([1,1,2,3,3,1]),Int32Array.from([1,3,2,1,3,1]),Int32Array.from([1,1,3,1,2,3]),Int32Array.from([1,1,3,3,2,1]),Int32Array.from([1,3,3,1,2,1]),Int32Array.from([3,1,3,1,2,1]),Int32Array.from([2,1,1,3,3,1]),Int32Array.from([2,3,1,1,3,1]),Int32Array.from([2,1,3,1,1,3]),Int32Array.from([2,1,3,3,1,1]),Int32Array.from([2,1,3,1,3,1]),Int32Array.from([3,1,1,1,2,3]),Int32Array.from([3,1,1,3,2,1]),Int32Array.from([3,3,1,1,2,1]),Int32Array.from([3,1,2,1,1,3]),Int32Array.from([3,1,2,3,1,1]),Int32Array.from([3,3,2,1,1,1]),Int32Array.from([3,1,4,1,1,1]),Int32Array.from([2,2,1,4,1,1]),Int32Array.from([4,3,1,1,1,1]),Int32Array.from([1,1,1,2,2,4]),Int32Array.from([1,1,1,4,2,2]),Int32Array.from([1,2,1,1,2,4]),Int32Array.from([1,2,1,4,2,1]),Int32Array.from([1,4,1,1,2,2]),Int32Array.from([1,4,1,2,2,1]),Int32Array.from([1,1,2,2,1,4]),Int32Array.from([1,1,2,4,1,2]),Int32Array.from([1,2,2,1,1,4]),Int32Array.from([1,2,2,4,1,1]),Int32Array.from([1,4,2,1,1,2]),Int32Array.from([1,4,2,2,1,1]),Int32Array.from([2,4,1,2,1,1]),Int32Array.from([2,2,1,1,1,4]),Int32Array.from([4,1,3,1,1,1]),Int32Array.from([2,4,1,1,1,2]),Int32Array.from([1,3,4,1,1,1]),Int32Array.from([1,1,1,2,4,2]),Int32Array.from([1,2,1,1,4,2]),Int32Array.from([1,2,1,2,4,1]),Int32Array.from([1,1,4,2,1,2]),Int32Array.from([1,2,4,1,1,2]),Int32Array.from([1,2,4,2,1,1]),Int32Array.from([4,1,1,2,1,2]),Int32Array.from([4,2,1,1,1,2]),Int32Array.from([4,2,1,2,1,1]),Int32Array.from([2,1,2,1,4,1]),Int32Array.from([2,1,4,1,2,1]),Int32Array.from([4,1,2,1,2,1]),Int32Array.from([1,1,1,1,4,3]),Int32Array.from([1,1,1,3,4,1]),Int32Array.from([1,3,1,1,4,1]),Int32Array.from([1,1,4,1,1,3]),Int32Array.from([1,1,4,3,1,1]),Int32Array.from([4,1,1,1,1,3]),Int32Array.from([4,1,1,3,1,1]),Int32Array.from([1,1,3,1,4,1]),Int32Array.from([1,1,4,1,3,1]),Int32Array.from([3,1,1,1,4,1]),Int32Array.from([4,1,1,1,3,1]),Int32Array.from([2,1,1,4,1,2]),Int32Array.from([2,1,1,2,1,4]),Int32Array.from([2,1,1,2,3,2]),Int32Array.from([2,3,3,1,1,1,2])],J.MAX_AVG_VARIANCE=.25,J.MAX_INDIVIDUAL_VARIANCE=.7,J.CODE_SHIFT=98,J.CODE_CODE_C=99,J.CODE_CODE_B=100,J.CODE_CODE_A=101,J.CODE_FNC_1=102,J.CODE_FNC_2=97,J.CODE_FNC_3=96,J.CODE_FNC_4_A=101,J.CODE_FNC_4_B=100,J.CODE_START_A=103,J.CODE_START_B=104,J.CODE_START_C=105,J.CODE_STOP=106;class ft extends ut{constructor(n=!1,r=!1){super(),this.usingCheckDigit=n,this.extendedMode=r,this.decodeRowResult="",this.counters=new Int32Array(9)}decodeRow(n,r,s){let o=this.counters;o.fill(0),this.decodeRowResult="";let a=ft.findAsteriskPattern(r,o),u=r.getNextSet(a[1]),d=r.getSize(),h,g;do{ft.recordPattern(r,u,o);let D=ft.toNarrowWidePattern(o);if(D<0)throw new j;h=ft.patternToChar(D),this.decodeRowResult+=h,g=u;for(let L of o)u+=L;u=r.getNextSet(u)}while(h!=="*");this.decodeRowResult=this.decodeRowResult.substring(0,this.decodeRowResult.length-1);let x=0;for(let D of o)x+=D;let E=u-g-x;if(u!==d&&E*2<x)throw new j;if(this.usingCheckDigit){let D=this.decodeRowResult.length-1,L=0;for(let z=0;z<D;z++)L+=ft.ALPHABET_STRING.indexOf(this.decodeRowResult.charAt(z));if(this.decodeRowResult.charAt(D)!==ft.ALPHABET_STRING.charAt(L%43))throw new M;this.decodeRowResult=this.decodeRowResult.substring(0,D)}if(this.decodeRowResult.length===0)throw new j;let A;this.extendedMode?A=ft.decodeExtended(this.decodeRowResult):A=this.decodeRowResult;let I=(a[1]+a[0])/2,b=g+x/2;return new Ke(A,null,0,[new oe(I,n),new oe(b,n)],ae.CODE_39,new Date().getTime())}static findAsteriskPattern(n,r){let s=n.getSize(),o=n.getNextSet(0),a=0,u=o,d=!1,h=r.length;for(let g=o;g<s;g++)if(n.get(g)!==d)r[a]++;else{if(a===h-1){if(this.toNarrowWidePattern(r)===ft.ASTERISK_ENCODING&&n.isRange(Math.max(0,u-Math.floor((g-u)/2)),u,!1))return[u,g];u+=r[0]+r[1],r.copyWithin(0,2,2+a-1),r[a-1]=0,r[a]=0,a--}else a++;r[a]=1,d=!d}throw new j}static toNarrowWidePattern(n){let r=n.length,s=0,o;do{let a=2147483647;for(let h of n)h<a&&h>s&&(a=h);s=a,o=0;let u=0,d=0;for(let h=0;h<r;h++){let g=n[h];g>s&&(d|=1<<r-1-h,o++,u+=g)}if(o===3){for(let h=0;h<r&&o>0;h++){let g=n[h];if(g>s&&(o--,g*2>=u))return-1}return d}}while(o>3);return-1}static patternToChar(n){for(let r=0;r<ft.CHARACTER_ENCODINGS.length;r++)if(ft.CHARACTER_ENCODINGS[r]===n)return ft.ALPHABET_STRING.charAt(r);if(n===ft.ASTERISK_ENCODING)return"*";throw new j}static decodeExtended(n){let r=n.length,s="";for(let o=0;o<r;o++){let a=n.charAt(o);if(a==="+"||a==="$"||a==="%"||a==="/"){let u=n.charAt(o+1),d="\0";switch(a){case"+":if(u>="A"&&u<="Z")d=String.fromCharCode(u.charCodeAt(0)+32);else throw new k;break;case"$":if(u>="A"&&u<="Z")d=String.fromCharCode(u.charCodeAt(0)-64);else throw new k;break;case"%":if(u>="A"&&u<="E")d=String.fromCharCode(u.charCodeAt(0)-38);else if(u>="F"&&u<="J")d=String.fromCharCode(u.charCodeAt(0)-11);else if(u>="K"&&u<="O")d=String.fromCharCode(u.charCodeAt(0)+16);else if(u>="P"&&u<="T")d=String.fromCharCode(u.charCodeAt(0)+43);else if(u==="U")d="\0";else if(u==="V")d="@";else if(u==="W")d="`";else if(u==="X"||u==="Y"||u==="Z")d="";else throw new k;break;case"/":if(u>="A"&&u<="O")d=String.fromCharCode(u.charCodeAt(0)-32);else if(u==="Z")d=":";else throw new k;break}s+=d,o++}else s+=a}return s}}ft.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",ft.CHARACTER_ENCODINGS=[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,168,162,138,42],ft.ASTERISK_ENCODING=148;class Be extends ut{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(n,r,s){let o=this.decodeStart(r),a=this.decodeEnd(r),u=new ge;Be.decodeMiddle(r,o[1],a[0],u);let d=u.toString(),h=null;s!=null&&(h=s.get(U.ALLOWED_LENGTHS)),h==null&&(h=Be.DEFAULT_ALLOWED_LENGTHS);let g=d.length,x=!1,E=0;for(let b of h){if(g===b){x=!0;break}b>E&&(E=b)}if(!x&&g>E&&(x=!0),!x)throw new k;const A=[new oe(o[1],n),new oe(a[0],n)];return new Ke(d,null,0,A,ae.ITF,new Date().getTime())}static decodeMiddle(n,r,s,o){let a=new Int32Array(10),u=new Int32Array(5),d=new Int32Array(5);for(a.fill(0),u.fill(0),d.fill(0);r<s;){ut.recordPattern(n,r,a);for(let g=0;g<5;g++){let x=2*g;u[g]=a[x],d[g]=a[x+1]}let h=Be.decodeDigit(u);o.append(h.toString()),h=this.decodeDigit(d),o.append(h.toString()),a.forEach(function(g){r+=g})}}decodeStart(n){let r=Be.skipWhiteSpace(n),s=Be.findGuardPattern(n,r,Be.START_PATTERN);return this.narrowLineWidth=(s[1]-s[0])/4,this.validateQuietZone(n,s[0]),s}validateQuietZone(n,r){let s=this.narrowLineWidth*10;s=s<r?s:r;for(let o=r-1;s>0&&o>=0&&!n.get(o);o--)s--;if(s!==0)throw new j}static skipWhiteSpace(n){const r=n.getSize(),s=n.getNextSet(0);if(s===r)throw new j;return s}decodeEnd(n){n.reverse();try{let r=Be.skipWhiteSpace(n),s;try{s=Be.findGuardPattern(n,r,Be.END_PATTERN_REVERSED[0])}catch(a){a instanceof j&&(s=Be.findGuardPattern(n,r,Be.END_PATTERN_REVERSED[1]))}this.validateQuietZone(n,s[0]);let o=s[0];return s[0]=n.getSize()-s[1],s[1]=n.getSize()-o,s}finally{n.reverse()}}static findGuardPattern(n,r,s){let o=s.length,a=new Int32Array(o),u=n.getSize(),d=!1,h=0,g=r;a.fill(0);for(let x=r;x<u;x++)if(n.get(x)!==d)a[h]++;else{if(h===o-1){if(ut.patternMatchVariance(a,s,Be.MAX_INDIVIDUAL_VARIANCE)<Be.MAX_AVG_VARIANCE)return[g,x];g+=a[0]+a[1],B.arraycopy(a,2,a,0,h-1),a[h-1]=0,a[h]=0,h--}else h++;a[h]=1,d=!d}throw new j}static decodeDigit(n){let r=Be.MAX_AVG_VARIANCE,s=-1,o=Be.PATTERNS.length;for(let a=0;a<o;a++){let u=Be.PATTERNS[a],d=ut.patternMatchVariance(n,u,Be.MAX_INDIVIDUAL_VARIANCE);d<r?(r=d,s=a):d===r&&(s=-1)}if(s>=0)return s%10;throw new j}}Be.PATTERNS=[Int32Array.from([1,1,2,2,1]),Int32Array.from([2,1,1,1,2]),Int32Array.from([1,2,1,1,2]),Int32Array.from([2,2,1,1,1]),Int32Array.from([1,1,2,1,2]),Int32Array.from([2,1,2,1,1]),Int32Array.from([1,2,2,1,1]),Int32Array.from([1,1,1,2,2]),Int32Array.from([2,1,1,2,1]),Int32Array.from([1,2,1,2,1]),Int32Array.from([1,1,3,3,1]),Int32Array.from([3,1,1,1,3]),Int32Array.from([1,3,1,1,3]),Int32Array.from([3,3,1,1,1]),Int32Array.from([1,1,3,1,3]),Int32Array.from([3,1,3,1,1]),Int32Array.from([1,3,3,1,1]),Int32Array.from([1,1,1,3,3]),Int32Array.from([3,1,1,3,1]),Int32Array.from([1,3,1,3,1])],Be.MAX_AVG_VARIANCE=.38,Be.MAX_INDIVIDUAL_VARIANCE=.5,Be.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],Be.START_PATTERN=Int32Array.from([1,1,1,1]),Be.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class nt extends ut{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(n){let r=!1,s,o=0,a=Int32Array.from([0,0,0]);for(;!r;){a=Int32Array.from([0,0,0]),s=nt.findGuardPattern(n,o,!1,this.START_END_PATTERN,a);let u=s[0];o=s[1];let d=u-(o-u);d>=0&&(r=n.isRange(d,u,!1))}return s}static checkChecksum(n){return nt.checkStandardUPCEANChecksum(n)}static checkStandardUPCEANChecksum(n){let r=n.length;if(r===0)return!1;let s=parseInt(n.charAt(r-1),10);return nt.getStandardUPCEANChecksum(n.substring(0,r-1))===s}static getStandardUPCEANChecksum(n){let r=n.length,s=0;for(let o=r-1;o>=0;o-=2){let a=n.charAt(o).charCodeAt(0)-48;if(a<0||a>9)throw new k;s+=a}s*=3;for(let o=r-2;o>=0;o-=2){let a=n.charAt(o).charCodeAt(0)-48;if(a<0||a>9)throw new k;s+=a}return(1e3-s)%10}static decodeEnd(n,r){return nt.findGuardPattern(n,r,!1,nt.START_END_PATTERN,new Int32Array(nt.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(n,r,s,o){return this.findGuardPattern(n,r,s,o,new Int32Array(o.length))}static findGuardPattern(n,r,s,o,a){let u=n.getSize();r=s?n.getNextUnset(r):n.getNextSet(r);let d=0,h=r,g=o.length,x=s;for(let E=r;E<u;E++)if(n.get(E)!==x)a[d]++;else{if(d===g-1){if(ut.patternMatchVariance(a,o,nt.MAX_INDIVIDUAL_VARIANCE)<nt.MAX_AVG_VARIANCE)return Int32Array.from([h,E]);h+=a[0]+a[1];let A=a.slice(2,a.length-1);for(let I=0;I<d-1;I++)a[I]=A[I];a[d-1]=0,a[d]=0,d--}else d++;a[d]=1,x=!x}throw new j}static decodeDigit(n,r,s,o){this.recordPattern(n,s,r);let a=this.MAX_AVG_VARIANCE,u=-1,d=o.length;for(let h=0;h<d;h++){let g=o[h],x=ut.patternMatchVariance(r,g,nt.MAX_INDIVIDUAL_VARIANCE);x<a&&(a=x,u=h)}if(u>=0)return u;throw new j}}nt.MAX_AVG_VARIANCE=.48,nt.MAX_INDIVIDUAL_VARIANCE=.7,nt.START_END_PATTERN=Int32Array.from([1,1,1]),nt.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),nt.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),nt.L_PATTERNS=[Int32Array.from([3,2,1,1]),Int32Array.from([2,2,2,1]),Int32Array.from([2,1,2,2]),Int32Array.from([1,4,1,1]),Int32Array.from([1,1,3,2]),Int32Array.from([1,2,3,1]),Int32Array.from([1,1,1,4]),Int32Array.from([1,3,1,2]),Int32Array.from([1,2,1,3]),Int32Array.from([3,1,1,2])];class Ji{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(n,r,s){let o=this.decodeRowStringBuffer,a=this.decodeMiddle(r,s,o),u=o.toString(),d=Ji.parseExtensionString(u),h=[new oe((s[0]+s[1])/2,n),new oe(a,n)],g=new Ke(u,null,0,h,ae.UPC_EAN_EXTENSION,new Date().getTime());return d!=null&&g.putAllMetadata(d),g}decodeMiddle(n,r,s){let o=this.decodeMiddleCounters;o[0]=0,o[1]=0,o[2]=0,o[3]=0;let a=n.getSize(),u=r[1],d=0;for(let g=0;g<5&&u<a;g++){let x=nt.decodeDigit(n,o,u,nt.L_AND_G_PATTERNS);s+=String.fromCharCode(48+x%10);for(let E of o)u+=E;x>=10&&(d|=1<<4-g),g!==4&&(u=n.getNextSet(u),u=n.getNextUnset(u))}if(s.length!==5)throw new j;let h=this.determineCheckDigit(d);if(Ji.extensionChecksum(s.toString())!==h)throw new j;return u}static extensionChecksum(n){let r=n.length,s=0;for(let o=r-2;o>=0;o-=2)s+=n.charAt(o).charCodeAt(0)-48;s*=3;for(let o=r-1;o>=0;o-=2)s+=n.charAt(o).charCodeAt(0)-48;return s*=3,s%10}determineCheckDigit(n){for(let r=0;r<10;r++)if(n===this.CHECK_DIGIT_ENCODINGS[r])return r;throw new j}static parseExtensionString(n){if(n.length!==5)return null;let r=Ji.parseExtension5String(n);return r==null?null:new Map([[mt.SUGGESTED_PRICE,r]])}static parseExtension5String(n){let r;switch(n.charAt(0)){case"0":r="£";break;case"5":r="$";break;case"9":switch(n){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}r="";break;default:r="";break}let s=parseInt(n.substring(1)),o=(s/100).toString(),a=s%100,u=a<10?"0"+a:a.toString();return r+o+"."+u}}class ja{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(n,r,s){let o=this.decodeRowStringBuffer,a=this.decodeMiddle(r,s,o),u=o.toString(),d=ja.parseExtensionString(u),h=[new oe((s[0]+s[1])/2,n),new oe(a,n)],g=new Ke(u,null,0,h,ae.UPC_EAN_EXTENSION,new Date().getTime());return d!=null&&g.putAllMetadata(d),g}decodeMiddle(n,r,s){let o=this.decodeMiddleCounters;o[0]=0,o[1]=0,o[2]=0,o[3]=0;let a=n.getSize(),u=r[1],d=0;for(let h=0;h<2&&u<a;h++){let g=nt.decodeDigit(n,o,u,nt.L_AND_G_PATTERNS);s+=String.fromCharCode(48+g%10);for(let x of o)u+=x;g>=10&&(d|=1<<1-h),h!==1&&(u=n.getNextSet(u),u=n.getNextUnset(u))}if(s.length!==2)throw new j;if(parseInt(s.toString())%4!==d)throw new j;return u}static parseExtensionString(n){return n.length!==2?null:new Map([[mt.ISSUE_NUMBER,parseInt(n)]])}}class $c{static decodeRow(n,r,s){let o=nt.findGuardPattern(r,s,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new Ji().decodeRow(n,r,o)}catch{return new ja().decodeRow(n,r,o)}}}$c.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class Oe extends nt{constructor(){super(),this.decodeRowStringBuffer="",Oe.L_AND_G_PATTERNS=Oe.L_PATTERNS.map(n=>Int32Array.from(n));for(let n=10;n<20;n++){let r=Oe.L_PATTERNS[n-10],s=new Int32Array(r.length);for(let o=0;o<r.length;o++)s[o]=r[r.length-o-1];Oe.L_AND_G_PATTERNS[n]=s}}decodeRow(n,r,s){let o=Oe.findStartGuardPattern(r),a=s==null?null:s.get(U.NEED_RESULT_POINT_CALLBACK);if(a!=null){const Z=new oe((o[0]+o[1])/2,n);a.foundPossibleResultPoint(Z)}let u=this.decodeMiddle(r,o,this.decodeRowStringBuffer),d=u.rowOffset,h=u.resultString;if(a!=null){const Z=new oe(d,n);a.foundPossibleResultPoint(Z)}let g=this.decodeEnd(r,d);if(a!=null){const Z=new oe((g[0]+g[1])/2,n);a.foundPossibleResultPoint(Z)}let x=g[1],E=x+(x-g[0]);if(E>=r.getSize()||!r.isRange(x,E,!1))throw new j;let A=h.toString();if(A.length<8)throw new k;if(!Oe.checkChecksum(A))throw new M;let I=(o[1]+o[0])/2,b=(g[1]+g[0])/2,D=this.getBarcodeFormat(),L=[new oe(I,n),new oe(b,n)],z=new Ke(A,null,0,L,D,new Date().getTime()),q=0;try{let Z=$c.decodeRow(n,r,g[1]);z.putMetadata(mt.UPC_EAN_EXTENSION,Z.getText()),z.putAllMetadata(Z.getResultMetadata()),z.addResultPoints(Z.getResultPoints()),q=Z.getText().length}catch{}let $=s==null?null:s.get(U.ALLOWED_EAN_EXTENSIONS);if($!=null){let Z=!1;for(let ve in $)if(q.toString()===ve){Z=!0;break}if(!Z)throw new j}return z}decodeEnd(n,r){return Oe.findGuardPattern(n,r,!1,Oe.START_END_PATTERN,new Int32Array(Oe.START_END_PATTERN.length).fill(0))}static checkChecksum(n){return Oe.checkStandardUPCEANChecksum(n)}static checkStandardUPCEANChecksum(n){let r=n.length;if(r===0)return!1;let s=parseInt(n.charAt(r-1),10);return Oe.getStandardUPCEANChecksum(n.substring(0,r-1))===s}static getStandardUPCEANChecksum(n){let r=n.length,s=0;for(let o=r-1;o>=0;o-=2){let a=n.charAt(o).charCodeAt(0)-48;if(a<0||a>9)throw new k;s+=a}s*=3;for(let o=r-2;o>=0;o-=2){let a=n.charAt(o).charCodeAt(0)-48;if(a<0||a>9)throw new k;s+=a}return(1e3-s)%10}}class Pr extends Oe{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(n,r,s){let o=this.decodeMiddleCounters;o[0]=0,o[1]=0,o[2]=0,o[3]=0;let a=n.getSize(),u=r[1],d=0;for(let g=0;g<6&&u<a;g++){let x=Oe.decodeDigit(n,o,u,Oe.L_AND_G_PATTERNS);s+=String.fromCharCode(48+x%10);for(let E of o)u+=E;x>=10&&(d|=1<<5-g)}s=Pr.determineFirstDigit(s,d),u=Oe.findGuardPattern(n,u,!0,Oe.MIDDLE_PATTERN,new Int32Array(Oe.MIDDLE_PATTERN.length).fill(0))[1];for(let g=0;g<6&&u<a;g++){let x=Oe.decodeDigit(n,o,u,Oe.L_PATTERNS);s+=String.fromCharCode(48+x);for(let E of o)u+=E}return{rowOffset:u,resultString:s}}getBarcodeFormat(){return ae.EAN_13}static determineFirstDigit(n,r){for(let s=0;s<10;s++)if(r===this.FIRST_DIGIT_ENCODINGS[s])return n=String.fromCharCode(48+s)+n,n;throw new j}}Pr.FIRST_DIGIT_ENCODINGS=[0,11,13,14,19,25,28,21,22,26];class Jc extends Oe{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(n,r,s){const o=this.decodeMiddleCounters;o[0]=0,o[1]=0,o[2]=0,o[3]=0;let a=n.getSize(),u=r[1];for(let h=0;h<4&&u<a;h++){let g=Oe.decodeDigit(n,o,u,Oe.L_PATTERNS);s+=String.fromCharCode(48+g);for(let x of o)u+=x}u=Oe.findGuardPattern(n,u,!0,Oe.MIDDLE_PATTERN,new Int32Array(Oe.MIDDLE_PATTERN.length).fill(0))[1];for(let h=0;h<4&&u<a;h++){let g=Oe.decodeDigit(n,o,u,Oe.L_PATTERNS);s+=String.fromCharCode(48+g);for(let x of o)u+=x}return{rowOffset:u,resultString:s}}getBarcodeFormat(){return ae.EAN_8}}class e1 extends Oe{constructor(){super(...arguments),this.ean13Reader=new Pr}getBarcodeFormat(){return ae.UPC_A}decode(n,r){return this.maybeReturnResult(this.ean13Reader.decode(n))}decodeRow(n,r,s){return this.maybeReturnResult(this.ean13Reader.decodeRow(n,r,s))}decodeMiddle(n,r,s){return this.ean13Reader.decodeMiddle(n,r,s)}maybeReturnResult(n){let r=n.getText();if(r.charAt(0)==="0"){let s=new Ke(r.substring(1),null,null,n.getResultPoints(),ae.UPC_A);return n.getResultMetadata()!=null&&s.putAllMetadata(n.getResultMetadata()),s}else throw new j}reset(){this.ean13Reader.reset()}}class An extends Oe{constructor(){super(),this.decodeMiddleCounters=new Int32Array(4)}decodeMiddle(n,r,s){const o=this.decodeMiddleCounters.map(g=>g);o[0]=0,o[1]=0,o[2]=0,o[3]=0;const a=n.getSize();let u=r[1],d=0;for(let g=0;g<6&&u<a;g++){const x=An.decodeDigit(n,o,u,An.L_AND_G_PATTERNS);s+=String.fromCharCode(48+x%10);for(let E of o)u+=E;x>=10&&(d|=1<<5-g)}let h=An.determineNumSysAndCheckDigit(s,d);return{rowOffset:u,resultString:h}}decodeEnd(n,r){return An.findGuardPatternWithoutCounters(n,r,!0,An.MIDDLE_END_PATTERN)}checkChecksum(n){return Oe.checkChecksum(An.convertUPCEtoUPCA(n))}static determineNumSysAndCheckDigit(n,r){for(let s=0;s<=1;s++)for(let o=0;o<10;o++)if(r===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[s][o]){let a=String.fromCharCode(48+s),u=String.fromCharCode(48+o);return a+n+u}throw j.getNotFoundInstance()}getBarcodeFormat(){return ae.UPC_E}static convertUPCEtoUPCA(n){const r=n.slice(1,7).split("").map(a=>a.charCodeAt(0)),s=new ge;s.append(n.charAt(0));let o=r[5];switch(o){case 0:case 1:case 2:s.appendChars(r,0,2),s.append(o),s.append("0000"),s.appendChars(r,2,3);break;case 3:s.appendChars(r,0,3),s.append("00000"),s.appendChars(r,3,2);break;case 4:s.appendChars(r,0,4),s.append("00000"),s.append(r[4]);break;default:s.appendChars(r,0,5),s.append("0000"),s.append(o);break}return n.length>=8&&s.append(n.charAt(7)),s.toString()}}An.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),An.NUMSYS_AND_CHECK_DIGIT_PATTERNS=[Int32Array.from([56,52,50,49,44,38,35,42,41,37]),Int32Array.from([7,11,13,14,19,25,28,21,22,26])];class Ga extends ut{constructor(n){super();let r=n==null?null:n.get(U.POSSIBLE_FORMATS),s=[];l(r)?(s.push(new Pr),s.push(new e1),s.push(new Jc),s.push(new An)):(r.indexOf(ae.EAN_13)>-1&&s.push(new Pr),r.indexOf(ae.UPC_A)>-1&&s.push(new e1),r.indexOf(ae.EAN_8)>-1&&s.push(new Jc),r.indexOf(ae.UPC_E)>-1&&s.push(new An)),this.readers=s}decodeRow(n,r,s){for(let o of this.readers)try{const a=o.decodeRow(n,r,s),u=a.getBarcodeFormat()===ae.EAN_13&&a.getText().charAt(0)==="0",d=s==null?null:s.get(U.POSSIBLE_FORMATS),h=d==null||d.includes(ae.UPC_A);if(u&&h){const g=a.getRawBytes(),x=new Ke(a.getText().substring(1),g,g?g.length:null,a.getResultPoints(),ae.UPC_A);return x.putAllMetadata(a.getResultMetadata()),x}return a}catch{}throw new j}reset(){for(let n of this.readers)n.reset()}}class bt extends ut{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(n,r){for(let s=0;s<r.length;s++)if(ut.patternMatchVariance(n,r[s],bt.MAX_INDIVIDUAL_VARIANCE)<bt.MAX_AVG_VARIANCE)return s;throw new j}static count(n){return Te.sum(new Int32Array(n))}static increment(n,r){let s=0,o=r[0];for(let a=1;a<n.length;a++)r[a]>o&&(o=r[a],s=a);n[s]++}static decrement(n,r){let s=0,o=r[0];for(let a=1;a<n.length;a++)r[a]<o&&(o=r[a],s=a);n[s]--}static isFinderPattern(n){let r=n[0]+n[1],s=r+n[2]+n[3],o=r/s;if(o>=bt.MIN_FINDER_PATTERN_RATIO&&o<=bt.MAX_FINDER_PATTERN_RATIO){let a=Number.MAX_SAFE_INTEGER,u=Number.MIN_SAFE_INTEGER;for(let d of n)d>u&&(u=d),d<a&&(a=d);return u<10*a}return!1}}bt.MAX_AVG_VARIANCE=.2,bt.MAX_INDIVIDUAL_VARIANCE=.45,bt.MIN_FINDER_PATTERN_RATIO=9.5/12,bt.MAX_FINDER_PATTERN_RATIO=12.5/14;class ii{constructor(n,r){this.value=n,this.checksumPortion=r}getValue(){return this.value}getChecksumPortion(){return this.checksumPortion}toString(){return this.value+"("+this.checksumPortion+")"}equals(n){if(!(n instanceof ii))return!1;const r=n;return this.value===r.value&&this.checksumPortion===r.checksumPortion}hashCode(){return this.value^this.checksumPortion}}class lo{constructor(n,r,s,o,a){this.value=n,this.startEnd=r,this.value=n,this.startEnd=r,this.resultPoints=new Array,this.resultPoints.push(new oe(s,a)),this.resultPoints.push(new oe(o,a))}getValue(){return this.value}getStartEnd(){return this.startEnd}getResultPoints(){return this.resultPoints}equals(n){if(!(n instanceof lo))return!1;const r=n;return this.value===r.value}hashCode(){return this.value}}class Mn{constructor(){}static getRSSvalue(n,r,s){let o=0;for(let h of n)o+=h;let a=0,u=0,d=n.length;for(let h=0;h<d-1;h++){let g;for(g=1,u|=1<<h;g<n[h];g++,u&=~(1<<h)){let x=Mn.combins(o-g-1,d-h-2);if(s&&u===0&&o-g-(d-h-1)>=d-h-1&&(x-=Mn.combins(o-g-(d-h),d-h-2)),d-h-1>1){let E=0;for(let A=o-g-(d-h-2);A>r;A--)E+=Mn.combins(o-g-A-1,d-h-3);x-=E*(d-1-h)}else o-g>r&&x--;a+=x}o-=g}return a}static combins(n,r){let s,o;n-r>r?(o=r,s=n-r):(o=n-r,s=r);let a=1,u=1;for(let d=n;d>s;d--)a*=d,u<=o&&(a/=u,u++);for(;u<=o;)a/=u,u++;return a}}class bh{static buildBitArray(n){let r=n.length*2-1;n[n.length-1].getRightChar()==null&&(r-=1);let s=12*r,o=new G(s),a=0,d=n[0].getRightChar().getValue();for(let h=11;h>=0;--h)d&1<<h&&o.set(a),a++;for(let h=1;h<n.length;++h){let g=n[h],x=g.getLeftChar().getValue();for(let E=11;E>=0;--E)x&1<<E&&o.set(a),a++;if(g.getRightChar()!=null){let E=g.getRightChar().getValue();for(let A=11;A>=0;--A)E&1<<A&&o.set(a),a++}}return o}}class Br{constructor(n,r){r?this.decodedInformation=null:(this.finished=n,this.decodedInformation=r)}getDecodedInformation(){return this.decodedInformation}isFinished(){return this.finished}}class Xa{constructor(n){this.newPosition=n}getNewPosition(){return this.newPosition}}class jt extends Xa{constructor(n,r){super(n),this.value=r}getValue(){return this.value}isFNC1(){return this.value===jt.FNC1}}jt.FNC1="$";class Lr extends Xa{constructor(n,r,s){super(n),s?(this.remaining=!0,this.remainingValue=this.remainingValue):(this.remaining=!1,this.remainingValue=0),this.newString=r}getNewString(){return this.newString}isRemaining(){return this.remaining}getRemainingValue(){return this.remainingValue}}class fn extends Xa{constructor(n,r,s){if(super(n),r<0||r>10||s<0||s>10)throw new k;this.firstDigit=r,this.secondDigit=s}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===fn.FNC1}isSecondDigitFNC1(){return this.secondDigit===fn.FNC1}isAnyFNC1(){return this.firstDigit===fn.FNC1||this.secondDigit===fn.FNC1}}fn.FNC1=10;class ne{constructor(){}static parseFieldsInGeneralPurpose(n){if(!n)return null;if(n.length<2)throw new j;let r=n.substring(0,2);for(let a of ne.TWO_DIGIT_DATA_LENGTH)if(a[0]===r)return a[1]===ne.VARIABLE_LENGTH?ne.processVariableAI(2,a[2],n):ne.processFixedAI(2,a[1],n);if(n.length<3)throw new j;let s=n.substring(0,3);for(let a of ne.THREE_DIGIT_DATA_LENGTH)if(a[0]===s)return a[1]===ne.VARIABLE_LENGTH?ne.processVariableAI(3,a[2],n):ne.processFixedAI(3,a[1],n);for(let a of ne.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(a[0]===s)return a[1]===ne.VARIABLE_LENGTH?ne.processVariableAI(4,a[2],n):ne.processFixedAI(4,a[1],n);if(n.length<4)throw new j;let o=n.substring(0,4);for(let a of ne.FOUR_DIGIT_DATA_LENGTH)if(a[0]===o)return a[1]===ne.VARIABLE_LENGTH?ne.processVariableAI(4,a[2],n):ne.processFixedAI(4,a[1],n);throw new j}static processFixedAI(n,r,s){if(s.length<n)throw new j;let o=s.substring(0,n);if(s.length<n+r)throw new j;let a=s.substring(n,n+r),u=s.substring(n+r),d="("+o+")"+a,h=ne.parseFieldsInGeneralPurpose(u);return h==null?d:d+h}static processVariableAI(n,r,s){let o=s.substring(0,n),a;s.length<n+r?a=s.length:a=n+r;let u=s.substring(n,a),d=s.substring(a),h="("+o+")"+u,g=ne.parseFieldsInGeneralPurpose(d);return g==null?h:h+g}}ne.VARIABLE_LENGTH=[],ne.TWO_DIGIT_DATA_LENGTH=[["00",18],["01",14],["02",14],["10",ne.VARIABLE_LENGTH,20],["11",6],["12",6],["13",6],["15",6],["17",6],["20",2],["21",ne.VARIABLE_LENGTH,20],["22",ne.VARIABLE_LENGTH,29],["30",ne.VARIABLE_LENGTH,8],["37",ne.VARIABLE_LENGTH,8],["90",ne.VARIABLE_LENGTH,30],["91",ne.VARIABLE_LENGTH,30],["92",ne.VARIABLE_LENGTH,30],["93",ne.VARIABLE_LENGTH,30],["94",ne.VARIABLE_LENGTH,30],["95",ne.VARIABLE_LENGTH,30],["96",ne.VARIABLE_LENGTH,30],["97",ne.VARIABLE_LENGTH,3],["98",ne.VARIABLE_LENGTH,30],["99",ne.VARIABLE_LENGTH,30]],ne.THREE_DIGIT_DATA_LENGTH=[["240",ne.VARIABLE_LENGTH,30],["241",ne.VARIABLE_LENGTH,30],["242",ne.VARIABLE_LENGTH,6],["250",ne.VARIABLE_LENGTH,30],["251",ne.VARIABLE_LENGTH,30],["253",ne.VARIABLE_LENGTH,17],["254",ne.VARIABLE_LENGTH,20],["400",ne.VARIABLE_LENGTH,30],["401",ne.VARIABLE_LENGTH,30],["402",17],["403",ne.VARIABLE_LENGTH,30],["410",13],["411",13],["412",13],["413",13],["414",13],["420",ne.VARIABLE_LENGTH,20],["421",ne.VARIABLE_LENGTH,15],["422",3],["423",ne.VARIABLE_LENGTH,15],["424",3],["425",3],["426",3]],ne.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH=[["310",6],["311",6],["312",6],["313",6],["314",6],["315",6],["316",6],["320",6],["321",6],["322",6],["323",6],["324",6],["325",6],["326",6],["327",6],["328",6],["329",6],["330",6],["331",6],["332",6],["333",6],["334",6],["335",6],["336",6],["340",6],["341",6],["342",6],["343",6],["344",6],["345",6],["346",6],["347",6],["348",6],["349",6],["350",6],["351",6],["352",6],["353",6],["354",6],["355",6],["356",6],["357",6],["360",6],["361",6],["362",6],["363",6],["364",6],["365",6],["366",6],["367",6],["368",6],["369",6],["390",ne.VARIABLE_LENGTH,15],["391",ne.VARIABLE_LENGTH,18],["392",ne.VARIABLE_LENGTH,15],["393",ne.VARIABLE_LENGTH,18],["703",ne.VARIABLE_LENGTH,30]],ne.FOUR_DIGIT_DATA_LENGTH=[["7001",13],["7002",ne.VARIABLE_LENGTH,30],["7003",10],["8001",14],["8002",ne.VARIABLE_LENGTH,20],["8003",ne.VARIABLE_LENGTH,30],["8004",ne.VARIABLE_LENGTH,30],["8005",6],["8006",18],["8007",ne.VARIABLE_LENGTH,30],["8008",ne.VARIABLE_LENGTH,12],["8018",18],["8020",ne.VARIABLE_LENGTH,25],["8100",6],["8101",10],["8102",2],["8110",ne.VARIABLE_LENGTH,70],["8200",ne.VARIABLE_LENGTH,70]];class si{constructor(n){this.buffer=new ge,this.information=n}decodeAllCodes(n,r){let s=r,o=null;do{let a=this.decodeGeneralPurposeField(s,o),u=ne.parseFieldsInGeneralPurpose(a.getNewString());if(u!=null&&n.append(u),a.isRemaining()?o=""+a.getRemainingValue():o=null,s===a.getNewPosition())break;s=a.getNewPosition()}while(!0);return n.toString()}isStillNumeric(n){if(n+7>this.information.getSize())return n+4<=this.information.getSize();for(let r=n;r<n+3;++r)if(this.information.get(r))return!0;return this.information.get(n+3)}decodeNumeric(n){if(n+7>this.information.getSize()){let a=this.extractNumericValueFromBitArray(n,4);return a===0?new fn(this.information.getSize(),fn.FNC1,fn.FNC1):new fn(this.information.getSize(),a-1,fn.FNC1)}let r=this.extractNumericValueFromBitArray(n,7),s=(r-8)/11,o=(r-8)%11;return new fn(n+7,s,o)}extractNumericValueFromBitArray(n,r){return si.extractNumericValueFromBitArray(this.information,n,r)}static extractNumericValueFromBitArray(n,r,s){let o=0;for(let a=0;a<s;++a)n.get(r+a)&&(o|=1<<s-a-1);return o}decodeGeneralPurposeField(n,r){this.buffer.setLengthToZero(),r!=null&&this.buffer.append(r),this.current.setPosition(n);let s=this.parseBlocks();return s!=null&&s.isRemaining()?new Lr(this.current.getPosition(),this.buffer.toString(),s.getRemainingValue()):new Lr(this.current.getPosition(),this.buffer.toString())}parseBlocks(){let n,r;do{let s=this.current.getPosition();if(this.current.isAlpha()?(r=this.parseAlphaBlock(),n=r.isFinished()):this.current.isIsoIec646()?(r=this.parseIsoIec646Block(),n=r.isFinished()):(r=this.parseNumericBlock(),n=r.isFinished()),!(s!==this.current.getPosition())&&!n)break}while(!n);return r.getDecodedInformation()}parseNumericBlock(){for(;this.isStillNumeric(this.current.getPosition());){let n=this.decodeNumeric(this.current.getPosition());if(this.current.setPosition(n.getNewPosition()),n.isFirstDigitFNC1()){let r;return n.isSecondDigitFNC1()?r=new Lr(this.current.getPosition(),this.buffer.toString()):r=new Lr(this.current.getPosition(),this.buffer.toString(),n.getSecondDigit()),new Br(!0,r)}if(this.buffer.append(n.getFirstDigit()),n.isSecondDigitFNC1()){let r=new Lr(this.current.getPosition(),this.buffer.toString());return new Br(!0,r)}this.buffer.append(n.getSecondDigit())}return this.isNumericToAlphaNumericLatch(this.current.getPosition())&&(this.current.setAlpha(),this.current.incrementPosition(4)),new Br(!1)}parseIsoIec646Block(){for(;this.isStillIsoIec646(this.current.getPosition());){let n=this.decodeIsoIec646(this.current.getPosition());if(this.current.setPosition(n.getNewPosition()),n.isFNC1()){let r=new Lr(this.current.getPosition(),this.buffer.toString());return new Br(!0,r)}this.buffer.append(n.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setAlpha()),new Br(!1)}parseAlphaBlock(){for(;this.isStillAlpha(this.current.getPosition());){let n=this.decodeAlphanumeric(this.current.getPosition());if(this.current.setPosition(n.getNewPosition()),n.isFNC1()){let r=new Lr(this.current.getPosition(),this.buffer.toString());return new Br(!0,r)}this.buffer.append(n.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setIsoIec646()),new Br(!1)}isStillIsoIec646(n){if(n+5>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(n,5);if(r>=5&&r<16)return!0;if(n+7>this.information.getSize())return!1;let s=this.extractNumericValueFromBitArray(n,7);if(s>=64&&s<116)return!0;if(n+8>this.information.getSize())return!1;let o=this.extractNumericValueFromBitArray(n,8);return o>=232&&o<253}decodeIsoIec646(n){let r=this.extractNumericValueFromBitArray(n,5);if(r===15)return new jt(n+5,jt.FNC1);if(r>=5&&r<15)return new jt(n+5,"0"+(r-5));let s=this.extractNumericValueFromBitArray(n,7);if(s>=64&&s<90)return new jt(n+7,""+(s+1));if(s>=90&&s<116)return new jt(n+7,""+(s+7));let o=this.extractNumericValueFromBitArray(n,8),a;switch(o){case 232:a="!";break;case 233:a='"';break;case 234:a="%";break;case 235:a="&";break;case 236:a="'";break;case 237:a="(";break;case 238:a=")";break;case 239:a="*";break;case 240:a="+";break;case 241:a=",";break;case 242:a="-";break;case 243:a=".";break;case 244:a="/";break;case 245:a=":";break;case 246:a=";";break;case 247:a="<";break;case 248:a="=";break;case 249:a=">";break;case 250:a="?";break;case 251:a="_";break;case 252:a=" ";break;default:throw new k}return new jt(n+8,a)}isStillAlpha(n){if(n+5>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(n,5);if(r>=5&&r<16)return!0;if(n+6>this.information.getSize())return!1;let s=this.extractNumericValueFromBitArray(n,6);return s>=16&&s<63}decodeAlphanumeric(n){let r=this.extractNumericValueFromBitArray(n,5);if(r===15)return new jt(n+5,jt.FNC1);if(r>=5&&r<15)return new jt(n+5,"0"+(r-5));let s=this.extractNumericValueFromBitArray(n,6);if(s>=32&&s<58)return new jt(n+6,""+(s+33));let o;switch(s){case 58:o="*";break;case 59:o=",";break;case 60:o="-";break;case 61:o=".";break;case 62:o="/";break;default:throw new Dn("Decoding invalid alphanumeric value: "+s)}return new jt(n+6,o)}isAlphaTo646ToAlphaLatch(n){if(n+1>this.information.getSize())return!1;for(let r=0;r<5&&r+n<this.information.getSize();++r)if(r===2){if(!this.information.get(n+2))return!1}else if(this.information.get(n+r))return!1;return!0}isAlphaOr646ToNumericLatch(n){if(n+3>this.information.getSize())return!1;for(let r=n;r<n+3;++r)if(this.information.get(r))return!1;return!0}isNumericToAlphaNumericLatch(n){if(n+1>this.information.getSize())return!1;for(let r=0;r<4&&r+n<this.information.getSize();++r)if(this.information.get(n+r))return!1;return!0}}class Ya{constructor(n){this.information=n,this.generalDecoder=new si(n)}getInformation(){return this.information}getGeneralDecoder(){return this.generalDecoder}}class Gt extends Ya{constructor(n){super(n)}encodeCompressedGtin(n,r){n.append("(01)");let s=n.length();n.append("9"),this.encodeCompressedGtinWithoutAI(n,r,s)}encodeCompressedGtinWithoutAI(n,r,s){for(let o=0;o<4;++o){let a=this.getGeneralDecoder().extractNumericValueFromBitArray(r+10*o,10);a/100===0&&n.append("0"),a/10===0&&n.append("0"),n.append(a)}Gt.appendCheckDigit(n,s)}static appendCheckDigit(n,r){let s=0;for(let o=0;o<13;o++){let a=n.charAt(o+r).charCodeAt(0)-48;s+=o&1?a:3*a}s=10-s%10,s===10&&(s=0),n.append(s)}}Gt.GTIN_SIZE=40;class oi extends Gt{constructor(n){super(n)}parseInformation(){let n=new ge;n.append("(01)");let r=n.length(),s=this.getGeneralDecoder().extractNumericValueFromBitArray(oi.HEADER_SIZE,4);return n.append(s),this.encodeCompressedGtinWithoutAI(n,oi.HEADER_SIZE+4,r),this.getGeneralDecoder().decodeAllCodes(n,oi.HEADER_SIZE+44)}}oi.HEADER_SIZE=4;class uo extends Ya{constructor(n){super(n)}parseInformation(){let n=new ge;return this.getGeneralDecoder().decodeAllCodes(n,uo.HEADER_SIZE)}}uo.HEADER_SIZE=5;class co extends Gt{constructor(n){super(n)}encodeCompressedWeight(n,r,s){let o=this.getGeneralDecoder().extractNumericValueFromBitArray(r,s);this.addWeightCode(n,o);let a=this.checkWeight(o),u=1e5;for(let d=0;d<5;++d)a/u===0&&n.append("0"),u/=10;n.append(a)}}class kn extends co{constructor(n){super(n)}parseInformation(){if(this.getInformation().getSize()!=kn.HEADER_SIZE+co.GTIN_SIZE+kn.WEIGHT_SIZE)throw new j;let n=new ge;return this.encodeCompressedGtin(n,kn.HEADER_SIZE),this.encodeCompressedWeight(n,kn.HEADER_SIZE+co.GTIN_SIZE,kn.WEIGHT_SIZE),n.toString()}}kn.HEADER_SIZE=5,kn.WEIGHT_SIZE=15;class Oh extends kn{constructor(n){super(n)}addWeightCode(n,r){n.append("(3103)")}checkWeight(n){return n}}class Dh extends kn{constructor(n){super(n)}addWeightCode(n,r){r<1e4?n.append("(3202)"):n.append("(3203)")}checkWeight(n){return n<1e4?n:n-1e4}}class Pn extends Gt{constructor(n){super(n)}parseInformation(){if(this.getInformation().getSize()<Pn.HEADER_SIZE+Gt.GTIN_SIZE)throw new j;let n=new ge;this.encodeCompressedGtin(n,Pn.HEADER_SIZE);let r=this.getGeneralDecoder().extractNumericValueFromBitArray(Pn.HEADER_SIZE+Gt.GTIN_SIZE,Pn.LAST_DIGIT_SIZE);n.append("(392"),n.append(r),n.append(")");let s=this.getGeneralDecoder().decodeGeneralPurposeField(Pn.HEADER_SIZE+Gt.GTIN_SIZE+Pn.LAST_DIGIT_SIZE,null);return n.append(s.getNewString()),n.toString()}}Pn.HEADER_SIZE=8,Pn.LAST_DIGIT_SIZE=2;class Ft extends Gt{constructor(n){super(n)}parseInformation(){if(this.getInformation().getSize()<Ft.HEADER_SIZE+Gt.GTIN_SIZE)throw new j;let n=new ge;this.encodeCompressedGtin(n,Ft.HEADER_SIZE);let r=this.getGeneralDecoder().extractNumericValueFromBitArray(Ft.HEADER_SIZE+Gt.GTIN_SIZE,Ft.LAST_DIGIT_SIZE);n.append("(393"),n.append(r),n.append(")");let s=this.getGeneralDecoder().extractNumericValueFromBitArray(Ft.HEADER_SIZE+Gt.GTIN_SIZE+Ft.LAST_DIGIT_SIZE,Ft.FIRST_THREE_DIGITS_SIZE);s/100==0&&n.append("0"),s/10==0&&n.append("0"),n.append(s);let o=this.getGeneralDecoder().decodeGeneralPurposeField(Ft.HEADER_SIZE+Gt.GTIN_SIZE+Ft.LAST_DIGIT_SIZE+Ft.FIRST_THREE_DIGITS_SIZE,null);return n.append(o.getNewString()),n.toString()}}Ft.HEADER_SIZE=8,Ft.LAST_DIGIT_SIZE=2,Ft.FIRST_THREE_DIGITS_SIZE=10;class Xe extends co{constructor(n,r,s){super(n),this.dateCode=s,this.firstAIdigits=r}parseInformation(){if(this.getInformation().getSize()!=Xe.HEADER_SIZE+Xe.GTIN_SIZE+Xe.WEIGHT_SIZE+Xe.DATE_SIZE)throw new j;let n=new ge;return this.encodeCompressedGtin(n,Xe.HEADER_SIZE),this.encodeCompressedWeight(n,Xe.HEADER_SIZE+Xe.GTIN_SIZE,Xe.WEIGHT_SIZE),this.encodeCompressedDate(n,Xe.HEADER_SIZE+Xe.GTIN_SIZE+Xe.WEIGHT_SIZE),n.toString()}encodeCompressedDate(n,r){let s=this.getGeneralDecoder().extractNumericValueFromBitArray(r,Xe.DATE_SIZE);if(s==38400)return;n.append("("),n.append(this.dateCode),n.append(")");let o=s%32;s/=32;let a=s%12+1;s/=12;let u=s;u/10==0&&n.append("0"),n.append(u),a/10==0&&n.append("0"),n.append(a),o/10==0&&n.append("0"),n.append(o)}addWeightCode(n,r){n.append("("),n.append(this.firstAIdigits),n.append(r/1e5),n.append(")")}checkWeight(n){return n%1e5}}Xe.HEADER_SIZE=8,Xe.WEIGHT_SIZE=20,Xe.DATE_SIZE=16;function t1(y){try{if(y.get(1))return new oi(y);if(!y.get(2))return new uo(y);switch(si.extractNumericValueFromBitArray(y,1,4)){case 4:return new Oh(y);case 5:return new Dh(y)}switch(si.extractNumericValueFromBitArray(y,1,5)){case 12:return new Pn(y);case 13:return new Ft(y)}switch(si.extractNumericValueFromBitArray(y,1,7)){case 56:return new Xe(y,"310","11");case 57:return new Xe(y,"320","11");case 58:return new Xe(y,"310","13");case 59:return new Xe(y,"320","13");case 60:return new Xe(y,"310","15");case 61:return new Xe(y,"320","15");case 62:return new Xe(y,"310","17");case 63:return new Xe(y,"320","17")}}catch(n){throw console.log(n),new Dn("unknown decoder: "+y)}}class or{constructor(n,r,s,o){this.leftchar=n,this.rightchar=r,this.finderpattern=s,this.maybeLast=o}mayBeLast(){return this.maybeLast}getLeftChar(){return this.leftchar}getRightChar(){return this.rightchar}getFinderPattern(){return this.finderpattern}mustBeLast(){return this.rightchar==null}toString(){return"[ "+this.leftchar+", "+this.rightchar+" : "+(this.finderpattern==null?"null":this.finderpattern.getValue())+" ]"}static equals(n,r){return n instanceof or?or.equalsOrNull(n.leftchar,r.leftchar)&&or.equalsOrNull(n.rightchar,r.rightchar)&&or.equalsOrNull(n.finderpattern,r.finderpattern):!1}static equalsOrNull(n,r){return n===null?r===null:or.equals(n,r)}hashCode(){return this.leftchar.getValue()^this.rightchar.getValue()^this.finderpattern.getValue()}}class Za{constructor(n,r,s){this.pairs=n,this.rowNumber=r,this.wasReversed=s}getPairs(){return this.pairs}getRowNumber(){return this.rowNumber}isReversed(){return this.wasReversed}isEquivalent(n){return this.checkEqualitity(this,n)}toString(){return"{ "+this.pairs+" }"}equals(n,r){return n instanceof Za?this.checkEqualitity(n,r)&&n.wasReversed===r.wasReversed:!1}checkEqualitity(n,r){if(!n||!r)return;let s;return n.forEach((o,a)=>{r.forEach(u=>{o.getLeftChar().getValue()===u.getLeftChar().getValue()&&o.getRightChar().getValue()===u.getRightChar().getValue()&&o.getFinderPatter().getValue()===u.getFinderPatter().getValue()&&(s=!0)})}),s}}class Y extends bt{constructor(n){super(...arguments),this.pairs=new Array(Y.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=n===!0}decodeRow(n,r,s){this.pairs.length=0,this.startFromEven=!1;try{return Y.constructResult(this.decodeRow2pairs(n,r))}catch(o){this.verbose&&console.log(o)}return this.pairs.length=0,this.startFromEven=!0,Y.constructResult(this.decodeRow2pairs(n,r))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(n,r){let s=!1;for(;!s;)try{this.pairs.push(this.retrieveNextPair(r,this.pairs,n))}catch(a){if(a instanceof j){if(!this.pairs.length)throw new j;s=!0}}if(this.checkChecksum())return this.pairs;let o;if(this.rows.length?o=!0:o=!1,this.storeRow(n,!1),o){let a=this.checkRowsBoolean(!1);if(a!=null||(a=this.checkRowsBoolean(!0),a!=null))return a}throw new j}checkRowsBoolean(n){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,n&&(this.rows=this.rows.reverse());let r=null;try{r=this.checkRows(new Array,0)}catch(s){this.verbose&&console.log(s)}return n&&(this.rows=this.rows.reverse()),r}checkRows(n,r){for(let s=r;s<this.rows.length;s++){let o=this.rows[s];this.pairs.length=0;for(let u of n)this.pairs.push(u.getPairs());if(this.pairs.push(o.getPairs()),!Y.isValidSequence(this.pairs))continue;if(this.checkChecksum())return this.pairs;let a=new Array(n);a.push(o);try{return this.checkRows(a,s+1)}catch(u){this.verbose&&console.log(u)}}throw new j}static isValidSequence(n){for(let r of Y.FINDER_PATTERN_SEQUENCES){if(n.length>r.length)continue;let s=!0;for(let o=0;o<n.length;o++)if(n[o].getFinderPattern().getValue()!=r[o]){s=!1;break}if(s)return!0}return!1}storeRow(n,r){let s=0,o=!1,a=!1;for(;s<this.rows.length;){let u=this.rows[s];if(u.getRowNumber()>n){a=u.isEquivalent(this.pairs);break}o=u.isEquivalent(this.pairs),s++}a||o||Y.isPartialRow(this.pairs,this.rows)||(this.rows.push(s,new Za(this.pairs,n,r)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(n,r){for(let s of r)if(s.getPairs().length!==n.length){for(let o of s.getPairs())for(let a of n)if(or.equals(o,a))break}}static isPartialRow(n,r){for(let s of r){let o=!0;for(let a of n){let u=!1;for(let d of s.getPairs())if(a.equals(d)){u=!0;break}if(!u){o=!1;break}}if(o)return!0}return!1}getRows(){return this.rows}static constructResult(n){let r=bh.buildBitArray(n),o=t1(r).parseInformation(),a=n[0].getFinderPattern().getResultPoints(),u=n[n.length-1].getFinderPattern().getResultPoints(),d=[a[0],a[1],u[0],u[1]];return new Ke(o,null,null,d,ae.RSS_EXPANDED,null)}checkChecksum(){let n=this.pairs.get(0),r=n.getLeftChar(),s=n.getRightChar();if(s==null)return!1;let o=s.getChecksumPortion(),a=2;for(let d=1;d<this.pairs.size();++d){let h=this.pairs.get(d);o+=h.getLeftChar().getChecksumPortion(),a++;let g=h.getRightChar();g!=null&&(o+=g.getChecksumPortion(),a++)}return o%=211,211*(a-4)+o==r.getValue()}static getNextSecondBar(n,r){let s;return n.get(r)?(s=n.getNextUnset(r),s=n.getNextSet(s)):(s=n.getNextSet(r),s=n.getNextUnset(s)),s}retrieveNextPair(n,r,s){let o=r.length%2==0;this.startFromEven&&(o=!o);let a,u=!0,d=-1;do this.findNextPair(n,r,d),a=this.parseFoundFinderPattern(n,s,o),a==null?d=Y.getNextSecondBar(n,this.startEnd[0]):u=!1;while(u);let h=this.decodeDataCharacter(n,a,o,!0);if(!this.isEmptyPair(r)&&r[r.length-1].mustBeLast())throw new j;let g;try{g=this.decodeDataCharacter(n,a,o,!1)}catch(x){g=null,this.verbose&&console.log(x)}return new or(h,g,a,!0)}isEmptyPair(n){return n.length===0}findNextPair(n,r,s){let o=this.getDecodeFinderCounters();o[0]=0,o[1]=0,o[2]=0,o[3]=0;let a=n.getSize(),u;s>=0?u=s:this.isEmptyPair(r)?u=0:u=r[r.length-1].getFinderPattern().getStartEnd()[1];let d=r.length%2!=0;this.startFromEven&&(d=!d);let h=!1;for(;u<a&&(h=!n.get(u),!!h);)u++;let g=0,x=u;for(let E=u;E<a;E++)if(n.get(E)!=h)o[g]++;else{if(g==3){if(d&&Y.reverseCounters(o),Y.isFinderPattern(o)){this.startEnd[0]=x,this.startEnd[1]=E;return}d&&Y.reverseCounters(o),x+=o[0]+o[1],o[0]=o[2],o[1]=o[3],o[2]=0,o[3]=0,g--}else g++;o[g]=1,h=!h}throw new j}static reverseCounters(n){let r=n.length;for(let s=0;s<r/2;++s){let o=n[s];n[s]=n[r-s-1],n[r-s-1]=o}}parseFoundFinderPattern(n,r,s){let o,a,u;if(s){let g=this.startEnd[0]-1;for(;g>=0&&!n.get(g);)g--;g++,o=this.startEnd[0]-g,a=g,u=this.startEnd[1]}else a=this.startEnd[0],u=n.getNextUnset(this.startEnd[1]+1),o=u-this.startEnd[1];let d=this.getDecodeFinderCounters();B.arraycopy(d,0,d,1,d.length-1),d[0]=o;let h;try{h=this.parseFinderValue(d,Y.FINDER_PATTERNS)}catch{return null}return new lo(h,[a,u],a,u,r)}decodeDataCharacter(n,r,s,o){let a=this.getDataCharacterCounters();for(let Fe=0;Fe<a.length;Fe++)a[Fe]=0;if(o)Y.recordPatternInReverse(n,r.getStartEnd()[0],a);else{Y.recordPattern(n,r.getStartEnd()[1],a);for(let Fe=0,_t=a.length-1;Fe<_t;Fe++,_t--){let tn=a[Fe];a[Fe]=a[_t],a[_t]=tn}}let u=17,d=Te.sum(new Int32Array(a))/u,h=(r.getStartEnd()[1]-r.getStartEnd()[0])/15;if(Math.abs(d-h)/h>.3)throw new j;let g=this.getOddCounts(),x=this.getEvenCounts(),E=this.getOddRoundingErrors(),A=this.getEvenRoundingErrors();for(let Fe=0;Fe<a.length;Fe++){let _t=1*a[Fe]/d,tn=_t+.5;if(tn<1){if(_t<.3)throw new j;tn=1}else if(tn>8){if(_t>8.7)throw new j;tn=8}let fi=Fe/2;Fe&1?(x[fi]=tn,A[fi]=_t-tn):(g[fi]=tn,E[fi]=_t-tn)}this.adjustOddEvenCounts(u);let I=4*r.getValue()+(s?0:2)+(o?0:1)-1,b=0,D=0;for(let Fe=g.length-1;Fe>=0;Fe--){if(Y.isNotA1left(r,s,o)){let _t=Y.WEIGHTS[I][2*Fe];D+=g[Fe]*_t}b+=g[Fe]}let L=0;for(let Fe=x.length-1;Fe>=0;Fe--)if(Y.isNotA1left(r,s,o)){let _t=Y.WEIGHTS[I][2*Fe+1];L+=x[Fe]*_t}let z=D+L;if(b&1||b>13||b<4)throw new j;let q=(13-b)/2,$=Y.SYMBOL_WIDEST[q],Z=9-$,ve=Mn.getRSSvalue(g,$,!0),me=Mn.getRSSvalue(x,Z,!1),Yt=Y.EVEN_TOTAL_SUBSET[q],vn=Y.GSUM[q],Zt=ve*Yt+me+vn;return new ii(Zt,z)}static isNotA1left(n,r,s){return!(n.getValue()==0&&r&&s)}adjustOddEvenCounts(n){let r=Te.sum(new Int32Array(this.getOddCounts())),s=Te.sum(new Int32Array(this.getEvenCounts())),o=!1,a=!1;r>13?a=!0:r<4&&(o=!0);let u=!1,d=!1;s>13?d=!0:s<4&&(u=!0);let h=r+s-n,g=(r&1)==1,x=(s&1)==0;if(h==1)if(g){if(x)throw new j;a=!0}else{if(!x)throw new j;d=!0}else if(h==-1)if(g){if(x)throw new j;o=!0}else{if(!x)throw new j;u=!0}else if(h==0){if(g){if(!x)throw new j;r<s?(o=!0,d=!0):(a=!0,u=!0)}else if(x)throw new j}else throw new j;if(o){if(a)throw new j;Y.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(a&&Y.decrement(this.getOddCounts(),this.getOddRoundingErrors()),u){if(d)throw new j;Y.increment(this.getEvenCounts(),this.getOddRoundingErrors())}d&&Y.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}Y.SYMBOL_WIDEST=[7,5,4,3,1],Y.EVEN_TOTAL_SUBSET=[4,20,52,104,204],Y.GSUM=[0,348,1388,2948,3988],Y.FINDER_PATTERNS=[Int32Array.from([1,8,4,1]),Int32Array.from([3,6,4,1]),Int32Array.from([3,4,6,1]),Int32Array.from([3,2,8,1]),Int32Array.from([2,6,5,1]),Int32Array.from([2,2,9,1])],Y.WEIGHTS=[[1,3,9,27,81,32,96,77],[20,60,180,118,143,7,21,63],[189,145,13,39,117,140,209,205],[193,157,49,147,19,57,171,91],[62,186,136,197,169,85,44,132],[185,133,188,142,4,12,36,108],[113,128,173,97,80,29,87,50],[150,28,84,41,123,158,52,156],[46,138,203,187,139,206,196,166],[76,17,51,153,37,111,122,155],[43,129,176,106,107,110,119,146],[16,48,144,10,30,90,59,177],[109,116,137,200,178,112,125,164],[70,210,208,202,184,130,179,115],[134,191,151,31,93,68,204,190],[148,22,66,198,172,94,71,2],[6,18,54,162,64,192,154,40],[120,149,25,75,14,42,126,167],[79,26,78,23,69,207,199,175],[103,98,83,38,114,131,182,124],[161,61,183,127,170,88,53,159],[55,165,73,8,24,72,5,15],[45,135,194,160,58,174,100,89]],Y.FINDER_PAT_A=0,Y.FINDER_PAT_B=1,Y.FINDER_PAT_C=2,Y.FINDER_PAT_D=3,Y.FINDER_PAT_E=4,Y.FINDER_PAT_F=5,Y.FINDER_PATTERN_SEQUENCES=[[Y.FINDER_PAT_A,Y.FINDER_PAT_A],[Y.FINDER_PAT_A,Y.FINDER_PAT_B,Y.FINDER_PAT_B],[Y.FINDER_PAT_A,Y.FINDER_PAT_C,Y.FINDER_PAT_B,Y.FINDER_PAT_D],[Y.FINDER_PAT_A,Y.FINDER_PAT_E,Y.FINDER_PAT_B,Y.FINDER_PAT_D,Y.FINDER_PAT_C],[Y.FINDER_PAT_A,Y.FINDER_PAT_E,Y.FINDER_PAT_B,Y.FINDER_PAT_D,Y.FINDER_PAT_D,Y.FINDER_PAT_F],[Y.FINDER_PAT_A,Y.FINDER_PAT_E,Y.FINDER_PAT_B,Y.FINDER_PAT_D,Y.FINDER_PAT_E,Y.FINDER_PAT_F,Y.FINDER_PAT_F],[Y.FINDER_PAT_A,Y.FINDER_PAT_A,Y.FINDER_PAT_B,Y.FINDER_PAT_B,Y.FINDER_PAT_C,Y.FINDER_PAT_C,Y.FINDER_PAT_D,Y.FINDER_PAT_D],[Y.FINDER_PAT_A,Y.FINDER_PAT_A,Y.FINDER_PAT_B,Y.FINDER_PAT_B,Y.FINDER_PAT_C,Y.FINDER_PAT_C,Y.FINDER_PAT_D,Y.FINDER_PAT_E,Y.FINDER_PAT_E],[Y.FINDER_PAT_A,Y.FINDER_PAT_A,Y.FINDER_PAT_B,Y.FINDER_PAT_B,Y.FINDER_PAT_C,Y.FINDER_PAT_C,Y.FINDER_PAT_D,Y.FINDER_PAT_E,Y.FINDER_PAT_F,Y.FINDER_PAT_F],[Y.FINDER_PAT_A,Y.FINDER_PAT_A,Y.FINDER_PAT_B,Y.FINDER_PAT_B,Y.FINDER_PAT_C,Y.FINDER_PAT_D,Y.FINDER_PAT_D,Y.FINDER_PAT_E,Y.FINDER_PAT_E,Y.FINDER_PAT_F,Y.FINDER_PAT_F]],Y.MAX_PAIRS=11;class Mh extends ii{constructor(n,r,s){super(n,r),this.count=0,this.finderPattern=s}getFinderPattern(){return this.finderPattern}getCount(){return this.count}incrementCount(){this.count++}}class rt extends bt{constructor(){super(...arguments),this.possibleLeftPairs=[],this.possibleRightPairs=[]}decodeRow(n,r,s){const o=this.decodePair(r,!1,n,s);rt.addOrTally(this.possibleLeftPairs,o),r.reverse();let a=this.decodePair(r,!0,n,s);rt.addOrTally(this.possibleRightPairs,a),r.reverse();for(let u of this.possibleLeftPairs)if(u.getCount()>1){for(let d of this.possibleRightPairs)if(d.getCount()>1&&rt.checkChecksum(u,d))return rt.constructResult(u,d)}throw new j}static addOrTally(n,r){if(r==null)return;let s=!1;for(let o of n)if(o.getValue()===r.getValue()){o.incrementCount(),s=!0;break}s||n.push(r)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(n,r){let s=4537077*n.getValue()+r.getValue(),o=new String(s).toString(),a=new ge;for(let g=13-o.length;g>0;g--)a.append("0");a.append(o);let u=0;for(let g=0;g<13;g++){let x=a.charAt(g).charCodeAt(0)-48;u+=g&1?x:3*x}u=10-u%10,u===10&&(u=0),a.append(u.toString());let d=n.getFinderPattern().getResultPoints(),h=r.getFinderPattern().getResultPoints();return new Ke(a.toString(),null,0,[d[0],d[1],h[0],h[1]],ae.RSS_14,new Date().getTime())}static checkChecksum(n,r){let s=(n.getChecksumPortion()+16*r.getChecksumPortion())%79,o=9*n.getFinderPattern().getValue()+r.getFinderPattern().getValue();return o>72&&o--,o>8&&o--,s===o}decodePair(n,r,s,o){try{let a=this.findFinderPattern(n,r),u=this.parseFoundFinderPattern(n,s,r,a),d=o==null?null:o.get(U.NEED_RESULT_POINT_CALLBACK);if(d!=null){let x=(a[0]+a[1])/2;r&&(x=n.getSize()-1-x),d.foundPossibleResultPoint(new oe(x,s))}let h=this.decodeDataCharacter(n,u,!0),g=this.decodeDataCharacter(n,u,!1);return new Mh(1597*h.getValue()+g.getValue(),h.getChecksumPortion()+4*g.getChecksumPortion(),u)}catch{return null}}decodeDataCharacter(n,r,s){let o=this.getDataCharacterCounters();for(let L=0;L<o.length;L++)o[L]=0;if(s)ut.recordPatternInReverse(n,r.getStartEnd()[0],o);else{ut.recordPattern(n,r.getStartEnd()[1]+1,o);for(let L=0,z=o.length-1;L<z;L++,z--){let q=o[L];o[L]=o[z],o[z]=q}}let a=s?16:15,u=Te.sum(new Int32Array(o))/a,d=this.getOddCounts(),h=this.getEvenCounts(),g=this.getOddRoundingErrors(),x=this.getEvenRoundingErrors();for(let L=0;L<o.length;L++){let z=o[L]/u,q=Math.floor(z+.5);q<1?q=1:q>8&&(q=8);let $=Math.floor(L/2);L&1?(h[$]=q,x[$]=z-q):(d[$]=q,g[$]=z-q)}this.adjustOddEvenCounts(s,a);let E=0,A=0;for(let L=d.length-1;L>=0;L--)A*=9,A+=d[L],E+=d[L];let I=0,b=0;for(let L=h.length-1;L>=0;L--)I*=9,I+=h[L],b+=h[L];let D=A+3*I;if(s){if(E&1||E>12||E<4)throw new j;let L=(12-E)/2,z=rt.OUTSIDE_ODD_WIDEST[L],q=9-z,$=Mn.getRSSvalue(d,z,!1),Z=Mn.getRSSvalue(h,q,!0),ve=rt.OUTSIDE_EVEN_TOTAL_SUBSET[L],me=rt.OUTSIDE_GSUM[L];return new ii($*ve+Z+me,D)}else{if(b&1||b>10||b<4)throw new j;let L=(10-b)/2,z=rt.INSIDE_ODD_WIDEST[L],q=9-z,$=Mn.getRSSvalue(d,z,!0),Z=Mn.getRSSvalue(h,q,!1),ve=rt.INSIDE_ODD_TOTAL_SUBSET[L],me=rt.INSIDE_GSUM[L];return new ii(Z*ve+$+me,D)}}findFinderPattern(n,r){let s=this.getDecodeFinderCounters();s[0]=0,s[1]=0,s[2]=0,s[3]=0;let o=n.getSize(),a=!1,u=0;for(;u<o&&(a=!n.get(u),r!==a);)u++;let d=0,h=u;for(let g=u;g<o;g++)if(n.get(g)!==a)s[d]++;else{if(d===3){if(bt.isFinderPattern(s))return[h,g];h+=s[0]+s[1],s[0]=s[2],s[1]=s[3],s[2]=0,s[3]=0,d--}else d++;s[d]=1,a=!a}throw new j}parseFoundFinderPattern(n,r,s,o){let a=n.get(o[0]),u=o[0]-1;for(;u>=0&&a!==n.get(u);)u--;u++;const d=o[0]-u,h=this.getDecodeFinderCounters(),g=new Int32Array(h.length);B.arraycopy(h,0,g,1,h.length-1),g[0]=d;const x=this.parseFinderValue(g,rt.FINDER_PATTERNS);let E=u,A=o[1];return s&&(E=n.getSize()-1-E,A=n.getSize()-1-A),new lo(x,[u,o[1]],E,A,r)}adjustOddEvenCounts(n,r){let s=Te.sum(new Int32Array(this.getOddCounts())),o=Te.sum(new Int32Array(this.getEvenCounts())),a=!1,u=!1,d=!1,h=!1;n?(s>12?u=!0:s<4&&(a=!0),o>12?h=!0:o<4&&(d=!0)):(s>11?u=!0:s<5&&(a=!0),o>10?h=!0:o<4&&(d=!0));let g=s+o-r,x=(s&1)===(n?1:0),E=(o&1)===1;if(g===1)if(x){if(E)throw new j;u=!0}else{if(!E)throw new j;h=!0}else if(g===-1)if(x){if(E)throw new j;a=!0}else{if(!E)throw new j;d=!0}else if(g===0){if(x){if(!E)throw new j;s<o?(a=!0,h=!0):(u=!0,d=!0)}else if(E)throw new j}else throw new j;if(a){if(u)throw new j;bt.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(u&&bt.decrement(this.getOddCounts(),this.getOddRoundingErrors()),d){if(h)throw new j;bt.increment(this.getEvenCounts(),this.getOddRoundingErrors())}h&&bt.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}rt.OUTSIDE_EVEN_TOTAL_SUBSET=[1,10,34,70,126],rt.INSIDE_ODD_TOTAL_SUBSET=[4,20,48,81],rt.OUTSIDE_GSUM=[0,161,961,2015,2715],rt.INSIDE_GSUM=[0,336,1036,1516],rt.OUTSIDE_ODD_WIDEST=[8,6,4,3,1],rt.INSIDE_ODD_WIDEST=[2,4,6,8],rt.FINDER_PATTERNS=[Int32Array.from([3,8,2,1]),Int32Array.from([3,5,5,1]),Int32Array.from([3,3,7,1]),Int32Array.from([3,1,9,1]),Int32Array.from([2,7,4,1]),Int32Array.from([2,5,6,1]),Int32Array.from([2,3,8,1]),Int32Array.from([1,5,7,1]),Int32Array.from([1,3,9,1])];class ai extends ut{constructor(n,r){super(),this.readers=[],this.verbose=r===!0;const s=n?n.get(U.POSSIBLE_FORMATS):null,o=n&&n.get(U.ASSUME_CODE_39_CHECK_DIGIT)!==void 0;s?((s.includes(ae.EAN_13)||s.includes(ae.UPC_A)||s.includes(ae.EAN_8)||s.includes(ae.UPC_E))&&this.readers.push(new Ga(n)),s.includes(ae.CODE_39)&&this.readers.push(new ft(o)),s.includes(ae.CODE_128)&&this.readers.push(new J),s.includes(ae.ITF)&&this.readers.push(new Be),s.includes(ae.RSS_14)&&this.readers.push(new rt),s.includes(ae.RSS_EXPANDED)&&this.readers.push(new Y(this.verbose))):(this.readers.push(new Ga(n)),this.readers.push(new ft),this.readers.push(new Ga(n)),this.readers.push(new J),this.readers.push(new Be),this.readers.push(new rt),this.readers.push(new Y(this.verbose)))}decodeRow(n,r,s){for(let o=0;o<this.readers.length;o++)try{return this.readers[o].decodeRow(n,r,s)}catch{}throw new j}reset(){this.readers.forEach(n=>n.reset())}}class kh extends cn{constructor(n=500,r){super(new ai(r),n,r)}}class Me{constructor(n,r,s){this.ecCodewords=n,this.ecBlocks=[r],s&&this.ecBlocks.push(s)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class De{constructor(n,r){this.count=n,this.dataCodewords=r}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class Se{constructor(n,r,s,o,a,u){this.versionNumber=n,this.symbolSizeRows=r,this.symbolSizeColumns=s,this.dataRegionSizeRows=o,this.dataRegionSizeColumns=a,this.ecBlocks=u;let d=0;const h=u.getECCodewords(),g=u.getECBlocks();for(let x of g)d+=x.getCount()*(x.getDataCodewords()+h);this.totalCodewords=d}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}static getVersionForDimensions(n,r){if(n&1||r&1)throw new k;for(let s of Se.VERSIONS)if(s.symbolSizeRows===n&&s.symbolSizeColumns===r)return s;throw new k}toString(){return""+this.versionNumber}static buildVersions(){return[new Se(1,10,10,8,8,new Me(5,new De(1,3))),new Se(2,12,12,10,10,new Me(7,new De(1,5))),new Se(3,14,14,12,12,new Me(10,new De(1,8))),new Se(4,16,16,14,14,new Me(12,new De(1,12))),new Se(5,18,18,16,16,new Me(14,new De(1,18))),new Se(6,20,20,18,18,new Me(18,new De(1,22))),new Se(7,22,22,20,20,new Me(20,new De(1,30))),new Se(8,24,24,22,22,new Me(24,new De(1,36))),new Se(9,26,26,24,24,new Me(28,new De(1,44))),new Se(10,32,32,14,14,new Me(36,new De(1,62))),new Se(11,36,36,16,16,new Me(42,new De(1,86))),new Se(12,40,40,18,18,new Me(48,new De(1,114))),new Se(13,44,44,20,20,new Me(56,new De(1,144))),new Se(14,48,48,22,22,new Me(68,new De(1,174))),new Se(15,52,52,24,24,new Me(42,new De(2,102))),new Se(16,64,64,14,14,new Me(56,new De(2,140))),new Se(17,72,72,16,16,new Me(36,new De(4,92))),new Se(18,80,80,18,18,new Me(48,new De(4,114))),new Se(19,88,88,20,20,new Me(56,new De(4,144))),new Se(20,96,96,22,22,new Me(68,new De(4,174))),new Se(21,104,104,24,24,new Me(56,new De(6,136))),new Se(22,120,120,18,18,new Me(68,new De(6,175))),new Se(23,132,132,20,20,new Me(62,new De(8,163))),new Se(24,144,144,22,22,new Me(62,new De(8,156),new De(2,155))),new Se(25,8,18,6,16,new Me(7,new De(1,5))),new Se(26,8,32,6,14,new Me(11,new De(1,10))),new Se(27,12,26,10,24,new Me(14,new De(1,16))),new Se(28,12,36,10,16,new Me(18,new De(1,22))),new Se(29,16,36,14,16,new Me(24,new De(1,32))),new Se(30,16,48,14,22,new Me(28,new De(1,49)))]}}Se.VERSIONS=Se.buildVersions();class Ka{constructor(n){const r=n.getHeight();if(r<8||r>144||r&1)throw new k;this.version=Ka.readVersion(n),this.mappingBitMatrix=this.extractDataRegion(n),this.readMappingMatrix=new _e(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(n){const r=n.getHeight(),s=n.getWidth();return Se.getVersionForDimensions(r,s)}readCodewords(){const n=new Int8Array(this.version.getTotalCodewords());let r=0,s=4,o=0;const a=this.mappingBitMatrix.getHeight(),u=this.mappingBitMatrix.getWidth();let d=!1,h=!1,g=!1,x=!1;do if(s===a&&o===0&&!d)n[r++]=this.readCorner1(a,u)&255,s-=2,o+=2,d=!0;else if(s===a-2&&o===0&&u&3&&!h)n[r++]=this.readCorner2(a,u)&255,s-=2,o+=2,h=!0;else if(s===a+4&&o===2&&!(u&7)&&!g)n[r++]=this.readCorner3(a,u)&255,s-=2,o+=2,g=!0;else if(s===a-2&&o===0&&(u&7)===4&&!x)n[r++]=this.readCorner4(a,u)&255,s-=2,o+=2,x=!0;else{do s<a&&o>=0&&!this.readMappingMatrix.get(o,s)&&(n[r++]=this.readUtah(s,o,a,u)&255),s-=2,o+=2;while(s>=0&&o<u);s+=1,o+=3;do s>=0&&o<u&&!this.readMappingMatrix.get(o,s)&&(n[r++]=this.readUtah(s,o,a,u)&255),s+=2,o-=2;while(s<a&&o>=0);s+=3,o+=1}while(s<a||o<u);if(r!==this.version.getTotalCodewords())throw new k;return n}readModule(n,r,s,o){return n<0&&(n+=s,r+=4-(s+4&7)),r<0&&(r+=o,n+=4-(o+4&7)),this.readMappingMatrix.set(r,n),this.mappingBitMatrix.get(r,n)}readUtah(n,r,s,o){let a=0;return this.readModule(n-2,r-2,s,o)&&(a|=1),a<<=1,this.readModule(n-2,r-1,s,o)&&(a|=1),a<<=1,this.readModule(n-1,r-2,s,o)&&(a|=1),a<<=1,this.readModule(n-1,r-1,s,o)&&(a|=1),a<<=1,this.readModule(n-1,r,s,o)&&(a|=1),a<<=1,this.readModule(n,r-2,s,o)&&(a|=1),a<<=1,this.readModule(n,r-1,s,o)&&(a|=1),a<<=1,this.readModule(n,r,s,o)&&(a|=1),a}readCorner1(n,r){let s=0;return this.readModule(n-1,0,n,r)&&(s|=1),s<<=1,this.readModule(n-1,1,n,r)&&(s|=1),s<<=1,this.readModule(n-1,2,n,r)&&(s|=1),s<<=1,this.readModule(0,r-2,n,r)&&(s|=1),s<<=1,this.readModule(0,r-1,n,r)&&(s|=1),s<<=1,this.readModule(1,r-1,n,r)&&(s|=1),s<<=1,this.readModule(2,r-1,n,r)&&(s|=1),s<<=1,this.readModule(3,r-1,n,r)&&(s|=1),s}readCorner2(n,r){let s=0;return this.readModule(n-3,0,n,r)&&(s|=1),s<<=1,this.readModule(n-2,0,n,r)&&(s|=1),s<<=1,this.readModule(n-1,0,n,r)&&(s|=1),s<<=1,this.readModule(0,r-4,n,r)&&(s|=1),s<<=1,this.readModule(0,r-3,n,r)&&(s|=1),s<<=1,this.readModule(0,r-2,n,r)&&(s|=1),s<<=1,this.readModule(0,r-1,n,r)&&(s|=1),s<<=1,this.readModule(1,r-1,n,r)&&(s|=1),s}readCorner3(n,r){let s=0;return this.readModule(n-1,0,n,r)&&(s|=1),s<<=1,this.readModule(n-1,r-1,n,r)&&(s|=1),s<<=1,this.readModule(0,r-3,n,r)&&(s|=1),s<<=1,this.readModule(0,r-2,n,r)&&(s|=1),s<<=1,this.readModule(0,r-1,n,r)&&(s|=1),s<<=1,this.readModule(1,r-3,n,r)&&(s|=1),s<<=1,this.readModule(1,r-2,n,r)&&(s|=1),s<<=1,this.readModule(1,r-1,n,r)&&(s|=1),s}readCorner4(n,r){let s=0;return this.readModule(n-3,0,n,r)&&(s|=1),s<<=1,this.readModule(n-2,0,n,r)&&(s|=1),s<<=1,this.readModule(n-1,0,n,r)&&(s|=1),s<<=1,this.readModule(0,r-2,n,r)&&(s|=1),s<<=1,this.readModule(0,r-1,n,r)&&(s|=1),s<<=1,this.readModule(1,r-1,n,r)&&(s|=1),s<<=1,this.readModule(2,r-1,n,r)&&(s|=1),s<<=1,this.readModule(3,r-1,n,r)&&(s|=1),s}extractDataRegion(n){const r=this.version.getSymbolSizeRows(),s=this.version.getSymbolSizeColumns();if(n.getHeight()!==r)throw new v("Dimension of bitMatrix must match the version size");const o=this.version.getDataRegionSizeRows(),a=this.version.getDataRegionSizeColumns(),u=r/o|0,d=s/a|0,h=u*o,g=d*a,x=new _e(g,h);for(let E=0;E<u;++E){const A=E*o;for(let I=0;I<d;++I){const b=I*a;for(let D=0;D<o;++D){const L=E*(o+2)+1+D,z=A+D;for(let q=0;q<a;++q){const $=I*(a+2)+1+q;if(n.get($,L)){const Z=b+q;x.set(Z,z)}}}}}return x}}class Qa{constructor(n,r){this.numDataCodewords=n,this.codewords=r}static getDataBlocks(n,r){const s=r.getECBlocks();let o=0;const a=s.getECBlocks();for(let D of a)o+=D.getCount();const u=new Array(o);let d=0;for(let D of a)for(let L=0;L<D.getCount();L++){const z=D.getDataCodewords(),q=s.getECCodewords()+z;u[d++]=new Qa(z,new Uint8Array(q))}const g=u[0].codewords.length-s.getECCodewords(),x=g-1;let E=0;for(let D=0;D<x;D++)for(let L=0;L<d;L++)u[L].codewords[D]=n[E++];const A=r.getVersionNumber()===24,I=A?8:d;for(let D=0;D<I;D++)u[D].codewords[g-1]=n[E++];const b=u[0].codewords.length;for(let D=g;D<b;D++)for(let L=0;L<d;L++){const z=A?(L+8)%d:L,q=A&&z>7?D-1:D;u[z].codewords[q]=n[E++]}if(E!==n.length)throw new v;return u}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class qa{constructor(n){this.bytes=n,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(n){if(n<1||n>32||n>this.available())throw new v(""+n);let r=0,s=this.bitOffset,o=this.byteOffset;const a=this.bytes;if(s>0){const u=8-s,d=n<u?n:u,h=u-d,g=255>>8-d<<h;r=(a[o]&g)>>h,n-=d,s+=d,s===8&&(s=0,o++)}if(n>0){for(;n>=8;)r=r<<8|a[o]&255,o++,n-=8;if(n>0){const u=8-n,d=255>>u<<u;r=r<<n|(a[o]&d)>>u,s+=n}}return this.bitOffset=s,this.byteOffset=o,r}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var dt;(function(y){y[y.PAD_ENCODE=0]="PAD_ENCODE",y[y.ASCII_ENCODE=1]="ASCII_ENCODE",y[y.C40_ENCODE=2]="C40_ENCODE",y[y.TEXT_ENCODE=3]="TEXT_ENCODE",y[y.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",y[y.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",y[y.BASE256_ENCODE=6]="BASE256_ENCODE"})(dt||(dt={}));class ar{static decode(n){const r=new qa(n),s=new ge,o=new ge,a=new Array;let u=dt.ASCII_ENCODE;do if(u===dt.ASCII_ENCODE)u=this.decodeAsciiSegment(r,s,o);else{switch(u){case dt.C40_ENCODE:this.decodeC40Segment(r,s);break;case dt.TEXT_ENCODE:this.decodeTextSegment(r,s);break;case dt.ANSIX12_ENCODE:this.decodeAnsiX12Segment(r,s);break;case dt.EDIFACT_ENCODE:this.decodeEdifactSegment(r,s);break;case dt.BASE256_ENCODE:this.decodeBase256Segment(r,s,a);break;default:throw new k}u=dt.ASCII_ENCODE}while(u!==dt.PAD_ENCODE&&r.available()>0);return o.length()>0&&s.append(o.toString()),new Qi(n,s.toString(),a.length===0?null:a,null)}static decodeAsciiSegment(n,r,s){let o=!1;do{let a=n.readBits(8);if(a===0)throw new k;if(a<=128)return o&&(a+=128),r.append(String.fromCharCode(a-1)),dt.ASCII_ENCODE;if(a===129)return dt.PAD_ENCODE;if(a<=229){const u=a-130;u<10&&r.append("0"),r.append(""+u)}else switch(a){case 230:return dt.C40_ENCODE;case 231:return dt.BASE256_ENCODE;case 232:r.append("");break;case 233:case 234:break;case 235:o=!0;break;case 236:r.append("[)>05"),s.insert(0,"");break;case 237:r.append("[)>06"),s.insert(0,"");break;case 238:return dt.ANSIX12_ENCODE;case 239:return dt.TEXT_ENCODE;case 240:return dt.EDIFACT_ENCODE;case 241:break;default:if(a!==254||n.available()!==0)throw new k;break}}while(n.available()>0);return dt.ASCII_ENCODE}static decodeC40Segment(n,r){let s=!1;const o=[];let a=0;do{if(n.available()===8)return;const u=n.readBits(8);if(u===254)return;this.parseTwoBytes(u,n.readBits(8),o);for(let d=0;d<3;d++){const h=o[d];switch(a){case 0:if(h<3)a=h+1;else if(h<this.C40_BASIC_SET_CHARS.length){const g=this.C40_BASIC_SET_CHARS[h];s?(r.append(String.fromCharCode(g.charCodeAt(0)+128)),s=!1):r.append(g)}else throw new k;break;case 1:s?(r.append(String.fromCharCode(h+128)),s=!1):r.append(String.fromCharCode(h)),a=0;break;case 2:if(h<this.C40_SHIFT2_SET_CHARS.length){const g=this.C40_SHIFT2_SET_CHARS[h];s?(r.append(String.fromCharCode(g.charCodeAt(0)+128)),s=!1):r.append(g)}else switch(h){case 27:r.append("");break;case 30:s=!0;break;default:throw new k}a=0;break;case 3:s?(r.append(String.fromCharCode(h+224)),s=!1):r.append(String.fromCharCode(h+96)),a=0;break;default:throw new k}}}while(n.available()>0)}static decodeTextSegment(n,r){let s=!1,o=[],a=0;do{if(n.available()===8)return;const u=n.readBits(8);if(u===254)return;this.parseTwoBytes(u,n.readBits(8),o);for(let d=0;d<3;d++){const h=o[d];switch(a){case 0:if(h<3)a=h+1;else if(h<this.TEXT_BASIC_SET_CHARS.length){const g=this.TEXT_BASIC_SET_CHARS[h];s?(r.append(String.fromCharCode(g.charCodeAt(0)+128)),s=!1):r.append(g)}else throw new k;break;case 1:s?(r.append(String.fromCharCode(h+128)),s=!1):r.append(String.fromCharCode(h)),a=0;break;case 2:if(h<this.TEXT_SHIFT2_SET_CHARS.length){const g=this.TEXT_SHIFT2_SET_CHARS[h];s?(r.append(String.fromCharCode(g.charCodeAt(0)+128)),s=!1):r.append(g)}else switch(h){case 27:r.append("");break;case 30:s=!0;break;default:throw new k}a=0;break;case 3:if(h<this.TEXT_SHIFT3_SET_CHARS.length){const g=this.TEXT_SHIFT3_SET_CHARS[h];s?(r.append(String.fromCharCode(g.charCodeAt(0)+128)),s=!1):r.append(g),a=0}else throw new k;break;default:throw new k}}}while(n.available()>0)}static decodeAnsiX12Segment(n,r){const s=[];do{if(n.available()===8)return;const o=n.readBits(8);if(o===254)return;this.parseTwoBytes(o,n.readBits(8),s);for(let a=0;a<3;a++){const u=s[a];switch(u){case 0:r.append("\r");break;case 1:r.append("*");break;case 2:r.append(">");break;case 3:r.append(" ");break;default:if(u<14)r.append(String.fromCharCode(u+44));else if(u<40)r.append(String.fromCharCode(u+51));else throw new k;break}}}while(n.available()>0)}static parseTwoBytes(n,r,s){let o=(n<<8)+r-1,a=Math.floor(o/1600);s[0]=a,o-=a*1600,a=Math.floor(o/40),s[1]=a,s[2]=o-a*40}static decodeEdifactSegment(n,r){do{if(n.available()<=16)return;for(let s=0;s<4;s++){let o=n.readBits(6);if(o===31){const a=8-n.getBitOffset();a!==8&&n.readBits(a);return}o&32||(o|=64),r.append(String.fromCharCode(o))}}while(n.available()>0)}static decodeBase256Segment(n,r,s){let o=1+n.getByteOffset();const a=this.unrandomize255State(n.readBits(8),o++);let u;if(a===0?u=n.available()/8|0:a<250?u=a:u=250*(a-249)+this.unrandomize255State(n.readBits(8),o++),u<0)throw new k;const d=new Uint8Array(u);for(let h=0;h<u;h++){if(n.available()<8)throw new k;d[h]=this.unrandomize255State(n.readBits(8),o++)}s.push(d);try{r.append(Ee.decode(d,ie.ISO88591))}catch(h){throw new Dn("Platform does not support required encoding: "+h.message)}}static unrandomize255State(n,r){const s=149*r%255+1,o=n-s;return o>=0?o:o+256}}ar.C40_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],ar.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],ar.TEXT_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],ar.TEXT_SHIFT2_SET_CHARS=ar.C40_SHIFT2_SET_CHARS,ar.TEXT_SHIFT3_SET_CHARS=["`","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","|","}","~",""];class Ph{constructor(){this.rsDecoder=new $i(be.DATA_MATRIX_FIELD_256)}decode(n){const r=new Ka(n),s=r.getVersion(),o=r.readCodewords(),a=Qa.getDataBlocks(o,s);let u=0;for(let g of a)u+=g.getNumDataCodewords();const d=new Uint8Array(u),h=a.length;for(let g=0;g<h;g++){const x=a[g],E=x.getCodewords(),A=x.getNumDataCodewords();this.correctErrors(E,A);for(let I=0;I<A;I++)d[I*h+g]=E[I]}return ar.decode(d)}correctErrors(n,r){const s=new Int32Array(n);try{this.rsDecoder.decode(s,n.length-r)}catch{throw new M}for(let o=0;o<r;o++)n[o]=s[o]}}class at{constructor(n){this.image=n,this.rectangleDetector=new Gn(this.image)}detect(){const n=this.rectangleDetector.detect();let r=this.detectSolid1(n);if(r=this.detectSolid2(r),r[3]=this.correctTopRight(r),!r[3])throw new j;r=this.shiftToModuleCenter(r);const s=r[0],o=r[1],a=r[2],u=r[3];let d=this.transitionsBetween(s,u)+1,h=this.transitionsBetween(a,u)+1;(d&1)===1&&(d+=1),(h&1)===1&&(h+=1),4*d<7*h&&4*h<7*d&&(d=h=Math.max(d,h));let g=at.sampleGrid(this.image,s,o,a,u,d,h);return new oo(g,[s,o,a,u])}static shiftPoint(n,r,s){let o=(r.getX()-n.getX())/(s+1),a=(r.getY()-n.getY())/(s+1);return new oe(n.getX()+o,n.getY()+a)}static moveAway(n,r,s){let o=n.getX(),a=n.getY();return o<r?o-=1:o+=1,a<s?a-=1:a+=1,new oe(o,a)}detectSolid1(n){let r=n[0],s=n[1],o=n[3],a=n[2],u=this.transitionsBetween(r,s),d=this.transitionsBetween(s,o),h=this.transitionsBetween(o,a),g=this.transitionsBetween(a,r),x=u,E=[a,r,s,o];return x>d&&(x=d,E[0]=r,E[1]=s,E[2]=o,E[3]=a),x>h&&(x=h,E[0]=s,E[1]=o,E[2]=a,E[3]=r),x>g&&(E[0]=o,E[1]=a,E[2]=r,E[3]=s),E}detectSolid2(n){let r=n[0],s=n[1],o=n[2],a=n[3],u=this.transitionsBetween(r,a),d=at.shiftPoint(s,o,(u+1)*4),h=at.shiftPoint(o,s,(u+1)*4),g=this.transitionsBetween(d,r),x=this.transitionsBetween(h,a);return g<x?(n[0]=r,n[1]=s,n[2]=o,n[3]=a):(n[0]=s,n[1]=o,n[2]=a,n[3]=r),n}correctTopRight(n){let r=n[0],s=n[1],o=n[2],a=n[3],u=this.transitionsBetween(r,a),d=this.transitionsBetween(s,a),h=at.shiftPoint(r,s,(d+1)*4),g=at.shiftPoint(o,s,(u+1)*4);u=this.transitionsBetween(h,a),d=this.transitionsBetween(g,a);let x=new oe(a.getX()+(o.getX()-s.getX())/(u+1),a.getY()+(o.getY()-s.getY())/(u+1)),E=new oe(a.getX()+(r.getX()-s.getX())/(d+1),a.getY()+(r.getY()-s.getY())/(d+1));if(!this.isValid(x))return this.isValid(E)?E:null;if(!this.isValid(E))return x;let A=this.transitionsBetween(h,x)+this.transitionsBetween(g,x),I=this.transitionsBetween(h,E)+this.transitionsBetween(g,E);return A>I?x:E}shiftToModuleCenter(n){let r=n[0],s=n[1],o=n[2],a=n[3],u=this.transitionsBetween(r,a)+1,d=this.transitionsBetween(o,a)+1,h=at.shiftPoint(r,s,d*4),g=at.shiftPoint(o,s,u*4);u=this.transitionsBetween(h,a)+1,d=this.transitionsBetween(g,a)+1,(u&1)===1&&(u+=1),(d&1)===1&&(d+=1);let x=(r.getX()+s.getX()+o.getX()+a.getX())/4,E=(r.getY()+s.getY()+o.getY()+a.getY())/4;r=at.moveAway(r,x,E),s=at.moveAway(s,x,E),o=at.moveAway(o,x,E),a=at.moveAway(a,x,E);let A,I;return h=at.shiftPoint(r,s,d*4),h=at.shiftPoint(h,a,u*4),A=at.shiftPoint(s,r,d*4),A=at.shiftPoint(A,o,u*4),g=at.shiftPoint(o,a,d*4),g=at.shiftPoint(g,s,u*4),I=at.shiftPoint(a,o,d*4),I=at.shiftPoint(I,r,u*4),[h,A,g,I]}isValid(n){return n.getX()>=0&&n.getX()<this.image.getWidth()&&n.getY()>0&&n.getY()<this.image.getHeight()}static sampleGrid(n,r,s,o,a,u,d){return sr.getInstance().sampleGrid(n,u,d,.5,.5,u-.5,.5,u-.5,d-.5,.5,d-.5,r.getX(),r.getY(),a.getX(),a.getY(),o.getX(),o.getY(),s.getX(),s.getY())}transitionsBetween(n,r){let s=Math.trunc(n.getX()),o=Math.trunc(n.getY()),a=Math.trunc(r.getX()),u=Math.trunc(r.getY()),d=Math.abs(u-o)>Math.abs(a-s);if(d){let D=s;s=o,o=D,D=a,a=u,u=D}let h=Math.abs(a-s),g=Math.abs(u-o),x=-h/2,E=o<u?1:-1,A=s<a?1:-1,I=0,b=this.image.get(d?o:s,d?s:o);for(let D=s,L=o;D!==a;D+=A){let z=this.image.get(d?L:D,d?D:L);if(z!==b&&(I++,b=z),x+=g,x>0){if(L===u)break;L+=E,x-=h}}return I}}class lr{constructor(){this.decoder=new Ph}decode(n,r=null){let s,o;if(r!=null&&r.has(U.PURE_BARCODE)){const g=lr.extractPureBits(n.getBlackMatrix());s=this.decoder.decode(g),o=lr.NO_POINTS}else{const g=new at(n.getBlackMatrix()).detect();s=this.decoder.decode(g.getBits()),o=g.getPoints()}const a=s.getRawBytes(),u=new Ke(s.getText(),a,8*a.length,o,ae.DATA_MATRIX,B.currentTimeMillis()),d=s.getByteSegments();d!=null&&u.putMetadata(mt.BYTE_SEGMENTS,d);const h=s.getECLevel();return h!=null&&u.putMetadata(mt.ERROR_CORRECTION_LEVEL,h),u}reset(){}static extractPureBits(n){const r=n.getTopLeftOnBit(),s=n.getBottomRightOnBit();if(r==null||s==null)throw new j;const o=this.moduleSize(r,n);let a=r[1];const u=s[1];let d=r[0];const g=(s[0]-d+1)/o,x=(u-a+1)/o;if(g<=0||x<=0)throw new j;const E=o/2;a+=E,d+=E;const A=new _e(g,x);for(let I=0;I<x;I++){const b=a+I*o;for(let D=0;D<g;D++)n.get(d+D*o,b)&&A.set(D,I)}return A}static moduleSize(n,r){const s=r.getWidth();let o=n[0];const a=n[1];for(;o<s&&r.get(o,a);)o++;if(o===s)throw new j;const u=o-n[0];if(u===0)throw new j;return u}}lr.NO_POINTS=[];class Bh extends cn{constructor(n=500){super(new lr,n)}}var li;(function(y){y[y.L=0]="L",y[y.M=1]="M",y[y.Q=2]="Q",y[y.H=3]="H"})(li||(li={}));class We{constructor(n,r,s){this.value=n,this.stringValue=r,this.bits=s,We.FOR_BITS.set(s,this),We.FOR_VALUE.set(n,this)}getValue(){return this.value}getBits(){return this.bits}static fromString(n){switch(n){case"L":return We.L;case"M":return We.M;case"Q":return We.Q;case"H":return We.H;default:throw new _(n+"not available")}}toString(){return this.stringValue}equals(n){if(!(n instanceof We))return!1;const r=n;return this.value===r.value}static forBits(n){if(n<0||n>=We.FOR_BITS.size)throw new v;return We.FOR_BITS.get(n)}}We.FOR_BITS=new Map,We.FOR_VALUE=new Map,We.L=new We(li.L,"L",1),We.M=new We(li.M,"M",0),We.Q=new We(li.Q,"Q",3),We.H=new We(li.H,"H",2);class Ot{constructor(n){this.errorCorrectionLevel=We.forBits(n>>3&3),this.dataMask=n&7}static numBitsDiffering(n,r){return N.bitCount(n^r)}static decodeFormatInformation(n,r){const s=Ot.doDecodeFormatInformation(n,r);return s!==null?s:Ot.doDecodeFormatInformation(n^Ot.FORMAT_INFO_MASK_QR,r^Ot.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(n,r){let s=Number.MAX_SAFE_INTEGER,o=0;for(const a of Ot.FORMAT_INFO_DECODE_LOOKUP){const u=a[0];if(u===n||u===r)return new Ot(a[1]);let d=Ot.numBitsDiffering(n,u);d<s&&(o=a[1],s=d),n!==r&&(d=Ot.numBitsDiffering(r,u),d<s&&(o=a[1],s=d))}return s<=3?new Ot(o):null}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getDataMask(){return this.dataMask}hashCode(){return this.errorCorrectionLevel.getBits()<<3|this.dataMask}equals(n){if(!(n instanceof Ot))return!1;const r=n;return this.errorCorrectionLevel===r.errorCorrectionLevel&&this.dataMask===r.dataMask}}Ot.FORMAT_INFO_MASK_QR=21522,Ot.FORMAT_INFO_DECODE_LOOKUP=[Int32Array.from([21522,0]),Int32Array.from([20773,1]),Int32Array.from([24188,2]),Int32Array.from([23371,3]),Int32Array.from([17913,4]),Int32Array.from([16590,5]),Int32Array.from([20375,6]),Int32Array.from([19104,7]),Int32Array.from([30660,8]),Int32Array.from([29427,9]),Int32Array.from([32170,10]),Int32Array.from([30877,11]),Int32Array.from([26159,12]),Int32Array.from([25368,13]),Int32Array.from([27713,14]),Int32Array.from([26998,15]),Int32Array.from([5769,16]),Int32Array.from([5054,17]),Int32Array.from([7399,18]),Int32Array.from([6608,19]),Int32Array.from([1890,20]),Int32Array.from([597,21]),Int32Array.from([3340,22]),Int32Array.from([2107,23]),Int32Array.from([13663,24]),Int32Array.from([12392,25]),Int32Array.from([16177,26]),Int32Array.from([14854,27]),Int32Array.from([9396,28]),Int32Array.from([8579,29]),Int32Array.from([11994,30]),Int32Array.from([11245,31])];class F{constructor(n,...r){this.ecCodewordsPerBlock=n,this.ecBlocks=r}getECCodewordsPerBlock(){return this.ecCodewordsPerBlock}getNumBlocks(){let n=0;const r=this.ecBlocks;for(const s of r)n+=s.getCount();return n}getTotalECCodewords(){return this.ecCodewordsPerBlock*this.getNumBlocks()}getECBlocks(){return this.ecBlocks}}class S{constructor(n,r){this.count=n,this.dataCodewords=r}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class le{constructor(n,r,...s){this.versionNumber=n,this.alignmentPatternCenters=r,this.ecBlocks=s;let o=0;const a=s[0].getECCodewordsPerBlock(),u=s[0].getECBlocks();for(const d of u)o+=d.getCount()*(d.getDataCodewords()+a);this.totalCodewords=o}getVersionNumber(){return this.versionNumber}getAlignmentPatternCenters(){return this.alignmentPatternCenters}getTotalCodewords(){return this.totalCodewords}getDimensionForVersion(){return 17+4*this.versionNumber}getECBlocksForLevel(n){return this.ecBlocks[n.getValue()]}static getProvisionalVersionForDimension(n){if(n%4!==1)throw new k;try{return this.getVersionForNumber((n-17)/4)}catch{throw new k}}static getVersionForNumber(n){if(n<1||n>40)throw new v;return le.VERSIONS[n-1]}static decodeVersionInformation(n){let r=Number.MAX_SAFE_INTEGER,s=0;for(let o=0;o<le.VERSION_DECODE_INFO.length;o++){const a=le.VERSION_DECODE_INFO[o];if(a===n)return le.getVersionForNumber(o+7);const u=Ot.numBitsDiffering(n,a);u<r&&(s=o+7,r=u)}return r<=3?le.getVersionForNumber(s):null}buildFunctionPattern(){const n=this.getDimensionForVersion(),r=new _e(n);r.setRegion(0,0,9,9),r.setRegion(n-8,0,8,9),r.setRegion(0,n-8,9,8);const s=this.alignmentPatternCenters.length;for(let o=0;o<s;o++){const a=this.alignmentPatternCenters[o]-2;for(let u=0;u<s;u++)o===0&&(u===0||u===s-1)||o===s-1&&u===0||r.setRegion(this.alignmentPatternCenters[u]-2,a,5,5)}return r.setRegion(6,9,1,n-17),r.setRegion(9,6,n-17,1),this.versionNumber>6&&(r.setRegion(n-11,0,3,6),r.setRegion(0,n-11,6,3)),r}toString(){return""+this.versionNumber}}le.VERSION_DECODE_INFO=Int32Array.from([31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017]),le.VERSIONS=[new le(1,new Int32Array(0),new F(7,new S(1,19)),new F(10,new S(1,16)),new F(13,new S(1,13)),new F(17,new S(1,9))),new le(2,Int32Array.from([6,18]),new F(10,new S(1,34)),new F(16,new S(1,28)),new F(22,new S(1,22)),new F(28,new S(1,16))),new le(3,Int32Array.from([6,22]),new F(15,new S(1,55)),new F(26,new S(1,44)),new F(18,new S(2,17)),new F(22,new S(2,13))),new le(4,Int32Array.from([6,26]),new F(20,new S(1,80)),new F(18,new S(2,32)),new F(26,new S(2,24)),new F(16,new S(4,9))),new le(5,Int32Array.from([6,30]),new F(26,new S(1,108)),new F(24,new S(2,43)),new F(18,new S(2,15),new S(2,16)),new F(22,new S(2,11),new S(2,12))),new le(6,Int32Array.from([6,34]),new F(18,new S(2,68)),new F(16,new S(4,27)),new F(24,new S(4,19)),new F(28,new S(4,15))),new le(7,Int32Array.from([6,22,38]),new F(20,new S(2,78)),new F(18,new S(4,31)),new F(18,new S(2,14),new S(4,15)),new F(26,new S(4,13),new S(1,14))),new le(8,Int32Array.from([6,24,42]),new F(24,new S(2,97)),new F(22,new S(2,38),new S(2,39)),new F(22,new S(4,18),new S(2,19)),new F(26,new S(4,14),new S(2,15))),new le(9,Int32Array.from([6,26,46]),new F(30,new S(2,116)),new F(22,new S(3,36),new S(2,37)),new F(20,new S(4,16),new S(4,17)),new F(24,new S(4,12),new S(4,13))),new le(10,Int32Array.from([6,28,50]),new F(18,new S(2,68),new S(2,69)),new F(26,new S(4,43),new S(1,44)),new F(24,new S(6,19),new S(2,20)),new F(28,new S(6,15),new S(2,16))),new le(11,Int32Array.from([6,30,54]),new F(20,new S(4,81)),new F(30,new S(1,50),new S(4,51)),new F(28,new S(4,22),new S(4,23)),new F(24,new S(3,12),new S(8,13))),new le(12,Int32Array.from([6,32,58]),new F(24,new S(2,92),new S(2,93)),new F(22,new S(6,36),new S(2,37)),new F(26,new S(4,20),new S(6,21)),new F(28,new S(7,14),new S(4,15))),new le(13,Int32Array.from([6,34,62]),new F(26,new S(4,107)),new F(22,new S(8,37),new S(1,38)),new F(24,new S(8,20),new S(4,21)),new F(22,new S(12,11),new S(4,12))),new le(14,Int32Array.from([6,26,46,66]),new F(30,new S(3,115),new S(1,116)),new F(24,new S(4,40),new S(5,41)),new F(20,new S(11,16),new S(5,17)),new F(24,new S(11,12),new S(5,13))),new le(15,Int32Array.from([6,26,48,70]),new F(22,new S(5,87),new S(1,88)),new F(24,new S(5,41),new S(5,42)),new F(30,new S(5,24),new S(7,25)),new F(24,new S(11,12),new S(7,13))),new le(16,Int32Array.from([6,26,50,74]),new F(24,new S(5,98),new S(1,99)),new F(28,new S(7,45),new S(3,46)),new F(24,new S(15,19),new S(2,20)),new F(30,new S(3,15),new S(13,16))),new le(17,Int32Array.from([6,30,54,78]),new F(28,new S(1,107),new S(5,108)),new F(28,new S(10,46),new S(1,47)),new F(28,new S(1,22),new S(15,23)),new F(28,new S(2,14),new S(17,15))),new le(18,Int32Array.from([6,30,56,82]),new F(30,new S(5,120),new S(1,121)),new F(26,new S(9,43),new S(4,44)),new F(28,new S(17,22),new S(1,23)),new F(28,new S(2,14),new S(19,15))),new le(19,Int32Array.from([6,30,58,86]),new F(28,new S(3,113),new S(4,114)),new F(26,new S(3,44),new S(11,45)),new F(26,new S(17,21),new S(4,22)),new F(26,new S(9,13),new S(16,14))),new le(20,Int32Array.from([6,34,62,90]),new F(28,new S(3,107),new S(5,108)),new F(26,new S(3,41),new S(13,42)),new F(30,new S(15,24),new S(5,25)),new F(28,new S(15,15),new S(10,16))),new le(21,Int32Array.from([6,28,50,72,94]),new F(28,new S(4,116),new S(4,117)),new F(26,new S(17,42)),new F(28,new S(17,22),new S(6,23)),new F(30,new S(19,16),new S(6,17))),new le(22,Int32Array.from([6,26,50,74,98]),new F(28,new S(2,111),new S(7,112)),new F(28,new S(17,46)),new F(30,new S(7,24),new S(16,25)),new F(24,new S(34,13))),new le(23,Int32Array.from([6,30,54,78,102]),new F(30,new S(4,121),new S(5,122)),new F(28,new S(4,47),new S(14,48)),new F(30,new S(11,24),new S(14,25)),new F(30,new S(16,15),new S(14,16))),new le(24,Int32Array.from([6,28,54,80,106]),new F(30,new S(6,117),new S(4,118)),new F(28,new S(6,45),new S(14,46)),new F(30,new S(11,24),new S(16,25)),new F(30,new S(30,16),new S(2,17))),new le(25,Int32Array.from([6,32,58,84,110]),new F(26,new S(8,106),new S(4,107)),new F(28,new S(8,47),new S(13,48)),new F(30,new S(7,24),new S(22,25)),new F(30,new S(22,15),new S(13,16))),new le(26,Int32Array.from([6,30,58,86,114]),new F(28,new S(10,114),new S(2,115)),new F(28,new S(19,46),new S(4,47)),new F(28,new S(28,22),new S(6,23)),new F(30,new S(33,16),new S(4,17))),new le(27,Int32Array.from([6,34,62,90,118]),new F(30,new S(8,122),new S(4,123)),new F(28,new S(22,45),new S(3,46)),new F(30,new S(8,23),new S(26,24)),new F(30,new S(12,15),new S(28,16))),new le(28,Int32Array.from([6,26,50,74,98,122]),new F(30,new S(3,117),new S(10,118)),new F(28,new S(3,45),new S(23,46)),new F(30,new S(4,24),new S(31,25)),new F(30,new S(11,15),new S(31,16))),new le(29,Int32Array.from([6,30,54,78,102,126]),new F(30,new S(7,116),new S(7,117)),new F(28,new S(21,45),new S(7,46)),new F(30,new S(1,23),new S(37,24)),new F(30,new S(19,15),new S(26,16))),new le(30,Int32Array.from([6,26,52,78,104,130]),new F(30,new S(5,115),new S(10,116)),new F(28,new S(19,47),new S(10,48)),new F(30,new S(15,24),new S(25,25)),new F(30,new S(23,15),new S(25,16))),new le(31,Int32Array.from([6,30,56,82,108,134]),new F(30,new S(13,115),new S(3,116)),new F(28,new S(2,46),new S(29,47)),new F(30,new S(42,24),new S(1,25)),new F(30,new S(23,15),new S(28,16))),new le(32,Int32Array.from([6,34,60,86,112,138]),new F(30,new S(17,115)),new F(28,new S(10,46),new S(23,47)),new F(30,new S(10,24),new S(35,25)),new F(30,new S(19,15),new S(35,16))),new le(33,Int32Array.from([6,30,58,86,114,142]),new F(30,new S(17,115),new S(1,116)),new F(28,new S(14,46),new S(21,47)),new F(30,new S(29,24),new S(19,25)),new F(30,new S(11,15),new S(46,16))),new le(34,Int32Array.from([6,34,62,90,118,146]),new F(30,new S(13,115),new S(6,116)),new F(28,new S(14,46),new S(23,47)),new F(30,new S(44,24),new S(7,25)),new F(30,new S(59,16),new S(1,17))),new le(35,Int32Array.from([6,30,54,78,102,126,150]),new F(30,new S(12,121),new S(7,122)),new F(28,new S(12,47),new S(26,48)),new F(30,new S(39,24),new S(14,25)),new F(30,new S(22,15),new S(41,16))),new le(36,Int32Array.from([6,24,50,76,102,128,154]),new F(30,new S(6,121),new S(14,122)),new F(28,new S(6,47),new S(34,48)),new F(30,new S(46,24),new S(10,25)),new F(30,new S(2,15),new S(64,16))),new le(37,Int32Array.from([6,28,54,80,106,132,158]),new F(30,new S(17,122),new S(4,123)),new F(28,new S(29,46),new S(14,47)),new F(30,new S(49,24),new S(10,25)),new F(30,new S(24,15),new S(46,16))),new le(38,Int32Array.from([6,32,58,84,110,136,162]),new F(30,new S(4,122),new S(18,123)),new F(28,new S(13,46),new S(32,47)),new F(30,new S(48,24),new S(14,25)),new F(30,new S(42,15),new S(32,16))),new le(39,Int32Array.from([6,26,54,82,110,138,166]),new F(30,new S(20,117),new S(4,118)),new F(28,new S(40,47),new S(7,48)),new F(30,new S(43,24),new S(22,25)),new F(30,new S(10,15),new S(67,16))),new le(40,Int32Array.from([6,30,58,86,114,142,170]),new F(30,new S(19,118),new S(6,119)),new F(28,new S(18,47),new S(31,48)),new F(30,new S(34,24),new S(34,25)),new F(30,new S(20,15),new S(61,16)))];var wt;(function(y){y[y.DATA_MASK_000=0]="DATA_MASK_000",y[y.DATA_MASK_001=1]="DATA_MASK_001",y[y.DATA_MASK_010=2]="DATA_MASK_010",y[y.DATA_MASK_011=3]="DATA_MASK_011",y[y.DATA_MASK_100=4]="DATA_MASK_100",y[y.DATA_MASK_101=5]="DATA_MASK_101",y[y.DATA_MASK_110=6]="DATA_MASK_110",y[y.DATA_MASK_111=7]="DATA_MASK_111"})(wt||(wt={}));class dn{constructor(n,r){this.value=n,this.isMasked=r}unmaskBitMatrix(n,r){for(let s=0;s<r;s++)for(let o=0;o<r;o++)this.isMasked(s,o)&&n.flip(o,s)}}dn.values=new Map([[wt.DATA_MASK_000,new dn(wt.DATA_MASK_000,(y,n)=>(y+n&1)===0)],[wt.DATA_MASK_001,new dn(wt.DATA_MASK_001,(y,n)=>(y&1)===0)],[wt.DATA_MASK_010,new dn(wt.DATA_MASK_010,(y,n)=>n%3===0)],[wt.DATA_MASK_011,new dn(wt.DATA_MASK_011,(y,n)=>(y+n)%3===0)],[wt.DATA_MASK_100,new dn(wt.DATA_MASK_100,(y,n)=>(Math.floor(y/2)+Math.floor(n/3)&1)===0)],[wt.DATA_MASK_101,new dn(wt.DATA_MASK_101,(y,n)=>y*n%6===0)],[wt.DATA_MASK_110,new dn(wt.DATA_MASK_110,(y,n)=>y*n%6<3)],[wt.DATA_MASK_111,new dn(wt.DATA_MASK_111,(y,n)=>(y+n+y*n%3&1)===0)]]);class Lh{constructor(n){const r=n.getHeight();if(r<21||(r&3)!==1)throw new k;this.bitMatrix=n}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let n=0;for(let a=0;a<6;a++)n=this.copyBit(a,8,n);n=this.copyBit(7,8,n),n=this.copyBit(8,8,n),n=this.copyBit(8,7,n);for(let a=5;a>=0;a--)n=this.copyBit(8,a,n);const r=this.bitMatrix.getHeight();let s=0;const o=r-7;for(let a=r-1;a>=o;a--)s=this.copyBit(8,a,s);for(let a=r-8;a<r;a++)s=this.copyBit(a,8,s);if(this.parsedFormatInfo=Ot.decodeFormatInformation(n,s),this.parsedFormatInfo!==null)return this.parsedFormatInfo;throw new k}readVersion(){if(this.parsedVersion!==null&&this.parsedVersion!==void 0)return this.parsedVersion;const n=this.bitMatrix.getHeight(),r=Math.floor((n-17)/4);if(r<=6)return le.getVersionForNumber(r);let s=0;const o=n-11;for(let u=5;u>=0;u--)for(let d=n-9;d>=o;d--)s=this.copyBit(d,u,s);let a=le.decodeVersionInformation(s);if(a!==null&&a.getDimensionForVersion()===n)return this.parsedVersion=a,a;s=0;for(let u=5;u>=0;u--)for(let d=n-9;d>=o;d--)s=this.copyBit(u,d,s);if(a=le.decodeVersionInformation(s),a!==null&&a.getDimensionForVersion()===n)return this.parsedVersion=a,a;throw new k}copyBit(n,r,s){return(this.isMirror?this.bitMatrix.get(r,n):this.bitMatrix.get(n,r))?s<<1|1:s<<1}readCodewords(){const n=this.readFormatInformation(),r=this.readVersion(),s=dn.values.get(n.getDataMask()),o=this.bitMatrix.getHeight();s.unmaskBitMatrix(this.bitMatrix,o);const a=r.buildFunctionPattern();let u=!0;const d=new Uint8Array(r.getTotalCodewords());let h=0,g=0,x=0;for(let E=o-1;E>0;E-=2){E===6&&E--;for(let A=0;A<o;A++){const I=u?o-1-A:A;for(let b=0;b<2;b++)a.get(E-b,I)||(x++,g<<=1,this.bitMatrix.get(E-b,I)&&(g|=1),x===8&&(d[h++]=g,x=0,g=0))}u=!u}if(h!==r.getTotalCodewords())throw new k;return d}remask(){if(this.parsedFormatInfo===null)return;const n=dn.values[this.parsedFormatInfo.getDataMask()],r=this.bitMatrix.getHeight();n.unmaskBitMatrix(this.bitMatrix,r)}setMirror(n){this.parsedVersion=null,this.parsedFormatInfo=null,this.isMirror=n}mirror(){const n=this.bitMatrix;for(let r=0,s=n.getWidth();r<s;r++)for(let o=r+1,a=n.getHeight();o<a;o++)n.get(r,o)!==n.get(o,r)&&(n.flip(o,r),n.flip(r,o))}}class $a{constructor(n,r){this.numDataCodewords=n,this.codewords=r}static getDataBlocks(n,r,s){if(n.length!==r.getTotalCodewords())throw new v;const o=r.getECBlocksForLevel(s);let a=0;const u=o.getECBlocks();for(const b of u)a+=b.getCount();const d=new Array(a);let h=0;for(const b of u)for(let D=0;D<b.getCount();D++){const L=b.getDataCodewords(),z=o.getECCodewordsPerBlock()+L;d[h++]=new $a(L,new Uint8Array(z))}const g=d[0].codewords.length;let x=d.length-1;for(;x>=0&&d[x].codewords.length!==g;)x--;x++;const E=g-o.getECCodewordsPerBlock();let A=0;for(let b=0;b<E;b++)for(let D=0;D<h;D++)d[D].codewords[b]=n[A++];for(let b=x;b<h;b++)d[b].codewords[E]=n[A++];const I=d[0].codewords.length;for(let b=E;b<I;b++)for(let D=0;D<h;D++){const L=D<x?b:b+1;d[D].codewords[L]=n[A++]}return d}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}var hn;(function(y){y[y.TERMINATOR=0]="TERMINATOR",y[y.NUMERIC=1]="NUMERIC",y[y.ALPHANUMERIC=2]="ALPHANUMERIC",y[y.STRUCTURED_APPEND=3]="STRUCTURED_APPEND",y[y.BYTE=4]="BYTE",y[y.ECI=5]="ECI",y[y.KANJI=6]="KANJI",y[y.FNC1_FIRST_POSITION=7]="FNC1_FIRST_POSITION",y[y.FNC1_SECOND_POSITION=8]="FNC1_SECOND_POSITION",y[y.HANZI=9]="HANZI"})(hn||(hn={}));class ce{constructor(n,r,s,o){this.value=n,this.stringValue=r,this.characterCountBitsForVersions=s,this.bits=o,ce.FOR_BITS.set(o,this),ce.FOR_VALUE.set(n,this)}static forBits(n){const r=ce.FOR_BITS.get(n);if(r===void 0)throw new v;return r}getCharacterCountBits(n){const r=n.getVersionNumber();let s;return r<=9?s=0:r<=26?s=1:s=2,this.characterCountBitsForVersions[s]}getValue(){return this.value}getBits(){return this.bits}equals(n){if(!(n instanceof ce))return!1;const r=n;return this.value===r.value}toString(){return this.stringValue}}ce.FOR_BITS=new Map,ce.FOR_VALUE=new Map,ce.TERMINATOR=new ce(hn.TERMINATOR,"TERMINATOR",Int32Array.from([0,0,0]),0),ce.NUMERIC=new ce(hn.NUMERIC,"NUMERIC",Int32Array.from([10,12,14]),1),ce.ALPHANUMERIC=new ce(hn.ALPHANUMERIC,"ALPHANUMERIC",Int32Array.from([9,11,13]),2),ce.STRUCTURED_APPEND=new ce(hn.STRUCTURED_APPEND,"STRUCTURED_APPEND",Int32Array.from([0,0,0]),3),ce.BYTE=new ce(hn.BYTE,"BYTE",Int32Array.from([8,16,16]),4),ce.ECI=new ce(hn.ECI,"ECI",Int32Array.from([0,0,0]),7),ce.KANJI=new ce(hn.KANJI,"KANJI",Int32Array.from([8,10,12]),8),ce.FNC1_FIRST_POSITION=new ce(hn.FNC1_FIRST_POSITION,"FNC1_FIRST_POSITION",Int32Array.from([0,0,0]),5),ce.FNC1_SECOND_POSITION=new ce(hn.FNC1_SECOND_POSITION,"FNC1_SECOND_POSITION",Int32Array.from([0,0,0]),9),ce.HANZI=new ce(hn.HANZI,"HANZI",Int32Array.from([8,10,12]),13);class Qe{static decode(n,r,s,o){const a=new qa(n);let u=new ge;const d=new Array;let h=-1,g=-1;try{let x=null,E=!1,A;do{if(a.available()<4)A=ce.TERMINATOR;else{const I=a.readBits(4);A=ce.forBits(I)}switch(A){case ce.TERMINATOR:break;case ce.FNC1_FIRST_POSITION:case ce.FNC1_SECOND_POSITION:E=!0;break;case ce.STRUCTURED_APPEND:if(a.available()<16)throw new k;h=a.readBits(8),g=a.readBits(8);break;case ce.ECI:const I=Qe.parseECIValue(a);if(x=V.getCharacterSetECIByValue(I),x===null)throw new k;break;case ce.HANZI:const b=a.readBits(4),D=a.readBits(A.getCharacterCountBits(r));b===Qe.GB2312_SUBSET&&Qe.decodeHanziSegment(a,u,D);break;default:const L=a.readBits(A.getCharacterCountBits(r));switch(A){case ce.NUMERIC:Qe.decodeNumericSegment(a,u,L);break;case ce.ALPHANUMERIC:Qe.decodeAlphanumericSegment(a,u,L,E);break;case ce.BYTE:Qe.decodeByteSegment(a,u,L,x,d,o);break;case ce.KANJI:Qe.decodeKanjiSegment(a,u,L);break;default:throw new k}break}}while(A!==ce.TERMINATOR)}catch{throw new k}return new Qi(n,u.toString(),d.length===0?null:d,s===null?null:s.toString(),h,g)}static decodeHanziSegment(n,r,s){if(s*13>n.available())throw new k;const o=new Uint8Array(2*s);let a=0;for(;s>0;){const u=n.readBits(13);let d=u/96<<8&4294967295|u%96;d<959?d+=41377:d+=42657,o[a]=d>>8&255,o[a+1]=d&255,a+=2,s--}try{r.append(Ee.decode(o,ie.GB2312))}catch(u){throw new k(u)}}static decodeKanjiSegment(n,r,s){if(s*13>n.available())throw new k;const o=new Uint8Array(2*s);let a=0;for(;s>0;){const u=n.readBits(13);let d=u/192<<8&4294967295|u%192;d<7936?d+=33088:d+=49472,o[a]=d>>8,o[a+1]=d,a+=2,s--}try{r.append(Ee.decode(o,ie.SHIFT_JIS))}catch(u){throw new k(u)}}static decodeByteSegment(n,r,s,o,a,u){if(8*s>n.available())throw new k;const d=new Uint8Array(s);for(let g=0;g<s;g++)d[g]=n.readBits(8);let h;o===null?h=ie.guessEncoding(d,u):h=o.getName();try{r.append(Ee.decode(d,h))}catch(g){throw new k(g)}a.push(d)}static toAlphaNumericChar(n){if(n>=Qe.ALPHANUMERIC_CHARS.length)throw new k;return Qe.ALPHANUMERIC_CHARS[n]}static decodeAlphanumericSegment(n,r,s,o){const a=r.length();for(;s>1;){if(n.available()<11)throw new k;const u=n.readBits(11);r.append(Qe.toAlphaNumericChar(Math.floor(u/45))),r.append(Qe.toAlphaNumericChar(u%45)),s-=2}if(s===1){if(n.available()<6)throw new k;r.append(Qe.toAlphaNumericChar(n.readBits(6)))}if(o)for(let u=a;u<r.length();u++)r.charAt(u)==="%"&&(u<r.length()-1&&r.charAt(u+1)==="%"?r.deleteCharAt(u+1):r.setCharAt(u,""))}static decodeNumericSegment(n,r,s){for(;s>=3;){if(n.available()<10)throw new k;const o=n.readBits(10);if(o>=1e3)throw new k;r.append(Qe.toAlphaNumericChar(Math.floor(o/100))),r.append(Qe.toAlphaNumericChar(Math.floor(o/10)%10)),r.append(Qe.toAlphaNumericChar(o%10)),s-=3}if(s===2){if(n.available()<7)throw new k;const o=n.readBits(7);if(o>=100)throw new k;r.append(Qe.toAlphaNumericChar(Math.floor(o/10))),r.append(Qe.toAlphaNumericChar(o%10))}else if(s===1){if(n.available()<4)throw new k;const o=n.readBits(4);if(o>=10)throw new k;r.append(Qe.toAlphaNumericChar(o))}}static parseECIValue(n){const r=n.readBits(8);if(!(r&128))return r&127;if((r&192)===128){const s=n.readBits(8);return(r&63)<<8&4294967295|s}if((r&224)===192){const s=n.readBits(16);return(r&31)<<16&4294967295|s}throw new k}}Qe.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Qe.GB2312_SUBSET=1;class n1{constructor(n){this.mirrored=n}isMirrored(){return this.mirrored}applyMirroredCorrection(n){if(!this.mirrored||n===null||n.length<3)return;const r=n[0];n[0]=n[2],n[2]=r}}class Fh{constructor(){this.rsDecoder=new $i(be.QR_CODE_FIELD_256)}decodeBooleanArray(n,r){return this.decodeBitMatrix(_e.parseFromBooleanArray(n),r)}decodeBitMatrix(n,r){const s=new Lh(n);let o=null;try{return this.decodeBitMatrixParser(s,r)}catch(a){o=a}try{s.remask(),s.setMirror(!0),s.readVersion(),s.readFormatInformation(),s.mirror();const a=this.decodeBitMatrixParser(s,r);return a.setOther(new n1(!0)),a}catch(a){throw o!==null?o:a}}decodeBitMatrixParser(n,r){const s=n.readVersion(),o=n.readFormatInformation().getErrorCorrectionLevel(),a=n.readCodewords(),u=$a.getDataBlocks(a,s,o);let d=0;for(const x of u)d+=x.getNumDataCodewords();const h=new Uint8Array(d);let g=0;for(const x of u){const E=x.getCodewords(),A=x.getNumDataCodewords();this.correctErrors(E,A);for(let I=0;I<A;I++)h[g++]=E[I]}return Qe.decode(h,s,o,r)}correctErrors(n,r){const s=new Int32Array(n);try{this.rsDecoder.decode(s,n.length-r)}catch{throw new M}for(let o=0;o<r;o++)n[o]=s[o]}}class Ja extends oe{constructor(n,r,s){super(n,r),this.estimatedModuleSize=s}aboutEquals(n,r,s){if(Math.abs(r-this.getY())<=n&&Math.abs(s-this.getX())<=n){const o=Math.abs(n-this.estimatedModuleSize);return o<=1||o<=this.estimatedModuleSize}return!1}combineEstimate(n,r,s){const o=(this.getX()+r)/2,a=(this.getY()+n)/2,u=(this.estimatedModuleSize+s)/2;return new Ja(o,a,u)}}class fo{constructor(n,r,s,o,a,u,d){this.image=n,this.startX=r,this.startY=s,this.width=o,this.height=a,this.moduleSize=u,this.resultPointCallback=d,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(3)}find(){const n=this.startX,r=this.height,s=this.width,o=n+s,a=this.startY+r/2,u=new Int32Array(3),d=this.image;for(let h=0;h<r;h++){const g=a+(h&1?-Math.floor((h+1)/2):Math.floor((h+1)/2));u[0]=0,u[1]=0,u[2]=0;let x=n;for(;x<o&&!d.get(x,g);)x++;let E=0;for(;x<o;){if(d.get(x,g))if(E===1)u[1]++;else if(E===2){if(this.foundPatternCross(u)){const A=this.handlePossibleCenter(u,g,x);if(A!==null)return A}u[0]=u[2],u[1]=1,u[2]=0,E=1}else u[++E]++;else E===1&&E++,u[E]++;x++}if(this.foundPatternCross(u)){const A=this.handlePossibleCenter(u,g,o);if(A!==null)return A}}if(this.possibleCenters.length!==0)return this.possibleCenters[0];throw new j}static centerFromEnd(n,r){return r-n[2]-n[1]/2}foundPatternCross(n){const r=this.moduleSize,s=r/2;for(let o=0;o<3;o++)if(Math.abs(r-n[o])>=s)return!1;return!0}crossCheckVertical(n,r,s,o){const a=this.image,u=a.getHeight(),d=this.crossCheckStateCount;d[0]=0,d[1]=0,d[2]=0;let h=n;for(;h>=0&&a.get(r,h)&&d[1]<=s;)d[1]++,h--;if(h<0||d[1]>s)return NaN;for(;h>=0&&!a.get(r,h)&&d[0]<=s;)d[0]++,h--;if(d[0]>s)return NaN;for(h=n+1;h<u&&a.get(r,h)&&d[1]<=s;)d[1]++,h++;if(h===u||d[1]>s)return NaN;for(;h<u&&!a.get(r,h)&&d[2]<=s;)d[2]++,h++;if(d[2]>s)return NaN;const g=d[0]+d[1]+d[2];return 5*Math.abs(g-o)>=2*o?NaN:this.foundPatternCross(d)?fo.centerFromEnd(d,h):NaN}handlePossibleCenter(n,r,s){const o=n[0]+n[1]+n[2],a=fo.centerFromEnd(n,s),u=this.crossCheckVertical(r,a,2*n[1],o);if(!isNaN(u)){const d=(n[0]+n[1]+n[2])/3;for(const g of this.possibleCenters)if(g.aboutEquals(d,u,a))return g.combineEstimate(u,a,d);const h=new Ja(a,u,d);this.possibleCenters.push(h),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(h)}return null}}class el extends oe{constructor(n,r,s,o){super(n,r),this.estimatedModuleSize=s,this.count=o,o===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(n,r,s){if(Math.abs(r-this.getY())<=n&&Math.abs(s-this.getX())<=n){const o=Math.abs(n-this.estimatedModuleSize);return o<=1||o<=this.estimatedModuleSize}return!1}combineEstimate(n,r,s){const o=this.count+1,a=(this.count*this.getX()+r)/o,u=(this.count*this.getY()+n)/o,d=(this.count*this.estimatedModuleSize+s)/o;return new el(a,u,d,o)}}class Uh{constructor(n){this.bottomLeft=n[0],this.topLeft=n[1],this.topRight=n[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class yt{constructor(n,r){this.image=n,this.resultPointCallback=r,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=r}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(n){const r=n!=null&&n.get(U.TRY_HARDER)!==void 0,s=n!=null&&n.get(U.PURE_BARCODE)!==void 0,o=this.image,a=o.getHeight(),u=o.getWidth();let d=Math.floor(3*a/(4*yt.MAX_MODULES));(d<yt.MIN_SKIP||r)&&(d=yt.MIN_SKIP);let h=!1;const g=new Int32Array(5);for(let E=d-1;E<a&&!h;E+=d){g[0]=0,g[1]=0,g[2]=0,g[3]=0,g[4]=0;let A=0;for(let I=0;I<u;I++)if(o.get(I,E))(A&1)===1&&A++,g[A]++;else if(A&1)g[A]++;else if(A===4)if(yt.foundPatternCross(g)){if(this.handlePossibleCenter(g,E,I,s)===!0)if(d=2,this.hasSkipped===!0)h=this.haveMultiplyConfirmedCenters();else{const D=this.findRowSkip();D>g[2]&&(E+=D-g[2]-d,I=u-1)}else{g[0]=g[2],g[1]=g[3],g[2]=g[4],g[3]=1,g[4]=0,A=3;continue}A=0,g[0]=0,g[1]=0,g[2]=0,g[3]=0,g[4]=0}else g[0]=g[2],g[1]=g[3],g[2]=g[4],g[3]=1,g[4]=0,A=3;else g[++A]++;yt.foundPatternCross(g)&&this.handlePossibleCenter(g,E,u,s)===!0&&(d=g[0],this.hasSkipped&&(h=this.haveMultiplyConfirmedCenters()))}const x=this.selectBestPatterns();return oe.orderBestPatterns(x),new Uh(x)}static centerFromEnd(n,r){return r-n[4]-n[3]-n[2]/2}static foundPatternCross(n){let r=0;for(let a=0;a<5;a++){const u=n[a];if(u===0)return!1;r+=u}if(r<7)return!1;const s=r/7,o=s/2;return Math.abs(s-n[0])<o&&Math.abs(s-n[1])<o&&Math.abs(3*s-n[2])<3*o&&Math.abs(s-n[3])<o&&Math.abs(s-n[4])<o}getCrossCheckStateCount(){const n=this.crossCheckStateCount;return n[0]=0,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n}crossCheckDiagonal(n,r,s,o){const a=this.getCrossCheckStateCount();let u=0;const d=this.image;for(;n>=u&&r>=u&&d.get(r-u,n-u);)a[2]++,u++;if(n<u||r<u)return!1;for(;n>=u&&r>=u&&!d.get(r-u,n-u)&&a[1]<=s;)a[1]++,u++;if(n<u||r<u||a[1]>s)return!1;for(;n>=u&&r>=u&&d.get(r-u,n-u)&&a[0]<=s;)a[0]++,u++;if(a[0]>s)return!1;const h=d.getHeight(),g=d.getWidth();for(u=1;n+u<h&&r+u<g&&d.get(r+u,n+u);)a[2]++,u++;if(n+u>=h||r+u>=g)return!1;for(;n+u<h&&r+u<g&&!d.get(r+u,n+u)&&a[3]<s;)a[3]++,u++;if(n+u>=h||r+u>=g||a[3]>=s)return!1;for(;n+u<h&&r+u<g&&d.get(r+u,n+u)&&a[4]<s;)a[4]++,u++;if(a[4]>=s)return!1;const x=a[0]+a[1]+a[2]+a[3]+a[4];return Math.abs(x-o)<2*o&&yt.foundPatternCross(a)}crossCheckVertical(n,r,s,o){const a=this.image,u=a.getHeight(),d=this.getCrossCheckStateCount();let h=n;for(;h>=0&&a.get(r,h);)d[2]++,h--;if(h<0)return NaN;for(;h>=0&&!a.get(r,h)&&d[1]<=s;)d[1]++,h--;if(h<0||d[1]>s)return NaN;for(;h>=0&&a.get(r,h)&&d[0]<=s;)d[0]++,h--;if(d[0]>s)return NaN;for(h=n+1;h<u&&a.get(r,h);)d[2]++,h++;if(h===u)return NaN;for(;h<u&&!a.get(r,h)&&d[3]<s;)d[3]++,h++;if(h===u||d[3]>=s)return NaN;for(;h<u&&a.get(r,h)&&d[4]<s;)d[4]++,h++;if(d[4]>=s)return NaN;const g=d[0]+d[1]+d[2]+d[3]+d[4];return 5*Math.abs(g-o)>=2*o?NaN:yt.foundPatternCross(d)?yt.centerFromEnd(d,h):NaN}crossCheckHorizontal(n,r,s,o){const a=this.image,u=a.getWidth(),d=this.getCrossCheckStateCount();let h=n;for(;h>=0&&a.get(h,r);)d[2]++,h--;if(h<0)return NaN;for(;h>=0&&!a.get(h,r)&&d[1]<=s;)d[1]++,h--;if(h<0||d[1]>s)return NaN;for(;h>=0&&a.get(h,r)&&d[0]<=s;)d[0]++,h--;if(d[0]>s)return NaN;for(h=n+1;h<u&&a.get(h,r);)d[2]++,h++;if(h===u)return NaN;for(;h<u&&!a.get(h,r)&&d[3]<s;)d[3]++,h++;if(h===u||d[3]>=s)return NaN;for(;h<u&&a.get(h,r)&&d[4]<s;)d[4]++,h++;if(d[4]>=s)return NaN;const g=d[0]+d[1]+d[2]+d[3]+d[4];return 5*Math.abs(g-o)>=o?NaN:yt.foundPatternCross(d)?yt.centerFromEnd(d,h):NaN}handlePossibleCenter(n,r,s,o){const a=n[0]+n[1]+n[2]+n[3]+n[4];let u=yt.centerFromEnd(n,s),d=this.crossCheckVertical(r,Math.floor(u),n[2],a);if(!isNaN(d)&&(u=this.crossCheckHorizontal(Math.floor(u),Math.floor(d),n[2],a),!isNaN(u)&&(!o||this.crossCheckDiagonal(Math.floor(d),Math.floor(u),n[2],a)))){const h=a/7;let g=!1;const x=this.possibleCenters;for(let E=0,A=x.length;E<A;E++){const I=x[E];if(I.aboutEquals(h,d,u)){x[E]=I.combineEstimate(d,u,h),g=!0;break}}if(!g){const E=new el(u,d,h);x.push(E),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(E)}return!0}return!1}findRowSkip(){if(this.possibleCenters.length<=1)return 0;let r=null;for(const s of this.possibleCenters)if(s.getCount()>=yt.CENTER_QUORUM)if(r==null)r=s;else return this.hasSkipped=!0,Math.floor((Math.abs(r.getX()-s.getX())-Math.abs(r.getY()-s.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let n=0,r=0;const s=this.possibleCenters.length;for(const u of this.possibleCenters)u.getCount()>=yt.CENTER_QUORUM&&(n++,r+=u.getEstimatedModuleSize());if(n<3)return!1;const o=r/s;let a=0;for(const u of this.possibleCenters)a+=Math.abs(u.getEstimatedModuleSize()-o);return a<=.05*r}selectBestPatterns(){const n=this.possibleCenters.length;if(n<3)throw new j;const r=this.possibleCenters;let s;if(n>3){let o=0,a=0;for(const h of this.possibleCenters){const g=h.getEstimatedModuleSize();o+=g,a+=g*g}s=o/n;let u=Math.sqrt(a/n-s*s);r.sort((h,g)=>{const x=Math.abs(g.getEstimatedModuleSize()-s),E=Math.abs(h.getEstimatedModuleSize()-s);return x<E?-1:x>E?1:0});const d=Math.max(.2*s,u);for(let h=0;h<r.length&&r.length>3;h++){const g=r[h];Math.abs(g.getEstimatedModuleSize()-s)>d&&(r.splice(h,1),h--)}}if(r.length>3){let o=0;for(const a of r)o+=a.getEstimatedModuleSize();s=o/r.length,r.sort((a,u)=>{if(u.getCount()===a.getCount()){const d=Math.abs(u.getEstimatedModuleSize()-s),h=Math.abs(a.getEstimatedModuleSize()-s);return d<h?1:d>h?-1:0}else return u.getCount()-a.getCount()}),r.splice(3)}return[r[0],r[1],r[2]]}}yt.CENTER_QUORUM=2,yt.MIN_SKIP=3,yt.MAX_MODULES=57;class es{constructor(n){this.image=n}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(n){this.resultPointCallback=n==null?null:n.get(U.NEED_RESULT_POINT_CALLBACK);const s=new yt(this.image,this.resultPointCallback).find(n);return this.processFinderPatternInfo(s)}processFinderPatternInfo(n){const r=n.getTopLeft(),s=n.getTopRight(),o=n.getBottomLeft(),a=this.calculateModuleSize(r,s,o);if(a<1)throw new j("No pattern found in proccess finder.");const u=es.computeDimension(r,s,o,a),d=le.getProvisionalVersionForDimension(u),h=d.getDimensionForVersion()-7;let g=null;if(d.getAlignmentPatternCenters().length>0){const I=s.getX()-r.getX()+o.getX(),b=s.getY()-r.getY()+o.getY(),D=1-3/h,L=Math.floor(r.getX()+D*(I-r.getX())),z=Math.floor(r.getY()+D*(b-r.getY()));for(let q=4;q<=16;q<<=1)try{g=this.findAlignmentInRegion(a,L,z,q);break}catch($){if(!($ instanceof j))throw $}}const x=es.createTransform(r,s,o,g,u),E=es.sampleGrid(this.image,x,u);let A;return g===null?A=[o,r,s]:A=[o,r,s,g],new oo(E,A)}static createTransform(n,r,s,o,a){const u=a-3.5;let d,h,g,x;return o!==null?(d=o.getX(),h=o.getY(),g=u-3,x=g):(d=r.getX()-n.getX()+s.getX(),h=r.getY()-n.getY()+s.getY(),g=u,x=u),Cn.quadrilateralToQuadrilateral(3.5,3.5,u,3.5,g,x,3.5,u,n.getX(),n.getY(),r.getX(),r.getY(),d,h,s.getX(),s.getY())}static sampleGrid(n,r,s){return sr.getInstance().sampleGridWithTransform(n,s,s,r)}static computeDimension(n,r,s,o){const a=Te.round(oe.distance(n,r)/o),u=Te.round(oe.distance(n,s)/o);let d=Math.floor((a+u)/2)+7;switch(d&3){case 0:d++;break;case 2:d--;break;case 3:throw new j("Dimensions could be not found.")}return d}calculateModuleSize(n,r,s){return(this.calculateModuleSizeOneWay(n,r)+this.calculateModuleSizeOneWay(n,s))/2}calculateModuleSizeOneWay(n,r){const s=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(n.getX()),Math.floor(n.getY()),Math.floor(r.getX()),Math.floor(r.getY())),o=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(r.getX()),Math.floor(r.getY()),Math.floor(n.getX()),Math.floor(n.getY()));return isNaN(s)?o/7:isNaN(o)?s/7:(s+o)/14}sizeOfBlackWhiteBlackRunBothWays(n,r,s,o){let a=this.sizeOfBlackWhiteBlackRun(n,r,s,o),u=1,d=n-(s-n);d<0?(u=n/(n-d),d=0):d>=this.image.getWidth()&&(u=(this.image.getWidth()-1-n)/(d-n),d=this.image.getWidth()-1);let h=Math.floor(r-(o-r)*u);return u=1,h<0?(u=r/(r-h),h=0):h>=this.image.getHeight()&&(u=(this.image.getHeight()-1-r)/(h-r),h=this.image.getHeight()-1),d=Math.floor(n+(d-n)*u),a+=this.sizeOfBlackWhiteBlackRun(n,r,d,h),a-1}sizeOfBlackWhiteBlackRun(n,r,s,o){const a=Math.abs(o-r)>Math.abs(s-n);if(a){let I=n;n=r,r=I,I=s,s=o,o=I}const u=Math.abs(s-n),d=Math.abs(o-r);let h=-u/2;const g=n<s?1:-1,x=r<o?1:-1;let E=0;const A=s+g;for(let I=n,b=r;I!==A;I+=g){const D=a?b:I,L=a?I:b;if(E===1===this.image.get(D,L)){if(E===2)return Te.distance(I,b,n,r);E++}if(h+=d,h>0){if(b===o)break;b+=x,h-=u}}return E===2?Te.distance(s+g,o,n,r):NaN}findAlignmentInRegion(n,r,s,o){const a=Math.floor(o*n),u=Math.max(0,r-a),d=Math.min(this.image.getWidth()-1,r+a);if(d-u<n*3)throw new j("Alignment top exceeds estimated module size.");const h=Math.max(0,s-a),g=Math.min(this.image.getHeight()-1,s+a);if(g-h<n*3)throw new j("Alignment bottom exceeds estimated module size.");return new fo(this.image,u,h,d-u,g-h,n,this.resultPointCallback).find()}}class ur{constructor(){this.decoder=new Fh}getDecoder(){return this.decoder}decode(n,r){let s,o;if(r!=null&&r.get(U.PURE_BARCODE)!==void 0){const h=ur.extractPureBits(n.getBlackMatrix());s=this.decoder.decodeBitMatrix(h,r),o=ur.NO_POINTS}else{const h=new es(n.getBlackMatrix()).detect(r);s=this.decoder.decodeBitMatrix(h.getBits(),r),o=h.getPoints()}s.getOther()instanceof n1&&s.getOther().applyMirroredCorrection(o);const a=new Ke(s.getText(),s.getRawBytes(),void 0,o,ae.QR_CODE,void 0),u=s.getByteSegments();u!==null&&a.putMetadata(mt.BYTE_SEGMENTS,u);const d=s.getECLevel();return d!==null&&a.putMetadata(mt.ERROR_CORRECTION_LEVEL,d),s.hasStructuredAppend()&&(a.putMetadata(mt.STRUCTURED_APPEND_SEQUENCE,s.getStructuredAppendSequenceNumber()),a.putMetadata(mt.STRUCTURED_APPEND_PARITY,s.getStructuredAppendParity())),a}reset(){}static extractPureBits(n){const r=n.getTopLeftOnBit(),s=n.getBottomRightOnBit();if(r===null||s===null)throw new j;const o=this.moduleSize(r,n);let a=r[1],u=s[1],d=r[0],h=s[0];if(d>=h||a>=u)throw new j;if(u-a!==h-d&&(h=d+(u-a),h>=n.getWidth()))throw new j;const g=Math.round((h-d+1)/o),x=Math.round((u-a+1)/o);if(g<=0||x<=0)throw new j;if(x!==g)throw new j;const E=Math.floor(o/2);a+=E,d+=E;const A=d+Math.floor((g-1)*o)-h;if(A>0){if(A>E)throw new j;d-=A}const I=a+Math.floor((x-1)*o)-u;if(I>0){if(I>E)throw new j;a-=I}const b=new _e(g,x);for(let D=0;D<x;D++){const L=a+Math.floor(D*o);for(let z=0;z<g;z++)n.get(d+Math.floor(z*o),L)&&b.set(z,D)}return b}static moduleSize(n,r){const s=r.getHeight(),o=r.getWidth();let a=n[0],u=n[1],d=!0,h=0;for(;a<o&&u<s;){if(d!==r.get(a,u)){if(++h===5)break;d=!d}a++,u++}if(a===o||u===s)throw new j;return(a-n[0])/7}}ur.NO_POINTS=new Array;class he{PDF417Common(){}static getBitCountSum(n){return Te.sum(n)}static toIntArray(n){if(n==null||!n.length)return he.EMPTY_INT_ARRAY;const r=new Int32Array(n.length);let s=0;for(const o of n)r[s++]=o;return r}static getCodeword(n){const r=T.binarySearch(he.SYMBOL_TABLE,n&262143);return r<0?-1:(he.CODEWORD_TABLE[r]-1)%he.NUMBER_OF_CODEWORDS}}he.NUMBER_OF_CODEWORDS=929,he.MAX_CODEWORDS_IN_BARCODE=he.NUMBER_OF_CODEWORDS-1,he.MIN_ROWS_IN_BARCODE=3,he.MAX_ROWS_IN_BARCODE=90,he.MODULES_IN_CODEWORD=17,he.MODULES_IN_STOP_PATTERN=18,he.BARS_IN_MODULE=8,he.EMPTY_INT_ARRAY=new Int32Array([]),he.SYMBOL_TABLE=Int32Array.from([66142,66170,66206,66236,66290,66292,66350,66382,66396,66454,66470,66476,66594,66600,66614,66626,66628,66632,66640,66654,66662,66668,66682,66690,66718,66720,66748,66758,66776,66798,66802,66804,66820,66824,66832,66846,66848,66876,66880,66936,66950,66956,66968,66992,67006,67022,67036,67042,67044,67048,67062,67118,67150,67164,67214,67228,67256,67294,67322,67350,67366,67372,67398,67404,67416,67438,67474,67476,67490,67492,67496,67510,67618,67624,67650,67656,67664,67678,67686,67692,67706,67714,67716,67728,67742,67744,67772,67782,67788,67800,67822,67826,67828,67842,67848,67870,67872,67900,67904,67960,67974,67992,68016,68030,68046,68060,68066,68068,68072,68086,68104,68112,68126,68128,68156,68160,68216,68336,68358,68364,68376,68400,68414,68448,68476,68494,68508,68536,68546,68548,68552,68560,68574,68582,68588,68654,68686,68700,68706,68708,68712,68726,68750,68764,68792,68802,68804,68808,68816,68830,68838,68844,68858,68878,68892,68920,68976,68990,68994,68996,69e3,69008,69022,69024,69052,69062,69068,69080,69102,69106,69108,69142,69158,69164,69190,69208,69230,69254,69260,69272,69296,69310,69326,69340,69386,69394,69396,69410,69416,69430,69442,69444,69448,69456,69470,69478,69484,69554,69556,69666,69672,69698,69704,69712,69726,69754,69762,69764,69776,69790,69792,69820,69830,69836,69848,69870,69874,69876,69890,69918,69920,69948,69952,70008,70022,70040,70064,70078,70094,70108,70114,70116,70120,70134,70152,70174,70176,70264,70384,70412,70448,70462,70496,70524,70542,70556,70584,70594,70600,70608,70622,70630,70636,70664,70672,70686,70688,70716,70720,70776,70896,71136,71180,71192,71216,71230,71264,71292,71360,71416,71452,71480,71536,71550,71554,71556,71560,71568,71582,71584,71612,71622,71628,71640,71662,71726,71732,71758,71772,71778,71780,71784,71798,71822,71836,71864,71874,71880,71888,71902,71910,71916,71930,71950,71964,71992,72048,72062,72066,72068,72080,72094,72096,72124,72134,72140,72152,72174,72178,72180,72206,72220,72248,72304,72318,72416,72444,72456,72464,72478,72480,72508,72512,72568,72588,72600,72624,72638,72654,72668,72674,72676,72680,72694,72726,72742,72748,72774,72780,72792,72814,72838,72856,72880,72894,72910,72924,72930,72932,72936,72950,72966,72972,72984,73008,73022,73056,73084,73102,73116,73144,73156,73160,73168,73182,73190,73196,73210,73226,73234,73236,73250,73252,73256,73270,73282,73284,73296,73310,73318,73324,73346,73348,73352,73360,73374,73376,73404,73414,73420,73432,73454,73498,73518,73522,73524,73550,73564,73570,73572,73576,73590,73800,73822,73858,73860,73872,73886,73888,73916,73944,73970,73972,73992,74014,74016,74044,74048,74104,74118,74136,74160,74174,74210,74212,74216,74230,74244,74256,74270,74272,74360,74480,74502,74508,74544,74558,74592,74620,74638,74652,74680,74690,74696,74704,74726,74732,74782,74784,74812,74992,75232,75288,75326,75360,75388,75456,75512,75576,75632,75646,75650,75652,75664,75678,75680,75708,75718,75724,75736,75758,75808,75836,75840,75896,76016,76256,76736,76824,76848,76862,76896,76924,76992,77048,77296,77340,77368,77424,77438,77536,77564,77572,77576,77584,77600,77628,77632,77688,77702,77708,77720,77744,77758,77774,77788,77870,77902,77916,77922,77928,77966,77980,78008,78018,78024,78032,78046,78060,78074,78094,78136,78192,78206,78210,78212,78224,78238,78240,78268,78278,78284,78296,78322,78324,78350,78364,78448,78462,78560,78588,78600,78622,78624,78652,78656,78712,78726,78744,78768,78782,78798,78812,78818,78820,78824,78838,78862,78876,78904,78960,78974,79072,79100,79296,79352,79368,79376,79390,79392,79420,79424,79480,79600,79628,79640,79664,79678,79712,79740,79772,79800,79810,79812,79816,79824,79838,79846,79852,79894,79910,79916,79942,79948,79960,79982,79988,80006,80024,80048,80062,80078,80092,80098,80100,80104,80134,80140,80176,80190,80224,80252,80270,80284,80312,80328,80336,80350,80358,80364,80378,80390,80396,80408,80432,80446,80480,80508,80576,80632,80654,80668,80696,80752,80766,80776,80784,80798,80800,80828,80844,80856,80878,80882,80884,80914,80916,80930,80932,80936,80950,80962,80968,80976,80990,80998,81004,81026,81028,81040,81054,81056,81084,81094,81100,81112,81134,81154,81156,81160,81168,81182,81184,81212,81216,81272,81286,81292,81304,81328,81342,81358,81372,81380,81384,81398,81434,81454,81458,81460,81486,81500,81506,81508,81512,81526,81550,81564,81592,81602,81604,81608,81616,81630,81638,81644,81702,81708,81722,81734,81740,81752,81774,81778,81780,82050,82078,82080,82108,82180,82184,82192,82206,82208,82236,82240,82296,82316,82328,82352,82366,82402,82404,82408,82440,82448,82462,82464,82492,82496,82552,82672,82694,82700,82712,82736,82750,82784,82812,82830,82882,82884,82888,82896,82918,82924,82952,82960,82974,82976,83004,83008,83064,83184,83424,83468,83480,83504,83518,83552,83580,83648,83704,83740,83768,83824,83838,83842,83844,83848,83856,83872,83900,83910,83916,83928,83950,83984,84e3,84028,84032,84088,84208,84448,84928,85040,85054,85088,85116,85184,85240,85488,85560,85616,85630,85728,85756,85764,85768,85776,85790,85792,85820,85824,85880,85894,85900,85912,85936,85966,85980,86048,86080,86136,86256,86496,86976,88160,88188,88256,88312,88560,89056,89200,89214,89312,89340,89536,89592,89608,89616,89632,89664,89720,89840,89868,89880,89904,89952,89980,89998,90012,90040,90190,90204,90254,90268,90296,90306,90308,90312,90334,90382,90396,90424,90480,90494,90500,90504,90512,90526,90528,90556,90566,90572,90584,90610,90612,90638,90652,90680,90736,90750,90848,90876,90884,90888,90896,90910,90912,90940,90944,91e3,91014,91020,91032,91056,91070,91086,91100,91106,91108,91112,91126,91150,91164,91192,91248,91262,91360,91388,91584,91640,91664,91678,91680,91708,91712,91768,91888,91928,91952,91966,92e3,92028,92046,92060,92088,92098,92100,92104,92112,92126,92134,92140,92188,92216,92272,92384,92412,92608,92664,93168,93200,93214,93216,93244,93248,93304,93424,93664,93720,93744,93758,93792,93820,93888,93944,93980,94008,94064,94078,94084,94088,94096,94110,94112,94140,94150,94156,94168,94246,94252,94278,94284,94296,94318,94342,94348,94360,94384,94398,94414,94428,94440,94470,94476,94488,94512,94526,94560,94588,94606,94620,94648,94658,94660,94664,94672,94686,94694,94700,94714,94726,94732,94744,94768,94782,94816,94844,94912,94968,94990,95004,95032,95088,95102,95112,95120,95134,95136,95164,95180,95192,95214,95218,95220,95244,95256,95280,95294,95328,95356,95424,95480,95728,95758,95772,95800,95856,95870,95968,95996,96008,96016,96030,96032,96060,96064,96120,96152,96176,96190,96220,96226,96228,96232,96290,96292,96296,96310,96322,96324,96328,96336,96350,96358,96364,96386,96388,96392,96400,96414,96416,96444,96454,96460,96472,96494,96498,96500,96514,96516,96520,96528,96542,96544,96572,96576,96632,96646,96652,96664,96688,96702,96718,96732,96738,96740,96744,96758,96772,96776,96784,96798,96800,96828,96832,96888,97008,97030,97036,97048,97072,97086,97120,97148,97166,97180,97208,97220,97224,97232,97246,97254,97260,97326,97330,97332,97358,97372,97378,97380,97384,97398,97422,97436,97464,97474,97476,97480,97488,97502,97510,97516,97550,97564,97592,97648,97666,97668,97672,97680,97694,97696,97724,97734,97740,97752,97774,97830,97836,97850,97862,97868,97880,97902,97906,97908,97926,97932,97944,97968,97998,98012,98018,98020,98024,98038,98618,98674,98676,98838,98854,98874,98892,98904,98926,98930,98932,98968,99006,99042,99044,99048,99062,99166,99194,99246,99286,99350,99366,99372,99386,99398,99416,99438,99442,99444,99462,99504,99518,99534,99548,99554,99556,99560,99574,99590,99596,99608,99632,99646,99680,99708,99726,99740,99768,99778,99780,99784,99792,99806,99814,99820,99834,99858,99860,99874,99880,99894,99906,99920,99934,99962,99970,99972,99976,99984,99998,1e5,100028,100038,100044,100056,100078,100082,100084,100142,100174,100188,100246,100262,100268,100306,100308,100390,100396,100410,100422,100428,100440,100462,100466,100468,100486,100504,100528,100542,100558,100572,100578,100580,100584,100598,100620,100656,100670,100704,100732,100750,100792,100802,100808,100816,100830,100838,100844,100858,100888,100912,100926,100960,100988,101056,101112,101148,101176,101232,101246,101250,101252,101256,101264,101278,101280,101308,101318,101324,101336,101358,101362,101364,101410,101412,101416,101430,101442,101448,101456,101470,101478,101498,101506,101508,101520,101534,101536,101564,101580,101618,101620,101636,101640,101648,101662,101664,101692,101696,101752,101766,101784,101838,101858,101860,101864,101934,101938,101940,101966,101980,101986,101988,101992,102030,102044,102072,102082,102084,102088,102096,102138,102166,102182,102188,102214,102220,102232,102254,102282,102290,102292,102306,102308,102312,102326,102444,102458,102470,102476,102488,102514,102516,102534,102552,102576,102590,102606,102620,102626,102632,102646,102662,102668,102704,102718,102752,102780,102798,102812,102840,102850,102856,102864,102878,102886,102892,102906,102936,102974,103008,103036,103104,103160,103224,103280,103294,103298,103300,103312,103326,103328,103356,103366,103372,103384,103406,103410,103412,103472,103486,103520,103548,103616,103672,103920,103992,104048,104062,104160,104188,104194,104196,104200,104208,104224,104252,104256,104312,104326,104332,104344,104368,104382,104398,104412,104418,104420,104424,104482,104484,104514,104520,104528,104542,104550,104570,104578,104580,104592,104606,104608,104636,104652,104690,104692,104706,104712,104734,104736,104764,104768,104824,104838,104856,104910,104930,104932,104936,104968,104976,104990,104992,105020,105024,105080,105200,105240,105278,105312,105372,105410,105412,105416,105424,105446,105518,105524,105550,105564,105570,105572,105576,105614,105628,105656,105666,105672,105680,105702,105722,105742,105756,105784,105840,105854,105858,105860,105864,105872,105888,105932,105970,105972,106006,106022,106028,106054,106060,106072,106100,106118,106124,106136,106160,106174,106190,106210,106212,106216,106250,106258,106260,106274,106276,106280,106306,106308,106312,106320,106334,106348,106394,106414,106418,106420,106566,106572,106610,106612,106630,106636,106648,106672,106686,106722,106724,106728,106742,106758,106764,106776,106800,106814,106848,106876,106894,106908,106936,106946,106948,106952,106960,106974,106982,106988,107032,107056,107070,107104,107132,107200,107256,107292,107320,107376,107390,107394,107396,107400,107408,107422,107424,107452,107462,107468,107480,107502,107506,107508,107544,107568,107582,107616,107644,107712,107768,108016,108060,108088,108144,108158,108256,108284,108290,108292,108296,108304,108318,108320,108348,108352,108408,108422,108428,108440,108464,108478,108494,108508,108514,108516,108520,108592,108640,108668,108736,108792,109040,109536,109680,109694,109792,109820,110016,110072,110084,110088,110096,110112,110140,110144,110200,110320,110342,110348,110360,110384,110398,110432,110460,110478,110492,110520,110532,110536,110544,110558,110658,110686,110714,110722,110724,110728,110736,110750,110752,110780,110796,110834,110836,110850,110852,110856,110864,110878,110880,110908,110912,110968,110982,111e3,111054,111074,111076,111080,111108,111112,111120,111134,111136,111164,111168,111224,111344,111372,111422,111456,111516,111554,111556,111560,111568,111590,111632,111646,111648,111676,111680,111736,111856,112096,112152,112224,112252,112320,112440,112514,112516,112520,112528,112542,112544,112588,112686,112718,112732,112782,112796,112824,112834,112836,112840,112848,112870,112890,112910,112924,112952,113008,113022,113026,113028,113032,113040,113054,113056,113100,113138,113140,113166,113180,113208,113264,113278,113376,113404,113416,113424,113440,113468,113472,113560,113614,113634,113636,113640,113686,113702,113708,113734,113740,113752,113778,113780,113798,113804,113816,113840,113854,113870,113890,113892,113896,113926,113932,113944,113968,113982,114016,114044,114076,114114,114116,114120,114128,114150,114170,114194,114196,114210,114212,114216,114242,114244,114248,114256,114270,114278,114306,114308,114312,114320,114334,114336,114364,114380,114420,114458,114478,114482,114484,114510,114524,114530,114532,114536,114842,114866,114868,114970,114994,114996,115042,115044,115048,115062,115130,115226,115250,115252,115278,115292,115298,115300,115304,115318,115342,115394,115396,115400,115408,115422,115430,115436,115450,115478,115494,115514,115526,115532,115570,115572,115738,115758,115762,115764,115790,115804,115810,115812,115816,115830,115854,115868,115896,115906,115912,115920,115934,115942,115948,115962,115996,116024,116080,116094,116098,116100,116104,116112,116126,116128,116156,116166,116172,116184,116206,116210,116212,116246,116262,116268,116282,116294,116300,116312,116334,116338,116340,116358,116364,116376,116400,116414,116430,116444,116450,116452,116456,116498,116500,116514,116520,116534,116546,116548,116552,116560,116574,116582,116588,116602,116654,116694,116714,116762,116782,116786,116788,116814,116828,116834,116836,116840,116854,116878,116892,116920,116930,116936,116944,116958,116966,116972,116986,117006,117048,117104,117118,117122,117124,117136,117150,117152,117180,117190,117196,117208,117230,117234,117236,117304,117360,117374,117472,117500,117506,117508,117512,117520,117536,117564,117568,117624,117638,117644,117656,117680,117694,117710,117724,117730,117732,117736,117750,117782,117798,117804,117818,117830,117848,117874,117876,117894,117936,117950,117966,117986,117988,117992,118022,118028,118040,118064,118078,118112,118140,118172,118210,118212,118216,118224,118238,118246,118266,118306,118312,118338,118352,118366,118374,118394,118402,118404,118408,118416,118430,118432,118460,118476,118514,118516,118574,118578,118580,118606,118620,118626,118628,118632,118678,118694,118700,118730,118738,118740,118830,118834,118836,118862,118876,118882,118884,118888,118902,118926,118940,118968,118978,118980,118984,118992,119006,119014,119020,119034,119068,119096,119152,119166,119170,119172,119176,119184,119198,119200,119228,119238,119244,119256,119278,119282,119284,119324,119352,119408,119422,119520,119548,119554,119556,119560,119568,119582,119584,119612,119616,119672,119686,119692,119704,119728,119742,119758,119772,119778,119780,119784,119798,119920,119934,120032,120060,120256,120312,120324,120328,120336,120352,120384,120440,120560,120582,120588,120600,120624,120638,120672,120700,120718,120732,120760,120770,120772,120776,120784,120798,120806,120812,120870,120876,120890,120902,120908,120920,120946,120948,120966,120972,120984,121008,121022,121038,121058,121060,121064,121078,121100,121112,121136,121150,121184,121212,121244,121282,121284,121288,121296,121318,121338,121356,121368,121392,121406,121440,121468,121536,121592,121656,121730,121732,121736,121744,121758,121760,121804,121842,121844,121890,121922,121924,121928,121936,121950,121958,121978,121986,121988,121992,122e3,122014,122016,122044,122060,122098,122100,122116,122120,122128,122142,122144,122172,122176,122232,122246,122264,122318,122338,122340,122344,122414,122418,122420,122446,122460,122466,122468,122472,122510,122524,122552,122562,122564,122568,122576,122598,122618,122646,122662,122668,122694,122700,122712,122738,122740,122762,122770,122772,122786,122788,122792,123018,123026,123028,123042,123044,123048,123062,123098,123146,123154,123156,123170,123172,123176,123190,123202,123204,123208,123216,123238,123244,123258,123290,123314,123316,123402,123410,123412,123426,123428,123432,123446,123458,123464,123472,123486,123494,123500,123514,123522,123524,123528,123536,123552,123580,123590,123596,123608,123630,123634,123636,123674,123698,123700,123740,123746,123748,123752,123834,123914,123922,123924,123938,123944,123958,123970,123976,123984,123998,124006,124012,124026,124034,124036,124048,124062,124064,124092,124102,124108,124120,124142,124146,124148,124162,124164,124168,124176,124190,124192,124220,124224,124280,124294,124300,124312,124336,124350,124366,124380,124386,124388,124392,124406,124442,124462,124466,124468,124494,124508,124514,124520,124558,124572,124600,124610,124612,124616,124624,124646,124666,124694,124710,124716,124730,124742,124748,124760,124786,124788,124818,124820,124834,124836,124840,124854,124946,124948,124962,124964,124968,124982,124994,124996,125e3,125008,125022,125030,125036,125050,125058,125060,125064,125072,125086,125088,125116,125126,125132,125144,125166,125170,125172,125186,125188,125192,125200,125216,125244,125248,125304,125318,125324,125336,125360,125374,125390,125404,125410,125412,125416,125430,125444,125448,125456,125472,125504,125560,125680,125702,125708,125720,125744,125758,125792,125820,125838,125852,125880,125890,125892,125896,125904,125918,125926,125932,125978,125998,126002,126004,126030,126044,126050,126052,126056,126094,126108,126136,126146,126148,126152,126160,126182,126202,126222,126236,126264,126320,126334,126338,126340,126344,126352,126366,126368,126412,126450,126452,126486,126502,126508,126522,126534,126540,126552,126574,126578,126580,126598,126604,126616,126640,126654,126670,126684,126690,126692,126696,126738,126754,126756,126760,126774,126786,126788,126792,126800,126814,126822,126828,126842,126894,126898,126900,126934,127126,127142,127148,127162,127178,127186,127188,127254,127270,127276,127290,127302,127308,127320,127342,127346,127348,127370,127378,127380,127394,127396,127400,127450,127510,127526,127532,127546,127558,127576,127598,127602,127604,127622,127628,127640,127664,127678,127694,127708,127714,127716,127720,127734,127754,127762,127764,127778,127784,127810,127812,127816,127824,127838,127846,127866,127898,127918,127922,127924,128022,128038,128044,128058,128070,128076,128088,128110,128114,128116,128134,128140,128152,128176,128190,128206,128220,128226,128228,128232,128246,128262,128268,128280,128304,128318,128352,128380,128398,128412,128440,128450,128452,128456,128464,128478,128486,128492,128506,128522,128530,128532,128546,128548,128552,128566,128578,128580,128584,128592,128606,128614,128634,128642,128644,128648,128656,128670,128672,128700,128716,128754,128756,128794,128814,128818,128820,128846,128860,128866,128868,128872,128886,128918,128934,128940,128954,128978,128980,129178,129198,129202,129204,129238,129258,129306,129326,129330,129332,129358,129372,129378,129380,129384,129398,129430,129446,129452,129466,129482,129490,129492,129562,129582,129586,129588,129614,129628,129634,129636,129640,129654,129678,129692,129720,129730,129732,129736,129744,129758,129766,129772,129814,129830,129836,129850,129862,129868,129880,129902,129906,129908,129930,129938,129940,129954,129956,129960,129974,130010]),he.CODEWORD_TABLE=Int32Array.from([2627,1819,2622,2621,1813,1812,2729,2724,2723,2779,2774,2773,902,896,908,868,865,861,859,2511,873,871,1780,835,2493,825,2491,842,837,844,1764,1762,811,810,809,2483,807,2482,806,2480,815,814,813,812,2484,817,816,1745,1744,1742,1746,2655,2637,2635,2626,2625,2623,2628,1820,2752,2739,2737,2728,2727,2725,2730,2785,2783,2778,2777,2775,2780,787,781,747,739,736,2413,754,752,1719,692,689,681,2371,678,2369,700,697,694,703,1688,1686,642,638,2343,631,2341,627,2338,651,646,643,2345,654,652,1652,1650,1647,1654,601,599,2322,596,2321,594,2319,2317,611,610,608,606,2324,603,2323,615,614,612,1617,1616,1614,1612,616,1619,1618,2575,2538,2536,905,901,898,909,2509,2507,2504,870,867,864,860,2512,875,872,1781,2490,2489,2487,2485,1748,836,834,832,830,2494,827,2492,843,841,839,845,1765,1763,2701,2676,2674,2653,2648,2656,2634,2633,2631,2629,1821,2638,2636,2770,2763,2761,2750,2745,2753,2736,2735,2733,2731,1848,2740,2738,2786,2784,591,588,576,569,566,2296,1590,537,534,526,2276,522,2274,545,542,539,548,1572,1570,481,2245,466,2242,462,2239,492,485,482,2249,496,494,1534,1531,1528,1538,413,2196,406,2191,2188,425,419,2202,415,2199,432,430,427,1472,1467,1464,433,1476,1474,368,367,2160,365,2159,362,2157,2155,2152,378,377,375,2166,372,2165,369,2162,383,381,379,2168,1419,1418,1416,1414,385,1411,384,1423,1422,1420,1424,2461,802,2441,2439,790,786,783,794,2409,2406,2403,750,742,738,2414,756,753,1720,2367,2365,2362,2359,1663,693,691,684,2373,680,2370,702,699,696,704,1690,1687,2337,2336,2334,2332,1624,2329,1622,640,637,2344,634,2342,630,2340,650,648,645,2346,655,653,1653,1651,1649,1655,2612,2597,2595,2571,2568,2565,2576,2534,2529,2526,1787,2540,2537,907,904,900,910,2503,2502,2500,2498,1768,2495,1767,2510,2508,2506,869,866,863,2513,876,874,1782,2720,2713,2711,2697,2694,2691,2702,2672,2670,2664,1828,2678,2675,2647,2646,2644,2642,1823,2639,1822,2654,2652,2650,2657,2771,1855,2765,2762,1850,1849,2751,2749,2747,2754,353,2148,344,342,336,2142,332,2140,345,1375,1373,306,2130,299,2128,295,2125,319,314,311,2132,1354,1352,1349,1356,262,257,2101,253,2096,2093,274,273,267,2107,263,2104,280,278,275,1316,1311,1308,1320,1318,2052,202,2050,2044,2040,219,2063,212,2060,208,2055,224,221,2066,1260,1258,1252,231,1248,229,1266,1264,1261,1268,155,1998,153,1996,1994,1991,1988,165,164,2007,162,2006,159,2003,2e3,172,171,169,2012,166,2010,1186,1184,1182,1179,175,1176,173,1192,1191,1189,1187,176,1194,1193,2313,2307,2305,592,589,2294,2292,2289,578,572,568,2297,580,1591,2272,2267,2264,1547,538,536,529,2278,525,2275,547,544,541,1574,1571,2237,2235,2229,1493,2225,1489,478,2247,470,2244,465,2241,493,488,484,2250,498,495,1536,1533,1530,1539,2187,2186,2184,2182,1432,2179,1430,2176,1427,414,412,2197,409,2195,405,2193,2190,426,424,421,2203,418,2201,431,429,1473,1471,1469,1466,434,1477,1475,2478,2472,2470,2459,2457,2454,2462,803,2437,2432,2429,1726,2443,2440,792,789,785,2401,2399,2393,1702,2389,1699,2411,2408,2405,745,741,2415,758,755,1721,2358,2357,2355,2353,1661,2350,1660,2347,1657,2368,2366,2364,2361,1666,690,687,2374,683,2372,701,698,705,1691,1689,2619,2617,2610,2608,2605,2613,2593,2588,2585,1803,2599,2596,2563,2561,2555,1797,2551,1795,2573,2570,2567,2577,2525,2524,2522,2520,1786,2517,1785,2514,1783,2535,2533,2531,2528,1788,2541,2539,906,903,911,2721,1844,2715,2712,1838,1836,2699,2696,2693,2703,1827,1826,1824,2673,2671,2669,2666,1829,2679,2677,1858,1857,2772,1854,1853,1851,1856,2766,2764,143,1987,139,1986,135,133,131,1984,128,1983,125,1981,138,137,136,1985,1133,1132,1130,112,110,1974,107,1973,104,1971,1969,122,121,119,117,1977,114,1976,124,1115,1114,1112,1110,1117,1116,84,83,1953,81,1952,78,1950,1948,1945,94,93,91,1959,88,1958,85,1955,99,97,95,1961,1086,1085,1083,1081,1078,100,1090,1089,1087,1091,49,47,1917,44,1915,1913,1910,1907,59,1926,56,1925,53,1922,1919,66,64,1931,61,1929,1042,1040,1038,71,1035,70,1032,68,1048,1047,1045,1043,1050,1049,12,10,1869,1867,1864,1861,21,1880,19,1877,1874,1871,28,1888,25,1886,22,1883,982,980,977,974,32,30,991,989,987,984,34,995,994,992,2151,2150,2147,2146,2144,356,355,354,2149,2139,2138,2136,2134,1359,343,341,338,2143,335,2141,348,347,346,1376,1374,2124,2123,2121,2119,1326,2116,1324,310,308,305,2131,302,2129,298,2127,320,318,316,313,2133,322,321,1355,1353,1351,1357,2092,2091,2089,2087,1276,2084,1274,2081,1271,259,2102,256,2100,252,2098,2095,272,269,2108,266,2106,281,279,277,1317,1315,1313,1310,282,1321,1319,2039,2037,2035,2032,1203,2029,1200,1197,207,2053,205,2051,201,2049,2046,2043,220,218,2064,215,2062,211,2059,228,226,223,2069,1259,1257,1254,232,1251,230,1267,1265,1263,2316,2315,2312,2311,2309,2314,2304,2303,2301,2299,1593,2308,2306,590,2288,2287,2285,2283,1578,2280,1577,2295,2293,2291,579,577,574,571,2298,582,581,1592,2263,2262,2260,2258,1545,2255,1544,2252,1541,2273,2271,2269,2266,1550,535,532,2279,528,2277,546,543,549,1575,1573,2224,2222,2220,1486,2217,1485,2214,1482,1479,2238,2236,2234,2231,1496,2228,1492,480,477,2248,473,2246,469,2243,490,487,2251,497,1537,1535,1532,2477,2476,2474,2479,2469,2468,2466,2464,1730,2473,2471,2453,2452,2450,2448,1729,2445,1728,2460,2458,2456,2463,805,804,2428,2427,2425,2423,1725,2420,1724,2417,1722,2438,2436,2434,2431,1727,2444,2442,793,791,788,795,2388,2386,2384,1697,2381,1696,2378,1694,1692,2402,2400,2398,2395,1703,2392,1701,2412,2410,2407,751,748,744,2416,759,757,1807,2620,2618,1806,1805,2611,2609,2607,2614,1802,1801,1799,2594,2592,2590,2587,1804,2600,2598,1794,1793,1791,1789,2564,2562,2560,2557,1798,2554,1796,2574,2572,2569,2578,1847,1846,2722,1843,1842,1840,1845,2716,2714,1835,1834,1832,1830,1839,1837,2700,2698,2695,2704,1817,1811,1810,897,862,1777,829,826,838,1760,1758,808,2481,1741,1740,1738,1743,2624,1818,2726,2776,782,740,737,1715,686,679,695,1682,1680,639,628,2339,647,644,1645,1643,1640,1648,602,600,597,595,2320,593,2318,609,607,604,1611,1610,1608,1606,613,1615,1613,2328,926,924,892,886,899,857,850,2505,1778,824,823,821,819,2488,818,2486,833,831,828,840,1761,1759,2649,2632,2630,2746,2734,2732,2782,2781,570,567,1587,531,527,523,540,1566,1564,476,467,463,2240,486,483,1524,1521,1518,1529,411,403,2192,399,2189,423,416,1462,1457,1454,428,1468,1465,2210,366,363,2158,360,2156,357,2153,376,373,370,2163,1410,1409,1407,1405,382,1402,380,1417,1415,1412,1421,2175,2174,777,774,771,784,732,725,722,2404,743,1716,676,674,668,2363,665,2360,685,1684,1681,626,624,622,2335,620,2333,617,2330,641,635,649,1646,1644,1642,2566,928,925,2530,2527,894,891,888,2501,2499,2496,858,856,854,851,1779,2692,2668,2665,2645,2643,2640,2651,2768,2759,2757,2744,2743,2741,2748,352,1382,340,337,333,1371,1369,307,300,296,2126,315,312,1347,1342,1350,261,258,250,2097,246,2094,271,268,264,1306,1301,1298,276,1312,1309,2115,203,2048,195,2045,191,2041,213,209,2056,1246,1244,1238,225,1234,222,1256,1253,1249,1262,2080,2079,154,1997,150,1995,147,1992,1989,163,160,2004,156,2001,1175,1174,1172,1170,1167,170,1164,167,1185,1183,1180,1177,174,1190,1188,2025,2024,2022,587,586,564,559,556,2290,573,1588,520,518,512,2268,508,2265,530,1568,1565,461,457,2233,450,2230,446,2226,479,471,489,1526,1523,1520,397,395,2185,392,2183,389,2180,2177,410,2194,402,422,1463,1461,1459,1456,1470,2455,799,2433,2430,779,776,773,2397,2394,2390,734,728,724,746,1717,2356,2354,2351,2348,1658,677,675,673,670,667,688,1685,1683,2606,2589,2586,2559,2556,2552,927,2523,2521,2518,2515,1784,2532,895,893,890,2718,2709,2707,2689,2687,2684,2663,2662,2660,2658,1825,2667,2769,1852,2760,2758,142,141,1139,1138,134,132,129,126,1982,1129,1128,1126,1131,113,111,108,105,1972,101,1970,120,118,115,1109,1108,1106,1104,123,1113,1111,82,79,1951,75,1949,72,1946,92,89,86,1956,1077,1076,1074,1072,98,1069,96,1084,1082,1079,1088,1968,1967,48,45,1916,42,1914,39,1911,1908,60,57,54,1923,50,1920,1031,1030,1028,1026,67,1023,65,1020,62,1041,1039,1036,1033,69,1046,1044,1944,1943,1941,11,9,1868,7,1865,1862,1859,20,1878,16,1875,13,1872,970,968,966,963,29,960,26,23,983,981,978,975,33,971,31,990,988,985,1906,1904,1902,993,351,2145,1383,331,330,328,326,2137,323,2135,339,1372,1370,294,293,291,289,2122,286,2120,283,2117,309,303,317,1348,1346,1344,245,244,242,2090,239,2088,236,2085,2082,260,2099,249,270,1307,1305,1303,1300,1314,189,2038,186,2036,183,2033,2030,2026,206,198,2047,194,216,1247,1245,1243,1240,227,1237,1255,2310,2302,2300,2286,2284,2281,565,563,561,558,575,1589,2261,2259,2256,2253,1542,521,519,517,514,2270,511,533,1569,1567,2223,2221,2218,2215,1483,2211,1480,459,456,453,2232,449,474,491,1527,1525,1522,2475,2467,2465,2451,2449,2446,801,800,2426,2424,2421,2418,1723,2435,780,778,775,2387,2385,2382,2379,1695,2375,1693,2396,735,733,730,727,749,1718,2616,2615,2604,2603,2601,2584,2583,2581,2579,1800,2591,2550,2549,2547,2545,1792,2542,1790,2558,929,2719,1841,2710,2708,1833,1831,2690,2688,2686,1815,1809,1808,1774,1756,1754,1737,1736,1734,1739,1816,1711,1676,1674,633,629,1638,1636,1633,1641,598,1605,1604,1602,1600,605,1609,1607,2327,887,853,1775,822,820,1757,1755,1584,524,1560,1558,468,464,1514,1511,1508,1519,408,404,400,1452,1447,1444,417,1458,1455,2208,364,361,358,2154,1401,1400,1398,1396,374,1393,371,1408,1406,1403,1413,2173,2172,772,726,723,1712,672,669,666,682,1678,1675,625,623,621,618,2331,636,632,1639,1637,1635,920,918,884,880,889,849,848,847,846,2497,855,852,1776,2641,2742,2787,1380,334,1367,1365,301,297,1340,1338,1335,1343,255,251,247,1296,1291,1288,265,1302,1299,2113,204,196,192,2042,1232,1230,1224,214,1220,210,1242,1239,1235,1250,2077,2075,151,148,1993,144,1990,1163,1162,1160,1158,1155,161,1152,157,1173,1171,1168,1165,168,1181,1178,2021,2020,2018,2023,585,560,557,1585,516,509,1562,1559,458,447,2227,472,1516,1513,1510,398,396,393,390,2181,386,2178,407,1453,1451,1449,1446,420,1460,2209,769,764,720,712,2391,729,1713,664,663,661,659,2352,656,2349,671,1679,1677,2553,922,919,2519,2516,885,883,881,2685,2661,2659,2767,2756,2755,140,1137,1136,130,127,1125,1124,1122,1127,109,106,102,1103,1102,1100,1098,116,1107,1105,1980,80,76,73,1947,1068,1067,1065,1063,90,1060,87,1075,1073,1070,1080,1966,1965,46,43,40,1912,36,1909,1019,1018,1016,1014,58,1011,55,1008,51,1029,1027,1024,1021,63,1037,1034,1940,1939,1937,1942,8,1866,4,1863,1,1860,956,954,952,949,946,17,14,969,967,964,961,27,957,24,979,976,972,1901,1900,1898,1896,986,1905,1903,350,349,1381,329,327,324,1368,1366,292,290,287,284,2118,304,1341,1339,1337,1345,243,240,237,2086,233,2083,254,1297,1295,1293,1290,1304,2114,190,187,184,2034,180,2031,177,2027,199,1233,1231,1229,1226,217,1223,1241,2078,2076,584,555,554,552,550,2282,562,1586,507,506,504,502,2257,499,2254,515,1563,1561,445,443,441,2219,438,2216,435,2212,460,454,475,1517,1515,1512,2447,798,797,2422,2419,770,768,766,2383,2380,2376,721,719,717,714,731,1714,2602,2582,2580,2548,2546,2543,923,921,2717,2706,2705,2683,2682,2680,1771,1752,1750,1733,1732,1731,1735,1814,1707,1670,1668,1631,1629,1626,1634,1599,1598,1596,1594,1603,1601,2326,1772,1753,1751,1581,1554,1552,1504,1501,1498,1509,1442,1437,1434,401,1448,1445,2206,1392,1391,1389,1387,1384,359,1399,1397,1394,1404,2171,2170,1708,1672,1669,619,1632,1630,1628,1773,1378,1363,1361,1333,1328,1336,1286,1281,1278,248,1292,1289,2111,1218,1216,1210,197,1206,193,1228,1225,1221,1236,2073,2071,1151,1150,1148,1146,152,1143,149,1140,145,1161,1159,1156,1153,158,1169,1166,2017,2016,2014,2019,1582,510,1556,1553,452,448,1506,1500,394,391,387,1443,1441,1439,1436,1450,2207,765,716,713,1709,662,660,657,1673,1671,916,914,879,878,877,882,1135,1134,1121,1120,1118,1123,1097,1096,1094,1092,103,1101,1099,1979,1059,1058,1056,1054,77,1051,74,1066,1064,1061,1071,1964,1963,1007,1006,1004,1002,999,41,996,37,1017,1015,1012,1009,52,1025,1022,1936,1935,1933,1938,942,940,938,935,932,5,2,955,953,950,947,18,943,15,965,962,958,1895,1894,1892,1890,973,1899,1897,1379,325,1364,1362,288,285,1334,1332,1330,241,238,234,1287,1285,1283,1280,1294,2112,188,185,181,178,2028,1219,1217,1215,1212,200,1209,1227,2074,2072,583,553,551,1583,505,503,500,513,1557,1555,444,442,439,436,2213,455,451,1507,1505,1502,796,763,762,760,767,711,710,708,706,2377,718,715,1710,2544,917,915,2681,1627,1597,1595,2325,1769,1749,1747,1499,1438,1435,2204,1390,1388,1385,1395,2169,2167,1704,1665,1662,1625,1623,1620,1770,1329,1282,1279,2109,1214,1207,1222,2068,2065,1149,1147,1144,1141,146,1157,1154,2013,2011,2008,2015,1579,1549,1546,1495,1487,1433,1431,1428,1425,388,1440,2205,1705,658,1667,1664,1119,1095,1093,1978,1057,1055,1052,1062,1962,1960,1005,1003,1e3,997,38,1013,1010,1932,1930,1927,1934,941,939,936,933,6,930,3,951,948,944,1889,1887,1884,1881,959,1893,1891,35,1377,1360,1358,1327,1325,1322,1331,1277,1275,1272,1269,235,1284,2110,1205,1204,1201,1198,182,1195,179,1213,2070,2067,1580,501,1551,1548,440,437,1497,1494,1490,1503,761,709,707,1706,913,912,2198,1386,2164,2161,1621,1766,2103,1208,2058,2054,1145,1142,2005,2002,1999,2009,1488,1429,1426,2200,1698,1659,1656,1975,1053,1957,1954,1001,998,1924,1921,1918,1928,937,934,931,1879,1876,1873,1870,945,1885,1882,1323,1273,1270,2105,1202,1199,1196,1211,2061,2057,1576,1543,1540,1484,1481,1478,1491,1700]);class Wh{constructor(n,r){this.bits=n,this.points=r}getBits(){return this.bits}getPoints(){return this.points}}class we{static detectMultiple(n,r,s){let o=n.getBlackMatrix(),a=we.detect(s,o);return a.length||(o=o.clone(),o.rotate180(),a=we.detect(s,o)),new Wh(o,a)}static detect(n,r){const s=new Array;let o=0,a=0,u=!1;for(;o<r.getHeight();){const d=we.findVertices(r,o,a);if(d[0]==null&&d[3]==null){if(!u)break;u=!1,a=0;for(const h of s)h[1]!=null&&(o=Math.trunc(Math.max(o,h[1].getY()))),h[3]!=null&&(o=Math.max(o,Math.trunc(h[3].getY())));o+=we.ROW_STEP;continue}if(u=!0,s.push(d),!n)break;d[2]!=null?(a=Math.trunc(d[2].getX()),o=Math.trunc(d[2].getY())):(a=Math.trunc(d[4].getX()),o=Math.trunc(d[4].getY()))}return s}static findVertices(n,r,s){const o=n.getHeight(),a=n.getWidth(),u=new Array(8);return we.copyToResult(u,we.findRowsWithPattern(n,o,a,r,s,we.START_PATTERN),we.INDEXES_START_PATTERN),u[4]!=null&&(s=Math.trunc(u[4].getX()),r=Math.trunc(u[4].getY())),we.copyToResult(u,we.findRowsWithPattern(n,o,a,r,s,we.STOP_PATTERN),we.INDEXES_STOP_PATTERN),u}static copyToResult(n,r,s){for(let o=0;o<s.length;o++)n[s[o]]=r[o]}static findRowsWithPattern(n,r,s,o,a,u){const d=new Array(4);let h=!1;const g=new Int32Array(u.length);for(;o<r;o+=we.ROW_STEP){let E=we.findGuardPattern(n,a,o,s,!1,u,g);if(E!=null){for(;o>0;){const A=we.findGuardPattern(n,a,--o,s,!1,u,g);if(A!=null)E=A;else{o++;break}}d[0]=new oe(E[0],o),d[1]=new oe(E[1],o),h=!0;break}}let x=o+1;if(h){let E=0,A=Int32Array.from([Math.trunc(d[0].getX()),Math.trunc(d[1].getX())]);for(;x<r;x++){const I=we.findGuardPattern(n,A[0],x,s,!1,u,g);if(I!=null&&Math.abs(A[0]-I[0])<we.MAX_PATTERN_DRIFT&&Math.abs(A[1]-I[1])<we.MAX_PATTERN_DRIFT)A=I,E=0;else{if(E>we.SKIPPED_ROW_COUNT_MAX)break;E++}}x-=E+1,d[2]=new oe(A[0],x),d[3]=new oe(A[1],x)}return x-o<we.BARCODE_MIN_HEIGHT&&T.fill(d,null),d}static findGuardPattern(n,r,s,o,a,u,d){T.fillWithin(d,0,d.length,0);let h=r,g=0;for(;n.get(h,s)&&h>0&&g++<we.MAX_PIXEL_DRIFT;)h--;let x=h,E=0,A=u.length;for(let I=a;x<o;x++)if(n.get(x,s)!==I)d[E]++;else{if(E===A-1){if(we.patternMatchVariance(d,u,we.MAX_INDIVIDUAL_VARIANCE)<we.MAX_AVG_VARIANCE)return new Int32Array([h,x]);h+=d[0]+d[1],B.arraycopy(d,2,d,0,E-1),d[E-1]=0,d[E]=0,E--}else E++;d[E]=1,I=!I}return E===A-1&&we.patternMatchVariance(d,u,we.MAX_INDIVIDUAL_VARIANCE)<we.MAX_AVG_VARIANCE?new Int32Array([h,x-1]):null}static patternMatchVariance(n,r,s){let o=n.length,a=0,u=0;for(let g=0;g<o;g++)a+=n[g],u+=r[g];if(a<u)return 1/0;let d=a/u;s*=d;let h=0;for(let g=0;g<o;g++){let x=n[g],E=r[g]*d,A=x>E?x-E:E-x;if(A>s)return 1/0;h+=A}return h/a}}we.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),we.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),we.MAX_AVG_VARIANCE=.42,we.MAX_INDIVIDUAL_VARIANCE=.8,we.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),we.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),we.MAX_PIXEL_DRIFT=3,we.MAX_PATTERN_DRIFT=5,we.SKIPPED_ROW_COUNT_MAX=25,we.ROW_STEP=5,we.BARCODE_MIN_HEIGHT=10;class St{constructor(n,r){if(r.length===0)throw new v;this.field=n;let s=r.length;if(s>1&&r[0]===0){let o=1;for(;o<s&&r[o]===0;)o++;o===s?this.coefficients=new Int32Array([0]):(this.coefficients=new Int32Array(s-o),B.arraycopy(r,o,this.coefficients,0,this.coefficients.length))}else this.coefficients=r}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(n){return this.coefficients[this.coefficients.length-1-n]}evaluateAt(n){if(n===0)return this.getCoefficient(0);if(n===1){let o=0;for(let a of this.coefficients)o=this.field.add(o,a);return o}let r=this.coefficients[0],s=this.coefficients.length;for(let o=1;o<s;o++)r=this.field.add(this.field.multiply(n,r),this.coefficients[o]);return r}add(n){if(!this.field.equals(n.field))throw new v("ModulusPolys do not have same ModulusGF field");if(this.isZero())return n;if(n.isZero())return this;let r=this.coefficients,s=n.coefficients;if(r.length>s.length){let u=r;r=s,s=u}let o=new Int32Array(s.length),a=s.length-r.length;B.arraycopy(s,0,o,0,a);for(let u=a;u<s.length;u++)o[u]=this.field.add(r[u-a],s[u]);return new St(this.field,o)}subtract(n){if(!this.field.equals(n.field))throw new v("ModulusPolys do not have same ModulusGF field");return n.isZero()?this:this.add(n.negative())}multiply(n){return n instanceof St?this.multiplyOther(n):this.multiplyScalar(n)}multiplyOther(n){if(!this.field.equals(n.field))throw new v("ModulusPolys do not have same ModulusGF field");if(this.isZero()||n.isZero())return new St(this.field,new Int32Array([0]));let r=this.coefficients,s=r.length,o=n.coefficients,a=o.length,u=new Int32Array(s+a-1);for(let d=0;d<s;d++){let h=r[d];for(let g=0;g<a;g++)u[d+g]=this.field.add(u[d+g],this.field.multiply(h,o[g]))}return new St(this.field,u)}negative(){let n=this.coefficients.length,r=new Int32Array(n);for(let s=0;s<n;s++)r[s]=this.field.subtract(0,this.coefficients[s]);return new St(this.field,r)}multiplyScalar(n){if(n===0)return new St(this.field,new Int32Array([0]));if(n===1)return this;let r=this.coefficients.length,s=new Int32Array(r);for(let o=0;o<r;o++)s[o]=this.field.multiply(this.coefficients[o],n);return new St(this.field,s)}multiplyByMonomial(n,r){if(n<0)throw new v;if(r===0)return new St(this.field,new Int32Array([0]));let s=this.coefficients.length,o=new Int32Array(s+n);for(let a=0;a<s;a++)o[a]=this.field.multiply(this.coefficients[a],r);return new St(this.field,o)}toString(){let n=new ge;for(let r=this.getDegree();r>=0;r--){let s=this.getCoefficient(r);s!==0&&(s<0?(n.append(" - "),s=-s):n.length()>0&&n.append(" + "),(r===0||s!==1)&&n.append(s),r!==0&&(r===1?n.append("x"):(n.append("x^"),n.append(r))))}return n.toString()}}class zh{add(n,r){return(n+r)%this.modulus}subtract(n,r){return(this.modulus+n-r)%this.modulus}exp(n){return this.expTable[n]}log(n){if(n===0)throw new v;return this.logTable[n]}inverse(n){if(n===0)throw new io;return this.expTable[this.modulus-this.logTable[n]-1]}multiply(n,r){return n===0||r===0?0:this.expTable[(this.logTable[n]+this.logTable[r])%(this.modulus-1)]}getSize(){return this.modulus}equals(n){return n===this}}class tl extends zh{constructor(n,r){super(),this.modulus=n,this.expTable=new Int32Array(n),this.logTable=new Int32Array(n);let s=1;for(let o=0;o<n;o++)this.expTable[o]=s,s=s*r%n;for(let o=0;o<n-1;o++)this.logTable[this.expTable[o]]=o;this.zero=new St(this,new Int32Array([0])),this.one=new St(this,new Int32Array([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(n,r){if(n<0)throw new v;if(r===0)return this.zero;let s=new Int32Array(n+1);return s[0]=r,new St(this,s)}}tl.PDF417_GF=new tl(he.NUMBER_OF_CODEWORDS,3);class r1{constructor(){this.field=tl.PDF417_GF}decode(n,r,s){let o=new St(this.field,n),a=new Int32Array(r),u=!1;for(let b=r;b>0;b--){let D=o.evaluateAt(this.field.exp(b));a[r-b]=D,D!==0&&(u=!0)}if(!u)return 0;let d=this.field.getOne();if(s!=null)for(const b of s){let D=this.field.exp(n.length-1-b),L=new St(this.field,new Int32Array([this.field.subtract(0,D),1]));d=d.multiply(L)}let h=new St(this.field,a),g=this.runEuclideanAlgorithm(this.field.buildMonomial(r,1),h,r),x=g[0],E=g[1],A=this.findErrorLocations(x),I=this.findErrorMagnitudes(E,x,A);for(let b=0;b<A.length;b++){let D=n.length-1-this.field.log(A[b]);if(D<0)throw M.getChecksumInstance();n[D]=this.field.subtract(n[D],I[b])}return A.length}runEuclideanAlgorithm(n,r,s){if(n.getDegree()<r.getDegree()){let A=n;n=r,r=A}let o=n,a=r,u=this.field.getZero(),d=this.field.getOne();for(;a.getDegree()>=Math.round(s/2);){let A=o,I=u;if(o=a,u=d,o.isZero())throw M.getChecksumInstance();a=A;let b=this.field.getZero(),D=o.getCoefficient(o.getDegree()),L=this.field.inverse(D);for(;a.getDegree()>=o.getDegree()&&!a.isZero();){let z=a.getDegree()-o.getDegree(),q=this.field.multiply(a.getCoefficient(a.getDegree()),L);b=b.add(this.field.buildMonomial(z,q)),a=a.subtract(o.multiplyByMonomial(z,q))}d=b.multiply(u).subtract(I).negative()}let h=d.getCoefficient(0);if(h===0)throw M.getChecksumInstance();let g=this.field.inverse(h),x=d.multiply(g),E=a.multiply(g);return[x,E]}findErrorLocations(n){let r=n.getDegree(),s=new Int32Array(r),o=0;for(let a=1;a<this.field.getSize()&&o<r;a++)n.evaluateAt(a)===0&&(s[o]=this.field.inverse(a),o++);if(o!==r)throw M.getChecksumInstance();return s}findErrorMagnitudes(n,r,s){let o=r.getDegree(),a=new Int32Array(o);for(let g=1;g<=o;g++)a[o-g]=this.field.multiply(g,r.getCoefficient(g));let u=new St(this.field,a),d=s.length,h=new Int32Array(d);for(let g=0;g<d;g++){let x=this.field.inverse(s[g]),E=this.field.subtract(0,n.evaluateAt(x)),A=this.field.inverse(u.evaluateAt(x));h[g]=this.field.multiply(E,A)}return h}}class Fr{constructor(n,r,s,o,a){n instanceof Fr?this.constructor_2(n):this.constructor_1(n,r,s,o,a)}constructor_1(n,r,s,o,a){const u=r==null||s==null,d=o==null||a==null;if(u&&d)throw new j;u?(r=new oe(0,o.getY()),s=new oe(0,a.getY())):d&&(o=new oe(n.getWidth()-1,r.getY()),a=new oe(n.getWidth()-1,s.getY())),this.image=n,this.topLeft=r,this.bottomLeft=s,this.topRight=o,this.bottomRight=a,this.minX=Math.trunc(Math.min(r.getX(),s.getX())),this.maxX=Math.trunc(Math.max(o.getX(),a.getX())),this.minY=Math.trunc(Math.min(r.getY(),o.getY())),this.maxY=Math.trunc(Math.max(s.getY(),a.getY()))}constructor_2(n){this.image=n.image,this.topLeft=n.getTopLeft(),this.bottomLeft=n.getBottomLeft(),this.topRight=n.getTopRight(),this.bottomRight=n.getBottomRight(),this.minX=n.getMinX(),this.maxX=n.getMaxX(),this.minY=n.getMinY(),this.maxY=n.getMaxY()}static merge(n,r){return n==null?r:r==null?n:new Fr(n.image,n.topLeft,n.bottomLeft,r.topRight,r.bottomRight)}addMissingRows(n,r,s){let o=this.topLeft,a=this.bottomLeft,u=this.topRight,d=this.bottomRight;if(n>0){let h=s?this.topLeft:this.topRight,g=Math.trunc(h.getY()-n);g<0&&(g=0);let x=new oe(h.getX(),g);s?o=x:u=x}if(r>0){let h=s?this.bottomLeft:this.bottomRight,g=Math.trunc(h.getY()+r);g>=this.image.getHeight()&&(g=this.image.getHeight()-1);let x=new oe(h.getX(),g);s?a=x:d=x}return new Fr(this.image,o,a,u,d)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class Vh{constructor(n,r,s,o){this.columnCount=n,this.errorCorrectionLevel=o,this.rowCountUpperPart=r,this.rowCountLowerPart=s,this.rowCount=r+s}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class ts{constructor(){this.buffer=""}static form(n,r){let s=-1;function o(u,d,h,g,x,E){if(u==="%%")return"%";if(r[++s]===void 0)return;u=g?parseInt(g.substr(1)):void 0;let A=x?parseInt(x.substr(1)):void 0,I;switch(E){case"s":I=r[s];break;case"c":I=r[s][0];break;case"f":I=parseFloat(r[s]).toFixed(u);break;case"p":I=parseFloat(r[s]).toPrecision(u);break;case"e":I=parseFloat(r[s]).toExponential(u);break;case"x":I=parseInt(r[s]).toString(A||16);break;case"d":I=parseFloat(parseInt(r[s],A||10).toPrecision(u)).toFixed(0);break}I=typeof I=="object"?JSON.stringify(I):(+I).toString(A);let b=parseInt(h),D=h&&h[0]+""=="0"?"0":" ";for(;I.length<b;)I=d!==void 0?I+D:D+I;return I}let a=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return n.replace(a,o)}format(n,...r){this.buffer+=ts.form(n,r)}toString(){return this.buffer}}class ns{constructor(n){this.boundingBox=new Fr(n),this.codewords=new Array(n.getMaxY()-n.getMinY()+1)}getCodewordNearby(n){let r=this.getCodeword(n);if(r!=null)return r;for(let s=1;s<ns.MAX_NEARBY_DISTANCE;s++){let o=this.imageRowToCodewordIndex(n)-s;if(o>=0&&(r=this.codewords[o],r!=null)||(o=this.imageRowToCodewordIndex(n)+s,o<this.codewords.length&&(r=this.codewords[o],r!=null)))return r}return null}imageRowToCodewordIndex(n){return n-this.boundingBox.getMinY()}setCodeword(n,r){this.codewords[this.imageRowToCodewordIndex(n)]=r}getCodeword(n){return this.codewords[this.imageRowToCodewordIndex(n)]}getBoundingBox(){return this.boundingBox}getCodewords(){return this.codewords}toString(){const n=new ts;let r=0;for(const s of this.codewords){if(s==null){n.format("%3d: | %n",r++);continue}n.format("%3d: %3d|%3d%n",r++,s.getRowNumber(),s.getValue())}return n.toString()}}ns.MAX_NEARBY_DISTANCE=5;class rs{constructor(){this.values=new Map}setValue(n){n=Math.trunc(n);let r=this.values.get(n);r==null&&(r=0),r++,this.values.set(n,r)}getValue(){let n=-1,r=new Array;for(const[s,o]of this.values.entries()){const a={getKey:()=>s,getValue:()=>o};a.getValue()>n?(n=a.getValue(),r=[],r.push(a.getKey())):a.getValue()===n&&r.push(a.getKey())}return he.toIntArray(r)}getConfidence(n){return this.values.get(n)}}class i1 extends ns{constructor(n,r){super(n),this._isLeft=r}setRowNumbers(){for(let n of this.getCodewords())n!=null&&n.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(n){let r=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(r,n);let s=this.getBoundingBox(),o=this._isLeft?s.getTopLeft():s.getTopRight(),a=this._isLeft?s.getBottomLeft():s.getBottomRight(),u=this.imageRowToCodewordIndex(Math.trunc(o.getY())),d=this.imageRowToCodewordIndex(Math.trunc(a.getY())),h=-1,g=1,x=0;for(let E=u;E<d;E++){if(r[E]==null)continue;let A=r[E],I=A.getRowNumber()-h;if(I===0)x++;else if(I===1)g=Math.max(g,x),x=1,h=A.getRowNumber();else if(I<0||A.getRowNumber()>=n.getRowCount()||I>E)r[E]=null;else{let b;g>2?b=(g-2)*I:b=I;let D=b>=E;for(let L=1;L<=b&&!D;L++)D=r[E-L]!=null;D?r[E]=null:(h=A.getRowNumber(),x=1)}}}getRowHeights(){let n=this.getBarcodeMetadata();if(n==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(n);let r=new Int32Array(n.getRowCount());for(let s of this.getCodewords())if(s!=null){let o=s.getRowNumber();if(o>=r.length)continue;r[o]++}return r}adjustIncompleteIndicatorColumnRowNumbers(n){let r=this.getBoundingBox(),s=this._isLeft?r.getTopLeft():r.getTopRight(),o=this._isLeft?r.getBottomLeft():r.getBottomRight(),a=this.imageRowToCodewordIndex(Math.trunc(s.getY())),u=this.imageRowToCodewordIndex(Math.trunc(o.getY())),d=this.getCodewords(),h=-1;for(let g=a;g<u;g++){if(d[g]==null)continue;let x=d[g];x.setRowNumberAsRowIndicatorColumn();let E=x.getRowNumber()-h;E===0||(E===1?h=x.getRowNumber():x.getRowNumber()>=n.getRowCount()?d[g]=null:h=x.getRowNumber())}}getBarcodeMetadata(){let n=this.getCodewords(),r=new rs,s=new rs,o=new rs,a=new rs;for(let d of n){if(d==null)continue;d.setRowNumberAsRowIndicatorColumn();let h=d.getValue()%30,g=d.getRowNumber();switch(this._isLeft||(g+=2),g%3){case 0:s.setValue(h*3+1);break;case 1:a.setValue(h/3),o.setValue(h%3);break;case 2:r.setValue(h+1);break}}if(r.getValue().length===0||s.getValue().length===0||o.getValue().length===0||a.getValue().length===0||r.getValue()[0]<1||s.getValue()[0]+o.getValue()[0]<he.MIN_ROWS_IN_BARCODE||s.getValue()[0]+o.getValue()[0]>he.MAX_ROWS_IN_BARCODE)return null;let u=new Vh(r.getValue()[0],s.getValue()[0],o.getValue()[0],a.getValue()[0]);return this.removeIncorrectCodewords(n,u),u}removeIncorrectCodewords(n,r){for(let s=0;s<n.length;s++){let o=n[s];if(n[s]==null)continue;let a=o.getValue()%30,u=o.getRowNumber();if(u>r.getRowCount()){n[s]=null;continue}switch(this._isLeft||(u+=2),u%3){case 0:a*3+1!==r.getRowCountUpperPart()&&(n[s]=null);break;case 1:(Math.trunc(a/3)!==r.getErrorCorrectionLevel()||a%3!==r.getRowCountLowerPart())&&(n[s]=null);break;case 2:a+1!==r.getColumnCount()&&(n[s]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+`
64
+ `,". ",", ",": ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}","CTRL_UL"],Ue.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class Te{constructor(){}static round(n){return n===NaN?0:n<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:n>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:n+(n<0?-.5:.5)|0}static distance(n,r,s,o){const a=n-s,u=r-o;return Math.sqrt(a*a+u*u)}static sum(n){let r=0;for(let s=0,o=n.length;s!==o;s++){const a=n[s];r+=a}return r}}class so{static floatToIntBits(n){return n}}so.MAX_VALUE=Number.MAX_SAFE_INTEGER;class oe{constructor(n,r){this.x=n,this.y=r}getX(){return this.x}getY(){return this.y}equals(n){if(n instanceof oe){const r=n;return this.x===r.x&&this.y===r.y}return!1}hashCode(){return 31*so.floatToIntBits(this.x)+so.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(n){const r=this.distance(n[0],n[1]),s=this.distance(n[1],n[2]),o=this.distance(n[0],n[2]);let a,u,d;if(s>=r&&s>=o?(u=n[0],a=n[1],d=n[2]):o>=s&&o>=r?(u=n[1],a=n[0],d=n[2]):(u=n[2],a=n[0],d=n[1]),this.crossProductZ(a,u,d)<0){const h=a;a=d,d=h}n[0]=a,n[1]=u,n[2]=d}static distance(n,r){return Te.distance(n.x,n.y,r.x,r.y)}static crossProductZ(n,r,s){const o=r.x,a=r.y;return(s.x-o)*(n.y-a)-(s.y-a)*(n.x-o)}}class oo{constructor(n,r){this.bits=n,this.points=r}getBits(){return this.bits}getPoints(){return this.points}}class Kc extends oo{constructor(n,r,s,o,a){super(n,r),this.compact=s,this.nbDatablocks=o,this.nbLayers=a}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class Gn{constructor(n,r,s,o){this.image=n,this.height=n.getHeight(),this.width=n.getWidth(),r==null&&(r=Gn.INIT_SIZE),s==null&&(s=n.getWidth()/2|0),o==null&&(o=n.getHeight()/2|0);const a=r/2|0;if(this.leftInit=s-a,this.rightInit=s+a,this.upInit=o-a,this.downInit=o+a,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new j}detect(){let n=this.leftInit,r=this.rightInit,s=this.upInit,o=this.downInit,a=!1,u=!0,d=!1,h=!1,g=!1,x=!1,E=!1;const A=this.width,I=this.height;for(;u;){u=!1;let b=!0;for(;(b||!h)&&r<A;)b=this.containsBlackPoint(s,o,r,!1),b?(r++,u=!0,h=!0):h||r++;if(r>=A){a=!0;break}let D=!0;for(;(D||!g)&&o<I;)D=this.containsBlackPoint(n,r,o,!0),D?(o++,u=!0,g=!0):g||o++;if(o>=I){a=!0;break}let L=!0;for(;(L||!x)&&n>=0;)L=this.containsBlackPoint(s,o,n,!1),L?(n--,u=!0,x=!0):x||n--;if(n<0){a=!0;break}let z=!0;for(;(z||!E)&&s>=0;)z=this.containsBlackPoint(n,r,s,!0),z?(s--,u=!0,E=!0):E||s--;if(s<0){a=!0;break}u&&(d=!0)}if(!a&&d){const b=r-n;let D=null;for(let $=1;D===null&&$<b;$++)D=this.getBlackPointOnSegment(n,o-$,n+$,o);if(D==null)throw new j;let L=null;for(let $=1;L===null&&$<b;$++)L=this.getBlackPointOnSegment(n,s+$,n+$,s);if(L==null)throw new j;let z=null;for(let $=1;z===null&&$<b;$++)z=this.getBlackPointOnSegment(r,s+$,r-$,s);if(z==null)throw new j;let q=null;for(let $=1;q===null&&$<b;$++)q=this.getBlackPointOnSegment(r,o-$,r-$,o);if(q==null)throw new j;return this.centerEdges(q,D,z,L)}else throw new j}getBlackPointOnSegment(n,r,s,o){const a=Te.round(Te.distance(n,r,s,o)),u=(s-n)/a,d=(o-r)/a,h=this.image;for(let g=0;g<a;g++){const x=Te.round(n+g*u),E=Te.round(r+g*d);if(h.get(x,E))return new oe(x,E)}return null}centerEdges(n,r,s,o){const a=n.getX(),u=n.getY(),d=r.getX(),h=r.getY(),g=s.getX(),x=s.getY(),E=o.getX(),A=o.getY(),I=Gn.CORR;return a<this.width/2?[new oe(E-I,A+I),new oe(d+I,h+I),new oe(g-I,x-I),new oe(a+I,u-I)]:[new oe(E+I,A+I),new oe(d+I,h-I),new oe(g-I,x+I),new oe(a-I,u-I)]}containsBlackPoint(n,r,s,o){const a=this.image;if(o){for(let u=n;u<=r;u++)if(a.get(u,s))return!0}else for(let u=n;u<=r;u++)if(a.get(s,u))return!0;return!1}}Gn.INIT_SIZE=10,Gn.CORR=1;class Ha{static checkAndNudgePoints(n,r){const s=n.getWidth(),o=n.getHeight();let a=!0;for(let u=0;u<r.length&&a;u+=2){const d=Math.floor(r[u]),h=Math.floor(r[u+1]);if(d<-1||d>s||h<-1||h>o)throw new j;a=!1,d===-1?(r[u]=0,a=!0):d===s&&(r[u]=s-1,a=!0),h===-1?(r[u+1]=0,a=!0):h===o&&(r[u+1]=o-1,a=!0)}a=!0;for(let u=r.length-2;u>=0&&a;u-=2){const d=Math.floor(r[u]),h=Math.floor(r[u+1]);if(d<-1||d>s||h<-1||h>o)throw new j;a=!1,d===-1?(r[u]=0,a=!0):d===s&&(r[u]=s-1,a=!0),h===-1?(r[u+1]=0,a=!0):h===o&&(r[u+1]=o-1,a=!0)}}}class Cn{constructor(n,r,s,o,a,u,d,h,g){this.a11=n,this.a21=r,this.a31=s,this.a12=o,this.a22=a,this.a32=u,this.a13=d,this.a23=h,this.a33=g}static quadrilateralToQuadrilateral(n,r,s,o,a,u,d,h,g,x,E,A,I,b,D,L){const z=Cn.quadrilateralToSquare(n,r,s,o,a,u,d,h);return Cn.squareToQuadrilateral(g,x,E,A,I,b,D,L).times(z)}transformPoints(n){const r=n.length,s=this.a11,o=this.a12,a=this.a13,u=this.a21,d=this.a22,h=this.a23,g=this.a31,x=this.a32,E=this.a33;for(let A=0;A<r;A+=2){const I=n[A],b=n[A+1],D=a*I+h*b+E;n[A]=(s*I+u*b+g)/D,n[A+1]=(o*I+d*b+x)/D}}transformPointsWithValues(n,r){const s=this.a11,o=this.a12,a=this.a13,u=this.a21,d=this.a22,h=this.a23,g=this.a31,x=this.a32,E=this.a33,A=n.length;for(let I=0;I<A;I++){const b=n[I],D=r[I],L=a*b+h*D+E;n[I]=(s*b+u*D+g)/L,r[I]=(o*b+d*D+x)/L}}static squareToQuadrilateral(n,r,s,o,a,u,d,h){const g=n-s+a-d,x=r-o+u-h;if(g===0&&x===0)return new Cn(s-n,a-s,n,o-r,u-o,r,0,0,1);{const E=s-a,A=d-a,I=o-u,b=h-u,D=E*b-A*I,L=(g*b-A*x)/D,z=(E*x-g*I)/D;return new Cn(s-n+L*s,d-n+z*d,n,o-r+L*o,h-r+z*h,r,L,z,1)}}static quadrilateralToSquare(n,r,s,o,a,u,d,h){return Cn.squareToQuadrilateral(n,r,s,o,a,u,d,h).buildAdjoint()}buildAdjoint(){return new Cn(this.a22*this.a33-this.a23*this.a32,this.a23*this.a31-this.a21*this.a33,this.a21*this.a32-this.a22*this.a31,this.a13*this.a32-this.a12*this.a33,this.a11*this.a33-this.a13*this.a31,this.a12*this.a31-this.a11*this.a32,this.a12*this.a23-this.a13*this.a22,this.a13*this.a21-this.a11*this.a23,this.a11*this.a22-this.a12*this.a21)}times(n){return new Cn(this.a11*n.a11+this.a21*n.a12+this.a31*n.a13,this.a11*n.a21+this.a21*n.a22+this.a31*n.a23,this.a11*n.a31+this.a21*n.a32+this.a31*n.a33,this.a12*n.a11+this.a22*n.a12+this.a32*n.a13,this.a12*n.a21+this.a22*n.a22+this.a32*n.a23,this.a12*n.a31+this.a22*n.a32+this.a32*n.a33,this.a13*n.a11+this.a23*n.a12+this.a33*n.a13,this.a13*n.a21+this.a23*n.a22+this.a33*n.a23,this.a13*n.a31+this.a23*n.a32+this.a33*n.a33)}}class Qc extends Ha{sampleGrid(n,r,s,o,a,u,d,h,g,x,E,A,I,b,D,L,z,q,$){const Z=Cn.quadrilateralToQuadrilateral(o,a,u,d,h,g,x,E,A,I,b,D,L,z,q,$);return this.sampleGridWithTransform(n,r,s,Z)}sampleGridWithTransform(n,r,s,o){if(r<=0||s<=0)throw new j;const a=new _e(r,s),u=new Float32Array(2*r);for(let d=0;d<s;d++){const h=u.length,g=d+.5;for(let x=0;x<h;x+=2)u[x]=x/2+.5,u[x+1]=g;o.transformPoints(u),Ha.checkAndNudgePoints(n,u);try{for(let x=0;x<h;x+=2)n.get(Math.floor(u[x]),Math.floor(u[x+1]))&&a.set(x/2,d)}catch{throw new j}}return a}}class sr{static setGridSampler(n){sr.gridSampler=n}static getInstance(){return sr.gridSampler}}sr.gridSampler=new Qc;class Lt{constructor(n,r){this.x=n,this.y=r}toResultPoint(){return new oe(this.getX(),this.getY())}getX(){return this.x}getY(){return this.y}}class qc{constructor(n){this.EXPECTED_CORNER_BITS=new Int32Array([3808,476,2107,1799]),this.image=n}detect(){return this.detectMirror(!1)}detectMirror(n){let r=this.getMatrixCenter(),s=this.getBullsEyeCorners(r);if(n){let u=s[0];s[0]=s[2],s[2]=u}this.extractParameters(s);let o=this.sampleGrid(this.image,s[this.shift%4],s[(this.shift+1)%4],s[(this.shift+2)%4],s[(this.shift+3)%4]),a=this.getMatrixCornerPoints(s);return new Kc(o,a,this.compact,this.nbDataBlocks,this.nbLayers)}extractParameters(n){if(!this.isValidPoint(n[0])||!this.isValidPoint(n[1])||!this.isValidPoint(n[2])||!this.isValidPoint(n[3]))throw new j;let r=2*this.nbCenterLayers,s=new Int32Array([this.sampleLine(n[0],n[1],r),this.sampleLine(n[1],n[2],r),this.sampleLine(n[2],n[3],r),this.sampleLine(n[3],n[0],r)]);this.shift=this.getRotation(s,r);let o=0;for(let u=0;u<4;u++){let d=s[(this.shift+u)%4];this.compact?(o<<=7,o+=d>>1&127):(o<<=10,o+=(d>>2&992)+(d>>1&31))}let a=this.getCorrectedParameterData(o,this.compact);this.compact?(this.nbLayers=(a>>6)+1,this.nbDataBlocks=(a&63)+1):(this.nbLayers=(a>>11)+1,this.nbDataBlocks=(a&2047)+1)}getRotation(n,r){let s=0;n.forEach((o,a,u)=>{let d=(o>>r-2<<1)+(o&1);s=(s<<3)+d}),s=((s&1)<<11)+(s>>1);for(let o=0;o<4;o++)if(N.bitCount(s^this.EXPECTED_CORNER_BITS[o])<=2)return o;throw new j}getCorrectedParameterData(n,r){let s,o;r?(s=7,o=2):(s=10,o=4);let a=s-o,u=new Int32Array(s);for(let h=s-1;h>=0;--h)u[h]=n&15,n>>=4;try{new $i(be.AZTEC_PARAM).decode(u,a)}catch{throw new j}let d=0;for(let h=0;h<o;h++)d=(d<<4)+u[h];return d}getBullsEyeCorners(n){let r=n,s=n,o=n,a=n,u=!0;for(this.nbCenterLayers=1;this.nbCenterLayers<9;this.nbCenterLayers++){let E=this.getFirstDifferent(r,u,1,-1),A=this.getFirstDifferent(s,u,1,1),I=this.getFirstDifferent(o,u,-1,1),b=this.getFirstDifferent(a,u,-1,-1);if(this.nbCenterLayers>2){let D=this.distancePoint(b,E)*this.nbCenterLayers/(this.distancePoint(a,r)*(this.nbCenterLayers+2));if(D<.75||D>1.25||!this.isWhiteOrBlackRectangle(E,A,I,b))break}r=E,s=A,o=I,a=b,u=!u}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new j;this.compact=this.nbCenterLayers===5;let d=new oe(r.getX()+.5,r.getY()-.5),h=new oe(s.getX()+.5,s.getY()+.5),g=new oe(o.getX()-.5,o.getY()+.5),x=new oe(a.getX()-.5,a.getY()-.5);return this.expandSquare([d,h,g,x],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let n,r,s,o;try{let d=new Gn(this.image).detect();n=d[0],r=d[1],s=d[2],o=d[3]}catch{let h=this.image.getWidth()/2,g=this.image.getHeight()/2;n=this.getFirstDifferent(new Lt(h+7,g-7),!1,1,-1).toResultPoint(),r=this.getFirstDifferent(new Lt(h+7,g+7),!1,1,1).toResultPoint(),s=this.getFirstDifferent(new Lt(h-7,g+7),!1,-1,1).toResultPoint(),o=this.getFirstDifferent(new Lt(h-7,g-7),!1,-1,-1).toResultPoint()}let a=Te.round((n.getX()+o.getX()+r.getX()+s.getX())/4),u=Te.round((n.getY()+o.getY()+r.getY()+s.getY())/4);try{let d=new Gn(this.image,15,a,u).detect();n=d[0],r=d[1],s=d[2],o=d[3]}catch{n=this.getFirstDifferent(new Lt(a+7,u-7),!1,1,-1).toResultPoint(),r=this.getFirstDifferent(new Lt(a+7,u+7),!1,1,1).toResultPoint(),s=this.getFirstDifferent(new Lt(a-7,u+7),!1,-1,1).toResultPoint(),o=this.getFirstDifferent(new Lt(a-7,u-7),!1,-1,-1).toResultPoint()}return a=Te.round((n.getX()+o.getX()+r.getX()+s.getX())/4),u=Te.round((n.getY()+o.getY()+r.getY()+s.getY())/4),new Lt(a,u)}getMatrixCornerPoints(n){return this.expandSquare(n,2*this.nbCenterLayers,this.getDimension())}sampleGrid(n,r,s,o,a){let u=sr.getInstance(),d=this.getDimension(),h=d/2-this.nbCenterLayers,g=d/2+this.nbCenterLayers;return u.sampleGrid(n,d,d,h,h,g,h,g,g,h,g,r.getX(),r.getY(),s.getX(),s.getY(),o.getX(),o.getY(),a.getX(),a.getY())}sampleLine(n,r,s){let o=0,a=this.distanceResultPoint(n,r),u=a/s,d=n.getX(),h=n.getY(),g=u*(r.getX()-n.getX())/a,x=u*(r.getY()-n.getY())/a;for(let E=0;E<s;E++)this.image.get(Te.round(d+E*g),Te.round(h+E*x))&&(o|=1<<s-E-1);return o}isWhiteOrBlackRectangle(n,r,s,o){let a=3;n=new Lt(n.getX()-a,n.getY()+a),r=new Lt(r.getX()-a,r.getY()-a),s=new Lt(s.getX()+a,s.getY()-a),o=new Lt(o.getX()+a,o.getY()+a);let u=this.getColor(o,n);if(u===0)return!1;let d=this.getColor(n,r);return d!==u||(d=this.getColor(r,s),d!==u)?!1:(d=this.getColor(s,o),d===u)}getColor(n,r){let s=this.distancePoint(n,r),o=(r.getX()-n.getX())/s,a=(r.getY()-n.getY())/s,u=0,d=n.getX(),h=n.getY(),g=this.image.get(n.getX(),n.getY()),x=Math.ceil(s);for(let A=0;A<x;A++)d+=o,h+=a,this.image.get(Te.round(d),Te.round(h))!==g&&u++;let E=u/s;return E>.1&&E<.9?0:E<=.1===g?1:-1}getFirstDifferent(n,r,s,o){let a=n.getX()+s,u=n.getY()+o;for(;this.isValid(a,u)&&this.image.get(a,u)===r;)a+=s,u+=o;for(a-=s,u-=o;this.isValid(a,u)&&this.image.get(a,u)===r;)a+=s;for(a-=s;this.isValid(a,u)&&this.image.get(a,u)===r;)u+=o;return u-=o,new Lt(a,u)}expandSquare(n,r,s){let o=s/(2*r),a=n[0].getX()-n[2].getX(),u=n[0].getY()-n[2].getY(),d=(n[0].getX()+n[2].getX())/2,h=(n[0].getY()+n[2].getY())/2,g=new oe(d+o*a,h+o*u),x=new oe(d-o*a,h-o*u);a=n[1].getX()-n[3].getX(),u=n[1].getY()-n[3].getY(),d=(n[1].getX()+n[3].getX())/2,h=(n[1].getY()+n[3].getY())/2;let E=new oe(d+o*a,h+o*u),A=new oe(d-o*a,h-o*u);return[g,E,x,A]}isValid(n,r){return n>=0&&n<this.image.getWidth()&&r>0&&r<this.image.getHeight()}isValidPoint(n){let r=Te.round(n.getX()),s=Te.round(n.getY());return this.isValid(r,s)}distancePoint(n,r){return Te.distance(n.getX(),n.getY(),r.getX(),r.getY())}distanceResultPoint(n,r){return Te.distance(n.getX(),n.getY(),r.getX(),r.getY())}getDimension(){return this.compact?4*this.nbLayers+11:this.nbLayers<=4?4*this.nbLayers+15:4*this.nbLayers+2*(N.truncDivision(this.nbLayers-4,8)+1)+15}}class ao{decode(n,r=null){let s=null,o=new qc(n.getBlackMatrix()),a=null,u=null;try{let x=o.detectMirror(!1);a=x.getPoints(),this.reportFoundResultPoints(r,a),u=new Ue().decode(x)}catch(x){s=x}if(u==null)try{let x=o.detectMirror(!0);a=x.getPoints(),this.reportFoundResultPoints(r,a),u=new Ue().decode(x)}catch(x){throw s??x}let d=new Ke(u.getText(),u.getRawBytes(),u.getNumBits(),a,le.AZTEC,B.currentTimeMillis()),h=u.getByteSegments();h!=null&&d.putMetadata(mt.BYTE_SEGMENTS,h);let g=u.getECLevel();return g!=null&&d.putMetadata(mt.ERROR_CORRECTION_LEVEL,g),d}reportFoundResultPoints(n,r){if(n!=null){let s=n.get(U.NEED_RESULT_POINT_CALLBACK);s!=null&&r.forEach((o,a,u)=>{s.foundPossibleResultPoint(o)})}}reset(){}}class Rh extends cn{constructor(n=500){super(new ao,n)}}class ut{decode(n,r){try{return this.doDecode(n,r)}catch{if(r&&r.get(U.TRY_HARDER)===!0&&n.isRotateSupported()){const a=n.rotateCounterClockwise(),u=this.doDecode(a,r),d=u.getResultMetadata();let h=270;d!==null&&d.get(mt.ORIENTATION)===!0&&(h=h+d.get(mt.ORIENTATION)%360),u.putMetadata(mt.ORIENTATION,h);const g=u.getResultPoints();if(g!==null){const x=a.getHeight();for(let E=0;E<g.length;E++)g[E]=new oe(x-g[E].getY()-1,g[E].getX())}return u}else throw new j}}reset(){}doDecode(n,r){const s=n.getWidth(),o=n.getHeight();let a=new G(s);const u=r&&r.get(U.TRY_HARDER)===!0,d=Math.max(1,o>>(u?8:5));let h;u?h=o:h=15;const g=Math.trunc(o/2);for(let x=0;x<h;x++){const E=Math.trunc((x+1)/2),A=(x&1)===0,I=g+d*(A?E:-E);if(I<0||I>=o)break;try{a=n.getBlackRow(I,a)}catch{continue}for(let b=0;b<2;b++){if(b===1&&(a.reverse(),r&&r.get(U.NEED_RESULT_POINT_CALLBACK)===!0)){const D=new Map;r.forEach((L,z)=>D.set(z,L)),D.delete(U.NEED_RESULT_POINT_CALLBACK),r=D}try{const D=this.decodeRow(I,a,r);if(b===1){D.putMetadata(mt.ORIENTATION,180);const L=D.getResultPoints();L!==null&&(L[0]=new oe(s-L[0].getX()-1,L[0].getY()),L[1]=new oe(s-L[1].getX()-1,L[1].getY()))}return D}catch{}}}throw new j}static recordPattern(n,r,s){const o=s.length;for(let g=0;g<o;g++)s[g]=0;const a=n.getSize();if(r>=a)throw new j;let u=!n.get(r),d=0,h=r;for(;h<a;){if(n.get(h)!==u)s[d]++;else{if(++d===o)break;s[d]=1,u=!u}h++}if(!(d===o||d===o-1&&h===a))throw new j}static recordPatternInReverse(n,r,s){let o=s.length,a=n.get(r);for(;r>0&&o>=0;)n.get(--r)!==a&&(o--,a=!a);if(o>=0)throw new j;ut.recordPattern(n,r+1,s)}static patternMatchVariance(n,r,s){const o=n.length;let a=0,u=0;for(let g=0;g<o;g++)a+=n[g],u+=r[g];if(a<u)return Number.POSITIVE_INFINITY;const d=a/u;s*=d;let h=0;for(let g=0;g<o;g++){const x=n[g],E=r[g]*d,A=x>E?x-E:E-x;if(A>s)return Number.POSITIVE_INFINITY;h+=A}return h/a}}class J extends ut{static findStartPattern(n){const r=n.getSize(),s=n.getNextSet(0);let o=0,a=Int32Array.from([0,0,0,0,0,0]),u=s,d=!1;const h=6;for(let g=s;g<r;g++)if(n.get(g)!==d)a[o]++;else{if(o===h-1){let x=J.MAX_AVG_VARIANCE,E=-1;for(let A=J.CODE_START_A;A<=J.CODE_START_C;A++){const I=ut.patternMatchVariance(a,J.CODE_PATTERNS[A],J.MAX_INDIVIDUAL_VARIANCE);I<x&&(x=I,E=A)}if(E>=0&&n.isRange(Math.max(0,u-(g-u)/2),u,!1))return Int32Array.from([u,g,E]);u+=a[0]+a[1],a=a.slice(2,a.length-1),a[o-1]=0,a[o]=0,o--}else o++;a[o]=1,d=!d}throw new j}static decodeCode(n,r,s){ut.recordPattern(n,s,r);let o=J.MAX_AVG_VARIANCE,a=-1;for(let u=0;u<J.CODE_PATTERNS.length;u++){const d=J.CODE_PATTERNS[u],h=this.patternMatchVariance(r,d,J.MAX_INDIVIDUAL_VARIANCE);h<o&&(o=h,a=u)}if(a>=0)return a;throw new j}decodeRow(n,r,s){const o=s&&s.get(U.ASSUME_GS1)===!0,a=J.findStartPattern(r),u=a[2];let d=0;const h=new Uint8Array(20);h[d++]=u;let g;switch(u){case J.CODE_START_A:g=J.CODE_CODE_A;break;case J.CODE_START_B:g=J.CODE_CODE_B;break;case J.CODE_START_C:g=J.CODE_CODE_C;break;default:throw new k}let x=!1,E=!1,A="",I=a[0],b=a[1];const D=Int32Array.from([0,0,0,0,0,0]);let L=0,z=0,q=u,$=0,Z=!0,ve=!1,me=!1;for(;!x;){const di=E;switch(E=!1,L=z,z=J.decodeCode(r,D,b),h[d++]=z,z!==J.CODE_STOP&&(Z=!0),z!==J.CODE_STOP&&($++,q+=$*z),I=b,b+=D.reduce((ig,sg)=>ig+sg,0),z){case J.CODE_START_A:case J.CODE_START_B:case J.CODE_START_C:throw new k}switch(g){case J.CODE_CODE_A:if(z<64)me===ve?A+=String.fromCharCode(32+z):A+=String.fromCharCode(32+z+128),me=!1;else if(z<96)me===ve?A+=String.fromCharCode(z-64):A+=String.fromCharCode(z+64),me=!1;else switch(z!==J.CODE_STOP&&(Z=!1),z){case J.CODE_FNC_1:o&&(A.length===0?A+="]C1":A+="");break;case J.CODE_FNC_2:case J.CODE_FNC_3:break;case J.CODE_FNC_4_A:!ve&&me?(ve=!0,me=!1):ve&&me?(ve=!1,me=!1):me=!0;break;case J.CODE_SHIFT:E=!0,g=J.CODE_CODE_B;break;case J.CODE_CODE_B:g=J.CODE_CODE_B;break;case J.CODE_CODE_C:g=J.CODE_CODE_C;break;case J.CODE_STOP:x=!0;break}break;case J.CODE_CODE_B:if(z<96)me===ve?A+=String.fromCharCode(32+z):A+=String.fromCharCode(32+z+128),me=!1;else switch(z!==J.CODE_STOP&&(Z=!1),z){case J.CODE_FNC_1:o&&(A.length===0?A+="]C1":A+="");break;case J.CODE_FNC_2:case J.CODE_FNC_3:break;case J.CODE_FNC_4_B:!ve&&me?(ve=!0,me=!1):ve&&me?(ve=!1,me=!1):me=!0;break;case J.CODE_SHIFT:E=!0,g=J.CODE_CODE_A;break;case J.CODE_CODE_A:g=J.CODE_CODE_A;break;case J.CODE_CODE_C:g=J.CODE_CODE_C;break;case J.CODE_STOP:x=!0;break}break;case J.CODE_CODE_C:if(z<100)z<10&&(A+="0"),A+=z;else switch(z!==J.CODE_STOP&&(Z=!1),z){case J.CODE_FNC_1:o&&(A.length===0?A+="]C1":A+="");break;case J.CODE_CODE_A:g=J.CODE_CODE_A;break;case J.CODE_CODE_B:g=J.CODE_CODE_B;break;case J.CODE_STOP:x=!0;break}break}di&&(g=g===J.CODE_CODE_A?J.CODE_CODE_B:J.CODE_CODE_A)}const Yt=b-I;if(b=r.getNextUnset(b),!r.isRange(b,Math.min(r.getSize(),b+(b-I)/2),!1))throw new j;if(q-=$*L,q%103!==L)throw new M;const vn=A.length;if(vn===0)throw new j;vn>0&&Z&&(g===J.CODE_CODE_C?A=A.substring(0,vn-2):A=A.substring(0,vn-1));const Zt=(a[1]+a[0])/2,Fe=I+Yt/2,_t=h.length,tn=new Uint8Array(_t);for(let di=0;di<_t;di++)tn[di]=h[di];const fi=[new oe(Zt,n),new oe(Fe,n)];return new Ke(A,tn,0,fi,le.CODE_128,new Date().getTime())}}J.CODE_PATTERNS=[Int32Array.from([2,1,2,2,2,2]),Int32Array.from([2,2,2,1,2,2]),Int32Array.from([2,2,2,2,2,1]),Int32Array.from([1,2,1,2,2,3]),Int32Array.from([1,2,1,3,2,2]),Int32Array.from([1,3,1,2,2,2]),Int32Array.from([1,2,2,2,1,3]),Int32Array.from([1,2,2,3,1,2]),Int32Array.from([1,3,2,2,1,2]),Int32Array.from([2,2,1,2,1,3]),Int32Array.from([2,2,1,3,1,2]),Int32Array.from([2,3,1,2,1,2]),Int32Array.from([1,1,2,2,3,2]),Int32Array.from([1,2,2,1,3,2]),Int32Array.from([1,2,2,2,3,1]),Int32Array.from([1,1,3,2,2,2]),Int32Array.from([1,2,3,1,2,2]),Int32Array.from([1,2,3,2,2,1]),Int32Array.from([2,2,3,2,1,1]),Int32Array.from([2,2,1,1,3,2]),Int32Array.from([2,2,1,2,3,1]),Int32Array.from([2,1,3,2,1,2]),Int32Array.from([2,2,3,1,1,2]),Int32Array.from([3,1,2,1,3,1]),Int32Array.from([3,1,1,2,2,2]),Int32Array.from([3,2,1,1,2,2]),Int32Array.from([3,2,1,2,2,1]),Int32Array.from([3,1,2,2,1,2]),Int32Array.from([3,2,2,1,1,2]),Int32Array.from([3,2,2,2,1,1]),Int32Array.from([2,1,2,1,2,3]),Int32Array.from([2,1,2,3,2,1]),Int32Array.from([2,3,2,1,2,1]),Int32Array.from([1,1,1,3,2,3]),Int32Array.from([1,3,1,1,2,3]),Int32Array.from([1,3,1,3,2,1]),Int32Array.from([1,1,2,3,1,3]),Int32Array.from([1,3,2,1,1,3]),Int32Array.from([1,3,2,3,1,1]),Int32Array.from([2,1,1,3,1,3]),Int32Array.from([2,3,1,1,1,3]),Int32Array.from([2,3,1,3,1,1]),Int32Array.from([1,1,2,1,3,3]),Int32Array.from([1,1,2,3,3,1]),Int32Array.from([1,3,2,1,3,1]),Int32Array.from([1,1,3,1,2,3]),Int32Array.from([1,1,3,3,2,1]),Int32Array.from([1,3,3,1,2,1]),Int32Array.from([3,1,3,1,2,1]),Int32Array.from([2,1,1,3,3,1]),Int32Array.from([2,3,1,1,3,1]),Int32Array.from([2,1,3,1,1,3]),Int32Array.from([2,1,3,3,1,1]),Int32Array.from([2,1,3,1,3,1]),Int32Array.from([3,1,1,1,2,3]),Int32Array.from([3,1,1,3,2,1]),Int32Array.from([3,3,1,1,2,1]),Int32Array.from([3,1,2,1,1,3]),Int32Array.from([3,1,2,3,1,1]),Int32Array.from([3,3,2,1,1,1]),Int32Array.from([3,1,4,1,1,1]),Int32Array.from([2,2,1,4,1,1]),Int32Array.from([4,3,1,1,1,1]),Int32Array.from([1,1,1,2,2,4]),Int32Array.from([1,1,1,4,2,2]),Int32Array.from([1,2,1,1,2,4]),Int32Array.from([1,2,1,4,2,1]),Int32Array.from([1,4,1,1,2,2]),Int32Array.from([1,4,1,2,2,1]),Int32Array.from([1,1,2,2,1,4]),Int32Array.from([1,1,2,4,1,2]),Int32Array.from([1,2,2,1,1,4]),Int32Array.from([1,2,2,4,1,1]),Int32Array.from([1,4,2,1,1,2]),Int32Array.from([1,4,2,2,1,1]),Int32Array.from([2,4,1,2,1,1]),Int32Array.from([2,2,1,1,1,4]),Int32Array.from([4,1,3,1,1,1]),Int32Array.from([2,4,1,1,1,2]),Int32Array.from([1,3,4,1,1,1]),Int32Array.from([1,1,1,2,4,2]),Int32Array.from([1,2,1,1,4,2]),Int32Array.from([1,2,1,2,4,1]),Int32Array.from([1,1,4,2,1,2]),Int32Array.from([1,2,4,1,1,2]),Int32Array.from([1,2,4,2,1,1]),Int32Array.from([4,1,1,2,1,2]),Int32Array.from([4,2,1,1,1,2]),Int32Array.from([4,2,1,2,1,1]),Int32Array.from([2,1,2,1,4,1]),Int32Array.from([2,1,4,1,2,1]),Int32Array.from([4,1,2,1,2,1]),Int32Array.from([1,1,1,1,4,3]),Int32Array.from([1,1,1,3,4,1]),Int32Array.from([1,3,1,1,4,1]),Int32Array.from([1,1,4,1,1,3]),Int32Array.from([1,1,4,3,1,1]),Int32Array.from([4,1,1,1,1,3]),Int32Array.from([4,1,1,3,1,1]),Int32Array.from([1,1,3,1,4,1]),Int32Array.from([1,1,4,1,3,1]),Int32Array.from([3,1,1,1,4,1]),Int32Array.from([4,1,1,1,3,1]),Int32Array.from([2,1,1,4,1,2]),Int32Array.from([2,1,1,2,1,4]),Int32Array.from([2,1,1,2,3,2]),Int32Array.from([2,3,3,1,1,1,2])],J.MAX_AVG_VARIANCE=.25,J.MAX_INDIVIDUAL_VARIANCE=.7,J.CODE_SHIFT=98,J.CODE_CODE_C=99,J.CODE_CODE_B=100,J.CODE_CODE_A=101,J.CODE_FNC_1=102,J.CODE_FNC_2=97,J.CODE_FNC_3=96,J.CODE_FNC_4_A=101,J.CODE_FNC_4_B=100,J.CODE_START_A=103,J.CODE_START_B=104,J.CODE_START_C=105,J.CODE_STOP=106;class ft extends ut{constructor(n=!1,r=!1){super(),this.usingCheckDigit=n,this.extendedMode=r,this.decodeRowResult="",this.counters=new Int32Array(9)}decodeRow(n,r,s){let o=this.counters;o.fill(0),this.decodeRowResult="";let a=ft.findAsteriskPattern(r,o),u=r.getNextSet(a[1]),d=r.getSize(),h,g;do{ft.recordPattern(r,u,o);let D=ft.toNarrowWidePattern(o);if(D<0)throw new j;h=ft.patternToChar(D),this.decodeRowResult+=h,g=u;for(let L of o)u+=L;u=r.getNextSet(u)}while(h!=="*");this.decodeRowResult=this.decodeRowResult.substring(0,this.decodeRowResult.length-1);let x=0;for(let D of o)x+=D;let E=u-g-x;if(u!==d&&E*2<x)throw new j;if(this.usingCheckDigit){let D=this.decodeRowResult.length-1,L=0;for(let z=0;z<D;z++)L+=ft.ALPHABET_STRING.indexOf(this.decodeRowResult.charAt(z));if(this.decodeRowResult.charAt(D)!==ft.ALPHABET_STRING.charAt(L%43))throw new M;this.decodeRowResult=this.decodeRowResult.substring(0,D)}if(this.decodeRowResult.length===0)throw new j;let A;this.extendedMode?A=ft.decodeExtended(this.decodeRowResult):A=this.decodeRowResult;let I=(a[1]+a[0])/2,b=g+x/2;return new Ke(A,null,0,[new oe(I,n),new oe(b,n)],le.CODE_39,new Date().getTime())}static findAsteriskPattern(n,r){let s=n.getSize(),o=n.getNextSet(0),a=0,u=o,d=!1,h=r.length;for(let g=o;g<s;g++)if(n.get(g)!==d)r[a]++;else{if(a===h-1){if(this.toNarrowWidePattern(r)===ft.ASTERISK_ENCODING&&n.isRange(Math.max(0,u-Math.floor((g-u)/2)),u,!1))return[u,g];u+=r[0]+r[1],r.copyWithin(0,2,2+a-1),r[a-1]=0,r[a]=0,a--}else a++;r[a]=1,d=!d}throw new j}static toNarrowWidePattern(n){let r=n.length,s=0,o;do{let a=2147483647;for(let h of n)h<a&&h>s&&(a=h);s=a,o=0;let u=0,d=0;for(let h=0;h<r;h++){let g=n[h];g>s&&(d|=1<<r-1-h,o++,u+=g)}if(o===3){for(let h=0;h<r&&o>0;h++){let g=n[h];if(g>s&&(o--,g*2>=u))return-1}return d}}while(o>3);return-1}static patternToChar(n){for(let r=0;r<ft.CHARACTER_ENCODINGS.length;r++)if(ft.CHARACTER_ENCODINGS[r]===n)return ft.ALPHABET_STRING.charAt(r);if(n===ft.ASTERISK_ENCODING)return"*";throw new j}static decodeExtended(n){let r=n.length,s="";for(let o=0;o<r;o++){let a=n.charAt(o);if(a==="+"||a==="$"||a==="%"||a==="/"){let u=n.charAt(o+1),d="\0";switch(a){case"+":if(u>="A"&&u<="Z")d=String.fromCharCode(u.charCodeAt(0)+32);else throw new k;break;case"$":if(u>="A"&&u<="Z")d=String.fromCharCode(u.charCodeAt(0)-64);else throw new k;break;case"%":if(u>="A"&&u<="E")d=String.fromCharCode(u.charCodeAt(0)-38);else if(u>="F"&&u<="J")d=String.fromCharCode(u.charCodeAt(0)-11);else if(u>="K"&&u<="O")d=String.fromCharCode(u.charCodeAt(0)+16);else if(u>="P"&&u<="T")d=String.fromCharCode(u.charCodeAt(0)+43);else if(u==="U")d="\0";else if(u==="V")d="@";else if(u==="W")d="`";else if(u==="X"||u==="Y"||u==="Z")d="";else throw new k;break;case"/":if(u>="A"&&u<="O")d=String.fromCharCode(u.charCodeAt(0)-32);else if(u==="Z")d=":";else throw new k;break}s+=d,o++}else s+=a}return s}}ft.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",ft.CHARACTER_ENCODINGS=[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,168,162,138,42],ft.ASTERISK_ENCODING=148;class Be extends ut{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(n,r,s){let o=this.decodeStart(r),a=this.decodeEnd(r),u=new ge;Be.decodeMiddle(r,o[1],a[0],u);let d=u.toString(),h=null;s!=null&&(h=s.get(U.ALLOWED_LENGTHS)),h==null&&(h=Be.DEFAULT_ALLOWED_LENGTHS);let g=d.length,x=!1,E=0;for(let b of h){if(g===b){x=!0;break}b>E&&(E=b)}if(!x&&g>E&&(x=!0),!x)throw new k;const A=[new oe(o[1],n),new oe(a[0],n)];return new Ke(d,null,0,A,le.ITF,new Date().getTime())}static decodeMiddle(n,r,s,o){let a=new Int32Array(10),u=new Int32Array(5),d=new Int32Array(5);for(a.fill(0),u.fill(0),d.fill(0);r<s;){ut.recordPattern(n,r,a);for(let g=0;g<5;g++){let x=2*g;u[g]=a[x],d[g]=a[x+1]}let h=Be.decodeDigit(u);o.append(h.toString()),h=this.decodeDigit(d),o.append(h.toString()),a.forEach(function(g){r+=g})}}decodeStart(n){let r=Be.skipWhiteSpace(n),s=Be.findGuardPattern(n,r,Be.START_PATTERN);return this.narrowLineWidth=(s[1]-s[0])/4,this.validateQuietZone(n,s[0]),s}validateQuietZone(n,r){let s=this.narrowLineWidth*10;s=s<r?s:r;for(let o=r-1;s>0&&o>=0&&!n.get(o);o--)s--;if(s!==0)throw new j}static skipWhiteSpace(n){const r=n.getSize(),s=n.getNextSet(0);if(s===r)throw new j;return s}decodeEnd(n){n.reverse();try{let r=Be.skipWhiteSpace(n),s;try{s=Be.findGuardPattern(n,r,Be.END_PATTERN_REVERSED[0])}catch(a){a instanceof j&&(s=Be.findGuardPattern(n,r,Be.END_PATTERN_REVERSED[1]))}this.validateQuietZone(n,s[0]);let o=s[0];return s[0]=n.getSize()-s[1],s[1]=n.getSize()-o,s}finally{n.reverse()}}static findGuardPattern(n,r,s){let o=s.length,a=new Int32Array(o),u=n.getSize(),d=!1,h=0,g=r;a.fill(0);for(let x=r;x<u;x++)if(n.get(x)!==d)a[h]++;else{if(h===o-1){if(ut.patternMatchVariance(a,s,Be.MAX_INDIVIDUAL_VARIANCE)<Be.MAX_AVG_VARIANCE)return[g,x];g+=a[0]+a[1],B.arraycopy(a,2,a,0,h-1),a[h-1]=0,a[h]=0,h--}else h++;a[h]=1,d=!d}throw new j}static decodeDigit(n){let r=Be.MAX_AVG_VARIANCE,s=-1,o=Be.PATTERNS.length;for(let a=0;a<o;a++){let u=Be.PATTERNS[a],d=ut.patternMatchVariance(n,u,Be.MAX_INDIVIDUAL_VARIANCE);d<r?(r=d,s=a):d===r&&(s=-1)}if(s>=0)return s%10;throw new j}}Be.PATTERNS=[Int32Array.from([1,1,2,2,1]),Int32Array.from([2,1,1,1,2]),Int32Array.from([1,2,1,1,2]),Int32Array.from([2,2,1,1,1]),Int32Array.from([1,1,2,1,2]),Int32Array.from([2,1,2,1,1]),Int32Array.from([1,2,2,1,1]),Int32Array.from([1,1,1,2,2]),Int32Array.from([2,1,1,2,1]),Int32Array.from([1,2,1,2,1]),Int32Array.from([1,1,3,3,1]),Int32Array.from([3,1,1,1,3]),Int32Array.from([1,3,1,1,3]),Int32Array.from([3,3,1,1,1]),Int32Array.from([1,1,3,1,3]),Int32Array.from([3,1,3,1,1]),Int32Array.from([1,3,3,1,1]),Int32Array.from([1,1,1,3,3]),Int32Array.from([3,1,1,3,1]),Int32Array.from([1,3,1,3,1])],Be.MAX_AVG_VARIANCE=.38,Be.MAX_INDIVIDUAL_VARIANCE=.5,Be.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],Be.START_PATTERN=Int32Array.from([1,1,1,1]),Be.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class nt extends ut{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(n){let r=!1,s,o=0,a=Int32Array.from([0,0,0]);for(;!r;){a=Int32Array.from([0,0,0]),s=nt.findGuardPattern(n,o,!1,this.START_END_PATTERN,a);let u=s[0];o=s[1];let d=u-(o-u);d>=0&&(r=n.isRange(d,u,!1))}return s}static checkChecksum(n){return nt.checkStandardUPCEANChecksum(n)}static checkStandardUPCEANChecksum(n){let r=n.length;if(r===0)return!1;let s=parseInt(n.charAt(r-1),10);return nt.getStandardUPCEANChecksum(n.substring(0,r-1))===s}static getStandardUPCEANChecksum(n){let r=n.length,s=0;for(let o=r-1;o>=0;o-=2){let a=n.charAt(o).charCodeAt(0)-48;if(a<0||a>9)throw new k;s+=a}s*=3;for(let o=r-2;o>=0;o-=2){let a=n.charAt(o).charCodeAt(0)-48;if(a<0||a>9)throw new k;s+=a}return(1e3-s)%10}static decodeEnd(n,r){return nt.findGuardPattern(n,r,!1,nt.START_END_PATTERN,new Int32Array(nt.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(n,r,s,o){return this.findGuardPattern(n,r,s,o,new Int32Array(o.length))}static findGuardPattern(n,r,s,o,a){let u=n.getSize();r=s?n.getNextUnset(r):n.getNextSet(r);let d=0,h=r,g=o.length,x=s;for(let E=r;E<u;E++)if(n.get(E)!==x)a[d]++;else{if(d===g-1){if(ut.patternMatchVariance(a,o,nt.MAX_INDIVIDUAL_VARIANCE)<nt.MAX_AVG_VARIANCE)return Int32Array.from([h,E]);h+=a[0]+a[1];let A=a.slice(2,a.length-1);for(let I=0;I<d-1;I++)a[I]=A[I];a[d-1]=0,a[d]=0,d--}else d++;a[d]=1,x=!x}throw new j}static decodeDigit(n,r,s,o){this.recordPattern(n,s,r);let a=this.MAX_AVG_VARIANCE,u=-1,d=o.length;for(let h=0;h<d;h++){let g=o[h],x=ut.patternMatchVariance(r,g,nt.MAX_INDIVIDUAL_VARIANCE);x<a&&(a=x,u=h)}if(u>=0)return u;throw new j}}nt.MAX_AVG_VARIANCE=.48,nt.MAX_INDIVIDUAL_VARIANCE=.7,nt.START_END_PATTERN=Int32Array.from([1,1,1]),nt.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),nt.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),nt.L_PATTERNS=[Int32Array.from([3,2,1,1]),Int32Array.from([2,2,2,1]),Int32Array.from([2,1,2,2]),Int32Array.from([1,4,1,1]),Int32Array.from([1,1,3,2]),Int32Array.from([1,2,3,1]),Int32Array.from([1,1,1,4]),Int32Array.from([1,3,1,2]),Int32Array.from([1,2,1,3]),Int32Array.from([3,1,1,2])];class Ji{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(n,r,s){let o=this.decodeRowStringBuffer,a=this.decodeMiddle(r,s,o),u=o.toString(),d=Ji.parseExtensionString(u),h=[new oe((s[0]+s[1])/2,n),new oe(a,n)],g=new Ke(u,null,0,h,le.UPC_EAN_EXTENSION,new Date().getTime());return d!=null&&g.putAllMetadata(d),g}decodeMiddle(n,r,s){let o=this.decodeMiddleCounters;o[0]=0,o[1]=0,o[2]=0,o[3]=0;let a=n.getSize(),u=r[1],d=0;for(let g=0;g<5&&u<a;g++){let x=nt.decodeDigit(n,o,u,nt.L_AND_G_PATTERNS);s+=String.fromCharCode(48+x%10);for(let E of o)u+=E;x>=10&&(d|=1<<4-g),g!==4&&(u=n.getNextSet(u),u=n.getNextUnset(u))}if(s.length!==5)throw new j;let h=this.determineCheckDigit(d);if(Ji.extensionChecksum(s.toString())!==h)throw new j;return u}static extensionChecksum(n){let r=n.length,s=0;for(let o=r-2;o>=0;o-=2)s+=n.charAt(o).charCodeAt(0)-48;s*=3;for(let o=r-1;o>=0;o-=2)s+=n.charAt(o).charCodeAt(0)-48;return s*=3,s%10}determineCheckDigit(n){for(let r=0;r<10;r++)if(n===this.CHECK_DIGIT_ENCODINGS[r])return r;throw new j}static parseExtensionString(n){if(n.length!==5)return null;let r=Ji.parseExtension5String(n);return r==null?null:new Map([[mt.SUGGESTED_PRICE,r]])}static parseExtension5String(n){let r;switch(n.charAt(0)){case"0":r="£";break;case"5":r="$";break;case"9":switch(n){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}r="";break;default:r="";break}let s=parseInt(n.substring(1)),o=(s/100).toString(),a=s%100,u=a<10?"0"+a:a.toString();return r+o+"."+u}}class ja{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(n,r,s){let o=this.decodeRowStringBuffer,a=this.decodeMiddle(r,s,o),u=o.toString(),d=ja.parseExtensionString(u),h=[new oe((s[0]+s[1])/2,n),new oe(a,n)],g=new Ke(u,null,0,h,le.UPC_EAN_EXTENSION,new Date().getTime());return d!=null&&g.putAllMetadata(d),g}decodeMiddle(n,r,s){let o=this.decodeMiddleCounters;o[0]=0,o[1]=0,o[2]=0,o[3]=0;let a=n.getSize(),u=r[1],d=0;for(let h=0;h<2&&u<a;h++){let g=nt.decodeDigit(n,o,u,nt.L_AND_G_PATTERNS);s+=String.fromCharCode(48+g%10);for(let x of o)u+=x;g>=10&&(d|=1<<1-h),h!==1&&(u=n.getNextSet(u),u=n.getNextUnset(u))}if(s.length!==2)throw new j;if(parseInt(s.toString())%4!==d)throw new j;return u}static parseExtensionString(n){return n.length!==2?null:new Map([[mt.ISSUE_NUMBER,parseInt(n)]])}}class $c{static decodeRow(n,r,s){let o=nt.findGuardPattern(r,s,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new Ji().decodeRow(n,r,o)}catch{return new ja().decodeRow(n,r,o)}}}$c.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class Oe extends nt{constructor(){super(),this.decodeRowStringBuffer="",Oe.L_AND_G_PATTERNS=Oe.L_PATTERNS.map(n=>Int32Array.from(n));for(let n=10;n<20;n++){let r=Oe.L_PATTERNS[n-10],s=new Int32Array(r.length);for(let o=0;o<r.length;o++)s[o]=r[r.length-o-1];Oe.L_AND_G_PATTERNS[n]=s}}decodeRow(n,r,s){let o=Oe.findStartGuardPattern(r),a=s==null?null:s.get(U.NEED_RESULT_POINT_CALLBACK);if(a!=null){const Z=new oe((o[0]+o[1])/2,n);a.foundPossibleResultPoint(Z)}let u=this.decodeMiddle(r,o,this.decodeRowStringBuffer),d=u.rowOffset,h=u.resultString;if(a!=null){const Z=new oe(d,n);a.foundPossibleResultPoint(Z)}let g=this.decodeEnd(r,d);if(a!=null){const Z=new oe((g[0]+g[1])/2,n);a.foundPossibleResultPoint(Z)}let x=g[1],E=x+(x-g[0]);if(E>=r.getSize()||!r.isRange(x,E,!1))throw new j;let A=h.toString();if(A.length<8)throw new k;if(!Oe.checkChecksum(A))throw new M;let I=(o[1]+o[0])/2,b=(g[1]+g[0])/2,D=this.getBarcodeFormat(),L=[new oe(I,n),new oe(b,n)],z=new Ke(A,null,0,L,D,new Date().getTime()),q=0;try{let Z=$c.decodeRow(n,r,g[1]);z.putMetadata(mt.UPC_EAN_EXTENSION,Z.getText()),z.putAllMetadata(Z.getResultMetadata()),z.addResultPoints(Z.getResultPoints()),q=Z.getText().length}catch{}let $=s==null?null:s.get(U.ALLOWED_EAN_EXTENSIONS);if($!=null){let Z=!1;for(let ve in $)if(q.toString()===ve){Z=!0;break}if(!Z)throw new j}return z}decodeEnd(n,r){return Oe.findGuardPattern(n,r,!1,Oe.START_END_PATTERN,new Int32Array(Oe.START_END_PATTERN.length).fill(0))}static checkChecksum(n){return Oe.checkStandardUPCEANChecksum(n)}static checkStandardUPCEANChecksum(n){let r=n.length;if(r===0)return!1;let s=parseInt(n.charAt(r-1),10);return Oe.getStandardUPCEANChecksum(n.substring(0,r-1))===s}static getStandardUPCEANChecksum(n){let r=n.length,s=0;for(let o=r-1;o>=0;o-=2){let a=n.charAt(o).charCodeAt(0)-48;if(a<0||a>9)throw new k;s+=a}s*=3;for(let o=r-2;o>=0;o-=2){let a=n.charAt(o).charCodeAt(0)-48;if(a<0||a>9)throw new k;s+=a}return(1e3-s)%10}}class Pr extends Oe{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(n,r,s){let o=this.decodeMiddleCounters;o[0]=0,o[1]=0,o[2]=0,o[3]=0;let a=n.getSize(),u=r[1],d=0;for(let g=0;g<6&&u<a;g++){let x=Oe.decodeDigit(n,o,u,Oe.L_AND_G_PATTERNS);s+=String.fromCharCode(48+x%10);for(let E of o)u+=E;x>=10&&(d|=1<<5-g)}s=Pr.determineFirstDigit(s,d),u=Oe.findGuardPattern(n,u,!0,Oe.MIDDLE_PATTERN,new Int32Array(Oe.MIDDLE_PATTERN.length).fill(0))[1];for(let g=0;g<6&&u<a;g++){let x=Oe.decodeDigit(n,o,u,Oe.L_PATTERNS);s+=String.fromCharCode(48+x);for(let E of o)u+=E}return{rowOffset:u,resultString:s}}getBarcodeFormat(){return le.EAN_13}static determineFirstDigit(n,r){for(let s=0;s<10;s++)if(r===this.FIRST_DIGIT_ENCODINGS[s])return n=String.fromCharCode(48+s)+n,n;throw new j}}Pr.FIRST_DIGIT_ENCODINGS=[0,11,13,14,19,25,28,21,22,26];class Jc extends Oe{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(n,r,s){const o=this.decodeMiddleCounters;o[0]=0,o[1]=0,o[2]=0,o[3]=0;let a=n.getSize(),u=r[1];for(let h=0;h<4&&u<a;h++){let g=Oe.decodeDigit(n,o,u,Oe.L_PATTERNS);s+=String.fromCharCode(48+g);for(let x of o)u+=x}u=Oe.findGuardPattern(n,u,!0,Oe.MIDDLE_PATTERN,new Int32Array(Oe.MIDDLE_PATTERN.length).fill(0))[1];for(let h=0;h<4&&u<a;h++){let g=Oe.decodeDigit(n,o,u,Oe.L_PATTERNS);s+=String.fromCharCode(48+g);for(let x of o)u+=x}return{rowOffset:u,resultString:s}}getBarcodeFormat(){return le.EAN_8}}class e1 extends Oe{constructor(){super(...arguments),this.ean13Reader=new Pr}getBarcodeFormat(){return le.UPC_A}decode(n,r){return this.maybeReturnResult(this.ean13Reader.decode(n))}decodeRow(n,r,s){return this.maybeReturnResult(this.ean13Reader.decodeRow(n,r,s))}decodeMiddle(n,r,s){return this.ean13Reader.decodeMiddle(n,r,s)}maybeReturnResult(n){let r=n.getText();if(r.charAt(0)==="0"){let s=new Ke(r.substring(1),null,null,n.getResultPoints(),le.UPC_A);return n.getResultMetadata()!=null&&s.putAllMetadata(n.getResultMetadata()),s}else throw new j}reset(){this.ean13Reader.reset()}}class An extends Oe{constructor(){super(),this.decodeMiddleCounters=new Int32Array(4)}decodeMiddle(n,r,s){const o=this.decodeMiddleCounters.map(g=>g);o[0]=0,o[1]=0,o[2]=0,o[3]=0;const a=n.getSize();let u=r[1],d=0;for(let g=0;g<6&&u<a;g++){const x=An.decodeDigit(n,o,u,An.L_AND_G_PATTERNS);s+=String.fromCharCode(48+x%10);for(let E of o)u+=E;x>=10&&(d|=1<<5-g)}let h=An.determineNumSysAndCheckDigit(s,d);return{rowOffset:u,resultString:h}}decodeEnd(n,r){return An.findGuardPatternWithoutCounters(n,r,!0,An.MIDDLE_END_PATTERN)}checkChecksum(n){return Oe.checkChecksum(An.convertUPCEtoUPCA(n))}static determineNumSysAndCheckDigit(n,r){for(let s=0;s<=1;s++)for(let o=0;o<10;o++)if(r===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[s][o]){let a=String.fromCharCode(48+s),u=String.fromCharCode(48+o);return a+n+u}throw j.getNotFoundInstance()}getBarcodeFormat(){return le.UPC_E}static convertUPCEtoUPCA(n){const r=n.slice(1,7).split("").map(a=>a.charCodeAt(0)),s=new ge;s.append(n.charAt(0));let o=r[5];switch(o){case 0:case 1:case 2:s.appendChars(r,0,2),s.append(o),s.append("0000"),s.appendChars(r,2,3);break;case 3:s.appendChars(r,0,3),s.append("00000"),s.appendChars(r,3,2);break;case 4:s.appendChars(r,0,4),s.append("00000"),s.append(r[4]);break;default:s.appendChars(r,0,5),s.append("0000"),s.append(o);break}return n.length>=8&&s.append(n.charAt(7)),s.toString()}}An.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),An.NUMSYS_AND_CHECK_DIGIT_PATTERNS=[Int32Array.from([56,52,50,49,44,38,35,42,41,37]),Int32Array.from([7,11,13,14,19,25,28,21,22,26])];class Ga extends ut{constructor(n){super();let r=n==null?null:n.get(U.POSSIBLE_FORMATS),s=[];l(r)?(s.push(new Pr),s.push(new e1),s.push(new Jc),s.push(new An)):(r.indexOf(le.EAN_13)>-1&&s.push(new Pr),r.indexOf(le.UPC_A)>-1&&s.push(new e1),r.indexOf(le.EAN_8)>-1&&s.push(new Jc),r.indexOf(le.UPC_E)>-1&&s.push(new An)),this.readers=s}decodeRow(n,r,s){for(let o of this.readers)try{const a=o.decodeRow(n,r,s),u=a.getBarcodeFormat()===le.EAN_13&&a.getText().charAt(0)==="0",d=s==null?null:s.get(U.POSSIBLE_FORMATS),h=d==null||d.includes(le.UPC_A);if(u&&h){const g=a.getRawBytes(),x=new Ke(a.getText().substring(1),g,g?g.length:null,a.getResultPoints(),le.UPC_A);return x.putAllMetadata(a.getResultMetadata()),x}return a}catch{}throw new j}reset(){for(let n of this.readers)n.reset()}}class bt extends ut{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(n,r){for(let s=0;s<r.length;s++)if(ut.patternMatchVariance(n,r[s],bt.MAX_INDIVIDUAL_VARIANCE)<bt.MAX_AVG_VARIANCE)return s;throw new j}static count(n){return Te.sum(new Int32Array(n))}static increment(n,r){let s=0,o=r[0];for(let a=1;a<n.length;a++)r[a]>o&&(o=r[a],s=a);n[s]++}static decrement(n,r){let s=0,o=r[0];for(let a=1;a<n.length;a++)r[a]<o&&(o=r[a],s=a);n[s]--}static isFinderPattern(n){let r=n[0]+n[1],s=r+n[2]+n[3],o=r/s;if(o>=bt.MIN_FINDER_PATTERN_RATIO&&o<=bt.MAX_FINDER_PATTERN_RATIO){let a=Number.MAX_SAFE_INTEGER,u=Number.MIN_SAFE_INTEGER;for(let d of n)d>u&&(u=d),d<a&&(a=d);return u<10*a}return!1}}bt.MAX_AVG_VARIANCE=.2,bt.MAX_INDIVIDUAL_VARIANCE=.45,bt.MIN_FINDER_PATTERN_RATIO=9.5/12,bt.MAX_FINDER_PATTERN_RATIO=12.5/14;class ii{constructor(n,r){this.value=n,this.checksumPortion=r}getValue(){return this.value}getChecksumPortion(){return this.checksumPortion}toString(){return this.value+"("+this.checksumPortion+")"}equals(n){if(!(n instanceof ii))return!1;const r=n;return this.value===r.value&&this.checksumPortion===r.checksumPortion}hashCode(){return this.value^this.checksumPortion}}class lo{constructor(n,r,s,o,a){this.value=n,this.startEnd=r,this.value=n,this.startEnd=r,this.resultPoints=new Array,this.resultPoints.push(new oe(s,a)),this.resultPoints.push(new oe(o,a))}getValue(){return this.value}getStartEnd(){return this.startEnd}getResultPoints(){return this.resultPoints}equals(n){if(!(n instanceof lo))return!1;const r=n;return this.value===r.value}hashCode(){return this.value}}class Mn{constructor(){}static getRSSvalue(n,r,s){let o=0;for(let h of n)o+=h;let a=0,u=0,d=n.length;for(let h=0;h<d-1;h++){let g;for(g=1,u|=1<<h;g<n[h];g++,u&=~(1<<h)){let x=Mn.combins(o-g-1,d-h-2);if(s&&u===0&&o-g-(d-h-1)>=d-h-1&&(x-=Mn.combins(o-g-(d-h),d-h-2)),d-h-1>1){let E=0;for(let A=o-g-(d-h-2);A>r;A--)E+=Mn.combins(o-g-A-1,d-h-3);x-=E*(d-1-h)}else o-g>r&&x--;a+=x}o-=g}return a}static combins(n,r){let s,o;n-r>r?(o=r,s=n-r):(o=n-r,s=r);let a=1,u=1;for(let d=n;d>s;d--)a*=d,u<=o&&(a/=u,u++);for(;u<=o;)a/=u,u++;return a}}class bh{static buildBitArray(n){let r=n.length*2-1;n[n.length-1].getRightChar()==null&&(r-=1);let s=12*r,o=new G(s),a=0,d=n[0].getRightChar().getValue();for(let h=11;h>=0;--h)d&1<<h&&o.set(a),a++;for(let h=1;h<n.length;++h){let g=n[h],x=g.getLeftChar().getValue();for(let E=11;E>=0;--E)x&1<<E&&o.set(a),a++;if(g.getRightChar()!=null){let E=g.getRightChar().getValue();for(let A=11;A>=0;--A)E&1<<A&&o.set(a),a++}}return o}}class Br{constructor(n,r){r?this.decodedInformation=null:(this.finished=n,this.decodedInformation=r)}getDecodedInformation(){return this.decodedInformation}isFinished(){return this.finished}}class Xa{constructor(n){this.newPosition=n}getNewPosition(){return this.newPosition}}class jt extends Xa{constructor(n,r){super(n),this.value=r}getValue(){return this.value}isFNC1(){return this.value===jt.FNC1}}jt.FNC1="$";class Lr extends Xa{constructor(n,r,s){super(n),s?(this.remaining=!0,this.remainingValue=this.remainingValue):(this.remaining=!1,this.remainingValue=0),this.newString=r}getNewString(){return this.newString}isRemaining(){return this.remaining}getRemainingValue(){return this.remainingValue}}class fn extends Xa{constructor(n,r,s){if(super(n),r<0||r>10||s<0||s>10)throw new k;this.firstDigit=r,this.secondDigit=s}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===fn.FNC1}isSecondDigitFNC1(){return this.secondDigit===fn.FNC1}isAnyFNC1(){return this.firstDigit===fn.FNC1||this.secondDigit===fn.FNC1}}fn.FNC1=10;class ne{constructor(){}static parseFieldsInGeneralPurpose(n){if(!n)return null;if(n.length<2)throw new j;let r=n.substring(0,2);for(let a of ne.TWO_DIGIT_DATA_LENGTH)if(a[0]===r)return a[1]===ne.VARIABLE_LENGTH?ne.processVariableAI(2,a[2],n):ne.processFixedAI(2,a[1],n);if(n.length<3)throw new j;let s=n.substring(0,3);for(let a of ne.THREE_DIGIT_DATA_LENGTH)if(a[0]===s)return a[1]===ne.VARIABLE_LENGTH?ne.processVariableAI(3,a[2],n):ne.processFixedAI(3,a[1],n);for(let a of ne.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(a[0]===s)return a[1]===ne.VARIABLE_LENGTH?ne.processVariableAI(4,a[2],n):ne.processFixedAI(4,a[1],n);if(n.length<4)throw new j;let o=n.substring(0,4);for(let a of ne.FOUR_DIGIT_DATA_LENGTH)if(a[0]===o)return a[1]===ne.VARIABLE_LENGTH?ne.processVariableAI(4,a[2],n):ne.processFixedAI(4,a[1],n);throw new j}static processFixedAI(n,r,s){if(s.length<n)throw new j;let o=s.substring(0,n);if(s.length<n+r)throw new j;let a=s.substring(n,n+r),u=s.substring(n+r),d="("+o+")"+a,h=ne.parseFieldsInGeneralPurpose(u);return h==null?d:d+h}static processVariableAI(n,r,s){let o=s.substring(0,n),a;s.length<n+r?a=s.length:a=n+r;let u=s.substring(n,a),d=s.substring(a),h="("+o+")"+u,g=ne.parseFieldsInGeneralPurpose(d);return g==null?h:h+g}}ne.VARIABLE_LENGTH=[],ne.TWO_DIGIT_DATA_LENGTH=[["00",18],["01",14],["02",14],["10",ne.VARIABLE_LENGTH,20],["11",6],["12",6],["13",6],["15",6],["17",6],["20",2],["21",ne.VARIABLE_LENGTH,20],["22",ne.VARIABLE_LENGTH,29],["30",ne.VARIABLE_LENGTH,8],["37",ne.VARIABLE_LENGTH,8],["90",ne.VARIABLE_LENGTH,30],["91",ne.VARIABLE_LENGTH,30],["92",ne.VARIABLE_LENGTH,30],["93",ne.VARIABLE_LENGTH,30],["94",ne.VARIABLE_LENGTH,30],["95",ne.VARIABLE_LENGTH,30],["96",ne.VARIABLE_LENGTH,30],["97",ne.VARIABLE_LENGTH,3],["98",ne.VARIABLE_LENGTH,30],["99",ne.VARIABLE_LENGTH,30]],ne.THREE_DIGIT_DATA_LENGTH=[["240",ne.VARIABLE_LENGTH,30],["241",ne.VARIABLE_LENGTH,30],["242",ne.VARIABLE_LENGTH,6],["250",ne.VARIABLE_LENGTH,30],["251",ne.VARIABLE_LENGTH,30],["253",ne.VARIABLE_LENGTH,17],["254",ne.VARIABLE_LENGTH,20],["400",ne.VARIABLE_LENGTH,30],["401",ne.VARIABLE_LENGTH,30],["402",17],["403",ne.VARIABLE_LENGTH,30],["410",13],["411",13],["412",13],["413",13],["414",13],["420",ne.VARIABLE_LENGTH,20],["421",ne.VARIABLE_LENGTH,15],["422",3],["423",ne.VARIABLE_LENGTH,15],["424",3],["425",3],["426",3]],ne.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH=[["310",6],["311",6],["312",6],["313",6],["314",6],["315",6],["316",6],["320",6],["321",6],["322",6],["323",6],["324",6],["325",6],["326",6],["327",6],["328",6],["329",6],["330",6],["331",6],["332",6],["333",6],["334",6],["335",6],["336",6],["340",6],["341",6],["342",6],["343",6],["344",6],["345",6],["346",6],["347",6],["348",6],["349",6],["350",6],["351",6],["352",6],["353",6],["354",6],["355",6],["356",6],["357",6],["360",6],["361",6],["362",6],["363",6],["364",6],["365",6],["366",6],["367",6],["368",6],["369",6],["390",ne.VARIABLE_LENGTH,15],["391",ne.VARIABLE_LENGTH,18],["392",ne.VARIABLE_LENGTH,15],["393",ne.VARIABLE_LENGTH,18],["703",ne.VARIABLE_LENGTH,30]],ne.FOUR_DIGIT_DATA_LENGTH=[["7001",13],["7002",ne.VARIABLE_LENGTH,30],["7003",10],["8001",14],["8002",ne.VARIABLE_LENGTH,20],["8003",ne.VARIABLE_LENGTH,30],["8004",ne.VARIABLE_LENGTH,30],["8005",6],["8006",18],["8007",ne.VARIABLE_LENGTH,30],["8008",ne.VARIABLE_LENGTH,12],["8018",18],["8020",ne.VARIABLE_LENGTH,25],["8100",6],["8101",10],["8102",2],["8110",ne.VARIABLE_LENGTH,70],["8200",ne.VARIABLE_LENGTH,70]];class si{constructor(n){this.buffer=new ge,this.information=n}decodeAllCodes(n,r){let s=r,o=null;do{let a=this.decodeGeneralPurposeField(s,o),u=ne.parseFieldsInGeneralPurpose(a.getNewString());if(u!=null&&n.append(u),a.isRemaining()?o=""+a.getRemainingValue():o=null,s===a.getNewPosition())break;s=a.getNewPosition()}while(!0);return n.toString()}isStillNumeric(n){if(n+7>this.information.getSize())return n+4<=this.information.getSize();for(let r=n;r<n+3;++r)if(this.information.get(r))return!0;return this.information.get(n+3)}decodeNumeric(n){if(n+7>this.information.getSize()){let a=this.extractNumericValueFromBitArray(n,4);return a===0?new fn(this.information.getSize(),fn.FNC1,fn.FNC1):new fn(this.information.getSize(),a-1,fn.FNC1)}let r=this.extractNumericValueFromBitArray(n,7),s=(r-8)/11,o=(r-8)%11;return new fn(n+7,s,o)}extractNumericValueFromBitArray(n,r){return si.extractNumericValueFromBitArray(this.information,n,r)}static extractNumericValueFromBitArray(n,r,s){let o=0;for(let a=0;a<s;++a)n.get(r+a)&&(o|=1<<s-a-1);return o}decodeGeneralPurposeField(n,r){this.buffer.setLengthToZero(),r!=null&&this.buffer.append(r),this.current.setPosition(n);let s=this.parseBlocks();return s!=null&&s.isRemaining()?new Lr(this.current.getPosition(),this.buffer.toString(),s.getRemainingValue()):new Lr(this.current.getPosition(),this.buffer.toString())}parseBlocks(){let n,r;do{let s=this.current.getPosition();if(this.current.isAlpha()?(r=this.parseAlphaBlock(),n=r.isFinished()):this.current.isIsoIec646()?(r=this.parseIsoIec646Block(),n=r.isFinished()):(r=this.parseNumericBlock(),n=r.isFinished()),!(s!==this.current.getPosition())&&!n)break}while(!n);return r.getDecodedInformation()}parseNumericBlock(){for(;this.isStillNumeric(this.current.getPosition());){let n=this.decodeNumeric(this.current.getPosition());if(this.current.setPosition(n.getNewPosition()),n.isFirstDigitFNC1()){let r;return n.isSecondDigitFNC1()?r=new Lr(this.current.getPosition(),this.buffer.toString()):r=new Lr(this.current.getPosition(),this.buffer.toString(),n.getSecondDigit()),new Br(!0,r)}if(this.buffer.append(n.getFirstDigit()),n.isSecondDigitFNC1()){let r=new Lr(this.current.getPosition(),this.buffer.toString());return new Br(!0,r)}this.buffer.append(n.getSecondDigit())}return this.isNumericToAlphaNumericLatch(this.current.getPosition())&&(this.current.setAlpha(),this.current.incrementPosition(4)),new Br(!1)}parseIsoIec646Block(){for(;this.isStillIsoIec646(this.current.getPosition());){let n=this.decodeIsoIec646(this.current.getPosition());if(this.current.setPosition(n.getNewPosition()),n.isFNC1()){let r=new Lr(this.current.getPosition(),this.buffer.toString());return new Br(!0,r)}this.buffer.append(n.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setAlpha()),new Br(!1)}parseAlphaBlock(){for(;this.isStillAlpha(this.current.getPosition());){let n=this.decodeAlphanumeric(this.current.getPosition());if(this.current.setPosition(n.getNewPosition()),n.isFNC1()){let r=new Lr(this.current.getPosition(),this.buffer.toString());return new Br(!0,r)}this.buffer.append(n.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setIsoIec646()),new Br(!1)}isStillIsoIec646(n){if(n+5>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(n,5);if(r>=5&&r<16)return!0;if(n+7>this.information.getSize())return!1;let s=this.extractNumericValueFromBitArray(n,7);if(s>=64&&s<116)return!0;if(n+8>this.information.getSize())return!1;let o=this.extractNumericValueFromBitArray(n,8);return o>=232&&o<253}decodeIsoIec646(n){let r=this.extractNumericValueFromBitArray(n,5);if(r===15)return new jt(n+5,jt.FNC1);if(r>=5&&r<15)return new jt(n+5,"0"+(r-5));let s=this.extractNumericValueFromBitArray(n,7);if(s>=64&&s<90)return new jt(n+7,""+(s+1));if(s>=90&&s<116)return new jt(n+7,""+(s+7));let o=this.extractNumericValueFromBitArray(n,8),a;switch(o){case 232:a="!";break;case 233:a='"';break;case 234:a="%";break;case 235:a="&";break;case 236:a="'";break;case 237:a="(";break;case 238:a=")";break;case 239:a="*";break;case 240:a="+";break;case 241:a=",";break;case 242:a="-";break;case 243:a=".";break;case 244:a="/";break;case 245:a=":";break;case 246:a=";";break;case 247:a="<";break;case 248:a="=";break;case 249:a=">";break;case 250:a="?";break;case 251:a="_";break;case 252:a=" ";break;default:throw new k}return new jt(n+8,a)}isStillAlpha(n){if(n+5>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(n,5);if(r>=5&&r<16)return!0;if(n+6>this.information.getSize())return!1;let s=this.extractNumericValueFromBitArray(n,6);return s>=16&&s<63}decodeAlphanumeric(n){let r=this.extractNumericValueFromBitArray(n,5);if(r===15)return new jt(n+5,jt.FNC1);if(r>=5&&r<15)return new jt(n+5,"0"+(r-5));let s=this.extractNumericValueFromBitArray(n,6);if(s>=32&&s<58)return new jt(n+6,""+(s+33));let o;switch(s){case 58:o="*";break;case 59:o=",";break;case 60:o="-";break;case 61:o=".";break;case 62:o="/";break;default:throw new Dn("Decoding invalid alphanumeric value: "+s)}return new jt(n+6,o)}isAlphaTo646ToAlphaLatch(n){if(n+1>this.information.getSize())return!1;for(let r=0;r<5&&r+n<this.information.getSize();++r)if(r===2){if(!this.information.get(n+2))return!1}else if(this.information.get(n+r))return!1;return!0}isAlphaOr646ToNumericLatch(n){if(n+3>this.information.getSize())return!1;for(let r=n;r<n+3;++r)if(this.information.get(r))return!1;return!0}isNumericToAlphaNumericLatch(n){if(n+1>this.information.getSize())return!1;for(let r=0;r<4&&r+n<this.information.getSize();++r)if(this.information.get(n+r))return!1;return!0}}class Ya{constructor(n){this.information=n,this.generalDecoder=new si(n)}getInformation(){return this.information}getGeneralDecoder(){return this.generalDecoder}}class Gt extends Ya{constructor(n){super(n)}encodeCompressedGtin(n,r){n.append("(01)");let s=n.length();n.append("9"),this.encodeCompressedGtinWithoutAI(n,r,s)}encodeCompressedGtinWithoutAI(n,r,s){for(let o=0;o<4;++o){let a=this.getGeneralDecoder().extractNumericValueFromBitArray(r+10*o,10);a/100===0&&n.append("0"),a/10===0&&n.append("0"),n.append(a)}Gt.appendCheckDigit(n,s)}static appendCheckDigit(n,r){let s=0;for(let o=0;o<13;o++){let a=n.charAt(o+r).charCodeAt(0)-48;s+=o&1?a:3*a}s=10-s%10,s===10&&(s=0),n.append(s)}}Gt.GTIN_SIZE=40;class oi extends Gt{constructor(n){super(n)}parseInformation(){let n=new ge;n.append("(01)");let r=n.length(),s=this.getGeneralDecoder().extractNumericValueFromBitArray(oi.HEADER_SIZE,4);return n.append(s),this.encodeCompressedGtinWithoutAI(n,oi.HEADER_SIZE+4,r),this.getGeneralDecoder().decodeAllCodes(n,oi.HEADER_SIZE+44)}}oi.HEADER_SIZE=4;class uo extends Ya{constructor(n){super(n)}parseInformation(){let n=new ge;return this.getGeneralDecoder().decodeAllCodes(n,uo.HEADER_SIZE)}}uo.HEADER_SIZE=5;class co extends Gt{constructor(n){super(n)}encodeCompressedWeight(n,r,s){let o=this.getGeneralDecoder().extractNumericValueFromBitArray(r,s);this.addWeightCode(n,o);let a=this.checkWeight(o),u=1e5;for(let d=0;d<5;++d)a/u===0&&n.append("0"),u/=10;n.append(a)}}class kn extends co{constructor(n){super(n)}parseInformation(){if(this.getInformation().getSize()!=kn.HEADER_SIZE+co.GTIN_SIZE+kn.WEIGHT_SIZE)throw new j;let n=new ge;return this.encodeCompressedGtin(n,kn.HEADER_SIZE),this.encodeCompressedWeight(n,kn.HEADER_SIZE+co.GTIN_SIZE,kn.WEIGHT_SIZE),n.toString()}}kn.HEADER_SIZE=5,kn.WEIGHT_SIZE=15;class Oh extends kn{constructor(n){super(n)}addWeightCode(n,r){n.append("(3103)")}checkWeight(n){return n}}class Dh extends kn{constructor(n){super(n)}addWeightCode(n,r){r<1e4?n.append("(3202)"):n.append("(3203)")}checkWeight(n){return n<1e4?n:n-1e4}}class Pn extends Gt{constructor(n){super(n)}parseInformation(){if(this.getInformation().getSize()<Pn.HEADER_SIZE+Gt.GTIN_SIZE)throw new j;let n=new ge;this.encodeCompressedGtin(n,Pn.HEADER_SIZE);let r=this.getGeneralDecoder().extractNumericValueFromBitArray(Pn.HEADER_SIZE+Gt.GTIN_SIZE,Pn.LAST_DIGIT_SIZE);n.append("(392"),n.append(r),n.append(")");let s=this.getGeneralDecoder().decodeGeneralPurposeField(Pn.HEADER_SIZE+Gt.GTIN_SIZE+Pn.LAST_DIGIT_SIZE,null);return n.append(s.getNewString()),n.toString()}}Pn.HEADER_SIZE=8,Pn.LAST_DIGIT_SIZE=2;class Ft extends Gt{constructor(n){super(n)}parseInformation(){if(this.getInformation().getSize()<Ft.HEADER_SIZE+Gt.GTIN_SIZE)throw new j;let n=new ge;this.encodeCompressedGtin(n,Ft.HEADER_SIZE);let r=this.getGeneralDecoder().extractNumericValueFromBitArray(Ft.HEADER_SIZE+Gt.GTIN_SIZE,Ft.LAST_DIGIT_SIZE);n.append("(393"),n.append(r),n.append(")");let s=this.getGeneralDecoder().extractNumericValueFromBitArray(Ft.HEADER_SIZE+Gt.GTIN_SIZE+Ft.LAST_DIGIT_SIZE,Ft.FIRST_THREE_DIGITS_SIZE);s/100==0&&n.append("0"),s/10==0&&n.append("0"),n.append(s);let o=this.getGeneralDecoder().decodeGeneralPurposeField(Ft.HEADER_SIZE+Gt.GTIN_SIZE+Ft.LAST_DIGIT_SIZE+Ft.FIRST_THREE_DIGITS_SIZE,null);return n.append(o.getNewString()),n.toString()}}Ft.HEADER_SIZE=8,Ft.LAST_DIGIT_SIZE=2,Ft.FIRST_THREE_DIGITS_SIZE=10;class Xe extends co{constructor(n,r,s){super(n),this.dateCode=s,this.firstAIdigits=r}parseInformation(){if(this.getInformation().getSize()!=Xe.HEADER_SIZE+Xe.GTIN_SIZE+Xe.WEIGHT_SIZE+Xe.DATE_SIZE)throw new j;let n=new ge;return this.encodeCompressedGtin(n,Xe.HEADER_SIZE),this.encodeCompressedWeight(n,Xe.HEADER_SIZE+Xe.GTIN_SIZE,Xe.WEIGHT_SIZE),this.encodeCompressedDate(n,Xe.HEADER_SIZE+Xe.GTIN_SIZE+Xe.WEIGHT_SIZE),n.toString()}encodeCompressedDate(n,r){let s=this.getGeneralDecoder().extractNumericValueFromBitArray(r,Xe.DATE_SIZE);if(s==38400)return;n.append("("),n.append(this.dateCode),n.append(")");let o=s%32;s/=32;let a=s%12+1;s/=12;let u=s;u/10==0&&n.append("0"),n.append(u),a/10==0&&n.append("0"),n.append(a),o/10==0&&n.append("0"),n.append(o)}addWeightCode(n,r){n.append("("),n.append(this.firstAIdigits),n.append(r/1e5),n.append(")")}checkWeight(n){return n%1e5}}Xe.HEADER_SIZE=8,Xe.WEIGHT_SIZE=20,Xe.DATE_SIZE=16;function t1(y){try{if(y.get(1))return new oi(y);if(!y.get(2))return new uo(y);switch(si.extractNumericValueFromBitArray(y,1,4)){case 4:return new Oh(y);case 5:return new Dh(y)}switch(si.extractNumericValueFromBitArray(y,1,5)){case 12:return new Pn(y);case 13:return new Ft(y)}switch(si.extractNumericValueFromBitArray(y,1,7)){case 56:return new Xe(y,"310","11");case 57:return new Xe(y,"320","11");case 58:return new Xe(y,"310","13");case 59:return new Xe(y,"320","13");case 60:return new Xe(y,"310","15");case 61:return new Xe(y,"320","15");case 62:return new Xe(y,"310","17");case 63:return new Xe(y,"320","17")}}catch(n){throw console.log(n),new Dn("unknown decoder: "+y)}}class or{constructor(n,r,s,o){this.leftchar=n,this.rightchar=r,this.finderpattern=s,this.maybeLast=o}mayBeLast(){return this.maybeLast}getLeftChar(){return this.leftchar}getRightChar(){return this.rightchar}getFinderPattern(){return this.finderpattern}mustBeLast(){return this.rightchar==null}toString(){return"[ "+this.leftchar+", "+this.rightchar+" : "+(this.finderpattern==null?"null":this.finderpattern.getValue())+" ]"}static equals(n,r){return n instanceof or?or.equalsOrNull(n.leftchar,r.leftchar)&&or.equalsOrNull(n.rightchar,r.rightchar)&&or.equalsOrNull(n.finderpattern,r.finderpattern):!1}static equalsOrNull(n,r){return n===null?r===null:or.equals(n,r)}hashCode(){return this.leftchar.getValue()^this.rightchar.getValue()^this.finderpattern.getValue()}}class Za{constructor(n,r,s){this.pairs=n,this.rowNumber=r,this.wasReversed=s}getPairs(){return this.pairs}getRowNumber(){return this.rowNumber}isReversed(){return this.wasReversed}isEquivalent(n){return this.checkEqualitity(this,n)}toString(){return"{ "+this.pairs+" }"}equals(n,r){return n instanceof Za?this.checkEqualitity(n,r)&&n.wasReversed===r.wasReversed:!1}checkEqualitity(n,r){if(!n||!r)return;let s;return n.forEach((o,a)=>{r.forEach(u=>{o.getLeftChar().getValue()===u.getLeftChar().getValue()&&o.getRightChar().getValue()===u.getRightChar().getValue()&&o.getFinderPatter().getValue()===u.getFinderPatter().getValue()&&(s=!0)})}),s}}class Y extends bt{constructor(n){super(...arguments),this.pairs=new Array(Y.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=n===!0}decodeRow(n,r,s){this.pairs.length=0,this.startFromEven=!1;try{return Y.constructResult(this.decodeRow2pairs(n,r))}catch(o){this.verbose&&console.log(o)}return this.pairs.length=0,this.startFromEven=!0,Y.constructResult(this.decodeRow2pairs(n,r))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(n,r){let s=!1;for(;!s;)try{this.pairs.push(this.retrieveNextPair(r,this.pairs,n))}catch(a){if(a instanceof j){if(!this.pairs.length)throw new j;s=!0}}if(this.checkChecksum())return this.pairs;let o;if(this.rows.length?o=!0:o=!1,this.storeRow(n,!1),o){let a=this.checkRowsBoolean(!1);if(a!=null||(a=this.checkRowsBoolean(!0),a!=null))return a}throw new j}checkRowsBoolean(n){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,n&&(this.rows=this.rows.reverse());let r=null;try{r=this.checkRows(new Array,0)}catch(s){this.verbose&&console.log(s)}return n&&(this.rows=this.rows.reverse()),r}checkRows(n,r){for(let s=r;s<this.rows.length;s++){let o=this.rows[s];this.pairs.length=0;for(let u of n)this.pairs.push(u.getPairs());if(this.pairs.push(o.getPairs()),!Y.isValidSequence(this.pairs))continue;if(this.checkChecksum())return this.pairs;let a=new Array(n);a.push(o);try{return this.checkRows(a,s+1)}catch(u){this.verbose&&console.log(u)}}throw new j}static isValidSequence(n){for(let r of Y.FINDER_PATTERN_SEQUENCES){if(n.length>r.length)continue;let s=!0;for(let o=0;o<n.length;o++)if(n[o].getFinderPattern().getValue()!=r[o]){s=!1;break}if(s)return!0}return!1}storeRow(n,r){let s=0,o=!1,a=!1;for(;s<this.rows.length;){let u=this.rows[s];if(u.getRowNumber()>n){a=u.isEquivalent(this.pairs);break}o=u.isEquivalent(this.pairs),s++}a||o||Y.isPartialRow(this.pairs,this.rows)||(this.rows.push(s,new Za(this.pairs,n,r)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(n,r){for(let s of r)if(s.getPairs().length!==n.length){for(let o of s.getPairs())for(let a of n)if(or.equals(o,a))break}}static isPartialRow(n,r){for(let s of r){let o=!0;for(let a of n){let u=!1;for(let d of s.getPairs())if(a.equals(d)){u=!0;break}if(!u){o=!1;break}}if(o)return!0}return!1}getRows(){return this.rows}static constructResult(n){let r=bh.buildBitArray(n),o=t1(r).parseInformation(),a=n[0].getFinderPattern().getResultPoints(),u=n[n.length-1].getFinderPattern().getResultPoints(),d=[a[0],a[1],u[0],u[1]];return new Ke(o,null,null,d,le.RSS_EXPANDED,null)}checkChecksum(){let n=this.pairs.get(0),r=n.getLeftChar(),s=n.getRightChar();if(s==null)return!1;let o=s.getChecksumPortion(),a=2;for(let d=1;d<this.pairs.size();++d){let h=this.pairs.get(d);o+=h.getLeftChar().getChecksumPortion(),a++;let g=h.getRightChar();g!=null&&(o+=g.getChecksumPortion(),a++)}return o%=211,211*(a-4)+o==r.getValue()}static getNextSecondBar(n,r){let s;return n.get(r)?(s=n.getNextUnset(r),s=n.getNextSet(s)):(s=n.getNextSet(r),s=n.getNextUnset(s)),s}retrieveNextPair(n,r,s){let o=r.length%2==0;this.startFromEven&&(o=!o);let a,u=!0,d=-1;do this.findNextPair(n,r,d),a=this.parseFoundFinderPattern(n,s,o),a==null?d=Y.getNextSecondBar(n,this.startEnd[0]):u=!1;while(u);let h=this.decodeDataCharacter(n,a,o,!0);if(!this.isEmptyPair(r)&&r[r.length-1].mustBeLast())throw new j;let g;try{g=this.decodeDataCharacter(n,a,o,!1)}catch(x){g=null,this.verbose&&console.log(x)}return new or(h,g,a,!0)}isEmptyPair(n){return n.length===0}findNextPair(n,r,s){let o=this.getDecodeFinderCounters();o[0]=0,o[1]=0,o[2]=0,o[3]=0;let a=n.getSize(),u;s>=0?u=s:this.isEmptyPair(r)?u=0:u=r[r.length-1].getFinderPattern().getStartEnd()[1];let d=r.length%2!=0;this.startFromEven&&(d=!d);let h=!1;for(;u<a&&(h=!n.get(u),!!h);)u++;let g=0,x=u;for(let E=u;E<a;E++)if(n.get(E)!=h)o[g]++;else{if(g==3){if(d&&Y.reverseCounters(o),Y.isFinderPattern(o)){this.startEnd[0]=x,this.startEnd[1]=E;return}d&&Y.reverseCounters(o),x+=o[0]+o[1],o[0]=o[2],o[1]=o[3],o[2]=0,o[3]=0,g--}else g++;o[g]=1,h=!h}throw new j}static reverseCounters(n){let r=n.length;for(let s=0;s<r/2;++s){let o=n[s];n[s]=n[r-s-1],n[r-s-1]=o}}parseFoundFinderPattern(n,r,s){let o,a,u;if(s){let g=this.startEnd[0]-1;for(;g>=0&&!n.get(g);)g--;g++,o=this.startEnd[0]-g,a=g,u=this.startEnd[1]}else a=this.startEnd[0],u=n.getNextUnset(this.startEnd[1]+1),o=u-this.startEnd[1];let d=this.getDecodeFinderCounters();B.arraycopy(d,0,d,1,d.length-1),d[0]=o;let h;try{h=this.parseFinderValue(d,Y.FINDER_PATTERNS)}catch{return null}return new lo(h,[a,u],a,u,r)}decodeDataCharacter(n,r,s,o){let a=this.getDataCharacterCounters();for(let Fe=0;Fe<a.length;Fe++)a[Fe]=0;if(o)Y.recordPatternInReverse(n,r.getStartEnd()[0],a);else{Y.recordPattern(n,r.getStartEnd()[1],a);for(let Fe=0,_t=a.length-1;Fe<_t;Fe++,_t--){let tn=a[Fe];a[Fe]=a[_t],a[_t]=tn}}let u=17,d=Te.sum(new Int32Array(a))/u,h=(r.getStartEnd()[1]-r.getStartEnd()[0])/15;if(Math.abs(d-h)/h>.3)throw new j;let g=this.getOddCounts(),x=this.getEvenCounts(),E=this.getOddRoundingErrors(),A=this.getEvenRoundingErrors();for(let Fe=0;Fe<a.length;Fe++){let _t=1*a[Fe]/d,tn=_t+.5;if(tn<1){if(_t<.3)throw new j;tn=1}else if(tn>8){if(_t>8.7)throw new j;tn=8}let fi=Fe/2;Fe&1?(x[fi]=tn,A[fi]=_t-tn):(g[fi]=tn,E[fi]=_t-tn)}this.adjustOddEvenCounts(u);let I=4*r.getValue()+(s?0:2)+(o?0:1)-1,b=0,D=0;for(let Fe=g.length-1;Fe>=0;Fe--){if(Y.isNotA1left(r,s,o)){let _t=Y.WEIGHTS[I][2*Fe];D+=g[Fe]*_t}b+=g[Fe]}let L=0;for(let Fe=x.length-1;Fe>=0;Fe--)if(Y.isNotA1left(r,s,o)){let _t=Y.WEIGHTS[I][2*Fe+1];L+=x[Fe]*_t}let z=D+L;if(b&1||b>13||b<4)throw new j;let q=(13-b)/2,$=Y.SYMBOL_WIDEST[q],Z=9-$,ve=Mn.getRSSvalue(g,$,!0),me=Mn.getRSSvalue(x,Z,!1),Yt=Y.EVEN_TOTAL_SUBSET[q],vn=Y.GSUM[q],Zt=ve*Yt+me+vn;return new ii(Zt,z)}static isNotA1left(n,r,s){return!(n.getValue()==0&&r&&s)}adjustOddEvenCounts(n){let r=Te.sum(new Int32Array(this.getOddCounts())),s=Te.sum(new Int32Array(this.getEvenCounts())),o=!1,a=!1;r>13?a=!0:r<4&&(o=!0);let u=!1,d=!1;s>13?d=!0:s<4&&(u=!0);let h=r+s-n,g=(r&1)==1,x=(s&1)==0;if(h==1)if(g){if(x)throw new j;a=!0}else{if(!x)throw new j;d=!0}else if(h==-1)if(g){if(x)throw new j;o=!0}else{if(!x)throw new j;u=!0}else if(h==0){if(g){if(!x)throw new j;r<s?(o=!0,d=!0):(a=!0,u=!0)}else if(x)throw new j}else throw new j;if(o){if(a)throw new j;Y.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(a&&Y.decrement(this.getOddCounts(),this.getOddRoundingErrors()),u){if(d)throw new j;Y.increment(this.getEvenCounts(),this.getOddRoundingErrors())}d&&Y.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}Y.SYMBOL_WIDEST=[7,5,4,3,1],Y.EVEN_TOTAL_SUBSET=[4,20,52,104,204],Y.GSUM=[0,348,1388,2948,3988],Y.FINDER_PATTERNS=[Int32Array.from([1,8,4,1]),Int32Array.from([3,6,4,1]),Int32Array.from([3,4,6,1]),Int32Array.from([3,2,8,1]),Int32Array.from([2,6,5,1]),Int32Array.from([2,2,9,1])],Y.WEIGHTS=[[1,3,9,27,81,32,96,77],[20,60,180,118,143,7,21,63],[189,145,13,39,117,140,209,205],[193,157,49,147,19,57,171,91],[62,186,136,197,169,85,44,132],[185,133,188,142,4,12,36,108],[113,128,173,97,80,29,87,50],[150,28,84,41,123,158,52,156],[46,138,203,187,139,206,196,166],[76,17,51,153,37,111,122,155],[43,129,176,106,107,110,119,146],[16,48,144,10,30,90,59,177],[109,116,137,200,178,112,125,164],[70,210,208,202,184,130,179,115],[134,191,151,31,93,68,204,190],[148,22,66,198,172,94,71,2],[6,18,54,162,64,192,154,40],[120,149,25,75,14,42,126,167],[79,26,78,23,69,207,199,175],[103,98,83,38,114,131,182,124],[161,61,183,127,170,88,53,159],[55,165,73,8,24,72,5,15],[45,135,194,160,58,174,100,89]],Y.FINDER_PAT_A=0,Y.FINDER_PAT_B=1,Y.FINDER_PAT_C=2,Y.FINDER_PAT_D=3,Y.FINDER_PAT_E=4,Y.FINDER_PAT_F=5,Y.FINDER_PATTERN_SEQUENCES=[[Y.FINDER_PAT_A,Y.FINDER_PAT_A],[Y.FINDER_PAT_A,Y.FINDER_PAT_B,Y.FINDER_PAT_B],[Y.FINDER_PAT_A,Y.FINDER_PAT_C,Y.FINDER_PAT_B,Y.FINDER_PAT_D],[Y.FINDER_PAT_A,Y.FINDER_PAT_E,Y.FINDER_PAT_B,Y.FINDER_PAT_D,Y.FINDER_PAT_C],[Y.FINDER_PAT_A,Y.FINDER_PAT_E,Y.FINDER_PAT_B,Y.FINDER_PAT_D,Y.FINDER_PAT_D,Y.FINDER_PAT_F],[Y.FINDER_PAT_A,Y.FINDER_PAT_E,Y.FINDER_PAT_B,Y.FINDER_PAT_D,Y.FINDER_PAT_E,Y.FINDER_PAT_F,Y.FINDER_PAT_F],[Y.FINDER_PAT_A,Y.FINDER_PAT_A,Y.FINDER_PAT_B,Y.FINDER_PAT_B,Y.FINDER_PAT_C,Y.FINDER_PAT_C,Y.FINDER_PAT_D,Y.FINDER_PAT_D],[Y.FINDER_PAT_A,Y.FINDER_PAT_A,Y.FINDER_PAT_B,Y.FINDER_PAT_B,Y.FINDER_PAT_C,Y.FINDER_PAT_C,Y.FINDER_PAT_D,Y.FINDER_PAT_E,Y.FINDER_PAT_E],[Y.FINDER_PAT_A,Y.FINDER_PAT_A,Y.FINDER_PAT_B,Y.FINDER_PAT_B,Y.FINDER_PAT_C,Y.FINDER_PAT_C,Y.FINDER_PAT_D,Y.FINDER_PAT_E,Y.FINDER_PAT_F,Y.FINDER_PAT_F],[Y.FINDER_PAT_A,Y.FINDER_PAT_A,Y.FINDER_PAT_B,Y.FINDER_PAT_B,Y.FINDER_PAT_C,Y.FINDER_PAT_D,Y.FINDER_PAT_D,Y.FINDER_PAT_E,Y.FINDER_PAT_E,Y.FINDER_PAT_F,Y.FINDER_PAT_F]],Y.MAX_PAIRS=11;class Mh extends ii{constructor(n,r,s){super(n,r),this.count=0,this.finderPattern=s}getFinderPattern(){return this.finderPattern}getCount(){return this.count}incrementCount(){this.count++}}class rt extends bt{constructor(){super(...arguments),this.possibleLeftPairs=[],this.possibleRightPairs=[]}decodeRow(n,r,s){const o=this.decodePair(r,!1,n,s);rt.addOrTally(this.possibleLeftPairs,o),r.reverse();let a=this.decodePair(r,!0,n,s);rt.addOrTally(this.possibleRightPairs,a),r.reverse();for(let u of this.possibleLeftPairs)if(u.getCount()>1){for(let d of this.possibleRightPairs)if(d.getCount()>1&&rt.checkChecksum(u,d))return rt.constructResult(u,d)}throw new j}static addOrTally(n,r){if(r==null)return;let s=!1;for(let o of n)if(o.getValue()===r.getValue()){o.incrementCount(),s=!0;break}s||n.push(r)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(n,r){let s=4537077*n.getValue()+r.getValue(),o=new String(s).toString(),a=new ge;for(let g=13-o.length;g>0;g--)a.append("0");a.append(o);let u=0;for(let g=0;g<13;g++){let x=a.charAt(g).charCodeAt(0)-48;u+=g&1?x:3*x}u=10-u%10,u===10&&(u=0),a.append(u.toString());let d=n.getFinderPattern().getResultPoints(),h=r.getFinderPattern().getResultPoints();return new Ke(a.toString(),null,0,[d[0],d[1],h[0],h[1]],le.RSS_14,new Date().getTime())}static checkChecksum(n,r){let s=(n.getChecksumPortion()+16*r.getChecksumPortion())%79,o=9*n.getFinderPattern().getValue()+r.getFinderPattern().getValue();return o>72&&o--,o>8&&o--,s===o}decodePair(n,r,s,o){try{let a=this.findFinderPattern(n,r),u=this.parseFoundFinderPattern(n,s,r,a),d=o==null?null:o.get(U.NEED_RESULT_POINT_CALLBACK);if(d!=null){let x=(a[0]+a[1])/2;r&&(x=n.getSize()-1-x),d.foundPossibleResultPoint(new oe(x,s))}let h=this.decodeDataCharacter(n,u,!0),g=this.decodeDataCharacter(n,u,!1);return new Mh(1597*h.getValue()+g.getValue(),h.getChecksumPortion()+4*g.getChecksumPortion(),u)}catch{return null}}decodeDataCharacter(n,r,s){let o=this.getDataCharacterCounters();for(let L=0;L<o.length;L++)o[L]=0;if(s)ut.recordPatternInReverse(n,r.getStartEnd()[0],o);else{ut.recordPattern(n,r.getStartEnd()[1]+1,o);for(let L=0,z=o.length-1;L<z;L++,z--){let q=o[L];o[L]=o[z],o[z]=q}}let a=s?16:15,u=Te.sum(new Int32Array(o))/a,d=this.getOddCounts(),h=this.getEvenCounts(),g=this.getOddRoundingErrors(),x=this.getEvenRoundingErrors();for(let L=0;L<o.length;L++){let z=o[L]/u,q=Math.floor(z+.5);q<1?q=1:q>8&&(q=8);let $=Math.floor(L/2);L&1?(h[$]=q,x[$]=z-q):(d[$]=q,g[$]=z-q)}this.adjustOddEvenCounts(s,a);let E=0,A=0;for(let L=d.length-1;L>=0;L--)A*=9,A+=d[L],E+=d[L];let I=0,b=0;for(let L=h.length-1;L>=0;L--)I*=9,I+=h[L],b+=h[L];let D=A+3*I;if(s){if(E&1||E>12||E<4)throw new j;let L=(12-E)/2,z=rt.OUTSIDE_ODD_WIDEST[L],q=9-z,$=Mn.getRSSvalue(d,z,!1),Z=Mn.getRSSvalue(h,q,!0),ve=rt.OUTSIDE_EVEN_TOTAL_SUBSET[L],me=rt.OUTSIDE_GSUM[L];return new ii($*ve+Z+me,D)}else{if(b&1||b>10||b<4)throw new j;let L=(10-b)/2,z=rt.INSIDE_ODD_WIDEST[L],q=9-z,$=Mn.getRSSvalue(d,z,!0),Z=Mn.getRSSvalue(h,q,!1),ve=rt.INSIDE_ODD_TOTAL_SUBSET[L],me=rt.INSIDE_GSUM[L];return new ii(Z*ve+$+me,D)}}findFinderPattern(n,r){let s=this.getDecodeFinderCounters();s[0]=0,s[1]=0,s[2]=0,s[3]=0;let o=n.getSize(),a=!1,u=0;for(;u<o&&(a=!n.get(u),r!==a);)u++;let d=0,h=u;for(let g=u;g<o;g++)if(n.get(g)!==a)s[d]++;else{if(d===3){if(bt.isFinderPattern(s))return[h,g];h+=s[0]+s[1],s[0]=s[2],s[1]=s[3],s[2]=0,s[3]=0,d--}else d++;s[d]=1,a=!a}throw new j}parseFoundFinderPattern(n,r,s,o){let a=n.get(o[0]),u=o[0]-1;for(;u>=0&&a!==n.get(u);)u--;u++;const d=o[0]-u,h=this.getDecodeFinderCounters(),g=new Int32Array(h.length);B.arraycopy(h,0,g,1,h.length-1),g[0]=d;const x=this.parseFinderValue(g,rt.FINDER_PATTERNS);let E=u,A=o[1];return s&&(E=n.getSize()-1-E,A=n.getSize()-1-A),new lo(x,[u,o[1]],E,A,r)}adjustOddEvenCounts(n,r){let s=Te.sum(new Int32Array(this.getOddCounts())),o=Te.sum(new Int32Array(this.getEvenCounts())),a=!1,u=!1,d=!1,h=!1;n?(s>12?u=!0:s<4&&(a=!0),o>12?h=!0:o<4&&(d=!0)):(s>11?u=!0:s<5&&(a=!0),o>10?h=!0:o<4&&(d=!0));let g=s+o-r,x=(s&1)===(n?1:0),E=(o&1)===1;if(g===1)if(x){if(E)throw new j;u=!0}else{if(!E)throw new j;h=!0}else if(g===-1)if(x){if(E)throw new j;a=!0}else{if(!E)throw new j;d=!0}else if(g===0){if(x){if(!E)throw new j;s<o?(a=!0,h=!0):(u=!0,d=!0)}else if(E)throw new j}else throw new j;if(a){if(u)throw new j;bt.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(u&&bt.decrement(this.getOddCounts(),this.getOddRoundingErrors()),d){if(h)throw new j;bt.increment(this.getEvenCounts(),this.getOddRoundingErrors())}h&&bt.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}rt.OUTSIDE_EVEN_TOTAL_SUBSET=[1,10,34,70,126],rt.INSIDE_ODD_TOTAL_SUBSET=[4,20,48,81],rt.OUTSIDE_GSUM=[0,161,961,2015,2715],rt.INSIDE_GSUM=[0,336,1036,1516],rt.OUTSIDE_ODD_WIDEST=[8,6,4,3,1],rt.INSIDE_ODD_WIDEST=[2,4,6,8],rt.FINDER_PATTERNS=[Int32Array.from([3,8,2,1]),Int32Array.from([3,5,5,1]),Int32Array.from([3,3,7,1]),Int32Array.from([3,1,9,1]),Int32Array.from([2,7,4,1]),Int32Array.from([2,5,6,1]),Int32Array.from([2,3,8,1]),Int32Array.from([1,5,7,1]),Int32Array.from([1,3,9,1])];class ai extends ut{constructor(n,r){super(),this.readers=[],this.verbose=r===!0;const s=n?n.get(U.POSSIBLE_FORMATS):null,o=n&&n.get(U.ASSUME_CODE_39_CHECK_DIGIT)!==void 0;s?((s.includes(le.EAN_13)||s.includes(le.UPC_A)||s.includes(le.EAN_8)||s.includes(le.UPC_E))&&this.readers.push(new Ga(n)),s.includes(le.CODE_39)&&this.readers.push(new ft(o)),s.includes(le.CODE_128)&&this.readers.push(new J),s.includes(le.ITF)&&this.readers.push(new Be),s.includes(le.RSS_14)&&this.readers.push(new rt),s.includes(le.RSS_EXPANDED)&&this.readers.push(new Y(this.verbose))):(this.readers.push(new Ga(n)),this.readers.push(new ft),this.readers.push(new Ga(n)),this.readers.push(new J),this.readers.push(new Be),this.readers.push(new rt),this.readers.push(new Y(this.verbose)))}decodeRow(n,r,s){for(let o=0;o<this.readers.length;o++)try{return this.readers[o].decodeRow(n,r,s)}catch{}throw new j}reset(){this.readers.forEach(n=>n.reset())}}class kh extends cn{constructor(n=500,r){super(new ai(r),n,r)}}class Me{constructor(n,r,s){this.ecCodewords=n,this.ecBlocks=[r],s&&this.ecBlocks.push(s)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class De{constructor(n,r){this.count=n,this.dataCodewords=r}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class Se{constructor(n,r,s,o,a,u){this.versionNumber=n,this.symbolSizeRows=r,this.symbolSizeColumns=s,this.dataRegionSizeRows=o,this.dataRegionSizeColumns=a,this.ecBlocks=u;let d=0;const h=u.getECCodewords(),g=u.getECBlocks();for(let x of g)d+=x.getCount()*(x.getDataCodewords()+h);this.totalCodewords=d}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}static getVersionForDimensions(n,r){if(n&1||r&1)throw new k;for(let s of Se.VERSIONS)if(s.symbolSizeRows===n&&s.symbolSizeColumns===r)return s;throw new k}toString(){return""+this.versionNumber}static buildVersions(){return[new Se(1,10,10,8,8,new Me(5,new De(1,3))),new Se(2,12,12,10,10,new Me(7,new De(1,5))),new Se(3,14,14,12,12,new Me(10,new De(1,8))),new Se(4,16,16,14,14,new Me(12,new De(1,12))),new Se(5,18,18,16,16,new Me(14,new De(1,18))),new Se(6,20,20,18,18,new Me(18,new De(1,22))),new Se(7,22,22,20,20,new Me(20,new De(1,30))),new Se(8,24,24,22,22,new Me(24,new De(1,36))),new Se(9,26,26,24,24,new Me(28,new De(1,44))),new Se(10,32,32,14,14,new Me(36,new De(1,62))),new Se(11,36,36,16,16,new Me(42,new De(1,86))),new Se(12,40,40,18,18,new Me(48,new De(1,114))),new Se(13,44,44,20,20,new Me(56,new De(1,144))),new Se(14,48,48,22,22,new Me(68,new De(1,174))),new Se(15,52,52,24,24,new Me(42,new De(2,102))),new Se(16,64,64,14,14,new Me(56,new De(2,140))),new Se(17,72,72,16,16,new Me(36,new De(4,92))),new Se(18,80,80,18,18,new Me(48,new De(4,114))),new Se(19,88,88,20,20,new Me(56,new De(4,144))),new Se(20,96,96,22,22,new Me(68,new De(4,174))),new Se(21,104,104,24,24,new Me(56,new De(6,136))),new Se(22,120,120,18,18,new Me(68,new De(6,175))),new Se(23,132,132,20,20,new Me(62,new De(8,163))),new Se(24,144,144,22,22,new Me(62,new De(8,156),new De(2,155))),new Se(25,8,18,6,16,new Me(7,new De(1,5))),new Se(26,8,32,6,14,new Me(11,new De(1,10))),new Se(27,12,26,10,24,new Me(14,new De(1,16))),new Se(28,12,36,10,16,new Me(18,new De(1,22))),new Se(29,16,36,14,16,new Me(24,new De(1,32))),new Se(30,16,48,14,22,new Me(28,new De(1,49)))]}}Se.VERSIONS=Se.buildVersions();class Ka{constructor(n){const r=n.getHeight();if(r<8||r>144||r&1)throw new k;this.version=Ka.readVersion(n),this.mappingBitMatrix=this.extractDataRegion(n),this.readMappingMatrix=new _e(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(n){const r=n.getHeight(),s=n.getWidth();return Se.getVersionForDimensions(r,s)}readCodewords(){const n=new Int8Array(this.version.getTotalCodewords());let r=0,s=4,o=0;const a=this.mappingBitMatrix.getHeight(),u=this.mappingBitMatrix.getWidth();let d=!1,h=!1,g=!1,x=!1;do if(s===a&&o===0&&!d)n[r++]=this.readCorner1(a,u)&255,s-=2,o+=2,d=!0;else if(s===a-2&&o===0&&u&3&&!h)n[r++]=this.readCorner2(a,u)&255,s-=2,o+=2,h=!0;else if(s===a+4&&o===2&&!(u&7)&&!g)n[r++]=this.readCorner3(a,u)&255,s-=2,o+=2,g=!0;else if(s===a-2&&o===0&&(u&7)===4&&!x)n[r++]=this.readCorner4(a,u)&255,s-=2,o+=2,x=!0;else{do s<a&&o>=0&&!this.readMappingMatrix.get(o,s)&&(n[r++]=this.readUtah(s,o,a,u)&255),s-=2,o+=2;while(s>=0&&o<u);s+=1,o+=3;do s>=0&&o<u&&!this.readMappingMatrix.get(o,s)&&(n[r++]=this.readUtah(s,o,a,u)&255),s+=2,o-=2;while(s<a&&o>=0);s+=3,o+=1}while(s<a||o<u);if(r!==this.version.getTotalCodewords())throw new k;return n}readModule(n,r,s,o){return n<0&&(n+=s,r+=4-(s+4&7)),r<0&&(r+=o,n+=4-(o+4&7)),this.readMappingMatrix.set(r,n),this.mappingBitMatrix.get(r,n)}readUtah(n,r,s,o){let a=0;return this.readModule(n-2,r-2,s,o)&&(a|=1),a<<=1,this.readModule(n-2,r-1,s,o)&&(a|=1),a<<=1,this.readModule(n-1,r-2,s,o)&&(a|=1),a<<=1,this.readModule(n-1,r-1,s,o)&&(a|=1),a<<=1,this.readModule(n-1,r,s,o)&&(a|=1),a<<=1,this.readModule(n,r-2,s,o)&&(a|=1),a<<=1,this.readModule(n,r-1,s,o)&&(a|=1),a<<=1,this.readModule(n,r,s,o)&&(a|=1),a}readCorner1(n,r){let s=0;return this.readModule(n-1,0,n,r)&&(s|=1),s<<=1,this.readModule(n-1,1,n,r)&&(s|=1),s<<=1,this.readModule(n-1,2,n,r)&&(s|=1),s<<=1,this.readModule(0,r-2,n,r)&&(s|=1),s<<=1,this.readModule(0,r-1,n,r)&&(s|=1),s<<=1,this.readModule(1,r-1,n,r)&&(s|=1),s<<=1,this.readModule(2,r-1,n,r)&&(s|=1),s<<=1,this.readModule(3,r-1,n,r)&&(s|=1),s}readCorner2(n,r){let s=0;return this.readModule(n-3,0,n,r)&&(s|=1),s<<=1,this.readModule(n-2,0,n,r)&&(s|=1),s<<=1,this.readModule(n-1,0,n,r)&&(s|=1),s<<=1,this.readModule(0,r-4,n,r)&&(s|=1),s<<=1,this.readModule(0,r-3,n,r)&&(s|=1),s<<=1,this.readModule(0,r-2,n,r)&&(s|=1),s<<=1,this.readModule(0,r-1,n,r)&&(s|=1),s<<=1,this.readModule(1,r-1,n,r)&&(s|=1),s}readCorner3(n,r){let s=0;return this.readModule(n-1,0,n,r)&&(s|=1),s<<=1,this.readModule(n-1,r-1,n,r)&&(s|=1),s<<=1,this.readModule(0,r-3,n,r)&&(s|=1),s<<=1,this.readModule(0,r-2,n,r)&&(s|=1),s<<=1,this.readModule(0,r-1,n,r)&&(s|=1),s<<=1,this.readModule(1,r-3,n,r)&&(s|=1),s<<=1,this.readModule(1,r-2,n,r)&&(s|=1),s<<=1,this.readModule(1,r-1,n,r)&&(s|=1),s}readCorner4(n,r){let s=0;return this.readModule(n-3,0,n,r)&&(s|=1),s<<=1,this.readModule(n-2,0,n,r)&&(s|=1),s<<=1,this.readModule(n-1,0,n,r)&&(s|=1),s<<=1,this.readModule(0,r-2,n,r)&&(s|=1),s<<=1,this.readModule(0,r-1,n,r)&&(s|=1),s<<=1,this.readModule(1,r-1,n,r)&&(s|=1),s<<=1,this.readModule(2,r-1,n,r)&&(s|=1),s<<=1,this.readModule(3,r-1,n,r)&&(s|=1),s}extractDataRegion(n){const r=this.version.getSymbolSizeRows(),s=this.version.getSymbolSizeColumns();if(n.getHeight()!==r)throw new v("Dimension of bitMatrix must match the version size");const o=this.version.getDataRegionSizeRows(),a=this.version.getDataRegionSizeColumns(),u=r/o|0,d=s/a|0,h=u*o,g=d*a,x=new _e(g,h);for(let E=0;E<u;++E){const A=E*o;for(let I=0;I<d;++I){const b=I*a;for(let D=0;D<o;++D){const L=E*(o+2)+1+D,z=A+D;for(let q=0;q<a;++q){const $=I*(a+2)+1+q;if(n.get($,L)){const Z=b+q;x.set(Z,z)}}}}}return x}}class Qa{constructor(n,r){this.numDataCodewords=n,this.codewords=r}static getDataBlocks(n,r){const s=r.getECBlocks();let o=0;const a=s.getECBlocks();for(let D of a)o+=D.getCount();const u=new Array(o);let d=0;for(let D of a)for(let L=0;L<D.getCount();L++){const z=D.getDataCodewords(),q=s.getECCodewords()+z;u[d++]=new Qa(z,new Uint8Array(q))}const g=u[0].codewords.length-s.getECCodewords(),x=g-1;let E=0;for(let D=0;D<x;D++)for(let L=0;L<d;L++)u[L].codewords[D]=n[E++];const A=r.getVersionNumber()===24,I=A?8:d;for(let D=0;D<I;D++)u[D].codewords[g-1]=n[E++];const b=u[0].codewords.length;for(let D=g;D<b;D++)for(let L=0;L<d;L++){const z=A?(L+8)%d:L,q=A&&z>7?D-1:D;u[z].codewords[q]=n[E++]}if(E!==n.length)throw new v;return u}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class qa{constructor(n){this.bytes=n,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(n){if(n<1||n>32||n>this.available())throw new v(""+n);let r=0,s=this.bitOffset,o=this.byteOffset;const a=this.bytes;if(s>0){const u=8-s,d=n<u?n:u,h=u-d,g=255>>8-d<<h;r=(a[o]&g)>>h,n-=d,s+=d,s===8&&(s=0,o++)}if(n>0){for(;n>=8;)r=r<<8|a[o]&255,o++,n-=8;if(n>0){const u=8-n,d=255>>u<<u;r=r<<n|(a[o]&d)>>u,s+=n}}return this.bitOffset=s,this.byteOffset=o,r}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var dt;(function(y){y[y.PAD_ENCODE=0]="PAD_ENCODE",y[y.ASCII_ENCODE=1]="ASCII_ENCODE",y[y.C40_ENCODE=2]="C40_ENCODE",y[y.TEXT_ENCODE=3]="TEXT_ENCODE",y[y.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",y[y.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",y[y.BASE256_ENCODE=6]="BASE256_ENCODE"})(dt||(dt={}));class ar{static decode(n){const r=new qa(n),s=new ge,o=new ge,a=new Array;let u=dt.ASCII_ENCODE;do if(u===dt.ASCII_ENCODE)u=this.decodeAsciiSegment(r,s,o);else{switch(u){case dt.C40_ENCODE:this.decodeC40Segment(r,s);break;case dt.TEXT_ENCODE:this.decodeTextSegment(r,s);break;case dt.ANSIX12_ENCODE:this.decodeAnsiX12Segment(r,s);break;case dt.EDIFACT_ENCODE:this.decodeEdifactSegment(r,s);break;case dt.BASE256_ENCODE:this.decodeBase256Segment(r,s,a);break;default:throw new k}u=dt.ASCII_ENCODE}while(u!==dt.PAD_ENCODE&&r.available()>0);return o.length()>0&&s.append(o.toString()),new Qi(n,s.toString(),a.length===0?null:a,null)}static decodeAsciiSegment(n,r,s){let o=!1;do{let a=n.readBits(8);if(a===0)throw new k;if(a<=128)return o&&(a+=128),r.append(String.fromCharCode(a-1)),dt.ASCII_ENCODE;if(a===129)return dt.PAD_ENCODE;if(a<=229){const u=a-130;u<10&&r.append("0"),r.append(""+u)}else switch(a){case 230:return dt.C40_ENCODE;case 231:return dt.BASE256_ENCODE;case 232:r.append("");break;case 233:case 234:break;case 235:o=!0;break;case 236:r.append("[)>05"),s.insert(0,"");break;case 237:r.append("[)>06"),s.insert(0,"");break;case 238:return dt.ANSIX12_ENCODE;case 239:return dt.TEXT_ENCODE;case 240:return dt.EDIFACT_ENCODE;case 241:break;default:if(a!==254||n.available()!==0)throw new k;break}}while(n.available()>0);return dt.ASCII_ENCODE}static decodeC40Segment(n,r){let s=!1;const o=[];let a=0;do{if(n.available()===8)return;const u=n.readBits(8);if(u===254)return;this.parseTwoBytes(u,n.readBits(8),o);for(let d=0;d<3;d++){const h=o[d];switch(a){case 0:if(h<3)a=h+1;else if(h<this.C40_BASIC_SET_CHARS.length){const g=this.C40_BASIC_SET_CHARS[h];s?(r.append(String.fromCharCode(g.charCodeAt(0)+128)),s=!1):r.append(g)}else throw new k;break;case 1:s?(r.append(String.fromCharCode(h+128)),s=!1):r.append(String.fromCharCode(h)),a=0;break;case 2:if(h<this.C40_SHIFT2_SET_CHARS.length){const g=this.C40_SHIFT2_SET_CHARS[h];s?(r.append(String.fromCharCode(g.charCodeAt(0)+128)),s=!1):r.append(g)}else switch(h){case 27:r.append("");break;case 30:s=!0;break;default:throw new k}a=0;break;case 3:s?(r.append(String.fromCharCode(h+224)),s=!1):r.append(String.fromCharCode(h+96)),a=0;break;default:throw new k}}}while(n.available()>0)}static decodeTextSegment(n,r){let s=!1,o=[],a=0;do{if(n.available()===8)return;const u=n.readBits(8);if(u===254)return;this.parseTwoBytes(u,n.readBits(8),o);for(let d=0;d<3;d++){const h=o[d];switch(a){case 0:if(h<3)a=h+1;else if(h<this.TEXT_BASIC_SET_CHARS.length){const g=this.TEXT_BASIC_SET_CHARS[h];s?(r.append(String.fromCharCode(g.charCodeAt(0)+128)),s=!1):r.append(g)}else throw new k;break;case 1:s?(r.append(String.fromCharCode(h+128)),s=!1):r.append(String.fromCharCode(h)),a=0;break;case 2:if(h<this.TEXT_SHIFT2_SET_CHARS.length){const g=this.TEXT_SHIFT2_SET_CHARS[h];s?(r.append(String.fromCharCode(g.charCodeAt(0)+128)),s=!1):r.append(g)}else switch(h){case 27:r.append("");break;case 30:s=!0;break;default:throw new k}a=0;break;case 3:if(h<this.TEXT_SHIFT3_SET_CHARS.length){const g=this.TEXT_SHIFT3_SET_CHARS[h];s?(r.append(String.fromCharCode(g.charCodeAt(0)+128)),s=!1):r.append(g),a=0}else throw new k;break;default:throw new k}}}while(n.available()>0)}static decodeAnsiX12Segment(n,r){const s=[];do{if(n.available()===8)return;const o=n.readBits(8);if(o===254)return;this.parseTwoBytes(o,n.readBits(8),s);for(let a=0;a<3;a++){const u=s[a];switch(u){case 0:r.append("\r");break;case 1:r.append("*");break;case 2:r.append(">");break;case 3:r.append(" ");break;default:if(u<14)r.append(String.fromCharCode(u+44));else if(u<40)r.append(String.fromCharCode(u+51));else throw new k;break}}}while(n.available()>0)}static parseTwoBytes(n,r,s){let o=(n<<8)+r-1,a=Math.floor(o/1600);s[0]=a,o-=a*1600,a=Math.floor(o/40),s[1]=a,s[2]=o-a*40}static decodeEdifactSegment(n,r){do{if(n.available()<=16)return;for(let s=0;s<4;s++){let o=n.readBits(6);if(o===31){const a=8-n.getBitOffset();a!==8&&n.readBits(a);return}o&32||(o|=64),r.append(String.fromCharCode(o))}}while(n.available()>0)}static decodeBase256Segment(n,r,s){let o=1+n.getByteOffset();const a=this.unrandomize255State(n.readBits(8),o++);let u;if(a===0?u=n.available()/8|0:a<250?u=a:u=250*(a-249)+this.unrandomize255State(n.readBits(8),o++),u<0)throw new k;const d=new Uint8Array(u);for(let h=0;h<u;h++){if(n.available()<8)throw new k;d[h]=this.unrandomize255State(n.readBits(8),o++)}s.push(d);try{r.append(Ee.decode(d,ie.ISO88591))}catch(h){throw new Dn("Platform does not support required encoding: "+h.message)}}static unrandomize255State(n,r){const s=149*r%255+1,o=n-s;return o>=0?o:o+256}}ar.C40_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],ar.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],ar.TEXT_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],ar.TEXT_SHIFT2_SET_CHARS=ar.C40_SHIFT2_SET_CHARS,ar.TEXT_SHIFT3_SET_CHARS=["`","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","|","}","~",""];class Ph{constructor(){this.rsDecoder=new $i(be.DATA_MATRIX_FIELD_256)}decode(n){const r=new Ka(n),s=r.getVersion(),o=r.readCodewords(),a=Qa.getDataBlocks(o,s);let u=0;for(let g of a)u+=g.getNumDataCodewords();const d=new Uint8Array(u),h=a.length;for(let g=0;g<h;g++){const x=a[g],E=x.getCodewords(),A=x.getNumDataCodewords();this.correctErrors(E,A);for(let I=0;I<A;I++)d[I*h+g]=E[I]}return ar.decode(d)}correctErrors(n,r){const s=new Int32Array(n);try{this.rsDecoder.decode(s,n.length-r)}catch{throw new M}for(let o=0;o<r;o++)n[o]=s[o]}}class at{constructor(n){this.image=n,this.rectangleDetector=new Gn(this.image)}detect(){const n=this.rectangleDetector.detect();let r=this.detectSolid1(n);if(r=this.detectSolid2(r),r[3]=this.correctTopRight(r),!r[3])throw new j;r=this.shiftToModuleCenter(r);const s=r[0],o=r[1],a=r[2],u=r[3];let d=this.transitionsBetween(s,u)+1,h=this.transitionsBetween(a,u)+1;(d&1)===1&&(d+=1),(h&1)===1&&(h+=1),4*d<7*h&&4*h<7*d&&(d=h=Math.max(d,h));let g=at.sampleGrid(this.image,s,o,a,u,d,h);return new oo(g,[s,o,a,u])}static shiftPoint(n,r,s){let o=(r.getX()-n.getX())/(s+1),a=(r.getY()-n.getY())/(s+1);return new oe(n.getX()+o,n.getY()+a)}static moveAway(n,r,s){let o=n.getX(),a=n.getY();return o<r?o-=1:o+=1,a<s?a-=1:a+=1,new oe(o,a)}detectSolid1(n){let r=n[0],s=n[1],o=n[3],a=n[2],u=this.transitionsBetween(r,s),d=this.transitionsBetween(s,o),h=this.transitionsBetween(o,a),g=this.transitionsBetween(a,r),x=u,E=[a,r,s,o];return x>d&&(x=d,E[0]=r,E[1]=s,E[2]=o,E[3]=a),x>h&&(x=h,E[0]=s,E[1]=o,E[2]=a,E[3]=r),x>g&&(E[0]=o,E[1]=a,E[2]=r,E[3]=s),E}detectSolid2(n){let r=n[0],s=n[1],o=n[2],a=n[3],u=this.transitionsBetween(r,a),d=at.shiftPoint(s,o,(u+1)*4),h=at.shiftPoint(o,s,(u+1)*4),g=this.transitionsBetween(d,r),x=this.transitionsBetween(h,a);return g<x?(n[0]=r,n[1]=s,n[2]=o,n[3]=a):(n[0]=s,n[1]=o,n[2]=a,n[3]=r),n}correctTopRight(n){let r=n[0],s=n[1],o=n[2],a=n[3],u=this.transitionsBetween(r,a),d=this.transitionsBetween(s,a),h=at.shiftPoint(r,s,(d+1)*4),g=at.shiftPoint(o,s,(u+1)*4);u=this.transitionsBetween(h,a),d=this.transitionsBetween(g,a);let x=new oe(a.getX()+(o.getX()-s.getX())/(u+1),a.getY()+(o.getY()-s.getY())/(u+1)),E=new oe(a.getX()+(r.getX()-s.getX())/(d+1),a.getY()+(r.getY()-s.getY())/(d+1));if(!this.isValid(x))return this.isValid(E)?E:null;if(!this.isValid(E))return x;let A=this.transitionsBetween(h,x)+this.transitionsBetween(g,x),I=this.transitionsBetween(h,E)+this.transitionsBetween(g,E);return A>I?x:E}shiftToModuleCenter(n){let r=n[0],s=n[1],o=n[2],a=n[3],u=this.transitionsBetween(r,a)+1,d=this.transitionsBetween(o,a)+1,h=at.shiftPoint(r,s,d*4),g=at.shiftPoint(o,s,u*4);u=this.transitionsBetween(h,a)+1,d=this.transitionsBetween(g,a)+1,(u&1)===1&&(u+=1),(d&1)===1&&(d+=1);let x=(r.getX()+s.getX()+o.getX()+a.getX())/4,E=(r.getY()+s.getY()+o.getY()+a.getY())/4;r=at.moveAway(r,x,E),s=at.moveAway(s,x,E),o=at.moveAway(o,x,E),a=at.moveAway(a,x,E);let A,I;return h=at.shiftPoint(r,s,d*4),h=at.shiftPoint(h,a,u*4),A=at.shiftPoint(s,r,d*4),A=at.shiftPoint(A,o,u*4),g=at.shiftPoint(o,a,d*4),g=at.shiftPoint(g,s,u*4),I=at.shiftPoint(a,o,d*4),I=at.shiftPoint(I,r,u*4),[h,A,g,I]}isValid(n){return n.getX()>=0&&n.getX()<this.image.getWidth()&&n.getY()>0&&n.getY()<this.image.getHeight()}static sampleGrid(n,r,s,o,a,u,d){return sr.getInstance().sampleGrid(n,u,d,.5,.5,u-.5,.5,u-.5,d-.5,.5,d-.5,r.getX(),r.getY(),a.getX(),a.getY(),o.getX(),o.getY(),s.getX(),s.getY())}transitionsBetween(n,r){let s=Math.trunc(n.getX()),o=Math.trunc(n.getY()),a=Math.trunc(r.getX()),u=Math.trunc(r.getY()),d=Math.abs(u-o)>Math.abs(a-s);if(d){let D=s;s=o,o=D,D=a,a=u,u=D}let h=Math.abs(a-s),g=Math.abs(u-o),x=-h/2,E=o<u?1:-1,A=s<a?1:-1,I=0,b=this.image.get(d?o:s,d?s:o);for(let D=s,L=o;D!==a;D+=A){let z=this.image.get(d?L:D,d?D:L);if(z!==b&&(I++,b=z),x+=g,x>0){if(L===u)break;L+=E,x-=h}}return I}}class lr{constructor(){this.decoder=new Ph}decode(n,r=null){let s,o;if(r!=null&&r.has(U.PURE_BARCODE)){const g=lr.extractPureBits(n.getBlackMatrix());s=this.decoder.decode(g),o=lr.NO_POINTS}else{const g=new at(n.getBlackMatrix()).detect();s=this.decoder.decode(g.getBits()),o=g.getPoints()}const a=s.getRawBytes(),u=new Ke(s.getText(),a,8*a.length,o,le.DATA_MATRIX,B.currentTimeMillis()),d=s.getByteSegments();d!=null&&u.putMetadata(mt.BYTE_SEGMENTS,d);const h=s.getECLevel();return h!=null&&u.putMetadata(mt.ERROR_CORRECTION_LEVEL,h),u}reset(){}static extractPureBits(n){const r=n.getTopLeftOnBit(),s=n.getBottomRightOnBit();if(r==null||s==null)throw new j;const o=this.moduleSize(r,n);let a=r[1];const u=s[1];let d=r[0];const g=(s[0]-d+1)/o,x=(u-a+1)/o;if(g<=0||x<=0)throw new j;const E=o/2;a+=E,d+=E;const A=new _e(g,x);for(let I=0;I<x;I++){const b=a+I*o;for(let D=0;D<g;D++)n.get(d+D*o,b)&&A.set(D,I)}return A}static moduleSize(n,r){const s=r.getWidth();let o=n[0];const a=n[1];for(;o<s&&r.get(o,a);)o++;if(o===s)throw new j;const u=o-n[0];if(u===0)throw new j;return u}}lr.NO_POINTS=[];class Bh extends cn{constructor(n=500){super(new lr,n)}}var li;(function(y){y[y.L=0]="L",y[y.M=1]="M",y[y.Q=2]="Q",y[y.H=3]="H"})(li||(li={}));class We{constructor(n,r,s){this.value=n,this.stringValue=r,this.bits=s,We.FOR_BITS.set(s,this),We.FOR_VALUE.set(n,this)}getValue(){return this.value}getBits(){return this.bits}static fromString(n){switch(n){case"L":return We.L;case"M":return We.M;case"Q":return We.Q;case"H":return We.H;default:throw new _(n+"not available")}}toString(){return this.stringValue}equals(n){if(!(n instanceof We))return!1;const r=n;return this.value===r.value}static forBits(n){if(n<0||n>=We.FOR_BITS.size)throw new v;return We.FOR_BITS.get(n)}}We.FOR_BITS=new Map,We.FOR_VALUE=new Map,We.L=new We(li.L,"L",1),We.M=new We(li.M,"M",0),We.Q=new We(li.Q,"Q",3),We.H=new We(li.H,"H",2);class Ot{constructor(n){this.errorCorrectionLevel=We.forBits(n>>3&3),this.dataMask=n&7}static numBitsDiffering(n,r){return N.bitCount(n^r)}static decodeFormatInformation(n,r){const s=Ot.doDecodeFormatInformation(n,r);return s!==null?s:Ot.doDecodeFormatInformation(n^Ot.FORMAT_INFO_MASK_QR,r^Ot.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(n,r){let s=Number.MAX_SAFE_INTEGER,o=0;for(const a of Ot.FORMAT_INFO_DECODE_LOOKUP){const u=a[0];if(u===n||u===r)return new Ot(a[1]);let d=Ot.numBitsDiffering(n,u);d<s&&(o=a[1],s=d),n!==r&&(d=Ot.numBitsDiffering(r,u),d<s&&(o=a[1],s=d))}return s<=3?new Ot(o):null}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getDataMask(){return this.dataMask}hashCode(){return this.errorCorrectionLevel.getBits()<<3|this.dataMask}equals(n){if(!(n instanceof Ot))return!1;const r=n;return this.errorCorrectionLevel===r.errorCorrectionLevel&&this.dataMask===r.dataMask}}Ot.FORMAT_INFO_MASK_QR=21522,Ot.FORMAT_INFO_DECODE_LOOKUP=[Int32Array.from([21522,0]),Int32Array.from([20773,1]),Int32Array.from([24188,2]),Int32Array.from([23371,3]),Int32Array.from([17913,4]),Int32Array.from([16590,5]),Int32Array.from([20375,6]),Int32Array.from([19104,7]),Int32Array.from([30660,8]),Int32Array.from([29427,9]),Int32Array.from([32170,10]),Int32Array.from([30877,11]),Int32Array.from([26159,12]),Int32Array.from([25368,13]),Int32Array.from([27713,14]),Int32Array.from([26998,15]),Int32Array.from([5769,16]),Int32Array.from([5054,17]),Int32Array.from([7399,18]),Int32Array.from([6608,19]),Int32Array.from([1890,20]),Int32Array.from([597,21]),Int32Array.from([3340,22]),Int32Array.from([2107,23]),Int32Array.from([13663,24]),Int32Array.from([12392,25]),Int32Array.from([16177,26]),Int32Array.from([14854,27]),Int32Array.from([9396,28]),Int32Array.from([8579,29]),Int32Array.from([11994,30]),Int32Array.from([11245,31])];class F{constructor(n,...r){this.ecCodewordsPerBlock=n,this.ecBlocks=r}getECCodewordsPerBlock(){return this.ecCodewordsPerBlock}getNumBlocks(){let n=0;const r=this.ecBlocks;for(const s of r)n+=s.getCount();return n}getTotalECCodewords(){return this.ecCodewordsPerBlock*this.getNumBlocks()}getECBlocks(){return this.ecBlocks}}class S{constructor(n,r){this.count=n,this.dataCodewords=r}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class ue{constructor(n,r,...s){this.versionNumber=n,this.alignmentPatternCenters=r,this.ecBlocks=s;let o=0;const a=s[0].getECCodewordsPerBlock(),u=s[0].getECBlocks();for(const d of u)o+=d.getCount()*(d.getDataCodewords()+a);this.totalCodewords=o}getVersionNumber(){return this.versionNumber}getAlignmentPatternCenters(){return this.alignmentPatternCenters}getTotalCodewords(){return this.totalCodewords}getDimensionForVersion(){return 17+4*this.versionNumber}getECBlocksForLevel(n){return this.ecBlocks[n.getValue()]}static getProvisionalVersionForDimension(n){if(n%4!==1)throw new k;try{return this.getVersionForNumber((n-17)/4)}catch{throw new k}}static getVersionForNumber(n){if(n<1||n>40)throw new v;return ue.VERSIONS[n-1]}static decodeVersionInformation(n){let r=Number.MAX_SAFE_INTEGER,s=0;for(let o=0;o<ue.VERSION_DECODE_INFO.length;o++){const a=ue.VERSION_DECODE_INFO[o];if(a===n)return ue.getVersionForNumber(o+7);const u=Ot.numBitsDiffering(n,a);u<r&&(s=o+7,r=u)}return r<=3?ue.getVersionForNumber(s):null}buildFunctionPattern(){const n=this.getDimensionForVersion(),r=new _e(n);r.setRegion(0,0,9,9),r.setRegion(n-8,0,8,9),r.setRegion(0,n-8,9,8);const s=this.alignmentPatternCenters.length;for(let o=0;o<s;o++){const a=this.alignmentPatternCenters[o]-2;for(let u=0;u<s;u++)o===0&&(u===0||u===s-1)||o===s-1&&u===0||r.setRegion(this.alignmentPatternCenters[u]-2,a,5,5)}return r.setRegion(6,9,1,n-17),r.setRegion(9,6,n-17,1),this.versionNumber>6&&(r.setRegion(n-11,0,3,6),r.setRegion(0,n-11,6,3)),r}toString(){return""+this.versionNumber}}ue.VERSION_DECODE_INFO=Int32Array.from([31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017]),ue.VERSIONS=[new ue(1,new Int32Array(0),new F(7,new S(1,19)),new F(10,new S(1,16)),new F(13,new S(1,13)),new F(17,new S(1,9))),new ue(2,Int32Array.from([6,18]),new F(10,new S(1,34)),new F(16,new S(1,28)),new F(22,new S(1,22)),new F(28,new S(1,16))),new ue(3,Int32Array.from([6,22]),new F(15,new S(1,55)),new F(26,new S(1,44)),new F(18,new S(2,17)),new F(22,new S(2,13))),new ue(4,Int32Array.from([6,26]),new F(20,new S(1,80)),new F(18,new S(2,32)),new F(26,new S(2,24)),new F(16,new S(4,9))),new ue(5,Int32Array.from([6,30]),new F(26,new S(1,108)),new F(24,new S(2,43)),new F(18,new S(2,15),new S(2,16)),new F(22,new S(2,11),new S(2,12))),new ue(6,Int32Array.from([6,34]),new F(18,new S(2,68)),new F(16,new S(4,27)),new F(24,new S(4,19)),new F(28,new S(4,15))),new ue(7,Int32Array.from([6,22,38]),new F(20,new S(2,78)),new F(18,new S(4,31)),new F(18,new S(2,14),new S(4,15)),new F(26,new S(4,13),new S(1,14))),new ue(8,Int32Array.from([6,24,42]),new F(24,new S(2,97)),new F(22,new S(2,38),new S(2,39)),new F(22,new S(4,18),new S(2,19)),new F(26,new S(4,14),new S(2,15))),new ue(9,Int32Array.from([6,26,46]),new F(30,new S(2,116)),new F(22,new S(3,36),new S(2,37)),new F(20,new S(4,16),new S(4,17)),new F(24,new S(4,12),new S(4,13))),new ue(10,Int32Array.from([6,28,50]),new F(18,new S(2,68),new S(2,69)),new F(26,new S(4,43),new S(1,44)),new F(24,new S(6,19),new S(2,20)),new F(28,new S(6,15),new S(2,16))),new ue(11,Int32Array.from([6,30,54]),new F(20,new S(4,81)),new F(30,new S(1,50),new S(4,51)),new F(28,new S(4,22),new S(4,23)),new F(24,new S(3,12),new S(8,13))),new ue(12,Int32Array.from([6,32,58]),new F(24,new S(2,92),new S(2,93)),new F(22,new S(6,36),new S(2,37)),new F(26,new S(4,20),new S(6,21)),new F(28,new S(7,14),new S(4,15))),new ue(13,Int32Array.from([6,34,62]),new F(26,new S(4,107)),new F(22,new S(8,37),new S(1,38)),new F(24,new S(8,20),new S(4,21)),new F(22,new S(12,11),new S(4,12))),new ue(14,Int32Array.from([6,26,46,66]),new F(30,new S(3,115),new S(1,116)),new F(24,new S(4,40),new S(5,41)),new F(20,new S(11,16),new S(5,17)),new F(24,new S(11,12),new S(5,13))),new ue(15,Int32Array.from([6,26,48,70]),new F(22,new S(5,87),new S(1,88)),new F(24,new S(5,41),new S(5,42)),new F(30,new S(5,24),new S(7,25)),new F(24,new S(11,12),new S(7,13))),new ue(16,Int32Array.from([6,26,50,74]),new F(24,new S(5,98),new S(1,99)),new F(28,new S(7,45),new S(3,46)),new F(24,new S(15,19),new S(2,20)),new F(30,new S(3,15),new S(13,16))),new ue(17,Int32Array.from([6,30,54,78]),new F(28,new S(1,107),new S(5,108)),new F(28,new S(10,46),new S(1,47)),new F(28,new S(1,22),new S(15,23)),new F(28,new S(2,14),new S(17,15))),new ue(18,Int32Array.from([6,30,56,82]),new F(30,new S(5,120),new S(1,121)),new F(26,new S(9,43),new S(4,44)),new F(28,new S(17,22),new S(1,23)),new F(28,new S(2,14),new S(19,15))),new ue(19,Int32Array.from([6,30,58,86]),new F(28,new S(3,113),new S(4,114)),new F(26,new S(3,44),new S(11,45)),new F(26,new S(17,21),new S(4,22)),new F(26,new S(9,13),new S(16,14))),new ue(20,Int32Array.from([6,34,62,90]),new F(28,new S(3,107),new S(5,108)),new F(26,new S(3,41),new S(13,42)),new F(30,new S(15,24),new S(5,25)),new F(28,new S(15,15),new S(10,16))),new ue(21,Int32Array.from([6,28,50,72,94]),new F(28,new S(4,116),new S(4,117)),new F(26,new S(17,42)),new F(28,new S(17,22),new S(6,23)),new F(30,new S(19,16),new S(6,17))),new ue(22,Int32Array.from([6,26,50,74,98]),new F(28,new S(2,111),new S(7,112)),new F(28,new S(17,46)),new F(30,new S(7,24),new S(16,25)),new F(24,new S(34,13))),new ue(23,Int32Array.from([6,30,54,78,102]),new F(30,new S(4,121),new S(5,122)),new F(28,new S(4,47),new S(14,48)),new F(30,new S(11,24),new S(14,25)),new F(30,new S(16,15),new S(14,16))),new ue(24,Int32Array.from([6,28,54,80,106]),new F(30,new S(6,117),new S(4,118)),new F(28,new S(6,45),new S(14,46)),new F(30,new S(11,24),new S(16,25)),new F(30,new S(30,16),new S(2,17))),new ue(25,Int32Array.from([6,32,58,84,110]),new F(26,new S(8,106),new S(4,107)),new F(28,new S(8,47),new S(13,48)),new F(30,new S(7,24),new S(22,25)),new F(30,new S(22,15),new S(13,16))),new ue(26,Int32Array.from([6,30,58,86,114]),new F(28,new S(10,114),new S(2,115)),new F(28,new S(19,46),new S(4,47)),new F(28,new S(28,22),new S(6,23)),new F(30,new S(33,16),new S(4,17))),new ue(27,Int32Array.from([6,34,62,90,118]),new F(30,new S(8,122),new S(4,123)),new F(28,new S(22,45),new S(3,46)),new F(30,new S(8,23),new S(26,24)),new F(30,new S(12,15),new S(28,16))),new ue(28,Int32Array.from([6,26,50,74,98,122]),new F(30,new S(3,117),new S(10,118)),new F(28,new S(3,45),new S(23,46)),new F(30,new S(4,24),new S(31,25)),new F(30,new S(11,15),new S(31,16))),new ue(29,Int32Array.from([6,30,54,78,102,126]),new F(30,new S(7,116),new S(7,117)),new F(28,new S(21,45),new S(7,46)),new F(30,new S(1,23),new S(37,24)),new F(30,new S(19,15),new S(26,16))),new ue(30,Int32Array.from([6,26,52,78,104,130]),new F(30,new S(5,115),new S(10,116)),new F(28,new S(19,47),new S(10,48)),new F(30,new S(15,24),new S(25,25)),new F(30,new S(23,15),new S(25,16))),new ue(31,Int32Array.from([6,30,56,82,108,134]),new F(30,new S(13,115),new S(3,116)),new F(28,new S(2,46),new S(29,47)),new F(30,new S(42,24),new S(1,25)),new F(30,new S(23,15),new S(28,16))),new ue(32,Int32Array.from([6,34,60,86,112,138]),new F(30,new S(17,115)),new F(28,new S(10,46),new S(23,47)),new F(30,new S(10,24),new S(35,25)),new F(30,new S(19,15),new S(35,16))),new ue(33,Int32Array.from([6,30,58,86,114,142]),new F(30,new S(17,115),new S(1,116)),new F(28,new S(14,46),new S(21,47)),new F(30,new S(29,24),new S(19,25)),new F(30,new S(11,15),new S(46,16))),new ue(34,Int32Array.from([6,34,62,90,118,146]),new F(30,new S(13,115),new S(6,116)),new F(28,new S(14,46),new S(23,47)),new F(30,new S(44,24),new S(7,25)),new F(30,new S(59,16),new S(1,17))),new ue(35,Int32Array.from([6,30,54,78,102,126,150]),new F(30,new S(12,121),new S(7,122)),new F(28,new S(12,47),new S(26,48)),new F(30,new S(39,24),new S(14,25)),new F(30,new S(22,15),new S(41,16))),new ue(36,Int32Array.from([6,24,50,76,102,128,154]),new F(30,new S(6,121),new S(14,122)),new F(28,new S(6,47),new S(34,48)),new F(30,new S(46,24),new S(10,25)),new F(30,new S(2,15),new S(64,16))),new ue(37,Int32Array.from([6,28,54,80,106,132,158]),new F(30,new S(17,122),new S(4,123)),new F(28,new S(29,46),new S(14,47)),new F(30,new S(49,24),new S(10,25)),new F(30,new S(24,15),new S(46,16))),new ue(38,Int32Array.from([6,32,58,84,110,136,162]),new F(30,new S(4,122),new S(18,123)),new F(28,new S(13,46),new S(32,47)),new F(30,new S(48,24),new S(14,25)),new F(30,new S(42,15),new S(32,16))),new ue(39,Int32Array.from([6,26,54,82,110,138,166]),new F(30,new S(20,117),new S(4,118)),new F(28,new S(40,47),new S(7,48)),new F(30,new S(43,24),new S(22,25)),new F(30,new S(10,15),new S(67,16))),new ue(40,Int32Array.from([6,30,58,86,114,142,170]),new F(30,new S(19,118),new S(6,119)),new F(28,new S(18,47),new S(31,48)),new F(30,new S(34,24),new S(34,25)),new F(30,new S(20,15),new S(61,16)))];var wt;(function(y){y[y.DATA_MASK_000=0]="DATA_MASK_000",y[y.DATA_MASK_001=1]="DATA_MASK_001",y[y.DATA_MASK_010=2]="DATA_MASK_010",y[y.DATA_MASK_011=3]="DATA_MASK_011",y[y.DATA_MASK_100=4]="DATA_MASK_100",y[y.DATA_MASK_101=5]="DATA_MASK_101",y[y.DATA_MASK_110=6]="DATA_MASK_110",y[y.DATA_MASK_111=7]="DATA_MASK_111"})(wt||(wt={}));class dn{constructor(n,r){this.value=n,this.isMasked=r}unmaskBitMatrix(n,r){for(let s=0;s<r;s++)for(let o=0;o<r;o++)this.isMasked(s,o)&&n.flip(o,s)}}dn.values=new Map([[wt.DATA_MASK_000,new dn(wt.DATA_MASK_000,(y,n)=>(y+n&1)===0)],[wt.DATA_MASK_001,new dn(wt.DATA_MASK_001,(y,n)=>(y&1)===0)],[wt.DATA_MASK_010,new dn(wt.DATA_MASK_010,(y,n)=>n%3===0)],[wt.DATA_MASK_011,new dn(wt.DATA_MASK_011,(y,n)=>(y+n)%3===0)],[wt.DATA_MASK_100,new dn(wt.DATA_MASK_100,(y,n)=>(Math.floor(y/2)+Math.floor(n/3)&1)===0)],[wt.DATA_MASK_101,new dn(wt.DATA_MASK_101,(y,n)=>y*n%6===0)],[wt.DATA_MASK_110,new dn(wt.DATA_MASK_110,(y,n)=>y*n%6<3)],[wt.DATA_MASK_111,new dn(wt.DATA_MASK_111,(y,n)=>(y+n+y*n%3&1)===0)]]);class Lh{constructor(n){const r=n.getHeight();if(r<21||(r&3)!==1)throw new k;this.bitMatrix=n}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let n=0;for(let a=0;a<6;a++)n=this.copyBit(a,8,n);n=this.copyBit(7,8,n),n=this.copyBit(8,8,n),n=this.copyBit(8,7,n);for(let a=5;a>=0;a--)n=this.copyBit(8,a,n);const r=this.bitMatrix.getHeight();let s=0;const o=r-7;for(let a=r-1;a>=o;a--)s=this.copyBit(8,a,s);for(let a=r-8;a<r;a++)s=this.copyBit(a,8,s);if(this.parsedFormatInfo=Ot.decodeFormatInformation(n,s),this.parsedFormatInfo!==null)return this.parsedFormatInfo;throw new k}readVersion(){if(this.parsedVersion!==null&&this.parsedVersion!==void 0)return this.parsedVersion;const n=this.bitMatrix.getHeight(),r=Math.floor((n-17)/4);if(r<=6)return ue.getVersionForNumber(r);let s=0;const o=n-11;for(let u=5;u>=0;u--)for(let d=n-9;d>=o;d--)s=this.copyBit(d,u,s);let a=ue.decodeVersionInformation(s);if(a!==null&&a.getDimensionForVersion()===n)return this.parsedVersion=a,a;s=0;for(let u=5;u>=0;u--)for(let d=n-9;d>=o;d--)s=this.copyBit(u,d,s);if(a=ue.decodeVersionInformation(s),a!==null&&a.getDimensionForVersion()===n)return this.parsedVersion=a,a;throw new k}copyBit(n,r,s){return(this.isMirror?this.bitMatrix.get(r,n):this.bitMatrix.get(n,r))?s<<1|1:s<<1}readCodewords(){const n=this.readFormatInformation(),r=this.readVersion(),s=dn.values.get(n.getDataMask()),o=this.bitMatrix.getHeight();s.unmaskBitMatrix(this.bitMatrix,o);const a=r.buildFunctionPattern();let u=!0;const d=new Uint8Array(r.getTotalCodewords());let h=0,g=0,x=0;for(let E=o-1;E>0;E-=2){E===6&&E--;for(let A=0;A<o;A++){const I=u?o-1-A:A;for(let b=0;b<2;b++)a.get(E-b,I)||(x++,g<<=1,this.bitMatrix.get(E-b,I)&&(g|=1),x===8&&(d[h++]=g,x=0,g=0))}u=!u}if(h!==r.getTotalCodewords())throw new k;return d}remask(){if(this.parsedFormatInfo===null)return;const n=dn.values[this.parsedFormatInfo.getDataMask()],r=this.bitMatrix.getHeight();n.unmaskBitMatrix(this.bitMatrix,r)}setMirror(n){this.parsedVersion=null,this.parsedFormatInfo=null,this.isMirror=n}mirror(){const n=this.bitMatrix;for(let r=0,s=n.getWidth();r<s;r++)for(let o=r+1,a=n.getHeight();o<a;o++)n.get(r,o)!==n.get(o,r)&&(n.flip(o,r),n.flip(r,o))}}class $a{constructor(n,r){this.numDataCodewords=n,this.codewords=r}static getDataBlocks(n,r,s){if(n.length!==r.getTotalCodewords())throw new v;const o=r.getECBlocksForLevel(s);let a=0;const u=o.getECBlocks();for(const b of u)a+=b.getCount();const d=new Array(a);let h=0;for(const b of u)for(let D=0;D<b.getCount();D++){const L=b.getDataCodewords(),z=o.getECCodewordsPerBlock()+L;d[h++]=new $a(L,new Uint8Array(z))}const g=d[0].codewords.length;let x=d.length-1;for(;x>=0&&d[x].codewords.length!==g;)x--;x++;const E=g-o.getECCodewordsPerBlock();let A=0;for(let b=0;b<E;b++)for(let D=0;D<h;D++)d[D].codewords[b]=n[A++];for(let b=x;b<h;b++)d[b].codewords[E]=n[A++];const I=d[0].codewords.length;for(let b=E;b<I;b++)for(let D=0;D<h;D++){const L=D<x?b:b+1;d[D].codewords[L]=n[A++]}return d}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}var hn;(function(y){y[y.TERMINATOR=0]="TERMINATOR",y[y.NUMERIC=1]="NUMERIC",y[y.ALPHANUMERIC=2]="ALPHANUMERIC",y[y.STRUCTURED_APPEND=3]="STRUCTURED_APPEND",y[y.BYTE=4]="BYTE",y[y.ECI=5]="ECI",y[y.KANJI=6]="KANJI",y[y.FNC1_FIRST_POSITION=7]="FNC1_FIRST_POSITION",y[y.FNC1_SECOND_POSITION=8]="FNC1_SECOND_POSITION",y[y.HANZI=9]="HANZI"})(hn||(hn={}));class ce{constructor(n,r,s,o){this.value=n,this.stringValue=r,this.characterCountBitsForVersions=s,this.bits=o,ce.FOR_BITS.set(o,this),ce.FOR_VALUE.set(n,this)}static forBits(n){const r=ce.FOR_BITS.get(n);if(r===void 0)throw new v;return r}getCharacterCountBits(n){const r=n.getVersionNumber();let s;return r<=9?s=0:r<=26?s=1:s=2,this.characterCountBitsForVersions[s]}getValue(){return this.value}getBits(){return this.bits}equals(n){if(!(n instanceof ce))return!1;const r=n;return this.value===r.value}toString(){return this.stringValue}}ce.FOR_BITS=new Map,ce.FOR_VALUE=new Map,ce.TERMINATOR=new ce(hn.TERMINATOR,"TERMINATOR",Int32Array.from([0,0,0]),0),ce.NUMERIC=new ce(hn.NUMERIC,"NUMERIC",Int32Array.from([10,12,14]),1),ce.ALPHANUMERIC=new ce(hn.ALPHANUMERIC,"ALPHANUMERIC",Int32Array.from([9,11,13]),2),ce.STRUCTURED_APPEND=new ce(hn.STRUCTURED_APPEND,"STRUCTURED_APPEND",Int32Array.from([0,0,0]),3),ce.BYTE=new ce(hn.BYTE,"BYTE",Int32Array.from([8,16,16]),4),ce.ECI=new ce(hn.ECI,"ECI",Int32Array.from([0,0,0]),7),ce.KANJI=new ce(hn.KANJI,"KANJI",Int32Array.from([8,10,12]),8),ce.FNC1_FIRST_POSITION=new ce(hn.FNC1_FIRST_POSITION,"FNC1_FIRST_POSITION",Int32Array.from([0,0,0]),5),ce.FNC1_SECOND_POSITION=new ce(hn.FNC1_SECOND_POSITION,"FNC1_SECOND_POSITION",Int32Array.from([0,0,0]),9),ce.HANZI=new ce(hn.HANZI,"HANZI",Int32Array.from([8,10,12]),13);class Qe{static decode(n,r,s,o){const a=new qa(n);let u=new ge;const d=new Array;let h=-1,g=-1;try{let x=null,E=!1,A;do{if(a.available()<4)A=ce.TERMINATOR;else{const I=a.readBits(4);A=ce.forBits(I)}switch(A){case ce.TERMINATOR:break;case ce.FNC1_FIRST_POSITION:case ce.FNC1_SECOND_POSITION:E=!0;break;case ce.STRUCTURED_APPEND:if(a.available()<16)throw new k;h=a.readBits(8),g=a.readBits(8);break;case ce.ECI:const I=Qe.parseECIValue(a);if(x=V.getCharacterSetECIByValue(I),x===null)throw new k;break;case ce.HANZI:const b=a.readBits(4),D=a.readBits(A.getCharacterCountBits(r));b===Qe.GB2312_SUBSET&&Qe.decodeHanziSegment(a,u,D);break;default:const L=a.readBits(A.getCharacterCountBits(r));switch(A){case ce.NUMERIC:Qe.decodeNumericSegment(a,u,L);break;case ce.ALPHANUMERIC:Qe.decodeAlphanumericSegment(a,u,L,E);break;case ce.BYTE:Qe.decodeByteSegment(a,u,L,x,d,o);break;case ce.KANJI:Qe.decodeKanjiSegment(a,u,L);break;default:throw new k}break}}while(A!==ce.TERMINATOR)}catch{throw new k}return new Qi(n,u.toString(),d.length===0?null:d,s===null?null:s.toString(),h,g)}static decodeHanziSegment(n,r,s){if(s*13>n.available())throw new k;const o=new Uint8Array(2*s);let a=0;for(;s>0;){const u=n.readBits(13);let d=u/96<<8&4294967295|u%96;d<959?d+=41377:d+=42657,o[a]=d>>8&255,o[a+1]=d&255,a+=2,s--}try{r.append(Ee.decode(o,ie.GB2312))}catch(u){throw new k(u)}}static decodeKanjiSegment(n,r,s){if(s*13>n.available())throw new k;const o=new Uint8Array(2*s);let a=0;for(;s>0;){const u=n.readBits(13);let d=u/192<<8&4294967295|u%192;d<7936?d+=33088:d+=49472,o[a]=d>>8,o[a+1]=d,a+=2,s--}try{r.append(Ee.decode(o,ie.SHIFT_JIS))}catch(u){throw new k(u)}}static decodeByteSegment(n,r,s,o,a,u){if(8*s>n.available())throw new k;const d=new Uint8Array(s);for(let g=0;g<s;g++)d[g]=n.readBits(8);let h;o===null?h=ie.guessEncoding(d,u):h=o.getName();try{r.append(Ee.decode(d,h))}catch(g){throw new k(g)}a.push(d)}static toAlphaNumericChar(n){if(n>=Qe.ALPHANUMERIC_CHARS.length)throw new k;return Qe.ALPHANUMERIC_CHARS[n]}static decodeAlphanumericSegment(n,r,s,o){const a=r.length();for(;s>1;){if(n.available()<11)throw new k;const u=n.readBits(11);r.append(Qe.toAlphaNumericChar(Math.floor(u/45))),r.append(Qe.toAlphaNumericChar(u%45)),s-=2}if(s===1){if(n.available()<6)throw new k;r.append(Qe.toAlphaNumericChar(n.readBits(6)))}if(o)for(let u=a;u<r.length();u++)r.charAt(u)==="%"&&(u<r.length()-1&&r.charAt(u+1)==="%"?r.deleteCharAt(u+1):r.setCharAt(u,""))}static decodeNumericSegment(n,r,s){for(;s>=3;){if(n.available()<10)throw new k;const o=n.readBits(10);if(o>=1e3)throw new k;r.append(Qe.toAlphaNumericChar(Math.floor(o/100))),r.append(Qe.toAlphaNumericChar(Math.floor(o/10)%10)),r.append(Qe.toAlphaNumericChar(o%10)),s-=3}if(s===2){if(n.available()<7)throw new k;const o=n.readBits(7);if(o>=100)throw new k;r.append(Qe.toAlphaNumericChar(Math.floor(o/10))),r.append(Qe.toAlphaNumericChar(o%10))}else if(s===1){if(n.available()<4)throw new k;const o=n.readBits(4);if(o>=10)throw new k;r.append(Qe.toAlphaNumericChar(o))}}static parseECIValue(n){const r=n.readBits(8);if(!(r&128))return r&127;if((r&192)===128){const s=n.readBits(8);return(r&63)<<8&4294967295|s}if((r&224)===192){const s=n.readBits(16);return(r&31)<<16&4294967295|s}throw new k}}Qe.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Qe.GB2312_SUBSET=1;class n1{constructor(n){this.mirrored=n}isMirrored(){return this.mirrored}applyMirroredCorrection(n){if(!this.mirrored||n===null||n.length<3)return;const r=n[0];n[0]=n[2],n[2]=r}}class Fh{constructor(){this.rsDecoder=new $i(be.QR_CODE_FIELD_256)}decodeBooleanArray(n,r){return this.decodeBitMatrix(_e.parseFromBooleanArray(n),r)}decodeBitMatrix(n,r){const s=new Lh(n);let o=null;try{return this.decodeBitMatrixParser(s,r)}catch(a){o=a}try{s.remask(),s.setMirror(!0),s.readVersion(),s.readFormatInformation(),s.mirror();const a=this.decodeBitMatrixParser(s,r);return a.setOther(new n1(!0)),a}catch(a){throw o!==null?o:a}}decodeBitMatrixParser(n,r){const s=n.readVersion(),o=n.readFormatInformation().getErrorCorrectionLevel(),a=n.readCodewords(),u=$a.getDataBlocks(a,s,o);let d=0;for(const x of u)d+=x.getNumDataCodewords();const h=new Uint8Array(d);let g=0;for(const x of u){const E=x.getCodewords(),A=x.getNumDataCodewords();this.correctErrors(E,A);for(let I=0;I<A;I++)h[g++]=E[I]}return Qe.decode(h,s,o,r)}correctErrors(n,r){const s=new Int32Array(n);try{this.rsDecoder.decode(s,n.length-r)}catch{throw new M}for(let o=0;o<r;o++)n[o]=s[o]}}class Ja extends oe{constructor(n,r,s){super(n,r),this.estimatedModuleSize=s}aboutEquals(n,r,s){if(Math.abs(r-this.getY())<=n&&Math.abs(s-this.getX())<=n){const o=Math.abs(n-this.estimatedModuleSize);return o<=1||o<=this.estimatedModuleSize}return!1}combineEstimate(n,r,s){const o=(this.getX()+r)/2,a=(this.getY()+n)/2,u=(this.estimatedModuleSize+s)/2;return new Ja(o,a,u)}}class fo{constructor(n,r,s,o,a,u,d){this.image=n,this.startX=r,this.startY=s,this.width=o,this.height=a,this.moduleSize=u,this.resultPointCallback=d,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(3)}find(){const n=this.startX,r=this.height,s=this.width,o=n+s,a=this.startY+r/2,u=new Int32Array(3),d=this.image;for(let h=0;h<r;h++){const g=a+(h&1?-Math.floor((h+1)/2):Math.floor((h+1)/2));u[0]=0,u[1]=0,u[2]=0;let x=n;for(;x<o&&!d.get(x,g);)x++;let E=0;for(;x<o;){if(d.get(x,g))if(E===1)u[1]++;else if(E===2){if(this.foundPatternCross(u)){const A=this.handlePossibleCenter(u,g,x);if(A!==null)return A}u[0]=u[2],u[1]=1,u[2]=0,E=1}else u[++E]++;else E===1&&E++,u[E]++;x++}if(this.foundPatternCross(u)){const A=this.handlePossibleCenter(u,g,o);if(A!==null)return A}}if(this.possibleCenters.length!==0)return this.possibleCenters[0];throw new j}static centerFromEnd(n,r){return r-n[2]-n[1]/2}foundPatternCross(n){const r=this.moduleSize,s=r/2;for(let o=0;o<3;o++)if(Math.abs(r-n[o])>=s)return!1;return!0}crossCheckVertical(n,r,s,o){const a=this.image,u=a.getHeight(),d=this.crossCheckStateCount;d[0]=0,d[1]=0,d[2]=0;let h=n;for(;h>=0&&a.get(r,h)&&d[1]<=s;)d[1]++,h--;if(h<0||d[1]>s)return NaN;for(;h>=0&&!a.get(r,h)&&d[0]<=s;)d[0]++,h--;if(d[0]>s)return NaN;for(h=n+1;h<u&&a.get(r,h)&&d[1]<=s;)d[1]++,h++;if(h===u||d[1]>s)return NaN;for(;h<u&&!a.get(r,h)&&d[2]<=s;)d[2]++,h++;if(d[2]>s)return NaN;const g=d[0]+d[1]+d[2];return 5*Math.abs(g-o)>=2*o?NaN:this.foundPatternCross(d)?fo.centerFromEnd(d,h):NaN}handlePossibleCenter(n,r,s){const o=n[0]+n[1]+n[2],a=fo.centerFromEnd(n,s),u=this.crossCheckVertical(r,a,2*n[1],o);if(!isNaN(u)){const d=(n[0]+n[1]+n[2])/3;for(const g of this.possibleCenters)if(g.aboutEquals(d,u,a))return g.combineEstimate(u,a,d);const h=new Ja(a,u,d);this.possibleCenters.push(h),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(h)}return null}}class el extends oe{constructor(n,r,s,o){super(n,r),this.estimatedModuleSize=s,this.count=o,o===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(n,r,s){if(Math.abs(r-this.getY())<=n&&Math.abs(s-this.getX())<=n){const o=Math.abs(n-this.estimatedModuleSize);return o<=1||o<=this.estimatedModuleSize}return!1}combineEstimate(n,r,s){const o=this.count+1,a=(this.count*this.getX()+r)/o,u=(this.count*this.getY()+n)/o,d=(this.count*this.estimatedModuleSize+s)/o;return new el(a,u,d,o)}}class Uh{constructor(n){this.bottomLeft=n[0],this.topLeft=n[1],this.topRight=n[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class yt{constructor(n,r){this.image=n,this.resultPointCallback=r,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=r}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(n){const r=n!=null&&n.get(U.TRY_HARDER)!==void 0,s=n!=null&&n.get(U.PURE_BARCODE)!==void 0,o=this.image,a=o.getHeight(),u=o.getWidth();let d=Math.floor(3*a/(4*yt.MAX_MODULES));(d<yt.MIN_SKIP||r)&&(d=yt.MIN_SKIP);let h=!1;const g=new Int32Array(5);for(let E=d-1;E<a&&!h;E+=d){g[0]=0,g[1]=0,g[2]=0,g[3]=0,g[4]=0;let A=0;for(let I=0;I<u;I++)if(o.get(I,E))(A&1)===1&&A++,g[A]++;else if(A&1)g[A]++;else if(A===4)if(yt.foundPatternCross(g)){if(this.handlePossibleCenter(g,E,I,s)===!0)if(d=2,this.hasSkipped===!0)h=this.haveMultiplyConfirmedCenters();else{const D=this.findRowSkip();D>g[2]&&(E+=D-g[2]-d,I=u-1)}else{g[0]=g[2],g[1]=g[3],g[2]=g[4],g[3]=1,g[4]=0,A=3;continue}A=0,g[0]=0,g[1]=0,g[2]=0,g[3]=0,g[4]=0}else g[0]=g[2],g[1]=g[3],g[2]=g[4],g[3]=1,g[4]=0,A=3;else g[++A]++;yt.foundPatternCross(g)&&this.handlePossibleCenter(g,E,u,s)===!0&&(d=g[0],this.hasSkipped&&(h=this.haveMultiplyConfirmedCenters()))}const x=this.selectBestPatterns();return oe.orderBestPatterns(x),new Uh(x)}static centerFromEnd(n,r){return r-n[4]-n[3]-n[2]/2}static foundPatternCross(n){let r=0;for(let a=0;a<5;a++){const u=n[a];if(u===0)return!1;r+=u}if(r<7)return!1;const s=r/7,o=s/2;return Math.abs(s-n[0])<o&&Math.abs(s-n[1])<o&&Math.abs(3*s-n[2])<3*o&&Math.abs(s-n[3])<o&&Math.abs(s-n[4])<o}getCrossCheckStateCount(){const n=this.crossCheckStateCount;return n[0]=0,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n}crossCheckDiagonal(n,r,s,o){const a=this.getCrossCheckStateCount();let u=0;const d=this.image;for(;n>=u&&r>=u&&d.get(r-u,n-u);)a[2]++,u++;if(n<u||r<u)return!1;for(;n>=u&&r>=u&&!d.get(r-u,n-u)&&a[1]<=s;)a[1]++,u++;if(n<u||r<u||a[1]>s)return!1;for(;n>=u&&r>=u&&d.get(r-u,n-u)&&a[0]<=s;)a[0]++,u++;if(a[0]>s)return!1;const h=d.getHeight(),g=d.getWidth();for(u=1;n+u<h&&r+u<g&&d.get(r+u,n+u);)a[2]++,u++;if(n+u>=h||r+u>=g)return!1;for(;n+u<h&&r+u<g&&!d.get(r+u,n+u)&&a[3]<s;)a[3]++,u++;if(n+u>=h||r+u>=g||a[3]>=s)return!1;for(;n+u<h&&r+u<g&&d.get(r+u,n+u)&&a[4]<s;)a[4]++,u++;if(a[4]>=s)return!1;const x=a[0]+a[1]+a[2]+a[3]+a[4];return Math.abs(x-o)<2*o&&yt.foundPatternCross(a)}crossCheckVertical(n,r,s,o){const a=this.image,u=a.getHeight(),d=this.getCrossCheckStateCount();let h=n;for(;h>=0&&a.get(r,h);)d[2]++,h--;if(h<0)return NaN;for(;h>=0&&!a.get(r,h)&&d[1]<=s;)d[1]++,h--;if(h<0||d[1]>s)return NaN;for(;h>=0&&a.get(r,h)&&d[0]<=s;)d[0]++,h--;if(d[0]>s)return NaN;for(h=n+1;h<u&&a.get(r,h);)d[2]++,h++;if(h===u)return NaN;for(;h<u&&!a.get(r,h)&&d[3]<s;)d[3]++,h++;if(h===u||d[3]>=s)return NaN;for(;h<u&&a.get(r,h)&&d[4]<s;)d[4]++,h++;if(d[4]>=s)return NaN;const g=d[0]+d[1]+d[2]+d[3]+d[4];return 5*Math.abs(g-o)>=2*o?NaN:yt.foundPatternCross(d)?yt.centerFromEnd(d,h):NaN}crossCheckHorizontal(n,r,s,o){const a=this.image,u=a.getWidth(),d=this.getCrossCheckStateCount();let h=n;for(;h>=0&&a.get(h,r);)d[2]++,h--;if(h<0)return NaN;for(;h>=0&&!a.get(h,r)&&d[1]<=s;)d[1]++,h--;if(h<0||d[1]>s)return NaN;for(;h>=0&&a.get(h,r)&&d[0]<=s;)d[0]++,h--;if(d[0]>s)return NaN;for(h=n+1;h<u&&a.get(h,r);)d[2]++,h++;if(h===u)return NaN;for(;h<u&&!a.get(h,r)&&d[3]<s;)d[3]++,h++;if(h===u||d[3]>=s)return NaN;for(;h<u&&a.get(h,r)&&d[4]<s;)d[4]++,h++;if(d[4]>=s)return NaN;const g=d[0]+d[1]+d[2]+d[3]+d[4];return 5*Math.abs(g-o)>=o?NaN:yt.foundPatternCross(d)?yt.centerFromEnd(d,h):NaN}handlePossibleCenter(n,r,s,o){const a=n[0]+n[1]+n[2]+n[3]+n[4];let u=yt.centerFromEnd(n,s),d=this.crossCheckVertical(r,Math.floor(u),n[2],a);if(!isNaN(d)&&(u=this.crossCheckHorizontal(Math.floor(u),Math.floor(d),n[2],a),!isNaN(u)&&(!o||this.crossCheckDiagonal(Math.floor(d),Math.floor(u),n[2],a)))){const h=a/7;let g=!1;const x=this.possibleCenters;for(let E=0,A=x.length;E<A;E++){const I=x[E];if(I.aboutEquals(h,d,u)){x[E]=I.combineEstimate(d,u,h),g=!0;break}}if(!g){const E=new el(u,d,h);x.push(E),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(E)}return!0}return!1}findRowSkip(){if(this.possibleCenters.length<=1)return 0;let r=null;for(const s of this.possibleCenters)if(s.getCount()>=yt.CENTER_QUORUM)if(r==null)r=s;else return this.hasSkipped=!0,Math.floor((Math.abs(r.getX()-s.getX())-Math.abs(r.getY()-s.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let n=0,r=0;const s=this.possibleCenters.length;for(const u of this.possibleCenters)u.getCount()>=yt.CENTER_QUORUM&&(n++,r+=u.getEstimatedModuleSize());if(n<3)return!1;const o=r/s;let a=0;for(const u of this.possibleCenters)a+=Math.abs(u.getEstimatedModuleSize()-o);return a<=.05*r}selectBestPatterns(){const n=this.possibleCenters.length;if(n<3)throw new j;const r=this.possibleCenters;let s;if(n>3){let o=0,a=0;for(const h of this.possibleCenters){const g=h.getEstimatedModuleSize();o+=g,a+=g*g}s=o/n;let u=Math.sqrt(a/n-s*s);r.sort((h,g)=>{const x=Math.abs(g.getEstimatedModuleSize()-s),E=Math.abs(h.getEstimatedModuleSize()-s);return x<E?-1:x>E?1:0});const d=Math.max(.2*s,u);for(let h=0;h<r.length&&r.length>3;h++){const g=r[h];Math.abs(g.getEstimatedModuleSize()-s)>d&&(r.splice(h,1),h--)}}if(r.length>3){let o=0;for(const a of r)o+=a.getEstimatedModuleSize();s=o/r.length,r.sort((a,u)=>{if(u.getCount()===a.getCount()){const d=Math.abs(u.getEstimatedModuleSize()-s),h=Math.abs(a.getEstimatedModuleSize()-s);return d<h?1:d>h?-1:0}else return u.getCount()-a.getCount()}),r.splice(3)}return[r[0],r[1],r[2]]}}yt.CENTER_QUORUM=2,yt.MIN_SKIP=3,yt.MAX_MODULES=57;class es{constructor(n){this.image=n}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(n){this.resultPointCallback=n==null?null:n.get(U.NEED_RESULT_POINT_CALLBACK);const s=new yt(this.image,this.resultPointCallback).find(n);return this.processFinderPatternInfo(s)}processFinderPatternInfo(n){const r=n.getTopLeft(),s=n.getTopRight(),o=n.getBottomLeft(),a=this.calculateModuleSize(r,s,o);if(a<1)throw new j("No pattern found in proccess finder.");const u=es.computeDimension(r,s,o,a),d=ue.getProvisionalVersionForDimension(u),h=d.getDimensionForVersion()-7;let g=null;if(d.getAlignmentPatternCenters().length>0){const I=s.getX()-r.getX()+o.getX(),b=s.getY()-r.getY()+o.getY(),D=1-3/h,L=Math.floor(r.getX()+D*(I-r.getX())),z=Math.floor(r.getY()+D*(b-r.getY()));for(let q=4;q<=16;q<<=1)try{g=this.findAlignmentInRegion(a,L,z,q);break}catch($){if(!($ instanceof j))throw $}}const x=es.createTransform(r,s,o,g,u),E=es.sampleGrid(this.image,x,u);let A;return g===null?A=[o,r,s]:A=[o,r,s,g],new oo(E,A)}static createTransform(n,r,s,o,a){const u=a-3.5;let d,h,g,x;return o!==null?(d=o.getX(),h=o.getY(),g=u-3,x=g):(d=r.getX()-n.getX()+s.getX(),h=r.getY()-n.getY()+s.getY(),g=u,x=u),Cn.quadrilateralToQuadrilateral(3.5,3.5,u,3.5,g,x,3.5,u,n.getX(),n.getY(),r.getX(),r.getY(),d,h,s.getX(),s.getY())}static sampleGrid(n,r,s){return sr.getInstance().sampleGridWithTransform(n,s,s,r)}static computeDimension(n,r,s,o){const a=Te.round(oe.distance(n,r)/o),u=Te.round(oe.distance(n,s)/o);let d=Math.floor((a+u)/2)+7;switch(d&3){case 0:d++;break;case 2:d--;break;case 3:throw new j("Dimensions could be not found.")}return d}calculateModuleSize(n,r,s){return(this.calculateModuleSizeOneWay(n,r)+this.calculateModuleSizeOneWay(n,s))/2}calculateModuleSizeOneWay(n,r){const s=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(n.getX()),Math.floor(n.getY()),Math.floor(r.getX()),Math.floor(r.getY())),o=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(r.getX()),Math.floor(r.getY()),Math.floor(n.getX()),Math.floor(n.getY()));return isNaN(s)?o/7:isNaN(o)?s/7:(s+o)/14}sizeOfBlackWhiteBlackRunBothWays(n,r,s,o){let a=this.sizeOfBlackWhiteBlackRun(n,r,s,o),u=1,d=n-(s-n);d<0?(u=n/(n-d),d=0):d>=this.image.getWidth()&&(u=(this.image.getWidth()-1-n)/(d-n),d=this.image.getWidth()-1);let h=Math.floor(r-(o-r)*u);return u=1,h<0?(u=r/(r-h),h=0):h>=this.image.getHeight()&&(u=(this.image.getHeight()-1-r)/(h-r),h=this.image.getHeight()-1),d=Math.floor(n+(d-n)*u),a+=this.sizeOfBlackWhiteBlackRun(n,r,d,h),a-1}sizeOfBlackWhiteBlackRun(n,r,s,o){const a=Math.abs(o-r)>Math.abs(s-n);if(a){let I=n;n=r,r=I,I=s,s=o,o=I}const u=Math.abs(s-n),d=Math.abs(o-r);let h=-u/2;const g=n<s?1:-1,x=r<o?1:-1;let E=0;const A=s+g;for(let I=n,b=r;I!==A;I+=g){const D=a?b:I,L=a?I:b;if(E===1===this.image.get(D,L)){if(E===2)return Te.distance(I,b,n,r);E++}if(h+=d,h>0){if(b===o)break;b+=x,h-=u}}return E===2?Te.distance(s+g,o,n,r):NaN}findAlignmentInRegion(n,r,s,o){const a=Math.floor(o*n),u=Math.max(0,r-a),d=Math.min(this.image.getWidth()-1,r+a);if(d-u<n*3)throw new j("Alignment top exceeds estimated module size.");const h=Math.max(0,s-a),g=Math.min(this.image.getHeight()-1,s+a);if(g-h<n*3)throw new j("Alignment bottom exceeds estimated module size.");return new fo(this.image,u,h,d-u,g-h,n,this.resultPointCallback).find()}}class ur{constructor(){this.decoder=new Fh}getDecoder(){return this.decoder}decode(n,r){let s,o;if(r!=null&&r.get(U.PURE_BARCODE)!==void 0){const h=ur.extractPureBits(n.getBlackMatrix());s=this.decoder.decodeBitMatrix(h,r),o=ur.NO_POINTS}else{const h=new es(n.getBlackMatrix()).detect(r);s=this.decoder.decodeBitMatrix(h.getBits(),r),o=h.getPoints()}s.getOther()instanceof n1&&s.getOther().applyMirroredCorrection(o);const a=new Ke(s.getText(),s.getRawBytes(),void 0,o,le.QR_CODE,void 0),u=s.getByteSegments();u!==null&&a.putMetadata(mt.BYTE_SEGMENTS,u);const d=s.getECLevel();return d!==null&&a.putMetadata(mt.ERROR_CORRECTION_LEVEL,d),s.hasStructuredAppend()&&(a.putMetadata(mt.STRUCTURED_APPEND_SEQUENCE,s.getStructuredAppendSequenceNumber()),a.putMetadata(mt.STRUCTURED_APPEND_PARITY,s.getStructuredAppendParity())),a}reset(){}static extractPureBits(n){const r=n.getTopLeftOnBit(),s=n.getBottomRightOnBit();if(r===null||s===null)throw new j;const o=this.moduleSize(r,n);let a=r[1],u=s[1],d=r[0],h=s[0];if(d>=h||a>=u)throw new j;if(u-a!==h-d&&(h=d+(u-a),h>=n.getWidth()))throw new j;const g=Math.round((h-d+1)/o),x=Math.round((u-a+1)/o);if(g<=0||x<=0)throw new j;if(x!==g)throw new j;const E=Math.floor(o/2);a+=E,d+=E;const A=d+Math.floor((g-1)*o)-h;if(A>0){if(A>E)throw new j;d-=A}const I=a+Math.floor((x-1)*o)-u;if(I>0){if(I>E)throw new j;a-=I}const b=new _e(g,x);for(let D=0;D<x;D++){const L=a+Math.floor(D*o);for(let z=0;z<g;z++)n.get(d+Math.floor(z*o),L)&&b.set(z,D)}return b}static moduleSize(n,r){const s=r.getHeight(),o=r.getWidth();let a=n[0],u=n[1],d=!0,h=0;for(;a<o&&u<s;){if(d!==r.get(a,u)){if(++h===5)break;d=!d}a++,u++}if(a===o||u===s)throw new j;return(a-n[0])/7}}ur.NO_POINTS=new Array;class he{PDF417Common(){}static getBitCountSum(n){return Te.sum(n)}static toIntArray(n){if(n==null||!n.length)return he.EMPTY_INT_ARRAY;const r=new Int32Array(n.length);let s=0;for(const o of n)r[s++]=o;return r}static getCodeword(n){const r=T.binarySearch(he.SYMBOL_TABLE,n&262143);return r<0?-1:(he.CODEWORD_TABLE[r]-1)%he.NUMBER_OF_CODEWORDS}}he.NUMBER_OF_CODEWORDS=929,he.MAX_CODEWORDS_IN_BARCODE=he.NUMBER_OF_CODEWORDS-1,he.MIN_ROWS_IN_BARCODE=3,he.MAX_ROWS_IN_BARCODE=90,he.MODULES_IN_CODEWORD=17,he.MODULES_IN_STOP_PATTERN=18,he.BARS_IN_MODULE=8,he.EMPTY_INT_ARRAY=new Int32Array([]),he.SYMBOL_TABLE=Int32Array.from([66142,66170,66206,66236,66290,66292,66350,66382,66396,66454,66470,66476,66594,66600,66614,66626,66628,66632,66640,66654,66662,66668,66682,66690,66718,66720,66748,66758,66776,66798,66802,66804,66820,66824,66832,66846,66848,66876,66880,66936,66950,66956,66968,66992,67006,67022,67036,67042,67044,67048,67062,67118,67150,67164,67214,67228,67256,67294,67322,67350,67366,67372,67398,67404,67416,67438,67474,67476,67490,67492,67496,67510,67618,67624,67650,67656,67664,67678,67686,67692,67706,67714,67716,67728,67742,67744,67772,67782,67788,67800,67822,67826,67828,67842,67848,67870,67872,67900,67904,67960,67974,67992,68016,68030,68046,68060,68066,68068,68072,68086,68104,68112,68126,68128,68156,68160,68216,68336,68358,68364,68376,68400,68414,68448,68476,68494,68508,68536,68546,68548,68552,68560,68574,68582,68588,68654,68686,68700,68706,68708,68712,68726,68750,68764,68792,68802,68804,68808,68816,68830,68838,68844,68858,68878,68892,68920,68976,68990,68994,68996,69e3,69008,69022,69024,69052,69062,69068,69080,69102,69106,69108,69142,69158,69164,69190,69208,69230,69254,69260,69272,69296,69310,69326,69340,69386,69394,69396,69410,69416,69430,69442,69444,69448,69456,69470,69478,69484,69554,69556,69666,69672,69698,69704,69712,69726,69754,69762,69764,69776,69790,69792,69820,69830,69836,69848,69870,69874,69876,69890,69918,69920,69948,69952,70008,70022,70040,70064,70078,70094,70108,70114,70116,70120,70134,70152,70174,70176,70264,70384,70412,70448,70462,70496,70524,70542,70556,70584,70594,70600,70608,70622,70630,70636,70664,70672,70686,70688,70716,70720,70776,70896,71136,71180,71192,71216,71230,71264,71292,71360,71416,71452,71480,71536,71550,71554,71556,71560,71568,71582,71584,71612,71622,71628,71640,71662,71726,71732,71758,71772,71778,71780,71784,71798,71822,71836,71864,71874,71880,71888,71902,71910,71916,71930,71950,71964,71992,72048,72062,72066,72068,72080,72094,72096,72124,72134,72140,72152,72174,72178,72180,72206,72220,72248,72304,72318,72416,72444,72456,72464,72478,72480,72508,72512,72568,72588,72600,72624,72638,72654,72668,72674,72676,72680,72694,72726,72742,72748,72774,72780,72792,72814,72838,72856,72880,72894,72910,72924,72930,72932,72936,72950,72966,72972,72984,73008,73022,73056,73084,73102,73116,73144,73156,73160,73168,73182,73190,73196,73210,73226,73234,73236,73250,73252,73256,73270,73282,73284,73296,73310,73318,73324,73346,73348,73352,73360,73374,73376,73404,73414,73420,73432,73454,73498,73518,73522,73524,73550,73564,73570,73572,73576,73590,73800,73822,73858,73860,73872,73886,73888,73916,73944,73970,73972,73992,74014,74016,74044,74048,74104,74118,74136,74160,74174,74210,74212,74216,74230,74244,74256,74270,74272,74360,74480,74502,74508,74544,74558,74592,74620,74638,74652,74680,74690,74696,74704,74726,74732,74782,74784,74812,74992,75232,75288,75326,75360,75388,75456,75512,75576,75632,75646,75650,75652,75664,75678,75680,75708,75718,75724,75736,75758,75808,75836,75840,75896,76016,76256,76736,76824,76848,76862,76896,76924,76992,77048,77296,77340,77368,77424,77438,77536,77564,77572,77576,77584,77600,77628,77632,77688,77702,77708,77720,77744,77758,77774,77788,77870,77902,77916,77922,77928,77966,77980,78008,78018,78024,78032,78046,78060,78074,78094,78136,78192,78206,78210,78212,78224,78238,78240,78268,78278,78284,78296,78322,78324,78350,78364,78448,78462,78560,78588,78600,78622,78624,78652,78656,78712,78726,78744,78768,78782,78798,78812,78818,78820,78824,78838,78862,78876,78904,78960,78974,79072,79100,79296,79352,79368,79376,79390,79392,79420,79424,79480,79600,79628,79640,79664,79678,79712,79740,79772,79800,79810,79812,79816,79824,79838,79846,79852,79894,79910,79916,79942,79948,79960,79982,79988,80006,80024,80048,80062,80078,80092,80098,80100,80104,80134,80140,80176,80190,80224,80252,80270,80284,80312,80328,80336,80350,80358,80364,80378,80390,80396,80408,80432,80446,80480,80508,80576,80632,80654,80668,80696,80752,80766,80776,80784,80798,80800,80828,80844,80856,80878,80882,80884,80914,80916,80930,80932,80936,80950,80962,80968,80976,80990,80998,81004,81026,81028,81040,81054,81056,81084,81094,81100,81112,81134,81154,81156,81160,81168,81182,81184,81212,81216,81272,81286,81292,81304,81328,81342,81358,81372,81380,81384,81398,81434,81454,81458,81460,81486,81500,81506,81508,81512,81526,81550,81564,81592,81602,81604,81608,81616,81630,81638,81644,81702,81708,81722,81734,81740,81752,81774,81778,81780,82050,82078,82080,82108,82180,82184,82192,82206,82208,82236,82240,82296,82316,82328,82352,82366,82402,82404,82408,82440,82448,82462,82464,82492,82496,82552,82672,82694,82700,82712,82736,82750,82784,82812,82830,82882,82884,82888,82896,82918,82924,82952,82960,82974,82976,83004,83008,83064,83184,83424,83468,83480,83504,83518,83552,83580,83648,83704,83740,83768,83824,83838,83842,83844,83848,83856,83872,83900,83910,83916,83928,83950,83984,84e3,84028,84032,84088,84208,84448,84928,85040,85054,85088,85116,85184,85240,85488,85560,85616,85630,85728,85756,85764,85768,85776,85790,85792,85820,85824,85880,85894,85900,85912,85936,85966,85980,86048,86080,86136,86256,86496,86976,88160,88188,88256,88312,88560,89056,89200,89214,89312,89340,89536,89592,89608,89616,89632,89664,89720,89840,89868,89880,89904,89952,89980,89998,90012,90040,90190,90204,90254,90268,90296,90306,90308,90312,90334,90382,90396,90424,90480,90494,90500,90504,90512,90526,90528,90556,90566,90572,90584,90610,90612,90638,90652,90680,90736,90750,90848,90876,90884,90888,90896,90910,90912,90940,90944,91e3,91014,91020,91032,91056,91070,91086,91100,91106,91108,91112,91126,91150,91164,91192,91248,91262,91360,91388,91584,91640,91664,91678,91680,91708,91712,91768,91888,91928,91952,91966,92e3,92028,92046,92060,92088,92098,92100,92104,92112,92126,92134,92140,92188,92216,92272,92384,92412,92608,92664,93168,93200,93214,93216,93244,93248,93304,93424,93664,93720,93744,93758,93792,93820,93888,93944,93980,94008,94064,94078,94084,94088,94096,94110,94112,94140,94150,94156,94168,94246,94252,94278,94284,94296,94318,94342,94348,94360,94384,94398,94414,94428,94440,94470,94476,94488,94512,94526,94560,94588,94606,94620,94648,94658,94660,94664,94672,94686,94694,94700,94714,94726,94732,94744,94768,94782,94816,94844,94912,94968,94990,95004,95032,95088,95102,95112,95120,95134,95136,95164,95180,95192,95214,95218,95220,95244,95256,95280,95294,95328,95356,95424,95480,95728,95758,95772,95800,95856,95870,95968,95996,96008,96016,96030,96032,96060,96064,96120,96152,96176,96190,96220,96226,96228,96232,96290,96292,96296,96310,96322,96324,96328,96336,96350,96358,96364,96386,96388,96392,96400,96414,96416,96444,96454,96460,96472,96494,96498,96500,96514,96516,96520,96528,96542,96544,96572,96576,96632,96646,96652,96664,96688,96702,96718,96732,96738,96740,96744,96758,96772,96776,96784,96798,96800,96828,96832,96888,97008,97030,97036,97048,97072,97086,97120,97148,97166,97180,97208,97220,97224,97232,97246,97254,97260,97326,97330,97332,97358,97372,97378,97380,97384,97398,97422,97436,97464,97474,97476,97480,97488,97502,97510,97516,97550,97564,97592,97648,97666,97668,97672,97680,97694,97696,97724,97734,97740,97752,97774,97830,97836,97850,97862,97868,97880,97902,97906,97908,97926,97932,97944,97968,97998,98012,98018,98020,98024,98038,98618,98674,98676,98838,98854,98874,98892,98904,98926,98930,98932,98968,99006,99042,99044,99048,99062,99166,99194,99246,99286,99350,99366,99372,99386,99398,99416,99438,99442,99444,99462,99504,99518,99534,99548,99554,99556,99560,99574,99590,99596,99608,99632,99646,99680,99708,99726,99740,99768,99778,99780,99784,99792,99806,99814,99820,99834,99858,99860,99874,99880,99894,99906,99920,99934,99962,99970,99972,99976,99984,99998,1e5,100028,100038,100044,100056,100078,100082,100084,100142,100174,100188,100246,100262,100268,100306,100308,100390,100396,100410,100422,100428,100440,100462,100466,100468,100486,100504,100528,100542,100558,100572,100578,100580,100584,100598,100620,100656,100670,100704,100732,100750,100792,100802,100808,100816,100830,100838,100844,100858,100888,100912,100926,100960,100988,101056,101112,101148,101176,101232,101246,101250,101252,101256,101264,101278,101280,101308,101318,101324,101336,101358,101362,101364,101410,101412,101416,101430,101442,101448,101456,101470,101478,101498,101506,101508,101520,101534,101536,101564,101580,101618,101620,101636,101640,101648,101662,101664,101692,101696,101752,101766,101784,101838,101858,101860,101864,101934,101938,101940,101966,101980,101986,101988,101992,102030,102044,102072,102082,102084,102088,102096,102138,102166,102182,102188,102214,102220,102232,102254,102282,102290,102292,102306,102308,102312,102326,102444,102458,102470,102476,102488,102514,102516,102534,102552,102576,102590,102606,102620,102626,102632,102646,102662,102668,102704,102718,102752,102780,102798,102812,102840,102850,102856,102864,102878,102886,102892,102906,102936,102974,103008,103036,103104,103160,103224,103280,103294,103298,103300,103312,103326,103328,103356,103366,103372,103384,103406,103410,103412,103472,103486,103520,103548,103616,103672,103920,103992,104048,104062,104160,104188,104194,104196,104200,104208,104224,104252,104256,104312,104326,104332,104344,104368,104382,104398,104412,104418,104420,104424,104482,104484,104514,104520,104528,104542,104550,104570,104578,104580,104592,104606,104608,104636,104652,104690,104692,104706,104712,104734,104736,104764,104768,104824,104838,104856,104910,104930,104932,104936,104968,104976,104990,104992,105020,105024,105080,105200,105240,105278,105312,105372,105410,105412,105416,105424,105446,105518,105524,105550,105564,105570,105572,105576,105614,105628,105656,105666,105672,105680,105702,105722,105742,105756,105784,105840,105854,105858,105860,105864,105872,105888,105932,105970,105972,106006,106022,106028,106054,106060,106072,106100,106118,106124,106136,106160,106174,106190,106210,106212,106216,106250,106258,106260,106274,106276,106280,106306,106308,106312,106320,106334,106348,106394,106414,106418,106420,106566,106572,106610,106612,106630,106636,106648,106672,106686,106722,106724,106728,106742,106758,106764,106776,106800,106814,106848,106876,106894,106908,106936,106946,106948,106952,106960,106974,106982,106988,107032,107056,107070,107104,107132,107200,107256,107292,107320,107376,107390,107394,107396,107400,107408,107422,107424,107452,107462,107468,107480,107502,107506,107508,107544,107568,107582,107616,107644,107712,107768,108016,108060,108088,108144,108158,108256,108284,108290,108292,108296,108304,108318,108320,108348,108352,108408,108422,108428,108440,108464,108478,108494,108508,108514,108516,108520,108592,108640,108668,108736,108792,109040,109536,109680,109694,109792,109820,110016,110072,110084,110088,110096,110112,110140,110144,110200,110320,110342,110348,110360,110384,110398,110432,110460,110478,110492,110520,110532,110536,110544,110558,110658,110686,110714,110722,110724,110728,110736,110750,110752,110780,110796,110834,110836,110850,110852,110856,110864,110878,110880,110908,110912,110968,110982,111e3,111054,111074,111076,111080,111108,111112,111120,111134,111136,111164,111168,111224,111344,111372,111422,111456,111516,111554,111556,111560,111568,111590,111632,111646,111648,111676,111680,111736,111856,112096,112152,112224,112252,112320,112440,112514,112516,112520,112528,112542,112544,112588,112686,112718,112732,112782,112796,112824,112834,112836,112840,112848,112870,112890,112910,112924,112952,113008,113022,113026,113028,113032,113040,113054,113056,113100,113138,113140,113166,113180,113208,113264,113278,113376,113404,113416,113424,113440,113468,113472,113560,113614,113634,113636,113640,113686,113702,113708,113734,113740,113752,113778,113780,113798,113804,113816,113840,113854,113870,113890,113892,113896,113926,113932,113944,113968,113982,114016,114044,114076,114114,114116,114120,114128,114150,114170,114194,114196,114210,114212,114216,114242,114244,114248,114256,114270,114278,114306,114308,114312,114320,114334,114336,114364,114380,114420,114458,114478,114482,114484,114510,114524,114530,114532,114536,114842,114866,114868,114970,114994,114996,115042,115044,115048,115062,115130,115226,115250,115252,115278,115292,115298,115300,115304,115318,115342,115394,115396,115400,115408,115422,115430,115436,115450,115478,115494,115514,115526,115532,115570,115572,115738,115758,115762,115764,115790,115804,115810,115812,115816,115830,115854,115868,115896,115906,115912,115920,115934,115942,115948,115962,115996,116024,116080,116094,116098,116100,116104,116112,116126,116128,116156,116166,116172,116184,116206,116210,116212,116246,116262,116268,116282,116294,116300,116312,116334,116338,116340,116358,116364,116376,116400,116414,116430,116444,116450,116452,116456,116498,116500,116514,116520,116534,116546,116548,116552,116560,116574,116582,116588,116602,116654,116694,116714,116762,116782,116786,116788,116814,116828,116834,116836,116840,116854,116878,116892,116920,116930,116936,116944,116958,116966,116972,116986,117006,117048,117104,117118,117122,117124,117136,117150,117152,117180,117190,117196,117208,117230,117234,117236,117304,117360,117374,117472,117500,117506,117508,117512,117520,117536,117564,117568,117624,117638,117644,117656,117680,117694,117710,117724,117730,117732,117736,117750,117782,117798,117804,117818,117830,117848,117874,117876,117894,117936,117950,117966,117986,117988,117992,118022,118028,118040,118064,118078,118112,118140,118172,118210,118212,118216,118224,118238,118246,118266,118306,118312,118338,118352,118366,118374,118394,118402,118404,118408,118416,118430,118432,118460,118476,118514,118516,118574,118578,118580,118606,118620,118626,118628,118632,118678,118694,118700,118730,118738,118740,118830,118834,118836,118862,118876,118882,118884,118888,118902,118926,118940,118968,118978,118980,118984,118992,119006,119014,119020,119034,119068,119096,119152,119166,119170,119172,119176,119184,119198,119200,119228,119238,119244,119256,119278,119282,119284,119324,119352,119408,119422,119520,119548,119554,119556,119560,119568,119582,119584,119612,119616,119672,119686,119692,119704,119728,119742,119758,119772,119778,119780,119784,119798,119920,119934,120032,120060,120256,120312,120324,120328,120336,120352,120384,120440,120560,120582,120588,120600,120624,120638,120672,120700,120718,120732,120760,120770,120772,120776,120784,120798,120806,120812,120870,120876,120890,120902,120908,120920,120946,120948,120966,120972,120984,121008,121022,121038,121058,121060,121064,121078,121100,121112,121136,121150,121184,121212,121244,121282,121284,121288,121296,121318,121338,121356,121368,121392,121406,121440,121468,121536,121592,121656,121730,121732,121736,121744,121758,121760,121804,121842,121844,121890,121922,121924,121928,121936,121950,121958,121978,121986,121988,121992,122e3,122014,122016,122044,122060,122098,122100,122116,122120,122128,122142,122144,122172,122176,122232,122246,122264,122318,122338,122340,122344,122414,122418,122420,122446,122460,122466,122468,122472,122510,122524,122552,122562,122564,122568,122576,122598,122618,122646,122662,122668,122694,122700,122712,122738,122740,122762,122770,122772,122786,122788,122792,123018,123026,123028,123042,123044,123048,123062,123098,123146,123154,123156,123170,123172,123176,123190,123202,123204,123208,123216,123238,123244,123258,123290,123314,123316,123402,123410,123412,123426,123428,123432,123446,123458,123464,123472,123486,123494,123500,123514,123522,123524,123528,123536,123552,123580,123590,123596,123608,123630,123634,123636,123674,123698,123700,123740,123746,123748,123752,123834,123914,123922,123924,123938,123944,123958,123970,123976,123984,123998,124006,124012,124026,124034,124036,124048,124062,124064,124092,124102,124108,124120,124142,124146,124148,124162,124164,124168,124176,124190,124192,124220,124224,124280,124294,124300,124312,124336,124350,124366,124380,124386,124388,124392,124406,124442,124462,124466,124468,124494,124508,124514,124520,124558,124572,124600,124610,124612,124616,124624,124646,124666,124694,124710,124716,124730,124742,124748,124760,124786,124788,124818,124820,124834,124836,124840,124854,124946,124948,124962,124964,124968,124982,124994,124996,125e3,125008,125022,125030,125036,125050,125058,125060,125064,125072,125086,125088,125116,125126,125132,125144,125166,125170,125172,125186,125188,125192,125200,125216,125244,125248,125304,125318,125324,125336,125360,125374,125390,125404,125410,125412,125416,125430,125444,125448,125456,125472,125504,125560,125680,125702,125708,125720,125744,125758,125792,125820,125838,125852,125880,125890,125892,125896,125904,125918,125926,125932,125978,125998,126002,126004,126030,126044,126050,126052,126056,126094,126108,126136,126146,126148,126152,126160,126182,126202,126222,126236,126264,126320,126334,126338,126340,126344,126352,126366,126368,126412,126450,126452,126486,126502,126508,126522,126534,126540,126552,126574,126578,126580,126598,126604,126616,126640,126654,126670,126684,126690,126692,126696,126738,126754,126756,126760,126774,126786,126788,126792,126800,126814,126822,126828,126842,126894,126898,126900,126934,127126,127142,127148,127162,127178,127186,127188,127254,127270,127276,127290,127302,127308,127320,127342,127346,127348,127370,127378,127380,127394,127396,127400,127450,127510,127526,127532,127546,127558,127576,127598,127602,127604,127622,127628,127640,127664,127678,127694,127708,127714,127716,127720,127734,127754,127762,127764,127778,127784,127810,127812,127816,127824,127838,127846,127866,127898,127918,127922,127924,128022,128038,128044,128058,128070,128076,128088,128110,128114,128116,128134,128140,128152,128176,128190,128206,128220,128226,128228,128232,128246,128262,128268,128280,128304,128318,128352,128380,128398,128412,128440,128450,128452,128456,128464,128478,128486,128492,128506,128522,128530,128532,128546,128548,128552,128566,128578,128580,128584,128592,128606,128614,128634,128642,128644,128648,128656,128670,128672,128700,128716,128754,128756,128794,128814,128818,128820,128846,128860,128866,128868,128872,128886,128918,128934,128940,128954,128978,128980,129178,129198,129202,129204,129238,129258,129306,129326,129330,129332,129358,129372,129378,129380,129384,129398,129430,129446,129452,129466,129482,129490,129492,129562,129582,129586,129588,129614,129628,129634,129636,129640,129654,129678,129692,129720,129730,129732,129736,129744,129758,129766,129772,129814,129830,129836,129850,129862,129868,129880,129902,129906,129908,129930,129938,129940,129954,129956,129960,129974,130010]),he.CODEWORD_TABLE=Int32Array.from([2627,1819,2622,2621,1813,1812,2729,2724,2723,2779,2774,2773,902,896,908,868,865,861,859,2511,873,871,1780,835,2493,825,2491,842,837,844,1764,1762,811,810,809,2483,807,2482,806,2480,815,814,813,812,2484,817,816,1745,1744,1742,1746,2655,2637,2635,2626,2625,2623,2628,1820,2752,2739,2737,2728,2727,2725,2730,2785,2783,2778,2777,2775,2780,787,781,747,739,736,2413,754,752,1719,692,689,681,2371,678,2369,700,697,694,703,1688,1686,642,638,2343,631,2341,627,2338,651,646,643,2345,654,652,1652,1650,1647,1654,601,599,2322,596,2321,594,2319,2317,611,610,608,606,2324,603,2323,615,614,612,1617,1616,1614,1612,616,1619,1618,2575,2538,2536,905,901,898,909,2509,2507,2504,870,867,864,860,2512,875,872,1781,2490,2489,2487,2485,1748,836,834,832,830,2494,827,2492,843,841,839,845,1765,1763,2701,2676,2674,2653,2648,2656,2634,2633,2631,2629,1821,2638,2636,2770,2763,2761,2750,2745,2753,2736,2735,2733,2731,1848,2740,2738,2786,2784,591,588,576,569,566,2296,1590,537,534,526,2276,522,2274,545,542,539,548,1572,1570,481,2245,466,2242,462,2239,492,485,482,2249,496,494,1534,1531,1528,1538,413,2196,406,2191,2188,425,419,2202,415,2199,432,430,427,1472,1467,1464,433,1476,1474,368,367,2160,365,2159,362,2157,2155,2152,378,377,375,2166,372,2165,369,2162,383,381,379,2168,1419,1418,1416,1414,385,1411,384,1423,1422,1420,1424,2461,802,2441,2439,790,786,783,794,2409,2406,2403,750,742,738,2414,756,753,1720,2367,2365,2362,2359,1663,693,691,684,2373,680,2370,702,699,696,704,1690,1687,2337,2336,2334,2332,1624,2329,1622,640,637,2344,634,2342,630,2340,650,648,645,2346,655,653,1653,1651,1649,1655,2612,2597,2595,2571,2568,2565,2576,2534,2529,2526,1787,2540,2537,907,904,900,910,2503,2502,2500,2498,1768,2495,1767,2510,2508,2506,869,866,863,2513,876,874,1782,2720,2713,2711,2697,2694,2691,2702,2672,2670,2664,1828,2678,2675,2647,2646,2644,2642,1823,2639,1822,2654,2652,2650,2657,2771,1855,2765,2762,1850,1849,2751,2749,2747,2754,353,2148,344,342,336,2142,332,2140,345,1375,1373,306,2130,299,2128,295,2125,319,314,311,2132,1354,1352,1349,1356,262,257,2101,253,2096,2093,274,273,267,2107,263,2104,280,278,275,1316,1311,1308,1320,1318,2052,202,2050,2044,2040,219,2063,212,2060,208,2055,224,221,2066,1260,1258,1252,231,1248,229,1266,1264,1261,1268,155,1998,153,1996,1994,1991,1988,165,164,2007,162,2006,159,2003,2e3,172,171,169,2012,166,2010,1186,1184,1182,1179,175,1176,173,1192,1191,1189,1187,176,1194,1193,2313,2307,2305,592,589,2294,2292,2289,578,572,568,2297,580,1591,2272,2267,2264,1547,538,536,529,2278,525,2275,547,544,541,1574,1571,2237,2235,2229,1493,2225,1489,478,2247,470,2244,465,2241,493,488,484,2250,498,495,1536,1533,1530,1539,2187,2186,2184,2182,1432,2179,1430,2176,1427,414,412,2197,409,2195,405,2193,2190,426,424,421,2203,418,2201,431,429,1473,1471,1469,1466,434,1477,1475,2478,2472,2470,2459,2457,2454,2462,803,2437,2432,2429,1726,2443,2440,792,789,785,2401,2399,2393,1702,2389,1699,2411,2408,2405,745,741,2415,758,755,1721,2358,2357,2355,2353,1661,2350,1660,2347,1657,2368,2366,2364,2361,1666,690,687,2374,683,2372,701,698,705,1691,1689,2619,2617,2610,2608,2605,2613,2593,2588,2585,1803,2599,2596,2563,2561,2555,1797,2551,1795,2573,2570,2567,2577,2525,2524,2522,2520,1786,2517,1785,2514,1783,2535,2533,2531,2528,1788,2541,2539,906,903,911,2721,1844,2715,2712,1838,1836,2699,2696,2693,2703,1827,1826,1824,2673,2671,2669,2666,1829,2679,2677,1858,1857,2772,1854,1853,1851,1856,2766,2764,143,1987,139,1986,135,133,131,1984,128,1983,125,1981,138,137,136,1985,1133,1132,1130,112,110,1974,107,1973,104,1971,1969,122,121,119,117,1977,114,1976,124,1115,1114,1112,1110,1117,1116,84,83,1953,81,1952,78,1950,1948,1945,94,93,91,1959,88,1958,85,1955,99,97,95,1961,1086,1085,1083,1081,1078,100,1090,1089,1087,1091,49,47,1917,44,1915,1913,1910,1907,59,1926,56,1925,53,1922,1919,66,64,1931,61,1929,1042,1040,1038,71,1035,70,1032,68,1048,1047,1045,1043,1050,1049,12,10,1869,1867,1864,1861,21,1880,19,1877,1874,1871,28,1888,25,1886,22,1883,982,980,977,974,32,30,991,989,987,984,34,995,994,992,2151,2150,2147,2146,2144,356,355,354,2149,2139,2138,2136,2134,1359,343,341,338,2143,335,2141,348,347,346,1376,1374,2124,2123,2121,2119,1326,2116,1324,310,308,305,2131,302,2129,298,2127,320,318,316,313,2133,322,321,1355,1353,1351,1357,2092,2091,2089,2087,1276,2084,1274,2081,1271,259,2102,256,2100,252,2098,2095,272,269,2108,266,2106,281,279,277,1317,1315,1313,1310,282,1321,1319,2039,2037,2035,2032,1203,2029,1200,1197,207,2053,205,2051,201,2049,2046,2043,220,218,2064,215,2062,211,2059,228,226,223,2069,1259,1257,1254,232,1251,230,1267,1265,1263,2316,2315,2312,2311,2309,2314,2304,2303,2301,2299,1593,2308,2306,590,2288,2287,2285,2283,1578,2280,1577,2295,2293,2291,579,577,574,571,2298,582,581,1592,2263,2262,2260,2258,1545,2255,1544,2252,1541,2273,2271,2269,2266,1550,535,532,2279,528,2277,546,543,549,1575,1573,2224,2222,2220,1486,2217,1485,2214,1482,1479,2238,2236,2234,2231,1496,2228,1492,480,477,2248,473,2246,469,2243,490,487,2251,497,1537,1535,1532,2477,2476,2474,2479,2469,2468,2466,2464,1730,2473,2471,2453,2452,2450,2448,1729,2445,1728,2460,2458,2456,2463,805,804,2428,2427,2425,2423,1725,2420,1724,2417,1722,2438,2436,2434,2431,1727,2444,2442,793,791,788,795,2388,2386,2384,1697,2381,1696,2378,1694,1692,2402,2400,2398,2395,1703,2392,1701,2412,2410,2407,751,748,744,2416,759,757,1807,2620,2618,1806,1805,2611,2609,2607,2614,1802,1801,1799,2594,2592,2590,2587,1804,2600,2598,1794,1793,1791,1789,2564,2562,2560,2557,1798,2554,1796,2574,2572,2569,2578,1847,1846,2722,1843,1842,1840,1845,2716,2714,1835,1834,1832,1830,1839,1837,2700,2698,2695,2704,1817,1811,1810,897,862,1777,829,826,838,1760,1758,808,2481,1741,1740,1738,1743,2624,1818,2726,2776,782,740,737,1715,686,679,695,1682,1680,639,628,2339,647,644,1645,1643,1640,1648,602,600,597,595,2320,593,2318,609,607,604,1611,1610,1608,1606,613,1615,1613,2328,926,924,892,886,899,857,850,2505,1778,824,823,821,819,2488,818,2486,833,831,828,840,1761,1759,2649,2632,2630,2746,2734,2732,2782,2781,570,567,1587,531,527,523,540,1566,1564,476,467,463,2240,486,483,1524,1521,1518,1529,411,403,2192,399,2189,423,416,1462,1457,1454,428,1468,1465,2210,366,363,2158,360,2156,357,2153,376,373,370,2163,1410,1409,1407,1405,382,1402,380,1417,1415,1412,1421,2175,2174,777,774,771,784,732,725,722,2404,743,1716,676,674,668,2363,665,2360,685,1684,1681,626,624,622,2335,620,2333,617,2330,641,635,649,1646,1644,1642,2566,928,925,2530,2527,894,891,888,2501,2499,2496,858,856,854,851,1779,2692,2668,2665,2645,2643,2640,2651,2768,2759,2757,2744,2743,2741,2748,352,1382,340,337,333,1371,1369,307,300,296,2126,315,312,1347,1342,1350,261,258,250,2097,246,2094,271,268,264,1306,1301,1298,276,1312,1309,2115,203,2048,195,2045,191,2041,213,209,2056,1246,1244,1238,225,1234,222,1256,1253,1249,1262,2080,2079,154,1997,150,1995,147,1992,1989,163,160,2004,156,2001,1175,1174,1172,1170,1167,170,1164,167,1185,1183,1180,1177,174,1190,1188,2025,2024,2022,587,586,564,559,556,2290,573,1588,520,518,512,2268,508,2265,530,1568,1565,461,457,2233,450,2230,446,2226,479,471,489,1526,1523,1520,397,395,2185,392,2183,389,2180,2177,410,2194,402,422,1463,1461,1459,1456,1470,2455,799,2433,2430,779,776,773,2397,2394,2390,734,728,724,746,1717,2356,2354,2351,2348,1658,677,675,673,670,667,688,1685,1683,2606,2589,2586,2559,2556,2552,927,2523,2521,2518,2515,1784,2532,895,893,890,2718,2709,2707,2689,2687,2684,2663,2662,2660,2658,1825,2667,2769,1852,2760,2758,142,141,1139,1138,134,132,129,126,1982,1129,1128,1126,1131,113,111,108,105,1972,101,1970,120,118,115,1109,1108,1106,1104,123,1113,1111,82,79,1951,75,1949,72,1946,92,89,86,1956,1077,1076,1074,1072,98,1069,96,1084,1082,1079,1088,1968,1967,48,45,1916,42,1914,39,1911,1908,60,57,54,1923,50,1920,1031,1030,1028,1026,67,1023,65,1020,62,1041,1039,1036,1033,69,1046,1044,1944,1943,1941,11,9,1868,7,1865,1862,1859,20,1878,16,1875,13,1872,970,968,966,963,29,960,26,23,983,981,978,975,33,971,31,990,988,985,1906,1904,1902,993,351,2145,1383,331,330,328,326,2137,323,2135,339,1372,1370,294,293,291,289,2122,286,2120,283,2117,309,303,317,1348,1346,1344,245,244,242,2090,239,2088,236,2085,2082,260,2099,249,270,1307,1305,1303,1300,1314,189,2038,186,2036,183,2033,2030,2026,206,198,2047,194,216,1247,1245,1243,1240,227,1237,1255,2310,2302,2300,2286,2284,2281,565,563,561,558,575,1589,2261,2259,2256,2253,1542,521,519,517,514,2270,511,533,1569,1567,2223,2221,2218,2215,1483,2211,1480,459,456,453,2232,449,474,491,1527,1525,1522,2475,2467,2465,2451,2449,2446,801,800,2426,2424,2421,2418,1723,2435,780,778,775,2387,2385,2382,2379,1695,2375,1693,2396,735,733,730,727,749,1718,2616,2615,2604,2603,2601,2584,2583,2581,2579,1800,2591,2550,2549,2547,2545,1792,2542,1790,2558,929,2719,1841,2710,2708,1833,1831,2690,2688,2686,1815,1809,1808,1774,1756,1754,1737,1736,1734,1739,1816,1711,1676,1674,633,629,1638,1636,1633,1641,598,1605,1604,1602,1600,605,1609,1607,2327,887,853,1775,822,820,1757,1755,1584,524,1560,1558,468,464,1514,1511,1508,1519,408,404,400,1452,1447,1444,417,1458,1455,2208,364,361,358,2154,1401,1400,1398,1396,374,1393,371,1408,1406,1403,1413,2173,2172,772,726,723,1712,672,669,666,682,1678,1675,625,623,621,618,2331,636,632,1639,1637,1635,920,918,884,880,889,849,848,847,846,2497,855,852,1776,2641,2742,2787,1380,334,1367,1365,301,297,1340,1338,1335,1343,255,251,247,1296,1291,1288,265,1302,1299,2113,204,196,192,2042,1232,1230,1224,214,1220,210,1242,1239,1235,1250,2077,2075,151,148,1993,144,1990,1163,1162,1160,1158,1155,161,1152,157,1173,1171,1168,1165,168,1181,1178,2021,2020,2018,2023,585,560,557,1585,516,509,1562,1559,458,447,2227,472,1516,1513,1510,398,396,393,390,2181,386,2178,407,1453,1451,1449,1446,420,1460,2209,769,764,720,712,2391,729,1713,664,663,661,659,2352,656,2349,671,1679,1677,2553,922,919,2519,2516,885,883,881,2685,2661,2659,2767,2756,2755,140,1137,1136,130,127,1125,1124,1122,1127,109,106,102,1103,1102,1100,1098,116,1107,1105,1980,80,76,73,1947,1068,1067,1065,1063,90,1060,87,1075,1073,1070,1080,1966,1965,46,43,40,1912,36,1909,1019,1018,1016,1014,58,1011,55,1008,51,1029,1027,1024,1021,63,1037,1034,1940,1939,1937,1942,8,1866,4,1863,1,1860,956,954,952,949,946,17,14,969,967,964,961,27,957,24,979,976,972,1901,1900,1898,1896,986,1905,1903,350,349,1381,329,327,324,1368,1366,292,290,287,284,2118,304,1341,1339,1337,1345,243,240,237,2086,233,2083,254,1297,1295,1293,1290,1304,2114,190,187,184,2034,180,2031,177,2027,199,1233,1231,1229,1226,217,1223,1241,2078,2076,584,555,554,552,550,2282,562,1586,507,506,504,502,2257,499,2254,515,1563,1561,445,443,441,2219,438,2216,435,2212,460,454,475,1517,1515,1512,2447,798,797,2422,2419,770,768,766,2383,2380,2376,721,719,717,714,731,1714,2602,2582,2580,2548,2546,2543,923,921,2717,2706,2705,2683,2682,2680,1771,1752,1750,1733,1732,1731,1735,1814,1707,1670,1668,1631,1629,1626,1634,1599,1598,1596,1594,1603,1601,2326,1772,1753,1751,1581,1554,1552,1504,1501,1498,1509,1442,1437,1434,401,1448,1445,2206,1392,1391,1389,1387,1384,359,1399,1397,1394,1404,2171,2170,1708,1672,1669,619,1632,1630,1628,1773,1378,1363,1361,1333,1328,1336,1286,1281,1278,248,1292,1289,2111,1218,1216,1210,197,1206,193,1228,1225,1221,1236,2073,2071,1151,1150,1148,1146,152,1143,149,1140,145,1161,1159,1156,1153,158,1169,1166,2017,2016,2014,2019,1582,510,1556,1553,452,448,1506,1500,394,391,387,1443,1441,1439,1436,1450,2207,765,716,713,1709,662,660,657,1673,1671,916,914,879,878,877,882,1135,1134,1121,1120,1118,1123,1097,1096,1094,1092,103,1101,1099,1979,1059,1058,1056,1054,77,1051,74,1066,1064,1061,1071,1964,1963,1007,1006,1004,1002,999,41,996,37,1017,1015,1012,1009,52,1025,1022,1936,1935,1933,1938,942,940,938,935,932,5,2,955,953,950,947,18,943,15,965,962,958,1895,1894,1892,1890,973,1899,1897,1379,325,1364,1362,288,285,1334,1332,1330,241,238,234,1287,1285,1283,1280,1294,2112,188,185,181,178,2028,1219,1217,1215,1212,200,1209,1227,2074,2072,583,553,551,1583,505,503,500,513,1557,1555,444,442,439,436,2213,455,451,1507,1505,1502,796,763,762,760,767,711,710,708,706,2377,718,715,1710,2544,917,915,2681,1627,1597,1595,2325,1769,1749,1747,1499,1438,1435,2204,1390,1388,1385,1395,2169,2167,1704,1665,1662,1625,1623,1620,1770,1329,1282,1279,2109,1214,1207,1222,2068,2065,1149,1147,1144,1141,146,1157,1154,2013,2011,2008,2015,1579,1549,1546,1495,1487,1433,1431,1428,1425,388,1440,2205,1705,658,1667,1664,1119,1095,1093,1978,1057,1055,1052,1062,1962,1960,1005,1003,1e3,997,38,1013,1010,1932,1930,1927,1934,941,939,936,933,6,930,3,951,948,944,1889,1887,1884,1881,959,1893,1891,35,1377,1360,1358,1327,1325,1322,1331,1277,1275,1272,1269,235,1284,2110,1205,1204,1201,1198,182,1195,179,1213,2070,2067,1580,501,1551,1548,440,437,1497,1494,1490,1503,761,709,707,1706,913,912,2198,1386,2164,2161,1621,1766,2103,1208,2058,2054,1145,1142,2005,2002,1999,2009,1488,1429,1426,2200,1698,1659,1656,1975,1053,1957,1954,1001,998,1924,1921,1918,1928,937,934,931,1879,1876,1873,1870,945,1885,1882,1323,1273,1270,2105,1202,1199,1196,1211,2061,2057,1576,1543,1540,1484,1481,1478,1491,1700]);class Wh{constructor(n,r){this.bits=n,this.points=r}getBits(){return this.bits}getPoints(){return this.points}}class we{static detectMultiple(n,r,s){let o=n.getBlackMatrix(),a=we.detect(s,o);return a.length||(o=o.clone(),o.rotate180(),a=we.detect(s,o)),new Wh(o,a)}static detect(n,r){const s=new Array;let o=0,a=0,u=!1;for(;o<r.getHeight();){const d=we.findVertices(r,o,a);if(d[0]==null&&d[3]==null){if(!u)break;u=!1,a=0;for(const h of s)h[1]!=null&&(o=Math.trunc(Math.max(o,h[1].getY()))),h[3]!=null&&(o=Math.max(o,Math.trunc(h[3].getY())));o+=we.ROW_STEP;continue}if(u=!0,s.push(d),!n)break;d[2]!=null?(a=Math.trunc(d[2].getX()),o=Math.trunc(d[2].getY())):(a=Math.trunc(d[4].getX()),o=Math.trunc(d[4].getY()))}return s}static findVertices(n,r,s){const o=n.getHeight(),a=n.getWidth(),u=new Array(8);return we.copyToResult(u,we.findRowsWithPattern(n,o,a,r,s,we.START_PATTERN),we.INDEXES_START_PATTERN),u[4]!=null&&(s=Math.trunc(u[4].getX()),r=Math.trunc(u[4].getY())),we.copyToResult(u,we.findRowsWithPattern(n,o,a,r,s,we.STOP_PATTERN),we.INDEXES_STOP_PATTERN),u}static copyToResult(n,r,s){for(let o=0;o<s.length;o++)n[s[o]]=r[o]}static findRowsWithPattern(n,r,s,o,a,u){const d=new Array(4);let h=!1;const g=new Int32Array(u.length);for(;o<r;o+=we.ROW_STEP){let E=we.findGuardPattern(n,a,o,s,!1,u,g);if(E!=null){for(;o>0;){const A=we.findGuardPattern(n,a,--o,s,!1,u,g);if(A!=null)E=A;else{o++;break}}d[0]=new oe(E[0],o),d[1]=new oe(E[1],o),h=!0;break}}let x=o+1;if(h){let E=0,A=Int32Array.from([Math.trunc(d[0].getX()),Math.trunc(d[1].getX())]);for(;x<r;x++){const I=we.findGuardPattern(n,A[0],x,s,!1,u,g);if(I!=null&&Math.abs(A[0]-I[0])<we.MAX_PATTERN_DRIFT&&Math.abs(A[1]-I[1])<we.MAX_PATTERN_DRIFT)A=I,E=0;else{if(E>we.SKIPPED_ROW_COUNT_MAX)break;E++}}x-=E+1,d[2]=new oe(A[0],x),d[3]=new oe(A[1],x)}return x-o<we.BARCODE_MIN_HEIGHT&&T.fill(d,null),d}static findGuardPattern(n,r,s,o,a,u,d){T.fillWithin(d,0,d.length,0);let h=r,g=0;for(;n.get(h,s)&&h>0&&g++<we.MAX_PIXEL_DRIFT;)h--;let x=h,E=0,A=u.length;for(let I=a;x<o;x++)if(n.get(x,s)!==I)d[E]++;else{if(E===A-1){if(we.patternMatchVariance(d,u,we.MAX_INDIVIDUAL_VARIANCE)<we.MAX_AVG_VARIANCE)return new Int32Array([h,x]);h+=d[0]+d[1],B.arraycopy(d,2,d,0,E-1),d[E-1]=0,d[E]=0,E--}else E++;d[E]=1,I=!I}return E===A-1&&we.patternMatchVariance(d,u,we.MAX_INDIVIDUAL_VARIANCE)<we.MAX_AVG_VARIANCE?new Int32Array([h,x-1]):null}static patternMatchVariance(n,r,s){let o=n.length,a=0,u=0;for(let g=0;g<o;g++)a+=n[g],u+=r[g];if(a<u)return 1/0;let d=a/u;s*=d;let h=0;for(let g=0;g<o;g++){let x=n[g],E=r[g]*d,A=x>E?x-E:E-x;if(A>s)return 1/0;h+=A}return h/a}}we.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),we.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),we.MAX_AVG_VARIANCE=.42,we.MAX_INDIVIDUAL_VARIANCE=.8,we.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),we.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),we.MAX_PIXEL_DRIFT=3,we.MAX_PATTERN_DRIFT=5,we.SKIPPED_ROW_COUNT_MAX=25,we.ROW_STEP=5,we.BARCODE_MIN_HEIGHT=10;class St{constructor(n,r){if(r.length===0)throw new v;this.field=n;let s=r.length;if(s>1&&r[0]===0){let o=1;for(;o<s&&r[o]===0;)o++;o===s?this.coefficients=new Int32Array([0]):(this.coefficients=new Int32Array(s-o),B.arraycopy(r,o,this.coefficients,0,this.coefficients.length))}else this.coefficients=r}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(n){return this.coefficients[this.coefficients.length-1-n]}evaluateAt(n){if(n===0)return this.getCoefficient(0);if(n===1){let o=0;for(let a of this.coefficients)o=this.field.add(o,a);return o}let r=this.coefficients[0],s=this.coefficients.length;for(let o=1;o<s;o++)r=this.field.add(this.field.multiply(n,r),this.coefficients[o]);return r}add(n){if(!this.field.equals(n.field))throw new v("ModulusPolys do not have same ModulusGF field");if(this.isZero())return n;if(n.isZero())return this;let r=this.coefficients,s=n.coefficients;if(r.length>s.length){let u=r;r=s,s=u}let o=new Int32Array(s.length),a=s.length-r.length;B.arraycopy(s,0,o,0,a);for(let u=a;u<s.length;u++)o[u]=this.field.add(r[u-a],s[u]);return new St(this.field,o)}subtract(n){if(!this.field.equals(n.field))throw new v("ModulusPolys do not have same ModulusGF field");return n.isZero()?this:this.add(n.negative())}multiply(n){return n instanceof St?this.multiplyOther(n):this.multiplyScalar(n)}multiplyOther(n){if(!this.field.equals(n.field))throw new v("ModulusPolys do not have same ModulusGF field");if(this.isZero()||n.isZero())return new St(this.field,new Int32Array([0]));let r=this.coefficients,s=r.length,o=n.coefficients,a=o.length,u=new Int32Array(s+a-1);for(let d=0;d<s;d++){let h=r[d];for(let g=0;g<a;g++)u[d+g]=this.field.add(u[d+g],this.field.multiply(h,o[g]))}return new St(this.field,u)}negative(){let n=this.coefficients.length,r=new Int32Array(n);for(let s=0;s<n;s++)r[s]=this.field.subtract(0,this.coefficients[s]);return new St(this.field,r)}multiplyScalar(n){if(n===0)return new St(this.field,new Int32Array([0]));if(n===1)return this;let r=this.coefficients.length,s=new Int32Array(r);for(let o=0;o<r;o++)s[o]=this.field.multiply(this.coefficients[o],n);return new St(this.field,s)}multiplyByMonomial(n,r){if(n<0)throw new v;if(r===0)return new St(this.field,new Int32Array([0]));let s=this.coefficients.length,o=new Int32Array(s+n);for(let a=0;a<s;a++)o[a]=this.field.multiply(this.coefficients[a],r);return new St(this.field,o)}toString(){let n=new ge;for(let r=this.getDegree();r>=0;r--){let s=this.getCoefficient(r);s!==0&&(s<0?(n.append(" - "),s=-s):n.length()>0&&n.append(" + "),(r===0||s!==1)&&n.append(s),r!==0&&(r===1?n.append("x"):(n.append("x^"),n.append(r))))}return n.toString()}}class zh{add(n,r){return(n+r)%this.modulus}subtract(n,r){return(this.modulus+n-r)%this.modulus}exp(n){return this.expTable[n]}log(n){if(n===0)throw new v;return this.logTable[n]}inverse(n){if(n===0)throw new io;return this.expTable[this.modulus-this.logTable[n]-1]}multiply(n,r){return n===0||r===0?0:this.expTable[(this.logTable[n]+this.logTable[r])%(this.modulus-1)]}getSize(){return this.modulus}equals(n){return n===this}}class tl extends zh{constructor(n,r){super(),this.modulus=n,this.expTable=new Int32Array(n),this.logTable=new Int32Array(n);let s=1;for(let o=0;o<n;o++)this.expTable[o]=s,s=s*r%n;for(let o=0;o<n-1;o++)this.logTable[this.expTable[o]]=o;this.zero=new St(this,new Int32Array([0])),this.one=new St(this,new Int32Array([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(n,r){if(n<0)throw new v;if(r===0)return this.zero;let s=new Int32Array(n+1);return s[0]=r,new St(this,s)}}tl.PDF417_GF=new tl(he.NUMBER_OF_CODEWORDS,3);class r1{constructor(){this.field=tl.PDF417_GF}decode(n,r,s){let o=new St(this.field,n),a=new Int32Array(r),u=!1;for(let b=r;b>0;b--){let D=o.evaluateAt(this.field.exp(b));a[r-b]=D,D!==0&&(u=!0)}if(!u)return 0;let d=this.field.getOne();if(s!=null)for(const b of s){let D=this.field.exp(n.length-1-b),L=new St(this.field,new Int32Array([this.field.subtract(0,D),1]));d=d.multiply(L)}let h=new St(this.field,a),g=this.runEuclideanAlgorithm(this.field.buildMonomial(r,1),h,r),x=g[0],E=g[1],A=this.findErrorLocations(x),I=this.findErrorMagnitudes(E,x,A);for(let b=0;b<A.length;b++){let D=n.length-1-this.field.log(A[b]);if(D<0)throw M.getChecksumInstance();n[D]=this.field.subtract(n[D],I[b])}return A.length}runEuclideanAlgorithm(n,r,s){if(n.getDegree()<r.getDegree()){let A=n;n=r,r=A}let o=n,a=r,u=this.field.getZero(),d=this.field.getOne();for(;a.getDegree()>=Math.round(s/2);){let A=o,I=u;if(o=a,u=d,o.isZero())throw M.getChecksumInstance();a=A;let b=this.field.getZero(),D=o.getCoefficient(o.getDegree()),L=this.field.inverse(D);for(;a.getDegree()>=o.getDegree()&&!a.isZero();){let z=a.getDegree()-o.getDegree(),q=this.field.multiply(a.getCoefficient(a.getDegree()),L);b=b.add(this.field.buildMonomial(z,q)),a=a.subtract(o.multiplyByMonomial(z,q))}d=b.multiply(u).subtract(I).negative()}let h=d.getCoefficient(0);if(h===0)throw M.getChecksumInstance();let g=this.field.inverse(h),x=d.multiply(g),E=a.multiply(g);return[x,E]}findErrorLocations(n){let r=n.getDegree(),s=new Int32Array(r),o=0;for(let a=1;a<this.field.getSize()&&o<r;a++)n.evaluateAt(a)===0&&(s[o]=this.field.inverse(a),o++);if(o!==r)throw M.getChecksumInstance();return s}findErrorMagnitudes(n,r,s){let o=r.getDegree(),a=new Int32Array(o);for(let g=1;g<=o;g++)a[o-g]=this.field.multiply(g,r.getCoefficient(g));let u=new St(this.field,a),d=s.length,h=new Int32Array(d);for(let g=0;g<d;g++){let x=this.field.inverse(s[g]),E=this.field.subtract(0,n.evaluateAt(x)),A=this.field.inverse(u.evaluateAt(x));h[g]=this.field.multiply(E,A)}return h}}class Fr{constructor(n,r,s,o,a){n instanceof Fr?this.constructor_2(n):this.constructor_1(n,r,s,o,a)}constructor_1(n,r,s,o,a){const u=r==null||s==null,d=o==null||a==null;if(u&&d)throw new j;u?(r=new oe(0,o.getY()),s=new oe(0,a.getY())):d&&(o=new oe(n.getWidth()-1,r.getY()),a=new oe(n.getWidth()-1,s.getY())),this.image=n,this.topLeft=r,this.bottomLeft=s,this.topRight=o,this.bottomRight=a,this.minX=Math.trunc(Math.min(r.getX(),s.getX())),this.maxX=Math.trunc(Math.max(o.getX(),a.getX())),this.minY=Math.trunc(Math.min(r.getY(),o.getY())),this.maxY=Math.trunc(Math.max(s.getY(),a.getY()))}constructor_2(n){this.image=n.image,this.topLeft=n.getTopLeft(),this.bottomLeft=n.getBottomLeft(),this.topRight=n.getTopRight(),this.bottomRight=n.getBottomRight(),this.minX=n.getMinX(),this.maxX=n.getMaxX(),this.minY=n.getMinY(),this.maxY=n.getMaxY()}static merge(n,r){return n==null?r:r==null?n:new Fr(n.image,n.topLeft,n.bottomLeft,r.topRight,r.bottomRight)}addMissingRows(n,r,s){let o=this.topLeft,a=this.bottomLeft,u=this.topRight,d=this.bottomRight;if(n>0){let h=s?this.topLeft:this.topRight,g=Math.trunc(h.getY()-n);g<0&&(g=0);let x=new oe(h.getX(),g);s?o=x:u=x}if(r>0){let h=s?this.bottomLeft:this.bottomRight,g=Math.trunc(h.getY()+r);g>=this.image.getHeight()&&(g=this.image.getHeight()-1);let x=new oe(h.getX(),g);s?a=x:d=x}return new Fr(this.image,o,a,u,d)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class Vh{constructor(n,r,s,o){this.columnCount=n,this.errorCorrectionLevel=o,this.rowCountUpperPart=r,this.rowCountLowerPart=s,this.rowCount=r+s}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class ts{constructor(){this.buffer=""}static form(n,r){let s=-1;function o(u,d,h,g,x,E){if(u==="%%")return"%";if(r[++s]===void 0)return;u=g?parseInt(g.substr(1)):void 0;let A=x?parseInt(x.substr(1)):void 0,I;switch(E){case"s":I=r[s];break;case"c":I=r[s][0];break;case"f":I=parseFloat(r[s]).toFixed(u);break;case"p":I=parseFloat(r[s]).toPrecision(u);break;case"e":I=parseFloat(r[s]).toExponential(u);break;case"x":I=parseInt(r[s]).toString(A||16);break;case"d":I=parseFloat(parseInt(r[s],A||10).toPrecision(u)).toFixed(0);break}I=typeof I=="object"?JSON.stringify(I):(+I).toString(A);let b=parseInt(h),D=h&&h[0]+""=="0"?"0":" ";for(;I.length<b;)I=d!==void 0?I+D:D+I;return I}let a=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return n.replace(a,o)}format(n,...r){this.buffer+=ts.form(n,r)}toString(){return this.buffer}}class ns{constructor(n){this.boundingBox=new Fr(n),this.codewords=new Array(n.getMaxY()-n.getMinY()+1)}getCodewordNearby(n){let r=this.getCodeword(n);if(r!=null)return r;for(let s=1;s<ns.MAX_NEARBY_DISTANCE;s++){let o=this.imageRowToCodewordIndex(n)-s;if(o>=0&&(r=this.codewords[o],r!=null)||(o=this.imageRowToCodewordIndex(n)+s,o<this.codewords.length&&(r=this.codewords[o],r!=null)))return r}return null}imageRowToCodewordIndex(n){return n-this.boundingBox.getMinY()}setCodeword(n,r){this.codewords[this.imageRowToCodewordIndex(n)]=r}getCodeword(n){return this.codewords[this.imageRowToCodewordIndex(n)]}getBoundingBox(){return this.boundingBox}getCodewords(){return this.codewords}toString(){const n=new ts;let r=0;for(const s of this.codewords){if(s==null){n.format("%3d: | %n",r++);continue}n.format("%3d: %3d|%3d%n",r++,s.getRowNumber(),s.getValue())}return n.toString()}}ns.MAX_NEARBY_DISTANCE=5;class rs{constructor(){this.values=new Map}setValue(n){n=Math.trunc(n);let r=this.values.get(n);r==null&&(r=0),r++,this.values.set(n,r)}getValue(){let n=-1,r=new Array;for(const[s,o]of this.values.entries()){const a={getKey:()=>s,getValue:()=>o};a.getValue()>n?(n=a.getValue(),r=[],r.push(a.getKey())):a.getValue()===n&&r.push(a.getKey())}return he.toIntArray(r)}getConfidence(n){return this.values.get(n)}}class i1 extends ns{constructor(n,r){super(n),this._isLeft=r}setRowNumbers(){for(let n of this.getCodewords())n!=null&&n.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(n){let r=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(r,n);let s=this.getBoundingBox(),o=this._isLeft?s.getTopLeft():s.getTopRight(),a=this._isLeft?s.getBottomLeft():s.getBottomRight(),u=this.imageRowToCodewordIndex(Math.trunc(o.getY())),d=this.imageRowToCodewordIndex(Math.trunc(a.getY())),h=-1,g=1,x=0;for(let E=u;E<d;E++){if(r[E]==null)continue;let A=r[E],I=A.getRowNumber()-h;if(I===0)x++;else if(I===1)g=Math.max(g,x),x=1,h=A.getRowNumber();else if(I<0||A.getRowNumber()>=n.getRowCount()||I>E)r[E]=null;else{let b;g>2?b=(g-2)*I:b=I;let D=b>=E;for(let L=1;L<=b&&!D;L++)D=r[E-L]!=null;D?r[E]=null:(h=A.getRowNumber(),x=1)}}}getRowHeights(){let n=this.getBarcodeMetadata();if(n==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(n);let r=new Int32Array(n.getRowCount());for(let s of this.getCodewords())if(s!=null){let o=s.getRowNumber();if(o>=r.length)continue;r[o]++}return r}adjustIncompleteIndicatorColumnRowNumbers(n){let r=this.getBoundingBox(),s=this._isLeft?r.getTopLeft():r.getTopRight(),o=this._isLeft?r.getBottomLeft():r.getBottomRight(),a=this.imageRowToCodewordIndex(Math.trunc(s.getY())),u=this.imageRowToCodewordIndex(Math.trunc(o.getY())),d=this.getCodewords(),h=-1;for(let g=a;g<u;g++){if(d[g]==null)continue;let x=d[g];x.setRowNumberAsRowIndicatorColumn();let E=x.getRowNumber()-h;E===0||(E===1?h=x.getRowNumber():x.getRowNumber()>=n.getRowCount()?d[g]=null:h=x.getRowNumber())}}getBarcodeMetadata(){let n=this.getCodewords(),r=new rs,s=new rs,o=new rs,a=new rs;for(let d of n){if(d==null)continue;d.setRowNumberAsRowIndicatorColumn();let h=d.getValue()%30,g=d.getRowNumber();switch(this._isLeft||(g+=2),g%3){case 0:s.setValue(h*3+1);break;case 1:a.setValue(h/3),o.setValue(h%3);break;case 2:r.setValue(h+1);break}}if(r.getValue().length===0||s.getValue().length===0||o.getValue().length===0||a.getValue().length===0||r.getValue()[0]<1||s.getValue()[0]+o.getValue()[0]<he.MIN_ROWS_IN_BARCODE||s.getValue()[0]+o.getValue()[0]>he.MAX_ROWS_IN_BARCODE)return null;let u=new Vh(r.getValue()[0],s.getValue()[0],o.getValue()[0],a.getValue()[0]);return this.removeIncorrectCodewords(n,u),u}removeIncorrectCodewords(n,r){for(let s=0;s<n.length;s++){let o=n[s];if(n[s]==null)continue;let a=o.getValue()%30,u=o.getRowNumber();if(u>r.getRowCount()){n[s]=null;continue}switch(this._isLeft||(u+=2),u%3){case 0:a*3+1!==r.getRowCountUpperPart()&&(n[s]=null);break;case 1:(Math.trunc(a/3)!==r.getErrorCorrectionLevel()||a%3!==r.getRowCountLowerPart())&&(n[s]=null);break;case 2:a+1!==r.getColumnCount()&&(n[s]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+`
65
65
  `+super.toString()}}class is{constructor(n,r){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=n,this.barcodeColumnCount=n.getColumnCount(),this.boundingBox=r,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let n=he.MAX_CODEWORDS_IN_BARCODE,r;do r=n,n=this.adjustRowNumbersAndGetCount();while(n>0&&n<r);return this.detectionResultColumns}adjustIndicatorColumnRowNumbers(n){n!=null&&n.adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata)}adjustRowNumbersAndGetCount(){let n=this.adjustRowNumbersByRow();if(n===0)return 0;for(let r=1;r<this.barcodeColumnCount+1;r++){let s=this.detectionResultColumns[r].getCodewords();for(let o=0;o<s.length;o++)s[o]!=null&&(s[o].hasValidRowNumber()||this.adjustRowNumbers(r,o,s))}return n}adjustRowNumbersByRow(){return this.adjustRowNumbersFromBothRI(),this.adjustRowNumbersFromLRI()+this.adjustRowNumbersFromRRI()}adjustRowNumbersFromBothRI(){if(this.detectionResultColumns[0]==null||this.detectionResultColumns[this.barcodeColumnCount+1]==null)return;let n=this.detectionResultColumns[0].getCodewords(),r=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let s=0;s<n.length;s++)if(n[s]!=null&&r[s]!=null&&n[s].getRowNumber()===r[s].getRowNumber())for(let o=1;o<=this.barcodeColumnCount;o++){let a=this.detectionResultColumns[o].getCodewords()[s];a!=null&&(a.setRowNumber(n[s].getRowNumber()),a.hasValidRowNumber()||(this.detectionResultColumns[o].getCodewords()[s]=null))}}adjustRowNumbersFromRRI(){if(this.detectionResultColumns[this.barcodeColumnCount+1]==null)return 0;let n=0,r=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let s=0;s<r.length;s++){if(r[s]==null)continue;let o=r[s].getRowNumber(),a=0;for(let u=this.barcodeColumnCount+1;u>0&&a<this.ADJUST_ROW_NUMBER_SKIP;u--){let d=this.detectionResultColumns[u].getCodewords()[s];d!=null&&(a=is.adjustRowNumberIfValid(o,a,d),d.hasValidRowNumber()||n++)}}return n}adjustRowNumbersFromLRI(){if(this.detectionResultColumns[0]==null)return 0;let n=0,r=this.detectionResultColumns[0].getCodewords();for(let s=0;s<r.length;s++){if(r[s]==null)continue;let o=r[s].getRowNumber(),a=0;for(let u=1;u<this.barcodeColumnCount+1&&a<this.ADJUST_ROW_NUMBER_SKIP;u++){let d=this.detectionResultColumns[u].getCodewords()[s];d!=null&&(a=is.adjustRowNumberIfValid(o,a,d),d.hasValidRowNumber()||n++)}}return n}static adjustRowNumberIfValid(n,r,s){return s==null||s.hasValidRowNumber()||(s.isValidRowNumber(n)?(s.setRowNumber(n),r=0):++r),r}adjustRowNumbers(n,r,s){if(!this.detectionResultColumns[n-1])return;let o=s[r],a=this.detectionResultColumns[n-1].getCodewords(),u=a;this.detectionResultColumns[n+1]!=null&&(u=this.detectionResultColumns[n+1].getCodewords());let d=new Array(14);d[2]=a[r],d[3]=u[r],r>0&&(d[0]=s[r-1],d[4]=a[r-1],d[5]=u[r-1]),r>1&&(d[8]=s[r-2],d[10]=a[r-2],d[11]=u[r-2]),r<s.length-1&&(d[1]=s[r+1],d[6]=a[r+1],d[7]=u[r+1]),r<s.length-2&&(d[9]=s[r+2],d[12]=a[r+2],d[13]=u[r+2]);for(let h of d)if(is.adjustRowNumber(o,h))return}static adjustRowNumber(n,r){return r==null?!1:r.hasValidRowNumber()&&r.getBucket()===n.getBucket()?(n.setRowNumber(r.getRowNumber()),!0):!1}getBarcodeColumnCount(){return this.barcodeColumnCount}getBarcodeRowCount(){return this.barcodeMetadata.getRowCount()}getBarcodeECLevel(){return this.barcodeMetadata.getErrorCorrectionLevel()}setBoundingBox(n){this.boundingBox=n}getBoundingBox(){return this.boundingBox}setDetectionResultColumn(n,r){this.detectionResultColumns[n]=r}getDetectionResultColumn(n){return this.detectionResultColumns[n]}toString(){let n=this.detectionResultColumns[0];n==null&&(n=this.detectionResultColumns[this.barcodeColumnCount+1]);let r=new ts;for(let s=0;s<n.getCodewords().length;s++){r.format("CW %3d:",s);for(let o=0;o<this.barcodeColumnCount+2;o++){if(this.detectionResultColumns[o]==null){r.format(" | ");continue}let a=this.detectionResultColumns[o].getCodewords()[s];if(a==null){r.format(" | ");continue}r.format(" %3d|%3d",a.getRowNumber(),a.getValue())}r.format("%n")}return r.toString()}}class ss{constructor(n,r,s,o){this.rowNumber=ss.BARCODE_ROW_UNKNOWN,this.startX=Math.trunc(n),this.endX=Math.trunc(r),this.bucket=Math.trunc(s),this.value=Math.trunc(o)}hasValidRowNumber(){return this.isValidRowNumber(this.rowNumber)}isValidRowNumber(n){return n!==ss.BARCODE_ROW_UNKNOWN&&this.bucket===n%3*3}setRowNumberAsRowIndicatorColumn(){this.rowNumber=Math.trunc(Math.trunc(this.value/30)*3+Math.trunc(this.bucket/3))}getWidth(){return this.endX-this.startX}getStartX(){return this.startX}getEndX(){return this.endX}getBucket(){return this.bucket}getValue(){return this.value}getRowNumber(){return this.rowNumber}setRowNumber(n){this.rowNumber=n}toString(){return this.rowNumber+"|"+this.value}}ss.BARCODE_ROW_UNKNOWN=-1;class Xt{static initialize(){for(let n=0;n<he.SYMBOL_TABLE.length;n++){let r=he.SYMBOL_TABLE[n],s=r&1;for(let o=0;o<he.BARS_IN_MODULE;o++){let a=0;for(;(r&1)===s;)a+=1,r>>=1;s=r&1,Xt.RATIOS_TABLE[n]||(Xt.RATIOS_TABLE[n]=new Array(he.BARS_IN_MODULE)),Xt.RATIOS_TABLE[n][he.BARS_IN_MODULE-o-1]=Math.fround(a/he.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(n){let r=Xt.getDecodedCodewordValue(Xt.sampleBitCounts(n));return r!==-1?r:Xt.getClosestDecodedValue(n)}static sampleBitCounts(n){let r=Te.sum(n),s=new Int32Array(he.BARS_IN_MODULE),o=0,a=0;for(let u=0;u<he.MODULES_IN_CODEWORD;u++){let d=r/(2*he.MODULES_IN_CODEWORD)+u*r/he.MODULES_IN_CODEWORD;a+n[o]<=d&&(a+=n[o],o++),s[o]++}return s}static getDecodedCodewordValue(n){let r=Xt.getBitValue(n);return he.getCodeword(r)===-1?-1:r}static getBitValue(n){let r=0;for(let s=0;s<n.length;s++)for(let o=0;o<n[s];o++)r=r<<1|(s%2===0?1:0);return Math.trunc(r)}static getClosestDecodedValue(n){let r=Te.sum(n),s=new Array(he.BARS_IN_MODULE);if(r>1)for(let u=0;u<s.length;u++)s[u]=Math.fround(n[u]/r);let o=so.MAX_VALUE,a=-1;this.bSymbolTableReady||Xt.initialize();for(let u=0;u<Xt.RATIOS_TABLE.length;u++){let d=0,h=Xt.RATIOS_TABLE[u];for(let g=0;g<he.BARS_IN_MODULE;g++){let x=Math.fround(h[g]-s[g]);if(d+=Math.fround(x*x),d>=o)break}d<o&&(o=d,a=he.SYMBOL_TABLE[u])}return a}}Xt.bSymbolTableReady=!1,Xt.RATIOS_TABLE=new Array(he.SYMBOL_TABLE.length).map(y=>new Array(he.BARS_IN_MODULE));class s1{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(n){this.segmentIndex=n}getFileId(){return this.fileId}setFileId(n){this.fileId=n}getOptionalData(){return this.optionalData}setOptionalData(n){this.optionalData=n}isLastSegment(){return this.lastSegment}setLastSegment(n){this.lastSegment=n}getSegmentCount(){return this.segmentCount}setSegmentCount(n){this.segmentCount=n}getSender(){return this.sender||null}setSender(n){this.sender=n}getAddressee(){return this.addressee||null}setAddressee(n){this.addressee=n}getFileName(){return this.fileName}setFileName(n){this.fileName=n}getFileSize(){return this.fileSize}setFileSize(n){this.fileSize=n}getChecksum(){return this.checksum}setChecksum(n){this.checksum=n}getTimestamp(){return this.timestamp}setTimestamp(n){this.timestamp=n}}class o1{static parseLong(n,r=void 0){return parseInt(n,r)}}class a1 extends m{}a1.kind="NullPointerException";class Hh{writeBytes(n){this.writeBytesOffset(n,0,n.length)}writeBytesOffset(n,r,s){if(n==null)throw new a1;if(r<0||r>n.length||s<0||r+s>n.length||r+s<0)throw new K;if(s===0)return;for(let o=0;o<s;o++)this.write(n[r+o])}flush(){}close(){}}class jh extends m{}class Gh extends Hh{constructor(n=32){if(super(),this.count=0,n<0)throw new v("Negative initial size: "+n);this.buf=new Uint8Array(n)}ensureCapacity(n){n-this.buf.length>0&&this.grow(n)}grow(n){let s=this.buf.length<<1;if(s-n<0&&(s=n),s<0){if(n<0)throw new jh;s=N.MAX_VALUE}this.buf=T.copyOfUint8Array(this.buf,s)}write(n){this.ensureCapacity(this.count+1),this.buf[this.count]=n,this.count+=1}writeBytesOffset(n,r,s){if(r<0||r>n.length||s<0||r+s-n.length>0)throw new K;this.ensureCapacity(this.count+s),B.arraycopy(n,r,this.buf,this.count,s),this.count+=s}writeTo(n){n.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return T.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(n){return n?typeof n=="string"?this.toString_string(n):this.toString_number(n):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(n){return new String(this.buf).toString()}toString_number(n){return new String(this.buf).toString()}close(){}}var Pe;(function(y){y[y.ALPHA=0]="ALPHA",y[y.LOWER=1]="LOWER",y[y.MIXED=2]="MIXED",y[y.PUNCT=3]="PUNCT",y[y.ALPHA_SHIFT=4]="ALPHA_SHIFT",y[y.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(Pe||(Pe={}));function l1(){if(typeof window<"u")return window.BigInt||null;if(typeof ls<"u")return ls.BigInt||null;if(typeof self<"u")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let ho;function cr(y){if(typeof ho>"u"&&(ho=l1()),ho===null)throw new Error("BigInt is not supported!");return ho(y)}function Xh(){let y=[];y[0]=cr(1);let n=cr(900);y[1]=n;for(let r=2;r<16;r++)y[r]=y[r-1]*n;return y}class W{static decode(n,r){let s=new ge(""),o=V.ISO8859_1;s.enableDecoding(o);let a=1,u=n[a++],d=new s1;for(;a<n[0];){switch(u){case W.TEXT_COMPACTION_MODE_LATCH:a=W.textCompaction(n,a,s);break;case W.BYTE_COMPACTION_MODE_LATCH:case W.BYTE_COMPACTION_MODE_LATCH_6:a=W.byteCompaction(u,n,o,a,s);break;case W.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s.append(n[a++]);break;case W.NUMERIC_COMPACTION_MODE_LATCH:a=W.numericCompaction(n,a,s);break;case W.ECI_CHARSET:V.getCharacterSetECIByValue(n[a++]);break;case W.ECI_GENERAL_PURPOSE:a+=2;break;case W.ECI_USER_DEFINED:a++;break;case W.BEGIN_MACRO_PDF417_CONTROL_BLOCK:a=W.decodeMacroBlock(n,a,d);break;case W.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case W.MACRO_PDF417_TERMINATOR:throw new k;default:a--,a=W.textCompaction(n,a,s);break}if(a<n.length)u=n[a++];else throw k.getFormatInstance()}if(s.length()===0)throw k.getFormatInstance();let h=new Qi(null,s.toString(),null,r);return h.setOther(d),h}static decodeMacroBlock(n,r,s){if(r+W.NUMBER_OF_SEQUENCE_CODEWORDS>n[0])throw k.getFormatInstance();let o=new Int32Array(W.NUMBER_OF_SEQUENCE_CODEWORDS);for(let d=0;d<W.NUMBER_OF_SEQUENCE_CODEWORDS;d++,r++)o[d]=n[r];s.setSegmentIndex(N.parseInt(W.decodeBase900toBase10(o,W.NUMBER_OF_SEQUENCE_CODEWORDS)));let a=new ge;r=W.textCompaction(n,r,a),s.setFileId(a.toString());let u=-1;for(n[r]===W.BEGIN_MACRO_PDF417_OPTIONAL_FIELD&&(u=r+1);r<n[0];)switch(n[r]){case W.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:switch(r++,n[r]){case W.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:let d=new ge;r=W.textCompaction(n,r+1,d),s.setFileName(d.toString());break;case W.MACRO_PDF417_OPTIONAL_FIELD_SENDER:let h=new ge;r=W.textCompaction(n,r+1,h),s.setSender(h.toString());break;case W.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:let g=new ge;r=W.textCompaction(n,r+1,g),s.setAddressee(g.toString());break;case W.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:let x=new ge;r=W.numericCompaction(n,r+1,x),s.setSegmentCount(N.parseInt(x.toString()));break;case W.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:let E=new ge;r=W.numericCompaction(n,r+1,E),s.setTimestamp(o1.parseLong(E.toString()));break;case W.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:let A=new ge;r=W.numericCompaction(n,r+1,A),s.setChecksum(N.parseInt(A.toString()));break;case W.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:let I=new ge;r=W.numericCompaction(n,r+1,I),s.setFileSize(o1.parseLong(I.toString()));break;default:throw k.getFormatInstance()}break;case W.MACRO_PDF417_TERMINATOR:r++,s.setLastSegment(!0);break;default:throw k.getFormatInstance()}if(u!==-1){let d=r-u;s.isLastSegment()&&d--,s.setOptionalData(T.copyOfRange(n,u,u+d))}return r}static textCompaction(n,r,s){let o=new Int32Array((n[0]-r)*2),a=new Int32Array((n[0]-r)*2),u=0,d=!1;for(;r<n[0]&&!d;){let h=n[r++];if(h<W.TEXT_COMPACTION_MODE_LATCH)o[u]=h/30,o[u+1]=h%30,u+=2;else switch(h){case W.TEXT_COMPACTION_MODE_LATCH:o[u++]=W.TEXT_COMPACTION_MODE_LATCH;break;case W.BYTE_COMPACTION_MODE_LATCH:case W.BYTE_COMPACTION_MODE_LATCH_6:case W.NUMERIC_COMPACTION_MODE_LATCH:case W.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case W.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case W.MACRO_PDF417_TERMINATOR:r--,d=!0;break;case W.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:o[u]=W.MODE_SHIFT_TO_BYTE_COMPACTION_MODE,h=n[r++],a[u]=h,u++;break}}return W.decodeTextCompaction(o,a,u,s),r}static decodeTextCompaction(n,r,s,o){let a=Pe.ALPHA,u=Pe.ALPHA,d=0;for(;d<s;){let h=n[d],g="";switch(a){case Pe.ALPHA:if(h<26)g=String.fromCharCode(65+h);else switch(h){case 26:g=" ";break;case W.LL:a=Pe.LOWER;break;case W.ML:a=Pe.MIXED;break;case W.PS:u=a,a=Pe.PUNCT_SHIFT;break;case W.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:o.append(r[d]);break;case W.TEXT_COMPACTION_MODE_LATCH:a=Pe.ALPHA;break}break;case Pe.LOWER:if(h<26)g=String.fromCharCode(97+h);else switch(h){case 26:g=" ";break;case W.AS:u=a,a=Pe.ALPHA_SHIFT;break;case W.ML:a=Pe.MIXED;break;case W.PS:u=a,a=Pe.PUNCT_SHIFT;break;case W.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:o.append(r[d]);break;case W.TEXT_COMPACTION_MODE_LATCH:a=Pe.ALPHA;break}break;case Pe.MIXED:if(h<W.PL)g=W.MIXED_CHARS[h];else switch(h){case W.PL:a=Pe.PUNCT;break;case 26:g=" ";break;case W.LL:a=Pe.LOWER;break;case W.AL:a=Pe.ALPHA;break;case W.PS:u=a,a=Pe.PUNCT_SHIFT;break;case W.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:o.append(r[d]);break;case W.TEXT_COMPACTION_MODE_LATCH:a=Pe.ALPHA;break}break;case Pe.PUNCT:if(h<W.PAL)g=W.PUNCT_CHARS[h];else switch(h){case W.PAL:a=Pe.ALPHA;break;case W.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:o.append(r[d]);break;case W.TEXT_COMPACTION_MODE_LATCH:a=Pe.ALPHA;break}break;case Pe.ALPHA_SHIFT:if(a=u,h<26)g=String.fromCharCode(65+h);else switch(h){case 26:g=" ";break;case W.TEXT_COMPACTION_MODE_LATCH:a=Pe.ALPHA;break}break;case Pe.PUNCT_SHIFT:if(a=u,h<W.PAL)g=W.PUNCT_CHARS[h];else switch(h){case W.PAL:a=Pe.ALPHA;break;case W.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:o.append(r[d]);break;case W.TEXT_COMPACTION_MODE_LATCH:a=Pe.ALPHA;break}break}g!==""&&o.append(g),d++}}static byteCompaction(n,r,s,o,a){let u=new Gh,d=0,h=0,g=!1;switch(n){case W.BYTE_COMPACTION_MODE_LATCH:let x=new Int32Array(6),E=r[o++];for(;o<r[0]&&!g;)switch(x[d++]=E,h=900*h+E,E=r[o++],E){case W.TEXT_COMPACTION_MODE_LATCH:case W.BYTE_COMPACTION_MODE_LATCH:case W.NUMERIC_COMPACTION_MODE_LATCH:case W.BYTE_COMPACTION_MODE_LATCH_6:case W.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case W.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case W.MACRO_PDF417_TERMINATOR:o--,g=!0;break;default:if(d%5===0&&d>0){for(let A=0;A<6;++A)u.write(Number(cr(h)>>cr(8*(5-A))));h=0,d=0}break}o===r[0]&&E<W.TEXT_COMPACTION_MODE_LATCH&&(x[d++]=E);for(let A=0;A<d;A++)u.write(x[A]);break;case W.BYTE_COMPACTION_MODE_LATCH_6:for(;o<r[0]&&!g;){let A=r[o++];if(A<W.TEXT_COMPACTION_MODE_LATCH)d++,h=900*h+A;else switch(A){case W.TEXT_COMPACTION_MODE_LATCH:case W.BYTE_COMPACTION_MODE_LATCH:case W.NUMERIC_COMPACTION_MODE_LATCH:case W.BYTE_COMPACTION_MODE_LATCH_6:case W.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case W.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case W.MACRO_PDF417_TERMINATOR:o--,g=!0;break}if(d%5===0&&d>0){for(let I=0;I<6;++I)u.write(Number(cr(h)>>cr(8*(5-I))));h=0,d=0}}break}return a.append(Ee.decode(u.toByteArray(),s)),o}static numericCompaction(n,r,s){let o=0,a=!1,u=new Int32Array(W.MAX_NUMERIC_CODEWORDS);for(;r<n[0]&&!a;){let d=n[r++];if(r===n[0]&&(a=!0),d<W.TEXT_COMPACTION_MODE_LATCH)u[o]=d,o++;else switch(d){case W.TEXT_COMPACTION_MODE_LATCH:case W.BYTE_COMPACTION_MODE_LATCH:case W.BYTE_COMPACTION_MODE_LATCH_6:case W.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case W.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case W.MACRO_PDF417_TERMINATOR:r--,a=!0;break}(o%W.MAX_NUMERIC_CODEWORDS===0||d===W.NUMERIC_COMPACTION_MODE_LATCH||a)&&o>0&&(s.append(W.decodeBase900toBase10(u,o)),o=0)}return r}static decodeBase900toBase10(n,r){let s=cr(0);for(let a=0;a<r;a++)s+=W.EXP900[r-a-1]*cr(n[a]);let o=s.toString();if(o.charAt(0)!=="1")throw new k;return o.substring(1)}}W.TEXT_COMPACTION_MODE_LATCH=900,W.BYTE_COMPACTION_MODE_LATCH=901,W.NUMERIC_COMPACTION_MODE_LATCH=902,W.BYTE_COMPACTION_MODE_LATCH_6=924,W.ECI_USER_DEFINED=925,W.ECI_GENERAL_PURPOSE=926,W.ECI_CHARSET=927,W.BEGIN_MACRO_PDF417_CONTROL_BLOCK=928,W.BEGIN_MACRO_PDF417_OPTIONAL_FIELD=923,W.MACRO_PDF417_TERMINATOR=922,W.MODE_SHIFT_TO_BYTE_COMPACTION_MODE=913,W.MAX_NUMERIC_CODEWORDS=15,W.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME=0,W.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT=1,W.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP=2,W.MACRO_PDF417_OPTIONAL_FIELD_SENDER=3,W.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE=4,W.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE=5,W.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM=6,W.PL=25,W.LL=27,W.AS=27,W.ML=28,W.AL=28,W.PS=29,W.PAL=29,W.PUNCT_CHARS=`;<>@[\\]_\`~!\r ,:
66
- -.$/"|*()?{}'`,W.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",W.EXP900=l1()?Xh():[],W.NUMBER_OF_SEQUENCE_CODEWORDS=2;class ye{constructor(){}static decode(n,r,s,o,a,u,d){let h=new Fr(n,r,s,o,a),g=null,x=null,E;for(let b=!0;;b=!1){if(r!=null&&(g=ye.getRowIndicatorColumn(n,h,r,!0,u,d)),o!=null&&(x=ye.getRowIndicatorColumn(n,h,o,!1,u,d)),E=ye.merge(g,x),E==null)throw j.getNotFoundInstance();let D=E.getBoundingBox();if(b&&D!=null&&(D.getMinY()<h.getMinY()||D.getMaxY()>h.getMaxY()))h=D;else break}E.setBoundingBox(h);let A=E.getBarcodeColumnCount()+1;E.setDetectionResultColumn(0,g),E.setDetectionResultColumn(A,x);let I=g!=null;for(let b=1;b<=A;b++){let D=I?b:A-b;if(E.getDetectionResultColumn(D)!==void 0)continue;let L;D===0||D===A?L=new i1(h,D===0):L=new ns(h),E.setDetectionResultColumn(D,L);let z=-1,q=z;for(let $=h.getMinY();$<=h.getMaxY();$++){if(z=ye.getStartColumn(E,D,$,I),z<0||z>h.getMaxX()){if(q===-1)continue;z=q}let Z=ye.detectCodeword(n,h.getMinX(),h.getMaxX(),I,z,$,u,d);Z!=null&&(L.setCodeword($,Z),q=z,u=Math.min(u,Z.getWidth()),d=Math.max(d,Z.getWidth()))}}return ye.createDecoderResult(E)}static merge(n,r){if(n==null&&r==null)return null;let s=ye.getBarcodeMetadata(n,r);if(s==null)return null;let o=Fr.merge(ye.adjustBoundingBox(n),ye.adjustBoundingBox(r));return new is(s,o)}static adjustBoundingBox(n){if(n==null)return null;let r=n.getRowHeights();if(r==null)return null;let s=ye.getMax(r),o=0;for(let d of r)if(o+=s-d,d>0)break;let a=n.getCodewords();for(let d=0;o>0&&a[d]==null;d++)o--;let u=0;for(let d=r.length-1;d>=0&&(u+=s-r[d],!(r[d]>0));d--);for(let d=a.length-1;u>0&&a[d]==null;d--)u--;return n.getBoundingBox().addMissingRows(o,u,n.isLeft())}static getMax(n){let r=-1;for(let s of n)r=Math.max(r,s);return r}static getBarcodeMetadata(n,r){let s;if(n==null||(s=n.getBarcodeMetadata())==null)return r==null?null:r.getBarcodeMetadata();let o;return r==null||(o=r.getBarcodeMetadata())==null?s:s.getColumnCount()!==o.getColumnCount()&&s.getErrorCorrectionLevel()!==o.getErrorCorrectionLevel()&&s.getRowCount()!==o.getRowCount()?null:s}static getRowIndicatorColumn(n,r,s,o,a,u){let d=new i1(r,o);for(let h=0;h<2;h++){let g=h===0?1:-1,x=Math.trunc(Math.trunc(s.getX()));for(let E=Math.trunc(Math.trunc(s.getY()));E<=r.getMaxY()&&E>=r.getMinY();E+=g){let A=ye.detectCodeword(n,0,n.getWidth(),o,x,E,a,u);A!=null&&(d.setCodeword(E,A),o?x=A.getStartX():x=A.getEndX())}}return d}static adjustCodewordCount(n,r){let s=r[0][1],o=s.getValue(),a=n.getBarcodeColumnCount()*n.getBarcodeRowCount()-ye.getNumberOfECCodeWords(n.getBarcodeECLevel());if(o.length===0){if(a<1||a>he.MAX_CODEWORDS_IN_BARCODE)throw j.getNotFoundInstance();s.setValue(a)}else o[0]!==a&&s.setValue(a)}static createDecoderResult(n){let r=ye.createBarcodeMatrix(n);ye.adjustCodewordCount(n,r);let s=new Array,o=new Int32Array(n.getBarcodeRowCount()*n.getBarcodeColumnCount()),a=[],u=new Array;for(let h=0;h<n.getBarcodeRowCount();h++)for(let g=0;g<n.getBarcodeColumnCount();g++){let x=r[h][g+1].getValue(),E=h*n.getBarcodeColumnCount()+g;x.length===0?s.push(E):x.length===1?o[E]=x[0]:(u.push(E),a.push(x))}let d=new Array(a.length);for(let h=0;h<d.length;h++)d[h]=a[h];return ye.createDecoderResultFromAmbiguousValues(n.getBarcodeECLevel(),o,he.toIntArray(s),he.toIntArray(u),d)}static createDecoderResultFromAmbiguousValues(n,r,s,o,a){let u=new Int32Array(o.length),d=100;for(;d-- >0;){for(let h=0;h<u.length;h++)r[o[h]]=a[h][u[h]];try{return ye.decodeCodewords(r,n,s)}catch(h){if(!(h instanceof M))throw h}if(u.length===0)throw M.getChecksumInstance();for(let h=0;h<u.length;h++)if(u[h]<a[h].length-1){u[h]++;break}else if(u[h]=0,h===u.length-1)throw M.getChecksumInstance()}throw M.getChecksumInstance()}static createBarcodeMatrix(n){let r=Array.from({length:n.getBarcodeRowCount()},()=>new Array(n.getBarcodeColumnCount()+2));for(let o=0;o<r.length;o++)for(let a=0;a<r[o].length;a++)r[o][a]=new rs;let s=0;for(let o of n.getDetectionResultColumns()){if(o!=null){for(let a of o.getCodewords())if(a!=null){let u=a.getRowNumber();if(u>=0){if(u>=r.length)continue;r[u][s].setValue(a.getValue())}}}s++}return r}static isValidBarcodeColumn(n,r){return r>=0&&r<=n.getBarcodeColumnCount()+1}static getStartColumn(n,r,s,o){let a=o?1:-1,u=null;if(ye.isValidBarcodeColumn(n,r-a)&&(u=n.getDetectionResultColumn(r-a).getCodeword(s)),u!=null)return o?u.getEndX():u.getStartX();if(u=n.getDetectionResultColumn(r).getCodewordNearby(s),u!=null)return o?u.getStartX():u.getEndX();if(ye.isValidBarcodeColumn(n,r-a)&&(u=n.getDetectionResultColumn(r-a).getCodewordNearby(s)),u!=null)return o?u.getEndX():u.getStartX();let d=0;for(;ye.isValidBarcodeColumn(n,r-a);){r-=a;for(let h of n.getDetectionResultColumn(r).getCodewords())if(h!=null)return(o?h.getEndX():h.getStartX())+a*d*(h.getEndX()-h.getStartX());d++}return o?n.getBoundingBox().getMinX():n.getBoundingBox().getMaxX()}static detectCodeword(n,r,s,o,a,u,d,h){a=ye.adjustCodewordStartColumn(n,r,s,o,a,u);let g=ye.getModuleBitCount(n,r,s,o,a,u);if(g==null)return null;let x,E=Te.sum(g);if(o)x=a+E;else{for(let b=0;b<g.length/2;b++){let D=g[b];g[b]=g[g.length-1-b],g[g.length-1-b]=D}x=a,a=x-E}if(!ye.checkCodewordSkew(E,d,h))return null;let A=Xt.getDecodedValue(g),I=he.getCodeword(A);return I===-1?null:new ss(a,x,ye.getCodewordBucketNumber(A),I)}static getModuleBitCount(n,r,s,o,a,u){let d=a,h=new Int32Array(8),g=0,x=o?1:-1,E=o;for(;(o?d<s:d>=r)&&g<h.length;)n.get(d,u)===E?(h[g]++,d+=x):(g++,E=!E);return g===h.length||d===(o?s:r)&&g===h.length-1?h:null}static getNumberOfECCodeWords(n){return 2<<n}static adjustCodewordStartColumn(n,r,s,o,a,u){let d=a,h=o?-1:1;for(let g=0;g<2;g++){for(;(o?d>=r:d<s)&&o===n.get(d,u);){if(Math.abs(a-d)>ye.CODEWORD_SKEW_SIZE)return a;d+=h}h=-h,o=!o}return d}static checkCodewordSkew(n,r,s){return r-ye.CODEWORD_SKEW_SIZE<=n&&n<=s+ye.CODEWORD_SKEW_SIZE}static decodeCodewords(n,r,s){if(n.length===0)throw k.getFormatInstance();let o=1<<r+1,a=ye.correctErrors(n,s,o);ye.verifyCodewordCount(n,o);let u=W.decode(n,""+r);return u.setErrorsCorrected(a),u.setErasures(s.length),u}static correctErrors(n,r,s){if(r!=null&&r.length>s/2+ye.MAX_ERRORS||s<0||s>ye.MAX_EC_CODEWORDS)throw M.getChecksumInstance();return ye.errorCorrection.decode(n,s,r)}static verifyCodewordCount(n,r){if(n.length<4)throw k.getFormatInstance();let s=n[0];if(s>n.length)throw k.getFormatInstance();if(s===0)if(r<n.length)n[0]=n.length-r;else throw k.getFormatInstance()}static getBitCountForCodeword(n){let r=new Int32Array(8),s=0,o=r.length-1;for(;!((n&1)!==s&&(s=n&1,o--,o<0));)r[o]++,n>>=1;return r}static getCodewordBucketNumber(n){return n instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(n):this.getCodewordBucketNumber_number(n)}static getCodewordBucketNumber_number(n){return ye.getCodewordBucketNumber(ye.getBitCountForCodeword(n))}static getCodewordBucketNumber_Int32Array(n){return(n[0]-n[2]+n[4]-n[6]+9)%9}static toString(n){let r=new ts;for(let s=0;s<n.length;s++){r.format("Row %2d: ",s);for(let o=0;o<n[s].length;o++){let a=n[s][o];a.getValue().length===0?r.format(" ",null):r.format("%4d(%2d)",a.getValue()[0],a.getConfidence(a.getValue()[0]))}r.format("%n")}return r.toString()}}ye.CODEWORD_SKEW_SIZE=2,ye.MAX_ERRORS=3,ye.MAX_EC_CODEWORDS=512,ye.errorCorrection=new r1;class It{decode(n,r=null){let s=It.decode(n,r,!1);if(s==null||s.length===0||s[0]==null)throw j.getNotFoundInstance();return s[0]}decodeMultiple(n,r=null){try{return It.decode(n,r,!0)}catch(s){throw s instanceof k||s instanceof M?j.getNotFoundInstance():s}}static decode(n,r,s){const o=new Array,a=we.detectMultiple(n,r,s);for(const u of a.getPoints()){const d=ye.decode(a.getBits(),u[4],u[5],u[6],u[7],It.getMinCodewordWidth(u),It.getMaxCodewordWidth(u)),h=new Ke(d.getText(),d.getRawBytes(),void 0,u,ae.PDF_417);h.putMetadata(mt.ERROR_CORRECTION_LEVEL,d.getECLevel());const g=d.getOther();g!=null&&h.putMetadata(mt.PDF417_EXTRA_METADATA,g),o.push(h)}return o.map(u=>u)}static getMaxWidth(n,r){return n==null||r==null?0:Math.trunc(Math.abs(n.getX()-r.getX()))}static getMinWidth(n,r){return n==null||r==null?N.MAX_VALUE:Math.trunc(Math.abs(n.getX()-r.getX()))}static getMaxCodewordWidth(n){return Math.floor(Math.max(Math.max(It.getMaxWidth(n[0],n[4]),It.getMaxWidth(n[6],n[2])*he.MODULES_IN_CODEWORD/he.MODULES_IN_STOP_PATTERN),Math.max(It.getMaxWidth(n[1],n[5]),It.getMaxWidth(n[7],n[3])*he.MODULES_IN_CODEWORD/he.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(n){return Math.floor(Math.min(Math.min(It.getMinWidth(n[0],n[4]),It.getMinWidth(n[6],n[2])*he.MODULES_IN_CODEWORD/he.MODULES_IN_STOP_PATTERN),Math.min(It.getMinWidth(n[1],n[5]),It.getMinWidth(n[7],n[3])*he.MODULES_IN_CODEWORD/he.MODULES_IN_STOP_PATTERN)))}reset(){}}class go extends m{}go.kind="ReaderException";class u1{constructor(n,r){this.verbose=n===!0,r&&this.setHints(r)}decode(n,r){return r&&this.setHints(r),this.decodeInternal(n)}decodeWithState(n){return(this.readers===null||this.readers===void 0)&&this.setHints(null),this.decodeInternal(n)}setHints(n){this.hints=n;const r=!l(n)&&n.get(U.TRY_HARDER)===!0,s=l(n)?null:n.get(U.POSSIBLE_FORMATS),o=new Array;if(!l(s)){const a=s.some(u=>u===ae.UPC_A||u===ae.UPC_E||u===ae.EAN_13||u===ae.EAN_8||u===ae.CODABAR||u===ae.CODE_39||u===ae.CODE_93||u===ae.CODE_128||u===ae.ITF||u===ae.RSS_14||u===ae.RSS_EXPANDED);a&&!r&&o.push(new ai(n,this.verbose)),s.includes(ae.QR_CODE)&&o.push(new ur),s.includes(ae.DATA_MATRIX)&&o.push(new lr),s.includes(ae.AZTEC)&&o.push(new ao),s.includes(ae.PDF_417)&&o.push(new It),a&&r&&o.push(new ai(n,this.verbose))}o.length===0&&(r||o.push(new ai(n,this.verbose)),o.push(new ur),o.push(new lr),o.push(new ao),o.push(new It),r&&o.push(new ai(n,this.verbose))),this.readers=o}reset(){if(this.readers!==null)for(const n of this.readers)n.reset()}decodeInternal(n){if(this.readers===null)throw new go("No readers where selected, nothing can be read.");for(const r of this.readers)try{return r.decode(n,this.hints)}catch(s){if(s instanceof go)continue}throw new j("No MultiFormat Readers were able to detect the code.")}}class Yh extends cn{constructor(n=null,r=500){const s=new u1;s.setHints(n),super(s,r)}decodeBitmap(n){return this.reader.decodeWithState(n)}}class Zh extends cn{constructor(n=500){super(new It,n)}}class Kh extends cn{constructor(n=500){super(new ur,n)}}var nl;(function(y){y[y.ERROR_CORRECTION=0]="ERROR_CORRECTION",y[y.CHARACTER_SET=1]="CHARACTER_SET",y[y.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",y[y.MIN_SIZE=3]="MIN_SIZE",y[y.MAX_SIZE=4]="MAX_SIZE",y[y.MARGIN=5]="MARGIN",y[y.PDF417_COMPACT=6]="PDF417_COMPACT",y[y.PDF417_COMPACTION=7]="PDF417_COMPACTION",y[y.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",y[y.AZTEC_LAYERS=9]="AZTEC_LAYERS",y[y.QR_VERSION=10]="QR_VERSION"})(nl||(nl={}));var ht=nl;class rl{constructor(n){this.field=n,this.cachedGenerators=[],this.cachedGenerators.push(new Ht(n,Int32Array.from([1])))}buildGenerator(n){const r=this.cachedGenerators;if(n>=r.length){let s=r[r.length-1];const o=this.field;for(let a=r.length;a<=n;a++){const u=s.multiply(new Ht(o,Int32Array.from([1,o.exp(a-1+o.getGeneratorBase())])));r.push(u),s=u}}return r[n]}encode(n,r){if(r===0)throw new v("No error correction bytes");const s=n.length-r;if(s<=0)throw new v("No data bytes provided");const o=this.buildGenerator(r),a=new Int32Array(s);B.arraycopy(n,0,a,0,s);let u=new Ht(this.field,a);u=u.multiplyByMonomial(r,1);const h=u.divide(o)[1].getCoefficients(),g=r-h.length;for(let x=0;x<g;x++)n[s+x]=0;B.arraycopy(h,0,n,s+g,h.length)}}class it{constructor(){}static applyMaskPenaltyRule1(n){return it.applyMaskPenaltyRule1Internal(n,!0)+it.applyMaskPenaltyRule1Internal(n,!1)}static applyMaskPenaltyRule2(n){let r=0;const s=n.getArray(),o=n.getWidth(),a=n.getHeight();for(let u=0;u<a-1;u++){const d=s[u];for(let h=0;h<o-1;h++){const g=d[h];g===d[h+1]&&g===s[u+1][h]&&g===s[u+1][h+1]&&r++}}return it.N2*r}static applyMaskPenaltyRule3(n){let r=0;const s=n.getArray(),o=n.getWidth(),a=n.getHeight();for(let u=0;u<a;u++)for(let d=0;d<o;d++){const h=s[u];d+6<o&&h[d]===1&&h[d+1]===0&&h[d+2]===1&&h[d+3]===1&&h[d+4]===1&&h[d+5]===0&&h[d+6]===1&&(it.isWhiteHorizontal(h,d-4,d)||it.isWhiteHorizontal(h,d+7,d+11))&&r++,u+6<a&&s[u][d]===1&&s[u+1][d]===0&&s[u+2][d]===1&&s[u+3][d]===1&&s[u+4][d]===1&&s[u+5][d]===0&&s[u+6][d]===1&&(it.isWhiteVertical(s,d,u-4,u)||it.isWhiteVertical(s,d,u+7,u+11))&&r++}return r*it.N3}static isWhiteHorizontal(n,r,s){r=Math.max(r,0),s=Math.min(s,n.length);for(let o=r;o<s;o++)if(n[o]===1)return!1;return!0}static isWhiteVertical(n,r,s,o){s=Math.max(s,0),o=Math.min(o,n.length);for(let a=s;a<o;a++)if(n[a][r]===1)return!1;return!0}static applyMaskPenaltyRule4(n){let r=0;const s=n.getArray(),o=n.getWidth(),a=n.getHeight();for(let h=0;h<a;h++){const g=s[h];for(let x=0;x<o;x++)g[x]===1&&r++}const u=n.getHeight()*n.getWidth();return Math.floor(Math.abs(r*2-u)*10/u)*it.N4}static getDataMaskBit(n,r,s){let o,a;switch(n){case 0:o=s+r&1;break;case 1:o=s&1;break;case 2:o=r%3;break;case 3:o=(s+r)%3;break;case 4:o=Math.floor(s/2)+Math.floor(r/3)&1;break;case 5:a=s*r,o=(a&1)+a%3;break;case 6:a=s*r,o=(a&1)+a%3&1;break;case 7:a=s*r,o=a%3+(s+r&1)&1;break;default:throw new v("Invalid mask pattern: "+n)}return o===0}static applyMaskPenaltyRule1Internal(n,r){let s=0;const o=r?n.getHeight():n.getWidth(),a=r?n.getWidth():n.getHeight(),u=n.getArray();for(let d=0;d<o;d++){let h=0,g=-1;for(let x=0;x<a;x++){const E=r?u[d][x]:u[x][d];E===g?h++:(h>=5&&(s+=it.N1+(h-5)),h=1,g=E)}h>=5&&(s+=it.N1+(h-5))}return s}}it.N1=3,it.N2=3,it.N3=40,it.N4=10;class po{constructor(n,r){this.width=n,this.height=r;const s=new Array(r);for(let o=0;o!==r;o++)s[o]=new Uint8Array(n);this.bytes=s}getHeight(){return this.height}getWidth(){return this.width}get(n,r){return this.bytes[r][n]}getArray(){return this.bytes}setNumber(n,r,s){this.bytes[r][n]=s}setBoolean(n,r,s){this.bytes[r][n]=s?1:0}clear(n){for(const r of this.bytes)T.fill(r,n)}equals(n){if(!(n instanceof po))return!1;const r=n;if(this.width!==r.width||this.height!==r.height)return!1;for(let s=0,o=this.height;s<o;++s){const a=this.bytes[s],u=r.bytes[s];for(let d=0,h=this.width;d<h;++d)if(a[d]!==u[d])return!1}return!0}toString(){const n=new ge;for(let r=0,s=this.height;r<s;++r){const o=this.bytes[r];for(let a=0,u=this.width;a<u;++a)switch(o[a]){case 0:n.append(" 0");break;case 1:n.append(" 1");break;default:n.append(" ");break}n.append(`
66
+ -.$/"|*()?{}'`,W.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",W.EXP900=l1()?Xh():[],W.NUMBER_OF_SEQUENCE_CODEWORDS=2;class ye{constructor(){}static decode(n,r,s,o,a,u,d){let h=new Fr(n,r,s,o,a),g=null,x=null,E;for(let b=!0;;b=!1){if(r!=null&&(g=ye.getRowIndicatorColumn(n,h,r,!0,u,d)),o!=null&&(x=ye.getRowIndicatorColumn(n,h,o,!1,u,d)),E=ye.merge(g,x),E==null)throw j.getNotFoundInstance();let D=E.getBoundingBox();if(b&&D!=null&&(D.getMinY()<h.getMinY()||D.getMaxY()>h.getMaxY()))h=D;else break}E.setBoundingBox(h);let A=E.getBarcodeColumnCount()+1;E.setDetectionResultColumn(0,g),E.setDetectionResultColumn(A,x);let I=g!=null;for(let b=1;b<=A;b++){let D=I?b:A-b;if(E.getDetectionResultColumn(D)!==void 0)continue;let L;D===0||D===A?L=new i1(h,D===0):L=new ns(h),E.setDetectionResultColumn(D,L);let z=-1,q=z;for(let $=h.getMinY();$<=h.getMaxY();$++){if(z=ye.getStartColumn(E,D,$,I),z<0||z>h.getMaxX()){if(q===-1)continue;z=q}let Z=ye.detectCodeword(n,h.getMinX(),h.getMaxX(),I,z,$,u,d);Z!=null&&(L.setCodeword($,Z),q=z,u=Math.min(u,Z.getWidth()),d=Math.max(d,Z.getWidth()))}}return ye.createDecoderResult(E)}static merge(n,r){if(n==null&&r==null)return null;let s=ye.getBarcodeMetadata(n,r);if(s==null)return null;let o=Fr.merge(ye.adjustBoundingBox(n),ye.adjustBoundingBox(r));return new is(s,o)}static adjustBoundingBox(n){if(n==null)return null;let r=n.getRowHeights();if(r==null)return null;let s=ye.getMax(r),o=0;for(let d of r)if(o+=s-d,d>0)break;let a=n.getCodewords();for(let d=0;o>0&&a[d]==null;d++)o--;let u=0;for(let d=r.length-1;d>=0&&(u+=s-r[d],!(r[d]>0));d--);for(let d=a.length-1;u>0&&a[d]==null;d--)u--;return n.getBoundingBox().addMissingRows(o,u,n.isLeft())}static getMax(n){let r=-1;for(let s of n)r=Math.max(r,s);return r}static getBarcodeMetadata(n,r){let s;if(n==null||(s=n.getBarcodeMetadata())==null)return r==null?null:r.getBarcodeMetadata();let o;return r==null||(o=r.getBarcodeMetadata())==null?s:s.getColumnCount()!==o.getColumnCount()&&s.getErrorCorrectionLevel()!==o.getErrorCorrectionLevel()&&s.getRowCount()!==o.getRowCount()?null:s}static getRowIndicatorColumn(n,r,s,o,a,u){let d=new i1(r,o);for(let h=0;h<2;h++){let g=h===0?1:-1,x=Math.trunc(Math.trunc(s.getX()));for(let E=Math.trunc(Math.trunc(s.getY()));E<=r.getMaxY()&&E>=r.getMinY();E+=g){let A=ye.detectCodeword(n,0,n.getWidth(),o,x,E,a,u);A!=null&&(d.setCodeword(E,A),o?x=A.getStartX():x=A.getEndX())}}return d}static adjustCodewordCount(n,r){let s=r[0][1],o=s.getValue(),a=n.getBarcodeColumnCount()*n.getBarcodeRowCount()-ye.getNumberOfECCodeWords(n.getBarcodeECLevel());if(o.length===0){if(a<1||a>he.MAX_CODEWORDS_IN_BARCODE)throw j.getNotFoundInstance();s.setValue(a)}else o[0]!==a&&s.setValue(a)}static createDecoderResult(n){let r=ye.createBarcodeMatrix(n);ye.adjustCodewordCount(n,r);let s=new Array,o=new Int32Array(n.getBarcodeRowCount()*n.getBarcodeColumnCount()),a=[],u=new Array;for(let h=0;h<n.getBarcodeRowCount();h++)for(let g=0;g<n.getBarcodeColumnCount();g++){let x=r[h][g+1].getValue(),E=h*n.getBarcodeColumnCount()+g;x.length===0?s.push(E):x.length===1?o[E]=x[0]:(u.push(E),a.push(x))}let d=new Array(a.length);for(let h=0;h<d.length;h++)d[h]=a[h];return ye.createDecoderResultFromAmbiguousValues(n.getBarcodeECLevel(),o,he.toIntArray(s),he.toIntArray(u),d)}static createDecoderResultFromAmbiguousValues(n,r,s,o,a){let u=new Int32Array(o.length),d=100;for(;d-- >0;){for(let h=0;h<u.length;h++)r[o[h]]=a[h][u[h]];try{return ye.decodeCodewords(r,n,s)}catch(h){if(!(h instanceof M))throw h}if(u.length===0)throw M.getChecksumInstance();for(let h=0;h<u.length;h++)if(u[h]<a[h].length-1){u[h]++;break}else if(u[h]=0,h===u.length-1)throw M.getChecksumInstance()}throw M.getChecksumInstance()}static createBarcodeMatrix(n){let r=Array.from({length:n.getBarcodeRowCount()},()=>new Array(n.getBarcodeColumnCount()+2));for(let o=0;o<r.length;o++)for(let a=0;a<r[o].length;a++)r[o][a]=new rs;let s=0;for(let o of n.getDetectionResultColumns()){if(o!=null){for(let a of o.getCodewords())if(a!=null){let u=a.getRowNumber();if(u>=0){if(u>=r.length)continue;r[u][s].setValue(a.getValue())}}}s++}return r}static isValidBarcodeColumn(n,r){return r>=0&&r<=n.getBarcodeColumnCount()+1}static getStartColumn(n,r,s,o){let a=o?1:-1,u=null;if(ye.isValidBarcodeColumn(n,r-a)&&(u=n.getDetectionResultColumn(r-a).getCodeword(s)),u!=null)return o?u.getEndX():u.getStartX();if(u=n.getDetectionResultColumn(r).getCodewordNearby(s),u!=null)return o?u.getStartX():u.getEndX();if(ye.isValidBarcodeColumn(n,r-a)&&(u=n.getDetectionResultColumn(r-a).getCodewordNearby(s)),u!=null)return o?u.getEndX():u.getStartX();let d=0;for(;ye.isValidBarcodeColumn(n,r-a);){r-=a;for(let h of n.getDetectionResultColumn(r).getCodewords())if(h!=null)return(o?h.getEndX():h.getStartX())+a*d*(h.getEndX()-h.getStartX());d++}return o?n.getBoundingBox().getMinX():n.getBoundingBox().getMaxX()}static detectCodeword(n,r,s,o,a,u,d,h){a=ye.adjustCodewordStartColumn(n,r,s,o,a,u);let g=ye.getModuleBitCount(n,r,s,o,a,u);if(g==null)return null;let x,E=Te.sum(g);if(o)x=a+E;else{for(let b=0;b<g.length/2;b++){let D=g[b];g[b]=g[g.length-1-b],g[g.length-1-b]=D}x=a,a=x-E}if(!ye.checkCodewordSkew(E,d,h))return null;let A=Xt.getDecodedValue(g),I=he.getCodeword(A);return I===-1?null:new ss(a,x,ye.getCodewordBucketNumber(A),I)}static getModuleBitCount(n,r,s,o,a,u){let d=a,h=new Int32Array(8),g=0,x=o?1:-1,E=o;for(;(o?d<s:d>=r)&&g<h.length;)n.get(d,u)===E?(h[g]++,d+=x):(g++,E=!E);return g===h.length||d===(o?s:r)&&g===h.length-1?h:null}static getNumberOfECCodeWords(n){return 2<<n}static adjustCodewordStartColumn(n,r,s,o,a,u){let d=a,h=o?-1:1;for(let g=0;g<2;g++){for(;(o?d>=r:d<s)&&o===n.get(d,u);){if(Math.abs(a-d)>ye.CODEWORD_SKEW_SIZE)return a;d+=h}h=-h,o=!o}return d}static checkCodewordSkew(n,r,s){return r-ye.CODEWORD_SKEW_SIZE<=n&&n<=s+ye.CODEWORD_SKEW_SIZE}static decodeCodewords(n,r,s){if(n.length===0)throw k.getFormatInstance();let o=1<<r+1,a=ye.correctErrors(n,s,o);ye.verifyCodewordCount(n,o);let u=W.decode(n,""+r);return u.setErrorsCorrected(a),u.setErasures(s.length),u}static correctErrors(n,r,s){if(r!=null&&r.length>s/2+ye.MAX_ERRORS||s<0||s>ye.MAX_EC_CODEWORDS)throw M.getChecksumInstance();return ye.errorCorrection.decode(n,s,r)}static verifyCodewordCount(n,r){if(n.length<4)throw k.getFormatInstance();let s=n[0];if(s>n.length)throw k.getFormatInstance();if(s===0)if(r<n.length)n[0]=n.length-r;else throw k.getFormatInstance()}static getBitCountForCodeword(n){let r=new Int32Array(8),s=0,o=r.length-1;for(;!((n&1)!==s&&(s=n&1,o--,o<0));)r[o]++,n>>=1;return r}static getCodewordBucketNumber(n){return n instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(n):this.getCodewordBucketNumber_number(n)}static getCodewordBucketNumber_number(n){return ye.getCodewordBucketNumber(ye.getBitCountForCodeword(n))}static getCodewordBucketNumber_Int32Array(n){return(n[0]-n[2]+n[4]-n[6]+9)%9}static toString(n){let r=new ts;for(let s=0;s<n.length;s++){r.format("Row %2d: ",s);for(let o=0;o<n[s].length;o++){let a=n[s][o];a.getValue().length===0?r.format(" ",null):r.format("%4d(%2d)",a.getValue()[0],a.getConfidence(a.getValue()[0]))}r.format("%n")}return r.toString()}}ye.CODEWORD_SKEW_SIZE=2,ye.MAX_ERRORS=3,ye.MAX_EC_CODEWORDS=512,ye.errorCorrection=new r1;class It{decode(n,r=null){let s=It.decode(n,r,!1);if(s==null||s.length===0||s[0]==null)throw j.getNotFoundInstance();return s[0]}decodeMultiple(n,r=null){try{return It.decode(n,r,!0)}catch(s){throw s instanceof k||s instanceof M?j.getNotFoundInstance():s}}static decode(n,r,s){const o=new Array,a=we.detectMultiple(n,r,s);for(const u of a.getPoints()){const d=ye.decode(a.getBits(),u[4],u[5],u[6],u[7],It.getMinCodewordWidth(u),It.getMaxCodewordWidth(u)),h=new Ke(d.getText(),d.getRawBytes(),void 0,u,le.PDF_417);h.putMetadata(mt.ERROR_CORRECTION_LEVEL,d.getECLevel());const g=d.getOther();g!=null&&h.putMetadata(mt.PDF417_EXTRA_METADATA,g),o.push(h)}return o.map(u=>u)}static getMaxWidth(n,r){return n==null||r==null?0:Math.trunc(Math.abs(n.getX()-r.getX()))}static getMinWidth(n,r){return n==null||r==null?N.MAX_VALUE:Math.trunc(Math.abs(n.getX()-r.getX()))}static getMaxCodewordWidth(n){return Math.floor(Math.max(Math.max(It.getMaxWidth(n[0],n[4]),It.getMaxWidth(n[6],n[2])*he.MODULES_IN_CODEWORD/he.MODULES_IN_STOP_PATTERN),Math.max(It.getMaxWidth(n[1],n[5]),It.getMaxWidth(n[7],n[3])*he.MODULES_IN_CODEWORD/he.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(n){return Math.floor(Math.min(Math.min(It.getMinWidth(n[0],n[4]),It.getMinWidth(n[6],n[2])*he.MODULES_IN_CODEWORD/he.MODULES_IN_STOP_PATTERN),Math.min(It.getMinWidth(n[1],n[5]),It.getMinWidth(n[7],n[3])*he.MODULES_IN_CODEWORD/he.MODULES_IN_STOP_PATTERN)))}reset(){}}class go extends m{}go.kind="ReaderException";class u1{constructor(n,r){this.verbose=n===!0,r&&this.setHints(r)}decode(n,r){return r&&this.setHints(r),this.decodeInternal(n)}decodeWithState(n){return(this.readers===null||this.readers===void 0)&&this.setHints(null),this.decodeInternal(n)}setHints(n){this.hints=n;const r=!l(n)&&n.get(U.TRY_HARDER)===!0,s=l(n)?null:n.get(U.POSSIBLE_FORMATS),o=new Array;if(!l(s)){const a=s.some(u=>u===le.UPC_A||u===le.UPC_E||u===le.EAN_13||u===le.EAN_8||u===le.CODABAR||u===le.CODE_39||u===le.CODE_93||u===le.CODE_128||u===le.ITF||u===le.RSS_14||u===le.RSS_EXPANDED);a&&!r&&o.push(new ai(n,this.verbose)),s.includes(le.QR_CODE)&&o.push(new ur),s.includes(le.DATA_MATRIX)&&o.push(new lr),s.includes(le.AZTEC)&&o.push(new ao),s.includes(le.PDF_417)&&o.push(new It),a&&r&&o.push(new ai(n,this.verbose))}o.length===0&&(r||o.push(new ai(n,this.verbose)),o.push(new ur),o.push(new lr),o.push(new ao),o.push(new It),r&&o.push(new ai(n,this.verbose))),this.readers=o}reset(){if(this.readers!==null)for(const n of this.readers)n.reset()}decodeInternal(n){if(this.readers===null)throw new go("No readers where selected, nothing can be read.");for(const r of this.readers)try{return r.decode(n,this.hints)}catch(s){if(s instanceof go)continue}throw new j("No MultiFormat Readers were able to detect the code.")}}class Yh extends cn{constructor(n=null,r=500){const s=new u1;s.setHints(n),super(s,r)}decodeBitmap(n){return this.reader.decodeWithState(n)}}class Zh extends cn{constructor(n=500){super(new It,n)}}class Kh extends cn{constructor(n=500){super(new ur,n)}}var nl;(function(y){y[y.ERROR_CORRECTION=0]="ERROR_CORRECTION",y[y.CHARACTER_SET=1]="CHARACTER_SET",y[y.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",y[y.MIN_SIZE=3]="MIN_SIZE",y[y.MAX_SIZE=4]="MAX_SIZE",y[y.MARGIN=5]="MARGIN",y[y.PDF417_COMPACT=6]="PDF417_COMPACT",y[y.PDF417_COMPACTION=7]="PDF417_COMPACTION",y[y.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",y[y.AZTEC_LAYERS=9]="AZTEC_LAYERS",y[y.QR_VERSION=10]="QR_VERSION"})(nl||(nl={}));var ht=nl;class rl{constructor(n){this.field=n,this.cachedGenerators=[],this.cachedGenerators.push(new Ht(n,Int32Array.from([1])))}buildGenerator(n){const r=this.cachedGenerators;if(n>=r.length){let s=r[r.length-1];const o=this.field;for(let a=r.length;a<=n;a++){const u=s.multiply(new Ht(o,Int32Array.from([1,o.exp(a-1+o.getGeneratorBase())])));r.push(u),s=u}}return r[n]}encode(n,r){if(r===0)throw new v("No error correction bytes");const s=n.length-r;if(s<=0)throw new v("No data bytes provided");const o=this.buildGenerator(r),a=new Int32Array(s);B.arraycopy(n,0,a,0,s);let u=new Ht(this.field,a);u=u.multiplyByMonomial(r,1);const h=u.divide(o)[1].getCoefficients(),g=r-h.length;for(let x=0;x<g;x++)n[s+x]=0;B.arraycopy(h,0,n,s+g,h.length)}}class it{constructor(){}static applyMaskPenaltyRule1(n){return it.applyMaskPenaltyRule1Internal(n,!0)+it.applyMaskPenaltyRule1Internal(n,!1)}static applyMaskPenaltyRule2(n){let r=0;const s=n.getArray(),o=n.getWidth(),a=n.getHeight();for(let u=0;u<a-1;u++){const d=s[u];for(let h=0;h<o-1;h++){const g=d[h];g===d[h+1]&&g===s[u+1][h]&&g===s[u+1][h+1]&&r++}}return it.N2*r}static applyMaskPenaltyRule3(n){let r=0;const s=n.getArray(),o=n.getWidth(),a=n.getHeight();for(let u=0;u<a;u++)for(let d=0;d<o;d++){const h=s[u];d+6<o&&h[d]===1&&h[d+1]===0&&h[d+2]===1&&h[d+3]===1&&h[d+4]===1&&h[d+5]===0&&h[d+6]===1&&(it.isWhiteHorizontal(h,d-4,d)||it.isWhiteHorizontal(h,d+7,d+11))&&r++,u+6<a&&s[u][d]===1&&s[u+1][d]===0&&s[u+2][d]===1&&s[u+3][d]===1&&s[u+4][d]===1&&s[u+5][d]===0&&s[u+6][d]===1&&(it.isWhiteVertical(s,d,u-4,u)||it.isWhiteVertical(s,d,u+7,u+11))&&r++}return r*it.N3}static isWhiteHorizontal(n,r,s){r=Math.max(r,0),s=Math.min(s,n.length);for(let o=r;o<s;o++)if(n[o]===1)return!1;return!0}static isWhiteVertical(n,r,s,o){s=Math.max(s,0),o=Math.min(o,n.length);for(let a=s;a<o;a++)if(n[a][r]===1)return!1;return!0}static applyMaskPenaltyRule4(n){let r=0;const s=n.getArray(),o=n.getWidth(),a=n.getHeight();for(let h=0;h<a;h++){const g=s[h];for(let x=0;x<o;x++)g[x]===1&&r++}const u=n.getHeight()*n.getWidth();return Math.floor(Math.abs(r*2-u)*10/u)*it.N4}static getDataMaskBit(n,r,s){let o,a;switch(n){case 0:o=s+r&1;break;case 1:o=s&1;break;case 2:o=r%3;break;case 3:o=(s+r)%3;break;case 4:o=Math.floor(s/2)+Math.floor(r/3)&1;break;case 5:a=s*r,o=(a&1)+a%3;break;case 6:a=s*r,o=(a&1)+a%3&1;break;case 7:a=s*r,o=a%3+(s+r&1)&1;break;default:throw new v("Invalid mask pattern: "+n)}return o===0}static applyMaskPenaltyRule1Internal(n,r){let s=0;const o=r?n.getHeight():n.getWidth(),a=r?n.getWidth():n.getHeight(),u=n.getArray();for(let d=0;d<o;d++){let h=0,g=-1;for(let x=0;x<a;x++){const E=r?u[d][x]:u[x][d];E===g?h++:(h>=5&&(s+=it.N1+(h-5)),h=1,g=E)}h>=5&&(s+=it.N1+(h-5))}return s}}it.N1=3,it.N2=3,it.N3=40,it.N4=10;class po{constructor(n,r){this.width=n,this.height=r;const s=new Array(r);for(let o=0;o!==r;o++)s[o]=new Uint8Array(n);this.bytes=s}getHeight(){return this.height}getWidth(){return this.width}get(n,r){return this.bytes[r][n]}getArray(){return this.bytes}setNumber(n,r,s){this.bytes[r][n]=s}setBoolean(n,r,s){this.bytes[r][n]=s?1:0}clear(n){for(const r of this.bytes)T.fill(r,n)}equals(n){if(!(n instanceof po))return!1;const r=n;if(this.width!==r.width||this.height!==r.height)return!1;for(let s=0,o=this.height;s<o;++s){const a=this.bytes[s],u=r.bytes[s];for(let d=0,h=this.width;d<h;++d)if(a[d]!==u[d])return!1}return!0}toString(){const n=new ge;for(let r=0,s=this.height;r<s;++r){const o=this.bytes[r];for(let a=0,u=this.width;a<u;++a)switch(o[a]){case 0:n.append(" 0");break;case 1:n.append(" 1");break;default:n.append(" ");break}n.append(`
67
67
  `)}return n.toString()}}class Ur{constructor(){this.maskPattern=-1}getMode(){return this.mode}getECLevel(){return this.ecLevel}getVersion(){return this.version}getMaskPattern(){return this.maskPattern}getMatrix(){return this.matrix}toString(){const n=new ge;return n.append(`<<
68
68
  `),n.append(" mode: "),n.append(this.mode?this.mode.toString():"null"),n.append(`
69
69
  ecLevel: `),n.append(this.ecLevel?this.ecLevel.toString():"null"),n.append(`
@@ -73,9 +73,9 @@ Error generating stack: `+f.message+`
73
73
  `),n.append(this.matrix.toString())):n.append(`
74
74
  matrix: null
75
75
  `),n.append(`>>
76
- `),n.toString()}setMode(n){this.mode=n}setECLevel(n){this.ecLevel=n}setVersion(n){this.version=n}setMaskPattern(n){this.maskPattern=n}setMatrix(n){this.matrix=n}static isValidMaskPattern(n){return n>=0&&n<Ur.NUM_MASK_PATTERNS}}Ur.NUM_MASK_PATTERNS=8;class Le extends m{}Le.kind="WriterException";class fe{constructor(){}static clearMatrix(n){n.clear(255)}static buildMatrix(n,r,s,o,a){fe.clearMatrix(a),fe.embedBasicPatterns(s,a),fe.embedTypeInfo(r,o,a),fe.maybeEmbedVersionInfo(s,a),fe.embedDataBits(n,o,a)}static embedBasicPatterns(n,r){fe.embedPositionDetectionPatternsAndSeparators(r),fe.embedDarkDotAtLeftBottomCorner(r),fe.maybeEmbedPositionAdjustmentPatterns(n,r),fe.embedTimingPatterns(r)}static embedTypeInfo(n,r,s){const o=new G;fe.makeTypeInfoBits(n,r,o);for(let a=0,u=o.getSize();a<u;++a){const d=o.get(o.getSize()-1-a),h=fe.TYPE_INFO_COORDINATES[a],g=h[0],x=h[1];if(s.setBoolean(g,x,d),a<8){const E=s.getWidth()-a-1;s.setBoolean(E,8,d)}else{const A=s.getHeight()-7+(a-8);s.setBoolean(8,A,d)}}}static maybeEmbedVersionInfo(n,r){if(n.getVersionNumber()<7)return;const s=new G;fe.makeVersionInfoBits(n,s);let o=6*3-1;for(let a=0;a<6;++a)for(let u=0;u<3;++u){const d=s.get(o);o--,r.setBoolean(a,r.getHeight()-11+u,d),r.setBoolean(r.getHeight()-11+u,a,d)}}static embedDataBits(n,r,s){let o=0,a=-1,u=s.getWidth()-1,d=s.getHeight()-1;for(;u>0;){for(u===6&&(u-=1);d>=0&&d<s.getHeight();){for(let h=0;h<2;++h){const g=u-h;if(!fe.isEmpty(s.get(g,d)))continue;let x;o<n.getSize()?(x=n.get(o),++o):x=!1,r!==255&&it.getDataMaskBit(r,g,d)&&(x=!x),s.setBoolean(g,d,x)}d+=a}a=-a,d+=a,u-=2}if(o!==n.getSize())throw new Le("Not all bits consumed: "+o+"/"+n.getSize())}static findMSBSet(n){return 32-N.numberOfLeadingZeros(n)}static calculateBCHCode(n,r){if(r===0)throw new v("0 polynomial");const s=fe.findMSBSet(r);for(n<<=s-1;fe.findMSBSet(n)>=s;)n^=r<<fe.findMSBSet(n)-s;return n}static makeTypeInfoBits(n,r,s){if(!Ur.isValidMaskPattern(r))throw new Le("Invalid mask pattern");const o=n.getBits()<<3|r;s.appendBits(o,5);const a=fe.calculateBCHCode(o,fe.TYPE_INFO_POLY);s.appendBits(a,10);const u=new G;if(u.appendBits(fe.TYPE_INFO_MASK_PATTERN,15),s.xor(u),s.getSize()!==15)throw new Le("should not happen but we got: "+s.getSize())}static makeVersionInfoBits(n,r){r.appendBits(n.getVersionNumber(),6);const s=fe.calculateBCHCode(n.getVersionNumber(),fe.VERSION_INFO_POLY);if(r.appendBits(s,12),r.getSize()!==18)throw new Le("should not happen but we got: "+r.getSize())}static isEmpty(n){return n===255}static embedTimingPatterns(n){for(let r=8;r<n.getWidth()-8;++r){const s=(r+1)%2;fe.isEmpty(n.get(r,6))&&n.setNumber(r,6,s),fe.isEmpty(n.get(6,r))&&n.setNumber(6,r,s)}}static embedDarkDotAtLeftBottomCorner(n){if(n.get(8,n.getHeight()-8)===0)throw new Le;n.setNumber(8,n.getHeight()-8,1)}static embedHorizontalSeparationPattern(n,r,s){for(let o=0;o<8;++o){if(!fe.isEmpty(s.get(n+o,r)))throw new Le;s.setNumber(n+o,r,0)}}static embedVerticalSeparationPattern(n,r,s){for(let o=0;o<7;++o){if(!fe.isEmpty(s.get(n,r+o)))throw new Le;s.setNumber(n,r+o,0)}}static embedPositionAdjustmentPattern(n,r,s){for(let o=0;o<5;++o){const a=fe.POSITION_ADJUSTMENT_PATTERN[o];for(let u=0;u<5;++u)s.setNumber(n+u,r+o,a[u])}}static embedPositionDetectionPattern(n,r,s){for(let o=0;o<7;++o){const a=fe.POSITION_DETECTION_PATTERN[o];for(let u=0;u<7;++u)s.setNumber(n+u,r+o,a[u])}}static embedPositionDetectionPatternsAndSeparators(n){const r=fe.POSITION_DETECTION_PATTERN[0].length;fe.embedPositionDetectionPattern(0,0,n),fe.embedPositionDetectionPattern(n.getWidth()-r,0,n),fe.embedPositionDetectionPattern(0,n.getWidth()-r,n);const s=8;fe.embedHorizontalSeparationPattern(0,s-1,n),fe.embedHorizontalSeparationPattern(n.getWidth()-s,s-1,n),fe.embedHorizontalSeparationPattern(0,n.getWidth()-s,n);const o=7;fe.embedVerticalSeparationPattern(o,0,n),fe.embedVerticalSeparationPattern(n.getHeight()-o-1,0,n),fe.embedVerticalSeparationPattern(o,n.getHeight()-o,n)}static maybeEmbedPositionAdjustmentPatterns(n,r){if(n.getVersionNumber()<2)return;const s=n.getVersionNumber()-1,o=fe.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[s];for(let a=0,u=o.length;a!==u;a++){const d=o[a];if(d>=0)for(let h=0;h!==u;h++){const g=o[h];g>=0&&fe.isEmpty(r.get(g,d))&&fe.embedPositionAdjustmentPattern(g-2,d-2,r)}}}}fe.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),fe.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),fe.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),fe.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),fe.VERSION_INFO_POLY=7973,fe.TYPE_INFO_POLY=1335,fe.TYPE_INFO_MASK_PATTERN=21522;class Qh{constructor(n,r){this.dataBytes=n,this.errorCorrectionBytes=r}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class Ve{constructor(){}static calculateMaskPenalty(n){return it.applyMaskPenaltyRule1(n)+it.applyMaskPenaltyRule2(n)+it.applyMaskPenaltyRule3(n)+it.applyMaskPenaltyRule4(n)}static encode(n,r,s=null){let o=Ve.DEFAULT_BYTE_MODE_ENCODING;const a=s!==null&&s.get(ht.CHARACTER_SET)!==void 0;a&&(o=s.get(ht.CHARACTER_SET).toString());const u=this.chooseMode(n,o),d=new G;if(u===ce.BYTE&&(a||Ve.DEFAULT_BYTE_MODE_ENCODING!==o)){const $=V.getCharacterSetECIByName(o);$!==void 0&&this.appendECI($,d)}this.appendModeInfo(u,d);const h=new G;this.appendBytes(n,u,h,o);let g;if(s!==null&&s.get(ht.QR_VERSION)!==void 0){const $=Number.parseInt(s.get(ht.QR_VERSION).toString(),10);g=le.getVersionForNumber($);const Z=this.calculateBitsNeeded(u,d,h,g);if(!this.willFit(Z,g,r))throw new Le("Data too big for requested version")}else g=this.recommendVersion(r,u,d,h);const x=new G;x.appendBitArray(d);const E=u===ce.BYTE?h.getSizeInBytes():n.length;this.appendLengthInfo(E,g,u,x),x.appendBitArray(h);const A=g.getECBlocksForLevel(r),I=g.getTotalCodewords()-A.getTotalECCodewords();this.terminateBits(I,x);const b=this.interleaveWithECBytes(x,g.getTotalCodewords(),I,A.getNumBlocks()),D=new Ur;D.setECLevel(r),D.setMode(u),D.setVersion(g);const L=g.getDimensionForVersion(),z=new po(L,L),q=this.chooseMaskPattern(b,r,g,z);return D.setMaskPattern(q),fe.buildMatrix(b,r,g,q,z),D.setMatrix(z),D}static recommendVersion(n,r,s,o){const a=this.calculateBitsNeeded(r,s,o,le.getVersionForNumber(1)),u=this.chooseVersion(a,n),d=this.calculateBitsNeeded(r,s,o,u);return this.chooseVersion(d,n)}static calculateBitsNeeded(n,r,s,o){return r.getSize()+n.getCharacterCountBits(o)+s.getSize()}static getAlphanumericCode(n){return n<Ve.ALPHANUMERIC_TABLE.length?Ve.ALPHANUMERIC_TABLE[n]:-1}static chooseMode(n,r=null){if(V.SJIS.getName()===r&&this.isOnlyDoubleByteKanji(n))return ce.KANJI;let s=!1,o=!1;for(let a=0,u=n.length;a<u;++a){const d=n.charAt(a);if(Ve.isDigit(d))s=!0;else if(this.getAlphanumericCode(d.charCodeAt(0))!==-1)o=!0;else return ce.BYTE}return o?ce.ALPHANUMERIC:s?ce.NUMERIC:ce.BYTE}static isOnlyDoubleByteKanji(n){let r;try{r=Ee.encode(n,V.SJIS)}catch{return!1}const s=r.length;if(s%2!==0)return!1;for(let o=0;o<s;o+=2){const a=r[o]&255;if((a<129||a>159)&&(a<224||a>235))return!1}return!0}static chooseMaskPattern(n,r,s,o){let a=Number.MAX_SAFE_INTEGER,u=-1;for(let d=0;d<Ur.NUM_MASK_PATTERNS;d++){fe.buildMatrix(n,r,s,d,o);let h=this.calculateMaskPenalty(o);h<a&&(a=h,u=d)}return u}static chooseVersion(n,r){for(let s=1;s<=40;s++){const o=le.getVersionForNumber(s);if(Ve.willFit(n,o,r))return o}throw new Le("Data too big")}static willFit(n,r,s){const o=r.getTotalCodewords(),u=r.getECBlocksForLevel(s).getTotalECCodewords(),d=o-u,h=(n+7)/8;return d>=h}static terminateBits(n,r){const s=n*8;if(r.getSize()>s)throw new Le("data bits cannot fit in the QR Code"+r.getSize()+" > "+s);for(let u=0;u<4&&r.getSize()<s;++u)r.appendBit(!1);const o=r.getSize()&7;if(o>0)for(let u=o;u<8;u++)r.appendBit(!1);const a=n-r.getSizeInBytes();for(let u=0;u<a;++u)r.appendBits(u&1?17:236,8);if(r.getSize()!==s)throw new Le("Bits size does not equal capacity")}static getNumDataBytesAndNumECBytesForBlockID(n,r,s,o,a,u){if(o>=s)throw new Le("Block ID too large");const d=n%s,h=s-d,g=Math.floor(n/s),x=g+1,E=Math.floor(r/s),A=E+1,I=g-E,b=x-A;if(I!==b)throw new Le("EC bytes mismatch");if(s!==h+d)throw new Le("RS blocks mismatch");if(n!==(E+I)*h+(A+b)*d)throw new Le("Total bytes mismatch");o<h?(a[0]=E,u[0]=I):(a[0]=A,u[0]=b)}static interleaveWithECBytes(n,r,s,o){if(n.getSizeInBytes()!==s)throw new Le("Number of bits and data bytes does not match");let a=0,u=0,d=0;const h=new Array;for(let x=0;x<o;++x){const E=new Int32Array(1),A=new Int32Array(1);Ve.getNumDataBytesAndNumECBytesForBlockID(r,s,o,x,E,A);const I=E[0],b=new Uint8Array(I);n.toBytes(8*a,b,0,I);const D=Ve.generateECBytes(b,A[0]);h.push(new Qh(b,D)),u=Math.max(u,I),d=Math.max(d,D.length),a+=E[0]}if(s!==a)throw new Le("Data bytes does not match offset");const g=new G;for(let x=0;x<u;++x)for(const E of h){const A=E.getDataBytes();x<A.length&&g.appendBits(A[x],8)}for(let x=0;x<d;++x)for(const E of h){const A=E.getErrorCorrectionBytes();x<A.length&&g.appendBits(A[x],8)}if(r!==g.getSizeInBytes())throw new Le("Interleaving error: "+r+" and "+g.getSizeInBytes()+" differ.");return g}static generateECBytes(n,r){const s=n.length,o=new Int32Array(s+r);for(let u=0;u<s;u++)o[u]=n[u]&255;new rl(be.QR_CODE_FIELD_256).encode(o,r);const a=new Uint8Array(r);for(let u=0;u<r;u++)a[u]=o[s+u];return a}static appendModeInfo(n,r){r.appendBits(n.getBits(),4)}static appendLengthInfo(n,r,s,o){const a=s.getCharacterCountBits(r);if(n>=1<<a)throw new Le(n+" is bigger than "+((1<<a)-1));o.appendBits(n,a)}static appendBytes(n,r,s,o){switch(r){case ce.NUMERIC:Ve.appendNumericBytes(n,s);break;case ce.ALPHANUMERIC:Ve.appendAlphanumericBytes(n,s);break;case ce.BYTE:Ve.append8BitBytes(n,s,o);break;case ce.KANJI:Ve.appendKanjiBytes(n,s);break;default:throw new Le("Invalid mode: "+r)}}static getDigit(n){return n.charCodeAt(0)-48}static isDigit(n){const r=Ve.getDigit(n);return r>=0&&r<=9}static appendNumericBytes(n,r){const s=n.length;let o=0;for(;o<s;){const a=Ve.getDigit(n.charAt(o));if(o+2<s){const u=Ve.getDigit(n.charAt(o+1)),d=Ve.getDigit(n.charAt(o+2));r.appendBits(a*100+u*10+d,10),o+=3}else if(o+1<s){const u=Ve.getDigit(n.charAt(o+1));r.appendBits(a*10+u,7),o+=2}else r.appendBits(a,4),o++}}static appendAlphanumericBytes(n,r){const s=n.length;let o=0;for(;o<s;){const a=Ve.getAlphanumericCode(n.charCodeAt(o));if(a===-1)throw new Le;if(o+1<s){const u=Ve.getAlphanumericCode(n.charCodeAt(o+1));if(u===-1)throw new Le;r.appendBits(a*45+u,11),o+=2}else r.appendBits(a,6),o++}}static append8BitBytes(n,r,s){let o;try{o=Ee.encode(n,s)}catch(a){throw new Le(a)}for(let a=0,u=o.length;a!==u;a++){const d=o[a];r.appendBits(d,8)}}static appendKanjiBytes(n,r){let s;try{s=Ee.encode(n,V.SJIS)}catch(a){throw new Le(a)}const o=s.length;for(let a=0;a<o;a+=2){const u=s[a]&255,d=s[a+1]&255,h=u<<8&4294967295|d;let g=-1;if(h>=33088&&h<=40956?g=h-33088:h>=57408&&h<=60351&&(g=h-49472),g===-1)throw new Le("Invalid byte sequence");const x=(g>>8)*192+(g&255);r.appendBits(x,13)}}static appendECI(n,r){r.appendBits(ce.ECI.getBits(),4),r.appendBits(n.getValue(),8)}}Ve.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),Ve.DEFAULT_BYTE_MODE_ENCODING=V.UTF8.getName();class Wr{write(n,r,s,o=null){if(n.length===0)throw new v("Found empty contents");if(r<0||s<0)throw new v("Requested dimensions are too small: "+r+"x"+s);let a=We.L,u=Wr.QUIET_ZONE_SIZE;o!==null&&(o.get(ht.ERROR_CORRECTION)!==void 0&&(a=We.fromString(o.get(ht.ERROR_CORRECTION).toString())),o.get(ht.MARGIN)!==void 0&&(u=Number.parseInt(o.get(ht.MARGIN).toString(),10)));const d=Ve.encode(n,a,o);return this.renderResult(d,r,s,u)}writeToDom(n,r,s,o,a=null){typeof n=="string"&&(n=document.querySelector(n));const u=this.write(r,s,o,a);n&&n.appendChild(u)}renderResult(n,r,s,o){const a=n.getMatrix();if(a===null)throw new Dn;const u=a.getWidth(),d=a.getHeight(),h=u+o*2,g=d+o*2,x=Math.max(r,h),E=Math.max(s,g),A=Math.min(Math.floor(x/h),Math.floor(E/g)),I=Math.floor((x-u*A)/2),b=Math.floor((E-d*A)/2),D=this.createSVGElement(x,E);for(let L=0,z=b;L<d;L++,z+=A)for(let q=0,$=I;q<u;q++,$+=A)if(a.get(q,L)===1){const Z=this.createSvgRectElement($,z,A,A);D.appendChild(Z)}return D}createSVGElement(n,r){const s=document.createElementNS(Wr.SVG_NS,"svg");return s.setAttributeNS(null,"height",n.toString()),s.setAttributeNS(null,"width",r.toString()),s}createSvgRectElement(n,r,s,o){const a=document.createElementNS(Wr.SVG_NS,"rect");return a.setAttributeNS(null,"x",n.toString()),a.setAttributeNS(null,"y",r.toString()),a.setAttributeNS(null,"height",s.toString()),a.setAttributeNS(null,"width",o.toString()),a.setAttributeNS(null,"fill","#000000"),a}}Wr.QUIET_ZONE_SIZE=4,Wr.SVG_NS="http://www.w3.org/2000/svg";class ui{encode(n,r,s,o,a){if(n.length===0)throw new v("Found empty contents");if(r!==ae.QR_CODE)throw new v("Can only encode QR_CODE, but got "+r);if(s<0||o<0)throw new v(`Requested dimensions are too small: ${s}x${o}`);let u=We.L,d=ui.QUIET_ZONE_SIZE;a!==null&&(a.get(ht.ERROR_CORRECTION)!==void 0&&(u=We.fromString(a.get(ht.ERROR_CORRECTION).toString())),a.get(ht.MARGIN)!==void 0&&(d=Number.parseInt(a.get(ht.MARGIN).toString(),10)));const h=Ve.encode(n,u,a);return ui.renderResult(h,s,o,d)}static renderResult(n,r,s,o){const a=n.getMatrix();if(a===null)throw new Dn;const u=a.getWidth(),d=a.getHeight(),h=u+o*2,g=d+o*2,x=Math.max(r,h),E=Math.max(s,g),A=Math.min(Math.floor(x/h),Math.floor(E/g)),I=Math.floor((x-u*A)/2),b=Math.floor((E-d*A)/2),D=new _e(x,E);for(let L=0,z=b;L<d;L++,z+=A)for(let q=0,$=I;q<u;q++,$+=A)a.get(q,L)===1&&D.setRegion($,z,A,A);return D}}ui.QUIET_ZONE_SIZE=4;class qh{encode(n,r,s,o,a){let u;switch(r){case ae.QR_CODE:u=new ui;break;default:throw new v("No encoder available for format "+r)}return u.encode(n,r,s,o,a)}}class Bn extends ee{constructor(n,r,s,o,a,u,d,h){if(super(u,d),this.yuvData=n,this.dataWidth=r,this.dataHeight=s,this.left=o,this.top=a,o+u>r||a+d>s)throw new v("Crop rectangle does not fit within image data.");h&&this.reverseHorizontal(u,d)}getRow(n,r){if(n<0||n>=this.getHeight())throw new v("Requested row is outside the image: "+n);const s=this.getWidth();(r==null||r.length<s)&&(r=new Uint8ClampedArray(s));const o=(n+this.top)*this.dataWidth+this.left;return B.arraycopy(this.yuvData,o,r,0,s),r}getMatrix(){const n=this.getWidth(),r=this.getHeight();if(n===this.dataWidth&&r===this.dataHeight)return this.yuvData;const s=n*r,o=new Uint8ClampedArray(s);let a=this.top*this.dataWidth+this.left;if(n===this.dataWidth)return B.arraycopy(this.yuvData,a,o,0,s),o;for(let u=0;u<r;u++){const d=u*n;B.arraycopy(this.yuvData,a,o,d,n),a+=this.dataWidth}return o}isCropSupported(){return!0}crop(n,r,s,o){return new Bn(this.yuvData,this.dataWidth,this.dataHeight,this.left+n,this.top+r,s,o,!1)}renderThumbnail(){const n=this.getWidth()/Bn.THUMBNAIL_SCALE_FACTOR,r=this.getHeight()/Bn.THUMBNAIL_SCALE_FACTOR,s=new Int32Array(n*r),o=this.yuvData;let a=this.top*this.dataWidth+this.left;for(let u=0;u<r;u++){const d=u*n;for(let h=0;h<n;h++){const g=o[a+h*Bn.THUMBNAIL_SCALE_FACTOR]&255;s[d+h]=4278190080|g*65793}a+=this.dataWidth*Bn.THUMBNAIL_SCALE_FACTOR}return s}getThumbnailWidth(){return this.getWidth()/Bn.THUMBNAIL_SCALE_FACTOR}getThumbnailHeight(){return this.getHeight()/Bn.THUMBNAIL_SCALE_FACTOR}reverseHorizontal(n,r){const s=this.yuvData;for(let o=0,a=this.top*this.dataWidth+this.left;o<r;o++,a+=this.dataWidth){const u=a+n/2;for(let d=a,h=a+n-1;d<u;d++,h--){const g=s[d];s[d]=s[h],s[h]=g}}}invert(){return new de(this)}}Bn.THUMBNAIL_SCALE_FACTOR=2;class il extends ee{constructor(n,r,s,o,a,u,d){if(super(r,s),this.dataWidth=o,this.dataHeight=a,this.left=u,this.top=d,n.BYTES_PER_ELEMENT===4){const h=r*s,g=new Uint8ClampedArray(h);for(let x=0;x<h;x++){const E=n[x],A=E>>16&255,I=E>>7&510,b=E&255;g[x]=(A+I+b)/4&255}this.luminances=g}else this.luminances=n;if(o===void 0&&(this.dataWidth=r),a===void 0&&(this.dataHeight=s),u===void 0&&(this.left=0),d===void 0&&(this.top=0),this.left+r>this.dataWidth||this.top+s>this.dataHeight)throw new v("Crop rectangle does not fit within image data.")}getRow(n,r){if(n<0||n>=this.getHeight())throw new v("Requested row is outside the image: "+n);const s=this.getWidth();(r==null||r.length<s)&&(r=new Uint8ClampedArray(s));const o=(n+this.top)*this.dataWidth+this.left;return B.arraycopy(this.luminances,o,r,0,s),r}getMatrix(){const n=this.getWidth(),r=this.getHeight();if(n===this.dataWidth&&r===this.dataHeight)return this.luminances;const s=n*r,o=new Uint8ClampedArray(s);let a=this.top*this.dataWidth+this.left;if(n===this.dataWidth)return B.arraycopy(this.luminances,a,o,0,s),o;for(let u=0;u<r;u++){const d=u*n;B.arraycopy(this.luminances,a,o,d,n),a+=this.dataWidth}return o}isCropSupported(){return!0}crop(n,r,s,o){return new il(this.luminances,s,o,this.dataWidth,this.dataHeight,this.left+n,this.top+r)}invert(){return new de(this)}}class c1 extends V{static forName(n){return this.getCharacterSetECIByName(n)}}class sl{}sl.ISO_8859_1=V.ISO8859_1;class f1{isCompact(){return this.compact}setCompact(n){this.compact=n}getSize(){return this.size}setSize(n){this.size=n}getLayers(){return this.layers}setLayers(n){this.layers=n}getCodeWords(){return this.codeWords}setCodeWords(n){this.codeWords=n}getMatrix(){return this.matrix}setMatrix(n){this.matrix=n}}class d1{static singletonList(n){return[n]}static min(n,r){return n.sort(r)[0]}}class $h{constructor(n){this.previous=n}getPrevious(){return this.previous}}class ci extends $h{constructor(n,r,s){super(n),this.value=r,this.bitCount=s}appendTo(n,r){n.appendBits(this.value,this.bitCount)}add(n,r){return new ci(this,n,r)}addBinaryShift(n,r){return console.warn("addBinaryShift on SimpleToken, this simply returns a copy of this token"),new ci(this,n,r)}toString(){let n=this.value&(1<<this.bitCount)-1;return n|=1<<this.bitCount,"<"+N.toBinaryString(n|1<<this.bitCount).substring(1)+">"}}class ol extends ci{constructor(n,r,s){super(n,0,0),this.binaryShiftStart=r,this.binaryShiftByteCount=s}appendTo(n,r){for(let s=0;s<this.binaryShiftByteCount;s++)(s===0||s===31&&this.binaryShiftByteCount<=62)&&(n.appendBits(31,5),this.binaryShiftByteCount>62?n.appendBits(this.binaryShiftByteCount-31,16):s===0?n.appendBits(Math.min(this.binaryShiftByteCount,31),5):n.appendBits(this.binaryShiftByteCount-31,5)),n.appendBits(r[this.binaryShiftStart+s],8)}addBinaryShift(n,r){return new ol(this,n,r)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function Jh(y,n,r){return new ol(y,n,r)}function os(y,n,r){return new ci(y,n,r)}const eg=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],fr=0,xo=1,gn=2,h1=3,Ln=4,tg=new ci(null,0,0),al=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])];function ng(y){for(let n of y)T.fill(n,-1);return y[fr][Ln]=0,y[xo][Ln]=0,y[xo][fr]=28,y[h1][Ln]=0,y[gn][Ln]=0,y[gn][fr]=15,y}const g1=ng(T.createInt32Array(6,6));class Fn{constructor(n,r,s,o){this.token=n,this.mode=r,this.binaryShiftByteCount=s,this.bitCount=o}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(n,r){let s=this.bitCount,o=this.token;if(n!==this.mode){let u=al[this.mode][n];o=os(o,u&65535,u>>16),s+=u>>16}let a=n===gn?4:5;return o=os(o,r,a),new Fn(o,n,0,s+a)}shiftAndAppend(n,r){let s=this.token,o=this.mode===gn?4:5;return s=os(s,g1[this.mode][n],o),s=os(s,r,5),new Fn(s,this.mode,0,this.bitCount+o+5)}addBinaryShiftChar(n){let r=this.token,s=this.mode,o=this.bitCount;if(this.mode===Ln||this.mode===gn){let d=al[s][fr];r=os(r,d&65535,d>>16),o+=d>>16,s=fr}let a=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,u=new Fn(r,s,this.binaryShiftByteCount+1,o+a);return u.binaryShiftByteCount===2078&&(u=u.endBinaryShift(n+1)),u}endBinaryShift(n){if(this.binaryShiftByteCount===0)return this;let r=this.token;return r=Jh(r,n-this.binaryShiftByteCount,this.binaryShiftByteCount),new Fn(r,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(n){let r=this.bitCount+(al[this.mode][n.mode]>>16);return this.binaryShiftByteCount<n.binaryShiftByteCount?r+=Fn.calculateBinaryShiftCost(n)-Fn.calculateBinaryShiftCost(this):this.binaryShiftByteCount>n.binaryShiftByteCount&&n.binaryShiftByteCount>0&&(r+=10),r<=n.bitCount}toBitArray(n){let r=[];for(let o=this.endBinaryShift(n.length).token;o!==null;o=o.getPrevious())r.unshift(o);let s=new G;for(const o of r)o.appendTo(s,n);return s}toString(){return ie.format("%s bits=%d bytes=%d",eg[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(n){return n.binaryShiftByteCount>62?21:n.binaryShiftByteCount>31?20:n.binaryShiftByteCount>0?10:0}}Fn.INITIAL_STATE=new Fn(tg,fr,0,0);function rg(y){const n=ie.getCharCode(" "),r=ie.getCharCode("."),s=ie.getCharCode(",");y[fr][n]=1;const o=ie.getCharCode("Z"),a=ie.getCharCode("A");for(let A=a;A<=o;A++)y[fr][A]=A-a+2;y[xo][n]=1;const u=ie.getCharCode("z"),d=ie.getCharCode("a");for(let A=d;A<=u;A++)y[xo][A]=A-d+2;y[gn][n]=1;const h=ie.getCharCode("9"),g=ie.getCharCode("0");for(let A=g;A<=h;A++)y[gn][A]=A-g+2;y[gn][s]=12,y[gn][r]=13;const x=["\0"," ","","","","","","","\x07","\b"," ",`
76
+ `),n.toString()}setMode(n){this.mode=n}setECLevel(n){this.ecLevel=n}setVersion(n){this.version=n}setMaskPattern(n){this.maskPattern=n}setMatrix(n){this.matrix=n}static isValidMaskPattern(n){return n>=0&&n<Ur.NUM_MASK_PATTERNS}}Ur.NUM_MASK_PATTERNS=8;class Le extends m{}Le.kind="WriterException";class fe{constructor(){}static clearMatrix(n){n.clear(255)}static buildMatrix(n,r,s,o,a){fe.clearMatrix(a),fe.embedBasicPatterns(s,a),fe.embedTypeInfo(r,o,a),fe.maybeEmbedVersionInfo(s,a),fe.embedDataBits(n,o,a)}static embedBasicPatterns(n,r){fe.embedPositionDetectionPatternsAndSeparators(r),fe.embedDarkDotAtLeftBottomCorner(r),fe.maybeEmbedPositionAdjustmentPatterns(n,r),fe.embedTimingPatterns(r)}static embedTypeInfo(n,r,s){const o=new G;fe.makeTypeInfoBits(n,r,o);for(let a=0,u=o.getSize();a<u;++a){const d=o.get(o.getSize()-1-a),h=fe.TYPE_INFO_COORDINATES[a],g=h[0],x=h[1];if(s.setBoolean(g,x,d),a<8){const E=s.getWidth()-a-1;s.setBoolean(E,8,d)}else{const A=s.getHeight()-7+(a-8);s.setBoolean(8,A,d)}}}static maybeEmbedVersionInfo(n,r){if(n.getVersionNumber()<7)return;const s=new G;fe.makeVersionInfoBits(n,s);let o=6*3-1;for(let a=0;a<6;++a)for(let u=0;u<3;++u){const d=s.get(o);o--,r.setBoolean(a,r.getHeight()-11+u,d),r.setBoolean(r.getHeight()-11+u,a,d)}}static embedDataBits(n,r,s){let o=0,a=-1,u=s.getWidth()-1,d=s.getHeight()-1;for(;u>0;){for(u===6&&(u-=1);d>=0&&d<s.getHeight();){for(let h=0;h<2;++h){const g=u-h;if(!fe.isEmpty(s.get(g,d)))continue;let x;o<n.getSize()?(x=n.get(o),++o):x=!1,r!==255&&it.getDataMaskBit(r,g,d)&&(x=!x),s.setBoolean(g,d,x)}d+=a}a=-a,d+=a,u-=2}if(o!==n.getSize())throw new Le("Not all bits consumed: "+o+"/"+n.getSize())}static findMSBSet(n){return 32-N.numberOfLeadingZeros(n)}static calculateBCHCode(n,r){if(r===0)throw new v("0 polynomial");const s=fe.findMSBSet(r);for(n<<=s-1;fe.findMSBSet(n)>=s;)n^=r<<fe.findMSBSet(n)-s;return n}static makeTypeInfoBits(n,r,s){if(!Ur.isValidMaskPattern(r))throw new Le("Invalid mask pattern");const o=n.getBits()<<3|r;s.appendBits(o,5);const a=fe.calculateBCHCode(o,fe.TYPE_INFO_POLY);s.appendBits(a,10);const u=new G;if(u.appendBits(fe.TYPE_INFO_MASK_PATTERN,15),s.xor(u),s.getSize()!==15)throw new Le("should not happen but we got: "+s.getSize())}static makeVersionInfoBits(n,r){r.appendBits(n.getVersionNumber(),6);const s=fe.calculateBCHCode(n.getVersionNumber(),fe.VERSION_INFO_POLY);if(r.appendBits(s,12),r.getSize()!==18)throw new Le("should not happen but we got: "+r.getSize())}static isEmpty(n){return n===255}static embedTimingPatterns(n){for(let r=8;r<n.getWidth()-8;++r){const s=(r+1)%2;fe.isEmpty(n.get(r,6))&&n.setNumber(r,6,s),fe.isEmpty(n.get(6,r))&&n.setNumber(6,r,s)}}static embedDarkDotAtLeftBottomCorner(n){if(n.get(8,n.getHeight()-8)===0)throw new Le;n.setNumber(8,n.getHeight()-8,1)}static embedHorizontalSeparationPattern(n,r,s){for(let o=0;o<8;++o){if(!fe.isEmpty(s.get(n+o,r)))throw new Le;s.setNumber(n+o,r,0)}}static embedVerticalSeparationPattern(n,r,s){for(let o=0;o<7;++o){if(!fe.isEmpty(s.get(n,r+o)))throw new Le;s.setNumber(n,r+o,0)}}static embedPositionAdjustmentPattern(n,r,s){for(let o=0;o<5;++o){const a=fe.POSITION_ADJUSTMENT_PATTERN[o];for(let u=0;u<5;++u)s.setNumber(n+u,r+o,a[u])}}static embedPositionDetectionPattern(n,r,s){for(let o=0;o<7;++o){const a=fe.POSITION_DETECTION_PATTERN[o];for(let u=0;u<7;++u)s.setNumber(n+u,r+o,a[u])}}static embedPositionDetectionPatternsAndSeparators(n){const r=fe.POSITION_DETECTION_PATTERN[0].length;fe.embedPositionDetectionPattern(0,0,n),fe.embedPositionDetectionPattern(n.getWidth()-r,0,n),fe.embedPositionDetectionPattern(0,n.getWidth()-r,n);const s=8;fe.embedHorizontalSeparationPattern(0,s-1,n),fe.embedHorizontalSeparationPattern(n.getWidth()-s,s-1,n),fe.embedHorizontalSeparationPattern(0,n.getWidth()-s,n);const o=7;fe.embedVerticalSeparationPattern(o,0,n),fe.embedVerticalSeparationPattern(n.getHeight()-o-1,0,n),fe.embedVerticalSeparationPattern(o,n.getHeight()-o,n)}static maybeEmbedPositionAdjustmentPatterns(n,r){if(n.getVersionNumber()<2)return;const s=n.getVersionNumber()-1,o=fe.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[s];for(let a=0,u=o.length;a!==u;a++){const d=o[a];if(d>=0)for(let h=0;h!==u;h++){const g=o[h];g>=0&&fe.isEmpty(r.get(g,d))&&fe.embedPositionAdjustmentPattern(g-2,d-2,r)}}}}fe.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),fe.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),fe.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),fe.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),fe.VERSION_INFO_POLY=7973,fe.TYPE_INFO_POLY=1335,fe.TYPE_INFO_MASK_PATTERN=21522;class Qh{constructor(n,r){this.dataBytes=n,this.errorCorrectionBytes=r}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class Ve{constructor(){}static calculateMaskPenalty(n){return it.applyMaskPenaltyRule1(n)+it.applyMaskPenaltyRule2(n)+it.applyMaskPenaltyRule3(n)+it.applyMaskPenaltyRule4(n)}static encode(n,r,s=null){let o=Ve.DEFAULT_BYTE_MODE_ENCODING;const a=s!==null&&s.get(ht.CHARACTER_SET)!==void 0;a&&(o=s.get(ht.CHARACTER_SET).toString());const u=this.chooseMode(n,o),d=new G;if(u===ce.BYTE&&(a||Ve.DEFAULT_BYTE_MODE_ENCODING!==o)){const $=V.getCharacterSetECIByName(o);$!==void 0&&this.appendECI($,d)}this.appendModeInfo(u,d);const h=new G;this.appendBytes(n,u,h,o);let g;if(s!==null&&s.get(ht.QR_VERSION)!==void 0){const $=Number.parseInt(s.get(ht.QR_VERSION).toString(),10);g=ue.getVersionForNumber($);const Z=this.calculateBitsNeeded(u,d,h,g);if(!this.willFit(Z,g,r))throw new Le("Data too big for requested version")}else g=this.recommendVersion(r,u,d,h);const x=new G;x.appendBitArray(d);const E=u===ce.BYTE?h.getSizeInBytes():n.length;this.appendLengthInfo(E,g,u,x),x.appendBitArray(h);const A=g.getECBlocksForLevel(r),I=g.getTotalCodewords()-A.getTotalECCodewords();this.terminateBits(I,x);const b=this.interleaveWithECBytes(x,g.getTotalCodewords(),I,A.getNumBlocks()),D=new Ur;D.setECLevel(r),D.setMode(u),D.setVersion(g);const L=g.getDimensionForVersion(),z=new po(L,L),q=this.chooseMaskPattern(b,r,g,z);return D.setMaskPattern(q),fe.buildMatrix(b,r,g,q,z),D.setMatrix(z),D}static recommendVersion(n,r,s,o){const a=this.calculateBitsNeeded(r,s,o,ue.getVersionForNumber(1)),u=this.chooseVersion(a,n),d=this.calculateBitsNeeded(r,s,o,u);return this.chooseVersion(d,n)}static calculateBitsNeeded(n,r,s,o){return r.getSize()+n.getCharacterCountBits(o)+s.getSize()}static getAlphanumericCode(n){return n<Ve.ALPHANUMERIC_TABLE.length?Ve.ALPHANUMERIC_TABLE[n]:-1}static chooseMode(n,r=null){if(V.SJIS.getName()===r&&this.isOnlyDoubleByteKanji(n))return ce.KANJI;let s=!1,o=!1;for(let a=0,u=n.length;a<u;++a){const d=n.charAt(a);if(Ve.isDigit(d))s=!0;else if(this.getAlphanumericCode(d.charCodeAt(0))!==-1)o=!0;else return ce.BYTE}return o?ce.ALPHANUMERIC:s?ce.NUMERIC:ce.BYTE}static isOnlyDoubleByteKanji(n){let r;try{r=Ee.encode(n,V.SJIS)}catch{return!1}const s=r.length;if(s%2!==0)return!1;for(let o=0;o<s;o+=2){const a=r[o]&255;if((a<129||a>159)&&(a<224||a>235))return!1}return!0}static chooseMaskPattern(n,r,s,o){let a=Number.MAX_SAFE_INTEGER,u=-1;for(let d=0;d<Ur.NUM_MASK_PATTERNS;d++){fe.buildMatrix(n,r,s,d,o);let h=this.calculateMaskPenalty(o);h<a&&(a=h,u=d)}return u}static chooseVersion(n,r){for(let s=1;s<=40;s++){const o=ue.getVersionForNumber(s);if(Ve.willFit(n,o,r))return o}throw new Le("Data too big")}static willFit(n,r,s){const o=r.getTotalCodewords(),u=r.getECBlocksForLevel(s).getTotalECCodewords(),d=o-u,h=(n+7)/8;return d>=h}static terminateBits(n,r){const s=n*8;if(r.getSize()>s)throw new Le("data bits cannot fit in the QR Code"+r.getSize()+" > "+s);for(let u=0;u<4&&r.getSize()<s;++u)r.appendBit(!1);const o=r.getSize()&7;if(o>0)for(let u=o;u<8;u++)r.appendBit(!1);const a=n-r.getSizeInBytes();for(let u=0;u<a;++u)r.appendBits(u&1?17:236,8);if(r.getSize()!==s)throw new Le("Bits size does not equal capacity")}static getNumDataBytesAndNumECBytesForBlockID(n,r,s,o,a,u){if(o>=s)throw new Le("Block ID too large");const d=n%s,h=s-d,g=Math.floor(n/s),x=g+1,E=Math.floor(r/s),A=E+1,I=g-E,b=x-A;if(I!==b)throw new Le("EC bytes mismatch");if(s!==h+d)throw new Le("RS blocks mismatch");if(n!==(E+I)*h+(A+b)*d)throw new Le("Total bytes mismatch");o<h?(a[0]=E,u[0]=I):(a[0]=A,u[0]=b)}static interleaveWithECBytes(n,r,s,o){if(n.getSizeInBytes()!==s)throw new Le("Number of bits and data bytes does not match");let a=0,u=0,d=0;const h=new Array;for(let x=0;x<o;++x){const E=new Int32Array(1),A=new Int32Array(1);Ve.getNumDataBytesAndNumECBytesForBlockID(r,s,o,x,E,A);const I=E[0],b=new Uint8Array(I);n.toBytes(8*a,b,0,I);const D=Ve.generateECBytes(b,A[0]);h.push(new Qh(b,D)),u=Math.max(u,I),d=Math.max(d,D.length),a+=E[0]}if(s!==a)throw new Le("Data bytes does not match offset");const g=new G;for(let x=0;x<u;++x)for(const E of h){const A=E.getDataBytes();x<A.length&&g.appendBits(A[x],8)}for(let x=0;x<d;++x)for(const E of h){const A=E.getErrorCorrectionBytes();x<A.length&&g.appendBits(A[x],8)}if(r!==g.getSizeInBytes())throw new Le("Interleaving error: "+r+" and "+g.getSizeInBytes()+" differ.");return g}static generateECBytes(n,r){const s=n.length,o=new Int32Array(s+r);for(let u=0;u<s;u++)o[u]=n[u]&255;new rl(be.QR_CODE_FIELD_256).encode(o,r);const a=new Uint8Array(r);for(let u=0;u<r;u++)a[u]=o[s+u];return a}static appendModeInfo(n,r){r.appendBits(n.getBits(),4)}static appendLengthInfo(n,r,s,o){const a=s.getCharacterCountBits(r);if(n>=1<<a)throw new Le(n+" is bigger than "+((1<<a)-1));o.appendBits(n,a)}static appendBytes(n,r,s,o){switch(r){case ce.NUMERIC:Ve.appendNumericBytes(n,s);break;case ce.ALPHANUMERIC:Ve.appendAlphanumericBytes(n,s);break;case ce.BYTE:Ve.append8BitBytes(n,s,o);break;case ce.KANJI:Ve.appendKanjiBytes(n,s);break;default:throw new Le("Invalid mode: "+r)}}static getDigit(n){return n.charCodeAt(0)-48}static isDigit(n){const r=Ve.getDigit(n);return r>=0&&r<=9}static appendNumericBytes(n,r){const s=n.length;let o=0;for(;o<s;){const a=Ve.getDigit(n.charAt(o));if(o+2<s){const u=Ve.getDigit(n.charAt(o+1)),d=Ve.getDigit(n.charAt(o+2));r.appendBits(a*100+u*10+d,10),o+=3}else if(o+1<s){const u=Ve.getDigit(n.charAt(o+1));r.appendBits(a*10+u,7),o+=2}else r.appendBits(a,4),o++}}static appendAlphanumericBytes(n,r){const s=n.length;let o=0;for(;o<s;){const a=Ve.getAlphanumericCode(n.charCodeAt(o));if(a===-1)throw new Le;if(o+1<s){const u=Ve.getAlphanumericCode(n.charCodeAt(o+1));if(u===-1)throw new Le;r.appendBits(a*45+u,11),o+=2}else r.appendBits(a,6),o++}}static append8BitBytes(n,r,s){let o;try{o=Ee.encode(n,s)}catch(a){throw new Le(a)}for(let a=0,u=o.length;a!==u;a++){const d=o[a];r.appendBits(d,8)}}static appendKanjiBytes(n,r){let s;try{s=Ee.encode(n,V.SJIS)}catch(a){throw new Le(a)}const o=s.length;for(let a=0;a<o;a+=2){const u=s[a]&255,d=s[a+1]&255,h=u<<8&4294967295|d;let g=-1;if(h>=33088&&h<=40956?g=h-33088:h>=57408&&h<=60351&&(g=h-49472),g===-1)throw new Le("Invalid byte sequence");const x=(g>>8)*192+(g&255);r.appendBits(x,13)}}static appendECI(n,r){r.appendBits(ce.ECI.getBits(),4),r.appendBits(n.getValue(),8)}}Ve.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),Ve.DEFAULT_BYTE_MODE_ENCODING=V.UTF8.getName();class Wr{write(n,r,s,o=null){if(n.length===0)throw new v("Found empty contents");if(r<0||s<0)throw new v("Requested dimensions are too small: "+r+"x"+s);let a=We.L,u=Wr.QUIET_ZONE_SIZE;o!==null&&(o.get(ht.ERROR_CORRECTION)!==void 0&&(a=We.fromString(o.get(ht.ERROR_CORRECTION).toString())),o.get(ht.MARGIN)!==void 0&&(u=Number.parseInt(o.get(ht.MARGIN).toString(),10)));const d=Ve.encode(n,a,o);return this.renderResult(d,r,s,u)}writeToDom(n,r,s,o,a=null){typeof n=="string"&&(n=document.querySelector(n));const u=this.write(r,s,o,a);n&&n.appendChild(u)}renderResult(n,r,s,o){const a=n.getMatrix();if(a===null)throw new Dn;const u=a.getWidth(),d=a.getHeight(),h=u+o*2,g=d+o*2,x=Math.max(r,h),E=Math.max(s,g),A=Math.min(Math.floor(x/h),Math.floor(E/g)),I=Math.floor((x-u*A)/2),b=Math.floor((E-d*A)/2),D=this.createSVGElement(x,E);for(let L=0,z=b;L<d;L++,z+=A)for(let q=0,$=I;q<u;q++,$+=A)if(a.get(q,L)===1){const Z=this.createSvgRectElement($,z,A,A);D.appendChild(Z)}return D}createSVGElement(n,r){const s=document.createElementNS(Wr.SVG_NS,"svg");return s.setAttributeNS(null,"height",n.toString()),s.setAttributeNS(null,"width",r.toString()),s}createSvgRectElement(n,r,s,o){const a=document.createElementNS(Wr.SVG_NS,"rect");return a.setAttributeNS(null,"x",n.toString()),a.setAttributeNS(null,"y",r.toString()),a.setAttributeNS(null,"height",s.toString()),a.setAttributeNS(null,"width",o.toString()),a.setAttributeNS(null,"fill","#000000"),a}}Wr.QUIET_ZONE_SIZE=4,Wr.SVG_NS="http://www.w3.org/2000/svg";class ui{encode(n,r,s,o,a){if(n.length===0)throw new v("Found empty contents");if(r!==le.QR_CODE)throw new v("Can only encode QR_CODE, but got "+r);if(s<0||o<0)throw new v(`Requested dimensions are too small: ${s}x${o}`);let u=We.L,d=ui.QUIET_ZONE_SIZE;a!==null&&(a.get(ht.ERROR_CORRECTION)!==void 0&&(u=We.fromString(a.get(ht.ERROR_CORRECTION).toString())),a.get(ht.MARGIN)!==void 0&&(d=Number.parseInt(a.get(ht.MARGIN).toString(),10)));const h=Ve.encode(n,u,a);return ui.renderResult(h,s,o,d)}static renderResult(n,r,s,o){const a=n.getMatrix();if(a===null)throw new Dn;const u=a.getWidth(),d=a.getHeight(),h=u+o*2,g=d+o*2,x=Math.max(r,h),E=Math.max(s,g),A=Math.min(Math.floor(x/h),Math.floor(E/g)),I=Math.floor((x-u*A)/2),b=Math.floor((E-d*A)/2),D=new _e(x,E);for(let L=0,z=b;L<d;L++,z+=A)for(let q=0,$=I;q<u;q++,$+=A)a.get(q,L)===1&&D.setRegion($,z,A,A);return D}}ui.QUIET_ZONE_SIZE=4;class qh{encode(n,r,s,o,a){let u;switch(r){case le.QR_CODE:u=new ui;break;default:throw new v("No encoder available for format "+r)}return u.encode(n,r,s,o,a)}}class Bn extends ee{constructor(n,r,s,o,a,u,d,h){if(super(u,d),this.yuvData=n,this.dataWidth=r,this.dataHeight=s,this.left=o,this.top=a,o+u>r||a+d>s)throw new v("Crop rectangle does not fit within image data.");h&&this.reverseHorizontal(u,d)}getRow(n,r){if(n<0||n>=this.getHeight())throw new v("Requested row is outside the image: "+n);const s=this.getWidth();(r==null||r.length<s)&&(r=new Uint8ClampedArray(s));const o=(n+this.top)*this.dataWidth+this.left;return B.arraycopy(this.yuvData,o,r,0,s),r}getMatrix(){const n=this.getWidth(),r=this.getHeight();if(n===this.dataWidth&&r===this.dataHeight)return this.yuvData;const s=n*r,o=new Uint8ClampedArray(s);let a=this.top*this.dataWidth+this.left;if(n===this.dataWidth)return B.arraycopy(this.yuvData,a,o,0,s),o;for(let u=0;u<r;u++){const d=u*n;B.arraycopy(this.yuvData,a,o,d,n),a+=this.dataWidth}return o}isCropSupported(){return!0}crop(n,r,s,o){return new Bn(this.yuvData,this.dataWidth,this.dataHeight,this.left+n,this.top+r,s,o,!1)}renderThumbnail(){const n=this.getWidth()/Bn.THUMBNAIL_SCALE_FACTOR,r=this.getHeight()/Bn.THUMBNAIL_SCALE_FACTOR,s=new Int32Array(n*r),o=this.yuvData;let a=this.top*this.dataWidth+this.left;for(let u=0;u<r;u++){const d=u*n;for(let h=0;h<n;h++){const g=o[a+h*Bn.THUMBNAIL_SCALE_FACTOR]&255;s[d+h]=4278190080|g*65793}a+=this.dataWidth*Bn.THUMBNAIL_SCALE_FACTOR}return s}getThumbnailWidth(){return this.getWidth()/Bn.THUMBNAIL_SCALE_FACTOR}getThumbnailHeight(){return this.getHeight()/Bn.THUMBNAIL_SCALE_FACTOR}reverseHorizontal(n,r){const s=this.yuvData;for(let o=0,a=this.top*this.dataWidth+this.left;o<r;o++,a+=this.dataWidth){const u=a+n/2;for(let d=a,h=a+n-1;d<u;d++,h--){const g=s[d];s[d]=s[h],s[h]=g}}}invert(){return new de(this)}}Bn.THUMBNAIL_SCALE_FACTOR=2;class il extends ee{constructor(n,r,s,o,a,u,d){if(super(r,s),this.dataWidth=o,this.dataHeight=a,this.left=u,this.top=d,n.BYTES_PER_ELEMENT===4){const h=r*s,g=new Uint8ClampedArray(h);for(let x=0;x<h;x++){const E=n[x],A=E>>16&255,I=E>>7&510,b=E&255;g[x]=(A+I+b)/4&255}this.luminances=g}else this.luminances=n;if(o===void 0&&(this.dataWidth=r),a===void 0&&(this.dataHeight=s),u===void 0&&(this.left=0),d===void 0&&(this.top=0),this.left+r>this.dataWidth||this.top+s>this.dataHeight)throw new v("Crop rectangle does not fit within image data.")}getRow(n,r){if(n<0||n>=this.getHeight())throw new v("Requested row is outside the image: "+n);const s=this.getWidth();(r==null||r.length<s)&&(r=new Uint8ClampedArray(s));const o=(n+this.top)*this.dataWidth+this.left;return B.arraycopy(this.luminances,o,r,0,s),r}getMatrix(){const n=this.getWidth(),r=this.getHeight();if(n===this.dataWidth&&r===this.dataHeight)return this.luminances;const s=n*r,o=new Uint8ClampedArray(s);let a=this.top*this.dataWidth+this.left;if(n===this.dataWidth)return B.arraycopy(this.luminances,a,o,0,s),o;for(let u=0;u<r;u++){const d=u*n;B.arraycopy(this.luminances,a,o,d,n),a+=this.dataWidth}return o}isCropSupported(){return!0}crop(n,r,s,o){return new il(this.luminances,s,o,this.dataWidth,this.dataHeight,this.left+n,this.top+r)}invert(){return new de(this)}}class c1 extends V{static forName(n){return this.getCharacterSetECIByName(n)}}class sl{}sl.ISO_8859_1=V.ISO8859_1;class f1{isCompact(){return this.compact}setCompact(n){this.compact=n}getSize(){return this.size}setSize(n){this.size=n}getLayers(){return this.layers}setLayers(n){this.layers=n}getCodeWords(){return this.codeWords}setCodeWords(n){this.codeWords=n}getMatrix(){return this.matrix}setMatrix(n){this.matrix=n}}class d1{static singletonList(n){return[n]}static min(n,r){return n.sort(r)[0]}}class $h{constructor(n){this.previous=n}getPrevious(){return this.previous}}class ci extends $h{constructor(n,r,s){super(n),this.value=r,this.bitCount=s}appendTo(n,r){n.appendBits(this.value,this.bitCount)}add(n,r){return new ci(this,n,r)}addBinaryShift(n,r){return console.warn("addBinaryShift on SimpleToken, this simply returns a copy of this token"),new ci(this,n,r)}toString(){let n=this.value&(1<<this.bitCount)-1;return n|=1<<this.bitCount,"<"+N.toBinaryString(n|1<<this.bitCount).substring(1)+">"}}class ol extends ci{constructor(n,r,s){super(n,0,0),this.binaryShiftStart=r,this.binaryShiftByteCount=s}appendTo(n,r){for(let s=0;s<this.binaryShiftByteCount;s++)(s===0||s===31&&this.binaryShiftByteCount<=62)&&(n.appendBits(31,5),this.binaryShiftByteCount>62?n.appendBits(this.binaryShiftByteCount-31,16):s===0?n.appendBits(Math.min(this.binaryShiftByteCount,31),5):n.appendBits(this.binaryShiftByteCount-31,5)),n.appendBits(r[this.binaryShiftStart+s],8)}addBinaryShift(n,r){return new ol(this,n,r)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function Jh(y,n,r){return new ol(y,n,r)}function os(y,n,r){return new ci(y,n,r)}const eg=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],fr=0,xo=1,gn=2,h1=3,Ln=4,tg=new ci(null,0,0),al=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])];function ng(y){for(let n of y)T.fill(n,-1);return y[fr][Ln]=0,y[xo][Ln]=0,y[xo][fr]=28,y[h1][Ln]=0,y[gn][Ln]=0,y[gn][fr]=15,y}const g1=ng(T.createInt32Array(6,6));class Fn{constructor(n,r,s,o){this.token=n,this.mode=r,this.binaryShiftByteCount=s,this.bitCount=o}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(n,r){let s=this.bitCount,o=this.token;if(n!==this.mode){let u=al[this.mode][n];o=os(o,u&65535,u>>16),s+=u>>16}let a=n===gn?4:5;return o=os(o,r,a),new Fn(o,n,0,s+a)}shiftAndAppend(n,r){let s=this.token,o=this.mode===gn?4:5;return s=os(s,g1[this.mode][n],o),s=os(s,r,5),new Fn(s,this.mode,0,this.bitCount+o+5)}addBinaryShiftChar(n){let r=this.token,s=this.mode,o=this.bitCount;if(this.mode===Ln||this.mode===gn){let d=al[s][fr];r=os(r,d&65535,d>>16),o+=d>>16,s=fr}let a=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,u=new Fn(r,s,this.binaryShiftByteCount+1,o+a);return u.binaryShiftByteCount===2078&&(u=u.endBinaryShift(n+1)),u}endBinaryShift(n){if(this.binaryShiftByteCount===0)return this;let r=this.token;return r=Jh(r,n-this.binaryShiftByteCount,this.binaryShiftByteCount),new Fn(r,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(n){let r=this.bitCount+(al[this.mode][n.mode]>>16);return this.binaryShiftByteCount<n.binaryShiftByteCount?r+=Fn.calculateBinaryShiftCost(n)-Fn.calculateBinaryShiftCost(this):this.binaryShiftByteCount>n.binaryShiftByteCount&&n.binaryShiftByteCount>0&&(r+=10),r<=n.bitCount}toBitArray(n){let r=[];for(let o=this.endBinaryShift(n.length).token;o!==null;o=o.getPrevious())r.unshift(o);let s=new G;for(const o of r)o.appendTo(s,n);return s}toString(){return ie.format("%s bits=%d bytes=%d",eg[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(n){return n.binaryShiftByteCount>62?21:n.binaryShiftByteCount>31?20:n.binaryShiftByteCount>0?10:0}}Fn.INITIAL_STATE=new Fn(tg,fr,0,0);function rg(y){const n=ie.getCharCode(" "),r=ie.getCharCode("."),s=ie.getCharCode(",");y[fr][n]=1;const o=ie.getCharCode("Z"),a=ie.getCharCode("A");for(let A=a;A<=o;A++)y[fr][A]=A-a+2;y[xo][n]=1;const u=ie.getCharCode("z"),d=ie.getCharCode("a");for(let A=d;A<=u;A++)y[xo][A]=A-d+2;y[gn][n]=1;const h=ie.getCharCode("9"),g=ie.getCharCode("0");for(let A=g;A<=h;A++)y[gn][A]=A-g+2;y[gn][s]=12,y[gn][r]=13;const x=["\0"," ","","","","","","","\x07","\b"," ",`
77
77
  `,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~",""];for(let A=0;A<x.length;A++)y[h1][ie.getCharCode(x[A])]=A;const E=["\0","\r","\0","\0","\0","\0","!","'","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}"];for(let A=0;A<E.length;A++)ie.getCharCode(E[A])>0&&(y[Ln][ie.getCharCode(E[A])]=A);return y}const ll=rg(T.createInt32Array(5,256));class as{constructor(n){this.text=n}encode(){const n=ie.getCharCode(" "),r=ie.getCharCode(`
78
- `);let s=d1.singletonList(Fn.INITIAL_STATE);for(let a=0;a<this.text.length;a++){let u,d=a+1<this.text.length?this.text[a+1]:0;switch(this.text[a]){case ie.getCharCode("\r"):u=d===r?2:0;break;case ie.getCharCode("."):u=d===n?3:0;break;case ie.getCharCode(","):u=d===n?4:0;break;case ie.getCharCode(":"):u=d===n?5:0;break;default:u=0}u>0?(s=as.updateStateListForPair(s,a,u),a++):s=this.updateStateListForChar(s,a)}return d1.min(s,(a,u)=>a.getBitCount()-u.getBitCount()).toBitArray(this.text)}updateStateListForChar(n,r){const s=[];for(let o of n)this.updateStateForChar(o,r,s);return as.simplifyStates(s)}updateStateForChar(n,r,s){let o=this.text[r]&255,a=ll[n.getMode()][o]>0,u=null;for(let d=0;d<=Ln;d++){let h=ll[d][o];if(h>0){if(u==null&&(u=n.endBinaryShift(r)),!a||d===n.getMode()||d===gn){const g=u.latchAndAppend(d,h);s.push(g)}if(!a&&g1[n.getMode()][d]>=0){const g=u.shiftAndAppend(d,h);s.push(g)}}}if(n.getBinaryShiftByteCount()>0||ll[n.getMode()][o]===0){let d=n.addBinaryShiftChar(r);s.push(d)}}static updateStateListForPair(n,r,s){const o=[];for(let a of n)this.updateStateForPair(a,r,s,o);return this.simplifyStates(o)}static updateStateForPair(n,r,s,o){let a=n.endBinaryShift(r);if(o.push(a.latchAndAppend(Ln,s)),n.getMode()!==Ln&&o.push(a.shiftAndAppend(Ln,s)),s===3||s===4){let u=a.latchAndAppend(gn,16-s).latchAndAppend(gn,1);o.push(u)}if(n.getBinaryShiftByteCount()>0){let u=n.addBinaryShiftChar(r).addBinaryShiftChar(r+1);o.push(u)}}static simplifyStates(n){let r=[];for(const s of n){let o=!0;for(const a of r){if(a.isBetterThanOrEqualTo(s)){o=!1;break}s.isBetterThanOrEqualTo(a)&&(r=r.filter(u=>u!==a))}o&&r.push(s)}return r}}class Ne{constructor(){}static encodeBytes(n){return Ne.encode(n,Ne.DEFAULT_EC_PERCENT,Ne.DEFAULT_AZTEC_LAYERS)}static encode(n,r,s){let o=new as(n).encode(),a=N.truncDivision(o.getSize()*r,100)+11,u=o.getSize()+a,d,h,g,x,E;if(s!==Ne.DEFAULT_AZTEC_LAYERS){if(d=s<0,h=Math.abs(s),h>(d?Ne.MAX_NB_BITS_COMPACT:Ne.MAX_NB_BITS))throw new v(ie.format("Illegal value %s for layers",s));g=Ne.totalBitsInLayer(h,d),x=Ne.WORD_SIZE[h];let Z=g-g%x;if(E=Ne.stuffBits(o,x),E.getSize()+a>Z)throw new v("Data to large for user specified layer");if(d&&E.getSize()>x*64)throw new v("Data to large for user specified layer")}else{x=0,E=null;for(let Z=0;;Z++){if(Z>Ne.MAX_NB_BITS)throw new v("Data too large for an Aztec code");if(d=Z<=3,h=d?Z+1:Z,g=Ne.totalBitsInLayer(h,d),u>g)continue;(E==null||x!==Ne.WORD_SIZE[h])&&(x=Ne.WORD_SIZE[h],E=Ne.stuffBits(o,x));let ve=g-g%x;if(!(d&&E.getSize()>x*64)&&E.getSize()+a<=ve)break}}let A=Ne.generateCheckWords(E,g,x),I=E.getSize()/x,b=Ne.generateModeMessage(d,h,I),D=(d?11:14)+h*4,L=new Int32Array(D),z;if(d){z=D;for(let Z=0;Z<L.length;Z++)L[Z]=Z}else{z=D+1+2*N.truncDivision(N.truncDivision(D,2)-1,15);let Z=N.truncDivision(D,2),ve=N.truncDivision(z,2);for(let me=0;me<Z;me++){let Yt=me+N.truncDivision(me,15);L[Z-me-1]=ve-Yt-1,L[Z+me]=ve+Yt+1}}let q=new _e(z);for(let Z=0,ve=0;Z<h;Z++){let me=(h-Z)*4+(d?9:12);for(let Yt=0;Yt<me;Yt++){let vn=Yt*2;for(let Zt=0;Zt<2;Zt++)A.get(ve+vn+Zt)&&q.set(L[Z*2+Zt],L[Z*2+Yt]),A.get(ve+me*2+vn+Zt)&&q.set(L[Z*2+Yt],L[D-1-Z*2-Zt]),A.get(ve+me*4+vn+Zt)&&q.set(L[D-1-Z*2-Zt],L[D-1-Z*2-Yt]),A.get(ve+me*6+vn+Zt)&&q.set(L[D-1-Z*2-Yt],L[Z*2+Zt])}ve+=me*8}if(Ne.drawModeMessage(q,d,z,b),d)Ne.drawBullsEye(q,N.truncDivision(z,2),5);else{Ne.drawBullsEye(q,N.truncDivision(z,2),7);for(let Z=0,ve=0;Z<N.truncDivision(D,2)-1;Z+=15,ve+=16)for(let me=N.truncDivision(z,2)&1;me<z;me+=2)q.set(N.truncDivision(z,2)-ve,me),q.set(N.truncDivision(z,2)+ve,me),q.set(me,N.truncDivision(z,2)-ve),q.set(me,N.truncDivision(z,2)+ve)}let $=new f1;return $.setCompact(d),$.setSize(z),$.setLayers(h),$.setCodeWords(I),$.setMatrix(q),$}static drawBullsEye(n,r,s){for(let o=0;o<s;o+=2)for(let a=r-o;a<=r+o;a++)n.set(a,r-o),n.set(a,r+o),n.set(r-o,a),n.set(r+o,a);n.set(r-s,r-s),n.set(r-s+1,r-s),n.set(r-s,r-s+1),n.set(r+s,r-s),n.set(r+s,r-s+1),n.set(r+s,r+s-1)}static generateModeMessage(n,r,s){let o=new G;return n?(o.appendBits(r-1,2),o.appendBits(s-1,6),o=Ne.generateCheckWords(o,28,4)):(o.appendBits(r-1,5),o.appendBits(s-1,11),o=Ne.generateCheckWords(o,40,4)),o}static drawModeMessage(n,r,s,o){let a=N.truncDivision(s,2);if(r)for(let u=0;u<7;u++){let d=a-3+u;o.get(u)&&n.set(d,a-5),o.get(u+7)&&n.set(a+5,d),o.get(20-u)&&n.set(d,a+5),o.get(27-u)&&n.set(a-5,d)}else for(let u=0;u<10;u++){let d=a-5+u+N.truncDivision(u,5);o.get(u)&&n.set(d,a-7),o.get(u+10)&&n.set(a+7,d),o.get(29-u)&&n.set(d,a+7),o.get(39-u)&&n.set(a-7,d)}}static generateCheckWords(n,r,s){let o=n.getSize()/s,a=new rl(Ne.getGF(s)),u=N.truncDivision(r,s),d=Ne.bitsToWords(n,s,u);a.encode(d,u-o);let h=r%s,g=new G;g.appendBits(0,h);for(const x of Array.from(d))g.appendBits(x,s);return g}static bitsToWords(n,r,s){let o=new Int32Array(s),a,u;for(a=0,u=n.getSize()/r;a<u;a++){let d=0;for(let h=0;h<r;h++)d|=n.get(a*r+h)?1<<r-h-1:0;o[a]=d}return o}static getGF(n){switch(n){case 4:return be.AZTEC_PARAM;case 6:return be.AZTEC_DATA_6;case 8:return be.AZTEC_DATA_8;case 10:return be.AZTEC_DATA_10;case 12:return be.AZTEC_DATA_12;default:throw new v("Unsupported word size "+n)}}static stuffBits(n,r){let s=new G,o=n.getSize(),a=(1<<r)-2;for(let u=0;u<o;u+=r){let d=0;for(let h=0;h<r;h++)(u+h>=o||n.get(u+h))&&(d|=1<<r-1-h);(d&a)===a?(s.appendBits(d&a,r),u--):d&a?s.appendBits(d,r):(s.appendBits(d|1,r),u--)}return s}static totalBitsInLayer(n,r){return((r?88:112)+16*n)*n}}Ne.DEFAULT_EC_PERCENT=33,Ne.DEFAULT_AZTEC_LAYERS=0,Ne.MAX_NB_BITS=32,Ne.MAX_NB_BITS_COMPACT=4,Ne.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]);class mo{encode(n,r,s,o){return this.encodeWithHints(n,r,s,o,null)}encodeWithHints(n,r,s,o,a){let u=sl.ISO_8859_1,d=Ne.DEFAULT_EC_PERCENT,h=Ne.DEFAULT_AZTEC_LAYERS;return a!=null&&(a.has(ht.CHARACTER_SET)&&(u=c1.forName(a.get(ht.CHARACTER_SET).toString())),a.has(ht.ERROR_CORRECTION)&&(d=N.parseInt(a.get(ht.ERROR_CORRECTION).toString())),a.has(ht.AZTEC_LAYERS)&&(h=N.parseInt(a.get(ht.AZTEC_LAYERS).toString()))),mo.encodeLayers(n,r,s,o,u,d,h)}static encodeLayers(n,r,s,o,a,u,d){if(r!==ae.AZTEC)throw new v("Can only encode AZTEC, but got "+r);let h=Ne.encode(ie.getBytes(n,a),u,d);return mo.renderResult(h,s,o)}static renderResult(n,r,s){let o=n.getMatrix();if(o==null)throw new Dn;let a=o.getWidth(),u=o.getHeight(),d=Math.max(r,a),h=Math.max(s,u),g=Math.min(d/a,h/u),x=(d-a*g)/2,E=(h-u*g)/2,A=new _e(d,h);for(let I=0,b=E;I<u;I++,b+=g)for(let D=0,L=x;D<a;D++,L+=g)o.get(D,I)&&A.setRegion(L,b,g,g);return A}}i.AbstractExpandedDecoder=Ya,i.ArgumentException=_,i.ArithmeticException=io,i.AztecCode=f1,i.AztecCodeReader=ao,i.AztecCodeWriter=mo,i.AztecDecoder=Ue,i.AztecDetector=qc,i.AztecDetectorResult=Kc,i.AztecEncoder=Ne,i.AztecHighLevelEncoder=as,i.AztecPoint=Lt,i.BarcodeFormat=ae,i.Binarizer=P,i.BinaryBitmap=R,i.BitArray=G,i.BitMatrix=_e,i.BitSource=qa,i.BrowserAztecCodeReader=Rh,i.BrowserBarcodeReader=kh,i.BrowserCodeReader=cn,i.BrowserDatamatrixCodeReader=Bh,i.BrowserMultiFormatReader=Yh,i.BrowserPDF417Reader=Zh,i.BrowserQRCodeReader=Kh,i.BrowserQRCodeSvgWriter=Wr,i.CharacterSetECI=V,i.ChecksumException=M,i.Code128Reader=J,i.Code39Reader=ft,i.DataMatrixDecodedBitStreamParser=ar,i.DataMatrixReader=lr,i.DecodeHintType=U,i.DecoderResult=Qi,i.DefaultGridSampler=Qc,i.DetectorResult=oo,i.EAN13Reader=Pr,i.EncodeHintType=ht,i.Exception=m,i.FormatException=k,i.GenericGF=be,i.GenericGFPoly=Ht,i.GlobalHistogramBinarizer=tt,i.GridSampler=Ha,i.GridSamplerInstance=sr,i.HTMLCanvasElementLuminanceSource=pe,i.HybridBinarizer=xe,i.ITFReader=Be,i.IllegalArgumentException=v,i.IllegalStateException=Dn,i.InvertedLuminanceSource=de,i.LuminanceSource=ee,i.MathUtils=Te,i.MultiFormatOneDReader=ai,i.MultiFormatReader=u1,i.MultiFormatWriter=qh,i.NotFoundException=j,i.OneDReader=ut,i.PDF417DecodedBitStreamParser=W,i.PDF417DecoderErrorCorrection=r1,i.PDF417Reader=It,i.PDF417ResultMetadata=s1,i.PerspectiveTransform=Cn,i.PlanarYUVLuminanceSource=Bn,i.QRCodeByteMatrix=po,i.QRCodeDataMask=dn,i.QRCodeDecodedBitStreamParser=Qe,i.QRCodeDecoderErrorCorrectionLevel=We,i.QRCodeDecoderFormatInformation=Ot,i.QRCodeEncoder=Ve,i.QRCodeEncoderQRCode=Ur,i.QRCodeMaskUtil=it,i.QRCodeMatrixUtil=fe,i.QRCodeMode=ce,i.QRCodeReader=ur,i.QRCodeVersion=le,i.QRCodeWriter=ui,i.RGBLuminanceSource=il,i.RSS14Reader=rt,i.RSSExpandedReader=Y,i.ReaderException=go,i.ReedSolomonDecoder=$i,i.ReedSolomonEncoder=rl,i.ReedSolomonException=ri,i.Result=Ke,i.ResultMetadataType=mt,i.ResultPoint=oe,i.StringUtils=ie,i.UnsupportedOperationException=se,i.VideoInputDevice=Ge,i.WhiteRectangleDetector=Gn,i.WriterException=Le,i.ZXingArrays=T,i.ZXingCharset=c1,i.ZXingInteger=N,i.ZXingStandardCharsets=sl,i.ZXingStringBuilder=ge,i.ZXingStringEncoding=Ee,i.ZXingSystem=B,i.createAbstractExpandedDecoder=t1,Object.defineProperty(i,"__esModule",{value:!0})})})(Lu,Lu.exports);var qe=Lu.exports;const Am=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var L0=function(){function e(t,i,l){if(this.formatMap=new Map([[te.QR_CODE,qe.BarcodeFormat.QR_CODE],[te.AZTEC,qe.BarcodeFormat.AZTEC],[te.CODABAR,qe.BarcodeFormat.CODABAR],[te.CODE_39,qe.BarcodeFormat.CODE_39],[te.CODE_93,qe.BarcodeFormat.CODE_93],[te.CODE_128,qe.BarcodeFormat.CODE_128],[te.DATA_MATRIX,qe.BarcodeFormat.DATA_MATRIX],[te.MAXICODE,qe.BarcodeFormat.MAXICODE],[te.ITF,qe.BarcodeFormat.ITF],[te.EAN_13,qe.BarcodeFormat.EAN_13],[te.EAN_8,qe.BarcodeFormat.EAN_8],[te.PDF_417,qe.BarcodeFormat.PDF_417],[te.RSS_14,qe.BarcodeFormat.RSS_14],[te.RSS_EXPANDED,qe.BarcodeFormat.RSS_EXPANDED],[te.UPC_A,qe.BarcodeFormat.UPC_A],[te.UPC_E,qe.BarcodeFormat.UPC_E],[te.UPC_EAN_EXTENSION,qe.BarcodeFormat.UPC_EAN_EXTENSION]]),this.reverseFormatMap=this.createReverseFormatMap(),!Am)throw"Use html5qrcode.min.js without edit, ZXing not found.";this.verbose=i,this.logger=l;var c=this.createZXingFormats(t),f=new Map;f.set(qe.DecodeHintType.POSSIBLE_FORMATS,c),f.set(qe.DecodeHintType.TRY_HARDER,!1),this.hints=f}return e.prototype.decodeAsync=function(t){var i=this;return new Promise(function(l,c){try{l(i.decode(t))}catch(f){c(f)}})},e.prototype.decode=function(t){var i=new qe.MultiFormatReader(this.verbose,this.hints),l=new qe.HTMLCanvasElementLuminanceSource(t),c=new qe.BinaryBitmap(new qe.HybridBinarizer(l)),f=i.decode(c);return{text:f.text,format:vh.create(this.toHtml5QrcodeSupportedFormats(f.format)),debugData:this.createDebugData()}},e.prototype.createReverseFormatMap=function(){var t=new Map;return this.formatMap.forEach(function(i,l,c){t.set(i,l)}),t},e.prototype.toHtml5QrcodeSupportedFormats=function(t){if(!this.reverseFormatMap.has(t))throw"reverseFormatMap doesn't have ".concat(t);return this.reverseFormatMap.get(t)},e.prototype.createZXingFormats=function(t){for(var i=[],l=0,c=t;l<c.length;l++){var f=c[l];this.formatMap.has(f)?i.push(this.formatMap.get(f)):this.logger.logError("".concat(f," is not supported by")+"ZXingHtml5QrcodeShim")}return i},e.prototype.createDebugData=function(){return{decoderName:"zxing-js"}},e}(),vm=function(e,t,i,l){function c(f){return f instanceof i?f:new i(function(p){p(f)})}return new(i||(i=Promise))(function(f,p){function w(_){try{m(l.next(_))}catch(v){p(v)}}function C(_){try{m(l.throw(_))}catch(v){p(v)}}function m(_){_.done?f(_.value):c(_.value).then(w,C)}m((l=l.apply(e,t||[])).next())})},Sm=function(e,t){var i={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,c,f,p;return p={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function w(m){return function(_){return C([m,_])}}function C(m){if(l)throw new TypeError("Generator is already executing.");for(;p&&(p=0,m[0]&&(i=0)),i;)try{if(l=1,c&&(f=m[0]&2?c.return:m[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,m[1])).done)return f;switch(c=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return i.label++,{value:m[1],done:!1};case 5:i.label++,c=m[1],m=[0];continue;case 7:m=i.ops.pop(),i.trys.pop();continue;default:if(f=i.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){i=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){i.label=m[1];break}if(m[0]===6&&i.label<f[1]){i.label=f[1],f=m;break}if(f&&i.label<f[2]){i.label=f[2],i.ops.push(m);break}f[2]&&i.ops.pop(),i.trys.pop();continue}m=t.call(e,i)}catch(_){m=[6,_],c=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},F0=function(){function e(t,i,l){if(this.formatMap=new Map([[te.QR_CODE,"qr_code"],[te.AZTEC,"aztec"],[te.CODABAR,"codabar"],[te.CODE_39,"code_39"],[te.CODE_93,"code_93"],[te.CODE_128,"code_128"],[te.DATA_MATRIX,"data_matrix"],[te.ITF,"itf"],[te.EAN_13,"ean_13"],[te.EAN_8,"ean_8"],[te.PDF_417,"pdf417"],[te.UPC_A,"upc_a"],[te.UPC_E,"upc_e"]]),this.reverseFormatMap=this.createReverseFormatMap(),!e.isSupported())throw"Use html5qrcode.min.js without edit, Use BarcodeDetectorDelegate only if it isSupported();";this.verbose=i,this.logger=l;var c=this.createBarcodeDetectorFormats(t);if(this.detector=new BarcodeDetector(c),!this.detector)throw"BarcodeDetector detector not supported"}return e.isSupported=function(){if(!("BarcodeDetector"in window))return!1;var t=new BarcodeDetector({formats:["qr_code"]});return typeof t<"u"},e.prototype.decodeAsync=function(t){return vm(this,void 0,void 0,function(){var i,l;return Sm(this,function(c){switch(c.label){case 0:return[4,this.detector.detect(t)];case 1:if(i=c.sent(),!i||i.length===0)throw"No barcode or QR code detected.";return l=this.selectLargestBarcode(i),[2,{text:l.rawValue,format:vh.create(this.toHtml5QrcodeSupportedFormats(l.format)),debugData:this.createDebugData()}]}})})},e.prototype.selectLargestBarcode=function(t){for(var i=null,l=0,c=0,f=t;c<f.length;c++){var p=f[c],w=p.boundingBox.width*p.boundingBox.height;w>l&&(l=w,i=p)}if(!i)throw"No largest barcode found";return i},e.prototype.createBarcodeDetectorFormats=function(t){for(var i=[],l=0,c=t;l<c.length;l++){var f=c[l];this.formatMap.has(f)?i.push(this.formatMap.get(f)):this.logger.warn("".concat(f," is not supported by")+"BarcodeDetectorDelegate")}return{formats:i}},e.prototype.toHtml5QrcodeSupportedFormats=function(t){if(!this.reverseFormatMap.has(t))throw"reverseFormatMap doesn't have ".concat(t);return this.reverseFormatMap.get(t)},e.prototype.createReverseFormatMap=function(){var t=new Map;return this.formatMap.forEach(function(i,l,c){t.set(i,l)}),t},e.prototype.createDebugData=function(){return{decoderName:"BarcodeDetector"}},e}(),U0=function(e,t,i,l){function c(f){return f instanceof i?f:new i(function(p){p(f)})}return new(i||(i=Promise))(function(f,p){function w(_){try{m(l.next(_))}catch(v){p(v)}}function C(_){try{m(l.throw(_))}catch(v){p(v)}}function m(_){_.done?f(_.value):c(_.value).then(w,C)}m((l=l.apply(e,t||[])).next())})},W0=function(e,t){var i={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,c,f,p;return p={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function w(m){return function(_){return C([m,_])}}function C(m){if(l)throw new TypeError("Generator is already executing.");for(;p&&(p=0,m[0]&&(i=0)),i;)try{if(l=1,c&&(f=m[0]&2?c.return:m[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,m[1])).done)return f;switch(c=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return i.label++,{value:m[1],done:!1};case 5:i.label++,c=m[1],m=[0];continue;case 7:m=i.ops.pop(),i.trys.pop();continue;default:if(f=i.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){i=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){i.label=m[1];break}if(m[0]===6&&i.label<f[1]){i.label=f[1],f=m;break}if(f&&i.label<f[2]){i.label=f[2],i.ops.push(m);break}f[2]&&i.ops.pop(),i.trys.pop();continue}m=t.call(e,i)}catch(_){m=[6,_],c=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},Im=function(){function e(t,i,l,c){this.EXECUTIONS_TO_REPORT_PERFORMANCE=100,this.executions=0,this.executionResults=[],this.wasPrimaryDecoderUsedInLastDecode=!1,this.verbose=l,i&&F0.isSupported()?(this.primaryDecoder=new F0(t,l,c),this.secondaryDecoder=new L0(t,l,c)):this.primaryDecoder=new L0(t,l,c)}return e.prototype.decodeAsync=function(t){return U0(this,void 0,void 0,function(){var i;return W0(this,function(l){switch(l.label){case 0:i=performance.now(),l.label=1;case 1:return l.trys.push([1,,3,4]),[4,this.getDecoder().decodeAsync(t)];case 2:return[2,l.sent()];case 3:return this.possiblyLogPerformance(i),[7];case 4:return[2]}})})},e.prototype.decodeRobustlyAsync=function(t){return U0(this,void 0,void 0,function(){var i,l;return W0(this,function(c){switch(c.label){case 0:i=performance.now(),c.label=1;case 1:return c.trys.push([1,3,4,5]),[4,this.primaryDecoder.decodeAsync(t)];case 2:return[2,c.sent()];case 3:if(l=c.sent(),this.secondaryDecoder)return[2,this.secondaryDecoder.decodeAsync(t)];throw l;case 4:return this.possiblyLogPerformance(i),[7];case 5:return[2]}})})},e.prototype.getDecoder=function(){return this.secondaryDecoder?this.wasPrimaryDecoderUsedInLastDecode===!1?(this.wasPrimaryDecoderUsedInLastDecode=!0,this.primaryDecoder):(this.wasPrimaryDecoderUsedInLastDecode=!1,this.secondaryDecoder):this.primaryDecoder},e.prototype.possiblyLogPerformance=function(t){if(this.verbose){var i=performance.now()-t;this.executionResults.push(i),this.executions++,this.possiblyFlushPerformanceReport()}},e.prototype.possiblyFlushPerformanceReport=function(){if(!(this.executions<this.EXECUTIONS_TO_REPORT_PERFORMANCE)){for(var t=0,i=0,l=this.executionResults;i<l.length;i++){var c=l[i];t+=c}var f=t/this.executionResults.length;console.log("".concat(f," ms for ").concat(this.executionResults.length," last runs.")),this.executions=0,this.executionResults=[]}},e}(),Xc=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,c){l.__proto__=c}||function(l,c){for(var f in c)Object.prototype.hasOwnProperty.call(c,f)&&(l[f]=c[f])},e(t,i)};return function(t,i){if(typeof i!="function"&&i!==null)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");e(t,i);function l(){this.constructor=t}t.prototype=i===null?Object.create(i):(l.prototype=i.prototype,new l)}}(),Aa=function(e,t,i,l){function c(f){return f instanceof i?f:new i(function(p){p(f)})}return new(i||(i=Promise))(function(f,p){function w(_){try{m(l.next(_))}catch(v){p(v)}}function C(_){try{m(l.throw(_))}catch(v){p(v)}}function m(_){_.done?f(_.value):c(_.value).then(w,C)}m((l=l.apply(e,t||[])).next())})},va=function(e,t){var i={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,c,f,p;return p={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function w(m){return function(_){return C([m,_])}}function C(m){if(l)throw new TypeError("Generator is already executing.");for(;p&&(p=0,m[0]&&(i=0)),i;)try{if(l=1,c&&(f=m[0]&2?c.return:m[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,m[1])).done)return f;switch(c=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return i.label++,{value:m[1],done:!1};case 5:i.label++,c=m[1],m=[0];continue;case 7:m=i.ops.pop(),i.trys.pop();continue;default:if(f=i.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){i=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){i.label=m[1];break}if(m[0]===6&&i.label<f[1]){i.label=f[1],f=m;break}if(f&&i.label<f[2]){i.label=f[2],i.ops.push(m);break}f[2]&&i.ops.pop(),i.trys.pop();continue}m=t.call(e,i)}catch(_){m=[6,_],c=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},Ih=function(){function e(t,i){this.name=t,this.track=i}return e.prototype.isSupported=function(){return this.track.getCapabilities?this.name in this.track.getCapabilities():!1},e.prototype.apply=function(t){var i={};i[this.name]=t;var l={advanced:[i]};return this.track.applyConstraints(l)},e.prototype.value=function(){var t=this.track.getSettings();if(this.name in t){var i=t[this.name];return i}return null},e}(),_m=function(e){Xc(t,e);function t(i,l){return e.call(this,i,l)||this}return t.prototype.min=function(){return this.getCapabilities().min},t.prototype.max=function(){return this.getCapabilities().max},t.prototype.step=function(){return this.getCapabilities().step},t.prototype.apply=function(i){var l={};l[this.name]=i;var c={advanced:[l]};return this.track.applyConstraints(c)},t.prototype.getCapabilities=function(){this.failIfNotSupported();var i=this.track.getCapabilities(),l=i[this.name];return{min:l.min,max:l.max,step:l.step}},t.prototype.failIfNotSupported=function(){if(!this.isSupported())throw new Error("".concat(this.name," capability not supported"))},t}(Ih),Tm=function(e){Xc(t,e);function t(i){return e.call(this,"zoom",i)||this}return t}(_m),Nm=function(e){Xc(t,e);function t(i){return e.call(this,"torch",i)||this}return t}(Ih),Rm=function(){function e(t){this.track=t}return e.prototype.zoomFeature=function(){return new Tm(this.track)},e.prototype.torchFeature=function(){return new Nm(this.track)},e}(),bm=function(){function e(t,i,l){this.isClosed=!1,this.parentElement=t,this.mediaStream=i,this.callbacks=l,this.surface=this.createVideoElement(this.parentElement.clientWidth),t.append(this.surface)}return e.prototype.createVideoElement=function(t){var i=document.createElement("video");return i.style.width="".concat(t,"px"),i.style.display="block",i.muted=!0,i.setAttribute("muted","true"),i.playsInline=!0,i},e.prototype.setupSurface=function(){var t=this;this.surface.onabort=function(){throw"RenderedCameraImpl video surface onabort() called"},this.surface.onerror=function(){throw"RenderedCameraImpl video surface onerror() called"};var i=function(){var l=t.surface.clientWidth,c=t.surface.clientHeight;t.callbacks.onRenderSurfaceReady(l,c),t.surface.removeEventListener("playing",i)};this.surface.addEventListener("playing",i),this.surface.srcObject=this.mediaStream,this.surface.play()},e.create=function(t,i,l,c){return Aa(this,void 0,void 0,function(){var f,p;return va(this,function(w){switch(w.label){case 0:return f=new e(t,i,c),l.aspectRatio?(p={aspectRatio:l.aspectRatio},[4,f.getFirstTrackOrFail().applyConstraints(p)]):[3,2];case 1:w.sent(),w.label=2;case 2:return f.setupSurface(),[2,f]}})})},e.prototype.failIfClosed=function(){if(this.isClosed)throw"The RenderedCamera has already been closed."},e.prototype.getFirstTrackOrFail=function(){if(this.failIfClosed(),this.mediaStream.getVideoTracks().length===0)throw"No video tracks found";return this.mediaStream.getVideoTracks()[0]},e.prototype.pause=function(){this.failIfClosed(),this.surface.pause()},e.prototype.resume=function(t){this.failIfClosed();var i=this,l=function(){setTimeout(t,200),i.surface.removeEventListener("playing",l)};this.surface.addEventListener("playing",l),this.surface.play()},e.prototype.isPaused=function(){return this.failIfClosed(),this.surface.paused},e.prototype.getSurface=function(){return this.failIfClosed(),this.surface},e.prototype.getRunningTrackCapabilities=function(){return this.getFirstTrackOrFail().getCapabilities()},e.prototype.getRunningTrackSettings=function(){return this.getFirstTrackOrFail().getSettings()},e.prototype.applyVideoConstraints=function(t){return Aa(this,void 0,void 0,function(){return va(this,function(i){if("aspectRatio"in t)throw"Changing 'aspectRatio' in run-time is not yet supported.";return[2,this.getFirstTrackOrFail().applyConstraints(t)]})})},e.prototype.close=function(){if(this.isClosed)return Promise.resolve();var t=this;return new Promise(function(i,l){var c=t.mediaStream.getVideoTracks(),f=c.length,p=0;t.mediaStream.getVideoTracks().forEach(function(w){t.mediaStream.removeTrack(w),w.stop(),++p,p>=f&&(t.isClosed=!0,t.parentElement.removeChild(t.surface),i())})})},e.prototype.getCapabilities=function(){return new Rm(this.getFirstTrackOrFail())},e}(),Om=function(){function e(t){this.mediaStream=t}return e.prototype.render=function(t,i,l){return Aa(this,void 0,void 0,function(){return va(this,function(c){return[2,bm.create(t,this.mediaStream,i,l)]})})},e.create=function(t){return Aa(this,void 0,void 0,function(){var i,l;return va(this,function(c){switch(c.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return i={audio:!1,video:t},[4,navigator.mediaDevices.getUserMedia(i)];case 1:return l=c.sent(),[2,new e(l)]}})})},e}(),z0=function(e,t,i,l){function c(f){return f instanceof i?f:new i(function(p){p(f)})}return new(i||(i=Promise))(function(f,p){function w(_){try{m(l.next(_))}catch(v){p(v)}}function C(_){try{m(l.throw(_))}catch(v){p(v)}}function m(_){_.done?f(_.value):c(_.value).then(w,C)}m((l=l.apply(e,t||[])).next())})},V0=function(e,t){var i={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,c,f,p;return p={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function w(m){return function(_){return C([m,_])}}function C(m){if(l)throw new TypeError("Generator is already executing.");for(;p&&(p=0,m[0]&&(i=0)),i;)try{if(l=1,c&&(f=m[0]&2?c.return:m[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,m[1])).done)return f;switch(c=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return i.label++,{value:m[1],done:!1};case 5:i.label++,c=m[1],m=[0];continue;case 7:m=i.ops.pop(),i.trys.pop();continue;default:if(f=i.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){i=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){i.label=m[1];break}if(m[0]===6&&i.label<f[1]){i.label=f[1],f=m;break}if(f&&i.label<f[2]){i.label=f[2],i.ops.push(m);break}f[2]&&i.ops.pop(),i.trys.pop();continue}m=t.call(e,i)}catch(_){m=[6,_],c=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},Dm=function(){function e(){}return e.failIfNotSupported=function(){return z0(this,void 0,void 0,function(){return V0(this,function(t){if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return[2,new e]})})},e.prototype.create=function(t){return z0(this,void 0,void 0,function(){return V0(this,function(i){return[2,Om.create(t)]})})},e}(),Mm=function(e,t,i,l){function c(f){return f instanceof i?f:new i(function(p){p(f)})}return new(i||(i=Promise))(function(f,p){function w(_){try{m(l.next(_))}catch(v){p(v)}}function C(_){try{m(l.throw(_))}catch(v){p(v)}}function m(_){_.done?f(_.value):c(_.value).then(w,C)}m((l=l.apply(e,t||[])).next())})},km=function(e,t){var i={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,c,f,p;return p={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function w(m){return function(_){return C([m,_])}}function C(m){if(l)throw new TypeError("Generator is already executing.");for(;p&&(p=0,m[0]&&(i=0)),i;)try{if(l=1,c&&(f=m[0]&2?c.return:m[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,m[1])).done)return f;switch(c=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return i.label++,{value:m[1],done:!1};case 5:i.label++,c=m[1],m=[0];continue;case 7:m=i.ops.pop(),i.trys.pop();continue;default:if(f=i.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){i=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){i.label=m[1];break}if(m[0]===6&&i.label<f[1]){i.label=f[1],f=m;break}if(f&&i.label<f[2]){i.label=f[2],i.ops.push(m);break}f[2]&&i.ops.pop(),i.trys.pop();continue}m=t.call(e,i)}catch(_){m=[6,_],c=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},Pm=function(){function e(){}return e.retrieve=function(){if(navigator.mediaDevices)return e.getCamerasFromMediaDevices();var t=MediaStreamTrack;return MediaStreamTrack&&t.getSources?e.getCamerasFromMediaStreamTrack():e.rejectWithError()},e.rejectWithError=function(){var t=Ri.unableToQuerySupportedDevices();return e.isHttpsOrLocalhost()||(t=Ri.insecureContextCameraQueryError()),Promise.reject(t)},e.isHttpsOrLocalhost=function(){if(location.protocol==="https:")return!0;var t=location.host.split(":")[0];return t==="127.0.0.1"||t==="localhost"},e.getCamerasFromMediaDevices=function(){return Mm(this,void 0,void 0,function(){var t,i,l,c,f,p,w;return km(this,function(C){switch(C.label){case 0:return t=function(m){for(var _=m.getVideoTracks(),v=0,R=_;v<R.length;v++){var M=R[v];M.enabled=!1,M.stop(),m.removeTrack(M)}},[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 1:return i=C.sent(),[4,navigator.mediaDevices.enumerateDevices()];case 2:for(l=C.sent(),c=[],f=0,p=l;f<p.length;f++)w=p[f],w.kind==="videoinput"&&c.push({id:w.deviceId,label:w.label});return t(i),[2,c]}})})},e.getCamerasFromMediaStreamTrack=function(){return new Promise(function(t,i){var l=function(f){for(var p=[],w=0,C=f;w<C.length;w++){var m=C[w];m.kind==="video"&&p.push({id:m.id,label:m.label})}t(p)},c=MediaStreamTrack;c.getSources(l)})},e}(),st;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.NOT_STARTED=1]="NOT_STARTED",e[e.SCANNING=2]="SCANNING",e[e.PAUSED=3]="PAUSED"})(st||(st={}));var Bm=function(){function e(){this.state=st.NOT_STARTED,this.onGoingTransactionNewState=st.UNKNOWN}return e.prototype.directTransition=function(t){this.failIfTransitionOngoing(),this.validateTransition(t),this.state=t},e.prototype.startTransition=function(t){return this.failIfTransitionOngoing(),this.validateTransition(t),this.onGoingTransactionNewState=t,this},e.prototype.execute=function(){if(this.onGoingTransactionNewState===st.UNKNOWN)throw"Transaction is already cancelled, cannot execute().";var t=this.onGoingTransactionNewState;this.onGoingTransactionNewState=st.UNKNOWN,this.directTransition(t)},e.prototype.cancel=function(){if(this.onGoingTransactionNewState===st.UNKNOWN)throw"Transaction is already cancelled, cannot cancel().";this.onGoingTransactionNewState=st.UNKNOWN},e.prototype.getState=function(){return this.state},e.prototype.failIfTransitionOngoing=function(){if(this.onGoingTransactionNewState!==st.UNKNOWN)throw"Cannot transition to a new state, already under transition"},e.prototype.validateTransition=function(t){switch(this.state){case st.UNKNOWN:throw"Transition from unknown is not allowed";case st.NOT_STARTED:this.failIfNewStateIs(t,[st.PAUSED]);break;case st.SCANNING:break;case st.PAUSED:break}},e.prototype.failIfNewStateIs=function(t,i){for(var l=0,c=i;l<c.length;l++){var f=c[l];if(t===f)throw"Cannot transition from ".concat(this.state," to ").concat(t)}},e}(),Lm=function(){function e(t){this.stateManager=t}return e.prototype.startTransition=function(t){return this.stateManager.startTransition(t)},e.prototype.directTransition=function(t){this.stateManager.directTransition(t)},e.prototype.getState=function(){return this.stateManager.getState()},e.prototype.canScanFile=function(){return this.stateManager.getState()===st.NOT_STARTED},e.prototype.isScanning=function(){return this.stateManager.getState()!==st.NOT_STARTED},e.prototype.isStrictlyScanning=function(){return this.stateManager.getState()===st.SCANNING},e.prototype.isPaused=function(){return this.stateManager.getState()===st.PAUSED},e}(),Fm=function(){function e(){}return e.create=function(){return new Lm(new Bm)},e}(),Um=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,c){l.__proto__=c}||function(l,c){for(var f in c)Object.prototype.hasOwnProperty.call(c,f)&&(l[f]=c[f])},e(t,i)};return function(t,i){if(typeof i!="function"&&i!==null)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");e(t,i);function l(){this.constructor=t}t.prototype=i===null?Object.create(i):(l.prototype=i.prototype,new l)}}(),nn=function(e){Um(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.DEFAULT_WIDTH=300,t.DEFAULT_WIDTH_OFFSET=2,t.FILE_SCAN_MIN_HEIGHT=300,t.FILE_SCAN_HIDDEN_CANVAS_PADDING=100,t.MIN_QR_BOX_SIZE=50,t.SHADED_LEFT=1,t.SHADED_RIGHT=2,t.SHADED_TOP=3,t.SHADED_BOTTOM=4,t.SHADED_REGION_ELEMENT_ID="qr-shaded-region",t.VERBOSE=!1,t.BORDER_SHADER_DEFAULT_COLOR="#ffffff",t.BORDER_SHADER_MATCH_COLOR="rgb(90, 193, 56)",t}(ym),Wm=function(){function e(t,i){this.logger=i,this.fps=nn.SCAN_DEFAULT_FPS,t?(t.fps&&(this.fps=t.fps),this.disableFlip=t.disableFlip===!0,this.qrbox=t.qrbox,this.aspectRatio=t.aspectRatio,this.videoConstraints=t.videoConstraints):this.disableFlip=nn.DEFAULT_DISABLE_FLIP}return e.prototype.isMediaStreamConstraintsValid=function(){return this.videoConstraints?Sh.isMediaStreamConstraintsValid(this.videoConstraints,this.logger):(this.logger.logError("Empty videoConstraints",!0),!1)},e.prototype.isShadedBoxEnabled=function(){return!Xn(this.qrbox)},e.create=function(t,i){return new e(t,i)},e}(),aw=function(){function e(t,i){if(this.element=null,this.canvasElement=null,this.scannerPausedUiElement=null,this.hasBorderShaders=null,this.borderShaders=null,this.qrMatch=null,this.renderedCamera=null,this.qrRegion=null,this.context=null,this.lastScanImageFile=null,this.isScanning=!1,!document.getElementById(t))throw"HTML Element with id=".concat(t," not found");this.elementId=t,this.verbose=!1;var l;typeof i=="boolean"?this.verbose=i===!0:i&&(l=i,this.verbose=l.verbose===!0,l.experimentalFeatures),this.logger=new Cm(this.verbose),this.qrcode=new Im(this.getSupportedFormats(i),this.getUseBarCodeDetectorIfSupported(l),this.verbose,this.logger),this.foreverScanTimeout,this.shouldScan=!0,this.stateManagerProxy=Fm.create()}return e.prototype.start=function(t,i,l,c){var f=this;if(!t)throw"cameraIdOrConfig is required";if(!l||typeof l!="function")throw"qrCodeSuccessCallback is required and should be a function.";var p;c?p=c:p=this.verbose?this.logger.log:function(){};var w=Wm.create(i,this.logger);this.clearElement();var C=!1;w.videoConstraints&&(w.isMediaStreamConstraintsValid()?C=!0:this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, it will be ignored.'",!0));var m=C,_=document.getElementById(this.elementId);_.clientWidth?_.clientWidth:nn.DEFAULT_WIDTH,_.style.position="relative",this.shouldScan=!0,this.element=_;var v=this,R=this.stateManagerProxy.startTransition(st.SCANNING);return new Promise(function(M,P){var B=m?w.videoConstraints:v.createVideoConstraints(t);if(!B){R.cancel(),P("videoConstraints should be defined");return}var K={};(!m||w.aspectRatio)&&(K.aspectRatio=w.aspectRatio);var O={onRenderSurfaceReady:function(T,N){v.setupUi(T,N,w),v.isScanning=!0,v.foreverScan(w,l,p)}};Dm.failIfNotSupported().then(function(T){T.create(B).then(function(N){return N.render(f.element,K,O).then(function(G){v.renderedCamera=G,R.execute(),M(null)}).catch(function(G){R.cancel(),P(G)})}).catch(function(N){R.cancel(),P(Ri.errorGettingUserMedia(N))})}).catch(function(T){R.cancel(),P(Ri.cameraStreamingNotSupported())})})},e.prototype.pause=function(t){if(!this.stateManagerProxy.isStrictlyScanning())throw"Cannot pause, scanner is not scanning.";this.stateManagerProxy.directTransition(st.PAUSED),this.showPausedState(),(Xn(t)||t!==!0)&&(t=!1),t&&this.renderedCamera&&this.renderedCamera.pause()},e.prototype.resume=function(){if(!this.stateManagerProxy.isPaused())throw"Cannot result, scanner is not paused.";if(!this.renderedCamera)throw"renderedCamera doesn't exist while trying resume()";var t=this,i=function(){t.stateManagerProxy.directTransition(st.SCANNING),t.hidePausedState()};if(!this.renderedCamera.isPaused()){i();return}this.renderedCamera.resume(function(){i()})},e.prototype.getState=function(){return this.stateManagerProxy.getState()},e.prototype.stop=function(){var t=this;if(!this.stateManagerProxy.isScanning())throw"Cannot stop, scanner is not running or paused.";var i=this.stateManagerProxy.startTransition(st.NOT_STARTED);this.shouldScan=!1,this.foreverScanTimeout&&clearTimeout(this.foreverScanTimeout);var l=function(){if(t.element){var f=document.getElementById(nn.SHADED_REGION_ELEMENT_ID);f&&t.element.removeChild(f)}},c=this;return this.renderedCamera.close().then(function(){return c.renderedCamera=null,c.element&&(c.element.removeChild(c.canvasElement),c.canvasElement=null),l(),c.qrRegion&&(c.qrRegion=null),c.context&&(c.context=null),i.execute(),c.hidePausedState(),c.isScanning=!1,Promise.resolve()})},e.prototype.scanFile=function(t,i){return this.scanFileV2(t,i).then(function(l){return l.decodedText})},e.prototype.scanFileV2=function(t,i){var l=this;if(!t||!(t instanceof File))throw"imageFile argument is mandatory and should be instance of File. Use 'event.target.files[0]'.";if(Xn(i)&&(i=!0),!this.stateManagerProxy.canScanFile())throw"Cannot start file scan - ongoing camera scan";return new Promise(function(c,f){l.possiblyCloseLastScanImageFile(),l.clearElement(),l.lastScanImageFile=URL.createObjectURL(t);var p=new Image;p.onload=function(){var w=p.width,C=p.height,m=document.getElementById(l.elementId),_=m.clientWidth?m.clientWidth:nn.DEFAULT_WIDTH,v=Math.max(m.clientHeight?m.clientHeight:C,nn.FILE_SCAN_MIN_HEIGHT),R=l.computeCanvasDrawConfig(w,C,_,v);if(i){var M=l.createCanvasElement(_,v,"qr-canvas-visible");M.style.display="inline-block",m.appendChild(M);var P=M.getContext("2d");if(!P)throw"Unable to get 2d context from canvas";P.canvas.width=_,P.canvas.height=v,P.drawImage(p,0,0,w,C,R.x,R.y,R.width,R.height)}var B=nn.FILE_SCAN_HIDDEN_CANVAS_PADDING,K=Math.max(p.width,R.width),O=Math.max(p.height,R.height),T=K+2*B,N=O+2*B,G=l.createCanvasElement(T,N);m.appendChild(G);var H=G.getContext("2d");if(!H)throw"Unable to get 2d context from canvas";H.canvas.width=T,H.canvas.height=N,H.drawImage(p,0,0,w,C,B,B,K,O);try{l.qrcode.decodeRobustlyAsync(G).then(function(U){c(B0.createFromQrcodeResult(U))}).catch(f)}catch(U){f("QR code parse error, error = ".concat(U))}},p.onerror=f,p.onabort=f,p.onstalled=f,p.onsuspend=f,p.src=URL.createObjectURL(t)})},e.prototype.clear=function(){this.clearElement()},e.getCameras=function(){return Pm.retrieve()},e.prototype.getRunningTrackCapabilities=function(){return this.getRenderedCameraOrFail().getRunningTrackCapabilities()},e.prototype.getRunningTrackSettings=function(){return this.getRenderedCameraOrFail().getRunningTrackSettings()},e.prototype.getRunningTrackCameraCapabilities=function(){return this.getRenderedCameraOrFail().getCapabilities()},e.prototype.applyVideoConstraints=function(t){if(t){if(!Sh.isMediaStreamConstraintsValid(t,this.logger))throw"invalid videoConstaints passed, check logs for more details"}else throw"videoConstaints is required argument.";return this.getRenderedCameraOrFail().applyVideoConstraints(t)},e.prototype.getRenderedCameraOrFail=function(){if(this.renderedCamera==null)throw"Scanning is not in running state, call this API only when QR code scanning using camera is in running state.";return this.renderedCamera},e.prototype.getSupportedFormats=function(t){var i=[te.QR_CODE,te.AZTEC,te.CODABAR,te.CODE_39,te.CODE_93,te.CODE_128,te.DATA_MATRIX,te.MAXICODE,te.ITF,te.EAN_13,te.EAN_8,te.PDF_417,te.RSS_14,te.RSS_EXPANDED,te.UPC_A,te.UPC_E,te.UPC_EAN_EXTENSION];if(!t||typeof t=="boolean"||!t.formatsToSupport)return i;if(!Array.isArray(t.formatsToSupport))throw"configOrVerbosityFlag.formatsToSupport should be undefined or an array.";if(t.formatsToSupport.length===0)throw"Atleast 1 formatsToSupport is needed.";for(var l=[],c=0,f=t.formatsToSupport;c<f.length;c++){var p=f[c];wm(p)?l.push(p):this.logger.warn("Invalid format: ".concat(p," passed in config, ignoring."))}if(l.length===0)throw"None of formatsToSupport match supported values.";return l},e.prototype.getUseBarCodeDetectorIfSupported=function(t){if(Xn(t))return!0;if(!Xn(t.useBarCodeDetectorIfSupported))return t.useBarCodeDetectorIfSupported!==!1;if(Xn(t.experimentalFeatures))return!0;var i=t.experimentalFeatures;return Xn(i.useBarCodeDetectorIfSupported)?!0:i.useBarCodeDetectorIfSupported!==!1},e.prototype.validateQrboxSize=function(t,i,l){var c=this,f=l.qrbox;this.validateQrboxConfig(f);var p=this.toQrdimensions(t,i,f),w=function(m){if(m<nn.MIN_QR_BOX_SIZE)throw"minimum size of 'config.qrbox' dimension value is"+" ".concat(nn.MIN_QR_BOX_SIZE,"px.")},C=function(m){return m>t&&(c.logger.warn("`qrbox.width` or `qrbox` is larger than the width of the root element. The width will be truncated to the width of root element."),m=t),m};w(p.width),w(p.height),p.width=C(p.width)},e.prototype.validateQrboxConfig=function(t){if(typeof t!="number"&&typeof t!="function"&&(t.width===void 0||t.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},e.prototype.toQrdimensions=function(t,i,l){if(typeof l=="number")return{width:l,height:l};if(typeof l=="function")try{return l(t,i)}catch(c){throw new Error("qrbox config was passed as a function but it failed with unknown error"+c)}return l},e.prototype.setupUi=function(t,i,l){l.isShadedBoxEnabled()&&this.validateQrboxSize(t,i,l);var c=Xn(l.qrbox)?{width:t,height:i}:l.qrbox;this.validateQrboxConfig(c);var f=this.toQrdimensions(t,i,c);f.height>i&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var p=l.isShadedBoxEnabled()&&f.height<=i,w={x:0,y:0,width:t,height:i},C=p?this.getShadedRegionBounds(t,i,f):w,m=this.createCanvasElement(C.width,C.height),_={willReadFrequently:!0},v=m.getContext("2d",_);v.canvas.width=C.width,v.canvas.height=C.height,this.element.append(m),p&&this.possiblyInsertShadingElement(this.element,t,i,f),this.createScannerPausedUiElement(this.element),this.qrRegion=C,this.context=v,this.canvasElement=m},e.prototype.createScannerPausedUiElement=function(t){var i=document.createElement("div");i.innerText=Ri.scannerPaused(),i.style.display="none",i.style.position="absolute",i.style.top="0px",i.style.zIndex="1",i.style.background="rgba(9, 9, 9, 0.46)",i.style.color="#FFECEC",i.style.textAlign="center",i.style.width="100%",t.appendChild(i),this.scannerPausedUiElement=i},e.prototype.scanContext=function(t,i){var l=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(c){return t(c.text,B0.createFromQrcodeResult(c)),l.possiblyUpdateShaders(!0),!0}).catch(function(c){l.possiblyUpdateShaders(!1);var f=Ri.codeParseError(c);return i(f,Em.createFrom(f)),!1})},e.prototype.foreverScan=function(t,i,l){var c=this;if(this.shouldScan&&this.renderedCamera){var f=this.renderedCamera.getSurface(),p=f.videoWidth/f.clientWidth,w=f.videoHeight/f.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var C=this.qrRegion.width*p,m=this.qrRegion.height*w,_=this.qrRegion.x*p,v=this.qrRegion.y*w;this.context.drawImage(f,_,v,C,m,0,0,this.qrRegion.width,this.qrRegion.height);var R=function(){c.foreverScanTimeout=setTimeout(function(){c.foreverScan(t,i,l)},c.getTimeoutFps(t.fps))};this.scanContext(i,l).then(function(M){!M&&t.disableFlip!==!0?(c.context.translate(c.context.canvas.width,0),c.context.scale(-1,1),c.scanContext(i,l).finally(function(){R()})):R()}).catch(function(M){c.logger.logError("Error happend while scanning context",M),R()})}},e.prototype.createVideoConstraints=function(t){if(typeof t=="string")return{deviceId:{exact:t}};if(typeof t=="object"){var i="facingMode",l="deviceId",c={user:!0,environment:!0},f="exact",p=function(P){if(P in c)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(P,"'")},w=Object.keys(t);if(w.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(w.length," keys");var C=Object.keys(t)[0];if(C!==i&&C!==l)throw"Only '".concat(i,"' and '").concat(l,"' ")+" are supported for 'cameraIdOrConfig'";if(C===i){var m=t.facingMode;if(typeof m=="string"){if(p(m))return{facingMode:m}}else if(typeof m=="object")if(f in m){if(p(m["".concat(f)]))return{facingMode:{exact:m["".concat(f)]}}}else throw"'facingMode' should be string or object with"+" ".concat(f," as key.");else{var _=typeof m;throw"Invalid type of 'facingMode' = ".concat(_)}}else{var v=t.deviceId;if(typeof v=="string")return{deviceId:v};if(typeof v=="object"){if(f in v)return{deviceId:{exact:v["".concat(f)]}};throw"'deviceId' should be string or object with"+" ".concat(f," as key.")}else{var R=typeof v;throw"Invalid type of 'deviceId' = ".concat(R)}}}var M=typeof t;throw"Invalid type of 'cameraIdOrConfig' = ".concat(M)},e.prototype.computeCanvasDrawConfig=function(t,i,l,c){if(t<=l&&i<=c){var f=(l-t)/2,p=(c-i)/2;return{x:f,y:p,width:t,height:i}}else{var w=t,C=i;return t>l&&(i=l/t*i,t=l),i>c&&(t=c/i*t,i=c),this.logger.log("Image downsampled from "+"".concat(w,"X").concat(C)+" to ".concat(t,"X").concat(i,".")),this.computeCanvasDrawConfig(t,i,l,c)}},e.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var t=document.getElementById(this.elementId);t&&(t.innerHTML="")},e.prototype.possiblyUpdateShaders=function(t){this.qrMatch!==t&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(i){i.style.backgroundColor=t?nn.BORDER_SHADER_MATCH_COLOR:nn.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=t)},e.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},e.prototype.createCanvasElement=function(t,i,l){var c=t,f=i,p=document.createElement("canvas");return p.style.width="".concat(c,"px"),p.style.height="".concat(f,"px"),p.style.display="none",p.id=Xn(l)?"qr-canvas":l,p},e.prototype.getShadedRegionBounds=function(t,i,l){if(l.width>t||l.height>i)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(t-l.width)/2,y:(i-l.height)/2,width:l.width,height:l.height}},e.prototype.possiblyInsertShadingElement=function(t,i,l,c){if(!(i-c.width<1||l-c.height<1)){var f=document.createElement("div");f.style.position="absolute";var p=(i-c.width)/2,w=(l-c.height)/2;if(f.style.borderLeft="".concat(p,"px solid rgba(0, 0, 0, 0.48)"),f.style.borderRight="".concat(p,"px solid rgba(0, 0, 0, 0.48)"),f.style.borderTop="".concat(w,"px solid rgba(0, 0, 0, 0.48)"),f.style.borderBottom="".concat(w,"px solid rgba(0, 0, 0, 0.48)"),f.style.boxSizing="border-box",f.style.top="0px",f.style.bottom="0px",f.style.left="0px",f.style.right="0px",f.id="".concat(nn.SHADED_REGION_ELEMENT_ID),i-c.width<11||l-c.height<11)this.hasBorderShaders=!1;else{var C=5,m=40;this.insertShaderBorders(f,m,C,-C,null,0,!0),this.insertShaderBorders(f,m,C,-C,null,0,!1),this.insertShaderBorders(f,m,C,null,-C,0,!0),this.insertShaderBorders(f,m,C,null,-C,0,!1),this.insertShaderBorders(f,C,m+C,-C,null,-C,!0),this.insertShaderBorders(f,C,m+C,null,-C,-C,!0),this.insertShaderBorders(f,C,m+C,-C,null,-C,!1),this.insertShaderBorders(f,C,m+C,null,-C,-C,!1),this.hasBorderShaders=!0}t.append(f)}},e.prototype.insertShaderBorders=function(t,i,l,c,f,p,w){var C=document.createElement("div");C.style.position="absolute",C.style.backgroundColor=nn.BORDER_SHADER_DEFAULT_COLOR,C.style.width="".concat(i,"px"),C.style.height="".concat(l,"px"),c!==null&&(C.style.top="".concat(c,"px")),f!==null&&(C.style.bottom="".concat(f,"px")),w?C.style.left="".concat(p,"px"):C.style.right="".concat(p,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(C),t.appendChild(C)},e.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},e.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},e.prototype.getTimeoutFps=function(t){return 1e3/t},e}(),H0;(function(e){e[e.STATUS_DEFAULT=0]="STATUS_DEFAULT",e[e.STATUS_SUCCESS=1]="STATUS_SUCCESS",e[e.STATUS_WARNING=2]="STATUS_WARNING",e[e.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"})(H0||(H0={}));var Fu;(function(e){e[e.BACK=1]="BACK",e[e.FRONT=2]="FRONT"})(Fu||(Fu={}));var Uu;(function(e){e[e.PORTRAIT=1]="PORTRAIT",e[e.LANDSCAPE=2]="LANDSCAPE",e[e.ADAPTIVE=3]="ADAPTIVE"})(Uu||(Uu={}));var Wu;(function(e){e[e.ALL=17]="ALL"})(Wu||(Wu={}));const zm=Object.assign(Object.assign({},te),Wu);var j0;(function(e){e.ZXING="zxing",e.MLKIT="mlkit"})(j0||(j0={}));const Vm=[{selector:".scanner-container-display",css:"display: block;"},{selector:".scanner-dialog",css:"display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4);"},{selector:".scanner-dialog-inner",css:"background-color: #fefefe; margin: 2% auto; padding: 20px; border: 1px solid #888; width: 96%;"},{selector:".close-button",css:"color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer;"},{selector:".close-button:hover",css:"color: #222;"},{selector:".scanner-container-full-width",css:"width: 100%;"}];function Hm(e){const t="custom-style-os-cap-barcode";let i=document.getElementById(t);if(i||(i=document.createElement("style"),i.type="text/css",i.id=t,document.head.appendChild(i)),i.sheet){for(;i.sheet.cssRules.length;)i.sheet.deleteRule(0);for(const{selector:l,css:c}of e)i.sheet.insertRule(`${l} { ${c} }`)}else{i.textContent="";for(const{selector:l,css:c}of e)i.textContent+=`${l} { ${c} }`}}const jm=Va("CapacitorBarcodeScanner",{web:()=>(Hm(Vm),qu(()=>import("./web-Bco3fxtw.js"),[],import.meta.url).then(e=>new e.CapacitorBarcodeScannerWeb))});class Gm{static async scanBarcode(t){return t.scanInstructions=t.scanInstructions||" ",t.scanButton=t.scanButton||!1,t.scanText=t.scanText||" ",t.cameraDirection=t.cameraDirection||Fu.BACK,t.scanOrientation=t.scanOrientation||Uu.ADAPTIVE,jm.scanBarcode(t)}}const zl=Va("SecureStoragePlugin",{web:()=>qu(()=>import("./web-D1VZM26_.js"),[],import.meta.url).then(e=>new e.SecureStoragePluginWeb)});function Xm(e){try{if(e.length>2048)throw new Error;if(!e.startsWith("{")){const c=new URL(e);if(!["http:","https:"].includes(c.protocol)||c.username||c.password||c.pathname!=="/pair"||c.search||!/^#pair=[A-Za-z0-9_-]{43}$/.test(c.hash))throw new Error;const f=br.parse(c.origin);if(!f)throw new Error;return{endpoint:f,grant:c.hash.slice(6)}}const t=JSON.parse(e);if(t.type!=="agentroam-pair"||t.version!==1||typeof t.server!="string"||typeof t.grant!="string"||!/^[A-Za-z0-9_-]{43}$/.test(t.grant))throw new Error;const i=new URL(t.server);if(i.username||i.password||i.search||i.hash||i.pathname!=="/")throw new Error;const l=br.parse(t.server);if(!l)throw new Error;return{endpoint:l,grant:t.grant}}catch{throw new Error("这不是 AgentRoam 授权二维码,请扫描电脑终端上新生成的二维码。")}}class Ym{ready(){if(!$s.isNativePlatform())throw new Error("请在 AgentRoam App 中扫码连接。")}async get(t){this.ready();try{return(await zl.get({key:`agentroam-device:${t}`})).value}catch(i){if(String(i).includes("does not exist"))return null;throw new Error("无法读取设备凭证,请重试。")}}async set(t,i){this.ready(),await zl.set({key:`agentroam-device:${t}`,value:i})}async remove(t){this.ready();try{await zl.remove({key:`agentroam-device:${t}`})}catch(i){if(!String(i).includes("does not exist"))throw i}}}async function Zm(){if(!$s.isNativePlatform())throw new Error("请在 AgentRoam App 中使用相机扫码。");try{return(await Gm.scanBarcode({hint:zm.QR_CODE,scanInstructions:"扫描电脑上的 AgentRoam 授权二维码",cameraDirection:1})).ScanResult||null}catch(e){if(/cancel/i.test(String(e)))return null;throw new Error("无法打开相机,请在系统设置中允许 AgentRoam 使用相机后重试。")}}class Km{constructor(t,i=(...c)=>fetch(...c),l=()=>window.dispatchEvent(new CustomEvent("webapp:unauthorized"))){this.storage=t,this.transport=i,this.onRevoked=l,this.session=null,this.fetch=async(c,f={})=>{const p=this.session,w=new URL(typeof c=="string"?c:c instanceof URL?c.href:c.url),C=new Headers(f.headers??(c instanceof Request?c.headers:void 0));p&&w.origin===p.origin&&C.set("authorization",`Bearer ${p.token}`);const m=await this.transport(c,{...f,headers:C,credentials:"omit",redirect:"error"});if(p&&this.session===p&&w.origin===p.origin&&(m.status===401||m.status===423)){this.session=null;try{await this.storage.remove(p.origin)}finally{this.onRevoked()}}return m}}async resume(t){const i=await this.storage.get(t.url);this.session=i?{origin:t.url,token:i}:null}async pair(t){const{endpoint:i,grant:l}=Xm(t),c=await this.transport(i.api("/api/pairing/qr-exchange"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({grant:l,name:"我的 App"}),credentials:"omit",redirect:"error",signal:AbortSignal.timeout(1e4)});if(!c.ok)throw new Error(c.status===423?"电脑已锁定远程访问,请先在电脑上解锁。":c.status===410?"二维码已使用或已过期,请在电脑上重新生成。":"扫码连接失败,请检查服务器地址和网络后重试。");const f=await c.json();if(typeof f.token!="string"||!/^[A-Za-z0-9_-]{43}$/.test(f.token))throw new Error("服务器返回了无效的设备凭证。");try{await this.storage.set(i.url,f.token)}catch{throw await this.transport(i.api("/api/pairing/logout"),{method:"POST",headers:{authorization:`Bearer ${f.token}`},credentials:"omit",redirect:"error",signal:AbortSignal.timeout(5e3)}).catch(()=>{}),new Error("无法安全保存设备凭证,请在电脑上重新生成二维码后重试。")}return this.session={origin:i.url,token:f.token},i}async checkAuthorization(){const t=this.session;if(!t)return;const i=await this.fetch(`${t.origin}/api/web-auth/status`,{signal:AbortSignal.timeout(5e3)});if(!i.ok)return;const l=await i.json();if(this.session===t&&(l.locked||l.authenticated===!1)){this.session=null;try{await this.storage.remove(t.origin)}finally{this.onRevoked()}}}}class Vl extends Error{constructor(t,i){super(t),this.name="ParseError",this.type=i.type,this.field=i.field,this.value=i.value,this.line=i.line}}const G0=10,Qm=13,zr=32;function Hl(e){}function qm(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:t=Hl,onError:i=Hl,onRetry:l=Hl,onComment:c,maxBufferSize:f}=e,p=[];let w=0,C=!0,m,_="",v=0,R,M=!1;function P(H){if(M)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(C&&(C=!1,H.charCodeAt(0)===239&&H.charCodeAt(1)===187&&H.charCodeAt(2)===191&&(H=H.slice(3))),p.length===0){const X=K(H);X!==""&&(p.push(X),w=X.length),B();return}if(H.indexOf(`
78
+ `);let s=d1.singletonList(Fn.INITIAL_STATE);for(let a=0;a<this.text.length;a++){let u,d=a+1<this.text.length?this.text[a+1]:0;switch(this.text[a]){case ie.getCharCode("\r"):u=d===r?2:0;break;case ie.getCharCode("."):u=d===n?3:0;break;case ie.getCharCode(","):u=d===n?4:0;break;case ie.getCharCode(":"):u=d===n?5:0;break;default:u=0}u>0?(s=as.updateStateListForPair(s,a,u),a++):s=this.updateStateListForChar(s,a)}return d1.min(s,(a,u)=>a.getBitCount()-u.getBitCount()).toBitArray(this.text)}updateStateListForChar(n,r){const s=[];for(let o of n)this.updateStateForChar(o,r,s);return as.simplifyStates(s)}updateStateForChar(n,r,s){let o=this.text[r]&255,a=ll[n.getMode()][o]>0,u=null;for(let d=0;d<=Ln;d++){let h=ll[d][o];if(h>0){if(u==null&&(u=n.endBinaryShift(r)),!a||d===n.getMode()||d===gn){const g=u.latchAndAppend(d,h);s.push(g)}if(!a&&g1[n.getMode()][d]>=0){const g=u.shiftAndAppend(d,h);s.push(g)}}}if(n.getBinaryShiftByteCount()>0||ll[n.getMode()][o]===0){let d=n.addBinaryShiftChar(r);s.push(d)}}static updateStateListForPair(n,r,s){const o=[];for(let a of n)this.updateStateForPair(a,r,s,o);return this.simplifyStates(o)}static updateStateForPair(n,r,s,o){let a=n.endBinaryShift(r);if(o.push(a.latchAndAppend(Ln,s)),n.getMode()!==Ln&&o.push(a.shiftAndAppend(Ln,s)),s===3||s===4){let u=a.latchAndAppend(gn,16-s).latchAndAppend(gn,1);o.push(u)}if(n.getBinaryShiftByteCount()>0){let u=n.addBinaryShiftChar(r).addBinaryShiftChar(r+1);o.push(u)}}static simplifyStates(n){let r=[];for(const s of n){let o=!0;for(const a of r){if(a.isBetterThanOrEqualTo(s)){o=!1;break}s.isBetterThanOrEqualTo(a)&&(r=r.filter(u=>u!==a))}o&&r.push(s)}return r}}class Ne{constructor(){}static encodeBytes(n){return Ne.encode(n,Ne.DEFAULT_EC_PERCENT,Ne.DEFAULT_AZTEC_LAYERS)}static encode(n,r,s){let o=new as(n).encode(),a=N.truncDivision(o.getSize()*r,100)+11,u=o.getSize()+a,d,h,g,x,E;if(s!==Ne.DEFAULT_AZTEC_LAYERS){if(d=s<0,h=Math.abs(s),h>(d?Ne.MAX_NB_BITS_COMPACT:Ne.MAX_NB_BITS))throw new v(ie.format("Illegal value %s for layers",s));g=Ne.totalBitsInLayer(h,d),x=Ne.WORD_SIZE[h];let Z=g-g%x;if(E=Ne.stuffBits(o,x),E.getSize()+a>Z)throw new v("Data to large for user specified layer");if(d&&E.getSize()>x*64)throw new v("Data to large for user specified layer")}else{x=0,E=null;for(let Z=0;;Z++){if(Z>Ne.MAX_NB_BITS)throw new v("Data too large for an Aztec code");if(d=Z<=3,h=d?Z+1:Z,g=Ne.totalBitsInLayer(h,d),u>g)continue;(E==null||x!==Ne.WORD_SIZE[h])&&(x=Ne.WORD_SIZE[h],E=Ne.stuffBits(o,x));let ve=g-g%x;if(!(d&&E.getSize()>x*64)&&E.getSize()+a<=ve)break}}let A=Ne.generateCheckWords(E,g,x),I=E.getSize()/x,b=Ne.generateModeMessage(d,h,I),D=(d?11:14)+h*4,L=new Int32Array(D),z;if(d){z=D;for(let Z=0;Z<L.length;Z++)L[Z]=Z}else{z=D+1+2*N.truncDivision(N.truncDivision(D,2)-1,15);let Z=N.truncDivision(D,2),ve=N.truncDivision(z,2);for(let me=0;me<Z;me++){let Yt=me+N.truncDivision(me,15);L[Z-me-1]=ve-Yt-1,L[Z+me]=ve+Yt+1}}let q=new _e(z);for(let Z=0,ve=0;Z<h;Z++){let me=(h-Z)*4+(d?9:12);for(let Yt=0;Yt<me;Yt++){let vn=Yt*2;for(let Zt=0;Zt<2;Zt++)A.get(ve+vn+Zt)&&q.set(L[Z*2+Zt],L[Z*2+Yt]),A.get(ve+me*2+vn+Zt)&&q.set(L[Z*2+Yt],L[D-1-Z*2-Zt]),A.get(ve+me*4+vn+Zt)&&q.set(L[D-1-Z*2-Zt],L[D-1-Z*2-Yt]),A.get(ve+me*6+vn+Zt)&&q.set(L[D-1-Z*2-Yt],L[Z*2+Zt])}ve+=me*8}if(Ne.drawModeMessage(q,d,z,b),d)Ne.drawBullsEye(q,N.truncDivision(z,2),5);else{Ne.drawBullsEye(q,N.truncDivision(z,2),7);for(let Z=0,ve=0;Z<N.truncDivision(D,2)-1;Z+=15,ve+=16)for(let me=N.truncDivision(z,2)&1;me<z;me+=2)q.set(N.truncDivision(z,2)-ve,me),q.set(N.truncDivision(z,2)+ve,me),q.set(me,N.truncDivision(z,2)-ve),q.set(me,N.truncDivision(z,2)+ve)}let $=new f1;return $.setCompact(d),$.setSize(z),$.setLayers(h),$.setCodeWords(I),$.setMatrix(q),$}static drawBullsEye(n,r,s){for(let o=0;o<s;o+=2)for(let a=r-o;a<=r+o;a++)n.set(a,r-o),n.set(a,r+o),n.set(r-o,a),n.set(r+o,a);n.set(r-s,r-s),n.set(r-s+1,r-s),n.set(r-s,r-s+1),n.set(r+s,r-s),n.set(r+s,r-s+1),n.set(r+s,r+s-1)}static generateModeMessage(n,r,s){let o=new G;return n?(o.appendBits(r-1,2),o.appendBits(s-1,6),o=Ne.generateCheckWords(o,28,4)):(o.appendBits(r-1,5),o.appendBits(s-1,11),o=Ne.generateCheckWords(o,40,4)),o}static drawModeMessage(n,r,s,o){let a=N.truncDivision(s,2);if(r)for(let u=0;u<7;u++){let d=a-3+u;o.get(u)&&n.set(d,a-5),o.get(u+7)&&n.set(a+5,d),o.get(20-u)&&n.set(d,a+5),o.get(27-u)&&n.set(a-5,d)}else for(let u=0;u<10;u++){let d=a-5+u+N.truncDivision(u,5);o.get(u)&&n.set(d,a-7),o.get(u+10)&&n.set(a+7,d),o.get(29-u)&&n.set(d,a+7),o.get(39-u)&&n.set(a-7,d)}}static generateCheckWords(n,r,s){let o=n.getSize()/s,a=new rl(Ne.getGF(s)),u=N.truncDivision(r,s),d=Ne.bitsToWords(n,s,u);a.encode(d,u-o);let h=r%s,g=new G;g.appendBits(0,h);for(const x of Array.from(d))g.appendBits(x,s);return g}static bitsToWords(n,r,s){let o=new Int32Array(s),a,u;for(a=0,u=n.getSize()/r;a<u;a++){let d=0;for(let h=0;h<r;h++)d|=n.get(a*r+h)?1<<r-h-1:0;o[a]=d}return o}static getGF(n){switch(n){case 4:return be.AZTEC_PARAM;case 6:return be.AZTEC_DATA_6;case 8:return be.AZTEC_DATA_8;case 10:return be.AZTEC_DATA_10;case 12:return be.AZTEC_DATA_12;default:throw new v("Unsupported word size "+n)}}static stuffBits(n,r){let s=new G,o=n.getSize(),a=(1<<r)-2;for(let u=0;u<o;u+=r){let d=0;for(let h=0;h<r;h++)(u+h>=o||n.get(u+h))&&(d|=1<<r-1-h);(d&a)===a?(s.appendBits(d&a,r),u--):d&a?s.appendBits(d,r):(s.appendBits(d|1,r),u--)}return s}static totalBitsInLayer(n,r){return((r?88:112)+16*n)*n}}Ne.DEFAULT_EC_PERCENT=33,Ne.DEFAULT_AZTEC_LAYERS=0,Ne.MAX_NB_BITS=32,Ne.MAX_NB_BITS_COMPACT=4,Ne.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]);class mo{encode(n,r,s,o){return this.encodeWithHints(n,r,s,o,null)}encodeWithHints(n,r,s,o,a){let u=sl.ISO_8859_1,d=Ne.DEFAULT_EC_PERCENT,h=Ne.DEFAULT_AZTEC_LAYERS;return a!=null&&(a.has(ht.CHARACTER_SET)&&(u=c1.forName(a.get(ht.CHARACTER_SET).toString())),a.has(ht.ERROR_CORRECTION)&&(d=N.parseInt(a.get(ht.ERROR_CORRECTION).toString())),a.has(ht.AZTEC_LAYERS)&&(h=N.parseInt(a.get(ht.AZTEC_LAYERS).toString()))),mo.encodeLayers(n,r,s,o,u,d,h)}static encodeLayers(n,r,s,o,a,u,d){if(r!==le.AZTEC)throw new v("Can only encode AZTEC, but got "+r);let h=Ne.encode(ie.getBytes(n,a),u,d);return mo.renderResult(h,s,o)}static renderResult(n,r,s){let o=n.getMatrix();if(o==null)throw new Dn;let a=o.getWidth(),u=o.getHeight(),d=Math.max(r,a),h=Math.max(s,u),g=Math.min(d/a,h/u),x=(d-a*g)/2,E=(h-u*g)/2,A=new _e(d,h);for(let I=0,b=E;I<u;I++,b+=g)for(let D=0,L=x;D<a;D++,L+=g)o.get(D,I)&&A.setRegion(L,b,g,g);return A}}i.AbstractExpandedDecoder=Ya,i.ArgumentException=_,i.ArithmeticException=io,i.AztecCode=f1,i.AztecCodeReader=ao,i.AztecCodeWriter=mo,i.AztecDecoder=Ue,i.AztecDetector=qc,i.AztecDetectorResult=Kc,i.AztecEncoder=Ne,i.AztecHighLevelEncoder=as,i.AztecPoint=Lt,i.BarcodeFormat=le,i.Binarizer=P,i.BinaryBitmap=R,i.BitArray=G,i.BitMatrix=_e,i.BitSource=qa,i.BrowserAztecCodeReader=Rh,i.BrowserBarcodeReader=kh,i.BrowserCodeReader=cn,i.BrowserDatamatrixCodeReader=Bh,i.BrowserMultiFormatReader=Yh,i.BrowserPDF417Reader=Zh,i.BrowserQRCodeReader=Kh,i.BrowserQRCodeSvgWriter=Wr,i.CharacterSetECI=V,i.ChecksumException=M,i.Code128Reader=J,i.Code39Reader=ft,i.DataMatrixDecodedBitStreamParser=ar,i.DataMatrixReader=lr,i.DecodeHintType=U,i.DecoderResult=Qi,i.DefaultGridSampler=Qc,i.DetectorResult=oo,i.EAN13Reader=Pr,i.EncodeHintType=ht,i.Exception=m,i.FormatException=k,i.GenericGF=be,i.GenericGFPoly=Ht,i.GlobalHistogramBinarizer=tt,i.GridSampler=Ha,i.GridSamplerInstance=sr,i.HTMLCanvasElementLuminanceSource=pe,i.HybridBinarizer=xe,i.ITFReader=Be,i.IllegalArgumentException=v,i.IllegalStateException=Dn,i.InvertedLuminanceSource=de,i.LuminanceSource=ee,i.MathUtils=Te,i.MultiFormatOneDReader=ai,i.MultiFormatReader=u1,i.MultiFormatWriter=qh,i.NotFoundException=j,i.OneDReader=ut,i.PDF417DecodedBitStreamParser=W,i.PDF417DecoderErrorCorrection=r1,i.PDF417Reader=It,i.PDF417ResultMetadata=s1,i.PerspectiveTransform=Cn,i.PlanarYUVLuminanceSource=Bn,i.QRCodeByteMatrix=po,i.QRCodeDataMask=dn,i.QRCodeDecodedBitStreamParser=Qe,i.QRCodeDecoderErrorCorrectionLevel=We,i.QRCodeDecoderFormatInformation=Ot,i.QRCodeEncoder=Ve,i.QRCodeEncoderQRCode=Ur,i.QRCodeMaskUtil=it,i.QRCodeMatrixUtil=fe,i.QRCodeMode=ce,i.QRCodeReader=ur,i.QRCodeVersion=ue,i.QRCodeWriter=ui,i.RGBLuminanceSource=il,i.RSS14Reader=rt,i.RSSExpandedReader=Y,i.ReaderException=go,i.ReedSolomonDecoder=$i,i.ReedSolomonEncoder=rl,i.ReedSolomonException=ri,i.Result=Ke,i.ResultMetadataType=mt,i.ResultPoint=oe,i.StringUtils=ie,i.UnsupportedOperationException=se,i.VideoInputDevice=Ge,i.WhiteRectangleDetector=Gn,i.WriterException=Le,i.ZXingArrays=T,i.ZXingCharset=c1,i.ZXingInteger=N,i.ZXingStandardCharsets=sl,i.ZXingStringBuilder=ge,i.ZXingStringEncoding=Ee,i.ZXingSystem=B,i.createAbstractExpandedDecoder=t1,Object.defineProperty(i,"__esModule",{value:!0})})})(Lu,Lu.exports);var qe=Lu.exports;const Am=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var L0=function(){function e(t,i,l){if(this.formatMap=new Map([[te.QR_CODE,qe.BarcodeFormat.QR_CODE],[te.AZTEC,qe.BarcodeFormat.AZTEC],[te.CODABAR,qe.BarcodeFormat.CODABAR],[te.CODE_39,qe.BarcodeFormat.CODE_39],[te.CODE_93,qe.BarcodeFormat.CODE_93],[te.CODE_128,qe.BarcodeFormat.CODE_128],[te.DATA_MATRIX,qe.BarcodeFormat.DATA_MATRIX],[te.MAXICODE,qe.BarcodeFormat.MAXICODE],[te.ITF,qe.BarcodeFormat.ITF],[te.EAN_13,qe.BarcodeFormat.EAN_13],[te.EAN_8,qe.BarcodeFormat.EAN_8],[te.PDF_417,qe.BarcodeFormat.PDF_417],[te.RSS_14,qe.BarcodeFormat.RSS_14],[te.RSS_EXPANDED,qe.BarcodeFormat.RSS_EXPANDED],[te.UPC_A,qe.BarcodeFormat.UPC_A],[te.UPC_E,qe.BarcodeFormat.UPC_E],[te.UPC_EAN_EXTENSION,qe.BarcodeFormat.UPC_EAN_EXTENSION]]),this.reverseFormatMap=this.createReverseFormatMap(),!Am)throw"Use html5qrcode.min.js without edit, ZXing not found.";this.verbose=i,this.logger=l;var c=this.createZXingFormats(t),f=new Map;f.set(qe.DecodeHintType.POSSIBLE_FORMATS,c),f.set(qe.DecodeHintType.TRY_HARDER,!1),this.hints=f}return e.prototype.decodeAsync=function(t){var i=this;return new Promise(function(l,c){try{l(i.decode(t))}catch(f){c(f)}})},e.prototype.decode=function(t){var i=new qe.MultiFormatReader(this.verbose,this.hints),l=new qe.HTMLCanvasElementLuminanceSource(t),c=new qe.BinaryBitmap(new qe.HybridBinarizer(l)),f=i.decode(c);return{text:f.text,format:vh.create(this.toHtml5QrcodeSupportedFormats(f.format)),debugData:this.createDebugData()}},e.prototype.createReverseFormatMap=function(){var t=new Map;return this.formatMap.forEach(function(i,l,c){t.set(i,l)}),t},e.prototype.toHtml5QrcodeSupportedFormats=function(t){if(!this.reverseFormatMap.has(t))throw"reverseFormatMap doesn't have ".concat(t);return this.reverseFormatMap.get(t)},e.prototype.createZXingFormats=function(t){for(var i=[],l=0,c=t;l<c.length;l++){var f=c[l];this.formatMap.has(f)?i.push(this.formatMap.get(f)):this.logger.logError("".concat(f," is not supported by")+"ZXingHtml5QrcodeShim")}return i},e.prototype.createDebugData=function(){return{decoderName:"zxing-js"}},e}(),vm=function(e,t,i,l){function c(f){return f instanceof i?f:new i(function(p){p(f)})}return new(i||(i=Promise))(function(f,p){function w(_){try{m(l.next(_))}catch(v){p(v)}}function C(_){try{m(l.throw(_))}catch(v){p(v)}}function m(_){_.done?f(_.value):c(_.value).then(w,C)}m((l=l.apply(e,t||[])).next())})},Sm=function(e,t){var i={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,c,f,p;return p={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function w(m){return function(_){return C([m,_])}}function C(m){if(l)throw new TypeError("Generator is already executing.");for(;p&&(p=0,m[0]&&(i=0)),i;)try{if(l=1,c&&(f=m[0]&2?c.return:m[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,m[1])).done)return f;switch(c=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return i.label++,{value:m[1],done:!1};case 5:i.label++,c=m[1],m=[0];continue;case 7:m=i.ops.pop(),i.trys.pop();continue;default:if(f=i.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){i=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){i.label=m[1];break}if(m[0]===6&&i.label<f[1]){i.label=f[1],f=m;break}if(f&&i.label<f[2]){i.label=f[2],i.ops.push(m);break}f[2]&&i.ops.pop(),i.trys.pop();continue}m=t.call(e,i)}catch(_){m=[6,_],c=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},F0=function(){function e(t,i,l){if(this.formatMap=new Map([[te.QR_CODE,"qr_code"],[te.AZTEC,"aztec"],[te.CODABAR,"codabar"],[te.CODE_39,"code_39"],[te.CODE_93,"code_93"],[te.CODE_128,"code_128"],[te.DATA_MATRIX,"data_matrix"],[te.ITF,"itf"],[te.EAN_13,"ean_13"],[te.EAN_8,"ean_8"],[te.PDF_417,"pdf417"],[te.UPC_A,"upc_a"],[te.UPC_E,"upc_e"]]),this.reverseFormatMap=this.createReverseFormatMap(),!e.isSupported())throw"Use html5qrcode.min.js without edit, Use BarcodeDetectorDelegate only if it isSupported();";this.verbose=i,this.logger=l;var c=this.createBarcodeDetectorFormats(t);if(this.detector=new BarcodeDetector(c),!this.detector)throw"BarcodeDetector detector not supported"}return e.isSupported=function(){if(!("BarcodeDetector"in window))return!1;var t=new BarcodeDetector({formats:["qr_code"]});return typeof t<"u"},e.prototype.decodeAsync=function(t){return vm(this,void 0,void 0,function(){var i,l;return Sm(this,function(c){switch(c.label){case 0:return[4,this.detector.detect(t)];case 1:if(i=c.sent(),!i||i.length===0)throw"No barcode or QR code detected.";return l=this.selectLargestBarcode(i),[2,{text:l.rawValue,format:vh.create(this.toHtml5QrcodeSupportedFormats(l.format)),debugData:this.createDebugData()}]}})})},e.prototype.selectLargestBarcode=function(t){for(var i=null,l=0,c=0,f=t;c<f.length;c++){var p=f[c],w=p.boundingBox.width*p.boundingBox.height;w>l&&(l=w,i=p)}if(!i)throw"No largest barcode found";return i},e.prototype.createBarcodeDetectorFormats=function(t){for(var i=[],l=0,c=t;l<c.length;l++){var f=c[l];this.formatMap.has(f)?i.push(this.formatMap.get(f)):this.logger.warn("".concat(f," is not supported by")+"BarcodeDetectorDelegate")}return{formats:i}},e.prototype.toHtml5QrcodeSupportedFormats=function(t){if(!this.reverseFormatMap.has(t))throw"reverseFormatMap doesn't have ".concat(t);return this.reverseFormatMap.get(t)},e.prototype.createReverseFormatMap=function(){var t=new Map;return this.formatMap.forEach(function(i,l,c){t.set(i,l)}),t},e.prototype.createDebugData=function(){return{decoderName:"BarcodeDetector"}},e}(),U0=function(e,t,i,l){function c(f){return f instanceof i?f:new i(function(p){p(f)})}return new(i||(i=Promise))(function(f,p){function w(_){try{m(l.next(_))}catch(v){p(v)}}function C(_){try{m(l.throw(_))}catch(v){p(v)}}function m(_){_.done?f(_.value):c(_.value).then(w,C)}m((l=l.apply(e,t||[])).next())})},W0=function(e,t){var i={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,c,f,p;return p={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function w(m){return function(_){return C([m,_])}}function C(m){if(l)throw new TypeError("Generator is already executing.");for(;p&&(p=0,m[0]&&(i=0)),i;)try{if(l=1,c&&(f=m[0]&2?c.return:m[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,m[1])).done)return f;switch(c=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return i.label++,{value:m[1],done:!1};case 5:i.label++,c=m[1],m=[0];continue;case 7:m=i.ops.pop(),i.trys.pop();continue;default:if(f=i.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){i=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){i.label=m[1];break}if(m[0]===6&&i.label<f[1]){i.label=f[1],f=m;break}if(f&&i.label<f[2]){i.label=f[2],i.ops.push(m);break}f[2]&&i.ops.pop(),i.trys.pop();continue}m=t.call(e,i)}catch(_){m=[6,_],c=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},Im=function(){function e(t,i,l,c){this.EXECUTIONS_TO_REPORT_PERFORMANCE=100,this.executions=0,this.executionResults=[],this.wasPrimaryDecoderUsedInLastDecode=!1,this.verbose=l,i&&F0.isSupported()?(this.primaryDecoder=new F0(t,l,c),this.secondaryDecoder=new L0(t,l,c)):this.primaryDecoder=new L0(t,l,c)}return e.prototype.decodeAsync=function(t){return U0(this,void 0,void 0,function(){var i;return W0(this,function(l){switch(l.label){case 0:i=performance.now(),l.label=1;case 1:return l.trys.push([1,,3,4]),[4,this.getDecoder().decodeAsync(t)];case 2:return[2,l.sent()];case 3:return this.possiblyLogPerformance(i),[7];case 4:return[2]}})})},e.prototype.decodeRobustlyAsync=function(t){return U0(this,void 0,void 0,function(){var i,l;return W0(this,function(c){switch(c.label){case 0:i=performance.now(),c.label=1;case 1:return c.trys.push([1,3,4,5]),[4,this.primaryDecoder.decodeAsync(t)];case 2:return[2,c.sent()];case 3:if(l=c.sent(),this.secondaryDecoder)return[2,this.secondaryDecoder.decodeAsync(t)];throw l;case 4:return this.possiblyLogPerformance(i),[7];case 5:return[2]}})})},e.prototype.getDecoder=function(){return this.secondaryDecoder?this.wasPrimaryDecoderUsedInLastDecode===!1?(this.wasPrimaryDecoderUsedInLastDecode=!0,this.primaryDecoder):(this.wasPrimaryDecoderUsedInLastDecode=!1,this.secondaryDecoder):this.primaryDecoder},e.prototype.possiblyLogPerformance=function(t){if(this.verbose){var i=performance.now()-t;this.executionResults.push(i),this.executions++,this.possiblyFlushPerformanceReport()}},e.prototype.possiblyFlushPerformanceReport=function(){if(!(this.executions<this.EXECUTIONS_TO_REPORT_PERFORMANCE)){for(var t=0,i=0,l=this.executionResults;i<l.length;i++){var c=l[i];t+=c}var f=t/this.executionResults.length;console.log("".concat(f," ms for ").concat(this.executionResults.length," last runs.")),this.executions=0,this.executionResults=[]}},e}(),Xc=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,c){l.__proto__=c}||function(l,c){for(var f in c)Object.prototype.hasOwnProperty.call(c,f)&&(l[f]=c[f])},e(t,i)};return function(t,i){if(typeof i!="function"&&i!==null)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");e(t,i);function l(){this.constructor=t}t.prototype=i===null?Object.create(i):(l.prototype=i.prototype,new l)}}(),Aa=function(e,t,i,l){function c(f){return f instanceof i?f:new i(function(p){p(f)})}return new(i||(i=Promise))(function(f,p){function w(_){try{m(l.next(_))}catch(v){p(v)}}function C(_){try{m(l.throw(_))}catch(v){p(v)}}function m(_){_.done?f(_.value):c(_.value).then(w,C)}m((l=l.apply(e,t||[])).next())})},va=function(e,t){var i={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,c,f,p;return p={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function w(m){return function(_){return C([m,_])}}function C(m){if(l)throw new TypeError("Generator is already executing.");for(;p&&(p=0,m[0]&&(i=0)),i;)try{if(l=1,c&&(f=m[0]&2?c.return:m[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,m[1])).done)return f;switch(c=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return i.label++,{value:m[1],done:!1};case 5:i.label++,c=m[1],m=[0];continue;case 7:m=i.ops.pop(),i.trys.pop();continue;default:if(f=i.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){i=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){i.label=m[1];break}if(m[0]===6&&i.label<f[1]){i.label=f[1],f=m;break}if(f&&i.label<f[2]){i.label=f[2],i.ops.push(m);break}f[2]&&i.ops.pop(),i.trys.pop();continue}m=t.call(e,i)}catch(_){m=[6,_],c=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},Ih=function(){function e(t,i){this.name=t,this.track=i}return e.prototype.isSupported=function(){return this.track.getCapabilities?this.name in this.track.getCapabilities():!1},e.prototype.apply=function(t){var i={};i[this.name]=t;var l={advanced:[i]};return this.track.applyConstraints(l)},e.prototype.value=function(){var t=this.track.getSettings();if(this.name in t){var i=t[this.name];return i}return null},e}(),_m=function(e){Xc(t,e);function t(i,l){return e.call(this,i,l)||this}return t.prototype.min=function(){return this.getCapabilities().min},t.prototype.max=function(){return this.getCapabilities().max},t.prototype.step=function(){return this.getCapabilities().step},t.prototype.apply=function(i){var l={};l[this.name]=i;var c={advanced:[l]};return this.track.applyConstraints(c)},t.prototype.getCapabilities=function(){this.failIfNotSupported();var i=this.track.getCapabilities(),l=i[this.name];return{min:l.min,max:l.max,step:l.step}},t.prototype.failIfNotSupported=function(){if(!this.isSupported())throw new Error("".concat(this.name," capability not supported"))},t}(Ih),Tm=function(e){Xc(t,e);function t(i){return e.call(this,"zoom",i)||this}return t}(_m),Nm=function(e){Xc(t,e);function t(i){return e.call(this,"torch",i)||this}return t}(Ih),Rm=function(){function e(t){this.track=t}return e.prototype.zoomFeature=function(){return new Tm(this.track)},e.prototype.torchFeature=function(){return new Nm(this.track)},e}(),bm=function(){function e(t,i,l){this.isClosed=!1,this.parentElement=t,this.mediaStream=i,this.callbacks=l,this.surface=this.createVideoElement(this.parentElement.clientWidth),t.append(this.surface)}return e.prototype.createVideoElement=function(t){var i=document.createElement("video");return i.style.width="".concat(t,"px"),i.style.display="block",i.muted=!0,i.setAttribute("muted","true"),i.playsInline=!0,i},e.prototype.setupSurface=function(){var t=this;this.surface.onabort=function(){throw"RenderedCameraImpl video surface onabort() called"},this.surface.onerror=function(){throw"RenderedCameraImpl video surface onerror() called"};var i=function(){var l=t.surface.clientWidth,c=t.surface.clientHeight;t.callbacks.onRenderSurfaceReady(l,c),t.surface.removeEventListener("playing",i)};this.surface.addEventListener("playing",i),this.surface.srcObject=this.mediaStream,this.surface.play()},e.create=function(t,i,l,c){return Aa(this,void 0,void 0,function(){var f,p;return va(this,function(w){switch(w.label){case 0:return f=new e(t,i,c),l.aspectRatio?(p={aspectRatio:l.aspectRatio},[4,f.getFirstTrackOrFail().applyConstraints(p)]):[3,2];case 1:w.sent(),w.label=2;case 2:return f.setupSurface(),[2,f]}})})},e.prototype.failIfClosed=function(){if(this.isClosed)throw"The RenderedCamera has already been closed."},e.prototype.getFirstTrackOrFail=function(){if(this.failIfClosed(),this.mediaStream.getVideoTracks().length===0)throw"No video tracks found";return this.mediaStream.getVideoTracks()[0]},e.prototype.pause=function(){this.failIfClosed(),this.surface.pause()},e.prototype.resume=function(t){this.failIfClosed();var i=this,l=function(){setTimeout(t,200),i.surface.removeEventListener("playing",l)};this.surface.addEventListener("playing",l),this.surface.play()},e.prototype.isPaused=function(){return this.failIfClosed(),this.surface.paused},e.prototype.getSurface=function(){return this.failIfClosed(),this.surface},e.prototype.getRunningTrackCapabilities=function(){return this.getFirstTrackOrFail().getCapabilities()},e.prototype.getRunningTrackSettings=function(){return this.getFirstTrackOrFail().getSettings()},e.prototype.applyVideoConstraints=function(t){return Aa(this,void 0,void 0,function(){return va(this,function(i){if("aspectRatio"in t)throw"Changing 'aspectRatio' in run-time is not yet supported.";return[2,this.getFirstTrackOrFail().applyConstraints(t)]})})},e.prototype.close=function(){if(this.isClosed)return Promise.resolve();var t=this;return new Promise(function(i,l){var c=t.mediaStream.getVideoTracks(),f=c.length,p=0;t.mediaStream.getVideoTracks().forEach(function(w){t.mediaStream.removeTrack(w),w.stop(),++p,p>=f&&(t.isClosed=!0,t.parentElement.removeChild(t.surface),i())})})},e.prototype.getCapabilities=function(){return new Rm(this.getFirstTrackOrFail())},e}(),Om=function(){function e(t){this.mediaStream=t}return e.prototype.render=function(t,i,l){return Aa(this,void 0,void 0,function(){return va(this,function(c){return[2,bm.create(t,this.mediaStream,i,l)]})})},e.create=function(t){return Aa(this,void 0,void 0,function(){var i,l;return va(this,function(c){switch(c.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return i={audio:!1,video:t},[4,navigator.mediaDevices.getUserMedia(i)];case 1:return l=c.sent(),[2,new e(l)]}})})},e}(),z0=function(e,t,i,l){function c(f){return f instanceof i?f:new i(function(p){p(f)})}return new(i||(i=Promise))(function(f,p){function w(_){try{m(l.next(_))}catch(v){p(v)}}function C(_){try{m(l.throw(_))}catch(v){p(v)}}function m(_){_.done?f(_.value):c(_.value).then(w,C)}m((l=l.apply(e,t||[])).next())})},V0=function(e,t){var i={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,c,f,p;return p={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function w(m){return function(_){return C([m,_])}}function C(m){if(l)throw new TypeError("Generator is already executing.");for(;p&&(p=0,m[0]&&(i=0)),i;)try{if(l=1,c&&(f=m[0]&2?c.return:m[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,m[1])).done)return f;switch(c=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return i.label++,{value:m[1],done:!1};case 5:i.label++,c=m[1],m=[0];continue;case 7:m=i.ops.pop(),i.trys.pop();continue;default:if(f=i.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){i=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){i.label=m[1];break}if(m[0]===6&&i.label<f[1]){i.label=f[1],f=m;break}if(f&&i.label<f[2]){i.label=f[2],i.ops.push(m);break}f[2]&&i.ops.pop(),i.trys.pop();continue}m=t.call(e,i)}catch(_){m=[6,_],c=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},Dm=function(){function e(){}return e.failIfNotSupported=function(){return z0(this,void 0,void 0,function(){return V0(this,function(t){if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return[2,new e]})})},e.prototype.create=function(t){return z0(this,void 0,void 0,function(){return V0(this,function(i){return[2,Om.create(t)]})})},e}(),Mm=function(e,t,i,l){function c(f){return f instanceof i?f:new i(function(p){p(f)})}return new(i||(i=Promise))(function(f,p){function w(_){try{m(l.next(_))}catch(v){p(v)}}function C(_){try{m(l.throw(_))}catch(v){p(v)}}function m(_){_.done?f(_.value):c(_.value).then(w,C)}m((l=l.apply(e,t||[])).next())})},km=function(e,t){var i={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,c,f,p;return p={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function w(m){return function(_){return C([m,_])}}function C(m){if(l)throw new TypeError("Generator is already executing.");for(;p&&(p=0,m[0]&&(i=0)),i;)try{if(l=1,c&&(f=m[0]&2?c.return:m[0]?c.throw||((f=c.return)&&f.call(c),0):c.next)&&!(f=f.call(c,m[1])).done)return f;switch(c=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return i.label++,{value:m[1],done:!1};case 5:i.label++,c=m[1],m=[0];continue;case 7:m=i.ops.pop(),i.trys.pop();continue;default:if(f=i.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){i=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){i.label=m[1];break}if(m[0]===6&&i.label<f[1]){i.label=f[1],f=m;break}if(f&&i.label<f[2]){i.label=f[2],i.ops.push(m);break}f[2]&&i.ops.pop(),i.trys.pop();continue}m=t.call(e,i)}catch(_){m=[6,_],c=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},Pm=function(){function e(){}return e.retrieve=function(){if(navigator.mediaDevices)return e.getCamerasFromMediaDevices();var t=MediaStreamTrack;return MediaStreamTrack&&t.getSources?e.getCamerasFromMediaStreamTrack():e.rejectWithError()},e.rejectWithError=function(){var t=Ri.unableToQuerySupportedDevices();return e.isHttpsOrLocalhost()||(t=Ri.insecureContextCameraQueryError()),Promise.reject(t)},e.isHttpsOrLocalhost=function(){if(location.protocol==="https:")return!0;var t=location.host.split(":")[0];return t==="127.0.0.1"||t==="localhost"},e.getCamerasFromMediaDevices=function(){return Mm(this,void 0,void 0,function(){var t,i,l,c,f,p,w;return km(this,function(C){switch(C.label){case 0:return t=function(m){for(var _=m.getVideoTracks(),v=0,R=_;v<R.length;v++){var M=R[v];M.enabled=!1,M.stop(),m.removeTrack(M)}},[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 1:return i=C.sent(),[4,navigator.mediaDevices.enumerateDevices()];case 2:for(l=C.sent(),c=[],f=0,p=l;f<p.length;f++)w=p[f],w.kind==="videoinput"&&c.push({id:w.deviceId,label:w.label});return t(i),[2,c]}})})},e.getCamerasFromMediaStreamTrack=function(){return new Promise(function(t,i){var l=function(f){for(var p=[],w=0,C=f;w<C.length;w++){var m=C[w];m.kind==="video"&&p.push({id:m.id,label:m.label})}t(p)},c=MediaStreamTrack;c.getSources(l)})},e}(),st;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.NOT_STARTED=1]="NOT_STARTED",e[e.SCANNING=2]="SCANNING",e[e.PAUSED=3]="PAUSED"})(st||(st={}));var Bm=function(){function e(){this.state=st.NOT_STARTED,this.onGoingTransactionNewState=st.UNKNOWN}return e.prototype.directTransition=function(t){this.failIfTransitionOngoing(),this.validateTransition(t),this.state=t},e.prototype.startTransition=function(t){return this.failIfTransitionOngoing(),this.validateTransition(t),this.onGoingTransactionNewState=t,this},e.prototype.execute=function(){if(this.onGoingTransactionNewState===st.UNKNOWN)throw"Transaction is already cancelled, cannot execute().";var t=this.onGoingTransactionNewState;this.onGoingTransactionNewState=st.UNKNOWN,this.directTransition(t)},e.prototype.cancel=function(){if(this.onGoingTransactionNewState===st.UNKNOWN)throw"Transaction is already cancelled, cannot cancel().";this.onGoingTransactionNewState=st.UNKNOWN},e.prototype.getState=function(){return this.state},e.prototype.failIfTransitionOngoing=function(){if(this.onGoingTransactionNewState!==st.UNKNOWN)throw"Cannot transition to a new state, already under transition"},e.prototype.validateTransition=function(t){switch(this.state){case st.UNKNOWN:throw"Transition from unknown is not allowed";case st.NOT_STARTED:this.failIfNewStateIs(t,[st.PAUSED]);break;case st.SCANNING:break;case st.PAUSED:break}},e.prototype.failIfNewStateIs=function(t,i){for(var l=0,c=i;l<c.length;l++){var f=c[l];if(t===f)throw"Cannot transition from ".concat(this.state," to ").concat(t)}},e}(),Lm=function(){function e(t){this.stateManager=t}return e.prototype.startTransition=function(t){return this.stateManager.startTransition(t)},e.prototype.directTransition=function(t){this.stateManager.directTransition(t)},e.prototype.getState=function(){return this.stateManager.getState()},e.prototype.canScanFile=function(){return this.stateManager.getState()===st.NOT_STARTED},e.prototype.isScanning=function(){return this.stateManager.getState()!==st.NOT_STARTED},e.prototype.isStrictlyScanning=function(){return this.stateManager.getState()===st.SCANNING},e.prototype.isPaused=function(){return this.stateManager.getState()===st.PAUSED},e}(),Fm=function(){function e(){}return e.create=function(){return new Lm(new Bm)},e}(),Um=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,c){l.__proto__=c}||function(l,c){for(var f in c)Object.prototype.hasOwnProperty.call(c,f)&&(l[f]=c[f])},e(t,i)};return function(t,i){if(typeof i!="function"&&i!==null)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");e(t,i);function l(){this.constructor=t}t.prototype=i===null?Object.create(i):(l.prototype=i.prototype,new l)}}(),nn=function(e){Um(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.DEFAULT_WIDTH=300,t.DEFAULT_WIDTH_OFFSET=2,t.FILE_SCAN_MIN_HEIGHT=300,t.FILE_SCAN_HIDDEN_CANVAS_PADDING=100,t.MIN_QR_BOX_SIZE=50,t.SHADED_LEFT=1,t.SHADED_RIGHT=2,t.SHADED_TOP=3,t.SHADED_BOTTOM=4,t.SHADED_REGION_ELEMENT_ID="qr-shaded-region",t.VERBOSE=!1,t.BORDER_SHADER_DEFAULT_COLOR="#ffffff",t.BORDER_SHADER_MATCH_COLOR="rgb(90, 193, 56)",t}(ym),Wm=function(){function e(t,i){this.logger=i,this.fps=nn.SCAN_DEFAULT_FPS,t?(t.fps&&(this.fps=t.fps),this.disableFlip=t.disableFlip===!0,this.qrbox=t.qrbox,this.aspectRatio=t.aspectRatio,this.videoConstraints=t.videoConstraints):this.disableFlip=nn.DEFAULT_DISABLE_FLIP}return e.prototype.isMediaStreamConstraintsValid=function(){return this.videoConstraints?Sh.isMediaStreamConstraintsValid(this.videoConstraints,this.logger):(this.logger.logError("Empty videoConstraints",!0),!1)},e.prototype.isShadedBoxEnabled=function(){return!Xn(this.qrbox)},e.create=function(t,i){return new e(t,i)},e}(),aw=function(){function e(t,i){if(this.element=null,this.canvasElement=null,this.scannerPausedUiElement=null,this.hasBorderShaders=null,this.borderShaders=null,this.qrMatch=null,this.renderedCamera=null,this.qrRegion=null,this.context=null,this.lastScanImageFile=null,this.isScanning=!1,!document.getElementById(t))throw"HTML Element with id=".concat(t," not found");this.elementId=t,this.verbose=!1;var l;typeof i=="boolean"?this.verbose=i===!0:i&&(l=i,this.verbose=l.verbose===!0,l.experimentalFeatures),this.logger=new Cm(this.verbose),this.qrcode=new Im(this.getSupportedFormats(i),this.getUseBarCodeDetectorIfSupported(l),this.verbose,this.logger),this.foreverScanTimeout,this.shouldScan=!0,this.stateManagerProxy=Fm.create()}return e.prototype.start=function(t,i,l,c){var f=this;if(!t)throw"cameraIdOrConfig is required";if(!l||typeof l!="function")throw"qrCodeSuccessCallback is required and should be a function.";var p;c?p=c:p=this.verbose?this.logger.log:function(){};var w=Wm.create(i,this.logger);this.clearElement();var C=!1;w.videoConstraints&&(w.isMediaStreamConstraintsValid()?C=!0:this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, it will be ignored.'",!0));var m=C,_=document.getElementById(this.elementId);_.clientWidth?_.clientWidth:nn.DEFAULT_WIDTH,_.style.position="relative",this.shouldScan=!0,this.element=_;var v=this,R=this.stateManagerProxy.startTransition(st.SCANNING);return new Promise(function(M,P){var B=m?w.videoConstraints:v.createVideoConstraints(t);if(!B){R.cancel(),P("videoConstraints should be defined");return}var K={};(!m||w.aspectRatio)&&(K.aspectRatio=w.aspectRatio);var O={onRenderSurfaceReady:function(T,N){v.setupUi(T,N,w),v.isScanning=!0,v.foreverScan(w,l,p)}};Dm.failIfNotSupported().then(function(T){T.create(B).then(function(N){return N.render(f.element,K,O).then(function(G){v.renderedCamera=G,R.execute(),M(null)}).catch(function(G){R.cancel(),P(G)})}).catch(function(N){R.cancel(),P(Ri.errorGettingUserMedia(N))})}).catch(function(T){R.cancel(),P(Ri.cameraStreamingNotSupported())})})},e.prototype.pause=function(t){if(!this.stateManagerProxy.isStrictlyScanning())throw"Cannot pause, scanner is not scanning.";this.stateManagerProxy.directTransition(st.PAUSED),this.showPausedState(),(Xn(t)||t!==!0)&&(t=!1),t&&this.renderedCamera&&this.renderedCamera.pause()},e.prototype.resume=function(){if(!this.stateManagerProxy.isPaused())throw"Cannot result, scanner is not paused.";if(!this.renderedCamera)throw"renderedCamera doesn't exist while trying resume()";var t=this,i=function(){t.stateManagerProxy.directTransition(st.SCANNING),t.hidePausedState()};if(!this.renderedCamera.isPaused()){i();return}this.renderedCamera.resume(function(){i()})},e.prototype.getState=function(){return this.stateManagerProxy.getState()},e.prototype.stop=function(){var t=this;if(!this.stateManagerProxy.isScanning())throw"Cannot stop, scanner is not running or paused.";var i=this.stateManagerProxy.startTransition(st.NOT_STARTED);this.shouldScan=!1,this.foreverScanTimeout&&clearTimeout(this.foreverScanTimeout);var l=function(){if(t.element){var f=document.getElementById(nn.SHADED_REGION_ELEMENT_ID);f&&t.element.removeChild(f)}},c=this;return this.renderedCamera.close().then(function(){return c.renderedCamera=null,c.element&&(c.element.removeChild(c.canvasElement),c.canvasElement=null),l(),c.qrRegion&&(c.qrRegion=null),c.context&&(c.context=null),i.execute(),c.hidePausedState(),c.isScanning=!1,Promise.resolve()})},e.prototype.scanFile=function(t,i){return this.scanFileV2(t,i).then(function(l){return l.decodedText})},e.prototype.scanFileV2=function(t,i){var l=this;if(!t||!(t instanceof File))throw"imageFile argument is mandatory and should be instance of File. Use 'event.target.files[0]'.";if(Xn(i)&&(i=!0),!this.stateManagerProxy.canScanFile())throw"Cannot start file scan - ongoing camera scan";return new Promise(function(c,f){l.possiblyCloseLastScanImageFile(),l.clearElement(),l.lastScanImageFile=URL.createObjectURL(t);var p=new Image;p.onload=function(){var w=p.width,C=p.height,m=document.getElementById(l.elementId),_=m.clientWidth?m.clientWidth:nn.DEFAULT_WIDTH,v=Math.max(m.clientHeight?m.clientHeight:C,nn.FILE_SCAN_MIN_HEIGHT),R=l.computeCanvasDrawConfig(w,C,_,v);if(i){var M=l.createCanvasElement(_,v,"qr-canvas-visible");M.style.display="inline-block",m.appendChild(M);var P=M.getContext("2d");if(!P)throw"Unable to get 2d context from canvas";P.canvas.width=_,P.canvas.height=v,P.drawImage(p,0,0,w,C,R.x,R.y,R.width,R.height)}var B=nn.FILE_SCAN_HIDDEN_CANVAS_PADDING,K=Math.max(p.width,R.width),O=Math.max(p.height,R.height),T=K+2*B,N=O+2*B,G=l.createCanvasElement(T,N);m.appendChild(G);var H=G.getContext("2d");if(!H)throw"Unable to get 2d context from canvas";H.canvas.width=T,H.canvas.height=N,H.drawImage(p,0,0,w,C,B,B,K,O);try{l.qrcode.decodeRobustlyAsync(G).then(function(U){c(B0.createFromQrcodeResult(U))}).catch(f)}catch(U){f("QR code parse error, error = ".concat(U))}},p.onerror=f,p.onabort=f,p.onstalled=f,p.onsuspend=f,p.src=URL.createObjectURL(t)})},e.prototype.clear=function(){this.clearElement()},e.getCameras=function(){return Pm.retrieve()},e.prototype.getRunningTrackCapabilities=function(){return this.getRenderedCameraOrFail().getRunningTrackCapabilities()},e.prototype.getRunningTrackSettings=function(){return this.getRenderedCameraOrFail().getRunningTrackSettings()},e.prototype.getRunningTrackCameraCapabilities=function(){return this.getRenderedCameraOrFail().getCapabilities()},e.prototype.applyVideoConstraints=function(t){if(t){if(!Sh.isMediaStreamConstraintsValid(t,this.logger))throw"invalid videoConstaints passed, check logs for more details"}else throw"videoConstaints is required argument.";return this.getRenderedCameraOrFail().applyVideoConstraints(t)},e.prototype.getRenderedCameraOrFail=function(){if(this.renderedCamera==null)throw"Scanning is not in running state, call this API only when QR code scanning using camera is in running state.";return this.renderedCamera},e.prototype.getSupportedFormats=function(t){var i=[te.QR_CODE,te.AZTEC,te.CODABAR,te.CODE_39,te.CODE_93,te.CODE_128,te.DATA_MATRIX,te.MAXICODE,te.ITF,te.EAN_13,te.EAN_8,te.PDF_417,te.RSS_14,te.RSS_EXPANDED,te.UPC_A,te.UPC_E,te.UPC_EAN_EXTENSION];if(!t||typeof t=="boolean"||!t.formatsToSupport)return i;if(!Array.isArray(t.formatsToSupport))throw"configOrVerbosityFlag.formatsToSupport should be undefined or an array.";if(t.formatsToSupport.length===0)throw"Atleast 1 formatsToSupport is needed.";for(var l=[],c=0,f=t.formatsToSupport;c<f.length;c++){var p=f[c];wm(p)?l.push(p):this.logger.warn("Invalid format: ".concat(p," passed in config, ignoring."))}if(l.length===0)throw"None of formatsToSupport match supported values.";return l},e.prototype.getUseBarCodeDetectorIfSupported=function(t){if(Xn(t))return!0;if(!Xn(t.useBarCodeDetectorIfSupported))return t.useBarCodeDetectorIfSupported!==!1;if(Xn(t.experimentalFeatures))return!0;var i=t.experimentalFeatures;return Xn(i.useBarCodeDetectorIfSupported)?!0:i.useBarCodeDetectorIfSupported!==!1},e.prototype.validateQrboxSize=function(t,i,l){var c=this,f=l.qrbox;this.validateQrboxConfig(f);var p=this.toQrdimensions(t,i,f),w=function(m){if(m<nn.MIN_QR_BOX_SIZE)throw"minimum size of 'config.qrbox' dimension value is"+" ".concat(nn.MIN_QR_BOX_SIZE,"px.")},C=function(m){return m>t&&(c.logger.warn("`qrbox.width` or `qrbox` is larger than the width of the root element. The width will be truncated to the width of root element."),m=t),m};w(p.width),w(p.height),p.width=C(p.width)},e.prototype.validateQrboxConfig=function(t){if(typeof t!="number"&&typeof t!="function"&&(t.width===void 0||t.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},e.prototype.toQrdimensions=function(t,i,l){if(typeof l=="number")return{width:l,height:l};if(typeof l=="function")try{return l(t,i)}catch(c){throw new Error("qrbox config was passed as a function but it failed with unknown error"+c)}return l},e.prototype.setupUi=function(t,i,l){l.isShadedBoxEnabled()&&this.validateQrboxSize(t,i,l);var c=Xn(l.qrbox)?{width:t,height:i}:l.qrbox;this.validateQrboxConfig(c);var f=this.toQrdimensions(t,i,c);f.height>i&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var p=l.isShadedBoxEnabled()&&f.height<=i,w={x:0,y:0,width:t,height:i},C=p?this.getShadedRegionBounds(t,i,f):w,m=this.createCanvasElement(C.width,C.height),_={willReadFrequently:!0},v=m.getContext("2d",_);v.canvas.width=C.width,v.canvas.height=C.height,this.element.append(m),p&&this.possiblyInsertShadingElement(this.element,t,i,f),this.createScannerPausedUiElement(this.element),this.qrRegion=C,this.context=v,this.canvasElement=m},e.prototype.createScannerPausedUiElement=function(t){var i=document.createElement("div");i.innerText=Ri.scannerPaused(),i.style.display="none",i.style.position="absolute",i.style.top="0px",i.style.zIndex="1",i.style.background="rgba(9, 9, 9, 0.46)",i.style.color="#FFECEC",i.style.textAlign="center",i.style.width="100%",t.appendChild(i),this.scannerPausedUiElement=i},e.prototype.scanContext=function(t,i){var l=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(c){return t(c.text,B0.createFromQrcodeResult(c)),l.possiblyUpdateShaders(!0),!0}).catch(function(c){l.possiblyUpdateShaders(!1);var f=Ri.codeParseError(c);return i(f,Em.createFrom(f)),!1})},e.prototype.foreverScan=function(t,i,l){var c=this;if(this.shouldScan&&this.renderedCamera){var f=this.renderedCamera.getSurface(),p=f.videoWidth/f.clientWidth,w=f.videoHeight/f.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var C=this.qrRegion.width*p,m=this.qrRegion.height*w,_=this.qrRegion.x*p,v=this.qrRegion.y*w;this.context.drawImage(f,_,v,C,m,0,0,this.qrRegion.width,this.qrRegion.height);var R=function(){c.foreverScanTimeout=setTimeout(function(){c.foreverScan(t,i,l)},c.getTimeoutFps(t.fps))};this.scanContext(i,l).then(function(M){!M&&t.disableFlip!==!0?(c.context.translate(c.context.canvas.width,0),c.context.scale(-1,1),c.scanContext(i,l).finally(function(){R()})):R()}).catch(function(M){c.logger.logError("Error happend while scanning context",M),R()})}},e.prototype.createVideoConstraints=function(t){if(typeof t=="string")return{deviceId:{exact:t}};if(typeof t=="object"){var i="facingMode",l="deviceId",c={user:!0,environment:!0},f="exact",p=function(P){if(P in c)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(P,"'")},w=Object.keys(t);if(w.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(w.length," keys");var C=Object.keys(t)[0];if(C!==i&&C!==l)throw"Only '".concat(i,"' and '").concat(l,"' ")+" are supported for 'cameraIdOrConfig'";if(C===i){var m=t.facingMode;if(typeof m=="string"){if(p(m))return{facingMode:m}}else if(typeof m=="object")if(f in m){if(p(m["".concat(f)]))return{facingMode:{exact:m["".concat(f)]}}}else throw"'facingMode' should be string or object with"+" ".concat(f," as key.");else{var _=typeof m;throw"Invalid type of 'facingMode' = ".concat(_)}}else{var v=t.deviceId;if(typeof v=="string")return{deviceId:v};if(typeof v=="object"){if(f in v)return{deviceId:{exact:v["".concat(f)]}};throw"'deviceId' should be string or object with"+" ".concat(f," as key.")}else{var R=typeof v;throw"Invalid type of 'deviceId' = ".concat(R)}}}var M=typeof t;throw"Invalid type of 'cameraIdOrConfig' = ".concat(M)},e.prototype.computeCanvasDrawConfig=function(t,i,l,c){if(t<=l&&i<=c){var f=(l-t)/2,p=(c-i)/2;return{x:f,y:p,width:t,height:i}}else{var w=t,C=i;return t>l&&(i=l/t*i,t=l),i>c&&(t=c/i*t,i=c),this.logger.log("Image downsampled from "+"".concat(w,"X").concat(C)+" to ".concat(t,"X").concat(i,".")),this.computeCanvasDrawConfig(t,i,l,c)}},e.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var t=document.getElementById(this.elementId);t&&(t.innerHTML="")},e.prototype.possiblyUpdateShaders=function(t){this.qrMatch!==t&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(i){i.style.backgroundColor=t?nn.BORDER_SHADER_MATCH_COLOR:nn.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=t)},e.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},e.prototype.createCanvasElement=function(t,i,l){var c=t,f=i,p=document.createElement("canvas");return p.style.width="".concat(c,"px"),p.style.height="".concat(f,"px"),p.style.display="none",p.id=Xn(l)?"qr-canvas":l,p},e.prototype.getShadedRegionBounds=function(t,i,l){if(l.width>t||l.height>i)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(t-l.width)/2,y:(i-l.height)/2,width:l.width,height:l.height}},e.prototype.possiblyInsertShadingElement=function(t,i,l,c){if(!(i-c.width<1||l-c.height<1)){var f=document.createElement("div");f.style.position="absolute";var p=(i-c.width)/2,w=(l-c.height)/2;if(f.style.borderLeft="".concat(p,"px solid rgba(0, 0, 0, 0.48)"),f.style.borderRight="".concat(p,"px solid rgba(0, 0, 0, 0.48)"),f.style.borderTop="".concat(w,"px solid rgba(0, 0, 0, 0.48)"),f.style.borderBottom="".concat(w,"px solid rgba(0, 0, 0, 0.48)"),f.style.boxSizing="border-box",f.style.top="0px",f.style.bottom="0px",f.style.left="0px",f.style.right="0px",f.id="".concat(nn.SHADED_REGION_ELEMENT_ID),i-c.width<11||l-c.height<11)this.hasBorderShaders=!1;else{var C=5,m=40;this.insertShaderBorders(f,m,C,-C,null,0,!0),this.insertShaderBorders(f,m,C,-C,null,0,!1),this.insertShaderBorders(f,m,C,null,-C,0,!0),this.insertShaderBorders(f,m,C,null,-C,0,!1),this.insertShaderBorders(f,C,m+C,-C,null,-C,!0),this.insertShaderBorders(f,C,m+C,null,-C,-C,!0),this.insertShaderBorders(f,C,m+C,-C,null,-C,!1),this.insertShaderBorders(f,C,m+C,null,-C,-C,!1),this.hasBorderShaders=!0}t.append(f)}},e.prototype.insertShaderBorders=function(t,i,l,c,f,p,w){var C=document.createElement("div");C.style.position="absolute",C.style.backgroundColor=nn.BORDER_SHADER_DEFAULT_COLOR,C.style.width="".concat(i,"px"),C.style.height="".concat(l,"px"),c!==null&&(C.style.top="".concat(c,"px")),f!==null&&(C.style.bottom="".concat(f,"px")),w?C.style.left="".concat(p,"px"):C.style.right="".concat(p,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(C),t.appendChild(C)},e.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},e.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},e.prototype.getTimeoutFps=function(t){return 1e3/t},e}(),H0;(function(e){e[e.STATUS_DEFAULT=0]="STATUS_DEFAULT",e[e.STATUS_SUCCESS=1]="STATUS_SUCCESS",e[e.STATUS_WARNING=2]="STATUS_WARNING",e[e.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"})(H0||(H0={}));var Fu;(function(e){e[e.BACK=1]="BACK",e[e.FRONT=2]="FRONT"})(Fu||(Fu={}));var Uu;(function(e){e[e.PORTRAIT=1]="PORTRAIT",e[e.LANDSCAPE=2]="LANDSCAPE",e[e.ADAPTIVE=3]="ADAPTIVE"})(Uu||(Uu={}));var Wu;(function(e){e[e.ALL=17]="ALL"})(Wu||(Wu={}));const zm=Object.assign(Object.assign({},te),Wu);var j0;(function(e){e.ZXING="zxing",e.MLKIT="mlkit"})(j0||(j0={}));const Vm=[{selector:".scanner-container-display",css:"display: block;"},{selector:".scanner-dialog",css:"display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4);"},{selector:".scanner-dialog-inner",css:"background-color: #fefefe; margin: 2% auto; padding: 20px; border: 1px solid #888; width: 96%;"},{selector:".close-button",css:"color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer;"},{selector:".close-button:hover",css:"color: #222;"},{selector:".scanner-container-full-width",css:"width: 100%;"}];function Hm(e){const t="custom-style-os-cap-barcode";let i=document.getElementById(t);if(i||(i=document.createElement("style"),i.type="text/css",i.id=t,document.head.appendChild(i)),i.sheet){for(;i.sheet.cssRules.length;)i.sheet.deleteRule(0);for(const{selector:l,css:c}of e)i.sheet.insertRule(`${l} { ${c} }`)}else{i.textContent="";for(const{selector:l,css:c}of e)i.textContent+=`${l} { ${c} }`}}const jm=Va("CapacitorBarcodeScanner",{web:()=>(Hm(Vm),qu(()=>import("./web-ueoOhAeL.js"),[],import.meta.url).then(e=>new e.CapacitorBarcodeScannerWeb))});class Gm{static async scanBarcode(t){return t.scanInstructions=t.scanInstructions||" ",t.scanButton=t.scanButton||!1,t.scanText=t.scanText||" ",t.cameraDirection=t.cameraDirection||Fu.BACK,t.scanOrientation=t.scanOrientation||Uu.ADAPTIVE,jm.scanBarcode(t)}}const zl=Va("SecureStoragePlugin",{web:()=>qu(()=>import("./web-DWyw2SAG.js"),[],import.meta.url).then(e=>new e.SecureStoragePluginWeb)});function Xm(e){try{if(e.length>2048)throw new Error;if(!e.startsWith("{")){const c=new URL(e);if(!["http:","https:"].includes(c.protocol)||c.username||c.password||c.pathname!=="/pair"||c.search||!/^#pair=[A-Za-z0-9_-]{43}$/.test(c.hash))throw new Error;const f=br.parse(c.origin);if(!f)throw new Error;return{endpoint:f,grant:c.hash.slice(6)}}const t=JSON.parse(e);if(t.type!=="agentroam-pair"||t.version!==1||typeof t.server!="string"||typeof t.grant!="string"||!/^[A-Za-z0-9_-]{43}$/.test(t.grant))throw new Error;const i=new URL(t.server);if(i.username||i.password||i.search||i.hash||i.pathname!=="/")throw new Error;const l=br.parse(t.server);if(!l)throw new Error;return{endpoint:l,grant:t.grant}}catch{throw new Error("这不是 AgentRoam 授权二维码,请扫描电脑终端上新生成的二维码。")}}class Ym{ready(){if(!$s.isNativePlatform())throw new Error("请在 AgentRoam App 中扫码连接。")}async get(t){this.ready();try{return(await zl.get({key:`agentroam-device:${t}`})).value}catch(i){if(String(i).includes("does not exist"))return null;throw new Error("无法读取设备凭证,请重试。")}}async set(t,i){this.ready(),await zl.set({key:`agentroam-device:${t}`,value:i})}async remove(t){this.ready();try{await zl.remove({key:`agentroam-device:${t}`})}catch(i){if(!String(i).includes("does not exist"))throw i}}}async function Zm(){if(!$s.isNativePlatform())throw new Error("请在 AgentRoam App 中使用相机扫码。");try{return(await Gm.scanBarcode({hint:zm.QR_CODE,scanInstructions:"扫描电脑上的 AgentRoam 授权二维码",cameraDirection:1})).ScanResult||null}catch(e){if(/cancel/i.test(String(e)))return null;throw new Error("无法打开相机,请在系统设置中允许 AgentRoam 使用相机后重试。")}}class Km{constructor(t,i=(...c)=>fetch(...c),l=()=>window.dispatchEvent(new CustomEvent("webapp:unauthorized"))){this.storage=t,this.transport=i,this.onRevoked=l,this.session=null,this.fetch=async(c,f={})=>{const p=this.session,w=new URL(typeof c=="string"?c:c instanceof URL?c.href:c.url),C=new Headers(f.headers??(c instanceof Request?c.headers:void 0));p&&w.origin===p.origin&&C.set("authorization",`Bearer ${p.token}`);const m=await this.transport(c,{...f,headers:C,credentials:"omit",redirect:"error"});if(p&&this.session===p&&w.origin===p.origin&&(m.status===401||m.status===423)){this.session=null;try{await this.storage.remove(p.origin)}finally{this.onRevoked()}}return m}}async resume(t){const i=await this.storage.get(t.url);this.session=i?{origin:t.url,token:i}:null}async pair(t){const{endpoint:i,grant:l}=Xm(t),c=await this.transport(i.api("/api/pairing/qr-exchange"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({grant:l,name:"我的 App"}),credentials:"omit",redirect:"error",signal:AbortSignal.timeout(1e4)});if(!c.ok)throw new Error(c.status===423?"电脑已锁定远程访问,请先在电脑上解锁。":c.status===410?"二维码已使用或已过期,请在电脑上重新生成。":"扫码连接失败,请检查服务器地址和网络后重试。");const f=await c.json();if(typeof f.token!="string"||!/^[A-Za-z0-9_-]{43}$/.test(f.token))throw new Error("服务器返回了无效的设备凭证。");try{await this.storage.set(i.url,f.token)}catch{throw await this.transport(i.api("/api/pairing/logout"),{method:"POST",headers:{authorization:`Bearer ${f.token}`},credentials:"omit",redirect:"error",signal:AbortSignal.timeout(5e3)}).catch(()=>{}),new Error("无法安全保存设备凭证,请在电脑上重新生成二维码后重试。")}return this.session={origin:i.url,token:f.token},i}async checkAuthorization(){const t=this.session;if(!t)return;const i=await this.fetch(`${t.origin}/api/web-auth/status`,{signal:AbortSignal.timeout(5e3)});if(!i.ok)return;const l=await i.json();if(this.session===t&&(l.locked||l.authenticated===!1)){this.session=null;try{await this.storage.remove(t.origin)}finally{this.onRevoked()}}}}class Vl extends Error{constructor(t,i){super(t),this.name="ParseError",this.type=i.type,this.field=i.field,this.value=i.value,this.line=i.line}}const G0=10,Qm=13,zr=32;function Hl(e){}function qm(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:t=Hl,onError:i=Hl,onRetry:l=Hl,onComment:c,maxBufferSize:f}=e,p=[];let w=0,C=!0,m,_="",v=0,R,M=!1;function P(H){if(M)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(C&&(C=!1,H.charCodeAt(0)===239&&H.charCodeAt(1)===187&&H.charCodeAt(2)===191&&(H=H.slice(3))),p.length===0){const X=K(H);X!==""&&(p.push(X),w=X.length),B();return}if(H.indexOf(`
79
79
  `)===-1&&H.indexOf("\r")===-1){p.push(H),w+=H.length,B();return}p.push(H);const U=p.join("");p.length=0,w=0;const k=K(U);k!==""&&(p.push(k),w=k.length),B()}function B(){f!==void 0&&(w+_.length<=f||(M=!0,p.length=0,w=0,m=void 0,_="",v=0,R=void 0,i(new Vl(`Buffered data exceeded max buffer size of ${f} characters`,{type:"max-buffer-size-exceeded"}))))}function K(H){let U=0;if(H.indexOf("\r")===-1){let k=H.indexOf(`
80
80
  `,U);for(;k!==-1;){if(U===k){v>0&&t({id:m,event:R,data:_}),m=void 0,_="",v=0,R=void 0,U=k+1,k=H.indexOf(`
81
81
  `,U);continue}const X=H.charCodeAt(U);if(X0(H,U,X)){const V=H.charCodeAt(U+5)===zr?U+6:U+5,se=H.slice(V,k);if(v===0&&H.charCodeAt(k+1)===G0){t({id:m,event:R,data:se}),m=void 0,_="",R=void 0,U=k+2,k=H.indexOf(`
@@ -84,4 +84,4 @@ ${se}`,v++}else Y0(H,U,X)?R=H.slice(H.charCodeAt(U+6)===zr?U+7:U+6,k)||void 0:O(
84
84
  `,U)}return H.slice(U)}for(;U<H.length;){const k=H.indexOf("\r",U),X=H.indexOf(`
85
85
  `,U);let V=-1;if(k!==-1&&X!==-1?V=k<X?k:X:k!==-1?k===H.length-1?V=-1:V=k:X!==-1&&(V=X),V===-1)break;O(H,U,V),U=V+1,H.charCodeAt(U-1)===Qm&&H.charCodeAt(U)===G0&&U++}return H.slice(U)}function O(H,U,k){if(U===k){N();return}const X=H.charCodeAt(U);if(X0(H,U,X)){const _e=H.charCodeAt(U+5)===zr?U+6:U+5,j=H.slice(_e,k);_=v===0?j:`${_}
86
86
  ${j}`,v++;return}if(Y0(H,U,X)){R=H.slice(H.charCodeAt(U+6)===zr?U+7:U+6,k)||void 0;return}if(X===105&&H.charCodeAt(U+1)===100&&H.charCodeAt(U+2)===58){const _e=H.slice(H.charCodeAt(U+3)===zr?U+4:U+3,k);_e.includes("\0")||(m=_e);return}if(X===58){if(c){const _e=H.slice(U,k);c(_e.slice(H.charCodeAt(U+1)===zr?2:1))}return}const V=H.slice(U,k),se=V.indexOf(":");if(se===-1){T(V,"",V);return}const Ee=V.slice(0,se),ie=V.charCodeAt(se+1)===zr?2:1,ge=V.slice(se+ie);T(Ee,ge,V)}function T(H,U,k){switch(H){case"event":R=U||void 0;break;case"data":_=v===0?U:`${_}
87
- ${U}`,v++;break;case"id":U.includes("\0")||(m=U);break;case"retry":/^\d+$/.test(U)?l(parseInt(U,10)):i(new Vl(`Invalid \`retry\` value: "${U}"`,{type:"invalid-retry",value:U,line:k}));break;default:i(new Vl(`Unknown field "${H.length>20?`${H.slice(0,20)}…`:H}"`,{type:"unknown-field",field:H,value:U,line:k}));break}}function N(){v>0&&t({id:m,event:R,data:_}),m=void 0,_="",v=0,R=void 0}function G(H={}){if(H.consume&&p.length>0){const U=p.join("");O(U,0,U.length)}C=!0,m=void 0,_="",v=0,R=void 0,p.length=0,w=0,M=!1}return{feed:P,reset:G}}function X0(e,t,i){return i===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function Y0(e,t,i){return i===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}class Z0 extends Event{constructor(t,i){var l,c;super(t),this.code=(l=i==null?void 0:i.code)!=null?l:void 0,this.message=(c=i==null?void 0:i.message)!=null?c:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,i,l){return l(K0(this),i)}[Symbol.for("Deno.customInspect")](t,i){return t(K0(this),i)}}function $m(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function zu(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(zu).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${zu(e.cause)}`:e.message:`${e}`}function K0(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var _h=e=>{throw TypeError(e)},Yc=(e,t,i)=>t.has(e)||_h("Cannot "+i),Ce=(e,t,i)=>(Yc(e,t,"read from private field"),i?i.call(e):t.get(e)),gt=(e,t,i)=>t.has(e)?_h("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),Ye=(e,t,i,l)=>(Yc(e,t,"write to private field"),t.set(e,i),i),Yn=(e,t,i)=>(Yc(e,t,"access private method"),i),Kt,jr,gi,Ko,Sa,Ds,bi,Ms,mr,pi,Li,xi,Cs,In,Vu,Hu,ju,Q0,Gu,Xu,As,Yu,Zu;let Qo=class extends EventTarget{constructor(t,i){var l,c;super(),gt(this,In),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,gt(this,Kt),gt(this,jr),gt(this,gi),gt(this,Ko),gt(this,Sa),gt(this,Ds),gt(this,bi),gt(this,Ms,null),gt(this,mr),gt(this,pi),gt(this,Li,null),gt(this,xi,null),gt(this,Cs,null),gt(this,Hu,async f=>{var p;Ce(this,pi).reset();const{body:w,redirected:C,status:m,headers:_}=f;if(m===204){Yn(this,In,As).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(C?Ye(this,gi,new URL(f.url)):Ye(this,gi,void 0),m!==200){Yn(this,In,As).call(this,`Non-200 status code (${m})`,m);return}if(!(_.get("content-type")||"").startsWith("text/event-stream")){Yn(this,In,As).call(this,'Invalid content type, expected "text/event-stream"',m);return}if(Ce(this,Kt)===this.CLOSED)return;Ye(this,Kt,this.OPEN);const v=new Event("open");if((p=Ce(this,Cs))==null||p.call(this,v),this.dispatchEvent(v),typeof w!="object"||!w||!("getReader"in w)){Yn(this,In,As).call(this,"Invalid response body, expected a web ReadableStream",m),this.close();return}const R=new TextDecoder,M=w.getReader();let P=!0;do{const{done:B,value:K}=await M.read();K&&Ce(this,pi).feed(R.decode(K,{stream:!B})),B&&(P=!1,Ce(this,pi).reset(),Yn(this,In,Yu).call(this))}while(P)}),gt(this,ju,f=>{Ye(this,mr,void 0),!(f.name==="AbortError"||f.type==="aborted")&&Yn(this,In,Yu).call(this,zu(f))}),gt(this,Gu,f=>{typeof f.id=="string"&&Ye(this,Ms,f.id);const p=new MessageEvent(f.event||"message",{data:f.data,origin:Ce(this,gi)?Ce(this,gi).origin:Ce(this,jr).origin,lastEventId:f.id||""});Ce(this,xi)&&(!f.event||f.event==="message")&&Ce(this,xi).call(this,p),this.dispatchEvent(p)}),gt(this,Xu,f=>{Ye(this,Ds,f)}),gt(this,Zu,()=>{Ye(this,bi,void 0),Ce(this,Kt)===this.CONNECTING&&Yn(this,In,Vu).call(this)});try{if(t instanceof URL)Ye(this,jr,t);else if(typeof t=="string")Ye(this,jr,new URL(t,Jm()));else throw new Error("Invalid URL")}catch{throw $m("An invalid or illegal string was specified")}Ye(this,pi,qm({onEvent:Ce(this,Gu),onRetry:Ce(this,Xu)})),Ye(this,Kt,this.CONNECTING),Ye(this,Ds,3e3),Ye(this,Sa,(l=i==null?void 0:i.fetch)!=null?l:globalThis.fetch),Ye(this,Ko,(c=i==null?void 0:i.withCredentials)!=null?c:!1),Yn(this,In,Vu).call(this)}get readyState(){return Ce(this,Kt)}get url(){return Ce(this,jr).href}get withCredentials(){return Ce(this,Ko)}get onerror(){return Ce(this,Li)}set onerror(t){Ye(this,Li,t)}get onmessage(){return Ce(this,xi)}set onmessage(t){Ye(this,xi,t)}get onopen(){return Ce(this,Cs)}set onopen(t){Ye(this,Cs,t)}addEventListener(t,i,l){const c=i;super.addEventListener(t,c,l)}removeEventListener(t,i,l){const c=i;super.removeEventListener(t,c,l)}close(){Ce(this,bi)&&clearTimeout(Ce(this,bi)),Ce(this,Kt)!==this.CLOSED&&(Ce(this,mr)&&Ce(this,mr).abort(),Ye(this,Kt,this.CLOSED),Ye(this,mr,void 0))}};Kt=new WeakMap,jr=new WeakMap,gi=new WeakMap,Ko=new WeakMap,Sa=new WeakMap,Ds=new WeakMap,bi=new WeakMap,Ms=new WeakMap,mr=new WeakMap,pi=new WeakMap,Li=new WeakMap,xi=new WeakMap,Cs=new WeakMap,In=new WeakSet,Vu=function(){Ye(this,Kt,this.CONNECTING),Ye(this,mr,new AbortController),Ce(this,Sa)(Ce(this,jr),Yn(this,In,Q0).call(this)).then(Ce(this,Hu)).catch(Ce(this,ju))},Hu=new WeakMap,ju=new WeakMap,Q0=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Ce(this,Ms)?{"Last-Event-ID":Ce(this,Ms)}:void 0},cache:"no-store",signal:(e=Ce(this,mr))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},Gu=new WeakMap,Xu=new WeakMap,As=function(e,t){var i;Ce(this,Kt)!==this.CLOSED&&Ye(this,Kt,this.CLOSED);const l=new Z0("error",{code:t,message:e});(i=Ce(this,Li))==null||i.call(this,l),this.dispatchEvent(l)},Yu=function(e,t){var i;if(Ce(this,Kt)===this.CLOSED)return;Ye(this,Kt,this.CONNECTING);const l=new Z0("error",{code:t,message:e});(i=Ce(this,Li))==null||i.call(this,l),this.dispatchEvent(l),Ye(this,bi,setTimeout(Ce(this,Zu),Ce(this,Ds)))},Zu=new WeakMap,Qo.CONNECTING=0,Qo.OPEN=1,Qo.CLOSED=2;function Jm(){const e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}Yp();qp();Lx();Wx();document.body.dataset.webShell="1";const Zc=new im;if(!Zc.isNativeApp()&&window.parent===window){const e=document.createElement("link");e.rel="manifest",e.href="/manifest.webmanifest",document.head.append(e);const t=document.querySelector('link[rel="apple-touch-icon"]');t&&(t.href="/pwa/icon-192.png");const i=document.createElement("script");i.src="/pwa/install.js",document.head.append(i)}const Pt=Zc.isNativeApp()?new Km(new Ym):null,Th=new Up(Pt==null?void 0:Pt.fetch),ew=window.parent===window?void 0:new Yx,tw=window.parent===window?void 0:new nm;let Ku="";const q0=new Hp(Th,new jp,ew,e=>Pt?new Qo(Ku+e,{fetch:Pt.fetch}):new EventSource(Ku+e));window.browserLiveApi=tw;const Nh=document.getElementById("root");if(!Nh)throw new Error("#root missing");const Qu=hh(Nh);function nw(){return Ct.useEffect(()=>{Vx()},[]),null}(async()=>{Pt&&window.addEventListener("webapp:unauthorized",()=>location.reload());const e=new rm(Zc,new O0,new om(Pt?async(i,l)=>{const c=br.parse(String(i));return c&&await Pt.resume(c),Pt.fetch(i,l)}:void 0)),t=await e.planStartup();if(t.mode==="setup"){Qu.render(ue.jsx(lm,{service:e,savedEndpoint:t.endpoint,initialFailure:t.failure,onScan:Pt?async()=>{const i=await Zm();if(!i)return null;const l=await Pt.pair(i);return new O0().save(l),l}:void 0,onConnected:i=>void $0(i)}));return}await $0(t.mode==="ready"?t.endpoint:null)})();async function $0(e){try{e&&(await(Pt==null?void 0:Pt.resume(e)),Th.setBaseUrl(e.url),Ku=e.url),window.agentApi=q0,await q0.refreshServerModel();const{default:t}=await qu(async()=>{const{default:i}=await import("./App-Cw8L8wC7.js");return{default:i}},__vite__mapDeps([0,1]),import.meta.url);Qu.render(ue.jsxs(Ct.StrictMode,{children:[ue.jsx(bg.Provider,{value:ue.jsx(Og,{}),children:ue.jsx(t,{})}),ue.jsx(nw,{})]})),Pt&&setInterval(()=>{Pt.checkAuthorization().catch(()=>{})},1e4),e||(window.addEventListener("webapp:unauthorized",()=>location.reload()),rw())}catch(t){Qu.render(ue.jsx("div",{style:{minHeight:"100dvh",display:"flex",alignItems:"center",justifyContent:"center",padding:24,background:"#f5f6fa",boxSizing:"border-box"},children:ue.jsxs("div",{style:{maxWidth:560,background:"#fff",borderRadius:12,padding:20,boxShadow:"0 4px 16px rgba(0,0,0,0.08)"},children:[ue.jsx("h2",{style:{margin:"0 0 8px",fontSize:16,color:"#dc2626"},children:"界面启动失败"}),ue.jsx("p",{style:{margin:"0 0 12px",fontSize:13,color:"#374151",wordBreak:"break-all"},children:t instanceof Error?`${t.name}: ${t.message}`:String(t)}),ue.jsx("button",{type:"button",onClick:()=>location.reload(),style:{padding:"8px 20px",fontSize:14,borderRadius:8,border:"1px solid #d6d9e0",background:"#fff",cursor:"pointer"},children:"重试"})]})}))}}function rw(){const e=[...document.scripts].map(i=>i.src).join(",").match(/index-([^/]+)\.js/),t=e?e[1]:null;t&&setInterval(async()=>{try{const i=await fetch("/api/agent/model",{credentials:"same-origin",cache:"no-store"});if(i.status===401||i.status===423){location.reload();return}const c=((await i.json()).buildId||"").replace(/^index-|\.js$/g,"");c&&c!==t&&location.reload()}catch{}},6e4)}export{bg as B,Uu as C,aw as H,ow as L,Fx as O,vg as R,sw as S,Ah as W,qu as _,zm as a,Bp as b,ls as c,Sx as d,iw as e,J0 as g,Ox as i,ue as j,Ct as r,kx as u};
87
+ ${U}`,v++;break;case"id":U.includes("\0")||(m=U);break;case"retry":/^\d+$/.test(U)?l(parseInt(U,10)):i(new Vl(`Invalid \`retry\` value: "${U}"`,{type:"invalid-retry",value:U,line:k}));break;default:i(new Vl(`Unknown field "${H.length>20?`${H.slice(0,20)}…`:H}"`,{type:"unknown-field",field:H,value:U,line:k}));break}}function N(){v>0&&t({id:m,event:R,data:_}),m=void 0,_="",v=0,R=void 0}function G(H={}){if(H.consume&&p.length>0){const U=p.join("");O(U,0,U.length)}C=!0,m=void 0,_="",v=0,R=void 0,p.length=0,w=0,M=!1}return{feed:P,reset:G}}function X0(e,t,i){return i===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function Y0(e,t,i){return i===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}class Z0 extends Event{constructor(t,i){var l,c;super(t),this.code=(l=i==null?void 0:i.code)!=null?l:void 0,this.message=(c=i==null?void 0:i.message)!=null?c:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,i,l){return l(K0(this),i)}[Symbol.for("Deno.customInspect")](t,i){return t(K0(this),i)}}function $m(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function zu(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(zu).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${zu(e.cause)}`:e.message:`${e}`}function K0(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var _h=e=>{throw TypeError(e)},Yc=(e,t,i)=>t.has(e)||_h("Cannot "+i),Ce=(e,t,i)=>(Yc(e,t,"read from private field"),i?i.call(e):t.get(e)),gt=(e,t,i)=>t.has(e)?_h("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),Ye=(e,t,i,l)=>(Yc(e,t,"write to private field"),t.set(e,i),i),Yn=(e,t,i)=>(Yc(e,t,"access private method"),i),Kt,jr,gi,Ko,Sa,Ds,bi,Ms,mr,pi,Li,xi,Cs,In,Vu,Hu,ju,Q0,Gu,Xu,As,Yu,Zu;let Qo=class extends EventTarget{constructor(t,i){var l,c;super(),gt(this,In),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,gt(this,Kt),gt(this,jr),gt(this,gi),gt(this,Ko),gt(this,Sa),gt(this,Ds),gt(this,bi),gt(this,Ms,null),gt(this,mr),gt(this,pi),gt(this,Li,null),gt(this,xi,null),gt(this,Cs,null),gt(this,Hu,async f=>{var p;Ce(this,pi).reset();const{body:w,redirected:C,status:m,headers:_}=f;if(m===204){Yn(this,In,As).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(C?Ye(this,gi,new URL(f.url)):Ye(this,gi,void 0),m!==200){Yn(this,In,As).call(this,`Non-200 status code (${m})`,m);return}if(!(_.get("content-type")||"").startsWith("text/event-stream")){Yn(this,In,As).call(this,'Invalid content type, expected "text/event-stream"',m);return}if(Ce(this,Kt)===this.CLOSED)return;Ye(this,Kt,this.OPEN);const v=new Event("open");if((p=Ce(this,Cs))==null||p.call(this,v),this.dispatchEvent(v),typeof w!="object"||!w||!("getReader"in w)){Yn(this,In,As).call(this,"Invalid response body, expected a web ReadableStream",m),this.close();return}const R=new TextDecoder,M=w.getReader();let P=!0;do{const{done:B,value:K}=await M.read();K&&Ce(this,pi).feed(R.decode(K,{stream:!B})),B&&(P=!1,Ce(this,pi).reset(),Yn(this,In,Yu).call(this))}while(P)}),gt(this,ju,f=>{Ye(this,mr,void 0),!(f.name==="AbortError"||f.type==="aborted")&&Yn(this,In,Yu).call(this,zu(f))}),gt(this,Gu,f=>{typeof f.id=="string"&&Ye(this,Ms,f.id);const p=new MessageEvent(f.event||"message",{data:f.data,origin:Ce(this,gi)?Ce(this,gi).origin:Ce(this,jr).origin,lastEventId:f.id||""});Ce(this,xi)&&(!f.event||f.event==="message")&&Ce(this,xi).call(this,p),this.dispatchEvent(p)}),gt(this,Xu,f=>{Ye(this,Ds,f)}),gt(this,Zu,()=>{Ye(this,bi,void 0),Ce(this,Kt)===this.CONNECTING&&Yn(this,In,Vu).call(this)});try{if(t instanceof URL)Ye(this,jr,t);else if(typeof t=="string")Ye(this,jr,new URL(t,Jm()));else throw new Error("Invalid URL")}catch{throw $m("An invalid or illegal string was specified")}Ye(this,pi,qm({onEvent:Ce(this,Gu),onRetry:Ce(this,Xu)})),Ye(this,Kt,this.CONNECTING),Ye(this,Ds,3e3),Ye(this,Sa,(l=i==null?void 0:i.fetch)!=null?l:globalThis.fetch),Ye(this,Ko,(c=i==null?void 0:i.withCredentials)!=null?c:!1),Yn(this,In,Vu).call(this)}get readyState(){return Ce(this,Kt)}get url(){return Ce(this,jr).href}get withCredentials(){return Ce(this,Ko)}get onerror(){return Ce(this,Li)}set onerror(t){Ye(this,Li,t)}get onmessage(){return Ce(this,xi)}set onmessage(t){Ye(this,xi,t)}get onopen(){return Ce(this,Cs)}set onopen(t){Ye(this,Cs,t)}addEventListener(t,i,l){const c=i;super.addEventListener(t,c,l)}removeEventListener(t,i,l){const c=i;super.removeEventListener(t,c,l)}close(){Ce(this,bi)&&clearTimeout(Ce(this,bi)),Ce(this,Kt)!==this.CLOSED&&(Ce(this,mr)&&Ce(this,mr).abort(),Ye(this,Kt,this.CLOSED),Ye(this,mr,void 0))}};Kt=new WeakMap,jr=new WeakMap,gi=new WeakMap,Ko=new WeakMap,Sa=new WeakMap,Ds=new WeakMap,bi=new WeakMap,Ms=new WeakMap,mr=new WeakMap,pi=new WeakMap,Li=new WeakMap,xi=new WeakMap,Cs=new WeakMap,In=new WeakSet,Vu=function(){Ye(this,Kt,this.CONNECTING),Ye(this,mr,new AbortController),Ce(this,Sa)(Ce(this,jr),Yn(this,In,Q0).call(this)).then(Ce(this,Hu)).catch(Ce(this,ju))},Hu=new WeakMap,ju=new WeakMap,Q0=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Ce(this,Ms)?{"Last-Event-ID":Ce(this,Ms)}:void 0},cache:"no-store",signal:(e=Ce(this,mr))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},Gu=new WeakMap,Xu=new WeakMap,As=function(e,t){var i;Ce(this,Kt)!==this.CLOSED&&Ye(this,Kt,this.CLOSED);const l=new Z0("error",{code:t,message:e});(i=Ce(this,Li))==null||i.call(this,l),this.dispatchEvent(l)},Yu=function(e,t){var i;if(Ce(this,Kt)===this.CLOSED)return;Ye(this,Kt,this.CONNECTING);const l=new Z0("error",{code:t,message:e});(i=Ce(this,Li))==null||i.call(this,l),this.dispatchEvent(l),Ye(this,bi,setTimeout(Ce(this,Zu),Ce(this,Ds)))},Zu=new WeakMap,Qo.CONNECTING=0,Qo.OPEN=1,Qo.CLOSED=2;function Jm(){const e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}Yp();qp();Lx();Wx();document.body.dataset.webShell="1";const Zc=new im;if(!Zc.isNativeApp()&&window.parent===window){const e=document.createElement("link");e.rel="manifest",e.href="/manifest.webmanifest",document.head.append(e);const t=document.querySelector('link[rel="apple-touch-icon"]');t&&(t.href="/pwa/icon-192.png");const i=document.createElement("script");i.src="/pwa/install.js",document.head.append(i)}const Pt=Zc.isNativeApp()?new Km(new Ym):null,Th=new Up(Pt==null?void 0:Pt.fetch),ew=window.parent===window?void 0:new Yx,tw=window.parent===window?void 0:new nm;let Ku="";const q0=new Hp(Th,new jp,ew,e=>Pt?new Qo(Ku+e,{fetch:Pt.fetch}):new EventSource(Ku+e));window.browserLiveApi=tw;const Nh=document.getElementById("root");if(!Nh)throw new Error("#root missing");const Qu=hh(Nh);function nw(){return Ct.useEffect(()=>{Vx()},[]),null}(async()=>{Pt&&window.addEventListener("webapp:unauthorized",()=>location.reload());const e=new rm(Zc,new O0,new om(Pt?async(i,l)=>{const c=br.parse(String(i));return c&&await Pt.resume(c),Pt.fetch(i,l)}:void 0)),t=await e.planStartup();if(t.mode==="setup"){Qu.render(ae.jsx(lm,{service:e,savedEndpoint:t.endpoint,initialFailure:t.failure,onScan:Pt?async()=>{const i=await Zm();if(!i)return null;const l=await Pt.pair(i);return new O0().save(l),l}:void 0,onConnected:i=>void $0(i)}));return}await $0(t.mode==="ready"?t.endpoint:null)})();async function $0(e){try{e&&(await(Pt==null?void 0:Pt.resume(e)),Th.setBaseUrl(e.url),Ku=e.url),window.agentApi=q0,await q0.refreshServerModel();const{default:t}=await qu(async()=>{const{default:i}=await import("./App-Cso_5v1O.js");return{default:i}},__vite__mapDeps([0,1]),import.meta.url);Qu.render(ae.jsxs(Ct.StrictMode,{children:[ae.jsx(bg.Provider,{value:ae.jsx(Og,{}),children:ae.jsx(t,{})}),ae.jsx(nw,{})]})),Pt&&setInterval(()=>{Pt.checkAuthorization().catch(()=>{})},1e4),e||(window.addEventListener("webapp:unauthorized",()=>location.reload()),rw())}catch(t){Qu.render(ae.jsx("div",{style:{minHeight:"100dvh",display:"flex",alignItems:"center",justifyContent:"center",padding:24,background:"#f5f6fa",boxSizing:"border-box"},children:ae.jsxs("div",{style:{maxWidth:560,background:"#fff",borderRadius:12,padding:20,boxShadow:"0 4px 16px rgba(0,0,0,0.08)"},children:[ae.jsx("h2",{style:{margin:"0 0 8px",fontSize:16,color:"#dc2626"},children:"界面启动失败"}),ae.jsx("p",{style:{margin:"0 0 12px",fontSize:13,color:"#374151",wordBreak:"break-all"},children:t instanceof Error?`${t.name}: ${t.message}`:String(t)}),ae.jsx("button",{type:"button",onClick:()=>location.reload(),style:{padding:"8px 20px",fontSize:14,borderRadius:8,border:"1px solid #d6d9e0",background:"#fff",cursor:"pointer"},children:"重试"})]})}))}}function rw(){const e=[...document.scripts].map(i=>i.src).join(",").match(/index-([^/]+)\.js/),t=e?e[1]:null;t&&setInterval(async()=>{try{const i=await fetch("/api/agent/model",{credentials:"same-origin",cache:"no-store"});if(i.status===401||i.status===423){location.reload();return}const c=((await i.json()).buildId||"").replace(/^index-|\.js$/g,"");c&&c!==t&&location.reload()}catch{}},6e4)}export{bg as B,Uu as C,aw as H,ow as L,Fx as O,vg as R,sw as S,Ah as W,qu as _,zm as a,Bp as b,ls as c,Sx as d,iw as e,J0 as g,Ox as i,ae as j,Ct as r,kx as u};