@mescius/wijmo.barcode.common 5.20261.45-nightly.d20251218.t163151 → 5.20261.45-nightly.d20260105.t163143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2015-esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * Wijmo Library 5.20261.45-nightly.d20251218.t163151
3
+ * Wijmo Library 5.20261.45-nightly.d20260105.t163143
4
4
  * https://developer.mescius.com/wijmo
5
5
  *
6
6
  * Copyright(c) MESCIUS inc. All rights reserved.
@@ -11,4 +11,4 @@
11
11
  *
12
12
  */
13
13
 
14
- import{asEnum,addClass,_registerModule}from"@mescius/wijmo";import{OneDimensionalBarcode,Utils,InvalidTextException,InvalidOptionsException,Barcode,InvalidCharacterException,Constants,TextTooLongException,BitBuffer,TwoDimensionalBarcode,BarcodeBase,_LabelPositionConvertor,_NarrowWideRatioConvertor}from"@mescius/wijmo.barcode";import*as selfModule from"@mescius/wijmo.barcode.common";const EXP_TABLE=new Array(256);for(let e=0;e<8;e++)EXP_TABLE[e]=1<<e;for(let e=8;e<256;e++)EXP_TABLE[e]=EXP_TABLE[e-4]^EXP_TABLE[e-5]^EXP_TABLE[e-6]^EXP_TABLE[e-8];const LOG_TABLE=new Array(256);for(let e=0;e<255;e+=1)LOG_TABLE[EXP_TABLE[e]]=e;const RS_COEFFICIENTS=[null,null,null,null,null,null,null,[0,87,229,146,149,238,102,21],null,null,[0,251,67,46,61,118,70,64,94,32,45],null,null,[0,74,152,176,100,86,100,106,104,130,218,206,140,78],null,[0,8,183,61,91,202,37,51,58,58,237,140,124,5,99,105],[0,120,104,107,109,102,161,76,3,91,191,147,169,182,194,225,120],[0,43,139,206,78,43,239,123,206,214,147,24,99,150,39,243,163,136],[0,215,234,158,94,184,97,118,170,79,187,152,148,252,179,5,98,96,153],null,[0,17,60,79,50,61,163,26,187,202,180,221,225,83,239,156,164,212,212,188,190],null,[0,210,171,247,242,93,230,14,109,221,53,200,74,8,172,98,80,219,134,160,105,165,231],null,[0,229,121,135,48,211,117,251,126,159,180,169,152,192,226,228,218,111,0,117,232,87,96,227,21],null,[0,173,125,158,2,103,182,118,17,145,201,111,28,165,53,161,21,245,142,13,102,48,227,153,145,218,70],null,[0,168,223,200,104,224,234,108,180,110,190,195,147,205,27,232,201,21,43,245,87,42,195,212,119,242,37,9,123],null,[0,41,173,145,152,216,31,179,182,50,48,110,86,239,96,222,125,42,173,226,193,224,130,156,37,251,216,238,40,192,180],null,[0,10,6,106,190,249,167,4,67,209,138,138,32,242,123,89,27,120,185,80,156,38,69,171,60,28,222,80,52,254,185,220,241],null,[0,111,77,146,94,26,21,108,19,105,94,113,193,86,140,163,125,58,158,229,239,218,103,56,70,114,61,183,129,167,13,98,62,129,51],null,[0,200,183,98,16,172,31,246,234,60,152,115,0,167,152,113,248,238,107,18,63,218,37,87,210,105,177,120,74,121,196,117,251,113,233,30,120],null,null,null,[0,59,116,79,161,252,98,128,205,128,161,247,57,163,56,235,106,53,26,187,174,226,104,170,7,175,35,181,114,88,41,47,163,125,134,72,20,232,53,35,15],null,[0,250,103,221,230,25,18,137,231,0,3,58,242,221,191,110,84,230,8,188,106,96,147,15,131,139,34,101,223,39,101,213,199,237,254,201,123,171,162,194,117,50,96],null,[0,190,7,61,121,71,246,69,55,168,188,89,243,191,25,72,123,9,145,14,247,1,238,44,78,143,62,224,126,118,114,68,163,52,194,217,147,204,169,37,130,113,102,73,181],null,[0,112,94,88,112,253,224,202,115,187,99,89,5,54,113,129,44,58,16,135,216,169,211,36,1,4,96,60,241,73,104,234,8,249,245,119,174,52,25,157,224,43,202,223,19,82,15],null,[0,228,25,196,130,211,146,60,24,251,90,39,102,240,61,178,63,46,123,115,18,221,111,135,160,182,205,107,206,95,150,120,184,91,21,247,156,140,238,191,11,94,227,84,50,163,39,34,108],null,[0,232,125,157,161,164,9,118,46,209,99,203,193,35,3,209,111,195,242,203,225,46,13,32,160,126,209,130,160,242,215,242,75,77,42,189,32,113,65,124,69,228,114,235,175,124,170,215,232,133,205],null,[0,116,50,86,186,50,220,251,89,192,46,86,127,124,19,184,233,151,215,22,14,59,145,37,242,203,134,254,89,190,94,59,65,124,113,100,233,235,121,22,76,86,97,39,242,200,220,101,33,239,254,116,51],null,[0,183,26,201,87,210,221,113,21,46,65,45,50,238,184,249,225,102,58,209,218,109,165,26,95,184,192,52,245,35,254,238,175,172,79,123,25,122,43,120,108,215,80,128,201,235,8,153,59,101,31,198,76,31,156],null,[0,106,120,107,157,164,216,112,116,2,91,248,163,36,201,202,229,6,144,254,155,135,208,170,209,12,139,127,142,182,249,177,174,190,28,10,85,239,184,101,124,152,206,96,23,163,61,27,196,247,151,154,202,207,20,61,10],null,[0,82,116,26,247,66,27,62,107,252,182,200,185,235,55,251,242,210,144,154,237,176,141,192,248,152,249,206,85,253,142,65,165,125,23,24,30,122,240,214,6,129,218,29,145,127,134,206,245,117,29,41,63,159,142,233,125,148,123],null,[0,107,140,26,12,9,141,243,197,226,197,219,45,211,101,219,120,28,181,127,6,100,247,2,205,198,57,115,219,101,109,160,82,37,38,238,49,160,209,121,86,11,124,30,181,84,25,194,87,65,102,190,220,70,27,209,16,89,7,33,240],null,[0,65,202,113,98,71,223,248,118,214,94,1,122,37,23,2,228,58,121,7,105,135,78,243,118,70,76,223,89,72,50,70,111,194,17,212,126,181,35,221,117,235,11,229,149,147,123,213,40,115,6,200,100,26,246,182,218,127,215,36,186,110,106],null,[0,45,51,175,9,7,158,159,49,68,119,92,123,177,204,187,254,200,78,141,149,119,26,127,53,160,93,199,212,29,24,145,156,208,150,218,209,4,216,91,47,184,146,47,140,195,195,125,242,238,63,99,108,140,230,242,31,204,11,178,243,217,156,213,231],null,[0,5,118,222,180,136,136,162,51,46,117,13,215,81,17,139,247,197,171,95,173,65,137,178,68,111,95,101,41,72,214,169,197,95,7,44,154,77,111,236,40,121,143,63,87,80,253,240,126,217,77,34,232,106,50,168,82,76,146,67,106,171,25,132,93,45,105],null,[0,247,159,223,33,224,93,77,70,90,160,32,254,43,150,84,101,190,205,133,52,60,202,165,220,203,151,93,84,15,84,253,173,160,89,227,52,199,97,95,231,52,177,41,125,137,241,166,225,118,2,54,32,82,215,175,198,43,238,235,27,101,184,127,3,5,8,163,238],null];export function generateErrorCorrectionCode(e,t,o){let r=[];const n=RS_COEFFICIENTS[t];let s=e.slice(0);for(let e=0;e<o;e++){if(0!=s[0]){let e=LOG_TABLE[s[0]];for(let t=0;t<=n.length-1;t++){let o=n[t]+e;for(;o>=255;)o-=255;r[t]=EXP_TABLE[o]}for(let e=0;e<=n.length-1;e++)s[e]=s[e]^r[e]}for(let e=1;e<s.length;e++)s[e-1]=s[e];s[s.length-1]=0}return s.slice(0,t)}const G15=1335,G18=7973,MODEL2_G15_MASK=21522,MODEL1_G15_MASK=10277;function getBCHDigit(e){let t=0;for(;0!=e;){t+=1;e>>>=1}return t}export function getBCH15(e,t){let o=2===t?21522:10277,r=e<<10;for(;getBCHDigit(r)-getBCHDigit(G15)>=0;)r^=G15<<getBCHDigit(r)-getBCHDigit(G15);return(e<<10|r)^o}export function getBCH18(e){let t=e<<12;for(;getBCHDigit(t)-getBCHDigit(G18)>=0;)t^=G18<<getBCHDigit(t)-getBCHDigit(G18);return e<<12|t}export const MODE_INDICATOR={ECI:7,Numeric:1,Alphanumeric:2,"8BitByte":4,Kanji:8,StructuredAppend:3,FNC1First:5,FNC2Second:9,Terminator:0};export const EC_INDICATOR={L:1,M:0,Q:3,H:2};function isNumericMode(e){return e>=48&&e<=57}function isAlphanumericMode(e){return-1!=" $%*+-./:".indexOf(String.fromCharCode(e))||(e>=48&&e<=57||e>=65&&e<=90)}function is8BitByteMode(e){return e>=0&&e<=255}function isKanjiMode(e){return e>=33087&&e<=64587}const checkFns={Numeric:isNumericMode,Alphanumeric:isAlphanumericMode,"8BitByte":is8BitByteMode,Kanji:isKanjiMode};export function isMode(e,t){let o=checkFns[e];return 1===t.length?o(t):t.every(e=>o(e))}export function getCharMode(e,t="UTF-8"){return isNumericMode(e)?"Numeric":isAlphanumericMode(e)?"Alphanumeric":"Shift_JIS"===t&&isKanjiMode(e)?"Kanji":"8BitByte"}export const getSizeByVersion=e=>4*e+17;export function getCharacterCountIndicatorbitsNumber(e){return e>=1&&e<=9?{Numeric:10,Alphanumeric:9,"8BitByte":8,Kanji:8}:e>=10&&e<=26?{Numeric:12,Alphanumeric:11,"8BitByte":16,Kanji:10}:{Numeric:14,Alphanumeric:13,"8BitByte":16,Kanji:12}}const SYMBOL_MAP={" ":36,$:37,"%":38,"*":39,"+":40,"-":41,".":42,"/":43,":":44};export function getAlphanumericCharValue(e){if(e>=48&&e<=57)return+String.fromCharCode(e);if(e>=65&&e<=90)return e-65+10;const t=SYMBOL_MAP[String.fromCharCode(e)];if(t)return t;throw new InvalidTextException(String.fromCharCode(e))}export function createModules(e){let t=[];for(let o=0;o<e;o++)t.push(Utils.fillArray(new Array(e),null));return t}const alignmentPatterns=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]];export function getAlignmentPattersPos(e){return alignmentPatterns[e-1]}export const padCodewords0=236;export const padCodewords1=17;export const maskFuncs=[(e,t)=>(e+t)%2==0,e=>e%2==0,(e,t)=>t%3==0,(e,t)=>(e+t)%3==0,(e,t)=>(Math.floor(e/2)+Math.floor(t/3))%2==0,(e,t)=>e*t%2+e*t%3==0,(e,t)=>(e*t%2+e*t%3)%2==0,(e,t)=>(e*t%3+(e+t)%2)%2==0];const MODEL2_1ERROR_CORRECTION_CHARACTERISTICS=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],MODEL1_ERROR_CORRECTION_CHARACTERISTICS=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,46,36],[1,46,30],[1,46,24],[1,46,16],[1,72,57],[1,72,44],[1,72,36],[1,72,24],[1,100,80],[1,100,60],[1,100,50],[1,100,34],[1,134,108],[1,134,82],[1,134,68],[2,67,23],[1,170,136],[2,85,53],[2,85,43],[2,85,29],[1,212,170],[2,106,66],[2,106,54],[3,70,24],[2,128,104],[2,128,80],[2,128,64],[3,85,29],[2,153,123],[2,153,93],[3,102,52],[3,102,34],[2,179,145],[2,179,111],[3,119,61],[4,89,31],[2,208,168],[4,104,64],[4,104,52],[5,83,29],[2,238,192],[4,119,73],[4,119,61],[5,95,33],[3,180,144],[4,135,83],[4,135,69],[6,90,32],[3,203,163],[4,152,92],[5,122,62],[6,101,35]];export function getErrorCorrectionCharacteristics(e,t,o=2){let r;switch(t){case 1:r=0;break;case 0:r=1;break;case 3:r=2;break;case 2:r=3}const n=(2===o?MODEL2_1ERROR_CORRECTION_CHARACTERISTICS:MODEL1_ERROR_CORRECTION_CHARACTERISTICS)[4*(e-1)+r],s=[],i=n.length/3;for(let e=0;e<i;e++){let t=n[3*e];for(let o=0;o<t;o++)s.push({total:n[3*e+1],data:n[3*e+2],ec:n[3*e+1]-n[3*e+2]})}return s}export function getMaskFunc(e){return maskFuncs[e]}function cloneModules(e){return e.reduce((e,t)=>{e.push(t.slice(0));return e},[])}export function getMaskScore(e){const t=e.length;let o=0;for(let r=0;r<t;r++)for(let n=0;n<t;n++){let s=0,i=e[r][n];for(let o=-1;o<=1;o++)if(!(r+o<0||t<=r+o))for(let a=-1;a<=1;a++)n+a<0||t<=n+a||0==o&&0==a||i==e[r+o][n+a]&&(s+=1);s>5&&(o+=3+s-5)}for(let r=0;r<t-1;r++)for(let n=0;n<t-1;n++){let t=0;e[r][n]&&(t+=1);e[r+1][n]&&(t+=1);e[r][n+1]&&(t+=1);e[r+1][n+1]&&(t+=1);0!=t&&4!=t||(o+=3)}for(let r=0;r<t;r++)for(let n=0;n<t-6;n++)e[r][n]&&!e[r][n+1]&&e[r][n+2]&&e[r][n+3]&&e[r][n+4]&&!e[r][n+5]&&e[r][n+6]&&(o+=40);for(let r=0;r<t;r++)for(let n=0;n<t-6;n++)e[n][r]&&!e[n+1][r]&&e[n+2][r]&&e[n+3][r]&&e[n+4][r]&&!e[n+5][r]&&e[n+6][r]&&(o+=40);let r=0;for(let o=0;o<t;o++)for(let n=0;n<t;n++)e[n][o]&&(r+=1);o+=10*(Math.abs(100*r/t/t-50)/5);return o}export function addFormatInformation(e,t,o,r){const n=e.length,s=cloneModules(e),i=Utils.strPadStart(Utils.convertRadix(o,2),2,0),a=Utils.strPadStart(Utils.convertRadix(t,2),3,0),l=getBCH15(parseInt(i+a,2),r);s[n-8][8]=1;for(let e=15;e>0;e--){let t=l>>e-1&1;if(e>9){s[8][15-e]=t;s[n-1-15+e][8]=t}else if(e>8){s[8][15-e+1]=t;s[n-1-15+e][8]=t}else if(e>6){s[e][8]=t;s[8][n-e]=t}else{s[e-1][8]=t;s[8][n-e]=t}}return s}export function getEstimatedVersion(e,t,o){let r=0,n=0,s=0,i=0;t.forEach(e=>{isNumericMode(e)?r++:isAlphanumericMode(e)?n++:isKanjiMode(e)?i++:is8BitByteMode(e)&&s++});let a=Math.ceil((5*n+3*r+13*i+8*s)/8);for(let t=1;t<=40;t++){if(a<=getErrorCorrectionCharacteristics(t,e,o).reduce((e,t)=>e+t.data,0))return t}throw new TextTooLongException}const MODE_CHECK_INFO={Alphanumeric:[[6,11],[7,15],[8,16]],Numeric:[[4,6,6,13],[4,7,8,15],[5,8,9,17]]};export function getModeCheckInfo(e,t){let o=MODE_CHECK_INFO[e];return t<=9?o[0]:t<=26?o[1]:o[2]}export function utf8Encode(e){const t=[];for(let o=0,r=e.length;o<r;o++){let r=e[o];if(r<128)t.push(r);else if(r<2048)t.push(192|r>>6,128|63&r);else if(r<55296||r>=57344)t.push(224|r>>12,128|r>>6&63,128|63&r);else{o++;r=65536+((1023&r)<<10|1023&e[o]);t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r)}}return t}export function getParityData(e){let t=utf8Encode(e),o=t[0];for(let e=1,r=t.length;e<r;e++)o^=t[e];return o}export function getCharCode(e){let t=[];Utils.sliceString(e,1,e=>{t.push(e.charCodeAt(0))});return t}export class ModeKanji{constructor(e){this.mode="Kanji";this.data=e}getMode(){return MODE_INDICATOR.Kanji}getLength(){return this.data.length}write(e){this.data.forEach(t=>{let o;if(t>33088&&t<40956){o=192*((t-=33088)>>>8)+(255&t)}else if(t>57408&&t<60351){o=192*((t-=49472)>>>8)+(255&t)}e.put(o,13)})}}export class ModeAlphanumeric{constructor(e){this.mode="Alphanumeric";this.data=e}getMode(){return MODE_INDICATOR.Alphanumeric}getLength(){return this.data.length}write(e){Utils.sliceArray(this.data,2,t=>{let o=getAlphanumericCharValue(t[0]);if(2===t.length){let r=45*o+getAlphanumericCharValue(t[1]);e.put(r,11)}else e.put(o,6)})}}export class ModeNumeric{constructor(e){this.mode="Numeric";this.data=e}getMode(){return MODE_INDICATOR.Numeric}getLength(){return this.data.length}write(e){Utils.sliceArray(this.data,3,t=>{const o=parseInt(t.reduce((e,t)=>e+String.fromCharCode(t),""));switch(t.length){case 1:e.put(o,4);return;case 2:e.put(o,7);return;default:e.put(o,10);return}})}}export class Mode8BitByte{constructor(e){this.mode="8BitByte";this.data=e;this.bytes=utf8Encode(e)}getMode(){return MODE_INDICATOR["8BitByte"]}getLength(){return this.bytes.length}write(e){this.bytes.forEach(t=>{e.put(t,8)})}}export class QRCodeBase{constructor(e,t){let{version:o,model:r,charCode:n}=t;this.charCode=n||getCharCode(e);const s=EC_INDICATOR[t.errorCorrectionLevel];this.config=t;this.errorCorrectionLevel=s;this.model=+r;o="auto"===o?this.getAutoVersion():+o;this.version=o;this.modulesCount=getSizeByVersion(o);this.charCountIndicatorBitsNumber=getCharacterCountIndicatorbitsNumber(o);this.errorCorrectionCharacteristics=getErrorCorrectionCharacteristics(o,s,this.model);this.totalDataCount=this.errorCorrectionCharacteristics.reduce((e,t)=>e+t.data,0);this.totalDataBits=8*this.totalDataCount}getConnections(){const{totalDataBits:e,charCode:t}=this;let o=e-20,r=t.length,n=0,s=1,i=[],a=t[0];for(;s<=r;){let e=t.slice(n,s),l=this.analysisData(e);if(this.encodeData(l).length>o){i.push(a);n=s-1}else s===r&&i.push(e);a=e;s++}return i}processConnection(e){let{totalDataBits:t,config:{connection:o,connectionNo:r}}=this;r=+r;if(o){let o=Math.ceil(e.length/(t-20));if(r>o-1)throw new InvalidOptionsException({connectionNo:r},"Max connection number is "+(o-1));let n=this.getConnections()[r],s=this.analysisData(n);return this.encodeData(s,{connectionNo:r,connectionCnt:o})}if(e.length>t)throw new TextTooLongException;return e}padBuffer(e){const{totalDataBits:t}=this;e.length+4<=t&&e.put(MODE_INDICATOR.Terminator,4);for(;e.length%8!=0;)e.putBit(!1);for(;!(e.length>=t);){e.put(236,8);if(e.length>=t)break;e.put(17,8)}}getAutoVersion(){let{errorCorrectionLevel:e,charCode:t,model:o}=this;for(let r=getEstimatedVersion(e,t,o);r<40;r++){this.version=r;this.modulesCount=getSizeByVersion(this.version);this.charCountIndicatorBitsNumber=getCharacterCountIndicatorbitsNumber(this.version);this.errorCorrectionCharacteristics=getErrorCorrectionCharacteristics(this.version,e);this.totalDataCount=this.errorCorrectionCharacteristics.reduce((e,t)=>e+t.data,0);this.totalDataBits=8*this.totalDataCount;let o=this.analysisData(t);if(!(this.encodeData(o).length>this.totalDataBits))return r}throw new TextTooLongException}analysisData(e){const{version:t,config:{charset:o}}=this;let r=getCharMode(e[0],o);switch(r){case"Alphanumeric":let o=getModeCheckInfo(r,t);isMode("8BitByte",e.slice(1,1+o[0]))&&(r="8BitByte");break;case"Numeric":let n=getModeCheckInfo(r,t),s=e.slice(1,1+n[0]),i=e.slice(1,1+n[1]);isMode("8BitByte",s)?r="8BitByte":isMode("Alphanumeric",i)&&(r="Alphanumeric")}let n={mode:r,code:[]};const s=[n];e.forEach((r,i)=>{let a=getCharMode(r,o);if(n.mode===a)n.code.push(r);else if("8BitByte"===n.mode)if("Kanji"===a){n={mode:a,code:[r]};s.push(n)}else if("Numeric"===a){let o=getModeCheckInfo(a,t);if(isMode(a,e.slice(i,i+o[2]))){n={mode:a,code:[r]};s.push(n)}else n.code.push(r)}else if("Alphanumeric"===a){let o=getModeCheckInfo(a,t);if(isMode(a,e.slice(i,i+o[1]))){n={mode:a,code:[r]};s.push(n)}else n.code.push(r)}else n.code.push(r);else if("Alphanumeric"===n.mode)if("Kanji"===a||"8BitByte"===a){n={mode:a,code:[r]};s.push(n)}else if("Numeric"===a){let o=getModeCheckInfo(a,t);if(isMode(a,e.slice(i,i+o[2]))){n={mode:a,code:[r]};s.push(n)}else n.code.push(r)}else n.code.push(r);else{n={mode:a,code:[r]};s.push(n)}});return s}generateErrorCorrectionCode(e){const{errorCorrectionCharacteristics:t}=this,o=[];let r=0;t.forEach(t=>{let n=e.getBuffer().slice(r,r+t.data);o.push({data:n,ec:generateErrorCorrectionCode(n,t.ec,t.data)});r+=t.data});return o}addRectModule(e,t,o,r,n=!1){const{modules:s}=this,i=r+t,a=o+e;for(;t<i;t++){let o=e;for(;o<a;o++)s[t][o]=+n}}addPositionDetectionPattern(){const{modules:e}=this,t=e.length;this.addPattern(0,0,7);this.addRectModule(7,0,1,8,!1);this.addRectModule(0,7,8,1,!1);let o=t-7;this.addPattern(o,0,7);this.addRectModule(o-1,0,1,8,!1);this.addRectModule(o-1,7,8,1,!1);let r=t-7;this.addPattern(0,r,7);this.addRectModule(7,r-1,1,8,!1);this.addRectModule(0,r-1,8,1,!1)}addTimingPattern(){const{modules:e}=this,t=e.length;let o=!0;for(let r=8;r<t-7;r++){e[6][r]=+o;e[r][6]=+o;o=!o}}addPattern(e,t,o){this.addRectModule(e,t,o,o,!0);this.addRectModule(e+1,t+1,o-2,o-2,!1);this.addRectModule(e+2,t+2,o-4,o-4,!0)}}export class QRCodeModel2 extends QRCodeBase{encodeData(e,t){const{charCountIndicatorBitsNumber:o,charCode:r}=this;let n=new BitBuffer;if(t){n.put(MODE_INDICATOR.StructuredAppend,4);n.put(t.connectionNo,4);n.put(t.connectionCnt-1,4);n.put(getParityData(r),8)}e.forEach(e=>{if(!e.code)return;let t;switch(e.mode){case"Numeric":t=new ModeNumeric(e.code);break;case"Alphanumeric":t=new ModeAlphanumeric(e.code);break;case"8BitByte":t=new Mode8BitByte(e.code);break;case"Kanji":t=new ModeKanji(e.code)}n.put(t.getMode(),4);n.put(t.getLength(),o[t.mode]);t.write(n)});return n}getFinalMessage(e){const t=[],o=e.map(e=>e.data),r=e.map(e=>e.ec),n=Utils.getMaxValue(o),s=Utils.getMaxValue(r);for(let e=0;e<n;e++)o.forEach(o=>{Utils.isDefined(o[e])&&t.push(o[e])});for(let e=0;e<s;e++)r.forEach(o=>{Utils.isDefined(o[e])&&t.push(o[e])});return t}setModules(e){let{modulesCount:t,version:o}=this;this.modules=createModules(t);this.addPositionDetectionPattern();this.addAlignmentPattern();this.addTimingPattern();o>6&&this.addVersionInformation();this.maskModules(e)}maskModules(e){const{modules:t,errorCorrectionLevel:o,model:r,config:{mask:n}}=this;if("auto"===n)this.autoMask(e);else{let s=getMaskFunc(n);this.maskPattern=n;let i=addFormatInformation(t,n,o,r);this.modules=this.fillDataModules(i,e,s)}}autoMask(e){const{modules:t,errorCorrectionLevel:o,model:r}=this;let n,s,i;maskFuncs.forEach((a,l)=>{let c=addFormatInformation(t,l,o,r),d=this.fillDataModules(c,e,a),h=getMaskScore(d);if(!s||h<s){n=d;s=h;i=l}});this.modules=n;this.maskPattern=i}addAlignmentPattern(){const{modules:e,version:t}=this,o=getAlignmentPattersPos(t);o.forEach(t=>{o.forEach(o=>{null===e[t][o]&&this.addPattern(o-2,t-2,5)})})}addVersionInformation(){const{modulesCount:e,modules:t,version:o}=this,r=getBCH18(o);for(let o=0;o<18;o++){let n=r>>o&1;t[Math.floor(o/3)][o%3+e-8-3]=n;t[o%3+e-8-3][Math.floor(o/3)]=n}}fillDataModules(e,t,o){const r=e.length;let n=-1,s=r-1,i=7,a=0;for(let l=r-1;l>0;l-=2){6==l&&(l-=1);for(;;){for(let r=0;r<2;r+=1)if(null==e[s][l-r]){let n=!1;a<t.length&&(n=1==(t[a]>>>i&1));o(s,l-r)&&(n=!n);e[s][l-r]=+n;i-=1;if(-1==i){a+=1;i=7}}s+=n;if(s<0||r<=s){s-=n;n=-n;break}}}return e}getMatrix(){let{charCode:e}=this,t=this.analysisData(e),o=this.encodeData(t),r=this.processConnection(o);this.padBuffer(r);let n=this.generateErrorCorrectionCode(r),s=this.getFinalMessage(n);this.setModules(s);return this.modules}}export class QRCodeModel1 extends QRCodeBase{encodeData(e,t){const{charCountIndicatorBitsNumber:o,charCode:r}=this;let n=new BitBuffer;n.put(0,4);if(t){n.put(MODE_INDICATOR.StructuredAppend,4);n.put(t.connectionNo,4);n.put(t.connectionCnt-1,4);n.put(getParityData(r),8)}e.forEach(e=>{if(!e.code)return;let t;switch(e.mode){case"Numeric":t=new ModeNumeric(e.code);break;case"Alphanumeric":t=new ModeAlphanumeric(e.code);break;case"8BitByte":t=new Mode8BitByte(e.code);break;case"Kanji":t=new ModeKanji(e.code)}n.put(t.getMode(),4);n.put(t.getLength(),o[t.mode]);t.write(n)});return n}getFinalMessage(e){let t=[];const o=e.map(e=>e.data),r=e.map(e=>e.ec);o.forEach(e=>t=t.concat(e));r.forEach(e=>t=t.concat(e));return t}setModules(e){let{modulesCount:t}=this;this.modules=createModules(t);this.addPositionDetectionPattern();this.addExtensionPattern();this.addTimingPattern();this.maskModules(e)}maskModules(e){const{modules:t,errorCorrectionLevel:o,model:r,config:{mask:n}}=this;if("auto"===n)this.autoMask(e);else{let s=getMaskFunc(n);this.maskPattern=n;let i=addFormatInformation(t,n,o,r);this.modules=this.fillDataModules(i,e,s)}}autoMask(e){const{modules:t,errorCorrectionLevel:o,model:r}=this;let n,s,i;maskFuncs.forEach((a,l)=>{let c=addFormatInformation(t,l,o,r),d=this.fillDataModules(c,e,a),h=getMaskScore(d);if(!s||h<s){n=d;s=h;i=l}});this.modules=n;this.maskPattern=i}addExtensionPattern(){const{modules:e,version:t}=this,o=e.length;e[o-1][o-1]=1;e[o-2][o-1]=0;e[o-1][o-2]=0;e[o-2][o-2]=0;let r=Math.floor(t/2);if(Utils.isEven(t))for(let e=0;e<r;e++){this.addBaseExtension(13+8*e);this.addRightExtension(13+8*e)}else for(let e=0;e<r;e++){this.addBaseExtension(17+8*e);this.addRightExtension(17+8*e)}}addBaseExtension(e){const{modules:t}=this,o=t.length;let r=o-2,n=o-1;t[r][e]=0;t[r][e+1]=0;t[r][e+2]=0;t[r][e+3]=0;t[n][e]=1;t[n][e+1]=1;t[n][e+2]=1;t[n][e+3]=1}addRightExtension(e){const{modules:t}=this,o=t.length;let r=o-2,n=o-1;t[e][r]=0;t[e+1][r]=0;t[e+2][r]=0;t[e+3][r]=0;t[e][n]=1;t[e+1][n]=1;t[e+2][n]=1;t[e+3][n]=1}fillDataModules(e,t,o){const r=e.length;let n,s;n=s=r-1;let i=2,a=new BitBuffer(t);a.next();a.next();a.next();a.next();for(;n>=0;){if(n==r-5)i=4;else if(8==n)i=2;else if(6==n){n--;continue}for(;s>=0;)if(null===e[s][n]){for(let t=0;t<i;t++){let r=a.next();o(s,n-t)&&(r=!r);e[s][n-t]=+r}s--}else s--;n-=i;s=r-1}return e}getMatrix(){let{charCode:e}=this,t=this.analysisData(e),o=this.encodeData(t),r=this.processConnection(o);this.padBuffer(r);let n=this.generateErrorCorrectionCode(r),s=this.getFinalMessage(n);this.setModules(s);return this.modules}}export class QRCodeEncoder extends TwoDimensionalBarcode{constructor(e){e.merge(QRCodeEncoder.DefaultConfig);super(e);const{encodeConfig:{text:t},config:o}=this;let r;r="2"==o.model?new QRCodeModel2(t,o):new QRCodeModel1(t,o);this.innerQRCode=r}calculateData(){return this.innerQRCode.getMatrix()}validate(){const{version:e,model:t,charset:o,charCode:r,connectionNo:n}=this.config,{text:s}=this.encodeConfig;if(!(s||r&&0!==r.length))throw new InvalidTextException(s);if("1"!=t&&"2"!=t)throw new InvalidOptionsException({model:t});if("UTF-8"!=o&&"Shift_JIS"!=o)throw new InvalidOptionsException({charset:o});if("1"==t&&Utils.isNumberLike(e)&&(e<1||e>14))throw new InvalidOptionsException({version:e},"Model 1 only support version 1 - 14.");if("2"==t&&Utils.isNumberLike(e)&&(e<1||e>40))throw new InvalidOptionsException({version:e},"Model 2 only support version 1 - 40.");if(n>15||n<0)throw new InvalidOptionsException({connectionNo:n},"ConnectionNo is in range 0 - 15.")}}QRCodeEncoder.DefaultConfig={version:"auto",errorCorrectionLevel:"L",model:2,mask:"auto",connection:!1,connectionNo:0,charCode:void 0,charset:"UTF-8",quietZone:{top:4,left:4,right:4,bottom:4}};Barcode.registerEncoder("QRCode",QRCodeEncoder);const TableCode128A=[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","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","[","\\","]","^","_","\0","","","","","","","","\b","\t","\n","\v","\f","\r","","","","","","","","","","","","","","","","","",""," "," "," "," "," "," "," "," "," "," "],TableCode128B=[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","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","[","\\","]","^","_","`","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","{","|","}","~",""," "," "," "," "," "," "," "," "," "," "],TableCode128Data=["212222","222122","222221","121223","121322","131222","122213","122312","132212","221213","221312","231212","112232","122132","122231","113222","123122","123221","223211","221132","221231","213212","223112","312131","311222","321122","321221","312212","322112","322211","212123","212321","232121","111323","131123","131321","112313","132113","132311","211313","231113","231311","112133","112331","132131","113123","113321","133121","313121","211331","231131","213113","213311","213131","311123","311321","331121","312113","312311","332111","314111","221411","431111","111224","111422","121124","121421","141122","141221","112214","112412","122114","122411","142112","142211","241211","221114","413111","241112","134111","111242","121142","121241","114212","124112","124211","411212","421112","421211","212141","214121","412121","111143","111341","131141","114113","114311","411113","411311","113141","114131","311141","411131","211412","211214","211232"];export const stopPattern="2331112";export const Code128Sym={CodeC:99,CodeB:100,CodeA:101,FNC1:102,FNC2:97,FNC3:96,StartA:103,StartB:104,StartC:105};export const Code128Char={CodeC:String.fromCharCode(204),CodeB:String.fromCharCode(205),CodeA:String.fromCharCode(206),FNC1:Constants.FNC1,FNC2:Constants.FNC2,FNC3:Constants.FNC3,StartA:String.fromCharCode(208),StartB:String.fromCharCode(209),StartC:String.fromCharCode(210)};export function getCharValue(e,t){if(e===Code128Char.FNC1)return Code128Sym.FNC1;if(e===Code128Char.FNC2)return Code128Sym.FNC2;if(e===Code128Char.FNC3)return Code128Sym.FNC3;let o;switch(t){case"A":o=TableCode128A.indexOf(e);return o;case"B":o=TableCode128B.indexOf(e);return o;case"C":return+e}}export function getCharPattern(e,t){const o=TableCode128Data[getCharValue(e,t)];if(!o)throw new InvalidCharacterException(e);return o}export function getPatternByIndex(e){return TableCode128Data[e]}export function encode(e){let t="";Utils.str2Array(e).forEach((e,o)=>{Utils.isEven(o)?t+=Utils.strRepeat("1",+e):t+=Utils.strRepeat("0",+e)});return t}const CODE_SET_A="A",CODE_SET_B="B",CODE_SET_C="C";export class Code128Auto{constructor(e,t=!1){this.text=e;this.isUccEan128=t;this.validate()}validate(){let{text:e}=this;if(!/^[\x00-\x7F\xC8-\xD3]+$/.test(e))throw new InvalidTextException(e)}calculateGroup(){let{text:e,isUccEan128:t}=this,o={code:t?"C":"B",text:""},r=[];r.push(o);for(let t=0,n=e.length;t<n;t++){let s=o.code,i=e[t];if("C"!==o.code&&t+3<n&&Utils.isNumberString(e.substr(t,4))||"C"===o.code&&t+1<n&&Utils.isNumberString(e.substr(t,2))){s="C";i+=e[++t]}else{s="C"===o.code?"B":o.code;if(getCharValue(i,s)<0){s="A"===o.code?"B":"A";if(getCharValue(i,s)<0)continue}}if(o.code!==s){o={code:s,text:i};r.push(o)}else o.text+=i}return r.filter(e=>e.text)}getData(){const e=this.calculateGroup(),t=this.checksum(e);let o="";e.forEach((e,t)=>{if(0===t){let t=getPatternByIndex(Code128Sym["Start"+e.code]);o+=encode(t)}else{let t=getPatternByIndex(Code128Sym["Code"+e.code]);o+=encode(t)}"C"===e.code?Utils.sliceString(e.text,2,t=>{o+=encode(getCharPattern(t,e.code))}):Utils.sliceString(e.text,1,t=>{o+=encode(getCharPattern(t,e.code))})});o+=encode(getPatternByIndex(t));o+=encode("2331112");return o}checksum(e){let t=0,o=0;e.forEach((e,r)=>{let{code:n,text:s}=e;if(0===r)o+=Code128Sym["Start"+n];else{o+=Code128Sym["Code"+n]*++t}"C"===n?Utils.sliceString(s,2,e=>{o+=getCharValue(e,n)*++t}):Utils.sliceString(s,1,e=>{o+=getCharValue(e,n)*++t})});return o%103}}export class Code128C{constructor(e){this.text=e;this.validate()}validate(){let{text:e}=this;if(!/^(\xCF*[0-9]{2}\xCF*)+$/.test(e))throw new InvalidTextException(e)}getData(){let{text:e}=this;const t=this.checksum();let o="",r=getPatternByIndex(Code128Sym.StartC);o+=encode(r);Utils.sliceString(e,2,e=>{let t=getCharPattern(e,"C");o+=encode(t)});o+=encode(getPatternByIndex(t));o+=encode("2331112");return o}checksum(){let{text:e}=this,t=0,o=0;Utils.sliceString(e,2,e=>{o+=getCharValue(e,"C")*++t});o+=Code128Sym.StartC;return o%103}}export class Code128B{constructor(e){this.text=e;this.validate()}validate(){let{text:e}=this;if(!/^[\x20-\x7F\xC8-\xCF]+$/.test(e))throw new InvalidTextException(e)}getData(){let{text:e}=this;const t=this.checksum();let o="",r=getPatternByIndex(Code128Sym.StartB);o+=encode(r);Utils.sliceString(e,1,e=>{let t=getCharPattern(e,"B");o+=encode(t)});o+=encode(getPatternByIndex(t));o+=encode("2331112");return o}checksum(){let{text:e}=this,t=0,o=0;Utils.sliceString(e,1,e=>{o+=getCharValue(e,"B")*++t});o+=Code128Sym.StartB;return o%103}}export class Code128A{constructor(e){this.text=e;this.validate()}validate(){let{text:e}=this;if(!/^[\x00-\x5F\xC8-\xCF]+$/.test(e))throw new InvalidTextException(e)}getData(){let{text:e}=this;const t=this.checksum();let o="",r=getPatternByIndex(Code128Sym.StartA);o+=encode(r);Utils.sliceString(e,1,e=>{let t=getCharPattern(e,"A");o+=encode(t)});o+=encode(getPatternByIndex(t));o+=encode("2331112");return o}checksum(){let{text:e}=this,t=0,o=0;Utils.sliceString(e,1,e=>{o+=getCharValue(e,"A")*++t});o+=Code128Sym.StartA;return o%103}}export class Code128Encoder extends OneDimensionalBarcode{constructor(e,t=!1){e.merge(Code128Encoder.DefaultConfig);super(e);let{text:o}=this.encodeConfig;this.isUccEan128=t;t&&o[0]!==Code128Char.FNC1&&(o=Code128Char.FNC1+o);this.text=o;this.label=o.replace(/[^\x20-\x7E]/g,"")}validate(){}calculateData(){let e,{config:{codeSet:t},text:o,isUccEan128:r}=this;if(r)e=new Code128Auto(o);else switch(t){case"A":e=new Code128A(o);break;case"B":e=new Code128B(o);break;case"C":e=new Code128C(o);break;default:e=new Code128Auto(o)}return e.getData()}}Code128Encoder.DefaultConfig={codeSet:"auto",quietZone:{right:10,left:10}};export class GS1_128Encoder extends Code128Encoder{constructor(e){super(e,!0)}}Barcode.registerEncoder("GS1_128",GS1_128Encoder);Barcode.registerEncoder("Code128",Code128Encoder);export class EncodeTable_Code39{static getMod43Val(e){let t=0;Utils.sliceString(e,1,e=>{t+=EncodeTable_Code39.MODULO_43_CHECK_TABLE.indexOf(e)});return EncodeTable_Code39.MODULO_43_CHECK_TABLE[t%43]}static getFullASCIIChar(e){let t="";Utils.sliceString(e,1,o=>{let r=EncodeTable_Code39.FULL_ASCII_TABLE[o.charCodeAt(0)];if(!r)throw new InvalidTextException(e);t+=r});return t}}EncodeTable_Code39.TABLE={0:"000110100",1:"100100001",2:"001100001",3:"101100000",4:"000110001",5:"100110000",6:"001110000",7:"000100101",8:"100100100",9:"001100100",A:"100001001",B:"001001001",C:"101001000",D:"000011001",E:"100011000",F:"001011000",G:"000001101",H:"100001100",I:"001001100",J:"000011100",K:"100000011",L:"001000011",M:"101000010",N:"000010011",O:"100010010",P:"001010010",Q:"000000111",R:"100000110",S:"001000110",T:"000010110",U:"110000001",V:"011000001",W:"111000000",X:"010010001",Y:"110010000",Z:"011010000","-":"010000101",".":"110000100"," ":"011000100",$:"010101000","/":"010100010","+":"010001010","%":"000101010","*":"010010100"};EncodeTable_Code39.MODULO_43_CHECK_TABLE=Utils.str2Array("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%");EncodeTable_Code39.FULL_ASCII_TABLE=["%U","$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","%A","%B","%C","%D","%E"," ","/A","/B","/C","/D","/E","/F","/G","/H","/I","/J","/K","/L","-",".","/O","0","1","2","3","4","5","6","7","8","9","/Z","%F","%G","%H","%I","%J","%V","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","%K","%L","%M","%N","%O","%W","+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","%P","%Q","%R","%S","%T"];export class Code39Encoder extends OneDimensionalBarcode{constructor(e){e.merge(Code39Encoder.DefaultConfig);super(e);let{encodeConfig:{text:t,hideExtraChecksum:o},config:{checkDigit:r,fullASCII:n,nwRatio:s,labelWithStartAndStopCharacter:i}}=this,a=n?EncodeTable_Code39.getFullASCIIChar(t):t;if(r){const e=EncodeTable_Code39.getMod43Val(a);this.text=Code39Encoder.START_STOP_CHARACTERS+a+e+Code39Encoder.START_STOP_CHARACTERS;const r=o?t:t+e,n=Code39Encoder.START_STOP_CHARACTERS+r+Code39Encoder.START_STOP_CHARACTERS;this.label=i?n:r}else{this.text=Code39Encoder.START_STOP_CHARACTERS+a+Code39Encoder.START_STOP_CHARACTERS;const e=t,o=Code39Encoder.START_STOP_CHARACTERS+e+Code39Encoder.START_STOP_CHARACTERS;this.label=i?o:e}this.nwRatio=+s}validate(){let{encodeConfig:{text:e},config:{fullASCII:t,nwRatio:o}}=this;if(!t&&!/^[0-9A-Z\-\.\ \$\/\+\%]+$/.test(e))throw new InvalidTextException(e);if(2!=o&&3!=o)throw new InvalidOptionsException({nwRatio:o},"NwRatio is 2 or 3")}encode(e){let{nwRatio:t}=this,o="";const r=Utils.strRepeat("1",t),n=Utils.strRepeat("0",t);Utils.str2Array(e).forEach((e,t)=>{Utils.isEven(t)?o+="1"===e?r:"1":o+="1"===e?n:"0"});return o}calculateData(){let{text:e}=this,t="";Utils.sliceString(e,1,e=>{t=t+this.encode(EncodeTable_Code39.TABLE[e])+"0"});t=t.substr(0,t.length-1);return t}}Code39Encoder.DefaultConfig={checkDigit:!1,fullASCII:!1,nwRatio:3,labelWithStartAndStopCharacter:!1,quietZone:{right:10,left:10}};Code39Encoder.START_STOP_CHARACTERS="*";Barcode.registerEncoder("Code39",Code39Encoder);export class EncodeTable{static encodeCharByTable(e,t){return EncodeTable.TABLE[t][e]}static encodeByStructure(e,t){return Utils.str2Array(e).reduce((e,o,r)=>e+=EncodeTable.encodeCharByTable(o,t[r]),"")}static encodeByTable(e,t){if(e.length>1){return Utils.str2Array(e).reduce((e,o)=>e+=EncodeTable.encodeCharByTable(o,t),"")}return EncodeTable.encodeCharByTable(e,t)}}EncodeTable.TABLE={A:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],B:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],C:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"]};export class AddOnSymbol{constructor(e,t,o,r){this.isTextGroup=o;this.addOn=""+e;if("auto"!==t)if(Utils.isNumberLike(t))t=+t;else{t=Utils.convertUnit(Utils.fixSize2PixelDefault(t));t/=r}this.addOnHeight=t;this.validate()}static get2DigitAddOnTable(e){switch((e=parseInt(e))%4){case 0:return{leftStructure:"A",rightStructure:"A"};case 1:return{leftStructure:"A",rightStructure:"B"};case 2:return{leftStructure:"B",rightStructure:"A"};case 3:return{leftStructure:"B",rightStructure:"B"}}}static get5DigitAddOnTable(e){const t=3*(+(e+="")[0]+ +e[2]+ +e[4])+9*(+e[1]+ +e[3]);return AddOnSymbol.fiveDigitAddOnStructure[t%10]}validate(){const{addOn:e}=this;if(2!==e.length&&5!==e.length)throw new InvalidOptionsException({addOn:e},"Add on length should be 2 or 5.")}_encode2DigitAddOn(){let{addOn:e,isTextGroup:t}=this;const o=[];let r,n,s;r=AddOnSymbol.get2DigitAddOnTable(e);n=EncodeTable.encodeByTable(e[0],r.leftStructure[0]);s=EncodeTable.encodeByTable(e[1],r.rightStructure[0]);if(t){o.push({binary:AddOnSymbol.ADD_ON_GUARD,role:"ADDON"});o.push({binary:n,text:e[0],role:"ADDON"});o.push({binary:AddOnSymbol.ADD_ON_DELINEATOR,role:"ADDON"});o.push({binary:s,text:e[1],role:"ADDON"})}else o.push({binary:AddOnSymbol.ADD_ON_GUARD+n+AddOnSymbol.ADD_ON_DELINEATOR+s,text:e,role:"ADDON"});return o}_encode5DigitAddOn(){let{addOn:e,isTextGroup:t}=this;const o=[];let r=AddOnSymbol.get5DigitAddOnTable(e);if(t){o.push({binary:AddOnSymbol.ADD_ON_GUARD,role:"ADDON"});Utils.str2Array(e).forEach((t,n)=>{o.push({binary:EncodeTable.encodeByTable(t,r[n]),text:t,role:"ADDON"});n<e.length-1&&o.push({binary:AddOnSymbol.ADD_ON_DELINEATOR,role:"ADDON"})})}else{let t=Utils.str2Array(e).reduce((t,o,n)=>{t+=EncodeTable.encodeByTable(o,r[n]);n<e.length-1&&(t+=AddOnSymbol.ADD_ON_DELINEATOR);return t},"");o.push({binary:AddOnSymbol.ADD_ON_GUARD+t,text:e,role:"ADDON"})}return o}calculateData(){let{addOn:e}=this,t=[];2===e.length?t=this._encode2DigitAddOn():5===e.length&&(t=this._encode5DigitAddOn());t.push({text:">",role:"ADDON_RIGHT_QUIET_ZONE"});return t}}AddOnSymbol.fiveDigitAddOnStructure=["BBAAA","BABAA","BAABA","BAAAB","ABBAA","AABBA","AAABB","ABABA","ABAAB","AABAB"];AddOnSymbol.ADD_ON_GUARD="1011";AddOnSymbol.ADD_ON_DELINEATOR="01";export class EANBase extends OneDimensionalBarcode{constructor(e){e.merge(EANBase.DefaultConfig);super(e);let{style:{textAlign:t,unitValue:o},config:{addOnLabelPosition:r,addOn:n,addOnHeight:s}}=this;this.isTextGroup="group"===t;this.isAddOnLabelBottom="top"!==r;this._setAddOn(n,s,o)}_setAddOn(e,t,o){if(Utils.isDefined(e)){this.addOn=new AddOnSymbol(e,t,this.isTextGroup,o);this.addOnHeight=this.addOn.addOnHeight}else this.addOnHeight=0}checksum(e,t=!1){let o=Utils.str2Array(e),r=t?Utils.isOdd:Utils.isEven,n=o.reduce((e,t,o)=>{t=+t;return e+=r(o)?t:3*t},0)%10;return 0===n?0:10-n}convertToShape(e){let{isTextGroup:t,addOnHeight:o,isAddOnLabelBottom:r,style:{textAlign:n},encodeConfig:{isLabelBottom:s,height:i,quietZone:a,showLabel:l,fontSizeInUnit:c}}=this;l||(c=0);o=o||0;const d=[];let h,u,C,g,p,E,A,m=a.left,f=a.top;if(s){h=i+5;u=f+i;C=l?i+c:h;if(r){g=f;E="auto"===o?l?i:h:o;p=g+E}else{p=f;g=f+c;E="auto"===o?h-c:o}}else{h=i;i-=5;u=f;f+=c;C=l?h+c:h;if(r){g=a.top;E="auto"===o?l?i:h:o;p=g+E}else{p=a.top;g=a.top+c;E="auto"===o?h:o}}A=l?E+c:E;e.forEach(e=>{let o,r=f,s=i,c=u,C=t?"center":n,A=m;switch(e.role){case"GUARD":s=h;o=e.binary.length;break;case"ADDON":r=g;s=E;c=p;o=e.binary.length;break;case"LEFT_QUIET_ZONE":C="left";o=a.left;A=0;break;case"RIGHT_QUIET_ZONE":case"NO_ADDON_RIGHT_QUIET_ZONE":C="right";o=a.right;break;case"ADDON_QUIET_ZONE":o=a.addOn;break;case"ADDON_RIGHT_QUIET_ZONE":C="right";c=p;o=a.right;break;default:o=e.binary.length}if(l&&e.text){switch(C){case"center":A+=o/2;break;case"right":A+=o}const t={type:"text",x:A,y:c,text:e.text,textAlign:C,maxWidth:o};if("NO_ADDON_RIGHT_QUIET_ZONE"===e.role||"ADDON_RIGHT_QUIET_ZONE"===e.role){t.fontStyle="normal";t.fontWeight="normal";t.textDecoration="none"}d.push(t)}e.binary?Utils.combineTruthy(e.binary).forEach(e=>{if(0!==e){d.push({type:"rect",x:m,y:r,width:e,height:s});m+=e}else m++}):"ADDON_QUIET_ZONE"===e.role&&(m+=o)});this.size={width:m+a.right,height:Math.max(C,A)+a.top+a.bottom};this.shapes=d}afterApplyDesiredSize(){let{config:{addOn:e,addOnHeight:t},style:{unitValue:o}}=this;this._setAddOn(e,t,o);this.addOnHeight>this.encodeConfig.height&&(this.addOnHeight=this.encodeConfig.height)}}EANBase.NORMAL_GUARD="101";EANBase.CENTRE_GUARD="01010";EANBase.DefaultConfig={quietZone:{right:7,left:11}};export class UPC_E extends EANBase{constructor(e,t,o){e.merge(UPC_E.DefaultConfig);super(e);let{text:r,hideExtraChecksum:n}=this.encodeConfig;this.prefix=t;let s=r;if(r.length<7){r+=this.checksum(r);n||(s=r)}this.label=s;this.text=r;this.tableStructure=o}validate(){const{text:e}=this.encodeConfig;if(!/^(\d{6}|\d{7})$/.test(e))throw new InvalidTextException(e,"Text should be numbers. The length should be 6 or 7.");if(7===e.length){if(this.checksum(e.substr(0,6))!=e[6])throw new InvalidTextException(e,"Check digit is invalid.")}}checksum(e){let t;switch(e[5]){case"0":case"1":case"2":t=e.substr(0,2)+e[5]+"0000"+e.substr(2,3);break;case"3":t=e.substr(0,3)+"00000"+e.substr(3,2);break;case"4":t=e.substr(0,4)+"00000"+e[4];break;default:t=e.substr(0,5)+"0000"+e[5]}t=this.prefix+t;return super.checksum(t,!0)}calculateData(){let{text:e,addOn:t,isTextGroup:o,prefix:r,tableStructure:n,label:s}=this;const i=e[6],a=s[6];e=e.substr(0,6);const l=s.substr(0,6),c=n[i];let d=[];d.push({text:r,role:"LEFT_QUIET_ZONE"});d.push({binary:EANBase.NORMAL_GUARD,role:"GUARD"});o?Utils.str2Array(e).forEach((e,t)=>{d.push({binary:EncodeTable.encodeByTable(e,c[t]),text:l[t]})}):d.push({binary:EncodeTable.encodeByStructure(e,c),text:l});d.push({binary:UPC_E.SPECIAL_GUARD,role:"GUARD"});if(t){d.push({text:a,role:"ADDON_QUIET_ZONE"});d=d.concat(t.calculateData())}else d.push({text:a,role:"NO_ADDON_RIGHT_QUIET_ZONE"});return d}}UPC_E.DefaultConfig={addOnHeight:"auto",addOnLabelPosition:"top",quietZone:{left:9,addOn:5}};UPC_E.SPECIAL_GUARD="010101";export class UPC_E1_Encoder extends UPC_E{constructor(e){super(e,"1",UPC_E1_Encoder.structure)}}UPC_E1_Encoder.structure=["AAABBB","AABABB","AABBAB","AABBBA","ABAABB","ABBAAB","ABBBAA","ABABAB","ABABBA","ABBABA"];export class UPC_E0_Encoder extends UPC_E{constructor(e){super(e,"0",UPC_E0_Encoder.structure)}}UPC_E0_Encoder.structure=["BBBAAA","BBABAA","BBAABA","BBAAAB","BABBAA","BAABBA","BAAABB","BABABA","BABAAB","BAABAB"];export class UPC_A_Encoder extends EANBase{constructor(e){e.merge(UPC_A_Encoder.DefaultConfig);super(e);let{text:t,hideExtraChecksum:o}=this.encodeConfig,r=t;if(t.length<12){t+=this.checksum(t,!0);o||(r=t)}this.label=r;this.text=t}validate(){const{text:e}=this.encodeConfig;if(!/^(\d{11}|\d{12})$/.test(e))throw new InvalidTextException(e,"Text should be numbers. The length should be 11 or 12.");if(12===e.length){if(this.checksum(e.substr(0,11),!0)!=e[11])throw new InvalidTextException(e,"Check digit is invalid.")}}calculateData(){let{text:e,addOn:t,isTextGroup:o,label:r}=this;const n=e[0],s=e[11],i=r[11];let a=e.substr(1,5),l=e.substr(6,5),c=r.substr(1,5),d=r.substr(6,5),h=[];h.push({text:n,role:"LEFT_QUIET_ZONE"});h.push({binary:EANBase.NORMAL_GUARD+EncodeTable.encodeByTable(n,"A"),role:"GUARD"});o?Utils.str2Array(a).forEach((e,t)=>{h.push({binary:EncodeTable.encodeByTable(e,"A"),text:c[t]})}):h.push({binary:EncodeTable.encodeByTable(a,"A"),text:c});h.push({binary:EANBase.CENTRE_GUARD,role:"GUARD"});o?Utils.str2Array(l).forEach((e,t)=>{h.push({binary:EncodeTable.encodeByTable(e,"C"),text:d[t]})}):h.push({binary:EncodeTable.encodeByTable(l,"C"),text:d});h.push({binary:EncodeTable.encodeByTable(s,"C")+EANBase.NORMAL_GUARD,role:"GUARD"});if(t){h.push({text:i,role:"ADDON_QUIET_ZONE"});h=h.concat(t.calculateData())}else h.push({text:i,role:"NO_ADDON_RIGHT_QUIET_ZONE"});return h}}UPC_A_Encoder.DefaultConfig={addOnHeight:"auto",addOnLabelPosition:"top",quietZone:{right:9,left:9,addOn:5}};Barcode.registerEncoder("UPC-A",UPC_A_Encoder);Barcode.registerEncoder("UPC-E0",UPC_E0_Encoder);Barcode.registerEncoder("UPC-E1",UPC_E1_Encoder);export class EAN13Encoder extends EANBase{constructor(e){e.merge(EAN13Encoder.DefaultConfig);super(e);let{text:t,hideExtraChecksum:o}=this.encodeConfig,r=t;if(t.length<13){t+=this.checksum(t);o||(r=t)}this.label=r;this.text=t}validate(){const{text:e}=this.encodeConfig;if(!/^[1-9](\d{11}|\d{12})$/.test(e))throw new InvalidTextException(e,"Text should be numbers. And it should not start with 0. The length should be 12 or 13.");if(13===e.length){if(this.checksum(e.substr(0,12))!=e[12])throw new InvalidTextException(e,"Check digit is invalid.")}}calculateData(){let{text:e,addOn:t,isTextGroup:o,label:r}=this,n=e.substr(1,6),s=e.substr(7,6),i=r.substr(1,6),a=r.substr(7,6);const l=EAN13Encoder.leftStructure[e[0]];let c=[];c.push({text:e[0],role:"LEFT_QUIET_ZONE"});c.push({binary:EANBase.NORMAL_GUARD,role:"GUARD"});o?Utils.str2Array(n).forEach((e,t)=>{c.push({binary:EncodeTable.encodeByTable(e,l[t]),text:i[t]})}):c.push({binary:EncodeTable.encodeByStructure(n,l),text:i});c.push({binary:EANBase.CENTRE_GUARD,role:"GUARD"});o?Utils.str2Array(s).forEach((e,t)=>{c.push({binary:EncodeTable.encodeByTable(e,"C"),text:a[t]})}):c.push({binary:EncodeTable.encodeByTable(s,"C"),text:a});c.push({binary:EANBase.NORMAL_GUARD,role:"GUARD"});if(t){c.push({role:"ADDON_QUIET_ZONE"});c=c.concat(t.calculateData())}else c.push({text:">",role:"NO_ADDON_RIGHT_QUIET_ZONE"});return c}}EAN13Encoder.leftStructure=["AAAAAA","AABABB","AABBAB","AABBBA","ABAABB","ABBAAB","ABBBAA","ABABAB","ABABBA","ABBABA"];EAN13Encoder.DefaultConfig={addOnHeight:"auto",addOnLabelPosition:"top",quietZone:{addOn:5}};export class EAN8Encoder extends EANBase{constructor(e){e.merge(EAN8Encoder.DefaultConfig);super(e);let{text:t,hideExtraChecksum:o}=this.encodeConfig,r=t;if(t.length<8){t+=this.checksum(t,!0);o||(r=t)}this.label=r;this.text=t}validate(){const{text:e}=this.encodeConfig;if(!/^[0-9](\d{6}|\d{7})$/.test(e))throw new InvalidTextException(e,"Text should be numbers. The length should be 7 or 8.");if(8===e.length){if(this.checksum(e.substr(0,7),!0)!=e[7])throw new InvalidTextException(e,"Check digit is invalid.")}}calculateData(){let{text:e,label:t,isTextGroup:o}=this,r=e.substr(0,4),n=e.substr(4,4),s=t.substr(0,4),i=t.substr(4,4);const a=[];a.push({text:"<",role:"LEFT_QUIET_ZONE"});a.push({binary:EANBase.NORMAL_GUARD,role:"GUARD"});o?Utils.str2Array(r).forEach((e,t)=>{a.push({binary:EncodeTable.encodeByTable(e,"A"),text:s[t]})}):a.push({binary:EncodeTable.encodeByTable(r,"A"),text:s});a.push({binary:EANBase.CENTRE_GUARD,role:"GUARD"});o?Utils.str2Array(n).forEach((e,t)=>{a.push({binary:EncodeTable.encodeByTable(e,"C"),text:i[t]})}):a.push({binary:EncodeTable.encodeByTable(n,"C"),text:i});a.push({binary:EANBase.NORMAL_GUARD,role:"GUARD"});a.push({text:">",role:"RIGHT_QUIET_ZONE"});return a}}EAN8Encoder.DefaultConfig={quietZone:{left:7}};Barcode.registerEncoder("EAN8",EAN8Encoder);Barcode.registerEncoder("EAN13",EAN13Encoder);const REG=/^([A-D]?)([0-9\-\$\:\.\+\/]+)([A-D]?)$/;export class CodabarEncoder extends OneDimensionalBarcode{constructor(e){e.merge(CodabarEncoder.DefaultConfig);super(e);let{config:{checkDigit:t,nwRatio:o},encodeConfig:{text:r,hideExtraChecksum:n}}=this;const{originStartPattern:s,startPattern:i,content:a,originStopPattern:l,stopPattern:c}=this.getTextEntity(r);this.label=r;if(t){let e=this.checksum(a);this.text=i+a+e+c;n||(this.label=s+a+e+l)}else this.text=i+a+c;this.nwRatio=+o}validate(){let{config:{nwRatio:e},encodeConfig:{text:t}}=this;if(!REG.test(t))throw new InvalidTextException(t);if(2!=e&&3!=e)throw new InvalidOptionsException({nwRatio:e},"NwRatio is 2 or 3")}getTextEntity(e){const t=REG.exec(e);if(!t)throw new InvalidTextException(e);const o=t[1],r=o||"A",n=t[2],s=t[3];return{originStartPattern:o,startPattern:r,content:n,originStopPattern:s,stopPattern:s||"B"}}encode(e){let{nwRatio:t}=this,o="";const r=Utils.strRepeat("1",t),n=Utils.strRepeat("0",t);Utils.str2Array(e).forEach((e,t)=>{Utils.isEven(t)?o+="1"===e?r:"1":o+="1"===e?n:"0"});return o}calculateData(){let{text:e}=this,t="";Utils.sliceString(e,1,e=>{t=t+this.encode(CodabarEncoder.TABLE[e])+"0"});t=t.substr(0,t.length-1);return t}checksum(e){let t=Utils.str2Array(e).filter(e=>Utils.isInteger(+e)).reverse().reduce((e,t,o)=>{let r=Utils.toNumber(t);if(Utils.isEven(o)){let t=2*r;e+=t>9?t-9:t}else e+=r;return e},0)%10;0!==t&&(t=10-t);return t}}CodabarEncoder.DefaultConfig={checkDigit:!1,quietZone:{right:10,left:10},nwRatio:3};CodabarEncoder.TABLE={0:"0000011",1:"0000110",2:"0001001",3:"1100000",4:"0010010",5:"1000010",6:"0100001",7:"0100100",8:"0110000",9:"1001000","-":"0001100",$:"0011000",":":"1000101","/":"1010001",".":"1010100","+":"0010101",A:"0011010",B:"0101001",C:"0001011",D:"0001110"};Barcode.registerEncoder("Codabar",CodabarEncoder);export const CodabarClsNames={hostElement:"wj-barcode-codabar"};export const Code128ClsNames={hostElement:"wj-barcode-code128"};export const Code39ClsNames={hostElement:"wj-barcode-code39"};export const Ean13ClsNames={hostElement:"wj-barcode-ean13"};export const Ean8ClsNames={hostElement:"wj-barcode-ean8"};export const EanBaseClsNames={hostElement:"wj-barcode-ean"};export const Gs1_128ClsNames={hostElement:"wj-barcode-gs1_128"};export const QrCodeClsNames={hostElement:"wj-barcode-qrcode"};export const UpcAClsNames={hostElement:"wj-barcode-upca"};export const UpcBaseClsNames={hostElement:"wj-barcode-upc"};export const UpcE0ClsNames={hostElement:"wj-barcode-upce0"};export const UpcE1ClsNames={hostElement:"wj-barcode-upce1"};export var QrCodeCharset;!function(e){e[e.Utf8=0]="Utf8";e[e.ShiftJis=1]="ShiftJis"}(QrCodeCharset||(QrCodeCharset={}));export var QrCodeCorrectionLevel;!function(e){e[e.Low=0]="Low";e[e.Medium=1]="Medium";e[e.Quartile=2]="Quartile";e[e.High=3]="High"}(QrCodeCorrectionLevel||(QrCodeCorrectionLevel={}));export var QrCodeModel;!function(e){e[e.Model1=0]="Model1";e[e.Model2=1]="Model2"}(QrCodeModel||(QrCodeModel={}));export var Code128CodeSet;!function(e){e[e.Auto=0]="Auto";e[e.A=1]="A";e[e.B=2]="B";e[e.C=3]="C"}(Code128CodeSet||(Code128CodeSet={}));export class _QrCodeModelConvertor{static stringToEnum(e){switch(e.toString()){case"1":return QrCodeModel.Model1;case"2":return QrCodeModel.Model2}throw`Unknown QRCode internal model '${e}'`}static enumToString(e){var t=QrCodeModel[asEnum(e,QrCodeModel)];return t.charAt(t.length-1)}}export class _CharsetTypeConvertor{static stringToEnum(e){switch(e){case"UTF-8":return QrCodeCharset.Utf8;case"Shift_JIS":return QrCodeCharset.ShiftJis}throw`Unknown Barcode internal charset '${e}'`}static enumToString(e){let t;switch(asEnum(e,QrCodeCharset)){case QrCodeCharset.Utf8:t="UTF-8";break;case QrCodeCharset.ShiftJis:t="Shift_JIS"}return t}}export class _CorrectionLevelConvertor{static stringToEnum(e){switch(e){case"L":return QrCodeCorrectionLevel.Low;case"M":return QrCodeCorrectionLevel.Medium;case"Q":return QrCodeCorrectionLevel.Quartile;case"H":return QrCodeCorrectionLevel.High}throw`Unknown barcode internal errorCorrectionLevel '${e}'`}static enumToString(e){return QrCodeCorrectionLevel[asEnum(e,QrCodeCorrectionLevel)].charAt(0)}}export class _CodeSetTypeConvertor{static stringToEnum(e){switch(e){case"auto":return Code128CodeSet.Auto;case"A":return Code128CodeSet.A;case"B":return Code128CodeSet.B;case"C":return Code128CodeSet.C}throw`Unknown barcode internal codeSet '${e}'`}static enumToString(e){let t,o=asEnum(e,Code128CodeSet);switch(o){case Code128CodeSet.Auto:t="auto";break;case Code128CodeSet.A:case Code128CodeSet.B:case Code128CodeSet.C:t=Code128CodeSet[o]}return t}}export class Codabar extends BarcodeBase{constructor(e,t){super(e);addClass(this.hostElement,CodabarClsNames.hostElement);this._setAw(!0);this.initialize(t)}static get controlTemplate(){Codabar._ctrlTemplate||(Codabar._ctrlTemplate=BarcodeBase.controlTemplate);return Codabar._ctrlTemplate}static set controlTemplate(e){Codabar._ctrlTemplate=e}get autoWidth(){return this._getAw()}set autoWidth(e){this._setAw(e)}get autoWidthZoom(){return this._getWzoom()}set autoWidthZoom(e){this._setWzoom(e)}get showLabel(){return this._getProp("showLabel")}set showLabel(e){this._setProp("showLabel",e)}get checkDigit(){return this._getProp("checkDigit")}set checkDigit(e){this._setProp("checkDigit",e)}get labelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("labelPosition"))}set labelPosition(e){this._setProp("labelPosition",_LabelPositionConvertor.enumToString(e))}get nwRatio(){return _NarrowWideRatioConvertor.stringToEnum(this._getProp("nwRatio"))}set nwRatio(e){this._setProp("nwRatio",_NarrowWideRatioConvertor.enumToString(e))}}Codabar.type="Codabar";Codabar._ctrlTemplate="";export class EanBase extends BarcodeBase{constructor(e,t){super(e,t);addClass(this.hostElement,EanBaseClsNames.hostElement)}get showLabel(){return this._getProp("showLabel")}set showLabel(e){this._setProp("showLabel",e)}get labelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("labelPosition"))}set labelPosition(e){this._setProp("labelPosition",_LabelPositionConvertor.enumToString(e))}}export class Ean8 extends EanBase{constructor(e,t){super(e,t);addClass(this.hostElement,Ean8ClsNames.hostElement)}}Ean8.type="EAN8";export class Ean13 extends EanBase{constructor(e,t){super(e,t);addClass(this.hostElement,Ean13ClsNames.hostElement)}get addOn(){return this._getProp("addOn")}set addOn(e){this._setProp("addOn",e)}get addOnHeight(){return this._getProp("addOnHeight")}set addOnHeight(e){this._setProp("addOnHeight",e)}get addOnLabelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("addOnLabelPosition"))}set addOnLabelPosition(e){this._setProp("addOnLabelPosition",_LabelPositionConvertor.enumToString(e))}get quietZone(){return this._getProp("quietZone")}set quietZone(e){this._setProp("quietZone",e)}}Ean13.type="EAN13";export class Code39 extends BarcodeBase{constructor(e,t){super(e);addClass(this.hostElement,Code39ClsNames.hostElement);this._setAw(!0);this.initialize(t)}static get controlTemplate(){Code39._ctrlTemplate||(Code39._ctrlTemplate=BarcodeBase.controlTemplate);return Code39._ctrlTemplate}static set controlTemplate(e){Code39._ctrlTemplate=e}get autoWidth(){return this._getAw()}set autoWidth(e){this._setAw(e)}get autoWidthZoom(){return this._getWzoom()}set autoWidthZoom(e){this._setWzoom(e)}get showLabel(){return this._getProp("showLabel")}set showLabel(e){this._setProp("showLabel",e)}get checkDigit(){return this._getProp("checkDigit")}set checkDigit(e){this._setProp("checkDigit",e)}get fullAscii(){return this._getProp("fullASCII")}set fullAscii(e){this._setProp("fullASCII",e)}get labelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("labelPosition"))}set labelPosition(e){this._setProp("labelPosition",_LabelPositionConvertor.enumToString(e))}get nwRatio(){return _NarrowWideRatioConvertor.stringToEnum(this._getProp("nwRatio"))}set nwRatio(e){this._setProp("nwRatio",_NarrowWideRatioConvertor.enumToString(e))}get labelWithStartAndStopCharacter(){return this._getProp("labelWithStartAndStopCharacter")}set labelWithStartAndStopCharacter(e){this._setProp("labelWithStartAndStopCharacter",e)}}Code39.type="Code39";Code39._ctrlTemplate="";export class Code128 extends BarcodeBase{constructor(e,t){super(e);addClass(this.hostElement,Code128ClsNames.hostElement);this._setAw(!0);this.initialize(t)}static get controlTemplate(){Code128._ctrlTemplate||(Code128._ctrlTemplate=BarcodeBase.controlTemplate);return Code128._ctrlTemplate}static set controlTemplate(e){Code128._ctrlTemplate=e}get autoWidth(){return this._getAw()}set autoWidth(e){this._setAw(e)}get autoWidthZoom(){return this._getWzoom()}set autoWidthZoom(e){this._setWzoom(e)}get showLabel(){return this._getProp("showLabel")}set showLabel(e){this._setProp("showLabel",e)}get codeSet(){return _CodeSetTypeConvertor.stringToEnum(this._getProp("codeSet"))}set codeSet(e){this._setProp("codeSet",_CodeSetTypeConvertor.enumToString(e))}get labelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("labelPosition"))}set labelPosition(e){this._setProp("labelPosition",_LabelPositionConvertor.enumToString(e))}}Code128.type="Code128";Code128._ctrlTemplate="";export class Gs1_128 extends BarcodeBase{constructor(e,t){super(e);addClass(this.hostElement,Gs1_128ClsNames.hostElement);this._setAw(!0);this.initialize(t)}static get controlTemplate(){Gs1_128._ctrlTemplate||(Gs1_128._ctrlTemplate=BarcodeBase.controlTemplate);return Gs1_128._ctrlTemplate}static set controlTemplate(e){Gs1_128._ctrlTemplate=e}get autoWidth(){return this._getAw()}set autoWidth(e){this._setAw(e)}get autoWidthZoom(){return this._getWzoom()}set autoWidthZoom(e){this._setWzoom(e)}get showLabel(){return this._getProp("showLabel")}set showLabel(e){this._setProp("showLabel",e)}get labelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("labelPosition"))}set labelPosition(e){this._setProp("labelPosition",_LabelPositionConvertor.enumToString(e))}}Gs1_128.type="GS1_128";Gs1_128._ctrlTemplate="";export class UpcBase extends BarcodeBase{constructor(e,t){super(e,t);addClass(this.hostElement,UpcBaseClsNames.hostElement)}static get controlTemplate(){UpcBase._ctrlTemplate||(UpcBase._ctrlTemplate=BarcodeBase.controlTemplate);return UpcBase._ctrlTemplate}static set controlTemplate(e){UpcBase._ctrlTemplate=e}get showLabel(){return this._getProp("showLabel")}set showLabel(e){this._setProp("showLabel",e)}get addOn(){return this._getProp("addOn")}set addOn(e){this._setProp("addOn",e)}get labelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("labelPosition"))}set labelPosition(e){this._setProp("labelPosition",_LabelPositionConvertor.enumToString(e))}get addOnHeight(){return this._getProp("addOnHeight")}set addOnHeight(e){this._setProp("addOnHeight",e)}get addOnLabelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("addOnLabelPosition"))}set addOnLabelPosition(e){this._setProp("addOnLabelPosition",_LabelPositionConvertor.enumToString(e))}get quietZone(){return this._getProp("quietZone")}set quietZone(e){this._setProp("quietZone",e)}}UpcBase._ctrlTemplate="";export class UpcA extends UpcBase{constructor(e,t){super(e,t);addClass(this.hostElement,UpcAClsNames.hostElement)}}UpcA.type="UPC-A";export class UpcE0 extends UpcBase{constructor(e,t){super(e,t);addClass(this.hostElement,UpcE0ClsNames.hostElement)}}UpcE0.type="UPC-E0";export class UpcE1 extends UpcBase{constructor(e,t){super(e,t);addClass(this.hostElement,UpcE1ClsNames.hostElement)}}UpcE1.type="UPC-E1";export class QrCode extends BarcodeBase{constructor(e,t){super(e,t);addClass(this.hostElement,QrCodeClsNames.hostElement)}get charCode(){return this._getProp("charCode")}set charCode(e){this._setProp("charCode",e)}get charset(){return _CharsetTypeConvertor.stringToEnum(this._getProp("charset"))}set charset(e){this._setProp("charset",_CharsetTypeConvertor.enumToString(e))}get model(){return _QrCodeModelConvertor.stringToEnum(this._getProp("model"))}set model(e){this._setProp("model",_QrCodeModelConvertor.enumToString(e))}get version(){let e=this._getProp("version");return"auto"===e?null:e}set version(e){this._setProp("version",null==e?"auto":e)}get errorCorrectionLevel(){return _CorrectionLevelConvertor.stringToEnum(this._getProp("errorCorrectionLevel"))}set errorCorrectionLevel(e){this._setProp("errorCorrectionLevel",_CorrectionLevelConvertor.enumToString(e))}get mask(){let e=this._getProp("mask");return"auto"===e?null:e}set mask(e){this._setProp("mask",null==e?"auto":e)}get connection(){return this._getProp("connection")}set connection(e){this._setProp("connection",e)}get connectionIndex(){return this._getProp("connectionNo")}set connectionIndex(e){this._setProp("connectionNo",e)}}QrCode.type="QRCode";_registerModule("wijmo.barcode.common",selfModule);
14
+ import{asEnum,addClass,_registerModule}from"@mescius/wijmo";import{OneDimensionalBarcode,Utils,InvalidTextException,InvalidOptionsException,Barcode,InvalidCharacterException,Constants,TextTooLongException,BitBuffer,TwoDimensionalBarcode,BarcodeBase,_LabelPositionConvertor,_NarrowWideRatioConvertor}from"@mescius/wijmo.barcode";import*as selfModule from"@mescius/wijmo.barcode.common";const EXP_TABLE=new Array(256);for(let e=0;e<8;e++)EXP_TABLE[e]=1<<e;for(let e=8;e<256;e++)EXP_TABLE[e]=EXP_TABLE[e-4]^EXP_TABLE[e-5]^EXP_TABLE[e-6]^EXP_TABLE[e-8];const LOG_TABLE=new Array(256);for(let e=0;e<255;e+=1)LOG_TABLE[EXP_TABLE[e]]=e;const RS_COEFFICIENTS=[null,null,null,null,null,null,null,[0,87,229,146,149,238,102,21],null,null,[0,251,67,46,61,118,70,64,94,32,45],null,null,[0,74,152,176,100,86,100,106,104,130,218,206,140,78],null,[0,8,183,61,91,202,37,51,58,58,237,140,124,5,99,105],[0,120,104,107,109,102,161,76,3,91,191,147,169,182,194,225,120],[0,43,139,206,78,43,239,123,206,214,147,24,99,150,39,243,163,136],[0,215,234,158,94,184,97,118,170,79,187,152,148,252,179,5,98,96,153],null,[0,17,60,79,50,61,163,26,187,202,180,221,225,83,239,156,164,212,212,188,190],null,[0,210,171,247,242,93,230,14,109,221,53,200,74,8,172,98,80,219,134,160,105,165,231],null,[0,229,121,135,48,211,117,251,126,159,180,169,152,192,226,228,218,111,0,117,232,87,96,227,21],null,[0,173,125,158,2,103,182,118,17,145,201,111,28,165,53,161,21,245,142,13,102,48,227,153,145,218,70],null,[0,168,223,200,104,224,234,108,180,110,190,195,147,205,27,232,201,21,43,245,87,42,195,212,119,242,37,9,123],null,[0,41,173,145,152,216,31,179,182,50,48,110,86,239,96,222,125,42,173,226,193,224,130,156,37,251,216,238,40,192,180],null,[0,10,6,106,190,249,167,4,67,209,138,138,32,242,123,89,27,120,185,80,156,38,69,171,60,28,222,80,52,254,185,220,241],null,[0,111,77,146,94,26,21,108,19,105,94,113,193,86,140,163,125,58,158,229,239,218,103,56,70,114,61,183,129,167,13,98,62,129,51],null,[0,200,183,98,16,172,31,246,234,60,152,115,0,167,152,113,248,238,107,18,63,218,37,87,210,105,177,120,74,121,196,117,251,113,233,30,120],null,null,null,[0,59,116,79,161,252,98,128,205,128,161,247,57,163,56,235,106,53,26,187,174,226,104,170,7,175,35,181,114,88,41,47,163,125,134,72,20,232,53,35,15],null,[0,250,103,221,230,25,18,137,231,0,3,58,242,221,191,110,84,230,8,188,106,96,147,15,131,139,34,101,223,39,101,213,199,237,254,201,123,171,162,194,117,50,96],null,[0,190,7,61,121,71,246,69,55,168,188,89,243,191,25,72,123,9,145,14,247,1,238,44,78,143,62,224,126,118,114,68,163,52,194,217,147,204,169,37,130,113,102,73,181],null,[0,112,94,88,112,253,224,202,115,187,99,89,5,54,113,129,44,58,16,135,216,169,211,36,1,4,96,60,241,73,104,234,8,249,245,119,174,52,25,157,224,43,202,223,19,82,15],null,[0,228,25,196,130,211,146,60,24,251,90,39,102,240,61,178,63,46,123,115,18,221,111,135,160,182,205,107,206,95,150,120,184,91,21,247,156,140,238,191,11,94,227,84,50,163,39,34,108],null,[0,232,125,157,161,164,9,118,46,209,99,203,193,35,3,209,111,195,242,203,225,46,13,32,160,126,209,130,160,242,215,242,75,77,42,189,32,113,65,124,69,228,114,235,175,124,170,215,232,133,205],null,[0,116,50,86,186,50,220,251,89,192,46,86,127,124,19,184,233,151,215,22,14,59,145,37,242,203,134,254,89,190,94,59,65,124,113,100,233,235,121,22,76,86,97,39,242,200,220,101,33,239,254,116,51],null,[0,183,26,201,87,210,221,113,21,46,65,45,50,238,184,249,225,102,58,209,218,109,165,26,95,184,192,52,245,35,254,238,175,172,79,123,25,122,43,120,108,215,80,128,201,235,8,153,59,101,31,198,76,31,156],null,[0,106,120,107,157,164,216,112,116,2,91,248,163,36,201,202,229,6,144,254,155,135,208,170,209,12,139,127,142,182,249,177,174,190,28,10,85,239,184,101,124,152,206,96,23,163,61,27,196,247,151,154,202,207,20,61,10],null,[0,82,116,26,247,66,27,62,107,252,182,200,185,235,55,251,242,210,144,154,237,176,141,192,248,152,249,206,85,253,142,65,165,125,23,24,30,122,240,214,6,129,218,29,145,127,134,206,245,117,29,41,63,159,142,233,125,148,123],null,[0,107,140,26,12,9,141,243,197,226,197,219,45,211,101,219,120,28,181,127,6,100,247,2,205,198,57,115,219,101,109,160,82,37,38,238,49,160,209,121,86,11,124,30,181,84,25,194,87,65,102,190,220,70,27,209,16,89,7,33,240],null,[0,65,202,113,98,71,223,248,118,214,94,1,122,37,23,2,228,58,121,7,105,135,78,243,118,70,76,223,89,72,50,70,111,194,17,212,126,181,35,221,117,235,11,229,149,147,123,213,40,115,6,200,100,26,246,182,218,127,215,36,186,110,106],null,[0,45,51,175,9,7,158,159,49,68,119,92,123,177,204,187,254,200,78,141,149,119,26,127,53,160,93,199,212,29,24,145,156,208,150,218,209,4,216,91,47,184,146,47,140,195,195,125,242,238,63,99,108,140,230,242,31,204,11,178,243,217,156,213,231],null,[0,5,118,222,180,136,136,162,51,46,117,13,215,81,17,139,247,197,171,95,173,65,137,178,68,111,95,101,41,72,214,169,197,95,7,44,154,77,111,236,40,121,143,63,87,80,253,240,126,217,77,34,232,106,50,168,82,76,146,67,106,171,25,132,93,45,105],null,[0,247,159,223,33,224,93,77,70,90,160,32,254,43,150,84,101,190,205,133,52,60,202,165,220,203,151,93,84,15,84,253,173,160,89,227,52,199,97,95,231,52,177,41,125,137,241,166,225,118,2,54,32,82,215,175,198,43,238,235,27,101,184,127,3,5,8,163,238],null];export function generateErrorCorrectionCode(e,t,o){const r=[],n=RS_COEFFICIENTS[t],s=e.slice(0);for(let e=0;e<o;e++){if(0!=s[0]){const e=LOG_TABLE[s[0]];for(let t=0;t<=n.length-1;t++){let o=n[t]+e;for(;o>=255;)o-=255;r[t]=EXP_TABLE[o]}for(let e=0;e<=n.length-1;e++)s[e]=s[e]^r[e]}for(let e=1;e<s.length;e++)s[e-1]=s[e];s[s.length-1]=0}return s.slice(0,t)}const G15=1335,G18=7973,MODEL2_G15_MASK=21522,MODEL1_G15_MASK=10277;function getBCHDigit(e){let t=0;for(;0!=e;){t+=1;e>>>=1}return t}export function getBCH15(e,t){const o=2===t?21522:10277;let r=e<<10;for(;getBCHDigit(r)-getBCHDigit(G15)>=0;)r^=G15<<getBCHDigit(r)-getBCHDigit(G15);return(e<<10|r)^o}export function getBCH18(e){let t=e<<12;for(;getBCHDigit(t)-getBCHDigit(G18)>=0;)t^=G18<<getBCHDigit(t)-getBCHDigit(G18);return e<<12|t}export const MODE_INDICATOR={ECI:7,Numeric:1,Alphanumeric:2,"8BitByte":4,Kanji:8,StructuredAppend:3,FNC1First:5,FNC2Second:9,Terminator:0};export const EC_INDICATOR={L:1,M:0,Q:3,H:2};function isNumericMode(e){return e>=48&&e<=57}function isAlphanumericMode(e){return-1!=" $%*+-./:".indexOf(String.fromCharCode(e))||(e>=48&&e<=57||e>=65&&e<=90)}function is8BitByteMode(e){return e>=0&&e<=255}function isKanjiMode(e){return e>=33087&&e<=64587}const checkFns={Numeric:isNumericMode,Alphanumeric:isAlphanumericMode,"8BitByte":is8BitByteMode,Kanji:isKanjiMode};export function isMode(e,t){const o=checkFns[e];return 1===t.length?o(t):t.every(e=>o(e))}export function getCharMode(e,t="UTF-8"){return isNumericMode(e)?"Numeric":isAlphanumericMode(e)?"Alphanumeric":"Shift_JIS"===t&&isKanjiMode(e)?"Kanji":"8BitByte"}export const getSizeByVersion=e=>4*e+17;export function getCharacterCountIndicatorbitsNumber(e){return e>=1&&e<=9?{Numeric:10,Alphanumeric:9,"8BitByte":8,Kanji:8}:e>=10&&e<=26?{Numeric:12,Alphanumeric:11,"8BitByte":16,Kanji:10}:{Numeric:14,Alphanumeric:13,"8BitByte":16,Kanji:12}}const SYMBOL_MAP={" ":36,$:37,"%":38,"*":39,"+":40,"-":41,".":42,"/":43,":":44};export function getAlphanumericCharValue(e){if(e>=48&&e<=57)return+String.fromCharCode(e);if(e>=65&&e<=90)return e-65+10;const t=SYMBOL_MAP[String.fromCharCode(e)];if(t)return t;throw new InvalidTextException(String.fromCharCode(e))}export function createModules(e){const t=[];for(let o=0;o<e;o++)t.push(Utils.fillArray(new Array(e),null));return t}const alignmentPatterns=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]];export function getAlignmentPattersPos(e){return alignmentPatterns[e-1]}export const padCodewords0=236;export const padCodewords1=17;export const maskFuncs=[(e,t)=>(e+t)%2==0,e=>e%2==0,(e,t)=>t%3==0,(e,t)=>(e+t)%3==0,(e,t)=>(Math.floor(e/2)+Math.floor(t/3))%2==0,(e,t)=>e*t%2+e*t%3==0,(e,t)=>(e*t%2+e*t%3)%2==0,(e,t)=>(e*t%3+(e+t)%2)%2==0];const MODEL2_1ERROR_CORRECTION_CHARACTERISTICS=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],MODEL1_ERROR_CORRECTION_CHARACTERISTICS=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,46,36],[1,46,30],[1,46,24],[1,46,16],[1,72,57],[1,72,44],[1,72,36],[1,72,24],[1,100,80],[1,100,60],[1,100,50],[1,100,34],[1,134,108],[1,134,82],[1,134,68],[2,67,23],[1,170,136],[2,85,53],[2,85,43],[2,85,29],[1,212,170],[2,106,66],[2,106,54],[3,70,24],[2,128,104],[2,128,80],[2,128,64],[3,85,29],[2,153,123],[2,153,93],[3,102,52],[3,102,34],[2,179,145],[2,179,111],[3,119,61],[4,89,31],[2,208,168],[4,104,64],[4,104,52],[5,83,29],[2,238,192],[4,119,73],[4,119,61],[5,95,33],[3,180,144],[4,135,83],[4,135,69],[6,90,32],[3,203,163],[4,152,92],[5,122,62],[6,101,35]];export function getErrorCorrectionCharacteristics(e,t,o=2){let r;switch(t){case 1:r=0;break;case 0:r=1;break;case 3:r=2;break;case 2:r=3}const n=(2===o?MODEL2_1ERROR_CORRECTION_CHARACTERISTICS:MODEL1_ERROR_CORRECTION_CHARACTERISTICS)[4*(e-1)+r],s=[],i=n.length/3;for(let e=0;e<i;e++){const t=n[3*e];for(let o=0;o<t;o++)s.push({total:n[3*e+1],data:n[3*e+2],ec:n[3*e+1]-n[3*e+2]})}return s}export function getMaskFunc(e){return maskFuncs[e]}function cloneModules(e){return e.reduce((e,t)=>{e.push(t.slice(0));return e},[])}export function getMaskScore(e){const t=e.length;let o=0;for(let r=0;r<t;r++)for(let n=0;n<t;n++){let s=0;const i=e[r][n];for(let o=-1;o<=1;o++)if(!(r+o<0||t<=r+o))for(let a=-1;a<=1;a++)n+a<0||t<=n+a||0==o&&0==a||i==e[r+o][n+a]&&(s+=1);s>5&&(o+=3+s-5)}for(let r=0;r<t-1;r++)for(let n=0;n<t-1;n++){let t=0;e[r][n]&&(t+=1);e[r+1][n]&&(t+=1);e[r][n+1]&&(t+=1);e[r+1][n+1]&&(t+=1);0!=t&&4!=t||(o+=3)}for(let r=0;r<t;r++)for(let n=0;n<t-6;n++)e[r][n]&&!e[r][n+1]&&e[r][n+2]&&e[r][n+3]&&e[r][n+4]&&!e[r][n+5]&&e[r][n+6]&&(o+=40);for(let r=0;r<t;r++)for(let n=0;n<t-6;n++)e[n][r]&&!e[n+1][r]&&e[n+2][r]&&e[n+3][r]&&e[n+4][r]&&!e[n+5][r]&&e[n+6][r]&&(o+=40);let r=0;for(let o=0;o<t;o++)for(let n=0;n<t;n++)e[n][o]&&(r+=1);o+=10*(Math.abs(100*r/t/t-50)/5);return o}export function addFormatInformation(e,t,o,r){const n=e.length,s=cloneModules(e),i=Utils.strPadStart(Utils.convertRadix(o,2),2,0),a=Utils.strPadStart(Utils.convertRadix(t,2),3,0),c=getBCH15(parseInt(i+a,2),r);s[n-8][8]=1;for(let e=15;e>0;e--){const t=c>>e-1&1;if(e>9){s[8][15-e]=t;s[n-1-15+e][8]=t}else if(e>8){s[8][15-e+1]=t;s[n-1-15+e][8]=t}else if(e>6){s[e][8]=t;s[8][n-e]=t}else{s[e-1][8]=t;s[8][n-e]=t}}return s}export function getEstimatedVersion(e,t,o){let r=0,n=0,s=0,i=0;t.forEach(e=>{isNumericMode(e)?r++:isAlphanumericMode(e)?n++:isKanjiMode(e)?i++:is8BitByteMode(e)&&s++});const a=Math.ceil((5*n+3*r+13*i+8*s)/8);for(let t=1;t<=40;t++){if(a<=getErrorCorrectionCharacteristics(t,e,o).reduce((e,t)=>e+t.data,0))return t}throw new TextTooLongException}const MODE_CHECK_INFO={Alphanumeric:[[6,11],[7,15],[8,16]],Numeric:[[4,6,6,13],[4,7,8,15],[5,8,9,17]]};export function getModeCheckInfo(e,t){const o=MODE_CHECK_INFO[e];return t<=9?o[0]:t<=26?o[1]:o[2]}export function utf8Encode(e){const t=[];for(let o=0,r=e.length;o<r;o++){let r=e[o];if(r<128)t.push(r);else if(r<2048)t.push(192|r>>6,128|63&r);else if(r<55296||r>=57344)t.push(224|r>>12,128|r>>6&63,128|63&r);else{o++;r=65536+((1023&r)<<10|1023&e[o]);t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r)}}return t}export function getParityData(e){const t=utf8Encode(e);let o=t[0];for(let e=1,r=t.length;e<r;e++)o^=t[e];return o}export function getCharCode(e){const t=[];Utils.sliceString(e,1,e=>{t.push(e.charCodeAt(0))});return t}export class ModeKanji{constructor(e){this.mode="Kanji";this.data=e}getMode(){return MODE_INDICATOR.Kanji}getLength(){return this.data.length}write(e){this.data.forEach(t=>{let o;if(t>33088&&t<40956){o=192*((t-=33088)>>>8)+(255&t)}else if(t>57408&&t<60351){o=192*((t-=49472)>>>8)+(255&t)}e.put(o,13)})}}export class ModeAlphanumeric{constructor(e){this.mode="Alphanumeric";this.data=e}getMode(){return MODE_INDICATOR.Alphanumeric}getLength(){return this.data.length}write(e){Utils.sliceArray(this.data,2,t=>{const o=getAlphanumericCharValue(t[0]);if(2===t.length){const r=45*o+getAlphanumericCharValue(t[1]);e.put(r,11)}else e.put(o,6)})}}export class ModeNumeric{constructor(e){this.mode="Numeric";this.data=e}getMode(){return MODE_INDICATOR.Numeric}getLength(){return this.data.length}write(e){Utils.sliceArray(this.data,3,t=>{const o=parseInt(t.reduce((e,t)=>e+String.fromCharCode(t),""));switch(t.length){case 1:e.put(o,4);return;case 2:e.put(o,7);return;default:e.put(o,10);return}})}}export class Mode8BitByte{constructor(e){this.mode="8BitByte";this.data=e;this.bytes=utf8Encode(e)}getMode(){return MODE_INDICATOR["8BitByte"]}getLength(){return this.bytes.length}write(e){this.bytes.forEach(t=>{e.put(t,8)})}}export class QRCodeBase{constructor(e,t){let{version:o,model:r,charCode:n}=t;this.charCode=n||getCharCode(e);const s=EC_INDICATOR[t.errorCorrectionLevel];this.config=t;this.errorCorrectionLevel=s;this.model=+r;o="auto"===o?this.getAutoVersion():+o;this.version=o;this.modulesCount=getSizeByVersion(o);this.charCountIndicatorBitsNumber=getCharacterCountIndicatorbitsNumber(o);this.errorCorrectionCharacteristics=getErrorCorrectionCharacteristics(o,s,this.model);this.totalDataCount=this.errorCorrectionCharacteristics.reduce((e,t)=>e+t.data,0);this.totalDataBits=8*this.totalDataCount}getConnections(){const{totalDataBits:e,charCode:t}=this,o=e-20,r=t.length;let n=0,s=1;const i=[];let a=t[0];for(;s<=r;){const e=t.slice(n,s),c=this.analysisData(e);if(this.encodeData(c).length>o){i.push(a);n=s-1}else s===r&&i.push(e);a=e;s++}return i}processConnection(e){let{totalDataBits:t,config:{connection:o,connectionNo:r}}=this;r=+r;if(o){const o=Math.ceil(e.length/(t-20));if(r>o-1)throw new InvalidOptionsException({connectionNo:r},"Max connection number is "+(o-1));const n=this.getConnections()[r],s=this.analysisData(n);return this.encodeData(s,{connectionNo:r,connectionCnt:o})}if(e.length>t)throw new TextTooLongException;return e}padBuffer(e){const{totalDataBits:t}=this;e.length+4<=t&&e.put(MODE_INDICATOR.Terminator,4);for(;e.length%8!=0;)e.putBit(!1);for(;!(e.length>=t);){e.put(236,8);if(e.length>=t)break;e.put(17,8)}}getAutoVersion(){const{errorCorrectionLevel:e,charCode:t,model:o}=this;for(let r=getEstimatedVersion(e,t,o);r<40;r++){this.version=r;this.modulesCount=getSizeByVersion(this.version);this.charCountIndicatorBitsNumber=getCharacterCountIndicatorbitsNumber(this.version);this.errorCorrectionCharacteristics=getErrorCorrectionCharacteristics(this.version,e);this.totalDataCount=this.errorCorrectionCharacteristics.reduce((e,t)=>e+t.data,0);this.totalDataBits=8*this.totalDataCount;const o=this.analysisData(t);if(!(this.encodeData(o).length>this.totalDataBits))return r}throw new TextTooLongException}analysisData(e){const{version:t,config:{charset:o}}=this;let r=getCharMode(e[0],o);switch(r){case"Alphanumeric":{const o=getModeCheckInfo(r,t);isMode("8BitByte",e.slice(1,1+o[0]))&&(r="8BitByte");break}case"Numeric":{const o=getModeCheckInfo(r,t),n=e.slice(1,1+o[0]),s=e.slice(1,1+o[1]);isMode("8BitByte",n)?r="8BitByte":isMode("Alphanumeric",s)&&(r="Alphanumeric");break}}let n={mode:r,code:[]};const s=[n];e.forEach((r,i)=>{const a=getCharMode(r,o);if(n.mode===a)n.code.push(r);else if("8BitByte"===n.mode)if("Kanji"===a){n={mode:a,code:[r]};s.push(n)}else if("Numeric"===a){const o=getModeCheckInfo(a,t);if(isMode(a,e.slice(i,i+o[2]))){n={mode:a,code:[r]};s.push(n)}else n.code.push(r)}else if("Alphanumeric"===a){const o=getModeCheckInfo(a,t);if(isMode(a,e.slice(i,i+o[1]))){n={mode:a,code:[r]};s.push(n)}else n.code.push(r)}else n.code.push(r);else if("Alphanumeric"===n.mode)if("Kanji"===a||"8BitByte"===a){n={mode:a,code:[r]};s.push(n)}else if("Numeric"===a){const o=getModeCheckInfo(a,t);if(isMode(a,e.slice(i,i+o[2]))){n={mode:a,code:[r]};s.push(n)}else n.code.push(r)}else n.code.push(r);else{n={mode:a,code:[r]};s.push(n)}});return s}generateErrorCorrectionCode(e){const{errorCorrectionCharacteristics:t}=this,o=[];let r=0;t.forEach(t=>{const n=e.getBuffer().slice(r,r+t.data);o.push({data:n,ec:generateErrorCorrectionCode(n,t.ec,t.data)});r+=t.data});return o}addRectModule(e,t,o,r,n=!1){const{modules:s}=this,i=r+t,a=o+e;for(;t<i;t++){let o=e;for(;o<a;o++)s[t][o]=+n}}addPositionDetectionPattern(){const{modules:e}=this,t=e.length;this.addPattern(0,0,7);this.addRectModule(7,0,1,8,!1);this.addRectModule(0,7,8,1,!1);const o=t-7;this.addPattern(o,0,7);this.addRectModule(o-1,0,1,8,!1);this.addRectModule(o-1,7,8,1,!1);const r=t-7;this.addPattern(0,r,7);this.addRectModule(7,r-1,1,8,!1);this.addRectModule(0,r-1,8,1,!1)}addTimingPattern(){const{modules:e}=this,t=e.length;let o=!0;for(let r=8;r<t-7;r++){e[6][r]=+o;e[r][6]=+o;o=!o}}addPattern(e,t,o){this.addRectModule(e,t,o,o,!0);this.addRectModule(e+1,t+1,o-2,o-2,!1);this.addRectModule(e+2,t+2,o-4,o-4,!0)}}export class QRCodeModel2 extends QRCodeBase{encodeData(e,t){const{charCountIndicatorBitsNumber:o,charCode:r}=this,n=new BitBuffer;if(t){n.put(MODE_INDICATOR.StructuredAppend,4);n.put(t.connectionNo,4);n.put(t.connectionCnt-1,4);n.put(getParityData(r),8)}e.forEach(e=>{if(!e.code)return;let t;switch(e.mode){case"Numeric":t=new ModeNumeric(e.code);break;case"Alphanumeric":t=new ModeAlphanumeric(e.code);break;case"8BitByte":t=new Mode8BitByte(e.code);break;case"Kanji":t=new ModeKanji(e.code)}n.put(t.getMode(),4);n.put(t.getLength(),o[t.mode]);t.write(n)});return n}getFinalMessage(e){const t=[],o=e.map(e=>e.data),r=e.map(e=>e.ec),n=Utils.getMaxValue(o),s=Utils.getMaxValue(r);for(let e=0;e<n;e++)o.forEach(o=>{Utils.isDefined(o[e])&&t.push(o[e])});for(let e=0;e<s;e++)r.forEach(o=>{Utils.isDefined(o[e])&&t.push(o[e])});return t}setModules(e){const{modulesCount:t,version:o}=this;this.modules=createModules(t);this.addPositionDetectionPattern();this.addAlignmentPattern();this.addTimingPattern();o>6&&this.addVersionInformation();this.maskModules(e)}maskModules(e){const{modules:t,errorCorrectionLevel:o,model:r,config:{mask:n}}=this;if("auto"===n)this.autoMask(e);else{const s=getMaskFunc(n);this.maskPattern=n;const i=addFormatInformation(t,n,o,r);this.modules=this.fillDataModules(i,e,s)}}autoMask(e){const{modules:t,errorCorrectionLevel:o,model:r}=this;let n,s,i;maskFuncs.forEach((a,c)=>{const l=addFormatInformation(t,c,o,r),d=this.fillDataModules(l,e,a),h=getMaskScore(d);if(!s||h<s){n=d;s=h;i=c}});this.modules=n;this.maskPattern=i}addAlignmentPattern(){const{modules:e,version:t}=this,o=getAlignmentPattersPos(t);o.forEach(t=>{o.forEach(o=>{null===e[t][o]&&this.addPattern(o-2,t-2,5)})})}addVersionInformation(){const{modulesCount:e,modules:t,version:o}=this,r=getBCH18(o);for(let o=0;o<18;o++){const n=r>>o&1;t[Math.floor(o/3)][o%3+e-8-3]=n;t[o%3+e-8-3][Math.floor(o/3)]=n}}fillDataModules(e,t,o){const r=e.length;let n=-1,s=r-1,i=7,a=0;for(let c=r-1;c>0;c-=2){6==c&&(c-=1);for(;;){for(let r=0;r<2;r+=1)if(null==e[s][c-r]){let n=!1;a<t.length&&(n=1==(t[a]>>>i&1));o(s,c-r)&&(n=!n);e[s][c-r]=+n;i-=1;if(-1==i){a+=1;i=7}}s+=n;if(s<0||r<=s){s-=n;n=-n;break}}}return e}getMatrix(){const{charCode:e}=this,t=this.analysisData(e),o=this.encodeData(t),r=this.processConnection(o);this.padBuffer(r);const n=this.generateErrorCorrectionCode(r),s=this.getFinalMessage(n);this.setModules(s);return this.modules}}export class QRCodeModel1 extends QRCodeBase{encodeData(e,t){const{charCountIndicatorBitsNumber:o,charCode:r}=this,n=new BitBuffer;n.put(0,4);if(t){n.put(MODE_INDICATOR.StructuredAppend,4);n.put(t.connectionNo,4);n.put(t.connectionCnt-1,4);n.put(getParityData(r),8)}e.forEach(e=>{if(!e.code)return;let t;switch(e.mode){case"Numeric":t=new ModeNumeric(e.code);break;case"Alphanumeric":t=new ModeAlphanumeric(e.code);break;case"8BitByte":t=new Mode8BitByte(e.code);break;case"Kanji":t=new ModeKanji(e.code)}n.put(t.getMode(),4);n.put(t.getLength(),o[t.mode]);t.write(n)});return n}getFinalMessage(e){let t=[];const o=e.map(e=>e.data),r=e.map(e=>e.ec);o.forEach(e=>{t=t.concat(e)});r.forEach(e=>{t=t.concat(e)});return t}setModules(e){const{modulesCount:t}=this;this.modules=createModules(t);this.addPositionDetectionPattern();this.addExtensionPattern();this.addTimingPattern();this.maskModules(e)}maskModules(e){const{modules:t,errorCorrectionLevel:o,model:r,config:{mask:n}}=this;if("auto"===n)this.autoMask(e);else{const s=getMaskFunc(n);this.maskPattern=n;const i=addFormatInformation(t,n,o,r);this.modules=this.fillDataModules(i,e,s)}}autoMask(e){const{modules:t,errorCorrectionLevel:o,model:r}=this;let n,s,i;maskFuncs.forEach((a,c)=>{const l=addFormatInformation(t,c,o,r),d=this.fillDataModules(l,e,a),h=getMaskScore(d);if(!s||h<s){n=d;s=h;i=c}});this.modules=n;this.maskPattern=i}addExtensionPattern(){const{modules:e,version:t}=this,o=e.length;e[o-1][o-1]=1;e[o-2][o-1]=0;e[o-1][o-2]=0;e[o-2][o-2]=0;const r=Math.floor(t/2);if(Utils.isEven(t))for(let e=0;e<r;e++){this.addBaseExtension(13+8*e);this.addRightExtension(13+8*e)}else for(let e=0;e<r;e++){this.addBaseExtension(17+8*e);this.addRightExtension(17+8*e)}}addBaseExtension(e){const{modules:t}=this,o=t.length,r=o-2,n=o-1;t[r][e]=0;t[r][e+1]=0;t[r][e+2]=0;t[r][e+3]=0;t[n][e]=1;t[n][e+1]=1;t[n][e+2]=1;t[n][e+3]=1}addRightExtension(e){const{modules:t}=this,o=t.length,r=o-2,n=o-1;t[e][r]=0;t[e+1][r]=0;t[e+2][r]=0;t[e+3][r]=0;t[e][n]=1;t[e+1][n]=1;t[e+2][n]=1;t[e+3][n]=1}fillDataModules(e,t,o){const r=e.length;let n,s;n=s=r-1;let i=2;const a=new BitBuffer(t);a.next();a.next();a.next();a.next();for(;n>=0;){if(n==r-5)i=4;else if(8==n)i=2;else if(6==n){n--;continue}for(;s>=0;)if(null===e[s][n]){for(let t=0;t<i;t++){let r=a.next();o(s,n-t)&&(r=!r);e[s][n-t]=+r}s--}else s--;n-=i;s=r-1}return e}getMatrix(){const{charCode:e}=this,t=this.analysisData(e),o=this.encodeData(t),r=this.processConnection(o);this.padBuffer(r);const n=this.generateErrorCorrectionCode(r),s=this.getFinalMessage(n);this.setModules(s);return this.modules}}export class QRCodeEncoder extends TwoDimensionalBarcode{constructor(e){e.merge(QRCodeEncoder.DefaultConfig);super(e);const{encodeConfig:{text:t},config:o}=this;let r;r="2"==o.model?new QRCodeModel2(t,o):new QRCodeModel1(t,o);this.innerQRCode=r}calculateData(){return this.innerQRCode.getMatrix()}validate(){const{version:e,model:t,charset:o,charCode:r,connectionNo:n}=this.config,{text:s}=this.encodeConfig;if(!(s||r&&0!==r.length))throw new InvalidTextException(s);if("1"!=t&&"2"!=t)throw new InvalidOptionsException({model:t});if("UTF-8"!=o&&"Shift_JIS"!=o)throw new InvalidOptionsException({charset:o});if("1"==t&&Utils.isNumberLike(e)&&(e<1||e>14))throw new InvalidOptionsException({version:e},"Model 1 only support version 1 - 14.");if("2"==t&&Utils.isNumberLike(e)&&(e<1||e>40))throw new InvalidOptionsException({version:e},"Model 2 only support version 1 - 40.");if(n>15||n<0)throw new InvalidOptionsException({connectionNo:n},"ConnectionNo is in range 0 - 15.")}}QRCodeEncoder.DefaultConfig={version:"auto",errorCorrectionLevel:"L",model:2,mask:"auto",connection:!1,connectionNo:0,charCode:void 0,charset:"UTF-8",quietZone:{top:4,left:4,right:4,bottom:4}};Barcode.registerEncoder("QRCode",QRCodeEncoder);const TableCode128A=[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","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","[","\\","]","^","_","\0","","","","","","","","\b","\t","\n","\v","\f","\r","","","","","","","","","","","","","","","","","",""," "," "," "," "," "," "," "," "," "," "],TableCode128B=[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","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","[","\\","]","^","_","`","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","{","|","}","~",""," "," "," "," "," "," "," "," "," "," "],TableCode128Data=["212222","222122","222221","121223","121322","131222","122213","122312","132212","221213","221312","231212","112232","122132","122231","113222","123122","123221","223211","221132","221231","213212","223112","312131","311222","321122","321221","312212","322112","322211","212123","212321","232121","111323","131123","131321","112313","132113","132311","211313","231113","231311","112133","112331","132131","113123","113321","133121","313121","211331","231131","213113","213311","213131","311123","311321","331121","312113","312311","332111","314111","221411","431111","111224","111422","121124","121421","141122","141221","112214","112412","122114","122411","142112","142211","241211","221114","413111","241112","134111","111242","121142","121241","114212","124112","124211","411212","421112","421211","212141","214121","412121","111143","111341","131141","114113","114311","411113","411311","113141","114131","311141","411131","211412","211214","211232"];export const stopPattern="2331112";export const Code128Sym={CodeC:99,CodeB:100,CodeA:101,FNC1:102,FNC2:97,FNC3:96,StartA:103,StartB:104,StartC:105};export const Code128Char={CodeC:String.fromCharCode(204),CodeB:String.fromCharCode(205),CodeA:String.fromCharCode(206),FNC1:Constants.FNC1,FNC2:Constants.FNC2,FNC3:Constants.FNC3,StartA:String.fromCharCode(208),StartB:String.fromCharCode(209),StartC:String.fromCharCode(210)};export function getCharValue(e,t){if(e===Code128Char.FNC1)return Code128Sym.FNC1;if(e===Code128Char.FNC2)return Code128Sym.FNC2;if(e===Code128Char.FNC3)return Code128Sym.FNC3;let o;switch(t){case"A":o=TableCode128A.indexOf(e);return o;case"B":o=TableCode128B.indexOf(e);return o;case"C":return+e}}export function getCharPattern(e,t){const o=TableCode128Data[getCharValue(e,t)];if(!o)throw new InvalidCharacterException(e);return o}export function getPatternByIndex(e){return TableCode128Data[e]}export function encode(e){let t="";Utils.str2Array(e).forEach((e,o)=>{Utils.isEven(o)?t+=Utils.strRepeat("1",+e):t+=Utils.strRepeat("0",+e)});return t}const CODE_SET_A="A",CODE_SET_B="B",CODE_SET_C="C";export class Code128Auto{constructor(e,t=!1){this.text=e;this.isUccEan128=t;this.validate()}validate(){const{text:e}=this;if(!/^[\x00-\x7F\xC8-\xD3]+$/.test(e))throw new InvalidTextException(e)}calculateGroup(){const{text:e,isUccEan128:t}=this;let o={code:t?"C":"B",text:""},r=[];r.push(o);for(let t=0,n=e.length;t<n;t++){let s=o.code,i=e[t];if("C"!==o.code&&t+3<n&&Utils.isNumberString(e.substr(t,4))||"C"===o.code&&t+1<n&&Utils.isNumberString(e.substr(t,2))){s="C";i+=e[++t]}else{s="C"===o.code?"B":o.code;if(getCharValue(i,s)<0){s="A"===o.code?"B":"A";if(getCharValue(i,s)<0)continue}}if(o.code!==s){o={code:s,text:i};r.push(o)}else o.text+=i}return r.filter(e=>e.text)}getData(){const e=this.calculateGroup(),t=this.checksum(e);let o="";e.forEach((e,t)=>{if(0===t){const t=getPatternByIndex(Code128Sym["Start"+e.code]);o+=encode(t)}else{const t=getPatternByIndex(Code128Sym["Code"+e.code]);o+=encode(t)}"C"===e.code?Utils.sliceString(e.text,2,t=>{o+=encode(getCharPattern(t,e.code))}):Utils.sliceString(e.text,1,t=>{o+=encode(getCharPattern(t,e.code))})});o+=encode(getPatternByIndex(t));o+=encode("2331112");return o}checksum(e){let t=0,o=0;e.forEach((e,r)=>{const{code:n,text:s}=e;if(0===r)o+=Code128Sym["Start"+n];else{o+=Code128Sym["Code"+n]*++t}"C"===n?Utils.sliceString(s,2,e=>{o+=getCharValue(e,n)*++t}):Utils.sliceString(s,1,e=>{o+=getCharValue(e,n)*++t})});return o%103}}export class Code128C{constructor(e){this.text=e;this.validate()}validate(){const{text:e}=this;if(!/^(\xCF*[0-9]{2}\xCF*)+$/.test(e))throw new InvalidTextException(e)}getData(){const{text:e}=this,t=this.checksum();let o="";const r=getPatternByIndex(Code128Sym.StartC);o+=encode(r);Utils.sliceString(e,2,e=>{const t=getCharPattern(e,"C");o+=encode(t)});o+=encode(getPatternByIndex(t));o+=encode("2331112");return o}checksum(){const{text:e}=this;let t=0,o=0;Utils.sliceString(e,2,e=>{o+=getCharValue(e,"C")*++t});o+=Code128Sym.StartC;return o%103}}export class Code128B{constructor(e){this.text=e;this.validate()}validate(){const{text:e}=this;if(!/^[\x20-\x7F\xC8-\xCF]+$/.test(e))throw new InvalidTextException(e)}getData(){const{text:e}=this,t=this.checksum();let o="";const r=getPatternByIndex(Code128Sym.StartB);o+=encode(r);Utils.sliceString(e,1,e=>{const t=getCharPattern(e,"B");o+=encode(t)});o+=encode(getPatternByIndex(t));o+=encode("2331112");return o}checksum(){const{text:e}=this;let t=0,o=0;Utils.sliceString(e,1,e=>{o+=getCharValue(e,"B")*++t});o+=Code128Sym.StartB;return o%103}}export class Code128A{constructor(e){this.text=e;this.validate()}validate(){const{text:e}=this;if(!/^[\x00-\x5F\xC8-\xCF]+$/.test(e))throw new InvalidTextException(e)}getData(){const{text:e}=this,t=this.checksum();let o="";const r=getPatternByIndex(Code128Sym.StartA);o+=encode(r);Utils.sliceString(e,1,e=>{const t=getCharPattern(e,"A");o+=encode(t)});o+=encode(getPatternByIndex(t));o+=encode("2331112");return o}checksum(){const{text:e}=this;let t=0,o=0;Utils.sliceString(e,1,e=>{o+=getCharValue(e,"A")*++t});o+=Code128Sym.StartA;return o%103}}export class Code128Encoder extends OneDimensionalBarcode{constructor(e,t=!1){e.merge(Code128Encoder.DefaultConfig);super(e);let{text:o}=this.encodeConfig;this.isUccEan128=t;t&&o[0]!==Code128Char.FNC1&&(o=Code128Char.FNC1+o);this.text=o;this.label=o.replace(/[^\x20-\x7E]/g,"")}validate(){}calculateData(){const{config:{codeSet:e},text:t,isUccEan128:o}=this;let r;if(o)r=new Code128Auto(t);else switch(e){case"A":r=new Code128A(t);break;case"B":r=new Code128B(t);break;case"C":r=new Code128C(t);break;default:r=new Code128Auto(t)}return r.getData()}}Code128Encoder.DefaultConfig={codeSet:"auto",quietZone:{right:10,left:10}};export class GS1_128Encoder extends Code128Encoder{constructor(e){super(e,!0)}}Barcode.registerEncoder("GS1_128",GS1_128Encoder);Barcode.registerEncoder("Code128",Code128Encoder);export class EncodeTable_Code39{static getMod43Val(e){let t=0;Utils.sliceString(e,1,e=>{t+=EncodeTable_Code39.MODULO_43_CHECK_TABLE.indexOf(e)});return EncodeTable_Code39.MODULO_43_CHECK_TABLE[t%43]}static getFullASCIIChar(e){let t="";Utils.sliceString(e,1,o=>{const r=EncodeTable_Code39.FULL_ASCII_TABLE[o.charCodeAt(0)];if(!r)throw new InvalidTextException(e);t+=r});return t}}EncodeTable_Code39.TABLE={0:"000110100",1:"100100001",2:"001100001",3:"101100000",4:"000110001",5:"100110000",6:"001110000",7:"000100101",8:"100100100",9:"001100100",A:"100001001",B:"001001001",C:"101001000",D:"000011001",E:"100011000",F:"001011000",G:"000001101",H:"100001100",I:"001001100",J:"000011100",K:"100000011",L:"001000011",M:"101000010",N:"000010011",O:"100010010",P:"001010010",Q:"000000111",R:"100000110",S:"001000110",T:"000010110",U:"110000001",V:"011000001",W:"111000000",X:"010010001",Y:"110010000",Z:"011010000","-":"010000101",".":"110000100"," ":"011000100",$:"010101000","/":"010100010","+":"010001010","%":"000101010","*":"010010100"};EncodeTable_Code39.MODULO_43_CHECK_TABLE=Utils.str2Array("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%");EncodeTable_Code39.FULL_ASCII_TABLE=["%U","$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","%A","%B","%C","%D","%E"," ","/A","/B","/C","/D","/E","/F","/G","/H","/I","/J","/K","/L","-",".","/O","0","1","2","3","4","5","6","7","8","9","/Z","%F","%G","%H","%I","%J","%V","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","%K","%L","%M","%N","%O","%W","+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","%P","%Q","%R","%S","%T"];export class Code39Encoder extends OneDimensionalBarcode{constructor(e){e.merge(Code39Encoder.DefaultConfig);super(e);const{encodeConfig:{text:t,hideExtraChecksum:o},config:{checkDigit:r,fullASCII:n,nwRatio:s,labelWithStartAndStopCharacter:i}}=this,a=n?EncodeTable_Code39.getFullASCIIChar(t):t;if(r){const e=EncodeTable_Code39.getMod43Val(a);this.text=Code39Encoder.START_STOP_CHARACTERS+a+e+Code39Encoder.START_STOP_CHARACTERS;const r=o?t:t+e,n=Code39Encoder.START_STOP_CHARACTERS+r+Code39Encoder.START_STOP_CHARACTERS;this.label=i?n:r}else{this.text=Code39Encoder.START_STOP_CHARACTERS+a+Code39Encoder.START_STOP_CHARACTERS;const e=t,o=Code39Encoder.START_STOP_CHARACTERS+e+Code39Encoder.START_STOP_CHARACTERS;this.label=i?o:e}this.nwRatio=+s}validate(){const{encodeConfig:{text:e},config:{fullASCII:t,nwRatio:o}}=this;if(!t&&!/^[0-9A-Z\-. $/+%]+$/.test(e))throw new InvalidTextException(e);if(2!=o&&3!=o)throw new InvalidOptionsException({nwRatio:o},"NwRatio is 2 or 3")}encode(e){const{nwRatio:t}=this;let o="";const r=Utils.strRepeat("1",t),n=Utils.strRepeat("0",t);Utils.str2Array(e).forEach((e,t)=>{Utils.isEven(t)?o+="1"===e?r:"1":o+="1"===e?n:"0"});return o}calculateData(){const{text:e}=this;let t="";Utils.sliceString(e,1,e=>{t=t+this.encode(EncodeTable_Code39.TABLE[e])+"0"});t=t.substr(0,t.length-1);return t}}Code39Encoder.DefaultConfig={checkDigit:!1,fullASCII:!1,nwRatio:3,labelWithStartAndStopCharacter:!1,quietZone:{right:10,left:10}};Code39Encoder.START_STOP_CHARACTERS="*";Barcode.registerEncoder("Code39",Code39Encoder);export class EncodeTable{static encodeCharByTable(e,t){return EncodeTable.TABLE[t][e]}static encodeByStructure(e,t){return Utils.str2Array(e).reduce((e,o,r)=>e+=EncodeTable.encodeCharByTable(o,t[r]),"")}static encodeByTable(e,t){if(e.length>1){return Utils.str2Array(e).reduce((e,o)=>e+=EncodeTable.encodeCharByTable(o,t),"")}return EncodeTable.encodeCharByTable(e,t)}}EncodeTable.TABLE={A:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],B:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],C:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"]};export class AddOnSymbol{constructor(e,t,o,r){this.isTextGroup=o;this.addOn=""+e;if("auto"!==t)if(Utils.isNumberLike(t))t=+t;else{t=Utils.convertUnit(Utils.fixSize2PixelDefault(t));t/=r}this.addOnHeight=t;this.validate()}static get2DigitAddOnTable(e){switch((e=parseInt(e))%4){case 0:return{leftStructure:"A",rightStructure:"A"};case 1:return{leftStructure:"A",rightStructure:"B"};case 2:return{leftStructure:"B",rightStructure:"A"};case 3:return{leftStructure:"B",rightStructure:"B"}}}static get5DigitAddOnTable(e){const t=3*(+(e+="")[0]+ +e[2]+ +e[4])+9*(+e[1]+ +e[3]);return AddOnSymbol.fiveDigitAddOnStructure[t%10]}validate(){const{addOn:e}=this;if(2!==e.length&&5!==e.length)throw new InvalidOptionsException({addOn:e},"Add on length should be 2 or 5.")}_encode2DigitAddOn(){const{addOn:e,isTextGroup:t}=this,o=[];let r,n,s;r=AddOnSymbol.get2DigitAddOnTable(e);n=EncodeTable.encodeByTable(e[0],r.leftStructure[0]);s=EncodeTable.encodeByTable(e[1],r.rightStructure[0]);if(t){o.push({binary:AddOnSymbol.ADD_ON_GUARD,role:"ADDON"});o.push({binary:n,text:e[0],role:"ADDON"});o.push({binary:AddOnSymbol.ADD_ON_DELINEATOR,role:"ADDON"});o.push({binary:s,text:e[1],role:"ADDON"})}else o.push({binary:AddOnSymbol.ADD_ON_GUARD+n+AddOnSymbol.ADD_ON_DELINEATOR+s,text:e,role:"ADDON"});return o}_encode5DigitAddOn(){const{addOn:e,isTextGroup:t}=this,o=[],r=AddOnSymbol.get5DigitAddOnTable(e);if(t){o.push({binary:AddOnSymbol.ADD_ON_GUARD,role:"ADDON"});Utils.str2Array(e).forEach((t,n)=>{o.push({binary:EncodeTable.encodeByTable(t,r[n]),text:t,role:"ADDON"});n<e.length-1&&o.push({binary:AddOnSymbol.ADD_ON_DELINEATOR,role:"ADDON"})})}else{const t=Utils.str2Array(e).reduce((t,o,n)=>{t+=EncodeTable.encodeByTable(o,r[n]);n<e.length-1&&(t+=AddOnSymbol.ADD_ON_DELINEATOR);return t},"");o.push({binary:AddOnSymbol.ADD_ON_GUARD+t,text:e,role:"ADDON"})}return o}calculateData(){const{addOn:e}=this;let t=[];2===e.length?t=this._encode2DigitAddOn():5===e.length&&(t=this._encode5DigitAddOn());t.push({text:">",role:"ADDON_RIGHT_QUIET_ZONE"});return t}}AddOnSymbol.fiveDigitAddOnStructure=["BBAAA","BABAA","BAABA","BAAAB","ABBAA","AABBA","AAABB","ABABA","ABAAB","AABAB"];AddOnSymbol.ADD_ON_GUARD="1011";AddOnSymbol.ADD_ON_DELINEATOR="01";export class EANBase extends OneDimensionalBarcode{constructor(e){e.merge(EANBase.DefaultConfig);super(e);const{style:{textAlign:t,unitValue:o},config:{addOnLabelPosition:r,addOn:n,addOnHeight:s}}=this;this.isTextGroup="group"===t;this.isAddOnLabelBottom="top"!==r;this._setAddOn(n,s,o)}_setAddOn(e,t,o){if(Utils.isDefined(e)){this.addOn=new AddOnSymbol(e,t,this.isTextGroup,o);this.addOnHeight=this.addOn.addOnHeight}else this.addOnHeight=0}checksum(e,t=!1){const o=Utils.str2Array(e),r=t?Utils.isOdd:Utils.isEven,n=o.reduce((e,t,o)=>{t=+t;return e+=r(o)?t:3*t},0)%10;return 0===n?0:10-n}convertToShape(e){let{isTextGroup:t,addOnHeight:o,isAddOnLabelBottom:r,style:{textAlign:n},encodeConfig:{isLabelBottom:s,height:i,quietZone:a,showLabel:c,fontSizeInUnit:l}}=this;c||(l=0);o=o||0;const d=[];let h,u,C,g,p,E,A,m=a.left,f=a.top;if(s){h=i+5;u=f+i;C=c?i+l:h;if(r){g=f;E="auto"===o?c?i:h:o;p=g+E}else{p=f;g=f+l;E="auto"===o?h-l:o}}else{h=i;i-=5;u=f;f+=l;C=c?h+l:h;if(r){g=a.top;E="auto"===o?c?i:h:o;p=g+E}else{p=a.top;g=a.top+l;E="auto"===o?h:o}}A=c?E+l:E;e.forEach(e=>{let o,r=f,s=i,l=u,C=t?"center":n,A=m;switch(e.role){case"GUARD":s=h;o=e.binary.length;break;case"ADDON":r=g;s=E;l=p;o=e.binary.length;break;case"LEFT_QUIET_ZONE":C="left";o=a.left;A=0;break;case"RIGHT_QUIET_ZONE":case"NO_ADDON_RIGHT_QUIET_ZONE":C="right";o=a.right;break;case"ADDON_QUIET_ZONE":o=a.addOn;break;case"ADDON_RIGHT_QUIET_ZONE":C="right";l=p;o=a.right;break;default:o=e.binary.length}if(c&&e.text){switch(C){case"center":A+=o/2;break;case"right":A+=o}const t={type:"text",x:A,y:l,text:e.text,textAlign:C,maxWidth:o};if("NO_ADDON_RIGHT_QUIET_ZONE"===e.role||"ADDON_RIGHT_QUIET_ZONE"===e.role){t.fontStyle="normal";t.fontWeight="normal";t.textDecoration="none"}d.push(t)}e.binary?Utils.combineTruthy(e.binary).forEach(e=>{if(0!==e){d.push({type:"rect",x:m,y:r,width:e,height:s});m+=e}else m++}):"ADDON_QUIET_ZONE"===e.role&&(m+=o)});this.size={width:m+a.right,height:Math.max(C,A)+a.top+a.bottom};this.shapes=d}afterApplyDesiredSize(){const{config:{addOn:e,addOnHeight:t},style:{unitValue:o}}=this;this._setAddOn(e,t,o);this.addOnHeight>this.encodeConfig.height&&(this.addOnHeight=this.encodeConfig.height)}}EANBase.NORMAL_GUARD="101";EANBase.CENTRE_GUARD="01010";EANBase.DefaultConfig={quietZone:{right:7,left:11}};export class UPC_E extends EANBase{constructor(e,t,o){e.merge(UPC_E.DefaultConfig);super(e);let{text:r,hideExtraChecksum:n}=this.encodeConfig;this.prefix=t;let s=r;if(r.length<7){r+=this.checksum(r);n||(s=r)}this.label=s;this.text=r;this.tableStructure=o}validate(){const{text:e}=this.encodeConfig;if(!/^(\d{6}|\d{7})$/.test(e))throw new InvalidTextException(e,"Text should be numbers. The length should be 6 or 7.");if(7===e.length){if(this.checksum(e.substr(0,6))!=e[6])throw new InvalidTextException(e,"Check digit is invalid.")}}checksum(e){let t;switch(e[5]){case"0":case"1":case"2":t=`${e.substr(0,2)}${e[5]}0000${e.substr(2,3)}`;break;case"3":t=`${e.substr(0,3)}00000${e.substr(3,2)}`;break;case"4":t=`${e.substr(0,4)}00000${e[4]}`;break;default:t=`${e.substr(0,5)}0000${e[5]}`}t=this.prefix+t;return super.checksum(t,!0)}calculateData(){let{text:e,addOn:t,isTextGroup:o,prefix:r,tableStructure:n,label:s}=this;const i=e[6],a=s[6];e=e.substr(0,6);const c=s.substr(0,6),l=n[i];let d=[];d.push({text:r,role:"LEFT_QUIET_ZONE"});d.push({binary:EANBase.NORMAL_GUARD,role:"GUARD"});o?Utils.str2Array(e).forEach((e,t)=>{d.push({binary:EncodeTable.encodeByTable(e,l[t]),text:c[t]})}):d.push({binary:EncodeTable.encodeByStructure(e,l),text:c});d.push({binary:UPC_E.SPECIAL_GUARD,role:"GUARD"});if(t){d.push({text:a,role:"ADDON_QUIET_ZONE"});d=d.concat(t.calculateData())}else d.push({text:a,role:"NO_ADDON_RIGHT_QUIET_ZONE"});return d}}UPC_E.DefaultConfig={addOnHeight:"auto",addOnLabelPosition:"top",quietZone:{left:9,addOn:5}};UPC_E.SPECIAL_GUARD="010101";export class UPC_E1_Encoder extends UPC_E{constructor(e){super(e,"1",UPC_E1_Encoder.structure)}}UPC_E1_Encoder.structure=["AAABBB","AABABB","AABBAB","AABBBA","ABAABB","ABBAAB","ABBBAA","ABABAB","ABABBA","ABBABA"];export class UPC_E0_Encoder extends UPC_E{constructor(e){super(e,"0",UPC_E0_Encoder.structure)}}UPC_E0_Encoder.structure=["BBBAAA","BBABAA","BBAABA","BBAAAB","BABBAA","BAABBA","BAAABB","BABABA","BABAAB","BAABAB"];export class UPC_A_Encoder extends EANBase{constructor(e){e.merge(UPC_A_Encoder.DefaultConfig);super(e);let{text:t,hideExtraChecksum:o}=this.encodeConfig,r=t;if(t.length<12){t+=this.checksum(t,!0);o||(r=t)}this.label=r;this.text=t}validate(){const{text:e}=this.encodeConfig;if(!/^(\d{11}|\d{12})$/.test(e))throw new InvalidTextException(e,"Text should be numbers. The length should be 11 or 12.");if(12===e.length){if(this.checksum(e.substr(0,11),!0)!=e[11])throw new InvalidTextException(e,"Check digit is invalid.")}}calculateData(){const{text:e,addOn:t,isTextGroup:o,label:r}=this,n=e[0],s=e[11],i=r[11],a=e.substr(1,5),c=e.substr(6,5),l=r.substr(1,5),d=r.substr(6,5);let h=[];h.push({text:n,role:"LEFT_QUIET_ZONE"});h.push({binary:EANBase.NORMAL_GUARD+EncodeTable.encodeByTable(n,"A"),role:"GUARD"});o?Utils.str2Array(a).forEach((e,t)=>{h.push({binary:EncodeTable.encodeByTable(e,"A"),text:l[t]})}):h.push({binary:EncodeTable.encodeByTable(a,"A"),text:l});h.push({binary:EANBase.CENTRE_GUARD,role:"GUARD"});o?Utils.str2Array(c).forEach((e,t)=>{h.push({binary:EncodeTable.encodeByTable(e,"C"),text:d[t]})}):h.push({binary:EncodeTable.encodeByTable(c,"C"),text:d});h.push({binary:EncodeTable.encodeByTable(s,"C")+EANBase.NORMAL_GUARD,role:"GUARD"});if(t){h.push({text:i,role:"ADDON_QUIET_ZONE"});h=h.concat(t.calculateData())}else h.push({text:i,role:"NO_ADDON_RIGHT_QUIET_ZONE"});return h}}UPC_A_Encoder.DefaultConfig={addOnHeight:"auto",addOnLabelPosition:"top",quietZone:{right:9,left:9,addOn:5}};Barcode.registerEncoder("UPC-A",UPC_A_Encoder);Barcode.registerEncoder("UPC-E0",UPC_E0_Encoder);Barcode.registerEncoder("UPC-E1",UPC_E1_Encoder);export class EAN13Encoder extends EANBase{constructor(e){e.merge(EAN13Encoder.DefaultConfig);super(e);let{text:t,hideExtraChecksum:o}=this.encodeConfig,r=t;if(t.length<13){t+=this.checksum(t);o||(r=t)}this.label=r;this.text=t}validate(){const{text:e}=this.encodeConfig;if(!/^[1-9](\d{11}|\d{12})$/.test(e))throw new InvalidTextException(e,"Text should be numbers. And it should not start with 0. The length should be 12 or 13.");if(13===e.length){if(this.checksum(e.substr(0,12))!=e[12])throw new InvalidTextException(e,"Check digit is invalid.")}}calculateData(){const{text:e,addOn:t,isTextGroup:o,label:r}=this,n=e.substr(1,6),s=e.substr(7,6),i=r.substr(1,6),a=r.substr(7,6),c=EAN13Encoder.leftStructure[e[0]];let l=[];l.push({text:e[0],role:"LEFT_QUIET_ZONE"});l.push({binary:EANBase.NORMAL_GUARD,role:"GUARD"});o?Utils.str2Array(n).forEach((e,t)=>{l.push({binary:EncodeTable.encodeByTable(e,c[t]),text:i[t]})}):l.push({binary:EncodeTable.encodeByStructure(n,c),text:i});l.push({binary:EANBase.CENTRE_GUARD,role:"GUARD"});o?Utils.str2Array(s).forEach((e,t)=>{l.push({binary:EncodeTable.encodeByTable(e,"C"),text:a[t]})}):l.push({binary:EncodeTable.encodeByTable(s,"C"),text:a});l.push({binary:EANBase.NORMAL_GUARD,role:"GUARD"});if(t){l.push({role:"ADDON_QUIET_ZONE"});l=l.concat(t.calculateData())}else l.push({text:">",role:"NO_ADDON_RIGHT_QUIET_ZONE"});return l}}EAN13Encoder.leftStructure=["AAAAAA","AABABB","AABBAB","AABBBA","ABAABB","ABBAAB","ABBBAA","ABABAB","ABABBA","ABBABA"];EAN13Encoder.DefaultConfig={addOnHeight:"auto",addOnLabelPosition:"top",quietZone:{addOn:5}};export class EAN8Encoder extends EANBase{constructor(e){e.merge(EAN8Encoder.DefaultConfig);super(e);let{text:t,hideExtraChecksum:o}=this.encodeConfig,r=t;if(t.length<8){t+=this.checksum(t,!0);o||(r=t)}this.label=r;this.text=t}validate(){const{text:e}=this.encodeConfig;if(!/^[0-9](\d{6}|\d{7})$/.test(e))throw new InvalidTextException(e,"Text should be numbers. The length should be 7 or 8.");if(8===e.length){if(this.checksum(e.substr(0,7),!0)!=e[7])throw new InvalidTextException(e,"Check digit is invalid.")}}calculateData(){const{text:e,label:t,isTextGroup:o}=this,r=e.substr(0,4),n=e.substr(4,4),s=t.substr(0,4),i=t.substr(4,4),a=[];a.push({text:"<",role:"LEFT_QUIET_ZONE"});a.push({binary:EANBase.NORMAL_GUARD,role:"GUARD"});o?Utils.str2Array(r).forEach((e,t)=>{a.push({binary:EncodeTable.encodeByTable(e,"A"),text:s[t]})}):a.push({binary:EncodeTable.encodeByTable(r,"A"),text:s});a.push({binary:EANBase.CENTRE_GUARD,role:"GUARD"});o?Utils.str2Array(n).forEach((e,t)=>{a.push({binary:EncodeTable.encodeByTable(e,"C"),text:i[t]})}):a.push({binary:EncodeTable.encodeByTable(n,"C"),text:i});a.push({binary:EANBase.NORMAL_GUARD,role:"GUARD"});a.push({text:">",role:"RIGHT_QUIET_ZONE"});return a}}EAN8Encoder.DefaultConfig={quietZone:{left:7}};Barcode.registerEncoder("EAN8",EAN8Encoder);Barcode.registerEncoder("EAN13",EAN13Encoder);const REG=/^([A-D]?)([0-9\-$:.+/]+)([A-D]?)$/;export class CodabarEncoder extends OneDimensionalBarcode{constructor(e){e.merge(CodabarEncoder.DefaultConfig);super(e);const{config:{checkDigit:t,nwRatio:o},encodeConfig:{text:r,hideExtraChecksum:n}}=this,{originStartPattern:s,startPattern:i,content:a,originStopPattern:c,stopPattern:l}=this.getTextEntity(r);this.label=r;if(t){const e=this.checksum(a);this.text=i+a+e+l;n||(this.label=s+a+e+c)}else this.text=i+a+l;this.nwRatio=+o}validate(){const{config:{nwRatio:e},encodeConfig:{text:t}}=this;if(!REG.test(t))throw new InvalidTextException(t);if(2!=e&&3!=e)throw new InvalidOptionsException({nwRatio:e},"NwRatio is 2 or 3")}getTextEntity(e){const t=REG.exec(e);if(!t)throw new InvalidTextException(e);const o=t[1],r=o||"A",n=t[2],s=t[3];return{originStartPattern:o,startPattern:r,content:n,originStopPattern:s,stopPattern:s||"B"}}encode(e){const{nwRatio:t}=this;let o="";const r=Utils.strRepeat("1",t),n=Utils.strRepeat("0",t);Utils.str2Array(e).forEach((e,t)=>{Utils.isEven(t)?o+="1"===e?r:"1":o+="1"===e?n:"0"});return o}calculateData(){const{text:e}=this;let t="";Utils.sliceString(e,1,e=>{t=t+this.encode(CodabarEncoder.TABLE[e])+"0"});t=t.substr(0,t.length-1);return t}checksum(e){let t=Utils.str2Array(e).filter(e=>Utils.isInteger(+e)).reverse().reduce((e,t,o)=>{const r=Utils.toNumber(t);if(Utils.isEven(o)){const t=2*r;e+=t>9?t-9:t}else e+=r;return e},0)%10;0!==t&&(t=10-t);return t}}CodabarEncoder.DefaultConfig={checkDigit:!1,quietZone:{right:10,left:10},nwRatio:3};CodabarEncoder.TABLE={0:"0000011",1:"0000110",2:"0001001",3:"1100000",4:"0010010",5:"1000010",6:"0100001",7:"0100100",8:"0110000",9:"1001000","-":"0001100",$:"0011000",":":"1000101","/":"1010001",".":"1010100","+":"0010101",A:"0011010",B:"0101001",C:"0001011",D:"0001110"};Barcode.registerEncoder("Codabar",CodabarEncoder);export const CodabarClsNames={hostElement:"wj-barcode-codabar"};export const Code128ClsNames={hostElement:"wj-barcode-code128"};export const Code39ClsNames={hostElement:"wj-barcode-code39"};export const Ean13ClsNames={hostElement:"wj-barcode-ean13"};export const Ean8ClsNames={hostElement:"wj-barcode-ean8"};export const EanBaseClsNames={hostElement:"wj-barcode-ean"};export const Gs1_128ClsNames={hostElement:"wj-barcode-gs1_128"};export const QrCodeClsNames={hostElement:"wj-barcode-qrcode"};export const UpcAClsNames={hostElement:"wj-barcode-upca"};export const UpcBaseClsNames={hostElement:"wj-barcode-upc"};export const UpcE0ClsNames={hostElement:"wj-barcode-upce0"};export const UpcE1ClsNames={hostElement:"wj-barcode-upce1"};export var QrCodeCharset;!function(e){e[e.Utf8=0]="Utf8";e[e.ShiftJis=1]="ShiftJis"}(QrCodeCharset||(QrCodeCharset={}));export var QrCodeCorrectionLevel;!function(e){e[e.Low=0]="Low";e[e.Medium=1]="Medium";e[e.Quartile=2]="Quartile";e[e.High=3]="High"}(QrCodeCorrectionLevel||(QrCodeCorrectionLevel={}));export var QrCodeModel;!function(e){e[e.Model1=0]="Model1";e[e.Model2=1]="Model2"}(QrCodeModel||(QrCodeModel={}));export var Code128CodeSet;!function(e){e[e.Auto=0]="Auto";e[e.A=1]="A";e[e.B=2]="B";e[e.C=3]="C"}(Code128CodeSet||(Code128CodeSet={}));export class _QrCodeModelConvertor{static stringToEnum(e){switch(e.toString()){case"1":return QrCodeModel.Model1;case"2":return QrCodeModel.Model2}throw`Unknown QRCode internal model '${e}'`}static enumToString(e){var t=QrCodeModel[asEnum(e,QrCodeModel)];return t.charAt(t.length-1)}}export class _CharsetTypeConvertor{static stringToEnum(e){switch(e){case"UTF-8":return QrCodeCharset.Utf8;case"Shift_JIS":return QrCodeCharset.ShiftJis}throw`Unknown Barcode internal charset '${e}'`}static enumToString(e){let t;switch(asEnum(e,QrCodeCharset)){case QrCodeCharset.Utf8:t="UTF-8";break;case QrCodeCharset.ShiftJis:t="Shift_JIS"}return t}}export class _CorrectionLevelConvertor{static stringToEnum(e){switch(e){case"L":return QrCodeCorrectionLevel.Low;case"M":return QrCodeCorrectionLevel.Medium;case"Q":return QrCodeCorrectionLevel.Quartile;case"H":return QrCodeCorrectionLevel.High}throw`Unknown barcode internal errorCorrectionLevel '${e}'`}static enumToString(e){return QrCodeCorrectionLevel[asEnum(e,QrCodeCorrectionLevel)].charAt(0)}}export class _CodeSetTypeConvertor{static stringToEnum(e){switch(e){case"auto":return Code128CodeSet.Auto;case"A":return Code128CodeSet.A;case"B":return Code128CodeSet.B;case"C":return Code128CodeSet.C}throw`Unknown barcode internal codeSet '${e}'`}static enumToString(e){let t,o=asEnum(e,Code128CodeSet);switch(o){case Code128CodeSet.Auto:t="auto";break;case Code128CodeSet.A:case Code128CodeSet.B:case Code128CodeSet.C:t=Code128CodeSet[o]}return t}}export class Codabar extends BarcodeBase{constructor(e,t){super(e);addClass(this.hostElement,CodabarClsNames.hostElement);this._setAw(!0);this.initialize(t)}static get controlTemplate(){Codabar._ctrlTemplate||(Codabar._ctrlTemplate=BarcodeBase.controlTemplate);return Codabar._ctrlTemplate}static set controlTemplate(e){Codabar._ctrlTemplate=e}get autoWidth(){return this._getAw()}set autoWidth(e){this._setAw(e)}get autoWidthZoom(){return this._getWzoom()}set autoWidthZoom(e){this._setWzoom(e)}get showLabel(){return this._getProp("showLabel")}set showLabel(e){this._setProp("showLabel",e)}get checkDigit(){return this._getProp("checkDigit")}set checkDigit(e){this._setProp("checkDigit",e)}get labelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("labelPosition"))}set labelPosition(e){this._setProp("labelPosition",_LabelPositionConvertor.enumToString(e))}get nwRatio(){return _NarrowWideRatioConvertor.stringToEnum(this._getProp("nwRatio"))}set nwRatio(e){this._setProp("nwRatio",_NarrowWideRatioConvertor.enumToString(e))}}Codabar.type="Codabar";Codabar._ctrlTemplate="";export class EanBase extends BarcodeBase{constructor(e,t){super(e,t);addClass(this.hostElement,EanBaseClsNames.hostElement)}get showLabel(){return this._getProp("showLabel")}set showLabel(e){this._setProp("showLabel",e)}get labelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("labelPosition"))}set labelPosition(e){this._setProp("labelPosition",_LabelPositionConvertor.enumToString(e))}}export class Ean8 extends EanBase{constructor(e,t){super(e,t);addClass(this.hostElement,Ean8ClsNames.hostElement)}}Ean8.type="EAN8";export class Ean13 extends EanBase{constructor(e,t){super(e,t);addClass(this.hostElement,Ean13ClsNames.hostElement)}get addOn(){return this._getProp("addOn")}set addOn(e){this._setProp("addOn",e)}get addOnHeight(){return this._getProp("addOnHeight")}set addOnHeight(e){this._setProp("addOnHeight",e)}get addOnLabelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("addOnLabelPosition"))}set addOnLabelPosition(e){this._setProp("addOnLabelPosition",_LabelPositionConvertor.enumToString(e))}get quietZone(){return this._getProp("quietZone")}set quietZone(e){this._setProp("quietZone",e)}}Ean13.type="EAN13";export class Code39 extends BarcodeBase{constructor(e,t){super(e);addClass(this.hostElement,Code39ClsNames.hostElement);this._setAw(!0);this.initialize(t)}static get controlTemplate(){Code39._ctrlTemplate||(Code39._ctrlTemplate=BarcodeBase.controlTemplate);return Code39._ctrlTemplate}static set controlTemplate(e){Code39._ctrlTemplate=e}get autoWidth(){return this._getAw()}set autoWidth(e){this._setAw(e)}get autoWidthZoom(){return this._getWzoom()}set autoWidthZoom(e){this._setWzoom(e)}get showLabel(){return this._getProp("showLabel")}set showLabel(e){this._setProp("showLabel",e)}get checkDigit(){return this._getProp("checkDigit")}set checkDigit(e){this._setProp("checkDigit",e)}get fullAscii(){return this._getProp("fullASCII")}set fullAscii(e){this._setProp("fullASCII",e)}get labelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("labelPosition"))}set labelPosition(e){this._setProp("labelPosition",_LabelPositionConvertor.enumToString(e))}get nwRatio(){return _NarrowWideRatioConvertor.stringToEnum(this._getProp("nwRatio"))}set nwRatio(e){this._setProp("nwRatio",_NarrowWideRatioConvertor.enumToString(e))}get labelWithStartAndStopCharacter(){return this._getProp("labelWithStartAndStopCharacter")}set labelWithStartAndStopCharacter(e){this._setProp("labelWithStartAndStopCharacter",e)}}Code39.type="Code39";Code39._ctrlTemplate="";export class Code128 extends BarcodeBase{constructor(e,t){super(e);addClass(this.hostElement,Code128ClsNames.hostElement);this._setAw(!0);this.initialize(t)}static get controlTemplate(){Code128._ctrlTemplate||(Code128._ctrlTemplate=BarcodeBase.controlTemplate);return Code128._ctrlTemplate}static set controlTemplate(e){Code128._ctrlTemplate=e}get autoWidth(){return this._getAw()}set autoWidth(e){this._setAw(e)}get autoWidthZoom(){return this._getWzoom()}set autoWidthZoom(e){this._setWzoom(e)}get showLabel(){return this._getProp("showLabel")}set showLabel(e){this._setProp("showLabel",e)}get codeSet(){return _CodeSetTypeConvertor.stringToEnum(this._getProp("codeSet"))}set codeSet(e){this._setProp("codeSet",_CodeSetTypeConvertor.enumToString(e))}get labelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("labelPosition"))}set labelPosition(e){this._setProp("labelPosition",_LabelPositionConvertor.enumToString(e))}}Code128.type="Code128";Code128._ctrlTemplate="";export class Gs1_128 extends BarcodeBase{constructor(e,t){super(e);addClass(this.hostElement,Gs1_128ClsNames.hostElement);this._setAw(!0);this.initialize(t)}static get controlTemplate(){Gs1_128._ctrlTemplate||(Gs1_128._ctrlTemplate=BarcodeBase.controlTemplate);return Gs1_128._ctrlTemplate}static set controlTemplate(e){Gs1_128._ctrlTemplate=e}get autoWidth(){return this._getAw()}set autoWidth(e){this._setAw(e)}get autoWidthZoom(){return this._getWzoom()}set autoWidthZoom(e){this._setWzoom(e)}get showLabel(){return this._getProp("showLabel")}set showLabel(e){this._setProp("showLabel",e)}get labelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("labelPosition"))}set labelPosition(e){this._setProp("labelPosition",_LabelPositionConvertor.enumToString(e))}}Gs1_128.type="GS1_128";Gs1_128._ctrlTemplate="";export class UpcBase extends BarcodeBase{constructor(e,t){super(e,t);addClass(this.hostElement,UpcBaseClsNames.hostElement)}static get controlTemplate(){UpcBase._ctrlTemplate||(UpcBase._ctrlTemplate=BarcodeBase.controlTemplate);return UpcBase._ctrlTemplate}static set controlTemplate(e){UpcBase._ctrlTemplate=e}get showLabel(){return this._getProp("showLabel")}set showLabel(e){this._setProp("showLabel",e)}get addOn(){return this._getProp("addOn")}set addOn(e){this._setProp("addOn",e)}get labelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("labelPosition"))}set labelPosition(e){this._setProp("labelPosition",_LabelPositionConvertor.enumToString(e))}get addOnHeight(){return this._getProp("addOnHeight")}set addOnHeight(e){this._setProp("addOnHeight",e)}get addOnLabelPosition(){return _LabelPositionConvertor.stringToEnum(this._getProp("addOnLabelPosition"))}set addOnLabelPosition(e){this._setProp("addOnLabelPosition",_LabelPositionConvertor.enumToString(e))}get quietZone(){return this._getProp("quietZone")}set quietZone(e){this._setProp("quietZone",e)}}UpcBase._ctrlTemplate="";export class UpcA extends UpcBase{constructor(e,t){super(e,t);addClass(this.hostElement,UpcAClsNames.hostElement)}}UpcA.type="UPC-A";export class UpcE0 extends UpcBase{constructor(e,t){super(e,t);addClass(this.hostElement,UpcE0ClsNames.hostElement)}}UpcE0.type="UPC-E0";export class UpcE1 extends UpcBase{constructor(e,t){super(e,t);addClass(this.hostElement,UpcE1ClsNames.hostElement)}}UpcE1.type="UPC-E1";export class QrCode extends BarcodeBase{constructor(e,t){super(e,t);addClass(this.hostElement,QrCodeClsNames.hostElement)}get charCode(){return this._getProp("charCode")}set charCode(e){this._setProp("charCode",e)}get charset(){return _CharsetTypeConvertor.stringToEnum(this._getProp("charset"))}set charset(e){this._setProp("charset",_CharsetTypeConvertor.enumToString(e))}get model(){return _QrCodeModelConvertor.stringToEnum(this._getProp("model"))}set model(e){this._setProp("model",_QrCodeModelConvertor.enumToString(e))}get version(){const e=this._getProp("version");return"auto"===e?null:e}set version(e){this._setProp("version",null==e?"auto":e)}get errorCorrectionLevel(){return _CorrectionLevelConvertor.stringToEnum(this._getProp("errorCorrectionLevel"))}set errorCorrectionLevel(e){this._setProp("errorCorrectionLevel",_CorrectionLevelConvertor.enumToString(e))}get mask(){const e=this._getProp("mask");return"auto"===e?null:e}set mask(e){this._setProp("mask",null==e?"auto":e)}get connection(){return this._getProp("connection")}set connection(e){this._setProp("connection",e)}get connectionIndex(){return this._getProp("connectionNo")}set connectionIndex(e){this._setProp("connectionNo",e)}}QrCode.type="QRCode";_registerModule("wijmo.barcode.common",selfModule);