diff --git a/dist/index.d.ts b/dist/index.d.ts index 48d4934..d97243a 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -22,10 +22,6 @@ interface ScanConfigOptions { * 网页扫码成功提示音是否启用,默认启用 */ webScanBeepEnabled?: boolean, - /** - * BarcodeDetector polyfill 地址,默认使用 jsDelivr CDN - */ - webBarcodeDetectorPolyfillUrl?: string, /** * 微信JSSDK配置,微信环境才会生效,配置后会自动初始化微信JSSDK */ diff --git a/dist/index.js b/dist/index.js index da98a9b..5160c83 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -!function(A){var n={};function t(e){if(n[e])return n[e].exports;var r=n[e]={i:e,l:!1,exports:{}};return A[e].call(r.exports,r,r.exports,t),r.l=!0,r.exports}t.m=A,t.c=n,t.d=function(A,n,e){t.o(A,n)||Object.defineProperty(A,n,{enumerable:!0,get:e})},t.r=function(A){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(A,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(A,"__esModule",{value:!0})},t.t=function(A,n){if(1&n&&(A=t(A)),8&n)return A;if(4&n&&"object"==typeof A&&A&&A.__esModule)return A;var e=Object.create(null);if(t.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:A}),2&n&&"string"!=typeof A)for(var r in A)t.d(e,r,function(n){return A[n]}.bind(null,r));return e},t.n=function(A){var n=A&&A.__esModule?function(){return A.default}:function(){return A};return t.d(n,"a",n),n},t.o=function(A,n){return Object.prototype.hasOwnProperty.call(A,n)},t.p="",t(t.s=7)}([function(A,n,t){"use strict";n.__esModule=!0;var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A};n.getVersion=function(){return r.version},n.getConfig=function(A){return Object.prototype.hasOwnProperty.call(i,A)?i[A]:Object.prototype.hasOwnProperty.call(o,A)?o[A]:void 0},n.setConfig=function(A){A&&"object"==(void 0===A?"undefined":e(A))&&Object.assign(i,A)};var r={version:"0.0.1.0430.1530"},o={},i={}},function(A,n,t){"use strict";n.__esModule=!0;var e;e="undefined"!=typeof GameGlobal?Object.assign({},GameGlobal):"undefined"==typeof window?{setTimeout:function(A){function n(){return A.apply(this,arguments)}return n.toString=function(){return A.toString()},n}((function(){return setTimeout.apply(void 0,arguments)})),setInterval:function(A){function n(){return A.apply(this,arguments)}return n.toString=function(){return A.toString()},n}((function(){return setInterval.apply(void 0,arguments)})),clearTimeout:function(A){function n(){return A.apply(this,arguments)}return n.toString=function(){return A.toString()},n}((function(){return clearTimeout.apply(void 0,arguments)})),clearInterval:function(A){function n(){return A.apply(this,arguments)}return n.toString=function(){return A.toString()},n}((function(){return clearInterval.apply(void 0,arguments)}))}:window,n.default=e},function(A,n,t){"use strict";n.__esModule=!0,n.createUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(A){var n=16*Math.random()|0;return("x"==A?n:3&n|8).toString(16)}))}},function(A,n,t){"use strict";n.__esModule=!0,n.isReadyCalled=function(){return u},t(8);var e=t(0),r=t(13),o=t(6),i=t(5),c=null,u=!1;n.default=Object.assign({},{config:function(A){return A&&(0,e.setConfig)(A),c||(c=Promise.resolve().then((function(){return(0,i.printDebug)("-------------------------------------"),(0,i.printDebug)("sdk_version:",(0,e.getVersion)()),(0,i.printDebug)("-------------------------------------"),(0,o.initWxJssdk)(),Promise.resolve().then((function(){u=!0})).catch((function(A){throw c=null,A}))})))},onScanListener:r.onScanListener,offScanListener:r.offScanListener,setStatusListener:r.setStatusListener,getStatus:r.getStatus,startScan:r.startScan,stopScan:r.stopScan,scanImage:r.scanImage,clear:r.clear})},function(A,n,t){"use strict";n.__esModule=!0;var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A};n.toAny=function(A,n){if(null==A)return n;var t=function(A){if("string"!=typeof A)return void 0===A?"undefined":e(A);try{var n=JSON.parse(A);return void 0===n?"undefined":e(n)}catch(n){var t=parseFloat(A);return isNaN(t)||""+t!==A?"string":"number"}}(A);switch(null!=n&&(t=void 0===n?"undefined":e(n)),t){case"number":return function(A){try{return JSON.parse(A)}catch(n){return parseFloat(A)}}(A);case"boolean":return function(A){return!!A&&"false"!=A&&"0"!=A}(A);case"object":return function(A,n){if("object"===(void 0===A?"undefined":e(A)))return A;try{return JSON.parse(A)}catch(A){}return n}(A,n);case"string":return function(A,n){try{var t=void 0===A?"undefined":e(A);if("string"===t)return A;if("boolean"===t)return A?"true":"false";if("number"===t)return""+A;if("object"===t)return JSON.stringify(A)}catch(A){}return n}(A,n)}return n}},function(A,n,t){"use strict";n.__esModule=!0,n.printError=function(A){for(var n,t=arguments.length,e=Array(t>1?t-1:0),r=1;r1?t-1:0),r=1;r1?t-1:0),r=1;r1)for(var t=1;t0?(0,i.startScanner)((function(A){!function(A){if(function(A){for(var n=0;n=0&&t.splice(e,1)}},n.bridgeSync=f,n.bridgeAsync=function(A,n,t){return new Promise((function(e,r){if(s()){var i=!1,u=null;t>0&&(u=setTimeout((function(){i=!0,u=null,r("bridgeAsync timeout")}),t));var a=(0,o.createUUID)()+"_"+Date.now();!function(A,n){n&&(c[A]=n)}(a,(function(A,n){i||(u&&clearTimeout(u),0==A?e(n):r(n))})),f(A,Object.assign({request_id:a},n))}else r("Can't bridgeAsync, because not in runtime")})).then((function(t){var e=[A];return n&&(e.push("params:"),e.push(n)),t&&(e.push("resp:"),e.push(t)),r.printDebug.apply(void 0,["bridge resp >>>"].concat(e)),t})).catch((function(t){throw n?(0,r.printWarn)("bridge err >>>",A,"params:",n,t):(0,r.printWarn)("bridge err >>>",A,t),t}))};var e=t(4),r=t(5),o=t(2),i={},c={},u="__bridge_client__";function a(){var A=u+"_handle_callback";window[A]||(window[A]=function(A){var n=(0,e.toAny)(A,{}),t=n.method,r=n.payload,o=n.code,u=n.request_id,a=(0,e.toAny)(r,{});u?c[u]&&c[u](o,a):i[t]&&i[t].forEach((function(A){A&&A(a)}))})}function s(){return!!window[u]}function f(A,n){a();var t=(0,e.toAny)(function(A){for(var n=A.split("."),t=window;n.length>1;)t=t[n.shift()];if(t&&1==n.length&&t.hasOwnProperty(n[0])){for(var e,r=arguments.length,o=Array(r>1?r-1:0),i=1;i>>"].concat(o)),t}},function(A,n,t){"use strict";n.__esModule=!0,n.isSupportWebScan=function(){return"undefined"!=typeof navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia&&!!f()},n.isSupportImageScan=function(){return"undefined"!=typeof document&&"undefined"!=typeof URL&&URL.createObjectURL},n.stopScanForWeb=function(){return Promise.resolve().then((function(){o.uuid=null}))},n.startScanForImage=function(){return l((0,r.getConfig)("webScanType")).then((function(A){return new Promise((function(A){var n=document.createElement("input");n.type="file",n.accept="image/*",n.style.display="none";var t=!1,e=function(n){t||(t=!0,u("__webscan_image_input__"),A(n))};n.id="__webscan_image_input__",n.onchange=function(){e(n.files&&n.files[0])},n.oncancel=function(){e(null)},document.body.appendChild(n),n.click()})).then((function(n){return function(A,n){return n?"undefined"!=typeof createImageBitmap?createImageBitmap(n).then((function(n){return A.detect(n).then((function(A){return n.close&&n.close(),A&&A[0]})).catch((function(A){throw n.close&&n.close(),A}))})):new Promise((function(t,e){var r=new Image,o=URL.createObjectURL(n);r.onload=function(){A.detect(r).then((function(A){URL.revokeObjectURL(o),t(A&&A[0])})).catch((function(A){URL.revokeObjectURL(o),e(A)}))},r.onerror=function(A){URL.revokeObjectURL(o),e(A)},r.src=o})):Promise.resolve(null)}(A,n)}))})).then((function(A){return A&&A.rawValue?{result:A.rawValue}:{success:!1,error:"未识别到二维码或条形码"}}))},n.startScanForWeb=function(A,n){return new Promise((function(t,c){try{o.uuid=(0,e.createUUID)(),o.finish=!1;var u,f=a("video","__webscan_video__","display: none",!1),g=!1!==(0,r.getConfig)("webCanvasEnabled"),d=A||"position: fixed; width: 300px; height: 240px; top: 0; left: 0; z-index: 9999;",p=a("canvas","__webscan_canvas__",d+" display: none;",!0);p.style.display,p.style.cssText=d,u=p.style.display,p.style.display="none";var C=p.getContext("2d"),h=o.uuid;f.width=300,f.height=300,f.uuid=o.uuid,l((0,r.getConfig)("webScanType")).then((function(A){return navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}}).then((function(n){return{detector:A,stream:n}}))})).then((function(A){var e=A.detector,a=A.stream;f.srcObject=a,f.setAttribute("playsinline",!0),f.play(),p.style.display="none";var l=!1,d=!1,w=!1,v=function(){if(!w){w=!0;try{a.getTracks()[0].stop()}catch(A){}}};requestAnimationFrame((function(){!function A(){try{f.readyState!==f.HAVE_ENOUGH_DATA||l||(p.height=f.videoHeight,p.width=f.videoWidth,C.setTransform(-1,0,0,1,p.width,0),C.drawImage(f,0,0,p.width,p.height),C.setTransform(1,0,0,1,0,0),g&&!d&&(d=!0,p.style.display=u||""),l=!0,e.detect(f).then((function(A){var e=A&&A[0];if(e&&e.rawValue&&o.uuid==h){if(!n||!n(e.rawValue))return;!function(A,n,t){var e=t.cornerPoints;if(e&&e.length)for(var r=0;r1&&(t[n[0]]=n[1])}})),a.status>=200&&a.status<300){var e={errMsg:"request:ok"};try{var r=JSON.parse(a.response);e.data=r}catch(A){e.data=a.response}e.header=t,e.statusCode=a.status,A.success&&A.success(e)}else A.fail&&A.fail({errMsg:"request:fail",data:a.response,header:t})}},a.send(n)}(Object.assign({},{url:n,method:t,data:s,headers:c,json:u,timeout:a},{success:A,fail:e}))})).then((function(A){if(A.statusCode&&200!=A.statusCode)throw A;return A}))};var e=t(2),r=t(18),o=t(19)},function(A,n,t){"use strict";n.__esModule=!0,n.hex_md5=function(A){return d(r(l(A),A.length*e))},n.b64_md5=function(A){return p(r(l(A),A.length*e))},n.str_md5=function(A){return g(r(l(A),A.length*e))},n.hex_hmac_md5=function(A,n){return d(s(A,n))},n.b64_hmac_md5=function(A,n){return p(s(A,n))},n.str_hmac_md5=function(A,n){return g(s(A,n))};var e=8;function r(A,n){A[n>>5]|=128<>>9<<4)]=n;for(var t=1732584193,e=-271733879,r=-1732584194,o=271733878,s=0;s>>32-n}(f(f(n,A),f(e,o)),r),t)}function i(A,n,t,e,r,i,c){return o(n&t|~n&e,A,n,r,i,c)}function c(A,n,t,e,r,i,c){return o(n&e|t&~e,A,n,r,i,c)}function u(A,n,t,e,r,i,c){return o(n^t^e,A,n,r,i,c)}function a(A,n,t,e,r,i,c){return o(t^(n|~e),A,n,r,i,c)}function s(A,n){var t=l(A);t.length>16&&(t=r(t,A.length*e));for(var o=Array(16),i=Array(16),c=0;c<16;c++)o[c]=909522486^t[c],i[c]=1549556828^t[c];var u=r(o.concat(l(n)),512+n.length*e);return r(i.concat(u),640)}function f(A,n){var t=(65535&A)+(65535&n);return(A>>16)+(n>>16)+(t>>16)<<16|65535&t}function l(A){for(var n=Array(),t=(1<>5]|=(A.charCodeAt(r/e)&t)<>5]>>>r%32&t);return n}function d(A){for(var n="0123456789abcdef",t="",e=0;e<4*A.length;e++)t+=n.charAt(A[e>>2]>>e%4*8+4&15)+n.charAt(A[e>>2]>>e%4*8&15);return t}function p(A){for(var n="",t=0;t<4*A.length;t+=3)for(var e=(A[t>>2]>>t%4*8&255)<<16|(A[t+1>>2]>>(t+1)%4*8&255)<<8|A[t+2>>2]>>(t+2)%4*8&255,r=0;r<4;r++)8*t+6*r>32*A.length?n+="":n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e>>6*(3-r)&63);return n}},function(A,n,t){"use strict";n.__esModule=!0,n.stringifyQuery=function(A){return Object.keys(A).map((function(n){var t=A[n];return n+"="+encodeURIComponent(t)})).join("&")},n.decodeQuery=function(A){return Object.keys(A).reduce((function(n,t){var e=A[t];return n[t]=decodeURIComponent(e),n}),{})},n.parseQueryParams=r,n.appendQueryParams=function(A){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=r(A),e=t.url,o=t.params;Object.keys(n).forEach((function(A){var t=n[A];null!=t?o[A]=t:delete o[A]}));var i=Object.keys(o).map((function(A){var n=o[A];return A+"="+encodeURIComponent(n)})).join("&");return e?i?e+"?"+i:e:i},n.getQueryString=function(A,n){var t=e.default.location.search,r=new RegExp("(^|&)"+A+"=([^&]*)(&|$)"),o=t.substr(1).match(r);return null!=o?decodeURIComponent(unescape(o[2])):n};var e=function(A){return A&&A.__esModule?A:{default:A}}(t(1));function r(A){var n="",t={};if(!A||"string"!=typeof A)return{url:n,params:t};var e="",r=A.indexOf("?"),o=A.indexOf("#"),i=A.indexOf("=");return r>=0?(n=A.substring(0,r),e=A.substring(r+1,o>0?o:A.length)):i>=0?(n="",e=A):(n=A,e=""),e.split("&").map((function(A){var n=A.indexOf("=");if(n>0){var e=A.substring(0,n),r=A.substring(n+1);t[e]=decodeURIComponent(r)}})),{url:n,params:t}}},function(A,n,t){"use strict";n.__esModule=!0,n.startScanner=function(A){A&&"function"==typeof A&&(e=A,"scanning"!==r&&(r="scanning",u(),window.addEventListener("keydown",a)))},n.stopScanner=function(){"scanning"===r&&(r="closed",e=null,u(),window.removeEventListener("keydown",a))};var e=null,r="closed",o="",i=null,c=0;function u(){o="",c=0,i&&(clearTimeout(i),i=null)}function a(A){if("scanning"===r&&!(A.ctrlKey||A.metaKey||A.altKey)){if("Enter"===A.key){var n=function(A){return A.replace(/[\uFF01-\uFF5E]/g,(function(A){return String.fromCharCode(A.charCodeAt(0)-65248)})).replace(/\u3002/g,".")}(o);return n&&function(A){A.preventDefault&&A.preventDefault(),A.stopPropagation&&A.stopPropagation()}(A),u(),void(n&&e&&e(n))}if(A.key&&1===A.key.length){var t=Date.now();c&&t-c>100&&u(),c=t,o+=A.key,i&&clearTimeout(i),i=setTimeout((function(){u()}),100)}}}},function(A,n,t){"use strict";n.__esModule=!0;var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A};n.exportSDK=function(A,n){for(var t=arguments.length,o=Array(t>2?t-2:0),i=2;i1&&void 0!==arguments[1]?arguments[1]:"",r={};return Object.keys(n).forEach((function(o){var i=n[o];if("object"===(void 0===i?"undefined":e(i)))Object.assign(r,A(i,""+t+o+"."));else if("function"==typeof i){var c,u=""+t+o;Object.assign(r,((c={})[u]=u,c))}})),r}(A);var u={};return Object.keys(c).forEach((function(n){var t=c[n],e=t&&t.method||n;!function(A,n,t){var e=n.split(".");e.forEach((function(n,r){r==e.length-1?A[n]=t:A[n]||(A[n]={}),A=A[n]}))}(u,n,(function(){for(var t=arguments.length,i=Array(t),c=0;c1;)t=t[e.shift()];if(t&&1==e.length&&t.hasOwnProperty(e[0])){for(var r,o=arguments.length,i=Array(o>2?o-2:0),c=2;ct[5]),r.filter(t=>"*"===t[1]).map(t=>t[0]),r.filter(t=>"*"!==t[1]).map(t=>t[0]),r.filter(t=>" "===t[2]).map(t=>t[0]),r.filter(t=>"l"===t[3][0]).map(t=>t[0]),r.filter(t=>"m"===t[3][0]).map(t=>t[0]),r.filter(t=>"r"===t[3][1]).map(t=>t[0]),r.filter(t=>"w"===t[3][2]||0!==t[4]).map(t=>t[0]),r.filter(t=>"G"===t[3][3]).map(t=>t[0]),r.filter(t=>"R"===t[3][4]).map(t=>t[0]),r.filter(t=>"I"===t[3][4]).map(t=>t[0]);var i=["LocalAverage","GlobalHistogram","FixedThreshold","BoolCast"];function A(t){return i.indexOf(t)}var u="Unknown.ASCII.ISO8859_1.ISO8859_2.ISO8859_3.ISO8859_4.ISO8859_5.ISO8859_6.ISO8859_7.ISO8859_8.ISO8859_9.ISO8859_10.ISO8859_11.ISO8859_13.ISO8859_14.ISO8859_15.ISO8859_16.Cp437.Cp1250.Cp1251.Cp1252.Cp1256.Shift_JIS.Big5.GB2312.GB18030.EUC_JP.EUC_KR.UTF16BE.UTF8.UTF16LE.UTF32BE.UTF32LE.BINARY".split(".");function c(t){return"UnicodeBig"===t?u.indexOf("UTF16BE"):u.indexOf(t)}var s=["Text","Binary","Mixed","GS1","ISO15434","UnknownECI"];function l(t){return s[t]}var f=["Ignore","Read","Require"];function d(t){return f.indexOf(t)}var h=["Plain","ECI","HRI","Escaped","Hex","HexECI"];function g(t){return h.indexOf(t)}var p={formats:[],tryHarder:!0,tryRotate:!0,tryInvert:!0,tryDownscale:!0,tryDenoise:!1,binarizer:"LocalAverage",isPure:!1,downscaleFactor:3,downscaleThreshold:500,minLineCount:2,maxNumberOfSymbols:255,validateOptionalChecksum:!1,returnErrors:!1,eanAddOnSymbol:"Ignore",textMode:"HRI",characterSet:"Unknown",tryCode39ExtendedMode:!0};function v(t){var e;return{...t,formats:a(t.formats),binarizer:A(t.binarizer),eanAddOnSymbol:d(t.eanAddOnSymbol),textMode:g(t.textMode),characterSet:c(t.characterSet),tryCode39ExtendedMode:null==(e=t.tryCode39ExtendedMode)||e}}function y(t){return{...t,format:t.format,symbology:t.symbology,contentType:l(t.contentType)}}var m={locateFile:(t,e)=>{let r=t.match(/_(.+?)\.wasm$/);return r?`https://fastly.jsdelivr.net/npm/zxing-wasm@3.0.2/dist/${r[1]}/${t}`:e+t}},w=new WeakMap;function C(t,e){return Object.is(t,e)||Object.keys(t).length===Object.keys(e).length&&Object.keys(t).every(r=>Object.hasOwn(e,r)&&t[r]===e[r])}function b(t,{overrides:e,equalityFn:r=C,fireImmediately:n=!1}={}){var o,a;let i,[A,u]=null==(o=w.get(t))?[m]:o,c=null==e?A:e;if(n){if(u&&(i=r(A,c)))return u;let e=t({...c});return w.set(t,[c,e]),e}(null==(a=i)?r(A,c):a)||w.set(t,[c])}async function B(t,e,r=p){let n,o,a={...p,...r},i=await b(t,{fireImmediately:!0});if("width"in e&&"height"in e&&"data"in e){let{data:t,width:r,height:A}=e,u=function(t){let e=t.byteLength>>2,r=new Uint8Array(e);for(let n=0;n>10}return r}(t),c=u.byteLength;if(o=i._malloc(c),!o)throw Error(`Failed to allocate ${c} bytes in WASM memory`);try{i.HEAPU8.set(u,o),n=i.readBarcodesFromPixmap(o,r,A,v(a))}finally{i._free(o)}}else{let t,r;if("buffer"in e)[t,r]=[e.byteLength,e];else if("byteLength"in e)[t,r]=[e.byteLength,new Uint8Array(e)];else{if(!("size"in e))throw TypeError("Invalid input type");[t,r]=[e.size,new Uint8Array(await e.arrayBuffer())]}if(o=i._malloc(t),!o)throw Error(`Failed to allocate ${t} bytes in WASM memory`);try{i.HEAPU8.set(r,o),n=i.readBarcodesFromImage(o,t,v(a))}finally{i._free(o)}}let A=[];for(let t=0;t{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),A=async t=>{var e=await fetch(t,{credentials:"same-origin"});if(e.ok)return e.arrayBuffer();throw Error(e.status+" : "+e.url)}}var l,f,d,h,g=console.log.bind(console),p=console.error.bind(console),v=!1,y=!1;function m(){var t=Oe.buffer;S=new Int8Array(t),E=new Int16Array(t),n.HEAPU8=O=new Uint8Array(t),T=new Uint16Array(t),I=new Int32Array(t),x=new Uint32Array(t),D=new Float32Array(t),Q=new Float64Array(t)}function w(t){var e,r;null==(e=n.onAbort)||e.call(n,t),p(t="Aborted("+t+")"),v=!0,t+=". Build with -sASSERTIONS for more info.";var o=new WebAssembly.RuntimeError(t);throw null==(r=d)||r(o),o}function C(){return function(t){return n.locateFile?n.locateFile(t,s):s+t}("zxing_reader.wasm")}async function b(t){if(!l)try{var e=await A(t);return new Uint8Array(e)}catch{}return function(t){if(t==h&&l)return new Uint8Array(l);if(u)return u(t);throw"both async and sync fetching of the wasm failed"}(t)}async function B(t,e,r){if(!t&&WebAssembly.instantiateStreaming)try{var n=fetch(e,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(n,r)}catch(t){p("wasm streaming compile failed: "+t),p("falling back to ArrayBuffer instantiation")}return async function(t,e){try{var r=await b(t);return await WebAssembly.instantiate(r,e)}catch(t){p("failed to asynchronously prepare wasm: "+t),w(t)}}(e,r)}var E,I,S,D,Q,T,x,O,F=t=>{for(;t.length>0;)t.shift()(n)},R=[],V=t=>R.push(t),M=[],P=t=>M.push(t),U=t=>Ee(t),_=()=>Ie(),k=[],j=0,W=0;class G{constructor(t){this.excPtr=t,this.ptr=t-24}set_type(t){x[this.ptr+4>>2]=t}get_type(){return x[this.ptr+4>>2]}set_destructor(t){x[this.ptr+8>>2]=t}get_destructor(){return x[this.ptr+8>>2]}set_caught(t){t=t?1:0,S[this.ptr+12]=t}get_caught(){return 0!=S[this.ptr+12]}set_rethrown(t){t=t?1:0,S[this.ptr+13]=t}get_rethrown(){return 0!=S[this.ptr+13]}init(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)}set_adjusted_ptr(t){x[this.ptr+16>>2]=t}get_adjusted_ptr(){return x[this.ptr+16>>2]}}var L=t=>Be(t),q=t=>{var e=W;if(!e)return L(0),0;var r=new G(e);r.set_adjusted_ptr(e);var n=r.get_type();if(!n)return L(0),e;for(var o of t){if(0===o||o===n)break;var a=r.ptr+16;if(Qe(o,n,a))return L(o),e}return L(n),e},J={},Z=t=>{for(;t.length;){var e=t.pop();t.pop()(e)}};function K(t){return this.fromWireType(x[t>>2])}var H={},N={},Y={},z=class extends Error{constructor(t){super(t),this.name="InternalError"}},X=t=>{throw new z(t)},$=(t,e,r)=>{function n(e){var n=r(e);n.length!==t.length&&X("Mismatched type converter count");for(var o=0;oY[t]=e);var o=Array(e.length),a=[],i=0;{let t=e;for(let e=0;e{o[e]=N[r],++i===a.length&&n(o)}))}}0===a.length&&n(o)},tt=t=>{for(var e="";;){var r=O[t++];if(!r)return e;e+=String.fromCharCode(r)}},et=class extends Error{constructor(t){super(t),this.name="BindingError"}},rt=t=>{throw new et(t)};function nt(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var n=e.name;if(t||rt(`type "${n}" must have a positive integer typeid pointer`),N.hasOwnProperty(t)){if(r.ignoreDuplicateRegistrations)return;rt(`Cannot register type '${n}' twice`)}if(N[t]=e,delete Y[t],H.hasOwnProperty(t)){var o=H[t];delete H[t],o.forEach(t=>t())}}function ot(t,e){return nt(t,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}var at=t=>({count:t.count,deleteScheduled:t.deleteScheduled,preservePointerOnDelete:t.preservePointerOnDelete,ptr:t.ptr,ptrType:t.ptrType,smartPtr:t.smartPtr,smartPtrType:t.smartPtrType}),it=t=>{rt(function(t){return t.$$.ptrType.registeredClass.name}(t)+" instance already deleted")},At=!1,ut=t=>{},ct=t=>{--t.count.value,0===t.count.value&&(t=>{t.smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr)})(t)},st=t=>globalThis.FinalizationRegistry?(At=new FinalizationRegistry(t=>{ct(t.$$)}),ut=t=>At.unregister(t),(st=t=>{var e=t.$$;if(e.smartPtr){var r={$$:e};At.register(t,r,t)}return t})(t)):(st=t=>t,t),lt=[];function ft(){}var dt=(t,e)=>Object.defineProperty(e,"name",{value:t}),ht={},gt=(t,e,r)=>{if(void 0===t[e].overloadTable){var n=t[e];t[e]=function(){var n=[...arguments];return t[e].overloadTable.hasOwnProperty(n.length)||rt(`Function '${r}' called with an invalid number of arguments (${n.length}) - expects one of (${t[e].overloadTable})!`),t[e].overloadTable[n.length].apply(this,n)},t[e].overloadTable=[],t[e].overloadTable[n.argCount]=n}},pt=(t,e,r)=>{n.hasOwnProperty(t)?((void 0===r||void 0!==n[t].overloadTable&&void 0!==n[t].overloadTable[r])&&rt(`Cannot register public name '${t}' twice`),gt(n,t,t),n[t].overloadTable.hasOwnProperty(r)&&rt(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),n[t].overloadTable[r]=e):(n[t]=e,n[t].argCount=r)};function vt(t,e,r,n,o,a,i,A){this.name=t,this.constructor=e,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=o,this.getActualType=a,this.upcast=i,this.downcast=A,this.pureVirtualFunctions=[]}var yt=(t,e,r)=>{for(;e!==r;)e.upcast||rt(`Expected null or instance of ${r.name}, got an instance of ${e.name}`),t=e.upcast(t),e=e.baseClass;return t},mt=t=>{if(null===t)return"null";var e=typeof t;return"object"===e||"array"===e||"function"===e?t.toString():""+t};function wt(t,e){if(null===e)return this.isReference&&rt("null is not a valid "+this.name),0;e.$$||rt(`Cannot pass "${mt(e)}" as a ${this.name}`),e.$$.ptr||rt("Cannot pass deleted object as a pointer of type "+this.name);var r=e.$$.ptrType.registeredClass;return yt(e.$$.ptr,r,this.registeredClass)}function Ct(t,e){var r;if(null===e)return this.isReference&&rt("null is not a valid "+this.name),this.isSmartPointer?(r=this.rawConstructor(),null!==t&&t.push(this.rawDestructor,r),r):0;(!e||!e.$$)&&rt(`Cannot pass "${mt(e)}" as a ${this.name}`),e.$$.ptr||rt("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&e.$$.ptrType.isConst&&rt(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);var n=e.$$.ptrType.registeredClass;if(r=yt(e.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===e.$$.smartPtr&&rt("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:e.$$.smartPtrType===this?r=e.$$.smartPtr:rt(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:r=e.$$.smartPtr;break;case 2:if(e.$$.smartPtrType===this)r=e.$$.smartPtr;else{var o=e.clone();r=this.rawShare(r,Zt.toHandle(()=>o.delete())),null!==t&&t.push(this.rawDestructor,r)}break;default:rt("Unsupported sharing policy")}return r}function bt(t,e){if(null===e)return this.isReference&&rt("null is not a valid "+this.name),0;e.$$||rt(`Cannot pass "${mt(e)}" as a ${this.name}`),e.$$.ptr||rt("Cannot pass deleted object as a pointer of type "+this.name),e.$$.ptrType.isConst&&rt(`Cannot convert argument of type ${e.$$.ptrType.name} to parameter type ${this.name}`);var r=e.$$.ptrType.registeredClass;return yt(e.$$.ptr,r,this.registeredClass)}var Bt=(t,e,r)=>{if(e===r)return t;if(void 0===r.baseClass)return null;var n=Bt(t,e,r.baseClass);return null===n?null:r.downcast(n)},Et={},It=(t,e)=>(e=((t,e)=>{for(void 0===e&&rt("ptr should not be undefined");t.baseClass;)e=t.upcast(e),t=t.baseClass;return e})(t,e),Et[e]),St=(t,e)=>((!e.ptrType||!e.ptr)&&X("makeClassHandle requires ptr and ptrType"),!!e.smartPtrType!=!!e.smartPtr&&X("Both smartPtrType and smartPtr must be specified"),e.count={value:1},st(Object.create(t,{$$:{value:e,writable:!0}})));function Dt(t){var e=this.getPointee(t);if(!e)return this.destructor(t),null;var r=It(this.registeredClass,e);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=e,r.$$.smartPtr=t,r.clone();var n=r.clone();return this.destructor(t),n}function o(){return this.isSmartPointer?St(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:e,smartPtrType:this,smartPtr:t}):St(this.registeredClass.instancePrototype,{ptrType:this,ptr:t})}var a=ht[this.registeredClass.getActualType(e)];if(!a)return o.call(this);var i=this.isConst?a.constPointerType:a.pointerType,A=Bt(e,this.registeredClass,i.registeredClass);return null===A?o.call(this):this.isSmartPointer?St(i.registeredClass.instancePrototype,{ptrType:i,ptr:A,smartPtrType:this,smartPtr:t}):St(i.registeredClass.instancePrototype,{ptrType:i,ptr:A})}function Qt(t,e,r,n,o,a,i,A,u,c,s){this.name=t,this.registeredClass=e,this.isReference=r,this.isConst=n,this.isSmartPointer=o,this.pointeeType=a,this.sharingPolicy=i,this.rawGetPointee=A,this.rawConstructor=u,this.rawShare=c,this.rawDestructor=s,o||void 0!==e.baseClass?this.toWireType=Ct:n?(this.toWireType=wt,this.destructorFunction=null):(this.toWireType=bt,this.destructorFunction=null)}var Tt=(t,e,r)=>{n.hasOwnProperty(t)||X("Replacing nonexistent public symbol"),void 0!==n[t].overloadTable&&void 0!==r?n[t].overloadTable[r]=e:(n[t]=e,n[t].argCount=r)},xt={},Ot=(t,e,r)=>(t=t.replace(/p/g,"i"),(0,xt[t])(e,...r)),Ft=[],Rt=t=>{var e=Ft[t];return e||(Ft[t]=e=Fe.get(t)),e},Vt=function(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(t.includes("j"))return Ot(t,e,r);var n=Rt(e)(...r);return n},Mt=function(t,e){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function(){return Vt(t,e,[...arguments],r)}},Pt=function(t,e){function r(){return t.includes("j")?Mt(t,e):Rt(e)}t=tt(t);var n=r();return"function"!=typeof n&&rt(`unknown function pointer with signature ${t}: ${e}`),n};class Ut extends Error{}var _t=t=>{var e=ye(t),r=tt(e);return me(e),r},kt=(t,e)=>{var r=[],n={};throw e.forEach((function t(e){if(!n[e]&&!N[e]){if(Y[e])return void Y[e].forEach(t);r.push(e),n[e]=!0}})),new Ut(t+": "+r.map(_t).join([", "]))},jt=(t,e)=>{for(var r=[],n=0;n>2]);return r};function Wt(t,e,r,n,o,a){var i=e.length;i<2&&rt("argTypes array size mismatch! Must at least get return value and 'this' types!");var A=null!==e[1]&&null!==r,u=function(t){for(var e=1;e{let e=(t=t.trim()).indexOf("(");return-1===e?t:t.slice(0,e)},Lt=[],qt=[0,1,,1,null,1,!0,1,!1,1],Jt=t=>{t>9&&0==--qt[t+1]&&(qt[t]=void 0,Lt.push(t))},Zt={toValue:t=>(t||rt("Cannot use deleted val. handle = "+t),qt[t]),toHandle:t=>{switch(t){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let e=Lt.pop()||qt.length;return qt[e]=t,qt[e+1]=1,e}}}},Kt={name:"emscripten::val",fromWireType:t=>{var e=Zt.toValue(t);return Jt(t),e},toWireType:(t,e)=>Zt.toHandle(e),readValueFromPointer:K,destructorFunction:null},Ht=(t,e)=>{switch(e){case 4:return function(t){return this.fromWireType(D[t>>2])};case 8:return function(t){return this.fromWireType(Q[t>>3])};default:throw TypeError(`invalid float width (${e}): ${t}`)}},Nt=(t,e,r)=>{switch(e){case 1:return r?t=>S[t]:t=>O[t];case 2:return r?t=>E[t>>1]:t=>T[t>>1];case 4:return r?t=>I[t>>2]:t=>x[t>>2];default:throw TypeError(`invalid integer width (${e}): ${t}`)}},Yt=(t,e,r)=>{let n=(t,e)=>{let r=0;return{next(){if(r>=t)return{done:!0};let n=r;return r++,{value:e(n),done:!1}},[Symbol.iterator](){return this}}};t[Symbol.iterator]||(t[Symbol.iterator]=function(){return n(this[e](),t=>this[r](t))})},zt=Object.assign({optional:!0},Kt),Xt=(t,e,r)=>((t,e,r,n)=>{if(!(n>0))return 0;for(var o=r,a=r+n-1,i=0;i=a)break;e[r++]=A}else if(A<=2047){if(r+1>=a)break;e[r++]=192|A>>6,e[r++]=128|63&A}else if(A<=65535){if(r+2>=a)break;e[r++]=224|A>>12,e[r++]=128|A>>6&63,e[r++]=128|63&A}else{if(r+3>=a)break;e[r++]=240|A>>18,e[r++]=128|A>>12&63,e[r++]=128|A>>6&63,e[r++]=128|63&A,i++}}return e[r]=0,r-o})(t,O,e,r),$t=t=>{for(var e=0,r=0;r=55296&&n<=57343?(e+=4,++r):e+=3}return e},te=globalThis.TextDecoder&&new TextDecoder,ee=(t,e,r,n)=>{var o=e+r;if(n)return o;for(;t[e]&&!(e>=o);)++e;return e},re=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0;var o=ee(t,e,r,n);if(o-e>16&&t.buffer&&te)return te.decode(t.subarray(e,o));for(var a="";e>10,56320|1023&c)}}else a+=String.fromCharCode((31&i)<<6|A)}else a+=String.fromCharCode(i)}return a},ne=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,oe=(t,e,r)=>{var n=t>>1,o=ee(T,n,e/2,r);if(o-n>16&&ne)return ne.decode(T.subarray(n,o));for(var a="",i=n;i{if(null!=r||(r=2147483647),r<2)return 0;for(var n=e,o=(r-=2)<2*t.length?r/2:t.length,a=0;a>1]=i,e+=2}return E[e>>1]=0,e-n},ie=t=>2*t.length,Ae=(t,e,r)=>{for(var n="",o=t>>2,a=0;!(a>=e/4);a++){var i=x[o+a];if(!i&&!r)break;n+=String.fromCodePoint(i)}return n},ue=(t,e,r)=>{if(null!=r||(r=2147483647),r<4)return 0;for(var n=e,o=n+r-4,a=0;a65535&&a++,I[e>>2]=i,(e+=4)+4>o)break}return I[e>>2]=0,e-n},ce=t=>{for(var e=0,r=0;r65535&&r++,e+=4;return e},se=[],le=(t,e)=>{var r=N[t];return void 0===r&&rt(`${e} has unknown type ${_t(t)}`),r},fe={},de=t=>{var e=fe[t];return void 0===e?tt(t):e},he=(t,e)=>Math.ceil(t/e)*e,ge=t=>{var e=(t-Oe.buffer.byteLength+65535)/65536|0;try{return Oe.grow(e),m(),1}catch{}},pe={},ve=()=>{if(!ve.strings){var t,e,r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(null==(t=null==(e=globalThis.navigator)?void 0:e.language)?"C":t).replace("-","_")+".UTF-8",_:c||"./this.program"};for(var n in pe)void 0===pe[n]?delete r[n]:r[n]=pe[n];var o=[];for(var n in r)o.push(`${n}=${r[n]}`);ve.strings=o}return ve.strings};var ye,me,we,Ce,be,Be,Ee,Ie,Se,De,Qe,Te,xe,Oe,Fe,Re=[null,[],[]],Ve=(t,e)=>{var r=Re[t];0===e||10===e?((1===t?g:p)(re(r)),r.length=0):r.push(e)};if((()=>{let t=ft.prototype;Object.assign(t,{isAliasOf(t){if(!(this instanceof ft&&t instanceof ft))return!1;var e=this.$$.ptrType.registeredClass,r=this.$$.ptr;t.$$=t.$$;for(var n=t.$$.ptrType.registeredClass,o=t.$$.ptr;e.baseClass;)r=e.upcast(r),e=e.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return e===n&&r===o},clone(){if(this.$$.ptr||it(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t=st(Object.create(Object.getPrototypeOf(this),{$$:{value:at(this.$$)}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},delete(){this.$$.ptr||it(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&rt("Object already scheduled for deletion"),ut(this),ct(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||it(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&rt("Object already scheduled for deletion"),lt.push(this),lt.length,this.$$.deleteScheduled=!0,this}});let e=Symbol.dispose;e&&(t[e]=t.delete)})(),Object.assign(Qt.prototype,{getPointee(t){return this.rawGetPointee&&(t=this.rawGetPointee(t)),t},destructor(t){var e;null==(e=this.rawDestructor)||e.call(this,t)},readValueFromPointer:K,fromWireType:Dt}),n.noExitRuntime&&n.noExitRuntime,n.print&&(g=n.print),n.printErr&&(p=n.printErr),n.wasmBinary&&(l=n.wasmBinary),n.arguments&&n.arguments,n.thisProgram&&(c=n.thisProgram),n.preInit)for("function"==typeof n.preInit&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.shift()();var Me={s:t=>{var e=new G(t);return e.get_caught()||(e.set_caught(!0),j--),e.set_rethrown(!1),k.push(e),Ce(t)},x:()=>{be(0,0);var t=k.pop();Se(t.excPtr),W=0},a:()=>q([]),i:t=>q([t]),m:(t,e)=>q([t,e]),Q:()=>{var t=k.pop();t||w("no exception to throw");var e=t.excPtr;throw t.get_rethrown()||(k.push(t),t.set_rethrown(!0),t.set_caught(!1),j++),De(e),W=e},q:(t,e,r)=>{throw new G(t).init(e,r),De(t),j++,W=t},fa:()=>j,d:t=>{throw W||(W=t),W},ba:()=>w(""),wa:t=>{var e=J[t];delete J[t];var r=e.rawConstructor,n=e.rawDestructor,o=e.fields,a=o.map(t=>t.getterReturnType).concat(o.map(t=>t.setterArgumentType));$([t],a,t=>{var a={};{let e=o;for(let r=0;ri.fromWireType(A(u,t)),write:(t,e)=>{var r=[];s(l,t,c.toWireType(r,e)),Z(r)},optional:i.optional}}}return[{name:e.name,fromWireType:t=>{var e={};for(var r in a)e[r]=a[r].read(t);return n(t),e},toWireType:(t,e)=>{for(var o in a)if(!(o in e)&&!a[o].optional)throw TypeError(`Missing field: "${o}"`);var i=r();for(o in a)a[o].write(i,e[o]);return null!==t&&t.push(n,i),i},readValueFromPointer:K,destructorFunction:n}]})},aa:(t,e,r,n,o)=>{},qa:(t,e,r,n)=>{ot(t,{name:e=tt(e),fromWireType:function(t){return!!t},toWireType:function(t,e){return e?r:n},readValueFromPointer:function(t){return this.fromWireType(O[t])},destructorFunction:null})},ua:(t,e,r,n,o,a,i,A,u,c,s,l,f)=>{s=tt(s),a=Pt(o,a),A&&(A=Pt(i,A)),c&&(c=Pt(u,c)),f=Pt(l,f);var d=(t=>{var e=(t=t.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return e>=48&&e<=57?"_"+t:t})(s);pt(d,(function(){kt(`Cannot construct ${s} due to unbound types`,[n])})),$([t,e,r],n?[n]:[],e=>{var r,o;e=e[0],n?o=(r=e.registeredClass).instancePrototype:o=ft.prototype;var i=dt(s,(function(){if(Object.getPrototypeOf(this)!==u)throw new et("Use 'new' to construct "+s);if(void 0===h.constructor_body)throw new et(s+" has no accessible constructor");var t=[...arguments],e=h.constructor_body[t.length];if(void 0===e)throw new et(`Tried to invoke ctor of ${s} with invalid number of parameters (${t.length}) - expected (${Object.keys(h.constructor_body).toString()}) parameters instead!`);return e.apply(this,t)})),u=Object.create(o,{constructor:{value:i}});i.prototype=u;var l,h=new vt(s,i,u,f,r,a,A,c);h.baseClass&&(null!=(l=h.baseClass).__derivedClasses||(l.__derivedClasses=[]),h.baseClass.__derivedClasses.push(h));var g=new Qt(s,h,!0,!1,!1),p=new Qt(s+"*",h,!1,!1,!1),v=new Qt(s+" const*",h,!1,!0,!1);return ht[t]={pointerType:p,constPointerType:v},Tt(d,i),[g,p,v]})},ta:(t,e,r,n,o,a)=>{var i=jt(e,r);o=Pt(n,o),$([],[t],t=>{var r="constructor "+(t=t[0]).name;if(void 0===t.registeredClass.constructor_body&&(t.registeredClass.constructor_body=[]),void 0!==t.registeredClass.constructor_body[e-1])throw new et(`Cannot register multiple constructors with identical number of parameters (${e-1}) for class '${t.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return t.registeredClass.constructor_body[e-1]=()=>{kt(`Cannot construct ${t.name} due to unbound types`,i)},$([],i,n=>(n.splice(1,0,null),t.registeredClass.constructor_body[e-1]=Wt(r,n,null,o,a),[])),[]})},F:(t,e,r,n,o,a,i,A,u,c)=>{var s=jt(r,n);e=tt(e),e=Gt(e),a=Pt(o,a,u),$([],[t],t=>{var n=`${(t=t[0]).name}.${e}`;function o(){kt(`Cannot call ${n} due to unbound types`,s)}e.startsWith("@@")&&(e=Symbol[e.substring(2)]),A&&t.registeredClass.pureVirtualFunctions.push(e);var u=t.registeredClass.instancePrototype,c=u[e];return void 0===c||void 0===c.overloadTable&&c.className!==t.name&&c.argCount===r-2?(o.argCount=r-2,o.className=t.name,u[e]=o):(gt(u,e,n),u[e].overloadTable[r-2]=o),$([],s,o=>{var A=Wt(n,o,t,a,i);return void 0===u[e].overloadTable?(A.argCount=r-2,u[e]=A):u[e].overloadTable[r-2]=A,[]}),[]})},oa:t=>ot(t,Kt),X:(t,e,r)=>{ot(t,{name:e=tt(e),fromWireType:t=>t,toWireType:(t,e)=>e,readValueFromPointer:Ht(e,r),destructorFunction:null})},Y:(t,e,r,n,o,a,i,A)=>{var u=jt(e,r);t=tt(t),t=Gt(t),o=Pt(n,o,i),pt(t,(function(){kt(`Cannot call ${t} due to unbound types`,u)}),e-1),$([],u,r=>{var n=[r[0],null].concat(r.slice(1));return Tt(t,Wt(t,n,null,o,a),e-1),[]})},A:(t,e,r,n,o)=>{e=tt(e);let a=t=>t;if(0===n){var i=32-8*r;a=t=>t<>>i,o=a(o)}ot(t,{name:e,fromWireType:a,toWireType:(t,e)=>e,readValueFromPointer:Nt(e,r,0!==n),destructorFunction:null})},sa:(t,e,r,n)=>{r=tt(r),n=tt(n),$([],[t,e],t=>{let e=t[0];return Yt(e.registeredClass.instancePrototype,r,n),[]})},t:(t,e,r)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][e];function o(t){var e=x[t>>2],r=x[t+4>>2];return new n(S.buffer,r,e)}ot(t,{name:r=tt(r),fromWireType:o,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},va:(t,e)=>{ot(t,zt)},pa:(t,e)=>{e=tt(e);ot(t,{name:e,fromWireType(t){var e,r=x[t>>2],n=t+4;return e=((t,e,r)=>t?re(O,t,e,r):"")(n,r,!0),me(t),e},toWireType(t,e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));var r,n="string"==typeof e;n||ArrayBuffer.isView(e)&&1==e.BYTES_PER_ELEMENT||rt("Cannot pass non-string to std::string"),r=n?$t(e):e.length;var o=we(4+r+1),a=o+4;(x[o>>2]=r,n)?Xt(e,a,r+1):O.set(e,a);return null!==t&&t.push(me,o),o},readValueFromPointer:K,destructorFunction(t){me(t)}})},S:(t,e,r)=>{var n,o,a;r=tt(r),2===e?(n=oe,o=ae,a=ie):(n=Ae,o=ue,a=ce),ot(t,{name:r,fromWireType:t=>{var r=x[t>>2],o=n(t+4,r*e,!0);return me(t),o},toWireType:(t,n)=>{"string"!=typeof n&&rt("Cannot pass non-string to C++ string type "+r);var i=a(n),A=we(4+i+e);return x[A>>2]=i/e,o(n,A+4,i+e),null!==t&&t.push(me,A),A},readValueFromPointer:K,destructorFunction(t){me(t)}})},G:(t,e,r,n,o,a)=>{J[t]={name:tt(e),rawConstructor:Pt(r,n),rawDestructor:Pt(o,a),fields:[]}},xa:(t,e,r,n,o,a,i,A,u,c)=>{J[t].fields.push({fieldName:tt(e),getterReturnType:r,getter:Pt(n,o),getterContext:a,setterArgumentType:i,setter:Pt(A,u),setterContext:c})},ra:(t,e)=>{ot(t,{isVoid:!0,name:e=tt(e),fromWireType:()=>{},toWireType:(t,e)=>{}})},N:(t,e,r)=>{var[n,...o]=((t,e)=>{for(var r=Array(t),n=0;n>2],"parameter "+n);return r})(t,e),a=n.toWireType.bind(n),i=o.map(t=>t.readValueFromPointer.bind(t));t--;var A=Array(t);return(t=>{var e=se.length;return se.push(t),e})(dt(`methodCaller<(${o.map(t=>t.name)}) => ${n.name}>`,(e,n,o,u)=>{for(var c=0,s=0;s{var n=[],o=t(n,r);return n.length&&(x[e>>2]=Zt.toHandle(n)),o})(a,o,l)}))},ya:Jt,C:t=>t?(t=de(t),Zt.toHandle(globalThis[t])):Zt.toHandle(globalThis),T:t=>{t>9&&(qt[t+1]+=1)},M:(t,e,r,n,o)=>se[t](e,r,n,o),ka:t=>{Z(Zt.toValue(t)),Jt(t)},ca:(t,e,r,n)=>{var o=(new Date).getFullYear(),a=new Date(o,0,1),i=new Date(o,6,1),A=a.getTimezoneOffset(),u=i.getTimezoneOffset(),c=Math.max(A,u);x[t>>2]=60*c,I[e>>2]=Number(A!=u);var s=t=>{var e=t>=0?"-":"+",r=Math.abs(t);return`UTC${e}${String(Math.floor(r/60)).padStart(2,"0")}${String(r%60).padStart(2,"0")}`},l=s(A),f=s(u);u{var e=O.length,r=2147483648;if((t>>>=0)>r)return!1;for(var n=1;n<=4;n*=2){var o=e*(1+.2/n);if(o=Math.min(o,t+100663296),ge(Math.min(r,he(Math.max(t,o),65536))))return!0}return!1},da:(t,e)=>{var r=0,n=0;for(var o of ve()){var a=e+r;x[t+n>>2]=a,r+=Xt(o,a,1/0)+1,n+=4}return 0},ea:(t,e)=>{var r=ve();x[t>>2]=r.length;var n=0;for(var o of r)n+=$t(o)+1;return x[e>>2]=n,0},ha:t=>52,_:function(t,e,r,n,o){return((t,e)=>{})(e,r),70},V:(t,e,r,n)=>{for(var o=0,a=0;a>2],A=x[e+4>>2];e+=8;for(var u=0;u>2]=o,0},ma:function(t,e,r){var n=_();try{return Rt(t)(e,r)}catch(t){if(U(n),t!==t+0)throw t;be(1,0)}},K:function(t,e,r,n){var o=_();try{return Rt(t)(e,r,n)}catch(t){if(U(o),t!==t+0)throw t;be(1,0)}},B:function(t,e,r,n,o,a){var i=_();try{return Rt(t)(e,r,n,o,a)}catch(t){if(U(i),t!==t+0)throw t;be(1,0)}},O:function(t,e,r,n,o,a){var i=_();try{return Rt(t)(e,r,n,o,a)}catch(t){if(U(i),t!==t+0)throw t;be(1,0)}},U:function(t,e,r,n){var o=_();try{return Rt(t)(e,r,n)}catch(t){if(U(o),t!==t+0)throw t;be(1,0)}},p:function(t){var e=_();try{return Rt(t)()}catch(t){if(U(e),t!==t+0)throw t;be(1,0)}},b:function(t,e){var r=_();try{return Rt(t)(e)}catch(t){if(U(r),t!==t+0)throw t;be(1,0)}},D:function(t,e,r,n){var o=_();try{return Rt(t)(e,r,n)}catch(t){if(U(o),t!==t+0)throw t;be(1,0)}},ja:function(t,e,r){var n=_();try{return Rt(t)(e,r)}catch(t){if(U(n),t!==t+0)throw t;be(1,0)}},c:function(t,e,r){var n=_();try{return Rt(t)(e,r)}catch(t){if(U(n),t!==t+0)throw t;be(1,0)}},ia:function(t,e,r,n,o){var a=_();try{return Rt(t)(e,r,n,o)}catch(t){if(U(a),t!==t+0)throw t;be(1,0)}},h:function(t,e,r,n){var o=_();try{return Rt(t)(e,r,n)}catch(t){if(U(o),t!==t+0)throw t;be(1,0)}},j:function(t,e,r,n,o){var a=_();try{return Rt(t)(e,r,n,o)}catch(t){if(U(a),t!==t+0)throw t;be(1,0)}},r:function(t,e,r,n,o,a){var i=_();try{return Rt(t)(e,r,n,o,a)}catch(t){if(U(i),t!==t+0)throw t;be(1,0)}},P:function(t,e,r,n,o,a,i){var A=_();try{return Rt(t)(e,r,n,o,a,i)}catch(t){if(U(A),t!==t+0)throw t;be(1,0)}},w:function(t,e,r,n,o,a,i){var A=_();try{return Rt(t)(e,r,n,o,a,i)}catch(t){if(U(A),t!==t+0)throw t;be(1,0)}},E:function(t,e,r,n,o,a,i,A){var u=_();try{return Rt(t)(e,r,n,o,a,i,A)}catch(t){if(U(u),t!==t+0)throw t;be(1,0)}},L:function(t,e,r,n,o,a,i,A,u){var c=_();try{return Rt(t)(e,r,n,o,a,i,A,u)}catch(t){if(U(c),t!==t+0)throw t;be(1,0)}},I:function(t,e,r,n,o,a,i,A,u,c,s,l){var f=_();try{return Rt(t)(e,r,n,o,a,i,A,u,c,s,l)}catch(t){if(U(f),t!==t+0)throw t;be(1,0)}},$:function(t,e,r,n,o,a,i){var A=_();try{return Te(t,e,r,n,o,a,i)}catch(t){if(U(A),t!==t+0)throw t;be(1,0)}},Z:function(t,e,r,n,o){var a=_();try{return xe(t,e,r,n,o)}catch(t){if(U(a),t!==t+0)throw t;be(1,0)}},f:function(t){var e=_();try{Rt(t)()}catch(t){if(U(e),t!==t+0)throw t;be(1,0)}},l:function(t,e){var r=_();try{Rt(t)(e)}catch(t){if(U(r),t!==t+0)throw t;be(1,0)}},e:function(t,e,r){var n=_();try{Rt(t)(e,r)}catch(t){if(U(n),t!==t+0)throw t;be(1,0)}},W:function(t,e,r,n,o,a,i,A,u){var c=_();try{Rt(t)(e,r,n,o,a,i,A,u)}catch(t){if(U(c),t!==t+0)throw t;be(1,0)}},g:function(t,e,r,n){var o=_();try{Rt(t)(e,r,n)}catch(t){if(U(o),t!==t+0)throw t;be(1,0)}},J:function(t,e,r,n,o,a,i){var A=_();try{Rt(t)(e,r,n,o,a,i)}catch(t){if(U(A),t!==t+0)throw t;be(1,0)}},k:function(t,e,r,n,o){var a=_();try{Rt(t)(e,r,n,o)}catch(t){if(U(a),t!==t+0)throw t;be(1,0)}},la:function(t,e,r,n,o,a,i,A){var u=_();try{Rt(t)(e,r,n,o,a,i,A)}catch(t){if(U(u),t!==t+0)throw t;be(1,0)}},o:function(t,e,r,n,o,a){var i=_();try{Rt(t)(e,r,n,o,a)}catch(t){if(U(i),t!==t+0)throw t;be(1,0)}},y:function(t,e,r,n,o,a,i){var A=_();try{Rt(t)(e,r,n,o,a,i)}catch(t){if(U(A),t!==t+0)throw t;be(1,0)}},u:function(t,e,r,n,o,a,i,A){var u=_();try{Rt(t)(e,r,n,o,a,i,A)}catch(t){if(U(u),t!==t+0)throw t;be(1,0)}},R:function(t,e,r,n,o,a,i,A,u){var c=_();try{Rt(t)(e,r,n,o,a,i,A,u)}catch(t){if(U(c),t!==t+0)throw t;be(1,0)}},v:function(t,e,r,n,o,a,i,A,u,c){var s=_();try{Rt(t)(e,r,n,o,a,i,A,u,c)}catch(t){if(U(s),t!==t+0)throw t;be(1,0)}},n:function(t,e,r,n,o,a,i,A,u,c,s){var l=_();try{Rt(t)(e,r,n,o,a,i,A,u,c,s)}catch(t){if(U(l),t!==t+0)throw t;be(1,0)}},H:function(t,e,r,n,o,a,i,A,u,c,s,l,f,d,h,g){var p=_();try{Rt(t)(e,r,n,o,a,i,A,u,c,s,l,f,d,h,g)}catch(t){if(U(p),t!==t+0)throw t;be(1,0)}},na:function(t,e,r,n,o,a,i,A,u,c,s,l,f,d,h,g,p){var v=_();try{Rt(t)(e,r,n,o,a,i,A,u,c,s,l,f,d,h,g,p)}catch(t){if(U(v),t!==t+0)throw t;be(1,0)}},z:t=>t};var Pe=await async function(){function t(t,e){return function(t){ye=t.Ba,me=n._free=t.Ca,we=n._malloc=t.Ea,Ce=t.Fa,be=t.Ga,Be=t.Ha,Ee=t.Ia,Ie=t.Ja,Se=t.Ka,De=t.La,Qe=t.Ma,xt.viijii=t.Na,Te=xt.iiijj=t.Oa,xt.jiji=t.Pa,xe=xt.jiiii=t.Qa,xt.iiiiij=t.Ra,xt.iiiiijj=t.Sa,xt.iiiiiijj=t.Ta,Oe=t.za,Fe=t.Da}(Pe=t.exports),m(),Pe}var e={a:Me};return n.instantiateWasm?new Promise((r,o)=>{n.instantiateWasm(e,(e,n)=>{r(t(e))})}):(null!=h||(h=C()),function(e){return t(e.instance)}(await B(l,h,e)))}();return function(){function t(){var t,e;n.calledRun=!0,!v&&(y=!0,Pe.Aa(),null==(t=f)||t(n),null==(e=n.onRuntimeInitialized)||e.call(n),function(){if(n.postRun)for("function"==typeof n.postRun&&(n.postRun=[n.postRun]);n.postRun.length;)V(n.postRun.shift());F(R)}())}!function(){if(n.preRun)for("function"==typeof n.preRun&&(n.preRun=[n.preRun]);n.preRun.length;)P(n.preRun.shift());F(M)}(),n.setStatus?(n.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>n.setStatus(""),1),t()},1)):t()}(),y?n:new Promise((t,e)=>{f=t,d=e})}function I(t){return b(E,t)}function S(){return function(t){w.delete(t)}(E)}function D(t){I({overrides:t,equalityFn:Object.is,fireImmediately:!1})}var Q=[["aztec","Aztec"],["aztec_code","AztecCode"],["aztec_rune","AztecRune"],["code_128","Code128"],["code_39","Code39"],["code_39_standard","Code39Std"],["code_39_extended","Code39Ext"],["code_32","Code32"],["pzn","PZN"],["code_93","Code93"],["codabar","Codabar"],["databar","DataBar"],["databar_omni","DataBarOmni"],["databar_stacked","DataBarStk"],["databar_stacked_omni","DataBarStkOmni"],["databar_expanded","DataBarExp"],["databar_expanded_stacked","DataBarExpStk"],["databar_limited","DataBarLtd"],["data_matrix","DataMatrix"],["dx_film_edge","DXFilmEdge"],["ean_13","EAN13"],["ean_upc","EANUPC"],["isbn","ISBN"],["ean_8","EAN8"],["itf","ITF"],["itf_14","ITF14"],["maxi_code","MaxiCode"],["micro_qr_code","MicroQRCode"],["pdf417","PDF417"],["compact_pdf417","CompactPDF417"],["qr_code","QRCode"],["qr_code_model_1","QRCodeModel1"],["qr_code_model_2","QRCodeModel2"],["rm_qr_code","RMQRCode"],["upc_a","UPCA"],["upc_e","UPCE"],["other_barcode","OtherBarcode"],["linear_codes","AllLinear"],["matrix_codes","AllMatrix"],["gs1_codes","AllGS1"],["retail_codes","AllRetail"],["industrial_codes","AllIndustrial"],["any","All"]],T=[...Q,["unknown"]].map(t=>t[0]),x=new Map(Q);function O(t){for(let[e,r]of x)if(t===r)return e;return"unknown"}function F(t){try{var e;return t instanceof(null==t||null==(e=t.ownerDocument)||null==(e=e.defaultView)?void 0:e.HTMLImageElement)}catch{return!1}}function R(t){try{var e;return t instanceof(null==t||null==(e=t.ownerDocument)||null==(e=e.defaultView)?void 0:e.SVGImageElement)}catch{return!1}}function V(t){try{var e;return t instanceof(null==t||null==(e=t.ownerDocument)||null==(e=e.defaultView)?void 0:e.HTMLVideoElement)}catch{return!1}}function M(t){try{var e;return t instanceof(null==t||null==(e=t.ownerDocument)||null==(e=e.defaultView)?void 0:e.HTMLCanvasElement)}catch{return!1}}function P(t){try{return t instanceof ImageBitmap||"[object ImageBitmap]"===Object.prototype.toString.call(t)}catch{return!1}}function U(t){try{return t instanceof OffscreenCanvas||"[object OffscreenCanvas]"===Object.prototype.toString.call(t)}catch{return!1}}function _(t){try{return t instanceof VideoFrame||"[object VideoFrame]"===Object.prototype.toString.call(t)}catch{return!1}}async function k(t){if(F(t)&&!await async function(t){try{return await t.decode(),!0}catch{return!1}}(t))throw new DOMException("Failed to load or decode HTMLImageElement.","InvalidStateError");if(R(t)&&!await async function(t){try{var e;return await(null==(e=t.decode)?void 0:e.call(t)),!0}catch{return!1}}(t))throw new DOMException("Failed to load or decode SVGImageElement.","InvalidStateError");if(_(t)&&function(t){return null===t.format}(t))throw new DOMException("VideoFrame is closed.","InvalidStateError");if(V(t)&&(0===t.readyState||1===t.readyState))throw new DOMException("Invalid element or state.","InvalidStateError");if(P(t)&&function(t){return 0===t.width&&0===t.height}(t))throw new DOMException("The image source is detached.","InvalidStateError");let{width:e,height:r}=function(t){if(F(t))return{width:t.naturalWidth,height:t.naturalHeight};if(R(t))return{width:t.width.baseVal.value,height:t.height.baseVal.value};if(V(t))return{width:t.videoWidth,height:t.videoHeight};if(P(t))return{width:t.width,height:t.height};if(_(t))return{width:t.displayWidth,height:t.displayHeight};if(M(t)||U(t))return{width:t.width,height:t.height};throw TypeError("The provided value is not of type '(Blob or HTMLCanvasElement or HTMLImageElement or HTMLVideoElement or ImageBitmap or ImageData or OffscreenCanvas or SVGImageElement or VideoFrame)'.")}(t);if(0===e||0===r)return null;let n=function(t,e){try{let r=new OffscreenCanvas(t,e);if(r.getContext("2d")instanceof OffscreenCanvasRenderingContext2D)return r;throw void 0}catch{let r=document.createElement("canvas");return r.width=t,r.height=e,r}}(e,r).getContext("2d");n.drawImage(t,0,0);try{return n.getImageData(0,0,e,r)}catch{throw new DOMException("Source would taint origin.","SecurityError")}}async function j(t){if(function(t){try{return t instanceof Blob||"[object Blob]"===Object.prototype.toString.call(t)}catch{return!1}}(t))return await async function(t){let e;try{e=await createImageBitmap(t)}catch{try{if(!globalThis.Image)return t;{e=new Image;let r="";try{r=URL.createObjectURL(t),e.src=r,await e.decode()}finally{URL.revokeObjectURL(r)}}}catch{throw new DOMException("Failed to load or decode Blob.","InvalidStateError")}}return await k(e)}(t);if(function(t){try{return t instanceof ImageData||"[object ImageData]"===Object.prototype.toString.call(t)}catch{return!1}}(t)){if(function(t){return 0===t.data.buffer.byteLength}(t))throw new DOMException("The image data has been detached.","InvalidStateError");return t}return M(t)||U(t)?function(t){let{width:e,height:r}=t;if(0===e||0===r)return null;let n=t.getContext("2d");try{return n.getImageData(0,0,e,r)}catch{throw new DOMException("Source would taint origin.","SecurityError")}}(t):await k(t)}function W(t,e){return function(t){return t instanceof DOMException||"[object DOMException]"===Object.prototype.toString.call(t)}(t)?new DOMException(`${e}: ${t.message}`,t.name):function(t){return t instanceof Error||"[object Error]"===Object.prototype.toString.call(t)}(t)?new t.constructor(`${e}: ${t.message}`):Error(`${e}: ${t}`)}function G(t,e,r){(function(t,e){if(e.has(t))throw TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}function L(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw TypeError("Private element is not present on this object")}function q(t,e){return t.get(L(t,e))}var J=new WeakMap;Object.defineProperty(e,"a",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"i",{enumerable:!0,get:function(){return"98106d24a9bc2c4a24a6e6864e0f5729bd68cf73d6f5b45bb1c824521146370c"}}),Object.defineProperty(e,"n",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"o",{enumerable:!0,get:function(){return"3.0.2"}}),Object.defineProperty(e,"r",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"s",{enumerable:!0,get:function(){return"b304f6656b865be11b00741d430b7d0027bc0ab4"}}),Object.defineProperty(e,"t",{enumerable:!0,get:function(){return class{constructor(t={}){G(this,J,void 0);try{var e;let r=null==t||null==(e=t.formats)?void 0:e.filter(t=>"unknown"!==t);if(0===(null==r?void 0:r.length))throw TypeError("Hint option provided, but is empty.");for(let t of null==r?[]:r)if(!x.has(t))throw TypeError(`Failed to read the 'formats' property from 'BarcodeDetectorOptions': The provided value '${t}' is not a valid enum value of type BarcodeFormat.`);(function(t,e,r){t.set(L(t,e),r)})(J,this,null==r?[]:r),I({fireImmediately:!0}).catch(()=>{})}catch(t){throw W(t,"Failed to construct 'BarcodeDetector'")}}static async getSupportedFormats(){return T.filter(t=>"unknown"!==t)}async detect(t){try{let e=await j(t);if(null===e)return[];let r,n={textMode:"Plain",formats:q(J,this).map(t=>x.get(t))};try{r=await async function(t,e){return B(E,t,e)}(e,n)}catch(t){throw console.error(t),new DOMException("Barcode detection service unavailable.","NotSupportedError")}return r.map(t=>{let{topLeft:{x:e,y:r},topRight:{x:n,y:o},bottomLeft:{x:a,y:i},bottomRight:{x:A,y:u}}=t.position,c=Math.min(e,n,a,A),s=Math.min(r,o,i,u),l=Math.max(e,n,a,A),f=Math.max(r,o,i,u);return{boundingBox:new DOMRectReadOnly(c,s,l-c,f-s),rawValue:t.text,format:O(t.format),cornerPoints:[{x:e,y:r},{x:n,y:o},{x:A,y:u},{x:a,y:i}]}})}catch(t){throw W(t,"Failed to execute 'detect' on 'BarcodeDetector'")}}}}})},function(t,e,r){"use strict";e.__esModule=!0,e.isReadyCalled=function(){return u},r(9);var n=r(0),o=r(14),a=r(7),i=r(6),A=null,u=!1;e.default=Object.assign({},{config:function(t){return t&&(0,n.setConfig)(t),A||(A=Promise.resolve().then((function(){return(0,i.printDebug)("-------------------------------------"),(0,i.printDebug)("sdk_version:",(0,n.getVersion)()),(0,i.printDebug)("-------------------------------------"),(0,a.initWxJssdk)(),Promise.resolve().then((function(){u=!0})).catch((function(t){throw A=null,t}))})))},onScanListener:o.onScanListener,offScanListener:o.offScanListener,setStatusListener:o.setStatusListener,getStatus:o.getStatus,startScan:o.startScan,stopScan:o.stopScan,scanImage:o.scanImage,clear:o.clear})},function(t,e,r){"use strict";e.__esModule=!0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.toAny=function(t,e){if(null==t)return e;var r=function(t){if("string"!=typeof t)return void 0===t?"undefined":n(t);try{var e=JSON.parse(t);return void 0===e?"undefined":n(e)}catch(e){var r=parseFloat(t);return isNaN(r)||""+r!==t?"string":"number"}}(t);null!=e&&(r=void 0===e?"undefined":n(e));switch(r){case"number":return function(t){try{return JSON.parse(t)}catch(e){return parseFloat(t)}}(t);case"boolean":return function(t){return!!t&&"false"!=t&&"0"!=t}(t);case"object":return function(t,e){if("object"===(void 0===t?"undefined":n(t)))return t;try{return JSON.parse(t)}catch(t){}return e}(t,e);case"string":return function(t,e){try{var r=void 0===t?"undefined":n(t);if("string"===r)return t;if("boolean"===r)return t?"true":"false";if("number"===r)return""+t;if("object"===r)return JSON.stringify(t)}catch(t){}return e}(t,e)}return e}},function(t,e,r){"use strict";e.__esModule=!0,e.printError=function(t){for(var e,r=arguments.length,n=Array(r>1?r-1:0),o=1;o1?r-1:0),o=1;o1?r-1:0),o=1;o1)for(var r=1;r0?(0,i.startScanner)((function(t){!function(t){if(!function(t){for(var e=0;e=0&&r.splice(n,1)}},e.bridgeSync=l,e.bridgeAsync=function(t,e,r){return new Promise((function(n,o){if(s()){var i=!1,u=null;r>0&&(u=setTimeout((function(){i=!0,u=null,o("bridgeAsync timeout")}),r));var c=(0,a.createUUID)()+"_"+Date.now();f=c,(d=function(t,e){i||(u&&clearTimeout(u),0==t?n(e):o(e))})&&"function"==typeof d&&(A[f]=d),l(t,Object.assign({request_id:c},e))}else o("Can't bridgeAsync, because not in runtime");var f,d})).then((function(r){var n=[t];return e&&(n.push("params:"),n.push(e)),r&&(n.push("resp:"),n.push(r)),o.printDebug.apply(void 0,["bridge resp >>>"].concat(n)),r})).catch((function(r){throw e?(0,o.printWarn)("bridge err >>>",t,"params:",e,r):(0,o.printWarn)("bridge err >>>",t,r),r}))};var n=r(5),o=r(6),a=r(2),i={},A={},u="__bridge_client__";function c(){var t=u+"_handle_callback";window[t]||(window[t]=function(t){var e=(0,n.toAny)(t,{}),r=e.method,o=e.payload,a=e.code,u=e.request_id,c=(0,n.toAny)(o,{});u?A[u]&&A[u](a,c):i[r]&&i[r].forEach((function(t){t&&t(c)}))})}function s(){return!!window[u]}function l(t,e){c();var r=(0,n.toAny)(function(t){for(var e=t.split("."),r=window;e.length>1;)r=r[e.shift()];if(r&&1==e.length&&r.hasOwnProperty(e[0])){for(var n,o=arguments.length,a=Array(o>1?o-1:0),i=1;i>>"].concat(a)),r}},function(t,e,r){"use strict";e.__esModule=!0,e.isSupportWebScan=function(){return"undefined"!=typeof navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia&&!!g()},e.isSupportImageScan=function(){return"undefined"!=typeof document&&"undefined"!=typeof URL&&URL.createObjectURL},e.stopScanForWeb=function(){return Promise.resolve().then((function(){c.uuid=null}))},e.startScanForImage=function(){return p((0,i.getConfig)("webScanType")).then((function(t){return new Promise((function(t){var e=document.createElement("input");e.type="file",e.accept="image/*",e.style.display="none";var r=!1,n=function(e){r||(r=!0,f("__webscan_image_input__"),t(e))};e.id="__webscan_image_input__",e.onchange=function(){n(e.files&&e.files[0])},e.oncancel=function(){n(null)},document.body.appendChild(e),e.click()})).then((function(e){return function(t,e){if(!e)return Promise.resolve(null);if("undefined"!=typeof createImageBitmap)return createImageBitmap(e).then((function(e){return t.detect(e).then((function(t){return e.close&&e.close(),t&&t[0]})).catch((function(t){throw e.close&&e.close(),t}))}));return new Promise((function(r,n){var o=new Image,a=URL.createObjectURL(e);o.onload=function(){t.detect(o).then((function(t){URL.revokeObjectURL(a),r(t&&t[0])})).catch((function(t){URL.revokeObjectURL(a),n(t)}))},o.onerror=function(t){URL.revokeObjectURL(a),n(t)},o.src=a}))}(t,e)}))})).then((function(t){return t&&t.rawValue?{result:t.rawValue}:{success:!1,error:"未识别到二维码或条形码"}}))},e.startScanForWeb=function(t,e){return new Promise((function(r,n){try{c.uuid=(0,a.createUUID)(),c.finish=!1;var o,A=d("video","__webscan_video__","display: none",!1),u=!1!==(0,i.getConfig)("webCanvasEnabled"),l=t||"position: fixed; width: 300px; height: 240px; top: 0; left: 0; z-index: 9999;",f=d("canvas","__webscan_canvas__",l+" display: none;",!0);f.style.display,f.style.cssText=l,o=f.style.display,f.style.display="none";var g=f.getContext("2d"),v=c.uuid;A.width=300,A.height=300,A.uuid=c.uuid,p((0,i.getConfig)("webScanType")).then((function(t){return navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}}).then((function(e){return{detector:t,stream:e}}))})).then((function(t){var a=t.detector,l=t.stream;A.srcObject=l,A.setAttribute("playsinline",!0),A.play(),f.style.display="none";var d=!1,p=!1,y=!1,m=function(){if(!y){y=!0;try{l.getTracks()[0].stop()}catch(t){}}},w=function t(){try{A.readyState!==A.HAVE_ENOUGH_DATA||d||(f.height=A.videoHeight,f.width=A.videoWidth,g.setTransform(-1,0,0,1,f.width,0),g.drawImage(A,0,0,f.width,f.height),g.setTransform(1,0,0,1,0,0),u&&!p&&(p=!0,f.style.display=o||""),d=!0,a.detect(A).then((function(t){var n=t&&t[0];if(n&&n.rawValue&&c.uuid==v){if(!e||!e(n.rawValue))return;!function(t,e,r){var n=r.cornerPoints;if(n&&n.length){for(var o=0;o1&&(r[e[0]]=e[1])}}));if(c.status>=200&&c.status<300){var n={errMsg:"request:ok"};try{var o=JSON.parse(c.response);n.data=o}catch(t){n.data=c.response}n.header=r,n.statusCode=c.status,t.success&&t.success(n)}else t.fail&&t.fail({errMsg:"request:fail",data:c.response,header:r})}},c.send(e)}(Object.assign({},{url:e,method:r,data:s,headers:A,json:u,timeout:c},{success:t,fail:n}))})).then((function(t){if(t.statusCode&&200!=t.statusCode)throw t;return t}))};var n=r(2),o=r(22),a=r(23)},function(t,e,r){"use strict";e.__esModule=!0,e.hex_md5=function(t){return d(n(l(t),8*t.length))},e.b64_md5=function(t){return h(n(l(t),8*t.length))},e.str_md5=function(t){return f(n(l(t),8*t.length))},e.hex_hmac_md5=function(t,e){return d(c(t,e))},e.b64_hmac_md5=function(t,e){return h(c(t,e))},e.str_hmac_md5=function(t,e){return f(c(t,e))};function n(t,e){t[e>>5]|=128<>>9<<4)]=e;for(var r=1732584193,n=-271733879,o=-1732584194,c=271733878,l=0;l>>32-A,r);var i,A}function a(t,e,r,n,a,i,A){return o(e&r|~e&n,t,e,a,i,A)}function i(t,e,r,n,a,i,A){return o(e&n|r&~n,t,e,a,i,A)}function A(t,e,r,n,a,i,A){return o(e^r^n,t,e,a,i,A)}function u(t,e,r,n,a,i,A){return o(r^(e|~n),t,e,a,i,A)}function c(t,e){var r=l(t);r.length>16&&(r=n(r,8*t.length));for(var o=Array(16),a=Array(16),i=0;i<16;i++)o[i]=909522486^r[i],a[i]=1549556828^r[i];var A=n(o.concat(l(e)),512+8*e.length);return n(a.concat(A),640)}function s(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function l(t){for(var e=Array(),r=0;r<8*t.length;r+=8)e[r>>5]|=(255&t.charCodeAt(r/8))<>5]>>>r%32&255);return e}function d(t){for(var e="0123456789abcdef",r="",n=0;n<4*t.length;n++)r+=e.charAt(t[n>>2]>>n%4*8+4&15)+e.charAt(t[n>>2]>>n%4*8&15);return r}function h(t){for(var e="",r=0;r<4*t.length;r+=3)for(var n=(t[r>>2]>>r%4*8&255)<<16|(t[r+1>>2]>>(r+1)%4*8&255)<<8|t[r+2>>2]>>(r+2)%4*8&255,o=0;o<4;o++)8*r+6*o>32*t.length?e+="":e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>6*(3-o)&63);return e}},function(t,e,r){"use strict";e.__esModule=!0,e.stringifyQuery=function(t){return Object.keys(t).map((function(e){var r=t[e];return e+"="+encodeURIComponent(r)})).join("&")},e.decodeQuery=function(t){return Object.keys(t).reduce((function(e,r){var n=t[r];return e[r]=decodeURIComponent(n),e}),{})},e.parseQueryParams=i,e.appendQueryParams=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i(t),n=r.url,o=r.params;Object.keys(e).forEach((function(t){var r=e[t];null!=r?o[t]=r:delete o[t]}));var a=Object.keys(o).map((function(t){var e=o[t];return t+"="+encodeURIComponent(e)})).join("&");if(!n)return a;if(!a)return n;return n+"?"+a},e.getQueryString=function(t,e){var r=a.default.location.search,n=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),o=r.substr(1).match(n);if(null!=o)return decodeURIComponent(unescape(o[2]));return e};var n,o=r(1),a=(n=o)&&n.__esModule?n:{default:n};function i(t){var e="",r={};if(!t||"string"!=typeof t)return{url:e,params:r};var n="",o=t.indexOf("?"),a=t.indexOf("#"),i=t.indexOf("=");return o>=0?(e=t.substring(0,o),n=t.substring(o+1,a>0?a:t.length)):i>=0?(e="",n=t):(e=t,n=""),n.split("&").map((function(t){var e=t.indexOf("=");if(e>0){var n=t.substring(0,e),o=t.substring(e+1);r[n]=decodeURIComponent(o)}})),{url:e,params:r}}},function(t,e,r){"use strict";e.__esModule=!0,e.startScanner=function(t){if(!t||"function"!=typeof t)return;if(n=t,"scanning"===o)return;o="scanning",u(),window.addEventListener("keydown",c)},e.stopScanner=function(){if("scanning"!==o)return;o="closed",n=null,u(),window.removeEventListener("keydown",c)};var n=null,o="closed",a="",i=null,A=0;function u(){a="",A=0,i&&(clearTimeout(i),i=null)}function c(t){if("scanning"===o&&!(t.ctrlKey||t.metaKey||t.altKey)){if("Enter"===t.key){var e=a.replace(/[\uFF01-\uFF5E]/g,(function(t){return String.fromCharCode(t.charCodeAt(0)-65248)})).replace(/\u3002/g,".");return e&&function(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()}(t),u(),void(e&&n&&n(e))}if(t.key&&1===t.key.length){var r=Date.now();A&&r-A>100&&u(),A=r,a+=t.key,i&&clearTimeout(i),i=setTimeout((function(){u()}),100)}}}},function(t,e,r){"use strict";e.__esModule=!0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.exportSDK=function(t,e){for(var r=arguments.length,o=Array(r>2?r-2:0),s=2;s1;)r=r[n.shift()];if(r&&1==n.length&&r.hasOwnProperty(n[0])){for(var o,a=arguments.length,i=Array(a>2?a-2:0),A=2;A1&&void 0!==arguments[1]?arguments[1]:"",r={};return Object.keys(t).forEach((function(o){var a=t[o];if("object"===(void 0===a?"undefined":n(a)))Object.assign(r,u(a,""+e+o+"."));else if("function"==typeof a){var i,A=""+e+o;Object.assign(r,((i={})[A]=A,i))}})),r}function c(t){Object.keys(t).forEach((function(e){var r=t[e];"object"===(void 0===r?"undefined":n(r))&&c(r)})),Object.freeze(t)}}]); \ No newline at end of file diff --git a/dist/lib/reader.wasm b/dist/lib/reader.wasm new file mode 100644 index 0000000..76d83a0 Binary files /dev/null and b/dist/lib/reader.wasm differ diff --git a/package.json b/package.json index bd2f668..b065c46 100644 --- a/package.json +++ b/package.json @@ -16,36 +16,38 @@ "types" ], "devDependencies": { - "barcode-detector": "^3.0.8", "autoprefixer": "^7.2.3", "axios": "0.21.1", "babel-core": "^6.25.0", "babel-loader": "^7.1.1", "babel-plugin-transform-class-properties": "^6.24.1", "babel-preset-env": "^1.6.0", + "barcode-detector": "^3.0.8", + "browserify-cipher": "1.0.1", "clean-webpack-plugin": "3.0.0", "concurrently": "^3.5.0", "cp-webpack-plugin": "^1.0.0", - "html-webpack-plugin": "4.5.2", "cross-env": "5.2.1", "css-loader": "^0.28.4", "es6-promise": "4.2.6", "exports-loader": "^0.6.4", "file-loader": "^0.11.2", "file-saver": "^1.3.3", + "html-webpack-plugin": "4.5.2", "http-server": "0.11.1", "imports-loader": "^0.7.1", "postcss-loader": "^2.0.6", + "quagga": "0.12.1", "str-webpack-plugin": "1.0.0", "style-loader": "^0.18.2", + "terser-webpack-plugin": "1.4.6", "uglifyjs-webpack-plugin": "^1.2.2", "url-loader": "^0.5.9", "vconsole": "3.3.0", - "quagga": "0.12.1", - "browserify-cipher": "1.0.1", "webpack": "^4.12.0", "webpack-bundle-analyzer": "3.6.0", - "webpack-cli": "^3.3.9" + "webpack-cli": "^3.3.9", + "zxing-wasm": "3.0.2" }, "repository": {}, "author": "", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5082760..eadad35 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -80,6 +80,9 @@ importers: style-loader: specifier: ^0.18.2 version: 0.18.2 + terser-webpack-plugin: + specifier: 1.4.6 + version: 1.4.6(webpack@4.47.0) uglifyjs-webpack-plugin: specifier: ^1.2.2 version: 1.3.0(webpack@4.47.0) @@ -98,6 +101,9 @@ importers: webpack-cli: specifier: ^3.3.9 version: 3.3.12(webpack@4.47.0) + zxing-wasm: + specifier: 3.0.2 + version: 3.0.2(@types/emscripten@1.41.5) packages: diff --git a/src/services/web/index.js b/src/services/web/index.js index 84ee736..ff1081d 100644 --- a/src/services/web/index.js +++ b/src/services/web/index.js @@ -1,3 +1,4 @@ +import { BarcodeDetector as BarcodeDetectorPonyfill, prepareZXingModule } from "barcode-detector/dist/cjs/index.js"; import { createUUID } from "../../utils/uuid"; import { getConfig } from "../config"; import scanBeepAudio from "../../../res/scan_beep.ogg"; @@ -8,9 +9,9 @@ const scanWeb = { } const DEFAULT_SCAN_BEEP_AUDIO = scanBeepAudio; -const BARCODE_DETECTOR_POLYFILL_URL = "https://fastly.jsdelivr.net/npm/barcode-detector@3/dist/iife/index.min.js"; +const ZXING_READER_WASM_URL = "./lib/reader.wasm"; -let barcodeDetectorPolyfillPromise = null; +let barcodeDetectorPreparePromise = null; function removeEl(id) { try { @@ -70,48 +71,32 @@ function getBarcodeDetectorClass() { if (typeof BarcodeDetector !== 'undefined') { return BarcodeDetector; } - if (typeof window !== 'undefined' - && window.BarcodeDetectionAPI - && window.BarcodeDetectionAPI.BarcodeDetector) { - return window.BarcodeDetectionAPI.BarcodeDetector; - } - return null; + return BarcodeDetectorPonyfill; } -function loadBarcodeDetectorPolyfill() { - if (getBarcodeDetectorClass()) { - return Promise.resolve(getBarcodeDetectorClass()); +function prepareBarcodeDetector() { + const BarcodeDetectorClass = getBarcodeDetectorClass(); + if (typeof BarcodeDetector !== 'undefined' || !prepareZXingModule) { + return Promise.resolve(BarcodeDetectorClass); } - if (barcodeDetectorPolyfillPromise) { - return barcodeDetectorPolyfillPromise; - } - barcodeDetectorPolyfillPromise = new Promise((resolve, reject) => { - if (typeof document === 'undefined') { - reject(new Error("BarcodeDetector is not supported")); - return; - } - const scriptUrl = getConfig("webBarcodeDetectorPolyfillUrl") || BARCODE_DETECTOR_POLYFILL_URL; - const script = document.createElement("script"); - script.src = scriptUrl; - script.onload = () => { - const BarcodeDetectorClass = getBarcodeDetectorClass(); - if (BarcodeDetectorClass) { - resolve(BarcodeDetectorClass); - } else { - reject(new Error("BarcodeDetector polyfill is not ready")); + if (!barcodeDetectorPreparePromise) { + prepareZXingModule({ + overrides: { + locateFile: path => { + if (path && path.indexOf(".wasm") !== -1) { + return ZXING_READER_WASM_URL; + } + return path; + } } - }; - script.onerror = reject; - document.head.appendChild(script); - }).catch(err => { - barcodeDetectorPolyfillPromise = null; - throw err; - }); - return barcodeDetectorPolyfillPromise; + }); + barcodeDetectorPreparePromise = Promise.resolve(BarcodeDetectorClass); + } + return barcodeDetectorPreparePromise; } function createBarcodeDetector(scanType) { - return loadBarcodeDetectorPolyfill().then(BarcodeDetectorClass => { + return prepareBarcodeDetector().then(BarcodeDetectorClass => { if (!BarcodeDetectorClass) { throw new Error("BarcodeDetector is not supported"); } diff --git a/types/index.d.ts b/types/index.d.ts index 48d4934..d97243a 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -22,10 +22,6 @@ interface ScanConfigOptions { * 网页扫码成功提示音是否启用,默认启用 */ webScanBeepEnabled?: boolean, - /** - * BarcodeDetector polyfill 地址,默认使用 jsDelivr CDN - */ - webBarcodeDetectorPolyfillUrl?: string, /** * 微信JSSDK配置,微信环境才会生效,配置后会自动初始化微信JSSDK */ diff --git a/webpack.base.js b/webpack.base.js index 2a19acc..d17cdfd 100644 --- a/webpack.base.js +++ b/webpack.base.js @@ -3,6 +3,7 @@ const rules = require('./webpack.rules.js'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CpWebpackPlugin = require('cp-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); +const zxingReaderWasm = require.resolve('zxing-wasm/reader/zxing_reader.wasm'); const output = path.resolve('./dist'); @@ -29,6 +30,7 @@ const config = { }), new CpWebpackPlugin([ { from: path.resolve('./types'), to: path.resolve('./dist') }, + { from: zxingReaderWasm, to: path.resolve('./dist/lib/reader.wasm') }, ]) ], devtool: 'cheap-module-souce-map', diff --git a/webpack.prod.js b/webpack.prod.js index c907044..2d01a2e 100644 --- a/webpack.prod.js +++ b/webpack.prod.js @@ -1,17 +1,22 @@ const baseConfig = require('./webpack.base.js'); -const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); +const TerserPlugin = require('terser-webpack-plugin'); const { EnvWebPackage } = require('./webpack.plugin.js'); module.exports = Object.assign({}, baseConfig, { + optimization: { + minimizer: [ + new TerserPlugin({ + terserOptions: { + output: { + comments: false + } + }, + extractComments: false + }) + ] + }, plugins: [ ...baseConfig.plugins, - new UglifyJsPlugin({ - uglifyOptions: { - output: { - comments: false - } - } - }), new EnvWebPackage({ entry: baseConfig.entry, output: baseConfig.output.path,