window.QRious=function(){"use strict";var t=function(){},e=Object.prototype.hasOwnProperty,i=Array.prototype.slice;function s(t,s,n){for(var r,a,o=0,h=(n=i.call(arguments,2)).length;o>1&1,s=0;s0;e--)s[e]=s[e]?s[e-1]^u.EXPONENT[_._modN(u.LOG[s[e]]+t)]:s[e-1];s[0]=u.EXPONENT[_._modN(u.LOG[s[0]]+t)]}for(t=0;t<=i;t++)s[t]=u.LOG[s[t]]},_checkBadness:function(){var t,e,i,s,n,r=0,a=this._badness,o=this.buffer,h=this.width;for(n=0;nh*h;)u-=h*h,f++;for(r+=f*_.N4,s=0;s=a-2&&(t=a-2,n>9&&t--);var o=t;if(n>9){for(r[o+2]=0,r[o+3]=0;o--;)e=r[o],r[o+3]|=255&e<<4,r[o+2]=e>>4;r[2]|=255&t<<4,r[1]=t>>4,r[0]=64|t>>12}else{for(r[o+1]=0,r[o+2]=0;o--;)e=r[o],r[o+2]|=255&e<<4,r[o+1]=e>>4;r[1]|=255&t<<4,r[0]=64|t>>4}for(o=t+3-(n<10);o=5&&(i+=_.N1+s[e]-5);for(e=3;et||3*s[e-3]>=4*s[e]||3*s[e+3]>=4*s[e])&&(i+=_.N3);return i},_finish:function(){var t,e;this._stringBuffer=this.buffer.slice();var i=0,s=3e4;for(e=0;e<8&&(this._applyMask(e),(t=this._checkBadness())>=1)1&s&&(n[r-1-e+8*r]=1,e<6?n[8+r*e]=1:n[8+r*(e+1)]=1);for(e=0;e<7;e++,s>>=1)1&s&&(n[8+r*(r-7+e)]=1,e?n[6-e+8*r]=1:n[7+8*r]=1)},_interleaveBlocks:function(){var t,e,i=this._dataBlock,s=this._ecc,n=this._eccBlock,r=0,a=this._calculateMaxLength(),o=this._neccBlock1,h=this._neccBlock2,c=this._stringBuffer;for(t=0;t1)for(t=c.BLOCK[s],i=n-7;;){for(e=n-7;e>t-3&&(this._addAlignment(e,i),!(e6)for(t=l.BLOCK[r-7],e=17,i=0;i<6;i++)for(s=0;s<3;s++,e--)1&(e>11?r>>e-12:t>>e)?(n[5-i+a*(2-s+a-11)]=1,n[2-s+a-11+a*(5-i)]=1):(this._setMask(5-i,2-s+a-11),this._setMask(2-s+a-11,5-i))},_isMasked:function(t,e){var i=_._getMaskBit(t,e);return 1===this._mask[i]},_pack:function(){var t,e,i,s=1,n=1,r=this.width,a=r-1,o=r-1,h=(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+this._neccBlock2;for(e=0;ee&&(i=t,t=e,e=i),i=e,i+=e*e,(i>>=1)+t},_modN:function(t){for(;t>=255;)t=((t-=255)>>8)+(255&t);return t},N1:3,N2:3,N3:40,N4:10}),d=_,v=o.extend({draw:function(){this.element.src=this.qrious.toDataURL()},reset:function(){this.element.src=""},resize:function(){var t=this.element;t.width=t.height=this.qrious.size}}),g=a.extend((function(t,e,i,s){this.name=t,this.modifiable=Boolean(e),this.defaultValue=i,this._valueTransformer=s}),{transform:function(t){var e=this._valueTransformer;return"function"==typeof e?e(t,this):t}}),k=a.extend(null,{abs:function(t){return null!=t?Math.abs(t):null},hasOwn:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},noop:function(){},toUpperCase:function(t){return null!=t?t.toUpperCase():null}}),m=a.extend((function(t){this.options={},t.forEach((function(t){this.options[t.name]=t}),this)}),{exists:function(t){return null!=this.options[t]},get:function(t,e){return m._get(this.options[t],e)},getAll:function(t){var e,i=this.options,s={};for(e in i)k.hasOwn(i,e)&&(s[e]=m._get(i[e],t));return s},init:function(t,e,i){var s,n;for(s in"function"!=typeof i&&(i=k.noop),this.options)k.hasOwn(this.options,s)&&(n=this.options[s],m._set(n,n.defaultValue,e),m._createAccessor(n,e,i));this._setAll(t,e,!0)},set:function(t,e,i){return this._set(t,e,i)},setAll:function(t,e){return this._setAll(t,e)},_set:function(t,e,i,s){var n=this.options[t];if(!n)throw new Error("Invalid option: "+t);if(!n.modifiable&&!s)throw new Error("Option cannot be modified: "+t);return m._set(n,e,i)},_setAll:function(t,e,i){if(!t)return!1;var s,n=!1;for(s in t)k.hasOwn(t,s)&&this._set(s,t[s],e,i)&&(n=!0);return n}},{_createAccessor:function(t,e,i){var s={get:function(){return m._get(t,e)}};t.modifiable&&(s.set=function(s){m._set(t,s,e)&&i(s,t)}),Object.defineProperty(e,t.name,s)},_get:function(t,e){return e["_"+t.name]},_set:function(t,e,i){var s="_"+t.name,n=i[s],r=t.transform(null!=e?e:t.defaultValue);return i[s]=r,r!==n}}),p=m,w=a.extend((function(){this._services={}}),{getService:function(t){var e=this._services[t];if(!e)throw new Error("Service is not being managed with name: "+t);return e},setService:function(t,e){if(this._services[t])throw new Error("Service is already managed with name: "+t);e&&(this._services[t]=e)}}),M=new p([new g("background",!0,"white"),new g("backgroundAlpha",!0,1,k.abs),new g("element"),new g("foreground",!0,"black"),new g("foregroundAlpha",!0,1,k.abs),new g("level",!0,"L",k.toUpperCase),new g("mime",!0,"image/png"),new g("padding",!0,null,k.abs),new g("size",!0,100,k.abs),new g("value",!0,"")]),b=new w,B=a.extend((function(t){M.init(t,this,this.update.bind(this));var e=M.get("element",this),i=b.getService("element"),s=e&&i.isCanvas(e)?e:i.createCanvas(),n=e&&i.isImage(e)?e:i.createImage();this._canvasRenderer=new h(this,s,!0),this._imageRenderer=new v(this,n,n===e),this.update()}),{get:function(){return M.getAll(this)},set:function(t){M.setAll(t,this)&&this.update()},toDataURL:function(t){return this.canvas.toDataURL(t||this.mime)},update:function(){var t=new d({level:this.level,value:this.value});this._canvasRenderer.render(t),this._imageRenderer.render(t)}},{use:function(t){b.setService(t.getName(),t)}});Object.defineProperties(B.prototype,{canvas:{get:function(){return this._canvasRenderer.getElement()}},image:{get:function(){return this._imageRenderer.getElement()}}});var O=B,y=a.extend({getName:function(){}}).extend({createCanvas:function(){},createImage:function(){},getName:function(){return"element"},isCanvas:function(t){},isImage:function(t){}}).extend({createCanvas:function(){return document.createElement("canvas")},createImage:function(){return document.createElement("img")},isCanvas:function(t){return t instanceof HTMLCanvasElement},isImage:function(t){return t instanceof HTMLImageElement}});return O.use(new y),O}();