/*! Build based on gin-vue-admin Time : 1757946830000 */ import{s as t,_ as e,l as o,g as r,c as i,o as a,f as n,w as s,v as l,aj as c,h,x as u,E as d,a as g,t as f,b as p,z as m,A as v,y,B as w,F as b,I as C,i as x,a0 as A,C as k,d as B}from"./index.DlqNVRUO.js";import{I as D,i as P,a as T}from"./image.GvU-S7BA.js";import{M as _}from"./vue-cropper.es.DpMT2N2c.js";const E=e=>t({url:"/fileUploadAndDownload/getFileList",method:"post",data:e}),S=e=>t({url:"/fileUploadAndDownload/deleteFile",method:"post",data:e}),R=e=>t({url:"/fileUploadAndDownload/editFileName",method:"post",data:e}),L=e=>t({url:"/fileUploadAndDownload/importURL",method:"post",data:e}),I=e(Object.assign({name:"UploadImage"},{__name:"image",props:{imageUrl:{type:String,default:""},fileSize:{type:Number,default:2048},maxWH:{type:Number,default:1920},classId:{type:Number,default:0}},emits:["on-success"],setup(t,{emit:e}){const g=e,f=t,p=o().token,m=t=>{var e,o;const r="image/jpeg"===(null==(e=t.type)?void 0:e.toLowerCase()),i="image/png"===(null==(o=t.type)?void 0:o.toLowerCase());if(!r&&!i)return d.error("上传头像图片只能是 jpg或png 格式!"),!1;const a=t.size/1024{const{data:e}=t;e.file&&g("on-success",e.file.url)};return(t,e)=>{const o=r("el-button"),d=r("el-upload");return a(),i("div",null,[n(d,{action:"".concat(l(u)(),"/fileUploadAndDownload/upload"),"show-file-list":!1,"on-success":v,"before-upload":m,multiple:!1,data:{classId:f.classId},headers:{"x-token":l(p)}},{default:s(()=>[n(o,{type:"primary",icon:l(c)},{default:s(()=>[...e[0]||(e[0]=[h("压缩上传",-1)])]),_:1},8,["icon"])]),_:1},8,["action","data","headers"])])}}}),[["__scopeId","data-v-a36ab207"]]),M=Object.assign({name:"UploadCommon"},{__name:"common",props:{classId:{type:Number,default:0}},emits:["on-success"],setup(t,{emit:e}){const f=o().token,p=t,m=e,v=g(!1),y=t=>{v.value=!0;const e=t.size/1024/1024<.5,o=t.size/1024/1024<5,r=P(t.type),i=T(t.type);let a=!0;return r||i||(d.error("上传图片只能是 jpg,png,svg,webp 格式, 上传视频只能是 mp4,webm 格式!"),v.value=!1,a=!1),!o&&r&&(d.error("上传视频大小不能超过 5MB"),v.value=!1,a=!1),!e&&i&&(d.error("未压缩的上传图片大小不能超过 500KB,请使用压缩上传"),v.value=!1,a=!1),a},w=t=>{const{data:e}=t;e.file&&m("on-success",e.file.url)},b=()=>{d({type:"error",message:"上传失败"}),v.value=!1};return(t,e)=>{const o=r("el-button"),d=r("el-upload");return a(),i("div",null,[n(d,{action:"".concat(l(u)(),"/fileUploadAndDownload/upload"),"before-upload":y,"on-error":b,"on-success":w,"show-file-list":!1,data:{classId:p.classId},headers:{"x-token":l(f)},multiple:"",class:"upload-btn"},{default:s(()=>[n(o,{type:"primary",icon:l(c)},{default:s(()=>[...e[0]||(e[0]=[h("普通上传",-1)])]),_:1},8,["icon"])]),_:1},8,["action","data","headers"])])}}}),N=()=>t({url:"/attachmentCategory/getCategoryList",method:"get"}),O=e=>t({url:"/attachmentCategory/addCategory",method:"post",data:e}),U=e=>t({url:"/attachmentCategory/deleteCategory",method:"post",data:e}),j={class:"flex gap-[30px] h-[600px]"},z={class:"flex flex-col flex-1"},F={class:"flex-1 bg-[#f8f8f8] rounded-lg overflow-hidden"},H={class:"mt-[20px] flex items-center p-[10px] bg-white rounded-lg shadow-[0_2px_12px_rgba(0,0,0,0.1)]"},G={class:"w-[340px]"},q={class:"bg-white p-5 rounded-lg shadow-[0_2px_12px_rgba(0,0,0,0.1)]"},Q={class:"w-full h-full relative overflow-hidden"},K=["src"],V={class:"dialog-footer"},X=e(Object.assign({name:"CropperImage"},{__name:"cropper",props:{classId:{type:Number,default:0}},emits:["on-success"],setup(t,{emit:e}){const o=e,c=t,B=g(null),D=g(!1),P=g(""),T=g(null),{proxy:E}=f(),S=g({}),R=g(!1),L=t=>{E.$refs.cropperRef.changeScale(t)},I=g([{label:"1:1",value:[1,1]},{label:"16:9",value:[16,9]},{label:"9:16",value:[9,16]},{label:"4:3",value:[4,3]},{label:"自由比例",value:[]}]),M=g([1,1]),N=g(300),O=g(300),U=g(!1),X=g(4),$=()=>{switch(M.value=I.value[X.value].value,X.value){case 0:N.value=300,O.value=300,U.value=!0;break;case 1:N.value=300,O.value=168.75,U.value=!0;break;case 2:N.value=168.75,O.value=300,U.value=!0;break;case 3:N.value=300,O.value=225,U.value=!0;break;default:N.value=300,O.value=300,U.value=!1}},W=t=>{if(!t.raw.type.includes("image"))return void d.error("请选择图片文件");if(t.raw.size/1024/1024>8)return d.error("文件大小不能超过8MB!"),!1;const e=new FileReader;e.onload=t=>{P.value=t.target.result,D.value=!0},e.readAsDataURL(t.raw)},Y=t=>{-90===t?E.$refs.cropperRef.rotateLeft():E.$refs.cropperRef.rotateRight()},J=t=>{S.value=t},Z=()=>{R.value=!0,E.$refs.cropperRef.getCropBlob(t=>{try{const e=new File([t],"".concat(Date.now(),".jpg"),{type:"image/jpeg"});B.value.clearFiles(),B.value.handleStart(e),B.value.submit()}catch(e){R.value=!1,d.error("上传失败: "+e.message)}})},tt=t=>{const{data:e}=t;e&&setTimeout(()=>{R.value=!1,D.value=!1,S.value={},d.success("上传成功"),o("on-success",e.url)},1e3)};return(t,e)=>{const o=r("el-button"),d=r("el-upload"),g=r("el-tooltip"),f=r("el-button-group"),E=r("el-option"),et=r("el-select"),ot=r("el-dialog");return a(),i(b,null,[n(d,{ref_key:"uploadRef",ref:B,action:"".concat(l(u)(),"/fileUploadAndDownload/upload"),accept:"image/*","show-file-list":!1,"auto-upload":!1,data:{classId:c.classId},"on-success":tt,"on-change":W,headers:{"x-token":t.token}},{default:s(()=>[n(o,{type:"primary",icon:"crop"},{default:s(()=>[...e[8]||(e[8]=[h(" 裁剪上传",-1)])]),_:1})]),_:1},8,["action","data","headers"]),n(ot,{modelValue:D.value,"onUpdate:modelValue":e[6]||(e[6]=t=>D.value=t),title:"图片裁剪",width:"1200px","append-to-body":"",onClose:e[7]||(e[7]=t=>D.value=!1),"close-on-click-modal":!1,draggable:""},{footer:s(()=>[p("div",V,[n(o,{onClick:e[5]||(e[5]=t=>D.value=!1)},{default:s(()=>[...e[10]||(e[10]=[h("取 消",-1)])]),_:1}),n(o,{type:"primary",onClick:Z,loading:R.value},{default:s(()=>[h(k(R.value?"上传中...":"上 传"),1)]),_:1},8,["loading"])])]),default:s(()=>[p("div",j,[p("div",z,[p("div",F,[n(l(_),{ref_key:"cropperRef",ref:T,img:P.value,outputType:"jpeg",autoCrop:!0,autoCropWidth:N.value,autoCropHeight:O.value,fixedBox:!1,fixed:U.value,fixedNumber:M.value,centerBox:!0,canMoveBox:!0,full:!1,maxImgSize:1200,original:!0,onRealTime:J},null,8,["img","autoCropWidth","autoCropHeight","fixed","fixedNumber"])]),p("div",H,[n(f,null,{default:s(()=>[n(g,{content:"向左旋转"},{default:s(()=>[n(o,{onClick:e[0]||(e[0]=t=>Y(-90)),icon:l(m)},null,8,["icon"])]),_:1}),n(g,{content:"向右旋转"},{default:s(()=>[n(o,{onClick:e[1]||(e[1]=t=>Y(90)),icon:l(v)},null,8,["icon"])]),_:1}),n(o,{icon:l(y),onClick:e[2]||(e[2]=t=>L(1))},null,8,["icon"]),n(o,{icon:l(w),onClick:e[3]||(e[3]=t=>L(-1))},null,8,["icon"])]),_:1}),n(et,{modelValue:X.value,"onUpdate:modelValue":e[4]||(e[4]=t=>X.value=t),placeholder:"选择比例",class:"w-32 ml-4",onChange:$},{default:s(()=>[(a(!0),i(b,null,C(I.value,(t,e)=>(a(),x(E,{key:e,label:t.label,value:e},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])])]),p("div",G,[p("div",q,[e[9]||(e[9]=p("div",{class:"mb-[15px] text-gray-600"},"裁剪预览",-1)),p("div",{class:"bg-white p-5 rounded-lg shadow-[0_2px_12px_rgba(0,0,0,0.1)]",style:A({width:S.value.w+"px",height:S.value.h+"px"})},[p("div",Q,[p("img",{src:S.value.url,style:A(S.value.img),alt:"",class:"max-w-none absolute transition-all duration-300 ease-in-out image-render-pixelated origin-[0_0]"},null,12,K)])],4)])])])]),_:1},8,["modelValue"])],64)}}}),[["__scopeId","data-v-5a05348c"]]);function $(t){return""===t?t:"true"===t||"1"==t}function W(t){if("string"!=typeof t)throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}function Y(t,e){for(var o,r="",i=0,a=-1,n=0,s=0;s<=t.length;++s){if(s2){var l=r.lastIndexOf("/");if(l!==r.length-1){-1===l?(r="",i=0):i=(r=r.slice(0,l)).length-1-r.lastIndexOf("/"),a=s,n=0;continue}}else if(2===r.length||1===r.length){r="",i=0,a=s,n=0;continue}e&&(r.length>0?r+="/..":r="..",i=2)}else r.length>0?r+="/"+t.slice(a+1,s):r=t.slice(a+1,s),i=s-a-1;a=s,n=0}else 46===o&&-1!==n?++n:n=-1}return r}var J={resolve:function(){for(var t,e="",o=!1,r=arguments.length-1;r>=-1&&!o;r--){var i;r>=0?i=arguments[r]:(void 0===t&&(t=process.cwd()),i=t),W(i),0!==i.length&&(e=i+"/"+e,o=47===i.charCodeAt(0))}return e=Y(e,!o),o?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(t){if(W(t),0===t.length)return".";var e=47===t.charCodeAt(0),o=47===t.charCodeAt(t.length-1);return 0!==(t=Y(t,!e)).length||e||(t="."),t.length>0&&o&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return W(t),t.length>0&&47===t.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var t,e=0;e0&&(void 0===t?t=o:t+="/"+o)}return void 0===t?".":J.normalize(t)},relative:function(t,e){if(W(t),W(e),t===e)return"";if((t=J.resolve(t))===(e=J.resolve(e)))return"";for(var o=1;os){if(47===e.charCodeAt(a+c))return e.slice(a+c+1);if(0===c)return e.slice(a+c)}else i>s&&(47===t.charCodeAt(o+c)?l=c:0===c&&(l=0));break}var h=t.charCodeAt(o+c);if(h!==e.charCodeAt(a+c))break;47===h&&(l=c)}var u="";for(c=o+l+1;c<=r;++c)c!==r&&47!==t.charCodeAt(c)||(0===u.length?u+="..":u+="/..");return u.length>0?u+e.slice(a+l):(a+=l,47===e.charCodeAt(a)&&++a,e.slice(a))},_makeLong:function(t){return t},dirname:function(t){if(W(t),0===t.length)return".";for(var e=t.charCodeAt(0),o=47===e,r=-1,i=!0,a=t.length-1;a>=1;--a)if(47===(e=t.charCodeAt(a))){if(!i){r=a;break}}else i=!1;return-1===r?o?"/":".":o&&1===r?"//":t.slice(0,r)},basename:function(t,e){if(void 0!==e&&"string"!=typeof e)throw new TypeError('"ext" argument must be a string');W(t);var o,r=0,i=-1,a=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var n=e.length-1,s=-1;for(o=t.length-1;o>=0;--o){var l=t.charCodeAt(o);if(47===l){if(!a){r=o+1;break}}else-1===s&&(a=!1,s=o+1),n>=0&&(l===e.charCodeAt(n)?-1===--n&&(i=o):(n=-1,i=s))}return r===i?i=s:-1===i&&(i=t.length),t.slice(r,i)}for(o=t.length-1;o>=0;--o)if(47===t.charCodeAt(o)){if(!a){r=o+1;break}}else-1===i&&(a=!1,i=o+1);return-1===i?"":t.slice(r,i)},extname:function(t){W(t);for(var e=-1,o=0,r=-1,i=!0,a=0,n=t.length-1;n>=0;--n){var s=t.charCodeAt(n);if(47!==s)-1===r&&(i=!1,r=n+1),46===s?-1===e?e=n:1!==a&&(a=1):-1!==e&&(a=-1);else if(!i){o=n+1;break}}return-1===e||-1===r||0===a||1===a&&e===r-1&&e===o+1?"":t.slice(e,r)},format:function(t){if(null===t||"object"!=typeof t)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return function(t,e){var o=e.dir||e.root,r=e.base||(e.name||"")+(e.ext||"");return o?o===e.root?o+r:o+t+r:r}("/",t)},parse:function(t){W(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;var o,r=t.charCodeAt(0),i=47===r;i?(e.root="/",o=1):o=0;for(var a=-1,n=0,s=-1,l=!0,c=t.length-1,h=0;c>=o;--c)if(47!==(r=t.charCodeAt(c)))-1===s&&(l=!1,s=c+1),46===r?-1===a?a=c:1!==h&&(h=1):-1!==a&&(h=-1);else if(!l){n=c+1;break}return-1===a||-1===s||0===h||1===h&&a===s-1&&a===n+1?-1!==s&&(e.base=e.name=0===n&&i?t.slice(1,s):t.slice(n,s)):(0===n&&i?(e.name=t.slice(1,a),e.base=t.slice(1,s)):(e.name=t.slice(n,a),e.base=t.slice(n,s)),e.ext=t.slice(a,s)),n>0?e.dir=t.slice(0,n-1):i&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};J.posix=J;const Z=J.extname,tt=J.basename;class et{constructor(){let t=(()=>"undefined"==typeof global)(),e="image/png",o="image/jpeg",r="image/jpeg",i="image/webp",a="application/pdf",n="image/svg+xml";Object.assign(this,{toMime:this.toMime.bind(this),fromMime:this.fromMime.bind(this),expected:t?'"png", "jpg", or "webp"':'"png", "jpg", "pdf", or "svg"',formats:t?{png:e,jpg:o,jpeg:r,webp:i}:{png:e,jpg:o,jpeg:r,pdf:a,svg:n},mimes:t?{[e]:"png",[o]:"jpg",[i]:"webp"}:{[e]:"png",[o]:"jpg",[a]:"pdf",[n]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}class ot{static for(t){return(new ot).append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=0|this.crc,o=this.table,r=0,i=0|t.length;r>>8^o[255&(e^t[r])];return this.crc=e,this}}function rt(t){let e=new Uint8Array(t),o=new DataView(e.buffer),r={array:e,view:o,size:t,set8:(t,e)=>(o.setUint8(t,e),r),set16:(t,e)=>(o.setUint16(t,e,!0),r),set32:(t,e)=>(o.setUint32(t,e,!0),r),bytes:(t,o)=>(e.set(o,t),r)};return r}ot.prototype.table=(()=>{var t,e,o,r=[];for(t=0;t<256;t++){for(o=t,e=0;e<8;e++)o=1&o?o>>>1^3988292384:o>>>1;r[t]=o}return r})();class it{constructor(t){let e=new Date;Object.assign(this,{directory:t,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(t)}async add(t,e){let o=!e,r=it.encoder.encode("".concat(this.directory,"/").concat(o?"":t)),i=new Uint8Array(o?0:await e.arrayBuffer()),a=30+r.length,n=a+i.length,{offset:s}=this,l=rt(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,ot.for(i)).set32(14,i.length).set32(18,i.length).set16(22,r.length);s+=a;let c=rt(a+i.length+16).set32(0,67324752).bytes(4,l.array).bytes(30,r).bytes(a,i);s+=i.length,c.set32(n,134695760).bytes(n+4,l.array.slice(10,22)),s+=16,this.files.push({offset:s,folder:o,name:r,header:l,payload:c}),this.offset=s}toBuffer(){let t=this.files.reduce((t,{name:e})=>46+e.length+t,0),e=rt(t+22),o=0;for(var{offset:r,name:i,header:a,folder:n}of this.files)e.set32(o,33639248).set16(o+4,20).bytes(o+6,a.array).set8(o+38,n?16:0).set32(o+42,r).bytes(o+46,i),o+=46+i.length;e.set32(o,101010256).set16(o+8,this.files.length).set16(o+10,this.files.length).set32(o+12,t).set32(o+16,this.offset);let s=new Uint8Array(this.offset+e.size),l=0;for(var{payload:c}of this.files)s.set(c.array,l),l+=c.size;return s.set(e.array,l),s}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}}it.encoder=new TextEncoder;const at=(t,e,o,r)=>{if(r){let{width:e,height:o}=t,i=Object.assign(document.createElement("canvas"),{width:e,height:o}),a=i.getContext("2d");a.fillStyle=r,a.fillRect(0,0,e,o),a.drawImage(t,0,0),t=i}return new Promise((r,i)=>t.toBlob(r,e,o))},nt=(t,e)=>{const o=window.URL.createObjectURL(e),r=document.createElement("a");r.style.display="none",r.href=o,r.setAttribute("download",t),void 0===r.download&&r.setAttribute("target","_blank"),document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>window.URL.revokeObjectURL(o),100)},st={asBuffer:(...t)=>at(...t).then(t=>t.arrayBuffer()),asDownload:async(t,e,o,r,i)=>{nt(i,await at(t,e,o,r))},asZipDownload:async(t,e,o,r,i,a,n)=>{let s=tt(i,".zip")||"archive",l=new it(s);await Promise.all(t.map(async(t,i)=>{let s=(t=>a.replace("{}",String(t+1).padStart(n,"0")))(i);await l.add(s,await at(t,e,o,r))})),nt("".concat(s,".zip"),l.blob)},atScale:(t,e,o)=>t.map(t=>{if(1==e&&!o)return t.canvas;let r=document.createElement("canvas"),i=r.getContext("2d"),a=t.canvas?t.canvas:t;return r.width=a.width*e,r.height=a.height*e,o&&(i.fillStyle=o,i.fillRect(0,0,r.width,r.height)),i.scale(e,e),i.drawImage(a,0,0),r}),options:function(t,{filename:e="",extension:o="",format:r,page:i,quality:a,matte:n,density:s,outline:l,archive:c}={}){var{fromMime:h,toMime:u,expected:d}=new et,g=(c=c||"canvas",r||o.replace(/@\d+x$/i,"")||Z(e)),f=(r=h(u(g)||g),u(r)),p=t.length;if(!g)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!r)throw new Error('Unsupported file format "'.concat(g,'" (expected ').concat(d,")"));if(!p)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let m,v,y=e.replace(/{(\d*)}/g,(t,e)=>(v=!0,e=parseInt(e,10),m=isFinite(e)?e:isFinite(m)?m:-1,"{}")),w=i>0?i-1:i<0?p+i:void 0;if(isFinite(w)&&w<0||w>=p)throw new RangeError(1==p?"Canvas only has a ‘page 1’ (".concat(w," is out of bounds)"):"Canvas has pages 1–".concat(p," (").concat(w," is out of bounds)"));if(t=isFinite(w)?[t[w]]:v||"pdf"==r?t:t.slice(-1),void 0===a)a=.92;else if("number"!=typeof a||!isFinite(a)||a<0||a>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(void 0===s){let t=(o||tt(e,g)).match(/@(\d+)x$/i);s=t?parseInt(t[1],10):1}else if("number"!=typeof s||!Number.isInteger(s)||s<1)throw new TypeError("The density option must be a non-negative integer");return void 0===l?l=!0:"svg"==r&&(l=!!l),{filename:e,pattern:y,format:r,mime:f,pages:t,padding:m,quality:a,matte:n,density:s,outline:l,archive:c}}},{asBuffer:lt,asDownload:ct,asZipDownload:ht,atScale:ut,options:dt}=st,gt=Symbol.for("toDataURL");const ft={Canvas:class{constructor(t,e){let o=document.createElement("canvas"),r=[];for(var[i,a]of(Object.defineProperty(o,"async",{value:!0,writable:!1,enumerable:!0}),Object.entries({png:()=>lt(o,"image/png"),jpg:()=>lt(o,"image/jpeg"),pages:()=>r.concat(o).map(t=>t.getContext("2d"))})))Object.defineProperty(o,i,{get:a});return Object.assign(o,{width:t,height:e,newPage(...t){var{width:e,height:i}=o,a=Object.assign(document.createElement("canvas"),{width:e,height:i});a.getContext("2d").drawImage(o,0,0),r.push(a);var[e,i]=t.length?t:[e,i];return Object.assign(o,{width:e,height:i}).getContext("2d")},saveAs(t,e){e="number"==typeof e?{quality:e}:e;let o=dt(this.pages,{filename:t,...e}),{pattern:r,padding:i,mime:a,quality:n,matte:s,density:l,archive:c}=o,h=ut(o.pages,l);return null==i?ct(h[0],a,n,s,t):ht(h,a,n,s,c,r,i)},toBuffer(t="png",e={}){e="number"==typeof e?{quality:e}:e;let o=dt(this.pages,{extension:t,...e}),{mime:r,quality:i,matte:a,pages:n,density:s}=o,l=ut(n,s,a)[0];return lt(l,r,i,a)},[gt]:o.toDataURL.bind(o),toDataURL(t="png",e={}){e="number"==typeof e?{quality:e}:e;let r=dt(this.pages,{extension:t,...e}),{mime:i,quality:a,matte:n,pages:s,density:l}=r,c=ut(s,l,n)[0],h=c[c===o?gt:"toDataURL"](i,a);return Promise.resolve(h)}})}}},pt=(t,e,o={},r=o)=>{if(Array.isArray(e))e.forEach(e=>pt(t,e,o,r));else if("function"==typeof e)e(t,o,r,pt);else{const i=Object.keys(e)[0];Array.isArray(e[i])?(r[i]={},pt(t,e[i],o,r[i])):r[i]=e[i](t,o,r,pt)}return o},mt=(t,e)=>(o,r,i,a)=>{e(o,r,i)&&a(o,t,r,i)},vt=()=>t=>t.data[t.pos++],yt=(t=0)=>e=>e.data[e.pos+t],wt=t=>e=>e.data.subarray(e.pos,e.pos+=t),bt=t=>e=>e.data.subarray(e.pos,e.pos+t),Ct=t=>e=>Array.from(wt(t)(e)).map(t=>String.fromCharCode(t)).join(""),xt=t=>e=>{const o=wt(2)(e);return t?(o[1]<<8)+o[0]:(o[0]<<8)+o[1]},At=(t,e)=>(o,r,i)=>{const a="function"==typeof e?e(o,r,i):e,n=wt(t),s=new Array(a);for(var l=0;le=>{const o=(t=>t.data[t.pos++])(e),r=new Array(8);for(var i=0;i<8;i++)r[7-i]=!!(o&1<{const i=t[o];return i.length?e[o]=((t,e,o)=>{for(var r=0,i=0;i{const e=[],o=t.data.length;for(var r=0,i=(t=>t.data[t.pos++])(t);0!==i&&i;i=vt()(t)){if(t.pos+i>=o){const i=o-t.pos;e.push(wt(i)(t)),r+=i;break}e.push(wt(i)(t)),r+=i}const a=new Uint8Array(r);for(var n=0,s=0;st.data[t.pos++]},{extras:kt({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:xt(!0)},{transparentColorIndex:t=>t.data[t.pos++]},{terminator:t=>t.data[t.pos++]}]},t=>{var e=bt(2)(t);return 33===e[0]&&249===e[1]}),Pt=mt({image:[{code:t=>t.data[t.pos++]},{descriptor:[{left:xt(!0)},{top:xt(!0)},{width:xt(!0)},{height:xt(!0)},{lct:kt({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},mt({lct:At(3,(t,e,o)=>Math.pow(2,o.descriptor.lct.size+1))},(t,e,o)=>o.descriptor.lct.exists),{data:[{minCodeSize:t=>t.data[t.pos++]},Bt]}]},t=>44===yt()(t)),Tt=mt({text:[{codes:wt(2)},{blockSize:t=>t.data[t.pos++]},{preData:(t,e,o)=>wt(o.text.blockSize)(t)},Bt]},t=>{var e=bt(2)(t);return 33===e[0]&&1===e[1]}),_t=mt({application:[{codes:wt(2)},{blockSize:t=>t.data[t.pos++]},{id:(t,e,o)=>Ct(o.blockSize)(t)},Bt]},t=>{var e=bt(2)(t);return 33===e[0]&&255===e[1]}),Et=mt({comment:[{codes:wt(2)},Bt]},t=>{var e=bt(2)(t);return 33===e[0]&&254===e[1]}),St=[{header:[{signature:Ct(3)},{version:Ct(3)}]},{lsd:[{width:xt(!0)},{height:xt(!0)},{gct:kt({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:t=>t.data[t.pos++]},{pixelAspectRatio:t=>t.data[t.pos++]}]},mt({gct:At(3,(t,e)=>Math.pow(2,e.lsd.gct.size+1))},(t,e)=>e.lsd.gct.exists),{frames:(Rt=[Dt,_t,Et,Pt,Tt],Lt=t=>{var e=yt()(t);return 33===e||44===e},(t,e,o,r)=>{const i=[];let a=t.pos;for(;Lt(t,e,o);){const o={};if(r(t,Rt,e,o),t.pos===a)break;a=t.pos,i.push(o)}return i})}];var Rt,Lt;const It=(t,e,o)=>{if(!t.image)return;const{image:r}=t,i=r.descriptor.width*r.descriptor.height;var a=((t,e,o)=>{const r=4096,i=o;var a,n,s,l,c,h,u,d,g,f;const p=new Array(o),m=new Array(r),v=new Array(r),y=new Array(4097);for(c=1+(n=1<<(f=t)),a=n+2,u=-1,s=(1<<(l=f+1))-1,d=0;d>=l,b-=l,d>a||d==c)break;if(d==n){s=(1<<(l=f+1))-1,a=n+2,u=-1;continue}if(-1==u){y[x++]=v[d],u=d,C=d;continue}for(h=d,d==a&&(y[x++]=C,d=u);d>n;)y[x++]=v[d],d=m[d];C=255&v[d],y[x++]=C,a{const o=new Array(t.length),r=t.length/e,i=function(r,i){const a=t.slice(i*e,(i+1)*e);o.splice.apply(o,[r*e,e].concat(a))},a=[0,4,2,1],n=[8,8,4,2];for(var s=0,l=0;l<4;l++)for(var c=a[l];c{const e=t.pixels.length,o=new Uint8ClampedArray(4*e);for(var r=0;r65536?(t[0]=240|(1835008&r)>>>18,t[1]=128|(258048&r)>>>12,t[2]=128|(4032&r)>>>6,t[3]=128|63&r):r>2048?(t[0]=224|(61440&r)>>>12,t[1]=128|(4032&r)>>>6,t[2]=128|63&r):r>128?(t[0]=192|(1984&r)>>>6,t[1]=128|63&r):t[0]=r,e.push(t)}this.parsedData=Array.prototype.concat.apply([],e),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}getLength(){return this.parsedData.length}write(t){for(let e=0,o=this.parsedData.length;eKt.length)throw new Error("Too long data");return o}(t,this.errorCorrectLevel);else{if(this.typeNumber>40)throw new Error("Invalid QR version: ".concat(this.typeNumber));if(!function(t,e,o){const r=Mt(e),i=t-1;let a=0;switch(o){case Ut.L:a=Kt[i][0];break;case Ut.M:a=Kt[i][1];break;case Ut.Q:a=Kt[i][2];break;case Ut.H:a=Kt[i][3]}return r<=a}(this.typeNumber,t,this.errorCorrectLevel))throw new Error("Data is too long for QR version: ".concat(this.typeNumber))}const e=new Nt(t);this.dataList.push(e),this.dataCache=void 0}isDark(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error("".concat(t,",").concat(e));return this.modules[t][e]}getModuleCount(){return this.moduleCount}make(){this.makeImpl(!1,this.getBestMaskPattern())}makeImpl(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(let o=0;o=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=Ot.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)}setupPositionProbePattern(t,e){for(let o=-1;o<=7;o++)if(!(t+o<=-1||this.moduleCount<=t+o))for(let r=-1;r<=7;r++)e+r<=-1||this.moduleCount<=e+r||(this.modules[t+o][e+r]=0<=o&&o<=6&&(0==r||6==r)||0<=r&&r<=6&&(0==o||6==o)||2<=o&&o<=4&&2<=r&&r<=4)}getBestMaskPattern(){if(Number.isInteger(this.maskPattern)&&Object.values(zt).includes(this.maskPattern))return this.maskPattern;let t=0,e=0;for(let o=0;o<8;o++){this.makeImpl(!0,o);const r=Ft.getLostPoint(this);(0==o||t>r)&&(t=r,e=o)}return e}setupTimingPattern(){for(let t=8;t>o&1);this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=r}for(o=0;o<18;o++){r=!t&&1==(e>>o&1);this.modules[o%3+this.moduleCount-8-3][Math.floor(o/3)]=r}}setupTypeInfo(t,e){const o=this.errorCorrectLevel<<3|e,r=Ft.getBCHTypeInfo(o);for(var i=0;i<15;i++){var a=!t&&1==(r>>i&1);i<6?this.modules[i][8]=a:i<8?this.modules[i+1][8]=a:this.modules[this.moduleCount-15+i][8]=a}for(i=0;i<15;i++){a=!t&&1==(r>>i&1);i<8?this.modules[8][this.moduleCount-i-1]=a:i<9?this.modules[8][15-i-1+1]=a:this.modules[8][15-i-1]=a}this.modules[this.moduleCount-8][8]=!t}mapData(t,e){let o=-1,r=this.moduleCount-1,i=7,a=0;for(let n=this.moduleCount-1;n>0;n-=2)for(6==n&&n--;;){for(let o=0;o<2;o++)if(null==this.modules[r][n-o]){let s=!1;a>>i&1));Ft.getMask(e,r,n-o)&&(s=!s),this.modules[r][n-o]=s,i--,-1==i&&(a++,i=7)}if(r+=o,r<0||this.moduleCount<=r){r-=o,o=-o;break}}}static createData(t,e,o){const r=qt.getRSBlocks(t,e),i=new Qt;for(var a=0;a8*n)throw new Error("code length overflow. (".concat(i.getLengthInBits(),">").concat(8*n,")"));for(i.getLengthInBits()+4<=8*n&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*n||(i.put(Ot.PAD0,8),i.getLengthInBits()>=8*n));)i.put(Ot.PAD1,8);return Ot.createBytes(i,r)}static createBytes(t,e){let o=0,r=0,i=0;const a=new Array(e.length),n=new Array(e.length);for(var s=0;s=0?d.get(t):0}}let c=0;for(l=0;l=0;)e^=Ft.G15<=0;)e^=Ft.G18<>>=1;return e}static getPatternPosition(t){return Ft.PATTERN_POSITION_TABLE[t-1]}static getMask(t,e,o){switch(t){case zt.PATTERN000:return(e+o)%2==0;case zt.PATTERN001:return e%2==0;case zt.PATTERN010:return o%3==0;case zt.PATTERN011:return(e+o)%3==0;case zt.PATTERN100:return(Math.floor(e/2)+Math.floor(o/3))%2==0;case zt.PATTERN101:return e*o%2+e*o%3==0;case zt.PATTERN110:return(e*o%2+e*o%3)%2==0;case zt.PATTERN111:return(e*o%3+(e+o)%2)%2==0;default:throw new Error("bad maskPattern:".concat(t))}}static getErrorCorrectPolynomial(t){let e=new Gt([1],0);for(let o=0;o5&&(o+=3+a-5)}for(r=0;r=256;)t-=255;return Ht.EXP_TABLE[t]}}Ht.EXP_TABLE=new Array(256),Ht.LOG_TABLE=new Array(256),Ht._constructor=function(){for(var t=0;t<8;t++)Ht.EXP_TABLE[t]=1<>>7-t%8&1)}put(t,e){for(let o=0;o>>e-o-1&1))}getLengthInBits(){return this.length}putBit(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}}const Kt=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];var Vt=256,Xt=1024,$t=1<<18;function Wt(t,e){var o,r,i,a,n;function s(t,e,r,i,a){o[e][0]-=t*(o[e][0]-r)/Xt,o[e][1]-=t*(o[e][1]-i)/Xt,o[e][2]-=t*(o[e][2]-a)/Xt}function l(t,e,r,i,a){for(var s,l,c=Math.abs(e-t),h=Math.min(e+t,Vt),u=e+1,d=e-1,g=1;uc;)l=n[g++],uc&&((s=o[d--])[0]-=l*(s[0]-r)/$t,s[1]-=l*(s[1]-i)/$t,s[2]-=l*(s[2]-a)/$t)}function c(t,e,r){var n,s,l,c,h,u=2147483647,d=u,g=-1,f=g;for(n=0;n>12))>10,a[n]-=h,i[n]+=h<<10;return a[g]+=64,i[g]-=65536,f}this.buildColormap=function(){!function(){var t,e;for(o=[],r=new Int32Array(256),i=new Int32Array(Vt),a=new Int32Array(Vt),n=new Int32Array(32),t=0;t>6;for(y<=1&&(y=0),o=0;o=d&&(w-=d),0===p&&(p=1),++o%p===0)for(m-=m/g,(y=(v-=v/30)>>6)<=1&&(y=0),u=0;u>=4,o[t][1]>>=4,o[t][2]>>=4,o[t][3]=t}(),function(){var t,e,i,a,n,s,l=0,c=0;for(t=0;t>1,e=l+1;e>1,e=l+1;e<256;e++)r[e]=255}()},this.getColormap=function(){for(var t=[],e=[],r=0;r=0;)h=l?h=Vt:(h++,s<0&&(s=-s),(a=n[0]-t)<0&&(a=-a),(s+=a)=0&&((s=e-(n=o[u])[1])>=l?u=-1:(u--,s<0&&(s=-s),(a=n[0]-t)<0&&(a=-a),(s+=a)=254&&A(e)}function C(t){x(Yt),y=l+2,w=!0,D(l,t)}function x(t){for(var e=0;e0&&(t.writeByte(a),t.writeBytes(f,0,a),a=0)}function k(t){return(1<0?i|=t<=8;)b(255&i,e),i>>=8,v-=8;if((y>n||w)&&(w?(n=k(d=s),w=!1):(++d,n=12==d?4096:k(d))),t==c){for(;v>0;)b(255&i,e),i>>=8,v-=8;A(e)}}this.encode=function(o){o.writeByte(g),h=t*e,u=0,function(t,e){var o,r,i,h,u,g,f;for(w=!1,n=k(d=s=t),c=1+(l=1<=0){u=g-i,0===i&&(u=1);do{if((i-=u)<0&&(i+=g),p[i]===o){h=m[i];continue t}}while(p[i]>=0)}D(h,e),h=r,y<4096?(m[i]=y++,p[i]=o):C(e)}else h=m[i];D(h,e),D(c,e)}(g+1,o),o.writeByte(0)}}function te(){this.page=-1,this.pages=[],this.newPage()}te.pageSize=4096,te.charMap={};for(var ee=0;ee<256;ee++)te.charMap[ee]=String.fromCharCode(ee);function oe(t,e){this.width=~~t,this.height=~~e,this.transparent=null,this.transIndex=0,this.repeat=-1,this.delay=0,this.image=null,this.pixels=null,this.indexedPixels=null,this.colorDepth=null,this.colorTab=null,this.neuQuant=null,this.usedEntry=new Array,this.palSize=7,this.dispose=-1,this.firstFrame=!0,this.sample=10,this.dither=!1,this.globalPalette=!1,this.out=new te}te.prototype.newPage=function(){this.pages[++this.page]=new Uint8Array(te.pageSize),this.cursor=0},te.prototype.getData=function(){for(var t="",e=0;et+e.length,0));return t.reduce((t,e)=>(o.set(e,t),t+e.length),0),o},te.prototype.writeByte=function(t){this.cursor>=te.pageSize&&this.newPage(),this.pages[this.page][this.cursor++]=t},te.prototype.writeUTFBytes=function(t){for(var e=t.length,o=0;o=0&&(this.dispose=t)},oe.prototype.setRepeat=function(t){this.repeat=t},oe.prototype.setTransparent=function(t){this.transparent=t},oe.prototype.addFrame=function(t){this.image=t,this.colorTab=this.globalPalette&&this.globalPalette.slice?this.globalPalette:null,this.getImagePixels(),this.analyzePixels(),!0===this.globalPalette&&(this.globalPalette=this.colorTab),this.firstFrame&&(this.writeHeader(),this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.globalPalette||this.writePalette(),this.writePixels(),this.firstFrame=!1},oe.prototype.finish=function(){this.out.writeByte(59)},oe.prototype.setQuality=function(t){t<1&&(t=1),this.sample=t},oe.prototype.setDither=function(t){!0===t&&(t="FloydSteinberg"),this.dither=t},oe.prototype.setGlobalPalette=function(t){this.globalPalette=t},oe.prototype.getGlobalPalette=function(){return this.globalPalette&&this.globalPalette.slice&&this.globalPalette.slice(0)||this.globalPalette},oe.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")},oe.prototype.analyzePixels=function(){this.colorTab||(this.neuQuant=new Wt(this.pixels,this.sample),this.neuQuant.buildColormap(),this.colorTab=this.neuQuant.getColormap()),this.dither?this.ditherPixels(this.dither.replace("-serpentine",""),null!==this.dither.match(/-serpentine/)):this.indexPixels(),this.pixels=null,this.colorDepth=8,this.palSize=7,null!==this.transparent&&(this.transIndex=this.findClosest(this.transparent,!0))},oe.prototype.indexPixels=function(t){var e=this.pixels.length/3;this.indexedPixels=new Uint8Array(e);for(var o=0,r=0;r=0&&C+h=0&&x+c>16,(65280&t)>>8,255&t,e)},oe.prototype.findClosestRGB=function(t,e,o,r){if(null===this.colorTab)return-1;if(this.neuQuant&&!r)return this.neuQuant.lookupRGB(t,e,o);for(var i=0,a=16777216,n=this.colorTab.length,s=0,l=0;s=0&&(e=7&this.dispose),e<<=2,this.out.writeByte(0|e|t),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)},oe.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame||this.globalPalette?this.out.writeByte(0):this.out.writeByte(128|this.palSize)},oe.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)},oe.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)},oe.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var t=768-this.colorTab.length,e=0;e>8&255)},oe.prototype.writePixels=function(){new Zt(this.width,this.height,this.indexedPixels,this.colorDepth).encode(this.out)},oe.prototype.stream=function(){return this.out};var re=function(t,e,o,r){return new(o||(o=Promise))(function(i,a){function n(t){try{l(r.next(t))}catch(e){a(e)}}function s(t){try{l(r.throw(t))}catch(e){a(e)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof o?e:new o(function(t){t(e)})).then(n,s)}l((r=r.apply(t,e||[])).next())})};const{Canvas:ie}=ft,ae=.4;function ne(t){if(t)return new Promise(function(o,r){if("data"==t.slice(0,4)){let i=new Image;return i.onload=function(){o(i),e(i)},i.onerror=function(){r("Image load error"),e(i)},void(i.src=t)}let i=new Image;i.setAttribute("crossOrigin","Anonymous"),i.onload=function(){o(i)},i.onerror=function(){r("Image load error")},i.src=t});function e(t){t.onload=null,t.onerror=null}}class se{constructor(t){const e=Object.assign({},t);if(Object.keys(se.defaultOptions).forEach(t=>{t in e||Object.defineProperty(e,t,{value:se.defaultOptions[t],enumerable:!0,writable:!0})}),e.components?"object"==typeof e.components&&Object.keys(se.defaultComponentOptions).forEach(t=>{t in e.components?Object.defineProperty(e.components,t,{value:Object.assign(Object.assign({},se.defaultComponentOptions[t]),e.components[t]),enumerable:!0,writable:!0}):Object.defineProperty(e.components,t,{value:se.defaultComponentOptions[t],enumerable:!0,writable:!0})}):e.components=se.defaultComponentOptions,null!==e.dotScale&&void 0!==e.dotScale){if(e.dotScale<=0||e.dotScale>1)throw new Error("dotScale should be in range (0, 1].");e.components.data.scale=e.dotScale,e.components.timing.scale=e.dotScale,e.components.alignment.scale=e.dotScale}this.options=e,this.canvas=new ie(t.size,t.size),this.canvasContext=this.canvas.getContext("2d"),this.qrCode=new Ot(-1,this.options.correctLevel),Number.isInteger(this.options.maskPattern)&&(this.qrCode.maskPattern=this.options.maskPattern),Number.isInteger(this.options.version)&&(this.qrCode.typeNumber=this.options.version),this.qrCode.addData(this.options.text),this.qrCode.make()}draw(){return new Promise(t=>this._draw().then(t))}_clear(){this.canvasContext.clearRect(0,0,this.canvas.width,this.canvas.height)}static _prepareRoundedCornerClip(t,e,o,r,i,a){t.beginPath(),t.moveTo(e,o),t.arcTo(e+r,o,e+r,o+i,a),t.arcTo(e+r,o+i,e,o+i,a),t.arcTo(e,o+i,e,o,a),t.arcTo(e,o,e+r,o,a),t.closePath()}static _getAverageRGB(t){const e={r:0,g:0,b:0};let o,r,i=-4;const a={r:0,g:0,b:0};let n=0;r=t.naturalHeight||t.height,o=t.naturalWidth||t.width;const s=new ie(o,r).getContext("2d");if(!s)return e;let l;s.drawImage(t,0,0);try{l=s.getImageData(0,0,o,r)}catch(c){return e}for(;(i+=20)200||l.data[i+1]>200||l.data[i+2]>200||(++n,a.r+=l.data[i],a.g+=l.data[i+1],a.b+=l.data[i+2]);return a.r=~~(a.r/n),a.g=~~(a.g/n),a.b=~~(a.b/n),a}static _drawDot(t,e,o,r,i=0,a=1){t.fillRect((e+i)*r,(o+i)*r,a*r,a*r)}static _drawAlignProtector(t,e,o,r){t.clearRect((e-2)*r,(o-2)*r,5*r,5*r),t.fillRect((e-2)*r,(o-2)*r,5*r,5*r)}static _drawAlign(t,e,o,r,i=0,a=1,n,s){const l=t.fillStyle;t.fillStyle=n,new Array(4).fill(0).map((n,s)=>{se._drawDot(t,e-2+s,o-2,r,i,a),se._drawDot(t,e+2,o-2+s,r,i,a),se._drawDot(t,e+2-s,o+2,r,i,a),se._drawDot(t,e-2,o+2-s,r,i,a)}),se._drawDot(t,e,o,r,i,a),s||(t.fillStyle="rgba(255, 255, 255, 0.6)",new Array(2).fill(0).map((n,s)=>{se._drawDot(t,e-1+s,o-1,r,i,a),se._drawDot(t,e+1,o-1+s,r,i,a),se._drawDot(t,e+1-s,o+1,r,i,a),se._drawDot(t,e-1,o+1-s,r,i,a)})),t.fillStyle=l}_draw(){var t,e,o,r,i,a,n,s,l,c,h,u,d,g,f,p,m,v,y;return re(this,void 0,void 0,function*(){const w=null===(t=this.qrCode)||void 0===t?void 0:t.moduleCount,b=this.options.size;let C=this.options.margin;(C<0||2*C>=b)&&(C=0);const x=Math.ceil(C),A=b-2*C,k=this.options.whiteMargin,B=this.options.backgroundDimming,D=Math.ceil(A/w),P=D*w,T=P+2*x,_=new ie(T,T),E=_.getContext("2d");this._clear(),E.save(),E.translate(x,x);const S=new ie(T,T),R=S.getContext("2d");let L=null,I=[];if(this.options.gifBackground){const t=(t=>{const e=new Uint8Array(t);return pt({data:e,pos:0},St)})(this.options.gifBackground);if(L=t,I=(M=t).frames.filter(t=>t.image).map(t=>It(t,M.gct)),this.options.autoColor){let t=0,e=0,o=0,r=0;for(let i=0;i200||a[1]>200||a[2]>200||(0===a[0]&&0===a[1]&&0===a[2]||(r++,t+=a[0],e+=a[1],o+=a[2]))}t=~~(t/r),e=~~(e/r),o=~~(o/r),this.options.colorDark="rgb(".concat(t,",").concat(e,",").concat(o,")")}}else if(this.options.backgroundImage){const t=yield ne(this.options.backgroundImage);if(this.options.autoColor){const e=se._getAverageRGB(t);this.options.colorDark="rgb(".concat(e.r,",").concat(e.g,",").concat(e.b,")")}R.drawImage(t,0,0,t.width,t.height,0,0,T,T),R.rect(0,0,T,T),R.fillStyle=B,R.fill()}else R.rect(0,0,T,T),R.fillStyle=this.options.colorLight,R.fill();var M;const N=Ft.getPatternPosition(this.qrCode.typeNumber),O=(null===(o=null===(e=this.options.components)||void 0===e?void 0:e.data)||void 0===o?void 0:o.scale)||ae,U=.5*(1-O);for(let t=0;t=w-8)||e>=w-8&&t<8;let i=r||(6==t&&e>=8&&e<=w-8||6==e&&t>=8&&t<=w-8);for(let s=1;s=N[s]-2&&t<=N[s]+2&&e>=N[s]-2&&e<=N[s]+2;const a=e*D+(i?0:U*D),n=t*D+(i?0:U*D);if(E.strokeStyle=o?this.options.colorDark:this.options.colorLight,E.lineWidth=.5,E.fillStyle=o?this.options.colorDark:this.options.colorLight,0===N.length)i||E.fillRect(a,n,(i?1:O)*D,(i?1:O)*D);else{i||e=w-4-5&&t=w-4-5||E.fillRect(a,n,(i?1:O)*D,(i?1:O)*D)}}const j=N[N.length-1],z=this.options.colorLight;if(E.fillStyle=z,E.fillRect(0,0,8*D,8*D),E.fillRect(0,(w-8)*D,8*D,8*D),E.fillRect((w-8)*D,0,8*D,8*D),(null===(i=null===(r=this.options.components)||void 0===r?void 0:r.timing)||void 0===i?void 0:i.protectors)&&(E.fillRect(8*D,6*D,(w-8-8)*D,D),E.fillRect(6*D,8*D,D,(w-8-8)*D)),(null===(n=null===(a=this.options.components)||void 0===a?void 0:a.cornerAlignment)||void 0===n?void 0:n.protectors)&&se._drawAlignProtector(E,j,j,D),null===(l=null===(s=this.options.components)||void 0===s?void 0:s.alignment)||void 0===l?void 0:l.protectors)for(let t=0;t=1)&&(e=.2),o<0&&(o=0),r<0&&(r=0);const i=P*e,a=.5*(T-i),n=a;E.restore(),E.fillStyle=this.options.logoBackgroundColor,E.save(),se._prepareRoundedCornerClip(E,a-o,n-o,i+2*o,i+2*o,r+o),E.clip();const s=E.globalCompositeOperation;E.globalCompositeOperation="destination-out",E.fill(),E.globalCompositeOperation=s,E.restore(),E.save(),se._prepareRoundedCornerClip(E,a,n,i,i,r),E.clip(),E.drawImage(t,a,n,i,i),E.restore(),E.save(),E.translate(x,x)}if(L){let t,e,o,r,i,a;if(I.forEach(function(n){t||(t=new oe(b,b),t.setDelay(n.delay),t.setRepeat(0));const{width:s,height:l}=n.dims;e||(e=new ie(s,l),o=e.getContext("2d"),o.rect(0,0,e.width,e.height),o.fillStyle="#ffffff",o.fill()),r&&a&&s===r.width&&l===r.height||(r=new ie(s,l),i=r.getContext("2d"),a=i.createImageData(s,l)),a.data.set(n.patch),i.putImageData(a,0,0),o.drawImage(r.getContext("2d").canvas,n.dims.left,n.dims.top);const c=new ie(T,T),h=c.getContext("2d");h.drawImage(e.getContext("2d").canvas,0,0,T,T),h.rect(0,0,T,T),h.fillStyle=B,h.fill(),h.drawImage(_.getContext("2d").canvas,0,0,T,T);const u=new ie(b,b),d=u.getContext("2d");d.drawImage(c.getContext("2d").canvas,0,0,b,b),t.addFrame(d.getImageData(0,0,u.width,u.height).data)}),!t)throw new Error("No frames.");if(t.finish(),le(this.canvas)){const e=t.stream().toFlattenUint8Array().reduce((t,e)=>t+String.fromCharCode(e),"");return Promise.resolve("data:image/gif;base64,".concat(window.btoa(e)))}return Promise.resolve(Buffer.from(t.stream().toFlattenUint8Array()))}{R.drawImage(_.getContext("2d").canvas,0,0,T,T),E.drawImage(S.getContext("2d").canvas,-x,-x,T,T);const t=new ie(b,b);t.getContext("2d").drawImage(_.getContext("2d").canvas,0,0,b,b),this.canvas=t;const e=this.options.gifBackground?"gif":"png";return le(this.canvas)?Promise.resolve(this.canvas.toDataURL(e)):Promise.resolve(this.canvas.toBuffer(e))}})}}function le(t){try{return t instanceof HTMLElement}catch(e){return"object"==typeof t&&1===t.nodeType&&"object"==typeof t.style&&"object"==typeof t.ownerDocument}}se.CorrectLevel=Ut,se.defaultComponentOptions={data:{scale:.4},timing:{scale:.5,protectors:!1},alignment:{scale:.5,protectors:!1},cornerAlignment:{scale:.5,protectors:!0}},se.defaultOptions={text:"",size:400,margin:20,colorDark:"#000000",colorLight:"rgba(255, 255, 255, 0.6)",correctLevel:Ut.M,backgroundImage:void 0,backgroundDimming:"rgba(0,0,0,0)",logoImage:void 0,logoScale:.2,logoMargin:4,logoCornerRadius:8,whiteMargin:!0,components:se.defaultComponentOptions,autoColor:!0,logoBackgroundColor:"#ffffff",backgroundColor:"#ffffff"};const ce={props:{text:{type:String,required:!0},qid:{type:String},correctLevel:{type:Number,default:1},size:{type:Number,default:200},margin:{type:Number,default:20},colorDark:{type:String,default:"#000000"},colorLight:{type:String,default:"#FFFFFF"},bgSrc:{type:String,default:void 0},background:{type:String,default:"rgba(0,0,0,0)"},backgroundDimming:{type:String,default:"rgba(0,0,0,0)"},logoSrc:{type:String,default:void 0},logoBackgroundColor:{type:String,default:"rgba(255,255,255,1)"},gifBgSrc:{type:String,default:void 0},logoScale:{type:Number,default:.2},logoMargin:{type:Number,default:0},logoCornerRadius:{type:Number,default:8},whiteMargin:{type:[Boolean,String],default:!0},dotScale:{type:Number,default:1},autoColor:{type:[Boolean,String],default:!0},binarize:{type:[Boolean,String],default:!1},binarizeThreshold:{type:Number,default:128},callback:{type:Function,default:function(){}},bindElement:{type:Boolean,default:!0},backgroundColor:{type:String,default:"#FFFFFF"},components:{default:function(){return{data:{scale:1},timing:{scale:1,protectors:!1},alignment:{scale:1,protectors:!1},cornerAlignment:{scale:1,protectors:!0}}}}},name:"vue-qr",data:()=>({imgUrl:""}),watch:{$props:{deep:!0,handler(){this.main()}}},mounted(){this.main()},methods:{async main(){if(this.gifBgSrc){const e=await(t=this.gifBgSrc,new Promise((e,o)=>{var r=new XMLHttpRequest;r.responseType="blob",r.onload=function(){var t=new FileReader;t.onloadend=function(){e(t.result)},t.readAsArrayBuffer(r.response)},r.open("GET",t),r.send()})),o=this.logoSrc;return void this.render(void 0,o,e)}var t;const e=this.bgSrc,o=this.logoSrc;this.render(e,o)},async render(t,e,o){const r=this;new se({gifBackground:o,text:r.text,size:r.size,margin:r.margin,colorDark:r.colorDark,colorLight:r.colorLight,backgroundColor:r.backgroundColor,backgroundImage:t,backgroundDimming:r.backgroundDimming,logoImage:e,logoScale:r.logoScale,logoBackgroundColor:r.logoBackgroundColor,correctLevel:r.correctLevel,logoMargin:r.logoMargin,logoCornerRadius:r.logoCornerRadius,whiteMargin:$(r.whiteMargin),dotScale:r.dotScale,autoColor:$(r.autoColor),binarize:$(r.binarize),binarizeThreshold:r.binarizeThreshold,components:r.components}).draw().then(t=>{this.imgUrl=t,r.callback&&r.callback(t,r.qid)})}}},he=["src"];const ue=e(ce,[["render",function(t,e,o,r,n,s){return o.bindElement?(a(),i("img",{key:0,style:{display:"inline-block"},src:n.imgUrl},null,8,he)):B("",!0)}]]),de={class:"m-2"},ge={class:"dialog-footer"},fe=Object.assign({name:"QRCodeUpload"},{__name:"QR-code",props:{classId:{type:Number,default:0}},emits:["on-success"],setup(t,{emit:e}){const c=e,u=t,d=g(!1),f=o(),m=g(""),v=()=>{const t=window.location;m.value=t.protocol+"//"+t.host+"/#/scanUpload?id="+u.classId+"&token="+f.token+"&t="+Date.now(),d.value=!0},y=()=>{d.value=!1,m.value="",c("on-success","")};return(t,e)=>{const o=r("el-button"),c=r("el-dialog");return a(),i(b,null,[p("div",null,[n(o,{type:"primary",icon:"iphone",onClick:v},{default:s(()=>[...e[2]||(e[2]=[h(" 扫码上传",-1)])]),_:1})]),n(c,{modelValue:d.value,"onUpdate:modelValue":e[1]||(e[1]=t=>d.value=t),title:"扫码上传",width:"320px","show-close":!1,"append-to-body":"","close-on-click-modal":!1,draggable:""},{footer:s(()=>[p("div",ge,[n(o,{onClick:e[0]||(e[0]=t=>d.value=!1)},{default:s(()=>[...e[3]||(e[3]=[h("取 消",-1)])]),_:1}),n(o,{type:"primary",onClick:y},{default:s(()=>[...e[4]||(e[4]=[h("完成上传",-1)])]),_:1})])]),default:s(()=>[p("div",de,[n(ue,{logoSrc:l("/assets/logo.DAivSsrL.png"),size:291,margin:0,autoColor:!0,dotScale:1,text:m.value,colorDark:"green",colorLight:"white",ref:"qrcode"},null,8,["logoSrc","text"])])]),_:1},8,["modelValue"])],64)}}});export{X as C,I as U,M as _,fe as a,N as b,S as c,U as d,R as e,O as f,E as g,L as i};