(function(h,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue"),require("xlsx"),require("lodash-es"),require("dayjs"),require("ant-design-vue")):typeof define=="function"&&define.amd?define(["exports","vue","xlsx","lodash-es","dayjs","ant-design-vue"],d):(h=typeof globalThis<"u"?globalThis:h||self,d(h.index={},h.Vue,h.XLSX,null,h.dayjs))})(this,function(h,d,K,De,Q){"use strict";function W(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const T=W(K),ee="G",te=Q;for(let e=0;e<=15;e++)e.toString(16);/*!
 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
 *
 * Copyright (c) 2014-2017, Jon Schlinkert.
 * Released under the MIT License.
 */function L(e){return Object.prototype.toString.call(e)==="[object Object]"}function ne(e){var n,t;return L(e)===!1?!1:(n=e.constructor,n===void 0?!0:(t=n.prototype,!(L(t)===!1||t.hasOwnProperty("isPrototypeOf")===!1)))}function E(){return E=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},E.apply(this,arguments)}function C(e,n){if(e==null)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(t=i[r])>=0||(o[t]=e[t]);return o}const V={silent:!1,logLevel:"warn"},re=["validator"],R=Object.prototype,I=R.toString,oe=R.hasOwnProperty,X=/^\s*function (\w+)/;function M(e){var n;const t=(n=e==null?void 0:e.type)!==null&&n!==void 0?n:e;if(t){const r=t.toString().match(X);return r?r[1]:""}return""}const O=ne,B=e=>e;let f=B;process.env.NODE_ENV!=="production"&&(f=typeof console<"u"?function(n,t=V.logLevel){V.silent===!1&&console[t](`[VueTypes warn]: ${n}`)}:B);const x=(e,n)=>oe.call(e,n),ie=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},S=Array.isArray||function(e){return I.call(e)==="[object Array]"},w=e=>I.call(e)==="[object Function]",F=e=>O(e)&&x(e,"_vueTypes_name"),U=e=>O(e)&&(x(e,"type")||["_vueTypes_name","validator","default","required"].some(n=>x(e,n)));function A(e,n){return Object.defineProperty(e.bind(n),"__original",{value:e})}function j(e,n,t=!1){let r,o=!0,i="";r=O(e)?e:{type:e};const s=F(r)?r._vueTypes_name+" - ":"";if(U(r)&&r.type!==null){if(r.type===void 0||r.type===!0||!r.required&&n===void 0)return o;S(r.type)?(o=r.type.some(a=>j(a,n,!0)===!0),i=r.type.map(a=>M(a)).join(" or ")):(i=M(r),o=i==="Array"?S(n):i==="Object"?O(n):i==="String"||i==="Number"||i==="Boolean"||i==="Function"?function(a){if(a==null)return"";const u=a.constructor.toString().match(X);return u?u[1]:""}(n)===i:n instanceof r.type)}if(!o){const a=`${s}value "${n}" should be of type "${i}"`;return t===!1?(f(a),!1):a}if(x(r,"validator")&&w(r.validator)){const a=f,u=[];if(f=c=>{u.push(c)},o=r.validator(n),f=a,!o){const c=(u.length>1?"* ":"")+u.join(`
* `);return u.length=0,t===!1?(f(c),o):c}}return o}function p(e,n){const t=Object.defineProperties(n,{_vueTypes_name:{value:e,writable:!0},isRequired:{get(){return this.required=!0,this}},def:{value(o){return o===void 0?(x(this,"default")&&delete this.default,this):w(o)||j(this,o,!0)===!0?(this.default=S(o)?()=>[...o]:O(o)?()=>Object.assign({},o):o,this):(f(`${this._vueTypes_name} - invalid default value: "${o}"`),this)}}}),{validator:r}=t;return w(r)&&(t.validator=A(r,t)),t}function g(e,n){const t=p(e,n);return Object.defineProperty(t,"validate",{value(r){return w(this.validator)&&f(`${this._vueTypes_name} - calling .validate() will overwrite the current custom validator function. Validator info:
${JSON.stringify(this)}`),this.validator=A(r,this),this}})}function Y(e,n,t){const r=function(u){const c={};return Object.getOwnPropertyNames(u).forEach(l=>{c[l]=Object.getOwnPropertyDescriptor(u,l)}),Object.defineProperties({},c)}(n);if(r._vueTypes_name=e,!O(t))return r;const{validator:o}=t,i=C(t,re);if(w(o)){let{validator:u}=r;u&&(u=(a=(s=u).__original)!==null&&a!==void 0?a:s),r.validator=A(u?function(c){return u.call(this,c)&&o.call(this,c)}:o,r)}var s,a;return Object.assign(r,i)}function q(e){return e.replace(/^(?!\s*$)/gm,"  ")}const se=()=>g("any",{}),ae=()=>g("function",{type:Function}),ue=()=>g("boolean",{type:Boolean}),le=()=>g("string",{type:String}),ce=()=>g("number",{type:Number}),fe=()=>g("array",{type:Array}),de=()=>g("object",{type:Object}),pe=()=>p("integer",{type:Number,validator:e=>ie(e)}),ye=()=>p("symbol",{validator:e=>typeof e=="symbol"});function he(e,n="custom validation failed"){if(typeof e!="function")throw new TypeError("[VueTypes error]: You must provide a function as argument");return p(e.name||"<<anonymous function>>",{type:null,validator(t){const r=e(t);return r||f(`${this._vueTypes_name} - ${n}`),r}})}function ve(e){if(!S(e))throw new TypeError("[VueTypes error]: You must provide an array as argument.");const n=`oneOf - value should be one of "${e.join('", "')}".`,t=e.reduce((r,o)=>{if(o!=null){const i=o.constructor;r.indexOf(i)===-1&&r.push(i)}return r},[]);return p("oneOf",{type:t.length>0?t:void 0,validator(r){const o=e.indexOf(r)!==-1;return o||f(n),o}})}function ge(e){if(!S(e))throw new TypeError("[VueTypes error]: You must provide an array as argument");let n=!1,t=[];for(let o=0;o<e.length;o+=1){const i=e[o];if(U(i)){if(F(i)&&i._vueTypes_name==="oneOf"&&i.type){t=t.concat(i.type);continue}if(w(i.validator)&&(n=!0),i.type===!0||!i.type){f('oneOfType - invalid usage of "true" or "null" as types.');continue}t=t.concat(i.type)}else t.push(i)}t=t.filter((o,i)=>t.indexOf(o)===i);const r=t.length>0?t:null;return p("oneOfType",n?{type:r,validator(o){const i=[],s=e.some(a=>{const u=j(F(a)&&a._vueTypes_name==="oneOf"?a.type||null:a,o,!0);return typeof u=="string"&&i.push(u),u===!0});return s||f(`oneOfType - provided value does not match any of the ${i.length} passed-in validators:
${q(i.join(`
`))}`),s}}:{type:r})}function be(e){return p("arrayOf",{type:Array,validator(n){let t="";const r=n.every(o=>(t=j(e,o,!0),t===!0));return r||f(`arrayOf - value validation error:
${q(t)}`),r}})}function me(e){return p("instanceOf",{type:e})}function Oe(e){return p("objectOf",{type:Object,validator(n){let t="";const r=Object.keys(n).every(o=>(t=j(e,n[o],!0),t===!0));return r||f(`objectOf - value validation error:
${q(t)}`),r}})}function je(e){const n=Object.keys(e),t=n.filter(o=>{var i;return!((i=e[o])===null||i===void 0||!i.required)}),r=p("shape",{type:Object,validator(o){if(!O(o))return!1;const i=Object.keys(o);if(t.length>0&&t.some(s=>i.indexOf(s)===-1)){const s=t.filter(a=>i.indexOf(a)===-1);return f(s.length===1?`shape - required property "${s[0]}" is not defined.`:`shape - required properties "${s.join('", "')}" are not defined.`),!1}return i.every(s=>{if(n.indexOf(s)===-1)return this._vueTypes_isLoose===!0||(f(`shape - shape definition does not include a "${s}" property. Allowed keys: "${n.join('", "')}".`),!1);const a=j(e[s],o[s],!0);return typeof a=="string"&&f(`shape - "${s}" property validation error:
 ${q(a)}`),a===!0})}});return Object.defineProperty(r,"_vueTypes_isLoose",{writable:!0,value:!1}),Object.defineProperty(r,"loose",{get(){return this._vueTypes_isLoose=!0,this}}),r}const _e=["name","validate","getter"],Te=(()=>{var e;return(e=class{static get any(){return se()}static get func(){return ae().def(this.defaults.func)}static get bool(){return ue().def(this.defaults.bool)}static get string(){return le().def(this.defaults.string)}static get number(){return ce().def(this.defaults.number)}static get array(){return fe().def(this.defaults.array)}static get object(){return de().def(this.defaults.object)}static get integer(){return pe().def(this.defaults.integer)}static get symbol(){return ye()}static get nullable(){return{type:null}}static extend(n){if(S(n))return n.forEach(u=>this.extend(u)),this;const{name:t,validate:r=!1,getter:o=!1}=n,i=C(n,_e);if(x(this,t))throw new TypeError(`[VueTypes error]: Type "${t}" already defined`);const{type:s}=i;if(F(s))return delete i.type,Object.defineProperty(this,t,o?{get:()=>Y(t,s,i)}:{value(...u){const c=Y(t,s,i);return c.validator&&(c.validator=c.validator.bind(c,...u)),c}});let a;return a=o?{get(){const u=Object.assign({},i);return r?g(t,u):p(t,u)},enumerable:!0}:{value(...u){const c=Object.assign({},i);let l;return l=r?g(t,c):p(t,c),c.validator&&(l.validator=c.validator.bind(l,...u)),l},enumerable:!0},Object.defineProperty(this,t,a)}}).defaults={},e.sensibleDefaults=void 0,e.config=V,e.custom=he,e.oneOf=ve,e.instanceOf=me,e.oneOfType=ge,e.arrayOf=be,e.objectOf=Oe,e.shape=je,e.utils={validate:(n,t)=>j(t,n,!0)===!0,toType:(n,t,r=!1)=>r?g(n,t):p(n,t)},e})();function z(e={func:()=>{},bool:!0,string:"",number:0,array:()=>[],object:()=>({}),integer:0}){var n;return(n=class extends Te{static get sensibleDefaults(){return E({},this.defaults)}static set sensibleDefaults(t){this.defaults=t!==!1?E({},t!==!0?t:e):{}}}).defaults=E({},e),n}class Pe extends z(){}z({func:void 0,bool:void 0,string:void 0,number:void 0,object:void 0,integer:void 0}).extend([{name:"style",getter:!0,type:[String,Object],default:void 0},{name:"VNodeChild",getter:!0,type:void 0}]);const xe=d.defineComponent({name:`${ee}ImportExcel`,components:{},props:{dateFormat:{type:String},timeZone:{type:Number,default:8}},emits:["success","error"],setup(e,{emit:n}){const t=d.ref(null),r=d.ref(!1);function o(l){if(!l||!l["!ref"])return[];const y=[],v=T.utils.decode_range(l["!ref"]),k=v.s.r;for(let b=v.s.c;b<=v.e.c;++b){const m=l[T.utils.encode_cell({c:b,r:k})];let N="UNKNOWN "+b;m&&m.t&&(N=T.utils.format_cell(m)),y.push(N)}return y}function i(l){const y=[],{dateFormat:v,timeZone:k}=e;for(const b of l.SheetNames){const m=l.Sheets[b],N=o(m);let D=T.utils.sheet_to_json(m,{raw:!0,dateNF:v});D=D.map(_=>{for(let P in _)_[P]instanceof Date&&(k===8&&_[P].setSeconds(_[P].getSeconds()+43),v&&(_[P]=te(_[P]).format(v)));return _}),y.push({header:N,results:D,meta:{sheetName:b}})}return y}function s(l){return r.value=!0,new Promise((y,v)=>{const k=new FileReader;k.onload=async b=>{try{const m=b.target&&b.target.result,N=T.read(m,{type:"array",cellDates:!0}),D=i(N);n("success",D),y("")}catch(m){v(m),n("error")}finally{r.value=!1}},k.readAsArrayBuffer(l)})}async function a(l){const y=d.unref(t);y&&(y.value=""),await s(l)}function u(l){const y=l&&l.target.files,v=y&&y[0];v&&a(v)}function c(){const l=d.unref(t);l&&l.click()}return{handleUpload:c,handleInputClick:u,inputRef:t}}}),Se=(e,n)=>{const t=e.__vccOpts||e;for(const[r,o]of n)t[r]=o;return t};function we(e,n,t,r,o,i){return d.openBlock(),d.createElementBlock("div",null,[d.withDirectives(d.createElementVNode("input",{ref:"inputRef",type:"file",accept:".xlsx, .xls",onChange:n[0]||(n[0]=(...s)=>e.handleInputClick&&e.handleInputClick(...s))},null,544),[[d.vShow,!1]]),d.createElementVNode("div",{onClick:n[1]||(n[1]=(...s)=>e.handleUpload&&e.handleUpload(...s))},[d.renderSlot(e.$slots,"default")])])}const $=Se(xe,[["render",we]]),{utils:H,writeFile:J}=T,Z="excel-list.xlsx";function $e({data:e,header:n,filename:t=Z,json2sheetOpts:r={},write2excelOpts:o={bookType:"xlsx"}}){const i=[...e];n&&(i.unshift(n),r.skipHeader=!0);const s=H.json_to_sheet(i,r),a={SheetNames:[t],Sheets:{[t]:s}};J(a,t,o)}function G(e){if([null,void 0].includes(e))return 20;if(/.*[\u4e00-\u9fa5]+.*$/.test(e)){const n=e.match(/[\u4e00-\u9fa5]/g).length,t=e.length-n;return n*2.1+t*1.1}else return e.toString().length*1.1}const ke=(e,n,t,r=!0)=>{if(r){const o=[],i=n;e.forEach(s=>{var u,c;let a=0;for(const l in s){switch(o[a]==null&&(o[a]=[]),typeof s[l]){case"string":case"number":case"boolean":(u=o[a])==null||u.push(G(s[l]));break;case"object":case"function":(c=o[a])==null||c.push(0);break}a++}}),t["!cols"]=[],o.forEach((s,a)=>{s==null||s.push(G(i[a])),t["!cols"].push({wch:Math.max(...s)})})}};function Ne({data:e,header:n,filename:t=Z,write2excelOpts:r={bookType:"xlsx"}}){const o=[...e];n&&o.unshift(n);const i=H.aoa_to_sheet(o);ke(e,n,i,!0);const s={SheetNames:[t],Sheets:{[t]:i}};J(s,t,r)}$.install=function(e,n){e.component(n||$.name,$)};const Ee={title:"Excel 导入导出",category:"高级组件",status:"100%",install(e){e.component($.name,$)}};h.ImportExcel=$,h.aoaToSheetXlsx=Ne,h.default=Ee,h.jsonToSheetXlsx=$e,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
