UNPKG

vue-directive-zery

Version:

Vue custom directive extensions, including long press, copy, watermark, permissions and more. Vue 自定义指令扩展集合,包括长按,复制,水印,权限控制等等。

10 lines (9 loc) 28.8 kB
function e(e,t,n=""){return e.getAttribute(t)||n}function t(e,n){if(n instanceof Object&&!Array.isArray(n))for(let r in n)e.hasOwnProperty(r)&&(e[r]=t(e[r],n[r]));else e=n;return e}const n=(e,t,n)=>{const r=new CustomEvent(t,n);e.dispatchEvent(r)};let r;class i{constructor(){return r||(r=this,this.lazyLoad={default:""},this.permission={list:["1","2","3","4"]}),r}}var o={bind(e,t){e.clickoutside=t.value,e.clicked=!1,e.handler=function(t){e&&!e.contains(t.target)&&e.clicked&&(e.clickoutside(t),e.clicked=!1)},e.handlerClick=function(t){t.stopPropagation(),e.clicked||(e.clicked=!0)},e.addEventListener("click",e.handlerClick),document.addEventListener("click",e.handler)},unbind(e,t){e.removeEventListener("click",e.handlerClick),document.removeEventListener("click",e.handler)}};const a={bind(t,n){t.value=e(t,"copy-text",""),t.sunccess=n.value||l,t.handler=()=>{const e=document.createElement("textarea");e.readOnly="readonly",e.style.position="absolute",e.style.left="-9999px",e.value=t.value,document.body.appendChild(e),e.select();document.execCommand("Copy")&&t.sunccess(t.value),document.body.removeChild(e)},t.addEventListener("click",t.handler)},unbind(e){e.removeEventListener("click",e.handler)},componentUpdated(t,n){t.value=e(t,"copy-text",""),t.sunccess=n.value||l}},l=()=>{},s={bind(t,n){t.timer=null,t.count=t.originCount=n.value,t.delay=e(t,"count-down-delay",1e3),t.countDownStop=c.bind(t),t.countDownStart=u.bind(t),t.countDownReset=d.bind(t)},inserted(e){e.innerText=e.count},componentUpdated(t,n){t.count=n.value,t.delay=e(t,"count-down-delay",1e3),t.innerText=t.count}};function u(){n(this,"count-down-start"),this.countDownStop(),this.timer=setInterval((()=>{this.count>0?(--this.count,this.innerText=this.count):(n(this,"count-down-end"),this.countDownStop())}),this.delay)}function c(){this.timer&&(clearInterval(this.timer),this.timer=null)}function d(){this.count=this.originCount,this.innerText=this.count}const f={bind(t,n){t.timer=null,t.handler=n.value,t.delay=e(t,"debounce-delay",350),t.handlerClick=e=>{t.timer&&clearTimeout(t.timer),t.timer=setTimeout((()=>t.handler(e)),t.delay)},t.addEventListener("click",t.handlerClick)},componentUpdated(t,n){t.handler=n.value,t.delay=e(t,"debounce-delay",350)},unbind(e){e.removeEventListener("click",e.handlerClick)}},m={inserted(e,t){e.style.cursor="move",e.style.position=t.arg||"absolute",e.style.userSelect="none",e.onmousedown=t=>{n(e,"drag-start",t);let r=t.clientX-e.offsetLeft,i=t.clientY-e.offsetTop;document.onmousemove=t=>{n(e,"drag",t);let o=t.clientX-r,a=t.clientY-i,l=e.parentNode.clientWidth-parseInt(e.clientWidth),s=e.parentNode.clientHeight-parseInt(e.clientHeight);o<0?o=0:o>l&&(o=l),a<0?a=0:a>s&&(a=s),e.style.left=o+"px",e.style.top=a+"px"},document.onmouseup=t=>{n(e,"drag-end",t),document.onmousemove=document.onmouseup=null}},e.ontouchstart=t=>{n(e,"drag-start",t);let r=(t=t.targetTouches[0]).clientX-e.offsetLeft,i=t.clientY-e.offsetTop;document.ontouchmove=t=>{n(e,"drag",t);let o=(t=t.targetTouches[0]).clientX-r,a=t.clientY-i,l=e.parentNode.clientWidth-parseInt(e.clientWidth),s=e.parentNode.clientHeight-parseInt(e.clientHeight);o<0?o=0:o>l&&(o=l),a<0?a=0:a>s&&(a=s),e.style.left=o+"px",e.style.top=a+"px"},document.ontouchend=t=>{n(e,"drag-end",t),document.ontouchmove=document.ontouchend=null}}}},h={bind(e,t){p(e,t)},componentUpdated(e,t){p(e,t)}};function p(e,t){const n=t.value||1;e.style.overflow="hidden",e.style.textOverflow="ellipsis",1===n?e.style.whiteSpace="nowrap":(e.style.WebkitBoxOrient="vertical",e.style.display="-webkit-box",e.style.WebkitLineClamp=n)}const v=(e,t)=>{if(t.some((t=>t.toUpperCase()===e.tagName)))return e;if(1===e.nodeType&&e.hasChildNodes()){let n=e.childNodes;for(let e=0;e<n.length;e++){let r=n.item(e);const i=v(r,t);if(i)return i}}},b={inserted(e){const t=v(e,["input","textarea"]);t&&t.focus()}};var g,y,w,$="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},x={exports:{}},k=x.exports=function(){var e=1e3,t=6e4,n=36e5,r="millisecond",i="second",o="minute",a="hour",l="day",s="week",u="month",c="quarter",d="year",f="date",m="Invalid Date",h=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,p=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},b=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},g={s:b,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?"+":"-")+b(r,2,"0")+":"+b(i,2,"0")},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,u),o=n-i<0,a=t.clone().add(r+(o?-1:1),u);return+(-(r+(n-i)/(o?i-a:a-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:u,y:d,w:s,d:l,D:f,h:a,m:o,s:i,ms:r,Q:c}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},y="en",w={};w[y]=v;var $=function(e){return e instanceof S},x=function(e,t,n){var r;if(!e)return y;if("string"==typeof e)w[e]&&(r=e),t&&(w[e]=t,r=e);else{var i=e.name;w[i]=e,r=i}return!n&&r&&(y=r),r||!n&&y},k=function(e,t){if($(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new S(n)},_=g;_.l=x,_.i=$,_.w=function(e,t){return k(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var S=function(){function v(e){this.$L=x(e.locale,null,!0),this.parse(e)}var b=v.prototype;return b.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(_.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(h);if(r){var i=r[2]-1||0,o=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,o)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,o)}}return new Date(t)}(e),this.$x=e.x||{},this.init()},b.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},b.$utils=function(){return _},b.isValid=function(){return!(this.$d.toString()===m)},b.isSame=function(e,t){var n=k(e);return this.startOf(t)<=n&&n<=this.endOf(t)},b.isAfter=function(e,t){return k(e)<this.startOf(t)},b.isBefore=function(e,t){return this.endOf(t)<k(e)},b.$g=function(e,t,n){return _.u(e)?this[t]:this.set(n,e)},b.unix=function(){return Math.floor(this.valueOf()/1e3)},b.valueOf=function(){return this.$d.getTime()},b.startOf=function(e,t){var n=this,r=!!_.u(t)||t,c=_.p(e),m=function(e,t){var i=_.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(l)},h=function(e,t){return _.w(n.toDate()[e].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},p=this.$W,v=this.$M,b=this.$D,g="set"+(this.$u?"UTC":"");switch(c){case d:return r?m(1,0):m(31,11);case u:return r?m(1,v):m(0,v+1);case s:var y=this.$locale().weekStart||0,w=(p<y?p+7:p)-y;return m(r?b-w:b+(6-w),v);case l:case f:return h(g+"Hours",0);case a:return h(g+"Minutes",1);case o:return h(g+"Seconds",2);case i:return h(g+"Milliseconds",3);default:return this.clone()}},b.endOf=function(e){return this.startOf(e,!1)},b.$set=function(e,t){var n,s=_.p(e),c="set"+(this.$u?"UTC":""),m=(n={},n[l]=c+"Date",n[f]=c+"Date",n[u]=c+"Month",n[d]=c+"FullYear",n[a]=c+"Hours",n[o]=c+"Minutes",n[i]=c+"Seconds",n[r]=c+"Milliseconds",n)[s],h=s===l?this.$D+(t-this.$W):t;if(s===u||s===d){var p=this.clone().set(f,1);p.$d[m](h),p.init(),this.$d=p.set(f,Math.min(this.$D,p.daysInMonth())).$d}else m&&this.$d[m](h);return this.init(),this},b.set=function(e,t){return this.clone().$set(e,t)},b.get=function(e){return this[_.p(e)]()},b.add=function(r,c){var f,m=this;r=Number(r);var h=_.p(c),p=function(e){var t=k(m);return _.w(t.date(t.date()+Math.round(e*r)),m)};if(h===u)return this.set(u,this.$M+r);if(h===d)return this.set(d,this.$y+r);if(h===l)return p(1);if(h===s)return p(7);var v=(f={},f[o]=t,f[a]=n,f[i]=e,f)[h]||1,b=this.$d.getTime()+r*v;return _.w(b,this)},b.subtract=function(e,t){return this.add(-1*e,t)},b.format=function(e){var t=this;if(!this.isValid())return m;var n=e||"YYYY-MM-DDTHH:mm:ssZ",r=_.z(this),i=this.$locale(),o=this.$H,a=this.$m,l=this.$M,s=i.weekdays,u=i.months,c=function(e,r,i,o){return e&&(e[r]||e(t,n))||i[r].substr(0,o)},d=function(e){return _.s(o%12||12,e,"0")},f=i.meridiem||function(e,t,n){var r=e<12?"AM":"PM";return n?r.toLowerCase():r},h={YY:String(this.$y).slice(-2),YYYY:this.$y,M:l+1,MM:_.s(l+1,2,"0"),MMM:c(i.monthsShort,l,u,3),MMMM:c(u,l),D:this.$D,DD:_.s(this.$D,2,"0"),d:String(this.$W),dd:c(i.weekdaysMin,this.$W,s,2),ddd:c(i.weekdaysShort,this.$W,s,3),dddd:s[this.$W],H:String(o),HH:_.s(o,2,"0"),h:d(1),hh:d(2),a:f(o,a,!0),A:f(o,a,!1),m:String(a),mm:_.s(a,2,"0"),s:String(this.$s),ss:_.s(this.$s,2,"0"),SSS:_.s(this.$ms,3,"0"),Z:r};return n.replace(p,(function(e,t){return t||h[e]||r.replace(":","")}))},b.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},b.diff=function(r,f,m){var h,p=_.p(f),v=k(r),b=(v.utcOffset()-this.utcOffset())*t,g=this-v,y=_.m(this,v);return y=(h={},h[d]=y/12,h[u]=y,h[c]=y/3,h[s]=(g-b)/6048e5,h[l]=(g-b)/864e5,h[a]=g/n,h[o]=g/t,h[i]=g/e,h)[p]||g,m?y:_.a(y)},b.daysInMonth=function(){return this.endOf(u).$D},b.$locale=function(){return w[this.$L]},b.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=x(e,t,!0);return r&&(n.$L=r),n},b.clone=function(){return _.w(this.$d,this)},b.toDate=function(){return new Date(this.valueOf())},b.toJSON=function(){return this.isValid()?this.toISOString():null},b.toISOString=function(){return this.$d.toISOString()},b.toString=function(){return this.$d.toUTCString()},v}(),F=S.prototype;return k.prototype=F,[["$ms",r],["$s",i],["$m",o],["$H",a],["$W",l],["$M",u],["$y",d],["$D",f]].forEach((function(e){F[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),k.extend=function(e,t){return e.$i||(e(t,S,k),e.$i=!0),k},k.locale=x,k.isDayjs=$,k.unix=function(e){return k(1e3*e)},k.en=w[y],k.Ls=w,k.p={},k}(),_={exports:{}};y=$,w=function(){var e,t,n,r,i,o={},a={},l={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0",scalePercentBy100:!0},s={currentLocale:l.currentLocale,zeroFormat:l.zeroFormat,nullFormat:l.nullFormat,defaultFormat:l.defaultFormat,scalePercentBy100:l.scalePercentBy100};function u(e,t){this._input=e,this._value=t}return(e=function(n){var r,i,a,l;if(e.isNumeral(n))r=n.value();else if(0===n||void 0===n)r=0;else if(null===n||t.isNaN(n))r=null;else if("string"==typeof n)if(s.zeroFormat&&n===s.zeroFormat)r=0;else if(s.nullFormat&&n===s.nullFormat||!n.replace(/[^0-9]+/g,"").length)r=null;else{for(i in o)if((l="function"==typeof o[i].regexps.unformat?o[i].regexps.unformat():o[i].regexps.unformat)&&n.match(l)){a=o[i].unformat;break}r=(a=a||e._.stringToNumber)(n)}else r=Number(n)||null;return new u(n,r)}).version="2.0.6",e.isNumeral=function(e){return e instanceof u},e._=t={numberToFormat:function(t,n,r){var i,o,l,s,u,c,d,f,m=a[e.options.currentLocale],h=!1,p=!1,v="",b=1e12,g=1e9,y=1e6,w="",$=!1;if(t=t||0,l=Math.abs(t),e._.includes(n,"(")?(h=!0,n=n.replace(/[\(|\)]/g,"")):(e._.includes(n,"+")||e._.includes(n,"-"))&&(c=e._.includes(n,"+")?n.indexOf("+"):t<0?n.indexOf("-"):-1,n=n.replace(/[\+|\-]/g,"")),e._.includes(n,"a")&&(o=!!(o=n.match(/a(k|m|b|t)?/))&&o[1],e._.includes(n," a")&&(v=" "),n=n.replace(new RegExp(v+"a[kmbt]?"),""),l>=b&&!o||"t"===o?(v+=m.abbreviations.trillion,t/=b):l<b&&l>=g&&!o||"b"===o?(v+=m.abbreviations.billion,t/=g):l<g&&l>=y&&!o||"m"===o?(v+=m.abbreviations.million,t/=y):(l<y&&l>=1e3&&!o||"k"===o)&&(v+=m.abbreviations.thousand,t/=1e3)),e._.includes(n,"[.]")&&(p=!0,n=n.replace("[.]",".")),s=t.toString().split(".")[0],u=n.split(".")[1],d=n.indexOf(","),i=(n.split(".")[0].split(",")[0].match(/0/g)||[]).length,u?(e._.includes(u,"[")?(u=(u=u.replace("]","")).split("["),w=e._.toFixed(t,u[0].length+u[1].length,r,u[1].length)):w=e._.toFixed(t,u.length,r),s=w.split(".")[0],w=e._.includes(w,".")?m.delimiters.decimal+w.split(".")[1]:"",p&&0===Number(w.slice(1))&&(w="")):s=e._.toFixed(t,0,r),v&&!o&&Number(s)>=1e3&&v!==m.abbreviations.trillion)switch(s=String(Number(s)/1e3),v){case m.abbreviations.thousand:v=m.abbreviations.million;break;case m.abbreviations.million:v=m.abbreviations.billion;break;case m.abbreviations.billion:v=m.abbreviations.trillion}if(e._.includes(s,"-")&&(s=s.slice(1),$=!0),s.length<i)for(var x=i-s.length;x>0;x--)s="0"+s;return d>-1&&(s=s.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===n.indexOf(".")&&(s=""),f=s+w+(v||""),h?f=(h&&$?"(":"")+f+(h&&$?")":""):c>=0?f=0===c?($?"-":"+")+f:f+($?"-":"+"):$&&(f="-"+f),f},stringToNumber:function(e){var t,n,r,i=a[s.currentLocale],o=e,l={thousand:3,million:6,billion:9,trillion:12};if(s.zeroFormat&&e===s.zeroFormat)n=0;else if(s.nullFormat&&e===s.nullFormat||!e.replace(/[^0-9]+/g,"").length)n=null;else{for(t in n=1,"."!==i.delimiters.decimal&&(e=e.replace(/\./g,"").replace(i.delimiters.decimal,".")),l)if(r=new RegExp("[^a-zA-Z]"+i.abbreviations[t]+"(?:\\)|(\\"+i.currency.symbol+")?(?:\\))?)?$"),o.match(r)){n*=Math.pow(10,l[t]);break}n*=(e.split("-").length+Math.min(e.split("(").length-1,e.split(")").length-1))%2?1:-1,e=e.replace(/[^0-9\.]+/g,""),n*=Number(e)}return n},isNaN:function(e){return"number"==typeof e&&isNaN(e)},includes:function(e,t){return-1!==e.indexOf(t)},insert:function(e,t,n){return e.slice(0,n)+t+e.slice(n)},reduce:function(e,t){if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof t)throw new TypeError(t+" is not a function");var n,r=Object(e),i=r.length>>>0,o=0;if(3===arguments.length)n=arguments[2];else{for(;o<i&&!(o in r);)o++;if(o>=i)throw new TypeError("Reduce of empty array with no initial value");n=r[o++]}for(;o<i;o++)o in r&&(n=t(n,r[o],o,r));return n},multiplier:function(e){var t=e.toString().split(".");return t.length<2?1:Math.pow(10,t[1].length)},correctionFactor:function(){var e=Array.prototype.slice.call(arguments);return e.reduce((function(e,n){var r=t.multiplier(n);return e>r?e:r}),1)},toFixed:function(e,t,n,r){var i,o,a,l,s=e.toString().split("."),u=t-(r||0);return i=2===s.length?Math.min(Math.max(s[1].length,u),t):u,a=Math.pow(10,i),l=(n(e+"e+"+i)/a).toFixed(i),r>t-i&&(o=new RegExp("\\.?0{1,"+(r-(t-i))+"}$"),l=l.replace(o,"")),l}},e.options=s,e.formats=o,e.locales=a,e.locale=function(e){return e&&(s.currentLocale=e.toLowerCase()),s.currentLocale},e.localeData=function(e){if(!e)return a[s.currentLocale];if(e=e.toLowerCase(),!a[e])throw new Error("Unknown locale : "+e);return a[e]},e.reset=function(){for(var e in l)s[e]=l[e]},e.zeroFormat=function(e){s.zeroFormat="string"==typeof e?e:null},e.nullFormat=function(e){s.nullFormat="string"==typeof e?e:null},e.defaultFormat=function(e){s.defaultFormat="string"==typeof e?e:"0.0"},e.register=function(e,t,n){if(t=t.toLowerCase(),this[e+"s"][t])throw new TypeError(t+" "+e+" already registered.");return this[e+"s"][t]=n,n},e.validate=function(t,n){var r,i,o,a,l,s,u,c;if("string"!=typeof t&&(t+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",t)),(t=t.trim()).match(/^\d+$/))return!0;if(""===t)return!1;try{u=e.localeData(n)}catch(d){u=e.localeData(e.locale())}return o=u.currency.symbol,l=u.abbreviations,r=u.delimiters.decimal,i="."===u.delimiters.thousands?"\\.":u.delimiters.thousands,!(null!==(c=t.match(/^[^\d]+/))&&(t=t.substr(1),c[0]!==o)||null!==(c=t.match(/[^\d]+$/))&&(t=t.slice(0,-1),c[0]!==l.thousand&&c[0]!==l.million&&c[0]!==l.billion&&c[0]!==l.trillion)||(s=new RegExp(i+"{2}"),t.match(/[^\d.,]/g)||(a=t.split(r)).length>2||(a.length<2?!a[0].match(/^\d+.*\d$/)||a[0].match(s):1===a[0].length?!a[0].match(/^\d+$/)||a[0].match(s)||!a[1].match(/^\d+$/):!a[0].match(/^\d+.*\d$/)||a[0].match(s)||!a[1].match(/^\d+$/))))},e.fn=u.prototype={clone:function(){return e(this)},format:function(t,n){var r,i,a,l=this._value,u=t||s.defaultFormat;if(n=n||Math.round,0===l&&null!==s.zeroFormat)i=s.zeroFormat;else if(null===l&&null!==s.nullFormat)i=s.nullFormat;else{for(r in o)if(u.match(o[r].regexps.format)){a=o[r].format;break}i=(a=a||e._.numberToFormat)(l,u,n)}return i},value:function(){return this._value},input:function(){return this._input},set:function(e){return this._value=Number(e),this},add:function(e){var n=t.correctionFactor.call(null,this._value,e);return this._value=t.reduce([this._value,e],(function(e,t,r,i){return e+Math.round(n*t)}),0)/n,this},subtract:function(e){var n=t.correctionFactor.call(null,this._value,e);return this._value=t.reduce([e],(function(e,t,r,i){return e-Math.round(n*t)}),Math.round(this._value*n))/n,this},multiply:function(e){return this._value=t.reduce([this._value,e],(function(e,n,r,i){var o=t.correctionFactor(e,n);return Math.round(e*o)*Math.round(n*o)/Math.round(o*o)}),1),this},divide:function(e){return this._value=t.reduce([this._value,e],(function(e,n,r,i){var o=t.correctionFactor(e,n);return Math.round(e*o)/Math.round(n*o)})),this},difference:function(t){return Math.abs(e(this._value).subtract(t).value())}},e.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(e){var t=e%10;return 1==~~(e%100/10)?"th":1===t?"st":2===t?"nd":3===t?"rd":"th"},currency:{symbol:"$"}}),e.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(t,n,r){var i,o=e._.includes(n," BPS")?" ":"";return t*=1e4,n=n.replace(/\s?BPS/,""),i=e._.numberToFormat(t,n,r),e._.includes(i,")")?((i=i.split("")).splice(-1,0,o+"BPS"),i=i.join("")):i=i+o+"BPS",i},unformat:function(t){return+(1e-4*e._.stringToNumber(t)).toFixed(15)}}),r={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},i="("+(i=(n={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}).suffixes.concat(r.suffixes.filter((function(e){return n.suffixes.indexOf(e)<0}))).join("|")).replace("B","B(?!PS)")+")",e.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp(i)},format:function(t,i,o){var a,l,s,u=e._.includes(i,"ib")?r:n,c=e._.includes(i," b")||e._.includes(i," ib")?" ":"";for(i=i.replace(/\s?i?b/,""),a=0;a<=u.suffixes.length;a++)if(l=Math.pow(u.base,a),s=Math.pow(u.base,a+1),null===t||0===t||t>=l&&t<s){c+=u.suffixes[a],l>0&&(t/=l);break}return e._.numberToFormat(t,i,o)+c},unformat:function(t){var i,o,a=e._.stringToNumber(t);if(a){for(i=n.suffixes.length-1;i>=0;i--){if(e._.includes(t,n.suffixes[i])){o=Math.pow(n.base,i);break}if(e._.includes(t,r.suffixes[i])){o=Math.pow(r.base,i);break}}a*=o||1}return a}}),e.register("format","currency",{regexps:{format:/(\$)/},format:function(t,n,r){var i,o,a=e.locales[e.options.currentLocale],l={before:n.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:n.match(/([\+|\-|\)|\s|\$]*)$/)[0]};for(n=n.replace(/\s?\$\s?/,""),i=e._.numberToFormat(t,n,r),t>=0?(l.before=l.before.replace(/[\-\(]/,""),l.after=l.after.replace(/[\-\)]/,"")):t<0&&!e._.includes(l.before,"-")&&!e._.includes(l.before,"(")&&(l.before="-"+l.before),o=0;o<l.before.length;o++)switch(l.before[o]){case"$":i=e._.insert(i,a.currency.symbol,o);break;case" ":i=e._.insert(i," ",o+a.currency.symbol.length-1)}for(o=l.after.length-1;o>=0;o--)switch(l.after[o]){case"$":i=o===l.after.length-1?i+a.currency.symbol:e._.insert(i,a.currency.symbol,-(l.after.length-(1+o)));break;case" ":i=o===l.after.length-1?i+" ":e._.insert(i," ",-(l.after.length-(1+o)+a.currency.symbol.length-1))}return i}}),e.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(t,n,r){var i=("number"!=typeof t||e._.isNaN(t)?"0e+0":t.toExponential()).split("e");return n=n.replace(/e[\+|\-]{1}0/,""),e._.numberToFormat(Number(i[0]),n,r)+"e"+i[1]},unformat:function(t){var n=e._.includes(t,"e+")?t.split("e+"):t.split("e-"),r=Number(n[0]),i=Number(n[1]);return i=e._.includes(t,"e-")?i*=-1:i,e._.reduce([r,Math.pow(10,i)],(function(t,n,r,i){var o=e._.correctionFactor(t,n);return t*o*(n*o)/(o*o)}),1)}}),e.register("format","ordinal",{regexps:{format:/(o)/},format:function(t,n,r){var i=e.locales[e.options.currentLocale],o=e._.includes(n," o")?" ":"";return n=n.replace(/\s?o/,""),o+=i.ordinal(t),e._.numberToFormat(t,n,r)+o}}),e.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(t,n,r){var i,o=e._.includes(n," %")?" ":"";return e.options.scalePercentBy100&&(t*=100),n=n.replace(/\s?\%/,""),i=e._.numberToFormat(t,n,r),e._.includes(i,")")?((i=i.split("")).splice(-1,0,o+"%"),i=i.join("")):i=i+o+"%",i},unformat:function(t){var n=e._.stringToNumber(t);return e.options.scalePercentBy100?.01*n:n}}),e.register("format","time",{regexps:{format:/(:)/,unformat:/(:)/},format:function(e,t,n){var r=Math.floor(e/60/60),i=Math.floor((e-60*r*60)/60),o=Math.round(e-60*r*60-60*i);return r+":"+(i<10?"0"+i:i)+":"+(o<10?"0"+o:o)},unformat:function(e){var t=e.split(":"),n=0;return 3===t.length?(n+=60*Number(t[0])*60,n+=60*Number(t[1]),n+=Number(t[2])):2===t.length&&(n+=60*Number(t[0]),n+=Number(t[1])),Number(n)}}),e},( /*! @preserve * numeral.js * version : 2.0.6 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ g=_).exports?g.exports=w():y.numeral=w();var S=_.exports;const F={bind(e,t){e.format=t.value,M(e)},componentUpdated(e,t){e.format=t.value,M(e)}};function M(t){const n=e(t,"formatter-value",""),r=e(t,"formatter-perfix",""),i=e(t,"formatter-suffix","");let o=n;o=/\d/.test(t.format)?S(n).format(t.format):k(n).format(t.format),t.innerText=r+o+i}const L={bind(e,t){e.container=t.arg,e.status=t.value},inserted(e,t,r){e.addEventListener("click",(t=>{E(e,r)})),document.addEventListener("keyup",(t=>{t&&122===t.keyCode&&(t.preventDefault(),E(e,r))})),window.addEventListener("fullscreenchange",(t=>{document.fullscreenElement?n(e,"enter-full-screen"):n(e,"exit-full-screen")})),window.addEventListener("webkitfullscreenchange",(t=>{document.webkitIsFullScreen?n(e,"enter-full-screen"):n(e,"exit-full-screen")})),window.addEventListener("mozfullscreenchange",(t=>{document.mozFullScreen?n(e,"enter-full-screen"):n(e,"exit-full-screen")})),window.addEventListener("msfullscreenchange",(t=>{document.msFullscreenElement?n(e,"enter-full-screen"):n(e,"exit-full-screen")}))},componentUpdated(e,t,n){e.status=t.value},unbind(e,t,r){e.removeEventListener("click",(t=>{E(e,r)})),document.removeEventListener("keyup",(t=>{t&&122===t.keyCode&&(t.preventDefault(),E(e,r))})),window.removeEventListener("fullscreenchange",(t=>{document.fullscreenElement?n(e,"enter-full-screen"):n(e,"exit-full-screen")})),window.removeEventListener("webkitfullscreenchange",(t=>{document.webkitIsFullScreen?n(e,"enter-full-screen"):n(e,"exit-full-screen")})),window.removeEventListener("mozfullscreenchange",(t=>{document.mozFullScreen?n(e,"enter-full-screen"):n(e,"exit-full-screen")})),window.removeEventListener("msfullscreenchange",(t=>{document.msFullscreenElement?n(e,"enter-full-screen"):n(e,"exit-full-screen")}))}};function E(e,t){const n=t.context.$refs[e.container];let r;if(r=n&&n.length>0?n[0]:n,e.status){const e=r.requestFullscreen||r.msRequestFullscreen||r.mozRequestFullScreen||r.webkitRequestFullScreen;if(e)return void e.call(r);if(void 0!==window.ActiveXObject){let e=new ActiveXObject("WScript.Shell");e&&e.SendKeys("{F11}")}}else{let e=r.exitFullscreen||r.msExitFullscreen||r.mozCancelFullScreen||r.webkitCancelFullScreen;if(e&&e.call(r),e=document.exitFullscreen||document.msExitFullscreen||document.mozCancelFullScreen||document.webkitCancelFullScreen,e)return void e.call(document);if(void 0!==window.ActiveXObject){let e=new ActiveXObject("WScript.Shell");e&&e.SendKeys("{F11}")}}}const T={bind(e){!function(e){e.style.overflow="auto"}(e)},inserted(t,n){t.callback=n.value,t.delay=e(t,"infinite-scroll-delay",200),t.distance=e(t,"infinite-scroll-distance",0),t.disabled=e(t,"infinite-scroll-disabled",!1),function(e){const t=function(e,t){let n,r;return function(...i){const o=Date.now(),a=this;if(r||(r=o),clearTimeout(n),o-r>t)return r=o,e.apply(a,i),void clearTimeout(n);n=setTimeout((function(){r=Date.now(),n=null,e.apply(a,i)}),t)}}((()=>D(e)),e.delay);D(e),e.addEventListener("scroll",(()=>{t()}))}(t)},componentUpdated(t,n){t.callback=n.value,t.delay=e(t,"infinite-scroll-delay",200),t.distance=e(t,"infinite-scroll-distance",0),t.disabled=e(t,"infinite-scroll-disabled",!1)},unbind(e){e.removeEventListener("scroll",(()=>{handler(e)}))}};function D(e){const t=e.clientHeight;e.scrollHeight-t-e.scrollTop<=e.distance&&!e.disabled&&e.callback()}const N=new i,O={bind(e){!function(e,t){e.setAttribute("src",t)}(e,N.lazyLoad.default)},inserted(e){!function(e){new IntersectionObserver((t=>{const n=e.dataset.src;t[0].isIntersecting&&n&&(e.src=n,e.removeAttribute("data-src"))})).observe(e)}(e)}};const B={bind:function(e,t){var n=t.value||/[^\u4E00-\u9FA5|\d|\a-zA-Z|\r\n\s,.?!,。?!…—&$=()-+/*{}[\]]|\s/g;let r=(o="input",(i=e).tagName.toLowerCase()===o?i:i.querySelector(o));var i,o;e.$inp=r,r.handle=function(){let e=r.value;r.value=e.replace(n,"")},r.addEventListener("input",r.handle)},unbind:function(e){e.$inp.removeEventListener("input",e.$inp.handle)}},C={bind:function(t,n,r){if("function"!=typeof n.value)throw"callback must be a function";t.delay=e(t,"longpress-delay",2e3);let i=null,o=e=>{"click"===e.type&&0!==e.button||null===i&&(i=setTimeout((()=>{l()}),t.delay))},a=e=>{null!==i&&(clearTimeout(i),i=null)};const l=e=>{n.value(e)};t.addEventListener("mousedown",o),t.addEventListener("touchstart",o),t.addEventListener("click",a),t.addEventListener("mouseout",a),t.addEventListener("touchend",a),t.addEventListener("touchcancel",a)},componentUpdated(t,{value:n}){t.delay=e(t,"longpress-delay",2e3)},unbind(e){e.removeEventListener("click",e.handler)}},z={bind(e){e.timer=null,e.distance=0,e.count=0,e.play=!1,e.marqueeStart=function(){I(e)},e.marqueeStop=function(){Y(e)},window.addEventListener("resize",(function(t){A(e)}))},inserted(e){A(e)},componentUpdated(e){I(e)},unbind(e){window.removeEventListener("resize",(function(t){A(e)}))}};function A(e){e.parentNode.style.overflow="hidden",e.parentNode.style.whiteSpace="nowrap","block"!==e.style.display&&(e.style.display="block"),I(e)}function I(t){t.timer&&Y(t);const r=e(t,"marquee-scroll-amount",6);let i=e(t,"marquee-scroll-delay",85);const o=e(t,"marquee-loop",-1);i<60&&(i=60);const a=t.parentNode.offsetWidth,l=t.scrollWidth;t.count=0,l>a&&(t.timer=setInterval((()=>{t.play||(n(t,"marquee-start"),t.play=!0),Math.abs(t.distance)>=l?(t.distance=a,o>-1&&(++t.count,n(t,"marquee-bounce",{detail:t.count}),o<=t.count&&(n(t,"marquee-finish"),Y(t)))):t.distance-=r,t.style.transform=`translateX(${t.distance}px)`}),i))}function Y(e){clearInterval(e.timer),e.timer=null,e.play=!1}const H=new i;function W(t,n){var r=document.createElement("canvas");r.width=e(n,"watermarker-width",200),r.height=e(n,"watermarker-height",150),r.style.display="none";var i=r.getContext("2d");const o=e(n,"watermarker-font-size",16),a=e(n,"watermarker-font-family","Microsoft YaHei"),l=e(n,"watermarker-rotate",-30);i.font=`${o}px ${a}`,i.fillStyle=e(n,"watermarker-text-color","rgba(180, 180, 180, 0.3)"),i.textAlign=e(n,"watermarker-text-align","center"),i.textBaseline=e(n,"watermarker-text-baseline","center"),i.translate(U(i,r),j(i,r)),i.rotate(l*Math.PI/180),i.translate(-U(i,r),-j(i,r)),i.fillText(t,U(i,r),j(i,r),r.width),n.style.backgroundImage="url("+r.toDataURL("image/png")+")"}const P={bind(e,t){W(t.value,e)},componentUpdated(e,t){W(t.value,e)}};function U({textAlign:e},{width:t}){let n;switch(e){case"left":n=0;break;case"right":n=t;break;default:n=t/2}return n}function j({textBaseline:e},{height:t}){let n;switch(e){case"top":n=0;break;case"bottom":n=t;break;default:n=t/2}return n}let q=new i;const R={clickOutside:o,copy:a,countDown:s,debounce:f,draggable:m,ellipsis:h,focus:b,formatter:F,fullScreen:L,infiniteScroll:T,lazyLoad:O,limitText:B,longpress:C,marquee:z,permission:function(e,t){let n=t.value;if(n){(r=n,H.permission.list.includes(r))||(e.style.display="none")}var r},watermarker:P},X={use(e){e&&(this.useList=e)},install(e){this.useList||(this.useList=Object.keys(R)),this.useList.forEach((t=>{if(!R[t])throw new Error("不存在该指令");e.directive(t.replace(/([A-Z])/g,"-$1").toLowerCase(),R[t])})),e.prototype.$zery=this},setOption(e){if(!(e instanceof Object)||Array.isArray(e))throw new Error("type of options is invalid");q=t(q,e)}};"undefined"!=typeof window&&window.Vue&&install(window.Vue);export default X;