import{V as Dt,d as ut,r as jt,o as Bt,f as Lt,W as Nt,g as de,X as Ct,c as H,n as Ve,j as x,w as S,h as Gt,i as ae,F as Ft,y as zt,u as Ht}from"./index.js";var se={},J={},l={};Object.defineProperty(l,"__esModule",{value:!0});function Xt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var Ut=function t(e,r){Xt(this,t),this.data=e,this.text=r.text||e,this.options=r};l.default=Ut;Object.defineProperty(J,"__esModule",{value:!0});J.CODE39=void 0;var Vt=function(){function t(e,r){for(var n=0;n=200){u=n.shift()-105;var d=h.SWAP[u];d!==void 0?o=e.next(n,a+1,d):((i===h.SET_A||i===h.SET_B)&&u===h.SHIFT&&(n[0]=i===h.SET_A?n[0]>95?n[0]-96:n[0]:n[0]<32?n[0]+96:n[0]),o=e.next(n,a+1,i))}else u=e.correctIndex(n,i),o=e.next(n,a+1,i);var g=e.getBar(u),It=u*a;return{result:g+o.result,checksum:It+o.checksum}}}]),e}(ln.default);M.default=sn;var pe={};Object.defineProperty(pe,"__esModule",{value:!0});var O=f,_t=function(e){return e.match(new RegExp("^"+O.A_CHARS+"*"))[0].length},vt=function(e){return e.match(new RegExp("^"+O.B_CHARS+"*"))[0].length},st=function(e){return e.match(new RegExp("^"+O.C_CHARS+"*"))[0]};function ge(t,e){var r=e?O.A_CHARS:O.B_CHARS,n=t.match(new RegExp("^("+r+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(n)return n[1]+String.fromCharCode(204)+yt(t.substring(n[1].length));var a=t.match(new RegExp("^"+r+"+"))[0];return a.length===t.length?t:a+String.fromCharCode(e?205:206)+ge(t.substring(a.length),!e)}function yt(t){var e=st(t),r=e.length;if(r===t.length)return t;t=t.substring(r);var n=_t(t)>=vt(t);return e+String.fromCharCode(n?206:205)+ge(t,n)}pe.default=function(t){var e=void 0,r=st(t).length;if(r>=2)e=O.C_START_CHAR+yt(t);else{var n=_t(t)>vt(t);e=(n?O.A_START_CHAR:O.B_START_CHAR)+ge(t,n)}return e.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(a,i){return String.fromCharCode(203)+i})};Object.defineProperty(ye,"__esModule",{value:!0});var yn=M,pn=pt(yn),gn=pe,On=pt(gn);function pt(t){return t&&t.__esModule?t:{default:t}}function En(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ue(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:t}function bn(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var mn=function(t){bn(e,t);function e(r,n){if(En(this,e),/^[\x00-\x7F\xC8-\xD3]+$/.test(r))var a=ue(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,(0,On.default)(r),n));else var a=ue(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,r,n));return ue(a)}return e}(pn.default);ye.default=mn;var Oe={};Object.defineProperty(Oe,"__esModule",{value:!0});var wn=function(){function t(e,r){for(var n=0;nn.width*10?n.width*10:n.fontSize,a.guardHeight=n.height+a.fontSize/2+n.textMargin,a}return rr(e,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(n,a){return this.text.substr(n,a)}},{key:"leftEncode",value:function(n,a){return(0,Qe.default)(n,a)}},{key:"rightText",value:function(n,a){return this.text.substr(n,a)}},{key:"rightEncode",value:function(n,a){return(0,Qe.default)(n,a)}},{key:"encodeGuarded",value:function(){var n={fontSize:this.fontSize},a={height:this.guardHeight};return[{data:R.SIDE_BIN,options:a},{data:this.leftEncode(),text:this.leftText(),options:n},{data:R.MIDDLE_BIN,options:a},{data:this.rightEncode(),text:this.rightText(),options:n},{data:R.SIDE_BIN,options:a}]}},{key:"encodeFlat",value:function(){var n=[R.SIDE_BIN,this.leftEncode(),R.MIDDLE_BIN,this.rightEncode(),R.SIDE_BIN];return{data:n.join(""),text:this.text}}}]),e}(or.default);Q.default=lr;Object.defineProperty(me,"__esModule",{value:!0});var dr=function(){function t(e,r){for(var n=0;nn.width*10?a.fontSize=n.width*10:a.fontSize=n.fontSize,a.guardHeight=n.height+a.fontSize/2+n.textMargin,a}return Wr(e,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==he(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var n="";return n+="101",n+=(0,A.default)(this.data.substr(0,6),"LLLLLL"),n+="01010",n+=(0,A.default)(this.data.substr(6,6),"RRRRRR"),n+="101",{data:n,text:this.text}}},{key:"guardedEncoding",value:function(){var n=[];return this.displayValue&&n.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),n.push({data:"101"+(0,A.default)(this.data[0],"L"),options:{height:this.guardHeight}}),n.push({data:(0,A.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),n.push({data:"01010",options:{height:this.guardHeight}}),n.push({data:(0,A.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),n.push({data:(0,A.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&n.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),n}}]),e}(Zr.default);function he(t){var e=0,r;for(r=1;r<11;r+=2)e+=parseInt(t[r]);for(r=0;r<11;r+=2)e+=parseInt(t[r])*3;return(10-e%10)%10}C.default=na;var Se={};Object.defineProperty(Se,"__esModule",{value:!0});var ra=function(){function t(e,r){for(var n=0;nn.width*10?a.fontSize=n.width*10:a.fontSize=n.fontSize,a.guardHeight=n.height+a.fontSize/2+n.textMargin,a}return ra(e,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var n="";return n+="101",n+=this.encodeMiddleDigits(),n+="010101",{data:n,text:this.text}}},{key:"guardedEncoding",value:function(){var n=[];return this.displayValue&&n.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),n.push({data:"101",options:{height:this.guardHeight}}),n.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),n.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&n.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),n}},{key:"encodeMiddleDigits",value:function(){var n=this.upcA[0],a=this.upcA[this.upcA.length-1],i=ha[parseInt(a)][parseInt(n)];return(0,ia.default)(this.middleDigits,i)}}]),e}(ua.default);function Ke(t,e){for(var r=parseInt(t[t.length-1]),n=da[r],a="",i=0,o=0;o=3&&this.number<=131070}}]),e}(Ui.default);Z.pharmacode=Qi;var K={};Object.defineProperty(K,"__esModule",{value:!0});K.codabar=void 0;var Yi=function(){function t(e,r){for(var n=0;n0?e.fontSize+e.textMargin:0)+e.marginTop+e.marginBottom}function St(t,e,r){if(r.displayValue&&ee&&(e=t[r].height);return e}function Io(t,e,r){var n;if(r)n=r;else if(typeof document<"u")n=document.createElement("canvas").getContext("2d");else return 0;n.font=e.fontOptions+" "+e.fontSize+"px "+e.font;var a=n.measureText(t);if(!a)return 0;var i=a.width;return i}_.getMaximumHeightOfEncodings=ko;_.getEncodingHeight=xt;_.getBarcodePadding=St;_.calculateEncodingAttributes=To;_.getTotalWidthOfEncodings=Mo;Object.defineProperty(Le,"__esModule",{value:!0});var Do=function(){function t(e,r){for(var n=0;n0?(o=0,a.textAlign="left"):r.textAlign=="right"?(o=n.width-1,a.textAlign="right"):(o=n.width/2,a.textAlign="center"),a.fillText(n.text,o,u)}}},{key:"moveCanvasDrawing",value:function(r){var n=this.canvas.getContext("2d");n.translate(r.width,0)}},{key:"restoreCanvas",value:function(){var r=this.canvas.getContext("2d");r.restore()}}]),t}();Le.default=Co;var Ne={};Object.defineProperty(Ne,"__esModule",{value:!0});var Go=function(){function t(e,r){for(var n=0;n0&&(this.drawRect(d-n.width*u,o,n.width*u,n.height,r),u=0);u>0&&this.drawRect(d-n.width*(u-1),o,n.width*u,n.height,r)}},{key:"drawSVGText",value:function(r,n,a){var i=this.document.createElementNS(q,"text");if(n.displayValue){var o,u;i.setAttribute("style","font:"+n.fontOptions+" "+n.fontSize+"px "+n.font),n.textPosition=="top"?u=n.fontSize-n.textMargin:u=n.height+n.textMargin+n.fontSize,n.textAlign=="left"||a.barcodePadding>0?(o=0,i.setAttribute("text-anchor","start")):n.textAlign=="right"?(o=a.width-1,i.setAttribute("text-anchor","end")):(o=a.width/2,i.setAttribute("text-anchor","middle")),i.setAttribute("x",o),i.setAttribute("y",u),i.appendChild(this.document.createTextNode(a.text)),r.appendChild(i)}}},{key:"setSvgAttributes",value:function(r,n){var a=this.svg;a.setAttribute("width",r+"px"),a.setAttribute("height",n+"px"),a.setAttribute("x","0px"),a.setAttribute("y","0px"),a.setAttribute("viewBox","0 0 "+r+" "+n),a.setAttribute("xmlns",q),a.setAttribute("version","1.1"),a.setAttribute("style","transform: translate(0,0)")}},{key:"createGroup",value:function(r,n,a){var i=this.document.createElementNS(q,"g");return i.setAttribute("transform","translate("+r+", "+n+")"),a.appendChild(i),i}},{key:"setGroupOptions",value:function(r,n){r.setAttribute("style","fill:"+n.lineColor+";")}},{key:"drawRect",value:function(r,n,a,i,o){var u=this.document.createElementNS(q,"rect");return u.setAttribute("x",r),u.setAttribute("y",n),u.setAttribute("width",a),u.setAttribute("height",i),o.appendChild(u),u}}]),t}();Ne.default=Uo;var Ce={};Object.defineProperty(Ce,"__esModule",{value:!0});var Vo=function(){function t(e,r){for(var n=0;n"u"?"undefined":au(t))==="object"&&!t.nodeName)return{element:t,renderer:N.default.ObjectRenderer};throw new uu.InvalidElementException}}function fu(t){var e=document.querySelectorAll(t);if(e.length!==0){for(var r=[],n=0;n"u")throw Error("No element to render on was provided.");return a._renderProperties=(0,gu.default)(e),a._encodings=[],a._options=Tt.default,a._errorHandler=new mu.default(a),typeof r<"u"&&(n=n||{},n.format||(n.format=kt()),a.options(n)[n.format](r,n).render()),a};re.getModule=function(t){return b.default[t]};for(var ot in b.default)b.default.hasOwnProperty(ot)&&$u(b.default,ot);function $u(t,e){p.prototype[e]=p.prototype[e.toUpperCase()]=p.prototype[e.toLowerCase()]=function(r,n){var a=this;return a._errorHandler.wrapBarcodeCall(function(){n.text=typeof n.text>"u"?void 0:""+n.text;var i=(0,z.default)(a._options,n);i=(0,Eu.default)(i);var o=t[e],u=Mt(r,o,i);return a._encodings.push(u),a})}}function Mt(t,e,r){t=""+t;var n=new e(t,r);if(!n.valid())throw new Pt.InvalidInputException(n.constructor.name,t);var a=n.encode();a=(0,At.default)(a);for(var i=0;i{const n={...e.options,format:e.type};Su(r.value,e.text,n)}),(n,a)=>(de(),Lt(Nt(t.tag),{ref_key:"wrapEl",ref:r},null,512))}}),Au=Ct(Ru),Pu={class:"font-medium"},Mu=ut({name:"BarCode",__name:"barcode",setup(t){const e=[{text:"CODE128",type:"CODE128",options:{}},{text:"CODE39",type:"CODE39",options:{lineColor:"#990000"}},{text:"123456",type:"pharmacode",options:{background:"#eee",width:5}}];return(r,n)=>{const a=H("el-link"),i=H("el-card"),o=H("el-col"),u=H("el-row");return de(),Ve("div",null,[x(i,{shadow:"never"},{header:S(()=>[Gt("div",Pu,[ae(" 条形码(基于 "),x(a,{href:"https://lindell.me/JsBarcode/",target:"_blank",style:{margin:"0 5px 4px 0","font-size":"16px"}},{default:S(()=>[ae(" JsBarcode ")]),_:1}),ae(" 生成) ")])]),default:S(()=>[x(u,{gutter:12},{default:S(()=>[(de(),Ve(Ft,null,zt(e,(d,g)=>x(o,{key:g,xs:24,sm:24,md:12,lg:8,xl:8},{default:S(()=>[x(i,{shadow:"hover",class:"flex justify-center"},{default:S(()=>[x(Ht(Au),{text:d.text,type:d.type,options:d.options},null,8,["text","type","options"])]),_:2},1024)]),_:2},1024)),64))]),_:1})]),_:1})])}}});export{Mu as default}; //# sourceMappingURL=barcode.js.map