-
Notifications
You must be signed in to change notification settings - Fork 3
/
localforage-8485d017.js
73 lines (73 loc) · 77.5 KB
/
localforage-8485d017.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*!
* .::::.
* .::::::::.
* ::::::::::: winsay v2.0.21
* ..:::::::::::'
* '::::::::::::'
* .::::::::::
* '::::::::::::::..
* ..::::::::::::.
* .''::::::::::::::::
* ::::'':::::::::' .:::.
* ::::' ':::::' .::::::::.
* .::::' :::: .:::::::'::::.
* .:::' ::::: .:::::::::' ':::::.
* .::' :::::.:::::::::' ':::::.
* .::' ::::::::::::::' ''::::.
* ...::: ::::::::::::' ''::.
* '''' ':. ':::::::::' ::::..
* '.:::::' ':'''''..
*
*
* https://github.com/Hi-Windom/winsay
* QQ 694357845
*
* For the brave souls who get this far: You are the chosen ones,
* the valiant knights of programming who toil away, without rest,
* fixing our most awful code. To you, true saviors, kings of men,
* I say this: never gonna give you up, never gonna let you down,
* never gonna run around and desert you. Never gonna make you cry,
* never gonna say goodbye. Never gonna tell a lie and hurt you.
*
*/
const e=document.getElementById("themeStyle"),t="theme-color-style";var n="Sofill",r="winsay";switch(n=window.siyuan.config.appearance.mode?window.siyuan.config.appearance.themeDark:window.siyuan.config.appearance.themeLight){case"Sofill+":r="lanco";break;case"Sofill=":r="lili"}const o={STYLE_COLOR:"custom-id-style-theme-color",BUTTON_TOOLBAR_CHANGE_COLOR:"custom-id-button-toolbar-change-color"},i=["root.css","root-L-Blue.css","root-L-Red.css","root-L-Pink.css","root-L-Green.css","root-L-Yellow.css"],a="root.css",c=["root-D-BlackGoldBlue.css","root-D-InkGreenPurple.css"],u="root-D-BlackGoldBlue.css",s="SC_winsay_cp_custom__LS",f="SC_winsay_cp_custom__DS";var l=function*(e){for(let t=0;;t=(t+1)%e.length)yield e[t]},d=function*(e){for(let t=0;;t=(t+1)%e.length)yield e[t]},h=(()=>{let e=new URL(window.location.href);switch(!0){case e.pathname.startsWith("/stage/build/app"):return"body--app";case e.pathname.startsWith("/stage/build/desktop"):return"body--desktop";case e.pathname.startsWith("/stage/build/mobile"):return"body--mobile";default:return null}})();window.siyuan.config.api.token;const v="Sofill-";window.winsay={cp:{awaitInitItem:0,inited:0,listened:0},funs:{},ekits:{},where:{themeRoot:window.lili?`${window.lili.where.themeRoot}eHiWindom/winsay/`:`/appearance/themes/${v}/`,localThemeName:window.lili?"winsay":v},storage:{}};let p="";if(1===window.siyuan.config.appearance.mode)document.body.classList.add("mode--dark"),window.lili||(window.winsay.where.localThemeName=window.siyuan.config.appearance.themeDark,p=new URL(e.href).pathname.replace("theme.css",""));else document.body.classList.add("mode--light"),window.lili||(window.winsay.where.localThemeName=window.siyuan.config.appearance.themeLight,p=new URL(e.href).pathname.replace("theme.css",""));window.siyuan.config.system.confDir;const y=`${p}style-S2/`
/*!
* sofill v1.0.76
* https://github.com/Hi-Windom/Sofill
* https://www.npmjs.com/package/sofill
*/;function m(e,t,n=null){var r=document.createElement(t);return n&&(r.id=n),e.appendChild(r),r}const b=e=>{document.body.classList.add(e)},g=e=>{document.body.classList.remove(e)},w=e=>document.body.classList.contains(e),_=(e,t)=>{document.documentElement.style.setProperty(e,t)},I=e=>{document.documentElement.style.removeProperty(e)};
/*!
* sofill v1.0.76
* https://github.com/Hi-Windom/Sofill
* https://www.npmjs.com/package/sofill
*/
var S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function E(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var k={};
/*!
* sofill v1.0.76
* https://github.com/Hi-Windom/Sofill
* https://www.npmjs.com/package/sofill
*/
function N(e,t){const n=e.split("."),r=t.split("."),o=n.length,i=r.length,a=Math.min(o,i);let c=0;for(;c<a;c++){let e=parseInt(n[c]),t=parseInt(r[c]);if(e>t)return 1;if(e<t)return-1}if(o>i){for(let e=c;e<o;e++)if(0!==parseInt(n[e]))return 1;return 0}if(o<i){for(let e=c;e<i;e++)if(0!==parseInt(r[e]))return-1;return 0}return 0}({get exports(){return k},set exports(e){k=e}}).exports=function e(t,n,r){function o(a,c){if(!n[a]){if(!t[a]){if(!c&&E)return E(a);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[a]={exports:{}};t[a][0].call(s.exports,(function(e){var n=t[a][1][e];return o(n||e)}),s,s.exports,e,t,n,r)}return n[a].exports}for(var i=E,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t,n){(function(e){var n,r,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var i=0,a=new o(f),c=e.document.createTextNode("");a.observe(c,{characterData:!0}),n=function(){c.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){f(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(f,0)};else{var u=new e.MessageChannel;u.port1.onmessage=f,n=function(){u.port2.postMessage(0)}}var s=[];function f(){var e,t;r=!0;for(var n=s.length;n;){for(t=s,s=[],e=-1;++e<n;)t[e]();n=s.length}r=!1}function l(e){1!==s.push(e)||r||n()}t.exports=l}).call(this,void 0!==S?S:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){var r=e(1);function o(){}var i={},a=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function s(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,e!==o&&h(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r((function(){var r;try{r=t(n)}catch(t){return i.reject(e,t)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var n=!1;function r(t){n||(n=!0,i.reject(e,t))}function o(t){n||(n=!0,i.resolve(e,t))}function a(){t(o,r)}var c=v(a);"error"===c.status&&r(c.value)}function v(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}function p(e){return e instanceof this?e:i.resolve(new this(o),e)}function y(e){var t=new this(o);return i.reject(t,e)}function m(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var a=new Array(n),c=0,u=-1,s=new this(o);++u<n;)f(e[u],u);return s;function f(e,o){function u(e){a[o]=e,++c!==n||r||(r=!0,i.resolve(s,a))}t.resolve(e).then(u,(function(e){r||(r=!0,i.reject(s,e))}))}}function b(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var a=-1,c=new this(o);++a<n;)u(e[a]);return c;function u(e){t.resolve(e).then((function(e){r||(r=!0,i.resolve(c,e))}),(function(e){r||(r=!0,i.reject(c,e))}))}}t.exports=s,s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){if("function"!=typeof e&&this.state===c||"function"!=typeof t&&this.state===a)return this;var n=new this.constructor(o);return this.state!==u?l(n,this.state===c?e:t,this.outcome):this.queue.push(new f(n,e,t)),n},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var n=v(d,t);if("error"===n.status)return i.reject(e,n.value);var r=n.value;if(r)h(e,r);else{e.state=c,e.outcome=t;for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(t)}return e},i.reject=function(e,t){e.state=a,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},s.resolve=p,s.reject=y,s.all=m,s.race=b},{1:1}],3:[function(e,t,n){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==S?S:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,n){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var a=i();function c(){try{if(!a||!a.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function u(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var s=Promise;function f(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function l(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function d(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function h(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var v="local-forage-detect-blob-support",p=void 0,y={},m=Object.prototype.toString,b="readonly",g="readwrite";function w(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o);return n}function _(e){return new s((function(t){var n=e.transaction(v,g),r=u([""]);n.objectStore(v).put(r,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function I(e){return"boolean"==typeof p?s.resolve(p):_(e).then((function(e){return p=e}))}function S(e){var t=y[e.name],n={};n.promise=new s((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function E(e){var t=y[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function k(e,t){var n=y[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function N(e,t){return new s((function(n,r){if(y[e.name]=y[e.name]||L(),e.db){if(!t)return n(e.db);S(e),e.db.close()}var o=[e.name];t&&o.push(e.version);var i=a.open.apply(a,o);t&&(i.onupgradeneeded=function(t){var n=i.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(v)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),i.onerror=function(e){e.preventDefault(),r(i.error)},i.onsuccess=function(){var t=i.result;t.onversionchange=function(e){e.target.close()},n(t),E(e)}}))}function D(e){return N(e,!1)}function B(e){return N(e,!0)}function R(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),r=e.version<e.db.version,o=e.version>e.db.version;if(r&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||n){if(n){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function A(e){return new s((function(t,n){var r=new FileReader;r.onerror=n,r.onloadend=function(n){var r=btoa(n.target.result||"");t({__local_forage_encoded_blob:!0,data:r,type:e.type})},r.readAsBinaryString(e)}))}function j(e){return u([w(atob(e.data))],{type:e.type})}function O(e){return e&&e.__local_forage_encoded_blob}function T(e){var t=this,n=t._initReady().then((function(){var e=y[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return l(n,e,e),n}function C(e){S(e);for(var t=y[e.name],n=t.forages,r=0;r<n.length;r++){var o=n[r];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,D(e).then((function(t){return e.db=t,R(e)?B(e):t})).then((function(r){e.db=t.db=r;for(var o=0;o<n.length;o++)n[o]._dbInfo.db=r})).catch((function(t){throw k(e,t),t}))}function x(e,t,n,r){void 0===r&&(r=1);try{var o=e.db.transaction(e.storeName,t);n(null,o)}catch(o){if(r>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return s.resolve().then((function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),B(e)})).then((function(){return C(e).then((function(){x(e,t,n,r-1)}))})).catch(n);n(o)}}function L(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function F(e){var t=this,n={db:null};if(e)for(var r in e)n[r]=e[r];var o=y[n.name];o||(o=L(),y[n.name]=o),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=T);var i=[];function a(){return s.resolve()}for(var c=0;c<o.forages.length;c++){var u=o.forages[c];u!==t&&i.push(u._initReady().catch(a))}var f=o.forages.slice(0);return s.all(i).then((function(){return n.db=o.db,D(n)})).then((function(e){return n.db=e,R(n,t._defaultConfig.version)?B(n):e})).then((function(e){n.db=o.db=e,t._dbInfo=n;for(var r=0;r<f.length;r++){var i=f[r];i!==t&&(i._dbInfo.db=n.db,i._dbInfo.version=n.version)}}))}function P(e,t){var n=this;e=d(e);var r=new s((function(t,r){n.ready().then((function(){x(n._dbInfo,b,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),O(e)&&(e=j(e)),t(e)},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return f(r,t),r}function M(e,t){var n=this,r=new s((function(t,r){n.ready().then((function(){x(n._dbInfo,b,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).openCursor(),c=1;a.onsuccess=function(){var n=a.result;if(n){var r=n.value;O(r)&&(r=j(r));var o=e(r,n.key,c++);void 0!==o?t(o):n.continue()}else t()},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return f(r,t),r}function z(e,t,n){var r=this;e=d(e);var o=new s((function(n,o){var i;r.ready().then((function(){return i=r._dbInfo,"[object Blob]"===m.call(t)?I(i.db).then((function(e){return e?t:A(t)})):t})).then((function(t){x(r._dbInfo,g,(function(i,a){if(i)return o(i);try{var c=a.objectStore(r._dbInfo.storeName);null===t&&(t=void 0);var u=c.put(t,e);a.oncomplete=function(){void 0===t&&(t=null),n(t)},a.onabort=a.onerror=function(){var e=u.error?u.error:u.transaction.error;o(e)}}catch(e){o(e)}}))})).catch(o)}));return f(o,n),o}function q(e,t){var n=this;e=d(e);var r=new s((function(t,r){n.ready().then((function(){x(n._dbInfo,g,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).delete(e);i.oncomplete=function(){t()},i.onerror=function(){r(a.error)},i.onabort=function(){var e=a.error?a.error:a.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return f(r,t),r}function U(e){var t=this,n=new s((function(e,n){t.ready().then((function(){x(t._dbInfo,g,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).clear();o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=i.error?i.error:i.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return f(n,e),n}function W(e){var t=this,n=new s((function(e,n){t.ready().then((function(){x(t._dbInfo,b,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).count();i.onsuccess=function(){e(i.result)},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return f(n,e),n}function H(e,t){var n=this,r=new s((function(t,r){e<0?t(null):n.ready().then((function(){x(n._dbInfo,b,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName),c=!1,u=a.openKeyCursor();u.onsuccess=function(){var n=u.result;n?0===e||c?t(n.key):(c=!0,n.advance(e)):t(null)},u.onerror=function(){r(u.error)}}catch(e){r(e)}}))})).catch(r)}));return f(r,t),r}function $(e){var t=this,n=new s((function(e,n){t.ready().then((function(){x(t._dbInfo,b,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).openKeyCursor(),a=[];i.onsuccess=function(){var t=i.result;t?(a.push(t.key),t.continue()):e(a)},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return f(n,e),n}function G(e,t){t=h.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,o=this;if(e.name){var i=e.name===n.name&&o._dbInfo.db?s.resolve(o._dbInfo.db):D(e).then((function(t){var n=y[e.name],r=n.forages;n.db=t;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=t;return t}));r=e.storeName?i.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1;S(e);var r=y[e.name],o=r.forages;t.close();for(var i=0;i<o.length;i++){var c=o[i];c._dbInfo.db=null,c._dbInfo.version=n}var u=new s((function(t,r){var o=a.open(e.name,n);o.onerror=function(e){o.result.close(),r(e)},o.onupgradeneeded=function(){o.result.deleteObjectStore(e.storeName)},o.onsuccess=function(){var e=o.result;e.close(),t(e)}}));return u.then((function(e){r.db=e;for(var t=0;t<o.length;t++){var n=o[t];n._dbInfo.db=e,E(n._dbInfo)}})).catch((function(t){throw(k(e,t)||s.resolve()).catch((function(){})),t}))}})):i.then((function(t){S(e);var n=y[e.name],r=n.forages;t.close();for(var o=0;o<r.length;o++)r[o]._dbInfo.db=null;var i=new s((function(t,n){var r=a.deleteDatabase(e.name);r.onerror=function(){var e=r.result;e&&e.close(),n(r.error)},r.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},r.onsuccess=function(){var e=r.result;e&&e.close(),t(e)}}));return i.then((function(e){n.db=e;for(var t=0;t<r.length;t++)E(r[t]._dbInfo)})).catch((function(t){throw(k(e,t)||s.resolve()).catch((function(){})),t}))}))}else r=s.reject("Invalid arguments");return f(r,t),r}var Q={_driver:"asyncStorage",_initStorage:F,_support:c(),iterate:M,getItem:P,setItem:z,removeItem:q,clear:U,length:W,key:H,keys:$,dropInstance:G};function K(){return"function"==typeof openDatabase}var X="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J="~~local_forage_type~",V=/^~~local_forage_type~([^~]+)~/,Y="__lfsc__:",Z=Y.length,ee="arbf",te="blob",ne="si08",re="ui08",oe="uic8",ie="si16",ae="si32",ce="ur16",ue="ui32",se="fl32",fe="fl64",le=Z+ee.length,de=Object.prototype.toString;function he(e){var t,n,r,o,i,a=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var s=new ArrayBuffer(a),f=new Uint8Array(s);for(t=0;t<c;t+=4)n=X.indexOf(e[t]),r=X.indexOf(e[t+1]),o=X.indexOf(e[t+2]),i=X.indexOf(e[t+3]),f[u++]=n<<2|r>>4,f[u++]=(15&r)<<4|o>>2,f[u++]=(3&o)<<6|63&i;return s}function ve(e){var t,n=new Uint8Array(e),r="";for(t=0;t<n.length;t+=3)r+=X[n[t]>>2],r+=X[(3&n[t])<<4|n[t+1]>>4],r+=X[(15&n[t+1])<<2|n[t+2]>>6],r+=X[63&n[t+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}function pe(e,t){var n="";if(e&&(n=de.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===de.call(e.buffer))){var r,o=Y;e instanceof ArrayBuffer?(r=e,o+=ee):(r=e.buffer,"[object Int8Array]"===n?o+=ne:"[object Uint8Array]"===n?o+=re:"[object Uint8ClampedArray]"===n?o+=oe:"[object Int16Array]"===n?o+=ie:"[object Uint16Array]"===n?o+=ce:"[object Int32Array]"===n?o+=ae:"[object Uint32Array]"===n?o+=ue:"[object Float32Array]"===n?o+=se:"[object Float64Array]"===n?o+=fe:t(new Error("Failed to get type for BinaryArray"))),t(o+ve(r))}else if("[object Blob]"===n){var i=new FileReader;i.onload=function(){var n=J+e.type+"~"+ve(this.result);t(Y+te+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}}function ye(e){if(e.substring(0,Z)!==Y)return JSON.parse(e);var t,n=e.substring(le),r=e.substring(Z,le);if(r===te&&V.test(n)){var o=n.match(V);t=o[1],n=n.substring(o[0].length)}var i=he(n);switch(r){case ee:return i;case te:return u([i],{type:t});case ne:return new Int8Array(i);case re:return new Uint8Array(i);case oe:return new Uint8ClampedArray(i);case ie:return new Int16Array(i);case ce:return new Uint16Array(i);case ae:return new Int32Array(i);case ue:return new Uint32Array(i);case se:return new Float32Array(i);case fe:return new Float64Array(i);default:throw new Error("Unkown type: "+r)}}var me={serialize:pe,deserialize:ye,stringToBuffer:he,bufferToString:ve};function be(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function ge(e){var t=this,n={db:null};if(e)for(var r in e)n[r]="string"!=typeof e[r]?e[r].toString():e[r];var o=new s((function(e,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return r(e)}n.db.transaction((function(o){be(o,n,(function(){t._dbInfo=n,e()}),(function(e,t){r(t)}))}),r)}));return n.serializer=me,o}function we(e,t,n,r,o,i){e.executeSql(n,r,o,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,c){c.rows.length?i(e,a):be(e,t,(function(){e.executeSql(n,r,o,i)}),i)}),i):i(e,a)}),i)}function _e(e,t){var n=this;e=d(e);var r=new s((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){we(n,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,n){var r=n.rows.length?n.rows.item(0).value:null;r&&(r=o.serializer.deserialize(r)),t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return f(r,t),r}function Ie(e,t){var n=this,r=new s((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){we(n,o,"SELECT * FROM "+o.storeName,[],(function(n,r){for(var i=r.rows,a=i.length,c=0;c<a;c++){var u=i.item(c),s=u.value;if(s&&(s=o.serializer.deserialize(s)),void 0!==(s=e(s,u.key,c+1)))return void t(s)}t()}),(function(e,t){r(t)}))}))})).catch(r)}));return f(r,t),r}function Se(e,t,n,r){var o=this;e=d(e);var i=new s((function(i,a){o.ready().then((function(){void 0===t&&(t=null);var c=t,u=o._dbInfo;u.serializer.serialize(t,(function(t,s){s?a(s):u.db.transaction((function(n){we(n,u,"INSERT OR REPLACE INTO "+u.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){i(c)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(r>0)return void i(Se.apply(o,[e,c,n,r-1]));a(t)}}))}))})).catch(a)}));return f(i,n),i}function Ee(e,t,n){return Se.apply(this,[e,t,n,1])}function ke(e,t){var n=this;e=d(e);var r=new s((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){we(n,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){r(t)}))}))})).catch(r)}));return f(r,t),r}function Ne(e){var t=this,n=new s((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){we(t,r,"DELETE FROM "+r.storeName,[],(function(){e()}),(function(e,t){n(t)}))}))})).catch(n)}));return f(n,e),n}function De(e){var t=this,n=new s((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){we(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],(function(t,n){var r=n.rows.item(0).c;e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return f(n,e),n}function Be(e,t){var n=this,r=new s((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){we(n,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,n){var r=n.rows.length?n.rows.item(0).key:null;t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return f(r,t),r}function Re(e){var t=this,n=new s((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){we(t,r,"SELECT key FROM "+r.storeName,[],(function(t,n){for(var r=[],o=0;o<n.rows.length;o++)r.push(n.rows.item(o).key);e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return f(n,e),n}function Ae(e){return new s((function(t,n){e.transaction((function(r){r.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,r){for(var o=[],i=0;i<r.rows.length;i++)o.push(r.rows.item(i).name);t({db:e,storeNames:o})}),(function(e,t){n(t)}))}),(function(e){n(e)}))}))}function je(e,t){t=h.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,o=this;return f(r=e.name?new s((function(t){var r;r=e.name===n.name?o._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:r,storeNames:[e.storeName]}):t(Ae(r))})).then((function(e){return new s((function(t,n){e.db.transaction((function(r){function o(e){return new s((function(t,n){r.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){n(t)}))}))}for(var i=[],a=0,c=e.storeNames.length;a<c;a++)i.push(o(e.storeNames[a]));s.all(i).then((function(){t()})).catch((function(e){n(e)}))}),(function(e){n(e)}))}))})):s.reject("Invalid arguments"),t),r}var Oe={_driver:"webSQLStorage",_initStorage:ge,_support:K(),iterate:Ie,getItem:_e,setItem:Ee,removeItem:ke,clear:Ne,length:De,key:Be,keys:Re,dropInstance:je};function Te(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function Ce(e,t){var n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}function xe(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function Le(){return!xe()||localStorage.length>0}function Fe(e){var t=this,n={};if(e)for(var r in e)n[r]=e[r];return n.keyPrefix=Ce(e,t._defaultConfig),Le()?(t._dbInfo=n,n.serializer=me,s.resolve()):s.reject()}function Pe(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n);0===r.indexOf(e)&&localStorage.removeItem(r)}}));return f(n,e),n}function Me(e,t){var n=this;e=d(e);var r=n.ready().then((function(){var t=n._dbInfo,r=localStorage.getItem(t.keyPrefix+e);return r&&(r=t.serializer.deserialize(r)),r}));return f(r,t),r}function ze(e,t){var n=this,r=n.ready().then((function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,c=0;c<i;c++){var u=localStorage.key(c);if(0===u.indexOf(r)){var s=localStorage.getItem(u);if(s&&(s=t.serializer.deserialize(s)),void 0!==(s=e(s,u.substring(o),a++)))return s}}}));return f(r,t),r}function qe(e,t){var n=this,r=n.ready().then((function(){var t,r=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(r.keyPrefix.length)),t}));return f(r,t),r}function Ue(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,r=[],o=0;o<n;o++){var i=localStorage.key(o);0===i.indexOf(e.keyPrefix)&&r.push(i.substring(e.keyPrefix.length))}return r}));return f(n,e),n}function We(e){var t=this.keys().then((function(e){return e.length}));return f(t,e),t}function He(e,t){var n=this;e=d(e);var r=n.ready().then((function(){var t=n._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return f(r,t),r}function $e(e,t,n){var r=this;e=d(e);var o=r.ready().then((function(){void 0===t&&(t=null);var n=t;return new s((function(o,i){var a=r._dbInfo;a.serializer.serialize(t,(function(t,r){if(r)i(r);else try{localStorage.setItem(a.keyPrefix+e,t),o(n)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||i(e),i(e)}}))}))}));return f(o,n),o}function Ge(e,t){if(t=h.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var r,o=this;return r=e.name?new s((function(t){e.storeName?t(Ce(e,o._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):s.reject("Invalid arguments"),f(r,t),r}var Qe={_driver:"localStorageWrapper",_initStorage:Fe,_support:Te(),iterate:ze,getItem:Me,setItem:$e,removeItem:He,clear:Pe,length:We,key:qe,keys:Ue,dropInstance:Ge},Ke=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},Xe=function(e,t){for(var n=e.length,r=0;r<n;){if(Ke(e[r],t))return!0;r++}return!1},Je=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Ve={},Ye={},Ze={INDEXEDDB:Q,WEBSQL:Oe,LOCALSTORAGE:Qe},et=[Ze.INDEXEDDB._driver,Ze.WEBSQL._driver,Ze.LOCALSTORAGE._driver],tt=["dropInstance"],nt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(tt),rt={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function ot(e,t){e[t]=function(){var n=arguments;return e.ready().then((function(){return e[t].apply(e,n)}))}}function it(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var n in t)t.hasOwnProperty(n)&&(Je(t[n])?arguments[0][n]=t[n].slice():arguments[0][n]=t[n])}return arguments[0]}var at=function(){function e(t){for(var n in o(this,e),Ze)if(Ze.hasOwnProperty(n)){var r=Ze[n],i=r._driver;this[n]=i,Ve[i]||this.defineDriver(r)}this._defaultConfig=it({},rt),this._config=it({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var r=new s((function(t,n){try{var r=e._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(o);for(var i=nt.concat("_initStorage"),a=0,c=i.length;a<c;a++){var u=i[a];if((!Xe(tt,u)||e[u])&&"function"!=typeof e[u])return void n(o)}var l=function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),n=s.reject(t);return f(n,arguments[arguments.length-1]),n}},n=0,r=tt.length;n<r;n++){var o=tt[n];e[o]||(e[o]=t(o))}};l();var d=function(n){Ve[r]&&console.info("Redefining LocalForage driver: "+r),Ve[r]=e,Ye[r]=n,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,n):d(!!e._support):d(!0)}catch(e){n(e)}}));return l(r,t,n),r},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var r=Ve[e]?s.resolve(Ve[e]):s.reject(new Error("Driver not found."));return l(r,t,n),r},e.prototype.getSerializer=function(e){var t=s.resolve(me);return l(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return l(n,e,e),n},e.prototype.setDriver=function(e,t,n){var r=this;Je(e)||(e=[e]);var o=this._getSupportedDrivers(e);function i(){r._config.driver=r.driver()}function a(e){return r._extend(e),i(),r._ready=r._initStorage(r._config),r._ready}function c(e){return function(){var t=0;function n(){for(;t<e.length;){var o=e[t];return t++,r._dbInfo=null,r._ready=null,r.getDriver(o).then(a).catch(n)}i();var c=new Error("No available storage method found.");return r._driverSet=s.reject(c),r._driverSet}return n()}}var u=null!==this._driverSet?this._driverSet.catch((function(){return s.resolve()})):s.resolve();return this._driverSet=u.then((function(){var e=o[0];return r._dbInfo=null,r._ready=null,r.getDriver(e).then((function(e){r._driver=e._driver,i(),r._wrapLibraryMethodsWithReady(),r._initDriver=c(o)}))})).catch((function(){i();var e=new Error("No available storage method found.");return r._driverSet=s.reject(e),r._driverSet})),l(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!Ye[e]},e.prototype._extend=function(e){it(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var o=e[n];this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=nt.length;e<t;e++)ot(this,nt[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),ct=new at;t.exports=ct},{3:3}]},{},[4])(4);const D=e=>new Promise((t=>setTimeout(t,e))),B=(()=>{switch(window.siyuan?.config.appearance.mode){case 0:return"light";case 1:return"dark";default:return null}})();function R(e){return"string"!=typeof e||null===e||""===e||"null"===e||"NULL"===e}function A(e,t,n){var r=parseInt(e,10),o=parseInt(t,10),i=parseInt(n,10),a=o<i?o:i;return r>a?r:a}function j(e,t){for(var n="js"===t?"script":"css"===t?"link":"none",r="js"===t?"src":"css"===t?"href":"none",o=document.getElementsByTagName(n),i=o.length;i>=0;i--)null!=o[i]?.getAttribute(r)&&-1!==o[i].getAttribute(r).indexOf(e)&&o[i].parentNode.removeChild(o[i])}function O(e,t=null){let n=document.createElement("link");t&&(n.id=t),n.type="text/css",n.rel="stylesheet",n.href=e,document.head.appendChild(n)}function T(e,t){let n=document.getElementById(e);n?n.setAttribute("href",t):O(t,e)}function C(e,t="module",n=!1,r=!1){const o=document.createElement("script");return t&&(o.type=t),n&&(o.async=!0),r&&(o.defer=!0),o.src=e,document.head.appendChild(o),o}
/*!
* sofill v1.0.76
* https://github.com/Hi-Windom/Sofill
* https://www.npmjs.com/package/sofill
*/
async function x(e,t={}){let n=null;return await fetch(e,{body:JSON.stringify(t),method:"POST",headers:{Authorization:`Token '${window.siyuan?.config.api.token}'`}}).then((function(e){n=e.json()})),console.log(n),n}async function L(e){let t=await e;return 0===t.code?t.data:null}
/*!
* sofill v1.0.76
* https://github.com/Hi-Windom/Sofill
* https://www.npmjs.com/package/sofill
*/
class F{_max;_count;_taskQueue;constructor(e){this._max=e,this._count=0,this._taskQueue=[]}call(e,...t){return new Promise(((n,r)=>{const o=this._createTask(e,t,n,r);this._count>=this._max?this._taskQueue.push(o):o()}))}_createTask(e,t,n,r){return()=>{e(...t).then(n).catch(r).finally((()=>{if(this._count--,this._taskQueue.length){this._taskQueue.shift()()}})),this._count++}}}const P=async e=>{const t=document.getElementById(e);return"checkbox"===t.type||"radio"===t.type?t.checked:t.value};async function M(e,t){document.getElementById(e).addEventListener("change",(async e=>{"function"==typeof t&&await t(e.target.value)})),window.winsay.cp.listened+=1,console.log(`${e} listen successfully`)}async function z(e,t,n){e.addEventListener("click",(async()=>{e.checked&&!0===e.checked?t():n()})),window.winsay.cp.listened+=1,console.log(`${e.id} listen successfully`)}const q={isDuringDate:function(e,t){const n=new Date,r=new Date(e),o=new Date(t);return n>=r&&n<=o},isDuringTime:function(e,t){const n=new Date,r=new Date(`${n.getFullYear()}-${n.getMonth()+1}-${n.getDate()} ${e}`),o=new Date(`${n.getFullYear()}-${n.getMonth()+1}-${n.getDate()} ${t}`);if(r<=o){if(r<=n&&n<=o)return!0}else if(r<=n||n<=o)return!0;return!1}};function U(e,t){const n=new URL(e).search.slice(1).split("&");for(let e=0;e<n.length;e++){const r=n[e].split("=");if(r[0]===t)return r[1]}}function W(){if(document.activeElement.classList.contains("protyle-wysiwyg")){let e=window.getSelection()?.focusNode?.parentElement;for(;null!=e&&null==e?.dataset?.nodeId;)e=e.parentElement;return e}return null}function H(){let e=W();return e?e.dataset.nodeId:null}function $(){return document.querySelector("div.layout__wnd--active div.protyle:not(.fn__none) > div.protyle-content > div.protyle-wysiwyg[data-doc-type]")||document.querySelector("#editor > div.protyle-content > div.protyle-wysiwyg[data-doc-type]")||null}function G(){for(var e=$();null!=e&&!1===e.classList.contains("protyle-background");)e=e.previousElementSibling;return e||null}function Q(){let e=G();return e?e.dataset.nodeId:null}var K={sql:X};async function X(e){return L(x("/api/query/sql",{stmt:e}))}var J={getBlockAttrs:async function(e){return L(x("/api/attr/getBlockAttrs",{id:e}))},setBlockAttrs:async function(e,t){return L(x("/api/attr/setBlockAttrs",{id:e,attrs:t}))},queryBlockById:async function(e){let t=`select * from blocks where id ='${e}'`;return(await X(t))[0]}};var V={getBazaarTheme:Y,getInstalledTheme:Z};async function Y(e,t){return x("http://"+e+"/api/bazaar/getBazaarTheme",t)}async function Z(e,t){return x("http://"+e+"/api/bazaar/getInstalledTheme",t)}var ee={getBlockKramdown:async function(e){return L(x("/api/block/getBlockKramdown",{id:e}))},getBlockBreadcrumb:async function(e){return L(x("/api/block/getBlockBreadcrumb",{id:e}))},insertBlock:async function(e,t,n){let r="/api/block/insertBlock";return L(x(r,n={previousID:e,dataType:t,data:n}))},prependBlock:async function(e,t,n){let r="/api/block/prependBlock";return L(x(r,n={parentID:e,dataType:t,data:n}))},appendBlock:async function(e,t,n){let r="/api/block/appendBlock";return L(x(r,n={parentID:e,dataType:t,data:n}))},deleteBlock:async function(e){return L(x("/api/block/deleteBlock",{id:e}))},updateBlock:async function(e,t,n){let r="/api/block/updateBlock";return L(x(r,n={id:e,dataType:t,data:n}))}};var te={exportMdContent:async function(e){return L(x("/api/export/exportMdContent",{id:e}))}};var ne=Object.freeze({__proto__:null,getFile:async function(e){const t=await fetch("/api/file/getFile",{method:"POST",headers:{Authorization:`Token ${window.siyuan?.config.api.token}`},body:JSON.stringify({path:e})});return 200===t.status?t:null},putFile:async function(e,t,n=!1,r=Date.now()){let o=new Blob([t]),i=new File([o],e.split("/").pop()),a=new FormData;a.append("path",e),a.append("file",i),a.append("isDir",n.toString()),a.append("modTime",r.toString());const c=await fetch("/api/file/putFile",{body:a,method:"POST",headers:{Authorization:`Token ${window.siyuan?.config.api.token}`}});return 200===c.status?await c.json():null}}),re={createDocWithMd:async function(e,t,n){return L(x("/api/filetree/createDocWithMd",{notebook:e,path:t,markdown:n}))},removeDoc:async function(e,t){return L(x("/api/filetree/removeDoc",{notebook:e,path:t}))},renameDoc:async function(e,t,n){return L(x("/api/filetree/renameDoc",{notebook:e,path:t,title:n}))},moveDoc:async function(e,t,n,r){return L(x("/api/filetree/moveDoc",{fromNotebook:e,fromPath:t,toNotebook:n,toPath:r}))},getHPathByPath:async function(e,t){let n={Notebook:e,Path:t};return L(x("/api/filetree/getHPathByPath",n))},getHPathByID:async function(e){return L(x("/api/filetree/getHPathByID",{id:e}))},listDocsByPath:async function(e){return L(x("/api/filetree/listDocsByPath",{path:e}))},getDoc:async function(e){return L(x("/api/filetree/getDoc",{id:e,k:"",mode:2,size:36}))},searchDocs:async function(e){return L(x("/api/filetree/searchDocs",{k:e}))}};var oe={getLocalGraph:async function(e,t,n,r){return L(x("/api/graph/getLocalGraph",{id:t,k:e,conf:n,reqId:r}))},getGraph:async function(e,t,n){return L(x("/api/graph/getGraph",{k:e,conf:t,reqId:n}))}};var ie={createNotebook:async function(e){return L(x("/api/notebook/createNotebook",{name:e}))},removeNotebook:async function(e){return L(x("/api/notebook/removeNotebook",{notebook:e}))},setNotebookConf:async function(e){return L(x("/api/notebook/setNotebookConf",{notebook:e}))},getNotebookConf:async function(e){return L(x("/api/notebook/getNotebookConf",{notebook:e}))},openNotebook:async function(e){return L(x("/api/notebook/openNotebook",{notebook:e}))},closeNotebook:async function(e){return L(x("/api/notebook/closeNotebook",{notebook:e}))},renameNotebook:async function(e,t){return L(x("/api/notebook/renameNotebook",{notebook:e,name:t}))}};function ae(e,t=7e3){return L(x("/api/notification/pushMsg",{msg:e,timeout:t}))}var ce={getDocOutline:async function(e){return L(x("/api/outline/getDocOutline",{id:e}))}};var ue={getBacklink:async function(e){return L(x("/api/ref/getBacklink",{id:e,beforeLen:10,k:"",mk:""}))}};var se={searchEmbedBlock:async function(e,t){return L(x("/api/search/searchEmbedBlock",{stmt:t,excludeIDs:e}))},searchBlock:async function(e){return L(x("/api/search/searchBlock",{query:e}))},searchTemplate:async function(e){return L(x("/api/search/searchTemplate",{k:e}))}};var fe={getTag:async function(){return L(x("/api/tag/getTag",{}))}};var le={docSaveAsTemplate:async function(e,t=!1){return L(x("/api/template/docSaveAsTemplate",{id:e,overwrite:t}))},renderTemplate:async function(e){return L(x("/api/template/render",e))}};function de(e,t,n=null){e||console.error("指定元素对象不存在!"),t||console.error("未指定字符串!");var r=document.createElement(t);return n&&(r.id=n),e.parentElement.insertBefore(r,e),r}var he=Object.freeze({__proto__:null,AI:{},Account:{},AddEvent:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent?e.attachEvent("on"+t,n):e["on"+t]=n},Asset:{},Attr:J,Av:{},Bazaar:V,Block:ee,Bookmark:{},CopyDOM:function(e,t){var n=document.querySelector(e),r=document.querySelector(t),o=n.cloneNode(!0);r.appendChild(o)},Export:te,File:ne,Filetree:re,Format:{},Graph:oe,History:{},Import:{},Inbox:{},LimitPromise:F,LocalStorage:class{_MAX;limitP;constructor(e){this._MAX=e,this.limitP=new F(this._MAX)}async getItem(e,t=null){return await this.limitP.call(this.GetItem,e)}async setItem(e,t,n=null){return await this.limitP.call(this.SetItem,e,t,n)}async removeItem(e,t=null){return await this.limitP.call(this.RemoveItem,e,t)}async GetItem(e){return e?await k.getItem(e).catch((function(e){console.warn(e)})):void console.error("Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getItem')")}async SetItem(e,t,n){return await k.setItem(e,t).then((function(e){console.log(e)})).catch((function(e){console.warn(e)}))}async RemoveItem(e,t){return await k.removeItem(e).then((()=>{console.log("Key is cleared!")})).catch((function(e){console.warn(e)}))}},Lute:{},MoveChildren:function(e,t){for(var n=document.querySelector(e),r=n.children,o=n.childElementCount,i=document.querySelector(t),a=0;a<o;a++)i.appendChild(r[0])},MoveDOM:function(e,t){var n=document.querySelector(e);document.querySelector(t).appendChild(n)},Notebook:ie,Outline:ce,Query:K,RangeLimitedInt:A,Ref:ue,Repo:{},Riff:{},Search:se,Setting:{},Snippet:{},SofillDate:q,Storage:{},Sync:{},System:{},Tag:fe,Template:le,addURLParam:function(e,t={v:window.siyuan?.config.appearance.themeVer}){let n;switch(!0){case e.startsWith("//"):n=new URL(`https:${e}`);break;case e.startsWith("http://"):case e.startsWith("https://"):n=new URL(e);break;case e.startsWith("/"):n=new URL(e,window.location.origin);break;default:n=new URL(e,window.location.origin+window.location.pathname)}for(let[e,r]of Object.entries(t))n.searchParams.set(e,r);switch(!0){case e.startsWith("//"):return n.href.substring(n.protocol.length);case e.startsWith("http://"):case e.startsWith("https://"):return n.href;case e.startsWith("/"):return n.href.substring(n.origin.length);default:return n.href.substring((window.location.origin+window.location.pathname).length)}},addinsertCreateElement:m,bodyAC:b,bodyCC:w,bodyRC:g,checkedChange:z,compareVersion:N,diguiTooONE:function(e,t){return null==e||null==t?null:function e(n){var r=n.children;if(r.length=0)return null;for(let n=0;n<r.length;n++){const i=r[n];if(t(i))return i;var o=e(i);if(null!=o)return o}return null}(e)},eRemoveProperty:I,eSetProperty:_,genUUID:()=>([1e7].toString()+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(parseInt(e,10)^window.crypto.getRandomValues(new Uint32Array(1))[0]&15>>parseInt(e,10)/4).toString(16))),getActualWidthOfChars:function(e,t){const{size:n,family:r="Microsoft YaHei"}=t,o=document.createElement("canvas").getContext("2d");o.font=`${n}px ${r}`;const i=o.measureText(e),a=Math.abs(i.actualBoundingBoxLeft)+Math.abs(i.actualBoundingBoxRight);return Math.max(i.width,a)},getBazaarTheme:Y,getFocusedBlock:W,getFocusedBlockID:H,getFocusedDoc:$,getFocusedDocBackground:G,getFocusedDocID:Q,getFocusedID:function(){return H()||Q()||null},getInstalledTheme:Z,getNewValueFromDomByID:P,getThemeMode:B,getTooltipDirection:function(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2,o=1*document.documentElement.offsetWidth/3,i=2*document.documentElement.offsetWidth/3,a=1*document.documentElement.offsetHeight/3,c=2*document.documentElement.offsetHeight/3;let u;switch(!0){case r<a&&n<o:u="b3-tooltips__se";break;case r<a&&n>=o&&n<=i:u="b3-tooltips__s";break;case r<a&&n>i:u="b3-tooltips__sw";break;case r>=a&&r<=c&&n<o:u="b3-tooltips__e";break;case r>=a&&r<=c&&n>=o&&n<=i:u="b3-tooltips__s";break;case r>=a&&r<=c&&n>i:u="b3-tooltips__w";break;case r>c&&n<o:u="b3-tooltips__ne";break;case r>c&&n>=o&&n<=i:u="b3-tooltips__n";break;case r>c&&n>i:u="b3-tooltips__nw"}return u},getUrlParam:U,getUrlParams:function(e){return new URL(e).search.slice(1).split("&")},initAllPropFromIDBAsync:async function(e){const t=async e=>{document.getElementById(e).type,console.log(`${e} binded successfully`)},n=async e=>{if(!R(e))return await t(e),k.getItem(e).then((async t=>{const n=document.getElementById(e);if(R(t))switch(n.type){case"select-one":case"select-multiple":n.bindIDB=n.options[0].value;break;case"number":case"range":n.bindIDB=0;break;default:n.bindIDB=""}else n.bindIDB=t;console.log(`${e} inited successfully with value \`${t}\``)}));console.warn(e)},r=async(e,t)=>{const n=e.length;let r=0;for(;r<n;)await t(e[r]),r++};let o=0;const i=e.querySelectorAll("select:not([id^='NoSync'])"),a=e.querySelectorAll("input[id^='SC_winsay_cp']:not([type='checkbox'])"),c=e.querySelectorAll("input[type='checkbox']:not([id^='NoSync'])");o+=i.length,o+=a.length,o+=c.length,console.warn(o),window.winsay.cp.awaitInitItem=o,await r(i,(async e=>{await n(e.id),window.winsay.cp.awaitInitItem-=1,window.winsay.cp.inited+=1})),await r(a,(async e=>{await n(e.id),window.winsay.cp.awaitInitItem-=1,window.winsay.cp.inited+=1})),await r(c,(async e=>{await(async e=>{if(!R(e.id))return await t(e.id),k.getItem(e.id).then((async t=>{R(t)?e.bindIDB="false":e.bindIDB="true",console.log(`${e.id} inited successfully with value \`${t}\``)}));console.warn(e)})(e),window.winsay.cp.awaitInitItem-=1,window.winsay.cp.inited+=1}))},insertCreateAfter:function(e,t,n=null){var r=document.createElement(t);n&&(r.id=n);var o=e.parentNode;return o.lastChild===e?(o.appendChild(r),r):(o.insertBefore(r,e.nextSibling),r)},insertCreateBefore:de,isEmpty:function(e){return null==e||""===e},isEmptyString:R,isMobile:()=>!!document.getElementById("sidebar"),isPromise:e=>"function"==typeof e.then,isWindow:()=>!document.getElementById("toolbar"),loadScript:C,loadStyle:O,myRemoveEvent:function(e,t,n){e.addEventListener?e.removeEventListener(t,n,!1):e.attachEvent?e.detachEvent("on"+t,n):e["on"+t]=null},parseResponse:L,post2Siyuan:x,propChange:M,pushMsg:ae,querySQL:X,removejscssfile:j,setTooltipDirection:function(e,...t){const n=["b3-tooltips__nw","b3-tooltips__n","b3-tooltips__ne","b3-tooltips__e","b3-tooltips__se","b3-tooltips__s","b3-tooltips__sw","b3-tooltips__w"];t.forEach((t=>{t.classList.remove(...n),t.classList.add(e(t))}))},sleep:D,updateStyle:T,"通知":function(e,t=7e3){var n=new XMLHttpRequest;n.open("POST","http://127.0.0.1:6806/api/notification/pushMsg",!0),n.setRequestHeader("Content-type","application/json");var r={msg:e,timeout:7e3};n.send(JSON.stringify(r)),n.onreadystatechange=function(){if(4===n.readyState&&200===n.status){var e=n.responseText;console.log(e)}}}});
/*!
* sofill v1.0.76
* https://github.com/Hi-Windom/Sofill
* https://www.npmjs.com/package/sofill
*/function ve(e=!1){return e?navigator.userAgent.toLowerCase().startsWith("siyuan")||document.body.classList.contains("body--docker"):navigator.userAgent.toLowerCase().startsWith("siyuan")}function pe(){return!!ve()&&("windows"===window.siyuan?.config.system.os||"darwin"===window.siyuan?.config.system.os)}function ye(){return document.body.classList.contains("body--mobile")&&ve()}var me="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function be(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ge={exports:{}},we=ge.exports=function e(t,n,r){function o(a,c){if(!n[a]){if(!t[a]){if(!c&&be)return be(a);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[a]={exports:{}};t[a][0].call(s.exports,(function(e){var n=t[a][1][e];return o(n||e)}),s,s.exports,e,t,n,r)}return n[a].exports}for(var i=be,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t,n){(function(e){var n,r,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var i=0,a=new o(f),c=e.document.createTextNode("");a.observe(c,{characterData:!0}),n=function(){c.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){f(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(f,0)};else{var u=new e.MessageChannel;u.port1.onmessage=f,n=function(){u.port2.postMessage(0)}}var s=[];function f(){var e,t;r=!0;for(var n=s.length;n;){for(t=s,s=[],e=-1;++e<n;)t[e]();n=s.length}r=!1}function l(e){1!==s.push(e)||r||n()}t.exports=l}).call(this,void 0!==me?me:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){var r=e(1);function o(){}var i={},a=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function s(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,e!==o&&h(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r((function(){var r;try{r=t(n)}catch(t){return i.reject(e,t)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var n=!1;function r(t){n||(n=!0,i.reject(e,t))}function o(t){n||(n=!0,i.resolve(e,t))}function a(){t(o,r)}var c=v(a);"error"===c.status&&r(c.value)}function v(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}function p(e){return e instanceof this?e:i.resolve(new this(o),e)}function y(e){var t=new this(o);return i.reject(t,e)}function m(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var a=new Array(n),c=0,u=-1,s=new this(o);++u<n;)f(e[u],u);return s;function f(e,o){function u(e){a[o]=e,++c!==n||r||(r=!0,i.resolve(s,a))}t.resolve(e).then(u,(function(e){r||(r=!0,i.reject(s,e))}))}}function b(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var a=-1,c=new this(o);++a<n;)u(e[a]);return c;function u(e){t.resolve(e).then((function(e){r||(r=!0,i.resolve(c,e))}),(function(e){r||(r=!0,i.reject(c,e))}))}}t.exports=s,s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){if("function"!=typeof e&&this.state===c||"function"!=typeof t&&this.state===a)return this;var n=new this.constructor(o);return this.state!==u?l(n,this.state===c?e:t,this.outcome):this.queue.push(new f(n,e,t)),n},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var n=v(d,t);if("error"===n.status)return i.reject(e,n.value);var r=n.value;if(r)h(e,r);else{e.state=c,e.outcome=t;for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(t)}return e},i.reject=function(e,t){e.state=a,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},s.resolve=p,s.reject=y,s.all=m,s.race=b},{1:1}],3:[function(e,t,n){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==me?me:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,n){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var a=i();function c(){try{if(!a||!a.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function u(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var s=Promise;function f(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function l(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function d(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function h(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var v="local-forage-detect-blob-support",p=void 0,y={},m=Object.prototype.toString,b="readonly",g="readwrite";function w(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o);return n}function _(e){return new s((function(t){var n=e.transaction(v,g),r=u([""]);n.objectStore(v).put(r,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function I(e){return"boolean"==typeof p?s.resolve(p):_(e).then((function(e){return p=e}))}function S(e){var t=y[e.name],n={};n.promise=new s((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function E(e){var t=y[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function k(e,t){var n=y[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function N(e,t){return new s((function(n,r){if(y[e.name]=y[e.name]||L(),e.db){if(!t)return n(e.db);S(e),e.db.close()}var o=[e.name];t&&o.push(e.version);var i=a.open.apply(a,o);t&&(i.onupgradeneeded=function(t){var n=i.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(v)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),i.onerror=function(e){e.preventDefault(),r(i.error)},i.onsuccess=function(){var t=i.result;t.onversionchange=function(e){e.target.close()},n(t),E(e)}}))}function D(e){return N(e,!1)}function B(e){return N(e,!0)}function R(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),r=e.version<e.db.version,o=e.version>e.db.version;if(r&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||n){if(n){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function A(e){return new s((function(t,n){var r=new FileReader;r.onerror=n,r.onloadend=function(n){var r=btoa(n.target.result||"");t({__local_forage_encoded_blob:!0,data:r,type:e.type})},r.readAsBinaryString(e)}))}function j(e){return u([w(atob(e.data))],{type:e.type})}function O(e){return e&&e.__local_forage_encoded_blob}function T(e){var t=this,n=t._initReady().then((function(){var e=y[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return l(n,e,e),n}function C(e){S(e);for(var t=y[e.name],n=t.forages,r=0;r<n.length;r++){var o=n[r];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,D(e).then((function(t){return e.db=t,R(e)?B(e):t})).then((function(r){e.db=t.db=r;for(var o=0;o<n.length;o++)n[o]._dbInfo.db=r})).catch((function(t){throw k(e,t),t}))}function x(e,t,n,r){void 0===r&&(r=1);try{var o=e.db.transaction(e.storeName,t);n(null,o)}catch(o){if(r>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return s.resolve().then((function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),B(e)})).then((function(){return C(e).then((function(){x(e,t,n,r-1)}))})).catch(n);n(o)}}function L(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function F(e){var t=this,n={db:null};if(e)for(var r in e)n[r]=e[r];var o=y[n.name];o||(o=L(),y[n.name]=o),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=T);var i=[];function a(){return s.resolve()}for(var c=0;c<o.forages.length;c++){var u=o.forages[c];u!==t&&i.push(u._initReady().catch(a))}var f=o.forages.slice(0);return s.all(i).then((function(){return n.db=o.db,D(n)})).then((function(e){return n.db=e,R(n,t._defaultConfig.version)?B(n):e})).then((function(e){n.db=o.db=e,t._dbInfo=n;for(var r=0;r<f.length;r++){var i=f[r];i!==t&&(i._dbInfo.db=n.db,i._dbInfo.version=n.version)}}))}function P(e,t){var n=this;e=d(e);var r=new s((function(t,r){n.ready().then((function(){x(n._dbInfo,b,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),O(e)&&(e=j(e)),t(e)},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return f(r,t),r}function M(e,t){var n=this,r=new s((function(t,r){n.ready().then((function(){x(n._dbInfo,b,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).openCursor(),c=1;a.onsuccess=function(){var n=a.result;if(n){var r=n.value;O(r)&&(r=j(r));var o=e(r,n.key,c++);void 0!==o?t(o):n.continue()}else t()},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return f(r,t),r}function z(e,t,n){var r=this;e=d(e);var o=new s((function(n,o){var i;r.ready().then((function(){return i=r._dbInfo,"[object Blob]"===m.call(t)?I(i.db).then((function(e){return e?t:A(t)})):t})).then((function(t){x(r._dbInfo,g,(function(i,a){if(i)return o(i);try{var c=a.objectStore(r._dbInfo.storeName);null===t&&(t=void 0);var u=c.put(t,e);a.oncomplete=function(){void 0===t&&(t=null),n(t)},a.onabort=a.onerror=function(){var e=u.error?u.error:u.transaction.error;o(e)}}catch(e){o(e)}}))})).catch(o)}));return f(o,n),o}function q(e,t){var n=this;e=d(e);var r=new s((function(t,r){n.ready().then((function(){x(n._dbInfo,g,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).delete(e);i.oncomplete=function(){t()},i.onerror=function(){r(a.error)},i.onabort=function(){var e=a.error?a.error:a.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return f(r,t),r}function U(e){var t=this,n=new s((function(e,n){t.ready().then((function(){x(t._dbInfo,g,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).clear();o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=i.error?i.error:i.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return f(n,e),n}function W(e){var t=this,n=new s((function(e,n){t.ready().then((function(){x(t._dbInfo,b,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).count();i.onsuccess=function(){e(i.result)},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return f(n,e),n}function H(e,t){var n=this,r=new s((function(t,r){e<0?t(null):n.ready().then((function(){x(n._dbInfo,b,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName),c=!1,u=a.openKeyCursor();u.onsuccess=function(){var n=u.result;n?0===e||c?t(n.key):(c=!0,n.advance(e)):t(null)},u.onerror=function(){r(u.error)}}catch(e){r(e)}}))})).catch(r)}));return f(r,t),r}function $(e){var t=this,n=new s((function(e,n){t.ready().then((function(){x(t._dbInfo,b,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).openKeyCursor(),a=[];i.onsuccess=function(){var t=i.result;t?(a.push(t.key),t.continue()):e(a)},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return f(n,e),n}function G(e,t){t=h.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,o=this;if(e.name){var i=e.name===n.name&&o._dbInfo.db?s.resolve(o._dbInfo.db):D(e).then((function(t){var n=y[e.name],r=n.forages;n.db=t;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=t;return t}));r=e.storeName?i.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1;S(e);var r=y[e.name],o=r.forages;t.close();for(var i=0;i<o.length;i++){var c=o[i];c._dbInfo.db=null,c._dbInfo.version=n}var u=new s((function(t,r){var o=a.open(e.name,n);o.onerror=function(e){o.result.close(),r(e)},o.onupgradeneeded=function(){o.result.deleteObjectStore(e.storeName)},o.onsuccess=function(){var e=o.result;e.close(),t(e)}}));return u.then((function(e){r.db=e;for(var t=0;t<o.length;t++){var n=o[t];n._dbInfo.db=e,E(n._dbInfo)}})).catch((function(t){throw(k(e,t)||s.resolve()).catch((function(){})),t}))}})):i.then((function(t){S(e);var n=y[e.name],r=n.forages;t.close();for(var o=0;o<r.length;o++)r[o]._dbInfo.db=null;var i=new s((function(t,n){var r=a.deleteDatabase(e.name);r.onerror=function(){var e=r.result;e&&e.close(),n(r.error)},r.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},r.onsuccess=function(){var e=r.result;e&&e.close(),t(e)}}));return i.then((function(e){n.db=e;for(var t=0;t<r.length;t++)E(r[t]._dbInfo)})).catch((function(t){throw(k(e,t)||s.resolve()).catch((function(){})),t}))}))}else r=s.reject("Invalid arguments");return f(r,t),r}var Q={_driver:"asyncStorage",_initStorage:F,_support:c(),iterate:M,getItem:P,setItem:z,removeItem:q,clear:U,length:W,key:H,keys:$,dropInstance:G};function K(){return"function"==typeof openDatabase}var X="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J="~~local_forage_type~",V=/^~~local_forage_type~([^~]+)~/,Y="__lfsc__:",Z=Y.length,ee="arbf",te="blob",ne="si08",re="ui08",oe="uic8",ie="si16",ae="si32",ce="ur16",ue="ui32",se="fl32",fe="fl64",le=Z+ee.length,de=Object.prototype.toString;function he(e){var t,n,r,o,i,a=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var s=new ArrayBuffer(a),f=new Uint8Array(s);for(t=0;t<c;t+=4)n=X.indexOf(e[t]),r=X.indexOf(e[t+1]),o=X.indexOf(e[t+2]),i=X.indexOf(e[t+3]),f[u++]=n<<2|r>>4,f[u++]=(15&r)<<4|o>>2,f[u++]=(3&o)<<6|63&i;return s}function ve(e){var t,n=new Uint8Array(e),r="";for(t=0;t<n.length;t+=3)r+=X[n[t]>>2],r+=X[(3&n[t])<<4|n[t+1]>>4],r+=X[(15&n[t+1])<<2|n[t+2]>>6],r+=X[63&n[t+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}function pe(e,t){var n="";if(e&&(n=de.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===de.call(e.buffer))){var r,o=Y;e instanceof ArrayBuffer?(r=e,o+=ee):(r=e.buffer,"[object Int8Array]"===n?o+=ne:"[object Uint8Array]"===n?o+=re:"[object Uint8ClampedArray]"===n?o+=oe:"[object Int16Array]"===n?o+=ie:"[object Uint16Array]"===n?o+=ce:"[object Int32Array]"===n?o+=ae:"[object Uint32Array]"===n?o+=ue:"[object Float32Array]"===n?o+=se:"[object Float64Array]"===n?o+=fe:t(new Error("Failed to get type for BinaryArray"))),t(o+ve(r))}else if("[object Blob]"===n){var i=new FileReader;i.onload=function(){var n=J+e.type+"~"+ve(this.result);t(Y+te+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}}function ye(e){if(e.substring(0,Z)!==Y)return JSON.parse(e);var t,n=e.substring(le),r=e.substring(Z,le);if(r===te&&V.test(n)){var o=n.match(V);t=o[1],n=n.substring(o[0].length)}var i=he(n);switch(r){case ee:return i;case te:return u([i],{type:t});case ne:return new Int8Array(i);case re:return new Uint8Array(i);case oe:return new Uint8ClampedArray(i);case ie:return new Int16Array(i);case ce:return new Uint16Array(i);case ae:return new Int32Array(i);case ue:return new Uint32Array(i);case se:return new Float32Array(i);case fe:return new Float64Array(i);default:throw new Error("Unkown type: "+r)}}var me={serialize:pe,deserialize:ye,stringToBuffer:he,bufferToString:ve};function be(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function ge(e){var t=this,n={db:null};if(e)for(var r in e)n[r]="string"!=typeof e[r]?e[r].toString():e[r];var o=new s((function(e,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return r(e)}n.db.transaction((function(o){be(o,n,(function(){t._dbInfo=n,e()}),(function(e,t){r(t)}))}),r)}));return n.serializer=me,o}function we(e,t,n,r,o,i){e.executeSql(n,r,o,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,c){c.rows.length?i(e,a):be(e,t,(function(){e.executeSql(n,r,o,i)}),i)}),i):i(e,a)}),i)}function _e(e,t){var n=this;e=d(e);var r=new s((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){we(n,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,n){var r=n.rows.length?n.rows.item(0).value:null;r&&(r=o.serializer.deserialize(r)),t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return f(r,t),r}function Ie(e,t){var n=this,r=new s((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){we(n,o,"SELECT * FROM "+o.storeName,[],(function(n,r){for(var i=r.rows,a=i.length,c=0;c<a;c++){var u=i.item(c),s=u.value;if(s&&(s=o.serializer.deserialize(s)),void 0!==(s=e(s,u.key,c+1)))return void t(s)}t()}),(function(e,t){r(t)}))}))})).catch(r)}));return f(r,t),r}function Se(e,t,n,r){var o=this;e=d(e);var i=new s((function(i,a){o.ready().then((function(){void 0===t&&(t=null);var c=t,u=o._dbInfo;u.serializer.serialize(t,(function(t,s){s?a(s):u.db.transaction((function(n){we(n,u,"INSERT OR REPLACE INTO "+u.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){i(c)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(r>0)return void i(Se.apply(o,[e,c,n,r-1]));a(t)}}))}))})).catch(a)}));return f(i,n),i}function Ee(e,t,n){return Se.apply(this,[e,t,n,1])}function ke(e,t){var n=this;e=d(e);var r=new s((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){we(n,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){r(t)}))}))})).catch(r)}));return f(r,t),r}function Ne(e){var t=this,n=new s((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){we(t,r,"DELETE FROM "+r.storeName,[],(function(){e()}),(function(e,t){n(t)}))}))})).catch(n)}));return f(n,e),n}function De(e){var t=this,n=new s((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){we(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],(function(t,n){var r=n.rows.item(0).c;e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return f(n,e),n}function Be(e,t){var n=this,r=new s((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){we(n,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,n){var r=n.rows.length?n.rows.item(0).key:null;t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return f(r,t),r}function Re(e){var t=this,n=new s((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){we(t,r,"SELECT key FROM "+r.storeName,[],(function(t,n){for(var r=[],o=0;o<n.rows.length;o++)r.push(n.rows.item(o).key);e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return f(n,e),n}function Ae(e){return new s((function(t,n){e.transaction((function(r){r.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,r){for(var o=[],i=0;i<r.rows.length;i++)o.push(r.rows.item(i).name);t({db:e,storeNames:o})}),(function(e,t){n(t)}))}),(function(e){n(e)}))}))}function je(e,t){t=h.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,o=this;return f(r=e.name?new s((function(t){var r;r=e.name===n.name?o._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:r,storeNames:[e.storeName]}):t(Ae(r))})).then((function(e){return new s((function(t,n){e.db.transaction((function(r){function o(e){return new s((function(t,n){r.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){n(t)}))}))}for(var i=[],a=0,c=e.storeNames.length;a<c;a++)i.push(o(e.storeNames[a]));s.all(i).then((function(){t()})).catch((function(e){n(e)}))}),(function(e){n(e)}))}))})):s.reject("Invalid arguments"),t),r}var Oe={_driver:"webSQLStorage",_initStorage:ge,_support:K(),iterate:Ie,getItem:_e,setItem:Ee,removeItem:ke,clear:Ne,length:De,key:Be,keys:Re,dropInstance:je};function Te(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function Ce(e,t){var n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}function xe(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function Le(){return!xe()||localStorage.length>0}function Fe(e){var t=this,n={};if(e)for(var r in e)n[r]=e[r];return n.keyPrefix=Ce(e,t._defaultConfig),Le()?(t._dbInfo=n,n.serializer=me,s.resolve()):s.reject()}function Pe(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n);0===r.indexOf(e)&&localStorage.removeItem(r)}}));return f(n,e),n}function Me(e,t){var n=this;e=d(e);var r=n.ready().then((function(){var t=n._dbInfo,r=localStorage.getItem(t.keyPrefix+e);return r&&(r=t.serializer.deserialize(r)),r}));return f(r,t),r}function ze(e,t){var n=this,r=n.ready().then((function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,c=0;c<i;c++){var u=localStorage.key(c);if(0===u.indexOf(r)){var s=localStorage.getItem(u);if(s&&(s=t.serializer.deserialize(s)),void 0!==(s=e(s,u.substring(o),a++)))return s}}}));return f(r,t),r}function qe(e,t){var n=this,r=n.ready().then((function(){var t,r=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(r.keyPrefix.length)),t}));return f(r,t),r}function Ue(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,r=[],o=0;o<n;o++){var i=localStorage.key(o);0===i.indexOf(e.keyPrefix)&&r.push(i.substring(e.keyPrefix.length))}return r}));return f(n,e),n}function We(e){var t=this.keys().then((function(e){return e.length}));return f(t,e),t}function He(e,t){var n=this;e=d(e);var r=n.ready().then((function(){var t=n._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return f(r,t),r}function $e(e,t,n){var r=this;e=d(e);var o=r.ready().then((function(){void 0===t&&(t=null);var n=t;return new s((function(o,i){var a=r._dbInfo;a.serializer.serialize(t,(function(t,r){if(r)i(r);else try{localStorage.setItem(a.keyPrefix+e,t),o(n)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||i(e),i(e)}}))}))}));return f(o,n),o}function Ge(e,t){if(t=h.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var r,o=this;return r=e.name?new s((function(t){e.storeName?t(Ce(e,o._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):s.reject("Invalid arguments"),f(r,t),r}var Qe={_driver:"localStorageWrapper",_initStorage:Fe,_support:Te(),iterate:ze,getItem:Me,setItem:$e,removeItem:He,clear:Pe,length:We,key:qe,keys:Ue,dropInstance:Ge},Ke=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},Xe=function(e,t){for(var n=e.length,r=0;r<n;){if(Ke(e[r],t))return!0;r++}return!1},Je=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Ve={},Ye={},Ze={INDEXEDDB:Q,WEBSQL:Oe,LOCALSTORAGE:Qe},et=[Ze.INDEXEDDB._driver,Ze.WEBSQL._driver,Ze.LOCALSTORAGE._driver],tt=["dropInstance"],nt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(tt),rt={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function ot(e,t){e[t]=function(){var n=arguments;return e.ready().then((function(){return e[t].apply(e,n)}))}}function it(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var n in t)t.hasOwnProperty(n)&&(Je(t[n])?arguments[0][n]=t[n].slice():arguments[0][n]=t[n])}return arguments[0]}var at=function(){function e(t){for(var n in o(this,e),Ze)if(Ze.hasOwnProperty(n)){var r=Ze[n],i=r._driver;this[n]=i,Ve[i]||this.defineDriver(r)}this._defaultConfig=it({},rt),this._config=it({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var r=new s((function(t,n){try{var r=e._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(o);for(var i=nt.concat("_initStorage"),a=0,c=i.length;a<c;a++){var u=i[a];if((!Xe(tt,u)||e[u])&&"function"!=typeof e[u])return void n(o)}var l=function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),n=s.reject(t);return f(n,arguments[arguments.length-1]),n}},n=0,r=tt.length;n<r;n++){var o=tt[n];e[o]||(e[o]=t(o))}};l();var d=function(n){Ve[r]&&console.info("Redefining LocalForage driver: "+r),Ve[r]=e,Ye[r]=n,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,n):d(!!e._support):d(!0)}catch(e){n(e)}}));return l(r,t,n),r},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var r=Ve[e]?s.resolve(Ve[e]):s.reject(new Error("Driver not found."));return l(r,t,n),r},e.prototype.getSerializer=function(e){var t=s.resolve(me);return l(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return l(n,e,e),n},e.prototype.setDriver=function(e,t,n){var r=this;Je(e)||(e=[e]);var o=this._getSupportedDrivers(e);function i(){r._config.driver=r.driver()}function a(e){return r._extend(e),i(),r._ready=r._initStorage(r._config),r._ready}function c(e){return function(){var t=0;function n(){for(;t<e.length;){var o=e[t];return t++,r._dbInfo=null,r._ready=null,r.getDriver(o).then(a).catch(n)}i();var c=new Error("No available storage method found.");return r._driverSet=s.reject(c),r._driverSet}return n()}}var u=null!==this._driverSet?this._driverSet.catch((function(){return s.resolve()})):s.resolve();return this._driverSet=u.then((function(){var e=o[0];return r._dbInfo=null,r._ready=null,r.getDriver(e).then((function(e){r._driver=e._driver,i(),r._wrapLibraryMethodsWithReady(),r._initDriver=c(o)}))})).catch((function(){i();var e=new Error("No available storage method found.");return r._driverSet=s.reject(e),r._driverSet})),l(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!Ye[e]},e.prototype._extend=function(e){it(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var o=e[n];this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=nt.length;e<t;e++)ot(this,nt[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),ct=new at;t.exports=ct},{3:3}]},{},[4])(4);
/*!
localForage -- Offline Storage, Improved
Version 1.10.0
https://localforage.github.io/localForage
(c) 2013-2017 Mozilla, Apache License 2.0
*/export{he as A,Y as B,Z as C,N as D,q as E,s as F,f as G,ye as H,l as I,ne as J,o as K,m as L,e as M,Q as N,u as O,a as P,A as R,y as S,n as T,d as a,C as b,h as c,i as d,c as e,w as f,U as g,g as h,pe as i,b as j,R as k,we as l,B as m,t as n,de as o,M as p,_ as q,j as r,D as s,p as t,T as u,z as v,P as w,ae as x,I as y,r as z};