var Quagga=function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(e.toString()).default:"object"==typeof exports?exports.Quagga=e(e.toString()).default:t.Quagga=e(e.toString()).default}(this,function(t){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/",r(r.s=30)}([function(t,e){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}},function(t,e){function r(t,e){for(var r=0;r=e&&t.y>=e&&t.x0){var h=n[c-1];h.m00+=1,h.m01+=o,h.m10+=u,h.m11+=u*o,h.m02+=s,h.m20+=u*u}}for(var l=Math.PI,f=l/4,d=0;d=0?f:-f)+l;v.theta=(180*b/l+90)%180-90,v.theta<0&&(v.theta+=180),v.rad=b>l?b-l:b,v.x=Math.cos(b),v.y=Math.sin(b),i.push(v)}}return i}},{key:"show",value:function(t,e){var r=this.size.y,n=this.size.x,i=t.getImageData(0,0,n,r),a=i.data,o=0;e||(e=1);for(var s=0;s360)&&(e=360);for(var h=this.data.length;h--;){i[0]=this.data[h]*e;var l=i[0]<=0?a:i[0]>=360?o:Object(c.a)(i);u[4*h+0]=l[0],u[4*h+1]=l[1],u[4*h+2]=l[2],u[4*h+3]=255}t.putImageData(s,r,n)}}]),t}()},function(t,e){function r(t,e,r,n,i,a,o){try{var s=t[a](o),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise(function(i,a){var o=t.apply(e,n);function s(t){r(o,i,a,s,u,"next",t)}function u(t){r(o,i,a,s,u,"throw",t)}s(void 0)})}}},function(t,e,r){"use strict";r.d(e,"a",function(){return n});var n={drawPath:function(t,e,r,n){t&&t.length>1&&(e.strokeStyle=r,e.fillStyle=r,e.lineWidth=n,e.beginPath(),e.moveTo(t[0].x,t[0].y),t.slice(1).forEach(function(t){var r=t.x,n=t.y;return e.lineTo(r,n)}),e.closePath(),e.stroke())},drawImage:function(t,e,r,n){var i=n.getImageData(0,0,e,r),a=i.data,o=0|t.length,s=0|a.length;if(s/o!=4)return!1;for(;o--;){var u=t[o];a[--s]=255,a[--s]=u,a[--s]=u,a[--s]=u}return n.putImageData(i,0,0),!0}}},function(t,e){function r(t){return(r="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})(t)}function n(e){return"function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?t.exports=n=function(t){return r(t)}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":r(t)},n(e)}t.exports=n},function(t,e,r){var n=r(22),i=r(23),a=r(24);t.exports=function(t){return n(t)||i(t)||a()}},function(t,e,r){"use strict";function n(t){var e=t[0],r=t[1],n=t[2],i=t[3],a=e*i-n*r;return a?new Float32Array([i/a,-r/a,-n/a,e/a]):null}function i(t,e){var r=t.x,n=t.y;return{x:e[0]*r+e[2]*n,y:e[1]*r+e[3]*n}}function a(t,e){e||(e=8);var r=8-e,n=function(t,e){e||(e=8);for(var r=t.data,n=8-e,i=new Int32Array(1<>n]++;return i}(t,e),i=[0],a=(1<n[t]?r:t},0)<>1,s=0,u=n,c=0;u>2,c++,s+=2,u+=2;s+=n,u+=n}}r.d(e,"b",function(){return n}),r.d(e,"d",function(){return i}),r.d(e,"c",function(){return o}),r.d(e,"a",function(){return s})},function(t,e,r){"use strict";function n(t,e){var r=t[0],n=t[1],i=t[2],a=i*n,o=a*(1-Math.abs(r/60%2-1)),s=i-a,u=0,c=0,h=0;return r<60?(u=a,c=o):r<120?(u=o,c=a):r<180?(c=a,h=o):r<240?(c=o,h=a):r<300?(u=o,h=a):r<360&&(u=a,h=o),(e=e||[0,0,0])[0]=255*(u+s)|0,e[1]=255*(c+s)|0,e[2]=255*(h+s)|0,e}r.d(e,"a",function(){return n})},function(t,e,r){"use strict";function n(t){for(var e=new Array,r=new Array,n=1;n*n<=t;n++)t%n==0&&(e.push(n),n*n!==t&&r.unshift(t/n|0));return e.concat(r)}function i(t,e){var r=e.x,i=e.y,a=0|Math.max(0|r,0|i),o=[8,10,15,20,32,60,80],s={"x-small":5,small:4,medium:3,large:2,"x-large":1},u=s[t]||0|s.medium,c=0|o[u],h=a/c|0;function l(t){for(var e=0,r=0|t[t.length>>1];e0&&(r=Math.abs(t[e]-h)>Math.abs(t[e-1]-h)?0|t[e-1]:0|t[e]),h/ro[u-1]/o[u]?{x:r,y:r}:null}return l(function(t,e){if(t===e)return n(t);for(var r=t>e?t:e,i=t>e?e:t,a=new Array,o=new Array,s=1;s*s<=i;s++)if(r%s==0&&i%s==0){a.push(s);var u=i/s|0;s!==u&&r%u==0&&o.unshift()}return a.concat(o)}(r,i))||l(n(a))||l(n(h*c))}function a(t,e){var r=t.width,n=t.height,a=e.halfSample?1:0,s=t.config;if(s&&s.area){var u=function(t,e,r){var n={width:t,height:e},i=Object.keys(r).reduce(function(t,e){var i=r[e],a=function(t){return{value:parseFloat(t),unit:t.indexOf("%")===t.length-1?"%":t.indexOf("px")===t.length-2?"px":"%"}}(i),s=o[e](a,n);return t[e]=s,t},{});return{topLeft:{x:i.left,y:i.top},width:i.right-i.left,height:i.bottom-i.top}}(r,n,s.area);t.topLeft=u.topLeft,t.setCanvasSize(r,n),r=u.width,n=u.height}var c={x:r>>a,y:n>>a},h=i(e.patchSize,c);if(t.width=(c.x/h.x<u&&(u=e),rc&&(c=r)})});var h=[{x:o,y:s},{x:u,y:s},{x:u,y:c},{x:o,y:c}];return h=h.map(function(t){return Object(d.d)(t,a)}),this._config.halfSample&&(h=h.map(function(t){var e=t.x,r=t.y;return{x:2*e,y:r*=2}})),h}},{key:"_binarizeImage",value:function(){Object(d.c)(this._currentImageWrapper,this._binaryImageWrapper),this._binaryImageWrapper.zeroBorder()}},{key:"_findPatches",value:function(){for(var t=new Array,e=0;e0&&e[t-1]++}),e.map(function(t,e){return{value:t,index:e}}).filter(function(t){return t.value>=5}).sort(function(t,e){return e.value-t.value}).map(function(t){return t.index+1})}},{key:"_findBoxes",value:function(t,e){var r=this,n=new Array;return t.forEach(function(t){var e=new Array;r._patchLabelGrid.data.forEach(function(n,i){n===t&&e.push(r._imageToPatchGrid[i])});var i=r._boxFromPatches(e);i&&n.push(i)}),n}},{key:"_similarMoments",value:function(t){return c.a.clusterize(t,.9).reduce(function(t,e){var r=e.moments.length;return r>t.count?{item:e,count:r}:t},{item:{moments:[]},count:0}).item.moments}},{key:"_skeletonize",value:function(t,e){this._binaryImageWrapper.subImageAsCopy(this._subImageWrapper,t,e),this._skeletonizer.skeletonize()}},{key:"_describePatch",value:function(t,e,r,n){if(t.length>1){var i=Math.ceil(this._patchSize.x/3),a=t.filter(function(t){return t.m00>i});if(a.length>1){var o=this._similarMoments(a),s=0|o.length;if(s>1&&s<<2>=3*a.length&&s<<2>t.length){var u=o.reduce(function(t,e){return t+e.rad},0)/s;return{index:e,pos:{x:r,y:n},box:[{x:r,y:n},{x:r+this._subImageWrapper.size.x,y:n},{x:r+this._subImageWrapper.size.x,y:n+this._subImageWrapper.size.y},{x:r,y:n+this._subImageWrapper.size.y}],moments:o,rad:u,x:Math.cos(u),y:Math.sin(u)}}}}return null}},{key:"_notYetProcessed",value:function(){for(var t=0;t.95&&r._trace(u,e)}})}}},{key:"_rasterizeAngularSimilarity",value:function(t){var e=this,r=0;this._patchGrid.data.fill(0),this._patchLabelGrid.data.fill(0),this._imageToPatchGrid.fill(null),t.forEach(function(t){e._imageToPatchGrid[t.index]=t,e._patchGrid.data[t.index]=1}),this._patchGrid.zeroBorder();for(var n=0;(n=this._notYetProcessed())this._threshold}},{key:"moments",get:function(){return this._moments}}]),t}()},function(t,e,r){"use strict";r.d(e,"a",function(){return f});var n,i,a=r(2),o=r.n(a),s=r(1),u=r.n(s),c=r(0),h=r.n(c),l=r(17);!function(t){t[t.Outside=-32767]="Outside",t[t.Inside=-32766]="Inside"}(n||(n={})),function(t){t[t.CW=0]="CW",t[t.CCW=1]="CCW",t[t.Unknown=2]="Unknown"}(i||(i={}));var f=function(){function t(e,r){o()(this,t),h()(this,"_width",void 0),h()(this,"_height",void 0),h()(this,"_tracer",void 0),h()(this,"_imageData",void 0),h()(this,"_labelData",void 0),this._imageData=e.data,this._labelData=r.data,this._width=e.size.x,this._height=e.size.y,this._tracer=new l.b(e,r)}return u()(t,[{key:"rasterize",value:function(t){for(var e=new Array,r=0;r<400;r++)e[r]=0;e[0]=this._imageData[0];for(var a,o=null,s=0,u=1;u0){o=o-1|0;n[r+o|0]=(n[t+o|0]|0)-(n[e+o|0]|0)|0}}function u(t,e,r){t=t|0;e=e|0;r=r|0;var o=0;o=a(i,i)|0;while((o|0)>0){o=o-1|0;n[r+o|0]=n[t+o|0]|0|(n[e+o|0]|0)|0}}function c(t){t=t|0;var e=0,r=0;r=a(i,i)|0;while((r|0)>0){r=r-1|0;e=(e|0)+(n[t+r|0]|0)|0}return e|0}function h(t,e){t=t|0;e=e|0;var r=0;r=a(i,i)|0;while((r|0)>0){r=r-1|0;n[t+r|0]=e}}function l(t,e){t=t|0;e=e|0;var r=0,a=0,o=0,s=0,u=0,c=0,h=0,l=0;for(r=1;(r|0)<(i-1|0);r=r+1|0){l=l+i|0;for(a=1;(a|0)<(i-1|0);a=a+1|0){s=l-i|0;u=l+i|0;c=a-1|0;h=a+1|0;o=(n[t+s+c|0]|0)+(n[t+s+h|0]|0)+(n[t+l+a|0]|0)+(n[t+u+c|0]|0)+(n[t+u+h|0]|0)|0;if((o|0)>(0|0)){n[e+l+a|0]=1}else{n[e+l+a|0]=0}}}return}function f(t,e){t=t|0;e=e|0;var r=0;r=a(i,i)|0;while((r|0)>0){r=r-1|0;n[e+r|0]=n[t+r|0]|0}}function d(t){t=t|0;var e=0,r=0;for(e=0;(e|0)<(i-1|0);e=e+1|0){n[t+e|0]=0;n[t+r|0]=0;r=r+i-1|0;n[t+r|0]=0;r=r+1|0}for(e=0;(e|0)<(i|0);e=e+1|0){n[t+r|0]=0;r=r+1|0}}function v(){var t=0,e=0,r=0,n=0,v=0,_=0;e=a(i,i)|0;r=e+e|0;n=r+e|0;h(n,0);d(t);do{o(t,e);l(e,r);s(t,r,r);u(n,r,n);f(e,t);v=c(t)|0;_=(v|0)==0|0}while(!_)}return{skeletonize:v}}},function(t,e){t.exports=function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e=0,a=i&&n.regeneratorRuntime;if(n.regeneratorRuntime=void 0,t.exports=r(28),i)n.regeneratorRuntime=a;else try{delete n.regeneratorRuntime}catch(t){n.regeneratorRuntime=void 0}},function(t,e){!function(e){"use strict";var r,n=Object.prototype,i=n.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag",c="object"==typeof t,h=e.regeneratorRuntime;if(h)c&&(t.exports=h);else{(h=e.regeneratorRuntime=c?t.exports:{}).wrap=b;var l="suspendedStart",f="suspendedYield",d="executing",v="completed",_={},p={};p[o]=function(){return this};var g=Object.getPrototypeOf,y=g&&g(g(I([])));y&&y!==n&&i.call(y,o)&&(p=y);var m=C.prototype=x.prototype=Object.create(p);k.prototype=m.constructor=C,C.constructor=k,C[u]=k.displayName="GeneratorFunction",h.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===k||"GeneratorFunction"===(e.displayName||e.name))},h.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,C):(t.__proto__=C,u in t||(t[u]="GeneratorFunction")),t.prototype=Object.create(m),t},h.awrap=function(t){return{__await:t}},E(S.prototype),S.prototype[s]=function(){return this},h.AsyncIterator=S,h.async=function(t,e,r,n){var i=new S(b(t,e,r,n));return h.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},E(m),m[u]="Generator",m[o]=function(){return this},m.toString=function(){return"[object Generator]"},h.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},h.values=I,R.prototype={constructor:R,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,i){return s.type="throw",s.arg=t,e.next=n,i&&(e.method="next",e.arg=r),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var u=i.call(o,"catchLoc"),c=i.call(o,"finallyLoc");if(u&&c){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;P(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:I(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),_}}}function b(t,e,r,n){var i=e&&e.prototype instanceof x?e:x,a=Object.create(i.prototype),o=new R(n||[]);return a._invoke=function(t,e,r){var n=l;return function(i,a){if(n===d)throw new Error("Generator is already running");if(n===v){if("throw"===i)throw a;return z()}for(r.method=i,r.arg=a;;){var o=r.delegate;if(o){var s=A(o,r);if(s){if(s===_)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var u=w(t,e,r);if("normal"===u.type){if(n=r.done?v:f,u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=v,r.method="throw",r.arg=u.arg)}}}(t,r,o),a}function w(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}function x(){}function k(){}function C(){}function E(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function S(t){var e;this._invoke=function(r,n){function a(){return new Promise(function(e,a){!function e(r,n,a,o){var s=w(t[r],t,n);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"==typeof c&&i.call(c,"__await")?Promise.resolve(c.__await).then(function(t){e("next",t,a,o)},function(t){e("throw",t,a,o)}):Promise.resolve(c).then(function(t){u.value=t,a(u)},function(t){return e("throw",t,a,o)})}o(s.arg)}(r,n,e,a)})}return e=e?e.then(a,a):a()}}function A(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,A(t,e),"throw"===e.method))return _;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var i=w(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,_;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,_):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,_)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function I(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++nr)return Number.MAX_VALUE;n+=l}return n/a}},{key:"_correctBars",value:function(t,e,r){for(var n=r.length,i=0;n--;)(i=t[r[n]]*(1-(1-e)/2))>1&&(t[r[n]]=i)}},{key:"decodePattern",value:function(t){this._row=t;var e=this.decode();return null===e?(this._row.reverse(),(e=this.decode())&&(e.direction=b.Reverse,e.start=this._row.length-e.start,e.end=this._row.length-e.end)):e.direction=b.Forward,e&&(e.format=this.FORMAT),e}},{key:"_fillCounters",value:function(t,e,r){var n=new Array,i=0;n[i]=0;for(var a=t;aa)return null;var l=I[i.code];return l&&(i.correction.bar=this._calculateCorrection(l,r,z),i.correction.space=this._calculateCorrection(l,r,D)),i}r[++s]=1,o=o?0:1}return null}},{key:"_correct",value:function(t,e){this._correctBars(t,e.bar,z),this._correctBars(t,e.space,D)}},{key:"_findStart",value:function(){for(var t,e=[0,0,0,0,0,0],r=this._nextSet(this._row),n={error:Number.MAX_VALUE,code:-1,start:0,end:0,correction:{bar:1,space:1}},i=this.AVERAGE_CODE_ERROR,a=0,o=0,s=r;s=n}},{key:"_findNextWidth",value:function(t,e){for(var r=Number.MAX_VALUE,n=0;ne&&(r=t[n]);return r}},{key:"_toPattern",value:function(t){for(var e,r=t.length,n=0,i=r,a=0;i>3;){n=this._findNextWidth(t,n),i=0,e=0;for(var o=0;on&&(e|=1<0;s++)if(t[s]>n&&(i--,2*t[s]>=a))return-1;return e}}return-1}},{key:"_findStart",value:function(){for(var t,e=this._nextSet(this._row),r=e,n=new Uint16Array(9),i=0,a=0,o=e;o1&&V.some(function(t){return t===e}))break}while(nthis._counters.length?this._counters.length:n;var a=t.start+this._sumCounters(t.startCounter,n-8);return{code:r.join(""),start:t.start,end:a,startInfo:t,decodedCodes:r}}},{key:"_verifyWhitespace",value:function(t,e){return(t-1<=0||this._counters[t-1]>=this._calculatePatternLength(t)/2)&&(e+8>=this._counters.length||this._counters[e+7]>=this._calculatePatternLength(e)/2)}},{key:"_calculatePatternLength",value:function(t){for(var e=0,r=t;r=0;o--){var s=2==(1&o)?r.bar:r.space,u=1==(1&a)?s.wide:s.narrow;u.size+=this._counters[n+o],u.counts++,a>>=1}n+=8}return["space","bar"].forEach(function(t){var e=r[t];e.wide.min=Math.floor((e.narrow.size/e.narrow.counts+e.wide.size/e.wide.counts)/2),e.narrow.max=Math.ceil(e.wide.min),e.wide.max=Math.ceil((2*e.wide.size+1.5)/e.wide.counts)}),r}},{key:"_charToPattern",value:function(t){for(var e=t.charCodeAt(0),r=0;r=0;o--){var s=0==(1&o)?r.bar:r.space,u=1==(1&a)?s.wide:s.narrow,c=this._counters[n+o];if(cu.max)return!1;a>>=1}n+=8}return!0}},{key:"_patternToChar",value:function(t){for(var e=0;en&&(n=a),athis._counters.length)return-1;for(var r=this._computeAlternatingThreshold(t,e),n=this._computeAlternatingThreshold(t+1,e),i=64,a=0,o=0;o<7;o++){var s=0==(1&o)?r:n;this._counters[t+o]>s&&(a|=i),i>>=1}return a}},{key:"_sumCounters",value:function(t,e){for(var r=0,n=t;na?null:i}r[++s]=1,o=o?0:1}return null}},{key:"_findStart",value:function(){for(var t,e=this._nextSet(this._row);!t;){if(!(t=this._findPattern(this.START_PATTERN,e,0,!0)))return null;var r=t.start-(t.end-t.start);if(r>=0&&this._matchRange(r,t.start,0))return t;e=t.end,t=null}return null}},{key:"_verifyTrailingWhitespace",value:function(t){var e=t.end+(t.end-t.start);return e=this.CODE_G_START?(t.code-=this.CODE_G_START,n|=1<<5-i):n|=0<<5-i,e.push(t.code),r.push(t)}var a=this._calculateFirstDigit(n);if(null===a)return null;if(e.unshift(a),null===(t=this._findPattern(this.MIDDLE_PATTERN,t.end,1,!1)))return null;r.push(t);for(var o=0;o<6;o++){if(!(t=this._decodeCode(t.end,this.CODE_G_START)))return null;r.push(t),e.push(t.code)}return t}},{key:"decode",value:function(){var t=new Array,e=new Array,r={},n=this._findStart();if(!n)return null;var i={code:n.code,start:n.start,end:n.end};if(e.push(i),!(i=this._decodePayload(i,t,e)))return null;if(!(i=this._findEnd(i.end,0)))return null;if(e.push(i),!this._checksum(t))return null;if(this.supplements.length>0){var a=this._decodeExtensions(i.end);if(!a)return null;var o=a.decodedCodes[a.decodedCodes.length-1],s={start:o.start+((o.end-o.start)/2|0),end:o.end};if(!this._verifyTrailingWhitespace(s))return null;r={supplement:a,code:t.join("")+a.code}}return function(t){for(var e=1;e=0;r-=2)e+=t[r];e*=3;for(var n=t.length-1;n>=0;n-=2)e+=t[n];return e%10==0}}]),e}(R),$=function(t){function e(t,r){var n;return a()(this,e),(n=E()(this,A()(e).call(this,t,r)))._format="ean_8",n}return P()(e,t),s()(e,[{key:"_decodePayload",value:function(t,e,r){for(var n=0;n<4;n++){if(!(t=this._decodeCode(t.end,this.CODE_G_START)))return null;e.push(t.code),r.push(t)}if(null===(t=this._findPattern(this.MIDDLE_PATTERN,t.end,1,!1)))return null;r.push(t);for(var i=0;i<4;i++){if(!(t=this._decodeCode(t.end,this.CODE_G_START)))return null;r.push(t),e.push(t.code)}return t}}]),e}(J),tt=function(t){function e(t,r){var n;return a()(this,e),(n=E()(this,A()(e).call(this,t,r)))._format="ean_2",n}return P()(e,t),s()(e,[{key:"decode",value:function(t,e){var r,n=t.length,i=new Array,a=new Array,o=e,s=0;this._row=t;for(var u=0;u<2&&o=this.CODE_G_START&&(s|=1<<1-u),1!==u&&(o=this._nextSet(this._row,r.end),o=this._nextUnset(this._row,o))}return 2!==i.length||parseInt(i.join(""))%4!==s?null:{code:i.join(""),decodedCodes:a,end:r.end}}}]),e}(J),et=function(t){function e(t,r){var n;return a()(this,e),(n=E()(this,A()(e).call(this,t,r)))._format="ean_5",n}return P()(e,t),s()(e,[{key:"CHECK_DIGIT_ENCODINGS",get:function(){return[24,20,18,17,12,6,3,10,9,5]}}]),s()(e,[{key:"decode",value:function(t,e){var r,n=t.length,i=new Array,a=new Array,o=0,s=e;this._row=t;for(var u=0;u<5&&s=this.CODE_G_START&&(o|=1<<4-u),4!==u&&(s=this._nextSet(this._row,r.end),s=this._nextUnset(this._row,s))}return 5!==i.length?null:this._extensionChecksum(i)!==this._determineCheckDigit(o)?null:{code:i.join(""),decodedCodes:a,end:r.end}}},{key:"_determineCheckDigit",value:function(t){for(var e=0;e<10;e++)if(t===this.CHECK_DIGIT_ENCODINGS[e])return e;return null}},{key:"_extensionChecksum",value:function(t){for(var e=t.length,r=0,n=e-2;n>=0;n-=2)r+=t[n];r*=3;for(var i=e-1;i>=0;i-=2)r+=t[i];return(r*=3)%10}}]),e}(J),rt=function(t){function e(t,r){var n;return a()(this,e),(n=E()(this,A()(e).call(this,t,r)))._format="upc_a",n}return P()(e,t),s()(e,[{key:"decode",value:function(){var t=U()(A()(e.prototype),"decode",this).call(this);return t&&t.code&&13===t.code.length&&"0"===t.code.charAt(0)?(t.code=t.code.substring(1),t):null}}]),e}(J),nt=[[56,52,50,49,44,38,35,42,41,37],[7,11,13,14,19,25,28,21,22,26]],it=function(t){function e(t,r){var n;return a()(this,e),(n=E()(this,A()(e).call(this,t,r)))._format="upc_e",n}return P()(e,t),s()(e,[{key:"STOP_PATTERN",get:function(){return[1/6*7,1/6*7,1/6*7,1/6*7,1/6*7,1/6*7]}}]),s()(e,[{key:"_decodePayload",value:function(t,e,r){for(var n=0,i=0;i<6;i++){if(!(t=this._decodeCode(t.end)))return null;t.code>=this.CODE_G_START&&(t.code=t.code-this.CODE_G_START,n|=1<<5-i),e.push(t.code),r.push(t)}return this._determineParity(n,e)?t:null}},{key:"_determineParity",value:function(t,e){for(var r=0;r>2,n=t.start-10*r;if(n>=0&&this._matchRange(n,t.start,0))return t;e=t.end,t=null}return null}},{key:"_verifyTrailingWhitespace",value:function(t){var e=t.end+(t.end-t.start)/2;return e=0&&this._matchRange(n,t.start,0))return t;e=t.end,t=null}return null}},{key:"_verifyTrailingWhitespace",value:function(t){var e=t.end+(t.end-t.start)/2;return e4)return-1;if(0==(1&a))for(var s=0;s="a"&&i<="d"){if(n>e-2)return null;var a=t[++n],o=a.charCodeAt(0),s=void 0;switch(i){case"a":if(!(a>="A"&&a<="Z"))return null;s=String.fromCharCode(o-64);break;case"b":if(a>="A"&&a<="E")s=String.fromCharCode(o-38);else if(a>="F"&&a<="J")s=String.fromCharCode(o-11);else if(a>="K"&&a<="O")s=String.fromCharCode(o+16);else if(a>="P"&&a<="S")s=String.fromCharCode(o+43);else{if(!(a>="T"&&a<="Z"))return null;s=String.fromCharCode(127)}break;case"c":if(a>="A"&&a<="O")s=String.fromCharCode(o-32);else{if("Z"!==a)return null;s=":"}break;case"d":if(!(a>="A"&&a<="Z"))return null;s=String.fromCharCode(o+32)}r.push(s)}else r.push(i)}return r}},{key:"_verifyChecksums",value:function(t){return this._matchCheckChar(t,t.length-2,20)&&this._matchCheckChar(t,t.length-1,15)}},{key:"_matchCheckChar",value:function(t,e,r){var n=t.slice(0,e),i=n.length,a=n.reduce(function(t,e,n){return t+((-1*n+(i-1))%r+1)*vt.indexOf(e.charCodeAt(0))},0);return vt[a%47]===t[e].charCodeAt(0)}}]),e}(R)};function gt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}!function(t){t[t.Up=1]="Up",t[t.Down=-1]="Down"}(Q||(Q={}));var yt,mt=function(t,e,r){var n,i,a=0|e.x,o=0|e.y,s=0|r.x,u=0|r.y,c=Math.abs(u-o)>Math.abs(s-a),h=[],l=t.data,f=t.size.x,d=255,v=0;function _(t,e){i=l[e*f+t],d=iv?i:v,h.push(i)}c&&(n=a,a=o,o=n,n=s,s=u,u=n),a>s&&(n=a,a=s,s=n,n=o,o=u,u=n);for(var p=s-a,g=Math.abs(u-o),y=p/2|0,m=o,b=oi?Q.Up:Q.Down;a.push({pos:0,val:n[0]});for(var h=0;ho&&n[h+1]>.5*i?Q.Up:u)&&(a.push({pos:h,val:n[h]}),u=d)}a.push({pos:n.length,val:n[n.length-1]});for(var v=a[0].pos;vi?0:1;for(var _=1;_a[_].val?a[_].val+(a[_+1].val-a[_].val)/3*2|0:a[_+1].val+(a[_].val-a[_+1].val)/3|0;for(var p=a[_].pos;po?0:1}return function(t){for(var e=1;e1&&(!this._inputImageWrapper.inImageWithBorder(t[0],0)||!this._inputImageWrapper.inImageWithBorder(t[1],0));)r(-(n>>=1));return t}},{key:"_getLine",value:function(t){return[{x:(t[1].x+t[0].x)/2,y:(t[1].y+t[0].y)/2},{x:(t[3].x+t[2].x)/2,y:(t[3].y+t[2].y)/2}]}},{key:"_tryDecode",value:function(t){var e=mt(this._inputImageWrapper,t[0],t[1]);e=bt(e);var r=null;return this._barcodeReaders.some(function(t){return!!(r=t.decodePattern(e.line))}),r?{codeResult:r,barcodeLine:e}:null}},{key:"_tryDecodeBruteForce",value:function(t,e,r){for(var n=Math.sqrt(Math.pow(t[1].x-t[0].x,2)+Math.pow(t[1].y-t[0].y,2)),i=Math.sin(r),a=Math.cos(r),o=1;o<16;o++){var s=n/16*o*(o%2==0?-1:1);e[0].y+=s*i,e[0].x-=s*a,e[1].y+=s*i,e[1].x-=s*a;var u=this._tryDecode(e);if(u)return u}return null}},{key:"_printFrequency",value:function(t){var e=this._frequencyCanvas.getContext("2d");this._frequencyCanvas.width=t.length,this._frequencyCanvas.height=256,e.beginPath(),e.strokeStyle="blue";for(var r=0;r0&&(i=s,console.log("WARNING: Constraint 'minAspectRatio' is deprecated; Use 'aspectRatio' instead")),void 0!==u&&(n=u,console.log("WARNING: Constraint 'facing' is deprecated. Use 'facingMode' instead'")),{audio:!1,video:a&&n?{width:e,height:r,aspectRatio:i,deviceId:a}:{width:e,height:r,facingMode:n,aspectRatio:i,deviceId:a}}}};function Pt(t){var e=t.videoWidth,r=t.videoHeight;return new Promise(function(t,n){var i=10;!function a(){i>0?e>10&&r>10?t():window.setTimeout(a,500):n("Unable to play video stream. Is webcam working?"),i--}()})}var Rt=Math.PI/2,It=function(){function t(e,r){a()(this,t),c()(this,"_inputStream",void 0),c()(this,"_streamConfig",void 0),c()(this,"_canvas",void 0),c()(this,"_context",void 0),c()(this,"_data",void 0),c()(this,"_canvasHeight",void 0),c()(this,"_canvasWidth",void 0),c()(this,"_height",void 0),c()(this,"_width",void 0),c()(this,"_topLeft",void 0),this._inputStream=e,this._streamConfig=e.config,this._canvasWidth=e.canvasWidth,this._canvasHeight=e.canvasHeight,this._width=e.width,this._height=e.height,this._topLeft=e.topLeft,this._canvas=r||document.createElement("canvas"),this._canvas.width=this._canvasWidth,this._canvas.height=this._canvasHeight,this._context=this._canvas.getContext("2d"),this._data=new Uint8Array(this._width*this._height)}return s()(t,[{key:"grab",value:function(t){this._data=t;var e=this._inputStream.getFrame();if(e){var r;this._adjustCanvasSize();var n=0;if(e instanceof HTMLVideoElement)r=e;else if(r=e.image,e.tags)switch(e.tags.orientation){case 6:n=Rt;break;case 8:n=-Rt}if(0!==n){var i=this._canvasWidth>>1,a=this._canvasHeight>>1;this._context.translate(i,a),this._context.rotate(n),this._context.drawImage(r,-a,-i,this._canvasHeight,this._canvasWidth),this._context.rotate(-n),this._context.translate(-i,-a)}else this._context.drawImage(r,0,0,this._canvasWidth,this._canvasHeight);var o=this._context.getImageData(this._topLeft.x,this._topLeft.y,this._width,this._height).data;return this._streamConfig.halfSample?this._grayAndHalfSampleFromCanvasData(o):this._computeGray(o),!0}return!1}},{key:"_adjustCanvasSize",value:function(){this._canvas.height===this._canvasHeight&&this._canvas.width===this._canvasWidth||(this._canvas.height=this._canvasHeight,this._canvas.width=this._canvasWidth)}},{key:"_grayAndHalfSampleFromCanvasData",value:function(t){for(var e=t.length>>2,r=this._width>>1,n=0,i=this._width,a=0;i1&&void 0!==i[1]?i[1]:Dt,!/^blob:/i.test(e)){t.next=6;break}return t.next=4,Lt(e);case 4:return n=t.sent,t.abrupt("return",Tt(n,r));case 6:return t.abrupt("return",Promise.resolve(null));case 7:case"end":return t.stop()}},t)}))).apply(this,arguments)}function Tt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Dt,r=new DataView(t),n=t.byteLength,i=e.reduce(function(t,e){var r=Object.keys(zt).find(function(t){return zt[t]===e});return r&&(t[r]=e),t},{}),a=2;if(255!==r.getUint8(0)||216!==r.getUint8(1))return null;for(;at._height?t._config.size:t._width*t._config.size/t._height|0:t._width,t._canvasHeight=t._calculatedHeight=t._config.size?t._width>t._height?t._height*t._config.size/t._width|0:t._config.size:t._height,t._loaded=!0,t._frameIndex=0,setTimeout(function(){return t.trigger("canrecord",[])},0)},this._offset,this._size,this._config.sequence)}},{key:"realHeight",get:function(){return this._height}},{key:"realWidth",get:function(){return this._width}},{key:"config",get:function(){return this._config},set:function(t){this._config=function(t){for(var e=1;ee?this._config.size:t*this._config.size/e|0:t,this._canvasHeight=this._calculatedHeight=this._config.size?t>e?e*this._config.size/t|0:this._config.size:e}},{key:"realHeight",get:function(){return this._video.videoHeight}},{key:"realWidth",get:function(){return this._video.videoWidth}},{key:"config",get:function(){return this._config},set:function(t){this._config=function(t){for(var e=1;e=e&&(e+=t,ve()),window.requestAnimationFrame(r))}(performance.now())):ve()},stop:function(){Zt=!0,ge(0),"LiveStream"===re.inputStream.type&&(Ot.release(),Xt.clearEventHandlers())},decodeSingle:function(t,e){var r=this;t=m({inputStream:{type:"ImageStream",sequence:!1,size:800,src:t.src},numOfWorkers:1,locator:{halfSample:!1}},t),this.init(t,function(){d.once("processed",function(t){r.stop(),e.call(null,t)},!0),r.start()})},pause:function(){Zt=!0},onDetected:function(t){d.subscribe("detected",t)},offDetected:function(t){d.unsubscribe("detected",t)},onProcessed:function(t){d.subscribe("processed",t)},offProcessed:function(t){d.unsubscribe("processed",t)},setReaders:function(t){$t?$t.setReaders(t):te&&ue.length>0&&ue.forEach(function(e){return e.worker.postMessage({cmd:"setReaders",readers:t})})},registerResultCollector:function(t){t&&"function"==typeof t.addResult&&(ee=t)}};function ce(t){!function(t){Yt=t||new p.a({x:Xt.width,y:Xt.height});0;Jt=[{x:0,y:0},{x:0,y:Yt.size.y},{x:Yt.size.x,y:Yt.size.y},{x:Yt.size.x,y:0}],Kt=new oe.a(Yt,re.locator)}(t),$t=new wt(re.decoder,Yt)}function he(){var t=re.inputStream.target;if(t instanceof HTMLElement)return t;var e="string"==typeof t?t:"#interactive.viewport";return document.querySelector(e)}function le(t,e){t.forEach(function(t){t.x+=e.x,t.y+=e.y})}function fe(t,e){var r=t;if(t&&te){var n=Xt.topLeft;0===n.x&&0===n.y||function t(e,r){e.barcodes&&e.barcodes.forEach(function(e){return t(e,r)}),e.line&&le(e.line,r),e.box&&le(e.box,r),e.boxes&&e.boxes.forEach(function(t){return le(t,r)})}(t,n),function(t,e,r,n){e&&ee&&(t.barcodes?t.barcodes.forEach(function(t){var i=t.codeResult;i&&ee.addResult(e,r,n,i)}):t.codeResult&&ee.addResult(e,r,n,t.codeResult))}(t,e,Xt.canvasWidth,Xt.canvasHeight),r=t.barcodes||t}d.publish("processed",r),function(t){return t&&(!!t.codeResult||t.barcodes&&t.barcodes.some(function(t){return!!t.codeResult}))}(t)&&d.publish("detected",r)}function de(){var t=re.locate?Kt.locate():[Jt];fe($t.decodeFromBoundingBoxes(t),Yt.data)}function ve(){if(te)if(ue.length>0){var t=ue.find(function(t){return!t.busy});if(!t)return;var e=t.imageData;Qt.grab(e)&&(t.busy=!0,t.worker.postMessage({cmd:"process",imageData:e},[e.buffer]))}else Qt.grab(Yt.data)&&de();else de()}function _e(e){var r,n,i=(r=t||"",n=new Blob(["(".concat(pe.toString(),")(").concat(r,");")],{type:"text/javascript"}),window.URL.createObjectURL(n)),a={worker:new Worker(i),imageData:new Uint8Array(Xt.width*Xt.height),busy:!0};a.worker.onmessage=function(t){var r=t.data;"initialized"===r.event?(URL.revokeObjectURL(i),a.busy=!1,a.imageData=new Uint8Array(r.imageData),e(a)):"processed"===r.event?(a.busy=!1,a.imageData=new Uint8Array(r.imageData),fe(r.result,a.imageData)):r.event},a.worker.postMessage({cmd:"init",size:{x:Xt.width,y:Xt.height},imageData:a.imageData,config:m(re,{inputStream:{target:null}})},[a.imageData.buffer])}function pe(t){var e,r,n=self;!t||(e=t().default)?self.onmessage=function(t){var i=t.data;if("init"===i.cmd){var a=i.config;a.numOfWorkers=0,r=new e.ImageWrapper({x:i.size.x,y:i.size.y},new Uint8Array(i.imageData)),e.init(a,function(){return n.postMessage({event:"initialized",imageData:r.data},[r.data.buffer])},r),e.onProcessed(function(t){return n.postMessage({event:"processed",imageData:r.data,result:t},[r.data.buffer])})}else"process"===i.cmd?(r.data=new Uint8Array(i.imageData),e.start()):"setReaders"===i.cmd&&e.setReaders(i.readers)}:n.postMessage({event:"error",message:"Quagga could not be created"})}function ge(t,e){var r=t-ue.length;if(!(r>0))return r<0&&(ue.slice(r).forEach(function(t){t.worker.terminate()}),ue=ue.slice(0,r)),e&&e();for(var n=0;n=t&&e&&e()})}}])});