(function(d){function n(a,b,c){var f=d(a);b=f.clone(b,c);var e=f.find("textarea").add(f.filter("textarea")),h=b.find("textarea").add(b.filter("textarea"));c=f.find("select").add(f.filter("select"));a=b.find("select").add(b.filter("select"));f=f.find("canvas").add(f.filter("canvas"));var m=b.find("canvas").add(b.filter("canvas")),k;var g=0;for(k=e.length;g<k;++g)d(h[g]).val(d(e[g]).val());g=0;for(k=c.length;g<k;++g)for(e=0,h=c[g].options.length;e<h;++e)!0===c[g].options[e].selected&&(a[g].options[e].selected=
!0);g=0;for(k=f.length;g<k;++g)if(c=f[g].getContext("2d"))m[g].getContext("2d").drawImage(f[g],0,0),d(m[g]).attr("data-jquery-print",c.canvas.toDataURL());return b}function q(a){var b=d("");try{b=n(a)}catch(c){b=d("\x3cspan /\x3e").html(a)}return b}function r(a,b,c){var f=d.Deferred();try{a=a.contentWindow||a.contentDocument||a;try{a.resizeTo(window.innerWidth,window.innerHeight)}catch(l){console.warn(l)}var e=a.document||a.contentDocument||a;c.doctype&&e.write(c.doctype);e.write(b);try{var h=e.querySelectorAll("canvas");
for(b=0;b<h.length;b++){var m=h[b].getContext("2d"),k=new Image;k.onload=function(){m.drawImage(k,0,0)};k.src=h[b].getAttribute("data-jquery-print")}}catch(l){console.warn(l)}e.close();var g=!1;e=function(){if(!g){a.focus();try{a.document.execCommand("print",!1,null)||a.print(),d("body").focus()}catch(l){a.print()}a.close();g=!0;f.resolve()}};d(a).on("load",e);setTimeout(e,c.timeout)}catch(l){f.reject(l)}return f}function u(a,b){var c=d(b.iframe+""),f=c.length;0===f&&(c=d('\x3ciframe height\x3d"0" width\x3d"0" border\x3d"0" wmode\x3d"Opaque"/\x3e').prependTo("body").css({position:"absolute",
top:-999,left:-999}));var e=c.get(0);return r(e,a,b).done(function(){setTimeout(function(){0===f&&c.remove()},1E3)}).fail(function(h){console.error("Failed to print from iframe",h);p(a,b)}).always(function(){try{b.deferred.resolve()}catch(h){console.warn("Error notifying deferred",h)}})}function p(a,b){var c=window.open();return r(c,a,b).always(function(){try{b.deferred.resolve()}catch(f){console.warn("Error notifying deferred",f)}})}function t(a){return!!("object"===typeof Node?a instanceof Node:
a&&"object"===typeof a&&"number"===typeof a.nodeType&&"string"===typeof a.nodeName)}d.print=d.fn.print=function(){var a;var b=this;b instanceof d&&(b=b.get(0));t(b)?(b=d(b),0<arguments.length&&(a=arguments[0])):0<arguments.length?(b=d(arguments[0]),t(b[0])?1<arguments.length&&(a=arguments[1]):(a=arguments[0],b=d("html"))):b=d("html");var c={globalStyles:!0,mediaPrint:!1,stylesheet:null,noPrintSelector:".no-print",iframe:!0,append:null,prepend:null,manuallyCopyFormValues:!0,deferred:d.Deferred(),timeout:750,
title:null,doctype:"\x3c!doctype html\x3e"};a=d.extend({},c,a||{});c=d("");a.globalStyles?c=d("style, link, meta, base, title"):a.mediaPrint&&(c=d("link[media\x3dprint]"));if(a.stylesheet){(d.isArray?d.isArray:Array.isArray)(a.stylesheet)||(a.stylesheet=[a.stylesheet]);for(var f=0;f<a.stylesheet.length;f++)c=d.merge(c,d('\x3clink rel\x3d"stylesheet" href\x3d"'+a.stylesheet[f]+'"\x3e'))}b=n(b,!0,!0);b=d("\x3cspan/\x3e").append(b);b.find(a.noPrintSelector).remove();b.append(n(c));a.title&&(c=d("title",
b),0===c.length&&(c=d("\x3ctitle /\x3e"),b.append(c)),c.text(a.title));b.append(q(a.append));b.prepend(q(a.prepend));a.manuallyCopyFormValues&&(b.find("input").each(function(){var e=d(this);e.is("[type\x3d'radio']")||e.is("[type\x3d'checkbox']")?e.prop("checked")&&e.attr("checked","checked"):e.attr("value",e.val())}),b.find("select").each(function(){d(this).find(":selected").attr("selected","selected")}),b.find("textarea").each(function(){var e=d(this);e.text(e.val())}));c=b.html();try{a.deferred.notify("generated_markup",
c,b)}catch(e){console.warn("Error notifying deferred",e)}b.remove();if(a.iframe)try{u(c,a)}catch(e){console.error("Failed to print from iframe",e.stack,e.message),p(c,a)}else p(c,a);return this}})(jQuery);