UNPKG

cnf-barcode

Version:
3 lines (2 loc) 34.4 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self,function(){var n=t.cnfBarcode,r=t.cnfBarcode=e();r.noConflict=function(){return t.cnfBarcode=n,r}}())}(this,function(){"use strict";var t=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function e(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var n=function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t};function r(t,e){return t(e={exports:{}},e.exports),e.exports}var i=r(function(t){function e(t){return(e="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(r){return"function"==typeof Symbol&&"symbol"===e(Symbol.iterator)?t.exports=n=function(t){return e(t)}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":e(t)},n(r)}t.exports=n});var o=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var a=function(t,e){return!e||"object"!==i(e)&&"function"!=typeof e?o(t):e},u=r(function(t){function e(n){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},e(n)}t.exports=e}),s=r(function(t){function e(n,r){return t.exports=e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},e(n,r)}t.exports=e});var c=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)},h=function e(n,r){t(this,e),this.data=n,this.text=r.text||n,this.options=r},f=function(e){function r(e,n){return t(this,r),e=e.toUpperCase(),n.mod43&&(e+=function(t){return l[t]}(function(t){for(var e=0,n=0;n<t.length;n++)e+=g(t[n]);return e%=43}(e))),a(this,u(r).call(this,e,n))}return c(r,h),n(r,[{key:"encode",value:function(){for(var t=p("*"),e=0;e<this.data.length;e++)t+="".concat(p(this.data[e]),"0");return{data:t+=p("*"),text:this.text}}},{key:"valid",value:function(){return-1!==this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)}}]),r}(),l=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],d=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function p(t){return function(t){return d[t].toString(2)}(g(t))}function g(t){return l.indexOf(t)}var v,y=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},x=(y(v={},103,0),y(v,104,1),y(v,105,2),v),m={101:0,100:1,99:2},E=String.fromCharCode(208),b=String.fromCharCode(209),O=String.fromCharCode(210),w="[\0-_È-Ï]",S="[ -È-Ï]",L=[11011001100,11001101100,11001100110,10010011e3,10010001100,10001001100,10011001e3,10011000100,10001100100,11001001e3,11001000100,11000100100,10110011100,10011011100,10011001110,10111001100,10011101100,10011100110,11001110010,11001011100,11001001110,11011100100,11001110100,11101101110,11101001100,11100101100,11100100110,11101100100,11100110100,11100110010,11011011e3,11011000110,11000110110,10100011e3,10001011e3,10001000110,10110001e3,10001101e3,10001100010,11010001e3,11000101e3,11000100010,10110111e3,10110001110,10001101110,10111011e3,10111000110,10001110110,11101110110,11010001110,11000101110,11011101e3,11011100010,11011101110,11101011e3,11101000110,11100010110,11101101e3,11101100010,11100011010,11101111010,11001000010,11110001010,1010011e4,10100001100,1001011e4,10010000110,10000101100,10000100110,1011001e4,10110000100,1001101e4,10011000010,10000110100,10000110010,11000010010,1100101e4,11110111010,11000010100,10001111010,10100111100,10010111100,10010011110,10111100100,10011110100,10011110010,11110100100,11110010100,11110010010,11011011110,11011110110,11110110110,10101111e3,10100011110,10001011110,10111101e3,10111100010,11110101e3,11110100010,10111011110,10111101110,11101011110,11110101110,11010000100,1101001e4,11010011100,1100011101011],k=function(e){function r(e,n){var i;return t(this,r),(i=a(this,u(r).call(this,e.substring(1),n))).bytes=e.split("").map(function(t){return t.charCodeAt(0)}),i}return c(r,h),n(r,[{key:"valid",value:function(){return/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)}},{key:"encode",value:function(){var t=this.bytes,e=t.shift()-105,n=x[e];if(void 0===n)throw new RangeError("The encoding does not start with a start character.");!0===this.shouldEncodeAsEan128()&&t.unshift(207);var i=r.next(t,1,n);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,""):this.text,data:r.getBar(e)+i.result+r.getBar((i.checksum+e)%103)+r.getBar(106)}}},{key:"shouldEncodeAsEan128",value:function(){var t=this.options.ean128||!1;return"string"==typeof t&&(t="true"===t.toLowerCase()),t}}],[{key:"getBar",value:function(t){return L[t]?L[t].toString():""}},{key:"correctIndex",value:function(t,e){if(0===e){var n=t.shift();return 32>n?n+64:n-32}return 1===e?t.shift()-32:10*(t.shift()-48)+t.shift()-48}},{key:"next",value:function(t,e,n){if(!t.length)return{result:"",checksum:0};var i,o;if(200<=t[0]){o=t.shift()-105;var a=m[o];void 0===a?((0===n||1===n)&&98===o&&(t[0]=0===n?95<t[0]?t[0]-96:t[0]:32>t[0]?t[0]+96:t[0]),i=r.next(t,e+1,n)):i=r.next(t,e+1,a)}else o=r.correctIndex(t,n),i=r.next(t,e+1,n);var u=o*e;return{result:r.getBar(o)+i.result,checksum:u+i.checksum}}}]),r}(),G=function(t){return t.match(new RegExp("^".concat(w,"*")))[0].length},C=function(t){return t.match(new RegExp("^".concat(S,"*")))[0].length},_=function(t){return t.match(new RegExp("^".concat("(Ï*[0-9]{2}Ï*)","*")))[0]};function R(t,e){var n=e?w:S,r=t.match(new RegExp("^(".concat(n,"+?)(([0-9]{2}){2,})([^0-9]|$)")));if(r)return r[1]+String.fromCharCode(204)+A(t.substring(r[1].length));var i=t.match(new RegExp("^".concat(n,"+")))[0];return i.length===t.length?t:i+String.fromCharCode(e?205:206)+R(t.substring(i.length),!e)}function A(t){var e=_(t),n=e.length;if(n===t.length)return t;t=t.substring(n);var r=G(t)>=C(t);return e+String.fromCharCode(r?206:205)+R(t,r)}var P=function(t){var e;if(2<=_(t).length)e=O+A(t);else{var n=G(t)>C(t);e=(n?E:b)+R(t,n)}return e.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(t,e){return String.fromCharCode(203)+e})},X=function(e){function n(e,r){var i;return t(this,n),i=/^[\x00-\x7F\xC8-\xD3]+$/.test(e)?a(this,u(n).call(this,P(e),r)):a(this,u(n).call(this,e,r)),a(i)}return c(n,k),n}(),j=function(e){function r(e,n){return t(this,r),a(this,u(r).call(this,E+e,n))}return c(r,k),n(r,[{key:"valid",value:function(){return new RegExp("^".concat(w,"+$")).test(this.data)}}]),r}(),z=function(e){function r(e,n){return t(this,r),a(this,u(r).call(this,b+e,n))}return c(r,k),n(r,[{key:"valid",value:function(){return new RegExp("^".concat(S,"+$")).test(this.data)}}]),r}(),M=function(e){function r(e,n){return t(this,r),a(this,u(r).call(this,O+e,n))}return c(r,k),n(r,[{key:"valid",value:function(){return new RegExp("^".concat("(Ï*[0-9]{2}Ï*)","+$")).test(this.data)}}]),r}();var T=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t},D=r(function(t){function e(n,r,i){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=e=Reflect.get:t.exports=e=function(t,e,n){var r=T(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(n):i.value}},e(n,r,i||n)}t.exports=e}),I={L:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],G:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],R:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],O:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],E:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"]},V=["LL","LG","GL","GG"],$=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],B=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"],F=function(t,e,n){var r=t.split("").map(function(t,n){return I[e[n]]}).map(function(e,n){return e?e[t[n]]:""});if(n){var i=t.length-1;r=r.map(function(t,e){return e<i?t+n:t})}return r.join("")},H=function(e){function r(e,n){var i;return t(this,r),(i=a(this,u(r).call(this,e,n))).fontSize=!n.flat&&n.fontSize>10*n.width?10*n.width:n.fontSize,i.guardHeight=n.height+i.fontSize/2+n.textMargin,i}return c(r,h),n(r,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(t,e){return this.text.substr(t,e)}},{key:"leftEncode",value:function(t,e){return F(t,e)}},{key:"rightText",value:function(t,e){return this.text.substr(t,e)}},{key:"rightEncode",value:function(t,e){return F(t,e)}},{key:"encodeGuarded",value:function(){var t={fontSize:this.fontSize},e={height:this.guardHeight};return[{data:"101",options:e},{data:this.leftEncode(),text:this.leftText(),options:t},{data:"01010",options:e},{data:this.rightEncode(),text:this.rightText(),options:t},{data:"101",options:e}]}},{key:"encodeFlat",value:function(){return{data:["101",this.leftEncode(),"01010",this.rightEncode(),"101"].join(""),text:this.text}}}]),r}(),N=function(t){return(10-t.substr(0,12).split("").map(function(t){return+t}).reduce(function(t,e,n){return n%2?t+3*e:t+e},0)%10)%10},U=function(e){function r(e,n){var i;return t(this,r),-1!==e.search(/^[0-9]{12}$/)&&(e+=N(e)),(i=a(this,u(r).call(this,e,n))).lastChar=n.lastChar,i}return c(r,H),n(r,[{key:"valid",value:function(){return-1!==this.data.search(/^[0-9]{13}$/)&&+this.data[12]===N(this.data)}},{key:"leftText",value:function(){return D(u(r.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var t=this.data.substr(1,6),e=B[this.data[0]];return D(u(r.prototype),"leftEncode",this).call(this,t,e)}},{key:"rightText",value:function(){return D(u(r.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var t=this.data.substr(7,6);return D(u(r.prototype),"rightEncode",this).call(this,t,"RRRRRR")}},{key:"encodeGuarded",value:function(){var t=D(u(r.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(t.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(t.push({data:"00"}),t.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),t}}]),r}(),J=function(t){return(10-t.substr(0,7).split("").map(function(t){return+t}).reduce(function(t,e,n){return n%2?t+e:t+3*e},0)%10)%10},W=function(e){function r(e,n){return t(this,r),-1!==e.search(/^[0-9]{7}$/)&&(e+=J(e)),a(this,u(r).call(this,e,n))}return c(r,H),n(r,[{key:"valid",value:function(){return-1!==this.data.search(/^[0-9]{8}$/)&&+this.data[7]===J(this.data)}},{key:"leftText",value:function(){return D(u(r.prototype),"leftText",this).call(this,0,4)}},{key:"leftEncode",value:function(){var t=this.data.substr(0,4);return D(u(r.prototype),"leftEncode",this).call(this,t,"LLLL")}},{key:"rightText",value:function(){return D(u(r.prototype),"rightText",this).call(this,4,4)}},{key:"rightEncode",value:function(){var t=this.data.substr(4,4);return D(u(r.prototype),"rightEncode",this).call(this,t,"RRRR")}}]),r}(),Z=function(e){function r(e,n){return t(this,r),a(this,u(r).call(this,e,n))}return c(r,h),n(r,[{key:"valid",value:function(){return-1!==this.data.search(/^[0-9]{5}$/)}},{key:"encode",value:function(){var t,e=$[(t=this.data,t.split("").map(function(t){return+t}).reduce(function(t,e,n){return n%2?t+9*e:t+3*e},0)%10)];return{data:"1011".concat(F(this.data,e,"01")),text:this.text}}}]),r}(),K=function(e){function r(e,n){return t(this,r),a(this,u(r).call(this,e,n))}return c(r,h),n(r,[{key:"valid",value:function(){return-1!==this.data.search(/^[0-9]{2}$/)}},{key:"encode",value:function(){var t=V[parseInt(this.data)%4];return{data:"1011".concat(F(this.data,t,"01")),text:this.text}}}]),r}(),Q=function(e){function r(e,n){var i;return t(this,r),-1!==e.search(/^[0-9]{11}$/)&&(e+=Y(e)),(i=a(this,u(r).call(this,e,n))).displayValue=n.displayValue,i.fontSize=n.fontSize>10*n.width?10*n.width:n.fontSize,i.guardHeight=n.height+i.fontSize/2+n.textMargin,i}return c(r,h),n(r,[{key:"valid",value:function(){return-1!==this.data.search(/^[0-9]{12}$/)&&this.data[11]==Y(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var t="";return t+="101",t+=F(this.data.substr(0,6),"LLLLLL"),t+="01010",t+=F(this.data.substr(6,6),"RRRRRR"),{data:t+="101",text:this.text}}},{key:"guardedEncoding",value:function(){var t=[];return this.displayValue&&t.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),t.push({data:"101".concat(F(this.data[0],"L")),options:{height:this.guardHeight}}),t.push({data:F(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),t.push({data:"01010",options:{height:this.guardHeight}}),t.push({data:F(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),t.push({data:"".concat(F(this.data[11],"R"),"101"),options:{height:this.guardHeight}}),this.displayValue&&t.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),t}}]),r}();function Y(t){var e,n=0;for(e=1;11>e;e+=2)n+=parseInt(t[e]);for(e=0;11>e;e+=2)n+=3*parseInt(t[e]);return(10-n%10)%10}var q=["XX00000XXX","XX10000XXX","XX20000XXX","XXX00000XX","XXXX00000X","XXXXX00005","XXXXX00006","XXXXX00007","XXXXX00008","XXXXX00009"],tt=[["EEEOOO","OOOEEE"],["EEOEOO","OOEOEE"],["EEOOEO","OOEEOE"],["EEOOOE","OOEEEO"],["EOEEOO","OEOOEE"],["EOOEEO","OEEOOE"],["EOOOEE","OEEEOO"],["EOEOEO","OEOEOE"],["EOEOOE","OEOEEO"],["EOOEOE","OEEOEO"]],et=function(e){function r(e,n){var i;if(t(this,r),(i=a(this,u(r).call(this,e,n))).isValid=!1,-1!==e.search(/^[0-9]{6}$/))i.middleDigits=e,i.upcA=nt(e,"0"),i.text=n.text||"".concat(i.upcA[0]).concat(e).concat(i.upcA[i.upcA.length-1]),i.isValid=!0;else{if(-1===e.search(/^[01][0-9]{7}$/))return a(i);if(i.middleDigits=e.substring(1,e.length-1),i.upcA=nt(i.middleDigits,e[0]),i.upcA[i.upcA.length-1]!==e[e.length-1])return a(i);i.isValid=!0}return i.displayValue=n.displayValue,i.fontSize=n.fontSize>10*n.width?10*n.width:n.fontSize,i.guardHeight=n.height+i.fontSize/2+n.textMargin,i}return c(r,h),n(r,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var t="";return t+="101",t+=this.encodeMiddleDigits(),{data:t+="010101",text:this.text}}},{key:"guardedEncoding",value:function(){var t=[];return this.displayValue&&t.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),t.push({data:"101",options:{height:this.guardHeight}}),t.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),t.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&t.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),t}},{key:"encodeMiddleDigits",value:function(){var t=this.upcA[0],e=this.upcA[this.upcA.length-1],n=tt[parseInt(e)][parseInt(t)];return F(this.middleDigits,n)}}]),r}();function nt(t,e){for(var n,r=parseInt(t[t.length-1]),i=q[r],o="",a=0,u=0;u<i.length;u++)o+="X"===(n=i[u])?t[a++]:n;return o="".concat(e).concat(o),"".concat(o).concat(Y(o))}var rt=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"],it=function(e){function r(){return t(this,r),a(this,u(r).apply(this,arguments))}return c(r,h),n(r,[{key:"valid",value:function(){return-1!==this.data.search(/^([0-9]{2})+$/)}},{key:"encode",value:function(){var t=this;return{data:"1010"+this.data.match(/.{2}/g).map(function(e){return t.encodePair(e)}).join("")+"11101",text:this.text}}},{key:"encodePair",value:function(t){var e=rt[t[1]];return rt[t[0]].split("").map(function(t,n){return("1"===t?"111":"1")+("1"===e[n]?"000":"0")}).join("")}}]),r}(),ot=function(t){var e=t.substr(0,13).split("").map(function(t){return parseInt(t,10)}).reduce(function(t,e,n){return t+e*(3-n%2*2)},0);return 10*Math.ceil(e/10)-e},at=function(e){function r(e,n){return t(this,r),-1!==e.search(/^[0-9]{13}$/)&&(e+=ot(e)),a(this,u(r).call(this,e,n))}return c(r,it),n(r,[{key:"valid",value:function(){return-1!==this.data.search(/^[0-9]{14}$/)&&+this.data[13]===ot(this.data)}}]),r}(),ut=function(e){function r(e,n){return t(this,r),a(this,u(r).call(this,e,n))}return c(r,h),n(r,[{key:"encode",value:function(){for(var t="110",e=0;e<this.data.length;e++){var n=parseInt(this.data[e]).toString(2);n=st(n,4-n.length);for(var r=0;r<n.length;r++)t+="0"==n[r]?"100":"110"}return{data:t+="1001",text:this.text}}},{key:"valid",value:function(){return-1!==this.data.search(/^[0-9]+$/)}}]),r}();function st(t,e){for(var n=0;n<e;n++)t="0".concat(t);return t}function ct(t){for(var e,n=0,r=0;r<t.length;r++)e=parseInt(t[r]),n+=0==(r+t.length)%2?e:2*e%10+Math.floor(2*e/10);return(10-n%10)%10}function ht(t){for(var e,n=0,r=[2,3,4,5,6,7],i=0;i<t.length;i++)e=parseInt(t[t.length-1-i]),n+=r[i%r.length]*e;return(11-n%11)%11}var ft={CODE39:f,CODE128:X,CODE128A:j,CODE128B:z,CODE128C:M,EAN13:U,EAN8:W,EAN5:Z,EAN2:K,UPC:Q,UPCE:et,ITF14:at,ITF:it,MSI:ut,MSI10:function(e){function n(e,r){return t(this,n),a(this,u(n).call(this,e+ct(e),r))}return c(n,ut),n}(),MSI11:function(e){function n(e,r){return t(this,n),a(this,u(n).call(this,e+ht(e),r))}return c(n,ut),n}(),MSI1010:function(e){function n(e,r){return t(this,n),e+=ct(e),e+=ct(e),a(this,u(n).call(this,e,r))}return c(n,ut),n}(),MSI1110:function(e){function n(e,r){return t(this,n),e+=ht(e),e+=ct(e),a(this,u(n).call(this,e,r))}return c(n,ut),n}(),pharmacode:function(e){function r(e,n){var i;return t(this,r),(i=a(this,u(r).call(this,e,n))).number=parseInt(e,10),i}return c(r,h),n(r,[{key:"encode",value:function(){for(var t=this.number,e="";!isNaN(t)&&0!=t;)0==t%2?(e="11100".concat(e),t=(t-2)/2):(e="100".concat(e),t=(t-1)/2);return{data:e=e.slice(0,-2),text:this.text}}},{key:"valid",value:function(){return 3<=this.number&&131070>=this.number}}]),r}(),codabar:function(e){function r(e,n){var i;return t(this,r),0===e.search(/^[0-9\-\$\:\.\+\/]+$/)&&(e="A".concat(e,"A")),(i=a(this,u(r).call(this,e.toUpperCase(),n))).text=i.options.text||i.text.replace(/[A-D]/g,""),i}return c(r,h),n(r,[{key:"valid",value:function(){return-1!==this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/)}},{key:"encode",value:function(){for(var t=[],e=this.getEncodings(),n=0;n<this.data.length;n++)t.push(e[this.data.charAt(n)]),n!=this.data.length-1&&t.push("0");return{text:this.text,data:t.join("")}}},{key:"getEncodings",value:function(){return{0:"101010011",1:"101011001",2:"101001011",3:"110010101",4:"101101001",5:"110101001",6:"100101011",7:"100101101",8:"100110101",9:"110100101","-":"101001101",$:"101100101",":":"1101011011","/":"1101101011",".":"1101101101","+":"101100110011",A:"1011001001",B:"1001001011",C:"1010010011",D:"1010011001"}}}]),r}(),GenericBarcode:function(e){function r(e,n){return t(this,r),a(this,u(r).call(this,e,n))}return c(r,h),n(r,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),r}()};function lt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}var dt=function(t,e){return function(t){for(var e,n=1;n<arguments.length;n++)e=null==arguments[n]?{}:arguments[n],n%2?lt(e,!0).forEach(function(n){y(t,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):lt(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))});return t}({},t,{},e)};function pt(t){var e=[];return function t(n){if(Array.isArray(n))for(var r=0;r<n.length;r++)t(n[r]);else n.text=n.text||"",n.data=n.data||"",e.push(n)}(t),e}function gt(t){return t.marginTop=t.marginTop||t.margin,t.marginBottom=t.marginBottom||t.margin,t.marginRight=t.marginRight||t.margin,t.marginLeft=t.marginLeft||t.margin,t}function vt(t,e){return t(e={exports:{}},e.exports),e.exports}var yt=vt(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),xt=vt(function(t){var e=t.exports={version:"2.6.9"};"number"==typeof __e&&(__e=e)}),mt=(xt.version,function(t,e,n){if(function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!")}(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}}),Et=function(t){return"object"==typeof t?null!==t:"function"==typeof t},bt=function(t){if(!Et(t))throw TypeError(t+" is not an object!");return t},Ot=function(t){try{return!!t()}catch(t){return!0}},wt=!Ot(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),St=yt.document,Lt=Et(St)&&Et(St.createElement),kt=!wt&&!Ot(function(){return 7!=Object.defineProperty((t="div",Lt?St.createElement(t):{}),"a",{get:function(){return 7}}).a;var t}),Gt=Object.defineProperty,Ct={f:wt?Object.defineProperty:function(t,e,n){if(bt(t),e=function(t,e){if(!Et(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!Et(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!Et(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!Et(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")}(e,!0),bt(n),kt)try{return Gt(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},_t=wt?function(t,e,n){return Ct.f(t,e,function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}(1,n))}:function(t,e,n){return t[e]=n,t},Rt={}.hasOwnProperty,At=function(t,e){return Rt.call(t,e)},Pt=function(t,e,n){var r,i,o,a=t&Pt.F,u=t&Pt.G,s=t&Pt.S,c=t&Pt.P,h=t&Pt.B,f=t&Pt.W,l=u?xt:xt[e]||(xt[e]={}),d=l.prototype,p=u?yt:s?yt[e]:(yt[e]||{}).prototype;for(r in u&&(n=e),n)(i=!a&&p&&void 0!==p[r])&&At(l,r)||(o=i?p[r]:n[r],l[r]=u&&"function"!=typeof p[r]?n[r]:h&&i?mt(o,yt):f&&p[r]==o?function(t){var e=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,r)}return t.apply(this,arguments)};return e.prototype=t.prototype,e}(o):c&&"function"==typeof o?mt(Function.call,o):o,c&&((l.virtual||(l.virtual={}))[r]=o,t&Pt.R&&d&&!d[r]&&_t(d,r,o)))};Pt.F=1,Pt.G=2,Pt.S=4,Pt.P=8,Pt.B=16,Pt.W=32,Pt.U=64,Pt.R=128;var Xt=Pt,jt={}.toString,zt=function(t){return jt.call(t).slice(8,-1)},Mt=Array.isArray||function(t){return"Array"==zt(t)};Xt(Xt.S,"Array",{isArray:Mt});var Tt,Dt,It,Vt,$t,Bt,Ft=xt.Array.isArray,Ht=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},Nt=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==zt(t)?t.split(""):Object(t)},Ut=function(t){return Nt(Ht(t))},Jt=Math.ceil,Wt=Math.floor,Zt=function(t){return isNaN(t=+t)?0:(t>0?Wt:Jt)(t)},Kt=Math.min,Qt=Math.max,Yt=Math.min,qt=vt(function(t){var e=yt["__core-js_shared__"]||(yt["__core-js_shared__"]={});(t.exports=function(t,n){return e[t]||(e[t]=void 0!==n?n:{})})("versions",[]).push({version:xt.version,mode:"pure",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})}),te=0,ee=Math.random(),ne=qt("keys"),re=(Tt=!1,function(t,e,n){var r,i,o=Ut(t),a=(r=o.length)>0?Kt(Zt(r),9007199254740991):0,u=function(t,e){return(t=Zt(t))<0?Qt(t+e,0):Yt(t,e)}(n,a);if(Tt&&e!=e){for(;a>u;)if((i=o[u++])!=i)return!0}else for(;a>u;u++)if((Tt||u in o)&&o[u]===e)return Tt||u||0;return!Tt&&-1}),ie=ne[Dt="IE_PROTO"]||(ne[Dt]=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++te+ee).toString(36))}(Dt)),oe="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),ae=Object.keys||function(t){return function(t,e){var n,r=Ut(t),i=0,o=[];for(n in r)n!=ie&&At(r,n)&&o.push(n);for(;e.length>i;)At(r,n=e[i++])&&(~re(o,n)||o.push(n));return o}(t,oe)};It="keys",Vt=function(){return function(t){return ae(function(t){return Object(Ht(t))}(t))}},$t=(xt.Object||{})[It]||Object[It],(Bt={})[It]=Vt($t),Xt(Xt.S+Xt.F*Ot(function(){$t(1)}),"Object",Bt);var ue=xt.Object.keys;function se(t,e){return e.height+(e.displayValue&&0<t.text.length?e.fontSize+e.textMargin:0)+e.marginTop+e.marginBottom}function ce(t,e,n){if(n.displayValue&&e<t){if("center"==n.textAlign)return Math.floor((t-e)/2);if("left"==n.textAlign)return 0;if("right"==n.textAlign)return Math.floor(t-e)}return 0}function he(t,e,n){var r;if(n)r=n;else{if("undefined"==typeof document)return 0;r=document.createElement("canvas").getContext("2d")}return r.font="".concat(e.fontOptions," ").concat(e.fontSize,"px ").concat(e.font),r.measureText(t).width}var fe={SVGRenderer:function(){function e(n,r){t(this,e),this.svgJson={node:"element",tag:"svg",attr:{style:""},child:[]},this.barCode="",this.encodings=n,this.options=r}return n(e,[{key:"render",value:function(){var t=this.options.marginLeft;this.prepareSVG();for(var e=0;e<this.encodings.length;e++){var n=this.encodings[e],r=dt(this.options,n.options),i=this.createGroup(t,r.marginTop,this.options.useTranslate);this.setGroupOptions(i,r),this.drawSvgBarcode(i,r,n),this.drawSVGText(i,r,n),this.svgJson.child.push(i),t+=n.width}this.barCode=function t(e){var n="";e.child&&(n=e.child.map(function(e){return t(e)}).join(""));var r="";if(e.attr&&""!==(r=ue(e.attr).map(function(t){var n=e.attr[t];return Ft(n)&&(n=n.join(" ")),t+'="'+n+'"'}).join(" "))&&(r=" "+r),"element"===e.node){var i=e.tag;return-1<["area","base","basefont","br","col","frame","hr","img","input","isindex","link","meta","param","embed"].indexOf(i)?"<"+e.tag+r+"/>":"<"+e.tag+r+">"+n+"</"+e.tag+">"}return"text"===e.node?e.text:"comment"===e.node?"\x3c!--"+e.text+"--\x3e":"root"===e.node?n:void 0}(this.svgJson)}},{key:"prepareSVG",value:function(){for(;this.svgJson.child[0];)this.svgJson.child.shift();!function(t,e,n){for(var r=0;r<t.length;r++){var i,o=t[r],a=dt(e,o.options);i=a.displayValue?he(o.text,a,n):0;var u=o.data.length*a.width;o.width=Math.ceil(Math.max(i,u)),o.height=se(o,a),o.barcodePadding=ce(i,u,a)}}(this.encodings,this.options);var t=function(t){for(var e=0,n=0;n<t.length;n++)e+=t[n].width;return e}(this.encodings),e=function(t){for(var e=0,n=0;n<t.length;n++)t[n].height>e&&(e=t[n].height);return e}(this.encodings),n=t;if(this.options.useTranslate&&(n=t+this.options.marginLeft+this.options.marginRight),this.setSvgAttributes(n,e),this.options.background){var r=this.drawRect(0,0,n,e,this.svgJson);r.attr.style=(r.attr.style||"")+"fill:".concat(this.options.background,";")}}},{key:"drawSvgBarcode",value:function(t,e,n){var r,i=n.data;r="top"==e.textPosition?e.fontSize+e.textMargin:0;for(var o=0,a=0,u=0;u<i.length;u++)a=u*e.width+n.barcodePadding,"1"===i[u]?o++:0<o&&(this.drawRect(a-e.width*o+t.x,r,e.width*o,e.height,t),o=0);0<o&&this.drawRect(a-e.width*(o-1)+t.x,r,e.width*o,e.height,t)}},{key:"setSvgAttributes",value:function(t,e){var n=this.svgJson;n.attr.width="".concat(t,"px"),n.attr.height="".concat(t,"px"),n.attr.x="0px",n.attr.y="0px",n.attr.viewBox="0 0 ".concat(t," ").concat(e),n.attr.xmlns="http://www.w3.org/2000/svg",n.attr.version="1.1"}},{key:"createGroup",value:function(t,e,n){return n?{node:"element",tag:"g",x:0,y:0,attr:{transform:"translate(".concat(t,", ").concat(e,")")},child:[]}:{node:"element",tag:"g",x:t,y:e,attr:{},child:[]}}},{key:"setGroupOptions",value:function(t,e){t.attr||(t.attr={}),t.attr.style=(t.attr.style||"")+";fill:".concat(e.lineColor,";")}},{key:"drawRect",value:function(t,e,n,r,i){var o={node:"element",tag:"rect",attr:{style:""}};return o.attr.x=t,o.attr.y=e,o.attr.width=n,o.attr.height=r,Array.isArray(i.child)&&i.child.push(o),o}},{key:"drawSVGText",value:function(t,e,n){var r,i,o={node:"element",tag:"text",attr:{style:""},text:"",child:[]};e.displayValue&&(o.attr.style+=";font:".concat(e.fontOptions," ").concat(e.fontSize,"px ").concat(e.font,";"),i="top"==e.textPosition?e.fontSize-e.textMargin:e.height+e.textMargin+e.fontSize,"left"==e.textAlign||0<n.barcodePadding?(r=0,o.attr["text-anchor"]="start"):"right"==e.textAlign?(r=n.width-1,o.attr["text-anchor"]="end"):(r=n.width/2,o.attr["text-anchor"]="middle"),o.attr.x=r+t.x,o.attr.y=i,o.child.push({node:"text",tag:"",text:n.text}),t.child.push(o))}}]),e}()};var le=function(){function e(n){t(this,e),this.api=n}return n(e,[{key:"handleCatch",value:function(t){if("InvalidInputException"!==t.name)throw t;if(this.api._options.valid===this.api._defaults.valid)throw t.message;this.api._options.valid(!1),this.api.render=function(){}}},{key:"wrapBarcodeCall",value:function(t){try{var e=t.apply(void 0,arguments);return this.api._options.valid(!0),e}catch(t){return this.handleCatch(t),this.api}}}]),e}();var de=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")},pe=r(function(t){function e(n,r,i){return!function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?t.exports=e=function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&s(i,n.prototype),i}:t.exports=e=Reflect.construct,e.apply(null,arguments)}t.exports=e}),ge=r(function(t){function e(n){var r="function"==typeof Map?new Map:void 0;return t.exports=e=function(t){if(null===t||!de(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return pe(t,arguments,u(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),s(e,t)},e(n)}t.exports=e}),ve=function(e){function n(e,r){var i;return t(this,n),(i=a(this,u(n).call(this))).name="InvalidInputException",i.symbology=e,i.input=r,i.message='"'.concat(i.input,'" is not a valid input for ').concat(i.symbology),i}return c(n,e),n}(ge(Error)),ye=(function(e){function n(){var e;return t(this,n),(e=a(this,u(n).call(this))).name="InvalidElementException",e.message="Not supported type to render on",e}c(n,e)}(ge(Error)),function(e){function n(){var e;return t(this,n),(e=a(this,u(n).call(this))).name="NoElementException",e.message="No element to render on.",e}return c(n,e),n}(ge(Error))),xe={width:2,height:100,format:"auto",displayValue:!0,fontOptions:"",font:"monospace",text:void 0,textAlign:"center",textPosition:"bottom",textMargin:2,fontSize:20,background:"#ffffff",lineColor:"#000000",margin:10,marginTop:void 0,marginBottom:void 0,marginLeft:void 0,marginRight:void 0,valid:function(){}},me=function(){};for(var Ee in ft)ft.hasOwnProperty(Ee)&&be(ft,Ee);function be(t,e){me.prototype[e]=me.prototype[e.toUpperCase()]=me.prototype[e.toLowerCase()]=function(n,r){var i=this;return i._errorHandler.wrapBarcodeCall(function(){r.text=void 0===r.text?void 0:"".concat(r.text);var o=dt(i._options,r);o=function(t){var e=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var n in e)e.hasOwnProperty(n)&&"string"==typeof t[n=e[n]]&&(t[n]=parseInt(t[n],10));return"string"==typeof t.displayValue&&(t.displayValue="false"!=t.displayValue),t}(o);var a=t[e],u=Oe(n,a,o);return i._encodings.push(u),i})}}function Oe(t,e,n){var r=new e(t="".concat(t),n);if(!r.valid())throw new ve(r.constructor.name,t);var i=r.encode();i=pt(i);for(var o=0;o<i.length;o++)i[o].options=dt(n,i[o].options);return i}function we(){return ft.CODE128?"CODE128":Object.keys(ft)[0]}function Se(t,e,n){e=pt(e);for(var r=0;r<e.length;r++)e[r].options=dt(n,e[r].options),gt(e[r].options);gt(n);var i=new(0,t.renderer)(e,n);return i.render(),t.afterRender&&t.afterRender(),i.barCode}return me.prototype.options=function(t){return this._options=dt(this._options,t),this},me.prototype.getSvg=function(){return this.barCodes.svg},me.prototype.getSvgDataURI=function(){return"data:image/svg+xml;utf8,".concat(encodeURIComponent(this.barCodes.svg))},me.prototype.blank=function(t){var e=Array(t+1).join("0");return this._encodings.push({data:e}),this},me.prototype.init=function(){var t;if(this._renderProperties)for(var e in Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]),this._renderProperties){t=this._renderProperties[e];var n=dt(this._options,t.options);"auto"==n.format&&(n.format=we()),this._errorHandler.wrapBarcodeCall(function(){var e=Oe(n.value,ft[n.format.toUpperCase()],n);Se(t,e,n)})}},me.prototype.render=function(){var t=this;if(!this._renderProperties)throw new ye;var e={};return Array.isArray(this._renderProperties)?this._renderProperties.forEach(function(n){e[n.type]=Se(n,t._encodings,t._options)}):e[this._renderProperties.type]=Se(this._renderProperties,this._encodings,this._options),this.barCodes=e,this},me.prototype._defaults=xe,function(t,e){var n=new me;return n._renderProperties=function(){return{type:0<arguments.length&&void 0!==arguments[0]?arguments[0]:"svg",renderer:fe.SVGRenderer}}("svg"),n._encodings=[],n._options=xe,n._errorHandler=new le(n),n.barCodes={},void 0!==t&&(!(e=e||{}).format&&(e.format=we()),n.options(e)[e.format](t,e).render()),n}}); //# sourceMappingURL=svg-barcode.common.js.map