@morehook/core
Version:
关于vue的一些hooks,兼容vue2+vue3
925 lines (879 loc) • 97.1 kB
JavaScript
var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
if (VueDemi.install) {
return VueDemi
}
if (!Vue) {
console.error('[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.')
return VueDemi
}
// Vue 2.7
if (Vue.version.slice(0, 4) === '2.7.') {
for (var key in Vue) {
VueDemi[key] = Vue[key]
}
VueDemi.isVue2 = true
VueDemi.isVue3 = false
VueDemi.install = function () {}
VueDemi.Vue = Vue
VueDemi.Vue2 = Vue
VueDemi.version = Vue.version
VueDemi.warn = Vue.util.warn
function createApp(rootComponent, rootProps) {
var vm
var provide = {}
var app = {
config: Vue.config,
use: Vue.use.bind(Vue),
mixin: Vue.mixin.bind(Vue),
component: Vue.component.bind(Vue),
provide: function (key, value) {
provide[key] = value
return this
},
directive: function (name, dir) {
if (dir) {
Vue.directive(name, dir)
return app
} else {
return Vue.directive(name)
}
},
mount: function (el, hydrating) {
if (!vm) {
vm = new Vue(Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) }))
vm.$mount(el, hydrating)
return vm
} else {
return vm
}
},
unmount: function () {
if (vm) {
vm.$destroy()
vm = undefined
}
},
}
return app
}
VueDemi.createApp = createApp
}
// Vue 2.6.x
else if (Vue.version.slice(0, 2) === '2.') {
if (VueCompositionAPI) {
for (var key in VueCompositionAPI) {
VueDemi[key] = VueCompositionAPI[key]
}
VueDemi.isVue2 = true
VueDemi.isVue3 = false
VueDemi.install = function () {}
VueDemi.Vue = Vue
VueDemi.Vue2 = Vue
VueDemi.version = Vue.version
} else {
console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.')
}
}
// Vue 3
else if (Vue.version.slice(0, 2) === '3.') {
for (var key in Vue) {
VueDemi[key] = Vue[key]
}
VueDemi.isVue2 = false
VueDemi.isVue3 = true
VueDemi.install = function () {}
VueDemi.Vue = Vue
VueDemi.Vue2 = undefined
VueDemi.version = Vue.version
VueDemi.set = function (target, key, val) {
if (Array.isArray(target)) {
target.length = Math.max(target.length, key)
target.splice(key, 1, val)
return val
}
target[key] = val
return val
}
VueDemi.del = function (target, key) {
if (Array.isArray(target)) {
target.splice(key, 1)
return
}
delete target[key]
}
} else {
console.error('[vue-demi] Vue version ' + Vue.version + ' is unsupported.')
}
return VueDemi
})(
(this.VueDemi = this.VueDemi || (typeof VueDemi !== 'undefined' ? VueDemi : {})),
this.Vue || (typeof Vue !== 'undefined' ? Vue : undefined),
this.VueCompositionAPI || (typeof VueCompositionAPI !== 'undefined' ? VueCompositionAPI : undefined)
);
;
;(function (exports, core, vueDemi) {
'use strict';
const defaultValue = false;
function useBoolean(value) {
value = value || defaultValue;
const [state, [toggle]] = core.useToggle(value, !value);
const setTrue = () => toggle(true);
const setFalse = () => toggle(false);
const actions = { toggle, setTrue, setFalse };
return [state, actions];
}
/*! js-cookie v3.0.1 | MIT */
/* eslint-disable no-var */
function assign (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
target[key] = source[key];
}
}
return target
}
/* eslint-enable no-var */
/* eslint-disable no-var */
var defaultConverter = {
read: function (value) {
if (value[0] === '"') {
value = value.slice(1, -1);
}
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
},
write: function (value) {
return encodeURIComponent(value).replace(
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
decodeURIComponent
)
}
};
/* eslint-enable no-var */
/* eslint-disable no-var */
function init (converter, defaultAttributes) {
function set (key, value, attributes) {
if (typeof document === 'undefined') {
return
}
attributes = assign({}, defaultAttributes, attributes);
if (typeof attributes.expires === 'number') {
attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
}
if (attributes.expires) {
attributes.expires = attributes.expires.toUTCString();
}
key = encodeURIComponent(key)
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
.replace(/[()]/g, escape);
var stringifiedAttributes = '';
for (var attributeName in attributes) {
if (!attributes[attributeName]) {
continue
}
stringifiedAttributes += '; ' + attributeName;
if (attributes[attributeName] === true) {
continue
}
// Considers RFC 6265 section 5.2:
// ...
// 3. If the remaining unparsed-attributes contains a %x3B (";")
// character:
// Consume the characters of the unparsed-attributes up to,
// not including, the first %x3B (";") character.
// ...
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
}
return (document.cookie =
key + '=' + converter.write(value, key) + stringifiedAttributes)
}
function get (key) {
if (typeof document === 'undefined' || (arguments.length && !key)) {
return
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all.
var cookies = document.cookie ? document.cookie.split('; ') : [];
var jar = {};
for (var i = 0; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var value = parts.slice(1).join('=');
try {
var foundKey = decodeURIComponent(parts[0]);
jar[foundKey] = converter.read(value, foundKey);
if (key === foundKey) {
break
}
} catch (e) {}
}
return key ? jar[key] : jar
}
return Object.create(
{
set: set,
get: get,
remove: function (key, attributes) {
set(
key,
'',
assign({}, attributes, {
expires: -1
})
);
},
withAttributes: function (attributes) {
return init(this.converter, assign({}, this.attributes, attributes))
},
withConverter: function (converter) {
return init(assign({}, this.converter, converter), this.attributes)
}
},
{
attributes: { value: Object.freeze(defaultAttributes) },
converter: { value: Object.freeze(converter) }
}
)
}
var api = init(defaultConverter, { path: '/' });
const defaultOptions$8 = {
watch: false,
defaultValue: void 0
};
function useCookie(key, options) {
const { watch, defaultValue } = { ...defaultOptions$8, ...options };
const state = vueDemi.ref(api.get(key) || defaultValue);
const setCookie = (value) => {
api.set(key, value, { ...options });
state.value = value;
};
if (watch) {
vueDemi.watch(state, (value) => {
if (value === null || value === void 0) {
api.remove(key);
return;
}
setCookie(value);
}, { deep: true });
}
return state;
}
const isClient = typeof window !== "undefined";
const defaultWindow = isClient ? window : void 0;
const defaultOptions$7 = {
onSuccess: () => {
},
onError: () => {
}
};
function useCopy(str, options) {
const state = vueDemi.ref();
const { onSuccess, onError } = { ...defaultOptions$7, ...options };
state.value = str || "";
const writeText = (str2) => {
if (!isClient) {
onError("\u8BF7\u5728window\u73AF\u5883\u4E0B\u4F7F\u7528");
return;
}
str2 = typeof str2 === "object" ? JSON.stringify(str2) : String(str2);
navigator.clipboard.writeText(str2).then(() => {
onSuccess(str2);
}, (err) => {
const errStr = `\u53D1\u751F\u9519\u8BEF: ${err},\u5FC5\u987B\u8981\u4FDD\u6301\u7F51\u9875\u7126\u70B9\u624D\u80FD\u590D\u5236`;
console.log(errStr);
onError(errStr);
});
};
writeText(str);
vueDemi.watch(state, (val) => {
writeText(val);
});
return state;
}
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var dayjs_min = {exports: {}};
(function (module, exports) {
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|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,M={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("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p=function(t){return t instanceof _},S=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=v;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(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,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return O},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),l=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(h){case c:return r?l(1,0):l(31,11);case f:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),l=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,l=this;r=Number(r);var $=O.p(h),y=function(t){var e=w(l);return O.w(e.date(e.date()+Math.round(t*r)),l)};if($===f)return this.set(f,this.$M+r);if($===c)return this.set(c,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},$={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||$[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,v=this-M,g=O.m(this,M);return g=($={},$[c]=g/12,$[f]=g,$[h]=g/3,$[o]=(v-m)/6048e5,$[a]=(v-m)/864e5,$[u]=v/n,$[s]=v/e,$[i]=v/t,$)[y]||v,l?g:O.a(g)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),T=_.prototype;return w.prototype=T,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=D[g],w.Ls=D,w.p={},w}));
} (dayjs_min));
var dayjs = dayjs_min.exports;
const defaultOptions$6 = {
format: "YYYY-MM-DD HH:mm:ss",
method: "format"
};
function useDate(options, initialValue) {
const state = vueDemi.ref();
const { format, method, methodParam } = { ...defaultOptions$6, ...options };
const refresh = (value = +new Date()) => {
switch (method) {
case "format":
state.value = dayjs(value).format(format);
break;
case "timestamp":
state.value = +dayjs(value);
break;
case void 0:
break;
default: {
let data2 = dayjs(value);
data2 = data2[method](methodParam);
if (dayjs.isDayjs(data2)) {
data2 = data2.format(format);
}
state.value = data2;
}
}
};
refresh(initialValue || +new Date());
const data = vueDemi.readonly(state);
return { data, refresh };
}
const defaultDelay$3 = 1e3;
function useDebounce(value, delay, firstTrigger = false) {
delay = delay || defaultDelay$3;
const res = vueDemi.ref(value.value);
const { run } = core.useDebounceFn(() => res.value = value.value, delay, firstTrigger);
vueDemi.watch(value, () => run(), { deep: true });
return res;
}
const debounce = function(fn, delay, firstTrigger = false) {
let timeer = null;
return (...arg) => {
if (firstTrigger) {
fn.call(this, ...arg);
firstTrigger = false;
}
if (timeer)
clearTimeout(timeer);
timeer = setTimeout(() => {
fn.call(this, ...arg);
firstTrigger = true;
}, delay);
};
};
const defaultDelay$2 = 1e3;
function useDebounceFn(fn, delay, firstTrigger = false) {
const run = debounce(fn, typeof delay === "number" ? delay : defaultDelay$2, firstTrigger);
return { run };
}
function useDocumentHidden() {
if (!isClient)
return vueDemi.ref(false);
const documentHidden = vueDemi.ref(document.hidden);
const handler = () => {
documentHidden.value = document.hidden;
};
document.addEventListener("visibilitychange", handler);
return documentHidden;
}
const getRandomStr = (randomLength = 5) => {
return Number(Math.random().toString().slice(3, 8) + Date.now()).toString(36).slice(0, randomLength);
};
function useDynamicList(initialValue) {
let uuid = 0;
const uuidKeys = vueDemi.ref([]);
const keysAdding = "+" + getRandomStr(8);
const setUUID = (index) => {
index = index === void 0 ? uuidKeys.value.length : index;
uuidKeys.value.splice(index, 0, String(uuid++) + keysAdding);
};
initialValue.value.forEach(() => setUUID());
const resetList = (resetList2) => {
uuidKeys.value = [];
if (vueDemi.isRef(resetList2)) {
resetList2.value.forEach(() => setUUID());
initialValue = resetList2;
} else {
resetList2.forEach(() => setUUID());
initialValue.value = resetList2;
}
};
const insert = (index, ...obj) => {
if (obj.length === 0)
return;
let list = [];
if (obj.length === 1 && Array.isArray(obj[0])) {
list = obj[0];
} else {
list = obj;
}
list.forEach((active, i) => setUUID(index + i));
initialValue.value.splice(index, 0, ...list);
};
const replace = (index, obj) => {
initialValue.value.splice(index, 1, obj);
};
const remove = (index) => {
uuidKeys.value.splice(index, 1);
initialValue.value.splice(index, 1);
};
const move = (oldIndex, newIndex) => {
if (oldIndex === newIndex)
return;
[initialValue.value[oldIndex], initialValue.value[newIndex]] = [
initialValue.value[newIndex],
initialValue.value[oldIndex]
];
[uuidKeys.value[oldIndex], uuidKeys.value[newIndex]] = [
uuidKeys.value[newIndex],
uuidKeys.value[oldIndex]
];
};
const getKey = (index) => uuidKeys.value[index];
const getIndex = (key) => uuidKeys.value.indexOf(key);
const push = (obj) => {
initialValue.value.push(obj);
setUUID();
};
const pop = () => {
initialValue.value.pop();
uuidKeys.value.pop();
};
const unshift = (obj) => {
initialValue.value.unshift(obj);
setUUID(0);
};
const shift = () => {
initialValue.value.shift();
uuidKeys.value.shift();
};
return {
list: initialValue,
resetList,
insert,
replace,
remove,
move,
push,
pop,
unshift,
shift,
getKey,
getIndex
};
}
function useExternal(src, onLoaded, options = {}) {
let originSrc = vueDemi.isRef(src) ? src.value : src;
const resources = vueDemi.ref(null);
const {
manual = false,
async,
crossOrigin,
referrerPolicy,
noModule,
defer,
media = "all",
target = defaultWindow ? document.body : void 0
} = options;
const loadScript = () => new Promise((resolve) => {
if (!isClient) {
resolve(void 0);
return;
}
const isExist = document.querySelector(`script[src="${originSrc}"]`);
if (isExist)
return;
el = document.createElement("script");
el.src = originSrc;
el.type = "text/javascript";
if (async)
el.async = async;
if (defer)
el.defer = defer;
if (noModule)
el.noModule = noModule;
if (crossOrigin)
el.crossOrigin = crossOrigin;
if (referrerPolicy)
el.referrerPolicy = referrerPolicy;
el = parentEl.appendChild(el);
resolve(el);
});
const loadCss = () => new Promise((resolve) => {
if (!isClient) {
resolve(void 0);
return;
}
const isExist = document.querySelector(`link[href="${originSrc}"]`);
if (isExist)
return;
el = document.createElement("link");
el.href = originSrc;
el.rel = "stylesheet";
el.type = "text/css";
el.media = media;
el = parentEl.appendChild(el);
resolve(el);
});
const loadImage = () => new Promise((resolve) => {
if (!isClient) {
resolve(void 0);
return;
}
const isExist = document.querySelector(`img[src="${originSrc}"]`);
if (isExist)
return;
el = document.createElement("img");
el.src = originSrc;
if (target) {
parentEl = vueDemi.isRef(target) ? target.value : target;
parentEl.appendChild(el);
}
resolve(el);
});
const load = () => {
return new Promise((resolve, reject) => {
if (!isClient) {
resolve(void 0);
return;
}
let _load = Promise.resolve();
if (/\.js$/.test(originSrc)) {
_load = loadScript();
}
if (/\.css$/.test(originSrc)) {
_load = loadCss();
}
if (/\.(gif|jpg|jpeg|png|svg|GIF|JPG|PNG|)$/.test(originSrc)) {
_load = loadImage();
}
_load.then(() => {
resources.value = el;
el.addEventListener("error", (event) => reject(event));
el.addEventListener("abort", (event) => reject(event));
el.addEventListener("load", () => {
onLoaded && onLoaded(el);
});
resolve(el);
});
});
};
const unload = () => {
if (resources.value) {
parentEl.removeChild(resources.value);
resources.value = null;
}
};
if (!isClient)
return { resources, load, unload };
let el = document.createElement("script");
let parentEl = document.head;
if (vueDemi.isRef(src)) {
vueDemi.watch(src, (val) => {
originSrc = val;
if (!manual)
load();
});
}
if (!manual)
load();
return { resources, load, unload };
}
const defaultOptions$5 = {
onFull: function() {
},
onExitFull: function() {
}
};
function useFullscreen(target, options) {
const actions = {
setFull: () => {
if (!isClient)
return;
if (isFullscreen.value)
return;
el.requestFullscreen();
isFullscreen.value = true;
},
exitFull: () => {
if (!isClient)
return;
if (!isFullscreen.value)
return;
document.exitFullscreen();
isFullscreen.value = false;
},
toggle: () => {
if (!isClient)
return;
isFullscreen.value ? actions.exitFull() : actions.setFull();
}
};
if (!isClient)
return [vueDemi.ref(false), actions];
const fullScreenElement = !!document.fullscreenElement;
const isFullscreen = vueDemi.ref(fullScreenElement);
const { onFull, onExitFull } = { ...defaultOptions$5, ...options };
let el = document.body;
const getEl = () => {
if (typeof target === "function") {
return target();
}
return vueDemi.isRef(target) ? target.value : target;
};
const handler = () => {
isFullscreen.value = !!document.fullscreenElement;
if (isFullscreen.value) {
onFull();
} else {
onExitFull();
}
};
vueDemi.onMounted(() => {
el = getEl() || el;
el.addEventListener("fullscreenchange", handler);
});
vueDemi.onUnmounted(() => {
el.removeEventListener("fullscreenchange", handler);
});
return [isFullscreen, actions];
}
const TypeSerializers = {
boolean: {
read: (v) => v != null ? v === "true" : null,
write: (v) => String(v)
},
object: {
read: (v) => v ? JSON.parse(v) : null,
write: (v) => JSON.stringify(v)
},
number: {
read: (v) => v != null ? Number.parseFloat(v) : null,
write: (v) => String(v)
},
any: {
read: (v) => v != null && v !== "null" ? v : null,
write: (v) => String(v)
},
string: {
read: (v) => v != null ? v : null,
write: (v) => String(v)
}
};
const getValueType = (defaultValue) => {
return defaultValue === null ? "any" : typeof defaultValue === "boolean" ? "boolean" : typeof defaultValue === "string" ? "string" : typeof defaultValue === "object" ? "object" : Array.isArray(defaultValue) ? "object" : !Number.isNaN(defaultValue) ? "number" : "any";
};
const defaultOptions$4 = {
watch: true
};
function useLocalStorage(key, initialValue, options) {
const data = vueDemi.ref();
if (!isClient)
return data;
const storage = localStorage;
const { watch } = { ...defaultOptions$4, ...options };
try {
if (initialValue !== void 0) {
data.value = vueDemi.isRef(initialValue) ? initialValue.value : initialValue;
} else {
data.value = JSON.parse(storage.getItem(key) || "{}");
}
} catch (error) {
console.log(error, "useLocalStorage \u521D\u59CB\u5316\u5931\u8D25");
}
const serializer = TypeSerializers[getValueType(data.value)];
const setStorage = () => storage.setItem(key, serializer.write(data.value));
if (watch) {
vueDemi.watch(data, (newValue) => {
if (newValue === void 0 || newValue === null) {
storage.removeItem(key);
return;
}
setStorage();
}, {
deep: true
});
}
setStorage();
return data;
}
function useLockFn(fn) {
const lock = vueDemi.ref(false);
return async (...args) => {
if (lock.value)
return;
lock.value = true;
try {
const ret = await fn(...args);
lock.value = false;
return ret;
} catch (error) {
lock.value = false;
throw error;
}
};
}
function useMap(initialValue) {
const initialMap = initialValue ? new Map(initialValue) : new Map();
const state = vueDemi.ref(initialMap);
const actions = {
set: (key, value) => {
state.value.set(key, value);
},
get: (key) => {
return state.value.get(key);
},
remove: (key) => {
state.value.delete(key);
},
has: (key) => state.value.has(key),
clear: () => state.value.clear(),
setAll: (newMap) => {
state.value = new Map(newMap);
},
reset: () => state.value = initialMap
};
return [state, vueDemi.markRaw(actions)];
}
function useMediaQuery(query) {
if (!isClient)
return vueDemi.ref(false);
const mediaQuery = window.matchMedia(query);
const stata = vueDemi.ref(mediaQuery.matches);
const handleChange = (event) => stata.value = event.matches;
mediaQuery.addEventListener("change", handleChange);
vueDemi.onUnmounted(() => {
mediaQuery.removeEventListener("change", handleChange);
});
return stata;
}
function useMediaQueryS(query) {
if (!isClient)
return vueDemi.ref("");
const activeKey = vueDemi.ref();
const mqlList = [];
const queryEntries = Object.entries(query);
queryEntries.forEach((item, index) => {
const key = item[0];
const mediaQueryString = item[1];
const mql = window.matchMedia(mediaQueryString);
if (mql.matches)
activeKey.value = key;
const handleChange = (event) => {
if (event.matches) {
activeKey.value = key;
} else {
if (index !== 0) {
activeKey.value = queryEntries[index - 1][0];
}
}
};
mqlList.push({ mql, handleChange });
mql.addEventListener("change", handleChange);
});
vueDemi.onUnmounted(() => {
mqlList.forEach((item) => {
item.mql.removeEventListener("change", item.handleChange);
});
});
return activeKey;
}
const defaultOptions$3 = {
type: "click",
target: defaultWindow ? defaultWindow.document.body : void 0,
onSuccess: () => {
}
};
function useMousePosition(options) {
const { type, target, onSuccess } = { ...defaultOptions$3, ...options };
const clickX = vueDemi.ref(-1);
const clickY = vueDemi.ref(-1);
if (!isClient || !target) {
return {
clickX,
clickY
};
}
let elm = target;
const handler = (event) => {
clickX.value = event.pageX;
clickY.value = event.pageY;
onSuccess();
};
vueDemi.onMounted(() => {
elm = vueDemi.isRef(target) ? target.value : target;
if (type === "click") {
elm.addEventListener("click", handler);
} else {
elm.addEventListener("mousemove", handler);
}
});
vueDemi.onBeforeUnmount(() => {
elm = vueDemi.isRef(target) ? target.value : target;
elm.removeEventListener("click", handler);
elm.removeEventListener("mousemove", handler);
});
return { clickX, clickY };
}
const getConnection = () => {
const nav = navigator;
if (typeof nav !== "object")
return null;
return nav.connection || nav.mozConnection || nav.webkitConnection;
};
const handlerSetConnection = () => {
const connection = getConnection();
return {
rtt: connection.rtt,
type: connection.type,
saveData: connection.saveData,
downlink: connection.downlink,
downlinkMax: connection.downlinkMax,
effectiveType: connection.effectiveType
};
};
function useNetwork() {
if (!isClient)
return vueDemi.reactive({});
const state = vueDemi.reactive({
online: navigator.onLine,
since: Date.now(),
...handlerSetConnection()
});
const onOnline = () => {
state.online = true;
state.since = Date.now();
};
const onOffline = () => {
state.online = false;
state.since = Date.now();
};
const onConnectionChange = () => {
const connectionData = handlerSetConnection();
Object.keys(connectionData).forEach((key) => {
const propertyKey = key;
state[propertyKey] = connectionData[propertyKey];
});
};
vueDemi.onMounted(() => {
window.addEventListener("online", onOnline);
window.addEventListener("offline", onOffline);
getConnection()?.addEventListener("change", onConnectionChange);
});
vueDemi.onUnmounted(() => {
window.removeEventListener("online", onOnline);
window.removeEventListener("offline", onOffline);
getConnection()?.removeEventListener("change", onConnectionChange);
});
return state;
}
var easy_qrcode_min = {exports: {}};
/**
* EasyQRCodeJS
*
* Cross-browser QRCode generator for pure javascript. Support Canvas, SVG and Table drawing methods. Support Dot style, Logo, Background image, Colorful, Title etc. settings. Support Angular, Vue.js, React, Next.js, Svelte framework. Support binary(hex) data mode.(Running with DOM on client side)
*
* Version 4.4.13
*
* @author [ inthinkcolor@gmail.com ]
*
* @see https://github.com/ushelp/EasyQRCodeJS
* @see http://www.easyproject.cn/easyqrcodejs/tryit.html
* @see https://github.com/ushelp/EasyQRCodeJS-NodeJS
*
* Copyright 2017 Ray, EasyProject
* Released under the MIT license
*
* [Support AMD, CMD, CommonJS/Node.js]
*
*/
(function (module, exports) {
!function(){function a(a,b){var c,d=Object.keys(b);for(c=0;c<d.length;c++)a=a.replace(new RegExp("\\{"+d[c]+"\\}","gi"),b[d[c]]);return a}function b(a){var b,c,d;if(!a)throw new Error("cannot create a random attribute name for an undefined object");b="ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",c="";do{for(c="",d=0;d<12;d++)c+=b[Math.floor(Math.random()*b.length)];}while(a[c]);return c}function c(a){var b={left:"start",right:"end",center:"middle",start:"start",end:"end"};return b[a]||b.start}function d(a){var b={alphabetic:"alphabetic",hanging:"hanging",top:"text-before-edge",bottom:"text-after-edge",middle:"central"};return b[a]||b.alphabetic}var e,f,g,h,i;i=function(a,b){var c,d,e,f={};for(a=a.split(","),b=b||10,c=0;c<a.length;c+=2)d="&"+a[c+1]+";",e=parseInt(a[c],b),f[d]="&#"+e+";";return f["\\xa0"]=" ",f}("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32),e={strokeStyle:{svgAttr:"stroke",canvas:"#000000",svg:"none",apply:"stroke"},fillStyle:{svgAttr:"fill",canvas:"#000000",svg:null,apply:"fill"},lineCap:{svgAttr:"stroke-linecap",canvas:"butt",svg:"butt",apply:"stroke"},lineJoin:{svgAttr:"stroke-linejoin",canvas:"miter",svg:"miter",apply:"stroke"},miterLimit:{svgAttr:"stroke-miterlimit",canvas:10,svg:4,apply:"stroke"},lineWidth:{svgAttr:"stroke-width",canvas:1,svg:1,apply:"stroke"},globalAlpha:{svgAttr:"opacity",canvas:1,svg:1,apply:"fill stroke"},font:{canvas:"10px sans-serif"},shadowColor:{canvas:"#000000"},shadowOffsetX:{canvas:0},shadowOffsetY:{canvas:0},shadowBlur:{canvas:0},textAlign:{canvas:"start"},textBaseline:{canvas:"alphabetic"},lineDash:{svgAttr:"stroke-dasharray",canvas:[],svg:null,apply:"stroke"}},g=function(a,b){this.__root=a,this.__ctx=b;},g.prototype.addColorStop=function(b,c){var d,e,f=this.__ctx.__createElement("stop");f.setAttribute("offset",b),-1!==c.indexOf("rgba")?(d=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi,e=d.exec(c),f.setAttribute("stop-color",a("rgb({r},{g},{b})",{r:e[1],g:e[2],b:e[3]})),f.setAttribute("stop-opacity",e[4])):f.setAttribute("stop-color",c),this.__root.appendChild(f);},h=function(a,b){this.__root=a,this.__ctx=b;},f=function(a){var b,c={width:500,height:500,enableMirroring:!1};if(arguments.length>1?(b=c,b.width=arguments[0],b.height=arguments[1]):b=a||c,!(this instanceof f))return new f(b);this.width=b.width||c.width,this.height=b.height||c.height,this.enableMirroring=void 0!==b.enableMirroring?b.enableMirroring:c.enableMirroring,this.canvas=this,this.__document=b.document||document,b.ctx?this.__ctx=b.ctx:(this.__canvas=this.__document.createElement("canvas"),this.__ctx=this.__canvas.getContext("2d")),this.__setDefaultStyles(),this.__stack=[this.__getStyleState()],this.__groupStack=[],this.__root=this.__document.createElementNS("http://www.w3.org/2000/svg","svg"),this.__root.setAttribute("version",1.1),this.__root.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.__root.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink"),this.__root.setAttribute("width",this.width),this.__root.setAttribute("height",this.height),this.__ids={},this.__defs=this.__document.createElementNS("http://www.w3.org/2000/svg","defs"),this.__root.appendChild(this.__defs),this.__currentElement=this.__document.createElementNS("http://www.w3.org/2000/svg","g"),this.__root.appendChild(this.__currentElement);},f.prototype.__createElement=function(a,b,c){void 0===b&&(b={});var d,e,f=this.__document.createElementNS("http://www.w3.org/2000/svg",a),g=Object.keys(b);for(c&&(f.setAttribute("fill","none"),f.setAttribute("stroke","none")),d=0;d<g.length;d++)e=g[d],f.setAttribute(e,b[e]);return f},f.prototype.__setDefaultStyles=function(){var a,b,c=Object.keys(e);for(a=0;a<c.length;a++)b=c[a],this[b]=e[b].canvas;},f.prototype.__applyStyleState=function(a){var b,c,d=Object.keys(a);for(b=0;b<d.length;b++)c=d[b],this[c]=a[c];},f.prototype.__getStyleState=function(){var a,b,c={},d=Object.keys(e);for(a=0;a<d.length;a++)b=d[a],c[b]=this[b];return c},f.prototype.__applyStyleToCurrentElement=function(b){var c=this.__currentElement,d=this.__currentElementsToStyle;d&&(c.setAttribute(b,""),c=d.element,d.children.forEach(function(a){a.setAttribute(b,"");}));var f,i,j,k,l,m,n=Object.keys(e);for(f=0;f<n.length;f++)if(i=e[n[f]],j=this[n[f]],i.apply)if(j instanceof h){if(j.__ctx)for(;j.__ctx.__defs.childNodes.length;)k=j.__ctx.__defs.childNodes[0].getAttribute("id"),this.__ids[k]=k,this.__defs.appendChild(j.__ctx.__defs.childNodes[0]);c.setAttribute(i.apply,a("url(#{id})",{id:j.__root.getAttribute("id")}));}else if(j instanceof g)c.setAttribute(i.apply,a("url(#{id})",{id:j.__root.getAttribute("id")}));else if(-1!==i.apply.indexOf(b)&&i.svg!==j)if("stroke"!==i.svgAttr&&"fill"!==i.svgAttr||-1===j.indexOf("rgba")){var o=i.svgAttr;if("globalAlpha"===n[f]&&(o=b+"-"+i.svgAttr,c.getAttribute(o)))continue;c.setAttribute(o,j);}else {l=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi,m=l.exec(j),c.setAttribute(i.svgAttr,a("rgb({r},{g},{b})",{r:m[1],g:m[2],b:m[3]}));var p=m[4],q=this.globalAlpha;null!=q&&(p*=q),c.setAttribute(i.svgAttr+"-opacity",p);}},f.prototype.__closestGroupOrSvg=function(a){return a=a||this.__currentElement,"g"===a.nodeName||"svg"===a.nodeName?a:this.__closestGroupOrSvg(a.parentNode)},f.prototype.getSerializedSvg=function(a){var b,c,d,e,f,g,h=(new XMLSerializer).serializeToString(this.__root);if(g=/xmlns="http:\/\/www\.w3\.org\/2000\/svg".+xmlns="http:\/\/www\.w3\.org\/2000\/svg/gi,g.test(h)&&(h=h.replace('xmlns="http://www.w3.org/2000/svg','xmlns:xlink="http://www.w3.org/1999/xlink')),a)for(b=Object.keys(i),c=0;c<b.length;c++)d=b[c],e=i[d],f=new RegExp(d,"gi"),f.test(h)&&(h=h.replace(f,e));return h},f.prototype.getSvg=function(){return this.__root},f.prototype.save=function(){var a=this.__createElement("g"),b=this.__closestGroupOrSvg();this.__groupStack.push(b),b.appendChild(a),this.__currentElement=a,this.__stack.push(this.__getStyleState());},f.prototype.restore=function(){this.__currentElement=this.__groupStack.pop(),this.__currentElementsToStyle=null,this.__currentElement||(this.__currentElement=this.__root.childNodes[1]);var a=this.__stack.pop();this.__applyStyleState(a);},f.prototype.__addTransform=function(a){var b=this.__closestGroupOrSvg();if(b.childNodes.length>0){"path"===this.__currentElement.nodeName&&(this.__currentElementsToStyle||(this.__currentElementsToStyle={element:b,children:[]}),this.__currentElementsToStyle.children.push(this.__currentElement),this.__applyCurrentDefaultPath());var c=this.__createElement("g");b.appendChild(c),this.__currentElement=c;}var d=this.__currentElement.getAttribute("transform");d?d+=" ":d="",d+=a,this.__currentElement.setAttribute("transform",d);},f.prototype.scale=function(b,c){void 0===c&&(c=b),this.__addTransform(a("scale({x},{y})",{x:b,y:c}));},f.prototype.rotate=function(b){var c=180*b/Math.PI;this.__addTransform(a("rotate({angle},{cx},{cy})",{angle:c,cx:0,cy:0}));},f.prototype.translate=function(b,c){this.__addTransform(a("translate({x},{y})",{x:b,y:c}));},f.prototype.transform=function(b,c,d,e,f,g){this.__addTransform(a("matrix({a},{b},{c},{d},{e},{f})",{a:b,b:c,c:d,d:e,e:f,f:g}));},f.prototype.beginPath=function(){var a,b;this.__currentDefaultPath="",this.__currentPosition={},a=this.__createElement("path",{},!0),b=this.__closestGroupOrSvg(),b.appendChild(a),this.__currentElement=a;},f.prototype.__applyCurrentDefaultPath=function(){var a=this.__currentElement;"path"===a.nodeName?a.setAttribute("d",this.__currentDefaultPath):console.error("Attempted to apply path command to node",a.nodeName);},f.prototype.__addPathCommand=function(a){this.__currentDefaultPath+=" ",this.__currentDefaultPath+=a;},f.prototype.moveTo=function(b,c){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.__currentPosition={x:b,y:c},this.__addPathCommand(a("M {x} {y}",{x:b,y:c}));},f.prototype.closePath=function(){this.__currentDefaultPath&&this.__addPathCommand("Z");},f.prototype.lineTo=function(b,c){this.__currentPosition={x:b,y:c},this.__currentDefaultPath.indexOf("M")>-1?this.__addPathCommand(a("L {x} {y}",{x:b,y:c})):this.__addPathCommand(a("M {x} {y}",{x:b,y:c}));},f.prototype.bezierCurveTo=function(b,c,d,e,f,g){this.__currentPosition={x:f,y:g},this.__addPathCommand(a("C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",{cp1x:b,cp1y:c,cp2x:d,cp2y:e,x:f,y:g}));},f.prototype.quadraticCurveTo=function(b,c,d,e){this.__currentPosition={x:d,y:e},this.__addPathCommand(a("Q {cpx} {cpy} {x} {y}",{cpx:b,cpy:c,x:d,y:e}));};var j=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]);return [a[0]/b,a[1]/b]};f.prototype.arcTo=function(a,b,c,d,e){var f=this.__currentPosition&&this.__currentPosition.x,g=this.__currentPosition&&this.__currentPosition.y;if(void 0!==f&&void 0!==g){if(e<0)throw new Error("IndexSizeError: The radius provided ("+e+") is negative.");if(f===a&&g===b||a===c&&b===d||0===e)return void this.lineTo(a,b);var h=j([f-a,g-b]),i=j([c-a,d-b]);if(h[0]*i[1]==h[1]*i[0])return void this.lineTo(a,b);var k=h[0]*i[0]+h[1]*i[1],l=Math.acos(Math.abs(k)),m=j([h[0]+i[0],h[1]+i[1]]),n=e/Math.sin(l/2),o=a+n*m[0],p=b+n*m[1],q=[-h[1],h[0]],r=[i[1],-i[0]],s=function(a){var b=a[0];return a[1]>=0?Math.acos(b):-Math.acos(b)},t=s(q),u=s(r);this.lineTo(o+q[0]*e,p+q[1]*e),this.arc(o,p,e,t,u);}},f.prototype.stroke=function(){"path"===this.__currentElement.nodeName&&this.__currentElement.setAttribute("paint-order","fill stroke markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("stroke");},f.prototype.fill=function(){"path"===this.__currentElement.nodeName&&this.__currentElement.setAttribute("paint-order","stroke fill markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("fill");},f.prototype.rect=function(a,b,c,d){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.moveTo(a,b),this.lineTo(a+c,b),this.lineTo(a+c,b+d),this.lineTo(a,b+d),this.lineTo(a,b),this.closePath();},f.prototype.fillRect=function(a,b,c,d){var e,f;e=this.__createElement("rect",{x:a,y:b,width:c,height:d,"shape-rendering":"crispEdges"},!0),f=this.__closestGroupOrSvg(),f.appendChild(e),this.__currentElement=e,this.__applyStyleToCurrentElement("fill");},f.prototype.strokeRect=function(a,b,c,d){var e,f;e=this.__createElement("rect",{x:a,y:b,width:c,height:d},!0),f=this.__closestGroupOrSvg(),f.appendChild(e),this.__currentElement=e,this.__applyStyleToCurrentElement("stroke");},f.prototype.__clearCanvas=function(){for(var a=this.__closestGroupOrSvg(),b=a.getAttribute("transform"),c=this.__root.childNodes[1],d=c.childNodes,e=d.length-1;e>=0;e--)d[e]&&c.removeChild(d[e]);this.__currentElement=c,this.__groupStack=[],b&&this.__addTransform(b);},f.prototype.clearRect=function(a,b,c,d){if(0===a&&0===b&&c===this.width&&d===this.height)return void this.__clearCanvas();var e,f=this.__closestGroupOrSvg();e=this.__createElement("rect",{x:a,y:b,width:c,height:d,fill:"#FFFFFF"},!0),f.appendChild(e);},f.prototype.createLinearGradient=function(a,c,d,e){var f=this.__createElement("linearGradient",{id:b(this.__ids),x1:a+"px",x2:d+"px",y1:c+"px",y2:e+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(f),new g(f,this)},f.prototype.createRadialGradient=function(a,c,d,e,f,h){var i=this.__createElement("radialGradient",{id:b(this.__ids),cx:e+"px",cy:f+"px",r:h+"px",fx:a+"px",fy:c+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(i),new g(i,this)},f.prototype.__parseFont=function(){var a=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-,\'\"\sa-z0-9]+?)\s*$/i,b=a.exec(this.font),c={style:b[1]||"normal",size:b[4]||"10px",family:b[6]||"sans-serif",weight:b[3]||"normal",decoration:b[2]||"normal",href:null};return "underline"===this.__fontUnderline&&(c.decoration="underline"),this.__fontHref&&(c.href=this.__fontHref),c},f.prototype.__wrapTextLink=function(a,b){if(a.href){var c=this.__createElement("a");return c.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.href),c.appendChild(b),c}return b},f.prototype.__applyText=function(a,b,e,f){var g=this.__parseFont(),h=this.__closestGroupOrSvg(),i=this.__createElement("text",{"font-family":g.family,"font-size":g.size,"font-style":g.style,"font-weight":g.weight,"text-decoration":g.decoration,x:b,y:e,"text-anchor":c(this.textAlign),"dominant-baseline":d(this.textBaseline)},!0);i.appendChild(this.__document.createTextNode(a)),this.__currentElement=i,this.__applyStyleToCurrentElement(f),h.appendChild(this.__wrapTextLink(g,i));},f.prototype.fillText=function(a,b,c){this.__applyText(a,b,c,"fill");},f.prototype.strokeText=function(a,b,c){this.__applyText(a,b,c,"stroke");},f.prototype.measureText=function(a){return this.__ctx.font=this.font,this.__ctx.measureText(a)},f.prototype.arc=function(b,c,d,e,f,g){if(e!==f){e%=2*Math.PI,f%=2*Math.PI,e===f&&(f=(f+2*Math.PI-.001*(g?-1:1))%(2*Math.PI));var h=b+d*Math.cos(f),i=c+d*Math.sin(f),j=b+d*Math.cos(e),k=c+d*Math.sin(e),l=g?0:1,m=0,n=f-e;n<0&&(n+=2*Math.PI),m=g?n>Math.PI?0:1:n>Math.PI?1:0,this.lineTo(j,k),this.__addPathCommand(a("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:d,ry:d,xAxisRotation:0,largeArcFlag:m,sweepFlag:l,endX:h,endY:i})),this.__currentPosition={x:h,y:i};}},f.prototype.clip=function(){var c=this.__closestGroupOrSvg(),d=this.__createElement("clipPath"),e=b(this.__ids),f=this.__createElement("g");this.__applyCurrentDefaultPath(),c.removeChild(this.__currentElement),d.setAttribute("id",e),d.appendChild(this.__currentElement),this.__defs.appendChild(d),c.setAttribute("clip-path",a("url(#{id})",{id:e})),c.appendChild(f),this.__currentElement=f;},f.prototype.drawImage=function(){var a,b,c,d,e,g,h,i,j,k,l,m,n,o,p=Array.prototype.slice.call(arguments),q=p[0],r=0,s=0;if(3===p.length)a=p[1],b=p[2],e=q.width,g=q.height,c=e,d=g;else if(5===p.length)a=p[1],b=p[2],c=p[3],d=p[4],e=q.width,g=q.height;else {if(9!==p.length)throw new Error("Invalid number of arguments passed to drawImage: "+arguments.length);r=p[1],s=p[2],e=p[3],g=p[4],a=p[5],b=p[6],c=p[7],d=p[8];}h=this.__closestGroupOrSvg(),this.__currentElement;var t="translate("+a+", "+b+")";if(q instanceof f){if(i=q.getSvg().cloneNode(!0),i.childNodes&&i.childNodes.length>1){for(j=i.childNodes[0];j.childNodes.length;)o=j.childNodes[0].getAttribute("id"),this.__ids[o]=o,this.__defs.appendChild(j.childNodes[0]);if(k=i.childNodes[1]){var u,v=k.getAttribute("transform");u=v?v+" "+t:t,k.setAttribute("transform",u),h.appendChild(k);}}}else "CANVAS"!==q.nodeName&&"IMG"!==q.nodeName||(l=this.__createElement("image"),l.setAttribute("width",c),l.setAttribute("height",d),l.setAttribute("preserveAspectRatio","none"),l