var Utils=require("./utils");function getColorAttrib(t,r){var o=t.a/255,i=r+'="'+t.hex+'"';return o<1?i+" "+r+'-opacity="'+o.toFixed(2).slice(1)+'"':i}function svgCmd(t,r,o){var i=t+r;return void 0!==o&&(i+=" "+o),i}function qrToPath(t,r,o){for(var i="",e=0,n=!1,l=0,a=0;a<t.length;a++){var s=Math.floor(a%r),g=Math.floor(a/r);s||n||(n=!0),t[a]?(l++,a>0&&s>0&&t[a-1]||(i+=n?svgCmd("M",s+o,.5+g+o):svgCmd("m",e,0),e=0,n=!1),s+1<r&&t[a+1]||(i+=svgCmd("h",l),l=0)):e++}return i}exports.render=function(t,r,o){var i=Utils.getOptions(r),e=t.modules.size,n=t.modules.data,l=e+2*i.margin,a=i.color.light.a?"<path "+getColorAttrib(i.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",s="<path "+getColorAttrib(i.color.dark,"stroke")+' d="'+qrToPath(n,e,i.margin)+'"/>',g='viewBox="0 0 '+l+" "+l+'"',h='<svg xmlns="http://www.w3.org/2000/svg" '+(i.width?'width="'+i.width+'" height="'+i.width+'" ':"")+g+' shape-rendering="crispEdges">'+a+s+"</svg>\n";return"function"==typeof o&&o(null,h),h};