angular.module("monospaced.qrcode",[]).directive("qrcode",["$window",function(e){var r=!!e.CanvasRenderingContext2D,n={L:"Low",M:"Medium",Q:"Quartile",H:"High"},o=function(e,r,n,o){for(var t=0;n>t;t++)for(var i=0;n>i;i++){var a=Math.ceil((i+1)*o)-Math.floor(i*o),c=Math.ceil((t+1)*o)-Math.floor(t*o);e.fillStyle=r.isDark(t,i)?"#000":"#fff",e.fillRect(Math.round(i*o),Math.round(t*o),a,c)}};return{restrict:"E",template:'',link:function(e,t,i){var a,c,d,f,l,s,u,v,h,m=t[0],g=t.find("canvas"),M=g[0],w=r?M.getContext("2d"):null,q="download"in i,p=i.href,$=q||p?document.createElement("a"):"",C=/^\s+|\s+$/g,L=function(e){c=Math.max(1,Math.min(parseInt(e,10),10))||4},b=function(e){d=e in n?e:"M"},D=function(e){if(e){f=e.replace(C,""),v=qrcode(c,d),v.addData(f);try{v.make()}catch(r){return void(a=r.message)}a=!1,s=v.getModuleCount()}},k=function(e){l=parseInt(e,10)||2*s,u=l/s,M.width=M.height=l},H=function(){if(v){if(a)return $&&($.removeAttribute("download"),$.title="",$.href="#_"),r||(m.innerHTML=''),void e.$emit("qrcode:error",a);if(q&&(m.download="qrcode.png",m.title="Download QR code"),r){if(o(w,v,s,u),q)return void(m.href=M.toDataURL("image/png"))}else if(m.innerHTML=v.createImgTag(u,0),h=t.find("img"),h.addClass("qrcode"),q)return void(m.href=h[0].src);p&&(m.href=p)}};$&&($.className="qrcode-link",g.wrap($),m=$),L(i.version),b(i.errorCorrectionLevel),k(i.size),i.$observe("version",function(e){e&&(L(e),D(f),k(l),H())}),i.$observe("errorCorrectionLevel",function(e){e&&(b(e),D(f),k(l),H())}),i.$observe("data",function(e){e&&(D(e),k(l),H())}),i.$observe("size",function(e){e&&(k(e),H())}),i.$observe("href",function(e){e&&(p=e,H())})}}}]);
//# sourceMappingURL=angular-qrcode.min.js.map