(function(E,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@barcode-bakery/barcode-common")):typeof define=="function"&&define.amd?define(["exports","@barcode-bakery/barcode-common"],r):(E=typeof globalThis<"u"?globalThis:E||self,r(E["barcode-bakery-aztec"]={},E["barcode-bakery-common"]))})(this,function(E,r){"use strict";var U=Object.defineProperty;var L=(E,r,m)=>r in E?U(E,r,{enumerable:!0,configurable:!0,writable:!0,value:m}):E[r]=m;var g=(E,r,m)=>(L(E,typeof r!="symbol"?r+"":r,m),m);const c=class c extends r.BCGBarcode2D{constructor(){super();g(this,"symbolsize",[[1,15,17,6,102,1,64,67],[1,19,21,6,126,0,64,67],[2,19,40,6,240,1,64,67],[2,23,48,6,288,0,64,67],[3,23,51,8,408,1,256,301],[3,27,60,8,480,0,256,301],[4,27,76,8,608,1,256,301],[4,31,88,8,704,0,256,301],[5,37,120,8,960,0,256,301],[6,41,156,8,1248,0,256,301],[7,45,196,8,1568,0,256,301],[8,49,240,8,1920,0,256,301],[9,53,230,10,2300,0,1024,1033],[10,57,272,10,2720,0,1024,1033],[11,61,316,10,3160,0,1024,1033],[12,67,364,10,3640,0,1024,1033],[13,71,416,10,4160,0,1024,1033],[14,75,470,10,4700,0,1024,1033],[15,79,528,10,5280,0,1024,1033],[16,83,588,10,5880,0,1024,1033],[17,87,652,10,6520,0,1024,1033],[18,91,720,10,7200,0,1024,1033],[19,95,790,10,7900,0,1024,1033],[20,101,894,10,8640,0,1024,1033],[21,105,940,10,9400,0,1024,1033],[22,109,1020,10,10200,0,1024,1033],[23,113,920,12,11040,0,4096,4201],[24,117,992,12,11904,0,4096,4201],[25,121,1066,12,12792,0,4096,4201],[26,125,1144,12,13728,0,4096,4201],[27,131,1224,12,14688,0,4096,4201],[28,135,1306,12,15672,0,4096,4201],[29,139,1392,12,16704,0,4096,4201],[30,143,1480,12,17760,0,4096,4201],[31,147,1570,12,18840,0,4096,4201],[32,151,1664,12,19968,0,4096,4201]]);g(this,"data",null);g(this,"messagemode",null);g(this,"symbolindex",-1);g(this,"xo",0);g(this,"latch",[[[null,null,null],["11100",null,null],["11101",null,null],["11101","11110",null],["11110",null,null],["11111",null,null]],[["11101","11101",null],[null,null,null],["11101",null,null],["11101","11110",null],["11110",null,null],["11111",null,null]],[["11101",null,null],["11100",null,null],[null,null,null],["11110",null,null],["11100","11110",null],["11111",null,null]],[["11111",null,null],["11111","11100",null],["11111","11101",null],[null,null,null],["11111","11110",null],["11111","11111",null]],[["1110",null,null],["1110","11100",null],["1110","11101",null],["1110","11101","11110"],[null,null,null],["1110","11111",null]]]);g(this,"shift",[["-1","-1","-1","00000","-1","-1"],["11100","-1","-1","00000","-1","-1"],["-1","-1","-1","00000","-1","-1"],["-1","-1","-1","-1","-1","-1"],["1111","-1","-1","0000","-1","-1"]]);g(this,"code",null);g(this,"errorlevel",23);g(this,"size",c.Size.Smallest);g(this,"symbolNumber",0);g(this,"symbolTotal",0);g(this,"symbolName",null);g(this,"tilde",!1);g(this,"rune",-1);let t=" ABCDEFGHIJKLMNOPQRSTUVWXYZ",e=" abcdefghijklmnopqrstuvwxyz",i=" ";for(let l=1;l<=13;l++)i+=String.fromCharCode(l);for(let l=27;l<=31;l++)i+=String.fromCharCode(l);i+="@\\^_`|~";let n=`\r!"#$%&'()*+,-./:;<=>?[]{}`,u=" 0123456789,.";this.code=[t,e,i,n,u],this.setScale(4)}parse(t){if(t.length===0)throw new r.BCGParseException("aztec","Provide data to parse.");this.rune=-1;let i;if({value:i,text:t}=this.getSequence(t),i!==""){let n=this.createBinaryStream(t,i);this.setData(n)}}draw(t){if(this.messagemode===null)throw new Error;let e=this.messagemode.length,i=0;if(this.data!==null&&(i=this.data.length),this.rune===-1&&(this.symbolindex===-1||e===0||i===0))throw new r.BCGDrawException("An unknown error occured during the drawing operation.");this.rune===-1?this.xo=Math.floor(this.symbolsize[this.symbolindex][c.S_SIZE]/2):this.xo=Math.floor(this.symbolsize[this.symbolindex][c.S_SIZE]/2)-2,this.drawFixed(t),this.drawMessageMode(t),this.rune===-1&&this.drawLayer(t),this.drawText(t,0,0,this.symbolsize[this.symbolindex][c.S_SIZE],this.symbolsize[this.symbolindex][c.S_SIZE])}getDimension(t,e){return this.symbolindex===-1?super.getDimension(t,e):(this.rune===-1?(t+=this.symbolsize[this.symbolindex][c.S_SIZE],e+=this.symbolsize[this.symbolindex][c.S_SIZE]):(t+=11,e+=11),super.getDimension(t,e))}getErrorLevel(){return this.errorlevel}setErrorLevel(t){if(t>99||t<5)throw new r.BCGArgumentException("The error level percentage must be between 5% and 99%.","level");this.errorlevel=t}getSize(){return this.size}setSize(t){this.size=t}setStructuredAppend(t,e=0,i=null){if(e===0)return this.symbolNumber=0,this.symbolTotal=0,this.symbolName=null,!0;if(t<=0)throw new r.BCGArgumentException("The symbol number must be equal or bigger than 1 or 0 to reset.","symbolNumber");if(t>e)throw new r.BCGArgumentException("The symbol number must be equal or lower than the symbol total.","symbolNumber");if(e>26)throw new r.BCGArgumentException("The symbol total must be equal or lower than 26.","symbolTotal");if(i!==null&&i.indexOf(" ")!==-1)throw new r.BCGArgumentException("The symbol name can't contain a space.","symbolName");return this.symbolNumber=t,this.symbolTotal=e,this.symbolName=i,!0}getTilde(){return this.tilde}setTilde(t){this.tilde=t}getRune(){return this.rune}setRune(t){if(t===-1){this.rune=-1;return}if(t<0||t>255)throw new r.BCGArgumentException("The Rune number has to be between 0 and 255.","runeNumber");this.symbolindex=0;let e=r.Utility.decbin(t,8);this.messagemode=this.groupBit(e,4,!1);let i=5,n=16,u=19;({bitstreamArray:this.messagemode}=this.computeError(this.messagemode,4,i,n,u));for(let l=0;l<7;l++)this.messagemode[l]=r.Utility.decbin(r.Utility.bindec(this.messagemode[l])^10,4);this.rune=t}getSequence(t){let e=1e5,i=[[0,5,5,10,5,10],[10,0,5,10,5,10],[5,5,0,5,10,10],[5,10,10,0,10,15],[4,9,9,14,0,14],[0,0,0,0,0,0]],n=[[e,e,e,5,e],[5,e,e,5,e],[e,e,e,5,e],[e,e,e,e,e],[4,e,e,4,e]],u=[5,5,5,5,4,8],l="";if(this.symbolNumber>0){let y=""+String.fromCharCode(65+this.symbolNumber-1)+String.fromCharCode(65+this.symbolTotal-1);this.symbolName!==null?t=" "+this.symbolName+" "+y+t:t=y+t,l="20"}let s=[0,e,e,e,e,e],f=[l,l,l,l,l,l],o="B"+r.Utility.strRepeat(".",32),w=t.length;for(let y=0;yy+1)if(t[y+1]==="~")x.push(2),b="~",y++;else if(t[y+1]==="E")if(t.length>y+2){let a=t.substr(y+2,Math.min(6,t.length-(y+2)));if(a.length===6&&r.Utility.isNumeric(a))x.push(3),b="E",y+=7;else throw new r.BCGParseException("aztec","Bad ~E. You must provide 6 following digits.")}else throw new r.BCGParseException("aztec","Bad ~E. You must provide 6 following digits.");else if(t[y+1]==="F")x.push(3),b="F",y++;else throw new r.BCGParseException("aztec","Wrong code after the ~.");else throw new r.BCGParseException("aztec","Wrong code after the ~.");else{for(let a=0;a<5;a++)this.code[a].indexOf(z)!==-1&&x.push(a);x.push(5)}let O=x.length;for(let a=0;a0){let a=t.substr(y-1,2);if(a[0]==="\r"&&a[1]===` `||a===". "||a===", "||a===": "){s[3]="A"&&w<="D"){let p=w.charCodeAt(0)-65;u.push(this.shift[n][p]),s===-1&&(s=n),n=p}else if(h>=0&&h<=5)if(s=-1,h===5){if(e.length>f+1&&e[f+1]==="."){let p=0;for(let y=f+1;y6)break}}}groupBit(t,e,i){let n=r.Utility.strRepeat("0",e-1),u=r.Utility.strRepeat("1",e-1),l=t.length,s=[],f=0,o=0;for(;f0&&(s[o-1]=r.Utility.pad(s[o-1],e,"1",!1),i&&r.Utility.safeSubstring(s[o-1],0,-1)===u&&(s[o-1]=r.Utility.safeSubstring(s[o-1],0,-1)+"0")),s}computeError(t,e,i,n,u){let l={},s=t.length;for(let o=0;o=n&&(s[h]^=u),l[s[h]]=h;let f=[];for(let h=0;h=1;p--)f[p]=f[p-1]^this.prod(f[p],s[h],l,s,n);f[0]=this.prod(f[0],s[h],l,s,n)}let o=e+i;for(let h=e;h<=o;h++)t[h]=0;for(let h=0;h0;u--){let l=r.BCGBarcode.COLOR_FG;u%2===1&&(l=r.BCGBarcode.COLOR_BG),this.drawRectangle(t,-u,-u,u,u,l)}this.drawPixel(t,-i-1,i),this.drawPixel(t,-i-1,i+1),this.drawPixel(t,-i,i+1),this.drawPixel(t,i+1,i+1),this.drawPixel(t,i+1,i),this.drawPixel(t,i+1,-i),this.drawPixel(t,i,i+1,r.BCGBarcode.COLOR_BG),this.drawPixel(t,i+1,-i-1,r.BCGBarcode.COLOR_BG),this.drawPixel(t,i,-i-1,r.BCGBarcode.COLOR_BG),this.drawPixel(t,-i,-i-1,r.BCGBarcode.COLOR_BG),this.drawPixel(t,-i-1,-i-1,r.BCGBarcode.COLOR_BG),this.drawPixel(t,-i-1,-i,r.BCGBarcode.COLOR_BG);let n=[r.BCGBarcode.COLOR_FG,r.BCGBarcode.COLOR_BG];if(!e){let u=Math.floor(this.xo%16)-this.xo;for(let l=-this.xo;l<=this.xo;l++)for(let s=u;sf;o--){if(!e&&o===0){f--;continue}let h=parseInt(u[l++].toString(),10);this.drawPixel(t,w,o,s[h])}f=n-1-i,o=-n-1;for(let h=n-1;h>f;h--){if(!e&&h===0){f--;continue}let p=parseInt(u[l++].toString(),10);this.drawPixel(t,h,o,s[p])}for(f=-n+1+i,w=-n-1,o=-n+1;o=0;S--)for(let b=u-1;b>=0;b-=2)l+=this.data[S][b-1],l+=this.data[S][b];for(let S=0;S{(R=>{R[R.Smallest=0]="Smallest",R[R.Compact=1]="Compact",R[R.Full=2]="Full"})(G.Size||(G.Size={}))})(m||(m={})),E.BCGaztec=m,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});