UNPKG

ll-package

Version:

2 lines (1 loc) 2.99 kB
"use strict";const c=require("../../../../../_virtual/EAN13.js");require("./constants.js");require("./EAN.js");const l=require("../../../../../_virtual/constants2.js"),s=require("../../../../../_virtual/EAN.js");Object.defineProperty(c.__exports,"__esModule",{value:!0});var h=function(){function r(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(t,n,e){return n&&r(t.prototype,n),e&&r(t,e),t}}(),i=function r(t,n,e){t===null&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,n);if(o===void 0){var u=Object.getPrototypeOf(t);return u===null?void 0:r(u,n,e)}else{if("value"in o)return o.value;var a=o.get;return a===void 0?void 0:a.call(e)}},p=l.__exports,_=s.__exports,d=y(_);function y(r){return r&&r.__esModule?r:{default:r}}function v(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function O(r,t){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t&&(typeof t=="object"||typeof t=="function")?t:r}function b(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof t);r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(r,t):r.__proto__=t)}var f=function(t){var n=t.substr(0,12).split("").map(function(e){return+e}).reduce(function(e,o,u){return u%2?e+o*3:e+o},0);return(10-n%10)%10},g=function(r){b(t,r);function t(n,e){v(this,t),n.search(/^[0-9]{12}$/)!==-1&&(n+=f(n));var o=O(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,n,e));return o.lastChar=e.lastChar,o}return h(t,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===f(this.data)}},{key:"leftText",value:function(){return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var e=this.data.substr(1,6),o=p.EAN13_STRUCTURE[this.data[0]];return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"leftEncode",this).call(this,e,o)}},{key:"rightText",value:function(){return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var e=this.data.substr(7,6);return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"rightEncode",this).call(this,e,"RRRRRR")}},{key:"encodeGuarded",value:function(){var e=i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(e.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(e.push({data:"00"}),e.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),e}}]),t}(d.default);c.__exports.default=g;