commonFunction.203a0abd.js 10 KB

12345678
  1. import{m as Q,g as W,a as Z,E as N}from"./index.72328493.js";import{f as k}from"./formatTime.29ac8c52.js";var R={exports:{}};/*!
  2. * clipboard.js v2.0.11
  3. * https://clipboardjs.com/
  4. *
  5. * Licensed MIT © Zeno Rocha
  6. */(function(S,T){(function(x,h){S.exports=h()})(W,function(){return function(){var _={686:function(d,a,t){t.d(a,{default:function(){return K}});var c=t(279),r=t.n(c),s=t(370),f=t.n(s),p=t(817),g=t.n(p);function y(u){try{return document.execCommand(u)}catch{return!1}}var v=function(n){var e=g()(n);return y("cut"),e},m=v;function E(u){var n=document.documentElement.getAttribute("dir")==="rtl",e=document.createElement("textarea");e.style.fontSize="12pt",e.style.border="0",e.style.padding="0",e.style.margin="0",e.style.position="absolute",e.style[n?"right":"left"]="-9999px";var o=window.pageYOffset||document.documentElement.scrollTop;return e.style.top="".concat(o,"px"),e.setAttribute("readonly",""),e.value=u,e}var P=function(n,e){var o=E(n);e.container.appendChild(o);var i=g()(o);return y("copy"),o.remove(),i},Y=function(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},o="";return typeof n=="string"?o=P(n,e):n instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(n==null?void 0:n.type)?o=P(n.value,e):(o=g()(n),y("copy")),o},O=Y;function C(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?C=function(e){return typeof e}:C=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},C(u)}var H=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=n.action,o=e===void 0?"copy":e,i=n.container,l=n.target,b=n.text;if(o!=="copy"&&o!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(l!==void 0)if(l&&C(l)==="object"&&l.nodeType===1){if(o==="copy"&&l.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(o==="cut"&&(l.hasAttribute("readonly")||l.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(b)return O(b,{container:i});if(l)return o==="cut"?m(l):O(l,{container:i})},j=H;function w(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?w=function(e){return typeof e}:w=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w(u)}function I(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function D(u,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(u,o.key,o)}}function z(u,n,e){return n&&D(u.prototype,n),e&&D(u,e),u}function B(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&F(u,n)}function F(u,n){return F=Object.setPrototypeOf||function(o,i){return o.__proto__=i,o},F(u,n)}function U(u){var n=X();return function(){var o=A(u),i;if(n){var l=A(this).constructor;i=Reflect.construct(o,arguments,l)}else i=o.apply(this,arguments);return $(this,i)}}function $(u,n){return n&&(w(n)==="object"||typeof n=="function")?n:G(u)}function G(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function X(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function A(u){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},A(u)}function L(u,n){var e="data-clipboard-".concat(u);if(n.hasAttribute(e))return n.getAttribute(e)}var J=function(u){B(e,u);var n=U(e);function e(o,i){var l;return I(this,e),l=n.call(this),l.resolveOptions(i),l.listenClick(o),l}return z(e,[{key:"resolveOptions",value:function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof i.action=="function"?i.action:this.defaultAction,this.target=typeof i.target=="function"?i.target:this.defaultTarget,this.text=typeof i.text=="function"?i.text:this.defaultText,this.container=w(i.container)==="object"?i.container:document.body}},{key:"listenClick",value:function(i){var l=this;this.listener=f()(i,"click",function(b){return l.onClick(b)})}},{key:"onClick",value:function(i){var l=i.delegateTarget||i.currentTarget,b=this.action(l)||"copy",M=j({action:b,container:this.container,target:this.target(l),text:this.text(l)});this.emit(M?"success":"error",{action:b,text:M,trigger:l,clearSelection:function(){l&&l.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(i){return L("action",i)}},{key:"defaultTarget",value:function(i){var l=L("target",i);if(l)return document.querySelector(l)}},{key:"defaultText",value:function(i){return L("text",i)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(i){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return O(i,l)}},{key:"cut",value:function(i){return m(i)}},{key:"isSupported",value:function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],l=typeof i=="string"?[i]:i,b=!!document.queryCommandSupported;return l.forEach(function(M){b=b&&!!document.queryCommandSupported(M)}),b}}]),e}(r()),K=J},828:function(d){var a=9;if(typeof Element<"u"&&!Element.prototype.matches){var t=Element.prototype;t.matches=t.matchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector||t.webkitMatchesSelector}function c(r,s){for(;r&&r.nodeType!==a;){if(typeof r.matches=="function"&&r.matches(s))return r;r=r.parentNode}}d.exports=c},438:function(d,a,t){var c=t(828);function r(p,g,y,v,m){var E=f.apply(this,arguments);return p.addEventListener(y,E,m),{destroy:function(){p.removeEventListener(y,E,m)}}}function s(p,g,y,v,m){return typeof p.addEventListener=="function"?r.apply(null,arguments):typeof y=="function"?r.bind(null,document).apply(null,arguments):(typeof p=="string"&&(p=document.querySelectorAll(p)),Array.prototype.map.call(p,function(E){return r(E,g,y,v,m)}))}function f(p,g,y,v){return function(m){m.delegateTarget=c(m.target,g),m.delegateTarget&&v.call(p,m)}}d.exports=s},879:function(d,a){a.node=function(t){return t!==void 0&&t instanceof HTMLElement&&t.nodeType===1},a.nodeList=function(t){var c=Object.prototype.toString.call(t);return t!==void 0&&(c==="[object NodeList]"||c==="[object HTMLCollection]")&&"length"in t&&(t.length===0||a.node(t[0]))},a.string=function(t){return typeof t=="string"||t instanceof String},a.fn=function(t){var c=Object.prototype.toString.call(t);return c==="[object Function]"}},370:function(d,a,t){var c=t(879),r=t(438);function s(y,v,m){if(!y&&!v&&!m)throw new Error("Missing required arguments");if(!c.string(v))throw new TypeError("Second argument must be a String");if(!c.fn(m))throw new TypeError("Third argument must be a Function");if(c.node(y))return f(y,v,m);if(c.nodeList(y))return p(y,v,m);if(c.string(y))return g(y,v,m);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function f(y,v,m){return y.addEventListener(v,m),{destroy:function(){y.removeEventListener(v,m)}}}function p(y,v,m){return Array.prototype.forEach.call(y,function(E){E.addEventListener(v,m)}),{destroy:function(){Array.prototype.forEach.call(y,function(E){E.removeEventListener(v,m)})}}}function g(y,v,m){return r(document.body,y,v,m)}d.exports=s},817:function(d){function a(t){var c;if(t.nodeName==="SELECT")t.focus(),c=t.value;else if(t.nodeName==="INPUT"||t.nodeName==="TEXTAREA"){var r=t.hasAttribute("readonly");r||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),r||t.removeAttribute("readonly"),c=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var s=window.getSelection(),f=document.createRange();f.selectNodeContents(t),s.removeAllRanges(),s.addRange(f),c=s.toString()}return c}d.exports=a},279:function(d){function a(){}a.prototype={on:function(t,c,r){var s=this.e||(this.e={});return(s[t]||(s[t]=[])).push({fn:c,ctx:r}),this},once:function(t,c,r){var s=this;function f(){s.off(t,f),c.apply(r,arguments)}return f._=c,this.on(t,f,r)},emit:function(t){var c=[].slice.call(arguments,1),r=((this.e||(this.e={}))[t]||[]).slice(),s=0,f=r.length;for(s;s<f;s++)r[s].fn.apply(r[s].ctx,c);return this},off:function(t,c){var r=this.e||(this.e={}),s=r[t],f=[];if(s&&c)for(var p=0,g=s.length;p<g;p++)s[p].fn!==c&&s[p].fn._!==c&&f.push(s[p]);return f.length?r[t]=f:delete r[t],this}},d.exports=a,d.exports.TinyEmitter=a}},x={};function h(d){if(x[d])return x[d].exports;var a=x[d]={exports:{}};return _[d](a,a.exports,h),a.exports}return function(){h.n=function(d){var a=d&&d.__esModule?function(){return d.default}:function(){return d};return h.d(a,{a}),a}}(),function(){h.d=function(d,a){for(var t in a)h.o(a,t)&&!h.o(d,t)&&Object.defineProperty(d,t,{enumerable:!0,get:a[t]})}}(),function(){h.o=function(d,a){return Object.prototype.hasOwnProperty.call(d,a)}}(),h(686)}().default})})(R);var q=R.exports;const V=Q(q),tt=S=>{const T=(S==null?void 0:S.appendToBody)===void 0?!0:S.appendToBody;return{toClipboard(_,x){return new Promise((h,d)=>{const a=document.createElement("button"),t=new V(a,{text:()=>_,action:()=>"copy",container:x!==void 0?x:document.body});t.on("success",c=>{t.destroy(),h(c)}),t.on("error",c=>{t.destroy(),d(c)}),T&&document.body.appendChild(a),a.click(),T&&document.body.removeChild(a)})}}};function ot(){const{t:S}=Z(),{toClipboard:T}=tt();return{percentFormat:(r,s,f)=>f?`${f}%`:"-",dateFormatYMD:(r,s,f)=>f?k(new Date(f),"YYYY-mm-dd"):"-",dateFormatYMDHMS:(r,s,f)=>f?k(new Date(f),"YYYY-mm-dd HH:MM:SS"):"-",dateFormatHMS:(r,s,f)=>{if(!f)return"-";let p=0;return typeof r=="number"&&(p=r),typeof f=="number"&&(p=f),k(new Date(p*1e3),"HH:MM:SS")},scaleFormat:(r="0",s=4)=>Number.parseFloat(r).toFixed(s),scale2Format:(r="0")=>Number.parseFloat(r).toFixed(2),copyText:r=>new Promise((s,f)=>{try{T(r),N.success(S("message.layout.copyTextSuccess")),s(r)}catch(p){N.error(S("message.layout.copyTextError")),f(p)}})}}export{ot as c};
  7. //# sourceMappingURL=commonFunction.203a0abd.js.map