anys-web 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +16 -16
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){var e={d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};!function(){"use strict";function n(e){return Array.isArray(e)}function r(e,t){return"function"==typeof e&&(!t||!function(e,t){if("function"!=typeof e)return!1;if(e===Symbol)return!1;if(!e.prototype)return!1;const n=e+"",r=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim(),s=0===n.indexOf("class "),o="[native code]"===r,i=s||o;if(t>=4)return i;const a=r.replace(/function.*?\{.*?\}/gm,"").replace(/return/gm,"").replace(/\n+/gm,";").replace(/\s+/gm,"").replace(/;;/gm,";"),c=/^_classCallCheck\(this,/.test(a),u=/^\(.*?_classCallCheck.*?\)\(this,/.test(a),h=/^[0-9a-zA-Z_;!?:]*?\(this,/.test(a),d=i||c||u||h;if(3==t)return d;const l=Object.getOwnPropertyDescriptors(e.prototype),p=!!Object.keys(l).filter((e=>"constructor"!==e)).length,m=d||p;if(2==t)return m;const f=0===a.indexOf("this.")||a.indexOf(";this.")>-1||a.indexOf("=this;")>-1,y=m||f;if(1==t)return y;return!0}(e,2))}function s(e=16){const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ";let n="";for(let r=0;r<e;r++)n+=t.charAt(Math.floor(Math.random()*t.length));return n}function o(e,t,r){return r?(()=>{const n=Object.getOwnPropertyDescriptors(e);Object.keys(n).forEach((r=>{const s=n[r],{get:o,set:i,enumerable:a,configurable:c,writable:u}=s;(a||o||i||c&&u)&&t(s,r,e)}))})():(()=>{if(n(e))e.forEach(t);else{Object.keys(e).forEach((n=>{const r=e[n];t(r,n,e)}))}})()}e.r(t),e.d(t,{create:function(){return A}});Symbol("Proxy");class i{constructor(e){this.$events=[],this.$queue=[];const t=(a=this,Object.getPrototypeOf(a).constructor);var a;const{filters:c=[],plugins:u=[],...h}={...i.defaultOptions,...t.defaultOptions||{}},{filters:d=[],plugins:l=[],defines:p=[],...m}=e||{},f={},y=[],v={},g=l&&!n(l)&&"object"==typeof l,w=g?D(l):n(l)?l:[],b=g?Object.keys(l).map((e=>({key:e,value:l[e]}))):[],E=[...u,...w],x=e=>{e.forEach((e=>{const t=e.dependencies||[];t.forEach((e=>{E.unshift(e)})),x(t)}))};x(E);const L=E.filter(((e,t)=>t===E.indexOf(e))),I=[],O={};L.forEach((e=>{const t=b.find((t=>t.value===e))?.key;if(t&&O[t])return void(t=>{const n=`plugin named '${t}' has been registered`;O[t]instanceof e?console.debug(n,e,O):console.error(n,e,O)})(t);const n=(e.dependencies||[]).map((e=>I.find((t=>t instanceof e)))),r=new e(this,n);r.options&&T(f,r.options()),r.defines&&T(v,r.defines()),r.filters&&y.push(...r.filters()),I.push(r),t&&(O[t]=r)})),this.$plugins=I,this.plugins=O,this.options={...h,...f,...m},this.filters=[...c,...y,...d];const P=D(this.options).find((e=>e&&e instanceof Error));if(P)throw P;const q={...v,...p};this.definitions=q,this.clientId=q.client?q.client():s(8),this.traceId=q.trace?q.trace():s(8),this.requestId=s(8);const k={};function D(e){return Object.keys(e).map((t=>e[t]))}function T(e,t){return Object.keys(t).forEach((n=>{const r=t[n];e[n]=r})),e}Object.defineProperties(k,function(e,t){if(n(e))return e.map(t);{const n={};return o(e,((r,s)=>{n[s]=t(r,s,e)})),n}}(q,(e=>({get:r(e)?e:()=>e,enumerable:!0,configurable:!0})))),Object.defineProperties(k,{client:{get:()=>this.clientId,enumerable:!0,configurable:!0},trace:{get:()=>this.traceId,enumerable:!0,configurable:!0},request:{get:()=>this.requestId,enumerable:!0,configurable:!0}}),this.$basicLog=k,this.invoke("init"),this.options.autoStart&&this.start()}define(e,t){Object.defineProperty(this.$basicLog,e,{get:t,enumerable:!0,configurable:!0})}on(e,t){this.$events.push([e,t])}off(e,t){this.$events.forEach(((n,r)=>{n[0]===e&&n[1]===t&&this.$events.splice(r,1)}))}emit(e,...t){this.$events.forEach((n=>{n[0]!==e&&"*"!==n[0]||n[1](...t)}))}invoke(e,...t){for(let n=0,s=this.$plugins.length;n<s;n+=1){const s=this.$plugins[n];s[e]&&(r(s[e])&&s[e](...t))}}refreshTraceId(){const e=this.traceId;this.traceId=this.definitions.trace?this.definitions.trace():s(8),this.emit("refreshTraceId",{prev:e,next:this.traceId})}refreshRequestId(){const e=this.requestId;this.requestId=s(8),this.emit("refreshRequestId",{prev:e,next:this.requestId})}start(){this.invoke("start"),this.emit("start")}write(e){setTimeout((()=>{const t={...this.$basicLog,...e},{filters:n}=this;for(let e=0,r=n.length;e<r;e+=1){if(!(0,n[e])(t))return}this.invoke("write",t),this.emit("write",t)}),0)}report(e){let t,s;const o=new Promise(((e,n)=>{t=e,s=n})),i={message:e,resolve:t,reject:s};this.$queue.push(i),this._reporting=!1;const a=()=>setTimeout((()=>{if(this._reporting)return;this._reporting=!0;const e=this.$queue.shift();if(!e)return;const{message:t,resolve:s,reject:o}=e;this.emit("report",t);const i=[];for(let e=0,t=this.$plugins.length;e<t;e+=1){const t=this.$plugins[e],n={};let s=0;r(t.read)&&(n.read=t.read.bind(t),s=1),r(t.send)&&(n.send=t.send.bind(t),s=1),r(t.clear)&&(n.clear=t.clear.bind(t),s=1),s&&i.push(n)}const c=(e,...t)=>Promise.resolve().then((()=>r(e)?e(...t):null));((...e)=>e.reduce(((e,t)=>r(t)?e.then(t):e),Promise.resolve()))((()=>Promise.all(i.map((e=>c(e.read,t).then((t=>(e.data=t,t))))))),(e=>{const t=[];return e.forEach((e=>{n(e)&&e.length&&t.push(...e)})),this.emit("read",t),t}),(e=>{if(e.length)return this.emit("send",e),Promise.all(i.map((t=>c(t.send,t.data,e)))).then((()=>e))}),(e=>{if(e)return this.emit("clear",e),Promise.all(i.map((e=>c(e.clear,e.data))))})).then(s,o).finally((()=>{this._reporting=!1,a()}))}),0);return a(),o}stop(){this.invoke("stop"),this.emit("stop")}static defaultOptions={autoStart:!0}}class a{constructor(e){this.anys=e,this.$effects={}}start(){if(!this.options)return;const e=this.options(),t=Object.keys(e),n=e=>{const t=`register${e.replace(e[0],e[0].toUpperCase())}`;if(this[t]){const n=this[t]();this.$effects[e]=n}},r=this.anys.options;t.forEach((e=>{r[e]&&n(e)}))}stop(){if(!this.options)return;const e=this.options(),t=Object.keys(e),n=this.anys.options;t.forEach((e=>{const t=this.$effects[e];n[e]&&t&&t(),this.$effects[e]=null}))}}function c(e,t){if(e.indexOf("?")<0){const n=Object.keys(t).map((e=>`${e}=${t[e]}`)).join("&"),[r,s]=e.split("#");return r+"?"+n+(s?"#"+s:"")}const[n,r]=e.split("?"),[s,o]=r.split("#"),i=s.split("&").map((e=>e.split("="))).reduce(((e,[t,n])=>({...e,[t]:n})),{});Object.assign(i,t);return n+"?"+Object.keys(i).map((e=>`${e}=${i[e]}`)).join("&")+(o?"#"+o:"")}const u=new class{constructor(){this.$events=[]}on(e,t){this.$events.push([e,t])}emit(e,...t){this.$events.forEach((([n,r])=>{e===n&&r(...t)}))}off(e,t){this.$events.forEach((([n,r],s)=>{e===n&&r===t&&this.$events.splice(s,1)}))}};!function(){const e=window.XMLHttpRequest;window.__XMLHttpRequest=e,window.XMLHttpRequest=function(){const t=new e,n={open:t.open,send:t.send},r={name:s(4)},o=e=>{const{name:n,url:s,method:o}=r;let i,a;t.responseType&&"text"!==t.responseType?"json"===t.responseType&&(i=t.response,a="json"):(i=t.responseText.toString(),a="text"),u.emit("xhr",{type:e,time:Date.now(),name:`xhr_${n}`,url:s,detail:{status:t.status,method:o,responseType:a,response:i||void 0}})},i=()=>{4===t.readyState&&(2===Math.floor(t.status/100)?o("xhr.ok"):o("xhr.fail"))};return Object.defineProperty(t,"open",{get:()=>(e,s,o=!0,...i)=>{const a={method:e,url:s};u.emit("request",a),Object.assign(r,{...a,async:o}),t.onreadystatechange&&(n.onreadystatechange=t.onreadystatechange);const{open:c}=n;return c.call(t,a.method,a.url,o,...i)},configurable:!0}),Object.defineProperty(t,"send",{get:()=>e=>{const{send:s}=n,{async:o}=r;Object.assign(r,{body:e}),(()=>{const{name:e,url:t,method:n,async:s,body:o}=r;u.emit("xhr",{type:"xhr.req",time:Date.now(),name:`xhr_${e}`,url:t,detail:{method:n,async:s,body:o}})})();const a=s.call(t,e);return o||i(),a},configurable:!0}),t.addEventListener("error",(()=>{o("xhr.err")})),t.addEventListener("readystatechange",(e=>{i()})),t}}(),function(){const e=window.fetch;window.__fetch=e,window.fetch=function(t,n={}){const{method:r,body:o}=n,i=s(4);u.emit("fetch",{type:"fetch.init",time:Date.now(),name:`fetch_${i}`,url:t,detail:{body:o,method:r}});const a={method:r,url:t};return u.emit("request",a),Promise.resolve().then((()=>e(a.url,n))).then((e=>{const{status:n}=e;return 2===Math.floor(n/100)?new Proxy(e,{get(s,o){return"json"===o||"text"===o?()=>e[o]().then((e=>(u.emit("fetch",{type:"fetch.ok",time:Date.now(),name:`fetch_${i}`,url:t,detail:{status:n,data:e,method:r}}),e))):"function"==typeof e[o]?e[o].bind(e):e[o]}}):(u.emit("fetch",{type:"fetch.fail",time:Date.now(),name:`fetch_${i}`,url:t,detail:{status:n,method:r}}),e)}),(e=>{let n;if(e instanceof Error){const{name:t,message:s}=e;n={method:r,type:t,err:s}}else n={method:r,err:e};u.emit("fetch",{type:"fetch.err",time:Date.now(),name:`fetch_${i}`,url:t,detail:n})}))}}();class h extends a{options(){return{xhr:!0,fetch:!0,ajaxResponse:!0,patchRequestId:!0}}registerXhr(){const e=e=>{this.anys.options.ajaxResponse||"xhr.ok"!==e.type||delete e.detail.response,this.anys.write(e)};return u.on("xhr",e),()=>u.off("xhr",e)}registerFetch(){const e=e=>{this.anys.options.ajaxResponse||"fetch.ok"!==e.type||delete e.detail.data,this.anys.write(e)};return u.on("fetch",e),()=>u.off("fetch",e)}registerPatchRequestId(){const e=e=>{const{url:t}=e,{traceId:n,requestId:r}=this.anys,s=c(t,{_request_id:n+r});e.url=s};return u.on("request",e),()=>u.off("request",e)}}class d{constructor(e){this.anys=e}options(){return{namespace:new Error("options.namespace is required!")}}defines(){return{client:this.defineClientId.bind(this),trace:this.defineTraceId.bind(this)}}defineClientId(){const{namespace:e}=this.anys.options,t=`Anys.${e}.clientId`;let n=localStorage.getItem(t);return n||(n=s(8),sessionStorage.setItem(t,n)),n}defineTraceId(){const{namespace:e}=this.anys.options,t=`Anys.${e}.traceId`,n=s(8);return sessionStorage.setItem(t,n),n}}function l(e,t=document.documentElement){const{nodeName:n,path:r}=e;if(r)return r;if("BODY"===n||"HTML"===n||"HEAD"===n)return n;const s=[];let o=e,i=e.parentNode;const a=e=>{const{nodeName:t,parentNode:n}=e;if(!n)return-1;return[].filter.call(n.childNodes,(e=>e.nodeName===t)).indexOf(e)};if("#"===n[0]){const t=a(e);s.push(`${n}:${t}`),o=i,i=o.parentNode}for(;i&&o!==t;){const{nodeName:e}=o;if("BODY"===e||"HTML"===e||"HEAD"===e)s.push(e);else{const t=a(o);s.push(`${e.toLowerCase()}:${t}`)}o=i,i=o.parentNode}return s.reverse(),s.join("/")}class p extends a{options(){return{input:!0}}registerInput(){const e=e=>t=>{const{target:n,type:r,inputType:s,data:o}=t;if("insertCompositionText"===s)return;if("compositionend"===r&&!o)return;const{tagName:i,value:a}=n;if(n.getAttribute("anys-ignore"))return;const c=n.getAttribute("type"),u=e({tagName:i,value:a,type:c,target:n});if(!u)return;const h={type:"input",time:Date.now(),el:l(n),detail:u};this.anys.write(h)},t=e((({tagName:e,value:t,type:n})=>"INPUT"===e&&"radio"!==n&&"checkbox"!==n&&"password"!==n?{value:t,type:n}:"INPUT"===e&&"password"===n?{value:"***",type:n}:"TEXTAREA"===e?{value:t,type:"textarea"}:void 0)),n=e((({tagName:e,value:t,type:n})=>"SELECT"===e?{value:t,type:"select"}:"INPUT"!==e||"radio"!==n&&"checkbox"!==n?void 0:{value:t,type:n})),r=e((({tagName:e,value:t,type:n})=>"TEXTAREA"===e?{value:t,type:"textarea"}:"INPUT"===e?{value:t,type:n}:void 0));return document.addEventListener("input",t,!0),document.addEventListener("compositionend",t,!0),document.addEventListener("change",n,!0),document.addEventListener("paste",r,!0),()=>{document.removeEventListener("input",t),document.removeEventListener("compositionend",t),document.removeEventListener("change",n),document.removeEventListener("paste",r)}}}class m extends a{options(){return{mouse:!("ontouchend"in document),click:!0,mousemove:!1,mousedown:!1,mouseup:!1,wheel:!1,contextmenu:!1}}addEventListener(e,t){if(!this.anys.options.mouse)return;const n=this.createThrottleListener((t=>{const{innerWidth:n,innerHeight:r}=window,{target:s,button:o,pageX:i,pageY:a}=t;return{type:e,time:Date.now(),detail:{e:l(s),w:n,h:r,x:i,y:a,button:o}}}),t);return document.addEventListener(e,n,!0),()=>document.removeEventListener(e,n)}registerClick(){return this.addEventListener("click")}registerMouseup(){return this.addEventListener("mouseup")}registerMousedown(){return this.addEventListener("mousedown")}registerContextmenu(){return this.addEventListener("contextmenu")}registerMousemove(){return this.addEventListener("mousemove",100)}registerWheel(){if(!this.anys.options.mouse)return;const e="wheel",t=this.createThrottleListener((t=>{const{target:n,deltaX:r,deltaY:s,deltaZ:o,deltaMode:i}=t;return{type:e,time:Date.now(),detail:{e:l(n),deltaX:r,deltaY:s,deltaZ:o,mode:i}}}),100);return document.addEventListener(e,t),()=>document.removeEventListener(e,t)}createThrottleListener(e,t){let n=0,r=0;return s=>{if(n)return;const o=Date.now();if(t&&r+t>o)return;const i=e(s);requestAnimationFrame((()=>{this.anys.write(i),n=0,r=Date.now()})),n=1}}}const f={type:"window_activity.enter",time:Date.now()};class y extends a{options(){return{activity:!0,deadTimeout:0}}init(){this.anys.options.activity&&this.anys.write(f)}registerActivity(){const e=()=>{if("hidden"===document.visibilityState){const e={type:"window_activity.focusout",time:Date.now()};this.anys.write(e)}else{const e={type:"window_activity.focusin",time:Date.now()};this.anys.write(e)}},t=()=>{const e={type:"window_activity.unload",time:Date.now()};this.anys.write(e)};return window.addEventListener("beforeunload",t,!0),document.addEventListener("visibilitychange",e,!0),()=>{window.removeEventListener("beforeunload",t),document.removeEventListener("visibilitychange",e)}}registerDeadTimeout(){const{deadTimeout:e}=this.anys.options;if(!e)return;let t;const n=()=>{clearTimeout(t),t=setTimeout((()=>{const e={type:"window_activity.dead",time:Date.now()};this.anys.write(e)}),e)};return document.addEventListener("keydown",n,!0),document.addEventListener("mousedown",n,!0),document.addEventListener("touchstart",n,!0),document.addEventListener("touchmove",n,!0),document.addEventListener("mousemove",n,!0),document.addEventListener("scroll",n,!0),window.addEventListener("resize",n,!0),()=>{document.removeEventListener("keydown",n),document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n),document.removeEventListener("touchmove",n),document.removeEventListener("mousemove",n),document.removeEventListener("scroll",n),window.removeEventListener("resize",n)}}}class v extends a{options(){return{url:!0}}registerUrl(){const e=()=>{this.recordUrl()};return window.addEventListener("hashchange",e),window.addEventListener("popstate",e),this.recordUrl(),()=>{window.removeEventListener("hashchange",e),window.removeEventListener("popstate",e)}}recordUrl(){const e=window.location.href,t=new URL(e),n=t.pathname.replace(/^([^/])/,"/$1"),r={type:"url",time:Date.now(),url:e,detail:{uri:n+(t.search?`?${t.search}`:""),path:n,protocol:t.protocol.replace(":",""),host:t.hostname,port:t.port,search:t.search,hash:t.hash.replace("#","")}};this.anys.write(r)}}class g extends a{options(){const e="ontouchend"in document;return{touch:e,touchstart:e,touchend:e,touchmove:e}}addEventListener(e){if(!this.anys.options.touch)return;let t=0;const n=n=>{if(t)return;const{innerWidth:r,innerHeight:s}=window,{target:o,identifier:i,force:a,pageX:c,pageY:u}=n,h={type:e,time:Date.now(),detail:{e:l(o),width:r,height:s,x:c,y:u,identifier:i,force:a}};requestAnimationFrame((()=>{this.anys.write(h),t=0})),t=1};return document.addEventListener(e,n,!0),()=>document.removeEventListener(e,n)}registerTouchmove(){return this.addEventListener("touchmove")}registerTouchend(){return this.addEventListener("touchend")}registerTouchstart(){return this.addEventListener("touchstart")}}class w{constructor(){this.queue=[],this.status=0}push(e){let t,n;const r=new Promise(((e,r)=>{t=e,n=r})),s={runner:e,resolve:t,reject:n};this.queue.push(s);const o=()=>{setTimeout((()=>{if(!this.queue.length)return void(this.status=0);const{runner:e,resolve:t,reject:n}=this.queue.shift();e().then(t,n).finally(o)}),0),this.status=1};return this.status||o(),r}}class b{constructor(e={}){let{name:t,version:n=1,stores:r}=e;const s=!t;t||(t="__indb__"),r&&Array.isArray(r)&&r.length||(r=[{name:"__indb__",isKv:!0}]),this.cache={},this.connection=null,this.name=t,this.version=n,this.stores=r;const o=indexedDB.open(t,n);if(o.onupgradeneeded=e=>{const t=e.target.result,n=Array.from(t.objectStoreNames),s=[];r.forEach((r=>{let o=null;if(n.indexOf(r.name)>-1)o=e.target.transaction.objectStore(r.name);else{const e=r.isKv?"key":r.primaryKeyPath,n=!r.isKv&&r.autoIncrement;o=t.createObjectStore(r.name,{keyPath:e,autoIncrement:n})}const i=o.indexNames;i&&i.length&&Array.from(i).forEach((e=>o.deleteIndex(e))),r.indexes&&r.indexes.length&&r.indexes.forEach((e=>{o.createIndex(e.name,e.keyPath||e.name,{unique:e.unique,multiEntry:Array.isArray(e.keyPath)})})),s.push(r.name)})),n&&n.forEach((e=>{-1===s.indexOf(e)&&t.deleteObjectStore(e)}))},o.onblocked=e=>{console.error(L(new Error("indexedDB "+t+" is blocked")))},s)return this.use(t)}connect(){return new Promise(((e,t)=>{const n=indexedDB.open(this.name,this.version);n.onerror=e=>{t(L(e))},n.onsuccess=t=>{e(t.target.result)}}))}use(e){const t=this.stores.find((t=>t.name===e));if(!t)throw new Error(`[InDB]: store ${e} is not existing.`);if(this.cache[e])return this.cache[e];const n=new E({db:this,store:t});return t.isKv&&Object.defineProperties(n,{key:{value:e=>n.keys().then((t=>t&&t[e]))},getItem:{value:e=>n.get(e).then((e=>e&&e.value))},setItem:{value:(e,t)=>n.put({key:e,value:t})},removeItem:{value:e=>n.delete(e)}}),this.cache[e]=n,n}close(){return this.cache=null,this.stores=null,this.connect().then((e=>{e.close()}))}static deleteDatabase(e){return new Promise(((t,n)=>{const r=indexedDB.deleteDatabase(e);r.onsuccess=()=>{t()},r.onerror=e=>{n(e)}}))}static databases(){return indexedDB.databases()}}class E{constructor(e={}){const{store:t,db:n}=e;if("object"!=typeof t||!t.name||"string"!=typeof t.name)throw new Error("[InDBStore]: options.store should be a store config object.");if(!(n instanceof b))throw new Error("[InDBStore]: options.db should be an instanceof InDB.");this.db=n,this.store=t,this.name=t.name,this.primaryKeyPath=t.isKv?"key":t.primaryKeyPath,this._queue=[]}transaction(e=!1){const t=()=>{const t=this.name,n=e?"readwrite":"readonly",r=this.db.connection;return(r?Promise.resolve(r):this.db.connect()).then((e=>{this.db.connection=e;const r=e.transaction(t,n),s=()=>{this.db.connection=null,this._queue.shift()};return r.oncomplete=s,r.onabort=s,r.onerror=s,r}))},n=this._queue[this._queue.length-1],r=n?n.then((()=>t())):t();return this._queue.push(r),r}objectStore(e=!1){const t=this.name;return this.transaction(e).then((e=>e.objectStore(t)))}cursor(e){const{index:t,range:n,direction:r,onTouch:s,onDone:o,onError:i,writable:a=!1}=e;return this.objectStore(a).then((e=>{const a=t?e.index(t):e,c=a.openCursor(n,r);c.onsuccess=e=>{const t=e.target.result;t?s(t,a):o(t,a)},c.onerror=e=>{i(L(e))}}))}request(e,t={}){const{writable:n=!1}=t;return new Promise(((t,r)=>{this.objectStore(n).then((n=>{const s=e(n);s.onsuccess=e=>{const n=e.target.result;t(n)},s.onerror=e=>{r(L(e))}}))}))}iterate(e,t={}){const{index:n,range:r,writable:s=!1,direction:o="next"}=t;return new Promise(((t,i)=>{this.cursor({index:n,range:r,writable:s,direction:o,onTouch:(n,r)=>{e(n,(()=>n.continue()),(()=>{r.transaction.commit(),t()}))},onDone:()=>{t()},onError:e=>{i(e)}})}))}batch(e,t={}){const{writable:n=!0}=t;return this.transaction(n).then((t=>{const n=this.name,r=[],s=t.objectStore(n);return e.forEach((e=>{const t=new Promise(((t,n)=>{const r=e(s);r.onsuccess=e=>{const n=e.target.result;t(n)},r.onerror=e=>{n(L(e))}}));r.push(t)})),Promise.all(r)}))}get(e){if(!Array.isArray(e))return this.request((t=>t.get(e)));const t=e.map((e=>t=>t.get(e)));return this.batch(t,{writable:!1})}keys(){const e=this.primaryKeyPath,t=[];return this.each((n=>{const r=x(n,e);t.push(r)})).then((()=>t))}all(){const e=[];return this.each((t=>{e.push(t)})).then((()=>e))}count(){return this.request((e=>e.count()))}each(e){return this.iterate(((t,n)=>{const r=t.value;e(r),n()}))}reverse(e){return this.iterate(((t,n)=>{const r=t.value;e(r),n()}),{direction:"prev"})}some(e=10,t=0){return new Promise(((n,r)=>{const s=[];let o,i=0,a=t,c=t+e;t<0&&(o="prev",e=Math.min(e,-t),a=-(t+e)||0,c=a+e),this.iterate(((e,t,n)=>{i<a?(i++,t()):i<c?(s.push(e.value),i++,t()):n()}),{direction:o}).then((()=>{t<0&&s.reverse(),n(s)})).catch(r)}))}first(){return this.some(1).then((e=>e[0]))}last(){return this.some(1,-1).then((e=>e[0]))}find(e,t){return this.request((n=>n.index(e).get(t)))}query(e,t,n){const r=function(){switch(n){case">":return IDBKeyRange.lowerBound(t,!0);case">=":return IDBKeyRange.lowerBound(t);case"<":return IDBKeyRange.upperBound(t,!0);case"<=":return IDBKeyRange.upperBound(t);case"%":case"!=":case"in":return;default:return IDBKeyRange.only(t)}}(),s=[];return new Promise(((o,i)=>{this.cursor({index:e,range:r,onTouch:(e,r)=>{const o=e.value,i=x(o,r.keyPath);"!="===n?i!==t&&s.push(o):"%"===n?"string"==typeof i&&i.indexOf(t)>-1&&s.push(o):"in"===n?Array.isArray(t)&&t.indexOf(i)>-1&&s.push(o):s.push(o),e.continue()},onDone:()=>{o(s)},onError:e=>{i(e)}})}))}select(...e){const t=this.store.indexes||[],n={};t.forEach((e=>{const{name:t,keyPath:r}=e;n[t]=r}));const r=function(e,t,n){if(void 0===e)return!1;switch(n){case">":return e>t;case">=":return e>=t;case"<":return e<t;case"<=":return e<=t;case"!=":return e!==t;case"%":return"string"==typeof e&&e.indexOf(t)>-1;case"in":return Array.isArray(t)&&t.indexOf(e)>-1;default:return e===t}},s=function(e,t,n){if(!t.length&&!n.length)return!1;for(let n=0,s=t.length;n<s;n++){const{keyPath:s,value:o,compare:i}=t[n],a=x(e,s);if(!r(a,o,i))return!1}if(!n.length)return!0;for(let t=0,s=n.length;t<s;t++){const{keyPath:s,value:o,compare:i}=n[t],a=x(e,s);if(r(a,o,i))return!0}return!1},o=[];e.forEach((e=>{const t=[],r=[];for(let s=0,o=e.length;s<o;s++){const{key:o,value:i,compare:a,optional:c}=e[s],u=n[o]||o;c?t.push({keyPath:u,value:i,compare:a}):r.push({keyPath:u,value:i,compare:a})}o.push([r,t])}));const i=[];return this.each((e=>{(e=>{for(let t=0,n=o.length;t<n;t++){const[n,r]=o[t];if(s(e,n,r))return!0}return!1})(e)&&i.push(e)})).then((()=>i))}add(e,t){if(Array.isArray(e)){const n=e;if(n.length<2)return this.add(e[0],t);const r=n.map((e=>n=>n.add(e,t)));return this.batch(r)}return e?this.request((n=>n.add(e,t)),{writable:!0}):Promise.resolve()}put(e,t){if(Array.isArray(e)){const n=e;if(n.length<2)return this.put(n[0],t);const r=n.map((e=>n=>n.put(e,t)));return this.batch(r)}return e?this.request((n=>n.put(e,t)),{writable:!0}):Promise.resolve()}delete(e){if(Array.isArray(e)){const t=e;if(t.length<2)return this.delete(t[0]);const n=t.map((e=>t=>t.delete(e)));return this.batch(n)}return e?this.request((t=>t.delete(e)),{writable:!0}):Promise.resolve()}remove(e){const t=this.primaryKeyPath;if(Array.isArray(e)){const n=e;if(n.length<2)return this.remove(n[0]);const r=n.map((e=>{const n=x(e,t);return e=>e.delete(n)}));return this.batch(r)}if(!e)return Promise.resolve();const n=x(e,t);return n?this.delete(n):Promise.resolve()}clear(){return this.request((e=>e.clear()),{writable:!0})}}function x(e,t){if(null==t)return;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++){const r=x(e,t[n]);if(void 0!==r)return r}return}let n=function(e){return e.toString().split(/\.|\[|\]/).filter((e=>!!e))}(t);if(!n.length)return e;let r=e;for(let e=0,t=n.length;e<t;e++){let t=n[e];if(void 0===r[t])return;r=r[t]}return r}function L(e){const{message:t}=e;return e.message=-1===t.indexOf("[IndexedDB]")?"[IndexedDB]: "+t:t,e}class I{constructor(e){this.anys=e}options(){return{namespace:new Error("options.namespace is required!"),autoReport:!1,expireTime:1728e5}}init(){const e="anyslogs",t=new b({name:this.anys.options.namespace,version:1,stores:[{name:e,primaryKeyPath:"_id",autoIncrement:!0}]});this.db=t.use(e),this.queue=new w;const{expireTime:n}=this.anys.options;if(n){let e=0;const t=setInterval((()=>{this.queue.push((()=>this.db.some(100,e))).then((r=>{if(!r.length)return void clearInterval(t);const s=Date.now(),o=[];r.forEach((e=>{const{_id:t,time:r}=e;s-r>n&&o.push(t)})),o.length&&this.queue.push((()=>this.db.delete(o))),e+=100,e-=o.length}))}),1e4)}}write(e){this.queue.push((()=>this.db.add(e))).then((t=>{this.anys.emit("writeOfflineLog",{id:t,data:e})}))}read(e){if(e){if(!Array.isArray(e))return;if(e.some((e=>!e.key)))return}else e=[{key:"client",value:this.anys.clientId},{key:"trace",value:this.anys.traceId}];return this.select(e)}clear(e){return this.queue.push((()=>this.db.remove(e))).catch((()=>{}))}select(e){return this.queue.push((()=>this.db.select(e)))}remove(e){return this.queue.push((()=>this.db.delete(e))).catch((()=>{}))}}class O extends a{options(){return{mutation:!0}}registerMutation(){const e=this.createObserver((e=>{const t={type:"mutation",time:Date.now(),detail:e};this.anys.write(t)}));return window.addEventListener("load",(()=>{e.observe(document,{characterData:!0,attributes:!0,childList:!0,subtree:!0}),this.recordSnapshot(),P(document.documentElement)})),()=>{e.disconnect()}}recordSnapshot(){const e=function(){const{name:e,publicId:t,systemId:n}=document.doctype,r={name:e,publicId:t,systemId:n},s=q(document.documentElement.innerHTML),o={},i=document.querySelector("html");for(let{name:e,value:t}of i.attributes)o[e]=t;const a=function(){const e=document.querySelectorAll("input, textarea, select"),t=[];return Array.from(e).forEach((e=>{const n=l(e),r="password"===e.type?"***":e.value;t.push({el:n,value:r})})),t}();return{doctype:r,attrs:o,html:s,values:a}}(),t=window.location.href,n=new URL(t),r=n.pathname.replace(/^([^/])/,"/$1");this.anys.write({type:"snapshot",time:Date.now(),url:{uri:r+(n.search?`?${n.search}`:""),path:r,protocol:n.protocol.replace(":",""),host:n.hostname,port:n.port,search:n.search,hash:n.hash.replace("#","")},detail:e})}createObserver(e){const t=new MutationObserver((t=>{const n=[];[...t].reverse().forEach((e=>{const{type:t,target:r,attributeName:s,oldValue:o}=e;if(!(e=>{if(e.hasAttribute?.("anys-ignore"))return!0;let t=e.parentNode;for(;t;){if(t.hasAttribute?.("anys-ignore"))return!0;t=t.parentNode}return!1})(r)){if("attributes"===t){if(r.getAttribute(s)===o)return;if(n.find((e=>e.type===t&&e.target===r&&e.attributeName===s)))return}else if("characterData"===t){const e=r.data;if(e===o)return;if(n.find((n=>n.type===t&&n.target===r&&n.target.data===e)))return}n.push(e)}})),n.reverse();const r=[];n.forEach((e=>{const{type:t,target:n,attributeName:s,oldValue:o}=e,i=n.path||l(n),a=e=>l(e).replace(i+"/","");if("attributes"===t){const e=n.getAttribute(s),t=o;r.push({type:"attribute",target:i,name:s,next:e,prev:t})}else if("characterData"===t){const e=n.data,t=o;r.push({type:"text",target:i,next:e,prev:t})}else if("childList"===t){if("TEXTAREA"===n.nodeName)return;const{removedNodes:t,addedNodes:s,previousSibling:o,nextSibling:c}=e,u=[],h=Array.from(t).map((e=>{if(document.body.contains(e))return void u.push({node:e,path:l(e)});const t=e.path?a(e):null,n=o?l(o):null,r=c?l(c):null,s={};return t?s.node=t:(s.before=n,s.after=r),s})).filter(Boolean),d=[],p=Array.from(s).map((e=>{const t=e.nextSibling?a(e.nextSibling):null,n=u.find((t=>t.node===e));if(n)return void d.push({node:n.path,sibling:t});const r="#text"===e.nodeName,s="#comment"===e.nodeName,o=r?e.data:null,i=s?e.data:null;return{text:o,html:r||s?null:q(e.outerHTML),comment:i,sibling:t}})).filter(Boolean);r.push({type:"children",target:i,remove:h,insert:p,move:d}),P(n)}})),e(r)}));return P(document),t}}function P(e){if(e!==document){const t=l(e);e.path=t}const t=e.childNodes;Array.from(t).forEach((e=>{P(e)}))}function q(e){return e.replace(/<script([^]*?)>([^]*?)<\/script>/gm,"<noscript$1></noscript>").replace(/<noscript([^]*?)>([^]*?)<\/noscript>/gm,"<noscript$1></noscript>").replace(/<link([^]*?)as="script"([^]*?)>/g,"<link$1$2>").replace(/\n\n*\s*\n*\n/gm,"\n")}class k extends a{options(){return{size:!0}}createRecordLog(){const{innerWidth:e,innerHeight:t}=window;return{type:"window_size",time:Date.now(),detail:{width:e,height:t}}}registerSize(){let e;const t=()=>{clearTimeout(e);const t=this.createRecordLog();e=setTimeout((()=>{this.anys.write(t)}),100)};return this.recordSize(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}}recordSize(){const e=this.createRecordLog();this.anys.write(e)}}class D extends a{options(){return{scroll:!0}}registerScroll(){let e=0;const t=t=>{if(e)return;const{target:n,bubbles:r}=t;let s;if(r){const{scrollX:e,scrollY:t}=window;s={type:"window_scroll",time:Date.now(),detail:{scrollX:e,scrollY:t}}}else{const{scrollLeft:e,scrollTop:t}=n;s={type:"scroll",time:Date.now(),target:l(n),detail:{scrollLeft:e,scrollTop:t}}}requestAnimationFrame((()=>{this.anys.write(s),e=0})),e=1};return window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("scroll",t)}}}class T extends a{static dependencies=[I,v,k,O,d,h,p,m,y,g,D];constructor(e,[t,n,r,s]){super(e),this.offlineStore=t,this.urlMonitor=n,this.windowSizeMonitor=r,this.DOMMutationMonitor=s,this.cache={}}options(){const e="ontouchend"in document;return{touch:e,mouse:!e,click:!1,mousedown:!0,mousemove:!0,mouseup:!0,autoReport:!1,reportUrl:new Error("options.reportUrl is required!"),reportInterval:1e4,reportParams:null}}registerAutoReport(){const{clientId:e}=this.anys,t=({prev:t})=>{this.anys.report([{key:"client",value:e},{key:"trace",value:t}]),this.cache={},this.urlMonitor.recordUrl(),this.windowSizeMonitor.recordSize(),this.DOMMutationMonitor.recordSnapshot()};this.anys.on("refreshTraceId",t);const n=setInterval((()=>{this.anys.report()}),this.anys.options.reportInterval);let r=0;const s=()=>{if(r)return;r=1;const e=Object.keys(this.cache),t=Object.values(this.cache);e.length&&(this.offlineStore.remove(e),navigator.sendBeacon(this.anys.options.reportUrl,JSON.stringify(t)),this.cache={})};window.addEventListener("beforeunload",s),window.addEventListener("pagehide",s),window.addEventListener("unload",s);const o=({id:e,data:t})=>{this.cache[e]=t};return this.anys.on("writeOfflineLog",o),()=>{this.anys.off("refreshTraceId",t),this.anys.off("writeOfflineLog",o),clearInterval(n),window.removeEventListener("beforeunload",s)}}read(e){return this.offlineStore.read(e)}send(e){const t=[];let n=0;e.forEach((e=>{t[n]=t[n]||[],t[n].push(e),t[n].length>200&&n++}));const r=t.map((e=>{const t=[],n=[];if(e.forEach((e=>{const{_id:r,...s}=e;n.push(r),t.push(s)})),!t.length)return;const{reportUrl:r,reportParams:s}=this.anys.options;return function(e,t){return new Promise(((n,r)=>{const s=new(window.__XMLHttpRequest||window.XMLHttpRequest);s.open("POST",e,!0),s.onreadystatechange=function(){4==s.readyState&&(200==s.status?n(s.responseText):r(new Error(`ajax post fail with status ${s.status}`)))},s.onerror=r,s.send(JSON.stringify(t))}))}(s?c(r,s):r,{data:t}).then((()=>{n.forEach((e=>{delete this.cache[e]}))}))}));return Promise.all(r)}clear(){this.cache={}}}class j extends i{auth(e){this.options.reportParams=Object.assign(this.options.reportParams||{},e)}}const A=(e={})=>new j({namespace:"AnysTracer",autoReport:!1,...e,plugins:{...e.plugins||{},recorder:T}})}();var n=anys="undefined"==typeof anys?{}:anys;for(var r in t)n[r]=t[r];t.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})}();
|
|
1
|
+
!function(){var t={d:function(e,r){for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};!function(){"use strict";function r(t){return Array.isArray(t)}function n(t,e){return"function"==typeof t&&(!e||!function(t,e){if("function"!=typeof t)return!1;if(t===Symbol)return!1;if(!t.prototype)return!1;var r=t+"",n=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim(),o=0===r.indexOf("class "),i="[native code]"===n,u=o||i;if(e>=4)return u;var a=n.replace(/function.*?\{.*?\}/gm,"").replace(/return/gm,"").replace(/\n+/gm,";").replace(/\s+/gm,"").replace(/;;/gm,";"),c=/^_classCallCheck\(this,/.test(a),f=/^\(.*?_classCallCheck.*?\)\(this,/.test(a),s=/^[0-9a-zA-Z_;!?:]*?\(this,/.test(a),l=u||c||f||s;if(3==e)return l;var p=Object.getOwnPropertyDescriptors(t.prototype),y=!!Object.keys(p).filter((function(t){return"constructor"!==t})).length,v=l||y;if(2==e)return v;var m=0===a.indexOf("this.")||a.indexOf(";this.")>-1||a.indexOf("=this;")>-1,b=v||m;if(1==e)return b;return!0}(t,2))}function o(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,e="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ",r="",n=0;n<t;n++)r+=e.charAt(Math.floor(Math.random()*e.length));return r}function i(t,e,n){var o;return n?(o=Object.getOwnPropertyDescriptors(t),void Object.keys(o).forEach((function(r){var n=o[r],i=n.get,u=n.set,a=n.enumerable,c=n.configurable,f=n.writable;(a||i||u||c&&f)&&e(n,r,t)}))):void(r(t)?t.forEach(e):Object.keys(t).forEach((function(r){var n=t[r];e(n,r,t)})))}t.r(e),t.d(e,{create:function(){return Pe}});Symbol("Proxy");var u=["filters","plugins"],a=["filters","plugins","defines"];function c(t){return function(t){if(Array.isArray(t))return f(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return f(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function l(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?l(Object(r),!0).forEach((function(e){y(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function y(t,e,r){return(e=b(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function v(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,b(n.key),n)}}function b(t){var e=function(t,e){if("object"!==s(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===s(e)?e:String(e)}var d=function(){function t(e){var f=this;this.$events=[],this.$queue=[];var l,y=(l=this,Object.getPrototypeOf(l).constructor),m=p(p({},t.defaultOptions),y.defaultOptions||{}),b=m.filters,d=void 0===b?[]:b,h=m.plugins,g=void 0===h?[]:h,w=v(m,u),O=e||{},S=O.filters,j=void 0===S?[]:S,P=O.plugins,E=void 0===P?[]:P,x=O.defines,A=void 0===x?[]:x,_=v(O,a),I={},T=[],L={},k=E&&!r(E)&&"object"===s(E),D=k?K(E):r(E)?E:[],q=k?Object.keys(E).map((function(t){return{key:t,value:E[t]}})):[],N=[].concat(c(g),c(D));!function t(e){e.forEach((function(e){var r=e.dependencies||[];r.forEach((function(t){N.unshift(t)})),t(r)}))}(N);var M=N.filter((function(t,e){return e===N.indexOf(t)})),$=[],R={};M.forEach((function(t){var e,r,n,o=null===(e=q.find((function(e){return e.value===t})))||void 0===e?void 0:e.key;if(o&&R[o])return n="plugin named '".concat(r=o,"' has been registered"),void(R[r]instanceof t?console.debug(n,t,R):console.error(n,t,R));var i=(t.dependencies||[]).map((function(t){return $.find((function(e){return e instanceof t}))})),u=new t(f,i);u.options&&X(I,u.options()),u.defines&&X(L,u.defines()),u.filters&&T.push.apply(T,c(u.filters())),$.push(u),o&&(R[o]=u)})),this.$plugins=$,this.plugins=R,this.options=p(p(p({},w),I),_),this.filters=[].concat(c(d),T,c(j));var B=K(this.options).find((function(t){return t&&t instanceof Error}));if(B)throw B;var U=p(p({},L),A);this.definitions=U,this.clientId=U.client?U.client():o(8),this.traceId=U.trace?U.trace():o(8),this.requestId=o(8);var C={};function K(t){return Object.keys(t).map((function(e){return t[e]}))}function X(t,e){return Object.keys(e).forEach((function(r){var n=e[r];t[r]=n})),t}Object.defineProperties(C,function(t,e){if(r(t))return t.map(e);var n={};return i(t,(function(r,o){n[o]=e(r,o,t)})),n}(U,(function(t){return{get:n(t)?t:function(){return t},enumerable:!0,configurable:!0}}))),Object.defineProperties(C,{client:{get:function(){return f.clientId},enumerable:!0,configurable:!0},trace:{get:function(){return f.traceId},enumerable:!0,configurable:!0},request:{get:function(){return f.requestId},enumerable:!0,configurable:!0}}),this.$basicLog=C,this.invoke("init"),this.options.autoStart&&this.start()}var e,f,l,y=t.prototype;return y.define=function(t,e){Object.defineProperty(this.$basicLog,t,{get:e,enumerable:!0,configurable:!0})},y.on=function(t,e){this.$events.push([t,e])},y.off=function(t,e){var r=this;this.$events.forEach((function(n,o){n[0]===t&&n[1]===e&&r.$events.splice(o,1)}))},y.emit=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];this.$events.forEach((function(e){e[0]!==t&&"*"!==e[0]||e[1].apply(e,r)}))},y.invoke=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=arguments[o];for(var i=0,u=this.$plugins.length;i<u;i+=1){var a=this.$plugins[i];a[t]&&(n(a[t])&&a[t].apply(a,r))}},y.refreshTraceId=function(){var t=this.traceId;this.traceId=this.definitions.trace?this.definitions.trace():o(8),this.emit("refreshTraceId",{prev:t,next:this.traceId})},y.refreshRequestId=function(){var t=this.requestId;this.requestId=o(8),this.emit("refreshRequestId",{prev:t,next:this.requestId})},y.start=function(){this.invoke("start"),this.emit("start")},y.write=function(t){for(var e=p(p({},this.$basicLog),t),r=this.filters,n=0,o=r.length;n<o;n+=1){if(!(0,r[n])(e))return}this.invoke("write",e),this.emit("write",e)},y.report=function(t){var e,o,i=this,u=new Promise((function(t,r){e=t,o=r})),a={message:t,resolve:e,reject:o};this.$queue.push(a),this._reporting=!1;return function t(){if(!i._reporting){i._reporting=!0;var e=i.$queue.shift();if(e){var o=e.message,u=e.resolve,a=e.reject;i.emit("report",o);for(var f=[],s=0,l=i.$plugins.length;s<l;s+=1){var p=i.$plugins[s],y={},v=0;n(p.read)&&(y.read=p.read.bind(p),v=1),n(p.send)&&(y.send=p.send.bind(p),v=1),n(p.clear)&&(y.clear=p.clear.bind(p),v=1),v&&f.push(y)}var m=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=arguments[o];return Promise.resolve().then((function(){return n(t)?t.apply(void 0,r):null}))};(function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.reduce((function(t,e){return n(e)?t.then(e):t}),Promise.resolve())})((function(){return Promise.all(f.map((function(t){return m(t.read,o).then((function(e){return t.data=e,e}))})))}),(function(t){var e=[];return t.forEach((function(t){r(t)&&t.length&&e.push.apply(e,c(t))})),i.emit("read",e),e}),(function(t){if(t.length)return i.emit("send",t),Promise.all(f.map((function(e){return m(e.send,e.data,t)}))).then((function(){return t}))}),(function(t){if(t)return i.emit("clear",t),Promise.all(f.map((function(t){return m(t.clear,t.data)})))})).then(u,a).finally((function(){i._reporting=!1,t()}))}}}(),u},y.stop=function(){this.invoke("stop"),this.emit("stop")},e=t,f&&m(e.prototype,f),l&&m(e,l),Object.defineProperty(e,"prototype",{writable:!1}),e}();function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function g(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function w(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?g(Object(r),!0).forEach((function(e){O(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function O(t,e,r){return(e=function(t){var e=function(t,e){if("object"!==h(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==h(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===h(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function S(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],c=!0,f=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){f=!0,o=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(f)throw o}}return a}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return j(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return j(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function P(t,e){if(t.indexOf("?")<0){var r=Object.keys(e).map((function(t){return"".concat(t,"=").concat(e[t])})).join("&"),n=S(t.split("#"),2),o=n[0],i=n[1];return o+"?"+r+(i?"#"+i:"")}var u=S(t.split("?"),2),a=u[0],c=S(u[1].split("#"),2),f=c[0],s=c[1],l=f.split("&").map((function(t){return t.split("=")})).reduce((function(t,e){var r=S(e,2),n=r[0],o=r[1];return w(w({},t),{},O({},n,o))}),{});return Object.assign(l,e),a+"?"+Object.keys(l).map((function(t){return"".concat(t,"=").concat(l[t])})).join("&")+(s?"#"+s:"")}function E(t){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},E(t)}function x(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,A(n.key),n)}}function A(t){var e=function(t,e){if("object"!==E(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==E(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===E(e)?e:String(e)}d.defaultOptions={autoStart:!0};var _=function(){function t(t){this.anys=t,this.$effects={}}var e,r,n,o=t.prototype;return o.start=function(){var t=this;if(this.options){var e=this.options(),r=Object.keys(e),n=this.anys.options;r.forEach((function(e){n[e]&&function(e){var r="register".concat(e.replace(e[0],e[0].toUpperCase()));if(t[r]){var n=t[r]();t.$effects[e]=n}}(e)}))}},o.stop=function(){var t=this;if(this.options){var e=this.options(),r=Object.keys(e),n=this.anys.options;r.forEach((function(e){var r=t.$effects[e];n[e]&&r&&r(),t.$effects[e]=null}))}},e=t,r&&x(e.prototype,r),n&&x(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}();function I(t){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},I(t)}function T(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],c=!0,f=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){f=!0,o=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(f)throw o}}return a}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return L(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return L(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function k(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,D(n.key),n)}}function D(t){var e=function(t,e){if("object"!==I(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==I(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===I(e)?e:String(e)}var q=function(){function t(){this.$events=[]}var e,r,n,o=t.prototype;return o.on=function(t,e){this.$events.push([t,e])},o.emit=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];this.$events.forEach((function(e){var n=T(e,2),o=n[0],i=n[1];t===o&&i.apply(void 0,r)}))},o.off=function(t,e){var r=this;this.$events.forEach((function(n,o){var i=T(n,2),u=i[0],a=i[1];t===u&&a===e&&r.$events.splice(o,1)}))},e=t,r&&k(e.prototype,r),n&&k(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}();function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}function M(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,C(n.key),n)}}function $(t,e){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$(t,e)}function R(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function B(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?R(Object(r),!0).forEach((function(e){U(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function U(t,e,r){return(e=C(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function C(t){var e=function(t,e){if("object"!==N(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==N(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===N(e)?e:String(e)}var K,X,H=new q;K=window.XMLHttpRequest,window.__XMLHttpRequest=K,window.XMLHttpRequest=function(){var t=new K,e={open:t.open,send:t.send},r={name:o(4)},n=function(e){var n,o,i=r.name,u=r.url,a=r.method;t.responseType&&"text"!==t.responseType?"json"===t.responseType&&(n=t.response,o="json"):(n=t.responseText.toString(),o="text"),H.emit("xhr",{type:e,time:Date.now(),name:"xhr_".concat(i),url:u,detail:{status:t.status,method:a,responseType:o,response:n||void 0}})},i=function(){4===t.readyState&&(2===Math.floor(t.status/100)?n("xhr.ok"):n("xhr.fail"))};return Object.defineProperty(t,"open",{get:function(){return function(n,o){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],u={method:n,url:o};H.emit("request",u),Object.assign(r,B(B({},u),{},{async:i})),t.onreadystatechange&&(e.onreadystatechange=t.onreadystatechange);for(var a=e.open,c=arguments.length,f=new Array(c>3?c-3:0),s=3;s<c;s++)f[s-3]=arguments[s];return a.call.apply(a,[t,u.method,u.url,i].concat(f))}},configurable:!0}),Object.defineProperty(t,"send",{get:function(){return function(n){var o=e.send,u=r.async;Object.assign(r,{body:n}),function(){var t=r.name,e=r.url,n=r.method,o=r.async,i=r.body;H.emit("xhr",{type:"xhr.req",time:Date.now(),name:"xhr_".concat(t),url:e,detail:{method:n,async:o,body:i}})}();var a=o.call(t,n);return u||i(),a}},configurable:!0}),t.addEventListener("error",(function(){n("xhr.err")})),t.addEventListener("readystatechange",(function(t){i()})),t},X=window.fetch,window.__fetch=X,window.fetch=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.method,n=e.body,i=o(4);H.emit("fetch",{type:"fetch.init",time:Date.now(),name:"fetch_".concat(i),url:t,detail:{body:n,method:r}});var u={method:r,url:t};return H.emit("request",u),Promise.resolve().then((function(){return X(u.url,e)})).then((function(e){var n=e.status;return 2===Math.floor(n/100)?new Proxy(e,{get:function(o,u){return"json"===u||"text"===u?function(){return e[u]().then((function(e){return H.emit("fetch",{type:"fetch.ok",time:Date.now(),name:"fetch_".concat(i),url:t,detail:{status:n,data:e,method:r}}),e}))}:"function"==typeof e[u]?e[u].bind(e):e[u]}}):(H.emit("fetch",{type:"fetch.fail",time:Date.now(),name:"fetch_".concat(i),url:t,detail:{status:n,method:r}}),e)}),(function(e){var n;if(e instanceof Error){var o=e.name,u=e.message;n={method:r,type:o,err:u}}else n={method:r,err:e};H.emit("fetch",{type:"fetch.err",time:Date.now(),name:"fetch_".concat(i),url:t,detail:n})}))};var z=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&$(t,e)}(e,t);var r,n,o,i=e.prototype;return i.options=function(){return{xhr:!0,fetch:!0,ajaxResponse:!0,patchRequestId:!0}},i.registerXhr=function(){var t=this,e=function(e){t.anys.options.ajaxResponse||"xhr.ok"!==e.type||delete e.detail.response,t.anys.write(e)};return H.on("xhr",e),function(){return H.off("xhr",e)}},i.registerFetch=function(){var t=this,e=function(e){t.anys.options.ajaxResponse||"fetch.ok"!==e.type||delete e.detail.data,t.anys.write(e)};return H.on("fetch",e),function(){return H.off("fetch",e)}},i.registerPatchRequestId=function(){var t=this,e=function(e){var r=e.url,n=t.anys,o=P(r,{_request_id:n.traceId+n.requestId});e.url=o};return H.on("request",e),function(){return H.off("request",e)}},r=e,n&&M(r.prototype,n),o&&M(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}(_);function Y(t){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Y(t)}function F(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,W(n.key),n)}}function W(t){var e=function(t,e){if("object"!==Y(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==Y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===Y(e)?e:String(e)}var Z=function(){function t(t){this.anys=t}var e,r,n,i=t.prototype;return i.options=function(){return{namespace:new Error("options.namespace is required!")}},i.defines=function(){return{client:this.defineClientId.bind(this),trace:this.defineTraceId.bind(this)}},i.defineClientId=function(){var t=this.anys.options.namespace,e="Anys.".concat(t,".clientId"),r=localStorage.getItem(e);return r||(r=o(8),sessionStorage.setItem(e,r)),r},i.defineTraceId=function(){var t=this.anys.options.namespace,e="Anys.".concat(t,".traceId"),r=o(8);return sessionStorage.setItem(e,r),r},e=t,r&&F(e.prototype,r),n&&F(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}();function V(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.documentElement,r=t.nodeName,n=t.path;if(n)return n;if("BODY"===r||"HTML"===r||"HEAD"===r)return r;var o=[],i=t,u=t.parentNode,a=function(t){var e=t.nodeName,r=t.parentNode;return r?[].filter.call(r.childNodes,(function(t){return t.nodeName===e})).indexOf(t):-1};if("#"===r[0]){var c=a(t);o.push("".concat(r,":").concat(c)),u=(i=u).parentNode}for(;u&&i!==e;){var f=i.nodeName;if("BODY"===f||"HTML"===f||"HEAD"===f)o.push(f);else{var s=a(i);o.push("".concat(f.toLowerCase(),":").concat(s))}u=(i=u).parentNode}return o.reverse(),o.join("/")}function G(t){return G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},G(t)}function J(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Q(n.key),n)}}function Q(t){var e=function(t,e){if("object"!==G(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==G(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===G(e)?e:String(e)}function tt(t,e){return tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},tt(t,e)}var et=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&tt(t,e)}(e,t);var r,n,o,i=e.prototype;return i.options=function(){return{input:!0}},i.registerInput=function(){var t=this,e=function(e){return function(r){var n=r.target,o=r.type,i=r.inputType,u=r.data;if("insertCompositionText"!==i&&("compositionend"!==o||u)){var a=n.tagName,c=n.value;if(!n.getAttribute("anys-ignore")){var f=n.getAttribute("type"),s=e({tagName:a,value:c,type:f,target:n});if(s){var l={type:"input",time:Date.now(),el:V(n),detail:s};t.anys.write(l)}}}}},r=e((function(t){var e=t.tagName,r=t.value,n=t.type;return"INPUT"===e&&"radio"!==n&&"checkbox"!==n&&"password"!==n?{value:r,type:n}:"INPUT"===e&&"password"===n?{value:"***",type:n}:"TEXTAREA"===e?{value:r,type:"textarea"}:void 0})),n=e((function(t){var e=t.tagName,r=t.value,n=t.type;return"SELECT"===e?{value:r,type:"select"}:"INPUT"!==e||"radio"!==n&&"checkbox"!==n?void 0:{value:r,type:n}})),o=e((function(t){var e=t.tagName,r=t.value,n=t.type;return"TEXTAREA"===e?{value:r,type:"textarea"}:"INPUT"===e?{value:r,type:n}:void 0}));return document.addEventListener("input",r,!0),document.addEventListener("compositionend",r,!0),document.addEventListener("change",n,!0),document.addEventListener("paste",o,!0),function(){document.removeEventListener("input",r),document.removeEventListener("compositionend",r),document.removeEventListener("change",n),document.removeEventListener("paste",o)}},r=e,n&&J(r.prototype,n),o&&J(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}(_);function rt(t){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rt(t)}function nt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ot(n.key),n)}}function ot(t){var e=function(t,e){if("object"!==rt(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==rt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===rt(e)?e:String(e)}function it(t,e){return it=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},it(t,e)}var ut=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&it(t,e)}(e,t);var r,n,o,i=e.prototype;return i.options=function(){return{mouse:!("ontouchend"in document),click:!0,mousemove:!1,mousedown:!1,mouseup:!1,wheel:!1,contextmenu:!1}},i.addEventListener=function(t,e){if(this.anys.options.mouse){var r=this.createThrottleListener((function(e){var r=window,n=r.innerWidth,o=r.innerHeight,i=e.target,u=e.button,a=e.pageX,c=e.pageY;return{type:t,time:Date.now(),detail:{e:V(i),w:n,h:o,x:a,y:c,button:u}}}),e);return document.addEventListener(t,r,!0),function(){return document.removeEventListener(t,r)}}},i.registerClick=function(){return this.addEventListener("click")},i.registerMouseup=function(){return this.addEventListener("mouseup")},i.registerMousedown=function(){return this.addEventListener("mousedown")},i.registerContextmenu=function(){return this.addEventListener("contextmenu")},i.registerMousemove=function(){return this.addEventListener("mousemove",100)},i.registerWheel=function(){if(this.anys.options.mouse){var t="wheel",e=this.createThrottleListener((function(e){var r=e.target,n=e.deltaX,o=e.deltaY,i=e.deltaZ,u=e.deltaMode;return{type:t,time:Date.now(),detail:{e:V(r),deltaX:n,deltaY:o,deltaZ:i,mode:u}}}),100);return document.addEventListener(t,e),function(){return document.removeEventListener(t,e)}}},i.createThrottleListener=function(t,e){var r=this,n=0,o=0;return function(i){if(!n){var u=Date.now();if(!(e&&o+e>u)){var a=t(i);requestAnimationFrame((function(){r.anys.write(a),n=0,o=Date.now()})),n=1}}}},r=e,n&&nt(r.prototype,n),o&&nt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}(_);function at(t){return at="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},at(t)}function ct(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ft(n.key),n)}}function ft(t){var e=function(t,e){if("object"!==at(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==at(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===at(e)?e:String(e)}function st(t,e){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},st(t,e)}var lt={type:"window_activity.enter",time:Date.now()},pt=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&st(t,e)}(e,t);var r,n,o,i=e.prototype;return i.options=function(){return{activity:!0,deadTimeout:0}},i.init=function(){this.anys.options.activity&&this.anys.write(lt)},i.registerActivity=function(){var t=this,e=function(){if("hidden"===document.visibilityState){var e={type:"window_activity.focusout",time:Date.now()};t.anys.write(e)}else{var r={type:"window_activity.focusin",time:Date.now()};t.anys.write(r)}},r=function(){var e={type:"window_activity.unload",time:Date.now()};t.anys.write(e)};return window.addEventListener("beforeunload",r,!0),document.addEventListener("visibilitychange",e,!0),function(){window.removeEventListener("beforeunload",r),document.removeEventListener("visibilitychange",e)}},i.registerDeadTimeout=function(){var t=this,e=this.anys.options.deadTimeout;if(e){var r,n=function(){clearTimeout(r),r=setTimeout((function(){var e={type:"window_activity.dead",time:Date.now()};t.anys.write(e)}),e)};return document.addEventListener("keydown",n,!0),document.addEventListener("mousedown",n,!0),document.addEventListener("touchstart",n,!0),document.addEventListener("touchmove",n,!0),document.addEventListener("mousemove",n,!0),document.addEventListener("scroll",n,!0),window.addEventListener("resize",n,!0),function(){document.removeEventListener("keydown",n),document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n),document.removeEventListener("touchmove",n),document.removeEventListener("mousemove",n),document.removeEventListener("scroll",n),window.removeEventListener("resize",n)}}},r=e,n&&ct(r.prototype,n),o&&ct(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}(_);function yt(t){return yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yt(t)}function vt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,mt(n.key),n)}}function mt(t){var e=function(t,e){if("object"!==yt(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===yt(e)?e:String(e)}function bt(t,e){return bt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},bt(t,e)}var dt=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&bt(t,e)}(e,t);var r,n,o,i=e.prototype;return i.options=function(){return{url:!0}},i.registerUrl=function(){var t=this,e=function(){t.recordUrl()};return window.addEventListener("hashchange",e),window.addEventListener("popstate",e),this.recordUrl(),function(){window.removeEventListener("hashchange",e),window.removeEventListener("popstate",e)}},i.recordUrl=function(){var t=window.location.href,e=new URL(t),r=e.pathname.replace(/^([^/])/,"/$1"),n={type:"url",time:Date.now(),url:t,detail:{uri:r+(e.search?"?".concat(e.search):""),path:r,protocol:e.protocol.replace(":",""),host:e.hostname,port:e.port,search:e.search,hash:e.hash.replace("#","")}};this.anys.write(n)},r=e,n&&vt(r.prototype,n),o&&vt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}(_);function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function gt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,wt(n.key),n)}}function wt(t){var e=function(t,e){if("object"!==ht(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===ht(e)?e:String(e)}function Ot(t,e){return Ot=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ot(t,e)}var St=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ot(t,e)}(e,t);var r,n,o,i=e.prototype;return i.options=function(){var t="ontouchend"in document;return{touch:t,touchstart:t,touchend:t,touchmove:t}},i.addEventListener=function(t){var e=this;if(this.anys.options.touch){var r=0,n=function(n){if(!r){var o=window,i=o.innerWidth,u=o.innerHeight,a=n.target,c=n.identifier,f=n.force,s=n.pageX,l=n.pageY,p={type:t,time:Date.now(),detail:{e:V(a),width:i,height:u,x:s,y:l,identifier:c,force:f}};requestAnimationFrame((function(){e.anys.write(p),r=0})),r=1}};return document.addEventListener(t,n,!0),function(){return document.removeEventListener(t,n)}}},i.registerTouchmove=function(){return this.addEventListener("touchmove")},i.registerTouchend=function(){return this.addEventListener("touchend")},i.registerTouchstart=function(){return this.addEventListener("touchstart")},r=e,n&>(r.prototype,n),o&>(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}(_);function jt(t){return jt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jt(t)}function Pt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Et(n.key),n)}}function Et(t){var e=function(t,e){if("object"!==jt(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==jt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===jt(e)?e:String(e)}var xt=function(){function t(){this.queue=[],this.status=0}var e,r,n;return t.prototype.push=function(t){var e,r,n=this,o=new Promise((function(t,n){e=t,r=n})),i={runner:t,resolve:e,reject:r};this.queue.push(i);return this.status||function t(){setTimeout((function(){if(n.queue.length){var e=n.queue.shift(),r=e.runner,o=e.resolve,i=e.reject;r().then(o,i).finally(t)}else n.status=0}),0),n.status=1}(),o},e=t,r&&Pt(e.prototype,r),n&&Pt(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}();function At(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],c=!0,f=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){f=!0,o=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(f)throw o}}return a}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return _t(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _t(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function It(t){return It="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},It(t)}function Tt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,kt(n.key),n)}}function Lt(t,e,r){return e&&Tt(t.prototype,e),r&&Tt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function kt(t){var e=function(t,e){if("object"!==It(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==It(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===It(e)?e:String(e)}var Dt=function(){function t(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.name,r=t.version,n=void 0===r?1:r,o=t.stores,i=!e;e||(e="__indb__"),o&&Array.isArray(o)&&o.length||(o=[{name:"__indb__",isKv:!0}]),this.cache={},this.connection=null,this.name=e,this.version=n,this.stores=o;var u=indexedDB.open(e,n);if(u.onupgradeneeded=function(t){var e=t.target.result,r=Array.from(e.objectStoreNames),n=[];o.forEach((function(o){var i=null;if(r.indexOf(o.name)>-1)i=t.target.transaction.objectStore(o.name);else{var u=o.isKv?"key":o.primaryKeyPath,a=!o.isKv&&o.autoIncrement;i=e.createObjectStore(o.name,{keyPath:u,autoIncrement:a})}var c=i.indexNames;c&&c.length&&Array.from(c).forEach((function(t){return i.deleteIndex(t)})),o.indexes&&o.indexes.length&&o.indexes.forEach((function(t){i.createIndex(t.name,t.keyPath||t.name,{unique:t.unique,multiEntry:Array.isArray(t.keyPath)})})),n.push(o.name)})),r&&r.forEach((function(t){-1===n.indexOf(t)&&e.deleteObjectStore(t)}))},u.onblocked=function(t){console.error(Mt(new Error("indexedDB "+e+" is blocked")))},i)return this.use(e)}var e=t.prototype;return e.connect=function(){var t=this;return new Promise((function(e,r){var n=indexedDB.open(t.name,t.version);n.onerror=function(t){r(Mt(t))},n.onsuccess=function(t){e(t.target.result)}}))},e.use=function(t){var e=this.stores.find((function(e){return e.name===t}));if(!e)throw new Error("[InDB]: store ".concat(t," is not existing."));if(this.cache[t])return this.cache[t];var r=new qt({db:this,store:e});return e.isKv&&Object.defineProperties(r,{key:{value:function(t){return r.keys().then((function(e){return e&&e[t]}))}},getItem:{value:function(t){return r.get(t).then((function(t){return t&&t.value}))}},setItem:{value:function(t,e){return r.put({key:t,value:e})}},removeItem:{value:function(t){return r.delete(t)}}}),this.cache[t]=r,r},e.close=function(){return this.cache=null,this.stores=null,this.connect().then((function(t){t.close()}))},t.deleteDatabase=function(t){return new Promise((function(e,r){var n=indexedDB.deleteDatabase(t);n.onsuccess=function(){e()},n.onerror=function(t){r(t)}}))},t.databases=function(){return indexedDB.databases()},Lt(t)}(),qt=function(){function t(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.store,r=t.db;if("object"!==It(e)||!e.name||"string"!=typeof e.name)throw new Error("[InDBStore]: options.store should be a store config object.");if(!(r instanceof Dt))throw new Error("[InDBStore]: options.db should be an instanceof InDB.");this.db=r,this.store=e,this.name=e.name,this.primaryKeyPath=e.isKv?"key":e.primaryKeyPath,this._queue=[]}var e=t.prototype;return e.transaction=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=function(){var r=t.name,n=e?"readwrite":"readonly",o=t.db.connection;return(o?Promise.resolve(o):t.db.connect()).then((function(e){t.db.connection=e;var o=e.transaction(r,n),i=function(){t.db.connection=null,t._queue.shift()};return o.oncomplete=i,o.onabort=i,o.onerror=i,o}))},n=this._queue[this._queue.length-1],o=n?n.then((function(){return r()})):r();return this._queue.push(o),o},e.objectStore=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.name;return this.transaction(t).then((function(t){return t.objectStore(e)}))},e.cursor=function(t){var e=t.index,r=t.range,n=t.direction,o=t.onTouch,i=t.onDone,u=t.onError,a=t.writable,c=void 0!==a&&a;return this.objectStore(c).then((function(t){var a=e?t.index(e):t,c=a.openCursor(r,n);c.onsuccess=function(t){var e=t.target.result;e?o(e,a):i(e,a)},c.onerror=function(t){u(Mt(t))}}))},e.request=function(t){var e=this,r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).writable,n=void 0!==r&&r;return new Promise((function(r,o){e.objectStore(n).then((function(e){var n=t(e);n.onsuccess=function(t){var e=t.target.result;r(e)},n.onerror=function(t){o(Mt(t))}}))}))},e.iterate=function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.index,o=r.range,i=r.writable,u=void 0!==i&&i,a=r.direction,c=void 0===a?"next":a;return new Promise((function(r,i){e.cursor({index:n,range:o,writable:u,direction:c,onTouch:function(e,n){t(e,(function(){return e.continue()}),(function(){n.transaction.commit(),r()}))},onDone:function(){r()},onError:function(t){i(t)}})}))},e.batch=function(t){var e=this,r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).writable,n=void 0===r||r;return this.transaction(n).then((function(r){var n=e.name,o=[],i=r.objectStore(n);return t.forEach((function(t){var e=new Promise((function(e,r){var n=t(i);n.onsuccess=function(t){var r=t.target.result;e(r)},n.onerror=function(t){r(Mt(t))}}));o.push(e)})),Promise.all(o)}))},e.get=function(t){if(!Array.isArray(t))return this.request((function(e){return e.get(t)}));var e=t.map((function(t){return function(e){return e.get(t)}}));return this.batch(e,{writable:!1})},e.keys=function(){var t=this.primaryKeyPath,e=[];return this.each((function(r){var n=Nt(r,t);e.push(n)})).then((function(){return e}))},e.all=function(){var t=[];return this.each((function(e){t.push(e)})).then((function(){return t}))},e.count=function(){return this.request((function(t){return t.count()}))},e.each=function(t){return this.iterate((function(e,r){var n=e.value;t(n),r()}))},e.reverse=function(t){return this.iterate((function(e,r){var n=e.value;t(n),r()}),{direction:"prev"})},e.some=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return new Promise((function(n,o){var i,u=[],a=0,c=r,f=r+e;r<0&&(i="prev",e=Math.min(e,-r),f=(c=-(r+e)||0)+e),t.iterate((function(t,e,r){a<c?(a++,e()):a<f?(u.push(t.value),a++,e()):r()}),{direction:i}).then((function(){r<0&&u.reverse(),n(u)})).catch(o)}))},e.first=function(){return this.some(1).then((function(t){return t[0]}))},e.last=function(){return this.some(1,-1).then((function(t){return t[0]}))},e.find=function(t,e){return this.request((function(r){return r.index(t).get(e)}))},e.query=function(t,e,r){var n=this,o=function(){switch(r){case">":return IDBKeyRange.lowerBound(e,!0);case">=":return IDBKeyRange.lowerBound(e);case"<":return IDBKeyRange.upperBound(e,!0);case"<=":return IDBKeyRange.upperBound(e);case"%":case"!=":case"in":return;default:return IDBKeyRange.only(e)}}(),i=[];return new Promise((function(u,a){n.cursor({index:t,range:o,onTouch:function(t,n){var o=t.value,u=Nt(o,n.keyPath);"!="===r?u!==e&&i.push(o):"%"===r?"string"==typeof u&&u.indexOf(e)>-1&&i.push(o):"in"===r?Array.isArray(e)&&e.indexOf(u)>-1&&i.push(o):i.push(o),t.continue()},onDone:function(){u(i)},onError:function(t){a(t)}})}))},e.select=function(){var t=this.store.indexes||[],e={};t.forEach((function(t){var r=t.name,n=t.keyPath;e[r]=n}));for(var r=function(t,e,r){if(void 0===t)return!1;switch(r){case">":return t>e;case">=":return t>=e;case"<":return t<e;case"<=":return t<=e;case"!=":return t!==e;case"%":return"string"==typeof t&&t.indexOf(e)>-1;case"in":return Array.isArray(e)&&e.indexOf(t)>-1;default:return t===e}},n=function(t,e,n){if(!e.length&&!n.length)return!1;for(var o=0,i=e.length;o<i;o++){var u=e[o],a=u.keyPath,c=u.value,f=u.compare,s=Nt(t,a);if(!r(s,c,f))return!1}if(!n.length)return!0;for(var l=0,p=n.length;l<p;l++){var y=n[l],v=y.keyPath,m=y.value,b=y.compare,d=Nt(t,v);if(r(d,m,b))return!0}return!1},o=[],i=arguments.length,u=new Array(i),a=0;a<i;a++)u[a]=arguments[a];u.forEach((function(t){for(var r=[],n=[],i=0,u=t.length;i<u;i++){var a=t[i],c=a.key,f=a.value,s=a.compare,l=a.optional,p=e[c]||c;l?r.push({keyPath:p,value:f,compare:s}):n.push({keyPath:p,value:f,compare:s})}o.push([n,r])}));var c=[];return this.each((function(t){(function(t){for(var e=0,r=o.length;e<r;e++){var i=At(o[e],2),u=i[0],a=i[1];if(n(t,u,a))return!0}return!1})(t)&&c.push(t)})).then((function(){return c}))},e.add=function(t,e){if(Array.isArray(t)){var r=t;if(r.length<2)return this.add(t[0],e);var n=r.map((function(t){return function(r){return r.add(t,e)}}));return this.batch(n)}return t?this.request((function(r){return r.add(t,e)}),{writable:!0}):Promise.resolve()},e.put=function(t,e){if(Array.isArray(t)){var r=t;if(r.length<2)return this.put(r[0],e);var n=r.map((function(t){return function(r){return r.put(t,e)}}));return this.batch(n)}return t?this.request((function(r){return r.put(t,e)}),{writable:!0}):Promise.resolve()},e.delete=function(t){if(Array.isArray(t)){var e=t;if(e.length<2)return this.delete(e[0]);var r=e.map((function(t){return function(e){return e.delete(t)}}));return this.batch(r)}return t?this.request((function(e){return e.delete(t)}),{writable:!0}):Promise.resolve()},e.remove=function(t){var e=this.primaryKeyPath;if(Array.isArray(t)){var r=t;if(r.length<2)return this.remove(r[0]);var n=r.map((function(t){var r=Nt(t,e);return function(t){return t.delete(r)}}));return this.batch(n)}if(!t)return Promise.resolve();var o=Nt(t,e);return o?this.delete(o):Promise.resolve()},e.clear=function(){return this.request((function(t){return t.clear()}),{writable:!0})},Lt(t)}();function Nt(t,e){if(null!=e){if(!Array.isArray(e)){var r=function(t){return t.toString().split(/\.|\[|\]/).filter((function(t){return!!t}))}(e);if(!r.length)return t;for(var n=t,o=0,i=r.length;o<i;o++){var u=r[o];if(void 0===n[u])return;n=n[u]}return n}for(var a=0,c=e.length;a<c;a++){var f=Nt(t,e[a]);if(void 0!==f)return f}}}function Mt(t){var e=t.message;return t.message=-1===e.indexOf("[IndexedDB]")?"[IndexedDB]: "+e:e,t}function $t(t){return $t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$t(t)}function Rt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Bt(n.key),n)}}function Bt(t){var e=function(t,e){if("object"!==$t(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==$t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===$t(e)?e:String(e)}var Ut=function(){function t(t){this.anys=t}var e,r,n,o=t.prototype;return o.options=function(){return{namespace:new Error("options.namespace is required!"),autoReport:!1,expireTime:1728e5}},o.init=function(){var t=this,e="anyslogs",r=new Dt({name:this.anys.options.namespace,version:1,stores:[{name:e,primaryKeyPath:"_id",autoIncrement:!0}]});this.db=r.use(e),this.queue=new xt;var n=this.anys.options.expireTime;if(n)var o=0,i=setInterval((function(){t.queue.push((function(){return t.db.some(100,o)})).then((function(e){if(e.length){var r=Date.now(),u=[];e.forEach((function(t){var e=t._id,o=t.time;r-o>n&&u.push(e)})),u.length&&t.queue.push((function(){return t.db.delete(u)})),o+=100,o-=u.length}else clearInterval(i)}))}),1e4)},o.write=function(t){var e=this;this.queue.push((function(){return e.db.add(t)})).then((function(r){e.anys.emit("writeOfflineLog",{id:r,data:t})}))},o.read=function(t){if(t){if(!Array.isArray(t))return;if(t.some((function(t){return!t.key})))return}else t=[{key:"client",value:this.anys.clientId},{key:"trace",value:this.anys.traceId}];return this.select(t)},o.clear=function(t){var e=this;return this.queue.push((function(){return e.db.remove(t)})).catch((function(){}))},o.select=function(t){var e=this;return this.queue.push((function(){return e.db.select(t)}))},o.remove=function(t){var e=this;return this.queue.push((function(){return e.db.delete(t)})).catch((function(){}))},e=t,r&&Rt(e.prototype,r),n&&Rt(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}();function Ct(t){return Ct="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ct(t)}function Kt(t){return function(t){if(Array.isArray(t))return Ht(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Xt(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Xt(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function zt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Yt(n.key),n)}}function Yt(t){var e=function(t,e){if("object"!==Ct(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==Ct(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===Ct(e)?e:String(e)}function Ft(t,e){return Ft=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ft(t,e)}var Wt=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ft(t,e)}(e,t);var r,n,o,i=e.prototype;return i.options=function(){return{mutation:!0}},i.registerMutation=function(){var t=this,e=this.createObserver((function(e){var r={type:"mutation",time:Date.now(),detail:e};t.anys.write(r)}));return window.addEventListener("load",(function(){e.observe(document,{characterData:!0,attributes:!0,childList:!0,subtree:!0}),t.recordSnapshot(),Zt(document.documentElement)})),function(){e.disconnect()}},i.recordSnapshot=function(){var t=function(){var t,e=document.doctype,r=e.name,n=e.publicId,o=e.systemId,i={name:r,publicId:n,systemId:o},u=Vt(document.documentElement.innerHTML),a={},c=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Xt(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){a=!0,i=t},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw i}}}}(document.querySelector("html").attributes);try{for(c.s();!(t=c.n()).done;){var f=t.value,s=f.name,l=f.value;a[s]=l}}catch(t){c.e(t)}finally{c.f()}var p=(y=document.querySelectorAll("input, textarea, select"),v=[],Array.from(y).forEach((function(t){var e=V(t),r="password"===t.type?"***":t.value;v.push({el:e,value:r})})),v);var y,v;return{doctype:i,attrs:a,html:u,values:p}}(),e=window.location.href,r=new URL(e),n=r.pathname.replace(/^([^/])/,"/$1");this.anys.write({type:"snapshot",time:Date.now(),url:{uri:n+(r.search?"?".concat(r.search):""),path:n,protocol:r.protocol.replace(":",""),host:r.hostname,port:r.port,search:r.search,hash:r.hash.replace("#","")},detail:t})},i.createObserver=function(t){var e=new MutationObserver((function(e){var r=[];Kt(e).reverse().forEach((function(t){var e=t.type,n=t.target,o=t.attributeName,i=t.oldValue;if(!function(t){var e;if(null!==(e=t.hasAttribute)&&void 0!==e&&e.call(t,"anys-ignore"))return!0;for(var r=t.parentNode;r;){var n,o;if(null!==(n=(o=r).hasAttribute)&&void 0!==n&&n.call(o,"anys-ignore"))return!0;r=r.parentNode}return!1}(n)){if("attributes"===e){if(n.getAttribute(o)===i)return;if(r.find((function(t){return t.type===e&&t.target===n&&t.attributeName===o})))return}else if("characterData"===e){var u=n.data;if(u===i)return;if(r.find((function(t){return t.type===e&&t.target===n&&t.target.data===u})))return}r.push(t)}})),r.reverse();var n=[];r.forEach((function(t){var e=t.type,r=t.target,o=t.attributeName,i=t.oldValue,u=r.path||V(r),a=function(t){return V(t).replace(u+"/","")};if("attributes"===e){var c=r.getAttribute(o),f=i;n.push({type:"attribute",target:u,name:o,next:c,prev:f})}else if("characterData"===e){var s=r.data,l=i;n.push({type:"text",target:u,next:s,prev:l})}else if("childList"===e){if("TEXTAREA"===r.nodeName)return;var p=t.removedNodes,y=t.addedNodes,v=t.previousSibling,m=t.nextSibling,b=[],d=Array.from(p).map((function(t){if(!document.body.contains(t)){var e=t.path?a(t):null,r=v?V(v):null,n=m?V(m):null,o={};return e?o.node=e:(o.before=r,o.after=n),o}b.push({node:t,path:V(t)})})).filter(Boolean),h=[],g=Array.from(y).map((function(t){var e=t.nextSibling?a(t.nextSibling):null,r=b.find((function(e){return e.node===t}));if(!r){var n="#text"===t.nodeName,o="#comment"===t.nodeName,i=n?t.data:null,u=o?t.data:null;return{text:i,html:n||o?null:Vt(t.outerHTML),comment:u,sibling:e}}h.push({node:r.path,sibling:e})})).filter(Boolean);n.push({type:"children",target:u,remove:d,insert:g,move:h}),Zt(r)}})),t(n)}));return Zt(document),e},r=e,n&&zt(r.prototype,n),o&&zt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}(_);function Zt(t){if(t!==document){var e=V(t);t.path=e}var r=t.childNodes;Array.from(r).forEach((function(t){Zt(t)}))}function Vt(t){return t.replace(/<script([^]*?)>([^]*?)<\/script>/gm,"<noscript$1></noscript>").replace(/<noscript([^]*?)>([^]*?)<\/noscript>/gm,"<noscript$1></noscript>").replace(/<link([^]*?)as="script"([^]*?)>/g,"<link$1$2>").replace(/\n\n*\s*\n*\n/gm,"\n")}function Gt(t){return Gt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gt(t)}function Jt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Qt(n.key),n)}}function Qt(t){var e=function(t,e){if("object"!==Gt(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==Gt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===Gt(e)?e:String(e)}function te(t,e){return te=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},te(t,e)}var ee=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&te(t,e)}(e,t);var r,n,o,i=e.prototype;return i.options=function(){return{size:!0}},i.createRecordLog=function(){var t=window,e=t.innerWidth,r=t.innerHeight;return{type:"window_size",time:Date.now(),detail:{width:e,height:r}}},i.registerSize=function(){var t,e=this,r=function(){clearTimeout(t);var r=e.createRecordLog();t=setTimeout((function(){e.anys.write(r)}),100)};return this.recordSize(),window.addEventListener("resize",r),function(){window.removeEventListener("resize",r)}},i.recordSize=function(){var t=this.createRecordLog();this.anys.write(t)},r=e,n&&Jt(r.prototype,n),o&&Jt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}(_);function re(t){return re="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},re(t)}function ne(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,oe(n.key),n)}}function oe(t){var e=function(t,e){if("object"!==re(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==re(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===re(e)?e:String(e)}function ie(t,e){return ie=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ie(t,e)}var ue=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ie(t,e)}(e,t);var r,n,o,i=e.prototype;return i.options=function(){return{scroll:!0}},i.registerScroll=function(){var t=this,e=0,r=function(r){if(!e){var n,o=r.target;if(r.bubbles){var i=window,u=i.scrollX,a=i.scrollY;n={type:"window_scroll",time:Date.now(),detail:{scrollX:u,scrollY:a}}}else{var c=o.scrollLeft,f=o.scrollTop;n={type:"scroll",time:Date.now(),target:V(o),detail:{scrollLeft:c,scrollTop:f}}}requestAnimationFrame((function(){t.anys.write(n),e=0})),e=1}};return window.addEventListener("scroll",r,!0),function(){window.removeEventListener("scroll",r)}},r=e,n&&ne(r.prototype,n),o&&ne(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}(_);function ae(t){return ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ae(t)}var ce=["_id"];function fe(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function se(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],c=!0,f=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){f=!0,o=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(f)throw o}}return a}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return le(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return le(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function le(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function pe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ye(n.key),n)}}function ye(t){var e=function(t,e){if("object"!==ae(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==ae(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===ae(e)?e:String(e)}function ve(t,e){return ve=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ve(t,e)}var me=function(t){function e(e,r){var n,o=se(r,4),i=o[0],u=o[1],a=o[2],c=o[3];return(n=t.call(this,e)||this).offlineStore=i,n.urlMonitor=u,n.windowSizeMonitor=a,n.DOMMutationMonitor=c,n.cache={},n}!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ve(t,e)}(e,t);var r,n,o,i=e.prototype;return i.options=function(){var t="ontouchend"in document;return{touch:t,mouse:!t,click:!1,mousedown:!0,mousemove:!0,mouseup:!0,autoReport:!1,reportUrl:new Error("options.reportUrl is required!"),reportInterval:1e4,reportParams:null}},i.registerAutoReport=function(){var t=this,e=this.anys.clientId,r=function(r){var n=r.prev;t.anys.report([{key:"client",value:e},{key:"trace",value:n}]),t.cache={},t.urlMonitor.recordUrl(),t.windowSizeMonitor.recordSize(),t.DOMMutationMonitor.recordSnapshot()};this.anys.on("refreshTraceId",r);var n=setInterval((function(){t.anys.report()}),this.anys.options.reportInterval),o=0,i=function(){if(!o){o=1;var e=Object.keys(t.cache),r=Object.values(t.cache);e.length&&(t.offlineStore.remove(e),navigator.sendBeacon(t.anys.options.reportUrl,JSON.stringify(r)),t.cache={})}};window.addEventListener("beforeunload",i),window.addEventListener("pagehide",i),window.addEventListener("unload",i);var u=function(e){var r=e.id,n=e.data;t.cache[r]=n};return this.anys.on("writeOfflineLog",u),function(){t.anys.off("refreshTraceId",r),t.anys.off("writeOfflineLog",u),clearInterval(n),window.removeEventListener("beforeunload",i)}},i.read=function(t){return this.offlineStore.read(t)},i.send=function(t){var e=this,r=[],n=0;t.forEach((function(t){r[n]=r[n]||[],r[n].push(t),r[n].length>200&&n++}));var o=r.map((function(t){var r=[],n=[];if(t.forEach((function(t){var e=t._id,o=fe(t,ce);n.push(e),r.push(o)})),r.length){var o=e.anys.options,i=o.reportUrl,u=o.reportParams;return function(t,e){return new Promise((function(r,n){var o=new(window.__XMLHttpRequest||window.XMLHttpRequest);o.open("POST",t,!0),o.onreadystatechange=function(){4==o.readyState&&(200==o.status?r(o.responseText):n(new Error("ajax post fail with status ".concat(o.status))))},o.onerror=n,o.send(JSON.stringify(e))}))}(u?P(i,u):i,{data:r}).then((function(){n.forEach((function(t){delete e.cache[t]}))}))}}));return Promise.all(o)},i.clear=function(){this.cache={}},r=e,n&&pe(r.prototype,n),o&&pe(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}(_);function be(t){return be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},be(t)}function de(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function he(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?de(Object(r),!0).forEach((function(e){ge(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):de(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ge(t,e,r){return(e=Oe(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function we(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Oe(n.key),n)}}function Oe(t){var e=function(t,e){if("object"!==be(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==be(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===be(e)?e:String(e)}function Se(t,e){return Se=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Se(t,e)}me.dependencies=[Ut,dt,ee,Wt,Z,z,et,ut,pt,St,ue];var je=function(t){function e(){return t.apply(this,arguments)||this}var r,n,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Se(t,e)}(e,t),e.prototype.auth=function(t){this.options.reportParams=Object.assign(this.options.reportParams||{},t)},r=e,n&&we(r.prototype,n),o&&we(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}(d),Pe=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new je(he(he({namespace:"AnysTracer",autoReport:!1},t),{},{plugins:he(he({},t.plugins||{}),{},{recorder:me})}))}}();var r=anys="undefined"==typeof anys?{}:anys;for(var n in e)r[n]=e[n];e.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})}();
|
|
2
2
|
//# sourceMappingURL=index.js.map
|