diff --git a/src/main/java/Team5/SmartTowns/data/DatabaseController.java b/src/main/java/Team5/SmartTowns/data/DatabaseController.java index 63b7c5f032178f9c5a3c2bec6c82ec13d11754a8..6252083616ff54a6934ab6098e400edd18ef492f 100644 --- a/src/main/java/Team5/SmartTowns/data/DatabaseController.java +++ b/src/main/java/Team5/SmartTowns/data/DatabaseController.java @@ -5,17 +5,17 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.servlet.ModelAndView; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; import java.util.*; @Controller public class DatabaseController { - - @Autowired private LocationRepository locationRepository; @Autowired private TrailsRepository trailsRepository; - @GetMapping("/trailList") public ModelAndView trailList() { ModelAndView mav1 = new ModelAndView("towns/trailsData"); diff --git a/src/main/java/Team5/SmartTowns/data/MockUser.java b/src/main/java/Team5/SmartTowns/data/MockUser.java new file mode 100644 index 0000000000000000000000000000000000000000..48748a17a4ac6fe230ee7f12119d5c71ab73839a --- /dev/null +++ b/src/main/java/Team5/SmartTowns/data/MockUser.java @@ -0,0 +1,16 @@ +package Team5.SmartTowns.Data; + +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; + +import java.util.List; + +public class MockUser { + + private JdbcTemplate jdbc; + private RowMapper<trail> trailMapper; + public List<trail> getAllTrails(){ + String sql= "SELECT * FROM trails"; + return jdbc.query(sql, trailMapper); + } +} diff --git a/src/main/java/Team5/SmartTowns/data/QRCodes.java b/src/main/java/Team5/SmartTowns/data/QRCodes.java new file mode 100644 index 0000000000000000000000000000000000000000..ef350eb418b959e1069ee51d061471448c3b7457 --- /dev/null +++ b/src/main/java/Team5/SmartTowns/data/QRCodes.java @@ -0,0 +1,4 @@ +package Team5.SmartTowns.Data; + +public class QRCodes { +} diff --git a/src/main/java/Team5/SmartTowns/landmarks/Landmarks.java b/src/main/java/Team5/SmartTowns/landmarks/Landmarks.java index 871aac6ed0c0b561c0d42dee8abb9a5c3a50bda6..6974c1e997c5b2dd6d7396f44ea0cbe4565331c7 100644 --- a/src/main/java/Team5/SmartTowns/landmarks/Landmarks.java +++ b/src/main/java/Team5/SmartTowns/landmarks/Landmarks.java @@ -16,7 +16,7 @@ public class Landmarks { // Initialized object to getID from trail. //Predefined Landmark for Dragons Tale. - private static List<Landmarks> landmarksDragonstrail = List.of( + public static List<Landmarks> landmarksDragonstrail = List.of( new Landmarks( 1, "A scent of...Dragon", "The Dragon has been spotted near by, find the QR code to continue" , "Start your discovery, at the sweet shop."), new Landmarks( 2, "They've been found!", "Don't let them escape, find the next QR code to continue!", "Location test") ); @@ -41,6 +41,4 @@ public class Landmarks { this.landmarkName = landmarkName; this.landmarkDescription = landmarkDescription; this.landmarkLocation = landmarkLocation; } - - } diff --git a/src/main/java/Team5/SmartTowns/trails/TrailsController.java b/src/main/java/Team5/SmartTowns/trails/TrailsController.java index 84aed1ee52839bac38b26725f72d28bb3bfd14a6..004fdabd4e836fb7e4110f8d3f63bad76fb8b3d4 100644 --- a/src/main/java/Team5/SmartTowns/trails/TrailsController.java +++ b/src/main/java/Team5/SmartTowns/trails/TrailsController.java @@ -1,18 +1,19 @@ package Team5.SmartTowns.trails; -import Team5.SmartTowns.landmarks.Landmarks; +import Team5.SmartTowns.Landmarks.Landmarks; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; +import java.util.ArrayList; import java.util.List; +import java.util.Optional; -import static Team5.SmartTowns.landmarks.Landmarks.getLandmarksDragonstrail; +import static Team5.SmartTowns.Landmarks.Landmarks.landmarksDragonstrail; + +//import static Team5.SmartTowns.Landmarks.Landmarks.landmarksDragonstrail; @Controller public class TrailsController { @@ -39,21 +40,22 @@ public class TrailsController { @GetMapping("/dragonstale") public ModelAndView getDragonsTale(){ - List<Landmarks> landmarksList = getLandmarksDragonstrail(); - Landmarks landmarks = new Landmarks(); - int listSize = landmarksList.size(); + List<Landmarks> landmarksList = landmarksDragonstrail; ModelAndView modelAndView = new ModelAndView("towns/trails/dragonstale/index"); modelAndView.addObject("landmarksList", landmarksList); - modelAndView.addObject("getListSize", listSize); return modelAndView; } -// @GetMapping("/dragonstale/{landmarks}") -// public ModelAndView getDragonstaleLandmarks(){ -// ModelAndView modelAndView = new ModelAndView(); -// modelAndView.addObject() -// } + // +// @GetMapping("dragonstale/{qrCode}/{id}") +// public String qrCodeCheck(@PathVariable Optional<String> qrCode, @PathVariable Optional<Integer> id){ +// if (qrCode.isPresent()){ +// +// //Check if ID is present, if do this, if not dfo that. +// +// } +// } } diff --git a/src/main/java/Team5/SmartTowns/users/User.java b/src/main/java/Team5/SmartTowns/users/User.java index d87a1fc9e8097806c671b617fede5167a7d6ed09..d0da0d6d974af401d29274e2f4aa8858ec70acc6 100644 --- a/src/main/java/Team5/SmartTowns/users/User.java +++ b/src/main/java/Team5/SmartTowns/users/User.java @@ -1,24 +1,41 @@ package Team5.SmartTowns.users; -import lombok.Getter; +import Team5.SmartTowns.rewards.Badge; +import Team5.SmartTowns.rewards.Sticker; +import lombok.Data; import java.io.File; +import java.sql.Connection; +import java.sql.DriverManager; +import java.util.HashMap; +import java.util.Map; -@Getter +@Data public class User { - int id; String email; //Validation would be done by email, since they will have that String name; String imgPath; + int dragonProgress; + Map<Badge, Integer> badgeProgress = new HashMap<>(); // Demonstrates the progress towards a specific badge (0-100) + Map<Sticker, Boolean> hasStickers = new HashMap<>(); // True if User has sticker (key) + Map<Integer, Boolean> dragonstaleLandmarkIDs = new HashMap<>(); // Storing the IDs of the landmarks associated with Dragonstale, as well as if the user has visited it before (boolean) - public User(int id, String email, String name) { + public User(int id, String email, String name, int dragonProgress) { this.id = id; this.email = email; this.name = name; + this.dragonProgress = dragonProgress; +// this.dragonstaleLandmarkIDs = dragonstaleLandmarkIDs; + imgPath = findImagePath(); + } + public User(int id, String email, String name, int dragonProgress) { + this.id = id; + this.email = email; + this.name = name; + this.dragonProgress = dragonProgress; imgPath = findImagePath(); } - private String findImagePath(){ /* Finds the image in the Path folder, if image is not found assigns default image */ diff --git a/src/main/java/Team5/SmartTowns/users/UserRepositoryJDBC.java b/src/main/java/Team5/SmartTowns/users/UserRepositoryJDBC.java index 868e738a703d707ad661fc4bbc372af7903881b9..8b46fc3a568455e91c180b66fc91b65f20d20c81 100644 --- a/src/main/java/Team5/SmartTowns/users/UserRepositoryJDBC.java +++ b/src/main/java/Team5/SmartTowns/users/UserRepositoryJDBC.java @@ -5,11 +5,11 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Repository; +import java.util.HashMap; import java.util.List; @Repository public class UserRepositoryJDBC implements UserRepository{ - private JdbcTemplate jdbc; private RowMapper<User> userMapper; @@ -32,6 +32,7 @@ public class UserRepositoryJDBC implements UserRepository{ return jdbc.query(sql, userMapper); } + @Override public User getUserById(int userID){ String sql= "SELECT * FROM users WHERE id="+userID; diff --git a/src/main/node_modules/.package-lock.json b/src/main/node_modules/.package-lock.json new file mode 100644 index 0000000000000000000000000000000000000000..c771511d25e96ca1a3c94f9d7d788bf956e3f0e2 --- /dev/null +++ b/src/main/node_modules/.package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "main", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "node_modules/html5-qrcode": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/html5-qrcode/-/html5-qrcode-2.3.8.tgz", + "integrity": "sha512-jsr4vafJhwoLVEDW3n1KvPnCCXWaQfRng0/EEYk1vNcQGcG/htAdhJX0be8YyqMoSz7+hZvOZSTAepsabiuhiQ==" + } + } +} diff --git a/src/main/node_modules/html5-qrcode/LICENSE b/src/main/node_modules/html5-qrcode/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..06900aadc1f392ed5cc260456b6e769f7645bd08 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2020] [MINHAZ <minhazav@gmail.com>] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/main/node_modules/html5-qrcode/README.md b/src/main/node_modules/html5-qrcode/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1441ce54dfb9a49c101ef6ceee8d86c80cb5e010 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/README.md @@ -0,0 +1,398 @@ +# Html5-QRCode + +## Lightweight & cross platform QR Code and Bar code scanning library for the web + +Use this lightweight library to easily / quickly integrate QR code, bar code, and other common code scanning capabilities to your web application. + +## Key highlights +- 🔲 Support scanning [different types of bar codes and QR codes](#supported-code-formats). + +- 🖥 Supports [different platforms](#supported-platforms) be it Android, IOS, MacOs, Windows or Linux + +- 🌠Supports [different browsers](#supported-platforms) like Chrome, Firefox, Safari, Edge, Opera ... + +- 📷 Supports scanning with camera as well as local files + +- âž¡ï¸ Comes with an [end to end library with UI](#easy-mode---with-end-to-end-scanner-user-interface) as well as a [low level library to build your own UI with](#pro-mode---if-you-want-to-implement-your-own-user-interface). + +- 🔦 Supports customisations like [flash/torch support](#showtorchbuttonifsupported---boolean--undefined), zooming etc. + + +Supports two kinds of APIs + +- `Html5QrcodeScanner` — End-to-end scanner with UI, integrate with less than ten lines of code. + +- `Html5Qrcode` — Powerful set of APIs you can use to build your UI without worrying about camera setup, handling permissions, reading codes, etc. + +> Support for scanning local files on the device is a new addition and helpful for the web browser which does not support inline web-camera access in smartphones. **Note:** This doesn't upload files to any server — everything is done locally. + +[](https://dl.circleci.com/status-badge/redirect/gh/mebjas/html5-qrcode/tree/master) [](https://github.com/mebjas/html5-qrcode/issues) [](https://github.com/mebjas/html5-qrcode/releases)  [](https://www.codacy.com/gh/mebjas/html5-qrcode/dashboard?utm_source=github.com&utm_medium=referral&utm_content=mebjas/html5-qrcode&utm_campaign=Badge_Grade) [](https://gitter.im/html5-qrcode/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) + + [](https://www.npmjs.com/package/html5-qrcode) [](https://bit.ly/3CZiASv) + +| <img src="https://scanapp.org/assets/github_assets/pixel6pro-optimised.gif" width="180px" /> | <img src="https://scanapp.org/assets/github_assets/pixel4_barcode_480.gif" width="180px" />| +| -- | -- | +| _Demo at [scanapp.org](https://scanapp.org)_ | _Demo at [qrcode.minhazav.dev](https://qrcode.minhazav.dev) - **Scanning different types of codes**_ | + +## We need your help! + + +Help incentivise feature development, bug fixing by supporting the sponsorhip goals of this project. See [list of sponsered feature requests here](https://github.com/mebjas/html5-qrcode/wiki/Feature-request-sponsorship-goals#feature-requests). + +[](https://ko-fi.com/L3L84G0C8) + +## Documentation + +The documentation for this project has been moved to [scanapp.org/html5-qrcode-docs](https://scanapp.org/html5-qrcode-docs/). + +- [Getting started](https://scanapp.org/html5-qrcode-docs/docs/intro) +- [Supported frameworks](https://scanapp.org/html5-qrcode-docs/docs/supported_frameworks) +- [Supported 1D and 2D Code formats](https://scanapp.org/html5-qrcode-docs/docs/supported_code_formats) +- [Detailed API documentation](https://scanapp.org/html5-qrcode-docs/docs/apis) + +## Supported platforms + +We are working continuously on adding support for more and more platforms. If you find a platform or a browser where the library is not working, please feel free to file an issue. Check the [demo link](https://blog.minhazav.dev/research/html5-qrcode.html) to test it out. + +**Legends** +-  Means full support — inline webcam and file based +-  Means partial support — only file based, webcam in progress + +### PC / Mac + +| <img src="https://scanapp.org/assets/github_assets/browsers/firefox_48x48.png" alt="Firefox" width="24px" height="24px" /><br/>Firefox | <img src="https://scanapp.org/assets/github_assets/browsers/chrome_48x48.png" alt="Chrome" width="24px" height="24px" /><br/>Chrome | <img src="https://scanapp.org/assets/github_assets/browsers/safari_48x48.png" alt="Safari" width="24px" height="24px" /><br/>Safari | <img src="https://scanapp.org/assets/github_assets/browsers/opera_48x48.png" alt="Opera" width="24px" height="24px" /><br/>Opera | <img src="https://scanapp.org/assets/github_assets/browsers/edge_48x48.png" alt="Edge" width="24px" height="24px" /><br/> Edge +| --------- | --------- | --------- | --------- | ------- | +|| | |  |  + +### Android + +| <img src="https://scanapp.org/assets/github_assets/browsers/chrome_48x48.png" alt="Chrome" width="24px" height="24px" /><br/>Chrome | <img src="https://scanapp.org/assets/github_assets/browsers/firefox_48x48.png" alt="Firefox" width="24px" height="24px" /><br/>Firefox | <img src="https://scanapp.org/assets/github_assets/browsers/edge_48x48.png" alt="Edge" width="24px" height="24px" /><br/> Edge | <img src="https://scanapp.org/assets/github_assets/browsers/opera_48x48.png" alt="Opera" width="24px" height="24px" /><br/>Opera | <img src="https://scanapp.org/assets/github_assets/browsers/opera-mini_48x48.png" alt="Opera-Mini" width="24px" height="24px" /><br/> Opera Mini | <img src="https://scanapp.org/assets/github_assets/browsers/uc_48x48.png" alt="UC" width="24px" height="24px" /> <br/> UC +| --------- | --------- | --------- | --------- | --------- | --------- | +|| | | |  |  + +### IOS + +| <img src="https://scanapp.org/assets/github_assets/browsers/safari_48x48.png" alt="Safari" width="24px" height="24px" /><br/>Safari | <img src="https://scanapp.org/assets/github_assets/browsers/chrome_48x48.png" alt="Chrome" width="24px" height="24px" /><br/>Chrome | <img src="https://scanapp.org/assets/github_assets/browsers/firefox_48x48.png" alt="Firefox" width="24px" height="24px" /><br/>Firefox | <img src="https://scanapp.org/assets/github_assets/browsers/edge_48x48.png" alt="Edge" width="24px" height="24px" /><br/> Edge +| --------- | --------- | --------- | --------- | +|| * | * |  + + +> \* Supported for IOS versions >= 15.1 +> +> Before version 15.1, Webkit for IOS is used by Chrome, Firefox, and other browsers in IOS and they do not have webcam permissions yet. There is an ongoing issue on fixing the support for iOS - [issue/14](https://github.com/mebjas/html5-qrcode/issues/14) + +### Framework support +The library can be easily used with several other frameworks, I have been adding examples for a few of them and would continue to add more. + +|<img src="https://scanapp.org/assets/github_assets/html5.png" width="30px" />| <img src="https://scanapp.org/assets/github_assets/vuejs.png" width="30px" />|<img src="https://scanapp.org/assets/github_assets/electron.png" width="30px" /> | <img src="https://scanapp.org/assets/github_assets/react.svg" width="30px" /> | <img src="https://seeklogo.com/images/L/lit-logo-6B43868CDC-seeklogo.com.png" width="30px" /> +| -------- | -------- | -------- | -------- | -------- | +| [Html5](./examples/html5) | [VueJs](./examples/vuejs) | [ElectronJs](./examples/electron) | [React](https://github.com/scanapp-org/html5-qrcode-react) | [Lit](./examples/lit) + +### Supported Code formats +Code scanning is dependent on [Zxing-js](https://github.com/zxing-js/library) library. We will be working on top of it to add support for more types of code scanning. If you feel a certain type of code would be helpful to have, please file a feature request. + +| Code | Example | +| ---- | ----- | +| QR Code | <img src="https://scanapp.org/assets/github_assets/qr-code.png" width="200px" /> | +| AZTEC | <img src="https://scanapp.org/assets/github_assets/aztec.png" /> | +| CODE_39| <img src="https://scanapp.org/assets/github_assets/code_39.gif" /> | +| CODE_93| <img src="https://scanapp.org/assets/github_assets/code_93.gif" />| +| CODE_128| <img src="https://scanapp.org/assets/github_assets/code_128.gif" />| +| ITF| <img src="https://scanapp.org/assets/github_assets/itf.png" />| +| EAN_13|<img src="https://scanapp.org/assets/github_assets/ean13.jpeg" /> | +| EAN_8| <img src="https://scanapp.org/assets/github_assets/ean8.jpeg" />| +| PDF_417| <img src="https://scanapp.org/assets/github_assets/pdf417.png" />| +| UPC_A| <img src="https://scanapp.org/assets/github_assets/upca.jpeg" />| +| UPC_E| <img src="https://scanapp.org/assets/github_assets/upce.jpeg" />| +| DATA_MATRIX|<img src="https://scanapp.org/assets/github_assets/datamatrix.png" /> | +| MAXICODE*| <img src="https://scanapp.org/assets/github_assets/maxicode.gif" /> | +| RSS_14*| <img src="https://scanapp.org/assets/github_assets/rss14.gif" />| +| RSS_EXPANDED*|<img src="https://scanapp.org/assets/github_assets/rssexpanded.gif" /> | + +> *Formats are not supported by our experimental integration with native +> BarcodeDetector API integration ([Read more](/experimental.md)). + +## Description - [View Demo](https://blog.minhazav.dev/research/html5-qrcode.html) + +> See an end to end scanner experience at [scanapp.org](https://scanapp.org). + +This is a cross-platform JavaScript library to integrate QR code, bar codes & a few other types of code scanning capabilities to your applications running on HTML5 compatible browser. + +Supports: +- Querying camera on the device (with user permissions) +- Rendering live camera feed, with easy to use user interface for scanning +- Supports scanning a different kind of QR codes, bar codes and other formats +- Supports selecting image files from the device for scanning codes + +## How to use + +Find detailed guidelines on how to use this library on [scanapp.org/html5-qrcode-docs](https://scanapp.org/html5-qrcode-docs/docs/intro). + +## Demo +<img src="https://scanapp.org/assets/github_assets/qr-code.png" width="200px"><br /> +_Scan this image or visit [blog.minhazav.dev/research/html5-qrcode.html](https://blog.minhazav.dev/research/html5-qrcode.html)_ + +### For more information +Check these articles on how to use this library: +<!-- TODO(mebjas) Mirgate this link to blog.minhazav.dev --> +- [QR and barcode scanner using HTML and JavaScript](https://minhazav.medium.com/qr-and-barcode-scanner-using-html-and-javascript-2cdc937f793d) +- [HTML5 QR Code scanning — launched v1.0.1 without jQuery dependency and refactored Promise based APIs](https://blog.minhazav.dev/HTML5-QR-Code-scanning-launched-v1.0.1/). +- [HTML5 QR Code scanning with JavaScript — Support for scanning the local file and using default camera added (v1.0.5)](https://blog.minhazav.dev/HTML5-QR-Code-scanning-support-for-local-file-and-default-camera/) + +## Screenshots +<br /> +_Figure: Screenshot from Google Chrome running on MacBook Pro_ + +## Documentation +Find the full API documentation at [scanapp.org/html5-qrcode-docs/docs/apis](https://scanapp.org/html5-qrcode-docs/docs/apis). + +### Extra optional `configuration` in `start()` method +Configuration object that can be used to configure both the scanning behavior and the user interface (UI). Most of the fields have default properties that will be used unless a different value is provided. If you do not want to override anything, you can just pass in an empty object `{}`. + +#### `fps` — Integer, Example = 10 +A.K.A frame per second, the default value for this is 2, but it can be increased to get faster scanning. Increasing too high value could affect performance. Value `>1000` will simply fail. + +#### `qrbox` — `QrDimensions` or `QrDimensionFunction` (Optional), Example = `{ width: 250, height: 250 }` +Use this property to limit the region of the viewfinder you want to use for scanning. The rest of the viewfinder would be shaded. For example, by passing config `{ qrbox : { width: 250, height: 250 } }`, the screen will look like: + +<img src="https://scanapp.org/assets/github_assets/screen.gif" /> + +This can be used to set a rectangular scanning area with config like: + +```js +let config = { qrbox : { width: 400, height: 150 } } +``` + +This config also accepts a function of type +```ts +/** + * A function that takes in the width and height of the video stream +* and returns QrDimensions. +* +* Viewfinder refers to the video showing camera stream. +*/ +type QrDimensionFunction = + (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; +``` + +This allows you to set dynamic QR box dimensions based on the video dimensions. See this blog article for example: [Setting dynamic QR box size in Html5-qrcode - ScanApp blog](https://scanapp.org/blog/2022/01/09/setting-dynamic-qr-box-size-in-html5-qrcode.html) + +> This might be desirable for bar code scanning. + +If this value is not set, no shaded QR box will be rendered and the scanner will scan the entire area of video stream. + +#### `aspectRatio` — Float, Example 1.777778 for 16:9 aspect ratio +Use this property to render the video feed in a certain aspect ratio. Passing a nonstandard aspect ratio like `100000:1` could lead to the video feed not even showing up. Ideal values can be: +| Value | Aspect Ratio | Use Case | +| ----- | ------------ | -------- | +|1.333334 | 4:3 | Standard camera aspect ratio | +|1.777778 | 16:9 | Full screen, cinematic | +|1.0 | 1:1 | Square view | + +If you do not pass any value, the whole viewfinder would be used for scanning. +**Note**: this value has to be smaller than the width and height of the `QR code HTML element`. + +#### `disableFlip` — Boolean (Optional), default = false +By default, the scanner can scan for horizontally flipped QR Codes. This also enables scanning QR code using the front camera on mobile devices which are sometimes mirrored. This is `false` by default and I recommend changing this only if: +- You are sure that the camera feed cannot be mirrored (Horizontally flipped) +- You are facing performance issues with this enabled. + +Here's an example of a normal and mirrored QR Code +| Normal QR Code | Mirrored QR Code | +| ----- | ---- | +| <img src="https://scanapp.org/assets/github_assets/qr-code.png" width="200px" /> | <img src="https://scanapp.org/assets/github_assets/qr-code-flipped.png" width="200px" /><br /> | + +#### `rememberLastUsedCamera` — Boolean (Optional), default = true +If `true` the last camera used by the user and weather or not permission was granted would be remembered in the local storage. If the user has previously granted permissions — the request permission option in the UI will be skipped and the last selected camera would be launched automatically for scanning. + +If `true` the library shall remember if the camera permissions were previously +granted and what camera was last used. If the permissions is already granted for +"camera", QR code scanning will automatically * start for previously used camera. + +#### `supportedScanTypes` - `Array<Html5QrcodeScanType> | []` +> This is only supported for `Html5QrcodeScanner`. + +Default = `[Html5QrcodeScanType.SCAN_TYPE_CAMERA, Html5QrcodeScanType.SCAN_TYPE_FILE]` + +This field can be used to: +- Limit support to either of `Camera` or `File` based scan. +- Change default scan type. + +How to use: + +```js +function onScanSuccess(decodedText, decodedResult) { + // handle the scanned code as you like, for example: + console.log(`Code matched = ${decodedText}`, decodedResult); +} + +let config = { + fps: 10, + qrbox: {width: 100, height: 100}, + rememberLastUsedCamera: true, + // Only support camera scan type. + supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_CAMERA] +}; + +let html5QrcodeScanner = new Html5QrcodeScanner( + "reader", config, /* verbose= */ false); +html5QrcodeScanner.render(onScanSuccess); +``` + +For file based scan only choose: +```js +supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_FILE] +``` + +For supporting both as it is today, you can ignore this field or set as: +```js +supportedScanTypes: [ + Html5QrcodeScanType.SCAN_TYPE_CAMERA, + Html5QrcodeScanType.SCAN_TYPE_FILE] +``` + +To set the file based scan as defult change the order: +```js +supportedScanTypes: [ + Html5QrcodeScanType.SCAN_TYPE_FILE, + Html5QrcodeScanType.SCAN_TYPE_CAMERA] +``` + +#### `showTorchButtonIfSupported` - `boolean | undefined` +> This is only supported for `Html5QrcodeScanner`. + +If `true` the rendered UI will have button to turn flash on or off based on device + browser support. The value is `false` by default. + +### Scanning only specific formats +By default, both camera stream and image files are scanned against all the +supported code formats. Both `Html5QrcodeScanner` and `Html5Qrcode` classes can + be configured to only support a subset of supported formats. Supported formats +are defined in +[enum Html5QrcodeSupportedFormats](https://github.com/mebjas/html5-qrcode/blob/master/src/core.ts#L14). + +```ts +enum Html5QrcodeSupportedFormats { + QR_CODE = 0, + AZTEC, + CODABAR, + CODE_39, + CODE_93, + CODE_128, + DATA_MATRIX, + MAXICODE, + ITF, + EAN_13, + EAN_8, + PDF_417, + RSS_14, + RSS_EXPANDED, + UPC_A, + UPC_E, + UPC_EAN_EXTENSION, +} +``` + +I recommend using this only if you need to explicitly omit support for certain +formats or want to reduce the number of scans done per second for performance +reasons. + +#### Scanning only QR code with `Html5Qrcode` +```js +const html5QrCode = new Html5Qrcode( + "reader", { formatsToSupport: [ Html5QrcodeSupportedFormats.QR_CODE ] }); +const qrCodeSuccessCallback = (decodedText, decodedResult) => { + /* handle success */ +}; +const config = { fps: 10, qrbox: { width: 250, height: 250 } }; + +// If you want to prefer front camera +html5QrCode.start({ facingMode: "user" }, config, qrCodeSuccessCallback); +``` + +#### Scanning only QR code and UPC codes with `Html5QrcodeScanner` +```js +function onScanSuccess(decodedText, decodedResult) { + // Handle the scanned code as you like, for example: + console.log(`Code matched = ${decodedText}`, decodedResult); +} + +const formatsToSupport = [ + Html5QrcodeSupportedFormats.QR_CODE, + Html5QrcodeSupportedFormats.UPC_A, + Html5QrcodeSupportedFormats.UPC_E, + Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, +]; +const html5QrcodeScanner = new Html5QrcodeScanner( + "reader", + { + fps: 10, + qrbox: { width: 250, height: 250 }, + formatsToSupport: formatsToSupport + }, + /* verbose= */ false); +html5QrcodeScanner.render(onScanSuccess); +``` + +## Experimental features +The library now supports some experimental features which are supported in the +library but not recommended for production usage either due to limited testing +done or limited compatibility for underlying APIs used. Read more about it [here](/experimental.md). +Some experimental features include: +- [Support for BarcodeDetector JavaScript API](/experimental.md) + +## How to modify and build +1. Code changes should only be made to [/src](./src) only. + +2. Run `npm install` to install all dependencies. + +3. Run `npm run-script build` to build JavaScript output. The output JavaScript distribution is built to [/dist/html5-qrcode.min.js](./dist/html5-qrcode.min.js). If you are developing on Windows OS, run `npm run-script build-windows`. + +4. Testing + - Run `npm test` + - Run the tests before sending a pull request, all tests should run. + - Please add tests for new behaviors sent in PR. + +5. Send a pull request + - Include code changes only to `./src`. **Do not change `./dist` manually.** + - In the pull request add a comment like + ```text + @all-contributors please add @mebjas for this new feature or tests + ``` + - For calling out your contributions, the bot will update the contributions file. + - Code will be built & published by the author in batches. + +## How to contribute +You can contribute to the project in several ways: + +- File issue ticket for any observed bug or compatibility issue with the project. +- File feature request for missing features. +- Take open bugs or feature request and work on it and send a Pull Request. +- Write unit tests for existing codebase (which is not covered by tests today). **Help wanted on this** - [read more](./tests). + +## Support 💖 + +This project would not be possible without all of our fantastic contributors and [sponsors](https://github.com/sponsors/mebjas). If you'd like to support the maintenance and upkeep of this project you can [donate via GitHub Sponsors](https://github.com/sponsors/mebjas). + +**Sponsor the project for priortising feature requests / bugs relevant to you**. (Depends on scope of ask and bandwidth of the contributors). + +<!-- sponsors --> +<a href="https://github.com/webauthor"><img src="https://github.com/webauthor.png" width="40px" alt="webauthor@" /></a> +<a href="https://github.com/ben-gy"><img src="https://github.com/ben-gy.png" width="40px" alt="ben-gy" /></a> +<a href="https://github.com/bujjivadu"><img src="https://github.com/bujjivadu.png" width="40px" alt="bujjivadu" /></a> +<!-- sponsors --> + +Help incentivise feature development, bug fixing by supporting the sponsorhip goals of this project. See [list of sponsered feature requests here](https://github.com/mebjas/html5-qrcode/wiki/Feature-request-sponsorship-goals#feature-requests). + +Also, huge thanks to following organizations for non monitery sponsorships + +<!-- sponsors --> +<div> + <a href="https://scanapp.org"><img src="https://scanapp.org/assets/svg/scanapp.svg" height="60px" alt="" /></a> +</div> +<div> + <a href="https://www.browserstack.com"><img src="https://www.browserstack.com/images/layout/browserstack-logo-600x315.png" height="100px" alt="" /></a> +</div> +<!-- sponsors --> + +## Credits +The decoder used for the QR code reading is from `Zxing-js` https://github.com/zxing-js/library<br /> diff --git a/src/main/node_modules/html5-qrcode/camera/core-impl.d.ts b/src/main/node_modules/html5-qrcode/camera/core-impl.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ffc8a05e27dd5c815882381cca903fde7ae268db --- /dev/null +++ b/src/main/node_modules/html5-qrcode/camera/core-impl.d.ts @@ -0,0 +1,7 @@ +import { Camera, CameraRenderingOptions, RenderedCamera, RenderingCallbacks } from "./core"; +export declare class CameraImpl implements Camera { + private readonly mediaStream; + private constructor(); + render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>; + static create(videoConstraints: MediaTrackConstraints): Promise<Camera>; +} diff --git a/src/main/node_modules/html5-qrcode/camera/core.d.ts b/src/main/node_modules/html5-qrcode/camera/core.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..52e27b5012fe7172a5d7b179174774fe206316ae --- /dev/null +++ b/src/main/node_modules/html5-qrcode/camera/core.d.ts @@ -0,0 +1,41 @@ +export interface CameraDevice { + id: string; + label: string; +} +export interface CameraCapability<T> { + isSupported(): boolean; + apply(value: T): Promise<void>; + value(): T | null; +} +export interface RangeCameraCapability extends CameraCapability<number> { + min(): number; + max(): number; + step(): number; +} +export interface BooleanCameraCapability extends CameraCapability<boolean> { +} +export interface CameraCapabilities { + zoomFeature(): RangeCameraCapability; + torchFeature(): BooleanCameraCapability; +} +export type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; +export interface RenderingCallbacks { + onRenderSurfaceReady: OnRenderSurfaceReady; +} +export interface RenderedCamera { + getSurface(): HTMLVideoElement; + pause(): void; + resume(onResumeCallback: () => void): void; + isPaused(): boolean; + close(): Promise<void>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + applyVideoConstraints(constraints: MediaTrackConstraints): Promise<void>; + getCapabilities(): CameraCapabilities; +} +export interface CameraRenderingOptions { + aspectRatio?: number; +} +export interface Camera { + render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>; +} diff --git a/src/main/node_modules/html5-qrcode/camera/factories.d.ts b/src/main/node_modules/html5-qrcode/camera/factories.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..df98f8ffb0479eb3c807d7e49c6018c3850f8f71 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/camera/factories.d.ts @@ -0,0 +1,6 @@ +import { Camera } from "./core"; +export declare class CameraFactory { + static failIfNotSupported(): Promise<CameraFactory>; + private constructor(); + create(videoConstraints: MediaTrackConstraints): Promise<Camera>; +} diff --git a/src/main/node_modules/html5-qrcode/camera/permissions.d.ts b/src/main/node_modules/html5-qrcode/camera/permissions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4209c552093cc9cc5bf1022bd100a4459b988c38 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/camera/permissions.d.ts @@ -0,0 +1,3 @@ +export declare class CameraPermissions { + static hasPermissions(): Promise<boolean>; +} diff --git a/src/main/node_modules/html5-qrcode/camera/retriever.d.ts b/src/main/node_modules/html5-qrcode/camera/retriever.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0baac120fbc60739f5a0b7b3f59d217b02a41c17 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/camera/retriever.d.ts @@ -0,0 +1,8 @@ +import { CameraDevice } from "./core"; +export declare class CameraRetriever { + static retrieve(): Promise<Array<CameraDevice>>; + private static rejectWithError; + private static isHttpsOrLocalhost; + private static getCamerasFromMediaDevices; + private static getCamerasFromMediaStreamTrack; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/core-impl.d.ts b/src/main/node_modules/html5-qrcode/cjs/camera/core-impl.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ffc8a05e27dd5c815882381cca903fde7ae268db --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/core-impl.d.ts @@ -0,0 +1,7 @@ +import { Camera, CameraRenderingOptions, RenderedCamera, RenderingCallbacks } from "./core"; +export declare class CameraImpl implements Camera { + private readonly mediaStream; + private constructor(); + render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>; + static create(videoConstraints: MediaTrackConstraints): Promise<Camera>; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/core-impl.js b/src/main/node_modules/html5-qrcode/cjs/camera/core-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..ef7bf76f1a11e094ac2cb2fe0bf941290d882797 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/core-impl.js @@ -0,0 +1,314 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CameraImpl = void 0; +var AbstractCameraCapability = (function () { + function AbstractCameraCapability(name, track) { + this.name = name; + this.track = track; + } + AbstractCameraCapability.prototype.isSupported = function () { + if (!this.track.getCapabilities) { + return false; + } + return this.name in this.track.getCapabilities(); + }; + AbstractCameraCapability.prototype.apply = function (value) { + var constraint = {}; + constraint[this.name] = value; + var constraints = { advanced: [constraint] }; + return this.track.applyConstraints(constraints); + }; + AbstractCameraCapability.prototype.value = function () { + var settings = this.track.getSettings(); + if (this.name in settings) { + var settingValue = settings[this.name]; + return settingValue; + } + return null; + }; + return AbstractCameraCapability; +}()); +var AbstractRangeCameraCapability = (function (_super) { + __extends(AbstractRangeCameraCapability, _super); + function AbstractRangeCameraCapability(name, track) { + return _super.call(this, name, track) || this; + } + AbstractRangeCameraCapability.prototype.min = function () { + return this.getCapabilities().min; + }; + AbstractRangeCameraCapability.prototype.max = function () { + return this.getCapabilities().max; + }; + AbstractRangeCameraCapability.prototype.step = function () { + return this.getCapabilities().step; + }; + AbstractRangeCameraCapability.prototype.apply = function (value) { + var constraint = {}; + constraint[this.name] = value; + var constraints = { advanced: [constraint] }; + return this.track.applyConstraints(constraints); + }; + AbstractRangeCameraCapability.prototype.getCapabilities = function () { + this.failIfNotSupported(); + var capabilities = this.track.getCapabilities(); + var capability = capabilities[this.name]; + return { + min: capability.min, + max: capability.max, + step: capability.step, + }; + }; + AbstractRangeCameraCapability.prototype.failIfNotSupported = function () { + if (!this.isSupported()) { + throw new Error("".concat(this.name, " capability not supported")); + } + }; + return AbstractRangeCameraCapability; +}(AbstractCameraCapability)); +var ZoomFeatureImpl = (function (_super) { + __extends(ZoomFeatureImpl, _super); + function ZoomFeatureImpl(track) { + return _super.call(this, "zoom", track) || this; + } + return ZoomFeatureImpl; +}(AbstractRangeCameraCapability)); +var TorchFeatureImpl = (function (_super) { + __extends(TorchFeatureImpl, _super); + function TorchFeatureImpl(track) { + return _super.call(this, "torch", track) || this; + } + return TorchFeatureImpl; +}(AbstractCameraCapability)); +var CameraCapabilitiesImpl = (function () { + function CameraCapabilitiesImpl(track) { + this.track = track; + } + CameraCapabilitiesImpl.prototype.zoomFeature = function () { + return new ZoomFeatureImpl(this.track); + }; + CameraCapabilitiesImpl.prototype.torchFeature = function () { + return new TorchFeatureImpl(this.track); + }; + return CameraCapabilitiesImpl; +}()); +var RenderedCameraImpl = (function () { + function RenderedCameraImpl(parentElement, mediaStream, callbacks) { + this.isClosed = false; + this.parentElement = parentElement; + this.mediaStream = mediaStream; + this.callbacks = callbacks; + this.surface = this.createVideoElement(this.parentElement.clientWidth); + parentElement.append(this.surface); + } + RenderedCameraImpl.prototype.createVideoElement = function (width) { + var videoElement = document.createElement("video"); + videoElement.style.width = "".concat(width, "px"); + videoElement.style.display = "block"; + videoElement.muted = true; + videoElement.setAttribute("muted", "true"); + videoElement.playsInline = true; + return videoElement; + }; + RenderedCameraImpl.prototype.setupSurface = function () { + var _this = this; + this.surface.onabort = function () { + throw "RenderedCameraImpl video surface onabort() called"; + }; + this.surface.onerror = function () { + throw "RenderedCameraImpl video surface onerror() called"; + }; + var onVideoStart = function () { + var videoWidth = _this.surface.clientWidth; + var videoHeight = _this.surface.clientHeight; + _this.callbacks.onRenderSurfaceReady(videoWidth, videoHeight); + _this.surface.removeEventListener("playing", onVideoStart); + }; + this.surface.addEventListener("playing", onVideoStart); + this.surface.srcObject = this.mediaStream; + this.surface.play(); + }; + RenderedCameraImpl.create = function (parentElement, mediaStream, options, callbacks) { + return __awaiter(this, void 0, void 0, function () { + var renderedCamera, aspectRatioConstraint; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + renderedCamera = new RenderedCameraImpl(parentElement, mediaStream, callbacks); + if (!options.aspectRatio) return [3, 2]; + aspectRatioConstraint = { + aspectRatio: options.aspectRatio + }; + return [4, renderedCamera.getFirstTrackOrFail().applyConstraints(aspectRatioConstraint)]; + case 1: + _a.sent(); + _a.label = 2; + case 2: + renderedCamera.setupSurface(); + return [2, renderedCamera]; + } + }); + }); + }; + RenderedCameraImpl.prototype.failIfClosed = function () { + if (this.isClosed) { + throw "The RenderedCamera has already been closed."; + } + }; + RenderedCameraImpl.prototype.getFirstTrackOrFail = function () { + this.failIfClosed(); + if (this.mediaStream.getVideoTracks().length === 0) { + throw "No video tracks found"; + } + return this.mediaStream.getVideoTracks()[0]; + }; + RenderedCameraImpl.prototype.pause = function () { + this.failIfClosed(); + this.surface.pause(); + }; + RenderedCameraImpl.prototype.resume = function (onResumeCallback) { + this.failIfClosed(); + var $this = this; + var onVideoResume = function () { + setTimeout(onResumeCallback, 200); + $this.surface.removeEventListener("playing", onVideoResume); + }; + this.surface.addEventListener("playing", onVideoResume); + this.surface.play(); + }; + RenderedCameraImpl.prototype.isPaused = function () { + this.failIfClosed(); + return this.surface.paused; + }; + RenderedCameraImpl.prototype.getSurface = function () { + this.failIfClosed(); + return this.surface; + }; + RenderedCameraImpl.prototype.getRunningTrackCapabilities = function () { + return this.getFirstTrackOrFail().getCapabilities(); + }; + RenderedCameraImpl.prototype.getRunningTrackSettings = function () { + return this.getFirstTrackOrFail().getSettings(); + }; + RenderedCameraImpl.prototype.applyVideoConstraints = function (constraints) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + if ("aspectRatio" in constraints) { + throw "Changing 'aspectRatio' in run-time is not yet supported."; + } + return [2, this.getFirstTrackOrFail().applyConstraints(constraints)]; + }); + }); + }; + RenderedCameraImpl.prototype.close = function () { + if (this.isClosed) { + return Promise.resolve(); + } + var $this = this; + return new Promise(function (resolve, _) { + var tracks = $this.mediaStream.getVideoTracks(); + var tracksToClose = tracks.length; + var tracksClosed = 0; + $this.mediaStream.getVideoTracks().forEach(function (videoTrack) { + $this.mediaStream.removeTrack(videoTrack); + videoTrack.stop(); + ++tracksClosed; + if (tracksClosed >= tracksToClose) { + $this.isClosed = true; + $this.parentElement.removeChild($this.surface); + resolve(); + } + }); + }); + }; + RenderedCameraImpl.prototype.getCapabilities = function () { + return new CameraCapabilitiesImpl(this.getFirstTrackOrFail()); + }; + return RenderedCameraImpl; +}()); +var CameraImpl = (function () { + function CameraImpl(mediaStream) { + this.mediaStream = mediaStream; + } + CameraImpl.prototype.render = function (parentElement, options, callbacks) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2, RenderedCameraImpl.create(parentElement, this.mediaStream, options, callbacks)]; + }); + }); + }; + CameraImpl.create = function (videoConstraints) { + return __awaiter(this, void 0, void 0, function () { + var constraints, mediaStream; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!navigator.mediaDevices) { + throw "navigator.mediaDevices not supported"; + } + constraints = { + audio: false, + video: videoConstraints + }; + return [4, navigator.mediaDevices.getUserMedia(constraints)]; + case 1: + mediaStream = _a.sent(); + return [2, new CameraImpl(mediaStream)]; + } + }); + }); + }; + return CameraImpl; +}()); +exports.CameraImpl = CameraImpl; +//# sourceMappingURL=core-impl.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/core-impl.js.map b/src/main/node_modules/html5-qrcode/cjs/camera/core-impl.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ca20c6e2d6b5477ff7f773baf4bf41ef0bb125a1 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/core-impl.js.map @@ -0,0 +1 @@ +{"version":3,"file":"core-impl.js","sourceRoot":"","sources":["../../../src/camera/core-impl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;IAII,kCAAY,IAAY,EAAE,KAAuB;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAEM,8CAAW,GAAlB;QAII,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE;YAC7B,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;IACrD,CAAC;IAEM,wCAAK,GAAZ,UAAa,KAAQ;QACjB,IAAI,UAAU,GAAQ,EAAE,CAAC;QACzB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC9B,IAAI,WAAW,GAAG,EAAE,QAAQ,EAAE,CAAE,UAAU,CAAE,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;IAEM,wCAAK,GAAZ;QACI,IAAI,QAAQ,GAAQ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,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;oBAC/C,OAAO,EAAE,CAAC;iBACb;YACL,CAAC,CAAC,CAAC;QAGP,CAAC,CAAC,CAAC;IACP,CAAC;IAED,4CAAe,GAAf;QACI,OAAO,IAAI,sBAAsB,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAClE,CAAC;IAEL,yBAAC;AAAD,CAAC,AAzKD,IAyKC;AAGD;IAGI,oBAAoB,WAAwB;QACxC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAEK,2BAAM,GAAZ,UACI,aAA0B,EAC1B,OAA+B,EAC/B,SAA6B;;;gBAE7B,WAAO,kBAAkB,CAAC,MAAM,CAC5B,aAAa,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,EAAC;;;KAC5D;IAEY,iBAAM,GAAnB,UAAoB,gBAAuC;;;;;;wBAEvD,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE;4BACzB,MAAM,sCAAsC,CAAC;yBAChD;wBACG,WAAW,GAA2B;4BACtC,KAAK,EAAE,KAAK;4BACZ,KAAK,EAAE,gBAAgB;yBAC1B,CAAC;wBAEgB,WAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CACvD,WAAW,CAAC,EAAA;;wBADZ,WAAW,GAAG,SACF;wBAChB,WAAO,IAAI,UAAU,CAAC,WAAW,CAAC,EAAC;;;;KACtC;IACL,iBAAC;AAAD,CAAC,AA9BD,IA8BC;AA9BY,gCAAU"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/core.d.ts b/src/main/node_modules/html5-qrcode/cjs/camera/core.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..52e27b5012fe7172a5d7b179174774fe206316ae --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/core.d.ts @@ -0,0 +1,41 @@ +export interface CameraDevice { + id: string; + label: string; +} +export interface CameraCapability<T> { + isSupported(): boolean; + apply(value: T): Promise<void>; + value(): T | null; +} +export interface RangeCameraCapability extends CameraCapability<number> { + min(): number; + max(): number; + step(): number; +} +export interface BooleanCameraCapability extends CameraCapability<boolean> { +} +export interface CameraCapabilities { + zoomFeature(): RangeCameraCapability; + torchFeature(): BooleanCameraCapability; +} +export type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; +export interface RenderingCallbacks { + onRenderSurfaceReady: OnRenderSurfaceReady; +} +export interface RenderedCamera { + getSurface(): HTMLVideoElement; + pause(): void; + resume(onResumeCallback: () => void): void; + isPaused(): boolean; + close(): Promise<void>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + applyVideoConstraints(constraints: MediaTrackConstraints): Promise<void>; + getCapabilities(): CameraCapabilities; +} +export interface CameraRenderingOptions { + aspectRatio?: number; +} +export interface Camera { + render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/core.js b/src/main/node_modules/html5-qrcode/cjs/camera/core.js new file mode 100644 index 0000000000000000000000000000000000000000..383d5be4c25f0cb4c1f8aa3f5d7d49c6bb5a26c9 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/core.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=core.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/core.js.map b/src/main/node_modules/html5-qrcode/cjs/camera/core.js.map new file mode 100644 index 0000000000000000000000000000000000000000..28f32d7a77e4af3d121d2ca609c13019871b22ea --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/core.js.map @@ -0,0 +1 @@ +{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/camera/core.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/factories.d.ts b/src/main/node_modules/html5-qrcode/cjs/camera/factories.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..df98f8ffb0479eb3c807d7e49c6018c3850f8f71 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/factories.d.ts @@ -0,0 +1,6 @@ +import { Camera } from "./core"; +export declare class CameraFactory { + static failIfNotSupported(): Promise<CameraFactory>; + private constructor(); + create(videoConstraints: MediaTrackConstraints): Promise<Camera>; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/factories.js b/src/main/node_modules/html5-qrcode/cjs/camera/factories.js new file mode 100644 index 0000000000000000000000000000000000000000..acbbe117b4f932891df927aed79810a6bb468fa0 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/factories.js @@ -0,0 +1,64 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CameraFactory = void 0; +var core_impl_1 = require("./core-impl"); +var CameraFactory = (function () { + function CameraFactory() { + } + CameraFactory.failIfNotSupported = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + if (!navigator.mediaDevices) { + throw "navigator.mediaDevices not supported"; + } + return [2, new CameraFactory()]; + }); + }); + }; + CameraFactory.prototype.create = function (videoConstraints) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2, core_impl_1.CameraImpl.create(videoConstraints)]; + }); + }); + }; + return CameraFactory; +}()); +exports.CameraFactory = CameraFactory; +//# sourceMappingURL=factories.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/factories.js.map b/src/main/node_modules/html5-qrcode/cjs/camera/factories.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9faf783f7b621f2940af71f4b6bf32eb2b6e2748 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/factories.js.map @@ -0,0 +1 @@ +{"version":3,"file":"factories.js","sourceRoot":"","sources":["../../../src/camera/factories.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,yCAAyC;AAGzC;IAcI;IAAqC,CAAC;IARlB,gCAAkB,GAAtC;;;gBACI,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE;oBACzB,MAAM,sCAAsC,CAAC;iBAChD;gBAED,WAAO,IAAI,aAAa,EAAE,EAAC;;;KAC9B;IAKY,8BAAM,GAAnB,UAAoB,gBAAuC;;;gBAEvD,WAAO,sBAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAC;;;KAC9C;IACL,oBAAC;AAAD,CAAC,AArBD,IAqBC;AArBY,sCAAa"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/permissions.d.ts b/src/main/node_modules/html5-qrcode/cjs/camera/permissions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4209c552093cc9cc5bf1022bd100a4459b988c38 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/permissions.d.ts @@ -0,0 +1,3 @@ +export declare class CameraPermissions { + static hasPermissions(): Promise<boolean>; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/permissions.js b/src/main/node_modules/html5-qrcode/cjs/camera/permissions.js new file mode 100644 index 0000000000000000000000000000000000000000..a8fd8ca94061451e6b99c9780909370063976a21 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/permissions.js @@ -0,0 +1,65 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CameraPermissions = void 0; +var CameraPermissions = (function () { + function CameraPermissions() { + } + CameraPermissions.hasPermissions = function () { + return __awaiter(this, void 0, void 0, function () { + var devices, _i, devices_1, device; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4, navigator.mediaDevices.enumerateDevices()]; + case 1: + devices = _a.sent(); + for (_i = 0, devices_1 = devices; _i < devices_1.length; _i++) { + device = devices_1[_i]; + if (device.kind === "videoinput" && device.label) { + return [2, true]; + } + } + return [2, false]; + } + }); + }); + }; + return CameraPermissions; +}()); +exports.CameraPermissions = CameraPermissions; +//# sourceMappingURL=permissions.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/permissions.js.map b/src/main/node_modules/html5-qrcode/cjs/camera/permissions.js.map new file mode 100644 index 0000000000000000000000000000000000000000..95eb92615e985a19d11ee93f9bf16bd134a8a505 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/permissions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../src/camera/permissions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYC;IAAA;IAqBD,CAAC;IAfuB,gCAAc,GAAlC;;;;;4BAIgB,WAAM,SAAS,CAAC,YAAY,CAAC,gBAAgB,EAAE,EAAA;;wBAAzD,OAAO,GAAG,SAA+C;wBAC7D,WAA4B,EAAP,mBAAO,EAAP,qBAAO,EAAP,IAAO,EAAE;4BAAnB,MAAM;4BAGf,IAAG,MAAM,CAAC,IAAI,KAAK,YAAY,IAAI,MAAM,CAAC,KAAK,EAAE;gCAC/C,WAAO,IAAI,EAAC;6BACb;yBACF;wBAED,WAAO,KAAK,EAAC;;;;KACd;IACL,wBAAC;AAAD,CAAC,AArBA,IAqBA;AArBa,8CAAiB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/retriever.d.ts b/src/main/node_modules/html5-qrcode/cjs/camera/retriever.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0baac120fbc60739f5a0b7b3f59d217b02a41c17 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/retriever.d.ts @@ -0,0 +1,8 @@ +import { CameraDevice } from "./core"; +export declare class CameraRetriever { + static retrieve(): Promise<Array<CameraDevice>>; + private static rejectWithError; + private static isHttpsOrLocalhost; + private static getCamerasFromMediaDevices; + private static getCamerasFromMediaStreamTrack; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/retriever.js b/src/main/node_modules/html5-qrcode/cjs/camera/retriever.js new file mode 100644 index 0000000000000000000000000000000000000000..329c343deeb13d13ba942f5bc5f05a4c8f86ac6b --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/retriever.js @@ -0,0 +1,127 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CameraRetriever = void 0; +var strings_1 = require("../strings"); +var CameraRetriever = (function () { + function CameraRetriever() { + } + CameraRetriever.retrieve = function () { + if (navigator.mediaDevices) { + return CameraRetriever.getCamerasFromMediaDevices(); + } + var mst = MediaStreamTrack; + if (MediaStreamTrack && mst.getSources) { + return CameraRetriever.getCamerasFromMediaStreamTrack(); + } + return CameraRetriever.rejectWithError(); + }; + CameraRetriever.rejectWithError = function () { + var errorMessage = strings_1.Html5QrcodeStrings.unableToQuerySupportedDevices(); + if (!CameraRetriever.isHttpsOrLocalhost()) { + errorMessage = strings_1.Html5QrcodeStrings.insecureContextCameraQueryError(); + } + return Promise.reject(errorMessage); + }; + CameraRetriever.isHttpsOrLocalhost = function () { + if (location.protocol === "https:") { + return true; + } + var host = location.host.split(":")[0]; + return host === "127.0.0.1" || host === "localhost"; + }; + CameraRetriever.getCamerasFromMediaDevices = function () { + return __awaiter(this, void 0, void 0, function () { + var closeActiveStreams, mediaStream, devices, results, _i, devices_1, device; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + closeActiveStreams = function (stream) { + var tracks = stream.getVideoTracks(); + for (var _i = 0, tracks_1 = tracks; _i < tracks_1.length; _i++) { + var track = tracks_1[_i]; + track.enabled = false; + track.stop(); + stream.removeTrack(track); + } + }; + return [4, navigator.mediaDevices.getUserMedia({ audio: false, video: true })]; + case 1: + mediaStream = _a.sent(); + return [4, navigator.mediaDevices.enumerateDevices()]; + case 2: + devices = _a.sent(); + results = []; + for (_i = 0, devices_1 = devices; _i < devices_1.length; _i++) { + device = devices_1[_i]; + if (device.kind === "videoinput") { + results.push({ + id: device.deviceId, + label: device.label + }); + } + } + closeActiveStreams(mediaStream); + return [2, results]; + } + }); + }); + }; + CameraRetriever.getCamerasFromMediaStreamTrack = function () { + return new Promise(function (resolve, _) { + var callback = function (sourceInfos) { + var results = []; + for (var _i = 0, sourceInfos_1 = sourceInfos; _i < sourceInfos_1.length; _i++) { + var sourceInfo = sourceInfos_1[_i]; + if (sourceInfo.kind === "video") { + results.push({ + id: sourceInfo.id, + label: sourceInfo.label + }); + } + } + resolve(results); + }; + var mst = MediaStreamTrack; + mst.getSources(callback); + }); + }; + return CameraRetriever; +}()); +exports.CameraRetriever = CameraRetriever; +//# sourceMappingURL=retriever.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/camera/retriever.js.map b/src/main/node_modules/html5-qrcode/cjs/camera/retriever.js.map new file mode 100644 index 0000000000000000000000000000000000000000..15cd41b981d1d6aabc26e72b236d9bec6e442d22 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/camera/retriever.js.map @@ -0,0 +1 @@ +{"version":3,"file":"retriever.js","sourceRoot":"","sources":["../../../src/camera/retriever.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,sCAAgD;AAGhD;IAAA;IAiFA,CAAC;IA9EiB,wBAAQ,GAAtB;QACI,IAAI,SAAS,CAAC,YAAY,EAAE;YACxB,OAAO,eAAe,CAAC,0BAA0B,EAAE,CAAC;SACvD;QAGD,IAAI,GAAG,GAAQ,gBAAgB,CAAC;QAChC,IAAI,gBAAgB,IAAI,GAAG,CAAC,UAAU,EAAE;YACpC,OAAO,eAAe,CAAC,8BAA8B,EAAE,CAAC;SAC3D;QAED,OAAO,eAAe,CAAC,eAAe,EAAE,CAAC;IAC7C,CAAC;IAEc,+BAAe,GAA9B;QAEI,IAAI,YAAY,GAAG,4BAAkB,CAAC,6BAA6B,EAAE,CAAC;QACtE,IAAI,CAAC,eAAe,CAAC,kBAAkB,EAAE,EAAE;YACvC,YAAY,GAAG,4BAAkB,CAAC,+BAA+B,EAAE,CAAC;SACvE;QACD,OAAO,OAAO,CAAC,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AC,CAAC;wBAChC,WAAO,OAAO,EAAC;;;;KAClB;IAEc,8CAA8B,GAA7C;QAEI,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,CAAC;YAC1B,IAAM,QAAQ,GAAG,UAAC,WAAuB;gBACrC,IAAM,OAAO,GAAwB,EAAE,CAAC;gBACxC,KAAyB,UAAW,EAAX,2BAAW,EAAX,yBAAW,EAAX,IAAW,EAAE;oBAAjC,IAAM,UAAU,oBAAA;oBACjB,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE;wBAC7B,OAAO,CAAC,IAAI,CAAC;4BACT,EAAE,EAAE,UAAU,CAAC,EAAE;4BACjB,KAAK,EAAE,UAAU,CAAC,KAAK;yBAC1B,CAAC,CAAC;qBACN;iBACJ;gBACD,OAAO,CAAC,OAAO,CAAC,CAAC;YACrB,CAAC,CAAA;YAED,IAAI,GAAG,GAAQ,gBAAgB,CAAC;YAChC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACP,CAAC;IACL,sBAAC;AAAD,CAAC,AAjFD,IAiFC;AAjFY,0CAAe"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/code-decoder.d.ts b/src/main/node_modules/html5-qrcode/cjs/code-decoder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13d5426a74815c3ff33f9221d161b055910a693c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/code-decoder.d.ts @@ -0,0 +1,16 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, Logger, RobustQrcodeDecoderAsync } from "./core"; +export declare class Html5QrcodeShim implements RobustQrcodeDecoderAsync { + private verbose; + private primaryDecoder; + private secondaryDecoder; + private readonly EXECUTIONS_TO_REPORT_PERFORMANCE; + private executions; + private executionResults; + private wasPrimaryDecoderUsedInLastDecode; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, useBarCodeDetectorIfSupported: boolean, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + decodeRobustlyAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private getDecoder; + private possiblyLogPerformance; + possiblyFlushPerformanceReport(): void; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/code-decoder.js b/src/main/node_modules/html5-qrcode/cjs/code-decoder.js new file mode 100644 index 0000000000000000000000000000000000000000..1815562307aaf8eacecf2a17d464835ec976d66c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/code-decoder.js @@ -0,0 +1,141 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Html5QrcodeShim = void 0; +var zxing_html5_qrcode_decoder_1 = require("./zxing-html5-qrcode-decoder"); +var native_bar_code_detector_1 = require("./native-bar-code-detector"); +var Html5QrcodeShim = (function () { + function Html5QrcodeShim(requestedFormats, useBarCodeDetectorIfSupported, verbose, logger) { + this.EXECUTIONS_TO_REPORT_PERFORMANCE = 100; + this.executions = 0; + this.executionResults = []; + this.wasPrimaryDecoderUsedInLastDecode = false; + this.verbose = verbose; + if (useBarCodeDetectorIfSupported + && native_bar_code_detector_1.BarcodeDetectorDelegate.isSupported()) { + this.primaryDecoder = new native_bar_code_detector_1.BarcodeDetectorDelegate(requestedFormats, verbose, logger); + this.secondaryDecoder = new zxing_html5_qrcode_decoder_1.ZXingHtml5QrcodeDecoder(requestedFormats, verbose, logger); + } + else { + this.primaryDecoder = new zxing_html5_qrcode_decoder_1.ZXingHtml5QrcodeDecoder(requestedFormats, verbose, logger); + } + } + Html5QrcodeShim.prototype.decodeAsync = function (canvas) { + return __awaiter(this, void 0, void 0, function () { + var startTime; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + startTime = performance.now(); + _a.label = 1; + case 1: + _a.trys.push([1, , 3, 4]); + return [4, this.getDecoder().decodeAsync(canvas)]; + case 2: return [2, _a.sent()]; + case 3: + this.possiblyLogPerformance(startTime); + return [7]; + case 4: return [2]; + } + }); + }); + }; + Html5QrcodeShim.prototype.decodeRobustlyAsync = function (canvas) { + return __awaiter(this, void 0, void 0, function () { + var startTime, error_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + startTime = performance.now(); + _a.label = 1; + case 1: + _a.trys.push([1, 3, 4, 5]); + return [4, this.primaryDecoder.decodeAsync(canvas)]; + case 2: return [2, _a.sent()]; + case 3: + error_1 = _a.sent(); + if (this.secondaryDecoder) { + return [2, this.secondaryDecoder.decodeAsync(canvas)]; + } + throw error_1; + case 4: + this.possiblyLogPerformance(startTime); + return [7]; + case 5: return [2]; + } + }); + }); + }; + Html5QrcodeShim.prototype.getDecoder = function () { + if (!this.secondaryDecoder) { + return this.primaryDecoder; + } + if (this.wasPrimaryDecoderUsedInLastDecode === false) { + this.wasPrimaryDecoderUsedInLastDecode = true; + return this.primaryDecoder; + } + this.wasPrimaryDecoderUsedInLastDecode = false; + return this.secondaryDecoder; + }; + Html5QrcodeShim.prototype.possiblyLogPerformance = function (startTime) { + if (!this.verbose) { + return; + } + var executionTime = performance.now() - startTime; + this.executionResults.push(executionTime); + this.executions++; + this.possiblyFlushPerformanceReport(); + }; + Html5QrcodeShim.prototype.possiblyFlushPerformanceReport = function () { + if (this.executions < this.EXECUTIONS_TO_REPORT_PERFORMANCE) { + return; + } + var sum = 0; + for (var _i = 0, _a = this.executionResults; _i < _a.length; _i++) { + var executionTime = _a[_i]; + sum += executionTime; + } + var mean = sum / this.executionResults.length; + console.log("".concat(mean, " ms for ").concat(this.executionResults.length, " last runs.")); + this.executions = 0; + this.executionResults = []; + }; + return Html5QrcodeShim; +}()); +exports.Html5QrcodeShim = Html5QrcodeShim; +//# sourceMappingURL=code-decoder.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/code-decoder.js.map b/src/main/node_modules/html5-qrcode/cjs/code-decoder.js.map new file mode 100644 index 0000000000000000000000000000000000000000..7c8f6931b8d6da74e0beffc2590a108ff7fb0a6d --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/code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C;QAE9C,OAAO,CAAC,GAAG,CAAC,UAAG,IAAI,qBAAW,IAAI,CAAC,gBAAgB,CAAC,MAAM,gBAAa,CAAC,CAAC;QACzE,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC/B,CAAC;IACL,sBAAC;AAAD,CAAC,AApGD,IAoGC;AApGY,0CAAe"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/core.d.ts b/src/main/node_modules/html5-qrcode/cjs/core.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d0206d4fcf87446a1161cd3b548b3196d9262be --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/core.d.ts @@ -0,0 +1,105 @@ +export declare enum Html5QrcodeSupportedFormats { + QR_CODE = 0, + AZTEC = 1, + CODABAR = 2, + CODE_39 = 3, + CODE_93 = 4, + CODE_128 = 5, + DATA_MATRIX = 6, + MAXICODE = 7, + ITF = 8, + EAN_13 = 9, + EAN_8 = 10, + PDF_417 = 11, + RSS_14 = 12, + RSS_EXPANDED = 13, + UPC_A = 14, + UPC_E = 15, + UPC_EAN_EXTENSION = 16 +} +export declare enum DecodedTextType { + UNKNOWN = 0, + URL = 1 +} +export declare function isValidHtml5QrcodeSupportedFormats(format: any): boolean; +export declare enum Html5QrcodeScanType { + SCAN_TYPE_CAMERA = 0, + SCAN_TYPE_FILE = 1 +} +export declare class Html5QrcodeConstants { + static GITHUB_PROJECT_URL: string; + static SCAN_DEFAULT_FPS: number; + static DEFAULT_DISABLE_FLIP: boolean; + static DEFAULT_REMEMBER_LAST_CAMERA_USED: boolean; + static DEFAULT_SUPPORTED_SCAN_TYPE: Html5QrcodeScanType[]; +} +export interface QrDimensions { + width: number; + height: number; +} +export type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; +export interface QrBounds extends QrDimensions { + x: number; + y: number; +} +export declare class QrcodeResultFormat { + readonly format: Html5QrcodeSupportedFormats; + readonly formatName: string; + private constructor(); + toString(): string; + static create(format: Html5QrcodeSupportedFormats): QrcodeResultFormat; +} +export interface QrcodeResultDebugData { + decoderName?: string; +} +export interface QrcodeResult { + text: string; + format?: QrcodeResultFormat; + bounds?: QrBounds; + decodedTextType?: DecodedTextType; + debugData?: QrcodeResultDebugData; +} +export interface Html5QrcodeResult { + decodedText: string; + result: QrcodeResult; +} +export declare class Html5QrcodeResultFactory { + static createFromText(decodedText: string): Html5QrcodeResult; + static createFromQrcodeResult(qrcodeResult: QrcodeResult): Html5QrcodeResult; +} +export declare enum Html5QrcodeErrorTypes { + UNKWOWN_ERROR = 0, + IMPLEMENTATION_ERROR = 1, + NO_CODE_FOUND_ERROR = 2 +} +export interface Html5QrcodeError { + errorMessage: string; + type: Html5QrcodeErrorTypes; +} +export declare class Html5QrcodeErrorFactory { + static createFrom(error: any): Html5QrcodeError; +} +export type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; +export type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; +export interface QrcodeDecoderAsync { + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; +} +export interface RobustQrcodeDecoderAsync extends QrcodeDecoderAsync { + decodeRobustlyAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; +} +export interface Logger { + log(message: string): void; + warn(message: string): void; + logError(message: string, isExperimental?: boolean): void; + logErrors(errors: Array<any>): void; +} +export declare class BaseLoggger implements Logger { + private verbose; + constructor(verbose: boolean); + log(message: string): void; + warn(message: string): void; + logError(message: string, isExperimental?: boolean): void; + logErrors(errors: Array<any>): void; +} +export declare function isNullOrUndefined(obj?: any): boolean; +export declare function clip(value: number, minValue: number, maxValue: number): number; diff --git a/src/main/node_modules/html5-qrcode/cjs/core.js b/src/main/node_modules/html5-qrcode/cjs/core.js new file mode 100644 index 0000000000000000000000000000000000000000..cbac339f1a9f28bba4a7c23412c5ac96d83932a9 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/core.js @@ -0,0 +1,171 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.clip = exports.isNullOrUndefined = exports.BaseLoggger = exports.Html5QrcodeErrorFactory = exports.Html5QrcodeErrorTypes = exports.Html5QrcodeResultFactory = exports.QrcodeResultFormat = exports.Html5QrcodeConstants = exports.Html5QrcodeScanType = exports.isValidHtml5QrcodeSupportedFormats = exports.DecodedTextType = exports.Html5QrcodeSupportedFormats = void 0; +var Html5QrcodeSupportedFormats; +(function (Html5QrcodeSupportedFormats) { + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["QR_CODE"] = 0] = "QR_CODE"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["AZTEC"] = 1] = "AZTEC"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["CODABAR"] = 2] = "CODABAR"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["CODE_39"] = 3] = "CODE_39"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["CODE_93"] = 4] = "CODE_93"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["CODE_128"] = 5] = "CODE_128"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["DATA_MATRIX"] = 6] = "DATA_MATRIX"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["MAXICODE"] = 7] = "MAXICODE"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["ITF"] = 8] = "ITF"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["EAN_13"] = 9] = "EAN_13"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["EAN_8"] = 10] = "EAN_8"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["PDF_417"] = 11] = "PDF_417"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["RSS_14"] = 12] = "RSS_14"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["RSS_EXPANDED"] = 13] = "RSS_EXPANDED"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["UPC_A"] = 14] = "UPC_A"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["UPC_E"] = 15] = "UPC_E"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["UPC_EAN_EXTENSION"] = 16] = "UPC_EAN_EXTENSION"; +})(Html5QrcodeSupportedFormats = exports.Html5QrcodeSupportedFormats || (exports.Html5QrcodeSupportedFormats = {})); +var html5QrcodeSupportedFormatsTextMap = new Map([ + [Html5QrcodeSupportedFormats.QR_CODE, "QR_CODE"], + [Html5QrcodeSupportedFormats.AZTEC, "AZTEC"], + [Html5QrcodeSupportedFormats.CODABAR, "CODABAR"], + [Html5QrcodeSupportedFormats.CODE_39, "CODE_39"], + [Html5QrcodeSupportedFormats.CODE_93, "CODE_93"], + [Html5QrcodeSupportedFormats.CODE_128, "CODE_128"], + [Html5QrcodeSupportedFormats.DATA_MATRIX, "DATA_MATRIX"], + [Html5QrcodeSupportedFormats.MAXICODE, "MAXICODE"], + [Html5QrcodeSupportedFormats.ITF, "ITF"], + [Html5QrcodeSupportedFormats.EAN_13, "EAN_13"], + [Html5QrcodeSupportedFormats.EAN_8, "EAN_8"], + [Html5QrcodeSupportedFormats.PDF_417, "PDF_417"], + [Html5QrcodeSupportedFormats.RSS_14, "RSS_14"], + [Html5QrcodeSupportedFormats.RSS_EXPANDED, "RSS_EXPANDED"], + [Html5QrcodeSupportedFormats.UPC_A, "UPC_A"], + [Html5QrcodeSupportedFormats.UPC_E, "UPC_E"], + [Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, "UPC_EAN_EXTENSION"] +]); +var DecodedTextType; +(function (DecodedTextType) { + DecodedTextType[DecodedTextType["UNKNOWN"] = 0] = "UNKNOWN"; + DecodedTextType[DecodedTextType["URL"] = 1] = "URL"; +})(DecodedTextType = exports.DecodedTextType || (exports.DecodedTextType = {})); +function isValidHtml5QrcodeSupportedFormats(format) { + return Object.values(Html5QrcodeSupportedFormats).includes(format); +} +exports.isValidHtml5QrcodeSupportedFormats = isValidHtml5QrcodeSupportedFormats; +var Html5QrcodeScanType; +(function (Html5QrcodeScanType) { + Html5QrcodeScanType[Html5QrcodeScanType["SCAN_TYPE_CAMERA"] = 0] = "SCAN_TYPE_CAMERA"; + Html5QrcodeScanType[Html5QrcodeScanType["SCAN_TYPE_FILE"] = 1] = "SCAN_TYPE_FILE"; +})(Html5QrcodeScanType = exports.Html5QrcodeScanType || (exports.Html5QrcodeScanType = {})); +var Html5QrcodeConstants = (function () { + function Html5QrcodeConstants() { + } + Html5QrcodeConstants.GITHUB_PROJECT_URL = "https://github.com/mebjas/html5-qrcode"; + Html5QrcodeConstants.SCAN_DEFAULT_FPS = 2; + Html5QrcodeConstants.DEFAULT_DISABLE_FLIP = false; + Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED = true; + Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE = [ + Html5QrcodeScanType.SCAN_TYPE_CAMERA, + Html5QrcodeScanType.SCAN_TYPE_FILE + ]; + return Html5QrcodeConstants; +}()); +exports.Html5QrcodeConstants = Html5QrcodeConstants; +var QrcodeResultFormat = (function () { + function QrcodeResultFormat(format, formatName) { + this.format = format; + this.formatName = formatName; + } + QrcodeResultFormat.prototype.toString = function () { + return this.formatName; + }; + QrcodeResultFormat.create = function (format) { + if (!html5QrcodeSupportedFormatsTextMap.has(format)) { + throw "".concat(format, " not in html5QrcodeSupportedFormatsTextMap"); + } + return new QrcodeResultFormat(format, html5QrcodeSupportedFormatsTextMap.get(format)); + }; + return QrcodeResultFormat; +}()); +exports.QrcodeResultFormat = QrcodeResultFormat; +var Html5QrcodeResultFactory = (function () { + function Html5QrcodeResultFactory() { + } + Html5QrcodeResultFactory.createFromText = function (decodedText) { + var qrcodeResult = { + text: decodedText + }; + return { + decodedText: decodedText, + result: qrcodeResult + }; + }; + Html5QrcodeResultFactory.createFromQrcodeResult = function (qrcodeResult) { + return { + decodedText: qrcodeResult.text, + result: qrcodeResult + }; + }; + return Html5QrcodeResultFactory; +}()); +exports.Html5QrcodeResultFactory = Html5QrcodeResultFactory; +var Html5QrcodeErrorTypes; +(function (Html5QrcodeErrorTypes) { + Html5QrcodeErrorTypes[Html5QrcodeErrorTypes["UNKWOWN_ERROR"] = 0] = "UNKWOWN_ERROR"; + Html5QrcodeErrorTypes[Html5QrcodeErrorTypes["IMPLEMENTATION_ERROR"] = 1] = "IMPLEMENTATION_ERROR"; + Html5QrcodeErrorTypes[Html5QrcodeErrorTypes["NO_CODE_FOUND_ERROR"] = 2] = "NO_CODE_FOUND_ERROR"; +})(Html5QrcodeErrorTypes = exports.Html5QrcodeErrorTypes || (exports.Html5QrcodeErrorTypes = {})); +var Html5QrcodeErrorFactory = (function () { + function Html5QrcodeErrorFactory() { + } + Html5QrcodeErrorFactory.createFrom = function (error) { + return { + errorMessage: error, + type: Html5QrcodeErrorTypes.UNKWOWN_ERROR + }; + }; + return Html5QrcodeErrorFactory; +}()); +exports.Html5QrcodeErrorFactory = Html5QrcodeErrorFactory; +var BaseLoggger = (function () { + function BaseLoggger(verbose) { + this.verbose = verbose; + } + BaseLoggger.prototype.log = function (message) { + if (this.verbose) { + console.log(message); + } + }; + BaseLoggger.prototype.warn = function (message) { + if (this.verbose) { + console.warn(message); + } + }; + BaseLoggger.prototype.logError = function (message, isExperimental) { + if (this.verbose || isExperimental === true) { + console.error(message); + } + }; + BaseLoggger.prototype.logErrors = function (errors) { + if (errors.length === 0) { + throw "Logger#logError called without arguments"; + } + if (this.verbose) { + console.error(errors); + } + }; + return BaseLoggger; +}()); +exports.BaseLoggger = BaseLoggger; +function isNullOrUndefined(obj) { + return (typeof obj === "undefined") || obj === null; +} +exports.isNullOrUndefined = isNullOrUndefined; +function clip(value, minValue, maxValue) { + if (value > maxValue) { + return maxValue; + } + if (value < minValue) { + return minValue; + } + return value; +} +exports.clip = clip; +//# sourceMappingURL=core.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/core.js.map b/src/main/node_modules/html5-qrcode/cjs/core.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a7246099ba5f3179e1a8d766d7b6fb5febd98352 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/core.js.map @@ -0,0 +1 @@ +{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;;AAaA,IAAY,2BAkBX;AAlBD,WAAY,2BAA2B;IACnC,mFAAW,CAAA;IACX,+EAAK,CAAA;IACL,mFAAO,CAAA;IACP,mFAAO,CAAA;IACP,mFAAO,CAAA;IACP,qFAAQ,CAAA;IACR,2FAAW,CAAA;IACX,qFAAQ,CAAA;IACR,2EAAG,CAAA;IACH,iFAAM,CAAA;IACN,gFAAK,CAAA;IACL,oFAAO,CAAA;IACP,kFAAM,CAAA;IACN,8FAAY,CAAA;IACZ,gFAAK,CAAA;IACL,gFAAK,CAAA;IACL,wGAAiB,CAAA;AACrB,CAAC,EAlBW,2BAA2B,GAA3B,mCAA2B,KAA3B,mCAA2B,QAkBtC;AAGD,IAAM,kCAAkC,GACS,IAAI,GAAG,CACpD;IACI,CAAE,2BAA2B,CAAC,OAAO,EAAE,SAAS,CAAE;IAClD,CAAE,2BAA2B,CAAC,KAAK,EAAE,OAAO,CAAE;IAC9C,CAAE,2BAA2B,CAAC,OAAO,EAAE,SAAS,CAAE;IAClD,CAAE,2BAA2B,CAAC,OAAO,EAAE,SAAS,CAAE;IAClD,CAAE,2BAA2B,CAAC,OAAO,EAAE,SAAS,CAAE;IAClD,CAAE,2BAA2B,CAAC,QAAQ,EAAE,UAAU,CAAE;IACpD,CAAE,2BAA2B,CAAC,WAAW,EAAE,aAAa,CAAE;IAC1D,CAAE,2BAA2B,CAAC,QAAQ,EAAE,UAAU,CAAE;IACpD,CAAE,2BAA2B,CAAC,GAAG,EAAE,KAAK,CAAE;IAC1C,CAAE,2BAA2B,CAAC,MAAM,EAAE,QAAQ,CAAE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AAV,UAAW,OAAe;QACtB,IAAI,IAAI,CAAC,OAAO,EAAE;YAEd,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SACxB;IACL,CAAC;IAEM,0BAAI,GAAX,UAAY,OAAe;QACvB,IAAI,IAAI,CAAC,OAAO,EAAE;YAEd,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACzB;IACL,CAAC;IAEM,8BAAQ,GAAf,UAAgB,OAAe,EAAE,cAAwB;QAErD,IAAI,IAAI,CAAC,OAAO,IAAI,cAAc,KAAK,IAAI,EAAE;YAEzC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SAC1B;IACL,CAAC;IAEM,+BAAS,GAAhB,UAAiB,MAAkB;QAC/B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,MAAM,0CAA0C,CAAC;SACpD;QACD,IAAI,IAAI,CAAC,OAAO,EAAE;YAEd,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SACzB;IACL,CAAC;IACL,kBAAC;AAAD,CAAC,AAvCD,IAuCC;AAvCY,kCAAW;AA2CxB,SAAgB,iBAAiB,CAAC,GAAS;IACvC,OAAO,CAAC,OAAO,GAAG,KAAK,WAAW,CAAC,IAAI,GAAG,KAAK,IAAI,CAAC;AACxD,CAAC;AAFD,8CAEC;AAGD,SAAgB,IAAI,CAAC,KAAa,EAAE,QAAgB,EAAE,QAAgB;IAClE,IAAI,KAAK,GAAG,QAAQ,EAAE;QAClB,OAAO,QAAQ,CAAC;KACnB;IACD,IAAI,KAAK,GAAG,QAAQ,EAAE;QAClB,OAAO,QAAQ,CAAC;KACnB;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AATD,oBASC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/experimental-features.d.ts b/src/main/node_modules/html5-qrcode/cjs/experimental-features.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0413abebd02d9788902f9ad47e60d2673507c5fe --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/experimental-features.d.ts @@ -0,0 +1,3 @@ +export interface ExperimentalFeaturesConfig { + useBarCodeDetectorIfSupported?: boolean | undefined; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/experimental-features.js b/src/main/node_modules/html5-qrcode/cjs/experimental-features.js new file mode 100644 index 0000000000000000000000000000000000000000..ecfcd7e78e6262dd6c48e01c01ee256cf3690e15 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/experimental-features.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=experimental-features.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/experimental-features.js.map b/src/main/node_modules/html5-qrcode/cjs/experimental-features.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8b8b9dd178d10babd1110d7f0ea70f9b1c95e641 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/experimental-features.js.map @@ -0,0 +1 @@ +{"version":3,"file":"experimental-features.js","sourceRoot":"","sources":["../../src/experimental-features.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/html5-qrcode-scanner.d.ts b/src/main/node_modules/html5-qrcode/cjs/html5-qrcode-scanner.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..417175bc07418ec36023c076274aef557b25f42b --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/html5-qrcode-scanner.d.ts @@ -0,0 +1,67 @@ +import { Html5QrcodeScanType, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; +import { Html5QrcodeConfigs, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; +import { Html5QrcodeScannerState } from "./state-manager"; +export interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { + rememberLastUsedCamera?: boolean | undefined; + supportedScanTypes?: Array<Html5QrcodeScanType> | []; + showTorchButtonIfSupported?: boolean | undefined; + showZoomSliderIfSupported?: boolean | undefined; + defaultZoomValueIfSupported?: number | undefined; +} +export declare class Html5QrcodeScanner { + private elementId; + private config; + private verbose; + private currentScanType; + private sectionSwapAllowed; + private persistedDataManager; + private scanTypeSelector; + private logger; + private html5Qrcode; + private qrCodeSuccessCallback; + private qrCodeErrorCallback; + private lastMatchFound; + private cameraScanImage; + private fileScanImage; + private fileSelectionUi; + constructor(elementId: string, config: Html5QrcodeScannerConfig | undefined, verbose: boolean | undefined); + render(qrCodeSuccessCallback: QrcodeSuccessCallback, qrCodeErrorCallback: QrcodeErrorCallback | undefined): void; + pause(shouldPauseVideo?: boolean): void; + resume(): void; + getState(): Html5QrcodeScannerState; + clear(): Promise<void>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + applyVideoConstraints(videoConstaints: MediaTrackConstraints): Promise<void>; + private getHtml5QrcodeOrFail; + private createConfig; + private createBasicLayout; + private resetBasicLayout; + private setupInitialDashboard; + private createHeader; + private createSection; + private createCameraListUi; + private createPermissionButton; + private createPermissionsUi; + private createSectionControlPanel; + private renderFileScanUi; + private renderCameraSelection; + private createSectionSwap; + private startCameraScanIfPermissionExistsOnSwap; + private resetHeaderMessage; + private setHeaderMessage; + private showHideScanTypeSwapLink; + private insertCameraScanImageToScanRegion; + private insertFileScanImageToScanRegion; + private clearScanRegion; + private getDashboardSectionId; + private getDashboardSectionCameraScanRegionId; + private getDashboardSectionSwapLinkId; + private getScanRegionId; + private getDashboardId; + private getHeaderMessageContainerId; + private getCameraPermissionButtonId; + private getCameraScanRegion; + private getDashboardSectionSwapLink; + private getHeaderMessageDiv; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/html5-qrcode-scanner.js b/src/main/node_modules/html5-qrcode/cjs/html5-qrcode-scanner.js new file mode 100644 index 0000000000000000000000000000000000000000..200425c0da70ecfcbfe8dbb5db6e5833c7c55494 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/html5-qrcode-scanner.js @@ -0,0 +1,661 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Html5QrcodeScanner = void 0; +var core_1 = require("./core"); +var html5_qrcode_1 = require("./html5-qrcode"); +var strings_1 = require("./strings"); +var image_assets_1 = require("./image-assets"); +var storage_1 = require("./storage"); +var ui_1 = require("./ui"); +var permissions_1 = require("./camera/permissions"); +var scan_type_selector_1 = require("./ui/scanner/scan-type-selector"); +var torch_button_1 = require("./ui/scanner/torch-button"); +var file_selection_ui_1 = require("./ui/scanner/file-selection-ui"); +var base_1 = require("./ui/scanner/base"); +var camera_selection_ui_1 = require("./ui/scanner/camera-selection-ui"); +var camera_zoom_ui_1 = require("./ui/scanner/camera-zoom-ui"); +var Html5QrcodeScannerStatus; +(function (Html5QrcodeScannerStatus) { + Html5QrcodeScannerStatus[Html5QrcodeScannerStatus["STATUS_DEFAULT"] = 0] = "STATUS_DEFAULT"; + Html5QrcodeScannerStatus[Html5QrcodeScannerStatus["STATUS_SUCCESS"] = 1] = "STATUS_SUCCESS"; + Html5QrcodeScannerStatus[Html5QrcodeScannerStatus["STATUS_WARNING"] = 2] = "STATUS_WARNING"; + Html5QrcodeScannerStatus[Html5QrcodeScannerStatus["STATUS_REQUESTING_PERMISSION"] = 3] = "STATUS_REQUESTING_PERMISSION"; +})(Html5QrcodeScannerStatus || (Html5QrcodeScannerStatus = {})); +function toHtml5QrcodeCameraScanConfig(config) { + return { + fps: config.fps, + qrbox: config.qrbox, + aspectRatio: config.aspectRatio, + disableFlip: config.disableFlip, + videoConstraints: config.videoConstraints + }; +} +function toHtml5QrcodeFullConfig(config, verbose) { + return { + formatsToSupport: config.formatsToSupport, + useBarCodeDetectorIfSupported: config.useBarCodeDetectorIfSupported, + experimentalFeatures: config.experimentalFeatures, + verbose: verbose + }; +} +var Html5QrcodeScanner = (function () { + function Html5QrcodeScanner(elementId, config, verbose) { + this.lastMatchFound = null; + this.cameraScanImage = null; + this.fileScanImage = null; + this.fileSelectionUi = null; + this.elementId = elementId; + this.config = this.createConfig(config); + this.verbose = verbose === true; + if (!document.getElementById(elementId)) { + throw "HTML Element with id=".concat(elementId, " not found"); + } + this.scanTypeSelector = new scan_type_selector_1.ScanTypeSelector(this.config.supportedScanTypes); + this.currentScanType = this.scanTypeSelector.getDefaultScanType(); + this.sectionSwapAllowed = true; + this.logger = new core_1.BaseLoggger(this.verbose); + this.persistedDataManager = new storage_1.PersistedDataManager(); + if (config.rememberLastUsedCamera !== true) { + this.persistedDataManager.reset(); + } + } + Html5QrcodeScanner.prototype.render = function (qrCodeSuccessCallback, qrCodeErrorCallback) { + var _this = this; + this.lastMatchFound = null; + this.qrCodeSuccessCallback + = function (decodedText, result) { + if (qrCodeSuccessCallback) { + qrCodeSuccessCallback(decodedText, result); + } + else { + if (_this.lastMatchFound === decodedText) { + return; + } + _this.lastMatchFound = decodedText; + _this.setHeaderMessage(strings_1.Html5QrcodeScannerStrings.lastMatch(decodedText), Html5QrcodeScannerStatus.STATUS_SUCCESS); + } + }; + this.qrCodeErrorCallback = + function (errorMessage, error) { + if (qrCodeErrorCallback) { + qrCodeErrorCallback(errorMessage, error); + } + }; + var container = document.getElementById(this.elementId); + if (!container) { + throw "HTML Element with id=".concat(this.elementId, " not found"); + } + container.innerHTML = ""; + this.createBasicLayout(container); + this.html5Qrcode = new html5_qrcode_1.Html5Qrcode(this.getScanRegionId(), toHtml5QrcodeFullConfig(this.config, this.verbose)); + }; + Html5QrcodeScanner.prototype.pause = function (shouldPauseVideo) { + if ((0, core_1.isNullOrUndefined)(shouldPauseVideo) || shouldPauseVideo !== true) { + shouldPauseVideo = false; + } + this.getHtml5QrcodeOrFail().pause(shouldPauseVideo); + }; + Html5QrcodeScanner.prototype.resume = function () { + this.getHtml5QrcodeOrFail().resume(); + }; + Html5QrcodeScanner.prototype.getState = function () { + return this.getHtml5QrcodeOrFail().getState(); + }; + Html5QrcodeScanner.prototype.clear = function () { + var _this = this; + var emptyHtmlContainer = function () { + var mainContainer = document.getElementById(_this.elementId); + if (mainContainer) { + mainContainer.innerHTML = ""; + _this.resetBasicLayout(mainContainer); + } + }; + if (this.html5Qrcode) { + return new Promise(function (resolve, reject) { + if (!_this.html5Qrcode) { + resolve(); + return; + } + if (_this.html5Qrcode.isScanning) { + _this.html5Qrcode.stop().then(function (_) { + if (!_this.html5Qrcode) { + resolve(); + return; + } + _this.html5Qrcode.clear(); + emptyHtmlContainer(); + resolve(); + }).catch(function (error) { + if (_this.verbose) { + _this.logger.logError("Unable to stop qrcode scanner", error); + } + reject(error); + }); + } + else { + _this.html5Qrcode.clear(); + emptyHtmlContainer(); + resolve(); + } + }); + } + return Promise.resolve(); + }; + Html5QrcodeScanner.prototype.getRunningTrackCapabilities = function () { + return this.getHtml5QrcodeOrFail().getRunningTrackCapabilities(); + }; + Html5QrcodeScanner.prototype.getRunningTrackSettings = function () { + return this.getHtml5QrcodeOrFail().getRunningTrackSettings(); + }; + Html5QrcodeScanner.prototype.applyVideoConstraints = function (videoConstaints) { + return this.getHtml5QrcodeOrFail().applyVideoConstraints(videoConstaints); + }; + Html5QrcodeScanner.prototype.getHtml5QrcodeOrFail = function () { + if (!this.html5Qrcode) { + throw "Code scanner not initialized."; + } + return this.html5Qrcode; + }; + Html5QrcodeScanner.prototype.createConfig = function (config) { + if (config) { + if (!config.fps) { + config.fps = core_1.Html5QrcodeConstants.SCAN_DEFAULT_FPS; + } + if (config.rememberLastUsedCamera !== (!core_1.Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED)) { + config.rememberLastUsedCamera + = core_1.Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED; + } + if (!config.supportedScanTypes) { + config.supportedScanTypes + = core_1.Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE; + } + return config; + } + return { + fps: core_1.Html5QrcodeConstants.SCAN_DEFAULT_FPS, + rememberLastUsedCamera: core_1.Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED, + supportedScanTypes: core_1.Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE + }; + }; + Html5QrcodeScanner.prototype.createBasicLayout = function (parent) { + parent.style.position = "relative"; + parent.style.padding = "0px"; + parent.style.border = "1px solid silver"; + this.createHeader(parent); + var qrCodeScanRegion = document.createElement("div"); + var scanRegionId = this.getScanRegionId(); + qrCodeScanRegion.id = scanRegionId; + qrCodeScanRegion.style.width = "100%"; + qrCodeScanRegion.style.minHeight = "100px"; + qrCodeScanRegion.style.textAlign = "center"; + parent.appendChild(qrCodeScanRegion); + if (scan_type_selector_1.ScanTypeSelector.isCameraScanType(this.currentScanType)) { + this.insertCameraScanImageToScanRegion(); + } + else { + this.insertFileScanImageToScanRegion(); + } + var qrCodeDashboard = document.createElement("div"); + var dashboardId = this.getDashboardId(); + qrCodeDashboard.id = dashboardId; + qrCodeDashboard.style.width = "100%"; + parent.appendChild(qrCodeDashboard); + this.setupInitialDashboard(qrCodeDashboard); + }; + Html5QrcodeScanner.prototype.resetBasicLayout = function (mainContainer) { + mainContainer.style.border = "none"; + }; + Html5QrcodeScanner.prototype.setupInitialDashboard = function (dashboard) { + this.createSection(dashboard); + this.createSectionControlPanel(); + if (this.scanTypeSelector.hasMoreThanOneScanType()) { + this.createSectionSwap(); + } + }; + Html5QrcodeScanner.prototype.createHeader = function (dashboard) { + var header = document.createElement("div"); + header.style.textAlign = "left"; + header.style.margin = "0px"; + dashboard.appendChild(header); + var libraryInfo = new ui_1.LibraryInfoContainer(); + libraryInfo.renderInto(header); + var headerMessageContainer = document.createElement("div"); + headerMessageContainer.id = this.getHeaderMessageContainerId(); + headerMessageContainer.style.display = "none"; + headerMessageContainer.style.textAlign = "center"; + headerMessageContainer.style.fontSize = "14px"; + headerMessageContainer.style.padding = "2px 10px"; + headerMessageContainer.style.margin = "4px"; + headerMessageContainer.style.borderTop = "1px solid #f6f6f6"; + header.appendChild(headerMessageContainer); + }; + Html5QrcodeScanner.prototype.createSection = function (dashboard) { + var section = document.createElement("div"); + section.id = this.getDashboardSectionId(); + section.style.width = "100%"; + section.style.padding = "10px 0px 10px 0px"; + section.style.textAlign = "left"; + dashboard.appendChild(section); + }; + Html5QrcodeScanner.prototype.createCameraListUi = function (scpCameraScanRegion, requestPermissionContainer, requestPermissionButton) { + var $this = this; + $this.showHideScanTypeSwapLink(false); + $this.setHeaderMessage(strings_1.Html5QrcodeScannerStrings.cameraPermissionRequesting()); + var createPermissionButtonIfNotExists = function () { + if (!requestPermissionButton) { + $this.createPermissionButton(scpCameraScanRegion, requestPermissionContainer); + } + }; + html5_qrcode_1.Html5Qrcode.getCameras().then(function (cameras) { + $this.persistedDataManager.setHasPermission(true); + $this.showHideScanTypeSwapLink(true); + $this.resetHeaderMessage(); + if (cameras && cameras.length > 0) { + scpCameraScanRegion.removeChild(requestPermissionContainer); + $this.renderCameraSelection(cameras); + } + else { + $this.setHeaderMessage(strings_1.Html5QrcodeScannerStrings.noCameraFound(), Html5QrcodeScannerStatus.STATUS_WARNING); + createPermissionButtonIfNotExists(); + } + }).catch(function (error) { + $this.persistedDataManager.setHasPermission(false); + if (requestPermissionButton) { + requestPermissionButton.disabled = false; + } + else { + createPermissionButtonIfNotExists(); + } + $this.setHeaderMessage(error, Html5QrcodeScannerStatus.STATUS_WARNING); + $this.showHideScanTypeSwapLink(true); + }); + }; + Html5QrcodeScanner.prototype.createPermissionButton = function (scpCameraScanRegion, requestPermissionContainer) { + var $this = this; + var requestPermissionButton = base_1.BaseUiElementFactory + .createElement("button", this.getCameraPermissionButtonId()); + requestPermissionButton.innerText + = strings_1.Html5QrcodeScannerStrings.cameraPermissionTitle(); + requestPermissionButton.addEventListener("click", function () { + requestPermissionButton.disabled = true; + $this.createCameraListUi(scpCameraScanRegion, requestPermissionContainer, requestPermissionButton); + }); + requestPermissionContainer.appendChild(requestPermissionButton); + }; + Html5QrcodeScanner.prototype.createPermissionsUi = function (scpCameraScanRegion, requestPermissionContainer) { + var $this = this; + if (scan_type_selector_1.ScanTypeSelector.isCameraScanType(this.currentScanType) + && this.persistedDataManager.hasCameraPermissions()) { + permissions_1.CameraPermissions.hasPermissions().then(function (hasPermissions) { + if (hasPermissions) { + $this.createCameraListUi(scpCameraScanRegion, requestPermissionContainer); + } + else { + $this.persistedDataManager.setHasPermission(false); + $this.createPermissionButton(scpCameraScanRegion, requestPermissionContainer); + } + }).catch(function (_) { + $this.persistedDataManager.setHasPermission(false); + $this.createPermissionButton(scpCameraScanRegion, requestPermissionContainer); + }); + return; + } + this.createPermissionButton(scpCameraScanRegion, requestPermissionContainer); + }; + Html5QrcodeScanner.prototype.createSectionControlPanel = function () { + var section = document.getElementById(this.getDashboardSectionId()); + var sectionControlPanel = document.createElement("div"); + section.appendChild(sectionControlPanel); + var scpCameraScanRegion = document.createElement("div"); + scpCameraScanRegion.id = this.getDashboardSectionCameraScanRegionId(); + scpCameraScanRegion.style.display + = scan_type_selector_1.ScanTypeSelector.isCameraScanType(this.currentScanType) + ? "block" : "none"; + sectionControlPanel.appendChild(scpCameraScanRegion); + var requestPermissionContainer = document.createElement("div"); + requestPermissionContainer.style.textAlign = "center"; + scpCameraScanRegion.appendChild(requestPermissionContainer); + if (this.scanTypeSelector.isCameraScanRequired()) { + this.createPermissionsUi(scpCameraScanRegion, requestPermissionContainer); + } + this.renderFileScanUi(sectionControlPanel); + }; + Html5QrcodeScanner.prototype.renderFileScanUi = function (parent) { + var showOnRender = scan_type_selector_1.ScanTypeSelector.isFileScanType(this.currentScanType); + var $this = this; + var onFileSelected = function (file) { + if (!$this.html5Qrcode) { + throw "html5Qrcode not defined"; + } + if (!scan_type_selector_1.ScanTypeSelector.isFileScanType($this.currentScanType)) { + return; + } + $this.setHeaderMessage(strings_1.Html5QrcodeScannerStrings.loadingImage()); + $this.html5Qrcode.scanFileV2(file, true) + .then(function (html5qrcodeResult) { + $this.resetHeaderMessage(); + $this.qrCodeSuccessCallback(html5qrcodeResult.decodedText, html5qrcodeResult); + }) + .catch(function (error) { + $this.setHeaderMessage(error, Html5QrcodeScannerStatus.STATUS_WARNING); + $this.qrCodeErrorCallback(error, core_1.Html5QrcodeErrorFactory.createFrom(error)); + }); + }; + this.fileSelectionUi = file_selection_ui_1.FileSelectionUi.create(parent, showOnRender, onFileSelected); + }; + Html5QrcodeScanner.prototype.renderCameraSelection = function (cameras) { + var _this = this; + var $this = this; + var scpCameraScanRegion = document.getElementById(this.getDashboardSectionCameraScanRegionId()); + scpCameraScanRegion.style.textAlign = "center"; + var cameraZoomUi = camera_zoom_ui_1.CameraZoomUi.create(scpCameraScanRegion, false); + var renderCameraZoomUiIfSupported = function (cameraCapabilities) { + var zoomCapability = cameraCapabilities.zoomFeature(); + if (!zoomCapability.isSupported()) { + return; + } + cameraZoomUi.setOnCameraZoomValueChangeCallback(function (zoomValue) { + zoomCapability.apply(zoomValue); + }); + var defaultZoom = 1; + if (_this.config.defaultZoomValueIfSupported) { + defaultZoom = _this.config.defaultZoomValueIfSupported; + } + defaultZoom = (0, core_1.clip)(defaultZoom, zoomCapability.min(), zoomCapability.max()); + cameraZoomUi.setValues(zoomCapability.min(), zoomCapability.max(), defaultZoom, zoomCapability.step()); + cameraZoomUi.show(); + }; + var cameraSelectUi = camera_selection_ui_1.CameraSelectionUi.create(scpCameraScanRegion, cameras); + var cameraActionContainer = document.createElement("span"); + var cameraActionStartButton = base_1.BaseUiElementFactory.createElement("button", base_1.PublicUiElementIdAndClasses.CAMERA_START_BUTTON_ID); + cameraActionStartButton.innerText + = strings_1.Html5QrcodeScannerStrings.scanButtonStartScanningText(); + cameraActionContainer.appendChild(cameraActionStartButton); + var cameraActionStopButton = base_1.BaseUiElementFactory.createElement("button", base_1.PublicUiElementIdAndClasses.CAMERA_STOP_BUTTON_ID); + cameraActionStopButton.innerText + = strings_1.Html5QrcodeScannerStrings.scanButtonStopScanningText(); + cameraActionStopButton.style.display = "none"; + cameraActionStopButton.disabled = true; + cameraActionContainer.appendChild(cameraActionStopButton); + var torchButton; + var createAndShowTorchButtonIfSupported = function (cameraCapabilities) { + if (!cameraCapabilities.torchFeature().isSupported()) { + if (torchButton) { + torchButton.hide(); + } + return; + } + if (!torchButton) { + torchButton = torch_button_1.TorchButton.create(cameraActionContainer, cameraCapabilities.torchFeature(), { display: "none", marginLeft: "5px" }, function (errorMessage) { + $this.setHeaderMessage(errorMessage, Html5QrcodeScannerStatus.STATUS_WARNING); + }); + } + else { + torchButton.updateTorchCapability(cameraCapabilities.torchFeature()); + } + torchButton.show(); + }; + scpCameraScanRegion.appendChild(cameraActionContainer); + var resetCameraActionStartButton = function (shouldShow) { + if (!shouldShow) { + cameraActionStartButton.style.display = "none"; + } + cameraActionStartButton.innerText + = strings_1.Html5QrcodeScannerStrings + .scanButtonStartScanningText(); + cameraActionStartButton.style.opacity = "1"; + cameraActionStartButton.disabled = false; + if (shouldShow) { + cameraActionStartButton.style.display = "inline-block"; + } + }; + cameraActionStartButton.addEventListener("click", function (_) { + cameraActionStartButton.innerText + = strings_1.Html5QrcodeScannerStrings.scanButtonScanningStarting(); + cameraSelectUi.disable(); + cameraActionStartButton.disabled = true; + cameraActionStartButton.style.opacity = "0.5"; + if (_this.scanTypeSelector.hasMoreThanOneScanType()) { + $this.showHideScanTypeSwapLink(false); + } + $this.resetHeaderMessage(); + var cameraId = cameraSelectUi.getValue(); + $this.persistedDataManager.setLastUsedCameraId(cameraId); + $this.html5Qrcode.start(cameraId, toHtml5QrcodeCameraScanConfig($this.config), $this.qrCodeSuccessCallback, $this.qrCodeErrorCallback) + .then(function (_) { + cameraActionStopButton.disabled = false; + cameraActionStopButton.style.display = "inline-block"; + resetCameraActionStartButton(false); + var cameraCapabilities = $this.html5Qrcode.getRunningTrackCameraCapabilities(); + if (_this.config.showTorchButtonIfSupported === true) { + createAndShowTorchButtonIfSupported(cameraCapabilities); + } + if (_this.config.showZoomSliderIfSupported === true) { + renderCameraZoomUiIfSupported(cameraCapabilities); + } + }) + .catch(function (error) { + $this.showHideScanTypeSwapLink(true); + cameraSelectUi.enable(); + resetCameraActionStartButton(true); + $this.setHeaderMessage(error, Html5QrcodeScannerStatus.STATUS_WARNING); + }); + }); + if (cameraSelectUi.hasSingleItem()) { + cameraActionStartButton.click(); + } + cameraActionStopButton.addEventListener("click", function (_) { + if (!$this.html5Qrcode) { + throw "html5Qrcode not defined"; + } + cameraActionStopButton.disabled = true; + $this.html5Qrcode.stop() + .then(function (_) { + if (_this.scanTypeSelector.hasMoreThanOneScanType()) { + $this.showHideScanTypeSwapLink(true); + } + cameraSelectUi.enable(); + cameraActionStartButton.disabled = false; + cameraActionStopButton.style.display = "none"; + cameraActionStartButton.style.display = "inline-block"; + if (torchButton) { + torchButton.reset(); + torchButton.hide(); + } + cameraZoomUi.removeOnCameraZoomValueChangeCallback(); + cameraZoomUi.hide(); + $this.insertCameraScanImageToScanRegion(); + }).catch(function (error) { + cameraActionStopButton.disabled = false; + $this.setHeaderMessage(error, Html5QrcodeScannerStatus.STATUS_WARNING); + }); + }); + if ($this.persistedDataManager.getLastUsedCameraId()) { + var cameraId = $this.persistedDataManager.getLastUsedCameraId(); + if (cameraSelectUi.hasValue(cameraId)) { + cameraSelectUi.setValue(cameraId); + cameraActionStartButton.click(); + } + else { + $this.persistedDataManager.resetLastUsedCameraId(); + } + } + }; + Html5QrcodeScanner.prototype.createSectionSwap = function () { + var $this = this; + var TEXT_IF_CAMERA_SCAN_SELECTED = strings_1.Html5QrcodeScannerStrings.textIfCameraScanSelected(); + var TEXT_IF_FILE_SCAN_SELECTED = strings_1.Html5QrcodeScannerStrings.textIfFileScanSelected(); + var section = document.getElementById(this.getDashboardSectionId()); + var switchContainer = document.createElement("div"); + switchContainer.style.textAlign = "center"; + var switchScanTypeLink = base_1.BaseUiElementFactory.createElement("span", this.getDashboardSectionSwapLinkId()); + switchScanTypeLink.style.textDecoration = "underline"; + switchScanTypeLink.style.cursor = "pointer"; + switchScanTypeLink.innerText + = scan_type_selector_1.ScanTypeSelector.isCameraScanType(this.currentScanType) + ? TEXT_IF_CAMERA_SCAN_SELECTED : TEXT_IF_FILE_SCAN_SELECTED; + switchScanTypeLink.addEventListener("click", function () { + if (!$this.sectionSwapAllowed) { + if ($this.verbose) { + $this.logger.logError("Section swap called when not allowed"); + } + return; + } + $this.resetHeaderMessage(); + $this.fileSelectionUi.resetValue(); + $this.sectionSwapAllowed = false; + if (scan_type_selector_1.ScanTypeSelector.isCameraScanType($this.currentScanType)) { + $this.clearScanRegion(); + $this.getCameraScanRegion().style.display = "none"; + $this.fileSelectionUi.show(); + switchScanTypeLink.innerText = TEXT_IF_FILE_SCAN_SELECTED; + $this.currentScanType = core_1.Html5QrcodeScanType.SCAN_TYPE_FILE; + $this.insertFileScanImageToScanRegion(); + } + else { + $this.clearScanRegion(); + $this.getCameraScanRegion().style.display = "block"; + $this.fileSelectionUi.hide(); + switchScanTypeLink.innerText = TEXT_IF_CAMERA_SCAN_SELECTED; + $this.currentScanType = core_1.Html5QrcodeScanType.SCAN_TYPE_CAMERA; + $this.insertCameraScanImageToScanRegion(); + $this.startCameraScanIfPermissionExistsOnSwap(); + } + $this.sectionSwapAllowed = true; + }); + switchContainer.appendChild(switchScanTypeLink); + section.appendChild(switchContainer); + }; + Html5QrcodeScanner.prototype.startCameraScanIfPermissionExistsOnSwap = function () { + var _this = this; + var $this = this; + if (this.persistedDataManager.hasCameraPermissions()) { + permissions_1.CameraPermissions.hasPermissions().then(function (hasPermissions) { + if (hasPermissions) { + var permissionButton = document.getElementById($this.getCameraPermissionButtonId()); + if (!permissionButton) { + _this.logger.logError("Permission button not found, fail;"); + throw "Permission button not found"; + } + permissionButton.click(); + } + else { + $this.persistedDataManager.setHasPermission(false); + } + }).catch(function (_) { + $this.persistedDataManager.setHasPermission(false); + }); + return; + } + }; + Html5QrcodeScanner.prototype.resetHeaderMessage = function () { + var messageDiv = document.getElementById(this.getHeaderMessageContainerId()); + messageDiv.style.display = "none"; + }; + Html5QrcodeScanner.prototype.setHeaderMessage = function (messageText, scannerStatus) { + if (!scannerStatus) { + scannerStatus = Html5QrcodeScannerStatus.STATUS_DEFAULT; + } + var messageDiv = this.getHeaderMessageDiv(); + messageDiv.innerText = messageText; + messageDiv.style.display = "block"; + switch (scannerStatus) { + case Html5QrcodeScannerStatus.STATUS_SUCCESS: + messageDiv.style.background = "rgba(106, 175, 80, 0.26)"; + messageDiv.style.color = "#477735"; + break; + case Html5QrcodeScannerStatus.STATUS_WARNING: + messageDiv.style.background = "rgba(203, 36, 49, 0.14)"; + messageDiv.style.color = "#cb2431"; + break; + case Html5QrcodeScannerStatus.STATUS_DEFAULT: + default: + messageDiv.style.background = "rgba(0, 0, 0, 0)"; + messageDiv.style.color = "rgb(17, 17, 17)"; + break; + } + }; + Html5QrcodeScanner.prototype.showHideScanTypeSwapLink = function (shouldDisplay) { + if (this.scanTypeSelector.hasMoreThanOneScanType()) { + if (shouldDisplay !== true) { + shouldDisplay = false; + } + this.sectionSwapAllowed = shouldDisplay; + this.getDashboardSectionSwapLink().style.display + = shouldDisplay ? "inline-block" : "none"; + } + }; + Html5QrcodeScanner.prototype.insertCameraScanImageToScanRegion = function () { + var $this = this; + var qrCodeScanRegion = document.getElementById(this.getScanRegionId()); + if (this.cameraScanImage) { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild(this.cameraScanImage); + return; + } + this.cameraScanImage = new Image; + this.cameraScanImage.onload = function (_) { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild($this.cameraScanImage); + }; + this.cameraScanImage.width = 64; + this.cameraScanImage.style.opacity = "0.8"; + this.cameraScanImage.src = image_assets_1.ASSET_CAMERA_SCAN; + this.cameraScanImage.alt = strings_1.Html5QrcodeScannerStrings.cameraScanAltText(); + }; + Html5QrcodeScanner.prototype.insertFileScanImageToScanRegion = function () { + var $this = this; + var qrCodeScanRegion = document.getElementById(this.getScanRegionId()); + if (this.fileScanImage) { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild(this.fileScanImage); + return; + } + this.fileScanImage = new Image; + this.fileScanImage.onload = function (_) { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild($this.fileScanImage); + }; + this.fileScanImage.width = 64; + this.fileScanImage.style.opacity = "0.8"; + this.fileScanImage.src = image_assets_1.ASSET_FILE_SCAN; + this.fileScanImage.alt = strings_1.Html5QrcodeScannerStrings.fileScanAltText(); + }; + Html5QrcodeScanner.prototype.clearScanRegion = function () { + var qrCodeScanRegion = document.getElementById(this.getScanRegionId()); + qrCodeScanRegion.innerHTML = ""; + }; + Html5QrcodeScanner.prototype.getDashboardSectionId = function () { + return "".concat(this.elementId, "__dashboard_section"); + }; + Html5QrcodeScanner.prototype.getDashboardSectionCameraScanRegionId = function () { + return "".concat(this.elementId, "__dashboard_section_csr"); + }; + Html5QrcodeScanner.prototype.getDashboardSectionSwapLinkId = function () { + return base_1.PublicUiElementIdAndClasses.SCAN_TYPE_CHANGE_ANCHOR_ID; + }; + Html5QrcodeScanner.prototype.getScanRegionId = function () { + return "".concat(this.elementId, "__scan_region"); + }; + Html5QrcodeScanner.prototype.getDashboardId = function () { + return "".concat(this.elementId, "__dashboard"); + }; + Html5QrcodeScanner.prototype.getHeaderMessageContainerId = function () { + return "".concat(this.elementId, "__header_message"); + }; + Html5QrcodeScanner.prototype.getCameraPermissionButtonId = function () { + return base_1.PublicUiElementIdAndClasses.CAMERA_PERMISSION_BUTTON_ID; + }; + Html5QrcodeScanner.prototype.getCameraScanRegion = function () { + return document.getElementById(this.getDashboardSectionCameraScanRegionId()); + }; + Html5QrcodeScanner.prototype.getDashboardSectionSwapLink = function () { + return document.getElementById(this.getDashboardSectionSwapLinkId()); + }; + Html5QrcodeScanner.prototype.getHeaderMessageDiv = function () { + return document.getElementById(this.getHeaderMessageContainerId()); + }; + return Html5QrcodeScanner; +}()); +exports.Html5QrcodeScanner = Html5QrcodeScanner; +//# sourceMappingURL=html5-qrcode-scanner.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/html5-qrcode-scanner.js.map b/src/main/node_modules/html5-qrcode/cjs/html5-qrcode-scanner.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ecb0462c38e49c3e3294381cfd161f66a29dcbe1 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/html5-qrcode-scanner.js.map @@ -0,0 +1 @@ +{"version":3,"file":"html5-qrcode-scanner.js","sourceRoot":"","sources":["../../src/html5-qrcode-scanner.ts"],"names":[],"mappings":";;;AAUA,+BAYgB;AAMhB,+CAKwB;AAExB,qCAEmB;AAEnB,+CAGwB;AAExB,qCAEmB;AAEnB,2BAEc;AAEd,oDAE8B;AAI9B,sEAAmE;AAEnE,0DAAwD;AAExD,oEAGwC;AAExC,0CAG2B;AAE3B,wEAAqE;AACrE,8DAA2D;AAK3D,IAAK,wBAKJ;AALD,WAAK,wBAAwB;IACzB,2FAAkB,CAAA;IAClB,2FAAkB,CAAA;IAClB,2FAAkB,CAAA;IAClB,uHAAgC,CAAA;AACpC,CAAC,EALI,wBAAwB,KAAxB,wBAAwB,QAK5B;AA+DD,SAAS,6BAA6B,CAAC,MAAgC;IAEnE,OAAO;QACH,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC5C,CAAC;AACN,CAAC;AAED,SAAS,uBAAuB,CAC5B,MAA0B,EAAE,OAA4B;IAExD,OAAO;QACH,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,6BAA6B,EAAE,MAAM,CAAC,6BAA6B;QACnE,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;QACjD,OAAO,EAAE,OAAO;KACnB,CAAC;AACN,CAAC;AAYD;IA6BI,4BACI,SAAiB,EACjB,MAA4C,EAC5C,OAA4B;QAhBxB,mBAAc,GAAkB,IAAI,CAAC;QACrC,oBAAe,GAA4B,IAAI,CAAC;QAChD,kBAAa,GA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IAAI,CAAC,2BAA2B,EAAE,CAAE,CAAC;IACxE,CAAC;IAGL,yBAAC;AAAD,CAAC,AA97BD,IA87BC;AA97BY,gDAAkB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/html5-qrcode.d.ts b/src/main/node_modules/html5-qrcode/cjs/html5-qrcode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e576933e30835c6b726b5e90faa67d6f3721a3a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/html5-qrcode.d.ts @@ -0,0 +1,75 @@ +import { QrcodeErrorCallback, QrcodeSuccessCallback, Html5QrcodeSupportedFormats, Html5QrcodeResult, QrDimensions, QrDimensionFunction } from "./core"; +import { CameraDevice, CameraCapabilities } from "./camera/core"; +import { ExperimentalFeaturesConfig } from "./experimental-features"; +import { Html5QrcodeScannerState } from "./state-manager"; +export interface Html5QrcodeConfigs { + formatsToSupport?: Array<Html5QrcodeSupportedFormats> | undefined; + useBarCodeDetectorIfSupported?: boolean | undefined; + experimentalFeatures?: ExperimentalFeaturesConfig | undefined; +} +export interface Html5QrcodeFullConfig extends Html5QrcodeConfigs { + verbose: boolean | undefined; +} +export interface Html5QrcodeCameraScanConfig { + fps: number | undefined; + qrbox?: number | QrDimensions | QrDimensionFunction | undefined; + aspectRatio?: number | undefined; + disableFlip?: boolean | undefined; + videoConstraints?: MediaTrackConstraints | undefined; +} +export declare class Html5Qrcode { + private readonly logger; + private readonly elementId; + private readonly verbose; + private readonly qrcode; + private shouldScan; + private element; + private canvasElement; + private scannerPausedUiElement; + private hasBorderShaders; + private borderShaders; + private qrMatch; + private renderedCamera; + private foreverScanTimeout; + private qrRegion; + private context; + private lastScanImageFile; + private stateManagerProxy; + isScanning: boolean; + constructor(elementId: string, configOrVerbosityFlag?: boolean | Html5QrcodeFullConfig | undefined); + start(cameraIdOrConfig: string | MediaTrackConstraints, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; + pause(shouldPauseVideo?: boolean): void; + resume(): void; + getState(): Html5QrcodeScannerState; + stop(): Promise<void>; + scanFile(imageFile: File, showImage?: boolean): Promise<string>; + scanFileV2(imageFile: File, showImage?: boolean): Promise<Html5QrcodeResult>; + clear(): void; + static getCameras(): Promise<Array<CameraDevice>>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + getRunningTrackCameraCapabilities(): CameraCapabilities; + applyVideoConstraints(videoConstaints: MediaTrackConstraints): Promise<void>; + private getRenderedCameraOrFail; + private getSupportedFormats; + private getUseBarCodeDetectorIfSupported; + private validateQrboxSize; + private validateQrboxConfig; + private toQrdimensions; + private setupUi; + private createScannerPausedUiElement; + private scanContext; + private foreverScan; + private createVideoConstraints; + private computeCanvasDrawConfig; + private clearElement; + private possiblyUpdateShaders; + private possiblyCloseLastScanImageFile; + private createCanvasElement; + private getShadedRegionBounds; + private possiblyInsertShadingElement; + private insertShaderBorders; + private showPausedState; + private hidePausedState; + private getTimeoutFps; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/html5-qrcode.js b/src/main/node_modules/html5-qrcode/cjs/html5-qrcode.js new file mode 100644 index 0000000000000000000000000000000000000000..27601fba3fb0ca1363ca154f5cfe6c81b554ee66 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/html5-qrcode.js @@ -0,0 +1,843 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Html5Qrcode = void 0; +var core_1 = require("./core"); +var strings_1 = require("./strings"); +var utils_1 = require("./utils"); +var code_decoder_1 = require("./code-decoder"); +var factories_1 = require("./camera/factories"); +var retriever_1 = require("./camera/retriever"); +var state_manager_1 = require("./state-manager"); +var Constants = (function (_super) { + __extends(Constants, _super); + function Constants() { + return _super !== null && _super.apply(this, arguments) || this; + } + Constants.DEFAULT_WIDTH = 300; + Constants.DEFAULT_WIDTH_OFFSET = 2; + Constants.FILE_SCAN_MIN_HEIGHT = 300; + Constants.FILE_SCAN_HIDDEN_CANVAS_PADDING = 100; + Constants.MIN_QR_BOX_SIZE = 50; + Constants.SHADED_LEFT = 1; + Constants.SHADED_RIGHT = 2; + Constants.SHADED_TOP = 3; + Constants.SHADED_BOTTOM = 4; + Constants.SHADED_REGION_ELEMENT_ID = "qr-shaded-region"; + Constants.VERBOSE = false; + Constants.BORDER_SHADER_DEFAULT_COLOR = "#ffffff"; + Constants.BORDER_SHADER_MATCH_COLOR = "rgb(90, 193, 56)"; + return Constants; +}(core_1.Html5QrcodeConstants)); +var InternalHtml5QrcodeConfig = (function () { + function InternalHtml5QrcodeConfig(config, logger) { + this.logger = logger; + this.fps = Constants.SCAN_DEFAULT_FPS; + if (!config) { + this.disableFlip = Constants.DEFAULT_DISABLE_FLIP; + } + else { + if (config.fps) { + this.fps = config.fps; + } + this.disableFlip = config.disableFlip === true; + this.qrbox = config.qrbox; + this.aspectRatio = config.aspectRatio; + this.videoConstraints = config.videoConstraints; + } + } + InternalHtml5QrcodeConfig.prototype.isMediaStreamConstraintsValid = function () { + if (!this.videoConstraints) { + this.logger.logError("Empty videoConstraints", true); + return false; + } + return utils_1.VideoConstraintsUtil.isMediaStreamConstraintsValid(this.videoConstraints, this.logger); + }; + InternalHtml5QrcodeConfig.prototype.isShadedBoxEnabled = function () { + return !(0, core_1.isNullOrUndefined)(this.qrbox); + }; + InternalHtml5QrcodeConfig.create = function (config, logger) { + return new InternalHtml5QrcodeConfig(config, logger); + }; + return InternalHtml5QrcodeConfig; +}()); +var Html5Qrcode = (function () { + function Html5Qrcode(elementId, configOrVerbosityFlag) { + 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 = false; + if (!document.getElementById(elementId)) { + throw "HTML Element with id=".concat(elementId, " not found"); + } + this.elementId = elementId; + this.verbose = false; + var experimentalFeatureConfig; + var configObject; + if (typeof configOrVerbosityFlag == "boolean") { + this.verbose = configOrVerbosityFlag === true; + } + else if (configOrVerbosityFlag) { + configObject = configOrVerbosityFlag; + this.verbose = configObject.verbose === true; + experimentalFeatureConfig = configObject.experimentalFeatures; + } + this.logger = new core_1.BaseLoggger(this.verbose); + this.qrcode = new code_decoder_1.Html5QrcodeShim(this.getSupportedFormats(configOrVerbosityFlag), this.getUseBarCodeDetectorIfSupported(configObject), this.verbose, this.logger); + this.foreverScanTimeout; + this.shouldScan = true; + this.stateManagerProxy = state_manager_1.StateManagerFactory.create(); + } + Html5Qrcode.prototype.start = function (cameraIdOrConfig, configuration, qrCodeSuccessCallback, qrCodeErrorCallback) { + var _this = this; + if (!cameraIdOrConfig) { + throw "cameraIdOrConfig is required"; + } + if (!qrCodeSuccessCallback + || typeof qrCodeSuccessCallback != "function") { + throw "qrCodeSuccessCallback is required and should be a function."; + } + var qrCodeErrorCallbackInternal; + if (qrCodeErrorCallback) { + qrCodeErrorCallbackInternal = qrCodeErrorCallback; + } + else { + qrCodeErrorCallbackInternal + = this.verbose ? this.logger.log : function () { }; + } + var internalConfig = InternalHtml5QrcodeConfig.create(configuration, this.logger); + this.clearElement(); + var videoConstraintsAvailableAndValid = false; + if (internalConfig.videoConstraints) { + if (!internalConfig.isMediaStreamConstraintsValid()) { + this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, " + + "it will be ignored.'", true); + } + else { + videoConstraintsAvailableAndValid = true; + } + } + var areVideoConstraintsEnabled = videoConstraintsAvailableAndValid; + var element = document.getElementById(this.elementId); + var rootElementWidth = element.clientWidth + ? element.clientWidth : Constants.DEFAULT_WIDTH; + element.style.position = "relative"; + this.shouldScan = true; + this.element = element; + var $this = this; + var toScanningStateChangeTransaction = this.stateManagerProxy.startTransition(state_manager_1.Html5QrcodeScannerState.SCANNING); + return new Promise(function (resolve, reject) { + var videoConstraints = areVideoConstraintsEnabled + ? internalConfig.videoConstraints + : $this.createVideoConstraints(cameraIdOrConfig); + if (!videoConstraints) { + toScanningStateChangeTransaction.cancel(); + reject("videoConstraints should be defined"); + return; + } + var cameraRenderingOptions = {}; + if (!areVideoConstraintsEnabled || internalConfig.aspectRatio) { + cameraRenderingOptions.aspectRatio = internalConfig.aspectRatio; + } + var renderingCallbacks = { + onRenderSurfaceReady: function (viewfinderWidth, viewfinderHeight) { + $this.setupUi(viewfinderWidth, viewfinderHeight, internalConfig); + $this.isScanning = true; + $this.foreverScan(internalConfig, qrCodeSuccessCallback, qrCodeErrorCallbackInternal); + } + }; + factories_1.CameraFactory.failIfNotSupported().then(function (factory) { + factory.create(videoConstraints).then(function (camera) { + return camera.render(_this.element, cameraRenderingOptions, renderingCallbacks) + .then(function (renderedCamera) { + $this.renderedCamera = renderedCamera; + toScanningStateChangeTransaction.execute(); + resolve(null); + }) + .catch(function (error) { + toScanningStateChangeTransaction.cancel(); + reject(error); + }); + }).catch(function (error) { + toScanningStateChangeTransaction.cancel(); + reject(strings_1.Html5QrcodeStrings.errorGettingUserMedia(error)); + }); + }).catch(function (_) { + toScanningStateChangeTransaction.cancel(); + reject(strings_1.Html5QrcodeStrings.cameraStreamingNotSupported()); + }); + }); + }; + Html5Qrcode.prototype.pause = function (shouldPauseVideo) { + if (!this.stateManagerProxy.isStrictlyScanning()) { + throw "Cannot pause, scanner is not scanning."; + } + this.stateManagerProxy.directTransition(state_manager_1.Html5QrcodeScannerState.PAUSED); + this.showPausedState(); + if ((0, core_1.isNullOrUndefined)(shouldPauseVideo) || shouldPauseVideo !== true) { + shouldPauseVideo = false; + } + if (shouldPauseVideo && this.renderedCamera) { + this.renderedCamera.pause(); + } + }; + Html5Qrcode.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 $this = this; + var transitionToScanning = function () { + $this.stateManagerProxy.directTransition(state_manager_1.Html5QrcodeScannerState.SCANNING); + $this.hidePausedState(); + }; + if (!this.renderedCamera.isPaused()) { + transitionToScanning(); + return; + } + this.renderedCamera.resume(function () { + transitionToScanning(); + }); + }; + Html5Qrcode.prototype.getState = function () { + return this.stateManagerProxy.getState(); + }; + Html5Qrcode.prototype.stop = function () { + var _this = this; + if (!this.stateManagerProxy.isScanning()) { + throw "Cannot stop, scanner is not running or paused."; + } + var toStoppedStateTransaction = this.stateManagerProxy.startTransition(state_manager_1.Html5QrcodeScannerState.NOT_STARTED); + this.shouldScan = false; + if (this.foreverScanTimeout) { + clearTimeout(this.foreverScanTimeout); + } + var removeQrRegion = function () { + if (!_this.element) { + return; + } + var childElement = document.getElementById(Constants.SHADED_REGION_ELEMENT_ID); + if (childElement) { + _this.element.removeChild(childElement); + } + }; + var $this = this; + return this.renderedCamera.close().then(function () { + $this.renderedCamera = null; + if ($this.element) { + $this.element.removeChild($this.canvasElement); + $this.canvasElement = null; + } + removeQrRegion(); + if ($this.qrRegion) { + $this.qrRegion = null; + } + if ($this.context) { + $this.context = null; + } + toStoppedStateTransaction.execute(); + $this.hidePausedState(); + $this.isScanning = false; + return Promise.resolve(); + }); + }; + Html5Qrcode.prototype.scanFile = function (imageFile, showImage) { + return this.scanFileV2(imageFile, showImage) + .then(function (html5qrcodeResult) { return html5qrcodeResult.decodedText; }); + }; + Html5Qrcode.prototype.scanFileV2 = function (imageFile, showImage) { + var _this = this; + if (!imageFile || !(imageFile instanceof File)) { + throw "imageFile argument is mandatory and should be instance " + + "of File. Use 'event.target.files[0]'."; + } + if ((0, core_1.isNullOrUndefined)(showImage)) { + showImage = true; + } + if (!this.stateManagerProxy.canScanFile()) { + throw "Cannot start file scan - ongoing camera scan"; + } + return new Promise(function (resolve, reject) { + _this.possiblyCloseLastScanImageFile(); + _this.clearElement(); + _this.lastScanImageFile = URL.createObjectURL(imageFile); + var inputImage = new Image; + inputImage.onload = function () { + var imageWidth = inputImage.width; + var imageHeight = inputImage.height; + var element = document.getElementById(_this.elementId); + var containerWidth = element.clientWidth + ? element.clientWidth : Constants.DEFAULT_WIDTH; + var containerHeight = Math.max(element.clientHeight ? element.clientHeight : imageHeight, Constants.FILE_SCAN_MIN_HEIGHT); + var config = _this.computeCanvasDrawConfig(imageWidth, imageHeight, containerWidth, containerHeight); + if (showImage) { + var visibleCanvas = _this.createCanvasElement(containerWidth, containerHeight, "qr-canvas-visible"); + visibleCanvas.style.display = "inline-block"; + element.appendChild(visibleCanvas); + var context_1 = visibleCanvas.getContext("2d"); + if (!context_1) { + throw "Unable to get 2d context from canvas"; + } + context_1.canvas.width = containerWidth; + context_1.canvas.height = containerHeight; + context_1.drawImage(inputImage, 0, 0, imageWidth, imageHeight, config.x, config.y, config.width, config.height); + } + var padding = Constants.FILE_SCAN_HIDDEN_CANVAS_PADDING; + var hiddenImageWidth = Math.max(inputImage.width, config.width); + var hiddenImageHeight = Math.max(inputImage.height, config.height); + var hiddenCanvasWidth = hiddenImageWidth + 2 * padding; + var hiddenCanvasHeight = hiddenImageHeight + 2 * padding; + var hiddenCanvas = _this.createCanvasElement(hiddenCanvasWidth, hiddenCanvasHeight); + element.appendChild(hiddenCanvas); + var context = hiddenCanvas.getContext("2d"); + if (!context) { + throw "Unable to get 2d context from canvas"; + } + context.canvas.width = hiddenCanvasWidth; + context.canvas.height = hiddenCanvasHeight; + context.drawImage(inputImage, 0, 0, imageWidth, imageHeight, padding, padding, hiddenImageWidth, hiddenImageHeight); + try { + _this.qrcode.decodeRobustlyAsync(hiddenCanvas) + .then(function (result) { + resolve(core_1.Html5QrcodeResultFactory.createFromQrcodeResult(result)); + }) + .catch(reject); + } + catch (exception) { + reject("QR code parse error, error = ".concat(exception)); + } + }; + inputImage.onerror = reject; + inputImage.onabort = reject; + inputImage.onstalled = reject; + inputImage.onsuspend = reject; + inputImage.src = URL.createObjectURL(imageFile); + }); + }; + Html5Qrcode.prototype.clear = function () { + this.clearElement(); + }; + Html5Qrcode.getCameras = function () { + return retriever_1.CameraRetriever.retrieve(); + }; + Html5Qrcode.prototype.getRunningTrackCapabilities = function () { + return this.getRenderedCameraOrFail().getRunningTrackCapabilities(); + }; + Html5Qrcode.prototype.getRunningTrackSettings = function () { + return this.getRenderedCameraOrFail().getRunningTrackSettings(); + }; + Html5Qrcode.prototype.getRunningTrackCameraCapabilities = function () { + return this.getRenderedCameraOrFail().getCapabilities(); + }; + Html5Qrcode.prototype.applyVideoConstraints = function (videoConstaints) { + if (!videoConstaints) { + throw "videoConstaints is required argument."; + } + else if (!utils_1.VideoConstraintsUtil.isMediaStreamConstraintsValid(videoConstaints, this.logger)) { + throw "invalid videoConstaints passed, check logs for more details"; + } + return this.getRenderedCameraOrFail().applyVideoConstraints(videoConstaints); + }; + Html5Qrcode.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; + }; + Html5Qrcode.prototype.getSupportedFormats = function (configOrVerbosityFlag) { + var allFormats = [ + core_1.Html5QrcodeSupportedFormats.QR_CODE, + core_1.Html5QrcodeSupportedFormats.AZTEC, + core_1.Html5QrcodeSupportedFormats.CODABAR, + core_1.Html5QrcodeSupportedFormats.CODE_39, + core_1.Html5QrcodeSupportedFormats.CODE_93, + core_1.Html5QrcodeSupportedFormats.CODE_128, + core_1.Html5QrcodeSupportedFormats.DATA_MATRIX, + core_1.Html5QrcodeSupportedFormats.MAXICODE, + core_1.Html5QrcodeSupportedFormats.ITF, + core_1.Html5QrcodeSupportedFormats.EAN_13, + core_1.Html5QrcodeSupportedFormats.EAN_8, + core_1.Html5QrcodeSupportedFormats.PDF_417, + core_1.Html5QrcodeSupportedFormats.RSS_14, + core_1.Html5QrcodeSupportedFormats.RSS_EXPANDED, + core_1.Html5QrcodeSupportedFormats.UPC_A, + core_1.Html5QrcodeSupportedFormats.UPC_E, + core_1.Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, + ]; + if (!configOrVerbosityFlag + || typeof configOrVerbosityFlag == "boolean") { + return allFormats; + } + if (!configOrVerbosityFlag.formatsToSupport) { + return allFormats; + } + if (!Array.isArray(configOrVerbosityFlag.formatsToSupport)) { + throw "configOrVerbosityFlag.formatsToSupport should be undefined " + + "or an array."; + } + if (configOrVerbosityFlag.formatsToSupport.length === 0) { + throw "Atleast 1 formatsToSupport is needed."; + } + var supportedFormats = []; + for (var _i = 0, _a = configOrVerbosityFlag.formatsToSupport; _i < _a.length; _i++) { + var format = _a[_i]; + if ((0, core_1.isValidHtml5QrcodeSupportedFormats)(format)) { + supportedFormats.push(format); + } + else { + this.logger.warn("Invalid format: ".concat(format, " passed in config, ignoring.")); + } + } + if (supportedFormats.length === 0) { + throw "None of formatsToSupport match supported values."; + } + return supportedFormats; + }; + Html5Qrcode.prototype.getUseBarCodeDetectorIfSupported = function (config) { + if ((0, core_1.isNullOrUndefined)(config)) { + return true; + } + if (!(0, core_1.isNullOrUndefined)(config.useBarCodeDetectorIfSupported)) { + return config.useBarCodeDetectorIfSupported !== false; + } + if ((0, core_1.isNullOrUndefined)(config.experimentalFeatures)) { + return true; + } + var experimentalFeatures = config.experimentalFeatures; + if ((0, core_1.isNullOrUndefined)(experimentalFeatures.useBarCodeDetectorIfSupported)) { + return true; + } + return experimentalFeatures.useBarCodeDetectorIfSupported !== false; + }; + Html5Qrcode.prototype.validateQrboxSize = function (viewfinderWidth, viewfinderHeight, internalConfig) { + var _this = this; + var qrboxSize = internalConfig.qrbox; + this.validateQrboxConfig(qrboxSize); + var qrDimensions = this.toQrdimensions(viewfinderWidth, viewfinderHeight, qrboxSize); + var validateMinSize = function (size) { + if (size < Constants.MIN_QR_BOX_SIZE) { + throw "minimum size of 'config.qrbox' dimension value is" + + " ".concat(Constants.MIN_QR_BOX_SIZE, "px."); + } + }; + var correctWidthBasedOnRootElementSize = function (configWidth) { + if (configWidth > viewfinderWidth) { + _this.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."); + configWidth = viewfinderWidth; + } + return configWidth; + }; + validateMinSize(qrDimensions.width); + validateMinSize(qrDimensions.height); + qrDimensions.width = correctWidthBasedOnRootElementSize(qrDimensions.width); + }; + Html5Qrcode.prototype.validateQrboxConfig = function (qrboxSize) { + if (typeof qrboxSize === "number") { + return; + } + if (typeof qrboxSize === "function") { + return; + } + if (qrboxSize.width === undefined || qrboxSize.height === undefined) { + throw "Invalid instance of QrDimensions passed for " + + "'config.qrbox'. Both 'width' and 'height' should be set."; + } + }; + Html5Qrcode.prototype.toQrdimensions = function (viewfinderWidth, viewfinderHeight, qrboxSize) { + if (typeof qrboxSize === "number") { + return { width: qrboxSize, height: qrboxSize }; + } + else if (typeof qrboxSize === "function") { + try { + return qrboxSize(viewfinderWidth, viewfinderHeight); + } + catch (error) { + throw new Error("qrbox config was passed as a function but it failed with " + + "unknown error" + error); + } + } + return qrboxSize; + }; + Html5Qrcode.prototype.setupUi = function (viewfinderWidth, viewfinderHeight, internalConfig) { + if (internalConfig.isShadedBoxEnabled()) { + this.validateQrboxSize(viewfinderWidth, viewfinderHeight, internalConfig); + } + var qrboxSize = (0, core_1.isNullOrUndefined)(internalConfig.qrbox) ? + { width: viewfinderWidth, height: viewfinderHeight } : internalConfig.qrbox; + this.validateQrboxConfig(qrboxSize); + var qrDimensions = this.toQrdimensions(viewfinderWidth, viewfinderHeight, qrboxSize); + if (qrDimensions.height > viewfinderHeight) { + this.logger.warn("[Html5Qrcode] config.qrbox has height that is" + + "greater than the height of the video stream. Shading will be" + + " ignored"); + } + var shouldShadingBeApplied = internalConfig.isShadedBoxEnabled() + && qrDimensions.height <= viewfinderHeight; + var defaultQrRegion = { + x: 0, + y: 0, + width: viewfinderWidth, + height: viewfinderHeight + }; + var qrRegion = shouldShadingBeApplied + ? this.getShadedRegionBounds(viewfinderWidth, viewfinderHeight, qrDimensions) + : defaultQrRegion; + var canvasElement = this.createCanvasElement(qrRegion.width, qrRegion.height); + var contextAttributes = { willReadFrequently: true }; + var context = canvasElement.getContext("2d", contextAttributes); + context.canvas.width = qrRegion.width; + context.canvas.height = qrRegion.height; + this.element.append(canvasElement); + if (shouldShadingBeApplied) { + this.possiblyInsertShadingElement(this.element, viewfinderWidth, viewfinderHeight, qrDimensions); + } + this.createScannerPausedUiElement(this.element); + this.qrRegion = qrRegion; + this.context = context; + this.canvasElement = canvasElement; + }; + Html5Qrcode.prototype.createScannerPausedUiElement = function (rootElement) { + var scannerPausedUiElement = document.createElement("div"); + scannerPausedUiElement.innerText = strings_1.Html5QrcodeStrings.scannerPaused(); + scannerPausedUiElement.style.display = "none"; + scannerPausedUiElement.style.position = "absolute"; + scannerPausedUiElement.style.top = "0px"; + scannerPausedUiElement.style.zIndex = "1"; + scannerPausedUiElement.style.background = "rgba(9, 9, 9, 0.46)"; + scannerPausedUiElement.style.color = "#FFECEC"; + scannerPausedUiElement.style.textAlign = "center"; + scannerPausedUiElement.style.width = "100%"; + rootElement.appendChild(scannerPausedUiElement); + this.scannerPausedUiElement = scannerPausedUiElement; + }; + Html5Qrcode.prototype.scanContext = function (qrCodeSuccessCallback, qrCodeErrorCallback) { + var _this = this; + if (this.stateManagerProxy.isPaused()) { + return Promise.resolve(false); + } + return this.qrcode.decodeAsync(this.canvasElement) + .then(function (result) { + qrCodeSuccessCallback(result.text, core_1.Html5QrcodeResultFactory.createFromQrcodeResult(result)); + _this.possiblyUpdateShaders(true); + return true; + }).catch(function (error) { + _this.possiblyUpdateShaders(false); + var errorMessage = strings_1.Html5QrcodeStrings.codeParseError(error); + qrCodeErrorCallback(errorMessage, core_1.Html5QrcodeErrorFactory.createFrom(errorMessage)); + return false; + }); + }; + Html5Qrcode.prototype.foreverScan = function (internalConfig, qrCodeSuccessCallback, qrCodeErrorCallback) { + var _this = this; + if (!this.shouldScan) { + return; + } + if (!this.renderedCamera) { + return; + } + var videoElement = this.renderedCamera.getSurface(); + var widthRatio = videoElement.videoWidth / videoElement.clientWidth; + var heightRatio = videoElement.videoHeight / videoElement.clientHeight; + if (!this.qrRegion) { + throw "qrRegion undefined when localMediaStream is ready."; + } + var sWidthOffset = this.qrRegion.width * widthRatio; + var sHeightOffset = this.qrRegion.height * heightRatio; + var sxOffset = this.qrRegion.x * widthRatio; + var syOffset = this.qrRegion.y * heightRatio; + this.context.drawImage(videoElement, sxOffset, syOffset, sWidthOffset, sHeightOffset, 0, 0, this.qrRegion.width, this.qrRegion.height); + var triggerNextScan = function () { + _this.foreverScanTimeout = setTimeout(function () { + _this.foreverScan(internalConfig, qrCodeSuccessCallback, qrCodeErrorCallback); + }, _this.getTimeoutFps(internalConfig.fps)); + }; + this.scanContext(qrCodeSuccessCallback, qrCodeErrorCallback) + .then(function (isSuccessfull) { + if (!isSuccessfull && internalConfig.disableFlip !== true) { + _this.context.translate(_this.context.canvas.width, 0); + _this.context.scale(-1, 1); + _this.scanContext(qrCodeSuccessCallback, qrCodeErrorCallback) + .finally(function () { + triggerNextScan(); + }); + } + else { + triggerNextScan(); + } + }).catch(function (error) { + _this.logger.logError("Error happend while scanning context", error); + triggerNextScan(); + }); + }; + Html5Qrcode.prototype.createVideoConstraints = function (cameraIdOrConfig) { + if (typeof cameraIdOrConfig == "string") { + return { deviceId: { exact: cameraIdOrConfig } }; + } + else if (typeof cameraIdOrConfig == "object") { + var facingModeKey = "facingMode"; + var deviceIdKey = "deviceId"; + var allowedFacingModeValues_1 = { "user": true, "environment": true }; + var exactKey = "exact"; + var isValidFacingModeValue = function (value) { + if (value in allowedFacingModeValues_1) { + return true; + } + else { + throw "config has invalid 'facingMode' value = " + + "'".concat(value, "'"); + } + }; + var keys = Object.keys(cameraIdOrConfig); + if (keys.length !== 1) { + throw "'cameraIdOrConfig' object should have exactly 1 key," + + " if passed as an object, found ".concat(keys.length, " keys"); + } + var key = Object.keys(cameraIdOrConfig)[0]; + if (key !== facingModeKey && key !== deviceIdKey) { + throw "Only '".concat(facingModeKey, "' and '").concat(deviceIdKey, "' ") + + " are supported for 'cameraIdOrConfig'"; + } + if (key === facingModeKey) { + var facingMode = cameraIdOrConfig.facingMode; + if (typeof facingMode == "string") { + if (isValidFacingModeValue(facingMode)) { + return { facingMode: facingMode }; + } + } + else if (typeof facingMode == "object") { + if (exactKey in facingMode) { + if (isValidFacingModeValue(facingMode["".concat(exactKey)])) { + return { + facingMode: { + exact: facingMode["".concat(exactKey)] + } + }; + } + } + else { + throw "'facingMode' should be string or object with" + + " ".concat(exactKey, " as key."); + } + } + else { + var type_1 = (typeof facingMode); + throw "Invalid type of 'facingMode' = ".concat(type_1); + } + } + else { + var deviceId = cameraIdOrConfig.deviceId; + if (typeof deviceId == "string") { + return { deviceId: deviceId }; + } + else if (typeof deviceId == "object") { + if (exactKey in deviceId) { + return { + deviceId: { exact: deviceId["".concat(exactKey)] } + }; + } + else { + throw "'deviceId' should be string or object with" + + " ".concat(exactKey, " as key."); + } + } + else { + var type_2 = (typeof deviceId); + throw "Invalid type of 'deviceId' = ".concat(type_2); + } + } + } + var type = (typeof cameraIdOrConfig); + throw "Invalid type of 'cameraIdOrConfig' = ".concat(type); + }; + Html5Qrcode.prototype.computeCanvasDrawConfig = function (imageWidth, imageHeight, containerWidth, containerHeight) { + if (imageWidth <= containerWidth + && imageHeight <= containerHeight) { + var xoffset = (containerWidth - imageWidth) / 2; + var yoffset = (containerHeight - imageHeight) / 2; + return { + x: xoffset, + y: yoffset, + width: imageWidth, + height: imageHeight + }; + } + else { + var formerImageWidth = imageWidth; + var formerImageHeight = imageHeight; + if (imageWidth > containerWidth) { + imageHeight = (containerWidth / imageWidth) * imageHeight; + imageWidth = containerWidth; + } + if (imageHeight > containerHeight) { + imageWidth = (containerHeight / imageHeight) * imageWidth; + imageHeight = containerHeight; + } + this.logger.log("Image downsampled from " + + "".concat(formerImageWidth, "X").concat(formerImageHeight) + + " to ".concat(imageWidth, "X").concat(imageHeight, ".")); + return this.computeCanvasDrawConfig(imageWidth, imageHeight, containerWidth, containerHeight); + } + }; + Html5Qrcode.prototype.clearElement = function () { + if (this.stateManagerProxy.isScanning()) { + throw "Cannot clear while scan is ongoing, close it first."; + } + var element = document.getElementById(this.elementId); + if (element) { + element.innerHTML = ""; + } + }; + Html5Qrcode.prototype.possiblyUpdateShaders = function (qrMatch) { + if (this.qrMatch === qrMatch) { + return; + } + if (this.hasBorderShaders + && this.borderShaders + && this.borderShaders.length) { + this.borderShaders.forEach(function (shader) { + shader.style.backgroundColor = qrMatch + ? Constants.BORDER_SHADER_MATCH_COLOR + : Constants.BORDER_SHADER_DEFAULT_COLOR; + }); + } + this.qrMatch = qrMatch; + }; + Html5Qrcode.prototype.possiblyCloseLastScanImageFile = function () { + if (this.lastScanImageFile) { + URL.revokeObjectURL(this.lastScanImageFile); + this.lastScanImageFile = null; + } + }; + Html5Qrcode.prototype.createCanvasElement = function (width, height, customId) { + var canvasWidth = width; + var canvasHeight = height; + var canvasElement = document.createElement("canvas"); + canvasElement.style.width = "".concat(canvasWidth, "px"); + canvasElement.style.height = "".concat(canvasHeight, "px"); + canvasElement.style.display = "none"; + canvasElement.id = (0, core_1.isNullOrUndefined)(customId) + ? "qr-canvas" : customId; + return canvasElement; + }; + Html5Qrcode.prototype.getShadedRegionBounds = function (width, height, qrboxSize) { + if (qrboxSize.width > width || qrboxSize.height > height) { + throw "'config.qrbox' dimensions should not be greater than the " + + "dimensions of the root HTML element."; + } + return { + x: (width - qrboxSize.width) / 2, + y: (height - qrboxSize.height) / 2, + width: qrboxSize.width, + height: qrboxSize.height + }; + }; + Html5Qrcode.prototype.possiblyInsertShadingElement = function (element, width, height, qrboxSize) { + if ((width - qrboxSize.width) < 1 || (height - qrboxSize.height) < 1) { + return; + } + var shadingElement = document.createElement("div"); + shadingElement.style.position = "absolute"; + var rightLeftBorderSize = (width - qrboxSize.width) / 2; + var topBottomBorderSize = (height - qrboxSize.height) / 2; + shadingElement.style.borderLeft + = "".concat(rightLeftBorderSize, "px solid rgba(0, 0, 0, 0.48)"); + shadingElement.style.borderRight + = "".concat(rightLeftBorderSize, "px solid rgba(0, 0, 0, 0.48)"); + shadingElement.style.borderTop + = "".concat(topBottomBorderSize, "px solid rgba(0, 0, 0, 0.48)"); + shadingElement.style.borderBottom + = "".concat(topBottomBorderSize, "px solid rgba(0, 0, 0, 0.48)"); + shadingElement.style.boxSizing = "border-box"; + shadingElement.style.top = "0px"; + shadingElement.style.bottom = "0px"; + shadingElement.style.left = "0px"; + shadingElement.style.right = "0px"; + shadingElement.id = "".concat(Constants.SHADED_REGION_ELEMENT_ID); + if ((width - qrboxSize.width) < 11 + || (height - qrboxSize.height) < 11) { + this.hasBorderShaders = false; + } + else { + var smallSize = 5; + var largeSize = 40; + this.insertShaderBorders(shadingElement, largeSize, smallSize, -smallSize, null, 0, true); + this.insertShaderBorders(shadingElement, largeSize, smallSize, -smallSize, null, 0, false); + this.insertShaderBorders(shadingElement, largeSize, smallSize, null, -smallSize, 0, true); + this.insertShaderBorders(shadingElement, largeSize, smallSize, null, -smallSize, 0, false); + this.insertShaderBorders(shadingElement, smallSize, largeSize + smallSize, -smallSize, null, -smallSize, true); + this.insertShaderBorders(shadingElement, smallSize, largeSize + smallSize, null, -smallSize, -smallSize, true); + this.insertShaderBorders(shadingElement, smallSize, largeSize + smallSize, -smallSize, null, -smallSize, false); + this.insertShaderBorders(shadingElement, smallSize, largeSize + smallSize, null, -smallSize, -smallSize, false); + this.hasBorderShaders = true; + } + element.append(shadingElement); + }; + Html5Qrcode.prototype.insertShaderBorders = function (shaderElem, width, height, top, bottom, side, isLeft) { + var elem = document.createElement("div"); + elem.style.position = "absolute"; + elem.style.backgroundColor = Constants.BORDER_SHADER_DEFAULT_COLOR; + elem.style.width = "".concat(width, "px"); + elem.style.height = "".concat(height, "px"); + if (top !== null) { + elem.style.top = "".concat(top, "px"); + } + if (bottom !== null) { + elem.style.bottom = "".concat(bottom, "px"); + } + if (isLeft) { + elem.style.left = "".concat(side, "px"); + } + else { + elem.style.right = "".concat(side, "px"); + } + if (!this.borderShaders) { + this.borderShaders = []; + } + this.borderShaders.push(elem); + shaderElem.appendChild(elem); + }; + Html5Qrcode.prototype.showPausedState = function () { + if (!this.scannerPausedUiElement) { + throw "[internal error] scanner paused UI element not found"; + } + this.scannerPausedUiElement.style.display = "block"; + }; + Html5Qrcode.prototype.hidePausedState = function () { + if (!this.scannerPausedUiElement) { + throw "[internal error] scanner paused UI element not found"; + } + this.scannerPausedUiElement.style.display = "none"; + }; + Html5Qrcode.prototype.getTimeoutFps = function (fps) { + return 1000 / fps; + }; + return Html5Qrcode; +}()); +exports.Html5Qrcode = Html5Qrcode; +//# sourceMappingURL=html5-qrcode.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/html5-qrcode.js.map b/src/main/node_modules/html5-qrcode/cjs/html5-qrcode.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ffdc1b9d3e6ed9fd49b1fa110524f30d2d01b216 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/html5-qrcode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"html5-qrcode.js","sourceRoot":"","sources":["../../src/html5-qrcode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAcA,+BAegB;AAChB,qCAA+C;AAC/C,iCAA+C;AAC/C,+CAAiD;AACjD,gDAAmD;AAQnD,gDAAqD;AAErD,iDAKyB;AAEzB;IAAwB,6BAAoB;IAA5C;;IAgBA,CAAC;IAdU,uBAAa,GAAG,GAAG,CAAC;IACpB,8BAAoB,GAAG,CAAC,CAAC;IACzB,8BAAoB,G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IAAI,CAAC,CAAC;QAC9B,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAEO,qCAAe,GAAvB;QACI,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE;YAC9B,MAAM,sDAAsD,CAAC;SAChE;QACD,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IACxD,CAAC;IAEO,qCAAe,GAAvB;QACI,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE;YAC9B,MAAM,sDAAsD,CAAC;SAChE;QACD,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACvD,CAAC;IAEO,mCAAa,GAArB,UAAsB,GAAW;QAC7B,OAAO,IAAI,GAAG,GAAG,CAAC;IACtB,CAAC;IAEL,kBAAC;AAAD,CAAC,AArzCD,IAqzCC;AArzCY,kCAAW"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/image-assets.d.ts b/src/main/node_modules/html5-qrcode/cjs/image-assets.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..59387ac2e6d5b21c1d1862a744e923298b400a24 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/image-assets.d.ts @@ -0,0 +1,4 @@ +export declare const ASSET_CAMERA_SCAN: string; +export declare const ASSET_FILE_SCAN: string; +export declare const ASSET_INFO_ICON_16PX: string; +export declare const ASSET_CLOSE_ICON_16PX: string; diff --git a/src/main/node_modules/html5-qrcode/cjs/image-assets.js b/src/main/node_modules/html5-qrcode/cjs/image-assets.js new file mode 100644 index 0000000000000000000000000000000000000000..2ac885c2ae07be3d0802ff7d65b565aca47f0bad --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/image-assets.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ASSET_CLOSE_ICON_16PX = exports.ASSET_INFO_ICON_16PX = exports.ASSET_FILE_SCAN = exports.ASSET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AAASUVORK5CYII="; +//# sourceMappingURL=image-assets.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/image-assets.js.map b/src/main/node_modules/html5-qrcode/cjs/image-assets.js.map new file mode 100644 index 0000000000000000000000000000000000000000..5c3324391040ac19e95e6a0e6638d3692fc353ce --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/image-assets.js.map @@ -0,0 +1 @@ +{"version":3,"file":"image-assets.js","sourceRoot":"","sources":["../../src/image-assets.ts"],"names":[],"mappings":";;;AASA,IAAM,cAAc,GAAG,4BAA4B,CAAC;AAEvC,QAAA,iBAAiB,GAAW,cAAc,GAAG,82GAA82G,CAAC;AAE55G,QAAA,eAAe,GAAW,cAAc,GAAG,s8CAAs8C,CAAC;AAEl/C,QAAA,oBAAoB,GAAY,cAAc,GAAG,8oBAA8oB,CAAC;AAEhsB,QAAA,qBAAqB,GAAY,omBAAomB,CAAC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/index.d.ts b/src/main/node_modules/html5-qrcode/cjs/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6b90c689f1a0c34ea728b5b7a5375a33722ed9f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/index.d.ts @@ -0,0 +1,6 @@ +export { Html5Qrcode, Html5QrcodeFullConfig, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; +export { Html5QrcodeScanner } from "./html5-qrcode-scanner"; +export { Html5QrcodeSupportedFormats, Html5QrcodeResult, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; +export { Html5QrcodeScannerState } from "./state-manager"; +export { Html5QrcodeScanType } from "./core"; +export { CameraCapabilities, CameraDevice } from "./camera/core"; diff --git a/src/main/node_modules/html5-qrcode/cjs/index.js b/src/main/node_modules/html5-qrcode/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..7afb6ce0d325ed8fed7d00318ed37e0257fa88ea --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/index.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Html5QrcodeScanType = exports.Html5QrcodeScannerState = exports.Html5QrcodeSupportedFormats = exports.Html5QrcodeScanner = exports.Html5Qrcode = void 0; +var html5_qrcode_1 = require("./html5-qrcode"); +Object.defineProperty(exports, "Html5Qrcode", { enumerable: true, get: function () { return html5_qrcode_1.Html5Qrcode; } }); +var html5_qrcode_scanner_1 = require("./html5-qrcode-scanner"); +Object.defineProperty(exports, "Html5QrcodeScanner", { enumerable: true, get: function () { return html5_qrcode_scanner_1.Html5QrcodeScanner; } }); +var core_1 = require("./core"); +Object.defineProperty(exports, "Html5QrcodeSupportedFormats", { enumerable: true, get: function () { return core_1.Html5QrcodeSupportedFormats; } }); +var state_manager_1 = require("./state-manager"); +Object.defineProperty(exports, "Html5QrcodeScannerState", { enumerable: true, get: function () { return state_manager_1.Html5QrcodeScannerState; } }); +var core_2 = require("./core"); +Object.defineProperty(exports, "Html5QrcodeScanType", { enumerable: true, get: function () { return core_2.Html5QrcodeScanType; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/index.js.map b/src/main/node_modules/html5-qrcode/cjs/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..649f5f24fe98df191b1250591a09f50191607454 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAcA,+CAIwB;AAHpB,2GAAA,WAAW,OAAA;AAIf,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,+BAKgB;AAJZ,mHAAA,2BAA2B,OAAA;AAK/B,iDAA0D;AAAjD,wHAAA,uBAAuB,OAAA;AAChC,+BAA6C;AAApC,2GAAA,mBAAmB,OAAA"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/native-bar-code-detector.d.ts b/src/main/node_modules/html5-qrcode/cjs/native-bar-code-detector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..85ef95e4c4fec982c26cea91f5bb9eb21923bdf4 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/native-bar-code-detector.d.ts @@ -0,0 +1,16 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, QrcodeDecoderAsync, Logger } from "./core"; +export declare class BarcodeDetectorDelegate implements QrcodeDecoderAsync { + private readonly formatMap; + private readonly reverseFormatMap; + private verbose; + private logger; + private detector; + static isSupported(): boolean; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private selectLargestBarcode; + private createBarcodeDetectorFormats; + private toHtml5QrcodeSupportedFormats; + private createReverseFormatMap; + private createDebugData; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/native-bar-code-detector.js b/src/main/node_modules/html5-qrcode/cjs/native-bar-code-detector.js new file mode 100644 index 0000000000000000000000000000000000000000..789203041a544a0db57e24cd78822e3b5b52e512 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/native-bar-code-detector.js @@ -0,0 +1,148 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BarcodeDetectorDelegate = void 0; +var core_1 = require("./core"); +var BarcodeDetectorDelegate = (function () { + function BarcodeDetectorDelegate(requestedFormats, verbose, logger) { + this.formatMap = new Map([ + [core_1.Html5QrcodeSupportedFormats.QR_CODE, "qr_code"], + [core_1.Html5QrcodeSupportedFormats.AZTEC, "aztec"], + [core_1.Html5QrcodeSupportedFormats.CODABAR, "codabar"], + [core_1.Html5QrcodeSupportedFormats.CODE_39, "code_39"], + [core_1.Html5QrcodeSupportedFormats.CODE_93, "code_93"], + [core_1.Html5QrcodeSupportedFormats.CODE_128, "code_128"], + [core_1.Html5QrcodeSupportedFormats.DATA_MATRIX, "data_matrix"], + [core_1.Html5QrcodeSupportedFormats.ITF, "itf"], + [core_1.Html5QrcodeSupportedFormats.EAN_13, "ean_13"], + [core_1.Html5QrcodeSupportedFormats.EAN_8, "ean_8"], + [core_1.Html5QrcodeSupportedFormats.PDF_417, "pdf417"], + [core_1.Html5QrcodeSupportedFormats.UPC_A, "upc_a"], + [core_1.Html5QrcodeSupportedFormats.UPC_E, "upc_e"] + ]); + this.reverseFormatMap = this.createReverseFormatMap(); + if (!BarcodeDetectorDelegate.isSupported()) { + throw "Use html5qrcode.min.js without edit, Use " + + "BarcodeDetectorDelegate only if it isSupported();"; + } + this.verbose = verbose; + this.logger = logger; + var formats = this.createBarcodeDetectorFormats(requestedFormats); + this.detector = new BarcodeDetector(formats); + if (!this.detector) { + throw "BarcodeDetector detector not supported"; + } + } + BarcodeDetectorDelegate.isSupported = function () { + if (!("BarcodeDetector" in window)) { + return false; + } + var dummyDetector = new BarcodeDetector({ formats: ["qr_code"] }); + return typeof dummyDetector !== "undefined"; + }; + BarcodeDetectorDelegate.prototype.decodeAsync = function (canvas) { + return __awaiter(this, void 0, void 0, function () { + var barcodes, largestBarcode; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4, this.detector.detect(canvas)]; + case 1: + barcodes = _a.sent(); + if (!barcodes || barcodes.length === 0) { + throw "No barcode or QR code detected."; + } + largestBarcode = this.selectLargestBarcode(barcodes); + return [2, { + text: largestBarcode.rawValue, + format: core_1.QrcodeResultFormat.create(this.toHtml5QrcodeSupportedFormats(largestBarcode.format)), + debugData: this.createDebugData() + }]; + } + }); + }); + }; + BarcodeDetectorDelegate.prototype.selectLargestBarcode = function (barcodes) { + var largestBarcode = null; + var maxArea = 0; + for (var _i = 0, barcodes_1 = barcodes; _i < barcodes_1.length; _i++) { + var barcode = barcodes_1[_i]; + var area = barcode.boundingBox.width * barcode.boundingBox.height; + if (area > maxArea) { + maxArea = area; + largestBarcode = barcode; + } + } + if (!largestBarcode) { + throw "No largest barcode found"; + } + return largestBarcode; + }; + BarcodeDetectorDelegate.prototype.createBarcodeDetectorFormats = function (requestedFormats) { + var formats = []; + for (var _i = 0, requestedFormats_1 = requestedFormats; _i < requestedFormats_1.length; _i++) { + var requestedFormat = requestedFormats_1[_i]; + if (this.formatMap.has(requestedFormat)) { + formats.push(this.formatMap.get(requestedFormat)); + } + else { + this.logger.warn("".concat(requestedFormat, " is not supported by") + + "BarcodeDetectorDelegate"); + } + } + return { formats: formats }; + }; + BarcodeDetectorDelegate.prototype.toHtml5QrcodeSupportedFormats = function (barcodeDetectorFormat) { + if (!this.reverseFormatMap.has(barcodeDetectorFormat)) { + throw "reverseFormatMap doesn't have ".concat(barcodeDetectorFormat); + } + return this.reverseFormatMap.get(barcodeDetectorFormat); + }; + BarcodeDetectorDelegate.prototype.createReverseFormatMap = function () { + var result = new Map(); + this.formatMap.forEach(function (value, key, _) { + result.set(value, key); + }); + return result; + }; + BarcodeDetectorDelegate.prototype.createDebugData = function () { + return { decoderName: "BarcodeDetector" }; + }; + return BarcodeDetectorDelegate; +}()); +exports.BarcodeDetectorDelegate = BarcodeDetectorDelegate; +//# sourceMappingURL=native-bar-code-detector.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/native-bar-code-detector.js.map b/src/main/node_modules/html5-qrcode/cjs/native-bar-code-detector.js.map new file mode 100644 index 0000000000000000000000000000000000000000..824651d784428b8db9eca1ba79123eb5b8ba7c94 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/native-bar-code-detector.js.map @@ -0,0 +1 @@ +{"version":3,"file":"native-bar-code-detector.js","sourceRoot":"","sources":["../../src/native-bar-code-detector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,+BAOgB;AA4Cf;IA4CG,iCACI,gBAAoD,EACpD,OAAgB,EAChB,MAAc;QA3CD,cAAS,GACpB,IAAI,GAAG,CAAC;YACN,CAAE,kCAA2B,CAAC,OAAO,EAAE,SAAS,CAAE;YAClD,CAAE,kCAA2B,CAAC,KAAK,EAAE,OAAO,CA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hB,8BAAgB,EAAhB,IAAgB,EAAE;YAA3C,IAAM,eAAe,yBAAA;YACtB,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;gBACrC,OAAO,CAAC,IAAI,CACR,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAE,CAAC,CAAC;aAC7C;iBAAM;gBACH,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAG,eAAe,yBAAsB;sBACnD,yBAAyB,CAAC,CAAC;aACpC;SACJ;QACD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IACpC,CAAC;IAEO,+DAA6B,GAArC,UAAsC,qBAA6B;QAE/D,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE;YACnD,MAAM,wCAAiC,qBAAqB,CAAE,CAAC;SAClE;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,qBAAqB,CAAE,CAAC;IAC7D,CAAC;IAEO,wDAAsB,GAA9B;QACI,IAAI,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,OAAO,CAClB,UAAC,KAAa,EAAE,GAAgC,EAAE,CAAC;YACnD,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,iDAAe,GAAvB;QACI,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IAC9C,CAAC;IACL,8BAAC;AAAD,CAAC,AA3IA,IA2IA;AA3Ia,0DAAuB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/state-manager.d.ts b/src/main/node_modules/html5-qrcode/cjs/state-manager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c740bbd882ab2dd15280713d5d0866cbdf2b9d8 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/state-manager.d.ts @@ -0,0 +1,29 @@ +export declare enum Html5QrcodeScannerState { + UNKNOWN = 0, + NOT_STARTED = 1, + SCANNING = 2, + PAUSED = 3 +} +export interface StateManagerTransaction { + execute(): void; + cancel(): void; +} +export interface StateManager { + startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction; + directTransition(newState: Html5QrcodeScannerState): void; + getState(): Html5QrcodeScannerState; +} +export declare class StateManagerProxy { + private stateManager; + constructor(stateManager: StateManager); + startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction; + directTransition(newState: Html5QrcodeScannerState): void; + getState(): Html5QrcodeScannerState; + canScanFile(): boolean; + isScanning(): boolean; + isStrictlyScanning(): boolean; + isPaused(): boolean; +} +export declare class StateManagerFactory { + static create(): StateManagerProxy; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/state-manager.js b/src/main/node_modules/html5-qrcode/cjs/state-manager.js new file mode 100644 index 0000000000000000000000000000000000000000..a89a9c6735509174935df89122dc350a161f3f6c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/state-manager.js @@ -0,0 +1,112 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.StateManagerFactory = exports.StateManagerProxy = exports.Html5QrcodeScannerState = void 0; +var Html5QrcodeScannerState; +(function (Html5QrcodeScannerState) { + Html5QrcodeScannerState[Html5QrcodeScannerState["UNKNOWN"] = 0] = "UNKNOWN"; + Html5QrcodeScannerState[Html5QrcodeScannerState["NOT_STARTED"] = 1] = "NOT_STARTED"; + Html5QrcodeScannerState[Html5QrcodeScannerState["SCANNING"] = 2] = "SCANNING"; + Html5QrcodeScannerState[Html5QrcodeScannerState["PAUSED"] = 3] = "PAUSED"; +})(Html5QrcodeScannerState = exports.Html5QrcodeScannerState || (exports.Html5QrcodeScannerState = {})); +var StateManagerImpl = (function () { + function StateManagerImpl() { + this.state = Html5QrcodeScannerState.NOT_STARTED; + this.onGoingTransactionNewState = Html5QrcodeScannerState.UNKNOWN; + } + StateManagerImpl.prototype.directTransition = function (newState) { + this.failIfTransitionOngoing(); + this.validateTransition(newState); + this.state = newState; + }; + StateManagerImpl.prototype.startTransition = function (newState) { + this.failIfTransitionOngoing(); + this.validateTransition(newState); + this.onGoingTransactionNewState = newState; + return this; + }; + StateManagerImpl.prototype.execute = function () { + if (this.onGoingTransactionNewState + === Html5QrcodeScannerState.UNKNOWN) { + throw "Transaction is already cancelled, cannot execute()."; + } + var tempNewState = this.onGoingTransactionNewState; + this.onGoingTransactionNewState = Html5QrcodeScannerState.UNKNOWN; + this.directTransition(tempNewState); + }; + StateManagerImpl.prototype.cancel = function () { + if (this.onGoingTransactionNewState + === Html5QrcodeScannerState.UNKNOWN) { + throw "Transaction is already cancelled, cannot cancel()."; + } + this.onGoingTransactionNewState = Html5QrcodeScannerState.UNKNOWN; + }; + StateManagerImpl.prototype.getState = function () { + return this.state; + }; + StateManagerImpl.prototype.failIfTransitionOngoing = function () { + if (this.onGoingTransactionNewState + !== Html5QrcodeScannerState.UNKNOWN) { + throw "Cannot transition to a new state, already under transition"; + } + }; + StateManagerImpl.prototype.validateTransition = function (newState) { + switch (this.state) { + case Html5QrcodeScannerState.UNKNOWN: + throw "Transition from unknown is not allowed"; + case Html5QrcodeScannerState.NOT_STARTED: + this.failIfNewStateIs(newState, [Html5QrcodeScannerState.PAUSED]); + break; + case Html5QrcodeScannerState.SCANNING: + break; + case Html5QrcodeScannerState.PAUSED: + break; + } + }; + StateManagerImpl.prototype.failIfNewStateIs = function (newState, disallowedStatesToTransition) { + for (var _i = 0, disallowedStatesToTransition_1 = disallowedStatesToTransition; _i < disallowedStatesToTransition_1.length; _i++) { + var disallowedState = disallowedStatesToTransition_1[_i]; + if (newState === disallowedState) { + throw "Cannot transition from ".concat(this.state, " to ").concat(newState); + } + } + }; + return StateManagerImpl; +}()); +var StateManagerProxy = (function () { + function StateManagerProxy(stateManager) { + this.stateManager = stateManager; + } + StateManagerProxy.prototype.startTransition = function (newState) { + return this.stateManager.startTransition(newState); + }; + StateManagerProxy.prototype.directTransition = function (newState) { + this.stateManager.directTransition(newState); + }; + StateManagerProxy.prototype.getState = function () { + return this.stateManager.getState(); + }; + StateManagerProxy.prototype.canScanFile = function () { + return this.stateManager.getState() === Html5QrcodeScannerState.NOT_STARTED; + }; + StateManagerProxy.prototype.isScanning = function () { + return this.stateManager.getState() !== Html5QrcodeScannerState.NOT_STARTED; + }; + StateManagerProxy.prototype.isStrictlyScanning = function () { + return this.stateManager.getState() === Html5QrcodeScannerState.SCANNING; + }; + StateManagerProxy.prototype.isPaused = function () { + return this.stateManager.getState() === Html5QrcodeScannerState.PAUSED; + }; + return StateManagerProxy; +}()); +exports.StateManagerProxy = StateManagerProxy; +var StateManagerFactory = (function () { + function StateManagerFactory() { + } + StateManagerFactory.create = function () { + return new StateManagerProxy(new StateManagerImpl()); + }; + return StateManagerFactory; +}()); +exports.StateManagerFactory = StateManagerFactory; +//# sourceMappingURL=state-manager.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/state-manager.js.map b/src/main/node_modules/html5-qrcode/cjs/state-manager.js.map new file mode 100644 index 0000000000000000000000000000000000000000..7cddf8a182ec0494a9f50081edb4ca89c2ad5e3d --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/state-manager.js.map @@ -0,0 +1 @@ +{"version":3,"file":"state-manager.js","sourceRoot":"","sources":["../../src/state-manager.ts"],"names":[],"mappings":";;;AAQA,IAAY,uBAUX;AAVD,WAAY,uBAAuB;IAE/B,2EAAW,CAAA;IAGX,mFAAe,CAAA;IAEf,6EAAQ,CAAA;IAER,yEAAM,CAAA;AACV,CAAC,EAVW,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAUlC;AAkDD;IAAA;QAEY,UAAK,GAA4B,uBAAuB,CAAC,WAAW,CAAC;QAErE,+BAA0B,GAC5B,uBAAuB,CAAC,OAAO,CAAC;IA0E1C,CAAC;IAxEU,2CAAgB,GAAvB,UAAwB,QAAiC;QACrD,I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QACI,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,uBAAuB,CAAC,MAAM,CAAC;IAC3E,CAAC;IACL,wBAAC;AAAD,CAAC,AAlCD,IAkCC;AAlCY,8CAAiB;AAuC7B;IAAA;IAID,CAAC;IAHiB,0BAAM,GAApB;QACI,OAAO,IAAI,iBAAiB,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;IACzD,CAAC;IACL,0BAAC;AAAD,CAAC,AAJA,IAIA;AAJa,kDAAmB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/storage.d.ts b/src/main/node_modules/html5-qrcode/cjs/storage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cae73a316feba6585b2cb887ab0a8d664ba1eb11 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/storage.d.ts @@ -0,0 +1,12 @@ +export declare class PersistedDataManager { + private data; + private static LOCAL_STORAGE_KEY; + constructor(); + hasCameraPermissions(): boolean; + getLastUsedCameraId(): string | null; + setHasPermission(hasPermission: boolean): void; + setLastUsedCameraId(lastUsedCameraId: string): void; + resetLastUsedCameraId(): void; + reset(): void; + private flush; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/storage.js b/src/main/node_modules/html5-qrcode/cjs/storage.js new file mode 100644 index 0000000000000000000000000000000000000000..ba59389361c5f73a677be238ded99badd44132fa --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/storage.js @@ -0,0 +1,55 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PersistedDataManager = void 0; +var PersistedDataFactory = (function () { + function PersistedDataFactory() { + } + PersistedDataFactory.createDefault = function () { + return { + hasPermission: false, + lastUsedCameraId: null + }; + }; + return PersistedDataFactory; +}()); +var PersistedDataManager = (function () { + function PersistedDataManager() { + this.data = PersistedDataFactory.createDefault(); + var data = localStorage.getItem(PersistedDataManager.LOCAL_STORAGE_KEY); + if (!data) { + this.reset(); + } + else { + this.data = JSON.parse(data); + } + } + PersistedDataManager.prototype.hasCameraPermissions = function () { + return this.data.hasPermission; + }; + PersistedDataManager.prototype.getLastUsedCameraId = function () { + return this.data.lastUsedCameraId; + }; + PersistedDataManager.prototype.setHasPermission = function (hasPermission) { + this.data.hasPermission = hasPermission; + this.flush(); + }; + PersistedDataManager.prototype.setLastUsedCameraId = function (lastUsedCameraId) { + this.data.lastUsedCameraId = lastUsedCameraId; + this.flush(); + }; + PersistedDataManager.prototype.resetLastUsedCameraId = function () { + this.data.lastUsedCameraId = null; + this.flush(); + }; + PersistedDataManager.prototype.reset = function () { + this.data = PersistedDataFactory.createDefault(); + this.flush(); + }; + PersistedDataManager.prototype.flush = function () { + localStorage.setItem(PersistedDataManager.LOCAL_STORAGE_KEY, JSON.stringify(this.data)); + }; + PersistedDataManager.LOCAL_STORAGE_KEY = "HTML5_QRCODE_DATA"; + return PersistedDataManager; +}()); +exports.PersistedDataManager = PersistedDataManager; +//# sourceMappingURL=storage.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/storage.js.map b/src/main/node_modules/html5-qrcode/cjs/storage.js.map new file mode 100644 index 0000000000000000000000000000000000000000..aeda3f00039fa55fbe8f311f2181bcb562dc7ccb --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/storage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":";;;AAeA;IAAA;IAOA,CAAC;IANU,kCAAa,GAApB;QACI,OAAO;YACH,aAAa,EAAE,KAAK;YACpB,gBAAgB,EAAE,IAAI;SACzB,CAAC;IACN,CAAC;IACL,2BAAC;AAAD,CAAC,AAPD,IAOC;AAED;IAKI;QAHQ,SAAI,GAAkB,oBAAoB,CAAC,aAAa,EAAE,CAAC;QAI/D,IAAI,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,EAAE;YACP,IAAI,CAAC,KAAK,EAAE,CAAC;SAChB;aAAM;YACH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAChC;IACL,CAAC;IAEM,mDAAoB,GAA3B;QACI,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;IACnC,CAAC;IAEM,kDAAmB,GAA1B;QACI,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;IACtC,CAAC;IAEM,+CAAgB,GAAvB,UAAwB,aAAsB;QAC1C,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACxC,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEM,kDAAmB,GAA1B,UAA2B,gBAAwB;QAC/C,IAAI,CAAC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEM,oDAAqB,GAA5B;QACI,IAAI,CAAC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEM,oCAAK,GAAZ;QACI,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC,aAAa,EAAE,CAAC;QACjD,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEO,oCAAK,GAAb;QACI,YAAY,CAAC,OAAO,CAChB,oBAAoB,CAAC,iBAAiB,EACtC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnC,CAAC;IA3Cc,sCAAiB,GAAW,mBAAmB,CAAC;IA4CnE,2BAAC;CAAA,AA/CD,IA+CC;AA/CY,oDAAoB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/strings.d.ts b/src/main/node_modules/html5-qrcode/cjs/strings.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb99f90013e8dc8c8fb988e3383678cdd993b99e --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/strings.d.ts @@ -0,0 +1,45 @@ +export declare class Html5QrcodeStrings { + static codeParseError(exception: any): string; + static errorGettingUserMedia(error: any): string; + static onlyDeviceSupportedError(): string; + static cameraStreamingNotSupported(): string; + static unableToQuerySupportedDevices(): string; + static insecureContextCameraQueryError(): string; + static scannerPaused(): string; +} +export declare class Html5QrcodeScannerStrings { + static scanningStatus(): string; + static idleStatus(): string; + static errorStatus(): string; + static permissionStatus(): string; + static noCameraFoundErrorStatus(): string; + static lastMatch(decodedText: string): string; + static codeScannerTitle(): string; + static cameraPermissionTitle(): string; + static cameraPermissionRequesting(): string; + static noCameraFound(): string; + static scanButtonStopScanningText(): string; + static scanButtonStartScanningText(): string; + static torchOnButton(): string; + static torchOffButton(): string; + static torchOnFailedMessage(): string; + static torchOffFailedMessage(): string; + static scanButtonScanningStarting(): string; + static textIfCameraScanSelected(): string; + static textIfFileScanSelected(): string; + static selectCamera(): string; + static fileSelectionChooseImage(): string; + static fileSelectionChooseAnother(): string; + static fileSelectionNoImageSelected(): string; + static anonymousCameraPrefix(): string; + static dragAndDropMessage(): string; + static dragAndDropMessageOnlyImages(): string; + static zoom(): string; + static loadingImage(): string; + static cameraScanAltText(): string; + static fileScanAltText(): string; +} +export declare class LibraryInfoStrings { + static poweredBy(): string; + static reportIssues(): string; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/strings.js b/src/main/node_modules/html5-qrcode/cjs/strings.js new file mode 100644 index 0000000000000000000000000000000000000000..97bfbf5a57a1fd45255c8668bd70542192734d57 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/strings.js @@ -0,0 +1,142 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LibraryInfoStrings = exports.Html5QrcodeScannerStrings = exports.Html5QrcodeStrings = void 0; +var Html5QrcodeStrings = (function () { + function Html5QrcodeStrings() { + } + Html5QrcodeStrings.codeParseError = function (exception) { + return "QR code parse error, error = ".concat(exception); + }; + Html5QrcodeStrings.errorGettingUserMedia = function (error) { + return "Error getting userMedia, error = ".concat(error); + }; + Html5QrcodeStrings.onlyDeviceSupportedError = function () { + return "The device doesn't support navigator.mediaDevices , only " + + "supported cameraIdOrConfig in this case is deviceId parameter " + + "(string)."; + }; + Html5QrcodeStrings.cameraStreamingNotSupported = function () { + return "Camera streaming not supported by the browser."; + }; + Html5QrcodeStrings.unableToQuerySupportedDevices = function () { + return "Unable to query supported devices, unknown error."; + }; + Html5QrcodeStrings.insecureContextCameraQueryError = function () { + return "Camera access is only supported in secure context like https " + + "or localhost."; + }; + Html5QrcodeStrings.scannerPaused = function () { + return "Scanner paused"; + }; + return Html5QrcodeStrings; +}()); +exports.Html5QrcodeStrings = Html5QrcodeStrings; +var Html5QrcodeScannerStrings = (function () { + function Html5QrcodeScannerStrings() { + } + Html5QrcodeScannerStrings.scanningStatus = function () { + return "Scanning"; + }; + Html5QrcodeScannerStrings.idleStatus = function () { + return "Idle"; + }; + Html5QrcodeScannerStrings.errorStatus = function () { + return "Error"; + }; + Html5QrcodeScannerStrings.permissionStatus = function () { + return "Permission"; + }; + Html5QrcodeScannerStrings.noCameraFoundErrorStatus = function () { + return "No Cameras"; + }; + Html5QrcodeScannerStrings.lastMatch = function (decodedText) { + return "Last Match: ".concat(decodedText); + }; + Html5QrcodeScannerStrings.codeScannerTitle = function () { + return "Code Scanner"; + }; + Html5QrcodeScannerStrings.cameraPermissionTitle = function () { + return "Request Camera Permissions"; + }; + Html5QrcodeScannerStrings.cameraPermissionRequesting = function () { + return "Requesting camera permissions..."; + }; + Html5QrcodeScannerStrings.noCameraFound = function () { + return "No camera found"; + }; + Html5QrcodeScannerStrings.scanButtonStopScanningText = function () { + return "Stop Scanning"; + }; + Html5QrcodeScannerStrings.scanButtonStartScanningText = function () { + return "Start Scanning"; + }; + Html5QrcodeScannerStrings.torchOnButton = function () { + return "Switch On Torch"; + }; + Html5QrcodeScannerStrings.torchOffButton = function () { + return "Switch Off Torch"; + }; + Html5QrcodeScannerStrings.torchOnFailedMessage = function () { + return "Failed to turn on torch"; + }; + Html5QrcodeScannerStrings.torchOffFailedMessage = function () { + return "Failed to turn off torch"; + }; + Html5QrcodeScannerStrings.scanButtonScanningStarting = function () { + return "Launching Camera..."; + }; + Html5QrcodeScannerStrings.textIfCameraScanSelected = function () { + return "Scan an Image File"; + }; + Html5QrcodeScannerStrings.textIfFileScanSelected = function () { + return "Scan using camera directly"; + }; + Html5QrcodeScannerStrings.selectCamera = function () { + return "Select Camera"; + }; + Html5QrcodeScannerStrings.fileSelectionChooseImage = function () { + return "Choose Image"; + }; + Html5QrcodeScannerStrings.fileSelectionChooseAnother = function () { + return "Choose Another"; + }; + Html5QrcodeScannerStrings.fileSelectionNoImageSelected = function () { + return "No image choosen"; + }; + Html5QrcodeScannerStrings.anonymousCameraPrefix = function () { + return "Anonymous Camera"; + }; + Html5QrcodeScannerStrings.dragAndDropMessage = function () { + return "Or drop an image to scan"; + }; + Html5QrcodeScannerStrings.dragAndDropMessageOnlyImages = function () { + return "Or drop an image to scan (other files not supported)"; + }; + Html5QrcodeScannerStrings.zoom = function () { + return "zoom"; + }; + Html5QrcodeScannerStrings.loadingImage = function () { + return "Loading image..."; + }; + Html5QrcodeScannerStrings.cameraScanAltText = function () { + return "Camera based scan"; + }; + Html5QrcodeScannerStrings.fileScanAltText = function () { + return "Fule based scan"; + }; + return Html5QrcodeScannerStrings; +}()); +exports.Html5QrcodeScannerStrings = Html5QrcodeScannerStrings; +var LibraryInfoStrings = (function () { + function LibraryInfoStrings() { + } + LibraryInfoStrings.poweredBy = function () { + return "Powered by "; + }; + LibraryInfoStrings.reportIssues = function () { + return "Report issues"; + }; + return LibraryInfoStrings; +}()); +exports.LibraryInfoStrings = LibraryInfoStrings; +//# sourceMappingURL=strings.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/strings.js.map b/src/main/node_modules/html5-qrcode/cjs/strings.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ff51b441fa9352ae7d8c94df26c560d49e9be6be --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/strings.js.map @@ -0,0 +1 @@ +{"version":3,"file":"strings.js","sourceRoot":"","sources":["../../src/strings.ts"],"names":[],"mappings":";;;AAeA;IAAA;IAgCA,CAAC;IA9BiB,iCAAc,GAA5B,UAA6B,SAAc;QACvC,OAAO,uCAAgC,SAAS,CAAE,CAAC;IACvD,CAAC;IAEa,wCAAqB,GAAnC,UAAoC,KAAU;QAC1C,OAAO,2CAAoC,KAAK,CAAE,CAAC;IACvD,CAAC;IAEa,2CAAwB,GAAtC;QACI,OAAO,2DAA2D;cAChE,gEAAgE;cAChE,WAAW,CAAC;IAClB,CAAC;IAEa,8CAA2B,GAAzC;QACI,OAAO,gDAAgD,CAAC;IAC5D,CAAC;IAEa,gDAA6B,GAA3C;QACI,OAAO,mDAAmD,CAAC;IAC/D,CAAC;IAEa,kDAA+B,GAA7C;QACI,OAAO,+DAA+D;cACpE,eAAe,CAAC;IACtB,CAAC;IAEa,gCAAa,GAA3B;QACI,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IACL,yBAAC;AAAD,CAAC,AAhCD,IAgCC;AAhCY,gDAAkB;AAuC/B;IAAA;IAqIA,CAAC;IAnIiB,wCAAc,GAA5B;QACI,OAAO,UAAU,CAAC;IACtB,CAAC;IAEa,oCAAU,GAAxB;QACI,OAAO,MAAM,CAAC;IAClB,CAAC;IAEa,qCAAW,GAAzB;QACI,OAAO,OAAO,CAAC;IACnB,CAAC;IAEa,0CAAgB,GAA9B;QACI,OAAO,YAAY,CAAC;IACxB,CAAC;IAEa,kDAAwB,GAAtC;QACI,OAAO,YAAY,CAAC;IACxB,CAAC;IAEa,mCAAS,GAAvB,UAAwB,WAAmB;QACvC,OAAO,sBAAe,WAAW,CAAE,CAAC;IACxC,CAAC;IAEa,0CAAgB,GAA9B;QACI,OAAO,cAAc,CAAC;IAC1B,CAAC;IAEa,+CAAqB,GAAnC;QACI,OAAO,4BAA4B,CAAC;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C;IAC/B,CAAC;IAEa,yCAAe,GAA7B;QACI,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IACL,gCAAC;AAAD,CAAC,AArID,IAqIC;AArIY,8DAAyB;AAwItC;IAAA;IASA,CAAC;IAPiB,4BAAS,GAAvB;QACI,OAAO,aAAa,CAAC;IACzB,CAAC;IAEa,+BAAY,GAA1B;QACI,OAAO,eAAe,CAAC;IAC3B,CAAC;IACL,yBAAC;AAAD,CAAC,AATD,IASC;AATY,gDAAkB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui.d.ts b/src/main/node_modules/html5-qrcode/cjs/ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f03fe96416ae95a12a35935d8b5f61c5d36d433 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui.d.ts @@ -0,0 +1,6 @@ +export declare class LibraryInfoContainer { + private infoDiv; + private infoIcon; + constructor(); + renderInto(parent: HTMLElement): void; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/ui.js b/src/main/node_modules/html5-qrcode/cjs/ui.js new file mode 100644 index 0000000000000000000000000000000000000000..a4c4d32637f05bd47aaf73e64f45b726a92cceb4 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui.js @@ -0,0 +1,118 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LibraryInfoContainer = void 0; +var image_assets_1 = require("./image-assets"); +var strings_1 = require("./strings"); +var LibraryInfoDiv = (function () { + function LibraryInfoDiv() { + this.infoDiv = document.createElement("div"); + } + LibraryInfoDiv.prototype.renderInto = function (parent) { + this.infoDiv.style.position = "absolute"; + this.infoDiv.style.top = "10px"; + this.infoDiv.style.right = "10px"; + this.infoDiv.style.zIndex = "2"; + this.infoDiv.style.display = "none"; + this.infoDiv.style.padding = "5pt"; + this.infoDiv.style.border = "1px solid #171717"; + this.infoDiv.style.fontSize = "10pt"; + this.infoDiv.style.background = "rgb(0 0 0 / 69%)"; + this.infoDiv.style.borderRadius = "5px"; + this.infoDiv.style.textAlign = "center"; + this.infoDiv.style.fontWeight = "400"; + this.infoDiv.style.color = "white"; + this.infoDiv.innerText = strings_1.LibraryInfoStrings.poweredBy(); + var projectLink = document.createElement("a"); + projectLink.innerText = "ScanApp"; + projectLink.href = "https://scanapp.org"; + projectLink.target = "new"; + projectLink.style.color = "white"; + this.infoDiv.appendChild(projectLink); + var breakElemFirst = document.createElement("br"); + var breakElemSecond = document.createElement("br"); + this.infoDiv.appendChild(breakElemFirst); + this.infoDiv.appendChild(breakElemSecond); + var reportIssueLink = document.createElement("a"); + reportIssueLink.innerText = strings_1.LibraryInfoStrings.reportIssues(); + reportIssueLink.href = "https://github.com/mebjas/html5-qrcode/issues"; + reportIssueLink.target = "new"; + reportIssueLink.style.color = "white"; + this.infoDiv.appendChild(reportIssueLink); + parent.appendChild(this.infoDiv); + }; + LibraryInfoDiv.prototype.show = function () { + this.infoDiv.style.display = "block"; + }; + LibraryInfoDiv.prototype.hide = function () { + this.infoDiv.style.display = "none"; + }; + return LibraryInfoDiv; +}()); +var LibraryInfoIcon = (function () { + function LibraryInfoIcon(onTapIn, onTapOut) { + this.isShowingInfoIcon = true; + this.onTapIn = onTapIn; + this.onTapOut = onTapOut; + this.infoIcon = document.createElement("img"); + } + LibraryInfoIcon.prototype.renderInto = function (parent) { + var _this = this; + this.infoIcon.alt = "Info icon"; + this.infoIcon.src = image_assets_1.ASSET_INFO_ICON_16PX; + this.infoIcon.style.position = "absolute"; + this.infoIcon.style.top = "4px"; + this.infoIcon.style.right = "4px"; + this.infoIcon.style.opacity = "0.6"; + this.infoIcon.style.cursor = "pointer"; + this.infoIcon.style.zIndex = "2"; + this.infoIcon.style.width = "16px"; + this.infoIcon.style.height = "16px"; + this.infoIcon.onmouseover = function (_) { return _this.onHoverIn(); }; + this.infoIcon.onmouseout = function (_) { return _this.onHoverOut(); }; + this.infoIcon.onclick = function (_) { return _this.onClick(); }; + parent.appendChild(this.infoIcon); + }; + LibraryInfoIcon.prototype.onHoverIn = function () { + if (this.isShowingInfoIcon) { + this.infoIcon.style.opacity = "1"; + } + }; + LibraryInfoIcon.prototype.onHoverOut = function () { + if (this.isShowingInfoIcon) { + this.infoIcon.style.opacity = "0.6"; + } + }; + LibraryInfoIcon.prototype.onClick = function () { + if (this.isShowingInfoIcon) { + this.isShowingInfoIcon = false; + this.onTapIn(); + this.infoIcon.src = image_assets_1.ASSET_CLOSE_ICON_16PX; + this.infoIcon.style.opacity = "1"; + } + else { + this.isShowingInfoIcon = true; + this.onTapOut(); + this.infoIcon.src = image_assets_1.ASSET_INFO_ICON_16PX; + this.infoIcon.style.opacity = "0.6"; + } + }; + return LibraryInfoIcon; +}()); +var LibraryInfoContainer = (function () { + function LibraryInfoContainer() { + var _this = this; + this.infoDiv = new LibraryInfoDiv(); + this.infoIcon = new LibraryInfoIcon(function () { + _this.infoDiv.show(); + }, function () { + _this.infoDiv.hide(); + }); + } + LibraryInfoContainer.prototype.renderInto = function (parent) { + this.infoDiv.renderInto(parent); + this.infoIcon.renderInto(parent); + }; + return LibraryInfoContainer; +}()); +exports.LibraryInfoContainer = LibraryInfoContainer; +//# sourceMappingURL=ui.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui.js.map b/src/main/node_modules/html5-qrcode/cjs/ui.js.map new file mode 100644 index 0000000000000000000000000000000000000000..31868f45bdeb2d1a05a0bfc50aa930c051cb8308 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/ui.ts"],"names":[],"mappings":";;;AAUA,+CAA6E;AAE7E,qCAA+C;AAM/C;IAGI;QACI,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IAEM,mCAAU,GAAjB,UAAkB,MAAmB;QACjC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,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AO,GAAG,KAAK,CAAC;SACvC;IACL,CAAC;IAEO,iCAAO,GAAf;QACI,IAAI,IAAI,CAAC,iBAAiB,EAAE;YACxB,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;YAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,oCAAqB,CAAC;YAC1C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;SACrC;aAAM;YACH,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAC9B,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,mCAAoB,CAAC;YACzC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;SACvC;IACL,CAAC;IACL,sBAAC;AAAD,CAAC,AA1DD,IA0DC;AAED;IAKI;QAAA,iBAOC;QANG,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC;YAChC,KAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,EAAE;YACC,KAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,yCAAU,GAAjB,UAAkB,MAAmB;QACjC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IACL,2BAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,oDAAoB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/base.d.ts b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/base.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f6ba9cf120e4959471cfef863e282fbbbb9db22 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/base.d.ts @@ -0,0 +1,16 @@ +export declare class PublicUiElementIdAndClasses { + static ALL_ELEMENT_CLASS: string; + static CAMERA_PERMISSION_BUTTON_ID: string; + static CAMERA_START_BUTTON_ID: string; + static CAMERA_STOP_BUTTON_ID: string; + static TORCH_BUTTON_ID: string; + static CAMERA_SELECTION_SELECT_ID: string; + static FILE_SELECTION_BUTTON_ID: string; + static ZOOM_SLIDER_ID: string; + static SCAN_TYPE_CHANGE_ANCHOR_ID: string; + static TORCH_BUTTON_CLASS_TORCH_ON: string; + static TORCH_BUTTON_CLASS_TORCH_OFF: string; +} +export declare class BaseUiElementFactory { + static createElement<Type extends HTMLElement>(elementType: string, elementId: string): Type; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/base.js b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/base.js new file mode 100644 index 0000000000000000000000000000000000000000..bcdabfc1cd320a5fc209b7226c9c27808c4609e8 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/base.js @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BaseUiElementFactory = exports.PublicUiElementIdAndClasses = void 0; +var PublicUiElementIdAndClasses = (function () { + function PublicUiElementIdAndClasses() { + } + PublicUiElementIdAndClasses.ALL_ELEMENT_CLASS = "html5-qrcode-element"; + PublicUiElementIdAndClasses.CAMERA_PERMISSION_BUTTON_ID = "html5-qrcode-button-camera-permission"; + PublicUiElementIdAndClasses.CAMERA_START_BUTTON_ID = "html5-qrcode-button-camera-start"; + PublicUiElementIdAndClasses.CAMERA_STOP_BUTTON_ID = "html5-qrcode-button-camera-stop"; + PublicUiElementIdAndClasses.TORCH_BUTTON_ID = "html5-qrcode-button-torch"; + PublicUiElementIdAndClasses.CAMERA_SELECTION_SELECT_ID = "html5-qrcode-select-camera"; + PublicUiElementIdAndClasses.FILE_SELECTION_BUTTON_ID = "html5-qrcode-button-file-selection"; + PublicUiElementIdAndClasses.ZOOM_SLIDER_ID = "html5-qrcode-input-range-zoom"; + PublicUiElementIdAndClasses.SCAN_TYPE_CHANGE_ANCHOR_ID = "html5-qrcode-anchor-scan-type-change"; + PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON = "html5-qrcode-button-torch-on"; + PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF = "html5-qrcode-button-torch-off"; + return PublicUiElementIdAndClasses; +}()); +exports.PublicUiElementIdAndClasses = PublicUiElementIdAndClasses; +var BaseUiElementFactory = (function () { + function BaseUiElementFactory() { + } + BaseUiElementFactory.createElement = function (elementType, elementId) { + var element = (document.createElement(elementType)); + element.id = elementId; + element.classList.add(PublicUiElementIdAndClasses.ALL_ELEMENT_CLASS); + if (elementType === "button") { + element.setAttribute("type", "button"); + } + return element; + }; + return BaseUiElementFactory; +}()); +exports.BaseUiElementFactory = BaseUiElementFactory; +//# sourceMappingURL=base.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/base.js.map b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/base.js.map new file mode 100644 index 0000000000000000000000000000000000000000..436f8c42022ea065d41d13eb1c845b6d203d0273 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/base.js.map @@ -0,0 +1 @@ +{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/ui/scanner/base.ts"],"names":[],"mappings":";;;AAcA;IAAA;IA4CA,CAAC;IAxCU,6CAAiB,GAAG,sBAAsB,CAAC;IAG3C,uDAA2B,GAAG,uCAAuC,CAAC;IAGtE,kDAAsB,GAAG,kCAAkC,CAAC;IAG5D,iDAAqB,GAAG,iCAAiC,CAAC;IAG1D,2CAAe,GAAG,2BAA2B,CAAC;IAG9C,sDAA0B,GAAG,4BAA4B,CAAC;IAG1D,oDAAwB,GAAG,oCAAoC,CAAC;IAGhE,0CAAc,GAAG,+BAA+B,CAAC;IAMjD,sDAA0B,GAAG,sCAAsC,CAAC;IAOpE,uDAA2B,GAAG,8BAA8B,CAAC;IAG7D,wDAA4B,GAAG,+BAA+B,CAAC;IAG1E,kCAAC;CAAA,AA5CD,IA4CC;AA5CY,kEAA2B;AAiDxC;IAAA;IAiBA,CAAC;IAXiB,kCAAa,GAA3B,UACI,WAAmB,EAAE,SAAiB;QAEtC,IAAI,OAAO,GAAe,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;QAChE,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;QACvB,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,2BAA2B,CAAC,iBAAiB,CAAC,CAAC;QACrE,IAAI,WAAW,KAAK,QAAQ,EAAE;YAC1B,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;SAC1C;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IACL,2BAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,oDAAoB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-selection-ui.d.ts b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-selection-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2090ed53de81e3fc2a4a3f33806eace194c983c9 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-selection-ui.d.ts @@ -0,0 +1,17 @@ +import { CameraDevice } from "../../camera/core"; +export declare class CameraSelectionUi { + private readonly selectElement; + private readonly options; + private readonly cameras; + private constructor(); + private render; + disable(): void; + isDisabled(): boolean; + enable(): void; + getValue(): string; + hasValue(value: string): boolean; + setValue(value: string): void; + hasSingleItem(): boolean; + numCameras(): number; + static create(parentElement: HTMLElement, cameras: Array<CameraDevice>): CameraSelectionUi; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-selection-ui.js b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-selection-ui.js new file mode 100644 index 0000000000000000000000000000000000000000..3c9a9d93e08aab8e3bb0730efb6fc27459fd3894 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-selection-ui.js @@ -0,0 +1,89 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CameraSelectionUi = void 0; +var base_1 = require("./base"); +var strings_1 = require("../../strings"); +var CameraSelectionUi = (function () { + function CameraSelectionUi(cameras) { + this.selectElement = base_1.BaseUiElementFactory + .createElement("select", base_1.PublicUiElementIdAndClasses.CAMERA_SELECTION_SELECT_ID); + this.cameras = cameras; + this.options = []; + } + CameraSelectionUi.prototype.render = function (parentElement) { + var cameraSelectionContainer = document.createElement("span"); + cameraSelectionContainer.style.marginRight = "10px"; + var numCameras = this.cameras.length; + if (numCameras === 0) { + throw new Error("No cameras found"); + } + if (numCameras === 1) { + cameraSelectionContainer.style.display = "none"; + } + else { + var selectCameraString = strings_1.Html5QrcodeScannerStrings.selectCamera(); + cameraSelectionContainer.innerText + = "".concat(selectCameraString, " (").concat(this.cameras.length, ") "); + } + var anonymousCameraId = 1; + for (var _i = 0, _a = this.cameras; _i < _a.length; _i++) { + var camera = _a[_i]; + var value = camera.id; + var name_1 = camera.label == null ? value : camera.label; + if (!name_1 || name_1 === "") { + name_1 = [ + strings_1.Html5QrcodeScannerStrings.anonymousCameraPrefix(), + anonymousCameraId++ + ].join(" "); + } + var option = document.createElement("option"); + option.value = value; + option.innerText = name_1; + this.options.push(option); + this.selectElement.appendChild(option); + } + cameraSelectionContainer.appendChild(this.selectElement); + parentElement.appendChild(cameraSelectionContainer); + }; + CameraSelectionUi.prototype.disable = function () { + this.selectElement.disabled = true; + }; + CameraSelectionUi.prototype.isDisabled = function () { + return this.selectElement.disabled === true; + }; + CameraSelectionUi.prototype.enable = function () { + this.selectElement.disabled = false; + }; + CameraSelectionUi.prototype.getValue = function () { + return this.selectElement.value; + }; + CameraSelectionUi.prototype.hasValue = function (value) { + for (var _i = 0, _a = this.options; _i < _a.length; _i++) { + var option = _a[_i]; + if (option.value === value) { + return true; + } + } + return false; + }; + CameraSelectionUi.prototype.setValue = function (value) { + if (!this.hasValue(value)) { + throw new Error("".concat(value, " is not present in the camera list.")); + } + this.selectElement.value = value; + }; + CameraSelectionUi.prototype.hasSingleItem = function () { + return this.cameras.length === 1; + }; + CameraSelectionUi.prototype.numCameras = function () { + return this.cameras.length; + }; + CameraSelectionUi.create = function (parentElement, cameras) { + var cameraSelectUi = new CameraSelectionUi(cameras); + cameraSelectUi.render(parentElement); + return cameraSelectUi; + }; + return CameraSelectionUi; +}()); +exports.CameraSelectionUi = CameraSelectionUi; +//# sourceMappingURL=camera-selection-ui.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-selection-ui.js.map b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-selection-ui.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8d16948a326923d183e826166fff9e39934c96c3 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-selection-ui.js.map @@ -0,0 +1 @@ +{"version":3,"file":"camera-selection-ui.js","sourceRoot":"","sources":["../../../../src/ui/scanner/camera-selection-ui.ts"],"names":[],"mappings":";;;AAWA,+BAGgB;AAChB,yCAEuB;AAGvB;IAMI,2BAAoB,OAA4B;QAC5C,IAAI,CAAC,aAAa,GAAG,2BAAoB;aACpC,aAAa,CACd,QAAQ,EACR,kCAA2B,CAAC,0BAA0B,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;IAGO,kCAAM,GAAd,UACI,aAA0B;QAC1B,IAAM,wBAAwB,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAChE,wBAAwB,CAAC,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC;QACpD,IAAM,UAAU,GAAG,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O,cAAc,CAAC;IAC1B,CAAC;IACL,wBAAC;AAAD,CAAC,AA5GD,IA4GC;AA5GY,8CAAiB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-zoom-ui.d.ts b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-zoom-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..215bb3f45a562941e18b27204250b45b021bc973 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-zoom-ui.d.ts @@ -0,0 +1,16 @@ +export type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; +export declare class CameraZoomUi { + private zoomElementContainer; + private rangeInput; + private rangeText; + private onChangeCallback; + private constructor(); + private render; + private onValueChange; + setValues(minValue: number, maxValue: number, defaultValue: number, step: number): void; + show(): void; + hide(): void; + setOnCameraZoomValueChangeCallback(onChangeCallback: OnCameraZoomValueChangeCallback): void; + removeOnCameraZoomValueChangeCallback(): void; + static create(parentElement: HTMLElement, renderOnCreate: boolean): CameraZoomUi; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-zoom-ui.js b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-zoom-ui.js new file mode 100644 index 0000000000000000000000000000000000000000..c3dee1b1485cd3be0374247014b93508ae1e1318 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-zoom-ui.js @@ -0,0 +1,73 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CameraZoomUi = void 0; +var base_1 = require("./base"); +var strings_1 = require("../../strings"); +var CameraZoomUi = (function () { + function CameraZoomUi() { + this.onChangeCallback = null; + this.zoomElementContainer = document.createElement("div"); + this.rangeInput = base_1.BaseUiElementFactory.createElement("input", base_1.PublicUiElementIdAndClasses.ZOOM_SLIDER_ID); + this.rangeInput.type = "range"; + this.rangeText = document.createElement("span"); + this.rangeInput.min = "1"; + this.rangeInput.max = "5"; + this.rangeInput.value = "1"; + this.rangeInput.step = "0.1"; + } + CameraZoomUi.prototype.render = function (parentElement, renderOnCreate) { + this.zoomElementContainer.style.display + = renderOnCreate ? "block" : "none"; + this.zoomElementContainer.style.padding = "5px 10px"; + this.zoomElementContainer.style.textAlign = "center"; + parentElement.appendChild(this.zoomElementContainer); + this.rangeInput.style.display = "inline-block"; + this.rangeInput.style.width = "50%"; + this.rangeInput.style.height = "5px"; + this.rangeInput.style.background = "#d3d3d3"; + this.rangeInput.style.outline = "none"; + this.rangeInput.style.opacity = "0.7"; + var zoomString = strings_1.Html5QrcodeScannerStrings.zoom(); + this.rangeText.innerText = "".concat(this.rangeInput.value, "x ").concat(zoomString); + this.rangeText.style.marginRight = "10px"; + var $this = this; + this.rangeInput.addEventListener("input", function () { return $this.onValueChange(); }); + this.rangeInput.addEventListener("change", function () { return $this.onValueChange(); }); + this.zoomElementContainer.appendChild(this.rangeInput); + this.zoomElementContainer.appendChild(this.rangeText); + }; + CameraZoomUi.prototype.onValueChange = function () { + var zoomString = strings_1.Html5QrcodeScannerStrings.zoom(); + this.rangeText.innerText = "".concat(this.rangeInput.value, "x ").concat(zoomString); + if (this.onChangeCallback) { + this.onChangeCallback(parseFloat(this.rangeInput.value)); + } + }; + CameraZoomUi.prototype.setValues = function (minValue, maxValue, defaultValue, step) { + this.rangeInput.min = minValue.toString(); + this.rangeInput.max = maxValue.toString(); + this.rangeInput.step = step.toString(); + this.rangeInput.value = defaultValue.toString(); + this.onValueChange(); + }; + CameraZoomUi.prototype.show = function () { + this.zoomElementContainer.style.display = "block"; + }; + CameraZoomUi.prototype.hide = function () { + this.zoomElementContainer.style.display = "none"; + }; + CameraZoomUi.prototype.setOnCameraZoomValueChangeCallback = function (onChangeCallback) { + this.onChangeCallback = onChangeCallback; + }; + CameraZoomUi.prototype.removeOnCameraZoomValueChangeCallback = function () { + this.onChangeCallback = null; + }; + CameraZoomUi.create = function (parentElement, renderOnCreate) { + var cameraZoomUi = new CameraZoomUi(); + cameraZoomUi.render(parentElement, renderOnCreate); + return cameraZoomUi; + }; + return CameraZoomUi; +}()); +exports.CameraZoomUi = CameraZoomUi; +//# sourceMappingURL=camera-zoom-ui.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-zoom-ui.js.map b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-zoom-ui.js.map new file mode 100644 index 0000000000000000000000000000000000000000..42f3c22d52f5d8b9949f2a85d14ae90341daba20 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/camera-zoom-ui.js.map @@ -0,0 +1 @@ +{"version":3,"file":"camera-zoom-ui.js","sourceRoot":"","sources":["../../../../src/ui/scanner/camera-zoom-ui.ts"],"names":[],"mappings":";;;AAUC,+BAGe;AAEhB,yCAA0D;AAM1D;IAQI;QAFQ,qBAAgB,GAA2C,IAAI,CAAC;QAGpE,IAAI,CAAC,oBAAoB,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1D,IAAI,CAAC,UAAU,GAAG,2BAAoB,CAAC,aAAa,CAChD,OAAO,EAAE,kCAA2B,CAAC,cAAc,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,OAAO,CAAC;QAE/B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAGhD,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,GAAG,CAAC;QAC1B,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,GAAG,CAAC;QAC1B,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,GAAG,CAAC;QAC5B,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,KAAK,CAAC;IACjC,CAAC;IAEO,6BAAM,GAAd,UACI,aAA0B,EAC1B,cAAuB;QAEvB,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,OAAO;cACjC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,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,YAAY,EAAE,CAAC;QACtC,YAAY,CAAC,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QACnD,OAAO,YAAY,CAAC;IACxB,CAAC;IACL,mBAAC;AAAD,CAAC,AAxGD,IAwGC;AAxGY,oCAAY"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/file-selection-ui.d.ts b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/file-selection-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..768f5ed8d5b9cd84994a11bca20a02224c665a75 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/file-selection-ui.d.ts @@ -0,0 +1,19 @@ +export type OnFileSelected = (file: File) => void; +export declare class FileSelectionUi { + private readonly fileBasedScanRegion; + private readonly fileScanInput; + private readonly fileSelectionButton; + private constructor(); + hide(): void; + show(): void; + isShowing(): boolean; + resetValue(): void; + private createFileBasedScanRegion; + private fileBasedScanRegionDefaultBorder; + private fileBasedScanRegionActiveBorder; + private createDragAndDropMessage; + private setImageNameToButton; + private setInitialValueToButton; + private getFileScanInputId; + static create(parentElement: HTMLDivElement, showOnRender: boolean, onFileSelected: OnFileSelected): FileSelectionUi; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/file-selection-ui.js b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/file-selection-ui.js new file mode 100644 index 0000000000000000000000000000000000000000..62d66989781e15ae33e04e12dc31814641e2096f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/file-selection-ui.js @@ -0,0 +1,170 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.FileSelectionUi = void 0; +var strings_1 = require("../../strings"); +var base_1 = require("./base"); +var FileSelectionUi = (function () { + function FileSelectionUi(parentElement, showOnRender, onFileSelected) { + this.fileBasedScanRegion = this.createFileBasedScanRegion(); + this.fileBasedScanRegion.style.display + = showOnRender ? "block" : "none"; + parentElement.appendChild(this.fileBasedScanRegion); + var fileScanLabel = document.createElement("label"); + fileScanLabel.setAttribute("for", this.getFileScanInputId()); + fileScanLabel.style.display = "inline-block"; + this.fileBasedScanRegion.appendChild(fileScanLabel); + this.fileSelectionButton + = base_1.BaseUiElementFactory.createElement("button", base_1.PublicUiElementIdAndClasses.FILE_SELECTION_BUTTON_ID); + this.setInitialValueToButton(); + this.fileSelectionButton.addEventListener("click", function (_) { + fileScanLabel.click(); + }); + fileScanLabel.append(this.fileSelectionButton); + this.fileScanInput + = base_1.BaseUiElementFactory.createElement("input", this.getFileScanInputId()); + this.fileScanInput.type = "file"; + this.fileScanInput.accept = "image/*"; + this.fileScanInput.style.display = "none"; + fileScanLabel.appendChild(this.fileScanInput); + var $this = this; + this.fileScanInput.addEventListener("change", function (e) { + if (e == null || e.target == null) { + return; + } + var target = e.target; + if (target.files && target.files.length === 0) { + return; + } + var fileList = target.files; + var file = fileList[0]; + var fileName = file.name; + $this.setImageNameToButton(fileName); + onFileSelected(file); + }); + var dragAndDropMessage = this.createDragAndDropMessage(); + this.fileBasedScanRegion.appendChild(dragAndDropMessage); + this.fileBasedScanRegion.addEventListener("dragenter", function (event) { + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionActiveBorder(); + event.stopPropagation(); + event.preventDefault(); + }); + this.fileBasedScanRegion.addEventListener("dragleave", function (event) { + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionDefaultBorder(); + event.stopPropagation(); + event.preventDefault(); + }); + this.fileBasedScanRegion.addEventListener("dragover", function (event) { + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionActiveBorder(); + event.stopPropagation(); + event.preventDefault(); + }); + this.fileBasedScanRegion.addEventListener("drop", function (event) { + event.stopPropagation(); + event.preventDefault(); + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionDefaultBorder(); + var dataTransfer = event.dataTransfer; + if (dataTransfer) { + var files = dataTransfer.files; + if (!files || files.length === 0) { + return; + } + var isAnyFileImage = false; + for (var i = 0; i < files.length; ++i) { + var file = files.item(i); + if (!file) { + continue; + } + var imageType = /image.*/; + if (!file.type.match(imageType)) { + continue; + } + isAnyFileImage = true; + var fileName = file.name; + $this.setImageNameToButton(fileName); + onFileSelected(file); + dragAndDropMessage.innerText + = strings_1.Html5QrcodeScannerStrings.dragAndDropMessage(); + break; + } + if (!isAnyFileImage) { + dragAndDropMessage.innerText + = strings_1.Html5QrcodeScannerStrings + .dragAndDropMessageOnlyImages(); + } + } + }); + } + FileSelectionUi.prototype.hide = function () { + this.fileBasedScanRegion.style.display = "none"; + this.fileScanInput.disabled = true; + }; + FileSelectionUi.prototype.show = function () { + this.fileBasedScanRegion.style.display = "block"; + this.fileScanInput.disabled = false; + }; + FileSelectionUi.prototype.isShowing = function () { + return this.fileBasedScanRegion.style.display === "block"; + }; + FileSelectionUi.prototype.resetValue = function () { + this.fileScanInput.value = ""; + this.setInitialValueToButton(); + }; + FileSelectionUi.prototype.createFileBasedScanRegion = function () { + var fileBasedScanRegion = document.createElement("div"); + fileBasedScanRegion.style.textAlign = "center"; + fileBasedScanRegion.style.margin = "auto"; + fileBasedScanRegion.style.width = "80%"; + fileBasedScanRegion.style.maxWidth = "600px"; + fileBasedScanRegion.style.border + = this.fileBasedScanRegionDefaultBorder(); + fileBasedScanRegion.style.padding = "10px"; + fileBasedScanRegion.style.marginBottom = "10px"; + return fileBasedScanRegion; + }; + FileSelectionUi.prototype.fileBasedScanRegionDefaultBorder = function () { + return "6px dashed #ebebeb"; + }; + FileSelectionUi.prototype.fileBasedScanRegionActiveBorder = function () { + return "6px dashed rgb(153 151 151)"; + }; + FileSelectionUi.prototype.createDragAndDropMessage = function () { + var dragAndDropMessage = document.createElement("div"); + dragAndDropMessage.innerText + = strings_1.Html5QrcodeScannerStrings.dragAndDropMessage(); + dragAndDropMessage.style.fontWeight = "400"; + return dragAndDropMessage; + }; + FileSelectionUi.prototype.setImageNameToButton = function (imageFileName) { + var MAX_CHARS = 20; + if (imageFileName.length > MAX_CHARS) { + var start8Chars = imageFileName.substring(0, 8); + var length_1 = imageFileName.length; + var last8Chars = imageFileName.substring(length_1 - 8, length_1); + imageFileName = "".concat(start8Chars, "....").concat(last8Chars); + } + var newText = strings_1.Html5QrcodeScannerStrings.fileSelectionChooseAnother() + + " - " + + imageFileName; + this.fileSelectionButton.innerText = newText; + }; + FileSelectionUi.prototype.setInitialValueToButton = function () { + var initialText = strings_1.Html5QrcodeScannerStrings.fileSelectionChooseImage() + + " - " + + strings_1.Html5QrcodeScannerStrings.fileSelectionNoImageSelected(); + this.fileSelectionButton.innerText = initialText; + }; + FileSelectionUi.prototype.getFileScanInputId = function () { + return "html5-qrcode-private-filescan-input"; + }; + FileSelectionUi.create = function (parentElement, showOnRender, onFileSelected) { + var button = new FileSelectionUi(parentElement, showOnRender, onFileSelected); + return button; + }; + return FileSelectionUi; +}()); +exports.FileSelectionUi = FileSelectionUi; +//# sourceMappingURL=file-selection-ui.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/file-selection-ui.js.map b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/file-selection-ui.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b860ebf27093606afa7536cf8fdfbc47254992dc --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/file-selection-ui.js.map @@ -0,0 +1 @@ +{"version":3,"file":"file-selection-ui.js","sourceRoot":"","sources":["../../../../src/ui/scanner/file-selection-ui.ts"],"names":[],"mappings":";;;AAUA,yCAAwD;AACxD,+BAGgB;AAQhB;IAOI,yBACI,aAA6B,EAC7B,YAAqB,EACrB,cAA8B;QAC9B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAC5D,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO;cAChC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;QACtC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,mB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C;QACjD,OAAO,MAAM,CAAC;IAClB,CAAC;IACL,sBAAC;AAAD,CAAC,AAhPD,IAgPC;AAhPY,0CAAe"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/scan-type-selector.d.ts b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/scan-type-selector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f0e1347449e85244139b7cf48cd52b2fca300cb --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/scan-type-selector.d.ts @@ -0,0 +1,11 @@ +import { Html5QrcodeScanType } from "../../core"; +export declare class ScanTypeSelector { + private supportedScanTypes; + constructor(supportedScanTypes?: Array<Html5QrcodeScanType> | []); + getDefaultScanType(): Html5QrcodeScanType; + hasMoreThanOneScanType(): boolean; + isCameraScanRequired(): boolean; + static isCameraScanType(scanType: Html5QrcodeScanType): boolean; + static isFileScanType(scanType: Html5QrcodeScanType): boolean; + private validateAndReturnScanTypes; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/scan-type-selector.js b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/scan-type-selector.js new file mode 100644 index 0000000000000000000000000000000000000000..df70b5591c83efc2e137b9121ba1a8eea2c59e24 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/scan-type-selector.js @@ -0,0 +1,51 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ScanTypeSelector = void 0; +var core_1 = require("../../core"); +var ScanTypeSelector = (function () { + function ScanTypeSelector(supportedScanTypes) { + this.supportedScanTypes = this.validateAndReturnScanTypes(supportedScanTypes); + } + ScanTypeSelector.prototype.getDefaultScanType = function () { + return this.supportedScanTypes[0]; + }; + ScanTypeSelector.prototype.hasMoreThanOneScanType = function () { + return this.supportedScanTypes.length > 1; + }; + ScanTypeSelector.prototype.isCameraScanRequired = function () { + for (var _i = 0, _a = this.supportedScanTypes; _i < _a.length; _i++) { + var scanType = _a[_i]; + if (ScanTypeSelector.isCameraScanType(scanType)) { + return true; + } + } + return false; + }; + ScanTypeSelector.isCameraScanType = function (scanType) { + return scanType === core_1.Html5QrcodeScanType.SCAN_TYPE_CAMERA; + }; + ScanTypeSelector.isFileScanType = function (scanType) { + return scanType === core_1.Html5QrcodeScanType.SCAN_TYPE_FILE; + }; + ScanTypeSelector.prototype.validateAndReturnScanTypes = function (supportedScanTypes) { + if (!supportedScanTypes || supportedScanTypes.length === 0) { + return core_1.Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE; + } + var maxExpectedValues = core_1.Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE.length; + if (supportedScanTypes.length > maxExpectedValues) { + throw "Max ".concat(maxExpectedValues, " values expected for ") + + "supportedScanTypes"; + } + for (var _i = 0, supportedScanTypes_1 = supportedScanTypes; _i < supportedScanTypes_1.length; _i++) { + var scanType = supportedScanTypes_1[_i]; + if (!core_1.Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE + .includes(scanType)) { + throw "Unsupported scan type ".concat(scanType); + } + } + return supportedScanTypes; + }; + return ScanTypeSelector; +}()); +exports.ScanTypeSelector = ScanTypeSelector; +//# sourceMappingURL=scan-type-selector.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/scan-type-selector.js.map b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/scan-type-selector.js.map new file mode 100644 index 0000000000000000000000000000000000000000..99e52261df69e2b41a13d96335597501a5bf7428 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/scan-type-selector.js.map @@ -0,0 +1 @@ +{"version":3,"file":"scan-type-selector.js","sourceRoot":"","sources":["../../../../src/ui/scanner/scan-type-selector.ts"],"names":[],"mappings":";;;AAUA,mCAGoB;AAGpB;IAGI,0BAAY,kBAAoD;QAC5D,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,0BAA0B,CACrD,kBAAkB,CAAC,CAAC;IAC5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C;SACJ;QAED,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAEL,uBAAC;AAAD,CAAC,AA7ED,IA6EC;AA7EY,4CAAgB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/torch-button.d.ts b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/torch-button.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a862a10bae47503e7ee4e8875da199ff90538d6f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/torch-button.d.ts @@ -0,0 +1,28 @@ +import { BooleanCameraCapability } from "../../camera/core"; +export type OnTorchActionFailureCallback = (failureMessage: string) => void; +interface TorchButtonController { + disable(): void; + enable(): void; + setText(text: string): void; +} +export interface TorchButtonOptions { + display: string; + marginLeft: string; +} +export declare class TorchButton implements TorchButtonController { + private readonly torchButton; + private readonly onTorchActionFailureCallback; + private torchController; + private constructor(); + private render; + updateTorchCapability(torchCapability: BooleanCameraCapability): void; + getTorchButton(): HTMLButtonElement; + hide(): void; + show(): void; + disable(): void; + enable(): void; + setText(text: string): void; + reset(): void; + static create(parentElement: HTMLElement, torchCapability: BooleanCameraCapability, torchButtonOptions: TorchButtonOptions, onTorchActionFailureCallback: OnTorchActionFailureCallback): TorchButton; +} +export {}; diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/torch-button.js b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/torch-button.js new file mode 100644 index 0000000000000000000000000000000000000000..4e1b7b296c12f0b4babb8b871d2af6bee86efd8e --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/torch-button.js @@ -0,0 +1,171 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TorchButton = void 0; +var strings_1 = require("../../strings"); +var base_1 = require("./base"); +var TorchController = (function () { + function TorchController(torchCapability, buttonController, onTorchActionFailureCallback) { + this.isTorchOn = false; + this.torchCapability = torchCapability; + this.buttonController = buttonController; + this.onTorchActionFailureCallback = onTorchActionFailureCallback; + } + TorchController.prototype.isTorchEnabled = function () { + return this.isTorchOn; + }; + TorchController.prototype.flipState = function () { + return __awaiter(this, void 0, void 0, function () { + var isTorchOnExpected, error_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + this.buttonController.disable(); + isTorchOnExpected = !this.isTorchOn; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + return [4, this.torchCapability.apply(isTorchOnExpected)]; + case 2: + _a.sent(); + this.updateUiBasedOnLatestSettings(this.torchCapability.value(), isTorchOnExpected); + return [3, 4]; + case 3: + error_1 = _a.sent(); + this.propagateFailure(isTorchOnExpected, error_1); + this.buttonController.enable(); + return [3, 4]; + case 4: return [2]; + } + }); + }); + }; + TorchController.prototype.updateUiBasedOnLatestSettings = function (isTorchOn, isTorchOnExpected) { + if (isTorchOn === isTorchOnExpected) { + this.buttonController.setText(isTorchOnExpected + ? strings_1.Html5QrcodeScannerStrings.torchOffButton() + : strings_1.Html5QrcodeScannerStrings.torchOnButton()); + this.isTorchOn = isTorchOnExpected; + } + else { + this.propagateFailure(isTorchOnExpected); + } + this.buttonController.enable(); + }; + TorchController.prototype.propagateFailure = function (isTorchOnExpected, error) { + var errorMessage = isTorchOnExpected + ? strings_1.Html5QrcodeScannerStrings.torchOnFailedMessage() + : strings_1.Html5QrcodeScannerStrings.torchOffFailedMessage(); + if (error) { + errorMessage += "; Error = " + error; + } + this.onTorchActionFailureCallback(errorMessage); + }; + TorchController.prototype.reset = function () { + this.isTorchOn = false; + }; + return TorchController; +}()); +var TorchButton = (function () { + function TorchButton(torchCapability, onTorchActionFailureCallback) { + this.onTorchActionFailureCallback = onTorchActionFailureCallback; + this.torchButton + = base_1.BaseUiElementFactory.createElement("button", base_1.PublicUiElementIdAndClasses.TORCH_BUTTON_ID); + this.torchController = new TorchController(torchCapability, this, onTorchActionFailureCallback); + } + TorchButton.prototype.render = function (parentElement, torchButtonOptions) { + var _this = this; + this.torchButton.innerText + = strings_1.Html5QrcodeScannerStrings.torchOnButton(); + this.torchButton.style.display = torchButtonOptions.display; + this.torchButton.style.marginLeft = torchButtonOptions.marginLeft; + var $this = this; + this.torchButton.addEventListener("click", function (_) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4, $this.torchController.flipState()]; + case 1: + _a.sent(); + if ($this.torchController.isTorchEnabled()) { + $this.torchButton.classList.remove(base_1.PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF); + $this.torchButton.classList.add(base_1.PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON); + } + else { + $this.torchButton.classList.remove(base_1.PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON); + $this.torchButton.classList.add(base_1.PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF); + } + return [2]; + } + }); + }); }); + parentElement.appendChild(this.torchButton); + }; + TorchButton.prototype.updateTorchCapability = function (torchCapability) { + this.torchController = new TorchController(torchCapability, this, this.onTorchActionFailureCallback); + }; + TorchButton.prototype.getTorchButton = function () { + return this.torchButton; + }; + TorchButton.prototype.hide = function () { + this.torchButton.style.display = "none"; + }; + TorchButton.prototype.show = function () { + this.torchButton.style.display = "inline-block"; + }; + TorchButton.prototype.disable = function () { + this.torchButton.disabled = true; + }; + TorchButton.prototype.enable = function () { + this.torchButton.disabled = false; + }; + TorchButton.prototype.setText = function (text) { + this.torchButton.innerText = text; + }; + TorchButton.prototype.reset = function () { + this.torchButton.innerText = strings_1.Html5QrcodeScannerStrings.torchOnButton(); + this.torchController.reset(); + }; + TorchButton.create = function (parentElement, torchCapability, torchButtonOptions, onTorchActionFailureCallback) { + var button = new TorchButton(torchCapability, onTorchActionFailureCallback); + button.render(parentElement, torchButtonOptions); + return button; + }; + return TorchButton; +}()); +exports.TorchButton = TorchButton; +//# sourceMappingURL=torch-button.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/ui/scanner/torch-button.js.map b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/torch-button.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8cc399e4bb3a74e233005cfb51bdf45db9ed5400 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/ui/scanner/torch-button.js.map @@ -0,0 +1 @@ +{"version":3,"file":"torch-button.js","sourceRoot":"","sources":["../../../../src/ui/scanner/torch-button.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,yCAA0D;AAC1D,+BAGgB;AAehB;IAQI,yBACI,eAAwC,EACxC,gBAAuC,EACvC,4BAA0D;QALtD,cAAS,GAAY,KAAK,CAAC;QAM/B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,4BAA4B,GAAG,4BAA4B,CAAC;IACrE,CAAC;IAGM,wCAAc,GAArB;QACI,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAUY,mCAAS,GAAtB;;;;;;wBACI,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;wBAC5B,iBAAiB,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;;;;wBAEpC,WAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAA;;wBAAnD,SAAmD,CAAC;wBACpD,IAAI,CAAC,6BAA6B,CAC9B,IAAI,CAAC,eAAe,CAAC,KAAK,EAAG,EAAE,iBAAiB,CAAC,CAAC;;;;wBAEtD,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,OAAK,CAAC,CAAC;wBAChD,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;;;;;;KAEtC;IAEO,uDAA6B,GAArC,UACI,SAAkB,EAClB,iBAA0B;QAC1B,IAAI,SAAS,KAAK,iBAAiB,EAAE;YAEjC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,iBA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I,IAAI,CAAC,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC;IACrC,CAAC;IAED,4BAAM,GAAN;QACI,IAAI,CAAC,WAAW,CAAC,QAAQ,GAAG,KAAK,CAAC;IACtC,CAAC;IAED,6BAAO,GAAP,UAAQ,IAAY;QAChB,IAAI,CAAC,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC;IACtC,CAAC;IAOM,2BAAK,GAAZ;QACI,IAAI,CAAC,WAAW,CAAC,SAAS,GAAG,mCAAyB,CAAC,aAAa,EAAE,CAAC;QACvE,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAWc,kBAAM,GAApB,UACG,aAA0B,EAC1B,eAAwC,EACxC,kBAAsC,EACtC,4BAA0D;QAE1D,IAAI,MAAM,GAAG,IAAI,WAAW,CACxB,eAAe,EAAE,4BAA4B,CAAC,CAAC;QACnD,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC;IAClB,CAAC;IACL,kBAAC;AAAD,CAAC,AA5GD,IA4GC;AA5GY,kCAAW"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/utils.d.ts b/src/main/node_modules/html5-qrcode/cjs/utils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b060ed9e1f751f6c8a3592683ce5726bf6d3e20 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/utils.d.ts @@ -0,0 +1,4 @@ +import { Logger } from "./core"; +export declare class VideoConstraintsUtil { + static isMediaStreamConstraintsValid(videoConstraints: MediaTrackConstraints, logger: Logger): boolean; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/utils.js b/src/main/node_modules/html5-qrcode/cjs/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..80d2660d3a69f483eaa300d5805043c10a6fdda9 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/utils.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.VideoConstraintsUtil = void 0; +var VideoConstraintsUtil = (function () { + function VideoConstraintsUtil() { + } + VideoConstraintsUtil.isMediaStreamConstraintsValid = function (videoConstraints, logger) { + if (typeof videoConstraints !== "object") { + var typeofVideoConstraints = typeof videoConstraints; + logger.logError("videoConstraints should be of type object, the " + + "object passed is of type ".concat(typeofVideoConstraints, "."), true); + return false; + } + var bannedKeys = [ + "autoGainControl", + "channelCount", + "echoCancellation", + "latency", + "noiseSuppression", + "sampleRate", + "sampleSize", + "volume" + ]; + var bannedkeysSet = new Set(bannedKeys); + var keysInVideoConstraints = Object.keys(videoConstraints); + for (var _i = 0, keysInVideoConstraints_1 = keysInVideoConstraints; _i < keysInVideoConstraints_1.length; _i++) { + var key = keysInVideoConstraints_1[_i]; + if (bannedkeysSet.has(key)) { + logger.logError("".concat(key, " is not supported videoConstaints."), true); + return false; + } + } + return true; + }; + return VideoConstraintsUtil; +}()); +exports.VideoConstraintsUtil = VideoConstraintsUtil; +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/utils.js.map b/src/main/node_modules/html5-qrcode/cjs/utils.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9273fab7961a16c79974b11ea6c72e90a6006a48 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAeA;IAAA;IAqCA,CAAC;IApCiB,kDAA6B,GAA3C,UACI,gBAAuC,EACvC,MAAc;QACd,IAAI,OAAO,gBAAgB,KAAK,QAAQ,EAAE;YACtC,IAAM,sBAAsB,GAAG,OAAO,gBAAgB,CAAC;YACvD,MAAM,CAAC,QAAQ,CACX,iDAAiD;kBAC3C,mCAA4B,sBAAsB,MAAG,EACvC,IAAI,CAAC,CAAC;YAC9B,OAAO,KAAK,CAAC;SAChB;QAGD,IAAM,UAAU,GAAG;YACf,iBAAiB;YACjB,cAAc;YACd,kBAAkB;YAClB,SAAS;YACT,kBAAkB;YAClB,YAAY;YACZ,YAAY;YACZ,QAAQ;SACX,CAAC;QACF,IAAM,aAAa,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;QAC1C,IAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC7D,KAAkB,UAAsB,EAAtB,iDAAsB,EAAtB,oCAAsB,EAAtB,IAAsB,EAAE;YAArC,IAAM,GAAG,+BAAA;YACV,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBACxB,MAAM,CAAC,QAAQ,CACX,UAAG,GAAG,uCAAoC,EACtB,IAAI,CAAC,CAAC;gBAC9B,OAAO,KAAK,CAAC;aAChB;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IACL,2BAAC;AAAD,CAAC,AArCD,IAqCC;AArCY,oDAAoB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/zxing-html5-qrcode-decoder.d.ts b/src/main/node_modules/html5-qrcode/cjs/zxing-html5-qrcode-decoder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..411d37712f3a62354959625cbe40dce24d67f1cc --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/zxing-html5-qrcode-decoder.d.ts @@ -0,0 +1,15 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, Logger, QrcodeDecoderAsync } from "./core"; +export declare class ZXingHtml5QrcodeDecoder implements QrcodeDecoderAsync { + private readonly formatMap; + private readonly reverseFormatMap; + private hints; + private verbose; + private logger; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private decode; + private createReverseFormatMap; + private toHtml5QrcodeSupportedFormats; + private createZXingFormats; + private createDebugData; +} diff --git a/src/main/node_modules/html5-qrcode/cjs/zxing-html5-qrcode-decoder.js b/src/main/node_modules/html5-qrcode/cjs/zxing-html5-qrcode-decoder.js new file mode 100644 index 0000000000000000000000000000000000000000..1bb0e37705162030213e34db44f1c9070bc76e32 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/zxing-html5-qrcode-decoder.js @@ -0,0 +1,109 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ZXingHtml5QrcodeDecoder = void 0; +var ZXing = require("../third_party/zxing-js.umd"); +var core_1 = require("./core"); +var ZXingHtml5QrcodeDecoder = (function () { + function ZXingHtml5QrcodeDecoder(requestedFormats, verbose, logger) { + this.formatMap = new Map([ + [core_1.Html5QrcodeSupportedFormats.QR_CODE, ZXing.BarcodeFormat.QR_CODE], + [core_1.Html5QrcodeSupportedFormats.AZTEC, ZXing.BarcodeFormat.AZTEC], + [core_1.Html5QrcodeSupportedFormats.CODABAR, ZXing.BarcodeFormat.CODABAR], + [core_1.Html5QrcodeSupportedFormats.CODE_39, ZXing.BarcodeFormat.CODE_39], + [core_1.Html5QrcodeSupportedFormats.CODE_93, ZXing.BarcodeFormat.CODE_93], + [ + core_1.Html5QrcodeSupportedFormats.CODE_128, + ZXing.BarcodeFormat.CODE_128 + ], + [ + core_1.Html5QrcodeSupportedFormats.DATA_MATRIX, + ZXing.BarcodeFormat.DATA_MATRIX + ], + [ + core_1.Html5QrcodeSupportedFormats.MAXICODE, + ZXing.BarcodeFormat.MAXICODE + ], + [core_1.Html5QrcodeSupportedFormats.ITF, ZXing.BarcodeFormat.ITF], + [core_1.Html5QrcodeSupportedFormats.EAN_13, ZXing.BarcodeFormat.EAN_13], + [core_1.Html5QrcodeSupportedFormats.EAN_8, ZXing.BarcodeFormat.EAN_8], + [core_1.Html5QrcodeSupportedFormats.PDF_417, ZXing.BarcodeFormat.PDF_417], + [core_1.Html5QrcodeSupportedFormats.RSS_14, ZXing.BarcodeFormat.RSS_14], + [ + core_1.Html5QrcodeSupportedFormats.RSS_EXPANDED, + ZXing.BarcodeFormat.RSS_EXPANDED + ], + [core_1.Html5QrcodeSupportedFormats.UPC_A, ZXing.BarcodeFormat.UPC_A], + [core_1.Html5QrcodeSupportedFormats.UPC_E, ZXing.BarcodeFormat.UPC_E], + [ + core_1.Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, + ZXing.BarcodeFormat.UPC_EAN_EXTENSION + ] + ]); + this.reverseFormatMap = this.createReverseFormatMap(); + if (!ZXing) { + throw "Use html5qrcode.min.js without edit, ZXing not found."; + } + this.verbose = verbose; + this.logger = logger; + var formats = this.createZXingFormats(requestedFormats); + var hints = new Map(); + hints.set(ZXing.DecodeHintType.POSSIBLE_FORMATS, formats); + hints.set(ZXing.DecodeHintType.TRY_HARDER, false); + this.hints = hints; + } + ZXingHtml5QrcodeDecoder.prototype.decodeAsync = function (canvas) { + var _this = this; + return new Promise(function (resolve, reject) { + try { + resolve(_this.decode(canvas)); + } + catch (error) { + reject(error); + } + }); + }; + ZXingHtml5QrcodeDecoder.prototype.decode = function (canvas) { + var zxingDecoder = new ZXing.MultiFormatReader(this.verbose, this.hints); + var luminanceSource = new ZXing.HTMLCanvasElementLuminanceSource(canvas); + var binaryBitmap = new ZXing.BinaryBitmap(new ZXing.HybridBinarizer(luminanceSource)); + var result = zxingDecoder.decode(binaryBitmap); + return { + text: result.text, + format: core_1.QrcodeResultFormat.create(this.toHtml5QrcodeSupportedFormats(result.format)), + debugData: this.createDebugData() + }; + }; + ZXingHtml5QrcodeDecoder.prototype.createReverseFormatMap = function () { + var result = new Map(); + this.formatMap.forEach(function (value, key, _) { + result.set(value, key); + }); + return result; + }; + ZXingHtml5QrcodeDecoder.prototype.toHtml5QrcodeSupportedFormats = function (zxingFormat) { + if (!this.reverseFormatMap.has(zxingFormat)) { + throw "reverseFormatMap doesn't have ".concat(zxingFormat); + } + return this.reverseFormatMap.get(zxingFormat); + }; + ZXingHtml5QrcodeDecoder.prototype.createZXingFormats = function (requestedFormats) { + var zxingFormats = []; + for (var _i = 0, requestedFormats_1 = requestedFormats; _i < requestedFormats_1.length; _i++) { + var requestedFormat = requestedFormats_1[_i]; + if (this.formatMap.has(requestedFormat)) { + zxingFormats.push(this.formatMap.get(requestedFormat)); + } + else { + this.logger.logError("".concat(requestedFormat, " is not supported by") + + "ZXingHtml5QrcodeShim"); + } + } + return zxingFormats; + }; + ZXingHtml5QrcodeDecoder.prototype.createDebugData = function () { + return { decoderName: "zxing-js" }; + }; + return ZXingHtml5QrcodeDecoder; +}()); +exports.ZXingHtml5QrcodeDecoder = ZXingHtml5QrcodeDecoder; +//# sourceMappingURL=zxing-html5-qrcode-decoder.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/cjs/zxing-html5-qrcode-decoder.js.map b/src/main/node_modules/html5-qrcode/cjs/zxing-html5-qrcode-decoder.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e33c888f92857951d2fb6be667dcd0c4d8118522 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/cjs/zxing-html5-qrcode-decoder.js.map @@ -0,0 +1 @@ +{"version":3,"file":"zxing-html5-qrcode-decoder.js","sourceRoot":"","sources":["../../src/zxing-html5-qrcode-decoder.ts"],"names":[],"mappings":";;;AAYA,mDAAqD;AAErD,+BAOgB;AAKhB;IAuCI,iCACI,gBAAoD,EACpD,OAAgB,EAChB,MAAc;QAxCD,cAAS,GACpB,IAAI,GAAG,CAAC;YACN,CAAC,kCAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAE;YACnE,CAAC,kCAA2B,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAE;YAC/D,CAAC,kCAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAE;YACnE,CAAC,kCAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAE;YACnE,CAAC,kCAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAE;YACnE;gBACI,k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AAO,CAClB,UAAC,KAAU,EAAE,GAAgC,EAAE,CAAC;YAChD,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,+DAA6B,GAArC,UAAsC,WAAgB;QAElD,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YACzC,MAAM,wCAAiC,WAAW,CAAE,CAAC;SACxD;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;IACnD,CAAC;IAEO,oDAAkB,GAA1B,UACI,gBAAoD;QAEhD,IAAI,YAAY,GAAG,EAAE,CAAC;QACtB,KAA8B,UAAgB,EAAhB,qCAAgB,EAAhB,8BAAgB,EAAhB,IAAgB,EAAE;YAA3C,IAAM,eAAe,yBAAA;YACtB,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;gBACrC,YAAY,CAAC,IAAI,CACb,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;aAC5C;iBAAM;gBACH,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAG,eAAe,yBAAsB;sBACvD,sBAAsB,CAAC,CAAC;aACjC;SACJ;QACD,OAAO,YAAY,CAAC;IAC5B,CAAC;IAEO,iDAAe,GAAvB;QACI,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;IACvC,CAAC;IACL,8BAAC;AAAD,CAAC,AAhID,IAgIC;AAhIY,0DAAuB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/code-decoder.d.ts b/src/main/node_modules/html5-qrcode/code-decoder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13d5426a74815c3ff33f9221d161b055910a693c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/code-decoder.d.ts @@ -0,0 +1,16 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, Logger, RobustQrcodeDecoderAsync } from "./core"; +export declare class Html5QrcodeShim implements RobustQrcodeDecoderAsync { + private verbose; + private primaryDecoder; + private secondaryDecoder; + private readonly EXECUTIONS_TO_REPORT_PERFORMANCE; + private executions; + private executionResults; + private wasPrimaryDecoderUsedInLastDecode; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, useBarCodeDetectorIfSupported: boolean, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + decodeRobustlyAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private getDecoder; + private possiblyLogPerformance; + possiblyFlushPerformanceReport(): void; +} diff --git a/src/main/node_modules/html5-qrcode/core.d.ts b/src/main/node_modules/html5-qrcode/core.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d0206d4fcf87446a1161cd3b548b3196d9262be --- /dev/null +++ b/src/main/node_modules/html5-qrcode/core.d.ts @@ -0,0 +1,105 @@ +export declare enum Html5QrcodeSupportedFormats { + QR_CODE = 0, + AZTEC = 1, + CODABAR = 2, + CODE_39 = 3, + CODE_93 = 4, + CODE_128 = 5, + DATA_MATRIX = 6, + MAXICODE = 7, + ITF = 8, + EAN_13 = 9, + EAN_8 = 10, + PDF_417 = 11, + RSS_14 = 12, + RSS_EXPANDED = 13, + UPC_A = 14, + UPC_E = 15, + UPC_EAN_EXTENSION = 16 +} +export declare enum DecodedTextType { + UNKNOWN = 0, + URL = 1 +} +export declare function isValidHtml5QrcodeSupportedFormats(format: any): boolean; +export declare enum Html5QrcodeScanType { + SCAN_TYPE_CAMERA = 0, + SCAN_TYPE_FILE = 1 +} +export declare class Html5QrcodeConstants { + static GITHUB_PROJECT_URL: string; + static SCAN_DEFAULT_FPS: number; + static DEFAULT_DISABLE_FLIP: boolean; + static DEFAULT_REMEMBER_LAST_CAMERA_USED: boolean; + static DEFAULT_SUPPORTED_SCAN_TYPE: Html5QrcodeScanType[]; +} +export interface QrDimensions { + width: number; + height: number; +} +export type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; +export interface QrBounds extends QrDimensions { + x: number; + y: number; +} +export declare class QrcodeResultFormat { + readonly format: Html5QrcodeSupportedFormats; + readonly formatName: string; + private constructor(); + toString(): string; + static create(format: Html5QrcodeSupportedFormats): QrcodeResultFormat; +} +export interface QrcodeResultDebugData { + decoderName?: string; +} +export interface QrcodeResult { + text: string; + format?: QrcodeResultFormat; + bounds?: QrBounds; + decodedTextType?: DecodedTextType; + debugData?: QrcodeResultDebugData; +} +export interface Html5QrcodeResult { + decodedText: string; + result: QrcodeResult; +} +export declare class Html5QrcodeResultFactory { + static createFromText(decodedText: string): Html5QrcodeResult; + static createFromQrcodeResult(qrcodeResult: QrcodeResult): Html5QrcodeResult; +} +export declare enum Html5QrcodeErrorTypes { + UNKWOWN_ERROR = 0, + IMPLEMENTATION_ERROR = 1, + NO_CODE_FOUND_ERROR = 2 +} +export interface Html5QrcodeError { + errorMessage: string; + type: Html5QrcodeErrorTypes; +} +export declare class Html5QrcodeErrorFactory { + static createFrom(error: any): Html5QrcodeError; +} +export type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; +export type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; +export interface QrcodeDecoderAsync { + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; +} +export interface RobustQrcodeDecoderAsync extends QrcodeDecoderAsync { + decodeRobustlyAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; +} +export interface Logger { + log(message: string): void; + warn(message: string): void; + logError(message: string, isExperimental?: boolean): void; + logErrors(errors: Array<any>): void; +} +export declare class BaseLoggger implements Logger { + private verbose; + constructor(verbose: boolean); + log(message: string): void; + warn(message: string): void; + logError(message: string, isExperimental?: boolean): void; + logErrors(errors: Array<any>): void; +} +export declare function isNullOrUndefined(obj?: any): boolean; +export declare function clip(value: number, minValue: number, maxValue: number): number; diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/core-impl.d.ts b/src/main/node_modules/html5-qrcode/es2015/camera/core-impl.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ffc8a05e27dd5c815882381cca903fde7ae268db --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/core-impl.d.ts @@ -0,0 +1,7 @@ +import { Camera, CameraRenderingOptions, RenderedCamera, RenderingCallbacks } from "./core"; +export declare class CameraImpl implements Camera { + private readonly mediaStream; + private constructor(); + render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>; + static create(videoConstraints: MediaTrackConstraints): Promise<Camera>; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/core-impl.js b/src/main/node_modules/html5-qrcode/es2015/camera/core-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..afd2d80586acca841f8bf840ca664fab0315f277 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/core-impl.js @@ -0,0 +1,236 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +class AbstractCameraCapability { + constructor(name, track) { + this.name = name; + this.track = track; + } + isSupported() { + if (!this.track.getCapabilities) { + return false; + } + return this.name in this.track.getCapabilities(); + } + apply(value) { + let constraint = {}; + constraint[this.name] = value; + let constraints = { advanced: [constraint] }; + return this.track.applyConstraints(constraints); + } + value() { + let settings = this.track.getSettings(); + if (this.name in settings) { + let settingValue = settings[this.name]; + return settingValue; + } + return null; + } +} +class AbstractRangeCameraCapability extends AbstractCameraCapability { + constructor(name, track) { + super(name, track); + } + min() { + return this.getCapabilities().min; + } + max() { + return this.getCapabilities().max; + } + step() { + return this.getCapabilities().step; + } + apply(value) { + let constraint = {}; + constraint[this.name] = value; + let constraints = { advanced: [constraint] }; + return this.track.applyConstraints(constraints); + } + getCapabilities() { + this.failIfNotSupported(); + let capabilities = this.track.getCapabilities(); + let capability = capabilities[this.name]; + return { + min: capability.min, + max: capability.max, + step: capability.step, + }; + } + failIfNotSupported() { + if (!this.isSupported()) { + throw new Error(`${this.name} capability not supported`); + } + } +} +class ZoomFeatureImpl extends AbstractRangeCameraCapability { + constructor(track) { + super("zoom", track); + } +} +class TorchFeatureImpl extends AbstractCameraCapability { + constructor(track) { + super("torch", track); + } +} +class CameraCapabilitiesImpl { + constructor(track) { + this.track = track; + } + zoomFeature() { + return new ZoomFeatureImpl(this.track); + } + torchFeature() { + return new TorchFeatureImpl(this.track); + } +} +class RenderedCameraImpl { + constructor(parentElement, mediaStream, callbacks) { + this.isClosed = false; + this.parentElement = parentElement; + this.mediaStream = mediaStream; + this.callbacks = callbacks; + this.surface = this.createVideoElement(this.parentElement.clientWidth); + parentElement.append(this.surface); + } + createVideoElement(width) { + const videoElement = document.createElement("video"); + videoElement.style.width = `${width}px`; + videoElement.style.display = "block"; + videoElement.muted = true; + videoElement.setAttribute("muted", "true"); + videoElement.playsInline = true; + return videoElement; + } + setupSurface() { + this.surface.onabort = () => { + throw "RenderedCameraImpl video surface onabort() called"; + }; + this.surface.onerror = () => { + throw "RenderedCameraImpl video surface onerror() called"; + }; + let onVideoStart = () => { + const videoWidth = this.surface.clientWidth; + const videoHeight = this.surface.clientHeight; + this.callbacks.onRenderSurfaceReady(videoWidth, videoHeight); + this.surface.removeEventListener("playing", onVideoStart); + }; + this.surface.addEventListener("playing", onVideoStart); + this.surface.srcObject = this.mediaStream; + this.surface.play(); + } + static create(parentElement, mediaStream, options, callbacks) { + return __awaiter(this, void 0, void 0, function* () { + let renderedCamera = new RenderedCameraImpl(parentElement, mediaStream, callbacks); + if (options.aspectRatio) { + let aspectRatioConstraint = { + aspectRatio: options.aspectRatio + }; + yield renderedCamera.getFirstTrackOrFail().applyConstraints(aspectRatioConstraint); + } + renderedCamera.setupSurface(); + return renderedCamera; + }); + } + failIfClosed() { + if (this.isClosed) { + throw "The RenderedCamera has already been closed."; + } + } + getFirstTrackOrFail() { + this.failIfClosed(); + if (this.mediaStream.getVideoTracks().length === 0) { + throw "No video tracks found"; + } + return this.mediaStream.getVideoTracks()[0]; + } + pause() { + this.failIfClosed(); + this.surface.pause(); + } + resume(onResumeCallback) { + this.failIfClosed(); + let $this = this; + const onVideoResume = () => { + setTimeout(onResumeCallback, 200); + $this.surface.removeEventListener("playing", onVideoResume); + }; + this.surface.addEventListener("playing", onVideoResume); + this.surface.play(); + } + isPaused() { + this.failIfClosed(); + return this.surface.paused; + } + getSurface() { + this.failIfClosed(); + return this.surface; + } + getRunningTrackCapabilities() { + return this.getFirstTrackOrFail().getCapabilities(); + } + getRunningTrackSettings() { + return this.getFirstTrackOrFail().getSettings(); + } + applyVideoConstraints(constraints) { + return __awaiter(this, void 0, void 0, function* () { + if ("aspectRatio" in constraints) { + throw "Changing 'aspectRatio' in run-time is not yet supported."; + } + return this.getFirstTrackOrFail().applyConstraints(constraints); + }); + } + close() { + if (this.isClosed) { + return Promise.resolve(); + } + let $this = this; + return new Promise((resolve, _) => { + let tracks = $this.mediaStream.getVideoTracks(); + const tracksToClose = tracks.length; + var tracksClosed = 0; + $this.mediaStream.getVideoTracks().forEach((videoTrack) => { + $this.mediaStream.removeTrack(videoTrack); + videoTrack.stop(); + ++tracksClosed; + if (tracksClosed >= tracksToClose) { + $this.isClosed = true; + $this.parentElement.removeChild($this.surface); + resolve(); + } + }); + }); + } + getCapabilities() { + return new CameraCapabilitiesImpl(this.getFirstTrackOrFail()); + } +} +export class CameraImpl { + constructor(mediaStream) { + this.mediaStream = mediaStream; + } + render(parentElement, options, callbacks) { + return __awaiter(this, void 0, void 0, function* () { + return RenderedCameraImpl.create(parentElement, this.mediaStream, options, callbacks); + }); + } + static create(videoConstraints) { + return __awaiter(this, void 0, void 0, function* () { + if (!navigator.mediaDevices) { + throw "navigator.mediaDevices not supported"; + } + let constraints = { + audio: false, + video: videoConstraints + }; + let mediaStream = yield navigator.mediaDevices.getUserMedia(constraints); + return new CameraImpl(mediaStream); + }); + } +} +//# sourceMappingURL=core-impl.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/core-impl.js.map b/src/main/node_modules/html5-qrcode/es2015/camera/core-impl.js.map new file mode 100644 index 0000000000000000000000000000000000000000..75ed98f53ee712d63dfd7d5771d6b9bfd24c0cd7 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/core-impl.js.map @@ -0,0 +1 @@ +{"version":3,"file":"core-impl.js","sourceRoot":"","sources":["../../../src/camera/core-impl.ts"],"names":[],"mappings":";;;;;;;;;AA0BA,MAAe,wBAAwB;IAInC,YAAY,IAAY,EAAE,KAAuB;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAEM,WAAW;QAId,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE;YAC7B,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,KAAQ;QACjB,IAAI,UAAU,GAAQ,EAAE,CAAC;QACzB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC9B,IAAI,WAAW,GAAG,EAAE,QAAQ,EAAE,CAAE,UAAU,CAAE,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;IAEM,KAAK;QACR,IAAI,QAAQ,GAAQ,IAAI,CAAC,KAAK,CAAC,WAAW,EAA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CAAC;CAEJ;AAGD,MAAM,OAAO,UAAU;IAGnB,YAAoB,WAAwB;QACxC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAEK,MAAM,CACR,aAA0B,EAC1B,OAA+B,EAC/B,SAA6B;;YAE7B,OAAO,kBAAkB,CAAC,MAAM,CAC5B,aAAa,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAC7D,CAAC;KAAA;IAED,MAAM,CAAO,MAAM,CAAC,gBAAuC;;YAEvD,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE;gBACzB,MAAM,sCAAsC,CAAC;aAChD;YACD,IAAI,WAAW,GAA2B;gBACtC,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,gBAAgB;aAC1B,CAAC;YAEF,IAAI,WAAW,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CACvD,WAAW,CAAC,CAAC;YACjB,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;QACvC,CAAC;KAAA;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/core.d.ts b/src/main/node_modules/html5-qrcode/es2015/camera/core.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..52e27b5012fe7172a5d7b179174774fe206316ae --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/core.d.ts @@ -0,0 +1,41 @@ +export interface CameraDevice { + id: string; + label: string; +} +export interface CameraCapability<T> { + isSupported(): boolean; + apply(value: T): Promise<void>; + value(): T | null; +} +export interface RangeCameraCapability extends CameraCapability<number> { + min(): number; + max(): number; + step(): number; +} +export interface BooleanCameraCapability extends CameraCapability<boolean> { +} +export interface CameraCapabilities { + zoomFeature(): RangeCameraCapability; + torchFeature(): BooleanCameraCapability; +} +export type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; +export interface RenderingCallbacks { + onRenderSurfaceReady: OnRenderSurfaceReady; +} +export interface RenderedCamera { + getSurface(): HTMLVideoElement; + pause(): void; + resume(onResumeCallback: () => void): void; + isPaused(): boolean; + close(): Promise<void>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + applyVideoConstraints(constraints: MediaTrackConstraints): Promise<void>; + getCapabilities(): CameraCapabilities; +} +export interface CameraRenderingOptions { + aspectRatio?: number; +} +export interface Camera { + render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/core.js b/src/main/node_modules/html5-qrcode/es2015/camera/core.js new file mode 100644 index 0000000000000000000000000000000000000000..d59ace34f25a1a21456fcb578fd8d55567d77d96 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/core.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=core.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/core.js.map b/src/main/node_modules/html5-qrcode/es2015/camera/core.js.map new file mode 100644 index 0000000000000000000000000000000000000000..28f32d7a77e4af3d121d2ca609c13019871b22ea --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/core.js.map @@ -0,0 +1 @@ +{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/camera/core.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/factories.d.ts b/src/main/node_modules/html5-qrcode/es2015/camera/factories.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..df98f8ffb0479eb3c807d7e49c6018c3850f8f71 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/factories.d.ts @@ -0,0 +1,6 @@ +import { Camera } from "./core"; +export declare class CameraFactory { + static failIfNotSupported(): Promise<CameraFactory>; + private constructor(); + create(videoConstraints: MediaTrackConstraints): Promise<Camera>; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/factories.js b/src/main/node_modules/html5-qrcode/es2015/camera/factories.js new file mode 100644 index 0000000000000000000000000000000000000000..ff79ee48422f11768b74e69b6f2827b8a269f2c1 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/factories.js @@ -0,0 +1,27 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { CameraImpl } from "./core-impl"; +export class CameraFactory { + static failIfNotSupported() { + return __awaiter(this, void 0, void 0, function* () { + if (!navigator.mediaDevices) { + throw "navigator.mediaDevices not supported"; + } + return new CameraFactory(); + }); + } + constructor() { } + create(videoConstraints) { + return __awaiter(this, void 0, void 0, function* () { + return CameraImpl.create(videoConstraints); + }); + } +} +//# sourceMappingURL=factories.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/factories.js.map b/src/main/node_modules/html5-qrcode/es2015/camera/factories.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b6b440cde047643af5604f788284051a425f58fb --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/factories.js.map @@ -0,0 +1 @@ +{"version":3,"file":"factories.js","sourceRoot":"","sources":["../../../src/camera/factories.ts"],"names":[],"mappings":";;;;;;;;;AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,OAAO,aAAa;IAMf,MAAM,CAAO,kBAAkB;;YAClC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE;gBACzB,MAAM,sCAAsC,CAAC;aAChD;YAED,OAAO,IAAI,aAAa,EAAE,CAAC;QAC/B,CAAC;KAAA;IAED,gBAAqC,CAAC;IAGzB,MAAM,CAAC,gBAAuC;;YAEvD,OAAO,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAC/C,CAAC;KAAA;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/permissions.d.ts b/src/main/node_modules/html5-qrcode/es2015/camera/permissions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4209c552093cc9cc5bf1022bd100a4459b988c38 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/permissions.d.ts @@ -0,0 +1,3 @@ +export declare class CameraPermissions { + static hasPermissions(): Promise<boolean>; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/permissions.js b/src/main/node_modules/html5-qrcode/es2015/camera/permissions.js new file mode 100644 index 0000000000000000000000000000000000000000..1e7e778ab14ecc8df51ba5b7eaf6e0c9582fc2dd --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/permissions.js @@ -0,0 +1,23 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +export class CameraPermissions { + static hasPermissions() { + return __awaiter(this, void 0, void 0, function* () { + let devices = yield navigator.mediaDevices.enumerateDevices(); + for (const device of devices) { + if (device.kind === "videoinput" && device.label) { + return true; + } + } + return false; + }); + } +} +//# sourceMappingURL=permissions.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/permissions.js.map b/src/main/node_modules/html5-qrcode/es2015/camera/permissions.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a7b26f01df7dde94e2b2c4294002e2ad5f66d72c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/permissions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../src/camera/permissions.ts"],"names":[],"mappings":";;;;;;;;;AAYC,MAAM,OAAO,iBAAiB;IAMpB,MAAM,CAAO,cAAc;;YAIhC,IAAI,OAAO,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,gBAAgB,EAAE,CAAC;YAC9D,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;gBAG5B,IAAG,MAAM,CAAC,IAAI,KAAK,YAAY,IAAI,MAAM,CAAC,KAAK,EAAE;oBAC/C,OAAO,IAAI,CAAC;iBACb;aACF;YAED,OAAO,KAAK,CAAC;QACf,CAAC;KAAA;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/retriever.d.ts b/src/main/node_modules/html5-qrcode/es2015/camera/retriever.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0baac120fbc60739f5a0b7b3f59d217b02a41c17 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/retriever.d.ts @@ -0,0 +1,8 @@ +import { CameraDevice } from "./core"; +export declare class CameraRetriever { + static retrieve(): Promise<Array<CameraDevice>>; + private static rejectWithError; + private static isHttpsOrLocalhost; + private static getCamerasFromMediaDevices; + private static getCamerasFromMediaStreamTrack; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/retriever.js b/src/main/node_modules/html5-qrcode/es2015/camera/retriever.js new file mode 100644 index 0000000000000000000000000000000000000000..0112ebb1943c27c185b21f0326014f523dd906d9 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/retriever.js @@ -0,0 +1,80 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { Html5QrcodeStrings } from "../strings"; +export class CameraRetriever { + static retrieve() { + if (navigator.mediaDevices) { + return CameraRetriever.getCamerasFromMediaDevices(); + } + var mst = MediaStreamTrack; + if (MediaStreamTrack && mst.getSources) { + return CameraRetriever.getCamerasFromMediaStreamTrack(); + } + return CameraRetriever.rejectWithError(); + } + static rejectWithError() { + let errorMessage = Html5QrcodeStrings.unableToQuerySupportedDevices(); + if (!CameraRetriever.isHttpsOrLocalhost()) { + errorMessage = Html5QrcodeStrings.insecureContextCameraQueryError(); + } + return Promise.reject(errorMessage); + } + static isHttpsOrLocalhost() { + if (location.protocol === "https:") { + return true; + } + const host = location.host.split(":")[0]; + return host === "127.0.0.1" || host === "localhost"; + } + static getCamerasFromMediaDevices() { + return __awaiter(this, void 0, void 0, function* () { + const closeActiveStreams = (stream) => { + const tracks = stream.getVideoTracks(); + for (const track of tracks) { + track.enabled = false; + track.stop(); + stream.removeTrack(track); + } + }; + let mediaStream = yield navigator.mediaDevices.getUserMedia({ audio: false, video: true }); + let devices = yield navigator.mediaDevices.enumerateDevices(); + let results = []; + for (const device of devices) { + if (device.kind === "videoinput") { + results.push({ + id: device.deviceId, + label: device.label + }); + } + } + closeActiveStreams(mediaStream); + return results; + }); + } + static getCamerasFromMediaStreamTrack() { + return new Promise((resolve, _) => { + const callback = (sourceInfos) => { + const results = []; + for (const sourceInfo of sourceInfos) { + if (sourceInfo.kind === "video") { + results.push({ + id: sourceInfo.id, + label: sourceInfo.label + }); + } + } + resolve(results); + }; + var mst = MediaStreamTrack; + mst.getSources(callback); + }); + } +} +//# sourceMappingURL=retriever.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/camera/retriever.js.map b/src/main/node_modules/html5-qrcode/es2015/camera/retriever.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8ad1186a001a8fbd46bc309373561d031602d0d2 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/camera/retriever.js.map @@ -0,0 +1 @@ +{"version":3,"file":"retriever.js","sourceRoot":"","sources":["../../../src/camera/retriever.ts"],"names":[],"mappings":";;;;;;;;;AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGhD,MAAM,OAAO,eAAe;IAGjB,MAAM,CAAC,QAAQ;QAClB,IAAI,SAAS,CAAC,YAAY,EAAE;YACxB,OAAO,eAAe,CAAC,0BAA0B,EAAE,CAAC;SACvD;QAGD,IAAI,GAAG,GAAQ,gBAAgB,CAAC;QAChC,IAAI,gBAAgB,IAAI,GAAG,CAAC,UAAU,EAAE;YACpC,OAAO,eAAe,CAAC,8BAA8B,EAAE,CAAC;SAC3D;QAED,OAAO,eAAe,CAAC,eAAe,EAAE,CAAC;IAC7C,CAAC;IAEO,MAAM,CAAC,eAAe;QAE1B,IAAI,YAAY,GAAG,kBAAkB,CAAC,6BAA6B,EAAE,CAAC;QACtE,IAAI,CAAC,eAAe,CAAC,kBAAkB,EAAE,EAAE;YACvC,YAAY,GAAG,kBAAkB,CAAC,+BAA+B,EAAE,CAAC;SACvE;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC;IAEO,MAAM,CAAC,kBAAkB;QAC7B,IAAI,QAAQ,CAAC,QAAQ,KAAK,QAAQ,EAAE;YAChC,OAAO,IAAI,CAAC;SACf;QACD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,CAAC;IACxD,CAAC;IAEO,MAAM,CAAO,0BAA0B;;YAE3C,MAAM,kBAAkB,GAAG,CAAC,MAAmB,EAAE,EAAE;gBAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,c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C,CAAA;YAED,IAAI,GAAG,GAAQ,gBAAgB,CAAC;YAChC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/code-decoder.d.ts b/src/main/node_modules/html5-qrcode/es2015/code-decoder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13d5426a74815c3ff33f9221d161b055910a693c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/code-decoder.d.ts @@ -0,0 +1,16 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, Logger, RobustQrcodeDecoderAsync } from "./core"; +export declare class Html5QrcodeShim implements RobustQrcodeDecoderAsync { + private verbose; + private primaryDecoder; + private secondaryDecoder; + private readonly EXECUTIONS_TO_REPORT_PERFORMANCE; + private executions; + private executionResults; + private wasPrimaryDecoderUsedInLastDecode; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, useBarCodeDetectorIfSupported: boolean, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + decodeRobustlyAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private getDecoder; + private possiblyLogPerformance; + possiblyFlushPerformanceReport(): void; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/code-decoder.js b/src/main/node_modules/html5-qrcode/es2015/code-decoder.js new file mode 100644 index 0000000000000000000000000000000000000000..4567dc60124ab63c7be683005f922f49c65c96cc --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/code-decoder.js @@ -0,0 +1,90 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { ZXingHtml5QrcodeDecoder } from "./zxing-html5-qrcode-decoder"; +import { BarcodeDetectorDelegate } from "./native-bar-code-detector"; +export class Html5QrcodeShim { + constructor(requestedFormats, useBarCodeDetectorIfSupported, verbose, logger) { + this.EXECUTIONS_TO_REPORT_PERFORMANCE = 100; + this.executions = 0; + this.executionResults = []; + this.wasPrimaryDecoderUsedInLastDecode = false; + this.verbose = verbose; + if (useBarCodeDetectorIfSupported + && BarcodeDetectorDelegate.isSupported()) { + this.primaryDecoder = new BarcodeDetectorDelegate(requestedFormats, verbose, logger); + this.secondaryDecoder = new ZXingHtml5QrcodeDecoder(requestedFormats, verbose, logger); + } + else { + this.primaryDecoder = new ZXingHtml5QrcodeDecoder(requestedFormats, verbose, logger); + } + } + decodeAsync(canvas) { + return __awaiter(this, void 0, void 0, function* () { + let startTime = performance.now(); + try { + return yield this.getDecoder().decodeAsync(canvas); + } + finally { + this.possiblyLogPerformance(startTime); + } + }); + } + decodeRobustlyAsync(canvas) { + return __awaiter(this, void 0, void 0, function* () { + let startTime = performance.now(); + try { + return yield this.primaryDecoder.decodeAsync(canvas); + } + catch (error) { + if (this.secondaryDecoder) { + return this.secondaryDecoder.decodeAsync(canvas); + } + throw error; + } + finally { + this.possiblyLogPerformance(startTime); + } + }); + } + getDecoder() { + if (!this.secondaryDecoder) { + return this.primaryDecoder; + } + if (this.wasPrimaryDecoderUsedInLastDecode === false) { + this.wasPrimaryDecoderUsedInLastDecode = true; + return this.primaryDecoder; + } + this.wasPrimaryDecoderUsedInLastDecode = false; + return this.secondaryDecoder; + } + possiblyLogPerformance(startTime) { + if (!this.verbose) { + return; + } + let executionTime = performance.now() - startTime; + this.executionResults.push(executionTime); + this.executions++; + this.possiblyFlushPerformanceReport(); + } + possiblyFlushPerformanceReport() { + if (this.executions < this.EXECUTIONS_TO_REPORT_PERFORMANCE) { + return; + } + let sum = 0; + for (let executionTime of this.executionResults) { + sum += executionTime; + } + let mean = sum / this.executionResults.length; + console.log(`${mean} ms for ${this.executionResults.length} last runs.`); + this.executions = 0; + this.executionResults = []; + } +} +//# sourceMappingURL=code-decoder.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/code-decoder.js.map b/src/main/node_modules/html5-qrcode/es2015/code-decoder.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a9a094715460a47b2811090e0dd1ebb03997494d --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/code-decoder.js.map @@ -0,0 +1 @@ +{"version":3,"file":"code-decoder.js","sourceRoot":"","sources":["../../src/code-decoder.ts"],"names":[],"mappings":";;;;;;;;;AAkBA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAOrE,MAAM,OAAO,eAAe;IAWxB,YACI,gBAAoD,EACpD,6BAAsC,EACtC,OAAgB,EAChB,MAAc;QATD,qCAAgC,GAAG,GAAG,CAAC;QAChD,eAAU,GAAW,CAAC,CAAC;QACvB,qBAAgB,GAAkB,EAAE,CAAC;QACrC,sCAAiC,GAAG,KAAK,CAAC;QAO9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAGvB,IAAI,6BAA6B;eACtB,uBAAuB,CAAC,WAAW,EAAE,EAAE;YAC9C,IAAI,CAAC,cAAc,GAAG,IAAI,uBAAuB,CAC7C,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAIvC,IAAI,CAAC,gBAAgB,GAAG,IAAI,uBAAuB,CAC/C,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SAC1C;aAAM;YACH,IAAI,CAAC,cAAc,GAAG,IAAI,uBAAuB,CAC7C,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SAC1C;IACL,CAAC;IAEK,WAAW,CAAC,MAAyB;;YACvC,IAAI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AClB,IAAI,CAAC,8BAA8B,EAAE,CAAC;IAC1C,CAAC;IAKD,8BAA8B;QAC1B,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,gCAAgC,EAAE;YACzD,OAAO;SACV;QAED,IAAI,GAAG,GAAU,CAAC,CAAC;QACnB,KAAK,IAAI,aAAa,IAAI,IAAI,CAAC,gBAAgB,EAAE;YAC7C,GAAG,IAAI,aAAa,CAAC;SACxB;QACD,IAAI,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC;QAE9C,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,WAAW,IAAI,CAAC,gBAAgB,CAAC,MAAM,aAAa,CAAC,CAAC;QACzE,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC/B,CAAC;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/core.d.ts b/src/main/node_modules/html5-qrcode/es2015/core.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d0206d4fcf87446a1161cd3b548b3196d9262be --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/core.d.ts @@ -0,0 +1,105 @@ +export declare enum Html5QrcodeSupportedFormats { + QR_CODE = 0, + AZTEC = 1, + CODABAR = 2, + CODE_39 = 3, + CODE_93 = 4, + CODE_128 = 5, + DATA_MATRIX = 6, + MAXICODE = 7, + ITF = 8, + EAN_13 = 9, + EAN_8 = 10, + PDF_417 = 11, + RSS_14 = 12, + RSS_EXPANDED = 13, + UPC_A = 14, + UPC_E = 15, + UPC_EAN_EXTENSION = 16 +} +export declare enum DecodedTextType { + UNKNOWN = 0, + URL = 1 +} +export declare function isValidHtml5QrcodeSupportedFormats(format: any): boolean; +export declare enum Html5QrcodeScanType { + SCAN_TYPE_CAMERA = 0, + SCAN_TYPE_FILE = 1 +} +export declare class Html5QrcodeConstants { + static GITHUB_PROJECT_URL: string; + static SCAN_DEFAULT_FPS: number; + static DEFAULT_DISABLE_FLIP: boolean; + static DEFAULT_REMEMBER_LAST_CAMERA_USED: boolean; + static DEFAULT_SUPPORTED_SCAN_TYPE: Html5QrcodeScanType[]; +} +export interface QrDimensions { + width: number; + height: number; +} +export type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; +export interface QrBounds extends QrDimensions { + x: number; + y: number; +} +export declare class QrcodeResultFormat { + readonly format: Html5QrcodeSupportedFormats; + readonly formatName: string; + private constructor(); + toString(): string; + static create(format: Html5QrcodeSupportedFormats): QrcodeResultFormat; +} +export interface QrcodeResultDebugData { + decoderName?: string; +} +export interface QrcodeResult { + text: string; + format?: QrcodeResultFormat; + bounds?: QrBounds; + decodedTextType?: DecodedTextType; + debugData?: QrcodeResultDebugData; +} +export interface Html5QrcodeResult { + decodedText: string; + result: QrcodeResult; +} +export declare class Html5QrcodeResultFactory { + static createFromText(decodedText: string): Html5QrcodeResult; + static createFromQrcodeResult(qrcodeResult: QrcodeResult): Html5QrcodeResult; +} +export declare enum Html5QrcodeErrorTypes { + UNKWOWN_ERROR = 0, + IMPLEMENTATION_ERROR = 1, + NO_CODE_FOUND_ERROR = 2 +} +export interface Html5QrcodeError { + errorMessage: string; + type: Html5QrcodeErrorTypes; +} +export declare class Html5QrcodeErrorFactory { + static createFrom(error: any): Html5QrcodeError; +} +export type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; +export type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; +export interface QrcodeDecoderAsync { + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; +} +export interface RobustQrcodeDecoderAsync extends QrcodeDecoderAsync { + decodeRobustlyAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; +} +export interface Logger { + log(message: string): void; + warn(message: string): void; + logError(message: string, isExperimental?: boolean): void; + logErrors(errors: Array<any>): void; +} +export declare class BaseLoggger implements Logger { + private verbose; + constructor(verbose: boolean); + log(message: string): void; + warn(message: string): void; + logError(message: string, isExperimental?: boolean): void; + logErrors(errors: Array<any>): void; +} +export declare function isNullOrUndefined(obj?: any): boolean; +export declare function clip(value: number, minValue: number, maxValue: number): number; diff --git a/src/main/node_modules/html5-qrcode/es2015/core.js b/src/main/node_modules/html5-qrcode/es2015/core.js new file mode 100644 index 0000000000000000000000000000000000000000..769580ee628153a7c8bf95001594b4654ca3edce --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/core.js @@ -0,0 +1,149 @@ +export var Html5QrcodeSupportedFormats; +(function (Html5QrcodeSupportedFormats) { + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["QR_CODE"] = 0] = "QR_CODE"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["AZTEC"] = 1] = "AZTEC"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["CODABAR"] = 2] = "CODABAR"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["CODE_39"] = 3] = "CODE_39"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["CODE_93"] = 4] = "CODE_93"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["CODE_128"] = 5] = "CODE_128"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["DATA_MATRIX"] = 6] = "DATA_MATRIX"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["MAXICODE"] = 7] = "MAXICODE"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["ITF"] = 8] = "ITF"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["EAN_13"] = 9] = "EAN_13"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["EAN_8"] = 10] = "EAN_8"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["PDF_417"] = 11] = "PDF_417"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["RSS_14"] = 12] = "RSS_14"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["RSS_EXPANDED"] = 13] = "RSS_EXPANDED"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["UPC_A"] = 14] = "UPC_A"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["UPC_E"] = 15] = "UPC_E"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["UPC_EAN_EXTENSION"] = 16] = "UPC_EAN_EXTENSION"; +})(Html5QrcodeSupportedFormats || (Html5QrcodeSupportedFormats = {})); +const html5QrcodeSupportedFormatsTextMap = new Map([ + [Html5QrcodeSupportedFormats.QR_CODE, "QR_CODE"], + [Html5QrcodeSupportedFormats.AZTEC, "AZTEC"], + [Html5QrcodeSupportedFormats.CODABAR, "CODABAR"], + [Html5QrcodeSupportedFormats.CODE_39, "CODE_39"], + [Html5QrcodeSupportedFormats.CODE_93, "CODE_93"], + [Html5QrcodeSupportedFormats.CODE_128, "CODE_128"], + [Html5QrcodeSupportedFormats.DATA_MATRIX, "DATA_MATRIX"], + [Html5QrcodeSupportedFormats.MAXICODE, "MAXICODE"], + [Html5QrcodeSupportedFormats.ITF, "ITF"], + [Html5QrcodeSupportedFormats.EAN_13, "EAN_13"], + [Html5QrcodeSupportedFormats.EAN_8, "EAN_8"], + [Html5QrcodeSupportedFormats.PDF_417, "PDF_417"], + [Html5QrcodeSupportedFormats.RSS_14, "RSS_14"], + [Html5QrcodeSupportedFormats.RSS_EXPANDED, "RSS_EXPANDED"], + [Html5QrcodeSupportedFormats.UPC_A, "UPC_A"], + [Html5QrcodeSupportedFormats.UPC_E, "UPC_E"], + [Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, "UPC_EAN_EXTENSION"] +]); +export var DecodedTextType; +(function (DecodedTextType) { + DecodedTextType[DecodedTextType["UNKNOWN"] = 0] = "UNKNOWN"; + DecodedTextType[DecodedTextType["URL"] = 1] = "URL"; +})(DecodedTextType || (DecodedTextType = {})); +export function isValidHtml5QrcodeSupportedFormats(format) { + return Object.values(Html5QrcodeSupportedFormats).includes(format); +} +export var Html5QrcodeScanType; +(function (Html5QrcodeScanType) { + Html5QrcodeScanType[Html5QrcodeScanType["SCAN_TYPE_CAMERA"] = 0] = "SCAN_TYPE_CAMERA"; + Html5QrcodeScanType[Html5QrcodeScanType["SCAN_TYPE_FILE"] = 1] = "SCAN_TYPE_FILE"; +})(Html5QrcodeScanType || (Html5QrcodeScanType = {})); +export class Html5QrcodeConstants { +} +Html5QrcodeConstants.GITHUB_PROJECT_URL = "https://github.com/mebjas/html5-qrcode"; +Html5QrcodeConstants.SCAN_DEFAULT_FPS = 2; +Html5QrcodeConstants.DEFAULT_DISABLE_FLIP = false; +Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED = true; +Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE = [ + Html5QrcodeScanType.SCAN_TYPE_CAMERA, + Html5QrcodeScanType.SCAN_TYPE_FILE +]; +export class QrcodeResultFormat { + constructor(format, formatName) { + this.format = format; + this.formatName = formatName; + } + toString() { + return this.formatName; + } + static create(format) { + if (!html5QrcodeSupportedFormatsTextMap.has(format)) { + throw `${format} not in html5QrcodeSupportedFormatsTextMap`; + } + return new QrcodeResultFormat(format, html5QrcodeSupportedFormatsTextMap.get(format)); + } +} +export class Html5QrcodeResultFactory { + static createFromText(decodedText) { + let qrcodeResult = { + text: decodedText + }; + return { + decodedText: decodedText, + result: qrcodeResult + }; + } + static createFromQrcodeResult(qrcodeResult) { + return { + decodedText: qrcodeResult.text, + result: qrcodeResult + }; + } +} +export var Html5QrcodeErrorTypes; +(function (Html5QrcodeErrorTypes) { + Html5QrcodeErrorTypes[Html5QrcodeErrorTypes["UNKWOWN_ERROR"] = 0] = "UNKWOWN_ERROR"; + Html5QrcodeErrorTypes[Html5QrcodeErrorTypes["IMPLEMENTATION_ERROR"] = 1] = "IMPLEMENTATION_ERROR"; + Html5QrcodeErrorTypes[Html5QrcodeErrorTypes["NO_CODE_FOUND_ERROR"] = 2] = "NO_CODE_FOUND_ERROR"; +})(Html5QrcodeErrorTypes || (Html5QrcodeErrorTypes = {})); +export class Html5QrcodeErrorFactory { + static createFrom(error) { + return { + errorMessage: error, + type: Html5QrcodeErrorTypes.UNKWOWN_ERROR + }; + } +} +export class BaseLoggger { + constructor(verbose) { + this.verbose = verbose; + } + log(message) { + if (this.verbose) { + console.log(message); + } + } + warn(message) { + if (this.verbose) { + console.warn(message); + } + } + logError(message, isExperimental) { + if (this.verbose || isExperimental === true) { + console.error(message); + } + } + logErrors(errors) { + if (errors.length === 0) { + throw "Logger#logError called without arguments"; + } + if (this.verbose) { + console.error(errors); + } + } +} +export function isNullOrUndefined(obj) { + return (typeof obj === "undefined") || obj === null; +} +export function clip(value, minValue, maxValue) { + if (value > maxValue) { + return maxValue; + } + if (value < minValue) { + return minValue; + } + return value; +} +//# sourceMappingURL=core.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/core.js.map b/src/main/node_modules/html5-qrcode/es2015/core.js.map new file mode 100644 index 0000000000000000000000000000000000000000..61321cc8aa895fec315c186362bc7238fc3dd4e9 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/core.js.map @@ -0,0 +1 @@ +{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAaA,MAAM,CAAN,IAAY,2BAkBX;AAlBD,WAAY,2BAA2B;IACnC,mFAAW,CAAA;IACX,+EAAK,CAAA;IACL,mFAAO,CAAA;IACP,mFAAO,CAAA;IACP,mFAAO,CAAA;IACP,qFAAQ,CAAA;IACR,2FAAW,CAAA;IACX,qFAAQ,CAAA;IACR,2EAAG,CAAA;IACH,iFAAM,CAAA;IACN,gFAAK,CAAA;IACL,oFAAO,CAAA;IACP,kFAAM,CAAA;IACN,8FAAY,CAAA;IACZ,gFAAK,CAAA;IACL,gFAAK,CAAA;IACL,wGAAiB,CAAA;AACrB,CAAC,EAlBW,2BAA2B,KAA3B,2BAA2B,QAkBtC;AAGD,MAAM,kC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AClB,OAAO,QAAQ,CAAC;KACnB;IACD,IAAI,KAAK,GAAG,QAAQ,EAAE;QAClB,OAAO,QAAQ,CAAC;KACnB;IAED,OAAO,KAAK,CAAC;AACjB,CAAC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/experimental-features.d.ts b/src/main/node_modules/html5-qrcode/es2015/experimental-features.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0413abebd02d9788902f9ad47e60d2673507c5fe --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/experimental-features.d.ts @@ -0,0 +1,3 @@ +export interface ExperimentalFeaturesConfig { + useBarCodeDetectorIfSupported?: boolean | undefined; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/experimental-features.js b/src/main/node_modules/html5-qrcode/es2015/experimental-features.js new file mode 100644 index 0000000000000000000000000000000000000000..ab918ba3d46babea15495f1c1ac8ccabc46c580d --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/experimental-features.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=experimental-features.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/experimental-features.js.map b/src/main/node_modules/html5-qrcode/es2015/experimental-features.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8b8b9dd178d10babd1110d7f0ea70f9b1c95e641 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/experimental-features.js.map @@ -0,0 +1 @@ +{"version":3,"file":"experimental-features.js","sourceRoot":"","sources":["../../src/experimental-features.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/html5-qrcode-scanner.d.ts b/src/main/node_modules/html5-qrcode/es2015/html5-qrcode-scanner.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..417175bc07418ec36023c076274aef557b25f42b --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/html5-qrcode-scanner.d.ts @@ -0,0 +1,67 @@ +import { Html5QrcodeScanType, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; +import { Html5QrcodeConfigs, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; +import { Html5QrcodeScannerState } from "./state-manager"; +export interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { + rememberLastUsedCamera?: boolean | undefined; + supportedScanTypes?: Array<Html5QrcodeScanType> | []; + showTorchButtonIfSupported?: boolean | undefined; + showZoomSliderIfSupported?: boolean | undefined; + defaultZoomValueIfSupported?: number | undefined; +} +export declare class Html5QrcodeScanner { + private elementId; + private config; + private verbose; + private currentScanType; + private sectionSwapAllowed; + private persistedDataManager; + private scanTypeSelector; + private logger; + private html5Qrcode; + private qrCodeSuccessCallback; + private qrCodeErrorCallback; + private lastMatchFound; + private cameraScanImage; + private fileScanImage; + private fileSelectionUi; + constructor(elementId: string, config: Html5QrcodeScannerConfig | undefined, verbose: boolean | undefined); + render(qrCodeSuccessCallback: QrcodeSuccessCallback, qrCodeErrorCallback: QrcodeErrorCallback | undefined): void; + pause(shouldPauseVideo?: boolean): void; + resume(): void; + getState(): Html5QrcodeScannerState; + clear(): Promise<void>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + applyVideoConstraints(videoConstaints: MediaTrackConstraints): Promise<void>; + private getHtml5QrcodeOrFail; + private createConfig; + private createBasicLayout; + private resetBasicLayout; + private setupInitialDashboard; + private createHeader; + private createSection; + private createCameraListUi; + private createPermissionButton; + private createPermissionsUi; + private createSectionControlPanel; + private renderFileScanUi; + private renderCameraSelection; + private createSectionSwap; + private startCameraScanIfPermissionExistsOnSwap; + private resetHeaderMessage; + private setHeaderMessage; + private showHideScanTypeSwapLink; + private insertCameraScanImageToScanRegion; + private insertFileScanImageToScanRegion; + private clearScanRegion; + private getDashboardSectionId; + private getDashboardSectionCameraScanRegionId; + private getDashboardSectionSwapLinkId; + private getScanRegionId; + private getDashboardId; + private getHeaderMessageContainerId; + private getCameraPermissionButtonId; + private getCameraScanRegion; + private getDashboardSectionSwapLink; + private getHeaderMessageDiv; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/html5-qrcode-scanner.js b/src/main/node_modules/html5-qrcode/es2015/html5-qrcode-scanner.js new file mode 100644 index 0000000000000000000000000000000000000000..81acc116b51c689c9887a8e327e9297a26343085 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/html5-qrcode-scanner.js @@ -0,0 +1,652 @@ +import { Html5QrcodeConstants, Html5QrcodeScanType, Html5QrcodeErrorFactory, BaseLoggger, isNullOrUndefined, clip, } from "./core"; +import { Html5Qrcode, } from "./html5-qrcode"; +import { Html5QrcodeScannerStrings, } from "./strings"; +import { ASSET_FILE_SCAN, ASSET_CAMERA_SCAN, } from "./image-assets"; +import { PersistedDataManager } from "./storage"; +import { LibraryInfoContainer } from "./ui"; +import { CameraPermissions } from "./camera/permissions"; +import { ScanTypeSelector } from "./ui/scanner/scan-type-selector"; +import { TorchButton } from "./ui/scanner/torch-button"; +import { FileSelectionUi } from "./ui/scanner/file-selection-ui"; +import { BaseUiElementFactory, PublicUiElementIdAndClasses } from "./ui/scanner/base"; +import { CameraSelectionUi } from "./ui/scanner/camera-selection-ui"; +import { CameraZoomUi } from "./ui/scanner/camera-zoom-ui"; +var Html5QrcodeScannerStatus; +(function (Html5QrcodeScannerStatus) { + Html5QrcodeScannerStatus[Html5QrcodeScannerStatus["STATUS_DEFAULT"] = 0] = "STATUS_DEFAULT"; + Html5QrcodeScannerStatus[Html5QrcodeScannerStatus["STATUS_SUCCESS"] = 1] = "STATUS_SUCCESS"; + Html5QrcodeScannerStatus[Html5QrcodeScannerStatus["STATUS_WARNING"] = 2] = "STATUS_WARNING"; + Html5QrcodeScannerStatus[Html5QrcodeScannerStatus["STATUS_REQUESTING_PERMISSION"] = 3] = "STATUS_REQUESTING_PERMISSION"; +})(Html5QrcodeScannerStatus || (Html5QrcodeScannerStatus = {})); +function toHtml5QrcodeCameraScanConfig(config) { + return { + fps: config.fps, + qrbox: config.qrbox, + aspectRatio: config.aspectRatio, + disableFlip: config.disableFlip, + videoConstraints: config.videoConstraints + }; +} +function toHtml5QrcodeFullConfig(config, verbose) { + return { + formatsToSupport: config.formatsToSupport, + useBarCodeDetectorIfSupported: config.useBarCodeDetectorIfSupported, + experimentalFeatures: config.experimentalFeatures, + verbose: verbose + }; +} +export class Html5QrcodeScanner { + constructor(elementId, config, verbose) { + this.lastMatchFound = null; + this.cameraScanImage = null; + this.fileScanImage = null; + this.fileSelectionUi = null; + this.elementId = elementId; + this.config = this.createConfig(config); + this.verbose = verbose === true; + if (!document.getElementById(elementId)) { + throw `HTML Element with id=${elementId} not found`; + } + this.scanTypeSelector = new ScanTypeSelector(this.config.supportedScanTypes); + this.currentScanType = this.scanTypeSelector.getDefaultScanType(); + this.sectionSwapAllowed = true; + this.logger = new BaseLoggger(this.verbose); + this.persistedDataManager = new PersistedDataManager(); + if (config.rememberLastUsedCamera !== true) { + this.persistedDataManager.reset(); + } + } + render(qrCodeSuccessCallback, qrCodeErrorCallback) { + this.lastMatchFound = null; + this.qrCodeSuccessCallback + = (decodedText, result) => { + if (qrCodeSuccessCallback) { + qrCodeSuccessCallback(decodedText, result); + } + else { + if (this.lastMatchFound === decodedText) { + return; + } + this.lastMatchFound = decodedText; + this.setHeaderMessage(Html5QrcodeScannerStrings.lastMatch(decodedText), Html5QrcodeScannerStatus.STATUS_SUCCESS); + } + }; + this.qrCodeErrorCallback = + (errorMessage, error) => { + if (qrCodeErrorCallback) { + qrCodeErrorCallback(errorMessage, error); + } + }; + const container = document.getElementById(this.elementId); + if (!container) { + throw `HTML Element with id=${this.elementId} not found`; + } + container.innerHTML = ""; + this.createBasicLayout(container); + this.html5Qrcode = new Html5Qrcode(this.getScanRegionId(), toHtml5QrcodeFullConfig(this.config, this.verbose)); + } + pause(shouldPauseVideo) { + if (isNullOrUndefined(shouldPauseVideo) || shouldPauseVideo !== true) { + shouldPauseVideo = false; + } + this.getHtml5QrcodeOrFail().pause(shouldPauseVideo); + } + resume() { + this.getHtml5QrcodeOrFail().resume(); + } + getState() { + return this.getHtml5QrcodeOrFail().getState(); + } + clear() { + const emptyHtmlContainer = () => { + const mainContainer = document.getElementById(this.elementId); + if (mainContainer) { + mainContainer.innerHTML = ""; + this.resetBasicLayout(mainContainer); + } + }; + if (this.html5Qrcode) { + return new Promise((resolve, reject) => { + if (!this.html5Qrcode) { + resolve(); + return; + } + if (this.html5Qrcode.isScanning) { + this.html5Qrcode.stop().then((_) => { + if (!this.html5Qrcode) { + resolve(); + return; + } + this.html5Qrcode.clear(); + emptyHtmlContainer(); + resolve(); + }).catch((error) => { + if (this.verbose) { + this.logger.logError("Unable to stop qrcode scanner", error); + } + reject(error); + }); + } + else { + this.html5Qrcode.clear(); + emptyHtmlContainer(); + resolve(); + } + }); + } + return Promise.resolve(); + } + getRunningTrackCapabilities() { + return this.getHtml5QrcodeOrFail().getRunningTrackCapabilities(); + } + getRunningTrackSettings() { + return this.getHtml5QrcodeOrFail().getRunningTrackSettings(); + } + applyVideoConstraints(videoConstaints) { + return this.getHtml5QrcodeOrFail().applyVideoConstraints(videoConstaints); + } + getHtml5QrcodeOrFail() { + if (!this.html5Qrcode) { + throw "Code scanner not initialized."; + } + return this.html5Qrcode; + } + createConfig(config) { + if (config) { + if (!config.fps) { + config.fps = Html5QrcodeConstants.SCAN_DEFAULT_FPS; + } + if (config.rememberLastUsedCamera !== (!Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED)) { + config.rememberLastUsedCamera + = Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED; + } + if (!config.supportedScanTypes) { + config.supportedScanTypes + = Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE; + } + return config; + } + return { + fps: Html5QrcodeConstants.SCAN_DEFAULT_FPS, + rememberLastUsedCamera: Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED, + supportedScanTypes: Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE + }; + } + createBasicLayout(parent) { + parent.style.position = "relative"; + parent.style.padding = "0px"; + parent.style.border = "1px solid silver"; + this.createHeader(parent); + const qrCodeScanRegion = document.createElement("div"); + const scanRegionId = this.getScanRegionId(); + qrCodeScanRegion.id = scanRegionId; + qrCodeScanRegion.style.width = "100%"; + qrCodeScanRegion.style.minHeight = "100px"; + qrCodeScanRegion.style.textAlign = "center"; + parent.appendChild(qrCodeScanRegion); + if (ScanTypeSelector.isCameraScanType(this.currentScanType)) { + this.insertCameraScanImageToScanRegion(); + } + else { + this.insertFileScanImageToScanRegion(); + } + const qrCodeDashboard = document.createElement("div"); + const dashboardId = this.getDashboardId(); + qrCodeDashboard.id = dashboardId; + qrCodeDashboard.style.width = "100%"; + parent.appendChild(qrCodeDashboard); + this.setupInitialDashboard(qrCodeDashboard); + } + resetBasicLayout(mainContainer) { + mainContainer.style.border = "none"; + } + setupInitialDashboard(dashboard) { + this.createSection(dashboard); + this.createSectionControlPanel(); + if (this.scanTypeSelector.hasMoreThanOneScanType()) { + this.createSectionSwap(); + } + } + createHeader(dashboard) { + const header = document.createElement("div"); + header.style.textAlign = "left"; + header.style.margin = "0px"; + dashboard.appendChild(header); + let libraryInfo = new LibraryInfoContainer(); + libraryInfo.renderInto(header); + const headerMessageContainer = document.createElement("div"); + headerMessageContainer.id = this.getHeaderMessageContainerId(); + headerMessageContainer.style.display = "none"; + headerMessageContainer.style.textAlign = "center"; + headerMessageContainer.style.fontSize = "14px"; + headerMessageContainer.style.padding = "2px 10px"; + headerMessageContainer.style.margin = "4px"; + headerMessageContainer.style.borderTop = "1px solid #f6f6f6"; + header.appendChild(headerMessageContainer); + } + createSection(dashboard) { + const section = document.createElement("div"); + section.id = this.getDashboardSectionId(); + section.style.width = "100%"; + section.style.padding = "10px 0px 10px 0px"; + section.style.textAlign = "left"; + dashboard.appendChild(section); + } + createCameraListUi(scpCameraScanRegion, requestPermissionContainer, requestPermissionButton) { + const $this = this; + $this.showHideScanTypeSwapLink(false); + $this.setHeaderMessage(Html5QrcodeScannerStrings.cameraPermissionRequesting()); + const createPermissionButtonIfNotExists = () => { + if (!requestPermissionButton) { + $this.createPermissionButton(scpCameraScanRegion, requestPermissionContainer); + } + }; + Html5Qrcode.getCameras().then((cameras) => { + $this.persistedDataManager.setHasPermission(true); + $this.showHideScanTypeSwapLink(true); + $this.resetHeaderMessage(); + if (cameras && cameras.length > 0) { + scpCameraScanRegion.removeChild(requestPermissionContainer); + $this.renderCameraSelection(cameras); + } + else { + $this.setHeaderMessage(Html5QrcodeScannerStrings.noCameraFound(), Html5QrcodeScannerStatus.STATUS_WARNING); + createPermissionButtonIfNotExists(); + } + }).catch((error) => { + $this.persistedDataManager.setHasPermission(false); + if (requestPermissionButton) { + requestPermissionButton.disabled = false; + } + else { + createPermissionButtonIfNotExists(); + } + $this.setHeaderMessage(error, Html5QrcodeScannerStatus.STATUS_WARNING); + $this.showHideScanTypeSwapLink(true); + }); + } + createPermissionButton(scpCameraScanRegion, requestPermissionContainer) { + const $this = this; + const requestPermissionButton = BaseUiElementFactory + .createElement("button", this.getCameraPermissionButtonId()); + requestPermissionButton.innerText + = Html5QrcodeScannerStrings.cameraPermissionTitle(); + requestPermissionButton.addEventListener("click", function () { + requestPermissionButton.disabled = true; + $this.createCameraListUi(scpCameraScanRegion, requestPermissionContainer, requestPermissionButton); + }); + requestPermissionContainer.appendChild(requestPermissionButton); + } + createPermissionsUi(scpCameraScanRegion, requestPermissionContainer) { + const $this = this; + if (ScanTypeSelector.isCameraScanType(this.currentScanType) + && this.persistedDataManager.hasCameraPermissions()) { + CameraPermissions.hasPermissions().then((hasPermissions) => { + if (hasPermissions) { + $this.createCameraListUi(scpCameraScanRegion, requestPermissionContainer); + } + else { + $this.persistedDataManager.setHasPermission(false); + $this.createPermissionButton(scpCameraScanRegion, requestPermissionContainer); + } + }).catch((_) => { + $this.persistedDataManager.setHasPermission(false); + $this.createPermissionButton(scpCameraScanRegion, requestPermissionContainer); + }); + return; + } + this.createPermissionButton(scpCameraScanRegion, requestPermissionContainer); + } + createSectionControlPanel() { + const section = document.getElementById(this.getDashboardSectionId()); + const sectionControlPanel = document.createElement("div"); + section.appendChild(sectionControlPanel); + const scpCameraScanRegion = document.createElement("div"); + scpCameraScanRegion.id = this.getDashboardSectionCameraScanRegionId(); + scpCameraScanRegion.style.display + = ScanTypeSelector.isCameraScanType(this.currentScanType) + ? "block" : "none"; + sectionControlPanel.appendChild(scpCameraScanRegion); + const requestPermissionContainer = document.createElement("div"); + requestPermissionContainer.style.textAlign = "center"; + scpCameraScanRegion.appendChild(requestPermissionContainer); + if (this.scanTypeSelector.isCameraScanRequired()) { + this.createPermissionsUi(scpCameraScanRegion, requestPermissionContainer); + } + this.renderFileScanUi(sectionControlPanel); + } + renderFileScanUi(parent) { + let showOnRender = ScanTypeSelector.isFileScanType(this.currentScanType); + const $this = this; + let onFileSelected = (file) => { + if (!$this.html5Qrcode) { + throw "html5Qrcode not defined"; + } + if (!ScanTypeSelector.isFileScanType($this.currentScanType)) { + return; + } + $this.setHeaderMessage(Html5QrcodeScannerStrings.loadingImage()); + $this.html5Qrcode.scanFileV2(file, true) + .then((html5qrcodeResult) => { + $this.resetHeaderMessage(); + $this.qrCodeSuccessCallback(html5qrcodeResult.decodedText, html5qrcodeResult); + }) + .catch((error) => { + $this.setHeaderMessage(error, Html5QrcodeScannerStatus.STATUS_WARNING); + $this.qrCodeErrorCallback(error, Html5QrcodeErrorFactory.createFrom(error)); + }); + }; + this.fileSelectionUi = FileSelectionUi.create(parent, showOnRender, onFileSelected); + } + renderCameraSelection(cameras) { + const $this = this; + const scpCameraScanRegion = document.getElementById(this.getDashboardSectionCameraScanRegionId()); + scpCameraScanRegion.style.textAlign = "center"; + let cameraZoomUi = CameraZoomUi.create(scpCameraScanRegion, false); + const renderCameraZoomUiIfSupported = (cameraCapabilities) => { + let zoomCapability = cameraCapabilities.zoomFeature(); + if (!zoomCapability.isSupported()) { + return; + } + cameraZoomUi.setOnCameraZoomValueChangeCallback((zoomValue) => { + zoomCapability.apply(zoomValue); + }); + let defaultZoom = 1; + if (this.config.defaultZoomValueIfSupported) { + defaultZoom = this.config.defaultZoomValueIfSupported; + } + defaultZoom = clip(defaultZoom, zoomCapability.min(), zoomCapability.max()); + cameraZoomUi.setValues(zoomCapability.min(), zoomCapability.max(), defaultZoom, zoomCapability.step()); + cameraZoomUi.show(); + }; + let cameraSelectUi = CameraSelectionUi.create(scpCameraScanRegion, cameras); + const cameraActionContainer = document.createElement("span"); + const cameraActionStartButton = BaseUiElementFactory.createElement("button", PublicUiElementIdAndClasses.CAMERA_START_BUTTON_ID); + cameraActionStartButton.innerText + = Html5QrcodeScannerStrings.scanButtonStartScanningText(); + cameraActionContainer.appendChild(cameraActionStartButton); + const cameraActionStopButton = BaseUiElementFactory.createElement("button", PublicUiElementIdAndClasses.CAMERA_STOP_BUTTON_ID); + cameraActionStopButton.innerText + = Html5QrcodeScannerStrings.scanButtonStopScanningText(); + cameraActionStopButton.style.display = "none"; + cameraActionStopButton.disabled = true; + cameraActionContainer.appendChild(cameraActionStopButton); + let torchButton; + const createAndShowTorchButtonIfSupported = (cameraCapabilities) => { + if (!cameraCapabilities.torchFeature().isSupported()) { + if (torchButton) { + torchButton.hide(); + } + return; + } + if (!torchButton) { + torchButton = TorchButton.create(cameraActionContainer, cameraCapabilities.torchFeature(), { display: "none", marginLeft: "5px" }, (errorMessage) => { + $this.setHeaderMessage(errorMessage, Html5QrcodeScannerStatus.STATUS_WARNING); + }); + } + else { + torchButton.updateTorchCapability(cameraCapabilities.torchFeature()); + } + torchButton.show(); + }; + scpCameraScanRegion.appendChild(cameraActionContainer); + const resetCameraActionStartButton = (shouldShow) => { + if (!shouldShow) { + cameraActionStartButton.style.display = "none"; + } + cameraActionStartButton.innerText + = Html5QrcodeScannerStrings + .scanButtonStartScanningText(); + cameraActionStartButton.style.opacity = "1"; + cameraActionStartButton.disabled = false; + if (shouldShow) { + cameraActionStartButton.style.display = "inline-block"; + } + }; + cameraActionStartButton.addEventListener("click", (_) => { + cameraActionStartButton.innerText + = Html5QrcodeScannerStrings.scanButtonScanningStarting(); + cameraSelectUi.disable(); + cameraActionStartButton.disabled = true; + cameraActionStartButton.style.opacity = "0.5"; + if (this.scanTypeSelector.hasMoreThanOneScanType()) { + $this.showHideScanTypeSwapLink(false); + } + $this.resetHeaderMessage(); + const cameraId = cameraSelectUi.getValue(); + $this.persistedDataManager.setLastUsedCameraId(cameraId); + $this.html5Qrcode.start(cameraId, toHtml5QrcodeCameraScanConfig($this.config), $this.qrCodeSuccessCallback, $this.qrCodeErrorCallback) + .then((_) => { + cameraActionStopButton.disabled = false; + cameraActionStopButton.style.display = "inline-block"; + resetCameraActionStartButton(false); + const cameraCapabilities = $this.html5Qrcode.getRunningTrackCameraCapabilities(); + if (this.config.showTorchButtonIfSupported === true) { + createAndShowTorchButtonIfSupported(cameraCapabilities); + } + if (this.config.showZoomSliderIfSupported === true) { + renderCameraZoomUiIfSupported(cameraCapabilities); + } + }) + .catch((error) => { + $this.showHideScanTypeSwapLink(true); + cameraSelectUi.enable(); + resetCameraActionStartButton(true); + $this.setHeaderMessage(error, Html5QrcodeScannerStatus.STATUS_WARNING); + }); + }); + if (cameraSelectUi.hasSingleItem()) { + cameraActionStartButton.click(); + } + cameraActionStopButton.addEventListener("click", (_) => { + if (!$this.html5Qrcode) { + throw "html5Qrcode not defined"; + } + cameraActionStopButton.disabled = true; + $this.html5Qrcode.stop() + .then((_) => { + if (this.scanTypeSelector.hasMoreThanOneScanType()) { + $this.showHideScanTypeSwapLink(true); + } + cameraSelectUi.enable(); + cameraActionStartButton.disabled = false; + cameraActionStopButton.style.display = "none"; + cameraActionStartButton.style.display = "inline-block"; + if (torchButton) { + torchButton.reset(); + torchButton.hide(); + } + cameraZoomUi.removeOnCameraZoomValueChangeCallback(); + cameraZoomUi.hide(); + $this.insertCameraScanImageToScanRegion(); + }).catch((error) => { + cameraActionStopButton.disabled = false; + $this.setHeaderMessage(error, Html5QrcodeScannerStatus.STATUS_WARNING); + }); + }); + if ($this.persistedDataManager.getLastUsedCameraId()) { + const cameraId = $this.persistedDataManager.getLastUsedCameraId(); + if (cameraSelectUi.hasValue(cameraId)) { + cameraSelectUi.setValue(cameraId); + cameraActionStartButton.click(); + } + else { + $this.persistedDataManager.resetLastUsedCameraId(); + } + } + } + createSectionSwap() { + const $this = this; + const TEXT_IF_CAMERA_SCAN_SELECTED = Html5QrcodeScannerStrings.textIfCameraScanSelected(); + const TEXT_IF_FILE_SCAN_SELECTED = Html5QrcodeScannerStrings.textIfFileScanSelected(); + const section = document.getElementById(this.getDashboardSectionId()); + const switchContainer = document.createElement("div"); + switchContainer.style.textAlign = "center"; + const switchScanTypeLink = BaseUiElementFactory.createElement("span", this.getDashboardSectionSwapLinkId()); + switchScanTypeLink.style.textDecoration = "underline"; + switchScanTypeLink.style.cursor = "pointer"; + switchScanTypeLink.innerText + = ScanTypeSelector.isCameraScanType(this.currentScanType) + ? TEXT_IF_CAMERA_SCAN_SELECTED : TEXT_IF_FILE_SCAN_SELECTED; + switchScanTypeLink.addEventListener("click", function () { + if (!$this.sectionSwapAllowed) { + if ($this.verbose) { + $this.logger.logError("Section swap called when not allowed"); + } + return; + } + $this.resetHeaderMessage(); + $this.fileSelectionUi.resetValue(); + $this.sectionSwapAllowed = false; + if (ScanTypeSelector.isCameraScanType($this.currentScanType)) { + $this.clearScanRegion(); + $this.getCameraScanRegion().style.display = "none"; + $this.fileSelectionUi.show(); + switchScanTypeLink.innerText = TEXT_IF_FILE_SCAN_SELECTED; + $this.currentScanType = Html5QrcodeScanType.SCAN_TYPE_FILE; + $this.insertFileScanImageToScanRegion(); + } + else { + $this.clearScanRegion(); + $this.getCameraScanRegion().style.display = "block"; + $this.fileSelectionUi.hide(); + switchScanTypeLink.innerText = TEXT_IF_CAMERA_SCAN_SELECTED; + $this.currentScanType = Html5QrcodeScanType.SCAN_TYPE_CAMERA; + $this.insertCameraScanImageToScanRegion(); + $this.startCameraScanIfPermissionExistsOnSwap(); + } + $this.sectionSwapAllowed = true; + }); + switchContainer.appendChild(switchScanTypeLink); + section.appendChild(switchContainer); + } + startCameraScanIfPermissionExistsOnSwap() { + const $this = this; + if (this.persistedDataManager.hasCameraPermissions()) { + CameraPermissions.hasPermissions().then((hasPermissions) => { + if (hasPermissions) { + let permissionButton = document.getElementById($this.getCameraPermissionButtonId()); + if (!permissionButton) { + this.logger.logError("Permission button not found, fail;"); + throw "Permission button not found"; + } + permissionButton.click(); + } + else { + $this.persistedDataManager.setHasPermission(false); + } + }).catch((_) => { + $this.persistedDataManager.setHasPermission(false); + }); + return; + } + } + resetHeaderMessage() { + const messageDiv = document.getElementById(this.getHeaderMessageContainerId()); + messageDiv.style.display = "none"; + } + setHeaderMessage(messageText, scannerStatus) { + if (!scannerStatus) { + scannerStatus = Html5QrcodeScannerStatus.STATUS_DEFAULT; + } + const messageDiv = this.getHeaderMessageDiv(); + messageDiv.innerText = messageText; + messageDiv.style.display = "block"; + switch (scannerStatus) { + case Html5QrcodeScannerStatus.STATUS_SUCCESS: + messageDiv.style.background = "rgba(106, 175, 80, 0.26)"; + messageDiv.style.color = "#477735"; + break; + case Html5QrcodeScannerStatus.STATUS_WARNING: + messageDiv.style.background = "rgba(203, 36, 49, 0.14)"; + messageDiv.style.color = "#cb2431"; + break; + case Html5QrcodeScannerStatus.STATUS_DEFAULT: + default: + messageDiv.style.background = "rgba(0, 0, 0, 0)"; + messageDiv.style.color = "rgb(17, 17, 17)"; + break; + } + } + showHideScanTypeSwapLink(shouldDisplay) { + if (this.scanTypeSelector.hasMoreThanOneScanType()) { + if (shouldDisplay !== true) { + shouldDisplay = false; + } + this.sectionSwapAllowed = shouldDisplay; + this.getDashboardSectionSwapLink().style.display + = shouldDisplay ? "inline-block" : "none"; + } + } + insertCameraScanImageToScanRegion() { + const $this = this; + const qrCodeScanRegion = document.getElementById(this.getScanRegionId()); + if (this.cameraScanImage) { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild(this.cameraScanImage); + return; + } + this.cameraScanImage = new Image; + this.cameraScanImage.onload = (_) => { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild($this.cameraScanImage); + }; + this.cameraScanImage.width = 64; + this.cameraScanImage.style.opacity = "0.8"; + this.cameraScanImage.src = ASSET_CAMERA_SCAN; + this.cameraScanImage.alt = Html5QrcodeScannerStrings.cameraScanAltText(); + } + insertFileScanImageToScanRegion() { + const $this = this; + const qrCodeScanRegion = document.getElementById(this.getScanRegionId()); + if (this.fileScanImage) { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild(this.fileScanImage); + return; + } + this.fileScanImage = new Image; + this.fileScanImage.onload = (_) => { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild($this.fileScanImage); + }; + this.fileScanImage.width = 64; + this.fileScanImage.style.opacity = "0.8"; + this.fileScanImage.src = ASSET_FILE_SCAN; + this.fileScanImage.alt = Html5QrcodeScannerStrings.fileScanAltText(); + } + clearScanRegion() { + const qrCodeScanRegion = document.getElementById(this.getScanRegionId()); + qrCodeScanRegion.innerHTML = ""; + } + getDashboardSectionId() { + return `${this.elementId}__dashboard_section`; + } + getDashboardSectionCameraScanRegionId() { + return `${this.elementId}__dashboard_section_csr`; + } + getDashboardSectionSwapLinkId() { + return PublicUiElementIdAndClasses.SCAN_TYPE_CHANGE_ANCHOR_ID; + } + getScanRegionId() { + return `${this.elementId}__scan_region`; + } + getDashboardId() { + return `${this.elementId}__dashboard`; + } + getHeaderMessageContainerId() { + return `${this.elementId}__header_message`; + } + getCameraPermissionButtonId() { + return PublicUiElementIdAndClasses.CAMERA_PERMISSION_BUTTON_ID; + } + getCameraScanRegion() { + return document.getElementById(this.getDashboardSectionCameraScanRegionId()); + } + getDashboardSectionSwapLink() { + return document.getElementById(this.getDashboardSectionSwapLinkId()); + } + getHeaderMessageDiv() { + return document.getElementById(this.getHeaderMessageContainerId()); + } +} +//# sourceMappingURL=html5-qrcode-scanner.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/html5-qrcode-scanner.js.map b/src/main/node_modules/html5-qrcode/es2015/html5-qrcode-scanner.js.map new file mode 100644 index 0000000000000000000000000000000000000000..f70d4db14ddfaf3916d3d902b4f87bddd71f9494 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/html5-qrcode-scanner.js.map @@ -0,0 +1 @@ +{"version":3,"file":"html5-qrcode-scanner.js","sourceRoot":"","sources":["../../src/html5-qrcode-scanner.ts"],"names":[],"mappings":"AAUA,OAAO,EACH,oBAAoB,EACpB,mBAAmB,EAKnB,uBAAuB,EACvB,WAAW,EAEX,iBAAiB,EACjB,IAAI,GACP,MAAM,QAAQ,CAAC;AAMhB,OAAO,EACH,WAAW,GAId,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,yBAAyB,GAC5B,MAAM,WAAW,CAAC;AAEnB,OAAO,EACH,eAAe,EACf,iBAAiB,GACpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,oBAAoB,EACvB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACH,oBAAoB,EACvB,MAAM,MAAM,CAAC;AAEd,OAAO,EACL,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EACH,eAAe,EAElB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACH,oBAAoB,EACpB,2BAA2B,EAC9B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAK3D,IAAK,wBAKJ;AALD,WAAK,wBAAwB;IACzB,2FAAkB,CAAA;IAClB,2FAAkB,CAAA;IAClB,2FAAkB,CAAA;IAClB,uHAAgC,CAAA;AACpC,CAAC,EAL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C,OAAO,GAAG,IAAI,CAAC,SAAS,yBAAyB,CAAC;IACtD,CAAC;IAEO,6BAA6B;QACjC,OAAO,2BAA2B,CAAC,0BAA0B,CAAC;IAClE,CAAC;IAEO,eAAe;QACnB,OAAO,GAAG,IAAI,CAAC,SAAS,eAAe,CAAC;IAC5C,CAAC;IAEO,cAAc;QAClB,OAAO,GAAG,IAAI,CAAC,SAAS,aAAa,CAAC;IAC1C,CAAC;IAEO,2BAA2B;QAC/B,OAAO,GAAG,IAAI,CAAC,SAAS,kBAAkB,CAAC;IAC/C,CAAC;IAEO,2BAA2B;QAC/B,OAAO,2BAA2B,CAAC,2BAA2B,CAAC;IACnE,CAAC;IAEO,mBAAmB;QACvB,OAAO,QAAQ,CAAC,cAAc,CAC1B,IAAI,CAAC,qCAAqC,EAAE,CAAE,CAAC;IACvD,CAAC;IAEO,2BAA2B;QAC/B,OAAO,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,6BAA6B,EAAE,CAAE,CAAC;IAC1E,CAAC;IAEO,mBAAmB;QACvB,OAAO,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAE,CAAC;IACxE,CAAC;CAGJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/html5-qrcode.d.ts b/src/main/node_modules/html5-qrcode/es2015/html5-qrcode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e576933e30835c6b726b5e90faa67d6f3721a3a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/html5-qrcode.d.ts @@ -0,0 +1,75 @@ +import { QrcodeErrorCallback, QrcodeSuccessCallback, Html5QrcodeSupportedFormats, Html5QrcodeResult, QrDimensions, QrDimensionFunction } from "./core"; +import { CameraDevice, CameraCapabilities } from "./camera/core"; +import { ExperimentalFeaturesConfig } from "./experimental-features"; +import { Html5QrcodeScannerState } from "./state-manager"; +export interface Html5QrcodeConfigs { + formatsToSupport?: Array<Html5QrcodeSupportedFormats> | undefined; + useBarCodeDetectorIfSupported?: boolean | undefined; + experimentalFeatures?: ExperimentalFeaturesConfig | undefined; +} +export interface Html5QrcodeFullConfig extends Html5QrcodeConfigs { + verbose: boolean | undefined; +} +export interface Html5QrcodeCameraScanConfig { + fps: number | undefined; + qrbox?: number | QrDimensions | QrDimensionFunction | undefined; + aspectRatio?: number | undefined; + disableFlip?: boolean | undefined; + videoConstraints?: MediaTrackConstraints | undefined; +} +export declare class Html5Qrcode { + private readonly logger; + private readonly elementId; + private readonly verbose; + private readonly qrcode; + private shouldScan; + private element; + private canvasElement; + private scannerPausedUiElement; + private hasBorderShaders; + private borderShaders; + private qrMatch; + private renderedCamera; + private foreverScanTimeout; + private qrRegion; + private context; + private lastScanImageFile; + private stateManagerProxy; + isScanning: boolean; + constructor(elementId: string, configOrVerbosityFlag?: boolean | Html5QrcodeFullConfig | undefined); + start(cameraIdOrConfig: string | MediaTrackConstraints, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; + pause(shouldPauseVideo?: boolean): void; + resume(): void; + getState(): Html5QrcodeScannerState; + stop(): Promise<void>; + scanFile(imageFile: File, showImage?: boolean): Promise<string>; + scanFileV2(imageFile: File, showImage?: boolean): Promise<Html5QrcodeResult>; + clear(): void; + static getCameras(): Promise<Array<CameraDevice>>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + getRunningTrackCameraCapabilities(): CameraCapabilities; + applyVideoConstraints(videoConstaints: MediaTrackConstraints): Promise<void>; + private getRenderedCameraOrFail; + private getSupportedFormats; + private getUseBarCodeDetectorIfSupported; + private validateQrboxSize; + private validateQrboxConfig; + private toQrdimensions; + private setupUi; + private createScannerPausedUiElement; + private scanContext; + private foreverScan; + private createVideoConstraints; + private computeCanvasDrawConfig; + private clearElement; + private possiblyUpdateShaders; + private possiblyCloseLastScanImageFile; + private createCanvasElement; + private getShadedRegionBounds; + private possiblyInsertShadingElement; + private insertShaderBorders; + private showPausedState; + private hidePausedState; + private getTimeoutFps; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/html5-qrcode.js b/src/main/node_modules/html5-qrcode/es2015/html5-qrcode.js new file mode 100644 index 0000000000000000000000000000000000000000..1c4ff8dd69b9d3f4c33708d3d5db431289a7302b --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/html5-qrcode.js @@ -0,0 +1,810 @@ +import { BaseLoggger, Html5QrcodeResultFactory, Html5QrcodeErrorFactory, Html5QrcodeSupportedFormats, isValidHtml5QrcodeSupportedFormats, Html5QrcodeConstants, isNullOrUndefined } from "./core"; +import { Html5QrcodeStrings } from "./strings"; +import { VideoConstraintsUtil } from "./utils"; +import { Html5QrcodeShim } from "./code-decoder"; +import { CameraFactory } from "./camera/factories"; +import { CameraRetriever } from "./camera/retriever"; +import { StateManagerFactory, Html5QrcodeScannerState } from "./state-manager"; +class Constants extends Html5QrcodeConstants { +} +Constants.DEFAULT_WIDTH = 300; +Constants.DEFAULT_WIDTH_OFFSET = 2; +Constants.FILE_SCAN_MIN_HEIGHT = 300; +Constants.FILE_SCAN_HIDDEN_CANVAS_PADDING = 100; +Constants.MIN_QR_BOX_SIZE = 50; +Constants.SHADED_LEFT = 1; +Constants.SHADED_RIGHT = 2; +Constants.SHADED_TOP = 3; +Constants.SHADED_BOTTOM = 4; +Constants.SHADED_REGION_ELEMENT_ID = "qr-shaded-region"; +Constants.VERBOSE = false; +Constants.BORDER_SHADER_DEFAULT_COLOR = "#ffffff"; +Constants.BORDER_SHADER_MATCH_COLOR = "rgb(90, 193, 56)"; +class InternalHtml5QrcodeConfig { + constructor(config, logger) { + this.logger = logger; + this.fps = Constants.SCAN_DEFAULT_FPS; + if (!config) { + this.disableFlip = Constants.DEFAULT_DISABLE_FLIP; + } + else { + if (config.fps) { + this.fps = config.fps; + } + this.disableFlip = config.disableFlip === true; + this.qrbox = config.qrbox; + this.aspectRatio = config.aspectRatio; + this.videoConstraints = config.videoConstraints; + } + } + isMediaStreamConstraintsValid() { + if (!this.videoConstraints) { + this.logger.logError("Empty videoConstraints", true); + return false; + } + return VideoConstraintsUtil.isMediaStreamConstraintsValid(this.videoConstraints, this.logger); + } + isShadedBoxEnabled() { + return !isNullOrUndefined(this.qrbox); + } + static create(config, logger) { + return new InternalHtml5QrcodeConfig(config, logger); + } +} +export class Html5Qrcode { + constructor(elementId, configOrVerbosityFlag) { + 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 = false; + if (!document.getElementById(elementId)) { + throw `HTML Element with id=${elementId} not found`; + } + this.elementId = elementId; + this.verbose = false; + let experimentalFeatureConfig; + let configObject; + if (typeof configOrVerbosityFlag == "boolean") { + this.verbose = configOrVerbosityFlag === true; + } + else if (configOrVerbosityFlag) { + configObject = configOrVerbosityFlag; + this.verbose = configObject.verbose === true; + experimentalFeatureConfig = configObject.experimentalFeatures; + } + this.logger = new BaseLoggger(this.verbose); + this.qrcode = new Html5QrcodeShim(this.getSupportedFormats(configOrVerbosityFlag), this.getUseBarCodeDetectorIfSupported(configObject), this.verbose, this.logger); + this.foreverScanTimeout; + this.shouldScan = true; + this.stateManagerProxy = StateManagerFactory.create(); + } + start(cameraIdOrConfig, configuration, qrCodeSuccessCallback, qrCodeErrorCallback) { + if (!cameraIdOrConfig) { + throw "cameraIdOrConfig is required"; + } + if (!qrCodeSuccessCallback + || typeof qrCodeSuccessCallback != "function") { + throw "qrCodeSuccessCallback is required and should be a function."; + } + let qrCodeErrorCallbackInternal; + if (qrCodeErrorCallback) { + qrCodeErrorCallbackInternal = qrCodeErrorCallback; + } + else { + qrCodeErrorCallbackInternal + = this.verbose ? this.logger.log : () => { }; + } + const internalConfig = InternalHtml5QrcodeConfig.create(configuration, this.logger); + this.clearElement(); + let videoConstraintsAvailableAndValid = false; + if (internalConfig.videoConstraints) { + if (!internalConfig.isMediaStreamConstraintsValid()) { + this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, " + + "it will be ignored.'", true); + } + else { + videoConstraintsAvailableAndValid = true; + } + } + const areVideoConstraintsEnabled = videoConstraintsAvailableAndValid; + const element = document.getElementById(this.elementId); + const rootElementWidth = element.clientWidth + ? element.clientWidth : Constants.DEFAULT_WIDTH; + element.style.position = "relative"; + this.shouldScan = true; + this.element = element; + const $this = this; + const toScanningStateChangeTransaction = this.stateManagerProxy.startTransition(Html5QrcodeScannerState.SCANNING); + return new Promise((resolve, reject) => { + const videoConstraints = areVideoConstraintsEnabled + ? internalConfig.videoConstraints + : $this.createVideoConstraints(cameraIdOrConfig); + if (!videoConstraints) { + toScanningStateChangeTransaction.cancel(); + reject("videoConstraints should be defined"); + return; + } + let cameraRenderingOptions = {}; + if (!areVideoConstraintsEnabled || internalConfig.aspectRatio) { + cameraRenderingOptions.aspectRatio = internalConfig.aspectRatio; + } + let renderingCallbacks = { + onRenderSurfaceReady: (viewfinderWidth, viewfinderHeight) => { + $this.setupUi(viewfinderWidth, viewfinderHeight, internalConfig); + $this.isScanning = true; + $this.foreverScan(internalConfig, qrCodeSuccessCallback, qrCodeErrorCallbackInternal); + } + }; + CameraFactory.failIfNotSupported().then((factory) => { + factory.create(videoConstraints).then((camera) => { + return camera.render(this.element, cameraRenderingOptions, renderingCallbacks) + .then((renderedCamera) => { + $this.renderedCamera = renderedCamera; + toScanningStateChangeTransaction.execute(); + resolve(null); + }) + .catch((error) => { + toScanningStateChangeTransaction.cancel(); + reject(error); + }); + }).catch((error) => { + toScanningStateChangeTransaction.cancel(); + reject(Html5QrcodeStrings.errorGettingUserMedia(error)); + }); + }).catch((_) => { + toScanningStateChangeTransaction.cancel(); + reject(Html5QrcodeStrings.cameraStreamingNotSupported()); + }); + }); + } + pause(shouldPauseVideo) { + if (!this.stateManagerProxy.isStrictlyScanning()) { + throw "Cannot pause, scanner is not scanning."; + } + this.stateManagerProxy.directTransition(Html5QrcodeScannerState.PAUSED); + this.showPausedState(); + if (isNullOrUndefined(shouldPauseVideo) || shouldPauseVideo !== true) { + shouldPauseVideo = false; + } + if (shouldPauseVideo && this.renderedCamera) { + this.renderedCamera.pause(); + } + } + resume() { + if (!this.stateManagerProxy.isPaused()) { + throw "Cannot result, scanner is not paused."; + } + if (!this.renderedCamera) { + throw "renderedCamera doesn't exist while trying resume()"; + } + const $this = this; + const transitionToScanning = () => { + $this.stateManagerProxy.directTransition(Html5QrcodeScannerState.SCANNING); + $this.hidePausedState(); + }; + if (!this.renderedCamera.isPaused()) { + transitionToScanning(); + return; + } + this.renderedCamera.resume(() => { + transitionToScanning(); + }); + } + getState() { + return this.stateManagerProxy.getState(); + } + stop() { + if (!this.stateManagerProxy.isScanning()) { + throw "Cannot stop, scanner is not running or paused."; + } + const toStoppedStateTransaction = this.stateManagerProxy.startTransition(Html5QrcodeScannerState.NOT_STARTED); + this.shouldScan = false; + if (this.foreverScanTimeout) { + clearTimeout(this.foreverScanTimeout); + } + const removeQrRegion = () => { + if (!this.element) { + return; + } + let childElement = document.getElementById(Constants.SHADED_REGION_ELEMENT_ID); + if (childElement) { + this.element.removeChild(childElement); + } + }; + let $this = this; + return this.renderedCamera.close().then(() => { + $this.renderedCamera = null; + if ($this.element) { + $this.element.removeChild($this.canvasElement); + $this.canvasElement = null; + } + removeQrRegion(); + if ($this.qrRegion) { + $this.qrRegion = null; + } + if ($this.context) { + $this.context = null; + } + toStoppedStateTransaction.execute(); + $this.hidePausedState(); + $this.isScanning = false; + return Promise.resolve(); + }); + } + scanFile(imageFile, showImage) { + return this.scanFileV2(imageFile, showImage) + .then((html5qrcodeResult) => html5qrcodeResult.decodedText); + } + scanFileV2(imageFile, showImage) { + if (!imageFile || !(imageFile instanceof File)) { + throw "imageFile argument is mandatory and should be instance " + + "of File. Use 'event.target.files[0]'."; + } + if (isNullOrUndefined(showImage)) { + showImage = true; + } + if (!this.stateManagerProxy.canScanFile()) { + throw "Cannot start file scan - ongoing camera scan"; + } + return new Promise((resolve, reject) => { + this.possiblyCloseLastScanImageFile(); + this.clearElement(); + this.lastScanImageFile = URL.createObjectURL(imageFile); + const inputImage = new Image; + inputImage.onload = () => { + const imageWidth = inputImage.width; + const imageHeight = inputImage.height; + const element = document.getElementById(this.elementId); + const containerWidth = element.clientWidth + ? element.clientWidth : Constants.DEFAULT_WIDTH; + const containerHeight = Math.max(element.clientHeight ? element.clientHeight : imageHeight, Constants.FILE_SCAN_MIN_HEIGHT); + const config = this.computeCanvasDrawConfig(imageWidth, imageHeight, containerWidth, containerHeight); + if (showImage) { + const visibleCanvas = this.createCanvasElement(containerWidth, containerHeight, "qr-canvas-visible"); + visibleCanvas.style.display = "inline-block"; + element.appendChild(visibleCanvas); + const context = visibleCanvas.getContext("2d"); + if (!context) { + throw "Unable to get 2d context from canvas"; + } + context.canvas.width = containerWidth; + context.canvas.height = containerHeight; + context.drawImage(inputImage, 0, 0, imageWidth, imageHeight, config.x, config.y, config.width, config.height); + } + let padding = Constants.FILE_SCAN_HIDDEN_CANVAS_PADDING; + let hiddenImageWidth = Math.max(inputImage.width, config.width); + let hiddenImageHeight = Math.max(inputImage.height, config.height); + let hiddenCanvasWidth = hiddenImageWidth + 2 * padding; + let hiddenCanvasHeight = hiddenImageHeight + 2 * padding; + const hiddenCanvas = this.createCanvasElement(hiddenCanvasWidth, hiddenCanvasHeight); + element.appendChild(hiddenCanvas); + const context = hiddenCanvas.getContext("2d"); + if (!context) { + throw "Unable to get 2d context from canvas"; + } + context.canvas.width = hiddenCanvasWidth; + context.canvas.height = hiddenCanvasHeight; + context.drawImage(inputImage, 0, 0, imageWidth, imageHeight, padding, padding, hiddenImageWidth, hiddenImageHeight); + try { + this.qrcode.decodeRobustlyAsync(hiddenCanvas) + .then((result) => { + resolve(Html5QrcodeResultFactory.createFromQrcodeResult(result)); + }) + .catch(reject); + } + catch (exception) { + reject(`QR code parse error, error = ${exception}`); + } + }; + inputImage.onerror = reject; + inputImage.onabort = reject; + inputImage.onstalled = reject; + inputImage.onsuspend = reject; + inputImage.src = URL.createObjectURL(imageFile); + }); + } + clear() { + this.clearElement(); + } + static getCameras() { + return CameraRetriever.retrieve(); + } + getRunningTrackCapabilities() { + return this.getRenderedCameraOrFail().getRunningTrackCapabilities(); + } + getRunningTrackSettings() { + return this.getRenderedCameraOrFail().getRunningTrackSettings(); + } + getRunningTrackCameraCapabilities() { + return this.getRenderedCameraOrFail().getCapabilities(); + } + applyVideoConstraints(videoConstaints) { + if (!videoConstaints) { + throw "videoConstaints is required argument."; + } + else if (!VideoConstraintsUtil.isMediaStreamConstraintsValid(videoConstaints, this.logger)) { + throw "invalid videoConstaints passed, check logs for more details"; + } + return this.getRenderedCameraOrFail().applyVideoConstraints(videoConstaints); + } + getRenderedCameraOrFail() { + 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; + } + getSupportedFormats(configOrVerbosityFlag) { + const allFormats = [ + Html5QrcodeSupportedFormats.QR_CODE, + Html5QrcodeSupportedFormats.AZTEC, + Html5QrcodeSupportedFormats.CODABAR, + Html5QrcodeSupportedFormats.CODE_39, + Html5QrcodeSupportedFormats.CODE_93, + Html5QrcodeSupportedFormats.CODE_128, + Html5QrcodeSupportedFormats.DATA_MATRIX, + Html5QrcodeSupportedFormats.MAXICODE, + Html5QrcodeSupportedFormats.ITF, + Html5QrcodeSupportedFormats.EAN_13, + Html5QrcodeSupportedFormats.EAN_8, + Html5QrcodeSupportedFormats.PDF_417, + Html5QrcodeSupportedFormats.RSS_14, + Html5QrcodeSupportedFormats.RSS_EXPANDED, + Html5QrcodeSupportedFormats.UPC_A, + Html5QrcodeSupportedFormats.UPC_E, + Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, + ]; + if (!configOrVerbosityFlag + || typeof configOrVerbosityFlag == "boolean") { + return allFormats; + } + if (!configOrVerbosityFlag.formatsToSupport) { + return allFormats; + } + if (!Array.isArray(configOrVerbosityFlag.formatsToSupport)) { + throw "configOrVerbosityFlag.formatsToSupport should be undefined " + + "or an array."; + } + if (configOrVerbosityFlag.formatsToSupport.length === 0) { + throw "Atleast 1 formatsToSupport is needed."; + } + const supportedFormats = []; + for (const format of configOrVerbosityFlag.formatsToSupport) { + if (isValidHtml5QrcodeSupportedFormats(format)) { + supportedFormats.push(format); + } + else { + this.logger.warn(`Invalid format: ${format} passed in config, ignoring.`); + } + } + if (supportedFormats.length === 0) { + throw "None of formatsToSupport match supported values."; + } + return supportedFormats; + } + getUseBarCodeDetectorIfSupported(config) { + if (isNullOrUndefined(config)) { + return true; + } + if (!isNullOrUndefined(config.useBarCodeDetectorIfSupported)) { + return config.useBarCodeDetectorIfSupported !== false; + } + if (isNullOrUndefined(config.experimentalFeatures)) { + return true; + } + let experimentalFeatures = config.experimentalFeatures; + if (isNullOrUndefined(experimentalFeatures.useBarCodeDetectorIfSupported)) { + return true; + } + return experimentalFeatures.useBarCodeDetectorIfSupported !== false; + } + validateQrboxSize(viewfinderWidth, viewfinderHeight, internalConfig) { + const qrboxSize = internalConfig.qrbox; + this.validateQrboxConfig(qrboxSize); + let qrDimensions = this.toQrdimensions(viewfinderWidth, viewfinderHeight, qrboxSize); + const validateMinSize = (size) => { + if (size < Constants.MIN_QR_BOX_SIZE) { + throw "minimum size of 'config.qrbox' dimension value is" + + ` ${Constants.MIN_QR_BOX_SIZE}px.`; + } + }; + const correctWidthBasedOnRootElementSize = (configWidth) => { + if (configWidth > viewfinderWidth) { + this.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."); + configWidth = viewfinderWidth; + } + return configWidth; + }; + validateMinSize(qrDimensions.width); + validateMinSize(qrDimensions.height); + qrDimensions.width = correctWidthBasedOnRootElementSize(qrDimensions.width); + } + validateQrboxConfig(qrboxSize) { + if (typeof qrboxSize === "number") { + return; + } + if (typeof qrboxSize === "function") { + return; + } + if (qrboxSize.width === undefined || qrboxSize.height === undefined) { + throw "Invalid instance of QrDimensions passed for " + + "'config.qrbox'. Both 'width' and 'height' should be set."; + } + } + toQrdimensions(viewfinderWidth, viewfinderHeight, qrboxSize) { + if (typeof qrboxSize === "number") { + return { width: qrboxSize, height: qrboxSize }; + } + else if (typeof qrboxSize === "function") { + try { + return qrboxSize(viewfinderWidth, viewfinderHeight); + } + catch (error) { + throw new Error("qrbox config was passed as a function but it failed with " + + "unknown error" + error); + } + } + return qrboxSize; + } + setupUi(viewfinderWidth, viewfinderHeight, internalConfig) { + if (internalConfig.isShadedBoxEnabled()) { + this.validateQrboxSize(viewfinderWidth, viewfinderHeight, internalConfig); + } + const qrboxSize = isNullOrUndefined(internalConfig.qrbox) ? + { width: viewfinderWidth, height: viewfinderHeight } : internalConfig.qrbox; + this.validateQrboxConfig(qrboxSize); + let qrDimensions = this.toQrdimensions(viewfinderWidth, viewfinderHeight, qrboxSize); + if (qrDimensions.height > viewfinderHeight) { + this.logger.warn("[Html5Qrcode] config.qrbox has height that is" + + "greater than the height of the video stream. Shading will be" + + " ignored"); + } + const shouldShadingBeApplied = internalConfig.isShadedBoxEnabled() + && qrDimensions.height <= viewfinderHeight; + const defaultQrRegion = { + x: 0, + y: 0, + width: viewfinderWidth, + height: viewfinderHeight + }; + const qrRegion = shouldShadingBeApplied + ? this.getShadedRegionBounds(viewfinderWidth, viewfinderHeight, qrDimensions) + : defaultQrRegion; + const canvasElement = this.createCanvasElement(qrRegion.width, qrRegion.height); + const contextAttributes = { willReadFrequently: true }; + const context = canvasElement.getContext("2d", contextAttributes); + context.canvas.width = qrRegion.width; + context.canvas.height = qrRegion.height; + this.element.append(canvasElement); + if (shouldShadingBeApplied) { + this.possiblyInsertShadingElement(this.element, viewfinderWidth, viewfinderHeight, qrDimensions); + } + this.createScannerPausedUiElement(this.element); + this.qrRegion = qrRegion; + this.context = context; + this.canvasElement = canvasElement; + } + createScannerPausedUiElement(rootElement) { + const scannerPausedUiElement = document.createElement("div"); + scannerPausedUiElement.innerText = Html5QrcodeStrings.scannerPaused(); + scannerPausedUiElement.style.display = "none"; + scannerPausedUiElement.style.position = "absolute"; + scannerPausedUiElement.style.top = "0px"; + scannerPausedUiElement.style.zIndex = "1"; + scannerPausedUiElement.style.background = "rgba(9, 9, 9, 0.46)"; + scannerPausedUiElement.style.color = "#FFECEC"; + scannerPausedUiElement.style.textAlign = "center"; + scannerPausedUiElement.style.width = "100%"; + rootElement.appendChild(scannerPausedUiElement); + this.scannerPausedUiElement = scannerPausedUiElement; + } + scanContext(qrCodeSuccessCallback, qrCodeErrorCallback) { + if (this.stateManagerProxy.isPaused()) { + return Promise.resolve(false); + } + return this.qrcode.decodeAsync(this.canvasElement) + .then((result) => { + qrCodeSuccessCallback(result.text, Html5QrcodeResultFactory.createFromQrcodeResult(result)); + this.possiblyUpdateShaders(true); + return true; + }).catch((error) => { + this.possiblyUpdateShaders(false); + let errorMessage = Html5QrcodeStrings.codeParseError(error); + qrCodeErrorCallback(errorMessage, Html5QrcodeErrorFactory.createFrom(errorMessage)); + return false; + }); + } + foreverScan(internalConfig, qrCodeSuccessCallback, qrCodeErrorCallback) { + if (!this.shouldScan) { + return; + } + if (!this.renderedCamera) { + return; + } + const videoElement = this.renderedCamera.getSurface(); + const widthRatio = videoElement.videoWidth / videoElement.clientWidth; + const heightRatio = videoElement.videoHeight / videoElement.clientHeight; + if (!this.qrRegion) { + throw "qrRegion undefined when localMediaStream is ready."; + } + const sWidthOffset = this.qrRegion.width * widthRatio; + const sHeightOffset = this.qrRegion.height * heightRatio; + const sxOffset = this.qrRegion.x * widthRatio; + const syOffset = this.qrRegion.y * heightRatio; + this.context.drawImage(videoElement, sxOffset, syOffset, sWidthOffset, sHeightOffset, 0, 0, this.qrRegion.width, this.qrRegion.height); + const triggerNextScan = () => { + this.foreverScanTimeout = setTimeout(() => { + this.foreverScan(internalConfig, qrCodeSuccessCallback, qrCodeErrorCallback); + }, this.getTimeoutFps(internalConfig.fps)); + }; + this.scanContext(qrCodeSuccessCallback, qrCodeErrorCallback) + .then((isSuccessfull) => { + if (!isSuccessfull && internalConfig.disableFlip !== true) { + this.context.translate(this.context.canvas.width, 0); + this.context.scale(-1, 1); + this.scanContext(qrCodeSuccessCallback, qrCodeErrorCallback) + .finally(() => { + triggerNextScan(); + }); + } + else { + triggerNextScan(); + } + }).catch((error) => { + this.logger.logError("Error happend while scanning context", error); + triggerNextScan(); + }); + } + createVideoConstraints(cameraIdOrConfig) { + if (typeof cameraIdOrConfig == "string") { + return { deviceId: { exact: cameraIdOrConfig } }; + } + else if (typeof cameraIdOrConfig == "object") { + const facingModeKey = "facingMode"; + const deviceIdKey = "deviceId"; + const allowedFacingModeValues = { "user": true, "environment": true }; + const exactKey = "exact"; + const isValidFacingModeValue = (value) => { + if (value in allowedFacingModeValues) { + return true; + } + else { + throw "config has invalid 'facingMode' value = " + + `'${value}'`; + } + }; + const keys = Object.keys(cameraIdOrConfig); + if (keys.length !== 1) { + throw "'cameraIdOrConfig' object should have exactly 1 key," + + ` if passed as an object, found ${keys.length} keys`; + } + const key = Object.keys(cameraIdOrConfig)[0]; + if (key !== facingModeKey && key !== deviceIdKey) { + throw `Only '${facingModeKey}' and '${deviceIdKey}' ` + + " are supported for 'cameraIdOrConfig'"; + } + if (key === facingModeKey) { + const facingMode = cameraIdOrConfig.facingMode; + if (typeof facingMode == "string") { + if (isValidFacingModeValue(facingMode)) { + return { facingMode: facingMode }; + } + } + else if (typeof facingMode == "object") { + if (exactKey in facingMode) { + if (isValidFacingModeValue(facingMode[`${exactKey}`])) { + return { + facingMode: { + exact: facingMode[`${exactKey}`] + } + }; + } + } + else { + throw "'facingMode' should be string or object with" + + ` ${exactKey} as key.`; + } + } + else { + const type = (typeof facingMode); + throw `Invalid type of 'facingMode' = ${type}`; + } + } + else { + const deviceId = cameraIdOrConfig.deviceId; + if (typeof deviceId == "string") { + return { deviceId: deviceId }; + } + else if (typeof deviceId == "object") { + if (exactKey in deviceId) { + return { + deviceId: { exact: deviceId[`${exactKey}`] } + }; + } + else { + throw "'deviceId' should be string or object with" + + ` ${exactKey} as key.`; + } + } + else { + const type = (typeof deviceId); + throw `Invalid type of 'deviceId' = ${type}`; + } + } + } + const type = (typeof cameraIdOrConfig); + throw `Invalid type of 'cameraIdOrConfig' = ${type}`; + } + computeCanvasDrawConfig(imageWidth, imageHeight, containerWidth, containerHeight) { + if (imageWidth <= containerWidth + && imageHeight <= containerHeight) { + const xoffset = (containerWidth - imageWidth) / 2; + const yoffset = (containerHeight - imageHeight) / 2; + return { + x: xoffset, + y: yoffset, + width: imageWidth, + height: imageHeight + }; + } + else { + const formerImageWidth = imageWidth; + const formerImageHeight = imageHeight; + if (imageWidth > containerWidth) { + imageHeight = (containerWidth / imageWidth) * imageHeight; + imageWidth = containerWidth; + } + if (imageHeight > containerHeight) { + imageWidth = (containerHeight / imageHeight) * imageWidth; + imageHeight = containerHeight; + } + this.logger.log("Image downsampled from " + + `${formerImageWidth}X${formerImageHeight}` + + ` to ${imageWidth}X${imageHeight}.`); + return this.computeCanvasDrawConfig(imageWidth, imageHeight, containerWidth, containerHeight); + } + } + clearElement() { + if (this.stateManagerProxy.isScanning()) { + throw "Cannot clear while scan is ongoing, close it first."; + } + const element = document.getElementById(this.elementId); + if (element) { + element.innerHTML = ""; + } + } + possiblyUpdateShaders(qrMatch) { + if (this.qrMatch === qrMatch) { + return; + } + if (this.hasBorderShaders + && this.borderShaders + && this.borderShaders.length) { + this.borderShaders.forEach((shader) => { + shader.style.backgroundColor = qrMatch + ? Constants.BORDER_SHADER_MATCH_COLOR + : Constants.BORDER_SHADER_DEFAULT_COLOR; + }); + } + this.qrMatch = qrMatch; + } + possiblyCloseLastScanImageFile() { + if (this.lastScanImageFile) { + URL.revokeObjectURL(this.lastScanImageFile); + this.lastScanImageFile = null; + } + } + createCanvasElement(width, height, customId) { + const canvasWidth = width; + const canvasHeight = height; + const canvasElement = document.createElement("canvas"); + canvasElement.style.width = `${canvasWidth}px`; + canvasElement.style.height = `${canvasHeight}px`; + canvasElement.style.display = "none"; + canvasElement.id = isNullOrUndefined(customId) + ? "qr-canvas" : customId; + return canvasElement; + } + getShadedRegionBounds(width, height, qrboxSize) { + if (qrboxSize.width > width || qrboxSize.height > height) { + throw "'config.qrbox' dimensions should not be greater than the " + + "dimensions of the root HTML element."; + } + return { + x: (width - qrboxSize.width) / 2, + y: (height - qrboxSize.height) / 2, + width: qrboxSize.width, + height: qrboxSize.height + }; + } + possiblyInsertShadingElement(element, width, height, qrboxSize) { + if ((width - qrboxSize.width) < 1 || (height - qrboxSize.height) < 1) { + return; + } + const shadingElement = document.createElement("div"); + shadingElement.style.position = "absolute"; + const rightLeftBorderSize = (width - qrboxSize.width) / 2; + const topBottomBorderSize = (height - qrboxSize.height) / 2; + shadingElement.style.borderLeft + = `${rightLeftBorderSize}px solid rgba(0, 0, 0, 0.48)`; + shadingElement.style.borderRight + = `${rightLeftBorderSize}px solid rgba(0, 0, 0, 0.48)`; + shadingElement.style.borderTop + = `${topBottomBorderSize}px solid rgba(0, 0, 0, 0.48)`; + shadingElement.style.borderBottom + = `${topBottomBorderSize}px solid rgba(0, 0, 0, 0.48)`; + shadingElement.style.boxSizing = "border-box"; + shadingElement.style.top = "0px"; + shadingElement.style.bottom = "0px"; + shadingElement.style.left = "0px"; + shadingElement.style.right = "0px"; + shadingElement.id = `${Constants.SHADED_REGION_ELEMENT_ID}`; + if ((width - qrboxSize.width) < 11 + || (height - qrboxSize.height) < 11) { + this.hasBorderShaders = false; + } + else { + const smallSize = 5; + const largeSize = 40; + this.insertShaderBorders(shadingElement, largeSize, smallSize, -smallSize, null, 0, true); + this.insertShaderBorders(shadingElement, largeSize, smallSize, -smallSize, null, 0, false); + this.insertShaderBorders(shadingElement, largeSize, smallSize, null, -smallSize, 0, true); + this.insertShaderBorders(shadingElement, largeSize, smallSize, null, -smallSize, 0, false); + this.insertShaderBorders(shadingElement, smallSize, largeSize + smallSize, -smallSize, null, -smallSize, true); + this.insertShaderBorders(shadingElement, smallSize, largeSize + smallSize, null, -smallSize, -smallSize, true); + this.insertShaderBorders(shadingElement, smallSize, largeSize + smallSize, -smallSize, null, -smallSize, false); + this.insertShaderBorders(shadingElement, smallSize, largeSize + smallSize, null, -smallSize, -smallSize, false); + this.hasBorderShaders = true; + } + element.append(shadingElement); + } + insertShaderBorders(shaderElem, width, height, top, bottom, side, isLeft) { + const elem = document.createElement("div"); + elem.style.position = "absolute"; + elem.style.backgroundColor = Constants.BORDER_SHADER_DEFAULT_COLOR; + elem.style.width = `${width}px`; + elem.style.height = `${height}px`; + if (top !== null) { + elem.style.top = `${top}px`; + } + if (bottom !== null) { + elem.style.bottom = `${bottom}px`; + } + if (isLeft) { + elem.style.left = `${side}px`; + } + else { + elem.style.right = `${side}px`; + } + if (!this.borderShaders) { + this.borderShaders = []; + } + this.borderShaders.push(elem); + shaderElem.appendChild(elem); + } + showPausedState() { + if (!this.scannerPausedUiElement) { + throw "[internal error] scanner paused UI element not found"; + } + this.scannerPausedUiElement.style.display = "block"; + } + hidePausedState() { + if (!this.scannerPausedUiElement) { + throw "[internal error] scanner paused UI element not found"; + } + this.scannerPausedUiElement.style.display = "none"; + } + getTimeoutFps(fps) { + return 1000 / fps; + } +} +//# sourceMappingURL=html5-qrcode.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/html5-qrcode.js.map b/src/main/node_modules/html5-qrcode/es2015/html5-qrcode.js.map new file mode 100644 index 0000000000000000000000000000000000000000..516cb8900dfab0ed7a977ec8b26dbb66539065b3 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/html5-qrcode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"html5-qrcode.js","sourceRoot":"","sources":["../../src/html5-qrcode.ts"],"names":[],"mappings":"AAcA,OAAO,EAIH,WAAW,EACX,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAE3B,kCAAkC,EAClC,oBAAoB,EAEpB,iBAAiB,EAGpB,MAAM,QAAQ,CAAC;AA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V,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC;SAC/B;aAAM;YACL,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,IAAI,IAAI,CAAC;SAChC;QACD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;SACzB;QACD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9B,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAEO,eAAe;QACnB,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE;YAC9B,MAAM,sDAAsD,CAAC;SAChE;QACD,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IACxD,CAAC;IAEO,eAAe;QACnB,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE;YAC9B,MAAM,sDAAsD,CAAC;SAChE;QACD,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACvD,CAAC;IAEO,aAAa,CAAC,GAAW;QAC7B,OAAO,IAAI,GAAG,GAAG,CAAC;IACtB,CAAC;CAEJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/image-assets.d.ts b/src/main/node_modules/html5-qrcode/es2015/image-assets.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..59387ac2e6d5b21c1d1862a744e923298b400a24 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/image-assets.d.ts @@ -0,0 +1,4 @@ +export declare const ASSET_CAMERA_SCAN: string; +export declare const ASSET_FILE_SCAN: string; +export declare const ASSET_INFO_ICON_16PX: string; +export declare const ASSET_CLOSE_ICON_16PX: string; diff --git a/src/main/node_modules/html5-qrcode/es2015/image-assets.js b/src/main/node_modules/html5-qrcode/es2015/image-assets.js new file mode 100644 index 0000000000000000000000000000000000000000..1cf59a4bf1a620e5336ef499e44ffa4cf1f11418 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/image-assets.js @@ -0,0 +1,6 @@ +const SVG_XML_PREFIX = "data:image/svg+xml;base64,"; +export const ASSET_CAMERA_SCAN = SVG_XML_PREFIX + "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzNzEuNjQzIDM3MS42NDMiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDM3MS42NDMgMzcxLjY0MyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBhdGggZD0iTTEwNS4wODQgMzguMjcxaDE2My43Njh2MjBIMTA1LjA4NHoiLz48cGF0aCBkPSJNMzExLjU5NiAxOTAuMTg5Yy03LjQ0MS05LjM0Ny0xOC40MDMtMTYuMjA2LTMyLjc0My0yMC41MjJWMzBjMC0xNi41NDItMTMuNDU4LTMwLTMwLTMwSDEyNS4wODRjLTE2LjU0MiAwLTMwIDEzLjQ1OC0zMCAzMHYxMjAuMTQzaC04LjI5NmMtMTYuNTQyIDAtMzAgMTMuNDU4LTMwIDMwdjEuMzMzYTI5LjgwNCAyOS44MDQgMCAwIDAgNC42MDMgMTUuOTM5Yy03LjM0IDUuNDc0LTEyLjEwMyAxNC4yMjEtMTIuMTAzIDI0LjA2MXYxLjMzM2MwIDkuODQgNC43NjMgMTguNTg3IDEyLjEwMyAyNC4wNjJhMjkuODEgMjkuODEgMCAwIDAtNC42MDMgMTUuOTM4djEuMzMzYzAgMTYuNTQyIDEzLjQ1OCAzMCAzMCAzMGg4LjMyNGMuNDI3IDExLjYzMSA3LjUwMyAyMS41ODcgMTcuNTM0IDI2LjE3Ny45MzEgMTAuNTAzIDQuMDg0IDMwLjE4NyAxNC43NjggNDUuNTM3YTkuOTg4IDkuOTg4IDAgMCAwIDguMjE2IDQuMjg4IDkuOTU4IDkuOTU4IDAgMCAwIDUuNzA0LTEuNzkzYzQuNTMzL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hcVSHmchiILzzuaDQvjBzV2m8yohCE1jHfPx/xhU+y4G/D75ELlRJsSYAAAAASUVORK5CYII="; +//# sourceMappingURL=image-assets.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/image-assets.js.map b/src/main/node_modules/html5-qrcode/es2015/image-assets.js.map new file mode 100644 index 0000000000000000000000000000000000000000..5480f6be939ccf50472eab423b3fea2ef828a7fa --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/image-assets.js.map @@ -0,0 +1 @@ +{"version":3,"file":"image-assets.js","sourceRoot":"","sources":["../../src/image-assets.ts"],"names":[],"mappings":"AASA,MAAM,cAAc,GAAG,4BAA4B,CAAC;AAEpD,MAAM,CAAC,MAAM,iBAAiB,GAAW,cAAc,GAAG,82GAA82G,CAAC;AAEz6G,MAAM,CAAC,MAAM,eAAe,GAAW,cAAc,GAAG,s8CAAs8C,CAAC;AAE//C,MAAM,CAAC,MAAM,oBAAoB,GAAY,cAAc,GAAG,8oBAA8oB,CAAC;AAE7sB,MAAM,CAAC,MAAM,qBAAqB,GAAY,omBAAomB,CAAC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/index.d.ts b/src/main/node_modules/html5-qrcode/es2015/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6b90c689f1a0c34ea728b5b7a5375a33722ed9f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/index.d.ts @@ -0,0 +1,6 @@ +export { Html5Qrcode, Html5QrcodeFullConfig, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; +export { Html5QrcodeScanner } from "./html5-qrcode-scanner"; +export { Html5QrcodeSupportedFormats, Html5QrcodeResult, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; +export { Html5QrcodeScannerState } from "./state-manager"; +export { Html5QrcodeScanType } from "./core"; +export { CameraCapabilities, CameraDevice } from "./camera/core"; diff --git a/src/main/node_modules/html5-qrcode/es2015/index.js b/src/main/node_modules/html5-qrcode/es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..890331ea292278518a37a54e4f794b5f2fd0c4e9 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/index.js @@ -0,0 +1,6 @@ +export { Html5Qrcode } from "./html5-qrcode"; +export { Html5QrcodeScanner } from "./html5-qrcode-scanner"; +export { Html5QrcodeSupportedFormats } from "./core"; +export { Html5QrcodeScannerState } from "./state-manager"; +export { Html5QrcodeScanType } from "./core"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/index.js.map b/src/main/node_modules/html5-qrcode/es2015/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8eede83f3ee9bb76ad797913c29b581f0104a443 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACH,WAAW,EAGd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACH,2BAA2B,EAI9B,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/native-bar-code-detector.d.ts b/src/main/node_modules/html5-qrcode/es2015/native-bar-code-detector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..85ef95e4c4fec982c26cea91f5bb9eb21923bdf4 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/native-bar-code-detector.d.ts @@ -0,0 +1,16 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, QrcodeDecoderAsync, Logger } from "./core"; +export declare class BarcodeDetectorDelegate implements QrcodeDecoderAsync { + private readonly formatMap; + private readonly reverseFormatMap; + private verbose; + private logger; + private detector; + static isSupported(): boolean; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private selectLargestBarcode; + private createBarcodeDetectorFormats; + private toHtml5QrcodeSupportedFormats; + private createReverseFormatMap; + private createDebugData; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/native-bar-code-detector.js b/src/main/node_modules/html5-qrcode/es2015/native-bar-code-detector.js new file mode 100644 index 0000000000000000000000000000000000000000..8b045c525466133d191bf1af9814fb7fc1890f95 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/native-bar-code-detector.js @@ -0,0 +1,107 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { QrcodeResultFormat, Html5QrcodeSupportedFormats } from "./core"; +export class BarcodeDetectorDelegate { + static isSupported() { + if (!("BarcodeDetector" in window)) { + return false; + } + const dummyDetector = new BarcodeDetector({ formats: ["qr_code"] }); + return typeof dummyDetector !== "undefined"; + } + constructor(requestedFormats, verbose, logger) { + this.formatMap = new Map([ + [Html5QrcodeSupportedFormats.QR_CODE, "qr_code"], + [Html5QrcodeSupportedFormats.AZTEC, "aztec"], + [Html5QrcodeSupportedFormats.CODABAR, "codabar"], + [Html5QrcodeSupportedFormats.CODE_39, "code_39"], + [Html5QrcodeSupportedFormats.CODE_93, "code_93"], + [Html5QrcodeSupportedFormats.CODE_128, "code_128"], + [Html5QrcodeSupportedFormats.DATA_MATRIX, "data_matrix"], + [Html5QrcodeSupportedFormats.ITF, "itf"], + [Html5QrcodeSupportedFormats.EAN_13, "ean_13"], + [Html5QrcodeSupportedFormats.EAN_8, "ean_8"], + [Html5QrcodeSupportedFormats.PDF_417, "pdf417"], + [Html5QrcodeSupportedFormats.UPC_A, "upc_a"], + [Html5QrcodeSupportedFormats.UPC_E, "upc_e"] + ]); + this.reverseFormatMap = this.createReverseFormatMap(); + if (!BarcodeDetectorDelegate.isSupported()) { + throw "Use html5qrcode.min.js without edit, Use " + + "BarcodeDetectorDelegate only if it isSupported();"; + } + this.verbose = verbose; + this.logger = logger; + const formats = this.createBarcodeDetectorFormats(requestedFormats); + this.detector = new BarcodeDetector(formats); + if (!this.detector) { + throw "BarcodeDetector detector not supported"; + } + } + decodeAsync(canvas) { + return __awaiter(this, void 0, void 0, function* () { + const barcodes = yield this.detector.detect(canvas); + if (!barcodes || barcodes.length === 0) { + throw "No barcode or QR code detected."; + } + let largestBarcode = this.selectLargestBarcode(barcodes); + return { + text: largestBarcode.rawValue, + format: QrcodeResultFormat.create(this.toHtml5QrcodeSupportedFormats(largestBarcode.format)), + debugData: this.createDebugData() + }; + }); + } + selectLargestBarcode(barcodes) { + let largestBarcode = null; + let maxArea = 0; + for (let barcode of barcodes) { + let area = barcode.boundingBox.width * barcode.boundingBox.height; + if (area > maxArea) { + maxArea = area; + largestBarcode = barcode; + } + } + if (!largestBarcode) { + throw "No largest barcode found"; + } + return largestBarcode; + } + createBarcodeDetectorFormats(requestedFormats) { + let formats = []; + for (const requestedFormat of requestedFormats) { + if (this.formatMap.has(requestedFormat)) { + formats.push(this.formatMap.get(requestedFormat)); + } + else { + this.logger.warn(`${requestedFormat} is not supported by` + + "BarcodeDetectorDelegate"); + } + } + return { formats: formats }; + } + toHtml5QrcodeSupportedFormats(barcodeDetectorFormat) { + if (!this.reverseFormatMap.has(barcodeDetectorFormat)) { + throw `reverseFormatMap doesn't have ${barcodeDetectorFormat}`; + } + return this.reverseFormatMap.get(barcodeDetectorFormat); + } + createReverseFormatMap() { + let result = new Map(); + this.formatMap.forEach((value, key, _) => { + result.set(value, key); + }); + return result; + } + createDebugData() { + return { decoderName: "BarcodeDetector" }; + } +} +//# sourceMappingURL=native-bar-code-detector.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/native-bar-code-detector.js.map b/src/main/node_modules/html5-qrcode/es2015/native-bar-code-detector.js.map new file mode 100644 index 0000000000000000000000000000000000000000..4b533afba020560fc3953bbe12dd2c4d58054df5 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/native-bar-code-detector.js.map @@ -0,0 +1 @@ +{"version":3,"file":"native-bar-code-detector.js","sourceRoot":"","sources":["../../src/native-bar-code-detector.ts"],"names":[],"mappings":";;;;;;;;;AAaA,OAAO,EAGH,kBAAkB,EAClB,2BAA2B,EAG9B,MAAM,QAAQ,CAAC;AA4Cf,MAAM,OAAO,uBAAuB;IAoC1B,MAAM,CAAC,WAAW;QACrB,IAAI,CAAC,CAAC,iBAAiB,IAAI,MAAM,CAAC,EAAE;YAChC,OAAO,KAAK,CAAC;SAChB;QACD,MAAM,aAAa,GAAG,IAAI,eAAe,CAAC,EAAC,OAAO,EAAE,CAAE,SAAS,CAAE,EAAC,CAAC,CAAC;QACpE,OAAO,OAAO,aAAa,KAAK,WAAW,CAAC;IAChD,CAAC;IAED,YACI,gBAAoD,EACpD,OAAgB,EAChB,MAAc;QA3CD,cAAS,GACpB,IAAI,GAAG,CAAC;YACN,CAAE,2BAA2B,CAAC,OAAO,EAAE,SAAS,CAAE;YAClD,CAAE,2BAA2B,CAAC,KAAK,EAAE,OAAO,CAAE;YAC9C,CAAE,2BAA2B,CAAC,OAAO,EAAE,SAAS,CAAE;YAClD,CAAE,2BAA2B,CAAC,OAAO,EAAE,SAAS,CAAE;YAClD,CAAE,2BAA2B,CAAC,OAAO,EAAE,SAAS,CAAE;YAClD,CAAE,2BAA2B,CAAC,QAAQ,EAAE,UAAU,CAAE;YACpD,CAAE,2BAA2B,CAAC,WAAW,EAAG,aAAa,CAAE;YAC3D,CAAE,2BAA2B,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,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,OAAO,CAClB,CAAC,KAAa,EAAE,GAAgC,EAAE,CAAC,EAAE,EAAE;YACvD,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,eAAe;QACnB,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IAC9C,CAAC;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/state-manager.d.ts b/src/main/node_modules/html5-qrcode/es2015/state-manager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c740bbd882ab2dd15280713d5d0866cbdf2b9d8 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/state-manager.d.ts @@ -0,0 +1,29 @@ +export declare enum Html5QrcodeScannerState { + UNKNOWN = 0, + NOT_STARTED = 1, + SCANNING = 2, + PAUSED = 3 +} +export interface StateManagerTransaction { + execute(): void; + cancel(): void; +} +export interface StateManager { + startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction; + directTransition(newState: Html5QrcodeScannerState): void; + getState(): Html5QrcodeScannerState; +} +export declare class StateManagerProxy { + private stateManager; + constructor(stateManager: StateManager); + startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction; + directTransition(newState: Html5QrcodeScannerState): void; + getState(): Html5QrcodeScannerState; + canScanFile(): boolean; + isScanning(): boolean; + isStrictlyScanning(): boolean; + isPaused(): boolean; +} +export declare class StateManagerFactory { + static create(): StateManagerProxy; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/state-manager.js b/src/main/node_modules/html5-qrcode/es2015/state-manager.js new file mode 100644 index 0000000000000000000000000000000000000000..e4f31542ff2889e63d32f236b375ada60f216ba0 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/state-manager.js @@ -0,0 +1,101 @@ +export var Html5QrcodeScannerState; +(function (Html5QrcodeScannerState) { + Html5QrcodeScannerState[Html5QrcodeScannerState["UNKNOWN"] = 0] = "UNKNOWN"; + Html5QrcodeScannerState[Html5QrcodeScannerState["NOT_STARTED"] = 1] = "NOT_STARTED"; + Html5QrcodeScannerState[Html5QrcodeScannerState["SCANNING"] = 2] = "SCANNING"; + Html5QrcodeScannerState[Html5QrcodeScannerState["PAUSED"] = 3] = "PAUSED"; +})(Html5QrcodeScannerState || (Html5QrcodeScannerState = {})); +class StateManagerImpl { + constructor() { + this.state = Html5QrcodeScannerState.NOT_STARTED; + this.onGoingTransactionNewState = Html5QrcodeScannerState.UNKNOWN; + } + directTransition(newState) { + this.failIfTransitionOngoing(); + this.validateTransition(newState); + this.state = newState; + } + startTransition(newState) { + this.failIfTransitionOngoing(); + this.validateTransition(newState); + this.onGoingTransactionNewState = newState; + return this; + } + execute() { + if (this.onGoingTransactionNewState + === Html5QrcodeScannerState.UNKNOWN) { + throw "Transaction is already cancelled, cannot execute()."; + } + const tempNewState = this.onGoingTransactionNewState; + this.onGoingTransactionNewState = Html5QrcodeScannerState.UNKNOWN; + this.directTransition(tempNewState); + } + cancel() { + if (this.onGoingTransactionNewState + === Html5QrcodeScannerState.UNKNOWN) { + throw "Transaction is already cancelled, cannot cancel()."; + } + this.onGoingTransactionNewState = Html5QrcodeScannerState.UNKNOWN; + } + getState() { + return this.state; + } + failIfTransitionOngoing() { + if (this.onGoingTransactionNewState + !== Html5QrcodeScannerState.UNKNOWN) { + throw "Cannot transition to a new state, already under transition"; + } + } + validateTransition(newState) { + switch (this.state) { + case Html5QrcodeScannerState.UNKNOWN: + throw "Transition from unknown is not allowed"; + case Html5QrcodeScannerState.NOT_STARTED: + this.failIfNewStateIs(newState, [Html5QrcodeScannerState.PAUSED]); + break; + case Html5QrcodeScannerState.SCANNING: + break; + case Html5QrcodeScannerState.PAUSED: + break; + } + } + failIfNewStateIs(newState, disallowedStatesToTransition) { + for (const disallowedState of disallowedStatesToTransition) { + if (newState === disallowedState) { + throw `Cannot transition from ${this.state} to ${newState}`; + } + } + } +} +export class StateManagerProxy { + constructor(stateManager) { + this.stateManager = stateManager; + } + startTransition(newState) { + return this.stateManager.startTransition(newState); + } + directTransition(newState) { + this.stateManager.directTransition(newState); + } + getState() { + return this.stateManager.getState(); + } + canScanFile() { + return this.stateManager.getState() === Html5QrcodeScannerState.NOT_STARTED; + } + isScanning() { + return this.stateManager.getState() !== Html5QrcodeScannerState.NOT_STARTED; + } + isStrictlyScanning() { + return this.stateManager.getState() === Html5QrcodeScannerState.SCANNING; + } + isPaused() { + return this.stateManager.getState() === Html5QrcodeScannerState.PAUSED; + } +} +export class StateManagerFactory { + static create() { + return new StateManagerProxy(new StateManagerImpl()); + } +} +//# sourceMappingURL=state-manager.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/state-manager.js.map b/src/main/node_modules/html5-qrcode/es2015/state-manager.js.map new file mode 100644 index 0000000000000000000000000000000000000000..d60cd6b551762e567f58a1ae9e02e779194bfd32 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/state-manager.js.map @@ -0,0 +1 @@ +{"version":3,"file":"state-manager.js","sourceRoot":"","sources":["../../src/state-manager.ts"],"names":[],"mappings":"AAQA,MAAM,CAAN,IAAY,uBAUX;AAVD,WAAY,uBAAuB;IAE/B,2EAAW,CAAA;IAGX,mFAAe,CAAA;IAEf,6EAAQ,CAAA;IAER,yEAAM,CAAA;AACV,CAAC,EAVW,uBAAuB,KAAvB,uBAAuB,QAUlC;AAkDD,MAAM,gBAAgB;IAAtB;QAEY,UAAK,GAA4B,uBAAuB,CAAC,WAAW,CAAC;QAErE,+BAA0B,GAC5B,uBAAuB,CAAC,OAAO,CAAC;IA0E1C,CAAC;IAxEU,gBAAgB,CAAC,QAAiC;QACrD,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC/B,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;IAC1B,CAA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ode/es2015/storage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cae73a316feba6585b2cb887ab0a8d664ba1eb11 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/storage.d.ts @@ -0,0 +1,12 @@ +export declare class PersistedDataManager { + private data; + private static LOCAL_STORAGE_KEY; + constructor(); + hasCameraPermissions(): boolean; + getLastUsedCameraId(): string | null; + setHasPermission(hasPermission: boolean): void; + setLastUsedCameraId(lastUsedCameraId: string): void; + resetLastUsedCameraId(): void; + reset(): void; + private flush; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/storage.js b/src/main/node_modules/html5-qrcode/es2015/storage.js new file mode 100644 index 0000000000000000000000000000000000000000..40b07e978e9e09262259e5f65d2ab6b797a8cae8 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/storage.js @@ -0,0 +1,47 @@ +class PersistedDataFactory { + static createDefault() { + return { + hasPermission: false, + lastUsedCameraId: null + }; + } +} +export class PersistedDataManager { + constructor() { + this.data = PersistedDataFactory.createDefault(); + let data = localStorage.getItem(PersistedDataManager.LOCAL_STORAGE_KEY); + if (!data) { + this.reset(); + } + else { + this.data = JSON.parse(data); + } + } + hasCameraPermissions() { + return this.data.hasPermission; + } + getLastUsedCameraId() { + return this.data.lastUsedCameraId; + } + setHasPermission(hasPermission) { + this.data.hasPermission = hasPermission; + this.flush(); + } + setLastUsedCameraId(lastUsedCameraId) { + this.data.lastUsedCameraId = lastUsedCameraId; + this.flush(); + } + resetLastUsedCameraId() { + this.data.lastUsedCameraId = null; + this.flush(); + } + reset() { + this.data = PersistedDataFactory.createDefault(); + this.flush(); + } + flush() { + localStorage.setItem(PersistedDataManager.LOCAL_STORAGE_KEY, JSON.stringify(this.data)); + } +} +PersistedDataManager.LOCAL_STORAGE_KEY = "HTML5_QRCODE_DATA"; +//# sourceMappingURL=storage.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/storage.js.map b/src/main/node_modules/html5-qrcode/es2015/storage.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b038ac35110796a3842ec672b17719291febe418 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/storage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":"AAeA,MAAM,oBAAoB;IACtB,MAAM,CAAC,aAAa;QAChB,OAAO;YACH,aAAa,EAAE,KAAK;YACpB,gBAAgB,EAAE,IAAI;SACzB,CAAC;IACN,CAAC;CACJ;AAED,MAAM,OAAO,oBAAoB;IAK7B;QAHQ,SAAI,GAAkB,oBAAoB,CAAC,aAAa,EAAE,CAAC;QAI/D,IAAI,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,EAAE;YACP,IAAI,CAAC,KAAK,EAAE,CAAC;SAChB;aAAM;YACH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAChC;IACL,CAAC;IAEM,oBAAoB;QACvB,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;IACnC,CAAC;IAEM,mBAAmB;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;IACtC,CAAC;IAEM,gBAAgB,CAAC,aAAsB;QAC1C,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACxC,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEM,mBAAmB,CAAC,gBAAwB;QAC/C,IAAI,CAAC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEM,qBAAqB;QACxB,IAAI,CAAC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC,aAAa,EAAE,CAAC;QACjD,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEO,KAAK;QACT,YAAY,CAAC,OAAO,CAChB,oBAAoB,CAAC,iBAAiB,EACtC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnC,CAAC;;AA3Cc,sCAAiB,GAAW,mBAAmB,CAAC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/strings.d.ts b/src/main/node_modules/html5-qrcode/es2015/strings.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb99f90013e8dc8c8fb988e3383678cdd993b99e --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/strings.d.ts @@ -0,0 +1,45 @@ +export declare class Html5QrcodeStrings { + static codeParseError(exception: any): string; + static errorGettingUserMedia(error: any): string; + static onlyDeviceSupportedError(): string; + static cameraStreamingNotSupported(): string; + static unableToQuerySupportedDevices(): string; + static insecureContextCameraQueryError(): string; + static scannerPaused(): string; +} +export declare class Html5QrcodeScannerStrings { + static scanningStatus(): string; + static idleStatus(): string; + static errorStatus(): string; + static permissionStatus(): string; + static noCameraFoundErrorStatus(): string; + static lastMatch(decodedText: string): string; + static codeScannerTitle(): string; + static cameraPermissionTitle(): string; + static cameraPermissionRequesting(): string; + static noCameraFound(): string; + static scanButtonStopScanningText(): string; + static scanButtonStartScanningText(): string; + static torchOnButton(): string; + static torchOffButton(): string; + static torchOnFailedMessage(): string; + static torchOffFailedMessage(): string; + static scanButtonScanningStarting(): string; + static textIfCameraScanSelected(): string; + static textIfFileScanSelected(): string; + static selectCamera(): string; + static fileSelectionChooseImage(): string; + static fileSelectionChooseAnother(): string; + static fileSelectionNoImageSelected(): string; + static anonymousCameraPrefix(): string; + static dragAndDropMessage(): string; + static dragAndDropMessageOnlyImages(): string; + static zoom(): string; + static loadingImage(): string; + static cameraScanAltText(): string; + static fileScanAltText(): string; +} +export declare class LibraryInfoStrings { + static poweredBy(): string; + static reportIssues(): string; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/strings.js b/src/main/node_modules/html5-qrcode/es2015/strings.js new file mode 100644 index 0000000000000000000000000000000000000000..a8c8eb2fe55e93094df473f2c453cbd52521f998 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/strings.js @@ -0,0 +1,127 @@ +export class Html5QrcodeStrings { + static codeParseError(exception) { + return `QR code parse error, error = ${exception}`; + } + static errorGettingUserMedia(error) { + return `Error getting userMedia, error = ${error}`; + } + static onlyDeviceSupportedError() { + return "The device doesn't support navigator.mediaDevices , only " + + "supported cameraIdOrConfig in this case is deviceId parameter " + + "(string)."; + } + static cameraStreamingNotSupported() { + return "Camera streaming not supported by the browser."; + } + static unableToQuerySupportedDevices() { + return "Unable to query supported devices, unknown error."; + } + static insecureContextCameraQueryError() { + return "Camera access is only supported in secure context like https " + + "or localhost."; + } + static scannerPaused() { + return "Scanner paused"; + } +} +export class Html5QrcodeScannerStrings { + static scanningStatus() { + return "Scanning"; + } + static idleStatus() { + return "Idle"; + } + static errorStatus() { + return "Error"; + } + static permissionStatus() { + return "Permission"; + } + static noCameraFoundErrorStatus() { + return "No Cameras"; + } + static lastMatch(decodedText) { + return `Last Match: ${decodedText}`; + } + static codeScannerTitle() { + return "Code Scanner"; + } + static cameraPermissionTitle() { + return "Request Camera Permissions"; + } + static cameraPermissionRequesting() { + return "Requesting camera permissions..."; + } + static noCameraFound() { + return "No camera found"; + } + static scanButtonStopScanningText() { + return "Stop Scanning"; + } + static scanButtonStartScanningText() { + return "Start Scanning"; + } + static torchOnButton() { + return "Switch On Torch"; + } + static torchOffButton() { + return "Switch Off Torch"; + } + static torchOnFailedMessage() { + return "Failed to turn on torch"; + } + static torchOffFailedMessage() { + return "Failed to turn off torch"; + } + static scanButtonScanningStarting() { + return "Launching Camera..."; + } + static textIfCameraScanSelected() { + return "Scan an Image File"; + } + static textIfFileScanSelected() { + return "Scan using camera directly"; + } + static selectCamera() { + return "Select Camera"; + } + static fileSelectionChooseImage() { + return "Choose Image"; + } + static fileSelectionChooseAnother() { + return "Choose Another"; + } + static fileSelectionNoImageSelected() { + return "No image choosen"; + } + static anonymousCameraPrefix() { + return "Anonymous Camera"; + } + static dragAndDropMessage() { + return "Or drop an image to scan"; + } + static dragAndDropMessageOnlyImages() { + return "Or drop an image to scan (other files not supported)"; + } + static zoom() { + return "zoom"; + } + static loadingImage() { + return "Loading image..."; + } + static cameraScanAltText() { + return "Camera based scan"; + } + static fileScanAltText() { + return "Fule based scan"; + } +} +export class LibraryInfoStrings { + static poweredBy() { + return "Powered by "; + } + static reportIssues() { + return "Report issues"; + } +} +//# sourceMappingURL=strings.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/strings.js.map b/src/main/node_modules/html5-qrcode/es2015/strings.js.map new file mode 100644 index 0000000000000000000000000000000000000000..5fe4ce0623f03954b051082a32513dd5426464e2 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/strings.js.map @@ -0,0 +1 @@ +{"version":3,"file":"strings.js","sourceRoot":"","sources":["../../src/strings.ts"],"names":[],"mappings":"AAeA,MAAM,OAAO,kBAAkB;IAEpB,MAAM,CAAC,cAAc,CAAC,SAAc;QACvC,OAAO,gCAAgC,SAAS,EAAE,CAAC;IACvD,CAAC;IAEM,MAAM,CAAC,qBAAqB,CAAC,KAAU;QAC1C,OAAO,oCAAoC,KAAK,EAAE,CAAC;IACvD,CAAC;IAEM,MAAM,CAAC,wBAAwB;QAClC,OAAO,2DAA2D;cAChE,gEAAgE;cAChE,WAAW,CAAC;IAClB,CAAC;IAEM,MAAM,CAAC,2BAA2B;QACrC,OAAO,gDAAgD,CAAC;IAC5D,CAAC;IAEM,MAAM,CAAC,6BAA6B;QACvC,OAAO,mDAAmD,CAAC;IAC/D,CAAC;IAEM,MAAM,CAAC,+BAA+B;QACzC,OAAO,+DAA+D;cACpE,eAAe,CAAC;IACtB,CAAC;IAEM,MAAM,CAAC,aAAa;QACvB,OAA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AAC;IAOM,MAAM,CAAC,sBAAsB;QAChC,OAAO,4BAA4B,CAAC;IACxC,CAAC;IAEM,MAAM,CAAC,YAAY;QACtB,OAAO,eAAe,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,wBAAwB;QAClC,OAAO,cAAc,CAAC;IAC1B,CAAC;IAEM,MAAM,CAAC,0BAA0B;QACpC,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,4BAA4B;QACtC,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAGM,MAAM,CAAC,qBAAqB;QAC/B,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAEM,MAAM,CAAC,kBAAkB;QAC5B,OAAO,0BAA0B,CAAC;IACtC,CAAC;IAEM,MAAM,CAAC,4BAA4B;QACtC,OAAO,sDAAsD,CAAC;IAClE,CAAC;IAGM,MAAM,CAAC,IAAI;QACd,OAAO,MAAM,CAAC;IAClB,CAAC;IAEM,MAAM,CAAC,YAAY;QACtB,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAEM,MAAM,CAAC,iBAAiB;QAC3B,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,eAAe;QACzB,OAAO,iBAAiB,CAAC;IAC7B,CAAC;CACJ;AAGD,MAAM,OAAO,kBAAkB;IAEpB,MAAM,CAAC,SAAS;QACnB,OAAO,aAAa,CAAC;IACzB,CAAC;IAEM,MAAM,CAAC,YAAY;QACtB,OAAO,eAAe,CAAC;IAC3B,CAAC;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui.d.ts b/src/main/node_modules/html5-qrcode/es2015/ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f03fe96416ae95a12a35935d8b5f61c5d36d433 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui.d.ts @@ -0,0 +1,6 @@ +export declare class LibraryInfoContainer { + private infoDiv; + private infoIcon; + constructor(); + renderInto(parent: HTMLElement): void; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/ui.js b/src/main/node_modules/html5-qrcode/es2015/ui.js new file mode 100644 index 0000000000000000000000000000000000000000..e52572fdcce19486661eb5259a81d1a576717718 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui.js @@ -0,0 +1,109 @@ +import { ASSET_CLOSE_ICON_16PX, ASSET_INFO_ICON_16PX } from "./image-assets"; +import { LibraryInfoStrings } from "./strings"; +class LibraryInfoDiv { + constructor() { + this.infoDiv = document.createElement("div"); + } + renderInto(parent) { + this.infoDiv.style.position = "absolute"; + this.infoDiv.style.top = "10px"; + this.infoDiv.style.right = "10px"; + this.infoDiv.style.zIndex = "2"; + this.infoDiv.style.display = "none"; + this.infoDiv.style.padding = "5pt"; + this.infoDiv.style.border = "1px solid #171717"; + this.infoDiv.style.fontSize = "10pt"; + this.infoDiv.style.background = "rgb(0 0 0 / 69%)"; + this.infoDiv.style.borderRadius = "5px"; + this.infoDiv.style.textAlign = "center"; + this.infoDiv.style.fontWeight = "400"; + this.infoDiv.style.color = "white"; + this.infoDiv.innerText = LibraryInfoStrings.poweredBy(); + const projectLink = document.createElement("a"); + projectLink.innerText = "ScanApp"; + projectLink.href = "https://scanapp.org"; + projectLink.target = "new"; + projectLink.style.color = "white"; + this.infoDiv.appendChild(projectLink); + const breakElemFirst = document.createElement("br"); + const breakElemSecond = document.createElement("br"); + this.infoDiv.appendChild(breakElemFirst); + this.infoDiv.appendChild(breakElemSecond); + const reportIssueLink = document.createElement("a"); + reportIssueLink.innerText = LibraryInfoStrings.reportIssues(); + reportIssueLink.href = "https://github.com/mebjas/html5-qrcode/issues"; + reportIssueLink.target = "new"; + reportIssueLink.style.color = "white"; + this.infoDiv.appendChild(reportIssueLink); + parent.appendChild(this.infoDiv); + } + show() { + this.infoDiv.style.display = "block"; + } + hide() { + this.infoDiv.style.display = "none"; + } +} +class LibraryInfoIcon { + constructor(onTapIn, onTapOut) { + this.isShowingInfoIcon = true; + this.onTapIn = onTapIn; + this.onTapOut = onTapOut; + this.infoIcon = document.createElement("img"); + } + renderInto(parent) { + this.infoIcon.alt = "Info icon"; + this.infoIcon.src = ASSET_INFO_ICON_16PX; + this.infoIcon.style.position = "absolute"; + this.infoIcon.style.top = "4px"; + this.infoIcon.style.right = "4px"; + this.infoIcon.style.opacity = "0.6"; + this.infoIcon.style.cursor = "pointer"; + this.infoIcon.style.zIndex = "2"; + this.infoIcon.style.width = "16px"; + this.infoIcon.style.height = "16px"; + this.infoIcon.onmouseover = (_) => this.onHoverIn(); + this.infoIcon.onmouseout = (_) => this.onHoverOut(); + this.infoIcon.onclick = (_) => this.onClick(); + parent.appendChild(this.infoIcon); + } + onHoverIn() { + if (this.isShowingInfoIcon) { + this.infoIcon.style.opacity = "1"; + } + } + onHoverOut() { + if (this.isShowingInfoIcon) { + this.infoIcon.style.opacity = "0.6"; + } + } + onClick() { + if (this.isShowingInfoIcon) { + this.isShowingInfoIcon = false; + this.onTapIn(); + this.infoIcon.src = ASSET_CLOSE_ICON_16PX; + this.infoIcon.style.opacity = "1"; + } + else { + this.isShowingInfoIcon = true; + this.onTapOut(); + this.infoIcon.src = ASSET_INFO_ICON_16PX; + this.infoIcon.style.opacity = "0.6"; + } + } +} +export class LibraryInfoContainer { + constructor() { + this.infoDiv = new LibraryInfoDiv(); + this.infoIcon = new LibraryInfoIcon(() => { + this.infoDiv.show(); + }, () => { + this.infoDiv.hide(); + }); + } + renderInto(parent) { + this.infoDiv.renderInto(parent); + this.infoIcon.renderInto(parent); + } +} +//# sourceMappingURL=ui.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui.js.map b/src/main/node_modules/html5-qrcode/es2015/ui.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8612e8cdb36cd595c3a4b3e4478cd3565c989ea3 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/ui.ts"],"names":[],"m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} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/base.d.ts b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/base.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f6ba9cf120e4959471cfef863e282fbbbb9db22 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/base.d.ts @@ -0,0 +1,16 @@ +export declare class PublicUiElementIdAndClasses { + static ALL_ELEMENT_CLASS: string; + static CAMERA_PERMISSION_BUTTON_ID: string; + static CAMERA_START_BUTTON_ID: string; + static CAMERA_STOP_BUTTON_ID: string; + static TORCH_BUTTON_ID: string; + static CAMERA_SELECTION_SELECT_ID: string; + static FILE_SELECTION_BUTTON_ID: string; + static ZOOM_SLIDER_ID: string; + static SCAN_TYPE_CHANGE_ANCHOR_ID: string; + static TORCH_BUTTON_CLASS_TORCH_ON: string; + static TORCH_BUTTON_CLASS_TORCH_OFF: string; +} +export declare class BaseUiElementFactory { + static createElement<Type extends HTMLElement>(elementType: string, elementId: string): Type; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/base.js b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/base.js new file mode 100644 index 0000000000000000000000000000000000000000..fe6b9cf201df25c1201aaeb5cb12afddd58fd96f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/base.js @@ -0,0 +1,25 @@ +export class PublicUiElementIdAndClasses { +} +PublicUiElementIdAndClasses.ALL_ELEMENT_CLASS = "html5-qrcode-element"; +PublicUiElementIdAndClasses.CAMERA_PERMISSION_BUTTON_ID = "html5-qrcode-button-camera-permission"; +PublicUiElementIdAndClasses.CAMERA_START_BUTTON_ID = "html5-qrcode-button-camera-start"; +PublicUiElementIdAndClasses.CAMERA_STOP_BUTTON_ID = "html5-qrcode-button-camera-stop"; +PublicUiElementIdAndClasses.TORCH_BUTTON_ID = "html5-qrcode-button-torch"; +PublicUiElementIdAndClasses.CAMERA_SELECTION_SELECT_ID = "html5-qrcode-select-camera"; +PublicUiElementIdAndClasses.FILE_SELECTION_BUTTON_ID = "html5-qrcode-button-file-selection"; +PublicUiElementIdAndClasses.ZOOM_SLIDER_ID = "html5-qrcode-input-range-zoom"; +PublicUiElementIdAndClasses.SCAN_TYPE_CHANGE_ANCHOR_ID = "html5-qrcode-anchor-scan-type-change"; +PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON = "html5-qrcode-button-torch-on"; +PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF = "html5-qrcode-button-torch-off"; +export class BaseUiElementFactory { + static createElement(elementType, elementId) { + let element = (document.createElement(elementType)); + element.id = elementId; + element.classList.add(PublicUiElementIdAndClasses.ALL_ELEMENT_CLASS); + if (elementType === "button") { + element.setAttribute("type", "button"); + } + return element; + } +} +//# sourceMappingURL=base.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/base.js.map b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/base.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e40a70a8dca1c07433ecde5a5f4bd42c72046f6a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/base.js.map @@ -0,0 +1 @@ +{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/ui/scanner/base.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,2BAA2B;;AAI7B,6CAAiB,GAAG,sBAAsB,CAAC;AAG3C,uDAA2B,GAAG,uCAAuC,CAAC;AAGtE,kDAAsB,GAAG,kCAAkC,CAAC;AAG5D,iDAAqB,GAAG,iCAAiC,CAAC;AAG1D,2CAAe,GAAG,2BAA2B,CAAC;AAG9C,sDAA0B,GAAG,4BAA4B,CAAC;AAG1D,oDAAwB,GAAG,oCAAoC,CAAC;AAGhE,0CAAc,GAAG,+BAA+B,CAAC;AAMjD,sDAA0B,GAAG,sCAAsC,CAAC;AAOpE,uDAA2B,GAAG,8BAA8B,CAAC;AAG7D,wDAA4B,GAAG,+BAA+B,CAAC;AAQ1E,MAAM,OAAO,oBAAoB;IAMtB,MAAM,CAAC,aAAa,CACvB,WAAmB,EAAE,SAAiB;QAEtC,IAAI,OAAO,GAAe,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;QAChE,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;QACvB,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,2BAA2B,CAAC,iBAAiB,CAAC,CAAC;QACrE,IAAI,WAAW,KAAK,QAAQ,EAAE;YAC1B,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;SAC1C;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-selection-ui.d.ts b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-selection-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2090ed53de81e3fc2a4a3f33806eace194c983c9 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-selection-ui.d.ts @@ -0,0 +1,17 @@ +import { CameraDevice } from "../../camera/core"; +export declare class CameraSelectionUi { + private readonly selectElement; + private readonly options; + private readonly cameras; + private constructor(); + private render; + disable(): void; + isDisabled(): boolean; + enable(): void; + getValue(): string; + hasValue(value: string): boolean; + setValue(value: string): void; + hasSingleItem(): boolean; + numCameras(): number; + static create(parentElement: HTMLElement, cameras: Array<CameraDevice>): CameraSelectionUi; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-selection-ui.js b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-selection-ui.js new file mode 100644 index 0000000000000000000000000000000000000000..6b68f7b06acc743598618d7efe86e605c5de1e85 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-selection-ui.js @@ -0,0 +1,82 @@ +import { BaseUiElementFactory, PublicUiElementIdAndClasses } from "./base"; +import { Html5QrcodeScannerStrings } from "../../strings"; +export class CameraSelectionUi { + constructor(cameras) { + this.selectElement = BaseUiElementFactory + .createElement("select", PublicUiElementIdAndClasses.CAMERA_SELECTION_SELECT_ID); + this.cameras = cameras; + this.options = []; + } + render(parentElement) { + const cameraSelectionContainer = document.createElement("span"); + cameraSelectionContainer.style.marginRight = "10px"; + const numCameras = this.cameras.length; + if (numCameras === 0) { + throw new Error("No cameras found"); + } + if (numCameras === 1) { + cameraSelectionContainer.style.display = "none"; + } + else { + const selectCameraString = Html5QrcodeScannerStrings.selectCamera(); + cameraSelectionContainer.innerText + = `${selectCameraString} (${this.cameras.length}) `; + } + let anonymousCameraId = 1; + for (const camera of this.cameras) { + const value = camera.id; + let name = camera.label == null ? value : camera.label; + if (!name || name === "") { + name = [ + Html5QrcodeScannerStrings.anonymousCameraPrefix(), + anonymousCameraId++ + ].join(" "); + } + const option = document.createElement("option"); + option.value = value; + option.innerText = name; + this.options.push(option); + this.selectElement.appendChild(option); + } + cameraSelectionContainer.appendChild(this.selectElement); + parentElement.appendChild(cameraSelectionContainer); + } + disable() { + this.selectElement.disabled = true; + } + isDisabled() { + return this.selectElement.disabled === true; + } + enable() { + this.selectElement.disabled = false; + } + getValue() { + return this.selectElement.value; + } + hasValue(value) { + for (const option of this.options) { + if (option.value === value) { + return true; + } + } + return false; + } + setValue(value) { + if (!this.hasValue(value)) { + throw new Error(`${value} is not present in the camera list.`); + } + this.selectElement.value = value; + } + hasSingleItem() { + return this.cameras.length === 1; + } + numCameras() { + return this.cameras.length; + } + static create(parentElement, cameras) { + let cameraSelectUi = new CameraSelectionUi(cameras); + cameraSelectUi.render(parentElement); + return cameraSelectUi; + } +} +//# sourceMappingURL=camera-selection-ui.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-selection-ui.js.map b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-selection-ui.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a310ef3b392b1ed19e8ce2790f1c15b795fd807b --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-selection-ui.js.map @@ -0,0 +1 @@ +{"version":3,"file":"camera-selection-ui.js","sourceRoot":"","sources":["../../../../src/ui/scanner/camera-selection-ui.ts"],"names":[],"mappings":"AAWA,OAAO,EACH,oBAAoB,EACpB,2BAA2B,EAC9B,MAAM,QAAQ,CAAC;AAChB,OAAO,EACH,yBAAyB,EAC5B,MAAM,eAAe,CAAC;AAGvB,MAAM,OAAO,iBAAiB;IAM1B,YAAoB,OAA4B;QAC5C,IAAI,CAAC,aAAa,GAAG,oBAAoB;aACpC,aAAa,CACd,QAAQ,EACR,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;IAGO,MAAM,CACV,aAA0B;QAC1B,MAAM,wBAAwB,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAChE,wBAAwB,CAAC,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC;QACpD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QACvC,IAAI,UAAU,KAAK,CAAC,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,IAAI,UAAU,KAAK,CAAC,EAAE;YAElB,wBAAwB,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;SACnD;aAAM;YAEH,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,YAAY,EAAE,CAAC;YACpE,wBAAwB,CAAC,SAAS;kBAC5B,GAAG,kBAAkB,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;SAC5D;QAED,IAAI,iBAAiB,GAAG,CAAC,CAAC;QAE1B,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;YAC/B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AAO,KAAK,CAAC;IACjB,CAAC;IAEM,QAAQ,CAAC,KAAa;QACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,qCAAqC,CAAC,CAAC;SAClE;QACD,IAAI,CAAC,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC;IACrC,CAAC;IAEM,aAAa;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC;IACrC,CAAC;IAEM,UAAU;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;IAIM,MAAM,CAAC,MAAM,CAChB,aAA0B,EAC1B,OAA4B;QAC5B,IAAI,cAAc,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACpD,cAAc,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACrC,OAAO,cAAc,CAAC;IAC1B,CAAC;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-zoom-ui.d.ts b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-zoom-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..215bb3f45a562941e18b27204250b45b021bc973 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-zoom-ui.d.ts @@ -0,0 +1,16 @@ +export type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; +export declare class CameraZoomUi { + private zoomElementContainer; + private rangeInput; + private rangeText; + private onChangeCallback; + private constructor(); + private render; + private onValueChange; + setValues(minValue: number, maxValue: number, defaultValue: number, step: number): void; + show(): void; + hide(): void; + setOnCameraZoomValueChangeCallback(onChangeCallback: OnCameraZoomValueChangeCallback): void; + removeOnCameraZoomValueChangeCallback(): void; + static create(parentElement: HTMLElement, renderOnCreate: boolean): CameraZoomUi; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-zoom-ui.js b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-zoom-ui.js new file mode 100644 index 0000000000000000000000000000000000000000..d44c2c04fe7cf23037900dd7c21f1b3d7d030c0c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-zoom-ui.js @@ -0,0 +1,68 @@ +import { BaseUiElementFactory, PublicUiElementIdAndClasses } from "./base"; +import { Html5QrcodeScannerStrings } from "../../strings"; +export class CameraZoomUi { + constructor() { + this.onChangeCallback = null; + this.zoomElementContainer = document.createElement("div"); + this.rangeInput = BaseUiElementFactory.createElement("input", PublicUiElementIdAndClasses.ZOOM_SLIDER_ID); + this.rangeInput.type = "range"; + this.rangeText = document.createElement("span"); + this.rangeInput.min = "1"; + this.rangeInput.max = "5"; + this.rangeInput.value = "1"; + this.rangeInput.step = "0.1"; + } + render(parentElement, renderOnCreate) { + this.zoomElementContainer.style.display + = renderOnCreate ? "block" : "none"; + this.zoomElementContainer.style.padding = "5px 10px"; + this.zoomElementContainer.style.textAlign = "center"; + parentElement.appendChild(this.zoomElementContainer); + this.rangeInput.style.display = "inline-block"; + this.rangeInput.style.width = "50%"; + this.rangeInput.style.height = "5px"; + this.rangeInput.style.background = "#d3d3d3"; + this.rangeInput.style.outline = "none"; + this.rangeInput.style.opacity = "0.7"; + let zoomString = Html5QrcodeScannerStrings.zoom(); + this.rangeText.innerText = `${this.rangeInput.value}x ${zoomString}`; + this.rangeText.style.marginRight = "10px"; + let $this = this; + this.rangeInput.addEventListener("input", () => $this.onValueChange()); + this.rangeInput.addEventListener("change", () => $this.onValueChange()); + this.zoomElementContainer.appendChild(this.rangeInput); + this.zoomElementContainer.appendChild(this.rangeText); + } + onValueChange() { + let zoomString = Html5QrcodeScannerStrings.zoom(); + this.rangeText.innerText = `${this.rangeInput.value}x ${zoomString}`; + if (this.onChangeCallback) { + this.onChangeCallback(parseFloat(this.rangeInput.value)); + } + } + setValues(minValue, maxValue, defaultValue, step) { + this.rangeInput.min = minValue.toString(); + this.rangeInput.max = maxValue.toString(); + this.rangeInput.step = step.toString(); + this.rangeInput.value = defaultValue.toString(); + this.onValueChange(); + } + show() { + this.zoomElementContainer.style.display = "block"; + } + hide() { + this.zoomElementContainer.style.display = "none"; + } + setOnCameraZoomValueChangeCallback(onChangeCallback) { + this.onChangeCallback = onChangeCallback; + } + removeOnCameraZoomValueChangeCallback() { + this.onChangeCallback = null; + } + static create(parentElement, renderOnCreate) { + let cameraZoomUi = new CameraZoomUi(); + cameraZoomUi.render(parentElement, renderOnCreate); + return cameraZoomUi; + } +} +//# sourceMappingURL=camera-zoom-ui.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-zoom-ui.js.map b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-zoom-ui.js.map new file mode 100644 index 0000000000000000000000000000000000000000..96ebeff3475d10724e0e063e985a300c84f4273f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/camera-zoom-ui.js.map @@ -0,0 +1 @@ +{"version":3,"file":"camera-zoom-ui.js","sourceRoot":"","sources":["../../../../src/ui/scanner/camera-zoom-ui.ts"],"names":[],"mappings":"AAUC,OAAO,EACJ,oBAAoB,EACpB,2BAA2B,EAC9B,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAM1D,MAAM,OAAO,YAAY;IAQrB;QAFQ,qBAAgB,GAA2C,IAAI,CAAC;QAGpE,IAAI,CAAC,oBAAoB,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1D,IAAI,CAAC,UAAU,GAAG,oBAAoB,CAAC,aAAa,CAChD,OAAO,EAAE,2BAA2B,CAAC,cAAc,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,OAAO,CAAC;QAE/B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAGhD,IAAI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P,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACrD,CAAC;IAEM,kCAAkC,CACrC,gBAAiD;QACjD,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC7C,CAAC;IAEM,qCAAqC;QACxC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;IACjC,CAAC;IAOM,MAAM,CAAC,MAAM,CAChB,aAA0B,EAC1B,cAAuB;QACvB,IAAI,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;QACtC,YAAY,CAAC,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QACnD,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/file-selection-ui.d.ts b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/file-selection-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..768f5ed8d5b9cd84994a11bca20a02224c665a75 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/file-selection-ui.d.ts @@ -0,0 +1,19 @@ +export type OnFileSelected = (file: File) => void; +export declare class FileSelectionUi { + private readonly fileBasedScanRegion; + private readonly fileScanInput; + private readonly fileSelectionButton; + private constructor(); + hide(): void; + show(): void; + isShowing(): boolean; + resetValue(): void; + private createFileBasedScanRegion; + private fileBasedScanRegionDefaultBorder; + private fileBasedScanRegionActiveBorder; + private createDragAndDropMessage; + private setImageNameToButton; + private setInitialValueToButton; + private getFileScanInputId; + static create(parentElement: HTMLDivElement, showOnRender: boolean, onFileSelected: OnFileSelected): FileSelectionUi; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/file-selection-ui.js b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/file-selection-ui.js new file mode 100644 index 0000000000000000000000000000000000000000..1bf31066e5e147670e22c4ff51c9d337b54362cb --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/file-selection-ui.js @@ -0,0 +1,165 @@ +import { Html5QrcodeScannerStrings } from "../../strings"; +import { BaseUiElementFactory, PublicUiElementIdAndClasses } from "./base"; +export class FileSelectionUi { + constructor(parentElement, showOnRender, onFileSelected) { + this.fileBasedScanRegion = this.createFileBasedScanRegion(); + this.fileBasedScanRegion.style.display + = showOnRender ? "block" : "none"; + parentElement.appendChild(this.fileBasedScanRegion); + let fileScanLabel = document.createElement("label"); + fileScanLabel.setAttribute("for", this.getFileScanInputId()); + fileScanLabel.style.display = "inline-block"; + this.fileBasedScanRegion.appendChild(fileScanLabel); + this.fileSelectionButton + = BaseUiElementFactory.createElement("button", PublicUiElementIdAndClasses.FILE_SELECTION_BUTTON_ID); + this.setInitialValueToButton(); + this.fileSelectionButton.addEventListener("click", (_) => { + fileScanLabel.click(); + }); + fileScanLabel.append(this.fileSelectionButton); + this.fileScanInput + = BaseUiElementFactory.createElement("input", this.getFileScanInputId()); + this.fileScanInput.type = "file"; + this.fileScanInput.accept = "image/*"; + this.fileScanInput.style.display = "none"; + fileScanLabel.appendChild(this.fileScanInput); + let $this = this; + this.fileScanInput.addEventListener("change", (e) => { + if (e == null || e.target == null) { + return; + } + let target = e.target; + if (target.files && target.files.length === 0) { + return; + } + let fileList = target.files; + const file = fileList[0]; + let fileName = file.name; + $this.setImageNameToButton(fileName); + onFileSelected(file); + }); + let dragAndDropMessage = this.createDragAndDropMessage(); + this.fileBasedScanRegion.appendChild(dragAndDropMessage); + this.fileBasedScanRegion.addEventListener("dragenter", function (event) { + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionActiveBorder(); + event.stopPropagation(); + event.preventDefault(); + }); + this.fileBasedScanRegion.addEventListener("dragleave", function (event) { + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionDefaultBorder(); + event.stopPropagation(); + event.preventDefault(); + }); + this.fileBasedScanRegion.addEventListener("dragover", function (event) { + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionActiveBorder(); + event.stopPropagation(); + event.preventDefault(); + }); + this.fileBasedScanRegion.addEventListener("drop", function (event) { + event.stopPropagation(); + event.preventDefault(); + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionDefaultBorder(); + var dataTransfer = event.dataTransfer; + if (dataTransfer) { + let files = dataTransfer.files; + if (!files || files.length === 0) { + return; + } + let isAnyFileImage = false; + for (let i = 0; i < files.length; ++i) { + let file = files.item(i); + if (!file) { + continue; + } + let imageType = /image.*/; + if (!file.type.match(imageType)) { + continue; + } + isAnyFileImage = true; + let fileName = file.name; + $this.setImageNameToButton(fileName); + onFileSelected(file); + dragAndDropMessage.innerText + = Html5QrcodeScannerStrings.dragAndDropMessage(); + break; + } + if (!isAnyFileImage) { + dragAndDropMessage.innerText + = Html5QrcodeScannerStrings + .dragAndDropMessageOnlyImages(); + } + } + }); + } + hide() { + this.fileBasedScanRegion.style.display = "none"; + this.fileScanInput.disabled = true; + } + show() { + this.fileBasedScanRegion.style.display = "block"; + this.fileScanInput.disabled = false; + } + isShowing() { + return this.fileBasedScanRegion.style.display === "block"; + } + resetValue() { + this.fileScanInput.value = ""; + this.setInitialValueToButton(); + } + createFileBasedScanRegion() { + let fileBasedScanRegion = document.createElement("div"); + fileBasedScanRegion.style.textAlign = "center"; + fileBasedScanRegion.style.margin = "auto"; + fileBasedScanRegion.style.width = "80%"; + fileBasedScanRegion.style.maxWidth = "600px"; + fileBasedScanRegion.style.border + = this.fileBasedScanRegionDefaultBorder(); + fileBasedScanRegion.style.padding = "10px"; + fileBasedScanRegion.style.marginBottom = "10px"; + return fileBasedScanRegion; + } + fileBasedScanRegionDefaultBorder() { + return "6px dashed #ebebeb"; + } + fileBasedScanRegionActiveBorder() { + return "6px dashed rgb(153 151 151)"; + } + createDragAndDropMessage() { + let dragAndDropMessage = document.createElement("div"); + dragAndDropMessage.innerText + = Html5QrcodeScannerStrings.dragAndDropMessage(); + dragAndDropMessage.style.fontWeight = "400"; + return dragAndDropMessage; + } + setImageNameToButton(imageFileName) { + const MAX_CHARS = 20; + if (imageFileName.length > MAX_CHARS) { + let start8Chars = imageFileName.substring(0, 8); + let length = imageFileName.length; + let last8Chars = imageFileName.substring(length - 8, length); + imageFileName = `${start8Chars}....${last8Chars}`; + } + let newText = Html5QrcodeScannerStrings.fileSelectionChooseAnother() + + " - " + + imageFileName; + this.fileSelectionButton.innerText = newText; + } + setInitialValueToButton() { + let initialText = Html5QrcodeScannerStrings.fileSelectionChooseImage() + + " - " + + Html5QrcodeScannerStrings.fileSelectionNoImageSelected(); + this.fileSelectionButton.innerText = initialText; + } + getFileScanInputId() { + return "html5-qrcode-private-filescan-input"; + } + static create(parentElement, showOnRender, onFileSelected) { + let button = new FileSelectionUi(parentElement, showOnRender, onFileSelected); + return button; + } +} +//# sourceMappingURL=file-selection-ui.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/file-selection-ui.js.map b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/file-selection-ui.js.map new file mode 100644 index 0000000000000000000000000000000000000000..1dc5220eee534c215c8e52ca7d25423dd4792d8d --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/file-selection-ui.js.map @@ -0,0 +1 @@ +{"version":3,"file":"file-selection-ui.js","sourceRoot":"","sources":["../../../../src/ui/scanner/file-selection-ui.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,yBAAyB,EAAC,MAAM,eAAe,CAAC;AACxD,OAAO,EACH,oBAAoB,EACpB,2BAA2B,EAC9B,MAAM,QAAQ,CAAC;AAQhB,MAAM,OAAO,eAAe;IAOxB,YACI,aAA6B,EAC7B,YAAqB,EACrB,cAA8B;QAC9B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAC5D,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO;cAChC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;QACtC,aAAa,CAAC,WAAW,CAAC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IAClB,CAAC;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/scan-type-selector.d.ts b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/scan-type-selector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f0e1347449e85244139b7cf48cd52b2fca300cb --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/scan-type-selector.d.ts @@ -0,0 +1,11 @@ +import { Html5QrcodeScanType } from "../../core"; +export declare class ScanTypeSelector { + private supportedScanTypes; + constructor(supportedScanTypes?: Array<Html5QrcodeScanType> | []); + getDefaultScanType(): Html5QrcodeScanType; + hasMoreThanOneScanType(): boolean; + isCameraScanRequired(): boolean; + static isCameraScanType(scanType: Html5QrcodeScanType): boolean; + static isFileScanType(scanType: Html5QrcodeScanType): boolean; + private validateAndReturnScanTypes; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/scan-type-selector.js b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/scan-type-selector.js new file mode 100644 index 0000000000000000000000000000000000000000..624427f8caec4669288a7b30fae893f2d3e63493 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/scan-type-selector.js @@ -0,0 +1,44 @@ +import { Html5QrcodeScanType, Html5QrcodeConstants } from "../../core"; +export class ScanTypeSelector { + constructor(supportedScanTypes) { + this.supportedScanTypes = this.validateAndReturnScanTypes(supportedScanTypes); + } + getDefaultScanType() { + return this.supportedScanTypes[0]; + } + hasMoreThanOneScanType() { + return this.supportedScanTypes.length > 1; + } + isCameraScanRequired() { + for (const scanType of this.supportedScanTypes) { + if (ScanTypeSelector.isCameraScanType(scanType)) { + return true; + } + } + return false; + } + static isCameraScanType(scanType) { + return scanType === Html5QrcodeScanType.SCAN_TYPE_CAMERA; + } + static isFileScanType(scanType) { + return scanType === Html5QrcodeScanType.SCAN_TYPE_FILE; + } + validateAndReturnScanTypes(supportedScanTypes) { + if (!supportedScanTypes || supportedScanTypes.length === 0) { + return Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE; + } + let maxExpectedValues = Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE.length; + if (supportedScanTypes.length > maxExpectedValues) { + throw `Max ${maxExpectedValues} values expected for ` + + "supportedScanTypes"; + } + for (const scanType of supportedScanTypes) { + if (!Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE + .includes(scanType)) { + throw `Unsupported scan type ${scanType}`; + } + } + return supportedScanTypes; + } +} +//# sourceMappingURL=scan-type-selector.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/scan-type-selector.js.map b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/scan-type-selector.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e8750db81864c0b4bc27c25e4efe87602e24d10a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/scan-type-selector.js.map @@ -0,0 +1 @@ +{"version":3,"file":"scan-type-selector.js","sourceRoot":"","sources":["../../../../src/ui/scanner/scan-type-selector.ts"],"names":[],"mappings":"AAUA,OAAO,EACH,mBAAmB,EACnB,oBAAoB,EACvB,MAAM,YAAY,CAAC;AAGpB,MAAM,OAAO,gBAAgB;IAGzB,YAAY,kBAAoD;QAC5D,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,0BAA0B,CACrD,kBAAkB,CAAC,CAAC;IAC5B,CAAC;IAMM,kBAAkB;QACrB,OAAO,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAMM,sBAAsB;QACzB,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9C,CAAC;IAGM,oBAAoB;QACvB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC5C,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE;gBAC7C,OAAO,IAAI,CAAC;aACf;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAGM,MAAM,CAAC,gBAAgB,CAAC,QAA6B;QACxD,OAAO,QAAQ,KAAK,mBAAmB,CAAC,gBAAgB,CAAC;IAC7D,CAAC;IAGM,MAAM,CAAC,cAAc,CAAC,QAA6B;QACtD,OAAO,QAAQ,KAAK,mBAAmB,CAAC,cAAc,CAAC;IAC3D,CAAC;IAQO,0BAA0B,CAC9B,kBAA8C;QAG9C,IAAI,CAAC,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE;YACxD,OAAO,oBAAoB,CAAC,2BAA2B,CAAC;SAC3D;QAGD,IAAI,iBAAiB,GACf,oBAAoB,CAAC,2BAA2B,CAAC,MAAM,CAAC;QAC9D,IAAI,kBAAkB,CAAC,MAAM,GAAG,iBAAiB,EAAE;YAC/C,MAAM,OAAO,iBAAiB,uBAAuB;kBAC/C,oBAAoB,CAAC;SAC9B;QAGD,KAAK,MAAM,QAAQ,IAAI,kBAAkB,EAAE;YACvC,IAAI,CAAC,oBAAoB,CAAC,2BAA2B;iBAC5C,QAAQ,CAAC,QAAQ,CAAC,EAAE;gBACzB,MAAM,yBAAyB,QAAQ,EAAE,CAAC;aAC7C;SACJ;QAED,OAAO,kBAAkB,CAAC;IAC9B,CAAC;CAEJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/torch-button.d.ts b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/torch-button.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a862a10bae47503e7ee4e8875da199ff90538d6f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/torch-button.d.ts @@ -0,0 +1,28 @@ +import { BooleanCameraCapability } from "../../camera/core"; +export type OnTorchActionFailureCallback = (failureMessage: string) => void; +interface TorchButtonController { + disable(): void; + enable(): void; + setText(text: string): void; +} +export interface TorchButtonOptions { + display: string; + marginLeft: string; +} +export declare class TorchButton implements TorchButtonController { + private readonly torchButton; + private readonly onTorchActionFailureCallback; + private torchController; + private constructor(); + private render; + updateTorchCapability(torchCapability: BooleanCameraCapability): void; + getTorchButton(): HTMLButtonElement; + hide(): void; + show(): void; + disable(): void; + enable(): void; + setText(text: string): void; + reset(): void; + static create(parentElement: HTMLElement, torchCapability: BooleanCameraCapability, torchButtonOptions: TorchButtonOptions, onTorchActionFailureCallback: OnTorchActionFailureCallback): TorchButton; +} +export {}; diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/torch-button.js b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/torch-button.js new file mode 100644 index 0000000000000000000000000000000000000000..f3fa699c3b0788dd8ca46a0a09641a72e6e7133a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/torch-button.js @@ -0,0 +1,118 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { Html5QrcodeScannerStrings } from "../../strings"; +import { BaseUiElementFactory, PublicUiElementIdAndClasses } from "./base"; +class TorchController { + constructor(torchCapability, buttonController, onTorchActionFailureCallback) { + this.isTorchOn = false; + this.torchCapability = torchCapability; + this.buttonController = buttonController; + this.onTorchActionFailureCallback = onTorchActionFailureCallback; + } + isTorchEnabled() { + return this.isTorchOn; + } + flipState() { + return __awaiter(this, void 0, void 0, function* () { + this.buttonController.disable(); + let isTorchOnExpected = !this.isTorchOn; + try { + yield this.torchCapability.apply(isTorchOnExpected); + this.updateUiBasedOnLatestSettings(this.torchCapability.value(), isTorchOnExpected); + } + catch (error) { + this.propagateFailure(isTorchOnExpected, error); + this.buttonController.enable(); + } + }); + } + updateUiBasedOnLatestSettings(isTorchOn, isTorchOnExpected) { + if (isTorchOn === isTorchOnExpected) { + this.buttonController.setText(isTorchOnExpected + ? Html5QrcodeScannerStrings.torchOffButton() + : Html5QrcodeScannerStrings.torchOnButton()); + this.isTorchOn = isTorchOnExpected; + } + else { + this.propagateFailure(isTorchOnExpected); + } + this.buttonController.enable(); + } + propagateFailure(isTorchOnExpected, error) { + let errorMessage = isTorchOnExpected + ? Html5QrcodeScannerStrings.torchOnFailedMessage() + : Html5QrcodeScannerStrings.torchOffFailedMessage(); + if (error) { + errorMessage += "; Error = " + error; + } + this.onTorchActionFailureCallback(errorMessage); + } + reset() { + this.isTorchOn = false; + } +} +export class TorchButton { + constructor(torchCapability, onTorchActionFailureCallback) { + this.onTorchActionFailureCallback = onTorchActionFailureCallback; + this.torchButton + = BaseUiElementFactory.createElement("button", PublicUiElementIdAndClasses.TORCH_BUTTON_ID); + this.torchController = new TorchController(torchCapability, this, onTorchActionFailureCallback); + } + render(parentElement, torchButtonOptions) { + this.torchButton.innerText + = Html5QrcodeScannerStrings.torchOnButton(); + this.torchButton.style.display = torchButtonOptions.display; + this.torchButton.style.marginLeft = torchButtonOptions.marginLeft; + let $this = this; + this.torchButton.addEventListener("click", (_) => __awaiter(this, void 0, void 0, function* () { + yield $this.torchController.flipState(); + if ($this.torchController.isTorchEnabled()) { + $this.torchButton.classList.remove(PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF); + $this.torchButton.classList.add(PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON); + } + else { + $this.torchButton.classList.remove(PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON); + $this.torchButton.classList.add(PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF); + } + })); + parentElement.appendChild(this.torchButton); + } + updateTorchCapability(torchCapability) { + this.torchController = new TorchController(torchCapability, this, this.onTorchActionFailureCallback); + } + getTorchButton() { + return this.torchButton; + } + hide() { + this.torchButton.style.display = "none"; + } + show() { + this.torchButton.style.display = "inline-block"; + } + disable() { + this.torchButton.disabled = true; + } + enable() { + this.torchButton.disabled = false; + } + setText(text) { + this.torchButton.innerText = text; + } + reset() { + this.torchButton.innerText = Html5QrcodeScannerStrings.torchOnButton(); + this.torchController.reset(); + } + static create(parentElement, torchCapability, torchButtonOptions, onTorchActionFailureCallback) { + let button = new TorchButton(torchCapability, onTorchActionFailureCallback); + button.render(parentElement, torchButtonOptions); + return button; + } +} +//# sourceMappingURL=torch-button.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/ui/scanner/torch-button.js.map b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/torch-button.js.map new file mode 100644 index 0000000000000000000000000000000000000000..cf9293f7303ea61c119b6c31fba07b099d3d505b --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/ui/scanner/torch-button.js.map @@ -0,0 +1 @@ +{"version":3,"file":"torch-button.js","sourceRoot":"","sources":["../../../../src/ui/scanner/torch-button.ts"],"names":[],"mappings":";;;;;;;;;AAWA,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACH,oBAAoB,EACpB,2BAA2B,EAC9B,MAAM,QAAQ,CAAC;AAehB,MAAM,eAAe;IAQjB,YACI,eAAwC,EACxC,gBAAuC,EACvC,4BAA0D;QALtD,cAAS,GAAY,KAAK,CAAC;QAM/B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,4BAA4B,GAAG,4BAA4B,CAAC;IACrE,CAAC;IAGM,cAAc;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAUY,SAAS;;YAClB,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;YAChC,IAAI,iBAAiB,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;Y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eAAwC;QACjE,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CACtC,eAAe,EACS,IAAI,EAC5B,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAC3C,CAAC;IAGM,cAAc;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IAC5C,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,GAAG,cAAc,CAAC;IACpD,CAAC;IAED,OAAO;QACH,IAAI,CAAC,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC;IACrC,CAAC;IAED,MAAM;QACF,IAAI,CAAC,WAAW,CAAC,QAAQ,GAAG,KAAK,CAAC;IACtC,CAAC;IAED,OAAO,CAAC,IAAY;QAChB,IAAI,CAAC,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC;IACtC,CAAC;IAOM,KAAK;QACR,IAAI,CAAC,WAAW,CAAC,SAAS,GAAG,yBAAyB,CAAC,aAAa,EAAE,CAAC;QACvE,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAWO,MAAM,CAAC,MAAM,CACjB,aAA0B,EAC1B,eAAwC,EACxC,kBAAsC,EACtC,4BAA0D;QAE1D,IAAI,MAAM,GAAG,IAAI,WAAW,CACxB,eAAe,EAAE,4BAA4B,CAAC,CAAC;QACnD,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/utils.d.ts b/src/main/node_modules/html5-qrcode/es2015/utils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b060ed9e1f751f6c8a3592683ce5726bf6d3e20 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/utils.d.ts @@ -0,0 +1,4 @@ +import { Logger } from "./core"; +export declare class VideoConstraintsUtil { + static isMediaStreamConstraintsValid(videoConstraints: MediaTrackConstraints, logger: Logger): boolean; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/utils.js b/src/main/node_modules/html5-qrcode/es2015/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..7812e2e1f2c0c1a94138fe009de612feb7cc350c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/utils.js @@ -0,0 +1,30 @@ +export class VideoConstraintsUtil { + static isMediaStreamConstraintsValid(videoConstraints, logger) { + if (typeof videoConstraints !== "object") { + const typeofVideoConstraints = typeof videoConstraints; + logger.logError("videoConstraints should be of type object, the " + + `object passed is of type ${typeofVideoConstraints}.`, true); + return false; + } + const bannedKeys = [ + "autoGainControl", + "channelCount", + "echoCancellation", + "latency", + "noiseSuppression", + "sampleRate", + "sampleSize", + "volume" + ]; + const bannedkeysSet = new Set(bannedKeys); + const keysInVideoConstraints = Object.keys(videoConstraints); + for (const key of keysInVideoConstraints) { + if (bannedkeysSet.has(key)) { + logger.logError(`${key} is not supported videoConstaints.`, true); + return false; + } + } + return true; + } +} +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/utils.js.map b/src/main/node_modules/html5-qrcode/es2015/utils.js.map new file mode 100644 index 0000000000000000000000000000000000000000..e5e1ca1da6c647446b812f72e5e94049b7ace0ad --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAeA,MAAM,OAAO,oBAAoB;IACtB,MAAM,CAAC,6BAA6B,CACvC,gBAAuC,EACvC,MAAc;QACd,IAAI,OAAO,gBAAgB,KAAK,QAAQ,EAAE;YACtC,MAAM,sBAAsB,GAAG,OAAO,gBAAgB,CAAC;YACvD,MAAM,CAAC,QAAQ,CACX,iDAAiD;kBAC3C,4BAA4B,sBAAsB,GAAG,EACvC,IAAI,CAAC,CAAC;YAC9B,OAAO,KAAK,CAAC;SAChB;QAGD,MAAM,UAAU,GAAG;YACf,iBAAiB;YACjB,cAAc;YACd,kBAAkB;YAClB,SAAS;YACT,kBAAkB;YAClB,YAAY;YACZ,YAAY;YACZ,QAAQ;SACX,CAAC;QACF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;QAC1C,MAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC7D,KAAK,MAAM,GAAG,IAAI,sBAAsB,EAAE;YACtC,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBACxB,MAAM,CAAC,QAAQ,CACX,GAAG,GAAG,oCAAoC,EACtB,IAAI,CAAC,CAAC;gBAC9B,OAAO,KAAK,CAAC;aAChB;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/zxing-html5-qrcode-decoder.d.ts b/src/main/node_modules/html5-qrcode/es2015/zxing-html5-qrcode-decoder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..411d37712f3a62354959625cbe40dce24d67f1cc --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/zxing-html5-qrcode-decoder.d.ts @@ -0,0 +1,15 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, Logger, QrcodeDecoderAsync } from "./core"; +export declare class ZXingHtml5QrcodeDecoder implements QrcodeDecoderAsync { + private readonly formatMap; + private readonly reverseFormatMap; + private hints; + private verbose; + private logger; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private decode; + private createReverseFormatMap; + private toHtml5QrcodeSupportedFormats; + private createZXingFormats; + private createDebugData; +} diff --git a/src/main/node_modules/html5-qrcode/es2015/zxing-html5-qrcode-decoder.js b/src/main/node_modules/html5-qrcode/es2015/zxing-html5-qrcode-decoder.js new file mode 100644 index 0000000000000000000000000000000000000000..ac81e2e3b8b3065dad143d6c97c4fb36b0b4d7ae --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/zxing-html5-qrcode-decoder.js @@ -0,0 +1,102 @@ +import * as ZXing from "../third_party/zxing-js.umd"; +import { QrcodeResultFormat, Html5QrcodeSupportedFormats } from "./core"; +export class ZXingHtml5QrcodeDecoder { + constructor(requestedFormats, verbose, logger) { + this.formatMap = new Map([ + [Html5QrcodeSupportedFormats.QR_CODE, ZXing.BarcodeFormat.QR_CODE], + [Html5QrcodeSupportedFormats.AZTEC, ZXing.BarcodeFormat.AZTEC], + [Html5QrcodeSupportedFormats.CODABAR, ZXing.BarcodeFormat.CODABAR], + [Html5QrcodeSupportedFormats.CODE_39, ZXing.BarcodeFormat.CODE_39], + [Html5QrcodeSupportedFormats.CODE_93, ZXing.BarcodeFormat.CODE_93], + [ + Html5QrcodeSupportedFormats.CODE_128, + ZXing.BarcodeFormat.CODE_128 + ], + [ + Html5QrcodeSupportedFormats.DATA_MATRIX, + ZXing.BarcodeFormat.DATA_MATRIX + ], + [ + Html5QrcodeSupportedFormats.MAXICODE, + ZXing.BarcodeFormat.MAXICODE + ], + [Html5QrcodeSupportedFormats.ITF, ZXing.BarcodeFormat.ITF], + [Html5QrcodeSupportedFormats.EAN_13, ZXing.BarcodeFormat.EAN_13], + [Html5QrcodeSupportedFormats.EAN_8, ZXing.BarcodeFormat.EAN_8], + [Html5QrcodeSupportedFormats.PDF_417, ZXing.BarcodeFormat.PDF_417], + [Html5QrcodeSupportedFormats.RSS_14, ZXing.BarcodeFormat.RSS_14], + [ + Html5QrcodeSupportedFormats.RSS_EXPANDED, + ZXing.BarcodeFormat.RSS_EXPANDED + ], + [Html5QrcodeSupportedFormats.UPC_A, ZXing.BarcodeFormat.UPC_A], + [Html5QrcodeSupportedFormats.UPC_E, ZXing.BarcodeFormat.UPC_E], + [ + Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, + ZXing.BarcodeFormat.UPC_EAN_EXTENSION + ] + ]); + this.reverseFormatMap = this.createReverseFormatMap(); + if (!ZXing) { + throw "Use html5qrcode.min.js without edit, ZXing not found."; + } + this.verbose = verbose; + this.logger = logger; + const formats = this.createZXingFormats(requestedFormats); + const hints = new Map(); + hints.set(ZXing.DecodeHintType.POSSIBLE_FORMATS, formats); + hints.set(ZXing.DecodeHintType.TRY_HARDER, false); + this.hints = hints; + } + decodeAsync(canvas) { + return new Promise((resolve, reject) => { + try { + resolve(this.decode(canvas)); + } + catch (error) { + reject(error); + } + }); + } + decode(canvas) { + const zxingDecoder = new ZXing.MultiFormatReader(this.verbose, this.hints); + const luminanceSource = new ZXing.HTMLCanvasElementLuminanceSource(canvas); + const binaryBitmap = new ZXing.BinaryBitmap(new ZXing.HybridBinarizer(luminanceSource)); + let result = zxingDecoder.decode(binaryBitmap); + return { + text: result.text, + format: QrcodeResultFormat.create(this.toHtml5QrcodeSupportedFormats(result.format)), + debugData: this.createDebugData() + }; + } + createReverseFormatMap() { + let result = new Map(); + this.formatMap.forEach((value, key, _) => { + result.set(value, key); + }); + return result; + } + toHtml5QrcodeSupportedFormats(zxingFormat) { + if (!this.reverseFormatMap.has(zxingFormat)) { + throw `reverseFormatMap doesn't have ${zxingFormat}`; + } + return this.reverseFormatMap.get(zxingFormat); + } + createZXingFormats(requestedFormats) { + let zxingFormats = []; + for (const requestedFormat of requestedFormats) { + if (this.formatMap.has(requestedFormat)) { + zxingFormats.push(this.formatMap.get(requestedFormat)); + } + else { + this.logger.logError(`${requestedFormat} is not supported by` + + "ZXingHtml5QrcodeShim"); + } + } + return zxingFormats; + } + createDebugData() { + return { decoderName: "zxing-js" }; + } +} +//# sourceMappingURL=zxing-html5-qrcode-decoder.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/es2015/zxing-html5-qrcode-decoder.js.map b/src/main/node_modules/html5-qrcode/es2015/zxing-html5-qrcode-decoder.js.map new file mode 100644 index 0000000000000000000000000000000000000000..aa9640fd859756abe5b521b7aa6396f9d2f35915 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/es2015/zxing-html5-qrcode-decoder.js.map @@ -0,0 +1 @@ +{"version":3,"file":"zxing-html5-qrcode-decoder.js","sourceRoot":"","sources":["../../src/zxing-html5-qrcode-decoder.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAGH,kBAAkB,EAClB,2BAA2B,EAG9B,MAAM,QAAQ,CAAC;AAKhB,MAAM,OAAO,uBAAuB;IAuChC,YACI,gBAAoD,EACpD,OAAgB,EAChB,MAAc;QAxCD,cAAS,GACpB,IAAI,GAAG,CAAC;YACN,CAAC,2BAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAE;YACnE,CAAC,2BAA2B,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAE;YAC/D,CAAC,2BAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAE;YACnE,CAAC,2BAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAE;YACnE,CAAC,2BAA2B,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAE;YACnE;gBACI,2BAA2B,CAAC,QAAQ;gBACpC,KAAK,CAAC,aAAa,CAAC,QAAQ;aAAE;YAClC;gBACI,2BAA2B,CAAC,WAAW;gBACvC,KAAK,CAAC,aAAa,CAAC,WAAW;aAAE;YACrC;gBACI,2BAA2B,CAAC,QAAQ;gBACpC,KAAK,CAAC,aAAa,CAAC,QAAQ;aAAE;YAClC,CAAC,2BAA2B,CAAC,GAAG,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAE;YAC3D,CAAC,2BAA2B,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAE;YACjE,CAAC,2B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;IAEO,kBAAkB,CACtB,gBAAoD;QAEhD,IAAI,YAAY,GAAG,EAAE,CAAC;QACtB,KAAK,MAAM,eAAe,IAAI,gBAAgB,EAAE;YAC5C,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;gBACrC,YAAY,CAAC,IAAI,CACb,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;aAC5C;iBAAM;gBACH,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,eAAe,sBAAsB;sBACvD,sBAAsB,CAAC,CAAC;aACjC;SACJ;QACD,OAAO,YAAY,CAAC;IAC5B,CAAC;IAEO,eAAe;QACnB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;IACvC,CAAC;CACJ"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/camera/core-impl.d.ts b/src/main/node_modules/html5-qrcode/esm/camera/core-impl.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ffc8a05e27dd5c815882381cca903fde7ae268db --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/core-impl.d.ts @@ -0,0 +1,7 @@ +import { Camera, CameraRenderingOptions, RenderedCamera, RenderingCallbacks } from "./core"; +export declare class CameraImpl implements Camera { + private readonly mediaStream; + private constructor(); + render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>; + static create(videoConstraints: MediaTrackConstraints): Promise<Camera>; +} diff --git a/src/main/node_modules/html5-qrcode/esm/camera/core-impl.js b/src/main/node_modules/html5-qrcode/esm/camera/core-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..48948cbf42d86190c11a4a5a6e7a486005f54315 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/core-impl.js @@ -0,0 +1,311 @@ +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var AbstractCameraCapability = (function () { + function AbstractCameraCapability(name, track) { + this.name = name; + this.track = track; + } + AbstractCameraCapability.prototype.isSupported = function () { + if (!this.track.getCapabilities) { + return false; + } + return this.name in this.track.getCapabilities(); + }; + AbstractCameraCapability.prototype.apply = function (value) { + var constraint = {}; + constraint[this.name] = value; + var constraints = { advanced: [constraint] }; + return this.track.applyConstraints(constraints); + }; + AbstractCameraCapability.prototype.value = function () { + var settings = this.track.getSettings(); + if (this.name in settings) { + var settingValue = settings[this.name]; + return settingValue; + } + return null; + }; + return AbstractCameraCapability; +}()); +var AbstractRangeCameraCapability = (function (_super) { + __extends(AbstractRangeCameraCapability, _super); + function AbstractRangeCameraCapability(name, track) { + return _super.call(this, name, track) || this; + } + AbstractRangeCameraCapability.prototype.min = function () { + return this.getCapabilities().min; + }; + AbstractRangeCameraCapability.prototype.max = function () { + return this.getCapabilities().max; + }; + AbstractRangeCameraCapability.prototype.step = function () { + return this.getCapabilities().step; + }; + AbstractRangeCameraCapability.prototype.apply = function (value) { + var constraint = {}; + constraint[this.name] = value; + var constraints = { advanced: [constraint] }; + return this.track.applyConstraints(constraints); + }; + AbstractRangeCameraCapability.prototype.getCapabilities = function () { + this.failIfNotSupported(); + var capabilities = this.track.getCapabilities(); + var capability = capabilities[this.name]; + return { + min: capability.min, + max: capability.max, + step: capability.step, + }; + }; + AbstractRangeCameraCapability.prototype.failIfNotSupported = function () { + if (!this.isSupported()) { + throw new Error("".concat(this.name, " capability not supported")); + } + }; + return AbstractRangeCameraCapability; +}(AbstractCameraCapability)); +var ZoomFeatureImpl = (function (_super) { + __extends(ZoomFeatureImpl, _super); + function ZoomFeatureImpl(track) { + return _super.call(this, "zoom", track) || this; + } + return ZoomFeatureImpl; +}(AbstractRangeCameraCapability)); +var TorchFeatureImpl = (function (_super) { + __extends(TorchFeatureImpl, _super); + function TorchFeatureImpl(track) { + return _super.call(this, "torch", track) || this; + } + return TorchFeatureImpl; +}(AbstractCameraCapability)); +var CameraCapabilitiesImpl = (function () { + function CameraCapabilitiesImpl(track) { + this.track = track; + } + CameraCapabilitiesImpl.prototype.zoomFeature = function () { + return new ZoomFeatureImpl(this.track); + }; + CameraCapabilitiesImpl.prototype.torchFeature = function () { + return new TorchFeatureImpl(this.track); + }; + return CameraCapabilitiesImpl; +}()); +var RenderedCameraImpl = (function () { + function RenderedCameraImpl(parentElement, mediaStream, callbacks) { + this.isClosed = false; + this.parentElement = parentElement; + this.mediaStream = mediaStream; + this.callbacks = callbacks; + this.surface = this.createVideoElement(this.parentElement.clientWidth); + parentElement.append(this.surface); + } + RenderedCameraImpl.prototype.createVideoElement = function (width) { + var videoElement = document.createElement("video"); + videoElement.style.width = "".concat(width, "px"); + videoElement.style.display = "block"; + videoElement.muted = true; + videoElement.setAttribute("muted", "true"); + videoElement.playsInline = true; + return videoElement; + }; + RenderedCameraImpl.prototype.setupSurface = function () { + var _this = this; + this.surface.onabort = function () { + throw "RenderedCameraImpl video surface onabort() called"; + }; + this.surface.onerror = function () { + throw "RenderedCameraImpl video surface onerror() called"; + }; + var onVideoStart = function () { + var videoWidth = _this.surface.clientWidth; + var videoHeight = _this.surface.clientHeight; + _this.callbacks.onRenderSurfaceReady(videoWidth, videoHeight); + _this.surface.removeEventListener("playing", onVideoStart); + }; + this.surface.addEventListener("playing", onVideoStart); + this.surface.srcObject = this.mediaStream; + this.surface.play(); + }; + RenderedCameraImpl.create = function (parentElement, mediaStream, options, callbacks) { + return __awaiter(this, void 0, void 0, function () { + var renderedCamera, aspectRatioConstraint; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + renderedCamera = new RenderedCameraImpl(parentElement, mediaStream, callbacks); + if (!options.aspectRatio) return [3, 2]; + aspectRatioConstraint = { + aspectRatio: options.aspectRatio + }; + return [4, renderedCamera.getFirstTrackOrFail().applyConstraints(aspectRatioConstraint)]; + case 1: + _a.sent(); + _a.label = 2; + case 2: + renderedCamera.setupSurface(); + return [2, renderedCamera]; + } + }); + }); + }; + RenderedCameraImpl.prototype.failIfClosed = function () { + if (this.isClosed) { + throw "The RenderedCamera has already been closed."; + } + }; + RenderedCameraImpl.prototype.getFirstTrackOrFail = function () { + this.failIfClosed(); + if (this.mediaStream.getVideoTracks().length === 0) { + throw "No video tracks found"; + } + return this.mediaStream.getVideoTracks()[0]; + }; + RenderedCameraImpl.prototype.pause = function () { + this.failIfClosed(); + this.surface.pause(); + }; + RenderedCameraImpl.prototype.resume = function (onResumeCallback) { + this.failIfClosed(); + var $this = this; + var onVideoResume = function () { + setTimeout(onResumeCallback, 200); + $this.surface.removeEventListener("playing", onVideoResume); + }; + this.surface.addEventListener("playing", onVideoResume); + this.surface.play(); + }; + RenderedCameraImpl.prototype.isPaused = function () { + this.failIfClosed(); + return this.surface.paused; + }; + RenderedCameraImpl.prototype.getSurface = function () { + this.failIfClosed(); + return this.surface; + }; + RenderedCameraImpl.prototype.getRunningTrackCapabilities = function () { + return this.getFirstTrackOrFail().getCapabilities(); + }; + RenderedCameraImpl.prototype.getRunningTrackSettings = function () { + return this.getFirstTrackOrFail().getSettings(); + }; + RenderedCameraImpl.prototype.applyVideoConstraints = function (constraints) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + if ("aspectRatio" in constraints) { + throw "Changing 'aspectRatio' in run-time is not yet supported."; + } + return [2, this.getFirstTrackOrFail().applyConstraints(constraints)]; + }); + }); + }; + RenderedCameraImpl.prototype.close = function () { + if (this.isClosed) { + return Promise.resolve(); + } + var $this = this; + return new Promise(function (resolve, _) { + var tracks = $this.mediaStream.getVideoTracks(); + var tracksToClose = tracks.length; + var tracksClosed = 0; + $this.mediaStream.getVideoTracks().forEach(function (videoTrack) { + $this.mediaStream.removeTrack(videoTrack); + videoTrack.stop(); + ++tracksClosed; + if (tracksClosed >= tracksToClose) { + $this.isClosed = true; + $this.parentElement.removeChild($this.surface); + resolve(); + } + }); + }); + }; + RenderedCameraImpl.prototype.getCapabilities = function () { + return new CameraCapabilitiesImpl(this.getFirstTrackOrFail()); + }; + return RenderedCameraImpl; +}()); +var CameraImpl = (function () { + function CameraImpl(mediaStream) { + this.mediaStream = mediaStream; + } + CameraImpl.prototype.render = function (parentElement, options, callbacks) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2, RenderedCameraImpl.create(parentElement, this.mediaStream, options, callbacks)]; + }); + }); + }; + CameraImpl.create = function (videoConstraints) { + return __awaiter(this, void 0, void 0, function () { + var constraints, mediaStream; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!navigator.mediaDevices) { + throw "navigator.mediaDevices not supported"; + } + constraints = { + audio: false, + video: videoConstraints + }; + return [4, navigator.mediaDevices.getUserMedia(constraints)]; + case 1: + mediaStream = _a.sent(); + return [2, new CameraImpl(mediaStream)]; + } + }); + }); + }; + return CameraImpl; +}()); +export { CameraImpl }; +//# sourceMappingURL=core-impl.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/camera/core-impl.js.map b/src/main/node_modules/html5-qrcode/esm/camera/core-impl.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b50538284eec2324004e2d3b4498afb1f1fe8632 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/core-impl.js.map @@ -0,0 +1 @@ +{"version":3,"file":"core-impl.js","sourceRoot":"","sources":["../../../src/camera/core-impl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;IAII,kCAAY,IAAY,EAAE,KAAuB;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,C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ACG,WAAW,GAA2B;4BACtC,KAAK,EAAE,KAAK;4BACZ,KAAK,EAAE,gBAAgB;yBAC1B,CAAC;wBAEgB,WAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CACvD,WAAW,CAAC,EAAA;;wBADZ,WAAW,GAAG,SACF;wBAChB,WAAO,IAAI,UAAU,CAAC,WAAW,CAAC,EAAC;;;;KACtC;IACL,iBAAC;AAAD,CAAC,AA9BD,IA8BC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/camera/core.d.ts b/src/main/node_modules/html5-qrcode/esm/camera/core.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..52e27b5012fe7172a5d7b179174774fe206316ae --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/core.d.ts @@ -0,0 +1,41 @@ +export interface CameraDevice { + id: string; + label: string; +} +export interface CameraCapability<T> { + isSupported(): boolean; + apply(value: T): Promise<void>; + value(): T | null; +} +export interface RangeCameraCapability extends CameraCapability<number> { + min(): number; + max(): number; + step(): number; +} +export interface BooleanCameraCapability extends CameraCapability<boolean> { +} +export interface CameraCapabilities { + zoomFeature(): RangeCameraCapability; + torchFeature(): BooleanCameraCapability; +} +export type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; +export interface RenderingCallbacks { + onRenderSurfaceReady: OnRenderSurfaceReady; +} +export interface RenderedCamera { + getSurface(): HTMLVideoElement; + pause(): void; + resume(onResumeCallback: () => void): void; + isPaused(): boolean; + close(): Promise<void>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + applyVideoConstraints(constraints: MediaTrackConstraints): Promise<void>; + getCapabilities(): CameraCapabilities; +} +export interface CameraRenderingOptions { + aspectRatio?: number; +} +export interface Camera { + render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>; +} diff --git a/src/main/node_modules/html5-qrcode/esm/camera/core.js b/src/main/node_modules/html5-qrcode/esm/camera/core.js new file mode 100644 index 0000000000000000000000000000000000000000..d59ace34f25a1a21456fcb578fd8d55567d77d96 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/core.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=core.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/camera/core.js.map b/src/main/node_modules/html5-qrcode/esm/camera/core.js.map new file mode 100644 index 0000000000000000000000000000000000000000..28f32d7a77e4af3d121d2ca609c13019871b22ea --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/core.js.map @@ -0,0 +1 @@ +{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/camera/core.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/camera/factories.d.ts b/src/main/node_modules/html5-qrcode/esm/camera/factories.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..df98f8ffb0479eb3c807d7e49c6018c3850f8f71 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/factories.d.ts @@ -0,0 +1,6 @@ +import { Camera } from "./core"; +export declare class CameraFactory { + static failIfNotSupported(): Promise<CameraFactory>; + private constructor(); + create(videoConstraints: MediaTrackConstraints): Promise<Camera>; +} diff --git a/src/main/node_modules/html5-qrcode/esm/camera/factories.js b/src/main/node_modules/html5-qrcode/esm/camera/factories.js new file mode 100644 index 0000000000000000000000000000000000000000..8e315c3174bec27b4de5c2e55b1910b4db69df73 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/factories.js @@ -0,0 +1,61 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +import { CameraImpl } from "./core-impl"; +var CameraFactory = (function () { + function CameraFactory() { + } + CameraFactory.failIfNotSupported = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + if (!navigator.mediaDevices) { + throw "navigator.mediaDevices not supported"; + } + return [2, new CameraFactory()]; + }); + }); + }; + CameraFactory.prototype.create = function (videoConstraints) { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2, CameraImpl.create(videoConstraints)]; + }); + }); + }; + return CameraFactory; +}()); +export { CameraFactory }; +//# sourceMappingURL=factories.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/camera/factories.js.map b/src/main/node_modules/html5-qrcode/esm/camera/factories.js.map new file mode 100644 index 0000000000000000000000000000000000000000..88c473fae70bf05ce0a920a181974341cee347c4 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/factories.js.map @@ -0,0 +1 @@ +{"version":3,"file":"factories.js","sourceRoot":"","sources":["../../../src/camera/factories.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC;IAcI;IAAqC,CAAC;IARlB,gCAAkB,GAAtC;;;gBACI,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE;oBACzB,MAAM,sCAAsC,CAAC;iBAChD;gBAED,WAAO,IAAI,aAAa,EAAE,EAAC;;;KAC9B;IAKY,8BAAM,GAAnB,UAAoB,gBAAuC;;;gBAEvD,WAAO,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAC;;;KAC9C;IACL,oBAAC;AAAD,CAAC,AArBD,IAqBC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/camera/permissions.d.ts b/src/main/node_modules/html5-qrcode/esm/camera/permissions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4209c552093cc9cc5bf1022bd100a4459b988c38 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/permissions.d.ts @@ -0,0 +1,3 @@ +export declare class CameraPermissions { + static hasPermissions(): Promise<boolean>; +} diff --git a/src/main/node_modules/html5-qrcode/esm/camera/permissions.js b/src/main/node_modules/html5-qrcode/esm/camera/permissions.js new file mode 100644 index 0000000000000000000000000000000000000000..633d3f788b2e3c66d8e7810571a60a10afa4c63e --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/permissions.js @@ -0,0 +1,62 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var CameraPermissions = (function () { + function CameraPermissions() { + } + CameraPermissions.hasPermissions = function () { + return __awaiter(this, void 0, void 0, function () { + var devices, _i, devices_1, device; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4, navigator.mediaDevices.enumerateDevices()]; + case 1: + devices = _a.sent(); + for (_i = 0, devices_1 = devices; _i < devices_1.length; _i++) { + device = devices_1[_i]; + if (device.kind === "videoinput" && device.label) { + return [2, true]; + } + } + return [2, false]; + } + }); + }); + }; + return CameraPermissions; +}()); +export { CameraPermissions }; +//# sourceMappingURL=permissions.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/camera/permissions.js.map b/src/main/node_modules/html5-qrcode/esm/camera/permissions.js.map new file mode 100644 index 0000000000000000000000000000000000000000..329191a6545cef0d04d31a1131fadfb8f87ddc0a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/permissions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../src/camera/permissions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYC;IAAA;IAqBD,CAAC;IAfuB,gCAAc,GAAlC;;;;;4BAIgB,WAAM,SAAS,CAAC,YAAY,CAAC,gBAAgB,EAAE,EAAA;;wBAAzD,OAAO,GAAG,SAA+C;wBAC7D,WAA4B,EAAP,mBAAO,EAAP,qBAAO,EAAP,IAAO,EAAE;4BAAnB,MAAM;4BAGf,IAAG,MAAM,CAAC,IAAI,KAAK,YAAY,IAAI,MAAM,CAAC,KAAK,EAAE;gCAC/C,WAAO,IAAI,EAAC;6BACb;yBACF;wBAED,WAAO,KAAK,EAAC;;;;KACd;IACL,wBAAC;AAAD,CAAC,AArBA,IAqBA"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/camera/retriever.d.ts b/src/main/node_modules/html5-qrcode/esm/camera/retriever.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0baac120fbc60739f5a0b7b3f59d217b02a41c17 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/retriever.d.ts @@ -0,0 +1,8 @@ +import { CameraDevice } from "./core"; +export declare class CameraRetriever { + static retrieve(): Promise<Array<CameraDevice>>; + private static rejectWithError; + private static isHttpsOrLocalhost; + private static getCamerasFromMediaDevices; + private static getCamerasFromMediaStreamTrack; +} diff --git a/src/main/node_modules/html5-qrcode/esm/camera/retriever.js b/src/main/node_modules/html5-qrcode/esm/camera/retriever.js new file mode 100644 index 0000000000000000000000000000000000000000..fd1a895ec0c87fe95fe36bccdbc7a7f7d3986220 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/retriever.js @@ -0,0 +1,124 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +import { Html5QrcodeStrings } from "../strings"; +var CameraRetriever = (function () { + function CameraRetriever() { + } + CameraRetriever.retrieve = function () { + if (navigator.mediaDevices) { + return CameraRetriever.getCamerasFromMediaDevices(); + } + var mst = MediaStreamTrack; + if (MediaStreamTrack && mst.getSources) { + return CameraRetriever.getCamerasFromMediaStreamTrack(); + } + return CameraRetriever.rejectWithError(); + }; + CameraRetriever.rejectWithError = function () { + var errorMessage = Html5QrcodeStrings.unableToQuerySupportedDevices(); + if (!CameraRetriever.isHttpsOrLocalhost()) { + errorMessage = Html5QrcodeStrings.insecureContextCameraQueryError(); + } + return Promise.reject(errorMessage); + }; + CameraRetriever.isHttpsOrLocalhost = function () { + if (location.protocol === "https:") { + return true; + } + var host = location.host.split(":")[0]; + return host === "127.0.0.1" || host === "localhost"; + }; + CameraRetriever.getCamerasFromMediaDevices = function () { + return __awaiter(this, void 0, void 0, function () { + var closeActiveStreams, mediaStream, devices, results, _i, devices_1, device; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + closeActiveStreams = function (stream) { + var tracks = stream.getVideoTracks(); + for (var _i = 0, tracks_1 = tracks; _i < tracks_1.length; _i++) { + var track = tracks_1[_i]; + track.enabled = false; + track.stop(); + stream.removeTrack(track); + } + }; + return [4, navigator.mediaDevices.getUserMedia({ audio: false, video: true })]; + case 1: + mediaStream = _a.sent(); + return [4, navigator.mediaDevices.enumerateDevices()]; + case 2: + devices = _a.sent(); + results = []; + for (_i = 0, devices_1 = devices; _i < devices_1.length; _i++) { + device = devices_1[_i]; + if (device.kind === "videoinput") { + results.push({ + id: device.deviceId, + label: device.label + }); + } + } + closeActiveStreams(mediaStream); + return [2, results]; + } + }); + }); + }; + CameraRetriever.getCamerasFromMediaStreamTrack = function () { + return new Promise(function (resolve, _) { + var callback = function (sourceInfos) { + var results = []; + for (var _i = 0, sourceInfos_1 = sourceInfos; _i < sourceInfos_1.length; _i++) { + var sourceInfo = sourceInfos_1[_i]; + if (sourceInfo.kind === "video") { + results.push({ + id: sourceInfo.id, + label: sourceInfo.label + }); + } + } + resolve(results); + }; + var mst = MediaStreamTrack; + mst.getSources(callback); + }); + }; + return CameraRetriever; +}()); +export { CameraRetriever }; +//# sourceMappingURL=retriever.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/camera/retriever.js.map b/src/main/node_modules/html5-qrcode/esm/camera/retriever.js.map new file mode 100644 index 0000000000000000000000000000000000000000..65b01bbc8ad8fb263a96876c36d91004b33867e4 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/camera/retriever.js.map @@ -0,0 +1 @@ +{"version":3,"file":"retriever.js","sourceRoot":"","sources":["../../../src/camera/retriever.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGhD;IAAA;IAiFA,CAAC;IA9EiB,wBAAQ,GAAtB;QACI,IAAI,SAAS,CAAC,YAAY,EAAE;YACxB,OAAO,eAAe,CAAC,0BAA0B,EAAE,CAAC;SACvD;QAGD,IAAI,GAAG,GAAQ,gBAAgB,CAAC;QAChC,IAAI,gBAAgB,IAAI,GAAG,CAAC,UAAU,EAAE;YACpC,OAAO,eAAe,CAAC,8BAA8B,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C,WAA4B,EAAP,mBAAO,EAAP,qBAAO,EAAP,IAAO,EAAE;4BAAnB,MAAM;4BACb,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY,EAAE;gCAC9B,OAAO,CAAC,IAAI,CAAC;oCACT,EAAE,EAAE,MAAM,CAAC,QAAQ;oCACnB,KAAK,EAAE,MAAM,CAAC,KAAK;iCACtB,CAAC,CAAC;6BACN;yBACJ;wBACD,kBAAkB,CAAC,WAAW,CAAC,CAAC;wBAChC,WAAO,OAAO,EAAC;;;;KAClB;IAEc,8CAA8B,GAA7C;QAEI,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,CAAC;YAC1B,IAAM,QAAQ,GAAG,UAAC,WAAuB;gBACrC,IAAM,OAAO,GAAwB,EAAE,CAAC;gBACxC,KAAyB,UAAW,EAAX,2BAAW,EAAX,yBAAW,EAAX,IAAW,EAAE;oBAAjC,IAAM,UAAU,oBAAA;oBACjB,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE;wBAC7B,OAAO,CAAC,IAAI,CAAC;4BACT,EAAE,EAAE,UAAU,CAAC,EAAE;4BACjB,KAAK,EAAE,UAAU,CAAC,KAAK;yBAC1B,CAAC,CAAC;qBACN;iBACJ;gBACD,OAAO,CAAC,OAAO,CAAC,CAAC;YACrB,CAAC,CAAA;YAED,IAAI,GAAG,GAAQ,gBAAgB,CAAC;YAChC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACP,CAAC;IACL,sBAAC;AAAD,CAAC,AAjFD,IAiFC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/code-decoder.d.ts b/src/main/node_modules/html5-qrcode/esm/code-decoder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13d5426a74815c3ff33f9221d161b055910a693c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/code-decoder.d.ts @@ -0,0 +1,16 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, Logger, RobustQrcodeDecoderAsync } from "./core"; +export declare class Html5QrcodeShim implements RobustQrcodeDecoderAsync { + private verbose; + private primaryDecoder; + private secondaryDecoder; + private readonly EXECUTIONS_TO_REPORT_PERFORMANCE; + private executions; + private executionResults; + private wasPrimaryDecoderUsedInLastDecode; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, useBarCodeDetectorIfSupported: boolean, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + decodeRobustlyAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private getDecoder; + private possiblyLogPerformance; + possiblyFlushPerformanceReport(): void; +} diff --git a/src/main/node_modules/html5-qrcode/esm/code-decoder.js b/src/main/node_modules/html5-qrcode/esm/code-decoder.js new file mode 100644 index 0000000000000000000000000000000000000000..0715baee891dbbe53e30b432b6bd8ed7d9b58dac --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/code-decoder.js @@ -0,0 +1,138 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +import { ZXingHtml5QrcodeDecoder } from "./zxing-html5-qrcode-decoder"; +import { BarcodeDetectorDelegate } from "./native-bar-code-detector"; +var Html5QrcodeShim = (function () { + function Html5QrcodeShim(requestedFormats, useBarCodeDetectorIfSupported, verbose, logger) { + this.EXECUTIONS_TO_REPORT_PERFORMANCE = 100; + this.executions = 0; + this.executionResults = []; + this.wasPrimaryDecoderUsedInLastDecode = false; + this.verbose = verbose; + if (useBarCodeDetectorIfSupported + && BarcodeDetectorDelegate.isSupported()) { + this.primaryDecoder = new BarcodeDetectorDelegate(requestedFormats, verbose, logger); + this.secondaryDecoder = new ZXingHtml5QrcodeDecoder(requestedFormats, verbose, logger); + } + else { + this.primaryDecoder = new ZXingHtml5QrcodeDecoder(requestedFormats, verbose, logger); + } + } + Html5QrcodeShim.prototype.decodeAsync = function (canvas) { + return __awaiter(this, void 0, void 0, function () { + var startTime; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + startTime = performance.now(); + _a.label = 1; + case 1: + _a.trys.push([1, , 3, 4]); + return [4, this.getDecoder().decodeAsync(canvas)]; + case 2: return [2, _a.sent()]; + case 3: + this.possiblyLogPerformance(startTime); + return [7]; + case 4: return [2]; + } + }); + }); + }; + Html5QrcodeShim.prototype.decodeRobustlyAsync = function (canvas) { + return __awaiter(this, void 0, void 0, function () { + var startTime, error_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + startTime = performance.now(); + _a.label = 1; + case 1: + _a.trys.push([1, 3, 4, 5]); + return [4, this.primaryDecoder.decodeAsync(canvas)]; + case 2: return [2, _a.sent()]; + case 3: + error_1 = _a.sent(); + if (this.secondaryDecoder) { + return [2, this.secondaryDecoder.decodeAsync(canvas)]; + } + throw error_1; + case 4: + this.possiblyLogPerformance(startTime); + return [7]; + case 5: return [2]; + } + }); + }); + }; + Html5QrcodeShim.prototype.getDecoder = function () { + if (!this.secondaryDecoder) { + return this.primaryDecoder; + } + if (this.wasPrimaryDecoderUsedInLastDecode === false) { + this.wasPrimaryDecoderUsedInLastDecode = true; + return this.primaryDecoder; + } + this.wasPrimaryDecoderUsedInLastDecode = false; + return this.secondaryDecoder; + }; + Html5QrcodeShim.prototype.possiblyLogPerformance = function (startTime) { + if (!this.verbose) { + return; + } + var executionTime = performance.now() - startTime; + this.executionResults.push(executionTime); + this.executions++; + this.possiblyFlushPerformanceReport(); + }; + Html5QrcodeShim.prototype.possiblyFlushPerformanceReport = function () { + if (this.executions < this.EXECUTIONS_TO_REPORT_PERFORMANCE) { + return; + } + var sum = 0; + for (var _i = 0, _a = this.executionResults; _i < _a.length; _i++) { + var executionTime = _a[_i]; + sum += executionTime; + } + var mean = sum / this.executionResults.length; + console.log("".concat(mean, " ms for ").concat(this.executionResults.length, " last runs.")); + this.executions = 0; + this.executionResults = []; + }; + return Html5QrcodeShim; +}()); +export { Html5QrcodeShim }; +//# sourceMappingURL=code-decoder.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/code-decoder.js.map b/src/main/node_modules/html5-qrcode/esm/code-decoder.js.map new file mode 100644 index 0000000000000000000000000000000000000000..08ccf35f97b7dd117d3eb8839286c2a869b4ce62 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/code-decoder.js.map @@ -0,0 +1 @@ +{"version":3,"file":"code-decoder.js","sourceRoot":"","sources":["../../src/code-decoder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAOrE;IAWI,yBACI,gBAAoD,EACpD,6BAAsC,EACtC,OAAgB,EAChB,MAAc;QATD,qCAAgC,GAAG,GAAG,CAAC;QAChD,eAAU,GAAW,CAAC,CAAC;QACvB,qBAAgB,GAAkB,EAAE,CAAC;QACrC,sCAAiC,GAAG,KAAK,CAAC;QAO9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAGvB,IAAI,6BAA6B;eACtB,uBAAuB,CAAC,WAAW,EAAE,EAAE;YAC9C,IAAI,CAAC,cAAc,GAAG,IAAI,uBAAuB,CAC7C,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAIvC,IAAI,CAAC,gBAAgB,GAAG,IAAI,uBAAuB,CAC/C,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SAC1C;aAAM;YACH,IAAI,CAAC,cAAc,GAAG,IAAI,uBAAuB,CAC7C,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SAC1C;IACL,CAAC;IAEK,qCAAW,GAAjB,UAAkB,MAAyB;;;;;;wBACnC,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;;;;wBAEvB,WAAM,IAAI,CAAC,UAAU,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,EAAA;4BAAlD,WAAO,SAA2C,EAAC;;wBAEnD,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,CA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,KAAA,IAAI,CAAC,gBAAgB,EAArB,cAAqB,EAArB,IAAqB,EAAE;YAA5C,IAAI,aAAa,SAAA;YAClB,GAAG,IAAI,aAAa,CAAC;SACxB;QACD,IAAI,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC;QAE9C,OAAO,CAAC,GAAG,CAAC,UAAG,IAAI,qBAAW,IAAI,CAAC,gBAAgB,CAAC,MAAM,gBAAa,CAAC,CAAC;QACzE,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC/B,CAAC;IACL,sBAAC;AAAD,CAAC,AApGD,IAoGC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/core.d.ts b/src/main/node_modules/html5-qrcode/esm/core.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d0206d4fcf87446a1161cd3b548b3196d9262be --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/core.d.ts @@ -0,0 +1,105 @@ +export declare enum Html5QrcodeSupportedFormats { + QR_CODE = 0, + AZTEC = 1, + CODABAR = 2, + CODE_39 = 3, + CODE_93 = 4, + CODE_128 = 5, + DATA_MATRIX = 6, + MAXICODE = 7, + ITF = 8, + EAN_13 = 9, + EAN_8 = 10, + PDF_417 = 11, + RSS_14 = 12, + RSS_EXPANDED = 13, + UPC_A = 14, + UPC_E = 15, + UPC_EAN_EXTENSION = 16 +} +export declare enum DecodedTextType { + UNKNOWN = 0, + URL = 1 +} +export declare function isValidHtml5QrcodeSupportedFormats(format: any): boolean; +export declare enum Html5QrcodeScanType { + SCAN_TYPE_CAMERA = 0, + SCAN_TYPE_FILE = 1 +} +export declare class Html5QrcodeConstants { + static GITHUB_PROJECT_URL: string; + static SCAN_DEFAULT_FPS: number; + static DEFAULT_DISABLE_FLIP: boolean; + static DEFAULT_REMEMBER_LAST_CAMERA_USED: boolean; + static DEFAULT_SUPPORTED_SCAN_TYPE: Html5QrcodeScanType[]; +} +export interface QrDimensions { + width: number; + height: number; +} +export type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; +export interface QrBounds extends QrDimensions { + x: number; + y: number; +} +export declare class QrcodeResultFormat { + readonly format: Html5QrcodeSupportedFormats; + readonly formatName: string; + private constructor(); + toString(): string; + static create(format: Html5QrcodeSupportedFormats): QrcodeResultFormat; +} +export interface QrcodeResultDebugData { + decoderName?: string; +} +export interface QrcodeResult { + text: string; + format?: QrcodeResultFormat; + bounds?: QrBounds; + decodedTextType?: DecodedTextType; + debugData?: QrcodeResultDebugData; +} +export interface Html5QrcodeResult { + decodedText: string; + result: QrcodeResult; +} +export declare class Html5QrcodeResultFactory { + static createFromText(decodedText: string): Html5QrcodeResult; + static createFromQrcodeResult(qrcodeResult: QrcodeResult): Html5QrcodeResult; +} +export declare enum Html5QrcodeErrorTypes { + UNKWOWN_ERROR = 0, + IMPLEMENTATION_ERROR = 1, + NO_CODE_FOUND_ERROR = 2 +} +export interface Html5QrcodeError { + errorMessage: string; + type: Html5QrcodeErrorTypes; +} +export declare class Html5QrcodeErrorFactory { + static createFrom(error: any): Html5QrcodeError; +} +export type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; +export type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; +export interface QrcodeDecoderAsync { + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; +} +export interface RobustQrcodeDecoderAsync extends QrcodeDecoderAsync { + decodeRobustlyAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; +} +export interface Logger { + log(message: string): void; + warn(message: string): void; + logError(message: string, isExperimental?: boolean): void; + logErrors(errors: Array<any>): void; +} +export declare class BaseLoggger implements Logger { + private verbose; + constructor(verbose: boolean); + log(message: string): void; + warn(message: string): void; + logError(message: string, isExperimental?: boolean): void; + logErrors(errors: Array<any>): void; +} +export declare function isNullOrUndefined(obj?: any): boolean; +export declare function clip(value: number, minValue: number, maxValue: number): number; diff --git a/src/main/node_modules/html5-qrcode/esm/core.js b/src/main/node_modules/html5-qrcode/esm/core.js new file mode 100644 index 0000000000000000000000000000000000000000..0c45ffa8e18be4a9a052979c51aa597c2f08fef0 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/core.js @@ -0,0 +1,165 @@ +export var Html5QrcodeSupportedFormats; +(function (Html5QrcodeSupportedFormats) { + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["QR_CODE"] = 0] = "QR_CODE"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["AZTEC"] = 1] = "AZTEC"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["CODABAR"] = 2] = "CODABAR"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["CODE_39"] = 3] = "CODE_39"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["CODE_93"] = 4] = "CODE_93"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["CODE_128"] = 5] = "CODE_128"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["DATA_MATRIX"] = 6] = "DATA_MATRIX"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["MAXICODE"] = 7] = "MAXICODE"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["ITF"] = 8] = "ITF"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["EAN_13"] = 9] = "EAN_13"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["EAN_8"] = 10] = "EAN_8"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["PDF_417"] = 11] = "PDF_417"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["RSS_14"] = 12] = "RSS_14"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["RSS_EXPANDED"] = 13] = "RSS_EXPANDED"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["UPC_A"] = 14] = "UPC_A"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["UPC_E"] = 15] = "UPC_E"; + Html5QrcodeSupportedFormats[Html5QrcodeSupportedFormats["UPC_EAN_EXTENSION"] = 16] = "UPC_EAN_EXTENSION"; +})(Html5QrcodeSupportedFormats || (Html5QrcodeSupportedFormats = {})); +var html5QrcodeSupportedFormatsTextMap = new Map([ + [Html5QrcodeSupportedFormats.QR_CODE, "QR_CODE"], + [Html5QrcodeSupportedFormats.AZTEC, "AZTEC"], + [Html5QrcodeSupportedFormats.CODABAR, "CODABAR"], + [Html5QrcodeSupportedFormats.CODE_39, "CODE_39"], + [Html5QrcodeSupportedFormats.CODE_93, "CODE_93"], + [Html5QrcodeSupportedFormats.CODE_128, "CODE_128"], + [Html5QrcodeSupportedFormats.DATA_MATRIX, "DATA_MATRIX"], + [Html5QrcodeSupportedFormats.MAXICODE, "MAXICODE"], + [Html5QrcodeSupportedFormats.ITF, "ITF"], + [Html5QrcodeSupportedFormats.EAN_13, "EAN_13"], + [Html5QrcodeSupportedFormats.EAN_8, "EAN_8"], + [Html5QrcodeSupportedFormats.PDF_417, "PDF_417"], + [Html5QrcodeSupportedFormats.RSS_14, "RSS_14"], + [Html5QrcodeSupportedFormats.RSS_EXPANDED, "RSS_EXPANDED"], + [Html5QrcodeSupportedFormats.UPC_A, "UPC_A"], + [Html5QrcodeSupportedFormats.UPC_E, "UPC_E"], + [Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, "UPC_EAN_EXTENSION"] +]); +export var DecodedTextType; +(function (DecodedTextType) { + DecodedTextType[DecodedTextType["UNKNOWN"] = 0] = "UNKNOWN"; + DecodedTextType[DecodedTextType["URL"] = 1] = "URL"; +})(DecodedTextType || (DecodedTextType = {})); +export function isValidHtml5QrcodeSupportedFormats(format) { + return Object.values(Html5QrcodeSupportedFormats).includes(format); +} +export var Html5QrcodeScanType; +(function (Html5QrcodeScanType) { + Html5QrcodeScanType[Html5QrcodeScanType["SCAN_TYPE_CAMERA"] = 0] = "SCAN_TYPE_CAMERA"; + Html5QrcodeScanType[Html5QrcodeScanType["SCAN_TYPE_FILE"] = 1] = "SCAN_TYPE_FILE"; +})(Html5QrcodeScanType || (Html5QrcodeScanType = {})); +var Html5QrcodeConstants = (function () { + function Html5QrcodeConstants() { + } + Html5QrcodeConstants.GITHUB_PROJECT_URL = "https://github.com/mebjas/html5-qrcode"; + Html5QrcodeConstants.SCAN_DEFAULT_FPS = 2; + Html5QrcodeConstants.DEFAULT_DISABLE_FLIP = false; + Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED = true; + Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE = [ + Html5QrcodeScanType.SCAN_TYPE_CAMERA, + Html5QrcodeScanType.SCAN_TYPE_FILE + ]; + return Html5QrcodeConstants; +}()); +export { Html5QrcodeConstants }; +var QrcodeResultFormat = (function () { + function QrcodeResultFormat(format, formatName) { + this.format = format; + this.formatName = formatName; + } + QrcodeResultFormat.prototype.toString = function () { + return this.formatName; + }; + QrcodeResultFormat.create = function (format) { + if (!html5QrcodeSupportedFormatsTextMap.has(format)) { + throw "".concat(format, " not in html5QrcodeSupportedFormatsTextMap"); + } + return new QrcodeResultFormat(format, html5QrcodeSupportedFormatsTextMap.get(format)); + }; + return QrcodeResultFormat; +}()); +export { QrcodeResultFormat }; +var Html5QrcodeResultFactory = (function () { + function Html5QrcodeResultFactory() { + } + Html5QrcodeResultFactory.createFromText = function (decodedText) { + var qrcodeResult = { + text: decodedText + }; + return { + decodedText: decodedText, + result: qrcodeResult + }; + }; + Html5QrcodeResultFactory.createFromQrcodeResult = function (qrcodeResult) { + return { + decodedText: qrcodeResult.text, + result: qrcodeResult + }; + }; + return Html5QrcodeResultFactory; +}()); +export { Html5QrcodeResultFactory }; +export var Html5QrcodeErrorTypes; +(function (Html5QrcodeErrorTypes) { + Html5QrcodeErrorTypes[Html5QrcodeErrorTypes["UNKWOWN_ERROR"] = 0] = "UNKWOWN_ERROR"; + Html5QrcodeErrorTypes[Html5QrcodeErrorTypes["IMPLEMENTATION_ERROR"] = 1] = "IMPLEMENTATION_ERROR"; + Html5QrcodeErrorTypes[Html5QrcodeErrorTypes["NO_CODE_FOUND_ERROR"] = 2] = "NO_CODE_FOUND_ERROR"; +})(Html5QrcodeErrorTypes || (Html5QrcodeErrorTypes = {})); +var Html5QrcodeErrorFactory = (function () { + function Html5QrcodeErrorFactory() { + } + Html5QrcodeErrorFactory.createFrom = function (error) { + return { + errorMessage: error, + type: Html5QrcodeErrorTypes.UNKWOWN_ERROR + }; + }; + return Html5QrcodeErrorFactory; +}()); +export { Html5QrcodeErrorFactory }; +var BaseLoggger = (function () { + function BaseLoggger(verbose) { + this.verbose = verbose; + } + BaseLoggger.prototype.log = function (message) { + if (this.verbose) { + console.log(message); + } + }; + BaseLoggger.prototype.warn = function (message) { + if (this.verbose) { + console.warn(message); + } + }; + BaseLoggger.prototype.logError = function (message, isExperimental) { + if (this.verbose || isExperimental === true) { + console.error(message); + } + }; + BaseLoggger.prototype.logErrors = function (errors) { + if (errors.length === 0) { + throw "Logger#logError called without arguments"; + } + if (this.verbose) { + console.error(errors); + } + }; + return BaseLoggger; +}()); +export { BaseLoggger }; +export function isNullOrUndefined(obj) { + return (typeof obj === "undefined") || obj === null; +} +export function clip(value, minValue, maxValue) { + if (value > maxValue) { + return maxValue; + } + if (value < minValue) { + return minValue; + } + return value; +} +//# sourceMappingURL=core.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/core.js.map b/src/main/node_modules/html5-qrcode/esm/core.js.map new file mode 100644 index 0000000000000000000000000000000000000000..97bdca26d28336cc8440fe3414e9bba142f2cca1 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/core.js.map @@ -0,0 +1 @@ +{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAaA,MAAM,CAAN,IAAY,2BAkBX;AAlBD,WAAY,2BAA2B;IACnC,mFAAW,CAAA;IACX,+EAAK,CA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B;IACL,CAAC;IAEM,+BAAS,GAAhB,UAAiB,MAAkB;QAC/B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,MAAM,0CAA0C,CAAC;SACpD;QACD,IAAI,IAAI,CAAC,OAAO,EAAE;YAEd,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SACzB;IACL,CAAC;IACL,kBAAC;AAAD,CAAC,AAvCD,IAuCC;;AAID,MAAM,UAAU,iBAAiB,CAAC,GAAS;IACvC,OAAO,CAAC,OAAO,GAAG,KAAK,WAAW,CAAC,IAAI,GAAG,KAAK,IAAI,CAAC;AACxD,CAAC;AAGD,MAAM,UAAU,IAAI,CAAC,KAAa,EAAE,QAAgB,EAAE,QAAgB;IAClE,IAAI,KAAK,GAAG,QAAQ,EAAE;QAClB,OAAO,QAAQ,CAAC;KACnB;IACD,IAAI,KAAK,GAAG,QAAQ,EAAE;QAClB,OAAO,QAAQ,CAAC;KACnB;IAED,OAAO,KAAK,CAAC;AACjB,CAAC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/experimental-features.d.ts b/src/main/node_modules/html5-qrcode/esm/experimental-features.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0413abebd02d9788902f9ad47e60d2673507c5fe --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/experimental-features.d.ts @@ -0,0 +1,3 @@ +export interface ExperimentalFeaturesConfig { + useBarCodeDetectorIfSupported?: boolean | undefined; +} diff --git a/src/main/node_modules/html5-qrcode/esm/experimental-features.js b/src/main/node_modules/html5-qrcode/esm/experimental-features.js new file mode 100644 index 0000000000000000000000000000000000000000..ab918ba3d46babea15495f1c1ac8ccabc46c580d --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/experimental-features.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=experimental-features.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/experimental-features.js.map b/src/main/node_modules/html5-qrcode/esm/experimental-features.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8b8b9dd178d10babd1110d7f0ea70f9b1c95e641 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/experimental-features.js.map @@ -0,0 +1 @@ +{"version":3,"file":"experimental-features.js","sourceRoot":"","sources":["../../src/experimental-features.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/html5-qrcode-scanner.d.ts b/src/main/node_modules/html5-qrcode/esm/html5-qrcode-scanner.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..417175bc07418ec36023c076274aef557b25f42b --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/html5-qrcode-scanner.d.ts @@ -0,0 +1,67 @@ +import { Html5QrcodeScanType, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; +import { Html5QrcodeConfigs, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; +import { Html5QrcodeScannerState } from "./state-manager"; +export interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { + rememberLastUsedCamera?: boolean | undefined; + supportedScanTypes?: Array<Html5QrcodeScanType> | []; + showTorchButtonIfSupported?: boolean | undefined; + showZoomSliderIfSupported?: boolean | undefined; + defaultZoomValueIfSupported?: number | undefined; +} +export declare class Html5QrcodeScanner { + private elementId; + private config; + private verbose; + private currentScanType; + private sectionSwapAllowed; + private persistedDataManager; + private scanTypeSelector; + private logger; + private html5Qrcode; + private qrCodeSuccessCallback; + private qrCodeErrorCallback; + private lastMatchFound; + private cameraScanImage; + private fileScanImage; + private fileSelectionUi; + constructor(elementId: string, config: Html5QrcodeScannerConfig | undefined, verbose: boolean | undefined); + render(qrCodeSuccessCallback: QrcodeSuccessCallback, qrCodeErrorCallback: QrcodeErrorCallback | undefined): void; + pause(shouldPauseVideo?: boolean): void; + resume(): void; + getState(): Html5QrcodeScannerState; + clear(): Promise<void>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + applyVideoConstraints(videoConstaints: MediaTrackConstraints): Promise<void>; + private getHtml5QrcodeOrFail; + private createConfig; + private createBasicLayout; + private resetBasicLayout; + private setupInitialDashboard; + private createHeader; + private createSection; + private createCameraListUi; + private createPermissionButton; + private createPermissionsUi; + private createSectionControlPanel; + private renderFileScanUi; + private renderCameraSelection; + private createSectionSwap; + private startCameraScanIfPermissionExistsOnSwap; + private resetHeaderMessage; + private setHeaderMessage; + private showHideScanTypeSwapLink; + private insertCameraScanImageToScanRegion; + private insertFileScanImageToScanRegion; + private clearScanRegion; + private getDashboardSectionId; + private getDashboardSectionCameraScanRegionId; + private getDashboardSectionSwapLinkId; + private getScanRegionId; + private getDashboardId; + private getHeaderMessageContainerId; + private getCameraPermissionButtonId; + private getCameraScanRegion; + private getDashboardSectionSwapLink; + private getHeaderMessageDiv; +} diff --git a/src/main/node_modules/html5-qrcode/esm/html5-qrcode-scanner.js b/src/main/node_modules/html5-qrcode/esm/html5-qrcode-scanner.js new file mode 100644 index 0000000000000000000000000000000000000000..e55afdda7c3809abbb182661a8bf271b2da62395 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/html5-qrcode-scanner.js @@ -0,0 +1,658 @@ +import { Html5QrcodeConstants, Html5QrcodeScanType, Html5QrcodeErrorFactory, BaseLoggger, isNullOrUndefined, clip, } from "./core"; +import { Html5Qrcode, } from "./html5-qrcode"; +import { Html5QrcodeScannerStrings, } from "./strings"; +import { ASSET_FILE_SCAN, ASSET_CAMERA_SCAN, } from "./image-assets"; +import { PersistedDataManager } from "./storage"; +import { LibraryInfoContainer } from "./ui"; +import { CameraPermissions } from "./camera/permissions"; +import { ScanTypeSelector } from "./ui/scanner/scan-type-selector"; +import { TorchButton } from "./ui/scanner/torch-button"; +import { FileSelectionUi } from "./ui/scanner/file-selection-ui"; +import { BaseUiElementFactory, PublicUiElementIdAndClasses } from "./ui/scanner/base"; +import { CameraSelectionUi } from "./ui/scanner/camera-selection-ui"; +import { CameraZoomUi } from "./ui/scanner/camera-zoom-ui"; +var Html5QrcodeScannerStatus; +(function (Html5QrcodeScannerStatus) { + Html5QrcodeScannerStatus[Html5QrcodeScannerStatus["STATUS_DEFAULT"] = 0] = "STATUS_DEFAULT"; + Html5QrcodeScannerStatus[Html5QrcodeScannerStatus["STATUS_SUCCESS"] = 1] = "STATUS_SUCCESS"; + Html5QrcodeScannerStatus[Html5QrcodeScannerStatus["STATUS_WARNING"] = 2] = "STATUS_WARNING"; + Html5QrcodeScannerStatus[Html5QrcodeScannerStatus["STATUS_REQUESTING_PERMISSION"] = 3] = "STATUS_REQUESTING_PERMISSION"; +})(Html5QrcodeScannerStatus || (Html5QrcodeScannerStatus = {})); +function toHtml5QrcodeCameraScanConfig(config) { + return { + fps: config.fps, + qrbox: config.qrbox, + aspectRatio: config.aspectRatio, + disableFlip: config.disableFlip, + videoConstraints: config.videoConstraints + }; +} +function toHtml5QrcodeFullConfig(config, verbose) { + return { + formatsToSupport: config.formatsToSupport, + useBarCodeDetectorIfSupported: config.useBarCodeDetectorIfSupported, + experimentalFeatures: config.experimentalFeatures, + verbose: verbose + }; +} +var Html5QrcodeScanner = (function () { + function Html5QrcodeScanner(elementId, config, verbose) { + this.lastMatchFound = null; + this.cameraScanImage = null; + this.fileScanImage = null; + this.fileSelectionUi = null; + this.elementId = elementId; + this.config = this.createConfig(config); + this.verbose = verbose === true; + if (!document.getElementById(elementId)) { + throw "HTML Element with id=".concat(elementId, " not found"); + } + this.scanTypeSelector = new ScanTypeSelector(this.config.supportedScanTypes); + this.currentScanType = this.scanTypeSelector.getDefaultScanType(); + this.sectionSwapAllowed = true; + this.logger = new BaseLoggger(this.verbose); + this.persistedDataManager = new PersistedDataManager(); + if (config.rememberLastUsedCamera !== true) { + this.persistedDataManager.reset(); + } + } + Html5QrcodeScanner.prototype.render = function (qrCodeSuccessCallback, qrCodeErrorCallback) { + var _this = this; + this.lastMatchFound = null; + this.qrCodeSuccessCallback + = function (decodedText, result) { + if (qrCodeSuccessCallback) { + qrCodeSuccessCallback(decodedText, result); + } + else { + if (_this.lastMatchFound === decodedText) { + return; + } + _this.lastMatchFound = decodedText; + _this.setHeaderMessage(Html5QrcodeScannerStrings.lastMatch(decodedText), Html5QrcodeScannerStatus.STATUS_SUCCESS); + } + }; + this.qrCodeErrorCallback = + function (errorMessage, error) { + if (qrCodeErrorCallback) { + qrCodeErrorCallback(errorMessage, error); + } + }; + var container = document.getElementById(this.elementId); + if (!container) { + throw "HTML Element with id=".concat(this.elementId, " not found"); + } + container.innerHTML = ""; + this.createBasicLayout(container); + this.html5Qrcode = new Html5Qrcode(this.getScanRegionId(), toHtml5QrcodeFullConfig(this.config, this.verbose)); + }; + Html5QrcodeScanner.prototype.pause = function (shouldPauseVideo) { + if (isNullOrUndefined(shouldPauseVideo) || shouldPauseVideo !== true) { + shouldPauseVideo = false; + } + this.getHtml5QrcodeOrFail().pause(shouldPauseVideo); + }; + Html5QrcodeScanner.prototype.resume = function () { + this.getHtml5QrcodeOrFail().resume(); + }; + Html5QrcodeScanner.prototype.getState = function () { + return this.getHtml5QrcodeOrFail().getState(); + }; + Html5QrcodeScanner.prototype.clear = function () { + var _this = this; + var emptyHtmlContainer = function () { + var mainContainer = document.getElementById(_this.elementId); + if (mainContainer) { + mainContainer.innerHTML = ""; + _this.resetBasicLayout(mainContainer); + } + }; + if (this.html5Qrcode) { + return new Promise(function (resolve, reject) { + if (!_this.html5Qrcode) { + resolve(); + return; + } + if (_this.html5Qrcode.isScanning) { + _this.html5Qrcode.stop().then(function (_) { + if (!_this.html5Qrcode) { + resolve(); + return; + } + _this.html5Qrcode.clear(); + emptyHtmlContainer(); + resolve(); + }).catch(function (error) { + if (_this.verbose) { + _this.logger.logError("Unable to stop qrcode scanner", error); + } + reject(error); + }); + } + else { + _this.html5Qrcode.clear(); + emptyHtmlContainer(); + resolve(); + } + }); + } + return Promise.resolve(); + }; + Html5QrcodeScanner.prototype.getRunningTrackCapabilities = function () { + return this.getHtml5QrcodeOrFail().getRunningTrackCapabilities(); + }; + Html5QrcodeScanner.prototype.getRunningTrackSettings = function () { + return this.getHtml5QrcodeOrFail().getRunningTrackSettings(); + }; + Html5QrcodeScanner.prototype.applyVideoConstraints = function (videoConstaints) { + return this.getHtml5QrcodeOrFail().applyVideoConstraints(videoConstaints); + }; + Html5QrcodeScanner.prototype.getHtml5QrcodeOrFail = function () { + if (!this.html5Qrcode) { + throw "Code scanner not initialized."; + } + return this.html5Qrcode; + }; + Html5QrcodeScanner.prototype.createConfig = function (config) { + if (config) { + if (!config.fps) { + config.fps = Html5QrcodeConstants.SCAN_DEFAULT_FPS; + } + if (config.rememberLastUsedCamera !== (!Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED)) { + config.rememberLastUsedCamera + = Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED; + } + if (!config.supportedScanTypes) { + config.supportedScanTypes + = Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE; + } + return config; + } + return { + fps: Html5QrcodeConstants.SCAN_DEFAULT_FPS, + rememberLastUsedCamera: Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED, + supportedScanTypes: Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE + }; + }; + Html5QrcodeScanner.prototype.createBasicLayout = function (parent) { + parent.style.position = "relative"; + parent.style.padding = "0px"; + parent.style.border = "1px solid silver"; + this.createHeader(parent); + var qrCodeScanRegion = document.createElement("div"); + var scanRegionId = this.getScanRegionId(); + qrCodeScanRegion.id = scanRegionId; + qrCodeScanRegion.style.width = "100%"; + qrCodeScanRegion.style.minHeight = "100px"; + qrCodeScanRegion.style.textAlign = "center"; + parent.appendChild(qrCodeScanRegion); + if (ScanTypeSelector.isCameraScanType(this.currentScanType)) { + this.insertCameraScanImageToScanRegion(); + } + else { + this.insertFileScanImageToScanRegion(); + } + var qrCodeDashboard = document.createElement("div"); + var dashboardId = this.getDashboardId(); + qrCodeDashboard.id = dashboardId; + qrCodeDashboard.style.width = "100%"; + parent.appendChild(qrCodeDashboard); + this.setupInitialDashboard(qrCodeDashboard); + }; + Html5QrcodeScanner.prototype.resetBasicLayout = function (mainContainer) { + mainContainer.style.border = "none"; + }; + Html5QrcodeScanner.prototype.setupInitialDashboard = function (dashboard) { + this.createSection(dashboard); + this.createSectionControlPanel(); + if (this.scanTypeSelector.hasMoreThanOneScanType()) { + this.createSectionSwap(); + } + }; + Html5QrcodeScanner.prototype.createHeader = function (dashboard) { + var header = document.createElement("div"); + header.style.textAlign = "left"; + header.style.margin = "0px"; + dashboard.appendChild(header); + var libraryInfo = new LibraryInfoContainer(); + libraryInfo.renderInto(header); + var headerMessageContainer = document.createElement("div"); + headerMessageContainer.id = this.getHeaderMessageContainerId(); + headerMessageContainer.style.display = "none"; + headerMessageContainer.style.textAlign = "center"; + headerMessageContainer.style.fontSize = "14px"; + headerMessageContainer.style.padding = "2px 10px"; + headerMessageContainer.style.margin = "4px"; + headerMessageContainer.style.borderTop = "1px solid #f6f6f6"; + header.appendChild(headerMessageContainer); + }; + Html5QrcodeScanner.prototype.createSection = function (dashboard) { + var section = document.createElement("div"); + section.id = this.getDashboardSectionId(); + section.style.width = "100%"; + section.style.padding = "10px 0px 10px 0px"; + section.style.textAlign = "left"; + dashboard.appendChild(section); + }; + Html5QrcodeScanner.prototype.createCameraListUi = function (scpCameraScanRegion, requestPermissionContainer, requestPermissionButton) { + var $this = this; + $this.showHideScanTypeSwapLink(false); + $this.setHeaderMessage(Html5QrcodeScannerStrings.cameraPermissionRequesting()); + var createPermissionButtonIfNotExists = function () { + if (!requestPermissionButton) { + $this.createPermissionButton(scpCameraScanRegion, requestPermissionContainer); + } + }; + Html5Qrcode.getCameras().then(function (cameras) { + $this.persistedDataManager.setHasPermission(true); + $this.showHideScanTypeSwapLink(true); + $this.resetHeaderMessage(); + if (cameras && cameras.length > 0) { + scpCameraScanRegion.removeChild(requestPermissionContainer); + $this.renderCameraSelection(cameras); + } + else { + $this.setHeaderMessage(Html5QrcodeScannerStrings.noCameraFound(), Html5QrcodeScannerStatus.STATUS_WARNING); + createPermissionButtonIfNotExists(); + } + }).catch(function (error) { + $this.persistedDataManager.setHasPermission(false); + if (requestPermissionButton) { + requestPermissionButton.disabled = false; + } + else { + createPermissionButtonIfNotExists(); + } + $this.setHeaderMessage(error, Html5QrcodeScannerStatus.STATUS_WARNING); + $this.showHideScanTypeSwapLink(true); + }); + }; + Html5QrcodeScanner.prototype.createPermissionButton = function (scpCameraScanRegion, requestPermissionContainer) { + var $this = this; + var requestPermissionButton = BaseUiElementFactory + .createElement("button", this.getCameraPermissionButtonId()); + requestPermissionButton.innerText + = Html5QrcodeScannerStrings.cameraPermissionTitle(); + requestPermissionButton.addEventListener("click", function () { + requestPermissionButton.disabled = true; + $this.createCameraListUi(scpCameraScanRegion, requestPermissionContainer, requestPermissionButton); + }); + requestPermissionContainer.appendChild(requestPermissionButton); + }; + Html5QrcodeScanner.prototype.createPermissionsUi = function (scpCameraScanRegion, requestPermissionContainer) { + var $this = this; + if (ScanTypeSelector.isCameraScanType(this.currentScanType) + && this.persistedDataManager.hasCameraPermissions()) { + CameraPermissions.hasPermissions().then(function (hasPermissions) { + if (hasPermissions) { + $this.createCameraListUi(scpCameraScanRegion, requestPermissionContainer); + } + else { + $this.persistedDataManager.setHasPermission(false); + $this.createPermissionButton(scpCameraScanRegion, requestPermissionContainer); + } + }).catch(function (_) { + $this.persistedDataManager.setHasPermission(false); + $this.createPermissionButton(scpCameraScanRegion, requestPermissionContainer); + }); + return; + } + this.createPermissionButton(scpCameraScanRegion, requestPermissionContainer); + }; + Html5QrcodeScanner.prototype.createSectionControlPanel = function () { + var section = document.getElementById(this.getDashboardSectionId()); + var sectionControlPanel = document.createElement("div"); + section.appendChild(sectionControlPanel); + var scpCameraScanRegion = document.createElement("div"); + scpCameraScanRegion.id = this.getDashboardSectionCameraScanRegionId(); + scpCameraScanRegion.style.display + = ScanTypeSelector.isCameraScanType(this.currentScanType) + ? "block" : "none"; + sectionControlPanel.appendChild(scpCameraScanRegion); + var requestPermissionContainer = document.createElement("div"); + requestPermissionContainer.style.textAlign = "center"; + scpCameraScanRegion.appendChild(requestPermissionContainer); + if (this.scanTypeSelector.isCameraScanRequired()) { + this.createPermissionsUi(scpCameraScanRegion, requestPermissionContainer); + } + this.renderFileScanUi(sectionControlPanel); + }; + Html5QrcodeScanner.prototype.renderFileScanUi = function (parent) { + var showOnRender = ScanTypeSelector.isFileScanType(this.currentScanType); + var $this = this; + var onFileSelected = function (file) { + if (!$this.html5Qrcode) { + throw "html5Qrcode not defined"; + } + if (!ScanTypeSelector.isFileScanType($this.currentScanType)) { + return; + } + $this.setHeaderMessage(Html5QrcodeScannerStrings.loadingImage()); + $this.html5Qrcode.scanFileV2(file, true) + .then(function (html5qrcodeResult) { + $this.resetHeaderMessage(); + $this.qrCodeSuccessCallback(html5qrcodeResult.decodedText, html5qrcodeResult); + }) + .catch(function (error) { + $this.setHeaderMessage(error, Html5QrcodeScannerStatus.STATUS_WARNING); + $this.qrCodeErrorCallback(error, Html5QrcodeErrorFactory.createFrom(error)); + }); + }; + this.fileSelectionUi = FileSelectionUi.create(parent, showOnRender, onFileSelected); + }; + Html5QrcodeScanner.prototype.renderCameraSelection = function (cameras) { + var _this = this; + var $this = this; + var scpCameraScanRegion = document.getElementById(this.getDashboardSectionCameraScanRegionId()); + scpCameraScanRegion.style.textAlign = "center"; + var cameraZoomUi = CameraZoomUi.create(scpCameraScanRegion, false); + var renderCameraZoomUiIfSupported = function (cameraCapabilities) { + var zoomCapability = cameraCapabilities.zoomFeature(); + if (!zoomCapability.isSupported()) { + return; + } + cameraZoomUi.setOnCameraZoomValueChangeCallback(function (zoomValue) { + zoomCapability.apply(zoomValue); + }); + var defaultZoom = 1; + if (_this.config.defaultZoomValueIfSupported) { + defaultZoom = _this.config.defaultZoomValueIfSupported; + } + defaultZoom = clip(defaultZoom, zoomCapability.min(), zoomCapability.max()); + cameraZoomUi.setValues(zoomCapability.min(), zoomCapability.max(), defaultZoom, zoomCapability.step()); + cameraZoomUi.show(); + }; + var cameraSelectUi = CameraSelectionUi.create(scpCameraScanRegion, cameras); + var cameraActionContainer = document.createElement("span"); + var cameraActionStartButton = BaseUiElementFactory.createElement("button", PublicUiElementIdAndClasses.CAMERA_START_BUTTON_ID); + cameraActionStartButton.innerText + = Html5QrcodeScannerStrings.scanButtonStartScanningText(); + cameraActionContainer.appendChild(cameraActionStartButton); + var cameraActionStopButton = BaseUiElementFactory.createElement("button", PublicUiElementIdAndClasses.CAMERA_STOP_BUTTON_ID); + cameraActionStopButton.innerText + = Html5QrcodeScannerStrings.scanButtonStopScanningText(); + cameraActionStopButton.style.display = "none"; + cameraActionStopButton.disabled = true; + cameraActionContainer.appendChild(cameraActionStopButton); + var torchButton; + var createAndShowTorchButtonIfSupported = function (cameraCapabilities) { + if (!cameraCapabilities.torchFeature().isSupported()) { + if (torchButton) { + torchButton.hide(); + } + return; + } + if (!torchButton) { + torchButton = TorchButton.create(cameraActionContainer, cameraCapabilities.torchFeature(), { display: "none", marginLeft: "5px" }, function (errorMessage) { + $this.setHeaderMessage(errorMessage, Html5QrcodeScannerStatus.STATUS_WARNING); + }); + } + else { + torchButton.updateTorchCapability(cameraCapabilities.torchFeature()); + } + torchButton.show(); + }; + scpCameraScanRegion.appendChild(cameraActionContainer); + var resetCameraActionStartButton = function (shouldShow) { + if (!shouldShow) { + cameraActionStartButton.style.display = "none"; + } + cameraActionStartButton.innerText + = Html5QrcodeScannerStrings + .scanButtonStartScanningText(); + cameraActionStartButton.style.opacity = "1"; + cameraActionStartButton.disabled = false; + if (shouldShow) { + cameraActionStartButton.style.display = "inline-block"; + } + }; + cameraActionStartButton.addEventListener("click", function (_) { + cameraActionStartButton.innerText + = Html5QrcodeScannerStrings.scanButtonScanningStarting(); + cameraSelectUi.disable(); + cameraActionStartButton.disabled = true; + cameraActionStartButton.style.opacity = "0.5"; + if (_this.scanTypeSelector.hasMoreThanOneScanType()) { + $this.showHideScanTypeSwapLink(false); + } + $this.resetHeaderMessage(); + var cameraId = cameraSelectUi.getValue(); + $this.persistedDataManager.setLastUsedCameraId(cameraId); + $this.html5Qrcode.start(cameraId, toHtml5QrcodeCameraScanConfig($this.config), $this.qrCodeSuccessCallback, $this.qrCodeErrorCallback) + .then(function (_) { + cameraActionStopButton.disabled = false; + cameraActionStopButton.style.display = "inline-block"; + resetCameraActionStartButton(false); + var cameraCapabilities = $this.html5Qrcode.getRunningTrackCameraCapabilities(); + if (_this.config.showTorchButtonIfSupported === true) { + createAndShowTorchButtonIfSupported(cameraCapabilities); + } + if (_this.config.showZoomSliderIfSupported === true) { + renderCameraZoomUiIfSupported(cameraCapabilities); + } + }) + .catch(function (error) { + $this.showHideScanTypeSwapLink(true); + cameraSelectUi.enable(); + resetCameraActionStartButton(true); + $this.setHeaderMessage(error, Html5QrcodeScannerStatus.STATUS_WARNING); + }); + }); + if (cameraSelectUi.hasSingleItem()) { + cameraActionStartButton.click(); + } + cameraActionStopButton.addEventListener("click", function (_) { + if (!$this.html5Qrcode) { + throw "html5Qrcode not defined"; + } + cameraActionStopButton.disabled = true; + $this.html5Qrcode.stop() + .then(function (_) { + if (_this.scanTypeSelector.hasMoreThanOneScanType()) { + $this.showHideScanTypeSwapLink(true); + } + cameraSelectUi.enable(); + cameraActionStartButton.disabled = false; + cameraActionStopButton.style.display = "none"; + cameraActionStartButton.style.display = "inline-block"; + if (torchButton) { + torchButton.reset(); + torchButton.hide(); + } + cameraZoomUi.removeOnCameraZoomValueChangeCallback(); + cameraZoomUi.hide(); + $this.insertCameraScanImageToScanRegion(); + }).catch(function (error) { + cameraActionStopButton.disabled = false; + $this.setHeaderMessage(error, Html5QrcodeScannerStatus.STATUS_WARNING); + }); + }); + if ($this.persistedDataManager.getLastUsedCameraId()) { + var cameraId = $this.persistedDataManager.getLastUsedCameraId(); + if (cameraSelectUi.hasValue(cameraId)) { + cameraSelectUi.setValue(cameraId); + cameraActionStartButton.click(); + } + else { + $this.persistedDataManager.resetLastUsedCameraId(); + } + } + }; + Html5QrcodeScanner.prototype.createSectionSwap = function () { + var $this = this; + var TEXT_IF_CAMERA_SCAN_SELECTED = Html5QrcodeScannerStrings.textIfCameraScanSelected(); + var TEXT_IF_FILE_SCAN_SELECTED = Html5QrcodeScannerStrings.textIfFileScanSelected(); + var section = document.getElementById(this.getDashboardSectionId()); + var switchContainer = document.createElement("div"); + switchContainer.style.textAlign = "center"; + var switchScanTypeLink = BaseUiElementFactory.createElement("span", this.getDashboardSectionSwapLinkId()); + switchScanTypeLink.style.textDecoration = "underline"; + switchScanTypeLink.style.cursor = "pointer"; + switchScanTypeLink.innerText + = ScanTypeSelector.isCameraScanType(this.currentScanType) + ? TEXT_IF_CAMERA_SCAN_SELECTED : TEXT_IF_FILE_SCAN_SELECTED; + switchScanTypeLink.addEventListener("click", function () { + if (!$this.sectionSwapAllowed) { + if ($this.verbose) { + $this.logger.logError("Section swap called when not allowed"); + } + return; + } + $this.resetHeaderMessage(); + $this.fileSelectionUi.resetValue(); + $this.sectionSwapAllowed = false; + if (ScanTypeSelector.isCameraScanType($this.currentScanType)) { + $this.clearScanRegion(); + $this.getCameraScanRegion().style.display = "none"; + $this.fileSelectionUi.show(); + switchScanTypeLink.innerText = TEXT_IF_FILE_SCAN_SELECTED; + $this.currentScanType = Html5QrcodeScanType.SCAN_TYPE_FILE; + $this.insertFileScanImageToScanRegion(); + } + else { + $this.clearScanRegion(); + $this.getCameraScanRegion().style.display = "block"; + $this.fileSelectionUi.hide(); + switchScanTypeLink.innerText = TEXT_IF_CAMERA_SCAN_SELECTED; + $this.currentScanType = Html5QrcodeScanType.SCAN_TYPE_CAMERA; + $this.insertCameraScanImageToScanRegion(); + $this.startCameraScanIfPermissionExistsOnSwap(); + } + $this.sectionSwapAllowed = true; + }); + switchContainer.appendChild(switchScanTypeLink); + section.appendChild(switchContainer); + }; + Html5QrcodeScanner.prototype.startCameraScanIfPermissionExistsOnSwap = function () { + var _this = this; + var $this = this; + if (this.persistedDataManager.hasCameraPermissions()) { + CameraPermissions.hasPermissions().then(function (hasPermissions) { + if (hasPermissions) { + var permissionButton = document.getElementById($this.getCameraPermissionButtonId()); + if (!permissionButton) { + _this.logger.logError("Permission button not found, fail;"); + throw "Permission button not found"; + } + permissionButton.click(); + } + else { + $this.persistedDataManager.setHasPermission(false); + } + }).catch(function (_) { + $this.persistedDataManager.setHasPermission(false); + }); + return; + } + }; + Html5QrcodeScanner.prototype.resetHeaderMessage = function () { + var messageDiv = document.getElementById(this.getHeaderMessageContainerId()); + messageDiv.style.display = "none"; + }; + Html5QrcodeScanner.prototype.setHeaderMessage = function (messageText, scannerStatus) { + if (!scannerStatus) { + scannerStatus = Html5QrcodeScannerStatus.STATUS_DEFAULT; + } + var messageDiv = this.getHeaderMessageDiv(); + messageDiv.innerText = messageText; + messageDiv.style.display = "block"; + switch (scannerStatus) { + case Html5QrcodeScannerStatus.STATUS_SUCCESS: + messageDiv.style.background = "rgba(106, 175, 80, 0.26)"; + messageDiv.style.color = "#477735"; + break; + case Html5QrcodeScannerStatus.STATUS_WARNING: + messageDiv.style.background = "rgba(203, 36, 49, 0.14)"; + messageDiv.style.color = "#cb2431"; + break; + case Html5QrcodeScannerStatus.STATUS_DEFAULT: + default: + messageDiv.style.background = "rgba(0, 0, 0, 0)"; + messageDiv.style.color = "rgb(17, 17, 17)"; + break; + } + }; + Html5QrcodeScanner.prototype.showHideScanTypeSwapLink = function (shouldDisplay) { + if (this.scanTypeSelector.hasMoreThanOneScanType()) { + if (shouldDisplay !== true) { + shouldDisplay = false; + } + this.sectionSwapAllowed = shouldDisplay; + this.getDashboardSectionSwapLink().style.display + = shouldDisplay ? "inline-block" : "none"; + } + }; + Html5QrcodeScanner.prototype.insertCameraScanImageToScanRegion = function () { + var $this = this; + var qrCodeScanRegion = document.getElementById(this.getScanRegionId()); + if (this.cameraScanImage) { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild(this.cameraScanImage); + return; + } + this.cameraScanImage = new Image; + this.cameraScanImage.onload = function (_) { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild($this.cameraScanImage); + }; + this.cameraScanImage.width = 64; + this.cameraScanImage.style.opacity = "0.8"; + this.cameraScanImage.src = ASSET_CAMERA_SCAN; + this.cameraScanImage.alt = Html5QrcodeScannerStrings.cameraScanAltText(); + }; + Html5QrcodeScanner.prototype.insertFileScanImageToScanRegion = function () { + var $this = this; + var qrCodeScanRegion = document.getElementById(this.getScanRegionId()); + if (this.fileScanImage) { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild(this.fileScanImage); + return; + } + this.fileScanImage = new Image; + this.fileScanImage.onload = function (_) { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild($this.fileScanImage); + }; + this.fileScanImage.width = 64; + this.fileScanImage.style.opacity = "0.8"; + this.fileScanImage.src = ASSET_FILE_SCAN; + this.fileScanImage.alt = Html5QrcodeScannerStrings.fileScanAltText(); + }; + Html5QrcodeScanner.prototype.clearScanRegion = function () { + var qrCodeScanRegion = document.getElementById(this.getScanRegionId()); + qrCodeScanRegion.innerHTML = ""; + }; + Html5QrcodeScanner.prototype.getDashboardSectionId = function () { + return "".concat(this.elementId, "__dashboard_section"); + }; + Html5QrcodeScanner.prototype.getDashboardSectionCameraScanRegionId = function () { + return "".concat(this.elementId, "__dashboard_section_csr"); + }; + Html5QrcodeScanner.prototype.getDashboardSectionSwapLinkId = function () { + return PublicUiElementIdAndClasses.SCAN_TYPE_CHANGE_ANCHOR_ID; + }; + Html5QrcodeScanner.prototype.getScanRegionId = function () { + return "".concat(this.elementId, "__scan_region"); + }; + Html5QrcodeScanner.prototype.getDashboardId = function () { + return "".concat(this.elementId, "__dashboard"); + }; + Html5QrcodeScanner.prototype.getHeaderMessageContainerId = function () { + return "".concat(this.elementId, "__header_message"); + }; + Html5QrcodeScanner.prototype.getCameraPermissionButtonId = function () { + return PublicUiElementIdAndClasses.CAMERA_PERMISSION_BUTTON_ID; + }; + Html5QrcodeScanner.prototype.getCameraScanRegion = function () { + return document.getElementById(this.getDashboardSectionCameraScanRegionId()); + }; + Html5QrcodeScanner.prototype.getDashboardSectionSwapLink = function () { + return document.getElementById(this.getDashboardSectionSwapLinkId()); + }; + Html5QrcodeScanner.prototype.getHeaderMessageDiv = function () { + return document.getElementById(this.getHeaderMessageContainerId()); + }; + return Html5QrcodeScanner; +}()); +export { Html5QrcodeScanner }; +//# sourceMappingURL=html5-qrcode-scanner.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/html5-qrcode-scanner.js.map b/src/main/node_modules/html5-qrcode/esm/html5-qrcode-scanner.js.map new file mode 100644 index 0000000000000000000000000000000000000000..d4b0249de4479cbb92807c64f706bac3b7cfb01b --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/html5-qrcode-scanner.js.map @@ -0,0 +1 @@ +{"version":3,"file":"html5-qrcode-scanner.js","sourceRoot":"","sources":["../../src/html5-qrcode-scanner.ts"],"names":[],"mappings":"AAUA,OAAO,EACH,oBAAoB,EACpB,mBAAmB,EAKnB,uBAAuB,EACvB,WAAW,EAEX,iBAAiB,EACjB,IAAI,GACP,MAAM,QAAQ,CAAC;AAMhB,OAAO,EACH,WAAW,GAId,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,yBAAyB,GAC5B,MAAM,WAAW,CAAC;AAEnB,OAAO,EACH,eAAe,EACf,iBAAiB,GACpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,oBAAoB,EACvB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACH,oBAAoB,EACvB,MAAM,MAAM,CAAC;AAEd,OAAO,EACL,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EACH,eAAe,EAElB,MAAM,gCAAgC,CAAC;AAExC,OAA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C5C,IAAI,CAAC,eAAe,EAAE,CAAE,CAAC;QAC7B,gBAAgB,CAAC,SAAS,GAAG,EAAE,CAAC;IACpC,CAAC;IAGO,kDAAqB,GAA7B;QACI,OAAO,UAAG,IAAI,CAAC,SAAS,wBAAqB,CAAC;IAClD,CAAC;IAEO,kEAAqC,GAA7C;QACI,OAAO,UAAG,IAAI,CAAC,SAAS,4BAAyB,CAAC;IACtD,CAAC;IAEO,0DAA6B,GAArC;QACI,OAAO,2BAA2B,CAAC,0BAA0B,CAAC;IAClE,CAAC;IAEO,4CAAe,GAAvB;QACI,OAAO,UAAG,IAAI,CAAC,SAAS,kBAAe,CAAC;IAC5C,CAAC;IAEO,2CAAc,GAAtB;QACI,OAAO,UAAG,IAAI,CAAC,SAAS,gBAAa,CAAC;IAC1C,CAAC;IAEO,wDAA2B,GAAnC;QACI,OAAO,UAAG,IAAI,CAAC,SAAS,qBAAkB,CAAC;IAC/C,CAAC;IAEO,wDAA2B,GAAnC;QACI,OAAO,2BAA2B,CAAC,2BAA2B,CAAC;IACnE,CAAC;IAEO,gDAAmB,GAA3B;QACI,OAAO,QAAQ,CAAC,cAAc,CAC1B,IAAI,CAAC,qCAAqC,EAAE,CAAE,CAAC;IACvD,CAAC;IAEO,wDAA2B,GAAnC;QACI,OAAO,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,6BAA6B,EAAE,CAAE,CAAC;IAC1E,CAAC;IAEO,gDAAmB,GAA3B;QACI,OAAO,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAE,CAAC;IACxE,CAAC;IAGL,yBAAC;AAAD,CAAC,AA97BD,IA87BC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/html5-qrcode.d.ts b/src/main/node_modules/html5-qrcode/esm/html5-qrcode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e576933e30835c6b726b5e90faa67d6f3721a3a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/html5-qrcode.d.ts @@ -0,0 +1,75 @@ +import { QrcodeErrorCallback, QrcodeSuccessCallback, Html5QrcodeSupportedFormats, Html5QrcodeResult, QrDimensions, QrDimensionFunction } from "./core"; +import { CameraDevice, CameraCapabilities } from "./camera/core"; +import { ExperimentalFeaturesConfig } from "./experimental-features"; +import { Html5QrcodeScannerState } from "./state-manager"; +export interface Html5QrcodeConfigs { + formatsToSupport?: Array<Html5QrcodeSupportedFormats> | undefined; + useBarCodeDetectorIfSupported?: boolean | undefined; + experimentalFeatures?: ExperimentalFeaturesConfig | undefined; +} +export interface Html5QrcodeFullConfig extends Html5QrcodeConfigs { + verbose: boolean | undefined; +} +export interface Html5QrcodeCameraScanConfig { + fps: number | undefined; + qrbox?: number | QrDimensions | QrDimensionFunction | undefined; + aspectRatio?: number | undefined; + disableFlip?: boolean | undefined; + videoConstraints?: MediaTrackConstraints | undefined; +} +export declare class Html5Qrcode { + private readonly logger; + private readonly elementId; + private readonly verbose; + private readonly qrcode; + private shouldScan; + private element; + private canvasElement; + private scannerPausedUiElement; + private hasBorderShaders; + private borderShaders; + private qrMatch; + private renderedCamera; + private foreverScanTimeout; + private qrRegion; + private context; + private lastScanImageFile; + private stateManagerProxy; + isScanning: boolean; + constructor(elementId: string, configOrVerbosityFlag?: boolean | Html5QrcodeFullConfig | undefined); + start(cameraIdOrConfig: string | MediaTrackConstraints, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; + pause(shouldPauseVideo?: boolean): void; + resume(): void; + getState(): Html5QrcodeScannerState; + stop(): Promise<void>; + scanFile(imageFile: File, showImage?: boolean): Promise<string>; + scanFileV2(imageFile: File, showImage?: boolean): Promise<Html5QrcodeResult>; + clear(): void; + static getCameras(): Promise<Array<CameraDevice>>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + getRunningTrackCameraCapabilities(): CameraCapabilities; + applyVideoConstraints(videoConstaints: MediaTrackConstraints): Promise<void>; + private getRenderedCameraOrFail; + private getSupportedFormats; + private getUseBarCodeDetectorIfSupported; + private validateQrboxSize; + private validateQrboxConfig; + private toQrdimensions; + private setupUi; + private createScannerPausedUiElement; + private scanContext; + private foreverScan; + private createVideoConstraints; + private computeCanvasDrawConfig; + private clearElement; + private possiblyUpdateShaders; + private possiblyCloseLastScanImageFile; + private createCanvasElement; + private getShadedRegionBounds; + private possiblyInsertShadingElement; + private insertShaderBorders; + private showPausedState; + private hidePausedState; + private getTimeoutFps; +} diff --git a/src/main/node_modules/html5-qrcode/esm/html5-qrcode.js b/src/main/node_modules/html5-qrcode/esm/html5-qrcode.js new file mode 100644 index 0000000000000000000000000000000000000000..b8bc86940ce90fceb8b0b6bb7fc71e4542dbdbcc --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/html5-qrcode.js @@ -0,0 +1,840 @@ +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +import { BaseLoggger, Html5QrcodeResultFactory, Html5QrcodeErrorFactory, Html5QrcodeSupportedFormats, isValidHtml5QrcodeSupportedFormats, Html5QrcodeConstants, isNullOrUndefined } from "./core"; +import { Html5QrcodeStrings } from "./strings"; +import { VideoConstraintsUtil } from "./utils"; +import { Html5QrcodeShim } from "./code-decoder"; +import { CameraFactory } from "./camera/factories"; +import { CameraRetriever } from "./camera/retriever"; +import { StateManagerFactory, Html5QrcodeScannerState } from "./state-manager"; +var Constants = (function (_super) { + __extends(Constants, _super); + function Constants() { + return _super !== null && _super.apply(this, arguments) || this; + } + Constants.DEFAULT_WIDTH = 300; + Constants.DEFAULT_WIDTH_OFFSET = 2; + Constants.FILE_SCAN_MIN_HEIGHT = 300; + Constants.FILE_SCAN_HIDDEN_CANVAS_PADDING = 100; + Constants.MIN_QR_BOX_SIZE = 50; + Constants.SHADED_LEFT = 1; + Constants.SHADED_RIGHT = 2; + Constants.SHADED_TOP = 3; + Constants.SHADED_BOTTOM = 4; + Constants.SHADED_REGION_ELEMENT_ID = "qr-shaded-region"; + Constants.VERBOSE = false; + Constants.BORDER_SHADER_DEFAULT_COLOR = "#ffffff"; + Constants.BORDER_SHADER_MATCH_COLOR = "rgb(90, 193, 56)"; + return Constants; +}(Html5QrcodeConstants)); +var InternalHtml5QrcodeConfig = (function () { + function InternalHtml5QrcodeConfig(config, logger) { + this.logger = logger; + this.fps = Constants.SCAN_DEFAULT_FPS; + if (!config) { + this.disableFlip = Constants.DEFAULT_DISABLE_FLIP; + } + else { + if (config.fps) { + this.fps = config.fps; + } + this.disableFlip = config.disableFlip === true; + this.qrbox = config.qrbox; + this.aspectRatio = config.aspectRatio; + this.videoConstraints = config.videoConstraints; + } + } + InternalHtml5QrcodeConfig.prototype.isMediaStreamConstraintsValid = function () { + if (!this.videoConstraints) { + this.logger.logError("Empty videoConstraints", true); + return false; + } + return VideoConstraintsUtil.isMediaStreamConstraintsValid(this.videoConstraints, this.logger); + }; + InternalHtml5QrcodeConfig.prototype.isShadedBoxEnabled = function () { + return !isNullOrUndefined(this.qrbox); + }; + InternalHtml5QrcodeConfig.create = function (config, logger) { + return new InternalHtml5QrcodeConfig(config, logger); + }; + return InternalHtml5QrcodeConfig; +}()); +var Html5Qrcode = (function () { + function Html5Qrcode(elementId, configOrVerbosityFlag) { + 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 = false; + if (!document.getElementById(elementId)) { + throw "HTML Element with id=".concat(elementId, " not found"); + } + this.elementId = elementId; + this.verbose = false; + var experimentalFeatureConfig; + var configObject; + if (typeof configOrVerbosityFlag == "boolean") { + this.verbose = configOrVerbosityFlag === true; + } + else if (configOrVerbosityFlag) { + configObject = configOrVerbosityFlag; + this.verbose = configObject.verbose === true; + experimentalFeatureConfig = configObject.experimentalFeatures; + } + this.logger = new BaseLoggger(this.verbose); + this.qrcode = new Html5QrcodeShim(this.getSupportedFormats(configOrVerbosityFlag), this.getUseBarCodeDetectorIfSupported(configObject), this.verbose, this.logger); + this.foreverScanTimeout; + this.shouldScan = true; + this.stateManagerProxy = StateManagerFactory.create(); + } + Html5Qrcode.prototype.start = function (cameraIdOrConfig, configuration, qrCodeSuccessCallback, qrCodeErrorCallback) { + var _this = this; + if (!cameraIdOrConfig) { + throw "cameraIdOrConfig is required"; + } + if (!qrCodeSuccessCallback + || typeof qrCodeSuccessCallback != "function") { + throw "qrCodeSuccessCallback is required and should be a function."; + } + var qrCodeErrorCallbackInternal; + if (qrCodeErrorCallback) { + qrCodeErrorCallbackInternal = qrCodeErrorCallback; + } + else { + qrCodeErrorCallbackInternal + = this.verbose ? this.logger.log : function () { }; + } + var internalConfig = InternalHtml5QrcodeConfig.create(configuration, this.logger); + this.clearElement(); + var videoConstraintsAvailableAndValid = false; + if (internalConfig.videoConstraints) { + if (!internalConfig.isMediaStreamConstraintsValid()) { + this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, " + + "it will be ignored.'", true); + } + else { + videoConstraintsAvailableAndValid = true; + } + } + var areVideoConstraintsEnabled = videoConstraintsAvailableAndValid; + var element = document.getElementById(this.elementId); + var rootElementWidth = element.clientWidth + ? element.clientWidth : Constants.DEFAULT_WIDTH; + element.style.position = "relative"; + this.shouldScan = true; + this.element = element; + var $this = this; + var toScanningStateChangeTransaction = this.stateManagerProxy.startTransition(Html5QrcodeScannerState.SCANNING); + return new Promise(function (resolve, reject) { + var videoConstraints = areVideoConstraintsEnabled + ? internalConfig.videoConstraints + : $this.createVideoConstraints(cameraIdOrConfig); + if (!videoConstraints) { + toScanningStateChangeTransaction.cancel(); + reject("videoConstraints should be defined"); + return; + } + var cameraRenderingOptions = {}; + if (!areVideoConstraintsEnabled || internalConfig.aspectRatio) { + cameraRenderingOptions.aspectRatio = internalConfig.aspectRatio; + } + var renderingCallbacks = { + onRenderSurfaceReady: function (viewfinderWidth, viewfinderHeight) { + $this.setupUi(viewfinderWidth, viewfinderHeight, internalConfig); + $this.isScanning = true; + $this.foreverScan(internalConfig, qrCodeSuccessCallback, qrCodeErrorCallbackInternal); + } + }; + CameraFactory.failIfNotSupported().then(function (factory) { + factory.create(videoConstraints).then(function (camera) { + return camera.render(_this.element, cameraRenderingOptions, renderingCallbacks) + .then(function (renderedCamera) { + $this.renderedCamera = renderedCamera; + toScanningStateChangeTransaction.execute(); + resolve(null); + }) + .catch(function (error) { + toScanningStateChangeTransaction.cancel(); + reject(error); + }); + }).catch(function (error) { + toScanningStateChangeTransaction.cancel(); + reject(Html5QrcodeStrings.errorGettingUserMedia(error)); + }); + }).catch(function (_) { + toScanningStateChangeTransaction.cancel(); + reject(Html5QrcodeStrings.cameraStreamingNotSupported()); + }); + }); + }; + Html5Qrcode.prototype.pause = function (shouldPauseVideo) { + if (!this.stateManagerProxy.isStrictlyScanning()) { + throw "Cannot pause, scanner is not scanning."; + } + this.stateManagerProxy.directTransition(Html5QrcodeScannerState.PAUSED); + this.showPausedState(); + if (isNullOrUndefined(shouldPauseVideo) || shouldPauseVideo !== true) { + shouldPauseVideo = false; + } + if (shouldPauseVideo && this.renderedCamera) { + this.renderedCamera.pause(); + } + }; + Html5Qrcode.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 $this = this; + var transitionToScanning = function () { + $this.stateManagerProxy.directTransition(Html5QrcodeScannerState.SCANNING); + $this.hidePausedState(); + }; + if (!this.renderedCamera.isPaused()) { + transitionToScanning(); + return; + } + this.renderedCamera.resume(function () { + transitionToScanning(); + }); + }; + Html5Qrcode.prototype.getState = function () { + return this.stateManagerProxy.getState(); + }; + Html5Qrcode.prototype.stop = function () { + var _this = this; + if (!this.stateManagerProxy.isScanning()) { + throw "Cannot stop, scanner is not running or paused."; + } + var toStoppedStateTransaction = this.stateManagerProxy.startTransition(Html5QrcodeScannerState.NOT_STARTED); + this.shouldScan = false; + if (this.foreverScanTimeout) { + clearTimeout(this.foreverScanTimeout); + } + var removeQrRegion = function () { + if (!_this.element) { + return; + } + var childElement = document.getElementById(Constants.SHADED_REGION_ELEMENT_ID); + if (childElement) { + _this.element.removeChild(childElement); + } + }; + var $this = this; + return this.renderedCamera.close().then(function () { + $this.renderedCamera = null; + if ($this.element) { + $this.element.removeChild($this.canvasElement); + $this.canvasElement = null; + } + removeQrRegion(); + if ($this.qrRegion) { + $this.qrRegion = null; + } + if ($this.context) { + $this.context = null; + } + toStoppedStateTransaction.execute(); + $this.hidePausedState(); + $this.isScanning = false; + return Promise.resolve(); + }); + }; + Html5Qrcode.prototype.scanFile = function (imageFile, showImage) { + return this.scanFileV2(imageFile, showImage) + .then(function (html5qrcodeResult) { return html5qrcodeResult.decodedText; }); + }; + Html5Qrcode.prototype.scanFileV2 = function (imageFile, showImage) { + var _this = this; + if (!imageFile || !(imageFile instanceof File)) { + throw "imageFile argument is mandatory and should be instance " + + "of File. Use 'event.target.files[0]'."; + } + if (isNullOrUndefined(showImage)) { + showImage = true; + } + if (!this.stateManagerProxy.canScanFile()) { + throw "Cannot start file scan - ongoing camera scan"; + } + return new Promise(function (resolve, reject) { + _this.possiblyCloseLastScanImageFile(); + _this.clearElement(); + _this.lastScanImageFile = URL.createObjectURL(imageFile); + var inputImage = new Image; + inputImage.onload = function () { + var imageWidth = inputImage.width; + var imageHeight = inputImage.height; + var element = document.getElementById(_this.elementId); + var containerWidth = element.clientWidth + ? element.clientWidth : Constants.DEFAULT_WIDTH; + var containerHeight = Math.max(element.clientHeight ? element.clientHeight : imageHeight, Constants.FILE_SCAN_MIN_HEIGHT); + var config = _this.computeCanvasDrawConfig(imageWidth, imageHeight, containerWidth, containerHeight); + if (showImage) { + var visibleCanvas = _this.createCanvasElement(containerWidth, containerHeight, "qr-canvas-visible"); + visibleCanvas.style.display = "inline-block"; + element.appendChild(visibleCanvas); + var context_1 = visibleCanvas.getContext("2d"); + if (!context_1) { + throw "Unable to get 2d context from canvas"; + } + context_1.canvas.width = containerWidth; + context_1.canvas.height = containerHeight; + context_1.drawImage(inputImage, 0, 0, imageWidth, imageHeight, config.x, config.y, config.width, config.height); + } + var padding = Constants.FILE_SCAN_HIDDEN_CANVAS_PADDING; + var hiddenImageWidth = Math.max(inputImage.width, config.width); + var hiddenImageHeight = Math.max(inputImage.height, config.height); + var hiddenCanvasWidth = hiddenImageWidth + 2 * padding; + var hiddenCanvasHeight = hiddenImageHeight + 2 * padding; + var hiddenCanvas = _this.createCanvasElement(hiddenCanvasWidth, hiddenCanvasHeight); + element.appendChild(hiddenCanvas); + var context = hiddenCanvas.getContext("2d"); + if (!context) { + throw "Unable to get 2d context from canvas"; + } + context.canvas.width = hiddenCanvasWidth; + context.canvas.height = hiddenCanvasHeight; + context.drawImage(inputImage, 0, 0, imageWidth, imageHeight, padding, padding, hiddenImageWidth, hiddenImageHeight); + try { + _this.qrcode.decodeRobustlyAsync(hiddenCanvas) + .then(function (result) { + resolve(Html5QrcodeResultFactory.createFromQrcodeResult(result)); + }) + .catch(reject); + } + catch (exception) { + reject("QR code parse error, error = ".concat(exception)); + } + }; + inputImage.onerror = reject; + inputImage.onabort = reject; + inputImage.onstalled = reject; + inputImage.onsuspend = reject; + inputImage.src = URL.createObjectURL(imageFile); + }); + }; + Html5Qrcode.prototype.clear = function () { + this.clearElement(); + }; + Html5Qrcode.getCameras = function () { + return CameraRetriever.retrieve(); + }; + Html5Qrcode.prototype.getRunningTrackCapabilities = function () { + return this.getRenderedCameraOrFail().getRunningTrackCapabilities(); + }; + Html5Qrcode.prototype.getRunningTrackSettings = function () { + return this.getRenderedCameraOrFail().getRunningTrackSettings(); + }; + Html5Qrcode.prototype.getRunningTrackCameraCapabilities = function () { + return this.getRenderedCameraOrFail().getCapabilities(); + }; + Html5Qrcode.prototype.applyVideoConstraints = function (videoConstaints) { + if (!videoConstaints) { + throw "videoConstaints is required argument."; + } + else if (!VideoConstraintsUtil.isMediaStreamConstraintsValid(videoConstaints, this.logger)) { + throw "invalid videoConstaints passed, check logs for more details"; + } + return this.getRenderedCameraOrFail().applyVideoConstraints(videoConstaints); + }; + Html5Qrcode.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; + }; + Html5Qrcode.prototype.getSupportedFormats = function (configOrVerbosityFlag) { + var allFormats = [ + Html5QrcodeSupportedFormats.QR_CODE, + Html5QrcodeSupportedFormats.AZTEC, + Html5QrcodeSupportedFormats.CODABAR, + Html5QrcodeSupportedFormats.CODE_39, + Html5QrcodeSupportedFormats.CODE_93, + Html5QrcodeSupportedFormats.CODE_128, + Html5QrcodeSupportedFormats.DATA_MATRIX, + Html5QrcodeSupportedFormats.MAXICODE, + Html5QrcodeSupportedFormats.ITF, + Html5QrcodeSupportedFormats.EAN_13, + Html5QrcodeSupportedFormats.EAN_8, + Html5QrcodeSupportedFormats.PDF_417, + Html5QrcodeSupportedFormats.RSS_14, + Html5QrcodeSupportedFormats.RSS_EXPANDED, + Html5QrcodeSupportedFormats.UPC_A, + Html5QrcodeSupportedFormats.UPC_E, + Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, + ]; + if (!configOrVerbosityFlag + || typeof configOrVerbosityFlag == "boolean") { + return allFormats; + } + if (!configOrVerbosityFlag.formatsToSupport) { + return allFormats; + } + if (!Array.isArray(configOrVerbosityFlag.formatsToSupport)) { + throw "configOrVerbosityFlag.formatsToSupport should be undefined " + + "or an array."; + } + if (configOrVerbosityFlag.formatsToSupport.length === 0) { + throw "Atleast 1 formatsToSupport is needed."; + } + var supportedFormats = []; + for (var _i = 0, _a = configOrVerbosityFlag.formatsToSupport; _i < _a.length; _i++) { + var format = _a[_i]; + if (isValidHtml5QrcodeSupportedFormats(format)) { + supportedFormats.push(format); + } + else { + this.logger.warn("Invalid format: ".concat(format, " passed in config, ignoring.")); + } + } + if (supportedFormats.length === 0) { + throw "None of formatsToSupport match supported values."; + } + return supportedFormats; + }; + Html5Qrcode.prototype.getUseBarCodeDetectorIfSupported = function (config) { + if (isNullOrUndefined(config)) { + return true; + } + if (!isNullOrUndefined(config.useBarCodeDetectorIfSupported)) { + return config.useBarCodeDetectorIfSupported !== false; + } + if (isNullOrUndefined(config.experimentalFeatures)) { + return true; + } + var experimentalFeatures = config.experimentalFeatures; + if (isNullOrUndefined(experimentalFeatures.useBarCodeDetectorIfSupported)) { + return true; + } + return experimentalFeatures.useBarCodeDetectorIfSupported !== false; + }; + Html5Qrcode.prototype.validateQrboxSize = function (viewfinderWidth, viewfinderHeight, internalConfig) { + var _this = this; + var qrboxSize = internalConfig.qrbox; + this.validateQrboxConfig(qrboxSize); + var qrDimensions = this.toQrdimensions(viewfinderWidth, viewfinderHeight, qrboxSize); + var validateMinSize = function (size) { + if (size < Constants.MIN_QR_BOX_SIZE) { + throw "minimum size of 'config.qrbox' dimension value is" + + " ".concat(Constants.MIN_QR_BOX_SIZE, "px."); + } + }; + var correctWidthBasedOnRootElementSize = function (configWidth) { + if (configWidth > viewfinderWidth) { + _this.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."); + configWidth = viewfinderWidth; + } + return configWidth; + }; + validateMinSize(qrDimensions.width); + validateMinSize(qrDimensions.height); + qrDimensions.width = correctWidthBasedOnRootElementSize(qrDimensions.width); + }; + Html5Qrcode.prototype.validateQrboxConfig = function (qrboxSize) { + if (typeof qrboxSize === "number") { + return; + } + if (typeof qrboxSize === "function") { + return; + } + if (qrboxSize.width === undefined || qrboxSize.height === undefined) { + throw "Invalid instance of QrDimensions passed for " + + "'config.qrbox'. Both 'width' and 'height' should be set."; + } + }; + Html5Qrcode.prototype.toQrdimensions = function (viewfinderWidth, viewfinderHeight, qrboxSize) { + if (typeof qrboxSize === "number") { + return { width: qrboxSize, height: qrboxSize }; + } + else if (typeof qrboxSize === "function") { + try { + return qrboxSize(viewfinderWidth, viewfinderHeight); + } + catch (error) { + throw new Error("qrbox config was passed as a function but it failed with " + + "unknown error" + error); + } + } + return qrboxSize; + }; + Html5Qrcode.prototype.setupUi = function (viewfinderWidth, viewfinderHeight, internalConfig) { + if (internalConfig.isShadedBoxEnabled()) { + this.validateQrboxSize(viewfinderWidth, viewfinderHeight, internalConfig); + } + var qrboxSize = isNullOrUndefined(internalConfig.qrbox) ? + { width: viewfinderWidth, height: viewfinderHeight } : internalConfig.qrbox; + this.validateQrboxConfig(qrboxSize); + var qrDimensions = this.toQrdimensions(viewfinderWidth, viewfinderHeight, qrboxSize); + if (qrDimensions.height > viewfinderHeight) { + this.logger.warn("[Html5Qrcode] config.qrbox has height that is" + + "greater than the height of the video stream. Shading will be" + + " ignored"); + } + var shouldShadingBeApplied = internalConfig.isShadedBoxEnabled() + && qrDimensions.height <= viewfinderHeight; + var defaultQrRegion = { + x: 0, + y: 0, + width: viewfinderWidth, + height: viewfinderHeight + }; + var qrRegion = shouldShadingBeApplied + ? this.getShadedRegionBounds(viewfinderWidth, viewfinderHeight, qrDimensions) + : defaultQrRegion; + var canvasElement = this.createCanvasElement(qrRegion.width, qrRegion.height); + var contextAttributes = { willReadFrequently: true }; + var context = canvasElement.getContext("2d", contextAttributes); + context.canvas.width = qrRegion.width; + context.canvas.height = qrRegion.height; + this.element.append(canvasElement); + if (shouldShadingBeApplied) { + this.possiblyInsertShadingElement(this.element, viewfinderWidth, viewfinderHeight, qrDimensions); + } + this.createScannerPausedUiElement(this.element); + this.qrRegion = qrRegion; + this.context = context; + this.canvasElement = canvasElement; + }; + Html5Qrcode.prototype.createScannerPausedUiElement = function (rootElement) { + var scannerPausedUiElement = document.createElement("div"); + scannerPausedUiElement.innerText = Html5QrcodeStrings.scannerPaused(); + scannerPausedUiElement.style.display = "none"; + scannerPausedUiElement.style.position = "absolute"; + scannerPausedUiElement.style.top = "0px"; + scannerPausedUiElement.style.zIndex = "1"; + scannerPausedUiElement.style.background = "rgba(9, 9, 9, 0.46)"; + scannerPausedUiElement.style.color = "#FFECEC"; + scannerPausedUiElement.style.textAlign = "center"; + scannerPausedUiElement.style.width = "100%"; + rootElement.appendChild(scannerPausedUiElement); + this.scannerPausedUiElement = scannerPausedUiElement; + }; + Html5Qrcode.prototype.scanContext = function (qrCodeSuccessCallback, qrCodeErrorCallback) { + var _this = this; + if (this.stateManagerProxy.isPaused()) { + return Promise.resolve(false); + } + return this.qrcode.decodeAsync(this.canvasElement) + .then(function (result) { + qrCodeSuccessCallback(result.text, Html5QrcodeResultFactory.createFromQrcodeResult(result)); + _this.possiblyUpdateShaders(true); + return true; + }).catch(function (error) { + _this.possiblyUpdateShaders(false); + var errorMessage = Html5QrcodeStrings.codeParseError(error); + qrCodeErrorCallback(errorMessage, Html5QrcodeErrorFactory.createFrom(errorMessage)); + return false; + }); + }; + Html5Qrcode.prototype.foreverScan = function (internalConfig, qrCodeSuccessCallback, qrCodeErrorCallback) { + var _this = this; + if (!this.shouldScan) { + return; + } + if (!this.renderedCamera) { + return; + } + var videoElement = this.renderedCamera.getSurface(); + var widthRatio = videoElement.videoWidth / videoElement.clientWidth; + var heightRatio = videoElement.videoHeight / videoElement.clientHeight; + if (!this.qrRegion) { + throw "qrRegion undefined when localMediaStream is ready."; + } + var sWidthOffset = this.qrRegion.width * widthRatio; + var sHeightOffset = this.qrRegion.height * heightRatio; + var sxOffset = this.qrRegion.x * widthRatio; + var syOffset = this.qrRegion.y * heightRatio; + this.context.drawImage(videoElement, sxOffset, syOffset, sWidthOffset, sHeightOffset, 0, 0, this.qrRegion.width, this.qrRegion.height); + var triggerNextScan = function () { + _this.foreverScanTimeout = setTimeout(function () { + _this.foreverScan(internalConfig, qrCodeSuccessCallback, qrCodeErrorCallback); + }, _this.getTimeoutFps(internalConfig.fps)); + }; + this.scanContext(qrCodeSuccessCallback, qrCodeErrorCallback) + .then(function (isSuccessfull) { + if (!isSuccessfull && internalConfig.disableFlip !== true) { + _this.context.translate(_this.context.canvas.width, 0); + _this.context.scale(-1, 1); + _this.scanContext(qrCodeSuccessCallback, qrCodeErrorCallback) + .finally(function () { + triggerNextScan(); + }); + } + else { + triggerNextScan(); + } + }).catch(function (error) { + _this.logger.logError("Error happend while scanning context", error); + triggerNextScan(); + }); + }; + Html5Qrcode.prototype.createVideoConstraints = function (cameraIdOrConfig) { + if (typeof cameraIdOrConfig == "string") { + return { deviceId: { exact: cameraIdOrConfig } }; + } + else if (typeof cameraIdOrConfig == "object") { + var facingModeKey = "facingMode"; + var deviceIdKey = "deviceId"; + var allowedFacingModeValues_1 = { "user": true, "environment": true }; + var exactKey = "exact"; + var isValidFacingModeValue = function (value) { + if (value in allowedFacingModeValues_1) { + return true; + } + else { + throw "config has invalid 'facingMode' value = " + + "'".concat(value, "'"); + } + }; + var keys = Object.keys(cameraIdOrConfig); + if (keys.length !== 1) { + throw "'cameraIdOrConfig' object should have exactly 1 key," + + " if passed as an object, found ".concat(keys.length, " keys"); + } + var key = Object.keys(cameraIdOrConfig)[0]; + if (key !== facingModeKey && key !== deviceIdKey) { + throw "Only '".concat(facingModeKey, "' and '").concat(deviceIdKey, "' ") + + " are supported for 'cameraIdOrConfig'"; + } + if (key === facingModeKey) { + var facingMode = cameraIdOrConfig.facingMode; + if (typeof facingMode == "string") { + if (isValidFacingModeValue(facingMode)) { + return { facingMode: facingMode }; + } + } + else if (typeof facingMode == "object") { + if (exactKey in facingMode) { + if (isValidFacingModeValue(facingMode["".concat(exactKey)])) { + return { + facingMode: { + exact: facingMode["".concat(exactKey)] + } + }; + } + } + else { + throw "'facingMode' should be string or object with" + + " ".concat(exactKey, " as key."); + } + } + else { + var type_1 = (typeof facingMode); + throw "Invalid type of 'facingMode' = ".concat(type_1); + } + } + else { + var deviceId = cameraIdOrConfig.deviceId; + if (typeof deviceId == "string") { + return { deviceId: deviceId }; + } + else if (typeof deviceId == "object") { + if (exactKey in deviceId) { + return { + deviceId: { exact: deviceId["".concat(exactKey)] } + }; + } + else { + throw "'deviceId' should be string or object with" + + " ".concat(exactKey, " as key."); + } + } + else { + var type_2 = (typeof deviceId); + throw "Invalid type of 'deviceId' = ".concat(type_2); + } + } + } + var type = (typeof cameraIdOrConfig); + throw "Invalid type of 'cameraIdOrConfig' = ".concat(type); + }; + Html5Qrcode.prototype.computeCanvasDrawConfig = function (imageWidth, imageHeight, containerWidth, containerHeight) { + if (imageWidth <= containerWidth + && imageHeight <= containerHeight) { + var xoffset = (containerWidth - imageWidth) / 2; + var yoffset = (containerHeight - imageHeight) / 2; + return { + x: xoffset, + y: yoffset, + width: imageWidth, + height: imageHeight + }; + } + else { + var formerImageWidth = imageWidth; + var formerImageHeight = imageHeight; + if (imageWidth > containerWidth) { + imageHeight = (containerWidth / imageWidth) * imageHeight; + imageWidth = containerWidth; + } + if (imageHeight > containerHeight) { + imageWidth = (containerHeight / imageHeight) * imageWidth; + imageHeight = containerHeight; + } + this.logger.log("Image downsampled from " + + "".concat(formerImageWidth, "X").concat(formerImageHeight) + + " to ".concat(imageWidth, "X").concat(imageHeight, ".")); + return this.computeCanvasDrawConfig(imageWidth, imageHeight, containerWidth, containerHeight); + } + }; + Html5Qrcode.prototype.clearElement = function () { + if (this.stateManagerProxy.isScanning()) { + throw "Cannot clear while scan is ongoing, close it first."; + } + var element = document.getElementById(this.elementId); + if (element) { + element.innerHTML = ""; + } + }; + Html5Qrcode.prototype.possiblyUpdateShaders = function (qrMatch) { + if (this.qrMatch === qrMatch) { + return; + } + if (this.hasBorderShaders + && this.borderShaders + && this.borderShaders.length) { + this.borderShaders.forEach(function (shader) { + shader.style.backgroundColor = qrMatch + ? Constants.BORDER_SHADER_MATCH_COLOR + : Constants.BORDER_SHADER_DEFAULT_COLOR; + }); + } + this.qrMatch = qrMatch; + }; + Html5Qrcode.prototype.possiblyCloseLastScanImageFile = function () { + if (this.lastScanImageFile) { + URL.revokeObjectURL(this.lastScanImageFile); + this.lastScanImageFile = null; + } + }; + Html5Qrcode.prototype.createCanvasElement = function (width, height, customId) { + var canvasWidth = width; + var canvasHeight = height; + var canvasElement = document.createElement("canvas"); + canvasElement.style.width = "".concat(canvasWidth, "px"); + canvasElement.style.height = "".concat(canvasHeight, "px"); + canvasElement.style.display = "none"; + canvasElement.id = isNullOrUndefined(customId) + ? "qr-canvas" : customId; + return canvasElement; + }; + Html5Qrcode.prototype.getShadedRegionBounds = function (width, height, qrboxSize) { + if (qrboxSize.width > width || qrboxSize.height > height) { + throw "'config.qrbox' dimensions should not be greater than the " + + "dimensions of the root HTML element."; + } + return { + x: (width - qrboxSize.width) / 2, + y: (height - qrboxSize.height) / 2, + width: qrboxSize.width, + height: qrboxSize.height + }; + }; + Html5Qrcode.prototype.possiblyInsertShadingElement = function (element, width, height, qrboxSize) { + if ((width - qrboxSize.width) < 1 || (height - qrboxSize.height) < 1) { + return; + } + var shadingElement = document.createElement("div"); + shadingElement.style.position = "absolute"; + var rightLeftBorderSize = (width - qrboxSize.width) / 2; + var topBottomBorderSize = (height - qrboxSize.height) / 2; + shadingElement.style.borderLeft + = "".concat(rightLeftBorderSize, "px solid rgba(0, 0, 0, 0.48)"); + shadingElement.style.borderRight + = "".concat(rightLeftBorderSize, "px solid rgba(0, 0, 0, 0.48)"); + shadingElement.style.borderTop + = "".concat(topBottomBorderSize, "px solid rgba(0, 0, 0, 0.48)"); + shadingElement.style.borderBottom + = "".concat(topBottomBorderSize, "px solid rgba(0, 0, 0, 0.48)"); + shadingElement.style.boxSizing = "border-box"; + shadingElement.style.top = "0px"; + shadingElement.style.bottom = "0px"; + shadingElement.style.left = "0px"; + shadingElement.style.right = "0px"; + shadingElement.id = "".concat(Constants.SHADED_REGION_ELEMENT_ID); + if ((width - qrboxSize.width) < 11 + || (height - qrboxSize.height) < 11) { + this.hasBorderShaders = false; + } + else { + var smallSize = 5; + var largeSize = 40; + this.insertShaderBorders(shadingElement, largeSize, smallSize, -smallSize, null, 0, true); + this.insertShaderBorders(shadingElement, largeSize, smallSize, -smallSize, null, 0, false); + this.insertShaderBorders(shadingElement, largeSize, smallSize, null, -smallSize, 0, true); + this.insertShaderBorders(shadingElement, largeSize, smallSize, null, -smallSize, 0, false); + this.insertShaderBorders(shadingElement, smallSize, largeSize + smallSize, -smallSize, null, -smallSize, true); + this.insertShaderBorders(shadingElement, smallSize, largeSize + smallSize, null, -smallSize, -smallSize, true); + this.insertShaderBorders(shadingElement, smallSize, largeSize + smallSize, -smallSize, null, -smallSize, false); + this.insertShaderBorders(shadingElement, smallSize, largeSize + smallSize, null, -smallSize, -smallSize, false); + this.hasBorderShaders = true; + } + element.append(shadingElement); + }; + Html5Qrcode.prototype.insertShaderBorders = function (shaderElem, width, height, top, bottom, side, isLeft) { + var elem = document.createElement("div"); + elem.style.position = "absolute"; + elem.style.backgroundColor = Constants.BORDER_SHADER_DEFAULT_COLOR; + elem.style.width = "".concat(width, "px"); + elem.style.height = "".concat(height, "px"); + if (top !== null) { + elem.style.top = "".concat(top, "px"); + } + if (bottom !== null) { + elem.style.bottom = "".concat(bottom, "px"); + } + if (isLeft) { + elem.style.left = "".concat(side, "px"); + } + else { + elem.style.right = "".concat(side, "px"); + } + if (!this.borderShaders) { + this.borderShaders = []; + } + this.borderShaders.push(elem); + shaderElem.appendChild(elem); + }; + Html5Qrcode.prototype.showPausedState = function () { + if (!this.scannerPausedUiElement) { + throw "[internal error] scanner paused UI element not found"; + } + this.scannerPausedUiElement.style.display = "block"; + }; + Html5Qrcode.prototype.hidePausedState = function () { + if (!this.scannerPausedUiElement) { + throw "[internal error] scanner paused UI element not found"; + } + this.scannerPausedUiElement.style.display = "none"; + }; + Html5Qrcode.prototype.getTimeoutFps = function (fps) { + return 1000 / fps; + }; + return Html5Qrcode; +}()); +export { Html5Qrcode }; +//# sourceMappingURL=html5-qrcode.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/html5-qrcode.js.map b/src/main/node_modules/html5-qrcode/esm/html5-qrcode.js.map new file mode 100644 index 0000000000000000000000000000000000000000..a29f6b6a43b2040d8322da9bb14aaed57fb04bbc --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/html5-qrcode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"html5-qrcode.js","sourceRoot":"","sources":["../../src/html5-qrcode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAcA,OAAO,EAIH,WAAW,EACX,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAE3B,kCAAkC,EAClC,oBAAoB,EAEpB,iBAAiB,EAGpB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAEH,mBAAmB,EAEnB,uBAAuB,EAC1B,MAAM,iBAAiB,CAAC;AAEzB;IAAwB,6BAAoB;IAA5C;;IAgBA,CAAC;IAdU,uBAAa,GAAG,GAAG,CAAC;IACpB,8BAAoB,GAAG,CAAC,CAAC;IACzB,8BAAoB,GAAG,GAAG,CAAC;IAC3B,yCAA+B,GAAG,GAAG,CAAC;IACtC,yBAAe,GAAG,EAAE,CAAC;IACrB,qBAAW,GAAG,CAAC,CAAC;IAChB,sBAAY,GAAG,CAAC,CAAC;IACjB,oBAAU,GAAG,CAAC,CAAC;IACf,uBAAa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AAC;IAEO,qCAAe,GAAvB;QACI,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE;YAC9B,MAAM,sDAAsD,CAAC;SAChE;QACD,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACvD,CAAC;IAEO,mCAAa,GAArB,UAAsB,GAAW;QAC7B,OAAO,IAAI,GAAG,GAAG,CAAC;IACtB,CAAC;IAEL,kBAAC;AAAD,CAAC,AArzCD,IAqzCC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/image-assets.d.ts b/src/main/node_modules/html5-qrcode/esm/image-assets.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..59387ac2e6d5b21c1d1862a744e923298b400a24 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/image-assets.d.ts @@ -0,0 +1,4 @@ +export declare const ASSET_CAMERA_SCAN: string; +export declare const ASSET_FILE_SCAN: string; +export declare const ASSET_INFO_ICON_16PX: string; +export declare const ASSET_CLOSE_ICON_16PX: string; diff --git a/src/main/node_modules/html5-qrcode/esm/image-assets.js b/src/main/node_modules/html5-qrcode/esm/image-assets.js new file mode 100644 index 0000000000000000000000000000000000000000..0b2e73cd03963fc7382b0d1b3d73b9aaf8eaca54 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/image-assets.js @@ -0,0 +1,6 @@ +var SVG_XML_PREFIX = "data:image/svg+xml;base64,"; +export var ASSET_CAMERA_SCAN = SVG_XML_PREFIX + "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzNzEuNjQzIDM3MS42NDMiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDM3MS42NDMgMzcxLjY0MyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBhdGggZD0iTTEwNS4wODQgMzguMjcxaDE2My43Njh2MjBIMTA1LjA4NHoiLz48cGF0aCBkPSJNMzExLjU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y0yMS41MzkgMC0zOS0xNy40NjEtMzktMzlzMTcuNDYxLTM5IDM5LTM5IDM5IDE3LjQ2MSAzOSAzOS0xNy40NjEgMzktMzkgMzl6Ii8+PC9zdmc+"; +export var ASSET_CLOSE_ICON_16PX = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAQgAAAEIBarqQRAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAE1SURBVDiNfdI7S0NBEAXgLya1otFgpbYSbISAgpXYi6CmiH9KCAiChaVga6OiWPgfRDQ+0itaGVNosXtluWwcuMzePfM4M3sq8lbHBubwg1dc4m1E/J/N4ghDPOIsfk/4xiEao5KX0McFljN4C9d4QTPXuY99jP3DsIoDPGM6BY5i5yI5R7O4q+ImFkJY2DCh3cAH2klyB+9J1xUMMAG7eCh1a+Mr+k48b5diXrFVwwLuS+BJ9MfR7+G0FHOHhTHhnXNWS87VDF4pcnfQK4Ep7XScNLmPTZgURNKKYENYWDpzW1BhscS1WHS8CDgURFJQrWcoF3c13KKbgg1BYQfy8xZWEzTTw1QZbAoKu8FqJnktdu5hcVSHmchiILzzuaDQvjBzV2m8yohCE1jHfPx/xhU+y4G/D75ELlRJsSYAAAAASUVORK5CYII="; +//# sourceMappingURL=image-assets.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/image-assets.js.map b/src/main/node_modules/html5-qrcode/esm/image-assets.js.map new file mode 100644 index 0000000000000000000000000000000000000000..4ba7fe100150a7ee8e4d9fd39771c5dc47531557 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/image-assets.js.map @@ -0,0 +1 @@ +{"version":3,"file":"image-assets.js","sourceRoot":"","sources":["../../src/image-assets.ts"],"names":[],"mappings":"AASA,IAAM,cAAc,GAAG,4BAA4B,CAAC;AAEpD,MAAM,CAAC,IAAM,iBAAiB,GAAW,cAAc,GAAG,82GAA82G,CAAC;AAEz6G,MAAM,CAAC,IAAM,eAAe,GAAW,cAAc,GAAG,s8CAAs8C,CAAC;AAE//C,MAAM,CAAC,IAAM,oBAAoB,GAAY,cAAc,GAAG,8oBAA8oB,CAAC;AAE7sB,MAAM,CAAC,IAAM,qBAAqB,GAAY,omBAAomB,CAAC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/index.d.ts b/src/main/node_modules/html5-qrcode/esm/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6b90c689f1a0c34ea728b5b7a5375a33722ed9f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/index.d.ts @@ -0,0 +1,6 @@ +export { Html5Qrcode, Html5QrcodeFullConfig, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; +export { Html5QrcodeScanner } from "./html5-qrcode-scanner"; +export { Html5QrcodeSupportedFormats, Html5QrcodeResult, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; +export { Html5QrcodeScannerState } from "./state-manager"; +export { Html5QrcodeScanType } from "./core"; +export { CameraCapabilities, CameraDevice } from "./camera/core"; diff --git a/src/main/node_modules/html5-qrcode/esm/index.js b/src/main/node_modules/html5-qrcode/esm/index.js new file mode 100644 index 0000000000000000000000000000000000000000..890331ea292278518a37a54e4f794b5f2fd0c4e9 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/index.js @@ -0,0 +1,6 @@ +export { Html5Qrcode } from "./html5-qrcode"; +export { Html5QrcodeScanner } from "./html5-qrcode-scanner"; +export { Html5QrcodeSupportedFormats } from "./core"; +export { Html5QrcodeScannerState } from "./state-manager"; +export { Html5QrcodeScanType } from "./core"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/index.js.map b/src/main/node_modules/html5-qrcode/esm/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8eede83f3ee9bb76ad797913c29b581f0104a443 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACH,WAAW,EAGd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACH,2BAA2B,EAI9B,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/native-bar-code-detector.d.ts b/src/main/node_modules/html5-qrcode/esm/native-bar-code-detector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..85ef95e4c4fec982c26cea91f5bb9eb21923bdf4 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/native-bar-code-detector.d.ts @@ -0,0 +1,16 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, QrcodeDecoderAsync, Logger } from "./core"; +export declare class BarcodeDetectorDelegate implements QrcodeDecoderAsync { + private readonly formatMap; + private readonly reverseFormatMap; + private verbose; + private logger; + private detector; + static isSupported(): boolean; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private selectLargestBarcode; + private createBarcodeDetectorFormats; + private toHtml5QrcodeSupportedFormats; + private createReverseFormatMap; + private createDebugData; +} diff --git a/src/main/node_modules/html5-qrcode/esm/native-bar-code-detector.js b/src/main/node_modules/html5-qrcode/esm/native-bar-code-detector.js new file mode 100644 index 0000000000000000000000000000000000000000..5760e30e1dbe70c801a9eea04b31cb9085bec4f1 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/native-bar-code-detector.js @@ -0,0 +1,145 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +import { QrcodeResultFormat, Html5QrcodeSupportedFormats } from "./core"; +var BarcodeDetectorDelegate = (function () { + function BarcodeDetectorDelegate(requestedFormats, verbose, logger) { + this.formatMap = new Map([ + [Html5QrcodeSupportedFormats.QR_CODE, "qr_code"], + [Html5QrcodeSupportedFormats.AZTEC, "aztec"], + [Html5QrcodeSupportedFormats.CODABAR, "codabar"], + [Html5QrcodeSupportedFormats.CODE_39, "code_39"], + [Html5QrcodeSupportedFormats.CODE_93, "code_93"], + [Html5QrcodeSupportedFormats.CODE_128, "code_128"], + [Html5QrcodeSupportedFormats.DATA_MATRIX, "data_matrix"], + [Html5QrcodeSupportedFormats.ITF, "itf"], + [Html5QrcodeSupportedFormats.EAN_13, "ean_13"], + [Html5QrcodeSupportedFormats.EAN_8, "ean_8"], + [Html5QrcodeSupportedFormats.PDF_417, "pdf417"], + [Html5QrcodeSupportedFormats.UPC_A, "upc_a"], + [Html5QrcodeSupportedFormats.UPC_E, "upc_e"] + ]); + this.reverseFormatMap = this.createReverseFormatMap(); + if (!BarcodeDetectorDelegate.isSupported()) { + throw "Use html5qrcode.min.js without edit, Use " + + "BarcodeDetectorDelegate only if it isSupported();"; + } + this.verbose = verbose; + this.logger = logger; + var formats = this.createBarcodeDetectorFormats(requestedFormats); + this.detector = new BarcodeDetector(formats); + if (!this.detector) { + throw "BarcodeDetector detector not supported"; + } + } + BarcodeDetectorDelegate.isSupported = function () { + if (!("BarcodeDetector" in window)) { + return false; + } + var dummyDetector = new BarcodeDetector({ formats: ["qr_code"] }); + return typeof dummyDetector !== "undefined"; + }; + BarcodeDetectorDelegate.prototype.decodeAsync = function (canvas) { + return __awaiter(this, void 0, void 0, function () { + var barcodes, largestBarcode; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4, this.detector.detect(canvas)]; + case 1: + barcodes = _a.sent(); + if (!barcodes || barcodes.length === 0) { + throw "No barcode or QR code detected."; + } + largestBarcode = this.selectLargestBarcode(barcodes); + return [2, { + text: largestBarcode.rawValue, + format: QrcodeResultFormat.create(this.toHtml5QrcodeSupportedFormats(largestBarcode.format)), + debugData: this.createDebugData() + }]; + } + }); + }); + }; + BarcodeDetectorDelegate.prototype.selectLargestBarcode = function (barcodes) { + var largestBarcode = null; + var maxArea = 0; + for (var _i = 0, barcodes_1 = barcodes; _i < barcodes_1.length; _i++) { + var barcode = barcodes_1[_i]; + var area = barcode.boundingBox.width * barcode.boundingBox.height; + if (area > maxArea) { + maxArea = area; + largestBarcode = barcode; + } + } + if (!largestBarcode) { + throw "No largest barcode found"; + } + return largestBarcode; + }; + BarcodeDetectorDelegate.prototype.createBarcodeDetectorFormats = function (requestedFormats) { + var formats = []; + for (var _i = 0, requestedFormats_1 = requestedFormats; _i < requestedFormats_1.length; _i++) { + var requestedFormat = requestedFormats_1[_i]; + if (this.formatMap.has(requestedFormat)) { + formats.push(this.formatMap.get(requestedFormat)); + } + else { + this.logger.warn("".concat(requestedFormat, " is not supported by") + + "BarcodeDetectorDelegate"); + } + } + return { formats: formats }; + }; + BarcodeDetectorDelegate.prototype.toHtml5QrcodeSupportedFormats = function (barcodeDetectorFormat) { + if (!this.reverseFormatMap.has(barcodeDetectorFormat)) { + throw "reverseFormatMap doesn't have ".concat(barcodeDetectorFormat); + } + return this.reverseFormatMap.get(barcodeDetectorFormat); + }; + BarcodeDetectorDelegate.prototype.createReverseFormatMap = function () { + var result = new Map(); + this.formatMap.forEach(function (value, key, _) { + result.set(value, key); + }); + return result; + }; + BarcodeDetectorDelegate.prototype.createDebugData = function () { + return { decoderName: "BarcodeDetector" }; + }; + return BarcodeDetectorDelegate; +}()); +export { BarcodeDetectorDelegate }; +//# sourceMappingURL=native-bar-code-detector.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/native-bar-code-detector.js.map b/src/main/node_modules/html5-qrcode/esm/native-bar-code-detector.js.map new file mode 100644 index 0000000000000000000000000000000000000000..08a79f396f5d0fca90ab830e9353c9d50f58835b --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/native-bar-code-detector.js.map @@ -0,0 +1 @@ +{"version":3,"file":"native-bar-code-detector.js","sourceRoot":"","sources":["../../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C;IAEO,iDAAe,GAAvB;QACI,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IAC9C,CAAC;IACL,8BAAC;AAAD,CAAC,AA3IA,IA2IA"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/state-manager.d.ts b/src/main/node_modules/html5-qrcode/esm/state-manager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c740bbd882ab2dd15280713d5d0866cbdf2b9d8 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/state-manager.d.ts @@ -0,0 +1,29 @@ +export declare enum Html5QrcodeScannerState { + UNKNOWN = 0, + NOT_STARTED = 1, + SCANNING = 2, + PAUSED = 3 +} +export interface StateManagerTransaction { + execute(): void; + cancel(): void; +} +export interface StateManager { + startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction; + directTransition(newState: Html5QrcodeScannerState): void; + getState(): Html5QrcodeScannerState; +} +export declare class StateManagerProxy { + private stateManager; + constructor(stateManager: StateManager); + startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction; + directTransition(newState: Html5QrcodeScannerState): void; + getState(): Html5QrcodeScannerState; + canScanFile(): boolean; + isScanning(): boolean; + isStrictlyScanning(): boolean; + isPaused(): boolean; +} +export declare class StateManagerFactory { + static create(): StateManagerProxy; +} diff --git a/src/main/node_modules/html5-qrcode/esm/state-manager.js b/src/main/node_modules/html5-qrcode/esm/state-manager.js new file mode 100644 index 0000000000000000000000000000000000000000..71a71d4db6d42f45a33f564807fec448914fbccb --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/state-manager.js @@ -0,0 +1,109 @@ +export var Html5QrcodeScannerState; +(function (Html5QrcodeScannerState) { + Html5QrcodeScannerState[Html5QrcodeScannerState["UNKNOWN"] = 0] = "UNKNOWN"; + Html5QrcodeScannerState[Html5QrcodeScannerState["NOT_STARTED"] = 1] = "NOT_STARTED"; + Html5QrcodeScannerState[Html5QrcodeScannerState["SCANNING"] = 2] = "SCANNING"; + Html5QrcodeScannerState[Html5QrcodeScannerState["PAUSED"] = 3] = "PAUSED"; +})(Html5QrcodeScannerState || (Html5QrcodeScannerState = {})); +var StateManagerImpl = (function () { + function StateManagerImpl() { + this.state = Html5QrcodeScannerState.NOT_STARTED; + this.onGoingTransactionNewState = Html5QrcodeScannerState.UNKNOWN; + } + StateManagerImpl.prototype.directTransition = function (newState) { + this.failIfTransitionOngoing(); + this.validateTransition(newState); + this.state = newState; + }; + StateManagerImpl.prototype.startTransition = function (newState) { + this.failIfTransitionOngoing(); + this.validateTransition(newState); + this.onGoingTransactionNewState = newState; + return this; + }; + StateManagerImpl.prototype.execute = function () { + if (this.onGoingTransactionNewState + === Html5QrcodeScannerState.UNKNOWN) { + throw "Transaction is already cancelled, cannot execute()."; + } + var tempNewState = this.onGoingTransactionNewState; + this.onGoingTransactionNewState = Html5QrcodeScannerState.UNKNOWN; + this.directTransition(tempNewState); + }; + StateManagerImpl.prototype.cancel = function () { + if (this.onGoingTransactionNewState + === Html5QrcodeScannerState.UNKNOWN) { + throw "Transaction is already cancelled, cannot cancel()."; + } + this.onGoingTransactionNewState = Html5QrcodeScannerState.UNKNOWN; + }; + StateManagerImpl.prototype.getState = function () { + return this.state; + }; + StateManagerImpl.prototype.failIfTransitionOngoing = function () { + if (this.onGoingTransactionNewState + !== Html5QrcodeScannerState.UNKNOWN) { + throw "Cannot transition to a new state, already under transition"; + } + }; + StateManagerImpl.prototype.validateTransition = function (newState) { + switch (this.state) { + case Html5QrcodeScannerState.UNKNOWN: + throw "Transition from unknown is not allowed"; + case Html5QrcodeScannerState.NOT_STARTED: + this.failIfNewStateIs(newState, [Html5QrcodeScannerState.PAUSED]); + break; + case Html5QrcodeScannerState.SCANNING: + break; + case Html5QrcodeScannerState.PAUSED: + break; + } + }; + StateManagerImpl.prototype.failIfNewStateIs = function (newState, disallowedStatesToTransition) { + for (var _i = 0, disallowedStatesToTransition_1 = disallowedStatesToTransition; _i < disallowedStatesToTransition_1.length; _i++) { + var disallowedState = disallowedStatesToTransition_1[_i]; + if (newState === disallowedState) { + throw "Cannot transition from ".concat(this.state, " to ").concat(newState); + } + } + }; + return StateManagerImpl; +}()); +var StateManagerProxy = (function () { + function StateManagerProxy(stateManager) { + this.stateManager = stateManager; + } + StateManagerProxy.prototype.startTransition = function (newState) { + return this.stateManager.startTransition(newState); + }; + StateManagerProxy.prototype.directTransition = function (newState) { + this.stateManager.directTransition(newState); + }; + StateManagerProxy.prototype.getState = function () { + return this.stateManager.getState(); + }; + StateManagerProxy.prototype.canScanFile = function () { + return this.stateManager.getState() === Html5QrcodeScannerState.NOT_STARTED; + }; + StateManagerProxy.prototype.isScanning = function () { + return this.stateManager.getState() !== Html5QrcodeScannerState.NOT_STARTED; + }; + StateManagerProxy.prototype.isStrictlyScanning = function () { + return this.stateManager.getState() === Html5QrcodeScannerState.SCANNING; + }; + StateManagerProxy.prototype.isPaused = function () { + return this.stateManager.getState() === Html5QrcodeScannerState.PAUSED; + }; + return StateManagerProxy; +}()); +export { StateManagerProxy }; +var StateManagerFactory = (function () { + function StateManagerFactory() { + } + StateManagerFactory.create = function () { + return new StateManagerProxy(new StateManagerImpl()); + }; + return StateManagerFactory; +}()); +export { StateManagerFactory }; +//# sourceMappingURL=state-manager.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/state-manager.js.map b/src/main/node_modules/html5-qrcode/esm/state-manager.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b1ebd19932b27adde377b4f1f34d1fae4ac73822 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/state-manager.js.map @@ -0,0 +1 @@ +{"version":3,"file":"state-manager.js","sourceRoot":"","sources":["../../src/state-manager.ts"],"names":[],"mappings":"AAQA,MAAM,CAAN,IAAY,uBAUX;AAVD,WAAY,uBAAuB;IAE/B,2EAAW,CAAA;IAGX,mFAAe,CAAA;IAEf,6EAAQ,CAAA;IAER,yEAAM,CAAA;AACV,CAAC,EAVW,uBAAuB,KAAvB,uBAAuB,QAUlC;AAkDD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,WAAW,CAAC;IAChF,CAAC;IAED,8CAAkB,GAAlB;QACI,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,uBAAuB,CAAC,QAAQ,CAAC;IAC7E,CAAC;IAED,oCAAQ,GAAR;QACI,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,uBAAuB,CAAC,MAAM,CAAC;IAC3E,CAAC;IACL,wBAAC;AAAD,CAAC,AAlCD,IAkCC;;AAKA;IAAA;IAID,CAAC;IAHiB,0BAAM,GAApB;QACI,OAAO,IAAI,iBAAiB,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;IACzD,CAAC;IACL,0BAAC;AAAD,CAAC,AAJA,IAIA"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/storage.d.ts b/src/main/node_modules/html5-qrcode/esm/storage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cae73a316feba6585b2cb887ab0a8d664ba1eb11 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/storage.d.ts @@ -0,0 +1,12 @@ +export declare class PersistedDataManager { + private data; + private static LOCAL_STORAGE_KEY; + constructor(); + hasCameraPermissions(): boolean; + getLastUsedCameraId(): string | null; + setHasPermission(hasPermission: boolean): void; + setLastUsedCameraId(lastUsedCameraId: string): void; + resetLastUsedCameraId(): void; + reset(): void; + private flush; +} diff --git a/src/main/node_modules/html5-qrcode/esm/storage.js b/src/main/node_modules/html5-qrcode/esm/storage.js new file mode 100644 index 0000000000000000000000000000000000000000..9d2215e730379d4dd6551dc5ace70cdfd4ea4b8a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/storage.js @@ -0,0 +1,52 @@ +var PersistedDataFactory = (function () { + function PersistedDataFactory() { + } + PersistedDataFactory.createDefault = function () { + return { + hasPermission: false, + lastUsedCameraId: null + }; + }; + return PersistedDataFactory; +}()); +var PersistedDataManager = (function () { + function PersistedDataManager() { + this.data = PersistedDataFactory.createDefault(); + var data = localStorage.getItem(PersistedDataManager.LOCAL_STORAGE_KEY); + if (!data) { + this.reset(); + } + else { + this.data = JSON.parse(data); + } + } + PersistedDataManager.prototype.hasCameraPermissions = function () { + return this.data.hasPermission; + }; + PersistedDataManager.prototype.getLastUsedCameraId = function () { + return this.data.lastUsedCameraId; + }; + PersistedDataManager.prototype.setHasPermission = function (hasPermission) { + this.data.hasPermission = hasPermission; + this.flush(); + }; + PersistedDataManager.prototype.setLastUsedCameraId = function (lastUsedCameraId) { + this.data.lastUsedCameraId = lastUsedCameraId; + this.flush(); + }; + PersistedDataManager.prototype.resetLastUsedCameraId = function () { + this.data.lastUsedCameraId = null; + this.flush(); + }; + PersistedDataManager.prototype.reset = function () { + this.data = PersistedDataFactory.createDefault(); + this.flush(); + }; + PersistedDataManager.prototype.flush = function () { + localStorage.setItem(PersistedDataManager.LOCAL_STORAGE_KEY, JSON.stringify(this.data)); + }; + PersistedDataManager.LOCAL_STORAGE_KEY = "HTML5_QRCODE_DATA"; + return PersistedDataManager; +}()); +export { PersistedDataManager }; +//# sourceMappingURL=storage.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/storage.js.map b/src/main/node_modules/html5-qrcode/esm/storage.js.map new file mode 100644 index 0000000000000000000000000000000000000000..c4571a8c522335eacaa4648e767428a08d3750fa --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/storage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":"AAeA;IAAA;IAOA,CAAC;IANU,kCAAa,GAApB;QACI,OAAO;YACH,aAAa,EAAE,KAAK;YACpB,gBAAgB,EAAE,IAAI;SACzB,CAAC;IACN,CAAC;IACL,2BAAC;AAAD,CAAC,AAPD,IAOC;AAED;IAKI;QAHQ,SAAI,GAAkB,oBAAoB,CAAC,aAAa,EAAE,CAAC;QAI/D,IAAI,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,EAAE;YACP,IAAI,CAAC,KAAK,EAAE,CAAC;SAChB;aAAM;YACH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAChC;IACL,CAAC;IAEM,mDAAoB,GAA3B;QACI,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;IACnC,CAAC;IAEM,kDAAmB,GAA1B;QACI,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;IACtC,CAAC;IAEM,+CAAgB,GAAvB,UAAwB,aAAsB;QAC1C,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACxC,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEM,kDAAmB,GAA1B,UAA2B,gBAAwB;QAC/C,IAAI,CAAC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEM,oDAAqB,GAA5B;QACI,IAAI,CAAC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEM,oCAAK,GAAZ;QACI,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC,aAAa,EAAE,CAAC;QACjD,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEO,oCAAK,GAAb;QACI,YAAY,CAAC,OAAO,CAChB,oBAAoB,CAAC,iBAAiB,EACtC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnC,CAAC;IA3Cc,sCAAiB,GAAW,mBAAmB,CAAC;IA4CnE,2BAAC;CAAA,AA/CD,IA+CC;SA/CY,oBAAoB"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/strings.d.ts b/src/main/node_modules/html5-qrcode/esm/strings.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb99f90013e8dc8c8fb988e3383678cdd993b99e --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/strings.d.ts @@ -0,0 +1,45 @@ +export declare class Html5QrcodeStrings { + static codeParseError(exception: any): string; + static errorGettingUserMedia(error: any): string; + static onlyDeviceSupportedError(): string; + static cameraStreamingNotSupported(): string; + static unableToQuerySupportedDevices(): string; + static insecureContextCameraQueryError(): string; + static scannerPaused(): string; +} +export declare class Html5QrcodeScannerStrings { + static scanningStatus(): string; + static idleStatus(): string; + static errorStatus(): string; + static permissionStatus(): string; + static noCameraFoundErrorStatus(): string; + static lastMatch(decodedText: string): string; + static codeScannerTitle(): string; + static cameraPermissionTitle(): string; + static cameraPermissionRequesting(): string; + static noCameraFound(): string; + static scanButtonStopScanningText(): string; + static scanButtonStartScanningText(): string; + static torchOnButton(): string; + static torchOffButton(): string; + static torchOnFailedMessage(): string; + static torchOffFailedMessage(): string; + static scanButtonScanningStarting(): string; + static textIfCameraScanSelected(): string; + static textIfFileScanSelected(): string; + static selectCamera(): string; + static fileSelectionChooseImage(): string; + static fileSelectionChooseAnother(): string; + static fileSelectionNoImageSelected(): string; + static anonymousCameraPrefix(): string; + static dragAndDropMessage(): string; + static dragAndDropMessageOnlyImages(): string; + static zoom(): string; + static loadingImage(): string; + static cameraScanAltText(): string; + static fileScanAltText(): string; +} +export declare class LibraryInfoStrings { + static poweredBy(): string; + static reportIssues(): string; +} diff --git a/src/main/node_modules/html5-qrcode/esm/strings.js b/src/main/node_modules/html5-qrcode/esm/strings.js new file mode 100644 index 0000000000000000000000000000000000000000..6840a7faaf7353dfa4d01282d7672768e4f5475c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/strings.js @@ -0,0 +1,139 @@ +var Html5QrcodeStrings = (function () { + function Html5QrcodeStrings() { + } + Html5QrcodeStrings.codeParseError = function (exception) { + return "QR code parse error, error = ".concat(exception); + }; + Html5QrcodeStrings.errorGettingUserMedia = function (error) { + return "Error getting userMedia, error = ".concat(error); + }; + Html5QrcodeStrings.onlyDeviceSupportedError = function () { + return "The device doesn't support navigator.mediaDevices , only " + + "supported cameraIdOrConfig in this case is deviceId parameter " + + "(string)."; + }; + Html5QrcodeStrings.cameraStreamingNotSupported = function () { + return "Camera streaming not supported by the browser."; + }; + Html5QrcodeStrings.unableToQuerySupportedDevices = function () { + return "Unable to query supported devices, unknown error."; + }; + Html5QrcodeStrings.insecureContextCameraQueryError = function () { + return "Camera access is only supported in secure context like https " + + "or localhost."; + }; + Html5QrcodeStrings.scannerPaused = function () { + return "Scanner paused"; + }; + return Html5QrcodeStrings; +}()); +export { Html5QrcodeStrings }; +var Html5QrcodeScannerStrings = (function () { + function Html5QrcodeScannerStrings() { + } + Html5QrcodeScannerStrings.scanningStatus = function () { + return "Scanning"; + }; + Html5QrcodeScannerStrings.idleStatus = function () { + return "Idle"; + }; + Html5QrcodeScannerStrings.errorStatus = function () { + return "Error"; + }; + Html5QrcodeScannerStrings.permissionStatus = function () { + return "Permission"; + }; + Html5QrcodeScannerStrings.noCameraFoundErrorStatus = function () { + return "No Cameras"; + }; + Html5QrcodeScannerStrings.lastMatch = function (decodedText) { + return "Last Match: ".concat(decodedText); + }; + Html5QrcodeScannerStrings.codeScannerTitle = function () { + return "Code Scanner"; + }; + Html5QrcodeScannerStrings.cameraPermissionTitle = function () { + return "Request Camera Permissions"; + }; + Html5QrcodeScannerStrings.cameraPermissionRequesting = function () { + return "Requesting camera permissions..."; + }; + Html5QrcodeScannerStrings.noCameraFound = function () { + return "No camera found"; + }; + Html5QrcodeScannerStrings.scanButtonStopScanningText = function () { + return "Stop Scanning"; + }; + Html5QrcodeScannerStrings.scanButtonStartScanningText = function () { + return "Start Scanning"; + }; + Html5QrcodeScannerStrings.torchOnButton = function () { + return "Switch On Torch"; + }; + Html5QrcodeScannerStrings.torchOffButton = function () { + return "Switch Off Torch"; + }; + Html5QrcodeScannerStrings.torchOnFailedMessage = function () { + return "Failed to turn on torch"; + }; + Html5QrcodeScannerStrings.torchOffFailedMessage = function () { + return "Failed to turn off torch"; + }; + Html5QrcodeScannerStrings.scanButtonScanningStarting = function () { + return "Launching Camera..."; + }; + Html5QrcodeScannerStrings.textIfCameraScanSelected = function () { + return "Scan an Image File"; + }; + Html5QrcodeScannerStrings.textIfFileScanSelected = function () { + return "Scan using camera directly"; + }; + Html5QrcodeScannerStrings.selectCamera = function () { + return "Select Camera"; + }; + Html5QrcodeScannerStrings.fileSelectionChooseImage = function () { + return "Choose Image"; + }; + Html5QrcodeScannerStrings.fileSelectionChooseAnother = function () { + return "Choose Another"; + }; + Html5QrcodeScannerStrings.fileSelectionNoImageSelected = function () { + return "No image choosen"; + }; + Html5QrcodeScannerStrings.anonymousCameraPrefix = function () { + return "Anonymous Camera"; + }; + Html5QrcodeScannerStrings.dragAndDropMessage = function () { + return "Or drop an image to scan"; + }; + Html5QrcodeScannerStrings.dragAndDropMessageOnlyImages = function () { + return "Or drop an image to scan (other files not supported)"; + }; + Html5QrcodeScannerStrings.zoom = function () { + return "zoom"; + }; + Html5QrcodeScannerStrings.loadingImage = function () { + return "Loading image..."; + }; + Html5QrcodeScannerStrings.cameraScanAltText = function () { + return "Camera based scan"; + }; + Html5QrcodeScannerStrings.fileScanAltText = function () { + return "Fule based scan"; + }; + return Html5QrcodeScannerStrings; +}()); +export { Html5QrcodeScannerStrings }; +var LibraryInfoStrings = (function () { + function LibraryInfoStrings() { + } + LibraryInfoStrings.poweredBy = function () { + return "Powered by "; + }; + LibraryInfoStrings.reportIssues = function () { + return "Report issues"; + }; + return LibraryInfoStrings; +}()); +export { LibraryInfoStrings }; +//# sourceMappingURL=strings.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/strings.js.map b/src/main/node_modules/html5-qrcode/esm/strings.js.map new file mode 100644 index 0000000000000000000000000000000000000000..05f81c5c89640183f5cfdc06c6393a3559508b3e --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/strings.js.map @@ -0,0 +1 @@ +{"version":3,"file":"strings.js","sourceRoot":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CAAC;IAPiB,4BAAS,GAAvB;QACI,OAAO,aAAa,CAAC;IACzB,CAAC;IAEa,+BAAY,GAA1B;QACI,OAAO,eAAe,CAAC;IAC3B,CAAC;IACL,yBAAC;AAAD,CAAC,AATD,IASC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui.d.ts b/src/main/node_modules/html5-qrcode/esm/ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f03fe96416ae95a12a35935d8b5f61c5d36d433 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui.d.ts @@ -0,0 +1,6 @@ +export declare class LibraryInfoContainer { + private infoDiv; + private infoIcon; + constructor(); + renderInto(parent: HTMLElement): void; +} diff --git a/src/main/node_modules/html5-qrcode/esm/ui.js b/src/main/node_modules/html5-qrcode/esm/ui.js new file mode 100644 index 0000000000000000000000000000000000000000..663072b26ca82fd8f8f11180413efd001ec68a00 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui.js @@ -0,0 +1,115 @@ +import { ASSET_CLOSE_ICON_16PX, ASSET_INFO_ICON_16PX } from "./image-assets"; +import { LibraryInfoStrings } from "./strings"; +var LibraryInfoDiv = (function () { + function LibraryInfoDiv() { + this.infoDiv = document.createElement("div"); + } + LibraryInfoDiv.prototype.renderInto = function (parent) { + this.infoDiv.style.position = "absolute"; + this.infoDiv.style.top = "10px"; + this.infoDiv.style.right = "10px"; + this.infoDiv.style.zIndex = "2"; + this.infoDiv.style.display = "none"; + this.infoDiv.style.padding = "5pt"; + this.infoDiv.style.border = "1px solid #171717"; + this.infoDiv.style.fontSize = "10pt"; + this.infoDiv.style.background = "rgb(0 0 0 / 69%)"; + this.infoDiv.style.borderRadius = "5px"; + this.infoDiv.style.textAlign = "center"; + this.infoDiv.style.fontWeight = "400"; + this.infoDiv.style.color = "white"; + this.infoDiv.innerText = LibraryInfoStrings.poweredBy(); + var projectLink = document.createElement("a"); + projectLink.innerText = "ScanApp"; + projectLink.href = "https://scanapp.org"; + projectLink.target = "new"; + projectLink.style.color = "white"; + this.infoDiv.appendChild(projectLink); + var breakElemFirst = document.createElement("br"); + var breakElemSecond = document.createElement("br"); + this.infoDiv.appendChild(breakElemFirst); + this.infoDiv.appendChild(breakElemSecond); + var reportIssueLink = document.createElement("a"); + reportIssueLink.innerText = LibraryInfoStrings.reportIssues(); + reportIssueLink.href = "https://github.com/mebjas/html5-qrcode/issues"; + reportIssueLink.target = "new"; + reportIssueLink.style.color = "white"; + this.infoDiv.appendChild(reportIssueLink); + parent.appendChild(this.infoDiv); + }; + LibraryInfoDiv.prototype.show = function () { + this.infoDiv.style.display = "block"; + }; + LibraryInfoDiv.prototype.hide = function () { + this.infoDiv.style.display = "none"; + }; + return LibraryInfoDiv; +}()); +var LibraryInfoIcon = (function () { + function LibraryInfoIcon(onTapIn, onTapOut) { + this.isShowingInfoIcon = true; + this.onTapIn = onTapIn; + this.onTapOut = onTapOut; + this.infoIcon = document.createElement("img"); + } + LibraryInfoIcon.prototype.renderInto = function (parent) { + var _this = this; + this.infoIcon.alt = "Info icon"; + this.infoIcon.src = ASSET_INFO_ICON_16PX; + this.infoIcon.style.position = "absolute"; + this.infoIcon.style.top = "4px"; + this.infoIcon.style.right = "4px"; + this.infoIcon.style.opacity = "0.6"; + this.infoIcon.style.cursor = "pointer"; + this.infoIcon.style.zIndex = "2"; + this.infoIcon.style.width = "16px"; + this.infoIcon.style.height = "16px"; + this.infoIcon.onmouseover = function (_) { return _this.onHoverIn(); }; + this.infoIcon.onmouseout = function (_) { return _this.onHoverOut(); }; + this.infoIcon.onclick = function (_) { return _this.onClick(); }; + parent.appendChild(this.infoIcon); + }; + LibraryInfoIcon.prototype.onHoverIn = function () { + if (this.isShowingInfoIcon) { + this.infoIcon.style.opacity = "1"; + } + }; + LibraryInfoIcon.prototype.onHoverOut = function () { + if (this.isShowingInfoIcon) { + this.infoIcon.style.opacity = "0.6"; + } + }; + LibraryInfoIcon.prototype.onClick = function () { + if (this.isShowingInfoIcon) { + this.isShowingInfoIcon = false; + this.onTapIn(); + this.infoIcon.src = ASSET_CLOSE_ICON_16PX; + this.infoIcon.style.opacity = "1"; + } + else { + this.isShowingInfoIcon = true; + this.onTapOut(); + this.infoIcon.src = ASSET_INFO_ICON_16PX; + this.infoIcon.style.opacity = "0.6"; + } + }; + return LibraryInfoIcon; +}()); +var LibraryInfoContainer = (function () { + function LibraryInfoContainer() { + var _this = this; + this.infoDiv = new LibraryInfoDiv(); + this.infoIcon = new LibraryInfoIcon(function () { + _this.infoDiv.show(); + }, function () { + _this.infoDiv.hide(); + }); + } + LibraryInfoContainer.prototype.renderInto = function (parent) { + this.infoDiv.renderInto(parent); + this.infoIcon.renderInto(parent); + }; + return LibraryInfoContainer; +}()); +export { LibraryInfoContainer }; +//# sourceMappingURL=ui.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui.js.map b/src/main/node_modules/html5-qrcode/esm/ui.js.map new file mode 100644 index 0000000000000000000000000000000000000000..9a5f97728234f11abc57f1d386207f253fda904c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/ui.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAM/C;IAGI;QACI,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IAEM,mCAAU,GAAjB,UAAkB,MAAmB;QACjC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;QACzC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;QAClC,IAAI,CAAC,OAAO,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O,EAAE,CAAC;YACf,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,qBAAqB,CAAC;YAC1C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;SACrC;aAAM;YACH,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAC9B,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,oBAAoB,CAAC;YACzC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;SACvC;IACL,CAAC;IACL,sBAAC;AAAD,CAAC,AA1DD,IA0DC;AAED;IAKI;QAAA,iBAOC;QANG,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC;YAChC,KAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,EAAE;YACC,KAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,yCAAU,GAAjB,UAAkB,MAAmB;QACjC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IACL,2BAAC;AAAD,CAAC,AAlBD,IAkBC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/base.d.ts b/src/main/node_modules/html5-qrcode/esm/ui/scanner/base.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f6ba9cf120e4959471cfef863e282fbbbb9db22 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/base.d.ts @@ -0,0 +1,16 @@ +export declare class PublicUiElementIdAndClasses { + static ALL_ELEMENT_CLASS: string; + static CAMERA_PERMISSION_BUTTON_ID: string; + static CAMERA_START_BUTTON_ID: string; + static CAMERA_STOP_BUTTON_ID: string; + static TORCH_BUTTON_ID: string; + static CAMERA_SELECTION_SELECT_ID: string; + static FILE_SELECTION_BUTTON_ID: string; + static ZOOM_SLIDER_ID: string; + static SCAN_TYPE_CHANGE_ANCHOR_ID: string; + static TORCH_BUTTON_CLASS_TORCH_ON: string; + static TORCH_BUTTON_CLASS_TORCH_OFF: string; +} +export declare class BaseUiElementFactory { + static createElement<Type extends HTMLElement>(elementType: string, elementId: string): Type; +} diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/base.js b/src/main/node_modules/html5-qrcode/esm/ui/scanner/base.js new file mode 100644 index 0000000000000000000000000000000000000000..ed154842e84c3158a2048d37ec15f0a26dbe4b41 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/base.js @@ -0,0 +1,33 @@ +var PublicUiElementIdAndClasses = (function () { + function PublicUiElementIdAndClasses() { + } + PublicUiElementIdAndClasses.ALL_ELEMENT_CLASS = "html5-qrcode-element"; + PublicUiElementIdAndClasses.CAMERA_PERMISSION_BUTTON_ID = "html5-qrcode-button-camera-permission"; + PublicUiElementIdAndClasses.CAMERA_START_BUTTON_ID = "html5-qrcode-button-camera-start"; + PublicUiElementIdAndClasses.CAMERA_STOP_BUTTON_ID = "html5-qrcode-button-camera-stop"; + PublicUiElementIdAndClasses.TORCH_BUTTON_ID = "html5-qrcode-button-torch"; + PublicUiElementIdAndClasses.CAMERA_SELECTION_SELECT_ID = "html5-qrcode-select-camera"; + PublicUiElementIdAndClasses.FILE_SELECTION_BUTTON_ID = "html5-qrcode-button-file-selection"; + PublicUiElementIdAndClasses.ZOOM_SLIDER_ID = "html5-qrcode-input-range-zoom"; + PublicUiElementIdAndClasses.SCAN_TYPE_CHANGE_ANCHOR_ID = "html5-qrcode-anchor-scan-type-change"; + PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON = "html5-qrcode-button-torch-on"; + PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF = "html5-qrcode-button-torch-off"; + return PublicUiElementIdAndClasses; +}()); +export { PublicUiElementIdAndClasses }; +var BaseUiElementFactory = (function () { + function BaseUiElementFactory() { + } + BaseUiElementFactory.createElement = function (elementType, elementId) { + var element = (document.createElement(elementType)); + element.id = elementId; + element.classList.add(PublicUiElementIdAndClasses.ALL_ELEMENT_CLASS); + if (elementType === "button") { + element.setAttribute("type", "button"); + } + return element; + }; + return BaseUiElementFactory; +}()); +export { BaseUiElementFactory }; +//# sourceMappingURL=base.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/base.js.map b/src/main/node_modules/html5-qrcode/esm/ui/scanner/base.js.map new file mode 100644 index 0000000000000000000000000000000000000000..ab784a0d25676f1a1dc3cfd9312d21af5b60681f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/base.js.map @@ -0,0 +1 @@ +{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/ui/scanner/base.ts"],"names":[],"mappings":"AAcA;IAAA;IA4CA,CAAC;IAxCU,6CAAiB,GAAG,sBAAsB,CAAC;IAG3C,uDAA2B,GAAG,uCAAuC,CAAC;IAGtE,kDAAsB,GAAG,kCAAkC,CAAC;IAG5D,iDAAqB,GAAG,iCAAiC,CAAC;IAG1D,2CAAe,GAAG,2BAA2B,CAAC;IAG9C,sDAA0B,GAAG,4BAA4B,CAAC;IAG1D,oDAAwB,GAAG,oCAAoC,CAAC;IAGhE,0CAAc,GAAG,+BAA+B,CAAC;IAMjD,sDAA0B,GAAG,sCAAsC,CAAC;IAOpE,uDAA2B,GAAG,8BAA8B,CAAC;IAG7D,wDAA4B,GAAG,+BAA+B,CAAC;IAG1E,kCAAC;CAAA,AA5CD,IA4CC;SA5CY,2BAA2B;AAiDxC;IAAA;IAiBA,CAAC;IAXiB,kCAAa,GAA3B,UACI,WAAmB,EAAE,SAAiB;QAEtC,IAAI,OAAO,GAAe,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;QAChE,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;QACvB,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,2BAA2B,CAAC,iBAAiB,CAAC,CAAC;QACrE,IAAI,WAAW,KAAK,QAAQ,EAAE;YAC1B,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;SAC1C;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IACL,2BAAC;AAAD,CAAC,AAjBD,IAiBC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-selection-ui.d.ts b/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-selection-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2090ed53de81e3fc2a4a3f33806eace194c983c9 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-selection-ui.d.ts @@ -0,0 +1,17 @@ +import { CameraDevice } from "../../camera/core"; +export declare class CameraSelectionUi { + private readonly selectElement; + private readonly options; + private readonly cameras; + private constructor(); + private render; + disable(): void; + isDisabled(): boolean; + enable(): void; + getValue(): string; + hasValue(value: string): boolean; + setValue(value: string): void; + hasSingleItem(): boolean; + numCameras(): number; + static create(parentElement: HTMLElement, cameras: Array<CameraDevice>): CameraSelectionUi; +} diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-selection-ui.js b/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-selection-ui.js new file mode 100644 index 0000000000000000000000000000000000000000..d5d422d8e2853fba9338b120d16da879874f3609 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-selection-ui.js @@ -0,0 +1,86 @@ +import { BaseUiElementFactory, PublicUiElementIdAndClasses } from "./base"; +import { Html5QrcodeScannerStrings } from "../../strings"; +var CameraSelectionUi = (function () { + function CameraSelectionUi(cameras) { + this.selectElement = BaseUiElementFactory + .createElement("select", PublicUiElementIdAndClasses.CAMERA_SELECTION_SELECT_ID); + this.cameras = cameras; + this.options = []; + } + CameraSelectionUi.prototype.render = function (parentElement) { + var cameraSelectionContainer = document.createElement("span"); + cameraSelectionContainer.style.marginRight = "10px"; + var numCameras = this.cameras.length; + if (numCameras === 0) { + throw new Error("No cameras found"); + } + if (numCameras === 1) { + cameraSelectionContainer.style.display = "none"; + } + else { + var selectCameraString = Html5QrcodeScannerStrings.selectCamera(); + cameraSelectionContainer.innerText + = "".concat(selectCameraString, " (").concat(this.cameras.length, ") "); + } + var anonymousCameraId = 1; + for (var _i = 0, _a = this.cameras; _i < _a.length; _i++) { + var camera = _a[_i]; + var value = camera.id; + var name_1 = camera.label == null ? value : camera.label; + if (!name_1 || name_1 === "") { + name_1 = [ + Html5QrcodeScannerStrings.anonymousCameraPrefix(), + anonymousCameraId++ + ].join(" "); + } + var option = document.createElement("option"); + option.value = value; + option.innerText = name_1; + this.options.push(option); + this.selectElement.appendChild(option); + } + cameraSelectionContainer.appendChild(this.selectElement); + parentElement.appendChild(cameraSelectionContainer); + }; + CameraSelectionUi.prototype.disable = function () { + this.selectElement.disabled = true; + }; + CameraSelectionUi.prototype.isDisabled = function () { + return this.selectElement.disabled === true; + }; + CameraSelectionUi.prototype.enable = function () { + this.selectElement.disabled = false; + }; + CameraSelectionUi.prototype.getValue = function () { + return this.selectElement.value; + }; + CameraSelectionUi.prototype.hasValue = function (value) { + for (var _i = 0, _a = this.options; _i < _a.length; _i++) { + var option = _a[_i]; + if (option.value === value) { + return true; + } + } + return false; + }; + CameraSelectionUi.prototype.setValue = function (value) { + if (!this.hasValue(value)) { + throw new Error("".concat(value, " is not present in the camera list.")); + } + this.selectElement.value = value; + }; + CameraSelectionUi.prototype.hasSingleItem = function () { + return this.cameras.length === 1; + }; + CameraSelectionUi.prototype.numCameras = function () { + return this.cameras.length; + }; + CameraSelectionUi.create = function (parentElement, cameras) { + var cameraSelectUi = new CameraSelectionUi(cameras); + cameraSelectUi.render(parentElement); + return cameraSelectUi; + }; + return CameraSelectionUi; +}()); +export { CameraSelectionUi }; +//# sourceMappingURL=camera-selection-ui.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-selection-ui.js.map b/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-selection-ui.js.map new file mode 100644 index 0000000000000000000000000000000000000000..abda560611e87ac8875c67acd1e6219529d29d66 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-selection-ui.js.map @@ -0,0 +1 @@ +{"version":3,"file":"camera-selection-ui.js","sourceRoot":"","sources":["../../../../src/ui/scanner/camera-selection-ui.ts"],"names":[],"mappings":"AAWA,OAAO,EACH,oBAAoB,EACpB,2BAA2B,EAC9B,MAAM,QAAQ,CAAC;AAChB,OAAO,EACH,yBAAyB,EAC5B,MAAM,eAAe,CAAC;AAGvB;IAMI,2BAAoB,OAA4B;QAC5C,IAAI,CAAC,aAAa,GAAG,oBAAoB;aACpC,aAAa,CACd,QAAQ,EACR,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;IAGO,kCAAM,GAAd,UACI,aAA0B;QAC1B,IAAM,wBAAwB,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAChE,wBAAwB,CAAC,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC;QACpD,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QACvC,IAAI,UAAU,KAAK,CAAC,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QACD,IAAI,UAAU,KAAK,CAAC,EAAE;YAElB,wBAAwB,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;SACnD;aAAM;YAEH,IAAM,kBAAkB,GAAG,yBAAyB,CAAC,YAAY,EAAE,CAAC;YACpE,wBAAwB,C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,CAAC;IACxC,CAAC;IAEM,oCAAQ,GAAf;QACI,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IACpC,CAAC;IAEM,oCAAQ,GAAf,UAAgB,KAAa;QACzB,KAAqB,UAAY,EAAZ,KAAA,IAAI,CAAC,OAAO,EAAZ,cAAY,EAAZ,IAAY,EAAE;YAA9B,IAAM,MAAM,SAAA;YACb,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE;gBACxB,OAAO,IAAI,CAAC;aACf;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,oCAAQ,GAAf,UAAgB,KAAa;QACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,UAAG,KAAK,wCAAqC,CAAC,CAAC;SAClE;QACD,IAAI,CAAC,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC;IACrC,CAAC;IAEM,yCAAa,GAApB;QACI,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC;IACrC,CAAC;IAEM,sCAAU,GAAjB;QACI,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;IAIa,wBAAM,GAApB,UACI,aAA0B,EAC1B,OAA4B;QAC5B,IAAI,cAAc,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACpD,cAAc,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACrC,OAAO,cAAc,CAAC;IAC1B,CAAC;IACL,wBAAC;AAAD,CAAC,AA5GD,IA4GC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-zoom-ui.d.ts b/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-zoom-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..215bb3f45a562941e18b27204250b45b021bc973 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-zoom-ui.d.ts @@ -0,0 +1,16 @@ +export type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; +export declare class CameraZoomUi { + private zoomElementContainer; + private rangeInput; + private rangeText; + private onChangeCallback; + private constructor(); + private render; + private onValueChange; + setValues(minValue: number, maxValue: number, defaultValue: number, step: number): void; + show(): void; + hide(): void; + setOnCameraZoomValueChangeCallback(onChangeCallback: OnCameraZoomValueChangeCallback): void; + removeOnCameraZoomValueChangeCallback(): void; + static create(parentElement: HTMLElement, renderOnCreate: boolean): CameraZoomUi; +} diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-zoom-ui.js b/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-zoom-ui.js new file mode 100644 index 0000000000000000000000000000000000000000..b80c1713d0ec3709cce22b0507d1ff2b3f342f98 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-zoom-ui.js @@ -0,0 +1,70 @@ +import { BaseUiElementFactory, PublicUiElementIdAndClasses } from "./base"; +import { Html5QrcodeScannerStrings } from "../../strings"; +var CameraZoomUi = (function () { + function CameraZoomUi() { + this.onChangeCallback = null; + this.zoomElementContainer = document.createElement("div"); + this.rangeInput = BaseUiElementFactory.createElement("input", PublicUiElementIdAndClasses.ZOOM_SLIDER_ID); + this.rangeInput.type = "range"; + this.rangeText = document.createElement("span"); + this.rangeInput.min = "1"; + this.rangeInput.max = "5"; + this.rangeInput.value = "1"; + this.rangeInput.step = "0.1"; + } + CameraZoomUi.prototype.render = function (parentElement, renderOnCreate) { + this.zoomElementContainer.style.display + = renderOnCreate ? "block" : "none"; + this.zoomElementContainer.style.padding = "5px 10px"; + this.zoomElementContainer.style.textAlign = "center"; + parentElement.appendChild(this.zoomElementContainer); + this.rangeInput.style.display = "inline-block"; + this.rangeInput.style.width = "50%"; + this.rangeInput.style.height = "5px"; + this.rangeInput.style.background = "#d3d3d3"; + this.rangeInput.style.outline = "none"; + this.rangeInput.style.opacity = "0.7"; + var zoomString = Html5QrcodeScannerStrings.zoom(); + this.rangeText.innerText = "".concat(this.rangeInput.value, "x ").concat(zoomString); + this.rangeText.style.marginRight = "10px"; + var $this = this; + this.rangeInput.addEventListener("input", function () { return $this.onValueChange(); }); + this.rangeInput.addEventListener("change", function () { return $this.onValueChange(); }); + this.zoomElementContainer.appendChild(this.rangeInput); + this.zoomElementContainer.appendChild(this.rangeText); + }; + CameraZoomUi.prototype.onValueChange = function () { + var zoomString = Html5QrcodeScannerStrings.zoom(); + this.rangeText.innerText = "".concat(this.rangeInput.value, "x ").concat(zoomString); + if (this.onChangeCallback) { + this.onChangeCallback(parseFloat(this.rangeInput.value)); + } + }; + CameraZoomUi.prototype.setValues = function (minValue, maxValue, defaultValue, step) { + this.rangeInput.min = minValue.toString(); + this.rangeInput.max = maxValue.toString(); + this.rangeInput.step = step.toString(); + this.rangeInput.value = defaultValue.toString(); + this.onValueChange(); + }; + CameraZoomUi.prototype.show = function () { + this.zoomElementContainer.style.display = "block"; + }; + CameraZoomUi.prototype.hide = function () { + this.zoomElementContainer.style.display = "none"; + }; + CameraZoomUi.prototype.setOnCameraZoomValueChangeCallback = function (onChangeCallback) { + this.onChangeCallback = onChangeCallback; + }; + CameraZoomUi.prototype.removeOnCameraZoomValueChangeCallback = function () { + this.onChangeCallback = null; + }; + CameraZoomUi.create = function (parentElement, renderOnCreate) { + var cameraZoomUi = new CameraZoomUi(); + cameraZoomUi.render(parentElement, renderOnCreate); + return cameraZoomUi; + }; + return CameraZoomUi; +}()); +export { CameraZoomUi }; +//# sourceMappingURL=camera-zoom-ui.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-zoom-ui.js.map b/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-zoom-ui.js.map new file mode 100644 index 0000000000000000000000000000000000000000..0aafbb08bb5cf73e5ad3b2d77484107e27adeb9d --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/camera-zoom-ui.js.map @@ -0,0 +1 @@ +{"version":3,"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AAU,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;SAC5D;IACL,CAAC;IAGM,gCAAS,GAAhB,UACI,QAAgB,EAChB,QAAgB,EAChB,YAAoB,EACpB,IAAY;QACZ,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAC1C,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAC1C,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvC,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;QAEhD,IAAI,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC;IAEM,2BAAI,GAAX;QACI,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IACtD,CAAC;IAEM,2BAAI,GAAX;QACI,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACrD,CAAC;IAEM,yDAAkC,GAAzC,UACI,gBAAiD;QACjD,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC7C,CAAC;IAEM,4DAAqC,GAA5C;QACI,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;IACjC,CAAC;IAOa,mBAAM,GAApB,UACI,aAA0B,EAC1B,cAAuB;QACvB,IAAI,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;QACtC,YAAY,CAAC,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QACnD,OAAO,YAAY,CAAC;IACxB,CAAC;IACL,mBAAC;AAAD,CAAC,AAxGD,IAwGC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/file-selection-ui.d.ts b/src/main/node_modules/html5-qrcode/esm/ui/scanner/file-selection-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..768f5ed8d5b9cd84994a11bca20a02224c665a75 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/file-selection-ui.d.ts @@ -0,0 +1,19 @@ +export type OnFileSelected = (file: File) => void; +export declare class FileSelectionUi { + private readonly fileBasedScanRegion; + private readonly fileScanInput; + private readonly fileSelectionButton; + private constructor(); + hide(): void; + show(): void; + isShowing(): boolean; + resetValue(): void; + private createFileBasedScanRegion; + private fileBasedScanRegionDefaultBorder; + private fileBasedScanRegionActiveBorder; + private createDragAndDropMessage; + private setImageNameToButton; + private setInitialValueToButton; + private getFileScanInputId; + static create(parentElement: HTMLDivElement, showOnRender: boolean, onFileSelected: OnFileSelected): FileSelectionUi; +} diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/file-selection-ui.js b/src/main/node_modules/html5-qrcode/esm/ui/scanner/file-selection-ui.js new file mode 100644 index 0000000000000000000000000000000000000000..5ebeade076fdf0069daa348c0ff56740f285b1e6 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/file-selection-ui.js @@ -0,0 +1,167 @@ +import { Html5QrcodeScannerStrings } from "../../strings"; +import { BaseUiElementFactory, PublicUiElementIdAndClasses } from "./base"; +var FileSelectionUi = (function () { + function FileSelectionUi(parentElement, showOnRender, onFileSelected) { + this.fileBasedScanRegion = this.createFileBasedScanRegion(); + this.fileBasedScanRegion.style.display + = showOnRender ? "block" : "none"; + parentElement.appendChild(this.fileBasedScanRegion); + var fileScanLabel = document.createElement("label"); + fileScanLabel.setAttribute("for", this.getFileScanInputId()); + fileScanLabel.style.display = "inline-block"; + this.fileBasedScanRegion.appendChild(fileScanLabel); + this.fileSelectionButton + = BaseUiElementFactory.createElement("button", PublicUiElementIdAndClasses.FILE_SELECTION_BUTTON_ID); + this.setInitialValueToButton(); + this.fileSelectionButton.addEventListener("click", function (_) { + fileScanLabel.click(); + }); + fileScanLabel.append(this.fileSelectionButton); + this.fileScanInput + = BaseUiElementFactory.createElement("input", this.getFileScanInputId()); + this.fileScanInput.type = "file"; + this.fileScanInput.accept = "image/*"; + this.fileScanInput.style.display = "none"; + fileScanLabel.appendChild(this.fileScanInput); + var $this = this; + this.fileScanInput.addEventListener("change", function (e) { + if (e == null || e.target == null) { + return; + } + var target = e.target; + if (target.files && target.files.length === 0) { + return; + } + var fileList = target.files; + var file = fileList[0]; + var fileName = file.name; + $this.setImageNameToButton(fileName); + onFileSelected(file); + }); + var dragAndDropMessage = this.createDragAndDropMessage(); + this.fileBasedScanRegion.appendChild(dragAndDropMessage); + this.fileBasedScanRegion.addEventListener("dragenter", function (event) { + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionActiveBorder(); + event.stopPropagation(); + event.preventDefault(); + }); + this.fileBasedScanRegion.addEventListener("dragleave", function (event) { + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionDefaultBorder(); + event.stopPropagation(); + event.preventDefault(); + }); + this.fileBasedScanRegion.addEventListener("dragover", function (event) { + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionActiveBorder(); + event.stopPropagation(); + event.preventDefault(); + }); + this.fileBasedScanRegion.addEventListener("drop", function (event) { + event.stopPropagation(); + event.preventDefault(); + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionDefaultBorder(); + var dataTransfer = event.dataTransfer; + if (dataTransfer) { + var files = dataTransfer.files; + if (!files || files.length === 0) { + return; + } + var isAnyFileImage = false; + for (var i = 0; i < files.length; ++i) { + var file = files.item(i); + if (!file) { + continue; + } + var imageType = /image.*/; + if (!file.type.match(imageType)) { + continue; + } + isAnyFileImage = true; + var fileName = file.name; + $this.setImageNameToButton(fileName); + onFileSelected(file); + dragAndDropMessage.innerText + = Html5QrcodeScannerStrings.dragAndDropMessage(); + break; + } + if (!isAnyFileImage) { + dragAndDropMessage.innerText + = Html5QrcodeScannerStrings + .dragAndDropMessageOnlyImages(); + } + } + }); + } + FileSelectionUi.prototype.hide = function () { + this.fileBasedScanRegion.style.display = "none"; + this.fileScanInput.disabled = true; + }; + FileSelectionUi.prototype.show = function () { + this.fileBasedScanRegion.style.display = "block"; + this.fileScanInput.disabled = false; + }; + FileSelectionUi.prototype.isShowing = function () { + return this.fileBasedScanRegion.style.display === "block"; + }; + FileSelectionUi.prototype.resetValue = function () { + this.fileScanInput.value = ""; + this.setInitialValueToButton(); + }; + FileSelectionUi.prototype.createFileBasedScanRegion = function () { + var fileBasedScanRegion = document.createElement("div"); + fileBasedScanRegion.style.textAlign = "center"; + fileBasedScanRegion.style.margin = "auto"; + fileBasedScanRegion.style.width = "80%"; + fileBasedScanRegion.style.maxWidth = "600px"; + fileBasedScanRegion.style.border + = this.fileBasedScanRegionDefaultBorder(); + fileBasedScanRegion.style.padding = "10px"; + fileBasedScanRegion.style.marginBottom = "10px"; + return fileBasedScanRegion; + }; + FileSelectionUi.prototype.fileBasedScanRegionDefaultBorder = function () { + return "6px dashed #ebebeb"; + }; + FileSelectionUi.prototype.fileBasedScanRegionActiveBorder = function () { + return "6px dashed rgb(153 151 151)"; + }; + FileSelectionUi.prototype.createDragAndDropMessage = function () { + var dragAndDropMessage = document.createElement("div"); + dragAndDropMessage.innerText + = Html5QrcodeScannerStrings.dragAndDropMessage(); + dragAndDropMessage.style.fontWeight = "400"; + return dragAndDropMessage; + }; + FileSelectionUi.prototype.setImageNameToButton = function (imageFileName) { + var MAX_CHARS = 20; + if (imageFileName.length > MAX_CHARS) { + var start8Chars = imageFileName.substring(0, 8); + var length_1 = imageFileName.length; + var last8Chars = imageFileName.substring(length_1 - 8, length_1); + imageFileName = "".concat(start8Chars, "....").concat(last8Chars); + } + var newText = Html5QrcodeScannerStrings.fileSelectionChooseAnother() + + " - " + + imageFileName; + this.fileSelectionButton.innerText = newText; + }; + FileSelectionUi.prototype.setInitialValueToButton = function () { + var initialText = Html5QrcodeScannerStrings.fileSelectionChooseImage() + + " - " + + Html5QrcodeScannerStrings.fileSelectionNoImageSelected(); + this.fileSelectionButton.innerText = initialText; + }; + FileSelectionUi.prototype.getFileScanInputId = function () { + return "html5-qrcode-private-filescan-input"; + }; + FileSelectionUi.create = function (parentElement, showOnRender, onFileSelected) { + var button = new FileSelectionUi(parentElement, showOnRender, onFileSelected); + return button; + }; + return FileSelectionUi; +}()); +export { FileSelectionUi }; +//# sourceMappingURL=file-selection-ui.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/file-selection-ui.js.map b/src/main/node_modules/html5-qrcode/esm/ui/scanner/file-selection-ui.js.map new file mode 100644 index 0000000000000000000000000000000000000000..12f28dea7e92636926578117fa2e79f7109fa57b --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/file-selection-ui.js.map @@ -0,0 +1 @@ +{"version":3,"file":"file-selection-ui.js","sourceRoot":"","sources":["../../../../src/ui/scanner/file-selection-ui.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,yBAAyB,EAAC,MAAM,eAAe,CAAC;AACxD,OAAO,EACH,oBAAoB,EACpB,2BAA2B,EAC9B,MAAM,QAAQ,CAAC;AAQhB;IAOI,yBACI,aAA6B,EAC7B,YAAqB,EACrB,cAA8B;QAC9B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAC5D,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO;cAChC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;QACtC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAEpD,IAAI,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACpD,aAAa,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC;QAC7D,aAAa,CAAC,KAAK,CAAC,OAAO,GAAG,cAAc,CAAC;QAE7C,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QAEpD,IAAI,CAAC,mBAA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,aAAqB;QAC9C,IAAM,SAAS,GAAG,EAAE,CAAC;QACrB,IAAI,aAAa,CAAC,MAAM,GAAG,SAAS,EAAE;YAIlC,IAAI,WAAW,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAChD,IAAI,QAAM,GAAG,aAAa,CAAC,MAAM,CAAC;YAClC,IAAI,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,QAAM,GAAG,CAAC,EAAE,QAAM,CAAC,CAAC;YAC7D,aAAa,GAAG,UAAG,WAAW,iBAAO,UAAU,CAAE,CAAC;SACrD;QAED,IAAI,OAAO,GAAG,yBAAyB,CAAC,0BAA0B,EAAE;cAC9D,KAAK;cACL,aAAa,CAAC;QACpB,IAAI,CAAC,mBAAmB,CAAC,SAAS,GAAG,OAAO,CAAC;IACjD,CAAC;IAEO,iDAAuB,GAA/B;QACI,IAAI,WAAW,GAAG,yBAAyB,CAAC,wBAAwB,EAAE;cAChE,KAAK;cACL,yBAAyB,CAAC,4BAA4B,EAAE,CAAC;QAC/D,IAAI,CAAC,mBAAmB,CAAC,SAAS,GAAG,WAAW,CAAC;IACrD,CAAC;IAEO,4CAAkB,GAA1B;QACI,OAAO,qCAAqC,CAAC;IACjD,CAAC;IAaa,sBAAM,GAApB,UACI,aAA6B,EAC7B,YAAqB,EACrB,cAA8B;QAC9B,IAAI,MAAM,GAAG,IAAI,eAAe,CAC5B,aAAa,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC;IAClB,CAAC;IACL,sBAAC;AAAD,CAAC,AAhPD,IAgPC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/scan-type-selector.d.ts b/src/main/node_modules/html5-qrcode/esm/ui/scanner/scan-type-selector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f0e1347449e85244139b7cf48cd52b2fca300cb --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/scan-type-selector.d.ts @@ -0,0 +1,11 @@ +import { Html5QrcodeScanType } from "../../core"; +export declare class ScanTypeSelector { + private supportedScanTypes; + constructor(supportedScanTypes?: Array<Html5QrcodeScanType> | []); + getDefaultScanType(): Html5QrcodeScanType; + hasMoreThanOneScanType(): boolean; + isCameraScanRequired(): boolean; + static isCameraScanType(scanType: Html5QrcodeScanType): boolean; + static isFileScanType(scanType: Html5QrcodeScanType): boolean; + private validateAndReturnScanTypes; +} diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/scan-type-selector.js b/src/main/node_modules/html5-qrcode/esm/ui/scanner/scan-type-selector.js new file mode 100644 index 0000000000000000000000000000000000000000..9b145b78cc6d10dc29bc00a2a7a9161ae0dcfc71 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/scan-type-selector.js @@ -0,0 +1,48 @@ +import { Html5QrcodeScanType, Html5QrcodeConstants } from "../../core"; +var ScanTypeSelector = (function () { + function ScanTypeSelector(supportedScanTypes) { + this.supportedScanTypes = this.validateAndReturnScanTypes(supportedScanTypes); + } + ScanTypeSelector.prototype.getDefaultScanType = function () { + return this.supportedScanTypes[0]; + }; + ScanTypeSelector.prototype.hasMoreThanOneScanType = function () { + return this.supportedScanTypes.length > 1; + }; + ScanTypeSelector.prototype.isCameraScanRequired = function () { + for (var _i = 0, _a = this.supportedScanTypes; _i < _a.length; _i++) { + var scanType = _a[_i]; + if (ScanTypeSelector.isCameraScanType(scanType)) { + return true; + } + } + return false; + }; + ScanTypeSelector.isCameraScanType = function (scanType) { + return scanType === Html5QrcodeScanType.SCAN_TYPE_CAMERA; + }; + ScanTypeSelector.isFileScanType = function (scanType) { + return scanType === Html5QrcodeScanType.SCAN_TYPE_FILE; + }; + ScanTypeSelector.prototype.validateAndReturnScanTypes = function (supportedScanTypes) { + if (!supportedScanTypes || supportedScanTypes.length === 0) { + return Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE; + } + var maxExpectedValues = Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE.length; + if (supportedScanTypes.length > maxExpectedValues) { + throw "Max ".concat(maxExpectedValues, " values expected for ") + + "supportedScanTypes"; + } + for (var _i = 0, supportedScanTypes_1 = supportedScanTypes; _i < supportedScanTypes_1.length; _i++) { + var scanType = supportedScanTypes_1[_i]; + if (!Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE + .includes(scanType)) { + throw "Unsupported scan type ".concat(scanType); + } + } + return supportedScanTypes; + }; + return ScanTypeSelector; +}()); +export { ScanTypeSelector }; +//# sourceMappingURL=scan-type-selector.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/scan-type-selector.js.map b/src/main/node_modules/html5-qrcode/esm/ui/scanner/scan-type-selector.js.map new file mode 100644 index 0000000000000000000000000000000000000000..dfde556231d5b9b6702179c3fe9250bc49fdb12f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/scan-type-selector.js.map @@ -0,0 +1 @@ +{"version":3,"file":"scan-type-selector.js","sourceRoot":"","sources":["../../../../src/ui/scanner/scan-type-selector.ts"],"names":[],"mappings":"AAUA,OAAO,EACH,mBAAmB,EACnB,oBAAoB,EACvB,MAAM,YAAY,CAAC;AAGpB;IAGI,0BAAY,kBAAoD;QAC5D,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,0BAA0B,CACrD,kBAAkB,CAAC,CAAC;IAC5B,CAAC;IAMM,6CAAkB,GAAzB;QACI,OAAO,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAMM,iDAAsB,GAA7B;QACI,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9C,CAAC;IAGM,+CAAoB,GAA3B;QACI,KAAuB,UAAuB,EAAvB,KAAA,IAAI,CAAC,kBAAkB,EAAvB,cAAuB,EAAvB,IAAuB,EAAE;YAA3C,IAAM,QAAQ,SAAA;YACf,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE;gBAC7C,OAAO,IAAI,CAAC;aACf;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAGa,iCAAgB,GAA9B,UAA+B,QAA6B;QACxD,OAAO,QAAQ,KAAK,mBAAmB,CAAC,gBAAgB,CAAC;IAC7D,CAAC;IAGa,+BAAc,GAA5B,UAA6B,QAA6B;QACtD,OAAO,QAAQ,KAAK,mBAAmB,CAAC,cAAc,CAAC;IAC3D,CAAC;IAQO,qDAA0B,GAAlC,UACI,kBAA8C;QAG9C,IAAI,CAAC,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE;YACxD,OAAO,oBAAoB,CAAC,2BAA2B,CAAC;SAC3D;QAGD,IAAI,iBAAiB,GACf,oBAAoB,CAAC,2BAA2B,CAAC,MAAM,CAAC;QAC9D,IAAI,kBAAkB,CAAC,MAAM,GAAG,iBAAiB,EAAE;YAC/C,MAAM,cAAO,iBAAiB,0BAAuB;kBAC/C,oBAAoB,CAAC;SAC9B;QAGD,KAAuB,UAAkB,EAAlB,yCAAkB,EAAlB,gCAAkB,EAAlB,IAAkB,EAAE;YAAtC,IAAM,QAAQ,2BAAA;YACf,IAAI,CAAC,oBAAoB,CAAC,2BAA2B;iBAC5C,QAAQ,CAAC,QAAQ,CAAC,EAAE;gBACzB,MAAM,gCAAyB,QAAQ,CAAE,CAAC;aAC7C;SACJ;QAED,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAEL,uBAAC;AAAD,CAAC,AA7ED,IA6EC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/torch-button.d.ts b/src/main/node_modules/html5-qrcode/esm/ui/scanner/torch-button.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a862a10bae47503e7ee4e8875da199ff90538d6f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/torch-button.d.ts @@ -0,0 +1,28 @@ +import { BooleanCameraCapability } from "../../camera/core"; +export type OnTorchActionFailureCallback = (failureMessage: string) => void; +interface TorchButtonController { + disable(): void; + enable(): void; + setText(text: string): void; +} +export interface TorchButtonOptions { + display: string; + marginLeft: string; +} +export declare class TorchButton implements TorchButtonController { + private readonly torchButton; + private readonly onTorchActionFailureCallback; + private torchController; + private constructor(); + private render; + updateTorchCapability(torchCapability: BooleanCameraCapability): void; + getTorchButton(): HTMLButtonElement; + hide(): void; + show(): void; + disable(): void; + enable(): void; + setText(text: string): void; + reset(): void; + static create(parentElement: HTMLElement, torchCapability: BooleanCameraCapability, torchButtonOptions: TorchButtonOptions, onTorchActionFailureCallback: OnTorchActionFailureCallback): TorchButton; +} +export {}; diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/torch-button.js b/src/main/node_modules/html5-qrcode/esm/ui/scanner/torch-button.js new file mode 100644 index 0000000000000000000000000000000000000000..5b31efb741ea8047b0b0c63743db47b50dbaeceb --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/torch-button.js @@ -0,0 +1,168 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +import { Html5QrcodeScannerStrings } from "../../strings"; +import { BaseUiElementFactory, PublicUiElementIdAndClasses } from "./base"; +var TorchController = (function () { + function TorchController(torchCapability, buttonController, onTorchActionFailureCallback) { + this.isTorchOn = false; + this.torchCapability = torchCapability; + this.buttonController = buttonController; + this.onTorchActionFailureCallback = onTorchActionFailureCallback; + } + TorchController.prototype.isTorchEnabled = function () { + return this.isTorchOn; + }; + TorchController.prototype.flipState = function () { + return __awaiter(this, void 0, void 0, function () { + var isTorchOnExpected, error_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + this.buttonController.disable(); + isTorchOnExpected = !this.isTorchOn; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + return [4, this.torchCapability.apply(isTorchOnExpected)]; + case 2: + _a.sent(); + this.updateUiBasedOnLatestSettings(this.torchCapability.value(), isTorchOnExpected); + return [3, 4]; + case 3: + error_1 = _a.sent(); + this.propagateFailure(isTorchOnExpected, error_1); + this.buttonController.enable(); + return [3, 4]; + case 4: return [2]; + } + }); + }); + }; + TorchController.prototype.updateUiBasedOnLatestSettings = function (isTorchOn, isTorchOnExpected) { + if (isTorchOn === isTorchOnExpected) { + this.buttonController.setText(isTorchOnExpected + ? Html5QrcodeScannerStrings.torchOffButton() + : Html5QrcodeScannerStrings.torchOnButton()); + this.isTorchOn = isTorchOnExpected; + } + else { + this.propagateFailure(isTorchOnExpected); + } + this.buttonController.enable(); + }; + TorchController.prototype.propagateFailure = function (isTorchOnExpected, error) { + var errorMessage = isTorchOnExpected + ? Html5QrcodeScannerStrings.torchOnFailedMessage() + : Html5QrcodeScannerStrings.torchOffFailedMessage(); + if (error) { + errorMessage += "; Error = " + error; + } + this.onTorchActionFailureCallback(errorMessage); + }; + TorchController.prototype.reset = function () { + this.isTorchOn = false; + }; + return TorchController; +}()); +var TorchButton = (function () { + function TorchButton(torchCapability, onTorchActionFailureCallback) { + this.onTorchActionFailureCallback = onTorchActionFailureCallback; + this.torchButton + = BaseUiElementFactory.createElement("button", PublicUiElementIdAndClasses.TORCH_BUTTON_ID); + this.torchController = new TorchController(torchCapability, this, onTorchActionFailureCallback); + } + TorchButton.prototype.render = function (parentElement, torchButtonOptions) { + var _this = this; + this.torchButton.innerText + = Html5QrcodeScannerStrings.torchOnButton(); + this.torchButton.style.display = torchButtonOptions.display; + this.torchButton.style.marginLeft = torchButtonOptions.marginLeft; + var $this = this; + this.torchButton.addEventListener("click", function (_) { return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4, $this.torchController.flipState()]; + case 1: + _a.sent(); + if ($this.torchController.isTorchEnabled()) { + $this.torchButton.classList.remove(PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF); + $this.torchButton.classList.add(PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON); + } + else { + $this.torchButton.classList.remove(PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON); + $this.torchButton.classList.add(PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF); + } + return [2]; + } + }); + }); }); + parentElement.appendChild(this.torchButton); + }; + TorchButton.prototype.updateTorchCapability = function (torchCapability) { + this.torchController = new TorchController(torchCapability, this, this.onTorchActionFailureCallback); + }; + TorchButton.prototype.getTorchButton = function () { + return this.torchButton; + }; + TorchButton.prototype.hide = function () { + this.torchButton.style.display = "none"; + }; + TorchButton.prototype.show = function () { + this.torchButton.style.display = "inline-block"; + }; + TorchButton.prototype.disable = function () { + this.torchButton.disabled = true; + }; + TorchButton.prototype.enable = function () { + this.torchButton.disabled = false; + }; + TorchButton.prototype.setText = function (text) { + this.torchButton.innerText = text; + }; + TorchButton.prototype.reset = function () { + this.torchButton.innerText = Html5QrcodeScannerStrings.torchOnButton(); + this.torchController.reset(); + }; + TorchButton.create = function (parentElement, torchCapability, torchButtonOptions, onTorchActionFailureCallback) { + var button = new TorchButton(torchCapability, onTorchActionFailureCallback); + button.render(parentElement, torchButtonOptions); + return button; + }; + return TorchButton; +}()); +export { TorchButton }; +//# sourceMappingURL=torch-button.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/ui/scanner/torch-button.js.map b/src/main/node_modules/html5-qrcode/esm/ui/scanner/torch-button.js.map new file mode 100644 index 0000000000000000000000000000000000000000..1f9b3950588b07fc3f67612f451b8aff1e9fa545 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/ui/scanner/torch-button.js.map @@ -0,0 +1 @@ +{"version":3,"file":"torch-button.js","sourceRoot":"","sources":["../../../../src/ui/scanner/torch-button.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACH,oBAAoB,EACpB,2BAA2B,EAC9B,MAAM,QAAQ,CAAC;AAehB;IAQI,yBACI,eAAwC,EACxC,gBAAuC,EACvC,4BAA0D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IACjC,CAAC;IAWc,kBAAM,GAApB,UACG,aAA0B,EAC1B,eAAwC,EACxC,kBAAsC,EACtC,4BAA0D;QAE1D,IAAI,MAAM,GAAG,IAAI,WAAW,CACxB,eAAe,EAAE,4BAA4B,CAAC,CAAC;QACnD,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC;IAClB,CAAC;IACL,kBAAC;AAAD,CAAC,AA5GD,IA4GC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/utils.d.ts b/src/main/node_modules/html5-qrcode/esm/utils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b060ed9e1f751f6c8a3592683ce5726bf6d3e20 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/utils.d.ts @@ -0,0 +1,4 @@ +import { Logger } from "./core"; +export declare class VideoConstraintsUtil { + static isMediaStreamConstraintsValid(videoConstraints: MediaTrackConstraints, logger: Logger): boolean; +} diff --git a/src/main/node_modules/html5-qrcode/esm/utils.js b/src/main/node_modules/html5-qrcode/esm/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..93531f88151504572cba215d3895aef0aab55bc7 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/utils.js @@ -0,0 +1,35 @@ +var VideoConstraintsUtil = (function () { + function VideoConstraintsUtil() { + } + VideoConstraintsUtil.isMediaStreamConstraintsValid = function (videoConstraints, logger) { + if (typeof videoConstraints !== "object") { + var typeofVideoConstraints = typeof videoConstraints; + logger.logError("videoConstraints should be of type object, the " + + "object passed is of type ".concat(typeofVideoConstraints, "."), true); + return false; + } + var bannedKeys = [ + "autoGainControl", + "channelCount", + "echoCancellation", + "latency", + "noiseSuppression", + "sampleRate", + "sampleSize", + "volume" + ]; + var bannedkeysSet = new Set(bannedKeys); + var keysInVideoConstraints = Object.keys(videoConstraints); + for (var _i = 0, keysInVideoConstraints_1 = keysInVideoConstraints; _i < keysInVideoConstraints_1.length; _i++) { + var key = keysInVideoConstraints_1[_i]; + if (bannedkeysSet.has(key)) { + logger.logError("".concat(key, " is not supported videoConstaints."), true); + return false; + } + } + return true; + }; + return VideoConstraintsUtil; +}()); +export { VideoConstraintsUtil }; +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/utils.js.map b/src/main/node_modules/html5-qrcode/esm/utils.js.map new file mode 100644 index 0000000000000000000000000000000000000000..3bec475161b5de50f978f283f58328bb63982757 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAeA;IAAA;IAqCA,CAAC;IApCiB,kDAA6B,GAA3C,UACI,gBAAuC,EACvC,MAAc;QACd,IAAI,OAAO,gBAAgB,KAAK,QAAQ,EAAE;YACtC,IAAM,sBAAsB,GAAG,OAAO,gBAAgB,CAAC;YACvD,MAAM,CAAC,QAAQ,CACX,iDAAiD;kBAC3C,mCAA4B,sBAAsB,MAAG,EACvC,IAAI,CAAC,CAAC;YAC9B,OAAO,KAAK,CAAC;SAChB;QAGD,IAAM,UAAU,GAAG;YACf,iBAAiB;YACjB,cAAc;YACd,kBAAkB;YAClB,SAAS;YACT,kBAAkB;YAClB,YAAY;YACZ,YAAY;YACZ,QAAQ;SACX,CAAC;QACF,IAAM,aAAa,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;QAC1C,IAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC7D,KAAkB,UAAsB,EAAtB,iDAAsB,EAAtB,oCAAsB,EAAtB,IAAsB,EAAE;YAArC,IAAM,GAAG,+BAAA;YACV,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBACxB,MAAM,CAAC,QAAQ,CACX,UAAG,GAAG,uCAAoC,EACtB,IAAI,CAAC,CAAC;gBAC9B,OAAO,KAAK,CAAC;aAChB;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IACL,2BAAC;AAAD,CAAC,AArCD,IAqCC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/zxing-html5-qrcode-decoder.d.ts b/src/main/node_modules/html5-qrcode/esm/zxing-html5-qrcode-decoder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..411d37712f3a62354959625cbe40dce24d67f1cc --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/zxing-html5-qrcode-decoder.d.ts @@ -0,0 +1,15 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, Logger, QrcodeDecoderAsync } from "./core"; +export declare class ZXingHtml5QrcodeDecoder implements QrcodeDecoderAsync { + private readonly formatMap; + private readonly reverseFormatMap; + private hints; + private verbose; + private logger; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private decode; + private createReverseFormatMap; + private toHtml5QrcodeSupportedFormats; + private createZXingFormats; + private createDebugData; +} diff --git a/src/main/node_modules/html5-qrcode/esm/zxing-html5-qrcode-decoder.js b/src/main/node_modules/html5-qrcode/esm/zxing-html5-qrcode-decoder.js new file mode 100644 index 0000000000000000000000000000000000000000..a117c8292e589548f53ee9474ca51a8cf1f4ad5a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/zxing-html5-qrcode-decoder.js @@ -0,0 +1,106 @@ +import * as ZXing from "../third_party/zxing-js.umd"; +import { QrcodeResultFormat, Html5QrcodeSupportedFormats } from "./core"; +var ZXingHtml5QrcodeDecoder = (function () { + function ZXingHtml5QrcodeDecoder(requestedFormats, verbose, logger) { + this.formatMap = new Map([ + [Html5QrcodeSupportedFormats.QR_CODE, ZXing.BarcodeFormat.QR_CODE], + [Html5QrcodeSupportedFormats.AZTEC, ZXing.BarcodeFormat.AZTEC], + [Html5QrcodeSupportedFormats.CODABAR, ZXing.BarcodeFormat.CODABAR], + [Html5QrcodeSupportedFormats.CODE_39, ZXing.BarcodeFormat.CODE_39], + [Html5QrcodeSupportedFormats.CODE_93, ZXing.BarcodeFormat.CODE_93], + [ + Html5QrcodeSupportedFormats.CODE_128, + ZXing.BarcodeFormat.CODE_128 + ], + [ + Html5QrcodeSupportedFormats.DATA_MATRIX, + ZXing.BarcodeFormat.DATA_MATRIX + ], + [ + Html5QrcodeSupportedFormats.MAXICODE, + ZXing.BarcodeFormat.MAXICODE + ], + [Html5QrcodeSupportedFormats.ITF, ZXing.BarcodeFormat.ITF], + [Html5QrcodeSupportedFormats.EAN_13, ZXing.BarcodeFormat.EAN_13], + [Html5QrcodeSupportedFormats.EAN_8, ZXing.BarcodeFormat.EAN_8], + [Html5QrcodeSupportedFormats.PDF_417, ZXing.BarcodeFormat.PDF_417], + [Html5QrcodeSupportedFormats.RSS_14, ZXing.BarcodeFormat.RSS_14], + [ + Html5QrcodeSupportedFormats.RSS_EXPANDED, + ZXing.BarcodeFormat.RSS_EXPANDED + ], + [Html5QrcodeSupportedFormats.UPC_A, ZXing.BarcodeFormat.UPC_A], + [Html5QrcodeSupportedFormats.UPC_E, ZXing.BarcodeFormat.UPC_E], + [ + Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, + ZXing.BarcodeFormat.UPC_EAN_EXTENSION + ] + ]); + this.reverseFormatMap = this.createReverseFormatMap(); + if (!ZXing) { + throw "Use html5qrcode.min.js without edit, ZXing not found."; + } + this.verbose = verbose; + this.logger = logger; + var formats = this.createZXingFormats(requestedFormats); + var hints = new Map(); + hints.set(ZXing.DecodeHintType.POSSIBLE_FORMATS, formats); + hints.set(ZXing.DecodeHintType.TRY_HARDER, false); + this.hints = hints; + } + ZXingHtml5QrcodeDecoder.prototype.decodeAsync = function (canvas) { + var _this = this; + return new Promise(function (resolve, reject) { + try { + resolve(_this.decode(canvas)); + } + catch (error) { + reject(error); + } + }); + }; + ZXingHtml5QrcodeDecoder.prototype.decode = function (canvas) { + var zxingDecoder = new ZXing.MultiFormatReader(this.verbose, this.hints); + var luminanceSource = new ZXing.HTMLCanvasElementLuminanceSource(canvas); + var binaryBitmap = new ZXing.BinaryBitmap(new ZXing.HybridBinarizer(luminanceSource)); + var result = zxingDecoder.decode(binaryBitmap); + return { + text: result.text, + format: QrcodeResultFormat.create(this.toHtml5QrcodeSupportedFormats(result.format)), + debugData: this.createDebugData() + }; + }; + ZXingHtml5QrcodeDecoder.prototype.createReverseFormatMap = function () { + var result = new Map(); + this.formatMap.forEach(function (value, key, _) { + result.set(value, key); + }); + return result; + }; + ZXingHtml5QrcodeDecoder.prototype.toHtml5QrcodeSupportedFormats = function (zxingFormat) { + if (!this.reverseFormatMap.has(zxingFormat)) { + throw "reverseFormatMap doesn't have ".concat(zxingFormat); + } + return this.reverseFormatMap.get(zxingFormat); + }; + ZXingHtml5QrcodeDecoder.prototype.createZXingFormats = function (requestedFormats) { + var zxingFormats = []; + for (var _i = 0, requestedFormats_1 = requestedFormats; _i < requestedFormats_1.length; _i++) { + var requestedFormat = requestedFormats_1[_i]; + if (this.formatMap.has(requestedFormat)) { + zxingFormats.push(this.formatMap.get(requestedFormat)); + } + else { + this.logger.logError("".concat(requestedFormat, " is not supported by") + + "ZXingHtml5QrcodeShim"); + } + } + return zxingFormats; + }; + ZXingHtml5QrcodeDecoder.prototype.createDebugData = function () { + return { decoderName: "zxing-js" }; + }; + return ZXingHtml5QrcodeDecoder; +}()); +export { ZXingHtml5QrcodeDecoder }; +//# sourceMappingURL=zxing-html5-qrcode-decoder.js.map \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/esm/zxing-html5-qrcode-decoder.js.map b/src/main/node_modules/html5-qrcode/esm/zxing-html5-qrcode-decoder.js.map new file mode 100644 index 0000000000000000000000000000000000000000..7b991dcbf521a898b142279d35f4140edeb19910 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/esm/zxing-html5-qrcode-decoder.js.map @@ -0,0 +1 @@ +{"version":3,"file":"zxing-html5-qrcode-decoder.js","sourceRoot":"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C,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;gBACrC,YAAY,CAAC,IAAI,CACb,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;aAC5C;iBAAM;gBACH,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAG,eAAe,yBAAsB;sBACvD,sBAAsB,CAAC,CAAC;aACjC;SACJ;QACD,OAAO,YAAY,CAAC;IAC5B,CAAC;IAEO,iDAAe,GAAvB;QACI,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;IACvC,CAAC;IACL,8BAAC;AAAD,CAAC,AAhID,IAgIC"} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/experimental-features.d.ts b/src/main/node_modules/html5-qrcode/experimental-features.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0413abebd02d9788902f9ad47e60d2673507c5fe --- /dev/null +++ b/src/main/node_modules/html5-qrcode/experimental-features.d.ts @@ -0,0 +1,3 @@ +export interface ExperimentalFeaturesConfig { + useBarCodeDetectorIfSupported?: boolean | undefined; +} diff --git a/src/main/node_modules/html5-qrcode/html5-qrcode-scanner.d.ts b/src/main/node_modules/html5-qrcode/html5-qrcode-scanner.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..417175bc07418ec36023c076274aef557b25f42b --- /dev/null +++ b/src/main/node_modules/html5-qrcode/html5-qrcode-scanner.d.ts @@ -0,0 +1,67 @@ +import { Html5QrcodeScanType, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; +import { Html5QrcodeConfigs, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; +import { Html5QrcodeScannerState } from "./state-manager"; +export interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { + rememberLastUsedCamera?: boolean | undefined; + supportedScanTypes?: Array<Html5QrcodeScanType> | []; + showTorchButtonIfSupported?: boolean | undefined; + showZoomSliderIfSupported?: boolean | undefined; + defaultZoomValueIfSupported?: number | undefined; +} +export declare class Html5QrcodeScanner { + private elementId; + private config; + private verbose; + private currentScanType; + private sectionSwapAllowed; + private persistedDataManager; + private scanTypeSelector; + private logger; + private html5Qrcode; + private qrCodeSuccessCallback; + private qrCodeErrorCallback; + private lastMatchFound; + private cameraScanImage; + private fileScanImage; + private fileSelectionUi; + constructor(elementId: string, config: Html5QrcodeScannerConfig | undefined, verbose: boolean | undefined); + render(qrCodeSuccessCallback: QrcodeSuccessCallback, qrCodeErrorCallback: QrcodeErrorCallback | undefined): void; + pause(shouldPauseVideo?: boolean): void; + resume(): void; + getState(): Html5QrcodeScannerState; + clear(): Promise<void>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + applyVideoConstraints(videoConstaints: MediaTrackConstraints): Promise<void>; + private getHtml5QrcodeOrFail; + private createConfig; + private createBasicLayout; + private resetBasicLayout; + private setupInitialDashboard; + private createHeader; + private createSection; + private createCameraListUi; + private createPermissionButton; + private createPermissionsUi; + private createSectionControlPanel; + private renderFileScanUi; + private renderCameraSelection; + private createSectionSwap; + private startCameraScanIfPermissionExistsOnSwap; + private resetHeaderMessage; + private setHeaderMessage; + private showHideScanTypeSwapLink; + private insertCameraScanImageToScanRegion; + private insertFileScanImageToScanRegion; + private clearScanRegion; + private getDashboardSectionId; + private getDashboardSectionCameraScanRegionId; + private getDashboardSectionSwapLinkId; + private getScanRegionId; + private getDashboardId; + private getHeaderMessageContainerId; + private getCameraPermissionButtonId; + private getCameraScanRegion; + private getDashboardSectionSwapLink; + private getHeaderMessageDiv; +} diff --git a/src/main/node_modules/html5-qrcode/html5-qrcode.d.ts b/src/main/node_modules/html5-qrcode/html5-qrcode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e576933e30835c6b726b5e90faa67d6f3721a3a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/html5-qrcode.d.ts @@ -0,0 +1,75 @@ +import { QrcodeErrorCallback, QrcodeSuccessCallback, Html5QrcodeSupportedFormats, Html5QrcodeResult, QrDimensions, QrDimensionFunction } from "./core"; +import { CameraDevice, CameraCapabilities } from "./camera/core"; +import { ExperimentalFeaturesConfig } from "./experimental-features"; +import { Html5QrcodeScannerState } from "./state-manager"; +export interface Html5QrcodeConfigs { + formatsToSupport?: Array<Html5QrcodeSupportedFormats> | undefined; + useBarCodeDetectorIfSupported?: boolean | undefined; + experimentalFeatures?: ExperimentalFeaturesConfig | undefined; +} +export interface Html5QrcodeFullConfig extends Html5QrcodeConfigs { + verbose: boolean | undefined; +} +export interface Html5QrcodeCameraScanConfig { + fps: number | undefined; + qrbox?: number | QrDimensions | QrDimensionFunction | undefined; + aspectRatio?: number | undefined; + disableFlip?: boolean | undefined; + videoConstraints?: MediaTrackConstraints | undefined; +} +export declare class Html5Qrcode { + private readonly logger; + private readonly elementId; + private readonly verbose; + private readonly qrcode; + private shouldScan; + private element; + private canvasElement; + private scannerPausedUiElement; + private hasBorderShaders; + private borderShaders; + private qrMatch; + private renderedCamera; + private foreverScanTimeout; + private qrRegion; + private context; + private lastScanImageFile; + private stateManagerProxy; + isScanning: boolean; + constructor(elementId: string, configOrVerbosityFlag?: boolean | Html5QrcodeFullConfig | undefined); + start(cameraIdOrConfig: string | MediaTrackConstraints, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; + pause(shouldPauseVideo?: boolean): void; + resume(): void; + getState(): Html5QrcodeScannerState; + stop(): Promise<void>; + scanFile(imageFile: File, showImage?: boolean): Promise<string>; + scanFileV2(imageFile: File, showImage?: boolean): Promise<Html5QrcodeResult>; + clear(): void; + static getCameras(): Promise<Array<CameraDevice>>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + getRunningTrackCameraCapabilities(): CameraCapabilities; + applyVideoConstraints(videoConstaints: MediaTrackConstraints): Promise<void>; + private getRenderedCameraOrFail; + private getSupportedFormats; + private getUseBarCodeDetectorIfSupported; + private validateQrboxSize; + private validateQrboxConfig; + private toQrdimensions; + private setupUi; + private createScannerPausedUiElement; + private scanContext; + private foreverScan; + private createVideoConstraints; + private computeCanvasDrawConfig; + private clearElement; + private possiblyUpdateShaders; + private possiblyCloseLastScanImageFile; + private createCanvasElement; + private getShadedRegionBounds; + private possiblyInsertShadingElement; + private insertShaderBorders; + private showPausedState; + private hidePausedState; + private getTimeoutFps; +} diff --git a/src/main/node_modules/html5-qrcode/html5-qrcode.min.js b/src/main/node_modules/html5-qrcode/html5-qrcode.min.js new file mode 100644 index 0000000000000000000000000000000000000000..18db263dbdc958f63f14c4904cb7e2124c766ecc --- /dev/null +++ b/src/main/node_modules/html5-qrcode/html5-qrcode.min.js @@ -0,0 +1 @@ +var __Html5QrcodeLibrary__;(()=>{var t={449:function(t,e,r){!function(t){"use strict";function e(t){return null==t}var n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};var i,o=function(t){function e(e){var r,n,i,o=this.constructor,s=t.call(this,e)||this;return Object.defineProperty(s,"name",{value:o.name,enumerable:!1}),r=s,n=o.prototype,(i=Object.setPrototypeOf)?i(r,n):r.__proto__=n,function(t,e){void 0===e&&(e=t.constructor);var r=Error.captureStackTrace;r&&r(t,e)}(s),s}return function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e}(Error);class s extends o{constructor(t=undefined){super(t),this.message=t}getKind(){return this.constructor.kind}}s.kind="Exception";class a extends s{}a.kind="ArgumentException";class c extends s{}c.kind="IllegalArgumentException";class l{constructor(t){if(this.binarizer=t,null===t)throw new c("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(t,e){return this.binarizer.getBlackRow(t,e)}getBlackMatrix(){return null!==this.matrix&&void 0!==this.matrix||(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(t,e,r,n){const i=this.binarizer.getLuminanceSource().crop(t,e,r,n);return new l(this.binarizer.createBinarizer(i))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){const t=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new l(this.binarizer.createBinarizer(t))}rotateCounterClockwise45(){const t=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new l(this.binarizer.createBinarizer(t))}toString(){try{return this.getBlackMatrix().toString()}catch(t){return""}}}class h extends s{static getChecksumInstance(){return new h}}h.kind="ChecksumException";class u{constructor(t){this.source=t}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class d{static arraycopy(t,e,r,n,i){for(;i--;)r[n++]=t[e++]}static currentTimeMillis(){return Date.now()}}class f extends s{}f.kind="IndexOutOfBoundsException";class g extends f{constructor(t=undefined,e=undefined){super(e),this.index=t,this.message=e}}g.kind="ArrayIndexOutOfBoundsException";class w{static fill(t,e){for(let r=0,n=t.length;r<n;r++)t[r]=e}static fillWithin(t,e,r,n){w.rangeCheck(t.length,e,r);for(let i=e;i<r;i++)t[i]=n}static rangeCheck(t,e,r){if(e>r)throw new c("fromIndex("+e+") > toIndex("+r+")");if(e<0)throw new g(e);if(r>t)throw new g(r)}static asList(...t){return t}static create(t,e,r){return Array.from({length:t}).map((t=>Array.from({length:e}).fill(r)))}static createInt32Array(t,e,r){return Array.from({length:t}).map((t=>Int32Array.from({length:e}).fill(r)))}static equals(t,e){if(!t)return!1;if(!e)return!1;if(!t.length)return!1;if(!e.length)return!1;if(t.length!==e.length)return!1;for(let r=0,n=t.length;r<n;r++)if(t[r]!==e[r])return!1;return!0}static hashCode(t){if(null===t)return 0;let e=1;for(const r of t)e=31*e+r;return e}static fillUint8Array(t,e){for(let r=0;r!==t.length;r++)t[r]=e}static copyOf(t,e){return t.slice(0,e)}static copyOfUint8Array(t,e){if(t.length<=e){const r=new Uint8Array(e);return r.set(t),r}return t.slice(0,e)}static copyOfRange(t,e,r){const n=r-e,i=new Int32Array(n);return d.arraycopy(t,e,i,0,n),i}static binarySearch(t,e,r){void 0===r&&(r=w.numberComparator);let n=0,i=t.length-1;for(;n<=i;){const o=i+n>>1,s=r(e,t[o]);if(s>0)n=o+1;else{if(!(s<0))return o;i=o-1}}return-n-1}static numberComparator(t,e){return t-e}}class m{static numberOfTrailingZeros(t){let e;if(0===t)return 32;let r=31;return e=t<<16,0!==e&&(r-=16,t=e),e=t<<8,0!==e&&(r-=8,t=e),e=t<<4,0!==e&&(r-=4,t=e),e=t<<2,0!==e&&(r-=2,t=e),r-(t<<1>>>31)}static numberOfLeadingZeros(t){if(0===t)return 32;let e=1;return t>>>16==0&&(e+=16,t<<=16),t>>>24==0&&(e+=8,t<<=8),t>>>28==0&&(e+=4,t<<=4),t>>>30==0&&(e+=2,t<<=2),e-=t>>>31,e}static toHexString(t){return t.toString(16)}static toBinaryString(t){return String(parseInt(String(t),2))}static bitCount(t){return t=(t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135,63&(t+=t>>>8)+(t>>>16)}static truncDivision(t,e){return Math.trunc(t/e)}static parseInt(t,e=undefined){return parseInt(t,e)}}m.MIN_VALUE_32_BITS=-2147483648,m.MAX_VALUE=Number.MAX_SAFE_INTEGER;class p{constructor(t,e){void 0===t?(this.size=0,this.bits=new Int32Array(1)):(this.size=t,this.bits=null==e?p.makeArray(t):e)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(t){if(t>32*this.bits.length){const e=p.makeArray(t);d.arraycopy(this.bits,0,e,0,this.bits.length),this.bits=e}}get(t){return 0!=(this.bits[Math.floor(t/32)]&1<<(31&t))}set(t){this.bits[Math.floor(t/32)]|=1<<(31&t)}flip(t){this.bits[Math.floor(t/32)]^=1<<(31&t)}getNextSet(t){const e=this.size;if(t>=e)return e;const r=this.bits;let n=Math.floor(t/32),i=r[n];i&=~((1<<(31&t))-1);const o=r.length;for(;0===i;){if(++n===o)return e;i=r[n]}const s=32*n+m.numberOfTrailingZeros(i);return s>e?e:s}getNextUnset(t){const e=this.size;if(t>=e)return e;const r=this.bits;let n=Math.floor(t/32),i=~r[n];i&=~((1<<(31&t))-1);const o=r.length;for(;0===i;){if(++n===o)return e;i=~r[n]}const s=32*n+m.numberOfTrailingZeros(i);return s>e?e:s}setBulk(t,e){this.bits[Math.floor(t/32)]=e}setRange(t,e){if(e<t||t<0||e>this.size)throw new c;if(e===t)return;e--;const r=Math.floor(t/32),n=Math.floor(e/32),i=this.bits;for(let o=r;o<=n;o++){const s=(2<<(o<n?31:31&e))-(1<<(o>r?0:31&t));i[o]|=s}}clear(){const t=this.bits.length,e=this.bits;for(let r=0;r<t;r++)e[r]=0}isRange(t,e,r){if(e<t||t<0||e>this.size)throw new c;if(e===t)return!0;e--;const n=Math.floor(t/32),i=Math.floor(e/32),o=this.bits;for(let s=n;s<=i;s++){const a=(2<<(s<i?31:31&e))-(1<<(s>n?0:31&t))&4294967295;if((o[s]&a)!==(r?a:0))return!1}return!0}appendBit(t){this.ensureCapacity(this.size+1),t&&(this.bits[Math.floor(this.size/32)]|=1<<(31&this.size)),this.size++}appendBits(t,e){if(e<0||e>32)throw new c("Num bits must be between 0 and 32");this.ensureCapacity(this.size+e);for(let r=e;r>0;r--)this.appendBit(1==(t>>r-1&1))}appendBitArray(t){const e=t.size;this.ensureCapacity(this.size+e);for(let r=0;r<e;r++)this.appendBit(t.get(r))}xor(t){if(this.size!==t.size)throw new c("Sizes don't match");const e=this.bits;for(let r=0,n=e.length;r<n;r++)e[r]^=t.bits[r]}toBytes(t,e,r,n){for(let i=0;i<n;i++){let n=0;for(let e=0;e<8;e++)this.get(t)&&(n|=1<<7-e),t++;e[r+i]=n}}getBitArray(){return this.bits}reverse(){const t=new Int32Array(this.bits.length),e=Math.floor((this.size-1)/32),r=e+1,n=this.bits;for(let i=0;i<r;i++){let r=n[i];r=r>>1&1431655765|(1431655765&r)<<1,r=r>>2&858993459|(858993459&r)<<2,r=r>>4&252645135|(252645135&r)<<4,r=r>>8&16711935|(16711935&r)<<8,r=r>>16&65535|(65535&r)<<16,t[e-i]=r}if(this.size!==32*r){const e=32*r-this.size;let n=t[0]>>>e;for(let i=1;i<r;i++){const r=t[i];n|=r<<32-e,t[i-1]=n,n=r>>>e}t[r-1]=n}this.bits=t}static makeArray(t){return new Int32Array(Math.floor((t+31)/32))}equals(t){if(!(t instanceof p))return!1;const e=t;return this.size===e.size&&w.equals(this.bits,e.bits)}hashCode(){return 31*this.size+w.hashCode(this.bits)}toString(){let t="";for(let e=0,r=this.size;e<r;e++)0==(7&e)&&(t+=" "),t+=this.get(e)?"X":".";return t}clone(){return new p(this.size,this.bits.slice())}}!function(t){t[t.OTHER=0]="OTHER",t[t.PURE_BARCODE=1]="PURE_BARCODE",t[t.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",t[t.TRY_HARDER=3]="TRY_HARDER",t[t.CHARACTER_SET=4]="CHARACTER_SET",t[t.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",t[t.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",t[t.ASSUME_GS1=7]="ASSUME_GS1",t[t.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",t[t.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",t[t.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"}(i||(i={}));var A,C=i;class E extends s{static getFormatInstance(){return new E}}E.kind="FormatException",function(t){t[t.Cp437=0]="Cp437",t[t.ISO8859_1=1]="ISO8859_1",t[t.ISO8859_2=2]="ISO8859_2",t[t.ISO8859_3=3]="ISO8859_3",t[t.ISO8859_4=4]="ISO8859_4",t[t.ISO8859_5=5]="ISO8859_5",t[t.ISO8859_6=6]="ISO8859_6",t[t.ISO8859_7=7]="ISO8859_7",t[t.ISO8859_8=8]="ISO8859_8",t[t.ISO8859_9=9]="ISO8859_9",t[t.ISO8859_10=10]="ISO8859_10",t[t.ISO8859_11=11]="ISO8859_11",t[t.ISO8859_13=12]="ISO8859_13",t[t.ISO8859_14=13]="ISO8859_14",t[t.ISO8859_15=14]="ISO8859_15",t[t.ISO8859_16=15]="ISO8859_16",t[t.SJIS=16]="SJIS",t[t.Cp1250=17]="Cp1250",t[t.Cp1251=18]="Cp1251",t[t.Cp1252=19]="Cp1252",t[t.Cp1256=20]="Cp1256",t[t.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",t[t.UTF8=22]="UTF8",t[t.ASCII=23]="ASCII",t[t.Big5=24]="Big5",t[t.GB18030=25]="GB18030",t[t.EUC_KR=26]="EUC_KR"}(A||(A={}));class I{constructor(t,e,r,...n){this.valueIdentifier=t,this.name=r,this.values="number"==typeof e?Int32Array.from([e]):e,this.otherEncodingNames=n,I.VALUE_IDENTIFIER_TO_ECI.set(t,this),I.NAME_TO_ECI.set(r,this);const i=this.values;for(let t=0,e=i.length;t!==e;t++){const e=i[t];I.VALUES_TO_ECI.set(e,this)}for(const t of n)I.NAME_TO_ECI.set(t,this)}getValueIdentifier(){return this.valueIdentifier}getName(){return this.name}getValue(){return this.values[0]}static getCharacterSetECIByValue(t){if(t<0||t>=900)throw new E("incorect value");const e=I.VALUES_TO_ECI.get(t);if(void 0===e)throw new E("incorect value");return e}static getCharacterSetECIByName(t){const e=I.NAME_TO_ECI.get(t);if(void 0===e)throw new E("incorect value");return e}equals(t){if(!(t instanceof I))return!1;const e=t;return this.getName()===e.getName()}}I.VALUE_IDENTIFIER_TO_ECI=new Map,I.VALUES_TO_ECI=new Map,I.NAME_TO_ECI=new Map,I.Cp437=new I(A.Cp437,Int32Array.from([0,2]),"Cp437"),I.ISO8859_1=new I(A.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),I.ISO8859_2=new I(A.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),I.ISO8859_3=new I(A.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),I.ISO8859_4=new I(A.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),I.ISO8859_5=new I(A.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),I.ISO8859_6=new I(A.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),I.ISO8859_7=new I(A.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),I.ISO8859_8=new I(A.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),I.ISO8859_9=new I(A.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),I.ISO8859_10=new I(A.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),I.ISO8859_11=new I(A.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),I.ISO8859_13=new I(A.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),I.ISO8859_14=new I(A.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),I.ISO8859_15=new I(A.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),I.ISO8859_16=new I(A.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),I.SJIS=new I(A.SJIS,20,"SJIS","Shift_JIS"),I.Cp1250=new I(A.Cp1250,21,"Cp1250","windows-1250"),I.Cp1251=new I(A.Cp1251,22,"Cp1251","windows-1251"),I.Cp1252=new I(A.Cp1252,23,"Cp1252","windows-1252"),I.Cp1256=new I(A.Cp1256,24,"Cp1256","windows-1256"),I.UnicodeBigUnmarked=new I(A.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),I.UTF8=new I(A.UTF8,26,"UTF8","UTF-8"),I.ASCII=new I(A.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),I.Big5=new I(A.Big5,28,"Big5"),I.GB18030=new I(A.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),I.EUC_KR=new I(A.EUC_KR,30,"EUC_KR","EUC-KR");class S extends s{}S.kind="UnsupportedOperationException";class _{static decode(t,e){const r=this.encodingName(e);return this.customDecoder?this.customDecoder(t,r):"undefined"==typeof TextDecoder||this.shouldDecodeOnFallback(r)?this.decodeFallback(t,r):new TextDecoder(r).decode(t)}static shouldDecodeOnFallback(t){return!_.isBrowser()&&"ISO-8859-1"===t}static encode(t,e){const r=this.encodingName(e);return this.customEncoder?this.customEncoder(t,r):"undefined"==typeof TextEncoder?this.encodeFallback(t):(new TextEncoder).encode(t)}static isBrowser(){return"undefined"!=typeof window&&"[object Window]"==={}.toString.call(window)}static encodingName(t){return"string"==typeof t?t:t.getName()}static encodingCharacterSet(t){return t instanceof I?t:I.getCharacterSetECIByName(t)}static decodeFallback(t,e){const r=this.encodingCharacterSet(e);if(_.isDecodeFallbackSupported(r)){let e="";for(let r=0,n=t.length;r<n;r++){let n=t[r].toString(16);n.length<2&&(n="0"+n),e+="%"+n}return decodeURIComponent(e)}if(r.equals(I.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(t.buffer));throw new S(`Encoding ${this.encodingName(e)} not supported by fallback.`)}static isDecodeFallbackSupported(t){return t.equals(I.UTF8)||t.equals(I.ISO8859_1)||t.equals(I.ASCII)}static encodeFallback(t){const e=btoa(unescape(encodeURIComponent(t))).split(""),r=[];for(let t=0;t<e.length;t++)r.push(e[t].charCodeAt(0));return new Uint8Array(r)}}class T{static castAsNonUtf8Char(t,e=null){const r=e?e.getName():this.ISO88591;return _.decode(new Uint8Array([t]),r)}static guessEncoding(t,e){if(null!=e&&void 0!==e.get(C.CHARACTER_SET))return e.get(C.CHARACTER_SET).toString();const r=t.length;let n=!0,i=!0,o=!0,s=0,a=0,c=0,l=0,h=0,u=0,d=0,f=0,g=0,w=0,m=0;const p=t.length>3&&239===t[0]&&187===t[1]&&191===t[2];for(let e=0;e<r&&(n||i||o);e++){const r=255&t[e];o&&(s>0?0==(128&r)?o=!1:s--:0!=(128&r)&&(0==(64&r)?o=!1:(s++,0==(32&r)?a++:(s++,0==(16&r)?c++:(s++,0==(8&r)?l++:o=!1))))),n&&(r>127&&r<160?n=!1:r>159&&(r<192||215===r||247===r)&&m++),i&&(h>0?r<64||127===r||r>252?i=!1:h--:128===r||160===r||r>239?i=!1:r>160&&r<224?(u++,f=0,d++,d>g&&(g=d)):r>127?(h++,d=0,f++,f>w&&(w=f)):(d=0,f=0))}return o&&s>0&&(o=!1),i&&h>0&&(i=!1),o&&(p||a+c+l>0)?T.UTF8:i&&(T.ASSUME_SHIFT_JIS||g>=3||w>=3)?T.SHIFT_JIS:n&&i?2===g&&2===u||10*m>=r?T.SHIFT_JIS:T.ISO88591:n?T.ISO88591:i?T.SHIFT_JIS:o?T.UTF8:T.PLATFORM_DEFAULT_ENCODING}static format(t,...e){let r=-1;return t.replace(/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g,(function(t,n,i,o,s,a){if("%%"===t)return"%";if(void 0===e[++r])return;t=o?parseInt(o.substr(1)):void 0;let c,l=s?parseInt(s.substr(1)):void 0;switch(a){case"s":c=e[r];break;case"c":c=e[r][0];break;case"f":c=parseFloat(e[r]).toFixed(t);break;case"p":c=parseFloat(e[r]).toPrecision(t);break;case"e":c=parseFloat(e[r]).toExponential(t);break;case"x":c=parseInt(e[r]).toString(l||16);break;case"d":c=parseFloat(parseInt(e[r],l||10).toPrecision(t)).toFixed(0)}c="object"==typeof c?JSON.stringify(c):(+c).toString(l);let h=parseInt(i),u=i&&i[0]+""=="0"?"0":" ";for(;c.length<h;)c=void 0!==n?c+u:u+c;return c}))}static getBytes(t,e){return _.encode(t,e)}static getCharCode(t,e=0){return t.charCodeAt(e)}static getCharAt(t){return String.fromCharCode(t)}}T.SHIFT_JIS=I.SJIS.getName(),T.GB2312="GB2312",T.ISO88591=I.ISO8859_1.getName(),T.EUC_JP="EUC_JP",T.UTF8=I.UTF8.getName(),T.PLATFORM_DEFAULT_ENCODING=T.UTF8,T.ASSUME_SHIFT_JIS=!1;class y{constructor(t=""){this.value=t}enableDecoding(t){return this.encoding=t,this}append(t){return"string"==typeof t?this.value+=t.toString():this.encoding?this.value+=T.castAsNonUtf8Char(t,this.encoding):this.value+=String.fromCharCode(t),this}appendChars(t,e,r){for(let n=e;e<e+r;n++)this.append(t[n]);return this}length(){return this.value.length}charAt(t){return this.value.charAt(t)}deleteCharAt(t){this.value=this.value.substr(0,t)+this.value.substring(t+1)}setCharAt(t,e){this.value=this.value.substr(0,t)+e+this.value.substr(t+1)}substring(t,e){return this.value.substring(t,e)}setLengthToZero(){this.value=""}toString(){return this.value}insert(t,e){this.value=this.value.substr(0,t)+e+this.value.substr(t+e.length)}}class N{constructor(t,e,r,n){if(this.width=t,this.height=e,this.rowSize=r,this.bits=n,null==e&&(e=t),this.height=e,t<1||e<1)throw new c("Both dimensions must be greater than 0");null==r&&(r=Math.floor((t+31)/32)),this.rowSize=r,null==n&&(this.bits=new Int32Array(this.rowSize*this.height))}static parseFromBooleanArray(t){const e=t.length,r=t[0].length,n=new N(r,e);for(let i=0;i<e;i++){const e=t[i];for(let t=0;t<r;t++)e[t]&&n.set(t,i)}return n}static parseFromString(t,e,r){if(null===t)throw new c("stringRepresentation cannot be null");const n=new Array(t.length);let i=0,o=0,s=-1,a=0,l=0;for(;l<t.length;)if("\n"===t.charAt(l)||"\r"===t.charAt(l)){if(i>o){if(-1===s)s=i-o;else if(i-o!==s)throw new c("row lengths do not match");o=i,a++}l++}else if(t.substring(l,l+e.length)===e)l+=e.length,n[i]=!0,i++;else{if(t.substring(l,l+r.length)!==r)throw new c("illegal character encountered: "+t.substring(l));l+=r.length,n[i]=!1,i++}if(i>o){if(-1===s)s=i-o;else if(i-o!==s)throw new c("row lengths do not match");a++}const h=new N(s,a);for(let t=0;t<i;t++)n[t]&&h.set(Math.floor(t%s),Math.floor(t/s));return h}get(t,e){const r=e*this.rowSize+Math.floor(t/32);return 0!=(this.bits[r]>>>(31&t)&1)}set(t,e){const r=e*this.rowSize+Math.floor(t/32);this.bits[r]|=1<<(31&t)&4294967295}unset(t,e){const r=e*this.rowSize+Math.floor(t/32);this.bits[r]&=~(1<<(31&t)&4294967295)}flip(t,e){const r=e*this.rowSize+Math.floor(t/32);this.bits[r]^=1<<(31&t)&4294967295}xor(t){if(this.width!==t.getWidth()||this.height!==t.getHeight()||this.rowSize!==t.getRowSize())throw new c("input matrix dimensions do not match");const e=new p(Math.floor(this.width/32)+1),r=this.rowSize,n=this.bits;for(let i=0,o=this.height;i<o;i++){const o=i*r,s=t.getRow(i,e).getBitArray();for(let t=0;t<r;t++)n[o+t]^=s[t]}}clear(){const t=this.bits,e=t.length;for(let r=0;r<e;r++)t[r]=0}setRegion(t,e,r,n){if(e<0||t<0)throw new c("Left and top must be nonnegative");if(n<1||r<1)throw new c("Height and width must be at least 1");const i=t+r,o=e+n;if(o>this.height||i>this.width)throw new c("The region must fit inside the matrix");const s=this.rowSize,a=this.bits;for(let r=e;r<o;r++){const e=r*s;for(let r=t;r<i;r++)a[e+Math.floor(r/32)]|=1<<(31&r)&4294967295}}getRow(t,e){null==e||e.getSize()<this.width?e=new p(this.width):e.clear();const r=this.rowSize,n=this.bits,i=t*r;for(let t=0;t<r;t++)e.setBulk(32*t,n[i+t]);return e}setRow(t,e){d.arraycopy(e.getBitArray(),0,this.bits,t*this.rowSize,this.rowSize)}rotate180(){const t=this.getWidth(),e=this.getHeight();let r=new p(t),n=new p(t);for(let t=0,i=Math.floor((e+1)/2);t<i;t++)r=this.getRow(t,r),n=this.getRow(e-1-t,n),r.reverse(),n.reverse(),this.setRow(t,n),this.setRow(e-1-t,r)}getEnclosingRectangle(){const t=this.width,e=this.height,r=this.rowSize,n=this.bits;let i=t,o=e,s=-1,a=-1;for(let t=0;t<e;t++)for(let e=0;e<r;e++){const c=n[t*r+e];if(0!==c){if(t<o&&(o=t),t>a&&(a=t),32*e<i){let t=0;for(;0==(c<<31-t&4294967295);)t++;32*e+t<i&&(i=32*e+t)}if(32*e+31>s){let t=31;for(;c>>>t==0;)t--;32*e+t>s&&(s=32*e+t)}}}return s<i||a<o?null:Int32Array.from([i,o,s-i+1,a-o+1])}getTopLeftOnBit(){const t=this.rowSize,e=this.bits;let r=0;for(;r<e.length&&0===e[r];)r++;if(r===e.length)return null;const n=r/t;let i=r%t*32;const o=e[r];let s=0;for(;0==(o<<31-s&4294967295);)s++;return i+=s,Int32Array.from([i,n])}getBottomRightOnBit(){const t=this.rowSize,e=this.bits;let r=e.length-1;for(;r>=0&&0===e[r];)r--;if(r<0)return null;const n=Math.floor(r/t);let i=32*Math.floor(r%t);const o=e[r];let s=31;for(;o>>>s==0;)s--;return i+=s,Int32Array.from([i,n])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(t){if(!(t instanceof N))return!1;const e=t;return this.width===e.width&&this.height===e.height&&this.rowSize===e.rowSize&&w.equals(this.bits,e.bits)}hashCode(){let t=this.width;return t=31*t+this.width,t=31*t+this.height,t=31*t+this.rowSize,t=31*t+w.hashCode(this.bits),t}toString(t="X ",e=" ",r="\n"){return this.buildToString(t,e,r)}buildToString(t,e,r){let n=new y;for(let i=0,o=this.height;i<o;i++){for(let r=0,o=this.width;r<o;r++)n.append(this.get(r,i)?t:e);n.append(r)}return n.toString()}clone(){return new N(this.width,this.height,this.rowSize,this.bits.slice())}}class D extends s{static getNotFoundInstance(){return new D}}D.kind="NotFoundException";class M extends u{constructor(t){super(t),this.luminances=M.EMPTY,this.buckets=new Int32Array(M.LUMINANCE_BUCKETS)}getBlackRow(t,e){const r=this.getLuminanceSource(),n=r.getWidth();null==e||e.getSize()<n?e=new p(n):e.clear(),this.initArrays(n);const i=r.getRow(t,this.luminances),o=this.buckets;for(let t=0;t<n;t++)o[(255&i[t])>>M.LUMINANCE_SHIFT]++;const s=M.estimateBlackPoint(o);if(n<3)for(let t=0;t<n;t++)(255&i[t])<s&&e.set(t);else{let t=255&i[0],r=255&i[1];for(let o=1;o<n-1;o++){const n=255&i[o+1];(4*r-t-n)/2<s&&e.set(o),t=r,r=n}}return e}getBlackMatrix(){const t=this.getLuminanceSource(),e=t.getWidth(),r=t.getHeight(),n=new N(e,r);this.initArrays(e);const i=this.buckets;for(let n=1;n<5;n++){const o=Math.floor(r*n/5),s=t.getRow(o,this.luminances),a=Math.floor(4*e/5);for(let t=Math.floor(e/5);t<a;t++)i[(255&s[t])>>M.LUMINANCE_SHIFT]++}const o=M.estimateBlackPoint(i),s=t.getMatrix();for(let t=0;t<r;t++){const r=t*e;for(let i=0;i<e;i++)(255&s[r+i])<o&&n.set(i,t)}return n}createBinarizer(t){return new M(t)}initArrays(t){this.luminances.length<t&&(this.luminances=new Uint8ClampedArray(t));const e=this.buckets;for(let t=0;t<M.LUMINANCE_BUCKETS;t++)e[t]=0}static estimateBlackPoint(t){const e=t.length;let r=0,n=0,i=0;for(let o=0;o<e;o++)t[o]>i&&(n=o,i=t[o]),t[o]>r&&(r=t[o]);let o=0,s=0;for(let r=0;r<e;r++){const e=r-n,i=t[r]*e*e;i>s&&(o=r,s=i)}if(n>o){const t=n;n=o,o=t}if(o-n<=e/16)throw new D;let a=o-1,c=-1;for(let e=o-1;e>n;e--){const i=e-n,s=i*i*(o-e)*(r-t[e]);s>c&&(a=e,c=s)}return a<<M.LUMINANCE_SHIFT}}M.LUMINANCE_BITS=5,M.LUMINANCE_SHIFT=8-M.LUMINANCE_BITS,M.LUMINANCE_BUCKETS=1<<M.LUMINANCE_BITS,M.EMPTY=Uint8ClampedArray.from([0]);class R extends M{constructor(t){super(t),this.matrix=null}getBlackMatrix(){if(null!==this.matrix)return this.matrix;const t=this.getLuminanceSource(),e=t.getWidth(),r=t.getHeight();if(e>=R.MINIMUM_DIMENSION&&r>=R.MINIMUM_DIMENSION){const n=t.getMatrix();let i=e>>R.BLOCK_SIZE_POWER;0!=(e&R.BLOCK_SIZE_MASK)&&i++;let o=r>>R.BLOCK_SIZE_POWER;0!=(r&R.BLOCK_SIZE_MASK)&&o++;const s=R.calculateBlackPoints(n,i,o,e,r),a=new N(e,r);R.calculateThresholdForBlock(n,i,o,e,r,s,a),this.matrix=a}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(t){return new R(t)}static calculateThresholdForBlock(t,e,r,n,i,o,s){const a=i-R.BLOCK_SIZE,c=n-R.BLOCK_SIZE;for(let i=0;i<r;i++){let l=i<<R.BLOCK_SIZE_POWER;l>a&&(l=a);const h=R.cap(i,2,r-3);for(let r=0;r<e;r++){let i=r<<R.BLOCK_SIZE_POWER;i>c&&(i=c);const a=R.cap(r,2,e-3);let u=0;for(let t=-2;t<=2;t++){const e=o[h+t];u+=e[a-2]+e[a-1]+e[a]+e[a+1]+e[a+2]}const d=u/25;R.thresholdBlock(t,i,l,d,n,s)}}}static cap(t,e,r){return t<e?e:t>r?r:t}static thresholdBlock(t,e,r,n,i,o){for(let s=0,a=r*i+e;s<R.BLOCK_SIZE;s++,a+=i)for(let i=0;i<R.BLOCK_SIZE;i++)(255&t[a+i])<=n&&o.set(e+i,r+s)}static calculateBlackPoints(t,e,r,n,i){const o=i-R.BLOCK_SIZE,s=n-R.BLOCK_SIZE,a=new Array(r);for(let i=0;i<r;i++){a[i]=new Int32Array(e);let r=i<<R.BLOCK_SIZE_POWER;r>o&&(r=o);for(let o=0;o<e;o++){let e=o<<R.BLOCK_SIZE_POWER;e>s&&(e=s);let c=0,l=255,h=0;for(let i=0,o=r*n+e;i<R.BLOCK_SIZE;i++,o+=n){for(let e=0;e<R.BLOCK_SIZE;e++){const r=255&t[o+e];c+=r,r<l&&(l=r),r>h&&(h=r)}if(h-l>R.MIN_DYNAMIC_RANGE)for(i++,o+=n;i<R.BLOCK_SIZE;i++,o+=n)for(let e=0;e<R.BLOCK_SIZE;e++)c+=255&t[o+e]}let u=c>>2*R.BLOCK_SIZE_POWER;if(h-l<=R.MIN_DYNAMIC_RANGE&&(u=l/2,i>0&&o>0)){const t=(a[i-1][o]+2*a[i][o-1]+a[i-1][o-1])/4;l<t&&(u=t)}a[i][o]=u}}return a}}R.BLOCK_SIZE_POWER=3,R.BLOCK_SIZE=1<<R.BLOCK_SIZE_POWER,R.BLOCK_SIZE_MASK=R.BLOCK_SIZE-1,R.MINIMUM_DIMENSION=5*R.BLOCK_SIZE,R.MIN_DYNAMIC_RANGE=24;class O{constructor(t,e){this.width=t,this.height=e}getWidth(){return this.width}getHeight(){return this.height}isCropSupported(){return!1}crop(t,e,r,n){throw new S("This luminance source does not support cropping.")}isRotateSupported(){return!1}rotateCounterClockwise(){throw new S("This luminance source does not support rotation by 90 degrees.")}rotateCounterClockwise45(){throw new S("This luminance source does not support rotation by 45 degrees.")}toString(){const t=new Uint8ClampedArray(this.width);let e=new y;for(let r=0;r<this.height;r++){const n=this.getRow(r,t);for(let t=0;t<this.width;t++){const r=255&n[t];let i;i=r<64?"#":r<128?"+":r<192?".":" ",e.append(i)}e.append("\n")}return e.toString()}}class b extends O{constructor(t){super(t.getWidth(),t.getHeight()),this.delegate=t}getRow(t,e){const r=this.delegate.getRow(t,e),n=this.getWidth();for(let t=0;t<n;t++)r[t]=255-(255&r[t]);return r}getMatrix(){const t=this.delegate.getMatrix(),e=this.getWidth()*this.getHeight(),r=new Uint8ClampedArray(e);for(let n=0;n<e;n++)r[n]=255-(255&t[n]);return r}isCropSupported(){return this.delegate.isCropSupported()}crop(t,e,r,n){return new b(this.delegate.crop(t,e,r,n))}isRotateSupported(){return this.delegate.isRotateSupported()}invert(){return this.delegate}rotateCounterClockwise(){return new b(this.delegate.rotateCounterClockwise())}rotateCounterClockwise45(){return new b(this.delegate.rotateCounterClockwise45())}}class B extends O{constructor(t){super(t.width,t.height),this.canvas=t,this.tempCanvasElement=null,this.buffer=B.makeBufferFromCanvasImageData(t)}static makeBufferFromCanvasImageData(t){const e=t.getContext("2d").getImageData(0,0,t.width,t.height);return B.toGrayscaleBuffer(e.data,t.width,t.height)}static toGrayscaleBuffer(t,e,r){const n=new Uint8ClampedArray(e*r);for(let e=0,r=0,i=t.length;e<i;e+=4,r++){let i;i=0===t[e+3]?255:306*t[e]+601*t[e+1]+117*t[e+2]+512>>10,n[r]=i}return n}getRow(t,e){if(t<0||t>=this.getHeight())throw new c("Requested row is outside the image: "+t);const r=this.getWidth(),n=t*r;return null===e?e=this.buffer.slice(n,n+r):(e.length<r&&(e=new Uint8ClampedArray(r)),e.set(this.buffer.slice(n,n+r))),e}getMatrix(){return this.buffer}isCropSupported(){return!0}crop(t,e,r,n){return super.crop(t,e,r,n),this}isRotateSupported(){return!0}rotateCounterClockwise(){return this.rotate(-90),this}rotateCounterClockwise45(){return this.rotate(-45),this}getTempCanvasElement(){if(null===this.tempCanvasElement){const t=this.canvas.ownerDocument.createElement("canvas");t.width=this.canvas.width,t.height=this.canvas.height,this.tempCanvasElement=t}return this.tempCanvasElement}rotate(t){const e=this.getTempCanvasElement(),r=e.getContext("2d"),n=t*B.DEGREE_TO_RADIANS,i=this.canvas.width,o=this.canvas.height,s=Math.ceil(Math.abs(Math.cos(n))*i+Math.abs(Math.sin(n))*o),a=Math.ceil(Math.abs(Math.sin(n))*i+Math.abs(Math.cos(n))*o);return e.width=s,e.height=a,r.translate(s/2,a/2),r.rotate(n),r.drawImage(this.canvas,i/-2,o/-2),this.buffer=B.makeBufferFromCanvasImageData(e),this}invert(){return new b(this)}}B.DEGREE_TO_RADIANS=Math.PI/180;class L{constructor(t,e,r){this.deviceId=t,this.label=e,this.kind="videoinput",this.groupId=r||void 0}toJSON(){return{kind:this.kind,groupId:this.groupId,deviceId:this.deviceId,label:this.label}}}var P,v=(globalThis||r.g||self||window?(globalThis||r.g||self||window||void 0).__awaiter:void 0)||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};class F{constructor(t,e=500,r){this.reader=t,this.timeBetweenScansMillis=e,this._hints=r,this._stopContinuousDecode=!1,this._stopAsyncDecode=!1,this._timeBetweenDecodingAttempts=0}get hasNavigator(){return"undefined"!=typeof navigator}get isMediaDevicesSuported(){return this.hasNavigator&&!!navigator.mediaDevices}get canEnumerateDevices(){return!(!this.isMediaDevicesSuported||!navigator.mediaDevices.enumerateDevices)}get timeBetweenDecodingAttempts(){return this._timeBetweenDecodingAttempts}set timeBetweenDecodingAttempts(t){this._timeBetweenDecodingAttempts=t<0?0:t}set hints(t){this._hints=t||null}get hints(){return this._hints}listVideoInputDevices(){return v(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 t=yield navigator.mediaDevices.enumerateDevices(),e=[];for(const r of t){const t="video"===r.kind?"videoinput":r.kind;if("videoinput"!==t)continue;const n={deviceId:r.deviceId||r.id,label:r.label||`Video device ${e.length+1}`,kind:t,groupId:r.groupId};e.push(n)}return e}))}getVideoInputDevices(){return v(this,void 0,void 0,(function*(){return(yield this.listVideoInputDevices()).map((t=>new L(t.deviceId,t.label)))}))}findDeviceById(t){return v(this,void 0,void 0,(function*(){const e=yield this.listVideoInputDevices();return e?e.find((e=>e.deviceId===t)):null}))}decodeFromInputVideoDevice(t,e){return v(this,void 0,void 0,(function*(){return yield this.decodeOnceFromVideoDevice(t,e)}))}decodeOnceFromVideoDevice(t,e){return v(this,void 0,void 0,(function*(){let r;this.reset(),r=t?{deviceId:{exact:t}}:{facingMode:"environment"};const n={video:r};return yield this.decodeOnceFromConstraints(n,e)}))}decodeOnceFromConstraints(t,e){return v(this,void 0,void 0,(function*(){const r=yield navigator.mediaDevices.getUserMedia(t);return yield this.decodeOnceFromStream(r,e)}))}decodeOnceFromStream(t,e){return v(this,void 0,void 0,(function*(){this.reset();const r=yield this.attachStreamToVideo(t,e);return yield this.decodeOnce(r)}))}decodeFromInputVideoDeviceContinuously(t,e,r){return v(this,void 0,void 0,(function*(){return yield this.decodeFromVideoDevice(t,e,r)}))}decodeFromVideoDevice(t,e,r){return v(this,void 0,void 0,(function*(){let n;n=t?{deviceId:{exact:t}}:{facingMode:"environment"};const i={video:n};return yield this.decodeFromConstraints(i,e,r)}))}decodeFromConstraints(t,e,r){return v(this,void 0,void 0,(function*(){const n=yield navigator.mediaDevices.getUserMedia(t);return yield this.decodeFromStream(n,e,r)}))}decodeFromStream(t,e,r){return v(this,void 0,void 0,(function*(){this.reset();const n=yield this.attachStreamToVideo(t,e);return yield this.decodeContinuously(n,r)}))}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(t,e){return v(this,void 0,void 0,(function*(){const r=this.prepareVideoElement(e);return this.addVideoSource(r,t),this.videoElement=r,this.stream=t,yield this.playVideoOnLoadAsync(r),r}))}playVideoOnLoadAsync(t){return new Promise(((e,r)=>this.playVideoOnLoad(t,(()=>e()))))}playVideoOnLoad(t,e){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(t),t.addEventListener("ended",this.videoEndedListener),t.addEventListener("canplay",this.videoCanPlayListener),t.addEventListener("playing",e),this.tryPlayVideo(t)}isVideoPlaying(t){return t.currentTime>0&&!t.paused&&!t.ended&&t.readyState>2}tryPlayVideo(t){return v(this,void 0,void 0,(function*(){if(this.isVideoPlaying(t))console.warn("Trying to play video that is already playing.");else try{yield t.play()}catch(t){console.warn("It was not possible to play the video.")}}))}getMediaElement(t,e){const r=document.getElementById(t);if(!r)throw new a(`element with id '${t}' not found`);if(r.nodeName.toLowerCase()!==e.toLowerCase())throw new a(`element with id '${t}' must be an ${e} element`);return r}decodeFromImage(t,e){if(!t&&!e)throw new a("either imageElement with a src set or an url must be provided");return e&&!t?this.decodeFromImageUrl(e):this.decodeFromImageElement(t)}decodeFromVideo(t,e){if(!t&&!e)throw new a("Either an element with a src set or an URL must be provided");return e&&!t?this.decodeFromVideoUrl(e):this.decodeFromVideoElement(t)}decodeFromVideoContinuously(t,e,r){if(void 0===t&&void 0===e)throw new a("Either an element with a src set or an URL must be provided");return e&&!t?this.decodeFromVideoUrlContinuously(e,r):this.decodeFromVideoElementContinuously(t,r)}decodeFromImageElement(t){if(!t)throw new a("An image element must be provided.");this.reset();const e=this.prepareImageElement(t);let r;return this.imageElement=e,r=this.isImageLoaded(e)?this.decodeOnce(e,!1,!0):this._decodeOnLoadImage(e),r}decodeFromVideoElement(t){const e=this._decodeFromVideoElementSetup(t);return this._decodeOnLoadVideo(e)}decodeFromVideoElementContinuously(t,e){const r=this._decodeFromVideoElementSetup(t);return this._decodeOnLoadVideoContinuously(r,e)}_decodeFromVideoElementSetup(t){if(!t)throw new a("A video element must be provided.");this.reset();const e=this.prepareVideoElement(t);return this.videoElement=e,e}decodeFromImageUrl(t){if(!t)throw new a("An URL must be provided.");this.reset();const e=this.prepareImageElement();this.imageElement=e;const r=this._decodeOnLoadImage(e);return e.src=t,r}decodeFromVideoUrl(t){if(!t)throw new a("An URL must be provided.");this.reset();const e=this.prepareVideoElement(),r=this.decodeFromVideoElement(e);return e.src=t,r}decodeFromVideoUrlContinuously(t,e){if(!t)throw new a("An URL must be provided.");this.reset();const r=this.prepareVideoElement(),n=this.decodeFromVideoElementContinuously(r,e);return r.src=t,n}_decodeOnLoadImage(t){return new Promise(((e,r)=>{this.imageLoadedListener=()=>this.decodeOnce(t,!1,!0).then(e,r),t.addEventListener("load",this.imageLoadedListener)}))}_decodeOnLoadVideo(t){return v(this,void 0,void 0,(function*(){return yield this.playVideoOnLoadAsync(t),yield this.decodeOnce(t)}))}_decodeOnLoadVideoContinuously(t,e){return v(this,void 0,void 0,(function*(){yield this.playVideoOnLoadAsync(t),this.decodeContinuously(t,e)}))}isImageLoaded(t){return!!t.complete&&0!==t.naturalWidth}prepareImageElement(t){let e;return void 0===t&&(e=document.createElement("img"),e.width=200,e.height=200),"string"==typeof t&&(e=this.getMediaElement(t,"img")),t instanceof HTMLImageElement&&(e=t),e}prepareVideoElement(t){let e;return t||"undefined"==typeof document||(e=document.createElement("video"),e.width=200,e.height=200),"string"==typeof t&&(e=this.getMediaElement(t,"video")),t instanceof HTMLVideoElement&&(e=t),e.setAttribute("autoplay","true"),e.setAttribute("muted","true"),e.setAttribute("playsinline","true"),e}decodeOnce(t,e=!0,r=!0){this._stopAsyncDecode=!1;const n=(i,o)=>{if(this._stopAsyncDecode)return o(new D("Video stream has ended before any code could be detected.")),void(this._stopAsyncDecode=void 0);try{i(this.decode(t))}catch(t){if(e&&t instanceof D||(t instanceof h||t instanceof E)&&r)return setTimeout(n,this._timeBetweenDecodingAttempts,i,o);o(t)}};return new Promise(((t,e)=>n(t,e)))}decodeContinuously(t,e){this._stopContinuousDecode=!1;const r=()=>{if(this._stopContinuousDecode)this._stopContinuousDecode=void 0;else try{const n=this.decode(t);e(n,null),setTimeout(r,this.timeBetweenScansMillis)}catch(t){e(null,t),(t instanceof h||t instanceof E||t instanceof D)&&setTimeout(r,this._timeBetweenDecodingAttempts)}};r()}decode(t){const e=this.createBinaryBitmap(t);return this.decodeBitmap(e)}_isHTMLVideoElement(t){return 0!==t.videoWidth}drawFrameOnCanvas(t,e,r){e||(e={sx:0,sy:0,sWidth:t.videoWidth,sHeight:t.videoHeight,dx:0,dy:0,dWidth:t.videoWidth,dHeight:t.videoHeight}),r||(r=this.captureCanvasContext),r.drawImage(t,e.sx,e.sy,e.sWidth,e.sHeight,e.dx,e.dy,e.dWidth,e.dHeight)}drawImageOnCanvas(t,e,r=this.captureCanvasContext){e||(e={sx:0,sy:0,sWidth:t.naturalWidth,sHeight:t.naturalHeight,dx:0,dy:0,dWidth:t.naturalWidth,dHeight:t.naturalHeight}),r||(r=this.captureCanvasContext),r.drawImage(t,e.sx,e.sy,e.sWidth,e.sHeight,e.dx,e.dy,e.dWidth,e.dHeight)}createBinaryBitmap(t){this.getCaptureCanvasContext(t),this._isHTMLVideoElement(t)?this.drawFrameOnCanvas(t):this.drawImageOnCanvas(t);const e=this.getCaptureCanvas(t),r=new B(e),n=new R(r);return new l(n)}getCaptureCanvasContext(t){if(!this.captureCanvasContext){const e=this.getCaptureCanvas(t).getContext("2d");this.captureCanvasContext=e}return this.captureCanvasContext}getCaptureCanvas(t){if(!this.captureCanvas){const e=this.createCaptureCanvas(t);this.captureCanvas=e}return this.captureCanvas}decodeBitmap(t){return this.reader.decode(t,this._hints)}createCaptureCanvas(t){if("undefined"==typeof document)return this._destroyCaptureCanvas(),null;const e=document.createElement("canvas");let r,n;return void 0!==t&&(t instanceof HTMLVideoElement?(r=t.videoWidth,n=t.videoHeight):t instanceof HTMLImageElement&&(r=t.naturalWidth||t.width,n=t.naturalHeight||t.height)),e.style.width=r+"px",e.style.height=n+"px",e.width=r,e.height=n,e}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach((t=>t.stop())),this.stream=void 0),!1===this._stopAsyncDecode&&this.stopAsyncDecode(),!1===this._stopContinuousDecode&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(void 0!==this.videoEndedListener&&this.videoElement.removeEventListener("ended",this.videoEndedListener),void 0!==this.videoPlayingEventListener&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),void 0!==this.videoCanPlayListener&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(void 0!==this.imageLoadedListener&&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(t,e){try{t.srcObject=e}catch(r){t.src=URL.createObjectURL(e)}}cleanVideoSource(t){try{t.srcObject=null}catch(e){t.src=""}this.videoElement.removeAttribute("src")}}class x{constructor(t,e,r=(null==e?0:8*e.length),n,i,o=d.currentTimeMillis()){this.text=t,this.rawBytes=e,this.numBits=r,this.resultPoints=n,this.format=i,this.timestamp=o,this.text=t,this.rawBytes=e,this.numBits=null==r?null==e?0:8*e.length:r,this.resultPoints=n,this.format=i,this.resultMetadata=null,this.timestamp=null==o?d.currentTimeMillis():o}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(t,e){null===this.resultMetadata&&(this.resultMetadata=new Map),this.resultMetadata.set(t,e)}putAllMetadata(t){null!==t&&(null===this.resultMetadata?this.resultMetadata=t:this.resultMetadata=new Map(t))}addResultPoints(t){const e=this.resultPoints;if(null===e)this.resultPoints=t;else if(null!==t&&t.length>0){const r=new Array(e.length+t.length);d.arraycopy(e,0,r,0,e.length),d.arraycopy(t,0,r,e.length,t.length),this.resultPoints=r}}getTimestamp(){return this.timestamp}toString(){return this.text}}!function(t){t[t.AZTEC=0]="AZTEC",t[t.CODABAR=1]="CODABAR",t[t.CODE_39=2]="CODE_39",t[t.CODE_93=3]="CODE_93",t[t.CODE_128=4]="CODE_128",t[t.DATA_MATRIX=5]="DATA_MATRIX",t[t.EAN_8=6]="EAN_8",t[t.EAN_13=7]="EAN_13",t[t.ITF=8]="ITF",t[t.MAXICODE=9]="MAXICODE",t[t.PDF_417=10]="PDF_417",t[t.QR_CODE=11]="QR_CODE",t[t.RSS_14=12]="RSS_14",t[t.RSS_EXPANDED=13]="RSS_EXPANDED",t[t.UPC_A=14]="UPC_A",t[t.UPC_E=15]="UPC_E",t[t.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"}(P||(P={}));var k,U=P;!function(t){t[t.OTHER=0]="OTHER",t[t.ORIENTATION=1]="ORIENTATION",t[t.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",t[t.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",t[t.ISSUE_NUMBER=4]="ISSUE_NUMBER",t[t.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",t[t.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",t[t.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",t[t.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",t[t.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",t[t.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"}(k||(k={}));var H,V,z,G,Y,X,W=k;class j{constructor(t,e,r,n,i=-1,o=-1){this.rawBytes=t,this.text=e,this.byteSegments=r,this.ecLevel=n,this.structuredAppendSequenceNumber=i,this.structuredAppendParity=o,this.numBits=null==t?0:8*t.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(t){this.numBits=t}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(t){this.errorsCorrected=t}getErasures(){return this.erasures}setErasures(t){this.erasures=t}getOther(){return this.other}setOther(t){this.other=t}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class Z{exp(t){return this.expTable[t]}log(t){if(0===t)throw new c;return this.logTable[t]}static addOrSubtract(t,e){return t^e}}class Q{constructor(t,e){if(0===e.length)throw new c;this.field=t;const r=e.length;if(r>1&&0===e[0]){let t=1;for(;t<r&&0===e[t];)t++;t===r?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(r-t),d.arraycopy(e,t,this.coefficients,0,this.coefficients.length))}else this.coefficients=e}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return 0===this.coefficients[0]}getCoefficient(t){return this.coefficients[this.coefficients.length-1-t]}evaluateAt(t){if(0===t)return this.getCoefficient(0);const e=this.coefficients;let r;if(1===t){r=0;for(let t=0,n=e.length;t!==n;t++){const n=e[t];r=Z.addOrSubtract(r,n)}return r}r=e[0];const n=e.length,i=this.field;for(let o=1;o<n;o++)r=Z.addOrSubtract(i.multiply(t,r),e[o]);return r}addOrSubtract(t){if(!this.field.equals(t.field))throw new c("GenericGFPolys do not have same GenericGF field");if(this.isZero())return t;if(t.isZero())return this;let e=this.coefficients,r=t.coefficients;if(e.length>r.length){const t=e;e=r,r=t}let n=new Int32Array(r.length);const i=r.length-e.length;d.arraycopy(r,0,n,0,i);for(let t=i;t<r.length;t++)n[t]=Z.addOrSubtract(e[t-i],r[t]);return new Q(this.field,n)}multiply(t){if(!this.field.equals(t.field))throw new c("GenericGFPolys do not have same GenericGF field");if(this.isZero()||t.isZero())return this.field.getZero();const e=this.coefficients,r=e.length,n=t.coefficients,i=n.length,o=new Int32Array(r+i-1),s=this.field;for(let t=0;t<r;t++){const r=e[t];for(let e=0;e<i;e++)o[t+e]=Z.addOrSubtract(o[t+e],s.multiply(r,n[e]))}return new Q(s,o)}multiplyScalar(t){if(0===t)return this.field.getZero();if(1===t)return this;const e=this.coefficients.length,r=this.field,n=new Int32Array(e),i=this.coefficients;for(let o=0;o<e;o++)n[o]=r.multiply(i[o],t);return new Q(r,n)}multiplyByMonomial(t,e){if(t<0)throw new c;if(0===e)return this.field.getZero();const r=this.coefficients,n=r.length,i=new Int32Array(n+t),o=this.field;for(let t=0;t<n;t++)i[t]=o.multiply(r[t],e);return new Q(o,i)}divide(t){if(!this.field.equals(t.field))throw new c("GenericGFPolys do not have same GenericGF field");if(t.isZero())throw new c("Divide by 0");const e=this.field;let r=e.getZero(),n=this;const i=t.getCoefficient(t.getDegree()),o=e.inverse(i);for(;n.getDegree()>=t.getDegree()&&!n.isZero();){const i=n.getDegree()-t.getDegree(),s=e.multiply(n.getCoefficient(n.getDegree()),o),a=t.multiplyByMonomial(i,s),c=e.buildMonomial(i,s);r=r.addOrSubtract(c),n=n.addOrSubtract(a)}return[r,n]}toString(){let t="";for(let e=this.getDegree();e>=0;e--){let r=this.getCoefficient(e);if(0!==r){if(r<0?(t+=" - ",r=-r):t.length>0&&(t+=" + "),0===e||1!==r){const e=this.field.log(r);0===e?t+="1":1===e?t+="a":(t+="a^",t+=e)}0!==e&&(1===e?t+="x":(t+="x^",t+=e))}}return t}}class K extends s{}K.kind="ArithmeticException";class q extends Z{constructor(t,e,r){super(),this.primitive=t,this.size=e,this.generatorBase=r;const n=new Int32Array(e);let i=1;for(let r=0;r<e;r++)n[r]=i,i*=2,i>=e&&(i^=t,i&=e-1);this.expTable=n;const o=new Int32Array(e);for(let t=0;t<e-1;t++)o[n[t]]=t;this.logTable=o,this.zero=new Q(this,Int32Array.from([0])),this.one=new Q(this,Int32Array.from([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(t,e){if(t<0)throw new c;if(0===e)return this.zero;const r=new Int32Array(t+1);return r[0]=e,new Q(this,r)}inverse(t){if(0===t)throw new K;return this.expTable[this.size-this.logTable[t]-1]}multiply(t,e){return 0===t||0===e?0:this.expTable[(this.logTable[t]+this.logTable[e])%(this.size-1)]}getSize(){return this.size}getGeneratorBase(){return this.generatorBase}toString(){return"GF(0x"+m.toHexString(this.primitive)+","+this.size+")"}equals(t){return t===this}}q.AZTEC_DATA_12=new q(4201,4096,1),q.AZTEC_DATA_10=new q(1033,1024,1),q.AZTEC_DATA_6=new q(67,64,1),q.AZTEC_PARAM=new q(19,16,1),q.QR_CODE_FIELD_256=new q(285,256,0),q.DATA_MATRIX_FIELD_256=new q(301,256,1),q.AZTEC_DATA_8=q.DATA_MATRIX_FIELD_256,q.MAXICODE_FIELD_64=q.AZTEC_DATA_6;class J extends s{}J.kind="ReedSolomonException";class $ extends s{}$.kind="IllegalStateException";class tt{constructor(t){this.field=t}decode(t,e){const r=this.field,n=new Q(r,t),i=new Int32Array(e);let o=!0;for(let t=0;t<e;t++){const e=n.evaluateAt(r.exp(t+r.getGeneratorBase()));i[i.length-1-t]=e,0!==e&&(o=!1)}if(o)return;const s=new Q(r,i),a=this.runEuclideanAlgorithm(r.buildMonomial(e,1),s,e),c=a[0],l=a[1],h=this.findErrorLocations(c),u=this.findErrorMagnitudes(l,h);for(let e=0;e<h.length;e++){const n=t.length-1-r.log(h[e]);if(n<0)throw new J("Bad error location");t[n]=q.addOrSubtract(t[n],u[e])}}runEuclideanAlgorithm(t,e,r){if(t.getDegree()<e.getDegree()){const r=t;t=e,e=r}const n=this.field;let i=t,o=e,s=n.getZero(),a=n.getOne();for(;o.getDegree()>=(r/2|0);){let t=i,e=s;if(i=o,s=a,i.isZero())throw new J("r_{i-1} was zero");o=t;let r=n.getZero();const c=i.getCoefficient(i.getDegree()),l=n.inverse(c);for(;o.getDegree()>=i.getDegree()&&!o.isZero();){const t=o.getDegree()-i.getDegree(),e=n.multiply(o.getCoefficient(o.getDegree()),l);r=r.addOrSubtract(n.buildMonomial(t,e)),o=o.addOrSubtract(i.multiplyByMonomial(t,e))}if(a=r.multiply(s).addOrSubtract(e),o.getDegree()>=i.getDegree())throw new $("Division algorithm failed to reduce polynomial?")}const c=a.getCoefficient(0);if(0===c)throw new J("sigmaTilde(0) was zero");const l=n.inverse(c);return[a.multiplyScalar(l),o.multiplyScalar(l)]}findErrorLocations(t){const e=t.getDegree();if(1===e)return Int32Array.from([t.getCoefficient(1)]);const r=new Int32Array(e);let n=0;const i=this.field;for(let o=1;o<i.getSize()&&n<e;o++)0===t.evaluateAt(o)&&(r[n]=i.inverse(o),n++);if(n!==e)throw new J("Error locator degree does not match number of roots");return r}findErrorMagnitudes(t,e){const r=e.length,n=new Int32Array(r),i=this.field;for(let o=0;o<r;o++){const s=i.inverse(e[o]);let a=1;for(let t=0;t<r;t++)if(o!==t){const r=i.multiply(e[t],s),n=0==(1&r)?1|r:-2&r;a=i.multiply(a,n)}n[o]=i.multiply(t.evaluateAt(s),i.inverse(a)),0!==i.getGeneratorBase()&&(n[o]=i.multiply(n[o],s))}return n}}!function(t){t[t.UPPER=0]="UPPER",t[t.LOWER=1]="LOWER",t[t.MIXED=2]="MIXED",t[t.DIGIT=3]="DIGIT",t[t.PUNCT=4]="PUNCT",t[t.BINARY=5]="BINARY"}(H||(H={}));class et{decode(t){this.ddata=t;let e=t.getBits(),r=this.extractBits(e),n=this.correctBits(r),i=et.convertBoolArrayToByteArray(n),o=et.getEncodedData(n),s=new j(i,o,null,null);return s.setNumBits(n.length),s}static highLevelDecode(t){return this.getEncodedData(t)}static getEncodedData(t){let e=t.length,r=H.UPPER,n=H.UPPER,i="",o=0;for(;o<e;)if(n===H.BINARY){if(e-o<5)break;let s=et.readCode(t,o,5);if(o+=5,0===s){if(e-o<11)break;s=et.readCode(t,o,11)+31,o+=11}for(let r=0;r<s;r++){if(e-o<8){o=e;break}const r=et.readCode(t,o,8);i+=T.castAsNonUtf8Char(r),o+=8}n=r}else{let s=n===H.DIGIT?4:5;if(e-o<s)break;let a=et.readCode(t,o,s);o+=s;let c=et.getCharacter(n,a);c.startsWith("CTRL_")?(r=n,n=et.getTable(c.charAt(5)),"L"===c.charAt(6)&&(r=n)):(i+=c,n=r)}return i}static getTable(t){switch(t){case"L":return H.LOWER;case"P":return H.PUNCT;case"M":return H.MIXED;case"D":return H.DIGIT;case"B":return H.BINARY;default:return H.UPPER}}static getCharacter(t,e){switch(t){case H.UPPER:return et.UPPER_TABLE[e];case H.LOWER:return et.LOWER_TABLE[e];case H.MIXED:return et.MIXED_TABLE[e];case H.PUNCT:return et.PUNCT_TABLE[e];case H.DIGIT:return et.DIGIT_TABLE[e];default:throw new $("Bad table")}}correctBits(t){let e,r;this.ddata.getNbLayers()<=2?(r=6,e=q.AZTEC_DATA_6):this.ddata.getNbLayers()<=8?(r=8,e=q.AZTEC_DATA_8):this.ddata.getNbLayers()<=22?(r=10,e=q.AZTEC_DATA_10):(r=12,e=q.AZTEC_DATA_12);let n=this.ddata.getNbDatablocks(),i=t.length/r;if(i<n)throw new E;let o=t.length%r,s=new Int32Array(i);for(let e=0;e<i;e++,o+=r)s[e]=et.readCode(t,o,r);try{new tt(e).decode(s,i-n)}catch(t){throw new E(t)}let a=(1<<r)-1,c=0;for(let t=0;t<n;t++){let e=s[t];if(0===e||e===a)throw new E;1!==e&&e!==a-1||c++}let l=new Array(n*r-c),h=0;for(let t=0;t<n;t++){let e=s[t];if(1===e||e===a-1)l.fill(e>1,h,h+r-1),h+=r-1;else for(let t=r-1;t>=0;--t)l[h++]=0!=(e&1<<t)}return l}extractBits(t){let e=this.ddata.isCompact(),r=this.ddata.getNbLayers(),n=(e?11:14)+4*r,i=new Int32Array(n),o=new Array(this.totalBitsInLayer(r,e));if(e)for(let t=0;t<i.length;t++)i[t]=t;else{let t=n+1+2*m.truncDivision(m.truncDivision(n,2)-1,15),e=n/2,r=m.truncDivision(t,2);for(let t=0;t<e;t++){let n=t+m.truncDivision(t,15);i[e-t-1]=r-n-1,i[e+t]=r+n+1}}for(let s=0,a=0;s<r;s++){let c=4*(r-s)+(e?9:12),l=2*s,h=n-1-l;for(let e=0;e<c;e++){let r=2*e;for(let n=0;n<2;n++)o[a+r+n]=t.get(i[l+n],i[l+e]),o[a+2*c+r+n]=t.get(i[l+e],i[h-n]),o[a+4*c+r+n]=t.get(i[h-n],i[h-e]),o[a+6*c+r+n]=t.get(i[h-e],i[l+n])}a+=8*c}return o}static readCode(t,e,r){let n=0;for(let i=e;i<e+r;i++)n<<=1,t[i]&&(n|=1);return n}static readByte(t,e){let r=t.length-e;return r>=8?et.readCode(t,e,8):et.readCode(t,e,r)<<8-r}static convertBoolArrayToByteArray(t){let e=new Uint8Array((t.length+7)/8);for(let r=0;r<e.length;r++)e[r]=et.readByte(t,8*r);return e}totalBitsInLayer(t,e){return((e?88:112)+16*t)*t}}et.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"],et.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"],et.MIXED_TABLE=["CTRL_PS"," ","\\1","\\2","\\3","\\4","\\5","\\6","\\7","\b","\t","\n","\\13","\f","\r","\\33","\\34","\\35","\\36","\\37","@","\\","^","_","`","|","~","\\177","CTRL_LL","CTRL_UL","CTRL_PL","CTRL_BS"],et.PUNCT_TABLE=["","\r","\r\n",". ",", ",": ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}","CTRL_UL"],et.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class rt{constructor(){}static round(t){return NaN===t?0:t<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:t>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:t+(t<0?-.5:.5)|0}static distance(t,e,r,n){const i=t-r,o=e-n;return Math.sqrt(i*i+o*o)}static sum(t){let e=0;for(let r=0,n=t.length;r!==n;r++)e+=t[r];return e}}class nt{static floatToIntBits(t){return t}}nt.MAX_VALUE=Number.MAX_SAFE_INTEGER;class it{constructor(t,e){this.x=t,this.y=e}getX(){return this.x}getY(){return this.y}equals(t){if(t instanceof it){const e=t;return this.x===e.x&&this.y===e.y}return!1}hashCode(){return 31*nt.floatToIntBits(this.x)+nt.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(t){const e=this.distance(t[0],t[1]),r=this.distance(t[1],t[2]),n=this.distance(t[0],t[2]);let i,o,s;if(r>=e&&r>=n?(o=t[0],i=t[1],s=t[2]):n>=r&&n>=e?(o=t[1],i=t[0],s=t[2]):(o=t[2],i=t[0],s=t[1]),this.crossProductZ(i,o,s)<0){const t=i;i=s,s=t}t[0]=i,t[1]=o,t[2]=s}static distance(t,e){return rt.distance(t.x,t.y,e.x,e.y)}static crossProductZ(t,e,r){const n=e.x,i=e.y;return(r.x-n)*(t.y-i)-(r.y-i)*(t.x-n)}}class ot{constructor(t,e){this.bits=t,this.points=e}getBits(){return this.bits}getPoints(){return this.points}}class st extends ot{constructor(t,e,r,n,i){super(t,e),this.compact=r,this.nbDatablocks=n,this.nbLayers=i}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class at{constructor(t,e,r,n){this.image=t,this.height=t.getHeight(),this.width=t.getWidth(),null==e&&(e=at.INIT_SIZE),null==r&&(r=t.getWidth()/2|0),null==n&&(n=t.getHeight()/2|0);const i=e/2|0;if(this.leftInit=r-i,this.rightInit=r+i,this.upInit=n-i,this.downInit=n+i,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new D}detect(){let t=this.leftInit,e=this.rightInit,r=this.upInit,n=this.downInit,i=!1,o=!0,s=!1,a=!1,c=!1,l=!1,h=!1;const u=this.width,d=this.height;for(;o;){o=!1;let f=!0;for(;(f||!a)&&e<u;)f=this.containsBlackPoint(r,n,e,!1),f?(e++,o=!0,a=!0):a||e++;if(e>=u){i=!0;break}let g=!0;for(;(g||!c)&&n<d;)g=this.containsBlackPoint(t,e,n,!0),g?(n++,o=!0,c=!0):c||n++;if(n>=d){i=!0;break}let w=!0;for(;(w||!l)&&t>=0;)w=this.containsBlackPoint(r,n,t,!1),w?(t--,o=!0,l=!0):l||t--;if(t<0){i=!0;break}let m=!0;for(;(m||!h)&&r>=0;)m=this.containsBlackPoint(t,e,r,!0),m?(r--,o=!0,h=!0):h||r--;if(r<0){i=!0;break}o&&(s=!0)}if(!i&&s){const i=e-t;let o=null;for(let e=1;null===o&&e<i;e++)o=this.getBlackPointOnSegment(t,n-e,t+e,n);if(null==o)throw new D;let s=null;for(let e=1;null===s&&e<i;e++)s=this.getBlackPointOnSegment(t,r+e,t+e,r);if(null==s)throw new D;let a=null;for(let t=1;null===a&&t<i;t++)a=this.getBlackPointOnSegment(e,r+t,e-t,r);if(null==a)throw new D;let c=null;for(let t=1;null===c&&t<i;t++)c=this.getBlackPointOnSegment(e,n-t,e-t,n);if(null==c)throw new D;return this.centerEdges(c,o,a,s)}throw new D}getBlackPointOnSegment(t,e,r,n){const i=rt.round(rt.distance(t,e,r,n)),o=(r-t)/i,s=(n-e)/i,a=this.image;for(let r=0;r<i;r++){const n=rt.round(t+r*o),i=rt.round(e+r*s);if(a.get(n,i))return new it(n,i)}return null}centerEdges(t,e,r,n){const i=t.getX(),o=t.getY(),s=e.getX(),a=e.getY(),c=r.getX(),l=r.getY(),h=n.getX(),u=n.getY(),d=at.CORR;return i<this.width/2?[new it(h-d,u+d),new it(s+d,a+d),new it(c-d,l-d),new it(i+d,o-d)]:[new it(h+d,u+d),new it(s+d,a-d),new it(c-d,l+d),new it(i-d,o-d)]}containsBlackPoint(t,e,r,n){const i=this.image;if(n){for(let n=t;n<=e;n++)if(i.get(n,r))return!0}else for(let n=t;n<=e;n++)if(i.get(r,n))return!0;return!1}}at.INIT_SIZE=10,at.CORR=1;class ct{static checkAndNudgePoints(t,e){const r=t.getWidth(),n=t.getHeight();let i=!0;for(let t=0;t<e.length&&i;t+=2){const o=Math.floor(e[t]),s=Math.floor(e[t+1]);if(o<-1||o>r||s<-1||s>n)throw new D;i=!1,-1===o?(e[t]=0,i=!0):o===r&&(e[t]=r-1,i=!0),-1===s?(e[t+1]=0,i=!0):s===n&&(e[t+1]=n-1,i=!0)}i=!0;for(let t=e.length-2;t>=0&&i;t-=2){const o=Math.floor(e[t]),s=Math.floor(e[t+1]);if(o<-1||o>r||s<-1||s>n)throw new D;i=!1,-1===o?(e[t]=0,i=!0):o===r&&(e[t]=r-1,i=!0),-1===s?(e[t+1]=0,i=!0):s===n&&(e[t+1]=n-1,i=!0)}}}class lt{constructor(t,e,r,n,i,o,s,a,c){this.a11=t,this.a21=e,this.a31=r,this.a12=n,this.a22=i,this.a32=o,this.a13=s,this.a23=a,this.a33=c}static quadrilateralToQuadrilateral(t,e,r,n,i,o,s,a,c,l,h,u,d,f,g,w){const m=lt.quadrilateralToSquare(t,e,r,n,i,o,s,a);return lt.squareToQuadrilateral(c,l,h,u,d,f,g,w).times(m)}transformPoints(t){const e=t.length,r=this.a11,n=this.a12,i=this.a13,o=this.a21,s=this.a22,a=this.a23,c=this.a31,l=this.a32,h=this.a33;for(let u=0;u<e;u+=2){const e=t[u],d=t[u+1],f=i*e+a*d+h;t[u]=(r*e+o*d+c)/f,t[u+1]=(n*e+s*d+l)/f}}transformPointsWithValues(t,e){const r=this.a11,n=this.a12,i=this.a13,o=this.a21,s=this.a22,a=this.a23,c=this.a31,l=this.a32,h=this.a33,u=t.length;for(let d=0;d<u;d++){const u=t[d],f=e[d],g=i*u+a*f+h;t[d]=(r*u+o*f+c)/g,e[d]=(n*u+s*f+l)/g}}static squareToQuadrilateral(t,e,r,n,i,o,s,a){const c=t-r+i-s,l=e-n+o-a;if(0===c&&0===l)return new lt(r-t,i-r,t,n-e,o-n,e,0,0,1);{const h=r-i,u=s-i,d=n-o,f=a-o,g=h*f-u*d,w=(c*f-u*l)/g,m=(h*l-c*d)/g;return new lt(r-t+w*r,s-t+m*s,t,n-e+w*n,a-e+m*a,e,w,m,1)}}static quadrilateralToSquare(t,e,r,n,i,o,s,a){return lt.squareToQuadrilateral(t,e,r,n,i,o,s,a).buildAdjoint()}buildAdjoint(){return new lt(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(t){return new lt(this.a11*t.a11+this.a21*t.a12+this.a31*t.a13,this.a11*t.a21+this.a21*t.a22+this.a31*t.a23,this.a11*t.a31+this.a21*t.a32+this.a31*t.a33,this.a12*t.a11+this.a22*t.a12+this.a32*t.a13,this.a12*t.a21+this.a22*t.a22+this.a32*t.a23,this.a12*t.a31+this.a22*t.a32+this.a32*t.a33,this.a13*t.a11+this.a23*t.a12+this.a33*t.a13,this.a13*t.a21+this.a23*t.a22+this.a33*t.a23,this.a13*t.a31+this.a23*t.a32+this.a33*t.a33)}}class ht extends ct{sampleGrid(t,e,r,n,i,o,s,a,c,l,h,u,d,f,g,w,m,p,A){const C=lt.quadrilateralToQuadrilateral(n,i,o,s,a,c,l,h,u,d,f,g,w,m,p,A);return this.sampleGridWithTransform(t,e,r,C)}sampleGridWithTransform(t,e,r,n){if(e<=0||r<=0)throw new D;const i=new N(e,r),o=new Float32Array(2*e);for(let e=0;e<r;e++){const r=o.length,s=e+.5;for(let t=0;t<r;t+=2)o[t]=t/2+.5,o[t+1]=s;n.transformPoints(o),ct.checkAndNudgePoints(t,o);try{for(let n=0;n<r;n+=2)t.get(Math.floor(o[n]),Math.floor(o[n+1]))&&i.set(n/2,e)}catch(t){throw new D}}return i}}class ut{static setGridSampler(t){ut.gridSampler=t}static getInstance(){return ut.gridSampler}}ut.gridSampler=new ht;class dt{constructor(t,e){this.x=t,this.y=e}toResultPoint(){return new it(this.getX(),this.getY())}getX(){return this.x}getY(){return this.y}}class ft{constructor(t){this.EXPECTED_CORNER_BITS=new Int32Array([3808,476,2107,1799]),this.image=t}detect(){return this.detectMirror(!1)}detectMirror(t){let e=this.getMatrixCenter(),r=this.getBullsEyeCorners(e);if(t){let t=r[0];r[0]=r[2],r[2]=t}this.extractParameters(r);let n=this.sampleGrid(this.image,r[this.shift%4],r[(this.shift+1)%4],r[(this.shift+2)%4],r[(this.shift+3)%4]),i=this.getMatrixCornerPoints(r);return new st(n,i,this.compact,this.nbDataBlocks,this.nbLayers)}extractParameters(t){if(!(this.isValidPoint(t[0])&&this.isValidPoint(t[1])&&this.isValidPoint(t[2])&&this.isValidPoint(t[3])))throw new D;let e=2*this.nbCenterLayers,r=new Int32Array([this.sampleLine(t[0],t[1],e),this.sampleLine(t[1],t[2],e),this.sampleLine(t[2],t[3],e),this.sampleLine(t[3],t[0],e)]);this.shift=this.getRotation(r,e);let n=0;for(let t=0;t<4;t++){let e=r[(this.shift+t)%4];this.compact?(n<<=7,n+=e>>1&127):(n<<=10,n+=(e>>2&992)+(e>>1&31))}let i=this.getCorrectedParameterData(n,this.compact);this.compact?(this.nbLayers=1+(i>>6),this.nbDataBlocks=1+(63&i)):(this.nbLayers=1+(i>>11),this.nbDataBlocks=1+(2047&i))}getRotation(t,e){let r=0;t.forEach(((t,n,i)=>{r=(t>>e-2<<1)+(1&t)+(r<<3)})),r=((1&r)<<11)+(r>>1);for(let t=0;t<4;t++)if(m.bitCount(r^this.EXPECTED_CORNER_BITS[t])<=2)return t;throw new D}getCorrectedParameterData(t,e){let r,n;e?(r=7,n=2):(r=10,n=4);let i=r-n,o=new Int32Array(r);for(let e=r-1;e>=0;--e)o[e]=15&t,t>>=4;try{new tt(q.AZTEC_PARAM).decode(o,i)}catch(t){throw new D}let s=0;for(let t=0;t<n;t++)s=(s<<4)+o[t];return s}getBullsEyeCorners(t){let e=t,r=t,n=t,i=t,o=!0;for(this.nbCenterLayers=1;this.nbCenterLayers<9;this.nbCenterLayers++){let t=this.getFirstDifferent(e,o,1,-1),s=this.getFirstDifferent(r,o,1,1),a=this.getFirstDifferent(n,o,-1,1),c=this.getFirstDifferent(i,o,-1,-1);if(this.nbCenterLayers>2){let r=this.distancePoint(c,t)*this.nbCenterLayers/(this.distancePoint(i,e)*(this.nbCenterLayers+2));if(r<.75||r>1.25||!this.isWhiteOrBlackRectangle(t,s,a,c))break}e=t,r=s,n=a,i=c,o=!o}if(5!==this.nbCenterLayers&&7!==this.nbCenterLayers)throw new D;this.compact=5===this.nbCenterLayers;let s=new it(e.getX()+.5,e.getY()-.5),a=new it(r.getX()+.5,r.getY()+.5),c=new it(n.getX()-.5,n.getY()+.5),l=new it(i.getX()-.5,i.getY()-.5);return this.expandSquare([s,a,c,l],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let t,e,r,n;try{let i=new at(this.image).detect();t=i[0],e=i[1],r=i[2],n=i[3]}catch(i){let o=this.image.getWidth()/2,s=this.image.getHeight()/2;t=this.getFirstDifferent(new dt(o+7,s-7),!1,1,-1).toResultPoint(),e=this.getFirstDifferent(new dt(o+7,s+7),!1,1,1).toResultPoint(),r=this.getFirstDifferent(new dt(o-7,s+7),!1,-1,1).toResultPoint(),n=this.getFirstDifferent(new dt(o-7,s-7),!1,-1,-1).toResultPoint()}let i=rt.round((t.getX()+n.getX()+e.getX()+r.getX())/4),o=rt.round((t.getY()+n.getY()+e.getY()+r.getY())/4);try{let s=new at(this.image,15,i,o).detect();t=s[0],e=s[1],r=s[2],n=s[3]}catch(s){t=this.getFirstDifferent(new dt(i+7,o-7),!1,1,-1).toResultPoint(),e=this.getFirstDifferent(new dt(i+7,o+7),!1,1,1).toResultPoint(),r=this.getFirstDifferent(new dt(i-7,o+7),!1,-1,1).toResultPoint(),n=this.getFirstDifferent(new dt(i-7,o-7),!1,-1,-1).toResultPoint()}return i=rt.round((t.getX()+n.getX()+e.getX()+r.getX())/4),o=rt.round((t.getY()+n.getY()+e.getY()+r.getY())/4),new dt(i,o)}getMatrixCornerPoints(t){return this.expandSquare(t,2*this.nbCenterLayers,this.getDimension())}sampleGrid(t,e,r,n,i){let o=ut.getInstance(),s=this.getDimension(),a=s/2-this.nbCenterLayers,c=s/2+this.nbCenterLayers;return o.sampleGrid(t,s,s,a,a,c,a,c,c,a,c,e.getX(),e.getY(),r.getX(),r.getY(),n.getX(),n.getY(),i.getX(),i.getY())}sampleLine(t,e,r){let n=0,i=this.distanceResultPoint(t,e),o=i/r,s=t.getX(),a=t.getY(),c=o*(e.getX()-t.getX())/i,l=o*(e.getY()-t.getY())/i;for(let t=0;t<r;t++)this.image.get(rt.round(s+t*c),rt.round(a+t*l))&&(n|=1<<r-t-1);return n}isWhiteOrBlackRectangle(t,e,r,n){t=new dt(t.getX()-3,t.getY()+3),e=new dt(e.getX()-3,e.getY()-3),r=new dt(r.getX()+3,r.getY()-3),n=new dt(n.getX()+3,n.getY()+3);let i=this.getColor(n,t);if(0===i)return!1;let o=this.getColor(t,e);return o===i&&(o=this.getColor(e,r),o===i&&(o=this.getColor(r,n),o===i))}getColor(t,e){let r=this.distancePoint(t,e),n=(e.getX()-t.getX())/r,i=(e.getY()-t.getY())/r,o=0,s=t.getX(),a=t.getY(),c=this.image.get(t.getX(),t.getY()),l=Math.ceil(r);for(let t=0;t<l;t++)s+=n,a+=i,this.image.get(rt.round(s),rt.round(a))!==c&&o++;let h=o/r;return h>.1&&h<.9?0:h<=.1===c?1:-1}getFirstDifferent(t,e,r,n){let i=t.getX()+r,o=t.getY()+n;for(;this.isValid(i,o)&&this.image.get(i,o)===e;)i+=r,o+=n;for(i-=r,o-=n;this.isValid(i,o)&&this.image.get(i,o)===e;)i+=r;for(i-=r;this.isValid(i,o)&&this.image.get(i,o)===e;)o+=n;return o-=n,new dt(i,o)}expandSquare(t,e,r){let n=r/(2*e),i=t[0].getX()-t[2].getX(),o=t[0].getY()-t[2].getY(),s=(t[0].getX()+t[2].getX())/2,a=(t[0].getY()+t[2].getY())/2,c=new it(s+n*i,a+n*o),l=new it(s-n*i,a-n*o);return i=t[1].getX()-t[3].getX(),o=t[1].getY()-t[3].getY(),s=(t[1].getX()+t[3].getX())/2,a=(t[1].getY()+t[3].getY())/2,[c,new it(s+n*i,a+n*o),l,new it(s-n*i,a-n*o)]}isValid(t,e){return t>=0&&t<this.image.getWidth()&&e>0&&e<this.image.getHeight()}isValidPoint(t){let e=rt.round(t.getX()),r=rt.round(t.getY());return this.isValid(e,r)}distancePoint(t,e){return rt.distance(t.getX(),t.getY(),e.getX(),e.getY())}distanceResultPoint(t,e){return rt.distance(t.getX(),t.getY(),e.getX(),e.getY())}getDimension(){return this.compact?4*this.nbLayers+11:this.nbLayers<=4?4*this.nbLayers+15:4*this.nbLayers+2*(m.truncDivision(this.nbLayers-4,8)+1)+15}}class gt{decode(t,e=null){let r=null,n=new ft(t.getBlackMatrix()),i=null,o=null;try{let t=n.detectMirror(!1);i=t.getPoints(),this.reportFoundResultPoints(e,i),o=(new et).decode(t)}catch(t){r=t}if(null==o)try{let t=n.detectMirror(!0);i=t.getPoints(),this.reportFoundResultPoints(e,i),o=(new et).decode(t)}catch(t){if(null!=r)throw r;throw t}let s=new x(o.getText(),o.getRawBytes(),o.getNumBits(),i,U.AZTEC,d.currentTimeMillis()),a=o.getByteSegments();null!=a&&s.putMetadata(W.BYTE_SEGMENTS,a);let c=o.getECLevel();return null!=c&&s.putMetadata(W.ERROR_CORRECTION_LEVEL,c),s}reportFoundResultPoints(t,e){if(null!=t){let r=t.get(C.NEED_RESULT_POINT_CALLBACK);null!=r&&e.forEach(((t,e,n)=>{r.foundPossibleResultPoint(t)}))}}reset(){}}class wt{decode(t,e){try{return this.doDecode(t,e)}catch(r){if(e&&!0===e.get(C.TRY_HARDER)&&t.isRotateSupported()){const r=t.rotateCounterClockwise(),n=this.doDecode(r,e),i=n.getResultMetadata();let o=270;null!==i&&!0===i.get(W.ORIENTATION)&&(o+=i.get(W.ORIENTATION)%360),n.putMetadata(W.ORIENTATION,o);const s=n.getResultPoints();if(null!==s){const t=r.getHeight();for(let e=0;e<s.length;e++)s[e]=new it(t-s[e].getY()-1,s[e].getX())}return n}throw new D}}reset(){}doDecode(t,e){const r=t.getWidth(),n=t.getHeight();let i=new p(r);const o=e&&!0===e.get(C.TRY_HARDER),s=Math.max(1,n>>(o?8:5));let a;a=o?n:15;const c=Math.trunc(n/2);for(let o=0;o<a;o++){const a=Math.trunc((o+1)/2),l=c+s*(0==(1&o)?a:-a);if(l<0||l>=n)break;try{i=t.getBlackRow(l,i)}catch(t){continue}for(let t=0;t<2;t++){if(1===t&&(i.reverse(),e&&!0===e.get(C.NEED_RESULT_POINT_CALLBACK))){const t=new Map;e.forEach(((e,r)=>t.set(r,e))),t.delete(C.NEED_RESULT_POINT_CALLBACK),e=t}try{const n=this.decodeRow(l,i,e);if(1===t){n.putMetadata(W.ORIENTATION,180);const t=n.getResultPoints();null!==t&&(t[0]=new it(r-t[0].getX()-1,t[0].getY()),t[1]=new it(r-t[1].getX()-1,t[1].getY()))}return n}catch(t){}}}throw new D}static recordPattern(t,e,r){const n=r.length;for(let t=0;t<n;t++)r[t]=0;const i=t.getSize();if(e>=i)throw new D;let o=!t.get(e),s=0,a=e;for(;a<i;){if(t.get(a)!==o)r[s]++;else{if(++s===n)break;r[s]=1,o=!o}a++}if(s!==n&&(s!==n-1||a!==i))throw new D}static recordPatternInReverse(t,e,r){let n=r.length,i=t.get(e);for(;e>0&&n>=0;)t.get(--e)!==i&&(n--,i=!i);if(n>=0)throw new D;wt.recordPattern(t,e+1,r)}static patternMatchVariance(t,e,r){const n=t.length;let i=0,o=0;for(let r=0;r<n;r++)i+=t[r],o+=e[r];if(i<o)return Number.POSITIVE_INFINITY;const s=i/o;r*=s;let a=0;for(let i=0;i<n;i++){const n=t[i],o=e[i]*s,c=n>o?n-o:o-n;if(c>r)return Number.POSITIVE_INFINITY;a+=c}return a/i}}class mt extends wt{static findStartPattern(t){const e=t.getSize(),r=t.getNextSet(0);let n=0,i=Int32Array.from([0,0,0,0,0,0]),o=r,s=!1;for(let a=r;a<e;a++)if(t.get(a)!==s)i[n]++;else{if(5===n){let e=mt.MAX_AVG_VARIANCE,r=-1;for(let t=mt.CODE_START_A;t<=mt.CODE_START_C;t++){const n=wt.patternMatchVariance(i,mt.CODE_PATTERNS[t],mt.MAX_INDIVIDUAL_VARIANCE);n<e&&(e=n,r=t)}if(r>=0&&t.isRange(Math.max(0,o-(a-o)/2),o,!1))return Int32Array.from([o,a,r]);o+=i[0]+i[1],i=i.slice(2,i.length-1),i[n-1]=0,i[n]=0,n--}else n++;i[n]=1,s=!s}throw new D}static decodeCode(t,e,r){wt.recordPattern(t,r,e);let n=mt.MAX_AVG_VARIANCE,i=-1;for(let t=0;t<mt.CODE_PATTERNS.length;t++){const r=mt.CODE_PATTERNS[t],o=this.patternMatchVariance(e,r,mt.MAX_INDIVIDUAL_VARIANCE);o<n&&(n=o,i=t)}if(i>=0)return i;throw new D}decodeRow(t,e,r){const n=r&&!0===r.get(C.ASSUME_GS1),i=mt.findStartPattern(e),o=i[2];let s=0;const a=new Uint8Array(20);let c;switch(a[s++]=o,o){case mt.CODE_START_A:c=mt.CODE_CODE_A;break;case mt.CODE_START_B:c=mt.CODE_CODE_B;break;case mt.CODE_START_C:c=mt.CODE_CODE_C;break;default:throw new E}let l=!1,u=!1,d="",f=i[0],g=i[1];const w=Int32Array.from([0,0,0,0,0,0]);let m=0,p=0,A=o,I=0,S=!0,_=!1,T=!1;for(;!l;){const t=u;switch(u=!1,m=p,p=mt.decodeCode(e,w,g),a[s++]=p,p!==mt.CODE_STOP&&(S=!0),p!==mt.CODE_STOP&&(I++,A+=I*p),f=g,g+=w.reduce(((t,e)=>t+e),0),p){case mt.CODE_START_A:case mt.CODE_START_B:case mt.CODE_START_C:throw new E}switch(c){case mt.CODE_CODE_A:if(p<64)d+=T===_?String.fromCharCode(" ".charCodeAt(0)+p):String.fromCharCode(" ".charCodeAt(0)+p+128),T=!1;else if(p<96)d+=T===_?String.fromCharCode(p-64):String.fromCharCode(p+64),T=!1;else switch(p!==mt.CODE_STOP&&(S=!1),p){case mt.CODE_FNC_1:n&&(0===d.length?d+="]C1":d+=String.fromCharCode(29));break;case mt.CODE_FNC_2:case mt.CODE_FNC_3:break;case mt.CODE_FNC_4_A:!_&&T?(_=!0,T=!1):_&&T?(_=!1,T=!1):T=!0;break;case mt.CODE_SHIFT:u=!0,c=mt.CODE_CODE_B;break;case mt.CODE_CODE_B:c=mt.CODE_CODE_B;break;case mt.CODE_CODE_C:c=mt.CODE_CODE_C;break;case mt.CODE_STOP:l=!0}break;case mt.CODE_CODE_B:if(p<96)d+=T===_?String.fromCharCode(" ".charCodeAt(0)+p):String.fromCharCode(" ".charCodeAt(0)+p+128),T=!1;else switch(p!==mt.CODE_STOP&&(S=!1),p){case mt.CODE_FNC_1:n&&(0===d.length?d+="]C1":d+=String.fromCharCode(29));break;case mt.CODE_FNC_2:case mt.CODE_FNC_3:break;case mt.CODE_FNC_4_B:!_&&T?(_=!0,T=!1):_&&T?(_=!1,T=!1):T=!0;break;case mt.CODE_SHIFT:u=!0,c=mt.CODE_CODE_A;break;case mt.CODE_CODE_A:c=mt.CODE_CODE_A;break;case mt.CODE_CODE_C:c=mt.CODE_CODE_C;break;case mt.CODE_STOP:l=!0}break;case mt.CODE_CODE_C:if(p<100)p<10&&(d+="0"),d+=p;else switch(p!==mt.CODE_STOP&&(S=!1),p){case mt.CODE_FNC_1:n&&(0===d.length?d+="]C1":d+=String.fromCharCode(29));break;case mt.CODE_CODE_A:c=mt.CODE_CODE_A;break;case mt.CODE_CODE_B:c=mt.CODE_CODE_B;break;case mt.CODE_STOP:l=!0}}t&&(c=c===mt.CODE_CODE_A?mt.CODE_CODE_B:mt.CODE_CODE_A)}const y=g-f;if(g=e.getNextUnset(g),!e.isRange(g,Math.min(e.getSize(),g+(g-f)/2),!1))throw new D;if(A-=I*m,A%103!==m)throw new h;const N=d.length;if(0===N)throw new D;N>0&&S&&(d=c===mt.CODE_CODE_C?d.substring(0,N-2):d.substring(0,N-1));const M=(i[1]+i[0])/2,R=f+y/2,O=a.length,b=new Uint8Array(O);for(let t=0;t<O;t++)b[t]=a[t];const B=[new it(M,t),new it(R,t)];return new x(d,b,0,B,U.CODE_128,(new Date).getTime())}}mt.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])],mt.MAX_AVG_VARIANCE=.25,mt.MAX_INDIVIDUAL_VARIANCE=.7,mt.CODE_SHIFT=98,mt.CODE_CODE_C=99,mt.CODE_CODE_B=100,mt.CODE_CODE_A=101,mt.CODE_FNC_1=102,mt.CODE_FNC_2=97,mt.CODE_FNC_3=96,mt.CODE_FNC_4_A=101,mt.CODE_FNC_4_B=100,mt.CODE_START_A=103,mt.CODE_START_B=104,mt.CODE_START_C=105,mt.CODE_STOP=106;class pt extends wt{constructor(t=!1,e=!1){super(),this.usingCheckDigit=t,this.extendedMode=e,this.decodeRowResult="",this.counters=new Int32Array(9)}decodeRow(t,e,r){let n=this.counters;n.fill(0),this.decodeRowResult="";let i,o,s=pt.findAsteriskPattern(e,n),a=e.getNextSet(s[1]),c=e.getSize();do{pt.recordPattern(e,a,n);let t=pt.toNarrowWidePattern(n);if(t<0)throw new D;i=pt.patternToChar(t),this.decodeRowResult+=i,o=a;for(let t of n)a+=t;a=e.getNextSet(a)}while("*"!==i);this.decodeRowResult=this.decodeRowResult.substring(0,this.decodeRowResult.length-1);let l,u=0;for(let t of n)u+=t;if(a!==c&&2*(a-o-u)<u)throw new D;if(this.usingCheckDigit){let t=this.decodeRowResult.length-1,e=0;for(let r=0;r<t;r++)e+=pt.ALPHABET_STRING.indexOf(this.decodeRowResult.charAt(r));if(this.decodeRowResult.charAt(t)!==pt.ALPHABET_STRING.charAt(e%43))throw new h;this.decodeRowResult=this.decodeRowResult.substring(0,t)}if(0===this.decodeRowResult.length)throw new D;l=this.extendedMode?pt.decodeExtended(this.decodeRowResult):this.decodeRowResult;let d=(s[1]+s[0])/2,f=o+u/2;return new x(l,null,0,[new it(d,t),new it(f,t)],U.CODE_39,(new Date).getTime())}static findAsteriskPattern(t,e){let r=t.getSize(),n=t.getNextSet(0),i=0,o=n,s=!1,a=e.length;for(let c=n;c<r;c++)if(t.get(c)!==s)e[i]++;else{if(i===a-1){if(this.toNarrowWidePattern(e)===pt.ASTERISK_ENCODING&&t.isRange(Math.max(0,o-Math.floor((c-o)/2)),o,!1))return[o,c];o+=e[0]+e[1],e.copyWithin(0,2,2+i-1),e[i-1]=0,e[i]=0,i--}else i++;e[i]=1,s=!s}throw new D}static toNarrowWidePattern(t){let e,r=t.length,n=0;do{let i=2147483647;for(let e of t)e<i&&e>n&&(i=e);n=i,e=0;let o=0,s=0;for(let i=0;i<r;i++){let a=t[i];a>n&&(s|=1<<r-1-i,e++,o+=a)}if(3===e){for(let i=0;i<r&&e>0;i++){let r=t[i];if(r>n&&(e--,2*r>=o))return-1}return s}}while(e>3);return-1}static patternToChar(t){for(let e=0;e<pt.CHARACTER_ENCODINGS.length;e++)if(pt.CHARACTER_ENCODINGS[e]===t)return pt.ALPHABET_STRING.charAt(e);if(t===pt.ASTERISK_ENCODING)return"*";throw new D}static decodeExtended(t){let e=t.length,r="";for(let n=0;n<e;n++){let e=t.charAt(n);if("+"===e||"$"===e||"%"===e||"/"===e){let i=t.charAt(n+1),o="\0";switch(e){case"+":if(!(i>="A"&&i<="Z"))throw new E;o=String.fromCharCode(i.charCodeAt(0)+32);break;case"$":if(!(i>="A"&&i<="Z"))throw new E;o=String.fromCharCode(i.charCodeAt(0)-64);break;case"%":if(i>="A"&&i<="E")o=String.fromCharCode(i.charCodeAt(0)-38);else if(i>="F"&&i<="J")o=String.fromCharCode(i.charCodeAt(0)-11);else if(i>="K"&&i<="O")o=String.fromCharCode(i.charCodeAt(0)+16);else if(i>="P"&&i<="T")o=String.fromCharCode(i.charCodeAt(0)+43);else if("U"===i)o="\0";else if("V"===i)o="@";else if("W"===i)o="`";else{if("X"!==i&&"Y"!==i&&"Z"!==i)throw new E;o=""}break;case"/":if(i>="A"&&i<="O")o=String.fromCharCode(i.charCodeAt(0)-32);else{if("Z"!==i)throw new E;o=":"}}r+=o,n++}else r+=e}return r}}pt.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",pt.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],pt.ASTERISK_ENCODING=148;class At extends wt{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(t,e,r){let n=this.decodeStart(e),i=this.decodeEnd(e),o=new y;At.decodeMiddle(e,n[1],i[0],o);let s=o.toString(),a=null;null!=r&&(a=r.get(C.ALLOWED_LENGTHS)),null==a&&(a=At.DEFAULT_ALLOWED_LENGTHS);let c=s.length,l=!1,h=0;for(let t of a){if(c===t){l=!0;break}t>h&&(h=t)}if(!l&&c>h&&(l=!0),!l)throw new E;const u=[new it(n[1],t),new it(i[0],t)];return new x(s,null,0,u,U.ITF,(new Date).getTime())}static decodeMiddle(t,e,r,n){let i=new Int32Array(10),o=new Int32Array(5),s=new Int32Array(5);for(i.fill(0),o.fill(0),s.fill(0);e<r;){wt.recordPattern(t,e,i);for(let t=0;t<5;t++){let e=2*t;o[t]=i[e],s[t]=i[e+1]}let r=At.decodeDigit(o);n.append(r.toString()),r=this.decodeDigit(s),n.append(r.toString()),i.forEach((function(t){e+=t}))}}decodeStart(t){let e=At.skipWhiteSpace(t),r=At.findGuardPattern(t,e,At.START_PATTERN);return this.narrowLineWidth=(r[1]-r[0])/4,this.validateQuietZone(t,r[0]),r}validateQuietZone(t,e){let r=10*this.narrowLineWidth;r=r<e?r:e;for(let n=e-1;r>0&&n>=0&&!t.get(n);n--)r--;if(0!==r)throw new D}static skipWhiteSpace(t){const e=t.getSize(),r=t.getNextSet(0);if(r===e)throw new D;return r}decodeEnd(t){t.reverse();try{let e,r=At.skipWhiteSpace(t);try{e=At.findGuardPattern(t,r,At.END_PATTERN_REVERSED[0])}catch(n){n instanceof D&&(e=At.findGuardPattern(t,r,At.END_PATTERN_REVERSED[1]))}this.validateQuietZone(t,e[0]);let n=e[0];return e[0]=t.getSize()-e[1],e[1]=t.getSize()-n,e}finally{t.reverse()}}static findGuardPattern(t,e,r){let n=r.length,i=new Int32Array(n),o=t.getSize(),s=!1,a=0,c=e;i.fill(0);for(let l=e;l<o;l++)if(t.get(l)!==s)i[a]++;else{if(a===n-1){if(wt.patternMatchVariance(i,r,At.MAX_INDIVIDUAL_VARIANCE)<At.MAX_AVG_VARIANCE)return[c,l];c+=i[0]+i[1],d.arraycopy(i,2,i,0,a-1),i[a-1]=0,i[a]=0,a--}else a++;i[a]=1,s=!s}throw new D}static decodeDigit(t){let e=At.MAX_AVG_VARIANCE,r=-1,n=At.PATTERNS.length;for(let i=0;i<n;i++){let n=At.PATTERNS[i],o=wt.patternMatchVariance(t,n,At.MAX_INDIVIDUAL_VARIANCE);o<e?(e=o,r=i):o===e&&(r=-1)}if(r>=0)return r%10;throw new D}}At.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])],At.MAX_AVG_VARIANCE=.38,At.MAX_INDIVIDUAL_VARIANCE=.5,At.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],At.START_PATTERN=Int32Array.from([1,1,1,1]),At.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class Ct extends wt{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(t){let e,r=!1,n=0,i=Int32Array.from([0,0,0]);for(;!r;){i=Int32Array.from([0,0,0]),e=Ct.findGuardPattern(t,n,!1,this.START_END_PATTERN,i);let o=e[0];n=e[1];let s=o-(n-o);s>=0&&(r=t.isRange(s,o,!1))}return e}static checkChecksum(t){return Ct.checkStandardUPCEANChecksum(t)}static checkStandardUPCEANChecksum(t){let e=t.length;if(0===e)return!1;let r=parseInt(t.charAt(e-1),10);return Ct.getStandardUPCEANChecksum(t.substring(0,e-1))===r}static getStandardUPCEANChecksum(t){let e=t.length,r=0;for(let n=e-1;n>=0;n-=2){let e=t.charAt(n).charCodeAt(0)-"0".charCodeAt(0);if(e<0||e>9)throw new E;r+=e}r*=3;for(let n=e-2;n>=0;n-=2){let e=t.charAt(n).charCodeAt(0)-"0".charCodeAt(0);if(e<0||e>9)throw new E;r+=e}return(1e3-r)%10}static decodeEnd(t,e){return Ct.findGuardPattern(t,e,!1,Ct.START_END_PATTERN,new Int32Array(Ct.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(t,e,r,n){return this.findGuardPattern(t,e,r,n,new Int32Array(n.length))}static findGuardPattern(t,e,r,n,i){let o=t.getSize(),s=0,a=e=r?t.getNextUnset(e):t.getNextSet(e),c=n.length,l=r;for(let r=e;r<o;r++)if(t.get(r)!==l)i[s]++;else{if(s===c-1){if(wt.patternMatchVariance(i,n,Ct.MAX_INDIVIDUAL_VARIANCE)<Ct.MAX_AVG_VARIANCE)return Int32Array.from([a,r]);a+=i[0]+i[1];let t=i.slice(2,i.length-1);for(let e=0;e<s-1;e++)i[e]=t[e];i[s-1]=0,i[s]=0,s--}else s++;i[s]=1,l=!l}throw new D}static decodeDigit(t,e,r,n){this.recordPattern(t,r,e);let i=this.MAX_AVG_VARIANCE,o=-1,s=n.length;for(let t=0;t<s;t++){let r=n[t],s=wt.patternMatchVariance(e,r,Ct.MAX_INDIVIDUAL_VARIANCE);s<i&&(i=s,o=t)}if(o>=0)return o;throw new D}}Ct.MAX_AVG_VARIANCE=.48,Ct.MAX_INDIVIDUAL_VARIANCE=.7,Ct.START_END_PATTERN=Int32Array.from([1,1,1]),Ct.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),Ct.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Ct.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 Et{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(t,e,r){let n=this.decodeRowStringBuffer,i=this.decodeMiddle(e,r,n),o=n.toString(),s=Et.parseExtensionString(o),a=[new it((r[0]+r[1])/2,t),new it(i,t)],c=new x(o,null,0,a,U.UPC_EAN_EXTENSION,(new Date).getTime());return null!=s&&c.putAllMetadata(s),c}decodeMiddle(t,e,r){let n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i=t.getSize(),o=e[1],s=0;for(let e=0;e<5&&o<i;e++){let i=Ct.decodeDigit(t,n,o,Ct.L_AND_G_PATTERNS);r+=String.fromCharCode("0".charCodeAt(0)+i%10);for(let t of n)o+=t;i>=10&&(s|=1<<4-e),4!==e&&(o=t.getNextSet(o),o=t.getNextUnset(o))}if(5!==r.length)throw new D;let a=this.determineCheckDigit(s);if(Et.extensionChecksum(r.toString())!==a)throw new D;return o}static extensionChecksum(t){let e=t.length,r=0;for(let n=e-2;n>=0;n-=2)r+=t.charAt(n).charCodeAt(0)-"0".charCodeAt(0);r*=3;for(let n=e-1;n>=0;n-=2)r+=t.charAt(n).charCodeAt(0)-"0".charCodeAt(0);return r*=3,r%10}determineCheckDigit(t){for(let e=0;e<10;e++)if(t===this.CHECK_DIGIT_ENCODINGS[e])return e;throw new D}static parseExtensionString(t){if(5!==t.length)return null;let e=Et.parseExtension5String(t);return null==e?null:new Map([[W.SUGGESTED_PRICE,e]])}static parseExtension5String(t){let e;switch(t.charAt(0)){case"0":e="£";break;case"5":e="$";break;case"9":switch(t){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}e="";break;default:e=""}let r=parseInt(t.substring(1)),n=r%100;return e+(r/100).toString()+"."+(n<10?"0"+n:n.toString())}}class It{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(t,e,r){let n=this.decodeRowStringBuffer,i=this.decodeMiddle(e,r,n),o=n.toString(),s=It.parseExtensionString(o),a=[new it((r[0]+r[1])/2,t),new it(i,t)],c=new x(o,null,0,a,U.UPC_EAN_EXTENSION,(new Date).getTime());return null!=s&&c.putAllMetadata(s),c}decodeMiddle(t,e,r){let n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i=t.getSize(),o=e[1],s=0;for(let e=0;e<2&&o<i;e++){let i=Ct.decodeDigit(t,n,o,Ct.L_AND_G_PATTERNS);r+=String.fromCharCode("0".charCodeAt(0)+i%10);for(let t of n)o+=t;i>=10&&(s|=1<<1-e),1!==e&&(o=t.getNextSet(o),o=t.getNextUnset(o))}if(2!==r.length)throw new D;if(parseInt(r.toString())%4!==s)throw new D;return o}static parseExtensionString(t){return 2!==t.length?null:new Map([[W.ISSUE_NUMBER,parseInt(t)]])}}class St{static decodeRow(t,e,r){let n=Ct.findGuardPattern(e,r,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return(new Et).decodeRow(t,e,n)}catch(r){return(new It).decodeRow(t,e,n)}}}St.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class _t extends Ct{constructor(){super(),this.decodeRowStringBuffer="",_t.L_AND_G_PATTERNS=_t.L_PATTERNS.map((t=>Int32Array.from(t)));for(let t=10;t<20;t++){let e=_t.L_PATTERNS[t-10],r=new Int32Array(e.length);for(let t=0;t<e.length;t++)r[t]=e[e.length-t-1];_t.L_AND_G_PATTERNS[t]=r}}decodeRow(t,e,r){let n=_t.findStartGuardPattern(e),i=null==r?null:r.get(C.NEED_RESULT_POINT_CALLBACK);if(null!=i){const e=new it((n[0]+n[1])/2,t);i.foundPossibleResultPoint(e)}let o=this.decodeMiddle(e,n,this.decodeRowStringBuffer),s=o.rowOffset,a=o.resultString;if(null!=i){const e=new it(s,t);i.foundPossibleResultPoint(e)}let c=this.decodeEnd(e,s);if(null!=i){const e=new it((c[0]+c[1])/2,t);i.foundPossibleResultPoint(e)}let l=c[1],u=l+(l-c[0]);if(u>=e.getSize()||!e.isRange(l,u,!1))throw new D;let d=a.toString();if(d.length<8)throw new E;if(!_t.checkChecksum(d))throw new h;let f=(n[1]+n[0])/2,g=(c[1]+c[0])/2,w=this.getBarcodeFormat(),m=[new it(f,t),new it(g,t)],p=new x(d,null,0,m,w,(new Date).getTime()),A=0;try{let r=St.decodeRow(t,e,c[1]);p.putMetadata(W.UPC_EAN_EXTENSION,r.getText()),p.putAllMetadata(r.getResultMetadata()),p.addResultPoints(r.getResultPoints()),A=r.getText().length}catch(t){}let I=null==r?null:r.get(C.ALLOWED_EAN_EXTENSIONS);if(null!=I){let t=!1;for(let e in I)if(A.toString()===e){t=!0;break}if(!t)throw new D}return p}decodeEnd(t,e){return _t.findGuardPattern(t,e,!1,_t.START_END_PATTERN,new Int32Array(_t.START_END_PATTERN.length).fill(0))}static checkChecksum(t){return _t.checkStandardUPCEANChecksum(t)}static checkStandardUPCEANChecksum(t){let e=t.length;if(0===e)return!1;let r=parseInt(t.charAt(e-1),10);return _t.getStandardUPCEANChecksum(t.substring(0,e-1))===r}static getStandardUPCEANChecksum(t){let e=t.length,r=0;for(let n=e-1;n>=0;n-=2){let e=t.charAt(n).charCodeAt(0)-"0".charCodeAt(0);if(e<0||e>9)throw new E;r+=e}r*=3;for(let n=e-2;n>=0;n-=2){let e=t.charAt(n).charCodeAt(0)-"0".charCodeAt(0);if(e<0||e>9)throw new E;r+=e}return(1e3-r)%10}}class Tt extends _t{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(t,e,r){let n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i=t.getSize(),o=e[1],s=0;for(let e=0;e<6&&o<i;e++){let i=_t.decodeDigit(t,n,o,_t.L_AND_G_PATTERNS);r+=String.fromCharCode("0".charCodeAt(0)+i%10);for(let t of n)o+=t;i>=10&&(s|=1<<5-e)}r=Tt.determineFirstDigit(r,s),o=_t.findGuardPattern(t,o,!0,_t.MIDDLE_PATTERN,new Int32Array(_t.MIDDLE_PATTERN.length).fill(0))[1];for(let e=0;e<6&&o<i;e++){let e=_t.decodeDigit(t,n,o,_t.L_PATTERNS);r+=String.fromCharCode("0".charCodeAt(0)+e);for(let t of n)o+=t}return{rowOffset:o,resultString:r}}getBarcodeFormat(){return U.EAN_13}static determineFirstDigit(t,e){for(let r=0;r<10;r++)if(e===this.FIRST_DIGIT_ENCODINGS[r])return String.fromCharCode("0".charCodeAt(0)+r)+t;throw new D}}Tt.FIRST_DIGIT_ENCODINGS=[0,11,13,14,19,25,28,21,22,26];class yt extends _t{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(t,e,r){const n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i=t.getSize(),o=e[1];for(let e=0;e<4&&o<i;e++){let e=_t.decodeDigit(t,n,o,_t.L_PATTERNS);r+=String.fromCharCode("0".charCodeAt(0)+e);for(let t of n)o+=t}o=_t.findGuardPattern(t,o,!0,_t.MIDDLE_PATTERN,new Int32Array(_t.MIDDLE_PATTERN.length).fill(0))[1];for(let e=0;e<4&&o<i;e++){let e=_t.decodeDigit(t,n,o,_t.L_PATTERNS);r+=String.fromCharCode("0".charCodeAt(0)+e);for(let t of n)o+=t}return{rowOffset:o,resultString:r}}getBarcodeFormat(){return U.EAN_8}}class Nt extends _t{constructor(){super(...arguments),this.ean13Reader=new Tt}getBarcodeFormat(){return U.UPC_A}decode(t,e){return this.maybeReturnResult(this.ean13Reader.decode(t))}decodeRow(t,e,r){return this.maybeReturnResult(this.ean13Reader.decodeRow(t,e,r))}decodeMiddle(t,e,r){return this.ean13Reader.decodeMiddle(t,e,r)}maybeReturnResult(t){let e=t.getText();if("0"===e.charAt(0)){let r=new x(e.substring(1),null,null,t.getResultPoints(),U.UPC_A);return null!=t.getResultMetadata()&&r.putAllMetadata(t.getResultMetadata()),r}throw new D}reset(){this.ean13Reader.reset()}}class Dt extends _t{constructor(){super(),this.decodeMiddleCounters=new Int32Array(4)}decodeMiddle(t,e,r){const n=this.decodeMiddleCounters.map((t=>t));n[0]=0,n[1]=0,n[2]=0,n[3]=0;const i=t.getSize();let o=e[1],s=0;for(let e=0;e<6&&o<i;e++){const i=Dt.decodeDigit(t,n,o,Dt.L_AND_G_PATTERNS);r+=String.fromCharCode("0".charCodeAt(0)+i%10);for(let t of n)o+=t;i>=10&&(s|=1<<5-e)}return{rowOffset:o,resultString:Dt.determineNumSysAndCheckDigit(r,s)}}decodeEnd(t,e){return Dt.findGuardPatternWithoutCounters(t,e,!0,Dt.MIDDLE_END_PATTERN)}checkChecksum(t){return _t.checkChecksum(Dt.convertUPCEtoUPCA(t))}static determineNumSysAndCheckDigit(t,e){for(let r=0;r<=1;r++)for(let n=0;n<10;n++)if(e===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[r][n])return String.fromCharCode("0".charCodeAt(0)+r)+t+String.fromCharCode("0".charCodeAt(0)+n);throw D.getNotFoundInstance()}getBarcodeFormat(){return U.UPC_E}static convertUPCEtoUPCA(t){const e=t.slice(1,7).split("").map((t=>t.charCodeAt(0))),r=new y;r.append(t.charAt(0));let n=e[5];switch(n){case 0:case 1:case 2:r.appendChars(e,0,2),r.append(n),r.append("0000"),r.appendChars(e,2,3);break;case 3:r.appendChars(e,0,3),r.append("00000"),r.appendChars(e,3,2);break;case 4:r.appendChars(e,0,4),r.append("00000"),r.append(e[4]);break;default:r.appendChars(e,0,5),r.append("0000"),r.append(n)}return t.length>=8&&r.append(t.charAt(7)),r.toString()}}Dt.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Dt.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 Mt extends wt{constructor(t){super();let r=null==t?null:t.get(C.POSSIBLE_FORMATS),n=[];e(r)?(n.push(new Tt),n.push(new Nt),n.push(new yt),n.push(new Dt)):(r.indexOf(U.EAN_13)>-1&&n.push(new Tt),r.indexOf(U.UPC_A)>-1&&n.push(new Nt),r.indexOf(U.EAN_8)>-1&&n.push(new yt),r.indexOf(U.UPC_E)>-1&&n.push(new Dt)),this.readers=n}decodeRow(t,e,r){for(let n of this.readers)try{const i=n.decodeRow(t,e,r),o=i.getBarcodeFormat()===U.EAN_13&&"0"===i.getText().charAt(0),s=null==r?null:r.get(C.POSSIBLE_FORMATS),a=null==s||s.includes(U.UPC_A);if(o&&a){const t=i.getRawBytes(),e=new x(i.getText().substring(1),t,t?t.length:null,i.getResultPoints(),U.UPC_A);return e.putAllMetadata(i.getResultMetadata()),e}return i}catch(t){}throw new D}reset(){for(let t of this.readers)t.reset()}}class Rt extends wt{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(t,e){for(let r=0;r<e.length;r++)if(wt.patternMatchVariance(t,e[r],Rt.MAX_INDIVIDUAL_VARIANCE)<Rt.MAX_AVG_VARIANCE)return r;throw new D}static count(t){return rt.sum(new Int32Array(t))}static increment(t,e){let r=0,n=e[0];for(let i=1;i<t.length;i++)e[i]>n&&(n=e[i],r=i);t[r]++}static decrement(t,e){let r=0,n=e[0];for(let i=1;i<t.length;i++)e[i]<n&&(n=e[i],r=i);t[r]--}static isFinderPattern(t){let e=t[0]+t[1],r=e/(e+t[2]+t[3]);if(r>=Rt.MIN_FINDER_PATTERN_RATIO&&r<=Rt.MAX_FINDER_PATTERN_RATIO){let e=Number.MAX_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(let n of t)n>r&&(r=n),n<e&&(e=n);return r<10*e}return!1}}Rt.MAX_AVG_VARIANCE=.2,Rt.MAX_INDIVIDUAL_VARIANCE=.45,Rt.MIN_FINDER_PATTERN_RATIO=9.5/12,Rt.MAX_FINDER_PATTERN_RATIO=12.5/14;class Ot{constructor(t,e){this.value=t,this.checksumPortion=e}getValue(){return this.value}getChecksumPortion(){return this.checksumPortion}toString(){return this.value+"("+this.checksumPortion+")"}equals(t){if(!(t instanceof Ot))return!1;const e=t;return this.value===e.value&&this.checksumPortion===e.checksumPortion}hashCode(){return this.value^this.checksumPortion}}class bt{constructor(t,e,r,n,i){this.value=t,this.startEnd=e,this.value=t,this.startEnd=e,this.resultPoints=new Array,this.resultPoints.push(new it(r,i)),this.resultPoints.push(new it(n,i))}getValue(){return this.value}getStartEnd(){return this.startEnd}getResultPoints(){return this.resultPoints}equals(t){if(!(t instanceof bt))return!1;const e=t;return this.value===e.value}hashCode(){return this.value}}class Bt{constructor(){}static getRSSvalue(t,e,r){let n=0;for(let e of t)n+=e;let i=0,o=0,s=t.length;for(let a=0;a<s-1;a++){let c;for(c=1,o|=1<<a;c<t[a];c++,o&=~(1<<a)){let t=Bt.combins(n-c-1,s-a-2);if(r&&0===o&&n-c-(s-a-1)>=s-a-1&&(t-=Bt.combins(n-c-(s-a),s-a-2)),s-a-1>1){let r=0;for(let t=n-c-(s-a-2);t>e;t--)r+=Bt.combins(n-c-t-1,s-a-3);t-=r*(s-1-a)}else n-c>e&&t--;i+=t}n-=c}return i}static combins(t,e){let r,n;t-e>e?(n=e,r=t-e):(n=t-e,r=e);let i=1,o=1;for(let e=t;e>r;e--)i*=e,o<=n&&(i/=o,o++);for(;o<=n;)i/=o,o++;return i}}class Lt{static buildBitArray(t){let e=2*t.length-1;null==t[t.length-1].getRightChar()&&(e-=1);let r=new p(12*e),n=0,i=t[0].getRightChar().getValue();for(let t=11;t>=0;--t)0!=(i&1<<t)&&r.set(n),n++;for(let e=1;e<t.length;++e){let i=t[e],o=i.getLeftChar().getValue();for(let t=11;t>=0;--t)0!=(o&1<<t)&&r.set(n),n++;if(null!=i.getRightChar()){let t=i.getRightChar().getValue();for(let e=11;e>=0;--e)0!=(t&1<<e)&&r.set(n),n++}}return r}}class Pt{constructor(t,e){e?this.decodedInformation=null:(this.finished=t,this.decodedInformation=e)}getDecodedInformation(){return this.decodedInformation}isFinished(){return this.finished}}class vt{constructor(t){this.newPosition=t}getNewPosition(){return this.newPosition}}class Ft extends vt{constructor(t,e){super(t),this.value=e}getValue(){return this.value}isFNC1(){return this.value===Ft.FNC1}}Ft.FNC1="$";class xt extends vt{constructor(t,e,r){super(t),r?(this.remaining=!0,this.remainingValue=this.remainingValue):(this.remaining=!1,this.remainingValue=0),this.newString=e}getNewString(){return this.newString}isRemaining(){return this.remaining}getRemainingValue(){return this.remainingValue}}class kt extends vt{constructor(t,e,r){if(super(t),e<0||e>10||r<0||r>10)throw new E;this.firstDigit=e,this.secondDigit=r}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return 10*this.firstDigit+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===kt.FNC1}isSecondDigitFNC1(){return this.secondDigit===kt.FNC1}isAnyFNC1(){return this.firstDigit===kt.FNC1||this.secondDigit===kt.FNC1}}kt.FNC1=10;class Ut{constructor(){}static parseFieldsInGeneralPurpose(t){if(!t)return null;if(t.length<2)throw new D;let e=t.substring(0,2);for(let r of Ut.TWO_DIGIT_DATA_LENGTH)if(r[0]===e)return r[1]===Ut.VARIABLE_LENGTH?Ut.processVariableAI(2,r[2],t):Ut.processFixedAI(2,r[1],t);if(t.length<3)throw new D;let r=t.substring(0,3);for(let e of Ut.THREE_DIGIT_DATA_LENGTH)if(e[0]===r)return e[1]===Ut.VARIABLE_LENGTH?Ut.processVariableAI(3,e[2],t):Ut.processFixedAI(3,e[1],t);for(let e of Ut.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(e[0]===r)return e[1]===Ut.VARIABLE_LENGTH?Ut.processVariableAI(4,e[2],t):Ut.processFixedAI(4,e[1],t);if(t.length<4)throw new D;let n=t.substring(0,4);for(let e of Ut.FOUR_DIGIT_DATA_LENGTH)if(e[0]===n)return e[1]===Ut.VARIABLE_LENGTH?Ut.processVariableAI(4,e[2],t):Ut.processFixedAI(4,e[1],t);throw new D}static processFixedAI(t,e,r){if(r.length<t)throw new D;let n=r.substring(0,t);if(r.length<t+e)throw new D;let i=r.substring(t,t+e),o=r.substring(t+e),s="("+n+")"+i,a=Ut.parseFieldsInGeneralPurpose(o);return null==a?s:s+a}static processVariableAI(t,e,r){let n,i=r.substring(0,t);n=r.length<t+e?r.length:t+e;let o=r.substring(t,n),s=r.substring(n),a="("+i+")"+o,c=Ut.parseFieldsInGeneralPurpose(s);return null==c?a:a+c}}Ut.VARIABLE_LENGTH=[],Ut.TWO_DIGIT_DATA_LENGTH=[["00",18],["01",14],["02",14],["10",Ut.VARIABLE_LENGTH,20],["11",6],["12",6],["13",6],["15",6],["17",6],["20",2],["21",Ut.VARIABLE_LENGTH,20],["22",Ut.VARIABLE_LENGTH,29],["30",Ut.VARIABLE_LENGTH,8],["37",Ut.VARIABLE_LENGTH,8],["90",Ut.VARIABLE_LENGTH,30],["91",Ut.VARIABLE_LENGTH,30],["92",Ut.VARIABLE_LENGTH,30],["93",Ut.VARIABLE_LENGTH,30],["94",Ut.VARIABLE_LENGTH,30],["95",Ut.VARIABLE_LENGTH,30],["96",Ut.VARIABLE_LENGTH,30],["97",Ut.VARIABLE_LENGTH,3],["98",Ut.VARIABLE_LENGTH,30],["99",Ut.VARIABLE_LENGTH,30]],Ut.THREE_DIGIT_DATA_LENGTH=[["240",Ut.VARIABLE_LENGTH,30],["241",Ut.VARIABLE_LENGTH,30],["242",Ut.VARIABLE_LENGTH,6],["250",Ut.VARIABLE_LENGTH,30],["251",Ut.VARIABLE_LENGTH,30],["253",Ut.VARIABLE_LENGTH,17],["254",Ut.VARIABLE_LENGTH,20],["400",Ut.VARIABLE_LENGTH,30],["401",Ut.VARIABLE_LENGTH,30],["402",17],["403",Ut.VARIABLE_LENGTH,30],["410",13],["411",13],["412",13],["413",13],["414",13],["420",Ut.VARIABLE_LENGTH,20],["421",Ut.VARIABLE_LENGTH,15],["422",3],["423",Ut.VARIABLE_LENGTH,15],["424",3],["425",3],["426",3]],Ut.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",Ut.VARIABLE_LENGTH,15],["391",Ut.VARIABLE_LENGTH,18],["392",Ut.VARIABLE_LENGTH,15],["393",Ut.VARIABLE_LENGTH,18],["703",Ut.VARIABLE_LENGTH,30]],Ut.FOUR_DIGIT_DATA_LENGTH=[["7001",13],["7002",Ut.VARIABLE_LENGTH,30],["7003",10],["8001",14],["8002",Ut.VARIABLE_LENGTH,20],["8003",Ut.VARIABLE_LENGTH,30],["8004",Ut.VARIABLE_LENGTH,30],["8005",6],["8006",18],["8007",Ut.VARIABLE_LENGTH,30],["8008",Ut.VARIABLE_LENGTH,12],["8018",18],["8020",Ut.VARIABLE_LENGTH,25],["8100",6],["8101",10],["8102",2],["8110",Ut.VARIABLE_LENGTH,70],["8200",Ut.VARIABLE_LENGTH,70]];class Ht{constructor(t){this.buffer=new y,this.information=t}decodeAllCodes(t,e){let r=e,n=null;for(;;){let e=this.decodeGeneralPurposeField(r,n),i=Ut.parseFieldsInGeneralPurpose(e.getNewString());if(null!=i&&t.append(i),n=e.isRemaining()?""+e.getRemainingValue():null,r===e.getNewPosition())break;r=e.getNewPosition()}return t.toString()}isStillNumeric(t){if(t+7>this.information.getSize())return t+4<=this.information.getSize();for(let e=t;e<t+3;++e)if(this.information.get(e))return!0;return this.information.get(t+3)}decodeNumeric(t){if(t+7>this.information.getSize()){let e=this.extractNumericValueFromBitArray(t,4);return new kt(this.information.getSize(),0===e?kt.FNC1:e-1,kt.FNC1)}let e=this.extractNumericValueFromBitArray(t,7);return new kt(t+7,(e-8)/11,(e-8)%11)}extractNumericValueFromBitArray(t,e){return Ht.extractNumericValueFromBitArray(this.information,t,e)}static extractNumericValueFromBitArray(t,e,r){let n=0;for(let i=0;i<r;++i)t.get(e+i)&&(n|=1<<r-i-1);return n}decodeGeneralPurposeField(t,e){this.buffer.setLengthToZero(),null!=e&&this.buffer.append(e),this.current.setPosition(t);let r=this.parseBlocks();return null!=r&&r.isRemaining()?new xt(this.current.getPosition(),this.buffer.toString(),r.getRemainingValue()):new xt(this.current.getPosition(),this.buffer.toString())}parseBlocks(){let t,e;do{let r=this.current.getPosition();if(this.current.isAlpha()?(e=this.parseAlphaBlock(),t=e.isFinished()):this.current.isIsoIec646()?(e=this.parseIsoIec646Block(),t=e.isFinished()):(e=this.parseNumericBlock(),t=e.isFinished()),r===this.current.getPosition()&&!t)break}while(!t);return e.getDecodedInformation()}parseNumericBlock(){for(;this.isStillNumeric(this.current.getPosition());){let t=this.decodeNumeric(this.current.getPosition());if(this.current.setPosition(t.getNewPosition()),t.isFirstDigitFNC1()){let e;return e=t.isSecondDigitFNC1()?new xt(this.current.getPosition(),this.buffer.toString()):new xt(this.current.getPosition(),this.buffer.toString(),t.getSecondDigit()),new Pt(!0,e)}if(this.buffer.append(t.getFirstDigit()),t.isSecondDigitFNC1()){let t=new xt(this.current.getPosition(),this.buffer.toString());return new Pt(!0,t)}this.buffer.append(t.getSecondDigit())}return this.isNumericToAlphaNumericLatch(this.current.getPosition())&&(this.current.setAlpha(),this.current.incrementPosition(4)),new Pt(!1)}parseIsoIec646Block(){for(;this.isStillIsoIec646(this.current.getPosition());){let t=this.decodeIsoIec646(this.current.getPosition());if(this.current.setPosition(t.getNewPosition()),t.isFNC1()){let t=new xt(this.current.getPosition(),this.buffer.toString());return new Pt(!0,t)}this.buffer.append(t.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 Pt(!1)}parseAlphaBlock(){for(;this.isStillAlpha(this.current.getPosition());){let t=this.decodeAlphanumeric(this.current.getPosition());if(this.current.setPosition(t.getNewPosition()),t.isFNC1()){let t=new xt(this.current.getPosition(),this.buffer.toString());return new Pt(!0,t)}this.buffer.append(t.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 Pt(!1)}isStillIsoIec646(t){if(t+5>this.information.getSize())return!1;let e=this.extractNumericValueFromBitArray(t,5);if(e>=5&&e<16)return!0;if(t+7>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(t,7);if(r>=64&&r<116)return!0;if(t+8>this.information.getSize())return!1;let n=this.extractNumericValueFromBitArray(t,8);return n>=232&&n<253}decodeIsoIec646(t){let e=this.extractNumericValueFromBitArray(t,5);if(15===e)return new Ft(t+5,Ft.FNC1);if(e>=5&&e<15)return new Ft(t+5,"0"+(e-5));let r,n=this.extractNumericValueFromBitArray(t,7);if(n>=64&&n<90)return new Ft(t+7,""+(n+1));if(n>=90&&n<116)return new Ft(t+7,""+(n+7));switch(this.extractNumericValueFromBitArray(t,8)){case 232:r="!";break;case 233:r='"';break;case 234:r="%";break;case 235:r="&";break;case 236:r="'";break;case 237:r="(";break;case 238:r=")";break;case 239:r="*";break;case 240:r="+";break;case 241:r=",";break;case 242:r="-";break;case 243:r=".";break;case 244:r="/";break;case 245:r=":";break;case 246:r=";";break;case 247:r="<";break;case 248:r="=";break;case 249:r=">";break;case 250:r="?";break;case 251:r="_";break;case 252:r=" ";break;default:throw new E}return new Ft(t+8,r)}isStillAlpha(t){if(t+5>this.information.getSize())return!1;let e=this.extractNumericValueFromBitArray(t,5);if(e>=5&&e<16)return!0;if(t+6>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(t,6);return r>=16&&r<63}decodeAlphanumeric(t){let e=this.extractNumericValueFromBitArray(t,5);if(15===e)return new Ft(t+5,Ft.FNC1);if(e>=5&&e<15)return new Ft(t+5,"0"+(e-5));let r,n=this.extractNumericValueFromBitArray(t,6);if(n>=32&&n<58)return new Ft(t+6,""+(n+33));switch(n){case 58:r="*";break;case 59:r=",";break;case 60:r="-";break;case 61:r=".";break;case 62:r="/";break;default:throw new $("Decoding invalid alphanumeric value: "+n)}return new Ft(t+6,r)}isAlphaTo646ToAlphaLatch(t){if(t+1>this.information.getSize())return!1;for(let e=0;e<5&&e+t<this.information.getSize();++e)if(2===e){if(!this.information.get(t+2))return!1}else if(this.information.get(t+e))return!1;return!0}isAlphaOr646ToNumericLatch(t){if(t+3>this.information.getSize())return!1;for(let e=t;e<t+3;++e)if(this.information.get(e))return!1;return!0}isNumericToAlphaNumericLatch(t){if(t+1>this.information.getSize())return!1;for(let e=0;e<4&&e+t<this.information.getSize();++e)if(this.information.get(t+e))return!1;return!0}}class Vt{constructor(t){this.information=t,this.generalDecoder=new Ht(t)}getInformation(){return this.information}getGeneralDecoder(){return this.generalDecoder}}class zt extends Vt{constructor(t){super(t)}encodeCompressedGtin(t,e){t.append("(01)");let r=t.length();t.append("9"),this.encodeCompressedGtinWithoutAI(t,e,r)}encodeCompressedGtinWithoutAI(t,e,r){for(let r=0;r<4;++r){let n=this.getGeneralDecoder().extractNumericValueFromBitArray(e+10*r,10);n/100==0&&t.append("0"),n/10==0&&t.append("0"),t.append(n)}zt.appendCheckDigit(t,r)}static appendCheckDigit(t,e){let r=0;for(let n=0;n<13;n++){let i=t.charAt(n+e).charCodeAt(0)-"0".charCodeAt(0);r+=0==(1&n)?3*i:i}r=10-r%10,10===r&&(r=0),t.append(r)}}zt.GTIN_SIZE=40;class Gt extends zt{constructor(t){super(t)}parseInformation(){let t=new y;t.append("(01)");let e=t.length(),r=this.getGeneralDecoder().extractNumericValueFromBitArray(Gt.HEADER_SIZE,4);return t.append(r),this.encodeCompressedGtinWithoutAI(t,Gt.HEADER_SIZE+4,e),this.getGeneralDecoder().decodeAllCodes(t,Gt.HEADER_SIZE+44)}}Gt.HEADER_SIZE=4;class Yt extends Vt{constructor(t){super(t)}parseInformation(){let t=new y;return this.getGeneralDecoder().decodeAllCodes(t,Yt.HEADER_SIZE)}}Yt.HEADER_SIZE=5;class Xt extends zt{constructor(t){super(t)}encodeCompressedWeight(t,e,r){let n=this.getGeneralDecoder().extractNumericValueFromBitArray(e,r);this.addWeightCode(t,n);let i=this.checkWeight(n),o=1e5;for(let e=0;e<5;++e)i/o==0&&t.append("0"),o/=10;t.append(i)}}class Wt extends Xt{constructor(t){super(t)}parseInformation(){if(this.getInformation().getSize()!=Wt.HEADER_SIZE+Xt.GTIN_SIZE+Wt.WEIGHT_SIZE)throw new D;let t=new y;return this.encodeCompressedGtin(t,Wt.HEADER_SIZE),this.encodeCompressedWeight(t,Wt.HEADER_SIZE+Xt.GTIN_SIZE,Wt.WEIGHT_SIZE),t.toString()}}Wt.HEADER_SIZE=5,Wt.WEIGHT_SIZE=15;class jt extends Wt{constructor(t){super(t)}addWeightCode(t,e){t.append("(3103)")}checkWeight(t){return t}}class Zt extends Wt{constructor(t){super(t)}addWeightCode(t,e){e<1e4?t.append("(3202)"):t.append("(3203)")}checkWeight(t){return t<1e4?t:t-1e4}}class Qt extends zt{constructor(t){super(t)}parseInformation(){if(this.getInformation().getSize()<Qt.HEADER_SIZE+zt.GTIN_SIZE)throw new D;let t=new y;this.encodeCompressedGtin(t,Qt.HEADER_SIZE);let e=this.getGeneralDecoder().extractNumericValueFromBitArray(Qt.HEADER_SIZE+zt.GTIN_SIZE,Qt.LAST_DIGIT_SIZE);t.append("(392"),t.append(e),t.append(")");let r=this.getGeneralDecoder().decodeGeneralPurposeField(Qt.HEADER_SIZE+zt.GTIN_SIZE+Qt.LAST_DIGIT_SIZE,null);return t.append(r.getNewString()),t.toString()}}Qt.HEADER_SIZE=8,Qt.LAST_DIGIT_SIZE=2;class Kt extends zt{constructor(t){super(t)}parseInformation(){if(this.getInformation().getSize()<Kt.HEADER_SIZE+zt.GTIN_SIZE)throw new D;let t=new y;this.encodeCompressedGtin(t,Kt.HEADER_SIZE);let e=this.getGeneralDecoder().extractNumericValueFromBitArray(Kt.HEADER_SIZE+zt.GTIN_SIZE,Kt.LAST_DIGIT_SIZE);t.append("(393"),t.append(e),t.append(")");let r=this.getGeneralDecoder().extractNumericValueFromBitArray(Kt.HEADER_SIZE+zt.GTIN_SIZE+Kt.LAST_DIGIT_SIZE,Kt.FIRST_THREE_DIGITS_SIZE);r/100==0&&t.append("0"),r/10==0&&t.append("0"),t.append(r);let n=this.getGeneralDecoder().decodeGeneralPurposeField(Kt.HEADER_SIZE+zt.GTIN_SIZE+Kt.LAST_DIGIT_SIZE+Kt.FIRST_THREE_DIGITS_SIZE,null);return t.append(n.getNewString()),t.toString()}}Kt.HEADER_SIZE=8,Kt.LAST_DIGIT_SIZE=2,Kt.FIRST_THREE_DIGITS_SIZE=10;class qt extends Xt{constructor(t,e,r){super(t),this.dateCode=r,this.firstAIdigits=e}parseInformation(){if(this.getInformation().getSize()!=qt.HEADER_SIZE+qt.GTIN_SIZE+qt.WEIGHT_SIZE+qt.DATE_SIZE)throw new D;let t=new y;return this.encodeCompressedGtin(t,qt.HEADER_SIZE),this.encodeCompressedWeight(t,qt.HEADER_SIZE+qt.GTIN_SIZE,qt.WEIGHT_SIZE),this.encodeCompressedDate(t,qt.HEADER_SIZE+qt.GTIN_SIZE+qt.WEIGHT_SIZE),t.toString()}encodeCompressedDate(t,e){let r=this.getGeneralDecoder().extractNumericValueFromBitArray(e,qt.DATE_SIZE);if(38400==r)return;t.append("("),t.append(this.dateCode),t.append(")");let n=r%32;r/=32;let i=r%12+1;r/=12;let o=r;o/10==0&&t.append("0"),t.append(o),i/10==0&&t.append("0"),t.append(i),n/10==0&&t.append("0"),t.append(n)}addWeightCode(t,e){t.append("("),t.append(this.firstAIdigits),t.append(e/1e5),t.append(")")}checkWeight(t){return t%1e5}}function Jt(t){try{if(t.get(1))return new Gt(t);if(!t.get(2))return new Yt(t);switch(Ht.extractNumericValueFromBitArray(t,1,4)){case 4:return new jt(t);case 5:return new Zt(t)}switch(Ht.extractNumericValueFromBitArray(t,1,5)){case 12:return new Qt(t);case 13:return new Kt(t)}switch(Ht.extractNumericValueFromBitArray(t,1,7)){case 56:return new qt(t,"310","11");case 57:return new qt(t,"320","11");case 58:return new qt(t,"310","13");case 59:return new qt(t,"320","13");case 60:return new qt(t,"310","15");case 61:return new qt(t,"320","15");case 62:return new qt(t,"310","17");case 63:return new qt(t,"320","17")}}catch(e){throw console.log(e),new $("unknown decoder: "+t)}}qt.HEADER_SIZE=8,qt.WEIGHT_SIZE=20,qt.DATE_SIZE=16;class $t{constructor(t,e,r,n){this.leftchar=t,this.rightchar=e,this.finderpattern=r,this.maybeLast=n}mayBeLast(){return this.maybeLast}getLeftChar(){return this.leftchar}getRightChar(){return this.rightchar}getFinderPattern(){return this.finderpattern}mustBeLast(){return null==this.rightchar}toString(){return"[ "+this.leftchar+", "+this.rightchar+" : "+(null==this.finderpattern?"null":this.finderpattern.getValue())+" ]"}static equals(t,e){return t instanceof $t&&$t.equalsOrNull(t.leftchar,e.leftchar)&&$t.equalsOrNull(t.rightchar,e.rightchar)&&$t.equalsOrNull(t.finderpattern,e.finderpattern)}static equalsOrNull(t,e){return null===t?null===e:$t.equals(t,e)}hashCode(){return this.leftchar.getValue()^this.rightchar.getValue()^this.finderpattern.getValue()}}class te{constructor(t,e,r){this.pairs=t,this.rowNumber=e,this.wasReversed=r}getPairs(){return this.pairs}getRowNumber(){return this.rowNumber}isReversed(){return this.wasReversed}isEquivalent(t){return this.checkEqualitity(this,t)}toString(){return"{ "+this.pairs+" }"}equals(t,e){return t instanceof te&&this.checkEqualitity(t,e)&&t.wasReversed===e.wasReversed}checkEqualitity(t,e){if(!t||!e)return;let r;return t.forEach(((t,n)=>{e.forEach((e=>{t.getLeftChar().getValue()===e.getLeftChar().getValue()&&t.getRightChar().getValue()===e.getRightChar().getValue()&&t.getFinderPatter().getValue()===e.getFinderPatter().getValue()&&(r=!0)}))})),r}}class ee extends Rt{constructor(t){super(...arguments),this.pairs=new Array(ee.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=!0===t}decodeRow(t,e,r){this.pairs.length=0,this.startFromEven=!1;try{return ee.constructResult(this.decodeRow2pairs(t,e))}catch(t){this.verbose&&console.log(t)}return this.pairs.length=0,this.startFromEven=!0,ee.constructResult(this.decodeRow2pairs(t,e))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(t,e){let r,n=!1;for(;!n;)try{this.pairs.push(this.retrieveNextPair(e,this.pairs,t))}catch(t){if(t instanceof D){if(!this.pairs.length)throw new D;n=!0}}if(this.checkChecksum())return this.pairs;if(r=!!this.rows.length,this.storeRow(t,!1),r){let t=this.checkRowsBoolean(!1);if(null!=t)return t;if(t=this.checkRowsBoolean(!0),null!=t)return t}throw new D}checkRowsBoolean(t){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,t&&(this.rows=this.rows.reverse());let e=null;try{e=this.checkRows(new Array,0)}catch(t){this.verbose&&console.log(t)}return t&&(this.rows=this.rows.reverse()),e}checkRows(t,e){for(let r=e;r<this.rows.length;r++){let e=this.rows[r];this.pairs.length=0;for(let e of t)this.pairs.push(e.getPairs());if(this.pairs.push(e.getPairs()),!ee.isValidSequence(this.pairs))continue;if(this.checkChecksum())return this.pairs;let n=new Array(t);n.push(e);try{return this.checkRows(n,r+1)}catch(t){this.verbose&&console.log(t)}}throw new D}static isValidSequence(t){for(let e of ee.FINDER_PATTERN_SEQUENCES){if(t.length>e.length)continue;let r=!0;for(let n=0;n<t.length;n++)if(t[n].getFinderPattern().getValue()!=e[n]){r=!1;break}if(r)return!0}return!1}storeRow(t,e){let r=0,n=!1,i=!1;for(;r<this.rows.length;){let e=this.rows[r];if(e.getRowNumber()>t){i=e.isEquivalent(this.pairs);break}n=e.isEquivalent(this.pairs),r++}i||n||ee.isPartialRow(this.pairs,this.rows)||(this.rows.push(r,new te(this.pairs,t,e)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(t,e){for(let r of e)if(r.getPairs().length!==t.length)for(let e of r.getPairs())for(let r of t)if($t.equals(e,r))break}static isPartialRow(t,e){for(let r of e){let e=!0;for(let n of t){let t=!1;for(let e of r.getPairs())if(n.equals(e)){t=!0;break}if(!t){e=!1;break}}if(e)return!0}return!1}getRows(){return this.rows}static constructResult(t){let e=Jt(Lt.buildBitArray(t)).parseInformation(),r=t[0].getFinderPattern().getResultPoints(),n=t[t.length-1].getFinderPattern().getResultPoints(),i=[r[0],r[1],n[0],n[1]];return new x(e,null,null,i,U.RSS_EXPANDED,null)}checkChecksum(){let t=this.pairs.get(0),e=t.getLeftChar(),r=t.getRightChar();if(null==r)return!1;let n=r.getChecksumPortion(),i=2;for(let t=1;t<this.pairs.size();++t){let e=this.pairs.get(t);n+=e.getLeftChar().getChecksumPortion(),i++;let r=e.getRightChar();null!=r&&(n+=r.getChecksumPortion(),i++)}return n%=211,211*(i-4)+n==e.getValue()}static getNextSecondBar(t,e){let r;return t.get(e)?(r=t.getNextUnset(e),r=t.getNextSet(r)):(r=t.getNextSet(e),r=t.getNextUnset(r)),r}retrieveNextPair(t,e,r){let n,i=e.length%2==0;this.startFromEven&&(i=!i);let o=!0,s=-1;do{this.findNextPair(t,e,s),n=this.parseFoundFinderPattern(t,r,i),null==n?s=ee.getNextSecondBar(t,this.startEnd[0]):o=!1}while(o);let a,c=this.decodeDataCharacter(t,n,i,!0);if(!this.isEmptyPair(e)&&e[e.length-1].mustBeLast())throw new D;try{a=this.decodeDataCharacter(t,n,i,!1)}catch(t){a=null,this.verbose&&console.log(t)}return new $t(c,a,n,!0)}isEmptyPair(t){return 0===t.length}findNextPair(t,e,r){let n=this.getDecodeFinderCounters();n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i,o=t.getSize();i=r>=0?r:this.isEmptyPair(e)?0:e[e.length-1].getFinderPattern().getStartEnd()[1];let s=e.length%2!=0;this.startFromEven&&(s=!s);let a=!1;for(;i<o&&(a=!t.get(i),a);)i++;let c=0,l=i;for(let e=i;e<o;e++)if(t.get(e)!=a)n[c]++;else{if(3==c){if(s&&ee.reverseCounters(n),ee.isFinderPattern(n))return this.startEnd[0]=l,void(this.startEnd[1]=e);s&&ee.reverseCounters(n),l+=n[0]+n[1],n[0]=n[2],n[1]=n[3],n[2]=0,n[3]=0,c--}else c++;n[c]=1,a=!a}throw new D}static reverseCounters(t){let e=t.length;for(let r=0;r<e/2;++r){let n=t[r];t[r]=t[e-r-1],t[e-r-1]=n}}parseFoundFinderPattern(t,e,r){let n,i,o;if(r){let e=this.startEnd[0]-1;for(;e>=0&&!t.get(e);)e--;e++,n=this.startEnd[0]-e,i=e,o=this.startEnd[1]}else i=this.startEnd[0],o=t.getNextUnset(this.startEnd[1]+1),n=o-this.startEnd[1];let s,a=this.getDecodeFinderCounters();d.arraycopy(a,0,a,1,a.length-1),a[0]=n;try{s=this.parseFinderValue(a,ee.FINDER_PATTERNS)}catch(t){return null}return new bt(s,[i,o],i,o,e)}decodeDataCharacter(t,e,r,n){let i=this.getDataCharacterCounters();for(let t=0;t<i.length;t++)i[t]=0;if(n)ee.recordPatternInReverse(t,e.getStartEnd()[0],i);else{ee.recordPattern(t,e.getStartEnd()[1],i);for(let t=0,e=i.length-1;t<e;t++,e--){let r=i[t];i[t]=i[e],i[e]=r}}let o=rt.sum(new Int32Array(i))/17,s=(e.getStartEnd()[1]-e.getStartEnd()[0])/15;if(Math.abs(o-s)/s>.3)throw new D;let a=this.getOddCounts(),c=this.getEvenCounts(),l=this.getOddRoundingErrors(),h=this.getEvenRoundingErrors();for(let t=0;t<i.length;t++){let e=1*i[t]/o,r=e+.5;if(r<1){if(e<.3)throw new D;r=1}else if(r>8){if(e>8.7)throw new D;r=8}let n=t/2;0==(1&t)?(a[n]=r,l[n]=e-r):(c[n]=r,h[n]=e-r)}this.adjustOddEvenCounts(17);let u=4*e.getValue()+(r?0:2)+(n?0:1)-1,d=0,f=0;for(let t=a.length-1;t>=0;t--){if(ee.isNotA1left(e,r,n)){let e=ee.WEIGHTS[u][2*t];f+=a[t]*e}d+=a[t]}let g=0;for(let t=c.length-1;t>=0;t--)if(ee.isNotA1left(e,r,n)){let e=ee.WEIGHTS[u][2*t+1];g+=c[t]*e}let w=f+g;if(0!=(1&d)||d>13||d<4)throw new D;let m=(13-d)/2,p=ee.SYMBOL_WIDEST[m],A=9-p,C=Bt.getRSSvalue(a,p,!0),E=Bt.getRSSvalue(c,A,!1),I=ee.EVEN_TOTAL_SUBSET[m],S=ee.GSUM[m];return new Ot(C*I+E+S,w)}static isNotA1left(t,e,r){return!(0==t.getValue()&&e&&r)}adjustOddEvenCounts(t){let e=rt.sum(new Int32Array(this.getOddCounts())),r=rt.sum(new Int32Array(this.getEvenCounts())),n=!1,i=!1;e>13?i=!0:e<4&&(n=!0);let o=!1,s=!1;r>13?s=!0:r<4&&(o=!0);let a=e+r-t,c=1==(1&e),l=0==(1&r);if(1==a)if(c){if(l)throw new D;i=!0}else{if(!l)throw new D;s=!0}else if(-1==a)if(c){if(l)throw new D;n=!0}else{if(!l)throw new D;o=!0}else{if(0!=a)throw new D;if(c){if(!l)throw new D;e<r?(n=!0,s=!0):(i=!0,o=!0)}else if(l)throw new D}if(n){if(i)throw new D;ee.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(i&&ee.decrement(this.getOddCounts(),this.getOddRoundingErrors()),o){if(s)throw new D;ee.increment(this.getEvenCounts(),this.getOddRoundingErrors())}s&&ee.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}ee.SYMBOL_WIDEST=[7,5,4,3,1],ee.EVEN_TOTAL_SUBSET=[4,20,52,104,204],ee.GSUM=[0,348,1388,2948,3988],ee.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])],ee.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]],ee.FINDER_PAT_A=0,ee.FINDER_PAT_B=1,ee.FINDER_PAT_C=2,ee.FINDER_PAT_D=3,ee.FINDER_PAT_E=4,ee.FINDER_PAT_F=5,ee.FINDER_PATTERN_SEQUENCES=[[ee.FINDER_PAT_A,ee.FINDER_PAT_A],[ee.FINDER_PAT_A,ee.FINDER_PAT_B,ee.FINDER_PAT_B],[ee.FINDER_PAT_A,ee.FINDER_PAT_C,ee.FINDER_PAT_B,ee.FINDER_PAT_D],[ee.FINDER_PAT_A,ee.FINDER_PAT_E,ee.FINDER_PAT_B,ee.FINDER_PAT_D,ee.FINDER_PAT_C],[ee.FINDER_PAT_A,ee.FINDER_PAT_E,ee.FINDER_PAT_B,ee.FINDER_PAT_D,ee.FINDER_PAT_D,ee.FINDER_PAT_F],[ee.FINDER_PAT_A,ee.FINDER_PAT_E,ee.FINDER_PAT_B,ee.FINDER_PAT_D,ee.FINDER_PAT_E,ee.FINDER_PAT_F,ee.FINDER_PAT_F],[ee.FINDER_PAT_A,ee.FINDER_PAT_A,ee.FINDER_PAT_B,ee.FINDER_PAT_B,ee.FINDER_PAT_C,ee.FINDER_PAT_C,ee.FINDER_PAT_D,ee.FINDER_PAT_D],[ee.FINDER_PAT_A,ee.FINDER_PAT_A,ee.FINDER_PAT_B,ee.FINDER_PAT_B,ee.FINDER_PAT_C,ee.FINDER_PAT_C,ee.FINDER_PAT_D,ee.FINDER_PAT_E,ee.FINDER_PAT_E],[ee.FINDER_PAT_A,ee.FINDER_PAT_A,ee.FINDER_PAT_B,ee.FINDER_PAT_B,ee.FINDER_PAT_C,ee.FINDER_PAT_C,ee.FINDER_PAT_D,ee.FINDER_PAT_E,ee.FINDER_PAT_F,ee.FINDER_PAT_F],[ee.FINDER_PAT_A,ee.FINDER_PAT_A,ee.FINDER_PAT_B,ee.FINDER_PAT_B,ee.FINDER_PAT_C,ee.FINDER_PAT_D,ee.FINDER_PAT_D,ee.FINDER_PAT_E,ee.FINDER_PAT_E,ee.FINDER_PAT_F,ee.FINDER_PAT_F]],ee.MAX_PAIRS=11;class re extends Ot{constructor(t,e,r){super(t,e),this.count=0,this.finderPattern=r}getFinderPattern(){return this.finderPattern}getCount(){return this.count}incrementCount(){this.count++}}class ne extends Rt{constructor(){super(...arguments),this.possibleLeftPairs=[],this.possibleRightPairs=[]}decodeRow(t,e,r){const n=this.decodePair(e,!1,t,r);ne.addOrTally(this.possibleLeftPairs,n),e.reverse();let i=this.decodePair(e,!0,t,r);ne.addOrTally(this.possibleRightPairs,i),e.reverse();for(let t of this.possibleLeftPairs)if(t.getCount()>1)for(let e of this.possibleRightPairs)if(e.getCount()>1&&ne.checkChecksum(t,e))return ne.constructResult(t,e);throw new D}static addOrTally(t,e){if(null==e)return;let r=!1;for(let n of t)if(n.getValue()===e.getValue()){n.incrementCount(),r=!0;break}r||t.push(e)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(t,e){let r=4537077*t.getValue()+e.getValue(),n=new String(r).toString(),i=new y;for(let t=13-n.length;t>0;t--)i.append("0");i.append(n);let o=0;for(let t=0;t<13;t++){let e=i.charAt(t).charCodeAt(0)-"0".charCodeAt(0);o+=0==(1&t)?3*e:e}o=10-o%10,10===o&&(o=0),i.append(o.toString());let s=t.getFinderPattern().getResultPoints(),a=e.getFinderPattern().getResultPoints();return new x(i.toString(),null,0,[s[0],s[1],a[0],a[1]],U.RSS_14,(new Date).getTime())}static checkChecksum(t,e){let r=(t.getChecksumPortion()+16*e.getChecksumPortion())%79,n=9*t.getFinderPattern().getValue()+e.getFinderPattern().getValue();return n>72&&n--,n>8&&n--,r===n}decodePair(t,e,r,n){try{let i=this.findFinderPattern(t,e),o=this.parseFoundFinderPattern(t,r,e,i),s=null==n?null:n.get(C.NEED_RESULT_POINT_CALLBACK);if(null!=s){let n=(i[0]+i[1])/2;e&&(n=t.getSize()-1-n),s.foundPossibleResultPoint(new it(n,r))}let a=this.decodeDataCharacter(t,o,!0),c=this.decodeDataCharacter(t,o,!1);return new re(1597*a.getValue()+c.getValue(),a.getChecksumPortion()+4*c.getChecksumPortion(),o)}catch(t){return null}}decodeDataCharacter(t,e,r){let n=this.getDataCharacterCounters();for(let t=0;t<n.length;t++)n[t]=0;if(r)wt.recordPatternInReverse(t,e.getStartEnd()[0],n);else{wt.recordPattern(t,e.getStartEnd()[1]+1,n);for(let t=0,e=n.length-1;t<e;t++,e--){let r=n[t];n[t]=n[e],n[e]=r}}let i=r?16:15,o=rt.sum(new Int32Array(n))/i,s=this.getOddCounts(),a=this.getEvenCounts(),c=this.getOddRoundingErrors(),l=this.getEvenRoundingErrors();for(let t=0;t<n.length;t++){let e=n[t]/o,r=Math.floor(e+.5);r<1?r=1:r>8&&(r=8);let i=Math.floor(t/2);0==(1&t)?(s[i]=r,c[i]=e-r):(a[i]=r,l[i]=e-r)}this.adjustOddEvenCounts(r,i);let h=0,u=0;for(let t=s.length-1;t>=0;t--)u*=9,u+=s[t],h+=s[t];let d=0,f=0;for(let t=a.length-1;t>=0;t--)d*=9,d+=a[t],f+=a[t];let g=u+3*d;if(r){if(0!=(1&h)||h>12||h<4)throw new D;let t=(12-h)/2,e=ne.OUTSIDE_ODD_WIDEST[t],r=9-e,n=Bt.getRSSvalue(s,e,!1),i=Bt.getRSSvalue(a,r,!0),o=ne.OUTSIDE_EVEN_TOTAL_SUBSET[t],c=ne.OUTSIDE_GSUM[t];return new Ot(n*o+i+c,g)}{if(0!=(1&f)||f>10||f<4)throw new D;let t=(10-f)/2,e=ne.INSIDE_ODD_WIDEST[t],r=9-e,n=Bt.getRSSvalue(s,e,!0),i=Bt.getRSSvalue(a,r,!1),o=ne.INSIDE_ODD_TOTAL_SUBSET[t],c=ne.INSIDE_GSUM[t];return new Ot(i*o+n+c,g)}}findFinderPattern(t,e){let r=this.getDecodeFinderCounters();r[0]=0,r[1]=0,r[2]=0,r[3]=0;let n=t.getSize(),i=!1,o=0;for(;o<n&&(i=!t.get(o),e!==i);)o++;let s=0,a=o;for(let e=o;e<n;e++)if(t.get(e)!==i)r[s]++;else{if(3===s){if(Rt.isFinderPattern(r))return[a,e];a+=r[0]+r[1],r[0]=r[2],r[1]=r[3],r[2]=0,r[3]=0,s--}else s++;r[s]=1,i=!i}throw new D}parseFoundFinderPattern(t,e,r,n){let i=t.get(n[0]),o=n[0]-1;for(;o>=0&&i!==t.get(o);)o--;o++;const s=n[0]-o,a=this.getDecodeFinderCounters(),c=new Int32Array(a.length);d.arraycopy(a,0,c,1,a.length-1),c[0]=s;const l=this.parseFinderValue(c,ne.FINDER_PATTERNS);let h=o,u=n[1];return r&&(h=t.getSize()-1-h,u=t.getSize()-1-u),new bt(l,[o,n[1]],h,u,e)}adjustOddEvenCounts(t,e){let r=rt.sum(new Int32Array(this.getOddCounts())),n=rt.sum(new Int32Array(this.getEvenCounts())),i=!1,o=!1,s=!1,a=!1;t?(r>12?o=!0:r<4&&(i=!0),n>12?a=!0:n<4&&(s=!0)):(r>11?o=!0:r<5&&(i=!0),n>10?a=!0:n<4&&(s=!0));let c=r+n-e,l=(1&r)==(t?1:0),h=1==(1&n);if(1===c)if(l){if(h)throw new D;o=!0}else{if(!h)throw new D;a=!0}else if(-1===c)if(l){if(h)throw new D;i=!0}else{if(!h)throw new D;s=!0}else{if(0!==c)throw new D;if(l){if(!h)throw new D;r<n?(i=!0,a=!0):(o=!0,s=!0)}else if(h)throw new D}if(i){if(o)throw new D;Rt.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(o&&Rt.decrement(this.getOddCounts(),this.getOddRoundingErrors()),s){if(a)throw new D;Rt.increment(this.getEvenCounts(),this.getOddRoundingErrors())}a&&Rt.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}ne.OUTSIDE_EVEN_TOTAL_SUBSET=[1,10,34,70,126],ne.INSIDE_ODD_TOTAL_SUBSET=[4,20,48,81],ne.OUTSIDE_GSUM=[0,161,961,2015,2715],ne.INSIDE_GSUM=[0,336,1036,1516],ne.OUTSIDE_ODD_WIDEST=[8,6,4,3,1],ne.INSIDE_ODD_WIDEST=[2,4,6,8],ne.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 ie extends wt{constructor(t,e){super(),this.readers=[],this.verbose=!0===e;const r=t?t.get(C.POSSIBLE_FORMATS):null,n=t&&void 0!==t.get(C.ASSUME_CODE_39_CHECK_DIGIT);r?((r.includes(U.EAN_13)||r.includes(U.UPC_A)||r.includes(U.EAN_8)||r.includes(U.UPC_E))&&this.readers.push(new Mt(t)),r.includes(U.CODE_39)&&this.readers.push(new pt(n)),r.includes(U.CODE_128)&&this.readers.push(new mt),r.includes(U.ITF)&&this.readers.push(new At),r.includes(U.RSS_14)&&this.readers.push(new ne),r.includes(U.RSS_EXPANDED)&&this.readers.push(new ee(this.verbose))):(this.readers.push(new Mt(t)),this.readers.push(new pt),this.readers.push(new Mt(t)),this.readers.push(new mt),this.readers.push(new At),this.readers.push(new ne),this.readers.push(new ee(this.verbose)))}decodeRow(t,e,r){for(let n=0;n<this.readers.length;n++)try{return this.readers[n].decodeRow(t,e,r)}catch(t){}throw new D}reset(){this.readers.forEach((t=>t.reset()))}}class oe{constructor(t,e,r){this.ecCodewords=t,this.ecBlocks=[e],r&&this.ecBlocks.push(r)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class se{constructor(t,e){this.count=t,this.dataCodewords=e}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class ae{constructor(t,e,r,n,i,o){this.versionNumber=t,this.symbolSizeRows=e,this.symbolSizeColumns=r,this.dataRegionSizeRows=n,this.dataRegionSizeColumns=i,this.ecBlocks=o;let s=0;const a=o.getECCodewords(),c=o.getECBlocks();for(let t of c)s+=t.getCount()*(t.getDataCodewords()+a);this.totalCodewords=s}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(t,e){if(0!=(1&t)||0!=(1&e))throw new E;for(let r of ae.VERSIONS)if(r.symbolSizeRows===t&&r.symbolSizeColumns===e)return r;throw new E}toString(){return""+this.versionNumber}static buildVersions(){return[new ae(1,10,10,8,8,new oe(5,new se(1,3))),new ae(2,12,12,10,10,new oe(7,new se(1,5))),new ae(3,14,14,12,12,new oe(10,new se(1,8))),new ae(4,16,16,14,14,new oe(12,new se(1,12))),new ae(5,18,18,16,16,new oe(14,new se(1,18))),new ae(6,20,20,18,18,new oe(18,new se(1,22))),new ae(7,22,22,20,20,new oe(20,new se(1,30))),new ae(8,24,24,22,22,new oe(24,new se(1,36))),new ae(9,26,26,24,24,new oe(28,new se(1,44))),new ae(10,32,32,14,14,new oe(36,new se(1,62))),new ae(11,36,36,16,16,new oe(42,new se(1,86))),new ae(12,40,40,18,18,new oe(48,new se(1,114))),new ae(13,44,44,20,20,new oe(56,new se(1,144))),new ae(14,48,48,22,22,new oe(68,new se(1,174))),new ae(15,52,52,24,24,new oe(42,new se(2,102))),new ae(16,64,64,14,14,new oe(56,new se(2,140))),new ae(17,72,72,16,16,new oe(36,new se(4,92))),new ae(18,80,80,18,18,new oe(48,new se(4,114))),new ae(19,88,88,20,20,new oe(56,new se(4,144))),new ae(20,96,96,22,22,new oe(68,new se(4,174))),new ae(21,104,104,24,24,new oe(56,new se(6,136))),new ae(22,120,120,18,18,new oe(68,new se(6,175))),new ae(23,132,132,20,20,new oe(62,new se(8,163))),new ae(24,144,144,22,22,new oe(62,new se(8,156),new se(2,155))),new ae(25,8,18,6,16,new oe(7,new se(1,5))),new ae(26,8,32,6,14,new oe(11,new se(1,10))),new ae(27,12,26,10,24,new oe(14,new se(1,16))),new ae(28,12,36,10,16,new oe(18,new se(1,22))),new ae(29,16,36,14,16,new oe(24,new se(1,32))),new ae(30,16,48,14,22,new oe(28,new se(1,49)))]}}ae.VERSIONS=ae.buildVersions();class ce{constructor(t){const e=t.getHeight();if(e<8||e>144||0!=(1&e))throw new E;this.version=ce.readVersion(t),this.mappingBitMatrix=this.extractDataRegion(t),this.readMappingMatrix=new N(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(t){const e=t.getHeight(),r=t.getWidth();return ae.getVersionForDimensions(e,r)}readCodewords(){const t=new Int8Array(this.version.getTotalCodewords());let e=0,r=4,n=0;const i=this.mappingBitMatrix.getHeight(),o=this.mappingBitMatrix.getWidth();let s=!1,a=!1,c=!1,l=!1;do{if(r!==i||0!==n||s)if(r!==i-2||0!==n||0==(3&o)||a)if(r!==i+4||2!==n||0!=(7&o)||c)if(r!==i-2||0!==n||4!=(7&o)||l){do{r<i&&n>=0&&!this.readMappingMatrix.get(n,r)&&(t[e++]=255&this.readUtah(r,n,i,o)),r-=2,n+=2}while(r>=0&&n<o);r+=1,n+=3;do{r>=0&&n<o&&!this.readMappingMatrix.get(n,r)&&(t[e++]=255&this.readUtah(r,n,i,o)),r+=2,n-=2}while(r<i&&n>=0);r+=3,n+=1}else t[e++]=255&this.readCorner4(i,o),r-=2,n+=2,l=!0;else t[e++]=255&this.readCorner3(i,o),r-=2,n+=2,c=!0;else t[e++]=255&this.readCorner2(i,o),r-=2,n+=2,a=!0;else t[e++]=255&this.readCorner1(i,o),r-=2,n+=2,s=!0}while(r<i||n<o);if(e!==this.version.getTotalCodewords())throw new E;return t}readModule(t,e,r,n){return t<0&&(t+=r,e+=4-(r+4&7)),e<0&&(e+=n,t+=4-(n+4&7)),this.readMappingMatrix.set(e,t),this.mappingBitMatrix.get(e,t)}readUtah(t,e,r,n){let i=0;return this.readModule(t-2,e-2,r,n)&&(i|=1),i<<=1,this.readModule(t-2,e-1,r,n)&&(i|=1),i<<=1,this.readModule(t-1,e-2,r,n)&&(i|=1),i<<=1,this.readModule(t-1,e-1,r,n)&&(i|=1),i<<=1,this.readModule(t-1,e,r,n)&&(i|=1),i<<=1,this.readModule(t,e-2,r,n)&&(i|=1),i<<=1,this.readModule(t,e-1,r,n)&&(i|=1),i<<=1,this.readModule(t,e,r,n)&&(i|=1),i}readCorner1(t,e){let r=0;return this.readModule(t-1,0,t,e)&&(r|=1),r<<=1,this.readModule(t-1,1,t,e)&&(r|=1),r<<=1,this.readModule(t-1,2,t,e)&&(r|=1),r<<=1,this.readModule(0,e-2,t,e)&&(r|=1),r<<=1,this.readModule(0,e-1,t,e)&&(r|=1),r<<=1,this.readModule(1,e-1,t,e)&&(r|=1),r<<=1,this.readModule(2,e-1,t,e)&&(r|=1),r<<=1,this.readModule(3,e-1,t,e)&&(r|=1),r}readCorner2(t,e){let r=0;return this.readModule(t-3,0,t,e)&&(r|=1),r<<=1,this.readModule(t-2,0,t,e)&&(r|=1),r<<=1,this.readModule(t-1,0,t,e)&&(r|=1),r<<=1,this.readModule(0,e-4,t,e)&&(r|=1),r<<=1,this.readModule(0,e-3,t,e)&&(r|=1),r<<=1,this.readModule(0,e-2,t,e)&&(r|=1),r<<=1,this.readModule(0,e-1,t,e)&&(r|=1),r<<=1,this.readModule(1,e-1,t,e)&&(r|=1),r}readCorner3(t,e){let r=0;return this.readModule(t-1,0,t,e)&&(r|=1),r<<=1,this.readModule(t-1,e-1,t,e)&&(r|=1),r<<=1,this.readModule(0,e-3,t,e)&&(r|=1),r<<=1,this.readModule(0,e-2,t,e)&&(r|=1),r<<=1,this.readModule(0,e-1,t,e)&&(r|=1),r<<=1,this.readModule(1,e-3,t,e)&&(r|=1),r<<=1,this.readModule(1,e-2,t,e)&&(r|=1),r<<=1,this.readModule(1,e-1,t,e)&&(r|=1),r}readCorner4(t,e){let r=0;return this.readModule(t-3,0,t,e)&&(r|=1),r<<=1,this.readModule(t-2,0,t,e)&&(r|=1),r<<=1,this.readModule(t-1,0,t,e)&&(r|=1),r<<=1,this.readModule(0,e-2,t,e)&&(r|=1),r<<=1,this.readModule(0,e-1,t,e)&&(r|=1),r<<=1,this.readModule(1,e-1,t,e)&&(r|=1),r<<=1,this.readModule(2,e-1,t,e)&&(r|=1),r<<=1,this.readModule(3,e-1,t,e)&&(r|=1),r}extractDataRegion(t){const e=this.version.getSymbolSizeRows(),r=this.version.getSymbolSizeColumns();if(t.getHeight()!==e)throw new c("Dimension of bitMatrix must match the version size");const n=this.version.getDataRegionSizeRows(),i=this.version.getDataRegionSizeColumns(),o=e/n|0,s=r/i|0,a=new N(s*i,o*n);for(let e=0;e<o;++e){const r=e*n;for(let o=0;o<s;++o){const s=o*i;for(let c=0;c<n;++c){const l=e*(n+2)+1+c,h=r+c;for(let e=0;e<i;++e){const r=o*(i+2)+1+e;if(t.get(r,l)){const t=s+e;a.set(t,h)}}}}}return a}}class le{constructor(t,e){this.numDataCodewords=t,this.codewords=e}static getDataBlocks(t,e){const r=e.getECBlocks();let n=0;const i=r.getECBlocks();for(let t of i)n+=t.getCount();const o=new Array(n);let s=0;for(let t of i)for(let e=0;e<t.getCount();e++){const e=t.getDataCodewords(),n=r.getECCodewords()+e;o[s++]=new le(e,new Uint8Array(n))}const a=o[0].codewords.length-r.getECCodewords(),l=a-1;let h=0;for(let e=0;e<l;e++)for(let r=0;r<s;r++)o[r].codewords[e]=t[h++];const u=24===e.getVersionNumber(),d=u?8:s;for(let e=0;e<d;e++)o[e].codewords[a-1]=t[h++];const f=o[0].codewords.length;for(let e=a;e<f;e++)for(let r=0;r<s;r++){const n=u?(r+8)%s:r,i=u&&n>7?e-1:e;o[n].codewords[i]=t[h++]}if(h!==t.length)throw new c;return o}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class he{constructor(t){this.bytes=t,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(t){if(t<1||t>32||t>this.available())throw new c(""+t);let e=0,r=this.bitOffset,n=this.byteOffset;const i=this.bytes;if(r>0){const o=8-r,s=t<o?t:o,a=o-s,c=255>>8-s<<a;e=(i[n]&c)>>a,t-=s,r+=s,8===r&&(r=0,n++)}if(t>0){for(;t>=8;)e=e<<8|255&i[n],n++,t-=8;if(t>0){const o=8-t,s=255>>o<<o;e=e<<t|(i[n]&s)>>o,r+=t}}return this.bitOffset=r,this.byteOffset=n,e}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}!function(t){t[t.PAD_ENCODE=0]="PAD_ENCODE",t[t.ASCII_ENCODE=1]="ASCII_ENCODE",t[t.C40_ENCODE=2]="C40_ENCODE",t[t.TEXT_ENCODE=3]="TEXT_ENCODE",t[t.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",t[t.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",t[t.BASE256_ENCODE=6]="BASE256_ENCODE"}(V||(V={}));class ue{static decode(t){const e=new he(t),r=new y,n=new y,i=new Array;let o=V.ASCII_ENCODE;do{if(o===V.ASCII_ENCODE)o=this.decodeAsciiSegment(e,r,n);else{switch(o){case V.C40_ENCODE:this.decodeC40Segment(e,r);break;case V.TEXT_ENCODE:this.decodeTextSegment(e,r);break;case V.ANSIX12_ENCODE:this.decodeAnsiX12Segment(e,r);break;case V.EDIFACT_ENCODE:this.decodeEdifactSegment(e,r);break;case V.BASE256_ENCODE:this.decodeBase256Segment(e,r,i);break;default:throw new E}o=V.ASCII_ENCODE}}while(o!==V.PAD_ENCODE&&e.available()>0);return n.length()>0&&r.append(n.toString()),new j(t,r.toString(),0===i.length?null:i,null)}static decodeAsciiSegment(t,e,r){let n=!1;do{let i=t.readBits(8);if(0===i)throw new E;if(i<=128)return n&&(i+=128),e.append(String.fromCharCode(i-1)),V.ASCII_ENCODE;if(129===i)return V.PAD_ENCODE;if(i<=229){const t=i-130;t<10&&e.append("0"),e.append(""+t)}else switch(i){case 230:return V.C40_ENCODE;case 231:return V.BASE256_ENCODE;case 232:e.append(String.fromCharCode(29));break;case 233:case 234:case 241:break;case 235:n=!0;break;case 236:e.append("[)>05"),r.insert(0,"");break;case 237:e.append("[)>06"),r.insert(0,"");break;case 238:return V.ANSIX12_ENCODE;case 239:return V.TEXT_ENCODE;case 240:return V.EDIFACT_ENCODE;default:if(254!==i||0!==t.available())throw new E}}while(t.available()>0);return V.ASCII_ENCODE}static decodeC40Segment(t,e){let r=!1;const n=[];let i=0;do{if(8===t.available())return;const o=t.readBits(8);if(254===o)return;this.parseTwoBytes(o,t.readBits(8),n);for(let t=0;t<3;t++){const o=n[t];switch(i){case 0:if(o<3)i=o+1;else{if(!(o<this.C40_BASIC_SET_CHARS.length))throw new E;{const t=this.C40_BASIC_SET_CHARS[o];r?(e.append(String.fromCharCode(t.charCodeAt(0)+128)),r=!1):e.append(t)}}break;case 1:r?(e.append(String.fromCharCode(o+128)),r=!1):e.append(String.fromCharCode(o)),i=0;break;case 2:if(o<this.C40_SHIFT2_SET_CHARS.length){const t=this.C40_SHIFT2_SET_CHARS[o];r?(e.append(String.fromCharCode(t.charCodeAt(0)+128)),r=!1):e.append(t)}else switch(o){case 27:e.append(String.fromCharCode(29));break;case 30:r=!0;break;default:throw new E}i=0;break;case 3:r?(e.append(String.fromCharCode(o+224)),r=!1):e.append(String.fromCharCode(o+96)),i=0;break;default:throw new E}}}while(t.available()>0)}static decodeTextSegment(t,e){let r=!1,n=[],i=0;do{if(8===t.available())return;const o=t.readBits(8);if(254===o)return;this.parseTwoBytes(o,t.readBits(8),n);for(let t=0;t<3;t++){const o=n[t];switch(i){case 0:if(o<3)i=o+1;else{if(!(o<this.TEXT_BASIC_SET_CHARS.length))throw new E;{const t=this.TEXT_BASIC_SET_CHARS[o];r?(e.append(String.fromCharCode(t.charCodeAt(0)+128)),r=!1):e.append(t)}}break;case 1:r?(e.append(String.fromCharCode(o+128)),r=!1):e.append(String.fromCharCode(o)),i=0;break;case 2:if(o<this.TEXT_SHIFT2_SET_CHARS.length){const t=this.TEXT_SHIFT2_SET_CHARS[o];r?(e.append(String.fromCharCode(t.charCodeAt(0)+128)),r=!1):e.append(t)}else switch(o){case 27:e.append(String.fromCharCode(29));break;case 30:r=!0;break;default:throw new E}i=0;break;case 3:if(!(o<this.TEXT_SHIFT3_SET_CHARS.length))throw new E;{const t=this.TEXT_SHIFT3_SET_CHARS[o];r?(e.append(String.fromCharCode(t.charCodeAt(0)+128)),r=!1):e.append(t),i=0}break;default:throw new E}}}while(t.available()>0)}static decodeAnsiX12Segment(t,e){const r=[];do{if(8===t.available())return;const n=t.readBits(8);if(254===n)return;this.parseTwoBytes(n,t.readBits(8),r);for(let t=0;t<3;t++){const n=r[t];switch(n){case 0:e.append("\r");break;case 1:e.append("*");break;case 2:e.append(">");break;case 3:e.append(" ");break;default:if(n<14)e.append(String.fromCharCode(n+44));else{if(!(n<40))throw new E;e.append(String.fromCharCode(n+51))}}}}while(t.available()>0)}static parseTwoBytes(t,e,r){let n=(t<<8)+e-1,i=Math.floor(n/1600);r[0]=i,n-=1600*i,i=Math.floor(n/40),r[1]=i,r[2]=n-40*i}static decodeEdifactSegment(t,e){do{if(t.available()<=16)return;for(let r=0;r<4;r++){let r=t.readBits(6);if(31===r){const e=8-t.getBitOffset();return void(8!==e&&t.readBits(e))}0==(32&r)&&(r|=64),e.append(String.fromCharCode(r))}}while(t.available()>0)}static decodeBase256Segment(t,e,r){let n=1+t.getByteOffset();const i=this.unrandomize255State(t.readBits(8),n++);let o;if(o=0===i?t.available()/8|0:i<250?i:250*(i-249)+this.unrandomize255State(t.readBits(8),n++),o<0)throw new E;const s=new Uint8Array(o);for(let e=0;e<o;e++){if(t.available()<8)throw new E;s[e]=this.unrandomize255State(t.readBits(8),n++)}r.push(s);try{e.append(_.decode(s,T.ISO88591))}catch(t){throw new $("Platform does not support required encoding: "+t.message)}}static unrandomize255State(t,e){const r=t-(149*e%255+1);return r>=0?r:r+256}}ue.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"],ue.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],ue.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"],ue.TEXT_SHIFT2_SET_CHARS=ue.C40_SHIFT2_SET_CHARS,ue.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","{","|","}","~",String.fromCharCode(127)];class de{constructor(){this.rsDecoder=new tt(q.DATA_MATRIX_FIELD_256)}decode(t){const e=new ce(t),r=e.getVersion(),n=e.readCodewords(),i=le.getDataBlocks(n,r);let o=0;for(let t of i)o+=t.getNumDataCodewords();const s=new Uint8Array(o),a=i.length;for(let t=0;t<a;t++){const e=i[t],r=e.getCodewords(),n=e.getNumDataCodewords();this.correctErrors(r,n);for(let e=0;e<n;e++)s[e*a+t]=r[e]}return ue.decode(s)}correctErrors(t,e){const r=new Int32Array(t);try{this.rsDecoder.decode(r,t.length-e)}catch(t){throw new h}for(let n=0;n<e;n++)t[n]=r[n]}}class fe{constructor(t){this.image=t,this.rectangleDetector=new at(this.image)}detect(){const t=this.rectangleDetector.detect();let e=this.detectSolid1(t);if(e=this.detectSolid2(e),e[3]=this.correctTopRight(e),!e[3])throw new D;e=this.shiftToModuleCenter(e);const r=e[0],n=e[1],i=e[2],o=e[3];let s=this.transitionsBetween(r,o)+1,a=this.transitionsBetween(i,o)+1;1==(1&s)&&(s+=1),1==(1&a)&&(a+=1),4*s<7*a&&4*a<7*s&&(s=a=Math.max(s,a));let c=fe.sampleGrid(this.image,r,n,i,o,s,a);return new ot(c,[r,n,i,o])}static shiftPoint(t,e,r){let n=(e.getX()-t.getX())/(r+1),i=(e.getY()-t.getY())/(r+1);return new it(t.getX()+n,t.getY()+i)}static moveAway(t,e,r){let n=t.getX(),i=t.getY();return n<e?n-=1:n+=1,i<r?i-=1:i+=1,new it(n,i)}detectSolid1(t){let e=t[0],r=t[1],n=t[3],i=t[2],o=this.transitionsBetween(e,r),s=this.transitionsBetween(r,n),a=this.transitionsBetween(n,i),c=this.transitionsBetween(i,e),l=o,h=[i,e,r,n];return l>s&&(l=s,h[0]=e,h[1]=r,h[2]=n,h[3]=i),l>a&&(l=a,h[0]=r,h[1]=n,h[2]=i,h[3]=e),l>c&&(h[0]=n,h[1]=i,h[2]=e,h[3]=r),h}detectSolid2(t){let e=t[0],r=t[1],n=t[2],i=t[3],o=this.transitionsBetween(e,i),s=fe.shiftPoint(r,n,4*(o+1)),a=fe.shiftPoint(n,r,4*(o+1));return this.transitionsBetween(s,e)<this.transitionsBetween(a,i)?(t[0]=e,t[1]=r,t[2]=n,t[3]=i):(t[0]=r,t[1]=n,t[2]=i,t[3]=e),t}correctTopRight(t){let e=t[0],r=t[1],n=t[2],i=t[3],o=this.transitionsBetween(e,i),s=this.transitionsBetween(r,i),a=fe.shiftPoint(e,r,4*(s+1)),c=fe.shiftPoint(n,r,4*(o+1));o=this.transitionsBetween(a,i),s=this.transitionsBetween(c,i);let l=new it(i.getX()+(n.getX()-r.getX())/(o+1),i.getY()+(n.getY()-r.getY())/(o+1)),h=new it(i.getX()+(e.getX()-r.getX())/(s+1),i.getY()+(e.getY()-r.getY())/(s+1));return this.isValid(l)?this.isValid(h)?this.transitionsBetween(a,l)+this.transitionsBetween(c,l)>this.transitionsBetween(a,h)+this.transitionsBetween(c,h)?l:h:l:this.isValid(h)?h:null}shiftToModuleCenter(t){let e=t[0],r=t[1],n=t[2],i=t[3],o=this.transitionsBetween(e,i)+1,s=this.transitionsBetween(n,i)+1,a=fe.shiftPoint(e,r,4*s),c=fe.shiftPoint(n,r,4*o);o=this.transitionsBetween(a,i)+1,s=this.transitionsBetween(c,i)+1,1==(1&o)&&(o+=1),1==(1&s)&&(s+=1);let l,h,u=(e.getX()+r.getX()+n.getX()+i.getX())/4,d=(e.getY()+r.getY()+n.getY()+i.getY())/4;return e=fe.moveAway(e,u,d),r=fe.moveAway(r,u,d),n=fe.moveAway(n,u,d),i=fe.moveAway(i,u,d),a=fe.shiftPoint(e,r,4*s),a=fe.shiftPoint(a,i,4*o),l=fe.shiftPoint(r,e,4*s),l=fe.shiftPoint(l,n,4*o),c=fe.shiftPoint(n,i,4*s),c=fe.shiftPoint(c,r,4*o),h=fe.shiftPoint(i,n,4*s),h=fe.shiftPoint(h,e,4*o),[a,l,c,h]}isValid(t){return t.getX()>=0&&t.getX()<this.image.getWidth()&&t.getY()>0&&t.getY()<this.image.getHeight()}static sampleGrid(t,e,r,n,i,o,s){return ut.getInstance().sampleGrid(t,o,s,.5,.5,o-.5,.5,o-.5,s-.5,.5,s-.5,e.getX(),e.getY(),i.getX(),i.getY(),n.getX(),n.getY(),r.getX(),r.getY())}transitionsBetween(t,e){let r=Math.trunc(t.getX()),n=Math.trunc(t.getY()),i=Math.trunc(e.getX()),o=Math.trunc(e.getY()),s=Math.abs(o-n)>Math.abs(i-r);if(s){let t=r;r=n,n=t,t=i,i=o,o=t}let a=Math.abs(i-r),c=Math.abs(o-n),l=-a/2,h=n<o?1:-1,u=r<i?1:-1,d=0,f=this.image.get(s?n:r,s?r:n);for(let t=r,e=n;t!==i;t+=u){let r=this.image.get(s?e:t,s?t:e);if(r!==f&&(d++,f=r),l+=c,l>0){if(e===o)break;e+=h,l-=a}}return d}}class ge{constructor(){this.decoder=new de}decode(t,e=null){let r,n;if(null!=e&&e.has(C.PURE_BARCODE)){const e=ge.extractPureBits(t.getBlackMatrix());r=this.decoder.decode(e),n=ge.NO_POINTS}else{const e=new fe(t.getBlackMatrix()).detect();r=this.decoder.decode(e.getBits()),n=e.getPoints()}const i=r.getRawBytes(),o=new x(r.getText(),i,8*i.length,n,U.DATA_MATRIX,d.currentTimeMillis()),s=r.getByteSegments();null!=s&&o.putMetadata(W.BYTE_SEGMENTS,s);const a=r.getECLevel();return null!=a&&o.putMetadata(W.ERROR_CORRECTION_LEVEL,a),o}reset(){}static extractPureBits(t){const e=t.getTopLeftOnBit(),r=t.getBottomRightOnBit();if(null==e||null==r)throw new D;const n=this.moduleSize(e,t);let i=e[1];const o=r[1];let s=e[0];const a=(r[0]-s+1)/n,c=(o-i+1)/n;if(a<=0||c<=0)throw new D;const l=n/2;i+=l,s+=l;const h=new N(a,c);for(let e=0;e<c;e++){const r=i+e*n;for(let i=0;i<a;i++)t.get(s+i*n,r)&&h.set(i,e)}return h}static moduleSize(t,e){const r=e.getWidth();let n=t[0];const i=t[1];for(;n<r&&e.get(n,i);)n++;if(n===r)throw new D;const o=n-t[0];if(0===o)throw new D;return o}}ge.NO_POINTS=[];!function(t){t[t.L=0]="L",t[t.M=1]="M",t[t.Q=2]="Q",t[t.H=3]="H"}(z||(z={}));class we{constructor(t,e,r){this.value=t,this.stringValue=e,this.bits=r,we.FOR_BITS.set(r,this),we.FOR_VALUE.set(t,this)}getValue(){return this.value}getBits(){return this.bits}static fromString(t){switch(t){case"L":return we.L;case"M":return we.M;case"Q":return we.Q;case"H":return we.H;default:throw new a(t+"not available")}}toString(){return this.stringValue}equals(t){if(!(t instanceof we))return!1;const e=t;return this.value===e.value}static forBits(t){if(t<0||t>=we.FOR_BITS.size)throw new c;return we.FOR_BITS.get(t)}}we.FOR_BITS=new Map,we.FOR_VALUE=new Map,we.L=new we(z.L,"L",1),we.M=new we(z.M,"M",0),we.Q=new we(z.Q,"Q",3),we.H=new we(z.H,"H",2);class me{constructor(t){this.errorCorrectionLevel=we.forBits(t>>3&3),this.dataMask=7&t}static numBitsDiffering(t,e){return m.bitCount(t^e)}static decodeFormatInformation(t,e){const r=me.doDecodeFormatInformation(t,e);return null!==r?r:me.doDecodeFormatInformation(t^me.FORMAT_INFO_MASK_QR,e^me.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(t,e){let r=Number.MAX_SAFE_INTEGER,n=0;for(const i of me.FORMAT_INFO_DECODE_LOOKUP){const o=i[0];if(o===t||o===e)return new me(i[1]);let s=me.numBitsDiffering(t,o);s<r&&(n=i[1],r=s),t!==e&&(s=me.numBitsDiffering(e,o),s<r&&(n=i[1],r=s))}return r<=3?new me(n):null}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getDataMask(){return this.dataMask}hashCode(){return this.errorCorrectionLevel.getBits()<<3|this.dataMask}equals(t){if(!(t instanceof me))return!1;const e=t;return this.errorCorrectionLevel===e.errorCorrectionLevel&&this.dataMask===e.dataMask}}me.FORMAT_INFO_MASK_QR=21522,me.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 pe{constructor(t,...e){this.ecCodewordsPerBlock=t,this.ecBlocks=e}getECCodewordsPerBlock(){return this.ecCodewordsPerBlock}getNumBlocks(){let t=0;const e=this.ecBlocks;for(const r of e)t+=r.getCount();return t}getTotalECCodewords(){return this.ecCodewordsPerBlock*this.getNumBlocks()}getECBlocks(){return this.ecBlocks}}class Ae{constructor(t,e){this.count=t,this.dataCodewords=e}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class Ce{constructor(t,e,...r){this.versionNumber=t,this.alignmentPatternCenters=e,this.ecBlocks=r;let n=0;const i=r[0].getECCodewordsPerBlock(),o=r[0].getECBlocks();for(const t of o)n+=t.getCount()*(t.getDataCodewords()+i);this.totalCodewords=n}getVersionNumber(){return this.versionNumber}getAlignmentPatternCenters(){return this.alignmentPatternCenters}getTotalCodewords(){return this.totalCodewords}getDimensionForVersion(){return 17+4*this.versionNumber}getECBlocksForLevel(t){return this.ecBlocks[t.getValue()]}static getProvisionalVersionForDimension(t){if(t%4!=1)throw new E;try{return this.getVersionForNumber((t-17)/4)}catch(t){throw new E}}static getVersionForNumber(t){if(t<1||t>40)throw new c;return Ce.VERSIONS[t-1]}static decodeVersionInformation(t){let e=Number.MAX_SAFE_INTEGER,r=0;for(let n=0;n<Ce.VERSION_DECODE_INFO.length;n++){const i=Ce.VERSION_DECODE_INFO[n];if(i===t)return Ce.getVersionForNumber(n+7);const o=me.numBitsDiffering(t,i);o<e&&(r=n+7,e=o)}return e<=3?Ce.getVersionForNumber(r):null}buildFunctionPattern(){const t=this.getDimensionForVersion(),e=new N(t);e.setRegion(0,0,9,9),e.setRegion(t-8,0,8,9),e.setRegion(0,t-8,9,8);const r=this.alignmentPatternCenters.length;for(let t=0;t<r;t++){const n=this.alignmentPatternCenters[t]-2;for(let i=0;i<r;i++)0===t&&(0===i||i===r-1)||t===r-1&&0===i||e.setRegion(this.alignmentPatternCenters[i]-2,n,5,5)}return e.setRegion(6,9,1,t-17),e.setRegion(9,6,t-17,1),this.versionNumber>6&&(e.setRegion(t-11,0,3,6),e.setRegion(0,t-11,6,3)),e}toString(){return""+this.versionNumber}}Ce.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]),Ce.VERSIONS=[new Ce(1,new Int32Array(0),new pe(7,new Ae(1,19)),new pe(10,new Ae(1,16)),new pe(13,new Ae(1,13)),new pe(17,new Ae(1,9))),new Ce(2,Int32Array.from([6,18]),new pe(10,new Ae(1,34)),new pe(16,new Ae(1,28)),new pe(22,new Ae(1,22)),new pe(28,new Ae(1,16))),new Ce(3,Int32Array.from([6,22]),new pe(15,new Ae(1,55)),new pe(26,new Ae(1,44)),new pe(18,new Ae(2,17)),new pe(22,new Ae(2,13))),new Ce(4,Int32Array.from([6,26]),new pe(20,new Ae(1,80)),new pe(18,new Ae(2,32)),new pe(26,new Ae(2,24)),new pe(16,new Ae(4,9))),new Ce(5,Int32Array.from([6,30]),new pe(26,new Ae(1,108)),new pe(24,new Ae(2,43)),new pe(18,new Ae(2,15),new Ae(2,16)),new pe(22,new Ae(2,11),new Ae(2,12))),new Ce(6,Int32Array.from([6,34]),new pe(18,new Ae(2,68)),new pe(16,new Ae(4,27)),new pe(24,new Ae(4,19)),new pe(28,new Ae(4,15))),new Ce(7,Int32Array.from([6,22,38]),new pe(20,new Ae(2,78)),new pe(18,new Ae(4,31)),new pe(18,new Ae(2,14),new Ae(4,15)),new pe(26,new Ae(4,13),new Ae(1,14))),new Ce(8,Int32Array.from([6,24,42]),new pe(24,new Ae(2,97)),new pe(22,new Ae(2,38),new Ae(2,39)),new pe(22,new Ae(4,18),new Ae(2,19)),new pe(26,new Ae(4,14),new Ae(2,15))),new Ce(9,Int32Array.from([6,26,46]),new pe(30,new Ae(2,116)),new pe(22,new Ae(3,36),new Ae(2,37)),new pe(20,new Ae(4,16),new Ae(4,17)),new pe(24,new Ae(4,12),new Ae(4,13))),new Ce(10,Int32Array.from([6,28,50]),new pe(18,new Ae(2,68),new Ae(2,69)),new pe(26,new Ae(4,43),new Ae(1,44)),new pe(24,new Ae(6,19),new Ae(2,20)),new pe(28,new Ae(6,15),new Ae(2,16))),new Ce(11,Int32Array.from([6,30,54]),new pe(20,new Ae(4,81)),new pe(30,new Ae(1,50),new Ae(4,51)),new pe(28,new Ae(4,22),new Ae(4,23)),new pe(24,new Ae(3,12),new Ae(8,13))),new Ce(12,Int32Array.from([6,32,58]),new pe(24,new Ae(2,92),new Ae(2,93)),new pe(22,new Ae(6,36),new Ae(2,37)),new pe(26,new Ae(4,20),new Ae(6,21)),new pe(28,new Ae(7,14),new Ae(4,15))),new Ce(13,Int32Array.from([6,34,62]),new pe(26,new Ae(4,107)),new pe(22,new Ae(8,37),new Ae(1,38)),new pe(24,new Ae(8,20),new Ae(4,21)),new pe(22,new Ae(12,11),new Ae(4,12))),new Ce(14,Int32Array.from([6,26,46,66]),new pe(30,new Ae(3,115),new Ae(1,116)),new pe(24,new Ae(4,40),new Ae(5,41)),new pe(20,new Ae(11,16),new Ae(5,17)),new pe(24,new Ae(11,12),new Ae(5,13))),new Ce(15,Int32Array.from([6,26,48,70]),new pe(22,new Ae(5,87),new Ae(1,88)),new pe(24,new Ae(5,41),new Ae(5,42)),new pe(30,new Ae(5,24),new Ae(7,25)),new pe(24,new Ae(11,12),new Ae(7,13))),new Ce(16,Int32Array.from([6,26,50,74]),new pe(24,new Ae(5,98),new Ae(1,99)),new pe(28,new Ae(7,45),new Ae(3,46)),new pe(24,new Ae(15,19),new Ae(2,20)),new pe(30,new Ae(3,15),new Ae(13,16))),new Ce(17,Int32Array.from([6,30,54,78]),new pe(28,new Ae(1,107),new Ae(5,108)),new pe(28,new Ae(10,46),new Ae(1,47)),new pe(28,new Ae(1,22),new Ae(15,23)),new pe(28,new Ae(2,14),new Ae(17,15))),new Ce(18,Int32Array.from([6,30,56,82]),new pe(30,new Ae(5,120),new Ae(1,121)),new pe(26,new Ae(9,43),new Ae(4,44)),new pe(28,new Ae(17,22),new Ae(1,23)),new pe(28,new Ae(2,14),new Ae(19,15))),new Ce(19,Int32Array.from([6,30,58,86]),new pe(28,new Ae(3,113),new Ae(4,114)),new pe(26,new Ae(3,44),new Ae(11,45)),new pe(26,new Ae(17,21),new Ae(4,22)),new pe(26,new Ae(9,13),new Ae(16,14))),new Ce(20,Int32Array.from([6,34,62,90]),new pe(28,new Ae(3,107),new Ae(5,108)),new pe(26,new Ae(3,41),new Ae(13,42)),new pe(30,new Ae(15,24),new Ae(5,25)),new pe(28,new Ae(15,15),new Ae(10,16))),new Ce(21,Int32Array.from([6,28,50,72,94]),new pe(28,new Ae(4,116),new Ae(4,117)),new pe(26,new Ae(17,42)),new pe(28,new Ae(17,22),new Ae(6,23)),new pe(30,new Ae(19,16),new Ae(6,17))),new Ce(22,Int32Array.from([6,26,50,74,98]),new pe(28,new Ae(2,111),new Ae(7,112)),new pe(28,new Ae(17,46)),new pe(30,new Ae(7,24),new Ae(16,25)),new pe(24,new Ae(34,13))),new Ce(23,Int32Array.from([6,30,54,78,102]),new pe(30,new Ae(4,121),new Ae(5,122)),new pe(28,new Ae(4,47),new Ae(14,48)),new pe(30,new Ae(11,24),new Ae(14,25)),new pe(30,new Ae(16,15),new Ae(14,16))),new Ce(24,Int32Array.from([6,28,54,80,106]),new pe(30,new Ae(6,117),new Ae(4,118)),new pe(28,new Ae(6,45),new Ae(14,46)),new pe(30,new Ae(11,24),new Ae(16,25)),new pe(30,new Ae(30,16),new Ae(2,17))),new Ce(25,Int32Array.from([6,32,58,84,110]),new pe(26,new Ae(8,106),new Ae(4,107)),new pe(28,new Ae(8,47),new Ae(13,48)),new pe(30,new Ae(7,24),new Ae(22,25)),new pe(30,new Ae(22,15),new Ae(13,16))),new Ce(26,Int32Array.from([6,30,58,86,114]),new pe(28,new Ae(10,114),new Ae(2,115)),new pe(28,new Ae(19,46),new Ae(4,47)),new pe(28,new Ae(28,22),new Ae(6,23)),new pe(30,new Ae(33,16),new Ae(4,17))),new Ce(27,Int32Array.from([6,34,62,90,118]),new pe(30,new Ae(8,122),new Ae(4,123)),new pe(28,new Ae(22,45),new Ae(3,46)),new pe(30,new Ae(8,23),new Ae(26,24)),new pe(30,new Ae(12,15),new Ae(28,16))),new Ce(28,Int32Array.from([6,26,50,74,98,122]),new pe(30,new Ae(3,117),new Ae(10,118)),new pe(28,new Ae(3,45),new Ae(23,46)),new pe(30,new Ae(4,24),new Ae(31,25)),new pe(30,new Ae(11,15),new Ae(31,16))),new Ce(29,Int32Array.from([6,30,54,78,102,126]),new pe(30,new Ae(7,116),new Ae(7,117)),new pe(28,new Ae(21,45),new Ae(7,46)),new pe(30,new Ae(1,23),new Ae(37,24)),new pe(30,new Ae(19,15),new Ae(26,16))),new Ce(30,Int32Array.from([6,26,52,78,104,130]),new pe(30,new Ae(5,115),new Ae(10,116)),new pe(28,new Ae(19,47),new Ae(10,48)),new pe(30,new Ae(15,24),new Ae(25,25)),new pe(30,new Ae(23,15),new Ae(25,16))),new Ce(31,Int32Array.from([6,30,56,82,108,134]),new pe(30,new Ae(13,115),new Ae(3,116)),new pe(28,new Ae(2,46),new Ae(29,47)),new pe(30,new Ae(42,24),new Ae(1,25)),new pe(30,new Ae(23,15),new Ae(28,16))),new Ce(32,Int32Array.from([6,34,60,86,112,138]),new pe(30,new Ae(17,115)),new pe(28,new Ae(10,46),new Ae(23,47)),new pe(30,new Ae(10,24),new Ae(35,25)),new pe(30,new Ae(19,15),new Ae(35,16))),new Ce(33,Int32Array.from([6,30,58,86,114,142]),new pe(30,new Ae(17,115),new Ae(1,116)),new pe(28,new Ae(14,46),new Ae(21,47)),new pe(30,new Ae(29,24),new Ae(19,25)),new pe(30,new Ae(11,15),new Ae(46,16))),new Ce(34,Int32Array.from([6,34,62,90,118,146]),new pe(30,new Ae(13,115),new Ae(6,116)),new pe(28,new Ae(14,46),new Ae(23,47)),new pe(30,new Ae(44,24),new Ae(7,25)),new pe(30,new Ae(59,16),new Ae(1,17))),new Ce(35,Int32Array.from([6,30,54,78,102,126,150]),new pe(30,new Ae(12,121),new Ae(7,122)),new pe(28,new Ae(12,47),new Ae(26,48)),new pe(30,new Ae(39,24),new Ae(14,25)),new pe(30,new Ae(22,15),new Ae(41,16))),new Ce(36,Int32Array.from([6,24,50,76,102,128,154]),new pe(30,new Ae(6,121),new Ae(14,122)),new pe(28,new Ae(6,47),new Ae(34,48)),new pe(30,new Ae(46,24),new Ae(10,25)),new pe(30,new Ae(2,15),new Ae(64,16))),new Ce(37,Int32Array.from([6,28,54,80,106,132,158]),new pe(30,new Ae(17,122),new Ae(4,123)),new pe(28,new Ae(29,46),new Ae(14,47)),new pe(30,new Ae(49,24),new Ae(10,25)),new pe(30,new Ae(24,15),new Ae(46,16))),new Ce(38,Int32Array.from([6,32,58,84,110,136,162]),new pe(30,new Ae(4,122),new Ae(18,123)),new pe(28,new Ae(13,46),new Ae(32,47)),new pe(30,new Ae(48,24),new Ae(14,25)),new pe(30,new Ae(42,15),new Ae(32,16))),new Ce(39,Int32Array.from([6,26,54,82,110,138,166]),new pe(30,new Ae(20,117),new Ae(4,118)),new pe(28,new Ae(40,47),new Ae(7,48)),new pe(30,new Ae(43,24),new Ae(22,25)),new pe(30,new Ae(10,15),new Ae(67,16))),new Ce(40,Int32Array.from([6,30,58,86,114,142,170]),new pe(30,new Ae(19,118),new Ae(6,119)),new pe(28,new Ae(18,47),new Ae(31,48)),new pe(30,new Ae(34,24),new Ae(34,25)),new pe(30,new Ae(20,15),new Ae(61,16)))],function(t){t[t.DATA_MASK_000=0]="DATA_MASK_000",t[t.DATA_MASK_001=1]="DATA_MASK_001",t[t.DATA_MASK_010=2]="DATA_MASK_010",t[t.DATA_MASK_011=3]="DATA_MASK_011",t[t.DATA_MASK_100=4]="DATA_MASK_100",t[t.DATA_MASK_101=5]="DATA_MASK_101",t[t.DATA_MASK_110=6]="DATA_MASK_110",t[t.DATA_MASK_111=7]="DATA_MASK_111"}(G||(G={}));class Ee{constructor(t,e){this.value=t,this.isMasked=e}unmaskBitMatrix(t,e){for(let r=0;r<e;r++)for(let n=0;n<e;n++)this.isMasked(r,n)&&t.flip(n,r)}}Ee.values=new Map([[G.DATA_MASK_000,new Ee(G.DATA_MASK_000,((t,e)=>0==(t+e&1)))],[G.DATA_MASK_001,new Ee(G.DATA_MASK_001,((t,e)=>0==(1&t)))],[G.DATA_MASK_010,new Ee(G.DATA_MASK_010,((t,e)=>e%3==0))],[G.DATA_MASK_011,new Ee(G.DATA_MASK_011,((t,e)=>(t+e)%3==0))],[G.DATA_MASK_100,new Ee(G.DATA_MASK_100,((t,e)=>0==(Math.floor(t/2)+Math.floor(e/3)&1)))],[G.DATA_MASK_101,new Ee(G.DATA_MASK_101,((t,e)=>t*e%6==0))],[G.DATA_MASK_110,new Ee(G.DATA_MASK_110,((t,e)=>t*e%6<3))],[G.DATA_MASK_111,new Ee(G.DATA_MASK_111,((t,e)=>0==(t+e+t*e%3&1)))]]);class Ie{constructor(t){const e=t.getHeight();if(e<21||1!=(3&e))throw new E;this.bitMatrix=t}readFormatInformation(){if(null!==this.parsedFormatInfo&&void 0!==this.parsedFormatInfo)return this.parsedFormatInfo;let t=0;for(let e=0;e<6;e++)t=this.copyBit(e,8,t);t=this.copyBit(7,8,t),t=this.copyBit(8,8,t),t=this.copyBit(8,7,t);for(let e=5;e>=0;e--)t=this.copyBit(8,e,t);const e=this.bitMatrix.getHeight();let r=0;const n=e-7;for(let t=e-1;t>=n;t--)r=this.copyBit(8,t,r);for(let t=e-8;t<e;t++)r=this.copyBit(t,8,r);if(this.parsedFormatInfo=me.decodeFormatInformation(t,r),null!==this.parsedFormatInfo)return this.parsedFormatInfo;throw new E}readVersion(){if(null!==this.parsedVersion&&void 0!==this.parsedVersion)return this.parsedVersion;const t=this.bitMatrix.getHeight(),e=Math.floor((t-17)/4);if(e<=6)return Ce.getVersionForNumber(e);let r=0;const n=t-11;for(let e=5;e>=0;e--)for(let i=t-9;i>=n;i--)r=this.copyBit(i,e,r);let i=Ce.decodeVersionInformation(r);if(null!==i&&i.getDimensionForVersion()===t)return this.parsedVersion=i,i;r=0;for(let e=5;e>=0;e--)for(let i=t-9;i>=n;i--)r=this.copyBit(e,i,r);if(i=Ce.decodeVersionInformation(r),null!==i&&i.getDimensionForVersion()===t)return this.parsedVersion=i,i;throw new E}copyBit(t,e,r){return(this.isMirror?this.bitMatrix.get(e,t):this.bitMatrix.get(t,e))?r<<1|1:r<<1}readCodewords(){const t=this.readFormatInformation(),e=this.readVersion(),r=Ee.values.get(t.getDataMask()),n=this.bitMatrix.getHeight();r.unmaskBitMatrix(this.bitMatrix,n);const i=e.buildFunctionPattern();let o=!0;const s=new Uint8Array(e.getTotalCodewords());let a=0,c=0,l=0;for(let t=n-1;t>0;t-=2){6===t&&t--;for(let e=0;e<n;e++){const r=o?n-1-e:e;for(let e=0;e<2;e++)i.get(t-e,r)||(l++,c<<=1,this.bitMatrix.get(t-e,r)&&(c|=1),8===l&&(s[a++]=c,l=0,c=0))}o=!o}if(a!==e.getTotalCodewords())throw new E;return s}remask(){if(null===this.parsedFormatInfo)return;const t=Ee.values[this.parsedFormatInfo.getDataMask()],e=this.bitMatrix.getHeight();t.unmaskBitMatrix(this.bitMatrix,e)}setMirror(t){this.parsedVersion=null,this.parsedFormatInfo=null,this.isMirror=t}mirror(){const t=this.bitMatrix;for(let e=0,r=t.getWidth();e<r;e++)for(let r=e+1,n=t.getHeight();r<n;r++)t.get(e,r)!==t.get(r,e)&&(t.flip(r,e),t.flip(e,r))}}class Se{constructor(t,e){this.numDataCodewords=t,this.codewords=e}static getDataBlocks(t,e,r){if(t.length!==e.getTotalCodewords())throw new c;const n=e.getECBlocksForLevel(r);let i=0;const o=n.getECBlocks();for(const t of o)i+=t.getCount();const s=new Array(i);let a=0;for(const t of o)for(let e=0;e<t.getCount();e++){const e=t.getDataCodewords(),r=n.getECCodewordsPerBlock()+e;s[a++]=new Se(e,new Uint8Array(r))}const l=s[0].codewords.length;let h=s.length-1;for(;h>=0&&s[h].codewords.length!==l;)h--;h++;const u=l-n.getECCodewordsPerBlock();let d=0;for(let e=0;e<u;e++)for(let r=0;r<a;r++)s[r].codewords[e]=t[d++];for(let e=h;e<a;e++)s[e].codewords[u]=t[d++];const f=s[0].codewords.length;for(let e=u;e<f;e++)for(let r=0;r<a;r++){const n=r<h?e:e+1;s[r].codewords[n]=t[d++]}return s}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}!function(t){t[t.TERMINATOR=0]="TERMINATOR",t[t.NUMERIC=1]="NUMERIC",t[t.ALPHANUMERIC=2]="ALPHANUMERIC",t[t.STRUCTURED_APPEND=3]="STRUCTURED_APPEND",t[t.BYTE=4]="BYTE",t[t.ECI=5]="ECI",t[t.KANJI=6]="KANJI",t[t.FNC1_FIRST_POSITION=7]="FNC1_FIRST_POSITION",t[t.FNC1_SECOND_POSITION=8]="FNC1_SECOND_POSITION",t[t.HANZI=9]="HANZI"}(Y||(Y={}));class _e{constructor(t,e,r,n){this.value=t,this.stringValue=e,this.characterCountBitsForVersions=r,this.bits=n,_e.FOR_BITS.set(n,this),_e.FOR_VALUE.set(t,this)}static forBits(t){const e=_e.FOR_BITS.get(t);if(void 0===e)throw new c;return e}getCharacterCountBits(t){const e=t.getVersionNumber();let r;return r=e<=9?0:e<=26?1:2,this.characterCountBitsForVersions[r]}getValue(){return this.value}getBits(){return this.bits}equals(t){if(!(t instanceof _e))return!1;const e=t;return this.value===e.value}toString(){return this.stringValue}}_e.FOR_BITS=new Map,_e.FOR_VALUE=new Map,_e.TERMINATOR=new _e(Y.TERMINATOR,"TERMINATOR",Int32Array.from([0,0,0]),0),_e.NUMERIC=new _e(Y.NUMERIC,"NUMERIC",Int32Array.from([10,12,14]),1),_e.ALPHANUMERIC=new _e(Y.ALPHANUMERIC,"ALPHANUMERIC",Int32Array.from([9,11,13]),2),_e.STRUCTURED_APPEND=new _e(Y.STRUCTURED_APPEND,"STRUCTURED_APPEND",Int32Array.from([0,0,0]),3),_e.BYTE=new _e(Y.BYTE,"BYTE",Int32Array.from([8,16,16]),4),_e.ECI=new _e(Y.ECI,"ECI",Int32Array.from([0,0,0]),7),_e.KANJI=new _e(Y.KANJI,"KANJI",Int32Array.from([8,10,12]),8),_e.FNC1_FIRST_POSITION=new _e(Y.FNC1_FIRST_POSITION,"FNC1_FIRST_POSITION",Int32Array.from([0,0,0]),5),_e.FNC1_SECOND_POSITION=new _e(Y.FNC1_SECOND_POSITION,"FNC1_SECOND_POSITION",Int32Array.from([0,0,0]),9),_e.HANZI=new _e(Y.HANZI,"HANZI",Int32Array.from([8,10,12]),13);class Te{static decode(t,e,r,n){const i=new he(t);let o=new y;const s=new Array;let a=-1,c=-1;try{let t,r=null,l=!1;do{if(i.available()<4)t=_e.TERMINATOR;else{const e=i.readBits(4);t=_e.forBits(e)}switch(t){case _e.TERMINATOR:break;case _e.FNC1_FIRST_POSITION:case _e.FNC1_SECOND_POSITION:l=!0;break;case _e.STRUCTURED_APPEND:if(i.available()<16)throw new E;a=i.readBits(8),c=i.readBits(8);break;case _e.ECI:const h=Te.parseECIValue(i);if(r=I.getCharacterSetECIByValue(h),null===r)throw new E;break;case _e.HANZI:const u=i.readBits(4),d=i.readBits(t.getCharacterCountBits(e));u===Te.GB2312_SUBSET&&Te.decodeHanziSegment(i,o,d);break;default:const f=i.readBits(t.getCharacterCountBits(e));switch(t){case _e.NUMERIC:Te.decodeNumericSegment(i,o,f);break;case _e.ALPHANUMERIC:Te.decodeAlphanumericSegment(i,o,f,l);break;case _e.BYTE:Te.decodeByteSegment(i,o,f,r,s,n);break;case _e.KANJI:Te.decodeKanjiSegment(i,o,f);break;default:throw new E}}}while(t!==_e.TERMINATOR)}catch(t){throw new E}return new j(t,o.toString(),0===s.length?null:s,null===r?null:r.toString(),a,c)}static decodeHanziSegment(t,e,r){if(13*r>t.available())throw new E;const n=new Uint8Array(2*r);let i=0;for(;r>0;){const e=t.readBits(13);let o=e/96<<8&4294967295|e%96;o+=o<959?41377:42657,n[i]=o>>8&255,n[i+1]=255&o,i+=2,r--}try{e.append(_.decode(n,T.GB2312))}catch(t){throw new E(t)}}static decodeKanjiSegment(t,e,r){if(13*r>t.available())throw new E;const n=new Uint8Array(2*r);let i=0;for(;r>0;){const e=t.readBits(13);let o=e/192<<8&4294967295|e%192;o+=o<7936?33088:49472,n[i]=o>>8,n[i+1]=o,i+=2,r--}try{e.append(_.decode(n,T.SHIFT_JIS))}catch(t){throw new E(t)}}static decodeByteSegment(t,e,r,n,i,o){if(8*r>t.available())throw new E;const s=new Uint8Array(r);for(let e=0;e<r;e++)s[e]=t.readBits(8);let a;a=null===n?T.guessEncoding(s,o):n.getName();try{e.append(_.decode(s,a))}catch(t){throw new E(t)}i.push(s)}static toAlphaNumericChar(t){if(t>=Te.ALPHANUMERIC_CHARS.length)throw new E;return Te.ALPHANUMERIC_CHARS[t]}static decodeAlphanumericSegment(t,e,r,n){const i=e.length();for(;r>1;){if(t.available()<11)throw new E;const n=t.readBits(11);e.append(Te.toAlphaNumericChar(Math.floor(n/45))),e.append(Te.toAlphaNumericChar(n%45)),r-=2}if(1===r){if(t.available()<6)throw new E;e.append(Te.toAlphaNumericChar(t.readBits(6)))}if(n)for(let t=i;t<e.length();t++)"%"===e.charAt(t)&&(t<e.length()-1&&"%"===e.charAt(t+1)?e.deleteCharAt(t+1):e.setCharAt(t,String.fromCharCode(29)))}static decodeNumericSegment(t,e,r){for(;r>=3;){if(t.available()<10)throw new E;const n=t.readBits(10);if(n>=1e3)throw new E;e.append(Te.toAlphaNumericChar(Math.floor(n/100))),e.append(Te.toAlphaNumericChar(Math.floor(n/10)%10)),e.append(Te.toAlphaNumericChar(n%10)),r-=3}if(2===r){if(t.available()<7)throw new E;const r=t.readBits(7);if(r>=100)throw new E;e.append(Te.toAlphaNumericChar(Math.floor(r/10))),e.append(Te.toAlphaNumericChar(r%10))}else if(1===r){if(t.available()<4)throw new E;const r=t.readBits(4);if(r>=10)throw new E;e.append(Te.toAlphaNumericChar(r))}}static parseECIValue(t){const e=t.readBits(8);if(0==(128&e))return 127&e;if(128==(192&e))return(63&e)<<8&4294967295|t.readBits(8);if(192==(224&e))return(31&e)<<16&4294967295|t.readBits(16);throw new E}}Te.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Te.GB2312_SUBSET=1;class ye{constructor(t){this.mirrored=t}isMirrored(){return this.mirrored}applyMirroredCorrection(t){if(!this.mirrored||null===t||t.length<3)return;const e=t[0];t[0]=t[2],t[2]=e}}class Ne{constructor(){this.rsDecoder=new tt(q.QR_CODE_FIELD_256)}decodeBooleanArray(t,e){return this.decodeBitMatrix(N.parseFromBooleanArray(t),e)}decodeBitMatrix(t,e){const r=new Ie(t);let n=null;try{return this.decodeBitMatrixParser(r,e)}catch(t){n=t}try{r.remask(),r.setMirror(!0),r.readVersion(),r.readFormatInformation(),r.mirror();const t=this.decodeBitMatrixParser(r,e);return t.setOther(new ye(!0)),t}catch(t){if(null!==n)throw n;throw t}}decodeBitMatrixParser(t,e){const r=t.readVersion(),n=t.readFormatInformation().getErrorCorrectionLevel(),i=t.readCodewords(),o=Se.getDataBlocks(i,r,n);let s=0;for(const t of o)s+=t.getNumDataCodewords();const a=new Uint8Array(s);let c=0;for(const t of o){const e=t.getCodewords(),r=t.getNumDataCodewords();this.correctErrors(e,r);for(let t=0;t<r;t++)a[c++]=e[t]}return Te.decode(a,r,n,e)}correctErrors(t,e){const r=new Int32Array(t);try{this.rsDecoder.decode(r,t.length-e)}catch(t){throw new h}for(let n=0;n<e;n++)t[n]=r[n]}}class De extends it{constructor(t,e,r){super(t,e),this.estimatedModuleSize=r}aboutEquals(t,e,r){if(Math.abs(e-this.getY())<=t&&Math.abs(r-this.getX())<=t){const e=Math.abs(t-this.estimatedModuleSize);return e<=1||e<=this.estimatedModuleSize}return!1}combineEstimate(t,e,r){const n=(this.getX()+e)/2,i=(this.getY()+t)/2,o=(this.estimatedModuleSize+r)/2;return new De(n,i,o)}}class Me{constructor(t,e,r,n,i,o,s){this.image=t,this.startX=e,this.startY=r,this.width=n,this.height=i,this.moduleSize=o,this.resultPointCallback=s,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(3)}find(){const t=this.startX,e=this.height,r=t+this.width,n=this.startY+e/2,i=new Int32Array(3),o=this.image;for(let s=0;s<e;s++){const e=n+(0==(1&s)?Math.floor((s+1)/2):-Math.floor((s+1)/2));i[0]=0,i[1]=0,i[2]=0;let a=t;for(;a<r&&!o.get(a,e);)a++;let c=0;for(;a<r;){if(o.get(a,e))if(1===c)i[1]++;else if(2===c){if(this.foundPatternCross(i)){const t=this.handlePossibleCenter(i,e,a);if(null!==t)return t}i[0]=i[2],i[1]=1,i[2]=0,c=1}else i[++c]++;else 1===c&&c++,i[c]++;a++}if(this.foundPatternCross(i)){const t=this.handlePossibleCenter(i,e,r);if(null!==t)return t}}if(0!==this.possibleCenters.length)return this.possibleCenters[0];throw new D}static centerFromEnd(t,e){return e-t[2]-t[1]/2}foundPatternCross(t){const e=this.moduleSize,r=e/2;for(let n=0;n<3;n++)if(Math.abs(e-t[n])>=r)return!1;return!0}crossCheckVertical(t,e,r,n){const i=this.image,o=i.getHeight(),s=this.crossCheckStateCount;s[0]=0,s[1]=0,s[2]=0;let a=t;for(;a>=0&&i.get(e,a)&&s[1]<=r;)s[1]++,a--;if(a<0||s[1]>r)return NaN;for(;a>=0&&!i.get(e,a)&&s[0]<=r;)s[0]++,a--;if(s[0]>r)return NaN;for(a=t+1;a<o&&i.get(e,a)&&s[1]<=r;)s[1]++,a++;if(a===o||s[1]>r)return NaN;for(;a<o&&!i.get(e,a)&&s[2]<=r;)s[2]++,a++;if(s[2]>r)return NaN;const c=s[0]+s[1]+s[2];return 5*Math.abs(c-n)>=2*n?NaN:this.foundPatternCross(s)?Me.centerFromEnd(s,a):NaN}handlePossibleCenter(t,e,r){const n=t[0]+t[1]+t[2],i=Me.centerFromEnd(t,r),o=this.crossCheckVertical(e,i,2*t[1],n);if(!isNaN(o)){const e=(t[0]+t[1]+t[2])/3;for(const t of this.possibleCenters)if(t.aboutEquals(e,o,i))return t.combineEstimate(o,i,e);const r=new De(i,o,e);this.possibleCenters.push(r),null!==this.resultPointCallback&&void 0!==this.resultPointCallback&&this.resultPointCallback.foundPossibleResultPoint(r)}return null}}class Re extends it{constructor(t,e,r,n){super(t,e),this.estimatedModuleSize=r,this.count=n,void 0===n&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(t,e,r){if(Math.abs(e-this.getY())<=t&&Math.abs(r-this.getX())<=t){const e=Math.abs(t-this.estimatedModuleSize);return e<=1||e<=this.estimatedModuleSize}return!1}combineEstimate(t,e,r){const n=this.count+1,i=(this.count*this.getX()+e)/n,o=(this.count*this.getY()+t)/n,s=(this.count*this.estimatedModuleSize+r)/n;return new Re(i,o,s,n)}}class Oe{constructor(t){this.bottomLeft=t[0],this.topLeft=t[1],this.topRight=t[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class be{constructor(t,e){this.image=t,this.resultPointCallback=e,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=e}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(t){const e=null!=t&&void 0!==t.get(C.TRY_HARDER),r=null!=t&&void 0!==t.get(C.PURE_BARCODE),n=this.image,i=n.getHeight(),o=n.getWidth();let s=Math.floor(3*i/(4*be.MAX_MODULES));(s<be.MIN_SKIP||e)&&(s=be.MIN_SKIP);let a=!1;const c=new Int32Array(5);for(let t=s-1;t<i&&!a;t+=s){c[0]=0,c[1]=0,c[2]=0,c[3]=0,c[4]=0;let e=0;for(let i=0;i<o;i++)if(n.get(i,t))1==(1&e)&&e++,c[e]++;else if(0==(1&e))if(4===e)if(be.foundPatternCross(c)){if(!0!==this.handlePossibleCenter(c,t,i,r)){c[0]=c[2],c[1]=c[3],c[2]=c[4],c[3]=1,c[4]=0,e=3;continue}if(s=2,!0===this.hasSkipped)a=this.haveMultiplyConfirmedCenters();else{const e=this.findRowSkip();e>c[2]&&(t+=e-c[2]-s,i=o-1)}e=0,c[0]=0,c[1]=0,c[2]=0,c[3]=0,c[4]=0}else c[0]=c[2],c[1]=c[3],c[2]=c[4],c[3]=1,c[4]=0,e=3;else c[++e]++;else c[e]++;be.foundPatternCross(c)&&!0===this.handlePossibleCenter(c,t,o,r)&&(s=c[0],this.hasSkipped&&(a=this.haveMultiplyConfirmedCenters()))}const l=this.selectBestPatterns();return it.orderBestPatterns(l),new Oe(l)}static centerFromEnd(t,e){return e-t[4]-t[3]-t[2]/2}static foundPatternCross(t){let e=0;for(let r=0;r<5;r++){const n=t[r];if(0===n)return!1;e+=n}if(e<7)return!1;const r=e/7,n=r/2;return Math.abs(r-t[0])<n&&Math.abs(r-t[1])<n&&Math.abs(3*r-t[2])<3*n&&Math.abs(r-t[3])<n&&Math.abs(r-t[4])<n}getCrossCheckStateCount(){const t=this.crossCheckStateCount;return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t}crossCheckDiagonal(t,e,r,n){const i=this.getCrossCheckStateCount();let o=0;const s=this.image;for(;t>=o&&e>=o&&s.get(e-o,t-o);)i[2]++,o++;if(t<o||e<o)return!1;for(;t>=o&&e>=o&&!s.get(e-o,t-o)&&i[1]<=r;)i[1]++,o++;if(t<o||e<o||i[1]>r)return!1;for(;t>=o&&e>=o&&s.get(e-o,t-o)&&i[0]<=r;)i[0]++,o++;if(i[0]>r)return!1;const a=s.getHeight(),c=s.getWidth();for(o=1;t+o<a&&e+o<c&&s.get(e+o,t+o);)i[2]++,o++;if(t+o>=a||e+o>=c)return!1;for(;t+o<a&&e+o<c&&!s.get(e+o,t+o)&&i[3]<r;)i[3]++,o++;if(t+o>=a||e+o>=c||i[3]>=r)return!1;for(;t+o<a&&e+o<c&&s.get(e+o,t+o)&&i[4]<r;)i[4]++,o++;if(i[4]>=r)return!1;const l=i[0]+i[1]+i[2]+i[3]+i[4];return Math.abs(l-n)<2*n&&be.foundPatternCross(i)}crossCheckVertical(t,e,r,n){const i=this.image,o=i.getHeight(),s=this.getCrossCheckStateCount();let a=t;for(;a>=0&&i.get(e,a);)s[2]++,a--;if(a<0)return NaN;for(;a>=0&&!i.get(e,a)&&s[1]<=r;)s[1]++,a--;if(a<0||s[1]>r)return NaN;for(;a>=0&&i.get(e,a)&&s[0]<=r;)s[0]++,a--;if(s[0]>r)return NaN;for(a=t+1;a<o&&i.get(e,a);)s[2]++,a++;if(a===o)return NaN;for(;a<o&&!i.get(e,a)&&s[3]<r;)s[3]++,a++;if(a===o||s[3]>=r)return NaN;for(;a<o&&i.get(e,a)&&s[4]<r;)s[4]++,a++;if(s[4]>=r)return NaN;const c=s[0]+s[1]+s[2]+s[3]+s[4];return 5*Math.abs(c-n)>=2*n?NaN:be.foundPatternCross(s)?be.centerFromEnd(s,a):NaN}crossCheckHorizontal(t,e,r,n){const i=this.image,o=i.getWidth(),s=this.getCrossCheckStateCount();let a=t;for(;a>=0&&i.get(a,e);)s[2]++,a--;if(a<0)return NaN;for(;a>=0&&!i.get(a,e)&&s[1]<=r;)s[1]++,a--;if(a<0||s[1]>r)return NaN;for(;a>=0&&i.get(a,e)&&s[0]<=r;)s[0]++,a--;if(s[0]>r)return NaN;for(a=t+1;a<o&&i.get(a,e);)s[2]++,a++;if(a===o)return NaN;for(;a<o&&!i.get(a,e)&&s[3]<r;)s[3]++,a++;if(a===o||s[3]>=r)return NaN;for(;a<o&&i.get(a,e)&&s[4]<r;)s[4]++,a++;if(s[4]>=r)return NaN;const c=s[0]+s[1]+s[2]+s[3]+s[4];return 5*Math.abs(c-n)>=n?NaN:be.foundPatternCross(s)?be.centerFromEnd(s,a):NaN}handlePossibleCenter(t,e,r,n){const i=t[0]+t[1]+t[2]+t[3]+t[4];let o=be.centerFromEnd(t,r),s=this.crossCheckVertical(e,Math.floor(o),t[2],i);if(!isNaN(s)&&(o=this.crossCheckHorizontal(Math.floor(o),Math.floor(s),t[2],i),!isNaN(o)&&(!n||this.crossCheckDiagonal(Math.floor(s),Math.floor(o),t[2],i)))){const t=i/7;let e=!1;const r=this.possibleCenters;for(let n=0,i=r.length;n<i;n++){const i=r[n];if(i.aboutEquals(t,s,o)){r[n]=i.combineEstimate(s,o,t),e=!0;break}}if(!e){const e=new Re(o,s,t);r.push(e),null!==this.resultPointCallback&&void 0!==this.resultPointCallback&&this.resultPointCallback.foundPossibleResultPoint(e)}return!0}return!1}findRowSkip(){if(this.possibleCenters.length<=1)return 0;let t=null;for(const e of this.possibleCenters)if(e.getCount()>=be.CENTER_QUORUM){if(null!=t)return this.hasSkipped=!0,Math.floor((Math.abs(t.getX()-e.getX())-Math.abs(t.getY()-e.getY()))/2);t=e}return 0}haveMultiplyConfirmedCenters(){let t=0,e=0;const r=this.possibleCenters.length;for(const r of this.possibleCenters)r.getCount()>=be.CENTER_QUORUM&&(t++,e+=r.getEstimatedModuleSize());if(t<3)return!1;const n=e/r;let i=0;for(const t of this.possibleCenters)i+=Math.abs(t.getEstimatedModuleSize()-n);return i<=.05*e}selectBestPatterns(){const t=this.possibleCenters.length;if(t<3)throw new D;const e=this.possibleCenters;let r;if(t>3){let n=0,i=0;for(const t of this.possibleCenters){const e=t.getEstimatedModuleSize();n+=e,i+=e*e}r=n/t;let o=Math.sqrt(i/t-r*r);e.sort(((t,e)=>{const n=Math.abs(e.getEstimatedModuleSize()-r),i=Math.abs(t.getEstimatedModuleSize()-r);return n<i?-1:n>i?1:0}));const s=Math.max(.2*r,o);for(let t=0;t<e.length&&e.length>3;t++){const n=e[t];Math.abs(n.getEstimatedModuleSize()-r)>s&&(e.splice(t,1),t--)}}if(e.length>3){let t=0;for(const r of e)t+=r.getEstimatedModuleSize();r=t/e.length,e.sort(((t,e)=>{if(e.getCount()===t.getCount()){const n=Math.abs(e.getEstimatedModuleSize()-r),i=Math.abs(t.getEstimatedModuleSize()-r);return n<i?1:n>i?-1:0}return e.getCount()-t.getCount()})),e.splice(3)}return[e[0],e[1],e[2]]}}be.CENTER_QUORUM=2,be.MIN_SKIP=3,be.MAX_MODULES=57;class Be{constructor(t){this.image=t}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(t){this.resultPointCallback=null==t?null:t.get(C.NEED_RESULT_POINT_CALLBACK);const e=new be(this.image,this.resultPointCallback).find(t);return this.processFinderPatternInfo(e)}processFinderPatternInfo(t){const e=t.getTopLeft(),r=t.getTopRight(),n=t.getBottomLeft(),i=this.calculateModuleSize(e,r,n);if(i<1)throw new D("No pattern found in proccess finder.");const o=Be.computeDimension(e,r,n,i),s=Ce.getProvisionalVersionForDimension(o),a=s.getDimensionForVersion()-7;let c=null;if(s.getAlignmentPatternCenters().length>0){const t=r.getX()-e.getX()+n.getX(),o=r.getY()-e.getY()+n.getY(),s=1-3/a,l=Math.floor(e.getX()+s*(t-e.getX())),h=Math.floor(e.getY()+s*(o-e.getY()));for(let t=4;t<=16;t<<=1)try{c=this.findAlignmentInRegion(i,l,h,t);break}catch(t){if(!(t instanceof D))throw t}}const l=Be.createTransform(e,r,n,c,o),h=Be.sampleGrid(this.image,l,o);let u;return u=null===c?[n,e,r]:[n,e,r,c],new ot(h,u)}static createTransform(t,e,r,n,i){const o=i-3.5;let s,a,c,l;return null!==n?(s=n.getX(),a=n.getY(),c=o-3,l=c):(s=e.getX()-t.getX()+r.getX(),a=e.getY()-t.getY()+r.getY(),c=o,l=o),lt.quadrilateralToQuadrilateral(3.5,3.5,o,3.5,c,l,3.5,o,t.getX(),t.getY(),e.getX(),e.getY(),s,a,r.getX(),r.getY())}static sampleGrid(t,e,r){return ut.getInstance().sampleGridWithTransform(t,r,r,e)}static computeDimension(t,e,r,n){const i=rt.round(it.distance(t,e)/n),o=rt.round(it.distance(t,r)/n);let s=Math.floor((i+o)/2)+7;switch(3&s){case 0:s++;break;case 2:s--;break;case 3:throw new D("Dimensions could be not found.")}return s}calculateModuleSize(t,e,r){return(this.calculateModuleSizeOneWay(t,e)+this.calculateModuleSizeOneWay(t,r))/2}calculateModuleSizeOneWay(t,e){const r=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(t.getX()),Math.floor(t.getY()),Math.floor(e.getX()),Math.floor(e.getY())),n=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(e.getX()),Math.floor(e.getY()),Math.floor(t.getX()),Math.floor(t.getY()));return isNaN(r)?n/7:isNaN(n)?r/7:(r+n)/14}sizeOfBlackWhiteBlackRunBothWays(t,e,r,n){let i=this.sizeOfBlackWhiteBlackRun(t,e,r,n),o=1,s=t-(r-t);s<0?(o=t/(t-s),s=0):s>=this.image.getWidth()&&(o=(this.image.getWidth()-1-t)/(s-t),s=this.image.getWidth()-1);let a=Math.floor(e-(n-e)*o);return o=1,a<0?(o=e/(e-a),a=0):a>=this.image.getHeight()&&(o=(this.image.getHeight()-1-e)/(a-e),a=this.image.getHeight()-1),s=Math.floor(t+(s-t)*o),i+=this.sizeOfBlackWhiteBlackRun(t,e,s,a),i-1}sizeOfBlackWhiteBlackRun(t,e,r,n){const i=Math.abs(n-e)>Math.abs(r-t);if(i){let i=t;t=e,e=i,i=r,r=n,n=i}const o=Math.abs(r-t),s=Math.abs(n-e);let a=-o/2;const c=t<r?1:-1,l=e<n?1:-1;let h=0;const u=r+c;for(let r=t,d=e;r!==u;r+=c){const c=i?d:r,u=i?r:d;if(1===h===this.image.get(c,u)){if(2===h)return rt.distance(r,d,t,e);h++}if(a+=s,a>0){if(d===n)break;d+=l,a-=o}}return 2===h?rt.distance(r+c,n,t,e):NaN}findAlignmentInRegion(t,e,r,n){const i=Math.floor(n*t),o=Math.max(0,e-i),s=Math.min(this.image.getWidth()-1,e+i);if(s-o<3*t)throw new D("Alignment top exceeds estimated module size.");const a=Math.max(0,r-i),c=Math.min(this.image.getHeight()-1,r+i);if(c-a<3*t)throw new D("Alignment bottom exceeds estimated module size.");return new Me(this.image,o,a,s-o,c-a,t,this.resultPointCallback).find()}}class Le{constructor(){this.decoder=new Ne}getDecoder(){return this.decoder}decode(t,e){let r,n;if(null!=e&&void 0!==e.get(C.PURE_BARCODE)){const i=Le.extractPureBits(t.getBlackMatrix());r=this.decoder.decodeBitMatrix(i,e),n=Le.NO_POINTS}else{const i=new Be(t.getBlackMatrix()).detect(e);r=this.decoder.decodeBitMatrix(i.getBits(),e),n=i.getPoints()}r.getOther()instanceof ye&&r.getOther().applyMirroredCorrection(n);const i=new x(r.getText(),r.getRawBytes(),void 0,n,U.QR_CODE,void 0),o=r.getByteSegments();null!==o&&i.putMetadata(W.BYTE_SEGMENTS,o);const s=r.getECLevel();return null!==s&&i.putMetadata(W.ERROR_CORRECTION_LEVEL,s),r.hasStructuredAppend()&&(i.putMetadata(W.STRUCTURED_APPEND_SEQUENCE,r.getStructuredAppendSequenceNumber()),i.putMetadata(W.STRUCTURED_APPEND_PARITY,r.getStructuredAppendParity())),i}reset(){}static extractPureBits(t){const e=t.getTopLeftOnBit(),r=t.getBottomRightOnBit();if(null===e||null===r)throw new D;const n=this.moduleSize(e,t);let i=e[1],o=r[1],s=e[0],a=r[0];if(s>=a||i>=o)throw new D;if(o-i!=a-s&&(a=s+(o-i),a>=t.getWidth()))throw new D;const c=Math.round((a-s+1)/n),l=Math.round((o-i+1)/n);if(c<=0||l<=0)throw new D;if(l!==c)throw new D;const h=Math.floor(n/2);i+=h,s+=h;const u=s+Math.floor((c-1)*n)-a;if(u>0){if(u>h)throw new D;s-=u}const d=i+Math.floor((l-1)*n)-o;if(d>0){if(d>h)throw new D;i-=d}const f=new N(c,l);for(let e=0;e<l;e++){const r=i+Math.floor(e*n);for(let i=0;i<c;i++)t.get(s+Math.floor(i*n),r)&&f.set(i,e)}return f}static moduleSize(t,e){const r=e.getHeight(),n=e.getWidth();let i=t[0],o=t[1],s=!0,a=0;for(;i<n&&o<r;){if(s!==e.get(i,o)){if(5==++a)break;s=!s}i++,o++}if(i===n||o===r)throw new D;return(i-t[0])/7}}Le.NO_POINTS=new Array;class Pe{PDF417Common(){}static getBitCountSum(t){return rt.sum(t)}static toIntArray(t){if(null==t||!t.length)return Pe.EMPTY_INT_ARRAY;const e=new Int32Array(t.length);let r=0;for(const n of t)e[r++]=n;return e}static getCodeword(t){const e=w.binarySearch(Pe.SYMBOL_TABLE,262143&t);return e<0?-1:(Pe.CODEWORD_TABLE[e]-1)%Pe.NUMBER_OF_CODEWORDS}}Pe.NUMBER_OF_CODEWORDS=929,Pe.MAX_CODEWORDS_IN_BARCODE=Pe.NUMBER_OF_CODEWORDS-1,Pe.MIN_ROWS_IN_BARCODE=3,Pe.MAX_ROWS_IN_BARCODE=90,Pe.MODULES_IN_CODEWORD=17,Pe.MODULES_IN_STOP_PATTERN=18,Pe.BARS_IN_MODULE=8,Pe.EMPTY_INT_ARRAY=new Int32Array([]),Pe.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]),Pe.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 ve{constructor(t,e){this.bits=t,this.points=e}getBits(){return this.bits}getPoints(){return this.points}}class Fe{static detectMultiple(t,e,r){let n=t.getBlackMatrix(),i=Fe.detect(r,n);return i.length||(n=n.clone(),n.rotate180(),i=Fe.detect(r,n)),new ve(n,i)}static detect(t,e){const r=new Array;let n=0,i=0,o=!1;for(;n<e.getHeight();){const s=Fe.findVertices(e,n,i);if(null!=s[0]||null!=s[3]){if(o=!0,r.push(s),!t)break;null!=s[2]?(i=Math.trunc(s[2].getX()),n=Math.trunc(s[2].getY())):(i=Math.trunc(s[4].getX()),n=Math.trunc(s[4].getY()))}else{if(!o)break;o=!1,i=0;for(const t of r)null!=t[1]&&(n=Math.trunc(Math.max(n,t[1].getY()))),null!=t[3]&&(n=Math.max(n,Math.trunc(t[3].getY())));n+=Fe.ROW_STEP}}return r}static findVertices(t,e,r){const n=t.getHeight(),i=t.getWidth(),o=new Array(8);return Fe.copyToResult(o,Fe.findRowsWithPattern(t,n,i,e,r,Fe.START_PATTERN),Fe.INDEXES_START_PATTERN),null!=o[4]&&(r=Math.trunc(o[4].getX()),e=Math.trunc(o[4].getY())),Fe.copyToResult(o,Fe.findRowsWithPattern(t,n,i,e,r,Fe.STOP_PATTERN),Fe.INDEXES_STOP_PATTERN),o}static copyToResult(t,e,r){for(let n=0;n<r.length;n++)t[r[n]]=e[n]}static findRowsWithPattern(t,e,r,n,i,o){const s=new Array(4);let a=!1;const c=new Int32Array(o.length);for(;n<e;n+=Fe.ROW_STEP){let e=Fe.findGuardPattern(t,i,n,r,!1,o,c);if(null!=e){for(;n>0;){const s=Fe.findGuardPattern(t,i,--n,r,!1,o,c);if(null==s){n++;break}e=s}s[0]=new it(e[0],n),s[1]=new it(e[1],n),a=!0;break}}let l=n+1;if(a){let n=0,i=Int32Array.from([Math.trunc(s[0].getX()),Math.trunc(s[1].getX())]);for(;l<e;l++){const e=Fe.findGuardPattern(t,i[0],l,r,!1,o,c);if(null!=e&&Math.abs(i[0]-e[0])<Fe.MAX_PATTERN_DRIFT&&Math.abs(i[1]-e[1])<Fe.MAX_PATTERN_DRIFT)i=e,n=0;else{if(n>Fe.SKIPPED_ROW_COUNT_MAX)break;n++}}l-=n+1,s[2]=new it(i[0],l),s[3]=new it(i[1],l)}return l-n<Fe.BARCODE_MIN_HEIGHT&&w.fill(s,null),s}static findGuardPattern(t,e,r,n,i,o,s){w.fillWithin(s,0,s.length,0);let a=e,c=0;for(;t.get(a,r)&&a>0&&c++<Fe.MAX_PIXEL_DRIFT;)a--;let l=a,h=0,u=o.length;for(let e=i;l<n;l++)if(t.get(l,r)!==e)s[h]++;else{if(h===u-1){if(Fe.patternMatchVariance(s,o,Fe.MAX_INDIVIDUAL_VARIANCE)<Fe.MAX_AVG_VARIANCE)return new Int32Array([a,l]);a+=s[0]+s[1],d.arraycopy(s,2,s,0,h-1),s[h-1]=0,s[h]=0,h--}else h++;s[h]=1,e=!e}return h===u-1&&Fe.patternMatchVariance(s,o,Fe.MAX_INDIVIDUAL_VARIANCE)<Fe.MAX_AVG_VARIANCE?new Int32Array([a,l-1]):null}static patternMatchVariance(t,e,r){let n=t.length,i=0,o=0;for(let r=0;r<n;r++)i+=t[r],o+=e[r];if(i<o)return 1/0;let s=i/o;r*=s;let a=0;for(let i=0;i<n;i++){let n=t[i],o=e[i]*s,c=n>o?n-o:o-n;if(c>r)return 1/0;a+=c}return a/i}}Fe.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),Fe.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),Fe.MAX_AVG_VARIANCE=.42,Fe.MAX_INDIVIDUAL_VARIANCE=.8,Fe.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),Fe.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),Fe.MAX_PIXEL_DRIFT=3,Fe.MAX_PATTERN_DRIFT=5,Fe.SKIPPED_ROW_COUNT_MAX=25,Fe.ROW_STEP=5,Fe.BARCODE_MIN_HEIGHT=10;class xe{constructor(t,e){if(0===e.length)throw new c;this.field=t;let r=e.length;if(r>1&&0===e[0]){let t=1;for(;t<r&&0===e[t];)t++;t===r?this.coefficients=new Int32Array([0]):(this.coefficients=new Int32Array(r-t),d.arraycopy(e,t,this.coefficients,0,this.coefficients.length))}else this.coefficients=e}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return 0===this.coefficients[0]}getCoefficient(t){return this.coefficients[this.coefficients.length-1-t]}evaluateAt(t){if(0===t)return this.getCoefficient(0);if(1===t){let t=0;for(let e of this.coefficients)t=this.field.add(t,e);return t}let e=this.coefficients[0],r=this.coefficients.length;for(let n=1;n<r;n++)e=this.field.add(this.field.multiply(t,e),this.coefficients[n]);return e}add(t){if(!this.field.equals(t.field))throw new c("ModulusPolys do not have same ModulusGF field");if(this.isZero())return t;if(t.isZero())return this;let e=this.coefficients,r=t.coefficients;if(e.length>r.length){let t=e;e=r,r=t}let n=new Int32Array(r.length),i=r.length-e.length;d.arraycopy(r,0,n,0,i);for(let t=i;t<r.length;t++)n[t]=this.field.add(e[t-i],r[t]);return new xe(this.field,n)}subtract(t){if(!this.field.equals(t.field))throw new c("ModulusPolys do not have same ModulusGF field");return t.isZero()?this:this.add(t.negative())}multiply(t){return t instanceof xe?this.multiplyOther(t):this.multiplyScalar(t)}multiplyOther(t){if(!this.field.equals(t.field))throw new c("ModulusPolys do not have same ModulusGF field");if(this.isZero()||t.isZero())return new xe(this.field,new Int32Array([0]));let e=this.coefficients,r=e.length,n=t.coefficients,i=n.length,o=new Int32Array(r+i-1);for(let t=0;t<r;t++){let r=e[t];for(let e=0;e<i;e++)o[t+e]=this.field.add(o[t+e],this.field.multiply(r,n[e]))}return new xe(this.field,o)}negative(){let t=this.coefficients.length,e=new Int32Array(t);for(let r=0;r<t;r++)e[r]=this.field.subtract(0,this.coefficients[r]);return new xe(this.field,e)}multiplyScalar(t){if(0===t)return new xe(this.field,new Int32Array([0]));if(1===t)return this;let e=this.coefficients.length,r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=this.field.multiply(this.coefficients[n],t);return new xe(this.field,r)}multiplyByMonomial(t,e){if(t<0)throw new c;if(0===e)return new xe(this.field,new Int32Array([0]));let r=this.coefficients.length,n=new Int32Array(r+t);for(let t=0;t<r;t++)n[t]=this.field.multiply(this.coefficients[t],e);return new xe(this.field,n)}toString(){let t=new y;for(let e=this.getDegree();e>=0;e--){let r=this.getCoefficient(e);0!==r&&(r<0?(t.append(" - "),r=-r):t.length()>0&&t.append(" + "),0!==e&&1===r||t.append(r),0!==e&&(1===e?t.append("x"):(t.append("x^"),t.append(e))))}return t.toString()}}class ke{add(t,e){return(t+e)%this.modulus}subtract(t,e){return(this.modulus+t-e)%this.modulus}exp(t){return this.expTable[t]}log(t){if(0===t)throw new c;return this.logTable[t]}inverse(t){if(0===t)throw new K;return this.expTable[this.modulus-this.logTable[t]-1]}multiply(t,e){return 0===t||0===e?0:this.expTable[(this.logTable[t]+this.logTable[e])%(this.modulus-1)]}getSize(){return this.modulus}equals(t){return t===this}}class Ue extends ke{constructor(t,e){super(),this.modulus=t,this.expTable=new Int32Array(t),this.logTable=new Int32Array(t);let r=1;for(let n=0;n<t;n++)this.expTable[n]=r,r=r*e%t;for(let e=0;e<t-1;e++)this.logTable[this.expTable[e]]=e;this.zero=new xe(this,new Int32Array([0])),this.one=new xe(this,new Int32Array([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(t,e){if(t<0)throw new c;if(0===e)return this.zero;let r=new Int32Array(t+1);return r[0]=e,new xe(this,r)}}Ue.PDF417_GF=new Ue(Pe.NUMBER_OF_CODEWORDS,3);class He{constructor(){this.field=Ue.PDF417_GF}decode(t,e,r){let n=new xe(this.field,t),i=new Int32Array(e),o=!1;for(let t=e;t>0;t--){let r=n.evaluateAt(this.field.exp(t));i[e-t]=r,0!==r&&(o=!0)}if(!o)return 0;let s=this.field.getOne();if(null!=r)for(const e of r){let r=this.field.exp(t.length-1-e),n=new xe(this.field,new Int32Array([this.field.subtract(0,r),1]));s=s.multiply(n)}let a=new xe(this.field,i),c=this.runEuclideanAlgorithm(this.field.buildMonomial(e,1),a,e),l=c[0],u=c[1],d=this.findErrorLocations(l),f=this.findErrorMagnitudes(u,l,d);for(let e=0;e<d.length;e++){let r=t.length-1-this.field.log(d[e]);if(r<0)throw h.getChecksumInstance();t[r]=this.field.subtract(t[r],f[e])}return d.length}runEuclideanAlgorithm(t,e,r){if(t.getDegree()<e.getDegree()){let r=t;t=e,e=r}let n=t,i=e,o=this.field.getZero(),s=this.field.getOne();for(;i.getDegree()>=Math.round(r/2);){let t=n,e=o;if(n=i,o=s,n.isZero())throw h.getChecksumInstance();i=t;let r=this.field.getZero(),a=n.getCoefficient(n.getDegree()),c=this.field.inverse(a);for(;i.getDegree()>=n.getDegree()&&!i.isZero();){let t=i.getDegree()-n.getDegree(),e=this.field.multiply(i.getCoefficient(i.getDegree()),c);r=r.add(this.field.buildMonomial(t,e)),i=i.subtract(n.multiplyByMonomial(t,e))}s=r.multiply(o).subtract(e).negative()}let a=s.getCoefficient(0);if(0===a)throw h.getChecksumInstance();let c=this.field.inverse(a);return[s.multiply(c),i.multiply(c)]}findErrorLocations(t){let e=t.getDegree(),r=new Int32Array(e),n=0;for(let i=1;i<this.field.getSize()&&n<e;i++)0===t.evaluateAt(i)&&(r[n]=this.field.inverse(i),n++);if(n!==e)throw h.getChecksumInstance();return r}findErrorMagnitudes(t,e,r){let n=e.getDegree(),i=new Int32Array(n);for(let t=1;t<=n;t++)i[n-t]=this.field.multiply(t,e.getCoefficient(t));let o=new xe(this.field,i),s=r.length,a=new Int32Array(s);for(let e=0;e<s;e++){let n=this.field.inverse(r[e]),i=this.field.subtract(0,t.evaluateAt(n)),s=this.field.inverse(o.evaluateAt(n));a[e]=this.field.multiply(i,s)}return a}}class Ve{constructor(t,e,r,n,i){t instanceof Ve?this.constructor_2(t):this.constructor_1(t,e,r,n,i)}constructor_1(t,e,r,n,i){const o=null==e||null==r,s=null==n||null==i;if(o&&s)throw new D;o?(e=new it(0,n.getY()),r=new it(0,i.getY())):s&&(n=new it(t.getWidth()-1,e.getY()),i=new it(t.getWidth()-1,r.getY())),this.image=t,this.topLeft=e,this.bottomLeft=r,this.topRight=n,this.bottomRight=i,this.minX=Math.trunc(Math.min(e.getX(),r.getX())),this.maxX=Math.trunc(Math.max(n.getX(),i.getX())),this.minY=Math.trunc(Math.min(e.getY(),n.getY())),this.maxY=Math.trunc(Math.max(r.getY(),i.getY()))}constructor_2(t){this.image=t.image,this.topLeft=t.getTopLeft(),this.bottomLeft=t.getBottomLeft(),this.topRight=t.getTopRight(),this.bottomRight=t.getBottomRight(),this.minX=t.getMinX(),this.maxX=t.getMaxX(),this.minY=t.getMinY(),this.maxY=t.getMaxY()}static merge(t,e){return null==t?e:null==e?t:new Ve(t.image,t.topLeft,t.bottomLeft,e.topRight,e.bottomRight)}addMissingRows(t,e,r){let n=this.topLeft,i=this.bottomLeft,o=this.topRight,s=this.bottomRight;if(t>0){let e=r?this.topLeft:this.topRight,i=Math.trunc(e.getY()-t);i<0&&(i=0);let s=new it(e.getX(),i);r?n=s:o=s}if(e>0){let t=r?this.bottomLeft:this.bottomRight,n=Math.trunc(t.getY()+e);n>=this.image.getHeight()&&(n=this.image.getHeight()-1);let o=new it(t.getX(),n);r?i=o:s=o}return new Ve(this.image,n,i,o,s)}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 ze{constructor(t,e,r,n){this.columnCount=t,this.errorCorrectionLevel=n,this.rowCountUpperPart=e,this.rowCountLowerPart=r,this.rowCount=e+r}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class Ge{constructor(){this.buffer=""}static form(t,e){let r=-1;return t.replace(/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g,(function(t,n,i,o,s,a){if("%%"===t)return"%";if(void 0===e[++r])return;t=o?parseInt(o.substr(1)):void 0;let c,l=s?parseInt(s.substr(1)):void 0;switch(a){case"s":c=e[r];break;case"c":c=e[r][0];break;case"f":c=parseFloat(e[r]).toFixed(t);break;case"p":c=parseFloat(e[r]).toPrecision(t);break;case"e":c=parseFloat(e[r]).toExponential(t);break;case"x":c=parseInt(e[r]).toString(l||16);break;case"d":c=parseFloat(parseInt(e[r],l||10).toPrecision(t)).toFixed(0)}c="object"==typeof c?JSON.stringify(c):(+c).toString(l);let h=parseInt(i),u=i&&i[0]+""=="0"?"0":" ";for(;c.length<h;)c=void 0!==n?c+u:u+c;return c}))}format(t,...e){this.buffer+=Ge.form(t,e)}toString(){return this.buffer}}class Ye{constructor(t){this.boundingBox=new Ve(t),this.codewords=new Array(t.getMaxY()-t.getMinY()+1)}getCodewordNearby(t){let e=this.getCodeword(t);if(null!=e)return e;for(let r=1;r<Ye.MAX_NEARBY_DISTANCE;r++){let n=this.imageRowToCodewordIndex(t)-r;if(n>=0&&(e=this.codewords[n],null!=e))return e;if(n=this.imageRowToCodewordIndex(t)+r,n<this.codewords.length&&(e=this.codewords[n],null!=e))return e}return null}imageRowToCodewordIndex(t){return t-this.boundingBox.getMinY()}setCodeword(t,e){this.codewords[this.imageRowToCodewordIndex(t)]=e}getCodeword(t){return this.codewords[this.imageRowToCodewordIndex(t)]}getBoundingBox(){return this.boundingBox}getCodewords(){return this.codewords}toString(){const t=new Ge;let e=0;for(const r of this.codewords)null!=r?t.format("%3d: %3d|%3d%n",e++,r.getRowNumber(),r.getValue()):t.format("%3d: | %n",e++);return t.toString()}}Ye.MAX_NEARBY_DISTANCE=5;class Xe{constructor(){this.values=new Map}setValue(t){t=Math.trunc(t);let e=this.values.get(t);null==e&&(e=0),e++,this.values.set(t,e)}getValue(){let t=-1,e=new Array;for(const[r,n]of this.values.entries()){const i={getKey:()=>r,getValue:()=>n};i.getValue()>t?(t=i.getValue(),e=[],e.push(i.getKey())):i.getValue()===t&&e.push(i.getKey())}return Pe.toIntArray(e)}getConfidence(t){return this.values.get(t)}}class We extends Ye{constructor(t,e){super(t),this._isLeft=e}setRowNumbers(){for(let t of this.getCodewords())null!=t&&t.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(t){let e=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(e,t);let r=this.getBoundingBox(),n=this._isLeft?r.getTopLeft():r.getTopRight(),i=this._isLeft?r.getBottomLeft():r.getBottomRight(),o=this.imageRowToCodewordIndex(Math.trunc(n.getY())),s=this.imageRowToCodewordIndex(Math.trunc(i.getY())),a=-1,c=1,l=0;for(let r=o;r<s;r++){if(null==e[r])continue;let n=e[r],i=n.getRowNumber()-a;if(0===i)l++;else if(1===i)c=Math.max(c,l),l=1,a=n.getRowNumber();else if(i<0||n.getRowNumber()>=t.getRowCount()||i>r)e[r]=null;else{let t;t=c>2?(c-2)*i:i;let o=t>=r;for(let n=1;n<=t&&!o;n++)o=null!=e[r-n];o?e[r]=null:(a=n.getRowNumber(),l=1)}}}getRowHeights(){let t=this.getBarcodeMetadata();if(null==t)return null;this.adjustIncompleteIndicatorColumnRowNumbers(t);let e=new Int32Array(t.getRowCount());for(let t of this.getCodewords())if(null!=t){let r=t.getRowNumber();if(r>=e.length)continue;e[r]++}return e}adjustIncompleteIndicatorColumnRowNumbers(t){let e=this.getBoundingBox(),r=this._isLeft?e.getTopLeft():e.getTopRight(),n=this._isLeft?e.getBottomLeft():e.getBottomRight(),i=this.imageRowToCodewordIndex(Math.trunc(r.getY())),o=this.imageRowToCodewordIndex(Math.trunc(n.getY())),s=this.getCodewords(),a=-1;for(let e=i;e<o;e++){if(null==s[e])continue;let r=s[e];r.setRowNumberAsRowIndicatorColumn();let n=r.getRowNumber()-a;0===n||(1===n?a=r.getRowNumber():r.getRowNumber()>=t.getRowCount()?s[e]=null:a=r.getRowNumber())}}getBarcodeMetadata(){let t=this.getCodewords(),e=new Xe,r=new Xe,n=new Xe,i=new Xe;for(let o of t){if(null==o)continue;o.setRowNumberAsRowIndicatorColumn();let t=o.getValue()%30,s=o.getRowNumber();switch(this._isLeft||(s+=2),s%3){case 0:r.setValue(3*t+1);break;case 1:i.setValue(t/3),n.setValue(t%3);break;case 2:e.setValue(t+1)}}if(0===e.getValue().length||0===r.getValue().length||0===n.getValue().length||0===i.getValue().length||e.getValue()[0]<1||r.getValue()[0]+n.getValue()[0]<Pe.MIN_ROWS_IN_BARCODE||r.getValue()[0]+n.getValue()[0]>Pe.MAX_ROWS_IN_BARCODE)return null;let o=new ze(e.getValue()[0],r.getValue()[0],n.getValue()[0],i.getValue()[0]);return this.removeIncorrectCodewords(t,o),o}removeIncorrectCodewords(t,e){for(let r=0;r<t.length;r++){let n=t[r];if(null==t[r])continue;let i=n.getValue()%30,o=n.getRowNumber();if(o>e.getRowCount())t[r]=null;else switch(this._isLeft||(o+=2),o%3){case 0:3*i+1!==e.getRowCountUpperPart()&&(t[r]=null);break;case 1:Math.trunc(i/3)===e.getErrorCorrectionLevel()&&i%3===e.getRowCountLowerPart()||(t[r]=null);break;case 2:i+1!==e.getColumnCount()&&(t[r]=null)}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+"\n"+super.toString()}}class je{constructor(t,e){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=t,this.barcodeColumnCount=t.getColumnCount(),this.boundingBox=e,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let t,e=Pe.MAX_CODEWORDS_IN_BARCODE;do{t=e,e=this.adjustRowNumbersAndGetCount()}while(e>0&&e<t);return this.detectionResultColumns}adjustIndicatorColumnRowNumbers(t){null!=t&&t.adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata)}adjustRowNumbersAndGetCount(){let t=this.adjustRowNumbersByRow();if(0===t)return 0;for(let t=1;t<this.barcodeColumnCount+1;t++){let e=this.detectionResultColumns[t].getCodewords();for(let r=0;r<e.length;r++)null!=e[r]&&(e[r].hasValidRowNumber()||this.adjustRowNumbers(t,r,e))}return t}adjustRowNumbersByRow(){return this.adjustRowNumbersFromBothRI(),this.adjustRowNumbersFromLRI()+this.adjustRowNumbersFromRRI()}adjustRowNumbersFromBothRI(){if(null==this.detectionResultColumns[0]||null==this.detectionResultColumns[this.barcodeColumnCount+1])return;let t=this.detectionResultColumns[0].getCodewords(),e=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let r=0;r<t.length;r++)if(null!=t[r]&&null!=e[r]&&t[r].getRowNumber()===e[r].getRowNumber())for(let e=1;e<=this.barcodeColumnCount;e++){let n=this.detectionResultColumns[e].getCodewords()[r];null!=n&&(n.setRowNumber(t[r].getRowNumber()),n.hasValidRowNumber()||(this.detectionResultColumns[e].getCodewords()[r]=null))}}adjustRowNumbersFromRRI(){if(null==this.detectionResultColumns[this.barcodeColumnCount+1])return 0;let t=0,e=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let r=0;r<e.length;r++){if(null==e[r])continue;let n=e[r].getRowNumber(),i=0;for(let e=this.barcodeColumnCount+1;e>0&&i<this.ADJUST_ROW_NUMBER_SKIP;e--){let o=this.detectionResultColumns[e].getCodewords()[r];null!=o&&(i=je.adjustRowNumberIfValid(n,i,o),o.hasValidRowNumber()||t++)}}return t}adjustRowNumbersFromLRI(){if(null==this.detectionResultColumns[0])return 0;let t=0,e=this.detectionResultColumns[0].getCodewords();for(let r=0;r<e.length;r++){if(null==e[r])continue;let n=e[r].getRowNumber(),i=0;for(let e=1;e<this.barcodeColumnCount+1&&i<this.ADJUST_ROW_NUMBER_SKIP;e++){let o=this.detectionResultColumns[e].getCodewords()[r];null!=o&&(i=je.adjustRowNumberIfValid(n,i,o),o.hasValidRowNumber()||t++)}}return t}static adjustRowNumberIfValid(t,e,r){return null==r||r.hasValidRowNumber()||(r.isValidRowNumber(t)?(r.setRowNumber(t),e=0):++e),e}adjustRowNumbers(t,e,r){if(!this.detectionResultColumns[t-1])return;let n=r[e],i=this.detectionResultColumns[t-1].getCodewords(),o=i;null!=this.detectionResultColumns[t+1]&&(o=this.detectionResultColumns[t+1].getCodewords());let s=new Array(14);s[2]=i[e],s[3]=o[e],e>0&&(s[0]=r[e-1],s[4]=i[e-1],s[5]=o[e-1]),e>1&&(s[8]=r[e-2],s[10]=i[e-2],s[11]=o[e-2]),e<r.length-1&&(s[1]=r[e+1],s[6]=i[e+1],s[7]=o[e+1]),e<r.length-2&&(s[9]=r[e+2],s[12]=i[e+2],s[13]=o[e+2]);for(let t of s)if(je.adjustRowNumber(n,t))return}static adjustRowNumber(t,e){return!(null==e||!e.hasValidRowNumber()||e.getBucket()!==t.getBucket()||(t.setRowNumber(e.getRowNumber()),0))}getBarcodeColumnCount(){return this.barcodeColumnCount}getBarcodeRowCount(){return this.barcodeMetadata.getRowCount()}getBarcodeECLevel(){return this.barcodeMetadata.getErrorCorrectionLevel()}setBoundingBox(t){this.boundingBox=t}getBoundingBox(){return this.boundingBox}setDetectionResultColumn(t,e){this.detectionResultColumns[t]=e}getDetectionResultColumn(t){return this.detectionResultColumns[t]}toString(){let t=this.detectionResultColumns[0];null==t&&(t=this.detectionResultColumns[this.barcodeColumnCount+1]);let e=new Ge;for(let r=0;r<t.getCodewords().length;r++){e.format("CW %3d:",r);for(let t=0;t<this.barcodeColumnCount+2;t++){if(null==this.detectionResultColumns[t]){e.format(" | ");continue}let n=this.detectionResultColumns[t].getCodewords()[r];null!=n?e.format(" %3d|%3d",n.getRowNumber(),n.getValue()):e.format(" | ")}e.format("%n")}return e.toString()}}class Ze{constructor(t,e,r,n){this.rowNumber=Ze.BARCODE_ROW_UNKNOWN,this.startX=Math.trunc(t),this.endX=Math.trunc(e),this.bucket=Math.trunc(r),this.value=Math.trunc(n)}hasValidRowNumber(){return this.isValidRowNumber(this.rowNumber)}isValidRowNumber(t){return t!==Ze.BARCODE_ROW_UNKNOWN&&this.bucket===t%3*3}setRowNumberAsRowIndicatorColumn(){this.rowNumber=Math.trunc(3*Math.trunc(this.value/30)+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(t){this.rowNumber=t}toString(){return this.rowNumber+"|"+this.value}}Ze.BARCODE_ROW_UNKNOWN=-1;class Qe{static initialize(){for(let t=0;t<Pe.SYMBOL_TABLE.length;t++){let e=Pe.SYMBOL_TABLE[t],r=1&e;for(let n=0;n<Pe.BARS_IN_MODULE;n++){let i=0;for(;(1&e)===r;)i+=1,e>>=1;r=1&e,Qe.RATIOS_TABLE[t]||(Qe.RATIOS_TABLE[t]=new Array(Pe.BARS_IN_MODULE)),Qe.RATIOS_TABLE[t][Pe.BARS_IN_MODULE-n-1]=Math.fround(i/Pe.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(t){let e=Qe.getDecodedCodewordValue(Qe.sampleBitCounts(t));return-1!==e?e:Qe.getClosestDecodedValue(t)}static sampleBitCounts(t){let e=rt.sum(t),r=new Int32Array(Pe.BARS_IN_MODULE),n=0,i=0;for(let o=0;o<Pe.MODULES_IN_CODEWORD;o++){let s=e/(2*Pe.MODULES_IN_CODEWORD)+o*e/Pe.MODULES_IN_CODEWORD;i+t[n]<=s&&(i+=t[n],n++),r[n]++}return r}static getDecodedCodewordValue(t){let e=Qe.getBitValue(t);return-1===Pe.getCodeword(e)?-1:e}static getBitValue(t){let e=0;for(let r=0;r<t.length;r++)for(let n=0;n<t[r];n++)e=e<<1|(r%2==0?1:0);return Math.trunc(e)}static getClosestDecodedValue(t){let e=rt.sum(t),r=new Array(Pe.BARS_IN_MODULE);if(e>1)for(let n=0;n<r.length;n++)r[n]=Math.fround(t[n]/e);let n=nt.MAX_VALUE,i=-1;this.bSymbolTableReady||Qe.initialize();for(let t=0;t<Qe.RATIOS_TABLE.length;t++){let e=0,o=Qe.RATIOS_TABLE[t];for(let t=0;t<Pe.BARS_IN_MODULE;t++){let i=Math.fround(o[t]-r[t]);if(e+=Math.fround(i*i),e>=n)break}e<n&&(n=e,i=Pe.SYMBOL_TABLE[t])}return i}}Qe.bSymbolTableReady=!1,Qe.RATIOS_TABLE=new Array(Pe.SYMBOL_TABLE.length).map((t=>new Array(Pe.BARS_IN_MODULE)));class Ke{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(t){this.segmentIndex=t}getFileId(){return this.fileId}setFileId(t){this.fileId=t}getOptionalData(){return this.optionalData}setOptionalData(t){this.optionalData=t}isLastSegment(){return this.lastSegment}setLastSegment(t){this.lastSegment=t}getSegmentCount(){return this.segmentCount}setSegmentCount(t){this.segmentCount=t}getSender(){return this.sender||null}setSender(t){this.sender=t}getAddressee(){return this.addressee||null}setAddressee(t){this.addressee=t}getFileName(){return this.fileName}setFileName(t){this.fileName=t}getFileSize(){return this.fileSize}setFileSize(t){this.fileSize=t}getChecksum(){return this.checksum}setChecksum(t){this.checksum=t}getTimestamp(){return this.timestamp}setTimestamp(t){this.timestamp=t}}class qe{static parseLong(t,e=undefined){return parseInt(t,e)}}class Je extends s{}Je.kind="NullPointerException";class $e{writeBytes(t){this.writeBytesOffset(t,0,t.length)}writeBytesOffset(t,e,r){if(null==t)throw new Je;if(e<0||e>t.length||r<0||e+r>t.length||e+r<0)throw new f;if(0!==r)for(let n=0;n<r;n++)this.write(t[e+n])}flush(){}close(){}}class tr extends s{}class er extends $e{constructor(t=32){if(super(),this.count=0,t<0)throw new c("Negative initial size: "+t);this.buf=new Uint8Array(t)}ensureCapacity(t){t-this.buf.length>0&&this.grow(t)}grow(t){let e=this.buf.length<<1;if(e-t<0&&(e=t),e<0){if(t<0)throw new tr;e=m.MAX_VALUE}this.buf=w.copyOfUint8Array(this.buf,e)}write(t){this.ensureCapacity(this.count+1),this.buf[this.count]=t,this.count+=1}writeBytesOffset(t,e,r){if(e<0||e>t.length||r<0||e+r-t.length>0)throw new f;this.ensureCapacity(this.count+r),d.arraycopy(t,e,this.buf,this.count,r),this.count+=r}writeTo(t){t.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return w.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(t){return t?"string"==typeof t?this.toString_string(t):this.toString_number(t):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(t){return new String(this.buf).toString()}toString_number(t){return new String(this.buf).toString()}close(){}}function rr(){if("undefined"!=typeof window)return window.BigInt||null;if(void 0!==r.g)return r.g.BigInt||null;if("undefined"!=typeof self)return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let nr;function ir(t){if(void 0===nr&&(nr=rr()),null===nr)throw new Error("BigInt is not supported!");return nr(t)}!function(t){t[t.ALPHA=0]="ALPHA",t[t.LOWER=1]="LOWER",t[t.MIXED=2]="MIXED",t[t.PUNCT=3]="PUNCT",t[t.ALPHA_SHIFT=4]="ALPHA_SHIFT",t[t.PUNCT_SHIFT=5]="PUNCT_SHIFT"}(X||(X={}));class or{static decode(t,e){let r=new y(""),n=I.ISO8859_1;r.enableDecoding(n);let i=1,o=t[i++],s=new Ke;for(;i<t[0];){switch(o){case or.TEXT_COMPACTION_MODE_LATCH:i=or.textCompaction(t,i,r);break;case or.BYTE_COMPACTION_MODE_LATCH:case or.BYTE_COMPACTION_MODE_LATCH_6:i=or.byteCompaction(o,t,n,i,r);break;case or.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r.append(t[i++]);break;case or.NUMERIC_COMPACTION_MODE_LATCH:i=or.numericCompaction(t,i,r);break;case or.ECI_CHARSET:I.getCharacterSetECIByValue(t[i++]);break;case or.ECI_GENERAL_PURPOSE:i+=2;break;case or.ECI_USER_DEFINED:i++;break;case or.BEGIN_MACRO_PDF417_CONTROL_BLOCK:i=or.decodeMacroBlock(t,i,s);break;case or.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case or.MACRO_PDF417_TERMINATOR:throw new E;default:i--,i=or.textCompaction(t,i,r)}if(!(i<t.length))throw E.getFormatInstance();o=t[i++]}if(0===r.length())throw E.getFormatInstance();let a=new j(null,r.toString(),null,e);return a.setOther(s),a}static decodeMacroBlock(t,e,r){if(e+or.NUMBER_OF_SEQUENCE_CODEWORDS>t[0])throw E.getFormatInstance();let n=new Int32Array(or.NUMBER_OF_SEQUENCE_CODEWORDS);for(let r=0;r<or.NUMBER_OF_SEQUENCE_CODEWORDS;r++,e++)n[r]=t[e];r.setSegmentIndex(m.parseInt(or.decodeBase900toBase10(n,or.NUMBER_OF_SEQUENCE_CODEWORDS)));let i=new y;e=or.textCompaction(t,e,i),r.setFileId(i.toString());let o=-1;for(t[e]===or.BEGIN_MACRO_PDF417_OPTIONAL_FIELD&&(o=e+1);e<t[0];)switch(t[e]){case or.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:switch(t[++e]){case or.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:let n=new y;e=or.textCompaction(t,e+1,n),r.setFileName(n.toString());break;case or.MACRO_PDF417_OPTIONAL_FIELD_SENDER:let i=new y;e=or.textCompaction(t,e+1,i),r.setSender(i.toString());break;case or.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:let o=new y;e=or.textCompaction(t,e+1,o),r.setAddressee(o.toString());break;case or.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:let s=new y;e=or.numericCompaction(t,e+1,s),r.setSegmentCount(m.parseInt(s.toString()));break;case or.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:let a=new y;e=or.numericCompaction(t,e+1,a),r.setTimestamp(qe.parseLong(a.toString()));break;case or.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:let c=new y;e=or.numericCompaction(t,e+1,c),r.setChecksum(m.parseInt(c.toString()));break;case or.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:let l=new y;e=or.numericCompaction(t,e+1,l),r.setFileSize(qe.parseLong(l.toString()));break;default:throw E.getFormatInstance()}break;case or.MACRO_PDF417_TERMINATOR:e++,r.setLastSegment(!0);break;default:throw E.getFormatInstance()}if(-1!==o){let n=e-o;r.isLastSegment()&&n--,r.setOptionalData(w.copyOfRange(t,o,o+n))}return e}static textCompaction(t,e,r){let n=new Int32Array(2*(t[0]-e)),i=new Int32Array(2*(t[0]-e)),o=0,s=!1;for(;e<t[0]&&!s;){let r=t[e++];if(r<or.TEXT_COMPACTION_MODE_LATCH)n[o]=r/30,n[o+1]=r%30,o+=2;else switch(r){case or.TEXT_COMPACTION_MODE_LATCH:n[o++]=or.TEXT_COMPACTION_MODE_LATCH;break;case or.BYTE_COMPACTION_MODE_LATCH:case or.BYTE_COMPACTION_MODE_LATCH_6:case or.NUMERIC_COMPACTION_MODE_LATCH:case or.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case or.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case or.MACRO_PDF417_TERMINATOR:e--,s=!0;break;case or.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n[o]=or.MODE_SHIFT_TO_BYTE_COMPACTION_MODE,r=t[e++],i[o]=r,o++}}return or.decodeTextCompaction(n,i,o,r),e}static decodeTextCompaction(t,e,r,n){let i=X.ALPHA,o=X.ALPHA,s=0;for(;s<r;){let r=t[s],a="";switch(i){case X.ALPHA:if(r<26)a=String.fromCharCode(65+r);else switch(r){case 26:a=" ";break;case or.LL:i=X.LOWER;break;case or.ML:i=X.MIXED;break;case or.PS:o=i,i=X.PUNCT_SHIFT;break;case or.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n.append(e[s]);break;case or.TEXT_COMPACTION_MODE_LATCH:i=X.ALPHA}break;case X.LOWER:if(r<26)a=String.fromCharCode(97+r);else switch(r){case 26:a=" ";break;case or.AS:o=i,i=X.ALPHA_SHIFT;break;case or.ML:i=X.MIXED;break;case or.PS:o=i,i=X.PUNCT_SHIFT;break;case or.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n.append(e[s]);break;case or.TEXT_COMPACTION_MODE_LATCH:i=X.ALPHA}break;case X.MIXED:if(r<or.PL)a=or.MIXED_CHARS[r];else switch(r){case or.PL:i=X.PUNCT;break;case 26:a=" ";break;case or.LL:i=X.LOWER;break;case or.AL:i=X.ALPHA;break;case or.PS:o=i,i=X.PUNCT_SHIFT;break;case or.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n.append(e[s]);break;case or.TEXT_COMPACTION_MODE_LATCH:i=X.ALPHA}break;case X.PUNCT:if(r<or.PAL)a=or.PUNCT_CHARS[r];else switch(r){case or.PAL:i=X.ALPHA;break;case or.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n.append(e[s]);break;case or.TEXT_COMPACTION_MODE_LATCH:i=X.ALPHA}break;case X.ALPHA_SHIFT:if(i=o,r<26)a=String.fromCharCode(65+r);else switch(r){case 26:a=" ";break;case or.TEXT_COMPACTION_MODE_LATCH:i=X.ALPHA}break;case X.PUNCT_SHIFT:if(i=o,r<or.PAL)a=or.PUNCT_CHARS[r];else switch(r){case or.PAL:i=X.ALPHA;break;case or.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n.append(e[s]);break;case or.TEXT_COMPACTION_MODE_LATCH:i=X.ALPHA}}""!==a&&n.append(a),s++}}static byteCompaction(t,e,r,n,i){let o=new er,s=0,a=0,c=!1;switch(t){case or.BYTE_COMPACTION_MODE_LATCH:let t=new Int32Array(6),r=e[n++];for(;n<e[0]&&!c;)switch(t[s++]=r,a=900*a+r,r=e[n++],r){case or.TEXT_COMPACTION_MODE_LATCH:case or.BYTE_COMPACTION_MODE_LATCH:case or.NUMERIC_COMPACTION_MODE_LATCH:case or.BYTE_COMPACTION_MODE_LATCH_6:case or.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case or.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case or.MACRO_PDF417_TERMINATOR:n--,c=!0;break;default:if(s%5==0&&s>0){for(let t=0;t<6;++t)o.write(Number(ir(a)>>ir(8*(5-t))));a=0,s=0}}n===e[0]&&r<or.TEXT_COMPACTION_MODE_LATCH&&(t[s++]=r);for(let e=0;e<s;e++)o.write(t[e]);break;case or.BYTE_COMPACTION_MODE_LATCH_6:for(;n<e[0]&&!c;){let t=e[n++];if(t<or.TEXT_COMPACTION_MODE_LATCH)s++,a=900*a+t;else switch(t){case or.TEXT_COMPACTION_MODE_LATCH:case or.BYTE_COMPACTION_MODE_LATCH:case or.NUMERIC_COMPACTION_MODE_LATCH:case or.BYTE_COMPACTION_MODE_LATCH_6:case or.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case or.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case or.MACRO_PDF417_TERMINATOR:n--,c=!0}if(s%5==0&&s>0){for(let t=0;t<6;++t)o.write(Number(ir(a)>>ir(8*(5-t))));a=0,s=0}}}return i.append(_.decode(o.toByteArray(),r)),n}static numericCompaction(t,e,r){let n=0,i=!1,o=new Int32Array(or.MAX_NUMERIC_CODEWORDS);for(;e<t[0]&&!i;){let s=t[e++];if(e===t[0]&&(i=!0),s<or.TEXT_COMPACTION_MODE_LATCH)o[n]=s,n++;else switch(s){case or.TEXT_COMPACTION_MODE_LATCH:case or.BYTE_COMPACTION_MODE_LATCH:case or.BYTE_COMPACTION_MODE_LATCH_6:case or.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case or.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case or.MACRO_PDF417_TERMINATOR:e--,i=!0}(n%or.MAX_NUMERIC_CODEWORDS==0||s===or.NUMERIC_COMPACTION_MODE_LATCH||i)&&n>0&&(r.append(or.decodeBase900toBase10(o,n)),n=0)}return e}static decodeBase900toBase10(t,e){let r=ir(0);for(let n=0;n<e;n++)r+=or.EXP900[e-n-1]*ir(t[n]);let n=r.toString();if("1"!==n.charAt(0))throw new E;return n.substring(1)}}or.TEXT_COMPACTION_MODE_LATCH=900,or.BYTE_COMPACTION_MODE_LATCH=901,or.NUMERIC_COMPACTION_MODE_LATCH=902,or.BYTE_COMPACTION_MODE_LATCH_6=924,or.ECI_USER_DEFINED=925,or.ECI_GENERAL_PURPOSE=926,or.ECI_CHARSET=927,or.BEGIN_MACRO_PDF417_CONTROL_BLOCK=928,or.BEGIN_MACRO_PDF417_OPTIONAL_FIELD=923,or.MACRO_PDF417_TERMINATOR=922,or.MODE_SHIFT_TO_BYTE_COMPACTION_MODE=913,or.MAX_NUMERIC_CODEWORDS=15,or.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME=0,or.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT=1,or.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP=2,or.MACRO_PDF417_OPTIONAL_FIELD_SENDER=3,or.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE=4,or.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE=5,or.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM=6,or.PL=25,or.LL=27,or.AS=27,or.ML=28,or.AL=28,or.PS=29,or.PAL=29,or.PUNCT_CHARS=";<>@[\\]_`~!\r\t,:\n-.$/\"|*()?{}'",or.MIXED_CHARS="0123456789&\r\t,:#-.$/+%*=^",or.EXP900=rr()?function(){let t=[];t[0]=ir(1);let e=ir(900);t[1]=e;for(let r=2;r<16;r++)t[r]=t[r-1]*e;return t}():[],or.NUMBER_OF_SEQUENCE_CODEWORDS=2;class sr{constructor(){}static decode(t,e,r,n,i,o,s){let a,c=new Ve(t,e,r,n,i),l=null,h=null;for(let r=!0;;r=!1){if(null!=e&&(l=sr.getRowIndicatorColumn(t,c,e,!0,o,s)),null!=n&&(h=sr.getRowIndicatorColumn(t,c,n,!1,o,s)),a=sr.merge(l,h),null==a)throw D.getNotFoundInstance();let i=a.getBoundingBox();if(!r||null==i||!(i.getMinY()<c.getMinY()||i.getMaxY()>c.getMaxY()))break;c=i}a.setBoundingBox(c);let u=a.getBarcodeColumnCount()+1;a.setDetectionResultColumn(0,l),a.setDetectionResultColumn(u,h);let d=null!=l;for(let e=1;e<=u;e++){let r,n=d?e:u-e;if(void 0!==a.getDetectionResultColumn(n))continue;r=0===n||n===u?new We(c,0===n):new Ye(c),a.setDetectionResultColumn(n,r);let i=-1,l=i;for(let e=c.getMinY();e<=c.getMaxY();e++){if(i=sr.getStartColumn(a,n,e,d),i<0||i>c.getMaxX()){if(-1===l)continue;i=l}let h=sr.detectCodeword(t,c.getMinX(),c.getMaxX(),d,i,e,o,s);null!=h&&(r.setCodeword(e,h),l=i,o=Math.min(o,h.getWidth()),s=Math.max(s,h.getWidth()))}}return sr.createDecoderResult(a)}static merge(t,e){if(null==t&&null==e)return null;let r=sr.getBarcodeMetadata(t,e);if(null==r)return null;let n=Ve.merge(sr.adjustBoundingBox(t),sr.adjustBoundingBox(e));return new je(r,n)}static adjustBoundingBox(t){if(null==t)return null;let e=t.getRowHeights();if(null==e)return null;let r=sr.getMax(e),n=0;for(let t of e)if(n+=r-t,t>0)break;let i=t.getCodewords();for(let t=0;n>0&&null==i[t];t++)n--;let o=0;for(let t=e.length-1;t>=0&&(o+=r-e[t],!(e[t]>0));t--);for(let t=i.length-1;o>0&&null==i[t];t--)o--;return t.getBoundingBox().addMissingRows(n,o,t.isLeft())}static getMax(t){let e=-1;for(let r of t)e=Math.max(e,r);return e}static getBarcodeMetadata(t,e){let r,n;return null==t||null==(r=t.getBarcodeMetadata())?null==e?null:e.getBarcodeMetadata():null==e||null==(n=e.getBarcodeMetadata())?r:r.getColumnCount()!==n.getColumnCount()&&r.getErrorCorrectionLevel()!==n.getErrorCorrectionLevel()&&r.getRowCount()!==n.getRowCount()?null:r}static getRowIndicatorColumn(t,e,r,n,i,o){let s=new We(e,n);for(let a=0;a<2;a++){let c=0===a?1:-1,l=Math.trunc(Math.trunc(r.getX()));for(let a=Math.trunc(Math.trunc(r.getY()));a<=e.getMaxY()&&a>=e.getMinY();a+=c){let e=sr.detectCodeword(t,0,t.getWidth(),n,l,a,i,o);null!=e&&(s.setCodeword(a,e),l=n?e.getStartX():e.getEndX())}}return s}static adjustCodewordCount(t,e){let r=e[0][1],n=r.getValue(),i=t.getBarcodeColumnCount()*t.getBarcodeRowCount()-sr.getNumberOfECCodeWords(t.getBarcodeECLevel());if(0===n.length){if(i<1||i>Pe.MAX_CODEWORDS_IN_BARCODE)throw D.getNotFoundInstance();r.setValue(i)}else n[0]!==i&&r.setValue(i)}static createDecoderResult(t){let e=sr.createBarcodeMatrix(t);sr.adjustCodewordCount(t,e);let r=new Array,n=new Int32Array(t.getBarcodeRowCount()*t.getBarcodeColumnCount()),i=[],o=new Array;for(let s=0;s<t.getBarcodeRowCount();s++)for(let a=0;a<t.getBarcodeColumnCount();a++){let c=e[s][a+1].getValue(),l=s*t.getBarcodeColumnCount()+a;0===c.length?r.push(l):1===c.length?n[l]=c[0]:(o.push(l),i.push(c))}let s=new Array(i.length);for(let t=0;t<s.length;t++)s[t]=i[t];return sr.createDecoderResultFromAmbiguousValues(t.getBarcodeECLevel(),n,Pe.toIntArray(r),Pe.toIntArray(o),s)}static createDecoderResultFromAmbiguousValues(t,e,r,n,i){let o=new Int32Array(n.length),s=100;for(;s-- >0;){for(let t=0;t<o.length;t++)e[n[t]]=i[t][o[t]];try{return sr.decodeCodewords(e,t,r)}catch(t){if(!(t instanceof h))throw t}if(0===o.length)throw h.getChecksumInstance();for(let t=0;t<o.length;t++){if(o[t]<i[t].length-1){o[t]++;break}if(o[t]=0,t===o.length-1)throw h.getChecksumInstance()}}throw h.getChecksumInstance()}static createBarcodeMatrix(t){let e=Array.from({length:t.getBarcodeRowCount()},(()=>new Array(t.getBarcodeColumnCount()+2)));for(let t=0;t<e.length;t++)for(let r=0;r<e[t].length;r++)e[t][r]=new Xe;let r=0;for(let n of t.getDetectionResultColumns()){if(null!=n)for(let t of n.getCodewords())if(null!=t){let n=t.getRowNumber();if(n>=0){if(n>=e.length)continue;e[n][r].setValue(t.getValue())}}r++}return e}static isValidBarcodeColumn(t,e){return e>=0&&e<=t.getBarcodeColumnCount()+1}static getStartColumn(t,e,r,n){let i=n?1:-1,o=null;if(sr.isValidBarcodeColumn(t,e-i)&&(o=t.getDetectionResultColumn(e-i).getCodeword(r)),null!=o)return n?o.getEndX():o.getStartX();if(o=t.getDetectionResultColumn(e).getCodewordNearby(r),null!=o)return n?o.getStartX():o.getEndX();if(sr.isValidBarcodeColumn(t,e-i)&&(o=t.getDetectionResultColumn(e-i).getCodewordNearby(r)),null!=o)return n?o.getEndX():o.getStartX();let s=0;for(;sr.isValidBarcodeColumn(t,e-i);){e-=i;for(let r of t.getDetectionResultColumn(e).getCodewords())if(null!=r)return(n?r.getEndX():r.getStartX())+i*s*(r.getEndX()-r.getStartX());s++}return n?t.getBoundingBox().getMinX():t.getBoundingBox().getMaxX()}static detectCodeword(t,e,r,n,i,o,s,a){i=sr.adjustCodewordStartColumn(t,e,r,n,i,o);let c,l=sr.getModuleBitCount(t,e,r,n,i,o);if(null==l)return null;let h=rt.sum(l);if(n)c=i+h;else{for(let t=0;t<l.length/2;t++){let e=l[t];l[t]=l[l.length-1-t],l[l.length-1-t]=e}c=i,i=c-h}if(!sr.checkCodewordSkew(h,s,a))return null;let u=Qe.getDecodedValue(l),d=Pe.getCodeword(u);return-1===d?null:new Ze(i,c,sr.getCodewordBucketNumber(u),d)}static getModuleBitCount(t,e,r,n,i,o){let s=i,a=new Int32Array(8),c=0,l=n?1:-1,h=n;for(;(n?s<r:s>=e)&&c<a.length;)t.get(s,o)===h?(a[c]++,s+=l):(c++,h=!h);return c===a.length||s===(n?r:e)&&c===a.length-1?a:null}static getNumberOfECCodeWords(t){return 2<<t}static adjustCodewordStartColumn(t,e,r,n,i,o){let s=i,a=n?-1:1;for(let c=0;c<2;c++){for(;(n?s>=e:s<r)&&n===t.get(s,o);){if(Math.abs(i-s)>sr.CODEWORD_SKEW_SIZE)return i;s+=a}a=-a,n=!n}return s}static checkCodewordSkew(t,e,r){return e-sr.CODEWORD_SKEW_SIZE<=t&&t<=r+sr.CODEWORD_SKEW_SIZE}static decodeCodewords(t,e,r){if(0===t.length)throw E.getFormatInstance();let n=1<<e+1,i=sr.correctErrors(t,r,n);sr.verifyCodewordCount(t,n);let o=or.decode(t,""+e);return o.setErrorsCorrected(i),o.setErasures(r.length),o}static correctErrors(t,e,r){if(null!=e&&e.length>r/2+sr.MAX_ERRORS||r<0||r>sr.MAX_EC_CODEWORDS)throw h.getChecksumInstance();return sr.errorCorrection.decode(t,r,e)}static verifyCodewordCount(t,e){if(t.length<4)throw E.getFormatInstance();let r=t[0];if(r>t.length)throw E.getFormatInstance();if(0===r){if(!(e<t.length))throw E.getFormatInstance();t[0]=t.length-e}}static getBitCountForCodeword(t){let e=new Int32Array(8),r=0,n=e.length-1;for(;!((1&t)!==r&&(r=1&t,n--,n<0));)e[n]++,t>>=1;return e}static getCodewordBucketNumber(t){return t instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(t):this.getCodewordBucketNumber_number(t)}static getCodewordBucketNumber_number(t){return sr.getCodewordBucketNumber(sr.getBitCountForCodeword(t))}static getCodewordBucketNumber_Int32Array(t){return(t[0]-t[2]+t[4]-t[6]+9)%9}static toString(t){let e=new Ge;for(let r=0;r<t.length;r++){e.format("Row %2d: ",r);for(let n=0;n<t[r].length;n++){let i=t[r][n];0===i.getValue().length?e.format(" ",null):e.format("%4d(%2d)",i.getValue()[0],i.getConfidence(i.getValue()[0]))}e.format("%n")}return e.toString()}}sr.CODEWORD_SKEW_SIZE=2,sr.MAX_ERRORS=3,sr.MAX_EC_CODEWORDS=512,sr.errorCorrection=new He;class ar{decode(t,e=null){let r=ar.decode(t,e,!1);if(null==r||0===r.length||null==r[0])throw D.getNotFoundInstance();return r[0]}decodeMultiple(t,e=null){try{return ar.decode(t,e,!0)}catch(t){if(t instanceof E||t instanceof h)throw D.getNotFoundInstance();throw t}}static decode(t,e,r){const n=new Array,i=Fe.detectMultiple(t,e,r);for(const t of i.getPoints()){const e=sr.decode(i.getBits(),t[4],t[5],t[6],t[7],ar.getMinCodewordWidth(t),ar.getMaxCodewordWidth(t)),r=new x(e.getText(),e.getRawBytes(),void 0,t,U.PDF_417);r.putMetadata(W.ERROR_CORRECTION_LEVEL,e.getECLevel());const o=e.getOther();null!=o&&r.putMetadata(W.PDF417_EXTRA_METADATA,o),n.push(r)}return n.map((t=>t))}static getMaxWidth(t,e){return null==t||null==e?0:Math.trunc(Math.abs(t.getX()-e.getX()))}static getMinWidth(t,e){return null==t||null==e?m.MAX_VALUE:Math.trunc(Math.abs(t.getX()-e.getX()))}static getMaxCodewordWidth(t){return Math.floor(Math.max(Math.max(ar.getMaxWidth(t[0],t[4]),ar.getMaxWidth(t[6],t[2])*Pe.MODULES_IN_CODEWORD/Pe.MODULES_IN_STOP_PATTERN),Math.max(ar.getMaxWidth(t[1],t[5]),ar.getMaxWidth(t[7],t[3])*Pe.MODULES_IN_CODEWORD/Pe.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(t){return Math.floor(Math.min(Math.min(ar.getMinWidth(t[0],t[4]),ar.getMinWidth(t[6],t[2])*Pe.MODULES_IN_CODEWORD/Pe.MODULES_IN_STOP_PATTERN),Math.min(ar.getMinWidth(t[1],t[5]),ar.getMinWidth(t[7],t[3])*Pe.MODULES_IN_CODEWORD/Pe.MODULES_IN_STOP_PATTERN)))}reset(){}}class cr extends s{}cr.kind="ReaderException";class lr{constructor(t,e){this.verbose=!0===t,e&&this.setHints(e)}decode(t,e){return e&&this.setHints(e),this.decodeInternal(t)}decodeWithState(t){return null!==this.readers&&void 0!==this.readers||this.setHints(null),this.decodeInternal(t)}setHints(t){this.hints=t;const r=!e(t)&&!0===t.get(C.TRY_HARDER),n=e(t)?null:t.get(C.POSSIBLE_FORMATS),i=new Array;if(!e(n)){const e=n.some((t=>t===U.UPC_A||t===U.UPC_E||t===U.EAN_13||t===U.EAN_8||t===U.CODABAR||t===U.CODE_39||t===U.CODE_93||t===U.CODE_128||t===U.ITF||t===U.RSS_14||t===U.RSS_EXPANDED));e&&!r&&i.push(new ie(t,this.verbose)),n.includes(U.QR_CODE)&&i.push(new Le),n.includes(U.DATA_MATRIX)&&i.push(new ge),n.includes(U.AZTEC)&&i.push(new gt),n.includes(U.PDF_417)&&i.push(new ar),e&&r&&i.push(new ie(t,this.verbose))}0===i.length&&(r||i.push(new ie(t,this.verbose)),i.push(new Le),i.push(new ge),i.push(new gt),i.push(new ar),r&&i.push(new ie(t,this.verbose))),this.readers=i}reset(){if(null!==this.readers)for(const t of this.readers)t.reset()}decodeInternal(t){if(null===this.readers)throw new cr("No readers where selected, nothing can be read.");for(const e of this.readers)try{return e.decode(t,this.hints)}catch(t){if(t instanceof cr)continue}throw new D("No MultiFormat Readers were able to detect the code.")}}var hr;!function(t){t[t.ERROR_CORRECTION=0]="ERROR_CORRECTION",t[t.CHARACTER_SET=1]="CHARACTER_SET",t[t.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",t[t.MIN_SIZE=3]="MIN_SIZE",t[t.MAX_SIZE=4]="MAX_SIZE",t[t.MARGIN=5]="MARGIN",t[t.PDF417_COMPACT=6]="PDF417_COMPACT",t[t.PDF417_COMPACTION=7]="PDF417_COMPACTION",t[t.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",t[t.AZTEC_LAYERS=9]="AZTEC_LAYERS",t[t.QR_VERSION=10]="QR_VERSION"}(hr||(hr={}));var ur=hr;class dr{constructor(t){this.field=t,this.cachedGenerators=[],this.cachedGenerators.push(new Q(t,Int32Array.from([1])))}buildGenerator(t){const e=this.cachedGenerators;if(t>=e.length){let r=e[e.length-1];const n=this.field;for(let i=e.length;i<=t;i++){const t=r.multiply(new Q(n,Int32Array.from([1,n.exp(i-1+n.getGeneratorBase())])));e.push(t),r=t}}return e[t]}encode(t,e){if(0===e)throw new c("No error correction bytes");const r=t.length-e;if(r<=0)throw new c("No data bytes provided");const n=this.buildGenerator(e),i=new Int32Array(r);d.arraycopy(t,0,i,0,r);let o=new Q(this.field,i);o=o.multiplyByMonomial(e,1);const s=o.divide(n)[1].getCoefficients(),a=e-s.length;for(let e=0;e<a;e++)t[r+e]=0;d.arraycopy(s,0,t,r+a,s.length)}}class fr{constructor(){}static applyMaskPenaltyRule1(t){return fr.applyMaskPenaltyRule1Internal(t,!0)+fr.applyMaskPenaltyRule1Internal(t,!1)}static applyMaskPenaltyRule2(t){let e=0;const r=t.getArray(),n=t.getWidth(),i=t.getHeight();for(let t=0;t<i-1;t++){const i=r[t];for(let o=0;o<n-1;o++){const n=i[o];n===i[o+1]&&n===r[t+1][o]&&n===r[t+1][o+1]&&e++}}return fr.N2*e}static applyMaskPenaltyRule3(t){let e=0;const r=t.getArray(),n=t.getWidth(),i=t.getHeight();for(let t=0;t<i;t++)for(let o=0;o<n;o++){const s=r[t];o+6<n&&1===s[o]&&0===s[o+1]&&1===s[o+2]&&1===s[o+3]&&1===s[o+4]&&0===s[o+5]&&1===s[o+6]&&(fr.isWhiteHorizontal(s,o-4,o)||fr.isWhiteHorizontal(s,o+7,o+11))&&e++,t+6<i&&1===r[t][o]&&0===r[t+1][o]&&1===r[t+2][o]&&1===r[t+3][o]&&1===r[t+4][o]&&0===r[t+5][o]&&1===r[t+6][o]&&(fr.isWhiteVertical(r,o,t-4,t)||fr.isWhiteVertical(r,o,t+7,t+11))&&e++}return e*fr.N3}static isWhiteHorizontal(t,e,r){e=Math.max(e,0),r=Math.min(r,t.length);for(let n=e;n<r;n++)if(1===t[n])return!1;return!0}static isWhiteVertical(t,e,r,n){r=Math.max(r,0),n=Math.min(n,t.length);for(let i=r;i<n;i++)if(1===t[i][e])return!1;return!0}static applyMaskPenaltyRule4(t){let e=0;const r=t.getArray(),n=t.getWidth(),i=t.getHeight();for(let t=0;t<i;t++){const i=r[t];for(let t=0;t<n;t++)1===i[t]&&e++}const o=t.getHeight()*t.getWidth();return Math.floor(10*Math.abs(2*e-o)/o)*fr.N4}static getDataMaskBit(t,e,r){let n,i;switch(t){case 0:n=r+e&1;break;case 1:n=1&r;break;case 2:n=e%3;break;case 3:n=(r+e)%3;break;case 4:n=Math.floor(r/2)+Math.floor(e/3)&1;break;case 5:i=r*e,n=(1&i)+i%3;break;case 6:i=r*e,n=(1&i)+i%3&1;break;case 7:i=r*e,n=i%3+(r+e&1)&1;break;default:throw new c("Invalid mask pattern: "+t)}return 0===n}static applyMaskPenaltyRule1Internal(t,e){let r=0;const n=e?t.getHeight():t.getWidth(),i=e?t.getWidth():t.getHeight(),o=t.getArray();for(let t=0;t<n;t++){let n=0,s=-1;for(let a=0;a<i;a++){const i=e?o[t][a]:o[a][t];i===s?n++:(n>=5&&(r+=fr.N1+(n-5)),n=1,s=i)}n>=5&&(r+=fr.N1+(n-5))}return r}}fr.N1=3,fr.N2=3,fr.N3=40,fr.N4=10;class gr{constructor(t,e){this.width=t,this.height=e;const r=new Array(e);for(let n=0;n!==e;n++)r[n]=new Uint8Array(t);this.bytes=r}getHeight(){return this.height}getWidth(){return this.width}get(t,e){return this.bytes[e][t]}getArray(){return this.bytes}setNumber(t,e,r){this.bytes[e][t]=r}setBoolean(t,e,r){this.bytes[e][t]=r?1:0}clear(t){for(const e of this.bytes)w.fill(e,t)}equals(t){if(!(t instanceof gr))return!1;const e=t;if(this.width!==e.width)return!1;if(this.height!==e.height)return!1;for(let t=0,r=this.height;t<r;++t){const r=this.bytes[t],n=e.bytes[t];for(let t=0,e=this.width;t<e;++t)if(r[t]!==n[t])return!1}return!0}toString(){const t=new y;for(let e=0,r=this.height;e<r;++e){const r=this.bytes[e];for(let e=0,n=this.width;e<n;++e)switch(r[e]){case 0:t.append(" 0");break;case 1:t.append(" 1");break;default:t.append(" ")}t.append("\n")}return t.toString()}}class wr{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 t=new y;return t.append("<<\n"),t.append(" mode: "),t.append(this.mode?this.mode.toString():"null"),t.append("\n ecLevel: "),t.append(this.ecLevel?this.ecLevel.toString():"null"),t.append("\n version: "),t.append(this.version?this.version.toString():"null"),t.append("\n maskPattern: "),t.append(this.maskPattern.toString()),this.matrix?(t.append("\n matrix:\n"),t.append(this.matrix.toString())):t.append("\n matrix: null\n"),t.append(">>\n"),t.toString()}setMode(t){this.mode=t}setECLevel(t){this.ecLevel=t}setVersion(t){this.version=t}setMaskPattern(t){this.maskPattern=t}setMatrix(t){this.matrix=t}static isValidMaskPattern(t){return t>=0&&t<wr.NUM_MASK_PATTERNS}}wr.NUM_MASK_PATTERNS=8;class mr extends s{}mr.kind="WriterException";class pr{constructor(){}static clearMatrix(t){t.clear(255)}static buildMatrix(t,e,r,n,i){pr.clearMatrix(i),pr.embedBasicPatterns(r,i),pr.embedTypeInfo(e,n,i),pr.maybeEmbedVersionInfo(r,i),pr.embedDataBits(t,n,i)}static embedBasicPatterns(t,e){pr.embedPositionDetectionPatternsAndSeparators(e),pr.embedDarkDotAtLeftBottomCorner(e),pr.maybeEmbedPositionAdjustmentPatterns(t,e),pr.embedTimingPatterns(e)}static embedTypeInfo(t,e,r){const n=new p;pr.makeTypeInfoBits(t,e,n);for(let t=0,e=n.getSize();t<e;++t){const e=n.get(n.getSize()-1-t),i=pr.TYPE_INFO_COORDINATES[t],o=i[0],s=i[1];if(r.setBoolean(o,s,e),t<8){const n=r.getWidth()-t-1,i=8;r.setBoolean(n,i,e)}else{const n=8,i=r.getHeight()-7+(t-8);r.setBoolean(n,i,e)}}}static maybeEmbedVersionInfo(t,e){if(t.getVersionNumber()<7)return;const r=new p;pr.makeVersionInfoBits(t,r);let n=17;for(let t=0;t<6;++t)for(let i=0;i<3;++i){const o=r.get(n);n--,e.setBoolean(t,e.getHeight()-11+i,o),e.setBoolean(e.getHeight()-11+i,t,o)}}static embedDataBits(t,e,r){let n=0,i=-1,o=r.getWidth()-1,s=r.getHeight()-1;for(;o>0;){for(6===o&&(o-=1);s>=0&&s<r.getHeight();){for(let i=0;i<2;++i){const a=o-i;if(!pr.isEmpty(r.get(a,s)))continue;let c;n<t.getSize()?(c=t.get(n),++n):c=!1,255!==e&&fr.getDataMaskBit(e,a,s)&&(c=!c),r.setBoolean(a,s,c)}s+=i}i=-i,s+=i,o-=2}if(n!==t.getSize())throw new mr("Not all bits consumed: "+n+"/"+t.getSize())}static findMSBSet(t){return 32-m.numberOfLeadingZeros(t)}static calculateBCHCode(t,e){if(0===e)throw new c("0 polynomial");const r=pr.findMSBSet(e);for(t<<=r-1;pr.findMSBSet(t)>=r;)t^=e<<pr.findMSBSet(t)-r;return t}static makeTypeInfoBits(t,e,r){if(!wr.isValidMaskPattern(e))throw new mr("Invalid mask pattern");const n=t.getBits()<<3|e;r.appendBits(n,5);const i=pr.calculateBCHCode(n,pr.TYPE_INFO_POLY);r.appendBits(i,10);const o=new p;if(o.appendBits(pr.TYPE_INFO_MASK_PATTERN,15),r.xor(o),15!==r.getSize())throw new mr("should not happen but we got: "+r.getSize())}static makeVersionInfoBits(t,e){e.appendBits(t.getVersionNumber(),6);const r=pr.calculateBCHCode(t.getVersionNumber(),pr.VERSION_INFO_POLY);if(e.appendBits(r,12),18!==e.getSize())throw new mr("should not happen but we got: "+e.getSize())}static isEmpty(t){return 255===t}static embedTimingPatterns(t){for(let e=8;e<t.getWidth()-8;++e){const r=(e+1)%2;pr.isEmpty(t.get(e,6))&&t.setNumber(e,6,r),pr.isEmpty(t.get(6,e))&&t.setNumber(6,e,r)}}static embedDarkDotAtLeftBottomCorner(t){if(0===t.get(8,t.getHeight()-8))throw new mr;t.setNumber(8,t.getHeight()-8,1)}static embedHorizontalSeparationPattern(t,e,r){for(let n=0;n<8;++n){if(!pr.isEmpty(r.get(t+n,e)))throw new mr;r.setNumber(t+n,e,0)}}static embedVerticalSeparationPattern(t,e,r){for(let n=0;n<7;++n){if(!pr.isEmpty(r.get(t,e+n)))throw new mr;r.setNumber(t,e+n,0)}}static embedPositionAdjustmentPattern(t,e,r){for(let n=0;n<5;++n){const i=pr.POSITION_ADJUSTMENT_PATTERN[n];for(let o=0;o<5;++o)r.setNumber(t+o,e+n,i[o])}}static embedPositionDetectionPattern(t,e,r){for(let n=0;n<7;++n){const i=pr.POSITION_DETECTION_PATTERN[n];for(let o=0;o<7;++o)r.setNumber(t+o,e+n,i[o])}}static embedPositionDetectionPatternsAndSeparators(t){const e=pr.POSITION_DETECTION_PATTERN[0].length;pr.embedPositionDetectionPattern(0,0,t),pr.embedPositionDetectionPattern(t.getWidth()-e,0,t),pr.embedPositionDetectionPattern(0,t.getWidth()-e,t);pr.embedHorizontalSeparationPattern(0,7,t),pr.embedHorizontalSeparationPattern(t.getWidth()-8,7,t),pr.embedHorizontalSeparationPattern(0,t.getWidth()-8,t);pr.embedVerticalSeparationPattern(7,0,t),pr.embedVerticalSeparationPattern(t.getHeight()-7-1,0,t),pr.embedVerticalSeparationPattern(7,t.getHeight()-7,t)}static maybeEmbedPositionAdjustmentPatterns(t,e){if(t.getVersionNumber()<2)return;const r=t.getVersionNumber()-1,n=pr.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[r];for(let t=0,r=n.length;t!==r;t++){const i=n[t];if(i>=0)for(let t=0;t!==r;t++){const r=n[t];r>=0&&pr.isEmpty(e.get(r,i))&&pr.embedPositionAdjustmentPattern(r-2,i-2,e)}}}}pr.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])]),pr.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])]),pr.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])]),pr.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])]),pr.VERSION_INFO_POLY=7973,pr.TYPE_INFO_POLY=1335,pr.TYPE_INFO_MASK_PATTERN=21522;class Ar{constructor(t,e){this.dataBytes=t,this.errorCorrectionBytes=e}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class Cr{constructor(){}static calculateMaskPenalty(t){return fr.applyMaskPenaltyRule1(t)+fr.applyMaskPenaltyRule2(t)+fr.applyMaskPenaltyRule3(t)+fr.applyMaskPenaltyRule4(t)}static encode(t,e,r=null){let n=Cr.DEFAULT_BYTE_MODE_ENCODING;const i=null!==r&&void 0!==r.get(ur.CHARACTER_SET);i&&(n=r.get(ur.CHARACTER_SET).toString());const o=this.chooseMode(t,n),s=new p;if(o===_e.BYTE&&(i||Cr.DEFAULT_BYTE_MODE_ENCODING!==n)){const t=I.getCharacterSetECIByName(n);void 0!==t&&this.appendECI(t,s)}this.appendModeInfo(o,s);const a=new p;let c;if(this.appendBytes(t,o,a,n),null!==r&&void 0!==r.get(ur.QR_VERSION)){const t=Number.parseInt(r.get(ur.QR_VERSION).toString(),10);c=Ce.getVersionForNumber(t);const n=this.calculateBitsNeeded(o,s,a,c);if(!this.willFit(n,c,e))throw new mr("Data too big for requested version")}else c=this.recommendVersion(e,o,s,a);const l=new p;l.appendBitArray(s);const h=o===_e.BYTE?a.getSizeInBytes():t.length;this.appendLengthInfo(h,c,o,l),l.appendBitArray(a);const u=c.getECBlocksForLevel(e),d=c.getTotalCodewords()-u.getTotalECCodewords();this.terminateBits(d,l);const f=this.interleaveWithECBytes(l,c.getTotalCodewords(),d,u.getNumBlocks()),g=new wr;g.setECLevel(e),g.setMode(o),g.setVersion(c);const w=c.getDimensionForVersion(),m=new gr(w,w),A=this.chooseMaskPattern(f,e,c,m);return g.setMaskPattern(A),pr.buildMatrix(f,e,c,A,m),g.setMatrix(m),g}static recommendVersion(t,e,r,n){const i=this.calculateBitsNeeded(e,r,n,Ce.getVersionForNumber(1)),o=this.chooseVersion(i,t),s=this.calculateBitsNeeded(e,r,n,o);return this.chooseVersion(s,t)}static calculateBitsNeeded(t,e,r,n){return e.getSize()+t.getCharacterCountBits(n)+r.getSize()}static getAlphanumericCode(t){return t<Cr.ALPHANUMERIC_TABLE.length?Cr.ALPHANUMERIC_TABLE[t]:-1}static chooseMode(t,e=null){if(I.SJIS.getName()===e&&this.isOnlyDoubleByteKanji(t))return _e.KANJI;let r=!1,n=!1;for(let e=0,i=t.length;e<i;++e){const i=t.charAt(e);if(Cr.isDigit(i))r=!0;else{if(-1===this.getAlphanumericCode(i.charCodeAt(0)))return _e.BYTE;n=!0}}return n?_e.ALPHANUMERIC:r?_e.NUMERIC:_e.BYTE}static isOnlyDoubleByteKanji(t){let e;try{e=_.encode(t,I.SJIS)}catch(t){return!1}const r=e.length;if(r%2!=0)return!1;for(let t=0;t<r;t+=2){const r=255&e[t];if((r<129||r>159)&&(r<224||r>235))return!1}return!0}static chooseMaskPattern(t,e,r,n){let i=Number.MAX_SAFE_INTEGER,o=-1;for(let s=0;s<wr.NUM_MASK_PATTERNS;s++){pr.buildMatrix(t,e,r,s,n);let a=this.calculateMaskPenalty(n);a<i&&(i=a,o=s)}return o}static chooseVersion(t,e){for(let r=1;r<=40;r++){const n=Ce.getVersionForNumber(r);if(Cr.willFit(t,n,e))return n}throw new mr("Data too big")}static willFit(t,e,r){return e.getTotalCodewords()-e.getECBlocksForLevel(r).getTotalECCodewords()>=(t+7)/8}static terminateBits(t,e){const r=8*t;if(e.getSize()>r)throw new mr("data bits cannot fit in the QR Code"+e.getSize()+" > "+r);for(let t=0;t<4&&e.getSize()<r;++t)e.appendBit(!1);const n=7&e.getSize();if(n>0)for(let t=n;t<8;t++)e.appendBit(!1);const i=t-e.getSizeInBytes();for(let t=0;t<i;++t)e.appendBits(0==(1&t)?236:17,8);if(e.getSize()!==r)throw new mr("Bits size does not equal capacity")}static getNumDataBytesAndNumECBytesForBlockID(t,e,r,n,i,o){if(n>=r)throw new mr("Block ID too large");const s=t%r,a=r-s,c=Math.floor(t/r),l=c+1,h=Math.floor(e/r),u=h+1,d=c-h,f=l-u;if(d!==f)throw new mr("EC bytes mismatch");if(r!==a+s)throw new mr("RS blocks mismatch");if(t!==(h+d)*a+(u+f)*s)throw new mr("Total bytes mismatch");n<a?(i[0]=h,o[0]=d):(i[0]=u,o[0]=f)}static interleaveWithECBytes(t,e,r,n){if(t.getSizeInBytes()!==r)throw new mr("Number of bits and data bytes does not match");let i=0,o=0,s=0;const a=new Array;for(let c=0;c<n;++c){const l=new Int32Array(1),h=new Int32Array(1);Cr.getNumDataBytesAndNumECBytesForBlockID(e,r,n,c,l,h);const u=l[0],d=new Uint8Array(u);t.toBytes(8*i,d,0,u);const f=Cr.generateECBytes(d,h[0]);a.push(new Ar(d,f)),o=Math.max(o,u),s=Math.max(s,f.length),i+=l[0]}if(r!==i)throw new mr("Data bytes does not match offset");const c=new p;for(let t=0;t<o;++t)for(const e of a){const r=e.getDataBytes();t<r.length&&c.appendBits(r[t],8)}for(let t=0;t<s;++t)for(const e of a){const r=e.getErrorCorrectionBytes();t<r.length&&c.appendBits(r[t],8)}if(e!==c.getSizeInBytes())throw new mr("Interleaving error: "+e+" and "+c.getSizeInBytes()+" differ.");return c}static generateECBytes(t,e){const r=t.length,n=new Int32Array(r+e);for(let e=0;e<r;e++)n[e]=255&t[e];new dr(q.QR_CODE_FIELD_256).encode(n,e);const i=new Uint8Array(e);for(let t=0;t<e;t++)i[t]=n[r+t];return i}static appendModeInfo(t,e){e.appendBits(t.getBits(),4)}static appendLengthInfo(t,e,r,n){const i=r.getCharacterCountBits(e);if(t>=1<<i)throw new mr(t+" is bigger than "+((1<<i)-1));n.appendBits(t,i)}static appendBytes(t,e,r,n){switch(e){case _e.NUMERIC:Cr.appendNumericBytes(t,r);break;case _e.ALPHANUMERIC:Cr.appendAlphanumericBytes(t,r);break;case _e.BYTE:Cr.append8BitBytes(t,r,n);break;case _e.KANJI:Cr.appendKanjiBytes(t,r);break;default:throw new mr("Invalid mode: "+e)}}static getDigit(t){return t.charCodeAt(0)-48}static isDigit(t){const e=Cr.getDigit(t);return e>=0&&e<=9}static appendNumericBytes(t,e){const r=t.length;let n=0;for(;n<r;){const i=Cr.getDigit(t.charAt(n));if(n+2<r){const r=Cr.getDigit(t.charAt(n+1)),o=Cr.getDigit(t.charAt(n+2));e.appendBits(100*i+10*r+o,10),n+=3}else if(n+1<r){const r=Cr.getDigit(t.charAt(n+1));e.appendBits(10*i+r,7),n+=2}else e.appendBits(i,4),n++}}static appendAlphanumericBytes(t,e){const r=t.length;let n=0;for(;n<r;){const i=Cr.getAlphanumericCode(t.charCodeAt(n));if(-1===i)throw new mr;if(n+1<r){const r=Cr.getAlphanumericCode(t.charCodeAt(n+1));if(-1===r)throw new mr;e.appendBits(45*i+r,11),n+=2}else e.appendBits(i,6),n++}}static append8BitBytes(t,e,r){let n;try{n=_.encode(t,r)}catch(t){throw new mr(t)}for(let t=0,r=n.length;t!==r;t++){const r=n[t];e.appendBits(r,8)}}static appendKanjiBytes(t,e){let r;try{r=_.encode(t,I.SJIS)}catch(t){throw new mr(t)}const n=r.length;for(let t=0;t<n;t+=2){const n=(255&r[t])<<8&4294967295|255&r[t+1];let i=-1;if(n>=33088&&n<=40956?i=n-33088:n>=57408&&n<=60351&&(i=n-49472),-1===i)throw new mr("Invalid byte sequence");const o=192*(i>>8)+(255&i);e.appendBits(o,13)}}static appendECI(t,e){e.appendBits(_e.ECI.getBits(),4),e.appendBits(t.getValue(),8)}}Cr.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]),Cr.DEFAULT_BYTE_MODE_ENCODING=I.UTF8.getName();class Er{write(t,e,r,n=null){if(0===t.length)throw new c("Found empty contents");if(e<0||r<0)throw new c("Requested dimensions are too small: "+e+"x"+r);let i=we.L,o=Er.QUIET_ZONE_SIZE;null!==n&&(void 0!==n.get(ur.ERROR_CORRECTION)&&(i=we.fromString(n.get(ur.ERROR_CORRECTION).toString())),void 0!==n.get(ur.MARGIN)&&(o=Number.parseInt(n.get(ur.MARGIN).toString(),10)));const s=Cr.encode(t,i,n);return this.renderResult(s,e,r,o)}writeToDom(t,e,r,n,i=null){"string"==typeof t&&(t=document.querySelector(t));const o=this.write(e,r,n,i);t&&t.appendChild(o)}renderResult(t,e,r,n){const i=t.getMatrix();if(null===i)throw new $;const o=i.getWidth(),s=i.getHeight(),a=o+2*n,c=s+2*n,l=Math.max(e,a),h=Math.max(r,c),u=Math.min(Math.floor(l/a),Math.floor(h/c)),d=Math.floor((l-o*u)/2),f=Math.floor((h-s*u)/2),g=this.createSVGElement(l,h);for(let t=0,e=f;t<s;t++,e+=u)for(let r=0,n=d;r<o;r++,n+=u)if(1===i.get(r,t)){const t=this.createSvgRectElement(n,e,u,u);g.appendChild(t)}return g}createSVGElement(t,e){const r=document.createElementNS(Er.SVG_NS,"svg");return r.setAttributeNS(null,"height",t.toString()),r.setAttributeNS(null,"width",e.toString()),r}createSvgRectElement(t,e,r,n){const i=document.createElementNS(Er.SVG_NS,"rect");return i.setAttributeNS(null,"x",t.toString()),i.setAttributeNS(null,"y",e.toString()),i.setAttributeNS(null,"height",r.toString()),i.setAttributeNS(null,"width",n.toString()),i.setAttributeNS(null,"fill","#000000"),i}}Er.QUIET_ZONE_SIZE=4,Er.SVG_NS="http://www.w3.org/2000/svg";class Ir{encode(t,e,r,n,i){if(0===t.length)throw new c("Found empty contents");if(e!==U.QR_CODE)throw new c("Can only encode QR_CODE, but got "+e);if(r<0||n<0)throw new c(`Requested dimensions are too small: ${r}x${n}`);let o=we.L,s=Ir.QUIET_ZONE_SIZE;null!==i&&(void 0!==i.get(ur.ERROR_CORRECTION)&&(o=we.fromString(i.get(ur.ERROR_CORRECTION).toString())),void 0!==i.get(ur.MARGIN)&&(s=Number.parseInt(i.get(ur.MARGIN).toString(),10)));const a=Cr.encode(t,o,i);return Ir.renderResult(a,r,n,s)}static renderResult(t,e,r,n){const i=t.getMatrix();if(null===i)throw new $;const o=i.getWidth(),s=i.getHeight(),a=o+2*n,c=s+2*n,l=Math.max(e,a),h=Math.max(r,c),u=Math.min(Math.floor(l/a),Math.floor(h/c)),d=Math.floor((l-o*u)/2),f=Math.floor((h-s*u)/2),g=new N(l,h);for(let t=0,e=f;t<s;t++,e+=u)for(let r=0,n=d;r<o;r++,n+=u)1===i.get(r,t)&&g.setRegion(n,e,u,u);return g}}Ir.QUIET_ZONE_SIZE=4;class Sr extends O{constructor(t,e,r,n,i,o,s,a){if(super(o,s),this.yuvData=t,this.dataWidth=e,this.dataHeight=r,this.left=n,this.top=i,n+o>e||i+s>r)throw new c("Crop rectangle does not fit within image data.");a&&this.reverseHorizontal(o,s)}getRow(t,e){if(t<0||t>=this.getHeight())throw new c("Requested row is outside the image: "+t);const r=this.getWidth();(null==e||e.length<r)&&(e=new Uint8ClampedArray(r));const n=(t+this.top)*this.dataWidth+this.left;return d.arraycopy(this.yuvData,n,e,0,r),e}getMatrix(){const t=this.getWidth(),e=this.getHeight();if(t===this.dataWidth&&e===this.dataHeight)return this.yuvData;const r=t*e,n=new Uint8ClampedArray(r);let i=this.top*this.dataWidth+this.left;if(t===this.dataWidth)return d.arraycopy(this.yuvData,i,n,0,r),n;for(let r=0;r<e;r++){const e=r*t;d.arraycopy(this.yuvData,i,n,e,t),i+=this.dataWidth}return n}isCropSupported(){return!0}crop(t,e,r,n){return new Sr(this.yuvData,this.dataWidth,this.dataHeight,this.left+t,this.top+e,r,n,!1)}renderThumbnail(){const t=this.getWidth()/Sr.THUMBNAIL_SCALE_FACTOR,e=this.getHeight()/Sr.THUMBNAIL_SCALE_FACTOR,r=new Int32Array(t*e),n=this.yuvData;let i=this.top*this.dataWidth+this.left;for(let o=0;o<e;o++){const e=o*t;for(let o=0;o<t;o++){const t=255&n[i+o*Sr.THUMBNAIL_SCALE_FACTOR];r[e+o]=4278190080|65793*t}i+=this.dataWidth*Sr.THUMBNAIL_SCALE_FACTOR}return r}getThumbnailWidth(){return this.getWidth()/Sr.THUMBNAIL_SCALE_FACTOR}getThumbnailHeight(){return this.getHeight()/Sr.THUMBNAIL_SCALE_FACTOR}reverseHorizontal(t,e){const r=this.yuvData;for(let n=0,i=this.top*this.dataWidth+this.left;n<e;n++,i+=this.dataWidth){const e=i+t/2;for(let n=i,o=i+t-1;n<e;n++,o--){const t=r[n];r[n]=r[o],r[o]=t}}}invert(){return new b(this)}}Sr.THUMBNAIL_SCALE_FACTOR=2;class _r extends O{constructor(t,e,r,n,i,o,s){if(super(e,r),this.dataWidth=n,this.dataHeight=i,this.left=o,this.top=s,4===t.BYTES_PER_ELEMENT){const n=e*r,i=new Uint8ClampedArray(n);for(let e=0;e<n;e++){const r=t[e],n=r>>16&255,o=r>>7&510,s=255&r;i[e]=(n+o+s)/4&255}this.luminances=i}else this.luminances=t;if(void 0===n&&(this.dataWidth=e),void 0===i&&(this.dataHeight=r),void 0===o&&(this.left=0),void 0===s&&(this.top=0),this.left+e>this.dataWidth||this.top+r>this.dataHeight)throw new c("Crop rectangle does not fit within image data.")}getRow(t,e){if(t<0||t>=this.getHeight())throw new c("Requested row is outside the image: "+t);const r=this.getWidth();(null==e||e.length<r)&&(e=new Uint8ClampedArray(r));const n=(t+this.top)*this.dataWidth+this.left;return d.arraycopy(this.luminances,n,e,0,r),e}getMatrix(){const t=this.getWidth(),e=this.getHeight();if(t===this.dataWidth&&e===this.dataHeight)return this.luminances;const r=t*e,n=new Uint8ClampedArray(r);let i=this.top*this.dataWidth+this.left;if(t===this.dataWidth)return d.arraycopy(this.luminances,i,n,0,r),n;for(let r=0;r<e;r++){const e=r*t;d.arraycopy(this.luminances,i,n,e,t),i+=this.dataWidth}return n}isCropSupported(){return!0}crop(t,e,r,n){return new _r(this.luminances,r,n,this.dataWidth,this.dataHeight,this.left+t,this.top+e)}invert(){return new b(this)}}class Tr extends I{static forName(t){return this.getCharacterSetECIByName(t)}}class yr{}yr.ISO_8859_1=I.ISO8859_1;class Nr{isCompact(){return this.compact}setCompact(t){this.compact=t}getSize(){return this.size}setSize(t){this.size=t}getLayers(){return this.layers}setLayers(t){this.layers=t}getCodeWords(){return this.codeWords}setCodeWords(t){this.codeWords=t}getMatrix(){return this.matrix}setMatrix(t){this.matrix=t}}class Dr{static singletonList(t){return[t]}static min(t,e){return t.sort(e)[0]}}class Mr{constructor(t){this.previous=t}getPrevious(){return this.previous}}class Rr extends Mr{constructor(t,e,r){super(t),this.value=e,this.bitCount=r}appendTo(t,e){t.appendBits(this.value,this.bitCount)}add(t,e){return new Rr(this,t,e)}addBinaryShift(t,e){return console.warn("addBinaryShift on SimpleToken, this simply returns a copy of this token"),new Rr(this,t,e)}toString(){let t=this.value&(1<<this.bitCount)-1;return t|=1<<this.bitCount,"<"+m.toBinaryString(t|1<<this.bitCount).substring(1)+">"}}class Or extends Rr{constructor(t,e,r){super(t,0,0),this.binaryShiftStart=e,this.binaryShiftByteCount=r}appendTo(t,e){for(let r=0;r<this.binaryShiftByteCount;r++)(0===r||31===r&&this.binaryShiftByteCount<=62)&&(t.appendBits(31,5),this.binaryShiftByteCount>62?t.appendBits(this.binaryShiftByteCount-31,16):0===r?t.appendBits(Math.min(this.binaryShiftByteCount,31),5):t.appendBits(this.binaryShiftByteCount-31,5)),t.appendBits(e[this.binaryShiftStart+r],8)}addBinaryShift(t,e){return new Or(this,t,e)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function br(t,e,r){return new Rr(t,e,r)}const Br=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],Lr=0,Pr=1,vr=2,Fr=3,xr=4,kr=new Rr(null,0,0),Ur=[Int32Array.from([0,327708,327710,327709,656318]),Int32Array.from([590318,0,327710,327709,656318]),Int32Array.from([262158,590300,0,590301,932798]),Int32Array.from([327709,327708,656318,0,327710]),Int32Array.from([327711,656380,656382,656381,0])];const Hr=function(t){for(let e of t)w.fill(e,-1);return t[Lr][xr]=0,t[Pr][xr]=0,t[Pr][Lr]=28,t[Fr][xr]=0,t[vr][xr]=0,t[vr][Lr]=15,t}(w.createInt32Array(6,6));class Vr{constructor(t,e,r,n){this.token=t,this.mode=e,this.binaryShiftByteCount=r,this.bitCount=n}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(t,e){let r=this.bitCount,n=this.token;if(t!==this.mode){let e=Ur[this.mode][t];n=br(n,65535&e,e>>16),r+=e>>16}let i=t===vr?4:5;return n=br(n,e,i),new Vr(n,t,0,r+i)}shiftAndAppend(t,e){let r=this.token,n=this.mode===vr?4:5;return r=br(r,Hr[this.mode][t],n),r=br(r,e,5),new Vr(r,this.mode,0,this.bitCount+n+5)}addBinaryShiftChar(t){let e=this.token,r=this.mode,n=this.bitCount;if(this.mode===xr||this.mode===vr){let t=Ur[r][Lr];e=br(e,65535&t,t>>16),n+=t>>16,r=Lr}let i=0===this.binaryShiftByteCount||31===this.binaryShiftByteCount?18:62===this.binaryShiftByteCount?9:8,o=new Vr(e,r,this.binaryShiftByteCount+1,n+i);return 2078===o.binaryShiftByteCount&&(o=o.endBinaryShift(t+1)),o}endBinaryShift(t){if(0===this.binaryShiftByteCount)return this;let e=this.token;return e=function(t,e,r){return new Or(t,e,r)}(e,t-this.binaryShiftByteCount,this.binaryShiftByteCount),new Vr(e,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(t){let e=this.bitCount+(Ur[this.mode][t.mode]>>16);return this.binaryShiftByteCount<t.binaryShiftByteCount?e+=Vr.calculateBinaryShiftCost(t)-Vr.calculateBinaryShiftCost(this):this.binaryShiftByteCount>t.binaryShiftByteCount&&t.binaryShiftByteCount>0&&(e+=10),e<=t.bitCount}toBitArray(t){let e=[];for(let r=this.endBinaryShift(t.length).token;null!==r;r=r.getPrevious())e.unshift(r);let r=new p;for(const n of e)n.appendTo(r,t);return r}toString(){return T.format("%s bits=%d bytes=%d",Br[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(t){return t.binaryShiftByteCount>62?21:t.binaryShiftByteCount>31?20:t.binaryShiftByteCount>0?10:0}}Vr.INITIAL_STATE=new Vr(kr,Lr,0,0);const zr=function(t){const e=T.getCharCode(" "),r=T.getCharCode("."),n=T.getCharCode(",");t[Lr][e]=1;const i=T.getCharCode("Z"),o=T.getCharCode("A");for(let e=o;e<=i;e++)t[Lr][e]=e-o+2;t[Pr][e]=1;const s=T.getCharCode("z"),a=T.getCharCode("a");for(let e=a;e<=s;e++)t[Pr][e]=e-a+2;t[vr][e]=1;const c=T.getCharCode("9"),l=T.getCharCode("0");for(let e=l;e<=c;e++)t[vr][e]=e-l+2;t[vr][n]=12,t[vr][r]=13;const h=["\0"," ","","","","","","","","\b","\t","\n","\v","\f","\r","","","","","","@","\\","^","_","`","|","~",""];for(let e=0;e<h.length;e++)t[Fr][T.getCharCode(h[e])]=e;const u=["\0","\r","\0","\0","\0","\0","!","'","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}"];for(let e=0;e<u.length;e++)T.getCharCode(u[e])>0&&(t[xr][T.getCharCode(u[e])]=e);return t}(w.createInt32Array(5,256));class Gr{constructor(t){this.text=t}encode(){const t=T.getCharCode(" "),e=T.getCharCode("\n");let r=Dr.singletonList(Vr.INITIAL_STATE);for(let n=0;n<this.text.length;n++){let i,o=n+1<this.text.length?this.text[n+1]:0;switch(this.text[n]){case T.getCharCode("\r"):i=o===e?2:0;break;case T.getCharCode("."):i=o===t?3:0;break;case T.getCharCode(","):i=o===t?4:0;break;case T.getCharCode(":"):i=o===t?5:0;break;default:i=0}i>0?(r=Gr.updateStateListForPair(r,n,i),n++):r=this.updateStateListForChar(r,n)}return Dr.min(r,((t,e)=>t.getBitCount()-e.getBitCount())).toBitArray(this.text)}updateStateListForChar(t,e){const r=[];for(let n of t)this.updateStateForChar(n,e,r);return Gr.simplifyStates(r)}updateStateForChar(t,e,r){let n=255&this.text[e],i=zr[t.getMode()][n]>0,o=null;for(let s=0;s<=xr;s++){let a=zr[s][n];if(a>0){if(null==o&&(o=t.endBinaryShift(e)),!i||s===t.getMode()||s===vr){const t=o.latchAndAppend(s,a);r.push(t)}if(!i&&Hr[t.getMode()][s]>=0){const t=o.shiftAndAppend(s,a);r.push(t)}}}if(t.getBinaryShiftByteCount()>0||0===zr[t.getMode()][n]){let n=t.addBinaryShiftChar(e);r.push(n)}}static updateStateListForPair(t,e,r){const n=[];for(let i of t)this.updateStateForPair(i,e,r,n);return this.simplifyStates(n)}static updateStateForPair(t,e,r,n){let i=t.endBinaryShift(e);if(n.push(i.latchAndAppend(xr,r)),t.getMode()!==xr&&n.push(i.shiftAndAppend(xr,r)),3===r||4===r){let t=i.latchAndAppend(vr,16-r).latchAndAppend(vr,1);n.push(t)}if(t.getBinaryShiftByteCount()>0){let r=t.addBinaryShiftChar(e).addBinaryShiftChar(e+1);n.push(r)}}static simplifyStates(t){let e=[];for(const r of t){let t=!0;for(const n of e){if(n.isBetterThanOrEqualTo(r)){t=!1;break}r.isBetterThanOrEqualTo(n)&&(e=e.filter((t=>t!==n)))}t&&e.push(r)}return e}}class Yr{constructor(){}static encodeBytes(t){return Yr.encode(t,Yr.DEFAULT_EC_PERCENT,Yr.DEFAULT_AZTEC_LAYERS)}static encode(t,e,r){let n,i,o,s,a,l=new Gr(t).encode(),h=m.truncDivision(l.getSize()*e,100)+11,u=l.getSize()+h;if(r!==Yr.DEFAULT_AZTEC_LAYERS){if(n=r<0,i=Math.abs(r),i>(n?Yr.MAX_NB_BITS_COMPACT:Yr.MAX_NB_BITS))throw new c(T.format("Illegal value %s for layers",r));o=Yr.totalBitsInLayer(i,n),s=Yr.WORD_SIZE[i];let t=o-o%s;if(a=Yr.stuffBits(l,s),a.getSize()+h>t)throw new c("Data to large for user specified layer");if(n&&a.getSize()>64*s)throw new c("Data to large for user specified layer")}else{s=0,a=null;for(let t=0;;t++){if(t>Yr.MAX_NB_BITS)throw new c("Data too large for an Aztec code");if(n=t<=3,i=n?t+1:t,o=Yr.totalBitsInLayer(i,n),u>o)continue;null!=a&&s===Yr.WORD_SIZE[i]||(s=Yr.WORD_SIZE[i],a=Yr.stuffBits(l,s));let e=o-o%s;if(!(n&&a.getSize()>64*s)&&a.getSize()+h<=e)break}}let d,f=Yr.generateCheckWords(a,o,s),g=a.getSize()/s,w=Yr.generateModeMessage(n,i,g),p=(n?11:14)+4*i,A=new Int32Array(p);if(n){d=p;for(let t=0;t<A.length;t++)A[t]=t}else{d=p+1+2*m.truncDivision(m.truncDivision(p,2)-1,15);let t=m.truncDivision(p,2),e=m.truncDivision(d,2);for(let r=0;r<t;r++){let n=r+m.truncDivision(r,15);A[t-r-1]=e-n-1,A[t+r]=e+n+1}}let C=new N(d);for(let t=0,e=0;t<i;t++){let r=4*(i-t)+(n?9:12);for(let n=0;n<r;n++){let i=2*n;for(let o=0;o<2;o++)f.get(e+i+o)&&C.set(A[2*t+o],A[2*t+n]),f.get(e+2*r+i+o)&&C.set(A[2*t+n],A[p-1-2*t-o]),f.get(e+4*r+i+o)&&C.set(A[p-1-2*t-o],A[p-1-2*t-n]),f.get(e+6*r+i+o)&&C.set(A[p-1-2*t-n],A[2*t+o])}e+=8*r}if(Yr.drawModeMessage(C,n,d,w),n)Yr.drawBullsEye(C,m.truncDivision(d,2),5);else{Yr.drawBullsEye(C,m.truncDivision(d,2),7);for(let t=0,e=0;t<m.truncDivision(p,2)-1;t+=15,e+=16)for(let t=1&m.truncDivision(d,2);t<d;t+=2)C.set(m.truncDivision(d,2)-e,t),C.set(m.truncDivision(d,2)+e,t),C.set(t,m.truncDivision(d,2)-e),C.set(t,m.truncDivision(d,2)+e)}let E=new Nr;return E.setCompact(n),E.setSize(d),E.setLayers(i),E.setCodeWords(g),E.setMatrix(C),E}static drawBullsEye(t,e,r){for(let n=0;n<r;n+=2)for(let r=e-n;r<=e+n;r++)t.set(r,e-n),t.set(r,e+n),t.set(e-n,r),t.set(e+n,r);t.set(e-r,e-r),t.set(e-r+1,e-r),t.set(e-r,e-r+1),t.set(e+r,e-r),t.set(e+r,e-r+1),t.set(e+r,e+r-1)}static generateModeMessage(t,e,r){let n=new p;return t?(n.appendBits(e-1,2),n.appendBits(r-1,6),n=Yr.generateCheckWords(n,28,4)):(n.appendBits(e-1,5),n.appendBits(r-1,11),n=Yr.generateCheckWords(n,40,4)),n}static drawModeMessage(t,e,r,n){let i=m.truncDivision(r,2);if(e)for(let e=0;e<7;e++){let r=i-3+e;n.get(e)&&t.set(r,i-5),n.get(e+7)&&t.set(i+5,r),n.get(20-e)&&t.set(r,i+5),n.get(27-e)&&t.set(i-5,r)}else for(let e=0;e<10;e++){let r=i-5+e+m.truncDivision(e,5);n.get(e)&&t.set(r,i-7),n.get(e+10)&&t.set(i+7,r),n.get(29-e)&&t.set(r,i+7),n.get(39-e)&&t.set(i-7,r)}}static generateCheckWords(t,e,r){let n=t.getSize()/r,i=new dr(Yr.getGF(r)),o=m.truncDivision(e,r),s=Yr.bitsToWords(t,r,o);i.encode(s,o-n);let a=e%r,c=new p;c.appendBits(0,a);for(const t of Array.from(s))c.appendBits(t,r);return c}static bitsToWords(t,e,r){let n,i,o=new Int32Array(r);for(n=0,i=t.getSize()/e;n<i;n++){let r=0;for(let i=0;i<e;i++)r|=t.get(n*e+i)?1<<e-i-1:0;o[n]=r}return o}static getGF(t){switch(t){case 4:return q.AZTEC_PARAM;case 6:return q.AZTEC_DATA_6;case 8:return q.AZTEC_DATA_8;case 10:return q.AZTEC_DATA_10;case 12:return q.AZTEC_DATA_12;default:throw new c("Unsupported word size "+t)}}static stuffBits(t,e){let r=new p,n=t.getSize(),i=(1<<e)-2;for(let o=0;o<n;o+=e){let s=0;for(let r=0;r<e;r++)(o+r>=n||t.get(o+r))&&(s|=1<<e-1-r);(s&i)===i?(r.appendBits(s&i,e),o--):0==(s&i)?(r.appendBits(1|s,e),o--):r.appendBits(s,e)}return r}static totalBitsInLayer(t,e){return((e?88:112)+16*t)*t}}Yr.DEFAULT_EC_PERCENT=33,Yr.DEFAULT_AZTEC_LAYERS=0,Yr.MAX_NB_BITS=32,Yr.MAX_NB_BITS_COMPACT=4,Yr.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 Xr{encode(t,e,r,n){return this.encodeWithHints(t,e,r,n,null)}encodeWithHints(t,e,r,n,i){let o=yr.ISO_8859_1,s=Yr.DEFAULT_EC_PERCENT,a=Yr.DEFAULT_AZTEC_LAYERS;return null!=i&&(i.has(ur.CHARACTER_SET)&&(o=Tr.forName(i.get(ur.CHARACTER_SET).toString())),i.has(ur.ERROR_CORRECTION)&&(s=m.parseInt(i.get(ur.ERROR_CORRECTION).toString())),i.has(ur.AZTEC_LAYERS)&&(a=m.parseInt(i.get(ur.AZTEC_LAYERS).toString()))),Xr.encodeLayers(t,e,r,n,o,s,a)}static encodeLayers(t,e,r,n,i,o,s){if(e!==U.AZTEC)throw new c("Can only encode AZTEC, but got "+e);let a=Yr.encode(T.getBytes(t,i),o,s);return Xr.renderResult(a,r,n)}static renderResult(t,e,r){let n=t.getMatrix();if(null==n)throw new $;let i=n.getWidth(),o=n.getHeight(),s=Math.max(e,i),a=Math.max(r,o),c=Math.min(s/i,a/o),l=(s-i*c)/2,h=(a-o*c)/2,u=new N(s,a);for(let t=0,e=h;t<o;t++,e+=c)for(let r=0,o=l;r<i;r++,o+=c)n.get(r,t)&&u.setRegion(o,e,c,c);return u}}t.AbstractExpandedDecoder=Vt,t.ArgumentException=a,t.ArithmeticException=K,t.AztecCode=Nr,t.AztecCodeReader=gt,t.AztecCodeWriter=Xr,t.AztecDecoder=et,t.AztecDetector=ft,t.AztecDetectorResult=st,t.AztecEncoder=Yr,t.AztecHighLevelEncoder=Gr,t.AztecPoint=dt,t.BarcodeFormat=U,t.Binarizer=u,t.BinaryBitmap=l,t.BitArray=p,t.BitMatrix=N,t.BitSource=he,t.BrowserAztecCodeReader=class extends F{constructor(t=500){super(new gt,t)}},t.BrowserBarcodeReader=class extends F{constructor(t=500,e){super(new ie(e),t,e)}},t.BrowserCodeReader=F,t.BrowserDatamatrixCodeReader=class extends F{constructor(t=500){super(new ge,t)}},t.BrowserMultiFormatReader=class extends F{constructor(t=null,e=500){const r=new lr;r.setHints(t),super(r,e)}decodeBitmap(t){return this.reader.decodeWithState(t)}},t.BrowserPDF417Reader=class extends F{constructor(t=500){super(new ar,t)}},t.BrowserQRCodeReader=class extends F{constructor(t=500){super(new Le,t)}},t.BrowserQRCodeSvgWriter=Er,t.CharacterSetECI=I,t.ChecksumException=h,t.Code128Reader=mt,t.Code39Reader=pt,t.DataMatrixDecodedBitStreamParser=ue,t.DataMatrixReader=ge,t.DecodeHintType=C,t.DecoderResult=j,t.DefaultGridSampler=ht,t.DetectorResult=ot,t.EAN13Reader=Tt,t.EncodeHintType=ur,t.Exception=s,t.FormatException=E,t.GenericGF=q,t.GenericGFPoly=Q,t.GlobalHistogramBinarizer=M,t.GridSampler=ct,t.GridSamplerInstance=ut,t.HTMLCanvasElementLuminanceSource=B,t.HybridBinarizer=R,t.ITFReader=At,t.IllegalArgumentException=c,t.IllegalStateException=$,t.InvertedLuminanceSource=b,t.LuminanceSource=O,t.MathUtils=rt,t.MultiFormatOneDReader=ie,t.MultiFormatReader=lr,t.MultiFormatWriter=class{encode(t,e,r,n,i){let o;if(e!==U.QR_CODE)throw new c("No encoder available for format "+e);return o=new Ir,o.encode(t,e,r,n,i)}},t.NotFoundException=D,t.OneDReader=wt,t.PDF417DecodedBitStreamParser=or,t.PDF417DecoderErrorCorrection=He,t.PDF417Reader=ar,t.PDF417ResultMetadata=Ke,t.PerspectiveTransform=lt,t.PlanarYUVLuminanceSource=Sr,t.QRCodeByteMatrix=gr,t.QRCodeDataMask=Ee,t.QRCodeDecodedBitStreamParser=Te,t.QRCodeDecoderErrorCorrectionLevel=we,t.QRCodeDecoderFormatInformation=me,t.QRCodeEncoder=Cr,t.QRCodeEncoderQRCode=wr,t.QRCodeMaskUtil=fr,t.QRCodeMatrixUtil=pr,t.QRCodeMode=_e,t.QRCodeReader=Le,t.QRCodeVersion=Ce,t.QRCodeWriter=Ir,t.RGBLuminanceSource=_r,t.RSS14Reader=ne,t.RSSExpandedReader=ee,t.ReaderException=cr,t.ReedSolomonDecoder=tt,t.ReedSolomonEncoder=dr,t.ReedSolomonException=J,t.Result=x,t.ResultMetadataType=W,t.ResultPoint=it,t.StringUtils=T,t.UnsupportedOperationException=S,t.VideoInputDevice=L,t.WhiteRectangleDetector=at,t.WriterException=mr,t.ZXingArrays=w,t.ZXingCharset=Tr,t.ZXingInteger=m,t.ZXingStandardCharsets=yr,t.ZXingStringBuilder=y,t.ZXingStringEncoding=_,t.ZXingSystem=d,t.createAbstractExpandedDecoder=Jt,Object.defineProperty(t,"__esModule",{value:!0})}(e)}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";var t;r.r(n),r.d(n,{Html5Qrcode:()=>W,Html5QrcodeScanType:()=>i,Html5QrcodeScanner:()=>ft,Html5QrcodeScannerState:()=>w,Html5QrcodeSupportedFormats:()=>t}),function(t){t[t.QR_CODE=0]="QR_CODE",t[t.AZTEC=1]="AZTEC",t[t.CODABAR=2]="CODABAR",t[t.CODE_39=3]="CODE_39",t[t.CODE_93=4]="CODE_93",t[t.CODE_128=5]="CODE_128",t[t.DATA_MATRIX=6]="DATA_MATRIX",t[t.MAXICODE=7]="MAXICODE",t[t.ITF=8]="ITF",t[t.EAN_13=9]="EAN_13",t[t.EAN_8=10]="EAN_8",t[t.PDF_417=11]="PDF_417",t[t.RSS_14=12]="RSS_14",t[t.RSS_EXPANDED=13]="RSS_EXPANDED",t[t.UPC_A=14]="UPC_A",t[t.UPC_E=15]="UPC_E",t[t.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"}(t||(t={}));var e,i,o=new Map([[t.QR_CODE,"QR_CODE"],[t.AZTEC,"AZTEC"],[t.CODABAR,"CODABAR"],[t.CODE_39,"CODE_39"],[t.CODE_93,"CODE_93"],[t.CODE_128,"CODE_128"],[t.DATA_MATRIX,"DATA_MATRIX"],[t.MAXICODE,"MAXICODE"],[t.ITF,"ITF"],[t.EAN_13,"EAN_13"],[t.EAN_8,"EAN_8"],[t.PDF_417,"PDF_417"],[t.RSS_14,"RSS_14"],[t.RSS_EXPANDED,"RSS_EXPANDED"],[t.UPC_A,"UPC_A"],[t.UPC_E,"UPC_E"],[t.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]);function s(e){return Object.values(t).includes(e)}!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.URL=1]="URL"}(e||(e={})),function(t){t[t.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",t[t.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"}(i||(i={}));var a,c=function(){function t(){}return t.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",t.SCAN_DEFAULT_FPS=2,t.DEFAULT_DISABLE_FLIP=!1,t.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,t.DEFAULT_SUPPORTED_SCAN_TYPE=[i.SCAN_TYPE_CAMERA,i.SCAN_TYPE_FILE],t}(),l=function(){function t(t,e){this.format=t,this.formatName=e}return t.prototype.toString=function(){return this.formatName},t.create=function(e){if(!o.has(e))throw"".concat(e," not in html5QrcodeSupportedFormatsTextMap");return new t(e,o.get(e))},t}(),h=function(){function t(){}return t.createFromText=function(t){return{decodedText:t,result:{text:t}}},t.createFromQrcodeResult=function(t){return{decodedText:t.text,result:t}},t}();!function(t){t[t.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",t[t.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",t[t.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"}(a||(a={}));var u=function(){function t(){}return t.createFrom=function(t){return{errorMessage:t,type:a.UNKWOWN_ERROR}},t}(),d=function(){function t(t){this.verbose=t}return t.prototype.log=function(t){this.verbose&&console.log(t)},t.prototype.warn=function(t){this.verbose&&console.warn(t)},t.prototype.logError=function(t,e){(this.verbose||!0===e)&&console.error(t)},t.prototype.logErrors=function(t){if(0===t.length)throw"Logger#logError called without arguments";this.verbose&&console.error(t)},t}();function f(t){return null==t}var g,w,m=function(){function t(){}return t.codeParseError=function(t){return"QR code parse error, error = ".concat(t)},t.errorGettingUserMedia=function(t){return"Error getting userMedia, error = ".concat(t)},t.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},t.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},t.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},t.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},t.scannerPaused=function(){return"Scanner paused"},t}(),p=function(){function t(){}return t.scanningStatus=function(){return"Scanning"},t.idleStatus=function(){return"Idle"},t.errorStatus=function(){return"Error"},t.permissionStatus=function(){return"Permission"},t.noCameraFoundErrorStatus=function(){return"No Cameras"},t.lastMatch=function(t){return"Last Match: ".concat(t)},t.codeScannerTitle=function(){return"Code Scanner"},t.cameraPermissionTitle=function(){return"Request Camera Permissions"},t.cameraPermissionRequesting=function(){return"Requesting camera permissions..."},t.noCameraFound=function(){return"No camera found"},t.scanButtonStopScanningText=function(){return"Stop Scanning"},t.scanButtonStartScanningText=function(){return"Start Scanning"},t.torchOnButton=function(){return"Switch On Torch"},t.torchOffButton=function(){return"Switch Off Torch"},t.torchOnFailedMessage=function(){return"Failed to turn on torch"},t.torchOffFailedMessage=function(){return"Failed to turn off torch"},t.scanButtonScanningStarting=function(){return"Launching Camera..."},t.textIfCameraScanSelected=function(){return"Scan an Image File"},t.textIfFileScanSelected=function(){return"Scan using camera directly"},t.selectCamera=function(){return"Select Camera"},t.fileSelectionChooseImage=function(){return"Choose Image"},t.fileSelectionChooseAnother=function(){return"Choose Another"},t.fileSelectionNoImageSelected=function(){return"No image choosen"},t.anonymousCameraPrefix=function(){return"Anonymous Camera"},t.dragAndDropMessage=function(){return"Or drop an image to scan"},t.dragAndDropMessageOnlyImages=function(){return"Or drop an image to scan (other files not supported)"},t.zoom=function(){return"zoom"},t.loadingImage=function(){return"Loading image..."},t.cameraScanAltText=function(){return"Camera based scan"},t.fileScanAltText=function(){return"Fule based scan"},t}(),A=function(){function t(){}return t.poweredBy=function(){return"Powered by "},t.reportIssues=function(){return"Report issues"},t}(),C=function(){function t(){}return t.isMediaStreamConstraintsValid=function(t,e){if("object"!=typeof t){var r=typeof t;return e.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(r,"."),!0),!1}for(var n=new Set(["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"]),i=0,o=Object.keys(t);i<o.length;i++){var s=o[i];if(n.has(s))return e.logError("".concat(s," is not supported videoConstaints."),!0),!1}return!0},t}(),E=r(449),I=function(){function e(e,r,n){if(this.formatMap=new Map([[t.QR_CODE,E.BarcodeFormat.QR_CODE],[t.AZTEC,E.BarcodeFormat.AZTEC],[t.CODABAR,E.BarcodeFormat.CODABAR],[t.CODE_39,E.BarcodeFormat.CODE_39],[t.CODE_93,E.BarcodeFormat.CODE_93],[t.CODE_128,E.BarcodeFormat.CODE_128],[t.DATA_MATRIX,E.BarcodeFormat.DATA_MATRIX],[t.MAXICODE,E.BarcodeFormat.MAXICODE],[t.ITF,E.BarcodeFormat.ITF],[t.EAN_13,E.BarcodeFormat.EAN_13],[t.EAN_8,E.BarcodeFormat.EAN_8],[t.PDF_417,E.BarcodeFormat.PDF_417],[t.RSS_14,E.BarcodeFormat.RSS_14],[t.RSS_EXPANDED,E.BarcodeFormat.RSS_EXPANDED],[t.UPC_A,E.BarcodeFormat.UPC_A],[t.UPC_E,E.BarcodeFormat.UPC_E],[t.UPC_EAN_EXTENSION,E.BarcodeFormat.UPC_EAN_EXTENSION]]),this.reverseFormatMap=this.createReverseFormatMap(),!E)throw"Use html5qrcode.min.js without edit, ZXing not found.";this.verbose=r,this.logger=n;var i=this.createZXingFormats(e),o=new Map;o.set(E.DecodeHintType.POSSIBLE_FORMATS,i),o.set(E.DecodeHintType.TRY_HARDER,!1),this.hints=o}return e.prototype.decodeAsync=function(t){var e=this;return new Promise((function(r,n){try{r(e.decode(t))}catch(t){n(t)}}))},e.prototype.decode=function(t){var e=new E.MultiFormatReader(this.verbose,this.hints),r=new E.HTMLCanvasElementLuminanceSource(t),n=new E.BinaryBitmap(new E.HybridBinarizer(r)),i=e.decode(n);return{text:i.text,format:l.create(this.toHtml5QrcodeSupportedFormats(i.format)),debugData:this.createDebugData()}},e.prototype.createReverseFormatMap=function(){var t=new Map;return this.formatMap.forEach((function(e,r,n){t.set(e,r)})),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 e=[],r=0,n=t;r<n.length;r++){var i=n[r];this.formatMap.has(i)?e.push(this.formatMap.get(i)):this.logger.logError("".concat(i," is not supported by")+"ZXingHtml5QrcodeShim")}return e},e.prototype.createDebugData=function(){return{decoderName:"zxing-js"}},e}(),S=function(){function e(r,n,i){if(this.formatMap=new Map([[t.QR_CODE,"qr_code"],[t.AZTEC,"aztec"],[t.CODABAR,"codabar"],[t.CODE_39,"code_39"],[t.CODE_93,"code_93"],[t.CODE_128,"code_128"],[t.DATA_MATRIX,"data_matrix"],[t.ITF,"itf"],[t.EAN_13,"ean_13"],[t.EAN_8,"ean_8"],[t.PDF_417,"pdf417"],[t.UPC_A,"upc_a"],[t.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=n,this.logger=i;var o=this.createBarcodeDetectorFormats(r);if(this.detector=new BarcodeDetector(o),!this.detector)throw"BarcodeDetector detector not supported"}return e.isSupported=function(){return"BarcodeDetector"in window&&void 0!==new BarcodeDetector({formats:["qr_code"]})},e.prototype.decodeAsync=function(t){return e=this,r=void 0,i=function(){var e,r;return function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(n){switch(n.label){case 0:return[4,this.detector.detect(t)];case 1:if(!(e=n.sent())||0===e.length)throw"No barcode or QR code detected.";return[2,{text:(r=this.selectLargestBarcode(e)).rawValue,format:l.create(this.toHtml5QrcodeSupportedFormats(r.format)),debugData:this.createDebugData()}]}}))},new((n=void 0)||(n=Promise))((function(t,o){function s(t){try{c(i.next(t))}catch(t){o(t)}}function a(t){try{c(i.throw(t))}catch(t){o(t)}}function c(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(t){t(r)}))).then(s,a)}c((i=i.apply(e,r||[])).next())}));var e,r,n,i},e.prototype.selectLargestBarcode=function(t){for(var e=null,r=0,n=0,i=t;n<i.length;n++){var o=i[n],s=o.boundingBox.width*o.boundingBox.height;s>r&&(r=s,e=o)}if(!e)throw"No largest barcode found";return e},e.prototype.createBarcodeDetectorFormats=function(t){for(var e=[],r=0,n=t;r<n.length;r++){var i=n[r];this.formatMap.has(i)?e.push(this.formatMap.get(i)):this.logger.warn("".concat(i," is not supported by")+"BarcodeDetectorDelegate")}return{formats:e}},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(e,r,n){t.set(e,r)})),t},e.prototype.createDebugData=function(){return{decoderName:"BarcodeDetector"}},e}(),_=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},T=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},y=function(){function t(t,e,r,n){this.EXECUTIONS_TO_REPORT_PERFORMANCE=100,this.executions=0,this.executionResults=[],this.wasPrimaryDecoderUsedInLastDecode=!1,this.verbose=r,e&&S.isSupported()?(this.primaryDecoder=new S(t,r,n),this.secondaryDecoder=new I(t,r,n)):this.primaryDecoder=new I(t,r,n)}return t.prototype.decodeAsync=function(t){return _(this,void 0,void 0,(function(){var e;return T(this,(function(r){switch(r.label){case 0:e=performance.now(),r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.getDecoder().decodeAsync(t)];case 2:return[2,r.sent()];case 3:return this.possiblyLogPerformance(e),[7];case 4:return[2]}}))}))},t.prototype.decodeRobustlyAsync=function(t){return _(this,void 0,void 0,(function(){var e,r;return T(this,(function(n){switch(n.label){case 0:e=performance.now(),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,this.primaryDecoder.decodeAsync(t)];case 2:return[2,n.sent()];case 3:if(r=n.sent(),this.secondaryDecoder)return[2,this.secondaryDecoder.decodeAsync(t)];throw r;case 4:return this.possiblyLogPerformance(e),[7];case 5:return[2]}}))}))},t.prototype.getDecoder=function(){return this.secondaryDecoder?!1===this.wasPrimaryDecoderUsedInLastDecode?(this.wasPrimaryDecoderUsedInLastDecode=!0,this.primaryDecoder):(this.wasPrimaryDecoderUsedInLastDecode=!1,this.secondaryDecoder):this.primaryDecoder},t.prototype.possiblyLogPerformance=function(t){if(this.verbose){var e=performance.now()-t;this.executionResults.push(e),this.executions++,this.possiblyFlushPerformanceReport()}},t.prototype.possiblyFlushPerformanceReport=function(){if(!(this.executions<this.EXECUTIONS_TO_REPORT_PERFORMANCE)){for(var t=0,e=0,r=this.executionResults;e<r.length;e++)t+=r[e];var n=t/this.executionResults.length;console.log("".concat(n," ms for ").concat(this.executionResults.length," last runs.")),this.executions=0,this.executionResults=[]}},t}(),N=(g=function(t,e){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},g(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}g(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),D=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},M=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},R=function(){function t(t,e){this.name=t,this.track=e}return t.prototype.isSupported=function(){return!!this.track.getCapabilities&&this.name in this.track.getCapabilities()},t.prototype.apply=function(t){var e={};e[this.name]=t;var r={advanced:[e]};return this.track.applyConstraints(r)},t.prototype.value=function(){var t=this.track.getSettings();return this.name in t?t[this.name]:null},t}(),O=function(t){function e(e){return t.call(this,"zoom",e)||this}return N(e,t),e}(function(t){function e(e,r){return t.call(this,e,r)||this}return N(e,t),e.prototype.min=function(){return this.getCapabilities().min},e.prototype.max=function(){return this.getCapabilities().max},e.prototype.step=function(){return this.getCapabilities().step},e.prototype.apply=function(t){var e={};e[this.name]=t;var r={advanced:[e]};return this.track.applyConstraints(r)},e.prototype.getCapabilities=function(){this.failIfNotSupported();var t=this.track.getCapabilities()[this.name];return{min:t.min,max:t.max,step:t.step}},e.prototype.failIfNotSupported=function(){if(!this.isSupported())throw new Error("".concat(this.name," capability not supported"))},e}(R)),b=function(t){function e(e){return t.call(this,"torch",e)||this}return N(e,t),e}(R),B=function(){function t(t){this.track=t}return t.prototype.zoomFeature=function(){return new O(this.track)},t.prototype.torchFeature=function(){return new b(this.track)},t}(),L=function(){function t(t,e,r){this.isClosed=!1,this.parentElement=t,this.mediaStream=e,this.callbacks=r,this.surface=this.createVideoElement(this.parentElement.clientWidth),t.append(this.surface)}return t.prototype.createVideoElement=function(t){var e=document.createElement("video");return e.style.width="".concat(t,"px"),e.style.display="block",e.muted=!0,e.setAttribute("muted","true"),e.playsInline=!0,e},t.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 e=function(){var r=t.surface.clientWidth,n=t.surface.clientHeight;t.callbacks.onRenderSurfaceReady(r,n),t.surface.removeEventListener("playing",e)};this.surface.addEventListener("playing",e),this.surface.srcObject=this.mediaStream,this.surface.play()},t.create=function(e,r,n,i){return D(this,void 0,void 0,(function(){var o,s;return M(this,(function(a){switch(a.label){case 0:return o=new t(e,r,i),n.aspectRatio?(s={aspectRatio:n.aspectRatio},[4,o.getFirstTrackOrFail().applyConstraints(s)]):[3,2];case 1:a.sent(),a.label=2;case 2:return o.setupSurface(),[2,o]}}))}))},t.prototype.failIfClosed=function(){if(this.isClosed)throw"The RenderedCamera has already been closed."},t.prototype.getFirstTrackOrFail=function(){if(this.failIfClosed(),0===this.mediaStream.getVideoTracks().length)throw"No video tracks found";return this.mediaStream.getVideoTracks()[0]},t.prototype.pause=function(){this.failIfClosed(),this.surface.pause()},t.prototype.resume=function(t){this.failIfClosed();var e=this,r=function(){setTimeout(t,200),e.surface.removeEventListener("playing",r)};this.surface.addEventListener("playing",r),this.surface.play()},t.prototype.isPaused=function(){return this.failIfClosed(),this.surface.paused},t.prototype.getSurface=function(){return this.failIfClosed(),this.surface},t.prototype.getRunningTrackCapabilities=function(){return this.getFirstTrackOrFail().getCapabilities()},t.prototype.getRunningTrackSettings=function(){return this.getFirstTrackOrFail().getSettings()},t.prototype.applyVideoConstraints=function(t){return D(this,void 0,void 0,(function(){return M(this,(function(e){if("aspectRatio"in t)throw"Changing 'aspectRatio' in run-time is not yet supported.";return[2,this.getFirstTrackOrFail().applyConstraints(t)]}))}))},t.prototype.close=function(){if(this.isClosed)return Promise.resolve();var t=this;return new Promise((function(e,r){var n=t.mediaStream.getVideoTracks().length,i=0;t.mediaStream.getVideoTracks().forEach((function(r){t.mediaStream.removeTrack(r),r.stop(),++i>=n&&(t.isClosed=!0,t.parentElement.removeChild(t.surface),e())}))}))},t.prototype.getCapabilities=function(){return new B(this.getFirstTrackOrFail())},t}(),P=function(){function t(t){this.mediaStream=t}return t.prototype.render=function(t,e,r){return D(this,void 0,void 0,(function(){return M(this,(function(n){return[2,L.create(t,this.mediaStream,e,r)]}))}))},t.create=function(e){return D(this,void 0,void 0,(function(){var r;return M(this,(function(n){switch(n.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return r={audio:!1,video:e},[4,navigator.mediaDevices.getUserMedia(r)];case 1:return[2,new t(n.sent())]}}))}))},t}(),v=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},F=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},x=function(){function t(){}return t.failIfNotSupported=function(){return v(this,void 0,void 0,(function(){return F(this,(function(e){if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return[2,new t]}))}))},t.prototype.create=function(t){return v(this,void 0,void 0,(function(){return F(this,(function(e){return[2,P.create(t)]}))}))},t}(),k=function(){function t(){}return t.retrieve=function(){if(navigator.mediaDevices)return t.getCamerasFromMediaDevices();var e=MediaStreamTrack;return MediaStreamTrack&&e.getSources?t.getCamerasFromMediaStreamTrack():t.rejectWithError()},t.rejectWithError=function(){var e=m.unableToQuerySupportedDevices();return t.isHttpsOrLocalhost()||(e=m.insecureContextCameraQueryError()),Promise.reject(e)},t.isHttpsOrLocalhost=function(){if("https:"===location.protocol)return!0;var t=location.host.split(":")[0];return"127.0.0.1"===t||"localhost"===t},t.getCamerasFromMediaDevices=function(){return t=this,e=void 0,n=function(){var t,e,r,n,i,o,s;return function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(a){switch(a.label){case 0:return t=function(t){for(var e=0,r=t.getVideoTracks();e<r.length;e++){var n=r[e];n.enabled=!1,n.stop(),t.removeTrack(n)}},[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 1:return e=a.sent(),[4,navigator.mediaDevices.enumerateDevices()];case 2:for(r=a.sent(),n=[],i=0,o=r;i<o.length;i++)"videoinput"===(s=o[i]).kind&&n.push({id:s.deviceId,label:s.label});return t(e),[2,n]}}))},new((r=void 0)||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}));var t,e,r,n},t.getCamerasFromMediaStreamTrack=function(){return new Promise((function(t,e){MediaStreamTrack.getSources((function(e){for(var r=[],n=0,i=e;n<i.length;n++){var o=i[n];"video"===o.kind&&r.push({id:o.id,label:o.label})}t(r)}))}))},t}();!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.NOT_STARTED=1]="NOT_STARTED",t[t.SCANNING=2]="SCANNING",t[t.PAUSED=3]="PAUSED"}(w||(w={}));var U,H=function(){function t(){this.state=w.NOT_STARTED,this.onGoingTransactionNewState=w.UNKNOWN}return t.prototype.directTransition=function(t){this.failIfTransitionOngoing(),this.validateTransition(t),this.state=t},t.prototype.startTransition=function(t){return this.failIfTransitionOngoing(),this.validateTransition(t),this.onGoingTransactionNewState=t,this},t.prototype.execute=function(){if(this.onGoingTransactionNewState===w.UNKNOWN)throw"Transaction is already cancelled, cannot execute().";var t=this.onGoingTransactionNewState;this.onGoingTransactionNewState=w.UNKNOWN,this.directTransition(t)},t.prototype.cancel=function(){if(this.onGoingTransactionNewState===w.UNKNOWN)throw"Transaction is already cancelled, cannot cancel().";this.onGoingTransactionNewState=w.UNKNOWN},t.prototype.getState=function(){return this.state},t.prototype.failIfTransitionOngoing=function(){if(this.onGoingTransactionNewState!==w.UNKNOWN)throw"Cannot transition to a new state, already under transition"},t.prototype.validateTransition=function(t){switch(this.state){case w.UNKNOWN:throw"Transition from unknown is not allowed";case w.NOT_STARTED:this.failIfNewStateIs(t,[w.PAUSED]);case w.SCANNING:case w.PAUSED:}},t.prototype.failIfNewStateIs=function(t,e){for(var r=0,n=e;r<n.length;r++)if(t===n[r])throw"Cannot transition from ".concat(this.state," to ").concat(t)},t}(),V=function(){function t(t){this.stateManager=t}return t.prototype.startTransition=function(t){return this.stateManager.startTransition(t)},t.prototype.directTransition=function(t){this.stateManager.directTransition(t)},t.prototype.getState=function(){return this.stateManager.getState()},t.prototype.canScanFile=function(){return this.stateManager.getState()===w.NOT_STARTED},t.prototype.isScanning=function(){return this.stateManager.getState()!==w.NOT_STARTED},t.prototype.isStrictlyScanning=function(){return this.stateManager.getState()===w.SCANNING},t.prototype.isPaused=function(){return this.stateManager.getState()===w.PAUSED},t}(),z=function(){function t(){}return t.create=function(){return new V(new H)},t}(),G=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return G(e,t),e.DEFAULT_WIDTH=300,e.DEFAULT_WIDTH_OFFSET=2,e.FILE_SCAN_MIN_HEIGHT=300,e.FILE_SCAN_HIDDEN_CANVAS_PADDING=100,e.MIN_QR_BOX_SIZE=50,e.SHADED_LEFT=1,e.SHADED_RIGHT=2,e.SHADED_TOP=3,e.SHADED_BOTTOM=4,e.SHADED_REGION_ELEMENT_ID="qr-shaded-region",e.VERBOSE=!1,e.BORDER_SHADER_DEFAULT_COLOR="#ffffff",e.BORDER_SHADER_MATCH_COLOR="rgb(90, 193, 56)",e}(c),X=function(){function t(t,e){this.logger=e,this.fps=Y.SCAN_DEFAULT_FPS,t?(t.fps&&(this.fps=t.fps),this.disableFlip=!0===t.disableFlip,this.qrbox=t.qrbox,this.aspectRatio=t.aspectRatio,this.videoConstraints=t.videoConstraints):this.disableFlip=Y.DEFAULT_DISABLE_FLIP}return t.prototype.isMediaStreamConstraintsValid=function(){return this.videoConstraints?C.isMediaStreamConstraintsValid(this.videoConstraints,this.logger):(this.logger.logError("Empty videoConstraints",!0),!1)},t.prototype.isShadedBoxEnabled=function(){return!f(this.qrbox)},t.create=function(e,r){return new t(e,r)},t}(),W=function(){function e(t,e){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");var r;this.elementId=t,this.verbose=!1,"boolean"==typeof e?this.verbose=!0===e:e&&(r=e,this.verbose=!0===r.verbose,r.experimentalFeatures),this.logger=new d(this.verbose),this.qrcode=new y(this.getSupportedFormats(e),this.getUseBarCodeDetectorIfSupported(r),this.verbose,this.logger),this.foreverScanTimeout,this.shouldScan=!0,this.stateManagerProxy=z.create()}return e.prototype.start=function(t,e,r,n){var i,o=this;if(!t)throw"cameraIdOrConfig is required";if(!r||"function"!=typeof r)throw"qrCodeSuccessCallback is required and should be a function.";i=n||(this.verbose?this.logger.log:function(){});var s=X.create(e,this.logger);this.clearElement();var a=!1;s.videoConstraints&&(s.isMediaStreamConstraintsValid()?a=!0:this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, it will be ignored.'",!0));var c=a,l=document.getElementById(this.elementId);l.clientWidth?l.clientWidth:Y.DEFAULT_WIDTH,l.style.position="relative",this.shouldScan=!0,this.element=l;var h=this,u=this.stateManagerProxy.startTransition(w.SCANNING);return new Promise((function(e,n){var a=c?s.videoConstraints:h.createVideoConstraints(t);if(!a)return u.cancel(),void n("videoConstraints should be defined");var l={};c&&!s.aspectRatio||(l.aspectRatio=s.aspectRatio);var d={onRenderSurfaceReady:function(t,e){h.setupUi(t,e,s),h.isScanning=!0,h.foreverScan(s,r,i)}};x.failIfNotSupported().then((function(t){t.create(a).then((function(t){return t.render(o.element,l,d).then((function(t){h.renderedCamera=t,u.execute(),e(null)})).catch((function(t){u.cancel(),n(t)}))})).catch((function(t){u.cancel(),n(m.errorGettingUserMedia(t))}))})).catch((function(t){u.cancel(),n(m.cameraStreamingNotSupported())}))}))},e.prototype.pause=function(t){if(!this.stateManagerProxy.isStrictlyScanning())throw"Cannot pause, scanner is not scanning.";this.stateManagerProxy.directTransition(w.PAUSED),this.showPausedState(),(f(t)||!0!==t)&&(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,e=function(){t.stateManagerProxy.directTransition(w.SCANNING),t.hidePausedState()};this.renderedCamera.isPaused()?this.renderedCamera.resume((function(){e()})):e()},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 e=this.stateManagerProxy.startTransition(w.NOT_STARTED);this.shouldScan=!1,this.foreverScanTimeout&&clearTimeout(this.foreverScanTimeout);var r=this;return this.renderedCamera.close().then((function(){return r.renderedCamera=null,r.element&&(r.element.removeChild(r.canvasElement),r.canvasElement=null),function(){if(t.element){var e=document.getElementById(Y.SHADED_REGION_ELEMENT_ID);e&&t.element.removeChild(e)}}(),r.qrRegion&&(r.qrRegion=null),r.context&&(r.context=null),e.execute(),r.hidePausedState(),r.isScanning=!1,Promise.resolve()}))},e.prototype.scanFile=function(t,e){return this.scanFileV2(t,e).then((function(t){return t.decodedText}))},e.prototype.scanFileV2=function(t,e){var r=this;if(!(t&&t instanceof File))throw"imageFile argument is mandatory and should be instance of File. Use 'event.target.files[0]'.";if(f(e)&&(e=!0),!this.stateManagerProxy.canScanFile())throw"Cannot start file scan - ongoing camera scan";return new Promise((function(n,i){r.possiblyCloseLastScanImageFile(),r.clearElement(),r.lastScanImageFile=URL.createObjectURL(t);var o=new Image;o.onload=function(){var t=o.width,s=o.height,a=document.getElementById(r.elementId),c=a.clientWidth?a.clientWidth:Y.DEFAULT_WIDTH,l=Math.max(a.clientHeight?a.clientHeight:s,Y.FILE_SCAN_MIN_HEIGHT),u=r.computeCanvasDrawConfig(t,s,c,l);if(e){var d=r.createCanvasElement(c,l,"qr-canvas-visible");d.style.display="inline-block",a.appendChild(d);var f=d.getContext("2d");if(!f)throw"Unable to get 2d context from canvas";f.canvas.width=c,f.canvas.height=l,f.drawImage(o,0,0,t,s,u.x,u.y,u.width,u.height)}var g=Y.FILE_SCAN_HIDDEN_CANVAS_PADDING,w=Math.max(o.width,u.width),m=Math.max(o.height,u.height),p=w+2*g,A=m+2*g,C=r.createCanvasElement(p,A);a.appendChild(C);var E=C.getContext("2d");if(!E)throw"Unable to get 2d context from canvas";E.canvas.width=p,E.canvas.height=A,E.drawImage(o,0,0,t,s,g,g,w,m);try{r.qrcode.decodeRobustlyAsync(C).then((function(t){n(h.createFromQrcodeResult(t))})).catch(i)}catch(t){i("QR code parse error, error = ".concat(t))}},o.onerror=i,o.onabort=i,o.onstalled=i,o.onsuspend=i,o.src=URL.createObjectURL(t)}))},e.prototype.clear=function(){this.clearElement()},e.getCameras=function(){return k.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)throw"videoConstaints is required argument.";if(!C.isMediaStreamConstraintsValid(t,this.logger))throw"invalid videoConstaints passed, check logs for more details";return this.getRenderedCameraOrFail().applyVideoConstraints(t)},e.prototype.getRenderedCameraOrFail=function(){if(null==this.renderedCamera)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(e){var r=[t.QR_CODE,t.AZTEC,t.CODABAR,t.CODE_39,t.CODE_93,t.CODE_128,t.DATA_MATRIX,t.MAXICODE,t.ITF,t.EAN_13,t.EAN_8,t.PDF_417,t.RSS_14,t.RSS_EXPANDED,t.UPC_A,t.UPC_E,t.UPC_EAN_EXTENSION];if(!e||"boolean"==typeof e)return r;if(!e.formatsToSupport)return r;if(!Array.isArray(e.formatsToSupport))throw"configOrVerbosityFlag.formatsToSupport should be undefined or an array.";if(0===e.formatsToSupport.length)throw"Atleast 1 formatsToSupport is needed.";for(var n=[],i=0,o=e.formatsToSupport;i<o.length;i++){var a=o[i];s(a)?n.push(a):this.logger.warn("Invalid format: ".concat(a," passed in config, ignoring."))}if(0===n.length)throw"None of formatsToSupport match supported values.";return n},e.prototype.getUseBarCodeDetectorIfSupported=function(t){if(f(t))return!0;if(!f(t.useBarCodeDetectorIfSupported))return!1!==t.useBarCodeDetectorIfSupported;if(f(t.experimentalFeatures))return!0;var e=t.experimentalFeatures;return!!f(e.useBarCodeDetectorIfSupported)||!1!==e.useBarCodeDetectorIfSupported},e.prototype.validateQrboxSize=function(t,e,r){var n=r.qrbox;this.validateQrboxConfig(n);var i,o=this.toQrdimensions(t,e,n),s=function(t){if(t<Y.MIN_QR_BOX_SIZE)throw"minimum size of 'config.qrbox' dimension value is"+" ".concat(Y.MIN_QR_BOX_SIZE,"px.")};s(o.width),s(o.height),o.width=((i=o.width)>t&&(this.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."),i=t),i)},e.prototype.validateQrboxConfig=function(t){if("number"!=typeof t&&"function"!=typeof t&&(void 0===t.width||void 0===t.height))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},e.prototype.toQrdimensions=function(t,e,r){if("number"==typeof r)return{width:r,height:r};if("function"==typeof r)try{return r(t,e)}catch(t){throw new Error("qrbox config was passed as a function but it failed with unknown error"+t)}return r},e.prototype.setupUi=function(t,e,r){r.isShadedBoxEnabled()&&this.validateQrboxSize(t,e,r);var n=f(r.qrbox)?{width:t,height:e}:r.qrbox;this.validateQrboxConfig(n);var i=this.toQrdimensions(t,e,n);i.height>e&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var o=r.isShadedBoxEnabled()&&i.height<=e,s={x:0,y:0,width:t,height:e},a=o?this.getShadedRegionBounds(t,e,i):s,c=this.createCanvasElement(a.width,a.height),l=c.getContext("2d",{willReadFrequently:!0});l.canvas.width=a.width,l.canvas.height=a.height,this.element.append(c),o&&this.possiblyInsertShadingElement(this.element,t,e,i),this.createScannerPausedUiElement(this.element),this.qrRegion=a,this.context=l,this.canvasElement=c},e.prototype.createScannerPausedUiElement=function(t){var e=document.createElement("div");e.innerText=m.scannerPaused(),e.style.display="none",e.style.position="absolute",e.style.top="0px",e.style.zIndex="1",e.style.background="rgba(9, 9, 9, 0.46)",e.style.color="#FFECEC",e.style.textAlign="center",e.style.width="100%",t.appendChild(e),this.scannerPausedUiElement=e},e.prototype.scanContext=function(t,e){var r=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then((function(e){return t(e.text,h.createFromQrcodeResult(e)),r.possiblyUpdateShaders(!0),!0})).catch((function(t){r.possiblyUpdateShaders(!1);var n=m.codeParseError(t);return e(n,u.createFrom(n)),!1}))},e.prototype.foreverScan=function(t,e,r){var n=this;if(this.shouldScan&&this.renderedCamera){var i=this.renderedCamera.getSurface(),o=i.videoWidth/i.clientWidth,s=i.videoHeight/i.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var a=this.qrRegion.width*o,c=this.qrRegion.height*s,l=this.qrRegion.x*o,h=this.qrRegion.y*s;this.context.drawImage(i,l,h,a,c,0,0,this.qrRegion.width,this.qrRegion.height);var u=function(){n.foreverScanTimeout=setTimeout((function(){n.foreverScan(t,e,r)}),n.getTimeoutFps(t.fps))};this.scanContext(e,r).then((function(i){i||!0===t.disableFlip?u():(n.context.translate(n.context.canvas.width,0),n.context.scale(-1,1),n.scanContext(e,r).finally((function(){u()})))})).catch((function(t){n.logger.logError("Error happend while scanning context",t),u()}))}},e.prototype.createVideoConstraints=function(t){if("string"==typeof t)return{deviceId:{exact:t}};if("object"==typeof t){var e="facingMode",r="deviceId",n={user:!0,environment:!0},i="exact",o=function(t){if(t in n)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(t,"'")},s=Object.keys(t);if(1!==s.length)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(s.length," keys");var a=Object.keys(t)[0];if(a!==e&&a!==r)throw"Only '".concat(e,"' and '").concat(r,"' ")+" are supported for 'cameraIdOrConfig'";if(a!==e){var c=t.deviceId;if("string"==typeof c)return{deviceId:c};if("object"==typeof c){if(i in c)return{deviceId:{exact:c["".concat(i)]}};throw"'deviceId' should be string or object with"+" ".concat(i," as key.")}throw"Invalid type of 'deviceId' = ".concat(typeof c)}var l=t.facingMode;if("string"==typeof l){if(o(l))return{facingMode:l}}else{if("object"!=typeof l)throw"Invalid type of 'facingMode' = ".concat(typeof l);if(!(i in l))throw"'facingMode' should be string or object with"+" ".concat(i," as key.");if(o(l["".concat(i)]))return{facingMode:{exact:l["".concat(i)]}}}}throw"Invalid type of 'cameraIdOrConfig' = ".concat(typeof t)},e.prototype.computeCanvasDrawConfig=function(t,e,r,n){if(t<=r&&e<=n)return{x:(r-t)/2,y:(n-e)/2,width:t,height:e};var i=t,o=e;return t>r&&(e*=r/t,t=r),e>n&&(t*=n/e,e=n),this.logger.log("Image downsampled from "+"".concat(i,"X").concat(o)+" to ".concat(t,"X").concat(e,".")),this.computeCanvasDrawConfig(t,e,r,n)},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(e){e.style.backgroundColor=t?Y.BORDER_SHADER_MATCH_COLOR:Y.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,e,r){var n=t,i=e,o=document.createElement("canvas");return o.style.width="".concat(n,"px"),o.style.height="".concat(i,"px"),o.style.display="none",o.id=f(r)?"qr-canvas":r,o},e.prototype.getShadedRegionBounds=function(t,e,r){if(r.width>t||r.height>e)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(t-r.width)/2,y:(e-r.height)/2,width:r.width,height:r.height}},e.prototype.possiblyInsertShadingElement=function(t,e,r,n){if(!(e-n.width<1||r-n.height<1)){var i=document.createElement("div");i.style.position="absolute";var o=(e-n.width)/2,s=(r-n.height)/2;if(i.style.borderLeft="".concat(o,"px solid rgba(0, 0, 0, 0.48)"),i.style.borderRight="".concat(o,"px solid rgba(0, 0, 0, 0.48)"),i.style.borderTop="".concat(s,"px solid rgba(0, 0, 0, 0.48)"),i.style.borderBottom="".concat(s,"px solid rgba(0, 0, 0, 0.48)"),i.style.boxSizing="border-box",i.style.top="0px",i.style.bottom="0px",i.style.left="0px",i.style.right="0px",i.id="".concat(Y.SHADED_REGION_ELEMENT_ID),e-n.width<11||r-n.height<11)this.hasBorderShaders=!1;else{this.insertShaderBorders(i,40,5,-5,null,0,!0),this.insertShaderBorders(i,40,5,-5,null,0,!1),this.insertShaderBorders(i,40,5,null,-5,0,!0),this.insertShaderBorders(i,40,5,null,-5,0,!1),this.insertShaderBorders(i,5,45,-5,null,-5,!0),this.insertShaderBorders(i,5,45,null,-5,-5,!0),this.insertShaderBorders(i,5,45,-5,null,-5,!1),this.insertShaderBorders(i,5,45,null,-5,-5,!1),this.hasBorderShaders=!0}t.append(i)}},e.prototype.insertShaderBorders=function(t,e,r,n,i,o,s){var a=document.createElement("div");a.style.position="absolute",a.style.backgroundColor=Y.BORDER_SHADER_DEFAULT_COLOR,a.style.width="".concat(e,"px"),a.style.height="".concat(r,"px"),null!==n&&(a.style.top="".concat(n,"px")),null!==i&&(a.style.bottom="".concat(i,"px")),s?a.style.left="".concat(o,"px"):a.style.right="".concat(o,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(a),t.appendChild(a)},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}(),j="data:image/svg+xml;base64,",Z=j+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzNzEuNjQzIDM3MS42NDMiIHN0eWxlPSJlbmFibGUtYmFja2dyb3V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UuNzEtMTUuNzFoNDMuMTAxYzguNjc2IDAgMTUuNzEgNy4wMzMgMTUuNzEgMTUuNzFWMzc3LjM2ek0yMzAgMTU3Yy0yMS41MzkgMC0zOS0xNy40NjEtMzktMzlzMTcuNDYxLTM5IDM5LTM5IDM5IDE3LjQ2MSAzOSAzOS0xNy40NjEgMzktMzkgMzl6Ii8+PC9zdmc+",q=function(){function t(){}return t.createDefault=function(){return{hasPermission:!1,lastUsedCameraId:null}},t}(),J=function(){function t(){this.data=q.createDefault();var e=localStorage.getItem(t.LOCAL_STORAGE_KEY);e?this.data=JSON.parse(e):this.reset()}return t.prototype.hasCameraPermissions=function(){return this.data.hasPermission},t.prototype.getLastUsedCameraId=function(){return this.data.lastUsedCameraId},t.prototype.setHasPermission=function(t){this.data.hasPermission=t,this.flush()},t.prototype.setLastUsedCameraId=function(t){this.data.lastUsedCameraId=t,this.flush()},t.prototype.resetLastUsedCameraId=function(){this.data.lastUsedCameraId=null,this.flush()},t.prototype.reset=function(){this.data=q.createDefault(),this.flush()},t.prototype.flush=function(){localStorage.setItem(t.LOCAL_STORAGE_KEY,JSON.stringify(this.data))},t.LOCAL_STORAGE_KEY="HTML5_QRCODE_DATA",t}(),$=function(){function t(){this.infoDiv=document.createElement("div")}return t.prototype.renderInto=function(t){this.infoDiv.style.position="absolute",this.infoDiv.style.top="10px",this.infoDiv.style.right="10px",this.infoDiv.style.zIndex="2",this.infoDiv.style.display="none",this.infoDiv.style.padding="5pt",this.infoDiv.style.border="1px solid #171717",this.infoDiv.style.fontSize="10pt",this.infoDiv.style.background="rgb(0 0 0 / 69%)",this.infoDiv.style.borderRadius="5px",this.infoDiv.style.textAlign="center",this.infoDiv.style.fontWeight="400",this.infoDiv.style.color="white",this.infoDiv.innerText=A.poweredBy();var e=document.createElement("a");e.innerText="ScanApp",e.href="https://scanapp.org",e.target="new",e.style.color="white",this.infoDiv.appendChild(e);var r=document.createElement("br"),n=document.createElement("br");this.infoDiv.appendChild(r),this.infoDiv.appendChild(n);var i=document.createElement("a");i.innerText=A.reportIssues(),i.href="https://github.com/mebjas/html5-qrcode/issues",i.target="new",i.style.color="white",this.infoDiv.appendChild(i),t.appendChild(this.infoDiv)},t.prototype.show=function(){this.infoDiv.style.display="block"},t.prototype.hide=function(){this.infoDiv.style.display="none"},t}(),tt=function(){function t(t,e){this.isShowingInfoIcon=!0,this.onTapIn=t,this.onTapOut=e,this.infoIcon=document.createElement("img")}return t.prototype.renderInto=function(t){var e=this;this.infoIcon.alt="Info icon",this.infoIcon.src=K,this.infoIcon.style.position="absolute",this.infoIcon.style.top="4px",this.infoIcon.style.right="4px",this.infoIcon.style.opacity="0.6",this.infoIcon.style.cursor="pointer",this.infoIcon.style.zIndex="2",this.infoIcon.style.width="16px",this.infoIcon.style.height="16px",this.infoIcon.onmouseover=function(t){return e.onHoverIn()},this.infoIcon.onmouseout=function(t){return e.onHoverOut()},this.infoIcon.onclick=function(t){return e.onClick()},t.appendChild(this.infoIcon)},t.prototype.onHoverIn=function(){this.isShowingInfoIcon&&(this.infoIcon.style.opacity="1")},t.prototype.onHoverOut=function(){this.isShowingInfoIcon&&(this.infoIcon.style.opacity="0.6")},t.prototype.onClick=function(){this.isShowingInfoIcon?(this.isShowingInfoIcon=!1,this.onTapIn(),this.infoIcon.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAQgAAAEIBarqQRAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAE1SURBVDiNfdI7S0NBEAXgLya1otFgpbYSbISAgpXYi6CmiH9KCAiChaVga6OiWPgfRDQ+0itaGVNosXtluWwcuMzePfM4M3sq8lbHBubwg1dc4m1E/J/N4ghDPOIsfk/4xiEao5KX0McFljN4C9d4QTPXuY99jP3DsIoDPGM6BY5i5yI5R7O4q+ImFkJY2DCh3cAH2klyB+9J1xUMMAG7eCh1a+Mr+k48b5diXrFVwwLuS+BJ9MfR7+G0FHOHhTHhnXNWS87VDF4pcnfQK4Ep7XScNLmPTZgURNKKYENYWDpzW1BhscS1WHS8CDgURFJQrWcoF3c13KKbgg1BYQfy8xZWEzTTw1QZbAoKu8FqJnktdu5hcVSHmchiILzzuaDQvjBzV2m8yohCE1jHfPx/xhU+y4G/D75ELlRJsSYAAAAASUVORK5CYII=",this.infoIcon.style.opacity="1"):(this.isShowingInfoIcon=!0,this.onTapOut(),this.infoIcon.src=K,this.infoIcon.style.opacity="0.6")},t}(),et=function(){function t(){var t=this;this.infoDiv=new $,this.infoIcon=new tt((function(){t.infoDiv.show()}),(function(){t.infoDiv.hide()}))}return t.prototype.renderInto=function(t){this.infoDiv.renderInto(t),this.infoIcon.renderInto(t)},t}(),rt=function(){function t(){}return t.hasPermissions=function(){return t=this,e=void 0,n=function(){var t,e,r,n;return function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(i){switch(i.label){case 0:return[4,navigator.mediaDevices.enumerateDevices()];case 1:for(t=i.sent(),e=0,r=t;e<r.length;e++)if("videoinput"===(n=r[e]).kind&&n.label)return[2,!0];return[2,!1]}}))},new((r=void 0)||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}));var t,e,r,n},t}(),nt=function(){function t(t){this.supportedScanTypes=this.validateAndReturnScanTypes(t)}return t.prototype.getDefaultScanType=function(){return this.supportedScanTypes[0]},t.prototype.hasMoreThanOneScanType=function(){return this.supportedScanTypes.length>1},t.prototype.isCameraScanRequired=function(){for(var e=0,r=this.supportedScanTypes;e<r.length;e++){var n=r[e];if(t.isCameraScanType(n))return!0}return!1},t.isCameraScanType=function(t){return t===i.SCAN_TYPE_CAMERA},t.isFileScanType=function(t){return t===i.SCAN_TYPE_FILE},t.prototype.validateAndReturnScanTypes=function(t){if(!t||0===t.length)return c.DEFAULT_SUPPORTED_SCAN_TYPE;var e=c.DEFAULT_SUPPORTED_SCAN_TYPE.length;if(t.length>e)throw"Max ".concat(e," values expected for ")+"supportedScanTypes";for(var r=0,n=t;r<n.length;r++){var i=n[r];if(!c.DEFAULT_SUPPORTED_SCAN_TYPE.includes(i))throw"Unsupported scan type ".concat(i)}return t},t}(),it=function(){function t(){}return t.ALL_ELEMENT_CLASS="html5-qrcode-element",t.CAMERA_PERMISSION_BUTTON_ID="html5-qrcode-button-camera-permission",t.CAMERA_START_BUTTON_ID="html5-qrcode-button-camera-start",t.CAMERA_STOP_BUTTON_ID="html5-qrcode-button-camera-stop",t.TORCH_BUTTON_ID="html5-qrcode-button-torch",t.CAMERA_SELECTION_SELECT_ID="html5-qrcode-select-camera",t.FILE_SELECTION_BUTTON_ID="html5-qrcode-button-file-selection",t.ZOOM_SLIDER_ID="html5-qrcode-input-range-zoom",t.SCAN_TYPE_CHANGE_ANCHOR_ID="html5-qrcode-anchor-scan-type-change",t.TORCH_BUTTON_CLASS_TORCH_ON="html5-qrcode-button-torch-on",t.TORCH_BUTTON_CLASS_TORCH_OFF="html5-qrcode-button-torch-off",t}(),ot=function(){function t(){}return t.createElement=function(t,e){var r=document.createElement(t);return r.id=e,r.classList.add(it.ALL_ELEMENT_CLASS),"button"===t&&r.setAttribute("type","button"),r},t}(),st=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},at=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},ct=function(){function t(t,e,r){this.isTorchOn=!1,this.torchCapability=t,this.buttonController=e,this.onTorchActionFailureCallback=r}return t.prototype.isTorchEnabled=function(){return this.isTorchOn},t.prototype.flipState=function(){return st(this,void 0,void 0,(function(){var t,e;return at(this,(function(r){switch(r.label){case 0:this.buttonController.disable(),t=!this.isTorchOn,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.torchCapability.apply(t)];case 2:return r.sent(),this.updateUiBasedOnLatestSettings(this.torchCapability.value(),t),[3,4];case 3:return e=r.sent(),this.propagateFailure(t,e),this.buttonController.enable(),[3,4];case 4:return[2]}}))}))},t.prototype.updateUiBasedOnLatestSettings=function(t,e){t===e?(this.buttonController.setText(e?p.torchOffButton():p.torchOnButton()),this.isTorchOn=e):this.propagateFailure(e),this.buttonController.enable()},t.prototype.propagateFailure=function(t,e){var r=t?p.torchOnFailedMessage():p.torchOffFailedMessage();e&&(r+="; Error = "+e),this.onTorchActionFailureCallback(r)},t.prototype.reset=function(){this.isTorchOn=!1},t}(),lt=function(){function t(t,e){this.onTorchActionFailureCallback=e,this.torchButton=ot.createElement("button",it.TORCH_BUTTON_ID),this.torchController=new ct(t,this,e)}return t.prototype.render=function(t,e){var r=this;this.torchButton.innerText=p.torchOnButton(),this.torchButton.style.display=e.display,this.torchButton.style.marginLeft=e.marginLeft;var n=this;this.torchButton.addEventListener("click",(function(t){return st(r,void 0,void 0,(function(){return at(this,(function(t){switch(t.label){case 0:return[4,n.torchController.flipState()];case 1:return t.sent(),n.torchController.isTorchEnabled()?(n.torchButton.classList.remove(it.TORCH_BUTTON_CLASS_TORCH_OFF),n.torchButton.classList.add(it.TORCH_BUTTON_CLASS_TORCH_ON)):(n.torchButton.classList.remove(it.TORCH_BUTTON_CLASS_TORCH_ON),n.torchButton.classList.add(it.TORCH_BUTTON_CLASS_TORCH_OFF)),[2]}}))}))})),t.appendChild(this.torchButton)},t.prototype.updateTorchCapability=function(t){this.torchController=new ct(t,this,this.onTorchActionFailureCallback)},t.prototype.getTorchButton=function(){return this.torchButton},t.prototype.hide=function(){this.torchButton.style.display="none"},t.prototype.show=function(){this.torchButton.style.display="inline-block"},t.prototype.disable=function(){this.torchButton.disabled=!0},t.prototype.enable=function(){this.torchButton.disabled=!1},t.prototype.setText=function(t){this.torchButton.innerText=t},t.prototype.reset=function(){this.torchButton.innerText=p.torchOnButton(),this.torchController.reset()},t.create=function(e,r,n,i){var o=new t(r,i);return o.render(e,n),o},t}(),ht=function(){function t(t,e,r){this.fileBasedScanRegion=this.createFileBasedScanRegion(),this.fileBasedScanRegion.style.display=e?"block":"none",t.appendChild(this.fileBasedScanRegion);var n=document.createElement("label");n.setAttribute("for",this.getFileScanInputId()),n.style.display="inline-block",this.fileBasedScanRegion.appendChild(n),this.fileSelectionButton=ot.createElement("button",it.FILE_SELECTION_BUTTON_ID),this.setInitialValueToButton(),this.fileSelectionButton.addEventListener("click",(function(t){n.click()})),n.append(this.fileSelectionButton),this.fileScanInput=ot.createElement("input",this.getFileScanInputId()),this.fileScanInput.type="file",this.fileScanInput.accept="image/*",this.fileScanInput.style.display="none",n.appendChild(this.fileScanInput);var i=this;this.fileScanInput.addEventListener("change",(function(t){if(null!=t&&null!=t.target){var e=t.target;if(!e.files||0!==e.files.length){var n=e.files[0],o=n.name;i.setImageNameToButton(o),r(n)}}}));var o=this.createDragAndDropMessage();this.fileBasedScanRegion.appendChild(o),this.fileBasedScanRegion.addEventListener("dragenter",(function(t){i.fileBasedScanRegion.style.border=i.fileBasedScanRegionActiveBorder(),t.stopPropagation(),t.preventDefault()})),this.fileBasedScanRegion.addEventListener("dragleave",(function(t){i.fileBasedScanRegion.style.border=i.fileBasedScanRegionDefaultBorder(),t.stopPropagation(),t.preventDefault()})),this.fileBasedScanRegion.addEventListener("dragover",(function(t){i.fileBasedScanRegion.style.border=i.fileBasedScanRegionActiveBorder(),t.stopPropagation(),t.preventDefault()})),this.fileBasedScanRegion.addEventListener("drop",(function(t){t.stopPropagation(),t.preventDefault(),i.fileBasedScanRegion.style.border=i.fileBasedScanRegionDefaultBorder();var e=t.dataTransfer;if(e){var n=e.files;if(!n||0===n.length)return;for(var s=!1,a=0;a<n.length;++a){var c=n.item(a);if(c&&c.type.match(/image.*/)){s=!0;var l=c.name;i.setImageNameToButton(l),r(c),o.innerText=p.dragAndDropMessage();break}}s||(o.innerText=p.dragAndDropMessageOnlyImages())}}))}return t.prototype.hide=function(){this.fileBasedScanRegion.style.display="none",this.fileScanInput.disabled=!0},t.prototype.show=function(){this.fileBasedScanRegion.style.display="block",this.fileScanInput.disabled=!1},t.prototype.isShowing=function(){return"block"===this.fileBasedScanRegion.style.display},t.prototype.resetValue=function(){this.fileScanInput.value="",this.setInitialValueToButton()},t.prototype.createFileBasedScanRegion=function(){var t=document.createElement("div");return t.style.textAlign="center",t.style.margin="auto",t.style.width="80%",t.style.maxWidth="600px",t.style.border=this.fileBasedScanRegionDefaultBorder(),t.style.padding="10px",t.style.marginBottom="10px",t},t.prototype.fileBasedScanRegionDefaultBorder=function(){return"6px dashed #ebebeb"},t.prototype.fileBasedScanRegionActiveBorder=function(){return"6px dashed rgb(153 151 151)"},t.prototype.createDragAndDropMessage=function(){var t=document.createElement("div");return t.innerText=p.dragAndDropMessage(),t.style.fontWeight="400",t},t.prototype.setImageNameToButton=function(t){if(t.length>20){var e=t.substring(0,8),r=t.length,n=t.substring(r-8,r);t="".concat(e,"....").concat(n)}var i=p.fileSelectionChooseAnother()+" - "+t;this.fileSelectionButton.innerText=i},t.prototype.setInitialValueToButton=function(){var t=p.fileSelectionChooseImage()+" - "+p.fileSelectionNoImageSelected();this.fileSelectionButton.innerText=t},t.prototype.getFileScanInputId=function(){return"html5-qrcode-private-filescan-input"},t.create=function(e,r,n){return new t(e,r,n)},t}(),ut=function(){function t(t){this.selectElement=ot.createElement("select",it.CAMERA_SELECTION_SELECT_ID),this.cameras=t,this.options=[]}return t.prototype.render=function(t){var e=document.createElement("span");e.style.marginRight="10px";var r=this.cameras.length;if(0===r)throw new Error("No cameras found");if(1===r)e.style.display="none";else{var n=p.selectCamera();e.innerText="".concat(n," (").concat(this.cameras.length,") ")}for(var i=1,o=0,s=this.cameras;o<s.length;o++){var a=s[o],c=a.id,l=null==a.label?c:a.label;l&&""!==l||(l=[p.anonymousCameraPrefix(),i++].join(" "));var h=document.createElement("option");h.value=c,h.innerText=l,this.options.push(h),this.selectElement.appendChild(h)}e.appendChild(this.selectElement),t.appendChild(e)},t.prototype.disable=function(){this.selectElement.disabled=!0},t.prototype.isDisabled=function(){return!0===this.selectElement.disabled},t.prototype.enable=function(){this.selectElement.disabled=!1},t.prototype.getValue=function(){return this.selectElement.value},t.prototype.hasValue=function(t){for(var e=0,r=this.options;e<r.length;e++)if(r[e].value===t)return!0;return!1},t.prototype.setValue=function(t){if(!this.hasValue(t))throw new Error("".concat(t," is not present in the camera list."));this.selectElement.value=t},t.prototype.hasSingleItem=function(){return 1===this.cameras.length},t.prototype.numCameras=function(){return this.cameras.length},t.create=function(e,r){var n=new t(r);return n.render(e),n},t}(),dt=function(){function t(){this.onChangeCallback=null,this.zoomElementContainer=document.createElement("div"),this.rangeInput=ot.createElement("input",it.ZOOM_SLIDER_ID),this.rangeInput.type="range",this.rangeText=document.createElement("span"),this.rangeInput.min="1",this.rangeInput.max="5",this.rangeInput.value="1",this.rangeInput.step="0.1"}return t.prototype.render=function(t,e){this.zoomElementContainer.style.display=e?"block":"none",this.zoomElementContainer.style.padding="5px 10px",this.zoomElementContainer.style.textAlign="center",t.appendChild(this.zoomElementContainer),this.rangeInput.style.display="inline-block",this.rangeInput.style.width="50%",this.rangeInput.style.height="5px",this.rangeInput.style.background="#d3d3d3",this.rangeInput.style.outline="none",this.rangeInput.style.opacity="0.7";var r=p.zoom();this.rangeText.innerText="".concat(this.rangeInput.value,"x ").concat(r),this.rangeText.style.marginRight="10px";var n=this;this.rangeInput.addEventListener("input",(function(){return n.onValueChange()})),this.rangeInput.addEventListener("change",(function(){return n.onValueChange()})),this.zoomElementContainer.appendChild(this.rangeInput),this.zoomElementContainer.appendChild(this.rangeText)},t.prototype.onValueChange=function(){var t=p.zoom();this.rangeText.innerText="".concat(this.rangeInput.value,"x ").concat(t),this.onChangeCallback&&this.onChangeCallback(parseFloat(this.rangeInput.value))},t.prototype.setValues=function(t,e,r,n){this.rangeInput.min=t.toString(),this.rangeInput.max=e.toString(),this.rangeInput.step=n.toString(),this.rangeInput.value=r.toString(),this.onValueChange()},t.prototype.show=function(){this.zoomElementContainer.style.display="block"},t.prototype.hide=function(){this.zoomElementContainer.style.display="none"},t.prototype.setOnCameraZoomValueChangeCallback=function(t){this.onChangeCallback=t},t.prototype.removeOnCameraZoomValueChangeCallback=function(){this.onChangeCallback=null},t.create=function(e,r){var n=new t;return n.render(e,r),n},t}();!function(t){t[t.STATUS_DEFAULT=0]="STATUS_DEFAULT",t[t.STATUS_SUCCESS=1]="STATUS_SUCCESS",t[t.STATUS_WARNING=2]="STATUS_WARNING",t[t.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"}(U||(U={}));var ft=function(){function t(t,e,r){if(this.lastMatchFound=null,this.cameraScanImage=null,this.fileScanImage=null,this.fileSelectionUi=null,this.elementId=t,this.config=this.createConfig(e),this.verbose=!0===r,!document.getElementById(t))throw"HTML Element with id=".concat(t," not found");this.scanTypeSelector=new nt(this.config.supportedScanTypes),this.currentScanType=this.scanTypeSelector.getDefaultScanType(),this.sectionSwapAllowed=!0,this.logger=new d(this.verbose),this.persistedDataManager=new J,!0!==e.rememberLastUsedCamera&&this.persistedDataManager.reset()}return t.prototype.render=function(t,e){var r=this;this.lastMatchFound=null,this.qrCodeSuccessCallback=function(e,n){if(t)t(e,n);else{if(r.lastMatchFound===e)return;r.lastMatchFound=e,r.setHeaderMessage(p.lastMatch(e),U.STATUS_SUCCESS)}},this.qrCodeErrorCallback=function(t,r){e&&e(t,r)};var n,i,o=document.getElementById(this.elementId);if(!o)throw"HTML Element with id=".concat(this.elementId," not found");o.innerHTML="",this.createBasicLayout(o),this.html5Qrcode=new W(this.getScanRegionId(),(n=this.config,i=this.verbose,{formatsToSupport:n.formatsToSupport,useBarCodeDetectorIfSupported:n.useBarCodeDetectorIfSupported,experimentalFeatures:n.experimentalFeatures,verbose:i}))},t.prototype.pause=function(t){(f(t)||!0!==t)&&(t=!1),this.getHtml5QrcodeOrFail().pause(t)},t.prototype.resume=function(){this.getHtml5QrcodeOrFail().resume()},t.prototype.getState=function(){return this.getHtml5QrcodeOrFail().getState()},t.prototype.clear=function(){var t=this,e=function(){var e=document.getElementById(t.elementId);e&&(e.innerHTML="",t.resetBasicLayout(e))};return this.html5Qrcode?new Promise((function(r,n){t.html5Qrcode?t.html5Qrcode.isScanning?t.html5Qrcode.stop().then((function(n){t.html5Qrcode?(t.html5Qrcode.clear(),e(),r()):r()})).catch((function(e){t.verbose&&t.logger.logError("Unable to stop qrcode scanner",e),n(e)})):(t.html5Qrcode.clear(),e(),r()):r()})):Promise.resolve()},t.prototype.getRunningTrackCapabilities=function(){return this.getHtml5QrcodeOrFail().getRunningTrackCapabilities()},t.prototype.getRunningTrackSettings=function(){return this.getHtml5QrcodeOrFail().getRunningTrackSettings()},t.prototype.applyVideoConstraints=function(t){return this.getHtml5QrcodeOrFail().applyVideoConstraints(t)},t.prototype.getHtml5QrcodeOrFail=function(){if(!this.html5Qrcode)throw"Code scanner not initialized.";return this.html5Qrcode},t.prototype.createConfig=function(t){return t?(t.fps||(t.fps=c.SCAN_DEFAULT_FPS),t.rememberLastUsedCamera!==!c.DEFAULT_REMEMBER_LAST_CAMERA_USED&&(t.rememberLastUsedCamera=c.DEFAULT_REMEMBER_LAST_CAMERA_USED),t.supportedScanTypes||(t.supportedScanTypes=c.DEFAULT_SUPPORTED_SCAN_TYPE),t):{fps:c.SCAN_DEFAULT_FPS,rememberLastUsedCamera:c.DEFAULT_REMEMBER_LAST_CAMERA_USED,supportedScanTypes:c.DEFAULT_SUPPORTED_SCAN_TYPE}},t.prototype.createBasicLayout=function(t){t.style.position="relative",t.style.padding="0px",t.style.border="1px solid silver",this.createHeader(t);var e=document.createElement("div"),r=this.getScanRegionId();e.id=r,e.style.width="100%",e.style.minHeight="100px",e.style.textAlign="center",t.appendChild(e),nt.isCameraScanType(this.currentScanType)?this.insertCameraScanImageToScanRegion():this.insertFileScanImageToScanRegion();var n=document.createElement("div"),i=this.getDashboardId();n.id=i,n.style.width="100%",t.appendChild(n),this.setupInitialDashboard(n)},t.prototype.resetBasicLayout=function(t){t.style.border="none"},t.prototype.setupInitialDashboard=function(t){this.createSection(t),this.createSectionControlPanel(),this.scanTypeSelector.hasMoreThanOneScanType()&&this.createSectionSwap()},t.prototype.createHeader=function(t){var e=document.createElement("div");e.style.textAlign="left",e.style.margin="0px",t.appendChild(e),(new et).renderInto(e);var r=document.createElement("div");r.id=this.getHeaderMessageContainerId(),r.style.display="none",r.style.textAlign="center",r.style.fontSize="14px",r.style.padding="2px 10px",r.style.margin="4px",r.style.borderTop="1px solid #f6f6f6",e.appendChild(r)},t.prototype.createSection=function(t){var e=document.createElement("div");e.id=this.getDashboardSectionId(),e.style.width="100%",e.style.padding="10px 0px 10px 0px",e.style.textAlign="left",t.appendChild(e)},t.prototype.createCameraListUi=function(t,e,r){var n=this;n.showHideScanTypeSwapLink(!1),n.setHeaderMessage(p.cameraPermissionRequesting());var i=function(){r||n.createPermissionButton(t,e)};W.getCameras().then((function(r){n.persistedDataManager.setHasPermission(!0),n.showHideScanTypeSwapLink(!0),n.resetHeaderMessage(),r&&r.length>0?(t.removeChild(e),n.renderCameraSelection(r)):(n.setHeaderMessage(p.noCameraFound(),U.STATUS_WARNING),i())})).catch((function(t){n.persistedDataManager.setHasPermission(!1),r?r.disabled=!1:i(),n.setHeaderMessage(t,U.STATUS_WARNING),n.showHideScanTypeSwapLink(!0)}))},t.prototype.createPermissionButton=function(t,e){var r=this,n=ot.createElement("button",this.getCameraPermissionButtonId());n.innerText=p.cameraPermissionTitle(),n.addEventListener("click",(function(){n.disabled=!0,r.createCameraListUi(t,e,n)})),e.appendChild(n)},t.prototype.createPermissionsUi=function(t,e){var r=this;nt.isCameraScanType(this.currentScanType)&&this.persistedDataManager.hasCameraPermissions()?rt.hasPermissions().then((function(n){n?r.createCameraListUi(t,e):(r.persistedDataManager.setHasPermission(!1),r.createPermissionButton(t,e))})).catch((function(n){r.persistedDataManager.setHasPermission(!1),r.createPermissionButton(t,e)})):this.createPermissionButton(t,e)},t.prototype.createSectionControlPanel=function(){var t=document.getElementById(this.getDashboardSectionId()),e=document.createElement("div");t.appendChild(e);var r=document.createElement("div");r.id=this.getDashboardSectionCameraScanRegionId(),r.style.display=nt.isCameraScanType(this.currentScanType)?"block":"none",e.appendChild(r);var n=document.createElement("div");n.style.textAlign="center",r.appendChild(n),this.scanTypeSelector.isCameraScanRequired()&&this.createPermissionsUi(r,n),this.renderFileScanUi(e)},t.prototype.renderFileScanUi=function(t){var e=nt.isFileScanType(this.currentScanType),r=this;this.fileSelectionUi=ht.create(t,e,(function(t){if(!r.html5Qrcode)throw"html5Qrcode not defined";nt.isFileScanType(r.currentScanType)&&(r.setHeaderMessage(p.loadingImage()),r.html5Qrcode.scanFileV2(t,!0).then((function(t){r.resetHeaderMessage(),r.qrCodeSuccessCallback(t.decodedText,t)})).catch((function(t){r.setHeaderMessage(t,U.STATUS_WARNING),r.qrCodeErrorCallback(t,u.createFrom(t))})))}))},t.prototype.renderCameraSelection=function(t){var e=this,r=this,n=document.getElementById(this.getDashboardSectionCameraScanRegionId());n.style.textAlign="center";var i=dt.create(n,!1),o=ut.create(n,t),s=document.createElement("span"),a=ot.createElement("button",it.CAMERA_START_BUTTON_ID);a.innerText=p.scanButtonStartScanningText(),s.appendChild(a);var c,l=ot.createElement("button",it.CAMERA_STOP_BUTTON_ID);l.innerText=p.scanButtonStopScanningText(),l.style.display="none",l.disabled=!0,s.appendChild(l),n.appendChild(s);var h=function(t){t||(a.style.display="none"),a.innerText=p.scanButtonStartScanningText(),a.style.opacity="1",a.disabled=!1,t&&(a.style.display="inline-block")};if(a.addEventListener("click",(function(t){a.innerText=p.scanButtonScanningStarting(),o.disable(),a.disabled=!0,a.style.opacity="0.5",e.scanTypeSelector.hasMoreThanOneScanType()&&r.showHideScanTypeSwapLink(!1),r.resetHeaderMessage();var n,u=o.getValue();r.persistedDataManager.setLastUsedCameraId(u),r.html5Qrcode.start(u,(n=r.config,{fps:n.fps,qrbox:n.qrbox,aspectRatio:n.aspectRatio,disableFlip:n.disableFlip,videoConstraints:n.videoConstraints}),r.qrCodeSuccessCallback,r.qrCodeErrorCallback).then((function(t){l.disabled=!1,l.style.display="inline-block",h(!1);var n=r.html5Qrcode.getRunningTrackCameraCapabilities();!0===e.config.showTorchButtonIfSupported&&function(t){t.torchFeature().isSupported()?(c?c.updateTorchCapability(t.torchFeature()):c=lt.create(s,t.torchFeature(),{display:"none",marginLeft:"5px"},(function(t){r.setHeaderMessage(t,U.STATUS_WARNING)})),c.show()):c&&c.hide()}(n),!0===e.config.showZoomSliderIfSupported&&function(t){var r=t.zoomFeature();if(r.isSupported()){i.setOnCameraZoomValueChangeCallback((function(t){r.apply(t)}));var n,o,s,a=1;e.config.defaultZoomValueIfSupported&&(a=e.config.defaultZoomValueIfSupported),n=a,o=r.min(),a=n>(s=r.max())?s:n<o?o:n,i.setValues(r.min(),r.max(),a,r.step()),i.show()}}(n)})).catch((function(t){r.showHideScanTypeSwapLink(!0),o.enable(),h(!0),r.setHeaderMessage(t,U.STATUS_WARNING)}))})),o.hasSingleItem()&&a.click(),l.addEventListener("click",(function(t){if(!r.html5Qrcode)throw"html5Qrcode not defined";l.disabled=!0,r.html5Qrcode.stop().then((function(t){e.scanTypeSelector.hasMoreThanOneScanType()&&r.showHideScanTypeSwapLink(!0),o.enable(),a.disabled=!1,l.style.display="none",a.style.display="inline-block",c&&(c.reset(),c.hide()),i.removeOnCameraZoomValueChangeCallback(),i.hide(),r.insertCameraScanImageToScanRegion()})).catch((function(t){l.disabled=!1,r.setHeaderMessage(t,U.STATUS_WARNING)}))})),r.persistedDataManager.getLastUsedCameraId()){var u=r.persistedDataManager.getLastUsedCameraId();o.hasValue(u)?(o.setValue(u),a.click()):r.persistedDataManager.resetLastUsedCameraId()}},t.prototype.createSectionSwap=function(){var t=this,e=p.textIfCameraScanSelected(),r=p.textIfFileScanSelected(),n=document.getElementById(this.getDashboardSectionId()),o=document.createElement("div");o.style.textAlign="center";var s=ot.createElement("span",this.getDashboardSectionSwapLinkId());s.style.textDecoration="underline",s.style.cursor="pointer",s.innerText=nt.isCameraScanType(this.currentScanType)?e:r,s.addEventListener("click",(function(){t.sectionSwapAllowed?(t.resetHeaderMessage(),t.fileSelectionUi.resetValue(),t.sectionSwapAllowed=!1,nt.isCameraScanType(t.currentScanType)?(t.clearScanRegion(),t.getCameraScanRegion().style.display="none",t.fileSelectionUi.show(),s.innerText=r,t.currentScanType=i.SCAN_TYPE_FILE,t.insertFileScanImageToScanRegion()):(t.clearScanRegion(),t.getCameraScanRegion().style.display="block",t.fileSelectionUi.hide(),s.innerText=e,t.currentScanType=i.SCAN_TYPE_CAMERA,t.insertCameraScanImageToScanRegion(),t.startCameraScanIfPermissionExistsOnSwap()),t.sectionSwapAllowed=!0):t.verbose&&t.logger.logError("Section swap called when not allowed")})),o.appendChild(s),n.appendChild(o)},t.prototype.startCameraScanIfPermissionExistsOnSwap=function(){var t=this,e=this;this.persistedDataManager.hasCameraPermissions()&&rt.hasPermissions().then((function(r){if(r){var n=document.getElementById(e.getCameraPermissionButtonId());if(!n)throw t.logger.logError("Permission button not found, fail;"),"Permission button not found";n.click()}else e.persistedDataManager.setHasPermission(!1)})).catch((function(t){e.persistedDataManager.setHasPermission(!1)}))},t.prototype.resetHeaderMessage=function(){document.getElementById(this.getHeaderMessageContainerId()).style.display="none"},t.prototype.setHeaderMessage=function(t,e){e||(e=U.STATUS_DEFAULT);var r=this.getHeaderMessageDiv();switch(r.innerText=t,r.style.display="block",e){case U.STATUS_SUCCESS:r.style.background="rgba(106, 175, 80, 0.26)",r.style.color="#477735";break;case U.STATUS_WARNING:r.style.background="rgba(203, 36, 49, 0.14)",r.style.color="#cb2431";break;case U.STATUS_DEFAULT:default:r.style.background="rgba(0, 0, 0, 0)",r.style.color="rgb(17, 17, 17)"}},t.prototype.showHideScanTypeSwapLink=function(t){this.scanTypeSelector.hasMoreThanOneScanType()&&(!0!==t&&(t=!1),this.sectionSwapAllowed=t,this.getDashboardSectionSwapLink().style.display=t?"inline-block":"none")},t.prototype.insertCameraScanImageToScanRegion=function(){var t=this,e=document.getElementById(this.getScanRegionId());if(this.cameraScanImage)return e.innerHTML="<br>",void e.appendChild(this.cameraScanImage);this.cameraScanImage=new Image,this.cameraScanImage.onload=function(r){e.innerHTML="<br>",e.appendChild(t.cameraScanImage)},this.cameraScanImage.width=64,this.cameraScanImage.style.opacity="0.8",this.cameraScanImage.src=Z,this.cameraScanImage.alt=p.cameraScanAltText()},t.prototype.insertFileScanImageToScanRegion=function(){var t=this,e=document.getElementById(this.getScanRegionId());if(this.fileScanImage)return e.innerHTML="<br>",void e.appendChild(this.fileScanImage);this.fileScanImage=new Image,this.fileScanImage.onload=function(r){e.innerHTML="<br>",e.appendChild(t.fileScanImage)},this.fileScanImage.width=64,this.fileScanImage.style.opacity="0.8",this.fileScanImage.src=Q,this.fileScanImage.alt=p.fileScanAltText()},t.prototype.clearScanRegion=function(){document.getElementById(this.getScanRegionId()).innerHTML=""},t.prototype.getDashboardSectionId=function(){return"".concat(this.elementId,"__dashboard_section")},t.prototype.getDashboardSectionCameraScanRegionId=function(){return"".concat(this.elementId,"__dashboard_section_csr")},t.prototype.getDashboardSectionSwapLinkId=function(){return it.SCAN_TYPE_CHANGE_ANCHOR_ID},t.prototype.getScanRegionId=function(){return"".concat(this.elementId,"__scan_region")},t.prototype.getDashboardId=function(){return"".concat(this.elementId,"__dashboard")},t.prototype.getHeaderMessageContainerId=function(){return"".concat(this.elementId,"__header_message")},t.prototype.getCameraPermissionButtonId=function(){return it.CAMERA_PERMISSION_BUTTON_ID},t.prototype.getCameraScanRegion=function(){return document.getElementById(this.getDashboardSectionCameraScanRegionId())},t.prototype.getDashboardSectionSwapLink=function(){return document.getElementById(this.getDashboardSectionSwapLinkId())},t.prototype.getHeaderMessageDiv=function(){return document.getElementById(this.getHeaderMessageContainerId())},t}()})(),__Html5QrcodeLibrary__=n})();if (window) { if (!Html5QrcodeScanner) { var Html5QrcodeScanner = window.__Html5QrcodeLibrary__.Html5QrcodeScanner; } if (!Html5Qrcode) { var Html5Qrcode = window.__Html5QrcodeLibrary__.Html5Qrcode; } if (!Html5QrcodeSupportedFormats) { var Html5QrcodeSupportedFormats = window.__Html5QrcodeLibrary__.Html5QrcodeSupportedFormats } if (!Html5QrcodeScannerState) { var Html5QrcodeScannerState = window.__Html5QrcodeLibrary__.Html5QrcodeScannerState; } if (!Html5QrcodeScanType) { var Html5QrcodeScanType = window.__Html5QrcodeLibrary__.Html5QrcodeScanType; }} \ No newline at end of file diff --git a/src/main/node_modules/html5-qrcode/image-assets.d.ts b/src/main/node_modules/html5-qrcode/image-assets.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..59387ac2e6d5b21c1d1862a744e923298b400a24 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/image-assets.d.ts @@ -0,0 +1,4 @@ +export declare const ASSET_CAMERA_SCAN: string; +export declare const ASSET_FILE_SCAN: string; +export declare const ASSET_INFO_ICON_16PX: string; +export declare const ASSET_CLOSE_ICON_16PX: string; diff --git a/src/main/node_modules/html5-qrcode/index.d.ts b/src/main/node_modules/html5-qrcode/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6b90c689f1a0c34ea728b5b7a5375a33722ed9f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/index.d.ts @@ -0,0 +1,6 @@ +export { Html5Qrcode, Html5QrcodeFullConfig, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; +export { Html5QrcodeScanner } from "./html5-qrcode-scanner"; +export { Html5QrcodeSupportedFormats, Html5QrcodeResult, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; +export { Html5QrcodeScannerState } from "./state-manager"; +export { Html5QrcodeScanType } from "./core"; +export { CameraCapabilities, CameraDevice } from "./camera/core"; diff --git a/src/main/node_modules/html5-qrcode/native-bar-code-detector.d.ts b/src/main/node_modules/html5-qrcode/native-bar-code-detector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..85ef95e4c4fec982c26cea91f5bb9eb21923bdf4 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/native-bar-code-detector.d.ts @@ -0,0 +1,16 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, QrcodeDecoderAsync, Logger } from "./core"; +export declare class BarcodeDetectorDelegate implements QrcodeDecoderAsync { + private readonly formatMap; + private readonly reverseFormatMap; + private verbose; + private logger; + private detector; + static isSupported(): boolean; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private selectLargestBarcode; + private createBarcodeDetectorFormats; + private toHtml5QrcodeSupportedFormats; + private createReverseFormatMap; + private createDebugData; +} diff --git a/src/main/node_modules/html5-qrcode/package.json b/src/main/node_modules/html5-qrcode/package.json new file mode 100644 index 0000000000000000000000000000000000000000..bc7616ad5306f6afcea5b530326b51d8d2cc44c7 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/package.json @@ -0,0 +1,93 @@ +{ + "name": "html5-qrcode", + "version": "2.3.8", + "description": "A cross platform HTML5 QR Code & bar code scanner", + "main": "./cjs/index.js", + "module": "./esm/index.js", + "typings": "./esm/index.d.ts", + "esnext": "./es2015/index.js", + "unpkg": "./html5-qrcode.min.js", + "scripts": { + "build-windows": "npm run build:es2015 && npm run build:esm && npm run build:esnext && npm run build:cjs && npm run build:umd_windows && npm run build:typing && npm run build:copy_windows", + "test": "npm run-script test:build && npm run-script test:run", + "test_windows": "npm run-script test:build && npm run-script test:run_windows", + "test:build": "tsc --build tsconfig.test.json", + "test:run_windows": ".\\scripts\\test-run.bat", + "test:run": "./scripts/test-run.sh", + "lint-md": "remark .", + "clean": "rm -Rf ./lib/* ./build/* ./meta/bundlesize/* ./meta/coverage/* ./.rpt2_cache ./dist/* ./src/*.d.ts", + "prebuild": "npm run clean", + "postbuild": "cp -R ./third_party ./dist/third_party", + "build": "npm run build:es2015 && npm run build:esm && npm run build:esnext && npm run build:cjs && npm run build:umd && npm run build:typing && npm run build:copy", + "build:es2015": "tsc --build tsconfig.lib-es2015.json", + "build:esm": "tsc --build tsconfig.lib-esm.json", + "build:esnext": "tsc --build tsconfig.lib-esm.json", + "build:cjs": "tsc --build tsconfig.lib-cjs.json", + "build:typing": "tsc --emitDeclarationOnly --outDir ./dist", + "build:umd": "./scripts/build-webpack.sh", + "build:umd_windows": ".\\scripts\\build-webpack.bat", + "build:copy": "cp README.md dist && cp package.json dist && cp LICENSE dist && cp -R src dist/src", + "build:copy_windows": "copy README.md dist && copy package.json dist && copy LICENSE dist", + "internal_release": "npm run build && cp dist/html5-qrcode.min.js minified/html5-qrcode.min.js", + "release": "npm run build && cp dist/html5-qrcode.min.js minified/html5-qrcode.min.js && cd dist && npm publish", + "release_windows": "npm run build && cp dist\\html5-qrcode.min.js minified\\html5-qrcode.min.js && cd dist && npm publish", + "doc_gen": "npx typedoc --excludePrivate src/index.ts" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/mebjas/html5-qrcode.git" + }, + "keywords": [ + "html5", + "qrcode", + "html", + "camera", + "scanner", + "barcode", + "barcode 1d", + "barcode 2d" + ], + "author": "minhazav@gmail.com", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/mebjas/html5-qrcode/issues" + }, + "homepage": "https://github.com/mebjas/html5-qrcode#readme", + "devDependencies": { + "@babel/cli": "^7.10.5", + "@babel/core": "^7.11.4", + "@babel/plugin-proposal-class-properties": "^7.10.4", + "@babel/preset-env": "^7.11.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "babel-minify": "^0.5.1", + "chai": "^4.3.4", + "docusaurus-plugin-typedoc": "^0.18.0", + "expose-loader": "^2.0.0", + "jsdom": "20.0.2", + "jsdom-global": "3.0.2", + "mocha": "^9.1.3", + "mocha-lcov-reporter": "^1.3.0", + "promise-polyfill": "^8.1.3", + "remark-cli": "^9.0.0", + "remark-preset-lint-recommended": "^5.0.0", + "rewire": "^5.0.0", + "ts-loader": "^9.1.2", + "ts-node": "^10.4.0", + "tsconfig-paths": "^3.12.0", + "typedoc": "^0.23.28", + "typedoc-plugin-markdown": "^3.14.0", + "typescript": "^4.3.2", + "typings": "^2.1.1", + "webpack": "^5.37.0", + "webpack-cli": "^4.7.0" + }, + "remarkConfig": { + "plugins": [ + "remark-preset-lint-recommended" + ] + }, + "publishConfig": { + "access": "public" + } +} diff --git a/src/main/node_modules/html5-qrcode/src/camera/core-impl.d.ts b/src/main/node_modules/html5-qrcode/src/camera/core-impl.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ffc8a05e27dd5c815882381cca903fde7ae268db --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/camera/core-impl.d.ts @@ -0,0 +1,7 @@ +import { Camera, CameraRenderingOptions, RenderedCamera, RenderingCallbacks } from "./core"; +export declare class CameraImpl implements Camera { + private readonly mediaStream; + private constructor(); + render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>; + static create(videoConstraints: MediaTrackConstraints): Promise<Camera>; +} diff --git a/src/main/node_modules/html5-qrcode/src/camera/core-impl.ts b/src/main/node_modules/html5-qrcode/src/camera/core-impl.ts new file mode 100644 index 0000000000000000000000000000000000000000..ad29ec4572adb345ef4769af7d362be712f0b829 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/camera/core-impl.ts @@ -0,0 +1,340 @@ +/** + * @fileoverview + * Core camera library implementations. + * + * @author mebjas <minhazav@gmail.com> + */ + +import { + Camera, + CameraCapabilities, + CameraCapability, + RangeCameraCapability, + CameraRenderingOptions, + RenderedCamera, + RenderingCallbacks, + BooleanCameraCapability +} from "./core"; + +/** Interface for a range value. */ +interface RangeValue { + min: number; + max: number; + step: number; +} + +/** Abstract camera capability class. */ +abstract class AbstractCameraCapability<T> implements CameraCapability<T> { + protected readonly name: string; + protected readonly track: MediaStreamTrack; + + constructor(name: string, track: MediaStreamTrack) { + this.name = name; + this.track = track; + } + + public isSupported(): boolean { + // TODO(minhazav): Figure out fallback for getCapabilities() + // in firefox. + // https://developer.mozilla.org/en-US/docs/Web/API/Media_Capture_and_Streams_API/Constraints + if (!this.track.getCapabilities) { + return false; + } + return this.name in this.track.getCapabilities(); + } + + public apply(value: T): Promise<void> { + let constraint: any = {}; + constraint[this.name] = value; + let constraints = { advanced: [ constraint ] }; + return this.track.applyConstraints(constraints); + } + + public value(): T | null { + let settings: any = this.track.getSettings(); + if (this.name in settings) { + let settingValue = settings[this.name]; + return settingValue; + } + + return null; + } +} + +abstract class AbstractRangeCameraCapability extends AbstractCameraCapability<number> { + constructor(name: string, track: MediaStreamTrack) { + super(name, track); + } + + public min(): number { + return this.getCapabilities().min; + } + + public max(): number { + return this.getCapabilities().max; + } + + public step(): number { + return this.getCapabilities().step; + } + + public apply(value: number): Promise<void> { + let constraint: any = {}; + constraint[this.name] = value; + let constraints = {advanced: [ constraint ]}; + return this.track.applyConstraints(constraints); + } + + private getCapabilities(): RangeValue { + this.failIfNotSupported(); + let capabilities: any = this.track.getCapabilities(); + let capability: any = capabilities[this.name]; + return { + min: capability.min, + max: capability.max, + step: capability.step, + }; + } + + private failIfNotSupported() { + if (!this.isSupported()) { + throw new Error(`${this.name} capability not supported`); + } + } +} + +/** Zoom feature. */ +class ZoomFeatureImpl extends AbstractRangeCameraCapability { + constructor(track: MediaStreamTrack) { + super("zoom", track); + } +} + +/** Torch feature. */ +class TorchFeatureImpl extends AbstractCameraCapability<boolean> { + constructor(track: MediaStreamTrack) { + super("torch", track); + } +} + +/** Implementation of {@link CameraCapabilities}. */ +class CameraCapabilitiesImpl implements CameraCapabilities { + private readonly track: MediaStreamTrack; + + constructor(track: MediaStreamTrack) { + this.track = track; + } + + zoomFeature(): RangeCameraCapability { + return new ZoomFeatureImpl(this.track); + } + + torchFeature(): BooleanCameraCapability { + return new TorchFeatureImpl(this.track); + } +} + +/** Implementation of {@link RenderedCamera}. */ +class RenderedCameraImpl implements RenderedCamera { + + private readonly parentElement: HTMLElement; + private readonly mediaStream: MediaStream; + private readonly surface: HTMLVideoElement; + private readonly callbacks: RenderingCallbacks; + + private isClosed: boolean = false; + + private constructor( + parentElement: HTMLElement, + mediaStream: MediaStream, + callbacks: RenderingCallbacks) { + this.parentElement = parentElement; + this.mediaStream = mediaStream; + this.callbacks = callbacks; + + this.surface = this.createVideoElement(this.parentElement.clientWidth); + + // Setup + parentElement.append(this.surface); + } + + private createVideoElement(width: number): HTMLVideoElement { + const videoElement = document.createElement("video"); + videoElement.style.width = `${width}px`; + videoElement.style.display = "block"; + videoElement.muted = true; + videoElement.setAttribute("muted", "true"); + (<any>videoElement).playsInline = true; + return videoElement; + } + + private setupSurface() { + this.surface.onabort = () => { + throw "RenderedCameraImpl video surface onabort() called"; + }; + + this.surface.onerror = () => { + throw "RenderedCameraImpl video surface onerror() called"; + }; + + let onVideoStart = () => { + const videoWidth = this.surface.clientWidth; + const videoHeight = this.surface.clientHeight; + this.callbacks.onRenderSurfaceReady(videoWidth, videoHeight); + this.surface.removeEventListener("playing", onVideoStart); + }; + + this.surface.addEventListener("playing", onVideoStart); + this.surface.srcObject = this.mediaStream; + this.surface.play(); + } + + static async create( + parentElement: HTMLElement, + mediaStream: MediaStream, + options: CameraRenderingOptions, + callbacks: RenderingCallbacks) + : Promise<RenderedCamera> { + let renderedCamera = new RenderedCameraImpl( + parentElement, mediaStream, callbacks); + if (options.aspectRatio) { + let aspectRatioConstraint = { + aspectRatio: options.aspectRatio! + }; + await renderedCamera.getFirstTrackOrFail().applyConstraints( + aspectRatioConstraint); + } + + renderedCamera.setupSurface(); + return renderedCamera; + } + + private failIfClosed() { + if (this.isClosed) { + throw "The RenderedCamera has already been closed."; + } + } + + private getFirstTrackOrFail(): MediaStreamTrack { + this.failIfClosed(); + + if (this.mediaStream.getVideoTracks().length === 0) { + throw "No video tracks found"; + } + + return this.mediaStream.getVideoTracks()[0]; + } + + //#region Public APIs. + public pause(): void { + this.failIfClosed(); + this.surface.pause(); + } + + public resume(onResumeCallback: () => void): void { + this.failIfClosed(); + let $this = this; + + const onVideoResume = () => { + // Transition after 200ms to avoid the previous canvas frame being + // re-scanned. + setTimeout(onResumeCallback, 200); + $this.surface.removeEventListener("playing", onVideoResume); + }; + + this.surface.addEventListener("playing", onVideoResume); + this.surface.play(); + } + + public isPaused(): boolean { + this.failIfClosed(); + return this.surface.paused; + } + + public getSurface(): HTMLVideoElement { + this.failIfClosed(); + return this.surface; + } + + public getRunningTrackCapabilities(): MediaTrackCapabilities { + return this.getFirstTrackOrFail().getCapabilities(); + } + + public getRunningTrackSettings(): MediaTrackSettings { + return this.getFirstTrackOrFail().getSettings(); + } + + public async applyVideoConstraints(constraints: MediaTrackConstraints) + : Promise<void> { + if ("aspectRatio" in constraints) { + throw "Changing 'aspectRatio' in run-time is not yet supported."; + } + + return this.getFirstTrackOrFail().applyConstraints(constraints); + } + + public close(): Promise<void> { + if (this.isClosed) { + // Already closed. + return Promise.resolve(); + } + + let $this = this; + return new Promise((resolve, _) => { + let tracks = $this.mediaStream.getVideoTracks(); + const tracksToClose = tracks.length; + var tracksClosed = 0; + $this.mediaStream.getVideoTracks().forEach((videoTrack) => { + $this.mediaStream.removeTrack(videoTrack); + videoTrack.stop(); + ++tracksClosed; + + if (tracksClosed >= tracksToClose) { + $this.isClosed = true; + $this.parentElement.removeChild($this.surface); + resolve(); + } + }); + + + }); + } + + getCapabilities(): CameraCapabilities { + return new CameraCapabilitiesImpl(this.getFirstTrackOrFail()); + } + //#endregion +} + +/** Default implementation of {@link Camera} interface. */ +export class CameraImpl implements Camera { + private readonly mediaStream: MediaStream; + + private constructor(mediaStream: MediaStream) { + this.mediaStream = mediaStream; + } + + async render( + parentElement: HTMLElement, + options: CameraRenderingOptions, + callbacks: RenderingCallbacks) + : Promise<RenderedCamera> { + return RenderedCameraImpl.create( + parentElement, this.mediaStream, options, callbacks); + } + + static async create(videoConstraints: MediaTrackConstraints) + : Promise<Camera> { + if (!navigator.mediaDevices) { + throw "navigator.mediaDevices not supported"; + } + let constraints: MediaStreamConstraints = { + audio: false, + video: videoConstraints + }; + + let mediaStream = await navigator.mediaDevices.getUserMedia( + constraints); + return new CameraImpl(mediaStream); + } +} diff --git a/src/main/node_modules/html5-qrcode/src/camera/core.d.ts b/src/main/node_modules/html5-qrcode/src/camera/core.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..52e27b5012fe7172a5d7b179174774fe206316ae --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/camera/core.d.ts @@ -0,0 +1,41 @@ +export interface CameraDevice { + id: string; + label: string; +} +export interface CameraCapability<T> { + isSupported(): boolean; + apply(value: T): Promise<void>; + value(): T | null; +} +export interface RangeCameraCapability extends CameraCapability<number> { + min(): number; + max(): number; + step(): number; +} +export interface BooleanCameraCapability extends CameraCapability<boolean> { +} +export interface CameraCapabilities { + zoomFeature(): RangeCameraCapability; + torchFeature(): BooleanCameraCapability; +} +export type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void; +export interface RenderingCallbacks { + onRenderSurfaceReady: OnRenderSurfaceReady; +} +export interface RenderedCamera { + getSurface(): HTMLVideoElement; + pause(): void; + resume(onResumeCallback: () => void): void; + isPaused(): boolean; + close(): Promise<void>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + applyVideoConstraints(constraints: MediaTrackConstraints): Promise<void>; + getCapabilities(): CameraCapabilities; +} +export interface CameraRenderingOptions { + aspectRatio?: number; +} +export interface Camera { + render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>; +} diff --git a/src/main/node_modules/html5-qrcode/src/camera/core.ts b/src/main/node_modules/html5-qrcode/src/camera/core.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3137cf482f8c8b1c3c44b74b2462095ee0b6264 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/camera/core.ts @@ -0,0 +1,180 @@ +/** + * @module + * Core Camera interfaces. + * + * @author mebjas <minhazav@gmail.com> + */ + +/** Camera device interface. */ +export interface CameraDevice { + id: string; + label: string; +} + +//#region Features +/** Generic capability of camera. */ +export interface CameraCapability<T> { + /** Returns {@code true} if the capability is supported by the camera. */ + isSupported(): boolean; + + /** Apply the {@code value} to camera for this capability. */ + apply(value: T): Promise<void>; + + /** Returns current value of this capability. */ + value(): T | null; +} + +/** Capability of the camera that has range. */ +export interface RangeCameraCapability extends CameraCapability<number> { + /** Min value allowed for this capability. */ + min(): number; + + /** Max value allowed for this capability. */ + max(): number; + + /** Steps allowed for this capability. */ + step(): number; +} + +/** Capability of camera that is boolean in nature. */ +export interface BooleanCameraCapability extends CameraCapability<boolean> {} + +/** Class exposing different capabilities of camera. */ +export interface CameraCapabilities { + + /** Zoom capability of the camera. */ + zoomFeature(): RangeCameraCapability; + + /** Torch capability of the camera. */ + torchFeature(): BooleanCameraCapability; +} + +//#endregion + +/** Type for callback called when camera surface is ready. */ +export type OnRenderSurfaceReady + = (viewfinderWidth: number, viewfinderHeight: number) => void; + +/** Callbacks around camera rendering. */ +export interface RenderingCallbacks { + onRenderSurfaceReady: OnRenderSurfaceReady; +} + +/** + * Interface for a rendered camera that is actively showing feed on a surface. + */ +export interface RenderedCamera { + /** + * Returns the video surface. + * + * @throws error if method is called when scanner is not in scanning state. + */ + getSurface(): HTMLVideoElement; + + /** + * Pauses the camera feed. + * + * @throws error if method is called when scanner is not in scanning state. + */ + pause(): void; + + /** + * Resumes the camera feed, if it's in paused state. + * + * @param onResumeCallback callback that is called when camera resumes. + * + * @throws error if {@link RenderedCamera} instance is already closed. + */ + resume(onResumeCallback: () => void): void; + + /** + * Returns {@code true} if the instance is paused. + * + * @throws error if {@link RenderedCamera} instance is already closed. + */ + isPaused(): boolean; + + /** + * Closes the instance. + * + * <p> The instance cannot be used after closing. + */ + close(): Promise<void>; + + // --------------------------------------------------------------------------- + // Direct Camera Access APIs. + // + // The APIs below are in flavour similar to what Javascript exposes. + // --------------------------------------------------------------------------- + + /** + * Returns the capabilities of the running camera stream. + * + * Read more: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getConstraints + * + * @returns the capabilities of a running video track. + * @throws error if {@link RenderedCamera} instance is already closed. + */ + getRunningTrackCapabilities(): MediaTrackCapabilities; + + /** + * Returns the object containing the current values of each constrainable + * property of the running video track. + * + * Read more: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getSettings + * + * @returns the supported settings of the running video track. + * @throws error if {@link RenderedCamera} instance is already closed. + */ + getRunningTrackSettings(): MediaTrackSettings; + + /** + * Apply a video constraints on running video track from camera. + * + * Important: Changing aspectRatio while scanner is running is not supported + * with this API. + * + * @param {MediaTrackConstraints} specifies a variety of video or camera + * controls as defined in + * https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints + * @returns a Promise which succeeds if the passed constraints are applied, + * fails otherwise. + * @throws error if {@link RenderedCamera} instance is already closed. + */ + applyVideoConstraints(constraints: MediaTrackConstraints): Promise<void>; + + /** + * Returns all capabilities of the camera. + */ + getCapabilities(): CameraCapabilities; +} + +/** Options for rendering camera feed. */ +export interface CameraRenderingOptions { + /** + * Aspect ratio to setup the surface with. + * + * <p> Setting this value doesn't guarantee the exact value to be applied. + */ + aspectRatio?: number; +} + +/** Interface for the camera. */ +export interface Camera { + + /** + * Renders camera to {@link HTMLVideoElement} as a child of + * {@code parentElement}. + * + * @params parentElement Parent HtmlElement to render camera feed into + * @params options rendering options + * @params callbacks callbacks associated with rendering + * + * @returns the {@link RenderedCamera} instance. + */ + render( + parentElement: HTMLElement, + options: CameraRenderingOptions, + callbacks: RenderingCallbacks) + : Promise<RenderedCamera>; +} diff --git a/src/main/node_modules/html5-qrcode/src/camera/factories.d.ts b/src/main/node_modules/html5-qrcode/src/camera/factories.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..df98f8ffb0479eb3c807d7e49c6018c3850f8f71 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/camera/factories.d.ts @@ -0,0 +1,6 @@ +import { Camera } from "./core"; +export declare class CameraFactory { + static failIfNotSupported(): Promise<CameraFactory>; + private constructor(); + create(videoConstraints: MediaTrackConstraints): Promise<Camera>; +} diff --git a/src/main/node_modules/html5-qrcode/src/camera/factories.ts b/src/main/node_modules/html5-qrcode/src/camera/factories.ts new file mode 100644 index 0000000000000000000000000000000000000000..48dda46c0b8d175913220de6dc0ffb1b814a5ffa --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/camera/factories.ts @@ -0,0 +1,33 @@ +/** + * @fileoverview + * Set of factory implementations around Camera. + * + * @author mebjas <minhazav@gmail.com> + */ + +import { Camera } from "./core"; +import { CameraImpl } from "./core-impl"; + +/** Factory class for creating Camera. */ +export class CameraFactory { + + /** + * Returns {@link CameraFactory} if {@link navigator.mediaDevices} is + * supported else fails. + */ + public static async failIfNotSupported(): Promise<CameraFactory> { + if (!navigator.mediaDevices) { + throw "navigator.mediaDevices not supported"; + } + + return new CameraFactory(); + } + + private constructor() { /* No Op. */ } + + /** Creates camera instance based on constraints. */ + public async create(videoConstraints: MediaTrackConstraints) + : Promise<Camera> { + return CameraImpl.create(videoConstraints); + } +} diff --git a/src/main/node_modules/html5-qrcode/src/camera/permissions.d.ts b/src/main/node_modules/html5-qrcode/src/camera/permissions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4209c552093cc9cc5bf1022bd100a4459b988c38 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/camera/permissions.d.ts @@ -0,0 +1,3 @@ +export declare class CameraPermissions { + static hasPermissions(): Promise<boolean>; +} diff --git a/src/main/node_modules/html5-qrcode/src/camera/permissions.ts b/src/main/node_modules/html5-qrcode/src/camera/permissions.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f032ba26afbc8eb383dca584a90fef90bf5e6ce --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/camera/permissions.ts @@ -0,0 +1,34 @@ +/** + * @fileoverview + * Libraries associated with Camera Permissions. + * + * @author mebjas <minhazav@gmail.com> + */ + +/** + * Permission management around Camera in javascript. + * + * TODO(mebjas): Migrate camera specific code / logic to this class / library. + */ + export class CameraPermissions { + + /** + * Returns {@code true} if the web page already has access to user camera + * permissions. + */ + public static async hasPermissions(): Promise<boolean> { + // TODO(mebjas): Use Permissions Query API, once support is widespread. + // https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query + + let devices = await navigator.mediaDevices.enumerateDevices(); + for (const device of devices) { + // Hacky way to check if camera permissions are granted. Device + // labels are only set in case user has granted permissions. + if(device.kind === "videoinput" && device.label) { + return true; + } + } + + return false; + } +} diff --git a/src/main/node_modules/html5-qrcode/src/camera/retriever.d.ts b/src/main/node_modules/html5-qrcode/src/camera/retriever.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0baac120fbc60739f5a0b7b3f59d217b02a41c17 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/camera/retriever.d.ts @@ -0,0 +1,8 @@ +import { CameraDevice } from "./core"; +export declare class CameraRetriever { + static retrieve(): Promise<Array<CameraDevice>>; + private static rejectWithError; + private static isHttpsOrLocalhost; + private static getCamerasFromMediaDevices; + private static getCamerasFromMediaStreamTrack; +} diff --git a/src/main/node_modules/html5-qrcode/src/camera/retriever.ts b/src/main/node_modules/html5-qrcode/src/camera/retriever.ts new file mode 100644 index 0000000000000000000000000000000000000000..227cae8f2ae7b724bd7400f33d1e1d09764ded20 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/camera/retriever.ts @@ -0,0 +1,93 @@ +/** + * @fileoverview + * Libraries associated with retrieving cameras. + * + * @author mebjas <minhazav@gmail.com> + */ + +import { CameraDevice } from "./core"; +import { Html5QrcodeStrings } from "../strings"; + +/** Class for retrieving cameras on the device. */ +export class CameraRetriever { + + /** Returns list of {@link CameraDevice} supported by the device. */ + public static retrieve(): Promise<Array<CameraDevice>> { + if (navigator.mediaDevices) { + return CameraRetriever.getCamerasFromMediaDevices(); + } + + // Using deprecated api to support really old browsers. + var mst = <any>MediaStreamTrack; + if (MediaStreamTrack && mst.getSources) { + return CameraRetriever.getCamerasFromMediaStreamTrack(); + } + + return CameraRetriever.rejectWithError(); + } + + private static rejectWithError(): Promise<Array<CameraDevice>> { + // This can potentially happen if the page is loaded without SSL. + let errorMessage = Html5QrcodeStrings.unableToQuerySupportedDevices(); + if (!CameraRetriever.isHttpsOrLocalhost()) { + errorMessage = Html5QrcodeStrings.insecureContextCameraQueryError(); + } + return Promise.reject(errorMessage); + } + + private static isHttpsOrLocalhost(): boolean { + if (location.protocol === "https:") { + return true; + } + const host = location.host.split(":")[0]; + return host === "127.0.0.1" || host === "localhost"; + } + + private static async getCamerasFromMediaDevices(): Promise<Array<CameraDevice>> { + // Hacky approach to close any active stream if they are active. + const closeActiveStreams = (stream: MediaStream) => { + const tracks = stream.getVideoTracks(); + for (const track of tracks) { + track.enabled = false; + track.stop(); + stream.removeTrack(track); + } + }; + // This should trigger the permission flow if required. + let mediaStream = await navigator.mediaDevices.getUserMedia( + { audio: false, video: true }); + let devices = await navigator.mediaDevices.enumerateDevices(); + let results: Array<CameraDevice> = []; + for (const device of devices) { + if (device.kind === "videoinput") { + results.push({ + id: device.deviceId, + label: device.label + }); + } + } + closeActiveStreams(mediaStream); + return results; + } + + private static getCamerasFromMediaStreamTrack() + : Promise<Array<CameraDevice>> { + return new Promise((resolve, _) => { + const callback = (sourceInfos: Array<any>) => { + const results: Array<CameraDevice> = []; + for (const sourceInfo of sourceInfos) { + if (sourceInfo.kind === "video") { + results.push({ + id: sourceInfo.id, + label: sourceInfo.label + }); + } + } + resolve(results); + } + + var mst = <any>MediaStreamTrack; + mst.getSources(callback); + }); + } +} diff --git a/src/main/node_modules/html5-qrcode/src/code-decoder.d.ts b/src/main/node_modules/html5-qrcode/src/code-decoder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..13d5426a74815c3ff33f9221d161b055910a693c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/code-decoder.d.ts @@ -0,0 +1,16 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, Logger, RobustQrcodeDecoderAsync } from "./core"; +export declare class Html5QrcodeShim implements RobustQrcodeDecoderAsync { + private verbose; + private primaryDecoder; + private secondaryDecoder; + private readonly EXECUTIONS_TO_REPORT_PERFORMANCE; + private executions; + private executionResults; + private wasPrimaryDecoderUsedInLastDecode; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, useBarCodeDetectorIfSupported: boolean, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + decodeRobustlyAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private getDecoder; + private possiblyLogPerformance; + possiblyFlushPerformanceReport(): void; +} diff --git a/src/main/node_modules/html5-qrcode/src/code-decoder.ts b/src/main/node_modules/html5-qrcode/src/code-decoder.ts new file mode 100644 index 0000000000000000000000000000000000000000..f2a034b18808551a5757b2654ce06eaa52ccc52d --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/code-decoder.ts @@ -0,0 +1,127 @@ +/** + * @fileoverview + * Shim layer for providing the decoding library. + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +import { + QrcodeResult, + Html5QrcodeSupportedFormats, + Logger, + QrcodeDecoderAsync, + RobustQrcodeDecoderAsync, +} from "./core"; + +import { ZXingHtml5QrcodeDecoder } from "./zxing-html5-qrcode-decoder"; +import { BarcodeDetectorDelegate } from "./native-bar-code-detector"; + +/** + * Shim layer for {@interface QrcodeDecoder}. + * + * Currently uses {@class ZXingHtml5QrcodeDecoder}, can be replace with another library. + */ +export class Html5QrcodeShim implements RobustQrcodeDecoderAsync { + + private verbose: boolean; + private primaryDecoder: QrcodeDecoderAsync; + private secondaryDecoder: QrcodeDecoderAsync | undefined; + + private readonly EXECUTIONS_TO_REPORT_PERFORMANCE = 100; + private executions: number = 0; + private executionResults: Array<number> = []; + private wasPrimaryDecoderUsedInLastDecode = false; + + public constructor( + requestedFormats: Array<Html5QrcodeSupportedFormats>, + useBarCodeDetectorIfSupported: boolean, + verbose: boolean, + logger: Logger) { + this.verbose = verbose; + + // Use BarcodeDetector library if enabled by config and is supported. + if (useBarCodeDetectorIfSupported + && BarcodeDetectorDelegate.isSupported()) { + this.primaryDecoder = new BarcodeDetectorDelegate( + requestedFormats, verbose, logger); + // If 'BarcodeDetector' is supported, the library will alternate + // between 'BarcodeDetector' and 'zxing-js' to compensate for + // quality gaps between the two. + this.secondaryDecoder = new ZXingHtml5QrcodeDecoder( + requestedFormats, verbose, logger); + } else { + this.primaryDecoder = new ZXingHtml5QrcodeDecoder( + requestedFormats, verbose, logger); + } + } + + async decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult> { + let startTime = performance.now(); + try { + return await this.getDecoder().decodeAsync(canvas); + } finally { + this.possiblyLogPerformance(startTime); + } + } + + async decodeRobustlyAsync(canvas: HTMLCanvasElement) + : Promise<QrcodeResult> { + let startTime = performance.now(); + try { + return await this.primaryDecoder.decodeAsync(canvas); + } catch(error) { + if (this.secondaryDecoder) { + // Try fallback. + return this.secondaryDecoder.decodeAsync(canvas); + } + throw error; + } finally { + this.possiblyLogPerformance(startTime); + } + } + + private getDecoder(): QrcodeDecoderAsync { + if (!this.secondaryDecoder) { + return this.primaryDecoder; + } + + if (this.wasPrimaryDecoderUsedInLastDecode === false) { + this.wasPrimaryDecoderUsedInLastDecode = true; + return this.primaryDecoder; + } + this.wasPrimaryDecoderUsedInLastDecode = false; + return this.secondaryDecoder; + } + + private possiblyLogPerformance(startTime: number) { + if (!this.verbose) { + return; + } + let executionTime = performance.now() - startTime; + this.executionResults.push(executionTime); + this.executions++; + this.possiblyFlushPerformanceReport(); + } + + // Dumps mean decoding latency to console for last + // EXECUTIONS_TO_REPORT_PERFORMANCE runs. + // TODO(mebjas): Can we automate instrumentation runs? + possiblyFlushPerformanceReport() { + if (this.executions < this.EXECUTIONS_TO_REPORT_PERFORMANCE) { + return; + } + + let sum:number = 0; + for (let executionTime of this.executionResults) { + sum += executionTime; + } + let mean = sum / this.executionResults.length; + // eslint-disable-next-line no-console + console.log(`${mean} ms for ${this.executionResults.length} last runs.`); + this.executions = 0; + this.executionResults = []; + } +} diff --git a/src/main/node_modules/html5-qrcode/src/core.d.ts b/src/main/node_modules/html5-qrcode/src/core.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d0206d4fcf87446a1161cd3b548b3196d9262be --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/core.d.ts @@ -0,0 +1,105 @@ +export declare enum Html5QrcodeSupportedFormats { + QR_CODE = 0, + AZTEC = 1, + CODABAR = 2, + CODE_39 = 3, + CODE_93 = 4, + CODE_128 = 5, + DATA_MATRIX = 6, + MAXICODE = 7, + ITF = 8, + EAN_13 = 9, + EAN_8 = 10, + PDF_417 = 11, + RSS_14 = 12, + RSS_EXPANDED = 13, + UPC_A = 14, + UPC_E = 15, + UPC_EAN_EXTENSION = 16 +} +export declare enum DecodedTextType { + UNKNOWN = 0, + URL = 1 +} +export declare function isValidHtml5QrcodeSupportedFormats(format: any): boolean; +export declare enum Html5QrcodeScanType { + SCAN_TYPE_CAMERA = 0, + SCAN_TYPE_FILE = 1 +} +export declare class Html5QrcodeConstants { + static GITHUB_PROJECT_URL: string; + static SCAN_DEFAULT_FPS: number; + static DEFAULT_DISABLE_FLIP: boolean; + static DEFAULT_REMEMBER_LAST_CAMERA_USED: boolean; + static DEFAULT_SUPPORTED_SCAN_TYPE: Html5QrcodeScanType[]; +} +export interface QrDimensions { + width: number; + height: number; +} +export type QrDimensionFunction = (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; +export interface QrBounds extends QrDimensions { + x: number; + y: number; +} +export declare class QrcodeResultFormat { + readonly format: Html5QrcodeSupportedFormats; + readonly formatName: string; + private constructor(); + toString(): string; + static create(format: Html5QrcodeSupportedFormats): QrcodeResultFormat; +} +export interface QrcodeResultDebugData { + decoderName?: string; +} +export interface QrcodeResult { + text: string; + format?: QrcodeResultFormat; + bounds?: QrBounds; + decodedTextType?: DecodedTextType; + debugData?: QrcodeResultDebugData; +} +export interface Html5QrcodeResult { + decodedText: string; + result: QrcodeResult; +} +export declare class Html5QrcodeResultFactory { + static createFromText(decodedText: string): Html5QrcodeResult; + static createFromQrcodeResult(qrcodeResult: QrcodeResult): Html5QrcodeResult; +} +export declare enum Html5QrcodeErrorTypes { + UNKWOWN_ERROR = 0, + IMPLEMENTATION_ERROR = 1, + NO_CODE_FOUND_ERROR = 2 +} +export interface Html5QrcodeError { + errorMessage: string; + type: Html5QrcodeErrorTypes; +} +export declare class Html5QrcodeErrorFactory { + static createFrom(error: any): Html5QrcodeError; +} +export type QrcodeSuccessCallback = (decodedText: string, result: Html5QrcodeResult) => void; +export type QrcodeErrorCallback = (errorMessage: string, error: Html5QrcodeError) => void; +export interface QrcodeDecoderAsync { + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; +} +export interface RobustQrcodeDecoderAsync extends QrcodeDecoderAsync { + decodeRobustlyAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; +} +export interface Logger { + log(message: string): void; + warn(message: string): void; + logError(message: string, isExperimental?: boolean): void; + logErrors(errors: Array<any>): void; +} +export declare class BaseLoggger implements Logger { + private verbose; + constructor(verbose: boolean); + log(message: string): void; + warn(message: string): void; + logError(message: string, isExperimental?: boolean): void; + logErrors(errors: Array<any>): void; +} +export declare function isNullOrUndefined(obj?: any): boolean; +export declare function clip(value: number, minValue: number, maxValue: number): number; diff --git a/src/main/node_modules/html5-qrcode/src/core.ts b/src/main/node_modules/html5-qrcode/src/core.ts new file mode 100644 index 0000000000000000000000000000000000000000..8d3d96560bc3d1bc459374303e692d2d6f9c2f7a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/core.ts @@ -0,0 +1,353 @@ +/** + * @fileoverview + * Core libraries, interfaces, enums shared across {@class Html5Qrcode} & {@class Html5QrcodeScanner} + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +/** + * Code formats supported by this library. + */ +export enum Html5QrcodeSupportedFormats { + QR_CODE = 0, + AZTEC, + CODABAR, + CODE_39, + CODE_93, + CODE_128, + DATA_MATRIX, + MAXICODE, + ITF, + EAN_13, + EAN_8, + PDF_417, + RSS_14, + RSS_EXPANDED, + UPC_A, + UPC_E, + UPC_EAN_EXTENSION, +} + +/** {@code Html5QrcodeSupportedFormats} to friendly name map. */ +const html5QrcodeSupportedFormatsTextMap + : Map<Html5QrcodeSupportedFormats, string> = new Map( + [ + [ Html5QrcodeSupportedFormats.QR_CODE, "QR_CODE" ], + [ Html5QrcodeSupportedFormats.AZTEC, "AZTEC" ], + [ Html5QrcodeSupportedFormats.CODABAR, "CODABAR" ], + [ Html5QrcodeSupportedFormats.CODE_39, "CODE_39" ], + [ Html5QrcodeSupportedFormats.CODE_93, "CODE_93" ], + [ Html5QrcodeSupportedFormats.CODE_128, "CODE_128" ], + [ Html5QrcodeSupportedFormats.DATA_MATRIX, "DATA_MATRIX" ], + [ Html5QrcodeSupportedFormats.MAXICODE, "MAXICODE" ], + [ Html5QrcodeSupportedFormats.ITF, "ITF" ], + [ Html5QrcodeSupportedFormats.EAN_13, "EAN_13" ], + [ Html5QrcodeSupportedFormats.EAN_8, "EAN_8" ], + [ Html5QrcodeSupportedFormats.PDF_417, "PDF_417" ], + [ Html5QrcodeSupportedFormats.RSS_14, "RSS_14" ], + [ Html5QrcodeSupportedFormats.RSS_EXPANDED, "RSS_EXPANDED" ], + [ Html5QrcodeSupportedFormats.UPC_A, "UPC_A" ], + [ Html5QrcodeSupportedFormats.UPC_E, "UPC_E" ], + [ Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, "UPC_EAN_EXTENSION" ] + ] +); + +/** + * Indicates the type of decoded text. + * + * Note: this is very experimental in nature at the moment. + */ +export enum DecodedTextType { + UNKNOWN = 0, + URL, +} + +/** Returns true if the passed object instance is a valid format. */ +export function isValidHtml5QrcodeSupportedFormats(format: any): boolean { + return Object.values(Html5QrcodeSupportedFormats).includes(format); +} + +/** + * Types of scans supported by the library + */ +export enum Html5QrcodeScanType { + SCAN_TYPE_CAMERA = 0, // Camera based scanner. + SCAN_TYPE_FILE = 1 // File based scanner. +} + +/** + * Constants used in QR code library. + */ +export class Html5QrcodeConstants { + static GITHUB_PROJECT_URL: string + = "https://github.com/mebjas/html5-qrcode"; + static SCAN_DEFAULT_FPS = 2; + static DEFAULT_DISABLE_FLIP = false; + static DEFAULT_REMEMBER_LAST_CAMERA_USED = true; + static DEFAULT_SUPPORTED_SCAN_TYPE = [ + Html5QrcodeScanType.SCAN_TYPE_CAMERA, + Html5QrcodeScanType.SCAN_TYPE_FILE]; +} + +/** Defines dimension for QR Code Scanner. */ +export interface QrDimensions { + width: number; + height: number; +} + +/** + * A function that takes in the width and height of the video stream + * and returns QrDimensions. + * + * Viewfinder refers to the video showing camera stream. + */ +export type QrDimensionFunction = + (viewfinderWidth: number, viewfinderHeight: number) => QrDimensions; + +/** + * Defines bounds of detected QR code w.r.t the scan region. + */ +export interface QrBounds extends QrDimensions { + x: number; + y: number; +} + +/** Format of detected code. */ +export class QrcodeResultFormat { + public readonly format: Html5QrcodeSupportedFormats; + public readonly formatName: string; + + private constructor( + format: Html5QrcodeSupportedFormats, + formatName: string) { + this.format = format; + this.formatName = formatName; + } + + public toString(): string { + return this.formatName; + } + + public static create(format: Html5QrcodeSupportedFormats) { + if (!html5QrcodeSupportedFormatsTextMap.has(format)) { + throw `${format} not in html5QrcodeSupportedFormatsTextMap`; + } + return new QrcodeResultFormat( + format, html5QrcodeSupportedFormatsTextMap.get(format)!); + } +} + +/** Data class for QR code result used for debugging. */ +export interface QrcodeResultDebugData { + + /** Name of the decoder that was used for decoding. */ + decoderName?: string; +} + +/** + * Detailed scan result. + */ +export interface QrcodeResult { + /** Decoded text. */ + text: string; + + /** Format that was successfully scanned. */ + format?: QrcodeResultFormat, + + /** + * The bounds of the decoded QR code or bar code in the whole stream of + * image. + * + * Note: this is experimental, and not fully supported. + */ + bounds?: QrBounds; + + /** + * If the decoded text from the QR code or bar code is of a known type like + * url or upi id or email id. + * + * Note: this is experimental, and not fully supported. + */ + decodedTextType?: DecodedTextType; + + /** Data class for QR code result used for debugging. */ + debugData?: QrcodeResultDebugData; +} + +/** + * QrCode result object. + */ +export interface Html5QrcodeResult { + decodedText: string; + result: QrcodeResult; +} + +/** + * Static factory for creating {@interface Html5QrcodeResult} instance. + */ +export class Html5QrcodeResultFactory { + static createFromText(decodedText: string): Html5QrcodeResult { + let qrcodeResult = { + text: decodedText + }; + + return { + decodedText: decodedText, + result: qrcodeResult + }; + } + + static createFromQrcodeResult(qrcodeResult: QrcodeResult) + : Html5QrcodeResult { + return { + decodedText: qrcodeResult.text, + result: qrcodeResult + }; + } +} + +/** + * Different kind of errors that can lead to scanning error. + */ +export enum Html5QrcodeErrorTypes { + UNKWOWN_ERROR = 0, + IMPLEMENTATION_ERROR = 1, + NO_CODE_FOUND_ERROR = 2 +} + +/** + * Interface for scan error response. + */ +export interface Html5QrcodeError { + errorMessage: string; + type: Html5QrcodeErrorTypes; +} + +/** + * Static factory for creating {@interface Html5QrcodeError} instance. + */ +export class Html5QrcodeErrorFactory { + static createFrom(error: any): Html5QrcodeError { + return { + errorMessage: error, + type: Html5QrcodeErrorTypes.UNKWOWN_ERROR + }; + } +} + +/** + * Type for a callback for a successful code scan. + */ +export type QrcodeSuccessCallback + = (decodedText: string, result: Html5QrcodeResult) => void; + +/** + * Type for a callback for failure during code scan. + */ +export type QrcodeErrorCallback + = (errorMessage: string, error: Html5QrcodeError) => void; + +/** Code decoder interface. */ +export interface QrcodeDecoderAsync { + /** + * Decodes content of the canvas to find a valid QR code or bar code. + * + * @param canvas a valid html5 canvas element. + */ + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; +} + +/** + * Code robust decoder interface. + * + * <p> A robust decoder may sacrifice latency of scanning for scanning quality. + * Ideal for file scan kind of operation. + */ +export interface RobustQrcodeDecoderAsync extends QrcodeDecoderAsync { + /** + * Decodes content of the canvas to find a valid QR code or bar code. + * + * <p>The method implementation will run the decoder more robustly at the + * expense of latency. + * + * @param canvas a valid html5 canvas element. + */ + decodeRobustlyAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; +} + +/** Interface for logger. */ +export interface Logger { + log(message: string): void; + warn(message: string): void; + logError(message: string, isExperimental?: boolean): void; + logErrors(errors: Array<any>): void; +} + +/** + * Base logger implementation based on browser console. + * + * This can be replaced by a custom implementation of logger. + * + */ +export class BaseLoggger implements Logger { + + private verbose: boolean; + + public constructor(verbose: boolean) { + this.verbose = verbose; + } + + public log(message: string): void { + if (this.verbose) { + // eslint-disable-next-line no-console + console.log(message); + } + } + + public warn(message: string): void { + if (this.verbose) { + // eslint-disable-next-line no-console + console.warn(message); + } + } + + public logError(message: string, isExperimental?: boolean) + : void { + if (this.verbose || isExperimental === true) { + // eslint-disable-next-line no-console + console.error(message); + } + } + + public logErrors(errors: Array<any>): void { + if (errors.length === 0) { + throw "Logger#logError called without arguments"; + } + if (this.verbose) { + // eslint-disable-next-line no-console + console.error(errors); + } + } +} + +//#region global functions +/** Returns true if the {@param obj} is null or undefined. */ +export function isNullOrUndefined(obj?: any) { + return (typeof obj === "undefined") || obj === null; +} + +/** Clips the {@code value} between {@code minValue} and {@code maxValue}. */ +export function clip(value: number, minValue: number, maxValue: number) { + if (value > maxValue) { + return maxValue; + } + if (value < minValue) { + return minValue; + } + + return value; +} +//#endregion diff --git a/src/main/node_modules/html5-qrcode/src/experimental-features.d.ts b/src/main/node_modules/html5-qrcode/src/experimental-features.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0413abebd02d9788902f9ad47e60d2673507c5fe --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/experimental-features.d.ts @@ -0,0 +1,3 @@ +export interface ExperimentalFeaturesConfig { + useBarCodeDetectorIfSupported?: boolean | undefined; +} diff --git a/src/main/node_modules/html5-qrcode/src/experimental-features.ts b/src/main/node_modules/html5-qrcode/src/experimental-features.ts new file mode 100644 index 0000000000000000000000000000000000000000..70f6c289bf550b8a2210e056951e7ba53e4cd673 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/experimental-features.ts @@ -0,0 +1,44 @@ +/** + * @fileoverview + * Core library for experimental features. + * + * @author mebjas <minhazav@gmail.com> + * + * Experimental features are those which have limited browser compatibility and + * hidden from official documentations. These features are not recommended by + * the author to be used in production unless explictly tested. + * + * Subset of the features are expected to upgrade to official feature list from + * time to time. + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + + +/** + * Configuration for enabling or disabling experimental features in the library. + * + * These features will eventually upgrade as fully supported features in the + * library. + */ +export interface ExperimentalFeaturesConfig { + /** + * {@class BarcodeDetector} is being implemented by browsers at the moment. + * It has very limited browser support but as it gets available it could + * enable faster native code scanning experience. + * + * Set this flag to true, to enable using {@class BarcodeDetector} if + * supported. This is false by default. + * + * @deprecated This configuration has graduated to + * {@code Html5QrcodeCameraScanConfig} you can set it there directly. All + * documentation and future improvements shall be added to that one. This + * config will still work for backwards compatibility. + * + * Documentations: + * - https://developer.mozilla.org/en-US/docs/Web/API/BarcodeDetector + * - https://web.dev/shape-detection/#barcodedetector + */ + useBarCodeDetectorIfSupported?: boolean | undefined; +} diff --git a/src/main/node_modules/html5-qrcode/src/html5-qrcode-scanner.d.ts b/src/main/node_modules/html5-qrcode/src/html5-qrcode-scanner.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..417175bc07418ec36023c076274aef557b25f42b --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/html5-qrcode-scanner.d.ts @@ -0,0 +1,67 @@ +import { Html5QrcodeScanType, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; +import { Html5QrcodeConfigs, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; +import { Html5QrcodeScannerState } from "./state-manager"; +export interface Html5QrcodeScannerConfig extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { + rememberLastUsedCamera?: boolean | undefined; + supportedScanTypes?: Array<Html5QrcodeScanType> | []; + showTorchButtonIfSupported?: boolean | undefined; + showZoomSliderIfSupported?: boolean | undefined; + defaultZoomValueIfSupported?: number | undefined; +} +export declare class Html5QrcodeScanner { + private elementId; + private config; + private verbose; + private currentScanType; + private sectionSwapAllowed; + private persistedDataManager; + private scanTypeSelector; + private logger; + private html5Qrcode; + private qrCodeSuccessCallback; + private qrCodeErrorCallback; + private lastMatchFound; + private cameraScanImage; + private fileScanImage; + private fileSelectionUi; + constructor(elementId: string, config: Html5QrcodeScannerConfig | undefined, verbose: boolean | undefined); + render(qrCodeSuccessCallback: QrcodeSuccessCallback, qrCodeErrorCallback: QrcodeErrorCallback | undefined): void; + pause(shouldPauseVideo?: boolean): void; + resume(): void; + getState(): Html5QrcodeScannerState; + clear(): Promise<void>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + applyVideoConstraints(videoConstaints: MediaTrackConstraints): Promise<void>; + private getHtml5QrcodeOrFail; + private createConfig; + private createBasicLayout; + private resetBasicLayout; + private setupInitialDashboard; + private createHeader; + private createSection; + private createCameraListUi; + private createPermissionButton; + private createPermissionsUi; + private createSectionControlPanel; + private renderFileScanUi; + private renderCameraSelection; + private createSectionSwap; + private startCameraScanIfPermissionExistsOnSwap; + private resetHeaderMessage; + private setHeaderMessage; + private showHideScanTypeSwapLink; + private insertCameraScanImageToScanRegion; + private insertFileScanImageToScanRegion; + private clearScanRegion; + private getDashboardSectionId; + private getDashboardSectionCameraScanRegionId; + private getDashboardSectionSwapLinkId; + private getScanRegionId; + private getDashboardId; + private getHeaderMessageContainerId; + private getCameraPermissionButtonId; + private getCameraScanRegion; + private getDashboardSectionSwapLink; + private getHeaderMessageDiv; +} diff --git a/src/main/node_modules/html5-qrcode/src/html5-qrcode-scanner.ts b/src/main/node_modules/html5-qrcode/src/html5-qrcode-scanner.ts new file mode 100644 index 0000000000000000000000000000000000000000..028262fea03d03c69f70410bf0bb6e561622d059 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/html5-qrcode-scanner.ts @@ -0,0 +1,1137 @@ +/** + * @module + * Complete Scanner build on top of {@link Html5Qrcode}. + * - Decode QR Code using web cam or smartphone camera + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ +import { + Html5QrcodeConstants, + Html5QrcodeScanType, + QrcodeSuccessCallback, + QrcodeErrorCallback, + Html5QrcodeResult, + Html5QrcodeError, + Html5QrcodeErrorFactory, + BaseLoggger, + Logger, + isNullOrUndefined, + clip, +} from "./core"; + +import { CameraCapabilities } from "./camera/core"; + +import { CameraDevice } from "./camera/core"; + +import { + Html5Qrcode, + Html5QrcodeConfigs, + Html5QrcodeCameraScanConfig, + Html5QrcodeFullConfig, +} from "./html5-qrcode"; + +import { + Html5QrcodeScannerStrings, +} from "./strings"; + +import { + ASSET_FILE_SCAN, + ASSET_CAMERA_SCAN, +} from "./image-assets"; + +import { + PersistedDataManager +} from "./storage"; + +import { + LibraryInfoContainer +} from "./ui"; + +import { + CameraPermissions +} from "./camera/permissions"; + +import { Html5QrcodeScannerState } from "./state-manager"; + +import { ScanTypeSelector } from "./ui/scanner/scan-type-selector"; + +import { TorchButton } from "./ui/scanner/torch-button"; + +import { + FileSelectionUi, + OnFileSelected +} from "./ui/scanner/file-selection-ui"; + +import { + BaseUiElementFactory, + PublicUiElementIdAndClasses +} from "./ui/scanner/base"; + +import { CameraSelectionUi } from "./ui/scanner/camera-selection-ui"; +import { CameraZoomUi } from "./ui/scanner/camera-zoom-ui"; + +/** + * Different states of QR Code Scanner. + */ +enum Html5QrcodeScannerStatus { + STATUS_DEFAULT = 0, + STATUS_SUCCESS = 1, + STATUS_WARNING = 2, + STATUS_REQUESTING_PERMISSION = 3, +} + +/** + * Interface for controlling different aspects of {@class Html5QrcodeScanner}. + */ +export interface Html5QrcodeScannerConfig + extends Html5QrcodeCameraScanConfig, Html5QrcodeConfigs { + + /** + * If `true` the library will remember if the camera permissions + * were previously granted and what camera was last used. If the permissions + * is already granted for "camera", QR code scanning will automatically + * start for previously used camera. + * + * Note: default value is `true`. + */ + rememberLastUsedCamera?: boolean | undefined; + + /** + * Sets the desired scan types to be supported in the scanner. + * + * - Not setting a value will follow the default order supported by + * library. + * - First value would be used as the default value. Example: + * - [SCAN_TYPE_CAMERA, SCAN_TYPE_FILE]: Camera will be default type, + * user can switch to file based scan. + * - [SCAN_TYPE_FILE, SCAN_TYPE_CAMERA]: File based scan will be default + * type, user can switch to camera based scan. + * - Setting only value will disable option to switch to other. Example: + * - [SCAN_TYPE_CAMERA] - Only camera based scan supported. + * - [SCAN_TYPE_FILE] - Only file based scan supported. + * - Setting wrong values or multiple values will fail. + */ + supportedScanTypes?: Array<Html5QrcodeScanType> | []; + + /** + * If `true` the rendered UI will have button to turn flash on or off + * based on device + browser support. + * + * Note: default value is `false`. + */ + showTorchButtonIfSupported?: boolean | undefined; + + /** + * If `true` the rendered UI will have slider to zoom camera based on + * device + browser support. + * + * Note: default value is `false`. + * + * TODO(minhazav): Document this API, currently hidden. + */ + showZoomSliderIfSupported?: boolean | undefined; + + /** + * Default zoom value if supported. + * + * Note: default value is 1x. + * + * TODO(minhazav): Document this API, currently hidden. + */ + defaultZoomValueIfSupported?: number | undefined; +} + +function toHtml5QrcodeCameraScanConfig(config: Html5QrcodeScannerConfig) + : Html5QrcodeCameraScanConfig { + return { + fps: config.fps, + qrbox: config.qrbox, + aspectRatio: config.aspectRatio, + disableFlip: config.disableFlip, + videoConstraints: config.videoConstraints + }; +} + +function toHtml5QrcodeFullConfig( + config: Html5QrcodeConfigs, verbose: boolean | undefined) + : Html5QrcodeFullConfig { + return { + formatsToSupport: config.formatsToSupport, + useBarCodeDetectorIfSupported: config.useBarCodeDetectorIfSupported, + experimentalFeatures: config.experimentalFeatures, + verbose: verbose + }; +} + +/** + * End to end web based QR and Barcode Scanner. + * + * Use this class for setting up QR scanner in your web application with + * few lines of codes. + * + * - Supports camera as well as file based scanning. + * - Depending on device supports camera selection, zoom and torch features. + * - Supports different kind of 2D and 1D codes {@link Html5QrcodeSupportedFormats}. + */ +export class Html5QrcodeScanner { + + //#region private fields + private elementId: string; + private config: Html5QrcodeScannerConfig; + private verbose: boolean; + private currentScanType: Html5QrcodeScanType; + private sectionSwapAllowed: boolean; + private persistedDataManager: PersistedDataManager; + private scanTypeSelector: ScanTypeSelector; + private logger: Logger; + + // Initally null fields. + private html5Qrcode: Html5Qrcode | undefined; + private qrCodeSuccessCallback: QrcodeSuccessCallback | undefined; + private qrCodeErrorCallback: QrcodeErrorCallback | undefined; + private lastMatchFound: string | null = null; + private cameraScanImage: HTMLImageElement | null = null; + private fileScanImage: HTMLImageElement | null = null; + private fileSelectionUi: FileSelectionUi | null = null; + //#endregion + + /** + * Creates instance of this class. + * + * @param elementId Id of the HTML element. + * @param config Extra configurations to tune the code scanner. + * @param verbose - If true, all logs would be printed to console. + */ + public constructor( + elementId: string, + config: Html5QrcodeScannerConfig | undefined, + verbose: boolean | undefined) { + this.elementId = elementId; + this.config = this.createConfig(config); + this.verbose = verbose === true; + + if (!document.getElementById(elementId)) { + throw `HTML Element with id=${elementId} not found`; + } + + this.scanTypeSelector = new ScanTypeSelector( + this.config.supportedScanTypes); + this.currentScanType = this.scanTypeSelector.getDefaultScanType(); + + this.sectionSwapAllowed = true; + this.logger = new BaseLoggger(this.verbose); + + this.persistedDataManager = new PersistedDataManager(); + if (config!.rememberLastUsedCamera !== true) { + this.persistedDataManager.reset(); + } + } + + /** + * Renders the User Interface. + * + * @param qrCodeSuccessCallback Callback called when an instance of a QR + * code or any other supported bar code is found. + * @param qrCodeErrorCallback optional, callback called in cases where no + * instance of QR code or any other supported bar code is found. + */ + public render( + qrCodeSuccessCallback: QrcodeSuccessCallback, + qrCodeErrorCallback: QrcodeErrorCallback | undefined) { + this.lastMatchFound = null; + + // Add wrapper to success callback. + this.qrCodeSuccessCallback + = (decodedText: string, result: Html5QrcodeResult) => { + if (qrCodeSuccessCallback) { + qrCodeSuccessCallback(decodedText, result); + } else { + if (this.lastMatchFound === decodedText) { + return; + } + + this.lastMatchFound = decodedText; + this.setHeaderMessage( + Html5QrcodeScannerStrings.lastMatch(decodedText), + Html5QrcodeScannerStatus.STATUS_SUCCESS); + } + }; + + // Add wrapper to failure callback + this.qrCodeErrorCallback = + (errorMessage: string, error: Html5QrcodeError) => { + if (qrCodeErrorCallback) { + qrCodeErrorCallback(errorMessage, error); + } + }; + + const container = document.getElementById(this.elementId); + if (!container) { + throw `HTML Element with id=${this.elementId} not found`; + } + container.innerHTML = ""; + this.createBasicLayout(container!); + this.html5Qrcode = new Html5Qrcode( + this.getScanRegionId(), + toHtml5QrcodeFullConfig(this.config, this.verbose)); + } + + //#region State related public APIs + /** + * Pauses the ongoing scan. + * + * Notes: + * - Should only be called if camera scan is ongoing. + * + * @param shouldPauseVideo (Optional, default = false) If `true` + * the video will be paused. + * + * @throws error if method is called when scanner is not in scanning state. + */ + public pause(shouldPauseVideo?: boolean) { + if (isNullOrUndefined(shouldPauseVideo) || shouldPauseVideo !== true) { + shouldPauseVideo = false; + } + + this.getHtml5QrcodeOrFail().pause(shouldPauseVideo); + } + + /** + * Resumes the paused scan. + * + * If the video was previously paused by setting `shouldPauseVideo` + * to `true` in {@link Html5QrcodeScanner#pause(shouldPauseVideo)}, + * calling this method will resume the video. + * + * Notes: + * - Should only be called if camera scan is ongoing. + * - With this caller will start getting results in success and error + * callbacks. + * + * @throws error if method is called when scanner is not in paused state. + */ + public resume() { + this.getHtml5QrcodeOrFail().resume(); + } + + /** + * Gets state of the camera scan. + * + * @returns state of type {@link Html5QrcodeScannerState}. + */ + public getState(): Html5QrcodeScannerState { + return this.getHtml5QrcodeOrFail().getState(); + } + + /** + * Removes the QR Code scanner UI. + * + * @returns Promise which succeeds if the cleanup is complete successfully, + * fails otherwise. + */ + public clear(): Promise<void> { + const emptyHtmlContainer = () => { + const mainContainer = document.getElementById(this.elementId); + if (mainContainer) { + mainContainer.innerHTML = ""; + this.resetBasicLayout(mainContainer); + } + } + + if (this.html5Qrcode) { + return new Promise((resolve, reject) => { + if (!this.html5Qrcode) { + resolve(); + return; + } + if (this.html5Qrcode.isScanning) { + this.html5Qrcode.stop().then((_) => { + if (!this.html5Qrcode) { + resolve(); + return; + } + + this.html5Qrcode.clear(); + emptyHtmlContainer(); + resolve(); + }).catch((error) => { + if (this.verbose) { + this.logger.logError( + "Unable to stop qrcode scanner", error); + } + reject(error); + }); + } else { + // Assuming file based scan was ongoing. + this.html5Qrcode.clear(); + emptyHtmlContainer(); + resolve(); + } + }); + } + + return Promise.resolve(); + } + //#endregion + + //#region Beta APIs to modify running stream state. + /** + * Returns the capabilities of the running video track. + * + * Read more: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getConstraints + * + * Note: Should only be called if {@link Html5QrcodeScanner#getState()} + * returns {@link Html5QrcodeScannerState#SCANNING} or + * {@link Html5QrcodeScannerState#PAUSED}. + * + * @returns the capabilities of a running video track. + * @throws error if the scanning is not in running state. + */ + public getRunningTrackCapabilities(): MediaTrackCapabilities { + return this.getHtml5QrcodeOrFail().getRunningTrackCapabilities(); + } + + /** + * Returns the object containing the current values of each constrainable + * property of the running video track. + * + * Read more: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getSettings + * + * Note: Should only be called if {@link Html5QrcodeScanner#getState()} + * returns {@link Html5QrcodeScannerState#SCANNING} or + * {@link Html5QrcodeScannerState#PAUSED}. + * + * @returns the supported settings of the running video track. + * @throws error if the scanning is not in running state. + */ + public getRunningTrackSettings(): MediaTrackSettings { + return this.getHtml5QrcodeOrFail().getRunningTrackSettings(); + } + + /** + * Apply a video constraints on running video track from camera. + * + * Note: Should only be called if {@link Html5QrcodeScanner#getState()} + * returns {@link Html5QrcodeScannerState#SCANNING} or + * {@link Html5QrcodeScannerState#PAUSED}. + * + * @param {MediaTrackConstraints} specifies a variety of video or camera + * controls as defined in + * https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints + * @returns a Promise which succeeds if the passed constraints are applied, + * fails otherwise. + * @throws error if the scanning is not in running state. + */ + public applyVideoConstraints(videoConstaints: MediaTrackConstraints) + : Promise<void> { + return this.getHtml5QrcodeOrFail().applyVideoConstraints(videoConstaints); + } + //#endregion + + //#region Private methods + private getHtml5QrcodeOrFail() { + if (!this.html5Qrcode) { + throw "Code scanner not initialized."; + } + return this.html5Qrcode!; + } + + private createConfig(config: Html5QrcodeScannerConfig | undefined) + : Html5QrcodeScannerConfig { + if (config) { + if (!config.fps) { + config.fps = Html5QrcodeConstants.SCAN_DEFAULT_FPS; + } + + if (config.rememberLastUsedCamera !== ( + !Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED)) { + config.rememberLastUsedCamera + = Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED; + } + + if (!config.supportedScanTypes) { + config.supportedScanTypes + = Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE; + } + + return config; + } + + return { + fps: Html5QrcodeConstants.SCAN_DEFAULT_FPS, + rememberLastUsedCamera: + Html5QrcodeConstants.DEFAULT_REMEMBER_LAST_CAMERA_USED, + supportedScanTypes: + Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE + }; + } + + private createBasicLayout(parent: HTMLElement) { + parent.style.position = "relative"; + parent.style.padding = "0px"; + parent.style.border = "1px solid silver"; + this.createHeader(parent); + + const qrCodeScanRegion = document.createElement("div"); + const scanRegionId = this.getScanRegionId(); + qrCodeScanRegion.id = scanRegionId; + qrCodeScanRegion.style.width = "100%"; + qrCodeScanRegion.style.minHeight = "100px"; + qrCodeScanRegion.style.textAlign = "center"; + parent.appendChild(qrCodeScanRegion); + if (ScanTypeSelector.isCameraScanType(this.currentScanType)) { + this.insertCameraScanImageToScanRegion(); + } else { + this.insertFileScanImageToScanRegion(); + } + + const qrCodeDashboard = document.createElement("div"); + const dashboardId = this.getDashboardId(); + qrCodeDashboard.id = dashboardId; + qrCodeDashboard.style.width = "100%"; + parent.appendChild(qrCodeDashboard); + + this.setupInitialDashboard(qrCodeDashboard); + } + + private resetBasicLayout(mainContainer: HTMLElement) { + mainContainer.style.border = "none"; + } + + private setupInitialDashboard(dashboard: HTMLElement) { + this.createSection(dashboard); + this.createSectionControlPanel(); + if (this.scanTypeSelector.hasMoreThanOneScanType()) { + this.createSectionSwap(); + } + } + + private createHeader(dashboard: HTMLElement) { + const header = document.createElement("div"); + header.style.textAlign = "left"; + header.style.margin = "0px"; + dashboard.appendChild(header); + + let libraryInfo = new LibraryInfoContainer(); + libraryInfo.renderInto(header); + + const headerMessageContainer = document.createElement("div"); + headerMessageContainer.id = this.getHeaderMessageContainerId(); + headerMessageContainer.style.display = "none"; + headerMessageContainer.style.textAlign = "center"; + headerMessageContainer.style.fontSize = "14px"; + headerMessageContainer.style.padding = "2px 10px"; + headerMessageContainer.style.margin = "4px"; + headerMessageContainer.style.borderTop = "1px solid #f6f6f6"; + header.appendChild(headerMessageContainer); + } + + private createSection(dashboard: HTMLElement) { + const section = document.createElement("div"); + section.id = this.getDashboardSectionId(); + section.style.width = "100%"; + section.style.padding = "10px 0px 10px 0px"; + section.style.textAlign = "left"; + dashboard.appendChild(section); + } + + private createCameraListUi( + scpCameraScanRegion: HTMLDivElement, + requestPermissionContainer: HTMLDivElement, + requestPermissionButton?: HTMLButtonElement) { + const $this = this; + $this.showHideScanTypeSwapLink(false); + $this.setHeaderMessage( + Html5QrcodeScannerStrings.cameraPermissionRequesting()); + + const createPermissionButtonIfNotExists = () => { + if (!requestPermissionButton) { + $this.createPermissionButton( + scpCameraScanRegion, requestPermissionContainer); + } + } + + Html5Qrcode.getCameras().then((cameras) => { + // By this point the user has granted camera permissions. + $this.persistedDataManager.setHasPermission( + /* hasPermission */ true); + $this.showHideScanTypeSwapLink(true); + $this.resetHeaderMessage(); + if (cameras && cameras.length > 0) { + scpCameraScanRegion.removeChild(requestPermissionContainer); + $this.renderCameraSelection(cameras); + } else { + $this.setHeaderMessage( + Html5QrcodeScannerStrings.noCameraFound(), + Html5QrcodeScannerStatus.STATUS_WARNING); + createPermissionButtonIfNotExists(); + } + }).catch((error) => { + $this.persistedDataManager.setHasPermission( + /* hasPermission */ false); + + if (requestPermissionButton) { + requestPermissionButton.disabled = false; + } else { + // Case when the permission button generation was skipped + // likely due to persistedDataManager indicated permissions + // exists. + // This should ideally never happen, but if it so happened that + // the camera retrieval failed, we want to create button this + // time. + createPermissionButtonIfNotExists(); + } + $this.setHeaderMessage( + error, Html5QrcodeScannerStatus.STATUS_WARNING); + $this.showHideScanTypeSwapLink(true); + }); + } + + private createPermissionButton( + scpCameraScanRegion: HTMLDivElement, + requestPermissionContainer: HTMLDivElement) { + const $this = this; + const requestPermissionButton = BaseUiElementFactory + .createElement<HTMLButtonElement>( + "button", this.getCameraPermissionButtonId()); + requestPermissionButton.innerText + = Html5QrcodeScannerStrings.cameraPermissionTitle(); + + requestPermissionButton.addEventListener("click", function () { + requestPermissionButton.disabled = true; + $this.createCameraListUi( + scpCameraScanRegion, + requestPermissionContainer, + requestPermissionButton); + }); + requestPermissionContainer.appendChild(requestPermissionButton); + } + + private createPermissionsUi( + scpCameraScanRegion: HTMLDivElement, + requestPermissionContainer: HTMLDivElement) { + const $this = this; + + // Only render last selected camera by default if the default scant type + // is camera. + if (ScanTypeSelector.isCameraScanType(this.currentScanType) + && this.persistedDataManager.hasCameraPermissions()) { + CameraPermissions.hasPermissions().then( + (hasPermissions: boolean) => { + if (hasPermissions) { + $this.createCameraListUi( + scpCameraScanRegion, requestPermissionContainer); + } else { + $this.persistedDataManager.setHasPermission( + /* hasPermission */ false); + $this.createPermissionButton( + scpCameraScanRegion, requestPermissionContainer); + } + }).catch((_: any) => { + $this.persistedDataManager.setHasPermission( + /* hasPermission */ false); + $this.createPermissionButton( + scpCameraScanRegion, requestPermissionContainer); + }); + return; + } + + this.createPermissionButton( + scpCameraScanRegion, requestPermissionContainer); + } + + private createSectionControlPanel() { + const section = document.getElementById(this.getDashboardSectionId())!; + const sectionControlPanel = document.createElement("div"); + section.appendChild(sectionControlPanel); + const scpCameraScanRegion = document.createElement("div"); + scpCameraScanRegion.id = this.getDashboardSectionCameraScanRegionId(); + scpCameraScanRegion.style.display + = ScanTypeSelector.isCameraScanType(this.currentScanType) + ? "block" : "none"; + sectionControlPanel.appendChild(scpCameraScanRegion); + + // Web browsers require the users to grant explicit permissions before + // giving camera access. We need to render a button to request user + // permission. + // Assuming when the object is created permission is needed. + const requestPermissionContainer = document.createElement("div"); + requestPermissionContainer.style.textAlign = "center"; + scpCameraScanRegion.appendChild(requestPermissionContainer); + + // TODO(minhazav): If default scan type is file, the permission or + // camera access shouldn't start unless user explicitly switches to + // camera based scan. @priority: high. + + if (this.scanTypeSelector.isCameraScanRequired()) { + this.createPermissionsUi( + scpCameraScanRegion, requestPermissionContainer); + } + + this.renderFileScanUi(sectionControlPanel); + } + + private renderFileScanUi(parent: HTMLDivElement) { + let showOnRender = ScanTypeSelector.isFileScanType( + this.currentScanType); + const $this = this; + let onFileSelected: OnFileSelected = (file: File) => { + if (!$this.html5Qrcode) { + throw "html5Qrcode not defined"; + } + + if (!ScanTypeSelector.isFileScanType($this.currentScanType)) { + return; + } + + $this.setHeaderMessage(Html5QrcodeScannerStrings.loadingImage()); + $this.html5Qrcode.scanFileV2(file, /* showImage= */ true) + .then((html5qrcodeResult: Html5QrcodeResult) => { + $this.resetHeaderMessage(); + $this.qrCodeSuccessCallback!( + html5qrcodeResult.decodedText, + html5qrcodeResult); + }) + .catch((error) => { + $this.setHeaderMessage( + error, Html5QrcodeScannerStatus.STATUS_WARNING); + $this.qrCodeErrorCallback!( + error, Html5QrcodeErrorFactory.createFrom(error)); + }); + }; + + this.fileSelectionUi = FileSelectionUi.create( + parent, showOnRender, onFileSelected); + } + + private renderCameraSelection(cameras: Array<CameraDevice>) { + const $this = this; + const scpCameraScanRegion = document.getElementById( + this.getDashboardSectionCameraScanRegionId())!; + scpCameraScanRegion.style.textAlign = "center"; + + // Hide by default. + let cameraZoomUi: CameraZoomUi = CameraZoomUi.create( + scpCameraScanRegion, /* renderOnCreate= */ false); + const renderCameraZoomUiIfSupported + = (cameraCapabilities: CameraCapabilities) => { + let zoomCapability = cameraCapabilities.zoomFeature(); + if (!zoomCapability.isSupported()) { + return; + } + + // Supported. + cameraZoomUi.setOnCameraZoomValueChangeCallback((zoomValue) => { + zoomCapability.apply(zoomValue); + }); + let defaultZoom = 1; + if (this.config.defaultZoomValueIfSupported) { + defaultZoom = this.config.defaultZoomValueIfSupported; + } + defaultZoom = clip( + defaultZoom, zoomCapability.min(), zoomCapability.max()); + cameraZoomUi.setValues( + zoomCapability.min(), + zoomCapability.max(), + defaultZoom, + zoomCapability.step(), + ); + cameraZoomUi.show(); + }; + + let cameraSelectUi: CameraSelectionUi = CameraSelectionUi.create( + scpCameraScanRegion, cameras); + + // Camera Action Buttons. + const cameraActionContainer = document.createElement("span"); + const cameraActionStartButton + = BaseUiElementFactory.createElement<HTMLButtonElement>( + "button", PublicUiElementIdAndClasses.CAMERA_START_BUTTON_ID); + cameraActionStartButton.innerText + = Html5QrcodeScannerStrings.scanButtonStartScanningText(); + cameraActionContainer.appendChild(cameraActionStartButton); + + const cameraActionStopButton + = BaseUiElementFactory.createElement<HTMLButtonElement>( + "button", PublicUiElementIdAndClasses.CAMERA_STOP_BUTTON_ID); + cameraActionStopButton.innerText + = Html5QrcodeScannerStrings.scanButtonStopScanningText(); + cameraActionStopButton.style.display = "none"; + cameraActionStopButton.disabled = true; + cameraActionContainer.appendChild(cameraActionStopButton); + + // Optional torch button support. + let torchButton: TorchButton; + const createAndShowTorchButtonIfSupported + = (cameraCapabilities: CameraCapabilities) => { + if (!cameraCapabilities.torchFeature().isSupported()) { + // Torch not supported, ignore. + if (torchButton) { + torchButton.hide(); + } + return; + } + + if (!torchButton) { + torchButton = TorchButton.create( + cameraActionContainer, + cameraCapabilities.torchFeature(), + { display: "none", marginLeft: "5px" }, + // Callback in case of torch action failure. + (errorMessage) => { + $this.setHeaderMessage( + errorMessage, + Html5QrcodeScannerStatus.STATUS_WARNING); + } + ); + } else { + torchButton.updateTorchCapability( + cameraCapabilities.torchFeature()); + } + torchButton.show(); + }; + + scpCameraScanRegion.appendChild(cameraActionContainer); + + const resetCameraActionStartButton = (shouldShow: boolean) => { + if (!shouldShow) { + cameraActionStartButton.style.display = "none"; + } + cameraActionStartButton.innerText + = Html5QrcodeScannerStrings + .scanButtonStartScanningText(); + cameraActionStartButton.style.opacity = "1"; + cameraActionStartButton.disabled = false; + if (shouldShow) { + cameraActionStartButton.style.display = "inline-block"; + } + }; + + cameraActionStartButton.addEventListener("click", (_) => { + // Update the UI. + cameraActionStartButton.innerText + = Html5QrcodeScannerStrings.scanButtonScanningStarting(); + cameraSelectUi.disable(); + cameraActionStartButton.disabled = true; + cameraActionStartButton.style.opacity = "0.5"; + // Swap link is available only when both scan types are required. + if (this.scanTypeSelector.hasMoreThanOneScanType()) { + $this.showHideScanTypeSwapLink(false); + } + $this.resetHeaderMessage(); + + // Attempt starting the camera. + const cameraId = cameraSelectUi.getValue(); + $this.persistedDataManager.setLastUsedCameraId(cameraId); + + $this.html5Qrcode!.start( + cameraId, + toHtml5QrcodeCameraScanConfig($this.config), + $this.qrCodeSuccessCallback!, + $this.qrCodeErrorCallback!) + .then((_) => { + cameraActionStopButton.disabled = false; + cameraActionStopButton.style.display = "inline-block"; + resetCameraActionStartButton(/* shouldShow= */ false); + + const cameraCapabilities + = $this.html5Qrcode!.getRunningTrackCameraCapabilities(); + + // Show torch button if needed. + if (this.config.showTorchButtonIfSupported === true) { + createAndShowTorchButtonIfSupported(cameraCapabilities); + } + // Show zoom slider if needed. + if (this.config.showZoomSliderIfSupported === true) { + renderCameraZoomUiIfSupported(cameraCapabilities); + } + }) + .catch((error) => { + $this.showHideScanTypeSwapLink(true); + cameraSelectUi.enable(); + resetCameraActionStartButton(/* shouldShow= */ true); + $this.setHeaderMessage( + error, Html5QrcodeScannerStatus.STATUS_WARNING); + }); + }); + + if (cameraSelectUi.hasSingleItem()) { + // If there is only one camera, start scanning directly. + cameraActionStartButton.click(); + } + + cameraActionStopButton.addEventListener("click", (_) => { + if (!$this.html5Qrcode) { + throw "html5Qrcode not defined"; + } + cameraActionStopButton.disabled = true; + $this.html5Qrcode.stop() + .then((_) => { + // Swap link is required if more than one scan types are + // required. + if(this.scanTypeSelector.hasMoreThanOneScanType()) { + $this.showHideScanTypeSwapLink(true); + } + + cameraSelectUi.enable(); + cameraActionStartButton.disabled = false; + cameraActionStopButton.style.display = "none"; + cameraActionStartButton.style.display = "inline-block"; + // Reset torch state. + if (torchButton) { + torchButton.reset(); + torchButton.hide(); + } + cameraZoomUi.removeOnCameraZoomValueChangeCallback(); + cameraZoomUi.hide(); + $this.insertCameraScanImageToScanRegion(); + }).catch((error) => { + cameraActionStopButton.disabled = false; + $this.setHeaderMessage( + error, Html5QrcodeScannerStatus.STATUS_WARNING); + }); + }); + + if ($this.persistedDataManager.getLastUsedCameraId()) { + const cameraId = $this.persistedDataManager.getLastUsedCameraId()!; + if (cameraSelectUi.hasValue(cameraId)) { + cameraSelectUi.setValue(cameraId); + cameraActionStartButton.click(); + } else { + $this.persistedDataManager.resetLastUsedCameraId(); + } + } + } + + private createSectionSwap() { + const $this = this; + const TEXT_IF_CAMERA_SCAN_SELECTED + = Html5QrcodeScannerStrings.textIfCameraScanSelected(); + const TEXT_IF_FILE_SCAN_SELECTED + = Html5QrcodeScannerStrings.textIfFileScanSelected(); + + // TODO(minhaz): Export this as an UI element. + const section = document.getElementById(this.getDashboardSectionId())!; + const switchContainer = document.createElement("div"); + switchContainer.style.textAlign = "center"; + const switchScanTypeLink + = BaseUiElementFactory.createElement<HTMLAnchorElement>( + "span", this.getDashboardSectionSwapLinkId()); + switchScanTypeLink.style.textDecoration = "underline"; + switchScanTypeLink.style.cursor = "pointer"; + switchScanTypeLink.innerText + = ScanTypeSelector.isCameraScanType(this.currentScanType) + ? TEXT_IF_CAMERA_SCAN_SELECTED : TEXT_IF_FILE_SCAN_SELECTED; + switchScanTypeLink.addEventListener("click", function () { + // TODO(minhazav): Abstract this to a different library. + if (!$this.sectionSwapAllowed) { + if ($this.verbose) { + $this.logger.logError( + "Section swap called when not allowed"); + } + return; + } + + // Cleanup states + $this.resetHeaderMessage(); + $this.fileSelectionUi!.resetValue(); + $this.sectionSwapAllowed = false; + + if (ScanTypeSelector.isCameraScanType($this.currentScanType)) { + // Swap to file based scanning. + $this.clearScanRegion(); + $this.getCameraScanRegion().style.display = "none"; + $this.fileSelectionUi!.show(); + switchScanTypeLink.innerText = TEXT_IF_FILE_SCAN_SELECTED; + $this.currentScanType = Html5QrcodeScanType.SCAN_TYPE_FILE; + $this.insertFileScanImageToScanRegion(); + } else { + // Swap to camera based scanning. + $this.clearScanRegion(); + $this.getCameraScanRegion().style.display = "block"; + $this.fileSelectionUi!.hide(); + switchScanTypeLink.innerText = TEXT_IF_CAMERA_SCAN_SELECTED; + $this.currentScanType = Html5QrcodeScanType.SCAN_TYPE_CAMERA; + $this.insertCameraScanImageToScanRegion(); + + $this.startCameraScanIfPermissionExistsOnSwap(); + } + + $this.sectionSwapAllowed = true; + }); + switchContainer.appendChild(switchScanTypeLink); + section.appendChild(switchContainer); + } + + // Start camera scanning automatically when swapping to camera based scan + // if set in config and has permission. + private startCameraScanIfPermissionExistsOnSwap() { + const $this = this; + if (this.persistedDataManager.hasCameraPermissions()) { + CameraPermissions.hasPermissions().then( + (hasPermissions: boolean) => { + if (hasPermissions) { + // Start feed. + // Assuming at this point the permission button exists. + let permissionButton = document.getElementById( + $this.getCameraPermissionButtonId()); + if (!permissionButton) { + this.logger.logError( + "Permission button not found, fail;"); + throw "Permission button not found"; + } + permissionButton.click(); + } else { + $this.persistedDataManager.setHasPermission( + /* hasPermission */ false); + } + }).catch((_: any) => { + $this.persistedDataManager.setHasPermission( + /* hasPermission */ false); + }); + return; + } + } + + private resetHeaderMessage() { + const messageDiv = document.getElementById( + this.getHeaderMessageContainerId())!; + messageDiv.style.display = "none"; + } + + private setHeaderMessage( + messageText: string, scannerStatus?: Html5QrcodeScannerStatus) { + if (!scannerStatus) { + scannerStatus = Html5QrcodeScannerStatus.STATUS_DEFAULT; + } + + const messageDiv = this.getHeaderMessageDiv(); + messageDiv.innerText = messageText; + messageDiv.style.display = "block"; + + switch (scannerStatus) { + case Html5QrcodeScannerStatus.STATUS_SUCCESS: + messageDiv.style.background = "rgba(106, 175, 80, 0.26)"; + messageDiv.style.color = "#477735"; + break; + case Html5QrcodeScannerStatus.STATUS_WARNING: + messageDiv.style.background = "rgba(203, 36, 49, 0.14)"; + messageDiv.style.color = "#cb2431"; + break; + case Html5QrcodeScannerStatus.STATUS_DEFAULT: + default: + messageDiv.style.background = "rgba(0, 0, 0, 0)"; + messageDiv.style.color = "rgb(17, 17, 17)"; + break; + } + } + + private showHideScanTypeSwapLink(shouldDisplay?: boolean) { + if (this.scanTypeSelector.hasMoreThanOneScanType()) { + if (shouldDisplay !== true) { + shouldDisplay = false; + } + + this.sectionSwapAllowed = shouldDisplay; + this.getDashboardSectionSwapLink().style.display + = shouldDisplay ? "inline-block" : "none"; + } + } + + private insertCameraScanImageToScanRegion() { + const $this = this; + const qrCodeScanRegion = document.getElementById( + this.getScanRegionId())!; + + if (this.cameraScanImage) { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild(this.cameraScanImage); + return; + } + + this.cameraScanImage = new Image; + this.cameraScanImage.onload = (_) => { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild($this.cameraScanImage!); + } + this.cameraScanImage.width = 64; + this.cameraScanImage.style.opacity = "0.8"; + this.cameraScanImage.src = ASSET_CAMERA_SCAN; + this.cameraScanImage.alt = Html5QrcodeScannerStrings.cameraScanAltText(); + } + + private insertFileScanImageToScanRegion() { + const $this = this; + const qrCodeScanRegion = document.getElementById( + this.getScanRegionId())!; + + if (this.fileScanImage) { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild(this.fileScanImage); + return; + } + + this.fileScanImage = new Image; + this.fileScanImage.onload = (_) => { + qrCodeScanRegion.innerHTML = "<br>"; + qrCodeScanRegion.appendChild($this.fileScanImage!); + } + this.fileScanImage.width = 64; + this.fileScanImage.style.opacity = "0.8"; + this.fileScanImage.src = ASSET_FILE_SCAN; + this.fileScanImage.alt = Html5QrcodeScannerStrings.fileScanAltText(); + } + + private clearScanRegion() { + const qrCodeScanRegion = document.getElementById( + this.getScanRegionId())!; + qrCodeScanRegion.innerHTML = ""; + } + + //#region state getters + private getDashboardSectionId(): string { + return `${this.elementId}__dashboard_section`; + } + + private getDashboardSectionCameraScanRegionId(): string { + return `${this.elementId}__dashboard_section_csr`; + } + + private getDashboardSectionSwapLinkId(): string { + return PublicUiElementIdAndClasses.SCAN_TYPE_CHANGE_ANCHOR_ID; + } + + private getScanRegionId(): string { + return `${this.elementId}__scan_region`; + } + + private getDashboardId(): string { + return `${this.elementId}__dashboard`; + } + + private getHeaderMessageContainerId(): string { + return `${this.elementId}__header_message`; + } + + private getCameraPermissionButtonId(): string { + return PublicUiElementIdAndClasses.CAMERA_PERMISSION_BUTTON_ID; + } + + private getCameraScanRegion(): HTMLElement { + return document.getElementById( + this.getDashboardSectionCameraScanRegionId())!; + } + + private getDashboardSectionSwapLink(): HTMLElement { + return document.getElementById(this.getDashboardSectionSwapLinkId())!; + } + + private getHeaderMessageDiv(): HTMLElement { + return document.getElementById(this.getHeaderMessageContainerId())!; + } + //#endregion + //#endregion +} diff --git a/src/main/node_modules/html5-qrcode/src/html5-qrcode.d.ts b/src/main/node_modules/html5-qrcode/src/html5-qrcode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e576933e30835c6b726b5e90faa67d6f3721a3a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/html5-qrcode.d.ts @@ -0,0 +1,75 @@ +import { QrcodeErrorCallback, QrcodeSuccessCallback, Html5QrcodeSupportedFormats, Html5QrcodeResult, QrDimensions, QrDimensionFunction } from "./core"; +import { CameraDevice, CameraCapabilities } from "./camera/core"; +import { ExperimentalFeaturesConfig } from "./experimental-features"; +import { Html5QrcodeScannerState } from "./state-manager"; +export interface Html5QrcodeConfigs { + formatsToSupport?: Array<Html5QrcodeSupportedFormats> | undefined; + useBarCodeDetectorIfSupported?: boolean | undefined; + experimentalFeatures?: ExperimentalFeaturesConfig | undefined; +} +export interface Html5QrcodeFullConfig extends Html5QrcodeConfigs { + verbose: boolean | undefined; +} +export interface Html5QrcodeCameraScanConfig { + fps: number | undefined; + qrbox?: number | QrDimensions | QrDimensionFunction | undefined; + aspectRatio?: number | undefined; + disableFlip?: boolean | undefined; + videoConstraints?: MediaTrackConstraints | undefined; +} +export declare class Html5Qrcode { + private readonly logger; + private readonly elementId; + private readonly verbose; + private readonly qrcode; + private shouldScan; + private element; + private canvasElement; + private scannerPausedUiElement; + private hasBorderShaders; + private borderShaders; + private qrMatch; + private renderedCamera; + private foreverScanTimeout; + private qrRegion; + private context; + private lastScanImageFile; + private stateManagerProxy; + isScanning: boolean; + constructor(elementId: string, configOrVerbosityFlag?: boolean | Html5QrcodeFullConfig | undefined); + start(cameraIdOrConfig: string | MediaTrackConstraints, configuration: Html5QrcodeCameraScanConfig | undefined, qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, qrCodeErrorCallback: QrcodeErrorCallback | undefined): Promise<null>; + pause(shouldPauseVideo?: boolean): void; + resume(): void; + getState(): Html5QrcodeScannerState; + stop(): Promise<void>; + scanFile(imageFile: File, showImage?: boolean): Promise<string>; + scanFileV2(imageFile: File, showImage?: boolean): Promise<Html5QrcodeResult>; + clear(): void; + static getCameras(): Promise<Array<CameraDevice>>; + getRunningTrackCapabilities(): MediaTrackCapabilities; + getRunningTrackSettings(): MediaTrackSettings; + getRunningTrackCameraCapabilities(): CameraCapabilities; + applyVideoConstraints(videoConstaints: MediaTrackConstraints): Promise<void>; + private getRenderedCameraOrFail; + private getSupportedFormats; + private getUseBarCodeDetectorIfSupported; + private validateQrboxSize; + private validateQrboxConfig; + private toQrdimensions; + private setupUi; + private createScannerPausedUiElement; + private scanContext; + private foreverScan; + private createVideoConstraints; + private computeCanvasDrawConfig; + private clearElement; + private possiblyUpdateShaders; + private possiblyCloseLastScanImageFile; + private createCanvasElement; + private getShadedRegionBounds; + private possiblyInsertShadingElement; + private insertShaderBorders; + private showPausedState; + private hidePausedState; + private getTimeoutFps; +} diff --git a/src/main/node_modules/html5-qrcode/src/html5-qrcode.ts b/src/main/node_modules/html5-qrcode/src/html5-qrcode.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3fcbdabf0623c201c19dc5b07ac9352828578bb --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/html5-qrcode.ts @@ -0,0 +1,1595 @@ +/** + * @module + * HTML5 QR code & barcode scanning library. + * - Decode QR Code. + * - Decode different kinds of barcodes. + * - Decode using web cam, smart phone camera or using images on local file + * system. + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +import { + QrcodeErrorCallback, + QrcodeSuccessCallback, + Logger, + BaseLoggger, + Html5QrcodeResultFactory, + Html5QrcodeErrorFactory, + Html5QrcodeSupportedFormats, + RobustQrcodeDecoderAsync, + isValidHtml5QrcodeSupportedFormats, + Html5QrcodeConstants, + Html5QrcodeResult, + isNullOrUndefined, + QrDimensions, + QrDimensionFunction +} from "./core"; +import { Html5QrcodeStrings } from "./strings"; +import { VideoConstraintsUtil } from "./utils"; +import { Html5QrcodeShim } from "./code-decoder"; +import { CameraFactory } from "./camera/factories"; +import { + CameraDevice, + CameraCapabilities, + CameraRenderingOptions, + RenderedCamera, + RenderingCallbacks +} from "./camera/core"; +import { CameraRetriever } from "./camera/retriever"; +import { ExperimentalFeaturesConfig } from "./experimental-features"; +import { + StateManagerProxy, + StateManagerFactory, + StateManagerTransaction, + Html5QrcodeScannerState +} from "./state-manager"; + +class Constants extends Html5QrcodeConstants { + //#region static constants + static DEFAULT_WIDTH = 300; + static DEFAULT_WIDTH_OFFSET = 2; + static FILE_SCAN_MIN_HEIGHT = 300; + static FILE_SCAN_HIDDEN_CANVAS_PADDING = 100; + static MIN_QR_BOX_SIZE = 50; + static SHADED_LEFT = 1; + static SHADED_RIGHT = 2; + static SHADED_TOP = 3; + static SHADED_BOTTOM = 4; + static SHADED_REGION_ELEMENT_ID = "qr-shaded-region"; + static VERBOSE = false; + static BORDER_SHADER_DEFAULT_COLOR = "#ffffff"; + static BORDER_SHADER_MATCH_COLOR = "rgb(90, 193, 56)"; + //#endregion +} + +/** + * Interface for configuring {@link Html5Qrcode} class instance. + */ +export interface Html5QrcodeConfigs { + /** + * Array of formats to support of type {@link Html5QrcodeSupportedFormats}. + * + * All invalid values would be ignored. If null or underfined all supported + * formats will be used for scanning. Unless you want to limit the scan to + * only certain formats or want to improve performance, you should not set + * this value. + */ + formatsToSupport?: Array<Html5QrcodeSupportedFormats> | undefined; + + /** + * {@link BarcodeDetector} is being implemented by browsers at the moment. + * It has very limited browser support but as it gets available it could + * enable faster native code scanning experience. + * + * Set this flag to true, to enable using {@link BarcodeDetector} if + * supported. This is true by default. + * + * Documentations: + * - https://developer.mozilla.org/en-US/docs/Web/API/BarcodeDetector + * - https://web.dev/shape-detection/#barcodedetector + */ + useBarCodeDetectorIfSupported?: boolean | undefined; + + /** + * Config for experimental features. + * + * Everything is false by default. + */ + experimentalFeatures?: ExperimentalFeaturesConfig | undefined; +} + +/** + * Interface for full configuration of {@link Html5Qrcode}. + * + * Notes: Ideally we don't need to have two interfaces for this purpose, but + * since the public APIs before version 2.0.8 allowed passing a boolean verbose + * flag to constructor we need to allow users to pass Html5QrcodeFullConfig or + * boolean flag to be backward compatible. + * In future versions these two interfaces can be merged. + */ +export interface Html5QrcodeFullConfig extends Html5QrcodeConfigs { + /** + * If true, all logs would be printed to console. False by default. + */ + verbose: boolean | undefined; +} + +/** + * Configuration type for scanning QR code with camera. + */ +export interface Html5QrcodeCameraScanConfig { + /** + * Optional, Expected framerate of qr code scanning. example `{ fps: 2 }` means the + * scanning would be done every `500 ms`. + */ + fps: number | undefined; + + /** + * Optional, edge size, dimension or calculator function for QR scanning + * box, the value or computed value should be smaller than the width and + * height of the full region. + * + * This would make the scanner look like this: + * ---------------------- + * |********************| + * |******,,,,,,,,,*****| <--- shaded region + * |******| |*****| <--- non shaded region would be + * |******| |*****| used for QR code scanning. + * |******|_______|*****| + * |********************| + * |********************| + * ---------------------- + * + * Instance of {@link QrDimensions} can be passed to construct a non + * square rendering of scanner box. You can also pass in a function of type + * {@link QrDimensionFunction} that takes in the width and height of the + * video stream and return QR box size of type {@link QrDimensions}. + * + * If this value is not set, no shaded QR box will be rendered and the + * scanner will scan the entire area of video stream. + */ + qrbox?: number | QrDimensions | QrDimensionFunction | undefined; + + /** + * Optional, Desired aspect ratio for the video feed. Ideal aspect ratios + * are 4:3 or 16:9. Passing very wrong aspect ratio could lead to video feed + * not showing up. + */ + aspectRatio?: number | undefined; + + /** + * Optional, if `true` flipped QR Code won't be scanned. Only use this + * if you are sure the camera cannot give mirrored feed if you are facing + * performance constraints. + */ + disableFlip?: boolean | undefined; + + /** + * Optional, @beta(this config is not well supported yet). + * + * Important: When passed this will override other parameters like + * 'cameraIdOrConfig' or configurations like 'aspectRatio'. + * 'videoConstraints' should be of type {@link MediaTrackConstraints} as + * defined in + * https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints + * and is used to specify a variety of video or camera controls like: + * aspectRatio, facingMode, frameRate, etc. + */ + videoConstraints?: MediaTrackConstraints | undefined; +} + +/** + * Internal implementation of {@link Html5QrcodeConfig} with util & factory + * methods. + * + * @hidden + */ +class InternalHtml5QrcodeConfig implements Html5QrcodeCameraScanConfig { + + public readonly fps: number; + public readonly disableFlip: boolean; + public readonly qrbox: number | QrDimensions | QrDimensionFunction | undefined; + public readonly aspectRatio: number | undefined; + public readonly videoConstraints: MediaTrackConstraints | undefined; + + private logger: Logger; + + private constructor( + config: Html5QrcodeCameraScanConfig | undefined, + logger: Logger) { + this.logger = logger; + + this.fps = Constants.SCAN_DEFAULT_FPS; + if (!config) { + this.disableFlip = Constants.DEFAULT_DISABLE_FLIP; + } else { + if (config.fps) { + this.fps = config.fps; + } + this.disableFlip = config.disableFlip === true; + this.qrbox = config.qrbox; + this.aspectRatio = config.aspectRatio; + this.videoConstraints = config.videoConstraints; + } + } + + public isMediaStreamConstraintsValid(): boolean { + if (!this.videoConstraints) { + this.logger.logError( + "Empty videoConstraints", /* experimental= */ true); + return false; + } + + return VideoConstraintsUtil.isMediaStreamConstraintsValid( + this.videoConstraints, this.logger); + } + + public isShadedBoxEnabled(): boolean { + return !isNullOrUndefined(this.qrbox); + } + + /** + * Create instance of {@link Html5QrcodeCameraScanConfig}. + * + * Create configuration by merging default and input settings. + */ + static create(config: Html5QrcodeCameraScanConfig | undefined, logger: Logger) + : InternalHtml5QrcodeConfig { + return new InternalHtml5QrcodeConfig(config, logger); + } +} + +/** @hidden */ +interface QrcodeRegionBounds { + x: number, + y: number, + width: number, + height: number +} + +/** + * Low level APIs for building web based QR and Barcode Scanner. + * + * Supports APIs for camera as well as file based scanning. + * + * Depending of the configuration, the class will help render code + * scanning UI on the provided parent HTML container. + */ +export class Html5Qrcode { + + //#region Private fields. + private readonly logger: Logger; + private readonly elementId: string; + private readonly verbose: boolean; + private readonly qrcode: RobustQrcodeDecoderAsync; + + private shouldScan: boolean; + + // Nullable elements + // TODO(mebjas): Reduce the state-fulness of this mammoth class, by splitting + // into independent classes for better separation of concerns and reducing + // error prone nature of a large stateful class. + private element: HTMLElement | null = null; + private canvasElement: HTMLCanvasElement | null = null; + private scannerPausedUiElement: HTMLDivElement | null = null; + private hasBorderShaders: boolean | null = null; + private borderShaders: Array<HTMLElement> | null = null; + private qrMatch: boolean | null = null; + private renderedCamera: RenderedCamera | null = null; + + private foreverScanTimeout: any; + private qrRegion: QrcodeRegionBounds | null = null; + private context: CanvasRenderingContext2D | null = null; + private lastScanImageFile: string | null = null; + //#endregion + + private stateManagerProxy: StateManagerProxy; + + // TODO(mebjas): deprecate this. + /** @hidden */ + public isScanning: boolean = false; + + /** + * Initialize the code scanner. + * + * @param elementId Id of the HTML element. + * @param configOrVerbosityFlag optional, config object of type {@link + * Html5QrcodeFullConfig} or a boolean verbosity flag (to maintain backward + * compatibility). If nothing is passed, default values would be used. + * If a boolean value is used, it'll be used to set verbosity. Pass a + * config value to configure the Html5Qrcode scanner as per needs. + * + * Use of `configOrVerbosityFlag` as a boolean value is being + * deprecated since version 2.0.7. + * + * TODO(mebjas): Deprecate the verbosity boolean flag completely. + */ + public constructor(elementId: string, + configOrVerbosityFlag?: boolean | Html5QrcodeFullConfig | undefined) { + if (!document.getElementById(elementId)) { + throw `HTML Element with id=${elementId} not found`; + } + + this.elementId = elementId; + this.verbose = false; + + let experimentalFeatureConfig : ExperimentalFeaturesConfig | undefined; + let configObject: Html5QrcodeFullConfig | undefined; + if (typeof configOrVerbosityFlag == "boolean") { + this.verbose = configOrVerbosityFlag === true; + } else if (configOrVerbosityFlag) { + configObject = configOrVerbosityFlag; + this.verbose = configObject.verbose === true; + experimentalFeatureConfig = configObject.experimentalFeatures; + } + + this.logger = new BaseLoggger(this.verbose); + this.qrcode = new Html5QrcodeShim( + this.getSupportedFormats(configOrVerbosityFlag), + this.getUseBarCodeDetectorIfSupported(configObject), + this.verbose, + this.logger); + + this.foreverScanTimeout; + this.shouldScan = true; + this.stateManagerProxy = StateManagerFactory.create(); + } + + //#region start() + /** + * Start scanning QR codes or bar codes for a given camera. + * + * @param cameraIdOrConfig Identifier of the camera, it can either be the + * camera id retrieved from {@link Html5Qrcode#getCameras()} method or + * object with facing mode constraint. + * @param configuration Extra configurations to tune the code scanner. + * @param qrCodeSuccessCallback Callback called when an instance of a QR + * code or any other supported bar code is found. + * @param qrCodeErrorCallback Callback called in cases where no instance of + * QR code or any other supported bar code is found. + * + * @returns Promise for starting the scan. The Promise can fail if the user + * doesn't grant permission or some API is not supported by the browser. + */ + public start( + cameraIdOrConfig: string | MediaTrackConstraints, + configuration: Html5QrcodeCameraScanConfig | undefined, + qrCodeSuccessCallback: QrcodeSuccessCallback | undefined, + qrCodeErrorCallback: QrcodeErrorCallback | undefined, + ): Promise<null> { + + // Code will be consumed as javascript. + if (!cameraIdOrConfig) { + throw "cameraIdOrConfig is required"; + } + + if (!qrCodeSuccessCallback + || typeof qrCodeSuccessCallback != "function") { + throw "qrCodeSuccessCallback is required and should be a function."; + } + + let qrCodeErrorCallbackInternal: QrcodeErrorCallback; + if (qrCodeErrorCallback) { + qrCodeErrorCallbackInternal = qrCodeErrorCallback; + } else { + qrCodeErrorCallbackInternal + = this.verbose ? this.logger.log : () => {}; + } + + const internalConfig = InternalHtml5QrcodeConfig.create( + configuration, this.logger); + this.clearElement(); + + // Check if videoConstraints is passed and valid + let videoConstraintsAvailableAndValid = false; + if (internalConfig.videoConstraints) { + if (!internalConfig.isMediaStreamConstraintsValid()) { + this.logger.logError( + "'videoConstraints' is not valid 'MediaStreamConstraints, " + + "it will be ignored.'", + /* experimental= */ true); + } else { + videoConstraintsAvailableAndValid = true; + } + } + const areVideoConstraintsEnabled = videoConstraintsAvailableAndValid; + + // qr shaded box + const element = document.getElementById(this.elementId)!; + const rootElementWidth = element.clientWidth + ? element.clientWidth : Constants.DEFAULT_WIDTH; + element.style.position = "relative"; + + this.shouldScan = true; + this.element = element; + + const $this = this; + const toScanningStateChangeTransaction: StateManagerTransaction + = this.stateManagerProxy.startTransition( + Html5QrcodeScannerState.SCANNING); + return new Promise((resolve, reject) => { + const videoConstraints = areVideoConstraintsEnabled + ? internalConfig.videoConstraints + : $this.createVideoConstraints(cameraIdOrConfig); + if (!videoConstraints) { + toScanningStateChangeTransaction.cancel(); + reject("videoConstraints should be defined"); + return; + } + + let cameraRenderingOptions: CameraRenderingOptions = {}; + if (!areVideoConstraintsEnabled || internalConfig.aspectRatio) { + cameraRenderingOptions.aspectRatio = internalConfig.aspectRatio; + } + + let renderingCallbacks: RenderingCallbacks = { + onRenderSurfaceReady: (viewfinderWidth, viewfinderHeight) => { + $this.setupUi( + viewfinderWidth, viewfinderHeight, internalConfig); + + $this.isScanning = true; + $this.foreverScan( + internalConfig, + qrCodeSuccessCallback, + qrCodeErrorCallbackInternal!); + } + }; + + + // TODO(minhazav): Flatten this flow. + CameraFactory.failIfNotSupported().then((factory) => { + factory.create(videoConstraints).then((camera) => { + return camera.render( + this.element!, cameraRenderingOptions, renderingCallbacks) + .then((renderedCamera) => { + $this.renderedCamera = renderedCamera; + toScanningStateChangeTransaction.execute(); + resolve(/* Void */ null); + }) + .catch((error) => { + toScanningStateChangeTransaction.cancel(); + reject(error); + }); + }).catch((error) => { + toScanningStateChangeTransaction.cancel(); + reject(Html5QrcodeStrings.errorGettingUserMedia(error)); + }); + }).catch((_) => { + toScanningStateChangeTransaction.cancel(); + reject(Html5QrcodeStrings.cameraStreamingNotSupported()); + }); + }); + } + //#endregion + + //#region Other state related public APIs + /** + * Pauses the ongoing scan. + * + * @param shouldPauseVideo (Optional, default = false) If true the + * video will be paused. + * + * @throws error if method is called when scanner is not in scanning state. + */ + public pause(shouldPauseVideo?: boolean) { + if (!this.stateManagerProxy.isStrictlyScanning()) { + throw "Cannot pause, scanner is not scanning."; + } + this.stateManagerProxy.directTransition(Html5QrcodeScannerState.PAUSED); + this.showPausedState(); + + if (isNullOrUndefined(shouldPauseVideo) || shouldPauseVideo !== true) { + shouldPauseVideo = false; + } + + if (shouldPauseVideo && this.renderedCamera) { + this.renderedCamera.pause(); + } + } + + /** + * Resumes the paused scan. + * + * If the video was previously paused by setting `shouldPauseVideo`` + * to `true` in {@link Html5Qrcode#pause(shouldPauseVideo)}, calling + * this method will resume the video. + * + * Note: with this caller will start getting results in success and error + * callbacks. + * + * @throws error if method is called when scanner is not in paused state. + */ + public resume() { + if (!this.stateManagerProxy.isPaused()) { + throw "Cannot result, scanner is not paused."; + } + + if (!this.renderedCamera) { + throw "renderedCamera doesn't exist while trying resume()"; + } + + const $this = this; + const transitionToScanning = () => { + $this.stateManagerProxy.directTransition( + Html5QrcodeScannerState.SCANNING); + $this.hidePausedState(); + } + + if (!this.renderedCamera.isPaused()) { + transitionToScanning(); + return; + } + this.renderedCamera.resume(() => { + // Transition state, when the video playback has resumed. + transitionToScanning(); + }); + } + + /** + * Gets state of the camera scan. + * + * @returns state of type {@link ScannerState}. + */ + public getState(): Html5QrcodeScannerState { + return this.stateManagerProxy.getState(); + } + + /** + * Stops streaming QR Code video and scanning. + * + * @returns Promise for safely closing the video stream. + */ + public stop(): Promise<void> { + if (!this.stateManagerProxy.isScanning()) { + throw "Cannot stop, scanner is not running or paused."; + } + + const toStoppedStateTransaction: StateManagerTransaction + = this.stateManagerProxy.startTransition( + Html5QrcodeScannerState.NOT_STARTED); + + this.shouldScan = false; + if (this.foreverScanTimeout) { + clearTimeout(this.foreverScanTimeout); + } + + // Removes the shaded region if exists. + const removeQrRegion = () => { + if (!this.element) { + return; + } + let childElement = document.getElementById(Constants.SHADED_REGION_ELEMENT_ID); + if (childElement) { + this.element.removeChild(childElement); + } + }; + + let $this = this; + return this.renderedCamera!.close().then(() => { + $this.renderedCamera = null; + + if ($this.element) { + $this.element.removeChild($this.canvasElement!); + $this.canvasElement = null; + } + + removeQrRegion(); + if ($this.qrRegion) { + $this.qrRegion = null; + } + if ($this.context) { + $this.context = null; + } + + toStoppedStateTransaction.execute(); + $this.hidePausedState(); + $this.isScanning = false; + return Promise.resolve(); + }); + } + //#endregion + + //#region File scan related public APIs + /** + * Scans an Image File for QR Code. + * + * This feature is mutually exclusive to camera-based scanning, you should + * call stop() if the camera-based scanning was ongoing. + * + * @param imageFile a local file with Image content. + * @param showImage if true the Image will be rendered on given + * element. + * + * @returns Promise with decoded QR code string on success and error message + * on failure. Failure could happen due to different reasons: + * 1. QR Code decode failed because enough patterns not found in image. + * 2. Input file was not image or unable to load the image or other image + * load errors. + */ + public scanFile( + imageFile: File, /* default=true */ showImage?: boolean): Promise<string> { + return this.scanFileV2(imageFile, showImage) + .then((html5qrcodeResult) => html5qrcodeResult.decodedText); + } + + /** + * Scans an Image File for QR Code & returns {@link Html5QrcodeResult}. + * + * This feature is mutually exclusive to camera-based scanning, you should + * call stop() if the camera-based scanning was ongoing. + * + * @param imageFile a local file with Image content. + * @param showImage if true the Image will be rendered on given + * element. + * + * @returns Promise which resolves with result of type + * {@link Html5QrcodeResult}. + * + * @beta This is a WIP method, it's available as a public method but not + * documented. + * TODO(mebjas): Replace scanFile with ScanFileV2 + */ + public scanFileV2(imageFile: File, /* default=true */ showImage?: boolean) + : Promise<Html5QrcodeResult> { + if (!imageFile || !(imageFile instanceof File)) { + throw "imageFile argument is mandatory and should be instance " + + "of File. Use 'event.target.files[0]'."; + } + + if (isNullOrUndefined(showImage)) { + showImage = true; + } + + if (!this.stateManagerProxy.canScanFile()) { + throw "Cannot start file scan - ongoing camera scan"; + } + + return new Promise((resolve, reject) => { + this.possiblyCloseLastScanImageFile(); + this.clearElement(); + this.lastScanImageFile = URL.createObjectURL(imageFile); + + const inputImage = new Image; + inputImage.onload = () => { + const imageWidth = inputImage.width; + const imageHeight = inputImage.height; + const element = document.getElementById(this.elementId)!; + const containerWidth = element.clientWidth + ? element.clientWidth : Constants.DEFAULT_WIDTH; + // No default height anymore. + const containerHeight = Math.max( + element.clientHeight ? element.clientHeight : imageHeight, + Constants.FILE_SCAN_MIN_HEIGHT); + + const config = this.computeCanvasDrawConfig( + imageWidth, imageHeight, containerWidth, containerHeight); + if (showImage) { + const visibleCanvas = this.createCanvasElement( + containerWidth, containerHeight, "qr-canvas-visible"); + visibleCanvas.style.display = "inline-block"; + element.appendChild(visibleCanvas); + const context = visibleCanvas.getContext("2d"); + if (!context) { + throw "Unable to get 2d context from canvas"; + } + context.canvas.width = containerWidth; + context.canvas.height = containerHeight; + // More reference + // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage + context.drawImage( + inputImage, + /* sx= */ 0, + /* sy= */ 0, + /* sWidth= */ imageWidth, + /* sHeight= */ imageHeight, + /* dx= */ config.x, + /* dy= */ config.y, + /* dWidth= */ config.width, + /* dHeight= */ config.height); + } + + // Hidden canvas should be at-least as big as the image. + // This could get really troublesome for large images like 12MP + // images or 48MP images captured on phone. + let padding = Constants.FILE_SCAN_HIDDEN_CANVAS_PADDING; + let hiddenImageWidth = Math.max(inputImage.width, config.width); + let hiddenImageHeight = Math.max(inputImage.height, config.height); + + let hiddenCanvasWidth = hiddenImageWidth + 2 * padding; + let hiddenCanvasHeight = hiddenImageHeight + 2 * padding; + + // Try harder for file scan. + // TODO(minhazav): Fallback to mirroring, 90 degree rotation and + // color inversion. + const hiddenCanvas = this.createCanvasElement( + hiddenCanvasWidth, hiddenCanvasHeight); + element.appendChild(hiddenCanvas); + const context = hiddenCanvas.getContext("2d"); + if (!context) { + throw "Unable to get 2d context from canvas"; + } + + context.canvas.width = hiddenCanvasWidth; + context.canvas.height = hiddenCanvasHeight; + context.drawImage( + inputImage, + /* sx= */ 0, + /* sy= */ 0, + /* sWidth= */ imageWidth, + /* sHeight= */ imageHeight, + /* dx= */ padding, + /* dy= */ padding, + /* dWidth= */ hiddenImageWidth, + /* dHeight= */ hiddenImageHeight); + try { + this.qrcode.decodeRobustlyAsync(hiddenCanvas) + .then((result) => { + resolve( + Html5QrcodeResultFactory.createFromQrcodeResult( + result)); + }) + .catch(reject); + } catch (exception) { + reject(`QR code parse error, error = ${exception}`); + } + }; + + inputImage.onerror = reject; + inputImage.onabort = reject; + inputImage.onstalled = reject; + inputImage.onsuspend = reject; + inputImage.src = URL.createObjectURL(imageFile); + }); + } + //#endregion + + /** + * Clears the existing canvas. + * + * Note: in case of ongoing web cam based scan, it needs to be explicitly + * closed before calling this method, else it will throw exception. + */ + public clear(): void { + this.clearElement(); + } + + /** + * Returns list of {@link CameraDevice} supported by the device. + * + * @returns array of camera devices on success. + */ + public static getCameras(): Promise<Array<CameraDevice>> { + return CameraRetriever.retrieve(); + } + + /** + * Returns the capabilities of the running video track. + * + * Read more: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getConstraints + * + * Important: + * 1. Must be called only if the camera based scanning is in progress. + * + * @returns capabilities of the running camera. + * @throws error if the scanning is not in running state. + */ + public getRunningTrackCapabilities(): MediaTrackCapabilities { + return this.getRenderedCameraOrFail().getRunningTrackCapabilities(); + } + + /** + * Returns the object containing the current values of each constrainable + * property of the running video track. + * + * Read more: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getSettings + * + * Important: + * 1. Must be called only if the camera based scanning is in progress. + * + * @returns settings of the running media track. + * + * @throws error if the scanning is not in running state. + */ + public getRunningTrackSettings(): MediaTrackSettings { + return this.getRenderedCameraOrFail().getRunningTrackSettings(); + } + + /** + * Returns {@link CameraCapabilities} of the running video track. + * + * TODO(minhazav): Document this API, currently hidden. + * + * @returns capabilities of the running camera. + * @throws error if the scanning is not in running state. + */ + public getRunningTrackCameraCapabilities(): CameraCapabilities { + return this.getRenderedCameraOrFail().getCapabilities(); + } + + /** + * Apply a video constraints on running video track from camera. + * + * Important: + * 1. Must be called only if the camera based scanning is in progress. + * 2. Changing aspectRatio while scanner is running is not yet supported. + * + * @param {MediaTrackConstraints} specifies a variety of video or camera + * controls as defined in + * https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints + * @returns a Promise which succeeds if the passed constraints are applied, + * fails otherwise. + * @throws error if the scanning is not in running state. + */ + public applyVideoConstraints(videoConstaints: MediaTrackConstraints) + : Promise<void> { + if (!videoConstaints) { + throw "videoConstaints is required argument."; + } else if (!VideoConstraintsUtil.isMediaStreamConstraintsValid( + videoConstaints, this.logger)) { + throw "invalid videoConstaints passed, check logs for more details"; + } + + return this.getRenderedCameraOrFail().applyVideoConstraints( + videoConstaints); + } + + //#region Private methods. + private getRenderedCameraOrFail() { + 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!; + } + + /** + * Construct list of supported formats and returns based on input args. + * `configOrVerbosityFlag` optional, config object of type {@link + * Html5QrcodeFullConfig} or a boolean verbosity flag (to maintain backward + * compatibility). If nothing is passed, default values would be used. + * If a boolean value is used, it'll be used to set verbosity. Pass a + * config value to configure the Html5Qrcode scanner as per needs. + * + * Use of `configOrVerbosityFlag` as a boolean value is being + * deprecated since version 2.0.7. + * + * TODO(mebjas): Deprecate the verbosity boolean flag completely. + */ + private getSupportedFormats( + configOrVerbosityFlag: boolean | Html5QrcodeFullConfig | undefined) + : Array<Html5QrcodeSupportedFormats> { + const allFormats: Array<Html5QrcodeSupportedFormats> = [ + Html5QrcodeSupportedFormats.QR_CODE, + Html5QrcodeSupportedFormats.AZTEC, + Html5QrcodeSupportedFormats.CODABAR, + Html5QrcodeSupportedFormats.CODE_39, + Html5QrcodeSupportedFormats.CODE_93, + Html5QrcodeSupportedFormats.CODE_128, + Html5QrcodeSupportedFormats.DATA_MATRIX, + Html5QrcodeSupportedFormats.MAXICODE, + Html5QrcodeSupportedFormats.ITF, + Html5QrcodeSupportedFormats.EAN_13, + Html5QrcodeSupportedFormats.EAN_8, + Html5QrcodeSupportedFormats.PDF_417, + Html5QrcodeSupportedFormats.RSS_14, + Html5QrcodeSupportedFormats.RSS_EXPANDED, + Html5QrcodeSupportedFormats.UPC_A, + Html5QrcodeSupportedFormats.UPC_E, + Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, + ]; + + if (!configOrVerbosityFlag + || typeof configOrVerbosityFlag == "boolean") { + return allFormats; + } + + if (!configOrVerbosityFlag.formatsToSupport) { + return allFormats; + } + + if (!Array.isArray(configOrVerbosityFlag.formatsToSupport)) { + throw "configOrVerbosityFlag.formatsToSupport should be undefined " + + "or an array."; + } + + if (configOrVerbosityFlag.formatsToSupport.length === 0) { + throw "Atleast 1 formatsToSupport is needed."; + } + + const supportedFormats: Array<Html5QrcodeSupportedFormats> = []; + for (const format of configOrVerbosityFlag.formatsToSupport) { + if (isValidHtml5QrcodeSupportedFormats(format)) { + supportedFormats.push(format); + } else { + this.logger.warn( + `Invalid format: ${format} passed in config, ignoring.`); + } + } + + if (supportedFormats.length === 0) { + throw "None of formatsToSupport match supported values."; + } + return supportedFormats; + + } + + /** + * Returns `true` if `useBarCodeDetectorIfSupported` is + * enabled in the config. + */ + /*eslint complexity: ["error", 10]*/ + private getUseBarCodeDetectorIfSupported( + config: Html5QrcodeConfigs | undefined) : boolean { + // Default value is true. + if (isNullOrUndefined(config)) { + return true; + } + + if (!isNullOrUndefined(config!.useBarCodeDetectorIfSupported)) { + // Default value is false. + return config!.useBarCodeDetectorIfSupported !== false; + } + + if (isNullOrUndefined(config!.experimentalFeatures)) { + return true; + } + + let experimentalFeatures = config!.experimentalFeatures!; + if (isNullOrUndefined( + experimentalFeatures.useBarCodeDetectorIfSupported)) { + return true; + } + + return experimentalFeatures.useBarCodeDetectorIfSupported !== false; + } + + /** + * Validates if the passed config for qrbox is correct. + */ + private validateQrboxSize( + viewfinderWidth: number, + viewfinderHeight: number, + internalConfig: InternalHtml5QrcodeConfig) { + const qrboxSize = internalConfig.qrbox!; + this.validateQrboxConfig(qrboxSize); + let qrDimensions = this.toQrdimensions( + viewfinderWidth, viewfinderHeight, qrboxSize); + + const validateMinSize = (size: number) => { + if (size < Constants.MIN_QR_BOX_SIZE) { + throw "minimum size of 'config.qrbox' dimension value is" + + ` ${Constants.MIN_QR_BOX_SIZE}px.`; + } + }; + + /** + * The 'config.qrbox.width' shall be overriden if it's larger than the + * width of the root element. + * + * Based on the verbosity settings, this will be logged to the logger. + * + * @param configWidth the width of qrbox set by users in the config. + */ + const correctWidthBasedOnRootElementSize = (configWidth: number) => { + if (configWidth > viewfinderWidth) { + this.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."); + configWidth = viewfinderWidth; + } + return configWidth; + }; + + validateMinSize(qrDimensions.width); + validateMinSize(qrDimensions.height); + qrDimensions.width = correctWidthBasedOnRootElementSize( + qrDimensions.width); + // Note: In this case if the height of the qrboxSize turns out to be + // greater than the height of the root element (which should later be + // based on the aspect ratio of the camera stream), it would be silently + // ignored with a warning. + } + + /** + * Validates if the `qrboxSize` is a valid value. + * + * It's expected to be either a number or of type {@link QrDimensions}. + */ + private validateQrboxConfig( + qrboxSize: number | QrDimensions | QrDimensionFunction) { + if (typeof qrboxSize === "number") { + return; + } + + if (typeof qrboxSize === "function") { + // This is a valid format. + return; + } + + // Alternatively, the config is expected to be of type QrDimensions. + if (qrboxSize.width === undefined || qrboxSize.height === undefined) { + throw "Invalid instance of QrDimensions passed for " + + "'config.qrbox'. Both 'width' and 'height' should be set."; + } + } + + /** + * Possibly converts `qrboxSize` to an object of type + * {@link QrDimensions}. + */ + private toQrdimensions( + viewfinderWidth: number, + viewfinderHeight: number, + qrboxSize: number | QrDimensions | QrDimensionFunction): QrDimensions { + if (typeof qrboxSize === "number") { + return { width: qrboxSize, height: qrboxSize}; + } else if (typeof qrboxSize === "function") { + try { + return qrboxSize(viewfinderWidth, viewfinderHeight); + } catch (error) { + throw new Error( + "qrbox config was passed as a function but it failed with " + + "unknown error" + error); + } + } + return qrboxSize; + } + + //#region Documented private methods for camera based scanner. + /** + * Setups the UI elements, changes the state of this class. + * + * @param viewfinderWidth derived width of viewfinder. + * @param viewfinderHeight derived height of viewfinder. + */ + private setupUi( + viewfinderWidth: number, + viewfinderHeight: number, + internalConfig: InternalHtml5QrcodeConfig): void { + // Validate before insertion + if (internalConfig.isShadedBoxEnabled()) { + this.validateQrboxSize( + viewfinderWidth, viewfinderHeight, internalConfig); + } + + // If `qrbox` size is not set, it will default to the dimensions of the + // viewfinder. + const qrboxSize = isNullOrUndefined(internalConfig.qrbox) ? + {width: viewfinderWidth, height: viewfinderHeight}: internalConfig.qrbox!; + + this.validateQrboxConfig(qrboxSize); + let qrDimensions = this.toQrdimensions(viewfinderWidth, viewfinderHeight, qrboxSize); + if (qrDimensions.height > viewfinderHeight) { + this.logger.warn("[Html5Qrcode] config.qrbox has height that is" + + "greater than the height of the video stream. Shading will be" + + " ignored"); + } + + const shouldShadingBeApplied + = internalConfig.isShadedBoxEnabled() + && qrDimensions.height <= viewfinderHeight; + const defaultQrRegion: QrcodeRegionBounds = { + x: 0, + y: 0, + width: viewfinderWidth, + height: viewfinderHeight + }; + + const qrRegion = shouldShadingBeApplied + ? this.getShadedRegionBounds(viewfinderWidth, viewfinderHeight, qrDimensions) + : defaultQrRegion; + + const canvasElement = this.createCanvasElement( + qrRegion.width, qrRegion.height); + // Tell user agent that this canvas will be read frequently. + // More info: + // https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently + const contextAttributes: any = { willReadFrequently: true }; + // Casting canvas to any, as Microsoft's interface definition hasn't + // caught up with latest definition for 'CanvasRenderingContext2DSettings'. + const context: CanvasRenderingContext2D + = (<any>canvasElement).getContext("2d", contextAttributes)!; + context.canvas.width = qrRegion.width; + context.canvas.height = qrRegion.height; + + // Insert the canvas + this.element!.append(canvasElement); + if (shouldShadingBeApplied) { + this.possiblyInsertShadingElement( + this.element!, viewfinderWidth, viewfinderHeight, qrDimensions); + } + + this.createScannerPausedUiElement(this.element!); + + // Update local states + this.qrRegion = qrRegion; + this.context = context; + this.canvasElement = canvasElement; + } + + // TODO(mebjas): Convert this to a standard message viewer. + private createScannerPausedUiElement(rootElement: HTMLElement) { + const scannerPausedUiElement = document.createElement("div"); + scannerPausedUiElement.innerText = Html5QrcodeStrings.scannerPaused(); + scannerPausedUiElement.style.display = "none"; + scannerPausedUiElement.style.position = "absolute"; + scannerPausedUiElement.style.top = "0px"; + scannerPausedUiElement.style.zIndex = "1"; + scannerPausedUiElement.style.background = "rgba(9, 9, 9, 0.46)"; + scannerPausedUiElement.style.color = "#FFECEC"; + scannerPausedUiElement.style.textAlign = "center"; + scannerPausedUiElement.style.width = "100%"; + rootElement.appendChild(scannerPausedUiElement); + this.scannerPausedUiElement = scannerPausedUiElement; + } + + /** + * Scans current context using the qrcode library. + * + * <p>This method call would result in callback being triggered by the + * qrcode library. This method also handles the border coloring. + * + * @returns true if scan match is found, false otherwise. + */ + private scanContext( + qrCodeSuccessCallback: QrcodeSuccessCallback, + qrCodeErrorCallback: QrcodeErrorCallback + ): Promise<boolean> { + if (this.stateManagerProxy.isPaused()) { + return Promise.resolve(false); + } + + return this.qrcode.decodeAsync(this.canvasElement!) + .then((result) => { + qrCodeSuccessCallback( + result.text, + Html5QrcodeResultFactory.createFromQrcodeResult( + result)); + this.possiblyUpdateShaders(/* qrMatch= */ true); + return true; + }).catch((error) => { + this.possiblyUpdateShaders(/* qrMatch= */ false); + let errorMessage = Html5QrcodeStrings.codeParseError(error); + qrCodeErrorCallback( + errorMessage, Html5QrcodeErrorFactory.createFrom(errorMessage)); + return false; + }); + } + + /** + * Forever scanning method. + */ + private foreverScan( + internalConfig: InternalHtml5QrcodeConfig, + qrCodeSuccessCallback: QrcodeSuccessCallback, + qrCodeErrorCallback: QrcodeErrorCallback) { + if (!this.shouldScan) { + // Stop scanning. + return; + } + + if (!this.renderedCamera) { + return; + } + // There is difference in size of rendered video and one that is + // considered by the canvas. Need to account for scaling factor. + const videoElement = this.renderedCamera!.getSurface(); + const widthRatio + = videoElement.videoWidth / videoElement.clientWidth; + const heightRatio + = videoElement.videoHeight / videoElement.clientHeight; + + if (!this.qrRegion) { + throw "qrRegion undefined when localMediaStream is ready."; + } + const sWidthOffset = this.qrRegion.width * widthRatio; + const sHeightOffset = this.qrRegion.height * heightRatio; + const sxOffset = this.qrRegion.x * widthRatio; + const syOffset = this.qrRegion.y * heightRatio; + + // Only decode the relevant area, ignore the shaded area, + // More reference: + // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage + this.context!.drawImage( + videoElement, + /* sx= */ sxOffset, + /* sy= */ syOffset, + /* sWidth= */ sWidthOffset, + /* sHeight= */ sHeightOffset, + /* dx= */ 0, + /* dy= */ 0, + /* dWidth= */ this.qrRegion.width, + /* dHeight= */ this.qrRegion.height); + + const triggerNextScan = () => { + this.foreverScanTimeout = setTimeout(() => { + this.foreverScan( + internalConfig, qrCodeSuccessCallback, qrCodeErrorCallback); + }, this.getTimeoutFps(internalConfig.fps)); + }; + + // Try scanning normal frame and in case of failure, scan + // the inverted context if not explictly disabled. + // TODO(mebjas): Move this logic to decoding library. + this.scanContext(qrCodeSuccessCallback, qrCodeErrorCallback) + .then((isSuccessfull) => { + // Previous scan failed and disableFlip is off. + if (!isSuccessfull && internalConfig.disableFlip !== true) { + this.context!.translate(this.context!.canvas.width, 0); + this.context!.scale(-1, 1); + this.scanContext(qrCodeSuccessCallback, qrCodeErrorCallback) + .finally(() => { + triggerNextScan(); + }); + } else { + triggerNextScan(); + } + }).catch((error) => { + this.logger.logError( + "Error happend while scanning context", error); + triggerNextScan(); + }); + } + + private createVideoConstraints( + cameraIdOrConfig: string | MediaTrackConstraints) + : MediaTrackConstraints | undefined { + if (typeof cameraIdOrConfig == "string") { + // If it's a string it should be camera device Id. + return { deviceId: { exact: cameraIdOrConfig } }; + } else if (typeof cameraIdOrConfig == "object") { + const facingModeKey = "facingMode"; + const deviceIdKey = "deviceId"; + const allowedFacingModeValues + = { "user" : true, "environment" : true}; + const exactKey = "exact"; + const isValidFacingModeValue = (value: string) => { + if (value in allowedFacingModeValues) { + // Valid config + return true; + } else { + // Invalid config + throw "config has invalid 'facingMode' value = " + + `'${value}'`; + } + }; + + const keys = Object.keys(cameraIdOrConfig); + if (keys.length !== 1) { + throw "'cameraIdOrConfig' object should have exactly 1 key," + + ` if passed as an object, found ${keys.length} keys`; + } + + const key:string = Object.keys(cameraIdOrConfig)[0]; + if (key !== facingModeKey && key !== deviceIdKey) { + throw `Only '${facingModeKey}' and '${deviceIdKey}' ` + + " are supported for 'cameraIdOrConfig'"; + } + + if (key === facingModeKey) { + /** + * Supported scenarios: + * - { facingMode: "user" } + * - { facingMode: "environment" } + * - { facingMode: { exact: "environment" } } + * - { facingMode: { exact: "user" } } + */ + const facingMode: any = cameraIdOrConfig.facingMode; + if (typeof facingMode == "string") { + if (isValidFacingModeValue(facingMode)) { + return { facingMode: facingMode }; + } + } else if (typeof facingMode == "object") { + if (exactKey in facingMode) { + if (isValidFacingModeValue(facingMode[`${exactKey}`])) { + return { + facingMode: { + exact: facingMode[`${exactKey}`] + } + }; + } + } else { + throw "'facingMode' should be string or object with" + + ` ${exactKey} as key.`; + } + } else { + const type = (typeof facingMode); + throw `Invalid type of 'facingMode' = ${type}`; + } + } else { + /** + * key == deviceIdKey; Supported scenarios: + * - { deviceId: { exact: "a76afe74e95e3.....38627b3bde" } + * - { deviceId: "a76afe74e95e3....065c9cd89438627b3bde" } + */ + const deviceId: any = cameraIdOrConfig.deviceId; + if (typeof deviceId == "string") { + return { deviceId: deviceId }; + } else if (typeof deviceId == "object") { + if (exactKey in deviceId) { + return { + deviceId : { exact: deviceId[`${exactKey}`] } + }; + } else { + throw "'deviceId' should be string or object with" + + ` ${exactKey} as key.`; + } + } else { + const type = (typeof deviceId); + throw `Invalid type of 'deviceId' = ${type}`; + } + } + } + + + // invalid type + const type = (typeof cameraIdOrConfig); + throw `Invalid type of 'cameraIdOrConfig' = ${type}`; + } + //#endregion + + //#region Documented private methods for file based scanner. + private computeCanvasDrawConfig( + imageWidth: number, + imageHeight: number, + containerWidth: number, + containerHeight: number): QrcodeRegionBounds { + + if (imageWidth <= containerWidth + && imageHeight <= containerHeight) { + // no downsampling needed. + const xoffset = (containerWidth - imageWidth) / 2; + const yoffset = (containerHeight - imageHeight) / 2; + return { + x: xoffset, + y: yoffset, + width: imageWidth, + height: imageHeight + }; + } else { + const formerImageWidth = imageWidth; + const formerImageHeight = imageHeight; + if (imageWidth > containerWidth) { + imageHeight = (containerWidth / imageWidth) * imageHeight; + imageWidth = containerWidth; + } + + if (imageHeight > containerHeight) { + imageWidth = (containerHeight / imageHeight) * imageWidth; + imageHeight = containerHeight; + } + + this.logger.log( + "Image downsampled from " + + `${formerImageWidth}X${formerImageHeight}` + + ` to ${imageWidth}X${imageHeight}.`); + + return this.computeCanvasDrawConfig( + imageWidth, imageHeight, containerWidth, containerHeight); + } + } + //#endregion + + private clearElement(): void { + if (this.stateManagerProxy.isScanning()) { + throw "Cannot clear while scan is ongoing, close it first."; + } + const element = document.getElementById(this.elementId); + if (element) { + element.innerHTML = ""; + } + } + + private possiblyUpdateShaders(qrMatch: boolean) { + if (this.qrMatch === qrMatch) { + return; + } + + if (this.hasBorderShaders + && this.borderShaders + && this.borderShaders.length) { + this.borderShaders.forEach((shader) => { + shader.style.backgroundColor = qrMatch + ? Constants.BORDER_SHADER_MATCH_COLOR + : Constants.BORDER_SHADER_DEFAULT_COLOR; + }); + } + this.qrMatch = qrMatch; + } + + private possiblyCloseLastScanImageFile() { + if (this.lastScanImageFile) { + URL.revokeObjectURL(this.lastScanImageFile); + this.lastScanImageFile = null; + } + } + + private createCanvasElement( + width: number, height: number, customId?: string): HTMLCanvasElement { + const canvasWidth = width; + const canvasHeight = height; + const canvasElement = document.createElement("canvas"); + canvasElement.style.width = `${canvasWidth}px`; + canvasElement.style.height = `${canvasHeight}px`; + canvasElement.style.display = "none"; + canvasElement.id = isNullOrUndefined(customId) + ? "qr-canvas" : customId!; + return canvasElement; + } + + private getShadedRegionBounds( + width: number, height: number, qrboxSize: QrDimensions) + : QrcodeRegionBounds { + if (qrboxSize.width > width || qrboxSize.height > height) { + throw "'config.qrbox' dimensions should not be greater than the " + + "dimensions of the root HTML element."; + } + + return { + x: (width - qrboxSize.width) / 2, + y: (height - qrboxSize.height) / 2, + width: qrboxSize.width, + height: qrboxSize.height + }; + } + + private possiblyInsertShadingElement( + element: HTMLElement, + width: number, + height: number, + qrboxSize: QrDimensions) { + if ((width - qrboxSize.width) < 1 || (height - qrboxSize.height) < 1) { + return; + } + const shadingElement = document.createElement("div"); + shadingElement.style.position = "absolute"; + + const rightLeftBorderSize = (width - qrboxSize.width) / 2; + const topBottomBorderSize = (height - qrboxSize.height) / 2; + + shadingElement.style.borderLeft + = `${rightLeftBorderSize}px solid rgba(0, 0, 0, 0.48)`; + shadingElement.style.borderRight + = `${rightLeftBorderSize}px solid rgba(0, 0, 0, 0.48)`; + shadingElement.style.borderTop + = `${topBottomBorderSize}px solid rgba(0, 0, 0, 0.48)`; + shadingElement.style.borderBottom + = `${topBottomBorderSize}px solid rgba(0, 0, 0, 0.48)`; + shadingElement.style.boxSizing = "border-box"; + shadingElement.style.top = "0px"; + shadingElement.style.bottom = "0px"; + shadingElement.style.left = "0px"; + shadingElement.style.right = "0px"; + shadingElement.id = `${Constants.SHADED_REGION_ELEMENT_ID}`; + + // Check if div is too small for shadows. As there are two 5px width + // borders the needs to have a size above 10px. + if ((width - qrboxSize.width) < 11 + || (height - qrboxSize.height) < 11) { + this.hasBorderShaders = false; + } else { + const smallSize = 5; + const largeSize = 40; + this.insertShaderBorders( + shadingElement, + /* width= */ largeSize, + /* height= */ smallSize, + /* top= */ -smallSize, + /* bottom= */ null, + /* side= */ 0, + /* isLeft= */ true); + this.insertShaderBorders( + shadingElement, + /* width= */ largeSize, + /* height= */ smallSize, + /* top= */ -smallSize, + /* bottom= */ null, + /* side= */ 0, + /* isLeft= */ false); + this.insertShaderBorders( + shadingElement, + /* width= */ largeSize, + /* height= */ smallSize, + /* top= */ null, + /* bottom= */ -smallSize, + /* side= */ 0, + /* isLeft= */ true); + this.insertShaderBorders( + shadingElement, + /* width= */ largeSize, + /* height= */ smallSize, + /* top= */ null, + /* bottom= */ -smallSize, + /* side= */ 0, + /* isLeft= */ false); + this.insertShaderBorders( + shadingElement, + /* width= */ smallSize, + /* height= */ largeSize + smallSize, + /* top= */ -smallSize, + /* bottom= */ null, + /* side= */ -smallSize, + /* isLeft= */ true); + this.insertShaderBorders( + shadingElement, + /* width= */ smallSize, + /* height= */ largeSize + smallSize, + /* top= */ null, + /* bottom= */ -smallSize, + /* side= */ -smallSize, + /* isLeft= */ true); + this.insertShaderBorders( + shadingElement, + /* width= */ smallSize, + /* height= */ largeSize + smallSize, + /* top= */ -smallSize, + /* bottom= */ null, + /* side= */ -smallSize, + /* isLeft= */ false); + this.insertShaderBorders( + shadingElement, + /* width= */ smallSize, + /* height= */ largeSize + smallSize, + /* top= */ null, + /* bottom= */ -smallSize, + /* side= */ -smallSize, + /* isLeft= */ false); + this.hasBorderShaders = true; + } + element.append(shadingElement); + } + + private insertShaderBorders( + shaderElem: HTMLDivElement, + width: number, + height: number, + top: number | null, + bottom: number | null, + side: number, + isLeft: boolean) { + const elem = document.createElement("div"); + elem.style.position = "absolute"; + elem.style.backgroundColor = Constants.BORDER_SHADER_DEFAULT_COLOR; + elem.style.width = `${width}px`; + elem.style.height = `${height}px`; + if (top !== null) { + elem.style.top = `${top}px`; + } + if (bottom !== null) { + elem.style.bottom = `${bottom}px`; + } + if (isLeft) { + elem.style.left = `${side}px`; + } else { + elem.style.right = `${side}px`; + } + if (!this.borderShaders) { + this.borderShaders = []; + } + this.borderShaders.push(elem); + shaderElem.appendChild(elem); + } + + private showPausedState() { + if (!this.scannerPausedUiElement) { + throw "[internal error] scanner paused UI element not found"; + } + this.scannerPausedUiElement.style.display = "block"; + } + + private hidePausedState() { + if (!this.scannerPausedUiElement) { + throw "[internal error] scanner paused UI element not found"; + } + this.scannerPausedUiElement.style.display = "none"; + } + + private getTimeoutFps(fps: number) { + return 1000 / fps; + } + //#endregion +} diff --git a/src/main/node_modules/html5-qrcode/src/image-assets.d.ts b/src/main/node_modules/html5-qrcode/src/image-assets.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..59387ac2e6d5b21c1d1862a744e923298b400a24 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/image-assets.d.ts @@ -0,0 +1,4 @@ +export declare const ASSET_CAMERA_SCAN: string; +export declare const ASSET_FILE_SCAN: string; +export declare const ASSET_INFO_ICON_16PX: string; +export declare const ASSET_CLOSE_ICON_16PX: string; diff --git a/src/main/node_modules/html5-qrcode/src/image-assets.ts b/src/main/node_modules/html5-qrcode/src/image-assets.ts new file mode 100644 index 0000000000000000000000000000000000000000..a27a6731e494b8c99bc7d17b63d0e823bf03084c --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/image-assets.ts @@ -0,0 +1,18 @@ +/** + * @fileoverview - Exports base64 assets for gif images. + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +const SVG_XML_PREFIX = "data:image/svg+xml;base64,"; + +export const ASSET_CAMERA_SCAN: string = SVG_XML_PREFIX + "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzNzEuNjQzIDM3MS42NDMiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDM3MS42NDMgMzcxLjY0MyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBhdGggZD0iTTEwNS4wODQgMzguMjcxaDE2My43Njh2MjBIMTA1LjA4NHoiLz48cGF0aCBkPSJNMzExLjU5NiAxOTAuMTg5Yy03LjQ0MS05LjM0Ny0xOC40MDMtMTYuMjA2LTMyLjc0My0yMC41MjJWMzBjMC0xNi41NDItMTMuNDU4LTMwLTMwLTMwSDEyNS4wODRjLTE2LjU0MiAwLTMwIDEzLjQ1OC0zMCAzMHYxMjAuMTQzaC04LjI5NmMtMTYuNTQyIDAtMzAgMTMuNDU4LTMwIDMwdjEuMzMzYTI5LjgwNCAy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lzAAAAQgAAAEIBarqQRAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAE1SURBVDiNfdI7S0NBEAXgLya1otFgpbYSbISAgpXYi6CmiH9KCAiChaVga6OiWPgfRDQ+0itaGVNosXtluWwcuMzePfM4M3sq8lbHBubwg1dc4m1E/J/N4ghDPOIsfk/4xiEao5KX0McFljN4C9d4QTPXuY99jP3DsIoDPGM6BY5i5yI5R7O4q+ImFkJY2DCh3cAH2klyB+9J1xUMMAG7eCh1a+Mr+k48b5diXrFVwwLuS+BJ9MfR7+G0FHOHhTHhnXNWS87VDF4pcnfQK4Ep7XScNLmPTZgURNKKYENYWDpzW1BhscS1WHS8CDgURFJQrWcoF3c13KKbgg1BYQfy8xZWEzTTw1QZbAoKu8FqJnktdu5hcVSHmchiILzzuaDQvjBzV2m8yohCE1jHfPx/xhU+y4G/D75ELlRJsSYAAAAASUVORK5CYII="; diff --git a/src/main/node_modules/html5-qrcode/src/index.d.ts b/src/main/node_modules/html5-qrcode/src/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6b90c689f1a0c34ea728b5b7a5375a33722ed9f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/index.d.ts @@ -0,0 +1,6 @@ +export { Html5Qrcode, Html5QrcodeFullConfig, Html5QrcodeCameraScanConfig } from "./html5-qrcode"; +export { Html5QrcodeScanner } from "./html5-qrcode-scanner"; +export { Html5QrcodeSupportedFormats, Html5QrcodeResult, QrcodeSuccessCallback, QrcodeErrorCallback } from "./core"; +export { Html5QrcodeScannerState } from "./state-manager"; +export { Html5QrcodeScanType } from "./core"; +export { CameraCapabilities, CameraDevice } from "./camera/core"; diff --git a/src/main/node_modules/html5-qrcode/src/index.ts b/src/main/node_modules/html5-qrcode/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..b9854263e3163d5307a81e57b4599e365fd28df4 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/index.ts @@ -0,0 +1,32 @@ +/** + * @fileoverview - Global export file. + * HTML5 QR code & barcode scanning library. + * - Decode QR Code. + * - Decode different kinds of barcodes. + * - Decode using web cam, smart phone camera or using images on local file + * system. + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +export { + Html5Qrcode, + Html5QrcodeFullConfig, + Html5QrcodeCameraScanConfig +} from "./html5-qrcode"; +export { Html5QrcodeScanner } from "./html5-qrcode-scanner"; +export { + Html5QrcodeSupportedFormats, + Html5QrcodeResult, + QrcodeSuccessCallback, + QrcodeErrorCallback +} from "./core"; +export { Html5QrcodeScannerState } from "./state-manager"; +export { Html5QrcodeScanType } from "./core"; +export { + CameraCapabilities, + CameraDevice +} from "./camera/core"; diff --git a/src/main/node_modules/html5-qrcode/src/native-bar-code-detector.d.ts b/src/main/node_modules/html5-qrcode/src/native-bar-code-detector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..85ef95e4c4fec982c26cea91f5bb9eb21923bdf4 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/native-bar-code-detector.d.ts @@ -0,0 +1,16 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, QrcodeDecoderAsync, Logger } from "./core"; +export declare class BarcodeDetectorDelegate implements QrcodeDecoderAsync { + private readonly formatMap; + private readonly reverseFormatMap; + private verbose; + private logger; + private detector; + static isSupported(): boolean; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private selectLargestBarcode; + private createBarcodeDetectorFormats; + private toHtml5QrcodeSupportedFormats; + private createReverseFormatMap; + private createDebugData; +} diff --git a/src/main/node_modules/html5-qrcode/src/native-bar-code-detector.ts b/src/main/node_modules/html5-qrcode/src/native-bar-code-detector.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9004d268f2f8d1d68f1d8ab0314fc90f9937082 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/native-bar-code-detector.ts @@ -0,0 +1,204 @@ +/** + * @fileoverview + * {@interface QrcodeDecoder} wrapper around experimental BarcodeDetector API. + * + * @author mebjas <minhazav@gmail.com> + * + * Read more about the experimental feature here: + * https://developer.mozilla.org/en-US/docs/Web/API/BarcodeDetector + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +import { + QrcodeResult, + QrcodeResultDebugData, + QrcodeResultFormat, + Html5QrcodeSupportedFormats, + QrcodeDecoderAsync, + Logger +} from "./core"; + +declare const BarcodeDetector: any; + +/** Config for BarcodeDetector API. */ +interface BarcodeDetectorConfig { + formats: Array<string>; +} + +/** + * Interface for BarcodeDetector result. + * + * Forked from + * https://developer.mozilla.org/en-US/docs/Web/API/BarcodeDetector#methods + */ +interface BarcodeDetectorResult { + /** + * A DOMRectReadOnly, which returns the dimensions of a rectangle + * representing the extent of a detected barcode, aligned with the image. + */ + boundingBox: DOMRectReadOnly; + + /** + * The x and y co-ordinates of the four corner points of the detected + * barcode relative to the image, starting with the top left and working + * clockwise. This may not be square due to perspective distortions within + * the image. + */ + cornerPoints: any; + + /** + * The detected barcode format. + */ + format: string; + + /** + * A String decoded from the barcode data. + */ + rawValue: string; +} + +/** + * ZXing based Code decoder. + */ + export class BarcodeDetectorDelegate implements QrcodeDecoderAsync { + + // All formats defined here + // https://developer.mozilla.org/en-US/docs/Web/API/Barcode_Detection_API#supported_barcode_formats + private readonly formatMap: Map<Html5QrcodeSupportedFormats, string> + = new Map([ + [ Html5QrcodeSupportedFormats.QR_CODE, "qr_code" ], + [ Html5QrcodeSupportedFormats.AZTEC, "aztec" ], + [ Html5QrcodeSupportedFormats.CODABAR, "codabar" ], + [ Html5QrcodeSupportedFormats.CODE_39, "code_39" ], + [ Html5QrcodeSupportedFormats.CODE_93, "code_93" ], + [ Html5QrcodeSupportedFormats.CODE_128, "code_128" ], + [ Html5QrcodeSupportedFormats.DATA_MATRIX, "data_matrix" ], + [ Html5QrcodeSupportedFormats.ITF, "itf" ], + [ Html5QrcodeSupportedFormats.EAN_13, "ean_13" ], + [ Html5QrcodeSupportedFormats.EAN_8, "ean_8" ], + [ Html5QrcodeSupportedFormats.PDF_417, "pdf417" ], + [ Html5QrcodeSupportedFormats.UPC_A, "upc_a" ], + [ Html5QrcodeSupportedFormats.UPC_E, "upc_e" ] + ]); + private readonly reverseFormatMap: Map<string, Html5QrcodeSupportedFormats> + = this.createReverseFormatMap(); + + private verbose: boolean; + private logger: Logger; + private detector: any; + + /** + * Returns true if this API is supported by the browser. + * + * TODO(mebjas): Add checks like this + * https://web.dev/shape-detection/#featuredetection + * TODO(mebjas): Check for format supported by the BarcodeDetector using + * getSupportedFormats() API. + * @returns + */ + public static isSupported(): boolean { + if (!("BarcodeDetector" in window)) { + return false; + } + const dummyDetector = new BarcodeDetector({formats: [ "qr_code" ]}); + return typeof dummyDetector !== "undefined"; + } + + public constructor( + requestedFormats: Array<Html5QrcodeSupportedFormats>, + verbose: boolean, + logger: Logger) { + if (!BarcodeDetectorDelegate.isSupported()) { + throw "Use html5qrcode.min.js without edit, Use " + + "BarcodeDetectorDelegate only if it isSupported();"; + } + this.verbose = verbose; + this.logger = logger; + + // create new detector + const formats = this.createBarcodeDetectorFormats(requestedFormats); + this.detector = new BarcodeDetector(formats); + + // check compatibility + if (!this.detector) { + throw "BarcodeDetector detector not supported"; + } + } + + async decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult> { + const barcodes: Array<BarcodeDetectorResult> + = await this.detector.detect(canvas); + if (!barcodes || barcodes.length === 0) { + throw "No barcode or QR code detected."; + } + + // TODO(mebjas): Today BarcodeDetector library seems to be returning + // mutliple barcodes if supported. But the documentation around it is + // not the best. As of now, we are returning just the largest code + // found. In future it'd be desriable to return mutli codes if supported + // and found. + let largestBarcode = this.selectLargestBarcode(barcodes); + return { + text: largestBarcode.rawValue, + format: QrcodeResultFormat.create( + this.toHtml5QrcodeSupportedFormats(largestBarcode.format)), + debugData: this.createDebugData() + }; + } + + private selectLargestBarcode(barcodes: Array<BarcodeDetectorResult>) + : BarcodeDetectorResult { + let largestBarcode: BarcodeDetectorResult | null = null; + let maxArea = 0; + for (let barcode of barcodes) { + let area = barcode.boundingBox.width * barcode.boundingBox.height; + if (area > maxArea) { + maxArea = area; + largestBarcode = barcode; + } + } + if (!largestBarcode) { + throw "No largest barcode found"; + } + return largestBarcode!; + } + + private createBarcodeDetectorFormats( + requestedFormats: Array<Html5QrcodeSupportedFormats>): + BarcodeDetectorConfig { + let formats: Array<string> = []; + for (const requestedFormat of requestedFormats) { + if (this.formatMap.has(requestedFormat)) { + formats.push( + this.formatMap.get(requestedFormat)!); + } else { + this.logger.warn(`${requestedFormat} is not supported by` + + "BarcodeDetectorDelegate"); + } + } + return { formats: formats }; + } + + private toHtml5QrcodeSupportedFormats(barcodeDetectorFormat: string) + : Html5QrcodeSupportedFormats { + if (!this.reverseFormatMap.has(barcodeDetectorFormat)) { + throw `reverseFormatMap doesn't have ${barcodeDetectorFormat}`; + } + return this.reverseFormatMap.get(barcodeDetectorFormat)!; + } + + private createReverseFormatMap(): Map<string, Html5QrcodeSupportedFormats> { + let result = new Map(); + this.formatMap.forEach( + (value: string, key: Html5QrcodeSupportedFormats, _) => { + result.set(value, key); + }); + return result; + } + + private createDebugData(): QrcodeResultDebugData { + return { decoderName: "BarcodeDetector" }; + } +} diff --git a/src/main/node_modules/html5-qrcode/src/state-manager.d.ts b/src/main/node_modules/html5-qrcode/src/state-manager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c740bbd882ab2dd15280713d5d0866cbdf2b9d8 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/state-manager.d.ts @@ -0,0 +1,29 @@ +export declare enum Html5QrcodeScannerState { + UNKNOWN = 0, + NOT_STARTED = 1, + SCANNING = 2, + PAUSED = 3 +} +export interface StateManagerTransaction { + execute(): void; + cancel(): void; +} +export interface StateManager { + startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction; + directTransition(newState: Html5QrcodeScannerState): void; + getState(): Html5QrcodeScannerState; +} +export declare class StateManagerProxy { + private stateManager; + constructor(stateManager: StateManager); + startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction; + directTransition(newState: Html5QrcodeScannerState): void; + getState(): Html5QrcodeScannerState; + canScanFile(): boolean; + isScanning(): boolean; + isStrictlyScanning(): boolean; + isPaused(): boolean; +} +export declare class StateManagerFactory { + static create(): StateManagerProxy; +} diff --git a/src/main/node_modules/html5-qrcode/src/state-manager.ts b/src/main/node_modules/html5-qrcode/src/state-manager.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf9d71de7498d1ee1de77126301810232541a96f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/state-manager.ts @@ -0,0 +1,193 @@ +/** + * @fileoverview + * State handler. + * + * @author mebjas <minhazav@gmail.com> + */ + +/** Different states of scanner */ +export enum Html5QrcodeScannerState { + // Invalid internal state, do not set to this state. + UNKNOWN = 0, + // Indicates the scanning is not running or user is using file based + // scanning. + NOT_STARTED = 1, + // Camera scan is running. + SCANNING, + // Camera scan is paused but camera is running. + PAUSED, +} + +/** Transaction for state transition. */ +export interface StateManagerTransaction { + /** + * Executes the current transaction. + */ + execute(): void; + + /** + * Cancels the current transaction. + */ + cancel(): void; +} + +/** Manager class for states. */ +export interface StateManager { + /** + * Start a transition to a new state. No other transitions will be allowed + * till this one is executed. + * + * @param newState new state to transition to. + * + * @returns transaction of type {@interface StateManagerTransaction}. + * + * @throws error if the new state is not a valid transition from current + * state. + */ + startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction; + + /** + * Directly execute a transition. + * + * @param newState new state to transition to. + * + * @throws error if the new state is not a valid transition from current + * state. + */ + directTransition(newState: Html5QrcodeScannerState): void; + + /** + * Get current state. + */ + getState(): Html5QrcodeScannerState; +} + +/** + * Implementation of {@interface StateManager} and + * {@interface StateManagerTransaction}. + */ +class StateManagerImpl implements StateManager, StateManagerTransaction { + + private state: Html5QrcodeScannerState = Html5QrcodeScannerState.NOT_STARTED; + + private onGoingTransactionNewState: Html5QrcodeScannerState + = Html5QrcodeScannerState.UNKNOWN; + + public directTransition(newState: Html5QrcodeScannerState) { + this.failIfTransitionOngoing(); + this.validateTransition(newState); + this.state = newState; + } + + public startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction { + this.failIfTransitionOngoing(); + this.validateTransition(newState); + + this.onGoingTransactionNewState = newState; + return this; + } + + public execute() { + if (this.onGoingTransactionNewState + === Html5QrcodeScannerState.UNKNOWN) { + throw "Transaction is already cancelled, cannot execute()."; + } + + const tempNewState = this.onGoingTransactionNewState; + this.onGoingTransactionNewState = Html5QrcodeScannerState.UNKNOWN; + this.directTransition(tempNewState); + } + + public cancel() { + if (this.onGoingTransactionNewState + === Html5QrcodeScannerState.UNKNOWN) { + throw "Transaction is already cancelled, cannot cancel()."; + } + + this.onGoingTransactionNewState = Html5QrcodeScannerState.UNKNOWN; + } + + public getState(): Html5QrcodeScannerState { + return this.state; + } + + //#region private methods + private failIfTransitionOngoing() { + if (this.onGoingTransactionNewState + !== Html5QrcodeScannerState.UNKNOWN) { + throw "Cannot transition to a new state, already under transition"; + } + } + + private validateTransition(newState: Html5QrcodeScannerState) { + switch(this.state) { + case Html5QrcodeScannerState.UNKNOWN: + throw "Transition from unknown is not allowed"; + case Html5QrcodeScannerState.NOT_STARTED: + this.failIfNewStateIs(newState, [Html5QrcodeScannerState.PAUSED]); + break; + case Html5QrcodeScannerState.SCANNING: + // Both state transitions legal from here. + break; + case Html5QrcodeScannerState.PAUSED: + // Both state transitions legal from here. + break; + } + } + + private failIfNewStateIs( + newState: Html5QrcodeScannerState, + disallowedStatesToTransition: Array<Html5QrcodeScannerState>) { + for (const disallowedState of disallowedStatesToTransition) { + if (newState === disallowedState) { + throw `Cannot transition from ${this.state} to ${newState}`; + } + } + } + //#endregion +} + +export class StateManagerProxy { + private stateManager: StateManager; + + constructor(stateManager: StateManager) { + this.stateManager = stateManager; + } + + startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction { + return this.stateManager.startTransition(newState); + } + + directTransition(newState: Html5QrcodeScannerState) { + this.stateManager.directTransition(newState); + } + + getState(): Html5QrcodeScannerState { + return this.stateManager.getState(); + } + + canScanFile(): boolean { + return this.stateManager.getState() === Html5QrcodeScannerState.NOT_STARTED; + } + + isScanning(): boolean { + return this.stateManager.getState() !== Html5QrcodeScannerState.NOT_STARTED; + } + + isStrictlyScanning(): boolean { + return this.stateManager.getState() === Html5QrcodeScannerState.SCANNING; + } + + isPaused(): boolean { + return this.stateManager.getState() === Html5QrcodeScannerState.PAUSED; + } +} + +/** + * Factory for creating instance of {@class StateManagerProxy}. + */ + export class StateManagerFactory { + public static create(): StateManagerProxy { + return new StateManagerProxy(new StateManagerImpl()); + } +} diff --git a/src/main/node_modules/html5-qrcode/src/storage.d.ts b/src/main/node_modules/html5-qrcode/src/storage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cae73a316feba6585b2cb887ab0a8d664ba1eb11 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/storage.d.ts @@ -0,0 +1,12 @@ +export declare class PersistedDataManager { + private data; + private static LOCAL_STORAGE_KEY; + constructor(); + hasCameraPermissions(): boolean; + getLastUsedCameraId(): string | null; + setHasPermission(hasPermission: boolean): void; + setLastUsedCameraId(lastUsedCameraId: string): void; + resetLastUsedCameraId(): void; + reset(): void; + private flush; +} diff --git a/src/main/node_modules/html5-qrcode/src/storage.ts b/src/main/node_modules/html5-qrcode/src/storage.ts new file mode 100644 index 0000000000000000000000000000000000000000..409cef9014dcdafcc72bc8eb68af7cb173c25e9f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/storage.ts @@ -0,0 +1,72 @@ +/** + * @fileoverview + * Core storage related APIs. + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +interface PersistedData { + hasPermission: boolean; + lastUsedCameraId: string | null; +} + +class PersistedDataFactory { + static createDefault(): PersistedData { + return { + hasPermission: false, + lastUsedCameraId: null + }; + } +} + +export class PersistedDataManager { + + private data: PersistedData = PersistedDataFactory.createDefault(); + private static LOCAL_STORAGE_KEY: string = "HTML5_QRCODE_DATA"; + + constructor() { + let data = localStorage.getItem(PersistedDataManager.LOCAL_STORAGE_KEY); + if (!data) { + this.reset(); + } else { + this.data = JSON.parse(data); + } + } + + public hasCameraPermissions(): boolean { + return this.data.hasPermission; + } + + public getLastUsedCameraId(): string | null { + return this.data.lastUsedCameraId; + } + + public setHasPermission(hasPermission: boolean) { + this.data.hasPermission = hasPermission; + this.flush(); + } + + public setLastUsedCameraId(lastUsedCameraId: string) { + this.data.lastUsedCameraId = lastUsedCameraId; + this.flush(); + } + + public resetLastUsedCameraId() { + this.data.lastUsedCameraId = null; + this.flush(); + } + + public reset() { + this.data = PersistedDataFactory.createDefault(); + this.flush(); + } + + private flush(): void { + localStorage.setItem( + PersistedDataManager.LOCAL_STORAGE_KEY, + JSON.stringify(this.data)); + } +} diff --git a/src/main/node_modules/html5-qrcode/src/strings.d.ts b/src/main/node_modules/html5-qrcode/src/strings.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb99f90013e8dc8c8fb988e3383678cdd993b99e --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/strings.d.ts @@ -0,0 +1,45 @@ +export declare class Html5QrcodeStrings { + static codeParseError(exception: any): string; + static errorGettingUserMedia(error: any): string; + static onlyDeviceSupportedError(): string; + static cameraStreamingNotSupported(): string; + static unableToQuerySupportedDevices(): string; + static insecureContextCameraQueryError(): string; + static scannerPaused(): string; +} +export declare class Html5QrcodeScannerStrings { + static scanningStatus(): string; + static idleStatus(): string; + static errorStatus(): string; + static permissionStatus(): string; + static noCameraFoundErrorStatus(): string; + static lastMatch(decodedText: string): string; + static codeScannerTitle(): string; + static cameraPermissionTitle(): string; + static cameraPermissionRequesting(): string; + static noCameraFound(): string; + static scanButtonStopScanningText(): string; + static scanButtonStartScanningText(): string; + static torchOnButton(): string; + static torchOffButton(): string; + static torchOnFailedMessage(): string; + static torchOffFailedMessage(): string; + static scanButtonScanningStarting(): string; + static textIfCameraScanSelected(): string; + static textIfFileScanSelected(): string; + static selectCamera(): string; + static fileSelectionChooseImage(): string; + static fileSelectionChooseAnother(): string; + static fileSelectionNoImageSelected(): string; + static anonymousCameraPrefix(): string; + static dragAndDropMessage(): string; + static dragAndDropMessageOnlyImages(): string; + static zoom(): string; + static loadingImage(): string; + static cameraScanAltText(): string; + static fileScanAltText(): string; +} +export declare class LibraryInfoStrings { + static poweredBy(): string; + static reportIssues(): string; +} diff --git a/src/main/node_modules/html5-qrcode/src/strings.ts b/src/main/node_modules/html5-qrcode/src/strings.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f701c1e0fc47504faa8f5b95a5f160d3efbf0f6 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/strings.ts @@ -0,0 +1,200 @@ +/** + * @fileoverview + * Strings used by {@class Html5Qrcode} & {@class Html5QrcodeScanner} + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +/** + * Strings used in {@class Html5Qrcode}. + * + * TODO(mebjas): Support internalization. + */ +export class Html5QrcodeStrings { + + public static codeParseError(exception: any): string { + return `QR code parse error, error = ${exception}`; + } + + public static errorGettingUserMedia(error: any): string { + return `Error getting userMedia, error = ${error}`; + } + + public static onlyDeviceSupportedError(): string { + return "The device doesn't support navigator.mediaDevices , only " + + "supported cameraIdOrConfig in this case is deviceId parameter " + + "(string)."; + } + + public static cameraStreamingNotSupported(): string { + return "Camera streaming not supported by the browser."; + } + + public static unableToQuerySupportedDevices(): string { + return "Unable to query supported devices, unknown error."; + } + + public static insecureContextCameraQueryError(): string { + return "Camera access is only supported in secure context like https " + + "or localhost."; + } + + public static scannerPaused(): string { + return "Scanner paused"; + } +} + +/** + * Strings used in {@class Html5QrcodeScanner}. + * + * TODO(mebjas): Support internalization. + */ +export class Html5QrcodeScannerStrings { + + public static scanningStatus(): string { + return "Scanning"; + } + + public static idleStatus(): string { + return "Idle"; + } + + public static errorStatus(): string { + return "Error"; + } + + public static permissionStatus(): string { + return "Permission"; + } + + public static noCameraFoundErrorStatus(): string { + return "No Cameras"; + } + + public static lastMatch(decodedText: string): string { + return `Last Match: ${decodedText}`; + } + + public static codeScannerTitle(): string { + return "Code Scanner"; + } + + public static cameraPermissionTitle(): string { + return "Request Camera Permissions"; + } + + public static cameraPermissionRequesting(): string { + return "Requesting camera permissions..."; + } + + public static noCameraFound(): string { + return "No camera found"; + } + + public static scanButtonStopScanningText(): string { + return "Stop Scanning"; + } + + public static scanButtonStartScanningText(): string { + return "Start Scanning"; + } + + public static torchOnButton(): string { + return "Switch On Torch"; + } + + public static torchOffButton(): string { + return "Switch Off Torch"; + } + + public static torchOnFailedMessage(): string { + return "Failed to turn on torch"; + } + + public static torchOffFailedMessage(): string { + return "Failed to turn off torch"; + } + + public static scanButtonScanningStarting(): string { + return "Launching Camera..."; + } + + /** + * Text to show when camera scan is selected. + * + * This will be used to switch to file based scanning. + */ + public static textIfCameraScanSelected(): string { + return "Scan an Image File"; + } + + /** + * Text to show when file based scan is selected. + * + * This will be used to switch to camera based scanning. + */ + public static textIfFileScanSelected(): string { + return "Scan using camera directly"; + } + + public static selectCamera(): string { + return "Select Camera"; + } + + public static fileSelectionChooseImage(): string { + return "Choose Image"; + } + + public static fileSelectionChooseAnother(): string { + return "Choose Another"; + } + + public static fileSelectionNoImageSelected(): string { + return "No image choosen"; + } + + /** Prefix to be given to anonymous cameras. */ + public static anonymousCameraPrefix(): string { + return "Anonymous Camera"; + } + + public static dragAndDropMessage(): string { + return "Or drop an image to scan"; + } + + public static dragAndDropMessageOnlyImages(): string { + return "Or drop an image to scan (other files not supported)"; + } + + /** Value for zoom. */ + public static zoom(): string { + return "zoom"; + } + + public static loadingImage(): string { + return "Loading image..."; + } + + public static cameraScanAltText(): string { + return "Camera based scan"; + } + + public static fileScanAltText(): string { + return "Fule based scan"; + } +} + +/** Strings used in {@class LibraryInfoDiv} */ +export class LibraryInfoStrings { + + public static poweredBy(): string { + return "Powered by "; + } + + public static reportIssues(): string { + return "Report issues"; + } +} diff --git a/src/main/node_modules/html5-qrcode/src/ui.d.ts b/src/main/node_modules/html5-qrcode/src/ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f03fe96416ae95a12a35935d8b5f61c5d36d433 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui.d.ts @@ -0,0 +1,6 @@ +export declare class LibraryInfoContainer { + private infoDiv; + private infoIcon; + constructor(); + renderInto(parent: HTMLElement): void; +} diff --git a/src/main/node_modules/html5-qrcode/src/ui.ts b/src/main/node_modules/html5-qrcode/src/ui.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee331d555b85f3cd4835ef36af357df38679303a --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui.ts @@ -0,0 +1,152 @@ +/** + * @fileoverview + * All structured UI classes. + * + * TODO(mebjas): Migrate all UI components to modular UI classes so they are + * easy to improve. + * TODO(mebjas): Add tests for all UI components. + * @author mebjas <minhazav@gmail.com> + */ + +import { ASSET_CLOSE_ICON_16PX, ASSET_INFO_ICON_16PX } from "./image-assets"; + +import { LibraryInfoStrings } from "./strings"; + +type OnClickListener0 = () => void; + +//#region Info Icon + Div + +class LibraryInfoDiv { + private infoDiv: HTMLDivElement; + + constructor() { + this.infoDiv = document.createElement("div"); + } + + public renderInto(parent: HTMLElement) { + this.infoDiv.style.position = "absolute"; + this.infoDiv.style.top = "10px"; + this.infoDiv.style.right = "10px"; + this.infoDiv.style.zIndex = "2"; + this.infoDiv.style.display = "none"; + this.infoDiv.style.padding = "5pt"; + this.infoDiv.style.border = "1px solid #171717"; + this.infoDiv.style.fontSize = "10pt"; + this.infoDiv.style.background = "rgb(0 0 0 / 69%)"; + this.infoDiv.style.borderRadius = "5px"; + this.infoDiv.style.textAlign = "center"; + this.infoDiv.style.fontWeight = "400"; + this.infoDiv.style.color = "white"; + + this.infoDiv.innerText = LibraryInfoStrings.poweredBy(); + const projectLink = document.createElement("a"); + projectLink.innerText = "ScanApp"; + projectLink.href = "https://scanapp.org"; + projectLink.target = "new"; + projectLink.style.color = "white"; + this.infoDiv.appendChild(projectLink); + + const breakElemFirst = document.createElement("br"); + const breakElemSecond = document.createElement("br"); + this.infoDiv.appendChild(breakElemFirst); + this.infoDiv.appendChild(breakElemSecond); + + const reportIssueLink = document.createElement("a"); + reportIssueLink.innerText = LibraryInfoStrings.reportIssues(); + reportIssueLink.href = "https://github.com/mebjas/html5-qrcode/issues"; + reportIssueLink.target = "new"; + reportIssueLink.style.color = "white"; + this.infoDiv.appendChild(reportIssueLink); + + parent.appendChild(this.infoDiv); + } + + public show() { + this.infoDiv.style.display = "block"; + } + + public hide() { + this.infoDiv.style.display = "none"; + } +} + +class LibraryInfoIcon { + + private infoIcon: HTMLImageElement; + private onTapIn: OnClickListener0; + private onTapOut: OnClickListener0; + private isShowingInfoIcon: boolean = true; + + constructor(onTapIn: OnClickListener0, onTapOut: OnClickListener0) { + this.onTapIn = onTapIn; + this.onTapOut = onTapOut; + + this.infoIcon = document.createElement("img"); + } + + public renderInto(parent: HTMLElement) { + this.infoIcon.alt = "Info icon"; + this.infoIcon.src = ASSET_INFO_ICON_16PX; + this.infoIcon.style.position = "absolute"; + this.infoIcon.style.top = "4px"; + this.infoIcon.style.right = "4px"; + this.infoIcon.style.opacity = "0.6"; + this.infoIcon.style.cursor = "pointer"; + this.infoIcon.style.zIndex = "2"; + this.infoIcon.style.width = "16px"; + this.infoIcon.style.height = "16px"; + + this.infoIcon.onmouseover = (_) => this.onHoverIn(); + this.infoIcon.onmouseout = (_) => this.onHoverOut(); + this.infoIcon.onclick = (_) => this.onClick(); + + parent.appendChild(this.infoIcon); + } + + private onHoverIn() { + if (this.isShowingInfoIcon) { + this.infoIcon.style.opacity = "1"; + } + } + + private onHoverOut() { + if (this.isShowingInfoIcon) { + this.infoIcon.style.opacity = "0.6"; + } + } + + private onClick() { + if (this.isShowingInfoIcon) { + this.isShowingInfoIcon = false; + this.onTapIn(); + this.infoIcon.src = ASSET_CLOSE_ICON_16PX; + this.infoIcon.style.opacity = "1"; + } else { + this.isShowingInfoIcon = true; + this.onTapOut(); + this.infoIcon.src = ASSET_INFO_ICON_16PX; + this.infoIcon.style.opacity = "0.6"; + } + } +} + +export class LibraryInfoContainer { + + private infoDiv: LibraryInfoDiv; + private infoIcon: LibraryInfoIcon; + + constructor() { + this.infoDiv = new LibraryInfoDiv(); + this.infoIcon = new LibraryInfoIcon(() => { + this.infoDiv.show(); + }, () => { + this.infoDiv.hide(); + }); + } + + public renderInto(parent: HTMLElement) { + this.infoDiv.renderInto(parent); + this.infoIcon.renderInto(parent); + } +} +//#endregion diff --git a/src/main/node_modules/html5-qrcode/src/ui/scanner/base.d.ts b/src/main/node_modules/html5-qrcode/src/ui/scanner/base.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f6ba9cf120e4959471cfef863e282fbbbb9db22 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui/scanner/base.d.ts @@ -0,0 +1,16 @@ +export declare class PublicUiElementIdAndClasses { + static ALL_ELEMENT_CLASS: string; + static CAMERA_PERMISSION_BUTTON_ID: string; + static CAMERA_START_BUTTON_ID: string; + static CAMERA_STOP_BUTTON_ID: string; + static TORCH_BUTTON_ID: string; + static CAMERA_SELECTION_SELECT_ID: string; + static FILE_SELECTION_BUTTON_ID: string; + static ZOOM_SLIDER_ID: string; + static SCAN_TYPE_CHANGE_ANCHOR_ID: string; + static TORCH_BUTTON_CLASS_TORCH_ON: string; + static TORCH_BUTTON_CLASS_TORCH_OFF: string; +} +export declare class BaseUiElementFactory { + static createElement<Type extends HTMLElement>(elementType: string, elementId: string): Type; +} diff --git a/src/main/node_modules/html5-qrcode/src/ui/scanner/base.ts b/src/main/node_modules/html5-qrcode/src/ui/scanner/base.ts new file mode 100644 index 0000000000000000000000000000000000000000..0c328ca4c2818b7301ca3959f77366d1f61e8736 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui/scanner/base.ts @@ -0,0 +1,81 @@ +/** + * @fileoverview + * Contains base classes for different UI elements used in the scanner. + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +/** + * Id and classes of UI elements, for developers to configure the theme of + * end to end scanner using css. + */ +export class PublicUiElementIdAndClasses { + //#region Public list of element IDs for major UI elements. + + /** Class name added to all major UI elements used in scanner. */ + static ALL_ELEMENT_CLASS = "html5-qrcode-element"; + + /** Id of the camera permission button. */ + static CAMERA_PERMISSION_BUTTON_ID = "html5-qrcode-button-camera-permission"; + + /** Id of the camera start button. */ + static CAMERA_START_BUTTON_ID = "html5-qrcode-button-camera-start"; + + /** Id of the camera stop button. */ + static CAMERA_STOP_BUTTON_ID = "html5-qrcode-button-camera-stop"; + + /** Id of the torch button. */ + static TORCH_BUTTON_ID = "html5-qrcode-button-torch"; + + /** Id of the select element used for camera selection. */ + static CAMERA_SELECTION_SELECT_ID = "html5-qrcode-select-camera"; + + /** Id of the button used for file selection. */ + static FILE_SELECTION_BUTTON_ID = "html5-qrcode-button-file-selection"; + + /** Id of the range input for zoom. */ + static ZOOM_SLIDER_ID = "html5-qrcode-input-range-zoom"; + + /** + * Id of the anchor {@code <a>} element used for swapping between file scan + * and camera scan. + */ + static SCAN_TYPE_CHANGE_ANCHOR_ID = "html5-qrcode-anchor-scan-type-change"; + + //#endregion + + //#region List of classes for specific use-cases. + + /** Torch button class when torch is ON. */ + static TORCH_BUTTON_CLASS_TORCH_ON = "html5-qrcode-button-torch-on"; + + /** Torch button class when torch is OFF. */ + static TORCH_BUTTON_CLASS_TORCH_OFF = "html5-qrcode-button-torch-off"; + + //#endregion +} + +/** + * Factory class for creating different base UI elements used by the scanner. + */ +export class BaseUiElementFactory { + /** + * Creates {@link HTMLElement} of given {@param elementType}. + * + * @param elementType Type of element to create, example + */ + public static createElement<Type extends HTMLElement>( + elementType: string, elementId: string): Type { + + let element: Type = <Type>(document.createElement(elementType)); + element.id = elementId; + element.classList.add(PublicUiElementIdAndClasses.ALL_ELEMENT_CLASS); + if (elementType === "button") { + element.setAttribute("type", "button"); + } + return element; + } +} diff --git a/src/main/node_modules/html5-qrcode/src/ui/scanner/camera-selection-ui.d.ts b/src/main/node_modules/html5-qrcode/src/ui/scanner/camera-selection-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2090ed53de81e3fc2a4a3f33806eace194c983c9 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui/scanner/camera-selection-ui.d.ts @@ -0,0 +1,17 @@ +import { CameraDevice } from "../../camera/core"; +export declare class CameraSelectionUi { + private readonly selectElement; + private readonly options; + private readonly cameras; + private constructor(); + private render; + disable(): void; + isDisabled(): boolean; + enable(): void; + getValue(): string; + hasValue(value: string): boolean; + setValue(value: string): void; + hasSingleItem(): boolean; + numCameras(): number; + static create(parentElement: HTMLElement, cameras: Array<CameraDevice>): CameraSelectionUi; +} diff --git a/src/main/node_modules/html5-qrcode/src/ui/scanner/camera-selection-ui.ts b/src/main/node_modules/html5-qrcode/src/ui/scanner/camera-selection-ui.ts new file mode 100644 index 0000000000000000000000000000000000000000..cda2b9b62665cfcdfe6e13834d961c61b74faf86 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui/scanner/camera-selection-ui.ts @@ -0,0 +1,129 @@ +/** + * @fileoverview + * File for camera selection UI. + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +import { CameraDevice } from "../../camera/core"; +import { + BaseUiElementFactory, + PublicUiElementIdAndClasses +} from "./base"; +import { + Html5QrcodeScannerStrings +} from "../../strings"; + +/** Class for rendering and handling camera selection UI. */ +export class CameraSelectionUi { + + private readonly selectElement: HTMLSelectElement; + private readonly options: Array<HTMLOptionElement>; + private readonly cameras: Array<CameraDevice>; + + private constructor(cameras: Array<CameraDevice>) { + this.selectElement = BaseUiElementFactory + .createElement<HTMLSelectElement>( + "select", + PublicUiElementIdAndClasses.CAMERA_SELECTION_SELECT_ID); + this.cameras = cameras; + this.options = []; + } + + /*eslint complexity: ["error", 10]*/ + private render( + parentElement: HTMLElement) { + const cameraSelectionContainer = document.createElement("span"); + cameraSelectionContainer.style.marginRight = "10px"; + const numCameras = this.cameras.length; + if (numCameras === 0) { + throw new Error("No cameras found"); + } + if (numCameras === 1) { + // If only one camera is found, don't show camera selection. + cameraSelectionContainer.style.display = "none"; + } else { + // Otherwise, show the number of cameras found as well. + const selectCameraString = Html5QrcodeScannerStrings.selectCamera(); + cameraSelectionContainer.innerText + = `${selectCameraString} (${this.cameras.length}) `; + } + + let anonymousCameraId = 1; + + for (const camera of this.cameras) { + const value = camera.id; + let name = camera.label == null ? value : camera.label; + // If no name is returned by the browser, replace it with custom + // camera label with a count. + if (!name || name === "") { + name = [ + Html5QrcodeScannerStrings.anonymousCameraPrefix(), + anonymousCameraId++ + ].join(" "); + } + + const option = document.createElement("option"); + option.value = value; + option.innerText = name; + this.options.push(option); + this.selectElement.appendChild(option); + } + cameraSelectionContainer.appendChild(this.selectElement); + parentElement.appendChild(cameraSelectionContainer); + } + + //#region Public APIs + public disable() { + this.selectElement.disabled = true; + } + + public isDisabled() { + return this.selectElement.disabled === true; + } + + public enable() { + this.selectElement.disabled = false; + } + + public getValue(): string { + return this.selectElement.value; + } + + public hasValue(value: string): boolean { + for (const option of this.options) { + if (option.value === value) { + return true; + } + } + return false; + } + + public setValue(value: string) { + if (!this.hasValue(value)) { + throw new Error(`${value} is not present in the camera list.`); + } + this.selectElement.value = value; + } + + public hasSingleItem() { + return this.cameras.length === 1; + } + + public numCameras() { + return this.cameras.length; + } + //#endregion + + /** Creates instance of {@link CameraSelectionUi} and renders it. */ + public static create( + parentElement: HTMLElement, + cameras: Array<CameraDevice>): CameraSelectionUi { + let cameraSelectUi = new CameraSelectionUi(cameras); + cameraSelectUi.render(parentElement); + return cameraSelectUi; + } +} diff --git a/src/main/node_modules/html5-qrcode/src/ui/scanner/camera-zoom-ui.d.ts b/src/main/node_modules/html5-qrcode/src/ui/scanner/camera-zoom-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..215bb3f45a562941e18b27204250b45b021bc973 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui/scanner/camera-zoom-ui.d.ts @@ -0,0 +1,16 @@ +export type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; +export declare class CameraZoomUi { + private zoomElementContainer; + private rangeInput; + private rangeText; + private onChangeCallback; + private constructor(); + private render; + private onValueChange; + setValues(minValue: number, maxValue: number, defaultValue: number, step: number): void; + show(): void; + hide(): void; + setOnCameraZoomValueChangeCallback(onChangeCallback: OnCameraZoomValueChangeCallback): void; + removeOnCameraZoomValueChangeCallback(): void; + static create(parentElement: HTMLElement, renderOnCreate: boolean): CameraZoomUi; +} diff --git a/src/main/node_modules/html5-qrcode/src/ui/scanner/camera-zoom-ui.ts b/src/main/node_modules/html5-qrcode/src/ui/scanner/camera-zoom-ui.ts new file mode 100644 index 0000000000000000000000000000000000000000..c49eecc29cb73d59c061540f0cd9dbe93eef2386 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui/scanner/camera-zoom-ui.ts @@ -0,0 +1,126 @@ +/** + * @fileoverview + * File for camera zooming UI. + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + + import { + BaseUiElementFactory, + PublicUiElementIdAndClasses +} from "./base"; + +import { Html5QrcodeScannerStrings } from "../../strings"; + +/** Callback when zoom value changes with the slider UI. */ +export type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; + +/** Class for creating and managing zoom slider UI. */ +export class CameraZoomUi { + + private zoomElementContainer: HTMLDivElement; + private rangeInput: HTMLInputElement; + private rangeText: HTMLSpanElement; + + private onChangeCallback: OnCameraZoomValueChangeCallback | null = null; + + private constructor() { + this.zoomElementContainer = document.createElement("div"); + this.rangeInput = BaseUiElementFactory.createElement<HTMLInputElement>( + "input", PublicUiElementIdAndClasses.ZOOM_SLIDER_ID); + this.rangeInput.type = "range"; + + this.rangeText = document.createElement("span"); + + // default values. + this.rangeInput.min = "1"; + this.rangeInput.max = "5"; + this.rangeInput.value = "1"; + this.rangeInput.step = "0.1"; + } + + private render( + parentElement: HTMLElement, + renderOnCreate: boolean) { + // Style for the range slider. + this.zoomElementContainer.style.display + = renderOnCreate ? "block" : "none"; + this.zoomElementContainer.style.padding = "5px 10px"; + this.zoomElementContainer.style.textAlign = "center"; + parentElement.appendChild(this.zoomElementContainer); + + this.rangeInput.style.display = "inline-block"; + this.rangeInput.style.width = "50%"; + this.rangeInput.style.height = "5px"; + this.rangeInput.style.background = "#d3d3d3"; + this.rangeInput.style.outline = "none"; + this.rangeInput.style.opacity = "0.7"; + + let zoomString = Html5QrcodeScannerStrings.zoom(); + this.rangeText.innerText = `${this.rangeInput.value}x ${zoomString}`; + this.rangeText.style.marginRight = "10px"; + + // Bind values. + let $this = this; + this.rangeInput.addEventListener("input", () => $this.onValueChange()); + this.rangeInput.addEventListener("change", () => $this.onValueChange()); + + this.zoomElementContainer.appendChild(this.rangeInput); + this.zoomElementContainer.appendChild(this.rangeText); + } + + private onValueChange() { + let zoomString = Html5QrcodeScannerStrings.zoom(); + this.rangeText.innerText = `${this.rangeInput.value}x ${zoomString}`; + if (this.onChangeCallback) { + this.onChangeCallback(parseFloat(this.rangeInput.value)); + } + } + + //#region Public APIs + public setValues( + minValue: number, + maxValue: number, + defaultValue: number, + step: number) { + this.rangeInput.min = minValue.toString(); + this.rangeInput.max = maxValue.toString(); + this.rangeInput.step = step.toString(); + this.rangeInput.value = defaultValue.toString(); + + this.onValueChange(); + } + + public show() { + this.zoomElementContainer.style.display = "block"; + } + + public hide() { + this.zoomElementContainer.style.display = "none"; + } + + public setOnCameraZoomValueChangeCallback( + onChangeCallback: OnCameraZoomValueChangeCallback) { + this.onChangeCallback = onChangeCallback; + } + + public removeOnCameraZoomValueChangeCallback() { + this.onChangeCallback = null; + } + //#endregion + + /** + * Creates and renders the zoom slider if {@code renderOnCreate} is + * {@code true}. + */ + public static create( + parentElement: HTMLElement, + renderOnCreate: boolean): CameraZoomUi { + let cameraZoomUi = new CameraZoomUi(); + cameraZoomUi.render(parentElement, renderOnCreate); + return cameraZoomUi; + } +} diff --git a/src/main/node_modules/html5-qrcode/src/ui/scanner/file-selection-ui.d.ts b/src/main/node_modules/html5-qrcode/src/ui/scanner/file-selection-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..768f5ed8d5b9cd84994a11bca20a02224c665a75 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui/scanner/file-selection-ui.d.ts @@ -0,0 +1,19 @@ +export type OnFileSelected = (file: File) => void; +export declare class FileSelectionUi { + private readonly fileBasedScanRegion; + private readonly fileScanInput; + private readonly fileSelectionButton; + private constructor(); + hide(): void; + show(): void; + isShowing(): boolean; + resetValue(): void; + private createFileBasedScanRegion; + private fileBasedScanRegionDefaultBorder; + private fileBasedScanRegionActiveBorder; + private createDragAndDropMessage; + private setImageNameToButton; + private setInitialValueToButton; + private getFileScanInputId; + static create(parentElement: HTMLDivElement, showOnRender: boolean, onFileSelected: OnFileSelected): FileSelectionUi; +} diff --git a/src/main/node_modules/html5-qrcode/src/ui/scanner/file-selection-ui.ts b/src/main/node_modules/html5-qrcode/src/ui/scanner/file-selection-ui.ts new file mode 100644 index 0000000000000000000000000000000000000000..ebf68f7247badf4c0a208627b3fa9bc31ad90c9d --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui/scanner/file-selection-ui.ts @@ -0,0 +1,263 @@ +/** + * @fileoverview + * File for file selection UI handling. + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +import {Html5QrcodeScannerStrings} from "../../strings"; +import { + BaseUiElementFactory, + PublicUiElementIdAndClasses +} from "./base"; + +/** + * Interface for callback when a file is selected by user using the button. + */ +export type OnFileSelected = (file: File) => void; + +/** UI class for file selection handling. */ +export class FileSelectionUi { + + private readonly fileBasedScanRegion: HTMLDivElement; + private readonly fileScanInput: HTMLInputElement; + private readonly fileSelectionButton: HTMLButtonElement; + + /** Creates object and renders. */ + private constructor( + parentElement: HTMLDivElement, + showOnRender: boolean, + onFileSelected: OnFileSelected) { + this.fileBasedScanRegion = this.createFileBasedScanRegion(); + this.fileBasedScanRegion.style.display + = showOnRender ? "block" : "none"; + parentElement.appendChild(this.fileBasedScanRegion); + + let fileScanLabel = document.createElement("label"); + fileScanLabel.setAttribute("for", this.getFileScanInputId()); + fileScanLabel.style.display = "inline-block"; + + this.fileBasedScanRegion.appendChild(fileScanLabel); + + this.fileSelectionButton + = BaseUiElementFactory.createElement<HTMLButtonElement>( + "button", + PublicUiElementIdAndClasses.FILE_SELECTION_BUTTON_ID); + this.setInitialValueToButton(); + + // Bind click events with the label element. + this.fileSelectionButton.addEventListener("click", (_) => { + fileScanLabel.click(); + }); + fileScanLabel.append(this.fileSelectionButton); + + this.fileScanInput + = BaseUiElementFactory.createElement<HTMLInputElement>( + "input", this.getFileScanInputId()); + this.fileScanInput.type = "file"; + this.fileScanInput.accept = "image/*"; + this.fileScanInput.style.display = "none"; + fileScanLabel.appendChild(this.fileScanInput); + + let $this = this; + /*eslint complexity: ["error", 5]*/ + this.fileScanInput.addEventListener("change", (e: Event) => { + if (e == null || e.target == null) { + return; + } + let target: HTMLInputElement = e.target as HTMLInputElement; + if (target.files && target.files.length === 0) { + return; + } + let fileList: FileList = target.files!; + const file: File = fileList[0]; + let fileName = file.name; + $this.setImageNameToButton(fileName); + + onFileSelected(file); + }); + + // Render drag and drop label + let dragAndDropMessage = this.createDragAndDropMessage(); + this.fileBasedScanRegion.appendChild(dragAndDropMessage); + + this.fileBasedScanRegion.addEventListener("dragenter", function(event) { + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionActiveBorder(); + + event.stopPropagation(); + event.preventDefault(); + }); + + this.fileBasedScanRegion.addEventListener("dragleave", function(event) { + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionDefaultBorder(); + + event.stopPropagation(); + event.preventDefault(); + }); + + this.fileBasedScanRegion.addEventListener("dragover", function(event) { + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionActiveBorder(); + + event.stopPropagation(); + event.preventDefault(); + }); + + /*eslint complexity: ["error", 10]*/ + this.fileBasedScanRegion.addEventListener("drop", function(event) { + event.stopPropagation(); + event.preventDefault(); + + $this.fileBasedScanRegion.style.border + = $this.fileBasedScanRegionDefaultBorder(); + + var dataTransfer = event.dataTransfer; + if (dataTransfer) { + let files = dataTransfer.files; + if (!files || files.length === 0) { + return; + } + let isAnyFileImage = false; + for (let i = 0; i < files.length; ++i) { + let file = files.item(i); + if (!file) { + continue; + } + let imageType = /image.*/; + + // Only process images. + if (!file.type.match(imageType)) { + continue; + } + + isAnyFileImage = true; + let fileName = file.name; + $this.setImageNameToButton(fileName); + + onFileSelected(file); + dragAndDropMessage.innerText + = Html5QrcodeScannerStrings.dragAndDropMessage(); + break; + } + + // None of the files were images. + if (!isAnyFileImage) { + dragAndDropMessage.innerText + = Html5QrcodeScannerStrings + .dragAndDropMessageOnlyImages(); + } + } + + }); + } + + //#region Public APIs. + /** Hide the file selection UI. */ + public hide() { + this.fileBasedScanRegion.style.display = "none"; + this.fileScanInput.disabled = true; + } + + /** Show the file selection UI. */ + public show() { + this.fileBasedScanRegion.style.display = "block"; + this.fileScanInput.disabled = false; + } + + /** Returns {@code true} if UI container is displayed. */ + public isShowing(): boolean { + return this.fileBasedScanRegion.style.display === "block"; + } + + /** Reset the file selection value */ + public resetValue() { + this.fileScanInput.value = ""; + this.setInitialValueToButton(); + } + //#endregion + + //#region private APIs + private createFileBasedScanRegion(): HTMLDivElement { + let fileBasedScanRegion = document.createElement("div"); + fileBasedScanRegion.style.textAlign = "center"; + fileBasedScanRegion.style.margin = "auto"; + fileBasedScanRegion.style.width = "80%"; + fileBasedScanRegion.style.maxWidth = "600px"; + fileBasedScanRegion.style.border + = this.fileBasedScanRegionDefaultBorder(); + fileBasedScanRegion.style.padding = "10px"; + fileBasedScanRegion.style.marginBottom = "10px"; + return fileBasedScanRegion; + } + + private fileBasedScanRegionDefaultBorder() { + return "6px dashed #ebebeb"; + } + + /** Border when a file is being dragged over the file scan region. */ + private fileBasedScanRegionActiveBorder() { + return "6px dashed rgb(153 151 151)"; + } + + private createDragAndDropMessage(): HTMLDivElement { + let dragAndDropMessage = document.createElement("div"); + dragAndDropMessage.innerText + = Html5QrcodeScannerStrings.dragAndDropMessage(); + dragAndDropMessage.style.fontWeight = "400"; + return dragAndDropMessage; + } + + private setImageNameToButton(imageFileName: string) { + const MAX_CHARS = 20; + if (imageFileName.length > MAX_CHARS) { + // Strip first 8 + // Strip last 8 + // Add 4 dots + let start8Chars = imageFileName.substring(0, 8); + let length = imageFileName.length; + let last8Chars = imageFileName.substring(length - 8, length); + imageFileName = `${start8Chars}....${last8Chars}`; + } + + let newText = Html5QrcodeScannerStrings.fileSelectionChooseAnother() + + " - " + + imageFileName; + this.fileSelectionButton.innerText = newText; + } + + private setInitialValueToButton() { + let initialText = Html5QrcodeScannerStrings.fileSelectionChooseImage() + + " - " + + Html5QrcodeScannerStrings.fileSelectionNoImageSelected(); + this.fileSelectionButton.innerText = initialText; + } + + private getFileScanInputId(): string { + return "html5-qrcode-private-filescan-input"; + } + //#endregion + + /** + * Creates a file selection UI and renders. + * + * @param parentElement parent div element to render the UI to. + * @param showOnRender if {@code true}, the UI will be shown upon render + * else hidden. + * @param onFileSelected callback to be called when file selection changes. + * + * @returns Instance of {@code FileSelectionUi}. + */ + public static create( + parentElement: HTMLDivElement, + showOnRender: boolean, + onFileSelected: OnFileSelected): FileSelectionUi { + let button = new FileSelectionUi( + parentElement, showOnRender, onFileSelected); + return button; + } +} diff --git a/src/main/node_modules/html5-qrcode/src/ui/scanner/scan-type-selector.d.ts b/src/main/node_modules/html5-qrcode/src/ui/scanner/scan-type-selector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f0e1347449e85244139b7cf48cd52b2fca300cb --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui/scanner/scan-type-selector.d.ts @@ -0,0 +1,11 @@ +import { Html5QrcodeScanType } from "../../core"; +export declare class ScanTypeSelector { + private supportedScanTypes; + constructor(supportedScanTypes?: Array<Html5QrcodeScanType> | []); + getDefaultScanType(): Html5QrcodeScanType; + hasMoreThanOneScanType(): boolean; + isCameraScanRequired(): boolean; + static isCameraScanType(scanType: Html5QrcodeScanType): boolean; + static isFileScanType(scanType: Html5QrcodeScanType): boolean; + private validateAndReturnScanTypes; +} diff --git a/src/main/node_modules/html5-qrcode/src/ui/scanner/scan-type-selector.ts b/src/main/node_modules/html5-qrcode/src/ui/scanner/scan-type-selector.ts new file mode 100644 index 0000000000000000000000000000000000000000..d822e1607e3066354591fcbfb818fb04629e23ca --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui/scanner/scan-type-selector.ts @@ -0,0 +1,94 @@ +/** + * @fileoverview + * Util class to help with scan type selection in scanner class. + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +import { + Html5QrcodeScanType, + Html5QrcodeConstants +} from "../../core"; + +/** Util class to help with scan type selection in scanner class. */ +export class ScanTypeSelector { + private supportedScanTypes: Array<Html5QrcodeScanType>; + + constructor(supportedScanTypes?: Array<Html5QrcodeScanType> | []) { + this.supportedScanTypes = this.validateAndReturnScanTypes( + supportedScanTypes); + } + + /** + * Returns the default {@link Html5QrcodeScanType} scanner UI should be + * created with. + */ + public getDefaultScanType(): Html5QrcodeScanType { + return this.supportedScanTypes[0]; + } + + /** + * Returns {@code true} if more than one {@link Html5QrcodeScanType} are + * set. + */ + public hasMoreThanOneScanType(): boolean { + return this.supportedScanTypes.length > 1; + } + + /** Returns {@code true} if camera scan is required at all. */ + public isCameraScanRequired(): boolean { + for (const scanType of this.supportedScanTypes) { + if (ScanTypeSelector.isCameraScanType(scanType)) { + return true; + } + } + return false; + } + + /** Returns {@code true} is {@code scanType} is camera based. */ + public static isCameraScanType(scanType: Html5QrcodeScanType): boolean { + return scanType === Html5QrcodeScanType.SCAN_TYPE_CAMERA; + } + + /** Returns {@code true} is {@code scanType} is file based. */ + public static isFileScanType(scanType: Html5QrcodeScanType): boolean { + return scanType === Html5QrcodeScanType.SCAN_TYPE_FILE; + } + + //#region Private methods. + /** + * Validates the input {@code supportedScanTypes}. + * + * Fails early if the config values is incorrectly set. + */ + private validateAndReturnScanTypes( + supportedScanTypes?:Array<Html5QrcodeScanType>): + Array<Html5QrcodeScanType> { + // If not set, use the default values and order. + if (!supportedScanTypes || supportedScanTypes.length === 0) { + return Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE; + } + + // Fail if more than expected number of values exist. + let maxExpectedValues + = Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE.length; + if (supportedScanTypes.length > maxExpectedValues) { + throw `Max ${maxExpectedValues} values expected for ` + + "supportedScanTypes"; + } + + // Fail if any of the scan types are not supported. + for (const scanType of supportedScanTypes) { + if (!Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE + .includes(scanType)) { + throw `Unsupported scan type ${scanType}`; + } + } + + return supportedScanTypes; + } + //#endregion +} diff --git a/src/main/node_modules/html5-qrcode/src/ui/scanner/torch-button.d.ts b/src/main/node_modules/html5-qrcode/src/ui/scanner/torch-button.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a862a10bae47503e7ee4e8875da199ff90538d6f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui/scanner/torch-button.d.ts @@ -0,0 +1,28 @@ +import { BooleanCameraCapability } from "../../camera/core"; +export type OnTorchActionFailureCallback = (failureMessage: string) => void; +interface TorchButtonController { + disable(): void; + enable(): void; + setText(text: string): void; +} +export interface TorchButtonOptions { + display: string; + marginLeft: string; +} +export declare class TorchButton implements TorchButtonController { + private readonly torchButton; + private readonly onTorchActionFailureCallback; + private torchController; + private constructor(); + private render; + updateTorchCapability(torchCapability: BooleanCameraCapability): void; + getTorchButton(): HTMLButtonElement; + hide(): void; + show(): void; + disable(): void; + enable(): void; + setText(text: string): void; + reset(): void; + static create(parentElement: HTMLElement, torchCapability: BooleanCameraCapability, torchButtonOptions: TorchButtonOptions, onTorchActionFailureCallback: OnTorchActionFailureCallback): TorchButton; +} +export {}; diff --git a/src/main/node_modules/html5-qrcode/src/ui/scanner/torch-button.ts b/src/main/node_modules/html5-qrcode/src/ui/scanner/torch-button.ts new file mode 100644 index 0000000000000000000000000000000000000000..f39cbe7ea98107edc6639909ca4d63fbafb359a3 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/ui/scanner/torch-button.ts @@ -0,0 +1,227 @@ +/** + * @fileoverview + * File for torch related UI components and handling. + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +import { BooleanCameraCapability } from "../../camera/core"; +import { Html5QrcodeScannerStrings } from "../../strings"; +import { + BaseUiElementFactory, + PublicUiElementIdAndClasses +} from "./base"; + +/** + * Interface for callback that will be called in case of torch action failures. + */ +export type OnTorchActionFailureCallback = (failureMessage: string) => void; + +/** Interface for controlling torch button. */ +interface TorchButtonController { + disable(): void; + enable(): void; + setText(text: string): void; +} + +/** Controller class for handling torch / flash. */ +class TorchController { + private readonly torchCapability: BooleanCameraCapability; + private readonly buttonController: TorchButtonController; + private readonly onTorchActionFailureCallback: OnTorchActionFailureCallback; + + // Mutable states. + private isTorchOn: boolean = false; + + constructor( + torchCapability: BooleanCameraCapability, + buttonController: TorchButtonController, + onTorchActionFailureCallback: OnTorchActionFailureCallback) { + this.torchCapability = torchCapability; + this.buttonController = buttonController; + this.onTorchActionFailureCallback = onTorchActionFailureCallback; + } + + /** Returns {@code true} if torch is enabled. */ + public isTorchEnabled(): boolean { + return this.isTorchOn; + } + + /** + * Flips the state of the torch. + * + * <p> Turns torch On if current state is Off and vice-versa. + * <p> Modifies the UI state accordingly. + * + * @returns Promise that finishes when the async action is done. + */ + public async flipState(): Promise<void> { + this.buttonController.disable(); + let isTorchOnExpected = !this.isTorchOn; + try { + await this.torchCapability.apply(isTorchOnExpected); + this.updateUiBasedOnLatestSettings( + this.torchCapability.value()!, isTorchOnExpected); + } catch (error) { + this.propagateFailure(isTorchOnExpected, error); + this.buttonController.enable(); + } + } + + private updateUiBasedOnLatestSettings( + isTorchOn: boolean, + isTorchOnExpected: boolean) { + if (isTorchOn === isTorchOnExpected) { + // Action succeeded, flip the state. + this.buttonController.setText(isTorchOnExpected + ? Html5QrcodeScannerStrings.torchOffButton() + : Html5QrcodeScannerStrings.torchOnButton()); + this.isTorchOn = isTorchOnExpected; + } else { + // Torch didn't get set as expected. + // Show warning. + this.propagateFailure(isTorchOnExpected); + } + this.buttonController.enable(); + } + + private propagateFailure( + isTorchOnExpected: boolean, error?: any) { + let errorMessage = isTorchOnExpected + ? Html5QrcodeScannerStrings.torchOnFailedMessage() + : Html5QrcodeScannerStrings.torchOffFailedMessage(); + if (error) { + errorMessage += "; Error = " + error; + } + this.onTorchActionFailureCallback(errorMessage); + } + + /** + * Resets the state. + * + * <p>Note: Doesn't turn off the torch implicitly. + */ + public reset() { + this.isTorchOn = false; + } +} + +/** Options for creating torch button. */ +export interface TorchButtonOptions { + display: string; + marginLeft: string; +} + +/** Helper class for creating Torch UI component. */ +export class TorchButton implements TorchButtonController { + private readonly torchButton: HTMLButtonElement; + private readonly onTorchActionFailureCallback: OnTorchActionFailureCallback; + + private torchController: TorchController; + + private constructor( + torchCapability: BooleanCameraCapability, + onTorchActionFailureCallback: OnTorchActionFailureCallback) { + this.onTorchActionFailureCallback = onTorchActionFailureCallback; + this.torchButton + = BaseUiElementFactory.createElement<HTMLButtonElement>( + "button", PublicUiElementIdAndClasses.TORCH_BUTTON_ID); + + this.torchController = new TorchController( + torchCapability, + /* buttonController= */ this, + onTorchActionFailureCallback); + } + + private render( + parentElement: HTMLElement, torchButtonOptions: TorchButtonOptions) { + this.torchButton.innerText + = Html5QrcodeScannerStrings.torchOnButton(); + this.torchButton.style.display = torchButtonOptions.display; + this.torchButton.style.marginLeft = torchButtonOptions.marginLeft; + + let $this = this; + this.torchButton.addEventListener("click", async (_) => { + await $this.torchController.flipState(); + if ($this.torchController.isTorchEnabled()) { + $this.torchButton.classList.remove( + PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF); + $this.torchButton.classList.add( + PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON); + } else { + $this.torchButton.classList.remove( + PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON); + $this.torchButton.classList.add( + PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF); + } + }); + + parentElement.appendChild(this.torchButton); + } + + public updateTorchCapability(torchCapability: BooleanCameraCapability) { + this.torchController = new TorchController( + torchCapability, + /* buttonController= */ this, + this.onTorchActionFailureCallback); + } + + /** Returns the torch button. */ + public getTorchButton(): HTMLButtonElement { + return this.torchButton; + } + + public hide() { + this.torchButton.style.display = "none"; + } + + public show() { + this.torchButton.style.display = "inline-block"; + } + + disable(): void { + this.torchButton.disabled = true; + } + + enable(): void { + this.torchButton.disabled = false; + } + + setText(text: string): void { + this.torchButton.innerText = text; + } + + /** + * Resets the state. + * + * <p>Note: Doesn't turn off the torch implicitly. + */ + public reset() { + this.torchButton.innerText = Html5QrcodeScannerStrings.torchOnButton(); + this.torchController.reset(); + } + + /** + * Factory method for creating torch button. + * + * @param parentElement parent HTML element to render torch button into + * @param torchCapability torch capability of the camera + * @param torchButtonOptions options for creating torch + * @param onTorchActionFailureCallback callback to be called in case of + * torch action failure. + */ + public static create( + parentElement: HTMLElement, + torchCapability: BooleanCameraCapability, + torchButtonOptions: TorchButtonOptions, + onTorchActionFailureCallback: OnTorchActionFailureCallback) + : TorchButton { + let button = new TorchButton( + torchCapability, onTorchActionFailureCallback); + button.render(parentElement, torchButtonOptions); + return button; + } +} diff --git a/src/main/node_modules/html5-qrcode/src/utils.d.ts b/src/main/node_modules/html5-qrcode/src/utils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b060ed9e1f751f6c8a3592683ce5726bf6d3e20 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/utils.d.ts @@ -0,0 +1,4 @@ +import { Logger } from "./core"; +export declare class VideoConstraintsUtil { + static isMediaStreamConstraintsValid(videoConstraints: MediaTrackConstraints, logger: Logger): boolean; +} diff --git a/src/main/node_modules/html5-qrcode/src/utils.ts b/src/main/node_modules/html5-qrcode/src/utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..a0e81f52717aee0586166479b49fffd90b80e3f2 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/utils.ts @@ -0,0 +1,53 @@ +/** + * @fileoverview + * Utils used by {@class Html5Qrcode} & {@class Html5QrcodeScanner} + * + * @author mebjas <minhazav@gmail.com> + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +import { Logger } from "./core"; + +/** + * Utils around {@interface MediaTrackConstraints} for video. + */ +export class VideoConstraintsUtil { + public static isMediaStreamConstraintsValid( + videoConstraints: MediaTrackConstraints, + logger: Logger): boolean { + if (typeof videoConstraints !== "object") { + const typeofVideoConstraints = typeof videoConstraints; + logger.logError( + "videoConstraints should be of type object, the " + + `object passed is of type ${typeofVideoConstraints}.`, + /* experimental= */ true); + return false; + } + // TODO(mebjas): Make this validity check more sophisticuated + // Following keys are audio controls, audio controls are not supported. + const bannedKeys = [ + "autoGainControl", + "channelCount", + "echoCancellation", + "latency", + "noiseSuppression", + "sampleRate", + "sampleSize", + "volume" + ]; + const bannedkeysSet = new Set(bannedKeys); + const keysInVideoConstraints = Object.keys(videoConstraints); + for (const key of keysInVideoConstraints) { + if (bannedkeysSet.has(key)) { + logger.logError( + `${key} is not supported videoConstaints.`, + /* experimental= */ true); + return false; + } + } + + return true; + } +} diff --git a/src/main/node_modules/html5-qrcode/src/zxing-html5-qrcode-decoder.d.ts b/src/main/node_modules/html5-qrcode/src/zxing-html5-qrcode-decoder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..411d37712f3a62354959625cbe40dce24d67f1cc --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/zxing-html5-qrcode-decoder.d.ts @@ -0,0 +1,15 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, Logger, QrcodeDecoderAsync } from "./core"; +export declare class ZXingHtml5QrcodeDecoder implements QrcodeDecoderAsync { + private readonly formatMap; + private readonly reverseFormatMap; + private hints; + private verbose; + private logger; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private decode; + private createReverseFormatMap; + private toHtml5QrcodeSupportedFormats; + private createZXingFormats; + private createDebugData; +} diff --git a/src/main/node_modules/html5-qrcode/src/zxing-html5-qrcode-decoder.ts b/src/main/node_modules/html5-qrcode/src/zxing-html5-qrcode-decoder.ts new file mode 100644 index 0000000000000000000000000000000000000000..a021d5dbf9d490464efcdb4eb66bd89af6a204e0 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/src/zxing-html5-qrcode-decoder.ts @@ -0,0 +1,155 @@ +/** + * @fileoverview + * {@interface QrcodeDecoder} wrapper around ZXing library. + * + * @author mebjas <minhazav@gmail.com> + * + * ZXing library forked from https://github.com/zxing-js/library. + * + * The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED + * http://www.denso-wave.com/qrcode/faqpatent-e.html + */ + +import * as ZXing from "../third_party/zxing-js.umd"; + +import { + QrcodeResult, + QrcodeResultDebugData, + QrcodeResultFormat, + Html5QrcodeSupportedFormats, + Logger, + QrcodeDecoderAsync +} from "./core"; + +/** + * ZXing based Code decoder. + */ +export class ZXingHtml5QrcodeDecoder implements QrcodeDecoderAsync { + + private readonly formatMap: Map<Html5QrcodeSupportedFormats, any> + = new Map([ + [Html5QrcodeSupportedFormats.QR_CODE, ZXing.BarcodeFormat.QR_CODE ], + [Html5QrcodeSupportedFormats.AZTEC, ZXing.BarcodeFormat.AZTEC ], + [Html5QrcodeSupportedFormats.CODABAR, ZXing.BarcodeFormat.CODABAR ], + [Html5QrcodeSupportedFormats.CODE_39, ZXing.BarcodeFormat.CODE_39 ], + [Html5QrcodeSupportedFormats.CODE_93, ZXing.BarcodeFormat.CODE_93 ], + [ + Html5QrcodeSupportedFormats.CODE_128, + ZXing.BarcodeFormat.CODE_128 ], + [ + Html5QrcodeSupportedFormats.DATA_MATRIX, + ZXing.BarcodeFormat.DATA_MATRIX ], + [ + Html5QrcodeSupportedFormats.MAXICODE, + ZXing.BarcodeFormat.MAXICODE ], + [Html5QrcodeSupportedFormats.ITF, ZXing.BarcodeFormat.ITF ], + [Html5QrcodeSupportedFormats.EAN_13, ZXing.BarcodeFormat.EAN_13 ], + [Html5QrcodeSupportedFormats.EAN_8, ZXing.BarcodeFormat.EAN_8 ], + [Html5QrcodeSupportedFormats.PDF_417, ZXing.BarcodeFormat.PDF_417 ], + [Html5QrcodeSupportedFormats.RSS_14, ZXing.BarcodeFormat.RSS_14 ], + [ + Html5QrcodeSupportedFormats.RSS_EXPANDED, + ZXing.BarcodeFormat.RSS_EXPANDED ], + [Html5QrcodeSupportedFormats.UPC_A, ZXing.BarcodeFormat.UPC_A ], + [Html5QrcodeSupportedFormats.UPC_E, ZXing.BarcodeFormat.UPC_E ], + [ + Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION, + ZXing.BarcodeFormat.UPC_EAN_EXTENSION ] + ]); + private readonly reverseFormatMap: Map<any, Html5QrcodeSupportedFormats> + = this.createReverseFormatMap(); + + private hints: Map<any, any>; + private verbose: boolean; + private logger: Logger; + + public constructor( + requestedFormats: Array<Html5QrcodeSupportedFormats>, + verbose: boolean, + logger: Logger) { + if (!ZXing) { + throw "Use html5qrcode.min.js without edit, ZXing not found."; + } + this.verbose = verbose; + this.logger = logger; + + const formats = this.createZXingFormats(requestedFormats); + const hints = new Map(); + hints.set(ZXing.DecodeHintType.POSSIBLE_FORMATS, formats); + // TODO(minhazav): Make this configurable by developers. + hints.set(ZXing.DecodeHintType.TRY_HARDER, false); + this.hints = hints; + } + + + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult> { + return new Promise((resolve, reject) => { + try { + resolve(this.decode(canvas)); + } catch (error) { + reject(error); + } + }); + } + + private decode(canvas: HTMLCanvasElement): QrcodeResult { + // Note: Earlier we used to instantiate the zxingDecoder once as state + // of this class and use it for each scans. There seems to be some + // stateful bug in ZXing library around RSS_14 likely due to + // https://github.com/zxing-js/library/issues/211. + // Recreating a new instance per scan doesn't lead to performance issues + // and temporarily mitigates this issue. + // TODO(mebjas): Properly fix this issue in ZXing library. + const zxingDecoder = new ZXing.MultiFormatReader( + this.verbose, this.hints); + const luminanceSource + = new ZXing.HTMLCanvasElementLuminanceSource(canvas); + const binaryBitmap + = new ZXing.BinaryBitmap( + new ZXing.HybridBinarizer(luminanceSource)); + let result = zxingDecoder.decode(binaryBitmap); + return { + text: result.text, + format: QrcodeResultFormat.create( + this.toHtml5QrcodeSupportedFormats(result.format)), + debugData: this.createDebugData() + }; + } + + private createReverseFormatMap(): Map<any, Html5QrcodeSupportedFormats> { + let result = new Map(); + this.formatMap.forEach( + (value: any, key: Html5QrcodeSupportedFormats, _) => { + result.set(value, key); + }); + return result; + } + + private toHtml5QrcodeSupportedFormats(zxingFormat: any) + : Html5QrcodeSupportedFormats { + if (!this.reverseFormatMap.has(zxingFormat)) { + throw `reverseFormatMap doesn't have ${zxingFormat}`; + } + return this.reverseFormatMap.get(zxingFormat)!; + } + + private createZXingFormats( + requestedFormats: Array<Html5QrcodeSupportedFormats>): + Array<any> { + let zxingFormats = []; + for (const requestedFormat of requestedFormats) { + if (this.formatMap.has(requestedFormat)) { + zxingFormats.push( + this.formatMap.get(requestedFormat)); + } else { + this.logger.logError(`${requestedFormat} is not supported by` + + "ZXingHtml5QrcodeShim"); + } + } + return zxingFormats; + } + + private createDebugData(): QrcodeResultDebugData { + return { decoderName: "zxing-js" }; + } +} diff --git a/src/main/node_modules/html5-qrcode/state-manager.d.ts b/src/main/node_modules/html5-qrcode/state-manager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c740bbd882ab2dd15280713d5d0866cbdf2b9d8 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/state-manager.d.ts @@ -0,0 +1,29 @@ +export declare enum Html5QrcodeScannerState { + UNKNOWN = 0, + NOT_STARTED = 1, + SCANNING = 2, + PAUSED = 3 +} +export interface StateManagerTransaction { + execute(): void; + cancel(): void; +} +export interface StateManager { + startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction; + directTransition(newState: Html5QrcodeScannerState): void; + getState(): Html5QrcodeScannerState; +} +export declare class StateManagerProxy { + private stateManager; + constructor(stateManager: StateManager); + startTransition(newState: Html5QrcodeScannerState): StateManagerTransaction; + directTransition(newState: Html5QrcodeScannerState): void; + getState(): Html5QrcodeScannerState; + canScanFile(): boolean; + isScanning(): boolean; + isStrictlyScanning(): boolean; + isPaused(): boolean; +} +export declare class StateManagerFactory { + static create(): StateManagerProxy; +} diff --git a/src/main/node_modules/html5-qrcode/storage.d.ts b/src/main/node_modules/html5-qrcode/storage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cae73a316feba6585b2cb887ab0a8d664ba1eb11 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/storage.d.ts @@ -0,0 +1,12 @@ +export declare class PersistedDataManager { + private data; + private static LOCAL_STORAGE_KEY; + constructor(); + hasCameraPermissions(): boolean; + getLastUsedCameraId(): string | null; + setHasPermission(hasPermission: boolean): void; + setLastUsedCameraId(lastUsedCameraId: string): void; + resetLastUsedCameraId(): void; + reset(): void; + private flush; +} diff --git a/src/main/node_modules/html5-qrcode/strings.d.ts b/src/main/node_modules/html5-qrcode/strings.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb99f90013e8dc8c8fb988e3383678cdd993b99e --- /dev/null +++ b/src/main/node_modules/html5-qrcode/strings.d.ts @@ -0,0 +1,45 @@ +export declare class Html5QrcodeStrings { + static codeParseError(exception: any): string; + static errorGettingUserMedia(error: any): string; + static onlyDeviceSupportedError(): string; + static cameraStreamingNotSupported(): string; + static unableToQuerySupportedDevices(): string; + static insecureContextCameraQueryError(): string; + static scannerPaused(): string; +} +export declare class Html5QrcodeScannerStrings { + static scanningStatus(): string; + static idleStatus(): string; + static errorStatus(): string; + static permissionStatus(): string; + static noCameraFoundErrorStatus(): string; + static lastMatch(decodedText: string): string; + static codeScannerTitle(): string; + static cameraPermissionTitle(): string; + static cameraPermissionRequesting(): string; + static noCameraFound(): string; + static scanButtonStopScanningText(): string; + static scanButtonStartScanningText(): string; + static torchOnButton(): string; + static torchOffButton(): string; + static torchOnFailedMessage(): string; + static torchOffFailedMessage(): string; + static scanButtonScanningStarting(): string; + static textIfCameraScanSelected(): string; + static textIfFileScanSelected(): string; + static selectCamera(): string; + static fileSelectionChooseImage(): string; + static fileSelectionChooseAnother(): string; + static fileSelectionNoImageSelected(): string; + static anonymousCameraPrefix(): string; + static dragAndDropMessage(): string; + static dragAndDropMessageOnlyImages(): string; + static zoom(): string; + static loadingImage(): string; + static cameraScanAltText(): string; + static fileScanAltText(): string; +} +export declare class LibraryInfoStrings { + static poweredBy(): string; + static reportIssues(): string; +} diff --git a/src/main/node_modules/html5-qrcode/third_party/zxing-js.umd.d.ts b/src/main/node_modules/html5-qrcode/third_party/zxing-js.umd.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..63520f7c131e8c46031a64b989e4d4378bc9ee36 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/third_party/zxing-js.umd.d.ts @@ -0,0 +1,43 @@ +import * as ZXing from "./zxing-js.umd"; + +declare class HTMLCanvasElementLuminanceSource { + constructor(canvas: HTMLCanvasElement); +} + +declare class HybridBinarizer { + constructor(luminanceSource: HTMLCanvasElementLuminanceSource); +} + +declare class BinaryBitmap { + constructor(binarizer: HybridBinarizer); +} + +declare class MultiFormatReader { + constructor(verbosity: boolean, b: any); + decode(binaryBitmap: BinaryBitmap): any; +} + +export declare enum DecodeHintType { + POSSIBLE_FORMATS = 2, + TRY_HARDER = 3 +} + +export declare enum BarcodeFormat { + AZTEC = 0, + CODABAR = 1, + CODE_39 = 2, + CODE_93 = 3, + CODE_128 = 4, + DATA_MATRIX = 5, + EAN_8 = 6, + EAN_13 = 7, + ITF = 8, + MAXICODE = 9, + PDF_417 = 10, + QR_CODE = 11, + RSS_14 = 12, + RSS_EXPANDED = 13, + UPC_A = 14, + UPC_E = 15, + UPC_EAN_EXTENSION = 16 +} diff --git a/src/main/node_modules/html5-qrcode/third_party/zxing-js.umd.js b/src/main/node_modules/html5-qrcode/third_party/zxing-js.umd.js new file mode 100644 index 0000000000000000000000000000000000000000..6cb3d6f46e7fa5651cfc5eaca2650ce717d31f23 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/third_party/zxing-js.umd.js @@ -0,0 +1,23870 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ZXing = {})); +}(this, (function (exports) { 'use strict'; + + function isNullOrUndefined(obj) { + return obj === null || obj === undefined; + } + + /* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /* global Reflect, Promise */ + + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + + function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + + function fixProto(target, prototype) { + var setPrototypeOf = Object.setPrototypeOf; + setPrototypeOf ? setPrototypeOf(target, prototype) : (target.__proto__ = prototype); + } + + function fixStack(target, fn) { + if (fn === void 0) { + fn = target.constructor; + } + var captureStackTrace = Error.captureStackTrace; + captureStackTrace && captureStackTrace(target, fn); + } + + var CustomError = (function (_super) { + __extends(CustomError, _super); + function CustomError(message) { + var _newTarget = this.constructor; + var _this = _super.call(this, message) || this; + Object.defineProperty(_this, 'name', { + value: _newTarget.name, + enumerable: false + }); + fixProto(_this, _newTarget.prototype); + fixStack(_this); + return _this; + } + + return CustomError; + })(Error); + + /** + * Custom Error class of type Exception. + */ + class Exception extends CustomError { + /** + * Allows Exception to be constructed directly + * with some message and prototype definition. + */ + constructor(message = undefined) { + super(message); + this.message = message; + } + getKind() { + const ex = this.constructor; + return ex.kind; + } + } + /** + * It's typed as string so it can be extended and overriden. + */ + Exception.kind = 'Exception'; + + /** + * Custom Error class of type Exception. + */ + class ArgumentException extends Exception { + } + ArgumentException.kind = 'ArgumentException'; + + /** + * Custom Error class of type Exception. + */ + class IllegalArgumentException extends Exception { + } + IllegalArgumentException.kind = 'IllegalArgumentException'; + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + class BinaryBitmap { + constructor(binarizer) { + this.binarizer = binarizer; + if (binarizer === null) { + throw new IllegalArgumentException('Binarizer must be non-null.'); + } + } + /** + * @return The width of the bitmap. + */ + getWidth() { + return this.binarizer.getWidth(); + } + /** + * @return The height of the bitmap. + */ + getHeight() { + return this.binarizer.getHeight(); + } + /** + * Converts one row of luminance data to 1 bit data. May actually do the conversion, or return + * cached data. Callers should assume this method is expensive and call it as seldom as possible. + * This method is intended for decoding 1D barcodes and may choose to apply sharpening. + * + * @param y The row to fetch, which must be in [0, bitmap height) + * @param row An optional preallocated array. If null or too small, it will be ignored. + * If used, the Binarizer will call BitArray.clear(). Always use the returned object. + * @return The array of bits for this row (true means black). + * @throws NotFoundException if row can't be binarized + */ + getBlackRow(y /*int*/, row) { + return this.binarizer.getBlackRow(y, row); + } + /** + * Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive + * and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or + * may not apply sharpening. Therefore, a row from this matrix may not be identical to one + * fetched using getBlackRow(), so don't mix and match between them. + * + * @return The 2D array of bits for the image (true means black). + * @throws NotFoundException if image can't be binarized to make a matrix + */ + getBlackMatrix() { + // The matrix is created on demand the first time it is requested, then cached. There are two + // reasons for this: + // 1. This work will never be done if the caller only installs 1D Reader objects, or if a + // 1D Reader finds a barcode before the 2D Readers run. + // 2. This work will only be done once even if the caller installs multiple 2D Readers. + if (this.matrix === null || this.matrix === undefined) { + this.matrix = this.binarizer.getBlackMatrix(); + } + return this.matrix; + } + /** + * @return Whether this bitmap can be cropped. + */ + isCropSupported() { + return this.binarizer.getLuminanceSource().isCropSupported(); + } + /** + * Returns a new object with cropped image data. Implementations may keep a reference to the + * original data rather than a copy. Only callable if isCropSupported() is true. + * + * @param left The left coordinate, which must be in [0,getWidth()) + * @param top The top coordinate, which must be in [0,getHeight()) + * @param width The width of the rectangle to crop. + * @param height The height of the rectangle to crop. + * @return A cropped version of this object. + */ + crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) { + const newSource = this.binarizer.getLuminanceSource().crop(left, top, width, height); + return new BinaryBitmap(this.binarizer.createBinarizer(newSource)); + } + /** + * @return Whether this bitmap supports counter-clockwise rotation. + */ + isRotateSupported() { + return this.binarizer.getLuminanceSource().isRotateSupported(); + } + /** + * Returns a new object with rotated image data by 90 degrees counterclockwise. + * Only callable if {@link #isRotateSupported()} is true. + * + * @return A rotated version of this object. + */ + rotateCounterClockwise() { + const newSource = this.binarizer.getLuminanceSource().rotateCounterClockwise(); + return new BinaryBitmap(this.binarizer.createBinarizer(newSource)); + } + /** + * Returns a new object with rotated image data by 45 degrees counterclockwise. + * Only callable if {@link #isRotateSupported()} is true. + * + * @return A rotated version of this object. + */ + rotateCounterClockwise45() { + const newSource = this.binarizer.getLuminanceSource().rotateCounterClockwise45(); + return new BinaryBitmap(this.binarizer.createBinarizer(newSource)); + } + /*@Override*/ + toString() { + try { + return this.getBlackMatrix().toString(); + } + catch (e /*: NotFoundException*/) { + return ''; + } + } + } + + /** + * Custom Error class of type Exception. + */ + class ChecksumException extends Exception { + static getChecksumInstance() { + return new ChecksumException(); + } + } + ChecksumException.kind = 'ChecksumException'; + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * This class hierarchy provides a set of methods to convert luminance data to 1 bit data. + * It allows the algorithm to vary polymorphically, for example allowing a very expensive + * thresholding technique for servers and a fast one for mobile. It also permits the implementation + * to vary, e.g. a JNI version for Android and a Java fallback version for other platforms. + * + * @author dswitkin@google.com (Daniel Switkin) + */ + class Binarizer { + constructor(source) { + this.source = source; + } + getLuminanceSource() { + return this.source; + } + getWidth() { + return this.source.getWidth(); + } + getHeight() { + return this.source.getHeight(); + } + } + + class System { + // public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length) + /** + * Makes a copy of a array. + */ + static arraycopy(src, srcPos, dest, destPos, length) { + // TODO: better use split or set? + while (length--) { + dest[destPos++] = src[srcPos++]; + } + } + /** + * Returns the current time in milliseconds. + */ + static currentTimeMillis() { + return Date.now(); + } + } + + /** + * Custom Error class of type Exception. + */ + class IndexOutOfBoundsException extends Exception { + } + IndexOutOfBoundsException.kind = 'IndexOutOfBoundsException'; + + /** + * Custom Error class of type Exception. + */ + class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException { + constructor(index = undefined, message = undefined) { + super(message); + this.index = index; + this.message = message; + } + } + ArrayIndexOutOfBoundsException.kind = 'ArrayIndexOutOfBoundsException'; + + class Arrays { + /** + * Assigns the specified int value to each element of the specified array + * of ints. + * + * @param a the array to be filled + * @param val the value to be stored in all elements of the array + */ + static fill(a, val) { + for (let i = 0, len = a.length; i < len; i++) + a[i] = val; + } + /** + * Assigns the specified int value to each element of the specified + * range of the specified array of ints. The range to be filled + * extends from index {@code fromIndex}, inclusive, to index + * {@code toIndex}, exclusive. (If {@code fromIndex==toIndex}, the + * range to be filled is empty.) + * + * @param a the array to be filled + * @param fromIndex the index of the first element (inclusive) to be + * filled with the specified value + * @param toIndex the index of the last element (exclusive) to be + * filled with the specified value + * @param val the value to be stored in all elements of the array + * @throws IllegalArgumentException if {@code fromIndex > toIndex} + * @throws ArrayIndexOutOfBoundsException if {@code fromIndex < 0} or + * {@code toIndex > a.length} + */ + static fillWithin(a, fromIndex, toIndex, val) { + Arrays.rangeCheck(a.length, fromIndex, toIndex); + for (let i = fromIndex; i < toIndex; i++) + a[i] = val; + } + /** + * Checks that {@code fromIndex} and {@code toIndex} are in + * the range and throws an exception if they aren't. + */ + static rangeCheck(arrayLength, fromIndex, toIndex) { + if (fromIndex > toIndex) { + throw new IllegalArgumentException('fromIndex(' + fromIndex + ') > toIndex(' + toIndex + ')'); + } + if (fromIndex < 0) { + throw new ArrayIndexOutOfBoundsException(fromIndex); + } + if (toIndex > arrayLength) { + throw new ArrayIndexOutOfBoundsException(toIndex); + } + } + static asList(...args) { + return args; + } + static create(rows, cols, value) { + let arr = Array.from({ length: rows }); + return arr.map(x => Array.from({ length: cols }).fill(value)); + } + static createInt32Array(rows, cols, value) { + let arr = Array.from({ length: rows }); + return arr.map(x => Int32Array.from({ length: cols }).fill(value)); + } + static equals(first, second) { + if (!first) { + return false; + } + if (!second) { + return false; + } + if (!first.length) { + return false; + } + if (!second.length) { + return false; + } + if (first.length !== second.length) { + return false; + } + for (let i = 0, length = first.length; i < length; i++) { + if (first[i] !== second[i]) { + return false; + } + } + return true; + } + static hashCode(a) { + if (a === null) { + return 0; + } + let result = 1; + for (const element of a) { + result = 31 * result + element; + } + return result; + } + static fillUint8Array(a, value) { + for (let i = 0; i !== a.length; i++) { + a[i] = value; + } + } + static copyOf(original, newLength) { + return original.slice(0, newLength); + } + static copyOfUint8Array(original, newLength) { + if (original.length <= newLength) { + const newArray = new Uint8Array(newLength); + newArray.set(original); + return newArray; + } + return original.slice(0, newLength); + } + static copyOfRange(original, from, to) { + const newLength = to - from; + const copy = new Int32Array(newLength); + System.arraycopy(original, from, copy, 0, newLength); + return copy; + } + /* + * Returns the index of of the element in a sorted array or (-n-1) where n is the insertion point + * for the new element. + * Parameters: + * ar - A sorted array + * el - An element to search for + * comparator - A comparator function. The function takes two arguments: (a, b) and returns: + * a negative number if a is less than b; + * 0 if a is equal to b; + * a positive number of a is greater than b. + * The array may contain duplicate elements. If there are more than one equal elements in the array, + * the returned value can be the index of any one of the equal elements. + * + * http://jsfiddle.net/aryzhov/pkfst550/ + */ + static binarySearch(ar, el, comparator) { + if (undefined === comparator) { + comparator = Arrays.numberComparator; + } + let m = 0; + let n = ar.length - 1; + while (m <= n) { + const k = (n + m) >> 1; + const cmp = comparator(el, ar[k]); + if (cmp > 0) { + m = k + 1; + } + else if (cmp < 0) { + n = k - 1; + } + else { + return k; + } + } + return -m - 1; + } + static numberComparator(a, b) { + return a - b; + } + } + + /** + * Ponyfill for Java's Integer class. + */ + class Integer { + static numberOfTrailingZeros(i) { + let y; + if (i === 0) + return 32; + let n = 31; + y = i << 16; + if (y !== 0) { + n -= 16; + i = y; + } + y = i << 8; + if (y !== 0) { + n -= 8; + i = y; + } + y = i << 4; + if (y !== 0) { + n -= 4; + i = y; + } + y = i << 2; + if (y !== 0) { + n -= 2; + i = y; + } + return n - ((i << 1) >>> 31); + } + static numberOfLeadingZeros(i) { + // HD, Figure 5-6 + if (i === 0) { + return 32; + } + let n = 1; + if (i >>> 16 === 0) { + n += 16; + i <<= 16; + } + if (i >>> 24 === 0) { + n += 8; + i <<= 8; + } + if (i >>> 28 === 0) { + n += 4; + i <<= 4; + } + if (i >>> 30 === 0) { + n += 2; + i <<= 2; + } + n -= i >>> 31; + return n; + } + static toHexString(i) { + return i.toString(16); + } + static toBinaryString(intNumber) { + return String(parseInt(String(intNumber), 2)); + } + // Returns the number of one-bits in the two's complement binary representation of the specified int value. This function is sometimes referred to as the population count. + // Returns: + // the number of one-bits in the two's complement binary representation of the specified int value. + static bitCount(i) { + // HD, Figure 5-2 + i = i - ((i >>> 1) & 0x55555555); + i = (i & 0x33333333) + ((i >>> 2) & 0x33333333); + i = (i + (i >>> 4)) & 0x0f0f0f0f; + i = i + (i >>> 8); + i = i + (i >>> 16); + return i & 0x3f; + } + static truncDivision(dividend, divisor) { + return Math.trunc(dividend / divisor); + } + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal. + */ + static parseInt(num, radix = undefined) { + return parseInt(num, radix); + } + } + Integer.MIN_VALUE_32_BITS = -2147483648; + Integer.MAX_VALUE = Number.MAX_SAFE_INTEGER; + + /** + * <p>A simple, fast array of bits, represented compactly by an array of ints internally.</p> + * + * @author Sean Owen + */ + class BitArray /*implements Cloneable*/ { + // For testing only + constructor(size /*int*/, bits) { + if (undefined === size) { + this.size = 0; + this.bits = new Int32Array(1); + } + else { + this.size = size; + if (undefined === bits || null === bits) { + this.bits = BitArray.makeArray(size); + } + else { + this.bits = bits; + } + } + } + getSize() { + return this.size; + } + getSizeInBytes() { + return Math.floor((this.size + 7) / 8); + } + ensureCapacity(size /*int*/) { + if (size > this.bits.length * 32) { + const newBits = BitArray.makeArray(size); + System.arraycopy(this.bits, 0, newBits, 0, this.bits.length); + this.bits = newBits; + } + } + /** + * @param i bit to get + * @return true iff bit i is set + */ + get(i /*int*/) { + return (this.bits[Math.floor(i / 32)] & (1 << (i & 0x1F))) !== 0; + } + /** + * Sets bit i. + * + * @param i bit to set + */ + set(i /*int*/) { + this.bits[Math.floor(i / 32)] |= 1 << (i & 0x1F); + } + /** + * Flips bit i. + * + * @param i bit to set + */ + flip(i /*int*/) { + this.bits[Math.floor(i / 32)] ^= 1 << (i & 0x1F); + } + /** + * @param from first bit to check + * @return index of first bit that is set, starting from the given index, or size if none are set + * at or beyond this given index + * @see #getNextUnset(int) + */ + getNextSet(from /*int*/) { + const size = this.size; + if (from >= size) { + return size; + } + const bits = this.bits; + let bitsOffset = Math.floor(from / 32); + let currentBits = bits[bitsOffset]; + // mask off lesser bits first + currentBits &= ~((1 << (from & 0x1F)) - 1); + const length = bits.length; + while (currentBits === 0) { + if (++bitsOffset === length) { + return size; + } + currentBits = bits[bitsOffset]; + } + const result = (bitsOffset * 32) + Integer.numberOfTrailingZeros(currentBits); + return result > size ? size : result; + } + /** + * @param from index to start looking for unset bit + * @return index of next unset bit, or {@code size} if none are unset until the end + * @see #getNextSet(int) + */ + getNextUnset(from /*int*/) { + const size = this.size; + if (from >= size) { + return size; + } + const bits = this.bits; + let bitsOffset = Math.floor(from / 32); + let currentBits = ~bits[bitsOffset]; + // mask off lesser bits first + currentBits &= ~((1 << (from & 0x1F)) - 1); + const length = bits.length; + while (currentBits === 0) { + if (++bitsOffset === length) { + return size; + } + currentBits = ~bits[bitsOffset]; + } + const result = (bitsOffset * 32) + Integer.numberOfTrailingZeros(currentBits); + return result > size ? size : result; + } + /** + * Sets a block of 32 bits, starting at bit i. + * + * @param i first bit to set + * @param newBits the new value of the next 32 bits. Note again that the least-significant bit + * corresponds to bit i, the next-least-significant to i+1, and so on. + */ + setBulk(i /*int*/, newBits /*int*/) { + this.bits[Math.floor(i / 32)] = newBits; + } + /** + * Sets a range of bits. + * + * @param start start of range, inclusive. + * @param end end of range, exclusive + */ + setRange(start /*int*/, end /*int*/) { + if (end < start || start < 0 || end > this.size) { + throw new IllegalArgumentException(); + } + if (end === start) { + return; + } + end--; // will be easier to treat this as the last actually set bit -- inclusive + const firstInt = Math.floor(start / 32); + const lastInt = Math.floor(end / 32); + const bits = this.bits; + for (let i = firstInt; i <= lastInt; i++) { + const firstBit = i > firstInt ? 0 : start & 0x1F; + const lastBit = i < lastInt ? 31 : end & 0x1F; + // Ones from firstBit to lastBit, inclusive + const mask = (2 << lastBit) - (1 << firstBit); + bits[i] |= mask; + } + } + /** + * Clears all bits (sets to false). + */ + clear() { + const max = this.bits.length; + const bits = this.bits; + for (let i = 0; i < max; i++) { + bits[i] = 0; + } + } + /** + * Efficient method to check if a range of bits is set, or not set. + * + * @param start start of range, inclusive. + * @param end end of range, exclusive + * @param value if true, checks that bits in range are set, otherwise checks that they are not set + * + * @return true iff all bits are set or not set in range, according to value argument + * @throws IllegalArgumentException if end is less than start or the range is not contained in the array + */ + isRange(start /*int*/, end /*int*/, value) { + if (end < start || start < 0 || end > this.size) { + throw new IllegalArgumentException(); + } + if (end === start) { + return true; // empty range matches + } + end--; // will be easier to treat this as the last actually set bit -- inclusive + const firstInt = Math.floor(start / 32); + const lastInt = Math.floor(end / 32); + const bits = this.bits; + for (let i = firstInt; i <= lastInt; i++) { + const firstBit = i > firstInt ? 0 : start & 0x1F; + const lastBit = i < lastInt ? 31 : end & 0x1F; + // Ones from firstBit to lastBit, inclusive + const mask = (2 << lastBit) - (1 << firstBit) & 0xFFFFFFFF; + // TYPESCRIPTPORT: & 0xFFFFFFFF added to discard anything after 32 bits, as ES has 53 bits + // Return false if we're looking for 1s and the masked bits[i] isn't all 1s (is: that, + // equals the mask, or we're looking for 0s and the masked portion is not all 0s + if ((bits[i] & mask) !== (value ? mask : 0)) { + return false; + } + } + return true; + } + appendBit(bit) { + this.ensureCapacity(this.size + 1); + if (bit) { + this.bits[Math.floor(this.size / 32)] |= 1 << (this.size & 0x1F); + } + this.size++; + } + /** + * Appends the least-significant bits, from value, in order from most-significant to + * least-significant. For example, appending 6 bits from 0x000001E will append the bits + * 0, 1, 1, 1, 1, 0 in that order. + * + * @param value {@code int} containing bits to append + * @param numBits bits from value to append + */ + appendBits(value /*int*/, numBits /*int*/) { + if (numBits < 0 || numBits > 32) { + throw new IllegalArgumentException('Num bits must be between 0 and 32'); + } + this.ensureCapacity(this.size + numBits); + // const appendBit = this.appendBit; + for (let numBitsLeft = numBits; numBitsLeft > 0; numBitsLeft--) { + this.appendBit(((value >> (numBitsLeft - 1)) & 0x01) === 1); + } + } + appendBitArray(other) { + const otherSize = other.size; + this.ensureCapacity(this.size + otherSize); + // const appendBit = this.appendBit; + for (let i = 0; i < otherSize; i++) { + this.appendBit(other.get(i)); + } + } + xor(other) { + if (this.size !== other.size) { + throw new IllegalArgumentException('Sizes don\'t match'); + } + const bits = this.bits; + for (let i = 0, length = bits.length; i < length; i++) { + // The last int could be incomplete (i.e. not have 32 bits in + // it) but there is no problem since 0 XOR 0 == 0. + bits[i] ^= other.bits[i]; + } + } + /** + * + * @param bitOffset first bit to start writing + * @param array array to write into. Bytes are written most-significant byte first. This is the opposite + * of the internal representation, which is exposed by {@link #getBitArray()} + * @param offset position in array to start writing + * @param numBytes how many bytes to write + */ + toBytes(bitOffset /*int*/, array, offset /*int*/, numBytes /*int*/) { + for (let i = 0; i < numBytes; i++) { + let theByte = 0; + for (let j = 0; j < 8; j++) { + if (this.get(bitOffset)) { + theByte |= 1 << (7 - j); + } + bitOffset++; + } + array[offset + i] = /*(byte)*/ theByte; + } + } + /** + * @return underlying array of ints. The first element holds the first 32 bits, and the least + * significant bit is bit 0. + */ + getBitArray() { + return this.bits; + } + /** + * Reverses all bits in the array. + */ + reverse() { + const newBits = new Int32Array(this.bits.length); + // reverse all int's first + const len = Math.floor((this.size - 1) / 32); + const oldBitsLen = len + 1; + const bits = this.bits; + for (let i = 0; i < oldBitsLen; i++) { + let x = bits[i]; + x = ((x >> 1) & 0x55555555) | ((x & 0x55555555) << 1); + x = ((x >> 2) & 0x33333333) | ((x & 0x33333333) << 2); + x = ((x >> 4) & 0x0f0f0f0f) | ((x & 0x0f0f0f0f) << 4); + x = ((x >> 8) & 0x00ff00ff) | ((x & 0x00ff00ff) << 8); + x = ((x >> 16) & 0x0000ffff) | ((x & 0x0000ffff) << 16); + newBits[len - i] = /*(int)*/ x; + } + // now correct the int's if the bit size isn't a multiple of 32 + if (this.size !== oldBitsLen * 32) { + const leftOffset = oldBitsLen * 32 - this.size; + let currentInt = newBits[0] >>> leftOffset; + for (let i = 1; i < oldBitsLen; i++) { + const nextInt = newBits[i]; + currentInt |= nextInt << (32 - leftOffset); + newBits[i - 1] = currentInt; + currentInt = nextInt >>> leftOffset; + } + newBits[oldBitsLen - 1] = currentInt; + } + this.bits = newBits; + } + static makeArray(size /*int*/) { + return new Int32Array(Math.floor((size + 31) / 32)); + } + /*@Override*/ + equals(o) { + if (!(o instanceof BitArray)) { + return false; + } + const other = o; + return this.size === other.size && Arrays.equals(this.bits, other.bits); + } + /*@Override*/ + hashCode() { + return 31 * this.size + Arrays.hashCode(this.bits); + } + /*@Override*/ + toString() { + let result = ''; + for (let i = 0, size = this.size; i < size; i++) { + if ((i & 0x07) === 0) { + result += ' '; + } + result += this.get(i) ? 'X' : '.'; + } + return result; + } + /*@Override*/ + clone() { + return new BitArray(this.size, this.bits.slice()); + } + } + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*namespace com.google.zxing {*/ + /** + * Encapsulates a type of hint that a caller may pass to a barcode reader to help it + * more quickly or accurately decode it. It is up to implementations to decide what, + * if anything, to do with the information that is supplied. + * + * @author Sean Owen + * @author dswitkin@google.com (Daniel Switkin) + * @see Reader#decode(BinaryBitmap,java.util.Map) + */ + var DecodeHintType; + (function (DecodeHintType) { + /** + * Unspecified, application-specific hint. Maps to an unspecified {@link Object}. + */ + DecodeHintType[DecodeHintType["OTHER"] = 0] = "OTHER"; /*(Object.class)*/ + /** + * Image is a pure monochrome image of a barcode. Doesn't matter what it maps to; + * use {@link Boolean#TRUE}. + */ + DecodeHintType[DecodeHintType["PURE_BARCODE"] = 1] = "PURE_BARCODE"; /*(Void.class)*/ + /** + * Image is known to be of one of a few possible formats. + * Maps to a {@link List} of {@link BarcodeFormat}s. + */ + DecodeHintType[DecodeHintType["POSSIBLE_FORMATS"] = 2] = "POSSIBLE_FORMATS"; /*(List.class)*/ + /** + * Spend more time to try to find a barcode; optimize for accuracy, not speed. + * Doesn't matter what it maps to; use {@link Boolean#TRUE}. + */ + DecodeHintType[DecodeHintType["TRY_HARDER"] = 3] = "TRY_HARDER"; /*(Void.class)*/ + /** + * Specifies what character encoding to use when decoding, where applicable (type String) + */ + DecodeHintType[DecodeHintType["CHARACTER_SET"] = 4] = "CHARACTER_SET"; /*(String.class)*/ + /** + * Allowed lengths of encoded data -- reject anything else. Maps to an {@code Int32Array}. + */ + DecodeHintType[DecodeHintType["ALLOWED_LENGTHS"] = 5] = "ALLOWED_LENGTHS"; /*(Int32Array.class)*/ + /** + * Assume Code 39 codes employ a check digit. Doesn't matter what it maps to; + * use {@link Boolean#TRUE}. + */ + DecodeHintType[DecodeHintType["ASSUME_CODE_39_CHECK_DIGIT"] = 6] = "ASSUME_CODE_39_CHECK_DIGIT"; /*(Void.class)*/ + /** + * Assume the barcode is being processed as a GS1 barcode, and modify behavior as needed. + * For example this affects FNC1 handling for Code 128 (aka GS1-128). Doesn't matter what it maps to; + * use {@link Boolean#TRUE}. + */ + DecodeHintType[DecodeHintType["ASSUME_GS1"] = 7] = "ASSUME_GS1"; /*(Void.class)*/ + /** + * If true, return the start and end digits in a Codabar barcode instead of stripping them. They + * are alpha, whereas the rest are numeric. By default, they are stripped, but this causes them + * to not be. Doesn't matter what it maps to; use {@link Boolean#TRUE}. + */ + DecodeHintType[DecodeHintType["RETURN_CODABAR_START_END"] = 8] = "RETURN_CODABAR_START_END"; /*(Void.class)*/ + /** + * The caller needs to be notified via callback when a possible {@link ResultPoint} + * is found. Maps to a {@link ResultPointCallback}. + */ + DecodeHintType[DecodeHintType["NEED_RESULT_POINT_CALLBACK"] = 9] = "NEED_RESULT_POINT_CALLBACK"; /*(ResultPointCallback.class)*/ + /** + * Allowed extension lengths for EAN or UPC barcodes. Other formats will ignore this. + * Maps to an {@code Int32Array} of the allowed extension lengths, for example [2], [5], or [2, 5]. + * If it is optional to have an extension, do not set this hint. If this is set, + * and a UPC or EAN barcode is found but an extension is not, then no result will be returned + * at all. + */ + DecodeHintType[DecodeHintType["ALLOWED_EAN_EXTENSIONS"] = 10] = "ALLOWED_EAN_EXTENSIONS"; /*(Int32Array.class)*/ + // End of enumeration values. + /** + * Data type the hint is expecting. + * Among the possible values the {@link Void} stands out as being used for + * hints that do not expect a value to be supplied (flag hints). Such hints + * will possibly have their value ignored, or replaced by a + * {@link Boolean#TRUE}. Hint suppliers should probably use + * {@link Boolean#TRUE} as directed by the actual hint documentation. + */ + // private valueType: Class<?> + // DecodeHintType(valueType: Class<?>) { + // this.valueType = valueType + // } + // public getValueType(): Class<?> { + // return valueType + // } + })(DecodeHintType || (DecodeHintType = {})); + var DecodeHintType$1 = DecodeHintType; + + /** + * Custom Error class of type Exception. + */ + class FormatException extends Exception { + static getFormatInstance() { + return new FormatException(); + } + } + FormatException.kind = 'FormatException'; + + /*import java.util.HashMap;*/ + /*import java.util.Map;*/ + var CharacterSetValueIdentifiers; + (function (CharacterSetValueIdentifiers) { + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["Cp437"] = 0] = "Cp437"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_1"] = 1] = "ISO8859_1"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_2"] = 2] = "ISO8859_2"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_3"] = 3] = "ISO8859_3"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_4"] = 4] = "ISO8859_4"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_5"] = 5] = "ISO8859_5"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_6"] = 6] = "ISO8859_6"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_7"] = 7] = "ISO8859_7"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_8"] = 8] = "ISO8859_8"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_9"] = 9] = "ISO8859_9"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_10"] = 10] = "ISO8859_10"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_11"] = 11] = "ISO8859_11"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_13"] = 12] = "ISO8859_13"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_14"] = 13] = "ISO8859_14"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_15"] = 14] = "ISO8859_15"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ISO8859_16"] = 15] = "ISO8859_16"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["SJIS"] = 16] = "SJIS"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["Cp1250"] = 17] = "Cp1250"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["Cp1251"] = 18] = "Cp1251"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["Cp1252"] = 19] = "Cp1252"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["Cp1256"] = 20] = "Cp1256"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["UnicodeBigUnmarked"] = 21] = "UnicodeBigUnmarked"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["UTF8"] = 22] = "UTF8"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["ASCII"] = 23] = "ASCII"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["Big5"] = 24] = "Big5"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["GB18030"] = 25] = "GB18030"; + CharacterSetValueIdentifiers[CharacterSetValueIdentifiers["EUC_KR"] = 26] = "EUC_KR"; + })(CharacterSetValueIdentifiers || (CharacterSetValueIdentifiers = {})); + /** + * Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1 + * of ISO 18004. + * + * @author Sean Owen + */ + class CharacterSetECI { + constructor(valueIdentifier, valuesParam, name, ...otherEncodingNames) { + this.valueIdentifier = valueIdentifier; + this.name = name; + if (typeof valuesParam === 'number') { + this.values = Int32Array.from([valuesParam]); + } + else { + this.values = valuesParam; + } + this.otherEncodingNames = otherEncodingNames; + CharacterSetECI.VALUE_IDENTIFIER_TO_ECI.set(valueIdentifier, this); + CharacterSetECI.NAME_TO_ECI.set(name, this); + const values = this.values; + for (let i = 0, length = values.length; i !== length; i++) { + const v = values[i]; + CharacterSetECI.VALUES_TO_ECI.set(v, this); + } + for (const otherName of otherEncodingNames) { + CharacterSetECI.NAME_TO_ECI.set(otherName, this); + } + } + // CharacterSetECI(value: number /*int*/) { + // this(new Int32Array {value}) + // } + // CharacterSetECI(value: number /*int*/, String... otherEncodingNames) { + // this.values = new Int32Array {value} + // this.otherEncodingNames = otherEncodingNames + // } + // CharacterSetECI(values: Int32Array, String... otherEncodingNames) { + // this.values = values + // this.otherEncodingNames = otherEncodingNames + // } + getValueIdentifier() { + return this.valueIdentifier; + } + getName() { + return this.name; + } + getValue() { + return this.values[0]; + } + /** + * @param value character set ECI value + * @return {@code CharacterSetECI} representing ECI of given value, or null if it is legal but + * unsupported + * @throws FormatException if ECI value is invalid + */ + static getCharacterSetECIByValue(value /*int*/) { + if (value < 0 || value >= 900) { + throw new FormatException('incorect value'); + } + const characterSet = CharacterSetECI.VALUES_TO_ECI.get(value); + if (undefined === characterSet) { + throw new FormatException('incorect value'); + } + return characterSet; + } + /** + * @param name character set ECI encoding name + * @return CharacterSetECI representing ECI for character encoding, or null if it is legal + * but unsupported + */ + static getCharacterSetECIByName(name) { + const characterSet = CharacterSetECI.NAME_TO_ECI.get(name); + if (undefined === characterSet) { + throw new FormatException('incorect value'); + } + return characterSet; + } + equals(o) { + if (!(o instanceof CharacterSetECI)) { + return false; + } + const other = o; + return this.getName() === other.getName(); + } + } + CharacterSetECI.VALUE_IDENTIFIER_TO_ECI = new Map(); + CharacterSetECI.VALUES_TO_ECI = new Map(); + CharacterSetECI.NAME_TO_ECI = new Map(); + // Enum name is a Java encoding valid for java.lang and java.io + // TYPESCRIPTPORT: changed the main label for ISO as the TextEncoder did not recognized them in the form from java + // (eg ISO8859_1 must be ISO88591 or ISO8859-1 or ISO-8859-1) + // later on: well, except 16 wich does not work with ISO885916 so used ISO-8859-1 form for default + CharacterSetECI.Cp437 = new CharacterSetECI(CharacterSetValueIdentifiers.Cp437, Int32Array.from([0, 2]), 'Cp437'); + CharacterSetECI.ISO8859_1 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_1, Int32Array.from([1, 3]), 'ISO-8859-1', 'ISO88591', 'ISO8859_1'); + CharacterSetECI.ISO8859_2 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_2, 4, 'ISO-8859-2', 'ISO88592', 'ISO8859_2'); + CharacterSetECI.ISO8859_3 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_3, 5, 'ISO-8859-3', 'ISO88593', 'ISO8859_3'); + CharacterSetECI.ISO8859_4 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_4, 6, 'ISO-8859-4', 'ISO88594', 'ISO8859_4'); + CharacterSetECI.ISO8859_5 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_5, 7, 'ISO-8859-5', 'ISO88595', 'ISO8859_5'); + CharacterSetECI.ISO8859_6 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_6, 8, 'ISO-8859-6', 'ISO88596', 'ISO8859_6'); + CharacterSetECI.ISO8859_7 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_7, 9, 'ISO-8859-7', 'ISO88597', 'ISO8859_7'); + CharacterSetECI.ISO8859_8 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_8, 10, 'ISO-8859-8', 'ISO88598', 'ISO8859_8'); + CharacterSetECI.ISO8859_9 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_9, 11, 'ISO-8859-9', 'ISO88599', 'ISO8859_9'); + CharacterSetECI.ISO8859_10 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_10, 12, 'ISO-8859-10', 'ISO885910', 'ISO8859_10'); + CharacterSetECI.ISO8859_11 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_11, 13, 'ISO-8859-11', 'ISO885911', 'ISO8859_11'); + CharacterSetECI.ISO8859_13 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_13, 15, 'ISO-8859-13', 'ISO885913', 'ISO8859_13'); + CharacterSetECI.ISO8859_14 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_14, 16, 'ISO-8859-14', 'ISO885914', 'ISO8859_14'); + CharacterSetECI.ISO8859_15 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_15, 17, 'ISO-8859-15', 'ISO885915', 'ISO8859_15'); + CharacterSetECI.ISO8859_16 = new CharacterSetECI(CharacterSetValueIdentifiers.ISO8859_16, 18, 'ISO-8859-16', 'ISO885916', 'ISO8859_16'); + CharacterSetECI.SJIS = new CharacterSetECI(CharacterSetValueIdentifiers.SJIS, 20, 'SJIS', 'Shift_JIS'); + CharacterSetECI.Cp1250 = new CharacterSetECI(CharacterSetValueIdentifiers.Cp1250, 21, 'Cp1250', 'windows-1250'); + CharacterSetECI.Cp1251 = new CharacterSetECI(CharacterSetValueIdentifiers.Cp1251, 22, 'Cp1251', 'windows-1251'); + CharacterSetECI.Cp1252 = new CharacterSetECI(CharacterSetValueIdentifiers.Cp1252, 23, 'Cp1252', 'windows-1252'); + CharacterSetECI.Cp1256 = new CharacterSetECI(CharacterSetValueIdentifiers.Cp1256, 24, 'Cp1256', 'windows-1256'); + CharacterSetECI.UnicodeBigUnmarked = new CharacterSetECI(CharacterSetValueIdentifiers.UnicodeBigUnmarked, 25, 'UnicodeBigUnmarked', 'UTF-16BE', 'UnicodeBig'); + CharacterSetECI.UTF8 = new CharacterSetECI(CharacterSetValueIdentifiers.UTF8, 26, 'UTF8', 'UTF-8'); + CharacterSetECI.ASCII = new CharacterSetECI(CharacterSetValueIdentifiers.ASCII, Int32Array.from([27, 170]), 'ASCII', 'US-ASCII'); + CharacterSetECI.Big5 = new CharacterSetECI(CharacterSetValueIdentifiers.Big5, 28, 'Big5'); + CharacterSetECI.GB18030 = new CharacterSetECI(CharacterSetValueIdentifiers.GB18030, 29, 'GB18030', 'GB2312', 'EUC_CN', 'GBK'); + CharacterSetECI.EUC_KR = new CharacterSetECI(CharacterSetValueIdentifiers.EUC_KR, 30, 'EUC_KR', 'EUC-KR'); + + /** + * Custom Error class of type Exception. + */ + class UnsupportedOperationException extends Exception { + } + UnsupportedOperationException.kind = 'UnsupportedOperationException'; + + /** + * Responsible for en/decoding strings. + */ + class StringEncoding { + /** + * Decodes some Uint8Array to a string format. + */ + static decode(bytes, encoding) { + const encodingName = this.encodingName(encoding); + if (this.customDecoder) { + return this.customDecoder(bytes, encodingName); + } + // Increases browser support. + if (typeof TextDecoder === 'undefined' || this.shouldDecodeOnFallback(encodingName)) { + return this.decodeFallback(bytes, encodingName); + } + return new TextDecoder(encodingName).decode(bytes); + } + /** + * Checks if the decoding method should use the fallback for decoding + * once Node TextDecoder doesn't support all encoding formats. + * + * @param encodingName + */ + static shouldDecodeOnFallback(encodingName) { + return !StringEncoding.isBrowser() && encodingName === 'ISO-8859-1'; + } + /** + * Encodes some string into a Uint8Array. + */ + static encode(s, encoding) { + const encodingName = this.encodingName(encoding); + if (this.customEncoder) { + return this.customEncoder(s, encodingName); + } + // Increases browser support. + if (typeof TextEncoder === 'undefined') { + return this.encodeFallback(s); + } + // TextEncoder only encodes to UTF8 by default as specified by encoding.spec.whatwg.org + return new TextEncoder().encode(s); + } + static isBrowser() { + return (typeof window !== 'undefined' && {}.toString.call(window) === '[object Window]'); + } + /** + * Returns the string value from some encoding character set. + */ + static encodingName(encoding) { + return typeof encoding === 'string' + ? encoding + : encoding.getName(); + } + /** + * Returns character set from some encoding character set. + */ + static encodingCharacterSet(encoding) { + if (encoding instanceof CharacterSetECI) { + return encoding; + } + return CharacterSetECI.getCharacterSetECIByName(encoding); + } + /** + * Runs a fallback for the native decoding funcion. + */ + static decodeFallback(bytes, encoding) { + const characterSet = this.encodingCharacterSet(encoding); + if (StringEncoding.isDecodeFallbackSupported(characterSet)) { + let s = ''; + for (let i = 0, length = bytes.length; i < length; i++) { + let h = bytes[i].toString(16); + if (h.length < 2) { + h = '0' + h; + } + s += '%' + h; + } + return decodeURIComponent(s); + } + if (characterSet.equals(CharacterSetECI.UnicodeBigUnmarked)) { + return String.fromCharCode.apply(null, new Uint16Array(bytes.buffer)); + } + throw new UnsupportedOperationException(`Encoding ${this.encodingName(encoding)} not supported by fallback.`); + } + static isDecodeFallbackSupported(characterSet) { + return characterSet.equals(CharacterSetECI.UTF8) || + characterSet.equals(CharacterSetECI.ISO8859_1) || + characterSet.equals(CharacterSetECI.ASCII); + } + /** + * Runs a fallback for the native encoding funcion. + * + * @see https://stackoverflow.com/a/17192845/4367683 + */ + static encodeFallback(s) { + const encodedURIstring = btoa(unescape(encodeURIComponent(s))); + const charList = encodedURIstring.split(''); + const uintArray = []; + for (let i = 0; i < charList.length; i++) { + uintArray.push(charList[i].charCodeAt(0)); + } + return new Uint8Array(uintArray); + } + } + + /* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * Common string-related functions. + * + * @author Sean Owen + * @author Alex Dupre + */ + class StringUtils { + // SHIFT_JIS.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING) || + // EUC_JP.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING); + static castAsNonUtf8Char(code, encoding = null) { + // ISO 8859-1 is the Java default as UTF-8 is JavaScripts + // you can see this method as a Java version of String.fromCharCode + const e = encoding ? encoding.getName() : this.ISO88591; + // use passed format (fromCharCode will return UTF8 encoding) + return StringEncoding.decode(new Uint8Array([code]), e); + } + /** + * @param bytes bytes encoding a string, whose encoding should be guessed + * @param hints decode hints if applicable + * @return name of guessed encoding; at the moment will only guess one of: + * {@link #SHIFT_JIS}, {@link #UTF8}, {@link #ISO88591}, or the platform + * default encoding if none of these can possibly be correct + */ + static guessEncoding(bytes, hints) { + if (hints !== null && hints !== undefined && undefined !== hints.get(DecodeHintType$1.CHARACTER_SET)) { + return hints.get(DecodeHintType$1.CHARACTER_SET).toString(); + } + // For now, merely tries to distinguish ISO-8859-1, UTF-8 and Shift_JIS, + // which should be by far the most common encodings. + const length = bytes.length; + let canBeISO88591 = true; + let canBeShiftJIS = true; + let canBeUTF8 = true; + let utf8BytesLeft = 0; + // int utf8LowChars = 0 + let utf2BytesChars = 0; + let utf3BytesChars = 0; + let utf4BytesChars = 0; + let sjisBytesLeft = 0; + // int sjisLowChars = 0 + let sjisKatakanaChars = 0; + // int sjisDoubleBytesChars = 0 + let sjisCurKatakanaWordLength = 0; + let sjisCurDoubleBytesWordLength = 0; + let sjisMaxKatakanaWordLength = 0; + let sjisMaxDoubleBytesWordLength = 0; + // int isoLowChars = 0 + // int isoHighChars = 0 + let isoHighOther = 0; + const utf8bom = bytes.length > 3 && + bytes[0] === /*(byte) */ 0xEF && + bytes[1] === /*(byte) */ 0xBB && + bytes[2] === /*(byte) */ 0xBF; + for (let i = 0; i < length && (canBeISO88591 || canBeShiftJIS || canBeUTF8); i++) { + const value = bytes[i] & 0xFF; + // UTF-8 stuff + if (canBeUTF8) { + if (utf8BytesLeft > 0) { + if ((value & 0x80) === 0) { + canBeUTF8 = false; + } + else { + utf8BytesLeft--; + } + } + else if ((value & 0x80) !== 0) { + if ((value & 0x40) === 0) { + canBeUTF8 = false; + } + else { + utf8BytesLeft++; + if ((value & 0x20) === 0) { + utf2BytesChars++; + } + else { + utf8BytesLeft++; + if ((value & 0x10) === 0) { + utf3BytesChars++; + } + else { + utf8BytesLeft++; + if ((value & 0x08) === 0) { + utf4BytesChars++; + } + else { + canBeUTF8 = false; + } + } + } + } + } // else { + // utf8LowChars++ + // } + } + // ISO-8859-1 stuff + if (canBeISO88591) { + if (value > 0x7F && value < 0xA0) { + canBeISO88591 = false; + } + else if (value > 0x9F) { + if (value < 0xC0 || value === 0xD7 || value === 0xF7) { + isoHighOther++; + } // else { + // isoHighChars++ + // } + } // else { + // isoLowChars++ + // } + } + // Shift_JIS stuff + if (canBeShiftJIS) { + if (sjisBytesLeft > 0) { + if (value < 0x40 || value === 0x7F || value > 0xFC) { + canBeShiftJIS = false; + } + else { + sjisBytesLeft--; + } + } + else if (value === 0x80 || value === 0xA0 || value > 0xEF) { + canBeShiftJIS = false; + } + else if (value > 0xA0 && value < 0xE0) { + sjisKatakanaChars++; + sjisCurDoubleBytesWordLength = 0; + sjisCurKatakanaWordLength++; + if (sjisCurKatakanaWordLength > sjisMaxKatakanaWordLength) { + sjisMaxKatakanaWordLength = sjisCurKatakanaWordLength; + } + } + else if (value > 0x7F) { + sjisBytesLeft++; + // sjisDoubleBytesChars++ + sjisCurKatakanaWordLength = 0; + sjisCurDoubleBytesWordLength++; + if (sjisCurDoubleBytesWordLength > sjisMaxDoubleBytesWordLength) { + sjisMaxDoubleBytesWordLength = sjisCurDoubleBytesWordLength; + } + } + else { + // sjisLowChars++ + sjisCurKatakanaWordLength = 0; + sjisCurDoubleBytesWordLength = 0; + } + } + } + if (canBeUTF8 && utf8BytesLeft > 0) { + canBeUTF8 = false; + } + if (canBeShiftJIS && sjisBytesLeft > 0) { + canBeShiftJIS = false; + } + // Easy -- if there is BOM or at least 1 valid not-single byte character (and no evidence it can't be UTF-8), done + if (canBeUTF8 && (utf8bom || utf2BytesChars + utf3BytesChars + utf4BytesChars > 0)) { + return StringUtils.UTF8; + } + // Easy -- if assuming Shift_JIS or at least 3 valid consecutive not-ascii characters (and no evidence it can't be), done + if (canBeShiftJIS && (StringUtils.ASSUME_SHIFT_JIS || sjisMaxKatakanaWordLength >= 3 || sjisMaxDoubleBytesWordLength >= 3)) { + return StringUtils.SHIFT_JIS; + } + // Distinguishing Shift_JIS and ISO-8859-1 can be a little tough for short words. The crude heuristic is: + // - If we saw + // - only two consecutive katakana chars in the whole text, or + // - at least 10% of bytes that could be "upper" not-alphanumeric Latin1, + // - then we conclude Shift_JIS, else ISO-8859-1 + if (canBeISO88591 && canBeShiftJIS) { + return (sjisMaxKatakanaWordLength === 2 && sjisKatakanaChars === 2) || isoHighOther * 10 >= length + ? StringUtils.SHIFT_JIS : StringUtils.ISO88591; + } + // Otherwise, try in order ISO-8859-1, Shift JIS, UTF-8 and fall back to default platform encoding + if (canBeISO88591) { + return StringUtils.ISO88591; + } + if (canBeShiftJIS) { + return StringUtils.SHIFT_JIS; + } + if (canBeUTF8) { + return StringUtils.UTF8; + } + // Otherwise, we take a wild guess with platform encoding + return StringUtils.PLATFORM_DEFAULT_ENCODING; + } + /** + * + * @see https://stackoverflow.com/a/13439711/4367683 + * + * @param append The new string to append. + * @param args Argumets values to be formated. + */ + static format(append, ...args) { + let i = -1; + function callback(exp, p0, p1, p2, p3, p4) { + if (exp === '%%') + return '%'; + if (args[++i] === undefined) + return undefined; + exp = p2 ? parseInt(p2.substr(1)) : undefined; + let base = p3 ? parseInt(p3.substr(1)) : undefined; + let val; + switch (p4) { + case 's': + val = args[i]; + break; + case 'c': + val = args[i][0]; + break; + case 'f': + val = parseFloat(args[i]).toFixed(exp); + break; + case 'p': + val = parseFloat(args[i]).toPrecision(exp); + break; + case 'e': + val = parseFloat(args[i]).toExponential(exp); + break; + case 'x': + val = parseInt(args[i]).toString(base ? base : 16); + break; + case 'd': + val = parseFloat(parseInt(args[i], base ? base : 10).toPrecision(exp)).toFixed(0); + break; + } + val = typeof val === 'object' ? JSON.stringify(val) : (+val).toString(base); + let size = parseInt(p1); /* padding size */ + let ch = p1 && (p1[0] + '') === '0' ? '0' : ' '; /* isnull? */ + while (val.length < size) + val = p0 !== undefined ? val + ch : ch + val; /* isminus? */ + return val; + } + let regex = /%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g; + return append.replace(regex, callback); + } + /** + * + */ + static getBytes(str, encoding) { + return StringEncoding.encode(str, encoding); + } + /** + * Returns the charcode at the specified index or at index zero. + */ + static getCharCode(str, index = 0) { + return str.charCodeAt(index); + } + /** + * Returns char for given charcode + */ + static getCharAt(charCode) { + return String.fromCharCode(charCode); + } + } + StringUtils.SHIFT_JIS = CharacterSetECI.SJIS.getName(); // "SJIS" + StringUtils.GB2312 = 'GB2312'; + StringUtils.ISO88591 = CharacterSetECI.ISO8859_1.getName(); // "ISO8859_1" + StringUtils.EUC_JP = 'EUC_JP'; + StringUtils.UTF8 = CharacterSetECI.UTF8.getName(); // "UTF8" + StringUtils.PLATFORM_DEFAULT_ENCODING = StringUtils.UTF8; // "UTF8"//Charset.defaultCharset().name() + StringUtils.ASSUME_SHIFT_JIS = false; + + class StringBuilder { + constructor(value = '') { + this.value = value; + } + enableDecoding(encoding) { + this.encoding = encoding; + return this; + } + append(s) { + if (typeof s === 'string') { + this.value += s.toString(); + } + else if (this.encoding) { + // use passed format (fromCharCode will return UTF8 encoding) + this.value += StringUtils.castAsNonUtf8Char(s, this.encoding); + } + else { + // correctly converts from UTF-8, but not other encodings + this.value += String.fromCharCode(s); + } + return this; + } + appendChars(str, offset, len) { + for (let i = offset; offset < offset + len; i++) { + this.append(str[i]); + } + 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, c) { + this.value = this.value.substr(0, n) + c + this.value.substr(n + 1); + } + substring(start, end) { + return this.value.substring(start, end); + } + /** + * @note helper method for RSS Expanded + */ + setLengthToZero() { + this.value = ''; + } + toString() { + return this.value; + } + insert(n, c) { + this.value = this.value.substr(0, n) + c + this.value.substr(n + c.length); + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Represents a 2D matrix of bits. In function arguments below, and throughout the common + * module, x is the column position, and y is the row position. The ordering is always x, y. + * The origin is at the top-left.</p> + * + * <p>Internally the bits are represented in a 1-D array of 32-bit ints. However, each row begins + * with a new int. This is done intentionally so that we can copy out a row into a BitArray very + * efficiently.</p> + * + * <p>The ordering of bits is row-major. Within each int, the least significant bits are used first, + * meaning they represent lower x values. This is compatible with BitArray's implementation.</p> + * + * @author Sean Owen + * @author dswitkin@google.com (Daniel Switkin) + */ + class BitMatrix /*implements Cloneable*/ { + /** + * Creates an empty square {@link BitMatrix}. + * + * @param dimension height and width + */ + // public constructor(dimension: number /*int*/) { + // this(dimension, dimension) + // } + /** + * Creates an empty {@link BitMatrix}. + * + * @param width bit matrix width + * @param height bit matrix height + */ + // public constructor(width: number /*int*/, height: number /*int*/) { + // if (width < 1 || height < 1) { + // throw new IllegalArgumentException("Both dimensions must be greater than 0") + // } + // this.width = width + // this.height = height + // this.rowSize = (width + 31) / 32 + // bits = new int[rowSize * height]; + // } + constructor(width /*int*/, height /*int*/, rowSize /*int*/, bits) { + this.width = width; + this.height = height; + this.rowSize = rowSize; + this.bits = bits; + if (undefined === height || null === height) { + height = width; + } + this.height = height; + if (width < 1 || height < 1) { + throw new IllegalArgumentException('Both dimensions must be greater than 0'); + } + if (undefined === rowSize || null === rowSize) { + rowSize = Math.floor((width + 31) / 32); + } + this.rowSize = rowSize; + if (undefined === bits || null === bits) { + this.bits = new Int32Array(this.rowSize * this.height); + } + } + /** + * Interprets a 2D array of booleans as a {@link BitMatrix}, where "true" means an "on" bit. + * + * @function parse + * @param image bits of the image, as a row-major 2D array. Elements are arrays representing rows + * @return {@link BitMatrix} representation of image + */ + static parseFromBooleanArray(image) { + const height = image.length; + const width = image[0].length; + const bits = new BitMatrix(width, height); + for (let i = 0; i < height; i++) { + const imageI = image[i]; + for (let j = 0; j < width; j++) { + if (imageI[j]) { + bits.set(j, i); + } + } + } + return bits; + } + /** + * + * @function parse + * @param stringRepresentation + * @param setString + * @param unsetString + */ + static parseFromString(stringRepresentation, setString, unsetString) { + if (stringRepresentation === null) { + throw new IllegalArgumentException('stringRepresentation cannot be null'); + } + const bits = new Array(stringRepresentation.length); + let bitsPos = 0; + let rowStartPos = 0; + let rowLength = -1; + let nRows = 0; + let pos = 0; + while (pos < stringRepresentation.length) { + if (stringRepresentation.charAt(pos) === '\n' || + stringRepresentation.charAt(pos) === '\r') { + if (bitsPos > rowStartPos) { + if (rowLength === -1) { + rowLength = bitsPos - rowStartPos; + } + else if (bitsPos - rowStartPos !== rowLength) { + throw new IllegalArgumentException('row lengths do not match'); + } + rowStartPos = bitsPos; + nRows++; + } + pos++; + } + else if (stringRepresentation.substring(pos, pos + setString.length) === setString) { + pos += setString.length; + bits[bitsPos] = true; + bitsPos++; + } + else if (stringRepresentation.substring(pos, pos + unsetString.length) === unsetString) { + pos += unsetString.length; + bits[bitsPos] = false; + bitsPos++; + } + else { + throw new IllegalArgumentException('illegal character encountered: ' + stringRepresentation.substring(pos)); + } + } + // no EOL at end? + if (bitsPos > rowStartPos) { + if (rowLength === -1) { + rowLength = bitsPos - rowStartPos; + } + else if (bitsPos - rowStartPos !== rowLength) { + throw new IllegalArgumentException('row lengths do not match'); + } + nRows++; + } + const matrix = new BitMatrix(rowLength, nRows); + for (let i = 0; i < bitsPos; i++) { + if (bits[i]) { + matrix.set(Math.floor(i % rowLength), Math.floor(i / rowLength)); + } + } + return matrix; + } + /** + * <p>Gets the requested bit, where true means black.</p> + * + * @param x The horizontal component (i.e. which column) + * @param y The vertical component (i.e. which row) + * @return value of given bit in matrix + */ + get(x /*int*/, y /*int*/) { + const offset = y * this.rowSize + Math.floor(x / 32); + return ((this.bits[offset] >>> (x & 0x1f)) & 1) !== 0; + } + /** + * <p>Sets the given bit to true.</p> + * + * @param x The horizontal component (i.e. which column) + * @param y The vertical component (i.e. which row) + */ + set(x /*int*/, y /*int*/) { + const offset = y * this.rowSize + Math.floor(x / 32); + this.bits[offset] |= (1 << (x & 0x1f)) & 0xFFFFFFFF; + } + unset(x /*int*/, y /*int*/) { + const offset = y * this.rowSize + Math.floor(x / 32); + this.bits[offset] &= ~((1 << (x & 0x1f)) & 0xFFFFFFFF); + } + /** + * <p>Flips the given bit.</p> + * + * @param x The horizontal component (i.e. which column) + * @param y The vertical component (i.e. which row) + */ + flip(x /*int*/, y /*int*/) { + const offset = y * this.rowSize + Math.floor(x / 32); + this.bits[offset] ^= ((1 << (x & 0x1f)) & 0xFFFFFFFF); + } + /** + * Exclusive-or (XOR): Flip the bit in this {@code BitMatrix} if the corresponding + * mask bit is set. + * + * @param mask XOR mask + */ + xor(mask) { + if (this.width !== mask.getWidth() || this.height !== mask.getHeight() + || this.rowSize !== mask.getRowSize()) { + throw new IllegalArgumentException('input matrix dimensions do not match'); + } + const rowArray = new BitArray(Math.floor(this.width / 32) + 1); + const rowSize = this.rowSize; + const bits = this.bits; + for (let y = 0, height = this.height; y < height; y++) { + const offset = y * rowSize; + const row = mask.getRow(y, rowArray).getBitArray(); + for (let x = 0; x < rowSize; x++) { + bits[offset + x] ^= row[x]; + } + } + } + /** + * Clears all bits (sets to false). + */ + clear() { + const bits = this.bits; + const max = bits.length; + for (let i = 0; i < max; i++) { + bits[i] = 0; + } + } + /** + * <p>Sets a square region of the bit matrix to true.</p> + * + * @param left The horizontal position to begin at (inclusive) + * @param top The vertical position to begin at (inclusive) + * @param width The width of the region + * @param height The height of the region + */ + setRegion(left /*int*/, top /*int*/, width /*int*/, height /*int*/) { + if (top < 0 || left < 0) { + throw new IllegalArgumentException('Left and top must be nonnegative'); + } + if (height < 1 || width < 1) { + throw new IllegalArgumentException('Height and width must be at least 1'); + } + const right = left + width; + const bottom = top + height; + if (bottom > this.height || right > this.width) { + throw new IllegalArgumentException('The region must fit inside the matrix'); + } + const rowSize = this.rowSize; + const bits = this.bits; + for (let y = top; y < bottom; y++) { + const offset = y * rowSize; + for (let x = left; x < right; x++) { + bits[offset + Math.floor(x / 32)] |= ((1 << (x & 0x1f)) & 0xFFFFFFFF); + } + } + } + /** + * A fast method to retrieve one row of data from the matrix as a BitArray. + * + * @param y The row to retrieve + * @param row An optional caller-allocated BitArray, will be allocated if null or too small + * @return The resulting BitArray - this reference should always be used even when passing + * your own row + */ + getRow(y /*int*/, row) { + if (row === null || row === undefined || row.getSize() < this.width) { + row = new BitArray(this.width); + } + else { + row.clear(); + } + const rowSize = this.rowSize; + const bits = this.bits; + const offset = y * rowSize; + for (let x = 0; x < rowSize; x++) { + row.setBulk(x * 32, bits[offset + x]); + } + return row; + } + /** + * @param y row to set + * @param row {@link BitArray} to copy from + */ + setRow(y /*int*/, row) { + System.arraycopy(row.getBitArray(), 0, this.bits, y * this.rowSize, this.rowSize); + } + /** + * Modifies this {@code BitMatrix} to represent the same but rotated 180 degrees + */ + rotate180() { + const width = this.getWidth(); + const height = this.getHeight(); + let topRow = new BitArray(width); + let bottomRow = new BitArray(width); + for (let i = 0, length = Math.floor((height + 1) / 2); i < length; i++) { + topRow = this.getRow(i, topRow); + bottomRow = this.getRow(height - 1 - i, bottomRow); + topRow.reverse(); + bottomRow.reverse(); + this.setRow(i, bottomRow); + this.setRow(height - 1 - i, topRow); + } + } + /** + * This is useful in detecting the enclosing rectangle of a 'pure' barcode. + * + * @return {@code left,top,width,height} enclosing rectangle of all 1 bits, or null if it is all white + */ + getEnclosingRectangle() { + const width = this.width; + const height = this.height; + const rowSize = this.rowSize; + const bits = this.bits; + let left = width; + let top = height; + let right = -1; + let bottom = -1; + for (let y = 0; y < height; y++) { + for (let x32 = 0; x32 < rowSize; x32++) { + const theBits = bits[y * rowSize + x32]; + if (theBits !== 0) { + if (y < top) { + top = y; + } + if (y > bottom) { + bottom = y; + } + if (x32 * 32 < left) { + let bit = 0; + while (((theBits << (31 - bit)) & 0xFFFFFFFF) === 0) { + bit++; + } + if ((x32 * 32 + bit) < left) { + left = x32 * 32 + bit; + } + } + if (x32 * 32 + 31 > right) { + let bit = 31; + while ((theBits >>> bit) === 0) { + bit--; + } + if ((x32 * 32 + bit) > right) { + right = x32 * 32 + bit; + } + } + } + } + } + if (right < left || bottom < top) { + return null; + } + return Int32Array.from([left, top, right - left + 1, bottom - top + 1]); + } + /** + * This is useful in detecting a corner of a 'pure' barcode. + * + * @return {@code x,y} coordinate of top-left-most 1 bit, or null if it is all white + */ + getTopLeftOnBit() { + const rowSize = this.rowSize; + const bits = this.bits; + let bitsOffset = 0; + while (bitsOffset < bits.length && bits[bitsOffset] === 0) { + bitsOffset++; + } + if (bitsOffset === bits.length) { + return null; + } + const y = bitsOffset / rowSize; + let x = (bitsOffset % rowSize) * 32; + const theBits = bits[bitsOffset]; + let bit = 0; + while (((theBits << (31 - bit)) & 0xFFFFFFFF) === 0) { + bit++; + } + x += bit; + return Int32Array.from([x, y]); + } + getBottomRightOnBit() { + const rowSize = this.rowSize; + const bits = this.bits; + let bitsOffset = bits.length - 1; + while (bitsOffset >= 0 && bits[bitsOffset] === 0) { + bitsOffset--; + } + if (bitsOffset < 0) { + return null; + } + const y = Math.floor(bitsOffset / rowSize); + let x = Math.floor(bitsOffset % rowSize) * 32; + const theBits = bits[bitsOffset]; + let bit = 31; + while ((theBits >>> bit) === 0) { + bit--; + } + x += bit; + return Int32Array.from([x, y]); + } + /** + * @return The width of the matrix + */ + getWidth() { + return this.width; + } + /** + * @return The height of the matrix + */ + getHeight() { + return this.height; + } + /** + * @return The row size of the matrix + */ + getRowSize() { + return this.rowSize; + } + /*@Override*/ + equals(o) { + if (!(o instanceof BitMatrix)) { + return false; + } + const other = o; + return this.width === other.width && this.height === other.height && this.rowSize === other.rowSize && + Arrays.equals(this.bits, other.bits); + } + /*@Override*/ + hashCode() { + let hash = this.width; + hash = 31 * hash + this.width; + hash = 31 * hash + this.height; + hash = 31 * hash + this.rowSize; + hash = 31 * hash + Arrays.hashCode(this.bits); + return hash; + } + /** + * @return string representation using "X" for set and " " for unset bits + */ + /*@Override*/ + // public toString(): string { + // return toString(": "X, " ") + // } + /** + * @param setString representation of a set bit + * @param unsetString representation of an unset bit + * @return string representation of entire matrix utilizing given strings + */ + // public toString(setString: string = "X ", unsetString: string = " "): string { + // return this.buildToString(setString, unsetString, "\n") + // } + /** + * @param setString representation of a set bit + * @param unsetString representation of an unset bit + * @param lineSeparator newline character in string representation + * @return string representation of entire matrix utilizing given strings and line separator + * @deprecated call {@link #toString(String,String)} only, which uses \n line separator always + */ + // @Deprecated + toString(setString = 'X ', unsetString = ' ', lineSeparator = '\n') { + return this.buildToString(setString, unsetString, lineSeparator); + } + buildToString(setString, unsetString, lineSeparator) { + let result = new StringBuilder(); + // result.append(lineSeparator); + for (let y = 0, height = this.height; y < height; y++) { + for (let x = 0, width = this.width; x < width; x++) { + result.append(this.get(x, y) ? setString : unsetString); + } + result.append(lineSeparator); + } + return result.toString(); + } + /*@Override*/ + clone() { + return new BitMatrix(this.width, this.height, this.rowSize, this.bits.slice()); + } + } + + /** + * Custom Error class of type Exception. + */ + class NotFoundException extends Exception { + static getNotFoundInstance() { + return new NotFoundException(); + } + } + NotFoundException.kind = 'NotFoundException'; + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * This Binarizer implementation uses the old ZXing global histogram approach. It is suitable + * for low-end mobile devices which don't have enough CPU or memory to use a local thresholding + * algorithm. However, because it picks a global black point, it cannot handle difficult shadows + * and gradients. + * + * Faster mobile devices and all desktop applications should probably use HybridBinarizer instead. + * + * @author dswitkin@google.com (Daniel Switkin) + * @author Sean Owen + */ + class GlobalHistogramBinarizer extends Binarizer { + constructor(source) { + super(source); + this.luminances = GlobalHistogramBinarizer.EMPTY; + this.buckets = new Int32Array(GlobalHistogramBinarizer.LUMINANCE_BUCKETS); + } + // Applies simple sharpening to the row data to improve performance of the 1D Readers. + /*@Override*/ + getBlackRow(y /*int*/, row) { + const source = this.getLuminanceSource(); + const width = source.getWidth(); + if (row === undefined || row === null || row.getSize() < width) { + row = new BitArray(width); + } + else { + row.clear(); + } + this.initArrays(width); + const localLuminances = source.getRow(y, this.luminances); + const localBuckets = this.buckets; + for (let x = 0; x < width; x++) { + localBuckets[(localLuminances[x] & 0xff) >> GlobalHistogramBinarizer.LUMINANCE_SHIFT]++; + } + const blackPoint = GlobalHistogramBinarizer.estimateBlackPoint(localBuckets); + if (width < 3) { + // Special case for very small images + for (let x = 0; x < width; x++) { + if ((localLuminances[x] & 0xff) < blackPoint) { + row.set(x); + } + } + } + else { + let left = localLuminances[0] & 0xff; + let center = localLuminances[1] & 0xff; + for (let x = 1; x < width - 1; x++) { + const right = localLuminances[x + 1] & 0xff; + // A simple -1 4 -1 box filter with a weight of 2. + if (((center * 4) - left - right) / 2 < blackPoint) { + row.set(x); + } + left = center; + center = right; + } + } + return row; + } + // Does not sharpen the data, as this call is intended to only be used by 2D Readers. + /*@Override*/ + getBlackMatrix() { + const source = this.getLuminanceSource(); + const width = source.getWidth(); + const height = source.getHeight(); + const matrix = new BitMatrix(width, height); + // Quickly calculates the histogram by sampling four rows from the image. This proved to be + // more robust on the blackbox tests than sampling a diagonal as we used to do. + this.initArrays(width); + const localBuckets = this.buckets; + for (let y = 1; y < 5; y++) { + const row = Math.floor((height * y) / 5); + const localLuminances = source.getRow(row, this.luminances); + const right = Math.floor((width * 4) / 5); + for (let x = Math.floor(width / 5); x < right; x++) { + const pixel = localLuminances[x] & 0xff; + localBuckets[pixel >> GlobalHistogramBinarizer.LUMINANCE_SHIFT]++; + } + } + const blackPoint = GlobalHistogramBinarizer.estimateBlackPoint(localBuckets); + // We delay reading the entire image luminance until the black point estimation succeeds. + // Although we end up reading four rows twice, it is consistent with our motto of + // "fail quickly" which is necessary for continuous scanning. + const localLuminances = source.getMatrix(); + for (let y = 0; y < height; y++) { + const offset = y * width; + for (let x = 0; x < width; x++) { + const pixel = localLuminances[offset + x] & 0xff; + if (pixel < blackPoint) { + matrix.set(x, y); + } + } + } + return matrix; + } + /*@Override*/ + createBinarizer(source) { + return new GlobalHistogramBinarizer(source); + } + initArrays(luminanceSize /*int*/) { + if (this.luminances.length < luminanceSize) { + this.luminances = new Uint8ClampedArray(luminanceSize); + } + const buckets = this.buckets; + for (let x = 0; x < GlobalHistogramBinarizer.LUMINANCE_BUCKETS; x++) { + buckets[x] = 0; + } + } + static estimateBlackPoint(buckets) { + // Find the tallest peak in the histogram. + const numBuckets = buckets.length; + let maxBucketCount = 0; + let firstPeak = 0; + let firstPeakSize = 0; + for (let x = 0; x < numBuckets; x++) { + if (buckets[x] > firstPeakSize) { + firstPeak = x; + firstPeakSize = buckets[x]; + } + if (buckets[x] > maxBucketCount) { + maxBucketCount = buckets[x]; + } + } + // Find the second-tallest peak which is somewhat far from the tallest peak. + let secondPeak = 0; + let secondPeakScore = 0; + for (let x = 0; x < numBuckets; x++) { + const distanceToBiggest = x - firstPeak; + // Encourage more distant second peaks by multiplying by square of distance. + const score = buckets[x] * distanceToBiggest * distanceToBiggest; + if (score > secondPeakScore) { + secondPeak = x; + secondPeakScore = score; + } + } + // Make sure firstPeak corresponds to the black peak. + if (firstPeak > secondPeak) { + const temp = firstPeak; + firstPeak = secondPeak; + secondPeak = temp; + } + // If there is too little contrast in the image to pick a meaningful black point, throw rather + // than waste time trying to decode the image, and risk false positives. + if (secondPeak - firstPeak <= numBuckets / 16) { + throw new NotFoundException(); + } + // Find a valley between them that is low and closer to the white peak. + let bestValley = secondPeak - 1; + let bestValleyScore = -1; + for (let x = secondPeak - 1; x > firstPeak; x--) { + const fromFirst = x - firstPeak; + const score = fromFirst * fromFirst * (secondPeak - x) * (maxBucketCount - buckets[x]); + if (score > bestValleyScore) { + bestValley = x; + bestValleyScore = score; + } + } + return bestValley << GlobalHistogramBinarizer.LUMINANCE_SHIFT; + } + } + GlobalHistogramBinarizer.LUMINANCE_BITS = 5; + GlobalHistogramBinarizer.LUMINANCE_SHIFT = 8 - GlobalHistogramBinarizer.LUMINANCE_BITS; + GlobalHistogramBinarizer.LUMINANCE_BUCKETS = 1 << GlobalHistogramBinarizer.LUMINANCE_BITS; + GlobalHistogramBinarizer.EMPTY = Uint8ClampedArray.from([0]); + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * This class implements a local thresholding algorithm, which while slower than the + * GlobalHistogramBinarizer, is fairly efficient for what it does. It is designed for + * high frequency images of barcodes with black data on white backgrounds. For this application, + * it does a much better job than a global blackpoint with severe shadows and gradients. + * However it tends to produce artifacts on lower frequency images and is therefore not + * a good general purpose binarizer for uses outside ZXing. + * + * This class extends GlobalHistogramBinarizer, using the older histogram approach for 1D readers, + * and the newer local approach for 2D readers. 1D decoding using a per-row histogram is already + * inherently local, and only fails for horizontal gradients. We can revisit that problem later, + * but for now it was not a win to use local blocks for 1D. + * + * This Binarizer is the default for the unit tests and the recommended class for library users. + * + * @author dswitkin@google.com (Daniel Switkin) + */ + class HybridBinarizer extends GlobalHistogramBinarizer { + constructor(source) { + super(source); + this.matrix = null; + } + /** + * Calculates the final BitMatrix once for all requests. This could be called once from the + * constructor instead, but there are some advantages to doing it lazily, such as making + * profiling easier, and not doing heavy lifting when callers don't expect it. + */ + /*@Override*/ + getBlackMatrix() { + if (this.matrix !== null) { + return this.matrix; + } + const source = this.getLuminanceSource(); + const width = source.getWidth(); + const height = source.getHeight(); + if (width >= HybridBinarizer.MINIMUM_DIMENSION && height >= HybridBinarizer.MINIMUM_DIMENSION) { + const luminances = source.getMatrix(); + let subWidth = width >> HybridBinarizer.BLOCK_SIZE_POWER; + if ((width & HybridBinarizer.BLOCK_SIZE_MASK) !== 0) { + subWidth++; + } + let subHeight = height >> HybridBinarizer.BLOCK_SIZE_POWER; + if ((height & HybridBinarizer.BLOCK_SIZE_MASK) !== 0) { + subHeight++; + } + const blackPoints = HybridBinarizer.calculateBlackPoints(luminances, subWidth, subHeight, width, height); + const newMatrix = new BitMatrix(width, height); + HybridBinarizer.calculateThresholdForBlock(luminances, subWidth, subHeight, width, height, blackPoints, newMatrix); + this.matrix = newMatrix; + } + else { + // If the image is too small, fall back to the global histogram approach. + this.matrix = super.getBlackMatrix(); + } + return this.matrix; + } + /*@Override*/ + createBinarizer(source) { + return new HybridBinarizer(source); + } + /** + * For each block in the image, calculate the average black point using a 5x5 grid + * of the blocks around it. Also handles the corner cases (fractional blocks are computed based + * on the last pixels in the row/column which are also used in the previous block). + */ + static calculateThresholdForBlock(luminances, subWidth /*int*/, subHeight /*int*/, width /*int*/, height /*int*/, blackPoints, matrix) { + const maxYOffset = height - HybridBinarizer.BLOCK_SIZE; + const maxXOffset = width - HybridBinarizer.BLOCK_SIZE; + for (let y = 0; y < subHeight; y++) { + let yoffset = y << HybridBinarizer.BLOCK_SIZE_POWER; + if (yoffset > maxYOffset) { + yoffset = maxYOffset; + } + const top = HybridBinarizer.cap(y, 2, subHeight - 3); + for (let x = 0; x < subWidth; x++) { + let xoffset = x << HybridBinarizer.BLOCK_SIZE_POWER; + if (xoffset > maxXOffset) { + xoffset = maxXOffset; + } + const left = HybridBinarizer.cap(x, 2, subWidth - 3); + let sum = 0; + for (let z = -2; z <= 2; z++) { + const blackRow = blackPoints[top + z]; + sum += blackRow[left - 2] + blackRow[left - 1] + blackRow[left] + blackRow[left + 1] + blackRow[left + 2]; + } + const average = sum / 25; + HybridBinarizer.thresholdBlock(luminances, xoffset, yoffset, average, width, matrix); + } + } + } + static cap(value /*int*/, min /*int*/, max /*int*/) { + return value < min ? min : value > max ? max : value; + } + /** + * Applies a single threshold to a block of pixels. + */ + static thresholdBlock(luminances, xoffset /*int*/, yoffset /*int*/, threshold /*int*/, stride /*int*/, matrix) { + for (let y = 0, offset = yoffset * stride + xoffset; y < HybridBinarizer.BLOCK_SIZE; y++, offset += stride) { + for (let x = 0; x < HybridBinarizer.BLOCK_SIZE; x++) { + // Comparison needs to be <= so that black == 0 pixels are black even if the threshold is 0. + if ((luminances[offset + x] & 0xFF) <= threshold) { + matrix.set(xoffset + x, yoffset + y); + } + } + } + } + /** + * Calculates a single black point for each block of pixels and saves it away. + * See the following thread for a discussion of this algorithm: + * http://groups.google.com/group/zxing/browse_thread/thread/d06efa2c35a7ddc0 + */ + static calculateBlackPoints(luminances, subWidth /*int*/, subHeight /*int*/, width /*int*/, height /*int*/) { + const maxYOffset = height - HybridBinarizer.BLOCK_SIZE; + const maxXOffset = width - HybridBinarizer.BLOCK_SIZE; + // tslint:disable-next-line:whitespace + const blackPoints = new Array(subHeight); // subWidth + for (let y = 0; y < subHeight; y++) { + blackPoints[y] = new Int32Array(subWidth); + let yoffset = y << HybridBinarizer.BLOCK_SIZE_POWER; + if (yoffset > maxYOffset) { + yoffset = maxYOffset; + } + for (let x = 0; x < subWidth; x++) { + let xoffset = x << HybridBinarizer.BLOCK_SIZE_POWER; + if (xoffset > maxXOffset) { + xoffset = maxXOffset; + } + let sum = 0; + let min = 0xFF; + let max = 0; + for (let yy = 0, offset = yoffset * width + xoffset; yy < HybridBinarizer.BLOCK_SIZE; yy++, offset += width) { + for (let xx = 0; xx < HybridBinarizer.BLOCK_SIZE; xx++) { + const pixel = luminances[offset + xx] & 0xFF; + sum += pixel; + // still looking for good contrast + if (pixel < min) { + min = pixel; + } + if (pixel > max) { + max = pixel; + } + } + // short-circuit min/max tests once dynamic range is met + if (max - min > HybridBinarizer.MIN_DYNAMIC_RANGE) { + // finish the rest of the rows quickly + for (yy++, offset += width; yy < HybridBinarizer.BLOCK_SIZE; yy++, offset += width) { + for (let xx = 0; xx < HybridBinarizer.BLOCK_SIZE; xx++) { + sum += luminances[offset + xx] & 0xFF; + } + } + } + } + // The default estimate is the average of the values in the block. + let average = sum >> (HybridBinarizer.BLOCK_SIZE_POWER * 2); + if (max - min <= HybridBinarizer.MIN_DYNAMIC_RANGE) { + // If variation within the block is low, assume this is a block with only light or only + // dark pixels. In that case we do not want to use the average, as it would divide this + // low contrast area into black and white pixels, essentially creating data out of noise. + // + // The default assumption is that the block is light/background. Since no estimate for + // the level of dark pixels exists locally, use half the min for the block. + average = min / 2; + if (y > 0 && x > 0) { + // Correct the "white background" assumption for blocks that have neighbors by comparing + // the pixels in this block to the previously calculated black points. This is based on + // the fact that dark barcode symbology is always surrounded by some amount of light + // background for which reasonable black point estimates were made. The bp estimated at + // the boundaries is used for the interior. + // The (min < bp) is arbitrary but works better than other heuristics that were tried. + const averageNeighborBlackPoint = (blackPoints[y - 1][x] + (2 * blackPoints[y][x - 1]) + blackPoints[y - 1][x - 1]) / 4; + if (min < averageNeighborBlackPoint) { + average = averageNeighborBlackPoint; + } + } + } + blackPoints[y][x] = average; + } + } + return blackPoints; + } + } + // This class uses 5x5 blocks to compute local luminance, where each block is 8x8 pixels. + // So this is the smallest dimension in each axis we can accept. + HybridBinarizer.BLOCK_SIZE_POWER = 3; + HybridBinarizer.BLOCK_SIZE = 1 << HybridBinarizer.BLOCK_SIZE_POWER; // ...0100...00 + HybridBinarizer.BLOCK_SIZE_MASK = HybridBinarizer.BLOCK_SIZE - 1; // ...0011...11 + HybridBinarizer.MINIMUM_DIMENSION = HybridBinarizer.BLOCK_SIZE * 5; + HybridBinarizer.MIN_DYNAMIC_RANGE = 24; + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*namespace com.google.zxing {*/ + /** + * The purpose of this class hierarchy is to abstract different bitmap implementations across + * platforms into a standard interface for requesting greyscale luminance values. The interface + * only provides immutable methods; therefore crop and rotation create copies. This is to ensure + * that one Reader does not modify the original luminance source and leave it in an unknown state + * for other Readers in the chain. + * + * @author dswitkin@google.com (Daniel Switkin) + */ + class LuminanceSource { + constructor(width /*int*/, height /*int*/) { + this.width = width; + this.height = height; + } + /** + * @return The width of the bitmap. + */ + getWidth() { + return this.width; + } + /** + * @return The height of the bitmap. + */ + getHeight() { + return this.height; + } + /** + * @return Whether this subclass supports cropping. + */ + isCropSupported() { + return false; + } + /** + * Returns a new object with cropped image data. Implementations may keep a reference to the + * original data rather than a copy. Only callable if isCropSupported() is true. + * + * @param left The left coordinate, which must be in [0,getWidth()) + * @param top The top coordinate, which must be in [0,getHeight()) + * @param width The width of the rectangle to crop. + * @param height The height of the rectangle to crop. + * @return A cropped version of this object. + */ + crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) { + throw new UnsupportedOperationException('This luminance source does not support cropping.'); + } + /** + * @return Whether this subclass supports counter-clockwise rotation. + */ + isRotateSupported() { + return false; + } + /** + * Returns a new object with rotated image data by 90 degrees counterclockwise. + * Only callable if {@link #isRotateSupported()} is true. + * + * @return A rotated version of this object. + */ + rotateCounterClockwise() { + throw new UnsupportedOperationException('This luminance source does not support rotation by 90 degrees.'); + } + /** + * Returns a new object with rotated image data by 45 degrees counterclockwise. + * Only callable if {@link #isRotateSupported()} is true. + * + * @return A rotated version of this object. + */ + rotateCounterClockwise45() { + throw new UnsupportedOperationException('This luminance source does not support rotation by 45 degrees.'); + } + /*@Override*/ + toString() { + const row = new Uint8ClampedArray(this.width); + let result = new StringBuilder(); + for (let y = 0; y < this.height; y++) { + const sourceRow = this.getRow(y, row); + for (let x = 0; x < this.width; x++) { + const luminance = sourceRow[x] & 0xFF; + let c; + if (luminance < 0x40) { + c = '#'; + } + else if (luminance < 0x80) { + c = '+'; + } + else if (luminance < 0xC0) { + c = '.'; + } + else { + c = ' '; + } + result.append(c); + } + result.append('\n'); + } + return result.toString(); + } + } + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*namespace com.google.zxing {*/ + /** + * A wrapper implementation of {@link LuminanceSource} which inverts the luminances it returns -- black becomes + * white and vice versa, and each value becomes (255-value). + * + * @author Sean Owen + */ + class InvertedLuminanceSource extends LuminanceSource { + constructor(delegate) { + super(delegate.getWidth(), delegate.getHeight()); + this.delegate = delegate; + } + /*@Override*/ + getRow(y /*int*/, row) { + const sourceRow = this.delegate.getRow(y, row); + const width = this.getWidth(); + for (let i = 0; i < width; i++) { + sourceRow[i] = /*(byte)*/ (255 - (sourceRow[i] & 0xFF)); + } + return sourceRow; + } + /*@Override*/ + getMatrix() { + const matrix = this.delegate.getMatrix(); + const length = this.getWidth() * this.getHeight(); + const invertedMatrix = new Uint8ClampedArray(length); + for (let i = 0; i < length; i++) { + invertedMatrix[i] = /*(byte)*/ (255 - (matrix[i] & 0xFF)); + } + return invertedMatrix; + } + /*@Override*/ + isCropSupported() { + return this.delegate.isCropSupported(); + } + /*@Override*/ + crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) { + return new InvertedLuminanceSource(this.delegate.crop(left, top, width, height)); + } + /*@Override*/ + isRotateSupported() { + return this.delegate.isRotateSupported(); + } + /** + * @return original delegate {@link LuminanceSource} since invert undoes itself + */ + /*@Override*/ + invert() { + return this.delegate; + } + /*@Override*/ + rotateCounterClockwise() { + return new InvertedLuminanceSource(this.delegate.rotateCounterClockwise()); + } + /*@Override*/ + rotateCounterClockwise45() { + return new InvertedLuminanceSource(this.delegate.rotateCounterClockwise45()); + } + } + + /** + * @deprecated Moving to @zxing/browser + */ + class HTMLCanvasElementLuminanceSource extends LuminanceSource { + constructor(canvas) { + super(canvas.width, canvas.height); + this.canvas = canvas; + this.tempCanvasElement = null; + this.buffer = HTMLCanvasElementLuminanceSource.makeBufferFromCanvasImageData(canvas); + } + static makeBufferFromCanvasImageData(canvas) { + const imageData = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height); + return HTMLCanvasElementLuminanceSource.toGrayscaleBuffer(imageData.data, canvas.width, canvas.height); + } + static toGrayscaleBuffer(imageBuffer, width, height) { + const grayscaleBuffer = new Uint8ClampedArray(width * height); + for (let i = 0, j = 0, length = imageBuffer.length; i < length; i += 4, j++) { + let gray; + const alpha = imageBuffer[i + 3]; + // The color of fully-transparent pixels is irrelevant. They are often, technically, fully-transparent + // black (0 alpha, and then 0 RGB). They are often used, of course as the "white" area in a + // barcode image. Force any such pixel to be white: + if (alpha === 0) { + gray = 0xFF; + } + else { + const pixelR = imageBuffer[i]; + const pixelG = imageBuffer[i + 1]; + const pixelB = imageBuffer[i + 2]; + // .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC), + // (306*R) >> 10 is approximately equal to R*0.299, and so on. + // 0x200 >> 10 is 0.5, it implements rounding. + gray = (306 * pixelR + + 601 * pixelG + + 117 * pixelB + + 0x200) >> 10; + } + grayscaleBuffer[j] = gray; + } + return grayscaleBuffer; + } + getRow(y /*int*/, row) { + if (y < 0 || y >= this.getHeight()) { + throw new IllegalArgumentException('Requested row is outside the image: ' + y); + } + const width = this.getWidth(); + const start = y * width; + if (row === null) { + row = this.buffer.slice(start, start + width); + } + else { + if (row.length < width) { + row = new Uint8ClampedArray(width); + } + // The underlying raster of image consists of bytes with the luminance values + // TODO: can avoid set/slice? + row.set(this.buffer.slice(start, start + width)); + } + return row; + } + getMatrix() { + return this.buffer; + } + isCropSupported() { + return true; + } + crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) { + super.crop(left, top, width, height); + return this; + } + /** + * This is always true, since the image is a gray-scale image. + * + * @return true + */ + isRotateSupported() { + return true; + } + rotateCounterClockwise() { + this.rotate(-90); + return this; + } + rotateCounterClockwise45() { + this.rotate(-45); + return this; + } + getTempCanvasElement() { + if (null === this.tempCanvasElement) { + const tempCanvasElement = this.canvas.ownerDocument.createElement('canvas'); + tempCanvasElement.width = this.canvas.width; + tempCanvasElement.height = this.canvas.height; + this.tempCanvasElement = tempCanvasElement; + } + return this.tempCanvasElement; + } + rotate(angle) { + const tempCanvasElement = this.getTempCanvasElement(); + const tempContext = tempCanvasElement.getContext('2d'); + const angleRadians = angle * HTMLCanvasElementLuminanceSource.DEGREE_TO_RADIANS; + // Calculate and set new dimensions for temp canvas + const width = this.canvas.width; + const height = this.canvas.height; + const newWidth = Math.ceil(Math.abs(Math.cos(angleRadians)) * width + Math.abs(Math.sin(angleRadians)) * height); + const newHeight = Math.ceil(Math.abs(Math.sin(angleRadians)) * width + Math.abs(Math.cos(angleRadians)) * height); + tempCanvasElement.width = newWidth; + tempCanvasElement.height = newHeight; + // Draw at center of temp canvas to prevent clipping of image data + tempContext.translate(newWidth / 2, newHeight / 2); + tempContext.rotate(angleRadians); + tempContext.drawImage(this.canvas, width / -2, height / -2); + this.buffer = HTMLCanvasElementLuminanceSource.makeBufferFromCanvasImageData(tempCanvasElement); + return this; + } + invert() { + return new InvertedLuminanceSource(this); + } + } + HTMLCanvasElementLuminanceSource.DEGREE_TO_RADIANS = Math.PI / 180; + + /** + * @deprecated Moving to @zxing/browser + * + * Video input device metadata containing the id and label of the device if available. + */ + class VideoInputDevice { + /** + * Creates an instance of VideoInputDevice. + * + * @param {string} deviceId the video input device id + * @param {string} label the label of the device if available + */ + constructor(deviceId, label, groupId) { + this.deviceId = deviceId; + this.label = label; + /** @inheritdoc */ + this.kind = 'videoinput'; + this.groupId = groupId || undefined; + } + /** @inheritdoc */ + toJSON() { + return { + kind: this.kind, + groupId: this.groupId, + deviceId: this.deviceId, + label: this.label, + }; + } + } + + var __awaiter = ((globalThis || global || self || window || undefined) && (globalThis || global || self || window || undefined).__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + /** + * @deprecated Moving to @zxing/browser + * + * Base class for browser code reader. + */ + class BrowserCodeReader { + /** + * Creates an instance of BrowserCodeReader. + * @param {Reader} reader The reader instance to decode the barcode + * @param {number} [timeBetweenScansMillis=500] the time delay between subsequent successful decode tries + * + * @memberOf BrowserCodeReader + */ + constructor(reader, timeBetweenScansMillis = 500, _hints) { + this.reader = reader; + this.timeBetweenScansMillis = timeBetweenScansMillis; + this._hints = _hints; + /** + * This will break the loop. + */ + this._stopContinuousDecode = false; + /** + * This will break the loop. + */ + this._stopAsyncDecode = false; + /** + * Delay time between decode attempts made by the scanner. + */ + this._timeBetweenDecodingAttempts = 0; + } + /** + * If navigator is present. + */ + get hasNavigator() { + return typeof navigator !== 'undefined'; + } + /** + * If mediaDevices under navigator is supported. + */ + get isMediaDevicesSuported() { + return this.hasNavigator && !!navigator.mediaDevices; + } + /** + * If enumerateDevices under navigator is supported. + */ + get canEnumerateDevices() { + return !!(this.isMediaDevicesSuported && navigator.mediaDevices.enumerateDevices); + } + /** Time between two decoding tries in milli seconds. */ + get timeBetweenDecodingAttempts() { + return this._timeBetweenDecodingAttempts; + } + /** + * Change the time span the decoder waits between two decoding tries. + * + * @param {number} millis Time between two decoding tries in milli seconds. + */ + set timeBetweenDecodingAttempts(millis) { + this._timeBetweenDecodingAttempts = millis < 0 ? 0 : millis; + } + /** + * Sets the hints. + */ + set hints(hints) { + this._hints = hints || null; + } + /** + * Sets the hints. + */ + get hints() { + return this._hints; + } + /** + * Lists all the available video input devices. + */ + listVideoInputDevices() { + return __awaiter(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 devices = yield navigator.mediaDevices.enumerateDevices(); + const videoDevices = []; + for (const device of devices) { + const kind = device.kind === 'video' ? 'videoinput' : device.kind; + if (kind !== 'videoinput') { + continue; + } + const deviceId = device.deviceId || device.id; + const label = device.label || `Video device ${videoDevices.length + 1}`; + const groupId = device.groupId; + const videoDevice = { deviceId, label, kind, groupId }; + videoDevices.push(videoDevice); + } + return videoDevices; + }); + } + /** + * Obtain the list of available devices with type 'videoinput'. + * + * @returns {Promise<VideoInputDevice[]>} an array of available video input devices + * + * @memberOf BrowserCodeReader + * + * @deprecated Use `listVideoInputDevices` instead. + */ + getVideoInputDevices() { + return __awaiter(this, void 0, void 0, function* () { + const devices = yield this.listVideoInputDevices(); + return devices.map(d => new VideoInputDevice(d.deviceId, d.label)); + }); + } + /** + * Let's you find a device using it's Id. + */ + findDeviceById(deviceId) { + return __awaiter(this, void 0, void 0, function* () { + const devices = yield this.listVideoInputDevices(); + if (!devices) { + return null; + } + return devices.find(x => x.deviceId === deviceId); + }); + } + /** + * Decodes the barcode from the device specified by deviceId while showing the video in the specified video element. + * + * @param deviceId the id of one of the devices obtained after calling getVideoInputDevices. Can be undefined, in this case it will decode from one of the available devices, preffering the main camera (environment facing) if available. + * @param video the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown. + * @returns The decoding result. + * + * @memberOf BrowserCodeReader + * + * @deprecated Use `decodeOnceFromVideoDevice` instead. + */ + decodeFromInputVideoDevice(deviceId, videoSource) { + return __awaiter(this, void 0, void 0, function* () { + return yield this.decodeOnceFromVideoDevice(deviceId, videoSource); + }); + } + /** + * In one attempt, tries to decode the barcode from the device specified by deviceId while showing the video in the specified video element. + * + * @param deviceId the id of one of the devices obtained after calling getVideoInputDevices. Can be undefined, in this case it will decode from one of the available devices, preffering the main camera (environment facing) if available. + * @param video the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown. + * @returns The decoding result. + * + * @memberOf BrowserCodeReader + */ + decodeOnceFromVideoDevice(deviceId, videoSource) { + return __awaiter(this, void 0, void 0, function* () { + this.reset(); + let videoConstraints; + if (!deviceId) { + videoConstraints = { facingMode: 'environment' }; + } + else { + videoConstraints = { deviceId: { exact: deviceId } }; + } + const constraints = { video: videoConstraints }; + return yield this.decodeOnceFromConstraints(constraints, videoSource); + }); + } + /** + * In one attempt, tries to decode the barcode from a stream obtained from the given constraints while showing the video in the specified video element. + * + * @param constraints the media stream constraints to get s valid media stream to decode from + * @param video the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown. + * @returns The decoding result. + * + * @memberOf BrowserCodeReader + */ + decodeOnceFromConstraints(constraints, videoSource) { + return __awaiter(this, void 0, void 0, function* () { + const stream = yield navigator.mediaDevices.getUserMedia(constraints); + return yield this.decodeOnceFromStream(stream, videoSource); + }); + } + /** + * In one attempt, tries to decode the barcode from a stream obtained from the given constraints while showing the video in the specified video element. + * + * @param {MediaStream} [constraints] the media stream constraints to get s valid media stream to decode from + * @param {string|HTMLVideoElement} [video] the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown. + * @returns {Promise<Result>} The decoding result. + * + * @memberOf BrowserCodeReader + */ + decodeOnceFromStream(stream, videoSource) { + return __awaiter(this, void 0, void 0, function* () { + this.reset(); + const video = yield this.attachStreamToVideo(stream, videoSource); + const result = yield this.decodeOnce(video); + return result; + }); + } + /** + * Continuously decodes the barcode from the device specified by device while showing the video in the specified video element. + * + * @param {string|null} [deviceId] the id of one of the devices obtained after calling getVideoInputDevices. Can be undefined, in this case it will decode from one of the available devices, preffering the main camera (environment facing) if available. + * @param {string|HTMLVideoElement|null} [video] the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown. + * @returns {Promise<void>} + * + * @memberOf BrowserCodeReader + * + * @deprecated Use `decodeFromVideoDevice` instead. + */ + decodeFromInputVideoDeviceContinuously(deviceId, videoSource, callbackFn) { + return __awaiter(this, void 0, void 0, function* () { + return yield this.decodeFromVideoDevice(deviceId, videoSource, callbackFn); + }); + } + /** + * Continuously tries to decode the barcode from the device specified by device while showing the video in the specified video element. + * + * @param {string|null} [deviceId] the id of one of the devices obtained after calling getVideoInputDevices. Can be undefined, in this case it will decode from one of the available devices, preffering the main camera (environment facing) if available. + * @param {string|HTMLVideoElement|null} [video] the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown. + * @returns {Promise<void>} + * + * @memberOf BrowserCodeReader + */ + decodeFromVideoDevice(deviceId, videoSource, callbackFn) { + return __awaiter(this, void 0, void 0, function* () { + let videoConstraints; + if (!deviceId) { + videoConstraints = { facingMode: 'environment' }; + } + else { + videoConstraints = { deviceId: { exact: deviceId } }; + } + const constraints = { video: videoConstraints }; + return yield this.decodeFromConstraints(constraints, videoSource, callbackFn); + }); + } + /** + * Continuously tries to decode the barcode from a stream obtained from the given constraints while showing the video in the specified video element. + * + * @param {MediaStream} [constraints] the media stream constraints to get s valid media stream to decode from + * @param {string|HTMLVideoElement} [video] the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown. + * @returns {Promise<Result>} The decoding result. + * + * @memberOf BrowserCodeReader + */ + decodeFromConstraints(constraints, videoSource, callbackFn) { + return __awaiter(this, void 0, void 0, function* () { + const stream = yield navigator.mediaDevices.getUserMedia(constraints); + return yield this.decodeFromStream(stream, videoSource, callbackFn); + }); + } + /** + * In one attempt, tries to decode the barcode from a stream obtained from the given constraints while showing the video in the specified video element. + * + * @param {MediaStream} [constraints] the media stream constraints to get s valid media stream to decode from + * @param {string|HTMLVideoElement} [video] the video element in page where to show the video while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in which case no video will be shown. + * @returns {Promise<Result>} The decoding result. + * + * @memberOf BrowserCodeReader + */ + decodeFromStream(stream, videoSource, callbackFn) { + return __awaiter(this, void 0, void 0, function* () { + this.reset(); + const video = yield this.attachStreamToVideo(stream, videoSource); + return yield this.decodeContinuously(video, callbackFn); + }); + } + /** + * Breaks the decoding loop. + */ + stopAsyncDecode() { + this._stopAsyncDecode = true; + } + /** + * Breaks the decoding loop. + */ + stopContinuousDecode() { + this._stopContinuousDecode = true; + } + /** + * Sets the new stream and request a new decoding-with-delay. + * + * @param stream The stream to be shown in the video element. + * @param decodeFn A callback for the decode method. + */ + attachStreamToVideo(stream, videoSource) { + return __awaiter(this, void 0, void 0, function* () { + const videoElement = this.prepareVideoElement(videoSource); + this.addVideoSource(videoElement, stream); + this.videoElement = videoElement; + this.stream = stream; + yield this.playVideoOnLoadAsync(videoElement); + return videoElement; + }); + } + /** + * + * @param videoElement + */ + playVideoOnLoadAsync(videoElement) { + return new Promise((resolve, reject) => this.playVideoOnLoad(videoElement, () => resolve())); + } + /** + * Binds listeners and callbacks to the videoElement. + * + * @param element + * @param callbackFn + */ + playVideoOnLoad(element, callbackFn) { + this.videoEndedListener = () => this.stopStreams(); + this.videoCanPlayListener = () => this.tryPlayVideo(element); + element.addEventListener('ended', this.videoEndedListener); + element.addEventListener('canplay', this.videoCanPlayListener); + element.addEventListener('playing', callbackFn); + // if canplay was already fired, we won't know when to play, so just give it a try + this.tryPlayVideo(element); + } + /** + * Checks if the given video element is currently playing. + */ + isVideoPlaying(video) { + return video.currentTime > 0 && !video.paused && !video.ended && video.readyState > 2; + } + /** + * Just tries to play the video and logs any errors. + * The play call is only made is the video is not already playing. + */ + tryPlayVideo(videoElement) { + return __awaiter(this, void 0, void 0, function* () { + if (this.isVideoPlaying(videoElement)) { + console.warn('Trying to play video that is already playing.'); + return; + } + try { + yield videoElement.play(); + } + catch (_a) { + console.warn('It was not possible to play the video.'); + } + }); + } + /** + * Searches and validates a media element. + */ + getMediaElement(mediaElementId, type) { + const mediaElement = document.getElementById(mediaElementId); + if (!mediaElement) { + throw new ArgumentException(`element with id '${mediaElementId}' not found`); + } + if (mediaElement.nodeName.toLowerCase() !== type.toLowerCase()) { + throw new ArgumentException(`element with id '${mediaElementId}' must be an ${type} element`); + } + return mediaElement; + } + /** + * Decodes the barcode from an image. + * + * @param {(string|HTMLImageElement)} [source] The image element that can be either an element id or the element itself. Can be undefined in which case the decoding will be done from the imageUrl parameter. + * @param {string} [url] + * @returns {Promise<Result>} The decoding result. + * + * @memberOf BrowserCodeReader + */ + decodeFromImage(source, url) { + if (!source && !url) { + throw new ArgumentException('either imageElement with a src set or an url must be provided'); + } + if (url && !source) { + return this.decodeFromImageUrl(url); + } + return this.decodeFromImageElement(source); + } + /** + * Decodes the barcode from a video. + * + * @param {(string|HTMLImageElement)} [source] The image element that can be either an element id or the element itself. Can be undefined in which case the decoding will be done from the imageUrl parameter. + * @param {string} [url] + * @returns {Promise<Result>} The decoding result. + * + * @memberOf BrowserCodeReader + */ + decodeFromVideo(source, url) { + if (!source && !url) { + throw new ArgumentException('Either an element with a src set or an URL must be provided'); + } + if (url && !source) { + return this.decodeFromVideoUrl(url); + } + return this.decodeFromVideoElement(source); + } + /** + * Decodes continuously the barcode from a video. + * + * @param {(string|HTMLImageElement)} [source] The image element that can be either an element id or the element itself. Can be undefined in which case the decoding will be done from the imageUrl parameter. + * @param {string} [url] + * @returns {Promise<Result>} The decoding result. + * + * @memberOf BrowserCodeReader + * + * @experimental + */ + decodeFromVideoContinuously(source, url, callbackFn) { + if (undefined === source && undefined === url) { + throw new ArgumentException('Either an element with a src set or an URL must be provided'); + } + if (url && !source) { + return this.decodeFromVideoUrlContinuously(url, callbackFn); + } + return this.decodeFromVideoElementContinuously(source, callbackFn); + } + /** + * Decodes something from an image HTML element. + */ + decodeFromImageElement(source) { + if (!source) { + throw new ArgumentException('An image element must be provided.'); + } + this.reset(); + const element = this.prepareImageElement(source); + this.imageElement = element; + let task; + if (this.isImageLoaded(element)) { + task = this.decodeOnce(element, false, true); + } + else { + task = this._decodeOnLoadImage(element); + } + return task; + } + /** + * Decodes something from an image HTML element. + */ + decodeFromVideoElement(source) { + const element = this._decodeFromVideoElementSetup(source); + return this._decodeOnLoadVideo(element); + } + /** + * Decodes something from an image HTML element. + */ + decodeFromVideoElementContinuously(source, callbackFn) { + const element = this._decodeFromVideoElementSetup(source); + return this._decodeOnLoadVideoContinuously(element, callbackFn); + } + /** + * Sets up the video source so it can be decoded when loaded. + * + * @param source The video source element. + */ + _decodeFromVideoElementSetup(source) { + if (!source) { + throw new ArgumentException('A video element must be provided.'); + } + this.reset(); + const element = this.prepareVideoElement(source); + // defines the video element before starts decoding + this.videoElement = element; + return element; + } + /** + * Decodes an image from a URL. + */ + decodeFromImageUrl(url) { + if (!url) { + throw new ArgumentException('An URL must be provided.'); + } + this.reset(); + const element = this.prepareImageElement(); + this.imageElement = element; + const decodeTask = this._decodeOnLoadImage(element); + element.src = url; + return decodeTask; + } + /** + * Decodes an image from a URL. + */ + decodeFromVideoUrl(url) { + if (!url) { + throw new ArgumentException('An URL must be provided.'); + } + this.reset(); + // creates a new element + const element = this.prepareVideoElement(); + const decodeTask = this.decodeFromVideoElement(element); + element.src = url; + return decodeTask; + } + /** + * Decodes an image from a URL. + * + * @experimental + */ + decodeFromVideoUrlContinuously(url, callbackFn) { + if (!url) { + throw new ArgumentException('An URL must be provided.'); + } + this.reset(); + // creates a new element + const element = this.prepareVideoElement(); + const decodeTask = this.decodeFromVideoElementContinuously(element, callbackFn); + element.src = url; + return decodeTask; + } + _decodeOnLoadImage(element) { + return new Promise((resolve, reject) => { + this.imageLoadedListener = () => this.decodeOnce(element, false, true).then(resolve, reject); + element.addEventListener('load', this.imageLoadedListener); + }); + } + _decodeOnLoadVideo(videoElement) { + return __awaiter(this, void 0, void 0, function* () { + // plays the video + yield this.playVideoOnLoadAsync(videoElement); + // starts decoding after played the video + return yield this.decodeOnce(videoElement); + }); + } + _decodeOnLoadVideoContinuously(videoElement, callbackFn) { + return __awaiter(this, void 0, void 0, function* () { + // plays the video + yield this.playVideoOnLoadAsync(videoElement); + // starts decoding after played the video + this.decodeContinuously(videoElement, callbackFn); + }); + } + isImageLoaded(img) { + // During the onload event, IE correctly identifies any images that + // weren’t downloaded as not complete. Others should too. Gecko-based + // browsers act like NS4 in that they report this incorrectly. + if (!img.complete) { + return false; + } + // However, they do have two very useful properties: naturalWidth and + // naturalHeight. These give the true size of the image. If it failed + // to load, either of these should be zero. + if (img.naturalWidth === 0) { + return false; + } + // No other way of checking: assume it’s ok. + return true; + } + prepareImageElement(imageSource) { + let imageElement; + if (typeof imageSource === 'undefined') { + imageElement = document.createElement('img'); + imageElement.width = 200; + imageElement.height = 200; + } + if (typeof imageSource === 'string') { + imageElement = this.getMediaElement(imageSource, 'img'); + } + if (imageSource instanceof HTMLImageElement) { + imageElement = imageSource; + } + return imageElement; + } + /** + * Sets a HTMLVideoElement for scanning or creates a new one. + * + * @param videoSource The HTMLVideoElement to be set. + */ + prepareVideoElement(videoSource) { + let videoElement; + if (!videoSource && typeof document !== 'undefined') { + videoElement = document.createElement('video'); + videoElement.width = 200; + videoElement.height = 200; + } + if (typeof videoSource === 'string') { + videoElement = this.getMediaElement(videoSource, 'video'); + } + if (videoSource instanceof HTMLVideoElement) { + videoElement = videoSource; + } + // Needed for iOS 11 + videoElement.setAttribute('autoplay', 'true'); + videoElement.setAttribute('muted', 'true'); + videoElement.setAttribute('playsinline', 'true'); + return videoElement; + } + /** + * Tries to decode from the video input until it finds some value. + */ + decodeOnce(element, retryIfNotFound = true, retryIfChecksumOrFormatError = true) { + this._stopAsyncDecode = false; + const loop = (resolve, reject) => { + if (this._stopAsyncDecode) { + reject(new NotFoundException('Video stream has ended before any code could be detected.')); + this._stopAsyncDecode = undefined; + return; + } + try { + const result = this.decode(element); + resolve(result); + } + catch (e) { + const ifNotFound = retryIfNotFound && e instanceof NotFoundException; + const isChecksumOrFormatError = e instanceof ChecksumException || e instanceof FormatException; + const ifChecksumOrFormat = isChecksumOrFormatError && retryIfChecksumOrFormatError; + if (ifNotFound || ifChecksumOrFormat) { + // trying again + return setTimeout(loop, this._timeBetweenDecodingAttempts, resolve, reject); + } + reject(e); + } + }; + return new Promise((resolve, reject) => loop(resolve, reject)); + } + /** + * Continuously decodes from video input. + */ + decodeContinuously(element, callbackFn) { + this._stopContinuousDecode = false; + const loop = () => { + if (this._stopContinuousDecode) { + this._stopContinuousDecode = undefined; + return; + } + try { + const result = this.decode(element); + callbackFn(result, null); + setTimeout(loop, this.timeBetweenScansMillis); + } + catch (e) { + callbackFn(null, e); + const isChecksumOrFormatError = e instanceof ChecksumException || e instanceof FormatException; + const isNotFound = e instanceof NotFoundException; + if (isChecksumOrFormatError || isNotFound) { + // trying again + setTimeout(loop, this._timeBetweenDecodingAttempts); + } + } + }; + loop(); + } + /** + * Gets the BinaryBitmap for ya! (and decodes it) + */ + decode(element) { + // get binary bitmap for decode function + const binaryBitmap = this.createBinaryBitmap(element); + return this.decodeBitmap(binaryBitmap); + } + /** + * Returns true if media element is indeed a {@link HtmlVideoElement}. + */ + _isHTMLVideoElement(mediaElement) { + const potentialVideo = mediaElement; + return potentialVideo.videoWidth !== 0; + } + /** + * Overwriting this allows you to manipulate the next frame in anyway + * you want before decode. + */ + drawFrameOnCanvas( + srcElement, dimensions, canvasElementContext) { + if (!dimensions) { + dimensions = { + sx: 0, + sy: 0, + sWidth: srcElement.videoWidth, + sHeight: srcElement.videoHeight, + dx: 0, + dy: 0, + dWidth: srcElement.videoWidth, + dHeight: srcElement.videoHeight}; + } + if (!canvasElementContext) { + canvasElementContext = this.captureCanvasContext; + } + canvasElementContext.drawImage( + srcElement, + dimensions.sx, + dimensions.sy, + dimensions.sWidth, + dimensions.sHeight, + dimensions.dx, + dimensions.dy, + dimensions.dWidth, + dimensions.dHeight); + } + /** + * Ovewriting this allows you to manipulate the snapshot image in anyway + * you want before decode. + */ + drawImageOnCanvas( + srcElement, + dimensions, + canvasElementContext = this.captureCanvasContext) { + if (!dimensions) { + dimensions = { + sx: 0, + sy: 0, + sWidth: srcElement.naturalWidth, + sHeight: srcElement.naturalHeight, + dx: 0, + dy: 0, + dWidth: srcElement.naturalWidth, + dHeight: srcElement.naturalHeight + }; + } + if (!canvasElementContext) { + canvasElementContext = this.captureCanvasContext; + } + canvasElementContext.drawImage( + srcElement, + dimensions.sx, + dimensions.sy, + dimensions.sWidth, + dimensions.sHeight, + dimensions.dx, + dimensions.dy, + dimensions.dWidth, + dimensions.dHeight); + } + /** + * Creates a binaryBitmap based in some image source. + * + * @param mediaElement HTML element containing drawable image source. + */ + createBinaryBitmap(mediaElement) { + const ctx = this.getCaptureCanvasContext(mediaElement); + if (this._isHTMLVideoElement(mediaElement)) { + this.drawFrameOnCanvas(mediaElement); + } else { + this.drawImageOnCanvas(mediaElement); + } + const canvas = this.getCaptureCanvas(mediaElement); + const luminanceSource = new HTMLCanvasElementLuminanceSource(canvas); + const hybridBinarizer = new HybridBinarizer(luminanceSource); + + return new BinaryBitmap(hybridBinarizer); + } + + getCaptureCanvasContext(mediaElement) { + if (!this.captureCanvasContext) { + const elem = this.getCaptureCanvas(mediaElement); + const ctx = elem.getContext('2d'); + this.captureCanvasContext = ctx; + } + return this.captureCanvasContext; + } + getCaptureCanvas(mediaElement) { + if (!this.captureCanvas) { + const elem = this.createCaptureCanvas(mediaElement); + this.captureCanvas = elem; + } + return this.captureCanvas; + } + /** + * Call the encapsulated readers decode + */ + decodeBitmap(binaryBitmap) { + return this.reader.decode(binaryBitmap, this._hints); + } + /** + * 🖌 Prepares the canvas for capture and scan frames. + */ + createCaptureCanvas(mediaElement) { + if (typeof document === 'undefined') { + this._destroyCaptureCanvas(); + return null; + } + const canvasElement = document.createElement('canvas'); + let width; + let height; + if (typeof mediaElement !== 'undefined') { + if (mediaElement instanceof HTMLVideoElement) { + width = mediaElement.videoWidth; + height = mediaElement.videoHeight; + } + else if (mediaElement instanceof HTMLImageElement) { + width = mediaElement.naturalWidth || mediaElement.width; + height = mediaElement.naturalHeight || mediaElement.height; + } + } + canvasElement.style.width = width + 'px'; + canvasElement.style.height = height + 'px'; + canvasElement.width = width; + canvasElement.height = height; + return canvasElement; + } + /** + * Stops the continuous scan and cleans the stream. + */ + stopStreams() { + if (this.stream) { + this.stream.getVideoTracks().forEach(t => t.stop()); + this.stream = undefined; + } + if (this._stopAsyncDecode === false) { + this.stopAsyncDecode(); + } + if (this._stopContinuousDecode === false) { + this.stopContinuousDecode(); + } + } + /** + * Resets the code reader to the initial state. Cancels any ongoing barcode scanning from video or camera. + * + * @memberOf BrowserCodeReader + */ + reset() { + // stops the camera, preview and scan 🔴 + this.stopStreams(); + // clean and forget about HTML elements + this._destroyVideoElement(); + this._destroyImageElement(); + this._destroyCaptureCanvas(); + } + _destroyVideoElement() { + if (!this.videoElement) { + return; + } + // first gives freedon to the element 🕊 + if (typeof this.videoEndedListener !== 'undefined') { + this.videoElement.removeEventListener('ended', this.videoEndedListener); + } + if (typeof this.videoPlayingEventListener !== 'undefined') { + this.videoElement.removeEventListener('playing', this.videoPlayingEventListener); + } + if (typeof this.videoCanPlayListener !== 'undefined') { + this.videoElement.removeEventListener('loadedmetadata', this.videoCanPlayListener); + } + // then forgets about that element 😢 + this.cleanVideoSource(this.videoElement); + this.videoElement = undefined; + } + _destroyImageElement() { + if (!this.imageElement) { + return; + } + // first gives freedon to the element 🕊 + if (undefined !== this.imageLoadedListener) { + this.imageElement.removeEventListener('load', this.imageLoadedListener); + } + // then forget about that element 😢 + this.imageElement.src = undefined; + this.imageElement.removeAttribute('src'); + this.imageElement = undefined; + } + /** + * Cleans canvas references 🖌 + */ + _destroyCaptureCanvas() { + // then forget about that element 😢 + this.captureCanvasContext = undefined; + this.captureCanvas = undefined; + } + /** + * Defines what the videoElement src will be. + * + * @param videoElement + * @param stream + */ + addVideoSource(videoElement, stream) { + // Older browsers may not have `srcObject` + try { + // @note Throws Exception if interrupted by a new loaded request + videoElement.srcObject = stream; + } + catch (err) { + // @note Avoid using this in new browsers, as it is going away. + videoElement.src = URL.createObjectURL(stream); + } + } + /** + * Unbinds a HTML video src property. + * + * @param videoElement + */ + cleanVideoSource(videoElement) { + try { + videoElement.srcObject = null; + } + catch (err) { + videoElement.src = ''; + } + this.videoElement.removeAttribute('src'); + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Encapsulates the result of decoding a barcode within an image.</p> + * + * @author Sean Owen + */ + class Result { + // public constructor(private text: string, + // Uint8Array rawBytes, + // ResultPoconst resultPoints: Int32Array, + // BarcodeFormat format) { + // this(text, rawBytes, resultPoints, format, System.currentTimeMillis()) + // } + // public constructor(text: string, + // Uint8Array rawBytes, + // ResultPoconst resultPoints: Int32Array, + // BarcodeFormat format, + // long timestamp) { + // this(text, rawBytes, rawBytes == null ? 0 : 8 * rawBytes.length, + // resultPoints, format, timestamp) + // } + constructor(text, rawBytes, numBits = rawBytes == null ? 0 : 8 * rawBytes.length, resultPoints, format, timestamp = System.currentTimeMillis()) { + this.text = text; + this.rawBytes = rawBytes; + this.numBits = numBits; + this.resultPoints = resultPoints; + this.format = format; + this.timestamp = timestamp; + this.text = text; + this.rawBytes = rawBytes; + if (undefined === numBits || null === numBits) { + this.numBits = (rawBytes === null || rawBytes === undefined) ? 0 : 8 * rawBytes.length; + } + else { + this.numBits = numBits; + } + this.resultPoints = resultPoints; + this.format = format; + this.resultMetadata = null; + if (undefined === timestamp || null === timestamp) { + this.timestamp = System.currentTimeMillis(); + } + else { + this.timestamp = timestamp; + } + } + /** + * @return raw text encoded by the barcode + */ + getText() { + return this.text; + } + /** + * @return raw bytes encoded by the barcode, if applicable, otherwise {@code null} + */ + getRawBytes() { + return this.rawBytes; + } + /** + * @return how many bits of {@link #getRawBytes()} are valid; typically 8 times its length + * @since 3.3.0 + */ + getNumBits() { + return this.numBits; + } + /** + * @return points related to the barcode in the image. These are typically points + * identifying finder patterns or the corners of the barcode. The exact meaning is + * specific to the type of barcode that was decoded. + */ + getResultPoints() { + return this.resultPoints; + } + /** + * @return {@link BarcodeFormat} representing the format of the barcode that was decoded + */ + getBarcodeFormat() { + return this.format; + } + /** + * @return {@link Map} mapping {@link ResultMetadataType} keys to values. May be + * {@code null}. This contains optional metadata about what was detected about the barcode, + * like orientation. + */ + getResultMetadata() { + return this.resultMetadata; + } + putMetadata(type, value) { + if (this.resultMetadata === null) { + this.resultMetadata = new Map(); + } + this.resultMetadata.set(type, value); + } + putAllMetadata(metadata) { + if (metadata !== null) { + if (this.resultMetadata === null) { + this.resultMetadata = metadata; + } + else { + this.resultMetadata = new Map(metadata); + } + } + } + addResultPoints(newPoints) { + const oldPoints = this.resultPoints; + if (oldPoints === null) { + this.resultPoints = newPoints; + } + else if (newPoints !== null && newPoints.length > 0) { + const allPoints = new Array(oldPoints.length + newPoints.length); + System.arraycopy(oldPoints, 0, allPoints, 0, oldPoints.length); + System.arraycopy(newPoints, 0, allPoints, oldPoints.length, newPoints.length); + this.resultPoints = allPoints; + } + } + getTimestamp() { + return this.timestamp; + } + /*@Override*/ + toString() { + return this.text; + } + } + + /* + * Direct port to TypeScript of ZXing by Adrian Toșcă + */ + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*namespace com.google.zxing {*/ + /** + * Enumerates barcode formats known to this package. Please keep alphabetized. + * + * @author Sean Owen + */ + var BarcodeFormat; + (function (BarcodeFormat) { + /** Aztec 2D barcode format. */ + BarcodeFormat[BarcodeFormat["AZTEC"] = 0] = "AZTEC"; + /** CODABAR 1D format. */ + BarcodeFormat[BarcodeFormat["CODABAR"] = 1] = "CODABAR"; + /** Code 39 1D format. */ + BarcodeFormat[BarcodeFormat["CODE_39"] = 2] = "CODE_39"; + /** Code 93 1D format. */ + BarcodeFormat[BarcodeFormat["CODE_93"] = 3] = "CODE_93"; + /** Code 128 1D format. */ + BarcodeFormat[BarcodeFormat["CODE_128"] = 4] = "CODE_128"; + /** Data Matrix 2D barcode format. */ + BarcodeFormat[BarcodeFormat["DATA_MATRIX"] = 5] = "DATA_MATRIX"; + /** EAN-8 1D format. */ + BarcodeFormat[BarcodeFormat["EAN_8"] = 6] = "EAN_8"; + /** EAN-13 1D format. */ + BarcodeFormat[BarcodeFormat["EAN_13"] = 7] = "EAN_13"; + /** ITF (Interleaved Two of Five) 1D format. */ + BarcodeFormat[BarcodeFormat["ITF"] = 8] = "ITF"; + /** MaxiCode 2D barcode format. */ + BarcodeFormat[BarcodeFormat["MAXICODE"] = 9] = "MAXICODE"; + /** PDF417 format. */ + BarcodeFormat[BarcodeFormat["PDF_417"] = 10] = "PDF_417"; + /** QR Code 2D barcode format. */ + BarcodeFormat[BarcodeFormat["QR_CODE"] = 11] = "QR_CODE"; + /** RSS 14 */ + BarcodeFormat[BarcodeFormat["RSS_14"] = 12] = "RSS_14"; + /** RSS EXPANDED */ + BarcodeFormat[BarcodeFormat["RSS_EXPANDED"] = 13] = "RSS_EXPANDED"; + /** UPC-A 1D format. */ + BarcodeFormat[BarcodeFormat["UPC_A"] = 14] = "UPC_A"; + /** UPC-E 1D format. */ + BarcodeFormat[BarcodeFormat["UPC_E"] = 15] = "UPC_E"; + /** UPC/EAN extension format. Not a stand-alone format. */ + BarcodeFormat[BarcodeFormat["UPC_EAN_EXTENSION"] = 16] = "UPC_EAN_EXTENSION"; + })(BarcodeFormat || (BarcodeFormat = {})); + var BarcodeFormat$1 = BarcodeFormat; + + /*namespace com.google.zxing {*/ + /** + * Represents some type of metadata about the result of the decoding that the decoder + * wishes to communicate back to the caller. + * + * @author Sean Owen + */ + var ResultMetadataType; + (function (ResultMetadataType) { + /** + * Unspecified, application-specific metadata. Maps to an unspecified {@link Object}. + */ + ResultMetadataType[ResultMetadataType["OTHER"] = 0] = "OTHER"; + /** + * Denotes the likely approximate orientation of the barcode in the image. This value + * is given as degrees rotated clockwise from the normal, upright orientation. + * For example a 1D barcode which was found by reading top-to-bottom would be + * said to have orientation "90". This key maps to an {@link Integer} whose + * value is in the range [0,360). + */ + ResultMetadataType[ResultMetadataType["ORIENTATION"] = 1] = "ORIENTATION"; + /** + * <p>2D barcode formats typically encode text, but allow for a sort of 'byte mode' + * which is sometimes used to encode binary data. While {@link Result} makes available + * the complete raw bytes in the barcode for these formats, it does not offer the bytes + * from the byte segments alone.</p> + * + * <p>This maps to a {@link java.util.List} of byte arrays corresponding to the + * raw bytes in the byte segments in the barcode, in order.</p> + */ + ResultMetadataType[ResultMetadataType["BYTE_SEGMENTS"] = 2] = "BYTE_SEGMENTS"; + /** + * Error correction level used, if applicable. The value type depends on the + * format, but is typically a String. + */ + ResultMetadataType[ResultMetadataType["ERROR_CORRECTION_LEVEL"] = 3] = "ERROR_CORRECTION_LEVEL"; + /** + * For some periodicals, indicates the issue number as an {@link Integer}. + */ + ResultMetadataType[ResultMetadataType["ISSUE_NUMBER"] = 4] = "ISSUE_NUMBER"; + /** + * For some products, indicates the suggested retail price in the barcode as a + * formatted {@link String}. + */ + ResultMetadataType[ResultMetadataType["SUGGESTED_PRICE"] = 5] = "SUGGESTED_PRICE"; + /** + * For some products, the possible country of manufacture as a {@link String} denoting the + * ISO country code. Some map to multiple possible countries, like "US/CA". + */ + ResultMetadataType[ResultMetadataType["POSSIBLE_COUNTRY"] = 6] = "POSSIBLE_COUNTRY"; + /** + * For some products, the extension text + */ + ResultMetadataType[ResultMetadataType["UPC_EAN_EXTENSION"] = 7] = "UPC_EAN_EXTENSION"; + /** + * PDF417-specific metadata + */ + ResultMetadataType[ResultMetadataType["PDF417_EXTRA_METADATA"] = 8] = "PDF417_EXTRA_METADATA"; + /** + * If the code format supports structured append and the current scanned code is part of one then the + * sequence number is given with it. + */ + ResultMetadataType[ResultMetadataType["STRUCTURED_APPEND_SEQUENCE"] = 9] = "STRUCTURED_APPEND_SEQUENCE"; + /** + * If the code format supports structured append and the current scanned code is part of one then the + * parity is given with it. + */ + ResultMetadataType[ResultMetadataType["STRUCTURED_APPEND_PARITY"] = 10] = "STRUCTURED_APPEND_PARITY"; + })(ResultMetadataType || (ResultMetadataType = {})); + var ResultMetadataType$1 = ResultMetadataType; + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*namespace com.google.zxing.common {*/ + /*import java.util.List;*/ + /** + * <p>Encapsulates the result of decoding a matrix of bits. This typically + * applies to 2D barcode formats. For now it contains the raw bytes obtained, + * as well as a String interpretation of those bytes, if applicable.</p> + * + * @author Sean Owen + */ + class DecoderResult { + // public constructor(rawBytes: Uint8Array, + // text: string, + // List<Uint8Array> byteSegments, + // String ecLevel) { + // this(rawBytes, text, byteSegments, ecLevel, -1, -1) + // } + constructor(rawBytes, text, byteSegments, ecLevel, structuredAppendSequenceNumber = -1, structuredAppendParity = -1) { + this.rawBytes = rawBytes; + this.text = text; + this.byteSegments = byteSegments; + this.ecLevel = ecLevel; + this.structuredAppendSequenceNumber = structuredAppendSequenceNumber; + this.structuredAppendParity = structuredAppendParity; + this.numBits = (rawBytes === undefined || rawBytes === null) ? 0 : 8 * rawBytes.length; + } + /** + * @return raw bytes representing the result, or {@code null} if not applicable + */ + getRawBytes() { + return this.rawBytes; + } + /** + * @return how many bits of {@link #getRawBytes()} are valid; typically 8 times its length + * @since 3.3.0 + */ + getNumBits() { + return this.numBits; + } + /** + * @param numBits overrides the number of bits that are valid in {@link #getRawBytes()} + * @since 3.3.0 + */ + setNumBits(numBits /*int*/) { + this.numBits = numBits; + } + /** + * @return text representation of the result + */ + getText() { + return this.text; + } + /** + * @return list of byte segments in the result, or {@code null} if not applicable + */ + getByteSegments() { + return this.byteSegments; + } + /** + * @return name of error correction level used, or {@code null} if not applicable + */ + getECLevel() { + return this.ecLevel; + } + /** + * @return number of errors corrected, or {@code null} if not applicable + */ + getErrorsCorrected() { + return this.errorsCorrected; + } + setErrorsCorrected(errorsCorrected /*Integer*/) { + this.errorsCorrected = errorsCorrected; + } + /** + * @return number of erasures corrected, or {@code null} if not applicable + */ + getErasures() { + return this.erasures; + } + setErasures(erasures /*Integer*/) { + this.erasures = erasures; + } + /** + * @return arbitrary additional metadata + */ + getOther() { + return this.other; + } + setOther(other) { + this.other = other; + } + hasStructuredAppend() { + return this.structuredAppendParity >= 0 && this.structuredAppendSequenceNumber >= 0; + } + getStructuredAppendParity() { + return this.structuredAppendParity; + } + getStructuredAppendSequenceNumber() { + return this.structuredAppendSequenceNumber; + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>This class contains utility methods for performing mathematical operations over + * the Galois Fields. Operations use a given primitive polynomial in calculations.</p> + * + * <p>Throughout this package, elements of the GF are represented as an {@code int} + * for convenience and speed (but at the cost of memory). + * </p> + * + * @author Sean Owen + * @author David Olivier + */ + class AbstractGenericGF { + /** + * @return 2 to the power of a in GF(size) + */ + exp(a) { + return this.expTable[a]; + } + /** + * @return base 2 log of a in GF(size) + */ + log(a /*int*/) { + if (a === 0) { + throw new IllegalArgumentException(); + } + return this.logTable[a]; + } + /** + * Implements both addition and subtraction -- they are the same in GF(size). + * + * @return sum/difference of a and b + */ + static addOrSubtract(a /*int*/, b /*int*/) { + return a ^ b; + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Represents a polynomial whose coefficients are elements of a GF. + * Instances of this class are immutable.</p> + * + * <p>Much credit is due to William Rucklidge since portions of this code are an indirect + * port of his C++ Reed-Solomon implementation.</p> + * + * @author Sean Owen + */ + class GenericGFPoly { + /** + * @param field the {@link GenericGF} instance representing the field to use + * to perform computations + * @param coefficients coefficients as ints representing elements of GF(size), arranged + * from most significant (highest-power term) coefficient to least significant + * @throws IllegalArgumentException if argument is null or empty, + * or if leading coefficient is 0 and this is not a + * constant polynomial (that is, it is not the monomial "0") + */ + constructor(field, coefficients) { + if (coefficients.length === 0) { + throw new IllegalArgumentException(); + } + this.field = field; + const coefficientsLength = coefficients.length; + if (coefficientsLength > 1 && coefficients[0] === 0) { + // Leading term must be non-zero for anything except the constant polynomial "0" + let firstNonZero = 1; + while (firstNonZero < coefficientsLength && coefficients[firstNonZero] === 0) { + firstNonZero++; + } + if (firstNonZero === coefficientsLength) { + this.coefficients = Int32Array.from([0]); + } + else { + this.coefficients = new Int32Array(coefficientsLength - firstNonZero); + System.arraycopy(coefficients, firstNonZero, this.coefficients, 0, this.coefficients.length); + } + } + else { + this.coefficients = coefficients; + } + } + getCoefficients() { + return this.coefficients; + } + /** + * @return degree of this polynomial + */ + getDegree() { + return this.coefficients.length - 1; + } + /** + * @return true iff this polynomial is the monomial "0" + */ + isZero() { + return this.coefficients[0] === 0; + } + /** + * @return coefficient of x^degree term in this polynomial + */ + getCoefficient(degree /*int*/) { + return this.coefficients[this.coefficients.length - 1 - degree]; + } + /** + * @return evaluation of this polynomial at a given point + */ + evaluateAt(a /*int*/) { + if (a === 0) { + // Just return the x^0 coefficient + return this.getCoefficient(0); + } + const coefficients = this.coefficients; + let result; + if (a === 1) { + // Just the sum of the coefficients + result = 0; + for (let i = 0, length = coefficients.length; i !== length; i++) { + const coefficient = coefficients[i]; + result = AbstractGenericGF.addOrSubtract(result, coefficient); + } + return result; + } + result = coefficients[0]; + const size = coefficients.length; + const field = this.field; + for (let i = 1; i < size; i++) { + result = AbstractGenericGF.addOrSubtract(field.multiply(a, result), coefficients[i]); + } + return result; + } + addOrSubtract(other) { + if (!this.field.equals(other.field)) { + throw new IllegalArgumentException('GenericGFPolys do not have same GenericGF field'); + } + if (this.isZero()) { + return other; + } + if (other.isZero()) { + return this; + } + let smallerCoefficients = this.coefficients; + let largerCoefficients = other.coefficients; + if (smallerCoefficients.length > largerCoefficients.length) { + const temp = smallerCoefficients; + smallerCoefficients = largerCoefficients; + largerCoefficients = temp; + } + let sumDiff = new Int32Array(largerCoefficients.length); + const lengthDiff = largerCoefficients.length - smallerCoefficients.length; + // Copy high-order terms only found in higher-degree polynomial's coefficients + System.arraycopy(largerCoefficients, 0, sumDiff, 0, lengthDiff); + for (let i = lengthDiff; i < largerCoefficients.length; i++) { + sumDiff[i] = AbstractGenericGF.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]); + } + return new GenericGFPoly(this.field, sumDiff); + } + multiply(other) { + if (!this.field.equals(other.field)) { + throw new IllegalArgumentException('GenericGFPolys do not have same GenericGF field'); + } + if (this.isZero() || other.isZero()) { + return this.field.getZero(); + } + const aCoefficients = this.coefficients; + const aLength = aCoefficients.length; + const bCoefficients = other.coefficients; + const bLength = bCoefficients.length; + const product = new Int32Array(aLength + bLength - 1); + const field = this.field; + for (let i = 0; i < aLength; i++) { + const aCoeff = aCoefficients[i]; + for (let j = 0; j < bLength; j++) { + product[i + j] = AbstractGenericGF.addOrSubtract(product[i + j], field.multiply(aCoeff, bCoefficients[j])); + } + } + return new GenericGFPoly(field, product); + } + multiplyScalar(scalar /*int*/) { + if (scalar === 0) { + return this.field.getZero(); + } + if (scalar === 1) { + return this; + } + const size = this.coefficients.length; + const field = this.field; + const product = new Int32Array(size); + const coefficients = this.coefficients; + for (let i = 0; i < size; i++) { + product[i] = field.multiply(coefficients[i], scalar); + } + return new GenericGFPoly(field, product); + } + multiplyByMonomial(degree /*int*/, coefficient /*int*/) { + if (degree < 0) { + throw new IllegalArgumentException(); + } + if (coefficient === 0) { + return this.field.getZero(); + } + const coefficients = this.coefficients; + const size = coefficients.length; + const product = new Int32Array(size + degree); + const field = this.field; + for (let i = 0; i < size; i++) { + product[i] = field.multiply(coefficients[i], coefficient); + } + return new GenericGFPoly(field, product); + } + divide(other) { + if (!this.field.equals(other.field)) { + throw new IllegalArgumentException('GenericGFPolys do not have same GenericGF field'); + } + if (other.isZero()) { + throw new IllegalArgumentException('Divide by 0'); + } + const field = this.field; + let quotient = field.getZero(); + let remainder = this; + const denominatorLeadingTerm = other.getCoefficient(other.getDegree()); + const inverseDenominatorLeadingTerm = field.inverse(denominatorLeadingTerm); + while (remainder.getDegree() >= other.getDegree() && !remainder.isZero()) { + const degreeDifference = remainder.getDegree() - other.getDegree(); + const scale = field.multiply(remainder.getCoefficient(remainder.getDegree()), inverseDenominatorLeadingTerm); + const term = other.multiplyByMonomial(degreeDifference, scale); + const iterationQuotient = field.buildMonomial(degreeDifference, scale); + quotient = quotient.addOrSubtract(iterationQuotient); + remainder = remainder.addOrSubtract(term); + } + return [quotient, remainder]; + } + /*@Override*/ + toString() { + let result = ''; + for (let degree = this.getDegree(); degree >= 0; degree--) { + let coefficient = this.getCoefficient(degree); + if (coefficient !== 0) { + if (coefficient < 0) { + result += ' - '; + coefficient = -coefficient; + } + else { + if (result.length > 0) { + result += ' + '; + } + } + if (degree === 0 || coefficient !== 1) { + const alphaPower = this.field.log(coefficient); + if (alphaPower === 0) { + result += '1'; + } + else if (alphaPower === 1) { + result += 'a'; + } + else { + result += 'a^'; + result += alphaPower; + } + } + if (degree !== 0) { + if (degree === 1) { + result += 'x'; + } + else { + result += 'x^'; + result += degree; + } + } + } + } + return result; + } + } + + /** + * Custom Error class of type Exception. + */ + class ArithmeticException extends Exception { + } + ArithmeticException.kind = 'ArithmeticException'; + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>This class contains utility methods for performing mathematical operations over + * the Galois Fields. Operations use a given primitive polynomial in calculations.</p> + * + * <p>Throughout this package, elements of the GF are represented as an {@code int} + * for convenience and speed (but at the cost of memory). + * </p> + * + * @author Sean Owen + * @author David Olivier + */ + class GenericGF extends AbstractGenericGF { + /** + * Create a representation of GF(size) using the given primitive polynomial. + * + * @param primitive irreducible polynomial whose coefficients are represented by + * the bits of an int, where the least-significant bit represents the constant + * coefficient + * @param size the size of the field + * @param b the factor b in the generator polynomial can be 0- or 1-based + * (g(x) = (x+a^b)(x+a^(b+1))...(x+a^(b+2t-1))). + * In most cases it should be 1, but for QR code it is 0. + */ + constructor(primitive /*int*/, size /*int*/, generatorBase /*int*/) { + super(); + this.primitive = primitive; + this.size = size; + this.generatorBase = generatorBase; + const expTable = new Int32Array(size); + let x = 1; + for (let i = 0; i < size; i++) { + expTable[i] = x; + x *= 2; // we're assuming the generator alpha is 2 + if (x >= size) { + x ^= primitive; + x &= size - 1; + } + } + this.expTable = expTable; + const logTable = new Int32Array(size); + for (let i = 0; i < size - 1; i++) { + logTable[expTable[i]] = i; + } + this.logTable = logTable; + // logTable[0] == 0 but this should never be used + this.zero = new GenericGFPoly(this, Int32Array.from([0])); + this.one = new GenericGFPoly(this, Int32Array.from([1])); + } + getZero() { + return this.zero; + } + getOne() { + return this.one; + } + /** + * @return the monomial representing coefficient * x^degree + */ + buildMonomial(degree /*int*/, coefficient /*int*/) { + if (degree < 0) { + throw new IllegalArgumentException(); + } + if (coefficient === 0) { + return this.zero; + } + const coefficients = new Int32Array(degree + 1); + coefficients[0] = coefficient; + return new GenericGFPoly(this, coefficients); + } + /** + * @return multiplicative inverse of a + */ + inverse(a /*int*/) { + if (a === 0) { + throw new ArithmeticException(); + } + return this.expTable[this.size - this.logTable[a] - 1]; + } + /** + * @return product of a and b in GF(size) + */ + multiply(a /*int*/, b /*int*/) { + if (a === 0 || b === 0) { + return 0; + } + return this.expTable[(this.logTable[a] + this.logTable[b]) % (this.size - 1)]; + } + getSize() { + return this.size; + } + getGeneratorBase() { + return this.generatorBase; + } + /*@Override*/ + toString() { + return ('GF(0x' + Integer.toHexString(this.primitive) + ',' + this.size + ')'); + } + equals(o) { + return o === this; + } + } + GenericGF.AZTEC_DATA_12 = new GenericGF(0x1069, 4096, 1); // x^12 + x^6 + x^5 + x^3 + 1 + GenericGF.AZTEC_DATA_10 = new GenericGF(0x409, 1024, 1); // x^10 + x^3 + 1 + GenericGF.AZTEC_DATA_6 = new GenericGF(0x43, 64, 1); // x^6 + x + 1 + GenericGF.AZTEC_PARAM = new GenericGF(0x13, 16, 1); // x^4 + x + 1 + GenericGF.QR_CODE_FIELD_256 = new GenericGF(0x011d, 256, 0); // x^8 + x^4 + x^3 + x^2 + 1 + GenericGF.DATA_MATRIX_FIELD_256 = new GenericGF(0x012d, 256, 1); // x^8 + x^5 + x^3 + x^2 + 1 + GenericGF.AZTEC_DATA_8 = GenericGF.DATA_MATRIX_FIELD_256; + GenericGF.MAXICODE_FIELD_64 = GenericGF.AZTEC_DATA_6; + + /** + * Custom Error class of type Exception. + */ + class ReedSolomonException extends Exception { + } + ReedSolomonException.kind = 'ReedSolomonException'; + + /** + * Custom Error class of type Exception. + */ + class IllegalStateException extends Exception { + } + IllegalStateException.kind = 'IllegalStateException'; + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Implements Reed-Solomon decoding, as the name implies.</p> + * + * <p>The algorithm will not be explained here, but the following references were helpful + * in creating this implementation:</p> + * + * <ul> + * <li>Bruce Maggs. + * <a href="http://www.cs.cmu.edu/afs/cs.cmu.edu/project/pscico-guyb/realworld/www/rs_decode.ps"> + * "Decoding Reed-Solomon Codes"</a> (see discussion of Forney's Formula)</li> + * <li>J.I. Hall. <a href="www.mth.msu.edu/~jhall/classes/codenotes/GRS.pdf"> + * "Chapter 5. Generalized Reed-Solomon Codes"</a> + * (see discussion of Euclidean algorithm)</li> + * </ul> + * + * <p>Much credit is due to William Rucklidge since portions of this code are an indirect + * port of his C++ Reed-Solomon implementation.</p> + * + * @author Sean Owen + * @author William Rucklidge + * @author sanfordsquires + */ + class ReedSolomonDecoder { + constructor(field) { + this.field = field; + } + /** + * <p>Decodes given set of received codewords, which include both data and error-correction + * codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place, + * in the input.</p> + * + * @param received data and error-correction codewords + * @param twoS number of error-correction codewords available + * @throws ReedSolomonException if decoding fails for any reason + */ + decode(received, twoS /*int*/) { + const field = this.field; + const poly = new GenericGFPoly(field, received); + const syndromeCoefficients = new Int32Array(twoS); + let noError = true; + for (let i = 0; i < twoS; i++) { + const evalResult = poly.evaluateAt(field.exp(i + field.getGeneratorBase())); + syndromeCoefficients[syndromeCoefficients.length - 1 - i] = evalResult; + if (evalResult !== 0) { + noError = false; + } + } + if (noError) { + return; + } + const syndrome = new GenericGFPoly(field, syndromeCoefficients); + const sigmaOmega = this.runEuclideanAlgorithm(field.buildMonomial(twoS, 1), syndrome, twoS); + const sigma = sigmaOmega[0]; + const omega = sigmaOmega[1]; + const errorLocations = this.findErrorLocations(sigma); + const errorMagnitudes = this.findErrorMagnitudes(omega, errorLocations); + for (let i = 0; i < errorLocations.length; i++) { + const position = received.length - 1 - field.log(errorLocations[i]); + if (position < 0) { + throw new ReedSolomonException('Bad error location'); + } + received[position] = GenericGF.addOrSubtract(received[position], errorMagnitudes[i]); + } + } + runEuclideanAlgorithm(a, b, R /*int*/) { + // Assume a's degree is >= b's + if (a.getDegree() < b.getDegree()) { + const temp = a; + a = b; + b = temp; + } + const field = this.field; + let rLast = a; + let r = b; + let tLast = field.getZero(); + let t = field.getOne(); + // Run Euclidean algorithm until r's degree is less than R/2 + while (r.getDegree() >= (R / 2 | 0)) { + let rLastLast = rLast; + let tLastLast = tLast; + rLast = r; + tLast = t; + // Divide rLastLast by rLast, with quotient in q and remainder in r + if (rLast.isZero()) { + // Oops, Euclidean algorithm already terminated? + throw new ReedSolomonException('r_{i-1} was zero'); + } + r = rLastLast; + let q = field.getZero(); + const denominatorLeadingTerm = rLast.getCoefficient(rLast.getDegree()); + const dltInverse = field.inverse(denominatorLeadingTerm); + while (r.getDegree() >= rLast.getDegree() && !r.isZero()) { + const degreeDiff = r.getDegree() - rLast.getDegree(); + const scale = field.multiply(r.getCoefficient(r.getDegree()), dltInverse); + q = q.addOrSubtract(field.buildMonomial(degreeDiff, scale)); + r = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale)); + } + t = q.multiply(tLast).addOrSubtract(tLastLast); + if (r.getDegree() >= rLast.getDegree()) { + throw new IllegalStateException('Division algorithm failed to reduce polynomial?'); + } + } + const sigmaTildeAtZero = t.getCoefficient(0); + if (sigmaTildeAtZero === 0) { + throw new ReedSolomonException('sigmaTilde(0) was zero'); + } + const inverse = field.inverse(sigmaTildeAtZero); + const sigma = t.multiplyScalar(inverse); + const omega = r.multiplyScalar(inverse); + return [sigma, omega]; + } + findErrorLocations(errorLocator) { + // This is a direct application of Chien's search + const numErrors = errorLocator.getDegree(); + if (numErrors === 1) { // shortcut + return Int32Array.from([errorLocator.getCoefficient(1)]); + } + const result = new Int32Array(numErrors); + let e = 0; + const field = this.field; + for (let i = 1; i < field.getSize() && e < numErrors; i++) { + if (errorLocator.evaluateAt(i) === 0) { + result[e] = field.inverse(i); + e++; + } + } + if (e !== numErrors) { + throw new ReedSolomonException('Error locator degree does not match number of roots'); + } + return result; + } + findErrorMagnitudes(errorEvaluator, errorLocations) { + // This is directly applying Forney's Formula + const s = errorLocations.length; + const result = new Int32Array(s); + const field = this.field; + for (let i = 0; i < s; i++) { + const xiInverse = field.inverse(errorLocations[i]); + let denominator = 1; + for (let j = 0; j < s; j++) { + if (i !== j) { + // denominator = field.multiply(denominator, + // GenericGF.addOrSubtract(1, field.multiply(errorLocations[j], xiInverse))) + // Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug. + // Below is a funny-looking workaround from Steven Parkes + const term = field.multiply(errorLocations[j], xiInverse); + const termPlus1 = (term & 0x1) === 0 ? term | 1 : term & ~1; + denominator = field.multiply(denominator, termPlus1); + } + } + result[i] = field.multiply(errorEvaluator.evaluateAt(xiInverse), field.inverse(denominator)); + if (field.getGeneratorBase() !== 0) { + result[i] = field.multiply(result[i], xiInverse); + } + } + return result; + } + } + + /* + * Copyright 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // import java.util.Arrays; + var Table; + (function (Table) { + Table[Table["UPPER"] = 0] = "UPPER"; + Table[Table["LOWER"] = 1] = "LOWER"; + Table[Table["MIXED"] = 2] = "MIXED"; + Table[Table["DIGIT"] = 3] = "DIGIT"; + Table[Table["PUNCT"] = 4] = "PUNCT"; + Table[Table["BINARY"] = 5] = "BINARY"; + })(Table || (Table = {})); + /** + * <p>The main class which implements Aztec Code decoding -- as opposed to locating and extracting + * the Aztec Code from an image.</p> + * + * @author David Olivier + */ + class Decoder { + decode(detectorResult) { + this.ddata = detectorResult; + let matrix = detectorResult.getBits(); + let rawbits = this.extractBits(matrix); + let correctedBits = this.correctBits(rawbits); + let rawBytes = Decoder.convertBoolArrayToByteArray(correctedBits); + let result = Decoder.getEncodedData(correctedBits); + let decoderResult = new DecoderResult(rawBytes, result, null, null); + decoderResult.setNumBits(correctedBits.length); + return decoderResult; + } + // This method is used for testing the high-level encoder + static highLevelDecode(correctedBits) { + return this.getEncodedData(correctedBits); + } + /** + * Gets the string encoded in the aztec code bits + * + * @return the decoded string + */ + static getEncodedData(correctedBits) { + let endIndex = correctedBits.length; + let latchTable = Table.UPPER; // table most recently latched to + let shiftTable = Table.UPPER; // table to use for the next read + let result = ''; + let index = 0; + while (index < endIndex) { + if (shiftTable === Table.BINARY) { + if (endIndex - index < 5) { + break; + } + let length = Decoder.readCode(correctedBits, index, 5); + index += 5; + if (length === 0) { + if (endIndex - index < 11) { + break; + } + length = Decoder.readCode(correctedBits, index, 11) + 31; + index += 11; + } + for (let charCount = 0; charCount < length; charCount++) { + if (endIndex - index < 8) { + index = endIndex; // Force outer loop to exit + break; + } + const code = Decoder.readCode(correctedBits, index, 8); + result += /*(char)*/ StringUtils.castAsNonUtf8Char(code); + index += 8; + } + // Go back to whatever mode we had been in + shiftTable = latchTable; + } + else { + let size = shiftTable === Table.DIGIT ? 4 : 5; + if (endIndex - index < size) { + break; + } + let code = Decoder.readCode(correctedBits, index, size); + index += size; + let str = Decoder.getCharacter(shiftTable, code); + if (str.startsWith('CTRL_')) { + // Table changes + // ISO/IEC 24778:2008 prescribes ending a shift sequence in the mode from which it was invoked. + // That's including when that mode is a shift. + // Our test case dlusbs.png for issue #642 exercises that. + latchTable = shiftTable; // Latch the current mode, so as to return to Upper after U/S B/S + shiftTable = Decoder.getTable(str.charAt(5)); + if (str.charAt(6) === 'L') { + latchTable = shiftTable; + } + } + else { + result += str; + // Go back to whatever mode we had been in + shiftTable = latchTable; + } + } + } + return result; + } + /** + * gets the table corresponding to the char passed + */ + static getTable(t) { + switch (t) { + case 'L': + return Table.LOWER; + case 'P': + return Table.PUNCT; + case 'M': + return Table.MIXED; + case 'D': + return Table.DIGIT; + case 'B': + return Table.BINARY; + case 'U': + default: + return Table.UPPER; + } + } + /** + * Gets the character (or string) corresponding to the passed code in the given table + * + * @param table the table used + * @param code the code of the character + */ + static getCharacter(table, code) { + switch (table) { + case Table.UPPER: + return Decoder.UPPER_TABLE[code]; + case Table.LOWER: + return Decoder.LOWER_TABLE[code]; + case Table.MIXED: + return Decoder.MIXED_TABLE[code]; + case Table.PUNCT: + return Decoder.PUNCT_TABLE[code]; + case Table.DIGIT: + return Decoder.DIGIT_TABLE[code]; + default: + // Should not reach here. + throw new IllegalStateException('Bad table'); + } + } + /** + * <p>Performs RS error correction on an array of bits.</p> + * + * @return the corrected array + * @throws FormatException if the input contains too many errors + */ + correctBits(rawbits) { + let gf; + let codewordSize; + if (this.ddata.getNbLayers() <= 2) { + codewordSize = 6; + gf = GenericGF.AZTEC_DATA_6; + } + else if (this.ddata.getNbLayers() <= 8) { + codewordSize = 8; + gf = GenericGF.AZTEC_DATA_8; + } + else if (this.ddata.getNbLayers() <= 22) { + codewordSize = 10; + gf = GenericGF.AZTEC_DATA_10; + } + else { + codewordSize = 12; + gf = GenericGF.AZTEC_DATA_12; + } + let numDataCodewords = this.ddata.getNbDatablocks(); + let numCodewords = rawbits.length / codewordSize; + if (numCodewords < numDataCodewords) { + throw new FormatException(); + } + let offset = rawbits.length % codewordSize; + let dataWords = new Int32Array(numCodewords); + for (let i = 0; i < numCodewords; i++, offset += codewordSize) { + dataWords[i] = Decoder.readCode(rawbits, offset, codewordSize); + } + try { + let rsDecoder = new ReedSolomonDecoder(gf); + rsDecoder.decode(dataWords, numCodewords - numDataCodewords); + } + catch (ex) { + throw new FormatException(ex); + } + // Now perform the unstuffing operation. + // First, count how many bits are going to be thrown out as stuffing + let mask = (1 << codewordSize) - 1; + let stuffedBits = 0; + for (let i = 0; i < numDataCodewords; i++) { + let dataWord = dataWords[i]; + if (dataWord === 0 || dataWord === mask) { + throw new FormatException(); + } + else if (dataWord === 1 || dataWord === mask - 1) { + stuffedBits++; + } + } + // Now, actually unpack the bits and remove the stuffing + let correctedBits = new Array(numDataCodewords * codewordSize - stuffedBits); + let index = 0; + for (let i = 0; i < numDataCodewords; i++) { + let dataWord = dataWords[i]; + if (dataWord === 1 || dataWord === mask - 1) { + // next codewordSize-1 bits are all zeros or all ones + correctedBits.fill(dataWord > 1, index, index + codewordSize - 1); + // Arrays.fill(correctedBits, index, index + codewordSize - 1, dataWord > 1); + index += codewordSize - 1; + } + else { + for (let bit = codewordSize - 1; bit >= 0; --bit) { + correctedBits[index++] = (dataWord & (1 << bit)) !== 0; + } + } + } + return correctedBits; + } + /** + * Gets the array of bits from an Aztec Code matrix + * + * @return the array of bits + */ + extractBits(matrix) { + let compact = this.ddata.isCompact(); + let layers = this.ddata.getNbLayers(); + let baseMatrixSize = (compact ? 11 : 14) + layers * 4; // not including alignment lines + let alignmentMap = new Int32Array(baseMatrixSize); + let rawbits = new Array(this.totalBitsInLayer(layers, compact)); + if (compact) { + for (let i = 0; i < alignmentMap.length; i++) { + alignmentMap[i] = i; + } + } + else { + let matrixSize = baseMatrixSize + 1 + 2 * Integer.truncDivision((Integer.truncDivision(baseMatrixSize, 2) - 1), 15); + let origCenter = baseMatrixSize / 2; + let center = Integer.truncDivision(matrixSize, 2); + for (let i = 0; i < origCenter; i++) { + let newOffset = i + Integer.truncDivision(i, 15); + alignmentMap[origCenter - i - 1] = center - newOffset - 1; + alignmentMap[origCenter + i] = center + newOffset + 1; + } + } + for (let i = 0, rowOffset = 0; i < layers; i++) { + let rowSize = (layers - i) * 4 + (compact ? 9 : 12); + // The top-left most point of this layer is <low, low> (not including alignment lines) + let low = i * 2; + // The bottom-right most point of this layer is <high, high> (not including alignment lines) + let high = baseMatrixSize - 1 - low; + // We pull bits from the two 2 x rowSize columns and two rowSize x 2 rows + for (let j = 0; j < rowSize; j++) { + let columnOffset = j * 2; + for (let k = 0; k < 2; k++) { + // left column + rawbits[rowOffset + columnOffset + k] = + matrix.get(alignmentMap[low + k], alignmentMap[low + j]); + // bottom row + rawbits[rowOffset + 2 * rowSize + columnOffset + k] = + matrix.get(alignmentMap[low + j], alignmentMap[high - k]); + // right column + rawbits[rowOffset + 4 * rowSize + columnOffset + k] = + matrix.get(alignmentMap[high - k], alignmentMap[high - j]); + // top row + rawbits[rowOffset + 6 * rowSize + columnOffset + k] = + matrix.get(alignmentMap[high - j], alignmentMap[low + k]); + } + } + rowOffset += rowSize * 8; + } + return rawbits; + } + /** + * Reads a code of given length and at given index in an array of bits + */ + static readCode(rawbits, startIndex, length) { + let res = 0; + for (let i = startIndex; i < startIndex + length; i++) { + res <<= 1; + if (rawbits[i]) { + res |= 0x01; + } + } + return res; + } + /** + * Reads a code of length 8 in an array of bits, padding with zeros + */ + static readByte(rawbits, startIndex) { + let n = rawbits.length - startIndex; + if (n >= 8) { + return Decoder.readCode(rawbits, startIndex, 8); + } + return Decoder.readCode(rawbits, startIndex, n) << (8 - n); + } + /** + * Packs a bit array into bytes, most significant bit first + */ + static convertBoolArrayToByteArray(boolArr) { + let byteArr = new Uint8Array((boolArr.length + 7) / 8); + for (let i = 0; i < byteArr.length; i++) { + byteArr[i] = Decoder.readByte(boolArr, 8 * i); + } + return byteArr; + } + totalBitsInLayer(layers, compact) { + return ((compact ? 88 : 112) + 16 * layers) * layers; + } + } + Decoder.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' + ]; + Decoder.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' + ]; + Decoder.MIXED_TABLE = [ + // Module parse failed: Octal literal in strict mode (50:29) + // so number string were scaped + 'CTRL_PS', ' ', '\\1', '\\2', '\\3', '\\4', '\\5', '\\6', '\\7', '\b', '\t', '\n', + '\\13', '\f', '\r', '\\33', '\\34', '\\35', '\\36', '\\37', '@', '\\', '^', '_', + '`', '|', '~', '\\177', 'CTRL_LL', 'CTRL_UL', 'CTRL_PL', 'CTRL_BS' + ]; + Decoder.PUNCT_TABLE = [ + '', '\r', '\r\n', '. ', ', ', ': ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', + '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '{', '}', 'CTRL_UL' + ]; + Decoder.DIGIT_TABLE = [ + 'CTRL_PS', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ',', '.', 'CTRL_UL', 'CTRL_US' + ]; + + /* + * Copyright 2012 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*namespace com.google.zxing.common.detector {*/ + /** + * General math-related and numeric utility functions. + */ + class MathUtils { + constructor() { } + /** + * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its + * argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut + * differ slightly from {@link Math#round(float)} in that half rounds down for negative + * values. -2.5 rounds to -3, not -2. For purposes here it makes no difference. + * + * @param d real value to round + * @return nearest {@code int} + */ + static round(d /*float*/) { + if (NaN === d) + return 0; + if (d <= Number.MIN_SAFE_INTEGER) + return Number.MIN_SAFE_INTEGER; + if (d >= Number.MAX_SAFE_INTEGER) + return Number.MAX_SAFE_INTEGER; + return /*(int) */ (d + (d < 0.0 ? -0.5 : 0.5)) | 0; + } + // TYPESCRIPTPORT: maybe remove round method and call directly Math.round, it looks like it doesn't make sense for js + /** + * @param aX point A x coordinate + * @param aY point A y coordinate + * @param bX point B x coordinate + * @param bY point B y coordinate + * @return Euclidean distance between points A and B + */ + static distance(aX /*float|int*/, aY /*float|int*/, bX /*float|int*/, bY /*float|int*/) { + const xDiff = aX - bX; + const yDiff = aY - bY; + return /*(float) */ Math.sqrt(xDiff * xDiff + yDiff * yDiff); + } + /** + * @param aX point A x coordinate + * @param aY point A y coordinate + * @param bX point B x coordinate + * @param bY point B y coordinate + * @return Euclidean distance between points A and B + */ + // public static distance(aX: number /*int*/, aY: number /*int*/, bX: number /*int*/, bY: number /*int*/): float { + // const xDiff = aX - bX + // const yDiff = aY - bY + // return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff); + // } + /** + * @param array values to sum + * @return sum of values in array + */ + static sum(array) { + let count = 0; + for (let i = 0, length = array.length; i !== length; i++) { + const a = array[i]; + count += a; + } + return count; + } + } + + /** + * Ponyfill for Java's Float class. + */ + class Float { + /** + * SincTS has no difference between int and float, there's all numbers, + * this is used only to polyfill Java code. + */ + static floatToIntBits(f) { + return f; + } + } + /** + * The float max value in JS is the number max value. + */ + Float.MAX_VALUE = Number.MAX_SAFE_INTEGER; + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Encapsulates a point of interest in an image containing a barcode. Typically, this + * would be the location of a finder pattern or the corner of the barcode, for example.</p> + * + * @author Sean Owen + */ + class ResultPoint { + constructor(x, y) { + this.x = x; + this.y = y; + } + getX() { + return this.x; + } + getY() { + return this.y; + } + /*@Override*/ + equals(other) { + if (other instanceof ResultPoint) { + const otherPoint = other; + return this.x === otherPoint.x && this.y === otherPoint.y; + } + return false; + } + /*@Override*/ + hashCode() { + return 31 * Float.floatToIntBits(this.x) + Float.floatToIntBits(this.y); + } + /*@Override*/ + toString() { + return '(' + this.x + ',' + this.y + ')'; + } + /** + * Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC + * and BC is less than AC, and the angle between BC and BA is less than 180 degrees. + * + * @param patterns array of three {@code ResultPoint} to order + */ + static orderBestPatterns(patterns) { + // Find distances between pattern centers + const zeroOneDistance = this.distance(patterns[0], patterns[1]); + const oneTwoDistance = this.distance(patterns[1], patterns[2]); + const zeroTwoDistance = this.distance(patterns[0], patterns[2]); + let pointA; + let pointB; + let pointC; + // Assume one closest to other two is B; A and C will just be guesses at first + if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) { + pointB = patterns[0]; + pointA = patterns[1]; + pointC = patterns[2]; + } + else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) { + pointB = patterns[1]; + pointA = patterns[0]; + pointC = patterns[2]; + } + else { + pointB = patterns[2]; + pointA = patterns[0]; + pointC = patterns[1]; + } + // Use cross product to figure out whether A and C are correct or flipped. + // This asks whether BC x BA has a positive z component, which is the arrangement + // we want for A, B, C. If it's negative, then we've got it flipped around and + // should swap A and C. + if (this.crossProductZ(pointA, pointB, pointC) < 0.0) { + const temp = pointA; + pointA = pointC; + pointC = temp; + } + patterns[0] = pointA; + patterns[1] = pointB; + patterns[2] = pointC; + } + /** + * @param pattern1 first pattern + * @param pattern2 second pattern + * @return distance between two points + */ + static distance(pattern1, pattern2) { + return MathUtils.distance(pattern1.x, pattern1.y, pattern2.x, pattern2.y); + } + /** + * Returns the z component of the cross product between vectors BC and BA. + */ + static crossProductZ(pointA, pointB, pointC) { + const bX = pointB.x; + const bY = pointB.y; + return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX)); + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Encapsulates the result of detecting a barcode in an image. This includes the raw + * matrix of black/white pixels corresponding to the barcode, and possibly points of interest + * in the image, like the location of finder patterns or corners of the barcode in the image.</p> + * + * @author Sean Owen + */ + class DetectorResult { + constructor(bits, points) { + this.bits = bits; + this.points = points; + } + getBits() { + return this.bits; + } + getPoints() { + return this.points; + } + } + + /* + * Copyright 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Extends {@link DetectorResult} with more information specific to the Aztec format, + * like the number of layers and whether it's compact.</p> + * + * @author Sean Owen + */ + class AztecDetectorResult extends DetectorResult { + constructor(bits, points, compact, nbDatablocks, nbLayers) { + super(bits, points); + this.compact = compact; + this.nbDatablocks = nbDatablocks; + this.nbLayers = nbLayers; + } + getNbLayers() { + return this.nbLayers; + } + getNbDatablocks() { + return this.nbDatablocks; + } + isCompact() { + return this.compact; + } + } + + /* + * Copyright 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p> + * Detects a candidate barcode-like rectangular region within an image. It + * starts around the center of the image, increases the size of the candidate + * region until it finds a white rectangular region. By keeping track of the + * last black points it encountered, it determines the corners of the barcode. + * </p> + * + * @author David Olivier + */ + class WhiteRectangleDetector { + // public constructor(private image: BitMatrix) /*throws NotFoundException*/ { + // this(image, INIT_SIZE, image.getWidth() / 2, image.getHeight() / 2) + // } + /** + * @param image barcode image to find a rectangle in + * @param initSize initial size of search area around center + * @param x x position of search center + * @param y y position of search center + * @throws NotFoundException if image is too small to accommodate {@code initSize} + */ + constructor(image, initSize /*int*/, x /*int*/, y /*int*/) { + this.image = image; + this.height = image.getHeight(); + this.width = image.getWidth(); + if (undefined === initSize || null === initSize) { + initSize = WhiteRectangleDetector.INIT_SIZE; + } + if (undefined === x || null === x) { + x = image.getWidth() / 2 | 0; + } + if (undefined === y || null === y) { + y = image.getHeight() / 2 | 0; + } + const halfsize = initSize / 2 | 0; + this.leftInit = x - halfsize; + this.rightInit = x + halfsize; + this.upInit = y - halfsize; + this.downInit = y + halfsize; + if (this.upInit < 0 || this.leftInit < 0 || this.downInit >= this.height || this.rightInit >= this.width) { + throw new NotFoundException(); + } + } + /** + * <p> + * Detects a candidate barcode-like rectangular region within an image. It + * starts around the center of the image, increases the size of the candidate + * region until it finds a white rectangular region. + * </p> + * + * @return {@link ResultPoint}[] describing the corners of the rectangular + * region. The first and last points are opposed on the diagonal, as + * are the second and third. The first point will be the topmost + * point and the last, the bottommost. The second point will be + * leftmost and the third, the rightmost + * @throws NotFoundException if no Data Matrix Code can be found + */ + detect() { + let left = this.leftInit; + let right = this.rightInit; + let up = this.upInit; + let down = this.downInit; + let sizeExceeded = false; + let aBlackPointFoundOnBorder = true; + let atLeastOneBlackPointFoundOnBorder = false; + let atLeastOneBlackPointFoundOnRight = false; + let atLeastOneBlackPointFoundOnBottom = false; + let atLeastOneBlackPointFoundOnLeft = false; + let atLeastOneBlackPointFoundOnTop = false; + const width = this.width; + const height = this.height; + while (aBlackPointFoundOnBorder) { + aBlackPointFoundOnBorder = false; + // ..... + // . | + // ..... + let rightBorderNotWhite = true; + while ((rightBorderNotWhite || !atLeastOneBlackPointFoundOnRight) && right < width) { + rightBorderNotWhite = this.containsBlackPoint(up, down, right, false); + if (rightBorderNotWhite) { + right++; + aBlackPointFoundOnBorder = true; + atLeastOneBlackPointFoundOnRight = true; + } + else if (!atLeastOneBlackPointFoundOnRight) { + right++; + } + } + if (right >= width) { + sizeExceeded = true; + break; + } + // ..... + // . . + // .___. + let bottomBorderNotWhite = true; + while ((bottomBorderNotWhite || !atLeastOneBlackPointFoundOnBottom) && down < height) { + bottomBorderNotWhite = this.containsBlackPoint(left, right, down, true); + if (bottomBorderNotWhite) { + down++; + aBlackPointFoundOnBorder = true; + atLeastOneBlackPointFoundOnBottom = true; + } + else if (!atLeastOneBlackPointFoundOnBottom) { + down++; + } + } + if (down >= height) { + sizeExceeded = true; + break; + } + // ..... + // | . + // ..... + let leftBorderNotWhite = true; + while ((leftBorderNotWhite || !atLeastOneBlackPointFoundOnLeft) && left >= 0) { + leftBorderNotWhite = this.containsBlackPoint(up, down, left, false); + if (leftBorderNotWhite) { + left--; + aBlackPointFoundOnBorder = true; + atLeastOneBlackPointFoundOnLeft = true; + } + else if (!atLeastOneBlackPointFoundOnLeft) { + left--; + } + } + if (left < 0) { + sizeExceeded = true; + break; + } + // .___. + // . . + // ..... + let topBorderNotWhite = true; + while ((topBorderNotWhite || !atLeastOneBlackPointFoundOnTop) && up >= 0) { + topBorderNotWhite = this.containsBlackPoint(left, right, up, true); + if (topBorderNotWhite) { + up--; + aBlackPointFoundOnBorder = true; + atLeastOneBlackPointFoundOnTop = true; + } + else if (!atLeastOneBlackPointFoundOnTop) { + up--; + } + } + if (up < 0) { + sizeExceeded = true; + break; + } + if (aBlackPointFoundOnBorder) { + atLeastOneBlackPointFoundOnBorder = true; + } + } + if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) { + const maxSize = right - left; + let z = null; + for (let i = 1; z === null && i < maxSize; i++) { + z = this.getBlackPointOnSegment(left, down - i, left + i, down); + } + if (z == null) { + throw new NotFoundException(); + } + let t = null; + // go down right + for (let i = 1; t === null && i < maxSize; i++) { + t = this.getBlackPointOnSegment(left, up + i, left + i, up); + } + if (t == null) { + throw new NotFoundException(); + } + let x = null; + // go down left + for (let i = 1; x === null && i < maxSize; i++) { + x = this.getBlackPointOnSegment(right, up + i, right - i, up); + } + if (x == null) { + throw new NotFoundException(); + } + let y = null; + // go up left + for (let i = 1; y === null && i < maxSize; i++) { + y = this.getBlackPointOnSegment(right, down - i, right - i, down); + } + if (y == null) { + throw new NotFoundException(); + } + return this.centerEdges(y, z, x, t); + } + else { + throw new NotFoundException(); + } + } + getBlackPointOnSegment(aX /*float*/, aY /*float*/, bX /*float*/, bY /*float*/) { + const dist = MathUtils.round(MathUtils.distance(aX, aY, bX, bY)); + const xStep = (bX - aX) / dist; + const yStep = (bY - aY) / dist; + const image = this.image; + for (let i = 0; i < dist; i++) { + const x = MathUtils.round(aX + i * xStep); + const y = MathUtils.round(aY + i * yStep); + if (image.get(x, y)) { + return new ResultPoint(x, y); + } + } + return null; + } + /** + * recenters the points of a constant distance towards the center + * + * @param y bottom most point + * @param z left most point + * @param x right most point + * @param t top most point + * @return {@link ResultPoint}[] describing the corners of the rectangular + * region. The first and last points are opposed on the diagonal, as + * are the second and third. The first point will be the topmost + * point and the last, the bottommost. The second point will be + * leftmost and the third, the rightmost + */ + centerEdges(y, z, x, t) { + // + // t t + // z x + // x OR z + // y y + // + const yi = y.getX(); + const yj = y.getY(); + const zi = z.getX(); + const zj = z.getY(); + const xi = x.getX(); + const xj = x.getY(); + const ti = t.getX(); + const tj = t.getY(); + const CORR = WhiteRectangleDetector.CORR; + if (yi < this.width / 2.0) { + return [ + new ResultPoint(ti - CORR, tj + CORR), + new ResultPoint(zi + CORR, zj + CORR), + new ResultPoint(xi - CORR, xj - CORR), + new ResultPoint(yi + CORR, yj - CORR) + ]; + } + else { + return [ + new ResultPoint(ti + CORR, tj + CORR), + new ResultPoint(zi + CORR, zj - CORR), + new ResultPoint(xi - CORR, xj + CORR), + new ResultPoint(yi - CORR, yj - CORR) + ]; + } + } + /** + * Determines whether a segment contains a black point + * + * @param a min value of the scanned coordinate + * @param b max value of the scanned coordinate + * @param fixed value of fixed coordinate + * @param horizontal set to true if scan must be horizontal, false if vertical + * @return true if a black point has been found, else false. + */ + containsBlackPoint(a /*int*/, b /*int*/, fixed /*int*/, horizontal) { + const image = this.image; + if (horizontal) { + for (let x = a; x <= b; x++) { + if (image.get(x, fixed)) { + return true; + } + } + } + else { + for (let y = a; y <= b; y++) { + if (image.get(fixed, y)) { + return true; + } + } + } + return false; + } + } + WhiteRectangleDetector.INIT_SIZE = 10; + WhiteRectangleDetector.CORR = 1; + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * Implementations of this class can, given locations of finder patterns for a QR code in an + * image, sample the right points in the image to reconstruct the QR code, accounting for + * perspective distortion. It is abstracted since it is relatively expensive and should be allowed + * to take advantage of platform-specific optimized implementations, like Sun's Java Advanced + * Imaging library, but which may not be available in other environments such as J2ME, and vice + * versa. + * + * The implementation used can be controlled by calling {@link #setGridSampler(GridSampler)} + * with an instance of a class which implements this interface. + * + * @author Sean Owen + */ + class GridSampler { + /** + * <p>Checks a set of points that have been transformed to sample points on an image against + * the image's dimensions to see if the point are even within the image.</p> + * + * <p>This method will actually "nudge" the endpoints back onto the image if they are found to be + * barely (less than 1 pixel) off the image. This accounts for imperfect detection of finder + * patterns in an image where the QR Code runs all the way to the image border.</p> + * + * <p>For efficiency, the method will check points from either end of the line until one is found + * to be within the image. Because the set of points are assumed to be linear, this is valid.</p> + * + * @param image image into which the points should map + * @param points actual points in x1,y1,...,xn,yn form + * @throws NotFoundException if an endpoint is lies outside the image boundaries + */ + static checkAndNudgePoints(image, points) { + const width = image.getWidth(); + const height = image.getHeight(); + // Check and nudge points from start until we see some that are OK: + let nudged = true; + for (let offset = 0; offset < points.length && nudged; offset += 2) { + const x = Math.floor(points[offset]); + const y = Math.floor(points[offset + 1]); + if (x < -1 || x > width || y < -1 || y > height) { + throw new NotFoundException(); + } + nudged = false; + if (x === -1) { + points[offset] = 0.0; + nudged = true; + } + else if (x === width) { + points[offset] = width - 1; + nudged = true; + } + if (y === -1) { + points[offset + 1] = 0.0; + nudged = true; + } + else if (y === height) { + points[offset + 1] = height - 1; + nudged = true; + } + } + // Check and nudge points from end: + nudged = true; + for (let offset = points.length - 2; offset >= 0 && nudged; offset -= 2) { + const x = Math.floor(points[offset]); + const y = Math.floor(points[offset + 1]); + if (x < -1 || x > width || y < -1 || y > height) { + throw new NotFoundException(); + } + nudged = false; + if (x === -1) { + points[offset] = 0.0; + nudged = true; + } + else if (x === width) { + points[offset] = width - 1; + nudged = true; + } + if (y === -1) { + points[offset + 1] = 0.0; + nudged = true; + } + else if (y === height) { + points[offset + 1] = height - 1; + nudged = true; + } + } + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*namespace com.google.zxing.common {*/ + /** + * <p>This class implements a perspective transform in two dimensions. Given four source and four + * destination points, it will compute the transformation implied between them. The code is based + * directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.</p> + * + * @author Sean Owen + */ + class PerspectiveTransform { + constructor(a11 /*float*/, a21 /*float*/, a31 /*float*/, a12 /*float*/, a22 /*float*/, a32 /*float*/, a13 /*float*/, a23 /*float*/, a33 /*float*/) { + this.a11 = a11; + this.a21 = a21; + this.a31 = a31; + this.a12 = a12; + this.a22 = a22; + this.a32 = a32; + this.a13 = a13; + this.a23 = a23; + this.a33 = a33; + } + static quadrilateralToQuadrilateral(x0 /*float*/, y0 /*float*/, x1 /*float*/, y1 /*float*/, x2 /*float*/, y2 /*float*/, x3 /*float*/, y3 /*float*/, x0p /*float*/, y0p /*float*/, x1p /*float*/, y1p /*float*/, x2p /*float*/, y2p /*float*/, x3p /*float*/, y3p /*float*/) { + const qToS = PerspectiveTransform.quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3); + const sToQ = PerspectiveTransform.squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p); + return sToQ.times(qToS); + } + transformPoints(points) { + const max = points.length; + const a11 = this.a11; + const a12 = this.a12; + const a13 = this.a13; + const a21 = this.a21; + const a22 = this.a22; + const a23 = this.a23; + const a31 = this.a31; + const a32 = this.a32; + const a33 = this.a33; + for (let i = 0; i < max; i += 2) { + const x = points[i]; + const y = points[i + 1]; + const denominator = a13 * x + a23 * y + a33; + points[i] = (a11 * x + a21 * y + a31) / denominator; + points[i + 1] = (a12 * x + a22 * y + a32) / denominator; + } + } + transformPointsWithValues(xValues, yValues) { + const a11 = this.a11; + const a12 = this.a12; + const a13 = this.a13; + const a21 = this.a21; + const a22 = this.a22; + const a23 = this.a23; + const a31 = this.a31; + const a32 = this.a32; + const a33 = this.a33; + const n = xValues.length; + for (let i = 0; i < n; i++) { + const x = xValues[i]; + const y = yValues[i]; + const denominator = a13 * x + a23 * y + a33; + xValues[i] = (a11 * x + a21 * y + a31) / denominator; + yValues[i] = (a12 * x + a22 * y + a32) / denominator; + } + } + static squareToQuadrilateral(x0 /*float*/, y0 /*float*/, x1 /*float*/, y1 /*float*/, x2 /*float*/, y2 /*float*/, x3 /*float*/, y3 /*float*/) { + const dx3 = x0 - x1 + x2 - x3; + const dy3 = y0 - y1 + y2 - y3; + if (dx3 === 0.0 && dy3 === 0.0) { + // Affine + return new PerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, y2 - y1, y0, 0.0, 0.0, 1.0); + } + else { + const dx1 = x1 - x2; + const dx2 = x3 - x2; + const dy1 = y1 - y2; + const dy2 = y3 - y2; + const denominator = dx1 * dy2 - dx2 * dy1; + const a13 = (dx3 * dy2 - dx2 * dy3) / denominator; + const a23 = (dx1 * dy3 - dx3 * dy1) / denominator; + return new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, a13, a23, 1.0); + } + } + static quadrilateralToSquare(x0 /*float*/, y0 /*float*/, x1 /*float*/, y1 /*float*/, x2 /*float*/, y2 /*float*/, x3 /*float*/, y3 /*float*/) { + // Here, the adjoint serves as the inverse: + return PerspectiveTransform.squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).buildAdjoint(); + } + buildAdjoint() { + // Adjoint is the transpose of the cofactor matrix: + return new PerspectiveTransform(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(other) { + return new PerspectiveTransform(this.a11 * other.a11 + this.a21 * other.a12 + this.a31 * other.a13, this.a11 * other.a21 + this.a21 * other.a22 + this.a31 * other.a23, this.a11 * other.a31 + this.a21 * other.a32 + this.a31 * other.a33, this.a12 * other.a11 + this.a22 * other.a12 + this.a32 * other.a13, this.a12 * other.a21 + this.a22 * other.a22 + this.a32 * other.a23, this.a12 * other.a31 + this.a22 * other.a32 + this.a32 * other.a33, this.a13 * other.a11 + this.a23 * other.a12 + this.a33 * other.a13, this.a13 * other.a21 + this.a23 * other.a22 + this.a33 * other.a23, this.a13 * other.a31 + this.a23 * other.a32 + this.a33 * other.a33); + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * @author Sean Owen + */ + class DefaultGridSampler extends GridSampler { + /*@Override*/ + sampleGrid(image, dimensionX /*int*/, dimensionY /*int*/, p1ToX /*float*/, p1ToY /*float*/, p2ToX /*float*/, p2ToY /*float*/, p3ToX /*float*/, p3ToY /*float*/, p4ToX /*float*/, p4ToY /*float*/, p1FromX /*float*/, p1FromY /*float*/, p2FromX /*float*/, p2FromY /*float*/, p3FromX /*float*/, p3FromY /*float*/, p4FromX /*float*/, p4FromY /*float*/) { + const transform = PerspectiveTransform.quadrilateralToQuadrilateral(p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY); + return this.sampleGridWithTransform(image, dimensionX, dimensionY, transform); + } + /*@Override*/ + sampleGridWithTransform(image, dimensionX /*int*/, dimensionY /*int*/, transform) { + if (dimensionX <= 0 || dimensionY <= 0) { + throw new NotFoundException(); + } + const bits = new BitMatrix(dimensionX, dimensionY); + const points = new Float32Array(2 * dimensionX); + for (let y = 0; y < dimensionY; y++) { + const max = points.length; + const iValue = y + 0.5; + for (let x = 0; x < max; x += 2) { + points[x] = (x / 2) + 0.5; + points[x + 1] = iValue; + } + transform.transformPoints(points); + // Quick check to see if points transformed to something inside the image + // sufficient to check the endpoints + GridSampler.checkAndNudgePoints(image, points); + try { + for (let x = 0; x < max; x += 2) { + if (image.get(Math.floor(points[x]), Math.floor(points[x + 1]))) { + // Black(-ish) pixel + bits.set(x / 2, y); + } + } + } + catch (aioobe /*: ArrayIndexOutOfBoundsException*/) { + // This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting + // transform gets "twisted" such that it maps a straight line of points to a set of points + // whose endpoints are in bounds, but others are not. There is probably some mathematical + // way to detect this about the transformation that I don't know yet. + // This results in an ugly runtime exception despite our clever checks above -- can't have + // that. We could check each point's coordinates but that feels duplicative. We settle for + // catching and wrapping ArrayIndexOutOfBoundsException. + throw new NotFoundException(); + } + } + return bits; + } + } + + class GridSamplerInstance { + /** + * Sets the implementation of GridSampler used by the library. One global + * instance is stored, which may sound problematic. But, the implementation provided + * ought to be appropriate for the entire platform, and all uses of this library + * in the whole lifetime of the JVM. For instance, an Android activity can swap in + * an implementation that takes advantage of native platform libraries. + * + * @param newGridSampler The platform-specific object to install. + */ + static setGridSampler(newGridSampler) { + GridSamplerInstance.gridSampler = newGridSampler; + } + /** + * @return the current implementation of GridSampler + */ + static getInstance() { + return GridSamplerInstance.gridSampler; + } + } + GridSamplerInstance.gridSampler = new DefaultGridSampler(); + + /* + * Copyright 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + class Point { + constructor(x, y) { + this.x = x; + this.y = y; + } + toResultPoint() { + return new ResultPoint(this.getX(), this.getY()); + } + getX() { + return this.x; + } + getY() { + return this.y; + } + } + /** + * Encapsulates logic that can detect an Aztec Code in an image, even if the Aztec Code + * is rotated or skewed, or partially obscured. + * + * @author David Olivier + * @author Frank Yellin + */ + class Detector { + constructor(image) { + this.EXPECTED_CORNER_BITS = new Int32Array([ + 0xee0, + 0x1dc, + 0x83b, + 0x707, + ]); + this.image = image; + } + detect() { + return this.detectMirror(false); + } + /** + * Detects an Aztec Code in an image. + * + * @param isMirror if true, image is a mirror-image of original + * @return {@link AztecDetectorResult} encapsulating results of detecting an Aztec Code + * @throws NotFoundException if no Aztec Code can be found + */ + detectMirror(isMirror) { + // 1. Get the center of the aztec matrix + let pCenter = this.getMatrixCenter(); + // 2. Get the center points of the four diagonal points just outside the bull's eye + // [topRight, bottomRight, bottomLeft, topLeft] + let bullsEyeCorners = this.getBullsEyeCorners(pCenter); + if (isMirror) { + let temp = bullsEyeCorners[0]; + bullsEyeCorners[0] = bullsEyeCorners[2]; + bullsEyeCorners[2] = temp; + } + // 3. Get the size of the matrix and other parameters from the bull's eye + this.extractParameters(bullsEyeCorners); + // 4. Sample the grid + let bits = this.sampleGrid(this.image, bullsEyeCorners[this.shift % 4], bullsEyeCorners[(this.shift + 1) % 4], bullsEyeCorners[(this.shift + 2) % 4], bullsEyeCorners[(this.shift + 3) % 4]); + // 5. Get the corners of the matrix. + let corners = this.getMatrixCornerPoints(bullsEyeCorners); + return new AztecDetectorResult(bits, corners, this.compact, this.nbDataBlocks, this.nbLayers); + } + /** + * Extracts the number of data layers and data blocks from the layer around the bull's eye. + * + * @param bullsEyeCorners the array of bull's eye corners + * @throws NotFoundException in case of too many errors or invalid parameters + */ + extractParameters(bullsEyeCorners) { + if (!this.isValidPoint(bullsEyeCorners[0]) || !this.isValidPoint(bullsEyeCorners[1]) || + !this.isValidPoint(bullsEyeCorners[2]) || !this.isValidPoint(bullsEyeCorners[3])) { + throw new NotFoundException(); + } + let length = 2 * this.nbCenterLayers; + // Get the bits around the bull's eye + let sides = new Int32Array([ + this.sampleLine(bullsEyeCorners[0], bullsEyeCorners[1], length), + this.sampleLine(bullsEyeCorners[1], bullsEyeCorners[2], length), + this.sampleLine(bullsEyeCorners[2], bullsEyeCorners[3], length), + this.sampleLine(bullsEyeCorners[3], bullsEyeCorners[0], length) // Top + ]); + // bullsEyeCorners[shift] is the corner of the bulls'eye that has three + // orientation marks. + // sides[shift] is the row/column that goes from the corner with three + // orientation marks to the corner with two. + this.shift = this.getRotation(sides, length); + // Flatten the parameter bits into a single 28- or 40-bit long + let parameterData = 0; + for (let i = 0; i < 4; i++) { + let side = sides[(this.shift + i) % 4]; + if (this.compact) { + // Each side of the form ..XXXXXXX. where Xs are parameter data + parameterData <<= 7; + parameterData += (side >> 1) & 0x7F; + } + else { + // Each side of the form ..XXXXX.XXXXX. where Xs are parameter data + parameterData <<= 10; + parameterData += ((side >> 2) & (0x1f << 5)) + ((side >> 1) & 0x1F); + } + } + // Corrects parameter data using RS. Returns just the data portion + // without the error correction. + let correctedData = this.getCorrectedParameterData(parameterData, this.compact); + if (this.compact) { + // 8 bits: 2 bits layers and 6 bits data blocks + this.nbLayers = (correctedData >> 6) + 1; + this.nbDataBlocks = (correctedData & 0x3F) + 1; + } + else { + // 16 bits: 5 bits layers and 11 bits data blocks + this.nbLayers = (correctedData >> 11) + 1; + this.nbDataBlocks = (correctedData & 0x7FF) + 1; + } + } + getRotation(sides, length) { + // In a normal pattern, we expect to See + // ** .* D A + // * * + // + // . * + // .. .. C B + // + // Grab the 3 bits from each of the sides the form the locator pattern and concatenate + // into a 12-bit integer. Start with the bit at A + let cornerBits = 0; + sides.forEach((side, idx, arr) => { + // XX......X where X's are orientation marks + let t = ((side >> (length - 2)) << 1) + (side & 1); + cornerBits = (cornerBits << 3) + t; + }); + // for (var side in sides) { + // // XX......X where X's are orientation marks + // var t = ((side >> (length - 2)) << 1) + (side & 1); + // cornerBits = (cornerBits << 3) + t; + // } + // Mov the bottom bit to the top, so that the three bits of the locator pattern at A are + // together. cornerBits is now: + // 3 orientation bits at A || 3 orientation bits at B || ... || 3 orientation bits at D + cornerBits = ((cornerBits & 1) << 11) + (cornerBits >> 1); + // The result shift indicates which element of BullsEyeCorners[] goes into the top-left + // corner. Since the four rotation values have a Hamming distance of 8, we + // can easily tolerate two errors. + for (let shift = 0; shift < 4; shift++) { + if (Integer.bitCount(cornerBits ^ this.EXPECTED_CORNER_BITS[shift]) <= 2) { + return shift; + } + } + throw new NotFoundException(); + } + /** + * Corrects the parameter bits using Reed-Solomon algorithm. + * + * @param parameterData parameter bits + * @param compact true if this is a compact Aztec code + * @throws NotFoundException if the array contains too many errors + */ + getCorrectedParameterData(parameterData, compact) { + let numCodewords; + let numDataCodewords; + if (compact) { + numCodewords = 7; + numDataCodewords = 2; + } + else { + numCodewords = 10; + numDataCodewords = 4; + } + let numECCodewords = numCodewords - numDataCodewords; + let parameterWords = new Int32Array(numCodewords); + for (let i = numCodewords - 1; i >= 0; --i) { + parameterWords[i] = parameterData & 0xF; + parameterData >>= 4; + } + try { + let rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM); + rsDecoder.decode(parameterWords, numECCodewords); + } + catch (ignored) { + throw new NotFoundException(); + } + // Toss the error correction. Just return the data as an integer + let result = 0; + for (let i = 0; i < numDataCodewords; i++) { + result = (result << 4) + parameterWords[i]; + } + return result; + } + /** + * Finds the corners of a bull-eye centered on the passed point. + * This returns the centers of the diagonal points just outside the bull's eye + * Returns [topRight, bottomRight, bottomLeft, topLeft] + * + * @param pCenter Center point + * @return The corners of the bull-eye + * @throws NotFoundException If no valid bull-eye can be found + */ + getBullsEyeCorners(pCenter) { + let pina = pCenter; + let pinb = pCenter; + let pinc = pCenter; + let pind = pCenter; + let color = true; + for (this.nbCenterLayers = 1; this.nbCenterLayers < 9; this.nbCenterLayers++) { + let pouta = this.getFirstDifferent(pina, color, 1, -1); + let poutb = this.getFirstDifferent(pinb, color, 1, 1); + let poutc = this.getFirstDifferent(pinc, color, -1, 1); + let poutd = this.getFirstDifferent(pind, color, -1, -1); + // d a + // + // c b + if (this.nbCenterLayers > 2) { + let q = (this.distancePoint(poutd, pouta) * this.nbCenterLayers) / (this.distancePoint(pind, pina) * (this.nbCenterLayers + 2)); + if (q < 0.75 || q > 1.25 || !this.isWhiteOrBlackRectangle(pouta, poutb, poutc, poutd)) { + break; + } + } + pina = pouta; + pinb = poutb; + pinc = poutc; + pind = poutd; + color = !color; + } + if (this.nbCenterLayers !== 5 && this.nbCenterLayers !== 7) { + throw new NotFoundException(); + } + this.compact = this.nbCenterLayers === 5; + // Expand the square by .5 pixel in each direction so that we're on the border + // between the white square and the black square + let pinax = new ResultPoint(pina.getX() + 0.5, pina.getY() - 0.5); + let pinbx = new ResultPoint(pinb.getX() + 0.5, pinb.getY() + 0.5); + let pincx = new ResultPoint(pinc.getX() - 0.5, pinc.getY() + 0.5); + let pindx = new ResultPoint(pind.getX() - 0.5, pind.getY() - 0.5); + // Expand the square so that its corners are the centers of the points + // just outside the bull's eye. + return this.expandSquare([pinax, pinbx, pincx, pindx], 2 * this.nbCenterLayers - 3, 2 * this.nbCenterLayers); + } + /** + * Finds a candidate center point of an Aztec code from an image + * + * @return the center point + */ + getMatrixCenter() { + let pointA; + let pointB; + let pointC; + let pointD; + // Get a white rectangle that can be the border of the matrix in center bull's eye or + try { + let cornerPoints = new WhiteRectangleDetector(this.image).detect(); + pointA = cornerPoints[0]; + pointB = cornerPoints[1]; + pointC = cornerPoints[2]; + pointD = cornerPoints[3]; + } + catch (e) { + // This exception can be in case the initial rectangle is white + // In that case, surely in the bull's eye, we try to expand the rectangle. + let cx = this.image.getWidth() / 2; + let cy = this.image.getHeight() / 2; + pointA = this.getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint(); + pointB = this.getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint(); + pointC = this.getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint(); + pointD = this.getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint(); + } + // Compute the center of the rectangle + let cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0); + let cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0); + // Redetermine the white rectangle starting from previously computed center. + // This will ensure that we end up with a white rectangle in center bull's eye + // in order to compute a more accurate center. + try { + let cornerPoints = new WhiteRectangleDetector(this.image, 15, cx, cy).detect(); + pointA = cornerPoints[0]; + pointB = cornerPoints[1]; + pointC = cornerPoints[2]; + pointD = cornerPoints[3]; + } + catch (e) { + // This exception can be in case the initial rectangle is white + // In that case we try to expand the rectangle. + pointA = this.getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint(); + pointB = this.getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint(); + pointC = this.getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint(); + pointD = this.getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint(); + } + // Recompute the center of the rectangle + cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0); + cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0); + return new Point(cx, cy); + } + /** + * Gets the Aztec code corners from the bull's eye corners and the parameters. + * + * @param bullsEyeCorners the array of bull's eye corners + * @return the array of aztec code corners + */ + getMatrixCornerPoints(bullsEyeCorners) { + return this.expandSquare(bullsEyeCorners, 2 * this.nbCenterLayers, this.getDimension()); + } + /** + * Creates a BitMatrix by sampling the provided image. + * topLeft, topRight, bottomRight, and bottomLeft are the centers of the squares on the + * diagonal just outside the bull's eye. + */ + sampleGrid(image, topLeft, topRight, bottomRight, bottomLeft) { + let sampler = GridSamplerInstance.getInstance(); + let dimension = this.getDimension(); + let low = dimension / 2 - this.nbCenterLayers; + let high = dimension / 2 + this.nbCenterLayers; + return sampler.sampleGrid(image, dimension, dimension, low, low, // topleft + high, low, // topright + high, high, // bottomright + low, high, // bottomleft + topLeft.getX(), topLeft.getY(), topRight.getX(), topRight.getY(), bottomRight.getX(), bottomRight.getY(), bottomLeft.getX(), bottomLeft.getY()); + } + /** + * Samples a line. + * + * @param p1 start point (inclusive) + * @param p2 end point (exclusive) + * @param size number of bits + * @return the array of bits as an int (first bit is high-order bit of result) + */ + sampleLine(p1, p2, size) { + let result = 0; + let d = this.distanceResultPoint(p1, p2); + let moduleSize = d / size; + let px = p1.getX(); + let py = p1.getY(); + let dx = moduleSize * (p2.getX() - p1.getX()) / d; + let dy = moduleSize * (p2.getY() - p1.getY()) / d; + for (let i = 0; i < size; i++) { + if (this.image.get(MathUtils.round(px + i * dx), MathUtils.round(py + i * dy))) { + result |= 1 << (size - i - 1); + } + } + return result; + } + /** + * @return true if the border of the rectangle passed in parameter is compound of white points only + * or black points only + */ + isWhiteOrBlackRectangle(p1, p2, p3, p4) { + let corr = 3; + p1 = new Point(p1.getX() - corr, p1.getY() + corr); + p2 = new Point(p2.getX() - corr, p2.getY() - corr); + p3 = new Point(p3.getX() + corr, p3.getY() - corr); + p4 = new Point(p4.getX() + corr, p4.getY() + corr); + let cInit = this.getColor(p4, p1); + if (cInit === 0) { + return false; + } + let c = this.getColor(p1, p2); + if (c !== cInit) { + return false; + } + c = this.getColor(p2, p3); + if (c !== cInit) { + return false; + } + c = this.getColor(p3, p4); + return c === cInit; + } + /** + * Gets the color of a segment + * + * @return 1 if segment more than 90% black, -1 if segment is more than 90% white, 0 else + */ + getColor(p1, p2) { + let d = this.distancePoint(p1, p2); + let dx = (p2.getX() - p1.getX()) / d; + let dy = (p2.getY() - p1.getY()) / d; + let error = 0; + let px = p1.getX(); + let py = p1.getY(); + let colorModel = this.image.get(p1.getX(), p1.getY()); + let iMax = Math.ceil(d); + for (let i = 0; i < iMax; i++) { + px += dx; + py += dy; + if (this.image.get(MathUtils.round(px), MathUtils.round(py)) !== colorModel) { + error++; + } + } + let errRatio = error / d; + if (errRatio > 0.1 && errRatio < 0.9) { + return 0; + } + return (errRatio <= 0.1) === colorModel ? 1 : -1; + } + /** + * Gets the coordinate of the first point with a different color in the given direction + */ + getFirstDifferent(init, color, dx, dy) { + let x = init.getX() + dx; + let y = init.getY() + dy; + while (this.isValid(x, y) && this.image.get(x, y) === color) { + x += dx; + y += dy; + } + x -= dx; + y -= dy; + while (this.isValid(x, y) && this.image.get(x, y) === color) { + x += dx; + } + x -= dx; + while (this.isValid(x, y) && this.image.get(x, y) === color) { + y += dy; + } + y -= dy; + return new Point(x, y); + } + /** + * Expand the square represented by the corner points by pushing out equally in all directions + * + * @param cornerPoints the corners of the square, which has the bull's eye at its center + * @param oldSide the original length of the side of the square in the target bit matrix + * @param newSide the new length of the size of the square in the target bit matrix + * @return the corners of the expanded square + */ + expandSquare(cornerPoints, oldSide, newSide) { + let ratio = newSide / (2.0 * oldSide); + let dx = cornerPoints[0].getX() - cornerPoints[2].getX(); + let dy = cornerPoints[0].getY() - cornerPoints[2].getY(); + let centerx = (cornerPoints[0].getX() + cornerPoints[2].getX()) / 2.0; + let centery = (cornerPoints[0].getY() + cornerPoints[2].getY()) / 2.0; + let result0 = new ResultPoint(centerx + ratio * dx, centery + ratio * dy); + let result2 = new ResultPoint(centerx - ratio * dx, centery - ratio * dy); + dx = cornerPoints[1].getX() - cornerPoints[3].getX(); + dy = cornerPoints[1].getY() - cornerPoints[3].getY(); + centerx = (cornerPoints[1].getX() + cornerPoints[3].getX()) / 2.0; + centery = (cornerPoints[1].getY() + cornerPoints[3].getY()) / 2.0; + let result1 = new ResultPoint(centerx + ratio * dx, centery + ratio * dy); + let result3 = new ResultPoint(centerx - ratio * dx, centery - ratio * dy); + let results = [result0, result1, result2, result3]; + return results; + } + isValid(x, y) { + return x >= 0 && x < this.image.getWidth() && y > 0 && y < this.image.getHeight(); + } + isValidPoint(point) { + let x = MathUtils.round(point.getX()); + let y = MathUtils.round(point.getY()); + return this.isValid(x, y); + } + distancePoint(a, b) { + return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY()); + } + distanceResultPoint(a, b) { + return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY()); + } + getDimension() { + if (this.compact) { + return 4 * this.nbLayers + 11; + } + if (this.nbLayers <= 4) { + return 4 * this.nbLayers + 15; + } + return 4 * this.nbLayers + 2 * (Integer.truncDivision((this.nbLayers - 4), 8) + 1) + 15; + } + } + + /* + * Copyright 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // import java.util.List; + // import java.util.Map; + /** + * This implementation can detect and decode Aztec codes in an image. + * + * @author David Olivier + */ + class AztecReader { + /** + * Locates and decodes a Data Matrix code in an image. + * + * @return a String representing the content encoded by the Data Matrix code + * @throws NotFoundException if a Data Matrix code cannot be found + * @throws FormatException if a Data Matrix code cannot be decoded + */ + decode(image, hints = null) { + let exception = null; + let detector = new Detector(image.getBlackMatrix()); + let points = null; + let decoderResult = null; + try { + let detectorResult = detector.detectMirror(false); + points = detectorResult.getPoints(); + this.reportFoundResultPoints(hints, points); + decoderResult = new Decoder().decode(detectorResult); + } + catch (e) { + exception = e; + } + if (decoderResult == null) { + try { + let detectorResult = detector.detectMirror(true); + points = detectorResult.getPoints(); + this.reportFoundResultPoints(hints, points); + decoderResult = new Decoder().decode(detectorResult); + } + catch (e) { + if (exception != null) { + throw exception; + } + throw e; + } + } + let result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), decoderResult.getNumBits(), points, BarcodeFormat$1.AZTEC, System.currentTimeMillis()); + let byteSegments = decoderResult.getByteSegments(); + if (byteSegments != null) { + result.putMetadata(ResultMetadataType$1.BYTE_SEGMENTS, byteSegments); + } + let ecLevel = decoderResult.getECLevel(); + if (ecLevel != null) { + result.putMetadata(ResultMetadataType$1.ERROR_CORRECTION_LEVEL, ecLevel); + } + return result; + } + reportFoundResultPoints(hints, points) { + if (hints != null) { + let rpcb = hints.get(DecodeHintType$1.NEED_RESULT_POINT_CALLBACK); + if (rpcb != null) { + points.forEach((point, idx, arr) => { + rpcb.foundPossibleResultPoint(point); + }); + } + } + } + // @Override + reset() { + // do nothing + } + } + + /** + * Aztec Code reader to use from browser. + * + * @class BrowserAztecCodeReader + * @extends {BrowserCodeReader} + */ + class BrowserAztecCodeReader extends BrowserCodeReader { + /** + * Creates an instance of BrowserAztecCodeReader. + * @param {number} [timeBetweenScansMillis=500] the time delay between subsequent decode tries + * + * @memberOf BrowserAztecCodeReader + */ + constructor(timeBetweenScansMillis = 500) { + super(new AztecReader(), timeBetweenScansMillis); + } + } + + /** + * Encapsulates functionality and implementation that is common to all families + * of one-dimensional barcodes. + * + * @author dswitkin@google.com (Daniel Switkin) + * @author Sean Owen + */ + class OneDReader { + /* + @Override + public Result decode(BinaryBitmap image) throws NotFoundException, FormatException { + return decode(image, null); + } + */ + // Note that we don't try rotation without the try harder flag, even if rotation was supported. + // @Override + decode(image, hints) { + try { + return this.doDecode(image, hints); + } + catch (nfe) { + const tryHarder = hints && (hints.get(DecodeHintType$1.TRY_HARDER) === true); + if (tryHarder && image.isRotateSupported()) { + const rotatedImage = image.rotateCounterClockwise(); + const result = this.doDecode(rotatedImage, hints); + // Record that we found it rotated 90 degrees CCW / 270 degrees CW + const metadata = result.getResultMetadata(); + let orientation = 270; + if (metadata !== null && (metadata.get(ResultMetadataType$1.ORIENTATION) === true)) { + // But if we found it reversed in doDecode(), add in that result here: + orientation = (orientation + metadata.get(ResultMetadataType$1.ORIENTATION) % 360); + } + result.putMetadata(ResultMetadataType$1.ORIENTATION, orientation); + // Update result points + const points = result.getResultPoints(); + if (points !== null) { + const height = rotatedImage.getHeight(); + for (let i = 0; i < points.length; i++) { + points[i] = new ResultPoint(height - points[i].getY() - 1, points[i].getX()); + } + } + return result; + } + else { + throw new NotFoundException(); + } + } + } + // @Override + reset() { + // do nothing + } + /** + * We're going to examine rows from the middle outward, searching alternately above and below the + * middle, and farther out each time. rowStep is the number of rows between each successive + * attempt above and below the middle. So we'd scan row middle, then middle - rowStep, then + * middle + rowStep, then middle - (2 * rowStep), etc. + * rowStep is bigger as the image is taller, but is always at least 1. We've somewhat arbitrarily + * decided that moving up and down by about 1/16 of the image is pretty good; we try more of the + * image if "trying harder". + * + * @param image The image to decode + * @param hints Any hints that were requested + * @return The contents of the decoded barcode + * @throws NotFoundException Any spontaneous errors which occur + */ + doDecode(image, hints) { + const width = image.getWidth(); + const height = image.getHeight(); + let row = new BitArray(width); + const tryHarder = hints && (hints.get(DecodeHintType$1.TRY_HARDER) === true); + const rowStep = Math.max(1, height >> (tryHarder ? 8 : 5)); + let maxLines; + if (tryHarder) { + maxLines = height; // Look at the whole image, not just the center + } + else { + maxLines = 15; // 15 rows spaced 1/32 apart is roughly the middle half of the image + } + const middle = Math.trunc(height / 2); + for (let x = 0; x < maxLines; x++) { + // Scanning from the middle out. Determine which row we're looking at next: + const rowStepsAboveOrBelow = Math.trunc((x + 1) / 2); + const isAbove = (x & 0x01) === 0; // i.e. is x even? + const rowNumber = middle + rowStep * (isAbove ? rowStepsAboveOrBelow : -rowStepsAboveOrBelow); + if (rowNumber < 0 || rowNumber >= height) { + // Oops, if we run off the top or bottom, stop + break; + } + // Estimate black point for this row and load it: + try { + row = image.getBlackRow(rowNumber, row); + } + catch (ignored) { + continue; + } + // While we have the image data in a BitArray, it's fairly cheap to reverse it in place to + // handle decoding upside down barcodes. + for (let attempt = 0; attempt < 2; attempt++) { + if (attempt === 1) { // trying again? + row.reverse(); // reverse the row and continue + // This means we will only ever draw result points *once* in the life of this method + // since we want to avoid drawing the wrong points after flipping the row, and, + // don't want to clutter with noise from every single row scan -- just the scans + // that start on the center line. + if (hints && (hints.get(DecodeHintType$1.NEED_RESULT_POINT_CALLBACK) === true)) { + const newHints = new Map(); + hints.forEach((hint, key) => newHints.set(key, hint)); + newHints.delete(DecodeHintType$1.NEED_RESULT_POINT_CALLBACK); + hints = newHints; + } + } + try { + // Look for a barcode + const result = this.decodeRow(rowNumber, row, hints); + // We found our barcode + if (attempt === 1) { + // But it was upside down, so note that + result.putMetadata(ResultMetadataType$1.ORIENTATION, 180); + // And remember to flip the result points horizontally. + const points = result.getResultPoints(); + if (points !== null) { + points[0] = new ResultPoint(width - points[0].getX() - 1, points[0].getY()); + points[1] = new ResultPoint(width - points[1].getX() - 1, points[1].getY()); + } + } + return result; + } + catch (re) { + // continue -- just couldn't decode this row + } + } + } + throw new NotFoundException(); + } + /** + * Records the size of successive runs of white and black pixels in a row, starting at a given point. + * The values are recorded in the given array, and the number of runs recorded is equal to the size + * of the array. If the row starts on a white pixel at the given start point, then the first count + * recorded is the run of white pixels starting from that point; likewise it is the count of a run + * of black pixels if the row begin on a black pixels at that point. + * + * @param row row to count from + * @param start offset into row to start at + * @param counters array into which to record counts + * @throws NotFoundException if counters cannot be filled entirely from row before running out + * of pixels + */ + static recordPattern(row, start, counters) { + const numCounters = counters.length; + for (let index = 0; index < numCounters; index++) + counters[index] = 0; + const end = row.getSize(); + if (start >= end) { + throw new NotFoundException(); + } + let isWhite = !row.get(start); + let counterPosition = 0; + let i = start; + while (i < end) { + if (row.get(i) !== isWhite) { + counters[counterPosition]++; + } + else { + if (++counterPosition === numCounters) { + break; + } + else { + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + i++; + } + // If we read fully the last section of pixels and filled up our counters -- or filled + // the last counter but ran off the side of the image, OK. Otherwise, a problem. + if (!(counterPosition === numCounters || (counterPosition === numCounters - 1 && i === end))) { + throw new NotFoundException(); + } + } + static recordPatternInReverse(row, start, counters) { + // This could be more efficient I guess + let numTransitionsLeft = counters.length; + let last = row.get(start); + while (start > 0 && numTransitionsLeft >= 0) { + if (row.get(--start) !== last) { + numTransitionsLeft--; + last = !last; + } + } + if (numTransitionsLeft >= 0) { + throw new NotFoundException(); + } + OneDReader.recordPattern(row, start + 1, counters); + } + /** + * Determines how closely a set of observed counts of runs of black/white values matches a given + * target pattern. This is reported as the ratio of the total variance from the expected pattern + * proportions across all pattern elements, to the length of the pattern. + * + * @param counters observed counters + * @param pattern expected pattern + * @param maxIndividualVariance The most any counter can differ before we give up + * @return ratio of total variance between counters and pattern compared to total pattern size + */ + static patternMatchVariance(counters, pattern, maxIndividualVariance) { + const numCounters = counters.length; + let total = 0; + let patternLength = 0; + for (let i = 0; i < numCounters; i++) { + total += counters[i]; + patternLength += pattern[i]; + } + if (total < patternLength) { + // If we don't even have one pixel per unit of bar width, assume this is too small + // to reliably match, so fail: + return Number.POSITIVE_INFINITY; + } + const unitBarWidth = total / patternLength; + maxIndividualVariance *= unitBarWidth; + let totalVariance = 0.0; + for (let x = 0; x < numCounters; x++) { + const counter = counters[x]; + const scaledPattern = pattern[x] * unitBarWidth; + const variance = counter > scaledPattern ? counter - scaledPattern : scaledPattern - counter; + if (variance > maxIndividualVariance) { + return Number.POSITIVE_INFINITY; + } + totalVariance += variance; + } + return totalVariance / total; + } + } + + /** + * <p>Decodes Code 128 barcodes.</p> + * + * @author Sean Owen + */ + class Code128Reader extends OneDReader { + static findStartPattern(row) { + const width = row.getSize(); + const rowOffset = row.getNextSet(0); + let counterPosition = 0; + let counters = Int32Array.from([0, 0, 0, 0, 0, 0]); + let patternStart = rowOffset; + let isWhite = false; + const patternLength = 6; + for (let i = rowOffset; i < width; i++) { + if (row.get(i) !== isWhite) { + counters[counterPosition]++; + } + else { + if (counterPosition === (patternLength - 1)) { + let bestVariance = Code128Reader.MAX_AVG_VARIANCE; + let bestMatch = -1; + for (let startCode = Code128Reader.CODE_START_A; startCode <= Code128Reader.CODE_START_C; startCode++) { + const variance = OneDReader.patternMatchVariance(counters, Code128Reader.CODE_PATTERNS[startCode], Code128Reader.MAX_INDIVIDUAL_VARIANCE); + if (variance < bestVariance) { + bestVariance = variance; + bestMatch = startCode; + } + } + // Look for whitespace before start pattern, >= 50% of width of start pattern + if (bestMatch >= 0 && + row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart, false)) { + return Int32Array.from([patternStart, i, bestMatch]); + } + patternStart += counters[0] + counters[1]; + counters = counters.slice(2, counters.length - 1); + counters[counterPosition - 1] = 0; + counters[counterPosition] = 0; + counterPosition--; + } + else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + throw new NotFoundException(); + } + static decodeCode(row, counters, rowOffset) { + OneDReader.recordPattern(row, rowOffset, counters); + let bestVariance = Code128Reader.MAX_AVG_VARIANCE; // worst variance we'll accept + let bestMatch = -1; + for (let d = 0; d < Code128Reader.CODE_PATTERNS.length; d++) { + const pattern = Code128Reader.CODE_PATTERNS[d]; + const variance = this.patternMatchVariance(counters, pattern, Code128Reader.MAX_INDIVIDUAL_VARIANCE); + if (variance < bestVariance) { + bestVariance = variance; + bestMatch = d; + } + } + // TODO We're overlooking the fact that the STOP pattern has 7 values, not 6. + if (bestMatch >= 0) { + return bestMatch; + } + else { + throw new NotFoundException(); + } + } + decodeRow(rowNumber, row, hints) { + const convertFNC1 = hints && (hints.get(DecodeHintType$1.ASSUME_GS1) === true); + const startPatternInfo = Code128Reader.findStartPattern(row); + const startCode = startPatternInfo[2]; + let currentRawCodesIndex = 0; + const rawCodes = new Uint8Array(20); + rawCodes[currentRawCodesIndex++] = startCode; + let codeSet; + switch (startCode) { + case Code128Reader.CODE_START_A: + codeSet = Code128Reader.CODE_CODE_A; + break; + case Code128Reader.CODE_START_B: + codeSet = Code128Reader.CODE_CODE_B; + break; + case Code128Reader.CODE_START_C: + codeSet = Code128Reader.CODE_CODE_C; + break; + default: + throw new FormatException(); + } + let done = false; + let isNextShifted = false; + let result = ''; + let lastStart = startPatternInfo[0]; + let nextStart = startPatternInfo[1]; + const counters = Int32Array.from([0, 0, 0, 0, 0, 0]); + let lastCode = 0; + let code = 0; + let checksumTotal = startCode; + let multiplier = 0; + let lastCharacterWasPrintable = true; + let upperMode = false; + let shiftUpperMode = false; + while (!done) { + const unshift = isNextShifted; + isNextShifted = false; + // Save off last code + lastCode = code; + // Decode another code from image + code = Code128Reader.decodeCode(row, counters, nextStart); + rawCodes[currentRawCodesIndex++] = code; + // Remember whether the last code was printable or not (excluding CODE_STOP) + if (code !== Code128Reader.CODE_STOP) { + lastCharacterWasPrintable = true; + } + // Add to checksum computation (if not CODE_STOP of course) + if (code !== Code128Reader.CODE_STOP) { + multiplier++; + checksumTotal += multiplier * code; + } + // Advance to where the next code will to start + lastStart = nextStart; + nextStart += counters.reduce((previous, current) => previous + current, 0); + // Take care of illegal start codes + switch (code) { + case Code128Reader.CODE_START_A: + case Code128Reader.CODE_START_B: + case Code128Reader.CODE_START_C: + throw new FormatException(); + } + switch (codeSet) { + case Code128Reader.CODE_CODE_A: + if (code < 64) { + if (shiftUpperMode === upperMode) { + result += String.fromCharCode((' '.charCodeAt(0) + code)); + } + else { + result += String.fromCharCode((' '.charCodeAt(0) + code + 128)); + } + shiftUpperMode = false; + } + else if (code < 96) { + if (shiftUpperMode === upperMode) { + result += String.fromCharCode((code - 64)); + } + else { + result += String.fromCharCode((code + 64)); + } + shiftUpperMode = false; + } + else { + // Don't let CODE_STOP, which always appears, affect whether whether we think the last + // code was printable or not. + if (code !== Code128Reader.CODE_STOP) { + lastCharacterWasPrintable = false; + } + switch (code) { + case Code128Reader.CODE_FNC_1: + if (convertFNC1) { + if (result.length === 0) { + // GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code + // is FNC1 then this is GS1-128. We add the symbology identifier. + result += ']C1'; + } + else { + // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) + result += String.fromCharCode(29); + } + } + break; + case Code128Reader.CODE_FNC_2: + case Code128Reader.CODE_FNC_3: + // do nothing? + break; + case Code128Reader.CODE_FNC_4_A: + if (!upperMode && shiftUpperMode) { + upperMode = true; + shiftUpperMode = false; + } + else if (upperMode && shiftUpperMode) { + upperMode = false; + shiftUpperMode = false; + } + else { + shiftUpperMode = true; + } + break; + case Code128Reader.CODE_SHIFT: + isNextShifted = true; + codeSet = Code128Reader.CODE_CODE_B; + break; + case Code128Reader.CODE_CODE_B: + codeSet = Code128Reader.CODE_CODE_B; + break; + case Code128Reader.CODE_CODE_C: + codeSet = Code128Reader.CODE_CODE_C; + break; + case Code128Reader.CODE_STOP: + done = true; + break; + } + } + break; + case Code128Reader.CODE_CODE_B: + if (code < 96) { + if (shiftUpperMode === upperMode) { + result += String.fromCharCode((' '.charCodeAt(0) + code)); + } + else { + result += String.fromCharCode((' '.charCodeAt(0) + code + 128)); + } + shiftUpperMode = false; + } + else { + if (code !== Code128Reader.CODE_STOP) { + lastCharacterWasPrintable = false; + } + switch (code) { + case Code128Reader.CODE_FNC_1: + if (convertFNC1) { + if (result.length === 0) { + // GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code + // is FNC1 then this is GS1-128. We add the symbology identifier. + result += ']C1'; + } + else { + // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) + result += String.fromCharCode(29); + } + } + break; + case Code128Reader.CODE_FNC_2: + case Code128Reader.CODE_FNC_3: + // do nothing? + break; + case Code128Reader.CODE_FNC_4_B: + if (!upperMode && shiftUpperMode) { + upperMode = true; + shiftUpperMode = false; + } + else if (upperMode && shiftUpperMode) { + upperMode = false; + shiftUpperMode = false; + } + else { + shiftUpperMode = true; + } + break; + case Code128Reader.CODE_SHIFT: + isNextShifted = true; + codeSet = Code128Reader.CODE_CODE_A; + break; + case Code128Reader.CODE_CODE_A: + codeSet = Code128Reader.CODE_CODE_A; + break; + case Code128Reader.CODE_CODE_C: + codeSet = Code128Reader.CODE_CODE_C; + break; + case Code128Reader.CODE_STOP: + done = true; + break; + } + } + break; + case Code128Reader.CODE_CODE_C: + if (code < 100) { + if (code < 10) { + result += '0'; + } + result += code; + } + else { + if (code !== Code128Reader.CODE_STOP) { + lastCharacterWasPrintable = false; + } + switch (code) { + case Code128Reader.CODE_FNC_1: + if (convertFNC1) { + if (result.length === 0) { + // GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code + // is FNC1 then this is GS1-128. We add the symbology identifier. + result += ']C1'; + } + else { + // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) + result += String.fromCharCode(29); + } + } + break; + case Code128Reader.CODE_CODE_A: + codeSet = Code128Reader.CODE_CODE_A; + break; + case Code128Reader.CODE_CODE_B: + codeSet = Code128Reader.CODE_CODE_B; + break; + case Code128Reader.CODE_STOP: + done = true; + break; + } + } + break; + } + // Unshift back to another code set if we were shifted + if (unshift) { + codeSet = codeSet === Code128Reader.CODE_CODE_A ? Code128Reader.CODE_CODE_B : Code128Reader.CODE_CODE_A; + } + } + const lastPatternSize = nextStart - lastStart; + // Check for ample whitespace following pattern, but, to do this we first need to remember that + // we fudged decoding CODE_STOP since it actually has 7 bars, not 6. There is a black bar left + // to read off. Would be slightly better to properly read. Here we just skip it: + nextStart = row.getNextUnset(nextStart); + if (!row.isRange(nextStart, Math.min(row.getSize(), nextStart + (nextStart - lastStart) / 2), false)) { + throw new NotFoundException(); + } + // Pull out from sum the value of the penultimate check code + checksumTotal -= multiplier * lastCode; + // lastCode is the checksum then: + if (checksumTotal % 103 !== lastCode) { + throw new ChecksumException(); + } + // Need to pull out the check digits from string + const resultLength = result.length; + if (resultLength === 0) { + // false positive + throw new NotFoundException(); + } + // Only bother if the result had at least one character, and if the checksum digit happened to + // be a printable character. If it was just interpreted as a control code, nothing to remove. + if (resultLength > 0 && lastCharacterWasPrintable) { + if (codeSet === Code128Reader.CODE_CODE_C) { + result = result.substring(0, resultLength - 2); + } + else { + result = result.substring(0, resultLength - 1); + } + } + const left = (startPatternInfo[1] + startPatternInfo[0]) / 2.0; + const right = lastStart + lastPatternSize / 2.0; + const rawCodesSize = rawCodes.length; + const rawBytes = new Uint8Array(rawCodesSize); + for (let i = 0; i < rawCodesSize; i++) { + rawBytes[i] = rawCodes[i]; + } + const points = [new ResultPoint(left, rowNumber), new ResultPoint(right, rowNumber)]; + return new Result(result, rawBytes, 0, points, BarcodeFormat$1.CODE_128, new Date().getTime()); + } + } + Code128Reader.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]), + ]; + Code128Reader.MAX_AVG_VARIANCE = 0.25; + Code128Reader.MAX_INDIVIDUAL_VARIANCE = 0.7; + Code128Reader.CODE_SHIFT = 98; + Code128Reader.CODE_CODE_C = 99; + Code128Reader.CODE_CODE_B = 100; + Code128Reader.CODE_CODE_A = 101; + Code128Reader.CODE_FNC_1 = 102; + Code128Reader.CODE_FNC_2 = 97; + Code128Reader.CODE_FNC_3 = 96; + Code128Reader.CODE_FNC_4_A = 101; + Code128Reader.CODE_FNC_4_B = 100; + Code128Reader.CODE_START_A = 103; + Code128Reader.CODE_START_B = 104; + Code128Reader.CODE_START_C = 105; + Code128Reader.CODE_STOP = 106; + + /** + * <p>Decodes Code 39 barcodes. Supports "Full ASCII Code 39" if USE_CODE_39_EXTENDED_MODE is set.</p> + * + * @author Sean Owen + * @see Code93Reader + */ + class Code39Reader extends OneDReader { + /** + * Creates a reader that assumes all encoded data is data, and does not treat the final + * character as a check digit. It will not decoded "extended Code 39" sequences. + */ + // public Code39Reader() { + // this(false); + // } + /** + * Creates a reader that can be configured to check the last character as a check digit. + * It will not decoded "extended Code 39" sequences. + * + * @param usingCheckDigit if true, treat the last data character as a check digit, not + * data, and verify that the checksum passes. + */ + // public Code39Reader(boolean usingCheckDigit) { + // this(usingCheckDigit, false); + // } + /** + * Creates a reader that can be configured to check the last character as a check digit, + * or optionally attempt to decode "extended Code 39" sequences that are used to encode + * the full ASCII character set. + * + * @param usingCheckDigit if true, treat the last data character as a check digit, not + * data, and verify that the checksum passes. + * @param extendedMode if true, will attempt to decode extended Code 39 sequences in the + * text. + */ + constructor(usingCheckDigit = false, extendedMode = false) { + super(); + this.usingCheckDigit = usingCheckDigit; + this.extendedMode = extendedMode; + this.decodeRowResult = ''; + this.counters = new Int32Array(9); + } + decodeRow(rowNumber, row, hints) { + let theCounters = this.counters; + theCounters.fill(0); + this.decodeRowResult = ''; + let start = Code39Reader.findAsteriskPattern(row, theCounters); + // Read off white space + let nextStart = row.getNextSet(start[1]); + let end = row.getSize(); + let decodedChar; + let lastStart; + do { + Code39Reader.recordPattern(row, nextStart, theCounters); + let pattern = Code39Reader.toNarrowWidePattern(theCounters); + if (pattern < 0) { + throw new NotFoundException(); + } + decodedChar = Code39Reader.patternToChar(pattern); + this.decodeRowResult += decodedChar; + lastStart = nextStart; + for (let counter of theCounters) { + nextStart += counter; + } + // Read off white space + nextStart = row.getNextSet(nextStart); + } while (decodedChar !== '*'); + this.decodeRowResult = this.decodeRowResult.substring(0, this.decodeRowResult.length - 1); // remove asterisk + // Look for whitespace after pattern: + let lastPatternSize = 0; + for (let counter of theCounters) { + lastPatternSize += counter; + } + let whiteSpaceAfterEnd = nextStart - lastStart - lastPatternSize; + // If 50% of last pattern size, following last pattern, is not whitespace, fail + // (but if it's whitespace to the very end of the image, that's OK) + if (nextStart !== end && (whiteSpaceAfterEnd * 2) < lastPatternSize) { + throw new NotFoundException(); + } + if (this.usingCheckDigit) { + let max = this.decodeRowResult.length - 1; + let total = 0; + for (let i = 0; i < max; i++) { + total += Code39Reader.ALPHABET_STRING.indexOf(this.decodeRowResult.charAt(i)); + } + if (this.decodeRowResult.charAt(max) !== Code39Reader.ALPHABET_STRING.charAt(total % 43)) { + throw new ChecksumException(); + } + this.decodeRowResult = this.decodeRowResult.substring(0, max); + } + if (this.decodeRowResult.length === 0) { + // false positive + throw new NotFoundException(); + } + let resultString; + if (this.extendedMode) { + resultString = Code39Reader.decodeExtended(this.decodeRowResult); + } + else { + resultString = this.decodeRowResult; + } + let left = (start[1] + start[0]) / 2.0; + let right = lastStart + lastPatternSize / 2.0; + return new Result(resultString, null, 0, [new ResultPoint(left, rowNumber), new ResultPoint(right, rowNumber)], BarcodeFormat$1.CODE_39, new Date().getTime()); + } + static findAsteriskPattern(row, counters) { + let width = row.getSize(); + let rowOffset = row.getNextSet(0); + let counterPosition = 0; + let patternStart = rowOffset; + let isWhite = false; + let patternLength = counters.length; + for (let i = rowOffset; i < width; i++) { + if (row.get(i) !== isWhite) { + counters[counterPosition]++; + } + else { + if (counterPosition === patternLength - 1) { + // Look for whitespace before start pattern, >= 50% of width of start pattern + if (this.toNarrowWidePattern(counters) === Code39Reader.ASTERISK_ENCODING && + row.isRange(Math.max(0, patternStart - Math.floor((i - patternStart) / 2)), patternStart, false)) { + return [patternStart, i]; + } + patternStart += counters[0] + counters[1]; + counters.copyWithin(0, 2, 2 + counterPosition - 1); + counters[counterPosition - 1] = 0; + counters[counterPosition] = 0; + counterPosition--; + } + else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + throw new NotFoundException(); + } + // For efficiency, returns -1 on failure. Not throwing here saved as many as 700 exceptions + // per image when using some of our blackbox images. + static toNarrowWidePattern(counters) { + let numCounters = counters.length; + let maxNarrowCounter = 0; + let wideCounters; + do { + let minCounter = 0x7fffffff; + for (let counter of counters) { + if (counter < minCounter && counter > maxNarrowCounter) { + minCounter = counter; + } + } + maxNarrowCounter = minCounter; + wideCounters = 0; + let totalWideCountersWidth = 0; + let pattern = 0; + for (let i = 0; i < numCounters; i++) { + let counter = counters[i]; + if (counter > maxNarrowCounter) { + pattern |= 1 << (numCounters - 1 - i); + wideCounters++; + totalWideCountersWidth += counter; + } + } + if (wideCounters === 3) { + // Found 3 wide counters, but are they close enough in width? + // We can perform a cheap, conservative check to see if any individual + // counter is more than 1.5 times the average: + for (let i = 0; i < numCounters && wideCounters > 0; i++) { + let counter = counters[i]; + if (counter > maxNarrowCounter) { + wideCounters--; + // totalWideCountersWidth = 3 * average, so this checks if counter >= 3/2 * average + if ((counter * 2) >= totalWideCountersWidth) { + return -1; + } + } + } + return pattern; + } + } while (wideCounters > 3); + return -1; + } + static patternToChar(pattern) { + for (let i = 0; i < Code39Reader.CHARACTER_ENCODINGS.length; i++) { + if (Code39Reader.CHARACTER_ENCODINGS[i] === pattern) { + return Code39Reader.ALPHABET_STRING.charAt(i); + } + } + if (pattern === Code39Reader.ASTERISK_ENCODING) { + return '*'; + } + throw new NotFoundException(); + } + static decodeExtended(encoded) { + let length = encoded.length; + let decoded = ''; + for (let i = 0; i < length; i++) { + let c = encoded.charAt(i); + if (c === '+' || c === '$' || c === '%' || c === '/') { + let next = encoded.charAt(i + 1); + let decodedChar = '\0'; + switch (c) { + case '+': + // +A to +Z map to a to z + if (next >= 'A' && next <= 'Z') { + decodedChar = String.fromCharCode(next.charCodeAt(0) + 32); + } + else { + throw new FormatException(); + } + break; + case '$': + // $A to $Z map to control codes SH to SB + if (next >= 'A' && next <= 'Z') { + decodedChar = String.fromCharCode(next.charCodeAt(0) - 64); + } + else { + throw new FormatException(); + } + break; + case '%': + // %A to %E map to control codes ESC to US + if (next >= 'A' && next <= 'E') { + decodedChar = String.fromCharCode(next.charCodeAt(0) - 38); + } + else if (next >= 'F' && next <= 'J') { + decodedChar = String.fromCharCode(next.charCodeAt(0) - 11); + } + else if (next >= 'K' && next <= 'O') { + decodedChar = String.fromCharCode(next.charCodeAt(0) + 16); + } + else if (next >= 'P' && next <= 'T') { + decodedChar = String.fromCharCode(next.charCodeAt(0) + 43); + } + else if (next === 'U') { + decodedChar = '\0'; + } + else if (next === 'V') { + decodedChar = '@'; + } + else if (next === 'W') { + decodedChar = '`'; + } + else if (next === 'X' || next === 'Y' || next === 'Z') { + decodedChar = '\x7f'; + } + else { + throw new FormatException(); + } + break; + case '/': + // /A to /O map to ! to , and /Z maps to : + if (next >= 'A' && next <= 'O') { + decodedChar = String.fromCharCode(next.charCodeAt(0) - 32); + } + else if (next === 'Z') { + decodedChar = ':'; + } + else { + throw new FormatException(); + } + break; + } + decoded += decodedChar; + // bump up i again since we read two characters + i++; + } + else { + decoded += c; + } + } + return decoded; + } + } + Code39Reader.ALPHABET_STRING = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%'; + /** + * These represent the encodings of characters, as patterns of wide and narrow bars. + * The 9 least-significant bits of each int correspond to the pattern of wide and narrow, + * with 1s representing "wide" and 0s representing narrow. + */ + Code39Reader.CHARACTER_ENCODINGS = [ + 0x034, 0x121, 0x061, 0x160, 0x031, 0x130, 0x070, 0x025, 0x124, 0x064, + 0x109, 0x049, 0x148, 0x019, 0x118, 0x058, 0x00D, 0x10C, 0x04C, 0x01C, + 0x103, 0x043, 0x142, 0x013, 0x112, 0x052, 0x007, 0x106, 0x046, 0x016, + 0x181, 0x0C1, 0x1C0, 0x091, 0x190, 0x0D0, 0x085, 0x184, 0x0C4, 0x0A8, + 0x0A2, 0x08A, 0x02A // /-% + ]; + Code39Reader.ASTERISK_ENCODING = 0x094; + + /** + * <p>Decodes ITF barcodes.</p> + * + * @author Tjieco + */ + class ITFReader extends OneDReader { + constructor() { + // private static W = 3; // Pixel width of a 3x wide line + // private static w = 2; // Pixel width of a 2x wide line + // private static N = 1; // Pixed width of a narrow line + super(...arguments); + // Stores the actual narrow line width of the image being decoded. + this.narrowLineWidth = -1; + } + // See ITFWriter.PATTERNS + /* + + /!** + * Patterns of Wide / Narrow lines to indicate each digit + *!/ + */ + decodeRow(rowNumber, row, hints) { + // Find out where the Middle section (payload) starts & ends + let startRange = this.decodeStart(row); + let endRange = this.decodeEnd(row); + let result = new StringBuilder(); + ITFReader.decodeMiddle(row, startRange[1], endRange[0], result); + let resultString = result.toString(); + let allowedLengths = null; + if (hints != null) { + allowedLengths = hints.get(DecodeHintType$1.ALLOWED_LENGTHS); + } + if (allowedLengths == null) { + allowedLengths = ITFReader.DEFAULT_ALLOWED_LENGTHS; + } + // To avoid false positives with 2D barcodes (and other patterns), make + // an assumption that the decoded string must be a 'standard' length if it's short + let length = resultString.length; + let lengthOK = false; + let maxAllowedLength = 0; + for (let value of allowedLengths) { + if (length === value) { + lengthOK = true; + break; + } + if (value > maxAllowedLength) { + maxAllowedLength = value; + } + } + if (!lengthOK && length > maxAllowedLength) { + lengthOK = true; + } + if (!lengthOK) { + throw new FormatException(); + } + const points = [new ResultPoint(startRange[1], rowNumber), new ResultPoint(endRange[0], rowNumber)]; + let resultReturn = new Result(resultString, null, // no natural byte representation for these barcodes + 0, points, BarcodeFormat$1.ITF, new Date().getTime()); + return resultReturn; + } + /* + /!** + * @param row row of black/white values to search + * @param payloadStart offset of start pattern + * @param resultString {@link StringBuilder} to append decoded chars to + * @throws NotFoundException if decoding could not complete successfully + *!/*/ + static decodeMiddle(row, payloadStart, payloadEnd, resultString) { + // Digits are interleaved in pairs - 5 black lines for one digit, and the + // 5 + // interleaved white lines for the second digit. + // Therefore, need to scan 10 lines and then + // split these into two arrays + let counterDigitPair = new Int32Array(10); // 10 + let counterBlack = new Int32Array(5); // 5 + let counterWhite = new Int32Array(5); // 5 + counterDigitPair.fill(0); + counterBlack.fill(0); + counterWhite.fill(0); + while (payloadStart < payloadEnd) { + // Get 10 runs of black/white. + OneDReader.recordPattern(row, payloadStart, counterDigitPair); + // Split them into each array + for (let k = 0; k < 5; k++) { + let twoK = 2 * k; + counterBlack[k] = counterDigitPair[twoK]; + counterWhite[k] = counterDigitPair[twoK + 1]; + } + let bestMatch = ITFReader.decodeDigit(counterBlack); + resultString.append(bestMatch.toString()); + bestMatch = this.decodeDigit(counterWhite); + resultString.append(bestMatch.toString()); + counterDigitPair.forEach(function (counterDigit) { + payloadStart += counterDigit; + }); + } + } + /*/!** + * Identify where the start of the middle / payload section starts. + * + * @param row row of black/white values to search + * @return Array, containing index of start of 'start block' and end of + * 'start block' + *!/*/ + decodeStart(row) { + let endStart = ITFReader.skipWhiteSpace(row); + let startPattern = ITFReader.findGuardPattern(row, endStart, ITFReader.START_PATTERN); + // Determine the width of a narrow line in pixels. We can do this by + // getting the width of the start pattern and dividing by 4 because its + // made up of 4 narrow lines. + this.narrowLineWidth = (startPattern[1] - startPattern[0]) / 4; + this.validateQuietZone(row, startPattern[0]); + return startPattern; + } + /*/!** + * The start & end patterns must be pre/post fixed by a quiet zone. This + * zone must be at least 10 times the width of a narrow line. Scan back until + * we either get to the start of the barcode or match the necessary number of + * quiet zone pixels. + * + * Note: Its assumed the row is reversed when using this method to find + * quiet zone after the end pattern. + * + * ref: http://www.barcode-1.net/i25code.html + * + * @param row bit array representing the scanned barcode. + * @param startPattern index into row of the start or end pattern. + * @throws NotFoundException if the quiet zone cannot be found + *!/*/ + validateQuietZone(row, startPattern) { + let quietCount = this.narrowLineWidth * 10; // expect to find this many pixels of quiet zone + // if there are not so many pixel at all let's try as many as possible + quietCount = quietCount < startPattern ? quietCount : startPattern; + for (let i = startPattern - 1; quietCount > 0 && i >= 0; i--) { + if (row.get(i)) { + break; + } + quietCount--; + } + if (quietCount !== 0) { + // Unable to find the necessary number of quiet zone pixels. + throw new NotFoundException(); + } + } + /* + /!** + * Skip all whitespace until we get to the first black line. + * + * @param row row of black/white values to search + * @return index of the first black line. + * @throws NotFoundException Throws exception if no black lines are found in the row + *!/*/ + static skipWhiteSpace(row) { + const width = row.getSize(); + const endStart = row.getNextSet(0); + if (endStart === width) { + throw new NotFoundException(); + } + return endStart; + } + /*/!** + * Identify where the end of the middle / payload section ends. + * + * @param row row of black/white values to search + * @return Array, containing index of start of 'end block' and end of 'end + * block' + *!/*/ + decodeEnd(row) { + // For convenience, reverse the row and then + // search from 'the start' for the end block + row.reverse(); + try { + let endStart = ITFReader.skipWhiteSpace(row); + let endPattern; + try { + endPattern = ITFReader.findGuardPattern(row, endStart, ITFReader.END_PATTERN_REVERSED[0]); + } + catch (error) { + if (error instanceof NotFoundException) { + endPattern = ITFReader.findGuardPattern(row, endStart, ITFReader.END_PATTERN_REVERSED[1]); + } + } + // The start & end patterns must be pre/post fixed by a quiet zone. This + // zone must be at least 10 times the width of a narrow line. + // ref: http://www.barcode-1.net/i25code.html + this.validateQuietZone(row, endPattern[0]); + // Now recalculate the indices of where the 'endblock' starts & stops to + // accommodate + // the reversed nature of the search + let temp = endPattern[0]; + endPattern[0] = row.getSize() - endPattern[1]; + endPattern[1] = row.getSize() - temp; + return endPattern; + } + finally { + // Put the row back the right way. + row.reverse(); + } + } + /* + /!** + * @param row row of black/white values to search + * @param rowOffset position to start search + * @param pattern pattern of counts of number of black and white pixels that are + * being searched for as a pattern + * @return start/end horizontal offset of guard pattern, as an array of two + * ints + * @throws NotFoundException if pattern is not found + *!/*/ + static findGuardPattern(row, rowOffset, pattern) { + let patternLength = pattern.length; + let counters = new Int32Array(patternLength); + let width = row.getSize(); + let isWhite = false; + let counterPosition = 0; + let patternStart = rowOffset; + counters.fill(0); + for (let x = rowOffset; x < width; x++) { + if (row.get(x) !== isWhite) { + counters[counterPosition]++; + } + else { + if (counterPosition === patternLength - 1) { + if (OneDReader.patternMatchVariance(counters, pattern, ITFReader.MAX_INDIVIDUAL_VARIANCE) < ITFReader.MAX_AVG_VARIANCE) { + return [patternStart, x]; + } + patternStart += counters[0] + counters[1]; + System.arraycopy(counters, 2, counters, 0, counterPosition - 1); + counters[counterPosition - 1] = 0; + counters[counterPosition] = 0; + counterPosition--; + } + else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + throw new NotFoundException(); + } + /*/!** + * Attempts to decode a sequence of ITF black/white lines into single + * digit. + * + * @param counters the counts of runs of observed black/white/black/... values + * @return The decoded digit + * @throws NotFoundException if digit cannot be decoded + *!/*/ + static decodeDigit(counters) { + let bestVariance = ITFReader.MAX_AVG_VARIANCE; // worst variance we'll accept + let bestMatch = -1; + let max = ITFReader.PATTERNS.length; + for (let i = 0; i < max; i++) { + let pattern = ITFReader.PATTERNS[i]; + let variance = OneDReader.patternMatchVariance(counters, pattern, ITFReader.MAX_INDIVIDUAL_VARIANCE); + if (variance < bestVariance) { + bestVariance = variance; + bestMatch = i; + } + else if (variance === bestVariance) { + // if we find a second 'best match' with the same variance, we can not reliably report to have a suitable match + bestMatch = -1; + } + } + if (bestMatch >= 0) { + return bestMatch % 10; + } + else { + throw new NotFoundException(); + } + } + } + ITFReader.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]) // 9 + ]; + ITFReader.MAX_AVG_VARIANCE = 0.38; + ITFReader.MAX_INDIVIDUAL_VARIANCE = 0.5; + /* /!** Valid ITF lengths. Anything longer than the largest value is also allowed. *!/*/ + ITFReader.DEFAULT_ALLOWED_LENGTHS = [6, 8, 10, 12, 14]; + /*/!** + * Start/end guard pattern. + * + * Note: The end pattern is reversed because the row is reversed before + * searching for the END_PATTERN + *!/*/ + ITFReader.START_PATTERN = Int32Array.from([1, 1, 1, 1]); + ITFReader.END_PATTERN_REVERSED = [ + Int32Array.from([1, 1, 2]), + Int32Array.from([1, 1, 3]) // 3x + ]; + + /** + * <p>Encapsulates functionality and implementation that is common to UPC and EAN families + * of one-dimensional barcodes.</p> + * + * @author dswitkin@google.com (Daniel Switkin) + * @author Sean Owen + * @author alasdair@google.com (Alasdair Mackintosh) + */ + class AbstractUPCEANReader extends OneDReader { + constructor() { + super(...arguments); + this.decodeRowStringBuffer = ''; + } + + static findStartGuardPattern(row) { + let foundStart = false; + let startRange; + let nextStart = 0; + let counters = Int32Array.from([0, 0, 0]); + while (!foundStart) { + counters = Int32Array.from([0, 0, 0]); + startRange = AbstractUPCEANReader.findGuardPattern(row, nextStart, false, this.START_END_PATTERN, counters); + let start = startRange[0]; + nextStart = startRange[1]; + let quietStart = start - (nextStart - start); + if (quietStart >= 0) { + foundStart = row.isRange(quietStart, start, false); + } + } + return startRange; + } + static checkChecksum(s) { + return AbstractUPCEANReader.checkStandardUPCEANChecksum(s); + } + static checkStandardUPCEANChecksum(s) { + let length = s.length; + if (length === 0) + return false; + let check = parseInt(s.charAt(length - 1), 10); + return AbstractUPCEANReader.getStandardUPCEANChecksum(s.substring(0, length - 1)) === check; + } + static getStandardUPCEANChecksum(s) { + let length = s.length; + let sum = 0; + for (let i = length - 1; i >= 0; i -= 2) { + let digit = s.charAt(i).charCodeAt(0) - '0'.charCodeAt(0); + if (digit < 0 || digit > 9) { + throw new FormatException(); + } + sum += digit; + } + sum *= 3; + for (let i = length - 2; i >= 0; i -= 2) { + let digit = s.charAt(i).charCodeAt(0) - '0'.charCodeAt(0); + if (digit < 0 || digit > 9) { + throw new FormatException(); + } + sum += digit; + } + return (1000 - sum) % 10; + } + static decodeEnd(row, endStart) { + return AbstractUPCEANReader.findGuardPattern(row, endStart, false, AbstractUPCEANReader.START_END_PATTERN, new Int32Array(AbstractUPCEANReader.START_END_PATTERN.length).fill(0)); + } + /** + * @throws NotFoundException + */ + static findGuardPatternWithoutCounters(row, rowOffset, whiteFirst, pattern) { + return this.findGuardPattern(row, rowOffset, whiteFirst, pattern, new Int32Array(pattern.length)); + } + /** + * @param row row of black/white values to search + * @param rowOffset position to start search + * @param whiteFirst if true, indicates that the pattern specifies white/black/white/... + * pixel counts, otherwise, it is interpreted as black/white/black/... + * @param pattern pattern of counts of number of black and white pixels that are being + * searched for as a pattern + * @param counters array of counters, as long as pattern, to re-use + * @return start/end horizontal offset of guard pattern, as an array of two ints + * @throws NotFoundException if pattern is not found + */ + static findGuardPattern(row, rowOffset, whiteFirst, pattern, counters) { + let width = row.getSize(); + rowOffset = whiteFirst ? row.getNextUnset(rowOffset) : row.getNextSet(rowOffset); + let counterPosition = 0; + let patternStart = rowOffset; + let patternLength = pattern.length; + let isWhite = whiteFirst; + for (let x = rowOffset; x < width; x++) { + if (row.get(x) !== isWhite) { + counters[counterPosition]++; + } + else { + if (counterPosition === patternLength - 1) { + if (OneDReader.patternMatchVariance(counters, pattern, AbstractUPCEANReader.MAX_INDIVIDUAL_VARIANCE) < AbstractUPCEANReader.MAX_AVG_VARIANCE) { + return Int32Array.from([patternStart, x]); + } + patternStart += counters[0] + counters[1]; + let slice = counters.slice(2, counters.length - 1); + for (let i = 0; i < counterPosition - 1; i++) { + counters[i] = slice[i]; + } + counters[counterPosition - 1] = 0; + counters[counterPosition] = 0; + counterPosition--; + } + else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + throw new NotFoundException(); + } + static decodeDigit(row, counters, rowOffset, patterns) { + this.recordPattern(row, rowOffset, counters); + let bestVariance = this.MAX_AVG_VARIANCE; + let bestMatch = -1; + let max = patterns.length; + for (let i = 0; i < max; i++) { + let pattern = patterns[i]; + let variance = OneDReader.patternMatchVariance(counters, pattern, AbstractUPCEANReader.MAX_INDIVIDUAL_VARIANCE); + if (variance < bestVariance) { + bestVariance = variance; + bestMatch = i; + } + } + if (bestMatch >= 0) { + return bestMatch; + } + else { + throw new NotFoundException(); + } + } + } + // These two values are critical for determining how permissive the decoding will be. + // We've arrived at these values through a lot of trial and error. Setting them any higher + // lets false positives creep in quickly. + AbstractUPCEANReader.MAX_AVG_VARIANCE = 0.48; + AbstractUPCEANReader.MAX_INDIVIDUAL_VARIANCE = 0.7; + /** + * Start/end guard pattern. + */ + AbstractUPCEANReader.START_END_PATTERN = Int32Array.from([1, 1, 1]); + /** + * Pattern marking the middle of a UPC/EAN pattern, separating the two halves. + */ + AbstractUPCEANReader.MIDDLE_PATTERN = Int32Array.from([1, 1, 1, 1, 1]); + /** + * end guard pattern. + */ + AbstractUPCEANReader.END_PATTERN = Int32Array.from([1, 1, 1, 1, 1, 1]); + /** + * "Odd", or "L" patterns used to encode UPC/EAN digits. + */ + AbstractUPCEANReader.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]), + ]; + + /** + * @see UPCEANExtension2Support + */ + class UPCEANExtension5Support { + constructor() { + this.CHECK_DIGIT_ENCODINGS = [0x18, 0x14, 0x12, 0x11, 0x0C, 0x06, 0x03, 0x0A, 0x09, 0x05]; + this.decodeMiddleCounters = Int32Array.from([0, 0, 0, 0]); + this.decodeRowStringBuffer = ''; + } + decodeRow(rowNumber, row, extensionStartRange) { + let result = this.decodeRowStringBuffer; + let end = this.decodeMiddle(row, extensionStartRange, result); + let resultString = result.toString(); + let extensionData = UPCEANExtension5Support.parseExtensionString(resultString); + let resultPoints = [ + new ResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0, rowNumber), + new ResultPoint(end, rowNumber) + ]; + let extensionResult = new Result(resultString, null, 0, resultPoints, BarcodeFormat$1.UPC_EAN_EXTENSION, new Date().getTime()); + if (extensionData != null) { + extensionResult.putAllMetadata(extensionData); + } + return extensionResult; + } + decodeMiddle(row, startRange, resultString) { + let counters = this.decodeMiddleCounters; + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + let end = row.getSize(); + let rowOffset = startRange[1]; + let lgPatternFound = 0; + for (let x = 0; x < 5 && rowOffset < end; x++) { + let bestMatch = AbstractUPCEANReader.decodeDigit( + row, + counters, + rowOffset, + AbstractUPCEANReader.L_AND_G_PATTERNS); + resultString += String.fromCharCode(('0'.charCodeAt(0) + bestMatch % 10)); + for (let counter of counters) { + rowOffset += counter; + } + if (bestMatch >= 10) { + lgPatternFound |= 1 << (4 - x); + } + if (x !== 4) { + // Read off separator if not last + rowOffset = row.getNextSet(rowOffset); + rowOffset = row.getNextUnset(rowOffset); + } + } + if (resultString.length !== 5) { + throw new NotFoundException(); + } + let checkDigit = this.determineCheckDigit(lgPatternFound); + if (UPCEANExtension5Support.extensionChecksum(resultString.toString()) !== checkDigit) { + throw new NotFoundException(); + } + return rowOffset; + } + static extensionChecksum(s) { + let length = s.length; + let sum = 0; + for (let i = length - 2; i >= 0; i -= 2) { + sum += s.charAt(i).charCodeAt(0) - '0'.charCodeAt(0); + } + sum *= 3; + for (let i = length - 1; i >= 0; i -= 2) { + sum += s.charAt(i).charCodeAt(0) - '0'.charCodeAt(0); + } + sum *= 3; + return sum % 10; + } + determineCheckDigit(lgPatternFound) { + for (let d = 0; d < 10; d++) { + if (lgPatternFound === this.CHECK_DIGIT_ENCODINGS[d]) { + return d; + } + } + throw new NotFoundException(); + } + static parseExtensionString(raw) { + if (raw.length !== 5) { + return null; + } + let value = UPCEANExtension5Support.parseExtension5String(raw); + if (value == null) { + return null; + } + return new Map([[ResultMetadataType$1.SUGGESTED_PRICE, value]]); + } + static parseExtension5String(raw) { + let currency; + switch (raw.charAt(0)) { + case '0': + currency = '£'; + break; + case '5': + currency = '$'; + break; + case '9': + // Reference: http://www.jollytech.com + switch (raw) { + case '90000': + // No suggested retail price + return null; + case '99991': + // Complementary + return '0.00'; + case '99990': + return 'Used'; + } + // Otherwise... unknown currency? + currency = ''; + break; + default: + currency = ''; + break; + } + let rawAmount = parseInt(raw.substring(1)); + let unitsString = (rawAmount / 100).toString(); + let hundredths = rawAmount % 100; + let hundredthsString = hundredths < 10 ? '0' + hundredths : hundredths.toString(); // fixme + return currency + unitsString + '.' + hundredthsString; + } + } + + /** + * @see UPCEANExtension5Support + */ + class UPCEANExtension2Support { + constructor() { + this.decodeMiddleCounters = Int32Array.from([0, 0, 0, 0]); + this.decodeRowStringBuffer = ''; + } + decodeRow(rowNumber, row, extensionStartRange) { + let result = this.decodeRowStringBuffer; + let end = this.decodeMiddle(row, extensionStartRange, result); + let resultString = result.toString(); + let extensionData = UPCEANExtension2Support.parseExtensionString(resultString); + let resultPoints = [ + new ResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0, rowNumber), + new ResultPoint(end, rowNumber) + ]; + let extensionResult = new Result(resultString, null, 0, resultPoints, BarcodeFormat$1.UPC_EAN_EXTENSION, new Date().getTime()); + if (extensionData != null) { + extensionResult.putAllMetadata(extensionData); + } + return extensionResult; + } + decodeMiddle(row, startRange, resultString) { + let counters = this.decodeMiddleCounters; + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + let end = row.getSize(); + let rowOffset = startRange[1]; + let checkParity = 0; + for (let x = 0; x < 2 && rowOffset < end; x++) { + let bestMatch = AbstractUPCEANReader.decodeDigit(row, counters, rowOffset, AbstractUPCEANReader.L_AND_G_PATTERNS); + resultString += String.fromCharCode(('0'.charCodeAt(0) + bestMatch % 10)); + for (let counter of counters) { + rowOffset += counter; + } + if (bestMatch >= 10) { + checkParity |= 1 << (1 - x); + } + if (x !== 1) { + // Read off separator if not last + rowOffset = row.getNextSet(rowOffset); + rowOffset = row.getNextUnset(rowOffset); + } + } + if (resultString.length !== 2) { + throw new NotFoundException(); + } + if (parseInt(resultString.toString()) % 4 !== checkParity) { + throw new NotFoundException(); + } + return rowOffset; + } + static parseExtensionString(raw) { + if (raw.length !== 2) { + return null; + } + return new Map([[ResultMetadataType$1.ISSUE_NUMBER, parseInt(raw)]]); + } + } + + class UPCEANExtensionSupport { + static decodeRow(rowNumber, row, rowOffset) { + let extensionStartRange = AbstractUPCEANReader.findGuardPattern( + row, + rowOffset, + false, + this.EXTENSION_START_PATTERN, + new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0)); + try { + // return null; + let fiveSupport = new UPCEANExtension5Support(); + return fiveSupport.decodeRow(rowNumber, row, extensionStartRange); + } + catch (err) { + // return null; + let twoSupport = new UPCEANExtension2Support(); + return twoSupport.decodeRow(rowNumber, row, extensionStartRange); + } + } + } + UPCEANExtensionSupport.EXTENSION_START_PATTERN = Int32Array.from([1, 1, 2]); + + /** + * <p>Encapsulates functionality and implementation that is common to UPC and EAN families + * of one-dimensional barcodes.</p> + * + * @author dswitkin@google.com (Daniel Switkin) + * @author Sean Owen + * @author alasdair@google.com (Alasdair Mackintosh) + */ + class UPCEANReader extends AbstractUPCEANReader { + constructor() { + super(); + this.decodeRowStringBuffer = ''; + UPCEANReader.L_AND_G_PATTERNS = UPCEANReader.L_PATTERNS.map(arr => Int32Array.from(arr)); + for (let i = 10; i < 20; i++) { + let widths = UPCEANReader.L_PATTERNS[i - 10]; + let reversedWidths = new Int32Array(widths.length); + for (let j = 0; j < widths.length; j++) { + reversedWidths[j] = widths[widths.length - j - 1]; + } + UPCEANReader.L_AND_G_PATTERNS[i] = reversedWidths; + } + } + decodeRow(rowNumber, row, hints) { + let startGuardRange = UPCEANReader.findStartGuardPattern(row); + let resultPointCallback = hints == null ? null : hints.get(DecodeHintType$1.NEED_RESULT_POINT_CALLBACK); + if (resultPointCallback != null) { + const resultPoint = new ResultPoint((startGuardRange[0] + startGuardRange[1]) / 2.0, rowNumber); + resultPointCallback.foundPossibleResultPoint(resultPoint); + } + let budello = this.decodeMiddle(row, startGuardRange, this.decodeRowStringBuffer); + let endStart = budello.rowOffset; + let result = budello.resultString; + if (resultPointCallback != null) { + const resultPoint = new ResultPoint(endStart, rowNumber); + resultPointCallback.foundPossibleResultPoint(resultPoint); + } + let endRange = this.decodeEnd(row, endStart); + if (resultPointCallback != null) { + const resultPoint = new ResultPoint((endRange[0] + endRange[1]) / 2.0, rowNumber); + resultPointCallback.foundPossibleResultPoint(resultPoint); + } + // Make sure there is a quiet zone at least as big as the end pattern after the barcode. The + // spec might want more whitespace, but in practice this is the maximum we can count on. + let end = endRange[1]; + let quietEnd = end + (end - endRange[0]); + if (quietEnd >= row.getSize() || !row.isRange(end, quietEnd, false)) { + throw new NotFoundException(); + } + let resultString = result.toString(); + // UPC/EAN should never be less than 8 chars anyway + if (resultString.length < 8) { + throw new FormatException(); + } + if (!UPCEANReader.checkChecksum(resultString)) { + throw new ChecksumException(); + } + let left = (startGuardRange[1] + startGuardRange[0]) / 2.0; + let right = (endRange[1] + endRange[0]) / 2.0; + let format = this.getBarcodeFormat(); + let resultPoint = [new ResultPoint(left, rowNumber), new ResultPoint(right, rowNumber)]; + let decodeResult = new Result(resultString, null, 0, resultPoint, format, new Date().getTime()); + let extensionLength = 0; + try { + let extensionResult = UPCEANExtensionSupport.decodeRow(rowNumber, row, endRange[1]); + decodeResult.putMetadata(ResultMetadataType$1.UPC_EAN_EXTENSION, extensionResult.getText()); + decodeResult.putAllMetadata(extensionResult.getResultMetadata()); + decodeResult.addResultPoints(extensionResult.getResultPoints()); + extensionLength = extensionResult.getText().length; + } + catch (ignoreError) {} + let allowedExtensions = hints == null ? null : hints.get(DecodeHintType$1.ALLOWED_EAN_EXTENSIONS); + if (allowedExtensions != null) { + let valid = false; + for (let length in allowedExtensions) { + if (extensionLength.toString() === length) { // check me + valid = true; + break; + } + } + if (!valid) { + throw new NotFoundException(); + } + } + return decodeResult; + } + decodeEnd(row, endStart) { + return UPCEANReader.findGuardPattern( + row, endStart, false, UPCEANReader.START_END_PATTERN, + new Int32Array(UPCEANReader.START_END_PATTERN.length).fill(0)); + } + static checkChecksum(s) { + return UPCEANReader.checkStandardUPCEANChecksum(s); + } + static checkStandardUPCEANChecksum(s) { + let length = s.length; + if (length === 0) + return false; + let check = parseInt(s.charAt(length - 1), 10); + return UPCEANReader.getStandardUPCEANChecksum(s.substring(0, length - 1)) === check; + } + static getStandardUPCEANChecksum(s) { + let length = s.length; + let sum = 0; + for (let i = length - 1; i >= 0; i -= 2) { + let digit = s.charAt(i).charCodeAt(0) - '0'.charCodeAt(0); + if (digit < 0 || digit > 9) { + throw new FormatException(); + } + sum += digit; + } + sum *= 3; + for (let i = length - 2; i >= 0; i -= 2) { + let digit = s.charAt(i).charCodeAt(0) - '0'.charCodeAt(0); + if (digit < 0 || digit > 9) { + throw new FormatException(); + } + sum += digit; + } + return (1000 - sum) % 10; + } + } + + /** + * <p>Implements decoding of the EAN-13 format.</p> + * + * @author dswitkin@google.com (Daniel Switkin) + * @author Sean Owen + * @author alasdair@google.com (Alasdair Mackintosh) + */ + class EAN13Reader extends UPCEANReader { + constructor() { + super(); + this.decodeMiddleCounters = Int32Array.from([0, 0, 0, 0]); + } + decodeMiddle(row, startRange, resultString) { + let counters = this.decodeMiddleCounters; + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + let end = row.getSize(); + let rowOffset = startRange[1]; + let lgPatternFound = 0; + for (let x = 0; x < 6 && rowOffset < end; x++) { + let bestMatch = UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_AND_G_PATTERNS); + resultString += String.fromCharCode(('0'.charCodeAt(0) + bestMatch % 10)); + for (let counter of counters) { + rowOffset += counter; + } + if (bestMatch >= 10) { + lgPatternFound |= 1 << (5 - x); + } + } + resultString = EAN13Reader.determineFirstDigit(resultString, lgPatternFound); + let middleRange = UPCEANReader.findGuardPattern( + row, + rowOffset, + true, + UPCEANReader.MIDDLE_PATTERN, + new Int32Array(UPCEANReader.MIDDLE_PATTERN.length).fill(0)); + rowOffset = middleRange[1]; + for (let x = 0; x < 6 && rowOffset < end; x++) { + let bestMatch = UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_PATTERNS); + resultString += String.fromCharCode(('0'.charCodeAt(0) + bestMatch)); + for (let counter of counters) { + rowOffset += counter; + } + } + return { rowOffset, resultString }; + } + getBarcodeFormat() { + return BarcodeFormat$1.EAN_13; + } + static determineFirstDigit(resultString, lgPatternFound) { + for (let d = 0; d < 10; d++) { + if (lgPatternFound === this.FIRST_DIGIT_ENCODINGS[d]) { + resultString = String.fromCharCode(('0'.charCodeAt(0) + d)) + resultString; + return resultString; + } + } + throw new NotFoundException(); + } + } + EAN13Reader.FIRST_DIGIT_ENCODINGS = [0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A]; + + /** + * <p>Implements decoding of the EAN-8 format.</p> + * + * @author Sean Owen + */ + class EAN8Reader extends UPCEANReader { + constructor() { + super(); + this.decodeMiddleCounters = Int32Array.from([0, 0, 0, 0]); + } + decodeMiddle(row, startRange, resultString) { + const counters = this.decodeMiddleCounters; + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + let end = row.getSize(); + let rowOffset = startRange[1]; + for (let x = 0; x < 4 && rowOffset < end; x++) { + let bestMatch = UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_PATTERNS); + resultString += String.fromCharCode(('0'.charCodeAt(0) + bestMatch)); + for (let counter of counters) { + rowOffset += counter; + } + } + let middleRange = UPCEANReader.findGuardPattern(row, rowOffset, true, UPCEANReader.MIDDLE_PATTERN, new Int32Array(UPCEANReader.MIDDLE_PATTERN.length).fill(0)); + rowOffset = middleRange[1]; + for (let x = 0; x < 4 && rowOffset < end; x++) { + let bestMatch = UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_PATTERNS); + resultString += String.fromCharCode(('0'.charCodeAt(0) + bestMatch)); + for (let counter of counters) { + rowOffset += counter; + } + } + return { rowOffset, resultString }; + } + getBarcodeFormat() { + return BarcodeFormat$1.EAN_8; + } + } + + /** + * Encapsulates functionality and implementation that is common to all families + * of one-dimensional barcodes. + * + * @author dswitkin@google.com (Daniel Switkin) + * @author Sean Owen + * @author sam2332 (Sam Rudloff) + * + * @source https://github.com/zxing/zxing/blob/3c96923276dd5785d58eb970b6ba3f80d36a9505/core/src/main/java/com/google/zxing/oned/UPCAReader.java + * + * @experimental + */ + class UPCAReader extends UPCEANReader { + constructor() { + super(...arguments); + this.ean13Reader = new EAN13Reader(); + } + // @Override + getBarcodeFormat() { + return BarcodeFormat$1.UPC_A; + } + // Note that we don't try rotation without the try harder flag, even if rotation was supported. + // @Override + decode(image, hints) { + return this.maybeReturnResult(this.ean13Reader.decode(image)); + } + // @Override + decodeRow(rowNumber, row, hints) { + return this.maybeReturnResult(this.ean13Reader.decodeRow(rowNumber, row, hints)); + } + // @Override + decodeMiddle(row, startRange, resultString) { + return this.ean13Reader.decodeMiddle(row, startRange, resultString); + } + maybeReturnResult(result) { + let text = result.getText(); + if (text.charAt(0) === '0') { + let upcaResult = new Result(text.substring(1), null, null, result.getResultPoints(), BarcodeFormat$1.UPC_A); + if (result.getResultMetadata() != null) { + upcaResult.putAllMetadata(result.getResultMetadata()); + } + return upcaResult; + } + else { + throw new NotFoundException(); + } + } + reset() { + this.ean13Reader.reset(); + } + } + + /** + * <p>Implements decoding of the UPC-E format.</p> + * <p><a href="http://www.barcodeisland.com/upce.phtml">This</a> is a great reference for + * UPC-E information.</p> + * + * @author Sean Owen + * + * @source https://github.com/zxing/zxing/blob/3c96923276dd5785d58eb970b6ba3f80d36a9505/core/src/main/java/com/google/zxing/oned/UPCEReader.java + * + * @experimental + */ + /* final */ class UPCEReader extends UPCEANReader { + constructor() { + super(); + this.decodeMiddleCounters = new Int32Array(4); + } + /** + * @throws NotFoundException + */ + // @Override + decodeMiddle(row, startRange, result) { + const counters = this.decodeMiddleCounters.map(x => x); + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + const end = row.getSize(); + let rowOffset = startRange[1]; + let lgPatternFound = 0; + for (let x = 0; x < 6 && rowOffset < end; x++) { + const bestMatch = UPCEReader.decodeDigit( + row, counters, rowOffset, UPCEReader.L_AND_G_PATTERNS); + result += String.fromCharCode(('0'.charCodeAt(0) + (bestMatch % 10))); + for (let counter of counters) { + rowOffset += counter; + } + if (bestMatch >= 10) { + lgPatternFound |= (1 << (5 - x)); + } + } + let resultString = UPCEReader.determineNumSysAndCheckDigit( + result, lgPatternFound); + return {rowOffset, resultString}; + } + /** + * @throws NotFoundException + */ + // @Override + decodeEnd(row, endStart) { + return UPCEReader.findGuardPatternWithoutCounters( + row, endStart, true, UPCEReader.MIDDLE_END_PATTERN); + } + /** + * @throws FormatException + */ + // @Override + checkChecksum(s) { + return UPCEANReader.checkChecksum(UPCEReader.convertUPCEtoUPCA(s)); + } + /** + * @throws NotFoundException + */ + static determineNumSysAndCheckDigit(resultString, lgPatternFound) { + for (let numSys = 0; numSys <= 1; numSys++) { + for (let d = 0; d < 10; d++) { + if (lgPatternFound === this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[numSys][d]) { + let prefix = String.fromCharCode('0'.charCodeAt(0) + numSys); + let suffix = String.fromCharCode('0'.charCodeAt(0) + d); + return prefix + resultString + suffix; + } + } + } + throw NotFoundException.getNotFoundInstance(); + } + // @Override + getBarcodeFormat() { + return BarcodeFormat$1.UPC_E; + } + /** + * Expands a UPC-E value back into its full, equivalent UPC-A code value. + * + * @param upce UPC-E code as string of digits + * @return equivalent UPC-A code as string of digits + */ + static convertUPCEtoUPCA(upce) { + // the following line is equivalent to upce.getChars(1, 7, upceChars, 0); + const upceChars = upce.slice(1, 7).split('').map(x => x.charCodeAt(0)); + const result = new StringBuilder( /*12*/); + result.append(upce.charAt(0)); + let lastChar = upceChars[5]; + switch (lastChar) { + case 0: + case 1: + case 2: + result.appendChars(upceChars, 0, 2); + result.append(lastChar); + result.append('0000'); + result.appendChars(upceChars, 2, 3); + break; + case 3: + result.appendChars(upceChars, 0, 3); + result.append('00000'); + result.appendChars(upceChars, 3, 2); + break; + case 4: + result.appendChars(upceChars, 0, 4); + result.append('00000'); + result.append(upceChars[4]); + break; + default: + result.appendChars(upceChars, 0, 5); + result.append('0000'); + result.append(lastChar); + break; + } + // Only append check digit in conversion if supplied + if (upce.length >= 8) { + result.append(upce.charAt(7)); + } + return result.toString(); + } + } + /** + * The pattern that marks the middle, and end, of a UPC-E pattern. + * There is no "second half" to a UPC-E barcode. + */ + UPCEReader.MIDDLE_END_PATTERN = Int32Array.from([1, 1, 1, 1, 1, 1]); + // For an UPC-E barcode, the final digit is represented by the parities used + // to encode the middle six digits, according to the table below. + // + // Parity of next 6 digits + // Digit 0 1 2 3 4 5 + // 0 Even Even Even Odd Odd Odd + // 1 Even Even Odd Even Odd Odd + // 2 Even Even Odd Odd Even Odd + // 3 Even Even Odd Odd Odd Even + // 4 Even Odd Even Even Odd Odd + // 5 Even Odd Odd Even Even Odd + // 6 Even Odd Odd Odd Even Even + // 7 Even Odd Even Odd Even Odd + // 8 Even Odd Even Odd Odd Even + // 9 Even Odd Odd Even Odd Even + // + // The encoding is represented by the following array, which is a bit pattern + // using Odd = 0 and Even = 1. For example, 5 is represented by: + // + // Odd Even Even Odd Odd Even + // in binary: + // 0 1 1 0 0 1 == 0x19 + // + /** + * See {@link #L_AND_G_PATTERNS}; these values similarly represent patterns of + * even-odd parity encodings of digits that imply both the number system (0 or 1) + * used, and the check digit. + */ + UPCEReader.NUMSYS_AND_CHECK_DIGIT_PATTERNS = [ + Int32Array.from([0x38, 0x34, 0x32, 0x31, 0x2C, 0x26, 0x23, 0x2A, 0x29, 0x25]), + Int32Array.from([0x07, 0x0B, 0x0D, 0x0E, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A]), + ]; + + /** + * <p>A reader that can read all available UPC/EAN formats. If a caller wants to try to + * read all such formats, it is most efficient to use this implementation rather than invoke + * individual readers.</p> + * + * @author Sean Owen + */ + class MultiFormatUPCEANReader extends OneDReader { + constructor(hints) { + super(); + let possibleFormats = hints == null ? null : hints.get(DecodeHintType$1.POSSIBLE_FORMATS); + let readers = []; + if (!isNullOrUndefined(possibleFormats)) { + if (possibleFormats.indexOf(BarcodeFormat$1.EAN_13) > -1) { + readers.push(new EAN13Reader()); + } + if (possibleFormats.indexOf(BarcodeFormat$1.UPC_A) > -1) { + readers.push(new UPCAReader()); + } + if (possibleFormats.indexOf(BarcodeFormat$1.EAN_8) > -1) { + readers.push(new EAN8Reader()); + } + if (possibleFormats.indexOf(BarcodeFormat$1.UPC_E) > -1) { + readers.push(new UPCEReader()); + } + } else { + // No hints provided. + readers.push(new EAN13Reader()); + readers.push(new UPCAReader()); + readers.push(new EAN8Reader()); + readers.push(new UPCEReader()); + } + this.readers = readers; + } + decodeRow(rowNumber, row, hints) { + for (let reader of this.readers) { + try { + // const result: Result = reader.decodeRow(rowNumber, row, startGuardPattern, hints); + const result = reader.decodeRow(rowNumber, row, hints); + // Special case: a 12-digit code encoded in UPC-A is identical to a "0" + // followed by those 12 digits encoded as EAN-13. Each will recognize such a code, + // UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0". + // Individually these are correct and their readers will both read such a code + // and correctly call it EAN-13, or UPC-A, respectively. + // + // In this case, if we've been looking for both types, we'd like to call it + // a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read + // UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A + // result if appropriate. + // + // But, don't return UPC-A if UPC-A was not a requested format! + const ean13MayBeUPCA = result.getBarcodeFormat() === BarcodeFormat$1.EAN_13 && + result.getText().charAt(0) === '0'; + // @SuppressWarnings("unchecked") + const possibleFormats = hints == null ? null : hints.get(DecodeHintType$1.POSSIBLE_FORMATS); + const canReturnUPCA = possibleFormats == null || possibleFormats.includes(BarcodeFormat$1.UPC_A); + if (ean13MayBeUPCA && canReturnUPCA) { + const rawBytes = result.getRawBytes(); + // Transfer the metadata across + const resultUPCA = new Result( + result.getText().substring(1), + rawBytes, + (rawBytes ? rawBytes.length : null), + result.getResultPoints(), + BarcodeFormat$1.UPC_A); + resultUPCA.putAllMetadata(result.getResultMetadata()); + return resultUPCA; + } + return result; + } + catch (err) { + // continue; + } + } + throw new NotFoundException(); + } + reset() { + for (let reader of this.readers) { + reader.reset(); + } + } + } + + // import Integer from '../../util/Integer'; + // import Float from '../../util/Float'; + class AbstractRSSReader extends OneDReader { + 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(counters, finderPatterns) { + for (let value = 0; value < finderPatterns.length; value++) { + if (OneDReader.patternMatchVariance(counters, finderPatterns[value], AbstractRSSReader.MAX_INDIVIDUAL_VARIANCE) < AbstractRSSReader.MAX_AVG_VARIANCE) { + return value; + } + } + throw new NotFoundException(); + } + /** + * @param array values to sum + * @return sum of values + * @deprecated call {@link MathUtils#sum(int[])} + */ + static count(array) { + return MathUtils.sum(new Int32Array(array)); + } + static increment(array, errors) { + let index = 0; + let biggestError = errors[0]; + for (let i = 1; i < array.length; i++) { + if (errors[i] > biggestError) { + biggestError = errors[i]; + index = i; + } + } + array[index]++; + } + static decrement(array, errors) { + let index = 0; + let biggestError = errors[0]; + for (let i = 1; i < array.length; i++) { + if (errors[i] < biggestError) { + biggestError = errors[i]; + index = i; + } + } + array[index]--; + } + static isFinderPattern(counters) { + let firstTwoSum = counters[0] + counters[1]; + let sum = firstTwoSum + counters[2] + counters[3]; + let ratio = firstTwoSum / sum; + if (ratio >= AbstractRSSReader.MIN_FINDER_PATTERN_RATIO && ratio <= AbstractRSSReader.MAX_FINDER_PATTERN_RATIO) { + // passes ratio test in spec, but see if the counts are unreasonable + let minCounter = Number.MAX_SAFE_INTEGER; + let maxCounter = Number.MIN_SAFE_INTEGER; + for (let counter of counters) { + if (counter > maxCounter) { + maxCounter = counter; + } + if (counter < minCounter) { + minCounter = counter; + } + } + return maxCounter < 10 * minCounter; + } + return false; + } + } + AbstractRSSReader.MAX_AVG_VARIANCE = 0.2; + AbstractRSSReader.MAX_INDIVIDUAL_VARIANCE = 0.45; + AbstractRSSReader.MIN_FINDER_PATTERN_RATIO = 9.5 / 12.0; + AbstractRSSReader.MAX_FINDER_PATTERN_RATIO = 12.5 / 14.0; + + class DataCharacter { + constructor(value, checksumPortion) { + this.value = value; + this.checksumPortion = checksumPortion; + } + getValue() { + return this.value; + } + getChecksumPortion() { + return this.checksumPortion; + } + toString() { + return this.value + '(' + this.checksumPortion + ')'; + } + equals(o) { + if (!(o instanceof DataCharacter)) { + return false; + } + const that = o; + return this.value === that.value && this.checksumPortion === that.checksumPortion; + } + hashCode() { + return this.value ^ this.checksumPortion; + } + } + + class FinderPattern { + constructor(value, startEnd, start, end, rowNumber) { + this.value = value; + this.startEnd = startEnd; + this.value = value; + this.startEnd = startEnd; + this.resultPoints = new Array(); + this.resultPoints.push(new ResultPoint(start, rowNumber)); + this.resultPoints.push(new ResultPoint(end, rowNumber)); + } + getValue() { + return this.value; + } + getStartEnd() { + return this.startEnd; + } + getResultPoints() { + return this.resultPoints; + } + equals(o) { + if (!(o instanceof FinderPattern)) { + return false; + } + const that = o; + return this.value === that.value; + } + hashCode() { + return this.value; + } + } + + /** + * RSS util functions. + */ + class RSSUtils { + constructor() { } + static getRSSvalue(widths, maxWidth, noNarrow) { + let n = 0; + for (let width of widths) { + n += width; + } + let val = 0; + let narrowMask = 0; + let elements = widths.length; + for (let bar = 0; bar < elements - 1; bar++) { + let elmWidth; + for (elmWidth = 1, narrowMask |= 1 << bar; elmWidth < widths[bar]; elmWidth++, narrowMask &= ~(1 << bar)) { + let subVal = RSSUtils.combins(n - elmWidth - 1, elements - bar - 2); + if (noNarrow && (narrowMask === 0) && (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { + subVal -= RSSUtils.combins(n - elmWidth - (elements - bar), elements - bar - 2); + } + if (elements - bar - 1 > 1) { + let lessVal = 0; + for (let mxwElement = n - elmWidth - (elements - bar - 2); mxwElement > maxWidth; mxwElement--) { + lessVal += RSSUtils.combins(n - elmWidth - mxwElement - 1, elements - bar - 3); + } + subVal -= lessVal * (elements - 1 - bar); + } + else if (n - elmWidth > maxWidth) { + subVal--; + } + val += subVal; + } + n -= elmWidth; + } + return val; + } + static combins(n, r) { + let maxDenom; + let minDenom; + if (n - r > r) { + minDenom = r; + maxDenom = n - r; + } + else { + minDenom = n - r; + maxDenom = r; + } + let val = 1; + let j = 1; + for (let i = n; i > maxDenom; i--) { + val *= i; + if (j <= minDenom) { + val /= j; + j++; + } + } + while ((j <= minDenom)) { + val /= j; + j++; + } + return val; + } + } + + class BitArrayBuilder { + static buildBitArray(pairs) { + let charNumber = (pairs.length * 2) - 1; + if (pairs[pairs.length - 1].getRightChar() == null) { + charNumber -= 1; + } + let size = 12 * charNumber; + let binary = new BitArray(size); + let accPos = 0; + let firstPair = pairs[0]; + let firstValue = firstPair.getRightChar().getValue(); + for (let i = 11; i >= 0; --i) { + if ((firstValue & (1 << i)) != 0) { + binary.set(accPos); + } + accPos++; + } + for (let i = 1; i < pairs.length; ++i) { + let currentPair = pairs[i]; + let leftValue = currentPair.getLeftChar().getValue(); + for (let j = 11; j >= 0; --j) { + if ((leftValue & (1 << j)) != 0) { + binary.set(accPos); + } + accPos++; + } + if (currentPair.getRightChar() != null) { + let rightValue = currentPair.getRightChar().getValue(); + for (let j = 11; j >= 0; --j) { + if ((rightValue & (1 << j)) != 0) { + binary.set(accPos); + } + accPos++; + } + } + } + return binary; + } + } + + class BlockParsedResult { + constructor(finished, decodedInformation) { + if (decodedInformation) { + this.decodedInformation = null; + } + else { + this.finished = finished; + this.decodedInformation = decodedInformation; + } + } + getDecodedInformation() { + return this.decodedInformation; + } + isFinished() { + return this.finished; + } + } + + class DecodedObject { + constructor(newPosition) { + this.newPosition = newPosition; + } + getNewPosition() { + return this.newPosition; + } + } + + class DecodedChar extends DecodedObject { + constructor(newPosition, value) { + super(newPosition); + this.value = value; + } + getValue() { + return this.value; + } + isFNC1() { + return this.value === DecodedChar.FNC1; + } + } + DecodedChar.FNC1 = '$'; + + class DecodedInformation extends DecodedObject { + constructor(newPosition, newString, remainingValue) { + super(newPosition); + if (remainingValue) { + this.remaining = true; + this.remainingValue = this.remainingValue; + } + else { + this.remaining = false; + this.remainingValue = 0; + } + this.newString = newString; + } + getNewString() { + return this.newString; + } + isRemaining() { + return this.remaining; + } + getRemainingValue() { + return this.remainingValue; + } + } + + class DecodedNumeric extends DecodedObject { + constructor(newPosition, firstDigit, secondDigit) { + super(newPosition); + if (firstDigit < 0 || firstDigit > 10 || secondDigit < 0 || secondDigit > 10) { + throw new FormatException(); + } + this.firstDigit = firstDigit; + this.secondDigit = secondDigit; + } + getFirstDigit() { + return this.firstDigit; + } + getSecondDigit() { + return this.secondDigit; + } + getValue() { + return this.firstDigit * 10 + this.secondDigit; + } + isFirstDigitFNC1() { + return this.firstDigit === DecodedNumeric.FNC1; + } + isSecondDigitFNC1() { + return this.secondDigit === DecodedNumeric.FNC1; + } + isAnyFNC1() { + return this.firstDigit === DecodedNumeric.FNC1 || this.secondDigit === DecodedNumeric.FNC1; + } + } + DecodedNumeric.FNC1 = 10; + + class FieldParser { + constructor() { + } + static parseFieldsInGeneralPurpose(rawInformation) { + if (!rawInformation) { + return null; + } + // Processing 2-digit AIs + if (rawInformation.length < 2) { + throw new NotFoundException(); + } + let firstTwoDigits = rawInformation.substring(0, 2); + for (let dataLength of FieldParser.TWO_DIGIT_DATA_LENGTH) { + if (dataLength[0] === firstTwoDigits) { + if (dataLength[1] === FieldParser.VARIABLE_LENGTH) { + return FieldParser.processVariableAI(2, dataLength[2], rawInformation); + } + return FieldParser.processFixedAI(2, dataLength[1], rawInformation); + } + } + if (rawInformation.length < 3) { + throw new NotFoundException(); + } + let firstThreeDigits = rawInformation.substring(0, 3); + for (let dataLength of FieldParser.THREE_DIGIT_DATA_LENGTH) { + if (dataLength[0] === firstThreeDigits) { + if (dataLength[1] === FieldParser.VARIABLE_LENGTH) { + return FieldParser.processVariableAI(3, dataLength[2], rawInformation); + } + return FieldParser.processFixedAI(3, dataLength[1], rawInformation); + } + } + for (let dataLength of FieldParser.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH) { + if (dataLength[0] === firstThreeDigits) { + if (dataLength[1] === FieldParser.VARIABLE_LENGTH) { + return FieldParser.processVariableAI(4, dataLength[2], rawInformation); + } + return FieldParser.processFixedAI(4, dataLength[1], rawInformation); + } + } + if (rawInformation.length < 4) { + throw new NotFoundException(); + } + let firstFourDigits = rawInformation.substring(0, 4); + for (let dataLength of FieldParser.FOUR_DIGIT_DATA_LENGTH) { + if (dataLength[0] === firstFourDigits) { + if (dataLength[1] === FieldParser.VARIABLE_LENGTH) { + return FieldParser.processVariableAI(4, dataLength[2], rawInformation); + } + return FieldParser.processFixedAI(4, dataLength[1], rawInformation); + } + } + throw new NotFoundException(); + } + static processFixedAI(aiSize, fieldSize, rawInformation) { + if (rawInformation.length < aiSize) { + throw new NotFoundException(); + } + let ai = rawInformation.substring(0, aiSize); + if (rawInformation.length < aiSize + fieldSize) { + throw new NotFoundException(); + } + let field = rawInformation.substring(aiSize, aiSize + fieldSize); + let remaining = rawInformation.substring(aiSize + fieldSize); + let result = '(' + ai + ')' + field; + let parsedAI = FieldParser.parseFieldsInGeneralPurpose(remaining); + return parsedAI == null ? result : result + parsedAI; + } + static processVariableAI(aiSize, variableFieldSize, rawInformation) { + let ai = rawInformation.substring(0, aiSize); + let maxSize; + if (rawInformation.length < aiSize + variableFieldSize) { + maxSize = rawInformation.length; + } + else { + maxSize = aiSize + variableFieldSize; + } + let field = rawInformation.substring(aiSize, maxSize); + let remaining = rawInformation.substring(maxSize); + let result = '(' + ai + ')' + field; + let parsedAI = FieldParser.parseFieldsInGeneralPurpose(remaining); + return parsedAI == null ? result : result + parsedAI; + } + } + FieldParser.VARIABLE_LENGTH = []; + FieldParser.TWO_DIGIT_DATA_LENGTH = [ + ['00', 18], + ['01', 14], + ['02', 14], + ['10', FieldParser.VARIABLE_LENGTH, 20], + ['11', 6], + ['12', 6], + ['13', 6], + ['15', 6], + ['17', 6], + ['20', 2], + ['21', FieldParser.VARIABLE_LENGTH, 20], + ['22', FieldParser.VARIABLE_LENGTH, 29], + ['30', FieldParser.VARIABLE_LENGTH, 8], + ['37', FieldParser.VARIABLE_LENGTH, 8], + // internal company codes + ['90', FieldParser.VARIABLE_LENGTH, 30], + ['91', FieldParser.VARIABLE_LENGTH, 30], + ['92', FieldParser.VARIABLE_LENGTH, 30], + ['93', FieldParser.VARIABLE_LENGTH, 30], + ['94', FieldParser.VARIABLE_LENGTH, 30], + ['95', FieldParser.VARIABLE_LENGTH, 30], + ['96', FieldParser.VARIABLE_LENGTH, 30], + ['97', FieldParser.VARIABLE_LENGTH, 3], + ['98', FieldParser.VARIABLE_LENGTH, 30], + ['99', FieldParser.VARIABLE_LENGTH, 30], + ]; + FieldParser.THREE_DIGIT_DATA_LENGTH = [ + // Same format as above + ['240', FieldParser.VARIABLE_LENGTH, 30], + ['241', FieldParser.VARIABLE_LENGTH, 30], + ['242', FieldParser.VARIABLE_LENGTH, 6], + ['250', FieldParser.VARIABLE_LENGTH, 30], + ['251', FieldParser.VARIABLE_LENGTH, 30], + ['253', FieldParser.VARIABLE_LENGTH, 17], + ['254', FieldParser.VARIABLE_LENGTH, 20], + ['400', FieldParser.VARIABLE_LENGTH, 30], + ['401', FieldParser.VARIABLE_LENGTH, 30], + ['402', 17], + ['403', FieldParser.VARIABLE_LENGTH, 30], + ['410', 13], + ['411', 13], + ['412', 13], + ['413', 13], + ['414', 13], + ['420', FieldParser.VARIABLE_LENGTH, 20], + ['421', FieldParser.VARIABLE_LENGTH, 15], + ['422', 3], + ['423', FieldParser.VARIABLE_LENGTH, 15], + ['424', 3], + ['425', 3], + ['426', 3], + ]; + FieldParser.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH = [ + // Same format as above + ['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', FieldParser.VARIABLE_LENGTH, 15], + ['391', FieldParser.VARIABLE_LENGTH, 18], + ['392', FieldParser.VARIABLE_LENGTH, 15], + ['393', FieldParser.VARIABLE_LENGTH, 18], + ['703', FieldParser.VARIABLE_LENGTH, 30], + ]; + FieldParser.FOUR_DIGIT_DATA_LENGTH = [ + // Same format as above + ['7001', 13], + ['7002', FieldParser.VARIABLE_LENGTH, 30], + ['7003', 10], + ['8001', 14], + ['8002', FieldParser.VARIABLE_LENGTH, 20], + ['8003', FieldParser.VARIABLE_LENGTH, 30], + ['8004', FieldParser.VARIABLE_LENGTH, 30], + ['8005', 6], + ['8006', 18], + ['8007', FieldParser.VARIABLE_LENGTH, 30], + ['8008', FieldParser.VARIABLE_LENGTH, 12], + ['8018', 18], + ['8020', FieldParser.VARIABLE_LENGTH, 25], + ['8100', 6], + ['8101', 10], + ['8102', 2], + ['8110', FieldParser.VARIABLE_LENGTH, 70], + ['8200', FieldParser.VARIABLE_LENGTH, 70], + ]; + + class GeneralAppIdDecoder { + constructor(information) { + this.buffer = new StringBuilder(); + this.information = information; + } + decodeAllCodes(buff, initialPosition) { + let currentPosition = initialPosition; + let remaining = null; + do { + let info = this.decodeGeneralPurposeField(currentPosition, remaining); + let parsedFields = FieldParser.parseFieldsInGeneralPurpose(info.getNewString()); + if (parsedFields != null) { + buff.append(parsedFields); + } + if (info.isRemaining()) { + remaining = '' + info.getRemainingValue(); + } + else { + remaining = null; + } + if (currentPosition === info.getNewPosition()) { // No step forward! + break; + } + currentPosition = info.getNewPosition(); + } while (true); + return buff.toString(); + } + isStillNumeric(pos) { + // It's numeric if it still has 7 positions + // and one of the first 4 bits is "1". + if (pos + 7 > this.information.getSize()) { + return pos + 4 <= this.information.getSize(); + } + for (let i = pos; i < pos + 3; ++i) { + if (this.information.get(i)) { + return true; + } + } + return this.information.get(pos + 3); + } + decodeNumeric(pos) { + if (pos + 7 > this.information.getSize()) { + let numeric = this.extractNumericValueFromBitArray(pos, 4); + if (numeric === 0) { + return new DecodedNumeric(this.information.getSize(), DecodedNumeric.FNC1, DecodedNumeric.FNC1); + } + return new DecodedNumeric(this.information.getSize(), numeric - 1, DecodedNumeric.FNC1); + } + let numeric = this.extractNumericValueFromBitArray(pos, 7); + let digit1 = (numeric - 8) / 11; + let digit2 = (numeric - 8) % 11; + return new DecodedNumeric(pos + 7, digit1, digit2); + } + extractNumericValueFromBitArray(pos, bits) { + return GeneralAppIdDecoder.extractNumericValueFromBitArray(this.information, pos, bits); + } + static extractNumericValueFromBitArray(information, pos, bits) { + let value = 0; + for (let i = 0; i < bits; ++i) { + if (information.get(pos + i)) { + value |= 1 << (bits - i - 1); + } + } + return value; + } + decodeGeneralPurposeField(pos, remaining) { + // this.buffer.setLength(0); + this.buffer.setLengthToZero(); + if (remaining != null) { + this.buffer.append(remaining); + } + this.current.setPosition(pos); + let lastDecoded = this.parseBlocks(); + if (lastDecoded != null && lastDecoded.isRemaining()) { + return new DecodedInformation(this.current.getPosition(), this.buffer.toString(), lastDecoded.getRemainingValue()); + } + return new DecodedInformation(this.current.getPosition(), this.buffer.toString()); + } + parseBlocks() { + let isFinished; + let result; + do { + let initialPosition = this.current.getPosition(); + if (this.current.isAlpha()) { + result = this.parseAlphaBlock(); + isFinished = result.isFinished(); + } + else if (this.current.isIsoIec646()) { + result = this.parseIsoIec646Block(); + isFinished = result.isFinished(); + } + else { // it must be numeric + result = this.parseNumericBlock(); + isFinished = result.isFinished(); + } + let positionChanged = initialPosition !== this.current.getPosition(); + if (!positionChanged && !isFinished) { + break; + } + } while (!isFinished); + return result.getDecodedInformation(); + } + parseNumericBlock() { + while (this.isStillNumeric(this.current.getPosition())) { + let numeric = this.decodeNumeric(this.current.getPosition()); + this.current.setPosition(numeric.getNewPosition()); + if (numeric.isFirstDigitFNC1()) { + let information; + if (numeric.isSecondDigitFNC1()) { + information = new DecodedInformation(this.current.getPosition(), this.buffer.toString()); + } + else { + information = new DecodedInformation(this.current.getPosition(), this.buffer.toString(), numeric.getSecondDigit()); + } + return new BlockParsedResult(true, information); + } + this.buffer.append(numeric.getFirstDigit()); + if (numeric.isSecondDigitFNC1()) { + let information = new DecodedInformation(this.current.getPosition(), this.buffer.toString()); + return new BlockParsedResult(true, information); + } + this.buffer.append(numeric.getSecondDigit()); + } + if (this.isNumericToAlphaNumericLatch(this.current.getPosition())) { + this.current.setAlpha(); + this.current.incrementPosition(4); + } + return new BlockParsedResult(false); + } + parseIsoIec646Block() { + while (this.isStillIsoIec646(this.current.getPosition())) { + let iso = this.decodeIsoIec646(this.current.getPosition()); + this.current.setPosition(iso.getNewPosition()); + if (iso.isFNC1()) { + let information = new DecodedInformation(this.current.getPosition(), this.buffer.toString()); + return new BlockParsedResult(true, information); + } + this.buffer.append(iso.getValue()); + } + if (this.isAlphaOr646ToNumericLatch(this.current.getPosition())) { + this.current.incrementPosition(3); + this.current.setNumeric(); + } + else if (this.isAlphaTo646ToAlphaLatch(this.current.getPosition())) { + if (this.current.getPosition() + 5 < this.information.getSize()) { + this.current.incrementPosition(5); + } + else { + this.current.setPosition(this.information.getSize()); + } + this.current.setAlpha(); + } + return new BlockParsedResult(false); + } + parseAlphaBlock() { + while (this.isStillAlpha(this.current.getPosition())) { + let alpha = this.decodeAlphanumeric(this.current.getPosition()); + this.current.setPosition(alpha.getNewPosition()); + if (alpha.isFNC1()) { + let information = new DecodedInformation(this.current.getPosition(), this.buffer.toString()); + return new BlockParsedResult(true, information); // end of the char block + } + this.buffer.append(alpha.getValue()); + } + if (this.isAlphaOr646ToNumericLatch(this.current.getPosition())) { + this.current.incrementPosition(3); + this.current.setNumeric(); + } + else if (this.isAlphaTo646ToAlphaLatch(this.current.getPosition())) { + if (this.current.getPosition() + 5 < this.information.getSize()) { + this.current.incrementPosition(5); + } + else { + this.current.setPosition(this.information.getSize()); + } + this.current.setIsoIec646(); + } + return new BlockParsedResult(false); + } + isStillIsoIec646(pos) { + if (pos + 5 > this.information.getSize()) { + return false; + } + let fiveBitValue = this.extractNumericValueFromBitArray(pos, 5); + if (fiveBitValue >= 5 && fiveBitValue < 16) { + return true; + } + if (pos + 7 > this.information.getSize()) { + return false; + } + let sevenBitValue = this.extractNumericValueFromBitArray(pos, 7); + if (sevenBitValue >= 64 && sevenBitValue < 116) { + return true; + } + if (pos + 8 > this.information.getSize()) { + return false; + } + let eightBitValue = this.extractNumericValueFromBitArray(pos, 8); + return eightBitValue >= 232 && eightBitValue < 253; + } + decodeIsoIec646(pos) { + let fiveBitValue = this.extractNumericValueFromBitArray(pos, 5); + if (fiveBitValue === 15) { + return new DecodedChar(pos + 5, DecodedChar.FNC1); + } + if (fiveBitValue >= 5 && fiveBitValue < 15) { + return new DecodedChar(pos + 5, ('0' + (fiveBitValue - 5))); + } + let sevenBitValue = this.extractNumericValueFromBitArray(pos, 7); + if (sevenBitValue >= 64 && sevenBitValue < 90) { + return new DecodedChar(pos + 7, ('' + (sevenBitValue + 1))); + } + if (sevenBitValue >= 90 && sevenBitValue < 116) { + return new DecodedChar(pos + 7, ('' + (sevenBitValue + 7))); + } + let eightBitValue = this.extractNumericValueFromBitArray(pos, 8); + let c; + switch (eightBitValue) { + case 232: + c = '!'; + break; + case 233: + c = '"'; + break; + case 234: + c = '%'; + break; + case 235: + c = '&'; + break; + case 236: + c = '\''; + break; + case 237: + c = '('; + break; + case 238: + c = ')'; + break; + case 239: + c = '*'; + break; + case 240: + c = '+'; + break; + case 241: + c = ','; + break; + case 242: + c = '-'; + break; + case 243: + c = '.'; + break; + case 244: + c = '/'; + break; + case 245: + c = ':'; + break; + case 246: + c = ';'; + break; + case 247: + c = '<'; + break; + case 248: + c = '='; + break; + case 249: + c = '>'; + break; + case 250: + c = '?'; + break; + case 251: + c = '_'; + break; + case 252: + c = ' '; + break; + default: + throw new FormatException(); + } + return new DecodedChar(pos + 8, c); + } + isStillAlpha(pos) { + if (pos + 5 > this.information.getSize()) { + return false; + } + // We now check if it's a valid 5-bit value (0..9 and FNC1) + let fiveBitValue = this.extractNumericValueFromBitArray(pos, 5); + if (fiveBitValue >= 5 && fiveBitValue < 16) { + return true; + } + if (pos + 6 > this.information.getSize()) { + return false; + } + let sixBitValue = this.extractNumericValueFromBitArray(pos, 6); + return sixBitValue >= 16 && sixBitValue < 63; // 63 not included + } + decodeAlphanumeric(pos) { + let fiveBitValue = this.extractNumericValueFromBitArray(pos, 5); + if (fiveBitValue === 15) { + return new DecodedChar(pos + 5, DecodedChar.FNC1); + } + if (fiveBitValue >= 5 && fiveBitValue < 15) { + return new DecodedChar(pos + 5, ('0' + (fiveBitValue - 5))); + } + let sixBitValue = this.extractNumericValueFromBitArray(pos, 6); + if (sixBitValue >= 32 && sixBitValue < 58) { + return new DecodedChar(pos + 6, ('' + (sixBitValue + 33))); + } + let c; + switch (sixBitValue) { + case 58: + c = '*'; + break; + case 59: + c = ','; + break; + case 60: + c = '-'; + break; + case 61: + c = '.'; + break; + case 62: + c = '/'; + break; + default: + throw new IllegalStateException('Decoding invalid alphanumeric value: ' + sixBitValue); + } + return new DecodedChar(pos + 6, c); + } + isAlphaTo646ToAlphaLatch(pos) { + if (pos + 1 > this.information.getSize()) { + return false; + } + for (let i = 0; i < 5 && i + pos < this.information.getSize(); ++i) { + if (i === 2) { + if (!this.information.get(pos + 2)) { + return false; + } + } + else if (this.information.get(pos + i)) { + return false; + } + } + return true; + } + isAlphaOr646ToNumericLatch(pos) { + // Next is alphanumeric if there are 3 positions and they are all zeros + if (pos + 3 > this.information.getSize()) { + return false; + } + for (let i = pos; i < pos + 3; ++i) { + if (this.information.get(i)) { + return false; + } + } + return true; + } + isNumericToAlphaNumericLatch(pos) { + // Next is alphanumeric if there are 4 positions and they are all zeros, or + // if there is a subset of this just before the end of the symbol + if (pos + 1 > this.information.getSize()) { + return false; + } + for (let i = 0; i < 4 && i + pos < this.information.getSize(); ++i) { + if (this.information.get(pos + i)) { + return false; + } + } + return true; + } + } + + class AbstractExpandedDecoder { + constructor(information) { + this.information = information; + this.generalDecoder = new GeneralAppIdDecoder(information); + } + getInformation() { + return this.information; + } + getGeneralDecoder() { + return this.generalDecoder; + } + } + + class AI01decoder extends AbstractExpandedDecoder { + constructor(information) { + super(information); + } + encodeCompressedGtin(buf, currentPos) { + buf.append('(01)'); + let initialPosition = buf.length(); + buf.append('9'); + this.encodeCompressedGtinWithoutAI(buf, currentPos, initialPosition); + } + encodeCompressedGtinWithoutAI(buf, currentPos, initialBufferPosition) { + for (let i = 0; i < 4; ++i) { + let currentBlock = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos + 10 * i, 10); + if (currentBlock / 100 === 0) { + buf.append('0'); + } + if (currentBlock / 10 === 0) { + buf.append('0'); + } + buf.append(currentBlock); + } + AI01decoder.appendCheckDigit(buf, initialBufferPosition); + } + static appendCheckDigit(buf, currentPos) { + let checkDigit = 0; + for (let i = 0; i < 13; i++) { + // let digit = buf.charAt(i + currentPos) - '0'; + // To be checked + let digit = buf.charAt(i + currentPos).charCodeAt(0) - '0'.charCodeAt(0); + checkDigit += (i & 0x01) === 0 ? 3 * digit : digit; + } + checkDigit = 10 - (checkDigit % 10); + if (checkDigit === 10) { + checkDigit = 0; + } + buf.append(checkDigit); + } + } + AI01decoder.GTIN_SIZE = 40; + + class AI01AndOtherAIs extends AI01decoder { + // the second one is the encodation method, and the other two are for the variable length + constructor(information) { + super(information); + } + parseInformation() { + let buff = new StringBuilder(); + buff.append('(01)'); + let initialGtinPosition = buff.length(); + let firstGtinDigit = this.getGeneralDecoder().extractNumericValueFromBitArray(AI01AndOtherAIs.HEADER_SIZE, 4); + buff.append(firstGtinDigit); + this.encodeCompressedGtinWithoutAI(buff, AI01AndOtherAIs.HEADER_SIZE + 4, initialGtinPosition); + return this.getGeneralDecoder().decodeAllCodes(buff, AI01AndOtherAIs.HEADER_SIZE + 44); + } + } + AI01AndOtherAIs.HEADER_SIZE = 1 + 1 + 2; // first bit encodes the linkage flag, + + class AnyAIDecoder extends AbstractExpandedDecoder { + constructor(information) { + super(information); + } + parseInformation() { + let buf = new StringBuilder(); + return this.getGeneralDecoder().decodeAllCodes(buf, AnyAIDecoder.HEADER_SIZE); + } + } + AnyAIDecoder.HEADER_SIZE = 2 + 1 + 2; + + class AI01weightDecoder extends AI01decoder { + constructor(information) { + super(information); + } + encodeCompressedWeight(buf, currentPos, weightSize) { + let originalWeightNumeric = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, weightSize); + this.addWeightCode(buf, originalWeightNumeric); + let weightNumeric = this.checkWeight(originalWeightNumeric); + let currentDivisor = 100000; + for (let i = 0; i < 5; ++i) { + if (weightNumeric / currentDivisor === 0) { + buf.append('0'); + } + currentDivisor /= 10; + } + buf.append(weightNumeric); + } + } + + class AI013x0xDecoder extends AI01weightDecoder { + constructor(information) { + super(information); + } + parseInformation() { + if (this.getInformation().getSize() != AI013x0xDecoder.HEADER_SIZE + AI01weightDecoder.GTIN_SIZE + AI013x0xDecoder.WEIGHT_SIZE) { + throw new NotFoundException(); + } + let buf = new StringBuilder(); + this.encodeCompressedGtin(buf, AI013x0xDecoder.HEADER_SIZE); + this.encodeCompressedWeight(buf, AI013x0xDecoder.HEADER_SIZE + AI01weightDecoder.GTIN_SIZE, AI013x0xDecoder.WEIGHT_SIZE); + return buf.toString(); + } + } + AI013x0xDecoder.HEADER_SIZE = 4 + 1; + AI013x0xDecoder.WEIGHT_SIZE = 15; + + class AI013103decoder extends AI013x0xDecoder { + constructor(information) { + super(information); + } + addWeightCode(buf, weight) { + buf.append('(3103)'); + } + checkWeight(weight) { + return weight; + } + } + + class AI01320xDecoder extends AI013x0xDecoder { + constructor(information) { + super(information); + } + addWeightCode(buf, weight) { + if (weight < 10000) { + buf.append('(3202)'); + } + else { + buf.append('(3203)'); + } + } + checkWeight(weight) { + if (weight < 10000) { + return weight; + } + return weight - 10000; + } + } + + class AI01392xDecoder extends AI01decoder { + constructor(information) { + super(information); + } + parseInformation() { + if (this.getInformation().getSize() < AI01392xDecoder.HEADER_SIZE + AI01decoder.GTIN_SIZE) { + throw new NotFoundException(); + } + let buf = new StringBuilder(); + this.encodeCompressedGtin(buf, AI01392xDecoder.HEADER_SIZE); + let lastAIdigit = this.getGeneralDecoder().extractNumericValueFromBitArray(AI01392xDecoder.HEADER_SIZE + AI01decoder.GTIN_SIZE, AI01392xDecoder.LAST_DIGIT_SIZE); + buf.append('(392'); + buf.append(lastAIdigit); + buf.append(')'); + let decodedInformation = this.getGeneralDecoder().decodeGeneralPurposeField(AI01392xDecoder.HEADER_SIZE + AI01decoder.GTIN_SIZE + AI01392xDecoder.LAST_DIGIT_SIZE, null); + buf.append(decodedInformation.getNewString()); + return buf.toString(); + } + } + AI01392xDecoder.HEADER_SIZE = 5 + 1 + 2; + AI01392xDecoder.LAST_DIGIT_SIZE = 2; + + class AI01393xDecoder extends AI01decoder { + constructor(information) { + super(information); + } + parseInformation() { + if (this.getInformation().getSize() < AI01393xDecoder.HEADER_SIZE + AI01decoder.GTIN_SIZE) { + throw new NotFoundException(); + } + let buf = new StringBuilder(); + this.encodeCompressedGtin(buf, AI01393xDecoder.HEADER_SIZE); + let lastAIdigit = this.getGeneralDecoder().extractNumericValueFromBitArray(AI01393xDecoder.HEADER_SIZE + AI01decoder.GTIN_SIZE, AI01393xDecoder.LAST_DIGIT_SIZE); + buf.append('(393'); + buf.append(lastAIdigit); + buf.append(')'); + let firstThreeDigits = this.getGeneralDecoder().extractNumericValueFromBitArray(AI01393xDecoder.HEADER_SIZE + AI01decoder.GTIN_SIZE + AI01393xDecoder.LAST_DIGIT_SIZE, AI01393xDecoder.FIRST_THREE_DIGITS_SIZE); + if (firstThreeDigits / 100 == 0) { + buf.append('0'); + } + if (firstThreeDigits / 10 == 0) { + buf.append('0'); + } + buf.append(firstThreeDigits); + let generalInformation = this.getGeneralDecoder().decodeGeneralPurposeField(AI01393xDecoder.HEADER_SIZE + AI01decoder.GTIN_SIZE + AI01393xDecoder.LAST_DIGIT_SIZE + AI01393xDecoder.FIRST_THREE_DIGITS_SIZE, null); + buf.append(generalInformation.getNewString()); + return buf.toString(); + } + } + AI01393xDecoder.HEADER_SIZE = 5 + 1 + 2; + AI01393xDecoder.LAST_DIGIT_SIZE = 2; + AI01393xDecoder.FIRST_THREE_DIGITS_SIZE = 10; + + class AI013x0x1xDecoder extends AI01weightDecoder { + constructor(information, firstAIdigits, dateCode) { + super(information); + this.dateCode = dateCode; + this.firstAIdigits = firstAIdigits; + } + parseInformation() { + if (this.getInformation().getSize() != AI013x0x1xDecoder.HEADER_SIZE + AI013x0x1xDecoder.GTIN_SIZE + AI013x0x1xDecoder.WEIGHT_SIZE + AI013x0x1xDecoder.DATE_SIZE) { + throw new NotFoundException(); + } + let buf = new StringBuilder(); + this.encodeCompressedGtin(buf, AI013x0x1xDecoder.HEADER_SIZE); + this.encodeCompressedWeight(buf, AI013x0x1xDecoder.HEADER_SIZE + AI013x0x1xDecoder.GTIN_SIZE, AI013x0x1xDecoder.WEIGHT_SIZE); + this.encodeCompressedDate(buf, AI013x0x1xDecoder.HEADER_SIZE + AI013x0x1xDecoder.GTIN_SIZE + AI013x0x1xDecoder.WEIGHT_SIZE); + return buf.toString(); + } + encodeCompressedDate(buf, currentPos) { + let numericDate = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, AI013x0x1xDecoder.DATE_SIZE); + if (numericDate == 38400) { + return; + } + buf.append('('); + buf.append(this.dateCode); + buf.append(')'); + let day = numericDate % 32; + numericDate /= 32; + let month = numericDate % 12 + 1; + numericDate /= 12; + let year = numericDate; + if (year / 10 == 0) { + buf.append('0'); + } + buf.append(year); + if (month / 10 == 0) { + buf.append('0'); + } + buf.append(month); + if (day / 10 == 0) { + buf.append('0'); + } + buf.append(day); + } + addWeightCode(buf, weight) { + buf.append('('); + buf.append(this.firstAIdigits); + buf.append(weight / 100000); + buf.append(')'); + } + checkWeight(weight) { + return weight % 100000; + } + } + AI013x0x1xDecoder.HEADER_SIZE = 7 + 1; + AI013x0x1xDecoder.WEIGHT_SIZE = 20; + AI013x0x1xDecoder.DATE_SIZE = 16; + + function createDecoder(information) { + try { + if (information.get(1)) { + return new AI01AndOtherAIs(information); + } + if (!information.get(2)) { + return new AnyAIDecoder(information); + } + let fourBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 4); + switch (fourBitEncodationMethod) { + case 4: return new AI013103decoder(information); + case 5: return new AI01320xDecoder(information); + } + let fiveBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 5); + switch (fiveBitEncodationMethod) { + case 12: return new AI01392xDecoder(information); + case 13: return new AI01393xDecoder(information); + } + let sevenBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 7); + switch (sevenBitEncodationMethod) { + case 56: return new AI013x0x1xDecoder(information, '310', '11'); + case 57: return new AI013x0x1xDecoder(information, '320', '11'); + case 58: return new AI013x0x1xDecoder(information, '310', '13'); + case 59: return new AI013x0x1xDecoder(information, '320', '13'); + case 60: return new AI013x0x1xDecoder(information, '310', '15'); + case 61: return new AI013x0x1xDecoder(information, '320', '15'); + case 62: return new AI013x0x1xDecoder(information, '310', '17'); + case 63: return new AI013x0x1xDecoder(information, '320', '17'); + } + } + catch (e) { + console.log(e); + throw new IllegalStateException('unknown decoder: ' + information); + } + } + + class ExpandedPair { + constructor(leftChar, rightChar, finderPatter, mayBeLast) { + this.leftchar = leftChar; + this.rightchar = rightChar; + this.finderpattern = finderPatter; + this.maybeLast = mayBeLast; + } + 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(o1, o2) { + if (!(o1 instanceof ExpandedPair)) { + return false; + } + return ExpandedPair.equalsOrNull(o1.leftchar, o2.leftchar) && + ExpandedPair.equalsOrNull(o1.rightchar, o2.rightchar) && + ExpandedPair.equalsOrNull(o1.finderpattern, o2.finderpattern); + } + static equalsOrNull(o1, o2) { + return o1 === null ? o2 === null : ExpandedPair.equals(o1, o2); + } + hashCode() { + // return ExpandedPair.hashNotNull(leftChar) ^ hashNotNull(rightChar) ^ hashNotNull(finderPattern); + let value = this.leftchar.getValue() ^ this.rightchar.getValue() ^ this.finderpattern.getValue(); + return value; + } + } + + class ExpandedRow { + constructor(pairs, rowNumber, wasReversed) { + this.pairs = pairs; + this.rowNumber = rowNumber; + this.wasReversed = wasReversed; + } + getPairs() { + return this.pairs; + } + getRowNumber() { + return this.rowNumber; + } + isReversed() { + return this.wasReversed; + } + // check implementation + isEquivalent(otherPairs) { + return this.checkEqualitity(this, otherPairs); + } + // @Override + toString() { + return '{ ' + this.pairs + ' }'; + } + /** + * Two rows are equal if they contain the same pairs in the same order. + */ + // @Override + // check implementation + equals(o1, o2) { + if (!(o1 instanceof ExpandedRow)) { + return false; + } + return this.checkEqualitity(o1, o2) && o1.wasReversed === o2.wasReversed; + } + checkEqualitity(pair1, pair2) { + if (!pair1 || !pair2) + return; + let result; + pair1.forEach((e1, i) => { + pair2.forEach(e2 => { + if (e1.getLeftChar().getValue() === e2.getLeftChar().getValue() && e1.getRightChar().getValue() === e2.getRightChar().getValue() && e1.getFinderPatter().getValue() === e2.getFinderPatter().getValue()) { + result = true; + } + }); + }); + return result; + } + } + + // import java.util.ArrayList; + // import java.util.Iterator; + // import java.util.List; + // import java.util.Map; + // import java.util.Collections; + class RSSExpandedReader extends AbstractRSSReader { + constructor(verbose) { + super(...arguments); + this.pairs = new Array(RSSExpandedReader.MAX_PAIRS); + this.rows = new Array(); + this.startEnd = [2]; + this.verbose = (verbose === true); + } + decodeRow(rowNumber, row, hints) { + // Rows can start with even pattern in case in prev rows there where odd number of patters. + // So lets try twice + // this.pairs.clear(); + this.pairs.length = 0; + this.startFromEven = false; + try { + return RSSExpandedReader.constructResult(this.decodeRow2pairs(rowNumber, row)); + } + catch (e) { + // OK + if (this.verbose) { + console.log(e); + } + } + this.pairs.length = 0; + this.startFromEven = true; + return RSSExpandedReader.constructResult(this.decodeRow2pairs(rowNumber, row)); + } + reset() { + this.pairs.length = 0; + this.rows.length = 0; + } + // Not private for testing + decodeRow2pairs(rowNumber, row) { + let done = false; + while (!done) { + try { + this.pairs.push(this.retrieveNextPair(row, this.pairs, rowNumber)); + } + catch (error) { + if (error instanceof NotFoundException) { + if (!this.pairs.length) { + throw new NotFoundException(); + } + // exit this loop when retrieveNextPair() fails and throws + done = true; + } + } + } + // TODO: verify sequence of finder patterns as in checkPairSequence() + if (this.checkChecksum()) { + return this.pairs; + } + let tryStackedDecode; + if (this.rows.length) { + tryStackedDecode = true; + } + else { + tryStackedDecode = false; + } + // let tryStackedDecode = !this.rows.isEmpty(); + this.storeRow(rowNumber, false); // TODO: deal with reversed rows + if (tryStackedDecode) { + // When the image is 180-rotated, then rows are sorted in wrong direction. + // Try twice with both the directions. + let ps = this.checkRowsBoolean(false); + if (ps != null) { + return ps; + } + ps = this.checkRowsBoolean(true); + if (ps != null) { + return ps; + } + } + throw new NotFoundException(); + } + // Need to Verify + checkRowsBoolean(reverse) { + // Limit number of rows we are checking + // We use recursive algorithm with pure complexity and don't want it to take forever + // Stacked barcode can have up to 11 rows, so 25 seems reasonable enough + if (this.rows.length > 25) { + this.rows.length = 0; // We will never have a chance to get result, so clear it + return null; + } + this.pairs.length = 0; + if (reverse) { + this.rows = this.rows.reverse(); + // Collections.reverse(this.rows); + } + let ps = null; + try { + ps = this.checkRows(new Array(), 0); + } + catch (e) { + // OK + if (this.verbose) { + console.log(e); + } + } + if (reverse) { + this.rows = this.rows.reverse(); + // Collections.reverse(this.rows); + } + return ps; + } + // Try to construct a valid rows sequence + // Recursion is used to implement backtracking + checkRows(collectedRows, currentRow) { + for (let i = currentRow; i < this.rows.length; i++) { + let row = this.rows[i]; + this.pairs.length = 0; + for (let collectedRow of collectedRows) { + this.pairs.push(collectedRow.getPairs()); + } + this.pairs.push(row.getPairs()); + if (!RSSExpandedReader.isValidSequence(this.pairs)) { + continue; + } + if (this.checkChecksum()) { + return this.pairs; + } + let rs = new Array(collectedRows); + rs.push(row); + try { + // Recursion: try to add more rows + return this.checkRows(rs, i + 1); + } + catch (e) { + // We failed, try the next candidate + if (this.verbose) { + console.log(e); + } + } + } + throw new NotFoundException(); + } + // Whether the pairs form a valid find pattern sequence, + // either complete or a prefix + static isValidSequence(pairs) { + for (let sequence of RSSExpandedReader.FINDER_PATTERN_SEQUENCES) { + if (pairs.length > sequence.length) { + continue; + } + let stop = true; + for (let j = 0; j < pairs.length; j++) { + if (pairs[j].getFinderPattern().getValue() != sequence[j]) { + stop = false; + break; + } + } + if (stop) { + return true; + } + } + return false; + } + storeRow(rowNumber, wasReversed) { + // Discard if duplicate above or below; otherwise insert in order by row number. + let insertPos = 0; + let prevIsSame = false; + let nextIsSame = false; + while (insertPos < this.rows.length) { + let erow = this.rows[insertPos]; + if (erow.getRowNumber() > rowNumber) { + nextIsSame = erow.isEquivalent(this.pairs); + break; + } + prevIsSame = erow.isEquivalent(this.pairs); + insertPos++; + } + if (nextIsSame || prevIsSame) { + return; + } + // When the row was partially decoded (e.g. 2 pairs found instead of 3), + // it will prevent us from detecting the barcode. + // Try to merge partial rows + // Check whether the row is part of an allready detected row + if (RSSExpandedReader.isPartialRow(this.pairs, this.rows)) { + return; + } + this.rows.push(insertPos, new ExpandedRow(this.pairs, rowNumber, wasReversed)); + this.removePartialRows(this.pairs, this.rows); + } + // Remove all the rows that contains only specified pairs + removePartialRows(pairs, rows) { + // for (Iterator<ExpandedRow> iterator = rows.iterator(); iterator.hasNext();) { + // ExpandedRow r = iterator.next(); + // if (r.getPairs().size() == pairs.size()) { + // continue; + // } + // boolean allFound = true; + // for (ExpandedPair p : r.getPairs()) { + // boolean found = false; + // for (ExpandedPair pp : pairs) { + // if (p.equals(pp)) { + // found = true; + // break; + // } + // } + // if (!found) { + // allFound = false; + // break; + // } + // } + // if (allFound) { + // // 'pairs' contains all the pairs from the row 'r' + // iterator.remove(); + // } + // } + for (let row of rows) { + if (row.getPairs().length === pairs.length) { + continue; + } + for (let p of row.getPairs()) { + for (let pp of pairs) { + if (ExpandedPair.equals(p, pp)) { + break; + } + } + } + } + } + // Returns true when one of the rows already contains all the pairs + static isPartialRow(pairs, rows) { + for (let r of rows) { + let allFound = true; + for (let p of pairs) { + let found = false; + for (let pp of r.getPairs()) { + if (p.equals(pp)) { + found = true; + break; + } + } + if (!found) { + allFound = false; + break; + } + } + if (allFound) { + // the row 'r' contain all the pairs from 'pairs' + return true; + } + } + return false; + } + // Only used for unit testing + getRows() { + return this.rows; + } + // Not private for unit testing + static constructResult(pairs) { + let binary = BitArrayBuilder.buildBitArray(pairs); + let decoder = createDecoder(binary); + let resultingString = decoder.parseInformation(); + let firstPoints = pairs[0].getFinderPattern().getResultPoints(); + let lastPoints = pairs[pairs.length - 1].getFinderPattern().getResultPoints(); + let points = [firstPoints[0], firstPoints[1], lastPoints[0], lastPoints[1]]; + return new Result(resultingString, null, null, points, BarcodeFormat$1.RSS_EXPANDED, null); + } + checkChecksum() { + let firstPair = this.pairs.get(0); + let checkCharacter = firstPair.getLeftChar(); + let firstCharacter = firstPair.getRightChar(); + if (firstCharacter == null) { + return false; + } + let checksum = firstCharacter.getChecksumPortion(); + let s = 2; + for (let i = 1; i < this.pairs.size(); ++i) { + let currentPair = this.pairs.get(i); + checksum += currentPair.getLeftChar().getChecksumPortion(); + s++; + let currentRightChar = currentPair.getRightChar(); + if (currentRightChar != null) { + checksum += currentRightChar.getChecksumPortion(); + s++; + } + } + checksum %= 211; + let checkCharacterValue = 211 * (s - 4) + checksum; + return checkCharacterValue == checkCharacter.getValue(); + } + static getNextSecondBar(row, initialPos) { + let currentPos; + if (row.get(initialPos)) { + currentPos = row.getNextUnset(initialPos); + currentPos = row.getNextSet(currentPos); + } + else { + currentPos = row.getNextSet(initialPos); + currentPos = row.getNextUnset(currentPos); + } + return currentPos; + } + // not private for testing + retrieveNextPair(row, previousPairs, rowNumber) { + let isOddPattern = previousPairs.length % 2 == 0; + if (this.startFromEven) { + isOddPattern = !isOddPattern; + } + let pattern; + let keepFinding = true; + let forcedOffset = -1; + do { + this.findNextPair(row, previousPairs, forcedOffset); + pattern = this.parseFoundFinderPattern(row, rowNumber, isOddPattern); + if (pattern == null) { + forcedOffset = RSSExpandedReader.getNextSecondBar(row, this.startEnd[0]); + } + else { + keepFinding = false; + } + } while (keepFinding); + // When stacked symbol is split over multiple rows, there's no way to guess if this pair can be last or not. + // boolean mayBeLast = checkPairSequence(previousPairs, pattern); + let leftChar = this.decodeDataCharacter(row, pattern, isOddPattern, true); + if (!this.isEmptyPair(previousPairs) && previousPairs[previousPairs.length - 1].mustBeLast()) { + throw new NotFoundException(); + } + let rightChar; + try { + rightChar = this.decodeDataCharacter(row, pattern, isOddPattern, false); + } + catch (e) { + rightChar = null; + if (this.verbose) { + console.log(e); + } + } + return new ExpandedPair(leftChar, rightChar, pattern, true); + } + isEmptyPair(pairs) { + if (pairs.length === 0) { + return true; + } + return false; + } + findNextPair(row, previousPairs, forcedOffset) { + let counters = this.getDecodeFinderCounters(); + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + let width = row.getSize(); + let rowOffset; + if (forcedOffset >= 0) { + rowOffset = forcedOffset; + } + else if (this.isEmptyPair(previousPairs)) { + rowOffset = 0; + } + else { + let lastPair = previousPairs[previousPairs.length - 1]; + rowOffset = lastPair.getFinderPattern().getStartEnd()[1]; + } + let searchingEvenPair = previousPairs.length % 2 != 0; + if (this.startFromEven) { + searchingEvenPair = !searchingEvenPair; + } + let isWhite = false; + while (rowOffset < width) { + isWhite = !row.get(rowOffset); + if (!isWhite) { + break; + } + rowOffset++; + } + let counterPosition = 0; + let patternStart = rowOffset; + for (let x = rowOffset; x < width; x++) { + if (row.get(x) != isWhite) { + counters[counterPosition]++; + } + else { + if (counterPosition == 3) { + if (searchingEvenPair) { + RSSExpandedReader.reverseCounters(counters); + } + if (RSSExpandedReader.isFinderPattern(counters)) { + this.startEnd[0] = patternStart; + this.startEnd[1] = x; + return; + } + if (searchingEvenPair) { + RSSExpandedReader.reverseCounters(counters); + } + patternStart += counters[0] + counters[1]; + counters[0] = counters[2]; + counters[1] = counters[3]; + counters[2] = 0; + counters[3] = 0; + counterPosition--; + } + else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + throw new NotFoundException(); + } + static reverseCounters(counters) { + let length = counters.length; + for (let i = 0; i < length / 2; ++i) { + let tmp = counters[i]; + counters[i] = counters[length - i - 1]; + counters[length - i - 1] = tmp; + } + } + parseFoundFinderPattern(row, rowNumber, oddPattern) { + // Actually we found elements 2-5. + let firstCounter; + let start; + let end; + if (oddPattern) { + // If pattern number is odd, we need to locate element 1 *before* the current block. + let firstElementStart = this.startEnd[0] - 1; + // Locate element 1 + while (firstElementStart >= 0 && !row.get(firstElementStart)) { + firstElementStart--; + } + firstElementStart++; + firstCounter = this.startEnd[0] - firstElementStart; + start = firstElementStart; + end = this.startEnd[1]; + } + else { + // If pattern number is even, the pattern is reversed, so we need to locate element 1 *after* the current block. + start = this.startEnd[0]; + end = row.getNextUnset(this.startEnd[1] + 1); + firstCounter = end - this.startEnd[1]; + } + // Make 'counters' hold 1-4 + let counters = this.getDecodeFinderCounters(); + System.arraycopy(counters, 0, counters, 1, counters.length - 1); + counters[0] = firstCounter; + let value; + try { + value = this.parseFinderValue(counters, RSSExpandedReader.FINDER_PATTERNS); + } + catch (e) { + return null; + } + // return new FinderPattern(value, new int[] { start, end }, start, end, rowNumber}); + return new FinderPattern(value, [start, end], start, end, rowNumber); + } + decodeDataCharacter(row, pattern, isOddPattern, leftChar) { + let counters = this.getDataCharacterCounters(); + for (let x = 0; x < counters.length; x++) { + counters[x] = 0; + } + if (leftChar) { + RSSExpandedReader.recordPatternInReverse(row, pattern.getStartEnd()[0], counters); + } + else { + RSSExpandedReader.recordPattern(row, pattern.getStartEnd()[1], counters); + // reverse it + for (let i = 0, j = counters.length - 1; i < j; i++, j--) { + let temp = counters[i]; + counters[i] = counters[j]; + counters[j] = temp; + } + } // counters[] has the pixels of the module + let numModules = 17; // left and right data characters have all the same length + let elementWidth = MathUtils.sum(new Int32Array(counters)) / numModules; + // Sanity check: element width for pattern and the character should match + let expectedElementWidth = (pattern.getStartEnd()[1] - pattern.getStartEnd()[0]) / 15.0; + if (Math.abs(elementWidth - expectedElementWidth) / expectedElementWidth > 0.3) { + throw new NotFoundException(); + } + let oddCounts = this.getOddCounts(); + let evenCounts = this.getEvenCounts(); + let oddRoundingErrors = this.getOddRoundingErrors(); + let evenRoundingErrors = this.getEvenRoundingErrors(); + for (let i = 0; i < counters.length; i++) { + let value = 1.0 * counters[i] / elementWidth; + let count = value + 0.5; // Round + if (count < 1) { + if (value < 0.3) { + throw new NotFoundException(); + } + count = 1; + } + else if (count > 8) { + if (value > 8.7) { + throw new NotFoundException(); + } + count = 8; + } + let offset = i / 2; + if ((i & 0x01) == 0) { + oddCounts[offset] = count; + oddRoundingErrors[offset] = value - count; + } + else { + evenCounts[offset] = count; + evenRoundingErrors[offset] = value - count; + } + } + this.adjustOddEvenCounts(numModules); + let weightRowNumber = 4 * pattern.getValue() + (isOddPattern ? 0 : 2) + (leftChar ? 0 : 1) - 1; + let oddSum = 0; + let oddChecksumPortion = 0; + for (let i = oddCounts.length - 1; i >= 0; i--) { + if (RSSExpandedReader.isNotA1left(pattern, isOddPattern, leftChar)) { + let weight = RSSExpandedReader.WEIGHTS[weightRowNumber][2 * i]; + oddChecksumPortion += oddCounts[i] * weight; + } + oddSum += oddCounts[i]; + } + let evenChecksumPortion = 0; + // int evenSum = 0; + for (let i = evenCounts.length - 1; i >= 0; i--) { + if (RSSExpandedReader.isNotA1left(pattern, isOddPattern, leftChar)) { + let weight = RSSExpandedReader.WEIGHTS[weightRowNumber][2 * i + 1]; + evenChecksumPortion += evenCounts[i] * weight; + } + // evenSum += evenCounts[i]; + } + let checksumPortion = oddChecksumPortion + evenChecksumPortion; + if ((oddSum & 0x01) != 0 || oddSum > 13 || oddSum < 4) { + throw new NotFoundException(); + } + let group = (13 - oddSum) / 2; + let oddWidest = RSSExpandedReader.SYMBOL_WIDEST[group]; + let evenWidest = 9 - oddWidest; + let vOdd = RSSUtils.getRSSvalue(oddCounts, oddWidest, true); + let vEven = RSSUtils.getRSSvalue(evenCounts, evenWidest, false); + let tEven = RSSExpandedReader.EVEN_TOTAL_SUBSET[group]; + let gSum = RSSExpandedReader.GSUM[group]; + let value = vOdd * tEven + vEven + gSum; + return new DataCharacter(value, checksumPortion); + } + static isNotA1left(pattern, isOddPattern, leftChar) { + // A1: pattern.getValue is 0 (A), and it's an oddPattern, and it is a left char + return !(pattern.getValue() == 0 && isOddPattern && leftChar); + } + adjustOddEvenCounts(numModules) { + let oddSum = MathUtils.sum(new Int32Array(this.getOddCounts())); + let evenSum = MathUtils.sum(new Int32Array(this.getEvenCounts())); + let incrementOdd = false; + let decrementOdd = false; + if (oddSum > 13) { + decrementOdd = true; + } + else if (oddSum < 4) { + incrementOdd = true; + } + let incrementEven = false; + let decrementEven = false; + if (evenSum > 13) { + decrementEven = true; + } + else if (evenSum < 4) { + incrementEven = true; + } + let mismatch = oddSum + evenSum - numModules; + let oddParityBad = (oddSum & 0x01) == 1; + let evenParityBad = (evenSum & 0x01) == 0; + if (mismatch == 1) { + if (oddParityBad) { + if (evenParityBad) { + throw new NotFoundException(); + } + decrementOdd = true; + } + else { + if (!evenParityBad) { + throw new NotFoundException(); + } + decrementEven = true; + } + } + else if (mismatch == -1) { + if (oddParityBad) { + if (evenParityBad) { + throw new NotFoundException(); + } + incrementOdd = true; + } + else { + if (!evenParityBad) { + throw new NotFoundException(); + } + incrementEven = true; + } + } + else if (mismatch == 0) { + if (oddParityBad) { + if (!evenParityBad) { + throw new NotFoundException(); + } + // Both bad + if (oddSum < evenSum) { + incrementOdd = true; + decrementEven = true; + } + else { + decrementOdd = true; + incrementEven = true; + } + } + else { + if (evenParityBad) { + throw new NotFoundException(); + } + // Nothing to do! + } + } + else { + throw new NotFoundException(); + } + if (incrementOdd) { + if (decrementOdd) { + throw new NotFoundException(); + } + RSSExpandedReader.increment(this.getOddCounts(), this.getOddRoundingErrors()); + } + if (decrementOdd) { + RSSExpandedReader.decrement(this.getOddCounts(), this.getOddRoundingErrors()); + } + if (incrementEven) { + if (decrementEven) { + throw new NotFoundException(); + } + RSSExpandedReader.increment(this.getEvenCounts(), this.getOddRoundingErrors()); + } + if (decrementEven) { + RSSExpandedReader.decrement(this.getEvenCounts(), this.getEvenRoundingErrors()); + } + } + } + RSSExpandedReader.SYMBOL_WIDEST = [7, 5, 4, 3, 1]; + RSSExpandedReader.EVEN_TOTAL_SUBSET = [4, 20, 52, 104, 204]; + RSSExpandedReader.GSUM = [0, 348, 1388, 2948, 3988]; + RSSExpandedReader.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]) // F + ]; + RSSExpandedReader.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] + ]; + RSSExpandedReader.FINDER_PAT_A = 0; + RSSExpandedReader.FINDER_PAT_B = 1; + RSSExpandedReader.FINDER_PAT_C = 2; + RSSExpandedReader.FINDER_PAT_D = 3; + RSSExpandedReader.FINDER_PAT_E = 4; + RSSExpandedReader.FINDER_PAT_F = 5; + RSSExpandedReader.FINDER_PATTERN_SEQUENCES = [ + [RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_A], + [RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_B], + [RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_C, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_D], + [RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_E, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_D, RSSExpandedReader.FINDER_PAT_C], + [RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_E, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_D, RSSExpandedReader.FINDER_PAT_D, RSSExpandedReader.FINDER_PAT_F], + [RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_E, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_D, RSSExpandedReader.FINDER_PAT_E, RSSExpandedReader.FINDER_PAT_F, RSSExpandedReader.FINDER_PAT_F], + [RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_C, RSSExpandedReader.FINDER_PAT_C, RSSExpandedReader.FINDER_PAT_D, RSSExpandedReader.FINDER_PAT_D], + [RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_C, RSSExpandedReader.FINDER_PAT_C, RSSExpandedReader.FINDER_PAT_D, RSSExpandedReader.FINDER_PAT_E, RSSExpandedReader.FINDER_PAT_E], + [RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_C, RSSExpandedReader.FINDER_PAT_C, RSSExpandedReader.FINDER_PAT_D, RSSExpandedReader.FINDER_PAT_E, RSSExpandedReader.FINDER_PAT_F, RSSExpandedReader.FINDER_PAT_F], + [RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_A, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_B, RSSExpandedReader.FINDER_PAT_C, RSSExpandedReader.FINDER_PAT_D, RSSExpandedReader.FINDER_PAT_D, RSSExpandedReader.FINDER_PAT_E, RSSExpandedReader.FINDER_PAT_E, RSSExpandedReader.FINDER_PAT_F, RSSExpandedReader.FINDER_PAT_F], + ]; + RSSExpandedReader.MAX_PAIRS = 11; + + class Pair extends DataCharacter { + constructor(value, checksumPortion, finderPattern) { + super(value, checksumPortion); + this.count = 0; + this.finderPattern = finderPattern; + } + getFinderPattern() { + return this.finderPattern; + } + getCount() { + return this.count; + } + incrementCount() { + this.count++; + } + } + + class RSS14Reader extends AbstractRSSReader { + constructor() { + super(...arguments); + this.possibleLeftPairs = []; + this.possibleRightPairs = []; + } + decodeRow(rowNumber, row, hints) { + const leftPair = this.decodePair(row, false, rowNumber, hints); + RSS14Reader.addOrTally(this.possibleLeftPairs, leftPair); + row.reverse(); + let rightPair = this.decodePair(row, true, rowNumber, hints); + RSS14Reader.addOrTally(this.possibleRightPairs, rightPair); + row.reverse(); + for (let left of this.possibleLeftPairs) { + if (left.getCount() > 1) { + for (let right of this.possibleRightPairs) { + if (right.getCount() > 1 && RSS14Reader.checkChecksum(left, right)) { + return RSS14Reader.constructResult(left, right); + } + } + } + } + throw new NotFoundException(); + } + static addOrTally(possiblePairs, pair) { + if (pair == null) { + return; + } + let found = false; + for (let other of possiblePairs) { + if (other.getValue() === pair.getValue()) { + other.incrementCount(); + found = true; + break; + } + } + if (!found) { + possiblePairs.push(pair); + } + } + reset() { + this.possibleLeftPairs.length = 0; + this.possibleRightPairs.length = 0; + } + static constructResult(leftPair, rightPair) { + let symbolValue = 4537077 * leftPair.getValue() + rightPair.getValue(); + let text = new String(symbolValue).toString(); + let buffer = new StringBuilder(); + for (let i = 13 - text.length; i > 0; i--) { + buffer.append('0'); + } + buffer.append(text); + let checkDigit = 0; + for (let i = 0; i < 13; i++) { + let digit = buffer.charAt(i).charCodeAt(0) - '0'.charCodeAt(0); + checkDigit += ((i & 0x01) === 0) ? 3 * digit : digit; + } + checkDigit = 10 - (checkDigit % 10); + if (checkDigit === 10) { + checkDigit = 0; + } + buffer.append(checkDigit.toString()); + let leftPoints = leftPair.getFinderPattern().getResultPoints(); + let rightPoints = rightPair.getFinderPattern().getResultPoints(); + return new Result(buffer.toString(), null, 0, [leftPoints[0], leftPoints[1], rightPoints[0], rightPoints[1]], BarcodeFormat$1.RSS_14, new Date().getTime()); + } + static checkChecksum(leftPair, rightPair) { + let checkValue = (leftPair.getChecksumPortion() + 16 * rightPair.getChecksumPortion()) % 79; + let targetCheckValue = 9 * leftPair.getFinderPattern().getValue() + rightPair.getFinderPattern().getValue(); + if (targetCheckValue > 72) { + targetCheckValue--; + } + if (targetCheckValue > 8) { + targetCheckValue--; + } + return checkValue === targetCheckValue; + } + decodePair(row, right, rowNumber, hints) { + try { + let startEnd = this.findFinderPattern(row, right); + let pattern = this.parseFoundFinderPattern(row, rowNumber, right, startEnd); + let resultPointCallback = hints == null ? null : hints.get(DecodeHintType$1.NEED_RESULT_POINT_CALLBACK); + if (resultPointCallback != null) { + let center = (startEnd[0] + startEnd[1]) / 2.0; + if (right) { + // row is actually reversed + center = row.getSize() - 1 - center; + } + resultPointCallback.foundPossibleResultPoint(new ResultPoint(center, rowNumber)); + } + let outside = this.decodeDataCharacter(row, pattern, true); + let inside = this.decodeDataCharacter(row, pattern, false); + return new Pair(1597 * outside.getValue() + inside.getValue(), outside.getChecksumPortion() + 4 * inside.getChecksumPortion(), pattern); + } + catch (err) { + return null; + } + } + decodeDataCharacter(row, pattern, outsideChar) { + let counters = this.getDataCharacterCounters(); + for (let x = 0; x < counters.length; x++) { + counters[x] = 0; + } + if (outsideChar) { + OneDReader.recordPatternInReverse(row, pattern.getStartEnd()[0], counters); + } + else { + OneDReader.recordPattern(row, pattern.getStartEnd()[1] + 1, counters); + // reverse it + for (let i = 0, j = counters.length - 1; i < j; i++, j--) { + let temp = counters[i]; + counters[i] = counters[j]; + counters[j] = temp; + } + } + let numModules = outsideChar ? 16 : 15; + let elementWidth = MathUtils.sum(new Int32Array(counters)) / numModules; + let oddCounts = this.getOddCounts(); + let evenCounts = this.getEvenCounts(); + let oddRoundingErrors = this.getOddRoundingErrors(); + let evenRoundingErrors = this.getEvenRoundingErrors(); + for (let i = 0; i < counters.length; i++) { + let value = counters[i] / elementWidth; + let count = Math.floor(value + 0.5); + if (count < 1) { + count = 1; + } + else if (count > 8) { + count = 8; + } + let offset = Math.floor(i / 2); + if ((i & 0x01) === 0) { + oddCounts[offset] = count; + oddRoundingErrors[offset] = value - count; + } + else { + evenCounts[offset] = count; + evenRoundingErrors[offset] = value - count; + } + } + this.adjustOddEvenCounts(outsideChar, numModules); + let oddSum = 0; + let oddChecksumPortion = 0; + for (let i = oddCounts.length - 1; i >= 0; i--) { + oddChecksumPortion *= 9; + oddChecksumPortion += oddCounts[i]; + oddSum += oddCounts[i]; + } + let evenChecksumPortion = 0; + let evenSum = 0; + for (let i = evenCounts.length - 1; i >= 0; i--) { + evenChecksumPortion *= 9; + evenChecksumPortion += evenCounts[i]; + evenSum += evenCounts[i]; + } + let checksumPortion = oddChecksumPortion + 3 * evenChecksumPortion; + if (outsideChar) { + if ((oddSum & 0x01) !== 0 || oddSum > 12 || oddSum < 4) { + throw new NotFoundException(); + } + let group = (12 - oddSum) / 2; + let oddWidest = RSS14Reader.OUTSIDE_ODD_WIDEST[group]; + let evenWidest = 9 - oddWidest; + let vOdd = RSSUtils.getRSSvalue(oddCounts, oddWidest, false); + let vEven = RSSUtils.getRSSvalue(evenCounts, evenWidest, true); + let tEven = RSS14Reader.OUTSIDE_EVEN_TOTAL_SUBSET[group]; + let gSum = RSS14Reader.OUTSIDE_GSUM[group]; + return new DataCharacter(vOdd * tEven + vEven + gSum, checksumPortion); + } + else { + if ((evenSum & 0x01) !== 0 || evenSum > 10 || evenSum < 4) { + throw new NotFoundException(); + } + let group = (10 - evenSum) / 2; + let oddWidest = RSS14Reader.INSIDE_ODD_WIDEST[group]; + let evenWidest = 9 - oddWidest; + let vOdd = RSSUtils.getRSSvalue(oddCounts, oddWidest, true); + let vEven = RSSUtils.getRSSvalue(evenCounts, evenWidest, false); + let tOdd = RSS14Reader.INSIDE_ODD_TOTAL_SUBSET[group]; + let gSum = RSS14Reader.INSIDE_GSUM[group]; + return new DataCharacter(vEven * tOdd + vOdd + gSum, checksumPortion); + } + } + findFinderPattern(row, rightFinderPattern) { + let counters = this.getDecodeFinderCounters(); + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + let width = row.getSize(); + let isWhite = false; + let rowOffset = 0; + while (rowOffset < width) { + isWhite = !row.get(rowOffset); + if (rightFinderPattern === isWhite) { + // Will encounter white first when searching for right finder pattern + break; + } + rowOffset++; + } + let counterPosition = 0; + let patternStart = rowOffset; + for (let x = rowOffset; x < width; x++) { + if (row.get(x) !== isWhite) { + counters[counterPosition]++; + } + else { + if (counterPosition === 3) { + if (AbstractRSSReader.isFinderPattern(counters)) { + return [patternStart, x]; + } + patternStart += counters[0] + counters[1]; + counters[0] = counters[2]; + counters[1] = counters[3]; + counters[2] = 0; + counters[3] = 0; + counterPosition--; + } + else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + throw new NotFoundException(); + } + parseFoundFinderPattern(row, rowNumber, right, startEnd) { + // Actually we found elements 2-5 + let firstIsBlack = row.get(startEnd[0]); + let firstElementStart = startEnd[0] - 1; + // Locate element 1 + while (firstElementStart >= 0 && firstIsBlack !== row.get(firstElementStart)) { + firstElementStart--; + } + firstElementStart++; + const firstCounter = startEnd[0] - firstElementStart; + // Make 'counters' hold 1-4 + const counters = this.getDecodeFinderCounters(); + const copy = new Int32Array(counters.length); + System.arraycopy(counters, 0, copy, 1, counters.length - 1); + copy[0] = firstCounter; + const value = this.parseFinderValue(copy, RSS14Reader.FINDER_PATTERNS); + let start = firstElementStart; + let end = startEnd[1]; + if (right) { + // row is actually reversed + start = row.getSize() - 1 - start; + end = row.getSize() - 1 - end; + } + return new FinderPattern(value, [firstElementStart, startEnd[1]], start, end, rowNumber); + } + adjustOddEvenCounts(outsideChar, numModules) { + let oddSum = MathUtils.sum(new Int32Array(this.getOddCounts())); + let evenSum = MathUtils.sum(new Int32Array(this.getEvenCounts())); + let incrementOdd = false; + let decrementOdd = false; + let incrementEven = false; + let decrementEven = false; + if (outsideChar) { + if (oddSum > 12) { + decrementOdd = true; + } + else if (oddSum < 4) { + incrementOdd = true; + } + if (evenSum > 12) { + decrementEven = true; + } + else if (evenSum < 4) { + incrementEven = true; + } + } + else { + if (oddSum > 11) { + decrementOdd = true; + } + else if (oddSum < 5) { + incrementOdd = true; + } + if (evenSum > 10) { + decrementEven = true; + } + else if (evenSum < 4) { + incrementEven = true; + } + } + let mismatch = oddSum + evenSum - numModules; + let oddParityBad = (oddSum & 0x01) === (outsideChar ? 1 : 0); + let evenParityBad = (evenSum & 0x01) === 1; + if (mismatch === 1) { + if (oddParityBad) { + if (evenParityBad) { + throw new NotFoundException(); + } + decrementOdd = true; + } + else { + if (!evenParityBad) { + throw new NotFoundException(); + } + decrementEven = true; + } + } + else if (mismatch === -1) { + if (oddParityBad) { + if (evenParityBad) { + throw new NotFoundException(); + } + incrementOdd = true; + } + else { + if (!evenParityBad) { + throw new NotFoundException(); + } + incrementEven = true; + } + } + else if (mismatch === 0) { + if (oddParityBad) { + if (!evenParityBad) { + throw new NotFoundException(); + } + // Both bad + if (oddSum < evenSum) { + incrementOdd = true; + decrementEven = true; + } + else { + decrementOdd = true; + incrementEven = true; + } + } + else { + if (evenParityBad) { + throw new NotFoundException(); + } + // Nothing to do! + } + } + else { + throw new NotFoundException(); + } + if (incrementOdd) { + if (decrementOdd) { + throw new NotFoundException(); + } + AbstractRSSReader.increment(this.getOddCounts(), this.getOddRoundingErrors()); + } + if (decrementOdd) { + AbstractRSSReader.decrement(this.getOddCounts(), this.getOddRoundingErrors()); + } + if (incrementEven) { + if (decrementEven) { + throw new NotFoundException(); + } + AbstractRSSReader.increment(this.getEvenCounts(), this.getOddRoundingErrors()); + } + if (decrementEven) { + AbstractRSSReader.decrement(this.getEvenCounts(), this.getEvenRoundingErrors()); + } + } + } + RSS14Reader.OUTSIDE_EVEN_TOTAL_SUBSET = [1, 10, 34, 70, 126]; + RSS14Reader.INSIDE_ODD_TOTAL_SUBSET = [4, 20, 48, 81]; + RSS14Reader.OUTSIDE_GSUM = [0, 161, 961, 2015, 2715]; + RSS14Reader.INSIDE_GSUM = [0, 336, 1036, 1516]; + RSS14Reader.OUTSIDE_ODD_WIDEST = [8, 6, 4, 3, 1]; + RSS14Reader.INSIDE_ODD_WIDEST = [2, 4, 6, 8]; + RSS14Reader.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]), + ]; + + /** + * @author Daniel Switkin <dswitkin@google.com> + * @author Sean Owen + */ + class MultiFormatOneDReader extends OneDReader { + constructor(hints, verbose) { + super(); + this.readers = []; + this.verbose = (verbose === true); + const possibleFormats = !hints ? null : hints.get(DecodeHintType$1.POSSIBLE_FORMATS); + const useCode39CheckDigit = hints && hints.get(DecodeHintType$1.ASSUME_CODE_39_CHECK_DIGIT) !== undefined; + if (possibleFormats) { + if (possibleFormats.includes(BarcodeFormat$1.EAN_13) || + possibleFormats.includes(BarcodeFormat$1.UPC_A) || + possibleFormats.includes(BarcodeFormat$1.EAN_8) || + possibleFormats.includes(BarcodeFormat$1.UPC_E)) { + this.readers.push(new MultiFormatUPCEANReader(hints)); + } + if (possibleFormats.includes(BarcodeFormat$1.CODE_39)) { + this.readers.push(new Code39Reader(useCode39CheckDigit)); + } + // if (possibleFormats.includes(BarcodeFormat.CODE_93)) { + // this.readers.push(new Code93Reader()); + // } + if (possibleFormats.includes(BarcodeFormat$1.CODE_128)) { + this.readers.push(new Code128Reader()); + } + if (possibleFormats.includes(BarcodeFormat$1.ITF)) { + this.readers.push(new ITFReader()); + } + // if (possibleFormats.includes(BarcodeFormat.CODABAR)) { + // this.readers.push(new CodaBarReader()); + // } + if (possibleFormats.includes(BarcodeFormat$1.RSS_14)) { + this.readers.push(new RSS14Reader()); + } + if (possibleFormats.includes(BarcodeFormat$1.RSS_EXPANDED)) { + this.readers.push(new RSSExpandedReader(this.verbose)); + } + } else { + // Case when no hints were provided -> add all. + this.readers.push(new MultiFormatUPCEANReader(hints)); + this.readers.push(new Code39Reader()); + // this.readers.push(new CodaBarReader()); + // this.readers.push(new Code93Reader()); + this.readers.push(new MultiFormatUPCEANReader(hints)); + this.readers.push(new Code128Reader()); + this.readers.push(new ITFReader()); + this.readers.push(new RSS14Reader()); + this.readers.push(new RSSExpandedReader(this.verbose)); + } + } + // @Override + decodeRow(rowNumber, row, hints) { + for (let i = 0; i < this.readers.length; i++) { + try { + return this.readers[i].decodeRow(rowNumber, row, hints); + } + catch (re) { + // continue + } + } + throw new NotFoundException(); + } + // @Override + reset() { + this.readers.forEach(reader => reader.reset()); + } + } + + /** + * @deprecated Moving to @zxing/browser + * + * Barcode reader reader to use from browser. + */ + class BrowserBarcodeReader extends BrowserCodeReader { + /** + * Creates an instance of BrowserBarcodeReader. + * @param {number} [timeBetweenScansMillis=500] the time delay between subsequent decode tries + * @param {Map<DecodeHintType, any>} hints + */ + constructor(timeBetweenScansMillis = 500, hints) { + super(new MultiFormatOneDReader(hints), timeBetweenScansMillis, hints); + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Encapsulates a set of error-correction blocks in one symbol version. Most versions will + * use blocks of differing sizes within one version, so, this encapsulates the parameters for + * each set of blocks. It also holds the number of error-correction codewords per block since it + * will be the same across all blocks within one version.</p> + */ + class ECBlocks { + constructor(ecCodewords, ecBlocks1, ecBlocks2) { + this.ecCodewords = ecCodewords; + this.ecBlocks = [ecBlocks1]; + ecBlocks2 && this.ecBlocks.push(ecBlocks2); + } + getECCodewords() { + return this.ecCodewords; + } + getECBlocks() { + return this.ecBlocks; + } + } + /** + * <p>Encapsulates the parameters for one error-correction block in one symbol version. + * This includes the number of data codewords, and the number of times a block with these + * parameters is used consecutively in the Data Matrix code version's format.</p> + */ + class ECB { + constructor(count, dataCodewords) { + this.count = count; + this.dataCodewords = dataCodewords; + } + getCount() { + return this.count; + } + getDataCodewords() { + return this.dataCodewords; + } + } + /** + * The Version object encapsulates attributes about a particular + * size Data Matrix Code. + * + * @author bbrown@google.com (Brian Brown) + */ + class Version { + constructor(versionNumber, symbolSizeRows, symbolSizeColumns, dataRegionSizeRows, dataRegionSizeColumns, ecBlocks) { + this.versionNumber = versionNumber; + this.symbolSizeRows = symbolSizeRows; + this.symbolSizeColumns = symbolSizeColumns; + this.dataRegionSizeRows = dataRegionSizeRows; + this.dataRegionSizeColumns = dataRegionSizeColumns; + this.ecBlocks = ecBlocks; + // Calculate the total number of codewords + let total = 0; + const ecCodewords = ecBlocks.getECCodewords(); + const ecbArray = ecBlocks.getECBlocks(); + for (let ecBlock of ecbArray) { + total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords); + } + this.totalCodewords = total; + } + 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; + } + /** + * <p>Deduces version information from Data Matrix dimensions.</p> + * + * @param numRows Number of rows in modules + * @param numColumns Number of columns in modules + * @return Version for a Data Matrix Code of those dimensions + * @throws FormatException if dimensions do correspond to a valid Data Matrix size + */ + static getVersionForDimensions(numRows, numColumns) { + if ((numRows & 0x01) !== 0 || (numColumns & 0x01) !== 0) { + throw new FormatException(); + } + for (let version of Version.VERSIONS) { + if (version.symbolSizeRows === numRows && version.symbolSizeColumns === numColumns) { + return version; + } + } + throw new FormatException(); + } + // @Override + toString() { + return '' + this.versionNumber; + } + /** + * See ISO 16022:2006 5.5.1 Table 7 + */ + static buildVersions() { + return [ + new Version(1, 10, 10, 8, 8, new ECBlocks(5, new ECB(1, 3))), + new Version(2, 12, 12, 10, 10, new ECBlocks(7, new ECB(1, 5))), + new Version(3, 14, 14, 12, 12, new ECBlocks(10, new ECB(1, 8))), + new Version(4, 16, 16, 14, 14, new ECBlocks(12, new ECB(1, 12))), + new Version(5, 18, 18, 16, 16, new ECBlocks(14, new ECB(1, 18))), + new Version(6, 20, 20, 18, 18, new ECBlocks(18, new ECB(1, 22))), + new Version(7, 22, 22, 20, 20, new ECBlocks(20, new ECB(1, 30))), + new Version(8, 24, 24, 22, 22, new ECBlocks(24, new ECB(1, 36))), + new Version(9, 26, 26, 24, 24, new ECBlocks(28, new ECB(1, 44))), + new Version(10, 32, 32, 14, 14, new ECBlocks(36, new ECB(1, 62))), + new Version(11, 36, 36, 16, 16, new ECBlocks(42, new ECB(1, 86))), + new Version(12, 40, 40, 18, 18, new ECBlocks(48, new ECB(1, 114))), + new Version(13, 44, 44, 20, 20, new ECBlocks(56, new ECB(1, 144))), + new Version(14, 48, 48, 22, 22, new ECBlocks(68, new ECB(1, 174))), + new Version(15, 52, 52, 24, 24, new ECBlocks(42, new ECB(2, 102))), + new Version(16, 64, 64, 14, 14, new ECBlocks(56, new ECB(2, 140))), + new Version(17, 72, 72, 16, 16, new ECBlocks(36, new ECB(4, 92))), + new Version(18, 80, 80, 18, 18, new ECBlocks(48, new ECB(4, 114))), + new Version(19, 88, 88, 20, 20, new ECBlocks(56, new ECB(4, 144))), + new Version(20, 96, 96, 22, 22, new ECBlocks(68, new ECB(4, 174))), + new Version(21, 104, 104, 24, 24, new ECBlocks(56, new ECB(6, 136))), + new Version(22, 120, 120, 18, 18, new ECBlocks(68, new ECB(6, 175))), + new Version(23, 132, 132, 20, 20, new ECBlocks(62, new ECB(8, 163))), + new Version(24, 144, 144, 22, 22, new ECBlocks(62, new ECB(8, 156), new ECB(2, 155))), + new Version(25, 8, 18, 6, 16, new ECBlocks(7, new ECB(1, 5))), + new Version(26, 8, 32, 6, 14, new ECBlocks(11, new ECB(1, 10))), + new Version(27, 12, 26, 10, 24, new ECBlocks(14, new ECB(1, 16))), + new Version(28, 12, 36, 10, 16, new ECBlocks(18, new ECB(1, 22))), + new Version(29, 16, 36, 14, 16, new ECBlocks(24, new ECB(1, 32))), + new Version(30, 16, 48, 14, 22, new ECBlocks(28, new ECB(1, 49))) + ]; + } + } + Version.VERSIONS = Version.buildVersions(); + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * @author bbrown@google.com (Brian Brown) + */ + class BitMatrixParser { + /** + * @param bitMatrix {@link BitMatrix} to parse + * @throws FormatException if dimension is < 8 or > 144 or not 0 mod 2 + */ + constructor(bitMatrix) { + const dimension = bitMatrix.getHeight(); + if (dimension < 8 || dimension > 144 || (dimension & 0x01) !== 0) { + throw new FormatException(); + } + this.version = BitMatrixParser.readVersion(bitMatrix); + this.mappingBitMatrix = this.extractDataRegion(bitMatrix); + this.readMappingMatrix = new BitMatrix(this.mappingBitMatrix.getWidth(), this.mappingBitMatrix.getHeight()); + } + getVersion() { + return this.version; + } + /** + * <p>Creates the version object based on the dimension of the original bit matrix from + * the datamatrix code.</p> + * + * <p>See ISO 16022:2006 Table 7 - ECC 200 symbol attributes</p> + * + * @param bitMatrix Original {@link BitMatrix} including alignment patterns + * @return {@link Version} encapsulating the Data Matrix Code's "version" + * @throws FormatException if the dimensions of the mapping matrix are not valid + * Data Matrix dimensions. + */ + static readVersion(bitMatrix) { + const numRows = bitMatrix.getHeight(); + const numColumns = bitMatrix.getWidth(); + return Version.getVersionForDimensions(numRows, numColumns); + } + /** + * <p>Reads the bits in the {@link BitMatrix} representing the mapping matrix (No alignment patterns) + * in the correct order in order to reconstitute the codewords bytes contained within the + * Data Matrix Code.</p> + * + * @return bytes encoded within the Data Matrix Code + * @throws FormatException if the exact number of bytes expected is not read + */ + readCodewords() { + const result = new Int8Array(this.version.getTotalCodewords()); + let resultOffset = 0; + let row = 4; + let column = 0; + const numRows = this.mappingBitMatrix.getHeight(); + const numColumns = this.mappingBitMatrix.getWidth(); + let corner1Read = false; + let corner2Read = false; + let corner3Read = false; + let corner4Read = false; + // Read all of the codewords + do { + // Check the four corner cases + if ((row === numRows) && (column === 0) && !corner1Read) { + result[resultOffset++] = this.readCorner1(numRows, numColumns) & 0xff; + row -= 2; + column += 2; + corner1Read = true; + } + else if ((row === numRows - 2) && (column === 0) && ((numColumns & 0x03) !== 0) && !corner2Read) { + result[resultOffset++] = this.readCorner2(numRows, numColumns) & 0xff; + row -= 2; + column += 2; + corner2Read = true; + } + else if ((row === numRows + 4) && (column === 2) && ((numColumns & 0x07) === 0) && !corner3Read) { + result[resultOffset++] = this.readCorner3(numRows, numColumns) & 0xff; + row -= 2; + column += 2; + corner3Read = true; + } + else if ((row === numRows - 2) && (column === 0) && ((numColumns & 0x07) === 4) && !corner4Read) { + result[resultOffset++] = this.readCorner4(numRows, numColumns) & 0xff; + row -= 2; + column += 2; + corner4Read = true; + } + else { + // Sweep upward diagonally to the right + do { + if ((row < numRows) && (column >= 0) && !this.readMappingMatrix.get(column, row)) { + result[resultOffset++] = this.readUtah(row, column, numRows, numColumns) & 0xff; + } + row -= 2; + column += 2; + } while ((row >= 0) && (column < numColumns)); + row += 1; + column += 3; + // Sweep downward diagonally to the left + do { + if ((row >= 0) && (column < numColumns) && !this.readMappingMatrix.get(column, row)) { + result[resultOffset++] = this.readUtah(row, column, numRows, numColumns) & 0xff; + } + row += 2; + column -= 2; + } while ((row < numRows) && (column >= 0)); + row += 3; + column += 1; + } + } while ((row < numRows) || (column < numColumns)); + if (resultOffset !== this.version.getTotalCodewords()) { + throw new FormatException(); + } + return result; + } + /** + * <p>Reads a bit of the mapping matrix accounting for boundary wrapping.</p> + * + * @param row Row to read in the mapping matrix + * @param column Column to read in the mapping matrix + * @param numRows Number of rows in the mapping matrix + * @param numColumns Number of columns in the mapping matrix + * @return value of the given bit in the mapping matrix + */ + readModule(row, column, numRows, numColumns) { + // Adjust the row and column indices based on boundary wrapping + if (row < 0) { + row += numRows; + column += 4 - ((numRows + 4) & 0x07); + } + if (column < 0) { + column += numColumns; + row += 4 - ((numColumns + 4) & 0x07); + } + this.readMappingMatrix.set(column, row); + return this.mappingBitMatrix.get(column, row); + } + /** + * <p>Reads the 8 bits of the standard Utah-shaped pattern.</p> + * + * <p>See ISO 16022:2006, 5.8.1 Figure 6</p> + * + * @param row Current row in the mapping matrix, anchored at the 8th bit (LSB) of the pattern + * @param column Current column in the mapping matrix, anchored at the 8th bit (LSB) of the pattern + * @param numRows Number of rows in the mapping matrix + * @param numColumns Number of columns in the mapping matrix + * @return byte from the utah shape + */ + readUtah(row, column, numRows, numColumns) { + let currentByte = 0; + if (this.readModule(row - 2, column - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(row - 2, column - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(row - 1, column - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(row - 1, column - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(row - 1, column, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(row, column - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(row, column - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(row, column, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; + } + /** + * <p>Reads the 8 bits of the special corner condition 1.</p> + * + * <p>See ISO 16022:2006, Figure F.3</p> + * + * @param numRows Number of rows in the mapping matrix + * @param numColumns Number of columns in the mapping matrix + * @return byte from the Corner condition 1 + */ + readCorner1(numRows, numColumns) { + let currentByte = 0; + if (this.readModule(numRows - 1, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(numRows - 1, 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(numRows - 1, 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(0, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(0, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(2, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(3, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; + } + /** + * <p>Reads the 8 bits of the special corner condition 2.</p> + * + * <p>See ISO 16022:2006, Figure F.4</p> + * + * @param numRows Number of rows in the mapping matrix + * @param numColumns Number of columns in the mapping matrix + * @return byte from the Corner condition 2 + */ + readCorner2(numRows, numColumns) { + let currentByte = 0; + if (this.readModule(numRows - 3, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(numRows - 2, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(numRows - 1, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(0, numColumns - 4, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(0, numColumns - 3, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(0, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(0, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; + } + /** + * <p>Reads the 8 bits of the special corner condition 3.</p> + * + * <p>See ISO 16022:2006, Figure F.5</p> + * + * @param numRows Number of rows in the mapping matrix + * @param numColumns Number of columns in the mapping matrix + * @return byte from the Corner condition 3 + */ + readCorner3(numRows, numColumns) { + let currentByte = 0; + if (this.readModule(numRows - 1, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(numRows - 1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(0, numColumns - 3, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(0, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(0, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(1, numColumns - 3, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(1, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; + } + /** + * <p>Reads the 8 bits of the special corner condition 4.</p> + * + * <p>See ISO 16022:2006, Figure F.6</p> + * + * @param numRows Number of rows in the mapping matrix + * @param numColumns Number of columns in the mapping matrix + * @return byte from the Corner condition 4 + */ + readCorner4(numRows, numColumns) { + let currentByte = 0; + if (this.readModule(numRows - 3, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(numRows - 2, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(numRows - 1, 0, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(0, numColumns - 2, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(0, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(1, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(2, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + currentByte <<= 1; + if (this.readModule(3, numColumns - 1, numRows, numColumns)) { + currentByte |= 1; + } + return currentByte; + } + /** + * <p>Extracts the data region from a {@link BitMatrix} that contains + * alignment patterns.</p> + * + * @param bitMatrix Original {@link BitMatrix} with alignment patterns + * @return BitMatrix that has the alignment patterns removed + */ + extractDataRegion(bitMatrix) { + const symbolSizeRows = this.version.getSymbolSizeRows(); + const symbolSizeColumns = this.version.getSymbolSizeColumns(); + if (bitMatrix.getHeight() !== symbolSizeRows) { + throw new IllegalArgumentException('Dimension of bitMatrix must match the version size'); + } + const dataRegionSizeRows = this.version.getDataRegionSizeRows(); + const dataRegionSizeColumns = this.version.getDataRegionSizeColumns(); + const numDataRegionsRow = symbolSizeRows / dataRegionSizeRows | 0; + const numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns | 0; + const sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows; + const sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns; + const bitMatrixWithoutAlignment = new BitMatrix(sizeDataRegionColumn, sizeDataRegionRow); + for (let dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) { + const dataRegionRowOffset = dataRegionRow * dataRegionSizeRows; + for (let dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn; ++dataRegionColumn) { + const dataRegionColumnOffset = dataRegionColumn * dataRegionSizeColumns; + for (let i = 0; i < dataRegionSizeRows; ++i) { + const readRowOffset = dataRegionRow * (dataRegionSizeRows + 2) + 1 + i; + const writeRowOffset = dataRegionRowOffset + i; + for (let j = 0; j < dataRegionSizeColumns; ++j) { + const readColumnOffset = dataRegionColumn * (dataRegionSizeColumns + 2) + 1 + j; + if (bitMatrix.get(readColumnOffset, readRowOffset)) { + const writeColumnOffset = dataRegionColumnOffset + j; + bitMatrixWithoutAlignment.set(writeColumnOffset, writeRowOffset); + } + } + } + } + } + return bitMatrixWithoutAlignment; + } + } + + /** + * <p>Encapsulates a block of data within a Data Matrix Code. Data Matrix Codes may split their data into + * multiple blocks, each of which is a unit of data and error-correction codewords. Each + * is represented by an instance of this class.</p> + * + * @author bbrown@google.com (Brian Brown) + */ + class DataBlock { + constructor(numDataCodewords, codewords) { + this.numDataCodewords = numDataCodewords; + this.codewords = codewords; + } + /** + * <p>When Data Matrix Codes use multiple data blocks, they actually interleave the bytes of each of them. + * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This + * method will separate the data into original blocks.</p> + * + * @param rawCodewords bytes as read directly from the Data Matrix Code + * @param version version of the Data Matrix Code + * @return DataBlocks containing original bytes, "de-interleaved" from representation in the + * Data Matrix Code + */ + static getDataBlocks(rawCodewords, version) { + // Figure out the number and size of data blocks used by this version + const ecBlocks = version.getECBlocks(); + // First count the total number of data blocks + let totalBlocks = 0; + const ecBlockArray = ecBlocks.getECBlocks(); + for (let ecBlock of ecBlockArray) { + totalBlocks += ecBlock.getCount(); + } + // Now establish DataBlocks of the appropriate size and number of data codewords + const result = new Array(totalBlocks); + let numResultBlocks = 0; + for (let ecBlock of ecBlockArray) { + for (let i = 0; i < ecBlock.getCount(); i++) { + const numDataCodewords = ecBlock.getDataCodewords(); + const numBlockCodewords = ecBlocks.getECCodewords() + numDataCodewords; + result[numResultBlocks++] = new DataBlock(numDataCodewords, new Uint8Array(numBlockCodewords)); + } + } + // All blocks have the same amount of data, except that the last n + // (where n may be 0) have 1 less byte. Figure out where these start. + // TODO(bbrown): There is only one case where there is a difference for Data Matrix for size 144 + const longerBlocksTotalCodewords = result[0].codewords.length; + // int shorterBlocksTotalCodewords = longerBlocksTotalCodewords - 1; + const longerBlocksNumDataCodewords = longerBlocksTotalCodewords - ecBlocks.getECCodewords(); + const shorterBlocksNumDataCodewords = longerBlocksNumDataCodewords - 1; + // The last elements of result may be 1 element shorter for 144 matrix + // first fill out as many elements as all of them have minus 1 + let rawCodewordsOffset = 0; + for (let i = 0; i < shorterBlocksNumDataCodewords; i++) { + for (let j = 0; j < numResultBlocks; j++) { + result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; + } + } + // Fill out the last data block in the longer ones + const specialVersion = version.getVersionNumber() === 24; + const numLongerBlocks = specialVersion ? 8 : numResultBlocks; + for (let j = 0; j < numLongerBlocks; j++) { + result[j].codewords[longerBlocksNumDataCodewords - 1] = rawCodewords[rawCodewordsOffset++]; + } + // Now add in error correction blocks + const max = result[0].codewords.length; + for (let i = longerBlocksNumDataCodewords; i < max; i++) { + for (let j = 0; j < numResultBlocks; j++) { + const jOffset = specialVersion ? (j + 8) % numResultBlocks : j; + const iOffset = specialVersion && jOffset > 7 ? i - 1 : i; + result[jOffset].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; + } + } + if (rawCodewordsOffset !== rawCodewords.length) { + throw new IllegalArgumentException(); + } + return result; + } + getNumDataCodewords() { + return this.numDataCodewords; + } + getCodewords() { + return this.codewords; + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the + * number of bits read is not often a multiple of 8.</p> + * + * <p>This class is thread-safe but not reentrant -- unless the caller modifies the bytes array + * it passed in, in which case all bets are off.</p> + * + * @author Sean Owen + */ + class BitSource { + /** + * @param bytes bytes from which this will read bits. Bits will be read from the first byte first. + * Bits are read within a byte from most-significant to least-significant bit. + */ + constructor(bytes) { + this.bytes = bytes; + this.byteOffset = 0; + this.bitOffset = 0; + } + /** + * @return index of next bit in current byte which would be read by the next call to {@link #readBits(int)}. + */ + getBitOffset() { + return this.bitOffset; + } + /** + * @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}. + */ + getByteOffset() { + return this.byteOffset; + } + /** + * @param numBits number of bits to read + * @return int representing the bits read. The bits will appear as the least-significant + * bits of the int + * @throws IllegalArgumentException if numBits isn't in [1,32] or more than is available + */ + readBits(numBits /*int*/) { + if (numBits < 1 || numBits > 32 || numBits > this.available()) { + throw new IllegalArgumentException('' + numBits); + } + let result = 0; + let bitOffset = this.bitOffset; + let byteOffset = this.byteOffset; + const bytes = this.bytes; + // First, read remainder from current byte + if (bitOffset > 0) { + const bitsLeft = 8 - bitOffset; + const toRead = numBits < bitsLeft ? numBits : bitsLeft; + const bitsToNotRead = bitsLeft - toRead; + const mask = (0xFF >> (8 - toRead)) << bitsToNotRead; + result = (bytes[byteOffset] & mask) >> bitsToNotRead; + numBits -= toRead; + bitOffset += toRead; + if (bitOffset === 8) { + bitOffset = 0; + byteOffset++; + } + } + // Next read whole bytes + if (numBits > 0) { + while (numBits >= 8) { + result = (result << 8) | (bytes[byteOffset] & 0xFF); + byteOffset++; + numBits -= 8; + } + // Finally read a partial byte + if (numBits > 0) { + const bitsToNotRead = 8 - numBits; + const mask = (0xFF >> bitsToNotRead) << bitsToNotRead; + result = (result << numBits) | ((bytes[byteOffset] & mask) >> bitsToNotRead); + bitOffset += numBits; + } + } + this.bitOffset = bitOffset; + this.byteOffset = byteOffset; + return result; + } + /** + * @return number of bits that can be read successfully + */ + available() { + return 8 * (this.bytes.length - this.byteOffset) - this.bitOffset; + } + } + + var Mode; + (function (Mode) { + Mode[Mode["PAD_ENCODE"] = 0] = "PAD_ENCODE"; + Mode[Mode["ASCII_ENCODE"] = 1] = "ASCII_ENCODE"; + Mode[Mode["C40_ENCODE"] = 2] = "C40_ENCODE"; + Mode[Mode["TEXT_ENCODE"] = 3] = "TEXT_ENCODE"; + Mode[Mode["ANSIX12_ENCODE"] = 4] = "ANSIX12_ENCODE"; + Mode[Mode["EDIFACT_ENCODE"] = 5] = "EDIFACT_ENCODE"; + Mode[Mode["BASE256_ENCODE"] = 6] = "BASE256_ENCODE"; + })(Mode || (Mode = {})); + /** + * <p>Data Matrix Codes can encode text as bits in one of several modes, and can use multiple modes + * in one Data Matrix Code. This class decodes the bits back into text.</p> + * + * <p>See ISO 16022:2006, 5.2.1 - 5.2.9.2</p> + * + * @author bbrown@google.com (Brian Brown) + * @author Sean Owen + */ + class DecodedBitStreamParser { + static decode(bytes) { + const bits = new BitSource(bytes); + const result = new StringBuilder(); + const resultTrailer = new StringBuilder(); + const byteSegments = new Array(); + let mode = Mode.ASCII_ENCODE; + do { + if (mode === Mode.ASCII_ENCODE) { + mode = this.decodeAsciiSegment(bits, result, resultTrailer); + } + else { + switch (mode) { + case Mode.C40_ENCODE: + this.decodeC40Segment(bits, result); + break; + case Mode.TEXT_ENCODE: + this.decodeTextSegment(bits, result); + break; + case Mode.ANSIX12_ENCODE: + this.decodeAnsiX12Segment(bits, result); + break; + case Mode.EDIFACT_ENCODE: + this.decodeEdifactSegment(bits, result); + break; + case Mode.BASE256_ENCODE: + this.decodeBase256Segment(bits, result, byteSegments); + break; + default: + throw new FormatException(); + } + mode = Mode.ASCII_ENCODE; + } + } while (mode !== Mode.PAD_ENCODE && bits.available() > 0); + if (resultTrailer.length() > 0) { + result.append(resultTrailer.toString()); + } + return new DecoderResult(bytes, result.toString(), byteSegments.length === 0 ? null : byteSegments, null); + } + /** + * See ISO 16022:2006, 5.2.3 and Annex C, Table C.2 + */ + static decodeAsciiSegment(bits, result, resultTrailer) { + let upperShift = false; + do { + let oneByte = bits.readBits(8); + if (oneByte === 0) { + throw new FormatException(); + } + else if (oneByte <= 128) { // ASCII data (ASCII value + 1) + if (upperShift) { + oneByte += 128; + // upperShift = false; + } + result.append(String.fromCharCode(oneByte - 1)); + return Mode.ASCII_ENCODE; + } + else if (oneByte === 129) { // Pad + return Mode.PAD_ENCODE; + } + else if (oneByte <= 229) { // 2-digit data 00-99 (Numeric Value + 130) + const value = oneByte - 130; + if (value < 10) { // pad with '0' for single digit values + result.append('0'); + } + result.append('' + value); + } + else { + switch (oneByte) { + case 230: // Latch to C40 encodation + return Mode.C40_ENCODE; + case 231: // Latch to Base 256 encodation + return Mode.BASE256_ENCODE; + case 232: // FNC1 + result.append(String.fromCharCode(29)); // translate as ASCII 29 + break; + case 233: // Structured Append + case 234: // Reader Programming + // Ignore these symbols for now + // throw ReaderException.getInstance(); + break; + case 235: // Upper Shift (shift to Extended ASCII) + upperShift = true; + break; + case 236: // 05 Macro + result.append('[)>\u001E05\u001D'); + resultTrailer.insert(0, '\u001E\u0004'); + break; + case 237: // 06 Macro + result.append('[)>\u001E06\u001D'); + resultTrailer.insert(0, '\u001E\u0004'); + break; + case 238: // Latch to ANSI X12 encodation + return Mode.ANSIX12_ENCODE; + case 239: // Latch to Text encodation + return Mode.TEXT_ENCODE; + case 240: // Latch to EDIFACT encodation + return Mode.EDIFACT_ENCODE; + case 241: // ECI Character + // TODO(bbrown): I think we need to support ECI + // throw ReaderException.getInstance(); + // Ignore this symbol for now + break; + default: + // Not to be used in ASCII encodation + // but work around encoders that end with 254, latch back to ASCII + if (oneByte !== 254 || bits.available() !== 0) { + throw new FormatException(); + } + break; + } + } + } while (bits.available() > 0); + return Mode.ASCII_ENCODE; + } + /** + * See ISO 16022:2006, 5.2.5 and Annex C, Table C.1 + */ + static decodeC40Segment(bits, result) { + // Three C40 values are encoded in a 16-bit value as + // (1600 * C1) + (40 * C2) + C3 + 1 + // TODO(bbrown): The Upper Shift with C40 doesn't work in the 4 value scenario all the time + let upperShift = false; + const cValues = []; + let shift = 0; + do { + // If there is only one byte left then it will be encoded as ASCII + if (bits.available() === 8) { + return; + } + const firstByte = bits.readBits(8); + if (firstByte === 254) { // Unlatch codeword + return; + } + this.parseTwoBytes(firstByte, bits.readBits(8), cValues); + for (let i = 0; i < 3; i++) { + const cValue = cValues[i]; + switch (shift) { + case 0: + if (cValue < 3) { + shift = cValue + 1; + } + else if (cValue < this.C40_BASIC_SET_CHARS.length) { + const c40char = this.C40_BASIC_SET_CHARS[cValue]; + if (upperShift) { + result.append(String.fromCharCode(c40char.charCodeAt(0) + 128)); + upperShift = false; + } + else { + result.append(c40char); + } + } + else { + throw new FormatException(); + } + break; + case 1: + if (upperShift) { + result.append(String.fromCharCode(cValue + 128)); + upperShift = false; + } + else { + result.append(String.fromCharCode(cValue)); + } + shift = 0; + break; + case 2: + if (cValue < this.C40_SHIFT2_SET_CHARS.length) { + const c40char = this.C40_SHIFT2_SET_CHARS[cValue]; + if (upperShift) { + result.append(String.fromCharCode(c40char.charCodeAt(0) + 128)); + upperShift = false; + } + else { + result.append(c40char); + } + } + else { + switch (cValue) { + case 27: // FNC1 + result.append(String.fromCharCode(29)); // translate as ASCII 29 + break; + case 30: // Upper Shift + upperShift = true; + break; + default: + throw new FormatException(); + } + } + shift = 0; + break; + case 3: + if (upperShift) { + result.append(String.fromCharCode(cValue + 224)); + upperShift = false; + } + else { + result.append(String.fromCharCode(cValue + 96)); + } + shift = 0; + break; + default: + throw new FormatException(); + } + } + } while (bits.available() > 0); + } + /** + * See ISO 16022:2006, 5.2.6 and Annex C, Table C.2 + */ + static decodeTextSegment(bits, result) { + // Three Text values are encoded in a 16-bit value as + // (1600 * C1) + (40 * C2) + C3 + 1 + // TODO(bbrown): The Upper Shift with Text doesn't work in the 4 value scenario all the time + let upperShift = false; + let cValues = []; + let shift = 0; + do { + // If there is only one byte left then it will be encoded as ASCII + if (bits.available() === 8) { + return; + } + const firstByte = bits.readBits(8); + if (firstByte === 254) { // Unlatch codeword + return; + } + this.parseTwoBytes(firstByte, bits.readBits(8), cValues); + for (let i = 0; i < 3; i++) { + const cValue = cValues[i]; + switch (shift) { + case 0: + if (cValue < 3) { + shift = cValue + 1; + } + else if (cValue < this.TEXT_BASIC_SET_CHARS.length) { + const textChar = this.TEXT_BASIC_SET_CHARS[cValue]; + if (upperShift) { + result.append(String.fromCharCode(textChar.charCodeAt(0) + 128)); + upperShift = false; + } + else { + result.append(textChar); + } + } + else { + throw new FormatException(); + } + break; + case 1: + if (upperShift) { + result.append(String.fromCharCode(cValue + 128)); + upperShift = false; + } + else { + result.append(String.fromCharCode(cValue)); + } + shift = 0; + break; + case 2: + // Shift 2 for Text is the same encoding as C40 + if (cValue < this.TEXT_SHIFT2_SET_CHARS.length) { + const textChar = this.TEXT_SHIFT2_SET_CHARS[cValue]; + if (upperShift) { + result.append(String.fromCharCode(textChar.charCodeAt(0) + 128)); + upperShift = false; + } + else { + result.append(textChar); + } + } + else { + switch (cValue) { + case 27: // FNC1 + result.append(String.fromCharCode(29)); // translate as ASCII 29 + break; + case 30: // Upper Shift + upperShift = true; + break; + default: + throw new FormatException(); + } + } + shift = 0; + break; + case 3: + if (cValue < this.TEXT_SHIFT3_SET_CHARS.length) { + const textChar = this.TEXT_SHIFT3_SET_CHARS[cValue]; + if (upperShift) { + result.append(String.fromCharCode(textChar.charCodeAt(0) + 128)); + upperShift = false; + } + else { + result.append(textChar); + } + shift = 0; + } + else { + throw new FormatException(); + } + break; + default: + throw new FormatException(); + } + } + } while (bits.available() > 0); + } + /** + * See ISO 16022:2006, 5.2.7 + */ + static decodeAnsiX12Segment(bits, result) { + // Three ANSI X12 values are encoded in a 16-bit value as + // (1600 * C1) + (40 * C2) + C3 + 1 + const cValues = []; + do { + // If there is only one byte left then it will be encoded as ASCII + if (bits.available() === 8) { + return; + } + const firstByte = bits.readBits(8); + if (firstByte === 254) { // Unlatch codeword + return; + } + this.parseTwoBytes(firstByte, bits.readBits(8), cValues); + for (let i = 0; i < 3; i++) { + const cValue = cValues[i]; + switch (cValue) { + case 0: // X12 segment terminator <CR> + result.append('\r'); + break; + case 1: // X12 segment separator * + result.append('*'); + break; + case 2: // X12 sub-element separator > + result.append('>'); + break; + case 3: // space + result.append(' '); + break; + default: + if (cValue < 14) { // 0 - 9 + result.append(String.fromCharCode(cValue + 44)); + } + else if (cValue < 40) { // A - Z + result.append(String.fromCharCode(cValue + 51)); + } + else { + throw new FormatException(); + } + break; + } + } + } while (bits.available() > 0); + } + static parseTwoBytes(firstByte, secondByte, result) { + let fullBitValue = (firstByte << 8) + secondByte - 1; + let temp = Math.floor(fullBitValue / 1600); + result[0] = temp; + fullBitValue -= temp * 1600; + temp = Math.floor(fullBitValue / 40); + result[1] = temp; + result[2] = fullBitValue - temp * 40; + } + /** + * See ISO 16022:2006, 5.2.8 and Annex C Table C.3 + */ + static decodeEdifactSegment(bits, result) { + do { + // If there is only two or less bytes left then it will be encoded as ASCII + if (bits.available() <= 16) { + return; + } + for (let i = 0; i < 4; i++) { + let edifactValue = bits.readBits(6); + // Check for the unlatch character + if (edifactValue === 0x1F) { // 011111 + // Read rest of byte, which should be 0, and stop + const bitsLeft = 8 - bits.getBitOffset(); + if (bitsLeft !== 8) { + bits.readBits(bitsLeft); + } + return; + } + if ((edifactValue & 0x20) === 0) { // no 1 in the leading (6th) bit + edifactValue |= 0x40; // Add a leading 01 to the 6 bit binary value + } + result.append(String.fromCharCode(edifactValue)); + } + } while (bits.available() > 0); + } + /** + * See ISO 16022:2006, 5.2.9 and Annex B, B.2 + */ + static decodeBase256Segment(bits, result, byteSegments) { + // Figure out how long the Base 256 Segment is. + let codewordPosition = 1 + bits.getByteOffset(); // position is 1-indexed + const d1 = this.unrandomize255State(bits.readBits(8), codewordPosition++); + let count; + if (d1 === 0) { // Read the remainder of the symbol + count = bits.available() / 8 | 0; + } + else if (d1 < 250) { + count = d1; + } + else { + count = 250 * (d1 - 249) + this.unrandomize255State(bits.readBits(8), codewordPosition++); + } + // We're seeing NegativeArraySizeException errors from users. + if (count < 0) { + throw new FormatException(); + } + const bytes = new Uint8Array(count); + for (let i = 0; i < count; i++) { + // Have seen this particular error in the wild, such as at + // http://www.bcgen.com/demo/IDAutomationStreamingDataMatrix.aspx?MODE=3&D=Fred&PFMT=3&PT=F&X=0.3&O=0&LM=0.2 + if (bits.available() < 8) { + throw new FormatException(); + } + bytes[i] = this.unrandomize255State(bits.readBits(8), codewordPosition++); + } + byteSegments.push(bytes); + try { + result.append(StringEncoding.decode(bytes, StringUtils.ISO88591)); + } + catch (uee) { + throw new IllegalStateException('Platform does not support required encoding: ' + uee.message); + } + } + /** + * See ISO 16022:2006, Annex B, B.2 + */ + static unrandomize255State(randomizedBase256Codeword, base256CodewordPosition) { + const pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1; + const tempVariable = randomizedBase256Codeword - pseudoRandomNumber; + return tempVariable >= 0 ? tempVariable : tempVariable + 256; + } + } + /** + * See ISO 16022:2006, Annex C Table C.1 + * The C40 Basic Character Set (*'s used for placeholders for the shift values) + */ + DecodedBitStreamParser.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' + ]; + DecodedBitStreamParser.C40_SHIFT2_SET_CHARS = [ + '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', + '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_' + ]; + /** + * See ISO 16022:2006, Annex C Table C.2 + * The Text Basic Character Set (*'s used for placeholders for the shift values) + */ + DecodedBitStreamParser.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' + ]; + // Shift 2 for Text is the same encoding as C40 + DecodedBitStreamParser.TEXT_SHIFT2_SET_CHARS = DecodedBitStreamParser.C40_SHIFT2_SET_CHARS; + DecodedBitStreamParser.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', '{', '|', '}', '~', String.fromCharCode(127) + ]; + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>The main class which implements Data Matrix Code decoding -- as opposed to locating and extracting + * the Data Matrix Code from an image.</p> + * + * @author bbrown@google.com (Brian Brown) + */ + class Decoder$1 { + constructor() { + this.rsDecoder = new ReedSolomonDecoder(GenericGF.DATA_MATRIX_FIELD_256); + } + /** + * <p>Decodes a Data Matrix Code represented as a {@link BitMatrix}. A 1 or "true" is taken + * to mean a black module.</p> + * + * @param bits booleans representing white/black Data Matrix Code modules + * @return text and bytes encoded within the Data Matrix Code + * @throws FormatException if the Data Matrix Code cannot be decoded + * @throws ChecksumException if error correction fails + */ + decode(bits) { + // Construct a parser and read version, error-correction level + const parser = new BitMatrixParser(bits); + const version = parser.getVersion(); + // Read codewords + const codewords = parser.readCodewords(); + // Separate into data blocks + const dataBlocks = DataBlock.getDataBlocks(codewords, version); + // Count total number of data bytes + let totalBytes = 0; + for (let db of dataBlocks) { + totalBytes += db.getNumDataCodewords(); + } + const resultBytes = new Uint8Array(totalBytes); + const dataBlocksCount = dataBlocks.length; + // Error-correct and copy data blocks together into a stream of bytes + for (let j = 0; j < dataBlocksCount; j++) { + const dataBlock = dataBlocks[j]; + const codewordBytes = dataBlock.getCodewords(); + const numDataCodewords = dataBlock.getNumDataCodewords(); + this.correctErrors(codewordBytes, numDataCodewords); + for (let i = 0; i < numDataCodewords; i++) { + // De-interlace data blocks. + resultBytes[i * dataBlocksCount + j] = codewordBytes[i]; + } + } + // Decode the contents of that stream of bytes + return DecodedBitStreamParser.decode(resultBytes); + } + /** + * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to + * correct the errors in-place using Reed-Solomon error correction.</p> + * + * @param codewordBytes data and error correction codewords + * @param numDataCodewords number of codewords that are data bytes + * @throws ChecksumException if error correction fails + */ + correctErrors(codewordBytes, numDataCodewords) { + // const numCodewords = codewordBytes.length; + // First read into an array of ints + const codewordsInts = new Int32Array(codewordBytes); + // for (let i = 0; i < numCodewords; i++) { + // codewordsInts[i] = codewordBytes[i] & 0xFF; + // } + try { + this.rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords); + } + catch (ignored /* ReedSolomonException */) { + throw new ChecksumException(); + } + // Copy back into array of bytes -- only need to worry about the bytes that were data + // We don't care about errors in the error-correction codewords + for (let i = 0; i < numDataCodewords; i++) { + codewordBytes[i] = codewordsInts[i]; + } + } + } + + /** + * <p>Encapsulates logic that can detect a Data Matrix Code in an image, even if the Data Matrix Code + * is rotated or skewed, or partially obscured.</p> + * + * @author Sean Owen + */ + class Detector$1 { + constructor(image) { + this.image = image; + this.rectangleDetector = new WhiteRectangleDetector(this.image); + } + /** + * <p>Detects a Data Matrix Code in an image.</p> + * + * @return {@link DetectorResult} encapsulating results of detecting a Data Matrix Code + * @throws NotFoundException if no Data Matrix Code can be found + */ + detect() { + const cornerPoints = this.rectangleDetector.detect(); + let points = this.detectSolid1(cornerPoints); + points = this.detectSolid2(points); + points[3] = this.correctTopRight(points); + if (!points[3]) { + throw new NotFoundException(); + } + points = this.shiftToModuleCenter(points); + const topLeft = points[0]; + const bottomLeft = points[1]; + const bottomRight = points[2]; + const topRight = points[3]; + let dimensionTop = this.transitionsBetween(topLeft, topRight) + 1; + let dimensionRight = this.transitionsBetween(bottomRight, topRight) + 1; + if ((dimensionTop & 0x01) === 1) { + dimensionTop += 1; + } + if ((dimensionRight & 0x01) === 1) { + dimensionRight += 1; + } + if (4 * dimensionTop < 7 * dimensionRight && 4 * dimensionRight < 7 * dimensionTop) { + // The matrix is square + dimensionTop = dimensionRight = Math.max(dimensionTop, dimensionRight); + } + let bits = Detector$1.sampleGrid(this.image, topLeft, bottomLeft, bottomRight, topRight, dimensionTop, dimensionRight); + return new DetectorResult(bits, [topLeft, bottomLeft, bottomRight, topRight]); + } + static shiftPoint(point, to, div) { + let x = (to.getX() - point.getX()) / (div + 1); + let y = (to.getY() - point.getY()) / (div + 1); + return new ResultPoint(point.getX() + x, point.getY() + y); + } + static moveAway(point, fromX, fromY) { + let x = point.getX(); + let y = point.getY(); + if (x < fromX) { + x -= 1; + } + else { + x += 1; + } + if (y < fromY) { + y -= 1; + } + else { + y += 1; + } + return new ResultPoint(x, y); + } + /** + * Detect a solid side which has minimum transition. + */ + detectSolid1(cornerPoints) { + // 0 2 + // 1 3 + let pointA = cornerPoints[0]; + let pointB = cornerPoints[1]; + let pointC = cornerPoints[3]; + let pointD = cornerPoints[2]; + let trAB = this.transitionsBetween(pointA, pointB); + let trBC = this.transitionsBetween(pointB, pointC); + let trCD = this.transitionsBetween(pointC, pointD); + let trDA = this.transitionsBetween(pointD, pointA); + // 0..3 + // : : + // 1--2 + let min = trAB; + let points = [pointD, pointA, pointB, pointC]; + if (min > trBC) { + min = trBC; + points[0] = pointA; + points[1] = pointB; + points[2] = pointC; + points[3] = pointD; + } + if (min > trCD) { + min = trCD; + points[0] = pointB; + points[1] = pointC; + points[2] = pointD; + points[3] = pointA; + } + if (min > trDA) { + points[0] = pointC; + points[1] = pointD; + points[2] = pointA; + points[3] = pointB; + } + return points; + } + /** + * Detect a second solid side next to first solid side. + */ + detectSolid2(points) { + // A..D + // : : + // B--C + let pointA = points[0]; + let pointB = points[1]; + let pointC = points[2]; + let pointD = points[3]; + // Transition detection on the edge is not stable. + // To safely detect, shift the points to the module center. + let tr = this.transitionsBetween(pointA, pointD); + let pointBs = Detector$1.shiftPoint(pointB, pointC, (tr + 1) * 4); + let pointCs = Detector$1.shiftPoint(pointC, pointB, (tr + 1) * 4); + let trBA = this.transitionsBetween(pointBs, pointA); + let trCD = this.transitionsBetween(pointCs, pointD); + // 0..3 + // | : + // 1--2 + if (trBA < trCD) { + // solid sides: A-B-C + points[0] = pointA; + points[1] = pointB; + points[2] = pointC; + points[3] = pointD; + } + else { + // solid sides: B-C-D + points[0] = pointB; + points[1] = pointC; + points[2] = pointD; + points[3] = pointA; + } + return points; + } + /** + * Calculates the corner position of the white top right module. + */ + correctTopRight(points) { + // A..D + // | : + // B--C + let pointA = points[0]; + let pointB = points[1]; + let pointC = points[2]; + let pointD = points[3]; + // shift points for safe transition detection. + let trTop = this.transitionsBetween(pointA, pointD); + let trRight = this.transitionsBetween(pointB, pointD); + let pointAs = Detector$1.shiftPoint(pointA, pointB, (trRight + 1) * 4); + let pointCs = Detector$1.shiftPoint(pointC, pointB, (trTop + 1) * 4); + trTop = this.transitionsBetween(pointAs, pointD); + trRight = this.transitionsBetween(pointCs, pointD); + let candidate1 = new ResultPoint(pointD.getX() + (pointC.getX() - pointB.getX()) / (trTop + 1), pointD.getY() + (pointC.getY() - pointB.getY()) / (trTop + 1)); + let candidate2 = new ResultPoint(pointD.getX() + (pointA.getX() - pointB.getX()) / (trRight + 1), pointD.getY() + (pointA.getY() - pointB.getY()) / (trRight + 1)); + if (!this.isValid(candidate1)) { + if (this.isValid(candidate2)) { + return candidate2; + } + return null; + } + if (!this.isValid(candidate2)) { + return candidate1; + } + let sumc1 = this.transitionsBetween(pointAs, candidate1) + this.transitionsBetween(pointCs, candidate1); + let sumc2 = this.transitionsBetween(pointAs, candidate2) + this.transitionsBetween(pointCs, candidate2); + if (sumc1 > sumc2) { + return candidate1; + } + else { + return candidate2; + } + } + /** + * Shift the edge points to the module center. + */ + shiftToModuleCenter(points) { + // A..D + // | : + // B--C + let pointA = points[0]; + let pointB = points[1]; + let pointC = points[2]; + let pointD = points[3]; + // calculate pseudo dimensions + let dimH = this.transitionsBetween(pointA, pointD) + 1; + let dimV = this.transitionsBetween(pointC, pointD) + 1; + // shift points for safe dimension detection + let pointAs = Detector$1.shiftPoint(pointA, pointB, dimV * 4); + let pointCs = Detector$1.shiftPoint(pointC, pointB, dimH * 4); + // calculate more precise dimensions + dimH = this.transitionsBetween(pointAs, pointD) + 1; + dimV = this.transitionsBetween(pointCs, pointD) + 1; + if ((dimH & 0x01) === 1) { + dimH += 1; + } + if ((dimV & 0x01) === 1) { + dimV += 1; + } + // WhiteRectangleDetector returns points inside of the rectangle. + // I want points on the edges. + let centerX = (pointA.getX() + pointB.getX() + pointC.getX() + pointD.getX()) / 4; + let centerY = (pointA.getY() + pointB.getY() + pointC.getY() + pointD.getY()) / 4; + pointA = Detector$1.moveAway(pointA, centerX, centerY); + pointB = Detector$1.moveAway(pointB, centerX, centerY); + pointC = Detector$1.moveAway(pointC, centerX, centerY); + pointD = Detector$1.moveAway(pointD, centerX, centerY); + let pointBs; + let pointDs; + // shift points to the center of each modules + pointAs = Detector$1.shiftPoint(pointA, pointB, dimV * 4); + pointAs = Detector$1.shiftPoint(pointAs, pointD, dimH * 4); + pointBs = Detector$1.shiftPoint(pointB, pointA, dimV * 4); + pointBs = Detector$1.shiftPoint(pointBs, pointC, dimH * 4); + pointCs = Detector$1.shiftPoint(pointC, pointD, dimV * 4); + pointCs = Detector$1.shiftPoint(pointCs, pointB, dimH * 4); + pointDs = Detector$1.shiftPoint(pointD, pointC, dimV * 4); + pointDs = Detector$1.shiftPoint(pointDs, pointA, dimH * 4); + return [pointAs, pointBs, pointCs, pointDs]; + } + isValid(p) { + return p.getX() >= 0 && p.getX() < this.image.getWidth() && p.getY() > 0 && p.getY() < this.image.getHeight(); + } + static sampleGrid(image, topLeft, bottomLeft, bottomRight, topRight, dimensionX, dimensionY) { + const sampler = GridSamplerInstance.getInstance(); + return sampler.sampleGrid(image, dimensionX, dimensionY, 0.5, 0.5, dimensionX - 0.5, 0.5, dimensionX - 0.5, dimensionY - 0.5, 0.5, dimensionY - 0.5, topLeft.getX(), topLeft.getY(), topRight.getX(), topRight.getY(), bottomRight.getX(), bottomRight.getY(), bottomLeft.getX(), bottomLeft.getY()); + } + /** + * Counts the number of black/white transitions between two points, using something like Bresenham's algorithm. + */ + transitionsBetween(from, to) { + // See QR Code Detector, sizeOfBlackWhiteBlackRun() + let fromX = Math.trunc(from.getX()); + let fromY = Math.trunc(from.getY()); + let toX = Math.trunc(to.getX()); + let toY = Math.trunc(to.getY()); + let steep = Math.abs(toY - fromY) > Math.abs(toX - fromX); + if (steep) { + let temp = fromX; + fromX = fromY; + fromY = temp; + temp = toX; + toX = toY; + toY = temp; + } + let dx = Math.abs(toX - fromX); + let dy = Math.abs(toY - fromY); + let error = -dx / 2; + let ystep = fromY < toY ? 1 : -1; + let xstep = fromX < toX ? 1 : -1; + let transitions = 0; + let inBlack = this.image.get(steep ? fromY : fromX, steep ? fromX : fromY); + for (let x = fromX, y = fromY; x !== toX; x += xstep) { + let isBlack = this.image.get(steep ? y : x, steep ? x : y); + if (isBlack !== inBlack) { + transitions++; + inBlack = isBlack; + } + error += dy; + if (error > 0) { + if (y === toY) { + break; + } + y += ystep; + error -= dx; + } + } + return transitions; + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * This implementation can detect and decode Data Matrix codes in an image. + * + * @author bbrown@google.com (Brian Brown) + */ + class DataMatrixReader { + constructor() { + this.decoder = new Decoder$1(); + } + /** + * Locates and decodes a Data Matrix code in an image. + * + * @return a String representing the content encoded by the Data Matrix code + * @throws NotFoundException if a Data Matrix code cannot be found + * @throws FormatException if a Data Matrix code cannot be decoded + * @throws ChecksumException if error correction fails + */ + // @Override + // public Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException { + // return decode(image, null); + // } + // @Override + decode(image, hints = null) { + let decoderResult; + let points; + if (hints != null && hints.has(DecodeHintType$1.PURE_BARCODE)) { + const bits = DataMatrixReader.extractPureBits(image.getBlackMatrix()); + decoderResult = this.decoder.decode(bits); + points = DataMatrixReader.NO_POINTS; + } + else { + const detectorResult = new Detector$1(image.getBlackMatrix()).detect(); + decoderResult = this.decoder.decode(detectorResult.getBits()); + points = detectorResult.getPoints(); + } + const rawBytes = decoderResult.getRawBytes(); + const result = new Result(decoderResult.getText(), rawBytes, 8 * rawBytes.length, points, BarcodeFormat$1.DATA_MATRIX, System.currentTimeMillis()); + const byteSegments = decoderResult.getByteSegments(); + if (byteSegments != null) { + result.putMetadata(ResultMetadataType$1.BYTE_SEGMENTS, byteSegments); + } + const ecLevel = decoderResult.getECLevel(); + if (ecLevel != null) { + result.putMetadata(ResultMetadataType$1.ERROR_CORRECTION_LEVEL, ecLevel); + } + return result; + } + // @Override + reset() { + // do nothing + } + /** + * This method detects a code in a "pure" image -- that is, pure monochrome image + * which contains only an unrotated, unskewed, image of a code, with some white border + * around it. This is a specialized method that works exceptionally fast in this special + * case. + * + * @see com.google.zxing.qrcode.QRCodeReader#extractPureBits(BitMatrix) + */ + static extractPureBits(image) { + const leftTopBlack = image.getTopLeftOnBit(); + const rightBottomBlack = image.getBottomRightOnBit(); + if (leftTopBlack == null || rightBottomBlack == null) { + throw new NotFoundException(); + } + const moduleSize = this.moduleSize(leftTopBlack, image); + let top = leftTopBlack[1]; + const bottom = rightBottomBlack[1]; + let left = leftTopBlack[0]; + const right = rightBottomBlack[0]; + const matrixWidth = (right - left + 1) / moduleSize; + const matrixHeight = (bottom - top + 1) / moduleSize; + if (matrixWidth <= 0 || matrixHeight <= 0) { + throw new NotFoundException(); + } + // Push in the "border" by half the module width so that we start + // sampling in the middle of the module. Just in case the image is a + // little off, this will help recover. + const nudge = moduleSize / 2; + top += nudge; + left += nudge; + // Now just read off the bits + const bits = new BitMatrix(matrixWidth, matrixHeight); + for (let y = 0; y < matrixHeight; y++) { + const iOffset = top + y * moduleSize; + for (let x = 0; x < matrixWidth; x++) { + if (image.get(left + x * moduleSize, iOffset)) { + bits.set(x, y); + } + } + } + return bits; + } + static moduleSize(leftTopBlack, image) { + const width = image.getWidth(); + let x = leftTopBlack[0]; + const y = leftTopBlack[1]; + while (x < width && image.get(x, y)) { + x++; + } + if (x === width) { + throw new NotFoundException(); + } + const moduleSize = x - leftTopBlack[0]; + if (moduleSize === 0) { + throw new NotFoundException(); + } + return moduleSize; + } + } + DataMatrixReader.NO_POINTS = []; + + /** + * @deprecated Moving to @zxing/browser + * + * QR Code reader to use from browser. + */ + class BrowserDatamatrixCodeReader extends BrowserCodeReader { + /** + * Creates an instance of BrowserQRCodeReader. + * @param {number} [timeBetweenScansMillis=500] the time delay between subsequent decode tries + */ + constructor(timeBetweenScansMillis = 500) { + super(new DataMatrixReader(), timeBetweenScansMillis); + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + var ErrorCorrectionLevelValues; + (function (ErrorCorrectionLevelValues) { + ErrorCorrectionLevelValues[ErrorCorrectionLevelValues["L"] = 0] = "L"; + ErrorCorrectionLevelValues[ErrorCorrectionLevelValues["M"] = 1] = "M"; + ErrorCorrectionLevelValues[ErrorCorrectionLevelValues["Q"] = 2] = "Q"; + ErrorCorrectionLevelValues[ErrorCorrectionLevelValues["H"] = 3] = "H"; + })(ErrorCorrectionLevelValues || (ErrorCorrectionLevelValues = {})); + /** + * <p>See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels + * defined by the QR code standard.</p> + * + * @author Sean Owen + */ + class ErrorCorrectionLevel { + constructor(value, stringValue, bits /*int*/) { + this.value = value; + this.stringValue = stringValue; + this.bits = bits; + ErrorCorrectionLevel.FOR_BITS.set(bits, this); + ErrorCorrectionLevel.FOR_VALUE.set(value, this); + } + getValue() { + return this.value; + } + getBits() { + return this.bits; + } + static fromString(s) { + switch (s) { + case 'L': return ErrorCorrectionLevel.L; + case 'M': return ErrorCorrectionLevel.M; + case 'Q': return ErrorCorrectionLevel.Q; + case 'H': return ErrorCorrectionLevel.H; + default: throw new ArgumentException(s + 'not available'); + } + } + toString() { + return this.stringValue; + } + equals(o) { + if (!(o instanceof ErrorCorrectionLevel)) { + return false; + } + const other = o; + return this.value === other.value; + } + /** + * @param bits int containing the two bits encoding a QR Code's error correction level + * @return ErrorCorrectionLevel representing the encoded error correction level + */ + static forBits(bits /*int*/) { + if (bits < 0 || bits >= ErrorCorrectionLevel.FOR_BITS.size) { + throw new IllegalArgumentException(); + } + return ErrorCorrectionLevel.FOR_BITS.get(bits); + } + } + ErrorCorrectionLevel.FOR_BITS = new Map(); + ErrorCorrectionLevel.FOR_VALUE = new Map(); + /** L = ~7% correction */ + ErrorCorrectionLevel.L = new ErrorCorrectionLevel(ErrorCorrectionLevelValues.L, 'L', 0x01); + /** M = ~15% correction */ + ErrorCorrectionLevel.M = new ErrorCorrectionLevel(ErrorCorrectionLevelValues.M, 'M', 0x00); + /** Q = ~25% correction */ + ErrorCorrectionLevel.Q = new ErrorCorrectionLevel(ErrorCorrectionLevelValues.Q, 'Q', 0x03); + /** H = ~30% correction */ + ErrorCorrectionLevel.H = new ErrorCorrectionLevel(ErrorCorrectionLevelValues.H, 'H', 0x02); + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Encapsulates a QR Code's format information, including the data mask used and + * error correction level.</p> + * + * @author Sean Owen + * @see DataMask + * @see ErrorCorrectionLevel + */ + class FormatInformation { + constructor(formatInfo /*int*/) { + // Bits 3,4 + this.errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03); + // Bottom 3 bits + this.dataMask = /*(byte) */ (formatInfo & 0x07); + } + static numBitsDiffering(a /*int*/, b /*int*/) { + return Integer.bitCount(a ^ b); + } + /** + * @param maskedFormatInfo1 format info indicator, with mask still applied + * @param maskedFormatInfo2 second copy of same info; both are checked at the same time + * to establish best match + * @return information about the format it specifies, or {@code null} + * if doesn't seem to match any known pattern + */ + static decodeFormatInformation(maskedFormatInfo1 /*int*/, maskedFormatInfo2 /*int*/) { + const formatInfo = FormatInformation.doDecodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2); + if (formatInfo !== null) { + return formatInfo; + } + // Should return null, but, some QR codes apparently + // do not mask this info. Try again by actually masking the pattern + // first + return FormatInformation.doDecodeFormatInformation(maskedFormatInfo1 ^ FormatInformation.FORMAT_INFO_MASK_QR, maskedFormatInfo2 ^ FormatInformation.FORMAT_INFO_MASK_QR); + } + static doDecodeFormatInformation(maskedFormatInfo1 /*int*/, maskedFormatInfo2 /*int*/) { + // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing + let bestDifference = Number.MAX_SAFE_INTEGER; + let bestFormatInfo = 0; + for (const decodeInfo of FormatInformation.FORMAT_INFO_DECODE_LOOKUP) { + const targetInfo = decodeInfo[0]; + if (targetInfo === maskedFormatInfo1 || targetInfo === maskedFormatInfo2) { + // Found an exact match + return new FormatInformation(decodeInfo[1]); + } + let bitsDifference = FormatInformation.numBitsDiffering(maskedFormatInfo1, targetInfo); + if (bitsDifference < bestDifference) { + bestFormatInfo = decodeInfo[1]; + bestDifference = bitsDifference; + } + if (maskedFormatInfo1 !== maskedFormatInfo2) { + // also try the other option + bitsDifference = FormatInformation.numBitsDiffering(maskedFormatInfo2, targetInfo); + if (bitsDifference < bestDifference) { + bestFormatInfo = decodeInfo[1]; + bestDifference = bitsDifference; + } + } + } + // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits + // differing means we found a match + if (bestDifference <= 3) { + return new FormatInformation(bestFormatInfo); + } + return null; + } + getErrorCorrectionLevel() { + return this.errorCorrectionLevel; + } + getDataMask() { + return this.dataMask; + } + /*@Override*/ + hashCode() { + return (this.errorCorrectionLevel.getBits() << 3) | this.dataMask; + } + /*@Override*/ + equals(o) { + if (!(o instanceof FormatInformation)) { + return false; + } + const other = o; + return this.errorCorrectionLevel === other.errorCorrectionLevel && + this.dataMask === other.dataMask; + } + } + FormatInformation.FORMAT_INFO_MASK_QR = 0x5412; + /** + * See ISO 18004:2006, Annex C, Table C.1 + */ + FormatInformation.FORMAT_INFO_DECODE_LOOKUP = [ + Int32Array.from([0x5412, 0x00]), + Int32Array.from([0x5125, 0x01]), + Int32Array.from([0x5E7C, 0x02]), + Int32Array.from([0x5B4B, 0x03]), + Int32Array.from([0x45F9, 0x04]), + Int32Array.from([0x40CE, 0x05]), + Int32Array.from([0x4F97, 0x06]), + Int32Array.from([0x4AA0, 0x07]), + Int32Array.from([0x77C4, 0x08]), + Int32Array.from([0x72F3, 0x09]), + Int32Array.from([0x7DAA, 0x0A]), + Int32Array.from([0x789D, 0x0B]), + Int32Array.from([0x662F, 0x0C]), + Int32Array.from([0x6318, 0x0D]), + Int32Array.from([0x6C41, 0x0E]), + Int32Array.from([0x6976, 0x0F]), + Int32Array.from([0x1689, 0x10]), + Int32Array.from([0x13BE, 0x11]), + Int32Array.from([0x1CE7, 0x12]), + Int32Array.from([0x19D0, 0x13]), + Int32Array.from([0x0762, 0x14]), + Int32Array.from([0x0255, 0x15]), + Int32Array.from([0x0D0C, 0x16]), + Int32Array.from([0x083B, 0x17]), + Int32Array.from([0x355F, 0x18]), + Int32Array.from([0x3068, 0x19]), + Int32Array.from([0x3F31, 0x1A]), + Int32Array.from([0x3A06, 0x1B]), + Int32Array.from([0x24B4, 0x1C]), + Int32Array.from([0x2183, 0x1D]), + Int32Array.from([0x2EDA, 0x1E]), + Int32Array.from([0x2BED, 0x1F]), + ]; + + /** + * <p>Encapsulates a set of error-correction blocks in one symbol version. Most versions will + * use blocks of differing sizes within one version, so, this encapsulates the parameters for + * each set of blocks. It also holds the number of error-correction codewords per block since it + * will be the same across all blocks within one version.</p> + */ + class ECBlocks$1 { + constructor(ecCodewordsPerBlock /*int*/, ...ecBlocks) { + this.ecCodewordsPerBlock = ecCodewordsPerBlock; + this.ecBlocks = ecBlocks; + } + getECCodewordsPerBlock() { + return this.ecCodewordsPerBlock; + } + getNumBlocks() { + let total = 0; + const ecBlocks = this.ecBlocks; + for (const ecBlock of ecBlocks) { + total += ecBlock.getCount(); + } + return total; + } + getTotalECCodewords() { + return this.ecCodewordsPerBlock * this.getNumBlocks(); + } + getECBlocks() { + return this.ecBlocks; + } + } + + /** + * <p>Encapsulates the parameters for one error-correction block in one symbol version. + * This includes the number of data codewords, and the number of times a block with these + * parameters is used consecutively in the QR code version's format.</p> + */ + class ECB$1 { + constructor(count /*int*/, dataCodewords /*int*/) { + this.count = count; + this.dataCodewords = dataCodewords; + } + getCount() { + return this.count; + } + getDataCodewords() { + return this.dataCodewords; + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * See ISO 18004:2006 Annex D + * + * @author Sean Owen + */ + class Version$1 { + constructor(versionNumber /*int*/, alignmentPatternCenters, ...ecBlocks) { + this.versionNumber = versionNumber; + this.alignmentPatternCenters = alignmentPatternCenters; + this.ecBlocks = ecBlocks; + let total = 0; + const ecCodewords = ecBlocks[0].getECCodewordsPerBlock(); + const ecbArray = ecBlocks[0].getECBlocks(); + for (const ecBlock of ecbArray) { + total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords); + } + this.totalCodewords = total; + } + getVersionNumber() { + return this.versionNumber; + } + getAlignmentPatternCenters() { + return this.alignmentPatternCenters; + } + getTotalCodewords() { + return this.totalCodewords; + } + getDimensionForVersion() { + return 17 + 4 * this.versionNumber; + } + getECBlocksForLevel(ecLevel) { + return this.ecBlocks[ecLevel.getValue()]; + // TYPESCRIPTPORT: original was using ordinal, and using the order of levels as defined in ErrorCorrectionLevel enum (LMQH) + // I will use the direct value from ErrorCorrectionLevelValues enum which in typescript goes to a number + } + /** + * <p>Deduces version information purely from QR Code dimensions.</p> + * + * @param dimension dimension in modules + * @return Version for a QR Code of that dimension + * @throws FormatException if dimension is not 1 mod 4 + */ + static getProvisionalVersionForDimension(dimension /*int*/) { + if (dimension % 4 !== 1) { + throw new FormatException(); + } + try { + return this.getVersionForNumber((dimension - 17) / 4); + } + catch (ignored /*: IllegalArgumentException*/) { + throw new FormatException(); + } + } + static getVersionForNumber(versionNumber /*int*/) { + if (versionNumber < 1 || versionNumber > 40) { + throw new IllegalArgumentException(); + } + return Version$1.VERSIONS[versionNumber - 1]; + } + static decodeVersionInformation(versionBits /*int*/) { + let bestDifference = Number.MAX_SAFE_INTEGER; + let bestVersion = 0; + for (let i = 0; i < Version$1.VERSION_DECODE_INFO.length; i++) { + const targetVersion = Version$1.VERSION_DECODE_INFO[i]; + // Do the version info bits match exactly? done. + if (targetVersion === versionBits) { + return Version$1.getVersionForNumber(i + 7); + } + // Otherwise see if this is the closest to a real version info bit string + // we have seen so far + const bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion); + if (bitsDifference < bestDifference) { + bestVersion = i + 7; + bestDifference = bitsDifference; + } + } + // We can tolerate up to 3 bits of error since no two version info codewords will + // differ in less than 8 bits. + if (bestDifference <= 3) { + return Version$1.getVersionForNumber(bestVersion); + } + // If we didn't find a close enough match, fail + return null; + } + /** + * See ISO 18004:2006 Annex E + */ + buildFunctionPattern() { + const dimension = this.getDimensionForVersion(); + const bitMatrix = new BitMatrix(dimension); + // Top left finder pattern + separator + format + bitMatrix.setRegion(0, 0, 9, 9); + // Top right finder pattern + separator + format + bitMatrix.setRegion(dimension - 8, 0, 8, 9); + // Bottom left finder pattern + separator + format + bitMatrix.setRegion(0, dimension - 8, 9, 8); + // Alignment patterns + const max = this.alignmentPatternCenters.length; + for (let x = 0; x < max; x++) { + const i = this.alignmentPatternCenters[x] - 2; + for (let y = 0; y < max; y++) { + if ((x === 0 && (y === 0 || y === max - 1)) || (x === max - 1 && y === 0)) { + // No alignment patterns near the three finder patterns + continue; + } + bitMatrix.setRegion(this.alignmentPatternCenters[y] - 2, i, 5, 5); + } + } + // Vertical timing pattern + bitMatrix.setRegion(6, 9, 1, dimension - 17); + // Horizontal timing pattern + bitMatrix.setRegion(9, 6, dimension - 17, 1); + if (this.versionNumber > 6) { + // Version info, top right + bitMatrix.setRegion(dimension - 11, 0, 3, 6); + // Version info, bottom left + bitMatrix.setRegion(0, dimension - 11, 6, 3); + } + return bitMatrix; + } + /*@Override*/ + toString() { + return '' + this.versionNumber; + } + } + /** + * See ISO 18004:2006 Annex D. + * Element i represents the raw version bits that specify version i + 7 + */ + Version$1.VERSION_DECODE_INFO = Int32Array.from([ + 0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, + 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, + 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, + 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, + 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, + 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, + 0x2542E, 0x26A64, 0x27541, 0x28C69 + ]); + /** + * See ISO 18004:2006 6.5.1 Table 9 + */ + Version$1.VERSIONS = [ + new Version$1(1, new Int32Array(0), new ECBlocks$1(7, new ECB$1(1, 19)), new ECBlocks$1(10, new ECB$1(1, 16)), new ECBlocks$1(13, new ECB$1(1, 13)), new ECBlocks$1(17, new ECB$1(1, 9))), + new Version$1(2, Int32Array.from([6, 18]), new ECBlocks$1(10, new ECB$1(1, 34)), new ECBlocks$1(16, new ECB$1(1, 28)), new ECBlocks$1(22, new ECB$1(1, 22)), new ECBlocks$1(28, new ECB$1(1, 16))), + new Version$1(3, Int32Array.from([6, 22]), new ECBlocks$1(15, new ECB$1(1, 55)), new ECBlocks$1(26, new ECB$1(1, 44)), new ECBlocks$1(18, new ECB$1(2, 17)), new ECBlocks$1(22, new ECB$1(2, 13))), + new Version$1(4, Int32Array.from([6, 26]), new ECBlocks$1(20, new ECB$1(1, 80)), new ECBlocks$1(18, new ECB$1(2, 32)), new ECBlocks$1(26, new ECB$1(2, 24)), new ECBlocks$1(16, new ECB$1(4, 9))), + new Version$1(5, Int32Array.from([6, 30]), new ECBlocks$1(26, new ECB$1(1, 108)), new ECBlocks$1(24, new ECB$1(2, 43)), new ECBlocks$1(18, new ECB$1(2, 15), new ECB$1(2, 16)), new ECBlocks$1(22, new ECB$1(2, 11), new ECB$1(2, 12))), + new Version$1(6, Int32Array.from([6, 34]), new ECBlocks$1(18, new ECB$1(2, 68)), new ECBlocks$1(16, new ECB$1(4, 27)), new ECBlocks$1(24, new ECB$1(4, 19)), new ECBlocks$1(28, new ECB$1(4, 15))), + new Version$1(7, Int32Array.from([6, 22, 38]), new ECBlocks$1(20, new ECB$1(2, 78)), new ECBlocks$1(18, new ECB$1(4, 31)), new ECBlocks$1(18, new ECB$1(2, 14), new ECB$1(4, 15)), new ECBlocks$1(26, new ECB$1(4, 13), new ECB$1(1, 14))), + new Version$1(8, Int32Array.from([6, 24, 42]), new ECBlocks$1(24, new ECB$1(2, 97)), new ECBlocks$1(22, new ECB$1(2, 38), new ECB$1(2, 39)), new ECBlocks$1(22, new ECB$1(4, 18), new ECB$1(2, 19)), new ECBlocks$1(26, new ECB$1(4, 14), new ECB$1(2, 15))), + new Version$1(9, Int32Array.from([6, 26, 46]), new ECBlocks$1(30, new ECB$1(2, 116)), new ECBlocks$1(22, new ECB$1(3, 36), new ECB$1(2, 37)), new ECBlocks$1(20, new ECB$1(4, 16), new ECB$1(4, 17)), new ECBlocks$1(24, new ECB$1(4, 12), new ECB$1(4, 13))), + new Version$1(10, Int32Array.from([6, 28, 50]), new ECBlocks$1(18, new ECB$1(2, 68), new ECB$1(2, 69)), new ECBlocks$1(26, new ECB$1(4, 43), new ECB$1(1, 44)), new ECBlocks$1(24, new ECB$1(6, 19), new ECB$1(2, 20)), new ECBlocks$1(28, new ECB$1(6, 15), new ECB$1(2, 16))), + new Version$1(11, Int32Array.from([6, 30, 54]), new ECBlocks$1(20, new ECB$1(4, 81)), new ECBlocks$1(30, new ECB$1(1, 50), new ECB$1(4, 51)), new ECBlocks$1(28, new ECB$1(4, 22), new ECB$1(4, 23)), new ECBlocks$1(24, new ECB$1(3, 12), new ECB$1(8, 13))), + new Version$1(12, Int32Array.from([6, 32, 58]), new ECBlocks$1(24, new ECB$1(2, 92), new ECB$1(2, 93)), new ECBlocks$1(22, new ECB$1(6, 36), new ECB$1(2, 37)), new ECBlocks$1(26, new ECB$1(4, 20), new ECB$1(6, 21)), new ECBlocks$1(28, new ECB$1(7, 14), new ECB$1(4, 15))), + new Version$1(13, Int32Array.from([6, 34, 62]), new ECBlocks$1(26, new ECB$1(4, 107)), new ECBlocks$1(22, new ECB$1(8, 37), new ECB$1(1, 38)), new ECBlocks$1(24, new ECB$1(8, 20), new ECB$1(4, 21)), new ECBlocks$1(22, new ECB$1(12, 11), new ECB$1(4, 12))), + new Version$1(14, Int32Array.from([6, 26, 46, 66]), new ECBlocks$1(30, new ECB$1(3, 115), new ECB$1(1, 116)), new ECBlocks$1(24, new ECB$1(4, 40), new ECB$1(5, 41)), new ECBlocks$1(20, new ECB$1(11, 16), new ECB$1(5, 17)), new ECBlocks$1(24, new ECB$1(11, 12), new ECB$1(5, 13))), + new Version$1(15, Int32Array.from([6, 26, 48, 70]), new ECBlocks$1(22, new ECB$1(5, 87), new ECB$1(1, 88)), new ECBlocks$1(24, new ECB$1(5, 41), new ECB$1(5, 42)), new ECBlocks$1(30, new ECB$1(5, 24), new ECB$1(7, 25)), new ECBlocks$1(24, new ECB$1(11, 12), new ECB$1(7, 13))), + new Version$1(16, Int32Array.from([6, 26, 50, 74]), new ECBlocks$1(24, new ECB$1(5, 98), new ECB$1(1, 99)), new ECBlocks$1(28, new ECB$1(7, 45), new ECB$1(3, 46)), new ECBlocks$1(24, new ECB$1(15, 19), new ECB$1(2, 20)), new ECBlocks$1(30, new ECB$1(3, 15), new ECB$1(13, 16))), + new Version$1(17, Int32Array.from([6, 30, 54, 78]), new ECBlocks$1(28, new ECB$1(1, 107), new ECB$1(5, 108)), new ECBlocks$1(28, new ECB$1(10, 46), new ECB$1(1, 47)), new ECBlocks$1(28, new ECB$1(1, 22), new ECB$1(15, 23)), new ECBlocks$1(28, new ECB$1(2, 14), new ECB$1(17, 15))), + new Version$1(18, Int32Array.from([6, 30, 56, 82]), new ECBlocks$1(30, new ECB$1(5, 120), new ECB$1(1, 121)), new ECBlocks$1(26, new ECB$1(9, 43), new ECB$1(4, 44)), new ECBlocks$1(28, new ECB$1(17, 22), new ECB$1(1, 23)), new ECBlocks$1(28, new ECB$1(2, 14), new ECB$1(19, 15))), + new Version$1(19, Int32Array.from([6, 30, 58, 86]), new ECBlocks$1(28, new ECB$1(3, 113), new ECB$1(4, 114)), new ECBlocks$1(26, new ECB$1(3, 44), new ECB$1(11, 45)), new ECBlocks$1(26, new ECB$1(17, 21), new ECB$1(4, 22)), new ECBlocks$1(26, new ECB$1(9, 13), new ECB$1(16, 14))), + new Version$1(20, Int32Array.from([6, 34, 62, 90]), new ECBlocks$1(28, new ECB$1(3, 107), new ECB$1(5, 108)), new ECBlocks$1(26, new ECB$1(3, 41), new ECB$1(13, 42)), new ECBlocks$1(30, new ECB$1(15, 24), new ECB$1(5, 25)), new ECBlocks$1(28, new ECB$1(15, 15), new ECB$1(10, 16))), + new Version$1(21, Int32Array.from([6, 28, 50, 72, 94]), new ECBlocks$1(28, new ECB$1(4, 116), new ECB$1(4, 117)), new ECBlocks$1(26, new ECB$1(17, 42)), new ECBlocks$1(28, new ECB$1(17, 22), new ECB$1(6, 23)), new ECBlocks$1(30, new ECB$1(19, 16), new ECB$1(6, 17))), + new Version$1(22, Int32Array.from([6, 26, 50, 74, 98]), new ECBlocks$1(28, new ECB$1(2, 111), new ECB$1(7, 112)), new ECBlocks$1(28, new ECB$1(17, 46)), new ECBlocks$1(30, new ECB$1(7, 24), new ECB$1(16, 25)), new ECBlocks$1(24, new ECB$1(34, 13))), + new Version$1(23, Int32Array.from([6, 30, 54, 78, 102]), new ECBlocks$1(30, new ECB$1(4, 121), new ECB$1(5, 122)), new ECBlocks$1(28, new ECB$1(4, 47), new ECB$1(14, 48)), new ECBlocks$1(30, new ECB$1(11, 24), new ECB$1(14, 25)), new ECBlocks$1(30, new ECB$1(16, 15), new ECB$1(14, 16))), + new Version$1(24, Int32Array.from([6, 28, 54, 80, 106]), new ECBlocks$1(30, new ECB$1(6, 117), new ECB$1(4, 118)), new ECBlocks$1(28, new ECB$1(6, 45), new ECB$1(14, 46)), new ECBlocks$1(30, new ECB$1(11, 24), new ECB$1(16, 25)), new ECBlocks$1(30, new ECB$1(30, 16), new ECB$1(2, 17))), + new Version$1(25, Int32Array.from([6, 32, 58, 84, 110]), new ECBlocks$1(26, new ECB$1(8, 106), new ECB$1(4, 107)), new ECBlocks$1(28, new ECB$1(8, 47), new ECB$1(13, 48)), new ECBlocks$1(30, new ECB$1(7, 24), new ECB$1(22, 25)), new ECBlocks$1(30, new ECB$1(22, 15), new ECB$1(13, 16))), + new Version$1(26, Int32Array.from([6, 30, 58, 86, 114]), new ECBlocks$1(28, new ECB$1(10, 114), new ECB$1(2, 115)), new ECBlocks$1(28, new ECB$1(19, 46), new ECB$1(4, 47)), new ECBlocks$1(28, new ECB$1(28, 22), new ECB$1(6, 23)), new ECBlocks$1(30, new ECB$1(33, 16), new ECB$1(4, 17))), + new Version$1(27, Int32Array.from([6, 34, 62, 90, 118]), new ECBlocks$1(30, new ECB$1(8, 122), new ECB$1(4, 123)), new ECBlocks$1(28, new ECB$1(22, 45), new ECB$1(3, 46)), new ECBlocks$1(30, new ECB$1(8, 23), new ECB$1(26, 24)), new ECBlocks$1(30, new ECB$1(12, 15), new ECB$1(28, 16))), + new Version$1(28, Int32Array.from([6, 26, 50, 74, 98, 122]), new ECBlocks$1(30, new ECB$1(3, 117), new ECB$1(10, 118)), new ECBlocks$1(28, new ECB$1(3, 45), new ECB$1(23, 46)), new ECBlocks$1(30, new ECB$1(4, 24), new ECB$1(31, 25)), new ECBlocks$1(30, new ECB$1(11, 15), new ECB$1(31, 16))), + new Version$1(29, Int32Array.from([6, 30, 54, 78, 102, 126]), new ECBlocks$1(30, new ECB$1(7, 116), new ECB$1(7, 117)), new ECBlocks$1(28, new ECB$1(21, 45), new ECB$1(7, 46)), new ECBlocks$1(30, new ECB$1(1, 23), new ECB$1(37, 24)), new ECBlocks$1(30, new ECB$1(19, 15), new ECB$1(26, 16))), + new Version$1(30, Int32Array.from([6, 26, 52, 78, 104, 130]), new ECBlocks$1(30, new ECB$1(5, 115), new ECB$1(10, 116)), new ECBlocks$1(28, new ECB$1(19, 47), new ECB$1(10, 48)), new ECBlocks$1(30, new ECB$1(15, 24), new ECB$1(25, 25)), new ECBlocks$1(30, new ECB$1(23, 15), new ECB$1(25, 16))), + new Version$1(31, Int32Array.from([6, 30, 56, 82, 108, 134]), new ECBlocks$1(30, new ECB$1(13, 115), new ECB$1(3, 116)), new ECBlocks$1(28, new ECB$1(2, 46), new ECB$1(29, 47)), new ECBlocks$1(30, new ECB$1(42, 24), new ECB$1(1, 25)), new ECBlocks$1(30, new ECB$1(23, 15), new ECB$1(28, 16))), + new Version$1(32, Int32Array.from([6, 34, 60, 86, 112, 138]), new ECBlocks$1(30, new ECB$1(17, 115)), new ECBlocks$1(28, new ECB$1(10, 46), new ECB$1(23, 47)), new ECBlocks$1(30, new ECB$1(10, 24), new ECB$1(35, 25)), new ECBlocks$1(30, new ECB$1(19, 15), new ECB$1(35, 16))), + new Version$1(33, Int32Array.from([6, 30, 58, 86, 114, 142]), new ECBlocks$1(30, new ECB$1(17, 115), new ECB$1(1, 116)), new ECBlocks$1(28, new ECB$1(14, 46), new ECB$1(21, 47)), new ECBlocks$1(30, new ECB$1(29, 24), new ECB$1(19, 25)), new ECBlocks$1(30, new ECB$1(11, 15), new ECB$1(46, 16))), + new Version$1(34, Int32Array.from([6, 34, 62, 90, 118, 146]), new ECBlocks$1(30, new ECB$1(13, 115), new ECB$1(6, 116)), new ECBlocks$1(28, new ECB$1(14, 46), new ECB$1(23, 47)), new ECBlocks$1(30, new ECB$1(44, 24), new ECB$1(7, 25)), new ECBlocks$1(30, new ECB$1(59, 16), new ECB$1(1, 17))), + new Version$1(35, Int32Array.from([6, 30, 54, 78, 102, 126, 150]), new ECBlocks$1(30, new ECB$1(12, 121), new ECB$1(7, 122)), new ECBlocks$1(28, new ECB$1(12, 47), new ECB$1(26, 48)), new ECBlocks$1(30, new ECB$1(39, 24), new ECB$1(14, 25)), new ECBlocks$1(30, new ECB$1(22, 15), new ECB$1(41, 16))), + new Version$1(36, Int32Array.from([6, 24, 50, 76, 102, 128, 154]), new ECBlocks$1(30, new ECB$1(6, 121), new ECB$1(14, 122)), new ECBlocks$1(28, new ECB$1(6, 47), new ECB$1(34, 48)), new ECBlocks$1(30, new ECB$1(46, 24), new ECB$1(10, 25)), new ECBlocks$1(30, new ECB$1(2, 15), new ECB$1(64, 16))), + new Version$1(37, Int32Array.from([6, 28, 54, 80, 106, 132, 158]), new ECBlocks$1(30, new ECB$1(17, 122), new ECB$1(4, 123)), new ECBlocks$1(28, new ECB$1(29, 46), new ECB$1(14, 47)), new ECBlocks$1(30, new ECB$1(49, 24), new ECB$1(10, 25)), new ECBlocks$1(30, new ECB$1(24, 15), new ECB$1(46, 16))), + new Version$1(38, Int32Array.from([6, 32, 58, 84, 110, 136, 162]), new ECBlocks$1(30, new ECB$1(4, 122), new ECB$1(18, 123)), new ECBlocks$1(28, new ECB$1(13, 46), new ECB$1(32, 47)), new ECBlocks$1(30, new ECB$1(48, 24), new ECB$1(14, 25)), new ECBlocks$1(30, new ECB$1(42, 15), new ECB$1(32, 16))), + new Version$1(39, Int32Array.from([6, 26, 54, 82, 110, 138, 166]), new ECBlocks$1(30, new ECB$1(20, 117), new ECB$1(4, 118)), new ECBlocks$1(28, new ECB$1(40, 47), new ECB$1(7, 48)), new ECBlocks$1(30, new ECB$1(43, 24), new ECB$1(22, 25)), new ECBlocks$1(30, new ECB$1(10, 15), new ECB$1(67, 16))), + new Version$1(40, Int32Array.from([6, 30, 58, 86, 114, 142, 170]), new ECBlocks$1(30, new ECB$1(19, 118), new ECB$1(6, 119)), new ECBlocks$1(28, new ECB$1(18, 47), new ECB$1(31, 48)), new ECBlocks$1(30, new ECB$1(34, 24), new ECB$1(34, 25)), new ECBlocks$1(30, new ECB$1(20, 15), new ECB$1(61, 16))) + ]; + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + var DataMaskValues; + (function (DataMaskValues) { + DataMaskValues[DataMaskValues["DATA_MASK_000"] = 0] = "DATA_MASK_000"; + DataMaskValues[DataMaskValues["DATA_MASK_001"] = 1] = "DATA_MASK_001"; + DataMaskValues[DataMaskValues["DATA_MASK_010"] = 2] = "DATA_MASK_010"; + DataMaskValues[DataMaskValues["DATA_MASK_011"] = 3] = "DATA_MASK_011"; + DataMaskValues[DataMaskValues["DATA_MASK_100"] = 4] = "DATA_MASK_100"; + DataMaskValues[DataMaskValues["DATA_MASK_101"] = 5] = "DATA_MASK_101"; + DataMaskValues[DataMaskValues["DATA_MASK_110"] = 6] = "DATA_MASK_110"; + DataMaskValues[DataMaskValues["DATA_MASK_111"] = 7] = "DATA_MASK_111"; + })(DataMaskValues || (DataMaskValues = {})); + /** + * <p>Encapsulates data masks for the data bits in a QR code, per ISO 18004:2006 6.8. Implementations + * of this class can un-mask a raw BitMatrix. For simplicity, they will unmask the entire BitMatrix, + * including areas used for finder patterns, timing patterns, etc. These areas should be unused + * after the point they are unmasked anyway.</p> + * + * <p>Note that the diagram in section 6.8.1 is misleading since it indicates that i is column position + * and j is row position. In fact, as the text says, i is row position and j is column position.</p> + * + * @author Sean Owen + */ + class DataMask { + // See ISO 18004:2006 6.8.1 + constructor(value, isMasked) { + this.value = value; + this.isMasked = isMasked; + } + // End of enum constants. + /** + * <p>Implementations of this method reverse the data masking process applied to a QR Code and + * make its bits ready to read.</p> + * + * @param bits representation of QR Code bits + * @param dimension dimension of QR Code, represented by bits, being unmasked + */ + unmaskBitMatrix(bits, dimension /*int*/) { + for (let i = 0; i < dimension; i++) { + for (let j = 0; j < dimension; j++) { + if (this.isMasked(i, j)) { + bits.flip(j, i); + } + } + } + } + } + DataMask.values = new Map([ + /** + * 000: mask bits for which (x + y) mod 2 == 0 + */ + [DataMaskValues.DATA_MASK_000, new DataMask(DataMaskValues.DATA_MASK_000, (i /*int*/, j /*int*/) => { return ((i + j) & 0x01) === 0; })], + /** + * 001: mask bits for which x mod 2 == 0 + */ + [DataMaskValues.DATA_MASK_001, new DataMask(DataMaskValues.DATA_MASK_001, (i /*int*/, j /*int*/) => { return (i & 0x01) === 0; })], + /** + * 010: mask bits for which y mod 3 == 0 + */ + [DataMaskValues.DATA_MASK_010, new DataMask(DataMaskValues.DATA_MASK_010, (i /*int*/, j /*int*/) => { return j % 3 === 0; })], + /** + * 011: mask bits for which (x + y) mod 3 == 0 + */ + [DataMaskValues.DATA_MASK_011, new DataMask(DataMaskValues.DATA_MASK_011, (i /*int*/, j /*int*/) => { return (i + j) % 3 === 0; })], + /** + * 100: mask bits for which (x/2 + y/3) mod 2 == 0 + */ + [DataMaskValues.DATA_MASK_100, new DataMask(DataMaskValues.DATA_MASK_100, (i /*int*/, j /*int*/) => { return ((Math.floor(i / 2) + Math.floor(j / 3)) & 0x01) === 0; })], + /** + * 101: mask bits for which xy mod 2 + xy mod 3 == 0 + * equivalently, such that xy mod 6 == 0 + */ + [DataMaskValues.DATA_MASK_101, new DataMask(DataMaskValues.DATA_MASK_101, (i /*int*/, j /*int*/) => { return (i * j) % 6 === 0; })], + /** + * 110: mask bits for which (xy mod 2 + xy mod 3) mod 2 == 0 + * equivalently, such that xy mod 6 < 3 + */ + [DataMaskValues.DATA_MASK_110, new DataMask(DataMaskValues.DATA_MASK_110, (i /*int*/, j /*int*/) => { return ((i * j) % 6) < 3; })], + /** + * 111: mask bits for which ((x+y)mod 2 + xy mod 3) mod 2 == 0 + * equivalently, such that (x + y + xy mod 3) mod 2 == 0 + */ + [DataMaskValues.DATA_MASK_111, new DataMask(DataMaskValues.DATA_MASK_111, (i /*int*/, j /*int*/) => { return ((i + j + ((i * j) % 3)) & 0x01) === 0; })], + ]); + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * @author Sean Owen + */ + class BitMatrixParser$1 { + /** + * @param bitMatrix {@link BitMatrix} to parse + * @throws FormatException if dimension is not >= 21 and 1 mod 4 + */ + constructor(bitMatrix) { + const dimension = bitMatrix.getHeight(); + if (dimension < 21 || (dimension & 0x03) !== 1) { + throw new FormatException(); + } + this.bitMatrix = bitMatrix; + } + /** + * <p>Reads format information from one of its two locations within the QR Code.</p> + * + * @return {@link FormatInformation} encapsulating the QR Code's format info + * @throws FormatException if both format information locations cannot be parsed as + * the valid encoding of format information + */ + readFormatInformation() { + if (this.parsedFormatInfo !== null && this.parsedFormatInfo !== undefined) { + return this.parsedFormatInfo; + } + // Read top-left format info bits + let formatInfoBits1 = 0; + for (let i = 0; i < 6; i++) { + formatInfoBits1 = this.copyBit(i, 8, formatInfoBits1); + } + // .. and skip a bit in the timing pattern ... + formatInfoBits1 = this.copyBit(7, 8, formatInfoBits1); + formatInfoBits1 = this.copyBit(8, 8, formatInfoBits1); + formatInfoBits1 = this.copyBit(8, 7, formatInfoBits1); + // .. and skip a bit in the timing pattern ... + for (let j = 5; j >= 0; j--) { + formatInfoBits1 = this.copyBit(8, j, formatInfoBits1); + } + // Read the top-right/bottom-left pattern too + const dimension = this.bitMatrix.getHeight(); + let formatInfoBits2 = 0; + const jMin = dimension - 7; + for (let j = dimension - 1; j >= jMin; j--) { + formatInfoBits2 = this.copyBit(8, j, formatInfoBits2); + } + for (let i = dimension - 8; i < dimension; i++) { + formatInfoBits2 = this.copyBit(i, 8, formatInfoBits2); + } + this.parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits1, formatInfoBits2); + if (this.parsedFormatInfo !== null) { + return this.parsedFormatInfo; + } + throw new FormatException(); + } + /** + * <p>Reads version information from one of its two locations within the QR Code.</p> + * + * @return {@link Version} encapsulating the QR Code's version + * @throws FormatException if both version information locations cannot be parsed as + * the valid encoding of version information + */ + readVersion() { + if (this.parsedVersion !== null && this.parsedVersion !== undefined) { + return this.parsedVersion; + } + const dimension = this.bitMatrix.getHeight(); + const provisionalVersion = Math.floor((dimension - 17) / 4); + if (provisionalVersion <= 6) { + return Version$1.getVersionForNumber(provisionalVersion); + } + // Read top-right version info: 3 wide by 6 tall + let versionBits = 0; + const ijMin = dimension - 11; + for (let j = 5; j >= 0; j--) { + for (let i = dimension - 9; i >= ijMin; i--) { + versionBits = this.copyBit(i, j, versionBits); + } + } + let theParsedVersion = Version$1.decodeVersionInformation(versionBits); + if (theParsedVersion !== null && theParsedVersion.getDimensionForVersion() === dimension) { + this.parsedVersion = theParsedVersion; + return theParsedVersion; + } + // Hmm, failed. Try bottom left: 6 wide by 3 tall + versionBits = 0; + for (let i = 5; i >= 0; i--) { + for (let j = dimension - 9; j >= ijMin; j--) { + versionBits = this.copyBit(i, j, versionBits); + } + } + theParsedVersion = Version$1.decodeVersionInformation(versionBits); + if (theParsedVersion !== null && theParsedVersion.getDimensionForVersion() === dimension) { + this.parsedVersion = theParsedVersion; + return theParsedVersion; + } + throw new FormatException(); + } + copyBit(i /*int*/, j /*int*/, versionBits /*int*/) { + const bit = this.isMirror ? this.bitMatrix.get(j, i) : this.bitMatrix.get(i, j); + return bit ? (versionBits << 1) | 0x1 : versionBits << 1; + } + /** + * <p>Reads the bits in the {@link BitMatrix} representing the finder pattern in the + * correct order in order to reconstruct the codewords bytes contained within the + * QR Code.</p> + * + * @return bytes encoded within the QR Code + * @throws FormatException if the exact number of bytes expected is not read + */ + readCodewords() { + const formatInfo = this.readFormatInformation(); + const version = this.readVersion(); + // Get the data mask for the format used in this QR Code. This will exclude + // some bits from reading as we wind through the bit matrix. + const dataMask = DataMask.values.get(formatInfo.getDataMask()); + const dimension = this.bitMatrix.getHeight(); + dataMask.unmaskBitMatrix(this.bitMatrix, dimension); + const functionPattern = version.buildFunctionPattern(); + let readingUp = true; + const result = new Uint8Array(version.getTotalCodewords()); + let resultOffset = 0; + let currentByte = 0; + let bitsRead = 0; + // Read columns in pairs, from right to left + for (let j = dimension - 1; j > 0; j -= 2) { + if (j === 6) { + // Skip whole column with vertical alignment pattern + // saves time and makes the other code proceed more cleanly + j--; + } + // Read alternatingly from bottom to top then top to bottom + for (let count = 0; count < dimension; count++) { + const i = readingUp ? dimension - 1 - count : count; + for (let col = 0; col < 2; col++) { + // Ignore bits covered by the function pattern + if (!functionPattern.get(j - col, i)) { + // Read a bit + bitsRead++; + currentByte <<= 1; + if (this.bitMatrix.get(j - col, i)) { + currentByte |= 1; + } + // If we've made a whole byte, save it off + if (bitsRead === 8) { + result[resultOffset++] = /*(byte) */ currentByte; + bitsRead = 0; + currentByte = 0; + } + } + } + } + readingUp = !readingUp; // readingUp ^= true; // readingUp = !readingUp; // switch directions + } + if (resultOffset !== version.getTotalCodewords()) { + throw new FormatException(); + } + return result; + } + /** + * Revert the mask removal done while reading the code words. The bit matrix should revert to its original state. + */ + remask() { + if (this.parsedFormatInfo === null) { + return; // We have no format information, and have no data mask + } + const dataMask = DataMask.values[this.parsedFormatInfo.getDataMask()]; + const dimension = this.bitMatrix.getHeight(); + dataMask.unmaskBitMatrix(this.bitMatrix, dimension); + } + /** + * Prepare the parser for a mirrored operation. + * This flag has effect only on the {@link #readFormatInformation()} and the + * {@link #readVersion()}. Before proceeding with {@link #readCodewords()} the + * {@link #mirror()} method should be called. + * + * @param mirror Whether to read version and format information mirrored. + */ + setMirror(isMirror) { + this.parsedVersion = null; + this.parsedFormatInfo = null; + this.isMirror = isMirror; + } + /** Mirror the bit matrix in order to attempt a second reading. */ + mirror() { + const bitMatrix = this.bitMatrix; + for (let x = 0, width = bitMatrix.getWidth(); x < width; x++) { + for (let y = x + 1, height = bitMatrix.getHeight(); y < height; y++) { + if (bitMatrix.get(x, y) !== bitMatrix.get(y, x)) { + bitMatrix.flip(y, x); + bitMatrix.flip(x, y); + } + } + } + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Encapsulates a block of data within a QR Code. QR Codes may split their data into + * multiple blocks, each of which is a unit of data and error-correction codewords. Each + * is represented by an instance of this class.</p> + * + * @author Sean Owen + */ + class DataBlock$1 { + constructor(numDataCodewords /*int*/, codewords) { + this.numDataCodewords = numDataCodewords; + this.codewords = codewords; + } + /** + * <p>When QR Codes use multiple data blocks, they are actually interleaved. + * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This + * method will separate the data into original blocks.</p> + * + * @param rawCodewords bytes as read directly from the QR Code + * @param version version of the QR Code + * @param ecLevel error-correction level of the QR Code + * @return DataBlocks containing original bytes, "de-interleaved" from representation in the + * QR Code + */ + static getDataBlocks(rawCodewords, version, ecLevel) { + if (rawCodewords.length !== version.getTotalCodewords()) { + throw new IllegalArgumentException(); + } + // Figure out the number and size of data blocks used by this version and + // error correction level + const ecBlocks = version.getECBlocksForLevel(ecLevel); + // First count the total number of data blocks + let totalBlocks = 0; + const ecBlockArray = ecBlocks.getECBlocks(); + for (const ecBlock of ecBlockArray) { + totalBlocks += ecBlock.getCount(); + } + // Now establish DataBlocks of the appropriate size and number of data codewords + const result = new Array(totalBlocks); + let numResultBlocks = 0; + for (const ecBlock of ecBlockArray) { + for (let i = 0; i < ecBlock.getCount(); i++) { + const numDataCodewords = ecBlock.getDataCodewords(); + const numBlockCodewords = ecBlocks.getECCodewordsPerBlock() + numDataCodewords; + result[numResultBlocks++] = new DataBlock$1(numDataCodewords, new Uint8Array(numBlockCodewords)); + } + } + // All blocks have the same amount of data, except that the last n + // (where n may be 0) have 1 more byte. Figure out where these start. + const shorterBlocksTotalCodewords = result[0].codewords.length; + let longerBlocksStartAt = result.length - 1; + // TYPESCRIPTPORT: check length is correct here + while (longerBlocksStartAt >= 0) { + const numCodewords = result[longerBlocksStartAt].codewords.length; + if (numCodewords === shorterBlocksTotalCodewords) { + break; + } + longerBlocksStartAt--; + } + longerBlocksStartAt++; + const shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.getECCodewordsPerBlock(); + // The last elements of result may be 1 element longer + // first fill out as many elements as all of them have + let rawCodewordsOffset = 0; + for (let i = 0; i < shorterBlocksNumDataCodewords; i++) { + for (let j = 0; j < numResultBlocks; j++) { + result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; + } + } + // Fill out the last data block in the longer ones + for (let j = longerBlocksStartAt; j < numResultBlocks; j++) { + result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++]; + } + // Now add in error correction blocks + const max = result[0].codewords.length; + for (let i = shorterBlocksNumDataCodewords; i < max; i++) { + for (let j = 0; j < numResultBlocks; j++) { + const iOffset = j < longerBlocksStartAt ? i : i + 1; + result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; + } + } + return result; + } + getNumDataCodewords() { + return this.numDataCodewords; + } + getCodewords() { + return this.codewords; + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + var ModeValues; + (function (ModeValues) { + ModeValues[ModeValues["TERMINATOR"] = 0] = "TERMINATOR"; + ModeValues[ModeValues["NUMERIC"] = 1] = "NUMERIC"; + ModeValues[ModeValues["ALPHANUMERIC"] = 2] = "ALPHANUMERIC"; + ModeValues[ModeValues["STRUCTURED_APPEND"] = 3] = "STRUCTURED_APPEND"; + ModeValues[ModeValues["BYTE"] = 4] = "BYTE"; + ModeValues[ModeValues["ECI"] = 5] = "ECI"; + ModeValues[ModeValues["KANJI"] = 6] = "KANJI"; + ModeValues[ModeValues["FNC1_FIRST_POSITION"] = 7] = "FNC1_FIRST_POSITION"; + ModeValues[ModeValues["FNC1_SECOND_POSITION"] = 8] = "FNC1_SECOND_POSITION"; + /** See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. */ + ModeValues[ModeValues["HANZI"] = 9] = "HANZI"; + })(ModeValues || (ModeValues = {})); + /** + * <p>See ISO 18004:2006, 6.4.1, Tables 2 and 3. This enum encapsulates the various modes in which + * data can be encoded to bits in the QR code standard.</p> + * + * @author Sean Owen + */ + class Mode$1 { + constructor(value, stringValue, characterCountBitsForVersions, bits /*int*/) { + this.value = value; + this.stringValue = stringValue; + this.characterCountBitsForVersions = characterCountBitsForVersions; + this.bits = bits; + Mode$1.FOR_BITS.set(bits, this); + Mode$1.FOR_VALUE.set(value, this); + } + /** + * @param bits four bits encoding a QR Code data mode + * @return Mode encoded by these bits + * @throws IllegalArgumentException if bits do not correspond to a known mode + */ + static forBits(bits /*int*/) { + const mode = Mode$1.FOR_BITS.get(bits); + if (undefined === mode) { + throw new IllegalArgumentException(); + } + return mode; + } + /** + * @param version version in question + * @return number of bits used, in this QR Code symbol {@link Version}, to encode the + * count of characters that will follow encoded in this Mode + */ + getCharacterCountBits(version) { + const versionNumber = version.getVersionNumber(); + let offset; + if (versionNumber <= 9) { + offset = 0; + } + else if (versionNumber <= 26) { + offset = 1; + } + else { + offset = 2; + } + return this.characterCountBitsForVersions[offset]; + } + getValue() { + return this.value; + } + getBits() { + return this.bits; + } + equals(o) { + if (!(o instanceof Mode$1)) { + return false; + } + const other = o; + return this.value === other.value; + } + toString() { + return this.stringValue; + } + } + Mode$1.FOR_BITS = new Map(); + Mode$1.FOR_VALUE = new Map(); + Mode$1.TERMINATOR = new Mode$1(ModeValues.TERMINATOR, 'TERMINATOR', Int32Array.from([0, 0, 0]), 0x00); // Not really a mode... + Mode$1.NUMERIC = new Mode$1(ModeValues.NUMERIC, 'NUMERIC', Int32Array.from([10, 12, 14]), 0x01); + Mode$1.ALPHANUMERIC = new Mode$1(ModeValues.ALPHANUMERIC, 'ALPHANUMERIC', Int32Array.from([9, 11, 13]), 0x02); + Mode$1.STRUCTURED_APPEND = new Mode$1(ModeValues.STRUCTURED_APPEND, 'STRUCTURED_APPEND', Int32Array.from([0, 0, 0]), 0x03); // Not supported + Mode$1.BYTE = new Mode$1(ModeValues.BYTE, 'BYTE', Int32Array.from([8, 16, 16]), 0x04); + Mode$1.ECI = new Mode$1(ModeValues.ECI, 'ECI', Int32Array.from([0, 0, 0]), 0x07); // character counts don't apply + Mode$1.KANJI = new Mode$1(ModeValues.KANJI, 'KANJI', Int32Array.from([8, 10, 12]), 0x08); + Mode$1.FNC1_FIRST_POSITION = new Mode$1(ModeValues.FNC1_FIRST_POSITION, 'FNC1_FIRST_POSITION', Int32Array.from([0, 0, 0]), 0x05); + Mode$1.FNC1_SECOND_POSITION = new Mode$1(ModeValues.FNC1_SECOND_POSITION, 'FNC1_SECOND_POSITION', Int32Array.from([0, 0, 0]), 0x09); + /** See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. */ + Mode$1.HANZI = new Mode$1(ModeValues.HANZI, 'HANZI', Int32Array.from([8, 10, 12]), 0x0D); + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*import java.io.UnsupportedEncodingException;*/ + /*import java.util.ArrayList;*/ + /*import java.util.Collection;*/ + /*import java.util.List;*/ + /*import java.util.Map;*/ + /** + * <p>QR Codes can encode text as bits in one of several modes, and can use multiple modes + * in one QR Code. This class decodes the bits back into text.</p> + * + * <p>See ISO 18004:2006, 6.4.3 - 6.4.7</p> + * + * @author Sean Owen + */ + class DecodedBitStreamParser$1 { + static decode(bytes, version, ecLevel, hints) { + const bits = new BitSource(bytes); + let result = new StringBuilder(); + const byteSegments = new Array(); // 1 + // TYPESCRIPTPORT: I do not use constructor with size 1 as in original Java means capacity and the array length is checked below + let symbolSequence = -1; + let parityData = -1; + try { + let currentCharacterSetECI = null; + let fc1InEffect = false; + let mode; + do { + // While still another segment to read... + if (bits.available() < 4) { + // OK, assume we're done. Really, a TERMINATOR mode should have been recorded here + mode = Mode$1.TERMINATOR; + } + else { + const modeBits = bits.readBits(4); + mode = Mode$1.forBits(modeBits); // mode is encoded by 4 bits + } + switch (mode) { + case Mode$1.TERMINATOR: + break; + case Mode$1.FNC1_FIRST_POSITION: + case Mode$1.FNC1_SECOND_POSITION: + // We do little with FNC1 except alter the parsed result a bit according to the spec + fc1InEffect = true; + break; + case Mode$1.STRUCTURED_APPEND: + if (bits.available() < 16) { + throw new FormatException(); + } + // sequence number and parity is added later to the result metadata + // Read next 8 bits (symbol sequence #) and 8 bits (data: parity), then continue + symbolSequence = bits.readBits(8); + parityData = bits.readBits(8); + break; + case Mode$1.ECI: + // Count doesn't apply to ECI + const value = DecodedBitStreamParser$1.parseECIValue(bits); + currentCharacterSetECI = CharacterSetECI.getCharacterSetECIByValue(value); + if (currentCharacterSetECI === null) { + throw new FormatException(); + } + break; + case Mode$1.HANZI: + // First handle Hanzi mode which does not start with character count + // Chinese mode contains a sub set indicator right after mode indicator + const subset = bits.readBits(4); + const countHanzi = bits.readBits(mode.getCharacterCountBits(version)); + if (subset === DecodedBitStreamParser$1.GB2312_SUBSET) { + DecodedBitStreamParser$1.decodeHanziSegment(bits, result, countHanzi); + } + break; + default: + // "Normal" QR code modes: + // How many characters will follow, encoded in this mode? + const count = bits.readBits(mode.getCharacterCountBits(version)); + switch (mode) { + case Mode$1.NUMERIC: + DecodedBitStreamParser$1.decodeNumericSegment(bits, result, count); + break; + case Mode$1.ALPHANUMERIC: + DecodedBitStreamParser$1.decodeAlphanumericSegment(bits, result, count, fc1InEffect); + break; + case Mode$1.BYTE: + DecodedBitStreamParser$1.decodeByteSegment(bits, result, count, currentCharacterSetECI, byteSegments, hints); + break; + case Mode$1.KANJI: + DecodedBitStreamParser$1.decodeKanjiSegment(bits, result, count); + break; + default: + throw new FormatException(); + } + break; + } + } while (mode !== Mode$1.TERMINATOR); + } + catch (iae /*: IllegalArgumentException*/) { + // from readBits() calls + throw new FormatException(); + } + return new DecoderResult(bytes, result.toString(), byteSegments.length === 0 ? null : byteSegments, ecLevel === null ? null : ecLevel.toString(), symbolSequence, parityData); + } + /** + * See specification GBT 18284-2000 + */ + static decodeHanziSegment(bits, result, count /*int*/) { + // Don't crash trying to read more bits than we have available. + if (count * 13 > bits.available()) { + throw new FormatException(); + } + // Each character will require 2 bytes. Read the characters as 2-byte pairs + // and decode as GB2312 afterwards + const buffer = new Uint8Array(2 * count); + let offset = 0; + while (count > 0) { + // Each 13 bits encodes a 2-byte character + const twoBytes = bits.readBits(13); + let assembledTwoBytes = (((twoBytes / 0x060) << 8) & 0xFFFFFFFF) | (twoBytes % 0x060); + if (assembledTwoBytes < 0x003BF) { + // In the 0xA1A1 to 0xAAFE range + assembledTwoBytes += 0x0A1A1; + } + else { + // In the 0xB0A1 to 0xFAFE range + assembledTwoBytes += 0x0A6A1; + } + buffer[offset] = /*(byte) */ ((assembledTwoBytes >> 8) & 0xFF); + buffer[offset + 1] = /*(byte) */ (assembledTwoBytes & 0xFF); + offset += 2; + count--; + } + try { + result.append(StringEncoding.decode(buffer, StringUtils.GB2312)); + // TYPESCRIPTPORT: TODO: implement GB2312 decode. StringView from MDN could be a starting point + } + catch (ignored /*: UnsupportedEncodingException*/) { + throw new FormatException(ignored); + } + } + static decodeKanjiSegment(bits, result, count /*int*/) { + // Don't crash trying to read more bits than we have available. + if (count * 13 > bits.available()) { + throw new FormatException(); + } + // Each character will require 2 bytes. Read the characters as 2-byte pairs + // and decode as Shift_JIS afterwards + const buffer = new Uint8Array(2 * count); + let offset = 0; + while (count > 0) { + // Each 13 bits encodes a 2-byte character + const twoBytes = bits.readBits(13); + let assembledTwoBytes = (((twoBytes / 0x0C0) << 8) & 0xFFFFFFFF) | (twoBytes % 0x0C0); + if (assembledTwoBytes < 0x01F00) { + // In the 0x8140 to 0x9FFC range + assembledTwoBytes += 0x08140; + } + else { + // In the 0xE040 to 0xEBBF range + assembledTwoBytes += 0x0C140; + } + buffer[offset] = /*(byte) */ (assembledTwoBytes >> 8); + buffer[offset + 1] = /*(byte) */ assembledTwoBytes; + offset += 2; + count--; + } + // Shift_JIS may not be supported in some environments: + try { + result.append(StringEncoding.decode(buffer, StringUtils.SHIFT_JIS)); + // TYPESCRIPTPORT: TODO: implement SHIFT_JIS decode. StringView from MDN could be a starting point + } + catch (ignored /*: UnsupportedEncodingException*/) { + throw new FormatException(ignored); + } + } + static decodeByteSegment(bits, result, count /*int*/, currentCharacterSetECI, byteSegments, hints) { + // Don't crash trying to read more bits than we have available. + if (8 * count > bits.available()) { + throw new FormatException(); + } + const readBytes = new Uint8Array(count); + for (let i = 0; i < count; i++) { + readBytes[i] = /*(byte) */ bits.readBits(8); + } + let encoding; + if (currentCharacterSetECI === null) { + // The spec isn't clear on this mode; see + // section 6.4.5: t does not say which encoding to assuming + // upon decoding. I have seen ISO-8859-1 used as well as + // Shift_JIS -- without anything like an ECI designator to + // give a hint. + encoding = StringUtils.guessEncoding(readBytes, hints); + } + else { + encoding = currentCharacterSetECI.getName(); + } + try { + result.append(StringEncoding.decode(readBytes, encoding)); + } + catch (ignored /*: UnsupportedEncodingException*/) { + throw new FormatException(ignored); + } + byteSegments.push(readBytes); + } + static toAlphaNumericChar(value /*int*/) { + if (value >= DecodedBitStreamParser$1.ALPHANUMERIC_CHARS.length) { + throw new FormatException(); + } + return DecodedBitStreamParser$1.ALPHANUMERIC_CHARS[value]; + } + static decodeAlphanumericSegment(bits, result, count /*int*/, fc1InEffect) { + // Read two characters at a time + const start = result.length(); + while (count > 1) { + if (bits.available() < 11) { + throw new FormatException(); + } + const nextTwoCharsBits = bits.readBits(11); + result.append(DecodedBitStreamParser$1.toAlphaNumericChar(Math.floor(nextTwoCharsBits / 45))); + result.append(DecodedBitStreamParser$1.toAlphaNumericChar(nextTwoCharsBits % 45)); + count -= 2; + } + if (count === 1) { + // special case: one character left + if (bits.available() < 6) { + throw new FormatException(); + } + result.append(DecodedBitStreamParser$1.toAlphaNumericChar(bits.readBits(6))); + } + // See section 6.4.8.1, 6.4.8.2 + if (fc1InEffect) { + // We need to massage the result a bit if in an FNC1 mode: + for (let i = start; i < result.length(); i++) { + if (result.charAt(i) === '%') { + if (i < result.length() - 1 && result.charAt(i + 1) === '%') { + // %% is rendered as % + result.deleteCharAt(i + 1); + } + else { + // In alpha mode, % should be converted to FNC1 separator 0x1D + result.setCharAt(i, String.fromCharCode(0x1D)); + } + } + } + } + } + static decodeNumericSegment(bits, result, count /*int*/) { + // Read three digits at a time + while (count >= 3) { + // Each 10 bits encodes three digits + if (bits.available() < 10) { + throw new FormatException(); + } + const threeDigitsBits = bits.readBits(10); + if (threeDigitsBits >= 1000) { + throw new FormatException(); + } + result.append(DecodedBitStreamParser$1.toAlphaNumericChar(Math.floor(threeDigitsBits / 100))); + result.append(DecodedBitStreamParser$1.toAlphaNumericChar(Math.floor(threeDigitsBits / 10) % 10)); + result.append(DecodedBitStreamParser$1.toAlphaNumericChar(threeDigitsBits % 10)); + count -= 3; + } + if (count === 2) { + // Two digits left over to read, encoded in 7 bits + if (bits.available() < 7) { + throw new FormatException(); + } + const twoDigitsBits = bits.readBits(7); + if (twoDigitsBits >= 100) { + throw new FormatException(); + } + result.append(DecodedBitStreamParser$1.toAlphaNumericChar(Math.floor(twoDigitsBits / 10))); + result.append(DecodedBitStreamParser$1.toAlphaNumericChar(twoDigitsBits % 10)); + } + else if (count === 1) { + // One digit left over to read + if (bits.available() < 4) { + throw new FormatException(); + } + const digitBits = bits.readBits(4); + if (digitBits >= 10) { + throw new FormatException(); + } + result.append(DecodedBitStreamParser$1.toAlphaNumericChar(digitBits)); + } + } + static parseECIValue(bits) { + const firstByte = bits.readBits(8); + if ((firstByte & 0x80) === 0) { + // just one byte + return firstByte & 0x7F; + } + if ((firstByte & 0xC0) === 0x80) { + // two bytes + const secondByte = bits.readBits(8); + return (((firstByte & 0x3F) << 8) & 0xFFFFFFFF) | secondByte; + } + if ((firstByte & 0xE0) === 0xC0) { + // three bytes + const secondThirdBytes = bits.readBits(16); + return (((firstByte & 0x1F) << 16) & 0xFFFFFFFF) | secondThirdBytes; + } + throw new FormatException(); + } + } + /** + * See ISO 18004:2006, 6.4.4 Table 5 + */ + DecodedBitStreamParser$1.ALPHANUMERIC_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'; + DecodedBitStreamParser$1.GB2312_SUBSET = 1; + // function Uint8ArrayToString(a: Uint8Array): string { + // const CHUNK_SZ = 0x8000; + // const c = new StringBuilder(); + // for (let i = 0, length = a.length; i < length; i += CHUNK_SZ) { + // c.append(String.fromCharCode.apply(null, a.subarray(i, i + CHUNK_SZ))); + // } + // return c.toString(); + // } + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * Meta-data container for QR Code decoding. Instances of this class may be used to convey information back to the + * decoding caller. Callers are expected to process this. + * + * @see com.google.zxing.common.DecoderResult#getOther() + */ + class QRCodeDecoderMetaData { + constructor(mirrored) { + this.mirrored = mirrored; + } + /** + * @return true if the QR Code was mirrored. + */ + isMirrored() { + return this.mirrored; + } + /** + * Apply the result points' order correction due to mirroring. + * + * @param points Array of points to apply mirror correction to. + */ + applyMirroredCorrection(points) { + if (!this.mirrored || points === null || points.length < 3) { + return; + } + const bottomLeft = points[0]; + points[0] = points[2]; + points[2] = bottomLeft; + // No need to 'fix' top-left and alignment pattern. + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*import java.util.Map;*/ + /** + * <p>The main class which implements QR Code decoding -- as opposed to locating and extracting + * the QR Code from an image.</p> + * + * @author Sean Owen + */ + class Decoder$2 { + constructor() { + this.rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256); + } + // public decode(image: boolean[][]): DecoderResult /*throws ChecksumException, FormatException*/ { + // return decode(image, null) + // } + /** + * <p>Convenience method that can decode a QR Code represented as a 2D array of booleans. + * "true" is taken to mean a black module.</p> + * + * @param image booleans representing white/black QR Code modules + * @param hints decoding hints that should be used to influence decoding + * @return text and bytes encoded within the QR Code + * @throws FormatException if the QR Code cannot be decoded + * @throws ChecksumException if error correction fails + */ + decodeBooleanArray(image, hints) { + return this.decodeBitMatrix(BitMatrix.parseFromBooleanArray(image), hints); + } + // public decodeBitMatrix(bits: BitMatrix): DecoderResult /*throws ChecksumException, FormatException*/ { + // return decode(bits, null) + // } + /** + * <p>Decodes a QR Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.</p> + * + * @param bits booleans representing white/black QR Code modules + * @param hints decoding hints that should be used to influence decoding + * @return text and bytes encoded within the QR Code + * @throws FormatException if the QR Code cannot be decoded + * @throws ChecksumException if error correction fails + */ + decodeBitMatrix(bits, hints) { + // Construct a parser and read version, error-correction level + const parser = new BitMatrixParser$1(bits); + let ex = null; + try { + return this.decodeBitMatrixParser(parser, hints); + } + catch (e /*: FormatException, ChecksumException*/) { + ex = e; + } + try { + // Revert the bit matrix + parser.remask(); + // Will be attempting a mirrored reading of the version and format info. + parser.setMirror(true); + // Preemptively read the version. + parser.readVersion(); + // Preemptively read the format information. + parser.readFormatInformation(); + /* + * Since we're here, this means we have successfully detected some kind + * of version and format information when mirrored. This is a good sign, + * that the QR code may be mirrored, and we should try once more with a + * mirrored content. + */ + // Prepare for a mirrored reading. + parser.mirror(); + const result = this.decodeBitMatrixParser(parser, hints); + // Success! Notify the caller that the code was mirrored. + result.setOther(new QRCodeDecoderMetaData(true)); + return result; + } + catch (e /*FormatException | ChecksumException*/) { + // Throw the exception from the original reading + if (ex !== null) { + throw ex; + } + throw e; + } + } + decodeBitMatrixParser(parser, hints) { + const version = parser.readVersion(); + const ecLevel = parser.readFormatInformation().getErrorCorrectionLevel(); + // Read codewords + const codewords = parser.readCodewords(); + // Separate into data blocks + const dataBlocks = DataBlock$1.getDataBlocks(codewords, version, ecLevel); + // Count total number of data bytes + let totalBytes = 0; + for (const dataBlock of dataBlocks) { + totalBytes += dataBlock.getNumDataCodewords(); + } + const resultBytes = new Uint8Array(totalBytes); + let resultOffset = 0; + // Error-correct and copy data blocks together into a stream of bytes + for (const dataBlock of dataBlocks) { + const codewordBytes = dataBlock.getCodewords(); + const numDataCodewords = dataBlock.getNumDataCodewords(); + this.correctErrors(codewordBytes, numDataCodewords); + for (let i = 0; i < numDataCodewords; i++) { + resultBytes[resultOffset++] = codewordBytes[i]; + } + } + // Decode the contents of that stream of bytes + return DecodedBitStreamParser$1.decode(resultBytes, version, ecLevel, hints); + } + /** + * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to + * correct the errors in-place using Reed-Solomon error correction.</p> + * + * @param codewordBytes data and error correction codewords + * @param numDataCodewords number of codewords that are data bytes + * @throws ChecksumException if error correction fails + */ + correctErrors(codewordBytes, numDataCodewords /*int*/) { + // const numCodewords = codewordBytes.length; + // First read into an array of ints + const codewordsInts = new Int32Array(codewordBytes); + // TYPESCRIPTPORT: not realy necessary to transform to ints? could redesign everything to work with unsigned bytes? + // const codewordsInts = new Int32Array(numCodewords) + // for (let i = 0; i < numCodewords; i++) { + // codewordsInts[i] = codewordBytes[i] & 0xFF + // } + try { + this.rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords); + } + catch (ignored /*: ReedSolomonException*/) { + throw new ChecksumException(); + } + // Copy back into array of bytes -- only need to worry about the bytes that were data + // We don't care about errors in the error-correction codewords + for (let i = 0; i < numDataCodewords; i++) { + codewordBytes[i] = /*(byte) */ codewordsInts[i]; + } + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Encapsulates an alignment pattern, which are the smaller square patterns found in + * all but the simplest QR Codes.</p> + * + * @author Sean Owen + */ + class AlignmentPattern extends ResultPoint { + constructor(posX /*float*/, posY /*float*/, estimatedModuleSize /*float*/) { + super(posX, posY); + this.estimatedModuleSize = estimatedModuleSize; + } + /** + * <p>Determines if this alignment pattern "about equals" an alignment pattern at the stated + * position and size -- meaning, it is at nearly the same center with nearly the same size.</p> + */ + aboutEquals(moduleSize /*float*/, i /*float*/, j /*float*/) { + if (Math.abs(i - this.getY()) <= moduleSize && Math.abs(j - this.getX()) <= moduleSize) { + const moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize); + return moduleSizeDiff <= 1.0 || moduleSizeDiff <= this.estimatedModuleSize; + } + return false; + } + /** + * Combines this object's current estimate of a finder pattern position and module size + * with a new estimate. It returns a new {@code FinderPattern} containing an average of the two. + */ + combineEstimate(i /*float*/, j /*float*/, newModuleSize /*float*/) { + const combinedX = (this.getX() + j) / 2.0; + const combinedY = (this.getY() + i) / 2.0; + const combinedModuleSize = (this.estimatedModuleSize + newModuleSize) / 2.0; + return new AlignmentPattern(combinedX, combinedY, combinedModuleSize); + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*import java.util.ArrayList;*/ + /*import java.util.List;*/ + /** + * <p>This class attempts to find alignment patterns in a QR Code. Alignment patterns look like finder + * patterns but are smaller and appear at regular intervals throughout the image.</p> + * + * <p>At the moment this only looks for the bottom-right alignment pattern.</p> + * + * <p>This is mostly a simplified copy of {@link FinderPatternFinder}. It is copied, + * pasted and stripped down here for maximum performance but does unfortunately duplicate + * some code.</p> + * + * <p>This class is thread-safe but not reentrant. Each thread must allocate its own object.</p> + * + * @author Sean Owen + */ + class AlignmentPatternFinder { + /** + * <p>Creates a finder that will look in a portion of the whole image.</p> + * + * @param image image to search + * @param startX left column from which to start searching + * @param startY top row from which to start searching + * @param width width of region to search + * @param height height of region to search + * @param moduleSize estimated module size so far + */ + constructor(image, startX /*int*/, startY /*int*/, width /*int*/, height /*int*/, moduleSize /*float*/, resultPointCallback) { + this.image = image; + this.startX = startX; + this.startY = startY; + this.width = width; + this.height = height; + this.moduleSize = moduleSize; + this.resultPointCallback = resultPointCallback; + this.possibleCenters = []; // new Array<any>(5)) + // TYPESCRIPTPORT: array initialization without size as the length is checked below + this.crossCheckStateCount = new Int32Array(3); + } + /** + * <p>This method attempts to find the bottom-right alignment pattern in the image. It is a bit messy since + * it's pretty performance-critical and so is written to be fast foremost.</p> + * + * @return {@link AlignmentPattern} if found + * @throws NotFoundException if not found + */ + find() { + const startX = this.startX; + const height = this.height; + const width = this.width; + const maxJ = startX + width; + const middleI = this.startY + (height / 2); + // We are looking for black/white/black modules in 1:1:1 ratio + // this tracks the number of black/white/black modules seen so far + const stateCount = new Int32Array(3); + const image = this.image; + for (let iGen = 0; iGen < height; iGen++) { + // Search from middle outwards + const i = middleI + ((iGen & 0x01) === 0 ? Math.floor((iGen + 1) / 2) : -Math.floor((iGen + 1) / 2)); + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + let j = startX; + // Burn off leading white pixels before anything else; if we start in the middle of + // a white run, it doesn't make sense to count its length, since we don't know if the + // white run continued to the left of the start point + while (j < maxJ && !image.get(j, i)) { + j++; + } + let currentState = 0; + while (j < maxJ) { + if (image.get(j, i)) { + // Black pixel + if (currentState === 1) { // Counting black pixels + stateCount[1]++; + } + else { // Counting white pixels + if (currentState === 2) { // A winner? + if (this.foundPatternCross(stateCount)) { // Yes + const confirmed = this.handlePossibleCenter(stateCount, i, j); + if (confirmed !== null) { + return confirmed; + } + } + stateCount[0] = stateCount[2]; + stateCount[1] = 1; + stateCount[2] = 0; + currentState = 1; + } + else { + stateCount[++currentState]++; + } + } + } + else { // White pixel + if (currentState === 1) { // Counting black pixels + currentState++; + } + stateCount[currentState]++; + } + j++; + } + if (this.foundPatternCross(stateCount)) { + const confirmed = this.handlePossibleCenter(stateCount, i, maxJ); + if (confirmed !== null) { + return confirmed; + } + } + } + // Hmm, nothing we saw was observed and confirmed twice. If we had + // any guess at all, return it. + if (this.possibleCenters.length !== 0) { + return this.possibleCenters[0]; + } + throw new NotFoundException(); + } + /** + * Given a count of black/white/black pixels just seen and an end position, + * figures the location of the center of this black/white/black run. + */ + static centerFromEnd(stateCount, end /*int*/) { + return (end - stateCount[2]) - stateCount[1] / 2.0; + } + /** + * @param stateCount count of black/white/black pixels just read + * @return true iff the proportions of the counts is close enough to the 1/1/1 ratios + * used by alignment patterns to be considered a match + */ + foundPatternCross(stateCount) { + const moduleSize = this.moduleSize; + const maxVariance = moduleSize / 2.0; + for (let i = 0; i < 3; i++) { + if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) { + return false; + } + } + return true; + } + /** + * <p>After a horizontal scan finds a potential alignment pattern, this method + * "cross-checks" by scanning down vertically through the center of the possible + * alignment pattern to see if the same proportion is detected.</p> + * + * @param startI row where an alignment pattern was detected + * @param centerJ center of the section that appears to cross an alignment pattern + * @param maxCount maximum reasonable number of modules that should be + * observed in any reading state, based on the results of the horizontal scan + * @return vertical center of alignment pattern, or {@link Float#NaN} if not found + */ + crossCheckVertical(startI /*int*/, centerJ /*int*/, maxCount /*int*/, originalStateCountTotal /*int*/) { + const image = this.image; + const maxI = image.getHeight(); + const stateCount = this.crossCheckStateCount; + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + // Start counting up from center + let i = startI; + while (i >= 0 && image.get(centerJ, i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i--; + } + // If already too many modules in this state or ran off the edge: + if (i < 0 || stateCount[1] > maxCount) { + return NaN; + } + while (i >= 0 && !image.get(centerJ, i) && stateCount[0] <= maxCount) { + stateCount[0]++; + i--; + } + if (stateCount[0] > maxCount) { + return NaN; + } + // Now also count down from center + i = startI + 1; + while (i < maxI && image.get(centerJ, i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i++; + } + if (i === maxI || stateCount[1] > maxCount) { + return NaN; + } + while (i < maxI && !image.get(centerJ, i) && stateCount[2] <= maxCount) { + stateCount[2]++; + i++; + } + if (stateCount[2] > maxCount) { + return NaN; + } + const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; + if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { + return NaN; + } + return this.foundPatternCross(stateCount) ? AlignmentPatternFinder.centerFromEnd(stateCount, i) : NaN; + } + /** + * <p>This is called when a horizontal scan finds a possible alignment pattern. It will + * cross check with a vertical scan, and if successful, will see if this pattern had been + * found on a previous horizontal scan. If so, we consider it confirmed and conclude we have + * found the alignment pattern.</p> + * + * @param stateCount reading state module counts from horizontal scan + * @param i row where alignment pattern may be found + * @param j end of possible alignment pattern in row + * @return {@link AlignmentPattern} if we have found the same pattern twice, or null if not + */ + handlePossibleCenter(stateCount, i /*int*/, j /*int*/) { + const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; + const centerJ = AlignmentPatternFinder.centerFromEnd(stateCount, j); + const centerI = this.crossCheckVertical(i, /*(int) */ centerJ, 2 * stateCount[1], stateCountTotal); + if (!isNaN(centerI)) { + const estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0; + for (const center of this.possibleCenters) { + // Look for about the same center and module size: + if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) { + return center.combineEstimate(centerI, centerJ, estimatedModuleSize); + } + } + // Hadn't found this before; save it + const point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize); + this.possibleCenters.push(point); + if (this.resultPointCallback !== null && this.resultPointCallback !== undefined) { + this.resultPointCallback.foundPossibleResultPoint(point); + } + } + return null; + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Encapsulates a finder pattern, which are the three square patterns found in + * the corners of QR Codes. It also encapsulates a count of similar finder patterns, + * as a convenience to the finder's bookkeeping.</p> + * + * @author Sean Owen + */ + class FinderPattern$1 extends ResultPoint { + // FinderPattern(posX: number/*float*/, posY: number/*float*/, estimatedModuleSize: number/*float*/) { + // this(posX, posY, estimatedModuleSize, 1) + // } + constructor(posX /*float*/, posY /*float*/, estimatedModuleSize /*float*/, count /*int*/) { + super(posX, posY); + this.estimatedModuleSize = estimatedModuleSize; + this.count = count; + if (undefined === count) { + this.count = 1; + } + } + getEstimatedModuleSize() { + return this.estimatedModuleSize; + } + getCount() { + return this.count; + } + /* + void incrementCount() { + this.count++ + } + */ + /** + * <p>Determines if this finder pattern "about equals" a finder pattern at the stated + * position and size -- meaning, it is at nearly the same center with nearly the same size.</p> + */ + aboutEquals(moduleSize /*float*/, i /*float*/, j /*float*/) { + if (Math.abs(i - this.getY()) <= moduleSize && Math.abs(j - this.getX()) <= moduleSize) { + const moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize); + return moduleSizeDiff <= 1.0 || moduleSizeDiff <= this.estimatedModuleSize; + } + return false; + } + /** + * Combines this object's current estimate of a finder pattern position and module size + * with a new estimate. It returns a new {@code FinderPattern} containing a weighted average + * based on count. + */ + combineEstimate(i /*float*/, j /*float*/, newModuleSize /*float*/) { + const combinedCount = this.count + 1; + const combinedX = (this.count * this.getX() + j) / combinedCount; + const combinedY = (this.count * this.getY() + i) / combinedCount; + const combinedModuleSize = (this.count * this.estimatedModuleSize + newModuleSize) / combinedCount; + return new FinderPattern$1(combinedX, combinedY, combinedModuleSize, combinedCount); + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>Encapsulates information about finder patterns in an image, including the location of + * the three finder patterns, and their estimated module size.</p> + * + * @author Sean Owen + */ + class FinderPatternInfo { + constructor(patternCenters) { + this.bottomLeft = patternCenters[0]; + this.topLeft = patternCenters[1]; + this.topRight = patternCenters[2]; + } + getBottomLeft() { + return this.bottomLeft; + } + getTopLeft() { + return this.topLeft; + } + getTopRight() { + return this.topRight; + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*import java.io.Serializable;*/ + /*import java.util.ArrayList;*/ + /*import java.util.Collections;*/ + /*import java.util.Comparator;*/ + /*import java.util.List;*/ + /*import java.util.Map;*/ + /** + * <p>This class attempts to find finder patterns in a QR Code. Finder patterns are the square + * markers at three corners of a QR Code.</p> + * + * <p>This class is thread-safe but not reentrant. Each thread must allocate its own object. + * + * @author Sean Owen + */ + class FinderPatternFinder { + /** + * <p>Creates a finder that will search the image for three finder patterns.</p> + * + * @param image image to search + */ + // public constructor(image: BitMatrix) { + // this(image, null) + // } + constructor(image, resultPointCallback) { + this.image = image; + this.resultPointCallback = resultPointCallback; + this.possibleCenters = []; + this.crossCheckStateCount = new Int32Array(5); + this.resultPointCallback = resultPointCallback; + } + getImage() { + return this.image; + } + getPossibleCenters() { + return this.possibleCenters; + } + find(hints) { + const tryHarder = (hints !== null && hints !== undefined) && undefined !== hints.get(DecodeHintType$1.TRY_HARDER); + const pureBarcode = (hints !== null && hints !== undefined) && undefined !== hints.get(DecodeHintType$1.PURE_BARCODE); + const image = this.image; + const maxI = image.getHeight(); + const maxJ = image.getWidth(); + // We are looking for black/white/black/white/black modules in + // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far + // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the + // image, and then account for the center being 3 modules in size. This gives the smallest + // number of pixels the center could be, so skip this often. When trying harder, look for all + // QR versions regardless of how dense they are. + let iSkip = Math.floor((3 * maxI) / (4 * FinderPatternFinder.MAX_MODULES)); + if (iSkip < FinderPatternFinder.MIN_SKIP || tryHarder) { + iSkip = FinderPatternFinder.MIN_SKIP; + } + let done = false; + const stateCount = new Int32Array(5); + for (let i = iSkip - 1; i < maxI && !done; i += iSkip) { + // Get a row of black/white values + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + stateCount[3] = 0; + stateCount[4] = 0; + let currentState = 0; + for (let j = 0; j < maxJ; j++) { + if (image.get(j, i)) { + // Black pixel + if ((currentState & 1) === 1) { // Counting white pixels + currentState++; + } + stateCount[currentState]++; + } + else { // White pixel + if ((currentState & 1) === 0) { // Counting black pixels + if (currentState === 4) { // A winner? + if (FinderPatternFinder.foundPatternCross(stateCount)) { // Yes + const confirmed = this.handlePossibleCenter(stateCount, i, j, pureBarcode); + if (confirmed === true) { + // Start examining every other line. Checking each line turned out to be too + // expensive and didn't improve performance. + iSkip = 2; + if (this.hasSkipped === true) { + done = this.haveMultiplyConfirmedCenters(); + } + else { + const rowSkip = this.findRowSkip(); + if (rowSkip > stateCount[2]) { + // Skip rows between row of lower confirmed center + // and top of presumed third confirmed center + // but back up a bit to get a full chance of detecting + // it, entire width of center of finder pattern + // Skip by rowSkip, but back off by stateCount[2] (size of last center + // of pattern we saw) to be conservative, and also back off by iSkip which + // is about to be re-added + i += rowSkip - stateCount[2] - iSkip; + j = maxJ - 1; + } + } + } + else { + stateCount[0] = stateCount[2]; + stateCount[1] = stateCount[3]; + stateCount[2] = stateCount[4]; + stateCount[3] = 1; + stateCount[4] = 0; + currentState = 3; + continue; + } + // Clear state to start looking again + currentState = 0; + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + stateCount[3] = 0; + stateCount[4] = 0; + } + else { // No, shift counts back by two + stateCount[0] = stateCount[2]; + stateCount[1] = stateCount[3]; + stateCount[2] = stateCount[4]; + stateCount[3] = 1; + stateCount[4] = 0; + currentState = 3; + } + } + else { + stateCount[++currentState]++; + } + } + else { // Counting white pixels + stateCount[currentState]++; + } + } + } + if (FinderPatternFinder.foundPatternCross(stateCount)) { + const confirmed = this.handlePossibleCenter(stateCount, i, maxJ, pureBarcode); + if (confirmed === true) { + iSkip = stateCount[0]; + if (this.hasSkipped) { + // Found a third one + done = this.haveMultiplyConfirmedCenters(); + } + } + } + } + const patternInfo = this.selectBestPatterns(); + ResultPoint.orderBestPatterns(patternInfo); + return new FinderPatternInfo(patternInfo); + } + /** + * Given a count of black/white/black/white/black pixels just seen and an end position, + * figures the location of the center of this run. + */ + static centerFromEnd(stateCount, end /*int*/) { + return (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0; + } + /** + * @param stateCount count of black/white/black/white/black pixels just read + * @return true iff the proportions of the counts is close enough to the 1/1/3/1/1 ratios + * used by finder patterns to be considered a match + */ + static foundPatternCross(stateCount) { + let totalModuleSize = 0; + for (let i = 0; i < 5; i++) { + const count = stateCount[i]; + if (count === 0) { + return false; + } + totalModuleSize += count; + } + if (totalModuleSize < 7) { + return false; + } + const moduleSize = totalModuleSize / 7.0; + const maxVariance = moduleSize / 2.0; + // Allow less than 50% variance from 1-1-3-1-1 proportions + return Math.abs(moduleSize - stateCount[0]) < maxVariance && + Math.abs(moduleSize - stateCount[1]) < maxVariance && + Math.abs(3.0 * moduleSize - stateCount[2]) < 3 * maxVariance && + Math.abs(moduleSize - stateCount[3]) < maxVariance && + Math.abs(moduleSize - stateCount[4]) < maxVariance; + } + getCrossCheckStateCount() { + const crossCheckStateCount = this.crossCheckStateCount; + crossCheckStateCount[0] = 0; + crossCheckStateCount[1] = 0; + crossCheckStateCount[2] = 0; + crossCheckStateCount[3] = 0; + crossCheckStateCount[4] = 0; + return crossCheckStateCount; + } + /** + * After a vertical and horizontal scan finds a potential finder pattern, this method + * "cross-cross-cross-checks" by scanning down diagonally through the center of the possible + * finder pattern to see if the same proportion is detected. + * + * @param startI row where a finder pattern was detected + * @param centerJ center of the section that appears to cross a finder pattern + * @param maxCount maximum reasonable number of modules that should be + * observed in any reading state, based on the results of the horizontal scan + * @param originalStateCountTotal The original state count total. + * @return true if proportions are withing expected limits + */ + crossCheckDiagonal(startI /*int*/, centerJ /*int*/, maxCount /*int*/, originalStateCountTotal /*int*/) { + const stateCount = this.getCrossCheckStateCount(); + // Start counting up, left from center finding black center mass + let i = 0; + const image = this.image; + while (startI >= i && centerJ >= i && image.get(centerJ - i, startI - i)) { + stateCount[2]++; + i++; + } + if (startI < i || centerJ < i) { + return false; + } + // Continue up, left finding white space + while (startI >= i && centerJ >= i && !image.get(centerJ - i, startI - i) && + stateCount[1] <= maxCount) { + stateCount[1]++; + i++; + } + // If already too many modules in this state or ran off the edge: + if (startI < i || centerJ < i || stateCount[1] > maxCount) { + return false; + } + // Continue up, left finding black border + while (startI >= i && centerJ >= i && image.get(centerJ - i, startI - i) && + stateCount[0] <= maxCount) { + stateCount[0]++; + i++; + } + if (stateCount[0] > maxCount) { + return false; + } + const maxI = image.getHeight(); + const maxJ = image.getWidth(); + // Now also count down, right from center + i = 1; + while (startI + i < maxI && centerJ + i < maxJ && image.get(centerJ + i, startI + i)) { + stateCount[2]++; + i++; + } + // Ran off the edge? + if (startI + i >= maxI || centerJ + i >= maxJ) { + return false; + } + while (startI + i < maxI && centerJ + i < maxJ && !image.get(centerJ + i, startI + i) && + stateCount[3] < maxCount) { + stateCount[3]++; + i++; + } + if (startI + i >= maxI || centerJ + i >= maxJ || stateCount[3] >= maxCount) { + return false; + } + while (startI + i < maxI && centerJ + i < maxJ && image.get(centerJ + i, startI + i) && + stateCount[4] < maxCount) { + stateCount[4]++; + i++; + } + if (stateCount[4] >= maxCount) { + return false; + } + // If we found a finder-pattern-like section, but its size is more than 100% different than + // the original, assume it's a false positive + const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; + return Math.abs(stateCountTotal - originalStateCountTotal) < 2 * originalStateCountTotal && + FinderPatternFinder.foundPatternCross(stateCount); + } + /** + * <p>After a horizontal scan finds a potential finder pattern, this method + * "cross-checks" by scanning down vertically through the center of the possible + * finder pattern to see if the same proportion is detected.</p> + * + * @param startI row where a finder pattern was detected + * @param centerJ center of the section that appears to cross a finder pattern + * @param maxCount maximum reasonable number of modules that should be + * observed in any reading state, based on the results of the horizontal scan + * @return vertical center of finder pattern, or {@link Float#NaN} if not found + */ + crossCheckVertical(startI /*int*/, centerJ /*int*/, maxCount /*int*/, originalStateCountTotal /*int*/) { + const image = this.image; + const maxI = image.getHeight(); + const stateCount = this.getCrossCheckStateCount(); + // Start counting up from center + let i = startI; + while (i >= 0 && image.get(centerJ, i)) { + stateCount[2]++; + i--; + } + if (i < 0) { + return NaN; + } + while (i >= 0 && !image.get(centerJ, i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i--; + } + // If already too many modules in this state or ran off the edge: + if (i < 0 || stateCount[1] > maxCount) { + return NaN; + } + while (i >= 0 && image.get(centerJ, i) && stateCount[0] <= maxCount) { + stateCount[0]++; + i--; + } + if (stateCount[0] > maxCount) { + return NaN; + } + // Now also count down from center + i = startI + 1; + while (i < maxI && image.get(centerJ, i)) { + stateCount[2]++; + i++; + } + if (i === maxI) { + return NaN; + } + while (i < maxI && !image.get(centerJ, i) && stateCount[3] < maxCount) { + stateCount[3]++; + i++; + } + if (i === maxI || stateCount[3] >= maxCount) { + return NaN; + } + while (i < maxI && image.get(centerJ, i) && stateCount[4] < maxCount) { + stateCount[4]++; + i++; + } + if (stateCount[4] >= maxCount) { + return NaN; + } + // If we found a finder-pattern-like section, but its size is more than 40% different than + // the original, assume it's a false positive + const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + + stateCount[4]; + if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { + return NaN; + } + return FinderPatternFinder.foundPatternCross(stateCount) ? FinderPatternFinder.centerFromEnd(stateCount, i) : NaN; + } + /** + * <p>Like {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical, + * except it reads horizontally instead of vertically. This is used to cross-cross + * check a vertical cross check and locate the real center of the alignment pattern.</p> + */ + crossCheckHorizontal(startJ /*int*/, centerI /*int*/, maxCount /*int*/, originalStateCountTotal /*int*/) { + const image = this.image; + const maxJ = image.getWidth(); + const stateCount = this.getCrossCheckStateCount(); + let j = startJ; + while (j >= 0 && image.get(j, centerI)) { + stateCount[2]++; + j--; + } + if (j < 0) { + return NaN; + } + while (j >= 0 && !image.get(j, centerI) && stateCount[1] <= maxCount) { + stateCount[1]++; + j--; + } + if (j < 0 || stateCount[1] > maxCount) { + return NaN; + } + while (j >= 0 && image.get(j, centerI) && stateCount[0] <= maxCount) { + stateCount[0]++; + j--; + } + if (stateCount[0] > maxCount) { + return NaN; + } + j = startJ + 1; + while (j < maxJ && image.get(j, centerI)) { + stateCount[2]++; + j++; + } + if (j === maxJ) { + return NaN; + } + while (j < maxJ && !image.get(j, centerI) && stateCount[3] < maxCount) { + stateCount[3]++; + j++; + } + if (j === maxJ || stateCount[3] >= maxCount) { + return NaN; + } + while (j < maxJ && image.get(j, centerI) && stateCount[4] < maxCount) { + stateCount[4]++; + j++; + } + if (stateCount[4] >= maxCount) { + return NaN; + } + // If we found a finder-pattern-like section, but its size is significantly different than + // the original, assume it's a false positive + const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + + stateCount[4]; + if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal) { + return NaN; + } + return FinderPatternFinder.foundPatternCross(stateCount) ? FinderPatternFinder.centerFromEnd(stateCount, j) : NaN; + } + /** + * <p>This is called when a horizontal scan finds a possible alignment pattern. It will + * cross check with a vertical scan, and if successful, will, ah, cross-cross-check + * with another horizontal scan. This is needed primarily to locate the real horizontal + * center of the pattern in cases of extreme skew. + * And then we cross-cross-cross check with another diagonal scan.</p> + * + * <p>If that succeeds the finder pattern location is added to a list that tracks + * the number of times each location has been nearly-matched as a finder pattern. + * Each additional find is more evidence that the location is in fact a finder + * pattern center + * + * @param stateCount reading state module counts from horizontal scan + * @param i row where finder pattern may be found + * @param j end of possible finder pattern in row + * @param pureBarcode true if in "pure barcode" mode + * @return true if a finder pattern candidate was found this time + */ + handlePossibleCenter(stateCount, i /*int*/, j /*int*/, pureBarcode) { + const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + + stateCount[4]; + let centerJ = FinderPatternFinder.centerFromEnd(stateCount, j); + let centerI = this.crossCheckVertical(i, /*(int) */ Math.floor(centerJ), stateCount[2], stateCountTotal); + if (!isNaN(centerI)) { + // Re-cross check + centerJ = this.crossCheckHorizontal(/*(int) */ Math.floor(centerJ), /*(int) */ Math.floor(centerI), stateCount[2], stateCountTotal); + if (!isNaN(centerJ) && + (!pureBarcode || this.crossCheckDiagonal(/*(int) */ Math.floor(centerI), /*(int) */ Math.floor(centerJ), stateCount[2], stateCountTotal))) { + const estimatedModuleSize = stateCountTotal / 7.0; + let found = false; + const possibleCenters = this.possibleCenters; + for (let index = 0, length = possibleCenters.length; index < length; index++) { + const center = possibleCenters[index]; + // Look for about the same center and module size: + if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) { + possibleCenters[index] = center.combineEstimate(centerI, centerJ, estimatedModuleSize); + found = true; + break; + } + } + if (!found) { + const point = new FinderPattern$1(centerJ, centerI, estimatedModuleSize); + possibleCenters.push(point); + if (this.resultPointCallback !== null && this.resultPointCallback !== undefined) { + this.resultPointCallback.foundPossibleResultPoint(point); + } + } + return true; + } + } + return false; + } + /** + * @return number of rows we could safely skip during scanning, based on the first + * two finder patterns that have been located. In some cases their position will + * allow us to infer that the third pattern must lie below a certain point farther + * down in the image. + */ + findRowSkip() { + const max = this.possibleCenters.length; + if (max <= 1) { + return 0; + } + let firstConfirmedCenter = null; + for (const center of this.possibleCenters) { + if (center.getCount() >= FinderPatternFinder.CENTER_QUORUM) { + if (firstConfirmedCenter == null) { + firstConfirmedCenter = center; + } + else { + // We have two confirmed centers + // How far down can we skip before resuming looking for the next + // pattern? In the worst case, only the difference between the + // difference in the x / y coordinates of the two centers. + // This is the case where you find top left last. + this.hasSkipped = true; + return /*(int) */ Math.floor((Math.abs(firstConfirmedCenter.getX() - center.getX()) - + Math.abs(firstConfirmedCenter.getY() - center.getY())) / 2); + } + } + } + return 0; + } + /** + * @return true iff we have found at least 3 finder patterns that have been detected + * at least {@link #CENTER_QUORUM} times each, and, the estimated module size of the + * candidates is "pretty similar" + */ + haveMultiplyConfirmedCenters() { + let confirmedCount = 0; + let totalModuleSize = 0.0; + const max = this.possibleCenters.length; + for (const pattern of this.possibleCenters) { + if (pattern.getCount() >= FinderPatternFinder.CENTER_QUORUM) { + confirmedCount++; + totalModuleSize += pattern.getEstimatedModuleSize(); + } + } + if (confirmedCount < 3) { + return false; + } + // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive" + // and that we need to keep looking. We detect this by asking if the estimated module sizes + // vary too much. We arbitrarily say that when the total deviation from average exceeds + // 5% of the total module size estimates, it's too much. + const average = totalModuleSize / max; + let totalDeviation = 0.0; + for (const pattern of this.possibleCenters) { + totalDeviation += Math.abs(pattern.getEstimatedModuleSize() - average); + } + return totalDeviation <= 0.05 * totalModuleSize; + } + /** + * @return the 3 best {@link FinderPattern}s from our list of candidates. The "best" are + * those that have been detected at least {@link #CENTER_QUORUM} times, and whose module + * size differs from the average among those patterns the least + * @throws NotFoundException if 3 such finder patterns do not exist + */ + selectBestPatterns() { + const startSize = this.possibleCenters.length; + if (startSize < 3) { + // Couldn't find enough finder patterns + throw new NotFoundException(); + } + const possibleCenters = this.possibleCenters; + let average; + // Filter outlier possibilities whose module size is too different + if (startSize > 3) { + // But we can only afford to do so if we have at least 4 possibilities to choose from + let totalModuleSize = 0.0; + let square = 0.0; + for (const center of this.possibleCenters) { + const size = center.getEstimatedModuleSize(); + totalModuleSize += size; + square += size * size; + } + average = totalModuleSize / startSize; + let stdDev = Math.sqrt(square / startSize - average * average); + possibleCenters.sort( + /** + * <p>Orders by furthest from average</p> + */ + // FurthestFromAverageComparator implements Comparator<FinderPattern> + (center1, center2) => { + const dA = Math.abs(center2.getEstimatedModuleSize() - average); + const dB = Math.abs(center1.getEstimatedModuleSize() - average); + return dA < dB ? -1 : dA > dB ? 1 : 0; + }); + const limit = Math.max(0.2 * average, stdDev); + for (let i = 0; i < possibleCenters.length && possibleCenters.length > 3; i++) { + const pattern = possibleCenters[i]; + if (Math.abs(pattern.getEstimatedModuleSize() - average) > limit) { + possibleCenters.splice(i, 1); + i--; + } + } + } + if (possibleCenters.length > 3) { + // Throw away all but those first size candidate points we found. + let totalModuleSize = 0.0; + for (const possibleCenter of possibleCenters) { + totalModuleSize += possibleCenter.getEstimatedModuleSize(); + } + average = totalModuleSize / possibleCenters.length; + possibleCenters.sort( + /** + * <p>Orders by {@link FinderPattern#getCount()}, descending.</p> + */ + // CenterComparator implements Comparator<FinderPattern> + (center1, center2) => { + if (center2.getCount() === center1.getCount()) { + const dA = Math.abs(center2.getEstimatedModuleSize() - average); + const dB = Math.abs(center1.getEstimatedModuleSize() - average); + return dA < dB ? 1 : dA > dB ? -1 : 0; + } + else { + return center2.getCount() - center1.getCount(); + } + }); + possibleCenters.splice(3); // this is not realy necessary as we only return first 3 anyway + } + return [ + possibleCenters[0], + possibleCenters[1], + possibleCenters[2] + ]; + } + } + FinderPatternFinder.CENTER_QUORUM = 2; + FinderPatternFinder.MIN_SKIP = 3; // 1 pixel/module times 3 modules/center + FinderPatternFinder.MAX_MODULES = 57; // support up to version 10 for mobile clients + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*import java.util.Map;*/ + /** + * <p>Encapsulates logic that can detect a QR Code in an image, even if the QR Code + * is rotated or skewed, or partially obscured.</p> + * + * @author Sean Owen + */ + class Detector$2 { + constructor(image) { + this.image = image; + } + getImage() { + return this.image; + } + getResultPointCallback() { + return this.resultPointCallback; + } + /** + * <p>Detects a QR Code in an image.</p> + * + * @return {@link DetectorResult} encapsulating results of detecting a QR Code + * @throws NotFoundException if QR Code cannot be found + * @throws FormatException if a QR Code cannot be decoded + */ + // public detect(): DetectorResult /*throws NotFoundException, FormatException*/ { + // return detect(null) + // } + /** + * <p>Detects a QR Code in an image.</p> + * + * @param hints optional hints to detector + * @return {@link DetectorResult} encapsulating results of detecting a QR Code + * @throws NotFoundException if QR Code cannot be found + * @throws FormatException if a QR Code cannot be decoded + */ + detect(hints) { + this.resultPointCallback = (hints === null || hints === undefined) ? null : + /*(ResultPointCallback) */ hints.get(DecodeHintType$1.NEED_RESULT_POINT_CALLBACK); + const finder = new FinderPatternFinder(this.image, this.resultPointCallback); + const info = finder.find(hints); + return this.processFinderPatternInfo(info); + } + processFinderPatternInfo(info) { + const topLeft = info.getTopLeft(); + const topRight = info.getTopRight(); + const bottomLeft = info.getBottomLeft(); + const moduleSize = this.calculateModuleSize(topLeft, topRight, bottomLeft); + if (moduleSize < 1.0) { + throw new NotFoundException('No pattern found in proccess finder.'); + } + const dimension = Detector$2.computeDimension(topLeft, topRight, bottomLeft, moduleSize); + const provisionalVersion = Version$1.getProvisionalVersionForDimension(dimension); + const modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7; + let alignmentPattern = null; + // Anything above version 1 has an alignment pattern + if (provisionalVersion.getAlignmentPatternCenters().length > 0) { + // Guess where a "bottom right" finder pattern would have been + const bottomRightX = topRight.getX() - topLeft.getX() + bottomLeft.getX(); + const bottomRightY = topRight.getY() - topLeft.getY() + bottomLeft.getY(); + // Estimate that alignment pattern is closer by 3 modules + // from "bottom right" to known top left location + const correctionToTopLeft = 1.0 - 3.0 / modulesBetweenFPCenters; + const estAlignmentX = /*(int) */ Math.floor(topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX())); + const estAlignmentY = /*(int) */ Math.floor(topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY())); + // Kind of arbitrary -- expand search radius before giving up + for (let i = 4; i <= 16; i <<= 1) { + try { + alignmentPattern = this.findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, i); + break; + } + catch (re /*NotFoundException*/) { + if (!(re instanceof NotFoundException)) { + throw re; + } + // try next round + } + } + // If we didn't find alignment pattern... well try anyway without it + } + const transform = Detector$2.createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension); + const bits = Detector$2.sampleGrid(this.image, transform, dimension); + let points; + if (alignmentPattern === null) { + points = [bottomLeft, topLeft, topRight]; + } + else { + points = [bottomLeft, topLeft, topRight, alignmentPattern]; + } + return new DetectorResult(bits, points); + } + static createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension /*int*/) { + const dimMinusThree = dimension - 3.5; + let bottomRightX; /*float*/ + let bottomRightY; /*float*/ + let sourceBottomRightX; /*float*/ + let sourceBottomRightY; /*float*/ + if (alignmentPattern !== null) { + bottomRightX = alignmentPattern.getX(); + bottomRightY = alignmentPattern.getY(); + sourceBottomRightX = dimMinusThree - 3.0; + sourceBottomRightY = sourceBottomRightX; + } + else { + // Don't have an alignment pattern, just make up the bottom-right point + bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX(); + bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY(); + sourceBottomRightX = dimMinusThree; + sourceBottomRightY = dimMinusThree; + } + return PerspectiveTransform.quadrilateralToQuadrilateral(3.5, 3.5, dimMinusThree, 3.5, sourceBottomRightX, sourceBottomRightY, 3.5, dimMinusThree, topLeft.getX(), topLeft.getY(), topRight.getX(), topRight.getY(), bottomRightX, bottomRightY, bottomLeft.getX(), bottomLeft.getY()); + } + static sampleGrid(image, transform, dimension /*int*/) { + const sampler = GridSamplerInstance.getInstance(); + return sampler.sampleGridWithTransform(image, dimension, dimension, transform); + } + /** + * <p>Computes the dimension (number of modules on a size) of the QR Code based on the position + * of the finder patterns and estimated module size.</p> + */ + static computeDimension(topLeft, topRight, bottomLeft, moduleSize /*float*/) { + const tltrCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleSize); + const tlblCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleSize); + let dimension = Math.floor((tltrCentersDimension + tlblCentersDimension) / 2) + 7; + switch (dimension & 0x03) { // mod 4 + case 0: + dimension++; + break; + // 1? do nothing + case 2: + dimension--; + break; + case 3: + throw new NotFoundException('Dimensions could be not found.'); + } + return dimension; + } + /** + * <p>Computes an average estimated module size based on estimated derived from the positions + * of the three finder patterns.</p> + * + * @param topLeft detected top-left finder pattern center + * @param topRight detected top-right finder pattern center + * @param bottomLeft detected bottom-left finder pattern center + * @return estimated module size + */ + calculateModuleSize(topLeft, topRight, bottomLeft) { + // Take the average + return (this.calculateModuleSizeOneWay(topLeft, topRight) + + this.calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0; + } + /** + * <p>Estimates module size based on two finder patterns -- it uses + * {@link #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int)} to figure the + * width of each, measuring along the axis between their centers.</p> + */ + calculateModuleSizeOneWay(pattern, otherPattern) { + const moduleSizeEst1 = this.sizeOfBlackWhiteBlackRunBothWays(/*(int) */ Math.floor(pattern.getX()), + /*(int) */ Math.floor(pattern.getY()), + /*(int) */ Math.floor(otherPattern.getX()), + /*(int) */ Math.floor(otherPattern.getY())); + const moduleSizeEst2 = this.sizeOfBlackWhiteBlackRunBothWays(/*(int) */ Math.floor(otherPattern.getX()), + /*(int) */ Math.floor(otherPattern.getY()), + /*(int) */ Math.floor(pattern.getX()), + /*(int) */ Math.floor(pattern.getY())); + if (isNaN(moduleSizeEst1)) { + return moduleSizeEst2 / 7.0; + } + if (isNaN(moduleSizeEst2)) { + return moduleSizeEst1 / 7.0; + } + // Average them, and divide by 7 since we've counted the width of 3 black modules, + // and 1 white and 1 black module on either side. Ergo, divide sum by 14. + return (moduleSizeEst1 + moduleSizeEst2) / 14.0; + } + /** + * See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of + * a finder pattern by looking for a black-white-black run from the center in the direction + * of another point (another finder pattern center), and in the opposite direction too. + */ + sizeOfBlackWhiteBlackRunBothWays(fromX /*int*/, fromY /*int*/, toX /*int*/, toY /*int*/) { + let result = this.sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY); + // Now count other way -- don't run off image though of course + let scale = 1.0; + let otherToX = fromX - (toX - fromX); + if (otherToX < 0) { + scale = fromX / /*(float) */ (fromX - otherToX); + otherToX = 0; + } + else if (otherToX >= this.image.getWidth()) { + scale = (this.image.getWidth() - 1 - fromX) / /*(float) */ (otherToX - fromX); + otherToX = this.image.getWidth() - 1; + } + let otherToY = /*(int) */ Math.floor(fromY - (toY - fromY) * scale); + scale = 1.0; + if (otherToY < 0) { + scale = fromY / /*(float) */ (fromY - otherToY); + otherToY = 0; + } + else if (otherToY >= this.image.getHeight()) { + scale = (this.image.getHeight() - 1 - fromY) / /*(float) */ (otherToY - fromY); + otherToY = this.image.getHeight() - 1; + } + otherToX = /*(int) */ Math.floor(fromX + (otherToX - fromX) * scale); + result += this.sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY); + // Middle pixel is double-counted this way; subtract 1 + return result - 1.0; + } + /** + * <p>This method traces a line from a point in the image, in the direction towards another point. + * It begins in a black region, and keeps going until it finds white, then black, then white again. + * It reports the distance from the start to this point.</p> + * + * <p>This is used when figuring out how wide a finder pattern is, when the finder pattern + * may be skewed or rotated.</p> + */ + sizeOfBlackWhiteBlackRun(fromX /*int*/, fromY /*int*/, toX /*int*/, toY /*int*/) { + // Mild variant of Bresenham's algorithm + // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm + const steep = Math.abs(toY - fromY) > Math.abs(toX - fromX); + if (steep) { + let temp = fromX; + fromX = fromY; + fromY = temp; + temp = toX; + toX = toY; + toY = temp; + } + const dx = Math.abs(toX - fromX); + const dy = Math.abs(toY - fromY); + let error = -dx / 2; + const xstep = fromX < toX ? 1 : -1; + const ystep = fromY < toY ? 1 : -1; + // In black pixels, looking for white, first or second time. + let state = 0; + // Loop up until x == toX, but not beyond + const xLimit = toX + xstep; + for (let x = fromX, y = fromY; x !== xLimit; x += xstep) { + const realX = steep ? y : x; + const realY = steep ? x : y; + // Does current pixel mean we have moved white to black or vice versa? + // Scanning black in state 0,2 and white in state 1, so if we find the wrong + // color, advance to next state or end if we are in state 2 already + if ((state === 1) === this.image.get(realX, realY)) { + if (state === 2) { + return MathUtils.distance(x, y, fromX, fromY); + } + state++; + } + error += dy; + if (error > 0) { + if (y === toY) { + break; + } + y += ystep; + error -= dx; + } + } + // Found black-white-black; give the benefit of the doubt that the next pixel outside the image + // is "white" so this last point at (toX+xStep,toY) is the right ending. This is really a + // small approximation; (toX+xStep,toY+yStep) might be really correct. Ignore this. + if (state === 2) { + return MathUtils.distance(toX + xstep, toY, fromX, fromY); + } + // else we didn't find even black-white-black; no estimate is really possible + return NaN; + } + /** + * <p>Attempts to locate an alignment pattern in a limited region of the image, which is + * guessed to contain it. This method uses {@link AlignmentPattern}.</p> + * + * @param overallEstModuleSize estimated module size so far + * @param estAlignmentX x coordinate of center of area probably containing alignment pattern + * @param estAlignmentY y coordinate of above + * @param allowanceFactor number of pixels in all directions to search from the center + * @return {@link AlignmentPattern} if found, or null otherwise + * @throws NotFoundException if an unexpected error occurs during detection + */ + findAlignmentInRegion(overallEstModuleSize /*float*/, estAlignmentX /*int*/, estAlignmentY /*int*/, allowanceFactor /*float*/) { + // Look for an alignment pattern (3 modules in size) around where it + // should be + const allowance = /*(int) */ Math.floor(allowanceFactor * overallEstModuleSize); + const alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance); + const alignmentAreaRightX = Math.min(this.image.getWidth() - 1, estAlignmentX + allowance); + if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) { + throw new NotFoundException('Alignment top exceeds estimated module size.'); + } + const alignmentAreaTopY = Math.max(0, estAlignmentY - allowance); + const alignmentAreaBottomY = Math.min(this.image.getHeight() - 1, estAlignmentY + allowance); + if (alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize * 3) { + throw new NotFoundException('Alignment bottom exceeds estimated module size.'); + } + const alignmentFinder = new AlignmentPatternFinder(this.image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, this.resultPointCallback); + return alignmentFinder.find(); + } + } + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*import java.util.List;*/ + /*import java.util.Map;*/ + /** + * This implementation can detect and decode QR Codes in an image. + * + * @author Sean Owen + */ + class QRCodeReader { + constructor() { + this.decoder = new Decoder$2(); + } + getDecoder() { + return this.decoder; + } + /** + * Locates and decodes a QR code in an image. + * + * @return a representing: string the content encoded by the QR code + * @throws NotFoundException if a QR code cannot be found + * @throws FormatException if a QR code cannot be decoded + * @throws ChecksumException if error correction fails + */ + /*@Override*/ + // public decode(image: BinaryBitmap): Result /*throws NotFoundException, ChecksumException, FormatException */ { + // return this.decode(image, null) + // } + /*@Override*/ + decode(image, hints) { + let decoderResult; + let points; + if (hints !== undefined && hints !== null && undefined !== hints.get(DecodeHintType$1.PURE_BARCODE)) { + const bits = QRCodeReader.extractPureBits(image.getBlackMatrix()); + decoderResult = this.decoder.decodeBitMatrix(bits, hints); + points = QRCodeReader.NO_POINTS; + } + else { + const detectorResult = new Detector$2(image.getBlackMatrix()).detect(hints); + decoderResult = this.decoder.decodeBitMatrix(detectorResult.getBits(), hints); + points = detectorResult.getPoints(); + } + // If the code was mirrored: swap the bottom-left and the top-right points. + if (decoderResult.getOther() instanceof QRCodeDecoderMetaData) { + decoderResult.getOther().applyMirroredCorrection(points); + } + const result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), undefined, points, BarcodeFormat$1.QR_CODE, undefined); + const byteSegments = decoderResult.getByteSegments(); + if (byteSegments !== null) { + result.putMetadata(ResultMetadataType$1.BYTE_SEGMENTS, byteSegments); + } + const ecLevel = decoderResult.getECLevel(); + if (ecLevel !== null) { + result.putMetadata(ResultMetadataType$1.ERROR_CORRECTION_LEVEL, ecLevel); + } + if (decoderResult.hasStructuredAppend()) { + result.putMetadata(ResultMetadataType$1.STRUCTURED_APPEND_SEQUENCE, decoderResult.getStructuredAppendSequenceNumber()); + result.putMetadata(ResultMetadataType$1.STRUCTURED_APPEND_PARITY, decoderResult.getStructuredAppendParity()); + } + return result; + } + /*@Override*/ + reset() { + // do nothing + } + /** + * This method detects a code in a "pure" image -- that is, pure monochrome image + * which contains only an unrotated, unskewed, image of a code, with some white border + * around it. This is a specialized method that works exceptionally fast in this special + * case. + * + * @see com.google.zxing.datamatrix.DataMatrixReader#extractPureBits(BitMatrix) + */ + static extractPureBits(image) { + const leftTopBlack = image.getTopLeftOnBit(); + const rightBottomBlack = image.getBottomRightOnBit(); + if (leftTopBlack === null || rightBottomBlack === null) { + throw new NotFoundException(); + } + const moduleSize = this.moduleSize(leftTopBlack, image); + let top = leftTopBlack[1]; + let bottom = rightBottomBlack[1]; + let left = leftTopBlack[0]; + let right = rightBottomBlack[0]; + // Sanity check! + if (left >= right || top >= bottom) { + throw new NotFoundException(); + } + if (bottom - top !== right - left) { + // Special case, where bottom-right module wasn't black so we found something else in the last row + // Assume it's a square, so use height as the width + right = left + (bottom - top); + if (right >= image.getWidth()) { + // Abort if that would not make sense -- off image + throw new NotFoundException(); + } + } + const matrixWidth = Math.round((right - left + 1) / moduleSize); + const matrixHeight = Math.round((bottom - top + 1) / moduleSize); + if (matrixWidth <= 0 || matrixHeight <= 0) { + throw new NotFoundException(); + } + if (matrixHeight !== matrixWidth) { + // Only possibly decode square regions + throw new NotFoundException(); + } + // Push in the "border" by half the module width so that we start + // sampling in the middle of the module. Just in case the image is a + // little off, this will help recover. + const nudge = /*(int) */ Math.floor(moduleSize / 2.0); + top += nudge; + left += nudge; + // But careful that this does not sample off the edge + // "right" is the farthest-right valid pixel location -- right+1 is not necessarily + // This is positive by how much the inner x loop below would be too large + const nudgedTooFarRight = left + /*(int) */ Math.floor((matrixWidth - 1) * moduleSize) - right; + if (nudgedTooFarRight > 0) { + if (nudgedTooFarRight > nudge) { + // Neither way fits; abort + throw new NotFoundException(); + } + left -= nudgedTooFarRight; + } + // See logic above + const nudgedTooFarDown = top + /*(int) */ Math.floor((matrixHeight - 1) * moduleSize) - bottom; + if (nudgedTooFarDown > 0) { + if (nudgedTooFarDown > nudge) { + // Neither way fits; abort + throw new NotFoundException(); + } + top -= nudgedTooFarDown; + } + // Now just read off the bits + const bits = new BitMatrix(matrixWidth, matrixHeight); + for (let y = 0; y < matrixHeight; y++) { + const iOffset = top + /*(int) */ Math.floor(y * moduleSize); + for (let x = 0; x < matrixWidth; x++) { + if (image.get(left + /*(int) */ Math.floor(x * moduleSize), iOffset)) { + bits.set(x, y); + } + } + } + return bits; + } + static moduleSize(leftTopBlack, image) { + const height = image.getHeight(); + const width = image.getWidth(); + let x = leftTopBlack[0]; + let y = leftTopBlack[1]; + let inBlack = true; + let transitions = 0; + while (x < width && y < height) { + if (inBlack !== image.get(x, y)) { + if (++transitions === 5) { + break; + } + inBlack = !inBlack; + } + x++; + y++; + } + if (x === width || y === height) { + throw new NotFoundException(); + } + return (x - leftTopBlack[0]) / 7.0; + } + } + QRCodeReader.NO_POINTS = new Array(); + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * @author SITA Lab (kevin.osullivan@sita.aero) + * @author Guenther Grau + */ + /*public final*/ class PDF417Common { + PDF417Common() { + } + /** + * @param moduleBitCount values to sum + * @return sum of values + * @deprecated call {@link MathUtils#sum(int[])} + */ + // @Deprecated + static getBitCountSum(moduleBitCount) { + return MathUtils.sum(moduleBitCount); + } + static toIntArray(list) { + if (list == null || !list.length) { + return PDF417Common.EMPTY_INT_ARRAY; + } + const result = new Int32Array(list.length); + let i = 0; + for (const integer of list) { + result[i++] = integer; + } + return result; + } + /** + * @param symbol encoded symbol to translate to a codeword + * @return the codeword corresponding to the symbol. + */ + static getCodeword(symbol /*int*/) { + const i = Arrays.binarySearch(PDF417Common.SYMBOL_TABLE, symbol & 0x3FFFF); + if (i < 0) { + return -1; + } + return (PDF417Common.CODEWORD_TABLE[i] - 1) % PDF417Common.NUMBER_OF_CODEWORDS; + } + } + PDF417Common.NUMBER_OF_CODEWORDS = 929; + // Maximum Codewords (Data + Error). + PDF417Common.MAX_CODEWORDS_IN_BARCODE = PDF417Common.NUMBER_OF_CODEWORDS - 1; + PDF417Common.MIN_ROWS_IN_BARCODE = 3; + PDF417Common.MAX_ROWS_IN_BARCODE = 90; + // One left row indication column + max 30 data columns + one right row indicator column + // public static /*final*/ MAX_CODEWORDS_IN_ROW: /*int*/ number = 32; + PDF417Common.MODULES_IN_CODEWORD = 17; + PDF417Common.MODULES_IN_STOP_PATTERN = 18; + PDF417Common.BARS_IN_MODULE = 8; + PDF417Common.EMPTY_INT_ARRAY = new Int32Array([]); + /** + * The sorted table of all possible symbols. Extracted from the PDF417 + * specification. The index of a symbol in this table corresponds to the + * index into the codeword table. + */ + PDF417Common.SYMBOL_TABLE = Int32Array.from([ + 0x1025e, 0x1027a, 0x1029e, 0x102bc, 0x102f2, 0x102f4, 0x1032e, 0x1034e, 0x1035c, 0x10396, 0x103a6, 0x103ac, + 0x10422, 0x10428, 0x10436, 0x10442, 0x10444, 0x10448, 0x10450, 0x1045e, 0x10466, 0x1046c, 0x1047a, 0x10482, + 0x1049e, 0x104a0, 0x104bc, 0x104c6, 0x104d8, 0x104ee, 0x104f2, 0x104f4, 0x10504, 0x10508, 0x10510, 0x1051e, + 0x10520, 0x1053c, 0x10540, 0x10578, 0x10586, 0x1058c, 0x10598, 0x105b0, 0x105be, 0x105ce, 0x105dc, 0x105e2, + 0x105e4, 0x105e8, 0x105f6, 0x1062e, 0x1064e, 0x1065c, 0x1068e, 0x1069c, 0x106b8, 0x106de, 0x106fa, 0x10716, + 0x10726, 0x1072c, 0x10746, 0x1074c, 0x10758, 0x1076e, 0x10792, 0x10794, 0x107a2, 0x107a4, 0x107a8, 0x107b6, + 0x10822, 0x10828, 0x10842, 0x10848, 0x10850, 0x1085e, 0x10866, 0x1086c, 0x1087a, 0x10882, 0x10884, 0x10890, + 0x1089e, 0x108a0, 0x108bc, 0x108c6, 0x108cc, 0x108d8, 0x108ee, 0x108f2, 0x108f4, 0x10902, 0x10908, 0x1091e, + 0x10920, 0x1093c, 0x10940, 0x10978, 0x10986, 0x10998, 0x109b0, 0x109be, 0x109ce, 0x109dc, 0x109e2, 0x109e4, + 0x109e8, 0x109f6, 0x10a08, 0x10a10, 0x10a1e, 0x10a20, 0x10a3c, 0x10a40, 0x10a78, 0x10af0, 0x10b06, 0x10b0c, + 0x10b18, 0x10b30, 0x10b3e, 0x10b60, 0x10b7c, 0x10b8e, 0x10b9c, 0x10bb8, 0x10bc2, 0x10bc4, 0x10bc8, 0x10bd0, + 0x10bde, 0x10be6, 0x10bec, 0x10c2e, 0x10c4e, 0x10c5c, 0x10c62, 0x10c64, 0x10c68, 0x10c76, 0x10c8e, 0x10c9c, + 0x10cb8, 0x10cc2, 0x10cc4, 0x10cc8, 0x10cd0, 0x10cde, 0x10ce6, 0x10cec, 0x10cfa, 0x10d0e, 0x10d1c, 0x10d38, + 0x10d70, 0x10d7e, 0x10d82, 0x10d84, 0x10d88, 0x10d90, 0x10d9e, 0x10da0, 0x10dbc, 0x10dc6, 0x10dcc, 0x10dd8, + 0x10dee, 0x10df2, 0x10df4, 0x10e16, 0x10e26, 0x10e2c, 0x10e46, 0x10e58, 0x10e6e, 0x10e86, 0x10e8c, 0x10e98, + 0x10eb0, 0x10ebe, 0x10ece, 0x10edc, 0x10f0a, 0x10f12, 0x10f14, 0x10f22, 0x10f28, 0x10f36, 0x10f42, 0x10f44, + 0x10f48, 0x10f50, 0x10f5e, 0x10f66, 0x10f6c, 0x10fb2, 0x10fb4, 0x11022, 0x11028, 0x11042, 0x11048, 0x11050, + 0x1105e, 0x1107a, 0x11082, 0x11084, 0x11090, 0x1109e, 0x110a0, 0x110bc, 0x110c6, 0x110cc, 0x110d8, 0x110ee, + 0x110f2, 0x110f4, 0x11102, 0x1111e, 0x11120, 0x1113c, 0x11140, 0x11178, 0x11186, 0x11198, 0x111b0, 0x111be, + 0x111ce, 0x111dc, 0x111e2, 0x111e4, 0x111e8, 0x111f6, 0x11208, 0x1121e, 0x11220, 0x11278, 0x112f0, 0x1130c, + 0x11330, 0x1133e, 0x11360, 0x1137c, 0x1138e, 0x1139c, 0x113b8, 0x113c2, 0x113c8, 0x113d0, 0x113de, 0x113e6, + 0x113ec, 0x11408, 0x11410, 0x1141e, 0x11420, 0x1143c, 0x11440, 0x11478, 0x114f0, 0x115e0, 0x1160c, 0x11618, + 0x11630, 0x1163e, 0x11660, 0x1167c, 0x116c0, 0x116f8, 0x1171c, 0x11738, 0x11770, 0x1177e, 0x11782, 0x11784, + 0x11788, 0x11790, 0x1179e, 0x117a0, 0x117bc, 0x117c6, 0x117cc, 0x117d8, 0x117ee, 0x1182e, 0x11834, 0x1184e, + 0x1185c, 0x11862, 0x11864, 0x11868, 0x11876, 0x1188e, 0x1189c, 0x118b8, 0x118c2, 0x118c8, 0x118d0, 0x118de, + 0x118e6, 0x118ec, 0x118fa, 0x1190e, 0x1191c, 0x11938, 0x11970, 0x1197e, 0x11982, 0x11984, 0x11990, 0x1199e, + 0x119a0, 0x119bc, 0x119c6, 0x119cc, 0x119d8, 0x119ee, 0x119f2, 0x119f4, 0x11a0e, 0x11a1c, 0x11a38, 0x11a70, + 0x11a7e, 0x11ae0, 0x11afc, 0x11b08, 0x11b10, 0x11b1e, 0x11b20, 0x11b3c, 0x11b40, 0x11b78, 0x11b8c, 0x11b98, + 0x11bb0, 0x11bbe, 0x11bce, 0x11bdc, 0x11be2, 0x11be4, 0x11be8, 0x11bf6, 0x11c16, 0x11c26, 0x11c2c, 0x11c46, + 0x11c4c, 0x11c58, 0x11c6e, 0x11c86, 0x11c98, 0x11cb0, 0x11cbe, 0x11cce, 0x11cdc, 0x11ce2, 0x11ce4, 0x11ce8, + 0x11cf6, 0x11d06, 0x11d0c, 0x11d18, 0x11d30, 0x11d3e, 0x11d60, 0x11d7c, 0x11d8e, 0x11d9c, 0x11db8, 0x11dc4, + 0x11dc8, 0x11dd0, 0x11dde, 0x11de6, 0x11dec, 0x11dfa, 0x11e0a, 0x11e12, 0x11e14, 0x11e22, 0x11e24, 0x11e28, + 0x11e36, 0x11e42, 0x11e44, 0x11e50, 0x11e5e, 0x11e66, 0x11e6c, 0x11e82, 0x11e84, 0x11e88, 0x11e90, 0x11e9e, + 0x11ea0, 0x11ebc, 0x11ec6, 0x11ecc, 0x11ed8, 0x11eee, 0x11f1a, 0x11f2e, 0x11f32, 0x11f34, 0x11f4e, 0x11f5c, + 0x11f62, 0x11f64, 0x11f68, 0x11f76, 0x12048, 0x1205e, 0x12082, 0x12084, 0x12090, 0x1209e, 0x120a0, 0x120bc, + 0x120d8, 0x120f2, 0x120f4, 0x12108, 0x1211e, 0x12120, 0x1213c, 0x12140, 0x12178, 0x12186, 0x12198, 0x121b0, + 0x121be, 0x121e2, 0x121e4, 0x121e8, 0x121f6, 0x12204, 0x12210, 0x1221e, 0x12220, 0x12278, 0x122f0, 0x12306, + 0x1230c, 0x12330, 0x1233e, 0x12360, 0x1237c, 0x1238e, 0x1239c, 0x123b8, 0x123c2, 0x123c8, 0x123d0, 0x123e6, + 0x123ec, 0x1241e, 0x12420, 0x1243c, 0x124f0, 0x125e0, 0x12618, 0x1263e, 0x12660, 0x1267c, 0x126c0, 0x126f8, + 0x12738, 0x12770, 0x1277e, 0x12782, 0x12784, 0x12790, 0x1279e, 0x127a0, 0x127bc, 0x127c6, 0x127cc, 0x127d8, + 0x127ee, 0x12820, 0x1283c, 0x12840, 0x12878, 0x128f0, 0x129e0, 0x12bc0, 0x12c18, 0x12c30, 0x12c3e, 0x12c60, + 0x12c7c, 0x12cc0, 0x12cf8, 0x12df0, 0x12e1c, 0x12e38, 0x12e70, 0x12e7e, 0x12ee0, 0x12efc, 0x12f04, 0x12f08, + 0x12f10, 0x12f20, 0x12f3c, 0x12f40, 0x12f78, 0x12f86, 0x12f8c, 0x12f98, 0x12fb0, 0x12fbe, 0x12fce, 0x12fdc, + 0x1302e, 0x1304e, 0x1305c, 0x13062, 0x13068, 0x1308e, 0x1309c, 0x130b8, 0x130c2, 0x130c8, 0x130d0, 0x130de, + 0x130ec, 0x130fa, 0x1310e, 0x13138, 0x13170, 0x1317e, 0x13182, 0x13184, 0x13190, 0x1319e, 0x131a0, 0x131bc, + 0x131c6, 0x131cc, 0x131d8, 0x131f2, 0x131f4, 0x1320e, 0x1321c, 0x13270, 0x1327e, 0x132e0, 0x132fc, 0x13308, + 0x1331e, 0x13320, 0x1333c, 0x13340, 0x13378, 0x13386, 0x13398, 0x133b0, 0x133be, 0x133ce, 0x133dc, 0x133e2, + 0x133e4, 0x133e8, 0x133f6, 0x1340e, 0x1341c, 0x13438, 0x13470, 0x1347e, 0x134e0, 0x134fc, 0x135c0, 0x135f8, + 0x13608, 0x13610, 0x1361e, 0x13620, 0x1363c, 0x13640, 0x13678, 0x136f0, 0x1370c, 0x13718, 0x13730, 0x1373e, + 0x13760, 0x1377c, 0x1379c, 0x137b8, 0x137c2, 0x137c4, 0x137c8, 0x137d0, 0x137de, 0x137e6, 0x137ec, 0x13816, + 0x13826, 0x1382c, 0x13846, 0x1384c, 0x13858, 0x1386e, 0x13874, 0x13886, 0x13898, 0x138b0, 0x138be, 0x138ce, + 0x138dc, 0x138e2, 0x138e4, 0x138e8, 0x13906, 0x1390c, 0x13930, 0x1393e, 0x13960, 0x1397c, 0x1398e, 0x1399c, + 0x139b8, 0x139c8, 0x139d0, 0x139de, 0x139e6, 0x139ec, 0x139fa, 0x13a06, 0x13a0c, 0x13a18, 0x13a30, 0x13a3e, + 0x13a60, 0x13a7c, 0x13ac0, 0x13af8, 0x13b0e, 0x13b1c, 0x13b38, 0x13b70, 0x13b7e, 0x13b88, 0x13b90, 0x13b9e, + 0x13ba0, 0x13bbc, 0x13bcc, 0x13bd8, 0x13bee, 0x13bf2, 0x13bf4, 0x13c12, 0x13c14, 0x13c22, 0x13c24, 0x13c28, + 0x13c36, 0x13c42, 0x13c48, 0x13c50, 0x13c5e, 0x13c66, 0x13c6c, 0x13c82, 0x13c84, 0x13c90, 0x13c9e, 0x13ca0, + 0x13cbc, 0x13cc6, 0x13ccc, 0x13cd8, 0x13cee, 0x13d02, 0x13d04, 0x13d08, 0x13d10, 0x13d1e, 0x13d20, 0x13d3c, + 0x13d40, 0x13d78, 0x13d86, 0x13d8c, 0x13d98, 0x13db0, 0x13dbe, 0x13dce, 0x13ddc, 0x13de4, 0x13de8, 0x13df6, + 0x13e1a, 0x13e2e, 0x13e32, 0x13e34, 0x13e4e, 0x13e5c, 0x13e62, 0x13e64, 0x13e68, 0x13e76, 0x13e8e, 0x13e9c, + 0x13eb8, 0x13ec2, 0x13ec4, 0x13ec8, 0x13ed0, 0x13ede, 0x13ee6, 0x13eec, 0x13f26, 0x13f2c, 0x13f3a, 0x13f46, + 0x13f4c, 0x13f58, 0x13f6e, 0x13f72, 0x13f74, 0x14082, 0x1409e, 0x140a0, 0x140bc, 0x14104, 0x14108, 0x14110, + 0x1411e, 0x14120, 0x1413c, 0x14140, 0x14178, 0x1418c, 0x14198, 0x141b0, 0x141be, 0x141e2, 0x141e4, 0x141e8, + 0x14208, 0x14210, 0x1421e, 0x14220, 0x1423c, 0x14240, 0x14278, 0x142f0, 0x14306, 0x1430c, 0x14318, 0x14330, + 0x1433e, 0x14360, 0x1437c, 0x1438e, 0x143c2, 0x143c4, 0x143c8, 0x143d0, 0x143e6, 0x143ec, 0x14408, 0x14410, + 0x1441e, 0x14420, 0x1443c, 0x14440, 0x14478, 0x144f0, 0x145e0, 0x1460c, 0x14618, 0x14630, 0x1463e, 0x14660, + 0x1467c, 0x146c0, 0x146f8, 0x1471c, 0x14738, 0x14770, 0x1477e, 0x14782, 0x14784, 0x14788, 0x14790, 0x147a0, + 0x147bc, 0x147c6, 0x147cc, 0x147d8, 0x147ee, 0x14810, 0x14820, 0x1483c, 0x14840, 0x14878, 0x148f0, 0x149e0, + 0x14bc0, 0x14c30, 0x14c3e, 0x14c60, 0x14c7c, 0x14cc0, 0x14cf8, 0x14df0, 0x14e38, 0x14e70, 0x14e7e, 0x14ee0, + 0x14efc, 0x14f04, 0x14f08, 0x14f10, 0x14f1e, 0x14f20, 0x14f3c, 0x14f40, 0x14f78, 0x14f86, 0x14f8c, 0x14f98, + 0x14fb0, 0x14fce, 0x14fdc, 0x15020, 0x15040, 0x15078, 0x150f0, 0x151e0, 0x153c0, 0x15860, 0x1587c, 0x158c0, + 0x158f8, 0x159f0, 0x15be0, 0x15c70, 0x15c7e, 0x15ce0, 0x15cfc, 0x15dc0, 0x15df8, 0x15e08, 0x15e10, 0x15e20, + 0x15e40, 0x15e78, 0x15ef0, 0x15f0c, 0x15f18, 0x15f30, 0x15f60, 0x15f7c, 0x15f8e, 0x15f9c, 0x15fb8, 0x1604e, + 0x1605c, 0x1608e, 0x1609c, 0x160b8, 0x160c2, 0x160c4, 0x160c8, 0x160de, 0x1610e, 0x1611c, 0x16138, 0x16170, + 0x1617e, 0x16184, 0x16188, 0x16190, 0x1619e, 0x161a0, 0x161bc, 0x161c6, 0x161cc, 0x161d8, 0x161f2, 0x161f4, + 0x1620e, 0x1621c, 0x16238, 0x16270, 0x1627e, 0x162e0, 0x162fc, 0x16304, 0x16308, 0x16310, 0x1631e, 0x16320, + 0x1633c, 0x16340, 0x16378, 0x16386, 0x1638c, 0x16398, 0x163b0, 0x163be, 0x163ce, 0x163dc, 0x163e2, 0x163e4, + 0x163e8, 0x163f6, 0x1640e, 0x1641c, 0x16438, 0x16470, 0x1647e, 0x164e0, 0x164fc, 0x165c0, 0x165f8, 0x16610, + 0x1661e, 0x16620, 0x1663c, 0x16640, 0x16678, 0x166f0, 0x16718, 0x16730, 0x1673e, 0x16760, 0x1677c, 0x1678e, + 0x1679c, 0x167b8, 0x167c2, 0x167c4, 0x167c8, 0x167d0, 0x167de, 0x167e6, 0x167ec, 0x1681c, 0x16838, 0x16870, + 0x168e0, 0x168fc, 0x169c0, 0x169f8, 0x16bf0, 0x16c10, 0x16c1e, 0x16c20, 0x16c3c, 0x16c40, 0x16c78, 0x16cf0, + 0x16de0, 0x16e18, 0x16e30, 0x16e3e, 0x16e60, 0x16e7c, 0x16ec0, 0x16ef8, 0x16f1c, 0x16f38, 0x16f70, 0x16f7e, + 0x16f84, 0x16f88, 0x16f90, 0x16f9e, 0x16fa0, 0x16fbc, 0x16fc6, 0x16fcc, 0x16fd8, 0x17026, 0x1702c, 0x17046, + 0x1704c, 0x17058, 0x1706e, 0x17086, 0x1708c, 0x17098, 0x170b0, 0x170be, 0x170ce, 0x170dc, 0x170e8, 0x17106, + 0x1710c, 0x17118, 0x17130, 0x1713e, 0x17160, 0x1717c, 0x1718e, 0x1719c, 0x171b8, 0x171c2, 0x171c4, 0x171c8, + 0x171d0, 0x171de, 0x171e6, 0x171ec, 0x171fa, 0x17206, 0x1720c, 0x17218, 0x17230, 0x1723e, 0x17260, 0x1727c, + 0x172c0, 0x172f8, 0x1730e, 0x1731c, 0x17338, 0x17370, 0x1737e, 0x17388, 0x17390, 0x1739e, 0x173a0, 0x173bc, + 0x173cc, 0x173d8, 0x173ee, 0x173f2, 0x173f4, 0x1740c, 0x17418, 0x17430, 0x1743e, 0x17460, 0x1747c, 0x174c0, + 0x174f8, 0x175f0, 0x1760e, 0x1761c, 0x17638, 0x17670, 0x1767e, 0x176e0, 0x176fc, 0x17708, 0x17710, 0x1771e, + 0x17720, 0x1773c, 0x17740, 0x17778, 0x17798, 0x177b0, 0x177be, 0x177dc, 0x177e2, 0x177e4, 0x177e8, 0x17822, + 0x17824, 0x17828, 0x17836, 0x17842, 0x17844, 0x17848, 0x17850, 0x1785e, 0x17866, 0x1786c, 0x17882, 0x17884, + 0x17888, 0x17890, 0x1789e, 0x178a0, 0x178bc, 0x178c6, 0x178cc, 0x178d8, 0x178ee, 0x178f2, 0x178f4, 0x17902, + 0x17904, 0x17908, 0x17910, 0x1791e, 0x17920, 0x1793c, 0x17940, 0x17978, 0x17986, 0x1798c, 0x17998, 0x179b0, + 0x179be, 0x179ce, 0x179dc, 0x179e2, 0x179e4, 0x179e8, 0x179f6, 0x17a04, 0x17a08, 0x17a10, 0x17a1e, 0x17a20, + 0x17a3c, 0x17a40, 0x17a78, 0x17af0, 0x17b06, 0x17b0c, 0x17b18, 0x17b30, 0x17b3e, 0x17b60, 0x17b7c, 0x17b8e, + 0x17b9c, 0x17bb8, 0x17bc4, 0x17bc8, 0x17bd0, 0x17bde, 0x17be6, 0x17bec, 0x17c2e, 0x17c32, 0x17c34, 0x17c4e, + 0x17c5c, 0x17c62, 0x17c64, 0x17c68, 0x17c76, 0x17c8e, 0x17c9c, 0x17cb8, 0x17cc2, 0x17cc4, 0x17cc8, 0x17cd0, + 0x17cde, 0x17ce6, 0x17cec, 0x17d0e, 0x17d1c, 0x17d38, 0x17d70, 0x17d82, 0x17d84, 0x17d88, 0x17d90, 0x17d9e, + 0x17da0, 0x17dbc, 0x17dc6, 0x17dcc, 0x17dd8, 0x17dee, 0x17e26, 0x17e2c, 0x17e3a, 0x17e46, 0x17e4c, 0x17e58, + 0x17e6e, 0x17e72, 0x17e74, 0x17e86, 0x17e8c, 0x17e98, 0x17eb0, 0x17ece, 0x17edc, 0x17ee2, 0x17ee4, 0x17ee8, + 0x17ef6, 0x1813a, 0x18172, 0x18174, 0x18216, 0x18226, 0x1823a, 0x1824c, 0x18258, 0x1826e, 0x18272, 0x18274, + 0x18298, 0x182be, 0x182e2, 0x182e4, 0x182e8, 0x182f6, 0x1835e, 0x1837a, 0x183ae, 0x183d6, 0x18416, 0x18426, + 0x1842c, 0x1843a, 0x18446, 0x18458, 0x1846e, 0x18472, 0x18474, 0x18486, 0x184b0, 0x184be, 0x184ce, 0x184dc, + 0x184e2, 0x184e4, 0x184e8, 0x184f6, 0x18506, 0x1850c, 0x18518, 0x18530, 0x1853e, 0x18560, 0x1857c, 0x1858e, + 0x1859c, 0x185b8, 0x185c2, 0x185c4, 0x185c8, 0x185d0, 0x185de, 0x185e6, 0x185ec, 0x185fa, 0x18612, 0x18614, + 0x18622, 0x18628, 0x18636, 0x18642, 0x18650, 0x1865e, 0x1867a, 0x18682, 0x18684, 0x18688, 0x18690, 0x1869e, + 0x186a0, 0x186bc, 0x186c6, 0x186cc, 0x186d8, 0x186ee, 0x186f2, 0x186f4, 0x1872e, 0x1874e, 0x1875c, 0x18796, + 0x187a6, 0x187ac, 0x187d2, 0x187d4, 0x18826, 0x1882c, 0x1883a, 0x18846, 0x1884c, 0x18858, 0x1886e, 0x18872, + 0x18874, 0x18886, 0x18898, 0x188b0, 0x188be, 0x188ce, 0x188dc, 0x188e2, 0x188e4, 0x188e8, 0x188f6, 0x1890c, + 0x18930, 0x1893e, 0x18960, 0x1897c, 0x1898e, 0x189b8, 0x189c2, 0x189c8, 0x189d0, 0x189de, 0x189e6, 0x189ec, + 0x189fa, 0x18a18, 0x18a30, 0x18a3e, 0x18a60, 0x18a7c, 0x18ac0, 0x18af8, 0x18b1c, 0x18b38, 0x18b70, 0x18b7e, + 0x18b82, 0x18b84, 0x18b88, 0x18b90, 0x18b9e, 0x18ba0, 0x18bbc, 0x18bc6, 0x18bcc, 0x18bd8, 0x18bee, 0x18bf2, + 0x18bf4, 0x18c22, 0x18c24, 0x18c28, 0x18c36, 0x18c42, 0x18c48, 0x18c50, 0x18c5e, 0x18c66, 0x18c7a, 0x18c82, + 0x18c84, 0x18c90, 0x18c9e, 0x18ca0, 0x18cbc, 0x18ccc, 0x18cf2, 0x18cf4, 0x18d04, 0x18d08, 0x18d10, 0x18d1e, + 0x18d20, 0x18d3c, 0x18d40, 0x18d78, 0x18d86, 0x18d98, 0x18dce, 0x18de2, 0x18de4, 0x18de8, 0x18e2e, 0x18e32, + 0x18e34, 0x18e4e, 0x18e5c, 0x18e62, 0x18e64, 0x18e68, 0x18e8e, 0x18e9c, 0x18eb8, 0x18ec2, 0x18ec4, 0x18ec8, + 0x18ed0, 0x18efa, 0x18f16, 0x18f26, 0x18f2c, 0x18f46, 0x18f4c, 0x18f58, 0x18f6e, 0x18f8a, 0x18f92, 0x18f94, + 0x18fa2, 0x18fa4, 0x18fa8, 0x18fb6, 0x1902c, 0x1903a, 0x19046, 0x1904c, 0x19058, 0x19072, 0x19074, 0x19086, + 0x19098, 0x190b0, 0x190be, 0x190ce, 0x190dc, 0x190e2, 0x190e8, 0x190f6, 0x19106, 0x1910c, 0x19130, 0x1913e, + 0x19160, 0x1917c, 0x1918e, 0x1919c, 0x191b8, 0x191c2, 0x191c8, 0x191d0, 0x191de, 0x191e6, 0x191ec, 0x191fa, + 0x19218, 0x1923e, 0x19260, 0x1927c, 0x192c0, 0x192f8, 0x19338, 0x19370, 0x1937e, 0x19382, 0x19384, 0x19390, + 0x1939e, 0x193a0, 0x193bc, 0x193c6, 0x193cc, 0x193d8, 0x193ee, 0x193f2, 0x193f4, 0x19430, 0x1943e, 0x19460, + 0x1947c, 0x194c0, 0x194f8, 0x195f0, 0x19638, 0x19670, 0x1967e, 0x196e0, 0x196fc, 0x19702, 0x19704, 0x19708, + 0x19710, 0x19720, 0x1973c, 0x19740, 0x19778, 0x19786, 0x1978c, 0x19798, 0x197b0, 0x197be, 0x197ce, 0x197dc, + 0x197e2, 0x197e4, 0x197e8, 0x19822, 0x19824, 0x19842, 0x19848, 0x19850, 0x1985e, 0x19866, 0x1987a, 0x19882, + 0x19884, 0x19890, 0x1989e, 0x198a0, 0x198bc, 0x198cc, 0x198f2, 0x198f4, 0x19902, 0x19908, 0x1991e, 0x19920, + 0x1993c, 0x19940, 0x19978, 0x19986, 0x19998, 0x199ce, 0x199e2, 0x199e4, 0x199e8, 0x19a08, 0x19a10, 0x19a1e, + 0x19a20, 0x19a3c, 0x19a40, 0x19a78, 0x19af0, 0x19b18, 0x19b3e, 0x19b60, 0x19b9c, 0x19bc2, 0x19bc4, 0x19bc8, + 0x19bd0, 0x19be6, 0x19c2e, 0x19c34, 0x19c4e, 0x19c5c, 0x19c62, 0x19c64, 0x19c68, 0x19c8e, 0x19c9c, 0x19cb8, + 0x19cc2, 0x19cc8, 0x19cd0, 0x19ce6, 0x19cfa, 0x19d0e, 0x19d1c, 0x19d38, 0x19d70, 0x19d7e, 0x19d82, 0x19d84, + 0x19d88, 0x19d90, 0x19da0, 0x19dcc, 0x19df2, 0x19df4, 0x19e16, 0x19e26, 0x19e2c, 0x19e46, 0x19e4c, 0x19e58, + 0x19e74, 0x19e86, 0x19e8c, 0x19e98, 0x19eb0, 0x19ebe, 0x19ece, 0x19ee2, 0x19ee4, 0x19ee8, 0x19f0a, 0x19f12, + 0x19f14, 0x19f22, 0x19f24, 0x19f28, 0x19f42, 0x19f44, 0x19f48, 0x19f50, 0x19f5e, 0x19f6c, 0x19f9a, 0x19fae, + 0x19fb2, 0x19fb4, 0x1a046, 0x1a04c, 0x1a072, 0x1a074, 0x1a086, 0x1a08c, 0x1a098, 0x1a0b0, 0x1a0be, 0x1a0e2, + 0x1a0e4, 0x1a0e8, 0x1a0f6, 0x1a106, 0x1a10c, 0x1a118, 0x1a130, 0x1a13e, 0x1a160, 0x1a17c, 0x1a18e, 0x1a19c, + 0x1a1b8, 0x1a1c2, 0x1a1c4, 0x1a1c8, 0x1a1d0, 0x1a1de, 0x1a1e6, 0x1a1ec, 0x1a218, 0x1a230, 0x1a23e, 0x1a260, + 0x1a27c, 0x1a2c0, 0x1a2f8, 0x1a31c, 0x1a338, 0x1a370, 0x1a37e, 0x1a382, 0x1a384, 0x1a388, 0x1a390, 0x1a39e, + 0x1a3a0, 0x1a3bc, 0x1a3c6, 0x1a3cc, 0x1a3d8, 0x1a3ee, 0x1a3f2, 0x1a3f4, 0x1a418, 0x1a430, 0x1a43e, 0x1a460, + 0x1a47c, 0x1a4c0, 0x1a4f8, 0x1a5f0, 0x1a61c, 0x1a638, 0x1a670, 0x1a67e, 0x1a6e0, 0x1a6fc, 0x1a702, 0x1a704, + 0x1a708, 0x1a710, 0x1a71e, 0x1a720, 0x1a73c, 0x1a740, 0x1a778, 0x1a786, 0x1a78c, 0x1a798, 0x1a7b0, 0x1a7be, + 0x1a7ce, 0x1a7dc, 0x1a7e2, 0x1a7e4, 0x1a7e8, 0x1a830, 0x1a860, 0x1a87c, 0x1a8c0, 0x1a8f8, 0x1a9f0, 0x1abe0, + 0x1ac70, 0x1ac7e, 0x1ace0, 0x1acfc, 0x1adc0, 0x1adf8, 0x1ae04, 0x1ae08, 0x1ae10, 0x1ae20, 0x1ae3c, 0x1ae40, + 0x1ae78, 0x1aef0, 0x1af06, 0x1af0c, 0x1af18, 0x1af30, 0x1af3e, 0x1af60, 0x1af7c, 0x1af8e, 0x1af9c, 0x1afb8, + 0x1afc4, 0x1afc8, 0x1afd0, 0x1afde, 0x1b042, 0x1b05e, 0x1b07a, 0x1b082, 0x1b084, 0x1b088, 0x1b090, 0x1b09e, + 0x1b0a0, 0x1b0bc, 0x1b0cc, 0x1b0f2, 0x1b0f4, 0x1b102, 0x1b104, 0x1b108, 0x1b110, 0x1b11e, 0x1b120, 0x1b13c, + 0x1b140, 0x1b178, 0x1b186, 0x1b198, 0x1b1ce, 0x1b1e2, 0x1b1e4, 0x1b1e8, 0x1b204, 0x1b208, 0x1b210, 0x1b21e, + 0x1b220, 0x1b23c, 0x1b240, 0x1b278, 0x1b2f0, 0x1b30c, 0x1b33e, 0x1b360, 0x1b39c, 0x1b3c2, 0x1b3c4, 0x1b3c8, + 0x1b3d0, 0x1b3e6, 0x1b410, 0x1b41e, 0x1b420, 0x1b43c, 0x1b440, 0x1b478, 0x1b4f0, 0x1b5e0, 0x1b618, 0x1b660, + 0x1b67c, 0x1b6c0, 0x1b738, 0x1b782, 0x1b784, 0x1b788, 0x1b790, 0x1b79e, 0x1b7a0, 0x1b7cc, 0x1b82e, 0x1b84e, + 0x1b85c, 0x1b88e, 0x1b89c, 0x1b8b8, 0x1b8c2, 0x1b8c4, 0x1b8c8, 0x1b8d0, 0x1b8e6, 0x1b8fa, 0x1b90e, 0x1b91c, + 0x1b938, 0x1b970, 0x1b97e, 0x1b982, 0x1b984, 0x1b988, 0x1b990, 0x1b99e, 0x1b9a0, 0x1b9cc, 0x1b9f2, 0x1b9f4, + 0x1ba0e, 0x1ba1c, 0x1ba38, 0x1ba70, 0x1ba7e, 0x1bae0, 0x1bafc, 0x1bb08, 0x1bb10, 0x1bb20, 0x1bb3c, 0x1bb40, + 0x1bb98, 0x1bbce, 0x1bbe2, 0x1bbe4, 0x1bbe8, 0x1bc16, 0x1bc26, 0x1bc2c, 0x1bc46, 0x1bc4c, 0x1bc58, 0x1bc72, + 0x1bc74, 0x1bc86, 0x1bc8c, 0x1bc98, 0x1bcb0, 0x1bcbe, 0x1bcce, 0x1bce2, 0x1bce4, 0x1bce8, 0x1bd06, 0x1bd0c, + 0x1bd18, 0x1bd30, 0x1bd3e, 0x1bd60, 0x1bd7c, 0x1bd9c, 0x1bdc2, 0x1bdc4, 0x1bdc8, 0x1bdd0, 0x1bde6, 0x1bdfa, + 0x1be12, 0x1be14, 0x1be22, 0x1be24, 0x1be28, 0x1be42, 0x1be44, 0x1be48, 0x1be50, 0x1be5e, 0x1be66, 0x1be82, + 0x1be84, 0x1be88, 0x1be90, 0x1be9e, 0x1bea0, 0x1bebc, 0x1becc, 0x1bef4, 0x1bf1a, 0x1bf2e, 0x1bf32, 0x1bf34, + 0x1bf4e, 0x1bf5c, 0x1bf62, 0x1bf64, 0x1bf68, 0x1c09a, 0x1c0b2, 0x1c0b4, 0x1c11a, 0x1c132, 0x1c134, 0x1c162, + 0x1c164, 0x1c168, 0x1c176, 0x1c1ba, 0x1c21a, 0x1c232, 0x1c234, 0x1c24e, 0x1c25c, 0x1c262, 0x1c264, 0x1c268, + 0x1c276, 0x1c28e, 0x1c2c2, 0x1c2c4, 0x1c2c8, 0x1c2d0, 0x1c2de, 0x1c2e6, 0x1c2ec, 0x1c2fa, 0x1c316, 0x1c326, + 0x1c33a, 0x1c346, 0x1c34c, 0x1c372, 0x1c374, 0x1c41a, 0x1c42e, 0x1c432, 0x1c434, 0x1c44e, 0x1c45c, 0x1c462, + 0x1c464, 0x1c468, 0x1c476, 0x1c48e, 0x1c49c, 0x1c4b8, 0x1c4c2, 0x1c4c8, 0x1c4d0, 0x1c4de, 0x1c4e6, 0x1c4ec, + 0x1c4fa, 0x1c51c, 0x1c538, 0x1c570, 0x1c57e, 0x1c582, 0x1c584, 0x1c588, 0x1c590, 0x1c59e, 0x1c5a0, 0x1c5bc, + 0x1c5c6, 0x1c5cc, 0x1c5d8, 0x1c5ee, 0x1c5f2, 0x1c5f4, 0x1c616, 0x1c626, 0x1c62c, 0x1c63a, 0x1c646, 0x1c64c, + 0x1c658, 0x1c66e, 0x1c672, 0x1c674, 0x1c686, 0x1c68c, 0x1c698, 0x1c6b0, 0x1c6be, 0x1c6ce, 0x1c6dc, 0x1c6e2, + 0x1c6e4, 0x1c6e8, 0x1c712, 0x1c714, 0x1c722, 0x1c728, 0x1c736, 0x1c742, 0x1c744, 0x1c748, 0x1c750, 0x1c75e, + 0x1c766, 0x1c76c, 0x1c77a, 0x1c7ae, 0x1c7d6, 0x1c7ea, 0x1c81a, 0x1c82e, 0x1c832, 0x1c834, 0x1c84e, 0x1c85c, + 0x1c862, 0x1c864, 0x1c868, 0x1c876, 0x1c88e, 0x1c89c, 0x1c8b8, 0x1c8c2, 0x1c8c8, 0x1c8d0, 0x1c8de, 0x1c8e6, + 0x1c8ec, 0x1c8fa, 0x1c90e, 0x1c938, 0x1c970, 0x1c97e, 0x1c982, 0x1c984, 0x1c990, 0x1c99e, 0x1c9a0, 0x1c9bc, + 0x1c9c6, 0x1c9cc, 0x1c9d8, 0x1c9ee, 0x1c9f2, 0x1c9f4, 0x1ca38, 0x1ca70, 0x1ca7e, 0x1cae0, 0x1cafc, 0x1cb02, + 0x1cb04, 0x1cb08, 0x1cb10, 0x1cb20, 0x1cb3c, 0x1cb40, 0x1cb78, 0x1cb86, 0x1cb8c, 0x1cb98, 0x1cbb0, 0x1cbbe, + 0x1cbce, 0x1cbdc, 0x1cbe2, 0x1cbe4, 0x1cbe8, 0x1cbf6, 0x1cc16, 0x1cc26, 0x1cc2c, 0x1cc3a, 0x1cc46, 0x1cc58, + 0x1cc72, 0x1cc74, 0x1cc86, 0x1ccb0, 0x1ccbe, 0x1ccce, 0x1cce2, 0x1cce4, 0x1cce8, 0x1cd06, 0x1cd0c, 0x1cd18, + 0x1cd30, 0x1cd3e, 0x1cd60, 0x1cd7c, 0x1cd9c, 0x1cdc2, 0x1cdc4, 0x1cdc8, 0x1cdd0, 0x1cdde, 0x1cde6, 0x1cdfa, + 0x1ce22, 0x1ce28, 0x1ce42, 0x1ce50, 0x1ce5e, 0x1ce66, 0x1ce7a, 0x1ce82, 0x1ce84, 0x1ce88, 0x1ce90, 0x1ce9e, + 0x1cea0, 0x1cebc, 0x1cecc, 0x1cef2, 0x1cef4, 0x1cf2e, 0x1cf32, 0x1cf34, 0x1cf4e, 0x1cf5c, 0x1cf62, 0x1cf64, + 0x1cf68, 0x1cf96, 0x1cfa6, 0x1cfac, 0x1cfca, 0x1cfd2, 0x1cfd4, 0x1d02e, 0x1d032, 0x1d034, 0x1d04e, 0x1d05c, + 0x1d062, 0x1d064, 0x1d068, 0x1d076, 0x1d08e, 0x1d09c, 0x1d0b8, 0x1d0c2, 0x1d0c4, 0x1d0c8, 0x1d0d0, 0x1d0de, + 0x1d0e6, 0x1d0ec, 0x1d0fa, 0x1d11c, 0x1d138, 0x1d170, 0x1d17e, 0x1d182, 0x1d184, 0x1d188, 0x1d190, 0x1d19e, + 0x1d1a0, 0x1d1bc, 0x1d1c6, 0x1d1cc, 0x1d1d8, 0x1d1ee, 0x1d1f2, 0x1d1f4, 0x1d21c, 0x1d238, 0x1d270, 0x1d27e, + 0x1d2e0, 0x1d2fc, 0x1d302, 0x1d304, 0x1d308, 0x1d310, 0x1d31e, 0x1d320, 0x1d33c, 0x1d340, 0x1d378, 0x1d386, + 0x1d38c, 0x1d398, 0x1d3b0, 0x1d3be, 0x1d3ce, 0x1d3dc, 0x1d3e2, 0x1d3e4, 0x1d3e8, 0x1d3f6, 0x1d470, 0x1d47e, + 0x1d4e0, 0x1d4fc, 0x1d5c0, 0x1d5f8, 0x1d604, 0x1d608, 0x1d610, 0x1d620, 0x1d640, 0x1d678, 0x1d6f0, 0x1d706, + 0x1d70c, 0x1d718, 0x1d730, 0x1d73e, 0x1d760, 0x1d77c, 0x1d78e, 0x1d79c, 0x1d7b8, 0x1d7c2, 0x1d7c4, 0x1d7c8, + 0x1d7d0, 0x1d7de, 0x1d7e6, 0x1d7ec, 0x1d826, 0x1d82c, 0x1d83a, 0x1d846, 0x1d84c, 0x1d858, 0x1d872, 0x1d874, + 0x1d886, 0x1d88c, 0x1d898, 0x1d8b0, 0x1d8be, 0x1d8ce, 0x1d8e2, 0x1d8e4, 0x1d8e8, 0x1d8f6, 0x1d90c, 0x1d918, + 0x1d930, 0x1d93e, 0x1d960, 0x1d97c, 0x1d99c, 0x1d9c2, 0x1d9c4, 0x1d9c8, 0x1d9d0, 0x1d9e6, 0x1d9fa, 0x1da0c, + 0x1da18, 0x1da30, 0x1da3e, 0x1da60, 0x1da7c, 0x1dac0, 0x1daf8, 0x1db38, 0x1db82, 0x1db84, 0x1db88, 0x1db90, + 0x1db9e, 0x1dba0, 0x1dbcc, 0x1dbf2, 0x1dbf4, 0x1dc22, 0x1dc42, 0x1dc44, 0x1dc48, 0x1dc50, 0x1dc5e, 0x1dc66, + 0x1dc7a, 0x1dc82, 0x1dc84, 0x1dc88, 0x1dc90, 0x1dc9e, 0x1dca0, 0x1dcbc, 0x1dccc, 0x1dcf2, 0x1dcf4, 0x1dd04, + 0x1dd08, 0x1dd10, 0x1dd1e, 0x1dd20, 0x1dd3c, 0x1dd40, 0x1dd78, 0x1dd86, 0x1dd98, 0x1ddce, 0x1dde2, 0x1dde4, + 0x1dde8, 0x1de2e, 0x1de32, 0x1de34, 0x1de4e, 0x1de5c, 0x1de62, 0x1de64, 0x1de68, 0x1de8e, 0x1de9c, 0x1deb8, + 0x1dec2, 0x1dec4, 0x1dec8, 0x1ded0, 0x1dee6, 0x1defa, 0x1df16, 0x1df26, 0x1df2c, 0x1df46, 0x1df4c, 0x1df58, + 0x1df72, 0x1df74, 0x1df8a, 0x1df92, 0x1df94, 0x1dfa2, 0x1dfa4, 0x1dfa8, 0x1e08a, 0x1e092, 0x1e094, 0x1e0a2, + 0x1e0a4, 0x1e0a8, 0x1e0b6, 0x1e0da, 0x1e10a, 0x1e112, 0x1e114, 0x1e122, 0x1e124, 0x1e128, 0x1e136, 0x1e142, + 0x1e144, 0x1e148, 0x1e150, 0x1e166, 0x1e16c, 0x1e17a, 0x1e19a, 0x1e1b2, 0x1e1b4, 0x1e20a, 0x1e212, 0x1e214, + 0x1e222, 0x1e224, 0x1e228, 0x1e236, 0x1e242, 0x1e248, 0x1e250, 0x1e25e, 0x1e266, 0x1e26c, 0x1e27a, 0x1e282, + 0x1e284, 0x1e288, 0x1e290, 0x1e2a0, 0x1e2bc, 0x1e2c6, 0x1e2cc, 0x1e2d8, 0x1e2ee, 0x1e2f2, 0x1e2f4, 0x1e31a, + 0x1e332, 0x1e334, 0x1e35c, 0x1e362, 0x1e364, 0x1e368, 0x1e3ba, 0x1e40a, 0x1e412, 0x1e414, 0x1e422, 0x1e428, + 0x1e436, 0x1e442, 0x1e448, 0x1e450, 0x1e45e, 0x1e466, 0x1e46c, 0x1e47a, 0x1e482, 0x1e484, 0x1e490, 0x1e49e, + 0x1e4a0, 0x1e4bc, 0x1e4c6, 0x1e4cc, 0x1e4d8, 0x1e4ee, 0x1e4f2, 0x1e4f4, 0x1e502, 0x1e504, 0x1e508, 0x1e510, + 0x1e51e, 0x1e520, 0x1e53c, 0x1e540, 0x1e578, 0x1e586, 0x1e58c, 0x1e598, 0x1e5b0, 0x1e5be, 0x1e5ce, 0x1e5dc, + 0x1e5e2, 0x1e5e4, 0x1e5e8, 0x1e5f6, 0x1e61a, 0x1e62e, 0x1e632, 0x1e634, 0x1e64e, 0x1e65c, 0x1e662, 0x1e668, + 0x1e68e, 0x1e69c, 0x1e6b8, 0x1e6c2, 0x1e6c4, 0x1e6c8, 0x1e6d0, 0x1e6e6, 0x1e6fa, 0x1e716, 0x1e726, 0x1e72c, + 0x1e73a, 0x1e746, 0x1e74c, 0x1e758, 0x1e772, 0x1e774, 0x1e792, 0x1e794, 0x1e7a2, 0x1e7a4, 0x1e7a8, 0x1e7b6, + 0x1e812, 0x1e814, 0x1e822, 0x1e824, 0x1e828, 0x1e836, 0x1e842, 0x1e844, 0x1e848, 0x1e850, 0x1e85e, 0x1e866, + 0x1e86c, 0x1e87a, 0x1e882, 0x1e884, 0x1e888, 0x1e890, 0x1e89e, 0x1e8a0, 0x1e8bc, 0x1e8c6, 0x1e8cc, 0x1e8d8, + 0x1e8ee, 0x1e8f2, 0x1e8f4, 0x1e902, 0x1e904, 0x1e908, 0x1e910, 0x1e920, 0x1e93c, 0x1e940, 0x1e978, 0x1e986, + 0x1e98c, 0x1e998, 0x1e9b0, 0x1e9be, 0x1e9ce, 0x1e9dc, 0x1e9e2, 0x1e9e4, 0x1e9e8, 0x1e9f6, 0x1ea04, 0x1ea08, + 0x1ea10, 0x1ea20, 0x1ea40, 0x1ea78, 0x1eaf0, 0x1eb06, 0x1eb0c, 0x1eb18, 0x1eb30, 0x1eb3e, 0x1eb60, 0x1eb7c, + 0x1eb8e, 0x1eb9c, 0x1ebb8, 0x1ebc2, 0x1ebc4, 0x1ebc8, 0x1ebd0, 0x1ebde, 0x1ebe6, 0x1ebec, 0x1ec1a, 0x1ec2e, + 0x1ec32, 0x1ec34, 0x1ec4e, 0x1ec5c, 0x1ec62, 0x1ec64, 0x1ec68, 0x1ec8e, 0x1ec9c, 0x1ecb8, 0x1ecc2, 0x1ecc4, + 0x1ecc8, 0x1ecd0, 0x1ece6, 0x1ecfa, 0x1ed0e, 0x1ed1c, 0x1ed38, 0x1ed70, 0x1ed7e, 0x1ed82, 0x1ed84, 0x1ed88, + 0x1ed90, 0x1ed9e, 0x1eda0, 0x1edcc, 0x1edf2, 0x1edf4, 0x1ee16, 0x1ee26, 0x1ee2c, 0x1ee3a, 0x1ee46, 0x1ee4c, + 0x1ee58, 0x1ee6e, 0x1ee72, 0x1ee74, 0x1ee86, 0x1ee8c, 0x1ee98, 0x1eeb0, 0x1eebe, 0x1eece, 0x1eedc, 0x1eee2, + 0x1eee4, 0x1eee8, 0x1ef12, 0x1ef22, 0x1ef24, 0x1ef28, 0x1ef36, 0x1ef42, 0x1ef44, 0x1ef48, 0x1ef50, 0x1ef5e, + 0x1ef66, 0x1ef6c, 0x1ef7a, 0x1efae, 0x1efb2, 0x1efb4, 0x1efd6, 0x1f096, 0x1f0a6, 0x1f0ac, 0x1f0ba, 0x1f0ca, + 0x1f0d2, 0x1f0d4, 0x1f116, 0x1f126, 0x1f12c, 0x1f13a, 0x1f146, 0x1f14c, 0x1f158, 0x1f16e, 0x1f172, 0x1f174, + 0x1f18a, 0x1f192, 0x1f194, 0x1f1a2, 0x1f1a4, 0x1f1a8, 0x1f1da, 0x1f216, 0x1f226, 0x1f22c, 0x1f23a, 0x1f246, + 0x1f258, 0x1f26e, 0x1f272, 0x1f274, 0x1f286, 0x1f28c, 0x1f298, 0x1f2b0, 0x1f2be, 0x1f2ce, 0x1f2dc, 0x1f2e2, + 0x1f2e4, 0x1f2e8, 0x1f2f6, 0x1f30a, 0x1f312, 0x1f314, 0x1f322, 0x1f328, 0x1f342, 0x1f344, 0x1f348, 0x1f350, + 0x1f35e, 0x1f366, 0x1f37a, 0x1f39a, 0x1f3ae, 0x1f3b2, 0x1f3b4, 0x1f416, 0x1f426, 0x1f42c, 0x1f43a, 0x1f446, + 0x1f44c, 0x1f458, 0x1f46e, 0x1f472, 0x1f474, 0x1f486, 0x1f48c, 0x1f498, 0x1f4b0, 0x1f4be, 0x1f4ce, 0x1f4dc, + 0x1f4e2, 0x1f4e4, 0x1f4e8, 0x1f4f6, 0x1f506, 0x1f50c, 0x1f518, 0x1f530, 0x1f53e, 0x1f560, 0x1f57c, 0x1f58e, + 0x1f59c, 0x1f5b8, 0x1f5c2, 0x1f5c4, 0x1f5c8, 0x1f5d0, 0x1f5de, 0x1f5e6, 0x1f5ec, 0x1f5fa, 0x1f60a, 0x1f612, + 0x1f614, 0x1f622, 0x1f624, 0x1f628, 0x1f636, 0x1f642, 0x1f644, 0x1f648, 0x1f650, 0x1f65e, 0x1f666, 0x1f67a, + 0x1f682, 0x1f684, 0x1f688, 0x1f690, 0x1f69e, 0x1f6a0, 0x1f6bc, 0x1f6cc, 0x1f6f2, 0x1f6f4, 0x1f71a, 0x1f72e, + 0x1f732, 0x1f734, 0x1f74e, 0x1f75c, 0x1f762, 0x1f764, 0x1f768, 0x1f776, 0x1f796, 0x1f7a6, 0x1f7ac, 0x1f7ba, + 0x1f7d2, 0x1f7d4, 0x1f89a, 0x1f8ae, 0x1f8b2, 0x1f8b4, 0x1f8d6, 0x1f8ea, 0x1f91a, 0x1f92e, 0x1f932, 0x1f934, + 0x1f94e, 0x1f95c, 0x1f962, 0x1f964, 0x1f968, 0x1f976, 0x1f996, 0x1f9a6, 0x1f9ac, 0x1f9ba, 0x1f9ca, 0x1f9d2, + 0x1f9d4, 0x1fa1a, 0x1fa2e, 0x1fa32, 0x1fa34, 0x1fa4e, 0x1fa5c, 0x1fa62, 0x1fa64, 0x1fa68, 0x1fa76, 0x1fa8e, + 0x1fa9c, 0x1fab8, 0x1fac2, 0x1fac4, 0x1fac8, 0x1fad0, 0x1fade, 0x1fae6, 0x1faec, 0x1fb16, 0x1fb26, 0x1fb2c, + 0x1fb3a, 0x1fb46, 0x1fb4c, 0x1fb58, 0x1fb6e, 0x1fb72, 0x1fb74, 0x1fb8a, 0x1fb92, 0x1fb94, 0x1fba2, 0x1fba4, + 0x1fba8, 0x1fbb6, 0x1fbda + ]); + /** + * This table contains to codewords for all symbols. + */ + PDF417Common.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, 2000, 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, 1000, 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 + ]); + + /* + * Copyright 2007 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // import java.util.List; + /** + * @author Guenther Grau + */ + /*public final*/ class PDF417DetectorResult { + constructor(bits, points) { + this.bits = bits; + this.points = points; + } + getBits() { + return this.bits; + } + getPoints() { + return this.points; + } + } + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // import java.util.ArrayList; + // import java.util.Arrays; + // import java.util.List; + // import java.util.Map; + /** + * <p>Encapsulates logic that can detect a PDF417 Code in an image, even if the + * PDF417 Code is rotated or skewed, or partially obscured.</p> + * + * @author SITA Lab (kevin.osullivan@sita.aero) + * @author dswitkin@google.com (Daniel Switkin) + * @author Guenther Grau + */ + /*public*/ /*final*/ class Detector$3 { + /** + * <p>Detects a PDF417 Code in an image. Only checks 0 and 180 degree rotations.</p> + * + * @param image barcode image to decode + * @param hints optional hints to detector + * @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will + * be found and returned + * @return {@link PDF417DetectorResult} encapsulating results of detecting a PDF417 code + * @throws NotFoundException if no PDF417 Code can be found + */ + static detectMultiple(image, hints, multiple) { + // TODO detection improvement, tryHarder could try several different luminance thresholds/blackpoints or even + // different binarizers + // boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); + let bitMatrix = image.getBlackMatrix(); + let barcodeCoordinates = Detector$3.detect(multiple, bitMatrix); + if (!barcodeCoordinates.length) { + bitMatrix = bitMatrix.clone(); + bitMatrix.rotate180(); + barcodeCoordinates = Detector$3.detect(multiple, bitMatrix); + } + return new PDF417DetectorResult(bitMatrix, barcodeCoordinates); + } + /** + * Detects PDF417 codes in an image. Only checks 0 degree rotation + * @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will + * be found and returned + * @param bitMatrix bit matrix to detect barcodes in + * @return List of ResultPoint arrays containing the coordinates of found barcodes + */ + static detect(multiple, bitMatrix) { + const barcodeCoordinates = new Array(); + let row = 0; + let column = 0; + let foundBarcodeInRow = false; + while (row < bitMatrix.getHeight()) { + const vertices = Detector$3.findVertices(bitMatrix, row, column); + if (vertices[0] == null && vertices[3] == null) { + if (!foundBarcodeInRow) { + // we didn't find any barcode so that's the end of searching + break; + } + // we didn't find a barcode starting at the given column and row. Try again from the first column and slightly + // below the lowest barcode we found so far. + foundBarcodeInRow = false; + column = 0; + for (const barcodeCoordinate of barcodeCoordinates) { + if (barcodeCoordinate[1] != null) { + row = Math.trunc(Math.max(row, barcodeCoordinate[1].getY())); + } + if (barcodeCoordinate[3] != null) { + row = Math.max(row, Math.trunc(barcodeCoordinate[3].getY())); + } + } + row += Detector$3.ROW_STEP; + continue; + } + foundBarcodeInRow = true; + barcodeCoordinates.push(vertices); + if (!multiple) { + break; + } + // if we didn't find a right row indicator column, then continue the search for the next barcode after the + // start pattern of the barcode just found. + if (vertices[2] != null) { + column = Math.trunc(vertices[2].getX()); + row = Math.trunc(vertices[2].getY()); + } + else { + column = Math.trunc(vertices[4].getX()); + row = Math.trunc(vertices[4].getY()); + } + } + return barcodeCoordinates; + } + /** + * Locate the vertices and the codewords area of a black blob using the Start + * and Stop patterns as locators. + * + * @param matrix the scanned barcode image. + * @return an array containing the vertices: + * vertices[0] x, y top left barcode + * vertices[1] x, y bottom left barcode + * vertices[2] x, y top right barcode + * vertices[3] x, y bottom right barcode + * vertices[4] x, y top left codeword area + * vertices[5] x, y bottom left codeword area + * vertices[6] x, y top right codeword area + * vertices[7] x, y bottom right codeword area + */ + static findVertices(matrix, startRow, startColumn) { + const height = matrix.getHeight(); + const width = matrix.getWidth(); + // const result = new ResultPoint[8]; + const result = new Array(8); + Detector$3.copyToResult(result, Detector$3.findRowsWithPattern(matrix, height, width, startRow, startColumn, Detector$3.START_PATTERN), Detector$3.INDEXES_START_PATTERN); + if (result[4] != null) { + startColumn = Math.trunc(result[4].getX()); + startRow = Math.trunc(result[4].getY()); + } + Detector$3.copyToResult(result, Detector$3.findRowsWithPattern(matrix, height, width, startRow, startColumn, Detector$3.STOP_PATTERN), Detector$3.INDEXES_STOP_PATTERN); + return result; + } + static copyToResult(result, tmpResult, destinationIndexes) { + for (let i = 0; i < destinationIndexes.length; i++) { + result[destinationIndexes[i]] = tmpResult[i]; + } + } + static findRowsWithPattern(matrix, height, width, startRow, startColumn, pattern) { + // const result = new ResultPoint[4]; + const result = new Array(4); + let found = false; + const counters = new Int32Array(pattern.length); + for (; startRow < height; startRow += Detector$3.ROW_STEP) { + let loc = Detector$3.findGuardPattern(matrix, startColumn, startRow, width, false, pattern, counters); + if (loc != null) { + while (startRow > 0) { + const previousRowLoc = Detector$3.findGuardPattern(matrix, startColumn, --startRow, width, false, pattern, counters); + if (previousRowLoc != null) { + loc = previousRowLoc; + } + else { + startRow++; + break; + } + } + result[0] = new ResultPoint(loc[0], startRow); + result[1] = new ResultPoint(loc[1], startRow); + found = true; + break; + } + } + let stopRow = startRow + 1; + // Last row of the current symbol that contains pattern + if (found) { + let skippedRowCount = 0; + let previousRowLoc = Int32Array.from([Math.trunc(result[0].getX()), Math.trunc(result[1].getX())]); + for (; stopRow < height; stopRow++) { + const loc = Detector$3.findGuardPattern(matrix, previousRowLoc[0], stopRow, width, false, pattern, counters); + // a found pattern is only considered to belong to the same barcode if the start and end positions + // don't differ too much. Pattern drift should be not bigger than two for consecutive rows. With + // a higher number of skipped rows drift could be larger. To keep it simple for now, we allow a slightly + // larger drift and don't check for skipped rows. + if (loc != null && + Math.abs(previousRowLoc[0] - loc[0]) < Detector$3.MAX_PATTERN_DRIFT && + Math.abs(previousRowLoc[1] - loc[1]) < Detector$3.MAX_PATTERN_DRIFT) { + previousRowLoc = loc; + skippedRowCount = 0; + } + else { + if (skippedRowCount > Detector$3.SKIPPED_ROW_COUNT_MAX) { + break; + } + else { + skippedRowCount++; + } + } + } + stopRow -= skippedRowCount + 1; + result[2] = new ResultPoint(previousRowLoc[0], stopRow); + result[3] = new ResultPoint(previousRowLoc[1], stopRow); + } + if (stopRow - startRow < Detector$3.BARCODE_MIN_HEIGHT) { + Arrays.fill(result, null); + } + return result; + } + /** + * @param matrix row of black/white values to search + * @param column x position to start search + * @param row y position to start search + * @param width the number of pixels to search on this row + * @param pattern pattern of counts of number of black and white pixels that are + * being searched for as a pattern + * @param counters array of counters, as long as pattern, to re-use + * @return start/end horizontal offset of guard pattern, as an array of two ints. + */ + static findGuardPattern(matrix, column, row, width, whiteFirst, pattern, counters) { + Arrays.fillWithin(counters, 0, counters.length, 0); + let patternStart = column; + let pixelDrift = 0; + // if there are black pixels left of the current pixel shift to the left, but only for MAX_PIXEL_DRIFT pixels + while (matrix.get(patternStart, row) && patternStart > 0 && pixelDrift++ < Detector$3.MAX_PIXEL_DRIFT) { + patternStart--; + } + let x = patternStart; + let counterPosition = 0; + let patternLength = pattern.length; + for (let isWhite = whiteFirst; x < width; x++) { + let pixel = matrix.get(x, row); + if (pixel !== isWhite) { + counters[counterPosition]++; + } + else { + if (counterPosition === patternLength - 1) { + if (Detector$3.patternMatchVariance(counters, pattern, Detector$3.MAX_INDIVIDUAL_VARIANCE) < Detector$3.MAX_AVG_VARIANCE) { + return new Int32Array([patternStart, x]); + } + patternStart += counters[0] + counters[1]; + System.arraycopy(counters, 2, counters, 0, counterPosition - 1); + counters[counterPosition - 1] = 0; + counters[counterPosition] = 0; + counterPosition--; + } + else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + if (counterPosition === patternLength - 1 && + Detector$3.patternMatchVariance(counters, pattern, Detector$3.MAX_INDIVIDUAL_VARIANCE) < Detector$3.MAX_AVG_VARIANCE) { + return new Int32Array([patternStart, x - 1]); + } + return null; + } + /** + * Determines how closely a set of observed counts of runs of black/white + * values matches a given target pattern. This is reported as the ratio of + * the total variance from the expected pattern proportions across all + * pattern elements, to the length of the pattern. + * + * @param counters observed counters + * @param pattern expected pattern + * @param maxIndividualVariance The most any counter can differ before we give up + * @return ratio of total variance between counters and pattern compared to total pattern size + */ + static patternMatchVariance(counters, pattern, maxIndividualVariance) { + let numCounters = counters.length; + let total = 0; + let patternLength = 0; + for (let i = 0; i < numCounters; i++) { + total += counters[i]; + patternLength += pattern[i]; + } + if (total < patternLength) { + // If we don't even have one pixel per unit of bar width, assume this + // is too small to reliably match, so fail: + return /*Float.POSITIVE_INFINITY*/ Infinity; + } + // We're going to fake floating-point math in integers. We just need to use more bits. + // Scale up patternLength so that intermediate values below like scaledCounter will have + // more "significant digits". + let unitBarWidth = total / patternLength; + maxIndividualVariance *= unitBarWidth; + let totalVariance = 0.0; + for (let x = 0; x < numCounters; x++) { + let counter = counters[x]; + let scaledPattern = pattern[x] * unitBarWidth; + let variance = counter > scaledPattern ? counter - scaledPattern : scaledPattern - counter; + if (variance > maxIndividualVariance) { + return /*Float.POSITIVE_INFINITY*/ Infinity; + } + totalVariance += variance; + } + return totalVariance / total; + } + } + Detector$3.INDEXES_START_PATTERN = Int32Array.from([0, 4, 1, 5]); + Detector$3.INDEXES_STOP_PATTERN = Int32Array.from([6, 2, 7, 3]); + Detector$3.MAX_AVG_VARIANCE = 0.42; + Detector$3.MAX_INDIVIDUAL_VARIANCE = 0.8; + // B S B S B S B S Bar/Space pattern + // 11111111 0 1 0 1 0 1 000 + Detector$3.START_PATTERN = Int32Array.from([8, 1, 1, 1, 1, 1, 1, 3]); + // 1111111 0 1 000 1 0 1 00 1 + Detector$3.STOP_PATTERN = Int32Array.from([7, 1, 1, 3, 1, 1, 1, 2, 1]); + Detector$3.MAX_PIXEL_DRIFT = 3; + Detector$3.MAX_PATTERN_DRIFT = 5; + // if we set the value too low, then we don't detect the correct height of the bar if the start patterns are damaged. + // if we set the value too high, then we might detect the start pattern from a neighbor barcode. + Detector$3.SKIPPED_ROW_COUNT_MAX = 25; + // A PDF471 barcode should have at least 3 rows, with each row being >= 3 times the module width. Therefore it should be at least + // 9 pixels tall. To be conservative, we use about half the size to ensure we don't miss it. + Detector$3.ROW_STEP = 5; + Detector$3.BARCODE_MIN_HEIGHT = 10; + + /* + * Copyright 2012 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * @author Sean Owen + * @see com.google.zxing.common.reedsolomon.GenericGFPoly + */ + /*final*/ class ModulusPoly { + constructor(field, coefficients) { + if (coefficients.length === 0) { + throw new IllegalArgumentException(); + } + this.field = field; + let coefficientsLength = /*int*/ coefficients.length; + if (coefficientsLength > 1 && coefficients[0] === 0) { + // Leading term must be non-zero for anything except the constant polynomial "0" + let firstNonZero = /*int*/ 1; + while (firstNonZero < coefficientsLength && coefficients[firstNonZero] === 0) { + firstNonZero++; + } + if (firstNonZero === coefficientsLength) { + this.coefficients = new Int32Array([0]); + } + else { + this.coefficients = new Int32Array(coefficientsLength - firstNonZero); + System.arraycopy(coefficients, firstNonZero, this.coefficients, 0, this.coefficients.length); + } + } + else { + this.coefficients = coefficients; + } + } + getCoefficients() { + return this.coefficients; + } + /** + * @return degree of this polynomial + */ + getDegree() { + return this.coefficients.length - 1; + } + /** + * @return true iff this polynomial is the monomial "0" + */ + isZero() { + return this.coefficients[0] === 0; + } + /** + * @return coefficient of x^degree term in this polynomial + */ + getCoefficient(degree) { + return this.coefficients[this.coefficients.length - 1 - degree]; + } + /** + * @return evaluation of this polynomial at a given point + */ + evaluateAt(a) { + if (a === 0) { + // Just return the x^0 coefficient + return this.getCoefficient(0); + } + if (a === 1) { + // Just the sum of the coefficients + let sum = /*int*/ 0; + for (let coefficient /*int*/ of this.coefficients) { + sum = this.field.add(sum, coefficient); + } + return sum; + } + let result = /*int*/ this.coefficients[0]; + let size = /*int*/ this.coefficients.length; + for (let i /*int*/ = 1; i < size; i++) { + result = this.field.add(this.field.multiply(a, result), this.coefficients[i]); + } + return result; + } + add(other) { + if (!this.field.equals(other.field)) { + throw new IllegalArgumentException('ModulusPolys do not have same ModulusGF field'); + } + if (this.isZero()) { + return other; + } + if (other.isZero()) { + return this; + } + let smallerCoefficients = this.coefficients; + let largerCoefficients = other.coefficients; + if (smallerCoefficients.length > largerCoefficients.length) { + let temp = smallerCoefficients; + smallerCoefficients = largerCoefficients; + largerCoefficients = temp; + } + let sumDiff = new Int32Array(largerCoefficients.length); + let lengthDiff = /*int*/ largerCoefficients.length - smallerCoefficients.length; + // Copy high-order terms only found in higher-degree polynomial's coefficients + System.arraycopy(largerCoefficients, 0, sumDiff, 0, lengthDiff); + for (let i /*int*/ = lengthDiff; i < largerCoefficients.length; i++) { + sumDiff[i] = this.field.add(smallerCoefficients[i - lengthDiff], largerCoefficients[i]); + } + return new ModulusPoly(this.field, sumDiff); + } + subtract(other) { + if (!this.field.equals(other.field)) { + throw new IllegalArgumentException('ModulusPolys do not have same ModulusGF field'); + } + if (other.isZero()) { + return this; + } + return this.add(other.negative()); + } + multiply(other) { + if (other instanceof ModulusPoly) { + return this.multiplyOther(other); + } + return this.multiplyScalar(other); + } + multiplyOther(other) { + if (!this.field.equals(other.field)) { + throw new IllegalArgumentException('ModulusPolys do not have same ModulusGF field'); + } + if (this.isZero() || other.isZero()) { + // return this.field.getZero(); + return new ModulusPoly(this.field, new Int32Array([0])); + } + let aCoefficients = this.coefficients; + let aLength = /*int*/ aCoefficients.length; + let bCoefficients = other.coefficients; + let bLength = /*int*/ bCoefficients.length; + let product = new Int32Array(aLength + bLength - 1); + for (let i /*int*/ = 0; i < aLength; i++) { + let aCoeff = /*int*/ aCoefficients[i]; + for (let j /*int*/ = 0; j < bLength; j++) { + product[i + j] = this.field.add(product[i + j], this.field.multiply(aCoeff, bCoefficients[j])); + } + } + return new ModulusPoly(this.field, product); + } + negative() { + let size = /*int*/ this.coefficients.length; + let negativeCoefficients = new Int32Array(size); + for (let i /*int*/ = 0; i < size; i++) { + negativeCoefficients[i] = this.field.subtract(0, this.coefficients[i]); + } + return new ModulusPoly(this.field, negativeCoefficients); + } + multiplyScalar(scalar) { + if (scalar === 0) { + return new ModulusPoly(this.field, new Int32Array([0])); + } + if (scalar === 1) { + return this; + } + let size = /*int*/ this.coefficients.length; + let product = new Int32Array(size); + for (let i /*int*/ = 0; i < size; i++) { + product[i] = this.field.multiply(this.coefficients[i], scalar); + } + return new ModulusPoly(this.field, product); + } + multiplyByMonomial(degree, coefficient) { + if (degree < 0) { + throw new IllegalArgumentException(); + } + if (coefficient === 0) { + return new ModulusPoly(this.field, new Int32Array([0])); + } + let size = /*int*/ this.coefficients.length; + let product = new Int32Array(size + degree); + for (let i /*int*/ = 0; i < size; i++) { + product[i] = this.field.multiply(this.coefficients[i], coefficient); + } + return new ModulusPoly(this.field, product); + } + /* + ModulusPoly[] divide(other: ModulusPoly) { + if (!field.equals(other.field)) { + throw new IllegalArgumentException("ModulusPolys do not have same ModulusGF field"); + } + if (other.isZero()) { + throw new IllegalArgumentException("Divide by 0"); + } + + let quotient: ModulusPoly = field.getZero(); + let remainder: ModulusPoly = this; + + let denominatorLeadingTerm: /*int/ number = other.getCoefficient(other.getDegree()); + let inverseDenominatorLeadingTerm: /*int/ number = field.inverse(denominatorLeadingTerm); + + while (remainder.getDegree() >= other.getDegree() && !remainder.isZero()) { + let degreeDifference: /*int/ number = remainder.getDegree() - other.getDegree(); + let scale: /*int/ number = field.multiply(remainder.getCoefficient(remainder.getDegree()), inverseDenominatorLeadingTerm); + let term: ModulusPoly = other.multiplyByMonomial(degreeDifference, scale); + let iterationQuotient: ModulusPoly = field.buildMonomial(degreeDifference, scale); + quotient = quotient.add(iterationQuotient); + remainder = remainder.subtract(term); + } + + return new ModulusPoly[] { quotient, remainder }; + } + */ + // @Override + toString() { + let result = new StringBuilder( /*8 * this.getDegree()*/); // dynamic string size in JS + for (let degree /*int*/ = this.getDegree(); degree >= 0; degree--) { + let coefficient = /*int*/ this.getCoefficient(degree); + if (coefficient !== 0) { + if (coefficient < 0) { + result.append(' - '); + coefficient = -coefficient; + } + else { + if (result.length() > 0) { + result.append(' + '); + } + } + if (degree === 0 || coefficient !== 1) { + result.append(coefficient); + } + if (degree !== 0) { + if (degree === 1) { + result.append('x'); + } + else { + result.append('x^'); + result.append(degree); + } + } + } + } + return result.toString(); + } + } + + class ModulusBase { + add(a, b) { + return (a + b) % this.modulus; + } + subtract(a, b) { + return (this.modulus + a - b) % this.modulus; + } + exp(a) { + return this.expTable[a]; + } + log(a) { + if (a === 0) { + throw new IllegalArgumentException(); + } + return this.logTable[a]; + } + inverse(a) { + if (a === 0) { + throw new ArithmeticException(); + } + return this.expTable[this.modulus - this.logTable[a] - 1]; + } + multiply(a, b) { + if (a === 0 || b === 0) { + return 0; + } + return this.expTable[(this.logTable[a] + this.logTable[b]) % (this.modulus - 1)]; + } + getSize() { + return this.modulus; + } + equals(o) { + return o === this; + } + } + + /* + * Copyright 2012 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>A field based on powers of a generator integer, modulo some modulus.</p> + * + * @author Sean Owen + * @see com.google.zxing.common.reedsolomon.GenericGF + */ + /*public final*/ class ModulusGF extends ModulusBase { + // private /*final*/ modulus: /*int*/ number; + constructor(modulus, generator) { + super(); + this.modulus = modulus; + this.expTable = new Int32Array(modulus); + this.logTable = new Int32Array(modulus); + let x = /*int*/ 1; + for (let i /*int*/ = 0; i < modulus; i++) { + this.expTable[i] = x; + x = (x * generator) % modulus; + } + for (let i /*int*/ = 0; i < modulus - 1; i++) { + this.logTable[this.expTable[i]] = i; + } + // logTable[0] == 0 but this should never be used + this.zero = new ModulusPoly(this, new Int32Array([0])); + this.one = new ModulusPoly(this, new Int32Array([1])); + } + getZero() { + return this.zero; + } + getOne() { + return this.one; + } + buildMonomial(degree, coefficient) { + if (degree < 0) { + throw new IllegalArgumentException(); + } + if (coefficient === 0) { + return this.zero; + } + let coefficients = new Int32Array(degree + 1); + coefficients[0] = coefficient; + return new ModulusPoly(this, coefficients); + } + } + ModulusGF.PDF417_GF = new ModulusGF(PDF417Common.NUMBER_OF_CODEWORDS, 3); + + /* + * Copyright 2012 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * <p>PDF417 error correction implementation.</p> + * + * <p>This <a href="http://en.wikipedia.org/wiki/Reed%E2%80%93Solomon_error_correction#Example">example</a> + * is quite useful in understanding the algorithm.</p> + * + * @author Sean Owen + * @see com.google.zxing.common.reedsolomon.ReedSolomonDecoder + */ + /*public final*/ class ErrorCorrection { + constructor() { + this.field = ModulusGF.PDF417_GF; + } + /** + * @param received received codewords + * @param numECCodewords number of those codewords used for EC + * @param erasures location of erasures + * @return number of errors + * @throws ChecksumException if errors cannot be corrected, maybe because of too many errors + */ + decode(received, numECCodewords, erasures) { + let poly = new ModulusPoly(this.field, received); + let S = new Int32Array(numECCodewords); + let error = false; + for (let i /*int*/ = numECCodewords; i > 0; i--) { + let evaluation = poly.evaluateAt(this.field.exp(i)); + S[numECCodewords - i] = evaluation; + if (evaluation !== 0) { + error = true; + } + } + if (!error) { + return 0; + } + let knownErrors = this.field.getOne(); + if (erasures != null) { + for (const erasure of erasures) { + let b = this.field.exp(received.length - 1 - erasure); + // Add (1 - bx) term: + let term = new ModulusPoly(this.field, new Int32Array([this.field.subtract(0, b), 1])); + knownErrors = knownErrors.multiply(term); + } + } + let syndrome = new ModulusPoly(this.field, S); + // syndrome = syndrome.multiply(knownErrors); + let sigmaOmega = this.runEuclideanAlgorithm(this.field.buildMonomial(numECCodewords, 1), syndrome, numECCodewords); + let sigma = sigmaOmega[0]; + let omega = sigmaOmega[1]; + // sigma = sigma.multiply(knownErrors); + let errorLocations = this.findErrorLocations(sigma); + let errorMagnitudes = this.findErrorMagnitudes(omega, sigma, errorLocations); + for (let i /*int*/ = 0; i < errorLocations.length; i++) { + let position = received.length - 1 - this.field.log(errorLocations[i]); + if (position < 0) { + throw ChecksumException.getChecksumInstance(); + } + received[position] = this.field.subtract(received[position], errorMagnitudes[i]); + } + return errorLocations.length; + } + /** + * + * @param ModulusPoly + * @param a + * @param ModulusPoly + * @param b + * @param int + * @param R + * @throws ChecksumException + */ + runEuclideanAlgorithm(a, b, R) { + // Assume a's degree is >= b's + if (a.getDegree() < b.getDegree()) { + let temp = a; + a = b; + b = temp; + } + let rLast = a; + let r = b; + let tLast = this.field.getZero(); + let t = this.field.getOne(); + // Run Euclidean algorithm until r's degree is less than R/2 + while (r.getDegree() >= Math.round(R / 2)) { + let rLastLast = rLast; + let tLastLast = tLast; + rLast = r; + tLast = t; + // Divide rLastLast by rLast, with quotient in q and remainder in r + if (rLast.isZero()) { + // Oops, Euclidean algorithm already terminated? + throw ChecksumException.getChecksumInstance(); + } + r = rLastLast; + let q = this.field.getZero(); + let denominatorLeadingTerm = rLast.getCoefficient(rLast.getDegree()); + let dltInverse = this.field.inverse(denominatorLeadingTerm); + while (r.getDegree() >= rLast.getDegree() && !r.isZero()) { + let degreeDiff = r.getDegree() - rLast.getDegree(); + let scale = this.field.multiply(r.getCoefficient(r.getDegree()), dltInverse); + q = q.add(this.field.buildMonomial(degreeDiff, scale)); + r = r.subtract(rLast.multiplyByMonomial(degreeDiff, scale)); + } + t = q.multiply(tLast).subtract(tLastLast).negative(); + } + let sigmaTildeAtZero = t.getCoefficient(0); + if (sigmaTildeAtZero === 0) { + throw ChecksumException.getChecksumInstance(); + } + let inverse = this.field.inverse(sigmaTildeAtZero); + let sigma = t.multiply(inverse); + let omega = r.multiply(inverse); + return [sigma, omega]; + } + /** + * + * @param errorLocator + * @throws ChecksumException + */ + findErrorLocations(errorLocator) { + // This is a direct application of Chien's search + let numErrors = errorLocator.getDegree(); + let result = new Int32Array(numErrors); + let e = 0; + for (let i /*int*/ = 1; i < this.field.getSize() && e < numErrors; i++) { + if (errorLocator.evaluateAt(i) === 0) { + result[e] = this.field.inverse(i); + e++; + } + } + if (e !== numErrors) { + throw ChecksumException.getChecksumInstance(); + } + return result; + } + findErrorMagnitudes(errorEvaluator, errorLocator, errorLocations) { + let errorLocatorDegree = errorLocator.getDegree(); + let formalDerivativeCoefficients = new Int32Array(errorLocatorDegree); + for (let i /*int*/ = 1; i <= errorLocatorDegree; i++) { + formalDerivativeCoefficients[errorLocatorDegree - i] = + this.field.multiply(i, errorLocator.getCoefficient(i)); + } + let formalDerivative = new ModulusPoly(this.field, formalDerivativeCoefficients); + // This is directly applying Forney's Formula + let s = errorLocations.length; + let result = new Int32Array(s); + for (let i /*int*/ = 0; i < s; i++) { + let xiInverse = this.field.inverse(errorLocations[i]); + let numerator = this.field.subtract(0, errorEvaluator.evaluateAt(xiInverse)); + let denominator = this.field.inverse(formalDerivative.evaluateAt(xiInverse)); + result[i] = this.field.multiply(numerator, denominator); + } + return result; + } + } + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * @author Guenther Grau + */ + /*final*/ class BoundingBox { + constructor(image, topLeft, bottomLeft, topRight, bottomRight) { + if (image instanceof BoundingBox) { + this.constructor_2(image); + } + else { + this.constructor_1(image, topLeft, bottomLeft, topRight, bottomRight); + } + } + /** + * + * @param image + * @param topLeft + * @param bottomLeft + * @param topRight + * @param bottomRight + * + * @throws NotFoundException + */ + constructor_1(image, topLeft, bottomLeft, topRight, bottomRight) { + const leftUnspecified = topLeft == null || bottomLeft == null; + const rightUnspecified = topRight == null || bottomRight == null; + if (leftUnspecified && rightUnspecified) { + throw new NotFoundException(); + } + if (leftUnspecified) { + topLeft = new ResultPoint(0, topRight.getY()); + bottomLeft = new ResultPoint(0, bottomRight.getY()); + } + else if (rightUnspecified) { + topRight = new ResultPoint(image.getWidth() - 1, topLeft.getY()); + bottomRight = new ResultPoint(image.getWidth() - 1, bottomLeft.getY()); + } + this.image = image; + this.topLeft = topLeft; + this.bottomLeft = bottomLeft; + this.topRight = topRight; + this.bottomRight = bottomRight; + this.minX = Math.trunc(Math.min(topLeft.getX(), bottomLeft.getX())); + this.maxX = Math.trunc(Math.max(topRight.getX(), bottomRight.getX())); + this.minY = Math.trunc(Math.min(topLeft.getY(), topRight.getY())); + this.maxY = Math.trunc(Math.max(bottomLeft.getY(), bottomRight.getY())); + } + constructor_2(boundingBox) { + this.image = boundingBox.image; + this.topLeft = boundingBox.getTopLeft(); + this.bottomLeft = boundingBox.getBottomLeft(); + this.topRight = boundingBox.getTopRight(); + this.bottomRight = boundingBox.getBottomRight(); + this.minX = boundingBox.getMinX(); + this.maxX = boundingBox.getMaxX(); + this.minY = boundingBox.getMinY(); + this.maxY = boundingBox.getMaxY(); + } + /** + * @throws NotFoundException + */ + static merge(leftBox, rightBox) { + if (leftBox == null) { + return rightBox; + } + if (rightBox == null) { + return leftBox; + } + return new BoundingBox(leftBox.image, leftBox.topLeft, leftBox.bottomLeft, rightBox.topRight, rightBox.bottomRight); + } + /** + * @throws NotFoundException + */ + addMissingRows(missingStartRows, missingEndRows, isLeft) { + let newTopLeft = this.topLeft; + let newBottomLeft = this.bottomLeft; + let newTopRight = this.topRight; + let newBottomRight = this.bottomRight; + if (missingStartRows > 0) { + let top = isLeft ? this.topLeft : this.topRight; + let newMinY = Math.trunc(top.getY() - missingStartRows); + if (newMinY < 0) { + newMinY = 0; + } + let newTop = new ResultPoint(top.getX(), newMinY); + if (isLeft) { + newTopLeft = newTop; + } + else { + newTopRight = newTop; + } + } + if (missingEndRows > 0) { + let bottom = isLeft ? this.bottomLeft : this.bottomRight; + let newMaxY = Math.trunc(bottom.getY() + missingEndRows); + if (newMaxY >= this.image.getHeight()) { + newMaxY = this.image.getHeight() - 1; + } + let newBottom = new ResultPoint(bottom.getX(), newMaxY); + if (isLeft) { + newBottomLeft = newBottom; + } + else { + newBottomRight = newBottom; + } + } + return new BoundingBox(this.image, newTopLeft, newBottomLeft, newTopRight, newBottomRight); + } + 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; + } + } + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // package com.google.zxing.pdf417.decoder; + /** + * @author Guenther Grau + */ + /*final*/ class BarcodeMetadata { + constructor(columnCount, rowCountUpperPart, rowCountLowerPart, errorCorrectionLevel) { + this.columnCount = columnCount; + this.errorCorrectionLevel = errorCorrectionLevel; + this.rowCountUpperPart = rowCountUpperPart; + this.rowCountLowerPart = rowCountLowerPart; + this.rowCount = rowCountUpperPart + rowCountLowerPart; + } + getColumnCount() { + return this.columnCount; + } + getErrorCorrectionLevel() { + return this.errorCorrectionLevel; + } + getRowCount() { + return this.rowCount; + } + getRowCountUpperPart() { + return this.rowCountUpperPart; + } + getRowCountLowerPart() { + return this.rowCountLowerPart; + } + } + + /** + * Java Formatter class polyfill that works in the JS way. + */ + class Formatter { + constructor() { + this.buffer = ''; + } + /** + * + * @see https://stackoverflow.com/a/13439711/4367683 + * + * @param str + * @param arr + */ + static form(str, arr) { + let i = -1; + function callback(exp, p0, p1, p2, p3, p4) { + if (exp === '%%') + return '%'; + if (arr[++i] === undefined) + return undefined; + exp = p2 ? parseInt(p2.substr(1)) : undefined; + let base = p3 ? parseInt(p3.substr(1)) : undefined; + let val; + switch (p4) { + case 's': + val = arr[i]; + break; + case 'c': + val = arr[i][0]; + break; + case 'f': + val = parseFloat(arr[i]).toFixed(exp); + break; + case 'p': + val = parseFloat(arr[i]).toPrecision(exp); + break; + case 'e': + val = parseFloat(arr[i]).toExponential(exp); + break; + case 'x': + val = parseInt(arr[i]).toString(base ? base : 16); + break; + case 'd': + val = parseFloat(parseInt(arr[i], base ? base : 10).toPrecision(exp)).toFixed(0); + break; + } + val = typeof val === 'object' ? JSON.stringify(val) : (+val).toString(base); + let size = parseInt(p1); /* padding size */ + let ch = p1 && (p1[0] + '') === '0' ? '0' : ' '; /* isnull? */ + while (val.length < size) + val = p0 !== undefined ? val + ch : ch + val; /* isminus? */ + return val; + } + let regex = /%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g; + return str.replace(regex, callback); + } + /** + * + * @param append The new string to append. + * @param args Argumets values to be formated. + */ + format(append, ...args) { + this.buffer += Formatter.form(append, args); + } + /** + * Returns the Formatter string value. + */ + toString() { + return this.buffer; + } + } + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * @author Guenther Grau + */ + class DetectionResultColumn { + constructor(boundingBox) { + this.boundingBox = new BoundingBox(boundingBox); + // this.codewords = new Codeword[boundingBox.getMaxY() - boundingBox.getMinY() + 1]; + this.codewords = new Array(boundingBox.getMaxY() - boundingBox.getMinY() + 1); + } + /*final*/ getCodewordNearby(imageRow) { + let codeword = this.getCodeword(imageRow); + if (codeword != null) { + return codeword; + } + for (let i = 1; i < DetectionResultColumn.MAX_NEARBY_DISTANCE; i++) { + let nearImageRow = this.imageRowToCodewordIndex(imageRow) - i; + if (nearImageRow >= 0) { + codeword = this.codewords[nearImageRow]; + if (codeword != null) { + return codeword; + } + } + nearImageRow = this.imageRowToCodewordIndex(imageRow) + i; + if (nearImageRow < this.codewords.length) { + codeword = this.codewords[nearImageRow]; + if (codeword != null) { + return codeword; + } + } + } + return null; + } + /*final int*/ imageRowToCodewordIndex(imageRow) { + return imageRow - this.boundingBox.getMinY(); + } + /*final void*/ setCodeword(imageRow, codeword) { + this.codewords[this.imageRowToCodewordIndex(imageRow)] = codeword; + } + /*final*/ getCodeword(imageRow) { + return this.codewords[this.imageRowToCodewordIndex(imageRow)]; + } + /*final*/ getBoundingBox() { + return this.boundingBox; + } + /*final*/ getCodewords() { + return this.codewords; + } + // @Override + toString() { + const formatter = new Formatter(); + let row = 0; + for (const codeword of this.codewords) { + if (codeword == null) { + formatter.format('%3d: | %n', row++); + continue; + } + formatter.format('%3d: %3d|%3d%n', row++, codeword.getRowNumber(), codeword.getValue()); + } + return formatter.toString(); + } + } + DetectionResultColumn.MAX_NEARBY_DISTANCE = 5; + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // import java.util.ArrayList; + // import java.util.Collection; + // import java.util.HashMap; + // import java.util.Map; + // import java.util.Map.Entry; + /** + * @author Guenther Grau + */ + /*final*/ class BarcodeValue { + constructor() { + this.values = new Map(); + } + /** + * Add an occurrence of a value + */ + setValue(value) { + value = Math.trunc(value); + let confidence = this.values.get(value); + if (confidence == null) { + confidence = 0; + } + confidence++; + this.values.set(value, confidence); + } + /** + * Determines the maximum occurrence of a set value and returns all values which were set with this occurrence. + * @return an array of int, containing the values with the highest occurrence, or null, if no value was set + */ + getValue() { + let maxConfidence = -1; + let result = new Array(); + for (const [key, value] of this.values.entries()) { + const entry = { + getKey: () => key, + getValue: () => value, + }; + if (entry.getValue() > maxConfidence) { + maxConfidence = entry.getValue(); + result = []; + result.push(entry.getKey()); + } + else if (entry.getValue() === maxConfidence) { + result.push(entry.getKey()); + } + } + return PDF417Common.toIntArray(result); + } + getConfidence(value) { + return this.values.get(value); + } + } + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * @author Guenther Grau + */ + /*final*/ class DetectionResultRowIndicatorColumn extends DetectionResultColumn { + constructor(boundingBox, isLeft) { + super(boundingBox); + this._isLeft = isLeft; + } + setRowNumbers() { + for (let codeword /*Codeword*/ of this.getCodewords()) { + if (codeword != null) { + codeword.setRowNumberAsRowIndicatorColumn(); + } + } + } + // TODO implement properly + // TODO maybe we should add missing codewords to store the correct row number to make + // finding row numbers for other columns easier + // use row height count to make detection of invalid row numbers more reliable + adjustCompleteIndicatorColumnRowNumbers(barcodeMetadata) { + let codewords = this.getCodewords(); + this.setRowNumbers(); + this.removeIncorrectCodewords(codewords, barcodeMetadata); + let boundingBox = this.getBoundingBox(); + let top = this._isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight(); + let bottom = this._isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight(); + let firstRow = this.imageRowToCodewordIndex(Math.trunc(top.getY())); + let lastRow = this.imageRowToCodewordIndex(Math.trunc(bottom.getY())); + // We need to be careful using the average row height. Barcode could be skewed so that we have smaller and + // taller rows + // float averageRowHeight = (lastRow - firstRow) / /*(float)*/ barcodeMetadata.getRowCount(); + let barcodeRow = -1; + let maxRowHeight = 1; + let currentRowHeight = 0; + for (let codewordsRow /*int*/ = firstRow; codewordsRow < lastRow; codewordsRow++) { + if (codewords[codewordsRow] == null) { + continue; + } + let codeword = codewords[codewordsRow]; + // float expectedRowNumber = (codewordsRow - firstRow) / averageRowHeight; + // if (Math.abs(codeword.getRowNumber() - expectedRowNumber) > 2) { + // SimpleLog.log(LEVEL.WARNING, + // "Removing codeword, rowNumberSkew too high, codeword[" + codewordsRow + "]: Expected Row: " + + // expectedRowNumber + ", RealRow: " + codeword.getRowNumber() + ", value: " + codeword.getValue()); + // codewords[codewordsRow] = null; + // } + let rowDifference = codeword.getRowNumber() - barcodeRow; + // TODO improve handling with case where first row indicator doesn't start with 0 + if (rowDifference === 0) { + currentRowHeight++; + } + else if (rowDifference === 1) { + maxRowHeight = Math.max(maxRowHeight, currentRowHeight); + currentRowHeight = 1; + barcodeRow = codeword.getRowNumber(); + } + else if (rowDifference < 0 || + codeword.getRowNumber() >= barcodeMetadata.getRowCount() || + rowDifference > codewordsRow) { + codewords[codewordsRow] = null; + } + else { + let checkedRows; + if (maxRowHeight > 2) { + checkedRows = (maxRowHeight - 2) * rowDifference; + } + else { + checkedRows = rowDifference; + } + let closePreviousCodewordFound = checkedRows >= codewordsRow; + for (let i /*int*/ = 1; i <= checkedRows && !closePreviousCodewordFound; i++) { + // there must be (height * rowDifference) number of codewords missing. For now we assume height = 1. + // This should hopefully get rid of most problems already. + closePreviousCodewordFound = codewords[codewordsRow - i] != null; + } + if (closePreviousCodewordFound) { + codewords[codewordsRow] = null; + } + else { + barcodeRow = codeword.getRowNumber(); + currentRowHeight = 1; + } + } + } + // return (int) (averageRowHeight + 0.5); + } + getRowHeights() { + let barcodeMetadata = this.getBarcodeMetadata(); + if (barcodeMetadata == null) { + return null; + } + this.adjustIncompleteIndicatorColumnRowNumbers(barcodeMetadata); + let result = new Int32Array(barcodeMetadata.getRowCount()); + for (let codeword /*Codeword*/ of this.getCodewords()) { + if (codeword != null) { + let rowNumber = codeword.getRowNumber(); + if (rowNumber >= result.length) { + // We have more rows than the barcode metadata allows for, ignore them. + continue; + } + result[rowNumber]++; + } // else throw exception? + } + return result; + } + // TODO maybe we should add missing codewords to store the correct row number to make + // finding row numbers for other columns easier + // use row height count to make detection of invalid row numbers more reliable + adjustIncompleteIndicatorColumnRowNumbers(barcodeMetadata) { + let boundingBox = this.getBoundingBox(); + let top = this._isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight(); + let bottom = this._isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight(); + let firstRow = this.imageRowToCodewordIndex(Math.trunc(top.getY())); + let lastRow = this.imageRowToCodewordIndex(Math.trunc(bottom.getY())); + // float averageRowHeight = (lastRow - firstRow) / /*(float)*/ barcodeMetadata.getRowCount(); + let codewords = this.getCodewords(); + let barcodeRow = -1; + for (let codewordsRow /*int*/ = firstRow; codewordsRow < lastRow; codewordsRow++) { + if (codewords[codewordsRow] == null) { + continue; + } + let codeword = codewords[codewordsRow]; + codeword.setRowNumberAsRowIndicatorColumn(); + let rowDifference = codeword.getRowNumber() - barcodeRow; + // TODO improve handling with case where first row indicator doesn't start with 0 + if (rowDifference === 0) ; + else if (rowDifference === 1) { + barcodeRow = codeword.getRowNumber(); + } + else if (codeword.getRowNumber() >= barcodeMetadata.getRowCount()) { + codewords[codewordsRow] = null; + } + else { + barcodeRow = codeword.getRowNumber(); + } + } + // return (int) (averageRowHeight + 0.5); + } + getBarcodeMetadata() { + let codewords = this.getCodewords(); + let barcodeColumnCount = new BarcodeValue(); + let barcodeRowCountUpperPart = new BarcodeValue(); + let barcodeRowCountLowerPart = new BarcodeValue(); + let barcodeECLevel = new BarcodeValue(); + for (let codeword /*Codeword*/ of codewords) { + if (codeword == null) { + continue; + } + codeword.setRowNumberAsRowIndicatorColumn(); + let rowIndicatorValue = codeword.getValue() % 30; + let codewordRowNumber = codeword.getRowNumber(); + if (!this._isLeft) { + codewordRowNumber += 2; + } + switch (codewordRowNumber % 3) { + case 0: + barcodeRowCountUpperPart.setValue(rowIndicatorValue * 3 + 1); + break; + case 1: + barcodeECLevel.setValue(rowIndicatorValue / 3); + barcodeRowCountLowerPart.setValue(rowIndicatorValue % 3); + break; + case 2: + barcodeColumnCount.setValue(rowIndicatorValue + 1); + break; + } + } + // Maybe we should check if we have ambiguous values? + if ((barcodeColumnCount.getValue().length === 0) || + (barcodeRowCountUpperPart.getValue().length === 0) || + (barcodeRowCountLowerPart.getValue().length === 0) || + (barcodeECLevel.getValue().length === 0) || + barcodeColumnCount.getValue()[0] < 1 || + barcodeRowCountUpperPart.getValue()[0] + barcodeRowCountLowerPart.getValue()[0] < PDF417Common.MIN_ROWS_IN_BARCODE || + barcodeRowCountUpperPart.getValue()[0] + barcodeRowCountLowerPart.getValue()[0] > PDF417Common.MAX_ROWS_IN_BARCODE) { + return null; + } + let barcodeMetadata = new BarcodeMetadata(barcodeColumnCount.getValue()[0], barcodeRowCountUpperPart.getValue()[0], barcodeRowCountLowerPart.getValue()[0], barcodeECLevel.getValue()[0]); + this.removeIncorrectCodewords(codewords, barcodeMetadata); + return barcodeMetadata; + } + removeIncorrectCodewords(codewords, barcodeMetadata) { + // Remove codewords which do not match the metadata + // TODO Maybe we should keep the incorrect codewords for the start and end positions? + for (let codewordRow /*int*/ = 0; codewordRow < codewords.length; codewordRow++) { + let codeword = codewords[codewordRow]; + if (codewords[codewordRow] == null) { + continue; + } + let rowIndicatorValue = codeword.getValue() % 30; + let codewordRowNumber = codeword.getRowNumber(); + if (codewordRowNumber > barcodeMetadata.getRowCount()) { + codewords[codewordRow] = null; + continue; + } + if (!this._isLeft) { + codewordRowNumber += 2; + } + switch (codewordRowNumber % 3) { + case 0: + if (rowIndicatorValue * 3 + 1 !== barcodeMetadata.getRowCountUpperPart()) { + codewords[codewordRow] = null; + } + break; + case 1: + if (Math.trunc(rowIndicatorValue / 3) !== barcodeMetadata.getErrorCorrectionLevel() || + rowIndicatorValue % 3 !== barcodeMetadata.getRowCountLowerPart()) { + codewords[codewordRow] = null; + } + break; + case 2: + if (rowIndicatorValue + 1 !== barcodeMetadata.getColumnCount()) { + codewords[codewordRow] = null; + } + break; + } + } + } + isLeft() { + return this._isLeft; + } + // @Override + toString() { + return 'IsLeft: ' + this._isLeft + '\n' + super.toString(); + } + } + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * @author Guenther Grau + */ + /*final*/ class DetectionResult { + constructor(barcodeMetadata, boundingBox) { + /*final*/ this.ADJUST_ROW_NUMBER_SKIP = 2; + this.barcodeMetadata = barcodeMetadata; + this.barcodeColumnCount = barcodeMetadata.getColumnCount(); + this.boundingBox = boundingBox; + // this.detectionResultColumns = new DetectionResultColumn[this.barcodeColumnCount + 2]; + this.detectionResultColumns = new Array(this.barcodeColumnCount + 2); + } + getDetectionResultColumns() { + this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]); + this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount + 1]); + let unadjustedCodewordCount = PDF417Common.MAX_CODEWORDS_IN_BARCODE; + let previousUnadjustedCount; + do { + previousUnadjustedCount = unadjustedCodewordCount; + unadjustedCodewordCount = this.adjustRowNumbersAndGetCount(); + } while (unadjustedCodewordCount > 0 && unadjustedCodewordCount < previousUnadjustedCount); + return this.detectionResultColumns; + } + adjustIndicatorColumnRowNumbers(detectionResultColumn) { + if (detectionResultColumn != null) { + detectionResultColumn + .adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata); + } + } + // TODO ensure that no detected codewords with unknown row number are left + // we should be able to estimate the row height and use it as a hint for the row number + // we should also fill the rows top to bottom and bottom to top + /** + * @return number of codewords which don't have a valid row number. Note that the count is not accurate as codewords + * will be counted several times. It just serves as an indicator to see when we can stop adjusting row numbers + */ + adjustRowNumbersAndGetCount() { + let unadjustedCount = this.adjustRowNumbersByRow(); + if (unadjustedCount === 0) { + return 0; + } + for (let barcodeColumn /*int*/ = 1; barcodeColumn < this.barcodeColumnCount + 1; barcodeColumn++) { + let codewords = this.detectionResultColumns[barcodeColumn].getCodewords(); + for (let codewordsRow /*int*/ = 0; codewordsRow < codewords.length; codewordsRow++) { + if (codewords[codewordsRow] == null) { + continue; + } + if (!codewords[codewordsRow].hasValidRowNumber()) { + this.adjustRowNumbers(barcodeColumn, codewordsRow, codewords); + } + } + } + return unadjustedCount; + } + adjustRowNumbersByRow() { + this.adjustRowNumbersFromBothRI(); + // TODO we should only do full row adjustments if row numbers of left and right row indicator column match. + // Maybe it's even better to calculated the height (rows: d) and divide it by the number of barcode + // rows. This, together with the LRI and RRI row numbers should allow us to get a good estimate where a row + // number starts and ends. + let unadjustedCount = this.adjustRowNumbersFromLRI(); + return unadjustedCount + this.adjustRowNumbersFromRRI(); + } + adjustRowNumbersFromBothRI() { + if (this.detectionResultColumns[0] == null || this.detectionResultColumns[this.barcodeColumnCount + 1] == null) { + return; + } + let LRIcodewords = this.detectionResultColumns[0].getCodewords(); + let RRIcodewords = this.detectionResultColumns[this.barcodeColumnCount + 1].getCodewords(); + for (let codewordsRow /*int*/ = 0; codewordsRow < LRIcodewords.length; codewordsRow++) { + if (LRIcodewords[codewordsRow] != null && + RRIcodewords[codewordsRow] != null && + LRIcodewords[codewordsRow].getRowNumber() === RRIcodewords[codewordsRow].getRowNumber()) { + for (let barcodeColumn /*int*/ = 1; barcodeColumn <= this.barcodeColumnCount; barcodeColumn++) { + let codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow]; + if (codeword == null) { + continue; + } + codeword.setRowNumber(LRIcodewords[codewordsRow].getRowNumber()); + if (!codeword.hasValidRowNumber()) { + this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow] = null; + } + } + } + } + } + adjustRowNumbersFromRRI() { + if (this.detectionResultColumns[this.barcodeColumnCount + 1] == null) { + return 0; + } + let unadjustedCount = 0; + let codewords = this.detectionResultColumns[this.barcodeColumnCount + 1].getCodewords(); + for (let codewordsRow /*int*/ = 0; codewordsRow < codewords.length; codewordsRow++) { + if (codewords[codewordsRow] == null) { + continue; + } + let rowIndicatorRowNumber = codewords[codewordsRow].getRowNumber(); + let invalidRowCounts = 0; + for (let barcodeColumn /*int*/ = this.barcodeColumnCount + 1; barcodeColumn > 0 && invalidRowCounts < this.ADJUST_ROW_NUMBER_SKIP; barcodeColumn--) { + let codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow]; + if (codeword != null) { + invalidRowCounts = DetectionResult.adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword); + if (!codeword.hasValidRowNumber()) { + unadjustedCount++; + } + } + } + } + return unadjustedCount; + } + adjustRowNumbersFromLRI() { + if (this.detectionResultColumns[0] == null) { + return 0; + } + let unadjustedCount = 0; + let codewords = this.detectionResultColumns[0].getCodewords(); + for (let codewordsRow /*int*/ = 0; codewordsRow < codewords.length; codewordsRow++) { + if (codewords[codewordsRow] == null) { + continue; + } + let rowIndicatorRowNumber = codewords[codewordsRow].getRowNumber(); + let invalidRowCounts = 0; + for (let barcodeColumn /*int*/ = 1; barcodeColumn < this.barcodeColumnCount + 1 && invalidRowCounts < this.ADJUST_ROW_NUMBER_SKIP; barcodeColumn++) { + let codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow]; + if (codeword != null) { + invalidRowCounts = DetectionResult.adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword); + if (!codeword.hasValidRowNumber()) { + unadjustedCount++; + } + } + } + } + return unadjustedCount; + } + static adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword) { + if (codeword == null) { + return invalidRowCounts; + } + if (!codeword.hasValidRowNumber()) { + if (codeword.isValidRowNumber(rowIndicatorRowNumber)) { + codeword.setRowNumber(rowIndicatorRowNumber); + invalidRowCounts = 0; + } + else { + ++invalidRowCounts; + } + } + return invalidRowCounts; + } + adjustRowNumbers(barcodeColumn, codewordsRow, codewords) { + if (!this.detectionResultColumns[barcodeColumn - 1]) { + return; + } + let codeword = codewords[codewordsRow]; + let previousColumnCodewords = this.detectionResultColumns[barcodeColumn - 1].getCodewords(); + let nextColumnCodewords = previousColumnCodewords; + if (this.detectionResultColumns[barcodeColumn + 1] != null) { + nextColumnCodewords = this.detectionResultColumns[barcodeColumn + 1].getCodewords(); + } + // let otherCodewords: Codeword[] = new Codeword[14]; + let otherCodewords = new Array(14); + otherCodewords[2] = previousColumnCodewords[codewordsRow]; + otherCodewords[3] = nextColumnCodewords[codewordsRow]; + if (codewordsRow > 0) { + otherCodewords[0] = codewords[codewordsRow - 1]; + otherCodewords[4] = previousColumnCodewords[codewordsRow - 1]; + otherCodewords[5] = nextColumnCodewords[codewordsRow - 1]; + } + if (codewordsRow > 1) { + otherCodewords[8] = codewords[codewordsRow - 2]; + otherCodewords[10] = previousColumnCodewords[codewordsRow - 2]; + otherCodewords[11] = nextColumnCodewords[codewordsRow - 2]; + } + if (codewordsRow < codewords.length - 1) { + otherCodewords[1] = codewords[codewordsRow + 1]; + otherCodewords[6] = previousColumnCodewords[codewordsRow + 1]; + otherCodewords[7] = nextColumnCodewords[codewordsRow + 1]; + } + if (codewordsRow < codewords.length - 2) { + otherCodewords[9] = codewords[codewordsRow + 2]; + otherCodewords[12] = previousColumnCodewords[codewordsRow + 2]; + otherCodewords[13] = nextColumnCodewords[codewordsRow + 2]; + } + for (let otherCodeword of otherCodewords) { + if (DetectionResult.adjustRowNumber(codeword, otherCodeword)) { + return; + } + } + } + /** + * @return true, if row number was adjusted, false otherwise + */ + static adjustRowNumber(codeword, otherCodeword) { + if (otherCodeword == null) { + return false; + } + if (otherCodeword.hasValidRowNumber() && otherCodeword.getBucket() === codeword.getBucket()) { + codeword.setRowNumber(otherCodeword.getRowNumber()); + return true; + } + return false; + } + getBarcodeColumnCount() { + return this.barcodeColumnCount; + } + getBarcodeRowCount() { + return this.barcodeMetadata.getRowCount(); + } + getBarcodeECLevel() { + return this.barcodeMetadata.getErrorCorrectionLevel(); + } + setBoundingBox(boundingBox) { + this.boundingBox = boundingBox; + } + getBoundingBox() { + return this.boundingBox; + } + setDetectionResultColumn(barcodeColumn, detectionResultColumn) { + this.detectionResultColumns[barcodeColumn] = detectionResultColumn; + } + getDetectionResultColumn(barcodeColumn) { + return this.detectionResultColumns[barcodeColumn]; + } + // @Override + toString() { + let rowIndicatorColumn = this.detectionResultColumns[0]; + if (rowIndicatorColumn == null) { + rowIndicatorColumn = this.detectionResultColumns[this.barcodeColumnCount + 1]; + } + // try ( + let formatter = new Formatter(); + // ) { + for (let codewordsRow /*int*/ = 0; codewordsRow < rowIndicatorColumn.getCodewords().length; codewordsRow++) { + formatter.format('CW %3d:', codewordsRow); + for (let barcodeColumn /*int*/ = 0; barcodeColumn < this.barcodeColumnCount + 2; barcodeColumn++) { + if (this.detectionResultColumns[barcodeColumn] == null) { + formatter.format(' | '); + continue; + } + let codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow]; + if (codeword == null) { + formatter.format(' | '); + continue; + } + formatter.format(' %3d|%3d', codeword.getRowNumber(), codeword.getValue()); + } + formatter.format('%n'); + } + return formatter.toString(); + // } + } + } + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // package com.google.zxing.pdf417.decoder; + /** + * @author Guenther Grau + */ + /*final*/ class Codeword { + constructor(startX, endX, bucket, value) { + this.rowNumber = Codeword.BARCODE_ROW_UNKNOWN; + this.startX = Math.trunc(startX); + this.endX = Math.trunc(endX); + this.bucket = Math.trunc(bucket); + this.value = Math.trunc(value); + } + hasValidRowNumber() { + return this.isValidRowNumber(this.rowNumber); + } + isValidRowNumber(rowNumber) { + return rowNumber !== Codeword.BARCODE_ROW_UNKNOWN && this.bucket === (rowNumber % 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(rowNumber) { + this.rowNumber = rowNumber; + } + // @Override + toString() { + return this.rowNumber + '|' + this.value; + } + } + Codeword.BARCODE_ROW_UNKNOWN = -1; + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * @author Guenther Grau + * @author creatale GmbH (christoph.schulz@creatale.de) + */ + /*final*/ class PDF417CodewordDecoder { + /* @note + * this action have to be performed before first use of class + * - static constructor + * working with 32bit float (based from Java logic) + */ + static initialize() { + // Pre-computes the symbol ratio table. + for ( /*int*/let i = 0; i < PDF417Common.SYMBOL_TABLE.length; i++) { + let currentSymbol = PDF417Common.SYMBOL_TABLE[i]; + let currentBit = currentSymbol & 0x1; + for ( /*int*/let j = 0; j < PDF417Common.BARS_IN_MODULE; j++) { + let size = 0.0; + while ((currentSymbol & 0x1) === currentBit) { + size += 1.0; + currentSymbol >>= 1; + } + currentBit = currentSymbol & 0x1; + if (!PDF417CodewordDecoder.RATIOS_TABLE[i]) { + PDF417CodewordDecoder.RATIOS_TABLE[i] = new Array(PDF417Common.BARS_IN_MODULE); + } + PDF417CodewordDecoder.RATIOS_TABLE[i][PDF417Common.BARS_IN_MODULE - j - 1] = Math.fround(size / PDF417Common.MODULES_IN_CODEWORD); + } + } + this.bSymbolTableReady = true; + } + static getDecodedValue(moduleBitCount) { + let decodedValue = PDF417CodewordDecoder.getDecodedCodewordValue(PDF417CodewordDecoder.sampleBitCounts(moduleBitCount)); + if (decodedValue !== -1) { + return decodedValue; + } + return PDF417CodewordDecoder.getClosestDecodedValue(moduleBitCount); + } + static sampleBitCounts(moduleBitCount) { + let bitCountSum = MathUtils.sum(moduleBitCount); + let result = new Int32Array(PDF417Common.BARS_IN_MODULE); + let bitCountIndex = 0; + let sumPreviousBits = 0; + for ( /*int*/let i = 0; i < PDF417Common.MODULES_IN_CODEWORD; i++) { + let sampleIndex = bitCountSum / (2 * PDF417Common.MODULES_IN_CODEWORD) + + (i * bitCountSum) / PDF417Common.MODULES_IN_CODEWORD; + if (sumPreviousBits + moduleBitCount[bitCountIndex] <= sampleIndex) { + sumPreviousBits += moduleBitCount[bitCountIndex]; + bitCountIndex++; + } + result[bitCountIndex]++; + } + return result; + } + static getDecodedCodewordValue(moduleBitCount) { + let decodedValue = PDF417CodewordDecoder.getBitValue(moduleBitCount); + return PDF417Common.getCodeword(decodedValue) === -1 ? -1 : decodedValue; + } + static getBitValue(moduleBitCount) { + let result = /*long*/ 0; + for (let /*int*/ i = 0; i < moduleBitCount.length; i++) { + for ( /*int*/let bit = 0; bit < moduleBitCount[i]; bit++) { + result = (result << 1) | (i % 2 === 0 ? 1 : 0); + } + } + return Math.trunc(result); + } + // working with 32bit float (as in Java) + static getClosestDecodedValue(moduleBitCount) { + let bitCountSum = MathUtils.sum(moduleBitCount); + let bitCountRatios = new Array(PDF417Common.BARS_IN_MODULE); + if (bitCountSum > 1) { + for (let /*int*/ i = 0; i < bitCountRatios.length; i++) { + bitCountRatios[i] = Math.fround(moduleBitCount[i] / bitCountSum); + } + } + let bestMatchError = Float.MAX_VALUE; + let bestMatch = -1; + if (!this.bSymbolTableReady) { + PDF417CodewordDecoder.initialize(); + } + for ( /*int*/let j = 0; j < PDF417CodewordDecoder.RATIOS_TABLE.length; j++) { + let error = 0.0; + let ratioTableRow = PDF417CodewordDecoder.RATIOS_TABLE[j]; + for ( /*int*/let k = 0; k < PDF417Common.BARS_IN_MODULE; k++) { + let diff = Math.fround(ratioTableRow[k] - bitCountRatios[k]); + error += Math.fround(diff * diff); + if (error >= bestMatchError) { + break; + } + } + if (error < bestMatchError) { + bestMatchError = error; + bestMatch = PDF417Common.SYMBOL_TABLE[j]; + } + } + return bestMatch; + } + } + // flag that the table is ready for use + PDF417CodewordDecoder.bSymbolTableReady = false; + PDF417CodewordDecoder.RATIOS_TABLE = new Array(PDF417Common.SYMBOL_TABLE.length).map(x => x = new Array(PDF417Common.BARS_IN_MODULE)); + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // package com.google.zxing.pdf417; + /** + * @author Guenther Grau + */ + /*public final*/ class PDF417ResultMetadata { + constructor() { + this.segmentCount = -1; + this.fileSize = -1; + this.timestamp = -1; + this.checksum = -1; + } + /** + * The Segment ID represents the segment of the whole file distributed over different symbols. + * + * @return File segment index + */ + getSegmentIndex() { + return this.segmentIndex; + } + setSegmentIndex(segmentIndex) { + this.segmentIndex = segmentIndex; + } + /** + * Is the same for each related PDF417 symbol + * + * @return File ID + */ + getFileId() { + return this.fileId; + } + setFileId(fileId) { + this.fileId = fileId; + } + /** + * @return always null + * @deprecated use dedicated already parsed fields + */ + // @Deprecated + getOptionalData() { + return this.optionalData; + } + /** + * @param optionalData old optional data format as int array + * @deprecated parse and use new fields + */ + // @Deprecated + setOptionalData(optionalData) { + this.optionalData = optionalData; + } + /** + * @return true if it is the last segment + */ + isLastSegment() { + return this.lastSegment; + } + setLastSegment(lastSegment) { + this.lastSegment = lastSegment; + } + /** + * @return count of segments, -1 if not set + */ + getSegmentCount() { + return this.segmentCount; + } + setSegmentCount(segmentCount /*int*/) { + this.segmentCount = segmentCount; + } + getSender() { + return this.sender || null; + } + setSender(sender) { + this.sender = sender; + } + getAddressee() { + return this.addressee || null; + } + setAddressee(addressee) { + this.addressee = addressee; + } + /** + * Filename of the encoded file + * + * @return filename + */ + getFileName() { + return this.fileName; + } + setFileName(fileName) { + this.fileName = fileName; + } + /** + * filesize in bytes of the encoded file + * + * @return filesize in bytes, -1 if not set + */ + getFileSize() { + return this.fileSize; + } + setFileSize(fileSize /*long*/) { + this.fileSize = fileSize; + } + /** + * 16-bit CRC checksum using CCITT-16 + * + * @return crc checksum, -1 if not set + */ + getChecksum() { + return this.checksum; + } + setChecksum(checksum /*int*/) { + this.checksum = checksum; + } + /** + * unix epock timestamp, elapsed seconds since 1970-01-01 + * + * @return elapsed seconds, -1 if not set + */ + getTimestamp() { + return this.timestamp; + } + setTimestamp(timestamp /*long*/) { + this.timestamp = timestamp; + } + } + + /** + * Ponyfill for Java's Long class. + */ + class Long { + /** + * Parses a string to a number, since JS has no really Int64. + * + * @param num Numeric string. + * @param radix Destination radix. + */ + static parseLong(num, radix = undefined) { + return parseInt(num, radix); + } + } + + /** + * Custom Error class of type Exception. + */ + class NullPointerException extends Exception { + } + NullPointerException.kind = 'NullPointerException'; + + /* + * Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + // package java.io; + /** + * This abstract class is the superclass of all classes representing + * an output stream of bytes. An output stream accepts output bytes + * and sends them to some sink. + * <p> + * Applications that need to define a subclass of + * <code>OutputStream</code> must always provide at least a method + * that writes one byte of output. + * + * @author Arthur van Hoff + * @see java.io.BufferedOutputStream + * @see java.io.ByteArrayOutputStream + * @see java.io.DataOutputStream + * @see java.io.FilterOutputStream + * @see java.io.InputStream + * @see java.io.OutputStream#write(int) + * @since JDK1.0 + */ + /*public*/ class OutputStream /*implements Closeable, Flushable*/ { + /** + * Writes <code>b.length</code> bytes from the specified byte array + * to this output stream. The general contract for <code>write(b)</code> + * is that it should have exactly the same effect as the call + * <code>write(b, 0, b.length)</code>. + * + * @param b the data. + * @exception IOException if an I/O error occurs. + * @see java.io.OutputStream#write(byte[], int, int) + */ + writeBytes(b) { + this.writeBytesOffset(b, 0, b.length); + } + /** + * Writes <code>len</code> bytes from the specified byte array + * starting at offset <code>off</code> to this output stream. + * The general contract for <code>write(b, off, len)</code> is that + * some of the bytes in the array <code>b</code> are written to the + * output stream in order; element <code>b[off]</code> is the first + * byte written and <code>b[off+len-1]</code> is the last byte written + * by this operation. + * <p> + * The <code>write</code> method of <code>OutputStream</code> calls + * the write method of one argument on each of the bytes to be + * written out. Subclasses are encouraged to override this method and + * provide a more efficient implementation. + * <p> + * If <code>b</code> is <code>null</code>, a + * <code>NullPointerException</code> is thrown. + * <p> + * If <code>off</code> is negative, or <code>len</code> is negative, or + * <code>off+len</code> is greater than the length of the array + * <code>b</code>, then an <tt>IndexOutOfBoundsException</tt> is thrown. + * + * @param b the data. + * @param off the start offset in the data. + * @param len the number of bytes to write. + * @exception IOException if an I/O error occurs. In particular, + * an <code>IOException</code> is thrown if the output + * stream is closed. + */ + writeBytesOffset(b, off, len) { + if (b == null) { + throw new NullPointerException(); + } + else if ((off < 0) || (off > b.length) || (len < 0) || + ((off + len) > b.length) || ((off + len) < 0)) { + throw new IndexOutOfBoundsException(); + } + else if (len === 0) { + return; + } + for (let i = 0; i < len; i++) { + this.write(b[off + i]); + } + } + /** + * Flushes this output stream and forces any buffered output bytes + * to be written out. The general contract of <code>flush</code> is + * that calling it is an indication that, if any bytes previously + * written have been buffered by the implementation of the output + * stream, such bytes should immediately be written to their + * intended destination. + * <p> + * If the intended destination of this stream is an abstraction provided by + * the underlying operating system, for example a file, then flushing the + * stream guarantees only that bytes previously written to the stream are + * passed to the operating system for writing; it does not guarantee that + * they are actually written to a physical device such as a disk drive. + * <p> + * The <code>flush</code> method of <code>OutputStream</code> does nothing. + * + * @exception IOException if an I/O error occurs. + */ + flush() { + } + /** + * Closes this output stream and releases any system resources + * associated with this stream. The general contract of <code>close</code> + * is that it closes the output stream. A closed stream cannot perform + * output operations and cannot be reopened. + * <p> + * The <code>close</code> method of <code>OutputStream</code> does nothing. + * + * @exception IOException if an I/O error occurs. + */ + close() { + } + } + + /** + * Custom Error class of type Exception. + */ + class OutOfMemoryError extends Exception { + } + + /* + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + /** + * This class implements an output stream in which the data is + * written into a byte array. The buffer automatically grows as data + * is written to it. + * The data can be retrieved using <code>toByteArray()</code> and + * <code>toString()</code>. + * <p> + * Closing a <tt>ByteArrayOutputStream</tt> has no effect. The methods in + * this class can be called after the stream has been closed without + * generating an <tt>IOException</tt>. + * + * @author Arthur van Hoff + * @since JDK1.0 + */ + /*public*/ class ByteArrayOutputStream extends OutputStream { + /** + * Creates a new byte array output stream. The buffer capacity is + * initially 32 bytes, though its size increases if necessary. + */ + // public constructor() { + // this(32); + // } + /** + * Creates a new byte array output stream, with a buffer capacity of + * the specified size, in bytes. + * + * @param size the initial size. + * @exception IllegalArgumentException if size is negative. + */ + constructor(size = 32) { + super(); + /** + * The number of valid bytes in the buffer. + */ + this.count = 0; + if (size < 0) { + throw new IllegalArgumentException('Negative initial size: ' + + size); + } + this.buf = new Uint8Array(size); + } + /** + * Increases the capacity if necessary to ensure that it can hold + * at least the number of elements specified by the minimum + * capacity argument. + * + * @param minCapacity the desired minimum capacity + * @throws OutOfMemoryError if {@code minCapacity < 0}. This is + * interpreted as a request for the unsatisfiably large capacity + * {@code (long) Integer.MAX_VALUE + (minCapacity - Integer.MAX_VALUE)}. + */ + ensureCapacity(minCapacity) { + // overflow-conscious code + if (minCapacity - this.buf.length > 0) + this.grow(minCapacity); + } + /** + * Increases the capacity to ensure that it can hold at least the + * number of elements specified by the minimum capacity argument. + * + * @param minCapacity the desired minimum capacity + */ + grow(minCapacity) { + // overflow-conscious code + let oldCapacity = this.buf.length; + let newCapacity = oldCapacity << 1; + if (newCapacity - minCapacity < 0) + newCapacity = minCapacity; + if (newCapacity < 0) { + if (minCapacity < 0) // overflow + throw new OutOfMemoryError(); + newCapacity = Integer.MAX_VALUE; + } + this.buf = Arrays.copyOfUint8Array(this.buf, newCapacity); + } + /** + * Writes the specified byte to this byte array output stream. + * + * @param b the byte to be written. + */ + write(b) { + this.ensureCapacity(this.count + 1); + this.buf[this.count] = /*(byte)*/ b; + this.count += 1; + } + /** + * Writes <code>len</code> bytes from the specified byte array + * starting at offset <code>off</code> to this byte array output stream. + * + * @param b the data. + * @param off the start offset in the data. + * @param len the number of bytes to write. + */ + writeBytesOffset(b, off, len) { + if ((off < 0) || (off > b.length) || (len < 0) || + ((off + len) - b.length > 0)) { + throw new IndexOutOfBoundsException(); + } + this.ensureCapacity(this.count + len); + System.arraycopy(b, off, this.buf, this.count, len); + this.count += len; + } + /** + * Writes the complete contents of this byte array output stream to + * the specified output stream argument, as if by calling the output + * stream's write method using <code>out.write(buf, 0, count)</code>. + * + * @param out the output stream to which to write the data. + * @exception IOException if an I/O error occurs. + */ + writeTo(out) { + out.writeBytesOffset(this.buf, 0, this.count); + } + /** + * Resets the <code>count</code> field of this byte array output + * stream to zero, so that all currently accumulated output in the + * output stream is discarded. The output stream can be used again, + * reusing the already allocated buffer space. + * + * @see java.io.ByteArrayInputStream#count + */ + reset() { + this.count = 0; + } + /** + * Creates a newly allocated byte array. Its size is the current + * size of this output stream and the valid contents of the buffer + * have been copied into it. + * + * @return the current contents of this output stream, as a byte array. + * @see java.io.ByteArrayOutputStream#size() + */ + toByteArray() { + return Arrays.copyOfUint8Array(this.buf, this.count); + } + /** + * Returns the current size of the buffer. + * + * @return the value of the <code>count</code> field, which is the number + * of valid bytes in this output stream. + * @see java.io.ByteArrayOutputStream#count + */ + size() { + return this.count; + } + toString(param) { + if (!param) { + return this.toString_void(); + } + if (typeof param === 'string') { + return this.toString_string(param); + } + return this.toString_number(param); + } + /** + * Converts the buffer's contents into a string decoding bytes using the + * platform's default character set. The length of the new <tt>String</tt> + * is a function of the character set, and hence may not be equal to the + * size of the buffer. + * + * <p> This method always replaces malformed-input and unmappable-character + * sequences with the default replacement string for the platform's + * default character set. The {@linkplain java.nio.charset.CharsetDecoder} + * class should be used when more control over the decoding process is + * required. + * + * @return String decoded from the buffer's contents. + * @since JDK1.1 + */ + toString_void() { + return new String(this.buf /*, 0, this.count*/).toString(); + } + /** + * Converts the buffer's contents into a string by decoding the bytes using + * the specified {@link java.nio.charset.Charset charsetName}. The length of + * the new <tt>String</tt> is a function of the charset, and hence may not be + * equal to the length of the byte array. + * + * <p> This method always replaces malformed-input and unmappable-character + * sequences with this charset's default replacement string. The {@link + * java.nio.charset.CharsetDecoder} class should be used when more control + * over the decoding process is required. + * + * @param charsetName the name of a supported + * {@linkplain java.nio.charset.Charset </code>charset<code>} + * @return String decoded from the buffer's contents. + * @exception UnsupportedEncodingException + * If the named charset is not supported + * @since JDK1.1 + */ + toString_string(charsetName) { + return new String(this.buf /*, 0, this.count, charsetName*/).toString(); + } + /** + * Creates a newly allocated string. Its size is the current size of + * the output stream and the valid contents of the buffer have been + * copied into it. Each character <i>c</i> in the resulting string is + * constructed from the corresponding element <i>b</i> in the byte + * array such that: + * <blockquote><pre> + * c == (char)(((hibyte & 0xff) << 8) | (b & 0xff)) + * </pre></blockquote> + * + * @deprecated This method does not properly convert bytes into characters. + * As of JDK 1.1, the preferred way to do this is via the + * <code>toString(String enc)</code> method, which takes an encoding-name + * argument, or the <code>toString()</code> method, which uses the + * platform's default character encoding. + * + * @param hibyte the high byte of each resulting Unicode character. + * @return the current contents of the output stream, as a string. + * @see java.io.ByteArrayOutputStream#size() + * @see java.io.ByteArrayOutputStream#toString(String) + * @see java.io.ByteArrayOutputStream#toString() + */ + // @Deprecated + toString_number(hibyte) { + return new String(this.buf /*, hibyte, 0, this.count*/).toString(); + } + /** + * Closing a <tt>ByteArrayOutputStream</tt> has no effect. The methods in + * this class can be called after the stream has been closed without + * generating an <tt>IOException</tt>. + * <p> + * + * @throws IOException + */ + close() { + } + } + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*private*/ var Mode$2; + (function (Mode) { + Mode[Mode["ALPHA"] = 0] = "ALPHA"; + Mode[Mode["LOWER"] = 1] = "LOWER"; + Mode[Mode["MIXED"] = 2] = "MIXED"; + Mode[Mode["PUNCT"] = 3] = "PUNCT"; + Mode[Mode["ALPHA_SHIFT"] = 4] = "ALPHA_SHIFT"; + Mode[Mode["PUNCT_SHIFT"] = 5] = "PUNCT_SHIFT"; + })(Mode$2 || (Mode$2 = {})); + /** + * Indirectly access the global BigInt constructor, it + * allows browsers that doesn't support BigInt to run + * the library without breaking due to "undefined BigInt" + * errors. + */ + function getBigIntConstructor() { + if (typeof window !== 'undefined') { + return window['BigInt'] || null; + } + if (typeof global !== 'undefined') { + return global['BigInt'] || null; + } + if (typeof self !== 'undefined') { + return self['BigInt'] || null; + } + throw new Error('Can\'t search globals for BigInt!'); + } + /** + * Used to store the BigInt constructor. + */ + let BigInteger; + /** + * This function creates a bigint value. It allows browsers + * that doesn't support BigInt to run the rest of the library + * by not directly accessing the BigInt constructor. + */ + function createBigInt(num) { + if (typeof BigInteger === 'undefined') { + BigInteger = getBigIntConstructor(); + } + if (BigInteger === null) { + throw new Error('BigInt is not supported!'); + } + return BigInteger(num); + } + function getEXP900() { + // in Java - array with length = 16 + let EXP900 = []; + EXP900[0] = createBigInt(1); + let nineHundred = createBigInt(900); + EXP900[1] = nineHundred; + // in Java - array with length = 16 + for (let i /*int*/ = 2; i < 16; i++) { + EXP900[i] = EXP900[i - 1] * nineHundred; + } + return EXP900; + } + /** + * <p>This class contains the methods for decoding the PDF417 codewords.</p> + * + * @author SITA Lab (kevin.osullivan@sita.aero) + * @author Guenther Grau + */ + /*final*/ class DecodedBitStreamParser$2 { + // private DecodedBitStreamParser() { + // } + /** + * + * @param codewords + * @param ecLevel + * + * @throws FormatException + */ + static decode(codewords, ecLevel) { + // pass encoding to result (will be used for decode symbols in byte mode) + let result = new StringBuilder(''); + // let encoding: Charset = StandardCharsets.ISO_8859_1; + let encoding = CharacterSetECI.ISO8859_1; + /** + * @note the next command is specific from this TypeScript library + * because TS can't properly cast some values to char and + * convert it to string later correctly due to encoding + * differences from Java version. As reported here: + * https://github.com/zxing-js/library/pull/264/files#r382831593 + */ + result.enableDecoding(encoding); + // Get compaction mode + let codeIndex = 1; + let code = codewords[codeIndex++]; + let resultMetadata = new PDF417ResultMetadata(); + while (codeIndex < codewords[0]) { + switch (code) { + case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH: + codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex, result); + break; + case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH: + case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6: + codeIndex = DecodedBitStreamParser$2.byteCompaction(code, codewords, encoding, codeIndex, result); + break; + case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: + result.append(/*(char)*/ codewords[codeIndex++]); + break; + case DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH: + codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex, result); + break; + case DecodedBitStreamParser$2.ECI_CHARSET: + let charsetECI = CharacterSetECI.getCharacterSetECIByValue(codewords[codeIndex++]); + // encoding = Charset.forName(charsetECI.getName()); + break; + case DecodedBitStreamParser$2.ECI_GENERAL_PURPOSE: + // Can't do anything with generic ECI; skip its 2 characters + codeIndex += 2; + break; + case DecodedBitStreamParser$2.ECI_USER_DEFINED: + // Can't do anything with user ECI; skip its 1 character + codeIndex++; + break; + case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK: + codeIndex = DecodedBitStreamParser$2.decodeMacroBlock(codewords, codeIndex, resultMetadata); + break; + case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD: + case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR: + // Should not see these outside a macro block + throw new FormatException(); + default: + // Default to text compaction. During testing numerous barcodes + // appeared to be missing the starting mode. In these cases defaulting + // to text compaction seems to work. + codeIndex--; + codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex, result); + break; + } + if (codeIndex < codewords.length) { + code = codewords[codeIndex++]; + } + else { + throw FormatException.getFormatInstance(); + } + } + if (result.length() === 0) { + throw FormatException.getFormatInstance(); + } + let decoderResult = new DecoderResult(null, result.toString(), null, ecLevel); + decoderResult.setOther(resultMetadata); + return decoderResult; + } + /** + * + * @param int + * @param param1 + * @param codewords + * @param int + * @param codeIndex + * @param PDF417ResultMetadata + * @param resultMetadata + * + * @throws FormatException + */ + // @SuppressWarnings("deprecation") + static decodeMacroBlock(codewords, codeIndex, resultMetadata) { + if (codeIndex + DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0]) { + // we must have at least two bytes left for the segment index + throw FormatException.getFormatInstance(); + } + let segmentIndexArray = new Int32Array(DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS); + for (let i /*int*/ = 0; i < DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS; i++, codeIndex++) { + segmentIndexArray[i] = codewords[codeIndex]; + } + resultMetadata.setSegmentIndex(Integer.parseInt(DecodedBitStreamParser$2.decodeBase900toBase10(segmentIndexArray, DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS))); + let fileId = new StringBuilder(); + codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex, fileId); + resultMetadata.setFileId(fileId.toString()); + let optionalFieldsStart = -1; + if (codewords[codeIndex] === DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD) { + optionalFieldsStart = codeIndex + 1; + } + while (codeIndex < codewords[0]) { + switch (codewords[codeIndex]) { + case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD: + codeIndex++; + switch (codewords[codeIndex]) { + case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME: + let fileName = new StringBuilder(); + codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex + 1, fileName); + resultMetadata.setFileName(fileName.toString()); + break; + case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_SENDER: + let sender = new StringBuilder(); + codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex + 1, sender); + resultMetadata.setSender(sender.toString()); + break; + case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE: + let addressee = new StringBuilder(); + codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex + 1, addressee); + resultMetadata.setAddressee(addressee.toString()); + break; + case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT: + let segmentCount = new StringBuilder(); + codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex + 1, segmentCount); + resultMetadata.setSegmentCount(Integer.parseInt(segmentCount.toString())); + break; + case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP: + let timestamp = new StringBuilder(); + codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex + 1, timestamp); + resultMetadata.setTimestamp(Long.parseLong(timestamp.toString())); + break; + case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM: + let checksum = new StringBuilder(); + codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex + 1, checksum); + resultMetadata.setChecksum(Integer.parseInt(checksum.toString())); + break; + case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE: + let fileSize = new StringBuilder(); + codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex + 1, fileSize); + resultMetadata.setFileSize(Long.parseLong(fileSize.toString())); + break; + default: + throw FormatException.getFormatInstance(); + } + break; + case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR: + codeIndex++; + resultMetadata.setLastSegment(true); + break; + default: + throw FormatException.getFormatInstance(); + } + } + // copy optional fields to additional options + if (optionalFieldsStart !== -1) { + let optionalFieldsLength = codeIndex - optionalFieldsStart; + if (resultMetadata.isLastSegment()) { + // do not include terminator + optionalFieldsLength--; + } + resultMetadata.setOptionalData(Arrays.copyOfRange(codewords, optionalFieldsStart, optionalFieldsStart + optionalFieldsLength)); + } + return codeIndex; + } + /** + * Text Compaction mode (see 5.4.1.5) permits all printable ASCII characters to be + * encoded, i.e. values 32 - 126 inclusive in accordance with ISO/IEC 646 (IRV), as + * well as selected control characters. + * + * @param codewords The array of codewords (data + error) + * @param codeIndex The current index into the codeword array. + * @param result The decoded data is appended to the result. + * @return The next index into the codeword array. + */ + static textCompaction(codewords, codeIndex, result) { + // 2 character per codeword + let textCompactionData = new Int32Array((codewords[0] - codeIndex) * 2); + // Used to hold the byte compaction value if there is a mode shift + let byteCompactionData = new Int32Array((codewords[0] - codeIndex) * 2); + let index = 0; + let end = false; + while ((codeIndex < codewords[0]) && !end) { + let code = codewords[codeIndex++]; + if (code < DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH) { + textCompactionData[index] = code / 30; + textCompactionData[index + 1] = code % 30; + index += 2; + } + else { + switch (code) { + case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH: + // reinitialize text compaction mode to alpha sub mode + textCompactionData[index++] = DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH; + break; + case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH: + case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6: + case DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH: + case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK: + case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD: + case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR: + codeIndex--; + end = true; + break; + case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: + // The Mode Shift codeword 913 shall cause a temporary + // switch from Text Compaction mode to Byte Compaction mode. + // This switch shall be in effect for only the next codeword, + // after which the mode shall revert to the prevailing sub-mode + // of the Text Compaction mode. Codeword 913 is only available + // in Text Compaction mode; its use is described in 5.4.2.4. + textCompactionData[index] = DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE; + code = codewords[codeIndex++]; + byteCompactionData[index] = code; + index++; + break; + } + } + } + DecodedBitStreamParser$2.decodeTextCompaction(textCompactionData, byteCompactionData, index, result); + return codeIndex; + } + /** + * The Text Compaction mode includes all the printable ASCII characters + * (i.e. values from 32 to 126) and three ASCII control characters: HT or tab + * (9: e), LF or line feed (10: e), and CR or carriage + * return (13: e). The Text Compaction mode also includes various latch + * and shift characters which are used exclusively within the mode. The Text + * Compaction mode encodes up to 2 characters per codeword. The compaction rules + * for converting data into PDF417 codewords are defined in 5.4.2.2. The sub-mode + * switches are defined in 5.4.2.3. + * + * @param textCompactionData The text compaction data. + * @param byteCompactionData The byte compaction data if there + * was a mode shift. + * @param length The size of the text compaction and byte compaction data. + * @param result The decoded data is appended to the result. + */ + static decodeTextCompaction(textCompactionData, byteCompactionData, length, result) { + // Beginning from an initial state of the Alpha sub-mode + // The default compaction mode for PDF417 in effect at the start of each symbol shall always be Text + // Compaction mode Alpha sub-mode (alphabetic: uppercase). A latch codeword from another mode to the Text + // Compaction mode shall always switch to the Text Compaction Alpha sub-mode. + let subMode = Mode$2.ALPHA; + let priorToShiftMode = Mode$2.ALPHA; + let i = 0; + while (i < length) { + let subModeCh = textCompactionData[i]; + let ch = /*char*/ ''; + switch (subMode) { + case Mode$2.ALPHA: + // Alpha (alphabetic: uppercase) + if (subModeCh < 26) { + // Upper case Alpha Character + // Note: 65 = 'A' ASCII -> there is byte code of symbol + ch = /*(char)('A' + subModeCh) */ String.fromCharCode(65 + subModeCh); + } + else { + switch (subModeCh) { + case 26: + ch = ' '; + break; + case DecodedBitStreamParser$2.LL: + subMode = Mode$2.LOWER; + break; + case DecodedBitStreamParser$2.ML: + subMode = Mode$2.MIXED; + break; + case DecodedBitStreamParser$2.PS: + // Shift to punctuation + priorToShiftMode = subMode; + subMode = Mode$2.PUNCT_SHIFT; + break; + case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: + result.append(/*(char)*/ byteCompactionData[i]); + break; + case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH: + subMode = Mode$2.ALPHA; + break; + } + } + break; + case Mode$2.LOWER: + // Lower (alphabetic: lowercase) + if (subModeCh < 26) { + ch = /*(char)('a' + subModeCh)*/ String.fromCharCode(97 + subModeCh); + } + else { + switch (subModeCh) { + case 26: + ch = ' '; + break; + case DecodedBitStreamParser$2.AS: + // Shift to alpha + priorToShiftMode = subMode; + subMode = Mode$2.ALPHA_SHIFT; + break; + case DecodedBitStreamParser$2.ML: + subMode = Mode$2.MIXED; + break; + case DecodedBitStreamParser$2.PS: + // Shift to punctuation + priorToShiftMode = subMode; + subMode = Mode$2.PUNCT_SHIFT; + break; + case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: + // TODO Does this need to use the current character encoding? See other occurrences below + result.append(/*(char)*/ byteCompactionData[i]); + break; + case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH: + subMode = Mode$2.ALPHA; + break; + } + } + break; + case Mode$2.MIXED: + // Mixed (punctuation: e) + if (subModeCh < DecodedBitStreamParser$2.PL) { + ch = DecodedBitStreamParser$2.MIXED_CHARS[subModeCh]; + } + else { + switch (subModeCh) { + case DecodedBitStreamParser$2.PL: + subMode = Mode$2.PUNCT; + break; + case 26: + ch = ' '; + break; + case DecodedBitStreamParser$2.LL: + subMode = Mode$2.LOWER; + break; + case DecodedBitStreamParser$2.AL: + subMode = Mode$2.ALPHA; + break; + case DecodedBitStreamParser$2.PS: + // Shift to punctuation + priorToShiftMode = subMode; + subMode = Mode$2.PUNCT_SHIFT; + break; + case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: + result.append(/*(char)*/ byteCompactionData[i]); + break; + case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH: + subMode = Mode$2.ALPHA; + break; + } + } + break; + case Mode$2.PUNCT: + // Punctuation + if (subModeCh < DecodedBitStreamParser$2.PAL) { + ch = DecodedBitStreamParser$2.PUNCT_CHARS[subModeCh]; + } + else { + switch (subModeCh) { + case DecodedBitStreamParser$2.PAL: + subMode = Mode$2.ALPHA; + break; + case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: + result.append(/*(char)*/ byteCompactionData[i]); + break; + case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH: + subMode = Mode$2.ALPHA; + break; + } + } + break; + case Mode$2.ALPHA_SHIFT: + // Restore sub-mode + subMode = priorToShiftMode; + if (subModeCh < 26) { + ch = /*(char)('A' + subModeCh)*/ String.fromCharCode(65 + subModeCh); + } + else { + switch (subModeCh) { + case 26: + ch = ' '; + break; + case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH: + subMode = Mode$2.ALPHA; + break; + } + } + break; + case Mode$2.PUNCT_SHIFT: + // Restore sub-mode + subMode = priorToShiftMode; + if (subModeCh < DecodedBitStreamParser$2.PAL) { + ch = DecodedBitStreamParser$2.PUNCT_CHARS[subModeCh]; + } + else { + switch (subModeCh) { + case DecodedBitStreamParser$2.PAL: + subMode = Mode$2.ALPHA; + break; + case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE: + // PS before Shift-to-Byte is used as a padding character, + // see 5.4.2.4 of the specification + result.append(/*(char)*/ byteCompactionData[i]); + break; + case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH: + subMode = Mode$2.ALPHA; + break; + } + } + break; + } + // if (ch !== 0) { + if (ch !== '') { + // Append decoded character to result + result.append(ch); + } + i++; + } + } + /** + * Byte Compaction mode (see 5.4.3) permits all 256 possible 8-bit byte values to be encoded. + * This includes all ASCII characters value 0 to 127 inclusive and provides for international + * character set support. + * + * @param mode The byte compaction mode i.e. 901 or 924 + * @param codewords The array of codewords (data + error) + * @param encoding Currently active character encoding + * @param codeIndex The current index into the codeword array. + * @param result The decoded data is appended to the result. + * @return The next index into the codeword array. + */ + static /*int*/ byteCompaction(mode, codewords, encoding, codeIndex, result) { + let decodedBytes = new ByteArrayOutputStream(); + let count = 0; + let value = /*long*/ 0; + let end = false; + switch (mode) { + case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH: + // Total number of Byte Compaction characters to be encoded + // is not a multiple of 6 + let byteCompactedCodewords = new Int32Array(6); + let nextCode = codewords[codeIndex++]; + while ((codeIndex < codewords[0]) && !end) { + byteCompactedCodewords[count++] = nextCode; + // Base 900 + value = 900 * value + nextCode; + nextCode = codewords[codeIndex++]; + // perhaps it should be ok to check only nextCode >= TEXT_COMPACTION_MODE_LATCH + switch (nextCode) { + case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH: + case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH: + case DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH: + case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6: + case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK: + case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD: + case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR: + codeIndex--; + end = true; + break; + default: + if ((count % 5 === 0) && (count > 0)) { + // Decode every 5 codewords + // Convert to Base 256 + for (let j /*int*/ = 0; j < 6; ++j) { + /* @note + * JavaScript stores numbers as 64 bits floating point numbers, but all bitwise operations are performed on 32 bits binary numbers. + * So the next bitwise operation could not be done with simple numbers + */ + decodedBytes.write(/*(byte)*/ Number(createBigInt(value) >> createBigInt(8 * (5 - j)))); + } + value = 0; + count = 0; + } + break; + } + } + // if the end of all codewords is reached the last codeword needs to be added + if (codeIndex === codewords[0] && nextCode < DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH) { + byteCompactedCodewords[count++] = nextCode; + } + // If Byte Compaction mode is invoked with codeword 901, + // the last group of codewords is interpreted directly + // as one byte per codeword, without compaction. + for (let i /*int*/ = 0; i < count; i++) { + decodedBytes.write(/*(byte)*/ byteCompactedCodewords[i]); + } + break; + case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6: + // Total number of Byte Compaction characters to be encoded + // is an integer multiple of 6 + while (codeIndex < codewords[0] && !end) { + let code = codewords[codeIndex++]; + if (code < DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH) { + count++; + // Base 900 + value = 900 * value + code; + } + else { + switch (code) { + case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH: + case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH: + case DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH: + case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6: + case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK: + case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD: + case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR: + codeIndex--; + end = true; + break; + } + } + if ((count % 5 === 0) && (count > 0)) { + // Decode every 5 codewords + // Convert to Base 256 + /* @note + * JavaScript stores numbers as 64 bits floating point numbers, but all bitwise operations are performed on 32 bits binary numbers. + * So the next bitwise operation could not be done with simple numbers + */ + for (let j /*int*/ = 0; j < 6; ++j) { + decodedBytes.write(/*(byte)*/ Number(createBigInt(value) >> createBigInt(8 * (5 - j)))); + } + value = 0; + count = 0; + } + } + break; + } + result.append(StringEncoding.decode(decodedBytes.toByteArray(), encoding)); + return codeIndex; + } + /** + * Numeric Compaction mode (see 5.4.4) permits efficient encoding of numeric data strings. + * + * @param codewords The array of codewords (data + error) + * @param codeIndex The current index into the codeword array. + * @param result The decoded data is appended to the result. + * @return The next index into the codeword array. + * + * @throws FormatException + */ + static numericCompaction(codewords, codeIndex /*int*/, result) { + let count = 0; + let end = false; + let numericCodewords = new Int32Array(DecodedBitStreamParser$2.MAX_NUMERIC_CODEWORDS); + while (codeIndex < codewords[0] && !end) { + let code = codewords[codeIndex++]; + if (codeIndex === codewords[0]) { + end = true; + } + if (code < DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH) { + numericCodewords[count] = code; + count++; + } + else { + switch (code) { + case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH: + case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH: + case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6: + case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK: + case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD: + case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR: + codeIndex--; + end = true; + break; + } + } + if ((count % DecodedBitStreamParser$2.MAX_NUMERIC_CODEWORDS === 0 || code === DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH || end) && count > 0) { + // Re-invoking Numeric Compaction mode (by using codeword 902 + // while in Numeric Compaction mode) serves to terminate the + // current Numeric Compaction mode grouping as described in 5.4.4.2, + // and then to start a new one grouping. + result.append(DecodedBitStreamParser$2.decodeBase900toBase10(numericCodewords, count)); + count = 0; + } + } + return codeIndex; + } + /** + * Convert a list of Numeric Compacted codewords from Base 900 to Base 10. + * + * @param codewords The array of codewords + * @param count The number of codewords + * @return The decoded string representing the Numeric data. + * + * EXAMPLE + * Encode the fifteen digit numeric string 000213298174000 + * Prefix the numeric string with a 1 and set the initial value of + * t = 1 000 213 298 174 000 + * Calculate codeword 0 + * d0 = 1 000 213 298 174 000 mod 900 = 200 + * + * t = 1 000 213 298 174 000 div 900 = 1 111 348 109 082 + * Calculate codeword 1 + * d1 = 1 111 348 109 082 mod 900 = 282 + * + * t = 1 111 348 109 082 div 900 = 1 234 831 232 + * Calculate codeword 2 + * d2 = 1 234 831 232 mod 900 = 632 + * + * t = 1 234 831 232 div 900 = 1 372 034 + * Calculate codeword 3 + * d3 = 1 372 034 mod 900 = 434 + * + * t = 1 372 034 div 900 = 1 524 + * Calculate codeword 4 + * d4 = 1 524 mod 900 = 624 + * + * t = 1 524 div 900 = 1 + * Calculate codeword 5 + * d5 = 1 mod 900 = 1 + * t = 1 div 900 = 0 + * Codeword sequence is: 1, 624, 434, 632, 282, 200 + * + * Decode the above codewords involves + * 1 x 900 power of 5 + 624 x 900 power of 4 + 434 x 900 power of 3 + + * 632 x 900 power of 2 + 282 x 900 power of 1 + 200 x 900 power of 0 = 1000213298174000 + * + * Remove leading 1 => Result is 000213298174000 + * + * @throws FormatException + */ + static decodeBase900toBase10(codewords, count) { + let result = createBigInt(0); + for (let i /*int*/ = 0; i < count; i++) { + result += DecodedBitStreamParser$2.EXP900[count - i - 1] * createBigInt(codewords[i]); + } + let resultString = result.toString(); + if (resultString.charAt(0) !== '1') { + throw new FormatException(); + } + return resultString.substring(1); + } + } + DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH = 900; + DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH = 901; + DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH = 902; + DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6 = 924; + DecodedBitStreamParser$2.ECI_USER_DEFINED = 925; + DecodedBitStreamParser$2.ECI_GENERAL_PURPOSE = 926; + DecodedBitStreamParser$2.ECI_CHARSET = 927; + DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK = 928; + DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD = 923; + DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR = 922; + DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE = 913; + DecodedBitStreamParser$2.MAX_NUMERIC_CODEWORDS = 15; + DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME = 0; + DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT = 1; + DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP = 2; + DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_SENDER = 3; + DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE = 4; + DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE = 5; + DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM = 6; + DecodedBitStreamParser$2.PL = 25; + DecodedBitStreamParser$2.LL = 27; + DecodedBitStreamParser$2.AS = 27; + DecodedBitStreamParser$2.ML = 28; + DecodedBitStreamParser$2.AL = 28; + DecodedBitStreamParser$2.PS = 29; + DecodedBitStreamParser$2.PAL = 29; + DecodedBitStreamParser$2.PUNCT_CHARS = ';<>@[\\]_`~!\r\t,:\n-.$/"|*()?{}\''; + DecodedBitStreamParser$2.MIXED_CHARS = '0123456789&\r\t,:#-.$/+%*=^'; + /** + * Table containing values for the exponent of 900. + * This is used in the numeric compaction decode algorithm. + */ + DecodedBitStreamParser$2.EXP900 = getBigIntConstructor() ? getEXP900() : []; + DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS = 2; + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // import java.util.ArrayList; + // import java.util.Collection; + // import java.util.Formatter; + // import java.util.List; + /** + * @author Guenther Grau + */ + /*public final*/ class PDF417ScanningDecoder { + constructor() { } + /** + * @TODO don't pass in minCodewordWidth and maxCodewordWidth, pass in barcode columns for start and stop pattern + * + * columns. That way width can be deducted from the pattern column. + * This approach also allows to detect more details about the barcode, e.g. if a bar type (white or black) is wider + * than it should be. This can happen if the scanner used a bad blackpoint. + * + * @param BitMatrix + * @param image + * @param ResultPoint + * @param imageTopLeft + * @param ResultPoint + * @param imageBottomLeft + * @param ResultPoint + * @param imageTopRight + * @param ResultPoint + * @param imageBottomRight + * @param int + * @param minCodewordWidth + * @param int + * @param maxCodewordWidth + * + * @throws NotFoundException + * @throws FormatException + * @throws ChecksumException + */ + static decode(image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight, minCodewordWidth, maxCodewordWidth) { + let boundingBox = new BoundingBox(image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight); + let leftRowIndicatorColumn = null; + let rightRowIndicatorColumn = null; + let detectionResult; + for (let firstPass /*boolean*/ = true;; firstPass = false) { + if (imageTopLeft != null) { + leftRowIndicatorColumn = PDF417ScanningDecoder.getRowIndicatorColumn(image, boundingBox, imageTopLeft, true, minCodewordWidth, maxCodewordWidth); + } + if (imageTopRight != null) { + rightRowIndicatorColumn = PDF417ScanningDecoder.getRowIndicatorColumn(image, boundingBox, imageTopRight, false, minCodewordWidth, maxCodewordWidth); + } + detectionResult = PDF417ScanningDecoder.merge(leftRowIndicatorColumn, rightRowIndicatorColumn); + if (detectionResult == null) { + throw NotFoundException.getNotFoundInstance(); + } + let resultBox = detectionResult.getBoundingBox(); + if (firstPass && resultBox != null && + (resultBox.getMinY() < boundingBox.getMinY() || resultBox.getMaxY() > boundingBox.getMaxY())) { + boundingBox = resultBox; + } + else { + break; + } + } + detectionResult.setBoundingBox(boundingBox); + let maxBarcodeColumn = detectionResult.getBarcodeColumnCount() + 1; + detectionResult.setDetectionResultColumn(0, leftRowIndicatorColumn); + detectionResult.setDetectionResultColumn(maxBarcodeColumn, rightRowIndicatorColumn); + let leftToRight = leftRowIndicatorColumn != null; + for (let barcodeColumnCount /*int*/ = 1; barcodeColumnCount <= maxBarcodeColumn; barcodeColumnCount++) { + let barcodeColumn = leftToRight ? barcodeColumnCount : maxBarcodeColumn - barcodeColumnCount; + if (detectionResult.getDetectionResultColumn(barcodeColumn) !== /* null */ undefined) { + // This will be the case for the opposite row indicator column, which doesn't need to be decoded again. + continue; + } + let detectionResultColumn; + if (barcodeColumn === 0 || barcodeColumn === maxBarcodeColumn) { + detectionResultColumn = new DetectionResultRowIndicatorColumn(boundingBox, barcodeColumn === 0); + } + else { + detectionResultColumn = new DetectionResultColumn(boundingBox); + } + detectionResult.setDetectionResultColumn(barcodeColumn, detectionResultColumn); + let startColumn = -1; + let previousStartColumn = startColumn; + // TODO start at a row for which we know the start position, then detect upwards and downwards from there. + for (let imageRow /*int*/ = boundingBox.getMinY(); imageRow <= boundingBox.getMaxY(); imageRow++) { + startColumn = PDF417ScanningDecoder.getStartColumn(detectionResult, barcodeColumn, imageRow, leftToRight); + if (startColumn < 0 || startColumn > boundingBox.getMaxX()) { + if (previousStartColumn === -1) { + continue; + } + startColumn = previousStartColumn; + } + let codeword = PDF417ScanningDecoder.detectCodeword(image, boundingBox.getMinX(), boundingBox.getMaxX(), leftToRight, startColumn, imageRow, minCodewordWidth, maxCodewordWidth); + if (codeword != null) { + detectionResultColumn.setCodeword(imageRow, codeword); + previousStartColumn = startColumn; + minCodewordWidth = Math.min(minCodewordWidth, codeword.getWidth()); + maxCodewordWidth = Math.max(maxCodewordWidth, codeword.getWidth()); + } + } + } + return PDF417ScanningDecoder.createDecoderResult(detectionResult); + } + /** + * + * @param leftRowIndicatorColumn + * @param rightRowIndicatorColumn + * + * @throws NotFoundException + */ + static merge(leftRowIndicatorColumn, rightRowIndicatorColumn) { + if (leftRowIndicatorColumn == null && rightRowIndicatorColumn == null) { + return null; + } + let barcodeMetadata = PDF417ScanningDecoder.getBarcodeMetadata(leftRowIndicatorColumn, rightRowIndicatorColumn); + if (barcodeMetadata == null) { + return null; + } + let boundingBox = BoundingBox.merge(PDF417ScanningDecoder.adjustBoundingBox(leftRowIndicatorColumn), PDF417ScanningDecoder.adjustBoundingBox(rightRowIndicatorColumn)); + return new DetectionResult(barcodeMetadata, boundingBox); + } + /** + * + * @param rowIndicatorColumn + * + * @throws NotFoundException + */ + static adjustBoundingBox(rowIndicatorColumn) { + if (rowIndicatorColumn == null) { + return null; + } + let rowHeights = rowIndicatorColumn.getRowHeights(); + if (rowHeights == null) { + return null; + } + let maxRowHeight = PDF417ScanningDecoder.getMax(rowHeights); + let missingStartRows = 0; + for (let rowHeight /*int*/ of rowHeights) { + missingStartRows += maxRowHeight - rowHeight; + if (rowHeight > 0) { + break; + } + } + let codewords = rowIndicatorColumn.getCodewords(); + for (let row /*int*/ = 0; missingStartRows > 0 && codewords[row] == null; row++) { + missingStartRows--; + } + let missingEndRows = 0; + for (let row /*int*/ = rowHeights.length - 1; row >= 0; row--) { + missingEndRows += maxRowHeight - rowHeights[row]; + if (rowHeights[row] > 0) { + break; + } + } + for (let row /*int*/ = codewords.length - 1; missingEndRows > 0 && codewords[row] == null; row--) { + missingEndRows--; + } + return rowIndicatorColumn.getBoundingBox().addMissingRows(missingStartRows, missingEndRows, rowIndicatorColumn.isLeft()); + } + static getMax(values) { + let maxValue = -1; + for (let value /*int*/ of values) { + maxValue = Math.max(maxValue, value); + } + return maxValue; + } + static getBarcodeMetadata(leftRowIndicatorColumn, rightRowIndicatorColumn) { + let leftBarcodeMetadata; + if (leftRowIndicatorColumn == null || + (leftBarcodeMetadata = leftRowIndicatorColumn.getBarcodeMetadata()) == null) { + return rightRowIndicatorColumn == null ? null : rightRowIndicatorColumn.getBarcodeMetadata(); + } + let rightBarcodeMetadata; + if (rightRowIndicatorColumn == null || + (rightBarcodeMetadata = rightRowIndicatorColumn.getBarcodeMetadata()) == null) { + return leftBarcodeMetadata; + } + if (leftBarcodeMetadata.getColumnCount() !== rightBarcodeMetadata.getColumnCount() && + leftBarcodeMetadata.getErrorCorrectionLevel() !== rightBarcodeMetadata.getErrorCorrectionLevel() && + leftBarcodeMetadata.getRowCount() !== rightBarcodeMetadata.getRowCount()) { + return null; + } + return leftBarcodeMetadata; + } + static getRowIndicatorColumn(image, boundingBox, startPoint, leftToRight, minCodewordWidth, maxCodewordWidth) { + let rowIndicatorColumn = new DetectionResultRowIndicatorColumn(boundingBox, leftToRight); + for (let i /*int*/ = 0; i < 2; i++) { + let increment = i === 0 ? 1 : -1; + let startColumn = Math.trunc(Math.trunc(startPoint.getX())); + for (let imageRow /*int*/ = Math.trunc(Math.trunc(startPoint.getY())); imageRow <= boundingBox.getMaxY() && + imageRow >= boundingBox.getMinY(); imageRow += increment) { + let codeword = PDF417ScanningDecoder.detectCodeword(image, 0, image.getWidth(), leftToRight, startColumn, imageRow, minCodewordWidth, maxCodewordWidth); + if (codeword != null) { + rowIndicatorColumn.setCodeword(imageRow, codeword); + if (leftToRight) { + startColumn = codeword.getStartX(); + } + else { + startColumn = codeword.getEndX(); + } + } + } + } + return rowIndicatorColumn; + } + /** + * + * @param detectionResult + * @param BarcodeValue + * @param param2 + * @param param3 + * @param barcodeMatrix + * + * @throws NotFoundException + */ + static adjustCodewordCount(detectionResult, barcodeMatrix) { + let barcodeMatrix01 = barcodeMatrix[0][1]; + let numberOfCodewords = barcodeMatrix01.getValue(); + let calculatedNumberOfCodewords = detectionResult.getBarcodeColumnCount() * + detectionResult.getBarcodeRowCount() - + PDF417ScanningDecoder.getNumberOfECCodeWords(detectionResult.getBarcodeECLevel()); + if (numberOfCodewords.length === 0) { + if (calculatedNumberOfCodewords < 1 || calculatedNumberOfCodewords > PDF417Common.MAX_CODEWORDS_IN_BARCODE) { + throw NotFoundException.getNotFoundInstance(); + } + barcodeMatrix01.setValue(calculatedNumberOfCodewords); + } + else if (numberOfCodewords[0] !== calculatedNumberOfCodewords) { + // The calculated one is more reliable as it is derived from the row indicator columns + barcodeMatrix01.setValue(calculatedNumberOfCodewords); + } + } + /** + * + * @param detectionResult + * + * @throws FormatException + * @throws ChecksumException + * @throws NotFoundException + */ + static createDecoderResult(detectionResult) { + let barcodeMatrix = PDF417ScanningDecoder.createBarcodeMatrix(detectionResult); + PDF417ScanningDecoder.adjustCodewordCount(detectionResult, barcodeMatrix); + let erasures /*Collection<Integer>*/ = new Array(); + let codewords = new Int32Array(detectionResult.getBarcodeRowCount() * detectionResult.getBarcodeColumnCount()); + let ambiguousIndexValuesList = /*List<int[]>*/ []; + let ambiguousIndexesList = /*Collection<Integer>*/ new Array(); + for (let row /*int*/ = 0; row < detectionResult.getBarcodeRowCount(); row++) { + for (let column /*int*/ = 0; column < detectionResult.getBarcodeColumnCount(); column++) { + let values = barcodeMatrix[row][column + 1].getValue(); + let codewordIndex = row * detectionResult.getBarcodeColumnCount() + column; + if (values.length === 0) { + erasures.push(codewordIndex); + } + else if (values.length === 1) { + codewords[codewordIndex] = values[0]; + } + else { + ambiguousIndexesList.push(codewordIndex); + ambiguousIndexValuesList.push(values); + } + } + } + let ambiguousIndexValues = new Array(ambiguousIndexValuesList.length); + for (let i /*int*/ = 0; i < ambiguousIndexValues.length; i++) { + ambiguousIndexValues[i] = ambiguousIndexValuesList[i]; + } + return PDF417ScanningDecoder.createDecoderResultFromAmbiguousValues(detectionResult.getBarcodeECLevel(), codewords, PDF417Common.toIntArray(erasures), PDF417Common.toIntArray(ambiguousIndexesList), ambiguousIndexValues); + } + /** + * This method deals with the fact, that the decoding process doesn't always yield a single most likely value. The + * current error correction implementation doesn't deal with erasures very well, so it's better to provide a value + * for these ambiguous codewords instead of treating it as an erasure. The problem is that we don't know which of + * the ambiguous values to choose. We try decode using the first value, and if that fails, we use another of the + * ambiguous values and try to decode again. This usually only happens on very hard to read and decode barcodes, + * so decoding the normal barcodes is not affected by this. + * + * @param erasureArray contains the indexes of erasures + * @param ambiguousIndexes array with the indexes that have more than one most likely value + * @param ambiguousIndexValues two dimensional array that contains the ambiguous values. The first dimension must + * be the same length as the ambiguousIndexes array + * + * @throws FormatException + * @throws ChecksumException + */ + static createDecoderResultFromAmbiguousValues(ecLevel, codewords, erasureArray, ambiguousIndexes, ambiguousIndexValues) { + let ambiguousIndexCount = new Int32Array(ambiguousIndexes.length); + let tries = 100; + while (tries-- > 0) { + for (let i /*int*/ = 0; i < ambiguousIndexCount.length; i++) { + codewords[ambiguousIndexes[i]] = ambiguousIndexValues[i][ambiguousIndexCount[i]]; + } + try { + return PDF417ScanningDecoder.decodeCodewords(codewords, ecLevel, erasureArray); + } + catch (err) { + let ignored = err instanceof ChecksumException; + if (!ignored) { + throw err; + } + } + if (ambiguousIndexCount.length === 0) { + throw ChecksumException.getChecksumInstance(); + } + for (let i /*int*/ = 0; i < ambiguousIndexCount.length; i++) { + if (ambiguousIndexCount[i] < ambiguousIndexValues[i].length - 1) { + ambiguousIndexCount[i]++; + break; + } + else { + ambiguousIndexCount[i] = 0; + if (i === ambiguousIndexCount.length - 1) { + throw ChecksumException.getChecksumInstance(); + } + } + } + } + throw ChecksumException.getChecksumInstance(); + } + static createBarcodeMatrix(detectionResult) { + // let barcodeMatrix: BarcodeValue[][] = + // new BarcodeValue[detectionResult.getBarcodeRowCount()][detectionResult.getBarcodeColumnCount() + 2]; + let barcodeMatrix = Array.from({ length: detectionResult.getBarcodeRowCount() }, () => new Array(detectionResult.getBarcodeColumnCount() + 2)); + for (let row /*int*/ = 0; row < barcodeMatrix.length; row++) { + for (let column /*int*/ = 0; column < barcodeMatrix[row].length; column++) { + barcodeMatrix[row][column] = new BarcodeValue(); + } + } + let column = 0; + for (let detectionResultColumn /*DetectionResultColumn*/ of detectionResult.getDetectionResultColumns()) { + if (detectionResultColumn != null) { + for (let codeword /*Codeword*/ of detectionResultColumn.getCodewords()) { + if (codeword != null) { + let rowNumber = codeword.getRowNumber(); + if (rowNumber >= 0) { + if (rowNumber >= barcodeMatrix.length) { + // We have more rows than the barcode metadata allows for, ignore them. + continue; + } + barcodeMatrix[rowNumber][column].setValue(codeword.getValue()); + } + } + } + } + column++; + } + return barcodeMatrix; + } + static isValidBarcodeColumn(detectionResult, barcodeColumn) { + return barcodeColumn >= 0 && barcodeColumn <= detectionResult.getBarcodeColumnCount() + 1; + } + static getStartColumn(detectionResult, barcodeColumn, imageRow, leftToRight) { + let offset = leftToRight ? 1 : -1; + let codeword = null; + if (PDF417ScanningDecoder.isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { + codeword = detectionResult.getDetectionResultColumn(barcodeColumn - offset).getCodeword(imageRow); + } + if (codeword != null) { + return leftToRight ? codeword.getEndX() : codeword.getStartX(); + } + codeword = detectionResult.getDetectionResultColumn(barcodeColumn).getCodewordNearby(imageRow); + if (codeword != null) { + return leftToRight ? codeword.getStartX() : codeword.getEndX(); + } + if (PDF417ScanningDecoder.isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { + codeword = detectionResult.getDetectionResultColumn(barcodeColumn - offset).getCodewordNearby(imageRow); + } + if (codeword != null) { + return leftToRight ? codeword.getEndX() : codeword.getStartX(); + } + let skippedColumns = 0; + while (PDF417ScanningDecoder.isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { + barcodeColumn -= offset; + for (let previousRowCodeword /*Codeword*/ of detectionResult.getDetectionResultColumn(barcodeColumn).getCodewords()) { + if (previousRowCodeword != null) { + return (leftToRight ? previousRowCodeword.getEndX() : previousRowCodeword.getStartX()) + + offset * + skippedColumns * + (previousRowCodeword.getEndX() - previousRowCodeword.getStartX()); + } + } + skippedColumns++; + } + return leftToRight ? detectionResult.getBoundingBox().getMinX() : detectionResult.getBoundingBox().getMaxX(); + } + static detectCodeword(image, minColumn, maxColumn, leftToRight, startColumn, imageRow, minCodewordWidth, maxCodewordWidth) { + startColumn = PDF417ScanningDecoder.adjustCodewordStartColumn(image, minColumn, maxColumn, leftToRight, startColumn, imageRow); + // we usually know fairly exact now how long a codeword is. We should provide minimum and maximum expected length + // and try to adjust the read pixels, e.g. remove single pixel errors or try to cut off exceeding pixels. + // min and maxCodewordWidth should not be used as they are calculated for the whole barcode an can be inaccurate + // for the current position + let moduleBitCount = PDF417ScanningDecoder.getModuleBitCount(image, minColumn, maxColumn, leftToRight, startColumn, imageRow); + if (moduleBitCount == null) { + return null; + } + let endColumn; + let codewordBitCount = MathUtils.sum(moduleBitCount); + if (leftToRight) { + endColumn = startColumn + codewordBitCount; + } + else { + for (let i /*int*/ = 0; i < moduleBitCount.length / 2; i++) { + let tmpCount = moduleBitCount[i]; + moduleBitCount[i] = moduleBitCount[moduleBitCount.length - 1 - i]; + moduleBitCount[moduleBitCount.length - 1 - i] = tmpCount; + } + endColumn = startColumn; + startColumn = endColumn - codewordBitCount; + } + // TODO implement check for width and correction of black and white bars + // use start (and maybe stop pattern) to determine if black bars are wider than white bars. If so, adjust. + // should probably done only for codewords with a lot more than 17 bits. + // The following fixes 10-1.png, which has wide black bars and small white bars + // for (let i /*int*/ = 0; i < moduleBitCount.length; i++) { + // if (i % 2 === 0) { + // moduleBitCount[i]--; + // } else { + // moduleBitCount[i]++; + // } + // } + // We could also use the width of surrounding codewords for more accurate results, but this seems + // sufficient for now + if (!PDF417ScanningDecoder.checkCodewordSkew(codewordBitCount, minCodewordWidth, maxCodewordWidth)) { + // We could try to use the startX and endX position of the codeword in the same column in the previous row, + // create the bit count from it and normalize it to 8. This would help with single pixel errors. + return null; + } + let decodedValue = PDF417CodewordDecoder.getDecodedValue(moduleBitCount); + let codeword = PDF417Common.getCodeword(decodedValue); + if (codeword === -1) { + return null; + } + return new Codeword(startColumn, endColumn, PDF417ScanningDecoder.getCodewordBucketNumber(decodedValue), codeword); + } + static getModuleBitCount(image, minColumn, maxColumn, leftToRight, startColumn, imageRow) { + let imageColumn = startColumn; + let moduleBitCount = new Int32Array(8); + let moduleNumber = 0; + let increment = leftToRight ? 1 : -1; + let previousPixelValue = leftToRight; + while ((leftToRight ? imageColumn < maxColumn : imageColumn >= minColumn) && + moduleNumber < moduleBitCount.length) { + if (image.get(imageColumn, imageRow) === previousPixelValue) { + moduleBitCount[moduleNumber]++; + imageColumn += increment; + } + else { + moduleNumber++; + previousPixelValue = !previousPixelValue; + } + } + if (moduleNumber === moduleBitCount.length || + ((imageColumn === (leftToRight ? maxColumn : minColumn)) && + moduleNumber === moduleBitCount.length - 1)) { + return moduleBitCount; + } + return null; + } + static getNumberOfECCodeWords(barcodeECLevel) { + return 2 << barcodeECLevel; + } + static adjustCodewordStartColumn(image, minColumn, maxColumn, leftToRight, codewordStartColumn, imageRow) { + let correctedStartColumn = codewordStartColumn; + let increment = leftToRight ? -1 : 1; + // there should be no black pixels before the start column. If there are, then we need to start earlier. + for (let i /*int*/ = 0; i < 2; i++) { + while ((leftToRight ? correctedStartColumn >= minColumn : correctedStartColumn < maxColumn) && + leftToRight === image.get(correctedStartColumn, imageRow)) { + if (Math.abs(codewordStartColumn - correctedStartColumn) > PDF417ScanningDecoder.CODEWORD_SKEW_SIZE) { + return codewordStartColumn; + } + correctedStartColumn += increment; + } + increment = -increment; + leftToRight = !leftToRight; + } + return correctedStartColumn; + } + static checkCodewordSkew(codewordSize, minCodewordWidth, maxCodewordWidth) { + return minCodewordWidth - PDF417ScanningDecoder.CODEWORD_SKEW_SIZE <= codewordSize && + codewordSize <= maxCodewordWidth + PDF417ScanningDecoder.CODEWORD_SKEW_SIZE; + } + /** + * @throws FormatException, + * @throws ChecksumException + */ + static decodeCodewords(codewords, ecLevel, erasures) { + if (codewords.length === 0) { + throw FormatException.getFormatInstance(); + } + let numECCodewords = 1 << (ecLevel + 1); + let correctedErrorsCount = PDF417ScanningDecoder.correctErrors(codewords, erasures, numECCodewords); + PDF417ScanningDecoder.verifyCodewordCount(codewords, numECCodewords); + // Decode the codewords + let decoderResult = DecodedBitStreamParser$2.decode(codewords, '' + ecLevel); + decoderResult.setErrorsCorrected(correctedErrorsCount); + decoderResult.setErasures(erasures.length); + return decoderResult; + } + /** + * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to + * correct the errors in-place.</p> + * + * @param codewords data and error correction codewords + * @param erasures positions of any known erasures + * @param numECCodewords number of error correction codewords that are available in codewords + * @throws ChecksumException if error correction fails + */ + static correctErrors(codewords, erasures, numECCodewords) { + if (erasures != null && + erasures.length > numECCodewords / 2 + PDF417ScanningDecoder.MAX_ERRORS || + numECCodewords < 0 || + numECCodewords > PDF417ScanningDecoder.MAX_EC_CODEWORDS) { + // Too many errors or EC Codewords is corrupted + throw ChecksumException.getChecksumInstance(); + } + return PDF417ScanningDecoder.errorCorrection.decode(codewords, numECCodewords, erasures); + } + /** + * Verify that all is OK with the codeword array. + * @throws FormatException + */ + static verifyCodewordCount(codewords, numECCodewords) { + if (codewords.length < 4) { + // Codeword array size should be at least 4 allowing for + // Count CW, At least one Data CW, Error Correction CW, Error Correction CW + throw FormatException.getFormatInstance(); + } + // The first codeword, the Symbol Length Descriptor, shall always encode the total number of data + // codewords in the symbol, including the Symbol Length Descriptor itself, data codewords and pad + // codewords, but excluding the number of error correction codewords. + let numberOfCodewords = codewords[0]; + if (numberOfCodewords > codewords.length) { + throw FormatException.getFormatInstance(); + } + if (numberOfCodewords === 0) { + // Reset to the length of the array - 8 (Allow for at least level 3 Error Correction (8 Error Codewords) + if (numECCodewords < codewords.length) { + codewords[0] = codewords.length - numECCodewords; + } + else { + throw FormatException.getFormatInstance(); + } + } + } + static getBitCountForCodeword(codeword) { + let result = new Int32Array(8); + let previousValue = 0; + let i = result.length - 1; + while (true) { + if ((codeword & 0x1) !== previousValue) { + previousValue = codeword & 0x1; + i--; + if (i < 0) { + break; + } + } + result[i]++; + codeword >>= 1; + } + return result; + } + static getCodewordBucketNumber(codeword) { + if (codeword instanceof Int32Array) { + return this.getCodewordBucketNumber_Int32Array(codeword); + } + return this.getCodewordBucketNumber_number(codeword); + } + static getCodewordBucketNumber_number(codeword) { + return PDF417ScanningDecoder.getCodewordBucketNumber(PDF417ScanningDecoder.getBitCountForCodeword(codeword)); + } + static getCodewordBucketNumber_Int32Array(moduleBitCount) { + return (moduleBitCount[0] - moduleBitCount[2] + moduleBitCount[4] - moduleBitCount[6] + 9) % 9; + } + static toString(barcodeMatrix) { + let formatter = new Formatter(); + // try (let formatter = new Formatter()) { + for (let row /*int*/ = 0; row < barcodeMatrix.length; row++) { + formatter.format('Row %2d: ', row); + for (let column /*int*/ = 0; column < barcodeMatrix[row].length; column++) { + let barcodeValue = barcodeMatrix[row][column]; + if (barcodeValue.getValue().length === 0) { + formatter.format(' ', null); + } + else { + formatter.format('%4d(%2d)', barcodeValue.getValue()[0], barcodeValue.getConfidence(barcodeValue.getValue()[0])); + } + } + formatter.format('%n'); + } + return formatter.toString(); + // } + } + } + /*final*/ PDF417ScanningDecoder.CODEWORD_SKEW_SIZE = 2; + /*final*/ PDF417ScanningDecoder.MAX_ERRORS = 3; + /*final*/ PDF417ScanningDecoder.MAX_EC_CODEWORDS = 512; + /*final*/ PDF417ScanningDecoder.errorCorrection = new ErrorCorrection(); + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // import java.util.ArrayList; + // import java.util.List; + // import java.util.Map; + /** + * This implementation can detect and decode PDF417 codes in an image. + * + * @author Guenther Grau + */ + /*public final*/ class PDF417Reader { + // private static /*final Result[]*/ EMPTY_RESULT_ARRAY: Result[] = new Result([0]); + /** + * Locates and decodes a PDF417 code in an image. + * + * @return a String representing the content encoded by the PDF417 code + * @throws NotFoundException if a PDF417 code cannot be found, + * @throws FormatException if a PDF417 cannot be decoded + * @throws ChecksumException + */ + // @Override + decode(image, hints = null) { + let result = PDF417Reader.decode(image, hints, false); + if (result == null || result.length === 0 || result[0] == null) { + throw NotFoundException.getNotFoundInstance(); + } + return result[0]; + } + /** + * + * @param BinaryBitmap + * @param image + * @throws NotFoundException + */ + // @Override + decodeMultiple(image, hints = null) { + try { + return PDF417Reader.decode(image, hints, true); + } + catch (ignored) { + if (ignored instanceof FormatException || ignored instanceof ChecksumException) { + throw NotFoundException.getNotFoundInstance(); + } + throw ignored; + } + } + /** + * + * @param image + * @param hints + * @param multiple + * + * @throws NotFoundException + * @throws FormatExceptionß + * @throws ChecksumException + */ + static decode(image, hints, multiple) { + const results = new Array(); + const detectorResult = Detector$3.detectMultiple(image, hints, multiple); + for (const points of detectorResult.getPoints()) { + const decoderResult = PDF417ScanningDecoder.decode(detectorResult.getBits(), points[4], points[5], points[6], points[7], PDF417Reader.getMinCodewordWidth(points), PDF417Reader.getMaxCodewordWidth(points)); + const result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), undefined, points, BarcodeFormat$1.PDF_417); + result.putMetadata(ResultMetadataType$1.ERROR_CORRECTION_LEVEL, decoderResult.getECLevel()); + const pdf417ResultMetadata = decoderResult.getOther(); + if (pdf417ResultMetadata != null) { + result.putMetadata(ResultMetadataType$1.PDF417_EXTRA_METADATA, pdf417ResultMetadata); + } + results.push(result); + } + return results.map(x => x); + } + static getMaxWidth(p1, p2) { + if (p1 == null || p2 == null) { + return 0; + } + return Math.trunc(Math.abs(p1.getX() - p2.getX())); + } + static getMinWidth(p1, p2) { + if (p1 == null || p2 == null) { + return Integer.MAX_VALUE; + } + return Math.trunc(Math.abs(p1.getX() - p2.getX())); + } + static getMaxCodewordWidth(p) { + return Math.floor(Math.max(Math.max(PDF417Reader.getMaxWidth(p[0], p[4]), PDF417Reader.getMaxWidth(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD / + PDF417Common.MODULES_IN_STOP_PATTERN), Math.max(PDF417Reader.getMaxWidth(p[1], p[5]), PDF417Reader.getMaxWidth(p[7], p[3]) * PDF417Common.MODULES_IN_CODEWORD / + PDF417Common.MODULES_IN_STOP_PATTERN))); + } + static getMinCodewordWidth(p) { + return Math.floor(Math.min(Math.min(PDF417Reader.getMinWidth(p[0], p[4]), PDF417Reader.getMinWidth(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD / + PDF417Common.MODULES_IN_STOP_PATTERN), Math.min(PDF417Reader.getMinWidth(p[1], p[5]), PDF417Reader.getMinWidth(p[7], p[3]) * PDF417Common.MODULES_IN_CODEWORD / + PDF417Common.MODULES_IN_STOP_PATTERN))); + } + // @Override + reset() { + // nothing needs to be reset + } + } + + /** + * Custom Error class of type Exception. + */ + class ReaderException extends Exception { + } + ReaderException.kind = 'ReaderException'; + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*namespace com.google.zxing {*/ + /** + * MultiFormatReader is a convenience class and the main entry point into the library for most uses. + * By default it attempts to decode all barcode formats that the library supports. Optionally, you + * can provide a hints object to request different behavior, for example only decoding QR codes. + * + * @author Sean Owen + * @author dswitkin@google.com (Daniel Switkin) + */ + class MultiFormatReader { + /** + * Creates an instance of this class + * + * @param {Boolean} verbose if 'true' logs will be dumped to console, otherwise hidden. + * @param hints The hints to use, clearing the previous state. + */ + constructor(verbose, hints) { + this.verbose = (verbose === true); + if (hints) { + this.setHints(hints); + } + } + /** + * This version of decode honors the intent of Reader.decode(BinaryBitmap) in that it + * passes null as a hint to the decoders. However, that makes it inefficient to call repeatedly. + * Use setHints() followed by decodeWithState() for continuous scan applications. + * + * @param image The pixel data to decode + * @return The contents of the image + * + * @throws NotFoundException Any errors which occurred + */ + /*@Override*/ + // public decode(image: BinaryBitmap): Result { + // setHints(null) + // return decodeInternal(image) + // } + /** + * Decode an image using the hints provided. Does not honor existing state. + * + * @param image The pixel data to decode + * @param hints The hints to use, clearing the previous state. + * @return The contents of the image + * + * @throws NotFoundException Any errors which occurred + */ + /*@Override*/ + decode(image, hints) { + if (hints) { + this.setHints(hints); + } + return this.decodeInternal(image); + } + /** + * Decode an image using the state set up by calling setHints() previously. Continuous scan + * clients will get a <b>large</b> speed increase by using this instead of decode(). + * + * @param image The pixel data to decode + * @return The contents of the image + * + * @throws NotFoundException Any errors which occurred + */ + decodeWithState(image) { + // Make sure to set up the default state so we don't crash + if (this.readers === null || this.readers === undefined) { + this.setHints(null); + } + return this.decodeInternal(image); + } + /** + * This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls + * to decodeWithState(image) can reuse the same set of readers without reallocating memory. This + * is important for performance in continuous scan clients. + * + * @param hints The set of hints to use for subsequent calls to decode(image) + */ + setHints(hints) { + this.hints = hints; + const tryHarder = !isNullOrUndefined(hints) + && hints.get(DecodeHintType$1.TRY_HARDER) === true; + const formats = isNullOrUndefined(hints) ? null : hints.get(DecodeHintType$1.POSSIBLE_FORMATS); + const readers = new Array(); + if (!isNullOrUndefined(formats)) { + const addOneDReader = formats.some(f => { + return ( + f === BarcodeFormat$1.UPC_A || + f === BarcodeFormat$1.UPC_E || + f === BarcodeFormat$1.EAN_13 || + f === BarcodeFormat$1.EAN_8 || + f === BarcodeFormat$1.CODABAR || + f === BarcodeFormat$1.CODE_39 || + f === BarcodeFormat$1.CODE_93 || + f === BarcodeFormat$1.CODE_128 || + f === BarcodeFormat$1.ITF || + f === BarcodeFormat$1.RSS_14 || + f === BarcodeFormat$1.RSS_EXPANDED); + }); + // Put 1D readers upfront in "normal" mode + if (addOneDReader && !tryHarder) { + readers.push(new MultiFormatOneDReader(hints, this.verbose)); + } + if (formats.includes(BarcodeFormat$1.QR_CODE)) { + readers.push(new QRCodeReader()); + } + if (formats.includes(BarcodeFormat$1.DATA_MATRIX)) { + readers.push(new DataMatrixReader()); + } + if (formats.includes(BarcodeFormat$1.AZTEC)) { + readers.push(new AztecReader()); + } + if (formats.includes(BarcodeFormat$1.PDF_417)) { + readers.push(new PDF417Reader()); + } + // if (formats.includes(BarcodeFormat.MAXICODE)) { + // readers.push(new MaxiCodeReader()) + // } + // At end in "try harder" mode + if (addOneDReader && tryHarder) { + readers.push(new MultiFormatOneDReader(hints, this.verbose)); + } + } + if (readers.length === 0) { + if (!tryHarder) { + readers.push(new MultiFormatOneDReader(hints, this.verbose)); + } + readers.push(new QRCodeReader()); + readers.push(new DataMatrixReader()); + readers.push(new AztecReader()); + readers.push(new PDF417Reader()); + // readers.push(new MaxiCodeReader()) + if (tryHarder) { + readers.push(new MultiFormatOneDReader(hints, this.verbose)); + } + } + this.readers = readers; // .toArray(new Reader[readers.size()]) + } + /*@Override*/ + reset() { + if (this.readers !== null) { + for (const reader of this.readers) { + reader.reset(); + } + } + } + /** + * @throws NotFoundException + */ + decodeInternal(image) { + if (this.readers === null) { + throw new ReaderException('No readers where selected, nothing can be read.'); + } + for (const reader of this.readers) { + // Trying to decode with ${reader} reader. + try { + return reader.decode(image, this.hints); + } + catch (ex) { + if (ex instanceof ReaderException) { + continue; + } + // Bad Exception. + } + } + throw new NotFoundException('No MultiFormat Readers were able to detect the code.'); + } + } + + class BrowserMultiFormatReader extends BrowserCodeReader { + constructor(hints = null, timeBetweenScansMillis = 500) { + const reader = new MultiFormatReader(); + reader.setHints(hints); + super(reader, timeBetweenScansMillis); + } + /** + * Overwrite decodeBitmap to call decodeWithState, which will pay + * attention to the hints set in the constructor function + */ + decodeBitmap(binaryBitmap) { + return this.reader.decodeWithState(binaryBitmap); + } + } + + /** + * @deprecated Moving to @zxing/browser + * + * QR Code reader to use from browser. + */ + class BrowserPDF417Reader extends BrowserCodeReader { + /** + * Creates an instance of BrowserPDF417Reader. + * @param {number} [timeBetweenScansMillis=500] the time delay between subsequent decode tries + */ + constructor(timeBetweenScansMillis = 500) { + super(new PDF417Reader(), timeBetweenScansMillis); + } + } + + /** + * @deprecated Moving to @zxing/browser + * + * QR Code reader to use from browser. + */ + class BrowserQRCodeReader extends BrowserCodeReader { + /** + * Creates an instance of BrowserQRCodeReader. + * @param {number} [timeBetweenScansMillis=500] the time delay between subsequent decode tries + */ + constructor(timeBetweenScansMillis = 500) { + super(new QRCodeReader(), timeBetweenScansMillis); + } + } + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*namespace com.google.zxing {*/ + /** + * These are a set of hints that you may pass to Writers to specify their behavior. + * + * @author dswitkin@google.com (Daniel Switkin) + */ + var EncodeHintType; + (function (EncodeHintType) { + /** + * Specifies what degree of error correction to use, for example in QR Codes. + * Type depends on the encoder. For example for QR codes it's type + * {@link com.google.zxing.qrcode.decoder.ErrorCorrectionLevel ErrorCorrectionLevel}. + * For Aztec it is of type {@link Integer}, representing the minimal percentage of error correction words. + * For PDF417 it is of type {@link Integer}, valid values being 0 to 8. + * In all cases, it can also be a {@link String} representation of the desired value as well. + * Note: an Aztec symbol should have a minimum of 25% EC words. + */ + EncodeHintType[EncodeHintType["ERROR_CORRECTION"] = 0] = "ERROR_CORRECTION"; + /** + * Specifies what character encoding to use where applicable (type {@link String}) + */ + EncodeHintType[EncodeHintType["CHARACTER_SET"] = 1] = "CHARACTER_SET"; + /** + * Specifies the matrix shape for Data Matrix (type {@link com.google.zxing.datamatrix.encoder.SymbolShapeHint}) + */ + EncodeHintType[EncodeHintType["DATA_MATRIX_SHAPE"] = 2] = "DATA_MATRIX_SHAPE"; + /** + * Specifies a minimum barcode size (type {@link Dimension}). Only applicable to Data Matrix now. + * + * @deprecated use width/height params in + * {@link com.google.zxing.datamatrix.DataMatrixWriter#encode(String, BarcodeFormat, int, int)} + */ + /*@Deprecated*/ + EncodeHintType[EncodeHintType["MIN_SIZE"] = 3] = "MIN_SIZE"; + /** + * Specifies a maximum barcode size (type {@link Dimension}). Only applicable to Data Matrix now. + * + * @deprecated without replacement + */ + /*@Deprecated*/ + EncodeHintType[EncodeHintType["MAX_SIZE"] = 4] = "MAX_SIZE"; + /** + * Specifies margin, in pixels, to use when generating the barcode. The meaning can vary + * by format; for example it controls margin before and after the barcode horizontally for + * most 1D formats. (Type {@link Integer}, or {@link String} representation of the integer value). + */ + EncodeHintType[EncodeHintType["MARGIN"] = 5] = "MARGIN"; + /** + * Specifies whether to use compact mode for PDF417 (type {@link Boolean}, or "true" or "false" + * {@link String} value). + */ + EncodeHintType[EncodeHintType["PDF417_COMPACT"] = 6] = "PDF417_COMPACT"; + /** + * Specifies what compaction mode to use for PDF417 (type + * {@link com.google.zxing.pdf417.encoder.Compaction Compaction} or {@link String} value of one of its + * enum values). + */ + EncodeHintType[EncodeHintType["PDF417_COMPACTION"] = 7] = "PDF417_COMPACTION"; + /** + * Specifies the minimum and maximum number of rows and columns for PDF417 (type + * {@link com.google.zxing.pdf417.encoder.Dimensions Dimensions}). + */ + EncodeHintType[EncodeHintType["PDF417_DIMENSIONS"] = 8] = "PDF417_DIMENSIONS"; + /** + * Specifies the required number of layers for an Aztec code. + * A negative number (-1, -2, -3, -4) specifies a compact Aztec code. + * 0 indicates to use the minimum number of layers (the default). + * A positive number (1, 2, .. 32) specifies a normal (non-compact) Aztec code. + * (Type {@link Integer}, or {@link String} representation of the integer value). + */ + EncodeHintType[EncodeHintType["AZTEC_LAYERS"] = 9] = "AZTEC_LAYERS"; + /** + * Specifies the exact version of QR code to be encoded. + * (Type {@link Integer}, or {@link String} representation of the integer value). + */ + EncodeHintType[EncodeHintType["QR_VERSION"] = 10] = "QR_VERSION"; + })(EncodeHintType || (EncodeHintType = {})); + var EncodeHintType$1 = EncodeHintType; + + /** + * <p>Implements Reed-Solomon encoding, as the name implies.</p> + * + * @author Sean Owen + * @author William Rucklidge + */ + class ReedSolomonEncoder { + /** + * A reed solomon error-correcting encoding constructor is created by + * passing as Galois Field with of size equal to the number of code + * words (symbols) in the alphabet (the number of values in each + * element of arrays that are encoded/decoded). + * @param field A galois field with a number of elements equal to the size + * of the alphabet of symbols to encode. + */ + constructor(field) { + this.field = field; + this.cachedGenerators = []; + this.cachedGenerators.push(new GenericGFPoly(field, Int32Array.from([1]))); + } + buildGenerator(degree /*int*/) { + const cachedGenerators = this.cachedGenerators; + if (degree >= cachedGenerators.length) { + let lastGenerator = cachedGenerators[cachedGenerators.length - 1]; + const field = this.field; + for (let d = cachedGenerators.length; d <= degree; d++) { + const nextGenerator = lastGenerator.multiply(new GenericGFPoly(field, Int32Array.from([1, field.exp(d - 1 + field.getGeneratorBase())]))); + cachedGenerators.push(nextGenerator); + lastGenerator = nextGenerator; + } + } + return cachedGenerators[degree]; + } + /** + * <p>Encode a sequence of code words (symbols) using Reed-Solomon to allow decoders + * to detect and correct errors that may have been introduced when the resulting + * data is stored or transmitted.</p> + * + * @param toEncode array used for both and output. Caller initializes the array with + * the code words (symbols) to be encoded followed by empty elements allocated to make + * space for error-correction code words in the encoded output. The array contains + * the encdoded output when encode returns. Code words are encoded as numbers from + * 0 to n-1, where n is the number of possible code words (symbols), as determined + * by the size of the Galois Field passed in the constructor of this object. + * @param ecBytes the number of elements reserved in the array (first parameter) + * to store error-correction code words. Thus, the number of code words (symbols) + * to encode in the first parameter is thus toEncode.length - ecBytes. + * Note, the use of "bytes" in the name of this parameter is misleading, as there may + * be more or fewer than 256 symbols being encoded, as determined by the number of + * elements in the Galois Field passed as a constructor to this object. + * @throws IllegalArgumentException thrown in response to validation errros. + */ + encode(toEncode, ecBytes /*int*/) { + if (ecBytes === 0) { + throw new IllegalArgumentException('No error correction bytes'); + } + const dataBytes = toEncode.length - ecBytes; + if (dataBytes <= 0) { + throw new IllegalArgumentException('No data bytes provided'); + } + const generator = this.buildGenerator(ecBytes); + const infoCoefficients = new Int32Array(dataBytes); + System.arraycopy(toEncode, 0, infoCoefficients, 0, dataBytes); + let info = new GenericGFPoly(this.field, infoCoefficients); + info = info.multiplyByMonomial(ecBytes, 1); + const remainder = info.divide(generator)[1]; + const coefficients = remainder.getCoefficients(); + const numZeroCoefficients = ecBytes - coefficients.length; + for (let i = 0; i < numZeroCoefficients; i++) { + toEncode[dataBytes + i] = 0; + } + System.arraycopy(coefficients, 0, toEncode, dataBytes + numZeroCoefficients, coefficients.length); + } + } + + /** + * @author Satoru Takabayashi + * @author Daniel Switkin + * @author Sean Owen + */ + class MaskUtil { + constructor() { + // do nothing + } + /** + * Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and + * give penalty to them. Example: 00000 or 11111. + */ + static applyMaskPenaltyRule1(matrix) { + return MaskUtil.applyMaskPenaltyRule1Internal(matrix, true) + MaskUtil.applyMaskPenaltyRule1Internal(matrix, false); + } + /** + * Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give + * penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a + * penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block. + */ + static applyMaskPenaltyRule2(matrix) { + let penalty = 0; + const array = matrix.getArray(); + const width = matrix.getWidth(); + const height = matrix.getHeight(); + for (let y = 0; y < height - 1; y++) { + const arrayY = array[y]; + for (let x = 0; x < width - 1; x++) { + const value = arrayY[x]; + if (value === arrayY[x + 1] && value === array[y + 1][x] && value === array[y + 1][x + 1]) { + penalty++; + } + } + } + return MaskUtil.N2 * penalty; + } + /** + * Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4 + * starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we + * find patterns like 000010111010000, we give penalty once. + */ + static applyMaskPenaltyRule3(matrix) { + let numPenalties = 0; + const array = matrix.getArray(); + const width = matrix.getWidth(); + const height = matrix.getHeight(); + for (let y = 0; y < height; y++) { + for (let x = 0; x < width; x++) { + const arrayY = array[y]; // We can at least optimize this access + if (x + 6 < width && + arrayY[x] === 1 && + arrayY[x + 1] === 0 && + arrayY[x + 2] === 1 && + arrayY[x + 3] === 1 && + arrayY[x + 4] === 1 && + arrayY[x + 5] === 0 && + arrayY[x + 6] === 1 && + (MaskUtil.isWhiteHorizontal(arrayY, x - 4, x) || MaskUtil.isWhiteHorizontal(arrayY, x + 7, x + 11))) { + numPenalties++; + } + if (y + 6 < height && + array[y][x] === 1 && + array[y + 1][x] === 0 && + array[y + 2][x] === 1 && + array[y + 3][x] === 1 && + array[y + 4][x] === 1 && + array[y + 5][x] === 0 && + array[y + 6][x] === 1 && + (MaskUtil.isWhiteVertical(array, x, y - 4, y) || MaskUtil.isWhiteVertical(array, x, y + 7, y + 11))) { + numPenalties++; + } + } + } + return numPenalties * MaskUtil.N3; + } + static isWhiteHorizontal(rowArray, from /*int*/, to /*int*/) { + from = Math.max(from, 0); + to = Math.min(to, rowArray.length); + for (let i = from; i < to; i++) { + if (rowArray[i] === 1) { + return false; + } + } + return true; + } + static isWhiteVertical(array, col /*int*/, from /*int*/, to /*int*/) { + from = Math.max(from, 0); + to = Math.min(to, array.length); + for (let i = from; i < to; i++) { + if (array[i][col] === 1) { + return false; + } + } + return true; + } + /** + * Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give + * penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance. + */ + static applyMaskPenaltyRule4(matrix) { + let numDarkCells = 0; + const array = matrix.getArray(); + const width = matrix.getWidth(); + const height = matrix.getHeight(); + for (let y = 0; y < height; y++) { + const arrayY = array[y]; + for (let x = 0; x < width; x++) { + if (arrayY[x] === 1) { + numDarkCells++; + } + } + } + const numTotalCells = matrix.getHeight() * matrix.getWidth(); + const fivePercentVariances = Math.floor(Math.abs(numDarkCells * 2 - numTotalCells) * 10 / numTotalCells); + return fivePercentVariances * MaskUtil.N4; + } + /** + * Return the mask bit for "getMaskPattern" at "x" and "y". See 8.8 of JISX0510:2004 for mask + * pattern conditions. + */ + static getDataMaskBit(maskPattern /*int*/, x /*int*/, y /*int*/) { + let intermediate; /*int*/ + let temp; /*int*/ + switch (maskPattern) { + case 0: + intermediate = (y + x) & 0x1; + break; + case 1: + intermediate = y & 0x1; + break; + case 2: + intermediate = x % 3; + break; + case 3: + intermediate = (y + x) % 3; + break; + case 4: + intermediate = (Math.floor(y / 2) + Math.floor(x / 3)) & 0x1; + break; + case 5: + temp = y * x; + intermediate = (temp & 0x1) + (temp % 3); + break; + case 6: + temp = y * x; + intermediate = ((temp & 0x1) + (temp % 3)) & 0x1; + break; + case 7: + temp = y * x; + intermediate = ((temp % 3) + ((y + x) & 0x1)) & 0x1; + break; + default: + throw new IllegalArgumentException('Invalid mask pattern: ' + maskPattern); + } + return intermediate === 0; + } + /** + * Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both + * vertical and horizontal orders respectively. + */ + static applyMaskPenaltyRule1Internal(matrix, isHorizontal) { + let penalty = 0; + const iLimit = isHorizontal ? matrix.getHeight() : matrix.getWidth(); + const jLimit = isHorizontal ? matrix.getWidth() : matrix.getHeight(); + const array = matrix.getArray(); + for (let i = 0; i < iLimit; i++) { + let numSameBitCells = 0; + let prevBit = -1; + for (let j = 0; j < jLimit; j++) { + const bit = isHorizontal ? array[i][j] : array[j][i]; + if (bit === prevBit) { + numSameBitCells++; + } + else { + if (numSameBitCells >= 5) { + penalty += MaskUtil.N1 + (numSameBitCells - 5); + } + numSameBitCells = 1; // Include the cell itself. + prevBit = bit; + } + } + if (numSameBitCells >= 5) { + penalty += MaskUtil.N1 + (numSameBitCells - 5); + } + } + return penalty; + } + } + // Penalty weights from section 6.8.2.1 + MaskUtil.N1 = 3; + MaskUtil.N2 = 3; + MaskUtil.N3 = 40; + MaskUtil.N4 = 10; + + /** + * JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned + * -1, 0, and 1, I'm going to use less memory and go with bytes. + * + * @author dswitkin@google.com (Daniel Switkin) + */ + class ByteMatrix { + constructor(width /*int*/, height /*int*/) { + this.width = width; + this.height = height; + const bytes = new Array(height); // [height][width] + for (let i = 0; i !== height; i++) { + bytes[i] = new Uint8Array(width); + } + this.bytes = bytes; + } + getHeight() { + return this.height; + } + getWidth() { + return this.width; + } + get(x /*int*/, y /*int*/) { + return this.bytes[y][x]; + } + /** + * @return an internal representation as bytes, in row-major order. array[y][x] represents point (x,y) + */ + getArray() { + return this.bytes; + } + // TYPESCRIPTPORT: preffer to let two methods instead of override to avoid type comparison inside + setNumber(x /*int*/, y /*int*/, value /*byte|int*/) { + this.bytes[y][x] = value; + } + // public set(x: number /*int*/, y: number /*int*/, value: number /*int*/): void { + // bytes[y][x] = (byte) value + // } + setBoolean(x /*int*/, y /*int*/, value) { + this.bytes[y][x] = /*(byte) */ (value ? 1 : 0); + } + clear(value /*byte*/) { + for (const aByte of this.bytes) { + Arrays.fill(aByte, value); + } + } + equals(o) { + if (!(o instanceof ByteMatrix)) { + return false; + } + const other = o; + if (this.width !== other.width) { + return false; + } + if (this.height !== other.height) { + return false; + } + for (let y = 0, height = this.height; y < height; ++y) { + const bytesY = this.bytes[y]; + const otherBytesY = other.bytes[y]; + for (let x = 0, width = this.width; x < width; ++x) { + if (bytesY[x] !== otherBytesY[x]) { + return false; + } + } + } + return true; + } + /*@Override*/ + toString() { + const result = new StringBuilder(); // (2 * width * height + 2) + for (let y = 0, height = this.height; y < height; ++y) { + const bytesY = this.bytes[y]; + for (let x = 0, width = this.width; x < width; ++x) { + switch (bytesY[x]) { + case 0: + result.append(' 0'); + break; + case 1: + result.append(' 1'); + break; + default: + result.append(' '); + break; + } + } + result.append('\n'); + } + return result.toString(); + } + } + + /** + * @author satorux@google.com (Satoru Takabayashi) - creator + * @author dswitkin@google.com (Daniel Switkin) - ported from C++ + */ + class QRCode { + constructor() { + this.maskPattern = -1; + } + getMode() { + return this.mode; + } + getECLevel() { + return this.ecLevel; + } + getVersion() { + return this.version; + } + getMaskPattern() { + return this.maskPattern; + } + getMatrix() { + return this.matrix; + } + /*@Override*/ + toString() { + const result = new StringBuilder(); // (200) + result.append('<<\n'); + result.append(' mode: '); + result.append(this.mode ? this.mode.toString() : 'null'); + result.append('\n ecLevel: '); + result.append(this.ecLevel ? this.ecLevel.toString() : 'null'); + result.append('\n version: '); + result.append(this.version ? this.version.toString() : 'null'); + result.append('\n maskPattern: '); + result.append(this.maskPattern.toString()); + if (this.matrix) { + result.append('\n matrix:\n'); + result.append(this.matrix.toString()); + } + else { + result.append('\n matrix: null\n'); + } + result.append('>>\n'); + return result.toString(); + } + setMode(value) { + this.mode = value; + } + setECLevel(value) { + this.ecLevel = value; + } + setVersion(version) { + this.version = version; + } + setMaskPattern(value /*int*/) { + this.maskPattern = value; + } + setMatrix(value) { + this.matrix = value; + } + // Check if "mask_pattern" is valid. + static isValidMaskPattern(maskPattern /*int*/) { + return maskPattern >= 0 && maskPattern < QRCode.NUM_MASK_PATTERNS; + } + } + QRCode.NUM_MASK_PATTERNS = 8; + + /** + * Custom Error class of type Exception. + */ + class WriterException extends Exception { + } + WriterException.kind = 'WriterException'; + + /** + * @author satorux@google.com (Satoru Takabayashi) - creator + * @author dswitkin@google.com (Daniel Switkin) - ported from C++ + */ + class MatrixUtil { + constructor() { + // do nothing + } + // Set all cells to -1 (TYPESCRIPTPORT: 255). -1 (TYPESCRIPTPORT: 255) means that the cell is empty (not set yet). + // + // JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding + // with the ByteMatrix initialized all to zero. + static clearMatrix(matrix) { + // TYPESCRIPTPORT: we use UintArray se changed here from -1 to 255 + matrix.clear(/*(byte) */ /*-1*/ 255); + } + // Build 2D matrix of QR Code from "dataBits" with "ecLevel", "version" and "getMaskPattern". On + // success, store the result in "matrix" and return true. + static buildMatrix(dataBits, ecLevel, version, maskPattern /*int*/, matrix) { + MatrixUtil.clearMatrix(matrix); + MatrixUtil.embedBasicPatterns(version, matrix); + // Type information appear with any version. + MatrixUtil.embedTypeInfo(ecLevel, maskPattern, matrix); + // Version info appear if version >= 7. + MatrixUtil.maybeEmbedVersionInfo(version, matrix); + // Data should be embedded at end. + MatrixUtil.embedDataBits(dataBits, maskPattern, matrix); + } + // Embed basic patterns. On success, modify the matrix and return true. + // The basic patterns are: + // - Position detection patterns + // - Timing patterns + // - Dark dot at the left bottom corner + // - Position adjustment patterns, if need be + static embedBasicPatterns(version, matrix) { + // Let's get started with embedding big squares at corners. + MatrixUtil.embedPositionDetectionPatternsAndSeparators(matrix); + // Then, embed the dark dot at the left bottom corner. + MatrixUtil.embedDarkDotAtLeftBottomCorner(matrix); + // Position adjustment patterns appear if version >= 2. + MatrixUtil.maybeEmbedPositionAdjustmentPatterns(version, matrix); + // Timing patterns should be embedded after position adj. patterns. + MatrixUtil.embedTimingPatterns(matrix); + } + // Embed type information. On success, modify the matrix. + static embedTypeInfo(ecLevel, maskPattern /*int*/, matrix) { + const typeInfoBits = new BitArray(); + MatrixUtil.makeTypeInfoBits(ecLevel, maskPattern, typeInfoBits); + for (let i = 0, size = typeInfoBits.getSize(); i < size; ++i) { + // Place bits in LSB to MSB order. LSB (least significant bit) is the last value in + // "typeInfoBits". + const bit = typeInfoBits.get(typeInfoBits.getSize() - 1 - i); + // Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46). + const coordinates = MatrixUtil.TYPE_INFO_COORDINATES[i]; + const x1 = coordinates[0]; + const y1 = coordinates[1]; + matrix.setBoolean(x1, y1, bit); + if (i < 8) { + // Right top corner. + const x2 = matrix.getWidth() - i - 1; + const y2 = 8; + matrix.setBoolean(x2, y2, bit); + } + else { + // Left bottom corner. + const x2 = 8; + const y2 = matrix.getHeight() - 7 + (i - 8); + matrix.setBoolean(x2, y2, bit); + } + } + } + // Embed version information if need be. On success, modify the matrix and return true. + // See 8.10 of JISX0510:2004 (p.47) for how to embed version information. + static maybeEmbedVersionInfo(version, matrix) { + if (version.getVersionNumber() < 7) { // Version info is necessary if version >= 7. + return; // Don't need version info. + } + const versionInfoBits = new BitArray(); + MatrixUtil.makeVersionInfoBits(version, versionInfoBits); + let bitIndex = 6 * 3 - 1; // It will decrease from 17 to 0. + for (let i = 0; i < 6; ++i) { + for (let j = 0; j < 3; ++j) { + // Place bits in LSB (least significant bit) to MSB order. + const bit = versionInfoBits.get(bitIndex); + bitIndex--; + // Left bottom corner. + matrix.setBoolean(i, matrix.getHeight() - 11 + j, bit); + // Right bottom corner. + matrix.setBoolean(matrix.getHeight() - 11 + j, i, bit); + } + } + } + // Embed "dataBits" using "getMaskPattern". On success, modify the matrix and return true. + // For debugging purposes, it skips masking process if "getMaskPattern" is -1(TYPESCRIPTPORT: 255). + // See 8.7 of JISX0510:2004 (p.38) for how to embed data bits. + static embedDataBits(dataBits, maskPattern /*int*/, matrix) { + let bitIndex = 0; + let direction = -1; + // Start from the right bottom cell. + let x = matrix.getWidth() - 1; + let y = matrix.getHeight() - 1; + while (x > 0) { + // Skip the vertical timing pattern. + if (x === 6) { + x -= 1; + } + while (y >= 0 && y < matrix.getHeight()) { + for (let i = 0; i < 2; ++i) { + const xx = x - i; + // Skip the cell if it's not empty. + if (!MatrixUtil.isEmpty(matrix.get(xx, y))) { + continue; + } + let bit; + if (bitIndex < dataBits.getSize()) { + bit = dataBits.get(bitIndex); + ++bitIndex; + } + else { + // Padding bit. If there is no bit left, we'll fill the left cells with 0, as described + // in 8.4.9 of JISX0510:2004 (p. 24). + bit = false; + } + // Skip masking if mask_pattern is -1 (TYPESCRIPTPORT: 255). + if (maskPattern !== 255 && MaskUtil.getDataMaskBit(maskPattern, xx, y)) { + bit = !bit; + } + matrix.setBoolean(xx, y, bit); + } + y += direction; + } + direction = -direction; // Reverse the direction. + y += direction; + x -= 2; // Move to the left. + } + // All bits should be consumed. + if (bitIndex !== dataBits.getSize()) { + throw new WriterException('Not all bits consumed: ' + bitIndex + '/' + dataBits.getSize()); + } + } + // Return the position of the most significant bit set (one: to) in the "value". The most + // significant bit is position 32. If there is no bit set, return 0. Examples: + // - findMSBSet(0) => 0 + // - findMSBSet(1) => 1 + // - findMSBSet(255) => 8 + static findMSBSet(value /*int*/) { + return 32 - Integer.numberOfLeadingZeros(value); + } + // Calculate BCH (Bose-Chaudhuri-Hocquenghem) code for "value" using polynomial "poly". The BCH + // code is used for encoding type information and version information. + // Example: Calculation of version information of 7. + // f(x) is created from 7. + // - 7 = 000111 in 6 bits + // - f(x) = x^2 + x^1 + x^0 + // g(x) is given by the standard (p. 67) + // - g(x) = x^12 + x^11 + x^10 + x^9 + x^8 + x^5 + x^2 + 1 + // Multiply f(x) by x^(18 - 6) + // - f'(x) = f(x) * x^(18 - 6) + // - f'(x) = x^14 + x^13 + x^12 + // Calculate the remainder of f'(x) / g(x) + // x^2 + // __________________________________________________ + // g(x) )x^14 + x^13 + x^12 + // x^14 + x^13 + x^12 + x^11 + x^10 + x^7 + x^4 + x^2 + // -------------------------------------------------- + // x^11 + x^10 + x^7 + x^4 + x^2 + // + // The remainder is x^11 + x^10 + x^7 + x^4 + x^2 + // Encode it in binary: 110010010100 + // The return value is 0xc94 (1100 1001 0100) + // + // Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit + // operations. We don't care if coefficients are positive or negative. + static calculateBCHCode(value /*int*/, poly /*int*/) { + if (poly === 0) { + throw new IllegalArgumentException('0 polynomial'); + } + // If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1 + // from 13 to make it 12. + const msbSetInPoly = MatrixUtil.findMSBSet(poly); + value <<= msbSetInPoly - 1; + // Do the division business using exclusive-or operations. + while (MatrixUtil.findMSBSet(value) >= msbSetInPoly) { + value ^= poly << (MatrixUtil.findMSBSet(value) - msbSetInPoly); + } + // Now the "value" is the remainder (i.e. the BCH code) + return value; + } + // Make bit vector of type information. On success, store the result in "bits" and return true. + // Encode error correction level and mask pattern. See 8.9 of + // JISX0510:2004 (p.45) for details. + static makeTypeInfoBits(ecLevel, maskPattern /*int*/, bits) { + if (!QRCode.isValidMaskPattern(maskPattern)) { + throw new WriterException('Invalid mask pattern'); + } + const typeInfo = (ecLevel.getBits() << 3) | maskPattern; + bits.appendBits(typeInfo, 5); + const bchCode = MatrixUtil.calculateBCHCode(typeInfo, MatrixUtil.TYPE_INFO_POLY); + bits.appendBits(bchCode, 10); + const maskBits = new BitArray(); + maskBits.appendBits(MatrixUtil.TYPE_INFO_MASK_PATTERN, 15); + bits.xor(maskBits); + if (bits.getSize() !== 15) { // Just in case. + throw new WriterException('should not happen but we got: ' + bits.getSize()); + } + } + // Make bit vector of version information. On success, store the result in "bits" and return true. + // See 8.10 of JISX0510:2004 (p.45) for details. + static makeVersionInfoBits(version, bits) { + bits.appendBits(version.getVersionNumber(), 6); + const bchCode = MatrixUtil.calculateBCHCode(version.getVersionNumber(), MatrixUtil.VERSION_INFO_POLY); + bits.appendBits(bchCode, 12); + if (bits.getSize() !== 18) { // Just in case. + throw new WriterException('should not happen but we got: ' + bits.getSize()); + } + } + // Check if "value" is empty. + static isEmpty(value /*int*/) { + return value === 255; // -1 + } + static embedTimingPatterns(matrix) { + // -8 is for skipping position detection patterns (7: size), and two horizontal/vertical + // separation patterns (1: size). Thus, 8 = 7 + 1. + for (let i = 8; i < matrix.getWidth() - 8; ++i) { + const bit = (i + 1) % 2; + // Horizontal line. + if (MatrixUtil.isEmpty(matrix.get(i, 6))) { + matrix.setNumber(i, 6, bit); + } + // Vertical line. + if (MatrixUtil.isEmpty(matrix.get(6, i))) { + matrix.setNumber(6, i, bit); + } + } + } + // Embed the lonely dark dot at left bottom corner. JISX0510:2004 (p.46) + static embedDarkDotAtLeftBottomCorner(matrix) { + if (matrix.get(8, matrix.getHeight() - 8) === 0) { + throw new WriterException(); + } + matrix.setNumber(8, matrix.getHeight() - 8, 1); + } + static embedHorizontalSeparationPattern(xStart /*int*/, yStart /*int*/, matrix) { + for (let x = 0; x < 8; ++x) { + if (!MatrixUtil.isEmpty(matrix.get(xStart + x, yStart))) { + throw new WriterException(); + } + matrix.setNumber(xStart + x, yStart, 0); + } + } + static embedVerticalSeparationPattern(xStart /*int*/, yStart /*int*/, matrix) { + for (let y = 0; y < 7; ++y) { + if (!MatrixUtil.isEmpty(matrix.get(xStart, yStart + y))) { + throw new WriterException(); + } + matrix.setNumber(xStart, yStart + y, 0); + } + } + static embedPositionAdjustmentPattern(xStart /*int*/, yStart /*int*/, matrix) { + for (let y = 0; y < 5; ++y) { + const patternY = MatrixUtil.POSITION_ADJUSTMENT_PATTERN[y]; + for (let x = 0; x < 5; ++x) { + matrix.setNumber(xStart + x, yStart + y, patternY[x]); + } + } + } + static embedPositionDetectionPattern(xStart /*int*/, yStart /*int*/, matrix) { + for (let y = 0; y < 7; ++y) { + const patternY = MatrixUtil.POSITION_DETECTION_PATTERN[y]; + for (let x = 0; x < 7; ++x) { + matrix.setNumber(xStart + x, yStart + y, patternY[x]); + } + } + } + // Embed position detection patterns and surrounding vertical/horizontal separators. + static embedPositionDetectionPatternsAndSeparators(matrix) { + // Embed three big squares at corners. + const pdpWidth = MatrixUtil.POSITION_DETECTION_PATTERN[0].length; + // Left top corner. + MatrixUtil.embedPositionDetectionPattern(0, 0, matrix); + // Right top corner. + MatrixUtil.embedPositionDetectionPattern(matrix.getWidth() - pdpWidth, 0, matrix); + // Left bottom corner. + MatrixUtil.embedPositionDetectionPattern(0, matrix.getWidth() - pdpWidth, matrix); + // Embed horizontal separation patterns around the squares. + const hspWidth = 8; + // Left top corner. + MatrixUtil.embedHorizontalSeparationPattern(0, hspWidth - 1, matrix); + // Right top corner. + MatrixUtil.embedHorizontalSeparationPattern(matrix.getWidth() - hspWidth, hspWidth - 1, matrix); + // Left bottom corner. + MatrixUtil.embedHorizontalSeparationPattern(0, matrix.getWidth() - hspWidth, matrix); + // Embed vertical separation patterns around the squares. + const vspSize = 7; + // Left top corner. + MatrixUtil.embedVerticalSeparationPattern(vspSize, 0, matrix); + // Right top corner. + MatrixUtil.embedVerticalSeparationPattern(matrix.getHeight() - vspSize - 1, 0, matrix); + // Left bottom corner. + MatrixUtil.embedVerticalSeparationPattern(vspSize, matrix.getHeight() - vspSize, matrix); + } + // Embed position adjustment patterns if need be. + static maybeEmbedPositionAdjustmentPatterns(version, matrix) { + if (version.getVersionNumber() < 2) { // The patterns appear if version >= 2 + return; + } + const index = version.getVersionNumber() - 1; + const coordinates = MatrixUtil.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index]; + for (let i = 0, length = coordinates.length; i !== length; i++) { + const y = coordinates[i]; + if (y >= 0) { + for (let j = 0; j !== length; j++) { + const x = coordinates[j]; + if (x >= 0 && MatrixUtil.isEmpty(matrix.get(x, y))) { + // If the cell is unset, we embed the position adjustment pattern here. + // -2 is necessary since the x/y coordinates point to the center of the pattern, not the + // left top corner. + MatrixUtil.embedPositionAdjustmentPattern(x - 2, y - 2, matrix); + } + } + } + } + } + } + MatrixUtil.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]), + ]); + MatrixUtil.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]), + ]); + // From Appendix E. Table 1, JIS0510X:2004 (71: p). The table was double-checked by komatsu. + MatrixUtil.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]), + ]); + // Type info cells at the left top corner. + MatrixUtil.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]), + ]); + // From Appendix D in JISX0510:2004 (p. 67) + MatrixUtil.VERSION_INFO_POLY = 0x1f25; // 1 1111 0010 0101 + // From Appendix C in JISX0510:2004 (p.65). + MatrixUtil.TYPE_INFO_POLY = 0x537; + MatrixUtil.TYPE_INFO_MASK_PATTERN = 0x5412; + + /*namespace com.google.zxing.qrcode.encoder {*/ + class BlockPair { + constructor(dataBytes, errorCorrectionBytes) { + this.dataBytes = dataBytes; + this.errorCorrectionBytes = errorCorrectionBytes; + } + getDataBytes() { + return this.dataBytes; + } + getErrorCorrectionBytes() { + return this.errorCorrectionBytes; + } + } + + /*import java.io.UnsupportedEncodingException;*/ + /*import java.util.ArrayList;*/ + /*import java.util.Collection;*/ + /*import java.util.Map;*/ + /** + * @author satorux@google.com (Satoru Takabayashi) - creator + * @author dswitkin@google.com (Daniel Switkin) - ported from C++ + */ + class Encoder { + // TYPESCRIPTPORT: changed to UTF8, the default for js + constructor() { } + // The mask penalty calculation is complicated. See Table 21 of JISX0510:2004 (p.45) for details. + // Basically it applies four rules and summate all penalties. + static calculateMaskPenalty(matrix) { + return MaskUtil.applyMaskPenaltyRule1(matrix) + + MaskUtil.applyMaskPenaltyRule2(matrix) + + MaskUtil.applyMaskPenaltyRule3(matrix) + + MaskUtil.applyMaskPenaltyRule4(matrix); + } + /** + * @param content text to encode + * @param ecLevel error correction level to use + * @return {@link QRCode} representing the encoded QR code + * @throws WriterException if encoding can't succeed, because of for example invalid content + * or configuration + */ + // public static encode(content: string, ecLevel: ErrorCorrectionLevel): QRCode /*throws WriterException*/ { + // return encode(content, ecLevel, null) + // } + static encode(content, ecLevel, hints = null) { + // Determine what character encoding has been specified by the caller, if any + let encoding = Encoder.DEFAULT_BYTE_MODE_ENCODING; + const hasEncodingHint = hints !== null && undefined !== hints.get(EncodeHintType$1.CHARACTER_SET); + if (hasEncodingHint) { + encoding = hints.get(EncodeHintType$1.CHARACTER_SET).toString(); + } + // Pick an encoding mode appropriate for the content. Note that this will not attempt to use + // multiple modes / segments even if that were more efficient. Twould be nice. + const mode = this.chooseMode(content, encoding); + // This will store the header information, like mode and + // length, as well as "header" segments like an ECI segment. + const headerBits = new BitArray(); + // Append ECI segment if applicable + if (mode === Mode$1.BYTE && (hasEncodingHint || Encoder.DEFAULT_BYTE_MODE_ENCODING !== encoding)) { + const eci = CharacterSetECI.getCharacterSetECIByName(encoding); + if (eci !== undefined) { + this.appendECI(eci, headerBits); + } + } + // (With ECI in place,) Write the mode marker + this.appendModeInfo(mode, headerBits); + // Collect data within the main segment, separately, to count its size if needed. Don't add it to + // main payload yet. + const dataBits = new BitArray(); + this.appendBytes(content, mode, dataBits, encoding); + let version; + if (hints !== null && undefined !== hints.get(EncodeHintType$1.QR_VERSION)) { + const versionNumber = Number.parseInt(hints.get(EncodeHintType$1.QR_VERSION).toString(), 10); + version = Version$1.getVersionForNumber(versionNumber); + const bitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, version); + if (!this.willFit(bitsNeeded, version, ecLevel)) { + throw new WriterException('Data too big for requested version'); + } + } + else { + version = this.recommendVersion(ecLevel, mode, headerBits, dataBits); + } + const headerAndDataBits = new BitArray(); + headerAndDataBits.appendBitArray(headerBits); + // Find "length" of main segment and write it + const numLetters = mode === Mode$1.BYTE ? dataBits.getSizeInBytes() : content.length; + this.appendLengthInfo(numLetters, version, mode, headerAndDataBits); + // Put data together into the overall payload + headerAndDataBits.appendBitArray(dataBits); + const ecBlocks = version.getECBlocksForLevel(ecLevel); + const numDataBytes = version.getTotalCodewords() - ecBlocks.getTotalECCodewords(); + // Terminate the bits properly. + this.terminateBits(numDataBytes, headerAndDataBits); + // Interleave data bits with error correction code. + const finalBits = this.interleaveWithECBytes(headerAndDataBits, version.getTotalCodewords(), numDataBytes, ecBlocks.getNumBlocks()); + const qrCode = new QRCode(); + qrCode.setECLevel(ecLevel); + qrCode.setMode(mode); + qrCode.setVersion(version); + // Choose the mask pattern and set to "qrCode". + const dimension = version.getDimensionForVersion(); + const matrix = new ByteMatrix(dimension, dimension); + const maskPattern = this.chooseMaskPattern(finalBits, ecLevel, version, matrix); + qrCode.setMaskPattern(maskPattern); + // Build the matrix and set it to "qrCode". + MatrixUtil.buildMatrix(finalBits, ecLevel, version, maskPattern, matrix); + qrCode.setMatrix(matrix); + return qrCode; + } + /** + * Decides the smallest version of QR code that will contain all of the provided data. + * + * @throws WriterException if the data cannot fit in any version + */ + static recommendVersion(ecLevel, mode, headerBits, dataBits) { + // Hard part: need to know version to know how many bits length takes. But need to know how many + // bits it takes to know version. First we take a guess at version by assuming version will be + // the minimum, 1: + const provisionalBitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, Version$1.getVersionForNumber(1)); + const provisionalVersion = this.chooseVersion(provisionalBitsNeeded, ecLevel); + // Use that guess to calculate the right version. I am still not sure this works in 100% of cases. + const bitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, provisionalVersion); + return this.chooseVersion(bitsNeeded, ecLevel); + } + static calculateBitsNeeded(mode, headerBits, dataBits, version) { + return headerBits.getSize() + mode.getCharacterCountBits(version) + dataBits.getSize(); + } + /** + * @return the code point of the table used in alphanumeric mode or + * -1 if there is no corresponding code in the table. + */ + static getAlphanumericCode(code /*int*/) { + if (code < Encoder.ALPHANUMERIC_TABLE.length) { + return Encoder.ALPHANUMERIC_TABLE[code]; + } + return -1; + } + // public static chooseMode(content: string): Mode { + // return chooseMode(content, null); + // } + /** + * Choose the best mode by examining the content. Note that 'encoding' is used as a hint; + * if it is Shift_JIS, and the input is only double-byte Kanji, then we return {@link Mode#KANJI}. + */ + static chooseMode(content, encoding = null) { + if (CharacterSetECI.SJIS.getName() === encoding && this.isOnlyDoubleByteKanji(content)) { + // Choose Kanji mode if all input are double-byte characters + return Mode$1.KANJI; + } + let hasNumeric = false; + let hasAlphanumeric = false; + for (let i = 0, length = content.length; i < length; ++i) { + const c = content.charAt(i); + if (Encoder.isDigit(c)) { + hasNumeric = true; + } + else if (this.getAlphanumericCode(c.charCodeAt(0)) !== -1) { + hasAlphanumeric = true; + } + else { + return Mode$1.BYTE; + } + } + if (hasAlphanumeric) { + return Mode$1.ALPHANUMERIC; + } + if (hasNumeric) { + return Mode$1.NUMERIC; + } + return Mode$1.BYTE; + } + static isOnlyDoubleByteKanji(content) { + let bytes; + try { + bytes = StringEncoding.encode(content, CharacterSetECI.SJIS); // content.getBytes("Shift_JIS")) + } + catch (ignored /*: UnsupportedEncodingException*/) { + return false; + } + const length = bytes.length; + if (length % 2 !== 0) { + return false; + } + for (let i = 0; i < length; i += 2) { + const byte1 = bytes[i] & 0xFF; + if ((byte1 < 0x81 || byte1 > 0x9F) && (byte1 < 0xE0 || byte1 > 0xEB)) { + return false; + } + } + return true; + } + static chooseMaskPattern(bits, ecLevel, version, matrix) { + let minPenalty = Number.MAX_SAFE_INTEGER; // Lower penalty is better. + let bestMaskPattern = -1; + // We try all mask patterns to choose the best one. + for (let maskPattern = 0; maskPattern < QRCode.NUM_MASK_PATTERNS; maskPattern++) { + MatrixUtil.buildMatrix(bits, ecLevel, version, maskPattern, matrix); + let penalty = this.calculateMaskPenalty(matrix); + if (penalty < minPenalty) { + minPenalty = penalty; + bestMaskPattern = maskPattern; + } + } + return bestMaskPattern; + } + static chooseVersion(numInputBits /*int*/, ecLevel) { + for (let versionNum = 1; versionNum <= 40; versionNum++) { + const version = Version$1.getVersionForNumber(versionNum); + if (Encoder.willFit(numInputBits, version, ecLevel)) { + return version; + } + } + throw new WriterException('Data too big'); + } + /** + * @return true if the number of input bits will fit in a code with the specified version and + * error correction level. + */ + static willFit(numInputBits /*int*/, version, ecLevel) { + // In the following comments, we use numbers of Version 7-H. + // numBytes = 196 + const numBytes = version.getTotalCodewords(); + // getNumECBytes = 130 + const ecBlocks = version.getECBlocksForLevel(ecLevel); + const numEcBytes = ecBlocks.getTotalECCodewords(); + // getNumDataBytes = 196 - 130 = 66 + const numDataBytes = numBytes - numEcBytes; + const totalInputBytes = (numInputBits + 7) / 8; + return numDataBytes >= totalInputBytes; + } + /** + * Terminate bits as described in 8.4.8 and 8.4.9 of JISX0510:2004 (p.24). + */ + static terminateBits(numDataBytes /*int*/, bits) { + const capacity = numDataBytes * 8; + if (bits.getSize() > capacity) { + throw new WriterException('data bits cannot fit in the QR Code' + bits.getSize() + ' > ' + + capacity); + } + for (let i = 0; i < 4 && bits.getSize() < capacity; ++i) { + bits.appendBit(false); + } + // Append termination bits. See 8.4.8 of JISX0510:2004 (p.24) for details. + // If the last byte isn't 8-bit aligned, we'll add padding bits. + const numBitsInLastByte = bits.getSize() & 0x07; + if (numBitsInLastByte > 0) { + for (let i = numBitsInLastByte; i < 8; i++) { + bits.appendBit(false); + } + } + // If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24). + const numPaddingBytes = numDataBytes - bits.getSizeInBytes(); + for (let i = 0; i < numPaddingBytes; ++i) { + bits.appendBits((i & 0x01) === 0 ? 0xEC : 0x11, 8); + } + if (bits.getSize() !== capacity) { + throw new WriterException('Bits size does not equal capacity'); + } + } + /** + * Get number of data bytes and number of error correction bytes for block id "blockID". Store + * the result in "numDataBytesInBlock", and "numECBytesInBlock". See table 12 in 8.5.1 of + * JISX0510:2004 (p.30) + */ + static getNumDataBytesAndNumECBytesForBlockID(numTotalBytes /*int*/, numDataBytes /*int*/, numRSBlocks /*int*/, blockID /*int*/, numDataBytesInBlock, numECBytesInBlock) { + if (blockID >= numRSBlocks) { + throw new WriterException('Block ID too large'); + } + // numRsBlocksInGroup2 = 196 % 5 = 1 + const numRsBlocksInGroup2 = numTotalBytes % numRSBlocks; + // numRsBlocksInGroup1 = 5 - 1 = 4 + const numRsBlocksInGroup1 = numRSBlocks - numRsBlocksInGroup2; + // numTotalBytesInGroup1 = 196 / 5 = 39 + const numTotalBytesInGroup1 = Math.floor(numTotalBytes / numRSBlocks); + // numTotalBytesInGroup2 = 39 + 1 = 40 + const numTotalBytesInGroup2 = numTotalBytesInGroup1 + 1; + // numDataBytesInGroup1 = 66 / 5 = 13 + const numDataBytesInGroup1 = Math.floor(numDataBytes / numRSBlocks); + // numDataBytesInGroup2 = 13 + 1 = 14 + const numDataBytesInGroup2 = numDataBytesInGroup1 + 1; + // numEcBytesInGroup1 = 39 - 13 = 26 + const numEcBytesInGroup1 = numTotalBytesInGroup1 - numDataBytesInGroup1; + // numEcBytesInGroup2 = 40 - 14 = 26 + const numEcBytesInGroup2 = numTotalBytesInGroup2 - numDataBytesInGroup2; + // Sanity checks. + // 26 = 26 + if (numEcBytesInGroup1 !== numEcBytesInGroup2) { + throw new WriterException('EC bytes mismatch'); + } + // 5 = 4 + 1. + if (numRSBlocks !== numRsBlocksInGroup1 + numRsBlocksInGroup2) { + throw new WriterException('RS blocks mismatch'); + } + // 196 = (13 + 26) * 4 + (14 + 26) * 1 + if (numTotalBytes !== + ((numDataBytesInGroup1 + numEcBytesInGroup1) * + numRsBlocksInGroup1) + + ((numDataBytesInGroup2 + numEcBytesInGroup2) * + numRsBlocksInGroup2)) { + throw new WriterException('Total bytes mismatch'); + } + if (blockID < numRsBlocksInGroup1) { + numDataBytesInBlock[0] = numDataBytesInGroup1; + numECBytesInBlock[0] = numEcBytesInGroup1; + } + else { + numDataBytesInBlock[0] = numDataBytesInGroup2; + numECBytesInBlock[0] = numEcBytesInGroup2; + } + } + /** + * Interleave "bits" with corresponding error correction bytes. On success, store the result in + * "result". The interleave rule is complicated. See 8.6 of JISX0510:2004 (p.37) for details. + */ + static interleaveWithECBytes(bits, numTotalBytes /*int*/, numDataBytes /*int*/, numRSBlocks /*int*/) { + // "bits" must have "getNumDataBytes" bytes of data. + if (bits.getSizeInBytes() !== numDataBytes) { + throw new WriterException('Number of bits and data bytes does not match'); + } + // Step 1. Divide data bytes into blocks and generate error correction bytes for them. We'll + // store the divided data bytes blocks and error correction bytes blocks into "blocks". + let dataBytesOffset = 0; + let maxNumDataBytes = 0; + let maxNumEcBytes = 0; + // Since, we know the number of reedsolmon blocks, we can initialize the vector with the number. + const blocks = new Array(); // new Array<BlockPair>(numRSBlocks) + for (let i = 0; i < numRSBlocks; ++i) { + const numDataBytesInBlock = new Int32Array(1); + const numEcBytesInBlock = new Int32Array(1); + Encoder.getNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes, numRSBlocks, i, numDataBytesInBlock, numEcBytesInBlock); + const size = numDataBytesInBlock[0]; + const dataBytes = new Uint8Array(size); + bits.toBytes(8 * dataBytesOffset, dataBytes, 0, size); + const ecBytes = Encoder.generateECBytes(dataBytes, numEcBytesInBlock[0]); + blocks.push(new BlockPair(dataBytes, ecBytes)); + maxNumDataBytes = Math.max(maxNumDataBytes, size); + maxNumEcBytes = Math.max(maxNumEcBytes, ecBytes.length); + dataBytesOffset += numDataBytesInBlock[0]; + } + if (numDataBytes !== dataBytesOffset) { + throw new WriterException('Data bytes does not match offset'); + } + const result = new BitArray(); + // First, place data blocks. + for (let i = 0; i < maxNumDataBytes; ++i) { + for (const block of blocks) { + const dataBytes = block.getDataBytes(); + if (i < dataBytes.length) { + result.appendBits(dataBytes[i], 8); + } + } + } + // Then, place error correction blocks. + for (let i = 0; i < maxNumEcBytes; ++i) { + for (const block of blocks) { + const ecBytes = block.getErrorCorrectionBytes(); + if (i < ecBytes.length) { + result.appendBits(ecBytes[i], 8); + } + } + } + if (numTotalBytes !== result.getSizeInBytes()) { // Should be same. + throw new WriterException('Interleaving error: ' + numTotalBytes + ' and ' + + result.getSizeInBytes() + ' differ.'); + } + return result; + } + static generateECBytes(dataBytes, numEcBytesInBlock /*int*/) { + const numDataBytes = dataBytes.length; + const toEncode = new Int32Array(numDataBytes + numEcBytesInBlock); // int[numDataBytes + numEcBytesInBlock] + for (let i = 0; i < numDataBytes; i++) { + toEncode[i] = dataBytes[i] & 0xFF; + } + new ReedSolomonEncoder(GenericGF.QR_CODE_FIELD_256).encode(toEncode, numEcBytesInBlock); + const ecBytes = new Uint8Array(numEcBytesInBlock); + for (let i = 0; i < numEcBytesInBlock; i++) { + ecBytes[i] = /*(byte) */ toEncode[numDataBytes + i]; + } + return ecBytes; + } + /** + * Append mode info. On success, store the result in "bits". + */ + static appendModeInfo(mode, bits) { + bits.appendBits(mode.getBits(), 4); + } + /** + * Append length info. On success, store the result in "bits". + */ + static appendLengthInfo(numLetters /*int*/, version, mode, bits) { + const numBits = mode.getCharacterCountBits(version); + if (numLetters >= (1 << numBits)) { + throw new WriterException(numLetters + ' is bigger than ' + ((1 << numBits) - 1)); + } + bits.appendBits(numLetters, numBits); + } + /** + * Append "bytes" in "mode" mode (encoding) into "bits". On success, store the result in "bits". + */ + static appendBytes(content, mode, bits, encoding) { + switch (mode) { + case Mode$1.NUMERIC: + Encoder.appendNumericBytes(content, bits); + break; + case Mode$1.ALPHANUMERIC: + Encoder.appendAlphanumericBytes(content, bits); + break; + case Mode$1.BYTE: + Encoder.append8BitBytes(content, bits, encoding); + break; + case Mode$1.KANJI: + Encoder.appendKanjiBytes(content, bits); + break; + default: + throw new WriterException('Invalid mode: ' + mode); + } + } + static getDigit(singleCharacter) { + return singleCharacter.charCodeAt(0) - 48; + } + static isDigit(singleCharacter) { + const cn = Encoder.getDigit(singleCharacter); + return cn >= 0 && cn <= 9; + } + static appendNumericBytes(content, bits) { + const length = content.length; + let i = 0; + while (i < length) { + const num1 = Encoder.getDigit(content.charAt(i)); + if (i + 2 < length) { + // Encode three numeric letters in ten bits. + const num2 = Encoder.getDigit(content.charAt(i + 1)); + const num3 = Encoder.getDigit(content.charAt(i + 2)); + bits.appendBits(num1 * 100 + num2 * 10 + num3, 10); + i += 3; + } + else if (i + 1 < length) { + // Encode two numeric letters in seven bits. + const num2 = Encoder.getDigit(content.charAt(i + 1)); + bits.appendBits(num1 * 10 + num2, 7); + i += 2; + } + else { + // Encode one numeric letter in four bits. + bits.appendBits(num1, 4); + i++; + } + } + } + static appendAlphanumericBytes(content, bits) { + const length = content.length; + let i = 0; + while (i < length) { + const code1 = Encoder.getAlphanumericCode(content.charCodeAt(i)); + if (code1 === -1) { + throw new WriterException(); + } + if (i + 1 < length) { + const code2 = Encoder.getAlphanumericCode(content.charCodeAt(i + 1)); + if (code2 === -1) { + throw new WriterException(); + } + // Encode two alphanumeric letters in 11 bits. + bits.appendBits(code1 * 45 + code2, 11); + i += 2; + } + else { + // Encode one alphanumeric letter in six bits. + bits.appendBits(code1, 6); + i++; + } + } + } + static append8BitBytes(content, bits, encoding) { + let bytes; + try { + bytes = StringEncoding.encode(content, encoding); + } + catch (uee /*: UnsupportedEncodingException*/) { + throw new WriterException(uee); + } + for (let i = 0, length = bytes.length; i !== length; i++) { + const b = bytes[i]; + bits.appendBits(b, 8); + } + } + /** + * @throws WriterException + */ + static appendKanjiBytes(content, bits) { + let bytes; + try { + bytes = StringEncoding.encode(content, CharacterSetECI.SJIS); + } + catch (uee /*: UnsupportedEncodingException*/) { + throw new WriterException(uee); + } + const length = bytes.length; + for (let i = 0; i < length; i += 2) { + const byte1 = bytes[i] & 0xFF; + const byte2 = bytes[i + 1] & 0xFF; + const code = ((byte1 << 8) & 0xFFFFFFFF) | byte2; + let subtracted = -1; + if (code >= 0x8140 && code <= 0x9ffc) { + subtracted = code - 0x8140; + } + else if (code >= 0xe040 && code <= 0xebbf) { + subtracted = code - 0xc140; + } + if (subtracted === -1) { + throw new WriterException('Invalid byte sequence'); + } + const encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff); + bits.appendBits(encoded, 13); + } + } + static appendECI(eci, bits) { + bits.appendBits(Mode$1.ECI.getBits(), 4); + // This is correct for values up to 127, which is all we need now. + bits.appendBits(eci.getValue(), 8); + } + } + // The original table is defined in the table 5 of JISX0510:2004 (p.19). + Encoder.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, + ]); + Encoder.DEFAULT_BYTE_MODE_ENCODING = CharacterSetECI.UTF8.getName(); // "ISO-8859-1" + + /** + * @deprecated Moving to @zxing/browser + */ + class BrowserQRCodeSvgWriter { + /** + * Writes and renders a QRCode SVG element. + * + * @param contents + * @param width + * @param height + * @param hints + */ + write(contents, width, height, hints = null) { + if (contents.length === 0) { + throw new IllegalArgumentException('Found empty contents'); + } + // if (format != BarcodeFormat.QR_CODE) { + // throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format) + // } + if (width < 0 || height < 0) { + throw new IllegalArgumentException('Requested dimensions are too small: ' + width + 'x' + height); + } + let errorCorrectionLevel = ErrorCorrectionLevel.L; + let quietZone = BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE; + if (hints !== null) { + if (undefined !== hints.get(EncodeHintType$1.ERROR_CORRECTION)) { + errorCorrectionLevel = ErrorCorrectionLevel.fromString(hints.get(EncodeHintType$1.ERROR_CORRECTION).toString()); + } + if (undefined !== hints.get(EncodeHintType$1.MARGIN)) { + quietZone = Number.parseInt(hints.get(EncodeHintType$1.MARGIN).toString(), 10); + } + } + const code = Encoder.encode(contents, errorCorrectionLevel, hints); + return this.renderResult(code, width, height, quietZone); + } + /** + * Renders the result and then appends it to the DOM. + */ + writeToDom(containerElement, contents, width, height, hints = null) { + if (typeof containerElement === 'string') { + containerElement = document.querySelector(containerElement); + } + const svgElement = this.write(contents, width, height, hints); + if (containerElement) + containerElement.appendChild(svgElement); + } + /** + * Note that the input matrix uses 0 == white, 1 == black. + * The output matrix uses 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap). + */ + renderResult(code, width /*int*/, height /*int*/, quietZone /*int*/) { + const input = code.getMatrix(); + if (input === null) { + throw new IllegalStateException(); + } + const inputWidth = input.getWidth(); + const inputHeight = input.getHeight(); + const qrWidth = inputWidth + (quietZone * 2); + const qrHeight = inputHeight + (quietZone * 2); + const outputWidth = Math.max(width, qrWidth); + const outputHeight = Math.max(height, qrHeight); + const multiple = Math.min(Math.floor(outputWidth / qrWidth), Math.floor(outputHeight / qrHeight)); + // Padding includes both the quiet zone and the extra white pixels to accommodate the requested + // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone. + // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will + // handle all the padding from 100x100 (the actual QR) up to 200x160. + const leftPadding = Math.floor((outputWidth - (inputWidth * multiple)) / 2); + const topPadding = Math.floor((outputHeight - (inputHeight * multiple)) / 2); + const svgElement = this.createSVGElement(outputWidth, outputHeight); + for (let inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) { + // Write the contents of this row of the barcode + for (let inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) { + if (input.get(inputX, inputY) === 1) { + const svgRectElement = this.createSvgRectElement(outputX, outputY, multiple, multiple); + svgElement.appendChild(svgRectElement); + } + } + } + return svgElement; + } + /** + * Creates a SVG element. + * + * @param w SVG's width attribute + * @param h SVG's height attribute + */ + createSVGElement(w, h) { + const svgElement = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'svg'); + svgElement.setAttributeNS(null, 'height', w.toString()); + svgElement.setAttributeNS(null, 'width', h.toString()); + return svgElement; + } + /** + * Creates a SVG rect element. + * + * @param x Element's x coordinate + * @param y Element's y coordinate + * @param w Element's width attribute + * @param h Element's height attribute + */ + createSvgRectElement(x, y, w, h) { + const rect = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'rect'); + rect.setAttributeNS(null, 'x', x.toString()); + rect.setAttributeNS(null, 'y', y.toString()); + rect.setAttributeNS(null, 'height', w.toString()); + rect.setAttributeNS(null, 'width', h.toString()); + rect.setAttributeNS(null, 'fill', '#000000'); + return rect; + } + } + BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE = 4; + /** + * SVG markup NameSpace + */ + BrowserQRCodeSvgWriter.SVG_NS = 'http://www.w3.org/2000/svg'; + + /*import java.util.Map;*/ + /** + * This object renders a QR Code as a BitMatrix 2D array of greyscale values. + * + * @author dswitkin@google.com (Daniel Switkin) + */ + class QRCodeWriter { + /*@Override*/ + // public encode(contents: string, format: BarcodeFormat, width: number /*int*/, height: number /*int*/): BitMatrix + // /*throws WriterException */ { + // return encode(contents, format, width, height, null) + // } + /*@Override*/ + encode(contents, format, width /*int*/, height /*int*/, hints) { + if (contents.length === 0) { + throw new IllegalArgumentException('Found empty contents'); + } + if (format !== BarcodeFormat$1.QR_CODE) { + throw new IllegalArgumentException('Can only encode QR_CODE, but got ' + format); + } + if (width < 0 || height < 0) { + throw new IllegalArgumentException(`Requested dimensions are too small: ${width}x${height}`); + } + let errorCorrectionLevel = ErrorCorrectionLevel.L; + let quietZone = QRCodeWriter.QUIET_ZONE_SIZE; + if (hints !== null) { + if (undefined !== hints.get(EncodeHintType$1.ERROR_CORRECTION)) { + errorCorrectionLevel = ErrorCorrectionLevel.fromString(hints.get(EncodeHintType$1.ERROR_CORRECTION).toString()); + } + if (undefined !== hints.get(EncodeHintType$1.MARGIN)) { + quietZone = Number.parseInt(hints.get(EncodeHintType$1.MARGIN).toString(), 10); + } + } + const code = Encoder.encode(contents, errorCorrectionLevel, hints); + return QRCodeWriter.renderResult(code, width, height, quietZone); + } + // Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses + // 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap). + static renderResult(code, width /*int*/, height /*int*/, quietZone /*int*/) { + const input = code.getMatrix(); + if (input === null) { + throw new IllegalStateException(); + } + const inputWidth = input.getWidth(); + const inputHeight = input.getHeight(); + const qrWidth = inputWidth + (quietZone * 2); + const qrHeight = inputHeight + (quietZone * 2); + const outputWidth = Math.max(width, qrWidth); + const outputHeight = Math.max(height, qrHeight); + const multiple = Math.min(Math.floor(outputWidth / qrWidth), Math.floor(outputHeight / qrHeight)); + // Padding includes both the quiet zone and the extra white pixels to accommodate the requested + // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone. + // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will + // handle all the padding from 100x100 (the actual QR) up to 200x160. + const leftPadding = Math.floor((outputWidth - (inputWidth * multiple)) / 2); + const topPadding = Math.floor((outputHeight - (inputHeight * multiple)) / 2); + const output = new BitMatrix(outputWidth, outputHeight); + for (let inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) { + // Write the contents of this row of the barcode + for (let inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) { + if (input.get(inputX, inputY) === 1) { + output.setRegion(outputX, outputY, multiple, multiple); + } + } + } + return output; + } + } + QRCodeWriter.QUIET_ZONE_SIZE = 4; + + /*import java.util.Map;*/ + /** + * This is a factory class which finds the appropriate Writer subclass for the BarcodeFormat + * requested and encodes the barcode with the supplied contents. + * + * @author dswitkin@google.com (Daniel Switkin) + */ + class MultiFormatWriter { + /*@Override*/ + // public encode(contents: string, + // format: BarcodeFormat, + // width: number /*int*/, + // height: number /*int*/): BitMatrix /*throws WriterException */ { + // return encode(contents, format, width, height, null) + // } + /*@Override*/ + encode(contents, format, width /*int*/, height /*int*/, hints) { + let writer; + switch (format) { + // case BarcodeFormat.EAN_8: + // writer = new EAN8Writer() + // break + // case BarcodeFormat.UPC_E: + // writer = new UPCEWriter() + // break + // case BarcodeFormat.EAN_13: + // writer = new EAN13Writer() + // break + // case BarcodeFormat.UPC_A: + // writer = new UPCAWriter() + // break + case BarcodeFormat$1.QR_CODE: + writer = new QRCodeWriter(); + break; + // case BarcodeFormat.CODE_39: + // writer = new Code39Writer() + // break + // case BarcodeFormat.CODE_93: + // writer = new Code93Writer() + // break + // case BarcodeFormat.CODE_128: + // writer = new Code128Writer() + // break + // case BarcodeFormat.ITF: + // writer = new ITFWriter() + // break + // case BarcodeFormat.PDF_417: + // writer = new PDF417Writer() + // break + // case BarcodeFormat.CODABAR: + // writer = new CodaBarWriter() + // break + // case BarcodeFormat.DATA_MATRIX: + // writer = new DataMatrixWriter() + // break + // case BarcodeFormat.AZTEC: + // writer = new AztecWriter() + // break + default: + throw new IllegalArgumentException('No encoder available for format ' + format); + } + return writer.encode(contents, format, width, height, hints); + } + } + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * This object extends LuminanceSource around an array of YUV data returned from the camera driver, + * with the option to crop to a rectangle within the full data. This can be used to exclude + * superfluous pixels around the perimeter and speed up decoding. + * + * It works for any pixel format where the Y channel is planar and appears first, including + * YCbCr_420_SP and YCbCr_422_SP. + * + * @author dswitkin@google.com (Daniel Switkin) + */ + class PlanarYUVLuminanceSource extends LuminanceSource { + constructor(yuvData, dataWidth /*int*/, dataHeight /*int*/, left /*int*/, top /*int*/, width /*int*/, height /*int*/, reverseHorizontal) { + super(width, height); + this.yuvData = yuvData; + this.dataWidth = dataWidth; + this.dataHeight = dataHeight; + this.left = left; + this.top = top; + if (left + width > dataWidth || top + height > dataHeight) { + throw new IllegalArgumentException('Crop rectangle does not fit within image data.'); + } + if (reverseHorizontal) { + this.reverseHorizontal(width, height); + } + } + /*@Override*/ + getRow(y /*int*/, row) { + if (y < 0 || y >= this.getHeight()) { + throw new IllegalArgumentException('Requested row is outside the image: ' + y); + } + const width = this.getWidth(); + if (row === null || row === undefined || row.length < width) { + row = new Uint8ClampedArray(width); + } + const offset = (y + this.top) * this.dataWidth + this.left; + System.arraycopy(this.yuvData, offset, row, 0, width); + return row; + } + /*@Override*/ + getMatrix() { + const width = this.getWidth(); + const height = this.getHeight(); + // If the caller asks for the entire underlying image, save the copy and give them the + // original data. The docs specifically warn that result.length must be ignored. + if (width === this.dataWidth && height === this.dataHeight) { + return this.yuvData; + } + const area = width * height; + const matrix = new Uint8ClampedArray(area); + let inputOffset = this.top * this.dataWidth + this.left; + // If the width matches the full width of the underlying data, perform a single copy. + if (width === this.dataWidth) { + System.arraycopy(this.yuvData, inputOffset, matrix, 0, area); + return matrix; + } + // Otherwise copy one cropped row at a time. + for (let y = 0; y < height; y++) { + const outputOffset = y * width; + System.arraycopy(this.yuvData, inputOffset, matrix, outputOffset, width); + inputOffset += this.dataWidth; + } + return matrix; + } + /*@Override*/ + isCropSupported() { + return true; + } + /*@Override*/ + crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) { + return new PlanarYUVLuminanceSource(this.yuvData, this.dataWidth, this.dataHeight, this.left + left, this.top + top, width, height, false); + } + renderThumbnail() { + const width = this.getWidth() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR; + const height = this.getHeight() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR; + const pixels = new Int32Array(width * height); + const yuv = this.yuvData; + let inputOffset = this.top * this.dataWidth + this.left; + for (let y = 0; y < height; y++) { + const outputOffset = y * width; + for (let x = 0; x < width; x++) { + const grey = yuv[inputOffset + x * PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR] & 0xff; + pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101); + } + inputOffset += this.dataWidth * PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR; + } + return pixels; + } + /** + * @return width of image from {@link #renderThumbnail()} + */ + getThumbnailWidth() { + return this.getWidth() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR; + } + /** + * @return height of image from {@link #renderThumbnail()} + */ + getThumbnailHeight() { + return this.getHeight() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR; + } + reverseHorizontal(width /*int*/, height /*int*/) { + const yuvData = this.yuvData; + for (let y = 0, rowStart = this.top * this.dataWidth + this.left; y < height; y++, rowStart += this.dataWidth) { + const middle = rowStart + width / 2; + for (let x1 = rowStart, x2 = rowStart + width - 1; x1 < middle; x1++, x2--) { + const temp = yuvData[x1]; + yuvData[x1] = yuvData[x2]; + yuvData[x2] = temp; + } + } + } + invert() { + return new InvertedLuminanceSource(this); + } + } + PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR = 2; + + /* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * This class is used to help decode images from files which arrive as RGB data from + * an ARGB pixel array. It does not support rotation. + * + * @author dswitkin@google.com (Daniel Switkin) + * @author Betaminos + */ + class RGBLuminanceSource extends LuminanceSource { + constructor(luminances, width /*int*/, height /*int*/, dataWidth /*int*/, dataHeight /*int*/, left /*int*/, top /*int*/) { + super(width, height); + this.dataWidth = dataWidth; + this.dataHeight = dataHeight; + this.left = left; + this.top = top; + if (luminances.BYTES_PER_ELEMENT === 4) { // Int32Array + const size = width * height; + const luminancesUint8Array = new Uint8ClampedArray(size); + for (let offset = 0; offset < size; offset++) { + const pixel = luminances[offset]; + const r = (pixel >> 16) & 0xff; // red + const g2 = (pixel >> 7) & 0x1fe; // 2 * green + const b = pixel & 0xff; // blue + // Calculate green-favouring average cheaply + luminancesUint8Array[offset] = /*(byte) */ ((r + g2 + b) / 4) & 0xFF; + } + this.luminances = luminancesUint8Array; + } + else { + this.luminances = luminances; + } + if (undefined === dataWidth) { + this.dataWidth = width; + } + if (undefined === dataHeight) { + this.dataHeight = height; + } + if (undefined === left) { + this.left = 0; + } + if (undefined === top) { + this.top = 0; + } + if (this.left + width > this.dataWidth || this.top + height > this.dataHeight) { + throw new IllegalArgumentException('Crop rectangle does not fit within image data.'); + } + } + /*@Override*/ + getRow(y /*int*/, row) { + if (y < 0 || y >= this.getHeight()) { + throw new IllegalArgumentException('Requested row is outside the image: ' + y); + } + const width = this.getWidth(); + if (row === null || row === undefined || row.length < width) { + row = new Uint8ClampedArray(width); + } + const offset = (y + this.top) * this.dataWidth + this.left; + System.arraycopy(this.luminances, offset, row, 0, width); + return row; + } + /*@Override*/ + getMatrix() { + const width = this.getWidth(); + const height = this.getHeight(); + // If the caller asks for the entire underlying image, save the copy and give them the + // original data. The docs specifically warn that result.length must be ignored. + if (width === this.dataWidth && height === this.dataHeight) { + return this.luminances; + } + const area = width * height; + const matrix = new Uint8ClampedArray(area); + let inputOffset = this.top * this.dataWidth + this.left; + // If the width matches the full width of the underlying data, perform a single copy. + if (width === this.dataWidth) { + System.arraycopy(this.luminances, inputOffset, matrix, 0, area); + return matrix; + } + // Otherwise copy one cropped row at a time. + for (let y = 0; y < height; y++) { + const outputOffset = y * width; + System.arraycopy(this.luminances, inputOffset, matrix, outputOffset, width); + inputOffset += this.dataWidth; + } + return matrix; + } + /*@Override*/ + isCropSupported() { + return true; + } + /*@Override*/ + crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) { + return new RGBLuminanceSource(this.luminances, width, height, this.dataWidth, this.dataHeight, this.left + left, this.top + top); + } + invert() { + return new InvertedLuminanceSource(this); + } + } + + /** + * Just to make a shortcut between Java code and TS code. + */ + class Charset extends CharacterSetECI { + static forName(name) { + return this.getCharacterSetECIByName(name); + } + } + + /** + * Just to make a shortcut between Java code and TS code. + */ + class StandardCharsets { + } + StandardCharsets.ISO_8859_1 = CharacterSetECI.ISO8859_1; + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * Aztec 2D code representation + * + * @author Rustam Abdullaev + */ + /*public final*/ class AztecCode { + /** + * @return {@code true} if compact instead of full mode + */ + isCompact() { + return this.compact; + } + setCompact(compact) { + this.compact = compact; + } + /** + * @return size in pixels (width and height) + */ + getSize() { + return this.size; + } + setSize(size) { + this.size = size; + } + /** + * @return number of levels + */ + getLayers() { + return this.layers; + } + setLayers(layers) { + this.layers = layers; + } + /** + * @return number of data codewords + */ + getCodeWords() { + return this.codeWords; + } + setCodeWords(codeWords) { + this.codeWords = codeWords; + } + /** + * @return the symbol image + */ + getMatrix() { + return this.matrix; + } + setMatrix(matrix) { + this.matrix = matrix; + } + } + + class Collections { + /** + * The singletonList(T) method is used to return an immutable list containing only the specified object. + */ + static singletonList(item) { + return [item]; + } + /** + * The min(Collection<? extends T>, Comparator<? super T>) method is used to return the minimum element of the given collection, according to the order induced by the specified comparator. + */ + static min(collection, comparator) { + return collection.sort(comparator)[0]; + } + } + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + class Token { + constructor(previous) { + this.previous = previous; + } + getPrevious() { + return this.previous; + } + } + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*final*/ class SimpleToken extends Token { + constructor(previous, value, bitCount) { + super(previous); + this.value = value; + this.bitCount = bitCount; + } + /** + * @Override + */ + appendTo(bitArray, text) { + bitArray.appendBits(this.value, this.bitCount); + } + add(value, bitCount) { + return new SimpleToken(this, value, bitCount); + } + addBinaryShift(start, byteCount) { + // no-op can't binary shift a simple token + console.warn('addBinaryShift on SimpleToken, this simply returns a copy of this token'); + return new SimpleToken(this, start, byteCount); + } + /** + * @Override + */ + toString() { + let value = this.value & ((1 << this.bitCount) - 1); + value |= 1 << this.bitCount; + return '<' + Integer.toBinaryString(value | (1 << this.bitCount)).substring(1) + '>'; + } + } + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*final*/ class BinaryShiftToken extends SimpleToken { + constructor(previous, binaryShiftStart, binaryShiftByteCount) { + super(previous, 0, 0); + this.binaryShiftStart = binaryShiftStart; + this.binaryShiftByteCount = binaryShiftByteCount; + } + /** + * @Override + */ + appendTo(bitArray, text) { + for (let i = 0; i < this.binaryShiftByteCount; i++) { + if (i === 0 || (i === 31 && this.binaryShiftByteCount <= 62)) { + // We need a header before the first character, and before + // character 31 when the total byte code is <= 62 + bitArray.appendBits(31, 5); // BINARY_SHIFT + if (this.binaryShiftByteCount > 62) { + bitArray.appendBits(this.binaryShiftByteCount - 31, 16); + } + else if (i === 0) { + // 1 <= binaryShiftByteCode <= 62 + bitArray.appendBits(Math.min(this.binaryShiftByteCount, 31), 5); + } + else { + // 32 <= binaryShiftCount <= 62 and i == 31 + bitArray.appendBits(this.binaryShiftByteCount - 31, 5); + } + } + bitArray.appendBits(text[this.binaryShiftStart + i], 8); + } + } + addBinaryShift(start, byteCount) { + // int bitCount = (byteCount * 8) + (byteCount <= 31 ? 10 : byteCount <= 62 ? 20 : 21); + return new BinaryShiftToken(this, start, byteCount); + } + /** + * @Override + */ + toString() { + return '<' + this.binaryShiftStart + '::' + (this.binaryShiftStart + this.binaryShiftByteCount - 1) + '>'; + } + } + + function addBinaryShift(token, start, byteCount) { + // int bitCount = (byteCount * 8) + (byteCount <= 31 ? 10 : byteCount <= 62 ? 20 : 21); + return new BinaryShiftToken(token, start, byteCount); + } + function add(token, value, bitCount) { + return new SimpleToken(token, value, bitCount); + } + + const /*final*/ MODE_NAMES = [ + 'UPPER', + 'LOWER', + 'DIGIT', + 'MIXED', + 'PUNCT' + ]; + const /*final*/ MODE_UPPER = 0; // 5 bits + const /*final*/ MODE_LOWER = 1; // 5 bits + const /*final*/ MODE_DIGIT = 2; // 4 bits + const /*final*/ MODE_MIXED = 3; // 5 bits + const /*final*/ MODE_PUNCT = 4; // 5 bits + const EMPTY_TOKEN = new SimpleToken(null, 0, 0); + + // The Latch Table shows, for each pair of Modes, the optimal method for + // getting from one mode to another. In the worst possible case, this can + // be up to 14 bits. In the best possible case, we are already there! + // The high half-word of each entry gives the number of bits. + // The low half-word of each entry are the actual bits necessary to change + const LATCH_TABLE = [ + Int32Array.from([ + 0, + (5 << 16) + 28, + (5 << 16) + 30, + (5 << 16) + 29, + (10 << 16) + (29 << 5) + 30 // UPPER -> MIXED -> PUNCT + ]), + Int32Array.from([ + (9 << 16) + (30 << 4) + 14, + 0, + (5 << 16) + 30, + (5 << 16) + 29, + (10 << 16) + (29 << 5) + 30 // LOWER -> MIXED -> PUNCT + ]), + Int32Array.from([ + (4 << 16) + 14, + (9 << 16) + (14 << 5) + 28, + 0, + (9 << 16) + (14 << 5) + 29, + (14 << 16) + (14 << 10) + (29 << 5) + 30 + // DIGIT -> UPPER -> MIXED -> PUNCT + ]), + Int32Array.from([ + (5 << 16) + 29, + (5 << 16) + 28, + (10 << 16) + (29 << 5) + 30, + 0, + (5 << 16) + 30 // MIXED -> PUNCT + ]), + Int32Array.from([ + (5 << 16) + 31, + (10 << 16) + (31 << 5) + 28, + (10 << 16) + (31 << 5) + 30, + (10 << 16) + (31 << 5) + 29, + 0 + ]) + ]; + + function static_SHIFT_TABLE(SHIFT_TABLE) { + for (let table /*Int32Array*/ of SHIFT_TABLE) { + Arrays.fill(table, -1); + } + SHIFT_TABLE[MODE_UPPER][MODE_PUNCT] = 0; + SHIFT_TABLE[MODE_LOWER][MODE_PUNCT] = 0; + SHIFT_TABLE[MODE_LOWER][MODE_UPPER] = 28; + SHIFT_TABLE[MODE_MIXED][MODE_PUNCT] = 0; + SHIFT_TABLE[MODE_DIGIT][MODE_PUNCT] = 0; + SHIFT_TABLE[MODE_DIGIT][MODE_UPPER] = 15; + return SHIFT_TABLE; + } + const /*final*/ SHIFT_TABLE = static_SHIFT_TABLE(Arrays.createInt32Array(6, 6)); // mode shift codes, per table + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * State represents all information about a sequence necessary to generate the current output. + * Note that a state is immutable. + */ + /*final*/ class State { + constructor(token, mode, binaryBytes, bitCount) { + this.token = token; + this.mode = mode; + this.binaryShiftByteCount = binaryBytes; + this.bitCount = bitCount; + // Make sure we match the token + // int binaryShiftBitCount = (binaryShiftByteCount * 8) + + // (binaryShiftByteCount === 0 ? 0 : + // binaryShiftByteCount <= 31 ? 10 : + // binaryShiftByteCount <= 62 ? 20 : 21); + // assert this.bitCount === token.getTotalBitCount() + binaryShiftBitCount; + } + getMode() { + return this.mode; + } + getToken() { + return this.token; + } + getBinaryShiftByteCount() { + return this.binaryShiftByteCount; + } + getBitCount() { + return this.bitCount; + } + // Create a new state representing this state with a latch to a (not + // necessary different) mode, and then a code. + latchAndAppend(mode, value) { + // assert binaryShiftByteCount === 0; + let bitCount = this.bitCount; + let token = this.token; + if (mode !== this.mode) { + let latch = LATCH_TABLE[this.mode][mode]; + token = add(token, latch & 0xffff, latch >> 16); + bitCount += latch >> 16; + } + let latchModeBitCount = mode === MODE_DIGIT ? 4 : 5; + token = add(token, value, latchModeBitCount); + return new State(token, mode, 0, bitCount + latchModeBitCount); + } + // Create a new state representing this state, with a temporary shift + // to a different mode to output a single value. + shiftAndAppend(mode, value) { + // assert binaryShiftByteCount === 0 && this.mode !== mode; + let token = this.token; + let thisModeBitCount = this.mode === MODE_DIGIT ? 4 : 5; + // Shifts exist only to UPPER and PUNCT, both with tokens size 5. + token = add(token, SHIFT_TABLE[this.mode][mode], thisModeBitCount); + token = add(token, value, 5); + return new State(token, this.mode, 0, this.bitCount + thisModeBitCount + 5); + } + // Create a new state representing this state, but an additional character + // output in Binary Shift mode. + addBinaryShiftChar(index) { + let token = this.token; + let mode = this.mode; + let bitCount = this.bitCount; + if (this.mode === MODE_PUNCT || this.mode === MODE_DIGIT) { + // assert binaryShiftByteCount === 0; + let latch = LATCH_TABLE[mode][MODE_UPPER]; + token = add(token, latch & 0xffff, latch >> 16); + bitCount += latch >> 16; + mode = MODE_UPPER; + } + let deltaBitCount = this.binaryShiftByteCount === 0 || this.binaryShiftByteCount === 31 + ? 18 + : this.binaryShiftByteCount === 62 + ? 9 + : 8; + let result = new State(token, mode, this.binaryShiftByteCount + 1, bitCount + deltaBitCount); + if (result.binaryShiftByteCount === 2047 + 31) { + // The string is as long as it's allowed to be. We should end it. + result = result.endBinaryShift(index + 1); + } + return result; + } + // Create the state identical to this one, but we are no longer in + // Binary Shift mode. + endBinaryShift(index) { + if (this.binaryShiftByteCount === 0) { + return this; + } + let token = this.token; + token = addBinaryShift(token, index - this.binaryShiftByteCount, this.binaryShiftByteCount); + // assert token.getTotalBitCount() === this.bitCount; + return new State(token, this.mode, 0, this.bitCount); + } + // Returns true if "this" state is better (equal: or) to be in than "that" + // state under all possible circumstances. + isBetterThanOrEqualTo(other) { + let newModeBitCount = this.bitCount + (LATCH_TABLE[this.mode][other.mode] >> 16); + if (this.binaryShiftByteCount < other.binaryShiftByteCount) { + // add additional B/S encoding cost of other, if any + newModeBitCount += + State.calculateBinaryShiftCost(other) - + State.calculateBinaryShiftCost(this); + } + else if (this.binaryShiftByteCount > other.binaryShiftByteCount && + other.binaryShiftByteCount > 0) { + // maximum possible additional cost (it: h) + newModeBitCount += 10; + } + return newModeBitCount <= other.bitCount; + } + toBitArray(text) { + // Reverse the tokens, so that they are in the order that they should + // be output + let symbols = []; + for (let token = this.endBinaryShift(text.length).token; token !== null; token = token.getPrevious()) { + symbols.unshift(token); + } + let bitArray = new BitArray(); + // Add each token to the result. + for (const symbol of symbols) { + symbol.appendTo(bitArray, text); + } + // assert bitArray.getSize() === this.bitCount; + return bitArray; + } + /** + * @Override + */ + toString() { + return StringUtils.format('%s bits=%d bytes=%d', MODE_NAMES[this.mode], this.bitCount, this.binaryShiftByteCount); + } + static calculateBinaryShiftCost(state) { + if (state.binaryShiftByteCount > 62) { + return 21; // B/S with extended length + } + if (state.binaryShiftByteCount > 31) { + return 20; // two B/S + } + if (state.binaryShiftByteCount > 0) { + return 10; // one B/S + } + return 0; + } + } + State.INITIAL_STATE = new State(EMPTY_TOKEN, MODE_UPPER, 0, 0); + + function static_CHAR_MAP(CHAR_MAP) { + const spaceCharCode = StringUtils.getCharCode(' '); + const pointCharCode = StringUtils.getCharCode('.'); + const commaCharCode = StringUtils.getCharCode(','); + CHAR_MAP[MODE_UPPER][spaceCharCode] = 1; + const zUpperCharCode = StringUtils.getCharCode('Z'); + const aUpperCharCode = StringUtils.getCharCode('A'); + for (let c = aUpperCharCode; c <= zUpperCharCode; c++) { + CHAR_MAP[MODE_UPPER][c] = c - aUpperCharCode + 2; + } + CHAR_MAP[MODE_LOWER][spaceCharCode] = 1; + const zLowerCharCode = StringUtils.getCharCode('z'); + const aLowerCharCode = StringUtils.getCharCode('a'); + for (let c = aLowerCharCode; c <= zLowerCharCode; c++) { + CHAR_MAP[MODE_LOWER][c] = c - aLowerCharCode + 2; + } + CHAR_MAP[MODE_DIGIT][spaceCharCode] = 1; + const nineCharCode = StringUtils.getCharCode('9'); + const zeroCharCode = StringUtils.getCharCode('0'); + for (let c = zeroCharCode; c <= nineCharCode; c++) { + CHAR_MAP[MODE_DIGIT][c] = c - zeroCharCode + 2; + } + CHAR_MAP[MODE_DIGIT][commaCharCode] = 12; + CHAR_MAP[MODE_DIGIT][pointCharCode] = 13; + const mixedTable = [ + '\x00', + ' ', + '\x01', + '\x02', + '\x03', + '\x04', + '\x05', + '\x06', + '\x07', + '\b', + '\t', + '\n', + '\x0b', + '\f', + '\r', + '\x1b', + '\x1c', + '\x1d', + '\x1e', + '\x1f', + '@', + '\\', + '^', + '_', + '`', + '|', + '~', + '\x7f' + ]; + for (let i = 0; i < mixedTable.length; i++) { + CHAR_MAP[MODE_MIXED][StringUtils.getCharCode(mixedTable[i])] = i; + } + const punctTable = [ + '\x00', + '\r', + '\x00', + '\x00', + '\x00', + '\x00', + '!', + '\'', + '#', + '$', + '%', + '&', + '\'', + '(', + ')', + '*', + '+', + ',', + '-', + '.', + '/', + ':', + ';', + '<', + '=', + '>', + '?', + '[', + ']', + '{', + '}' + ]; + for (let i = 0; i < punctTable.length; i++) { + if (StringUtils.getCharCode(punctTable[i]) > 0) { + CHAR_MAP[MODE_PUNCT][StringUtils.getCharCode(punctTable[i])] = i; + } + } + return CHAR_MAP; + } + const CHAR_MAP = static_CHAR_MAP(Arrays.createInt32Array(5, 256)); + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * This produces nearly optimal encodings of text into the first-level of + * encoding used by Aztec code. + * + * It uses a dynamic algorithm. For each prefix of the string, it determines + * a set of encodings that could lead to this prefix. We repeatedly add a + * character and generate a new set of optimal encodings until we have read + * through the entire input. + * + * @author Frank Yellin + * @author Rustam Abdullaev + */ + /*public final*/ class HighLevelEncoder { + constructor(text) { + this.text = text; + } + /** + * @return text represented by this encoder encoded as a {@link BitArray} + */ + encode() { + const spaceCharCode = StringUtils.getCharCode(' '); + const lineBreakCharCode = StringUtils.getCharCode('\n'); + let states = Collections.singletonList(State.INITIAL_STATE); + for (let index = 0; index < this.text.length; index++) { + let pairCode; + let nextChar = index + 1 < this.text.length ? this.text[index + 1] : 0; + switch (this.text[index]) { + case StringUtils.getCharCode('\r'): + pairCode = nextChar === lineBreakCharCode ? 2 : 0; + break; + case StringUtils.getCharCode('.'): + pairCode = nextChar === spaceCharCode ? 3 : 0; + break; + case StringUtils.getCharCode(','): + pairCode = nextChar === spaceCharCode ? 4 : 0; + break; + case StringUtils.getCharCode(':'): + pairCode = nextChar === spaceCharCode ? 5 : 0; + break; + default: + pairCode = 0; + } + if (pairCode > 0) { + // We have one of the four special PUNCT pairs. Treat them specially. + // Get a new set of states for the two new characters. + states = HighLevelEncoder.updateStateListForPair(states, index, pairCode); + index++; + } + else { + // Get a new set of states for the new character. + states = this.updateStateListForChar(states, index); + } + } + // We are left with a set of states. Find the shortest one. + const minState = Collections.min(states, (a, b) => { + return a.getBitCount() - b.getBitCount(); + }); + // Convert it to a bit array, and return. + return minState.toBitArray(this.text); + } + // We update a set of states for a new character by updating each state + // for the new character, merging the results, and then removing the + // non-optimal states. + updateStateListForChar(states, index) { + const result = []; + for (let state /*State*/ of states) { + this.updateStateForChar(state, index, result); + } + return HighLevelEncoder.simplifyStates(result); + } + // Return a set of states that represent the possible ways of updating this + // state for the next character. The resulting set of states are added to + // the "result" list. + updateStateForChar(state, index, result) { + let ch = (this.text[index] & 0xff); + let charInCurrentTable = CHAR_MAP[state.getMode()][ch] > 0; + let stateNoBinary = null; + for (let mode /*int*/ = 0; mode <= MODE_PUNCT; mode++) { + let charInMode = CHAR_MAP[mode][ch]; + if (charInMode > 0) { + if (stateNoBinary == null) { + // Only create stateNoBinary the first time it's required. + stateNoBinary = state.endBinaryShift(index); + } + // Try generating the character by latching to its mode + if (!charInCurrentTable || + mode === state.getMode() || + mode === MODE_DIGIT) { + // If the character is in the current table, we don't want to latch to + // any other mode except possibly digit (which uses only 4 bits). Any + // other latch would be equally successful *after* this character, and + // so wouldn't save any bits. + const latchState = stateNoBinary.latchAndAppend(mode, charInMode); + result.push(latchState); + } + // Try generating the character by switching to its mode. + if (!charInCurrentTable && + SHIFT_TABLE[state.getMode()][mode] >= 0) { + // It never makes sense to temporarily shift to another mode if the + // character exists in the current mode. That can never save bits. + const shiftState = stateNoBinary.shiftAndAppend(mode, charInMode); + result.push(shiftState); + } + } + } + if (state.getBinaryShiftByteCount() > 0 || + CHAR_MAP[state.getMode()][ch] === 0) { + // It's never worthwhile to go into binary shift mode if you're not already + // in binary shift mode, and the character exists in your current mode. + // That can never save bits over just outputting the char in the current mode. + let binaryState = state.addBinaryShiftChar(index); + result.push(binaryState); + } + } + static updateStateListForPair(states, index, pairCode) { + const result = []; + for (let state /*State*/ of states) { + this.updateStateForPair(state, index, pairCode, result); + } + return this.simplifyStates(result); + } + static updateStateForPair(state, index, pairCode, result) { + let stateNoBinary = state.endBinaryShift(index); + // Possibility 1. Latch to C.MODE_PUNCT, and then append this code + result.push(stateNoBinary.latchAndAppend(MODE_PUNCT, pairCode)); + if (state.getMode() !== MODE_PUNCT) { + // Possibility 2. Shift to C.MODE_PUNCT, and then append this code. + // Every state except C.MODE_PUNCT (handled above) can shift + result.push(stateNoBinary.shiftAndAppend(MODE_PUNCT, pairCode)); + } + if (pairCode === 3 || pairCode === 4) { + // both characters are in DIGITS. Sometimes better to just add two digits + let digitState = stateNoBinary + .latchAndAppend(MODE_DIGIT, 16 - pairCode) // period or comma in DIGIT + .latchAndAppend(MODE_DIGIT, 1); // space in DIGIT + result.push(digitState); + } + if (state.getBinaryShiftByteCount() > 0) { + // It only makes sense to do the characters as binary if we're already + // in binary mode. + let binaryState = state + .addBinaryShiftChar(index) + .addBinaryShiftChar(index + 1); + result.push(binaryState); + } + } + static simplifyStates(states) { + let result = []; + for (const newState of states) { + let add = true; + for (const oldState of result) { + if (oldState.isBetterThanOrEqualTo(newState)) { + add = false; + break; + } + if (newState.isBetterThanOrEqualTo(oldState)) { + // iterator.remove(); + result = result.filter(x => x !== oldState); // remove old state + } + } + if (add) { + result.push(newState); + } + } + return result; + } + } + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // package com.google.zxing.aztec.encoder; + // import com.google.zxing.common.BitArray; + // import com.google.zxing.common.BitMatrix; + // import com.google.zxing.common.reedsolomon.GenericGF; + // import com.google.zxing.common.reedsolomon.ReedSolomonEncoder; + /** + * Generates Aztec 2D barcodes. + * + * @author Rustam Abdullaev + */ + /*public final*/ class Encoder$1 { + constructor() { + } + /** + * Encodes the given binary content as an Aztec symbol + * + * @param data input data string + * @return Aztec symbol matrix with metadata + */ + static encodeBytes(data) { + return Encoder$1.encode(data, Encoder$1.DEFAULT_EC_PERCENT, Encoder$1.DEFAULT_AZTEC_LAYERS); + } + /** + * Encodes the given binary content as an Aztec symbol + * + * @param data input data string + * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008, + * a minimum of 23% + 3 words is recommended) + * @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers + * @return Aztec symbol matrix with metadata + */ + static encode(data, minECCPercent, userSpecifiedLayers) { + // High-level encode + let bits = new HighLevelEncoder(data).encode(); + // stuff bits and choose symbol size + let eccBits = Integer.truncDivision((bits.getSize() * minECCPercent), 100) + 11; + let totalSizeBits = bits.getSize() + eccBits; + let compact; + let layers; + let totalBitsInLayer; + let wordSize; + let stuffedBits; + if (userSpecifiedLayers !== Encoder$1.DEFAULT_AZTEC_LAYERS) { + compact = userSpecifiedLayers < 0; + layers = Math.abs(userSpecifiedLayers); + if (layers > (compact ? Encoder$1.MAX_NB_BITS_COMPACT : Encoder$1.MAX_NB_BITS)) { + throw new IllegalArgumentException(StringUtils.format('Illegal value %s for layers', userSpecifiedLayers)); + } + totalBitsInLayer = Encoder$1.totalBitsInLayer(layers, compact); + wordSize = Encoder$1.WORD_SIZE[layers]; + let usableBitsInLayers = totalBitsInLayer - (totalBitsInLayer % wordSize); + stuffedBits = Encoder$1.stuffBits(bits, wordSize); + if (stuffedBits.getSize() + eccBits > usableBitsInLayers) { + throw new IllegalArgumentException('Data to large for user specified layer'); + } + if (compact && stuffedBits.getSize() > wordSize * 64) { + // Compact format only allows 64 data words, though C4 can hold more words than that + throw new IllegalArgumentException('Data to large for user specified layer'); + } + } + else { + wordSize = 0; + stuffedBits = null; + // We look at the possible table sizes in the order Compact1, Compact2, Compact3, + // Compact4, Normal4,... Normal(i) for i < 4 isn't typically used since Compact(i+1) + // is the same size, but has more data. + for (let i /*int*/ = 0;; i++) { + if (i > Encoder$1.MAX_NB_BITS) { + throw new IllegalArgumentException('Data too large for an Aztec code'); + } + compact = i <= 3; + layers = compact ? i + 1 : i; + totalBitsInLayer = Encoder$1.totalBitsInLayer(layers, compact); + if (totalSizeBits > totalBitsInLayer) { + continue; + } + // [Re]stuff the bits if this is the first opportunity, or if the + // wordSize has changed + if (stuffedBits == null || wordSize !== Encoder$1.WORD_SIZE[layers]) { + wordSize = Encoder$1.WORD_SIZE[layers]; + stuffedBits = Encoder$1.stuffBits(bits, wordSize); + } + let usableBitsInLayers = totalBitsInLayer - (totalBitsInLayer % wordSize); + if (compact && stuffedBits.getSize() > wordSize * 64) { + // Compact format only allows 64 data words, though C4 can hold more words than that + continue; + } + if (stuffedBits.getSize() + eccBits <= usableBitsInLayers) { + break; + } + } + } + let messageBits = Encoder$1.generateCheckWords(stuffedBits, totalBitsInLayer, wordSize); + // generate mode message + let messageSizeInWords = stuffedBits.getSize() / wordSize; + let modeMessage = Encoder$1.generateModeMessage(compact, layers, messageSizeInWords); + // allocate symbol + let baseMatrixSize = (compact ? 11 : 14) + layers * 4; // not including alignment lines + let alignmentMap = new Int32Array(baseMatrixSize); + let matrixSize; + if (compact) { + // no alignment marks in compact mode, alignmentMap is a no-op + matrixSize = baseMatrixSize; + for (let i /*int*/ = 0; i < alignmentMap.length; i++) { + alignmentMap[i] = i; + } + } + else { + matrixSize = baseMatrixSize + 1 + 2 * Integer.truncDivision((Integer.truncDivision(baseMatrixSize, 2) - 1), 15); + let origCenter = Integer.truncDivision(baseMatrixSize, 2); + let center = Integer.truncDivision(matrixSize, 2); + for (let i /*int*/ = 0; i < origCenter; i++) { + let newOffset = i + Integer.truncDivision(i, 15); + alignmentMap[origCenter - i - 1] = center - newOffset - 1; + alignmentMap[origCenter + i] = center + newOffset + 1; + } + } + let matrix = new BitMatrix(matrixSize); + // draw data bits + for (let i /*int*/ = 0, rowOffset = 0; i < layers; i++) { + let rowSize = (layers - i) * 4 + (compact ? 9 : 12); + for (let j /*int*/ = 0; j < rowSize; j++) { + let columnOffset = j * 2; + for (let k /*int*/ = 0; k < 2; k++) { + if (messageBits.get(rowOffset + columnOffset + k)) { + matrix.set(alignmentMap[i * 2 + k], alignmentMap[i * 2 + j]); + } + if (messageBits.get(rowOffset + rowSize * 2 + columnOffset + k)) { + matrix.set(alignmentMap[i * 2 + j], alignmentMap[baseMatrixSize - 1 - i * 2 - k]); + } + if (messageBits.get(rowOffset + rowSize * 4 + columnOffset + k)) { + matrix.set(alignmentMap[baseMatrixSize - 1 - i * 2 - k], alignmentMap[baseMatrixSize - 1 - i * 2 - j]); + } + if (messageBits.get(rowOffset + rowSize * 6 + columnOffset + k)) { + matrix.set(alignmentMap[baseMatrixSize - 1 - i * 2 - j], alignmentMap[i * 2 + k]); + } + } + } + rowOffset += rowSize * 8; + } + // draw mode message + Encoder$1.drawModeMessage(matrix, compact, matrixSize, modeMessage); + // draw alignment marks + if (compact) { + Encoder$1.drawBullsEye(matrix, Integer.truncDivision(matrixSize, 2), 5); + } + else { + Encoder$1.drawBullsEye(matrix, Integer.truncDivision(matrixSize, 2), 7); + for (let i /*int*/ = 0, j = 0; i < Integer.truncDivision(baseMatrixSize, 2) - 1; i += 15, j += 16) { + for (let k /*int*/ = Integer.truncDivision(matrixSize, 2) & 1; k < matrixSize; k += 2) { + matrix.set(Integer.truncDivision(matrixSize, 2) - j, k); + matrix.set(Integer.truncDivision(matrixSize, 2) + j, k); + matrix.set(k, Integer.truncDivision(matrixSize, 2) - j); + matrix.set(k, Integer.truncDivision(matrixSize, 2) + j); + } + } + } + let aztec = new AztecCode(); + aztec.setCompact(compact); + aztec.setSize(matrixSize); + aztec.setLayers(layers); + aztec.setCodeWords(messageSizeInWords); + aztec.setMatrix(matrix); + return aztec; + } + static drawBullsEye(matrix, center, size) { + for (let i /*int*/ = 0; i < size; i += 2) { + for (let j /*int*/ = center - i; j <= center + i; j++) { + matrix.set(j, center - i); + matrix.set(j, center + i); + matrix.set(center - i, j); + matrix.set(center + i, j); + } + } + matrix.set(center - size, center - size); + matrix.set(center - size + 1, center - size); + matrix.set(center - size, center - size + 1); + matrix.set(center + size, center - size); + matrix.set(center + size, center - size + 1); + matrix.set(center + size, center + size - 1); + } + static generateModeMessage(compact, layers, messageSizeInWords) { + let modeMessage = new BitArray(); + if (compact) { + modeMessage.appendBits(layers - 1, 2); + modeMessage.appendBits(messageSizeInWords - 1, 6); + modeMessage = Encoder$1.generateCheckWords(modeMessage, 28, 4); + } + else { + modeMessage.appendBits(layers - 1, 5); + modeMessage.appendBits(messageSizeInWords - 1, 11); + modeMessage = Encoder$1.generateCheckWords(modeMessage, 40, 4); + } + return modeMessage; + } + static drawModeMessage(matrix, compact, matrixSize, modeMessage) { + let center = Integer.truncDivision(matrixSize, 2); + if (compact) { + for (let i /*int*/ = 0; i < 7; i++) { + let offset = center - 3 + i; + if (modeMessage.get(i)) { + matrix.set(offset, center - 5); + } + if (modeMessage.get(i + 7)) { + matrix.set(center + 5, offset); + } + if (modeMessage.get(20 - i)) { + matrix.set(offset, center + 5); + } + if (modeMessage.get(27 - i)) { + matrix.set(center - 5, offset); + } + } + } + else { + for (let i /*int*/ = 0; i < 10; i++) { + let offset = center - 5 + i + Integer.truncDivision(i, 5); + if (modeMessage.get(i)) { + matrix.set(offset, center - 7); + } + if (modeMessage.get(i + 10)) { + matrix.set(center + 7, offset); + } + if (modeMessage.get(29 - i)) { + matrix.set(offset, center + 7); + } + if (modeMessage.get(39 - i)) { + matrix.set(center - 7, offset); + } + } + } + } + static generateCheckWords(bitArray, totalBits, wordSize) { + // bitArray is guaranteed to be a multiple of the wordSize, so no padding needed + let messageSizeInWords = bitArray.getSize() / wordSize; + let rs = new ReedSolomonEncoder(Encoder$1.getGF(wordSize)); + let totalWords = Integer.truncDivision(totalBits, wordSize); + let messageWords = Encoder$1.bitsToWords(bitArray, wordSize, totalWords); + rs.encode(messageWords, totalWords - messageSizeInWords); + let startPad = totalBits % wordSize; + let messageBits = new BitArray(); + messageBits.appendBits(0, startPad); + for (const messageWord /*: int*/ of Array.from(messageWords)) { + messageBits.appendBits(messageWord, wordSize); + } + return messageBits; + } + static bitsToWords(stuffedBits, wordSize, totalWords) { + let message = new Int32Array(totalWords); + let i; + let n; + for (i = 0, n = stuffedBits.getSize() / wordSize; i < n; i++) { + let value = 0; + for (let j /*int*/ = 0; j < wordSize; j++) { + value |= stuffedBits.get(i * wordSize + j) ? (1 << wordSize - j - 1) : 0; + } + message[i] = value; + } + return message; + } + static getGF(wordSize) { + switch (wordSize) { + case 4: + return GenericGF.AZTEC_PARAM; + case 6: + return GenericGF.AZTEC_DATA_6; + case 8: + return GenericGF.AZTEC_DATA_8; + case 10: + return GenericGF.AZTEC_DATA_10; + case 12: + return GenericGF.AZTEC_DATA_12; + default: + throw new IllegalArgumentException('Unsupported word size ' + wordSize); + } + } + static stuffBits(bits, wordSize) { + let out = new BitArray(); + let n = bits.getSize(); + let mask = (1 << wordSize) - 2; + for (let i /*int*/ = 0; i < n; i += wordSize) { + let word = 0; + for (let j /*int*/ = 0; j < wordSize; j++) { + if (i + j >= n || bits.get(i + j)) { + word |= 1 << (wordSize - 1 - j); + } + } + if ((word & mask) === mask) { + out.appendBits(word & mask, wordSize); + i--; + } + else if ((word & mask) === 0) { + out.appendBits(word | 1, wordSize); + i--; + } + else { + out.appendBits(word, wordSize); + } + } + return out; + } + static totalBitsInLayer(layers, compact) { + return ((compact ? 88 : 112) + 16 * layers) * layers; + } + } + Encoder$1.DEFAULT_EC_PERCENT = 33; // default minimal percentage of error check words + Encoder$1.DEFAULT_AZTEC_LAYERS = 0; + Encoder$1.MAX_NB_BITS = 32; + Encoder$1.MAX_NB_BITS_COMPACT = 4; + Encoder$1.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 + ]); + + /* + * Copyright 2013 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * Renders an Aztec code as a {@link BitMatrix}. + */ + /*public final*/ class AztecWriter { + // @Override + encode(contents, format, width, height) { + return this.encodeWithHints(contents, format, width, height, null); + } + // @Override + encodeWithHints(contents, format, width, height, hints) { + let charset = StandardCharsets.ISO_8859_1; + let eccPercent = Encoder$1.DEFAULT_EC_PERCENT; + let layers = Encoder$1.DEFAULT_AZTEC_LAYERS; + if (hints != null) { + if (hints.has(EncodeHintType$1.CHARACTER_SET)) { + charset = Charset.forName(hints.get(EncodeHintType$1.CHARACTER_SET).toString()); + } + if (hints.has(EncodeHintType$1.ERROR_CORRECTION)) { + eccPercent = Integer.parseInt(hints.get(EncodeHintType$1.ERROR_CORRECTION).toString()); + } + if (hints.has(EncodeHintType$1.AZTEC_LAYERS)) { + layers = Integer.parseInt(hints.get(EncodeHintType$1.AZTEC_LAYERS).toString()); + } + } + return AztecWriter.encodeLayers(contents, format, width, height, charset, eccPercent, layers); + } + static encodeLayers(contents, format, width, height, charset, eccPercent, layers) { + if (format !== BarcodeFormat$1.AZTEC) { + throw new IllegalArgumentException('Can only encode AZTEC, but got ' + format); + } + let aztec = Encoder$1.encode(StringUtils.getBytes(contents, charset), eccPercent, layers); + return AztecWriter.renderResult(aztec, width, height); + } + static renderResult(code, width, height) { + let input = code.getMatrix(); + if (input == null) { + throw new IllegalStateException(); + } + let inputWidth = input.getWidth(); + let inputHeight = input.getHeight(); + let outputWidth = Math.max(width, inputWidth); + let outputHeight = Math.max(height, inputHeight); + let multiple = Math.min(outputWidth / inputWidth, outputHeight / inputHeight); + let leftPadding = (outputWidth - (inputWidth * multiple)) / 2; + let topPadding = (outputHeight - (inputHeight * multiple)) / 2; + let output = new BitMatrix(outputWidth, outputHeight); + for (let inputY /*int*/ = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) { + // Write the contents of this row of the barcode + for (let inputX /*int*/ = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) { + if (input.get(inputX, inputY)) { + output.setRegion(outputX, outputY, multiple, multiple); + } + } + } + return output; + } + } + + exports.AbstractExpandedDecoder = AbstractExpandedDecoder; + exports.ArgumentException = ArgumentException; + exports.ArithmeticException = ArithmeticException; + exports.AztecCode = AztecCode; + exports.AztecCodeReader = AztecReader; + exports.AztecCodeWriter = AztecWriter; + exports.AztecDecoder = Decoder; + exports.AztecDetector = Detector; + exports.AztecDetectorResult = AztecDetectorResult; + exports.AztecEncoder = Encoder$1; + exports.AztecHighLevelEncoder = HighLevelEncoder; + exports.AztecPoint = Point; + exports.BarcodeFormat = BarcodeFormat$1; + exports.Binarizer = Binarizer; + exports.BinaryBitmap = BinaryBitmap; + exports.BitArray = BitArray; + exports.BitMatrix = BitMatrix; + exports.BitSource = BitSource; + exports.BrowserAztecCodeReader = BrowserAztecCodeReader; + exports.BrowserBarcodeReader = BrowserBarcodeReader; + exports.BrowserCodeReader = BrowserCodeReader; + exports.BrowserDatamatrixCodeReader = BrowserDatamatrixCodeReader; + exports.BrowserMultiFormatReader = BrowserMultiFormatReader; + exports.BrowserPDF417Reader = BrowserPDF417Reader; + exports.BrowserQRCodeReader = BrowserQRCodeReader; + exports.BrowserQRCodeSvgWriter = BrowserQRCodeSvgWriter; + exports.CharacterSetECI = CharacterSetECI; + exports.ChecksumException = ChecksumException; + exports.Code128Reader = Code128Reader; + exports.Code39Reader = Code39Reader; + exports.DataMatrixDecodedBitStreamParser = DecodedBitStreamParser; + exports.DataMatrixReader = DataMatrixReader; + exports.DecodeHintType = DecodeHintType$1; + exports.DecoderResult = DecoderResult; + exports.DefaultGridSampler = DefaultGridSampler; + exports.DetectorResult = DetectorResult; + exports.EAN13Reader = EAN13Reader; + exports.EncodeHintType = EncodeHintType$1; + exports.Exception = Exception; + exports.FormatException = FormatException; + exports.GenericGF = GenericGF; + exports.GenericGFPoly = GenericGFPoly; + exports.GlobalHistogramBinarizer = GlobalHistogramBinarizer; + exports.GridSampler = GridSampler; + exports.GridSamplerInstance = GridSamplerInstance; + exports.HTMLCanvasElementLuminanceSource = HTMLCanvasElementLuminanceSource; + exports.HybridBinarizer = HybridBinarizer; + exports.ITFReader = ITFReader; + exports.IllegalArgumentException = IllegalArgumentException; + exports.IllegalStateException = IllegalStateException; + exports.InvertedLuminanceSource = InvertedLuminanceSource; + exports.LuminanceSource = LuminanceSource; + exports.MathUtils = MathUtils; + exports.MultiFormatOneDReader = MultiFormatOneDReader; + exports.MultiFormatReader = MultiFormatReader; + exports.MultiFormatWriter = MultiFormatWriter; + exports.NotFoundException = NotFoundException; + exports.OneDReader = OneDReader; + exports.PDF417DecodedBitStreamParser = DecodedBitStreamParser$2; + exports.PDF417DecoderErrorCorrection = ErrorCorrection; + exports.PDF417Reader = PDF417Reader; + exports.PDF417ResultMetadata = PDF417ResultMetadata; + exports.PerspectiveTransform = PerspectiveTransform; + exports.PlanarYUVLuminanceSource = PlanarYUVLuminanceSource; + exports.QRCodeByteMatrix = ByteMatrix; + exports.QRCodeDataMask = DataMask; + exports.QRCodeDecodedBitStreamParser = DecodedBitStreamParser$1; + exports.QRCodeDecoderErrorCorrectionLevel = ErrorCorrectionLevel; + exports.QRCodeDecoderFormatInformation = FormatInformation; + exports.QRCodeEncoder = Encoder; + exports.QRCodeEncoderQRCode = QRCode; + exports.QRCodeMaskUtil = MaskUtil; + exports.QRCodeMatrixUtil = MatrixUtil; + exports.QRCodeMode = Mode$1; + exports.QRCodeReader = QRCodeReader; + exports.QRCodeVersion = Version$1; + exports.QRCodeWriter = QRCodeWriter; + exports.RGBLuminanceSource = RGBLuminanceSource; + exports.RSS14Reader = RSS14Reader; + exports.RSSExpandedReader = RSSExpandedReader; + exports.ReaderException = ReaderException; + exports.ReedSolomonDecoder = ReedSolomonDecoder; + exports.ReedSolomonEncoder = ReedSolomonEncoder; + exports.ReedSolomonException = ReedSolomonException; + exports.Result = Result; + exports.ResultMetadataType = ResultMetadataType$1; + exports.ResultPoint = ResultPoint; + exports.StringUtils = StringUtils; + exports.UnsupportedOperationException = UnsupportedOperationException; + exports.VideoInputDevice = VideoInputDevice; + exports.WhiteRectangleDetector = WhiteRectangleDetector; + exports.WriterException = WriterException; + exports.ZXingArrays = Arrays; + exports.ZXingCharset = Charset; + exports.ZXingInteger = Integer; + exports.ZXingStandardCharsets = StandardCharsets; + exports.ZXingStringBuilder = StringBuilder; + exports.ZXingStringEncoding = StringEncoding; + exports.ZXingSystem = System; + exports.createAbstractExpandedDecoder = createDecoder; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); diff --git a/src/main/node_modules/html5-qrcode/ui.d.ts b/src/main/node_modules/html5-qrcode/ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f03fe96416ae95a12a35935d8b5f61c5d36d433 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/ui.d.ts @@ -0,0 +1,6 @@ +export declare class LibraryInfoContainer { + private infoDiv; + private infoIcon; + constructor(); + renderInto(parent: HTMLElement): void; +} diff --git a/src/main/node_modules/html5-qrcode/ui/scanner/base.d.ts b/src/main/node_modules/html5-qrcode/ui/scanner/base.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f6ba9cf120e4959471cfef863e282fbbbb9db22 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/ui/scanner/base.d.ts @@ -0,0 +1,16 @@ +export declare class PublicUiElementIdAndClasses { + static ALL_ELEMENT_CLASS: string; + static CAMERA_PERMISSION_BUTTON_ID: string; + static CAMERA_START_BUTTON_ID: string; + static CAMERA_STOP_BUTTON_ID: string; + static TORCH_BUTTON_ID: string; + static CAMERA_SELECTION_SELECT_ID: string; + static FILE_SELECTION_BUTTON_ID: string; + static ZOOM_SLIDER_ID: string; + static SCAN_TYPE_CHANGE_ANCHOR_ID: string; + static TORCH_BUTTON_CLASS_TORCH_ON: string; + static TORCH_BUTTON_CLASS_TORCH_OFF: string; +} +export declare class BaseUiElementFactory { + static createElement<Type extends HTMLElement>(elementType: string, elementId: string): Type; +} diff --git a/src/main/node_modules/html5-qrcode/ui/scanner/camera-selection-ui.d.ts b/src/main/node_modules/html5-qrcode/ui/scanner/camera-selection-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2090ed53de81e3fc2a4a3f33806eace194c983c9 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/ui/scanner/camera-selection-ui.d.ts @@ -0,0 +1,17 @@ +import { CameraDevice } from "../../camera/core"; +export declare class CameraSelectionUi { + private readonly selectElement; + private readonly options; + private readonly cameras; + private constructor(); + private render; + disable(): void; + isDisabled(): boolean; + enable(): void; + getValue(): string; + hasValue(value: string): boolean; + setValue(value: string): void; + hasSingleItem(): boolean; + numCameras(): number; + static create(parentElement: HTMLElement, cameras: Array<CameraDevice>): CameraSelectionUi; +} diff --git a/src/main/node_modules/html5-qrcode/ui/scanner/camera-zoom-ui.d.ts b/src/main/node_modules/html5-qrcode/ui/scanner/camera-zoom-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..215bb3f45a562941e18b27204250b45b021bc973 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/ui/scanner/camera-zoom-ui.d.ts @@ -0,0 +1,16 @@ +export type OnCameraZoomValueChangeCallback = (zoomValue: number) => void; +export declare class CameraZoomUi { + private zoomElementContainer; + private rangeInput; + private rangeText; + private onChangeCallback; + private constructor(); + private render; + private onValueChange; + setValues(minValue: number, maxValue: number, defaultValue: number, step: number): void; + show(): void; + hide(): void; + setOnCameraZoomValueChangeCallback(onChangeCallback: OnCameraZoomValueChangeCallback): void; + removeOnCameraZoomValueChangeCallback(): void; + static create(parentElement: HTMLElement, renderOnCreate: boolean): CameraZoomUi; +} diff --git a/src/main/node_modules/html5-qrcode/ui/scanner/file-selection-ui.d.ts b/src/main/node_modules/html5-qrcode/ui/scanner/file-selection-ui.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..768f5ed8d5b9cd84994a11bca20a02224c665a75 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/ui/scanner/file-selection-ui.d.ts @@ -0,0 +1,19 @@ +export type OnFileSelected = (file: File) => void; +export declare class FileSelectionUi { + private readonly fileBasedScanRegion; + private readonly fileScanInput; + private readonly fileSelectionButton; + private constructor(); + hide(): void; + show(): void; + isShowing(): boolean; + resetValue(): void; + private createFileBasedScanRegion; + private fileBasedScanRegionDefaultBorder; + private fileBasedScanRegionActiveBorder; + private createDragAndDropMessage; + private setImageNameToButton; + private setInitialValueToButton; + private getFileScanInputId; + static create(parentElement: HTMLDivElement, showOnRender: boolean, onFileSelected: OnFileSelected): FileSelectionUi; +} diff --git a/src/main/node_modules/html5-qrcode/ui/scanner/scan-type-selector.d.ts b/src/main/node_modules/html5-qrcode/ui/scanner/scan-type-selector.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f0e1347449e85244139b7cf48cd52b2fca300cb --- /dev/null +++ b/src/main/node_modules/html5-qrcode/ui/scanner/scan-type-selector.d.ts @@ -0,0 +1,11 @@ +import { Html5QrcodeScanType } from "../../core"; +export declare class ScanTypeSelector { + private supportedScanTypes; + constructor(supportedScanTypes?: Array<Html5QrcodeScanType> | []); + getDefaultScanType(): Html5QrcodeScanType; + hasMoreThanOneScanType(): boolean; + isCameraScanRequired(): boolean; + static isCameraScanType(scanType: Html5QrcodeScanType): boolean; + static isFileScanType(scanType: Html5QrcodeScanType): boolean; + private validateAndReturnScanTypes; +} diff --git a/src/main/node_modules/html5-qrcode/ui/scanner/torch-button.d.ts b/src/main/node_modules/html5-qrcode/ui/scanner/torch-button.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a862a10bae47503e7ee4e8875da199ff90538d6f --- /dev/null +++ b/src/main/node_modules/html5-qrcode/ui/scanner/torch-button.d.ts @@ -0,0 +1,28 @@ +import { BooleanCameraCapability } from "../../camera/core"; +export type OnTorchActionFailureCallback = (failureMessage: string) => void; +interface TorchButtonController { + disable(): void; + enable(): void; + setText(text: string): void; +} +export interface TorchButtonOptions { + display: string; + marginLeft: string; +} +export declare class TorchButton implements TorchButtonController { + private readonly torchButton; + private readonly onTorchActionFailureCallback; + private torchController; + private constructor(); + private render; + updateTorchCapability(torchCapability: BooleanCameraCapability): void; + getTorchButton(): HTMLButtonElement; + hide(): void; + show(): void; + disable(): void; + enable(): void; + setText(text: string): void; + reset(): void; + static create(parentElement: HTMLElement, torchCapability: BooleanCameraCapability, torchButtonOptions: TorchButtonOptions, onTorchActionFailureCallback: OnTorchActionFailureCallback): TorchButton; +} +export {}; diff --git a/src/main/node_modules/html5-qrcode/utils.d.ts b/src/main/node_modules/html5-qrcode/utils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b060ed9e1f751f6c8a3592683ce5726bf6d3e20 --- /dev/null +++ b/src/main/node_modules/html5-qrcode/utils.d.ts @@ -0,0 +1,4 @@ +import { Logger } from "./core"; +export declare class VideoConstraintsUtil { + static isMediaStreamConstraintsValid(videoConstraints: MediaTrackConstraints, logger: Logger): boolean; +} diff --git a/src/main/node_modules/html5-qrcode/zxing-html5-qrcode-decoder.d.ts b/src/main/node_modules/html5-qrcode/zxing-html5-qrcode-decoder.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..411d37712f3a62354959625cbe40dce24d67f1cc --- /dev/null +++ b/src/main/node_modules/html5-qrcode/zxing-html5-qrcode-decoder.d.ts @@ -0,0 +1,15 @@ +import { QrcodeResult, Html5QrcodeSupportedFormats, Logger, QrcodeDecoderAsync } from "./core"; +export declare class ZXingHtml5QrcodeDecoder implements QrcodeDecoderAsync { + private readonly formatMap; + private readonly reverseFormatMap; + private hints; + private verbose; + private logger; + constructor(requestedFormats: Array<Html5QrcodeSupportedFormats>, verbose: boolean, logger: Logger); + decodeAsync(canvas: HTMLCanvasElement): Promise<QrcodeResult>; + private decode; + private createReverseFormatMap; + private toHtml5QrcodeSupportedFormats; + private createZXingFormats; + private createDebugData; +} diff --git a/src/main/package-lock.json b/src/main/package-lock.json new file mode 100644 index 0000000000000000000000000000000000000000..f87cd0fa617c70015c9a214b517c1c4ccb8d53ce --- /dev/null +++ b/src/main/package-lock.json @@ -0,0 +1,20 @@ +{ + "name": "main", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "main", + "version": "1.0.0", + "dependencies": { + "html5-qrcode": "^2.3.8" + } + }, + "node_modules/html5-qrcode": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/html5-qrcode/-/html5-qrcode-2.3.8.tgz", + "integrity": "sha512-jsr4vafJhwoLVEDW3n1KvPnCCXWaQfRng0/EEYk1vNcQGcG/htAdhJX0be8YyqMoSz7+hZvOZSTAepsabiuhiQ==" + } + } +} diff --git a/src/main/package.json b/src/main/package.json new file mode 100644 index 0000000000000000000000000000000000000000..b58ec6ea1338ef9ef2376b74567a94cef9c2efd5 --- /dev/null +++ b/src/main/package.json @@ -0,0 +1,7 @@ +{ + "name": "main", + "version": "1.0.0", + "dependencies": { + "html5-qrcode": "^2.3.8" + } +} diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index b46b3d8905f157657ed741a994da4a74a4202c44..e964d63dd7313b3a8040a43d2cfa609dc40e7370 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -27,7 +27,10 @@ create table if not exists users ( id bigint auto_increment primary key, email varchar(128), - name varchar(30) + name varchar(30), + name varchar(128), + dragonProgress int, + dragonsLandmarkIDs longtext ) engine=InnoDB; diff --git a/src/main/resources/static/css/qrstyle.css b/src/main/resources/static/css/qrstyle.css new file mode 100644 index 0000000000000000000000000000000000000000..b0c851a93e488b09a7ebb4c36b09579ac7dedf88 --- /dev/null +++ b/src/main/resources/static/css/qrstyle.css @@ -0,0 +1,65 @@ +/*style sheet for QR code - R Nute*/ +/*Modified from (https://www.geeksforgeeks.org/create-a-qr-code-scanner-or-reader-in-html-css-javascript/)*/ + +body { + display: flex; + justify-content: center; + margin: 0; + padding: 0; + height: 100vh; + box-sizing: border-box; + text-align: center; + background: rgb(84 33 128 / 66%); +} +.container { + width: 100%; + max-width: 500px; + margin: 5px; +} +.container h1 { + color: rgb(84 33 128); +} +.section { + background-color: rgb(84 33 128); + padding: 50px 30px; + border: 2px solid #b2b2b2; + border-radius: 0.5em; + box-shadow: 0 20px 25px rgba(0, 0, 0, 30); +} +#qr-code-reader { + padding: 20px !important; + border: 2px solid #b2b2b2 !important; + border-radius: 10px; +} +#qr-code-reader img[alt="Information icon"] { + display: none; +} +#qr-code-reader img[alt="QR Code Scan"] { + width: 100px !important; + height: 100px !important; +} +button { + padding: 15px 25px; + border: 2px solid #b2b2b2; + outline: none; + border-radius: 0.5em; + color: grey; + font-size: 25px; + cursor: default; + margin-top: 20px; + margin-bottom: 15px; + background-color: rgb(84 33 128); + transition: 0.5s background-color; +} +button:hover { + background-color: rgb(84 33 128); +} +#html-qrcode-scan-type-change { + text-decoration: none !important; + color: #1d9bf0; +} +stickers { + width: 100% !important; + border: 2px solid #b2b2b2 !important; + border-radius: 0.5em; +} diff --git a/src/main/resources/static/images/QRAllTrails.png b/src/main/resources/static/images/QRAllTrails.png new file mode 100644 index 0000000000000000000000000000000000000000..ed1d4465b3c286eba618b9a459b5a35295bacc8d Binary files /dev/null and b/src/main/resources/static/images/QRAllTrails.png differ diff --git a/src/main/resources/static/images/QR_code_for_mobile_English_Wikipedia.svg.png b/src/main/resources/static/images/QR_code_for_mobile_English_Wikipedia.svg.png new file mode 100644 index 0000000000000000000000000000000000000000..a66fb3c2a1596251164075828413368656bfb0c9 Binary files /dev/null and b/src/main/resources/static/images/QR_code_for_mobile_English_Wikipedia.svg.png differ diff --git a/src/main/resources/static/qr-scanner.html b/src/main/resources/static/qr-scanner.html new file mode 100644 index 0000000000000000000000000000000000000000..2e93c18b5decfdb0f2b2f3e390e87dd9a8600661 --- /dev/null +++ b/src/main/resources/static/qr-scanner.html @@ -0,0 +1,29 @@ +<!--setup html page for QR codes - R Nute--> +<!--Modified from (https://www.geeksforgeeks.org/create-a-qr-code-scanner-or-reader-in-html-css-javascript/)--> + +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewpoint" content="width-device-width, initial-scale=1.0"> + <link rel="stylesheet" href="css/templatingstyle.css"> + <link rel="stylesheet" href="css/qrstyle.css"> + <script src="https://unpkg.com/html5-qrcode"></script> + <script type="module" src="scripts/qr-script.js"></script> + <title>QR Code</title> +</head> + +<body> + <header th:insert="towns/Templating.html :: header"></header> + + <div class="container"> + <h1>Scan location QR code</h1> + <div class="section"> + <div id="qr-code-reader"> + </div> + </div> + </div> + + <div th:insert="towns/Templating.html :: footer"></div> +</body> +</html> diff --git a/src/main/resources/static/scripts/qr-script.js b/src/main/resources/static/scripts/qr-script.js new file mode 100644 index 0000000000000000000000000000000000000000..ff2bbf82d70a4bbf152239e568ccc7052b4c8438 --- /dev/null +++ b/src/main/resources/static/scripts/qr-script.js @@ -0,0 +1,28 @@ +//qr-script file - R Nute +//Modified from (https://www.geeksforgeeks.org/create-a-qr-code-scanner-or-reader-in-html-css-javascript/) +function domReady(fn){ + if ( + document.readyState === "complete" || + document.readyState === "interactive" + ){ + setTimeout(fn, 1000); + } else { + document.addEventListener("DOMContentLoaded", fn); + } +} +domReady(function (message){ + //if QR code found + function onScanSuccess(decodeText, decodeResult){ + alert("You have collected: " + decodeText, decodeResult); + // Open the result, what methods are available through the HTML5 Qr scanner node package? + window.open(decodeText); + // Record the result, see above. + // Get user and tie to user account, intergrate with database, retrieving and storing under user info. + } + let htmlscanner = new Html5QrcodeScanner( + "qr-code-reader", + { fps: 20, qrbos: 250} + ); + htmlscanner.render(onScanSuccess); +}); +