!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).dtpweb={})}(this,(function(e){"use strict";
/**
     * @file utils.ts
     * @author DothanTech (hudianxing@dothantech.com)
     * @brief PC JavaScript 版本 相关接口类型及方法定义。
     * @version 2.1
     * @date 2022-05-16
     *
     * @copyright Copyright (c) 2022
     *
     */var t,n,r,i,a,o,s,u,l,c,h,g,p,d,f,m,y,_,P,A,v,L,b="GET",T="127.0.0.1",N=15216,R=35216,E=2e3,I=5e3,D=40,O=30,w="黑体",C=3.5,B=.35,S=[.5,.5],x=1.5,W=5,M=20,j=192,k=4096,q="lpapi",F="local",U="Version",K="SetSupportedPrinters",V="GetDefaultPrinter",H="SetDefaultPrinter",J="DiscoveryPrinters",G="GetPrinters",$="OpenPrinter",X="ClosePrinter",Y="IsPrinterOpened",z="IsPrinterOnline",Q="GetPrinterName",Z="ShowProperty",ee="PrintImageD",te="Print",ne="GetParam",re="SetParam",ie="GetPrinterDPI",ae="SetItemOrientation",oe="SetItemHorizontalAlignment",se="SetItemVerticalAlignment",ue="StartJob",le="AbortJob",ce="CommitJob",he="GetJobID",ge="GetJobInfo",pe="GetPageInfo",de="GetPageImage",fe="StartPage",me="EndPage",ye="ReturnDrawResult",_e="DrawText",Pe="Draw1DBarcode",Ae="Draw2DQRCode",ve="Draw2DPdf417",Le="Draw2DDataMatrix",be="DrawRectangle",Te="DrawRoundRectangle",Ne="DrawEllipse",Re="DrawLine",Ee="DrawDashLine",Ie="DrawImage",De="DrawImageD",Oe="ServerInfo",we="application/x-www-form-urlencoded;charset=UTF-8",Ce="application/octet-stream;encoding=base64",Be="application/json;charset:utf-8",Se="";e.LPA_ParamID=void 0,(t=e.LPA_ParamID||(e.LPA_ParamID={}))[t.GapType=1]="GapType",t[t.PrintDarkness=2]="PrintDarkness",t[t.PrintSpeed=3]="PrintSpeed",t[t.PrinterDPIx=4]="PrinterDPIx",t[t.PrinterDPIy=5]="PrinterDPIy",e.LPA_GapType=void 0,(n=e.LPA_GapType||(e.LPA_GapType={}))[n.Unset=255]="Unset",n[n.None=0]="None",n[n.Hole=1]="Hole",n[n.Gap=2]="Gap",n[n.Black=3]="Black",e.LPA_PrintSpeed=void 0,(r=e.LPA_PrintSpeed||(e.LPA_PrintSpeed={}))[r.Unset=255]="Unset",r[r.Min=0]="Min",r[r.Low=1]="Low",r[r.Normal=2]="Normal",r[r.High=3]="High",r[r.Max=4]="Max",e.LPA_PrintDarkness=void 0,(i=e.LPA_PrintDarkness||(e.LPA_PrintDarkness={}))[i.Unset=255]="Unset",i[i.Min=0]="Min",i[i.Low=3]="Low",i[i.Normal=5]="Normal",i[i.High=9]="High",i[i.Max=14]="Max",e.LPA_ItemAlignment=void 0,(a=e.LPA_ItemAlignment||(e.LPA_ItemAlignment={}))[a.Start=0]="Start",a[a.Center=1]="Center",a[a.End=2]="End",a[a.Stretch=3]="Stretch",a[a.Expand=4]="Expand",e.LPA_FontStyle=void 0,(o=e.LPA_FontStyle||(e.LPA_FontStyle={}))[o.Regular=0]="Regular",o[o.Bold=1]="Bold",o[o.Italic=2]="Italic",o[o.BoldItalic=3]="BoldItalic",o[o.Underline=4]="Underline",o[o.Strikeout=8]="Strikeout",function(e){e[e.None=0]="None",e[e.Char=1]="Char",e[e.Word=2]="Word"}(s||(s={})),function(e){e[e.LPA_1DBT_UPC_A=20]="LPA_1DBT_UPC_A",e[e.LPA_1DBT_UPC_E=21]="LPA_1DBT_UPC_E",e[e.LPA_1DBT_EAN13=22]="LPA_1DBT_EAN13",e[e.LPA_1DBT_EAN8=23]="LPA_1DBT_EAN8",e[e.LPA_1DBT_CODE39=24]="LPA_1DBT_CODE39",e[e.LPA_1DBT_ITF25=25]="LPA_1DBT_ITF25",e[e.LPA_1DBT_CODABAR=26]="LPA_1DBT_CODABAR",e[e.LPA_1DBT_CODE93=27]="LPA_1DBT_CODE93",e[e.LPA_1DBT_CODE128=28]="LPA_1DBT_CODE128",e[e.LPA_1DBT_ISBN=29]="LPA_1DBT_ISBN",e[e.LPA_1DBT_ECODE39=30]="LPA_1DBT_ECODE39",e[e.LPA_1DBT_AUTO=60]="LPA_1DBT_AUTO"}(u||(u={})),e.LPA_JobNames=void 0,(l=e.LPA_JobNames||(e.LPA_JobNames={})).Preview="#!#Preview#!#",l.Transparent="#!#Transparent#!#",l.Print="dtpweb",e.LPA_PrintActions=void 0,(c=e.LPA_PrintActions||(e.LPA_PrintActions={}))[c.PrintData=1]="PrintData",c[c.PrevBase64=2]="PrevBase64",c[c.PrevUrl=4]="PrevUrl",c[c.Transparent=128]="Transparent",c[c.TransBase64=130]="TransBase64",c[c.Print=4096]="Print",function(e){e[e.Print=0]="Print",e[e.White=1]="White",e[e.Transparent=2]="Transparent"}(h||(h={})),e.LPA_Result=void 0,(g=e.LPA_Result||(e.LPA_Result={}))[g.WAIT_FOR_ASYNC=-1]="WAIT_FOR_ASYNC",g[g.OK=0]="OK",g[g.PARAM_ERROR=1]="PARAM_ERROR",g[g.SYSTEM_ERROR=2]="SYSTEM_ERROR",g[g.NO_SUPPORTED_PRINTER=3]="NO_SUPPORTED_PRINTER",g[g.UNSUPPORTED_PRINTER=4]="UNSUPPORTED_PRINTER",g[g.NO_PRINT_DATA=5]="NO_PRINT_DATA",g[g.NO_PAGE_DIMENSION=6]="NO_PAGE_DIMENSION",g[g.INVALID_FILE=7]="INVALID_FILE",g[g.ERROR_START_JOB=8]="ERROR_START_JOB",g[g.UNSUPPORTED_FUNCTION=9]="UNSUPPORTED_FUNCTION",g[g.INVALID_FONT_NAME=10]="INVALID_FONT_NAME",g[g.NETWORK_FAILED=90]="NETWORK_FAILED",g[g.NETWORK_TIMEOUT=91]="NETWORK_TIMEOUT",g[g.NETWORK_ERROR=92]="NETWORK_ERROR",g[g.NETWORK_ABORT=93]="NETWORK_ABORT",g[g.NETWORK_UNSUPPORTED=94]="NETWORK_UNSUPPORTED",g[g.NETWORK_EXCEPTION=95]="NETWORK_EXCEPTION",function(e){e[e.ShowReadNone=0]="ShowReadNone",e[e.ShowReadDown=1]="ShowReadDown",e[e.ShowReadUp=2]="ShowReadUp",e[e.ShowStartStop=4]="ShowStartStop",e[e.EanCheckCode=8]="EanCheckCode"}(p||(p={})),function(e){e[e.Unicode=0]="Unicode",e[e.Ansi=1]="Ansi",e[e.UTF8=2]="UTF8"}(d||(d={})),function(e){e[e.ModeNum=0]="ModeNum",e[e.ModeAn=1]="ModeAn",e[e.Mode8Bit=2]="Mode8Bit",e[e.ModeKanji=3]="ModeKanji",e[e.ModeStructure=4]="ModeStructure",e[e.ModeEci=5]="ModeEci",e[e.ModeFnc1First=6]="ModeFnc1First",e[e.ModeFnc1Second=7]="ModeFnc1Second"}(f||(f={})),function(e){e[e.EccLevel_L=0]="EccLevel_L",e[e.EccLevel_M=1]="EccLevel_M",e[e.EccLevel_Q=2]="EccLevel_Q",e[e.EccLevel_H=3]="EccLevel_H"}(m||(m={})),function(e){e[e.Unicode=0]="Unicode",e[e.Ansi=1]="Ansi",e[e.UTF8=2]="UTF8"}(y||(y={})),function(e){e[e.ModeAuto=0]="ModeAuto",e[e.ModeNumeric=1]="ModeNumeric",e[e.ModeText=2]="ModeText",e[e.ModeBinary=3]="ModeBinary"}(_||(_={})),function(e){e[e.EccLevel_Auto=0]="EccLevel_Auto",e[e.EccLevel_1=1]="EccLevel_1",e[e.EccLevel_2=2]="EccLevel_2",e[e.EccLevel_3=3]="EccLevel_3",e[e.EccLevel_4=4]="EccLevel_4",e[e.EccLevel_5=5]="EccLevel_5",e[e.EccLevel_6=6]="EccLevel_6",e[e.EccLevel_7=7]="EccLevel_7",e[e.EccLevel_8=8]="EccLevel_8"}(P||(P={})),function(e){e[e.LPASIF_RAWDATA=0]="LPASIF_RAWDATA",e[e.LPASIF_BPP_1=1]="LPASIF_BPP_1",e[e.LPASIF_BPP_1N=2]="LPASIF_BPP_1N",e[e.LPASIF_32_RGBA=32]="LPASIF_32_RGBA",e[e.LPASIF_32_BGRA=33]="LPASIF_32_BGRA",e[e.LPASIF_32_RGB=34]="LPASIF_32_RGB",e[e.LPASIF_32_BGR=35]="LPASIF_32_BGR",e[e.LPASIF_PACKAGE=90]="LPASIF_PACKAGE",e[e.LPASIF_IMAGEDATA=93]="LPASIF_IMAGEDATA"}(A||(A={})),function(e){e[e.UrlEncoded=0]="UrlEncoded",e[e.Base64=1]="Base64",e[e.Json=2]="Json",e[e.Blob=3]="Blob"}(v||(v={})),e.LPA_DrawType=void 0,(L=e.LPA_DrawType||(e.LPA_DrawType={})).Text="text",L.Barcode="barcode",L.QRCode="qrcode",L.Pdf417="pdf417",L.DataMatrix="dataMatrix",L.Image="image",L.Rect="rectangle",L.RoundRect="roundRectangle",L.Ellipse="ellipse",L.Line="line",L.DashLine="dashLine";var xe={scaleUnit:0,getJobAction:function(e){var t=e||"";return t.startsWith("#!#Prev")?2:t.startsWith("#!#Trans")?130:4096},assignValue:function(e,t){var n=e||{};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(this.isPlainObject(n[r])&&this.isPlainObject(t[r])?this.assignValue(n[r],t[r]):this.isPlainObject(t[r])?n[r]=this.assignValue({},t[r]):Array.isArray(t[r])?n[r]=t[r].slice():n[r]=t[r]);return n},merge:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=e||{};if(!t)return r;for(var i=0;i<t.length;i++)r=this.assignValue(r,t[i]);return r},isObject:function(e){return null!==e&&"object"==typeof e},isPlainObject:function(e){if("[object Object]"!==toString.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},isArrayBuffer:function(e){return"[object ArrayBuffer]"===toString.call(e)},isArray:function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)},isHttpsRequest:function(e){return/https:?/.test(e)},isNumberString:function(e){return!!e&&(!!(e=e.trim()).match(/^[-+]?[0-9]*\.?[0-9]+$/)||!!e.match(/^(0x)?[0-9a-f]+$/i))},isBooleanString:function(e){return!!e&&!!(e=e.trim()).match(/^(yes)|(no)|(true)|(false)$/i)},getNumber:function(e,t){return e=(e||"").trim(),this.isNumberString(e)?Number(e):t||0},getBoolean:function(e,t){return!!(e=(e||"").trim()).match(/^(yes)|(true)$/i)||!e.match(/^(no)|(false)$/i)&&(t||!1)},parseArray:function(e,t){void 0===t&&(t=1);var n=[];if(xe.isArray(e))return e;if("string"==typeof e)return e.split(",");if("number"==typeof e)for(var r=0;r<t;r++)n.push(e);return n},parseMargin:function(e){var t,n,r,i,a=[];if(e.margin&&(1===(a=xe.parseArray(e.margin,4)).length?a=[a[0],a[0],a[0],a[0]]:2===a.length?a=[a[0],a[1],a[0],a[1]]:3===a.length&&a.push(a[1])),e.marginH){var o=xe.parseArray(e.marginH,2);a[1]=null!==(t=o[0])&&void 0!==t?t:0,a[3]=null!==(n=o[1])&&void 0!==n?n:o[0]}if(e.marginV){o=xe.parseArray(e.marginV,2);a[0]=null!==(r=o[0])&&void 0!==r?r:0,a[2]=null!==(i=o[1])&&void 0!==i?i:o[0]}return a},getParamString:function(e){e=e||{};var t=[];for(var n in e){var r=e[n];null!=r&&("object"!=typeof r&&"function"!=typeof r&&t.push("".concat(n,"=").concat(encodeURIComponent(r))))}return t.length>0?t.join("&"):""},getRequestData:function(e,t){if(null==t?t=[]:"object"!=typeof t&&(t=[t]),t.length&&"object"==typeof t[0])return t[0];var n={};if("string"==typeof e&&(e=[e]),e.length<1||!e[0])return n;for(var r=0;r<e.length;r++)n[e[r]]=t[r];return n},filterRecord:function(e,t){return Object.keys(e).filter((function(n){return t(n,e[n])})).reduce((function(t,n){return t[n]=e[n],t}),{})},processResult:function(e,t,n){t&&t(e),n&&n(e)},buildURL:function(e,t){var n="string"==typeof t?t:this.getParamString(t);return n?"".concat(e,":").concat(n):e},request:function(t,n){"undefined"!=typeof XMLHttpRequest?this.requestXMLHttp(t,n):"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)?this.requestNodeHttp(t,n):n({statusCode:e.LPA_Result.NETWORK_UNSUPPORTED,resultInfo:"not supported http request environment!"})},requestXMLHttp:function(t,n){var r,i=new XMLHttpRequest,a=t.host||T,o=t.port||N,s=t.baseUrl||"http://".concat(a,":").concat(o),u=t.data,l=t.headers;t.url&&"/"===t.url[0]&&(t.url=t.url.substring(1));var c="".concat(s,"/").concat(t.url);try{i.open(t.method||b,c,!t.sync),t.timeout&&!t.sync&&(i.timeout=t.timeout);var h=function(){i&&(r=200===i.status?JSON.parse(i.responseText):{statusCode:e.LPA_Result.NETWORK_FAILED,resultInfo:i.responseText},n(r),i=null)};if("onloadend"in i?i.onloadend=h:i.onreadystatechange=function(){i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))&&setTimeout(h)},i.onabort=function(){i&&(n({statusCode:e.LPA_Result.NETWORK_ABORT,resultInfo:"Request aborted!"}),i=null)},i.onerror=function(){n({statusCode:e.LPA_Result.NETWORK_ERROR,resultInfo:"Network Error"}),i=null},i.ontimeout=function(){n({statusCode:e.LPA_Result.NETWORK_TIMEOUT,resultInfo:t.timeout?"timeout of ".concat(t.timeout,"ms exceeded"):"timeout exceeded"}),i=null},l&&"setRequestHeader"in i)for(var g in l)void 0===u&&"content-type"===g.toLowerCase()?delete l[g]:i.setRequestHeader(g,l[g]);i.send(u)}catch(t){n({statusCode:e.LPA_Result.NETWORK_EXCEPTION,resultInfo:t})}},requestNodeHttp:function(t,n){var r=require("http");t.url&&"/"!==t.url[0]&&(t.url="/".concat(t.url));var i={host:t.host||T,port:t.port||N,method:t.method||b,path:t.url,headers:t.headers},a="",o=r.request(i,(function(t){t.on("data",(function(e){a+=e})),t.on("end",(function(){var t={statusCode:e.LPA_Result.NETWORK_EXCEPTION,resultInfo:a};try{t=JSON.parse(a)}catch(e){console.log(e)}n(t)})),t.on("error",(function(t){r.aborted||n({statusCode:e.LPA_Result.NETWORK_ERROR,resultInfo:t})}))}));if(o.on("error",(function(t){n({statusCode:e.LPA_Result.NETWORK_FAILED,resultInfo:t})})),o.on("socket",(function(e){e.setKeepAlive(!0,6e4)})),t.timeout){var s=t.timeout;o.setTimeout(s,(function(){o.destroy(),n({statusCode:e.LPA_Result.NETWORK_TIMEOUT,resultInfo:t.timeout?"timeout of ".concat(t.timeout,"ms exceeded"):"timeout exceeded"})}))}o.end(t.data)},unitConvert:function(e){return 1===this.scaleUnit&&e?100*e:e},poundToMm:function(e){return 25.4*e/72},mmToPound:function(e){return 72*e/25.4},unitConvertOfDrawBase:function(e,t){e=e||{};var n=t||[],r=n[3]||0,i=n[0]||0,a=n[4]||0,o=n[5]||0,s=e.x||0,u=e.y||0;return e.x=this.unitConvert(s+r+a),e.y=this.unitConvert(u+i+o),e.width=this.unitConvert(e.width),e.height=this.unitConvert(e.height),e.orientation&&e.orientation>3&&(e.orientation=e.orientation/90),e},unitConvertOfDrawRect:function(e,t){return(e=this.unitConvertOfDrawBase(e,t)).width=e.width||this.unitConvert(M),e.height=e.height||e.width,e.cornerWidth=this.unitConvert(e.cornerWidth),e.cornerHeight=this.unitConvert(e.cornerHeight)||e.cornerWidth,e.lineWidth=this.unitConvert(e.lineWidth||B),e},unitConvertOfLine:function(e,t){var n,r;e=e||{};var i=t||[],a=i[3]||0,o=i[0]||0,s=i[4]||0,u=i[5]||0,l=e.x1||0,c=e.y1||0,h=null!==(n=e.x2)&&void 0!==n?n:l,g=null!==(r=e.y2)&&void 0!==r?r:c;if(e.x1=this.unitConvert(l+a+s),e.y1=this.unitConvert(c+o+u),e.x2=this.unitConvert(h+a+s),e.y2=this.unitConvert(g+o+u),e.lineWidth=this.unitConvert(e.lineWidth||B),!e.dashLens&&xe.isArray(e.dashLen)?(e.dashLens=e.dashLen,e.dashLen=void 0):e.dashLen||"string"!=typeof e.dashLens||(e.dashLen=e.dashLens,e.dashLens=void 0),"string"==typeof e.dashLen&&(e.dashLens=e.dashLen.split(",")),e.dashLens&&e.dashLens.length>0){1===e.dashLens.length&&e.dashLens.push(e.dashLens[0]);for(var p=0;p<e.dashLens.length;p++)e.dashLens[p]=this.unitConvert(e.dashLens[p]);e.dashLen=e.dashLens.join(","),delete e.dashLens}return e.orientation&&e.orientation>3&&(e.orientation=e.orientation/90),e},checkTextOptions:function(e){if(e.fontHeight=xe.unitConvert(e.fontHeight),e.charSpace=xe.unitConvert(e.charSpace),"number"==typeof e.lineSpace&&(e.lineSpace=xe.unitConvert(e.lineSpace)),e.leadingIndent||(e.leadingIndentChars?(e.leadingIndent=10*e.leadingIndentChars,delete e.leadingIndentChars):e.leadingIndentMM?(e.leadingIndentMM>=.01?e.leadingIndent=100*e.leadingIndentMM+1e3:e.leadingIndentMM<=-.01&&(e.leadingIndent=100*e.leadingIndentMM-1e3),delete e.leadingIndentMM):e.leadingIndentColon&&(e.leadingIndent=1e3,delete e.leadingIndentColon)),0===e.leadingIndent&&delete e.leadingIndent,Array.isArray(e.regionCorners)){for(var t=0;t<e.regionCorners.length;t++)e.regionCorners[t]=xe.unitConvert(e.regionCorners[t]);e.regionCorners=e.regionCorners.join(",")}if(!e.regionCorners){var n=[];if(e.regionLeftUpCorner&&(n[0]=e.regionLeftUpCorner,delete e.regionLeftUpCorner),e.regionRightUpCorner&&(n[1]=e.regionRightUpCorner,delete e.regionRightUpCorner),e.regionRightBottomCorner&&(n[2]=e.regionRightBottomCorner,delete e.regionRightBottomCorner),e.regionLeftBottomCorner&&(n[3]=e.regionLeftBottomCorner,delete e.regionLeftBottomCorner),n.length>0){var r=[];for(t=0;t<4;t++){var i=n[t];if("string"==typeof i&&(i=i.split(",")),r[t]="0,0",Array.isArray(i)){i.length>2&&(i=i.slice(0,2));for(var a=0;a<2;a++)i[a]=xe.unitConvert(i[a]||0);r[t]=i.join(",")}}e.regionCorners=r.join(",")}}if(e.regionLeftBorders){var o=e.regionLeftBorders;if("string"==typeof e.regionLeftBorders&&(o=e.regionLeftBorders.split(",")),Array.isArray(o)&&o.length>2){for(t=0;t<o.length;t++)o[t]=xe.unitConvert(o[t]);e.regionLeftBorders=o.join(",")}else delete e.regionLeftBorders}if(e.regionRightBorders)if("string"==typeof(o=e.regionRightBorders)&&(o=o.split(",")),Array.isArray(o)&&o.length>2){for(t=0;t<o.length;t++)o[t]=xe.unitConvert(o[t]);e.regionRightBorders=o.join(",")}else delete e.regionRightBorders;return void 0!==e.text&&null!==e.text||(Array.isArray(e.texts)?e.text=e.texts.join("\n"):void 0!==e.texts&&null!==e.texts&&(e.text=e.texts)),e},getAgent:function(){return navigator.userAgent.toLowerCase()||""},isWin32:function(){var e=this.getAgent();return e.indexOf("win32")||e.indexOf("wow32")},isWin64:function(){var e=this.getAgent();return e.indexOf("win64")||e.indexOf("wow64")},isWindows:function(){var e=this.getAgent();return e.indexOf("win")>=0||e.indexOf("wow")>=0},isMac:function(){return/macintosh|mac os x/i.test(this.getAgent())},formatDate:function(e,t){var n,r=e||"HH:mm:ss.SSS",i={"y+":(t=t||new Date).getFullYear(),"M+":t.getMonth()+1,"d+":t.getDate(),"h+":t.getHours(),"H+":t.getHours(),"m+":t.getMinutes(),"s+":t.getSeconds(),"q+":Math.floor((t.getMonth()+3)/3),"S+":t.getMilliseconds()};for(var a in i)if(n=new RegExp("(".concat(a,")")).exec(r)){var o="".concat(i[a]),s="00".concat(o),u=n[1].length>s.length?0:s.length-n[1].length;r=r.replace(n[1],1===n[1].length?o:s.substring(u))}return r},arrayBufferToDataUrl:function(e){return btoa(new Uint8Array(e).reduce((function(e,t){return e+String.fromCharCode(t)}),""))},downloadDtpweb:function(e){var t=document.createElement("a");return t.href=e,t.click(),!0},parseXmlDocument:function(e){try{return e?(new DOMParser).parseFromString(e,"text/xml"):void 0}catch(e){console.warn("xml parse error:"),console.warn(e)}},getElementsByTagName:function(e,t,n){if(!e||!t||e.childElementCount<=0)return[];if(n){for(var r=[],i=0;i<e.childElementCount;i++){var a=e.children[i];a.tagName.toLowerCase()===t.toLocaleLowerCase()&&r.push(a)}return r}return e.getElementsByTagName(t)},getElementByTagName:function(e,t,n){return this.getElementsByTagName(e,t,n)[0]},getElementValue:function(e){try{return e.childNodes[0].nodeValue||""}catch(e){return""}},getElementValueByTagName:function(e,t){if(!t)return"";for(var n=t.split(";"),r=0;r<n.length;r++){var i=n[r];if(i){var a=this.getElementsByTagName(e,i);return a.length>0?this.getElementValue(a[0]):""}}},parseWdfxString:function(e){var t=this.parseXmlDocument(e),n=t?t.getElementsByTagName("LPAPI"):void 0;return n&&n.length>0?n[0]:void 0}},We=function(){function e(){}return e.parseEmbeddedImg=function(e){if(!e)return e;var t="*****",n=e.indexOf(t);if(n<0)return e;var r=e.substring(0,n).trim();return e=e.substring(n+5),"data:image/".concat(r,";base64,").concat(e)},e.parseBaseElement=function(e,t){var n=t||{},r=xe.getElementValueByTagName(e,"x"),i=xe.getElementValueByTagName(e,"y"),a=xe.getElementValueByTagName(e,"width"),o=xe.getElementValueByTagName(e,"height"),s=xe.getElementValueByTagName(e,"orientation;direction");return xe.isNumberString(r)&&(n.x=Number(r)),xe.isNumberString(i)&&(n.y=Number(i)),xe.isNumberString(a)&&(n.width=Number(a)),xe.isNumberString(o)&&(n.height=Number(o)),n.orientation=xe.getNumber(s),n},e.parseBorderElement=function(e,t){var n=this.parseBaseElement(e,t),r=xe.getElementValueByTagName(e,"filled"),i=xe.getElementValueByTagName(e,"lineWidth");return xe.isBooleanString(r)&&(n.fill=xe.getBoolean(r)),n.fill||(n.lineWidth=xe.getNumber(i,.5)),n},e.parseContentElement=function(e,t){var n=this.parseBaseElement(e,t),r=xe.getElementValueByTagName(e,"content"),i=xe.getElementValueByTagName(e,"contentType"),a=xe.getElementValueByTagName(e,"verAlignment"),o=xe.getElementValueByTagName(e,"horAlignment"),s=xe.getElementValueByTagName(e,"dataColumnName;dataName");return 2===xe.getNumber(i)?n.text=s?"[".concat(s,"]"):r||n.text||"":r&&(n.text=r),n.horizontalAlignment=xe.getNumber(o),n.verticalAlignment=xe.getNumber(a),n},e.parseFontTextElement=function(e,t){var n=this.parseContentElement(e,t),r=xe.getElementValueByTagName(e,"fontName"),i=xe.getElementValueByTagName(e,"fontHeight"),a=xe.getElementValueByTagName(e,"fontStyle");return r&&(n.fontName=r),xe.isNumberString(i)&&(n.fontHeight=Number(i)),xe.isNumberString(a)&&(n.fontStyle=Number(a)),n},e.parseTextElement=function(e,t){var n=this.parseFontTextElement(e),r=xe.getElementValueByTagName(e,"charSpace"),i=xe.getElementValueByTagName(e,"lineSpace"),a=xe.getElementValueByTagName(e,"autoReturn"),o={type:"text",text:"",autoReturn:xe.getNumber(a),lineSpace:i,charSpace:xe.getNumber(r)};return t.push(Object.assign(o,n)),o},e.parseDateTimeElement=function(e,t){var n=this.parseTextElement(e,t),r=xe.getElementValueByTagName(e,"dateFormat"),i=xe.getElementValueByTagName(e,"dateOffset;dateDiff"),a=xe.getElementValueByTagName(e,"timeFormat"),o=xe.getElementValueByTagName(e,"hourOffset;hourDiff"),s=xe.getElementValueByTagName(e,"minuteOffset;minuteDiff"),u=xe.getElementValueByTagName(e,"secondOffset;secondDiff"),l=xe.getNumber(i),c=xe.getNumber(o),h=xe.getNumber(s),g=xe.getNumber(u),p=new Date;if(l>0||c>0||h>0||g>0){var d=p.getTime();l>0&&(d+=864e5*l),c>0&&(d+=36e5*c),h>0&&(d+=6e4*h),g>0&&(d+=1e3*g),p.setTime(d)}return n.text=r&&a?xe.formatDate("".concat(r," ").concat(a)):r||a?xe.formatDate(r||a,p):xe.formatDate("yyyy年MM月dd日"),!0},e.parseArchTextElement=function(e,t){return!1},e.parse1DBarcodeElement=function(e,t){var n=this.parseFontTextElement(e),r=xe.getElementValueByTagName(e,"type;barcodeType"),i=xe.getElementValueByTagName(e,"textAlignment"),a=xe.getElementValueByTagName(e,"flags;barcodeFlags"),o=xe.getElementValueByTagName(e,"horAlignment"),s=xe.getNumber(r);void 0===n.text&&(s===u.LPA_1DBT_EAN13?n.text="690123456789":s===u.LPA_1DBT_EAN8?n.text="6901234":s===u.LPA_1DBT_UPC_A?n.text="69012345678":s===u.LPA_1DBT_UPC_E?n.text="0123456":s===u.LPA_1DBT_ISBN?n.text="978012345678":n.text="12345678");var l=xe.getNumber(a,2),c={type:"barcode",barcodeType:s>=20&&s<=30?s:u.LPA_1DBT_AUTO,textAlignment:xe.getNumber(i),textHeight:0===l?0:n.fontHeight,barcodeFlags:1===l?2:2===l?1:l};return t.push(Object.assign(c,n,{horizontalAlignment:xe.getNumber(o,1)})),!0},e.parse2DBarcodeElement=function(e,t){var n=this.parseContentElement(e,{text:"http://detonger.com/wdbq"}),r=xe.getElementValueByTagName(e,"eccLevel"),i=xe.getElementValueByTagName(e,"type;barcodeType"),a=xe.getElementValueByTagName(e,"pdf417EccLevel"),o=xe.getElementValueByTagName(e,"pdf417Cols"),s=xe.getElementValueByTagName(e,"dmCodeShape"),u=xe.getNumber(i);if(1===u){var l={type:"pdf417",eccLevel:xe.getNumber(a),codeColumns:xe.getNumber(o)};t.push(Object.assign(l,n))}else if(2===u){l={type:"dataMatrix",symbolShape:xe.getNumber(s)};t.push(Object.assign(l,n))}else{l={type:"qrcode",eccLevel:xe.getNumber(r)};t.push(Object.assign(l,n))}return!0},e.parseImageElement=function(e,t){var n=this.parseContentElement(e),r=xe.getElementValueByTagName(e,"threshold"),i=this.parseEmbeddedImg(n.text||"");n.text="";var a={type:"image",imageFile:i,threshold:xe.getNumber(r,192)};return t.push(Object.assign(a,n)),!0},e.parseRectangleElement=function(e,t){var n=this.parseBorderElement(e);if(!n.width||!n.height)return!1;var r,i=xe.getElementValueByTagName(e,"type;rectangleType"),a=xe.getElementValueByTagName(e,"cornerWidth"),o=xe.getNumber(i);return 1===o?(xe.isNumberString(a)&&(n.cornerWidth=Number(a)),r={type:"roundRectangle"}):2===o?r={type:"ellipse"}:3===o?(n.width&&n.height&&n.width>n.height?(n.x=(n.x||0)+.5*(n.width-n.height),n.width=n.height):(n.y=(n.y||0)+.5*(n.height-n.width),n.height=n.width),r={type:"ellipse"}):r={type:"rectangle"},t.push(Object.assign(r,n)),!0},e.parseLineElement=function(e,t){var n=this.parseBaseElement(e),r=xe.getElementValueByTagName(e,"x1"),i=xe.getElementValueByTagName(e,"x2"),a=xe.getElementValueByTagName(e,"y1"),o=xe.getElementValueByTagName(e,"y2"),s=xe.getElementValueByTagName(e,"type;lineType"),u=xe.getElementValueByTagName(e,"dashGap"),l=n.x||0,c=n.y||0,h=n.width||0,g=n.height||0;(r||i)&&(a||o)&&(l=xe.getNumber(r),h=xe.getNumber(i)-l,c=xe.getNumber(a),g=xe.getNumber(o)-c);var p,d={lineWidth:Math.min(h,g)};if(h>g?(d.x1=l,d.x2=l+h,d.y1=d.y2=c+.5*g):(d.y1=c,d.y2=c+g,d.x1=d.x2=l+.5*h),1===xe.getNumber(s)){var f=xe.getNumber(u,1);d.dashLens=[f,f],p={type:"dashLine"}}else p={type:"line"};return t.push(Object.assign(p,d)),!0},e.isInnerRect=function(e,t){return e.x>=t.x&&e.x+e.width<=t.x+t.width&&e.y>=t.y&&e.y+e.height<=t.y+t.height},e.parseTableElement=function(e,t){var n=this,r=this.parseBorderElement(e),i=r.x||0,a=r.y||0,o=r.lineWidth||.5,s=xe.getElementValueByTagName(e,"rows;row;rowCount"),u=xe.getElementValueByTagName(e,"cols;col;colCount"),l=xe.getElementValueByTagName(e,"rowHeight")||"",c=xe.getElementValueByTagName(e,"colWidth")||"",h=xe.getElementValueByTagName(e,"group")||"",g=xe.getNumber(s),p=xe.getNumber(u),d=l.split(",").map((function(e){return xe.getNumber(e)})),f=c.split(",").map((function(e){return xe.getNumber(e)})),m=h.split(";").map((function(e){var t=e.split(",").map((function(e){return xe.getNumber(e)}));return{x:t[1],y:t[0],width:t[3]-t[1],height:t[2]-t[0]}}));this.parseRectangleElement(e,t);var y=xe.getElementByTagName(e,"Cells");if(y&&y.children.length>0)for(var _=0;_<g;_++)for(var P=function(e){var s=y.children[_*p+e],u={x:e+1,y:_+1,width:0,height:0},l=m.filter((function(e){return n.isInnerRect(u,e)}));l.length>0&&(u.x===l[0].x&&u.y===l[0].y?(u.width=l[0].width,u.height=l[0].height):u.x=u.y=0);var c=function(e,t){return(e||0)+t};if(u.x>0&&u.y>0){var h={x:i+(u.x>1?f.slice(0,u.x-1).reduce(c,0)+o*e:0),y:a+(u.y>1?d.slice(0,u.y-1).reduce(c,0)+o*_:0),width:u.width>0?f.slice(u.x-1,u.x+u.width).reduce(c,0)+(u.width+1)*o:f[u.x-1],height:u.height>0?d.slice(u.y-1,u.y+u.height).reduce(c,0)+(u.height+1)*o:d[u.y-1],lineWidth:r.lineWidth};if(u.x>1){var g={type:"line",x1:h.x,y1:h.y,x2:h.x,y2:(h.y||0)+(h.height||0),lineWidth:r.lineWidth};t.push(g)}if(u.y>1){var P={type:"line",x1:h.x,y1:h.y,x2:(h.x||0)+(h.width||0),y2:h.y,lineWidth:r.lineWidth};t.push(P)}if("Text"===s.tagName){var v=A.parseTextElement(s,t);Object.assign(v,h)}}},A=this,v=0;v<p;v++)P(v)},e.parseLPAPIElement=function(e,t){var n=xe.getElementValueByTagName(e,"labelWidth;width"),r=xe.getElementValueByTagName(e,"labelHeight;height"),i=xe.getElementValueByTagName(e,"printOrientation;orientation;direction"),a=xe.getElementValueByTagName(e,"printHorOffset;horizontalOffset"),o=xe.getElementValueByTagName(e,"printVerOffset;verticalOffset"),s=xe.getElementValueByTagName(e,"gapType"),u=xe.getElementValueByTagName(e,"gapLength"),l=xe.getElementValueByTagName(e,"printDarkness;printStrength"),c=xe.getElementValueByTagName(e,"printSpeed"),h=xe.getElementValueByTagName(e,"background"),g=xe.getElementValueByTagName(e,"horFlip"),p={jobWidth:xe.getNumber(n),jobHeight:xe.getNumber(r),orientation:xe.getNumber(i),horizontalOffset:xe.getNumber(a),verticalOffset:xe.getNumber(o),horizontalFlip:xe.getNumber(g),printDarkness:xe.getNumber(l,255),printSpeed:xe.getNumber(c,255),gapType:xe.getNumber(s,255),gapLength:xe.getNumber(u,0)},d=[];if(!(p.jobWidth<=0||p.jobHeight<=0)){if(h){var f={type:"image",imageFile:this.parseEmbeddedImg(h),x:0,y:0,width:p.jobWidth,height:p.jobHeight};d.push(f)}var m=xe.getElementByTagName(e,"Page");if(m&&!(m.childElementCount<=0)){for(var y=0;y<m.children.length;y++){var _=m.children[y];"Text"===_.tagName||"String"===_.tagName?this.parseTextElement(_,d):"Barcode"===_.tagName?this.parse1DBarcodeElement(_,d):"Qrcode"===_.tagName?this.parse2DBarcodeElement(_,d):"Time"===_.tagName||"Date"===_.tagName?this.parseDateTimeElement(_,d):"Image"===_.tagName||"Photo"===_.tagName||"Logo"===_.tagName?this.parseImageElement(_,d):"Rectangle"===_.tagName||"Rect"===_.tagName||"Circle"===_.tagName||"Ellipse"===_.tagName?this.parseRectangleElement(_,d):"Line"===_.tagName?this.parseLineElement(_,d):"Table"===_.tagName?this.parseTableElement(_,d):"ArcText"===_.tagName?this.parseArchTextElement(_,d):console.warn("----不支持的绘制内容：".concat(_.tagName))}return{jobInfo:p,jobPages:[d]}}}},e}(),Me=void 0,je=function(){function t(){this._labelWidth=0,this._labelHeight=0,this._margins=[],this._localIPs=new Set,this._version=""}return t.checkServer=function(t){var n,r="function"==typeof t?{callback:t}:t||{},i=this.getInstance(r);return i.checkPlugin({clientType:r.clientType,callback:function(t){n=t.statusCode===e.LPA_Result.OK?i:void 0,r.callback&&r.callback(n,t)}}),n},t.getInstance=function(e){var n=Me||(Me=new t);return n.init(e),n},t.readAsDataURL=function(e,t){try{if(e instanceof Blob){var n=new FileReader;return n.onload=function(){t&&t(n.result)},n.onerror=function(e){console.warn(e),t&&t("")},n.readAsDataURL(e),!0}if(e instanceof ArrayBuffer){var r=xe.arrayBufferToDataUrl(e);return t(r)}return t(r="string"==typeof e?e:"")}catch(e){return console.warn(e),t("")}},t.isTransPrevJob=function(e){return!!e&&e.toUpperCase().startsWith("#!#trans")},t.isWhitePrevJob=function(e){return!!e&&e.toLowerCase().startsWith("#!#prev")},t.isPreviewJob=function(e){return!!e&&((e=e.toLowerCase()).startsWith("#!#trans")||e.startsWith("#!#prev"))},Object.defineProperty(t.prototype,"LastResponse",{get:function(){return this._Response},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"IsJsonMode",{get:function(){return this._jsonMode||!1},enumerable:!1,configurable:!0}),t.prototype.getIpAddress=function(e){return e||this._ip||this._initIp},t.prototype.getPort=function(e){return e||this._port||this._initPort},t.prototype.getTimeout=function(e,t){return e&&e>0?e:this._timeout&&this._timeout>0?this._timeout:this.isLocalPrinter(t)?E:I},t.prototype.getDeviceType=function(e){return e||this._deviceType},t.prototype.getFontName=function(e){return e||this._fontName||w},t.prototype.getFontHeight=function(e){return e||this._fontHeight||C},t.prototype.getLineWidth=function(e){return e||this._lineWidth||B},t.prototype.getRadius=function(e){return e||this._radius||W},t.prototype.getCornerWidth=function(e){return e||this._cornerWidth||x},t.prototype.parseMargin=function(e){this._margins.splice(0);for(var t=xe.parseMargin(e),n=0;n<4;n++)this._margins[n]=1*(t[n]||0);return this._margins},t.prototype.setFontName=function(e){this._fontName=e},t.prototype.setOffsetX=function(e){this._margins[4]=e},t.prototype.setOffsetY=function(e){this._margins[5]=e},t.prototype.init=function(e){var t=e||{};t.ip&&(this._initIp=t.ip),t.port&&(this._initPort=t.port),t.timeout&&(this._timeout=t.timeout),this._downloadUrl=t.downloadUrl,t.fontName&&(this._fontName=t.fontName),t.fontHeight&&(this._fontHeight=t.fontHeight),t.lineWidth&&(this._lineWidth=t.lineWidth),t.radius&&(this._radius=t.radius),this._showAlert="boolean"!=typeof t.showAlert||t.showAlert,this._jsonMode="boolean"!=typeof t.jsonMode||t.jsonMode,this._showLog="boolean"!=typeof t.showLog||t.showLog},t.prototype.logMsg=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(this._showLog){var r=xe.formatDate();console.log("[".concat(r,"]: ").concat(e)),console.log.apply(console,t)}},t.prototype.logObj=function(e){this._showLog&&console.log(e)},t.prototype.setServerInfo=function(e){var t;if(e){if((null===(t=e.selfIps)||void 0===t?void 0:t.length)>0)for(var n=0,r=e.selfIps;n<r.length;n++){var i=r[n];this._localIPs.add(i)}var a=(e.version||"").split("/");a.length>1&&(this._version=a[1])}},t.prototype.isLocalPrinter=function(e){var t="number"==typeof e?e:(null==e?void 0:e.type)||0;return this._version&&this._version>="2.3.2023.621"?t<10:t<=1},t.prototype.checkPlugin=function(n){var r=this,i="function"==typeof n?{callback:n}:n||{},a=function(n){if(n.statusCode===e.LPA_Result.OK)console.log("★★★ 打印助手运行正常 ★★★");else if((null==n?void 0:n.statusCode)===e.LPA_Result.NETWORK_ERROR&&"http:"===window.location.protocol)console.log("★★★ 不安全网络[http]环境下需要禁用对本地服务的拦截操作 ★★★"),r._showAlert&&window.prompt("检测到不安全的网络环境，如果需要在 http 环境下继续使用打印助手，请打开浏览器，然后在浏览器的地址栏输入下列链接，然后将浏览器的 [Block insecure private network requests] 标志切换到【disable】:",t.URL_BLOCK_PRIVATE_NETWORK);else{console.log("★★★ 未检测到打印助手 ★★★");var a=r._downloadUrl||t.URL_DTPWEB_DOWNLOAD;r._showAlert&&window.confirm("未检测到打印助手，是否要下载最新版本的打印助手？")&&window.open("".concat(a,"?protocol=").concat(window.location.protocol),"")}i.callback&&i.callback(n)},o={clientType:i.clientType};this.checkPort({port:N,params:o,callback:function(t){t.statusCode!==e.LPA_Result.OK?t.statusCode===e.LPA_Result.NETWORK_ERROR&&"http:"===window.location.protocol?a(t):r.checkPort({port:R,params:o,callback:a}):a(t)}})},t.prototype.checkPort=function(t){var n=this;this.logMsg("$$$$ DTPWEB request: checkPort(".concat(t.port,") $$$$"));var r=this._initIp||T,i=xe.getParamString(t.params||{}),a=i?"?".concat(i):"";Me||(Me=this),xe.request({host:r,port:t.port||this._port,url:"".concat(F,"/").concat(Oe).concat(a),sync:!1,timeout:this.getTimeout(0)},(function(i){if(n.logMsg("#### onResponse: checkPort(".concat(t.port,") ####"),i),i.statusCode<e.LPA_Result.NETWORK_FAILED){var a=i.resultInfo;n._initIp||(n._initIp=r),t.port&&(n._initPort=t.port),n.setServerInfo(a)}t.callback&&t.callback(i)}))},t.prototype.requestApi=function(t,n){var r=this,i=xe.getRequestData(["action"],[t]);this.logMsg("$$$$ DTPWEB request: ".concat(i.action," $$$$"),i),n&&this.logObj(n),n=n||{};var a=i.data||n.data;n.data&&(n.data=void 0);var o=xe.getParamString(i.params||n),s=o?"?".concat(o):"",u=i.control||q,l=this.getDeviceType(i.deviceType);this._Response=void 0,i.contentType===v.Json?a=JSON.stringify(a||n):i.contentType||(a=o);var c=we;i.contentType===v.Json?c=Be:i.contentType===v.Base64?c=Ce:i.contentType===v.Blob&&(c=Se);var h=this.isLocalPrinter(l)?void 0:i.ip,g={statusCode:e.LPA_Result.WAIT_FOR_ASYNC,resultInfo:void 0};return xe.request({method:"POST",host:this.getIpAddress(h),port:this.getPort(i.port),url:"".concat(u,"/").concat(i.action).concat(s),params:n,headers:{"Content-type":c},data:a,sync:!i.async,timeout:this.getTimeout(i.timeout,l)},(function(e){r.logMsg("#### onResponse: ".concat(i.action," ####"),e),r._Response=e,i.callback&&i.callback(e),g=e})),g},t.prototype.getVersion=function(t){var n="number"==typeof t?{clientType:t}:{},r=this.requestApi(U,n);return r.statusCode===e.LPA_Result.OK?r.resultInfo:void 0},t.prototype.getServerInfo=function(t){var n="number"==typeof t?{clientType:t}:{},r=this.requestApi(Oe,n);return r.statusCode===e.LPA_Result.OK?r.resultInfo:void 0},t.prototype.setSupportedPrinters=function(t){if(xe.isWindows())return this.requestApi(K,{supportedPrinters:t}).statusCode===e.LPA_Result.OK},t.prototype.getDefaultPrinter=function(){if(xe.isWindows()){var t=this.requestApi(V);return t.statusCode===e.LPA_Result.OK?t.resultInfo:void 0}},t.prototype.setDefaultPrinter=function(e){xe.isWindows()&&this.requestApi(H,{printerName:e})},t.prototype.discoveryPrinters=function(t){return this.requestApi(J,{mode:null!=t?t:1}).statusCode===e.LPA_Result.OK},t.prototype.getPrinters=function(e,t){var n;(e=xe.getRequestData(["onlyOnline"],[e])).onlyOnline="boolean"!=typeof e.onlyOnline||e.onlyOnline,e.onlySupported=!0;var r=this.requestApi({action:G,timeout:t||5e3},e);return this._deviceList=null===(n=r.resultInfo)||void 0===n?void 0:n.printers,this._deviceList||[]},t.prototype.getDeviceInfo=function(t){var n=this.requestApi("GetDeviceInfo",{printerName:t});return n.statusCode===e.LPA_Result.OK?n.resultInfo:{}},t.prototype.openPrinter=function(t,n){var r,i=this;"function"==typeof(r="string"==typeof t?/^\s*([A-Z]+[0-9]+)-([A-Z]?[0-9]{8,})\s*/.test(t)?{deviceName:t}:{name:t}:"function"==typeof t?{callback:t}:t||{}).callback&&(n=r.callback);var a=this.requestApi({action:$,ip:r.ip||this._initIp,port:r.port||this._initPort,deviceType:r.type,timeout:r.timeout||8e3,async:"boolean"!=typeof r.async||r.async,callback:function(t){if(t.statusCode===e.LPA_Result.OK){i.isLocalPrinter(r.type)?(i._ip=void 0,i._port=void 0):(i._ip=r.ip,i._port=r.port);var a=r.name||r.deviceName||r.printerName;r.type&&(i._deviceType=r.type),a&&(i._deviceName=a)}n&&n(t.statusCode===e.LPA_Result.OK)}},r);return a.statusCode===e.LPA_Result.OK||a.statusCode===e.LPA_Result.WAIT_FOR_ASYNC},t.prototype.getPrinterName=function(){return this.requestApi(Q).resultInfo},t.prototype.isPrinterOpened=function(){return this.requestApi(Y).statusCode===e.LPA_Result.OK},t.prototype.isPrinterOnline=function(){var t;return!!xe.isWindows()&&(null===(t=this.requestApi(z))||void 0===t?void 0:t.statusCode)===e.LPA_Result.OK},t.prototype.closePrinter=function(){return this.requestApi(X).statusCode===e.LPA_Result.OK},t.prototype.showProperty=function(t){return!!xe.isWindows()&&(t.showDocument="boolean"!=typeof t.showDocument||t.showDocument,this.requestApi(Z,t).statusCode===e.LPA_Result.OK)},t.prototype.getParam=function(t){var n=xe.getRequestData(["id"],[t]),r=this.requestApi(ne,n);return r.statusCode===e.LPA_Result.OK?r.resultInfo:-1},t.prototype.setParam=function(t){return t=xe.getRequestData(["id","value"],arguments),this.requestApi(re,t).statusCode===e.LPA_Result.OK},t.prototype.getGapType=function(){return this.getParam(e.LPA_ParamID.GapType)},t.prototype.setGapType=function(t){return this.setParam({id:e.LPA_ParamID.GapType,value:t})},t.prototype.getPrintDarkness=function(){return this.getParam(e.LPA_ParamID.PrintDarkness)},t.prototype.setPrintDarkness=function(t){return this.setParam({id:e.LPA_ParamID.PrintDarkness,value:t})},t.prototype.getPrintSpeed=function(){return this.getParam(e.LPA_ParamID.PrintSpeed)},t.prototype.setPrintSpeed=function(t){return this.setParam({id:e.LPA_ParamID.PrintSpeed,value:t})},t.prototype.getPrinterDPI=function(){var t=this.requestApi(ie);return t.statusCode===e.LPA_Result.OK?t.resultInfo:void 0},t.prototype.startJob=function(t){var n=this;t=xe.getRequestData(["width","height","orientation","jobName"],arguments);var r=this.parseMargin(t);this._labelWidth=t.width||D,this._labelHeight=t.height||O,this._pageStartedFunc=t.pageStarted,this._pageEndedFunc=t.pageEnded,xe.scaleUnit=this.IsJsonMode?0:1,t.scaleUnit=1,t.width=xe.unitConvert(t.width+r[1]+r[3]),t.height=xe.unitConvert(t.height+r[0]+r[2]),t.jobName=t.jobName||e.LPA_JobNames.Print;var i=t.printerName||this._deviceName;if(!i&&this._deviceList&&this._deviceList.length>0)for(var a=0,o=this._deviceList;a<o.length;a++){var s=o[a];if(this.isLocalPrinter(s)){i=s.name;break}}if(this.jobPrintResult=void 0,this.jobStartInfo={action:xe.getJobAction(t.jobName),jobPages:[],jobInfo:{jobWidth:t.width,jobHeight:t.height,orientation:t.orientation,jobName:t.jobName},printerInfo:{printerName:i}},this.IsJsonMode)return this.startPage();var u=this.requestApi({action:ue,callback:function(t){t.statusCode===e.LPA_Result.OK&&(n.pageInfo=[],n._pageStartedFunc&&n._pageStartedFunc(n))}},t);return u.statusCode===e.LPA_Result.OK||u.statusCode===e.LPA_Result.WAIT_FOR_ASYNC},t.prototype.startPrintJob=function(e,n){var r=this,i=e.jobName;if("function"==typeof e.callback&&(n=e.callback),t.isPreviewJob(i)){var a=this.startJob(e);return n&&n(a),a}var o="string"==typeof e.printer?{name:e.printer}:e.printer,s=this.openPrinter(o,(function(t){t&&r.startJob(e)?n&&n(!0):n&&n(!1)}));return!!s||(n&&n(s),!1)},t.prototype.abortJob=function(){this.IsJsonMode||this.requestApi(le)},t.prototype.commitJob=function(n){var r=this,i="function"==typeof n?{callback:n}:n||{};if(!this.jobStartInfo)return console.warn("===== 调用错误，未创建打印任务！====="),void(i.callback&&i.callback(void 0));Object.assign(this.jobStartInfo.jobInfo,xe.filterRecord(i,(function(e,t){return"function"!=typeof t})));var a=this.jobStartInfo,o=a.jobInfo,s=t.isPreviewJob(o.jobName);if("number"==typeof i.darkness&&(o.printDarkness=i.darkness),"number"==typeof i.speed&&(o.printSpeed=i.speed),s||("number"==typeof o.gapType&&this.setGapType(o.gapType),"number"==typeof o.printDarkness&&this.setPrintDarkness(o.printDarkness),"number"==typeof o.printSpeed&&this.setPrintSpeed(o.printSpeed)),this.IsJsonMode)return this.endPage(),this.print(Object.assign(a,{async:i.async,callback:function(e){r.jobPrintResult=e,i.callback&&i.callback(e)}}));var u={},l=this.requestApi({action:ce,timeout:6e4,async:i.async,callback:function(t){if(r.pageInfo&&(r.pageInfo=void 0,r._pageEndedFunc&&r._pageEndedFunc(r)),t.statusCode!==e.LPA_Result.OK)i.callback&&i.callback(void 0);else{if(s){var n=r.getPageInfo();if(n){u.width=n.width,u.height=n.height,u.previewData=[];for(var a=0;a<n.pages;a++){var o=r.getPageImage({page:a});u.previewData.push(o.data)}}}r.jobPrintResult=u,i.callback&&i.callback(u)}}},i);return l.statusCode===e.LPA_Result.OK||l.statusCode===e.LPA_Result.WAIT_FOR_ASYNC?u:void 0},t.prototype.setItemHorizontalAlignment=function(e){return this.requestApi(oe,{alignment:e})},t.prototype.setItemVerticalAlignment=function(e){return this.requestApi(se,{alignment:e})},t.prototype.setItemOrientation=function(e){return this.requestApi(ae,{orientation:e})},t.prototype.getJobID=function(){return xe.isWindows()?this.requestApi(he).resultInfo:0},t.prototype.getJobInfo=function(t){if(xe.isWindows()){var n=this.requestApi(ge,t);return n.statusCode===e.LPA_Result.OK?n.resultInfo:void 0}},t.prototype.getPageInfo=function(){return this.jobPrintResult&&this.jobPrintResult.previewData?{width:this.jobPrintResult.width||0,height:this.jobPrintResult.height||0,pages:this.jobPrintResult.previewData.length||0}:this.IsJsonMode?{width:0,height:0,pages:0}:this.requestApi(pe).resultInfo},t.prototype.getPageImage=function(e){var t=(e=xe.getRequestData(["page","format"],arguments)).page||0,n=this.jobPrintResult||{};return n.previewData&&n.previewData[t]?{page:t,data:n.previewData[t]}:this.IsJsonMode?{page:t,data:""}:this.requestApi(de,e).resultInfo},t.prototype.startPage=function(){if(!this.jobStartInfo)return!1;if(this.pageInfo&&this.pageInfo.length<=0)return!0;if(this.pageInfo&&this.pageInfo.length>0&&this.endPage(),this.pageInfo=[],this.IsJsonMode)return this._pageStartedFunc&&this._pageStartedFunc(this),!0;var t=this.requestApi(fe);return this._pageStartedFunc&&this._pageStartedFunc(this),t.statusCode===e.LPA_Result.OK},t.prototype.endPage=function(){if(!this.jobStartInfo||!this.pageInfo)return!1;if(this.pageInfo.length>0&&this.jobStartInfo.jobPages.push(this.pageInfo),this.pageInfo=void 0,this.IsJsonMode)return this._pageEndedFunc&&this._pageEndedFunc(this),!0;var t=this.requestApi(me);return this._pageEndedFunc&&this._pageEndedFunc(this),t.statusCode===e.LPA_Result.OK},t.prototype.returnDrawResult=function(t){var n,r=xe.getRequestData(["returnDrawResult"],[t]);return r.returnDrawResult=null===(n=r.returnDrawResult)||void 0===n||n,this.requestApi(ye,r).statusCode===e.LPA_Result.OK},t.prototype.mm2Pound=function(e){return xe.mmToPound(e)},t.prototype.pound2Mm=function(e){return xe.poundToMm(e)},t.prototype.drawText=function(t){return t=xe.getRequestData(["text","x","y","width","height","fontHeight","fontStyle"],arguments),!(!this.pageInfo||!t.text)&&(t.fontHeight=this.getFontHeight(t.fontHeight||t.height),t.fontName=this.getFontName(t.fontName),t=xe.unitConvertOfDrawBase(t,this._margins),xe.checkTextOptions(t),this.pageInfo.push(Object.assign(t,{type:e.LPA_DrawType.Text})),!!this.IsJsonMode||this.requestApi(_e,t).statusCode===e.LPA_Result.OK)},t.prototype.draw1DBarcode=function(t){return t=xe.getRequestData(["text","x","y","width","height","textHeight"],arguments),!(!this.pageInfo||!t.text)&&((t=xe.unitConvertOfDrawBase(t,this._margins)).textHeight=xe.unitConvert(t.textHeight),t.textBarSpace=xe.unitConvert(t.textBarSpace),t.fontName=this.getFontName(t.fontName),this.pageInfo.push(Object.assign(t,{type:e.LPA_DrawType.Barcode})),!!this.IsJsonMode||this.requestApi(Pe,t).statusCode===e.LPA_Result.OK)},t.prototype.draw2DQRCode=function(t){return t=xe.getRequestData(["text","x","y","width","height","eccLevel"],arguments),!(!this.pageInfo||!t.text)&&((t=xe.unitConvertOfDrawBase(t,this._margins)).height||(t.height=t.width),this.pageInfo.push(Object.assign(t,{type:e.LPA_DrawType.QRCode})),!!this.IsJsonMode||this.requestApi(Ae,t).statusCode===e.LPA_Result.OK)},t.prototype.draw2DPdf417=function(t){return t=xe.getRequestData(["text","x","y","width","height"],arguments),!(!this.pageInfo||!t.text)&&(t=xe.unitConvertOfDrawBase(t,this._margins),this.pageInfo.push(Object.assign(t,{type:e.LPA_DrawType.Pdf417})),!!this.IsJsonMode||this.requestApi(ve,t).statusCode===e.LPA_Result.OK)},t.prototype.draw2DDataMatrix=function(t){return t=xe.getRequestData(["text","x","y","width","height"],arguments),!(!this.pageInfo||!t.text)&&(t=xe.unitConvertOfDrawBase(t,this._margins),this.pageInfo.push(Object.assign(t,{type:e.LPA_DrawType.DataMatrix})),!!this.IsJsonMode||this.requestApi(Le,t).statusCode===e.LPA_Result.OK)},t.prototype.drawRectangle=function(t){return!!this.pageInfo&&((t=xe.getRequestData(["x","y","width","height","lineWidth"],arguments)).cornerWidth||t.cornerHeight?this.drawRoundRectangle(t):(t.lineWidth=this.getLineWidth(t.lineWidth),t=xe.unitConvertOfDrawRect(t,this._margins),this.pageInfo.push(Object.assign(t,{type:e.LPA_DrawType.Rect})),!!this.IsJsonMode||this.requestApi(be,t).statusCode===e.LPA_Result.OK))},t.prototype.drawRoundRectangle=function(t){return!!this.pageInfo&&((t=xe.getRequestData(["x","y","width","height","cornerWidth","lineWidth"],arguments)).cornerWidth=this.getCornerWidth(t.cornerWidth||t.cornerHeight),t.lineWidth=this.getLineWidth(t.lineWidth),t=xe.unitConvertOfDrawRect(t,this._margins),this.pageInfo.push(Object.assign(t,{type:e.LPA_DrawType.RoundRect})),!!this.IsJsonMode||this.requestApi(Te,t).statusCode===e.LPA_Result.OK)},t.prototype.drawEllipse=function(t){return!!this.pageInfo&&((t=xe.getRequestData(["x","y","width","height","lineWidth"],arguments)).lineWidth=this.getLineWidth(t.lineWidth),t=xe.unitConvertOfDrawRect(t,this._margins),this.pageInfo.push(Object.assign(t,{type:e.LPA_DrawType.Ellipse})),!!this.IsJsonMode||this.requestApi(Ne,t).statusCode===e.LPA_Result.OK)},t.prototype.drawCircle=function(e){e=xe.getRequestData(["x","y","radius","lineWidth"],arguments);var t=this.getRadius(e.radius),n=2*t;delete e.radius;var r=e;return r.x=(e.x||0)-t,r.y=(e.y||0)-t,r.width=r.height=n,this.drawEllipse(r)},t.prototype.drawLine=function(t){return!!this.pageInfo&&(((t=xe.getRequestData(["x1","y1","x2","y2","lineWidth"],arguments)).dashLens||t.dashLen||[]).length>0?this.drawDashLine(t):(t.lineWidth=this.getLineWidth(t.lineWidth),t=xe.unitConvertOfLine(t,this._margins),this.pageInfo.push(Object.assign(t,{type:e.LPA_DrawType.Line})),!!this.IsJsonMode||this.requestApi(Re,t).statusCode===e.LPA_Result.OK))},t.prototype.drawDashLine=function(t){return!!this.pageInfo&&(((t=xe.getRequestData(["x1","y1","x2","y2","dashLen","lineWidth"],arguments)).dashLen||t.dashLens||[]).length<1&&(t.dashLens=S),t.lineWidth=this.getLineWidth(t.lineWidth),t=xe.unitConvertOfLine(t,this._margins),this.pageInfo.push(Object.assign(t,{type:e.LPA_DrawType.DashLine})),!!this.IsJsonMode||this.requestApi(Ee,t).statusCode===e.LPA_Result.OK)},t.prototype.drawImage=function(t){return!!this.pageInfo&&(t=xe.getRequestData(["imageFile","x","y","width","height"],arguments),t=xe.unitConvertOfDrawBase(t,this._margins),this.pageInfo.push(Object.assign(t,{type:e.LPA_DrawType.Image})),!!this.IsJsonMode||this.requestApi(Ie,t).statusCode===e.LPA_Result.OK)},t.prototype.drawImageD=function(n){var r,i=this;return!!this.pageInfo&&((n=xe.getRequestData(["data","x","y","drawWidth","drawWidth"],arguments)).threshold=null!==(r=n.threshold)&&void 0!==r?r:j,n.width||(n.width=n.drawWidth),n.height||(n.height=n.drawHeight),n.drawWidth||(n.drawWidth=n.width),n.drawHeight||(n.drawHeight=n.height),(n=xe.unitConvertOfDrawBase(n,this._margins)).drawWidth=xe.unitConvert(n.drawWidth||this._labelWidth),n.drawHeight=xe.unitConvert(n.drawHeight||this._labelHeight),t.readAsDataURL(n.data,(function(t){return n.data=t,!(!t||!i.pageInfo)&&(n.imageFile=t,delete n.data,i.pageInfo.push(Object.assign(n,{type:e.LPA_DrawType.Image})),i.IsJsonMode?!!i.pageInfo:i.requestApi({action:De,contentType:v.Base64,data:t},n).statusCode===e.LPA_Result.OK)})))},t.prototype.printImage=function(n){var r=this;return(n=xe.getRequestData(["data","printerName"],arguments)).data?t.readAsDataURL(n.data,(function(t){var i;if(t){n.data=t,n.scaleUnit=1,n.printWidth=xe.unitConvert(n.printWidth),n.printHeight=xe.unitConvert(n.printHeight),n.threshold=null!==(i=n.threshold)&&void 0!==i?i:j,n.jobName=n.jobName||e.LPA_JobNames.Print;var a=r.requestApi({action:ee,contentType:v.Base64,data:t,timeout:18e4,callback:function(t){n.callback&&n.callback(t.statusCode===e.LPA_Result.OK)}},n);return a.statusCode===e.LPA_Result.OK||a.statusCode===e.LPA_Result.WAIT_FOR_ASYNC}return n.callback&&n.callback(!1),!1})):(n.callback&&n.callback(!1),!1)},t.prototype.print=function(t){var n,r;(t=t||{}).content&&delete(t=Object.assign({},JSON.parse(t.content),t)).content;var i=t.action||k,a=t.jobInfo||{};if(t.action&&delete t.action,a.copies&&a.copies>1){var o=t.jobPages.slice(0);if(!a.autoPage&&o.length>1){t.jobPages.splice(0);for(var s=0,u=o;s<u.length;s++){var l=u[s];(n=t.jobPages).push.apply(n,Array(a.copies).fill(l))}}else for(var c=1;c<a.copies;c++)(r=t.jobPages).push.apply(r,o)}var h=this.requestApi({action:te,timeout:6e4,contentType:v.Json,params:{action:i},data:t,async:t.async,callback:function(n){var r=(null==n?void 0:n.statusCode)===e.LPA_Result.OK?n.resultInfo:void 0;t.callback&&t.callback(r)}});return h.statusCode===e.LPA_Result.OK?h.resultInfo:void 0},t.prototype.printWdfx=function(e){var t=e||{},n=t.action||0,r=xe.parseWdfxString(e.content);if(!r)return console.warn("---- wdfx内容解析错误："),console.warn(e.content),void(e.callback&&e.callback(void 0));var i=We.parseLPAPIElement(r,!!(2&n)),a=t.jobInfo||{};Object.keys(a).forEach((function(e){null!==a[e]&&void 0!==a[e]||delete a[e]})),i?this.print({action:t.action,printerInfo:t.printerInfo,jobInfo:Object.assign(i.jobInfo||{},a),jobPages:i.jobPages,callback:t.callback}):(console.log("---- 数据解析失败！"),t.callback&&t.callback(void 0))},t.URL_DTPWEB_DOWNLOAD="https://weida.dothantech.com/assets/dtpweb/index.html",t.URL_BLOCK_PRIVATE_NETWORK="chrome://flags/#block-insecure-private-network-requests",t}();e.DTPWeb=je,e.checkServer=function(e){return je.checkServer(e)},e.getInstance=function(e){return je.getInstance(e)},Object.defineProperty(e,"__esModule",{value:!0})}));
